Built motion from commit 52c8a02d.|2.6.29
[motion2.git] / server / api / automation / automation.controller.js
index 90298ec..d22f8d8 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xc16a=['addConditions','ids','getConditions','hasOwnProperty','addActions','Action','getActions','findOne','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','path','ejs','fs-extra','lodash','squel','jsforce','desk.js','to-csv','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../config/license/hardware','api','../../config/utils','../../config/environment','../../mysqldb','sendStatus','status','end','json','offset','undefined','limit','count','set','apply','reject','save','update','then','destroy','error','stack','name','send','index','map','Automation','rawAttributes','fieldName','type','key','model','keys','query','intersection','fields','attributes','nolimit','order','sort','filters','pick','filter','merge','options','where','includeAll','findAll','rows','catch','show','params','length','create','find','body','Condition'];(function(_0x2c5d4d,_0x1d4d5e){var _0x14dfe0=function(_0x47a9e4){while(--_0x47a9e4){_0x2c5d4d['push'](_0x2c5d4d['shift']());}};_0x14dfe0(++_0x1d4d5e);}(_0xc16a,0x15c));var _0xac16=function(_0x40eba7,_0x277722){_0x40eba7=_0x40eba7-0x0;var _0x1152fd=_0xc16a[_0x40eba7];return _0x1152fd;};'use strict';var emlformat=require(_0xac16('0x0'));var rimraf=require(_0xac16('0x1'));var zipdir=require(_0xac16('0x2'));var jsonpatch=require(_0xac16('0x3'));var rp=require(_0xac16('0x4'));var moment=require(_0xac16('0x5'));var BPromise=require(_0xac16('0x6'));var Mustache=require('mustache');var util=require('util');var path=require(_0xac16('0x7'));var sox=require('sox');var csv=require('to-csv');var ejs=require(_0xac16('0x8'));var fs=require('fs');var fs_extra=require(_0xac16('0x9'));var _=require(_0xac16('0xa'));var squel=require(_0xac16('0xb'));var crypto=require('crypto');var jsforce=require(_0xac16('0xc'));var deskjs=require(_0xac16('0xd'));var toCsv=require(_0xac16('0xe'));var querystring=require(_0xac16('0xf'));var Papa=require(_0xac16('0x10'));var Redis=require(_0xac16('0x11'));var authService=require(_0xac16('0x12'));var qs=require(_0xac16('0x13'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0xac16('0x14'));var logger=require('../../config/logger')(_0xac16('0x15'));var utils=require(_0xac16('0x16'));var config=require(_0xac16('0x17'));var licenseUtil=require('../../config/license/util');var db=require(_0xac16('0x18'))['db'];function respondWithStatusCode(_0x44bfb3,_0x382dee){_0x382dee=_0x382dee||0xcc;return function(_0x5ab5d8){if(_0x5ab5d8){return _0x44bfb3[_0xac16('0x19')](_0x382dee);}return _0x44bfb3[_0xac16('0x1a')](_0x382dee)[_0xac16('0x1b')]();};}function respondWithResult(_0x2a08b4,_0x55bcfa){_0x55bcfa=_0x55bcfa||0xc8;return function(_0x472b45){if(_0x472b45){return _0x2a08b4[_0xac16('0x1a')](_0x55bcfa)[_0xac16('0x1c')](_0x472b45);}};}function respondWithFilteredResult(_0x22a6c2,_0x1913bc){return function(_0x127808){if(_0x127808){var _0xb5854d=typeof _0x1913bc[_0xac16('0x1d')]===_0xac16('0x1e')&&typeof _0x1913bc[_0xac16('0x1f')]==='undefined';var _0x48bae4=_0x127808[_0xac16('0x20')];var _0x859065=_0xb5854d?0x0:_0x1913bc[_0xac16('0x1d')];var _0x489218=_0xb5854d?_0x127808[_0xac16('0x20')]:_0x1913bc['offset']+_0x1913bc['limit'];var _0xa1bd21;if(_0x489218>=_0x48bae4){_0x489218=_0x48bae4;_0xa1bd21=0xc8;}else{_0xa1bd21=0xce;}_0x22a6c2[_0xac16('0x1a')](_0xa1bd21);return _0x22a6c2[_0xac16('0x21')]('Content-Range',_0x859065+'-'+_0x489218+'/'+_0x48bae4)[_0xac16('0x1c')](_0x127808);}return null;};}function patchUpdates(_0x3c9ba7){return function(_0x1cf53f){try{jsonpatch[_0xac16('0x22')](_0x1cf53f,_0x3c9ba7,!![]);}catch(_0x347f3b){return BPromise[_0xac16('0x23')](_0x347f3b);}return _0x1cf53f[_0xac16('0x24')]();};}function saveUpdates(_0x4c1dc7,_0x182b40){return function(_0x365cc3){if(_0x365cc3){return _0x365cc3[_0xac16('0x25')](_0x4c1dc7)[_0xac16('0x26')](function(_0x356e9c){return _0x356e9c;});}return null;};}function removeEntity(_0x30956b,_0x761355){return function(_0x2cade0){if(_0x2cade0){return _0x2cade0[_0xac16('0x27')]()[_0xac16('0x26')](function(){_0x30956b[_0xac16('0x1a')](0xcc)[_0xac16('0x1b')]();});}};}function handleEntityNotFound(_0x490f3c,_0x3f33df){return function(_0x43ed5a){if(!_0x43ed5a){_0x490f3c['sendStatus'](0x194);}return _0x43ed5a;};}function handleError(_0x5e55ff,_0x3947af){_0x3947af=_0x3947af||0x1f4;return function(_0x214dce){logger[_0xac16('0x28')](_0x214dce[_0xac16('0x29')]);if(_0x214dce[_0xac16('0x2a')]){delete _0x214dce[_0xac16('0x2a')];}_0x5e55ff['status'](_0x3947af)[_0xac16('0x2b')](_0x214dce);};}exports[_0xac16('0x2c')]=function(_0x1dfbe6,_0x35d208){var _0x553a38={},_0x580dfd={},_0x3683b4={'count':0x0,'rows':[]};var _0x550919=_[_0xac16('0x2d')](db[_0xac16('0x2e')][_0xac16('0x2f')],function(_0x3e6cf8){return{'name':_0x3e6cf8[_0xac16('0x30')],'type':_0x3e6cf8[_0xac16('0x31')][_0xac16('0x32')]};});_0x580dfd[_0xac16('0x33')]=_['map'](_0x550919,'name');_0x580dfd['query']=_[_0xac16('0x34')](_0x1dfbe6[_0xac16('0x35')]);_0x580dfd['filters']=_[_0xac16('0x36')](_0x580dfd['model'],_0x580dfd[_0xac16('0x35')]);_0x553a38['attributes']=_[_0xac16('0x36')](_0x580dfd[_0xac16('0x33')],qs[_0xac16('0x37')](_0x1dfbe6[_0xac16('0x35')][_0xac16('0x37')]));_0x553a38[_0xac16('0x38')]=_0x553a38[_0xac16('0x38')]['length']?_0x553a38[_0xac16('0x38')]:_0x580dfd['model'];if(!_0x1dfbe6['query']['hasOwnProperty'](_0xac16('0x39'))){_0x553a38[_0xac16('0x1f')]=qs['limit'](_0x1dfbe6['query'][_0xac16('0x1f')]);_0x553a38[_0xac16('0x1d')]=qs[_0xac16('0x1d')](_0x1dfbe6[_0xac16('0x35')]['offset']);}_0x553a38[_0xac16('0x3a')]=qs['sort'](_0x1dfbe6[_0xac16('0x35')][_0xac16('0x3b')]);_0x553a38['where']=qs[_0xac16('0x3c')](_[_0xac16('0x3d')](_0x1dfbe6[_0xac16('0x35')],_0x580dfd['filters']),_0x550919);if(_0x1dfbe6[_0xac16('0x35')][_0xac16('0x3e')]){_0x553a38['where']=_[_0xac16('0x3f')](_0x553a38['where'],{'$or':_['map'](_0x550919,function(_0x33ea1e){if(_0x33ea1e[_0xac16('0x31')]!=='VIRTUAL'){var _0x761d63={};_0x761d63[_0x33ea1e[_0xac16('0x2a')]]={'$like':'%'+_0x1dfbe6[_0xac16('0x35')]['filter']+'%'};return _0x761d63;}})});}_0x553a38=_['merge']({},_0x553a38,_0x1dfbe6[_0xac16('0x40')]);var _0x512e76={'where':_0x553a38[_0xac16('0x41')]};return db[_0xac16('0x2e')][_0xac16('0x20')](_0x512e76)[_0xac16('0x26')](function(_0x59fac4){_0x3683b4['count']=_0x59fac4;if(_0x1dfbe6[_0xac16('0x35')][_0xac16('0x42')]){_0x553a38['include']=[{'all':!![]}];}return db[_0xac16('0x2e')][_0xac16('0x43')](_0x553a38);})[_0xac16('0x26')](function(_0x2d957d){_0x3683b4[_0xac16('0x44')]=_0x2d957d;return _0x3683b4;})[_0xac16('0x26')](respondWithFilteredResult(_0x35d208,_0x553a38))[_0xac16('0x45')](handleError(_0x35d208,null));};exports[_0xac16('0x46')]=function(_0x3ecea2,_0x2f301d){var _0x1f193d={'raw':![],'where':{'id':_0x3ecea2[_0xac16('0x47')]['id']}},_0x554270={};_0x554270[_0xac16('0x33')]=_[_0xac16('0x34')](db[_0xac16('0x2e')][_0xac16('0x2f')]);_0x554270[_0xac16('0x35')]=_['keys'](_0x3ecea2[_0xac16('0x35')]);_0x554270[_0xac16('0x3c')]=_['intersection'](_0x554270['model'],_0x554270['query']);_0x1f193d[_0xac16('0x38')]=_[_0xac16('0x36')](_0x554270[_0xac16('0x33')],qs[_0xac16('0x37')](_0x3ecea2[_0xac16('0x35')][_0xac16('0x37')]));_0x1f193d['attributes']=_0x1f193d[_0xac16('0x38')][_0xac16('0x48')]?_0x1f193d[_0xac16('0x38')]:_0x554270[_0xac16('0x33')];if(_0x3ecea2[_0xac16('0x35')][_0xac16('0x42')]){_0x1f193d['include']=[{'all':!![]}];}_0x1f193d=_[_0xac16('0x3f')]({},_0x1f193d,_0x3ecea2[_0xac16('0x40')]);return db[_0xac16('0x2e')]['find'](_0x1f193d)[_0xac16('0x26')](handleEntityNotFound(_0x2f301d,null))[_0xac16('0x26')](respondWithResult(_0x2f301d,null))['catch'](handleError(_0x2f301d,null));};exports['create']=function(_0x3b07c7,_0x535b2c){return db[_0xac16('0x2e')][_0xac16('0x49')](_0x3b07c7['body'],{})[_0xac16('0x26')](respondWithResult(_0x535b2c,0xc9))[_0xac16('0x45')](handleError(_0x535b2c,null));};exports[_0xac16('0x25')]=function(_0x52adf0,_0x1e246e){if(_0x52adf0['body']['id']){delete _0x52adf0['body']['id'];}return db[_0xac16('0x2e')][_0xac16('0x4a')]({'where':{'id':_0x52adf0[_0xac16('0x47')]['id']}})[_0xac16('0x26')](handleEntityNotFound(_0x1e246e,null))[_0xac16('0x26')](saveUpdates(_0x52adf0[_0xac16('0x4b')],null))[_0xac16('0x26')](respondWithResult(_0x1e246e,null))[_0xac16('0x45')](handleError(_0x1e246e,null));};exports[_0xac16('0x27')]=function(_0x11eac3,_0x121a16){return db[_0xac16('0x2e')][_0xac16('0x4a')]({'where':{'id':_0x11eac3[_0xac16('0x47')]['id']}})[_0xac16('0x26')](handleEntityNotFound(_0x121a16,null))['then'](removeEntity(_0x121a16,null))[_0xac16('0x45')](handleError(_0x121a16,null));};exports['addConditions']=function(_0x4840a5,_0x59d6e5,_0x2c59d9){return db[_0xac16('0x4c')][_0xac16('0x4a')]({'where':{'id':_0x4840a5[_0xac16('0x47')]['id']}})[_0xac16('0x26')](handleEntityNotFound(_0x59d6e5,null))['then'](function(_0x286f73){if(_0x286f73){return _0x286f73[_0xac16('0x4d')](_0x4840a5[_0xac16('0x4b')]['ids'],_['omit'](_0x4840a5[_0xac16('0x4b')],[_0xac16('0x4e'),'id'])||{});}})[_0xac16('0x26')](respondWithResult(_0x59d6e5,null))['catch'](handleError(_0x59d6e5,null));};exports['getConditions']=function(_0x2bfe3f,_0x4f3a9c,_0x37bcc4){var _0x179c5={};var _0x2583b9={};var _0x248c2d;var _0x154f76;return db[_0xac16('0x2e')]['findOne']({'where':{'id':_0x2bfe3f[_0xac16('0x47')]['id']}})[_0xac16('0x26')](handleEntityNotFound(_0x4f3a9c,null))[_0xac16('0x26')](function(_0x175d0a){if(_0x175d0a){_0x248c2d=_0x175d0a;_0x2583b9[_0xac16('0x33')]=_[_0xac16('0x34')](db[_0xac16('0x4c')]['rawAttributes']);_0x2583b9['query']=_[_0xac16('0x34')](_0x2bfe3f[_0xac16('0x35')]);_0x2583b9[_0xac16('0x3c')]=_['intersection'](_0x2583b9['model'],_0x2583b9['query']);_0x179c5['attributes']=_['intersection'](_0x2583b9[_0xac16('0x33')],qs[_0xac16('0x37')](_0x2bfe3f[_0xac16('0x35')]['fields']));_0x179c5[_0xac16('0x38')]=_0x179c5['attributes'][_0xac16('0x48')]?_0x179c5[_0xac16('0x38')]:_0x2583b9['model'];_0x179c5[_0xac16('0x3a')]=qs['sort'](_0x2bfe3f[_0xac16('0x35')][_0xac16('0x3b')]);_0x179c5[_0xac16('0x41')]=qs[_0xac16('0x3c')](_[_0xac16('0x3d')](_0x2bfe3f[_0xac16('0x35')],_0x2583b9[_0xac16('0x3c')]));if(_0x2bfe3f[_0xac16('0x35')]['filter']){_0x179c5['where']=_[_0xac16('0x3f')](_0x179c5[_0xac16('0x41')],{'$or':_[_0xac16('0x2d')](_0x179c5[_0xac16('0x38')],function(_0x5acd05){var _0x3927eb={};_0x3927eb[_0x5acd05]={'$like':'%'+_0x2bfe3f[_0xac16('0x35')]['filter']+'%'};return _0x3927eb;})});}_0x179c5=_[_0xac16('0x3f')]({},_0x179c5,_0x2bfe3f[_0xac16('0x40')]);return _0x248c2d[_0xac16('0x4f')](_0x179c5);}})['then'](function(_0x379d91){if(_0x379d91){_0x154f76=_0x379d91['length'];if(!_0x2bfe3f[_0xac16('0x35')][_0xac16('0x50')](_0xac16('0x39'))){_0x179c5[_0xac16('0x1f')]=qs[_0xac16('0x1f')](_0x2bfe3f['query']['limit']);_0x179c5[_0xac16('0x1d')]=qs[_0xac16('0x1d')](_0x2bfe3f[_0xac16('0x35')][_0xac16('0x1d')]);}return _0x248c2d[_0xac16('0x4f')](_0x179c5);}})[_0xac16('0x26')](function(_0x2c660a){if(_0x2c660a){return _0x2c660a?{'count':_0x154f76,'rows':_0x2c660a}:null;}})[_0xac16('0x26')](respondWithResult(_0x4f3a9c,null))[_0xac16('0x45')](handleError(_0x4f3a9c,null));};exports[_0xac16('0x51')]=function(_0x27f9e0,_0x4c2ec4,_0x5cba6a){return db[_0xac16('0x52')]['find']({'where':{'id':_0x27f9e0[_0xac16('0x47')]['id']}})['then'](handleEntityNotFound(_0x4c2ec4,null))[_0xac16('0x26')](function(_0x2da1a3){if(_0x2da1a3){return _0x2da1a3[_0xac16('0x51')](_0x27f9e0[_0xac16('0x4b')][_0xac16('0x4e')],_['omit'](_0x27f9e0[_0xac16('0x4b')],[_0xac16('0x4e'),'id'])||{});}})[_0xac16('0x26')](respondWithResult(_0x4c2ec4,null))['catch'](handleError(_0x4c2ec4,null));};exports[_0xac16('0x53')]=function(_0x9a3e3,_0x46e7dd,_0x87e1a7){var _0x340930={};var _0x3e142b={};var _0xfe5313;var _0x5b7729;return db['Automation'][_0xac16('0x54')]({'where':{'id':_0x9a3e3[_0xac16('0x47')]['id']}})[_0xac16('0x26')](handleEntityNotFound(_0x46e7dd,null))[_0xac16('0x26')](function(_0x477c31){if(_0x477c31){_0xfe5313=_0x477c31;_0x3e142b[_0xac16('0x33')]=_[_0xac16('0x34')](db[_0xac16('0x52')][_0xac16('0x2f')]);_0x3e142b['query']=_[_0xac16('0x34')](_0x9a3e3[_0xac16('0x35')]);_0x3e142b[_0xac16('0x3c')]=_[_0xac16('0x36')](_0x3e142b['model'],_0x3e142b[_0xac16('0x35')]);_0x340930[_0xac16('0x38')]=_[_0xac16('0x36')](_0x3e142b[_0xac16('0x33')],qs[_0xac16('0x37')](_0x9a3e3['query'][_0xac16('0x37')]));_0x340930[_0xac16('0x38')]=_0x340930[_0xac16('0x38')][_0xac16('0x48')]?_0x340930['attributes']:_0x3e142b[_0xac16('0x33')];_0x340930[_0xac16('0x3a')]=qs[_0xac16('0x3b')](_0x9a3e3[_0xac16('0x35')][_0xac16('0x3b')]);_0x340930['where']=qs[_0xac16('0x3c')](_[_0xac16('0x3d')](_0x9a3e3['query'],_0x3e142b['filters']));if(_0x9a3e3[_0xac16('0x35')][_0xac16('0x3e')]){_0x340930[_0xac16('0x41')]=_[_0xac16('0x3f')](_0x340930[_0xac16('0x41')],{'$or':_[_0xac16('0x2d')](_0x340930[_0xac16('0x38')],function(_0x44d962){var _0x54f547={};_0x54f547[_0x44d962]={'$like':'%'+_0x9a3e3[_0xac16('0x35')][_0xac16('0x3e')]+'%'};return _0x54f547;})});}_0x340930=_['merge']({},_0x340930,_0x9a3e3[_0xac16('0x40')]);return _0xfe5313[_0xac16('0x53')](_0x340930);}})[_0xac16('0x26')](function(_0x31ee61){if(_0x31ee61){_0x5b7729=_0x31ee61[_0xac16('0x48')];if(!_0x9a3e3[_0xac16('0x35')][_0xac16('0x50')](_0xac16('0x39'))){_0x340930[_0xac16('0x1f')]=qs[_0xac16('0x1f')](_0x9a3e3['query'][_0xac16('0x1f')]);_0x340930[_0xac16('0x1d')]=qs[_0xac16('0x1d')](_0x9a3e3[_0xac16('0x35')][_0xac16('0x1d')]);}return _0xfe5313['getActions'](_0x340930);}})[_0xac16('0x26')](function(_0x56e0a3){if(_0x56e0a3){return _0x56e0a3?{'count':_0x5b7729,'rows':_0x56e0a3}:null;}})[_0xac16('0x26')](respondWithResult(_0x46e7dd,null))['catch'](handleError(_0x46e7dd,null));};
\ No newline at end of file
+var _0xcf7b=['hasOwnProperty','nolimit','order','sort','where','filter','merge','VIRTUAL','options','count','includeAll','findAll','rows','catch','show','params','create','body','update','find','addConditions','Condition','ids','getConditions','findOne','pick','addActions','Action','omit','getActions','eml-format','zip-dir','fast-json-patch','request-promise','moment','mustache','util','path','to-csv','ejs','fs-extra','lodash','squel','crypto','jsforce','desk.js','querystring','papaparse','../../components/auth/service','../../components/parsers/qs','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../mysqldb','sendStatus','end','json','undefined','offset','limit','status','set','reject','save','then','destroy','error','name','send','index','map','Automation','rawAttributes','fieldName','key','model','query','keys','filters','attributes','intersection','fields','length'];(function(_0x2ac5f8,_0x4c3a9f){var _0x3b8229=function(_0x46a3c0){while(--_0x46a3c0){_0x2ac5f8['push'](_0x2ac5f8['shift']());}};_0x3b8229(++_0x4c3a9f);}(_0xcf7b,0x172));var _0xbcf7=function(_0x1969a7,_0x5a133a){_0x1969a7=_0x1969a7-0x0;var _0x3d665f=_0xcf7b[_0x1969a7];return _0x3d665f;};'use strict';var emlformat=require(_0xbcf7('0x0'));var rimraf=require('rimraf');var zipdir=require(_0xbcf7('0x1'));var jsonpatch=require(_0xbcf7('0x2'));var rp=require(_0xbcf7('0x3'));var moment=require(_0xbcf7('0x4'));var BPromise=require('bluebird');var Mustache=require(_0xbcf7('0x5'));var util=require(_0xbcf7('0x6'));var path=require(_0xbcf7('0x7'));var sox=require('sox');var csv=require(_0xbcf7('0x8'));var ejs=require(_0xbcf7('0x9'));var fs=require('fs');var fs_extra=require(_0xbcf7('0xa'));var _=require(_0xbcf7('0xb'));var squel=require(_0xbcf7('0xc'));var crypto=require(_0xbcf7('0xd'));var jsforce=require(_0xbcf7('0xe'));var deskjs=require(_0xbcf7('0xf'));var toCsv=require(_0xbcf7('0x8'));var querystring=require(_0xbcf7('0x10'));var Papa=require(_0xbcf7('0x11'));var Redis=require('ioredis');var authService=require(_0xbcf7('0x12'));var qs=require(_0xbcf7('0x13'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0xbcf7('0x14'));var logger=require(_0xbcf7('0x15'))(_0xbcf7('0x16'));var utils=require(_0xbcf7('0x17'));var config=require(_0xbcf7('0x18'));var licenseUtil=require('../../config/license/util');var db=require(_0xbcf7('0x19'))['db'];function respondWithStatusCode(_0x35ff0a,_0x2cfda4){_0x2cfda4=_0x2cfda4||0xcc;return function(_0x5dec67){if(_0x5dec67){return _0x35ff0a[_0xbcf7('0x1a')](_0x2cfda4);}return _0x35ff0a['status'](_0x2cfda4)[_0xbcf7('0x1b')]();};}function respondWithResult(_0x1997c7,_0xf7aef5){_0xf7aef5=_0xf7aef5||0xc8;return function(_0x150807){if(_0x150807){return _0x1997c7['status'](_0xf7aef5)[_0xbcf7('0x1c')](_0x150807);}};}function respondWithFilteredResult(_0x52426c,_0xae9554){return function(_0x278c82){if(_0x278c82){var _0x2b3c43=typeof _0xae9554['offset']==='undefined'&&typeof _0xae9554['limit']===_0xbcf7('0x1d');var _0x23d088=_0x278c82['count'];var _0x3557c4=_0x2b3c43?0x0:_0xae9554[_0xbcf7('0x1e')];var _0x1315be=_0x2b3c43?_0x278c82['count']:_0xae9554['offset']+_0xae9554[_0xbcf7('0x1f')];var _0xf03848;if(_0x1315be>=_0x23d088){_0x1315be=_0x23d088;_0xf03848=0xc8;}else{_0xf03848=0xce;}_0x52426c[_0xbcf7('0x20')](_0xf03848);return _0x52426c[_0xbcf7('0x21')]('Content-Range',_0x3557c4+'-'+_0x1315be+'/'+_0x23d088)[_0xbcf7('0x1c')](_0x278c82);}return null;};}function patchUpdates(_0x242565){return function(_0x3acbf4){try{jsonpatch['apply'](_0x3acbf4,_0x242565,!![]);}catch(_0x160484){return BPromise[_0xbcf7('0x22')](_0x160484);}return _0x3acbf4[_0xbcf7('0x23')]();};}function saveUpdates(_0x4a592f,_0x14e896){return function(_0x3436eb){if(_0x3436eb){return _0x3436eb['update'](_0x4a592f)[_0xbcf7('0x24')](function(_0x5006c7){return _0x5006c7;});}return null;};}function removeEntity(_0x24ddd0,_0x3ee9c0){return function(_0x2274b0){if(_0x2274b0){return _0x2274b0[_0xbcf7('0x25')]()[_0xbcf7('0x24')](function(){_0x24ddd0[_0xbcf7('0x20')](0xcc)[_0xbcf7('0x1b')]();});}};}function handleEntityNotFound(_0x1a9fb1,_0x428463){return function(_0x22b250){if(!_0x22b250){_0x1a9fb1[_0xbcf7('0x1a')](0x194);}return _0x22b250;};}function handleError(_0xd8e8bf,_0x3a50c8){_0x3a50c8=_0x3a50c8||0x1f4;return function(_0x53d591){logger[_0xbcf7('0x26')](_0x53d591['stack']);if(_0x53d591[_0xbcf7('0x27')]){delete _0x53d591[_0xbcf7('0x27')];}_0xd8e8bf['status'](_0x3a50c8)[_0xbcf7('0x28')](_0x53d591);};}exports[_0xbcf7('0x29')]=function(_0x2e0f01,_0x5bc226){var _0x45af4a={},_0x9ef68c={},_0x2006db={'count':0x0,'rows':[]};var _0xbeed1d=_[_0xbcf7('0x2a')](db[_0xbcf7('0x2b')][_0xbcf7('0x2c')],function(_0x3afdd4){return{'name':_0x3afdd4[_0xbcf7('0x2d')],'type':_0x3afdd4['type'][_0xbcf7('0x2e')]};});_0x9ef68c[_0xbcf7('0x2f')]=_[_0xbcf7('0x2a')](_0xbeed1d,_0xbcf7('0x27'));_0x9ef68c[_0xbcf7('0x30')]=_[_0xbcf7('0x31')](_0x2e0f01['query']);_0x9ef68c[_0xbcf7('0x32')]=_['intersection'](_0x9ef68c[_0xbcf7('0x2f')],_0x9ef68c[_0xbcf7('0x30')]);_0x45af4a[_0xbcf7('0x33')]=_[_0xbcf7('0x34')](_0x9ef68c[_0xbcf7('0x2f')],qs['fields'](_0x2e0f01[_0xbcf7('0x30')][_0xbcf7('0x35')]));_0x45af4a['attributes']=_0x45af4a[_0xbcf7('0x33')][_0xbcf7('0x36')]?_0x45af4a[_0xbcf7('0x33')]:_0x9ef68c[_0xbcf7('0x2f')];if(!_0x2e0f01[_0xbcf7('0x30')][_0xbcf7('0x37')](_0xbcf7('0x38'))){_0x45af4a['limit']=qs[_0xbcf7('0x1f')](_0x2e0f01[_0xbcf7('0x30')]['limit']);_0x45af4a[_0xbcf7('0x1e')]=qs[_0xbcf7('0x1e')](_0x2e0f01[_0xbcf7('0x30')]['offset']);}_0x45af4a[_0xbcf7('0x39')]=qs[_0xbcf7('0x3a')](_0x2e0f01[_0xbcf7('0x30')]['sort']);_0x45af4a[_0xbcf7('0x3b')]=qs['filters'](_['pick'](_0x2e0f01[_0xbcf7('0x30')],_0x9ef68c[_0xbcf7('0x32')]),_0xbeed1d);if(_0x2e0f01[_0xbcf7('0x30')][_0xbcf7('0x3c')]){_0x45af4a[_0xbcf7('0x3b')]=_[_0xbcf7('0x3d')](_0x45af4a[_0xbcf7('0x3b')],{'$or':_[_0xbcf7('0x2a')](_0xbeed1d,function(_0x50105d){if(_0x50105d['type']!==_0xbcf7('0x3e')){var _0x1a1951={};_0x1a1951[_0x50105d[_0xbcf7('0x27')]]={'$like':'%'+_0x2e0f01[_0xbcf7('0x30')]['filter']+'%'};return _0x1a1951;}})});}_0x45af4a=_['merge']({},_0x45af4a,_0x2e0f01[_0xbcf7('0x3f')]);var _0x49b067={'where':_0x45af4a[_0xbcf7('0x3b')]};return db[_0xbcf7('0x2b')][_0xbcf7('0x40')](_0x49b067)[_0xbcf7('0x24')](function(_0x3e2da2){_0x2006db[_0xbcf7('0x40')]=_0x3e2da2;if(_0x2e0f01[_0xbcf7('0x30')][_0xbcf7('0x41')]){_0x45af4a['include']=[{'all':!![]}];}return db[_0xbcf7('0x2b')][_0xbcf7('0x42')](_0x45af4a);})[_0xbcf7('0x24')](function(_0x3af49d){_0x2006db[_0xbcf7('0x43')]=_0x3af49d;return _0x2006db;})['then'](respondWithFilteredResult(_0x5bc226,_0x45af4a))[_0xbcf7('0x44')](handleError(_0x5bc226,null));};exports[_0xbcf7('0x45')]=function(_0x2cc909,_0x179afb){var _0x5462c9={'raw':![],'where':{'id':_0x2cc909[_0xbcf7('0x46')]['id']}},_0x546dd8={};_0x546dd8[_0xbcf7('0x2f')]=_[_0xbcf7('0x31')](db['Automation'][_0xbcf7('0x2c')]);_0x546dd8[_0xbcf7('0x30')]=_[_0xbcf7('0x31')](_0x2cc909[_0xbcf7('0x30')]);_0x546dd8['filters']=_['intersection'](_0x546dd8['model'],_0x546dd8[_0xbcf7('0x30')]);_0x5462c9[_0xbcf7('0x33')]=_['intersection'](_0x546dd8['model'],qs[_0xbcf7('0x35')](_0x2cc909[_0xbcf7('0x30')][_0xbcf7('0x35')]));_0x5462c9[_0xbcf7('0x33')]=_0x5462c9[_0xbcf7('0x33')][_0xbcf7('0x36')]?_0x5462c9[_0xbcf7('0x33')]:_0x546dd8['model'];if(_0x2cc909['query'][_0xbcf7('0x41')]){_0x5462c9['include']=[{'all':!![]}];}_0x5462c9=_[_0xbcf7('0x3d')]({},_0x5462c9,_0x2cc909[_0xbcf7('0x3f')]);return db[_0xbcf7('0x2b')]['find'](_0x5462c9)[_0xbcf7('0x24')](handleEntityNotFound(_0x179afb,null))['then'](respondWithResult(_0x179afb,null))['catch'](handleError(_0x179afb,null));};exports[_0xbcf7('0x47')]=function(_0xbf2f19,_0x28cea0){return db[_0xbcf7('0x2b')]['create'](_0xbf2f19[_0xbcf7('0x48')],{})['then'](respondWithResult(_0x28cea0,0xc9))[_0xbcf7('0x44')](handleError(_0x28cea0,null));};exports[_0xbcf7('0x49')]=function(_0x1cef3d,_0x4b5de4){if(_0x1cef3d['body']['id']){delete _0x1cef3d[_0xbcf7('0x48')]['id'];}return db['Automation'][_0xbcf7('0x4a')]({'where':{'id':_0x1cef3d[_0xbcf7('0x46')]['id']}})['then'](handleEntityNotFound(_0x4b5de4,null))['then'](saveUpdates(_0x1cef3d['body'],null))['then'](respondWithResult(_0x4b5de4,null))['catch'](handleError(_0x4b5de4,null));};exports[_0xbcf7('0x25')]=function(_0x46970b,_0xcfc37f){return db[_0xbcf7('0x2b')][_0xbcf7('0x4a')]({'where':{'id':_0x46970b['params']['id']}})[_0xbcf7('0x24')](handleEntityNotFound(_0xcfc37f,null))[_0xbcf7('0x24')](removeEntity(_0xcfc37f,null))['catch'](handleError(_0xcfc37f,null));};exports[_0xbcf7('0x4b')]=function(_0xf06b57,_0xc0e18e,_0x1ab964){return db[_0xbcf7('0x4c')][_0xbcf7('0x4a')]({'where':{'id':_0xf06b57[_0xbcf7('0x46')]['id']}})['then'](handleEntityNotFound(_0xc0e18e,null))['then'](function(_0x155151){if(_0x155151){return _0x155151[_0xbcf7('0x4b')](_0xf06b57['body']['ids'],_['omit'](_0xf06b57[_0xbcf7('0x48')],[_0xbcf7('0x4d'),'id'])||{});}})[_0xbcf7('0x24')](respondWithResult(_0xc0e18e,null))[_0xbcf7('0x44')](handleError(_0xc0e18e,null));};exports[_0xbcf7('0x4e')]=function(_0x35430e,_0x115bb4,_0x3d24ed){var _0x48c29c={};var _0x34e48d={};var _0x2a2fef;var _0x130042;return db[_0xbcf7('0x2b')][_0xbcf7('0x4f')]({'where':{'id':_0x35430e['params']['id']}})['then'](handleEntityNotFound(_0x115bb4,null))['then'](function(_0x48cbcf){if(_0x48cbcf){_0x2a2fef=_0x48cbcf;_0x34e48d[_0xbcf7('0x2f')]=_[_0xbcf7('0x31')](db[_0xbcf7('0x4c')][_0xbcf7('0x2c')]);_0x34e48d[_0xbcf7('0x30')]=_[_0xbcf7('0x31')](_0x35430e['query']);_0x34e48d[_0xbcf7('0x32')]=_[_0xbcf7('0x34')](_0x34e48d[_0xbcf7('0x2f')],_0x34e48d[_0xbcf7('0x30')]);_0x48c29c[_0xbcf7('0x33')]=_[_0xbcf7('0x34')](_0x34e48d[_0xbcf7('0x2f')],qs[_0xbcf7('0x35')](_0x35430e[_0xbcf7('0x30')][_0xbcf7('0x35')]));_0x48c29c[_0xbcf7('0x33')]=_0x48c29c[_0xbcf7('0x33')][_0xbcf7('0x36')]?_0x48c29c[_0xbcf7('0x33')]:_0x34e48d[_0xbcf7('0x2f')];_0x48c29c[_0xbcf7('0x39')]=qs['sort'](_0x35430e[_0xbcf7('0x30')]['sort']);_0x48c29c[_0xbcf7('0x3b')]=qs[_0xbcf7('0x32')](_[_0xbcf7('0x50')](_0x35430e['query'],_0x34e48d[_0xbcf7('0x32')]));if(_0x35430e[_0xbcf7('0x30')][_0xbcf7('0x3c')]){_0x48c29c[_0xbcf7('0x3b')]=_['merge'](_0x48c29c[_0xbcf7('0x3b')],{'$or':_[_0xbcf7('0x2a')](_0x48c29c[_0xbcf7('0x33')],function(_0x53f3f1){var _0xd127ca={};_0xd127ca[_0x53f3f1]={'$like':'%'+_0x35430e['query'][_0xbcf7('0x3c')]+'%'};return _0xd127ca;})});}_0x48c29c=_['merge']({},_0x48c29c,_0x35430e[_0xbcf7('0x3f')]);return _0x2a2fef[_0xbcf7('0x4e')](_0x48c29c);}})[_0xbcf7('0x24')](function(_0x3cd8cd){if(_0x3cd8cd){_0x130042=_0x3cd8cd['length'];if(!_0x35430e[_0xbcf7('0x30')][_0xbcf7('0x37')](_0xbcf7('0x38'))){_0x48c29c[_0xbcf7('0x1f')]=qs[_0xbcf7('0x1f')](_0x35430e['query'][_0xbcf7('0x1f')]);_0x48c29c[_0xbcf7('0x1e')]=qs[_0xbcf7('0x1e')](_0x35430e[_0xbcf7('0x30')][_0xbcf7('0x1e')]);}return _0x2a2fef[_0xbcf7('0x4e')](_0x48c29c);}})[_0xbcf7('0x24')](function(_0x44707c){if(_0x44707c){return _0x44707c?{'count':_0x130042,'rows':_0x44707c}:null;}})[_0xbcf7('0x24')](respondWithResult(_0x115bb4,null))[_0xbcf7('0x44')](handleError(_0x115bb4,null));};exports[_0xbcf7('0x51')]=function(_0x46b1c1,_0x5c77c9,_0x24e4ea){return db[_0xbcf7('0x52')][_0xbcf7('0x4a')]({'where':{'id':_0x46b1c1[_0xbcf7('0x46')]['id']}})[_0xbcf7('0x24')](handleEntityNotFound(_0x5c77c9,null))[_0xbcf7('0x24')](function(_0x89721e){if(_0x89721e){return _0x89721e['addActions'](_0x46b1c1[_0xbcf7('0x48')][_0xbcf7('0x4d')],_[_0xbcf7('0x53')](_0x46b1c1[_0xbcf7('0x48')],['ids','id'])||{});}})[_0xbcf7('0x24')](respondWithResult(_0x5c77c9,null))[_0xbcf7('0x44')](handleError(_0x5c77c9,null));};exports[_0xbcf7('0x54')]=function(_0x31a844,_0xe005f2,_0x80cbd4){var _0x3f844e={};var _0x4c84cd={};var _0x2ee4fe;var _0x132518;return db[_0xbcf7('0x2b')][_0xbcf7('0x4f')]({'where':{'id':_0x31a844[_0xbcf7('0x46')]['id']}})[_0xbcf7('0x24')](handleEntityNotFound(_0xe005f2,null))[_0xbcf7('0x24')](function(_0xdbb9cf){if(_0xdbb9cf){_0x2ee4fe=_0xdbb9cf;_0x4c84cd[_0xbcf7('0x2f')]=_[_0xbcf7('0x31')](db[_0xbcf7('0x52')]['rawAttributes']);_0x4c84cd[_0xbcf7('0x30')]=_[_0xbcf7('0x31')](_0x31a844[_0xbcf7('0x30')]);_0x4c84cd[_0xbcf7('0x32')]=_[_0xbcf7('0x34')](_0x4c84cd[_0xbcf7('0x2f')],_0x4c84cd[_0xbcf7('0x30')]);_0x3f844e[_0xbcf7('0x33')]=_[_0xbcf7('0x34')](_0x4c84cd[_0xbcf7('0x2f')],qs[_0xbcf7('0x35')](_0x31a844[_0xbcf7('0x30')][_0xbcf7('0x35')]));_0x3f844e[_0xbcf7('0x33')]=_0x3f844e[_0xbcf7('0x33')][_0xbcf7('0x36')]?_0x3f844e['attributes']:_0x4c84cd[_0xbcf7('0x2f')];_0x3f844e['order']=qs[_0xbcf7('0x3a')](_0x31a844['query'][_0xbcf7('0x3a')]);_0x3f844e[_0xbcf7('0x3b')]=qs[_0xbcf7('0x32')](_['pick'](_0x31a844['query'],_0x4c84cd[_0xbcf7('0x32')]));if(_0x31a844[_0xbcf7('0x30')][_0xbcf7('0x3c')]){_0x3f844e[_0xbcf7('0x3b')]=_[_0xbcf7('0x3d')](_0x3f844e['where'],{'$or':_[_0xbcf7('0x2a')](_0x3f844e['attributes'],function(_0x1f4ba0){var _0x2213f1={};_0x2213f1[_0x1f4ba0]={'$like':'%'+_0x31a844[_0xbcf7('0x30')]['filter']+'%'};return _0x2213f1;})});}_0x3f844e=_['merge']({},_0x3f844e,_0x31a844[_0xbcf7('0x3f')]);return _0x2ee4fe[_0xbcf7('0x54')](_0x3f844e);}})[_0xbcf7('0x24')](function(_0x4d2c94){if(_0x4d2c94){_0x132518=_0x4d2c94[_0xbcf7('0x36')];if(!_0x31a844[_0xbcf7('0x30')][_0xbcf7('0x37')](_0xbcf7('0x38'))){_0x3f844e[_0xbcf7('0x1f')]=qs[_0xbcf7('0x1f')](_0x31a844[_0xbcf7('0x30')][_0xbcf7('0x1f')]);_0x3f844e[_0xbcf7('0x1e')]=qs['offset'](_0x31a844['query'][_0xbcf7('0x1e')]);}return _0x2ee4fe['getActions'](_0x3f844e);}})[_0xbcf7('0x24')](function(_0x159ba3){if(_0x159ba3){return _0x159ba3?{'count':_0x132518,'rows':_0x159ba3}:null;}})[_0xbcf7('0x24')](respondWithResult(_0xe005f2,null))['catch'](handleError(_0xe005f2,null));};
\ No newline at end of file