Built motion from commit (unavailable).|2.5.25
[motion2.git] / server / api / automation / automation.controller.js
index 770c867..0dcbfcc 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xa9e0=['apply','reject','save','update','destroy','then','name','send','map','Automation','rawAttributes','fieldName','type','model','query','filters','intersection','attributes','fields','length','nolimit','order','sort','where','filter','VIRTUAL','merge','count','includeAll','include','findAll','rows','show','params','keys','options','find','catch','create','body','addConditions','Condition','ids','findOne','pick','getConditions','addActions','Action','omit','getActions','hasOwnProperty','html-pdf','eml-format','rimraf','request-promise','bluebird','mustache','util','path','sox','ejs','lodash','squel','desk.js','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/license/util','../../mysqldb','sendStatus','end','status','json','offset','limit','set','Content-Range'];(function(_0x5e3c3e,_0x291dd1){var _0x5c0356=function(_0x40dd33){while(--_0x40dd33){_0x5e3c3e['push'](_0x5e3c3e['shift']());}};_0x5c0356(++_0x291dd1);}(_0xa9e0,0x123));var _0x0a9e=function(_0x3c2a69,_0x4c8b41){_0x3c2a69=_0x3c2a69-0x0;var _0x596bc8=_0xa9e0[_0x3c2a69];return _0x596bc8;};'use strict';var pdf=require(_0x0a9e('0x0'));var emlformat=require(_0x0a9e('0x1'));var rimraf=require(_0x0a9e('0x2'));var zipdir=require('zip-dir');var jsonpatch=require('fast-json-patch');var rp=require(_0x0a9e('0x3'));var moment=require('moment');var BPromise=require(_0x0a9e('0x4'));var Mustache=require(_0x0a9e('0x5'));var util=require(_0x0a9e('0x6'));var path=require(_0x0a9e('0x7'));var sox=require(_0x0a9e('0x8'));var csv=require('to-csv');var ejs=require(_0x0a9e('0x9'));var fs=require('fs');var _=require(_0x0a9e('0xa'));var squel=require(_0x0a9e('0xb'));var crypto=require('crypto');var jsforce=require('jsforce');var deskjs=require(_0x0a9e('0xc'));var toCsv=require('to-csv');var querystring=require('querystring');var Papa=require(_0x0a9e('0xd'));var Redis=require(_0x0a9e('0xe'));var authService=require(_0x0a9e('0xf'));var qs=require(_0x0a9e('0x10'));var as=require(_0x0a9e('0x11'));var hardwareService=require(_0x0a9e('0x12'));var logger=require('../../config/logger')('api');var utils=require('../../config/utils');var config=require('../../config/environment');var licenseUtil=require(_0x0a9e('0x13'));var db=require(_0x0a9e('0x14'))['db'];function respondWithStatusCode(_0xd5b662,_0x26d672){_0x26d672=_0x26d672||0xcc;return function(_0x32d742){if(_0x32d742){return _0xd5b662[_0x0a9e('0x15')](_0x26d672);}return _0xd5b662['status'](_0x26d672)[_0x0a9e('0x16')]();};}function respondWithResult(_0x239b12,_0x2b4227){_0x2b4227=_0x2b4227||0xc8;return function(_0x281129){if(_0x281129){return _0x239b12[_0x0a9e('0x17')](_0x2b4227)[_0x0a9e('0x18')](_0x281129);}};}function respondWithFilteredResult(_0x52a03d,_0x22dccb){return function(_0x5d0880){if(_0x5d0880){var _0x1985b6=_0x5d0880['count'],_0x519dfd=_0x22dccb[_0x0a9e('0x19')],_0x16033c=_0x22dccb['offset']+_0x22dccb[_0x0a9e('0x1a')],_0x12066b;if(_0x16033c>=_0x1985b6){_0x16033c=_0x1985b6;_0x12066b=0xc8;}else{_0x12066b=0xce;}_0x52a03d[_0x0a9e('0x17')](_0x12066b);return _0x52a03d[_0x0a9e('0x1b')](_0x0a9e('0x1c'),_0x519dfd+'-'+_0x16033c+'/'+_0x1985b6)[_0x0a9e('0x18')](_0x5d0880);}return null;};}function patchUpdates(_0x2eb11f){return function(_0x530eb7){try{jsonpatch[_0x0a9e('0x1d')](_0x530eb7,_0x2eb11f,!![]);}catch(_0x1314ae){return BPromise[_0x0a9e('0x1e')](_0x1314ae);}return _0x530eb7[_0x0a9e('0x1f')]();};}function saveUpdates(_0x105080,_0x4bb1e3){return function(_0x2c3407){if(_0x2c3407){return _0x2c3407[_0x0a9e('0x20')](_0x105080)['then'](function(_0x20f109){return _0x20f109;});}return null;};}function removeEntity(_0x5a09ef,_0x588269){return function(_0x3a02e1){if(_0x3a02e1){return _0x3a02e1[_0x0a9e('0x21')]()[_0x0a9e('0x22')](function(){_0x5a09ef[_0x0a9e('0x17')](0xcc)['end']();});}};}function handleEntityNotFound(_0xfb6e48,_0x2fb0e4){return function(_0x3b45bc){if(!_0x3b45bc){_0xfb6e48[_0x0a9e('0x15')](0x194);}return _0x3b45bc;};}function handleError(_0x370d86,_0x42ac8f){_0x42ac8f=_0x42ac8f||0x1f4;return function(_0x16b1ca){logger['error'](_0x16b1ca['stack']);if(_0x16b1ca[_0x0a9e('0x23')]){delete _0x16b1ca[_0x0a9e('0x23')];}_0x370d86[_0x0a9e('0x17')](_0x42ac8f)[_0x0a9e('0x24')](_0x16b1ca);};}exports['index']=function(_0x384319,_0x479bc4){var _0x45a1e7={},_0x5bfb33={},_0x1dc186={'count':0x0,'rows':[]};var _0x34dc65=_[_0x0a9e('0x25')](db[_0x0a9e('0x26')][_0x0a9e('0x27')],function(_0x1538a4){return{'name':_0x1538a4[_0x0a9e('0x28')],'type':_0x1538a4[_0x0a9e('0x29')]['key']};});_0x5bfb33[_0x0a9e('0x2a')]=_[_0x0a9e('0x25')](_0x34dc65,_0x0a9e('0x23'));_0x5bfb33[_0x0a9e('0x2b')]=_['keys'](_0x384319[_0x0a9e('0x2b')]);_0x5bfb33[_0x0a9e('0x2c')]=_[_0x0a9e('0x2d')](_0x5bfb33[_0x0a9e('0x2a')],_0x5bfb33[_0x0a9e('0x2b')]);_0x45a1e7[_0x0a9e('0x2e')]=_[_0x0a9e('0x2d')](_0x5bfb33[_0x0a9e('0x2a')],qs[_0x0a9e('0x2f')](_0x384319['query'][_0x0a9e('0x2f')]));_0x45a1e7['attributes']=_0x45a1e7[_0x0a9e('0x2e')][_0x0a9e('0x30')]?_0x45a1e7[_0x0a9e('0x2e')]:_0x5bfb33[_0x0a9e('0x2a')];if(!_0x384319[_0x0a9e('0x2b')]['hasOwnProperty'](_0x0a9e('0x31'))){_0x45a1e7[_0x0a9e('0x1a')]=qs[_0x0a9e('0x1a')](_0x384319[_0x0a9e('0x2b')][_0x0a9e('0x1a')]);_0x45a1e7[_0x0a9e('0x19')]=qs[_0x0a9e('0x19')](_0x384319[_0x0a9e('0x2b')]['offset']);}_0x45a1e7[_0x0a9e('0x32')]=qs['sort'](_0x384319[_0x0a9e('0x2b')][_0x0a9e('0x33')]);_0x45a1e7[_0x0a9e('0x34')]=qs[_0x0a9e('0x2c')](_['pick'](_0x384319[_0x0a9e('0x2b')],_0x5bfb33[_0x0a9e('0x2c')]),_0x34dc65);if(_0x384319[_0x0a9e('0x2b')][_0x0a9e('0x35')]){_0x45a1e7['where']=_['merge'](_0x45a1e7[_0x0a9e('0x34')],{'$or':_['map'](_0x34dc65,function(_0x24936a){if(_0x24936a[_0x0a9e('0x29')]!==_0x0a9e('0x36')){var _0x1ef87a={};_0x1ef87a[_0x24936a['name']]={'$like':'%'+_0x384319[_0x0a9e('0x2b')][_0x0a9e('0x35')]+'%'};return _0x1ef87a;}})});}_0x45a1e7=_[_0x0a9e('0x37')]({},_0x45a1e7,_0x384319['options']);var _0x1dbf74={'where':_0x45a1e7[_0x0a9e('0x34')]};return db[_0x0a9e('0x26')]['count'](_0x1dbf74)['then'](function(_0x11b61d){_0x1dc186[_0x0a9e('0x38')]=_0x11b61d;if(_0x384319['query'][_0x0a9e('0x39')]){_0x45a1e7[_0x0a9e('0x3a')]=[{'all':!![]}];}return db[_0x0a9e('0x26')][_0x0a9e('0x3b')](_0x45a1e7);})['then'](function(_0x5a594b){_0x1dc186[_0x0a9e('0x3c')]=_0x5a594b;return _0x1dc186;})[_0x0a9e('0x22')](respondWithFilteredResult(_0x479bc4,_0x45a1e7))['catch'](handleError(_0x479bc4,null));};exports[_0x0a9e('0x3d')]=function(_0x1dec2e,_0x1459bb){var _0x5b4f5e={'raw':![],'where':{'id':_0x1dec2e[_0x0a9e('0x3e')]['id']}},_0x316c8f={};_0x316c8f[_0x0a9e('0x2a')]=_[_0x0a9e('0x3f')](db[_0x0a9e('0x26')][_0x0a9e('0x27')]);_0x316c8f[_0x0a9e('0x2b')]=_[_0x0a9e('0x3f')](_0x1dec2e[_0x0a9e('0x2b')]);_0x316c8f[_0x0a9e('0x2c')]=_[_0x0a9e('0x2d')](_0x316c8f[_0x0a9e('0x2a')],_0x316c8f[_0x0a9e('0x2b')]);_0x5b4f5e[_0x0a9e('0x2e')]=_[_0x0a9e('0x2d')](_0x316c8f['model'],qs['fields'](_0x1dec2e[_0x0a9e('0x2b')][_0x0a9e('0x2f')]));_0x5b4f5e[_0x0a9e('0x2e')]=_0x5b4f5e[_0x0a9e('0x2e')][_0x0a9e('0x30')]?_0x5b4f5e[_0x0a9e('0x2e')]:_0x316c8f[_0x0a9e('0x2a')];if(_0x1dec2e[_0x0a9e('0x2b')][_0x0a9e('0x39')]){_0x5b4f5e[_0x0a9e('0x3a')]=[{'all':!![]}];}_0x5b4f5e=_[_0x0a9e('0x37')]({},_0x5b4f5e,_0x1dec2e[_0x0a9e('0x40')]);return db['Automation'][_0x0a9e('0x41')](_0x5b4f5e)[_0x0a9e('0x22')](handleEntityNotFound(_0x1459bb,null))[_0x0a9e('0x22')](respondWithResult(_0x1459bb,null))[_0x0a9e('0x42')](handleError(_0x1459bb,null));};exports[_0x0a9e('0x43')]=function(_0xbe9d19,_0x21eb86){return db[_0x0a9e('0x26')]['create'](_0xbe9d19[_0x0a9e('0x44')],{})['then'](respondWithResult(_0x21eb86,0xc9))[_0x0a9e('0x42')](handleError(_0x21eb86,null));};exports[_0x0a9e('0x20')]=function(_0x8d6dd1,_0x562fb4){if(_0x8d6dd1[_0x0a9e('0x44')]['id']){delete _0x8d6dd1[_0x0a9e('0x44')]['id'];}return db[_0x0a9e('0x26')][_0x0a9e('0x41')]({'where':{'id':_0x8d6dd1[_0x0a9e('0x3e')]['id']}})[_0x0a9e('0x22')](handleEntityNotFound(_0x562fb4,null))[_0x0a9e('0x22')](saveUpdates(_0x8d6dd1['body'],null))[_0x0a9e('0x22')](respondWithResult(_0x562fb4,null))[_0x0a9e('0x42')](handleError(_0x562fb4,null));};exports[_0x0a9e('0x21')]=function(_0x16f976,_0x409789){return db[_0x0a9e('0x26')][_0x0a9e('0x41')]({'where':{'id':_0x16f976[_0x0a9e('0x3e')]['id']}})[_0x0a9e('0x22')](handleEntityNotFound(_0x409789,null))['then'](removeEntity(_0x409789,null))[_0x0a9e('0x42')](handleError(_0x409789,null));};exports[_0x0a9e('0x45')]=function(_0x4f7240,_0x4ae14b,_0x5ddf84){return db[_0x0a9e('0x46')][_0x0a9e('0x41')]({'where':{'id':_0x4f7240[_0x0a9e('0x3e')]['id']}})[_0x0a9e('0x22')](handleEntityNotFound(_0x4ae14b,null))[_0x0a9e('0x22')](function(_0x30decb){if(_0x30decb){return _0x30decb[_0x0a9e('0x45')](_0x4f7240[_0x0a9e('0x44')]['ids'],_['omit'](_0x4f7240['body'],[_0x0a9e('0x47'),'id'])||{});}})[_0x0a9e('0x22')](respondWithResult(_0x4ae14b,null))[_0x0a9e('0x42')](handleError(_0x4ae14b,null));};exports['getConditions']=function(_0x2b69d9,_0x161aa7,_0x53d113){var _0x5a88da={};var _0x2ef381={};var _0x59c6ff;var _0x443e72;return db['Automation'][_0x0a9e('0x48')]({'where':{'id':_0x2b69d9[_0x0a9e('0x3e')]['id']}})[_0x0a9e('0x22')](handleEntityNotFound(_0x161aa7,null))['then'](function(_0x2f82da){if(_0x2f82da){_0x59c6ff=_0x2f82da;_0x2ef381[_0x0a9e('0x2a')]=_['keys'](db['Condition'][_0x0a9e('0x27')]);_0x2ef381[_0x0a9e('0x2b')]=_['keys'](_0x2b69d9[_0x0a9e('0x2b')]);_0x2ef381['filters']=_[_0x0a9e('0x2d')](_0x2ef381['model'],_0x2ef381[_0x0a9e('0x2b')]);_0x5a88da['attributes']=_['intersection'](_0x2ef381['model'],qs[_0x0a9e('0x2f')](_0x2b69d9['query'][_0x0a9e('0x2f')]));_0x5a88da[_0x0a9e('0x2e')]=_0x5a88da[_0x0a9e('0x2e')][_0x0a9e('0x30')]?_0x5a88da[_0x0a9e('0x2e')]:_0x2ef381[_0x0a9e('0x2a')];_0x5a88da[_0x0a9e('0x32')]=qs[_0x0a9e('0x33')](_0x2b69d9['query'][_0x0a9e('0x33')]);_0x5a88da[_0x0a9e('0x34')]=qs[_0x0a9e('0x2c')](_[_0x0a9e('0x49')](_0x2b69d9[_0x0a9e('0x2b')],_0x2ef381[_0x0a9e('0x2c')]));if(_0x2b69d9['query'][_0x0a9e('0x35')]){_0x5a88da[_0x0a9e('0x34')]=_['merge'](_0x5a88da[_0x0a9e('0x34')],{'$or':_['map'](_0x5a88da[_0x0a9e('0x2e')],function(_0x5ba1f9){var _0x4b3c1a={};_0x4b3c1a[_0x5ba1f9]={'$like':'%'+_0x2b69d9['query'][_0x0a9e('0x35')]+'%'};return _0x4b3c1a;})});}_0x5a88da=_['merge']({},_0x5a88da,_0x2b69d9[_0x0a9e('0x40')]);return _0x59c6ff[_0x0a9e('0x4a')](_0x5a88da);}})[_0x0a9e('0x22')](function(_0x7be420){if(_0x7be420){_0x443e72=_0x7be420[_0x0a9e('0x30')];if(!_0x2b69d9[_0x0a9e('0x2b')]['hasOwnProperty'](_0x0a9e('0x31'))){_0x5a88da['limit']=qs[_0x0a9e('0x1a')](_0x2b69d9[_0x0a9e('0x2b')][_0x0a9e('0x1a')]);_0x5a88da['offset']=qs[_0x0a9e('0x19')](_0x2b69d9[_0x0a9e('0x2b')][_0x0a9e('0x19')]);}return _0x59c6ff[_0x0a9e('0x4a')](_0x5a88da);}})['then'](function(_0x1d0dc8){if(_0x1d0dc8){return _0x1d0dc8?{'count':_0x443e72,'rows':_0x1d0dc8}:null;}})[_0x0a9e('0x22')](respondWithResult(_0x161aa7,null))['catch'](handleError(_0x161aa7,null));};exports[_0x0a9e('0x4b')]=function(_0x17e88c,_0x88dcbf,_0x409b29){return db[_0x0a9e('0x4c')]['find']({'where':{'id':_0x17e88c[_0x0a9e('0x3e')]['id']}})[_0x0a9e('0x22')](handleEntityNotFound(_0x88dcbf,null))[_0x0a9e('0x22')](function(_0x47bb43){if(_0x47bb43){return _0x47bb43[_0x0a9e('0x4b')](_0x17e88c['body']['ids'],_[_0x0a9e('0x4d')](_0x17e88c[_0x0a9e('0x44')],[_0x0a9e('0x47'),'id'])||{});}})[_0x0a9e('0x22')](respondWithResult(_0x88dcbf,null))[_0x0a9e('0x42')](handleError(_0x88dcbf,null));};exports[_0x0a9e('0x4e')]=function(_0x387489,_0x54a37d,_0x2d7205){var _0x1cc4f3={};var _0x2e89b7={};var _0x19012b;var _0x2bbb86;return db[_0x0a9e('0x26')][_0x0a9e('0x48')]({'where':{'id':_0x387489[_0x0a9e('0x3e')]['id']}})[_0x0a9e('0x22')](handleEntityNotFound(_0x54a37d,null))[_0x0a9e('0x22')](function(_0x5150a4){if(_0x5150a4){_0x19012b=_0x5150a4;_0x2e89b7[_0x0a9e('0x2a')]=_[_0x0a9e('0x3f')](db[_0x0a9e('0x4c')]['rawAttributes']);_0x2e89b7[_0x0a9e('0x2b')]=_[_0x0a9e('0x3f')](_0x387489['query']);_0x2e89b7[_0x0a9e('0x2c')]=_[_0x0a9e('0x2d')](_0x2e89b7[_0x0a9e('0x2a')],_0x2e89b7[_0x0a9e('0x2b')]);_0x1cc4f3[_0x0a9e('0x2e')]=_['intersection'](_0x2e89b7['model'],qs['fields'](_0x387489[_0x0a9e('0x2b')][_0x0a9e('0x2f')]));_0x1cc4f3[_0x0a9e('0x2e')]=_0x1cc4f3[_0x0a9e('0x2e')][_0x0a9e('0x30')]?_0x1cc4f3[_0x0a9e('0x2e')]:_0x2e89b7[_0x0a9e('0x2a')];_0x1cc4f3[_0x0a9e('0x32')]=qs['sort'](_0x387489[_0x0a9e('0x2b')][_0x0a9e('0x33')]);_0x1cc4f3[_0x0a9e('0x34')]=qs['filters'](_[_0x0a9e('0x49')](_0x387489['query'],_0x2e89b7[_0x0a9e('0x2c')]));if(_0x387489[_0x0a9e('0x2b')]['filter']){_0x1cc4f3[_0x0a9e('0x34')]=_[_0x0a9e('0x37')](_0x1cc4f3[_0x0a9e('0x34')],{'$or':_[_0x0a9e('0x25')](_0x1cc4f3['attributes'],function(_0x1d442c){var _0x2e9552={};_0x2e9552[_0x1d442c]={'$like':'%'+_0x387489[_0x0a9e('0x2b')][_0x0a9e('0x35')]+'%'};return _0x2e9552;})});}_0x1cc4f3=_['merge']({},_0x1cc4f3,_0x387489[_0x0a9e('0x40')]);return _0x19012b[_0x0a9e('0x4e')](_0x1cc4f3);}})[_0x0a9e('0x22')](function(_0x361b21){if(_0x361b21){_0x2bbb86=_0x361b21['length'];if(!_0x387489[_0x0a9e('0x2b')][_0x0a9e('0x4f')](_0x0a9e('0x31'))){_0x1cc4f3[_0x0a9e('0x1a')]=qs[_0x0a9e('0x1a')](_0x387489[_0x0a9e('0x2b')][_0x0a9e('0x1a')]);_0x1cc4f3[_0x0a9e('0x19')]=qs[_0x0a9e('0x19')](_0x387489[_0x0a9e('0x2b')][_0x0a9e('0x19')]);}return _0x19012b[_0x0a9e('0x4e')](_0x1cc4f3);}})[_0x0a9e('0x22')](function(_0xe0749e){if(_0xe0749e){return _0xe0749e?{'count':_0x2bbb86,'rows':_0xe0749e}:null;}})['then'](respondWithResult(_0x54a37d,null))[_0x0a9e('0x42')](handleError(_0x54a37d,null));};
\ No newline at end of file
+var _0x719f=['jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/advancedSearch','../../config/license/hardware','api','../../config/utils','../../config/environment','../../mysqldb','sendStatus','status','end','count','offset','set','Content-Range','json','apply','reject','update','then','destroy','error','name','send','index','Automation','rawAttributes','fieldName','type','key','model','query','keys','intersection','attributes','fields','length','hasOwnProperty','nolimit','limit','order','sort','where','filters','filter','merge','map','VIRTUAL','options','includeAll','include','rows','catch','show','find','create','body','params','addConditions','omit','getConditions','findOne','Condition','pick','addActions','ids','getActions','html-pdf','rimraf','zip-dir','request-promise','moment','bluebird','mustache','util','path','sox','to-csv','ejs','lodash'];(function(_0x206a08,_0x524918){var _0x34cd48=function(_0x5ddb1c){while(--_0x5ddb1c){_0x206a08['push'](_0x206a08['shift']());}};_0x34cd48(++_0x524918);}(_0x719f,0x1eb));var _0xf719=function(_0xa1e3ca,_0x559022){_0xa1e3ca=_0xa1e3ca-0x0;var _0x5005ab=_0x719f[_0xa1e3ca];return _0x5005ab;};'use strict';var pdf=require(_0xf719('0x0'));var emlformat=require('eml-format');var rimraf=require(_0xf719('0x1'));var zipdir=require(_0xf719('0x2'));var jsonpatch=require('fast-json-patch');var rp=require(_0xf719('0x3'));var moment=require(_0xf719('0x4'));var BPromise=require(_0xf719('0x5'));var Mustache=require(_0xf719('0x6'));var util=require(_0xf719('0x7'));var path=require(_0xf719('0x8'));var sox=require(_0xf719('0x9'));var csv=require(_0xf719('0xa'));var ejs=require(_0xf719('0xb'));var fs=require('fs');var _=require(_0xf719('0xc'));var squel=require('squel');var crypto=require('crypto');var jsforce=require(_0xf719('0xd'));var deskjs=require(_0xf719('0xe'));var toCsv=require('to-csv');var querystring=require(_0xf719('0xf'));var Papa=require(_0xf719('0x10'));var Redis=require(_0xf719('0x11'));var authService=require(_0xf719('0x12'));var qs=require('../../components/parsers/qs');var as=require(_0xf719('0x13'));var hardwareService=require(_0xf719('0x14'));var logger=require('../../config/logger')(_0xf719('0x15'));var utils=require(_0xf719('0x16'));var config=require(_0xf719('0x17'));var licenseUtil=require('../../config/license/util');var db=require(_0xf719('0x18'))['db'];function respondWithStatusCode(_0x843f88,_0x1901f8){_0x1901f8=_0x1901f8||0xcc;return function(_0x1c6245){if(_0x1c6245){return _0x843f88[_0xf719('0x19')](_0x1901f8);}return _0x843f88[_0xf719('0x1a')](_0x1901f8)[_0xf719('0x1b')]();};}function respondWithResult(_0x510acb,_0x3978bf){_0x3978bf=_0x3978bf||0xc8;return function(_0x1fc249){if(_0x1fc249){return _0x510acb[_0xf719('0x1a')](_0x3978bf)['json'](_0x1fc249);}};}function respondWithFilteredResult(_0x3269bb,_0x687314){return function(_0x1bbeae){if(_0x1bbeae){var _0x20ca96=_0x1bbeae[_0xf719('0x1c')],_0xf47819=_0x687314[_0xf719('0x1d')],_0x52cf95=_0x687314[_0xf719('0x1d')]+_0x687314['limit'],_0x2b5b37;if(_0x52cf95>=_0x20ca96){_0x52cf95=_0x20ca96;_0x2b5b37=0xc8;}else{_0x2b5b37=0xce;}_0x3269bb['status'](_0x2b5b37);return _0x3269bb[_0xf719('0x1e')](_0xf719('0x1f'),_0xf47819+'-'+_0x52cf95+'/'+_0x20ca96)[_0xf719('0x20')](_0x1bbeae);}return null;};}function patchUpdates(_0x537890){return function(_0x581e2e){try{jsonpatch[_0xf719('0x21')](_0x581e2e,_0x537890,!![]);}catch(_0xacefd2){return BPromise[_0xf719('0x22')](_0xacefd2);}return _0x581e2e['save']();};}function saveUpdates(_0x1d037f,_0x15e3f6){return function(_0x3149be){if(_0x3149be){return _0x3149be[_0xf719('0x23')](_0x1d037f)[_0xf719('0x24')](function(_0x19f932){return _0x19f932;});}return null;};}function removeEntity(_0x3ad718,_0x54d701){return function(_0xa6e0a2){if(_0xa6e0a2){return _0xa6e0a2[_0xf719('0x25')]()[_0xf719('0x24')](function(){_0x3ad718['status'](0xcc)[_0xf719('0x1b')]();});}};}function handleEntityNotFound(_0x3b8b52,_0xf672af){return function(_0x37dbdd){if(!_0x37dbdd){_0x3b8b52['sendStatus'](0x194);}return _0x37dbdd;};}function handleError(_0x3502cf,_0x401df9){_0x401df9=_0x401df9||0x1f4;return function(_0x25f732){logger[_0xf719('0x26')](_0x25f732['stack']);if(_0x25f732[_0xf719('0x27')]){delete _0x25f732['name'];}_0x3502cf[_0xf719('0x1a')](_0x401df9)[_0xf719('0x28')](_0x25f732);};}exports[_0xf719('0x29')]=function(_0x3f0134,_0x13e28e){var _0x276678={},_0x3a6f54={},_0x1176b4={'count':0x0,'rows':[]};var _0x504e95=_['map'](db[_0xf719('0x2a')][_0xf719('0x2b')],function(_0x1d0b90){return{'name':_0x1d0b90[_0xf719('0x2c')],'type':_0x1d0b90[_0xf719('0x2d')][_0xf719('0x2e')]};});_0x3a6f54[_0xf719('0x2f')]=_['map'](_0x504e95,'name');_0x3a6f54[_0xf719('0x30')]=_[_0xf719('0x31')](_0x3f0134[_0xf719('0x30')]);_0x3a6f54['filters']=_[_0xf719('0x32')](_0x3a6f54[_0xf719('0x2f')],_0x3a6f54['query']);_0x276678[_0xf719('0x33')]=_[_0xf719('0x32')](_0x3a6f54[_0xf719('0x2f')],qs[_0xf719('0x34')](_0x3f0134[_0xf719('0x30')][_0xf719('0x34')]));_0x276678['attributes']=_0x276678['attributes'][_0xf719('0x35')]?_0x276678[_0xf719('0x33')]:_0x3a6f54[_0xf719('0x2f')];if(!_0x3f0134[_0xf719('0x30')][_0xf719('0x36')](_0xf719('0x37'))){_0x276678['limit']=qs[_0xf719('0x38')](_0x3f0134['query'][_0xf719('0x38')]);_0x276678[_0xf719('0x1d')]=qs[_0xf719('0x1d')](_0x3f0134[_0xf719('0x30')][_0xf719('0x1d')]);}_0x276678[_0xf719('0x39')]=qs[_0xf719('0x3a')](_0x3f0134[_0xf719('0x30')][_0xf719('0x3a')]);_0x276678[_0xf719('0x3b')]=qs[_0xf719('0x3c')](_['pick'](_0x3f0134[_0xf719('0x30')],_0x3a6f54[_0xf719('0x3c')]),_0x504e95);if(_0x3f0134[_0xf719('0x30')][_0xf719('0x3d')]){_0x276678[_0xf719('0x3b')]=_[_0xf719('0x3e')](_0x276678[_0xf719('0x3b')],{'$or':_[_0xf719('0x3f')](_0x504e95,function(_0x3b4fcb){if(_0x3b4fcb[_0xf719('0x2d')]!==_0xf719('0x40')){var _0x2b9c94={};_0x2b9c94[_0x3b4fcb['name']]={'$like':'%'+_0x3f0134[_0xf719('0x30')][_0xf719('0x3d')]+'%'};return _0x2b9c94;}})});}_0x276678=_[_0xf719('0x3e')]({},_0x276678,_0x3f0134[_0xf719('0x41')]);var _0x51124b={'where':_0x276678[_0xf719('0x3b')]};return db[_0xf719('0x2a')]['count'](_0x51124b)[_0xf719('0x24')](function(_0x250fb4){_0x1176b4[_0xf719('0x1c')]=_0x250fb4;if(_0x3f0134['query'][_0xf719('0x42')]){_0x276678[_0xf719('0x43')]=[{'all':!![]}];}return db[_0xf719('0x2a')]['findAll'](_0x276678);})[_0xf719('0x24')](function(_0x4acd5f){_0x1176b4[_0xf719('0x44')]=_0x4acd5f;return _0x1176b4;})[_0xf719('0x24')](respondWithFilteredResult(_0x13e28e,_0x276678))[_0xf719('0x45')](handleError(_0x13e28e,null));};exports[_0xf719('0x46')]=function(_0x5c2c0b,_0x2c8b9d){var _0x1b9419={'raw':![],'where':{'id':_0x5c2c0b['params']['id']}},_0x4d72f4={};_0x4d72f4[_0xf719('0x2f')]=_[_0xf719('0x31')](db['Automation']['rawAttributes']);_0x4d72f4[_0xf719('0x30')]=_[_0xf719('0x31')](_0x5c2c0b[_0xf719('0x30')]);_0x4d72f4[_0xf719('0x3c')]=_[_0xf719('0x32')](_0x4d72f4['model'],_0x4d72f4[_0xf719('0x30')]);_0x1b9419[_0xf719('0x33')]=_[_0xf719('0x32')](_0x4d72f4[_0xf719('0x2f')],qs[_0xf719('0x34')](_0x5c2c0b[_0xf719('0x30')][_0xf719('0x34')]));_0x1b9419['attributes']=_0x1b9419[_0xf719('0x33')][_0xf719('0x35')]?_0x1b9419['attributes']:_0x4d72f4[_0xf719('0x2f')];if(_0x5c2c0b['query']['includeAll']){_0x1b9419[_0xf719('0x43')]=[{'all':!![]}];}_0x1b9419=_[_0xf719('0x3e')]({},_0x1b9419,_0x5c2c0b[_0xf719('0x41')]);return db['Automation'][_0xf719('0x47')](_0x1b9419)['then'](handleEntityNotFound(_0x2c8b9d,null))[_0xf719('0x24')](respondWithResult(_0x2c8b9d,null))[_0xf719('0x45')](handleError(_0x2c8b9d,null));};exports[_0xf719('0x48')]=function(_0xc6489d,_0x190395){return db[_0xf719('0x2a')]['create'](_0xc6489d['body'],{})[_0xf719('0x24')](respondWithResult(_0x190395,0xc9))[_0xf719('0x45')](handleError(_0x190395,null));};exports[_0xf719('0x23')]=function(_0x14c869,_0x2f01e5){if(_0x14c869[_0xf719('0x49')]['id']){delete _0x14c869['body']['id'];}return db['Automation']['find']({'where':{'id':_0x14c869[_0xf719('0x4a')]['id']}})['then'](handleEntityNotFound(_0x2f01e5,null))[_0xf719('0x24')](saveUpdates(_0x14c869[_0xf719('0x49')],null))[_0xf719('0x24')](respondWithResult(_0x2f01e5,null))['catch'](handleError(_0x2f01e5,null));};exports[_0xf719('0x25')]=function(_0x20165f,_0x175239){return db[_0xf719('0x2a')]['find']({'where':{'id':_0x20165f['params']['id']}})['then'](handleEntityNotFound(_0x175239,null))[_0xf719('0x24')](removeEntity(_0x175239,null))[_0xf719('0x45')](handleError(_0x175239,null));};exports[_0xf719('0x4b')]=function(_0x4c3f72,_0x15131c,_0x4deadd){return db['Condition'][_0xf719('0x47')]({'where':{'id':_0x4c3f72['params']['id']}})[_0xf719('0x24')](handleEntityNotFound(_0x15131c,null))['then'](function(_0x22d9f1){if(_0x22d9f1){return _0x22d9f1[_0xf719('0x4b')](_0x4c3f72[_0xf719('0x49')]['ids'],_[_0xf719('0x4c')](_0x4c3f72[_0xf719('0x49')],['ids','id'])||{});}})[_0xf719('0x24')](respondWithResult(_0x15131c,null))[_0xf719('0x45')](handleError(_0x15131c,null));};exports[_0xf719('0x4d')]=function(_0x5d077b,_0x1fbc39,_0x1eb788){var _0x5b9091={};var _0x2a0c9d={};var _0x4a4d8d;var _0x798883;return db[_0xf719('0x2a')][_0xf719('0x4e')]({'where':{'id':_0x5d077b['params']['id']}})['then'](handleEntityNotFound(_0x1fbc39,null))[_0xf719('0x24')](function(_0x42155d){if(_0x42155d){_0x4a4d8d=_0x42155d;_0x2a0c9d[_0xf719('0x2f')]=_['keys'](db[_0xf719('0x4f')][_0xf719('0x2b')]);_0x2a0c9d['query']=_[_0xf719('0x31')](_0x5d077b[_0xf719('0x30')]);_0x2a0c9d[_0xf719('0x3c')]=_[_0xf719('0x32')](_0x2a0c9d['model'],_0x2a0c9d[_0xf719('0x30')]);_0x5b9091[_0xf719('0x33')]=_[_0xf719('0x32')](_0x2a0c9d['model'],qs['fields'](_0x5d077b['query'][_0xf719('0x34')]));_0x5b9091['attributes']=_0x5b9091[_0xf719('0x33')][_0xf719('0x35')]?_0x5b9091['attributes']:_0x2a0c9d['model'];_0x5b9091['order']=qs['sort'](_0x5d077b[_0xf719('0x30')][_0xf719('0x3a')]);_0x5b9091['where']=qs[_0xf719('0x3c')](_[_0xf719('0x50')](_0x5d077b[_0xf719('0x30')],_0x2a0c9d[_0xf719('0x3c')]));if(_0x5d077b[_0xf719('0x30')][_0xf719('0x3d')]){_0x5b9091[_0xf719('0x3b')]=_[_0xf719('0x3e')](_0x5b9091[_0xf719('0x3b')],{'$or':_[_0xf719('0x3f')](_0x5b9091['attributes'],function(_0x39a1b8){var _0x401689={};_0x401689[_0x39a1b8]={'$like':'%'+_0x5d077b[_0xf719('0x30')]['filter']+'%'};return _0x401689;})});}_0x5b9091=_[_0xf719('0x3e')]({},_0x5b9091,_0x5d077b[_0xf719('0x41')]);return _0x4a4d8d[_0xf719('0x4d')](_0x5b9091);}})[_0xf719('0x24')](function(_0x3e563f){if(_0x3e563f){_0x798883=_0x3e563f[_0xf719('0x35')];if(!_0x5d077b['query']['hasOwnProperty']('nolimit')){_0x5b9091[_0xf719('0x38')]=qs[_0xf719('0x38')](_0x5d077b['query'][_0xf719('0x38')]);_0x5b9091[_0xf719('0x1d')]=qs['offset'](_0x5d077b['query']['offset']);}return _0x4a4d8d['getConditions'](_0x5b9091);}})['then'](function(_0x501872){if(_0x501872){return _0x501872?{'count':_0x798883,'rows':_0x501872}:null;}})[_0xf719('0x24')](respondWithResult(_0x1fbc39,null))[_0xf719('0x45')](handleError(_0x1fbc39,null));};exports[_0xf719('0x51')]=function(_0x461529,_0x3419bd,_0x162305){return db['Action']['find']({'where':{'id':_0x461529['params']['id']}})[_0xf719('0x24')](handleEntityNotFound(_0x3419bd,null))[_0xf719('0x24')](function(_0x1a938b){if(_0x1a938b){return _0x1a938b[_0xf719('0x51')](_0x461529[_0xf719('0x49')][_0xf719('0x52')],_[_0xf719('0x4c')](_0x461529['body'],[_0xf719('0x52'),'id'])||{});}})[_0xf719('0x24')](respondWithResult(_0x3419bd,null))['catch'](handleError(_0x3419bd,null));};exports[_0xf719('0x53')]=function(_0x3f523d,_0x4d7dd8,_0x23b6d8){var _0x29dbf1={};var _0x27a688={};var _0x538a41;var _0x2d64cb;return db[_0xf719('0x2a')][_0xf719('0x4e')]({'where':{'id':_0x3f523d[_0xf719('0x4a')]['id']}})[_0xf719('0x24')](handleEntityNotFound(_0x4d7dd8,null))[_0xf719('0x24')](function(_0xa78b8e){if(_0xa78b8e){_0x538a41=_0xa78b8e;_0x27a688[_0xf719('0x2f')]=_[_0xf719('0x31')](db['Action']['rawAttributes']);_0x27a688[_0xf719('0x30')]=_[_0xf719('0x31')](_0x3f523d[_0xf719('0x30')]);_0x27a688[_0xf719('0x3c')]=_[_0xf719('0x32')](_0x27a688[_0xf719('0x2f')],_0x27a688['query']);_0x29dbf1['attributes']=_[_0xf719('0x32')](_0x27a688['model'],qs[_0xf719('0x34')](_0x3f523d[_0xf719('0x30')][_0xf719('0x34')]));_0x29dbf1[_0xf719('0x33')]=_0x29dbf1[_0xf719('0x33')]['length']?_0x29dbf1[_0xf719('0x33')]:_0x27a688[_0xf719('0x2f')];_0x29dbf1[_0xf719('0x39')]=qs[_0xf719('0x3a')](_0x3f523d[_0xf719('0x30')][_0xf719('0x3a')]);_0x29dbf1['where']=qs[_0xf719('0x3c')](_['pick'](_0x3f523d['query'],_0x27a688[_0xf719('0x3c')]));if(_0x3f523d['query'][_0xf719('0x3d')]){_0x29dbf1['where']=_[_0xf719('0x3e')](_0x29dbf1[_0xf719('0x3b')],{'$or':_[_0xf719('0x3f')](_0x29dbf1[_0xf719('0x33')],function(_0x299828){var _0x2a8689={};_0x2a8689[_0x299828]={'$like':'%'+_0x3f523d['query']['filter']+'%'};return _0x2a8689;})});}_0x29dbf1=_['merge']({},_0x29dbf1,_0x3f523d[_0xf719('0x41')]);return _0x538a41['getActions'](_0x29dbf1);}})[_0xf719('0x24')](function(_0x48df97){if(_0x48df97){_0x2d64cb=_0x48df97[_0xf719('0x35')];if(!_0x3f523d[_0xf719('0x30')]['hasOwnProperty']('nolimit')){_0x29dbf1[_0xf719('0x38')]=qs['limit'](_0x3f523d[_0xf719('0x30')][_0xf719('0x38')]);_0x29dbf1[_0xf719('0x1d')]=qs['offset'](_0x3f523d['query']['offset']);}return _0x538a41[_0xf719('0x53')](_0x29dbf1);}})['then'](function(_0x482ab5){if(_0x482ab5){return _0x482ab5?{'count':_0x2d64cb,'rows':_0x482ab5}:null;}})[_0xf719('0x24')](respondWithResult(_0x4d7dd8,null))['catch'](handleError(_0x4d7dd8,null));};
\ No newline at end of file