Built motion from commit 092f8824.|2.5.49
[motion2.git] / server / api / automation / automation.controller.js
index e5ec79a..16a575f 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xb6fb=['zip-dir','fast-json-patch','request-promise','moment','mustache','util','path','sox','ejs','lodash','squel','jsforce','to-csv','querystring','papaparse','ioredis','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','sendStatus','status','end','offset','undefined','limit','count','set','Content-Range','json','apply','reject','save','then','destroy','error','send','index','map','Automation','type','key','model','name','query','keys','filters','intersection','fields','attributes','hasOwnProperty','sort','pick','filter','where','merge','VIRTUAL','options','findAll','rows','catch','show','rawAttributes','include','find','create','update','body','params','addConditions','Condition','ids','getConditions','findOne','length','order','nolimit','addActions','Action','omit','getActions','eml-format','rimraf'];(function(_0x138adb,_0x193fee){var _0x1b27f2=function(_0x5e97a2){while(--_0x5e97a2){_0x138adb['push'](_0x138adb['shift']());}};_0x1b27f2(++_0x193fee);}(_0xb6fb,0x1b6));var _0xbb6f=function(_0x1543d,_0x13d9eb){_0x1543d=_0x1543d-0x0;var _0x4dd719=_0xb6fb[_0x1543d];return _0x4dd719;};'use strict';var emlformat=require(_0xbb6f('0x0'));var rimraf=require(_0xbb6f('0x1'));var zipdir=require(_0xbb6f('0x2'));var jsonpatch=require(_0xbb6f('0x3'));var rp=require(_0xbb6f('0x4'));var moment=require(_0xbb6f('0x5'));var BPromise=require('bluebird');var Mustache=require(_0xbb6f('0x6'));var util=require(_0xbb6f('0x7'));var path=require(_0xbb6f('0x8'));var sox=require(_0xbb6f('0x9'));var csv=require('to-csv');var ejs=require(_0xbb6f('0xa'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0xbb6f('0xb'));var squel=require(_0xbb6f('0xc'));var crypto=require('crypto');var jsforce=require(_0xbb6f('0xd'));var deskjs=require('desk.js');var toCsv=require(_0xbb6f('0xe'));var querystring=require(_0xbb6f('0xf'));var Papa=require(_0xbb6f('0x10'));var Redis=require(_0xbb6f('0x11'));var authService=require('../../components/auth/service');var qs=require(_0xbb6f('0x12'));var as=require(_0xbb6f('0x13'));var hardwareService=require(_0xbb6f('0x14'));var logger=require(_0xbb6f('0x15'))(_0xbb6f('0x16'));var utils=require(_0xbb6f('0x17'));var config=require(_0xbb6f('0x18'));var licenseUtil=require(_0xbb6f('0x19'));var db=require(_0xbb6f('0x1a'))['db'];function respondWithStatusCode(_0x215091,_0x13eede){_0x13eede=_0x13eede||0xcc;return function(_0x292753){if(_0x292753){return _0x215091[_0xbb6f('0x1b')](_0x13eede);}return _0x215091[_0xbb6f('0x1c')](_0x13eede)[_0xbb6f('0x1d')]();};}function respondWithResult(_0x58032d,_0x447b1b){_0x447b1b=_0x447b1b||0xc8;return function(_0x31946c){if(_0x31946c){return _0x58032d[_0xbb6f('0x1c')](_0x447b1b)['json'](_0x31946c);}};}function respondWithFilteredResult(_0x4d9c84,_0x214823){return function(_0x25d354){if(_0x25d354){var _0x15c647=typeof _0x214823[_0xbb6f('0x1e')]===_0xbb6f('0x1f')&&typeof _0x214823[_0xbb6f('0x20')]==='undefined';var _0x5eeb93=_0x25d354[_0xbb6f('0x21')];var _0x4cf242=_0x15c647?0x0:_0x214823[_0xbb6f('0x1e')];var _0x3da0b6=_0x15c647?_0x25d354['count']:_0x214823[_0xbb6f('0x1e')]+_0x214823[_0xbb6f('0x20')];var _0x449793;if(_0x3da0b6>=_0x5eeb93){_0x3da0b6=_0x5eeb93;_0x449793=0xc8;}else{_0x449793=0xce;}_0x4d9c84[_0xbb6f('0x1c')](_0x449793);return _0x4d9c84[_0xbb6f('0x22')](_0xbb6f('0x23'),_0x4cf242+'-'+_0x3da0b6+'/'+_0x5eeb93)[_0xbb6f('0x24')](_0x25d354);}return null;};}function patchUpdates(_0x345ffc){return function(_0x25f48e){try{jsonpatch[_0xbb6f('0x25')](_0x25f48e,_0x345ffc,!![]);}catch(_0x95a236){return BPromise[_0xbb6f('0x26')](_0x95a236);}return _0x25f48e[_0xbb6f('0x27')]();};}function saveUpdates(_0x550013,_0x51f891){return function(_0x2e9481){if(_0x2e9481){return _0x2e9481['update'](_0x550013)[_0xbb6f('0x28')](function(_0x3d09cb){return _0x3d09cb;});}return null;};}function removeEntity(_0x26d66d,_0xe49c6e){return function(_0xe63aed){if(_0xe63aed){return _0xe63aed[_0xbb6f('0x29')]()[_0xbb6f('0x28')](function(){_0x26d66d['status'](0xcc)[_0xbb6f('0x1d')]();});}};}function handleEntityNotFound(_0x4751c3,_0x2996cf){return function(_0x3723f5){if(!_0x3723f5){_0x4751c3[_0xbb6f('0x1b')](0x194);}return _0x3723f5;};}function handleError(_0x2d42d8,_0x44a31b){_0x44a31b=_0x44a31b||0x1f4;return function(_0x156b1d){logger[_0xbb6f('0x2a')](_0x156b1d['stack']);if(_0x156b1d['name']){delete _0x156b1d['name'];}_0x2d42d8['status'](_0x44a31b)[_0xbb6f('0x2b')](_0x156b1d);};}exports[_0xbb6f('0x2c')]=function(_0x435d35,_0x35575f){var _0x2a8e18={},_0x4fdac0={},_0x4aa37a={'count':0x0,'rows':[]};var _0x574ef8=_[_0xbb6f('0x2d')](db[_0xbb6f('0x2e')]['rawAttributes'],function(_0x4e81cd){return{'name':_0x4e81cd['fieldName'],'type':_0x4e81cd[_0xbb6f('0x2f')][_0xbb6f('0x30')]};});_0x4fdac0[_0xbb6f('0x31')]=_[_0xbb6f('0x2d')](_0x574ef8,_0xbb6f('0x32'));_0x4fdac0[_0xbb6f('0x33')]=_[_0xbb6f('0x34')](_0x435d35[_0xbb6f('0x33')]);_0x4fdac0[_0xbb6f('0x35')]=_[_0xbb6f('0x36')](_0x4fdac0[_0xbb6f('0x31')],_0x4fdac0[_0xbb6f('0x33')]);_0x2a8e18['attributes']=_['intersection'](_0x4fdac0['model'],qs[_0xbb6f('0x37')](_0x435d35[_0xbb6f('0x33')][_0xbb6f('0x37')]));_0x2a8e18[_0xbb6f('0x38')]=_0x2a8e18[_0xbb6f('0x38')]['length']?_0x2a8e18[_0xbb6f('0x38')]:_0x4fdac0[_0xbb6f('0x31')];if(!_0x435d35[_0xbb6f('0x33')][_0xbb6f('0x39')]('nolimit')){_0x2a8e18[_0xbb6f('0x20')]=qs[_0xbb6f('0x20')](_0x435d35[_0xbb6f('0x33')][_0xbb6f('0x20')]);_0x2a8e18['offset']=qs[_0xbb6f('0x1e')](_0x435d35[_0xbb6f('0x33')][_0xbb6f('0x1e')]);}_0x2a8e18['order']=qs['sort'](_0x435d35[_0xbb6f('0x33')][_0xbb6f('0x3a')]);_0x2a8e18['where']=qs[_0xbb6f('0x35')](_[_0xbb6f('0x3b')](_0x435d35[_0xbb6f('0x33')],_0x4fdac0['filters']),_0x574ef8);if(_0x435d35[_0xbb6f('0x33')][_0xbb6f('0x3c')]){_0x2a8e18[_0xbb6f('0x3d')]=_[_0xbb6f('0x3e')](_0x2a8e18['where'],{'$or':_['map'](_0x574ef8,function(_0x57fbab){if(_0x57fbab['type']!==_0xbb6f('0x3f')){var _0x3c0b17={};_0x3c0b17[_0x57fbab[_0xbb6f('0x32')]]={'$like':'%'+_0x435d35[_0xbb6f('0x33')][_0xbb6f('0x3c')]+'%'};return _0x3c0b17;}})});}_0x2a8e18=_[_0xbb6f('0x3e')]({},_0x2a8e18,_0x435d35[_0xbb6f('0x40')]);var _0x5605dd={'where':_0x2a8e18[_0xbb6f('0x3d')]};return db['Automation'][_0xbb6f('0x21')](_0x5605dd)['then'](function(_0x200f46){_0x4aa37a['count']=_0x200f46;if(_0x435d35['query']['includeAll']){_0x2a8e18['include']=[{'all':!![]}];}return db[_0xbb6f('0x2e')][_0xbb6f('0x41')](_0x2a8e18);})[_0xbb6f('0x28')](function(_0x352115){_0x4aa37a[_0xbb6f('0x42')]=_0x352115;return _0x4aa37a;})[_0xbb6f('0x28')](respondWithFilteredResult(_0x35575f,_0x2a8e18))[_0xbb6f('0x43')](handleError(_0x35575f,null));};exports[_0xbb6f('0x44')]=function(_0x124563,_0x2e449b){var _0x3a60b7={'raw':![],'where':{'id':_0x124563['params']['id']}},_0x2333d9={};_0x2333d9[_0xbb6f('0x31')]=_[_0xbb6f('0x34')](db[_0xbb6f('0x2e')][_0xbb6f('0x45')]);_0x2333d9[_0xbb6f('0x33')]=_[_0xbb6f('0x34')](_0x124563[_0xbb6f('0x33')]);_0x2333d9['filters']=_[_0xbb6f('0x36')](_0x2333d9[_0xbb6f('0x31')],_0x2333d9['query']);_0x3a60b7[_0xbb6f('0x38')]=_[_0xbb6f('0x36')](_0x2333d9[_0xbb6f('0x31')],qs[_0xbb6f('0x37')](_0x124563[_0xbb6f('0x33')][_0xbb6f('0x37')]));_0x3a60b7[_0xbb6f('0x38')]=_0x3a60b7[_0xbb6f('0x38')]['length']?_0x3a60b7[_0xbb6f('0x38')]:_0x2333d9[_0xbb6f('0x31')];if(_0x124563[_0xbb6f('0x33')]['includeAll']){_0x3a60b7[_0xbb6f('0x46')]=[{'all':!![]}];}_0x3a60b7=_[_0xbb6f('0x3e')]({},_0x3a60b7,_0x124563[_0xbb6f('0x40')]);return db[_0xbb6f('0x2e')][_0xbb6f('0x47')](_0x3a60b7)['then'](handleEntityNotFound(_0x2e449b,null))[_0xbb6f('0x28')](respondWithResult(_0x2e449b,null))[_0xbb6f('0x43')](handleError(_0x2e449b,null));};exports[_0xbb6f('0x48')]=function(_0x5e21f6,_0x2e8d06){return db[_0xbb6f('0x2e')][_0xbb6f('0x48')](_0x5e21f6['body'],{})[_0xbb6f('0x28')](respondWithResult(_0x2e8d06,0xc9))[_0xbb6f('0x43')](handleError(_0x2e8d06,null));};exports[_0xbb6f('0x49')]=function(_0x26d3a1,_0x59e5f7){if(_0x26d3a1[_0xbb6f('0x4a')]['id']){delete _0x26d3a1[_0xbb6f('0x4a')]['id'];}return db[_0xbb6f('0x2e')][_0xbb6f('0x47')]({'where':{'id':_0x26d3a1['params']['id']}})['then'](handleEntityNotFound(_0x59e5f7,null))[_0xbb6f('0x28')](saveUpdates(_0x26d3a1[_0xbb6f('0x4a')],null))[_0xbb6f('0x28')](respondWithResult(_0x59e5f7,null))['catch'](handleError(_0x59e5f7,null));};exports[_0xbb6f('0x29')]=function(_0x57abc5,_0x4356bd){return db[_0xbb6f('0x2e')][_0xbb6f('0x47')]({'where':{'id':_0x57abc5[_0xbb6f('0x4b')]['id']}})['then'](handleEntityNotFound(_0x4356bd,null))[_0xbb6f('0x28')](removeEntity(_0x4356bd,null))[_0xbb6f('0x43')](handleError(_0x4356bd,null));};exports[_0xbb6f('0x4c')]=function(_0x43ab30,_0x598a5a,_0x2e8690){return db[_0xbb6f('0x4d')][_0xbb6f('0x47')]({'where':{'id':_0x43ab30[_0xbb6f('0x4b')]['id']}})['then'](handleEntityNotFound(_0x598a5a,null))[_0xbb6f('0x28')](function(_0x5b6da9){if(_0x5b6da9){return _0x5b6da9[_0xbb6f('0x4c')](_0x43ab30[_0xbb6f('0x4a')][_0xbb6f('0x4e')],_['omit'](_0x43ab30[_0xbb6f('0x4a')],[_0xbb6f('0x4e'),'id'])||{});}})[_0xbb6f('0x28')](respondWithResult(_0x598a5a,null))['catch'](handleError(_0x598a5a,null));};exports[_0xbb6f('0x4f')]=function(_0x3a1db5,_0x20b08c,_0x5675b5){var _0x5362a3={};var _0x143dae={};var _0x51400f;var _0x2f4d89;return db['Automation'][_0xbb6f('0x50')]({'where':{'id':_0x3a1db5[_0xbb6f('0x4b')]['id']}})[_0xbb6f('0x28')](handleEntityNotFound(_0x20b08c,null))[_0xbb6f('0x28')](function(_0x274960){if(_0x274960){_0x51400f=_0x274960;_0x143dae['model']=_[_0xbb6f('0x34')](db[_0xbb6f('0x4d')][_0xbb6f('0x45')]);_0x143dae[_0xbb6f('0x33')]=_[_0xbb6f('0x34')](_0x3a1db5[_0xbb6f('0x33')]);_0x143dae['filters']=_['intersection'](_0x143dae['model'],_0x143dae[_0xbb6f('0x33')]);_0x5362a3['attributes']=_['intersection'](_0x143dae[_0xbb6f('0x31')],qs[_0xbb6f('0x37')](_0x3a1db5[_0xbb6f('0x33')][_0xbb6f('0x37')]));_0x5362a3[_0xbb6f('0x38')]=_0x5362a3['attributes'][_0xbb6f('0x51')]?_0x5362a3[_0xbb6f('0x38')]:_0x143dae[_0xbb6f('0x31')];_0x5362a3[_0xbb6f('0x52')]=qs[_0xbb6f('0x3a')](_0x3a1db5['query'][_0xbb6f('0x3a')]);_0x5362a3['where']=qs[_0xbb6f('0x35')](_[_0xbb6f('0x3b')](_0x3a1db5[_0xbb6f('0x33')],_0x143dae[_0xbb6f('0x35')]));if(_0x3a1db5[_0xbb6f('0x33')][_0xbb6f('0x3c')]){_0x5362a3['where']=_[_0xbb6f('0x3e')](_0x5362a3[_0xbb6f('0x3d')],{'$or':_[_0xbb6f('0x2d')](_0x5362a3[_0xbb6f('0x38')],function(_0x167542){var _0x386aab={};_0x386aab[_0x167542]={'$like':'%'+_0x3a1db5['query'][_0xbb6f('0x3c')]+'%'};return _0x386aab;})});}_0x5362a3=_[_0xbb6f('0x3e')]({},_0x5362a3,_0x3a1db5[_0xbb6f('0x40')]);return _0x51400f['getConditions'](_0x5362a3);}})[_0xbb6f('0x28')](function(_0x21ffc1){if(_0x21ffc1){_0x2f4d89=_0x21ffc1[_0xbb6f('0x51')];if(!_0x3a1db5['query'][_0xbb6f('0x39')](_0xbb6f('0x53'))){_0x5362a3[_0xbb6f('0x20')]=qs[_0xbb6f('0x20')](_0x3a1db5[_0xbb6f('0x33')][_0xbb6f('0x20')]);_0x5362a3['offset']=qs['offset'](_0x3a1db5['query'][_0xbb6f('0x1e')]);}return _0x51400f['getConditions'](_0x5362a3);}})[_0xbb6f('0x28')](function(_0x4d0e75){if(_0x4d0e75){return _0x4d0e75?{'count':_0x2f4d89,'rows':_0x4d0e75}:null;}})[_0xbb6f('0x28')](respondWithResult(_0x20b08c,null))[_0xbb6f('0x43')](handleError(_0x20b08c,null));};exports[_0xbb6f('0x54')]=function(_0x5e5b80,_0x160723,_0x1671f4){return db[_0xbb6f('0x55')][_0xbb6f('0x47')]({'where':{'id':_0x5e5b80[_0xbb6f('0x4b')]['id']}})[_0xbb6f('0x28')](handleEntityNotFound(_0x160723,null))['then'](function(_0x48ba05){if(_0x48ba05){return _0x48ba05[_0xbb6f('0x54')](_0x5e5b80[_0xbb6f('0x4a')][_0xbb6f('0x4e')],_[_0xbb6f('0x56')](_0x5e5b80[_0xbb6f('0x4a')],['ids','id'])||{});}})[_0xbb6f('0x28')](respondWithResult(_0x160723,null))[_0xbb6f('0x43')](handleError(_0x160723,null));};exports[_0xbb6f('0x57')]=function(_0x39fc2b,_0x5e5842,_0xca2905){var _0x62716={};var _0x10c8bd={};var _0x597220;var _0x206047;return db[_0xbb6f('0x2e')]['findOne']({'where':{'id':_0x39fc2b[_0xbb6f('0x4b')]['id']}})[_0xbb6f('0x28')](handleEntityNotFound(_0x5e5842,null))['then'](function(_0x49cc26){if(_0x49cc26){_0x597220=_0x49cc26;_0x10c8bd['model']=_[_0xbb6f('0x34')](db[_0xbb6f('0x55')][_0xbb6f('0x45')]);_0x10c8bd[_0xbb6f('0x33')]=_[_0xbb6f('0x34')](_0x39fc2b[_0xbb6f('0x33')]);_0x10c8bd[_0xbb6f('0x35')]=_[_0xbb6f('0x36')](_0x10c8bd[_0xbb6f('0x31')],_0x10c8bd[_0xbb6f('0x33')]);_0x62716[_0xbb6f('0x38')]=_[_0xbb6f('0x36')](_0x10c8bd['model'],qs['fields'](_0x39fc2b[_0xbb6f('0x33')]['fields']));_0x62716[_0xbb6f('0x38')]=_0x62716['attributes'][_0xbb6f('0x51')]?_0x62716[_0xbb6f('0x38')]:_0x10c8bd[_0xbb6f('0x31')];_0x62716[_0xbb6f('0x52')]=qs[_0xbb6f('0x3a')](_0x39fc2b[_0xbb6f('0x33')][_0xbb6f('0x3a')]);_0x62716[_0xbb6f('0x3d')]=qs['filters'](_[_0xbb6f('0x3b')](_0x39fc2b[_0xbb6f('0x33')],_0x10c8bd['filters']));if(_0x39fc2b[_0xbb6f('0x33')][_0xbb6f('0x3c')]){_0x62716[_0xbb6f('0x3d')]=_[_0xbb6f('0x3e')](_0x62716[_0xbb6f('0x3d')],{'$or':_[_0xbb6f('0x2d')](_0x62716[_0xbb6f('0x38')],function(_0x25661a){var _0x6a0869={};_0x6a0869[_0x25661a]={'$like':'%'+_0x39fc2b['query']['filter']+'%'};return _0x6a0869;})});}_0x62716=_[_0xbb6f('0x3e')]({},_0x62716,_0x39fc2b[_0xbb6f('0x40')]);return _0x597220['getActions'](_0x62716);}})[_0xbb6f('0x28')](function(_0x3d643d){if(_0x3d643d){_0x206047=_0x3d643d[_0xbb6f('0x51')];if(!_0x39fc2b[_0xbb6f('0x33')]['hasOwnProperty'](_0xbb6f('0x53'))){_0x62716['limit']=qs[_0xbb6f('0x20')](_0x39fc2b[_0xbb6f('0x33')][_0xbb6f('0x20')]);_0x62716[_0xbb6f('0x1e')]=qs['offset'](_0x39fc2b[_0xbb6f('0x33')]['offset']);}return _0x597220[_0xbb6f('0x57')](_0x62716);}})[_0xbb6f('0x28')](function(_0x48fe67){if(_0x48fe67){return _0x48fe67?{'count':_0x206047,'rows':_0x48fe67}:null;}})[_0xbb6f('0x28')](respondWithResult(_0x5e5842,null))[_0xbb6f('0x43')](handleError(_0x5e5842,null));};
\ No newline at end of file
+var _0x9ce6=['../../config/environment','sendStatus','status','end','json','offset','limit','undefined','count','set','Content-Range','apply','reject','save','then','destroy','name','send','index','map','Automation','rawAttributes','type','key','model','keys','filters','intersection','query','attributes','fields','hasOwnProperty','nolimit','sort','where','filter','merge','VIRTUAL','includeAll','include','findAll','rows','catch','show','params','options','create','body','update','find','addConditions','ids','getConditions','findOne','length','order','pick','addActions','Action','omit','getActions','eml-format','fast-json-patch','request-promise','moment','bluebird','mustache','path','sox','ejs','lodash','squel','crypto','jsforce','desk.js','to-csv','querystring','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils'];(function(_0x52c7bd,_0x407c0a){var _0x4f8660=function(_0x6ddf4a){while(--_0x6ddf4a){_0x52c7bd['push'](_0x52c7bd['shift']());}};_0x4f8660(++_0x407c0a);}(_0x9ce6,0x92));var _0x69ce=function(_0x385e3a,_0x2a7f5f){_0x385e3a=_0x385e3a-0x0;var _0x1e07fd=_0x9ce6[_0x385e3a];return _0x1e07fd;};'use strict';var emlformat=require(_0x69ce('0x0'));var rimraf=require('rimraf');var zipdir=require('zip-dir');var jsonpatch=require(_0x69ce('0x1'));var rp=require(_0x69ce('0x2'));var moment=require(_0x69ce('0x3'));var BPromise=require(_0x69ce('0x4'));var Mustache=require(_0x69ce('0x5'));var util=require('util');var path=require(_0x69ce('0x6'));var sox=require(_0x69ce('0x7'));var csv=require('to-csv');var ejs=require(_0x69ce('0x8'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0x69ce('0x9'));var squel=require(_0x69ce('0xa'));var crypto=require(_0x69ce('0xb'));var jsforce=require(_0x69ce('0xc'));var deskjs=require(_0x69ce('0xd'));var toCsv=require(_0x69ce('0xe'));var querystring=require(_0x69ce('0xf'));var Papa=require('papaparse');var Redis=require(_0x69ce('0x10'));var authService=require(_0x69ce('0x11'));var qs=require(_0x69ce('0x12'));var as=require(_0x69ce('0x13'));var hardwareService=require(_0x69ce('0x14'));var logger=require(_0x69ce('0x15'))(_0x69ce('0x16'));var utils=require(_0x69ce('0x17'));var config=require(_0x69ce('0x18'));var licenseUtil=require('../../config/license/util');var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x43626e,_0x235f48){_0x235f48=_0x235f48||0xcc;return function(_0x727782){if(_0x727782){return _0x43626e[_0x69ce('0x19')](_0x235f48);}return _0x43626e[_0x69ce('0x1a')](_0x235f48)[_0x69ce('0x1b')]();};}function respondWithResult(_0x273423,_0x20eb1f){_0x20eb1f=_0x20eb1f||0xc8;return function(_0x11f23a){if(_0x11f23a){return _0x273423[_0x69ce('0x1a')](_0x20eb1f)[_0x69ce('0x1c')](_0x11f23a);}};}function respondWithFilteredResult(_0x566142,_0x11a21a){return function(_0x427489){if(_0x427489){var _0x447351=typeof _0x11a21a[_0x69ce('0x1d')]==='undefined'&&typeof _0x11a21a[_0x69ce('0x1e')]===_0x69ce('0x1f');var _0x54642c=_0x427489[_0x69ce('0x20')];var _0x21a983=_0x447351?0x0:_0x11a21a[_0x69ce('0x1d')];var _0x48cbeb=_0x447351?_0x427489['count']:_0x11a21a['offset']+_0x11a21a[_0x69ce('0x1e')];var _0x378767;if(_0x48cbeb>=_0x54642c){_0x48cbeb=_0x54642c;_0x378767=0xc8;}else{_0x378767=0xce;}_0x566142[_0x69ce('0x1a')](_0x378767);return _0x566142[_0x69ce('0x21')](_0x69ce('0x22'),_0x21a983+'-'+_0x48cbeb+'/'+_0x54642c)[_0x69ce('0x1c')](_0x427489);}return null;};}function patchUpdates(_0x47ea47){return function(_0x12ae55){try{jsonpatch[_0x69ce('0x23')](_0x12ae55,_0x47ea47,!![]);}catch(_0x378b54){return BPromise[_0x69ce('0x24')](_0x378b54);}return _0x12ae55[_0x69ce('0x25')]();};}function saveUpdates(_0x441eca,_0x295fc4){return function(_0x1a9c9f){if(_0x1a9c9f){return _0x1a9c9f['update'](_0x441eca)[_0x69ce('0x26')](function(_0x1e66c6){return _0x1e66c6;});}return null;};}function removeEntity(_0x54aed2,_0x301488){return function(_0x272a21){if(_0x272a21){return _0x272a21[_0x69ce('0x27')]()[_0x69ce('0x26')](function(){_0x54aed2[_0x69ce('0x1a')](0xcc)['end']();});}};}function handleEntityNotFound(_0x417bfe,_0x40f9e3){return function(_0x387a25){if(!_0x387a25){_0x417bfe[_0x69ce('0x19')](0x194);}return _0x387a25;};}function handleError(_0x28eaab,_0x2f8bc5){_0x2f8bc5=_0x2f8bc5||0x1f4;return function(_0x26b991){logger['error'](_0x26b991['stack']);if(_0x26b991[_0x69ce('0x28')]){delete _0x26b991[_0x69ce('0x28')];}_0x28eaab[_0x69ce('0x1a')](_0x2f8bc5)[_0x69ce('0x29')](_0x26b991);};}exports[_0x69ce('0x2a')]=function(_0x15db8c,_0x52587a){var _0x349579={},_0x1c0a04={},_0x5d49af={'count':0x0,'rows':[]};var _0x233a43=_[_0x69ce('0x2b')](db[_0x69ce('0x2c')][_0x69ce('0x2d')],function(_0x1e6a43){return{'name':_0x1e6a43['fieldName'],'type':_0x1e6a43[_0x69ce('0x2e')][_0x69ce('0x2f')]};});_0x1c0a04[_0x69ce('0x30')]=_[_0x69ce('0x2b')](_0x233a43,'name');_0x1c0a04['query']=_[_0x69ce('0x31')](_0x15db8c['query']);_0x1c0a04[_0x69ce('0x32')]=_[_0x69ce('0x33')](_0x1c0a04[_0x69ce('0x30')],_0x1c0a04[_0x69ce('0x34')]);_0x349579[_0x69ce('0x35')]=_['intersection'](_0x1c0a04[_0x69ce('0x30')],qs[_0x69ce('0x36')](_0x15db8c[_0x69ce('0x34')]['fields']));_0x349579[_0x69ce('0x35')]=_0x349579[_0x69ce('0x35')]['length']?_0x349579[_0x69ce('0x35')]:_0x1c0a04['model'];if(!_0x15db8c['query'][_0x69ce('0x37')](_0x69ce('0x38'))){_0x349579[_0x69ce('0x1e')]=qs[_0x69ce('0x1e')](_0x15db8c[_0x69ce('0x34')][_0x69ce('0x1e')]);_0x349579[_0x69ce('0x1d')]=qs[_0x69ce('0x1d')](_0x15db8c['query'][_0x69ce('0x1d')]);}_0x349579['order']=qs['sort'](_0x15db8c[_0x69ce('0x34')][_0x69ce('0x39')]);_0x349579[_0x69ce('0x3a')]=qs['filters'](_['pick'](_0x15db8c[_0x69ce('0x34')],_0x1c0a04['filters']),_0x233a43);if(_0x15db8c['query'][_0x69ce('0x3b')]){_0x349579[_0x69ce('0x3a')]=_[_0x69ce('0x3c')](_0x349579[_0x69ce('0x3a')],{'$or':_[_0x69ce('0x2b')](_0x233a43,function(_0x286b1a){if(_0x286b1a[_0x69ce('0x2e')]!==_0x69ce('0x3d')){var _0x2f1373={};_0x2f1373[_0x286b1a[_0x69ce('0x28')]]={'$like':'%'+_0x15db8c[_0x69ce('0x34')][_0x69ce('0x3b')]+'%'};return _0x2f1373;}})});}_0x349579=_[_0x69ce('0x3c')]({},_0x349579,_0x15db8c['options']);var _0x4f1a7f={'where':_0x349579['where']};return db[_0x69ce('0x2c')][_0x69ce('0x20')](_0x4f1a7f)[_0x69ce('0x26')](function(_0x70b412){_0x5d49af[_0x69ce('0x20')]=_0x70b412;if(_0x15db8c[_0x69ce('0x34')][_0x69ce('0x3e')]){_0x349579[_0x69ce('0x3f')]=[{'all':!![]}];}return db[_0x69ce('0x2c')][_0x69ce('0x40')](_0x349579);})[_0x69ce('0x26')](function(_0x3e3989){_0x5d49af[_0x69ce('0x41')]=_0x3e3989;return _0x5d49af;})[_0x69ce('0x26')](respondWithFilteredResult(_0x52587a,_0x349579))[_0x69ce('0x42')](handleError(_0x52587a,null));};exports[_0x69ce('0x43')]=function(_0x3e43fc,_0x11fe0f){var _0x558eff={'raw':![],'where':{'id':_0x3e43fc[_0x69ce('0x44')]['id']}},_0xa3a7fd={};_0xa3a7fd[_0x69ce('0x30')]=_[_0x69ce('0x31')](db[_0x69ce('0x2c')][_0x69ce('0x2d')]);_0xa3a7fd[_0x69ce('0x34')]=_[_0x69ce('0x31')](_0x3e43fc[_0x69ce('0x34')]);_0xa3a7fd[_0x69ce('0x32')]=_[_0x69ce('0x33')](_0xa3a7fd[_0x69ce('0x30')],_0xa3a7fd[_0x69ce('0x34')]);_0x558eff[_0x69ce('0x35')]=_[_0x69ce('0x33')](_0xa3a7fd['model'],qs['fields'](_0x3e43fc[_0x69ce('0x34')][_0x69ce('0x36')]));_0x558eff['attributes']=_0x558eff[_0x69ce('0x35')]['length']?_0x558eff[_0x69ce('0x35')]:_0xa3a7fd[_0x69ce('0x30')];if(_0x3e43fc[_0x69ce('0x34')][_0x69ce('0x3e')]){_0x558eff[_0x69ce('0x3f')]=[{'all':!![]}];}_0x558eff=_['merge']({},_0x558eff,_0x3e43fc[_0x69ce('0x45')]);return db[_0x69ce('0x2c')]['find'](_0x558eff)[_0x69ce('0x26')](handleEntityNotFound(_0x11fe0f,null))[_0x69ce('0x26')](respondWithResult(_0x11fe0f,null))['catch'](handleError(_0x11fe0f,null));};exports[_0x69ce('0x46')]=function(_0x1806ad,_0x106695){return db[_0x69ce('0x2c')]['create'](_0x1806ad[_0x69ce('0x47')],{})[_0x69ce('0x26')](respondWithResult(_0x106695,0xc9))[_0x69ce('0x42')](handleError(_0x106695,null));};exports[_0x69ce('0x48')]=function(_0x2c6ff3,_0x207792){if(_0x2c6ff3[_0x69ce('0x47')]['id']){delete _0x2c6ff3[_0x69ce('0x47')]['id'];}return db['Automation'][_0x69ce('0x49')]({'where':{'id':_0x2c6ff3[_0x69ce('0x44')]['id']}})['then'](handleEntityNotFound(_0x207792,null))[_0x69ce('0x26')](saveUpdates(_0x2c6ff3['body'],null))[_0x69ce('0x26')](respondWithResult(_0x207792,null))[_0x69ce('0x42')](handleError(_0x207792,null));};exports[_0x69ce('0x27')]=function(_0x2890fe,_0x280bf4){return db['Automation'][_0x69ce('0x49')]({'where':{'id':_0x2890fe['params']['id']}})[_0x69ce('0x26')](handleEntityNotFound(_0x280bf4,null))[_0x69ce('0x26')](removeEntity(_0x280bf4,null))[_0x69ce('0x42')](handleError(_0x280bf4,null));};exports[_0x69ce('0x4a')]=function(_0x26f976,_0x3d8e8b,_0x4ce254){return db['Condition'][_0x69ce('0x49')]({'where':{'id':_0x26f976[_0x69ce('0x44')]['id']}})[_0x69ce('0x26')](handleEntityNotFound(_0x3d8e8b,null))[_0x69ce('0x26')](function(_0x43d858){if(_0x43d858){return _0x43d858[_0x69ce('0x4a')](_0x26f976[_0x69ce('0x47')]['ids'],_['omit'](_0x26f976[_0x69ce('0x47')],[_0x69ce('0x4b'),'id'])||{});}})[_0x69ce('0x26')](respondWithResult(_0x3d8e8b,null))[_0x69ce('0x42')](handleError(_0x3d8e8b,null));};exports[_0x69ce('0x4c')]=function(_0x23594b,_0x390db8,_0x5402a9){var _0x162f1a={};var _0x54c48b={};var _0x109600;var _0x173ee5;return db[_0x69ce('0x2c')][_0x69ce('0x4d')]({'where':{'id':_0x23594b[_0x69ce('0x44')]['id']}})[_0x69ce('0x26')](handleEntityNotFound(_0x390db8,null))[_0x69ce('0x26')](function(_0x522020){if(_0x522020){_0x109600=_0x522020;_0x54c48b[_0x69ce('0x30')]=_[_0x69ce('0x31')](db['Condition'][_0x69ce('0x2d')]);_0x54c48b[_0x69ce('0x34')]=_['keys'](_0x23594b['query']);_0x54c48b[_0x69ce('0x32')]=_[_0x69ce('0x33')](_0x54c48b[_0x69ce('0x30')],_0x54c48b[_0x69ce('0x34')]);_0x162f1a[_0x69ce('0x35')]=_[_0x69ce('0x33')](_0x54c48b[_0x69ce('0x30')],qs[_0x69ce('0x36')](_0x23594b[_0x69ce('0x34')]['fields']));_0x162f1a['attributes']=_0x162f1a[_0x69ce('0x35')][_0x69ce('0x4e')]?_0x162f1a[_0x69ce('0x35')]:_0x54c48b[_0x69ce('0x30')];_0x162f1a[_0x69ce('0x4f')]=qs[_0x69ce('0x39')](_0x23594b[_0x69ce('0x34')][_0x69ce('0x39')]);_0x162f1a[_0x69ce('0x3a')]=qs['filters'](_[_0x69ce('0x50')](_0x23594b[_0x69ce('0x34')],_0x54c48b[_0x69ce('0x32')]));if(_0x23594b[_0x69ce('0x34')][_0x69ce('0x3b')]){_0x162f1a[_0x69ce('0x3a')]=_[_0x69ce('0x3c')](_0x162f1a[_0x69ce('0x3a')],{'$or':_[_0x69ce('0x2b')](_0x162f1a[_0x69ce('0x35')],function(_0x2f9a4b){var _0x177ee4={};_0x177ee4[_0x2f9a4b]={'$like':'%'+_0x23594b['query'][_0x69ce('0x3b')]+'%'};return _0x177ee4;})});}_0x162f1a=_['merge']({},_0x162f1a,_0x23594b[_0x69ce('0x45')]);return _0x109600[_0x69ce('0x4c')](_0x162f1a);}})['then'](function(_0xb345df){if(_0xb345df){_0x173ee5=_0xb345df[_0x69ce('0x4e')];if(!_0x23594b[_0x69ce('0x34')][_0x69ce('0x37')]('nolimit')){_0x162f1a[_0x69ce('0x1e')]=qs[_0x69ce('0x1e')](_0x23594b['query'][_0x69ce('0x1e')]);_0x162f1a[_0x69ce('0x1d')]=qs[_0x69ce('0x1d')](_0x23594b[_0x69ce('0x34')][_0x69ce('0x1d')]);}return _0x109600['getConditions'](_0x162f1a);}})[_0x69ce('0x26')](function(_0x5f65d){if(_0x5f65d){return _0x5f65d?{'count':_0x173ee5,'rows':_0x5f65d}:null;}})[_0x69ce('0x26')](respondWithResult(_0x390db8,null))['catch'](handleError(_0x390db8,null));};exports[_0x69ce('0x51')]=function(_0xeccb95,_0x1659ec,_0x18ad83){return db[_0x69ce('0x52')]['find']({'where':{'id':_0xeccb95[_0x69ce('0x44')]['id']}})[_0x69ce('0x26')](handleEntityNotFound(_0x1659ec,null))[_0x69ce('0x26')](function(_0x2221fa){if(_0x2221fa){return _0x2221fa[_0x69ce('0x51')](_0xeccb95[_0x69ce('0x47')][_0x69ce('0x4b')],_[_0x69ce('0x53')](_0xeccb95[_0x69ce('0x47')],[_0x69ce('0x4b'),'id'])||{});}})[_0x69ce('0x26')](respondWithResult(_0x1659ec,null))[_0x69ce('0x42')](handleError(_0x1659ec,null));};exports[_0x69ce('0x54')]=function(_0x521665,_0x29ebfe,_0x2ba083){var _0x4ee35e={};var _0x21caaa={};var _0x3d17a9;var _0x1265ce;return db[_0x69ce('0x2c')][_0x69ce('0x4d')]({'where':{'id':_0x521665[_0x69ce('0x44')]['id']}})[_0x69ce('0x26')](handleEntityNotFound(_0x29ebfe,null))[_0x69ce('0x26')](function(_0x31f59d){if(_0x31f59d){_0x3d17a9=_0x31f59d;_0x21caaa[_0x69ce('0x30')]=_[_0x69ce('0x31')](db[_0x69ce('0x52')][_0x69ce('0x2d')]);_0x21caaa['query']=_[_0x69ce('0x31')](_0x521665[_0x69ce('0x34')]);_0x21caaa['filters']=_['intersection'](_0x21caaa[_0x69ce('0x30')],_0x21caaa[_0x69ce('0x34')]);_0x4ee35e[_0x69ce('0x35')]=_[_0x69ce('0x33')](_0x21caaa['model'],qs[_0x69ce('0x36')](_0x521665[_0x69ce('0x34')]['fields']));_0x4ee35e['attributes']=_0x4ee35e[_0x69ce('0x35')][_0x69ce('0x4e')]?_0x4ee35e[_0x69ce('0x35')]:_0x21caaa[_0x69ce('0x30')];_0x4ee35e[_0x69ce('0x4f')]=qs[_0x69ce('0x39')](_0x521665[_0x69ce('0x34')][_0x69ce('0x39')]);_0x4ee35e[_0x69ce('0x3a')]=qs[_0x69ce('0x32')](_[_0x69ce('0x50')](_0x521665[_0x69ce('0x34')],_0x21caaa[_0x69ce('0x32')]));if(_0x521665[_0x69ce('0x34')][_0x69ce('0x3b')]){_0x4ee35e[_0x69ce('0x3a')]=_[_0x69ce('0x3c')](_0x4ee35e[_0x69ce('0x3a')],{'$or':_[_0x69ce('0x2b')](_0x4ee35e[_0x69ce('0x35')],function(_0x4c82a6){var _0x4f88ac={};_0x4f88ac[_0x4c82a6]={'$like':'%'+_0x521665[_0x69ce('0x34')]['filter']+'%'};return _0x4f88ac;})});}_0x4ee35e=_[_0x69ce('0x3c')]({},_0x4ee35e,_0x521665[_0x69ce('0x45')]);return _0x3d17a9[_0x69ce('0x54')](_0x4ee35e);}})['then'](function(_0x1dff93){if(_0x1dff93){_0x1265ce=_0x1dff93['length'];if(!_0x521665['query']['hasOwnProperty'](_0x69ce('0x38'))){_0x4ee35e[_0x69ce('0x1e')]=qs[_0x69ce('0x1e')](_0x521665[_0x69ce('0x34')]['limit']);_0x4ee35e[_0x69ce('0x1d')]=qs[_0x69ce('0x1d')](_0x521665[_0x69ce('0x34')]['offset']);}return _0x3d17a9[_0x69ce('0x54')](_0x4ee35e);}})[_0x69ce('0x26')](function(_0x1abd8e){if(_0x1abd8e){return _0x1abd8e?{'count':_0x1265ce,'rows':_0x1abd8e}:null;}})['then'](respondWithResult(_0x29ebfe,null))['catch'](handleError(_0x29ebfe,null));};
\ No newline at end of file