Built motion from commit 52c8a02d.|2.6.29
[motion2.git] / server / api / automation / automation.controller.js
index 8615b77..d22f8d8 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xff41=['apply','reject','save','destroy','then','error','name','send','map','Automation','rawAttributes','fieldName','type','model','keys','query','filters','intersection','fields','attributes','hasOwnProperty','nolimit','order','sort','pick','filter','where','merge','VIRTUAL','options','includeAll','include','findAll','rows','catch','show','params','length','find','create','body','addConditions','getConditions','findOne','Condition','addActions','Action','omit','getActions','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','util','sox','to-csv','ejs','fs-extra','lodash','squel','crypto','jsforce','querystring','papaparse','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','sendStatus','end','status','json','undefined','count','offset','limit'];(function(_0x45d3f0,_0x4be53f){var _0x314b79=function(_0x563d32){while(--_0x563d32){_0x45d3f0['push'](_0x45d3f0['shift']());}};_0x314b79(++_0x4be53f);}(_0xff41,0x12d));var _0x1ff4=function(_0x5dffaa,_0x2e2073){_0x5dffaa=_0x5dffaa-0x0;var _0x6b79f8=_0xff41[_0x5dffaa];return _0x6b79f8;};'use strict';var emlformat=require(_0x1ff4('0x0'));var rimraf=require(_0x1ff4('0x1'));var zipdir=require(_0x1ff4('0x2'));var jsonpatch=require(_0x1ff4('0x3'));var rp=require(_0x1ff4('0x4'));var moment=require(_0x1ff4('0x5'));var BPromise=require(_0x1ff4('0x6'));var Mustache=require('mustache');var util=require(_0x1ff4('0x7'));var path=require('path');var sox=require(_0x1ff4('0x8'));var csv=require(_0x1ff4('0x9'));var ejs=require(_0x1ff4('0xa'));var fs=require('fs');var fs_extra=require(_0x1ff4('0xb'));var _=require(_0x1ff4('0xc'));var squel=require(_0x1ff4('0xd'));var crypto=require(_0x1ff4('0xe'));var jsforce=require(_0x1ff4('0xf'));var deskjs=require('desk.js');var toCsv=require(_0x1ff4('0x9'));var querystring=require(_0x1ff4('0x10'));var Papa=require(_0x1ff4('0x11'));var Redis=require('ioredis');var authService=require(_0x1ff4('0x12'));var qs=require(_0x1ff4('0x13'));var as=require(_0x1ff4('0x14'));var hardwareService=require(_0x1ff4('0x15'));var logger=require('../../config/logger')(_0x1ff4('0x16'));var utils=require(_0x1ff4('0x17'));var config=require(_0x1ff4('0x18'));var licenseUtil=require(_0x1ff4('0x19'));var db=require(_0x1ff4('0x1a'))['db'];function respondWithStatusCode(_0xd7152f,_0x21ebe1){_0x21ebe1=_0x21ebe1||0xcc;return function(_0x49ebc2){if(_0x49ebc2){return _0xd7152f[_0x1ff4('0x1b')](_0x21ebe1);}return _0xd7152f['status'](_0x21ebe1)[_0x1ff4('0x1c')]();};}function respondWithResult(_0x3834b6,_0x40aebe){_0x40aebe=_0x40aebe||0xc8;return function(_0x303710){if(_0x303710){return _0x3834b6[_0x1ff4('0x1d')](_0x40aebe)[_0x1ff4('0x1e')](_0x303710);}};}function respondWithFilteredResult(_0x39fc4a,_0x1a157c){return function(_0x1d6c22){if(_0x1d6c22){var _0x1361e1=typeof _0x1a157c['offset']===_0x1ff4('0x1f')&&typeof _0x1a157c['limit']===_0x1ff4('0x1f');var _0x24ec8f=_0x1d6c22[_0x1ff4('0x20')];var _0x36a6e3=_0x1361e1?0x0:_0x1a157c[_0x1ff4('0x21')];var _0x5eb2da=_0x1361e1?_0x1d6c22[_0x1ff4('0x20')]:_0x1a157c[_0x1ff4('0x21')]+_0x1a157c[_0x1ff4('0x22')];var _0x19bbd4;if(_0x5eb2da>=_0x24ec8f){_0x5eb2da=_0x24ec8f;_0x19bbd4=0xc8;}else{_0x19bbd4=0xce;}_0x39fc4a['status'](_0x19bbd4);return _0x39fc4a['set']('Content-Range',_0x36a6e3+'-'+_0x5eb2da+'/'+_0x24ec8f)['json'](_0x1d6c22);}return null;};}function patchUpdates(_0x19c838){return function(_0x39795e){try{jsonpatch[_0x1ff4('0x23')](_0x39795e,_0x19c838,!![]);}catch(_0x469b30){return BPromise[_0x1ff4('0x24')](_0x469b30);}return _0x39795e[_0x1ff4('0x25')]();};}function saveUpdates(_0x146e80,_0x2df35a){return function(_0x1b56c9){if(_0x1b56c9){return _0x1b56c9['update'](_0x146e80)['then'](function(_0x4caf57){return _0x4caf57;});}return null;};}function removeEntity(_0x4a55b5,_0x501fdc){return function(_0x27e053){if(_0x27e053){return _0x27e053[_0x1ff4('0x26')]()[_0x1ff4('0x27')](function(){_0x4a55b5[_0x1ff4('0x1d')](0xcc)[_0x1ff4('0x1c')]();});}};}function handleEntityNotFound(_0x45e2de,_0x3de1c9){return function(_0x2d5605){if(!_0x2d5605){_0x45e2de['sendStatus'](0x194);}return _0x2d5605;};}function handleError(_0x396690,_0x141cc1){_0x141cc1=_0x141cc1||0x1f4;return function(_0x7fd279){logger[_0x1ff4('0x28')](_0x7fd279['stack']);if(_0x7fd279[_0x1ff4('0x29')]){delete _0x7fd279[_0x1ff4('0x29')];}_0x396690['status'](_0x141cc1)[_0x1ff4('0x2a')](_0x7fd279);};}exports['index']=function(_0x2495f6,_0x16a4e8){var _0x4c7305={},_0xb5331f={},_0x50faff={'count':0x0,'rows':[]};var _0x19113=_[_0x1ff4('0x2b')](db[_0x1ff4('0x2c')][_0x1ff4('0x2d')],function(_0x6bafce){return{'name':_0x6bafce[_0x1ff4('0x2e')],'type':_0x6bafce[_0x1ff4('0x2f')]['key']};});_0xb5331f[_0x1ff4('0x30')]=_[_0x1ff4('0x2b')](_0x19113,_0x1ff4('0x29'));_0xb5331f['query']=_[_0x1ff4('0x31')](_0x2495f6[_0x1ff4('0x32')]);_0xb5331f[_0x1ff4('0x33')]=_['intersection'](_0xb5331f[_0x1ff4('0x30')],_0xb5331f['query']);_0x4c7305['attributes']=_[_0x1ff4('0x34')](_0xb5331f[_0x1ff4('0x30')],qs[_0x1ff4('0x35')](_0x2495f6[_0x1ff4('0x32')][_0x1ff4('0x35')]));_0x4c7305['attributes']=_0x4c7305[_0x1ff4('0x36')]['length']?_0x4c7305['attributes']:_0xb5331f[_0x1ff4('0x30')];if(!_0x2495f6[_0x1ff4('0x32')][_0x1ff4('0x37')](_0x1ff4('0x38'))){_0x4c7305[_0x1ff4('0x22')]=qs[_0x1ff4('0x22')](_0x2495f6[_0x1ff4('0x32')][_0x1ff4('0x22')]);_0x4c7305[_0x1ff4('0x21')]=qs[_0x1ff4('0x21')](_0x2495f6['query']['offset']);}_0x4c7305[_0x1ff4('0x39')]=qs[_0x1ff4('0x3a')](_0x2495f6[_0x1ff4('0x32')]['sort']);_0x4c7305['where']=qs[_0x1ff4('0x33')](_[_0x1ff4('0x3b')](_0x2495f6['query'],_0xb5331f[_0x1ff4('0x33')]),_0x19113);if(_0x2495f6['query'][_0x1ff4('0x3c')]){_0x4c7305[_0x1ff4('0x3d')]=_[_0x1ff4('0x3e')](_0x4c7305['where'],{'$or':_[_0x1ff4('0x2b')](_0x19113,function(_0x435822){if(_0x435822['type']!==_0x1ff4('0x3f')){var _0x46ed66={};_0x46ed66[_0x435822[_0x1ff4('0x29')]]={'$like':'%'+_0x2495f6[_0x1ff4('0x32')][_0x1ff4('0x3c')]+'%'};return _0x46ed66;}})});}_0x4c7305=_['merge']({},_0x4c7305,_0x2495f6[_0x1ff4('0x40')]);var _0x23f970={'where':_0x4c7305[_0x1ff4('0x3d')]};return db[_0x1ff4('0x2c')]['count'](_0x23f970)['then'](function(_0x3d6283){_0x50faff['count']=_0x3d6283;if(_0x2495f6[_0x1ff4('0x32')][_0x1ff4('0x41')]){_0x4c7305[_0x1ff4('0x42')]=[{'all':!![]}];}return db[_0x1ff4('0x2c')][_0x1ff4('0x43')](_0x4c7305);})[_0x1ff4('0x27')](function(_0x3fe528){_0x50faff[_0x1ff4('0x44')]=_0x3fe528;return _0x50faff;})[_0x1ff4('0x27')](respondWithFilteredResult(_0x16a4e8,_0x4c7305))[_0x1ff4('0x45')](handleError(_0x16a4e8,null));};exports[_0x1ff4('0x46')]=function(_0x10ecc4,_0x32658d){var _0x29ca1a={'raw':![],'where':{'id':_0x10ecc4[_0x1ff4('0x47')]['id']}},_0x3abaf5={};_0x3abaf5[_0x1ff4('0x30')]=_['keys'](db[_0x1ff4('0x2c')][_0x1ff4('0x2d')]);_0x3abaf5[_0x1ff4('0x32')]=_['keys'](_0x10ecc4[_0x1ff4('0x32')]);_0x3abaf5['filters']=_['intersection'](_0x3abaf5[_0x1ff4('0x30')],_0x3abaf5['query']);_0x29ca1a['attributes']=_['intersection'](_0x3abaf5['model'],qs[_0x1ff4('0x35')](_0x10ecc4[_0x1ff4('0x32')]['fields']));_0x29ca1a[_0x1ff4('0x36')]=_0x29ca1a['attributes'][_0x1ff4('0x48')]?_0x29ca1a['attributes']:_0x3abaf5['model'];if(_0x10ecc4['query'][_0x1ff4('0x41')]){_0x29ca1a[_0x1ff4('0x42')]=[{'all':!![]}];}_0x29ca1a=_['merge']({},_0x29ca1a,_0x10ecc4[_0x1ff4('0x40')]);return db[_0x1ff4('0x2c')][_0x1ff4('0x49')](_0x29ca1a)[_0x1ff4('0x27')](handleEntityNotFound(_0x32658d,null))[_0x1ff4('0x27')](respondWithResult(_0x32658d,null))[_0x1ff4('0x45')](handleError(_0x32658d,null));};exports[_0x1ff4('0x4a')]=function(_0x59672c,_0x50f21e){return db[_0x1ff4('0x2c')][_0x1ff4('0x4a')](_0x59672c[_0x1ff4('0x4b')],{})[_0x1ff4('0x27')](respondWithResult(_0x50f21e,0xc9))[_0x1ff4('0x45')](handleError(_0x50f21e,null));};exports['update']=function(_0x312bf3,_0x162635){if(_0x312bf3[_0x1ff4('0x4b')]['id']){delete _0x312bf3[_0x1ff4('0x4b')]['id'];}return db[_0x1ff4('0x2c')][_0x1ff4('0x49')]({'where':{'id':_0x312bf3[_0x1ff4('0x47')]['id']}})[_0x1ff4('0x27')](handleEntityNotFound(_0x162635,null))[_0x1ff4('0x27')](saveUpdates(_0x312bf3[_0x1ff4('0x4b')],null))[_0x1ff4('0x27')](respondWithResult(_0x162635,null))[_0x1ff4('0x45')](handleError(_0x162635,null));};exports[_0x1ff4('0x26')]=function(_0x20dbde,_0x24fcf8){return db[_0x1ff4('0x2c')][_0x1ff4('0x49')]({'where':{'id':_0x20dbde[_0x1ff4('0x47')]['id']}})[_0x1ff4('0x27')](handleEntityNotFound(_0x24fcf8,null))[_0x1ff4('0x27')](removeEntity(_0x24fcf8,null))[_0x1ff4('0x45')](handleError(_0x24fcf8,null));};exports[_0x1ff4('0x4c')]=function(_0x2352b6,_0x2f2170,_0x5dfdd2){return db['Condition'][_0x1ff4('0x49')]({'where':{'id':_0x2352b6['params']['id']}})[_0x1ff4('0x27')](handleEntityNotFound(_0x2f2170,null))[_0x1ff4('0x27')](function(_0x51f5df){if(_0x51f5df){return _0x51f5df[_0x1ff4('0x4c')](_0x2352b6[_0x1ff4('0x4b')]['ids'],_['omit'](_0x2352b6[_0x1ff4('0x4b')],['ids','id'])||{});}})['then'](respondWithResult(_0x2f2170,null))[_0x1ff4('0x45')](handleError(_0x2f2170,null));};exports[_0x1ff4('0x4d')]=function(_0x33b43a,_0x707726,_0x1ba19b){var _0x2d244b={};var _0x373eb3={};var _0x380f26;var _0x50163c;return db[_0x1ff4('0x2c')][_0x1ff4('0x4e')]({'where':{'id':_0x33b43a[_0x1ff4('0x47')]['id']}})['then'](handleEntityNotFound(_0x707726,null))[_0x1ff4('0x27')](function(_0x4db03){if(_0x4db03){_0x380f26=_0x4db03;_0x373eb3[_0x1ff4('0x30')]=_[_0x1ff4('0x31')](db[_0x1ff4('0x4f')]['rawAttributes']);_0x373eb3[_0x1ff4('0x32')]=_[_0x1ff4('0x31')](_0x33b43a[_0x1ff4('0x32')]);_0x373eb3[_0x1ff4('0x33')]=_[_0x1ff4('0x34')](_0x373eb3[_0x1ff4('0x30')],_0x373eb3['query']);_0x2d244b['attributes']=_['intersection'](_0x373eb3[_0x1ff4('0x30')],qs[_0x1ff4('0x35')](_0x33b43a['query']['fields']));_0x2d244b['attributes']=_0x2d244b[_0x1ff4('0x36')]['length']?_0x2d244b[_0x1ff4('0x36')]:_0x373eb3[_0x1ff4('0x30')];_0x2d244b[_0x1ff4('0x39')]=qs['sort'](_0x33b43a[_0x1ff4('0x32')][_0x1ff4('0x3a')]);_0x2d244b[_0x1ff4('0x3d')]=qs['filters'](_['pick'](_0x33b43a[_0x1ff4('0x32')],_0x373eb3[_0x1ff4('0x33')]));if(_0x33b43a[_0x1ff4('0x32')][_0x1ff4('0x3c')]){_0x2d244b['where']=_[_0x1ff4('0x3e')](_0x2d244b['where'],{'$or':_[_0x1ff4('0x2b')](_0x2d244b['attributes'],function(_0x4a2625){var _0x460d4d={};_0x460d4d[_0x4a2625]={'$like':'%'+_0x33b43a[_0x1ff4('0x32')][_0x1ff4('0x3c')]+'%'};return _0x460d4d;})});}_0x2d244b=_[_0x1ff4('0x3e')]({},_0x2d244b,_0x33b43a[_0x1ff4('0x40')]);return _0x380f26[_0x1ff4('0x4d')](_0x2d244b);}})[_0x1ff4('0x27')](function(_0x5a39e4){if(_0x5a39e4){_0x50163c=_0x5a39e4[_0x1ff4('0x48')];if(!_0x33b43a[_0x1ff4('0x32')][_0x1ff4('0x37')](_0x1ff4('0x38'))){_0x2d244b[_0x1ff4('0x22')]=qs[_0x1ff4('0x22')](_0x33b43a[_0x1ff4('0x32')][_0x1ff4('0x22')]);_0x2d244b[_0x1ff4('0x21')]=qs['offset'](_0x33b43a[_0x1ff4('0x32')][_0x1ff4('0x21')]);}return _0x380f26[_0x1ff4('0x4d')](_0x2d244b);}})[_0x1ff4('0x27')](function(_0x1dce9){if(_0x1dce9){return _0x1dce9?{'count':_0x50163c,'rows':_0x1dce9}:null;}})[_0x1ff4('0x27')](respondWithResult(_0x707726,null))['catch'](handleError(_0x707726,null));};exports[_0x1ff4('0x50')]=function(_0x59b074,_0xb3d3f5,_0x473ee1){return db[_0x1ff4('0x51')][_0x1ff4('0x49')]({'where':{'id':_0x59b074['params']['id']}})[_0x1ff4('0x27')](handleEntityNotFound(_0xb3d3f5,null))[_0x1ff4('0x27')](function(_0x8fcc21){if(_0x8fcc21){return _0x8fcc21[_0x1ff4('0x50')](_0x59b074[_0x1ff4('0x4b')]['ids'],_[_0x1ff4('0x52')](_0x59b074[_0x1ff4('0x4b')],['ids','id'])||{});}})['then'](respondWithResult(_0xb3d3f5,null))[_0x1ff4('0x45')](handleError(_0xb3d3f5,null));};exports[_0x1ff4('0x53')]=function(_0x44ce4b,_0x54e2f5,_0x282582){var _0xdc6611={};var _0x2faa1e={};var _0x3357b1;var _0x38ff69;return db[_0x1ff4('0x2c')][_0x1ff4('0x4e')]({'where':{'id':_0x44ce4b[_0x1ff4('0x47')]['id']}})[_0x1ff4('0x27')](handleEntityNotFound(_0x54e2f5,null))[_0x1ff4('0x27')](function(_0x4eb744){if(_0x4eb744){_0x3357b1=_0x4eb744;_0x2faa1e['model']=_['keys'](db[_0x1ff4('0x51')][_0x1ff4('0x2d')]);_0x2faa1e[_0x1ff4('0x32')]=_['keys'](_0x44ce4b[_0x1ff4('0x32')]);_0x2faa1e[_0x1ff4('0x33')]=_[_0x1ff4('0x34')](_0x2faa1e[_0x1ff4('0x30')],_0x2faa1e[_0x1ff4('0x32')]);_0xdc6611[_0x1ff4('0x36')]=_[_0x1ff4('0x34')](_0x2faa1e[_0x1ff4('0x30')],qs[_0x1ff4('0x35')](_0x44ce4b['query'][_0x1ff4('0x35')]));_0xdc6611[_0x1ff4('0x36')]=_0xdc6611['attributes'][_0x1ff4('0x48')]?_0xdc6611[_0x1ff4('0x36')]:_0x2faa1e[_0x1ff4('0x30')];_0xdc6611['order']=qs[_0x1ff4('0x3a')](_0x44ce4b['query'][_0x1ff4('0x3a')]);_0xdc6611[_0x1ff4('0x3d')]=qs['filters'](_[_0x1ff4('0x3b')](_0x44ce4b[_0x1ff4('0x32')],_0x2faa1e[_0x1ff4('0x33')]));if(_0x44ce4b[_0x1ff4('0x32')][_0x1ff4('0x3c')]){_0xdc6611['where']=_['merge'](_0xdc6611['where'],{'$or':_[_0x1ff4('0x2b')](_0xdc6611[_0x1ff4('0x36')],function(_0x5f1935){var _0x5ffcbd={};_0x5ffcbd[_0x5f1935]={'$like':'%'+_0x44ce4b[_0x1ff4('0x32')]['filter']+'%'};return _0x5ffcbd;})});}_0xdc6611=_[_0x1ff4('0x3e')]({},_0xdc6611,_0x44ce4b[_0x1ff4('0x40')]);return _0x3357b1[_0x1ff4('0x53')](_0xdc6611);}})[_0x1ff4('0x27')](function(_0x1206a1){if(_0x1206a1){_0x38ff69=_0x1206a1[_0x1ff4('0x48')];if(!_0x44ce4b[_0x1ff4('0x32')][_0x1ff4('0x37')](_0x1ff4('0x38'))){_0xdc6611[_0x1ff4('0x22')]=qs[_0x1ff4('0x22')](_0x44ce4b[_0x1ff4('0x32')][_0x1ff4('0x22')]);_0xdc6611[_0x1ff4('0x21')]=qs[_0x1ff4('0x21')](_0x44ce4b[_0x1ff4('0x32')]['offset']);}return _0x3357b1['getActions'](_0xdc6611);}})[_0x1ff4('0x27')](function(_0x217910){if(_0x217910){return _0x217910?{'count':_0x38ff69,'rows':_0x217910}:null;}})[_0x1ff4('0x27')](respondWithResult(_0x54e2f5,null))[_0x1ff4('0x45')](handleError(_0x54e2f5,null));};
\ No newline at end of file
+var _0xcf7b=['hasOwnProperty','nolimit','order','sort','where','filter','merge','VIRTUAL','options','count','includeAll','findAll','rows','catch','show','params','create','body','update','find','addConditions','Condition','ids','getConditions','findOne','pick','addActions','Action','omit','getActions','eml-format','zip-dir','fast-json-patch','request-promise','moment','mustache','util','path','to-csv','ejs','fs-extra','lodash','squel','crypto','jsforce','desk.js','querystring','papaparse','../../components/auth/service','../../components/parsers/qs','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../mysqldb','sendStatus','end','json','undefined','offset','limit','status','set','reject','save','then','destroy','error','name','send','index','map','Automation','rawAttributes','fieldName','key','model','query','keys','filters','attributes','intersection','fields','length'];(function(_0x2ac5f8,_0x4c3a9f){var _0x3b8229=function(_0x46a3c0){while(--_0x46a3c0){_0x2ac5f8['push'](_0x2ac5f8['shift']());}};_0x3b8229(++_0x4c3a9f);}(_0xcf7b,0x172));var _0xbcf7=function(_0x1969a7,_0x5a133a){_0x1969a7=_0x1969a7-0x0;var _0x3d665f=_0xcf7b[_0x1969a7];return _0x3d665f;};'use strict';var emlformat=require(_0xbcf7('0x0'));var rimraf=require('rimraf');var zipdir=require(_0xbcf7('0x1'));var jsonpatch=require(_0xbcf7('0x2'));var rp=require(_0xbcf7('0x3'));var moment=require(_0xbcf7('0x4'));var BPromise=require('bluebird');var Mustache=require(_0xbcf7('0x5'));var util=require(_0xbcf7('0x6'));var path=require(_0xbcf7('0x7'));var sox=require('sox');var csv=require(_0xbcf7('0x8'));var ejs=require(_0xbcf7('0x9'));var fs=require('fs');var fs_extra=require(_0xbcf7('0xa'));var _=require(_0xbcf7('0xb'));var squel=require(_0xbcf7('0xc'));var crypto=require(_0xbcf7('0xd'));var jsforce=require(_0xbcf7('0xe'));var deskjs=require(_0xbcf7('0xf'));var toCsv=require(_0xbcf7('0x8'));var querystring=require(_0xbcf7('0x10'));var Papa=require(_0xbcf7('0x11'));var Redis=require('ioredis');var authService=require(_0xbcf7('0x12'));var qs=require(_0xbcf7('0x13'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0xbcf7('0x14'));var logger=require(_0xbcf7('0x15'))(_0xbcf7('0x16'));var utils=require(_0xbcf7('0x17'));var config=require(_0xbcf7('0x18'));var licenseUtil=require('../../config/license/util');var db=require(_0xbcf7('0x19'))['db'];function respondWithStatusCode(_0x35ff0a,_0x2cfda4){_0x2cfda4=_0x2cfda4||0xcc;return function(_0x5dec67){if(_0x5dec67){return _0x35ff0a[_0xbcf7('0x1a')](_0x2cfda4);}return _0x35ff0a['status'](_0x2cfda4)[_0xbcf7('0x1b')]();};}function respondWithResult(_0x1997c7,_0xf7aef5){_0xf7aef5=_0xf7aef5||0xc8;return function(_0x150807){if(_0x150807){return _0x1997c7['status'](_0xf7aef5)[_0xbcf7('0x1c')](_0x150807);}};}function respondWithFilteredResult(_0x52426c,_0xae9554){return function(_0x278c82){if(_0x278c82){var _0x2b3c43=typeof _0xae9554['offset']==='undefined'&&typeof _0xae9554['limit']===_0xbcf7('0x1d');var _0x23d088=_0x278c82['count'];var _0x3557c4=_0x2b3c43?0x0:_0xae9554[_0xbcf7('0x1e')];var _0x1315be=_0x2b3c43?_0x278c82['count']:_0xae9554['offset']+_0xae9554[_0xbcf7('0x1f')];var _0xf03848;if(_0x1315be>=_0x23d088){_0x1315be=_0x23d088;_0xf03848=0xc8;}else{_0xf03848=0xce;}_0x52426c[_0xbcf7('0x20')](_0xf03848);return _0x52426c[_0xbcf7('0x21')]('Content-Range',_0x3557c4+'-'+_0x1315be+'/'+_0x23d088)[_0xbcf7('0x1c')](_0x278c82);}return null;};}function patchUpdates(_0x242565){return function(_0x3acbf4){try{jsonpatch['apply'](_0x3acbf4,_0x242565,!![]);}catch(_0x160484){return BPromise[_0xbcf7('0x22')](_0x160484);}return _0x3acbf4[_0xbcf7('0x23')]();};}function saveUpdates(_0x4a592f,_0x14e896){return function(_0x3436eb){if(_0x3436eb){return _0x3436eb['update'](_0x4a592f)[_0xbcf7('0x24')](function(_0x5006c7){return _0x5006c7;});}return null;};}function removeEntity(_0x24ddd0,_0x3ee9c0){return function(_0x2274b0){if(_0x2274b0){return _0x2274b0[_0xbcf7('0x25')]()[_0xbcf7('0x24')](function(){_0x24ddd0[_0xbcf7('0x20')](0xcc)[_0xbcf7('0x1b')]();});}};}function handleEntityNotFound(_0x1a9fb1,_0x428463){return function(_0x22b250){if(!_0x22b250){_0x1a9fb1[_0xbcf7('0x1a')](0x194);}return _0x22b250;};}function handleError(_0xd8e8bf,_0x3a50c8){_0x3a50c8=_0x3a50c8||0x1f4;return function(_0x53d591){logger[_0xbcf7('0x26')](_0x53d591['stack']);if(_0x53d591[_0xbcf7('0x27')]){delete _0x53d591[_0xbcf7('0x27')];}_0xd8e8bf['status'](_0x3a50c8)[_0xbcf7('0x28')](_0x53d591);};}exports[_0xbcf7('0x29')]=function(_0x2e0f01,_0x5bc226){var _0x45af4a={},_0x9ef68c={},_0x2006db={'count':0x0,'rows':[]};var _0xbeed1d=_[_0xbcf7('0x2a')](db[_0xbcf7('0x2b')][_0xbcf7('0x2c')],function(_0x3afdd4){return{'name':_0x3afdd4[_0xbcf7('0x2d')],'type':_0x3afdd4['type'][_0xbcf7('0x2e')]};});_0x9ef68c[_0xbcf7('0x2f')]=_[_0xbcf7('0x2a')](_0xbeed1d,_0xbcf7('0x27'));_0x9ef68c[_0xbcf7('0x30')]=_[_0xbcf7('0x31')](_0x2e0f01['query']);_0x9ef68c[_0xbcf7('0x32')]=_['intersection'](_0x9ef68c[_0xbcf7('0x2f')],_0x9ef68c[_0xbcf7('0x30')]);_0x45af4a[_0xbcf7('0x33')]=_[_0xbcf7('0x34')](_0x9ef68c[_0xbcf7('0x2f')],qs['fields'](_0x2e0f01[_0xbcf7('0x30')][_0xbcf7('0x35')]));_0x45af4a['attributes']=_0x45af4a[_0xbcf7('0x33')][_0xbcf7('0x36')]?_0x45af4a[_0xbcf7('0x33')]:_0x9ef68c[_0xbcf7('0x2f')];if(!_0x2e0f01[_0xbcf7('0x30')][_0xbcf7('0x37')](_0xbcf7('0x38'))){_0x45af4a['limit']=qs[_0xbcf7('0x1f')](_0x2e0f01[_0xbcf7('0x30')]['limit']);_0x45af4a[_0xbcf7('0x1e')]=qs[_0xbcf7('0x1e')](_0x2e0f01[_0xbcf7('0x30')]['offset']);}_0x45af4a[_0xbcf7('0x39')]=qs[_0xbcf7('0x3a')](_0x2e0f01[_0xbcf7('0x30')]['sort']);_0x45af4a[_0xbcf7('0x3b')]=qs['filters'](_['pick'](_0x2e0f01[_0xbcf7('0x30')],_0x9ef68c[_0xbcf7('0x32')]),_0xbeed1d);if(_0x2e0f01[_0xbcf7('0x30')][_0xbcf7('0x3c')]){_0x45af4a[_0xbcf7('0x3b')]=_[_0xbcf7('0x3d')](_0x45af4a[_0xbcf7('0x3b')],{'$or':_[_0xbcf7('0x2a')](_0xbeed1d,function(_0x50105d){if(_0x50105d['type']!==_0xbcf7('0x3e')){var _0x1a1951={};_0x1a1951[_0x50105d[_0xbcf7('0x27')]]={'$like':'%'+_0x2e0f01[_0xbcf7('0x30')]['filter']+'%'};return _0x1a1951;}})});}_0x45af4a=_['merge']({},_0x45af4a,_0x2e0f01[_0xbcf7('0x3f')]);var _0x49b067={'where':_0x45af4a[_0xbcf7('0x3b')]};return db[_0xbcf7('0x2b')][_0xbcf7('0x40')](_0x49b067)[_0xbcf7('0x24')](function(_0x3e2da2){_0x2006db[_0xbcf7('0x40')]=_0x3e2da2;if(_0x2e0f01[_0xbcf7('0x30')][_0xbcf7('0x41')]){_0x45af4a['include']=[{'all':!![]}];}return db[_0xbcf7('0x2b')][_0xbcf7('0x42')](_0x45af4a);})[_0xbcf7('0x24')](function(_0x3af49d){_0x2006db[_0xbcf7('0x43')]=_0x3af49d;return _0x2006db;})['then'](respondWithFilteredResult(_0x5bc226,_0x45af4a))[_0xbcf7('0x44')](handleError(_0x5bc226,null));};exports[_0xbcf7('0x45')]=function(_0x2cc909,_0x179afb){var _0x5462c9={'raw':![],'where':{'id':_0x2cc909[_0xbcf7('0x46')]['id']}},_0x546dd8={};_0x546dd8[_0xbcf7('0x2f')]=_[_0xbcf7('0x31')](db['Automation'][_0xbcf7('0x2c')]);_0x546dd8[_0xbcf7('0x30')]=_[_0xbcf7('0x31')](_0x2cc909[_0xbcf7('0x30')]);_0x546dd8['filters']=_['intersection'](_0x546dd8['model'],_0x546dd8[_0xbcf7('0x30')]);_0x5462c9[_0xbcf7('0x33')]=_['intersection'](_0x546dd8['model'],qs[_0xbcf7('0x35')](_0x2cc909[_0xbcf7('0x30')][_0xbcf7('0x35')]));_0x5462c9[_0xbcf7('0x33')]=_0x5462c9[_0xbcf7('0x33')][_0xbcf7('0x36')]?_0x5462c9[_0xbcf7('0x33')]:_0x546dd8['model'];if(_0x2cc909['query'][_0xbcf7('0x41')]){_0x5462c9['include']=[{'all':!![]}];}_0x5462c9=_[_0xbcf7('0x3d')]({},_0x5462c9,_0x2cc909[_0xbcf7('0x3f')]);return db[_0xbcf7('0x2b')]['find'](_0x5462c9)[_0xbcf7('0x24')](handleEntityNotFound(_0x179afb,null))['then'](respondWithResult(_0x179afb,null))['catch'](handleError(_0x179afb,null));};exports[_0xbcf7('0x47')]=function(_0xbf2f19,_0x28cea0){return db[_0xbcf7('0x2b')]['create'](_0xbf2f19[_0xbcf7('0x48')],{})['then'](respondWithResult(_0x28cea0,0xc9))[_0xbcf7('0x44')](handleError(_0x28cea0,null));};exports[_0xbcf7('0x49')]=function(_0x1cef3d,_0x4b5de4){if(_0x1cef3d['body']['id']){delete _0x1cef3d[_0xbcf7('0x48')]['id'];}return db['Automation'][_0xbcf7('0x4a')]({'where':{'id':_0x1cef3d[_0xbcf7('0x46')]['id']}})['then'](handleEntityNotFound(_0x4b5de4,null))['then'](saveUpdates(_0x1cef3d['body'],null))['then'](respondWithResult(_0x4b5de4,null))['catch'](handleError(_0x4b5de4,null));};exports[_0xbcf7('0x25')]=function(_0x46970b,_0xcfc37f){return db[_0xbcf7('0x2b')][_0xbcf7('0x4a')]({'where':{'id':_0x46970b['params']['id']}})[_0xbcf7('0x24')](handleEntityNotFound(_0xcfc37f,null))[_0xbcf7('0x24')](removeEntity(_0xcfc37f,null))['catch'](handleError(_0xcfc37f,null));};exports[_0xbcf7('0x4b')]=function(_0xf06b57,_0xc0e18e,_0x1ab964){return db[_0xbcf7('0x4c')][_0xbcf7('0x4a')]({'where':{'id':_0xf06b57[_0xbcf7('0x46')]['id']}})['then'](handleEntityNotFound(_0xc0e18e,null))['then'](function(_0x155151){if(_0x155151){return _0x155151[_0xbcf7('0x4b')](_0xf06b57['body']['ids'],_['omit'](_0xf06b57[_0xbcf7('0x48')],[_0xbcf7('0x4d'),'id'])||{});}})[_0xbcf7('0x24')](respondWithResult(_0xc0e18e,null))[_0xbcf7('0x44')](handleError(_0xc0e18e,null));};exports[_0xbcf7('0x4e')]=function(_0x35430e,_0x115bb4,_0x3d24ed){var _0x48c29c={};var _0x34e48d={};var _0x2a2fef;var _0x130042;return db[_0xbcf7('0x2b')][_0xbcf7('0x4f')]({'where':{'id':_0x35430e['params']['id']}})['then'](handleEntityNotFound(_0x115bb4,null))['then'](function(_0x48cbcf){if(_0x48cbcf){_0x2a2fef=_0x48cbcf;_0x34e48d[_0xbcf7('0x2f')]=_[_0xbcf7('0x31')](db[_0xbcf7('0x4c')][_0xbcf7('0x2c')]);_0x34e48d[_0xbcf7('0x30')]=_[_0xbcf7('0x31')](_0x35430e['query']);_0x34e48d[_0xbcf7('0x32')]=_[_0xbcf7('0x34')](_0x34e48d[_0xbcf7('0x2f')],_0x34e48d[_0xbcf7('0x30')]);_0x48c29c[_0xbcf7('0x33')]=_[_0xbcf7('0x34')](_0x34e48d[_0xbcf7('0x2f')],qs[_0xbcf7('0x35')](_0x35430e[_0xbcf7('0x30')][_0xbcf7('0x35')]));_0x48c29c[_0xbcf7('0x33')]=_0x48c29c[_0xbcf7('0x33')][_0xbcf7('0x36')]?_0x48c29c[_0xbcf7('0x33')]:_0x34e48d[_0xbcf7('0x2f')];_0x48c29c[_0xbcf7('0x39')]=qs['sort'](_0x35430e[_0xbcf7('0x30')]['sort']);_0x48c29c[_0xbcf7('0x3b')]=qs[_0xbcf7('0x32')](_[_0xbcf7('0x50')](_0x35430e['query'],_0x34e48d[_0xbcf7('0x32')]));if(_0x35430e[_0xbcf7('0x30')][_0xbcf7('0x3c')]){_0x48c29c[_0xbcf7('0x3b')]=_['merge'](_0x48c29c[_0xbcf7('0x3b')],{'$or':_[_0xbcf7('0x2a')](_0x48c29c[_0xbcf7('0x33')],function(_0x53f3f1){var _0xd127ca={};_0xd127ca[_0x53f3f1]={'$like':'%'+_0x35430e['query'][_0xbcf7('0x3c')]+'%'};return _0xd127ca;})});}_0x48c29c=_['merge']({},_0x48c29c,_0x35430e[_0xbcf7('0x3f')]);return _0x2a2fef[_0xbcf7('0x4e')](_0x48c29c);}})[_0xbcf7('0x24')](function(_0x3cd8cd){if(_0x3cd8cd){_0x130042=_0x3cd8cd['length'];if(!_0x35430e[_0xbcf7('0x30')][_0xbcf7('0x37')](_0xbcf7('0x38'))){_0x48c29c[_0xbcf7('0x1f')]=qs[_0xbcf7('0x1f')](_0x35430e['query'][_0xbcf7('0x1f')]);_0x48c29c[_0xbcf7('0x1e')]=qs[_0xbcf7('0x1e')](_0x35430e[_0xbcf7('0x30')][_0xbcf7('0x1e')]);}return _0x2a2fef[_0xbcf7('0x4e')](_0x48c29c);}})[_0xbcf7('0x24')](function(_0x44707c){if(_0x44707c){return _0x44707c?{'count':_0x130042,'rows':_0x44707c}:null;}})[_0xbcf7('0x24')](respondWithResult(_0x115bb4,null))[_0xbcf7('0x44')](handleError(_0x115bb4,null));};exports[_0xbcf7('0x51')]=function(_0x46b1c1,_0x5c77c9,_0x24e4ea){return db[_0xbcf7('0x52')][_0xbcf7('0x4a')]({'where':{'id':_0x46b1c1[_0xbcf7('0x46')]['id']}})[_0xbcf7('0x24')](handleEntityNotFound(_0x5c77c9,null))[_0xbcf7('0x24')](function(_0x89721e){if(_0x89721e){return _0x89721e['addActions'](_0x46b1c1[_0xbcf7('0x48')][_0xbcf7('0x4d')],_[_0xbcf7('0x53')](_0x46b1c1[_0xbcf7('0x48')],['ids','id'])||{});}})[_0xbcf7('0x24')](respondWithResult(_0x5c77c9,null))[_0xbcf7('0x44')](handleError(_0x5c77c9,null));};exports[_0xbcf7('0x54')]=function(_0x31a844,_0xe005f2,_0x80cbd4){var _0x3f844e={};var _0x4c84cd={};var _0x2ee4fe;var _0x132518;return db[_0xbcf7('0x2b')][_0xbcf7('0x4f')]({'where':{'id':_0x31a844[_0xbcf7('0x46')]['id']}})[_0xbcf7('0x24')](handleEntityNotFound(_0xe005f2,null))[_0xbcf7('0x24')](function(_0xdbb9cf){if(_0xdbb9cf){_0x2ee4fe=_0xdbb9cf;_0x4c84cd[_0xbcf7('0x2f')]=_[_0xbcf7('0x31')](db[_0xbcf7('0x52')]['rawAttributes']);_0x4c84cd[_0xbcf7('0x30')]=_[_0xbcf7('0x31')](_0x31a844[_0xbcf7('0x30')]);_0x4c84cd[_0xbcf7('0x32')]=_[_0xbcf7('0x34')](_0x4c84cd[_0xbcf7('0x2f')],_0x4c84cd[_0xbcf7('0x30')]);_0x3f844e[_0xbcf7('0x33')]=_[_0xbcf7('0x34')](_0x4c84cd[_0xbcf7('0x2f')],qs[_0xbcf7('0x35')](_0x31a844[_0xbcf7('0x30')][_0xbcf7('0x35')]));_0x3f844e[_0xbcf7('0x33')]=_0x3f844e[_0xbcf7('0x33')][_0xbcf7('0x36')]?_0x3f844e['attributes']:_0x4c84cd[_0xbcf7('0x2f')];_0x3f844e['order']=qs[_0xbcf7('0x3a')](_0x31a844['query'][_0xbcf7('0x3a')]);_0x3f844e[_0xbcf7('0x3b')]=qs[_0xbcf7('0x32')](_['pick'](_0x31a844['query'],_0x4c84cd[_0xbcf7('0x32')]));if(_0x31a844[_0xbcf7('0x30')][_0xbcf7('0x3c')]){_0x3f844e[_0xbcf7('0x3b')]=_[_0xbcf7('0x3d')](_0x3f844e['where'],{'$or':_[_0xbcf7('0x2a')](_0x3f844e['attributes'],function(_0x1f4ba0){var _0x2213f1={};_0x2213f1[_0x1f4ba0]={'$like':'%'+_0x31a844[_0xbcf7('0x30')]['filter']+'%'};return _0x2213f1;})});}_0x3f844e=_['merge']({},_0x3f844e,_0x31a844[_0xbcf7('0x3f')]);return _0x2ee4fe[_0xbcf7('0x54')](_0x3f844e);}})[_0xbcf7('0x24')](function(_0x4d2c94){if(_0x4d2c94){_0x132518=_0x4d2c94[_0xbcf7('0x36')];if(!_0x31a844[_0xbcf7('0x30')][_0xbcf7('0x37')](_0xbcf7('0x38'))){_0x3f844e[_0xbcf7('0x1f')]=qs[_0xbcf7('0x1f')](_0x31a844[_0xbcf7('0x30')][_0xbcf7('0x1f')]);_0x3f844e[_0xbcf7('0x1e')]=qs['offset'](_0x31a844['query'][_0xbcf7('0x1e')]);}return _0x2ee4fe['getActions'](_0x3f844e);}})[_0xbcf7('0x24')](function(_0x159ba3){if(_0x159ba3){return _0x159ba3?{'count':_0x132518,'rows':_0x159ba3}:null;}})[_0xbcf7('0x24')](respondWithResult(_0xe005f2,null))['catch'](handleError(_0xe005f2,null));};
\ No newline at end of file