Built motion from commit e1760111.|2.6.18
[motion2.git] / server / api / automation / automation.controller.js
index 70b5bc9..ed534d5 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x13f3=['querystring','ioredis','../../components/auth/service','../../components/parsers/qs','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','sendStatus','status','json','count','offset','set','Content-Range','apply','reject','save','update','then','destroy','end','error','name','send','index','map','Automation','rawAttributes','fieldName','type','key','model','query','attributes','intersection','fields','length','hasOwnProperty','nolimit','limit','order','sort','where','filters','filter','merge','VIRTUAL','options','includeAll','include','findAll','rows','catch','show','params','keys','find','create','body','addConditions','Condition','omit','ids','getConditions','findOne','addActions','Action','getActions','pick','rimraf','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','sox','to-csv','ejs','lodash','squel','crypto','desk.js'];(function(_0x59ee6f,_0x450239){var _0x4c0979=function(_0x565e92){while(--_0x565e92){_0x59ee6f['push'](_0x59ee6f['shift']());}};_0x4c0979(++_0x450239);}(_0x13f3,0xa1));var _0x313f=function(_0x4a82ac,_0x1fb931){_0x4a82ac=_0x4a82ac-0x0;var _0x58ee97=_0x13f3[_0x4a82ac];return _0x58ee97;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0x313f('0x0'));var zipdir=require('zip-dir');var jsonpatch=require(_0x313f('0x1'));var rp=require(_0x313f('0x2'));var moment=require(_0x313f('0x3'));var BPromise=require(_0x313f('0x4'));var Mustache=require(_0x313f('0x5'));var util=require(_0x313f('0x6'));var path=require(_0x313f('0x7'));var sox=require(_0x313f('0x8'));var csv=require(_0x313f('0x9'));var ejs=require(_0x313f('0xa'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0x313f('0xb'));var squel=require(_0x313f('0xc'));var crypto=require(_0x313f('0xd'));var jsforce=require('jsforce');var deskjs=require(_0x313f('0xe'));var toCsv=require(_0x313f('0x9'));var querystring=require(_0x313f('0xf'));var Papa=require('papaparse');var Redis=require(_0x313f('0x10'));var authService=require(_0x313f('0x11'));var qs=require(_0x313f('0x12'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0x313f('0x13'));var logger=require(_0x313f('0x14'))(_0x313f('0x15'));var utils=require(_0x313f('0x16'));var config=require(_0x313f('0x17'));var licenseUtil=require(_0x313f('0x18'));var db=require(_0x313f('0x19'))['db'];function respondWithStatusCode(_0x374516,_0x5400de){_0x5400de=_0x5400de||0xcc;return function(_0xfb39e5){if(_0xfb39e5){return _0x374516[_0x313f('0x1a')](_0x5400de);}return _0x374516['status'](_0x5400de)['end']();};}function respondWithResult(_0x486560,_0x5b8e53){_0x5b8e53=_0x5b8e53||0xc8;return function(_0x2050f2){if(_0x2050f2){return _0x486560[_0x313f('0x1b')](_0x5b8e53)[_0x313f('0x1c')](_0x2050f2);}};}function respondWithFilteredResult(_0x431efd,_0x25185a){return function(_0x3ea5db){if(_0x3ea5db){var _0x44ac9b=_0x3ea5db[_0x313f('0x1d')],_0x4f6b50=_0x25185a['offset'],_0x4008bd=_0x25185a[_0x313f('0x1e')]+_0x25185a['limit'],_0x838fb8;if(_0x4008bd>=_0x44ac9b){_0x4008bd=_0x44ac9b;_0x838fb8=0xc8;}else{_0x838fb8=0xce;}_0x431efd[_0x313f('0x1b')](_0x838fb8);return _0x431efd[_0x313f('0x1f')](_0x313f('0x20'),_0x4f6b50+'-'+_0x4008bd+'/'+_0x44ac9b)['json'](_0x3ea5db);}return null;};}function patchUpdates(_0x3bb87f){return function(_0x57a8b3){try{jsonpatch[_0x313f('0x21')](_0x57a8b3,_0x3bb87f,!![]);}catch(_0xc8e817){return BPromise[_0x313f('0x22')](_0xc8e817);}return _0x57a8b3[_0x313f('0x23')]();};}function saveUpdates(_0x1a3d60,_0x57f34e){return function(_0x3f4430){if(_0x3f4430){return _0x3f4430[_0x313f('0x24')](_0x1a3d60)[_0x313f('0x25')](function(_0x1127d1){return _0x1127d1;});}return null;};}function removeEntity(_0x3d6ca8,_0x56ea5b){return function(_0x47b99d){if(_0x47b99d){return _0x47b99d[_0x313f('0x26')]()[_0x313f('0x25')](function(){_0x3d6ca8[_0x313f('0x1b')](0xcc)[_0x313f('0x27')]();});}};}function handleEntityNotFound(_0x9a91d0,_0xac4383){return function(_0x1ba073){if(!_0x1ba073){_0x9a91d0[_0x313f('0x1a')](0x194);}return _0x1ba073;};}function handleError(_0x5de6af,_0x51bcfd){_0x51bcfd=_0x51bcfd||0x1f4;return function(_0x3aa7b0){logger[_0x313f('0x28')](_0x3aa7b0['stack']);if(_0x3aa7b0[_0x313f('0x29')]){delete _0x3aa7b0['name'];}_0x5de6af['status'](_0x51bcfd)[_0x313f('0x2a')](_0x3aa7b0);};}exports[_0x313f('0x2b')]=function(_0x30140b,_0x1a4da1){var _0x587f32={},_0x100dc0={},_0x30c533={'count':0x0,'rows':[]};var _0x2b4b94=_[_0x313f('0x2c')](db[_0x313f('0x2d')][_0x313f('0x2e')],function(_0x37753d){return{'name':_0x37753d[_0x313f('0x2f')],'type':_0x37753d[_0x313f('0x30')][_0x313f('0x31')]};});_0x100dc0[_0x313f('0x32')]=_[_0x313f('0x2c')](_0x2b4b94,'name');_0x100dc0['query']=_['keys'](_0x30140b[_0x313f('0x33')]);_0x100dc0['filters']=_['intersection'](_0x100dc0[_0x313f('0x32')],_0x100dc0['query']);_0x587f32[_0x313f('0x34')]=_[_0x313f('0x35')](_0x100dc0[_0x313f('0x32')],qs[_0x313f('0x36')](_0x30140b[_0x313f('0x33')][_0x313f('0x36')]));_0x587f32['attributes']=_0x587f32[_0x313f('0x34')][_0x313f('0x37')]?_0x587f32[_0x313f('0x34')]:_0x100dc0[_0x313f('0x32')];if(!_0x30140b[_0x313f('0x33')][_0x313f('0x38')](_0x313f('0x39'))){_0x587f32['limit']=qs[_0x313f('0x3a')](_0x30140b[_0x313f('0x33')][_0x313f('0x3a')]);_0x587f32[_0x313f('0x1e')]=qs[_0x313f('0x1e')](_0x30140b[_0x313f('0x33')][_0x313f('0x1e')]);}_0x587f32[_0x313f('0x3b')]=qs[_0x313f('0x3c')](_0x30140b[_0x313f('0x33')][_0x313f('0x3c')]);_0x587f32[_0x313f('0x3d')]=qs[_0x313f('0x3e')](_['pick'](_0x30140b[_0x313f('0x33')],_0x100dc0[_0x313f('0x3e')]),_0x2b4b94);if(_0x30140b[_0x313f('0x33')][_0x313f('0x3f')]){_0x587f32[_0x313f('0x3d')]=_[_0x313f('0x40')](_0x587f32[_0x313f('0x3d')],{'$or':_[_0x313f('0x2c')](_0x2b4b94,function(_0x671003){if(_0x671003[_0x313f('0x30')]!==_0x313f('0x41')){var _0x467b28={};_0x467b28[_0x671003['name']]={'$like':'%'+_0x30140b[_0x313f('0x33')][_0x313f('0x3f')]+'%'};return _0x467b28;}})});}_0x587f32=_[_0x313f('0x40')]({},_0x587f32,_0x30140b[_0x313f('0x42')]);var _0x784a35={'where':_0x587f32[_0x313f('0x3d')]};return db[_0x313f('0x2d')]['count'](_0x784a35)[_0x313f('0x25')](function(_0x28f8cf){_0x30c533['count']=_0x28f8cf;if(_0x30140b[_0x313f('0x33')][_0x313f('0x43')]){_0x587f32[_0x313f('0x44')]=[{'all':!![]}];}return db[_0x313f('0x2d')][_0x313f('0x45')](_0x587f32);})['then'](function(_0x14dd77){_0x30c533[_0x313f('0x46')]=_0x14dd77;return _0x30c533;})[_0x313f('0x25')](respondWithFilteredResult(_0x1a4da1,_0x587f32))[_0x313f('0x47')](handleError(_0x1a4da1,null));};exports[_0x313f('0x48')]=function(_0x4b5918,_0x1b89d8){var _0xb8cb62={'raw':![],'where':{'id':_0x4b5918[_0x313f('0x49')]['id']}},_0x12e02b={};_0x12e02b['model']=_[_0x313f('0x4a')](db['Automation']['rawAttributes']);_0x12e02b['query']=_['keys'](_0x4b5918[_0x313f('0x33')]);_0x12e02b[_0x313f('0x3e')]=_['intersection'](_0x12e02b[_0x313f('0x32')],_0x12e02b['query']);_0xb8cb62[_0x313f('0x34')]=_[_0x313f('0x35')](_0x12e02b['model'],qs[_0x313f('0x36')](_0x4b5918[_0x313f('0x33')][_0x313f('0x36')]));_0xb8cb62[_0x313f('0x34')]=_0xb8cb62[_0x313f('0x34')][_0x313f('0x37')]?_0xb8cb62['attributes']:_0x12e02b[_0x313f('0x32')];if(_0x4b5918['query'][_0x313f('0x43')]){_0xb8cb62['include']=[{'all':!![]}];}_0xb8cb62=_['merge']({},_0xb8cb62,_0x4b5918[_0x313f('0x42')]);return db[_0x313f('0x2d')][_0x313f('0x4b')](_0xb8cb62)[_0x313f('0x25')](handleEntityNotFound(_0x1b89d8,null))[_0x313f('0x25')](respondWithResult(_0x1b89d8,null))['catch'](handleError(_0x1b89d8,null));};exports[_0x313f('0x4c')]=function(_0x3c81c5,_0x56f03d){return db['Automation'][_0x313f('0x4c')](_0x3c81c5[_0x313f('0x4d')],{})[_0x313f('0x25')](respondWithResult(_0x56f03d,0xc9))['catch'](handleError(_0x56f03d,null));};exports[_0x313f('0x24')]=function(_0x3b21b7,_0x100c32){if(_0x3b21b7[_0x313f('0x4d')]['id']){delete _0x3b21b7[_0x313f('0x4d')]['id'];}return db[_0x313f('0x2d')][_0x313f('0x4b')]({'where':{'id':_0x3b21b7[_0x313f('0x49')]['id']}})[_0x313f('0x25')](handleEntityNotFound(_0x100c32,null))[_0x313f('0x25')](saveUpdates(_0x3b21b7[_0x313f('0x4d')],null))[_0x313f('0x25')](respondWithResult(_0x100c32,null))[_0x313f('0x47')](handleError(_0x100c32,null));};exports[_0x313f('0x26')]=function(_0x15f54d,_0x23f419){return db[_0x313f('0x2d')][_0x313f('0x4b')]({'where':{'id':_0x15f54d[_0x313f('0x49')]['id']}})[_0x313f('0x25')](handleEntityNotFound(_0x23f419,null))['then'](removeEntity(_0x23f419,null))['catch'](handleError(_0x23f419,null));};exports[_0x313f('0x4e')]=function(_0x3588a3,_0x4ee831,_0x481836){return db[_0x313f('0x4f')][_0x313f('0x4b')]({'where':{'id':_0x3588a3[_0x313f('0x49')]['id']}})[_0x313f('0x25')](handleEntityNotFound(_0x4ee831,null))[_0x313f('0x25')](function(_0x554726){if(_0x554726){return _0x554726[_0x313f('0x4e')](_0x3588a3[_0x313f('0x4d')]['ids'],_[_0x313f('0x50')](_0x3588a3[_0x313f('0x4d')],[_0x313f('0x51'),'id'])||{});}})[_0x313f('0x25')](respondWithResult(_0x4ee831,null))[_0x313f('0x47')](handleError(_0x4ee831,null));};exports[_0x313f('0x52')]=function(_0x43be24,_0x310177,_0x4a447a){var _0x43f08f={};var _0xe9cefe={};var _0x380317;var _0x2807e4;return db[_0x313f('0x2d')][_0x313f('0x53')]({'where':{'id':_0x43be24['params']['id']}})[_0x313f('0x25')](handleEntityNotFound(_0x310177,null))['then'](function(_0x56d194){if(_0x56d194){_0x380317=_0x56d194;_0xe9cefe['model']=_[_0x313f('0x4a')](db[_0x313f('0x4f')][_0x313f('0x2e')]);_0xe9cefe['query']=_[_0x313f('0x4a')](_0x43be24[_0x313f('0x33')]);_0xe9cefe[_0x313f('0x3e')]=_[_0x313f('0x35')](_0xe9cefe['model'],_0xe9cefe[_0x313f('0x33')]);_0x43f08f[_0x313f('0x34')]=_['intersection'](_0xe9cefe[_0x313f('0x32')],qs[_0x313f('0x36')](_0x43be24[_0x313f('0x33')][_0x313f('0x36')]));_0x43f08f[_0x313f('0x34')]=_0x43f08f['attributes']['length']?_0x43f08f['attributes']:_0xe9cefe[_0x313f('0x32')];_0x43f08f['order']=qs[_0x313f('0x3c')](_0x43be24[_0x313f('0x33')][_0x313f('0x3c')]);_0x43f08f[_0x313f('0x3d')]=qs['filters'](_['pick'](_0x43be24[_0x313f('0x33')],_0xe9cefe[_0x313f('0x3e')]));if(_0x43be24[_0x313f('0x33')]['filter']){_0x43f08f[_0x313f('0x3d')]=_[_0x313f('0x40')](_0x43f08f['where'],{'$or':_[_0x313f('0x2c')](_0x43f08f['attributes'],function(_0x483b42){var _0x5dff5b={};_0x5dff5b[_0x483b42]={'$like':'%'+_0x43be24[_0x313f('0x33')]['filter']+'%'};return _0x5dff5b;})});}_0x43f08f=_['merge']({},_0x43f08f,_0x43be24[_0x313f('0x42')]);return _0x380317[_0x313f('0x52')](_0x43f08f);}})[_0x313f('0x25')](function(_0x215449){if(_0x215449){_0x2807e4=_0x215449[_0x313f('0x37')];if(!_0x43be24['query'][_0x313f('0x38')](_0x313f('0x39'))){_0x43f08f[_0x313f('0x3a')]=qs[_0x313f('0x3a')](_0x43be24['query'][_0x313f('0x3a')]);_0x43f08f[_0x313f('0x1e')]=qs[_0x313f('0x1e')](_0x43be24['query'][_0x313f('0x1e')]);}return _0x380317[_0x313f('0x52')](_0x43f08f);}})[_0x313f('0x25')](function(_0x33594b){if(_0x33594b){return _0x33594b?{'count':_0x2807e4,'rows':_0x33594b}:null;}})[_0x313f('0x25')](respondWithResult(_0x310177,null))['catch'](handleError(_0x310177,null));};exports[_0x313f('0x54')]=function(_0x40943b,_0x361321,_0x3e6b10){return db[_0x313f('0x55')]['find']({'where':{'id':_0x40943b[_0x313f('0x49')]['id']}})[_0x313f('0x25')](handleEntityNotFound(_0x361321,null))[_0x313f('0x25')](function(_0x394389){if(_0x394389){return _0x394389['addActions'](_0x40943b[_0x313f('0x4d')]['ids'],_[_0x313f('0x50')](_0x40943b[_0x313f('0x4d')],[_0x313f('0x51'),'id'])||{});}})['then'](respondWithResult(_0x361321,null))[_0x313f('0x47')](handleError(_0x361321,null));};exports[_0x313f('0x56')]=function(_0x2efc71,_0x24d851,_0x350204){var _0x4a3dd7={};var _0x2959c1={};var _0x4b6b5b;var _0x9393e6;return db[_0x313f('0x2d')][_0x313f('0x53')]({'where':{'id':_0x2efc71[_0x313f('0x49')]['id']}})[_0x313f('0x25')](handleEntityNotFound(_0x24d851,null))[_0x313f('0x25')](function(_0x38d744){if(_0x38d744){_0x4b6b5b=_0x38d744;_0x2959c1[_0x313f('0x32')]=_[_0x313f('0x4a')](db[_0x313f('0x55')]['rawAttributes']);_0x2959c1[_0x313f('0x33')]=_[_0x313f('0x4a')](_0x2efc71['query']);_0x2959c1[_0x313f('0x3e')]=_[_0x313f('0x35')](_0x2959c1[_0x313f('0x32')],_0x2959c1[_0x313f('0x33')]);_0x4a3dd7[_0x313f('0x34')]=_[_0x313f('0x35')](_0x2959c1[_0x313f('0x32')],qs[_0x313f('0x36')](_0x2efc71[_0x313f('0x33')][_0x313f('0x36')]));_0x4a3dd7[_0x313f('0x34')]=_0x4a3dd7['attributes'][_0x313f('0x37')]?_0x4a3dd7[_0x313f('0x34')]:_0x2959c1[_0x313f('0x32')];_0x4a3dd7[_0x313f('0x3b')]=qs[_0x313f('0x3c')](_0x2efc71[_0x313f('0x33')][_0x313f('0x3c')]);_0x4a3dd7[_0x313f('0x3d')]=qs[_0x313f('0x3e')](_[_0x313f('0x57')](_0x2efc71['query'],_0x2959c1['filters']));if(_0x2efc71[_0x313f('0x33')][_0x313f('0x3f')]){_0x4a3dd7['where']=_[_0x313f('0x40')](_0x4a3dd7['where'],{'$or':_[_0x313f('0x2c')](_0x4a3dd7['attributes'],function(_0x241e7b){var _0x42618c={};_0x42618c[_0x241e7b]={'$like':'%'+_0x2efc71[_0x313f('0x33')][_0x313f('0x3f')]+'%'};return _0x42618c;})});}_0x4a3dd7=_[_0x313f('0x40')]({},_0x4a3dd7,_0x2efc71[_0x313f('0x42')]);return _0x4b6b5b[_0x313f('0x56')](_0x4a3dd7);}})[_0x313f('0x25')](function(_0x5a0ca1){if(_0x5a0ca1){_0x9393e6=_0x5a0ca1['length'];if(!_0x2efc71[_0x313f('0x33')][_0x313f('0x38')]('nolimit')){_0x4a3dd7['limit']=qs[_0x313f('0x3a')](_0x2efc71['query']['limit']);_0x4a3dd7[_0x313f('0x1e')]=qs['offset'](_0x2efc71['query'][_0x313f('0x1e')]);}return _0x4b6b5b[_0x313f('0x56')](_0x4a3dd7);}})[_0x313f('0x25')](function(_0x5ec12b){if(_0x5ec12b){return _0x5ec12b?{'count':_0x9393e6,'rows':_0x5ec12b}:null;}})[_0x313f('0x25')](respondWithResult(_0x24d851,null))['catch'](handleError(_0x24d851,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