Built motion from commit e1760111.|2.6.18
[motion2.git] / server / api / automation / automation.controller.js
index 0dcbfcc..ed534d5 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x719f=['jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/advancedSearch','../../config/license/hardware','api','../../config/utils','../../config/environment','../../mysqldb','sendStatus','status','end','count','offset','set','Content-Range','json','apply','reject','update','then','destroy','error','name','send','index','Automation','rawAttributes','fieldName','type','key','model','query','keys','intersection','attributes','fields','length','hasOwnProperty','nolimit','limit','order','sort','where','filters','filter','merge','map','VIRTUAL','options','includeAll','include','rows','catch','show','find','create','body','params','addConditions','omit','getConditions','findOne','Condition','pick','addActions','ids','getActions','html-pdf','rimraf','zip-dir','request-promise','moment','bluebird','mustache','util','path','sox','to-csv','ejs','lodash'];(function(_0x206a08,_0x524918){var _0x34cd48=function(_0x5ddb1c){while(--_0x5ddb1c){_0x206a08['push'](_0x206a08['shift']());}};_0x34cd48(++_0x524918);}(_0x719f,0x1eb));var _0xf719=function(_0xa1e3ca,_0x559022){_0xa1e3ca=_0xa1e3ca-0x0;var _0x5005ab=_0x719f[_0xa1e3ca];return _0x5005ab;};'use strict';var pdf=require(_0xf719('0x0'));var emlformat=require('eml-format');var rimraf=require(_0xf719('0x1'));var zipdir=require(_0xf719('0x2'));var jsonpatch=require('fast-json-patch');var rp=require(_0xf719('0x3'));var moment=require(_0xf719('0x4'));var BPromise=require(_0xf719('0x5'));var Mustache=require(_0xf719('0x6'));var util=require(_0xf719('0x7'));var path=require(_0xf719('0x8'));var sox=require(_0xf719('0x9'));var csv=require(_0xf719('0xa'));var ejs=require(_0xf719('0xb'));var fs=require('fs');var _=require(_0xf719('0xc'));var squel=require('squel');var crypto=require('crypto');var jsforce=require(_0xf719('0xd'));var deskjs=require(_0xf719('0xe'));var toCsv=require('to-csv');var querystring=require(_0xf719('0xf'));var Papa=require(_0xf719('0x10'));var Redis=require(_0xf719('0x11'));var authService=require(_0xf719('0x12'));var qs=require('../../components/parsers/qs');var as=require(_0xf719('0x13'));var hardwareService=require(_0xf719('0x14'));var logger=require('../../config/logger')(_0xf719('0x15'));var utils=require(_0xf719('0x16'));var config=require(_0xf719('0x17'));var licenseUtil=require('../../config/license/util');var db=require(_0xf719('0x18'))['db'];function respondWithStatusCode(_0x843f88,_0x1901f8){_0x1901f8=_0x1901f8||0xcc;return function(_0x1c6245){if(_0x1c6245){return _0x843f88[_0xf719('0x19')](_0x1901f8);}return _0x843f88[_0xf719('0x1a')](_0x1901f8)[_0xf719('0x1b')]();};}function respondWithResult(_0x510acb,_0x3978bf){_0x3978bf=_0x3978bf||0xc8;return function(_0x1fc249){if(_0x1fc249){return _0x510acb[_0xf719('0x1a')](_0x3978bf)['json'](_0x1fc249);}};}function respondWithFilteredResult(_0x3269bb,_0x687314){return function(_0x1bbeae){if(_0x1bbeae){var _0x20ca96=_0x1bbeae[_0xf719('0x1c')],_0xf47819=_0x687314[_0xf719('0x1d')],_0x52cf95=_0x687314[_0xf719('0x1d')]+_0x687314['limit'],_0x2b5b37;if(_0x52cf95>=_0x20ca96){_0x52cf95=_0x20ca96;_0x2b5b37=0xc8;}else{_0x2b5b37=0xce;}_0x3269bb['status'](_0x2b5b37);return _0x3269bb[_0xf719('0x1e')](_0xf719('0x1f'),_0xf47819+'-'+_0x52cf95+'/'+_0x20ca96)[_0xf719('0x20')](_0x1bbeae);}return null;};}function patchUpdates(_0x537890){return function(_0x581e2e){try{jsonpatch[_0xf719('0x21')](_0x581e2e,_0x537890,!![]);}catch(_0xacefd2){return BPromise[_0xf719('0x22')](_0xacefd2);}return _0x581e2e['save']();};}function saveUpdates(_0x1d037f,_0x15e3f6){return function(_0x3149be){if(_0x3149be){return _0x3149be[_0xf719('0x23')](_0x1d037f)[_0xf719('0x24')](function(_0x19f932){return _0x19f932;});}return null;};}function removeEntity(_0x3ad718,_0x54d701){return function(_0xa6e0a2){if(_0xa6e0a2){return _0xa6e0a2[_0xf719('0x25')]()[_0xf719('0x24')](function(){_0x3ad718['status'](0xcc)[_0xf719('0x1b')]();});}};}function handleEntityNotFound(_0x3b8b52,_0xf672af){return function(_0x37dbdd){if(!_0x37dbdd){_0x3b8b52['sendStatus'](0x194);}return _0x37dbdd;};}function handleError(_0x3502cf,_0x401df9){_0x401df9=_0x401df9||0x1f4;return function(_0x25f732){logger[_0xf719('0x26')](_0x25f732['stack']);if(_0x25f732[_0xf719('0x27')]){delete _0x25f732['name'];}_0x3502cf[_0xf719('0x1a')](_0x401df9)[_0xf719('0x28')](_0x25f732);};}exports[_0xf719('0x29')]=function(_0x3f0134,_0x13e28e){var _0x276678={},_0x3a6f54={},_0x1176b4={'count':0x0,'rows':[]};var _0x504e95=_['map'](db[_0xf719('0x2a')][_0xf719('0x2b')],function(_0x1d0b90){return{'name':_0x1d0b90[_0xf719('0x2c')],'type':_0x1d0b90[_0xf719('0x2d')][_0xf719('0x2e')]};});_0x3a6f54[_0xf719('0x2f')]=_['map'](_0x504e95,'name');_0x3a6f54[_0xf719('0x30')]=_[_0xf719('0x31')](_0x3f0134[_0xf719('0x30')]);_0x3a6f54['filters']=_[_0xf719('0x32')](_0x3a6f54[_0xf719('0x2f')],_0x3a6f54['query']);_0x276678[_0xf719('0x33')]=_[_0xf719('0x32')](_0x3a6f54[_0xf719('0x2f')],qs[_0xf719('0x34')](_0x3f0134[_0xf719('0x30')][_0xf719('0x34')]));_0x276678['attributes']=_0x276678['attributes'][_0xf719('0x35')]?_0x276678[_0xf719('0x33')]:_0x3a6f54[_0xf719('0x2f')];if(!_0x3f0134[_0xf719('0x30')][_0xf719('0x36')](_0xf719('0x37'))){_0x276678['limit']=qs[_0xf719('0x38')](_0x3f0134['query'][_0xf719('0x38')]);_0x276678[_0xf719('0x1d')]=qs[_0xf719('0x1d')](_0x3f0134[_0xf719('0x30')][_0xf719('0x1d')]);}_0x276678[_0xf719('0x39')]=qs[_0xf719('0x3a')](_0x3f0134[_0xf719('0x30')][_0xf719('0x3a')]);_0x276678[_0xf719('0x3b')]=qs[_0xf719('0x3c')](_['pick'](_0x3f0134[_0xf719('0x30')],_0x3a6f54[_0xf719('0x3c')]),_0x504e95);if(_0x3f0134[_0xf719('0x30')][_0xf719('0x3d')]){_0x276678[_0xf719('0x3b')]=_[_0xf719('0x3e')](_0x276678[_0xf719('0x3b')],{'$or':_[_0xf719('0x3f')](_0x504e95,function(_0x3b4fcb){if(_0x3b4fcb[_0xf719('0x2d')]!==_0xf719('0x40')){var _0x2b9c94={};_0x2b9c94[_0x3b4fcb['name']]={'$like':'%'+_0x3f0134[_0xf719('0x30')][_0xf719('0x3d')]+'%'};return _0x2b9c94;}})});}_0x276678=_[_0xf719('0x3e')]({},_0x276678,_0x3f0134[_0xf719('0x41')]);var _0x51124b={'where':_0x276678[_0xf719('0x3b')]};return db[_0xf719('0x2a')]['count'](_0x51124b)[_0xf719('0x24')](function(_0x250fb4){_0x1176b4[_0xf719('0x1c')]=_0x250fb4;if(_0x3f0134['query'][_0xf719('0x42')]){_0x276678[_0xf719('0x43')]=[{'all':!![]}];}return db[_0xf719('0x2a')]['findAll'](_0x276678);})[_0xf719('0x24')](function(_0x4acd5f){_0x1176b4[_0xf719('0x44')]=_0x4acd5f;return _0x1176b4;})[_0xf719('0x24')](respondWithFilteredResult(_0x13e28e,_0x276678))[_0xf719('0x45')](handleError(_0x13e28e,null));};exports[_0xf719('0x46')]=function(_0x5c2c0b,_0x2c8b9d){var _0x1b9419={'raw':![],'where':{'id':_0x5c2c0b['params']['id']}},_0x4d72f4={};_0x4d72f4[_0xf719('0x2f')]=_[_0xf719('0x31')](db['Automation']['rawAttributes']);_0x4d72f4[_0xf719('0x30')]=_[_0xf719('0x31')](_0x5c2c0b[_0xf719('0x30')]);_0x4d72f4[_0xf719('0x3c')]=_[_0xf719('0x32')](_0x4d72f4['model'],_0x4d72f4[_0xf719('0x30')]);_0x1b9419[_0xf719('0x33')]=_[_0xf719('0x32')](_0x4d72f4[_0xf719('0x2f')],qs[_0xf719('0x34')](_0x5c2c0b[_0xf719('0x30')][_0xf719('0x34')]));_0x1b9419['attributes']=_0x1b9419[_0xf719('0x33')][_0xf719('0x35')]?_0x1b9419['attributes']:_0x4d72f4[_0xf719('0x2f')];if(_0x5c2c0b['query']['includeAll']){_0x1b9419[_0xf719('0x43')]=[{'all':!![]}];}_0x1b9419=_[_0xf719('0x3e')]({},_0x1b9419,_0x5c2c0b[_0xf719('0x41')]);return db['Automation'][_0xf719('0x47')](_0x1b9419)['then'](handleEntityNotFound(_0x2c8b9d,null))[_0xf719('0x24')](respondWithResult(_0x2c8b9d,null))[_0xf719('0x45')](handleError(_0x2c8b9d,null));};exports[_0xf719('0x48')]=function(_0xc6489d,_0x190395){return db[_0xf719('0x2a')]['create'](_0xc6489d['body'],{})[_0xf719('0x24')](respondWithResult(_0x190395,0xc9))[_0xf719('0x45')](handleError(_0x190395,null));};exports[_0xf719('0x23')]=function(_0x14c869,_0x2f01e5){if(_0x14c869[_0xf719('0x49')]['id']){delete _0x14c869['body']['id'];}return db['Automation']['find']({'where':{'id':_0x14c869[_0xf719('0x4a')]['id']}})['then'](handleEntityNotFound(_0x2f01e5,null))[_0xf719('0x24')](saveUpdates(_0x14c869[_0xf719('0x49')],null))[_0xf719('0x24')](respondWithResult(_0x2f01e5,null))['catch'](handleError(_0x2f01e5,null));};exports[_0xf719('0x25')]=function(_0x20165f,_0x175239){return db[_0xf719('0x2a')]['find']({'where':{'id':_0x20165f['params']['id']}})['then'](handleEntityNotFound(_0x175239,null))[_0xf719('0x24')](removeEntity(_0x175239,null))[_0xf719('0x45')](handleError(_0x175239,null));};exports[_0xf719('0x4b')]=function(_0x4c3f72,_0x15131c,_0x4deadd){return db['Condition'][_0xf719('0x47')]({'where':{'id':_0x4c3f72['params']['id']}})[_0xf719('0x24')](handleEntityNotFound(_0x15131c,null))['then'](function(_0x22d9f1){if(_0x22d9f1){return _0x22d9f1[_0xf719('0x4b')](_0x4c3f72[_0xf719('0x49')]['ids'],_[_0xf719('0x4c')](_0x4c3f72[_0xf719('0x49')],['ids','id'])||{});}})[_0xf719('0x24')](respondWithResult(_0x15131c,null))[_0xf719('0x45')](handleError(_0x15131c,null));};exports[_0xf719('0x4d')]=function(_0x5d077b,_0x1fbc39,_0x1eb788){var _0x5b9091={};var _0x2a0c9d={};var _0x4a4d8d;var _0x798883;return db[_0xf719('0x2a')][_0xf719('0x4e')]({'where':{'id':_0x5d077b['params']['id']}})['then'](handleEntityNotFound(_0x1fbc39,null))[_0xf719('0x24')](function(_0x42155d){if(_0x42155d){_0x4a4d8d=_0x42155d;_0x2a0c9d[_0xf719('0x2f')]=_['keys'](db[_0xf719('0x4f')][_0xf719('0x2b')]);_0x2a0c9d['query']=_[_0xf719('0x31')](_0x5d077b[_0xf719('0x30')]);_0x2a0c9d[_0xf719('0x3c')]=_[_0xf719('0x32')](_0x2a0c9d['model'],_0x2a0c9d[_0xf719('0x30')]);_0x5b9091[_0xf719('0x33')]=_[_0xf719('0x32')](_0x2a0c9d['model'],qs['fields'](_0x5d077b['query'][_0xf719('0x34')]));_0x5b9091['attributes']=_0x5b9091[_0xf719('0x33')][_0xf719('0x35')]?_0x5b9091['attributes']:_0x2a0c9d['model'];_0x5b9091['order']=qs['sort'](_0x5d077b[_0xf719('0x30')][_0xf719('0x3a')]);_0x5b9091['where']=qs[_0xf719('0x3c')](_[_0xf719('0x50')](_0x5d077b[_0xf719('0x30')],_0x2a0c9d[_0xf719('0x3c')]));if(_0x5d077b[_0xf719('0x30')][_0xf719('0x3d')]){_0x5b9091[_0xf719('0x3b')]=_[_0xf719('0x3e')](_0x5b9091[_0xf719('0x3b')],{'$or':_[_0xf719('0x3f')](_0x5b9091['attributes'],function(_0x39a1b8){var _0x401689={};_0x401689[_0x39a1b8]={'$like':'%'+_0x5d077b[_0xf719('0x30')]['filter']+'%'};return _0x401689;})});}_0x5b9091=_[_0xf719('0x3e')]({},_0x5b9091,_0x5d077b[_0xf719('0x41')]);return _0x4a4d8d[_0xf719('0x4d')](_0x5b9091);}})[_0xf719('0x24')](function(_0x3e563f){if(_0x3e563f){_0x798883=_0x3e563f[_0xf719('0x35')];if(!_0x5d077b['query']['hasOwnProperty']('nolimit')){_0x5b9091[_0xf719('0x38')]=qs[_0xf719('0x38')](_0x5d077b['query'][_0xf719('0x38')]);_0x5b9091[_0xf719('0x1d')]=qs['offset'](_0x5d077b['query']['offset']);}return _0x4a4d8d['getConditions'](_0x5b9091);}})['then'](function(_0x501872){if(_0x501872){return _0x501872?{'count':_0x798883,'rows':_0x501872}:null;}})[_0xf719('0x24')](respondWithResult(_0x1fbc39,null))[_0xf719('0x45')](handleError(_0x1fbc39,null));};exports[_0xf719('0x51')]=function(_0x461529,_0x3419bd,_0x162305){return db['Action']['find']({'where':{'id':_0x461529['params']['id']}})[_0xf719('0x24')](handleEntityNotFound(_0x3419bd,null))[_0xf719('0x24')](function(_0x1a938b){if(_0x1a938b){return _0x1a938b[_0xf719('0x51')](_0x461529[_0xf719('0x49')][_0xf719('0x52')],_[_0xf719('0x4c')](_0x461529['body'],[_0xf719('0x52'),'id'])||{});}})[_0xf719('0x24')](respondWithResult(_0x3419bd,null))['catch'](handleError(_0x3419bd,null));};exports[_0xf719('0x53')]=function(_0x3f523d,_0x4d7dd8,_0x23b6d8){var _0x29dbf1={};var _0x27a688={};var _0x538a41;var _0x2d64cb;return db[_0xf719('0x2a')][_0xf719('0x4e')]({'where':{'id':_0x3f523d[_0xf719('0x4a')]['id']}})[_0xf719('0x24')](handleEntityNotFound(_0x4d7dd8,null))[_0xf719('0x24')](function(_0xa78b8e){if(_0xa78b8e){_0x538a41=_0xa78b8e;_0x27a688[_0xf719('0x2f')]=_[_0xf719('0x31')](db['Action']['rawAttributes']);_0x27a688[_0xf719('0x30')]=_[_0xf719('0x31')](_0x3f523d[_0xf719('0x30')]);_0x27a688[_0xf719('0x3c')]=_[_0xf719('0x32')](_0x27a688[_0xf719('0x2f')],_0x27a688['query']);_0x29dbf1['attributes']=_[_0xf719('0x32')](_0x27a688['model'],qs[_0xf719('0x34')](_0x3f523d[_0xf719('0x30')][_0xf719('0x34')]));_0x29dbf1[_0xf719('0x33')]=_0x29dbf1[_0xf719('0x33')]['length']?_0x29dbf1[_0xf719('0x33')]:_0x27a688[_0xf719('0x2f')];_0x29dbf1[_0xf719('0x39')]=qs[_0xf719('0x3a')](_0x3f523d[_0xf719('0x30')][_0xf719('0x3a')]);_0x29dbf1['where']=qs[_0xf719('0x3c')](_['pick'](_0x3f523d['query'],_0x27a688[_0xf719('0x3c')]));if(_0x3f523d['query'][_0xf719('0x3d')]){_0x29dbf1['where']=_[_0xf719('0x3e')](_0x29dbf1[_0xf719('0x3b')],{'$or':_[_0xf719('0x3f')](_0x29dbf1[_0xf719('0x33')],function(_0x299828){var _0x2a8689={};_0x2a8689[_0x299828]={'$like':'%'+_0x3f523d['query']['filter']+'%'};return _0x2a8689;})});}_0x29dbf1=_['merge']({},_0x29dbf1,_0x3f523d[_0xf719('0x41')]);return _0x538a41['getActions'](_0x29dbf1);}})[_0xf719('0x24')](function(_0x48df97){if(_0x48df97){_0x2d64cb=_0x48df97[_0xf719('0x35')];if(!_0x3f523d[_0xf719('0x30')]['hasOwnProperty']('nolimit')){_0x29dbf1[_0xf719('0x38')]=qs['limit'](_0x3f523d[_0xf719('0x30')][_0xf719('0x38')]);_0x29dbf1[_0xf719('0x1d')]=qs['offset'](_0x3f523d['query']['offset']);}return _0x538a41[_0xf719('0x53')](_0x29dbf1);}})['then'](function(_0x482ab5){if(_0x482ab5){return _0x482ab5?{'count':_0x2d64cb,'rows':_0x482ab5}:null;}})[_0xf719('0x24')](respondWithResult(_0x4d7dd8,null))['catch'](handleError(_0x4d7dd8,null));};
\ No newline at end of file
+var _0x7431=['then','destroy','error','stack','name','index','map','Automation','rawAttributes','key','model','query','intersection','fields','attributes','length','nolimit','sort','where','pick','filter','type','VIRTUAL','merge','options','include','findAll','rows','catch','show','filters','find','create','body','params','Condition','ids','omit','findOne','keys','order','getConditions','Action','addActions','getActions','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','to-csv','fs-extra','squel','crypto','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/environment','../../mysqldb','sendStatus','end','status','json','offset','limit','undefined','count','set','apply','save','update'];(function(_0x32023d,_0x281593){var _0xb4a7b4=function(_0x206ffc){while(--_0x206ffc){_0x32023d['push'](_0x32023d['shift']());}};_0xb4a7b4(++_0x281593);}(_0x7431,0x1c2));var _0x1743=function(_0x5e75ef,_0x4ce765){_0x5e75ef=_0x5e75ef-0x0;var _0x3c28b2=_0x7431[_0x5e75ef];return _0x3c28b2;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0x1743('0x0'));var zipdir=require(_0x1743('0x1'));var jsonpatch=require(_0x1743('0x2'));var rp=require(_0x1743('0x3'));var moment=require(_0x1743('0x4'));var BPromise=require(_0x1743('0x5'));var Mustache=require(_0x1743('0x6'));var util=require(_0x1743('0x7'));var path=require(_0x1743('0x8'));var sox=require('sox');var csv=require(_0x1743('0x9'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0x1743('0xa'));var _=require('lodash');var squel=require(_0x1743('0xb'));var crypto=require(_0x1743('0xc'));var jsforce=require('jsforce');var deskjs=require('desk.js');var toCsv=require(_0x1743('0x9'));var querystring=require(_0x1743('0xd'));var Papa=require(_0x1743('0xe'));var Redis=require(_0x1743('0xf'));var authService=require(_0x1743('0x10'));var qs=require(_0x1743('0x11'));var as=require(_0x1743('0x12'));var hardwareService=require(_0x1743('0x13'));var logger=require(_0x1743('0x14'))(_0x1743('0x15'));var utils=require('../../config/utils');var config=require(_0x1743('0x16'));var licenseUtil=require('../../config/license/util');var db=require(_0x1743('0x17'))['db'];function respondWithStatusCode(_0x22127f,_0x3c2958){_0x3c2958=_0x3c2958||0xcc;return function(_0x21584a){if(_0x21584a){return _0x22127f[_0x1743('0x18')](_0x3c2958);}return _0x22127f['status'](_0x3c2958)[_0x1743('0x19')]();};}function respondWithResult(_0x1d85e8,_0x580c85){_0x580c85=_0x580c85||0xc8;return function(_0x31da7b){if(_0x31da7b){return _0x1d85e8[_0x1743('0x1a')](_0x580c85)[_0x1743('0x1b')](_0x31da7b);}};}function respondWithFilteredResult(_0x43a425,_0x5313e1){return function(_0x456d61){if(_0x456d61){var _0x579ad9=typeof _0x5313e1[_0x1743('0x1c')]==='undefined'&&typeof _0x5313e1[_0x1743('0x1d')]===_0x1743('0x1e');var _0x5dbef1=_0x456d61['count'];var _0x33397e=_0x579ad9?0x0:_0x5313e1[_0x1743('0x1c')];var _0x19915e=_0x579ad9?_0x456d61[_0x1743('0x1f')]:_0x5313e1['offset']+_0x5313e1[_0x1743('0x1d')];var _0x220014;if(_0x19915e>=_0x5dbef1){_0x19915e=_0x5dbef1;_0x220014=0xc8;}else{_0x220014=0xce;}_0x43a425[_0x1743('0x1a')](_0x220014);return _0x43a425[_0x1743('0x20')]('Content-Range',_0x33397e+'-'+_0x19915e+'/'+_0x5dbef1)[_0x1743('0x1b')](_0x456d61);}return null;};}function patchUpdates(_0x298b0b){return function(_0x4d94c7){try{jsonpatch[_0x1743('0x21')](_0x4d94c7,_0x298b0b,!![]);}catch(_0x6bb972){return BPromise['reject'](_0x6bb972);}return _0x4d94c7[_0x1743('0x22')]();};}function saveUpdates(_0x1b5a93,_0x390152){return function(_0x439618){if(_0x439618){return _0x439618[_0x1743('0x23')](_0x1b5a93)[_0x1743('0x24')](function(_0x40e29b){return _0x40e29b;});}return null;};}function removeEntity(_0x5dc1a7,_0x1d0d8b){return function(_0x1f5d79){if(_0x1f5d79){return _0x1f5d79[_0x1743('0x25')]()[_0x1743('0x24')](function(){_0x5dc1a7[_0x1743('0x1a')](0xcc)[_0x1743('0x19')]();});}};}function handleEntityNotFound(_0x372b09,_0x117d47){return function(_0x50a9fe){if(!_0x50a9fe){_0x372b09['sendStatus'](0x194);}return _0x50a9fe;};}function handleError(_0x5a2cd1,_0x541add){_0x541add=_0x541add||0x1f4;return function(_0x53689c){logger[_0x1743('0x26')](_0x53689c[_0x1743('0x27')]);if(_0x53689c[_0x1743('0x28')]){delete _0x53689c[_0x1743('0x28')];}_0x5a2cd1[_0x1743('0x1a')](_0x541add)['send'](_0x53689c);};}exports[_0x1743('0x29')]=function(_0x5ab610,_0x4a3412){var _0x4c6ecb={},_0x5c4581={},_0x7fd8e0={'count':0x0,'rows':[]};var _0x3e4401=_[_0x1743('0x2a')](db[_0x1743('0x2b')][_0x1743('0x2c')],function(_0x53c998){return{'name':_0x53c998['fieldName'],'type':_0x53c998['type'][_0x1743('0x2d')]};});_0x5c4581[_0x1743('0x2e')]=_[_0x1743('0x2a')](_0x3e4401,_0x1743('0x28'));_0x5c4581['query']=_['keys'](_0x5ab610['query']);_0x5c4581['filters']=_['intersection'](_0x5c4581['model'],_0x5c4581[_0x1743('0x2f')]);_0x4c6ecb['attributes']=_[_0x1743('0x30')](_0x5c4581[_0x1743('0x2e')],qs[_0x1743('0x31')](_0x5ab610[_0x1743('0x2f')]['fields']));_0x4c6ecb[_0x1743('0x32')]=_0x4c6ecb['attributes'][_0x1743('0x33')]?_0x4c6ecb[_0x1743('0x32')]:_0x5c4581[_0x1743('0x2e')];if(!_0x5ab610['query']['hasOwnProperty'](_0x1743('0x34'))){_0x4c6ecb['limit']=qs[_0x1743('0x1d')](_0x5ab610[_0x1743('0x2f')][_0x1743('0x1d')]);_0x4c6ecb['offset']=qs[_0x1743('0x1c')](_0x5ab610[_0x1743('0x2f')]['offset']);}_0x4c6ecb['order']=qs[_0x1743('0x35')](_0x5ab610[_0x1743('0x2f')][_0x1743('0x35')]);_0x4c6ecb[_0x1743('0x36')]=qs['filters'](_[_0x1743('0x37')](_0x5ab610['query'],_0x5c4581['filters']),_0x3e4401);if(_0x5ab610['query'][_0x1743('0x38')]){_0x4c6ecb[_0x1743('0x36')]=_['merge'](_0x4c6ecb[_0x1743('0x36')],{'$or':_[_0x1743('0x2a')](_0x3e4401,function(_0x576e26){if(_0x576e26[_0x1743('0x39')]!==_0x1743('0x3a')){var _0x2914db={};_0x2914db[_0x576e26[_0x1743('0x28')]]={'$like':'%'+_0x5ab610[_0x1743('0x2f')][_0x1743('0x38')]+'%'};return _0x2914db;}})});}_0x4c6ecb=_[_0x1743('0x3b')]({},_0x4c6ecb,_0x5ab610[_0x1743('0x3c')]);var _0x415003={'where':_0x4c6ecb[_0x1743('0x36')]};return db[_0x1743('0x2b')][_0x1743('0x1f')](_0x415003)[_0x1743('0x24')](function(_0x3b1433){_0x7fd8e0[_0x1743('0x1f')]=_0x3b1433;if(_0x5ab610[_0x1743('0x2f')]['includeAll']){_0x4c6ecb[_0x1743('0x3d')]=[{'all':!![]}];}return db['Automation'][_0x1743('0x3e')](_0x4c6ecb);})['then'](function(_0x14ff93){_0x7fd8e0[_0x1743('0x3f')]=_0x14ff93;return _0x7fd8e0;})[_0x1743('0x24')](respondWithFilteredResult(_0x4a3412,_0x4c6ecb))[_0x1743('0x40')](handleError(_0x4a3412,null));};exports[_0x1743('0x41')]=function(_0x4f5ef5,_0x12b49c){var _0x2d8a18={'raw':![],'where':{'id':_0x4f5ef5['params']['id']}},_0x160fbe={};_0x160fbe[_0x1743('0x2e')]=_['keys'](db[_0x1743('0x2b')][_0x1743('0x2c')]);_0x160fbe[_0x1743('0x2f')]=_['keys'](_0x4f5ef5[_0x1743('0x2f')]);_0x160fbe[_0x1743('0x42')]=_['intersection'](_0x160fbe[_0x1743('0x2e')],_0x160fbe['query']);_0x2d8a18[_0x1743('0x32')]=_[_0x1743('0x30')](_0x160fbe['model'],qs[_0x1743('0x31')](_0x4f5ef5['query'][_0x1743('0x31')]));_0x2d8a18[_0x1743('0x32')]=_0x2d8a18['attributes'][_0x1743('0x33')]?_0x2d8a18[_0x1743('0x32')]:_0x160fbe[_0x1743('0x2e')];if(_0x4f5ef5[_0x1743('0x2f')]['includeAll']){_0x2d8a18[_0x1743('0x3d')]=[{'all':!![]}];}_0x2d8a18=_['merge']({},_0x2d8a18,_0x4f5ef5['options']);return db[_0x1743('0x2b')][_0x1743('0x43')](_0x2d8a18)[_0x1743('0x24')](handleEntityNotFound(_0x12b49c,null))['then'](respondWithResult(_0x12b49c,null))[_0x1743('0x40')](handleError(_0x12b49c,null));};exports[_0x1743('0x44')]=function(_0x393dbe,_0x13f327){return db['Automation'][_0x1743('0x44')](_0x393dbe[_0x1743('0x45')],{})[_0x1743('0x24')](respondWithResult(_0x13f327,0xc9))[_0x1743('0x40')](handleError(_0x13f327,null));};exports[_0x1743('0x23')]=function(_0x56e5b2,_0x260647){if(_0x56e5b2[_0x1743('0x45')]['id']){delete _0x56e5b2[_0x1743('0x45')]['id'];}return db[_0x1743('0x2b')][_0x1743('0x43')]({'where':{'id':_0x56e5b2[_0x1743('0x46')]['id']}})[_0x1743('0x24')](handleEntityNotFound(_0x260647,null))[_0x1743('0x24')](saveUpdates(_0x56e5b2['body'],null))[_0x1743('0x24')](respondWithResult(_0x260647,null))[_0x1743('0x40')](handleError(_0x260647,null));};exports[_0x1743('0x25')]=function(_0x44a222,_0x2f6425){return db[_0x1743('0x2b')][_0x1743('0x43')]({'where':{'id':_0x44a222[_0x1743('0x46')]['id']}})[_0x1743('0x24')](handleEntityNotFound(_0x2f6425,null))[_0x1743('0x24')](removeEntity(_0x2f6425,null))[_0x1743('0x40')](handleError(_0x2f6425,null));};exports['addConditions']=function(_0x882315,_0x3c43b6,_0x5cff9a){return db[_0x1743('0x47')][_0x1743('0x43')]({'where':{'id':_0x882315['params']['id']}})[_0x1743('0x24')](handleEntityNotFound(_0x3c43b6,null))['then'](function(_0x295d92){if(_0x295d92){return _0x295d92['addConditions'](_0x882315['body'][_0x1743('0x48')],_[_0x1743('0x49')](_0x882315[_0x1743('0x45')],[_0x1743('0x48'),'id'])||{});}})['then'](respondWithResult(_0x3c43b6,null))[_0x1743('0x40')](handleError(_0x3c43b6,null));};exports['getConditions']=function(_0x15fd92,_0x1fe3f6,_0x5cc565){var _0x4131c6={};var _0x2b40d9={};var _0x299132;var _0x2a724c;return db[_0x1743('0x2b')][_0x1743('0x4a')]({'where':{'id':_0x15fd92[_0x1743('0x46')]['id']}})[_0x1743('0x24')](handleEntityNotFound(_0x1fe3f6,null))[_0x1743('0x24')](function(_0x2a701c){if(_0x2a701c){_0x299132=_0x2a701c;_0x2b40d9['model']=_[_0x1743('0x4b')](db['Condition']['rawAttributes']);_0x2b40d9['query']=_['keys'](_0x15fd92[_0x1743('0x2f')]);_0x2b40d9[_0x1743('0x42')]=_['intersection'](_0x2b40d9['model'],_0x2b40d9[_0x1743('0x2f')]);_0x4131c6[_0x1743('0x32')]=_[_0x1743('0x30')](_0x2b40d9[_0x1743('0x2e')],qs[_0x1743('0x31')](_0x15fd92[_0x1743('0x2f')]['fields']));_0x4131c6[_0x1743('0x32')]=_0x4131c6['attributes']['length']?_0x4131c6[_0x1743('0x32')]:_0x2b40d9[_0x1743('0x2e')];_0x4131c6[_0x1743('0x4c')]=qs[_0x1743('0x35')](_0x15fd92[_0x1743('0x2f')][_0x1743('0x35')]);_0x4131c6[_0x1743('0x36')]=qs[_0x1743('0x42')](_['pick'](_0x15fd92['query'],_0x2b40d9[_0x1743('0x42')]));if(_0x15fd92[_0x1743('0x2f')][_0x1743('0x38')]){_0x4131c6['where']=_[_0x1743('0x3b')](_0x4131c6[_0x1743('0x36')],{'$or':_[_0x1743('0x2a')](_0x4131c6[_0x1743('0x32')],function(_0x22513d){var _0x5fb576={};_0x5fb576[_0x22513d]={'$like':'%'+_0x15fd92[_0x1743('0x2f')][_0x1743('0x38')]+'%'};return _0x5fb576;})});}_0x4131c6=_['merge']({},_0x4131c6,_0x15fd92[_0x1743('0x3c')]);return _0x299132[_0x1743('0x4d')](_0x4131c6);}})[_0x1743('0x24')](function(_0x1a8b1e){if(_0x1a8b1e){_0x2a724c=_0x1a8b1e['length'];if(!_0x15fd92[_0x1743('0x2f')]['hasOwnProperty'](_0x1743('0x34'))){_0x4131c6['limit']=qs[_0x1743('0x1d')](_0x15fd92[_0x1743('0x2f')]['limit']);_0x4131c6[_0x1743('0x1c')]=qs[_0x1743('0x1c')](_0x15fd92['query'][_0x1743('0x1c')]);}return _0x299132[_0x1743('0x4d')](_0x4131c6);}})[_0x1743('0x24')](function(_0x44796b){if(_0x44796b){return _0x44796b?{'count':_0x2a724c,'rows':_0x44796b}:null;}})[_0x1743('0x24')](respondWithResult(_0x1fe3f6,null))[_0x1743('0x40')](handleError(_0x1fe3f6,null));};exports['addActions']=function(_0xc1f0ad,_0x54da50,_0x4b7b3){return db[_0x1743('0x4e')]['find']({'where':{'id':_0xc1f0ad[_0x1743('0x46')]['id']}})['then'](handleEntityNotFound(_0x54da50,null))[_0x1743('0x24')](function(_0x53b1cc){if(_0x53b1cc){return _0x53b1cc[_0x1743('0x4f')](_0xc1f0ad[_0x1743('0x45')]['ids'],_[_0x1743('0x49')](_0xc1f0ad['body'],['ids','id'])||{});}})['then'](respondWithResult(_0x54da50,null))['catch'](handleError(_0x54da50,null));};exports[_0x1743('0x50')]=function(_0x2585c0,_0x36093f,_0x5b246c){var _0x24bb9a={};var _0x297622={};var _0x2b9237;var _0x39e200;return db['Automation'][_0x1743('0x4a')]({'where':{'id':_0x2585c0[_0x1743('0x46')]['id']}})[_0x1743('0x24')](handleEntityNotFound(_0x36093f,null))[_0x1743('0x24')](function(_0x4ebaa5){if(_0x4ebaa5){_0x2b9237=_0x4ebaa5;_0x297622[_0x1743('0x2e')]=_['keys'](db[_0x1743('0x4e')][_0x1743('0x2c')]);_0x297622[_0x1743('0x2f')]=_['keys'](_0x2585c0['query']);_0x297622[_0x1743('0x42')]=_[_0x1743('0x30')](_0x297622['model'],_0x297622[_0x1743('0x2f')]);_0x24bb9a[_0x1743('0x32')]=_[_0x1743('0x30')](_0x297622['model'],qs[_0x1743('0x31')](_0x2585c0['query'][_0x1743('0x31')]));_0x24bb9a[_0x1743('0x32')]=_0x24bb9a[_0x1743('0x32')][_0x1743('0x33')]?_0x24bb9a[_0x1743('0x32')]:_0x297622['model'];_0x24bb9a[_0x1743('0x4c')]=qs[_0x1743('0x35')](_0x2585c0[_0x1743('0x2f')][_0x1743('0x35')]);_0x24bb9a['where']=qs[_0x1743('0x42')](_['pick'](_0x2585c0['query'],_0x297622[_0x1743('0x42')]));if(_0x2585c0[_0x1743('0x2f')]['filter']){_0x24bb9a['where']=_[_0x1743('0x3b')](_0x24bb9a['where'],{'$or':_[_0x1743('0x2a')](_0x24bb9a['attributes'],function(_0x3b22f8){var _0x37d5a0={};_0x37d5a0[_0x3b22f8]={'$like':'%'+_0x2585c0['query']['filter']+'%'};return _0x37d5a0;})});}_0x24bb9a=_[_0x1743('0x3b')]({},_0x24bb9a,_0x2585c0[_0x1743('0x3c')]);return _0x2b9237[_0x1743('0x50')](_0x24bb9a);}})[_0x1743('0x24')](function(_0x507a77){if(_0x507a77){_0x39e200=_0x507a77[_0x1743('0x33')];if(!_0x2585c0[_0x1743('0x2f')]['hasOwnProperty'](_0x1743('0x34'))){_0x24bb9a['limit']=qs[_0x1743('0x1d')](_0x2585c0[_0x1743('0x2f')][_0x1743('0x1d')]);_0x24bb9a['offset']=qs[_0x1743('0x1c')](_0x2585c0[_0x1743('0x2f')][_0x1743('0x1c')]);}return _0x2b9237[_0x1743('0x50')](_0x24bb9a);}})[_0x1743('0x24')](function(_0x2cad59){if(_0x2cad59){return _0x2cad59?{'count':_0x39e200,'rows':_0x2cad59}:null;}})[_0x1743('0x24')](respondWithResult(_0x36093f,null))['catch'](handleError(_0x36093f,null));};
\ No newline at end of file