Built motion from commit 1fa89557.|2.6.10
[motion2.git] / server / api / automation / automation.controller.js
index 8e22697..4c06fd0 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xf694=['offset','undefined','count','limit','Content-Range','apply','reject','update','then','error','name','send','index','map','fieldName','type','key','model','keys','query','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','order','sort','where','pick','filter','merge','VIRTUAL','options','Automation','includeAll','rows','catch','show','params','rawAttributes','include','find','create','body','addConditions','ids','omit','getConditions','Condition','addActions','getActions','findOne','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','util','sox','ejs','fs-extra','lodash','squel','crypto','jsforce','desk.js','to-csv','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','sendStatus','status','end','json'];(function(_0x5c3ccd,_0x4b45af){var _0x1733dd=function(_0x107fc2){while(--_0x107fc2){_0x5c3ccd['push'](_0x5c3ccd['shift']());}};_0x1733dd(++_0x4b45af);}(_0xf694,0x8c));var _0x4f69=function(_0x2b7329,_0x218d8e){_0x2b7329=_0x2b7329-0x0;var _0x4b779b=_0xf694[_0x2b7329];return _0x4b779b;};'use strict';var emlformat=require(_0x4f69('0x0'));var rimraf=require(_0x4f69('0x1'));var zipdir=require(_0x4f69('0x2'));var jsonpatch=require(_0x4f69('0x3'));var rp=require(_0x4f69('0x4'));var moment=require(_0x4f69('0x5'));var BPromise=require('bluebird');var Mustache=require('mustache');var util=require(_0x4f69('0x6'));var path=require('path');var sox=require(_0x4f69('0x7'));var csv=require('to-csv');var ejs=require(_0x4f69('0x8'));var fs=require('fs');var fs_extra=require(_0x4f69('0x9'));var _=require(_0x4f69('0xa'));var squel=require(_0x4f69('0xb'));var crypto=require(_0x4f69('0xc'));var jsforce=require(_0x4f69('0xd'));var deskjs=require(_0x4f69('0xe'));var toCsv=require(_0x4f69('0xf'));var querystring=require(_0x4f69('0x10'));var Papa=require(_0x4f69('0x11'));var Redis=require(_0x4f69('0x12'));var authService=require(_0x4f69('0x13'));var qs=require(_0x4f69('0x14'));var as=require(_0x4f69('0x15'));var hardwareService=require(_0x4f69('0x16'));var logger=require(_0x4f69('0x17'))(_0x4f69('0x18'));var utils=require(_0x4f69('0x19'));var config=require(_0x4f69('0x1a'));var licenseUtil=require(_0x4f69('0x1b'));var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x430017,_0x56fe7a){_0x56fe7a=_0x56fe7a||0xcc;return function(_0x33c262){if(_0x33c262){return _0x430017[_0x4f69('0x1c')](_0x56fe7a);}return _0x430017[_0x4f69('0x1d')](_0x56fe7a)[_0x4f69('0x1e')]();};}function respondWithResult(_0x10e247,_0x3fdbf9){_0x3fdbf9=_0x3fdbf9||0xc8;return function(_0x5b2b24){if(_0x5b2b24){return _0x10e247[_0x4f69('0x1d')](_0x3fdbf9)[_0x4f69('0x1f')](_0x5b2b24);}};}function respondWithFilteredResult(_0x2f87f2,_0x46f0ec){return function(_0x17047b){if(_0x17047b){var _0x936002=typeof _0x46f0ec[_0x4f69('0x20')]===_0x4f69('0x21')&&typeof _0x46f0ec['limit']===_0x4f69('0x21');var _0x4b6ebd=_0x17047b[_0x4f69('0x22')];var _0x25604d=_0x936002?0x0:_0x46f0ec[_0x4f69('0x20')];var _0x567bb2=_0x936002?_0x17047b[_0x4f69('0x22')]:_0x46f0ec[_0x4f69('0x20')]+_0x46f0ec[_0x4f69('0x23')];var _0x5eba52;if(_0x567bb2>=_0x4b6ebd){_0x567bb2=_0x4b6ebd;_0x5eba52=0xc8;}else{_0x5eba52=0xce;}_0x2f87f2[_0x4f69('0x1d')](_0x5eba52);return _0x2f87f2['set'](_0x4f69('0x24'),_0x25604d+'-'+_0x567bb2+'/'+_0x4b6ebd)[_0x4f69('0x1f')](_0x17047b);}return null;};}function patchUpdates(_0x148d2f){return function(_0x340cba){try{jsonpatch[_0x4f69('0x25')](_0x340cba,_0x148d2f,!![]);}catch(_0x753c7e){return BPromise[_0x4f69('0x26')](_0x753c7e);}return _0x340cba['save']();};}function saveUpdates(_0x5dcd96,_0x169bc4){return function(_0x5d4bd8){if(_0x5d4bd8){return _0x5d4bd8[_0x4f69('0x27')](_0x5dcd96)[_0x4f69('0x28')](function(_0x77acda){return _0x77acda;});}return null;};}function removeEntity(_0x56c094,_0x2f5e90){return function(_0x47d463){if(_0x47d463){return _0x47d463['destroy']()[_0x4f69('0x28')](function(){_0x56c094[_0x4f69('0x1d')](0xcc)[_0x4f69('0x1e')]();});}};}function handleEntityNotFound(_0x586348,_0xc3a6a2){return function(_0x5b3b7b){if(!_0x5b3b7b){_0x586348[_0x4f69('0x1c')](0x194);}return _0x5b3b7b;};}function handleError(_0x16b9ed,_0x2e7e70){_0x2e7e70=_0x2e7e70||0x1f4;return function(_0x311740){logger[_0x4f69('0x29')](_0x311740['stack']);if(_0x311740[_0x4f69('0x2a')]){delete _0x311740[_0x4f69('0x2a')];}_0x16b9ed[_0x4f69('0x1d')](_0x2e7e70)[_0x4f69('0x2b')](_0x311740);};}exports[_0x4f69('0x2c')]=function(_0x1503a4,_0x2d1136){var _0x55d933={},_0x477e26={},_0x457995={'count':0x0,'rows':[]};var _0x2455bf=_[_0x4f69('0x2d')](db['Automation']['rawAttributes'],function(_0x56e4e0){return{'name':_0x56e4e0[_0x4f69('0x2e')],'type':_0x56e4e0[_0x4f69('0x2f')][_0x4f69('0x30')]};});_0x477e26[_0x4f69('0x31')]=_['map'](_0x2455bf,_0x4f69('0x2a'));_0x477e26['query']=_[_0x4f69('0x32')](_0x1503a4[_0x4f69('0x33')]);_0x477e26[_0x4f69('0x34')]=_[_0x4f69('0x35')](_0x477e26[_0x4f69('0x31')],_0x477e26['query']);_0x55d933[_0x4f69('0x36')]=_[_0x4f69('0x35')](_0x477e26[_0x4f69('0x31')],qs[_0x4f69('0x37')](_0x1503a4[_0x4f69('0x33')][_0x4f69('0x37')]));_0x55d933['attributes']=_0x55d933[_0x4f69('0x36')][_0x4f69('0x38')]?_0x55d933['attributes']:_0x477e26['model'];if(!_0x1503a4['query'][_0x4f69('0x39')](_0x4f69('0x3a'))){_0x55d933[_0x4f69('0x23')]=qs['limit'](_0x1503a4['query'][_0x4f69('0x23')]);_0x55d933['offset']=qs[_0x4f69('0x20')](_0x1503a4[_0x4f69('0x33')][_0x4f69('0x20')]);}_0x55d933[_0x4f69('0x3b')]=qs[_0x4f69('0x3c')](_0x1503a4[_0x4f69('0x33')][_0x4f69('0x3c')]);_0x55d933[_0x4f69('0x3d')]=qs[_0x4f69('0x34')](_[_0x4f69('0x3e')](_0x1503a4['query'],_0x477e26[_0x4f69('0x34')]),_0x2455bf);if(_0x1503a4[_0x4f69('0x33')][_0x4f69('0x3f')]){_0x55d933[_0x4f69('0x3d')]=_[_0x4f69('0x40')](_0x55d933[_0x4f69('0x3d')],{'$or':_[_0x4f69('0x2d')](_0x2455bf,function(_0x3b5a9a){if(_0x3b5a9a[_0x4f69('0x2f')]!==_0x4f69('0x41')){var _0x418114={};_0x418114[_0x3b5a9a['name']]={'$like':'%'+_0x1503a4[_0x4f69('0x33')]['filter']+'%'};return _0x418114;}})});}_0x55d933=_[_0x4f69('0x40')]({},_0x55d933,_0x1503a4[_0x4f69('0x42')]);var _0xf41d5b={'where':_0x55d933[_0x4f69('0x3d')]};return db[_0x4f69('0x43')][_0x4f69('0x22')](_0xf41d5b)[_0x4f69('0x28')](function(_0x100786){_0x457995['count']=_0x100786;if(_0x1503a4[_0x4f69('0x33')][_0x4f69('0x44')]){_0x55d933['include']=[{'all':!![]}];}return db['Automation']['findAll'](_0x55d933);})['then'](function(_0xb046f9){_0x457995[_0x4f69('0x45')]=_0xb046f9;return _0x457995;})[_0x4f69('0x28')](respondWithFilteredResult(_0x2d1136,_0x55d933))[_0x4f69('0x46')](handleError(_0x2d1136,null));};exports[_0x4f69('0x47')]=function(_0x561c43,_0xbcca24){var _0x1d5690={'raw':![],'where':{'id':_0x561c43[_0x4f69('0x48')]['id']}},_0x336915={};_0x336915['model']=_[_0x4f69('0x32')](db[_0x4f69('0x43')][_0x4f69('0x49')]);_0x336915[_0x4f69('0x33')]=_[_0x4f69('0x32')](_0x561c43[_0x4f69('0x33')]);_0x336915[_0x4f69('0x34')]=_['intersection'](_0x336915[_0x4f69('0x31')],_0x336915[_0x4f69('0x33')]);_0x1d5690[_0x4f69('0x36')]=_['intersection'](_0x336915[_0x4f69('0x31')],qs[_0x4f69('0x37')](_0x561c43[_0x4f69('0x33')][_0x4f69('0x37')]));_0x1d5690[_0x4f69('0x36')]=_0x1d5690[_0x4f69('0x36')][_0x4f69('0x38')]?_0x1d5690[_0x4f69('0x36')]:_0x336915[_0x4f69('0x31')];if(_0x561c43['query'][_0x4f69('0x44')]){_0x1d5690[_0x4f69('0x4a')]=[{'all':!![]}];}_0x1d5690=_[_0x4f69('0x40')]({},_0x1d5690,_0x561c43[_0x4f69('0x42')]);return db[_0x4f69('0x43')][_0x4f69('0x4b')](_0x1d5690)[_0x4f69('0x28')](handleEntityNotFound(_0xbcca24,null))[_0x4f69('0x28')](respondWithResult(_0xbcca24,null))[_0x4f69('0x46')](handleError(_0xbcca24,null));};exports[_0x4f69('0x4c')]=function(_0x425832,_0x3aa3e8){return db['Automation'][_0x4f69('0x4c')](_0x425832[_0x4f69('0x4d')],{})[_0x4f69('0x28')](respondWithResult(_0x3aa3e8,0xc9))[_0x4f69('0x46')](handleError(_0x3aa3e8,null));};exports[_0x4f69('0x27')]=function(_0x3a6ed5,_0x2dcec7){if(_0x3a6ed5[_0x4f69('0x4d')]['id']){delete _0x3a6ed5['body']['id'];}return db[_0x4f69('0x43')][_0x4f69('0x4b')]({'where':{'id':_0x3a6ed5[_0x4f69('0x48')]['id']}})[_0x4f69('0x28')](handleEntityNotFound(_0x2dcec7,null))[_0x4f69('0x28')](saveUpdates(_0x3a6ed5['body'],null))['then'](respondWithResult(_0x2dcec7,null))[_0x4f69('0x46')](handleError(_0x2dcec7,null));};exports['destroy']=function(_0x5e867b,_0x8a14f6){return db['Automation'][_0x4f69('0x4b')]({'where':{'id':_0x5e867b[_0x4f69('0x48')]['id']}})['then'](handleEntityNotFound(_0x8a14f6,null))['then'](removeEntity(_0x8a14f6,null))[_0x4f69('0x46')](handleError(_0x8a14f6,null));};exports[_0x4f69('0x4e')]=function(_0x561830,_0x3adbf6,_0x3348e3){return db['Condition'][_0x4f69('0x4b')]({'where':{'id':_0x561830[_0x4f69('0x48')]['id']}})[_0x4f69('0x28')](handleEntityNotFound(_0x3adbf6,null))[_0x4f69('0x28')](function(_0x2cabfa){if(_0x2cabfa){return _0x2cabfa[_0x4f69('0x4e')](_0x561830[_0x4f69('0x4d')][_0x4f69('0x4f')],_[_0x4f69('0x50')](_0x561830[_0x4f69('0x4d')],['ids','id'])||{});}})[_0x4f69('0x28')](respondWithResult(_0x3adbf6,null))[_0x4f69('0x46')](handleError(_0x3adbf6,null));};exports[_0x4f69('0x51')]=function(_0x31d399,_0x531bc6,_0x48c632){var _0x8e8ff4={};var _0x1ec4d0={};var _0x1dfafd;var _0x4c2f76;return db[_0x4f69('0x43')]['findOne']({'where':{'id':_0x31d399[_0x4f69('0x48')]['id']}})[_0x4f69('0x28')](handleEntityNotFound(_0x531bc6,null))[_0x4f69('0x28')](function(_0x19cd4b){if(_0x19cd4b){_0x1dfafd=_0x19cd4b;_0x1ec4d0[_0x4f69('0x31')]=_[_0x4f69('0x32')](db[_0x4f69('0x52')][_0x4f69('0x49')]);_0x1ec4d0['query']=_['keys'](_0x31d399[_0x4f69('0x33')]);_0x1ec4d0[_0x4f69('0x34')]=_[_0x4f69('0x35')](_0x1ec4d0['model'],_0x1ec4d0['query']);_0x8e8ff4[_0x4f69('0x36')]=_['intersection'](_0x1ec4d0['model'],qs[_0x4f69('0x37')](_0x31d399['query'][_0x4f69('0x37')]));_0x8e8ff4[_0x4f69('0x36')]=_0x8e8ff4[_0x4f69('0x36')][_0x4f69('0x38')]?_0x8e8ff4['attributes']:_0x1ec4d0[_0x4f69('0x31')];_0x8e8ff4[_0x4f69('0x3b')]=qs['sort'](_0x31d399[_0x4f69('0x33')][_0x4f69('0x3c')]);_0x8e8ff4['where']=qs[_0x4f69('0x34')](_['pick'](_0x31d399[_0x4f69('0x33')],_0x1ec4d0[_0x4f69('0x34')]));if(_0x31d399[_0x4f69('0x33')][_0x4f69('0x3f')]){_0x8e8ff4['where']=_[_0x4f69('0x40')](_0x8e8ff4[_0x4f69('0x3d')],{'$or':_['map'](_0x8e8ff4[_0x4f69('0x36')],function(_0x25739e){var _0x1ba611={};_0x1ba611[_0x25739e]={'$like':'%'+_0x31d399[_0x4f69('0x33')][_0x4f69('0x3f')]+'%'};return _0x1ba611;})});}_0x8e8ff4=_[_0x4f69('0x40')]({},_0x8e8ff4,_0x31d399[_0x4f69('0x42')]);return _0x1dfafd[_0x4f69('0x51')](_0x8e8ff4);}})['then'](function(_0x5c1b8e){if(_0x5c1b8e){_0x4c2f76=_0x5c1b8e[_0x4f69('0x38')];if(!_0x31d399[_0x4f69('0x33')][_0x4f69('0x39')](_0x4f69('0x3a'))){_0x8e8ff4[_0x4f69('0x23')]=qs[_0x4f69('0x23')](_0x31d399[_0x4f69('0x33')][_0x4f69('0x23')]);_0x8e8ff4['offset']=qs[_0x4f69('0x20')](_0x31d399[_0x4f69('0x33')][_0x4f69('0x20')]);}return _0x1dfafd[_0x4f69('0x51')](_0x8e8ff4);}})['then'](function(_0x3e7984){if(_0x3e7984){return _0x3e7984?{'count':_0x4c2f76,'rows':_0x3e7984}:null;}})[_0x4f69('0x28')](respondWithResult(_0x531bc6,null))[_0x4f69('0x46')](handleError(_0x531bc6,null));};exports[_0x4f69('0x53')]=function(_0x4236db,_0x4509d7,_0xb867b5){return db['Action'][_0x4f69('0x4b')]({'where':{'id':_0x4236db[_0x4f69('0x48')]['id']}})[_0x4f69('0x28')](handleEntityNotFound(_0x4509d7,null))[_0x4f69('0x28')](function(_0x3e698f){if(_0x3e698f){return _0x3e698f['addActions'](_0x4236db[_0x4f69('0x4d')]['ids'],_[_0x4f69('0x50')](_0x4236db[_0x4f69('0x4d')],['ids','id'])||{});}})[_0x4f69('0x28')](respondWithResult(_0x4509d7,null))[_0x4f69('0x46')](handleError(_0x4509d7,null));};exports[_0x4f69('0x54')]=function(_0x210461,_0x17fc3e,_0x5e5358){var _0x2e995d={};var _0x345524={};var _0x110a22;var _0x130a31;return db[_0x4f69('0x43')][_0x4f69('0x55')]({'where':{'id':_0x210461[_0x4f69('0x48')]['id']}})['then'](handleEntityNotFound(_0x17fc3e,null))['then'](function(_0x36ac98){if(_0x36ac98){_0x110a22=_0x36ac98;_0x345524[_0x4f69('0x31')]=_[_0x4f69('0x32')](db['Action'][_0x4f69('0x49')]);_0x345524[_0x4f69('0x33')]=_[_0x4f69('0x32')](_0x210461[_0x4f69('0x33')]);_0x345524[_0x4f69('0x34')]=_[_0x4f69('0x35')](_0x345524[_0x4f69('0x31')],_0x345524[_0x4f69('0x33')]);_0x2e995d[_0x4f69('0x36')]=_[_0x4f69('0x35')](_0x345524['model'],qs[_0x4f69('0x37')](_0x210461[_0x4f69('0x33')][_0x4f69('0x37')]));_0x2e995d[_0x4f69('0x36')]=_0x2e995d[_0x4f69('0x36')][_0x4f69('0x38')]?_0x2e995d[_0x4f69('0x36')]:_0x345524['model'];_0x2e995d[_0x4f69('0x3b')]=qs['sort'](_0x210461['query']['sort']);_0x2e995d['where']=qs['filters'](_[_0x4f69('0x3e')](_0x210461[_0x4f69('0x33')],_0x345524['filters']));if(_0x210461[_0x4f69('0x33')][_0x4f69('0x3f')]){_0x2e995d['where']=_[_0x4f69('0x40')](_0x2e995d[_0x4f69('0x3d')],{'$or':_[_0x4f69('0x2d')](_0x2e995d['attributes'],function(_0xf73ee7){var _0x1f3786={};_0x1f3786[_0xf73ee7]={'$like':'%'+_0x210461[_0x4f69('0x33')][_0x4f69('0x3f')]+'%'};return _0x1f3786;})});}_0x2e995d=_[_0x4f69('0x40')]({},_0x2e995d,_0x210461[_0x4f69('0x42')]);return _0x110a22[_0x4f69('0x54')](_0x2e995d);}})[_0x4f69('0x28')](function(_0x76bb29){if(_0x76bb29){_0x130a31=_0x76bb29['length'];if(!_0x210461[_0x4f69('0x33')][_0x4f69('0x39')](_0x4f69('0x3a'))){_0x2e995d[_0x4f69('0x23')]=qs[_0x4f69('0x23')](_0x210461[_0x4f69('0x33')]['limit']);_0x2e995d['offset']=qs['offset'](_0x210461['query'][_0x4f69('0x20')]);}return _0x110a22[_0x4f69('0x54')](_0x2e995d);}})[_0x4f69('0x28')](function(_0x24d845){if(_0x24d845){return _0x24d845?{'count':_0x130a31,'rows':_0x24d845}:null;}})['then'](respondWithResult(_0x17fc3e,null))[_0x4f69('0x46')](handleError(_0x17fc3e,null));};
\ No newline at end of file
+var _0xce75=['json','undefined','limit','count','offset','Content-Range','apply','reject','save','then','destroy','stack','name','send','map','Automation','rawAttributes','fieldName','type','key','model','filters','intersection','query','attributes','fields','length','hasOwnProperty','nolimit','sort','where','filter','VIRTUAL','merge','include','rows','catch','params','keys','includeAll','options','find','create','body','update','addConditions','Condition','omit','getConditions','findOne','order','pick','addActions','ids','Action','getActions','rimraf','zip-dir','request-promise','moment','mustache','util','path','sox','ejs','fs-extra','jsforce','to-csv','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','../../config/utils','../../config/license/util','../../mysqldb','sendStatus','status','end'];(function(_0x23bd15,_0x39da80){var _0x110e11=function(_0x204e58){while(--_0x204e58){_0x23bd15['push'](_0x23bd15['shift']());}};_0x110e11(++_0x39da80);}(_0xce75,0x12e));var _0x5ce7=function(_0x49c2e6,_0x5a9d1e){_0x49c2e6=_0x49c2e6-0x0;var _0x3c2340=_0xce75[_0x49c2e6];return _0x3c2340;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0x5ce7('0x0'));var zipdir=require(_0x5ce7('0x1'));var jsonpatch=require('fast-json-patch');var rp=require(_0x5ce7('0x2'));var moment=require(_0x5ce7('0x3'));var BPromise=require('bluebird');var Mustache=require(_0x5ce7('0x4'));var util=require(_0x5ce7('0x5'));var path=require(_0x5ce7('0x6'));var sox=require(_0x5ce7('0x7'));var csv=require('to-csv');var ejs=require(_0x5ce7('0x8'));var fs=require('fs');var fs_extra=require(_0x5ce7('0x9'));var _=require('lodash');var squel=require('squel');var crypto=require('crypto');var jsforce=require(_0x5ce7('0xa'));var deskjs=require('desk.js');var toCsv=require(_0x5ce7('0xb'));var querystring=require(_0x5ce7('0xc'));var Papa=require(_0x5ce7('0xd'));var Redis=require(_0x5ce7('0xe'));var authService=require(_0x5ce7('0xf'));var qs=require(_0x5ce7('0x10'));var as=require(_0x5ce7('0x11'));var hardwareService=require(_0x5ce7('0x12'));var logger=require(_0x5ce7('0x13'))('api');var utils=require(_0x5ce7('0x14'));var config=require('../../config/environment');var licenseUtil=require(_0x5ce7('0x15'));var db=require(_0x5ce7('0x16'))['db'];function respondWithStatusCode(_0x474924,_0x587d0b){_0x587d0b=_0x587d0b||0xcc;return function(_0x5e69fc){if(_0x5e69fc){return _0x474924[_0x5ce7('0x17')](_0x587d0b);}return _0x474924[_0x5ce7('0x18')](_0x587d0b)[_0x5ce7('0x19')]();};}function respondWithResult(_0x434fa7,_0x3465c0){_0x3465c0=_0x3465c0||0xc8;return function(_0x1b8ee6){if(_0x1b8ee6){return _0x434fa7[_0x5ce7('0x18')](_0x3465c0)[_0x5ce7('0x1a')](_0x1b8ee6);}};}function respondWithFilteredResult(_0xb07d7a,_0x512376){return function(_0x1bd14e){if(_0x1bd14e){var _0xc22916=typeof _0x512376['offset']===_0x5ce7('0x1b')&&typeof _0x512376[_0x5ce7('0x1c')]===_0x5ce7('0x1b');var _0x46d222=_0x1bd14e[_0x5ce7('0x1d')];var _0x1ea8e3=_0xc22916?0x0:_0x512376[_0x5ce7('0x1e')];var _0x3dd1b1=_0xc22916?_0x1bd14e[_0x5ce7('0x1d')]:_0x512376[_0x5ce7('0x1e')]+_0x512376['limit'];var _0x14f93a;if(_0x3dd1b1>=_0x46d222){_0x3dd1b1=_0x46d222;_0x14f93a=0xc8;}else{_0x14f93a=0xce;}_0xb07d7a['status'](_0x14f93a);return _0xb07d7a['set'](_0x5ce7('0x1f'),_0x1ea8e3+'-'+_0x3dd1b1+'/'+_0x46d222)[_0x5ce7('0x1a')](_0x1bd14e);}return null;};}function patchUpdates(_0x19d7e4){return function(_0x2c9fda){try{jsonpatch[_0x5ce7('0x20')](_0x2c9fda,_0x19d7e4,!![]);}catch(_0x390a9e){return BPromise[_0x5ce7('0x21')](_0x390a9e);}return _0x2c9fda[_0x5ce7('0x22')]();};}function saveUpdates(_0x80ba4c,_0x535eef){return function(_0x11de56){if(_0x11de56){return _0x11de56['update'](_0x80ba4c)[_0x5ce7('0x23')](function(_0x35172c){return _0x35172c;});}return null;};}function removeEntity(_0x45e781,_0x4910d1){return function(_0x57f18b){if(_0x57f18b){return _0x57f18b[_0x5ce7('0x24')]()['then'](function(){_0x45e781[_0x5ce7('0x18')](0xcc)[_0x5ce7('0x19')]();});}};}function handleEntityNotFound(_0x3d68b3,_0x238590){return function(_0x628dee){if(!_0x628dee){_0x3d68b3[_0x5ce7('0x17')](0x194);}return _0x628dee;};}function handleError(_0x741f22,_0x387eaf){_0x387eaf=_0x387eaf||0x1f4;return function(_0x1a2ffe){logger['error'](_0x1a2ffe[_0x5ce7('0x25')]);if(_0x1a2ffe[_0x5ce7('0x26')]){delete _0x1a2ffe[_0x5ce7('0x26')];}_0x741f22[_0x5ce7('0x18')](_0x387eaf)[_0x5ce7('0x27')](_0x1a2ffe);};}exports['index']=function(_0x4c3089,_0x129e84){var _0x12bb37={},_0x5ac912={},_0x22ba31={'count':0x0,'rows':[]};var _0x1542ab=_[_0x5ce7('0x28')](db[_0x5ce7('0x29')][_0x5ce7('0x2a')],function(_0x5624df){return{'name':_0x5624df[_0x5ce7('0x2b')],'type':_0x5624df[_0x5ce7('0x2c')][_0x5ce7('0x2d')]};});_0x5ac912[_0x5ce7('0x2e')]=_[_0x5ce7('0x28')](_0x1542ab,_0x5ce7('0x26'));_0x5ac912['query']=_['keys'](_0x4c3089['query']);_0x5ac912[_0x5ce7('0x2f')]=_[_0x5ce7('0x30')](_0x5ac912[_0x5ce7('0x2e')],_0x5ac912[_0x5ce7('0x31')]);_0x12bb37[_0x5ce7('0x32')]=_[_0x5ce7('0x30')](_0x5ac912[_0x5ce7('0x2e')],qs[_0x5ce7('0x33')](_0x4c3089[_0x5ce7('0x31')][_0x5ce7('0x33')]));_0x12bb37[_0x5ce7('0x32')]=_0x12bb37['attributes'][_0x5ce7('0x34')]?_0x12bb37['attributes']:_0x5ac912[_0x5ce7('0x2e')];if(!_0x4c3089['query'][_0x5ce7('0x35')](_0x5ce7('0x36'))){_0x12bb37[_0x5ce7('0x1c')]=qs['limit'](_0x4c3089['query'][_0x5ce7('0x1c')]);_0x12bb37[_0x5ce7('0x1e')]=qs['offset'](_0x4c3089['query'][_0x5ce7('0x1e')]);}_0x12bb37['order']=qs['sort'](_0x4c3089[_0x5ce7('0x31')][_0x5ce7('0x37')]);_0x12bb37[_0x5ce7('0x38')]=qs[_0x5ce7('0x2f')](_['pick'](_0x4c3089['query'],_0x5ac912[_0x5ce7('0x2f')]),_0x1542ab);if(_0x4c3089['query'][_0x5ce7('0x39')]){_0x12bb37['where']=_['merge'](_0x12bb37['where'],{'$or':_[_0x5ce7('0x28')](_0x1542ab,function(_0x4eebfe){if(_0x4eebfe[_0x5ce7('0x2c')]!==_0x5ce7('0x3a')){var _0x5a2463={};_0x5a2463[_0x4eebfe[_0x5ce7('0x26')]]={'$like':'%'+_0x4c3089['query'][_0x5ce7('0x39')]+'%'};return _0x5a2463;}})});}_0x12bb37=_[_0x5ce7('0x3b')]({},_0x12bb37,_0x4c3089['options']);var _0x3ed208={'where':_0x12bb37['where']};return db[_0x5ce7('0x29')]['count'](_0x3ed208)[_0x5ce7('0x23')](function(_0x24f351){_0x22ba31[_0x5ce7('0x1d')]=_0x24f351;if(_0x4c3089[_0x5ce7('0x31')]['includeAll']){_0x12bb37[_0x5ce7('0x3c')]=[{'all':!![]}];}return db[_0x5ce7('0x29')]['findAll'](_0x12bb37);})[_0x5ce7('0x23')](function(_0x2423d3){_0x22ba31[_0x5ce7('0x3d')]=_0x2423d3;return _0x22ba31;})[_0x5ce7('0x23')](respondWithFilteredResult(_0x129e84,_0x12bb37))[_0x5ce7('0x3e')](handleError(_0x129e84,null));};exports['show']=function(_0x37a507,_0x1aeafa){var _0x282094={'raw':![],'where':{'id':_0x37a507[_0x5ce7('0x3f')]['id']}},_0xbeebe7={};_0xbeebe7[_0x5ce7('0x2e')]=_[_0x5ce7('0x40')](db['Automation'][_0x5ce7('0x2a')]);_0xbeebe7['query']=_[_0x5ce7('0x40')](_0x37a507['query']);_0xbeebe7[_0x5ce7('0x2f')]=_['intersection'](_0xbeebe7[_0x5ce7('0x2e')],_0xbeebe7['query']);_0x282094[_0x5ce7('0x32')]=_['intersection'](_0xbeebe7['model'],qs[_0x5ce7('0x33')](_0x37a507[_0x5ce7('0x31')][_0x5ce7('0x33')]));_0x282094[_0x5ce7('0x32')]=_0x282094[_0x5ce7('0x32')][_0x5ce7('0x34')]?_0x282094[_0x5ce7('0x32')]:_0xbeebe7['model'];if(_0x37a507[_0x5ce7('0x31')][_0x5ce7('0x41')]){_0x282094[_0x5ce7('0x3c')]=[{'all':!![]}];}_0x282094=_[_0x5ce7('0x3b')]({},_0x282094,_0x37a507[_0x5ce7('0x42')]);return db[_0x5ce7('0x29')][_0x5ce7('0x43')](_0x282094)[_0x5ce7('0x23')](handleEntityNotFound(_0x1aeafa,null))[_0x5ce7('0x23')](respondWithResult(_0x1aeafa,null))['catch'](handleError(_0x1aeafa,null));};exports['create']=function(_0x6b383b,_0x5917c4){return db['Automation'][_0x5ce7('0x44')](_0x6b383b[_0x5ce7('0x45')],{})[_0x5ce7('0x23')](respondWithResult(_0x5917c4,0xc9))[_0x5ce7('0x3e')](handleError(_0x5917c4,null));};exports[_0x5ce7('0x46')]=function(_0x716977,_0x820154){if(_0x716977[_0x5ce7('0x45')]['id']){delete _0x716977['body']['id'];}return db[_0x5ce7('0x29')][_0x5ce7('0x43')]({'where':{'id':_0x716977[_0x5ce7('0x3f')]['id']}})[_0x5ce7('0x23')](handleEntityNotFound(_0x820154,null))[_0x5ce7('0x23')](saveUpdates(_0x716977[_0x5ce7('0x45')],null))[_0x5ce7('0x23')](respondWithResult(_0x820154,null))['catch'](handleError(_0x820154,null));};exports['destroy']=function(_0x124776,_0x55cfe3){return db[_0x5ce7('0x29')][_0x5ce7('0x43')]({'where':{'id':_0x124776[_0x5ce7('0x3f')]['id']}})[_0x5ce7('0x23')](handleEntityNotFound(_0x55cfe3,null))[_0x5ce7('0x23')](removeEntity(_0x55cfe3,null))[_0x5ce7('0x3e')](handleError(_0x55cfe3,null));};exports[_0x5ce7('0x47')]=function(_0x26ad57,_0x1b44c2,_0xe0656b){return db[_0x5ce7('0x48')][_0x5ce7('0x43')]({'where':{'id':_0x26ad57[_0x5ce7('0x3f')]['id']}})['then'](handleEntityNotFound(_0x1b44c2,null))[_0x5ce7('0x23')](function(_0x3c2226){if(_0x3c2226){return _0x3c2226[_0x5ce7('0x47')](_0x26ad57[_0x5ce7('0x45')]['ids'],_[_0x5ce7('0x49')](_0x26ad57[_0x5ce7('0x45')],['ids','id'])||{});}})[_0x5ce7('0x23')](respondWithResult(_0x1b44c2,null))['catch'](handleError(_0x1b44c2,null));};exports[_0x5ce7('0x4a')]=function(_0x2cbec2,_0x5c4ff5,_0x4c776e){var _0x44eb55={};var _0x5b7974={};var _0x2c9912;var _0x42c481;return db[_0x5ce7('0x29')][_0x5ce7('0x4b')]({'where':{'id':_0x2cbec2[_0x5ce7('0x3f')]['id']}})[_0x5ce7('0x23')](handleEntityNotFound(_0x5c4ff5,null))[_0x5ce7('0x23')](function(_0x59de47){if(_0x59de47){_0x2c9912=_0x59de47;_0x5b7974[_0x5ce7('0x2e')]=_[_0x5ce7('0x40')](db[_0x5ce7('0x48')][_0x5ce7('0x2a')]);_0x5b7974['query']=_['keys'](_0x2cbec2[_0x5ce7('0x31')]);_0x5b7974['filters']=_[_0x5ce7('0x30')](_0x5b7974[_0x5ce7('0x2e')],_0x5b7974[_0x5ce7('0x31')]);_0x44eb55['attributes']=_[_0x5ce7('0x30')](_0x5b7974[_0x5ce7('0x2e')],qs[_0x5ce7('0x33')](_0x2cbec2[_0x5ce7('0x31')][_0x5ce7('0x33')]));_0x44eb55[_0x5ce7('0x32')]=_0x44eb55[_0x5ce7('0x32')][_0x5ce7('0x34')]?_0x44eb55['attributes']:_0x5b7974['model'];_0x44eb55[_0x5ce7('0x4c')]=qs[_0x5ce7('0x37')](_0x2cbec2[_0x5ce7('0x31')]['sort']);_0x44eb55[_0x5ce7('0x38')]=qs[_0x5ce7('0x2f')](_[_0x5ce7('0x4d')](_0x2cbec2[_0x5ce7('0x31')],_0x5b7974[_0x5ce7('0x2f')]));if(_0x2cbec2[_0x5ce7('0x31')][_0x5ce7('0x39')]){_0x44eb55[_0x5ce7('0x38')]=_[_0x5ce7('0x3b')](_0x44eb55['where'],{'$or':_[_0x5ce7('0x28')](_0x44eb55['attributes'],function(_0x2c7a7b){var _0x368cb0={};_0x368cb0[_0x2c7a7b]={'$like':'%'+_0x2cbec2[_0x5ce7('0x31')][_0x5ce7('0x39')]+'%'};return _0x368cb0;})});}_0x44eb55=_[_0x5ce7('0x3b')]({},_0x44eb55,_0x2cbec2[_0x5ce7('0x42')]);return _0x2c9912[_0x5ce7('0x4a')](_0x44eb55);}})['then'](function(_0x538cd2){if(_0x538cd2){_0x42c481=_0x538cd2['length'];if(!_0x2cbec2[_0x5ce7('0x31')][_0x5ce7('0x35')](_0x5ce7('0x36'))){_0x44eb55[_0x5ce7('0x1c')]=qs[_0x5ce7('0x1c')](_0x2cbec2[_0x5ce7('0x31')][_0x5ce7('0x1c')]);_0x44eb55[_0x5ce7('0x1e')]=qs['offset'](_0x2cbec2['query'][_0x5ce7('0x1e')]);}return _0x2c9912[_0x5ce7('0x4a')](_0x44eb55);}})[_0x5ce7('0x23')](function(_0x4f7b61){if(_0x4f7b61){return _0x4f7b61?{'count':_0x42c481,'rows':_0x4f7b61}:null;}})[_0x5ce7('0x23')](respondWithResult(_0x5c4ff5,null))[_0x5ce7('0x3e')](handleError(_0x5c4ff5,null));};exports['addActions']=function(_0x1843e6,_0x4e91b4,_0x5af260){return db['Action']['find']({'where':{'id':_0x1843e6[_0x5ce7('0x3f')]['id']}})[_0x5ce7('0x23')](handleEntityNotFound(_0x4e91b4,null))[_0x5ce7('0x23')](function(_0x181a3b){if(_0x181a3b){return _0x181a3b[_0x5ce7('0x4e')](_0x1843e6[_0x5ce7('0x45')]['ids'],_[_0x5ce7('0x49')](_0x1843e6[_0x5ce7('0x45')],[_0x5ce7('0x4f'),'id'])||{});}})[_0x5ce7('0x23')](respondWithResult(_0x4e91b4,null))[_0x5ce7('0x3e')](handleError(_0x4e91b4,null));};exports['getActions']=function(_0x4bb5e0,_0x7c201a,_0x3ee06e){var _0x659fb3={};var _0x10bd8a={};var _0xe6567;var _0x2bc649;return db[_0x5ce7('0x29')][_0x5ce7('0x4b')]({'where':{'id':_0x4bb5e0[_0x5ce7('0x3f')]['id']}})['then'](handleEntityNotFound(_0x7c201a,null))[_0x5ce7('0x23')](function(_0x2b5236){if(_0x2b5236){_0xe6567=_0x2b5236;_0x10bd8a['model']=_[_0x5ce7('0x40')](db[_0x5ce7('0x50')][_0x5ce7('0x2a')]);_0x10bd8a[_0x5ce7('0x31')]=_[_0x5ce7('0x40')](_0x4bb5e0[_0x5ce7('0x31')]);_0x10bd8a[_0x5ce7('0x2f')]=_[_0x5ce7('0x30')](_0x10bd8a['model'],_0x10bd8a[_0x5ce7('0x31')]);_0x659fb3[_0x5ce7('0x32')]=_[_0x5ce7('0x30')](_0x10bd8a['model'],qs['fields'](_0x4bb5e0['query']['fields']));_0x659fb3[_0x5ce7('0x32')]=_0x659fb3[_0x5ce7('0x32')]['length']?_0x659fb3['attributes']:_0x10bd8a['model'];_0x659fb3[_0x5ce7('0x4c')]=qs[_0x5ce7('0x37')](_0x4bb5e0[_0x5ce7('0x31')][_0x5ce7('0x37')]);_0x659fb3['where']=qs['filters'](_[_0x5ce7('0x4d')](_0x4bb5e0['query'],_0x10bd8a[_0x5ce7('0x2f')]));if(_0x4bb5e0[_0x5ce7('0x31')][_0x5ce7('0x39')]){_0x659fb3[_0x5ce7('0x38')]=_['merge'](_0x659fb3[_0x5ce7('0x38')],{'$or':_[_0x5ce7('0x28')](_0x659fb3[_0x5ce7('0x32')],function(_0x2d3a9a){var _0x2f8916={};_0x2f8916[_0x2d3a9a]={'$like':'%'+_0x4bb5e0[_0x5ce7('0x31')][_0x5ce7('0x39')]+'%'};return _0x2f8916;})});}_0x659fb3=_[_0x5ce7('0x3b')]({},_0x659fb3,_0x4bb5e0[_0x5ce7('0x42')]);return _0xe6567[_0x5ce7('0x51')](_0x659fb3);}})[_0x5ce7('0x23')](function(_0x319ff7){if(_0x319ff7){_0x2bc649=_0x319ff7[_0x5ce7('0x34')];if(!_0x4bb5e0[_0x5ce7('0x31')][_0x5ce7('0x35')](_0x5ce7('0x36'))){_0x659fb3['limit']=qs[_0x5ce7('0x1c')](_0x4bb5e0[_0x5ce7('0x31')][_0x5ce7('0x1c')]);_0x659fb3[_0x5ce7('0x1e')]=qs['offset'](_0x4bb5e0[_0x5ce7('0x31')][_0x5ce7('0x1e')]);}return _0xe6567[_0x5ce7('0x51')](_0x659fb3);}})['then'](function(_0x5f1365){if(_0x5f1365){return _0x5f1365?{'count':_0x2bc649,'rows':_0x5f1365}:null;}})[_0x5ce7('0x23')](respondWithResult(_0x7c201a,null))[_0x5ce7('0x3e')](handleError(_0x7c201a,null));};
\ No newline at end of file