Built motion from commit 47436d59.|2.6.7
[motion2.git] / server / api / automation / automation.controller.js
index 62d441f..e511a58 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x5965=['getActions','options','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','mustache','util','path','to-csv','ejs','fs-extra','squel','crypto','jsforce','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../mysqldb','sendStatus','status','end','json','offset','undefined','limit','set','Content-Range','reject','save','update','then','error','stack','name','index','map','Automation','rawAttributes','fieldName','type','key','model','keys','query','filters','intersection','attributes','fields','nolimit','order','where','pick','filter','merge','VIRTUAL','count','includeAll','findAll','rows','catch','show','params','length','include','body','find','destroy','addConditions','Condition','omit','getConditions','findOne','sort','hasOwnProperty','Action','ids'];(function(_0x58b603,_0x450f6d){var _0xf76126=function(_0x5688da){while(--_0x5688da){_0x58b603['push'](_0x58b603['shift']());}};_0xf76126(++_0x450f6d);}(_0x5965,0x1b5));var _0x5596=function(_0x1abbbb,_0x234d69){_0x1abbbb=_0x1abbbb-0x0;var _0x439102=_0x5965[_0x1abbbb];return _0x439102;};'use strict';var emlformat=require(_0x5596('0x0'));var rimraf=require(_0x5596('0x1'));var zipdir=require(_0x5596('0x2'));var jsonpatch=require(_0x5596('0x3'));var rp=require(_0x5596('0x4'));var moment=require(_0x5596('0x5'));var BPromise=require('bluebird');var Mustache=require(_0x5596('0x6'));var util=require(_0x5596('0x7'));var path=require(_0x5596('0x8'));var sox=require('sox');var csv=require(_0x5596('0x9'));var ejs=require(_0x5596('0xa'));var fs=require('fs');var fs_extra=require(_0x5596('0xb'));var _=require('lodash');var squel=require(_0x5596('0xc'));var crypto=require(_0x5596('0xd'));var jsforce=require(_0x5596('0xe'));var deskjs=require('desk.js');var toCsv=require(_0x5596('0x9'));var querystring=require(_0x5596('0xf'));var Papa=require(_0x5596('0x10'));var Redis=require(_0x5596('0x11'));var authService=require(_0x5596('0x12'));var qs=require(_0x5596('0x13'));var as=require(_0x5596('0x14'));var hardwareService=require(_0x5596('0x15'));var logger=require(_0x5596('0x16'))(_0x5596('0x17'));var utils=require(_0x5596('0x18'));var config=require(_0x5596('0x19'));var licenseUtil=require('../../config/license/util');var db=require(_0x5596('0x1a'))['db'];function respondWithStatusCode(_0x459581,_0x320074){_0x320074=_0x320074||0xcc;return function(_0x59ceaf){if(_0x59ceaf){return _0x459581[_0x5596('0x1b')](_0x320074);}return _0x459581[_0x5596('0x1c')](_0x320074)[_0x5596('0x1d')]();};}function respondWithResult(_0x2abe0a,_0x574d2a){_0x574d2a=_0x574d2a||0xc8;return function(_0x4f8807){if(_0x4f8807){return _0x2abe0a[_0x5596('0x1c')](_0x574d2a)[_0x5596('0x1e')](_0x4f8807);}};}function respondWithFilteredResult(_0x18ac92,_0x14ecc6){return function(_0x3989a2){if(_0x3989a2){var _0x5cae74=typeof _0x14ecc6[_0x5596('0x1f')]===_0x5596('0x20')&&typeof _0x14ecc6[_0x5596('0x21')]==='undefined';var _0x57bf1f=_0x3989a2['count'];var _0x5580fa=_0x5cae74?0x0:_0x14ecc6[_0x5596('0x1f')];var _0x32afc8=_0x5cae74?_0x3989a2['count']:_0x14ecc6[_0x5596('0x1f')]+_0x14ecc6[_0x5596('0x21')];var _0x5a4478;if(_0x32afc8>=_0x57bf1f){_0x32afc8=_0x57bf1f;_0x5a4478=0xc8;}else{_0x5a4478=0xce;}_0x18ac92[_0x5596('0x1c')](_0x5a4478);return _0x18ac92[_0x5596('0x22')](_0x5596('0x23'),_0x5580fa+'-'+_0x32afc8+'/'+_0x57bf1f)[_0x5596('0x1e')](_0x3989a2);}return null;};}function patchUpdates(_0x2d2aec){return function(_0x273f1c){try{jsonpatch['apply'](_0x273f1c,_0x2d2aec,!![]);}catch(_0x1ac973){return BPromise[_0x5596('0x24')](_0x1ac973);}return _0x273f1c[_0x5596('0x25')]();};}function saveUpdates(_0x25cd02,_0x5a4bfe){return function(_0x579bd3){if(_0x579bd3){return _0x579bd3[_0x5596('0x26')](_0x25cd02)['then'](function(_0x4e5d26){return _0x4e5d26;});}return null;};}function removeEntity(_0x1308e3,_0x44866c){return function(_0x503a7){if(_0x503a7){return _0x503a7['destroy']()[_0x5596('0x27')](function(){_0x1308e3['status'](0xcc)['end']();});}};}function handleEntityNotFound(_0x2eef27,_0x1ea1b4){return function(_0x31ecd8){if(!_0x31ecd8){_0x2eef27[_0x5596('0x1b')](0x194);}return _0x31ecd8;};}function handleError(_0x23fc69,_0x1a815e){_0x1a815e=_0x1a815e||0x1f4;return function(_0xf3fa7c){logger[_0x5596('0x28')](_0xf3fa7c[_0x5596('0x29')]);if(_0xf3fa7c['name']){delete _0xf3fa7c[_0x5596('0x2a')];}_0x23fc69['status'](_0x1a815e)['send'](_0xf3fa7c);};}exports[_0x5596('0x2b')]=function(_0x270b99,_0x11c392){var _0x145791={},_0xc7721f={},_0x20d0bf={'count':0x0,'rows':[]};var _0x3a0acf=_[_0x5596('0x2c')](db[_0x5596('0x2d')][_0x5596('0x2e')],function(_0x5cbffc){return{'name':_0x5cbffc[_0x5596('0x2f')],'type':_0x5cbffc[_0x5596('0x30')][_0x5596('0x31')]};});_0xc7721f[_0x5596('0x32')]=_['map'](_0x3a0acf,_0x5596('0x2a'));_0xc7721f['query']=_[_0x5596('0x33')](_0x270b99[_0x5596('0x34')]);_0xc7721f[_0x5596('0x35')]=_[_0x5596('0x36')](_0xc7721f['model'],_0xc7721f[_0x5596('0x34')]);_0x145791[_0x5596('0x37')]=_[_0x5596('0x36')](_0xc7721f[_0x5596('0x32')],qs[_0x5596('0x38')](_0x270b99[_0x5596('0x34')]['fields']));_0x145791[_0x5596('0x37')]=_0x145791[_0x5596('0x37')]['length']?_0x145791[_0x5596('0x37')]:_0xc7721f[_0x5596('0x32')];if(!_0x270b99['query']['hasOwnProperty'](_0x5596('0x39'))){_0x145791[_0x5596('0x21')]=qs['limit'](_0x270b99[_0x5596('0x34')][_0x5596('0x21')]);_0x145791['offset']=qs[_0x5596('0x1f')](_0x270b99['query'][_0x5596('0x1f')]);}_0x145791[_0x5596('0x3a')]=qs['sort'](_0x270b99[_0x5596('0x34')]['sort']);_0x145791[_0x5596('0x3b')]=qs[_0x5596('0x35')](_[_0x5596('0x3c')](_0x270b99[_0x5596('0x34')],_0xc7721f[_0x5596('0x35')]),_0x3a0acf);if(_0x270b99[_0x5596('0x34')][_0x5596('0x3d')]){_0x145791[_0x5596('0x3b')]=_[_0x5596('0x3e')](_0x145791[_0x5596('0x3b')],{'$or':_[_0x5596('0x2c')](_0x3a0acf,function(_0x4ae9f6){if(_0x4ae9f6['type']!==_0x5596('0x3f')){var _0x20b1d0={};_0x20b1d0[_0x4ae9f6[_0x5596('0x2a')]]={'$like':'%'+_0x270b99[_0x5596('0x34')][_0x5596('0x3d')]+'%'};return _0x20b1d0;}})});}_0x145791=_['merge']({},_0x145791,_0x270b99['options']);var _0x18cca5={'where':_0x145791['where']};return db['Automation'][_0x5596('0x40')](_0x18cca5)['then'](function(_0x24e03a){_0x20d0bf[_0x5596('0x40')]=_0x24e03a;if(_0x270b99[_0x5596('0x34')][_0x5596('0x41')]){_0x145791['include']=[{'all':!![]}];}return db[_0x5596('0x2d')][_0x5596('0x42')](_0x145791);})[_0x5596('0x27')](function(_0x1301b4){_0x20d0bf[_0x5596('0x43')]=_0x1301b4;return _0x20d0bf;})[_0x5596('0x27')](respondWithFilteredResult(_0x11c392,_0x145791))[_0x5596('0x44')](handleError(_0x11c392,null));};exports[_0x5596('0x45')]=function(_0x112025,_0x7d6e56){var _0x27313a={'raw':![],'where':{'id':_0x112025[_0x5596('0x46')]['id']}},_0x49552c={};_0x49552c[_0x5596('0x32')]=_[_0x5596('0x33')](db[_0x5596('0x2d')][_0x5596('0x2e')]);_0x49552c['query']=_[_0x5596('0x33')](_0x112025[_0x5596('0x34')]);_0x49552c['filters']=_['intersection'](_0x49552c[_0x5596('0x32')],_0x49552c[_0x5596('0x34')]);_0x27313a['attributes']=_['intersection'](_0x49552c[_0x5596('0x32')],qs['fields'](_0x112025[_0x5596('0x34')][_0x5596('0x38')]));_0x27313a[_0x5596('0x37')]=_0x27313a[_0x5596('0x37')][_0x5596('0x47')]?_0x27313a['attributes']:_0x49552c[_0x5596('0x32')];if(_0x112025['query'][_0x5596('0x41')]){_0x27313a[_0x5596('0x48')]=[{'all':!![]}];}_0x27313a=_['merge']({},_0x27313a,_0x112025['options']);return db[_0x5596('0x2d')]['find'](_0x27313a)[_0x5596('0x27')](handleEntityNotFound(_0x7d6e56,null))[_0x5596('0x27')](respondWithResult(_0x7d6e56,null))[_0x5596('0x44')](handleError(_0x7d6e56,null));};exports['create']=function(_0x211ad8,_0x356446){return db['Automation']['create'](_0x211ad8['body'],{})[_0x5596('0x27')](respondWithResult(_0x356446,0xc9))['catch'](handleError(_0x356446,null));};exports[_0x5596('0x26')]=function(_0x53f6d3,_0x511248){if(_0x53f6d3[_0x5596('0x49')]['id']){delete _0x53f6d3[_0x5596('0x49')]['id'];}return db[_0x5596('0x2d')][_0x5596('0x4a')]({'where':{'id':_0x53f6d3[_0x5596('0x46')]['id']}})[_0x5596('0x27')](handleEntityNotFound(_0x511248,null))[_0x5596('0x27')](saveUpdates(_0x53f6d3[_0x5596('0x49')],null))[_0x5596('0x27')](respondWithResult(_0x511248,null))[_0x5596('0x44')](handleError(_0x511248,null));};exports[_0x5596('0x4b')]=function(_0x1ed24a,_0x357c29){return db[_0x5596('0x2d')][_0x5596('0x4a')]({'where':{'id':_0x1ed24a[_0x5596('0x46')]['id']}})['then'](handleEntityNotFound(_0x357c29,null))[_0x5596('0x27')](removeEntity(_0x357c29,null))[_0x5596('0x44')](handleError(_0x357c29,null));};exports[_0x5596('0x4c')]=function(_0x1616a7,_0x41dc95,_0x4b524c){return db[_0x5596('0x4d')][_0x5596('0x4a')]({'where':{'id':_0x1616a7[_0x5596('0x46')]['id']}})['then'](handleEntityNotFound(_0x41dc95,null))[_0x5596('0x27')](function(_0x72f462){if(_0x72f462){return _0x72f462['addConditions'](_0x1616a7['body']['ids'],_[_0x5596('0x4e')](_0x1616a7[_0x5596('0x49')],['ids','id'])||{});}})['then'](respondWithResult(_0x41dc95,null))[_0x5596('0x44')](handleError(_0x41dc95,null));};exports[_0x5596('0x4f')]=function(_0x2a1ff6,_0x38b12c,_0x3ec75e){var _0x348be5={};var _0x26b5b8={};var _0xd56f65;var _0x3ce795;return db[_0x5596('0x2d')][_0x5596('0x50')]({'where':{'id':_0x2a1ff6['params']['id']}})[_0x5596('0x27')](handleEntityNotFound(_0x38b12c,null))[_0x5596('0x27')](function(_0x19a111){if(_0x19a111){_0xd56f65=_0x19a111;_0x26b5b8[_0x5596('0x32')]=_['keys'](db[_0x5596('0x4d')]['rawAttributes']);_0x26b5b8[_0x5596('0x34')]=_[_0x5596('0x33')](_0x2a1ff6[_0x5596('0x34')]);_0x26b5b8['filters']=_[_0x5596('0x36')](_0x26b5b8[_0x5596('0x32')],_0x26b5b8['query']);_0x348be5[_0x5596('0x37')]=_[_0x5596('0x36')](_0x26b5b8[_0x5596('0x32')],qs[_0x5596('0x38')](_0x2a1ff6['query']['fields']));_0x348be5[_0x5596('0x37')]=_0x348be5[_0x5596('0x37')][_0x5596('0x47')]?_0x348be5[_0x5596('0x37')]:_0x26b5b8['model'];_0x348be5[_0x5596('0x3a')]=qs[_0x5596('0x51')](_0x2a1ff6[_0x5596('0x34')][_0x5596('0x51')]);_0x348be5[_0x5596('0x3b')]=qs[_0x5596('0x35')](_[_0x5596('0x3c')](_0x2a1ff6[_0x5596('0x34')],_0x26b5b8[_0x5596('0x35')]));if(_0x2a1ff6[_0x5596('0x34')][_0x5596('0x3d')]){_0x348be5[_0x5596('0x3b')]=_[_0x5596('0x3e')](_0x348be5['where'],{'$or':_[_0x5596('0x2c')](_0x348be5[_0x5596('0x37')],function(_0x31af16){var _0x428b37={};_0x428b37[_0x31af16]={'$like':'%'+_0x2a1ff6[_0x5596('0x34')][_0x5596('0x3d')]+'%'};return _0x428b37;})});}_0x348be5=_[_0x5596('0x3e')]({},_0x348be5,_0x2a1ff6['options']);return _0xd56f65['getConditions'](_0x348be5);}})[_0x5596('0x27')](function(_0x368b66){if(_0x368b66){_0x3ce795=_0x368b66['length'];if(!_0x2a1ff6['query'][_0x5596('0x52')](_0x5596('0x39'))){_0x348be5[_0x5596('0x21')]=qs['limit'](_0x2a1ff6[_0x5596('0x34')][_0x5596('0x21')]);_0x348be5[_0x5596('0x1f')]=qs['offset'](_0x2a1ff6['query'][_0x5596('0x1f')]);}return _0xd56f65[_0x5596('0x4f')](_0x348be5);}})[_0x5596('0x27')](function(_0xc8e969){if(_0xc8e969){return _0xc8e969?{'count':_0x3ce795,'rows':_0xc8e969}:null;}})[_0x5596('0x27')](respondWithResult(_0x38b12c,null))[_0x5596('0x44')](handleError(_0x38b12c,null));};exports['addActions']=function(_0x2aa532,_0x2cb0e0,_0x5d4893){return db[_0x5596('0x53')]['find']({'where':{'id':_0x2aa532[_0x5596('0x46')]['id']}})['then'](handleEntityNotFound(_0x2cb0e0,null))[_0x5596('0x27')](function(_0xc9d1b2){if(_0xc9d1b2){return _0xc9d1b2['addActions'](_0x2aa532['body']['ids'],_[_0x5596('0x4e')](_0x2aa532[_0x5596('0x49')],[_0x5596('0x54'),'id'])||{});}})['then'](respondWithResult(_0x2cb0e0,null))[_0x5596('0x44')](handleError(_0x2cb0e0,null));};exports[_0x5596('0x55')]=function(_0x403926,_0x53e62a,_0x10a0ee){var _0x1947cd={};var _0x3bbcb4={};var _0x43f43d;var _0x53ab27;return db[_0x5596('0x2d')][_0x5596('0x50')]({'where':{'id':_0x403926['params']['id']}})['then'](handleEntityNotFound(_0x53e62a,null))['then'](function(_0x5a3ff7){if(_0x5a3ff7){_0x43f43d=_0x5a3ff7;_0x3bbcb4['model']=_[_0x5596('0x33')](db['Action']['rawAttributes']);_0x3bbcb4[_0x5596('0x34')]=_['keys'](_0x403926[_0x5596('0x34')]);_0x3bbcb4[_0x5596('0x35')]=_['intersection'](_0x3bbcb4[_0x5596('0x32')],_0x3bbcb4[_0x5596('0x34')]);_0x1947cd[_0x5596('0x37')]=_[_0x5596('0x36')](_0x3bbcb4[_0x5596('0x32')],qs['fields'](_0x403926[_0x5596('0x34')][_0x5596('0x38')]));_0x1947cd[_0x5596('0x37')]=_0x1947cd[_0x5596('0x37')][_0x5596('0x47')]?_0x1947cd[_0x5596('0x37')]:_0x3bbcb4[_0x5596('0x32')];_0x1947cd[_0x5596('0x3a')]=qs[_0x5596('0x51')](_0x403926[_0x5596('0x34')][_0x5596('0x51')]);_0x1947cd[_0x5596('0x3b')]=qs['filters'](_[_0x5596('0x3c')](_0x403926['query'],_0x3bbcb4['filters']));if(_0x403926['query'][_0x5596('0x3d')]){_0x1947cd['where']=_[_0x5596('0x3e')](_0x1947cd['where'],{'$or':_[_0x5596('0x2c')](_0x1947cd['attributes'],function(_0x154f3b){var _0x2ae98e={};_0x2ae98e[_0x154f3b]={'$like':'%'+_0x403926['query'][_0x5596('0x3d')]+'%'};return _0x2ae98e;})});}_0x1947cd=_[_0x5596('0x3e')]({},_0x1947cd,_0x403926[_0x5596('0x56')]);return _0x43f43d['getActions'](_0x1947cd);}})['then'](function(_0x286794){if(_0x286794){_0x53ab27=_0x286794[_0x5596('0x47')];if(!_0x403926[_0x5596('0x34')][_0x5596('0x52')](_0x5596('0x39'))){_0x1947cd[_0x5596('0x21')]=qs[_0x5596('0x21')](_0x403926[_0x5596('0x34')][_0x5596('0x21')]);_0x1947cd[_0x5596('0x1f')]=qs[_0x5596('0x1f')](_0x403926[_0x5596('0x34')][_0x5596('0x1f')]);}return _0x43f43d['getActions'](_0x1947cd);}})[_0x5596('0x27')](function(_0x2c220a){if(_0x2c220a){return _0x2c220a?{'count':_0x53ab27,'rows':_0x2c220a}:null;}})[_0x5596('0x27')](respondWithResult(_0x53e62a,null))[_0x5596('0x44')](handleError(_0x53e62a,null));};
\ No newline at end of file
+var _0xfa1d=['then','destroy','error','stack','name','index','Automation','rawAttributes','fieldName','type','model','query','keys','filters','intersection','attributes','fields','hasOwnProperty','order','sort','where','pick','filter','merge','map','VIRTUAL','includeAll','include','findAll','catch','show','params','length','options','create','body','update','find','addConditions','Condition','ids','getConditions','nolimit','addActions','getActions','findOne','Action','eml-format','zip-dir','fast-json-patch','request-promise','bluebird','mustache','util','path','sox','to-csv','lodash','squel','crypto','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','sendStatus','end','count','offset','limit','status','set','Content-Range','apply'];(function(_0x151334,_0x1e11ac){var _0x3d03da=function(_0x2099cf){while(--_0x2099cf){_0x151334['push'](_0x151334['shift']());}};_0x3d03da(++_0x1e11ac);}(_0xfa1d,0x122));var _0xdfa1=function(_0x86a8fa,_0x323e96){_0x86a8fa=_0x86a8fa-0x0;var _0x551384=_0xfa1d[_0x86a8fa];return _0x551384;};'use strict';var emlformat=require(_0xdfa1('0x0'));var rimraf=require('rimraf');var zipdir=require(_0xdfa1('0x1'));var jsonpatch=require(_0xdfa1('0x2'));var rp=require(_0xdfa1('0x3'));var moment=require('moment');var BPromise=require(_0xdfa1('0x4'));var Mustache=require(_0xdfa1('0x5'));var util=require(_0xdfa1('0x6'));var path=require(_0xdfa1('0x7'));var sox=require(_0xdfa1('0x8'));var csv=require(_0xdfa1('0x9'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0xdfa1('0xa'));var squel=require(_0xdfa1('0xb'));var crypto=require(_0xdfa1('0xc'));var jsforce=require('jsforce');var deskjs=require(_0xdfa1('0xd'));var toCsv=require('to-csv');var querystring=require(_0xdfa1('0xe'));var Papa=require(_0xdfa1('0xf'));var Redis=require(_0xdfa1('0x10'));var authService=require(_0xdfa1('0x11'));var qs=require(_0xdfa1('0x12'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require('../../config/license/hardware');var logger=require(_0xdfa1('0x13'))(_0xdfa1('0x14'));var utils=require(_0xdfa1('0x15'));var config=require(_0xdfa1('0x16'));var licenseUtil=require(_0xdfa1('0x17'));var db=require(_0xdfa1('0x18'))['db'];function respondWithStatusCode(_0x1f9b72,_0x158753){_0x158753=_0x158753||0xcc;return function(_0x551061){if(_0x551061){return _0x1f9b72[_0xdfa1('0x19')](_0x158753);}return _0x1f9b72['status'](_0x158753)[_0xdfa1('0x1a')]();};}function respondWithResult(_0x222a8e,_0x3fa2a4){_0x3fa2a4=_0x3fa2a4||0xc8;return function(_0x1c5b9b){if(_0x1c5b9b){return _0x222a8e['status'](_0x3fa2a4)['json'](_0x1c5b9b);}};}function respondWithFilteredResult(_0xe15d51,_0x566832){return function(_0x1bb0bf){if(_0x1bb0bf){var _0x3ffb95=typeof _0x566832['offset']==='undefined'&&typeof _0x566832['limit']==='undefined';var _0x18a215=_0x1bb0bf[_0xdfa1('0x1b')];var _0x6b247e=_0x3ffb95?0x0:_0x566832[_0xdfa1('0x1c')];var _0x4f3e79=_0x3ffb95?_0x1bb0bf[_0xdfa1('0x1b')]:_0x566832[_0xdfa1('0x1c')]+_0x566832[_0xdfa1('0x1d')];var _0x43cb83;if(_0x4f3e79>=_0x18a215){_0x4f3e79=_0x18a215;_0x43cb83=0xc8;}else{_0x43cb83=0xce;}_0xe15d51[_0xdfa1('0x1e')](_0x43cb83);return _0xe15d51[_0xdfa1('0x1f')](_0xdfa1('0x20'),_0x6b247e+'-'+_0x4f3e79+'/'+_0x18a215)['json'](_0x1bb0bf);}return null;};}function patchUpdates(_0x1e74bb){return function(_0x129442){try{jsonpatch[_0xdfa1('0x21')](_0x129442,_0x1e74bb,!![]);}catch(_0x529127){return BPromise['reject'](_0x529127);}return _0x129442['save']();};}function saveUpdates(_0x33bb03,_0x2222b2){return function(_0x360963){if(_0x360963){return _0x360963['update'](_0x33bb03)[_0xdfa1('0x22')](function(_0x17e277){return _0x17e277;});}return null;};}function removeEntity(_0x502978,_0x2be531){return function(_0x1aed59){if(_0x1aed59){return _0x1aed59[_0xdfa1('0x23')]()[_0xdfa1('0x22')](function(){_0x502978[_0xdfa1('0x1e')](0xcc)[_0xdfa1('0x1a')]();});}};}function handleEntityNotFound(_0x19d675,_0x30c423){return function(_0x15fc86){if(!_0x15fc86){_0x19d675[_0xdfa1('0x19')](0x194);}return _0x15fc86;};}function handleError(_0xc0ba58,_0x4951f6){_0x4951f6=_0x4951f6||0x1f4;return function(_0x461168){logger[_0xdfa1('0x24')](_0x461168[_0xdfa1('0x25')]);if(_0x461168[_0xdfa1('0x26')]){delete _0x461168['name'];}_0xc0ba58[_0xdfa1('0x1e')](_0x4951f6)['send'](_0x461168);};}exports[_0xdfa1('0x27')]=function(_0x1c6740,_0x52e0e3){var _0x3bcdac={},_0x23573a={},_0x3480d6={'count':0x0,'rows':[]};var _0x59eab2=_['map'](db[_0xdfa1('0x28')][_0xdfa1('0x29')],function(_0x357b7d){return{'name':_0x357b7d[_0xdfa1('0x2a')],'type':_0x357b7d[_0xdfa1('0x2b')]['key']};});_0x23573a[_0xdfa1('0x2c')]=_['map'](_0x59eab2,_0xdfa1('0x26'));_0x23573a[_0xdfa1('0x2d')]=_[_0xdfa1('0x2e')](_0x1c6740[_0xdfa1('0x2d')]);_0x23573a[_0xdfa1('0x2f')]=_[_0xdfa1('0x30')](_0x23573a['model'],_0x23573a['query']);_0x3bcdac[_0xdfa1('0x31')]=_[_0xdfa1('0x30')](_0x23573a[_0xdfa1('0x2c')],qs[_0xdfa1('0x32')](_0x1c6740[_0xdfa1('0x2d')]['fields']));_0x3bcdac[_0xdfa1('0x31')]=_0x3bcdac[_0xdfa1('0x31')]['length']?_0x3bcdac['attributes']:_0x23573a[_0xdfa1('0x2c')];if(!_0x1c6740[_0xdfa1('0x2d')][_0xdfa1('0x33')]('nolimit')){_0x3bcdac[_0xdfa1('0x1d')]=qs['limit'](_0x1c6740[_0xdfa1('0x2d')][_0xdfa1('0x1d')]);_0x3bcdac[_0xdfa1('0x1c')]=qs[_0xdfa1('0x1c')](_0x1c6740['query']['offset']);}_0x3bcdac[_0xdfa1('0x34')]=qs[_0xdfa1('0x35')](_0x1c6740[_0xdfa1('0x2d')][_0xdfa1('0x35')]);_0x3bcdac[_0xdfa1('0x36')]=qs[_0xdfa1('0x2f')](_[_0xdfa1('0x37')](_0x1c6740[_0xdfa1('0x2d')],_0x23573a['filters']),_0x59eab2);if(_0x1c6740[_0xdfa1('0x2d')][_0xdfa1('0x38')]){_0x3bcdac[_0xdfa1('0x36')]=_[_0xdfa1('0x39')](_0x3bcdac['where'],{'$or':_[_0xdfa1('0x3a')](_0x59eab2,function(_0x333253){if(_0x333253[_0xdfa1('0x2b')]!==_0xdfa1('0x3b')){var _0x103a43={};_0x103a43[_0x333253['name']]={'$like':'%'+_0x1c6740[_0xdfa1('0x2d')][_0xdfa1('0x38')]+'%'};return _0x103a43;}})});}_0x3bcdac=_[_0xdfa1('0x39')]({},_0x3bcdac,_0x1c6740['options']);var _0x437dd5={'where':_0x3bcdac['where']};return db['Automation'][_0xdfa1('0x1b')](_0x437dd5)['then'](function(_0x3155b0){_0x3480d6['count']=_0x3155b0;if(_0x1c6740[_0xdfa1('0x2d')][_0xdfa1('0x3c')]){_0x3bcdac[_0xdfa1('0x3d')]=[{'all':!![]}];}return db[_0xdfa1('0x28')][_0xdfa1('0x3e')](_0x3bcdac);})[_0xdfa1('0x22')](function(_0x3dc0f8){_0x3480d6['rows']=_0x3dc0f8;return _0x3480d6;})[_0xdfa1('0x22')](respondWithFilteredResult(_0x52e0e3,_0x3bcdac))[_0xdfa1('0x3f')](handleError(_0x52e0e3,null));};exports[_0xdfa1('0x40')]=function(_0x26f89a,_0x347641){var _0x4c397a={'raw':![],'where':{'id':_0x26f89a[_0xdfa1('0x41')]['id']}},_0x3e1c3e={};_0x3e1c3e[_0xdfa1('0x2c')]=_[_0xdfa1('0x2e')](db[_0xdfa1('0x28')][_0xdfa1('0x29')]);_0x3e1c3e[_0xdfa1('0x2d')]=_[_0xdfa1('0x2e')](_0x26f89a[_0xdfa1('0x2d')]);_0x3e1c3e['filters']=_['intersection'](_0x3e1c3e[_0xdfa1('0x2c')],_0x3e1c3e['query']);_0x4c397a[_0xdfa1('0x31')]=_[_0xdfa1('0x30')](_0x3e1c3e[_0xdfa1('0x2c')],qs['fields'](_0x26f89a[_0xdfa1('0x2d')]['fields']));_0x4c397a[_0xdfa1('0x31')]=_0x4c397a['attributes'][_0xdfa1('0x42')]?_0x4c397a[_0xdfa1('0x31')]:_0x3e1c3e[_0xdfa1('0x2c')];if(_0x26f89a['query']['includeAll']){_0x4c397a[_0xdfa1('0x3d')]=[{'all':!![]}];}_0x4c397a=_['merge']({},_0x4c397a,_0x26f89a[_0xdfa1('0x43')]);return db[_0xdfa1('0x28')]['find'](_0x4c397a)[_0xdfa1('0x22')](handleEntityNotFound(_0x347641,null))[_0xdfa1('0x22')](respondWithResult(_0x347641,null))[_0xdfa1('0x3f')](handleError(_0x347641,null));};exports['create']=function(_0x490b9c,_0x506596){return db[_0xdfa1('0x28')][_0xdfa1('0x44')](_0x490b9c[_0xdfa1('0x45')],{})[_0xdfa1('0x22')](respondWithResult(_0x506596,0xc9))['catch'](handleError(_0x506596,null));};exports[_0xdfa1('0x46')]=function(_0x3686f6,_0x4cef1c){if(_0x3686f6[_0xdfa1('0x45')]['id']){delete _0x3686f6['body']['id'];}return db[_0xdfa1('0x28')][_0xdfa1('0x47')]({'where':{'id':_0x3686f6[_0xdfa1('0x41')]['id']}})[_0xdfa1('0x22')](handleEntityNotFound(_0x4cef1c,null))['then'](saveUpdates(_0x3686f6['body'],null))[_0xdfa1('0x22')](respondWithResult(_0x4cef1c,null))[_0xdfa1('0x3f')](handleError(_0x4cef1c,null));};exports['destroy']=function(_0x201f7e,_0x220798){return db[_0xdfa1('0x28')]['find']({'where':{'id':_0x201f7e[_0xdfa1('0x41')]['id']}})[_0xdfa1('0x22')](handleEntityNotFound(_0x220798,null))[_0xdfa1('0x22')](removeEntity(_0x220798,null))[_0xdfa1('0x3f')](handleError(_0x220798,null));};exports[_0xdfa1('0x48')]=function(_0x341e23,_0x4373e9,_0x45ae8e){return db[_0xdfa1('0x49')]['find']({'where':{'id':_0x341e23[_0xdfa1('0x41')]['id']}})['then'](handleEntityNotFound(_0x4373e9,null))['then'](function(_0x1662c4){if(_0x1662c4){return _0x1662c4[_0xdfa1('0x48')](_0x341e23[_0xdfa1('0x45')][_0xdfa1('0x4a')],_['omit'](_0x341e23[_0xdfa1('0x45')],[_0xdfa1('0x4a'),'id'])||{});}})[_0xdfa1('0x22')](respondWithResult(_0x4373e9,null))[_0xdfa1('0x3f')](handleError(_0x4373e9,null));};exports[_0xdfa1('0x4b')]=function(_0x221486,_0x4b9140,_0x1ea84f){var _0x588fb6={};var _0x51171f={};var _0x4d17b5;var _0x955af0;return db[_0xdfa1('0x28')]['findOne']({'where':{'id':_0x221486['params']['id']}})[_0xdfa1('0x22')](handleEntityNotFound(_0x4b9140,null))[_0xdfa1('0x22')](function(_0x4c67d2){if(_0x4c67d2){_0x4d17b5=_0x4c67d2;_0x51171f[_0xdfa1('0x2c')]=_[_0xdfa1('0x2e')](db[_0xdfa1('0x49')]['rawAttributes']);_0x51171f[_0xdfa1('0x2d')]=_['keys'](_0x221486[_0xdfa1('0x2d')]);_0x51171f[_0xdfa1('0x2f')]=_['intersection'](_0x51171f['model'],_0x51171f[_0xdfa1('0x2d')]);_0x588fb6[_0xdfa1('0x31')]=_[_0xdfa1('0x30')](_0x51171f[_0xdfa1('0x2c')],qs['fields'](_0x221486['query'][_0xdfa1('0x32')]));_0x588fb6[_0xdfa1('0x31')]=_0x588fb6[_0xdfa1('0x31')][_0xdfa1('0x42')]?_0x588fb6[_0xdfa1('0x31')]:_0x51171f[_0xdfa1('0x2c')];_0x588fb6[_0xdfa1('0x34')]=qs[_0xdfa1('0x35')](_0x221486[_0xdfa1('0x2d')][_0xdfa1('0x35')]);_0x588fb6[_0xdfa1('0x36')]=qs[_0xdfa1('0x2f')](_[_0xdfa1('0x37')](_0x221486[_0xdfa1('0x2d')],_0x51171f[_0xdfa1('0x2f')]));if(_0x221486['query']['filter']){_0x588fb6[_0xdfa1('0x36')]=_[_0xdfa1('0x39')](_0x588fb6[_0xdfa1('0x36')],{'$or':_['map'](_0x588fb6[_0xdfa1('0x31')],function(_0x397f47){var _0x1fda6c={};_0x1fda6c[_0x397f47]={'$like':'%'+_0x221486['query']['filter']+'%'};return _0x1fda6c;})});}_0x588fb6=_[_0xdfa1('0x39')]({},_0x588fb6,_0x221486['options']);return _0x4d17b5[_0xdfa1('0x4b')](_0x588fb6);}})['then'](function(_0x4ea686){if(_0x4ea686){_0x955af0=_0x4ea686[_0xdfa1('0x42')];if(!_0x221486[_0xdfa1('0x2d')][_0xdfa1('0x33')](_0xdfa1('0x4c'))){_0x588fb6[_0xdfa1('0x1d')]=qs[_0xdfa1('0x1d')](_0x221486[_0xdfa1('0x2d')][_0xdfa1('0x1d')]);_0x588fb6[_0xdfa1('0x1c')]=qs[_0xdfa1('0x1c')](_0x221486[_0xdfa1('0x2d')]['offset']);}return _0x4d17b5[_0xdfa1('0x4b')](_0x588fb6);}})[_0xdfa1('0x22')](function(_0x3be95a){if(_0x3be95a){return _0x3be95a?{'count':_0x955af0,'rows':_0x3be95a}:null;}})['then'](respondWithResult(_0x4b9140,null))[_0xdfa1('0x3f')](handleError(_0x4b9140,null));};exports[_0xdfa1('0x4d')]=function(_0x49f48d,_0xcd8b41,_0x46e67e){return db['Action'][_0xdfa1('0x47')]({'where':{'id':_0x49f48d[_0xdfa1('0x41')]['id']}})['then'](handleEntityNotFound(_0xcd8b41,null))[_0xdfa1('0x22')](function(_0x60a350){if(_0x60a350){return _0x60a350['addActions'](_0x49f48d[_0xdfa1('0x45')][_0xdfa1('0x4a')],_['omit'](_0x49f48d[_0xdfa1('0x45')],[_0xdfa1('0x4a'),'id'])||{});}})[_0xdfa1('0x22')](respondWithResult(_0xcd8b41,null))[_0xdfa1('0x3f')](handleError(_0xcd8b41,null));};exports[_0xdfa1('0x4e')]=function(_0x376390,_0x4017c4,_0x3a39d0){var _0x512874={};var _0x3d8c2f={};var _0x18a2a0;var _0x37a98f;return db['Automation'][_0xdfa1('0x4f')]({'where':{'id':_0x376390[_0xdfa1('0x41')]['id']}})['then'](handleEntityNotFound(_0x4017c4,null))[_0xdfa1('0x22')](function(_0x446392){if(_0x446392){_0x18a2a0=_0x446392;_0x3d8c2f[_0xdfa1('0x2c')]=_['keys'](db[_0xdfa1('0x50')]['rawAttributes']);_0x3d8c2f[_0xdfa1('0x2d')]=_[_0xdfa1('0x2e')](_0x376390[_0xdfa1('0x2d')]);_0x3d8c2f[_0xdfa1('0x2f')]=_['intersection'](_0x3d8c2f[_0xdfa1('0x2c')],_0x3d8c2f[_0xdfa1('0x2d')]);_0x512874[_0xdfa1('0x31')]=_[_0xdfa1('0x30')](_0x3d8c2f['model'],qs['fields'](_0x376390['query'][_0xdfa1('0x32')]));_0x512874[_0xdfa1('0x31')]=_0x512874['attributes'][_0xdfa1('0x42')]?_0x512874['attributes']:_0x3d8c2f[_0xdfa1('0x2c')];_0x512874[_0xdfa1('0x34')]=qs[_0xdfa1('0x35')](_0x376390[_0xdfa1('0x2d')][_0xdfa1('0x35')]);_0x512874[_0xdfa1('0x36')]=qs[_0xdfa1('0x2f')](_[_0xdfa1('0x37')](_0x376390['query'],_0x3d8c2f[_0xdfa1('0x2f')]));if(_0x376390[_0xdfa1('0x2d')]['filter']){_0x512874[_0xdfa1('0x36')]=_[_0xdfa1('0x39')](_0x512874[_0xdfa1('0x36')],{'$or':_[_0xdfa1('0x3a')](_0x512874[_0xdfa1('0x31')],function(_0x4722bb){var _0x518c2f={};_0x518c2f[_0x4722bb]={'$like':'%'+_0x376390['query']['filter']+'%'};return _0x518c2f;})});}_0x512874=_[_0xdfa1('0x39')]({},_0x512874,_0x376390['options']);return _0x18a2a0[_0xdfa1('0x4e')](_0x512874);}})[_0xdfa1('0x22')](function(_0x435663){if(_0x435663){_0x37a98f=_0x435663['length'];if(!_0x376390[_0xdfa1('0x2d')][_0xdfa1('0x33')](_0xdfa1('0x4c'))){_0x512874[_0xdfa1('0x1d')]=qs[_0xdfa1('0x1d')](_0x376390['query'][_0xdfa1('0x1d')]);_0x512874['offset']=qs['offset'](_0x376390[_0xdfa1('0x2d')][_0xdfa1('0x1c')]);}return _0x18a2a0[_0xdfa1('0x4e')](_0x512874);}})[_0xdfa1('0x22')](function(_0x58076f){if(_0x58076f){return _0x58076f?{'count':_0x37a98f,'rows':_0x58076f}:null;}})[_0xdfa1('0x22')](respondWithResult(_0x4017c4,null))['catch'](handleError(_0x4017c4,null));};
\ No newline at end of file