Built motion from commit 85328c08.|2.5.50
[motion2.git] / server / api / automation / automation.controller.js
index 0dcbfcc..0bb0aad 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-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
+var _0x8068=['Condition','pick','getConditions','hasOwnProperty','addActions','Action','getActions','findOne','order','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','util','sox','to-csv','ejs','fs-extra','lodash','jsforce','desk.js','papaparse','ioredis','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','end','status','json','offset','undefined','limit','Content-Range','apply','reject','save','update','then','sendStatus','stack','name','send','index','map','Automation','fieldName','type','key','model','query','keys','filters','intersection','attributes','fields','length','nolimit','sort','where','filter','VIRTUAL','options','count','include','findAll','rows','catch','params','rawAttributes','includeAll','merge','create','body','destroy','find','addConditions','ids','omit'];(function(_0x54fb7a,_0x24dc21){var _0x981a80=function(_0x40324f){while(--_0x40324f){_0x54fb7a['push'](_0x54fb7a['shift']());}};_0x981a80(++_0x24dc21);}(_0x8068,0x15d));var _0x8806=function(_0x333fc8,_0x2b292c){_0x333fc8=_0x333fc8-0x0;var _0x432439=_0x8068[_0x333fc8];return _0x432439;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0x8806('0x0'));var zipdir=require(_0x8806('0x1'));var jsonpatch=require(_0x8806('0x2'));var rp=require(_0x8806('0x3'));var moment=require(_0x8806('0x4'));var BPromise=require(_0x8806('0x5'));var Mustache=require('mustache');var util=require(_0x8806('0x6'));var path=require('path');var sox=require(_0x8806('0x7'));var csv=require(_0x8806('0x8'));var ejs=require(_0x8806('0x9'));var fs=require('fs');var fs_extra=require(_0x8806('0xa'));var _=require(_0x8806('0xb'));var squel=require('squel');var crypto=require('crypto');var jsforce=require(_0x8806('0xc'));var deskjs=require(_0x8806('0xd'));var toCsv=require('to-csv');var querystring=require('querystring');var Papa=require(_0x8806('0xe'));var Redis=require(_0x8806('0xf'));var authService=require('../../components/auth/service');var qs=require(_0x8806('0x10'));var as=require(_0x8806('0x11'));var hardwareService=require('../../config/license/hardware');var logger=require(_0x8806('0x12'))(_0x8806('0x13'));var utils=require(_0x8806('0x14'));var config=require(_0x8806('0x15'));var licenseUtil=require(_0x8806('0x16'));var db=require(_0x8806('0x17'))['db'];function respondWithStatusCode(_0x4858f0,_0x40453e){_0x40453e=_0x40453e||0xcc;return function(_0x1c9718){if(_0x1c9718){return _0x4858f0['sendStatus'](_0x40453e);}return _0x4858f0['status'](_0x40453e)[_0x8806('0x18')]();};}function respondWithResult(_0x1e56f2,_0x467360){_0x467360=_0x467360||0xc8;return function(_0x4171d1){if(_0x4171d1){return _0x1e56f2[_0x8806('0x19')](_0x467360)[_0x8806('0x1a')](_0x4171d1);}};}function respondWithFilteredResult(_0x1dbcc6,_0x53601e){return function(_0x139b81){if(_0x139b81){var _0x4ff617=typeof _0x53601e[_0x8806('0x1b')]===_0x8806('0x1c')&&typeof _0x53601e[_0x8806('0x1d')]===_0x8806('0x1c');var _0x47c869=_0x139b81['count'];var _0x5355ea=_0x4ff617?0x0:_0x53601e[_0x8806('0x1b')];var _0x50e741=_0x4ff617?_0x139b81['count']:_0x53601e[_0x8806('0x1b')]+_0x53601e['limit'];var _0x4f337d;if(_0x50e741>=_0x47c869){_0x50e741=_0x47c869;_0x4f337d=0xc8;}else{_0x4f337d=0xce;}_0x1dbcc6[_0x8806('0x19')](_0x4f337d);return _0x1dbcc6['set'](_0x8806('0x1e'),_0x5355ea+'-'+_0x50e741+'/'+_0x47c869)[_0x8806('0x1a')](_0x139b81);}return null;};}function patchUpdates(_0x4baca6){return function(_0x4db274){try{jsonpatch[_0x8806('0x1f')](_0x4db274,_0x4baca6,!![]);}catch(_0x3afeea){return BPromise[_0x8806('0x20')](_0x3afeea);}return _0x4db274[_0x8806('0x21')]();};}function saveUpdates(_0x3087c2,_0x734e44){return function(_0x19c3bd){if(_0x19c3bd){return _0x19c3bd[_0x8806('0x22')](_0x3087c2)[_0x8806('0x23')](function(_0x292534){return _0x292534;});}return null;};}function removeEntity(_0xe736dd,_0x38031b){return function(_0x5e7c72){if(_0x5e7c72){return _0x5e7c72['destroy']()[_0x8806('0x23')](function(){_0xe736dd[_0x8806('0x19')](0xcc)[_0x8806('0x18')]();});}};}function handleEntityNotFound(_0x13f220,_0x58709c){return function(_0x24abfa){if(!_0x24abfa){_0x13f220[_0x8806('0x24')](0x194);}return _0x24abfa;};}function handleError(_0x134eb6,_0x2dddfb){_0x2dddfb=_0x2dddfb||0x1f4;return function(_0x4b459c){logger['error'](_0x4b459c[_0x8806('0x25')]);if(_0x4b459c['name']){delete _0x4b459c[_0x8806('0x26')];}_0x134eb6[_0x8806('0x19')](_0x2dddfb)[_0x8806('0x27')](_0x4b459c);};}exports[_0x8806('0x28')]=function(_0x570f3b,_0x177268){var _0x4786c8={},_0x4e06b6={},_0x115cf4={'count':0x0,'rows':[]};var _0x8210c=_[_0x8806('0x29')](db[_0x8806('0x2a')]['rawAttributes'],function(_0x126f00){return{'name':_0x126f00[_0x8806('0x2b')],'type':_0x126f00[_0x8806('0x2c')][_0x8806('0x2d')]};});_0x4e06b6[_0x8806('0x2e')]=_[_0x8806('0x29')](_0x8210c,_0x8806('0x26'));_0x4e06b6[_0x8806('0x2f')]=_[_0x8806('0x30')](_0x570f3b['query']);_0x4e06b6[_0x8806('0x31')]=_[_0x8806('0x32')](_0x4e06b6[_0x8806('0x2e')],_0x4e06b6['query']);_0x4786c8[_0x8806('0x33')]=_[_0x8806('0x32')](_0x4e06b6[_0x8806('0x2e')],qs[_0x8806('0x34')](_0x570f3b[_0x8806('0x2f')][_0x8806('0x34')]));_0x4786c8[_0x8806('0x33')]=_0x4786c8[_0x8806('0x33')][_0x8806('0x35')]?_0x4786c8[_0x8806('0x33')]:_0x4e06b6[_0x8806('0x2e')];if(!_0x570f3b['query']['hasOwnProperty'](_0x8806('0x36'))){_0x4786c8[_0x8806('0x1d')]=qs['limit'](_0x570f3b[_0x8806('0x2f')]['limit']);_0x4786c8[_0x8806('0x1b')]=qs[_0x8806('0x1b')](_0x570f3b['query']['offset']);}_0x4786c8['order']=qs[_0x8806('0x37')](_0x570f3b['query'][_0x8806('0x37')]);_0x4786c8[_0x8806('0x38')]=qs[_0x8806('0x31')](_['pick'](_0x570f3b[_0x8806('0x2f')],_0x4e06b6['filters']),_0x8210c);if(_0x570f3b['query'][_0x8806('0x39')]){_0x4786c8[_0x8806('0x38')]=_['merge'](_0x4786c8[_0x8806('0x38')],{'$or':_[_0x8806('0x29')](_0x8210c,function(_0x42acf8){if(_0x42acf8[_0x8806('0x2c')]!==_0x8806('0x3a')){var _0x4f0d33={};_0x4f0d33[_0x42acf8[_0x8806('0x26')]]={'$like':'%'+_0x570f3b[_0x8806('0x2f')][_0x8806('0x39')]+'%'};return _0x4f0d33;}})});}_0x4786c8=_['merge']({},_0x4786c8,_0x570f3b[_0x8806('0x3b')]);var _0x5d3ac7={'where':_0x4786c8['where']};return db['Automation'][_0x8806('0x3c')](_0x5d3ac7)[_0x8806('0x23')](function(_0x453419){_0x115cf4[_0x8806('0x3c')]=_0x453419;if(_0x570f3b[_0x8806('0x2f')]['includeAll']){_0x4786c8[_0x8806('0x3d')]=[{'all':!![]}];}return db[_0x8806('0x2a')][_0x8806('0x3e')](_0x4786c8);})[_0x8806('0x23')](function(_0x19f8a0){_0x115cf4[_0x8806('0x3f')]=_0x19f8a0;return _0x115cf4;})['then'](respondWithFilteredResult(_0x177268,_0x4786c8))[_0x8806('0x40')](handleError(_0x177268,null));};exports['show']=function(_0x188a37,_0x95b785){var _0x3eea2f={'raw':![],'where':{'id':_0x188a37[_0x8806('0x41')]['id']}},_0x160f95={};_0x160f95[_0x8806('0x2e')]=_[_0x8806('0x30')](db[_0x8806('0x2a')][_0x8806('0x42')]);_0x160f95[_0x8806('0x2f')]=_[_0x8806('0x30')](_0x188a37[_0x8806('0x2f')]);_0x160f95['filters']=_[_0x8806('0x32')](_0x160f95[_0x8806('0x2e')],_0x160f95['query']);_0x3eea2f['attributes']=_[_0x8806('0x32')](_0x160f95[_0x8806('0x2e')],qs['fields'](_0x188a37['query'][_0x8806('0x34')]));_0x3eea2f[_0x8806('0x33')]=_0x3eea2f[_0x8806('0x33')]['length']?_0x3eea2f[_0x8806('0x33')]:_0x160f95[_0x8806('0x2e')];if(_0x188a37[_0x8806('0x2f')][_0x8806('0x43')]){_0x3eea2f[_0x8806('0x3d')]=[{'all':!![]}];}_0x3eea2f=_[_0x8806('0x44')]({},_0x3eea2f,_0x188a37[_0x8806('0x3b')]);return db[_0x8806('0x2a')]['find'](_0x3eea2f)[_0x8806('0x23')](handleEntityNotFound(_0x95b785,null))[_0x8806('0x23')](respondWithResult(_0x95b785,null))['catch'](handleError(_0x95b785,null));};exports[_0x8806('0x45')]=function(_0x2c27de,_0x3bf095){return db[_0x8806('0x2a')][_0x8806('0x45')](_0x2c27de[_0x8806('0x46')],{})[_0x8806('0x23')](respondWithResult(_0x3bf095,0xc9))[_0x8806('0x40')](handleError(_0x3bf095,null));};exports[_0x8806('0x22')]=function(_0x4237cb,_0x334fac){if(_0x4237cb[_0x8806('0x46')]['id']){delete _0x4237cb[_0x8806('0x46')]['id'];}return db[_0x8806('0x2a')]['find']({'where':{'id':_0x4237cb[_0x8806('0x41')]['id']}})[_0x8806('0x23')](handleEntityNotFound(_0x334fac,null))[_0x8806('0x23')](saveUpdates(_0x4237cb[_0x8806('0x46')],null))[_0x8806('0x23')](respondWithResult(_0x334fac,null))[_0x8806('0x40')](handleError(_0x334fac,null));};exports[_0x8806('0x47')]=function(_0x571090,_0x423f67){return db['Automation'][_0x8806('0x48')]({'where':{'id':_0x571090[_0x8806('0x41')]['id']}})[_0x8806('0x23')](handleEntityNotFound(_0x423f67,null))[_0x8806('0x23')](removeEntity(_0x423f67,null))['catch'](handleError(_0x423f67,null));};exports[_0x8806('0x49')]=function(_0x195074,_0x3ba4f4,_0x48705a){return db['Condition'][_0x8806('0x48')]({'where':{'id':_0x195074[_0x8806('0x41')]['id']}})[_0x8806('0x23')](handleEntityNotFound(_0x3ba4f4,null))['then'](function(_0xe1b1f5){if(_0xe1b1f5){return _0xe1b1f5[_0x8806('0x49')](_0x195074['body'][_0x8806('0x4a')],_[_0x8806('0x4b')](_0x195074['body'],[_0x8806('0x4a'),'id'])||{});}})[_0x8806('0x23')](respondWithResult(_0x3ba4f4,null))[_0x8806('0x40')](handleError(_0x3ba4f4,null));};exports['getConditions']=function(_0x23b8dd,_0xdb21ac,_0x4148bf){var _0xe9eca2={};var _0x24fea2={};var _0x1cbf08;var _0x211220;return db[_0x8806('0x2a')]['findOne']({'where':{'id':_0x23b8dd[_0x8806('0x41')]['id']}})['then'](handleEntityNotFound(_0xdb21ac,null))[_0x8806('0x23')](function(_0x398836){if(_0x398836){_0x1cbf08=_0x398836;_0x24fea2[_0x8806('0x2e')]=_[_0x8806('0x30')](db[_0x8806('0x4c')][_0x8806('0x42')]);_0x24fea2[_0x8806('0x2f')]=_[_0x8806('0x30')](_0x23b8dd[_0x8806('0x2f')]);_0x24fea2[_0x8806('0x31')]=_['intersection'](_0x24fea2[_0x8806('0x2e')],_0x24fea2[_0x8806('0x2f')]);_0xe9eca2[_0x8806('0x33')]=_[_0x8806('0x32')](_0x24fea2[_0x8806('0x2e')],qs[_0x8806('0x34')](_0x23b8dd['query'][_0x8806('0x34')]));_0xe9eca2[_0x8806('0x33')]=_0xe9eca2[_0x8806('0x33')]['length']?_0xe9eca2[_0x8806('0x33')]:_0x24fea2[_0x8806('0x2e')];_0xe9eca2['order']=qs['sort'](_0x23b8dd[_0x8806('0x2f')]['sort']);_0xe9eca2[_0x8806('0x38')]=qs[_0x8806('0x31')](_[_0x8806('0x4d')](_0x23b8dd[_0x8806('0x2f')],_0x24fea2[_0x8806('0x31')]));if(_0x23b8dd[_0x8806('0x2f')]['filter']){_0xe9eca2[_0x8806('0x38')]=_[_0x8806('0x44')](_0xe9eca2[_0x8806('0x38')],{'$or':_[_0x8806('0x29')](_0xe9eca2[_0x8806('0x33')],function(_0x3163e3){var _0x4435f6={};_0x4435f6[_0x3163e3]={'$like':'%'+_0x23b8dd[_0x8806('0x2f')][_0x8806('0x39')]+'%'};return _0x4435f6;})});}_0xe9eca2=_[_0x8806('0x44')]({},_0xe9eca2,_0x23b8dd[_0x8806('0x3b')]);return _0x1cbf08[_0x8806('0x4e')](_0xe9eca2);}})[_0x8806('0x23')](function(_0x157aba){if(_0x157aba){_0x211220=_0x157aba[_0x8806('0x35')];if(!_0x23b8dd[_0x8806('0x2f')][_0x8806('0x4f')](_0x8806('0x36'))){_0xe9eca2['limit']=qs[_0x8806('0x1d')](_0x23b8dd[_0x8806('0x2f')][_0x8806('0x1d')]);_0xe9eca2[_0x8806('0x1b')]=qs[_0x8806('0x1b')](_0x23b8dd[_0x8806('0x2f')][_0x8806('0x1b')]);}return _0x1cbf08[_0x8806('0x4e')](_0xe9eca2);}})[_0x8806('0x23')](function(_0x26254b){if(_0x26254b){return _0x26254b?{'count':_0x211220,'rows':_0x26254b}:null;}})[_0x8806('0x23')](respondWithResult(_0xdb21ac,null))[_0x8806('0x40')](handleError(_0xdb21ac,null));};exports[_0x8806('0x50')]=function(_0x51187a,_0x5e306,_0x1a8fc3){return db[_0x8806('0x51')]['find']({'where':{'id':_0x51187a[_0x8806('0x41')]['id']}})[_0x8806('0x23')](handleEntityNotFound(_0x5e306,null))[_0x8806('0x23')](function(_0x5eba2f){if(_0x5eba2f){return _0x5eba2f['addActions'](_0x51187a[_0x8806('0x46')]['ids'],_[_0x8806('0x4b')](_0x51187a[_0x8806('0x46')],[_0x8806('0x4a'),'id'])||{});}})['then'](respondWithResult(_0x5e306,null))[_0x8806('0x40')](handleError(_0x5e306,null));};exports[_0x8806('0x52')]=function(_0x443d2b,_0x5bf539,_0x430d72){var _0x144c9c={};var _0x505f6e={};var _0x11f13f;var _0x45a199;return db[_0x8806('0x2a')][_0x8806('0x53')]({'where':{'id':_0x443d2b[_0x8806('0x41')]['id']}})[_0x8806('0x23')](handleEntityNotFound(_0x5bf539,null))[_0x8806('0x23')](function(_0x2a78ad){if(_0x2a78ad){_0x11f13f=_0x2a78ad;_0x505f6e['model']=_['keys'](db[_0x8806('0x51')][_0x8806('0x42')]);_0x505f6e[_0x8806('0x2f')]=_[_0x8806('0x30')](_0x443d2b[_0x8806('0x2f')]);_0x505f6e[_0x8806('0x31')]=_[_0x8806('0x32')](_0x505f6e[_0x8806('0x2e')],_0x505f6e[_0x8806('0x2f')]);_0x144c9c[_0x8806('0x33')]=_[_0x8806('0x32')](_0x505f6e[_0x8806('0x2e')],qs[_0x8806('0x34')](_0x443d2b[_0x8806('0x2f')][_0x8806('0x34')]));_0x144c9c[_0x8806('0x33')]=_0x144c9c['attributes'][_0x8806('0x35')]?_0x144c9c['attributes']:_0x505f6e['model'];_0x144c9c[_0x8806('0x54')]=qs[_0x8806('0x37')](_0x443d2b['query'][_0x8806('0x37')]);_0x144c9c[_0x8806('0x38')]=qs['filters'](_['pick'](_0x443d2b['query'],_0x505f6e[_0x8806('0x31')]));if(_0x443d2b[_0x8806('0x2f')]['filter']){_0x144c9c[_0x8806('0x38')]=_['merge'](_0x144c9c['where'],{'$or':_[_0x8806('0x29')](_0x144c9c[_0x8806('0x33')],function(_0x465263){var _0x1963e4={};_0x1963e4[_0x465263]={'$like':'%'+_0x443d2b[_0x8806('0x2f')][_0x8806('0x39')]+'%'};return _0x1963e4;})});}_0x144c9c=_[_0x8806('0x44')]({},_0x144c9c,_0x443d2b[_0x8806('0x3b')]);return _0x11f13f['getActions'](_0x144c9c);}})[_0x8806('0x23')](function(_0x73d5dc){if(_0x73d5dc){_0x45a199=_0x73d5dc[_0x8806('0x35')];if(!_0x443d2b[_0x8806('0x2f')]['hasOwnProperty'](_0x8806('0x36'))){_0x144c9c[_0x8806('0x1d')]=qs[_0x8806('0x1d')](_0x443d2b[_0x8806('0x2f')][_0x8806('0x1d')]);_0x144c9c[_0x8806('0x1b')]=qs[_0x8806('0x1b')](_0x443d2b['query']['offset']);}return _0x11f13f['getActions'](_0x144c9c);}})[_0x8806('0x23')](function(_0x445fa1){if(_0x445fa1){return _0x445fa1?{'count':_0x45a199,'rows':_0x445fa1}:null;}})['then'](respondWithResult(_0x5bf539,null))['catch'](handleError(_0x5bf539,null));};
\ No newline at end of file