Built motion from commit (unavailable).|2.5.22
[motion2.git] / server / api / automation / automation.controller.js
index c771dc6..e9854f9 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x9f91=['then','destroy','error','stack','name','send','index','map','Automation','fieldName','key','model','query','keys','filters','intersection','attributes','fields','length','hasOwnProperty','order','sort','where','pick','filter','merge','type','options','includeAll','include','findAll','show','params','find','create','update','body','catch','addConditions','getConditions','findOne','rawAttributes','nolimit','addActions','Action','getActions','html-pdf','eml-format','fast-json-patch','request-promise','bluebird','mustache','util','path','sox','to-csv','ejs','squel','crypto','jsforce','desk.js','querystring','papaparse','../../components/auth/service','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../mysqldb','sendStatus','end','status','json','offset','limit','set','Content-Range','reject','save'];(function(_0x585756,_0x3d9a9b){var _0xb89469=function(_0x4821b1){while(--_0x4821b1){_0x585756['push'](_0x585756['shift']());}};_0xb89469(++_0x3d9a9b);}(_0x9f91,0xce));var _0x19f9=function(_0x5a3cf0,_0x160a68){_0x5a3cf0=_0x5a3cf0-0x0;var _0x5a64ee=_0x9f91[_0x5a3cf0];return _0x5a64ee;};'use strict';var pdf=require(_0x19f9('0x0'));var emlformat=require(_0x19f9('0x1'));var rimraf=require('rimraf');var zipdir=require('zip-dir');var jsonpatch=require(_0x19f9('0x2'));var rp=require(_0x19f9('0x3'));var moment=require('moment');var BPromise=require(_0x19f9('0x4'));var Mustache=require(_0x19f9('0x5'));var util=require(_0x19f9('0x6'));var path=require(_0x19f9('0x7'));var sox=require(_0x19f9('0x8'));var csv=require(_0x19f9('0x9'));var ejs=require(_0x19f9('0xa'));var fs=require('fs');var _=require('lodash');var squel=require(_0x19f9('0xb'));var crypto=require(_0x19f9('0xc'));var jsforce=require(_0x19f9('0xd'));var deskjs=require(_0x19f9('0xe'));var toCsv=require(_0x19f9('0x9'));var querystring=require(_0x19f9('0xf'));var Papa=require(_0x19f9('0x10'));var Redis=require('ioredis');var authService=require(_0x19f9('0x11'));var qs=require('../../components/parsers/qs');var as=require(_0x19f9('0x12'));var hardwareService=require(_0x19f9('0x13'));var logger=require(_0x19f9('0x14'))(_0x19f9('0x15'));var utils=require(_0x19f9('0x16'));var config=require('../../config/environment');var db=require(_0x19f9('0x17'))['db'];function respondWithStatusCode(_0x4a4145,_0x41789d){_0x41789d=_0x41789d||0xcc;return function(_0x3d7c7a){if(_0x3d7c7a){return _0x4a4145[_0x19f9('0x18')](_0x41789d);}return _0x4a4145['status'](_0x41789d)[_0x19f9('0x19')]();};}function respondWithResult(_0x23fb1b,_0xa8c9b0){_0xa8c9b0=_0xa8c9b0||0xc8;return function(_0x2fdbfb){if(_0x2fdbfb){return _0x23fb1b[_0x19f9('0x1a')](_0xa8c9b0)[_0x19f9('0x1b')](_0x2fdbfb);}};}function respondWithFilteredResult(_0x4b30ea,_0x54580d){return function(_0x12b73e){if(_0x12b73e){var _0x146c1b=_0x12b73e['count'],_0x3d0b3f=_0x54580d[_0x19f9('0x1c')],_0x119bd2=_0x54580d[_0x19f9('0x1c')]+_0x54580d[_0x19f9('0x1d')],_0x455871;if(_0x119bd2>=_0x146c1b){_0x119bd2=_0x146c1b;_0x455871=0xc8;}else{_0x455871=0xce;}_0x4b30ea[_0x19f9('0x1a')](_0x455871);return _0x4b30ea[_0x19f9('0x1e')](_0x19f9('0x1f'),_0x3d0b3f+'-'+_0x119bd2+'/'+_0x146c1b)[_0x19f9('0x1b')](_0x12b73e);}return null;};}function patchUpdates(_0xc3ee1a){return function(_0x53c553){try{jsonpatch['apply'](_0x53c553,_0xc3ee1a,!![]);}catch(_0x3f146c){return BPromise[_0x19f9('0x20')](_0x3f146c);}return _0x53c553[_0x19f9('0x21')]();};}function saveUpdates(_0x1eae40,_0xd38fa7){return function(_0x3c0b81){if(_0x3c0b81){return _0x3c0b81['update'](_0x1eae40)[_0x19f9('0x22')](function(_0x49a70c){return _0x49a70c;});}return null;};}function removeEntity(_0x1080c9,_0x3dbc1a){return function(_0x4bec17){if(_0x4bec17){return _0x4bec17[_0x19f9('0x23')]()['then'](function(){_0x1080c9[_0x19f9('0x1a')](0xcc)[_0x19f9('0x19')]();});}};}function handleEntityNotFound(_0x477022,_0x1b8a5e){return function(_0x3388d4){if(!_0x3388d4){_0x477022[_0x19f9('0x18')](0x194);}return _0x3388d4;};}function handleError(_0xb9b52a,_0x51e80d){_0x51e80d=_0x51e80d||0x1f4;return function(_0x3a24bf){logger[_0x19f9('0x24')](_0x3a24bf[_0x19f9('0x25')]);if(_0x3a24bf['name']){delete _0x3a24bf[_0x19f9('0x26')];}_0xb9b52a[_0x19f9('0x1a')](_0x51e80d)[_0x19f9('0x27')](_0x3a24bf);};}exports[_0x19f9('0x28')]=function(_0x3c7c5f,_0x28656a){var _0x573370={},_0x41036b={},_0x3bcf05={'count':0x0,'rows':[]};var _0x256518=_[_0x19f9('0x29')](db[_0x19f9('0x2a')]['rawAttributes'],function(_0x4c0299){return{'name':_0x4c0299[_0x19f9('0x2b')],'type':_0x4c0299['type'][_0x19f9('0x2c')]};});_0x41036b[_0x19f9('0x2d')]=_[_0x19f9('0x29')](_0x256518,'name');_0x41036b[_0x19f9('0x2e')]=_[_0x19f9('0x2f')](_0x3c7c5f[_0x19f9('0x2e')]);_0x41036b[_0x19f9('0x30')]=_[_0x19f9('0x31')](_0x41036b[_0x19f9('0x2d')],_0x41036b['query']);_0x573370[_0x19f9('0x32')]=_[_0x19f9('0x31')](_0x41036b['model'],qs[_0x19f9('0x33')](_0x3c7c5f[_0x19f9('0x2e')][_0x19f9('0x33')]));_0x573370['attributes']=_0x573370[_0x19f9('0x32')][_0x19f9('0x34')]?_0x573370[_0x19f9('0x32')]:_0x41036b['model'];if(!_0x3c7c5f['query'][_0x19f9('0x35')]('nolimit')){_0x573370[_0x19f9('0x1d')]=qs[_0x19f9('0x1d')](_0x3c7c5f['query']['limit']);_0x573370['offset']=qs[_0x19f9('0x1c')](_0x3c7c5f[_0x19f9('0x2e')][_0x19f9('0x1c')]);}_0x573370[_0x19f9('0x36')]=qs[_0x19f9('0x37')](_0x3c7c5f[_0x19f9('0x2e')]['sort']);_0x573370[_0x19f9('0x38')]=qs[_0x19f9('0x30')](_[_0x19f9('0x39')](_0x3c7c5f[_0x19f9('0x2e')],_0x41036b['filters']),_0x256518);if(_0x3c7c5f[_0x19f9('0x2e')][_0x19f9('0x3a')]){_0x573370['where']=_[_0x19f9('0x3b')](_0x573370[_0x19f9('0x38')],{'$or':_[_0x19f9('0x29')](_0x256518,function(_0x18a760){if(_0x18a760[_0x19f9('0x3c')]!=='VIRTUAL'){var _0x193993={};_0x193993[_0x18a760[_0x19f9('0x26')]]={'$like':'%'+_0x3c7c5f[_0x19f9('0x2e')][_0x19f9('0x3a')]+'%'};return _0x193993;}})});}_0x573370=_[_0x19f9('0x3b')]({},_0x573370,_0x3c7c5f[_0x19f9('0x3d')]);var _0x7754ce={'where':_0x573370[_0x19f9('0x38')]};return db[_0x19f9('0x2a')]['count'](_0x7754ce)[_0x19f9('0x22')](function(_0x5e9916){_0x3bcf05['count']=_0x5e9916;if(_0x3c7c5f[_0x19f9('0x2e')][_0x19f9('0x3e')]){_0x573370[_0x19f9('0x3f')]=[{'all':!![]}];}return db['Automation'][_0x19f9('0x40')](_0x573370);})[_0x19f9('0x22')](function(_0x4018ed){_0x3bcf05['rows']=_0x4018ed;return _0x3bcf05;})[_0x19f9('0x22')](respondWithFilteredResult(_0x28656a,_0x573370))['catch'](handleError(_0x28656a,null));};exports[_0x19f9('0x41')]=function(_0xba9988,_0x5b1665){var _0x2067d0={'raw':![],'where':{'id':_0xba9988[_0x19f9('0x42')]['id']}},_0x150528={};_0x150528[_0x19f9('0x2d')]=_[_0x19f9('0x2f')](db[_0x19f9('0x2a')]['rawAttributes']);_0x150528[_0x19f9('0x2e')]=_[_0x19f9('0x2f')](_0xba9988[_0x19f9('0x2e')]);_0x150528['filters']=_[_0x19f9('0x31')](_0x150528[_0x19f9('0x2d')],_0x150528[_0x19f9('0x2e')]);_0x2067d0['attributes']=_[_0x19f9('0x31')](_0x150528['model'],qs[_0x19f9('0x33')](_0xba9988[_0x19f9('0x2e')][_0x19f9('0x33')]));_0x2067d0[_0x19f9('0x32')]=_0x2067d0[_0x19f9('0x32')][_0x19f9('0x34')]?_0x2067d0[_0x19f9('0x32')]:_0x150528[_0x19f9('0x2d')];if(_0xba9988[_0x19f9('0x2e')][_0x19f9('0x3e')]){_0x2067d0[_0x19f9('0x3f')]=[{'all':!![]}];}_0x2067d0=_[_0x19f9('0x3b')]({},_0x2067d0,_0xba9988['options']);return db[_0x19f9('0x2a')][_0x19f9('0x43')](_0x2067d0)[_0x19f9('0x22')](handleEntityNotFound(_0x5b1665,null))[_0x19f9('0x22')](respondWithResult(_0x5b1665,null))['catch'](handleError(_0x5b1665,null));};exports[_0x19f9('0x44')]=function(_0x1cda36,_0x1c199a){return db[_0x19f9('0x2a')]['create'](_0x1cda36['body'],{})[_0x19f9('0x22')](respondWithResult(_0x1c199a,0xc9))['catch'](handleError(_0x1c199a,null));};exports[_0x19f9('0x45')]=function(_0x2ad1b4,_0x14e931){if(_0x2ad1b4[_0x19f9('0x46')]['id']){delete _0x2ad1b4['body']['id'];}return db[_0x19f9('0x2a')][_0x19f9('0x43')]({'where':{'id':_0x2ad1b4[_0x19f9('0x42')]['id']}})[_0x19f9('0x22')](handleEntityNotFound(_0x14e931,null))[_0x19f9('0x22')](saveUpdates(_0x2ad1b4['body'],null))[_0x19f9('0x22')](respondWithResult(_0x14e931,null))[_0x19f9('0x47')](handleError(_0x14e931,null));};exports['destroy']=function(_0x15487d,_0x2579dd){return db[_0x19f9('0x2a')]['find']({'where':{'id':_0x15487d[_0x19f9('0x42')]['id']}})['then'](handleEntityNotFound(_0x2579dd,null))[_0x19f9('0x22')](removeEntity(_0x2579dd,null))['catch'](handleError(_0x2579dd,null));};exports[_0x19f9('0x48')]=function(_0xacfbe2,_0xd4b987,_0x4bb389){return db['Condition'][_0x19f9('0x43')]({'where':{'id':_0xacfbe2[_0x19f9('0x42')]['id']}})[_0x19f9('0x22')](handleEntityNotFound(_0xd4b987,null))[_0x19f9('0x22')](function(_0x4475ea){if(_0x4475ea){return _0x4475ea['addConditions'](_0xacfbe2[_0x19f9('0x46')]['ids'],_['omit'](_0xacfbe2[_0x19f9('0x46')],['ids','id'])||{});}})['then'](respondWithResult(_0xd4b987,null))[_0x19f9('0x47')](handleError(_0xd4b987,null));};exports[_0x19f9('0x49')]=function(_0x3f834b,_0x271880,_0x39972d){var _0x51303b={};var _0x3fccc7={};var _0x5d090c;var _0x552b80;return db['Automation'][_0x19f9('0x4a')]({'where':{'id':_0x3f834b['params']['id']}})[_0x19f9('0x22')](handleEntityNotFound(_0x271880,null))[_0x19f9('0x22')](function(_0x40ee62){if(_0x40ee62){_0x5d090c=_0x40ee62;_0x3fccc7[_0x19f9('0x2d')]=_[_0x19f9('0x2f')](db['Condition'][_0x19f9('0x4b')]);_0x3fccc7['query']=_[_0x19f9('0x2f')](_0x3f834b[_0x19f9('0x2e')]);_0x3fccc7[_0x19f9('0x30')]=_[_0x19f9('0x31')](_0x3fccc7[_0x19f9('0x2d')],_0x3fccc7[_0x19f9('0x2e')]);_0x51303b[_0x19f9('0x32')]=_[_0x19f9('0x31')](_0x3fccc7[_0x19f9('0x2d')],qs['fields'](_0x3f834b['query'][_0x19f9('0x33')]));_0x51303b['attributes']=_0x51303b['attributes'][_0x19f9('0x34')]?_0x51303b['attributes']:_0x3fccc7[_0x19f9('0x2d')];_0x51303b[_0x19f9('0x36')]=qs[_0x19f9('0x37')](_0x3f834b[_0x19f9('0x2e')][_0x19f9('0x37')]);_0x51303b[_0x19f9('0x38')]=qs[_0x19f9('0x30')](_[_0x19f9('0x39')](_0x3f834b[_0x19f9('0x2e')],_0x3fccc7['filters']));if(_0x3f834b[_0x19f9('0x2e')][_0x19f9('0x3a')]){_0x51303b[_0x19f9('0x38')]=_[_0x19f9('0x3b')](_0x51303b[_0x19f9('0x38')],{'$or':_[_0x19f9('0x29')](_0x51303b[_0x19f9('0x32')],function(_0x124409){var _0xc064af={};_0xc064af[_0x124409]={'$like':'%'+_0x3f834b['query'][_0x19f9('0x3a')]+'%'};return _0xc064af;})});}_0x51303b=_[_0x19f9('0x3b')]({},_0x51303b,_0x3f834b[_0x19f9('0x3d')]);return _0x5d090c[_0x19f9('0x49')](_0x51303b);}})[_0x19f9('0x22')](function(_0x10d75a){if(_0x10d75a){_0x552b80=_0x10d75a[_0x19f9('0x34')];if(!_0x3f834b[_0x19f9('0x2e')][_0x19f9('0x35')](_0x19f9('0x4c'))){_0x51303b[_0x19f9('0x1d')]=qs[_0x19f9('0x1d')](_0x3f834b[_0x19f9('0x2e')]['limit']);_0x51303b[_0x19f9('0x1c')]=qs[_0x19f9('0x1c')](_0x3f834b[_0x19f9('0x2e')]['offset']);}return _0x5d090c[_0x19f9('0x49')](_0x51303b);}})[_0x19f9('0x22')](function(_0x161766){if(_0x161766){return _0x161766?{'count':_0x552b80,'rows':_0x161766}:null;}})['then'](respondWithResult(_0x271880,null))[_0x19f9('0x47')](handleError(_0x271880,null));};exports[_0x19f9('0x4d')]=function(_0x5b778a,_0x21172c,_0x45376c){return db[_0x19f9('0x4e')]['find']({'where':{'id':_0x5b778a['params']['id']}})[_0x19f9('0x22')](handleEntityNotFound(_0x21172c,null))[_0x19f9('0x22')](function(_0x4786d6){if(_0x4786d6){return _0x4786d6[_0x19f9('0x4d')](_0x5b778a[_0x19f9('0x46')]['ids'],_['omit'](_0x5b778a[_0x19f9('0x46')],['ids','id'])||{});}})['then'](respondWithResult(_0x21172c,null))['catch'](handleError(_0x21172c,null));};exports['getActions']=function(_0x3f8b43,_0x2a5e2d,_0x4ee15c){var _0x38ccc4={};var _0x5bb692={};var _0x4a852e;var _0x3c1e63;return db[_0x19f9('0x2a')][_0x19f9('0x4a')]({'where':{'id':_0x3f8b43[_0x19f9('0x42')]['id']}})[_0x19f9('0x22')](handleEntityNotFound(_0x2a5e2d,null))[_0x19f9('0x22')](function(_0x52b70e){if(_0x52b70e){_0x4a852e=_0x52b70e;_0x5bb692['model']=_['keys'](db[_0x19f9('0x4e')]['rawAttributes']);_0x5bb692[_0x19f9('0x2e')]=_[_0x19f9('0x2f')](_0x3f8b43['query']);_0x5bb692[_0x19f9('0x30')]=_[_0x19f9('0x31')](_0x5bb692[_0x19f9('0x2d')],_0x5bb692[_0x19f9('0x2e')]);_0x38ccc4[_0x19f9('0x32')]=_['intersection'](_0x5bb692['model'],qs[_0x19f9('0x33')](_0x3f8b43[_0x19f9('0x2e')][_0x19f9('0x33')]));_0x38ccc4[_0x19f9('0x32')]=_0x38ccc4[_0x19f9('0x32')]['length']?_0x38ccc4[_0x19f9('0x32')]:_0x5bb692[_0x19f9('0x2d')];_0x38ccc4[_0x19f9('0x36')]=qs['sort'](_0x3f8b43[_0x19f9('0x2e')][_0x19f9('0x37')]);_0x38ccc4[_0x19f9('0x38')]=qs[_0x19f9('0x30')](_[_0x19f9('0x39')](_0x3f8b43['query'],_0x5bb692[_0x19f9('0x30')]));if(_0x3f8b43[_0x19f9('0x2e')]['filter']){_0x38ccc4[_0x19f9('0x38')]=_['merge'](_0x38ccc4[_0x19f9('0x38')],{'$or':_['map'](_0x38ccc4['attributes'],function(_0x53f80c){var _0x1578bc={};_0x1578bc[_0x53f80c]={'$like':'%'+_0x3f8b43[_0x19f9('0x2e')][_0x19f9('0x3a')]+'%'};return _0x1578bc;})});}_0x38ccc4=_[_0x19f9('0x3b')]({},_0x38ccc4,_0x3f8b43[_0x19f9('0x3d')]);return _0x4a852e[_0x19f9('0x4f')](_0x38ccc4);}})[_0x19f9('0x22')](function(_0x5c51c6){if(_0x5c51c6){_0x3c1e63=_0x5c51c6[_0x19f9('0x34')];if(!_0x3f8b43[_0x19f9('0x2e')]['hasOwnProperty'](_0x19f9('0x4c'))){_0x38ccc4[_0x19f9('0x1d')]=qs[_0x19f9('0x1d')](_0x3f8b43[_0x19f9('0x2e')][_0x19f9('0x1d')]);_0x38ccc4[_0x19f9('0x1c')]=qs[_0x19f9('0x1c')](_0x3f8b43[_0x19f9('0x2e')]['offset']);}return _0x4a852e[_0x19f9('0x4f')](_0x38ccc4);}})[_0x19f9('0x22')](function(_0x344072){if(_0x344072){return _0x344072?{'count':_0x3c1e63,'rows':_0x344072}:null;}})[_0x19f9('0x22')](respondWithResult(_0x2a5e2d,null))[_0x19f9('0x47')](handleError(_0x2a5e2d,null));};
\ No newline at end of file
+var _0xa9e0=['apply','reject','save','update','destroy','then','name','send','map','Automation','rawAttributes','fieldName','type','model','query','filters','intersection','attributes','fields','length','nolimit','order','sort','where','filter','VIRTUAL','merge','count','includeAll','include','findAll','rows','show','params','keys','options','find','catch','create','body','addConditions','Condition','ids','findOne','pick','getConditions','addActions','Action','omit','getActions','hasOwnProperty','html-pdf','eml-format','rimraf','request-promise','bluebird','mustache','util','path','sox','ejs','lodash','squel','desk.js','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/license/util','../../mysqldb','sendStatus','end','status','json','offset','limit','set','Content-Range'];(function(_0x1709e1,_0x36187a){var _0x31f086=function(_0x250033){while(--_0x250033){_0x1709e1['push'](_0x1709e1['shift']());}};_0x31f086(++_0x36187a);}(_0xa9e0,0x123));var _0x0a9e=function(_0x2576d7,_0x167624){_0x2576d7=_0x2576d7-0x0;var _0x16a08c=_0xa9e0[_0x2576d7];return _0x16a08c;};'use strict';var pdf=require(_0x0a9e('0x0'));var emlformat=require(_0x0a9e('0x1'));var rimraf=require(_0x0a9e('0x2'));var zipdir=require('zip-dir');var jsonpatch=require('fast-json-patch');var rp=require(_0x0a9e('0x3'));var moment=require('moment');var BPromise=require(_0x0a9e('0x4'));var Mustache=require(_0x0a9e('0x5'));var util=require(_0x0a9e('0x6'));var path=require(_0x0a9e('0x7'));var sox=require(_0x0a9e('0x8'));var csv=require('to-csv');var ejs=require(_0x0a9e('0x9'));var fs=require('fs');var _=require(_0x0a9e('0xa'));var squel=require(_0x0a9e('0xb'));var crypto=require('crypto');var jsforce=require('jsforce');var deskjs=require(_0x0a9e('0xc'));var toCsv=require('to-csv');var querystring=require('querystring');var Papa=require(_0x0a9e('0xd'));var Redis=require(_0x0a9e('0xe'));var authService=require(_0x0a9e('0xf'));var qs=require(_0x0a9e('0x10'));var as=require(_0x0a9e('0x11'));var hardwareService=require(_0x0a9e('0x12'));var logger=require('../../config/logger')('api');var utils=require('../../config/utils');var config=require('../../config/environment');var licenseUtil=require(_0x0a9e('0x13'));var db=require(_0x0a9e('0x14'))['db'];function respondWithStatusCode(_0xd5b662,_0x26d672){_0x26d672=_0x26d672||0xcc;return function(_0x32d742){if(_0x32d742){return _0xd5b662[_0x0a9e('0x15')](_0x26d672);}return _0xd5b662['status'](_0x26d672)[_0x0a9e('0x16')]();};}function respondWithResult(_0x239b12,_0x2b4227){_0x2b4227=_0x2b4227||0xc8;return function(_0x281129){if(_0x281129){return _0x239b12[_0x0a9e('0x17')](_0x2b4227)[_0x0a9e('0x18')](_0x281129);}};}function respondWithFilteredResult(_0x52a03d,_0x22dccb){return function(_0x5d0880){if(_0x5d0880){var _0x1985b6=_0x5d0880['count'],_0x519dfd=_0x22dccb[_0x0a9e('0x19')],_0x16033c=_0x22dccb['offset']+_0x22dccb[_0x0a9e('0x1a')],_0x12066b;if(_0x16033c>=_0x1985b6){_0x16033c=_0x1985b6;_0x12066b=0xc8;}else{_0x12066b=0xce;}_0x52a03d[_0x0a9e('0x17')](_0x12066b);return _0x52a03d[_0x0a9e('0x1b')](_0x0a9e('0x1c'),_0x519dfd+'-'+_0x16033c+'/'+_0x1985b6)[_0x0a9e('0x18')](_0x5d0880);}return null;};}function patchUpdates(_0x2eb11f){return function(_0x530eb7){try{jsonpatch[_0x0a9e('0x1d')](_0x530eb7,_0x2eb11f,!![]);}catch(_0x1314ae){return BPromise[_0x0a9e('0x1e')](_0x1314ae);}return _0x530eb7[_0x0a9e('0x1f')]();};}function saveUpdates(_0x105080,_0x4bb1e3){return function(_0x2c3407){if(_0x2c3407){return _0x2c3407[_0x0a9e('0x20')](_0x105080)['then'](function(_0x20f109){return _0x20f109;});}return null;};}function removeEntity(_0x5a09ef,_0x588269){return function(_0x3a02e1){if(_0x3a02e1){return _0x3a02e1[_0x0a9e('0x21')]()[_0x0a9e('0x22')](function(){_0x5a09ef[_0x0a9e('0x17')](0xcc)['end']();});}};}function handleEntityNotFound(_0xfb6e48,_0x2fb0e4){return function(_0x3b45bc){if(!_0x3b45bc){_0xfb6e48[_0x0a9e('0x15')](0x194);}return _0x3b45bc;};}function handleError(_0x370d86,_0x42ac8f){_0x42ac8f=_0x42ac8f||0x1f4;return function(_0x16b1ca){logger['error'](_0x16b1ca['stack']);if(_0x16b1ca[_0x0a9e('0x23')]){delete _0x16b1ca[_0x0a9e('0x23')];}_0x370d86[_0x0a9e('0x17')](_0x42ac8f)[_0x0a9e('0x24')](_0x16b1ca);};}exports['index']=function(_0x384319,_0x479bc4){var _0x45a1e7={},_0x5bfb33={},_0x1dc186={'count':0x0,'rows':[]};var _0x34dc65=_[_0x0a9e('0x25')](db[_0x0a9e('0x26')][_0x0a9e('0x27')],function(_0x1538a4){return{'name':_0x1538a4[_0x0a9e('0x28')],'type':_0x1538a4[_0x0a9e('0x29')]['key']};});_0x5bfb33[_0x0a9e('0x2a')]=_[_0x0a9e('0x25')](_0x34dc65,_0x0a9e('0x23'));_0x5bfb33[_0x0a9e('0x2b')]=_['keys'](_0x384319[_0x0a9e('0x2b')]);_0x5bfb33[_0x0a9e('0x2c')]=_[_0x0a9e('0x2d')](_0x5bfb33[_0x0a9e('0x2a')],_0x5bfb33[_0x0a9e('0x2b')]);_0x45a1e7[_0x0a9e('0x2e')]=_[_0x0a9e('0x2d')](_0x5bfb33[_0x0a9e('0x2a')],qs[_0x0a9e('0x2f')](_0x384319['query'][_0x0a9e('0x2f')]));_0x45a1e7['attributes']=_0x45a1e7[_0x0a9e('0x2e')][_0x0a9e('0x30')]?_0x45a1e7[_0x0a9e('0x2e')]:_0x5bfb33[_0x0a9e('0x2a')];if(!_0x384319[_0x0a9e('0x2b')]['hasOwnProperty'](_0x0a9e('0x31'))){_0x45a1e7[_0x0a9e('0x1a')]=qs[_0x0a9e('0x1a')](_0x384319[_0x0a9e('0x2b')][_0x0a9e('0x1a')]);_0x45a1e7[_0x0a9e('0x19')]=qs[_0x0a9e('0x19')](_0x384319[_0x0a9e('0x2b')]['offset']);}_0x45a1e7[_0x0a9e('0x32')]=qs['sort'](_0x384319[_0x0a9e('0x2b')][_0x0a9e('0x33')]);_0x45a1e7[_0x0a9e('0x34')]=qs[_0x0a9e('0x2c')](_['pick'](_0x384319[_0x0a9e('0x2b')],_0x5bfb33[_0x0a9e('0x2c')]),_0x34dc65);if(_0x384319[_0x0a9e('0x2b')][_0x0a9e('0x35')]){_0x45a1e7['where']=_['merge'](_0x45a1e7[_0x0a9e('0x34')],{'$or':_['map'](_0x34dc65,function(_0x24936a){if(_0x24936a[_0x0a9e('0x29')]!==_0x0a9e('0x36')){var _0x1ef87a={};_0x1ef87a[_0x24936a['name']]={'$like':'%'+_0x384319[_0x0a9e('0x2b')][_0x0a9e('0x35')]+'%'};return _0x1ef87a;}})});}_0x45a1e7=_[_0x0a9e('0x37')]({},_0x45a1e7,_0x384319['options']);var _0x1dbf74={'where':_0x45a1e7[_0x0a9e('0x34')]};return db[_0x0a9e('0x26')]['count'](_0x1dbf74)['then'](function(_0x11b61d){_0x1dc186[_0x0a9e('0x38')]=_0x11b61d;if(_0x384319['query'][_0x0a9e('0x39')]){_0x45a1e7[_0x0a9e('0x3a')]=[{'all':!![]}];}return db[_0x0a9e('0x26')][_0x0a9e('0x3b')](_0x45a1e7);})['then'](function(_0x5a594b){_0x1dc186[_0x0a9e('0x3c')]=_0x5a594b;return _0x1dc186;})[_0x0a9e('0x22')](respondWithFilteredResult(_0x479bc4,_0x45a1e7))['catch'](handleError(_0x479bc4,null));};exports[_0x0a9e('0x3d')]=function(_0x1dec2e,_0x1459bb){var _0x5b4f5e={'raw':![],'where':{'id':_0x1dec2e[_0x0a9e('0x3e')]['id']}},_0x316c8f={};_0x316c8f[_0x0a9e('0x2a')]=_[_0x0a9e('0x3f')](db[_0x0a9e('0x26')][_0x0a9e('0x27')]);_0x316c8f[_0x0a9e('0x2b')]=_[_0x0a9e('0x3f')](_0x1dec2e[_0x0a9e('0x2b')]);_0x316c8f[_0x0a9e('0x2c')]=_[_0x0a9e('0x2d')](_0x316c8f[_0x0a9e('0x2a')],_0x316c8f[_0x0a9e('0x2b')]);_0x5b4f5e[_0x0a9e('0x2e')]=_[_0x0a9e('0x2d')](_0x316c8f['model'],qs['fields'](_0x1dec2e[_0x0a9e('0x2b')][_0x0a9e('0x2f')]));_0x5b4f5e[_0x0a9e('0x2e')]=_0x5b4f5e[_0x0a9e('0x2e')][_0x0a9e('0x30')]?_0x5b4f5e[_0x0a9e('0x2e')]:_0x316c8f[_0x0a9e('0x2a')];if(_0x1dec2e[_0x0a9e('0x2b')][_0x0a9e('0x39')]){_0x5b4f5e[_0x0a9e('0x3a')]=[{'all':!![]}];}_0x5b4f5e=_[_0x0a9e('0x37')]({},_0x5b4f5e,_0x1dec2e[_0x0a9e('0x40')]);return db['Automation'][_0x0a9e('0x41')](_0x5b4f5e)[_0x0a9e('0x22')](handleEntityNotFound(_0x1459bb,null))[_0x0a9e('0x22')](respondWithResult(_0x1459bb,null))[_0x0a9e('0x42')](handleError(_0x1459bb,null));};exports[_0x0a9e('0x43')]=function(_0xbe9d19,_0x21eb86){return db[_0x0a9e('0x26')]['create'](_0xbe9d19[_0x0a9e('0x44')],{})['then'](respondWithResult(_0x21eb86,0xc9))[_0x0a9e('0x42')](handleError(_0x21eb86,null));};exports[_0x0a9e('0x20')]=function(_0x8d6dd1,_0x562fb4){if(_0x8d6dd1[_0x0a9e('0x44')]['id']){delete _0x8d6dd1[_0x0a9e('0x44')]['id'];}return db[_0x0a9e('0x26')][_0x0a9e('0x41')]({'where':{'id':_0x8d6dd1[_0x0a9e('0x3e')]['id']}})[_0x0a9e('0x22')](handleEntityNotFound(_0x562fb4,null))[_0x0a9e('0x22')](saveUpdates(_0x8d6dd1['body'],null))[_0x0a9e('0x22')](respondWithResult(_0x562fb4,null))[_0x0a9e('0x42')](handleError(_0x562fb4,null));};exports[_0x0a9e('0x21')]=function(_0x16f976,_0x409789){return db[_0x0a9e('0x26')][_0x0a9e('0x41')]({'where':{'id':_0x16f976[_0x0a9e('0x3e')]['id']}})[_0x0a9e('0x22')](handleEntityNotFound(_0x409789,null))['then'](removeEntity(_0x409789,null))[_0x0a9e('0x42')](handleError(_0x409789,null));};exports[_0x0a9e('0x45')]=function(_0x4f7240,_0x4ae14b,_0x5ddf84){return db[_0x0a9e('0x46')][_0x0a9e('0x41')]({'where':{'id':_0x4f7240[_0x0a9e('0x3e')]['id']}})[_0x0a9e('0x22')](handleEntityNotFound(_0x4ae14b,null))[_0x0a9e('0x22')](function(_0x30decb){if(_0x30decb){return _0x30decb[_0x0a9e('0x45')](_0x4f7240[_0x0a9e('0x44')]['ids'],_['omit'](_0x4f7240['body'],[_0x0a9e('0x47'),'id'])||{});}})[_0x0a9e('0x22')](respondWithResult(_0x4ae14b,null))[_0x0a9e('0x42')](handleError(_0x4ae14b,null));};exports['getConditions']=function(_0x2b69d9,_0x161aa7,_0x53d113){var _0x5a88da={};var _0x2ef381={};var _0x59c6ff;var _0x443e72;return db['Automation'][_0x0a9e('0x48')]({'where':{'id':_0x2b69d9[_0x0a9e('0x3e')]['id']}})[_0x0a9e('0x22')](handleEntityNotFound(_0x161aa7,null))['then'](function(_0x2f82da){if(_0x2f82da){_0x59c6ff=_0x2f82da;_0x2ef381[_0x0a9e('0x2a')]=_['keys'](db['Condition'][_0x0a9e('0x27')]);_0x2ef381[_0x0a9e('0x2b')]=_['keys'](_0x2b69d9[_0x0a9e('0x2b')]);_0x2ef381['filters']=_[_0x0a9e('0x2d')](_0x2ef381['model'],_0x2ef381[_0x0a9e('0x2b')]);_0x5a88da['attributes']=_['intersection'](_0x2ef381['model'],qs[_0x0a9e('0x2f')](_0x2b69d9['query'][_0x0a9e('0x2f')]));_0x5a88da[_0x0a9e('0x2e')]=_0x5a88da[_0x0a9e('0x2e')][_0x0a9e('0x30')]?_0x5a88da[_0x0a9e('0x2e')]:_0x2ef381[_0x0a9e('0x2a')];_0x5a88da[_0x0a9e('0x32')]=qs[_0x0a9e('0x33')](_0x2b69d9['query'][_0x0a9e('0x33')]);_0x5a88da[_0x0a9e('0x34')]=qs[_0x0a9e('0x2c')](_[_0x0a9e('0x49')](_0x2b69d9[_0x0a9e('0x2b')],_0x2ef381[_0x0a9e('0x2c')]));if(_0x2b69d9['query'][_0x0a9e('0x35')]){_0x5a88da[_0x0a9e('0x34')]=_['merge'](_0x5a88da[_0x0a9e('0x34')],{'$or':_['map'](_0x5a88da[_0x0a9e('0x2e')],function(_0x5ba1f9){var _0x4b3c1a={};_0x4b3c1a[_0x5ba1f9]={'$like':'%'+_0x2b69d9['query'][_0x0a9e('0x35')]+'%'};return _0x4b3c1a;})});}_0x5a88da=_['merge']({},_0x5a88da,_0x2b69d9[_0x0a9e('0x40')]);return _0x59c6ff[_0x0a9e('0x4a')](_0x5a88da);}})[_0x0a9e('0x22')](function(_0x7be420){if(_0x7be420){_0x443e72=_0x7be420[_0x0a9e('0x30')];if(!_0x2b69d9[_0x0a9e('0x2b')]['hasOwnProperty'](_0x0a9e('0x31'))){_0x5a88da['limit']=qs[_0x0a9e('0x1a')](_0x2b69d9[_0x0a9e('0x2b')][_0x0a9e('0x1a')]);_0x5a88da['offset']=qs[_0x0a9e('0x19')](_0x2b69d9[_0x0a9e('0x2b')][_0x0a9e('0x19')]);}return _0x59c6ff[_0x0a9e('0x4a')](_0x5a88da);}})['then'](function(_0x1d0dc8){if(_0x1d0dc8){return _0x1d0dc8?{'count':_0x443e72,'rows':_0x1d0dc8}:null;}})[_0x0a9e('0x22')](respondWithResult(_0x161aa7,null))['catch'](handleError(_0x161aa7,null));};exports[_0x0a9e('0x4b')]=function(_0x17e88c,_0x88dcbf,_0x409b29){return db[_0x0a9e('0x4c')]['find']({'where':{'id':_0x17e88c[_0x0a9e('0x3e')]['id']}})[_0x0a9e('0x22')](handleEntityNotFound(_0x88dcbf,null))[_0x0a9e('0x22')](function(_0x47bb43){if(_0x47bb43){return _0x47bb43[_0x0a9e('0x4b')](_0x17e88c['body']['ids'],_[_0x0a9e('0x4d')](_0x17e88c[_0x0a9e('0x44')],[_0x0a9e('0x47'),'id'])||{});}})[_0x0a9e('0x22')](respondWithResult(_0x88dcbf,null))[_0x0a9e('0x42')](handleError(_0x88dcbf,null));};exports[_0x0a9e('0x4e')]=function(_0x387489,_0x54a37d,_0x2d7205){var _0x1cc4f3={};var _0x2e89b7={};var _0x19012b;var _0x2bbb86;return db[_0x0a9e('0x26')][_0x0a9e('0x48')]({'where':{'id':_0x387489[_0x0a9e('0x3e')]['id']}})[_0x0a9e('0x22')](handleEntityNotFound(_0x54a37d,null))[_0x0a9e('0x22')](function(_0x5150a4){if(_0x5150a4){_0x19012b=_0x5150a4;_0x2e89b7[_0x0a9e('0x2a')]=_[_0x0a9e('0x3f')](db[_0x0a9e('0x4c')]['rawAttributes']);_0x2e89b7[_0x0a9e('0x2b')]=_[_0x0a9e('0x3f')](_0x387489['query']);_0x2e89b7[_0x0a9e('0x2c')]=_[_0x0a9e('0x2d')](_0x2e89b7[_0x0a9e('0x2a')],_0x2e89b7[_0x0a9e('0x2b')]);_0x1cc4f3[_0x0a9e('0x2e')]=_['intersection'](_0x2e89b7['model'],qs['fields'](_0x387489[_0x0a9e('0x2b')][_0x0a9e('0x2f')]));_0x1cc4f3[_0x0a9e('0x2e')]=_0x1cc4f3[_0x0a9e('0x2e')][_0x0a9e('0x30')]?_0x1cc4f3[_0x0a9e('0x2e')]:_0x2e89b7[_0x0a9e('0x2a')];_0x1cc4f3[_0x0a9e('0x32')]=qs['sort'](_0x387489[_0x0a9e('0x2b')][_0x0a9e('0x33')]);_0x1cc4f3[_0x0a9e('0x34')]=qs['filters'](_[_0x0a9e('0x49')](_0x387489['query'],_0x2e89b7[_0x0a9e('0x2c')]));if(_0x387489[_0x0a9e('0x2b')]['filter']){_0x1cc4f3[_0x0a9e('0x34')]=_[_0x0a9e('0x37')](_0x1cc4f3[_0x0a9e('0x34')],{'$or':_[_0x0a9e('0x25')](_0x1cc4f3['attributes'],function(_0x1d442c){var _0x2e9552={};_0x2e9552[_0x1d442c]={'$like':'%'+_0x387489[_0x0a9e('0x2b')][_0x0a9e('0x35')]+'%'};return _0x2e9552;})});}_0x1cc4f3=_['merge']({},_0x1cc4f3,_0x387489[_0x0a9e('0x40')]);return _0x19012b[_0x0a9e('0x4e')](_0x1cc4f3);}})[_0x0a9e('0x22')](function(_0x361b21){if(_0x361b21){_0x2bbb86=_0x361b21['length'];if(!_0x387489[_0x0a9e('0x2b')][_0x0a9e('0x4f')](_0x0a9e('0x31'))){_0x1cc4f3[_0x0a9e('0x1a')]=qs[_0x0a9e('0x1a')](_0x387489[_0x0a9e('0x2b')][_0x0a9e('0x1a')]);_0x1cc4f3[_0x0a9e('0x19')]=qs[_0x0a9e('0x19')](_0x387489[_0x0a9e('0x2b')][_0x0a9e('0x19')]);}return _0x19012b[_0x0a9e('0x4e')](_0x1cc4f3);}})[_0x0a9e('0x22')](function(_0xe0749e){if(_0xe0749e){return _0xe0749e?{'count':_0x2bbb86,'rows':_0xe0749e}:null;}})['then'](respondWithResult(_0x54a37d,null))[_0x0a9e('0x42')](handleError(_0x54a37d,null));};
\ No newline at end of file