Built motion from commit 6362bb75.|2.6.13
[motion2.git] / server / api / trigger / trigger.controller.js
1 // *************************************************************************
2 // *                                                                       *
3 // * xCALLY Motion -  The Omnichannel Contact Center                       *
4 // * Copyright (c) Xenialab s.r.l. All Rights Reserved                     *
5 // *                                                                       *
6 // *************************************************************************
7 // *                                                                       *
8 // * Email: info@xcally.com                                                *
9 // * Website: https://www.xcally.com                                       *
10 // *                                                                       *
11 // *************************************************************************
12 // *                                                                       *
13 // * The SOFTWARE PRODUCT is protected by copyright laws and international *
14 // * copyright treaties, as well as other intellectual property laws and   *
15 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                         *
16 // *                                                                       *
17 // *************************************************************************
18 var _0xf355=['type','key','model','query','keys','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','order','sort','where','filter','merge','VIRTUAL','findAll','rows','catch','show','params','Trigger','includeAll','include','options','find','create','body','user','role','get','UserProfileSection','userProfileId','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','addAllCondition','TriggerAllId','Condition','TriggerAnyId','getAllConditions','findOne','pick','getAnyConditions','addAction','TriggerId','Action','getActions','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','bluebird','mustache','util','sox','to-csv','fs-extra','lodash','squel','crypto','jsforce','desk.js','papaparse','../../components/auth/service','../../components/parsers/qs','../../config/license/hardware','../../config/logger','../../config/environment','../../config/license/util','sendStatus','status','json','offset','undefined','limit','count','set','Content-Range','apply','reject','save','update','then','Triggers','UserProfileResource','end','error','stack','name','send','index','map','rawAttributes','fieldName'];(function(_0x47647f,_0x4951a6){var _0x2f61d8=function(_0x107e94){while(--_0x107e94){_0x47647f['push'](_0x47647f['shift']());}};_0x2f61d8(++_0x4951a6);}(_0xf355,0x1b5));var _0x5f35=function(_0x5c8773,_0x316827){_0x5c8773=_0x5c8773-0x0;var _0x203464=_0xf355[_0x5c8773];return _0x203464;};'use strict';var emlformat=require(_0x5f35('0x0'));var rimraf=require(_0x5f35('0x1'));var zipdir=require(_0x5f35('0x2'));var jsonpatch=require(_0x5f35('0x3'));var rp=require(_0x5f35('0x4'));var moment=require('moment');var BPromise=require(_0x5f35('0x5'));var Mustache=require(_0x5f35('0x6'));var util=require(_0x5f35('0x7'));var path=require('path');var sox=require(_0x5f35('0x8'));var csv=require(_0x5f35('0x9'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0x5f35('0xa'));var _=require(_0x5f35('0xb'));var squel=require(_0x5f35('0xc'));var crypto=require(_0x5f35('0xd'));var jsforce=require(_0x5f35('0xe'));var deskjs=require(_0x5f35('0xf'));var toCsv=require(_0x5f35('0x9'));var querystring=require('querystring');var Papa=require(_0x5f35('0x10'));var Redis=require('ioredis');var authService=require(_0x5f35('0x11'));var qs=require(_0x5f35('0x12'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0x5f35('0x13'));var logger=require(_0x5f35('0x14'))('api');var utils=require('../../config/utils');var config=require(_0x5f35('0x15'));var licenseUtil=require(_0x5f35('0x16'));var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x134c03,_0x5a9a61){_0x5a9a61=_0x5a9a61||0xcc;return function(_0x132707){if(_0x132707){return _0x134c03[_0x5f35('0x17')](_0x5a9a61);}return _0x134c03[_0x5f35('0x18')](_0x5a9a61)['end']();};}function respondWithResult(_0x5efbee,_0x10aa94){_0x10aa94=_0x10aa94||0xc8;return function(_0x595e2d){if(_0x595e2d){return _0x5efbee[_0x5f35('0x18')](_0x10aa94)[_0x5f35('0x19')](_0x595e2d);}};}function respondWithFilteredResult(_0xea0eba,_0x44d40f){return function(_0x5de0cb){if(_0x5de0cb){var _0x1cde46=typeof _0x44d40f[_0x5f35('0x1a')]===_0x5f35('0x1b')&&typeof _0x44d40f[_0x5f35('0x1c')]===_0x5f35('0x1b');var _0x51ab8b=_0x5de0cb[_0x5f35('0x1d')];var _0x559f63=_0x1cde46?0x0:_0x44d40f[_0x5f35('0x1a')];var _0x2ec131=_0x1cde46?_0x5de0cb[_0x5f35('0x1d')]:_0x44d40f[_0x5f35('0x1a')]+_0x44d40f[_0x5f35('0x1c')];var _0x3a9d5a;if(_0x2ec131>=_0x51ab8b){_0x2ec131=_0x51ab8b;_0x3a9d5a=0xc8;}else{_0x3a9d5a=0xce;}_0xea0eba[_0x5f35('0x18')](_0x3a9d5a);return _0xea0eba[_0x5f35('0x1e')](_0x5f35('0x1f'),_0x559f63+'-'+_0x2ec131+'/'+_0x51ab8b)[_0x5f35('0x19')](_0x5de0cb);}return null;};}function patchUpdates(_0x4de488){return function(_0x35ead9){try{jsonpatch[_0x5f35('0x20')](_0x35ead9,_0x4de488,!![]);}catch(_0x460190){return BPromise[_0x5f35('0x21')](_0x460190);}return _0x35ead9[_0x5f35('0x22')]();};}function saveUpdates(_0x6bba50,_0x5716ae){return function(_0x53752e){if(_0x53752e){return _0x53752e[_0x5f35('0x23')](_0x6bba50)[_0x5f35('0x24')](function(_0x4812c1){return _0x4812c1;});}return null;};}function removeEntity(_0x23df4d,_0x282f95){return function(_0x2c8082){if(_0x2c8082){return _0x2c8082['destroy']()['then'](function(){var _0x3700e1=_0x2c8082['get']({'plain':!![]});var _0xca6223=_0x5f35('0x25');return db[_0x5f35('0x26')]['destroy']({'where':{'type':_0xca6223,'resourceId':_0x3700e1['id']}})['then'](function(){return _0x2c8082;});})[_0x5f35('0x24')](function(){_0x23df4d[_0x5f35('0x18')](0xcc)[_0x5f35('0x27')]();});}};}function handleEntityNotFound(_0x2990e9,_0x3e29c3){return function(_0x1f66c3){if(!_0x1f66c3){_0x2990e9[_0x5f35('0x17')](0x194);}return _0x1f66c3;};}function handleError(_0x48c941,_0x4a7e3d){_0x4a7e3d=_0x4a7e3d||0x1f4;return function(_0x4af381){logger[_0x5f35('0x28')](_0x4af381[_0x5f35('0x29')]);if(_0x4af381[_0x5f35('0x2a')]){delete _0x4af381[_0x5f35('0x2a')];}_0x48c941['status'](_0x4a7e3d)[_0x5f35('0x2b')](_0x4af381);};}exports[_0x5f35('0x2c')]=function(_0x1c64d1,_0x5174e2){var _0x56b834={},_0x104631={},_0x4ef6a3={'count':0x0,'rows':[]};var _0x9a94f8=_[_0x5f35('0x2d')](db['Trigger'][_0x5f35('0x2e')],function(_0x7c7248){return{'name':_0x7c7248[_0x5f35('0x2f')],'type':_0x7c7248[_0x5f35('0x30')][_0x5f35('0x31')]};});_0x104631[_0x5f35('0x32')]=_['map'](_0x9a94f8,_0x5f35('0x2a'));_0x104631[_0x5f35('0x33')]=_[_0x5f35('0x34')](_0x1c64d1[_0x5f35('0x33')]);_0x104631[_0x5f35('0x35')]=_[_0x5f35('0x36')](_0x104631[_0x5f35('0x32')],_0x104631[_0x5f35('0x33')]);_0x56b834[_0x5f35('0x37')]=_['intersection'](_0x104631[_0x5f35('0x32')],qs[_0x5f35('0x38')](_0x1c64d1[_0x5f35('0x33')]['fields']));_0x56b834['attributes']=_0x56b834[_0x5f35('0x37')][_0x5f35('0x39')]?_0x56b834[_0x5f35('0x37')]:_0x104631[_0x5f35('0x32')];if(!_0x1c64d1['query'][_0x5f35('0x3a')](_0x5f35('0x3b'))){_0x56b834[_0x5f35('0x1c')]=qs[_0x5f35('0x1c')](_0x1c64d1['query'][_0x5f35('0x1c')]);_0x56b834[_0x5f35('0x1a')]=qs[_0x5f35('0x1a')](_0x1c64d1[_0x5f35('0x33')][_0x5f35('0x1a')]);}_0x56b834[_0x5f35('0x3c')]=qs['sort'](_0x1c64d1[_0x5f35('0x33')][_0x5f35('0x3d')]);_0x56b834[_0x5f35('0x3e')]=qs['filters'](_['pick'](_0x1c64d1[_0x5f35('0x33')],_0x104631['filters']),_0x9a94f8);if(_0x1c64d1['query'][_0x5f35('0x3f')]){_0x56b834[_0x5f35('0x3e')]=_[_0x5f35('0x40')](_0x56b834[_0x5f35('0x3e')],{'$or':_[_0x5f35('0x2d')](_0x9a94f8,function(_0x27ba13){if(_0x27ba13[_0x5f35('0x30')]!==_0x5f35('0x41')){var _0x4a1fce={};_0x4a1fce[_0x27ba13[_0x5f35('0x2a')]]={'$like':'%'+_0x1c64d1[_0x5f35('0x33')]['filter']+'%'};return _0x4a1fce;}})});}_0x56b834=_[_0x5f35('0x40')]({},_0x56b834,_0x1c64d1['options']);var _0xa75b2e={'where':_0x56b834[_0x5f35('0x3e')]};return db['Trigger'][_0x5f35('0x1d')](_0xa75b2e)[_0x5f35('0x24')](function(_0x200ee7){_0x4ef6a3[_0x5f35('0x1d')]=_0x200ee7;if(_0x1c64d1[_0x5f35('0x33')]['includeAll']){_0x56b834['include']=[{'all':!![]}];}return db['Trigger'][_0x5f35('0x42')](_0x56b834);})[_0x5f35('0x24')](function(_0x5b2d5f){_0x4ef6a3[_0x5f35('0x43')]=_0x5b2d5f;return _0x4ef6a3;})['then'](respondWithFilteredResult(_0x5174e2,_0x56b834))[_0x5f35('0x44')](handleError(_0x5174e2,null));};exports[_0x5f35('0x45')]=function(_0x3ddffa,_0x3d62e9){var _0x4f3f52={'raw':![],'where':{'id':_0x3ddffa[_0x5f35('0x46')]['id']}},_0x2e9afd={};_0x2e9afd[_0x5f35('0x32')]=_[_0x5f35('0x34')](db[_0x5f35('0x47')][_0x5f35('0x2e')]);_0x2e9afd[_0x5f35('0x33')]=_['keys'](_0x3ddffa['query']);_0x2e9afd[_0x5f35('0x35')]=_[_0x5f35('0x36')](_0x2e9afd[_0x5f35('0x32')],_0x2e9afd['query']);_0x4f3f52['attributes']=_[_0x5f35('0x36')](_0x2e9afd[_0x5f35('0x32')],qs[_0x5f35('0x38')](_0x3ddffa[_0x5f35('0x33')][_0x5f35('0x38')]));_0x4f3f52[_0x5f35('0x37')]=_0x4f3f52[_0x5f35('0x37')][_0x5f35('0x39')]?_0x4f3f52['attributes']:_0x2e9afd['model'];if(_0x3ddffa['query'][_0x5f35('0x48')]){_0x4f3f52[_0x5f35('0x49')]=[{'all':!![]}];}_0x4f3f52=_['merge']({},_0x4f3f52,_0x3ddffa[_0x5f35('0x4a')]);return db[_0x5f35('0x47')][_0x5f35('0x4b')](_0x4f3f52)[_0x5f35('0x24')](handleEntityNotFound(_0x3d62e9,null))['then'](respondWithResult(_0x3d62e9,null))[_0x5f35('0x44')](handleError(_0x3d62e9,null));};exports[_0x5f35('0x4c')]=function(_0x3a7c9c,_0x36b179){return db[_0x5f35('0x47')][_0x5f35('0x4c')](_0x3a7c9c[_0x5f35('0x4d')],{})[_0x5f35('0x24')](function(_0x5bb015){var _0x54bcd6=_0x3a7c9c[_0x5f35('0x4e')]['get']({'plain':!![]});if(!_0x54bcd6)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x54bcd6[_0x5f35('0x4f')]===_0x5f35('0x4e')){var _0x2dd4b9=_0x5bb015[_0x5f35('0x50')]({'plain':!![]});var _0x5c3a4e=_0x5f35('0x25');return db[_0x5f35('0x51')][_0x5f35('0x4b')]({'where':{'name':_0x5c3a4e,'userProfileId':_0x54bcd6[_0x5f35('0x52')]},'raw':!![]})['then'](function(_0x53049a){if(_0x53049a&&_0x53049a[_0x5f35('0x53')]===0x0){return db['UserProfileResource'][_0x5f35('0x4c')]({'name':_0x2dd4b9[_0x5f35('0x2a')],'resourceId':_0x2dd4b9['id'],'type':_0x53049a['name'],'sectionId':_0x53049a['id']},{})[_0x5f35('0x24')](function(){return _0x5bb015;});}else{return _0x5bb015;}})['catch'](function(_0x16c00f){logger[_0x5f35('0x28')](_0x5f35('0x54'),_0x16c00f);throw _0x16c00f;});}return _0x5bb015;})[_0x5f35('0x24')](respondWithResult(_0x36b179,0xc9))['catch'](handleError(_0x36b179,null));};exports[_0x5f35('0x23')]=function(_0x241fa2,_0x4756c3){if(_0x241fa2[_0x5f35('0x4d')]['id']){delete _0x241fa2[_0x5f35('0x4d')]['id'];}return db[_0x5f35('0x47')][_0x5f35('0x4b')]({'where':{'id':_0x241fa2[_0x5f35('0x46')]['id']}})['then'](handleEntityNotFound(_0x4756c3,null))[_0x5f35('0x24')](saveUpdates(_0x241fa2[_0x5f35('0x4d')],null))[_0x5f35('0x24')](respondWithResult(_0x4756c3,null))['catch'](handleError(_0x4756c3,null));};exports['destroy']=function(_0x36e710,_0x2a18ae){return db[_0x5f35('0x47')][_0x5f35('0x4b')]({'where':{'id':_0x36e710[_0x5f35('0x46')]['id']}})[_0x5f35('0x24')](handleEntityNotFound(_0x2a18ae,null))[_0x5f35('0x24')](removeEntity(_0x2a18ae,null))[_0x5f35('0x44')](handleError(_0x2a18ae,null));};exports[_0x5f35('0x55')]=function(_0xbfb5cc,_0x4f837b,_0x346a46){if(_0xbfb5cc[_0x5f35('0x4d')]['id']){delete _0xbfb5cc[_0x5f35('0x4d')]['id'];}return db[_0x5f35('0x47')]['find']({'where':{'id':_0xbfb5cc['params']['id']}})[_0x5f35('0x24')](handleEntityNotFound(_0x4f837b,null))[_0x5f35('0x24')](function(_0x204ae7){if(_0x204ae7){_0xbfb5cc[_0x5f35('0x4d')][_0x5f35('0x56')]=_0x204ae7['id'];return db[_0x5f35('0x57')][_0x5f35('0x4c')](_0xbfb5cc['body']);}})[_0x5f35('0x24')](respondWithResult(_0x4f837b,null))[_0x5f35('0x44')](handleError(_0x4f837b,null));};exports['addAnyCondition']=function(_0x11e596,_0x978979,_0x309a25){if(_0x11e596[_0x5f35('0x4d')]['id']){delete _0x11e596[_0x5f35('0x4d')]['id'];}return db['Trigger'][_0x5f35('0x4b')]({'where':{'id':_0x11e596['params']['id']}})[_0x5f35('0x24')](handleEntityNotFound(_0x978979,null))[_0x5f35('0x24')](function(_0x4fb3a6){if(_0x4fb3a6){_0x11e596[_0x5f35('0x4d')][_0x5f35('0x58')]=_0x4fb3a6['id'];return db[_0x5f35('0x57')][_0x5f35('0x4c')](_0x11e596[_0x5f35('0x4d')]);}})[_0x5f35('0x24')](respondWithResult(_0x978979,null))['catch'](handleError(_0x978979,null));};exports[_0x5f35('0x59')]=function(_0x1a55ad,_0x2ed533,_0x26abcb){var _0x1ffad7={};var _0x51d351={};var _0x1813df;var _0x5c9aad;return db['Trigger'][_0x5f35('0x5a')]({'where':{'id':_0x1a55ad[_0x5f35('0x46')]['id']}})[_0x5f35('0x24')](handleEntityNotFound(_0x2ed533,null))[_0x5f35('0x24')](function(_0x5b9cf9){if(_0x5b9cf9){_0x1813df=_0x5b9cf9;_0x51d351['model']=_[_0x5f35('0x34')](db[_0x5f35('0x57')]['rawAttributes']);_0x51d351[_0x5f35('0x33')]=_[_0x5f35('0x34')](_0x1a55ad['query']);_0x51d351[_0x5f35('0x35')]=_[_0x5f35('0x36')](_0x51d351[_0x5f35('0x32')],_0x51d351[_0x5f35('0x33')]);_0x1ffad7['attributes']=_['intersection'](_0x51d351[_0x5f35('0x32')],qs['fields'](_0x1a55ad['query'][_0x5f35('0x38')]));_0x1ffad7[_0x5f35('0x37')]=_0x1ffad7['attributes'][_0x5f35('0x39')]?_0x1ffad7[_0x5f35('0x37')]:_0x51d351[_0x5f35('0x32')];_0x1ffad7[_0x5f35('0x3c')]=qs[_0x5f35('0x3d')](_0x1a55ad['query'][_0x5f35('0x3d')]);_0x1ffad7[_0x5f35('0x3e')]=qs[_0x5f35('0x35')](_[_0x5f35('0x5b')](_0x1a55ad[_0x5f35('0x33')],_0x51d351[_0x5f35('0x35')]));if(_0x1a55ad[_0x5f35('0x33')][_0x5f35('0x3f')]){_0x1ffad7[_0x5f35('0x3e')]=_[_0x5f35('0x40')](_0x1ffad7['where'],{'$or':_[_0x5f35('0x2d')](_0x1ffad7[_0x5f35('0x37')],function(_0x27e74b){var _0x3cdda8={};_0x3cdda8[_0x27e74b]={'$like':'%'+_0x1a55ad[_0x5f35('0x33')][_0x5f35('0x3f')]+'%'};return _0x3cdda8;})});}_0x1ffad7=_['merge']({},_0x1ffad7,_0x1a55ad[_0x5f35('0x4a')]);return _0x1813df['getAllConditions'](_0x1ffad7);}})[_0x5f35('0x24')](function(_0x50a495){if(_0x50a495){_0x5c9aad=_0x50a495[_0x5f35('0x39')];if(!_0x1a55ad[_0x5f35('0x33')][_0x5f35('0x3a')](_0x5f35('0x3b'))){_0x1ffad7[_0x5f35('0x1c')]=qs[_0x5f35('0x1c')](_0x1a55ad[_0x5f35('0x33')][_0x5f35('0x1c')]);_0x1ffad7[_0x5f35('0x1a')]=qs['offset'](_0x1a55ad[_0x5f35('0x33')][_0x5f35('0x1a')]);}return _0x1813df['getAllConditions'](_0x1ffad7);}})[_0x5f35('0x24')](function(_0x42d232){if(_0x42d232){return _0x42d232?{'count':_0x5c9aad,'rows':_0x42d232}:null;}})[_0x5f35('0x24')](respondWithResult(_0x2ed533,null))[_0x5f35('0x44')](handleError(_0x2ed533,null));};exports[_0x5f35('0x5c')]=function(_0xed5997,_0x1d8159,_0x4eac1b){var _0xb45004={};var _0x3d3905={};var _0x55abaa;var _0x6c393a;return db['Trigger'][_0x5f35('0x5a')]({'where':{'id':_0xed5997[_0x5f35('0x46')]['id']}})['then'](handleEntityNotFound(_0x1d8159,null))[_0x5f35('0x24')](function(_0x38cdb4){if(_0x38cdb4){_0x55abaa=_0x38cdb4;_0x3d3905[_0x5f35('0x32')]=_['keys'](db[_0x5f35('0x57')]['rawAttributes']);_0x3d3905[_0x5f35('0x33')]=_[_0x5f35('0x34')](_0xed5997[_0x5f35('0x33')]);_0x3d3905[_0x5f35('0x35')]=_['intersection'](_0x3d3905[_0x5f35('0x32')],_0x3d3905['query']);_0xb45004[_0x5f35('0x37')]=_['intersection'](_0x3d3905['model'],qs['fields'](_0xed5997[_0x5f35('0x33')][_0x5f35('0x38')]));_0xb45004[_0x5f35('0x37')]=_0xb45004[_0x5f35('0x37')][_0x5f35('0x39')]?_0xb45004['attributes']:_0x3d3905['model'];_0xb45004[_0x5f35('0x3c')]=qs[_0x5f35('0x3d')](_0xed5997[_0x5f35('0x33')][_0x5f35('0x3d')]);_0xb45004[_0x5f35('0x3e')]=qs[_0x5f35('0x35')](_['pick'](_0xed5997[_0x5f35('0x33')],_0x3d3905[_0x5f35('0x35')]));if(_0xed5997[_0x5f35('0x33')][_0x5f35('0x3f')]){_0xb45004[_0x5f35('0x3e')]=_[_0x5f35('0x40')](_0xb45004[_0x5f35('0x3e')],{'$or':_['map'](_0xb45004['attributes'],function(_0x4493b9){var _0x4c9a6e={};_0x4c9a6e[_0x4493b9]={'$like':'%'+_0xed5997[_0x5f35('0x33')][_0x5f35('0x3f')]+'%'};return _0x4c9a6e;})});}_0xb45004=_[_0x5f35('0x40')]({},_0xb45004,_0xed5997[_0x5f35('0x4a')]);return _0x55abaa['getAnyConditions'](_0xb45004);}})['then'](function(_0x551a3b){if(_0x551a3b){_0x6c393a=_0x551a3b[_0x5f35('0x39')];if(!_0xed5997['query']['hasOwnProperty'](_0x5f35('0x3b'))){_0xb45004['limit']=qs[_0x5f35('0x1c')](_0xed5997['query'][_0x5f35('0x1c')]);_0xb45004['offset']=qs[_0x5f35('0x1a')](_0xed5997[_0x5f35('0x33')][_0x5f35('0x1a')]);}return _0x55abaa[_0x5f35('0x5c')](_0xb45004);}})[_0x5f35('0x24')](function(_0x51cae7){if(_0x51cae7){return _0x51cae7?{'count':_0x6c393a,'rows':_0x51cae7}:null;}})[_0x5f35('0x24')](respondWithResult(_0x1d8159,null))['catch'](handleError(_0x1d8159,null));};exports[_0x5f35('0x5d')]=function(_0xa83db8,_0x1827db,_0x228853){if(_0xa83db8[_0x5f35('0x4d')]['id']){delete _0xa83db8[_0x5f35('0x4d')]['id'];}return db[_0x5f35('0x47')][_0x5f35('0x4b')]({'where':{'id':_0xa83db8['params']['id']}})[_0x5f35('0x24')](handleEntityNotFound(_0x1827db,null))[_0x5f35('0x24')](function(_0xd6c266){if(_0xd6c266){_0xa83db8[_0x5f35('0x4d')][_0x5f35('0x5e')]=_0xd6c266['id'];return db[_0x5f35('0x5f')][_0x5f35('0x4c')](_0xa83db8[_0x5f35('0x4d')]);}})['then'](respondWithResult(_0x1827db,null))['catch'](handleError(_0x1827db,null));};exports[_0x5f35('0x60')]=function(_0x82ca20,_0xef16b6,_0x165ed7){var _0x45e300={};var _0x506bb0={};var _0x2e136e;var _0x3b644f;return db[_0x5f35('0x47')][_0x5f35('0x5a')]({'where':{'id':_0x82ca20[_0x5f35('0x46')]['id']}})['then'](handleEntityNotFound(_0xef16b6,null))[_0x5f35('0x24')](function(_0x49f902){if(_0x49f902){_0x2e136e=_0x49f902;_0x506bb0['model']=_[_0x5f35('0x34')](db[_0x5f35('0x5f')][_0x5f35('0x2e')]);_0x506bb0[_0x5f35('0x33')]=_['keys'](_0x82ca20['query']);_0x506bb0['filters']=_[_0x5f35('0x36')](_0x506bb0[_0x5f35('0x32')],_0x506bb0['query']);_0x45e300[_0x5f35('0x37')]=_[_0x5f35('0x36')](_0x506bb0[_0x5f35('0x32')],qs[_0x5f35('0x38')](_0x82ca20[_0x5f35('0x33')][_0x5f35('0x38')]));_0x45e300[_0x5f35('0x37')]=_0x45e300[_0x5f35('0x37')][_0x5f35('0x39')]?_0x45e300[_0x5f35('0x37')]:_0x506bb0['model'];_0x45e300['order']=qs[_0x5f35('0x3d')](_0x82ca20[_0x5f35('0x33')][_0x5f35('0x3d')]);_0x45e300[_0x5f35('0x3e')]=qs['filters'](_[_0x5f35('0x5b')](_0x82ca20[_0x5f35('0x33')],_0x506bb0['filters']));if(_0x82ca20[_0x5f35('0x33')][_0x5f35('0x3f')]){_0x45e300['where']=_['merge'](_0x45e300[_0x5f35('0x3e')],{'$or':_['map'](_0x45e300[_0x5f35('0x37')],function(_0x51a3b6){var _0x1de3a4={};_0x1de3a4[_0x51a3b6]={'$like':'%'+_0x82ca20[_0x5f35('0x33')][_0x5f35('0x3f')]+'%'};return _0x1de3a4;})});}_0x45e300=_[_0x5f35('0x40')]({},_0x45e300,_0x82ca20[_0x5f35('0x4a')]);return _0x2e136e[_0x5f35('0x60')](_0x45e300);}})[_0x5f35('0x24')](function(_0xb3c38d){if(_0xb3c38d){_0x3b644f=_0xb3c38d[_0x5f35('0x39')];if(!_0x82ca20[_0x5f35('0x33')]['hasOwnProperty'](_0x5f35('0x3b'))){_0x45e300['limit']=qs[_0x5f35('0x1c')](_0x82ca20[_0x5f35('0x33')][_0x5f35('0x1c')]);_0x45e300['offset']=qs[_0x5f35('0x1a')](_0x82ca20[_0x5f35('0x33')][_0x5f35('0x1a')]);}return _0x2e136e['getActions'](_0x45e300);}})[_0x5f35('0x24')](function(_0x46ef3b){if(_0x46ef3b){return _0x46ef3b?{'count':_0x3b644f,'rows':_0x46ef3b}:null;}})[_0x5f35('0x24')](respondWithResult(_0xef16b6,null))[_0x5f35('0x44')](handleError(_0xef16b6,null));};