Built motion from commit ddca4d0d.|2.5.47
[motion2.git] / server / api / automation / automation.controller.js
index ef98f8b..4c21e45 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x88dd=['options','includeAll','include','findAll','catch','show','params','keys','find','create','body','destroy','addConditions','ids','omit','getConditions','findOne','addActions','getActions','Action','eml-format','rimraf','fast-json-patch','request-promise','bluebird','mustache','path','sox','to-csv','ejs','fs-extra','lodash','crypto','jsforce','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','sendStatus','status','count','offset','set','Content-Range','json','apply','reject','save','update','then','error','name','send','index','map','Automation','rawAttributes','type','model','query','filters','intersection','fields','attributes','length','hasOwnProperty','nolimit','limit','order','sort','where','pick','filter','merge'];(function(_0x4f13ef,_0xd6e098){var _0x18d6b0=function(_0x5b04e0){while(--_0x5b04e0){_0x4f13ef['push'](_0x4f13ef['shift']());}};_0x18d6b0(++_0xd6e098);}(_0x88dd,0x1ae));var _0xd88d=function(_0x27a824,_0x50dc82){_0x27a824=_0x27a824-0x0;var _0x5a1a7b=_0x88dd[_0x27a824];return _0x5a1a7b;};'use strict';var emlformat=require(_0xd88d('0x0'));var rimraf=require(_0xd88d('0x1'));var zipdir=require('zip-dir');var jsonpatch=require(_0xd88d('0x2'));var rp=require(_0xd88d('0x3'));var moment=require('moment');var BPromise=require(_0xd88d('0x4'));var Mustache=require(_0xd88d('0x5'));var util=require('util');var path=require(_0xd88d('0x6'));var sox=require(_0xd88d('0x7'));var csv=require(_0xd88d('0x8'));var ejs=require(_0xd88d('0x9'));var fs=require('fs');var fs_extra=require(_0xd88d('0xa'));var _=require(_0xd88d('0xb'));var squel=require('squel');var crypto=require(_0xd88d('0xc'));var jsforce=require(_0xd88d('0xd'));var deskjs=require('desk.js');var toCsv=require(_0xd88d('0x8'));var querystring=require('querystring');var Papa=require(_0xd88d('0xe'));var Redis=require(_0xd88d('0xf'));var authService=require(_0xd88d('0x10'));var qs=require(_0xd88d('0x11'));var as=require(_0xd88d('0x12'));var hardwareService=require(_0xd88d('0x13'));var logger=require(_0xd88d('0x14'))(_0xd88d('0x15'));var utils=require(_0xd88d('0x16'));var config=require(_0xd88d('0x17'));var licenseUtil=require(_0xd88d('0x18'));var db=require(_0xd88d('0x19'))['db'];function respondWithStatusCode(_0x587abf,_0x4ac440){_0x4ac440=_0x4ac440||0xcc;return function(_0x466dbb){if(_0x466dbb){return _0x587abf[_0xd88d('0x1a')](_0x4ac440);}return _0x587abf['status'](_0x4ac440)['end']();};}function respondWithResult(_0x310930,_0xf3f040){_0xf3f040=_0xf3f040||0xc8;return function(_0x3beb1b){if(_0x3beb1b){return _0x310930[_0xd88d('0x1b')](_0xf3f040)['json'](_0x3beb1b);}};}function respondWithFilteredResult(_0x36f50f,_0x870ab){return function(_0x119c95){if(_0x119c95){var _0x3e9aaa=_0x119c95[_0xd88d('0x1c')],_0x44cb99=_0x870ab[_0xd88d('0x1d')],_0x1390e0=_0x870ab[_0xd88d('0x1d')]+_0x870ab['limit'],_0x31af1a;if(_0x1390e0>=_0x3e9aaa){_0x1390e0=_0x3e9aaa;_0x31af1a=0xc8;}else{_0x31af1a=0xce;}_0x36f50f[_0xd88d('0x1b')](_0x31af1a);return _0x36f50f[_0xd88d('0x1e')](_0xd88d('0x1f'),_0x44cb99+'-'+_0x1390e0+'/'+_0x3e9aaa)[_0xd88d('0x20')](_0x119c95);}return null;};}function patchUpdates(_0x40df10){return function(_0x16013e){try{jsonpatch[_0xd88d('0x21')](_0x16013e,_0x40df10,!![]);}catch(_0x1d06e4){return BPromise[_0xd88d('0x22')](_0x1d06e4);}return _0x16013e[_0xd88d('0x23')]();};}function saveUpdates(_0x38eb11,_0x2d08fe){return function(_0x279ba6){if(_0x279ba6){return _0x279ba6[_0xd88d('0x24')](_0x38eb11)[_0xd88d('0x25')](function(_0x50969e){return _0x50969e;});}return null;};}function removeEntity(_0x4fcc43,_0x60d57d){return function(_0x5ddc5c){if(_0x5ddc5c){return _0x5ddc5c['destroy']()['then'](function(){_0x4fcc43[_0xd88d('0x1b')](0xcc)['end']();});}};}function handleEntityNotFound(_0x59c491,_0x1a8352){return function(_0x2a0387){if(!_0x2a0387){_0x59c491[_0xd88d('0x1a')](0x194);}return _0x2a0387;};}function handleError(_0x2f4932,_0x34e004){_0x34e004=_0x34e004||0x1f4;return function(_0x485aea){logger[_0xd88d('0x26')](_0x485aea['stack']);if(_0x485aea['name']){delete _0x485aea[_0xd88d('0x27')];}_0x2f4932[_0xd88d('0x1b')](_0x34e004)[_0xd88d('0x28')](_0x485aea);};}exports[_0xd88d('0x29')]=function(_0x1a561a,_0x3d20a3){var _0x53fedd={},_0x693fd5={},_0x43caa7={'count':0x0,'rows':[]};var _0x105623=_[_0xd88d('0x2a')](db[_0xd88d('0x2b')][_0xd88d('0x2c')],function(_0x194bce){return{'name':_0x194bce['fieldName'],'type':_0x194bce[_0xd88d('0x2d')]['key']};});_0x693fd5[_0xd88d('0x2e')]=_[_0xd88d('0x2a')](_0x105623,_0xd88d('0x27'));_0x693fd5['query']=_['keys'](_0x1a561a[_0xd88d('0x2f')]);_0x693fd5[_0xd88d('0x30')]=_[_0xd88d('0x31')](_0x693fd5[_0xd88d('0x2e')],_0x693fd5[_0xd88d('0x2f')]);_0x53fedd['attributes']=_[_0xd88d('0x31')](_0x693fd5[_0xd88d('0x2e')],qs['fields'](_0x1a561a['query'][_0xd88d('0x32')]));_0x53fedd['attributes']=_0x53fedd[_0xd88d('0x33')][_0xd88d('0x34')]?_0x53fedd['attributes']:_0x693fd5['model'];if(!_0x1a561a[_0xd88d('0x2f')][_0xd88d('0x35')](_0xd88d('0x36'))){_0x53fedd[_0xd88d('0x37')]=qs[_0xd88d('0x37')](_0x1a561a[_0xd88d('0x2f')]['limit']);_0x53fedd['offset']=qs['offset'](_0x1a561a[_0xd88d('0x2f')]['offset']);}_0x53fedd[_0xd88d('0x38')]=qs[_0xd88d('0x39')](_0x1a561a[_0xd88d('0x2f')][_0xd88d('0x39')]);_0x53fedd[_0xd88d('0x3a')]=qs[_0xd88d('0x30')](_[_0xd88d('0x3b')](_0x1a561a['query'],_0x693fd5[_0xd88d('0x30')]),_0x105623);if(_0x1a561a[_0xd88d('0x2f')][_0xd88d('0x3c')]){_0x53fedd['where']=_[_0xd88d('0x3d')](_0x53fedd[_0xd88d('0x3a')],{'$or':_['map'](_0x105623,function(_0x579641){if(_0x579641[_0xd88d('0x2d')]!=='VIRTUAL'){var _0x519766={};_0x519766[_0x579641[_0xd88d('0x27')]]={'$like':'%'+_0x1a561a[_0xd88d('0x2f')][_0xd88d('0x3c')]+'%'};return _0x519766;}})});}_0x53fedd=_[_0xd88d('0x3d')]({},_0x53fedd,_0x1a561a[_0xd88d('0x3e')]);var _0x3a6d30={'where':_0x53fedd[_0xd88d('0x3a')]};return db[_0xd88d('0x2b')]['count'](_0x3a6d30)[_0xd88d('0x25')](function(_0x33ed55){_0x43caa7[_0xd88d('0x1c')]=_0x33ed55;if(_0x1a561a[_0xd88d('0x2f')][_0xd88d('0x3f')]){_0x53fedd[_0xd88d('0x40')]=[{'all':!![]}];}return db['Automation'][_0xd88d('0x41')](_0x53fedd);})[_0xd88d('0x25')](function(_0x40c914){_0x43caa7['rows']=_0x40c914;return _0x43caa7;})['then'](respondWithFilteredResult(_0x3d20a3,_0x53fedd))[_0xd88d('0x42')](handleError(_0x3d20a3,null));};exports[_0xd88d('0x43')]=function(_0x339c3d,_0x25ac5a){var _0x12b8f3={'raw':![],'where':{'id':_0x339c3d[_0xd88d('0x44')]['id']}},_0x223645={};_0x223645[_0xd88d('0x2e')]=_['keys'](db['Automation']['rawAttributes']);_0x223645[_0xd88d('0x2f')]=_[_0xd88d('0x45')](_0x339c3d[_0xd88d('0x2f')]);_0x223645[_0xd88d('0x30')]=_[_0xd88d('0x31')](_0x223645[_0xd88d('0x2e')],_0x223645[_0xd88d('0x2f')]);_0x12b8f3[_0xd88d('0x33')]=_[_0xd88d('0x31')](_0x223645[_0xd88d('0x2e')],qs['fields'](_0x339c3d[_0xd88d('0x2f')][_0xd88d('0x32')]));_0x12b8f3[_0xd88d('0x33')]=_0x12b8f3[_0xd88d('0x33')][_0xd88d('0x34')]?_0x12b8f3[_0xd88d('0x33')]:_0x223645['model'];if(_0x339c3d['query'][_0xd88d('0x3f')]){_0x12b8f3['include']=[{'all':!![]}];}_0x12b8f3=_[_0xd88d('0x3d')]({},_0x12b8f3,_0x339c3d[_0xd88d('0x3e')]);return db['Automation'][_0xd88d('0x46')](_0x12b8f3)[_0xd88d('0x25')](handleEntityNotFound(_0x25ac5a,null))[_0xd88d('0x25')](respondWithResult(_0x25ac5a,null))[_0xd88d('0x42')](handleError(_0x25ac5a,null));};exports[_0xd88d('0x47')]=function(_0x45f037,_0x122ee6){return db[_0xd88d('0x2b')][_0xd88d('0x47')](_0x45f037[_0xd88d('0x48')],{})[_0xd88d('0x25')](respondWithResult(_0x122ee6,0xc9))[_0xd88d('0x42')](handleError(_0x122ee6,null));};exports[_0xd88d('0x24')]=function(_0x7d585c,_0x26daa1){if(_0x7d585c[_0xd88d('0x48')]['id']){delete _0x7d585c[_0xd88d('0x48')]['id'];}return db[_0xd88d('0x2b')][_0xd88d('0x46')]({'where':{'id':_0x7d585c[_0xd88d('0x44')]['id']}})[_0xd88d('0x25')](handleEntityNotFound(_0x26daa1,null))[_0xd88d('0x25')](saveUpdates(_0x7d585c[_0xd88d('0x48')],null))[_0xd88d('0x25')](respondWithResult(_0x26daa1,null))[_0xd88d('0x42')](handleError(_0x26daa1,null));};exports[_0xd88d('0x49')]=function(_0x3e13b3,_0x1d1915){return db[_0xd88d('0x2b')]['find']({'where':{'id':_0x3e13b3[_0xd88d('0x44')]['id']}})['then'](handleEntityNotFound(_0x1d1915,null))[_0xd88d('0x25')](removeEntity(_0x1d1915,null))[_0xd88d('0x42')](handleError(_0x1d1915,null));};exports[_0xd88d('0x4a')]=function(_0x4e8491,_0x1769fc,_0xa1919){return db['Condition'][_0xd88d('0x46')]({'where':{'id':_0x4e8491[_0xd88d('0x44')]['id']}})['then'](handleEntityNotFound(_0x1769fc,null))[_0xd88d('0x25')](function(_0x17f7cb){if(_0x17f7cb){return _0x17f7cb[_0xd88d('0x4a')](_0x4e8491[_0xd88d('0x48')][_0xd88d('0x4b')],_[_0xd88d('0x4c')](_0x4e8491[_0xd88d('0x48')],['ids','id'])||{});}})['then'](respondWithResult(_0x1769fc,null))[_0xd88d('0x42')](handleError(_0x1769fc,null));};exports[_0xd88d('0x4d')]=function(_0x4213a5,_0x1017f4,_0x9c5967){var _0x38d688={};var _0x28191b={};var _0x179faf;var _0x1434d6;return db[_0xd88d('0x2b')][_0xd88d('0x4e')]({'where':{'id':_0x4213a5['params']['id']}})['then'](handleEntityNotFound(_0x1017f4,null))[_0xd88d('0x25')](function(_0x90dbd1){if(_0x90dbd1){_0x179faf=_0x90dbd1;_0x28191b['model']=_[_0xd88d('0x45')](db['Condition'][_0xd88d('0x2c')]);_0x28191b[_0xd88d('0x2f')]=_[_0xd88d('0x45')](_0x4213a5[_0xd88d('0x2f')]);_0x28191b[_0xd88d('0x30')]=_['intersection'](_0x28191b[_0xd88d('0x2e')],_0x28191b[_0xd88d('0x2f')]);_0x38d688[_0xd88d('0x33')]=_[_0xd88d('0x31')](_0x28191b[_0xd88d('0x2e')],qs[_0xd88d('0x32')](_0x4213a5['query'][_0xd88d('0x32')]));_0x38d688[_0xd88d('0x33')]=_0x38d688[_0xd88d('0x33')][_0xd88d('0x34')]?_0x38d688['attributes']:_0x28191b[_0xd88d('0x2e')];_0x38d688['order']=qs['sort'](_0x4213a5[_0xd88d('0x2f')][_0xd88d('0x39')]);_0x38d688['where']=qs[_0xd88d('0x30')](_[_0xd88d('0x3b')](_0x4213a5[_0xd88d('0x2f')],_0x28191b[_0xd88d('0x30')]));if(_0x4213a5[_0xd88d('0x2f')]['filter']){_0x38d688[_0xd88d('0x3a')]=_[_0xd88d('0x3d')](_0x38d688[_0xd88d('0x3a')],{'$or':_[_0xd88d('0x2a')](_0x38d688['attributes'],function(_0x522aae){var _0x51833d={};_0x51833d[_0x522aae]={'$like':'%'+_0x4213a5[_0xd88d('0x2f')]['filter']+'%'};return _0x51833d;})});}_0x38d688=_['merge']({},_0x38d688,_0x4213a5[_0xd88d('0x3e')]);return _0x179faf['getConditions'](_0x38d688);}})['then'](function(_0x1a7a5c){if(_0x1a7a5c){_0x1434d6=_0x1a7a5c[_0xd88d('0x34')];if(!_0x4213a5[_0xd88d('0x2f')][_0xd88d('0x35')](_0xd88d('0x36'))){_0x38d688[_0xd88d('0x37')]=qs[_0xd88d('0x37')](_0x4213a5[_0xd88d('0x2f')][_0xd88d('0x37')]);_0x38d688['offset']=qs[_0xd88d('0x1d')](_0x4213a5[_0xd88d('0x2f')]['offset']);}return _0x179faf[_0xd88d('0x4d')](_0x38d688);}})['then'](function(_0x5a7af9){if(_0x5a7af9){return _0x5a7af9?{'count':_0x1434d6,'rows':_0x5a7af9}:null;}})['then'](respondWithResult(_0x1017f4,null))['catch'](handleError(_0x1017f4,null));};exports[_0xd88d('0x4f')]=function(_0x47aba7,_0x25fa36,_0x5c0bb2){return db['Action']['find']({'where':{'id':_0x47aba7['params']['id']}})[_0xd88d('0x25')](handleEntityNotFound(_0x25fa36,null))[_0xd88d('0x25')](function(_0x4d3830){if(_0x4d3830){return _0x4d3830['addActions'](_0x47aba7[_0xd88d('0x48')][_0xd88d('0x4b')],_[_0xd88d('0x4c')](_0x47aba7[_0xd88d('0x48')],[_0xd88d('0x4b'),'id'])||{});}})['then'](respondWithResult(_0x25fa36,null))[_0xd88d('0x42')](handleError(_0x25fa36,null));};exports[_0xd88d('0x50')]=function(_0xfe118f,_0x1a5fca,_0x22be12){var _0x35c6fc={};var _0x18eb8b={};var _0x136613;var _0x4cc491;return db['Automation'][_0xd88d('0x4e')]({'where':{'id':_0xfe118f[_0xd88d('0x44')]['id']}})[_0xd88d('0x25')](handleEntityNotFound(_0x1a5fca,null))[_0xd88d('0x25')](function(_0x255a1d){if(_0x255a1d){_0x136613=_0x255a1d;_0x18eb8b[_0xd88d('0x2e')]=_['keys'](db[_0xd88d('0x51')][_0xd88d('0x2c')]);_0x18eb8b[_0xd88d('0x2f')]=_['keys'](_0xfe118f[_0xd88d('0x2f')]);_0x18eb8b[_0xd88d('0x30')]=_[_0xd88d('0x31')](_0x18eb8b['model'],_0x18eb8b['query']);_0x35c6fc['attributes']=_[_0xd88d('0x31')](_0x18eb8b['model'],qs[_0xd88d('0x32')](_0xfe118f[_0xd88d('0x2f')][_0xd88d('0x32')]));_0x35c6fc['attributes']=_0x35c6fc[_0xd88d('0x33')][_0xd88d('0x34')]?_0x35c6fc[_0xd88d('0x33')]:_0x18eb8b[_0xd88d('0x2e')];_0x35c6fc[_0xd88d('0x38')]=qs['sort'](_0xfe118f[_0xd88d('0x2f')][_0xd88d('0x39')]);_0x35c6fc[_0xd88d('0x3a')]=qs[_0xd88d('0x30')](_[_0xd88d('0x3b')](_0xfe118f[_0xd88d('0x2f')],_0x18eb8b['filters']));if(_0xfe118f[_0xd88d('0x2f')][_0xd88d('0x3c')]){_0x35c6fc[_0xd88d('0x3a')]=_['merge'](_0x35c6fc[_0xd88d('0x3a')],{'$or':_[_0xd88d('0x2a')](_0x35c6fc[_0xd88d('0x33')],function(_0xbe21c8){var _0xd96344={};_0xd96344[_0xbe21c8]={'$like':'%'+_0xfe118f[_0xd88d('0x2f')][_0xd88d('0x3c')]+'%'};return _0xd96344;})});}_0x35c6fc=_['merge']({},_0x35c6fc,_0xfe118f['options']);return _0x136613[_0xd88d('0x50')](_0x35c6fc);}})[_0xd88d('0x25')](function(_0x58a550){if(_0x58a550){_0x4cc491=_0x58a550['length'];if(!_0xfe118f[_0xd88d('0x2f')][_0xd88d('0x35')](_0xd88d('0x36'))){_0x35c6fc['limit']=qs['limit'](_0xfe118f[_0xd88d('0x2f')]['limit']);_0x35c6fc[_0xd88d('0x1d')]=qs[_0xd88d('0x1d')](_0xfe118f['query'][_0xd88d('0x1d')]);}return _0x136613['getActions'](_0x35c6fc);}})[_0xd88d('0x25')](function(_0x18f9b4){if(_0x18f9b4){return _0x18f9b4?{'count':_0x4cc491,'rows':_0x18f9b4}:null;}})['then'](respondWithResult(_0x1a5fca,null))[_0xd88d('0x42')](handleError(_0x1a5fca,null));};
\ No newline at end of file
+var _0x63f7=['status','json','undefined','count','offset','limit','set','Content-Range','apply','reject','save','then','error','stack','name','send','index','map','Automation','rawAttributes','fieldName','type','key','model','query','keys','filters','intersection','attributes','hasOwnProperty','nolimit','order','sort','where','pick','filter','merge','VIRTUAL','options','include','findAll','rows','params','fields','length','find','catch','create','body','addConditions','ids','omit','getConditions','findOne','Condition','addActions','getActions','Action','eml-format','rimraf','fast-json-patch','bluebird','mustache','util','path','sox','to-csv','fs-extra','lodash','squel','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/license/util','sendStatus'];(function(_0x47d5d1,_0x57a87e){var _0xc4750a=function(_0x2bb7f5){while(--_0x2bb7f5){_0x47d5d1['push'](_0x47d5d1['shift']());}};_0xc4750a(++_0x57a87e);}(_0x63f7,0xde));var _0x763f=function(_0x5c52ca,_0x5a3e19){_0x5c52ca=_0x5c52ca-0x0;var _0x164c4e=_0x63f7[_0x5c52ca];return _0x164c4e;};'use strict';var emlformat=require(_0x763f('0x0'));var rimraf=require(_0x763f('0x1'));var zipdir=require('zip-dir');var jsonpatch=require(_0x763f('0x2'));var rp=require('request-promise');var moment=require('moment');var BPromise=require(_0x763f('0x3'));var Mustache=require(_0x763f('0x4'));var util=require(_0x763f('0x5'));var path=require(_0x763f('0x6'));var sox=require(_0x763f('0x7'));var csv=require(_0x763f('0x8'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0x763f('0x9'));var _=require(_0x763f('0xa'));var squel=require(_0x763f('0xb'));var crypto=require('crypto');var jsforce=require(_0x763f('0xc'));var deskjs=require(_0x763f('0xd'));var toCsv=require(_0x763f('0x8'));var querystring=require(_0x763f('0xe'));var Papa=require(_0x763f('0xf'));var Redis=require(_0x763f('0x10'));var authService=require(_0x763f('0x11'));var qs=require('../../components/parsers/qs');var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0x763f('0x12'));var logger=require(_0x763f('0x13'))(_0x763f('0x14'));var utils=require(_0x763f('0x15'));var config=require('../../config/environment');var licenseUtil=require(_0x763f('0x16'));var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x3b9f42,_0x276b04){_0x276b04=_0x276b04||0xcc;return function(_0x2500d8){if(_0x2500d8){return _0x3b9f42[_0x763f('0x17')](_0x276b04);}return _0x3b9f42[_0x763f('0x18')](_0x276b04)['end']();};}function respondWithResult(_0x383eb7,_0x5d28a3){_0x5d28a3=_0x5d28a3||0xc8;return function(_0x4fabe1){if(_0x4fabe1){return _0x383eb7['status'](_0x5d28a3)[_0x763f('0x19')](_0x4fabe1);}};}function respondWithFilteredResult(_0x380315,_0x4d49ab){return function(_0x2852c9){if(_0x2852c9){var _0x49be11=typeof _0x4d49ab['offset']===_0x763f('0x1a')&&typeof _0x4d49ab['limit']==='undefined';var _0x23f8d9=_0x2852c9[_0x763f('0x1b')];var _0x45550f=_0x49be11?0x0:_0x4d49ab[_0x763f('0x1c')];var _0x3e5936=_0x49be11?_0x2852c9[_0x763f('0x1b')]:_0x4d49ab[_0x763f('0x1c')]+_0x4d49ab[_0x763f('0x1d')];var _0x276ede;if(_0x3e5936>=_0x23f8d9){_0x3e5936=_0x23f8d9;_0x276ede=0xc8;}else{_0x276ede=0xce;}_0x380315[_0x763f('0x18')](_0x276ede);return _0x380315[_0x763f('0x1e')](_0x763f('0x1f'),_0x45550f+'-'+_0x3e5936+'/'+_0x23f8d9)[_0x763f('0x19')](_0x2852c9);}return null;};}function patchUpdates(_0x129816){return function(_0x3e6eab){try{jsonpatch[_0x763f('0x20')](_0x3e6eab,_0x129816,!![]);}catch(_0x3df1e0){return BPromise[_0x763f('0x21')](_0x3df1e0);}return _0x3e6eab[_0x763f('0x22')]();};}function saveUpdates(_0x5399a4,_0x5550eb){return function(_0x1b5fa8){if(_0x1b5fa8){return _0x1b5fa8['update'](_0x5399a4)[_0x763f('0x23')](function(_0x1ff8b6){return _0x1ff8b6;});}return null;};}function removeEntity(_0x4261d1,_0x1593e5){return function(_0x2becac){if(_0x2becac){return _0x2becac['destroy']()[_0x763f('0x23')](function(){_0x4261d1['status'](0xcc)['end']();});}};}function handleEntityNotFound(_0x51582e,_0x2fbf1e){return function(_0xac5ab){if(!_0xac5ab){_0x51582e[_0x763f('0x17')](0x194);}return _0xac5ab;};}function handleError(_0x1be329,_0x3f9207){_0x3f9207=_0x3f9207||0x1f4;return function(_0x2d81bb){logger[_0x763f('0x24')](_0x2d81bb[_0x763f('0x25')]);if(_0x2d81bb[_0x763f('0x26')]){delete _0x2d81bb[_0x763f('0x26')];}_0x1be329[_0x763f('0x18')](_0x3f9207)[_0x763f('0x27')](_0x2d81bb);};}exports[_0x763f('0x28')]=function(_0xa5d9a6,_0x5ef283){var _0x210928={},_0x3fc4f9={},_0x45fa31={'count':0x0,'rows':[]};var _0xa0a075=_[_0x763f('0x29')](db[_0x763f('0x2a')][_0x763f('0x2b')],function(_0x5dc982){return{'name':_0x5dc982[_0x763f('0x2c')],'type':_0x5dc982[_0x763f('0x2d')][_0x763f('0x2e')]};});_0x3fc4f9[_0x763f('0x2f')]=_['map'](_0xa0a075,'name');_0x3fc4f9[_0x763f('0x30')]=_[_0x763f('0x31')](_0xa5d9a6[_0x763f('0x30')]);_0x3fc4f9[_0x763f('0x32')]=_[_0x763f('0x33')](_0x3fc4f9['model'],_0x3fc4f9['query']);_0x210928['attributes']=_[_0x763f('0x33')](_0x3fc4f9[_0x763f('0x2f')],qs['fields'](_0xa5d9a6[_0x763f('0x30')]['fields']));_0x210928[_0x763f('0x34')]=_0x210928['attributes']['length']?_0x210928[_0x763f('0x34')]:_0x3fc4f9[_0x763f('0x2f')];if(!_0xa5d9a6['query'][_0x763f('0x35')](_0x763f('0x36'))){_0x210928[_0x763f('0x1d')]=qs['limit'](_0xa5d9a6[_0x763f('0x30')][_0x763f('0x1d')]);_0x210928[_0x763f('0x1c')]=qs[_0x763f('0x1c')](_0xa5d9a6['query'][_0x763f('0x1c')]);}_0x210928[_0x763f('0x37')]=qs[_0x763f('0x38')](_0xa5d9a6[_0x763f('0x30')]['sort']);_0x210928[_0x763f('0x39')]=qs[_0x763f('0x32')](_[_0x763f('0x3a')](_0xa5d9a6['query'],_0x3fc4f9[_0x763f('0x32')]),_0xa0a075);if(_0xa5d9a6[_0x763f('0x30')][_0x763f('0x3b')]){_0x210928['where']=_[_0x763f('0x3c')](_0x210928[_0x763f('0x39')],{'$or':_[_0x763f('0x29')](_0xa0a075,function(_0xe2b0ab){if(_0xe2b0ab[_0x763f('0x2d')]!==_0x763f('0x3d')){var _0x478818={};_0x478818[_0xe2b0ab['name']]={'$like':'%'+_0xa5d9a6[_0x763f('0x30')][_0x763f('0x3b')]+'%'};return _0x478818;}})});}_0x210928=_['merge']({},_0x210928,_0xa5d9a6[_0x763f('0x3e')]);var _0x3dda2d={'where':_0x210928['where']};return db[_0x763f('0x2a')][_0x763f('0x1b')](_0x3dda2d)[_0x763f('0x23')](function(_0x418d1c){_0x45fa31[_0x763f('0x1b')]=_0x418d1c;if(_0xa5d9a6[_0x763f('0x30')]['includeAll']){_0x210928[_0x763f('0x3f')]=[{'all':!![]}];}return db[_0x763f('0x2a')][_0x763f('0x40')](_0x210928);})[_0x763f('0x23')](function(_0x314b59){_0x45fa31[_0x763f('0x41')]=_0x314b59;return _0x45fa31;})[_0x763f('0x23')](respondWithFilteredResult(_0x5ef283,_0x210928))['catch'](handleError(_0x5ef283,null));};exports['show']=function(_0x4b6796,_0x78d8ef){var _0x4fb113={'raw':![],'where':{'id':_0x4b6796[_0x763f('0x42')]['id']}},_0x12d1f2={};_0x12d1f2[_0x763f('0x2f')]=_[_0x763f('0x31')](db['Automation'][_0x763f('0x2b')]);_0x12d1f2['query']=_[_0x763f('0x31')](_0x4b6796[_0x763f('0x30')]);_0x12d1f2[_0x763f('0x32')]=_[_0x763f('0x33')](_0x12d1f2[_0x763f('0x2f')],_0x12d1f2['query']);_0x4fb113[_0x763f('0x34')]=_['intersection'](_0x12d1f2['model'],qs[_0x763f('0x43')](_0x4b6796[_0x763f('0x30')]['fields']));_0x4fb113[_0x763f('0x34')]=_0x4fb113[_0x763f('0x34')][_0x763f('0x44')]?_0x4fb113['attributes']:_0x12d1f2[_0x763f('0x2f')];if(_0x4b6796[_0x763f('0x30')]['includeAll']){_0x4fb113[_0x763f('0x3f')]=[{'all':!![]}];}_0x4fb113=_['merge']({},_0x4fb113,_0x4b6796['options']);return db[_0x763f('0x2a')][_0x763f('0x45')](_0x4fb113)[_0x763f('0x23')](handleEntityNotFound(_0x78d8ef,null))[_0x763f('0x23')](respondWithResult(_0x78d8ef,null))[_0x763f('0x46')](handleError(_0x78d8ef,null));};exports[_0x763f('0x47')]=function(_0x4721ee,_0x1a4996){return db['Automation'][_0x763f('0x47')](_0x4721ee[_0x763f('0x48')],{})[_0x763f('0x23')](respondWithResult(_0x1a4996,0xc9))[_0x763f('0x46')](handleError(_0x1a4996,null));};exports['update']=function(_0x444b46,_0x2fa72e){if(_0x444b46[_0x763f('0x48')]['id']){delete _0x444b46[_0x763f('0x48')]['id'];}return db['Automation']['find']({'where':{'id':_0x444b46[_0x763f('0x42')]['id']}})[_0x763f('0x23')](handleEntityNotFound(_0x2fa72e,null))[_0x763f('0x23')](saveUpdates(_0x444b46[_0x763f('0x48')],null))['then'](respondWithResult(_0x2fa72e,null))['catch'](handleError(_0x2fa72e,null));};exports['destroy']=function(_0x19f3a0,_0x2813ee){return db['Automation'][_0x763f('0x45')]({'where':{'id':_0x19f3a0[_0x763f('0x42')]['id']}})['then'](handleEntityNotFound(_0x2813ee,null))[_0x763f('0x23')](removeEntity(_0x2813ee,null))[_0x763f('0x46')](handleError(_0x2813ee,null));};exports['addConditions']=function(_0x55cbbb,_0x3a99a8,_0x31a1c9){return db['Condition'][_0x763f('0x45')]({'where':{'id':_0x55cbbb[_0x763f('0x42')]['id']}})[_0x763f('0x23')](handleEntityNotFound(_0x3a99a8,null))[_0x763f('0x23')](function(_0x1cc844){if(_0x1cc844){return _0x1cc844[_0x763f('0x49')](_0x55cbbb['body'][_0x763f('0x4a')],_[_0x763f('0x4b')](_0x55cbbb[_0x763f('0x48')],[_0x763f('0x4a'),'id'])||{});}})[_0x763f('0x23')](respondWithResult(_0x3a99a8,null))[_0x763f('0x46')](handleError(_0x3a99a8,null));};exports[_0x763f('0x4c')]=function(_0x45e061,_0x55c7fa,_0x5c882c){var _0x1e024d={};var _0x742091={};var _0x551ac0;var _0x5ac2ba;return db[_0x763f('0x2a')][_0x763f('0x4d')]({'where':{'id':_0x45e061[_0x763f('0x42')]['id']}})[_0x763f('0x23')](handleEntityNotFound(_0x55c7fa,null))['then'](function(_0x3214f1){if(_0x3214f1){_0x551ac0=_0x3214f1;_0x742091[_0x763f('0x2f')]=_[_0x763f('0x31')](db[_0x763f('0x4e')][_0x763f('0x2b')]);_0x742091['query']=_[_0x763f('0x31')](_0x45e061[_0x763f('0x30')]);_0x742091[_0x763f('0x32')]=_['intersection'](_0x742091['model'],_0x742091[_0x763f('0x30')]);_0x1e024d[_0x763f('0x34')]=_[_0x763f('0x33')](_0x742091[_0x763f('0x2f')],qs[_0x763f('0x43')](_0x45e061['query'][_0x763f('0x43')]));_0x1e024d[_0x763f('0x34')]=_0x1e024d[_0x763f('0x34')][_0x763f('0x44')]?_0x1e024d['attributes']:_0x742091[_0x763f('0x2f')];_0x1e024d[_0x763f('0x37')]=qs[_0x763f('0x38')](_0x45e061['query']['sort']);_0x1e024d[_0x763f('0x39')]=qs[_0x763f('0x32')](_[_0x763f('0x3a')](_0x45e061[_0x763f('0x30')],_0x742091[_0x763f('0x32')]));if(_0x45e061['query'][_0x763f('0x3b')]){_0x1e024d['where']=_[_0x763f('0x3c')](_0x1e024d['where'],{'$or':_[_0x763f('0x29')](_0x1e024d[_0x763f('0x34')],function(_0x53cb06){var _0x37f155={};_0x37f155[_0x53cb06]={'$like':'%'+_0x45e061[_0x763f('0x30')]['filter']+'%'};return _0x37f155;})});}_0x1e024d=_[_0x763f('0x3c')]({},_0x1e024d,_0x45e061[_0x763f('0x3e')]);return _0x551ac0['getConditions'](_0x1e024d);}})[_0x763f('0x23')](function(_0x23d20d){if(_0x23d20d){_0x5ac2ba=_0x23d20d[_0x763f('0x44')];if(!_0x45e061[_0x763f('0x30')]['hasOwnProperty'](_0x763f('0x36'))){_0x1e024d[_0x763f('0x1d')]=qs[_0x763f('0x1d')](_0x45e061['query'][_0x763f('0x1d')]);_0x1e024d[_0x763f('0x1c')]=qs[_0x763f('0x1c')](_0x45e061['query'][_0x763f('0x1c')]);}return _0x551ac0[_0x763f('0x4c')](_0x1e024d);}})[_0x763f('0x23')](function(_0x569339){if(_0x569339){return _0x569339?{'count':_0x5ac2ba,'rows':_0x569339}:null;}})[_0x763f('0x23')](respondWithResult(_0x55c7fa,null))['catch'](handleError(_0x55c7fa,null));};exports[_0x763f('0x4f')]=function(_0x119b0a,_0x5e13c3,_0x363e2d){return db['Action'][_0x763f('0x45')]({'where':{'id':_0x119b0a[_0x763f('0x42')]['id']}})[_0x763f('0x23')](handleEntityNotFound(_0x5e13c3,null))[_0x763f('0x23')](function(_0x4c6607){if(_0x4c6607){return _0x4c6607[_0x763f('0x4f')](_0x119b0a[_0x763f('0x48')][_0x763f('0x4a')],_[_0x763f('0x4b')](_0x119b0a[_0x763f('0x48')],[_0x763f('0x4a'),'id'])||{});}})['then'](respondWithResult(_0x5e13c3,null))[_0x763f('0x46')](handleError(_0x5e13c3,null));};exports[_0x763f('0x50')]=function(_0x4c9526,_0xc2704f,_0x21ed10){var _0x28e2ea={};var _0x15b94f={};var _0x4504cb;var _0x2eaad1;return db[_0x763f('0x2a')][_0x763f('0x4d')]({'where':{'id':_0x4c9526['params']['id']}})['then'](handleEntityNotFound(_0xc2704f,null))['then'](function(_0x4edbe1){if(_0x4edbe1){_0x4504cb=_0x4edbe1;_0x15b94f[_0x763f('0x2f')]=_[_0x763f('0x31')](db[_0x763f('0x51')][_0x763f('0x2b')]);_0x15b94f[_0x763f('0x30')]=_[_0x763f('0x31')](_0x4c9526[_0x763f('0x30')]);_0x15b94f['filters']=_[_0x763f('0x33')](_0x15b94f[_0x763f('0x2f')],_0x15b94f[_0x763f('0x30')]);_0x28e2ea[_0x763f('0x34')]=_[_0x763f('0x33')](_0x15b94f[_0x763f('0x2f')],qs['fields'](_0x4c9526[_0x763f('0x30')]['fields']));_0x28e2ea['attributes']=_0x28e2ea[_0x763f('0x34')][_0x763f('0x44')]?_0x28e2ea['attributes']:_0x15b94f[_0x763f('0x2f')];_0x28e2ea[_0x763f('0x37')]=qs[_0x763f('0x38')](_0x4c9526['query'][_0x763f('0x38')]);_0x28e2ea[_0x763f('0x39')]=qs[_0x763f('0x32')](_['pick'](_0x4c9526[_0x763f('0x30')],_0x15b94f[_0x763f('0x32')]));if(_0x4c9526[_0x763f('0x30')][_0x763f('0x3b')]){_0x28e2ea[_0x763f('0x39')]=_[_0x763f('0x3c')](_0x28e2ea[_0x763f('0x39')],{'$or':_[_0x763f('0x29')](_0x28e2ea['attributes'],function(_0x41d76c){var _0xb5a7ce={};_0xb5a7ce[_0x41d76c]={'$like':'%'+_0x4c9526[_0x763f('0x30')][_0x763f('0x3b')]+'%'};return _0xb5a7ce;})});}_0x28e2ea=_[_0x763f('0x3c')]({},_0x28e2ea,_0x4c9526[_0x763f('0x3e')]);return _0x4504cb[_0x763f('0x50')](_0x28e2ea);}})[_0x763f('0x23')](function(_0xf175b8){if(_0xf175b8){_0x2eaad1=_0xf175b8[_0x763f('0x44')];if(!_0x4c9526[_0x763f('0x30')][_0x763f('0x35')]('nolimit')){_0x28e2ea[_0x763f('0x1d')]=qs[_0x763f('0x1d')](_0x4c9526[_0x763f('0x30')][_0x763f('0x1d')]);_0x28e2ea[_0x763f('0x1c')]=qs[_0x763f('0x1c')](_0x4c9526[_0x763f('0x30')][_0x763f('0x1c')]);}return _0x4504cb['getActions'](_0x28e2ea);}})[_0x763f('0x23')](function(_0x73b6f6){if(_0x73b6f6){return _0x73b6f6?{'count':_0x2eaad1,'rows':_0x73b6f6}:null;}})[_0x763f('0x23')](respondWithResult(_0xc2704f,null))[_0x763f('0x46')](handleError(_0xc2704f,null));};
\ No newline at end of file