Built motion from commit fe909640.|2.6.8
[motion2.git] / server / api / automation / automation.controller.js
index 52506c3..358edbc 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x1bc2=['../../mysqldb','status','end','json','offset','undefined','limit','count','set','apply','reject','update','destroy','then','sendStatus','error','stack','name','index','map','Automation','rawAttributes','fieldName','key','query','filters','model','attributes','fields','length','hasOwnProperty','nolimit','order','sort','where','pick','filter','merge','VIRTUAL','includeAll','include','findAll','rows','catch','show','params','keys','intersection','options','create','body','find','addConditions','ids','getConditions','findOne','Condition','addActions','Action','omit','getActions','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','sox','to-csv','fs-extra','lodash','crypto','jsforce','desk.js','papaparse','ioredis','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','../../config/utils','../../config/environment','../../config/license/util'];(function(_0x32a767,_0x4e3e76){var _0x2b4e6d=function(_0x5e0702){while(--_0x5e0702){_0x32a767['push'](_0x32a767['shift']());}};_0x2b4e6d(++_0x4e3e76);}(_0x1bc2,0x199));var _0x21bc=function(_0x5c1098,_0x2400a5){_0x5c1098=_0x5c1098-0x0;var _0x2d9090=_0x1bc2[_0x5c1098];return _0x2d9090;};'use strict';var emlformat=require(_0x21bc('0x0'));var rimraf=require(_0x21bc('0x1'));var zipdir=require(_0x21bc('0x2'));var jsonpatch=require(_0x21bc('0x3'));var rp=require(_0x21bc('0x4'));var moment=require(_0x21bc('0x5'));var BPromise=require(_0x21bc('0x6'));var Mustache=require(_0x21bc('0x7'));var util=require(_0x21bc('0x8'));var path=require(_0x21bc('0x9'));var sox=require(_0x21bc('0xa'));var csv=require(_0x21bc('0xb'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0x21bc('0xc'));var _=require(_0x21bc('0xd'));var squel=require('squel');var crypto=require(_0x21bc('0xe'));var jsforce=require(_0x21bc('0xf'));var deskjs=require(_0x21bc('0x10'));var toCsv=require(_0x21bc('0xb'));var querystring=require('querystring');var Papa=require(_0x21bc('0x11'));var Redis=require(_0x21bc('0x12'));var authService=require('../../components/auth/service');var qs=require(_0x21bc('0x13'));var as=require(_0x21bc('0x14'));var hardwareService=require(_0x21bc('0x15'));var logger=require(_0x21bc('0x16'))('api');var utils=require(_0x21bc('0x17'));var config=require(_0x21bc('0x18'));var licenseUtil=require(_0x21bc('0x19'));var db=require(_0x21bc('0x1a'))['db'];function respondWithStatusCode(_0xe31938,_0x261702){_0x261702=_0x261702||0xcc;return function(_0x416359){if(_0x416359){return _0xe31938['sendStatus'](_0x261702);}return _0xe31938[_0x21bc('0x1b')](_0x261702)[_0x21bc('0x1c')]();};}function respondWithResult(_0x304f02,_0x424c6b){_0x424c6b=_0x424c6b||0xc8;return function(_0x32a761){if(_0x32a761){return _0x304f02[_0x21bc('0x1b')](_0x424c6b)[_0x21bc('0x1d')](_0x32a761);}};}function respondWithFilteredResult(_0x3fe7f3,_0xa0d2ca){return function(_0x322979){if(_0x322979){var _0x3785e4=typeof _0xa0d2ca[_0x21bc('0x1e')]===_0x21bc('0x1f')&&typeof _0xa0d2ca[_0x21bc('0x20')]==='undefined';var _0x562a5e=_0x322979[_0x21bc('0x21')];var _0x183e65=_0x3785e4?0x0:_0xa0d2ca['offset'];var _0x19181b=_0x3785e4?_0x322979[_0x21bc('0x21')]:_0xa0d2ca[_0x21bc('0x1e')]+_0xa0d2ca[_0x21bc('0x20')];var _0x4020c2;if(_0x19181b>=_0x562a5e){_0x19181b=_0x562a5e;_0x4020c2=0xc8;}else{_0x4020c2=0xce;}_0x3fe7f3[_0x21bc('0x1b')](_0x4020c2);return _0x3fe7f3[_0x21bc('0x22')]('Content-Range',_0x183e65+'-'+_0x19181b+'/'+_0x562a5e)[_0x21bc('0x1d')](_0x322979);}return null;};}function patchUpdates(_0x18149f){return function(_0x722551){try{jsonpatch[_0x21bc('0x23')](_0x722551,_0x18149f,!![]);}catch(_0x5df380){return BPromise[_0x21bc('0x24')](_0x5df380);}return _0x722551['save']();};}function saveUpdates(_0x2a6af5,_0x51d74c){return function(_0x529c33){if(_0x529c33){return _0x529c33[_0x21bc('0x25')](_0x2a6af5)['then'](function(_0x3f05dd){return _0x3f05dd;});}return null;};}function removeEntity(_0x4b7c1b,_0x406fe6){return function(_0x5ed2da){if(_0x5ed2da){return _0x5ed2da[_0x21bc('0x26')]()[_0x21bc('0x27')](function(){_0x4b7c1b[_0x21bc('0x1b')](0xcc)['end']();});}};}function handleEntityNotFound(_0x7b7f97,_0x424ab2){return function(_0x396708){if(!_0x396708){_0x7b7f97[_0x21bc('0x28')](0x194);}return _0x396708;};}function handleError(_0xce95cd,_0x13fe7b){_0x13fe7b=_0x13fe7b||0x1f4;return function(_0x1fc0eb){logger[_0x21bc('0x29')](_0x1fc0eb[_0x21bc('0x2a')]);if(_0x1fc0eb[_0x21bc('0x2b')]){delete _0x1fc0eb[_0x21bc('0x2b')];}_0xce95cd[_0x21bc('0x1b')](_0x13fe7b)['send'](_0x1fc0eb);};}exports[_0x21bc('0x2c')]=function(_0x455f1a,_0x1249b2){var _0x57f937={},_0x34e1c3={},_0x270090={'count':0x0,'rows':[]};var _0x2e2a51=_[_0x21bc('0x2d')](db[_0x21bc('0x2e')][_0x21bc('0x2f')],function(_0x3db661){return{'name':_0x3db661[_0x21bc('0x30')],'type':_0x3db661['type'][_0x21bc('0x31')]};});_0x34e1c3['model']=_[_0x21bc('0x2d')](_0x2e2a51,'name');_0x34e1c3[_0x21bc('0x32')]=_['keys'](_0x455f1a[_0x21bc('0x32')]);_0x34e1c3[_0x21bc('0x33')]=_['intersection'](_0x34e1c3[_0x21bc('0x34')],_0x34e1c3[_0x21bc('0x32')]);_0x57f937[_0x21bc('0x35')]=_['intersection'](_0x34e1c3[_0x21bc('0x34')],qs[_0x21bc('0x36')](_0x455f1a[_0x21bc('0x32')][_0x21bc('0x36')]));_0x57f937[_0x21bc('0x35')]=_0x57f937['attributes'][_0x21bc('0x37')]?_0x57f937[_0x21bc('0x35')]:_0x34e1c3[_0x21bc('0x34')];if(!_0x455f1a['query'][_0x21bc('0x38')](_0x21bc('0x39'))){_0x57f937[_0x21bc('0x20')]=qs['limit'](_0x455f1a[_0x21bc('0x32')][_0x21bc('0x20')]);_0x57f937[_0x21bc('0x1e')]=qs[_0x21bc('0x1e')](_0x455f1a[_0x21bc('0x32')][_0x21bc('0x1e')]);}_0x57f937[_0x21bc('0x3a')]=qs[_0x21bc('0x3b')](_0x455f1a[_0x21bc('0x32')][_0x21bc('0x3b')]);_0x57f937[_0x21bc('0x3c')]=qs[_0x21bc('0x33')](_[_0x21bc('0x3d')](_0x455f1a['query'],_0x34e1c3[_0x21bc('0x33')]),_0x2e2a51);if(_0x455f1a[_0x21bc('0x32')][_0x21bc('0x3e')]){_0x57f937[_0x21bc('0x3c')]=_[_0x21bc('0x3f')](_0x57f937[_0x21bc('0x3c')],{'$or':_[_0x21bc('0x2d')](_0x2e2a51,function(_0x2ec525){if(_0x2ec525['type']!==_0x21bc('0x40')){var _0x397955={};_0x397955[_0x2ec525[_0x21bc('0x2b')]]={'$like':'%'+_0x455f1a['query'][_0x21bc('0x3e')]+'%'};return _0x397955;}})});}_0x57f937=_[_0x21bc('0x3f')]({},_0x57f937,_0x455f1a['options']);var _0x3d3928={'where':_0x57f937[_0x21bc('0x3c')]};return db[_0x21bc('0x2e')][_0x21bc('0x21')](_0x3d3928)[_0x21bc('0x27')](function(_0x247f65){_0x270090[_0x21bc('0x21')]=_0x247f65;if(_0x455f1a[_0x21bc('0x32')][_0x21bc('0x41')]){_0x57f937[_0x21bc('0x42')]=[{'all':!![]}];}return db[_0x21bc('0x2e')][_0x21bc('0x43')](_0x57f937);})[_0x21bc('0x27')](function(_0x14adc9){_0x270090[_0x21bc('0x44')]=_0x14adc9;return _0x270090;})[_0x21bc('0x27')](respondWithFilteredResult(_0x1249b2,_0x57f937))[_0x21bc('0x45')](handleError(_0x1249b2,null));};exports[_0x21bc('0x46')]=function(_0x21e73a,_0x3d86a2){var _0x4b42cf={'raw':![],'where':{'id':_0x21e73a[_0x21bc('0x47')]['id']}},_0x45490e={};_0x45490e[_0x21bc('0x34')]=_[_0x21bc('0x48')](db[_0x21bc('0x2e')][_0x21bc('0x2f')]);_0x45490e[_0x21bc('0x32')]=_[_0x21bc('0x48')](_0x21e73a['query']);_0x45490e['filters']=_[_0x21bc('0x49')](_0x45490e[_0x21bc('0x34')],_0x45490e[_0x21bc('0x32')]);_0x4b42cf[_0x21bc('0x35')]=_[_0x21bc('0x49')](_0x45490e['model'],qs[_0x21bc('0x36')](_0x21e73a[_0x21bc('0x32')][_0x21bc('0x36')]));_0x4b42cf['attributes']=_0x4b42cf[_0x21bc('0x35')]['length']?_0x4b42cf[_0x21bc('0x35')]:_0x45490e['model'];if(_0x21e73a[_0x21bc('0x32')][_0x21bc('0x41')]){_0x4b42cf['include']=[{'all':!![]}];}_0x4b42cf=_['merge']({},_0x4b42cf,_0x21e73a[_0x21bc('0x4a')]);return db[_0x21bc('0x2e')]['find'](_0x4b42cf)[_0x21bc('0x27')](handleEntityNotFound(_0x3d86a2,null))[_0x21bc('0x27')](respondWithResult(_0x3d86a2,null))['catch'](handleError(_0x3d86a2,null));};exports[_0x21bc('0x4b')]=function(_0x252e0e,_0x528fcb){return db[_0x21bc('0x2e')][_0x21bc('0x4b')](_0x252e0e['body'],{})[_0x21bc('0x27')](respondWithResult(_0x528fcb,0xc9))[_0x21bc('0x45')](handleError(_0x528fcb,null));};exports[_0x21bc('0x25')]=function(_0x5d41b4,_0x565ed9){if(_0x5d41b4[_0x21bc('0x4c')]['id']){delete _0x5d41b4[_0x21bc('0x4c')]['id'];}return db['Automation'][_0x21bc('0x4d')]({'where':{'id':_0x5d41b4[_0x21bc('0x47')]['id']}})[_0x21bc('0x27')](handleEntityNotFound(_0x565ed9,null))['then'](saveUpdates(_0x5d41b4[_0x21bc('0x4c')],null))[_0x21bc('0x27')](respondWithResult(_0x565ed9,null))['catch'](handleError(_0x565ed9,null));};exports[_0x21bc('0x26')]=function(_0x18abdd,_0x319595){return db['Automation'][_0x21bc('0x4d')]({'where':{'id':_0x18abdd[_0x21bc('0x47')]['id']}})['then'](handleEntityNotFound(_0x319595,null))['then'](removeEntity(_0x319595,null))[_0x21bc('0x45')](handleError(_0x319595,null));};exports[_0x21bc('0x4e')]=function(_0x37bcd4,_0x499879,_0x528402){return db['Condition']['find']({'where':{'id':_0x37bcd4[_0x21bc('0x47')]['id']}})[_0x21bc('0x27')](handleEntityNotFound(_0x499879,null))[_0x21bc('0x27')](function(_0xf6afea){if(_0xf6afea){return _0xf6afea[_0x21bc('0x4e')](_0x37bcd4['body'][_0x21bc('0x4f')],_['omit'](_0x37bcd4[_0x21bc('0x4c')],['ids','id'])||{});}})[_0x21bc('0x27')](respondWithResult(_0x499879,null))['catch'](handleError(_0x499879,null));};exports[_0x21bc('0x50')]=function(_0xd949ef,_0x3f27e1,_0x23494e){var _0x3577c2={};var _0x59c639={};var _0x2267d8;var _0x33054d;return db['Automation'][_0x21bc('0x51')]({'where':{'id':_0xd949ef[_0x21bc('0x47')]['id']}})[_0x21bc('0x27')](handleEntityNotFound(_0x3f27e1,null))[_0x21bc('0x27')](function(_0x3da7a8){if(_0x3da7a8){_0x2267d8=_0x3da7a8;_0x59c639[_0x21bc('0x34')]=_[_0x21bc('0x48')](db[_0x21bc('0x52')][_0x21bc('0x2f')]);_0x59c639[_0x21bc('0x32')]=_[_0x21bc('0x48')](_0xd949ef[_0x21bc('0x32')]);_0x59c639[_0x21bc('0x33')]=_['intersection'](_0x59c639[_0x21bc('0x34')],_0x59c639[_0x21bc('0x32')]);_0x3577c2[_0x21bc('0x35')]=_[_0x21bc('0x49')](_0x59c639[_0x21bc('0x34')],qs[_0x21bc('0x36')](_0xd949ef[_0x21bc('0x32')][_0x21bc('0x36')]));_0x3577c2[_0x21bc('0x35')]=_0x3577c2[_0x21bc('0x35')][_0x21bc('0x37')]?_0x3577c2[_0x21bc('0x35')]:_0x59c639[_0x21bc('0x34')];_0x3577c2[_0x21bc('0x3a')]=qs[_0x21bc('0x3b')](_0xd949ef[_0x21bc('0x32')][_0x21bc('0x3b')]);_0x3577c2[_0x21bc('0x3c')]=qs['filters'](_[_0x21bc('0x3d')](_0xd949ef[_0x21bc('0x32')],_0x59c639[_0x21bc('0x33')]));if(_0xd949ef[_0x21bc('0x32')][_0x21bc('0x3e')]){_0x3577c2[_0x21bc('0x3c')]=_[_0x21bc('0x3f')](_0x3577c2['where'],{'$or':_[_0x21bc('0x2d')](_0x3577c2[_0x21bc('0x35')],function(_0x464939){var _0x49a6ee={};_0x49a6ee[_0x464939]={'$like':'%'+_0xd949ef[_0x21bc('0x32')][_0x21bc('0x3e')]+'%'};return _0x49a6ee;})});}_0x3577c2=_[_0x21bc('0x3f')]({},_0x3577c2,_0xd949ef[_0x21bc('0x4a')]);return _0x2267d8[_0x21bc('0x50')](_0x3577c2);}})[_0x21bc('0x27')](function(_0x51f48a){if(_0x51f48a){_0x33054d=_0x51f48a[_0x21bc('0x37')];if(!_0xd949ef[_0x21bc('0x32')][_0x21bc('0x38')](_0x21bc('0x39'))){_0x3577c2[_0x21bc('0x20')]=qs[_0x21bc('0x20')](_0xd949ef[_0x21bc('0x32')][_0x21bc('0x20')]);_0x3577c2[_0x21bc('0x1e')]=qs[_0x21bc('0x1e')](_0xd949ef[_0x21bc('0x32')]['offset']);}return _0x2267d8[_0x21bc('0x50')](_0x3577c2);}})[_0x21bc('0x27')](function(_0x5139f4){if(_0x5139f4){return _0x5139f4?{'count':_0x33054d,'rows':_0x5139f4}:null;}})[_0x21bc('0x27')](respondWithResult(_0x3f27e1,null))[_0x21bc('0x45')](handleError(_0x3f27e1,null));};exports[_0x21bc('0x53')]=function(_0x1bbaff,_0x1a0435,_0x52bb08){return db[_0x21bc('0x54')][_0x21bc('0x4d')]({'where':{'id':_0x1bbaff[_0x21bc('0x47')]['id']}})['then'](handleEntityNotFound(_0x1a0435,null))[_0x21bc('0x27')](function(_0x5d5cd1){if(_0x5d5cd1){return _0x5d5cd1[_0x21bc('0x53')](_0x1bbaff[_0x21bc('0x4c')]['ids'],_[_0x21bc('0x55')](_0x1bbaff[_0x21bc('0x4c')],[_0x21bc('0x4f'),'id'])||{});}})[_0x21bc('0x27')](respondWithResult(_0x1a0435,null))[_0x21bc('0x45')](handleError(_0x1a0435,null));};exports[_0x21bc('0x56')]=function(_0x5231f4,_0x3a0538,_0x57a601){var _0x194c11={};var _0x46dcfc={};var _0x48119b;var _0xc44cbc;return db[_0x21bc('0x2e')]['findOne']({'where':{'id':_0x5231f4[_0x21bc('0x47')]['id']}})[_0x21bc('0x27')](handleEntityNotFound(_0x3a0538,null))['then'](function(_0x17461b){if(_0x17461b){_0x48119b=_0x17461b;_0x46dcfc['model']=_['keys'](db['Action'][_0x21bc('0x2f')]);_0x46dcfc[_0x21bc('0x32')]=_[_0x21bc('0x48')](_0x5231f4[_0x21bc('0x32')]);_0x46dcfc[_0x21bc('0x33')]=_[_0x21bc('0x49')](_0x46dcfc[_0x21bc('0x34')],_0x46dcfc[_0x21bc('0x32')]);_0x194c11[_0x21bc('0x35')]=_[_0x21bc('0x49')](_0x46dcfc[_0x21bc('0x34')],qs[_0x21bc('0x36')](_0x5231f4['query'][_0x21bc('0x36')]));_0x194c11[_0x21bc('0x35')]=_0x194c11[_0x21bc('0x35')][_0x21bc('0x37')]?_0x194c11[_0x21bc('0x35')]:_0x46dcfc[_0x21bc('0x34')];_0x194c11['order']=qs['sort'](_0x5231f4[_0x21bc('0x32')][_0x21bc('0x3b')]);_0x194c11[_0x21bc('0x3c')]=qs[_0x21bc('0x33')](_['pick'](_0x5231f4[_0x21bc('0x32')],_0x46dcfc[_0x21bc('0x33')]));if(_0x5231f4['query']['filter']){_0x194c11['where']=_['merge'](_0x194c11[_0x21bc('0x3c')],{'$or':_['map'](_0x194c11[_0x21bc('0x35')],function(_0x553c61){var _0x4ee199={};_0x4ee199[_0x553c61]={'$like':'%'+_0x5231f4[_0x21bc('0x32')][_0x21bc('0x3e')]+'%'};return _0x4ee199;})});}_0x194c11=_[_0x21bc('0x3f')]({},_0x194c11,_0x5231f4[_0x21bc('0x4a')]);return _0x48119b['getActions'](_0x194c11);}})['then'](function(_0xa18827){if(_0xa18827){_0xc44cbc=_0xa18827[_0x21bc('0x37')];if(!_0x5231f4['query']['hasOwnProperty'](_0x21bc('0x39'))){_0x194c11[_0x21bc('0x20')]=qs[_0x21bc('0x20')](_0x5231f4[_0x21bc('0x32')][_0x21bc('0x20')]);_0x194c11[_0x21bc('0x1e')]=qs[_0x21bc('0x1e')](_0x5231f4[_0x21bc('0x32')]['offset']);}return _0x48119b[_0x21bc('0x56')](_0x194c11);}})[_0x21bc('0x27')](function(_0x34b026){if(_0x34b026){return _0x34b026?{'count':_0xc44cbc,'rows':_0x34b026}:null;}})['then'](respondWithResult(_0x3a0538,null))[_0x21bc('0x45')](handleError(_0x3a0538,null));};
\ No newline at end of file
+var _0x3395=['hasOwnProperty','nolimit','sort','where','filters','pick','filter','merge','VIRTUAL','includeAll','Automation','findAll','rows','catch','keys','rawAttributes','options','find','create','body','update','params','Condition','addConditions','ids','omit','getConditions','findOne','order','addActions','Action','getActions','zip-dir','request-promise','moment','bluebird','mustache','util','path','sox','to-csv','ejs','fs-extra','squel','crypto','desk.js','querystring','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','api','../../config/environment','../../config/license/util','../../mysqldb','sendStatus','status','end','json','offset','limit','undefined','count','Content-Range','apply','reject','save','then','destroy','error','name','send','index','map','fieldName','type','key','model','query','intersection','fields','attributes','length'];(function(_0x4c89d9,_0x65a4c){var _0x2af1ef=function(_0x5f4ed0){while(--_0x5f4ed0){_0x4c89d9['push'](_0x4c89d9['shift']());}};_0x2af1ef(++_0x65a4c);}(_0x3395,0x1c4));var _0x5339=function(_0x1197c1,_0x149118){_0x1197c1=_0x1197c1-0x0;var _0xdfaa1f=_0x3395[_0x1197c1];return _0xdfaa1f;};'use strict';var emlformat=require('eml-format');var rimraf=require('rimraf');var zipdir=require(_0x5339('0x0'));var jsonpatch=require('fast-json-patch');var rp=require(_0x5339('0x1'));var moment=require(_0x5339('0x2'));var BPromise=require(_0x5339('0x3'));var Mustache=require(_0x5339('0x4'));var util=require(_0x5339('0x5'));var path=require(_0x5339('0x6'));var sox=require(_0x5339('0x7'));var csv=require(_0x5339('0x8'));var ejs=require(_0x5339('0x9'));var fs=require('fs');var fs_extra=require(_0x5339('0xa'));var _=require('lodash');var squel=require(_0x5339('0xb'));var crypto=require(_0x5339('0xc'));var jsforce=require('jsforce');var deskjs=require(_0x5339('0xd'));var toCsv=require(_0x5339('0x8'));var querystring=require(_0x5339('0xe'));var Papa=require('papaparse');var Redis=require(_0x5339('0xf'));var authService=require(_0x5339('0x10'));var qs=require(_0x5339('0x11'));var as=require(_0x5339('0x12'));var hardwareService=require(_0x5339('0x13'));var logger=require('../../config/logger')(_0x5339('0x14'));var utils=require('../../config/utils');var config=require(_0x5339('0x15'));var licenseUtil=require(_0x5339('0x16'));var db=require(_0x5339('0x17'))['db'];function respondWithStatusCode(_0x4d91a2,_0xddc381){_0xddc381=_0xddc381||0xcc;return function(_0x30a572){if(_0x30a572){return _0x4d91a2[_0x5339('0x18')](_0xddc381);}return _0x4d91a2[_0x5339('0x19')](_0xddc381)[_0x5339('0x1a')]();};}function respondWithResult(_0x4558fd,_0x43610d){_0x43610d=_0x43610d||0xc8;return function(_0xa46c6b){if(_0xa46c6b){return _0x4558fd[_0x5339('0x19')](_0x43610d)[_0x5339('0x1b')](_0xa46c6b);}};}function respondWithFilteredResult(_0x5cd414,_0xf89312){return function(_0x3b4765){if(_0x3b4765){var _0x1e66e8=typeof _0xf89312[_0x5339('0x1c')]==='undefined'&&typeof _0xf89312[_0x5339('0x1d')]===_0x5339('0x1e');var _0x513723=_0x3b4765['count'];var _0x3c99dc=_0x1e66e8?0x0:_0xf89312[_0x5339('0x1c')];var _0x16ec6e=_0x1e66e8?_0x3b4765[_0x5339('0x1f')]:_0xf89312[_0x5339('0x1c')]+_0xf89312[_0x5339('0x1d')];var _0x3ccd01;if(_0x16ec6e>=_0x513723){_0x16ec6e=_0x513723;_0x3ccd01=0xc8;}else{_0x3ccd01=0xce;}_0x5cd414['status'](_0x3ccd01);return _0x5cd414['set'](_0x5339('0x20'),_0x3c99dc+'-'+_0x16ec6e+'/'+_0x513723)[_0x5339('0x1b')](_0x3b4765);}return null;};}function patchUpdates(_0x1edcbb){return function(_0x99c1dc){try{jsonpatch[_0x5339('0x21')](_0x99c1dc,_0x1edcbb,!![]);}catch(_0x4a3c34){return BPromise[_0x5339('0x22')](_0x4a3c34);}return _0x99c1dc[_0x5339('0x23')]();};}function saveUpdates(_0x2aa157,_0x118ad3){return function(_0x29d02d){if(_0x29d02d){return _0x29d02d['update'](_0x2aa157)[_0x5339('0x24')](function(_0x18c189){return _0x18c189;});}return null;};}function removeEntity(_0x14d1a6,_0x4f2868){return function(_0x176a6e){if(_0x176a6e){return _0x176a6e[_0x5339('0x25')]()[_0x5339('0x24')](function(){_0x14d1a6[_0x5339('0x19')](0xcc)[_0x5339('0x1a')]();});}};}function handleEntityNotFound(_0x423e,_0x56d3d5){return function(_0x21792c){if(!_0x21792c){_0x423e['sendStatus'](0x194);}return _0x21792c;};}function handleError(_0xa0b0e8,_0x12a8d7){_0x12a8d7=_0x12a8d7||0x1f4;return function(_0x44cce8){logger[_0x5339('0x26')](_0x44cce8['stack']);if(_0x44cce8[_0x5339('0x27')]){delete _0x44cce8[_0x5339('0x27')];}_0xa0b0e8[_0x5339('0x19')](_0x12a8d7)[_0x5339('0x28')](_0x44cce8);};}exports[_0x5339('0x29')]=function(_0x184f5c,_0x5ec9c4){var _0x3bd795={},_0x6921b6={},_0x39e74b={'count':0x0,'rows':[]};var _0x1abee6=_[_0x5339('0x2a')](db['Automation']['rawAttributes'],function(_0x459b3c){return{'name':_0x459b3c[_0x5339('0x2b')],'type':_0x459b3c[_0x5339('0x2c')][_0x5339('0x2d')]};});_0x6921b6[_0x5339('0x2e')]=_[_0x5339('0x2a')](_0x1abee6,'name');_0x6921b6['query']=_['keys'](_0x184f5c[_0x5339('0x2f')]);_0x6921b6['filters']=_[_0x5339('0x30')](_0x6921b6[_0x5339('0x2e')],_0x6921b6[_0x5339('0x2f')]);_0x3bd795['attributes']=_[_0x5339('0x30')](_0x6921b6['model'],qs[_0x5339('0x31')](_0x184f5c[_0x5339('0x2f')][_0x5339('0x31')]));_0x3bd795[_0x5339('0x32')]=_0x3bd795[_0x5339('0x32')][_0x5339('0x33')]?_0x3bd795[_0x5339('0x32')]:_0x6921b6['model'];if(!_0x184f5c['query'][_0x5339('0x34')](_0x5339('0x35'))){_0x3bd795['limit']=qs[_0x5339('0x1d')](_0x184f5c[_0x5339('0x2f')]['limit']);_0x3bd795[_0x5339('0x1c')]=qs['offset'](_0x184f5c['query'][_0x5339('0x1c')]);}_0x3bd795['order']=qs[_0x5339('0x36')](_0x184f5c['query'][_0x5339('0x36')]);_0x3bd795[_0x5339('0x37')]=qs[_0x5339('0x38')](_[_0x5339('0x39')](_0x184f5c[_0x5339('0x2f')],_0x6921b6[_0x5339('0x38')]),_0x1abee6);if(_0x184f5c['query'][_0x5339('0x3a')]){_0x3bd795[_0x5339('0x37')]=_[_0x5339('0x3b')](_0x3bd795[_0x5339('0x37')],{'$or':_[_0x5339('0x2a')](_0x1abee6,function(_0x4ede15){if(_0x4ede15[_0x5339('0x2c')]!==_0x5339('0x3c')){var _0x2bc535={};_0x2bc535[_0x4ede15[_0x5339('0x27')]]={'$like':'%'+_0x184f5c[_0x5339('0x2f')][_0x5339('0x3a')]+'%'};return _0x2bc535;}})});}_0x3bd795=_[_0x5339('0x3b')]({},_0x3bd795,_0x184f5c['options']);var _0xa2a4={'where':_0x3bd795[_0x5339('0x37')]};return db['Automation']['count'](_0xa2a4)['then'](function(_0x367427){_0x39e74b[_0x5339('0x1f')]=_0x367427;if(_0x184f5c[_0x5339('0x2f')][_0x5339('0x3d')]){_0x3bd795['include']=[{'all':!![]}];}return db[_0x5339('0x3e')][_0x5339('0x3f')](_0x3bd795);})[_0x5339('0x24')](function(_0x242fea){_0x39e74b[_0x5339('0x40')]=_0x242fea;return _0x39e74b;})[_0x5339('0x24')](respondWithFilteredResult(_0x5ec9c4,_0x3bd795))[_0x5339('0x41')](handleError(_0x5ec9c4,null));};exports['show']=function(_0x4e7c23,_0x53de8c){var _0x56d674={'raw':![],'where':{'id':_0x4e7c23['params']['id']}},_0x2e3ed8={};_0x2e3ed8[_0x5339('0x2e')]=_[_0x5339('0x42')](db[_0x5339('0x3e')][_0x5339('0x43')]);_0x2e3ed8[_0x5339('0x2f')]=_[_0x5339('0x42')](_0x4e7c23[_0x5339('0x2f')]);_0x2e3ed8[_0x5339('0x38')]=_[_0x5339('0x30')](_0x2e3ed8[_0x5339('0x2e')],_0x2e3ed8[_0x5339('0x2f')]);_0x56d674[_0x5339('0x32')]=_[_0x5339('0x30')](_0x2e3ed8[_0x5339('0x2e')],qs['fields'](_0x4e7c23['query']['fields']));_0x56d674[_0x5339('0x32')]=_0x56d674[_0x5339('0x32')][_0x5339('0x33')]?_0x56d674[_0x5339('0x32')]:_0x2e3ed8[_0x5339('0x2e')];if(_0x4e7c23['query'][_0x5339('0x3d')]){_0x56d674['include']=[{'all':!![]}];}_0x56d674=_[_0x5339('0x3b')]({},_0x56d674,_0x4e7c23[_0x5339('0x44')]);return db[_0x5339('0x3e')][_0x5339('0x45')](_0x56d674)['then'](handleEntityNotFound(_0x53de8c,null))[_0x5339('0x24')](respondWithResult(_0x53de8c,null))['catch'](handleError(_0x53de8c,null));};exports[_0x5339('0x46')]=function(_0x35fbf1,_0x1a1e8f){return db[_0x5339('0x3e')][_0x5339('0x46')](_0x35fbf1[_0x5339('0x47')],{})[_0x5339('0x24')](respondWithResult(_0x1a1e8f,0xc9))['catch'](handleError(_0x1a1e8f,null));};exports[_0x5339('0x48')]=function(_0x506b3c,_0x14f3d7){if(_0x506b3c[_0x5339('0x47')]['id']){delete _0x506b3c[_0x5339('0x47')]['id'];}return db[_0x5339('0x3e')]['find']({'where':{'id':_0x506b3c[_0x5339('0x49')]['id']}})[_0x5339('0x24')](handleEntityNotFound(_0x14f3d7,null))[_0x5339('0x24')](saveUpdates(_0x506b3c['body'],null))[_0x5339('0x24')](respondWithResult(_0x14f3d7,null))['catch'](handleError(_0x14f3d7,null));};exports[_0x5339('0x25')]=function(_0x47081a,_0x331f40){return db['Automation'][_0x5339('0x45')]({'where':{'id':_0x47081a['params']['id']}})[_0x5339('0x24')](handleEntityNotFound(_0x331f40,null))[_0x5339('0x24')](removeEntity(_0x331f40,null))['catch'](handleError(_0x331f40,null));};exports['addConditions']=function(_0x3bbab7,_0x468ad6,_0x46d947){return db[_0x5339('0x4a')][_0x5339('0x45')]({'where':{'id':_0x3bbab7[_0x5339('0x49')]['id']}})[_0x5339('0x24')](handleEntityNotFound(_0x468ad6,null))[_0x5339('0x24')](function(_0x1bb9af){if(_0x1bb9af){return _0x1bb9af[_0x5339('0x4b')](_0x3bbab7[_0x5339('0x47')][_0x5339('0x4c')],_[_0x5339('0x4d')](_0x3bbab7[_0x5339('0x47')],[_0x5339('0x4c'),'id'])||{});}})[_0x5339('0x24')](respondWithResult(_0x468ad6,null))[_0x5339('0x41')](handleError(_0x468ad6,null));};exports[_0x5339('0x4e')]=function(_0x4637e4,_0x2f459d,_0x50e459){var _0x3c277c={};var _0x24e2ae={};var _0x3ea940;var _0x2ed4b8;return db[_0x5339('0x3e')][_0x5339('0x4f')]({'where':{'id':_0x4637e4[_0x5339('0x49')]['id']}})[_0x5339('0x24')](handleEntityNotFound(_0x2f459d,null))[_0x5339('0x24')](function(_0x32fdb1){if(_0x32fdb1){_0x3ea940=_0x32fdb1;_0x24e2ae[_0x5339('0x2e')]=_[_0x5339('0x42')](db[_0x5339('0x4a')][_0x5339('0x43')]);_0x24e2ae['query']=_['keys'](_0x4637e4[_0x5339('0x2f')]);_0x24e2ae['filters']=_['intersection'](_0x24e2ae[_0x5339('0x2e')],_0x24e2ae[_0x5339('0x2f')]);_0x3c277c['attributes']=_['intersection'](_0x24e2ae[_0x5339('0x2e')],qs[_0x5339('0x31')](_0x4637e4[_0x5339('0x2f')][_0x5339('0x31')]));_0x3c277c['attributes']=_0x3c277c['attributes'][_0x5339('0x33')]?_0x3c277c[_0x5339('0x32')]:_0x24e2ae[_0x5339('0x2e')];_0x3c277c[_0x5339('0x50')]=qs[_0x5339('0x36')](_0x4637e4[_0x5339('0x2f')][_0x5339('0x36')]);_0x3c277c[_0x5339('0x37')]=qs[_0x5339('0x38')](_[_0x5339('0x39')](_0x4637e4[_0x5339('0x2f')],_0x24e2ae[_0x5339('0x38')]));if(_0x4637e4[_0x5339('0x2f')][_0x5339('0x3a')]){_0x3c277c['where']=_[_0x5339('0x3b')](_0x3c277c[_0x5339('0x37')],{'$or':_[_0x5339('0x2a')](_0x3c277c[_0x5339('0x32')],function(_0xab75f3){var _0x2cf085={};_0x2cf085[_0xab75f3]={'$like':'%'+_0x4637e4[_0x5339('0x2f')]['filter']+'%'};return _0x2cf085;})});}_0x3c277c=_[_0x5339('0x3b')]({},_0x3c277c,_0x4637e4['options']);return _0x3ea940[_0x5339('0x4e')](_0x3c277c);}})[_0x5339('0x24')](function(_0x585ff1){if(_0x585ff1){_0x2ed4b8=_0x585ff1[_0x5339('0x33')];if(!_0x4637e4[_0x5339('0x2f')][_0x5339('0x34')]('nolimit')){_0x3c277c[_0x5339('0x1d')]=qs[_0x5339('0x1d')](_0x4637e4[_0x5339('0x2f')][_0x5339('0x1d')]);_0x3c277c['offset']=qs[_0x5339('0x1c')](_0x4637e4['query'][_0x5339('0x1c')]);}return _0x3ea940['getConditions'](_0x3c277c);}})[_0x5339('0x24')](function(_0x423878){if(_0x423878){return _0x423878?{'count':_0x2ed4b8,'rows':_0x423878}:null;}})[_0x5339('0x24')](respondWithResult(_0x2f459d,null))[_0x5339('0x41')](handleError(_0x2f459d,null));};exports[_0x5339('0x51')]=function(_0x5460ea,_0x5a2f9e,_0x4b814f){return db[_0x5339('0x52')][_0x5339('0x45')]({'where':{'id':_0x5460ea[_0x5339('0x49')]['id']}})[_0x5339('0x24')](handleEntityNotFound(_0x5a2f9e,null))['then'](function(_0x161a00){if(_0x161a00){return _0x161a00[_0x5339('0x51')](_0x5460ea['body'][_0x5339('0x4c')],_[_0x5339('0x4d')](_0x5460ea[_0x5339('0x47')],['ids','id'])||{});}})[_0x5339('0x24')](respondWithResult(_0x5a2f9e,null))[_0x5339('0x41')](handleError(_0x5a2f9e,null));};exports[_0x5339('0x53')]=function(_0xbdca9b,_0x428e72,_0x1c636a){var _0x355816={};var _0x46d536={};var _0x56006e;var _0x376eea;return db[_0x5339('0x3e')][_0x5339('0x4f')]({'where':{'id':_0xbdca9b[_0x5339('0x49')]['id']}})[_0x5339('0x24')](handleEntityNotFound(_0x428e72,null))['then'](function(_0xab36ae){if(_0xab36ae){_0x56006e=_0xab36ae;_0x46d536[_0x5339('0x2e')]=_[_0x5339('0x42')](db[_0x5339('0x52')]['rawAttributes']);_0x46d536[_0x5339('0x2f')]=_['keys'](_0xbdca9b[_0x5339('0x2f')]);_0x46d536[_0x5339('0x38')]=_['intersection'](_0x46d536[_0x5339('0x2e')],_0x46d536['query']);_0x355816[_0x5339('0x32')]=_[_0x5339('0x30')](_0x46d536[_0x5339('0x2e')],qs[_0x5339('0x31')](_0xbdca9b[_0x5339('0x2f')][_0x5339('0x31')]));_0x355816[_0x5339('0x32')]=_0x355816['attributes'][_0x5339('0x33')]?_0x355816[_0x5339('0x32')]:_0x46d536[_0x5339('0x2e')];_0x355816[_0x5339('0x50')]=qs[_0x5339('0x36')](_0xbdca9b[_0x5339('0x2f')]['sort']);_0x355816[_0x5339('0x37')]=qs['filters'](_[_0x5339('0x39')](_0xbdca9b[_0x5339('0x2f')],_0x46d536[_0x5339('0x38')]));if(_0xbdca9b[_0x5339('0x2f')][_0x5339('0x3a')]){_0x355816[_0x5339('0x37')]=_[_0x5339('0x3b')](_0x355816[_0x5339('0x37')],{'$or':_['map'](_0x355816[_0x5339('0x32')],function(_0x1c03fd){var _0x5dd9f8={};_0x5dd9f8[_0x1c03fd]={'$like':'%'+_0xbdca9b[_0x5339('0x2f')]['filter']+'%'};return _0x5dd9f8;})});}_0x355816=_['merge']({},_0x355816,_0xbdca9b[_0x5339('0x44')]);return _0x56006e[_0x5339('0x53')](_0x355816);}})[_0x5339('0x24')](function(_0x2665ac){if(_0x2665ac){_0x376eea=_0x2665ac['length'];if(!_0xbdca9b[_0x5339('0x2f')][_0x5339('0x34')](_0x5339('0x35'))){_0x355816['limit']=qs[_0x5339('0x1d')](_0xbdca9b[_0x5339('0x2f')]['limit']);_0x355816[_0x5339('0x1c')]=qs[_0x5339('0x1c')](_0xbdca9b[_0x5339('0x2f')]['offset']);}return _0x56006e[_0x5339('0x53')](_0x355816);}})[_0x5339('0x24')](function(_0x28b505){if(_0x28b505){return _0x28b505?{'count':_0x376eea,'rows':_0x28b505}:null;}})[_0x5339('0x24')](respondWithResult(_0x428e72,null))['catch'](handleError(_0x428e72,null));};
\ No newline at end of file