Built motion from commit c738b9ac.|2.6.25
[motion2.git] / server / api / automation / automation.controller.js
index 8a1d2e4..3bca8f4 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xf088=['index','map','Automation','rawAttributes','fieldName','type','key','model','query','intersection','fields','attributes','length','hasOwnProperty','nolimit','order','sort','pick','filters','where','VIRTUAL','filter','merge','options','includeAll','include','findAll','rows','show','params','keys','find','catch','create','body','addConditions','Condition','ids','omit','getConditions','findOne','Action','getActions','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','bluebird','mustache','to-csv','ejs','fs-extra','lodash','squel','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','api','../../config/utils','../../config/license/util','../../mysqldb','sendStatus','status','end','offset','limit','undefined','count','Content-Range','json','apply','reject','save','update','then','destroy','error','stack','name','send'];(function(_0x3b380d,_0x4bf247){var _0x54502b=function(_0x35d207){while(--_0x35d207){_0x3b380d['push'](_0x3b380d['shift']());}};_0x54502b(++_0x4bf247);}(_0xf088,0x1d9));var _0x8f08=function(_0x141c35,_0x554a8e){_0x141c35=_0x141c35-0x0;var _0x3ef67b=_0xf088[_0x141c35];return _0x3ef67b;};'use strict';var emlformat=require(_0x8f08('0x0'));var rimraf=require(_0x8f08('0x1'));var zipdir=require(_0x8f08('0x2'));var jsonpatch=require(_0x8f08('0x3'));var rp=require(_0x8f08('0x4'));var moment=require('moment');var BPromise=require(_0x8f08('0x5'));var Mustache=require(_0x8f08('0x6'));var util=require('util');var path=require('path');var sox=require('sox');var csv=require(_0x8f08('0x7'));var ejs=require(_0x8f08('0x8'));var fs=require('fs');var fs_extra=require(_0x8f08('0x9'));var _=require(_0x8f08('0xa'));var squel=require(_0x8f08('0xb'));var crypto=require('crypto');var jsforce=require(_0x8f08('0xc'));var deskjs=require(_0x8f08('0xd'));var toCsv=require(_0x8f08('0x7'));var querystring=require(_0x8f08('0xe'));var Papa=require(_0x8f08('0xf'));var Redis=require(_0x8f08('0x10'));var authService=require(_0x8f08('0x11'));var qs=require(_0x8f08('0x12'));var as=require(_0x8f08('0x13'));var hardwareService=require('../../config/license/hardware');var logger=require('../../config/logger')(_0x8f08('0x14'));var utils=require(_0x8f08('0x15'));var config=require('../../config/environment');var licenseUtil=require(_0x8f08('0x16'));var db=require(_0x8f08('0x17'))['db'];function respondWithStatusCode(_0x5a1bc3,_0x5cc82b){_0x5cc82b=_0x5cc82b||0xcc;return function(_0x2a67fd){if(_0x2a67fd){return _0x5a1bc3[_0x8f08('0x18')](_0x5cc82b);}return _0x5a1bc3[_0x8f08('0x19')](_0x5cc82b)[_0x8f08('0x1a')]();};}function respondWithResult(_0x2423fd,_0x3c64b2){_0x3c64b2=_0x3c64b2||0xc8;return function(_0x2f79eb){if(_0x2f79eb){return _0x2423fd[_0x8f08('0x19')](_0x3c64b2)['json'](_0x2f79eb);}};}function respondWithFilteredResult(_0x46c4a7,_0x435645){return function(_0x9e4c5a){if(_0x9e4c5a){var _0x21e90d=typeof _0x435645[_0x8f08('0x1b')]==='undefined'&&typeof _0x435645[_0x8f08('0x1c')]===_0x8f08('0x1d');var _0x54cda4=_0x9e4c5a[_0x8f08('0x1e')];var _0x53972f=_0x21e90d?0x0:_0x435645[_0x8f08('0x1b')];var _0x5353d7=_0x21e90d?_0x9e4c5a['count']:_0x435645['offset']+_0x435645[_0x8f08('0x1c')];var _0x52d24b;if(_0x5353d7>=_0x54cda4){_0x5353d7=_0x54cda4;_0x52d24b=0xc8;}else{_0x52d24b=0xce;}_0x46c4a7['status'](_0x52d24b);return _0x46c4a7['set'](_0x8f08('0x1f'),_0x53972f+'-'+_0x5353d7+'/'+_0x54cda4)[_0x8f08('0x20')](_0x9e4c5a);}return null;};}function patchUpdates(_0x36d489){return function(_0x573c2c){try{jsonpatch[_0x8f08('0x21')](_0x573c2c,_0x36d489,!![]);}catch(_0x272173){return BPromise[_0x8f08('0x22')](_0x272173);}return _0x573c2c[_0x8f08('0x23')]();};}function saveUpdates(_0x4ce4ca,_0x149d1e){return function(_0x2f2dac){if(_0x2f2dac){return _0x2f2dac[_0x8f08('0x24')](_0x4ce4ca)[_0x8f08('0x25')](function(_0x39c281){return _0x39c281;});}return null;};}function removeEntity(_0x4df472,_0x5cec0f){return function(_0x1d6b16){if(_0x1d6b16){return _0x1d6b16[_0x8f08('0x26')]()[_0x8f08('0x25')](function(){_0x4df472['status'](0xcc)[_0x8f08('0x1a')]();});}};}function handleEntityNotFound(_0x13c5c9,_0x1f621e){return function(_0x12e125){if(!_0x12e125){_0x13c5c9['sendStatus'](0x194);}return _0x12e125;};}function handleError(_0x3954a3,_0x3e6b1b){_0x3e6b1b=_0x3e6b1b||0x1f4;return function(_0x20ebc0){logger[_0x8f08('0x27')](_0x20ebc0[_0x8f08('0x28')]);if(_0x20ebc0[_0x8f08('0x29')]){delete _0x20ebc0[_0x8f08('0x29')];}_0x3954a3[_0x8f08('0x19')](_0x3e6b1b)[_0x8f08('0x2a')](_0x20ebc0);};}exports[_0x8f08('0x2b')]=function(_0x237729,_0x3d9754){var _0x4e9b4f={},_0x50b495={},_0x918610={'count':0x0,'rows':[]};var _0x12516=_[_0x8f08('0x2c')](db[_0x8f08('0x2d')][_0x8f08('0x2e')],function(_0x2690a2){return{'name':_0x2690a2[_0x8f08('0x2f')],'type':_0x2690a2[_0x8f08('0x30')][_0x8f08('0x31')]};});_0x50b495[_0x8f08('0x32')]=_['map'](_0x12516,'name');_0x50b495['query']=_['keys'](_0x237729[_0x8f08('0x33')]);_0x50b495['filters']=_['intersection'](_0x50b495[_0x8f08('0x32')],_0x50b495['query']);_0x4e9b4f['attributes']=_[_0x8f08('0x34')](_0x50b495[_0x8f08('0x32')],qs[_0x8f08('0x35')](_0x237729['query'][_0x8f08('0x35')]));_0x4e9b4f[_0x8f08('0x36')]=_0x4e9b4f[_0x8f08('0x36')][_0x8f08('0x37')]?_0x4e9b4f[_0x8f08('0x36')]:_0x50b495[_0x8f08('0x32')];if(!_0x237729[_0x8f08('0x33')][_0x8f08('0x38')](_0x8f08('0x39'))){_0x4e9b4f['limit']=qs[_0x8f08('0x1c')](_0x237729[_0x8f08('0x33')][_0x8f08('0x1c')]);_0x4e9b4f[_0x8f08('0x1b')]=qs[_0x8f08('0x1b')](_0x237729['query'][_0x8f08('0x1b')]);}_0x4e9b4f[_0x8f08('0x3a')]=qs[_0x8f08('0x3b')](_0x237729[_0x8f08('0x33')][_0x8f08('0x3b')]);_0x4e9b4f['where']=qs['filters'](_[_0x8f08('0x3c')](_0x237729[_0x8f08('0x33')],_0x50b495[_0x8f08('0x3d')]),_0x12516);if(_0x237729['query']['filter']){_0x4e9b4f[_0x8f08('0x3e')]=_['merge'](_0x4e9b4f[_0x8f08('0x3e')],{'$or':_[_0x8f08('0x2c')](_0x12516,function(_0x22e209){if(_0x22e209[_0x8f08('0x30')]!==_0x8f08('0x3f')){var _0x211081={};_0x211081[_0x22e209[_0x8f08('0x29')]]={'$like':'%'+_0x237729[_0x8f08('0x33')][_0x8f08('0x40')]+'%'};return _0x211081;}})});}_0x4e9b4f=_[_0x8f08('0x41')]({},_0x4e9b4f,_0x237729[_0x8f08('0x42')]);var _0x2142db={'where':_0x4e9b4f[_0x8f08('0x3e')]};return db[_0x8f08('0x2d')][_0x8f08('0x1e')](_0x2142db)[_0x8f08('0x25')](function(_0x467764){_0x918610['count']=_0x467764;if(_0x237729[_0x8f08('0x33')][_0x8f08('0x43')]){_0x4e9b4f[_0x8f08('0x44')]=[{'all':!![]}];}return db[_0x8f08('0x2d')][_0x8f08('0x45')](_0x4e9b4f);})[_0x8f08('0x25')](function(_0x3e0551){_0x918610[_0x8f08('0x46')]=_0x3e0551;return _0x918610;})['then'](respondWithFilteredResult(_0x3d9754,_0x4e9b4f))['catch'](handleError(_0x3d9754,null));};exports[_0x8f08('0x47')]=function(_0x23a561,_0x3c136b){var _0x471463={'raw':![],'where':{'id':_0x23a561[_0x8f08('0x48')]['id']}},_0x1d6895={};_0x1d6895['model']=_[_0x8f08('0x49')](db['Automation'][_0x8f08('0x2e')]);_0x1d6895[_0x8f08('0x33')]=_['keys'](_0x23a561[_0x8f08('0x33')]);_0x1d6895['filters']=_[_0x8f08('0x34')](_0x1d6895[_0x8f08('0x32')],_0x1d6895[_0x8f08('0x33')]);_0x471463['attributes']=_[_0x8f08('0x34')](_0x1d6895[_0x8f08('0x32')],qs[_0x8f08('0x35')](_0x23a561[_0x8f08('0x33')]['fields']));_0x471463['attributes']=_0x471463[_0x8f08('0x36')][_0x8f08('0x37')]?_0x471463[_0x8f08('0x36')]:_0x1d6895['model'];if(_0x23a561[_0x8f08('0x33')]['includeAll']){_0x471463[_0x8f08('0x44')]=[{'all':!![]}];}_0x471463=_[_0x8f08('0x41')]({},_0x471463,_0x23a561[_0x8f08('0x42')]);return db[_0x8f08('0x2d')][_0x8f08('0x4a')](_0x471463)[_0x8f08('0x25')](handleEntityNotFound(_0x3c136b,null))[_0x8f08('0x25')](respondWithResult(_0x3c136b,null))[_0x8f08('0x4b')](handleError(_0x3c136b,null));};exports[_0x8f08('0x4c')]=function(_0x124f4a,_0xdea504){return db[_0x8f08('0x2d')][_0x8f08('0x4c')](_0x124f4a[_0x8f08('0x4d')],{})[_0x8f08('0x25')](respondWithResult(_0xdea504,0xc9))[_0x8f08('0x4b')](handleError(_0xdea504,null));};exports[_0x8f08('0x24')]=function(_0x137178,_0x4264ee){if(_0x137178[_0x8f08('0x4d')]['id']){delete _0x137178[_0x8f08('0x4d')]['id'];}return db[_0x8f08('0x2d')]['find']({'where':{'id':_0x137178['params']['id']}})['then'](handleEntityNotFound(_0x4264ee,null))['then'](saveUpdates(_0x137178[_0x8f08('0x4d')],null))['then'](respondWithResult(_0x4264ee,null))[_0x8f08('0x4b')](handleError(_0x4264ee,null));};exports[_0x8f08('0x26')]=function(_0x40bb10,_0x1f0bcf){return db['Automation']['find']({'where':{'id':_0x40bb10[_0x8f08('0x48')]['id']}})['then'](handleEntityNotFound(_0x1f0bcf,null))['then'](removeEntity(_0x1f0bcf,null))[_0x8f08('0x4b')](handleError(_0x1f0bcf,null));};exports[_0x8f08('0x4e')]=function(_0x37d7ed,_0x45b964,_0x42e6e4){return db[_0x8f08('0x4f')][_0x8f08('0x4a')]({'where':{'id':_0x37d7ed[_0x8f08('0x48')]['id']}})[_0x8f08('0x25')](handleEntityNotFound(_0x45b964,null))[_0x8f08('0x25')](function(_0x1bf224){if(_0x1bf224){return _0x1bf224[_0x8f08('0x4e')](_0x37d7ed[_0x8f08('0x4d')][_0x8f08('0x50')],_[_0x8f08('0x51')](_0x37d7ed[_0x8f08('0x4d')],['ids','id'])||{});}})[_0x8f08('0x25')](respondWithResult(_0x45b964,null))[_0x8f08('0x4b')](handleError(_0x45b964,null));};exports[_0x8f08('0x52')]=function(_0x48df09,_0x4e3c04,_0x43b4bc){var _0x590484={};var _0x1972e1={};var _0x229bd5;var _0x39cc14;return db[_0x8f08('0x2d')][_0x8f08('0x53')]({'where':{'id':_0x48df09[_0x8f08('0x48')]['id']}})[_0x8f08('0x25')](handleEntityNotFound(_0x4e3c04,null))[_0x8f08('0x25')](function(_0x54edc3){if(_0x54edc3){_0x229bd5=_0x54edc3;_0x1972e1[_0x8f08('0x32')]=_[_0x8f08('0x49')](db[_0x8f08('0x4f')]['rawAttributes']);_0x1972e1['query']=_[_0x8f08('0x49')](_0x48df09['query']);_0x1972e1[_0x8f08('0x3d')]=_[_0x8f08('0x34')](_0x1972e1[_0x8f08('0x32')],_0x1972e1[_0x8f08('0x33')]);_0x590484['attributes']=_[_0x8f08('0x34')](_0x1972e1[_0x8f08('0x32')],qs[_0x8f08('0x35')](_0x48df09[_0x8f08('0x33')]['fields']));_0x590484[_0x8f08('0x36')]=_0x590484['attributes'][_0x8f08('0x37')]?_0x590484[_0x8f08('0x36')]:_0x1972e1['model'];_0x590484[_0x8f08('0x3a')]=qs[_0x8f08('0x3b')](_0x48df09[_0x8f08('0x33')][_0x8f08('0x3b')]);_0x590484['where']=qs['filters'](_[_0x8f08('0x3c')](_0x48df09['query'],_0x1972e1[_0x8f08('0x3d')]));if(_0x48df09[_0x8f08('0x33')][_0x8f08('0x40')]){_0x590484[_0x8f08('0x3e')]=_[_0x8f08('0x41')](_0x590484[_0x8f08('0x3e')],{'$or':_[_0x8f08('0x2c')](_0x590484[_0x8f08('0x36')],function(_0x138229){var _0x305878={};_0x305878[_0x138229]={'$like':'%'+_0x48df09[_0x8f08('0x33')][_0x8f08('0x40')]+'%'};return _0x305878;})});}_0x590484=_[_0x8f08('0x41')]({},_0x590484,_0x48df09[_0x8f08('0x42')]);return _0x229bd5['getConditions'](_0x590484);}})[_0x8f08('0x25')](function(_0xc61745){if(_0xc61745){_0x39cc14=_0xc61745[_0x8f08('0x37')];if(!_0x48df09[_0x8f08('0x33')][_0x8f08('0x38')](_0x8f08('0x39'))){_0x590484[_0x8f08('0x1c')]=qs[_0x8f08('0x1c')](_0x48df09['query'][_0x8f08('0x1c')]);_0x590484[_0x8f08('0x1b')]=qs[_0x8f08('0x1b')](_0x48df09[_0x8f08('0x33')][_0x8f08('0x1b')]);}return _0x229bd5[_0x8f08('0x52')](_0x590484);}})['then'](function(_0x3f56a7){if(_0x3f56a7){return _0x3f56a7?{'count':_0x39cc14,'rows':_0x3f56a7}:null;}})[_0x8f08('0x25')](respondWithResult(_0x4e3c04,null))[_0x8f08('0x4b')](handleError(_0x4e3c04,null));};exports['addActions']=function(_0x44abf8,_0x4a04b3,_0x3bda49){return db[_0x8f08('0x54')][_0x8f08('0x4a')]({'where':{'id':_0x44abf8[_0x8f08('0x48')]['id']}})[_0x8f08('0x25')](handleEntityNotFound(_0x4a04b3,null))[_0x8f08('0x25')](function(_0x5e91ae){if(_0x5e91ae){return _0x5e91ae['addActions'](_0x44abf8[_0x8f08('0x4d')][_0x8f08('0x50')],_['omit'](_0x44abf8['body'],['ids','id'])||{});}})[_0x8f08('0x25')](respondWithResult(_0x4a04b3,null))['catch'](handleError(_0x4a04b3,null));};exports[_0x8f08('0x55')]=function(_0x4f0ef5,_0x4454ee,_0x1f3727){var _0x2da102={};var _0x39d3a1={};var _0x589f53;var _0x1e66e5;return db[_0x8f08('0x2d')][_0x8f08('0x53')]({'where':{'id':_0x4f0ef5[_0x8f08('0x48')]['id']}})[_0x8f08('0x25')](handleEntityNotFound(_0x4454ee,null))[_0x8f08('0x25')](function(_0x16d811){if(_0x16d811){_0x589f53=_0x16d811;_0x39d3a1[_0x8f08('0x32')]=_[_0x8f08('0x49')](db['Action'][_0x8f08('0x2e')]);_0x39d3a1['query']=_['keys'](_0x4f0ef5[_0x8f08('0x33')]);_0x39d3a1[_0x8f08('0x3d')]=_[_0x8f08('0x34')](_0x39d3a1[_0x8f08('0x32')],_0x39d3a1[_0x8f08('0x33')]);_0x2da102['attributes']=_['intersection'](_0x39d3a1[_0x8f08('0x32')],qs['fields'](_0x4f0ef5[_0x8f08('0x33')][_0x8f08('0x35')]));_0x2da102[_0x8f08('0x36')]=_0x2da102[_0x8f08('0x36')][_0x8f08('0x37')]?_0x2da102[_0x8f08('0x36')]:_0x39d3a1[_0x8f08('0x32')];_0x2da102['order']=qs[_0x8f08('0x3b')](_0x4f0ef5[_0x8f08('0x33')][_0x8f08('0x3b')]);_0x2da102[_0x8f08('0x3e')]=qs[_0x8f08('0x3d')](_[_0x8f08('0x3c')](_0x4f0ef5[_0x8f08('0x33')],_0x39d3a1[_0x8f08('0x3d')]));if(_0x4f0ef5[_0x8f08('0x33')]['filter']){_0x2da102[_0x8f08('0x3e')]=_[_0x8f08('0x41')](_0x2da102[_0x8f08('0x3e')],{'$or':_[_0x8f08('0x2c')](_0x2da102[_0x8f08('0x36')],function(_0x4c82ac){var _0x3da3d5={};_0x3da3d5[_0x4c82ac]={'$like':'%'+_0x4f0ef5[_0x8f08('0x33')]['filter']+'%'};return _0x3da3d5;})});}_0x2da102=_['merge']({},_0x2da102,_0x4f0ef5['options']);return _0x589f53[_0x8f08('0x55')](_0x2da102);}})[_0x8f08('0x25')](function(_0x42db96){if(_0x42db96){_0x1e66e5=_0x42db96[_0x8f08('0x37')];if(!_0x4f0ef5['query'][_0x8f08('0x38')]('nolimit')){_0x2da102[_0x8f08('0x1c')]=qs[_0x8f08('0x1c')](_0x4f0ef5[_0x8f08('0x33')][_0x8f08('0x1c')]);_0x2da102['offset']=qs[_0x8f08('0x1b')](_0x4f0ef5[_0x8f08('0x33')]['offset']);}return _0x589f53['getActions'](_0x2da102);}})[_0x8f08('0x25')](function(_0x2b7f1f){if(_0x2b7f1f){return _0x2b7f1f?{'count':_0x1e66e5,'rows':_0x2b7f1f}:null;}})[_0x8f08('0x25')](respondWithResult(_0x4454ee,null))[_0x8f08('0x4b')](handleError(_0x4454ee,null));};
\ No newline at end of file
+var _0x4b06=['find','catch','create','body','destroy','addConditions','Condition','getConditions','hasOwnProperty','addActions','omit','findOne','Action','getActions','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','path','fs-extra','lodash','squel','crypto','desk.js','to-csv','ioredis','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','sendStatus','status','end','json','undefined','count','offset','limit','set','apply','reject','save','then','error','stack','name','send','map','rawAttributes','fieldName','key','query','keys','filters','intersection','model','fields','attributes','length','nolimit','order','sort','where','pick','filter','merge','type','options','includeAll','include','Automation','findAll','rows','show','params'];(function(_0x5a1b6b,_0x320036){var _0xca9688=function(_0x315cb0){while(--_0x315cb0){_0x5a1b6b['push'](_0x5a1b6b['shift']());}};_0xca9688(++_0x320036);}(_0x4b06,0x101));var _0x64b0=function(_0x336d0f,_0x44101c){_0x336d0f=_0x336d0f-0x0;var _0x3a7e06=_0x4b06[_0x336d0f];return _0x3a7e06;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0x64b0('0x0'));var zipdir=require(_0x64b0('0x1'));var jsonpatch=require(_0x64b0('0x2'));var rp=require(_0x64b0('0x3'));var moment=require(_0x64b0('0x4'));var BPromise=require(_0x64b0('0x5'));var Mustache=require(_0x64b0('0x6'));var util=require('util');var path=require(_0x64b0('0x7'));var sox=require('sox');var csv=require('to-csv');var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0x64b0('0x8'));var _=require(_0x64b0('0x9'));var squel=require(_0x64b0('0xa'));var crypto=require(_0x64b0('0xb'));var jsforce=require('jsforce');var deskjs=require(_0x64b0('0xc'));var toCsv=require(_0x64b0('0xd'));var querystring=require('querystring');var Papa=require('papaparse');var Redis=require(_0x64b0('0xe'));var authService=require('../../components/auth/service');var qs=require('../../components/parsers/qs');var as=require(_0x64b0('0xf'));var hardwareService=require(_0x64b0('0x10'));var logger=require(_0x64b0('0x11'))('api');var utils=require(_0x64b0('0x12'));var config=require(_0x64b0('0x13'));var licenseUtil=require(_0x64b0('0x14'));var db=require(_0x64b0('0x15'))['db'];function respondWithStatusCode(_0x416c84,_0x4099cd){_0x4099cd=_0x4099cd||0xcc;return function(_0x16d28d){if(_0x16d28d){return _0x416c84[_0x64b0('0x16')](_0x4099cd);}return _0x416c84[_0x64b0('0x17')](_0x4099cd)[_0x64b0('0x18')]();};}function respondWithResult(_0x5ad2f0,_0x39a58b){_0x39a58b=_0x39a58b||0xc8;return function(_0x376e7f){if(_0x376e7f){return _0x5ad2f0[_0x64b0('0x17')](_0x39a58b)[_0x64b0('0x19')](_0x376e7f);}};}function respondWithFilteredResult(_0x9f8a9f,_0x23f7b3){return function(_0x491011){if(_0x491011){var _0x4bff5c=typeof _0x23f7b3['offset']===_0x64b0('0x1a')&&typeof _0x23f7b3['limit']===_0x64b0('0x1a');var _0x195cac=_0x491011[_0x64b0('0x1b')];var _0x3c3760=_0x4bff5c?0x0:_0x23f7b3['offset'];var _0x238182=_0x4bff5c?_0x491011['count']:_0x23f7b3[_0x64b0('0x1c')]+_0x23f7b3[_0x64b0('0x1d')];var _0x4e485c;if(_0x238182>=_0x195cac){_0x238182=_0x195cac;_0x4e485c=0xc8;}else{_0x4e485c=0xce;}_0x9f8a9f[_0x64b0('0x17')](_0x4e485c);return _0x9f8a9f[_0x64b0('0x1e')]('Content-Range',_0x3c3760+'-'+_0x238182+'/'+_0x195cac)[_0x64b0('0x19')](_0x491011);}return null;};}function patchUpdates(_0xc9e407){return function(_0x5f3960){try{jsonpatch[_0x64b0('0x1f')](_0x5f3960,_0xc9e407,!![]);}catch(_0x2b8460){return BPromise[_0x64b0('0x20')](_0x2b8460);}return _0x5f3960[_0x64b0('0x21')]();};}function saveUpdates(_0x2feeef,_0x1cb558){return function(_0x34fb1a){if(_0x34fb1a){return _0x34fb1a['update'](_0x2feeef)[_0x64b0('0x22')](function(_0x3711ca){return _0x3711ca;});}return null;};}function removeEntity(_0x4d331d,_0x54b136){return function(_0x5dadc4){if(_0x5dadc4){return _0x5dadc4['destroy']()[_0x64b0('0x22')](function(){_0x4d331d['status'](0xcc)['end']();});}};}function handleEntityNotFound(_0x3cf31d,_0x40bc8c){return function(_0x2a2e85){if(!_0x2a2e85){_0x3cf31d[_0x64b0('0x16')](0x194);}return _0x2a2e85;};}function handleError(_0x2791da,_0x29dbe2){_0x29dbe2=_0x29dbe2||0x1f4;return function(_0x2b644d){logger[_0x64b0('0x23')](_0x2b644d[_0x64b0('0x24')]);if(_0x2b644d[_0x64b0('0x25')]){delete _0x2b644d[_0x64b0('0x25')];}_0x2791da['status'](_0x29dbe2)[_0x64b0('0x26')](_0x2b644d);};}exports['index']=function(_0x4d9d4a,_0x50034d){var _0x2d581e={},_0x13bb18={},_0xa15acf={'count':0x0,'rows':[]};var _0x5f20fd=_[_0x64b0('0x27')](db['Automation'][_0x64b0('0x28')],function(_0x137d60){return{'name':_0x137d60[_0x64b0('0x29')],'type':_0x137d60['type'][_0x64b0('0x2a')]};});_0x13bb18['model']=_[_0x64b0('0x27')](_0x5f20fd,_0x64b0('0x25'));_0x13bb18[_0x64b0('0x2b')]=_[_0x64b0('0x2c')](_0x4d9d4a[_0x64b0('0x2b')]);_0x13bb18[_0x64b0('0x2d')]=_[_0x64b0('0x2e')](_0x13bb18['model'],_0x13bb18[_0x64b0('0x2b')]);_0x2d581e['attributes']=_[_0x64b0('0x2e')](_0x13bb18[_0x64b0('0x2f')],qs[_0x64b0('0x30')](_0x4d9d4a[_0x64b0('0x2b')][_0x64b0('0x30')]));_0x2d581e[_0x64b0('0x31')]=_0x2d581e[_0x64b0('0x31')][_0x64b0('0x32')]?_0x2d581e['attributes']:_0x13bb18['model'];if(!_0x4d9d4a[_0x64b0('0x2b')]['hasOwnProperty'](_0x64b0('0x33'))){_0x2d581e[_0x64b0('0x1d')]=qs[_0x64b0('0x1d')](_0x4d9d4a[_0x64b0('0x2b')][_0x64b0('0x1d')]);_0x2d581e[_0x64b0('0x1c')]=qs[_0x64b0('0x1c')](_0x4d9d4a['query'][_0x64b0('0x1c')]);}_0x2d581e[_0x64b0('0x34')]=qs[_0x64b0('0x35')](_0x4d9d4a[_0x64b0('0x2b')][_0x64b0('0x35')]);_0x2d581e[_0x64b0('0x36')]=qs['filters'](_[_0x64b0('0x37')](_0x4d9d4a[_0x64b0('0x2b')],_0x13bb18[_0x64b0('0x2d')]),_0x5f20fd);if(_0x4d9d4a['query'][_0x64b0('0x38')]){_0x2d581e['where']=_[_0x64b0('0x39')](_0x2d581e['where'],{'$or':_[_0x64b0('0x27')](_0x5f20fd,function(_0x352186){if(_0x352186[_0x64b0('0x3a')]!=='VIRTUAL'){var _0x360644={};_0x360644[_0x352186['name']]={'$like':'%'+_0x4d9d4a[_0x64b0('0x2b')]['filter']+'%'};return _0x360644;}})});}_0x2d581e=_[_0x64b0('0x39')]({},_0x2d581e,_0x4d9d4a[_0x64b0('0x3b')]);var _0x520b49={'where':_0x2d581e[_0x64b0('0x36')]};return db['Automation']['count'](_0x520b49)['then'](function(_0x27c543){_0xa15acf['count']=_0x27c543;if(_0x4d9d4a[_0x64b0('0x2b')][_0x64b0('0x3c')]){_0x2d581e[_0x64b0('0x3d')]=[{'all':!![]}];}return db[_0x64b0('0x3e')][_0x64b0('0x3f')](_0x2d581e);})[_0x64b0('0x22')](function(_0x5f0577){_0xa15acf[_0x64b0('0x40')]=_0x5f0577;return _0xa15acf;})['then'](respondWithFilteredResult(_0x50034d,_0x2d581e))['catch'](handleError(_0x50034d,null));};exports[_0x64b0('0x41')]=function(_0x9a291b,_0x2a7116){var _0x89bed7={'raw':![],'where':{'id':_0x9a291b[_0x64b0('0x42')]['id']}},_0x1288fa={};_0x1288fa[_0x64b0('0x2f')]=_[_0x64b0('0x2c')](db['Automation'][_0x64b0('0x28')]);_0x1288fa[_0x64b0('0x2b')]=_[_0x64b0('0x2c')](_0x9a291b[_0x64b0('0x2b')]);_0x1288fa['filters']=_['intersection'](_0x1288fa[_0x64b0('0x2f')],_0x1288fa[_0x64b0('0x2b')]);_0x89bed7['attributes']=_['intersection'](_0x1288fa['model'],qs[_0x64b0('0x30')](_0x9a291b[_0x64b0('0x2b')]['fields']));_0x89bed7[_0x64b0('0x31')]=_0x89bed7[_0x64b0('0x31')]['length']?_0x89bed7['attributes']:_0x1288fa['model'];if(_0x9a291b[_0x64b0('0x2b')][_0x64b0('0x3c')]){_0x89bed7[_0x64b0('0x3d')]=[{'all':!![]}];}_0x89bed7=_[_0x64b0('0x39')]({},_0x89bed7,_0x9a291b['options']);return db[_0x64b0('0x3e')][_0x64b0('0x43')](_0x89bed7)[_0x64b0('0x22')](handleEntityNotFound(_0x2a7116,null))[_0x64b0('0x22')](respondWithResult(_0x2a7116,null))[_0x64b0('0x44')](handleError(_0x2a7116,null));};exports[_0x64b0('0x45')]=function(_0x55834b,_0x1941ec){return db[_0x64b0('0x3e')][_0x64b0('0x45')](_0x55834b[_0x64b0('0x46')],{})[_0x64b0('0x22')](respondWithResult(_0x1941ec,0xc9))[_0x64b0('0x44')](handleError(_0x1941ec,null));};exports['update']=function(_0x1e7f88,_0x31411b){if(_0x1e7f88[_0x64b0('0x46')]['id']){delete _0x1e7f88[_0x64b0('0x46')]['id'];}return db[_0x64b0('0x3e')]['find']({'where':{'id':_0x1e7f88[_0x64b0('0x42')]['id']}})[_0x64b0('0x22')](handleEntityNotFound(_0x31411b,null))[_0x64b0('0x22')](saveUpdates(_0x1e7f88[_0x64b0('0x46')],null))[_0x64b0('0x22')](respondWithResult(_0x31411b,null))[_0x64b0('0x44')](handleError(_0x31411b,null));};exports[_0x64b0('0x47')]=function(_0x49b184,_0x187406){return db['Automation'][_0x64b0('0x43')]({'where':{'id':_0x49b184[_0x64b0('0x42')]['id']}})[_0x64b0('0x22')](handleEntityNotFound(_0x187406,null))[_0x64b0('0x22')](removeEntity(_0x187406,null))['catch'](handleError(_0x187406,null));};exports[_0x64b0('0x48')]=function(_0x24ba92,_0x26cc31,_0x55ac7f){return db[_0x64b0('0x49')]['find']({'where':{'id':_0x24ba92[_0x64b0('0x42')]['id']}})[_0x64b0('0x22')](handleEntityNotFound(_0x26cc31,null))[_0x64b0('0x22')](function(_0x34b09d){if(_0x34b09d){return _0x34b09d[_0x64b0('0x48')](_0x24ba92[_0x64b0('0x46')]['ids'],_['omit'](_0x24ba92['body'],['ids','id'])||{});}})[_0x64b0('0x22')](respondWithResult(_0x26cc31,null))[_0x64b0('0x44')](handleError(_0x26cc31,null));};exports[_0x64b0('0x4a')]=function(_0x5b5cd6,_0x298258,_0x3f01a3){var _0x32be94={};var _0x238f9f={};var _0x3d9a72;var _0x226cd2;return db[_0x64b0('0x3e')]['findOne']({'where':{'id':_0x5b5cd6[_0x64b0('0x42')]['id']}})[_0x64b0('0x22')](handleEntityNotFound(_0x298258,null))['then'](function(_0x398fd7){if(_0x398fd7){_0x3d9a72=_0x398fd7;_0x238f9f[_0x64b0('0x2f')]=_[_0x64b0('0x2c')](db[_0x64b0('0x49')][_0x64b0('0x28')]);_0x238f9f[_0x64b0('0x2b')]=_[_0x64b0('0x2c')](_0x5b5cd6[_0x64b0('0x2b')]);_0x238f9f[_0x64b0('0x2d')]=_[_0x64b0('0x2e')](_0x238f9f['model'],_0x238f9f['query']);_0x32be94[_0x64b0('0x31')]=_[_0x64b0('0x2e')](_0x238f9f['model'],qs[_0x64b0('0x30')](_0x5b5cd6[_0x64b0('0x2b')][_0x64b0('0x30')]));_0x32be94[_0x64b0('0x31')]=_0x32be94['attributes']['length']?_0x32be94['attributes']:_0x238f9f[_0x64b0('0x2f')];_0x32be94[_0x64b0('0x34')]=qs[_0x64b0('0x35')](_0x5b5cd6[_0x64b0('0x2b')][_0x64b0('0x35')]);_0x32be94[_0x64b0('0x36')]=qs[_0x64b0('0x2d')](_[_0x64b0('0x37')](_0x5b5cd6['query'],_0x238f9f['filters']));if(_0x5b5cd6[_0x64b0('0x2b')][_0x64b0('0x38')]){_0x32be94[_0x64b0('0x36')]=_['merge'](_0x32be94[_0x64b0('0x36')],{'$or':_[_0x64b0('0x27')](_0x32be94[_0x64b0('0x31')],function(_0x338997){var _0x31c801={};_0x31c801[_0x338997]={'$like':'%'+_0x5b5cd6[_0x64b0('0x2b')][_0x64b0('0x38')]+'%'};return _0x31c801;})});}_0x32be94=_[_0x64b0('0x39')]({},_0x32be94,_0x5b5cd6[_0x64b0('0x3b')]);return _0x3d9a72[_0x64b0('0x4a')](_0x32be94);}})[_0x64b0('0x22')](function(_0x143f2f){if(_0x143f2f){_0x226cd2=_0x143f2f['length'];if(!_0x5b5cd6['query'][_0x64b0('0x4b')](_0x64b0('0x33'))){_0x32be94[_0x64b0('0x1d')]=qs[_0x64b0('0x1d')](_0x5b5cd6[_0x64b0('0x2b')][_0x64b0('0x1d')]);_0x32be94[_0x64b0('0x1c')]=qs[_0x64b0('0x1c')](_0x5b5cd6[_0x64b0('0x2b')][_0x64b0('0x1c')]);}return _0x3d9a72['getConditions'](_0x32be94);}})[_0x64b0('0x22')](function(_0x170873){if(_0x170873){return _0x170873?{'count':_0x226cd2,'rows':_0x170873}:null;}})[_0x64b0('0x22')](respondWithResult(_0x298258,null))[_0x64b0('0x44')](handleError(_0x298258,null));};exports[_0x64b0('0x4c')]=function(_0x154ab3,_0x180079,_0x1a56c7){return db['Action'][_0x64b0('0x43')]({'where':{'id':_0x154ab3[_0x64b0('0x42')]['id']}})[_0x64b0('0x22')](handleEntityNotFound(_0x180079,null))[_0x64b0('0x22')](function(_0x3df816){if(_0x3df816){return _0x3df816[_0x64b0('0x4c')](_0x154ab3[_0x64b0('0x46')]['ids'],_[_0x64b0('0x4d')](_0x154ab3[_0x64b0('0x46')],['ids','id'])||{});}})['then'](respondWithResult(_0x180079,null))[_0x64b0('0x44')](handleError(_0x180079,null));};exports['getActions']=function(_0x2c4e89,_0x46068c,_0x46bf49){var _0x348fbf={};var _0x36ee1a={};var _0xa2bc22;var _0x17f495;return db[_0x64b0('0x3e')][_0x64b0('0x4e')]({'where':{'id':_0x2c4e89['params']['id']}})['then'](handleEntityNotFound(_0x46068c,null))[_0x64b0('0x22')](function(_0x84b72b){if(_0x84b72b){_0xa2bc22=_0x84b72b;_0x36ee1a['model']=_['keys'](db[_0x64b0('0x4f')][_0x64b0('0x28')]);_0x36ee1a['query']=_[_0x64b0('0x2c')](_0x2c4e89[_0x64b0('0x2b')]);_0x36ee1a['filters']=_['intersection'](_0x36ee1a[_0x64b0('0x2f')],_0x36ee1a[_0x64b0('0x2b')]);_0x348fbf['attributes']=_[_0x64b0('0x2e')](_0x36ee1a[_0x64b0('0x2f')],qs[_0x64b0('0x30')](_0x2c4e89[_0x64b0('0x2b')]['fields']));_0x348fbf['attributes']=_0x348fbf['attributes'][_0x64b0('0x32')]?_0x348fbf[_0x64b0('0x31')]:_0x36ee1a['model'];_0x348fbf[_0x64b0('0x34')]=qs[_0x64b0('0x35')](_0x2c4e89[_0x64b0('0x2b')][_0x64b0('0x35')]);_0x348fbf[_0x64b0('0x36')]=qs[_0x64b0('0x2d')](_[_0x64b0('0x37')](_0x2c4e89[_0x64b0('0x2b')],_0x36ee1a['filters']));if(_0x2c4e89[_0x64b0('0x2b')][_0x64b0('0x38')]){_0x348fbf[_0x64b0('0x36')]=_['merge'](_0x348fbf[_0x64b0('0x36')],{'$or':_[_0x64b0('0x27')](_0x348fbf[_0x64b0('0x31')],function(_0x2711e3){var _0x554290={};_0x554290[_0x2711e3]={'$like':'%'+_0x2c4e89[_0x64b0('0x2b')]['filter']+'%'};return _0x554290;})});}_0x348fbf=_[_0x64b0('0x39')]({},_0x348fbf,_0x2c4e89[_0x64b0('0x3b')]);return _0xa2bc22[_0x64b0('0x50')](_0x348fbf);}})[_0x64b0('0x22')](function(_0x229302){if(_0x229302){_0x17f495=_0x229302[_0x64b0('0x32')];if(!_0x2c4e89[_0x64b0('0x2b')]['hasOwnProperty']('nolimit')){_0x348fbf['limit']=qs[_0x64b0('0x1d')](_0x2c4e89[_0x64b0('0x2b')][_0x64b0('0x1d')]);_0x348fbf[_0x64b0('0x1c')]=qs[_0x64b0('0x1c')](_0x2c4e89['query']['offset']);}return _0xa2bc22['getActions'](_0x348fbf);}})[_0x64b0('0x22')](function(_0x47bbc7){if(_0x47bbc7){return _0x47bbc7?{'count':_0x17f495,'rows':_0x47bbc7}:null;}})[_0x64b0('0x22')](respondWithResult(_0x46068c,null))[_0x64b0('0x44')](handleError(_0x46068c,null));};
\ No newline at end of file