Built motion from commit 3e059bc2.|2.5.32
[motion2.git] / server / api / automation / automation.controller.js
index 70b5bc9..c2d787e 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 _0xda4f=['include','Automation','rows','catch','params','find','create','body','destroy','addConditions','omit','ids','getConditions','findOne','pick','options','Action','getActions','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','mustache','path','to-csv','ejs','lodash','jsforce','querystring','papaparse','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','sendStatus','status','end','json','offset','undefined','limit','count','set','Content-Range','apply','update','then','error','stack','name','map','rawAttributes','type','key','query','keys','model','attributes','intersection','fields','length','hasOwnProperty','nolimit','order','sort','where','filters','filter','merge','includeAll'];(function(_0x20aae1,_0x51efd4){var _0x510601=function(_0x20895f){while(--_0x20895f){_0x20aae1['push'](_0x20aae1['shift']());}};_0x510601(++_0x51efd4);}(_0xda4f,0x1e6));var _0xfda4=function(_0x43675f,_0x5f5ae6){_0x43675f=_0x43675f-0x0;var _0x56ea2e=_0xda4f[_0x43675f];return _0x56ea2e;};'use strict';var emlformat=require(_0xfda4('0x0'));var rimraf=require(_0xfda4('0x1'));var zipdir=require(_0xfda4('0x2'));var jsonpatch=require(_0xfda4('0x3'));var rp=require(_0xfda4('0x4'));var moment=require(_0xfda4('0x5'));var BPromise=require('bluebird');var Mustache=require(_0xfda4('0x6'));var util=require('util');var path=require(_0xfda4('0x7'));var sox=require('sox');var csv=require(_0xfda4('0x8'));var ejs=require(_0xfda4('0x9'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0xfda4('0xa'));var squel=require('squel');var crypto=require('crypto');var jsforce=require(_0xfda4('0xb'));var deskjs=require('desk.js');var toCsv=require(_0xfda4('0x8'));var querystring=require(_0xfda4('0xc'));var Papa=require(_0xfda4('0xd'));var Redis=require('ioredis');var authService=require(_0xfda4('0xe'));var qs=require(_0xfda4('0xf'));var as=require(_0xfda4('0x10'));var hardwareService=require(_0xfda4('0x11'));var logger=require(_0xfda4('0x12'))(_0xfda4('0x13'));var utils=require(_0xfda4('0x14'));var config=require(_0xfda4('0x15'));var licenseUtil=require(_0xfda4('0x16'));var db=require(_0xfda4('0x17'))['db'];function respondWithStatusCode(_0x24df48,_0x5428b4){_0x5428b4=_0x5428b4||0xcc;return function(_0x4f42e1){if(_0x4f42e1){return _0x24df48[_0xfda4('0x18')](_0x5428b4);}return _0x24df48[_0xfda4('0x19')](_0x5428b4)[_0xfda4('0x1a')]();};}function respondWithResult(_0x52411a,_0x1431f7){_0x1431f7=_0x1431f7||0xc8;return function(_0x4e6d8f){if(_0x4e6d8f){return _0x52411a['status'](_0x1431f7)[_0xfda4('0x1b')](_0x4e6d8f);}};}function respondWithFilteredResult(_0x5686dd,_0x164ad9){return function(_0xc069e4){if(_0xc069e4){var _0x459d73=typeof _0x164ad9[_0xfda4('0x1c')]===_0xfda4('0x1d')&&typeof _0x164ad9[_0xfda4('0x1e')]==='undefined';var _0xec6624=_0xc069e4[_0xfda4('0x1f')];var _0x31b776=_0x459d73?0x0:_0x164ad9['offset'];var _0x2fbf1d=_0x459d73?_0xc069e4[_0xfda4('0x1f')]:_0x164ad9['offset']+_0x164ad9[_0xfda4('0x1e')];var _0x2cc638;if(_0x2fbf1d>=_0xec6624){_0x2fbf1d=_0xec6624;_0x2cc638=0xc8;}else{_0x2cc638=0xce;}_0x5686dd[_0xfda4('0x19')](_0x2cc638);return _0x5686dd[_0xfda4('0x20')](_0xfda4('0x21'),_0x31b776+'-'+_0x2fbf1d+'/'+_0xec6624)[_0xfda4('0x1b')](_0xc069e4);}return null;};}function patchUpdates(_0xd47295){return function(_0x17d849){try{jsonpatch[_0xfda4('0x22')](_0x17d849,_0xd47295,!![]);}catch(_0x1edd62){return BPromise['reject'](_0x1edd62);}return _0x17d849['save']();};}function saveUpdates(_0x394a9d,_0x39b243){return function(_0x3cefb0){if(_0x3cefb0){return _0x3cefb0[_0xfda4('0x23')](_0x394a9d)[_0xfda4('0x24')](function(_0x37912f){return _0x37912f;});}return null;};}function removeEntity(_0xef0f08,_0x204433){return function(_0x330868){if(_0x330868){return _0x330868['destroy']()['then'](function(){_0xef0f08[_0xfda4('0x19')](0xcc)[_0xfda4('0x1a')]();});}};}function handleEntityNotFound(_0x586026,_0x596c6f){return function(_0x314551){if(!_0x314551){_0x586026[_0xfda4('0x18')](0x194);}return _0x314551;};}function handleError(_0x1efc6d,_0x413221){_0x413221=_0x413221||0x1f4;return function(_0x21fe1c){logger[_0xfda4('0x25')](_0x21fe1c[_0xfda4('0x26')]);if(_0x21fe1c['name']){delete _0x21fe1c[_0xfda4('0x27')];}_0x1efc6d[_0xfda4('0x19')](_0x413221)['send'](_0x21fe1c);};}exports['index']=function(_0x403814,_0x3b6d00){var _0x261090={},_0x1113df={},_0x38da6c={'count':0x0,'rows':[]};var _0x34ee0d=_[_0xfda4('0x28')](db['Automation'][_0xfda4('0x29')],function(_0x5501e3){return{'name':_0x5501e3['fieldName'],'type':_0x5501e3[_0xfda4('0x2a')][_0xfda4('0x2b')]};});_0x1113df['model']=_[_0xfda4('0x28')](_0x34ee0d,'name');_0x1113df[_0xfda4('0x2c')]=_[_0xfda4('0x2d')](_0x403814[_0xfda4('0x2c')]);_0x1113df['filters']=_['intersection'](_0x1113df[_0xfda4('0x2e')],_0x1113df[_0xfda4('0x2c')]);_0x261090[_0xfda4('0x2f')]=_[_0xfda4('0x30')](_0x1113df['model'],qs[_0xfda4('0x31')](_0x403814['query'][_0xfda4('0x31')]));_0x261090[_0xfda4('0x2f')]=_0x261090[_0xfda4('0x2f')][_0xfda4('0x32')]?_0x261090['attributes']:_0x1113df[_0xfda4('0x2e')];if(!_0x403814['query'][_0xfda4('0x33')](_0xfda4('0x34'))){_0x261090[_0xfda4('0x1e')]=qs[_0xfda4('0x1e')](_0x403814[_0xfda4('0x2c')]['limit']);_0x261090[_0xfda4('0x1c')]=qs[_0xfda4('0x1c')](_0x403814['query'][_0xfda4('0x1c')]);}_0x261090[_0xfda4('0x35')]=qs[_0xfda4('0x36')](_0x403814[_0xfda4('0x2c')][_0xfda4('0x36')]);_0x261090[_0xfda4('0x37')]=qs[_0xfda4('0x38')](_['pick'](_0x403814[_0xfda4('0x2c')],_0x1113df[_0xfda4('0x38')]),_0x34ee0d);if(_0x403814[_0xfda4('0x2c')][_0xfda4('0x39')]){_0x261090[_0xfda4('0x37')]=_[_0xfda4('0x3a')](_0x261090['where'],{'$or':_[_0xfda4('0x28')](_0x34ee0d,function(_0x1b830d){if(_0x1b830d[_0xfda4('0x2a')]!=='VIRTUAL'){var _0x13f54d={};_0x13f54d[_0x1b830d[_0xfda4('0x27')]]={'$like':'%'+_0x403814[_0xfda4('0x2c')][_0xfda4('0x39')]+'%'};return _0x13f54d;}})});}_0x261090=_[_0xfda4('0x3a')]({},_0x261090,_0x403814['options']);var _0x19e16e={'where':_0x261090[_0xfda4('0x37')]};return db['Automation']['count'](_0x19e16e)[_0xfda4('0x24')](function(_0xf80347){_0x38da6c[_0xfda4('0x1f')]=_0xf80347;if(_0x403814[_0xfda4('0x2c')][_0xfda4('0x3b')]){_0x261090[_0xfda4('0x3c')]=[{'all':!![]}];}return db[_0xfda4('0x3d')]['findAll'](_0x261090);})[_0xfda4('0x24')](function(_0x53ff36){_0x38da6c[_0xfda4('0x3e')]=_0x53ff36;return _0x38da6c;})['then'](respondWithFilteredResult(_0x3b6d00,_0x261090))[_0xfda4('0x3f')](handleError(_0x3b6d00,null));};exports['show']=function(_0x11e528,_0x5b8c33){var _0x2a1921={'raw':![],'where':{'id':_0x11e528[_0xfda4('0x40')]['id']}},_0x51cba3={};_0x51cba3[_0xfda4('0x2e')]=_['keys'](db[_0xfda4('0x3d')][_0xfda4('0x29')]);_0x51cba3[_0xfda4('0x2c')]=_[_0xfda4('0x2d')](_0x11e528[_0xfda4('0x2c')]);_0x51cba3[_0xfda4('0x38')]=_[_0xfda4('0x30')](_0x51cba3[_0xfda4('0x2e')],_0x51cba3[_0xfda4('0x2c')]);_0x2a1921[_0xfda4('0x2f')]=_[_0xfda4('0x30')](_0x51cba3[_0xfda4('0x2e')],qs[_0xfda4('0x31')](_0x11e528['query'][_0xfda4('0x31')]));_0x2a1921['attributes']=_0x2a1921[_0xfda4('0x2f')][_0xfda4('0x32')]?_0x2a1921[_0xfda4('0x2f')]:_0x51cba3[_0xfda4('0x2e')];if(_0x11e528[_0xfda4('0x2c')][_0xfda4('0x3b')]){_0x2a1921[_0xfda4('0x3c')]=[{'all':!![]}];}_0x2a1921=_[_0xfda4('0x3a')]({},_0x2a1921,_0x11e528['options']);return db[_0xfda4('0x3d')][_0xfda4('0x41')](_0x2a1921)['then'](handleEntityNotFound(_0x5b8c33,null))[_0xfda4('0x24')](respondWithResult(_0x5b8c33,null))[_0xfda4('0x3f')](handleError(_0x5b8c33,null));};exports[_0xfda4('0x42')]=function(_0x12ece4,_0x2cc2d1){return db[_0xfda4('0x3d')][_0xfda4('0x42')](_0x12ece4[_0xfda4('0x43')],{})['then'](respondWithResult(_0x2cc2d1,0xc9))[_0xfda4('0x3f')](handleError(_0x2cc2d1,null));};exports[_0xfda4('0x23')]=function(_0x210f6c,_0x34169e){if(_0x210f6c[_0xfda4('0x43')]['id']){delete _0x210f6c[_0xfda4('0x43')]['id'];}return db[_0xfda4('0x3d')][_0xfda4('0x41')]({'where':{'id':_0x210f6c[_0xfda4('0x40')]['id']}})[_0xfda4('0x24')](handleEntityNotFound(_0x34169e,null))[_0xfda4('0x24')](saveUpdates(_0x210f6c[_0xfda4('0x43')],null))['then'](respondWithResult(_0x34169e,null))[_0xfda4('0x3f')](handleError(_0x34169e,null));};exports[_0xfda4('0x44')]=function(_0x2f908b,_0x38f11a){return db['Automation'][_0xfda4('0x41')]({'where':{'id':_0x2f908b[_0xfda4('0x40')]['id']}})['then'](handleEntityNotFound(_0x38f11a,null))[_0xfda4('0x24')](removeEntity(_0x38f11a,null))['catch'](handleError(_0x38f11a,null));};exports[_0xfda4('0x45')]=function(_0x2621c3,_0x52b43f,_0x21ec48){return db['Condition']['find']({'where':{'id':_0x2621c3[_0xfda4('0x40')]['id']}})[_0xfda4('0x24')](handleEntityNotFound(_0x52b43f,null))[_0xfda4('0x24')](function(_0x4b1dda){if(_0x4b1dda){return _0x4b1dda[_0xfda4('0x45')](_0x2621c3[_0xfda4('0x43')]['ids'],_[_0xfda4('0x46')](_0x2621c3[_0xfda4('0x43')],[_0xfda4('0x47'),'id'])||{});}})[_0xfda4('0x24')](respondWithResult(_0x52b43f,null))['catch'](handleError(_0x52b43f,null));};exports[_0xfda4('0x48')]=function(_0x4730f5,_0x4608f1,_0x46dcc3){var _0x315cd6={};var _0xd8d1cc={};var _0x3762c0;var _0x521a39;return db[_0xfda4('0x3d')][_0xfda4('0x49')]({'where':{'id':_0x4730f5[_0xfda4('0x40')]['id']}})[_0xfda4('0x24')](handleEntityNotFound(_0x4608f1,null))['then'](function(_0x290ab6){if(_0x290ab6){_0x3762c0=_0x290ab6;_0xd8d1cc[_0xfda4('0x2e')]=_[_0xfda4('0x2d')](db['Condition'][_0xfda4('0x29')]);_0xd8d1cc[_0xfda4('0x2c')]=_['keys'](_0x4730f5[_0xfda4('0x2c')]);_0xd8d1cc['filters']=_[_0xfda4('0x30')](_0xd8d1cc[_0xfda4('0x2e')],_0xd8d1cc['query']);_0x315cd6[_0xfda4('0x2f')]=_['intersection'](_0xd8d1cc[_0xfda4('0x2e')],qs[_0xfda4('0x31')](_0x4730f5[_0xfda4('0x2c')][_0xfda4('0x31')]));_0x315cd6['attributes']=_0x315cd6[_0xfda4('0x2f')][_0xfda4('0x32')]?_0x315cd6['attributes']:_0xd8d1cc[_0xfda4('0x2e')];_0x315cd6[_0xfda4('0x35')]=qs['sort'](_0x4730f5['query'][_0xfda4('0x36')]);_0x315cd6[_0xfda4('0x37')]=qs[_0xfda4('0x38')](_[_0xfda4('0x4a')](_0x4730f5['query'],_0xd8d1cc['filters']));if(_0x4730f5['query'][_0xfda4('0x39')]){_0x315cd6[_0xfda4('0x37')]=_['merge'](_0x315cd6['where'],{'$or':_['map'](_0x315cd6[_0xfda4('0x2f')],function(_0x4428ae){var _0x8f7d3f={};_0x8f7d3f[_0x4428ae]={'$like':'%'+_0x4730f5['query'][_0xfda4('0x39')]+'%'};return _0x8f7d3f;})});}_0x315cd6=_[_0xfda4('0x3a')]({},_0x315cd6,_0x4730f5[_0xfda4('0x4b')]);return _0x3762c0[_0xfda4('0x48')](_0x315cd6);}})['then'](function(_0x131efa){if(_0x131efa){_0x521a39=_0x131efa[_0xfda4('0x32')];if(!_0x4730f5[_0xfda4('0x2c')][_0xfda4('0x33')](_0xfda4('0x34'))){_0x315cd6[_0xfda4('0x1e')]=qs[_0xfda4('0x1e')](_0x4730f5['query'][_0xfda4('0x1e')]);_0x315cd6['offset']=qs[_0xfda4('0x1c')](_0x4730f5[_0xfda4('0x2c')][_0xfda4('0x1c')]);}return _0x3762c0['getConditions'](_0x315cd6);}})['then'](function(_0x3eb2e9){if(_0x3eb2e9){return _0x3eb2e9?{'count':_0x521a39,'rows':_0x3eb2e9}:null;}})[_0xfda4('0x24')](respondWithResult(_0x4608f1,null))['catch'](handleError(_0x4608f1,null));};exports['addActions']=function(_0x17a4de,_0x452e79,_0xca6d44){return db[_0xfda4('0x4c')][_0xfda4('0x41')]({'where':{'id':_0x17a4de[_0xfda4('0x40')]['id']}})['then'](handleEntityNotFound(_0x452e79,null))[_0xfda4('0x24')](function(_0x3ad553){if(_0x3ad553){return _0x3ad553['addActions'](_0x17a4de[_0xfda4('0x43')][_0xfda4('0x47')],_[_0xfda4('0x46')](_0x17a4de[_0xfda4('0x43')],['ids','id'])||{});}})[_0xfda4('0x24')](respondWithResult(_0x452e79,null))['catch'](handleError(_0x452e79,null));};exports[_0xfda4('0x4d')]=function(_0x54d5db,_0x73f828,_0x13f528){var _0x5e8d4e={};var _0x1abba3={};var _0x145da0;var _0x55ff6d;return db[_0xfda4('0x3d')][_0xfda4('0x49')]({'where':{'id':_0x54d5db['params']['id']}})['then'](handleEntityNotFound(_0x73f828,null))['then'](function(_0x142757){if(_0x142757){_0x145da0=_0x142757;_0x1abba3[_0xfda4('0x2e')]=_[_0xfda4('0x2d')](db[_0xfda4('0x4c')][_0xfda4('0x29')]);_0x1abba3[_0xfda4('0x2c')]=_[_0xfda4('0x2d')](_0x54d5db[_0xfda4('0x2c')]);_0x1abba3[_0xfda4('0x38')]=_[_0xfda4('0x30')](_0x1abba3[_0xfda4('0x2e')],_0x1abba3[_0xfda4('0x2c')]);_0x5e8d4e['attributes']=_[_0xfda4('0x30')](_0x1abba3[_0xfda4('0x2e')],qs[_0xfda4('0x31')](_0x54d5db['query'][_0xfda4('0x31')]));_0x5e8d4e[_0xfda4('0x2f')]=_0x5e8d4e['attributes'][_0xfda4('0x32')]?_0x5e8d4e[_0xfda4('0x2f')]:_0x1abba3[_0xfda4('0x2e')];_0x5e8d4e['order']=qs[_0xfda4('0x36')](_0x54d5db[_0xfda4('0x2c')]['sort']);_0x5e8d4e['where']=qs['filters'](_[_0xfda4('0x4a')](_0x54d5db[_0xfda4('0x2c')],_0x1abba3['filters']));if(_0x54d5db[_0xfda4('0x2c')][_0xfda4('0x39')]){_0x5e8d4e['where']=_[_0xfda4('0x3a')](_0x5e8d4e[_0xfda4('0x37')],{'$or':_[_0xfda4('0x28')](_0x5e8d4e['attributes'],function(_0x1db77f){var _0x399c27={};_0x399c27[_0x1db77f]={'$like':'%'+_0x54d5db[_0xfda4('0x2c')][_0xfda4('0x39')]+'%'};return _0x399c27;})});}_0x5e8d4e=_[_0xfda4('0x3a')]({},_0x5e8d4e,_0x54d5db[_0xfda4('0x4b')]);return _0x145da0[_0xfda4('0x4d')](_0x5e8d4e);}})[_0xfda4('0x24')](function(_0x5a1009){if(_0x5a1009){_0x55ff6d=_0x5a1009[_0xfda4('0x32')];if(!_0x54d5db[_0xfda4('0x2c')][_0xfda4('0x33')]('nolimit')){_0x5e8d4e[_0xfda4('0x1e')]=qs[_0xfda4('0x1e')](_0x54d5db[_0xfda4('0x2c')][_0xfda4('0x1e')]);_0x5e8d4e[_0xfda4('0x1c')]=qs['offset'](_0x54d5db[_0xfda4('0x2c')][_0xfda4('0x1c')]);}return _0x145da0[_0xfda4('0x4d')](_0x5e8d4e);}})[_0xfda4('0x24')](function(_0x15d905){if(_0x15d905){return _0x15d905?{'count':_0x55ff6d,'rows':_0x15d905}:null;}})[_0xfda4('0x24')](respondWithResult(_0x73f828,null))[_0xfda4('0x3f')](handleError(_0x73f828,null));};
\ No newline at end of file