Built motion from commit 2e4747fd.|2.6.7
[motion2.git] / server / api / intDeskConfiguration / intDeskConfiguration.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 _0x32f3=['../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/license/util','../../mysqldb','sendStatus','status','json','limit','undefined','count','offset','set','Content-Range','apply','reject','save','update','then','destroy','end','error','stack','name','send','DeskConfiguration','rawAttributes','type','key','model','map','query','keys','filters','fields','attributes','length','hasOwnProperty','sort','where','pick','filter','merge','VIRTUAL','rows','show','params','intersection','includeAll','include','options','find','create','body','catch','getFields','findOne','order','getSubjects','nolimit','getDescriptions','DeskField','getTags','Tag','setTags','ids','eml-format','zip-dir','request-promise','mustache','path','sox','to-csv','ejs','fs-extra','lodash','squel','jsforce','desk.js','querystring','papaparse','ioredis','../../components/parsers/qs'];(function(_0x435335,_0x570ca0){var _0x245de5=function(_0x3376b1){while(--_0x3376b1){_0x435335['push'](_0x435335['shift']());}};_0x245de5(++_0x570ca0);}(_0x32f3,0x13f));var _0x332f=function(_0x175729,_0x5f533){_0x175729=_0x175729-0x0;var _0x4c209e=_0x32f3[_0x175729];return _0x4c209e;};'use strict';var emlformat=require(_0x332f('0x0'));var rimraf=require('rimraf');var zipdir=require(_0x332f('0x1'));var jsonpatch=require('fast-json-patch');var rp=require(_0x332f('0x2'));var moment=require('moment');var BPromise=require('bluebird');var Mustache=require(_0x332f('0x3'));var util=require('util');var path=require(_0x332f('0x4'));var sox=require(_0x332f('0x5'));var csv=require(_0x332f('0x6'));var ejs=require(_0x332f('0x7'));var fs=require('fs');var fs_extra=require(_0x332f('0x8'));var _=require(_0x332f('0x9'));var squel=require(_0x332f('0xa'));var crypto=require('crypto');var jsforce=require(_0x332f('0xb'));var deskjs=require(_0x332f('0xc'));var toCsv=require(_0x332f('0x6'));var querystring=require(_0x332f('0xd'));var Papa=require(_0x332f('0xe'));var Redis=require(_0x332f('0xf'));var authService=require('../../components/auth/service');var qs=require(_0x332f('0x10'));var as=require(_0x332f('0x11'));var hardwareService=require(_0x332f('0x12'));var logger=require(_0x332f('0x13'))(_0x332f('0x14'));var utils=require('../../config/utils');var config=require('../../config/environment');var licenseUtil=require(_0x332f('0x15'));var db=require(_0x332f('0x16'))['db'];function respondWithStatusCode(_0x1df7cd,_0x225cac){_0x225cac=_0x225cac||0xcc;return function(_0x37a19c){if(_0x37a19c){return _0x1df7cd[_0x332f('0x17')](_0x225cac);}return _0x1df7cd[_0x332f('0x18')](_0x225cac)['end']();};}function respondWithResult(_0x4541ab,_0x6b44db){_0x6b44db=_0x6b44db||0xc8;return function(_0x313d31){if(_0x313d31){return _0x4541ab[_0x332f('0x18')](_0x6b44db)[_0x332f('0x19')](_0x313d31);}};}function respondWithFilteredResult(_0x36eb3d,_0xb740a){return function(_0x48e36a){if(_0x48e36a){var _0x13ec6b=typeof _0xb740a['offset']==='undefined'&&typeof _0xb740a[_0x332f('0x1a')]===_0x332f('0x1b');var _0xbb15b5=_0x48e36a[_0x332f('0x1c')];var _0x1a7de1=_0x13ec6b?0x0:_0xb740a[_0x332f('0x1d')];var _0x2635cd=_0x13ec6b?_0x48e36a[_0x332f('0x1c')]:_0xb740a[_0x332f('0x1d')]+_0xb740a[_0x332f('0x1a')];var _0xaeefc2;if(_0x2635cd>=_0xbb15b5){_0x2635cd=_0xbb15b5;_0xaeefc2=0xc8;}else{_0xaeefc2=0xce;}_0x36eb3d[_0x332f('0x18')](_0xaeefc2);return _0x36eb3d[_0x332f('0x1e')](_0x332f('0x1f'),_0x1a7de1+'-'+_0x2635cd+'/'+_0xbb15b5)['json'](_0x48e36a);}return null;};}function patchUpdates(_0x46605a){return function(_0x596848){try{jsonpatch[_0x332f('0x20')](_0x596848,_0x46605a,!![]);}catch(_0x3fc306){return BPromise[_0x332f('0x21')](_0x3fc306);}return _0x596848[_0x332f('0x22')]();};}function saveUpdates(_0x3f45fa,_0x2290ad){return function(_0x2ed4e4){if(_0x2ed4e4){return _0x2ed4e4[_0x332f('0x23')](_0x3f45fa)[_0x332f('0x24')](function(_0x1c6f4f){return _0x1c6f4f;});}return null;};}function removeEntity(_0x1d244c,_0x20eaae){return function(_0x28655c){if(_0x28655c){return _0x28655c[_0x332f('0x25')]()[_0x332f('0x24')](function(){_0x1d244c['status'](0xcc)[_0x332f('0x26')]();});}};}function handleEntityNotFound(_0x515b46,_0x137840){return function(_0x4f9ae0){if(!_0x4f9ae0){_0x515b46['sendStatus'](0x194);}return _0x4f9ae0;};}function handleError(_0x5f2260,_0x3c249f){_0x3c249f=_0x3c249f||0x1f4;return function(_0x220b2f){logger[_0x332f('0x27')](_0x220b2f[_0x332f('0x28')]);if(_0x220b2f[_0x332f('0x29')]){delete _0x220b2f[_0x332f('0x29')];}_0x5f2260[_0x332f('0x18')](_0x3c249f)[_0x332f('0x2a')](_0x220b2f);};}exports['index']=function(_0x1ecbb9,_0x5f381c){var _0x2f78de={},_0x575af1={},_0x52a02f={'count':0x0,'rows':[]};var _0x5aef8f=_['map'](db[_0x332f('0x2b')][_0x332f('0x2c')],function(_0x3f604a){return{'name':_0x3f604a['fieldName'],'type':_0x3f604a[_0x332f('0x2d')][_0x332f('0x2e')]};});_0x575af1[_0x332f('0x2f')]=_[_0x332f('0x30')](_0x5aef8f,'name');_0x575af1[_0x332f('0x31')]=_[_0x332f('0x32')](_0x1ecbb9['query']);_0x575af1[_0x332f('0x33')]=_['intersection'](_0x575af1[_0x332f('0x2f')],_0x575af1[_0x332f('0x31')]);_0x2f78de['attributes']=_['intersection'](_0x575af1[_0x332f('0x2f')],qs['fields'](_0x1ecbb9[_0x332f('0x31')][_0x332f('0x34')]));_0x2f78de[_0x332f('0x35')]=_0x2f78de[_0x332f('0x35')][_0x332f('0x36')]?_0x2f78de['attributes']:_0x575af1[_0x332f('0x2f')];if(!_0x1ecbb9[_0x332f('0x31')][_0x332f('0x37')]('nolimit')){_0x2f78de[_0x332f('0x1a')]=qs[_0x332f('0x1a')](_0x1ecbb9[_0x332f('0x31')][_0x332f('0x1a')]);_0x2f78de[_0x332f('0x1d')]=qs[_0x332f('0x1d')](_0x1ecbb9[_0x332f('0x31')][_0x332f('0x1d')]);}_0x2f78de['order']=qs[_0x332f('0x38')](_0x1ecbb9[_0x332f('0x31')]['sort']);_0x2f78de[_0x332f('0x39')]=qs[_0x332f('0x33')](_[_0x332f('0x3a')](_0x1ecbb9[_0x332f('0x31')],_0x575af1['filters']),_0x5aef8f);if(_0x1ecbb9[_0x332f('0x31')][_0x332f('0x3b')]){_0x2f78de[_0x332f('0x39')]=_[_0x332f('0x3c')](_0x2f78de[_0x332f('0x39')],{'$or':_['map'](_0x5aef8f,function(_0x5b375d){if(_0x5b375d[_0x332f('0x2d')]!==_0x332f('0x3d')){var _0x330f48={};_0x330f48[_0x5b375d['name']]={'$like':'%'+_0x1ecbb9[_0x332f('0x31')][_0x332f('0x3b')]+'%'};return _0x330f48;}})});}_0x2f78de=_[_0x332f('0x3c')]({},_0x2f78de,_0x1ecbb9['options']);var _0x4a7c0f={'where':_0x2f78de[_0x332f('0x39')]};return db[_0x332f('0x2b')]['count'](_0x4a7c0f)['then'](function(_0x5a84aa){_0x52a02f['count']=_0x5a84aa;if(_0x1ecbb9[_0x332f('0x31')]['includeAll']){_0x2f78de['include']=[{'all':!![]}];}return db[_0x332f('0x2b')]['findAll'](_0x2f78de);})[_0x332f('0x24')](function(_0x36b877){_0x52a02f[_0x332f('0x3e')]=_0x36b877;return _0x52a02f;})[_0x332f('0x24')](respondWithFilteredResult(_0x5f381c,_0x2f78de))['catch'](handleError(_0x5f381c,null));};exports[_0x332f('0x3f')]=function(_0x2e5dea,_0x1625ce){var _0x268c1e={'raw':![],'where':{'id':_0x2e5dea[_0x332f('0x40')]['id']}},_0x572857={};_0x572857[_0x332f('0x2f')]=_['keys'](db[_0x332f('0x2b')][_0x332f('0x2c')]);_0x572857[_0x332f('0x31')]=_['keys'](_0x2e5dea[_0x332f('0x31')]);_0x572857[_0x332f('0x33')]=_['intersection'](_0x572857['model'],_0x572857[_0x332f('0x31')]);_0x268c1e['attributes']=_[_0x332f('0x41')](_0x572857[_0x332f('0x2f')],qs[_0x332f('0x34')](_0x2e5dea['query'][_0x332f('0x34')]));_0x268c1e[_0x332f('0x35')]=_0x268c1e[_0x332f('0x35')][_0x332f('0x36')]?_0x268c1e[_0x332f('0x35')]:_0x572857['model'];if(_0x2e5dea[_0x332f('0x31')][_0x332f('0x42')]){_0x268c1e[_0x332f('0x43')]=[{'all':!![]}];}_0x268c1e=_[_0x332f('0x3c')]({},_0x268c1e,_0x2e5dea[_0x332f('0x44')]);return db[_0x332f('0x2b')][_0x332f('0x45')](_0x268c1e)['then'](handleEntityNotFound(_0x1625ce,null))[_0x332f('0x24')](respondWithResult(_0x1625ce,null))['catch'](handleError(_0x1625ce,null));};exports[_0x332f('0x46')]=function(_0xc69a26,_0x2ae4d8){return db['DeskConfiguration']['create'](_0xc69a26[_0x332f('0x47')],{})[_0x332f('0x24')](respondWithResult(_0x2ae4d8,0xc9))[_0x332f('0x48')](handleError(_0x2ae4d8,null));};exports['update']=function(_0x546a4a,_0x246873){if(_0x546a4a[_0x332f('0x47')]['id']){delete _0x546a4a[_0x332f('0x47')]['id'];}return db[_0x332f('0x2b')]['find']({'where':{'id':_0x546a4a[_0x332f('0x40')]['id']}})[_0x332f('0x24')](handleEntityNotFound(_0x246873,null))[_0x332f('0x24')](saveUpdates(_0x546a4a[_0x332f('0x47')],null))[_0x332f('0x24')](respondWithResult(_0x246873,null))[_0x332f('0x48')](handleError(_0x246873,null));};exports['destroy']=function(_0x4d9e7f,_0x553b09){return db['DeskConfiguration'][_0x332f('0x45')]({'where':{'id':_0x4d9e7f[_0x332f('0x40')]['id']}})['then'](handleEntityNotFound(_0x553b09,null))[_0x332f('0x24')](removeEntity(_0x553b09,null))['catch'](handleError(_0x553b09,null));};exports[_0x332f('0x49')]=function(_0x43a3c1,_0x154c1d,_0x7f401b){var _0x448294={};var _0x25d65e={};var _0x35d1ab;var _0x19a06c;return db['DeskConfiguration'][_0x332f('0x4a')]({'where':{'id':_0x43a3c1[_0x332f('0x40')]['id']}})['then'](handleEntityNotFound(_0x154c1d,null))[_0x332f('0x24')](function(_0xda31b7){if(_0xda31b7){_0x35d1ab=_0xda31b7;_0x25d65e['model']=_['keys'](db['DeskField']['rawAttributes']);_0x25d65e['query']=_['keys'](_0x43a3c1[_0x332f('0x31')]);_0x25d65e[_0x332f('0x33')]=_[_0x332f('0x41')](_0x25d65e['model'],_0x25d65e[_0x332f('0x31')]);_0x448294[_0x332f('0x35')]=_[_0x332f('0x41')](_0x25d65e[_0x332f('0x2f')],qs[_0x332f('0x34')](_0x43a3c1[_0x332f('0x31')][_0x332f('0x34')]));_0x448294['attributes']=_0x448294[_0x332f('0x35')][_0x332f('0x36')]?_0x448294['attributes']:_0x25d65e['model'];_0x448294[_0x332f('0x4b')]=qs['sort'](_0x43a3c1['query'][_0x332f('0x38')]);_0x448294[_0x332f('0x39')]=qs['filters'](_['pick'](_0x43a3c1['query'],_0x25d65e[_0x332f('0x33')]));if(_0x43a3c1['query'][_0x332f('0x3b')]){_0x448294[_0x332f('0x39')]=_[_0x332f('0x3c')](_0x448294[_0x332f('0x39')],{'$or':_[_0x332f('0x30')](_0x448294['attributes'],function(_0x4794cd){var _0x5ae7ea={};_0x5ae7ea[_0x4794cd]={'$like':'%'+_0x43a3c1[_0x332f('0x31')][_0x332f('0x3b')]+'%'};return _0x5ae7ea;})});}_0x448294=_[_0x332f('0x3c')]({},_0x448294,_0x43a3c1['options']);return _0x35d1ab[_0x332f('0x49')](_0x448294);}})['then'](function(_0x62bbda){if(_0x62bbda){_0x19a06c=_0x62bbda['length'];if(!_0x43a3c1[_0x332f('0x31')][_0x332f('0x37')]('nolimit')){_0x448294['limit']=qs[_0x332f('0x1a')](_0x43a3c1[_0x332f('0x31')][_0x332f('0x1a')]);_0x448294[_0x332f('0x1d')]=qs[_0x332f('0x1d')](_0x43a3c1['query'][_0x332f('0x1d')]);}return _0x35d1ab[_0x332f('0x49')](_0x448294);}})[_0x332f('0x24')](function(_0x28e87d){if(_0x28e87d){return _0x28e87d?{'count':_0x19a06c,'rows':_0x28e87d}:null;}})[_0x332f('0x24')](respondWithResult(_0x154c1d,null))['catch'](handleError(_0x154c1d,null));};exports[_0x332f('0x4c')]=function(_0x231df9,_0x1b959a,_0x3e2447){var _0x903338={};var _0x4adc3a={};var _0x269df7;var _0x25e07c;return db[_0x332f('0x2b')][_0x332f('0x4a')]({'where':{'id':_0x231df9['params']['id']}})[_0x332f('0x24')](handleEntityNotFound(_0x1b959a,null))[_0x332f('0x24')](function(_0x2d10d2){if(_0x2d10d2){_0x269df7=_0x2d10d2;_0x4adc3a[_0x332f('0x2f')]=_[_0x332f('0x32')](db['DeskField'][_0x332f('0x2c')]);_0x4adc3a[_0x332f('0x31')]=_['keys'](_0x231df9[_0x332f('0x31')]);_0x4adc3a[_0x332f('0x33')]=_['intersection'](_0x4adc3a['model'],_0x4adc3a[_0x332f('0x31')]);_0x903338[_0x332f('0x35')]=_['intersection'](_0x4adc3a[_0x332f('0x2f')],qs['fields'](_0x231df9['query']['fields']));_0x903338[_0x332f('0x35')]=_0x903338[_0x332f('0x35')][_0x332f('0x36')]?_0x903338['attributes']:_0x4adc3a[_0x332f('0x2f')];_0x903338['order']=qs[_0x332f('0x38')](_0x231df9[_0x332f('0x31')][_0x332f('0x38')]);_0x903338[_0x332f('0x39')]=qs[_0x332f('0x33')](_[_0x332f('0x3a')](_0x231df9[_0x332f('0x31')],_0x4adc3a[_0x332f('0x33')]));if(_0x231df9[_0x332f('0x31')]['filter']){_0x903338[_0x332f('0x39')]=_[_0x332f('0x3c')](_0x903338[_0x332f('0x39')],{'$or':_[_0x332f('0x30')](_0x903338[_0x332f('0x35')],function(_0x9e07b9){var _0x435724={};_0x435724[_0x9e07b9]={'$like':'%'+_0x231df9[_0x332f('0x31')][_0x332f('0x3b')]+'%'};return _0x435724;})});}_0x903338=_[_0x332f('0x3c')]({},_0x903338,_0x231df9[_0x332f('0x44')]);return _0x269df7[_0x332f('0x4c')](_0x903338);}})[_0x332f('0x24')](function(_0x3e2d8e){if(_0x3e2d8e){_0x25e07c=_0x3e2d8e[_0x332f('0x36')];if(!_0x231df9[_0x332f('0x31')][_0x332f('0x37')](_0x332f('0x4d'))){_0x903338[_0x332f('0x1a')]=qs[_0x332f('0x1a')](_0x231df9[_0x332f('0x31')][_0x332f('0x1a')]);_0x903338[_0x332f('0x1d')]=qs['offset'](_0x231df9[_0x332f('0x31')][_0x332f('0x1d')]);}return _0x269df7[_0x332f('0x4c')](_0x903338);}})[_0x332f('0x24')](function(_0x3da0c6){if(_0x3da0c6){return _0x3da0c6?{'count':_0x25e07c,'rows':_0x3da0c6}:null;}})[_0x332f('0x24')](respondWithResult(_0x1b959a,null))['catch'](handleError(_0x1b959a,null));};exports[_0x332f('0x4e')]=function(_0x1d1deb,_0x4221d1,_0x27cc08){var _0x380120={};var _0x292206={};var _0x1c6e53;var _0x33e4d9;return db[_0x332f('0x2b')]['findOne']({'where':{'id':_0x1d1deb[_0x332f('0x40')]['id']}})[_0x332f('0x24')](handleEntityNotFound(_0x4221d1,null))[_0x332f('0x24')](function(_0x581e2e){if(_0x581e2e){_0x1c6e53=_0x581e2e;_0x292206['model']=_[_0x332f('0x32')](db[_0x332f('0x4f')]['rawAttributes']);_0x292206[_0x332f('0x31')]=_['keys'](_0x1d1deb[_0x332f('0x31')]);_0x292206[_0x332f('0x33')]=_[_0x332f('0x41')](_0x292206[_0x332f('0x2f')],_0x292206[_0x332f('0x31')]);_0x380120[_0x332f('0x35')]=_[_0x332f('0x41')](_0x292206[_0x332f('0x2f')],qs[_0x332f('0x34')](_0x1d1deb[_0x332f('0x31')]['fields']));_0x380120[_0x332f('0x35')]=_0x380120[_0x332f('0x35')][_0x332f('0x36')]?_0x380120[_0x332f('0x35')]:_0x292206[_0x332f('0x2f')];_0x380120[_0x332f('0x4b')]=qs[_0x332f('0x38')](_0x1d1deb[_0x332f('0x31')][_0x332f('0x38')]);_0x380120['where']=qs['filters'](_[_0x332f('0x3a')](_0x1d1deb[_0x332f('0x31')],_0x292206[_0x332f('0x33')]));if(_0x1d1deb[_0x332f('0x31')][_0x332f('0x3b')]){_0x380120[_0x332f('0x39')]=_[_0x332f('0x3c')](_0x380120[_0x332f('0x39')],{'$or':_[_0x332f('0x30')](_0x380120[_0x332f('0x35')],function(_0x994284){var _0x5ebc93={};_0x5ebc93[_0x994284]={'$like':'%'+_0x1d1deb[_0x332f('0x31')][_0x332f('0x3b')]+'%'};return _0x5ebc93;})});}_0x380120=_['merge']({},_0x380120,_0x1d1deb['options']);return _0x1c6e53[_0x332f('0x4e')](_0x380120);}})[_0x332f('0x24')](function(_0x23fa59){if(_0x23fa59){_0x33e4d9=_0x23fa59[_0x332f('0x36')];if(!_0x1d1deb[_0x332f('0x31')][_0x332f('0x37')](_0x332f('0x4d'))){_0x380120[_0x332f('0x1a')]=qs[_0x332f('0x1a')](_0x1d1deb['query']['limit']);_0x380120[_0x332f('0x1d')]=qs[_0x332f('0x1d')](_0x1d1deb[_0x332f('0x31')][_0x332f('0x1d')]);}return _0x1c6e53[_0x332f('0x4e')](_0x380120);}})[_0x332f('0x24')](function(_0x1a8507){if(_0x1a8507){return _0x1a8507?{'count':_0x33e4d9,'rows':_0x1a8507}:null;}})['then'](respondWithResult(_0x4221d1,null))[_0x332f('0x48')](handleError(_0x4221d1,null));};exports[_0x332f('0x50')]=function(_0x37f424,_0x1464dc,_0x31987c){var _0x27a518={};var _0xfd9849={};var _0x13539b;var _0x31772e;return db[_0x332f('0x2b')][_0x332f('0x4a')]({'where':{'id':_0x37f424[_0x332f('0x40')]['id']}})[_0x332f('0x24')](handleEntityNotFound(_0x1464dc,null))[_0x332f('0x24')](function(_0xc20ef6){if(_0xc20ef6){_0x13539b=_0xc20ef6;_0xfd9849[_0x332f('0x2f')]=_[_0x332f('0x32')](db[_0x332f('0x51')][_0x332f('0x2c')]);_0xfd9849[_0x332f('0x31')]=_[_0x332f('0x32')](_0x37f424['query']);_0xfd9849[_0x332f('0x33')]=_[_0x332f('0x41')](_0xfd9849[_0x332f('0x2f')],_0xfd9849['query']);_0x27a518[_0x332f('0x35')]=_[_0x332f('0x41')](_0xfd9849[_0x332f('0x2f')],qs[_0x332f('0x34')](_0x37f424[_0x332f('0x31')][_0x332f('0x34')]));_0x27a518[_0x332f('0x35')]=_0x27a518[_0x332f('0x35')][_0x332f('0x36')]?_0x27a518[_0x332f('0x35')]:_0xfd9849[_0x332f('0x2f')];_0x27a518[_0x332f('0x4b')]=qs[_0x332f('0x38')](_0x37f424[_0x332f('0x31')]['sort']);_0x27a518[_0x332f('0x39')]=qs[_0x332f('0x33')](_['pick'](_0x37f424[_0x332f('0x31')],_0xfd9849['filters']));if(_0x37f424[_0x332f('0x31')][_0x332f('0x3b')]){_0x27a518[_0x332f('0x39')]=_['merge'](_0x27a518[_0x332f('0x39')],{'$or':_[_0x332f('0x30')](_0x27a518[_0x332f('0x35')],function(_0x34f71b){var _0x5d55bb={};_0x5d55bb[_0x34f71b]={'$like':'%'+_0x37f424['query']['filter']+'%'};return _0x5d55bb;})});}_0x27a518=_[_0x332f('0x3c')]({},_0x27a518,_0x37f424[_0x332f('0x44')]);return _0x13539b[_0x332f('0x50')](_0x27a518);}})['then'](function(_0x100ab1){if(_0x100ab1){_0x31772e=_0x100ab1[_0x332f('0x36')];if(!_0x37f424['query'][_0x332f('0x37')](_0x332f('0x4d'))){_0x27a518[_0x332f('0x1a')]=qs[_0x332f('0x1a')](_0x37f424[_0x332f('0x31')]['limit']);_0x27a518[_0x332f('0x1d')]=qs[_0x332f('0x1d')](_0x37f424[_0x332f('0x31')]['offset']);}return _0x13539b[_0x332f('0x50')](_0x27a518);}})[_0x332f('0x24')](function(_0x18d7cb){if(_0x18d7cb){return _0x18d7cb?{'count':_0x31772e,'rows':_0x18d7cb}:null;}})['then'](respondWithResult(_0x1464dc,null))[_0x332f('0x48')](handleError(_0x1464dc,null));};exports[_0x332f('0x52')]=function(_0x1ca801,_0x58c660,_0x5c5923){if(_0x1ca801['body']['id']){delete _0x1ca801[_0x332f('0x47')]['id'];}return db[_0x332f('0x2b')]['findOne']({'where':{'id':_0x1ca801['params']['id']}})['then'](handleEntityNotFound(_0x58c660,null))[_0x332f('0x24')](function(_0x45bb79){if(_0x45bb79){return _0x45bb79[_0x332f('0x52')](_0x1ca801[_0x332f('0x47')][_0x332f('0x53')]||[]);}return null;})[_0x332f('0x24')](respondWithResult(_0x58c660,null))[_0x332f('0x48')](handleError(_0x58c660,null));};