Built motion from commit 8271bb6f.|2.6.28
[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 _0xc90f=['fields','length','hasOwnProperty','nolimit','order','sort','pick','filters','filter','where','merge','type','VIRTUAL','options','includeAll','findAll','catch','params','include','find','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','UserProfileSection','autoAssociation','UserProfileResource','error','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','addAllCondition','TriggerAllId','Condition','addAnyCondition','getAllConditions','findOne','getAnyConditions','addAction','TriggerId','Action','getActions','rimraf','zip-dir','moment','bluebird','mustache','util','sox','ejs','fs-extra','lodash','crypto','jsforce','desk.js','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/environment','../../config/license/util','sendStatus','end','status','json','offset','undefined','limit','count','set','Content-Range','apply','reject','update','then','get','Triggers','destroy','name','send','index','map','Trigger','rawAttributes','fieldName','key','model','query','keys','intersection','attributes'];(function(_0x11b9be,_0x3a8373){var _0x32057d=function(_0x4da603){while(--_0x4da603){_0x11b9be['push'](_0x11b9be['shift']());}};_0x32057d(++_0x3a8373);}(_0xc90f,0x1a1));var _0xfc90=function(_0x580576,_0x2f107d){_0x580576=_0x580576-0x0;var _0x3f55a0=_0xc90f[_0x580576];return _0x3f55a0;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0xfc90('0x0'));var zipdir=require(_0xfc90('0x1'));var jsonpatch=require('fast-json-patch');var rp=require('request-promise');var moment=require(_0xfc90('0x2'));var BPromise=require(_0xfc90('0x3'));var Mustache=require(_0xfc90('0x4'));var util=require(_0xfc90('0x5'));var path=require('path');var sox=require(_0xfc90('0x6'));var csv=require('to-csv');var ejs=require(_0xfc90('0x7'));var fs=require('fs');var fs_extra=require(_0xfc90('0x8'));var _=require(_0xfc90('0x9'));var squel=require('squel');var crypto=require(_0xfc90('0xa'));var jsforce=require(_0xfc90('0xb'));var deskjs=require(_0xfc90('0xc'));var toCsv=require('to-csv');var querystring=require('querystring');var Papa=require(_0xfc90('0xd'));var Redis=require(_0xfc90('0xe'));var authService=require(_0xfc90('0xf'));var qs=require(_0xfc90('0x10'));var as=require(_0xfc90('0x11'));var hardwareService=require(_0xfc90('0x12'));var logger=require(_0xfc90('0x13'))(_0xfc90('0x14'));var utils=require('../../config/utils');var config=require(_0xfc90('0x15'));var licenseUtil=require(_0xfc90('0x16'));var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x16f8ee,_0x42d824){_0x42d824=_0x42d824||0xcc;return function(_0x214e1c){if(_0x214e1c){return _0x16f8ee[_0xfc90('0x17')](_0x42d824);}return _0x16f8ee['status'](_0x42d824)[_0xfc90('0x18')]();};}function respondWithResult(_0x221759,_0x39b22c){_0x39b22c=_0x39b22c||0xc8;return function(_0x4c1f3f){if(_0x4c1f3f){return _0x221759[_0xfc90('0x19')](_0x39b22c)[_0xfc90('0x1a')](_0x4c1f3f);}};}function respondWithFilteredResult(_0x3b28f4,_0x49e2ca){return function(_0x1bf613){if(_0x1bf613){var _0xf77e2e=typeof _0x49e2ca[_0xfc90('0x1b')]===_0xfc90('0x1c')&&typeof _0x49e2ca[_0xfc90('0x1d')]===_0xfc90('0x1c');var _0x49931f=_0x1bf613[_0xfc90('0x1e')];var _0x45e522=_0xf77e2e?0x0:_0x49e2ca[_0xfc90('0x1b')];var _0x4981ff=_0xf77e2e?_0x1bf613[_0xfc90('0x1e')]:_0x49e2ca[_0xfc90('0x1b')]+_0x49e2ca[_0xfc90('0x1d')];var _0x5b2e9c;if(_0x4981ff>=_0x49931f){_0x4981ff=_0x49931f;_0x5b2e9c=0xc8;}else{_0x5b2e9c=0xce;}_0x3b28f4[_0xfc90('0x19')](_0x5b2e9c);return _0x3b28f4[_0xfc90('0x1f')](_0xfc90('0x20'),_0x45e522+'-'+_0x4981ff+'/'+_0x49931f)['json'](_0x1bf613);}return null;};}function patchUpdates(_0x5d2089){return function(_0x57b0ff){try{jsonpatch[_0xfc90('0x21')](_0x57b0ff,_0x5d2089,!![]);}catch(_0x2810fe){return BPromise[_0xfc90('0x22')](_0x2810fe);}return _0x57b0ff['save']();};}function saveUpdates(_0x3e4091,_0x49dff0){return function(_0x328b66){if(_0x328b66){return _0x328b66[_0xfc90('0x23')](_0x3e4091)[_0xfc90('0x24')](function(_0x3cc2c9){return _0x3cc2c9;});}return null;};}function removeEntity(_0x42607e,_0x16a054){return function(_0x36bf30){if(_0x36bf30){return _0x36bf30['destroy']()['then'](function(){var _0x3fcdb2=_0x36bf30[_0xfc90('0x25')]({'plain':!![]});var _0x6dd651=_0xfc90('0x26');return db['UserProfileResource'][_0xfc90('0x27')]({'where':{'type':_0x6dd651,'resourceId':_0x3fcdb2['id']}})[_0xfc90('0x24')](function(){return _0x36bf30;});})[_0xfc90('0x24')](function(){_0x42607e[_0xfc90('0x19')](0xcc)[_0xfc90('0x18')]();});}};}function handleEntityNotFound(_0x32f134,_0x192604){return function(_0x5491fe){if(!_0x5491fe){_0x32f134[_0xfc90('0x17')](0x194);}return _0x5491fe;};}function handleError(_0xeb3b54,_0xdc3c3b){_0xdc3c3b=_0xdc3c3b||0x1f4;return function(_0x6fd14b){logger['error'](_0x6fd14b['stack']);if(_0x6fd14b[_0xfc90('0x28')]){delete _0x6fd14b[_0xfc90('0x28')];}_0xeb3b54[_0xfc90('0x19')](_0xdc3c3b)[_0xfc90('0x29')](_0x6fd14b);};}exports[_0xfc90('0x2a')]=function(_0x4e0c93,_0x3a67a2){var _0x2ea493={},_0x100c8d={},_0x2bbf46={'count':0x0,'rows':[]};var _0x3ce7d4=_[_0xfc90('0x2b')](db[_0xfc90('0x2c')][_0xfc90('0x2d')],function(_0x11a7b9){return{'name':_0x11a7b9[_0xfc90('0x2e')],'type':_0x11a7b9['type'][_0xfc90('0x2f')]};});_0x100c8d[_0xfc90('0x30')]=_['map'](_0x3ce7d4,'name');_0x100c8d[_0xfc90('0x31')]=_[_0xfc90('0x32')](_0x4e0c93[_0xfc90('0x31')]);_0x100c8d['filters']=_[_0xfc90('0x33')](_0x100c8d[_0xfc90('0x30')],_0x100c8d['query']);_0x2ea493[_0xfc90('0x34')]=_[_0xfc90('0x33')](_0x100c8d[_0xfc90('0x30')],qs[_0xfc90('0x35')](_0x4e0c93[_0xfc90('0x31')][_0xfc90('0x35')]));_0x2ea493[_0xfc90('0x34')]=_0x2ea493[_0xfc90('0x34')][_0xfc90('0x36')]?_0x2ea493[_0xfc90('0x34')]:_0x100c8d[_0xfc90('0x30')];if(!_0x4e0c93[_0xfc90('0x31')][_0xfc90('0x37')](_0xfc90('0x38'))){_0x2ea493[_0xfc90('0x1d')]=qs[_0xfc90('0x1d')](_0x4e0c93[_0xfc90('0x31')][_0xfc90('0x1d')]);_0x2ea493[_0xfc90('0x1b')]=qs[_0xfc90('0x1b')](_0x4e0c93['query'][_0xfc90('0x1b')]);}_0x2ea493[_0xfc90('0x39')]=qs['sort'](_0x4e0c93[_0xfc90('0x31')][_0xfc90('0x3a')]);_0x2ea493['where']=qs['filters'](_[_0xfc90('0x3b')](_0x4e0c93['query'],_0x100c8d[_0xfc90('0x3c')]),_0x3ce7d4);if(_0x4e0c93[_0xfc90('0x31')][_0xfc90('0x3d')]){_0x2ea493[_0xfc90('0x3e')]=_[_0xfc90('0x3f')](_0x2ea493[_0xfc90('0x3e')],{'$or':_[_0xfc90('0x2b')](_0x3ce7d4,function(_0x158175){if(_0x158175[_0xfc90('0x40')]!==_0xfc90('0x41')){var _0x522183={};_0x522183[_0x158175[_0xfc90('0x28')]]={'$like':'%'+_0x4e0c93['query'][_0xfc90('0x3d')]+'%'};return _0x522183;}})});}_0x2ea493=_[_0xfc90('0x3f')]({},_0x2ea493,_0x4e0c93[_0xfc90('0x42')]);var _0x468c86={'where':_0x2ea493[_0xfc90('0x3e')]};return db[_0xfc90('0x2c')][_0xfc90('0x1e')](_0x468c86)['then'](function(_0x4b295f){_0x2bbf46[_0xfc90('0x1e')]=_0x4b295f;if(_0x4e0c93[_0xfc90('0x31')][_0xfc90('0x43')]){_0x2ea493['include']=[{'all':!![]}];}return db[_0xfc90('0x2c')][_0xfc90('0x44')](_0x2ea493);})[_0xfc90('0x24')](function(_0x4124c3){_0x2bbf46['rows']=_0x4124c3;return _0x2bbf46;})['then'](respondWithFilteredResult(_0x3a67a2,_0x2ea493))[_0xfc90('0x45')](handleError(_0x3a67a2,null));};exports['show']=function(_0x1ef84a,_0x2fe027){var _0x578e92={'raw':![],'where':{'id':_0x1ef84a[_0xfc90('0x46')]['id']}},_0x5082a0={};_0x5082a0['model']=_['keys'](db[_0xfc90('0x2c')][_0xfc90('0x2d')]);_0x5082a0['query']=_[_0xfc90('0x32')](_0x1ef84a[_0xfc90('0x31')]);_0x5082a0[_0xfc90('0x3c')]=_[_0xfc90('0x33')](_0x5082a0[_0xfc90('0x30')],_0x5082a0[_0xfc90('0x31')]);_0x578e92[_0xfc90('0x34')]=_['intersection'](_0x5082a0[_0xfc90('0x30')],qs[_0xfc90('0x35')](_0x1ef84a['query']['fields']));_0x578e92[_0xfc90('0x34')]=_0x578e92[_0xfc90('0x34')]['length']?_0x578e92[_0xfc90('0x34')]:_0x5082a0['model'];if(_0x1ef84a['query']['includeAll']){_0x578e92[_0xfc90('0x47')]=[{'all':!![]}];}_0x578e92=_[_0xfc90('0x3f')]({},_0x578e92,_0x1ef84a[_0xfc90('0x42')]);return db[_0xfc90('0x2c')][_0xfc90('0x48')](_0x578e92)[_0xfc90('0x24')](handleEntityNotFound(_0x2fe027,null))['then'](respondWithResult(_0x2fe027,null))[_0xfc90('0x45')](handleError(_0x2fe027,null));};exports[_0xfc90('0x49')]=function(_0x3233ff,_0xbddc8a){return db[_0xfc90('0x2c')]['create'](_0x3233ff[_0xfc90('0x4a')],{})[_0xfc90('0x24')](function(_0x1ae4b1){var _0x40a9ef=_0x3233ff[_0xfc90('0x4b')]['get']({'plain':!![]});if(!_0x40a9ef)throw new Error(_0xfc90('0x4c'));if(_0x40a9ef[_0xfc90('0x4d')]===_0xfc90('0x4b')){var _0x1552bc=_0x1ae4b1['get']({'plain':!![]});var _0x433705=_0xfc90('0x26');return db[_0xfc90('0x4e')]['find']({'where':{'name':_0x433705,'userProfileId':_0x40a9ef['userProfileId']},'raw':!![]})[_0xfc90('0x24')](function(_0x2c7ff6){if(_0x2c7ff6&&_0x2c7ff6[_0xfc90('0x4f')]===0x0){return db[_0xfc90('0x50')][_0xfc90('0x49')]({'name':_0x1552bc[_0xfc90('0x28')],'resourceId':_0x1552bc['id'],'type':_0x2c7ff6[_0xfc90('0x28')],'sectionId':_0x2c7ff6['id']},{})['then'](function(){return _0x1ae4b1;});}else{return _0x1ae4b1;}})['catch'](function(_0x42e835){logger[_0xfc90('0x51')](_0xfc90('0x52'),_0x42e835);throw _0x42e835;});}return _0x1ae4b1;})[_0xfc90('0x24')](respondWithResult(_0xbddc8a,0xc9))[_0xfc90('0x45')](handleError(_0xbddc8a,null));};exports['update']=function(_0x110dc2,_0x136aa0){if(_0x110dc2['body']['id']){delete _0x110dc2[_0xfc90('0x4a')]['id'];}return db[_0xfc90('0x2c')][_0xfc90('0x48')]({'where':{'id':_0x110dc2[_0xfc90('0x46')]['id']}})[_0xfc90('0x24')](handleEntityNotFound(_0x136aa0,null))[_0xfc90('0x24')](saveUpdates(_0x110dc2[_0xfc90('0x4a')],null))['then'](respondWithResult(_0x136aa0,null))[_0xfc90('0x45')](handleError(_0x136aa0,null));};exports[_0xfc90('0x27')]=function(_0x2b5202,_0x530297){return db[_0xfc90('0x2c')][_0xfc90('0x48')]({'where':{'id':_0x2b5202[_0xfc90('0x46')]['id']}})[_0xfc90('0x24')](handleEntityNotFound(_0x530297,null))[_0xfc90('0x24')](removeEntity(_0x530297,null))['catch'](handleError(_0x530297,null));};exports[_0xfc90('0x53')]=function(_0x30bb5f,_0x21ebf6,_0x12f269){if(_0x30bb5f['body']['id']){delete _0x30bb5f['body']['id'];}return db[_0xfc90('0x2c')]['find']({'where':{'id':_0x30bb5f['params']['id']}})['then'](handleEntityNotFound(_0x21ebf6,null))['then'](function(_0x39c6ae){if(_0x39c6ae){_0x30bb5f[_0xfc90('0x4a')][_0xfc90('0x54')]=_0x39c6ae['id'];return db[_0xfc90('0x55')]['create'](_0x30bb5f[_0xfc90('0x4a')]);}})[_0xfc90('0x24')](respondWithResult(_0x21ebf6,null))[_0xfc90('0x45')](handleError(_0x21ebf6,null));};exports[_0xfc90('0x56')]=function(_0x1226f3,_0x3bb090,_0x2b0687){if(_0x1226f3[_0xfc90('0x4a')]['id']){delete _0x1226f3[_0xfc90('0x4a')]['id'];}return db[_0xfc90('0x2c')][_0xfc90('0x48')]({'where':{'id':_0x1226f3[_0xfc90('0x46')]['id']}})['then'](handleEntityNotFound(_0x3bb090,null))[_0xfc90('0x24')](function(_0x23498d){if(_0x23498d){_0x1226f3[_0xfc90('0x4a')]['TriggerAnyId']=_0x23498d['id'];return db[_0xfc90('0x55')]['create'](_0x1226f3['body']);}})[_0xfc90('0x24')](respondWithResult(_0x3bb090,null))[_0xfc90('0x45')](handleError(_0x3bb090,null));};exports[_0xfc90('0x57')]=function(_0x12b71e,_0x3411a8,_0x2d49b6){var _0x320329={};var _0x981ea3={};var _0x296b91;var _0x1cdeef;return db['Trigger'][_0xfc90('0x58')]({'where':{'id':_0x12b71e[_0xfc90('0x46')]['id']}})[_0xfc90('0x24')](handleEntityNotFound(_0x3411a8,null))[_0xfc90('0x24')](function(_0x1fb9a4){if(_0x1fb9a4){_0x296b91=_0x1fb9a4;_0x981ea3[_0xfc90('0x30')]=_['keys'](db['Condition'][_0xfc90('0x2d')]);_0x981ea3[_0xfc90('0x31')]=_[_0xfc90('0x32')](_0x12b71e['query']);_0x981ea3[_0xfc90('0x3c')]=_[_0xfc90('0x33')](_0x981ea3['model'],_0x981ea3[_0xfc90('0x31')]);_0x320329['attributes']=_[_0xfc90('0x33')](_0x981ea3['model'],qs[_0xfc90('0x35')](_0x12b71e[_0xfc90('0x31')][_0xfc90('0x35')]));_0x320329[_0xfc90('0x34')]=_0x320329[_0xfc90('0x34')][_0xfc90('0x36')]?_0x320329['attributes']:_0x981ea3['model'];_0x320329[_0xfc90('0x39')]=qs[_0xfc90('0x3a')](_0x12b71e['query']['sort']);_0x320329['where']=qs[_0xfc90('0x3c')](_[_0xfc90('0x3b')](_0x12b71e['query'],_0x981ea3[_0xfc90('0x3c')]));if(_0x12b71e[_0xfc90('0x31')][_0xfc90('0x3d')]){_0x320329[_0xfc90('0x3e')]=_[_0xfc90('0x3f')](_0x320329['where'],{'$or':_[_0xfc90('0x2b')](_0x320329[_0xfc90('0x34')],function(_0x1add71){var _0x3fb5b9={};_0x3fb5b9[_0x1add71]={'$like':'%'+_0x12b71e['query'][_0xfc90('0x3d')]+'%'};return _0x3fb5b9;})});}_0x320329=_[_0xfc90('0x3f')]({},_0x320329,_0x12b71e['options']);return _0x296b91[_0xfc90('0x57')](_0x320329);}})[_0xfc90('0x24')](function(_0x122578){if(_0x122578){_0x1cdeef=_0x122578[_0xfc90('0x36')];if(!_0x12b71e['query'][_0xfc90('0x37')](_0xfc90('0x38'))){_0x320329[_0xfc90('0x1d')]=qs[_0xfc90('0x1d')](_0x12b71e[_0xfc90('0x31')][_0xfc90('0x1d')]);_0x320329[_0xfc90('0x1b')]=qs[_0xfc90('0x1b')](_0x12b71e[_0xfc90('0x31')][_0xfc90('0x1b')]);}return _0x296b91[_0xfc90('0x57')](_0x320329);}})[_0xfc90('0x24')](function(_0x3d61f2){if(_0x3d61f2){return _0x3d61f2?{'count':_0x1cdeef,'rows':_0x3d61f2}:null;}})[_0xfc90('0x24')](respondWithResult(_0x3411a8,null))['catch'](handleError(_0x3411a8,null));};exports[_0xfc90('0x59')]=function(_0x41f24a,_0x55fdb1,_0x12144c){var _0x26daf9={};var _0x3c1628={};var _0x5099bc;var _0x148e82;return db[_0xfc90('0x2c')][_0xfc90('0x58')]({'where':{'id':_0x41f24a[_0xfc90('0x46')]['id']}})[_0xfc90('0x24')](handleEntityNotFound(_0x55fdb1,null))[_0xfc90('0x24')](function(_0x3d9633){if(_0x3d9633){_0x5099bc=_0x3d9633;_0x3c1628[_0xfc90('0x30')]=_[_0xfc90('0x32')](db['Condition'][_0xfc90('0x2d')]);_0x3c1628[_0xfc90('0x31')]=_[_0xfc90('0x32')](_0x41f24a[_0xfc90('0x31')]);_0x3c1628[_0xfc90('0x3c')]=_[_0xfc90('0x33')](_0x3c1628[_0xfc90('0x30')],_0x3c1628[_0xfc90('0x31')]);_0x26daf9[_0xfc90('0x34')]=_[_0xfc90('0x33')](_0x3c1628['model'],qs['fields'](_0x41f24a[_0xfc90('0x31')][_0xfc90('0x35')]));_0x26daf9['attributes']=_0x26daf9[_0xfc90('0x34')][_0xfc90('0x36')]?_0x26daf9[_0xfc90('0x34')]:_0x3c1628[_0xfc90('0x30')];_0x26daf9[_0xfc90('0x39')]=qs[_0xfc90('0x3a')](_0x41f24a['query'][_0xfc90('0x3a')]);_0x26daf9[_0xfc90('0x3e')]=qs[_0xfc90('0x3c')](_[_0xfc90('0x3b')](_0x41f24a[_0xfc90('0x31')],_0x3c1628[_0xfc90('0x3c')]));if(_0x41f24a[_0xfc90('0x31')][_0xfc90('0x3d')]){_0x26daf9[_0xfc90('0x3e')]=_[_0xfc90('0x3f')](_0x26daf9[_0xfc90('0x3e')],{'$or':_[_0xfc90('0x2b')](_0x26daf9[_0xfc90('0x34')],function(_0x4a461c){var _0x52df59={};_0x52df59[_0x4a461c]={'$like':'%'+_0x41f24a['query'][_0xfc90('0x3d')]+'%'};return _0x52df59;})});}_0x26daf9=_[_0xfc90('0x3f')]({},_0x26daf9,_0x41f24a[_0xfc90('0x42')]);return _0x5099bc[_0xfc90('0x59')](_0x26daf9);}})[_0xfc90('0x24')](function(_0x13da49){if(_0x13da49){_0x148e82=_0x13da49[_0xfc90('0x36')];if(!_0x41f24a['query'][_0xfc90('0x37')](_0xfc90('0x38'))){_0x26daf9[_0xfc90('0x1d')]=qs[_0xfc90('0x1d')](_0x41f24a[_0xfc90('0x31')][_0xfc90('0x1d')]);_0x26daf9[_0xfc90('0x1b')]=qs['offset'](_0x41f24a[_0xfc90('0x31')][_0xfc90('0x1b')]);}return _0x5099bc[_0xfc90('0x59')](_0x26daf9);}})[_0xfc90('0x24')](function(_0x1c1fcd){if(_0x1c1fcd){return _0x1c1fcd?{'count':_0x148e82,'rows':_0x1c1fcd}:null;}})['then'](respondWithResult(_0x55fdb1,null))[_0xfc90('0x45')](handleError(_0x55fdb1,null));};exports[_0xfc90('0x5a')]=function(_0x3b2855,_0x24408b,_0x4e3d1f){if(_0x3b2855[_0xfc90('0x4a')]['id']){delete _0x3b2855['body']['id'];}return db[_0xfc90('0x2c')][_0xfc90('0x48')]({'where':{'id':_0x3b2855[_0xfc90('0x46')]['id']}})[_0xfc90('0x24')](handleEntityNotFound(_0x24408b,null))[_0xfc90('0x24')](function(_0x4daa2b){if(_0x4daa2b){_0x3b2855['body'][_0xfc90('0x5b')]=_0x4daa2b['id'];return db[_0xfc90('0x5c')]['create'](_0x3b2855[_0xfc90('0x4a')]);}})[_0xfc90('0x24')](respondWithResult(_0x24408b,null))[_0xfc90('0x45')](handleError(_0x24408b,null));};exports[_0xfc90('0x5d')]=function(_0x18208e,_0x113e55,_0x5a8881){var _0x30955b={};var _0x5ab890={};var _0x300477;var _0x15c6a0;return db[_0xfc90('0x2c')][_0xfc90('0x58')]({'where':{'id':_0x18208e[_0xfc90('0x46')]['id']}})['then'](handleEntityNotFound(_0x113e55,null))[_0xfc90('0x24')](function(_0x3bba2a){if(_0x3bba2a){_0x300477=_0x3bba2a;_0x5ab890[_0xfc90('0x30')]=_[_0xfc90('0x32')](db[_0xfc90('0x5c')][_0xfc90('0x2d')]);_0x5ab890['query']=_['keys'](_0x18208e['query']);_0x5ab890['filters']=_[_0xfc90('0x33')](_0x5ab890[_0xfc90('0x30')],_0x5ab890[_0xfc90('0x31')]);_0x30955b[_0xfc90('0x34')]=_[_0xfc90('0x33')](_0x5ab890[_0xfc90('0x30')],qs['fields'](_0x18208e[_0xfc90('0x31')][_0xfc90('0x35')]));_0x30955b[_0xfc90('0x34')]=_0x30955b[_0xfc90('0x34')]['length']?_0x30955b[_0xfc90('0x34')]:_0x5ab890['model'];_0x30955b[_0xfc90('0x39')]=qs[_0xfc90('0x3a')](_0x18208e['query'][_0xfc90('0x3a')]);_0x30955b[_0xfc90('0x3e')]=qs[_0xfc90('0x3c')](_[_0xfc90('0x3b')](_0x18208e['query'],_0x5ab890[_0xfc90('0x3c')]));if(_0x18208e['query'][_0xfc90('0x3d')]){_0x30955b['where']=_[_0xfc90('0x3f')](_0x30955b['where'],{'$or':_[_0xfc90('0x2b')](_0x30955b['attributes'],function(_0x2c97bf){var _0x3b850c={};_0x3b850c[_0x2c97bf]={'$like':'%'+_0x18208e['query'][_0xfc90('0x3d')]+'%'};return _0x3b850c;})});}_0x30955b=_['merge']({},_0x30955b,_0x18208e[_0xfc90('0x42')]);return _0x300477[_0xfc90('0x5d')](_0x30955b);}})['then'](function(_0x12077a){if(_0x12077a){_0x15c6a0=_0x12077a[_0xfc90('0x36')];if(!_0x18208e['query'][_0xfc90('0x37')]('nolimit')){_0x30955b[_0xfc90('0x1d')]=qs[_0xfc90('0x1d')](_0x18208e[_0xfc90('0x31')]['limit']);_0x30955b['offset']=qs[_0xfc90('0x1b')](_0x18208e[_0xfc90('0x31')][_0xfc90('0x1b')]);}return _0x300477['getActions'](_0x30955b);}})['then'](function(_0x1d8275){if(_0x1d8275){return _0x1d8275?{'count':_0x15c6a0,'rows':_0x1d8275}:null;}})[_0xfc90('0x24')](respondWithResult(_0x113e55,null))[_0xfc90('0x45')](handleError(_0x113e55,null));};