Built motion from commit e02f907f.|2.6.14
[motion2.git] / server / api / intFreshsalesConfiguration / intFreshsalesConfiguration.controller.js
index 7098b77..4e1efb4 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x918c=['save','destroy','then','error','stack','name','index','map','FreshsalesConfiguration','key','query','keys','filters','intersection','model','attributes','fields','length','hasOwnProperty','nolimit','sort','where','pick','filter','VIRTUAL','merge','options','include','findAll','show','params','rawAttributes','includeAll','find','catch','create','update','body','getSubjects','findOne','FreshsalesField','order','getDescriptions','getFields','eml-format','rimraf','zip-dir','bluebird','util','path','to-csv','ejs','fs-extra','lodash','crypto','jsforce','desk.js','querystring','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../mysqldb','sendStatus','end','status','offset','undefined','count','limit','set','Content-Range','apply','reject'];(function(_0x1bc95c,_0x109aec){var _0x1a9fdc=function(_0x3d73f8){while(--_0x3d73f8){_0x1bc95c['push'](_0x1bc95c['shift']());}};_0x1a9fdc(++_0x109aec);}(_0x918c,0x160));var _0xc918=function(_0x17406a,_0x1e2320){_0x17406a=_0x17406a-0x0;var _0x1501ff=_0x918c[_0x17406a];return _0x1501ff;};'use strict';var emlformat=require(_0xc918('0x0'));var rimraf=require(_0xc918('0x1'));var zipdir=require(_0xc918('0x2'));var jsonpatch=require('fast-json-patch');var rp=require('request-promise');var moment=require('moment');var BPromise=require(_0xc918('0x3'));var Mustache=require('mustache');var util=require(_0xc918('0x4'));var path=require(_0xc918('0x5'));var sox=require('sox');var csv=require(_0xc918('0x6'));var ejs=require(_0xc918('0x7'));var fs=require('fs');var fs_extra=require(_0xc918('0x8'));var _=require(_0xc918('0x9'));var squel=require('squel');var crypto=require(_0xc918('0xa'));var jsforce=require(_0xc918('0xb'));var deskjs=require(_0xc918('0xc'));var toCsv=require(_0xc918('0x6'));var querystring=require(_0xc918('0xd'));var Papa=require('papaparse');var Redis=require('ioredis');var authService=require('../../components/auth/service');var qs=require(_0xc918('0xe'));var as=require(_0xc918('0xf'));var hardwareService=require(_0xc918('0x10'));var logger=require(_0xc918('0x11'))(_0xc918('0x12'));var utils=require(_0xc918('0x13'));var config=require(_0xc918('0x14'));var licenseUtil=require('../../config/license/util');var db=require(_0xc918('0x15'))['db'];function respondWithStatusCode(_0x30951d,_0x9a3fca){_0x9a3fca=_0x9a3fca||0xcc;return function(_0x292220){if(_0x292220){return _0x30951d[_0xc918('0x16')](_0x9a3fca);}return _0x30951d['status'](_0x9a3fca)[_0xc918('0x17')]();};}function respondWithResult(_0x2c9e2a,_0x31543e){_0x31543e=_0x31543e||0xc8;return function(_0x4f3a31){if(_0x4f3a31){return _0x2c9e2a[_0xc918('0x18')](_0x31543e)['json'](_0x4f3a31);}};}function respondWithFilteredResult(_0x573cb2,_0x5280b6){return function(_0xb2a05b){if(_0xb2a05b){var _0x4e7759=typeof _0x5280b6[_0xc918('0x19')]===_0xc918('0x1a')&&typeof _0x5280b6['limit']==='undefined';var _0x26b27=_0xb2a05b['count'];var _0x42704a=_0x4e7759?0x0:_0x5280b6[_0xc918('0x19')];var _0xa86fa7=_0x4e7759?_0xb2a05b[_0xc918('0x1b')]:_0x5280b6[_0xc918('0x19')]+_0x5280b6[_0xc918('0x1c')];var _0x1646c1;if(_0xa86fa7>=_0x26b27){_0xa86fa7=_0x26b27;_0x1646c1=0xc8;}else{_0x1646c1=0xce;}_0x573cb2['status'](_0x1646c1);return _0x573cb2[_0xc918('0x1d')](_0xc918('0x1e'),_0x42704a+'-'+_0xa86fa7+'/'+_0x26b27)['json'](_0xb2a05b);}return null;};}function patchUpdates(_0xc9c8ff){return function(_0x32270a){try{jsonpatch[_0xc918('0x1f')](_0x32270a,_0xc9c8ff,!![]);}catch(_0x70b1c1){return BPromise[_0xc918('0x20')](_0x70b1c1);}return _0x32270a[_0xc918('0x21')]();};}function saveUpdates(_0x56b3ec,_0x4c3ee1){return function(_0x4d2e3b){if(_0x4d2e3b){return _0x4d2e3b['update'](_0x56b3ec)['then'](function(_0x5b97b8){return _0x5b97b8;});}return null;};}function removeEntity(_0x24abeb,_0x2d0235){return function(_0x3581d3){if(_0x3581d3){return _0x3581d3[_0xc918('0x22')]()[_0xc918('0x23')](function(){_0x24abeb['status'](0xcc)[_0xc918('0x17')]();});}};}function handleEntityNotFound(_0x2fdf30,_0x3c02f9){return function(_0x232403){if(!_0x232403){_0x2fdf30[_0xc918('0x16')](0x194);}return _0x232403;};}function handleError(_0x12c092,_0x5b187d){_0x5b187d=_0x5b187d||0x1f4;return function(_0x4c6e05){logger[_0xc918('0x24')](_0x4c6e05[_0xc918('0x25')]);if(_0x4c6e05[_0xc918('0x26')]){delete _0x4c6e05['name'];}_0x12c092['status'](_0x5b187d)['send'](_0x4c6e05);};}exports[_0xc918('0x27')]=function(_0xa06f0b,_0x1d6673){var _0x408c4b={},_0xcbe0f8={},_0x22a5f9={'count':0x0,'rows':[]};var _0x36e0ca=_[_0xc918('0x28')](db[_0xc918('0x29')]['rawAttributes'],function(_0x580656){return{'name':_0x580656['fieldName'],'type':_0x580656['type'][_0xc918('0x2a')]};});_0xcbe0f8['model']=_[_0xc918('0x28')](_0x36e0ca,_0xc918('0x26'));_0xcbe0f8[_0xc918('0x2b')]=_[_0xc918('0x2c')](_0xa06f0b[_0xc918('0x2b')]);_0xcbe0f8[_0xc918('0x2d')]=_[_0xc918('0x2e')](_0xcbe0f8[_0xc918('0x2f')],_0xcbe0f8[_0xc918('0x2b')]);_0x408c4b[_0xc918('0x30')]=_[_0xc918('0x2e')](_0xcbe0f8[_0xc918('0x2f')],qs[_0xc918('0x31')](_0xa06f0b[_0xc918('0x2b')]['fields']));_0x408c4b[_0xc918('0x30')]=_0x408c4b[_0xc918('0x30')][_0xc918('0x32')]?_0x408c4b[_0xc918('0x30')]:_0xcbe0f8[_0xc918('0x2f')];if(!_0xa06f0b['query'][_0xc918('0x33')](_0xc918('0x34'))){_0x408c4b[_0xc918('0x1c')]=qs[_0xc918('0x1c')](_0xa06f0b[_0xc918('0x2b')][_0xc918('0x1c')]);_0x408c4b[_0xc918('0x19')]=qs[_0xc918('0x19')](_0xa06f0b[_0xc918('0x2b')][_0xc918('0x19')]);}_0x408c4b['order']=qs[_0xc918('0x35')](_0xa06f0b[_0xc918('0x2b')][_0xc918('0x35')]);_0x408c4b[_0xc918('0x36')]=qs[_0xc918('0x2d')](_[_0xc918('0x37')](_0xa06f0b['query'],_0xcbe0f8[_0xc918('0x2d')]),_0x36e0ca);if(_0xa06f0b[_0xc918('0x2b')][_0xc918('0x38')]){_0x408c4b['where']=_['merge'](_0x408c4b[_0xc918('0x36')],{'$or':_[_0xc918('0x28')](_0x36e0ca,function(_0x13cfa4){if(_0x13cfa4['type']!==_0xc918('0x39')){var _0x4c3cd7={};_0x4c3cd7[_0x13cfa4[_0xc918('0x26')]]={'$like':'%'+_0xa06f0b[_0xc918('0x2b')]['filter']+'%'};return _0x4c3cd7;}})});}_0x408c4b=_[_0xc918('0x3a')]({},_0x408c4b,_0xa06f0b[_0xc918('0x3b')]);var _0x2959b6={'where':_0x408c4b[_0xc918('0x36')]};return db['FreshsalesConfiguration'][_0xc918('0x1b')](_0x2959b6)[_0xc918('0x23')](function(_0x4dcd2e){_0x22a5f9[_0xc918('0x1b')]=_0x4dcd2e;if(_0xa06f0b[_0xc918('0x2b')]['includeAll']){_0x408c4b[_0xc918('0x3c')]=[{'all':!![]}];}return db[_0xc918('0x29')][_0xc918('0x3d')](_0x408c4b);})['then'](function(_0x4f0070){_0x22a5f9['rows']=_0x4f0070;return _0x22a5f9;})['then'](respondWithFilteredResult(_0x1d6673,_0x408c4b))['catch'](handleError(_0x1d6673,null));};exports[_0xc918('0x3e')]=function(_0x5be383,_0x11b189){var _0x24b2a2={'raw':![],'where':{'id':_0x5be383[_0xc918('0x3f')]['id']}},_0x41cc87={};_0x41cc87[_0xc918('0x2f')]=_[_0xc918('0x2c')](db[_0xc918('0x29')][_0xc918('0x40')]);_0x41cc87[_0xc918('0x2b')]=_[_0xc918('0x2c')](_0x5be383[_0xc918('0x2b')]);_0x41cc87[_0xc918('0x2d')]=_[_0xc918('0x2e')](_0x41cc87[_0xc918('0x2f')],_0x41cc87['query']);_0x24b2a2[_0xc918('0x30')]=_[_0xc918('0x2e')](_0x41cc87[_0xc918('0x2f')],qs[_0xc918('0x31')](_0x5be383[_0xc918('0x2b')][_0xc918('0x31')]));_0x24b2a2[_0xc918('0x30')]=_0x24b2a2['attributes'][_0xc918('0x32')]?_0x24b2a2[_0xc918('0x30')]:_0x41cc87[_0xc918('0x2f')];if(_0x5be383[_0xc918('0x2b')][_0xc918('0x41')]){_0x24b2a2[_0xc918('0x3c')]=[{'all':!![]}];}_0x24b2a2=_[_0xc918('0x3a')]({},_0x24b2a2,_0x5be383[_0xc918('0x3b')]);return db[_0xc918('0x29')][_0xc918('0x42')](_0x24b2a2)[_0xc918('0x23')](handleEntityNotFound(_0x11b189,null))[_0xc918('0x23')](respondWithResult(_0x11b189,null))[_0xc918('0x43')](handleError(_0x11b189,null));};exports['create']=function(_0xcbb779,_0x359e49){return db['FreshsalesConfiguration'][_0xc918('0x44')](_0xcbb779['body'],{})[_0xc918('0x23')](respondWithResult(_0x359e49,0xc9))['catch'](handleError(_0x359e49,null));};exports[_0xc918('0x45')]=function(_0x35b6ff,_0x440a02){if(_0x35b6ff[_0xc918('0x46')]['id']){delete _0x35b6ff[_0xc918('0x46')]['id'];}return db[_0xc918('0x29')]['find']({'where':{'id':_0x35b6ff[_0xc918('0x3f')]['id']}})[_0xc918('0x23')](handleEntityNotFound(_0x440a02,null))[_0xc918('0x23')](saveUpdates(_0x35b6ff['body'],null))[_0xc918('0x23')](respondWithResult(_0x440a02,null))[_0xc918('0x43')](handleError(_0x440a02,null));};exports['destroy']=function(_0xc9db3c,_0xbd172b){return db[_0xc918('0x29')][_0xc918('0x42')]({'where':{'id':_0xc9db3c[_0xc918('0x3f')]['id']}})[_0xc918('0x23')](handleEntityNotFound(_0xbd172b,null))['then'](removeEntity(_0xbd172b,null))[_0xc918('0x43')](handleError(_0xbd172b,null));};exports['getSubjects']=function(_0x357499,_0x36bbf7,_0x269996){var _0x2159f7={};var _0x2efd6e={};var _0x34a74b;var _0x298a14;return db[_0xc918('0x29')]['findOne']({'where':{'id':_0x357499[_0xc918('0x3f')]['id']}})['then'](handleEntityNotFound(_0x36bbf7,null))['then'](function(_0x5dfd73){if(_0x5dfd73){_0x34a74b=_0x5dfd73;_0x2efd6e['model']=_[_0xc918('0x2c')](db['FreshsalesField'][_0xc918('0x40')]);_0x2efd6e[_0xc918('0x2b')]=_[_0xc918('0x2c')](_0x357499[_0xc918('0x2b')]);_0x2efd6e[_0xc918('0x2d')]=_[_0xc918('0x2e')](_0x2efd6e[_0xc918('0x2f')],_0x2efd6e[_0xc918('0x2b')]);_0x2159f7[_0xc918('0x30')]=_[_0xc918('0x2e')](_0x2efd6e[_0xc918('0x2f')],qs[_0xc918('0x31')](_0x357499[_0xc918('0x2b')][_0xc918('0x31')]));_0x2159f7[_0xc918('0x30')]=_0x2159f7['attributes'][_0xc918('0x32')]?_0x2159f7[_0xc918('0x30')]:_0x2efd6e['model'];_0x2159f7['order']=qs[_0xc918('0x35')](_0x357499[_0xc918('0x2b')][_0xc918('0x35')]);_0x2159f7['where']=qs['filters'](_[_0xc918('0x37')](_0x357499[_0xc918('0x2b')],_0x2efd6e[_0xc918('0x2d')]));if(_0x357499[_0xc918('0x2b')][_0xc918('0x38')]){_0x2159f7[_0xc918('0x36')]=_[_0xc918('0x3a')](_0x2159f7['where'],{'$or':_[_0xc918('0x28')](_0x2159f7['attributes'],function(_0x4cce19){var _0x44a328={};_0x44a328[_0x4cce19]={'$like':'%'+_0x357499[_0xc918('0x2b')][_0xc918('0x38')]+'%'};return _0x44a328;})});}_0x2159f7=_[_0xc918('0x3a')]({},_0x2159f7,_0x357499[_0xc918('0x3b')]);return _0x34a74b['getSubjects'](_0x2159f7);}})[_0xc918('0x23')](function(_0x67561f){if(_0x67561f){_0x298a14=_0x67561f[_0xc918('0x32')];if(!_0x357499['query'][_0xc918('0x33')](_0xc918('0x34'))){_0x2159f7[_0xc918('0x1c')]=qs[_0xc918('0x1c')](_0x357499[_0xc918('0x2b')]['limit']);_0x2159f7['offset']=qs[_0xc918('0x19')](_0x357499['query'][_0xc918('0x19')]);}return _0x34a74b[_0xc918('0x47')](_0x2159f7);}})[_0xc918('0x23')](function(_0x570982){if(_0x570982){return _0x570982?{'count':_0x298a14,'rows':_0x570982}:null;}})['then'](respondWithResult(_0x36bbf7,null))['catch'](handleError(_0x36bbf7,null));};exports['getDescriptions']=function(_0x1259ee,_0x1301a2,_0x4c653b){var _0x1ec90f={};var _0x4762e1={};var _0x3bad21;var _0x7662d0;return db[_0xc918('0x29')][_0xc918('0x48')]({'where':{'id':_0x1259ee[_0xc918('0x3f')]['id']}})[_0xc918('0x23')](handleEntityNotFound(_0x1301a2,null))[_0xc918('0x23')](function(_0x1e8421){if(_0x1e8421){_0x3bad21=_0x1e8421;_0x4762e1[_0xc918('0x2f')]=_['keys'](db[_0xc918('0x49')]['rawAttributes']);_0x4762e1['query']=_[_0xc918('0x2c')](_0x1259ee['query']);_0x4762e1['filters']=_['intersection'](_0x4762e1[_0xc918('0x2f')],_0x4762e1[_0xc918('0x2b')]);_0x1ec90f[_0xc918('0x30')]=_[_0xc918('0x2e')](_0x4762e1[_0xc918('0x2f')],qs['fields'](_0x1259ee[_0xc918('0x2b')]['fields']));_0x1ec90f['attributes']=_0x1ec90f[_0xc918('0x30')][_0xc918('0x32')]?_0x1ec90f['attributes']:_0x4762e1[_0xc918('0x2f')];_0x1ec90f[_0xc918('0x4a')]=qs[_0xc918('0x35')](_0x1259ee[_0xc918('0x2b')]['sort']);_0x1ec90f['where']=qs[_0xc918('0x2d')](_[_0xc918('0x37')](_0x1259ee[_0xc918('0x2b')],_0x4762e1['filters']));if(_0x1259ee[_0xc918('0x2b')]['filter']){_0x1ec90f[_0xc918('0x36')]=_[_0xc918('0x3a')](_0x1ec90f[_0xc918('0x36')],{'$or':_[_0xc918('0x28')](_0x1ec90f['attributes'],function(_0x250f56){var _0x15adda={};_0x15adda[_0x250f56]={'$like':'%'+_0x1259ee[_0xc918('0x2b')]['filter']+'%'};return _0x15adda;})});}_0x1ec90f=_['merge']({},_0x1ec90f,_0x1259ee[_0xc918('0x3b')]);return _0x3bad21[_0xc918('0x4b')](_0x1ec90f);}})[_0xc918('0x23')](function(_0x87fff0){if(_0x87fff0){_0x7662d0=_0x87fff0['length'];if(!_0x1259ee[_0xc918('0x2b')][_0xc918('0x33')](_0xc918('0x34'))){_0x1ec90f[_0xc918('0x1c')]=qs['limit'](_0x1259ee['query']['limit']);_0x1ec90f['offset']=qs[_0xc918('0x19')](_0x1259ee[_0xc918('0x2b')]['offset']);}return _0x3bad21[_0xc918('0x4b')](_0x1ec90f);}})['then'](function(_0x4b603e){if(_0x4b603e){return _0x4b603e?{'count':_0x7662d0,'rows':_0x4b603e}:null;}})[_0xc918('0x23')](respondWithResult(_0x1301a2,null))[_0xc918('0x43')](handleError(_0x1301a2,null));};exports[_0xc918('0x4c')]=function(_0x3737eb,_0xf5ea61,_0x455259){var _0x4cea9f={};var _0x3da9e9={};var _0x57b019;var _0x416aee;return db[_0xc918('0x29')][_0xc918('0x48')]({'where':{'id':_0x3737eb[_0xc918('0x3f')]['id']}})[_0xc918('0x23')](handleEntityNotFound(_0xf5ea61,null))[_0xc918('0x23')](function(_0x31b83b){if(_0x31b83b){_0x57b019=_0x31b83b;_0x3da9e9[_0xc918('0x2f')]=_[_0xc918('0x2c')](db['FreshsalesField'][_0xc918('0x40')]);_0x3da9e9['query']=_[_0xc918('0x2c')](_0x3737eb['query']);_0x3da9e9['filters']=_[_0xc918('0x2e')](_0x3da9e9['model'],_0x3da9e9['query']);_0x4cea9f['attributes']=_['intersection'](_0x3da9e9[_0xc918('0x2f')],qs['fields'](_0x3737eb[_0xc918('0x2b')][_0xc918('0x31')]));_0x4cea9f[_0xc918('0x30')]=_0x4cea9f[_0xc918('0x30')][_0xc918('0x32')]?_0x4cea9f[_0xc918('0x30')]:_0x3da9e9[_0xc918('0x2f')];_0x4cea9f[_0xc918('0x4a')]=qs['sort'](_0x3737eb['query'][_0xc918('0x35')]);_0x4cea9f[_0xc918('0x36')]=qs['filters'](_[_0xc918('0x37')](_0x3737eb['query'],_0x3da9e9[_0xc918('0x2d')]));if(_0x3737eb[_0xc918('0x2b')][_0xc918('0x38')]){_0x4cea9f[_0xc918('0x36')]=_['merge'](_0x4cea9f[_0xc918('0x36')],{'$or':_[_0xc918('0x28')](_0x4cea9f['attributes'],function(_0x18b735){var _0x22c8c3={};_0x22c8c3[_0x18b735]={'$like':'%'+_0x3737eb['query'][_0xc918('0x38')]+'%'};return _0x22c8c3;})});}_0x4cea9f=_['merge']({},_0x4cea9f,_0x3737eb[_0xc918('0x3b')]);return _0x57b019['getFields'](_0x4cea9f);}})[_0xc918('0x23')](function(_0x47a111){if(_0x47a111){_0x416aee=_0x47a111[_0xc918('0x32')];if(!_0x3737eb[_0xc918('0x2b')]['hasOwnProperty'](_0xc918('0x34'))){_0x4cea9f[_0xc918('0x1c')]=qs['limit'](_0x3737eb[_0xc918('0x2b')][_0xc918('0x1c')]);_0x4cea9f[_0xc918('0x19')]=qs[_0xc918('0x19')](_0x3737eb[_0xc918('0x2b')][_0xc918('0x19')]);}return _0x57b019[_0xc918('0x4c')](_0x4cea9f);}})[_0xc918('0x23')](function(_0x597934){if(_0x597934){return _0x597934?{'count':_0x416aee,'rows':_0x597934}:null;}})[_0xc918('0x23')](respondWithResult(_0xf5ea61,null))[_0xc918('0x43')](handleError(_0xf5ea61,null));};
\ No newline at end of file
+var _0xe043=['ejs','fs-extra','squel','crypto','jsforce','querystring','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/utils','../../config/license/util','../../mysqldb','sendStatus','status','json','undefined','limit','count','offset','set','Content-Range','apply','reject','then','destroy','end','name','send','index','FreshsalesConfiguration','rawAttributes','key','model','query','keys','filters','attributes','intersection','fields','length','order','sort','where','pick','filter','map','VIRTUAL','includeAll','include','findAll','catch','show','merge','options','find','create','body','update','params','getSubjects','findOne','FreshsalesField','nolimit','getDescriptions','hasOwnProperty','getFields','eml-format','rimraf','zip-dir','util','sox','to-csv'];(function(_0x4cdfa7,_0x1661f6){var _0x5299b2=function(_0x47e52c){while(--_0x47e52c){_0x4cdfa7['push'](_0x4cdfa7['shift']());}};_0x5299b2(++_0x1661f6);}(_0xe043,0x1b6));var _0x3e04=function(_0xbfc467,_0x2eb680){_0xbfc467=_0xbfc467-0x0;var _0x2971d2=_0xe043[_0xbfc467];return _0x2971d2;};'use strict';var emlformat=require(_0x3e04('0x0'));var rimraf=require(_0x3e04('0x1'));var zipdir=require(_0x3e04('0x2'));var jsonpatch=require('fast-json-patch');var rp=require('request-promise');var moment=require('moment');var BPromise=require('bluebird');var Mustache=require('mustache');var util=require(_0x3e04('0x3'));var path=require('path');var sox=require(_0x3e04('0x4'));var csv=require(_0x3e04('0x5'));var ejs=require(_0x3e04('0x6'));var fs=require('fs');var fs_extra=require(_0x3e04('0x7'));var _=require('lodash');var squel=require(_0x3e04('0x8'));var crypto=require(_0x3e04('0x9'));var jsforce=require(_0x3e04('0xa'));var deskjs=require('desk.js');var toCsv=require(_0x3e04('0x5'));var querystring=require(_0x3e04('0xb'));var Papa=require('papaparse');var Redis=require(_0x3e04('0xc'));var authService=require(_0x3e04('0xd'));var qs=require(_0x3e04('0xe'));var as=require(_0x3e04('0xf'));var hardwareService=require(_0x3e04('0x10'));var logger=require('../../config/logger')('api');var utils=require(_0x3e04('0x11'));var config=require('../../config/environment');var licenseUtil=require(_0x3e04('0x12'));var db=require(_0x3e04('0x13'))['db'];function respondWithStatusCode(_0x4156dd,_0x56608a){_0x56608a=_0x56608a||0xcc;return function(_0x2541cf){if(_0x2541cf){return _0x4156dd[_0x3e04('0x14')](_0x56608a);}return _0x4156dd[_0x3e04('0x15')](_0x56608a)['end']();};}function respondWithResult(_0x60862d,_0x5d4308){_0x5d4308=_0x5d4308||0xc8;return function(_0x23ccbd){if(_0x23ccbd){return _0x60862d['status'](_0x5d4308)[_0x3e04('0x16')](_0x23ccbd);}};}function respondWithFilteredResult(_0x12a880,_0x311008){return function(_0x887af2){if(_0x887af2){var _0x5291b1=typeof _0x311008['offset']===_0x3e04('0x17')&&typeof _0x311008[_0x3e04('0x18')]==='undefined';var _0xcfc148=_0x887af2[_0x3e04('0x19')];var _0x230931=_0x5291b1?0x0:_0x311008['offset'];var _0xdedde8=_0x5291b1?_0x887af2[_0x3e04('0x19')]:_0x311008[_0x3e04('0x1a')]+_0x311008[_0x3e04('0x18')];var _0x3dc472;if(_0xdedde8>=_0xcfc148){_0xdedde8=_0xcfc148;_0x3dc472=0xc8;}else{_0x3dc472=0xce;}_0x12a880[_0x3e04('0x15')](_0x3dc472);return _0x12a880[_0x3e04('0x1b')](_0x3e04('0x1c'),_0x230931+'-'+_0xdedde8+'/'+_0xcfc148)[_0x3e04('0x16')](_0x887af2);}return null;};}function patchUpdates(_0x3b46d0){return function(_0x36d57e){try{jsonpatch[_0x3e04('0x1d')](_0x36d57e,_0x3b46d0,!![]);}catch(_0x19963b){return BPromise[_0x3e04('0x1e')](_0x19963b);}return _0x36d57e['save']();};}function saveUpdates(_0x374bc6,_0x25c0c4){return function(_0x28d22d){if(_0x28d22d){return _0x28d22d['update'](_0x374bc6)[_0x3e04('0x1f')](function(_0x3dd9a5){return _0x3dd9a5;});}return null;};}function removeEntity(_0x34dba9,_0x3e4f54){return function(_0x1828c7){if(_0x1828c7){return _0x1828c7[_0x3e04('0x20')]()[_0x3e04('0x1f')](function(){_0x34dba9[_0x3e04('0x15')](0xcc)[_0x3e04('0x21')]();});}};}function handleEntityNotFound(_0x3c1c5a,_0x5cc7c7){return function(_0x299fc1){if(!_0x299fc1){_0x3c1c5a[_0x3e04('0x14')](0x194);}return _0x299fc1;};}function handleError(_0x56fce7,_0x41f44a){_0x41f44a=_0x41f44a||0x1f4;return function(_0x32654b){logger['error'](_0x32654b['stack']);if(_0x32654b[_0x3e04('0x22')]){delete _0x32654b[_0x3e04('0x22')];}_0x56fce7[_0x3e04('0x15')](_0x41f44a)[_0x3e04('0x23')](_0x32654b);};}exports[_0x3e04('0x24')]=function(_0x341442,_0x2c0515){var _0x17d216={},_0x5f317e={},_0xdc9b86={'count':0x0,'rows':[]};var _0x4c6702=_['map'](db[_0x3e04('0x25')][_0x3e04('0x26')],function(_0x493174){return{'name':_0x493174['fieldName'],'type':_0x493174['type'][_0x3e04('0x27')]};});_0x5f317e[_0x3e04('0x28')]=_['map'](_0x4c6702,_0x3e04('0x22'));_0x5f317e[_0x3e04('0x29')]=_[_0x3e04('0x2a')](_0x341442['query']);_0x5f317e[_0x3e04('0x2b')]=_['intersection'](_0x5f317e['model'],_0x5f317e[_0x3e04('0x29')]);_0x17d216[_0x3e04('0x2c')]=_[_0x3e04('0x2d')](_0x5f317e[_0x3e04('0x28')],qs[_0x3e04('0x2e')](_0x341442[_0x3e04('0x29')]['fields']));_0x17d216[_0x3e04('0x2c')]=_0x17d216[_0x3e04('0x2c')][_0x3e04('0x2f')]?_0x17d216[_0x3e04('0x2c')]:_0x5f317e[_0x3e04('0x28')];if(!_0x341442[_0x3e04('0x29')]['hasOwnProperty']('nolimit')){_0x17d216[_0x3e04('0x18')]=qs['limit'](_0x341442[_0x3e04('0x29')][_0x3e04('0x18')]);_0x17d216[_0x3e04('0x1a')]=qs[_0x3e04('0x1a')](_0x341442['query'][_0x3e04('0x1a')]);}_0x17d216[_0x3e04('0x30')]=qs[_0x3e04('0x31')](_0x341442['query'][_0x3e04('0x31')]);_0x17d216[_0x3e04('0x32')]=qs['filters'](_[_0x3e04('0x33')](_0x341442[_0x3e04('0x29')],_0x5f317e[_0x3e04('0x2b')]),_0x4c6702);if(_0x341442[_0x3e04('0x29')][_0x3e04('0x34')]){_0x17d216[_0x3e04('0x32')]=_['merge'](_0x17d216[_0x3e04('0x32')],{'$or':_[_0x3e04('0x35')](_0x4c6702,function(_0x8fb0e){if(_0x8fb0e['type']!==_0x3e04('0x36')){var _0x50dc27={};_0x50dc27[_0x8fb0e[_0x3e04('0x22')]]={'$like':'%'+_0x341442[_0x3e04('0x29')][_0x3e04('0x34')]+'%'};return _0x50dc27;}})});}_0x17d216=_['merge']({},_0x17d216,_0x341442['options']);var _0x33e7bb={'where':_0x17d216[_0x3e04('0x32')]};return db[_0x3e04('0x25')][_0x3e04('0x19')](_0x33e7bb)[_0x3e04('0x1f')](function(_0x3caafe){_0xdc9b86[_0x3e04('0x19')]=_0x3caafe;if(_0x341442[_0x3e04('0x29')][_0x3e04('0x37')]){_0x17d216[_0x3e04('0x38')]=[{'all':!![]}];}return db[_0x3e04('0x25')][_0x3e04('0x39')](_0x17d216);})[_0x3e04('0x1f')](function(_0x1f1f15){_0xdc9b86['rows']=_0x1f1f15;return _0xdc9b86;})[_0x3e04('0x1f')](respondWithFilteredResult(_0x2c0515,_0x17d216))[_0x3e04('0x3a')](handleError(_0x2c0515,null));};exports[_0x3e04('0x3b')]=function(_0x361b6a,_0x1d6f6e){var _0x25b7ba={'raw':![],'where':{'id':_0x361b6a['params']['id']}},_0x44a24f={};_0x44a24f[_0x3e04('0x28')]=_['keys'](db[_0x3e04('0x25')]['rawAttributes']);_0x44a24f[_0x3e04('0x29')]=_['keys'](_0x361b6a[_0x3e04('0x29')]);_0x44a24f[_0x3e04('0x2b')]=_['intersection'](_0x44a24f[_0x3e04('0x28')],_0x44a24f[_0x3e04('0x29')]);_0x25b7ba[_0x3e04('0x2c')]=_[_0x3e04('0x2d')](_0x44a24f[_0x3e04('0x28')],qs[_0x3e04('0x2e')](_0x361b6a[_0x3e04('0x29')][_0x3e04('0x2e')]));_0x25b7ba[_0x3e04('0x2c')]=_0x25b7ba[_0x3e04('0x2c')]['length']?_0x25b7ba[_0x3e04('0x2c')]:_0x44a24f[_0x3e04('0x28')];if(_0x361b6a['query'][_0x3e04('0x37')]){_0x25b7ba['include']=[{'all':!![]}];}_0x25b7ba=_[_0x3e04('0x3c')]({},_0x25b7ba,_0x361b6a[_0x3e04('0x3d')]);return db['FreshsalesConfiguration'][_0x3e04('0x3e')](_0x25b7ba)[_0x3e04('0x1f')](handleEntityNotFound(_0x1d6f6e,null))[_0x3e04('0x1f')](respondWithResult(_0x1d6f6e,null))[_0x3e04('0x3a')](handleError(_0x1d6f6e,null));};exports[_0x3e04('0x3f')]=function(_0x47f25e,_0x230a65){return db[_0x3e04('0x25')][_0x3e04('0x3f')](_0x47f25e[_0x3e04('0x40')],{})[_0x3e04('0x1f')](respondWithResult(_0x230a65,0xc9))[_0x3e04('0x3a')](handleError(_0x230a65,null));};exports[_0x3e04('0x41')]=function(_0x257914,_0x2e14af){if(_0x257914['body']['id']){delete _0x257914[_0x3e04('0x40')]['id'];}return db[_0x3e04('0x25')][_0x3e04('0x3e')]({'where':{'id':_0x257914[_0x3e04('0x42')]['id']}})[_0x3e04('0x1f')](handleEntityNotFound(_0x2e14af,null))[_0x3e04('0x1f')](saveUpdates(_0x257914[_0x3e04('0x40')],null))[_0x3e04('0x1f')](respondWithResult(_0x2e14af,null))[_0x3e04('0x3a')](handleError(_0x2e14af,null));};exports[_0x3e04('0x20')]=function(_0x187807,_0x49fc70){return db[_0x3e04('0x25')]['find']({'where':{'id':_0x187807[_0x3e04('0x42')]['id']}})[_0x3e04('0x1f')](handleEntityNotFound(_0x49fc70,null))[_0x3e04('0x1f')](removeEntity(_0x49fc70,null))[_0x3e04('0x3a')](handleError(_0x49fc70,null));};exports[_0x3e04('0x43')]=function(_0x1df937,_0xa60287,_0x436e8d){var _0x4cf5d8={};var _0x45636e={};var _0x11a581;var _0x37be2f;return db[_0x3e04('0x25')][_0x3e04('0x44')]({'where':{'id':_0x1df937[_0x3e04('0x42')]['id']}})[_0x3e04('0x1f')](handleEntityNotFound(_0xa60287,null))[_0x3e04('0x1f')](function(_0x1d37e9){if(_0x1d37e9){_0x11a581=_0x1d37e9;_0x45636e[_0x3e04('0x28')]=_[_0x3e04('0x2a')](db[_0x3e04('0x45')][_0x3e04('0x26')]);_0x45636e['query']=_['keys'](_0x1df937['query']);_0x45636e[_0x3e04('0x2b')]=_[_0x3e04('0x2d')](_0x45636e[_0x3e04('0x28')],_0x45636e[_0x3e04('0x29')]);_0x4cf5d8[_0x3e04('0x2c')]=_['intersection'](_0x45636e[_0x3e04('0x28')],qs[_0x3e04('0x2e')](_0x1df937[_0x3e04('0x29')]['fields']));_0x4cf5d8[_0x3e04('0x2c')]=_0x4cf5d8[_0x3e04('0x2c')][_0x3e04('0x2f')]?_0x4cf5d8[_0x3e04('0x2c')]:_0x45636e[_0x3e04('0x28')];_0x4cf5d8[_0x3e04('0x30')]=qs[_0x3e04('0x31')](_0x1df937[_0x3e04('0x29')][_0x3e04('0x31')]);_0x4cf5d8[_0x3e04('0x32')]=qs[_0x3e04('0x2b')](_['pick'](_0x1df937[_0x3e04('0x29')],_0x45636e[_0x3e04('0x2b')]));if(_0x1df937[_0x3e04('0x29')][_0x3e04('0x34')]){_0x4cf5d8[_0x3e04('0x32')]=_[_0x3e04('0x3c')](_0x4cf5d8[_0x3e04('0x32')],{'$or':_[_0x3e04('0x35')](_0x4cf5d8[_0x3e04('0x2c')],function(_0x4e9653){var _0x33414a={};_0x33414a[_0x4e9653]={'$like':'%'+_0x1df937[_0x3e04('0x29')][_0x3e04('0x34')]+'%'};return _0x33414a;})});}_0x4cf5d8=_[_0x3e04('0x3c')]({},_0x4cf5d8,_0x1df937['options']);return _0x11a581['getSubjects'](_0x4cf5d8);}})[_0x3e04('0x1f')](function(_0x3d7b5e){if(_0x3d7b5e){_0x37be2f=_0x3d7b5e['length'];if(!_0x1df937[_0x3e04('0x29')]['hasOwnProperty'](_0x3e04('0x46'))){_0x4cf5d8[_0x3e04('0x18')]=qs['limit'](_0x1df937[_0x3e04('0x29')][_0x3e04('0x18')]);_0x4cf5d8[_0x3e04('0x1a')]=qs[_0x3e04('0x1a')](_0x1df937[_0x3e04('0x29')][_0x3e04('0x1a')]);}return _0x11a581[_0x3e04('0x43')](_0x4cf5d8);}})[_0x3e04('0x1f')](function(_0xb2ae11){if(_0xb2ae11){return _0xb2ae11?{'count':_0x37be2f,'rows':_0xb2ae11}:null;}})[_0x3e04('0x1f')](respondWithResult(_0xa60287,null))['catch'](handleError(_0xa60287,null));};exports['getDescriptions']=function(_0x13e59d,_0x428596,_0x42fd81){var _0x1806fa={};var _0x3b4a61={};var _0x41e7d1;var _0x166f5e;return db[_0x3e04('0x25')][_0x3e04('0x44')]({'where':{'id':_0x13e59d['params']['id']}})[_0x3e04('0x1f')](handleEntityNotFound(_0x428596,null))[_0x3e04('0x1f')](function(_0x433d7c){if(_0x433d7c){_0x41e7d1=_0x433d7c;_0x3b4a61[_0x3e04('0x28')]=_[_0x3e04('0x2a')](db[_0x3e04('0x45')][_0x3e04('0x26')]);_0x3b4a61['query']=_[_0x3e04('0x2a')](_0x13e59d[_0x3e04('0x29')]);_0x3b4a61['filters']=_['intersection'](_0x3b4a61[_0x3e04('0x28')],_0x3b4a61[_0x3e04('0x29')]);_0x1806fa[_0x3e04('0x2c')]=_[_0x3e04('0x2d')](_0x3b4a61[_0x3e04('0x28')],qs['fields'](_0x13e59d[_0x3e04('0x29')][_0x3e04('0x2e')]));_0x1806fa[_0x3e04('0x2c')]=_0x1806fa[_0x3e04('0x2c')][_0x3e04('0x2f')]?_0x1806fa['attributes']:_0x3b4a61[_0x3e04('0x28')];_0x1806fa['order']=qs[_0x3e04('0x31')](_0x13e59d[_0x3e04('0x29')][_0x3e04('0x31')]);_0x1806fa[_0x3e04('0x32')]=qs['filters'](_[_0x3e04('0x33')](_0x13e59d[_0x3e04('0x29')],_0x3b4a61[_0x3e04('0x2b')]));if(_0x13e59d[_0x3e04('0x29')]['filter']){_0x1806fa[_0x3e04('0x32')]=_[_0x3e04('0x3c')](_0x1806fa[_0x3e04('0x32')],{'$or':_[_0x3e04('0x35')](_0x1806fa[_0x3e04('0x2c')],function(_0x3051e6){var _0x5710e7={};_0x5710e7[_0x3051e6]={'$like':'%'+_0x13e59d[_0x3e04('0x29')][_0x3e04('0x34')]+'%'};return _0x5710e7;})});}_0x1806fa=_[_0x3e04('0x3c')]({},_0x1806fa,_0x13e59d['options']);return _0x41e7d1[_0x3e04('0x47')](_0x1806fa);}})[_0x3e04('0x1f')](function(_0x41e229){if(_0x41e229){_0x166f5e=_0x41e229[_0x3e04('0x2f')];if(!_0x13e59d[_0x3e04('0x29')][_0x3e04('0x48')](_0x3e04('0x46'))){_0x1806fa['limit']=qs['limit'](_0x13e59d['query'][_0x3e04('0x18')]);_0x1806fa[_0x3e04('0x1a')]=qs[_0x3e04('0x1a')](_0x13e59d[_0x3e04('0x29')][_0x3e04('0x1a')]);}return _0x41e7d1[_0x3e04('0x47')](_0x1806fa);}})[_0x3e04('0x1f')](function(_0x25ee1d){if(_0x25ee1d){return _0x25ee1d?{'count':_0x166f5e,'rows':_0x25ee1d}:null;}})['then'](respondWithResult(_0x428596,null))[_0x3e04('0x3a')](handleError(_0x428596,null));};exports[_0x3e04('0x49')]=function(_0x1976c3,_0x7ab46c,_0x42a363){var _0x21738b={};var _0x2180b5={};var _0x127574;var _0x1459bb;return db['FreshsalesConfiguration'][_0x3e04('0x44')]({'where':{'id':_0x1976c3[_0x3e04('0x42')]['id']}})[_0x3e04('0x1f')](handleEntityNotFound(_0x7ab46c,null))[_0x3e04('0x1f')](function(_0x1657df){if(_0x1657df){_0x127574=_0x1657df;_0x2180b5[_0x3e04('0x28')]=_['keys'](db[_0x3e04('0x45')][_0x3e04('0x26')]);_0x2180b5[_0x3e04('0x29')]=_[_0x3e04('0x2a')](_0x1976c3[_0x3e04('0x29')]);_0x2180b5[_0x3e04('0x2b')]=_[_0x3e04('0x2d')](_0x2180b5[_0x3e04('0x28')],_0x2180b5[_0x3e04('0x29')]);_0x21738b[_0x3e04('0x2c')]=_['intersection'](_0x2180b5[_0x3e04('0x28')],qs[_0x3e04('0x2e')](_0x1976c3[_0x3e04('0x29')]['fields']));_0x21738b[_0x3e04('0x2c')]=_0x21738b[_0x3e04('0x2c')][_0x3e04('0x2f')]?_0x21738b['attributes']:_0x2180b5[_0x3e04('0x28')];_0x21738b[_0x3e04('0x30')]=qs[_0x3e04('0x31')](_0x1976c3[_0x3e04('0x29')]['sort']);_0x21738b[_0x3e04('0x32')]=qs[_0x3e04('0x2b')](_[_0x3e04('0x33')](_0x1976c3[_0x3e04('0x29')],_0x2180b5[_0x3e04('0x2b')]));if(_0x1976c3['query']['filter']){_0x21738b[_0x3e04('0x32')]=_['merge'](_0x21738b[_0x3e04('0x32')],{'$or':_['map'](_0x21738b[_0x3e04('0x2c')],function(_0x35f62f){var _0x8603={};_0x8603[_0x35f62f]={'$like':'%'+_0x1976c3[_0x3e04('0x29')][_0x3e04('0x34')]+'%'};return _0x8603;})});}_0x21738b=_[_0x3e04('0x3c')]({},_0x21738b,_0x1976c3[_0x3e04('0x3d')]);return _0x127574[_0x3e04('0x49')](_0x21738b);}})[_0x3e04('0x1f')](function(_0x1b0ce5){if(_0x1b0ce5){_0x1459bb=_0x1b0ce5[_0x3e04('0x2f')];if(!_0x1976c3[_0x3e04('0x29')][_0x3e04('0x48')]('nolimit')){_0x21738b[_0x3e04('0x18')]=qs[_0x3e04('0x18')](_0x1976c3['query'][_0x3e04('0x18')]);_0x21738b['offset']=qs[_0x3e04('0x1a')](_0x1976c3[_0x3e04('0x29')][_0x3e04('0x1a')]);}return _0x127574[_0x3e04('0x49')](_0x21738b);}})['then'](function(_0x164f92){if(_0x164f92){return _0x164f92?{'count':_0x1459bb,'rows':_0x164f92}:null;}})[_0x3e04('0x1f')](respondWithResult(_0x7ab46c,null))[_0x3e04('0x3a')](handleError(_0x7ab46c,null));};
\ No newline at end of file