Built motion from commit (unavailable).|2.5.4
[motion2.git] / server / api / automation / automation.controller.js
index c5cb0fe..2f26aa5 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x45f6=['body','addConditions','Condition','ids','omit','getConditions','findOne','pick','Action','addActions','getActions','html-pdf','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','sox','to-csv','ejs','lodash','squel','crypto','jsforce','desk.js','querystring','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','api','../../config/environment','../../mysqldb','sendStatus','status','end','json','count','offset','set','apply','reject','save','update','then','destroy','error','stack','name','send','index','map','Automation','rawAttributes','type','key','model','query','keys','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','limit','order','sort','where','filter','merge','VIRTUAL','options','findAll','rows','catch','show','params','includeAll','find','create'];(function(_0x2dea24,_0x2fc021){var _0x309d58=function(_0x2eb89f){while(--_0x2eb89f){_0x2dea24['push'](_0x2dea24['shift']());}};_0x309d58(++_0x2fc021);}(_0x45f6,0x110));var _0x645f=function(_0x4394b6,_0x12357f){_0x4394b6=_0x4394b6-0x0;var _0x360244=_0x45f6[_0x4394b6];return _0x360244;};'use strict';var pdf=require(_0x645f('0x0'));var emlformat=require(_0x645f('0x1'));var rimraf=require(_0x645f('0x2'));var zipdir=require(_0x645f('0x3'));var jsonpatch=require(_0x645f('0x4'));var rp=require(_0x645f('0x5'));var moment=require(_0x645f('0x6'));var BPromise=require(_0x645f('0x7'));var Mustache=require(_0x645f('0x8'));var util=require(_0x645f('0x9'));var path=require(_0x645f('0xa'));var sox=require(_0x645f('0xb'));var csv=require(_0x645f('0xc'));var ejs=require(_0x645f('0xd'));var fs=require('fs');var _=require(_0x645f('0xe'));var squel=require(_0x645f('0xf'));var crypto=require(_0x645f('0x10'));var jsforce=require(_0x645f('0x11'));var deskjs=require(_0x645f('0x12'));var toCsv=require(_0x645f('0xc'));var querystring=require(_0x645f('0x13'));var Papa=require('papaparse');var Redis=require(_0x645f('0x14'));var authService=require(_0x645f('0x15'));var qs=require(_0x645f('0x16'));var as=require(_0x645f('0x17'));var hardwareService=require('../../config/license/hardware');var logger=require('../../config/logger')(_0x645f('0x18'));var utils=require('../../config/utils');var config=require(_0x645f('0x19'));var db=require(_0x645f('0x1a'))['db'];function respondWithStatusCode(_0x348b0a,_0x16251c){_0x16251c=_0x16251c||0xcc;return function(_0x403493){if(_0x403493){return _0x348b0a[_0x645f('0x1b')](_0x16251c);}return _0x348b0a[_0x645f('0x1c')](_0x16251c)[_0x645f('0x1d')]();};}function respondWithResult(_0x14d3b2,_0x409fea){_0x409fea=_0x409fea||0xc8;return function(_0x17ad96){if(_0x17ad96){return _0x14d3b2['status'](_0x409fea)[_0x645f('0x1e')](_0x17ad96);}};}function respondWithFilteredResult(_0x39690a,_0x5b29f4){return function(_0x47518b){if(_0x47518b){var _0x49e48e=_0x47518b[_0x645f('0x1f')],_0x383862=_0x5b29f4[_0x645f('0x20')],_0x25a5b5=_0x5b29f4[_0x645f('0x20')]+_0x5b29f4['limit'],_0x426acf;if(_0x25a5b5>=_0x49e48e){_0x25a5b5=_0x49e48e;_0x426acf=0xc8;}else{_0x426acf=0xce;}_0x39690a[_0x645f('0x1c')](_0x426acf);return _0x39690a[_0x645f('0x21')]('Content-Range',_0x383862+'-'+_0x25a5b5+'/'+_0x49e48e)[_0x645f('0x1e')](_0x47518b);}return null;};}function patchUpdates(_0x2d3c06){return function(_0x56b41a){try{jsonpatch[_0x645f('0x22')](_0x56b41a,_0x2d3c06,!![]);}catch(_0x15cddf){return BPromise[_0x645f('0x23')](_0x15cddf);}return _0x56b41a[_0x645f('0x24')]();};}function saveUpdates(_0x2a2b42,_0x4c9b0e){return function(_0x45f752){if(_0x45f752){return _0x45f752[_0x645f('0x25')](_0x2a2b42)[_0x645f('0x26')](function(_0x552ad6){return _0x552ad6;});}return null;};}function removeEntity(_0x53e4d4,_0x283736){return function(_0x5307af){if(_0x5307af){return _0x5307af[_0x645f('0x27')]()[_0x645f('0x26')](function(){_0x53e4d4[_0x645f('0x1c')](0xcc)[_0x645f('0x1d')]();});}};}function handleEntityNotFound(_0x3e9c57,_0x1b5db5){return function(_0x38eb2c){if(!_0x38eb2c){_0x3e9c57[_0x645f('0x1b')](0x194);}return _0x38eb2c;};}function handleError(_0x6943,_0x5d3d2f){_0x5d3d2f=_0x5d3d2f||0x1f4;return function(_0x2b84c0){logger[_0x645f('0x28')](_0x2b84c0[_0x645f('0x29')]);if(_0x2b84c0[_0x645f('0x2a')]){delete _0x2b84c0['name'];}_0x6943[_0x645f('0x1c')](_0x5d3d2f)[_0x645f('0x2b')](_0x2b84c0);};}exports[_0x645f('0x2c')]=function(_0x1ed24f,_0x534bf7){var _0x21156e={},_0x676bd6={},_0x580f46={'count':0x0,'rows':[]};var _0x560cad=_[_0x645f('0x2d')](db[_0x645f('0x2e')][_0x645f('0x2f')],function(_0x233413){return{'name':_0x233413['fieldName'],'type':_0x233413[_0x645f('0x30')][_0x645f('0x31')]};});_0x676bd6[_0x645f('0x32')]=_[_0x645f('0x2d')](_0x560cad,_0x645f('0x2a'));_0x676bd6[_0x645f('0x33')]=_[_0x645f('0x34')](_0x1ed24f[_0x645f('0x33')]);_0x676bd6[_0x645f('0x35')]=_[_0x645f('0x36')](_0x676bd6[_0x645f('0x32')],_0x676bd6[_0x645f('0x33')]);_0x21156e[_0x645f('0x37')]=_['intersection'](_0x676bd6['model'],qs['fields'](_0x1ed24f['query'][_0x645f('0x38')]));_0x21156e['attributes']=_0x21156e[_0x645f('0x37')][_0x645f('0x39')]?_0x21156e[_0x645f('0x37')]:_0x676bd6[_0x645f('0x32')];if(!_0x1ed24f[_0x645f('0x33')][_0x645f('0x3a')](_0x645f('0x3b'))){_0x21156e['limit']=qs[_0x645f('0x3c')](_0x1ed24f[_0x645f('0x33')][_0x645f('0x3c')]);_0x21156e[_0x645f('0x20')]=qs[_0x645f('0x20')](_0x1ed24f[_0x645f('0x33')][_0x645f('0x20')]);}_0x21156e[_0x645f('0x3d')]=qs[_0x645f('0x3e')](_0x1ed24f[_0x645f('0x33')][_0x645f('0x3e')]);_0x21156e[_0x645f('0x3f')]=qs[_0x645f('0x35')](_['pick'](_0x1ed24f[_0x645f('0x33')],_0x676bd6[_0x645f('0x35')]),_0x560cad);if(_0x1ed24f[_0x645f('0x33')][_0x645f('0x40')]){_0x21156e[_0x645f('0x3f')]=_[_0x645f('0x41')](_0x21156e[_0x645f('0x3f')],{'$or':_[_0x645f('0x2d')](_0x560cad,function(_0x4ed096){if(_0x4ed096[_0x645f('0x30')]!==_0x645f('0x42')){var _0x49c196={};_0x49c196[_0x4ed096[_0x645f('0x2a')]]={'$like':'%'+_0x1ed24f['query'][_0x645f('0x40')]+'%'};return _0x49c196;}})});}_0x21156e=_[_0x645f('0x41')]({},_0x21156e,_0x1ed24f[_0x645f('0x43')]);var _0x407ad8={'where':_0x21156e['where']};return db[_0x645f('0x2e')][_0x645f('0x1f')](_0x407ad8)[_0x645f('0x26')](function(_0x23942c){_0x580f46[_0x645f('0x1f')]=_0x23942c;if(_0x1ed24f[_0x645f('0x33')]['includeAll']){_0x21156e['include']=[{'all':!![]}];}return db[_0x645f('0x2e')][_0x645f('0x44')](_0x21156e);})[_0x645f('0x26')](function(_0x7e765b){_0x580f46[_0x645f('0x45')]=_0x7e765b;return _0x580f46;})['then'](respondWithFilteredResult(_0x534bf7,_0x21156e))[_0x645f('0x46')](handleError(_0x534bf7,null));};exports[_0x645f('0x47')]=function(_0x5d16ce,_0x5c2ed2){var _0x5f3b57={'raw':![],'where':{'id':_0x5d16ce[_0x645f('0x48')]['id']}},_0xab1bc4={};_0xab1bc4[_0x645f('0x32')]=_[_0x645f('0x34')](db[_0x645f('0x2e')][_0x645f('0x2f')]);_0xab1bc4[_0x645f('0x33')]=_['keys'](_0x5d16ce['query']);_0xab1bc4['filters']=_['intersection'](_0xab1bc4[_0x645f('0x32')],_0xab1bc4[_0x645f('0x33')]);_0x5f3b57[_0x645f('0x37')]=_['intersection'](_0xab1bc4['model'],qs[_0x645f('0x38')](_0x5d16ce[_0x645f('0x33')]['fields']));_0x5f3b57[_0x645f('0x37')]=_0x5f3b57[_0x645f('0x37')][_0x645f('0x39')]?_0x5f3b57['attributes']:_0xab1bc4[_0x645f('0x32')];if(_0x5d16ce[_0x645f('0x33')][_0x645f('0x49')]){_0x5f3b57['include']=[{'all':!![]}];}_0x5f3b57=_[_0x645f('0x41')]({},_0x5f3b57,_0x5d16ce[_0x645f('0x43')]);return db[_0x645f('0x2e')][_0x645f('0x4a')](_0x5f3b57)[_0x645f('0x26')](handleEntityNotFound(_0x5c2ed2,null))[_0x645f('0x26')](respondWithResult(_0x5c2ed2,null))[_0x645f('0x46')](handleError(_0x5c2ed2,null));};exports[_0x645f('0x4b')]=function(_0xef2940,_0x5964f4){return db[_0x645f('0x2e')]['create'](_0xef2940[_0x645f('0x4c')],{})[_0x645f('0x26')](respondWithResult(_0x5964f4,0xc9))[_0x645f('0x46')](handleError(_0x5964f4,null));};exports['update']=function(_0x51d3ed,_0x4a6c79){if(_0x51d3ed['body']['id']){delete _0x51d3ed['body']['id'];}return db['Automation'][_0x645f('0x4a')]({'where':{'id':_0x51d3ed['params']['id']}})[_0x645f('0x26')](handleEntityNotFound(_0x4a6c79,null))[_0x645f('0x26')](saveUpdates(_0x51d3ed['body'],null))[_0x645f('0x26')](respondWithResult(_0x4a6c79,null))['catch'](handleError(_0x4a6c79,null));};exports[_0x645f('0x27')]=function(_0x51623b,_0x3d42e8){return db['Automation'][_0x645f('0x4a')]({'where':{'id':_0x51623b[_0x645f('0x48')]['id']}})[_0x645f('0x26')](handleEntityNotFound(_0x3d42e8,null))[_0x645f('0x26')](removeEntity(_0x3d42e8,null))[_0x645f('0x46')](handleError(_0x3d42e8,null));};exports[_0x645f('0x4d')]=function(_0x560f70,_0xb5e24b,_0x574bec){return db[_0x645f('0x4e')][_0x645f('0x4a')]({'where':{'id':_0x560f70['params']['id']}})[_0x645f('0x26')](handleEntityNotFound(_0xb5e24b,null))[_0x645f('0x26')](function(_0x56c990){if(_0x56c990){return _0x56c990[_0x645f('0x4d')](_0x560f70['body'][_0x645f('0x4f')],_[_0x645f('0x50')](_0x560f70[_0x645f('0x4c')],[_0x645f('0x4f'),'id'])||{});}})[_0x645f('0x26')](respondWithResult(_0xb5e24b,null))['catch'](handleError(_0xb5e24b,null));};exports[_0x645f('0x51')]=function(_0x2ac73b,_0x45c7bd,_0x103760){var _0x1cdc84={};var _0x2fedcc={};var _0x597dd2;var _0x208d8c;return db[_0x645f('0x2e')][_0x645f('0x52')]({'where':{'id':_0x2ac73b[_0x645f('0x48')]['id']}})[_0x645f('0x26')](handleEntityNotFound(_0x45c7bd,null))[_0x645f('0x26')](function(_0x268837){if(_0x268837){_0x597dd2=_0x268837;_0x2fedcc['model']=_['keys'](db[_0x645f('0x4e')][_0x645f('0x2f')]);_0x2fedcc[_0x645f('0x33')]=_[_0x645f('0x34')](_0x2ac73b[_0x645f('0x33')]);_0x2fedcc[_0x645f('0x35')]=_[_0x645f('0x36')](_0x2fedcc[_0x645f('0x32')],_0x2fedcc[_0x645f('0x33')]);_0x1cdc84[_0x645f('0x37')]=_['intersection'](_0x2fedcc['model'],qs[_0x645f('0x38')](_0x2ac73b[_0x645f('0x33')]['fields']));_0x1cdc84[_0x645f('0x37')]=_0x1cdc84[_0x645f('0x37')][_0x645f('0x39')]?_0x1cdc84[_0x645f('0x37')]:_0x2fedcc[_0x645f('0x32')];_0x1cdc84[_0x645f('0x3d')]=qs[_0x645f('0x3e')](_0x2ac73b[_0x645f('0x33')][_0x645f('0x3e')]);_0x1cdc84[_0x645f('0x3f')]=qs[_0x645f('0x35')](_[_0x645f('0x53')](_0x2ac73b['query'],_0x2fedcc[_0x645f('0x35')]));if(_0x2ac73b[_0x645f('0x33')][_0x645f('0x40')]){_0x1cdc84['where']=_[_0x645f('0x41')](_0x1cdc84[_0x645f('0x3f')],{'$or':_['map'](_0x1cdc84[_0x645f('0x37')],function(_0x2eb030){var _0x2aa5c1={};_0x2aa5c1[_0x2eb030]={'$like':'%'+_0x2ac73b[_0x645f('0x33')][_0x645f('0x40')]+'%'};return _0x2aa5c1;})});}_0x1cdc84=_[_0x645f('0x41')]({},_0x1cdc84,_0x2ac73b[_0x645f('0x43')]);return _0x597dd2['getConditions'](_0x1cdc84);}})['then'](function(_0x317191){if(_0x317191){_0x208d8c=_0x317191['length'];if(!_0x2ac73b[_0x645f('0x33')][_0x645f('0x3a')](_0x645f('0x3b'))){_0x1cdc84[_0x645f('0x3c')]=qs[_0x645f('0x3c')](_0x2ac73b[_0x645f('0x33')]['limit']);_0x1cdc84[_0x645f('0x20')]=qs['offset'](_0x2ac73b[_0x645f('0x33')][_0x645f('0x20')]);}return _0x597dd2[_0x645f('0x51')](_0x1cdc84);}})['then'](function(_0xf2ae00){if(_0xf2ae00){return _0xf2ae00?{'count':_0x208d8c,'rows':_0xf2ae00}:null;}})[_0x645f('0x26')](respondWithResult(_0x45c7bd,null))[_0x645f('0x46')](handleError(_0x45c7bd,null));};exports['addActions']=function(_0x207fd8,_0x1b6803,_0x53ed4c){return db[_0x645f('0x54')][_0x645f('0x4a')]({'where':{'id':_0x207fd8[_0x645f('0x48')]['id']}})[_0x645f('0x26')](handleEntityNotFound(_0x1b6803,null))[_0x645f('0x26')](function(_0x440b8e){if(_0x440b8e){return _0x440b8e[_0x645f('0x55')](_0x207fd8[_0x645f('0x4c')][_0x645f('0x4f')],_['omit'](_0x207fd8['body'],['ids','id'])||{});}})[_0x645f('0x26')](respondWithResult(_0x1b6803,null))[_0x645f('0x46')](handleError(_0x1b6803,null));};exports[_0x645f('0x56')]=function(_0x400602,_0x219df4,_0x2d6d74){var _0x20e849={};var _0x22a633={};var _0x456b67;var _0x3cf33d;return db['Automation'][_0x645f('0x52')]({'where':{'id':_0x400602[_0x645f('0x48')]['id']}})[_0x645f('0x26')](handleEntityNotFound(_0x219df4,null))[_0x645f('0x26')](function(_0xeac092){if(_0xeac092){_0x456b67=_0xeac092;_0x22a633[_0x645f('0x32')]=_[_0x645f('0x34')](db[_0x645f('0x54')][_0x645f('0x2f')]);_0x22a633[_0x645f('0x33')]=_[_0x645f('0x34')](_0x400602[_0x645f('0x33')]);_0x22a633[_0x645f('0x35')]=_[_0x645f('0x36')](_0x22a633[_0x645f('0x32')],_0x22a633[_0x645f('0x33')]);_0x20e849[_0x645f('0x37')]=_[_0x645f('0x36')](_0x22a633[_0x645f('0x32')],qs['fields'](_0x400602[_0x645f('0x33')]['fields']));_0x20e849['attributes']=_0x20e849[_0x645f('0x37')][_0x645f('0x39')]?_0x20e849[_0x645f('0x37')]:_0x22a633[_0x645f('0x32')];_0x20e849[_0x645f('0x3d')]=qs['sort'](_0x400602['query'][_0x645f('0x3e')]);_0x20e849[_0x645f('0x3f')]=qs[_0x645f('0x35')](_['pick'](_0x400602['query'],_0x22a633['filters']));if(_0x400602['query'][_0x645f('0x40')]){_0x20e849[_0x645f('0x3f')]=_[_0x645f('0x41')](_0x20e849[_0x645f('0x3f')],{'$or':_[_0x645f('0x2d')](_0x20e849[_0x645f('0x37')],function(_0x9e3f5f){var _0x465e6b={};_0x465e6b[_0x9e3f5f]={'$like':'%'+_0x400602[_0x645f('0x33')][_0x645f('0x40')]+'%'};return _0x465e6b;})});}_0x20e849=_[_0x645f('0x41')]({},_0x20e849,_0x400602[_0x645f('0x43')]);return _0x456b67[_0x645f('0x56')](_0x20e849);}})[_0x645f('0x26')](function(_0x6ef96b){if(_0x6ef96b){_0x3cf33d=_0x6ef96b[_0x645f('0x39')];if(!_0x400602[_0x645f('0x33')][_0x645f('0x3a')]('nolimit')){_0x20e849[_0x645f('0x3c')]=qs['limit'](_0x400602[_0x645f('0x33')]['limit']);_0x20e849[_0x645f('0x20')]=qs[_0x645f('0x20')](_0x400602[_0x645f('0x33')]['offset']);}return _0x456b67['getActions'](_0x20e849);}})['then'](function(_0x306fe7){if(_0x306fe7){return _0x306fe7?{'count':_0x3cf33d,'rows':_0x306fe7}:null;}})[_0x645f('0x26')](respondWithResult(_0x219df4,null))[_0x645f('0x46')](handleError(_0x219df4,null));};
\ No newline at end of file
+var _0x6b98=['sort','where','filter','VIRTUAL','merge','options','includeAll','include','findAll','catch','show','rawAttributes','find','create','body','params','addConditions','omit','getConditions','Condition','order','pick','Action','ids','findOne','getActions','html-pdf','eml-format','fast-json-patch','moment','mustache','util','path','sox','to-csv','squel','crypto','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/logger','api','../../config/utils','end','status','json','count','offset','limit','set','Content-Range','reject','save','update','then','destroy','sendStatus','error','stack','name','send','index','map','Automation','fieldName','type','key','model','query','keys','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit'];(function(_0x18d6bf,_0x5fb49b){var _0x28dac7=function(_0x2a1e25){while(--_0x2a1e25){_0x18d6bf['push'](_0x18d6bf['shift']());}};_0x28dac7(++_0x5fb49b);}(_0x6b98,0x1af));var _0x86b9=function(_0x421cf8,_0x23152c){_0x421cf8=_0x421cf8-0x0;var _0x145c48=_0x6b98[_0x421cf8];return _0x145c48;};'use strict';var pdf=require(_0x86b9('0x0'));var emlformat=require(_0x86b9('0x1'));var rimraf=require('rimraf');var zipdir=require('zip-dir');var jsonpatch=require(_0x86b9('0x2'));var rp=require('request-promise');var moment=require(_0x86b9('0x3'));var BPromise=require('bluebird');var Mustache=require(_0x86b9('0x4'));var util=require(_0x86b9('0x5'));var path=require(_0x86b9('0x6'));var sox=require(_0x86b9('0x7'));var csv=require(_0x86b9('0x8'));var ejs=require('ejs');var fs=require('fs');var _=require('lodash');var squel=require(_0x86b9('0x9'));var crypto=require(_0x86b9('0xa'));var jsforce=require('jsforce');var deskjs=require(_0x86b9('0xb'));var toCsv=require(_0x86b9('0x8'));var querystring=require(_0x86b9('0xc'));var Papa=require(_0x86b9('0xd'));var Redis=require(_0x86b9('0xe'));var authService=require(_0x86b9('0xf'));var qs=require(_0x86b9('0x10'));var as=require(_0x86b9('0x11'));var hardwareService=require('../../config/license/hardware');var logger=require(_0x86b9('0x12'))(_0x86b9('0x13'));var utils=require(_0x86b9('0x14'));var config=require('../../config/environment');var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x429cca,_0x138701){_0x138701=_0x138701||0xcc;return function(_0x17ce03){if(_0x17ce03){return _0x429cca['sendStatus'](_0x138701);}return _0x429cca['status'](_0x138701)[_0x86b9('0x15')]();};}function respondWithResult(_0x108018,_0x54c088){_0x54c088=_0x54c088||0xc8;return function(_0x39906c){if(_0x39906c){return _0x108018[_0x86b9('0x16')](_0x54c088)[_0x86b9('0x17')](_0x39906c);}};}function respondWithFilteredResult(_0x42ceb7,_0x13b644){return function(_0x11d450){if(_0x11d450){var _0x156eee=_0x11d450[_0x86b9('0x18')],_0x42e0ab=_0x13b644[_0x86b9('0x19')],_0x494602=_0x13b644['offset']+_0x13b644[_0x86b9('0x1a')],_0x1230f3;if(_0x494602>=_0x156eee){_0x494602=_0x156eee;_0x1230f3=0xc8;}else{_0x1230f3=0xce;}_0x42ceb7[_0x86b9('0x16')](_0x1230f3);return _0x42ceb7[_0x86b9('0x1b')](_0x86b9('0x1c'),_0x42e0ab+'-'+_0x494602+'/'+_0x156eee)[_0x86b9('0x17')](_0x11d450);}return null;};}function patchUpdates(_0xb9b06f){return function(_0x15747a){try{jsonpatch['apply'](_0x15747a,_0xb9b06f,!![]);}catch(_0x23a4f3){return BPromise[_0x86b9('0x1d')](_0x23a4f3);}return _0x15747a[_0x86b9('0x1e')]();};}function saveUpdates(_0x394d40,_0x21b51a){return function(_0x3ecb37){if(_0x3ecb37){return _0x3ecb37[_0x86b9('0x1f')](_0x394d40)[_0x86b9('0x20')](function(_0x26d318){return _0x26d318;});}return null;};}function removeEntity(_0x1d83d7,_0x40480d){return function(_0xde91b){if(_0xde91b){return _0xde91b[_0x86b9('0x21')]()[_0x86b9('0x20')](function(){_0x1d83d7[_0x86b9('0x16')](0xcc)['end']();});}};}function handleEntityNotFound(_0x3810e2,_0x17cb2c){return function(_0xd658af){if(!_0xd658af){_0x3810e2[_0x86b9('0x22')](0x194);}return _0xd658af;};}function handleError(_0x57d46f,_0x228dcc){_0x228dcc=_0x228dcc||0x1f4;return function(_0x467452){logger[_0x86b9('0x23')](_0x467452[_0x86b9('0x24')]);if(_0x467452['name']){delete _0x467452[_0x86b9('0x25')];}_0x57d46f[_0x86b9('0x16')](_0x228dcc)[_0x86b9('0x26')](_0x467452);};}exports[_0x86b9('0x27')]=function(_0x36a2c0,_0x4a89ab){var _0x560f1d={},_0x1c7330={},_0xa63e23={'count':0x0,'rows':[]};var _0x5e1394=_[_0x86b9('0x28')](db[_0x86b9('0x29')]['rawAttributes'],function(_0x43eb87){return{'name':_0x43eb87[_0x86b9('0x2a')],'type':_0x43eb87[_0x86b9('0x2b')][_0x86b9('0x2c')]};});_0x1c7330[_0x86b9('0x2d')]=_['map'](_0x5e1394,_0x86b9('0x25'));_0x1c7330[_0x86b9('0x2e')]=_[_0x86b9('0x2f')](_0x36a2c0[_0x86b9('0x2e')]);_0x1c7330[_0x86b9('0x30')]=_[_0x86b9('0x31')](_0x1c7330[_0x86b9('0x2d')],_0x1c7330[_0x86b9('0x2e')]);_0x560f1d[_0x86b9('0x32')]=_['intersection'](_0x1c7330[_0x86b9('0x2d')],qs[_0x86b9('0x33')](_0x36a2c0[_0x86b9('0x2e')][_0x86b9('0x33')]));_0x560f1d[_0x86b9('0x32')]=_0x560f1d[_0x86b9('0x32')][_0x86b9('0x34')]?_0x560f1d[_0x86b9('0x32')]:_0x1c7330[_0x86b9('0x2d')];if(!_0x36a2c0[_0x86b9('0x2e')][_0x86b9('0x35')](_0x86b9('0x36'))){_0x560f1d[_0x86b9('0x1a')]=qs['limit'](_0x36a2c0['query'][_0x86b9('0x1a')]);_0x560f1d[_0x86b9('0x19')]=qs[_0x86b9('0x19')](_0x36a2c0[_0x86b9('0x2e')][_0x86b9('0x19')]);}_0x560f1d['order']=qs[_0x86b9('0x37')](_0x36a2c0[_0x86b9('0x2e')][_0x86b9('0x37')]);_0x560f1d[_0x86b9('0x38')]=qs['filters'](_['pick'](_0x36a2c0['query'],_0x1c7330[_0x86b9('0x30')]),_0x5e1394);if(_0x36a2c0[_0x86b9('0x2e')][_0x86b9('0x39')]){_0x560f1d['where']=_['merge'](_0x560f1d[_0x86b9('0x38')],{'$or':_[_0x86b9('0x28')](_0x5e1394,function(_0x23d421){if(_0x23d421[_0x86b9('0x2b')]!==_0x86b9('0x3a')){var _0x512f39={};_0x512f39[_0x23d421[_0x86b9('0x25')]]={'$like':'%'+_0x36a2c0[_0x86b9('0x2e')][_0x86b9('0x39')]+'%'};return _0x512f39;}})});}_0x560f1d=_[_0x86b9('0x3b')]({},_0x560f1d,_0x36a2c0[_0x86b9('0x3c')]);var _0x5bc25a={'where':_0x560f1d[_0x86b9('0x38')]};return db[_0x86b9('0x29')][_0x86b9('0x18')](_0x5bc25a)[_0x86b9('0x20')](function(_0x14af01){_0xa63e23[_0x86b9('0x18')]=_0x14af01;if(_0x36a2c0['query'][_0x86b9('0x3d')]){_0x560f1d[_0x86b9('0x3e')]=[{'all':!![]}];}return db[_0x86b9('0x29')][_0x86b9('0x3f')](_0x560f1d);})[_0x86b9('0x20')](function(_0x50e25e){_0xa63e23['rows']=_0x50e25e;return _0xa63e23;})[_0x86b9('0x20')](respondWithFilteredResult(_0x4a89ab,_0x560f1d))[_0x86b9('0x40')](handleError(_0x4a89ab,null));};exports[_0x86b9('0x41')]=function(_0x5b4182,_0x4d4f85){var _0x3cf3bb={'raw':![],'where':{'id':_0x5b4182['params']['id']}},_0x5cf8b8={};_0x5cf8b8[_0x86b9('0x2d')]=_['keys'](db['Automation'][_0x86b9('0x42')]);_0x5cf8b8[_0x86b9('0x2e')]=_[_0x86b9('0x2f')](_0x5b4182[_0x86b9('0x2e')]);_0x5cf8b8[_0x86b9('0x30')]=_[_0x86b9('0x31')](_0x5cf8b8[_0x86b9('0x2d')],_0x5cf8b8['query']);_0x3cf3bb[_0x86b9('0x32')]=_['intersection'](_0x5cf8b8[_0x86b9('0x2d')],qs[_0x86b9('0x33')](_0x5b4182['query'][_0x86b9('0x33')]));_0x3cf3bb[_0x86b9('0x32')]=_0x3cf3bb[_0x86b9('0x32')][_0x86b9('0x34')]?_0x3cf3bb[_0x86b9('0x32')]:_0x5cf8b8[_0x86b9('0x2d')];if(_0x5b4182[_0x86b9('0x2e')]['includeAll']){_0x3cf3bb[_0x86b9('0x3e')]=[{'all':!![]}];}_0x3cf3bb=_[_0x86b9('0x3b')]({},_0x3cf3bb,_0x5b4182[_0x86b9('0x3c')]);return db[_0x86b9('0x29')][_0x86b9('0x43')](_0x3cf3bb)[_0x86b9('0x20')](handleEntityNotFound(_0x4d4f85,null))[_0x86b9('0x20')](respondWithResult(_0x4d4f85,null))['catch'](handleError(_0x4d4f85,null));};exports[_0x86b9('0x44')]=function(_0x320e55,_0xe9471c){return db[_0x86b9('0x29')]['create'](_0x320e55[_0x86b9('0x45')],{})[_0x86b9('0x20')](respondWithResult(_0xe9471c,0xc9))[_0x86b9('0x40')](handleError(_0xe9471c,null));};exports[_0x86b9('0x1f')]=function(_0x3bbdcf,_0x3377d6){if(_0x3bbdcf[_0x86b9('0x45')]['id']){delete _0x3bbdcf[_0x86b9('0x45')]['id'];}return db[_0x86b9('0x29')]['find']({'where':{'id':_0x3bbdcf[_0x86b9('0x46')]['id']}})[_0x86b9('0x20')](handleEntityNotFound(_0x3377d6,null))[_0x86b9('0x20')](saveUpdates(_0x3bbdcf[_0x86b9('0x45')],null))['then'](respondWithResult(_0x3377d6,null))[_0x86b9('0x40')](handleError(_0x3377d6,null));};exports[_0x86b9('0x21')]=function(_0x49b384,_0x1ecc86){return db['Automation']['find']({'where':{'id':_0x49b384['params']['id']}})[_0x86b9('0x20')](handleEntityNotFound(_0x1ecc86,null))['then'](removeEntity(_0x1ecc86,null))[_0x86b9('0x40')](handleError(_0x1ecc86,null));};exports[_0x86b9('0x47')]=function(_0x4a76ba,_0x1926c4,_0x3b501c){return db['Condition'][_0x86b9('0x43')]({'where':{'id':_0x4a76ba[_0x86b9('0x46')]['id']}})[_0x86b9('0x20')](handleEntityNotFound(_0x1926c4,null))[_0x86b9('0x20')](function(_0x35cab4){if(_0x35cab4){return _0x35cab4[_0x86b9('0x47')](_0x4a76ba[_0x86b9('0x45')]['ids'],_[_0x86b9('0x48')](_0x4a76ba[_0x86b9('0x45')],['ids','id'])||{});}})[_0x86b9('0x20')](respondWithResult(_0x1926c4,null))[_0x86b9('0x40')](handleError(_0x1926c4,null));};exports[_0x86b9('0x49')]=function(_0x2f651c,_0x2ce35f,_0xe0214c){var _0x5a3616={};var _0x5a47b5={};var _0x205ad3;var _0x3f204a;return db[_0x86b9('0x29')]['findOne']({'where':{'id':_0x2f651c[_0x86b9('0x46')]['id']}})[_0x86b9('0x20')](handleEntityNotFound(_0x2ce35f,null))[_0x86b9('0x20')](function(_0x407215){if(_0x407215){_0x205ad3=_0x407215;_0x5a47b5[_0x86b9('0x2d')]=_[_0x86b9('0x2f')](db[_0x86b9('0x4a')][_0x86b9('0x42')]);_0x5a47b5['query']=_[_0x86b9('0x2f')](_0x2f651c['query']);_0x5a47b5[_0x86b9('0x30')]=_[_0x86b9('0x31')](_0x5a47b5[_0x86b9('0x2d')],_0x5a47b5[_0x86b9('0x2e')]);_0x5a3616[_0x86b9('0x32')]=_[_0x86b9('0x31')](_0x5a47b5[_0x86b9('0x2d')],qs[_0x86b9('0x33')](_0x2f651c['query'][_0x86b9('0x33')]));_0x5a3616[_0x86b9('0x32')]=_0x5a3616[_0x86b9('0x32')][_0x86b9('0x34')]?_0x5a3616[_0x86b9('0x32')]:_0x5a47b5[_0x86b9('0x2d')];_0x5a3616[_0x86b9('0x4b')]=qs[_0x86b9('0x37')](_0x2f651c[_0x86b9('0x2e')]['sort']);_0x5a3616[_0x86b9('0x38')]=qs[_0x86b9('0x30')](_[_0x86b9('0x4c')](_0x2f651c['query'],_0x5a47b5[_0x86b9('0x30')]));if(_0x2f651c[_0x86b9('0x2e')][_0x86b9('0x39')]){_0x5a3616[_0x86b9('0x38')]=_[_0x86b9('0x3b')](_0x5a3616[_0x86b9('0x38')],{'$or':_[_0x86b9('0x28')](_0x5a3616[_0x86b9('0x32')],function(_0x7bff69){var _0x414f8b={};_0x414f8b[_0x7bff69]={'$like':'%'+_0x2f651c[_0x86b9('0x2e')][_0x86b9('0x39')]+'%'};return _0x414f8b;})});}_0x5a3616=_[_0x86b9('0x3b')]({},_0x5a3616,_0x2f651c['options']);return _0x205ad3[_0x86b9('0x49')](_0x5a3616);}})['then'](function(_0xa885eb){if(_0xa885eb){_0x3f204a=_0xa885eb[_0x86b9('0x34')];if(!_0x2f651c[_0x86b9('0x2e')]['hasOwnProperty'](_0x86b9('0x36'))){_0x5a3616[_0x86b9('0x1a')]=qs[_0x86b9('0x1a')](_0x2f651c['query'][_0x86b9('0x1a')]);_0x5a3616[_0x86b9('0x19')]=qs[_0x86b9('0x19')](_0x2f651c['query']['offset']);}return _0x205ad3[_0x86b9('0x49')](_0x5a3616);}})[_0x86b9('0x20')](function(_0x365d0c){if(_0x365d0c){return _0x365d0c?{'count':_0x3f204a,'rows':_0x365d0c}:null;}})['then'](respondWithResult(_0x2ce35f,null))['catch'](handleError(_0x2ce35f,null));};exports['addActions']=function(_0x52103e,_0x319f5a,_0x41874d){return db[_0x86b9('0x4d')][_0x86b9('0x43')]({'where':{'id':_0x52103e[_0x86b9('0x46')]['id']}})[_0x86b9('0x20')](handleEntityNotFound(_0x319f5a,null))[_0x86b9('0x20')](function(_0x406cda){if(_0x406cda){return _0x406cda['addActions'](_0x52103e[_0x86b9('0x45')]['ids'],_[_0x86b9('0x48')](_0x52103e[_0x86b9('0x45')],[_0x86b9('0x4e'),'id'])||{});}})[_0x86b9('0x20')](respondWithResult(_0x319f5a,null))[_0x86b9('0x40')](handleError(_0x319f5a,null));};exports['getActions']=function(_0x36343b,_0x18e823,_0xa38910){var _0x5c0939={};var _0x1641c9={};var _0x8bf7d4;var _0x3f18bb;return db['Automation'][_0x86b9('0x4f')]({'where':{'id':_0x36343b[_0x86b9('0x46')]['id']}})['then'](handleEntityNotFound(_0x18e823,null))[_0x86b9('0x20')](function(_0xbbd733){if(_0xbbd733){_0x8bf7d4=_0xbbd733;_0x1641c9[_0x86b9('0x2d')]=_[_0x86b9('0x2f')](db[_0x86b9('0x4d')][_0x86b9('0x42')]);_0x1641c9['query']=_[_0x86b9('0x2f')](_0x36343b['query']);_0x1641c9['filters']=_[_0x86b9('0x31')](_0x1641c9['model'],_0x1641c9['query']);_0x5c0939['attributes']=_[_0x86b9('0x31')](_0x1641c9['model'],qs[_0x86b9('0x33')](_0x36343b['query']['fields']));_0x5c0939[_0x86b9('0x32')]=_0x5c0939[_0x86b9('0x32')]['length']?_0x5c0939[_0x86b9('0x32')]:_0x1641c9['model'];_0x5c0939['order']=qs[_0x86b9('0x37')](_0x36343b[_0x86b9('0x2e')][_0x86b9('0x37')]);_0x5c0939[_0x86b9('0x38')]=qs[_0x86b9('0x30')](_[_0x86b9('0x4c')](_0x36343b[_0x86b9('0x2e')],_0x1641c9['filters']));if(_0x36343b[_0x86b9('0x2e')][_0x86b9('0x39')]){_0x5c0939[_0x86b9('0x38')]=_[_0x86b9('0x3b')](_0x5c0939['where'],{'$or':_[_0x86b9('0x28')](_0x5c0939[_0x86b9('0x32')],function(_0x591e6c){var _0x307414={};_0x307414[_0x591e6c]={'$like':'%'+_0x36343b[_0x86b9('0x2e')][_0x86b9('0x39')]+'%'};return _0x307414;})});}_0x5c0939=_[_0x86b9('0x3b')]({},_0x5c0939,_0x36343b['options']);return _0x8bf7d4['getActions'](_0x5c0939);}})[_0x86b9('0x20')](function(_0x52feec){if(_0x52feec){_0x3f18bb=_0x52feec[_0x86b9('0x34')];if(!_0x36343b['query'][_0x86b9('0x35')]('nolimit')){_0x5c0939[_0x86b9('0x1a')]=qs[_0x86b9('0x1a')](_0x36343b[_0x86b9('0x2e')][_0x86b9('0x1a')]);_0x5c0939[_0x86b9('0x19')]=qs['offset'](_0x36343b['query'][_0x86b9('0x19')]);}return _0x8bf7d4[_0x86b9('0x50')](_0x5c0939);}})[_0x86b9('0x20')](function(_0x3090d2){if(_0x3090d2){return _0x3090d2?{'count':_0x3f18bb,'rows':_0x3090d2}:null;}})[_0x86b9('0x20')](respondWithResult(_0x18e823,null))['catch'](handleError(_0x18e823,null));};
\ No newline at end of file