Built motion from commit ff78e754.|2.6.29
[motion2.git] / server / api / automation / automation.controller.js
index 3315e92..e99bad1 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x967a=['create','body','addConditions','Condition','ids','getConditions','findOne','addActions','Action','omit','getActions','rimraf','fast-json-patch','request-promise','bluebird','util','sox','to-csv','ejs','fs-extra','lodash','crypto','papaparse','ioredis','../../components/auth/service','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','end','status','json','offset','undefined','count','limit','Content-Range','apply','reject','save','then','sendStatus','error','stack','name','send','index','rawAttributes','fieldName','model','map','query','keys','intersection','fields','attributes','length','hasOwnProperty','nolimit','order','sort','where','filters','pick','filter','merge','type','VIRTUAL','options','includeAll','include','Automation','rows','catch','params','find'];(function(_0x23493c,_0xece383){var _0xb4af18=function(_0x3d28af){while(--_0x3d28af){_0x23493c['push'](_0x23493c['shift']());}};_0xb4af18(++_0xece383);}(_0x967a,0xf2));var _0xa967=function(_0x5170b3,_0x5df19e){_0x5170b3=_0x5170b3-0x0;var _0x4e43a7=_0x967a[_0x5170b3];return _0x4e43a7;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0xa967('0x0'));var zipdir=require('zip-dir');var jsonpatch=require(_0xa967('0x1'));var rp=require(_0xa967('0x2'));var moment=require('moment');var BPromise=require(_0xa967('0x3'));var Mustache=require('mustache');var util=require(_0xa967('0x4'));var path=require('path');var sox=require(_0xa967('0x5'));var csv=require(_0xa967('0x6'));var ejs=require(_0xa967('0x7'));var fs=require('fs');var fs_extra=require(_0xa967('0x8'));var _=require(_0xa967('0x9'));var squel=require('squel');var crypto=require(_0xa967('0xa'));var jsforce=require('jsforce');var deskjs=require('desk.js');var toCsv=require('to-csv');var querystring=require('querystring');var Papa=require(_0xa967('0xb'));var Redis=require(_0xa967('0xc'));var authService=require(_0xa967('0xd'));var qs=require('../../components/parsers/qs');var as=require(_0xa967('0xe'));var hardwareService=require(_0xa967('0xf'));var logger=require(_0xa967('0x10'))(_0xa967('0x11'));var utils=require(_0xa967('0x12'));var config=require('../../config/environment');var licenseUtil=require('../../config/license/util');var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x40eabd,_0x218ed5){_0x218ed5=_0x218ed5||0xcc;return function(_0x3e4d19){if(_0x3e4d19){return _0x40eabd['sendStatus'](_0x218ed5);}return _0x40eabd['status'](_0x218ed5)[_0xa967('0x13')]();};}function respondWithResult(_0x330e97,_0x17fff1){_0x17fff1=_0x17fff1||0xc8;return function(_0x129b0c){if(_0x129b0c){return _0x330e97[_0xa967('0x14')](_0x17fff1)[_0xa967('0x15')](_0x129b0c);}};}function respondWithFilteredResult(_0x396487,_0x4d1ef2){return function(_0x234bdc){if(_0x234bdc){var _0x3c73df=typeof _0x4d1ef2[_0xa967('0x16')]==='undefined'&&typeof _0x4d1ef2['limit']===_0xa967('0x17');var _0xd66328=_0x234bdc['count'];var _0x295d7b=_0x3c73df?0x0:_0x4d1ef2['offset'];var _0x3d3257=_0x3c73df?_0x234bdc[_0xa967('0x18')]:_0x4d1ef2['offset']+_0x4d1ef2[_0xa967('0x19')];var _0x320b81;if(_0x3d3257>=_0xd66328){_0x3d3257=_0xd66328;_0x320b81=0xc8;}else{_0x320b81=0xce;}_0x396487['status'](_0x320b81);return _0x396487['set'](_0xa967('0x1a'),_0x295d7b+'-'+_0x3d3257+'/'+_0xd66328)[_0xa967('0x15')](_0x234bdc);}return null;};}function patchUpdates(_0x615df6){return function(_0xa859d0){try{jsonpatch[_0xa967('0x1b')](_0xa859d0,_0x615df6,!![]);}catch(_0x171871){return BPromise[_0xa967('0x1c')](_0x171871);}return _0xa859d0[_0xa967('0x1d')]();};}function saveUpdates(_0x517cf4,_0x5b8047){return function(_0x1e0645){if(_0x1e0645){return _0x1e0645['update'](_0x517cf4)[_0xa967('0x1e')](function(_0x42c808){return _0x42c808;});}return null;};}function removeEntity(_0x59ddf7,_0x5a99d7){return function(_0x2cf1d7){if(_0x2cf1d7){return _0x2cf1d7['destroy']()[_0xa967('0x1e')](function(){_0x59ddf7[_0xa967('0x14')](0xcc)[_0xa967('0x13')]();});}};}function handleEntityNotFound(_0x31f84f,_0x4bb2d1){return function(_0x4dc81c){if(!_0x4dc81c){_0x31f84f[_0xa967('0x1f')](0x194);}return _0x4dc81c;};}function handleError(_0x410204,_0x13cc54){_0x13cc54=_0x13cc54||0x1f4;return function(_0xb413b7){logger[_0xa967('0x20')](_0xb413b7[_0xa967('0x21')]);if(_0xb413b7['name']){delete _0xb413b7[_0xa967('0x22')];}_0x410204[_0xa967('0x14')](_0x13cc54)[_0xa967('0x23')](_0xb413b7);};}exports[_0xa967('0x24')]=function(_0xf2845d,_0x50953f){var _0x3c977d={},_0x5ab51a={},_0x327950={'count':0x0,'rows':[]};var _0x52b37d=_['map'](db['Automation'][_0xa967('0x25')],function(_0x29f77d){return{'name':_0x29f77d[_0xa967('0x26')],'type':_0x29f77d['type']['key']};});_0x5ab51a[_0xa967('0x27')]=_[_0xa967('0x28')](_0x52b37d,_0xa967('0x22'));_0x5ab51a[_0xa967('0x29')]=_[_0xa967('0x2a')](_0xf2845d['query']);_0x5ab51a['filters']=_[_0xa967('0x2b')](_0x5ab51a[_0xa967('0x27')],_0x5ab51a['query']);_0x3c977d['attributes']=_[_0xa967('0x2b')](_0x5ab51a['model'],qs[_0xa967('0x2c')](_0xf2845d[_0xa967('0x29')][_0xa967('0x2c')]));_0x3c977d[_0xa967('0x2d')]=_0x3c977d['attributes'][_0xa967('0x2e')]?_0x3c977d[_0xa967('0x2d')]:_0x5ab51a[_0xa967('0x27')];if(!_0xf2845d['query'][_0xa967('0x2f')](_0xa967('0x30'))){_0x3c977d[_0xa967('0x19')]=qs['limit'](_0xf2845d[_0xa967('0x29')][_0xa967('0x19')]);_0x3c977d[_0xa967('0x16')]=qs[_0xa967('0x16')](_0xf2845d[_0xa967('0x29')]['offset']);}_0x3c977d[_0xa967('0x31')]=qs[_0xa967('0x32')](_0xf2845d[_0xa967('0x29')][_0xa967('0x32')]);_0x3c977d[_0xa967('0x33')]=qs[_0xa967('0x34')](_[_0xa967('0x35')](_0xf2845d[_0xa967('0x29')],_0x5ab51a['filters']),_0x52b37d);if(_0xf2845d['query'][_0xa967('0x36')]){_0x3c977d['where']=_[_0xa967('0x37')](_0x3c977d[_0xa967('0x33')],{'$or':_['map'](_0x52b37d,function(_0x46ef2b){if(_0x46ef2b[_0xa967('0x38')]!==_0xa967('0x39')){var _0x52c631={};_0x52c631[_0x46ef2b[_0xa967('0x22')]]={'$like':'%'+_0xf2845d['query'][_0xa967('0x36')]+'%'};return _0x52c631;}})});}_0x3c977d=_['merge']({},_0x3c977d,_0xf2845d[_0xa967('0x3a')]);var _0xed8ef1={'where':_0x3c977d[_0xa967('0x33')]};return db['Automation'][_0xa967('0x18')](_0xed8ef1)[_0xa967('0x1e')](function(_0x58fc26){_0x327950[_0xa967('0x18')]=_0x58fc26;if(_0xf2845d[_0xa967('0x29')][_0xa967('0x3b')]){_0x3c977d[_0xa967('0x3c')]=[{'all':!![]}];}return db[_0xa967('0x3d')]['findAll'](_0x3c977d);})[_0xa967('0x1e')](function(_0x3cb6de){_0x327950[_0xa967('0x3e')]=_0x3cb6de;return _0x327950;})[_0xa967('0x1e')](respondWithFilteredResult(_0x50953f,_0x3c977d))[_0xa967('0x3f')](handleError(_0x50953f,null));};exports['show']=function(_0x1cbfd5,_0x3e86c7){var _0x1a29c0={'raw':![],'where':{'id':_0x1cbfd5[_0xa967('0x40')]['id']}},_0x16d800={};_0x16d800['model']=_[_0xa967('0x2a')](db[_0xa967('0x3d')]['rawAttributes']);_0x16d800[_0xa967('0x29')]=_['keys'](_0x1cbfd5[_0xa967('0x29')]);_0x16d800[_0xa967('0x34')]=_[_0xa967('0x2b')](_0x16d800[_0xa967('0x27')],_0x16d800[_0xa967('0x29')]);_0x1a29c0[_0xa967('0x2d')]=_[_0xa967('0x2b')](_0x16d800['model'],qs[_0xa967('0x2c')](_0x1cbfd5['query'][_0xa967('0x2c')]));_0x1a29c0[_0xa967('0x2d')]=_0x1a29c0['attributes'][_0xa967('0x2e')]?_0x1a29c0[_0xa967('0x2d')]:_0x16d800[_0xa967('0x27')];if(_0x1cbfd5['query'][_0xa967('0x3b')]){_0x1a29c0['include']=[{'all':!![]}];}_0x1a29c0=_[_0xa967('0x37')]({},_0x1a29c0,_0x1cbfd5['options']);return db['Automation'][_0xa967('0x41')](_0x1a29c0)['then'](handleEntityNotFound(_0x3e86c7,null))[_0xa967('0x1e')](respondWithResult(_0x3e86c7,null))[_0xa967('0x3f')](handleError(_0x3e86c7,null));};exports[_0xa967('0x42')]=function(_0x1b9408,_0x1e63e0){return db[_0xa967('0x3d')]['create'](_0x1b9408[_0xa967('0x43')],{})[_0xa967('0x1e')](respondWithResult(_0x1e63e0,0xc9))[_0xa967('0x3f')](handleError(_0x1e63e0,null));};exports['update']=function(_0xb5f0ae,_0x3ec895){if(_0xb5f0ae[_0xa967('0x43')]['id']){delete _0xb5f0ae['body']['id'];}return db['Automation'][_0xa967('0x41')]({'where':{'id':_0xb5f0ae[_0xa967('0x40')]['id']}})['then'](handleEntityNotFound(_0x3ec895,null))[_0xa967('0x1e')](saveUpdates(_0xb5f0ae[_0xa967('0x43')],null))[_0xa967('0x1e')](respondWithResult(_0x3ec895,null))[_0xa967('0x3f')](handleError(_0x3ec895,null));};exports['destroy']=function(_0xb36b39,_0x296a37){return db[_0xa967('0x3d')]['find']({'where':{'id':_0xb36b39[_0xa967('0x40')]['id']}})[_0xa967('0x1e')](handleEntityNotFound(_0x296a37,null))['then'](removeEntity(_0x296a37,null))[_0xa967('0x3f')](handleError(_0x296a37,null));};exports[_0xa967('0x44')]=function(_0x6eef9c,_0x26ae51,_0x116438){return db[_0xa967('0x45')][_0xa967('0x41')]({'where':{'id':_0x6eef9c[_0xa967('0x40')]['id']}})['then'](handleEntityNotFound(_0x26ae51,null))[_0xa967('0x1e')](function(_0x559c2a){if(_0x559c2a){return _0x559c2a[_0xa967('0x44')](_0x6eef9c[_0xa967('0x43')][_0xa967('0x46')],_['omit'](_0x6eef9c[_0xa967('0x43')],[_0xa967('0x46'),'id'])||{});}})[_0xa967('0x1e')](respondWithResult(_0x26ae51,null))[_0xa967('0x3f')](handleError(_0x26ae51,null));};exports[_0xa967('0x47')]=function(_0x3f3e3b,_0x4eb75f,_0x2248c8){var _0x56baa2={};var _0x38bfff={};var _0x5c72f1;var _0x20c74c;return db[_0xa967('0x3d')][_0xa967('0x48')]({'where':{'id':_0x3f3e3b[_0xa967('0x40')]['id']}})[_0xa967('0x1e')](handleEntityNotFound(_0x4eb75f,null))['then'](function(_0x100556){if(_0x100556){_0x5c72f1=_0x100556;_0x38bfff[_0xa967('0x27')]=_[_0xa967('0x2a')](db['Condition'][_0xa967('0x25')]);_0x38bfff[_0xa967('0x29')]=_[_0xa967('0x2a')](_0x3f3e3b['query']);_0x38bfff['filters']=_[_0xa967('0x2b')](_0x38bfff['model'],_0x38bfff[_0xa967('0x29')]);_0x56baa2['attributes']=_['intersection'](_0x38bfff[_0xa967('0x27')],qs[_0xa967('0x2c')](_0x3f3e3b[_0xa967('0x29')][_0xa967('0x2c')]));_0x56baa2[_0xa967('0x2d')]=_0x56baa2[_0xa967('0x2d')][_0xa967('0x2e')]?_0x56baa2[_0xa967('0x2d')]:_0x38bfff['model'];_0x56baa2[_0xa967('0x31')]=qs[_0xa967('0x32')](_0x3f3e3b[_0xa967('0x29')]['sort']);_0x56baa2[_0xa967('0x33')]=qs[_0xa967('0x34')](_[_0xa967('0x35')](_0x3f3e3b[_0xa967('0x29')],_0x38bfff[_0xa967('0x34')]));if(_0x3f3e3b['query'][_0xa967('0x36')]){_0x56baa2[_0xa967('0x33')]=_[_0xa967('0x37')](_0x56baa2['where'],{'$or':_[_0xa967('0x28')](_0x56baa2[_0xa967('0x2d')],function(_0x500092){var _0x1c4c2b={};_0x1c4c2b[_0x500092]={'$like':'%'+_0x3f3e3b['query'][_0xa967('0x36')]+'%'};return _0x1c4c2b;})});}_0x56baa2=_[_0xa967('0x37')]({},_0x56baa2,_0x3f3e3b[_0xa967('0x3a')]);return _0x5c72f1[_0xa967('0x47')](_0x56baa2);}})[_0xa967('0x1e')](function(_0x1df1b1){if(_0x1df1b1){_0x20c74c=_0x1df1b1[_0xa967('0x2e')];if(!_0x3f3e3b[_0xa967('0x29')]['hasOwnProperty'](_0xa967('0x30'))){_0x56baa2[_0xa967('0x19')]=qs[_0xa967('0x19')](_0x3f3e3b[_0xa967('0x29')][_0xa967('0x19')]);_0x56baa2[_0xa967('0x16')]=qs[_0xa967('0x16')](_0x3f3e3b['query'][_0xa967('0x16')]);}return _0x5c72f1[_0xa967('0x47')](_0x56baa2);}})[_0xa967('0x1e')](function(_0x4c5948){if(_0x4c5948){return _0x4c5948?{'count':_0x20c74c,'rows':_0x4c5948}:null;}})[_0xa967('0x1e')](respondWithResult(_0x4eb75f,null))[_0xa967('0x3f')](handleError(_0x4eb75f,null));};exports[_0xa967('0x49')]=function(_0x5d70d4,_0x27479f,_0x220b29){return db[_0xa967('0x4a')][_0xa967('0x41')]({'where':{'id':_0x5d70d4['params']['id']}})['then'](handleEntityNotFound(_0x27479f,null))[_0xa967('0x1e')](function(_0xf14816){if(_0xf14816){return _0xf14816['addActions'](_0x5d70d4['body'][_0xa967('0x46')],_[_0xa967('0x4b')](_0x5d70d4[_0xa967('0x43')],[_0xa967('0x46'),'id'])||{});}})[_0xa967('0x1e')](respondWithResult(_0x27479f,null))[_0xa967('0x3f')](handleError(_0x27479f,null));};exports[_0xa967('0x4c')]=function(_0x20c239,_0x4e2776,_0x57c1f2){var _0x1ebc68={};var _0x6e3587={};var _0x344c28;var _0x54df72;return db[_0xa967('0x3d')][_0xa967('0x48')]({'where':{'id':_0x20c239[_0xa967('0x40')]['id']}})[_0xa967('0x1e')](handleEntityNotFound(_0x4e2776,null))[_0xa967('0x1e')](function(_0x1435ab){if(_0x1435ab){_0x344c28=_0x1435ab;_0x6e3587[_0xa967('0x27')]=_['keys'](db[_0xa967('0x4a')][_0xa967('0x25')]);_0x6e3587[_0xa967('0x29')]=_['keys'](_0x20c239[_0xa967('0x29')]);_0x6e3587[_0xa967('0x34')]=_['intersection'](_0x6e3587[_0xa967('0x27')],_0x6e3587[_0xa967('0x29')]);_0x1ebc68['attributes']=_[_0xa967('0x2b')](_0x6e3587[_0xa967('0x27')],qs['fields'](_0x20c239[_0xa967('0x29')]['fields']));_0x1ebc68[_0xa967('0x2d')]=_0x1ebc68['attributes'][_0xa967('0x2e')]?_0x1ebc68[_0xa967('0x2d')]:_0x6e3587[_0xa967('0x27')];_0x1ebc68['order']=qs['sort'](_0x20c239[_0xa967('0x29')][_0xa967('0x32')]);_0x1ebc68['where']=qs['filters'](_[_0xa967('0x35')](_0x20c239[_0xa967('0x29')],_0x6e3587[_0xa967('0x34')]));if(_0x20c239[_0xa967('0x29')][_0xa967('0x36')]){_0x1ebc68[_0xa967('0x33')]=_[_0xa967('0x37')](_0x1ebc68['where'],{'$or':_['map'](_0x1ebc68[_0xa967('0x2d')],function(_0x20e36b){var _0x3a00a9={};_0x3a00a9[_0x20e36b]={'$like':'%'+_0x20c239['query'][_0xa967('0x36')]+'%'};return _0x3a00a9;})});}_0x1ebc68=_[_0xa967('0x37')]({},_0x1ebc68,_0x20c239[_0xa967('0x3a')]);return _0x344c28[_0xa967('0x4c')](_0x1ebc68);}})['then'](function(_0x10a07d){if(_0x10a07d){_0x54df72=_0x10a07d[_0xa967('0x2e')];if(!_0x20c239['query'][_0xa967('0x2f')](_0xa967('0x30'))){_0x1ebc68[_0xa967('0x19')]=qs['limit'](_0x20c239[_0xa967('0x29')][_0xa967('0x19')]);_0x1ebc68['offset']=qs[_0xa967('0x16')](_0x20c239[_0xa967('0x29')]['offset']);}return _0x344c28[_0xa967('0x4c')](_0x1ebc68);}})[_0xa967('0x1e')](function(_0x442bb2){if(_0x442bb2){return _0x442bb2?{'count':_0x54df72,'rows':_0x442bb2}:null;}})[_0xa967('0x1e')](respondWithResult(_0x4e2776,null))['catch'](handleError(_0x4e2776,null));};
\ No newline at end of file
+var _0x1f71=['sox','fs-extra','lodash','squel','jsforce','querystring','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','sendStatus','status','end','json','offset','undefined','limit','count','set','Content-Range','apply','reject','save','update','then','error','stack','name','send','index','map','Automation','type','key','query','filters','intersection','model','fields','attributes','length','hasOwnProperty','nolimit','order','sort','where','filter','merge','options','includeAll','include','findAll','rows','catch','params','keys','create','body','find','destroy','addConditions','ids','getConditions','findOne','Condition','rawAttributes','pick','addActions','omit','getActions','Action','eml-format','zip-dir','fast-json-patch','bluebird'];(function(_0x3ab9ee,_0x4a74b8){var _0x82ee88=function(_0x6ccc7e){while(--_0x6ccc7e){_0x3ab9ee['push'](_0x3ab9ee['shift']());}};_0x82ee88(++_0x4a74b8);}(_0x1f71,0x13c));var _0x11f7=function(_0x5b6f56,_0x3d743a){_0x5b6f56=_0x5b6f56-0x0;var _0x681169=_0x1f71[_0x5b6f56];return _0x681169;};'use strict';var emlformat=require(_0x11f7('0x0'));var rimraf=require('rimraf');var zipdir=require(_0x11f7('0x1'));var jsonpatch=require(_0x11f7('0x2'));var rp=require('request-promise');var moment=require('moment');var BPromise=require(_0x11f7('0x3'));var Mustache=require('mustache');var util=require('util');var path=require('path');var sox=require(_0x11f7('0x4'));var csv=require('to-csv');var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0x11f7('0x5'));var _=require(_0x11f7('0x6'));var squel=require(_0x11f7('0x7'));var crypto=require('crypto');var jsforce=require(_0x11f7('0x8'));var deskjs=require('desk.js');var toCsv=require('to-csv');var querystring=require(_0x11f7('0x9'));var Papa=require('papaparse');var Redis=require('ioredis');var authService=require('../../components/auth/service');var qs=require(_0x11f7('0xa'));var as=require(_0x11f7('0xb'));var hardwareService=require(_0x11f7('0xc'));var logger=require(_0x11f7('0xd'))(_0x11f7('0xe'));var utils=require(_0x11f7('0xf'));var config=require(_0x11f7('0x10'));var licenseUtil=require(_0x11f7('0x11'));var db=require(_0x11f7('0x12'))['db'];function respondWithStatusCode(_0x6262b6,_0x93c5d6){_0x93c5d6=_0x93c5d6||0xcc;return function(_0x230ff1){if(_0x230ff1){return _0x6262b6[_0x11f7('0x13')](_0x93c5d6);}return _0x6262b6[_0x11f7('0x14')](_0x93c5d6)[_0x11f7('0x15')]();};}function respondWithResult(_0x578f5c,_0x5c5932){_0x5c5932=_0x5c5932||0xc8;return function(_0x38faf9){if(_0x38faf9){return _0x578f5c[_0x11f7('0x14')](_0x5c5932)[_0x11f7('0x16')](_0x38faf9);}};}function respondWithFilteredResult(_0x39b0b4,_0x4dd216){return function(_0x425966){if(_0x425966){var _0x197e0f=typeof _0x4dd216[_0x11f7('0x17')]===_0x11f7('0x18')&&typeof _0x4dd216[_0x11f7('0x19')]===_0x11f7('0x18');var _0xd882cd=_0x425966[_0x11f7('0x1a')];var _0x5d902a=_0x197e0f?0x0:_0x4dd216[_0x11f7('0x17')];var _0x4ebff4=_0x197e0f?_0x425966['count']:_0x4dd216['offset']+_0x4dd216[_0x11f7('0x19')];var _0x4de014;if(_0x4ebff4>=_0xd882cd){_0x4ebff4=_0xd882cd;_0x4de014=0xc8;}else{_0x4de014=0xce;}_0x39b0b4[_0x11f7('0x14')](_0x4de014);return _0x39b0b4[_0x11f7('0x1b')](_0x11f7('0x1c'),_0x5d902a+'-'+_0x4ebff4+'/'+_0xd882cd)[_0x11f7('0x16')](_0x425966);}return null;};}function patchUpdates(_0x41f595){return function(_0x3b77fd){try{jsonpatch[_0x11f7('0x1d')](_0x3b77fd,_0x41f595,!![]);}catch(_0x17c4c4){return BPromise[_0x11f7('0x1e')](_0x17c4c4);}return _0x3b77fd[_0x11f7('0x1f')]();};}function saveUpdates(_0x365f55,_0x4fb84f){return function(_0x2a61a){if(_0x2a61a){return _0x2a61a[_0x11f7('0x20')](_0x365f55)[_0x11f7('0x21')](function(_0x51b645){return _0x51b645;});}return null;};}function removeEntity(_0x46a98f,_0x6e40b3){return function(_0x288a5b){if(_0x288a5b){return _0x288a5b['destroy']()['then'](function(){_0x46a98f['status'](0xcc)[_0x11f7('0x15')]();});}};}function handleEntityNotFound(_0x3bbbbe,_0x39f2ba){return function(_0x59489a){if(!_0x59489a){_0x3bbbbe['sendStatus'](0x194);}return _0x59489a;};}function handleError(_0x3161cf,_0x731982){_0x731982=_0x731982||0x1f4;return function(_0x128f66){logger[_0x11f7('0x22')](_0x128f66[_0x11f7('0x23')]);if(_0x128f66[_0x11f7('0x24')]){delete _0x128f66[_0x11f7('0x24')];}_0x3161cf[_0x11f7('0x14')](_0x731982)[_0x11f7('0x25')](_0x128f66);};}exports[_0x11f7('0x26')]=function(_0x237630,_0x38c65a){var _0x21e37e={},_0x5a8488={},_0xc8dfc1={'count':0x0,'rows':[]};var _0x22090b=_[_0x11f7('0x27')](db[_0x11f7('0x28')]['rawAttributes'],function(_0x1f2804){return{'name':_0x1f2804['fieldName'],'type':_0x1f2804[_0x11f7('0x29')][_0x11f7('0x2a')]};});_0x5a8488['model']=_[_0x11f7('0x27')](_0x22090b,_0x11f7('0x24'));_0x5a8488[_0x11f7('0x2b')]=_['keys'](_0x237630[_0x11f7('0x2b')]);_0x5a8488[_0x11f7('0x2c')]=_[_0x11f7('0x2d')](_0x5a8488[_0x11f7('0x2e')],_0x5a8488[_0x11f7('0x2b')]);_0x21e37e['attributes']=_[_0x11f7('0x2d')](_0x5a8488[_0x11f7('0x2e')],qs[_0x11f7('0x2f')](_0x237630[_0x11f7('0x2b')][_0x11f7('0x2f')]));_0x21e37e[_0x11f7('0x30')]=_0x21e37e['attributes'][_0x11f7('0x31')]?_0x21e37e[_0x11f7('0x30')]:_0x5a8488[_0x11f7('0x2e')];if(!_0x237630['query'][_0x11f7('0x32')](_0x11f7('0x33'))){_0x21e37e[_0x11f7('0x19')]=qs[_0x11f7('0x19')](_0x237630[_0x11f7('0x2b')]['limit']);_0x21e37e[_0x11f7('0x17')]=qs['offset'](_0x237630[_0x11f7('0x2b')][_0x11f7('0x17')]);}_0x21e37e[_0x11f7('0x34')]=qs['sort'](_0x237630[_0x11f7('0x2b')][_0x11f7('0x35')]);_0x21e37e[_0x11f7('0x36')]=qs['filters'](_['pick'](_0x237630[_0x11f7('0x2b')],_0x5a8488[_0x11f7('0x2c')]),_0x22090b);if(_0x237630[_0x11f7('0x2b')][_0x11f7('0x37')]){_0x21e37e['where']=_[_0x11f7('0x38')](_0x21e37e[_0x11f7('0x36')],{'$or':_[_0x11f7('0x27')](_0x22090b,function(_0x49e8fa){if(_0x49e8fa['type']!=='VIRTUAL'){var _0x1d131b={};_0x1d131b[_0x49e8fa[_0x11f7('0x24')]]={'$like':'%'+_0x237630[_0x11f7('0x2b')]['filter']+'%'};return _0x1d131b;}})});}_0x21e37e=_[_0x11f7('0x38')]({},_0x21e37e,_0x237630[_0x11f7('0x39')]);var _0x2a8219={'where':_0x21e37e[_0x11f7('0x36')]};return db[_0x11f7('0x28')][_0x11f7('0x1a')](_0x2a8219)[_0x11f7('0x21')](function(_0x4f8517){_0xc8dfc1[_0x11f7('0x1a')]=_0x4f8517;if(_0x237630[_0x11f7('0x2b')][_0x11f7('0x3a')]){_0x21e37e[_0x11f7('0x3b')]=[{'all':!![]}];}return db[_0x11f7('0x28')][_0x11f7('0x3c')](_0x21e37e);})[_0x11f7('0x21')](function(_0x127ea7){_0xc8dfc1[_0x11f7('0x3d')]=_0x127ea7;return _0xc8dfc1;})[_0x11f7('0x21')](respondWithFilteredResult(_0x38c65a,_0x21e37e))[_0x11f7('0x3e')](handleError(_0x38c65a,null));};exports['show']=function(_0x21d9e7,_0x4b5d96){var _0x35f491={'raw':![],'where':{'id':_0x21d9e7[_0x11f7('0x3f')]['id']}},_0x1769e2={};_0x1769e2[_0x11f7('0x2e')]=_[_0x11f7('0x40')](db[_0x11f7('0x28')]['rawAttributes']);_0x1769e2[_0x11f7('0x2b')]=_['keys'](_0x21d9e7[_0x11f7('0x2b')]);_0x1769e2[_0x11f7('0x2c')]=_[_0x11f7('0x2d')](_0x1769e2[_0x11f7('0x2e')],_0x1769e2[_0x11f7('0x2b')]);_0x35f491[_0x11f7('0x30')]=_['intersection'](_0x1769e2[_0x11f7('0x2e')],qs[_0x11f7('0x2f')](_0x21d9e7['query']['fields']));_0x35f491[_0x11f7('0x30')]=_0x35f491[_0x11f7('0x30')]['length']?_0x35f491[_0x11f7('0x30')]:_0x1769e2[_0x11f7('0x2e')];if(_0x21d9e7[_0x11f7('0x2b')][_0x11f7('0x3a')]){_0x35f491[_0x11f7('0x3b')]=[{'all':!![]}];}_0x35f491=_[_0x11f7('0x38')]({},_0x35f491,_0x21d9e7[_0x11f7('0x39')]);return db['Automation']['find'](_0x35f491)['then'](handleEntityNotFound(_0x4b5d96,null))[_0x11f7('0x21')](respondWithResult(_0x4b5d96,null))[_0x11f7('0x3e')](handleError(_0x4b5d96,null));};exports['create']=function(_0x513c53,_0x54b879){return db[_0x11f7('0x28')][_0x11f7('0x41')](_0x513c53[_0x11f7('0x42')],{})['then'](respondWithResult(_0x54b879,0xc9))[_0x11f7('0x3e')](handleError(_0x54b879,null));};exports[_0x11f7('0x20')]=function(_0x55290b,_0x5ed392){if(_0x55290b[_0x11f7('0x42')]['id']){delete _0x55290b[_0x11f7('0x42')]['id'];}return db[_0x11f7('0x28')][_0x11f7('0x43')]({'where':{'id':_0x55290b[_0x11f7('0x3f')]['id']}})[_0x11f7('0x21')](handleEntityNotFound(_0x5ed392,null))[_0x11f7('0x21')](saveUpdates(_0x55290b[_0x11f7('0x42')],null))['then'](respondWithResult(_0x5ed392,null))[_0x11f7('0x3e')](handleError(_0x5ed392,null));};exports[_0x11f7('0x44')]=function(_0x12a358,_0x3281bc){return db[_0x11f7('0x28')]['find']({'where':{'id':_0x12a358['params']['id']}})['then'](handleEntityNotFound(_0x3281bc,null))['then'](removeEntity(_0x3281bc,null))[_0x11f7('0x3e')](handleError(_0x3281bc,null));};exports[_0x11f7('0x45')]=function(_0x2b5335,_0x118554,_0x36b4df){return db['Condition'][_0x11f7('0x43')]({'where':{'id':_0x2b5335[_0x11f7('0x3f')]['id']}})[_0x11f7('0x21')](handleEntityNotFound(_0x118554,null))[_0x11f7('0x21')](function(_0x1d8cf8){if(_0x1d8cf8){return _0x1d8cf8[_0x11f7('0x45')](_0x2b5335['body']['ids'],_['omit'](_0x2b5335['body'],[_0x11f7('0x46'),'id'])||{});}})[_0x11f7('0x21')](respondWithResult(_0x118554,null))[_0x11f7('0x3e')](handleError(_0x118554,null));};exports[_0x11f7('0x47')]=function(_0x515ef5,_0x29ed55,_0x453ec8){var _0x44f9c8={};var _0x351515={};var _0x1a2402;var _0x46b49a;return db[_0x11f7('0x28')][_0x11f7('0x48')]({'where':{'id':_0x515ef5['params']['id']}})['then'](handleEntityNotFound(_0x29ed55,null))[_0x11f7('0x21')](function(_0x1ddb51){if(_0x1ddb51){_0x1a2402=_0x1ddb51;_0x351515['model']=_[_0x11f7('0x40')](db[_0x11f7('0x49')][_0x11f7('0x4a')]);_0x351515[_0x11f7('0x2b')]=_[_0x11f7('0x40')](_0x515ef5[_0x11f7('0x2b')]);_0x351515[_0x11f7('0x2c')]=_[_0x11f7('0x2d')](_0x351515[_0x11f7('0x2e')],_0x351515[_0x11f7('0x2b')]);_0x44f9c8['attributes']=_['intersection'](_0x351515['model'],qs[_0x11f7('0x2f')](_0x515ef5[_0x11f7('0x2b')]['fields']));_0x44f9c8[_0x11f7('0x30')]=_0x44f9c8[_0x11f7('0x30')][_0x11f7('0x31')]?_0x44f9c8['attributes']:_0x351515[_0x11f7('0x2e')];_0x44f9c8['order']=qs['sort'](_0x515ef5[_0x11f7('0x2b')]['sort']);_0x44f9c8[_0x11f7('0x36')]=qs['filters'](_[_0x11f7('0x4b')](_0x515ef5[_0x11f7('0x2b')],_0x351515[_0x11f7('0x2c')]));if(_0x515ef5[_0x11f7('0x2b')][_0x11f7('0x37')]){_0x44f9c8['where']=_[_0x11f7('0x38')](_0x44f9c8['where'],{'$or':_[_0x11f7('0x27')](_0x44f9c8['attributes'],function(_0x50e8fe){var _0x506492={};_0x506492[_0x50e8fe]={'$like':'%'+_0x515ef5[_0x11f7('0x2b')][_0x11f7('0x37')]+'%'};return _0x506492;})});}_0x44f9c8=_[_0x11f7('0x38')]({},_0x44f9c8,_0x515ef5['options']);return _0x1a2402['getConditions'](_0x44f9c8);}})[_0x11f7('0x21')](function(_0x405ccc){if(_0x405ccc){_0x46b49a=_0x405ccc[_0x11f7('0x31')];if(!_0x515ef5[_0x11f7('0x2b')][_0x11f7('0x32')](_0x11f7('0x33'))){_0x44f9c8[_0x11f7('0x19')]=qs[_0x11f7('0x19')](_0x515ef5['query'][_0x11f7('0x19')]);_0x44f9c8['offset']=qs[_0x11f7('0x17')](_0x515ef5['query'][_0x11f7('0x17')]);}return _0x1a2402[_0x11f7('0x47')](_0x44f9c8);}})[_0x11f7('0x21')](function(_0xb72a33){if(_0xb72a33){return _0xb72a33?{'count':_0x46b49a,'rows':_0xb72a33}:null;}})['then'](respondWithResult(_0x29ed55,null))[_0x11f7('0x3e')](handleError(_0x29ed55,null));};exports[_0x11f7('0x4c')]=function(_0x481522,_0x4b2cec,_0x1ada5e){return db['Action'][_0x11f7('0x43')]({'where':{'id':_0x481522['params']['id']}})[_0x11f7('0x21')](handleEntityNotFound(_0x4b2cec,null))[_0x11f7('0x21')](function(_0x178bc2){if(_0x178bc2){return _0x178bc2[_0x11f7('0x4c')](_0x481522['body']['ids'],_[_0x11f7('0x4d')](_0x481522[_0x11f7('0x42')],[_0x11f7('0x46'),'id'])||{});}})['then'](respondWithResult(_0x4b2cec,null))[_0x11f7('0x3e')](handleError(_0x4b2cec,null));};exports[_0x11f7('0x4e')]=function(_0x51a95e,_0x48bf9b,_0x1061e1){var _0xb6c725={};var _0x373b44={};var _0x5e9842;var _0x2e1b56;return db['Automation'][_0x11f7('0x48')]({'where':{'id':_0x51a95e[_0x11f7('0x3f')]['id']}})[_0x11f7('0x21')](handleEntityNotFound(_0x48bf9b,null))[_0x11f7('0x21')](function(_0x28ca54){if(_0x28ca54){_0x5e9842=_0x28ca54;_0x373b44[_0x11f7('0x2e')]=_['keys'](db[_0x11f7('0x4f')][_0x11f7('0x4a')]);_0x373b44['query']=_[_0x11f7('0x40')](_0x51a95e[_0x11f7('0x2b')]);_0x373b44['filters']=_[_0x11f7('0x2d')](_0x373b44[_0x11f7('0x2e')],_0x373b44[_0x11f7('0x2b')]);_0xb6c725[_0x11f7('0x30')]=_[_0x11f7('0x2d')](_0x373b44['model'],qs[_0x11f7('0x2f')](_0x51a95e[_0x11f7('0x2b')]['fields']));_0xb6c725[_0x11f7('0x30')]=_0xb6c725[_0x11f7('0x30')]['length']?_0xb6c725[_0x11f7('0x30')]:_0x373b44[_0x11f7('0x2e')];_0xb6c725[_0x11f7('0x34')]=qs[_0x11f7('0x35')](_0x51a95e[_0x11f7('0x2b')][_0x11f7('0x35')]);_0xb6c725[_0x11f7('0x36')]=qs[_0x11f7('0x2c')](_[_0x11f7('0x4b')](_0x51a95e[_0x11f7('0x2b')],_0x373b44[_0x11f7('0x2c')]));if(_0x51a95e[_0x11f7('0x2b')][_0x11f7('0x37')]){_0xb6c725[_0x11f7('0x36')]=_[_0x11f7('0x38')](_0xb6c725[_0x11f7('0x36')],{'$or':_['map'](_0xb6c725[_0x11f7('0x30')],function(_0x104091){var _0x275922={};_0x275922[_0x104091]={'$like':'%'+_0x51a95e['query'][_0x11f7('0x37')]+'%'};return _0x275922;})});}_0xb6c725=_[_0x11f7('0x38')]({},_0xb6c725,_0x51a95e[_0x11f7('0x39')]);return _0x5e9842[_0x11f7('0x4e')](_0xb6c725);}})[_0x11f7('0x21')](function(_0x59ed5e){if(_0x59ed5e){_0x2e1b56=_0x59ed5e['length'];if(!_0x51a95e[_0x11f7('0x2b')][_0x11f7('0x32')](_0x11f7('0x33'))){_0xb6c725[_0x11f7('0x19')]=qs[_0x11f7('0x19')](_0x51a95e[_0x11f7('0x2b')][_0x11f7('0x19')]);_0xb6c725['offset']=qs[_0x11f7('0x17')](_0x51a95e[_0x11f7('0x2b')][_0x11f7('0x17')]);}return _0x5e9842[_0x11f7('0x4e')](_0xb6c725);}})[_0x11f7('0x21')](function(_0x51dd28){if(_0x51dd28){return _0x51dd28?{'count':_0x2e1b56,'rows':_0x51dd28}:null;}})[_0x11f7('0x21')](respondWithResult(_0x48bf9b,null))[_0x11f7('0x3e')](handleError(_0x48bf9b,null));};
\ No newline at end of file