Built motion from commit ffdca78c.|2.6.24
[motion2.git] / server / api / intFreshsalesConfiguration / intFreshsalesConfiguration.controller.js
index 7f36ae3..6d0cbd0 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x8506=['../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','sendStatus','status','end','offset','limit','undefined','count','Content-Range','json','reject','save','update','then','destroy','error','name','send','FreshsalesConfiguration','rawAttributes','fieldName','type','key','model','map','query','filters','attributes','fields','hasOwnProperty','nolimit','order','sort','where','VIRTUAL','filter','merge','includeAll','findAll','rows','catch','show','params','keys','intersection','include','options','find','create','body','getSubjects','findOne','FreshsalesField','length','pick','getDescriptions','getFields','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','util','path','to-csv','fs-extra','lodash','squel','crypto','jsforce','desk.js','querystring'];(function(_0x3bee27,_0x211a75){var _0x500445=function(_0x2f30a2){while(--_0x2f30a2){_0x3bee27['push'](_0x3bee27['shift']());}};_0x500445(++_0x211a75);}(_0x8506,0x1d5));var _0x6850=function(_0x572e28,_0x3f014f){_0x572e28=_0x572e28-0x0;var _0x789853=_0x8506[_0x572e28];return _0x789853;};'use strict';var emlformat=require(_0x6850('0x0'));var rimraf=require(_0x6850('0x1'));var zipdir=require(_0x6850('0x2'));var jsonpatch=require(_0x6850('0x3'));var rp=require(_0x6850('0x4'));var moment=require(_0x6850('0x5'));var BPromise=require(_0x6850('0x6'));var Mustache=require('mustache');var util=require(_0x6850('0x7'));var path=require(_0x6850('0x8'));var sox=require('sox');var csv=require(_0x6850('0x9'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0x6850('0xa'));var _=require(_0x6850('0xb'));var squel=require(_0x6850('0xc'));var crypto=require(_0x6850('0xd'));var jsforce=require(_0x6850('0xe'));var deskjs=require(_0x6850('0xf'));var toCsv=require(_0x6850('0x9'));var querystring=require(_0x6850('0x10'));var Papa=require('papaparse');var Redis=require('ioredis');var authService=require('../../components/auth/service');var qs=require('../../components/parsers/qs');var as=require(_0x6850('0x11'));var hardwareService=require(_0x6850('0x12'));var logger=require(_0x6850('0x13'))(_0x6850('0x14'));var utils=require(_0x6850('0x15'));var config=require(_0x6850('0x16'));var licenseUtil=require(_0x6850('0x17'));var db=require(_0x6850('0x18'))['db'];function respondWithStatusCode(_0x2a3727,_0x52f5d1){_0x52f5d1=_0x52f5d1||0xcc;return function(_0x17afeb){if(_0x17afeb){return _0x2a3727[_0x6850('0x19')](_0x52f5d1);}return _0x2a3727[_0x6850('0x1a')](_0x52f5d1)[_0x6850('0x1b')]();};}function respondWithResult(_0x36abfd,_0x844aa9){_0x844aa9=_0x844aa9||0xc8;return function(_0x196d5c){if(_0x196d5c){return _0x36abfd[_0x6850('0x1a')](_0x844aa9)['json'](_0x196d5c);}};}function respondWithFilteredResult(_0x11abb0,_0x597650){return function(_0xd24659){if(_0xd24659){var _0x5e03c2=typeof _0x597650[_0x6850('0x1c')]==='undefined'&&typeof _0x597650[_0x6850('0x1d')]===_0x6850('0x1e');var _0x2fda8f=_0xd24659[_0x6850('0x1f')];var _0x38b489=_0x5e03c2?0x0:_0x597650[_0x6850('0x1c')];var _0x58a36d=_0x5e03c2?_0xd24659[_0x6850('0x1f')]:_0x597650[_0x6850('0x1c')]+_0x597650['limit'];var _0x46c39b;if(_0x58a36d>=_0x2fda8f){_0x58a36d=_0x2fda8f;_0x46c39b=0xc8;}else{_0x46c39b=0xce;}_0x11abb0[_0x6850('0x1a')](_0x46c39b);return _0x11abb0['set'](_0x6850('0x20'),_0x38b489+'-'+_0x58a36d+'/'+_0x2fda8f)[_0x6850('0x21')](_0xd24659);}return null;};}function patchUpdates(_0x24e5c6){return function(_0x5eb4ea){try{jsonpatch['apply'](_0x5eb4ea,_0x24e5c6,!![]);}catch(_0x5d08be){return BPromise[_0x6850('0x22')](_0x5d08be);}return _0x5eb4ea[_0x6850('0x23')]();};}function saveUpdates(_0x24f151,_0x2ef188){return function(_0x28c3b5){if(_0x28c3b5){return _0x28c3b5[_0x6850('0x24')](_0x24f151)[_0x6850('0x25')](function(_0x48caee){return _0x48caee;});}return null;};}function removeEntity(_0x1bc538,_0x266910){return function(_0x4ce190){if(_0x4ce190){return _0x4ce190[_0x6850('0x26')]()[_0x6850('0x25')](function(){_0x1bc538[_0x6850('0x1a')](0xcc)[_0x6850('0x1b')]();});}};}function handleEntityNotFound(_0x25dea0,_0x3b1cd9){return function(_0x2764f9){if(!_0x2764f9){_0x25dea0[_0x6850('0x19')](0x194);}return _0x2764f9;};}function handleError(_0x1bfd6b,_0x44b6f1){_0x44b6f1=_0x44b6f1||0x1f4;return function(_0x36e44a){logger[_0x6850('0x27')](_0x36e44a['stack']);if(_0x36e44a[_0x6850('0x28')]){delete _0x36e44a[_0x6850('0x28')];}_0x1bfd6b[_0x6850('0x1a')](_0x44b6f1)[_0x6850('0x29')](_0x36e44a);};}exports['index']=function(_0x3a48df,_0x3a413b){var _0x26e604={},_0x422f07={},_0x42e758={'count':0x0,'rows':[]};var _0xb6020d=_['map'](db[_0x6850('0x2a')][_0x6850('0x2b')],function(_0x44e1f2){return{'name':_0x44e1f2[_0x6850('0x2c')],'type':_0x44e1f2[_0x6850('0x2d')][_0x6850('0x2e')]};});_0x422f07[_0x6850('0x2f')]=_[_0x6850('0x30')](_0xb6020d,_0x6850('0x28'));_0x422f07[_0x6850('0x31')]=_['keys'](_0x3a48df[_0x6850('0x31')]);_0x422f07[_0x6850('0x32')]=_['intersection'](_0x422f07[_0x6850('0x2f')],_0x422f07[_0x6850('0x31')]);_0x26e604[_0x6850('0x33')]=_['intersection'](_0x422f07[_0x6850('0x2f')],qs[_0x6850('0x34')](_0x3a48df[_0x6850('0x31')][_0x6850('0x34')]));_0x26e604[_0x6850('0x33')]=_0x26e604[_0x6850('0x33')]['length']?_0x26e604[_0x6850('0x33')]:_0x422f07[_0x6850('0x2f')];if(!_0x3a48df[_0x6850('0x31')][_0x6850('0x35')](_0x6850('0x36'))){_0x26e604[_0x6850('0x1d')]=qs[_0x6850('0x1d')](_0x3a48df[_0x6850('0x31')]['limit']);_0x26e604[_0x6850('0x1c')]=qs[_0x6850('0x1c')](_0x3a48df[_0x6850('0x31')][_0x6850('0x1c')]);}_0x26e604[_0x6850('0x37')]=qs[_0x6850('0x38')](_0x3a48df[_0x6850('0x31')][_0x6850('0x38')]);_0x26e604[_0x6850('0x39')]=qs['filters'](_['pick'](_0x3a48df[_0x6850('0x31')],_0x422f07[_0x6850('0x32')]),_0xb6020d);if(_0x3a48df[_0x6850('0x31')]['filter']){_0x26e604['where']=_['merge'](_0x26e604[_0x6850('0x39')],{'$or':_[_0x6850('0x30')](_0xb6020d,function(_0x5a8ce5){if(_0x5a8ce5['type']!==_0x6850('0x3a')){var _0x4741f6={};_0x4741f6[_0x5a8ce5[_0x6850('0x28')]]={'$like':'%'+_0x3a48df[_0x6850('0x31')][_0x6850('0x3b')]+'%'};return _0x4741f6;}})});}_0x26e604=_[_0x6850('0x3c')]({},_0x26e604,_0x3a48df['options']);var _0xf59ee6={'where':_0x26e604['where']};return db[_0x6850('0x2a')][_0x6850('0x1f')](_0xf59ee6)[_0x6850('0x25')](function(_0xbbd0ec){_0x42e758['count']=_0xbbd0ec;if(_0x3a48df[_0x6850('0x31')][_0x6850('0x3d')]){_0x26e604['include']=[{'all':!![]}];}return db[_0x6850('0x2a')][_0x6850('0x3e')](_0x26e604);})[_0x6850('0x25')](function(_0x572eff){_0x42e758[_0x6850('0x3f')]=_0x572eff;return _0x42e758;})[_0x6850('0x25')](respondWithFilteredResult(_0x3a413b,_0x26e604))[_0x6850('0x40')](handleError(_0x3a413b,null));};exports[_0x6850('0x41')]=function(_0x383d32,_0x1efa3f){var _0xf49fb9={'raw':![],'where':{'id':_0x383d32[_0x6850('0x42')]['id']}},_0x4660ba={};_0x4660ba[_0x6850('0x2f')]=_[_0x6850('0x43')](db[_0x6850('0x2a')][_0x6850('0x2b')]);_0x4660ba['query']=_['keys'](_0x383d32[_0x6850('0x31')]);_0x4660ba['filters']=_[_0x6850('0x44')](_0x4660ba[_0x6850('0x2f')],_0x4660ba['query']);_0xf49fb9[_0x6850('0x33')]=_[_0x6850('0x44')](_0x4660ba[_0x6850('0x2f')],qs[_0x6850('0x34')](_0x383d32[_0x6850('0x31')][_0x6850('0x34')]));_0xf49fb9[_0x6850('0x33')]=_0xf49fb9[_0x6850('0x33')]['length']?_0xf49fb9[_0x6850('0x33')]:_0x4660ba[_0x6850('0x2f')];if(_0x383d32[_0x6850('0x31')][_0x6850('0x3d')]){_0xf49fb9[_0x6850('0x45')]=[{'all':!![]}];}_0xf49fb9=_[_0x6850('0x3c')]({},_0xf49fb9,_0x383d32[_0x6850('0x46')]);return db['FreshsalesConfiguration'][_0x6850('0x47')](_0xf49fb9)[_0x6850('0x25')](handleEntityNotFound(_0x1efa3f,null))[_0x6850('0x25')](respondWithResult(_0x1efa3f,null))['catch'](handleError(_0x1efa3f,null));};exports[_0x6850('0x48')]=function(_0x5f3b9c,_0x3b3c28){return db[_0x6850('0x2a')][_0x6850('0x48')](_0x5f3b9c[_0x6850('0x49')],{})[_0x6850('0x25')](respondWithResult(_0x3b3c28,0xc9))[_0x6850('0x40')](handleError(_0x3b3c28,null));};exports[_0x6850('0x24')]=function(_0x4eb9e3,_0x302ba3){if(_0x4eb9e3[_0x6850('0x49')]['id']){delete _0x4eb9e3[_0x6850('0x49')]['id'];}return db[_0x6850('0x2a')][_0x6850('0x47')]({'where':{'id':_0x4eb9e3[_0x6850('0x42')]['id']}})['then'](handleEntityNotFound(_0x302ba3,null))[_0x6850('0x25')](saveUpdates(_0x4eb9e3[_0x6850('0x49')],null))[_0x6850('0x25')](respondWithResult(_0x302ba3,null))[_0x6850('0x40')](handleError(_0x302ba3,null));};exports['destroy']=function(_0x15f4a4,_0x40d0e9){return db[_0x6850('0x2a')][_0x6850('0x47')]({'where':{'id':_0x15f4a4['params']['id']}})['then'](handleEntityNotFound(_0x40d0e9,null))['then'](removeEntity(_0x40d0e9,null))[_0x6850('0x40')](handleError(_0x40d0e9,null));};exports[_0x6850('0x4a')]=function(_0x551c55,_0x57a948,_0x225a72){var _0x5175b2={};var _0x2e7713={};var _0x2a7575;var _0x5e1dcd;return db[_0x6850('0x2a')][_0x6850('0x4b')]({'where':{'id':_0x551c55[_0x6850('0x42')]['id']}})[_0x6850('0x25')](handleEntityNotFound(_0x57a948,null))[_0x6850('0x25')](function(_0x5aa8e6){if(_0x5aa8e6){_0x2a7575=_0x5aa8e6;_0x2e7713[_0x6850('0x2f')]=_[_0x6850('0x43')](db[_0x6850('0x4c')][_0x6850('0x2b')]);_0x2e7713[_0x6850('0x31')]=_['keys'](_0x551c55['query']);_0x2e7713['filters']=_[_0x6850('0x44')](_0x2e7713['model'],_0x2e7713[_0x6850('0x31')]);_0x5175b2[_0x6850('0x33')]=_[_0x6850('0x44')](_0x2e7713[_0x6850('0x2f')],qs[_0x6850('0x34')](_0x551c55[_0x6850('0x31')]['fields']));_0x5175b2[_0x6850('0x33')]=_0x5175b2[_0x6850('0x33')][_0x6850('0x4d')]?_0x5175b2['attributes']:_0x2e7713[_0x6850('0x2f')];_0x5175b2[_0x6850('0x37')]=qs[_0x6850('0x38')](_0x551c55[_0x6850('0x31')]['sort']);_0x5175b2[_0x6850('0x39')]=qs['filters'](_[_0x6850('0x4e')](_0x551c55[_0x6850('0x31')],_0x2e7713[_0x6850('0x32')]));if(_0x551c55[_0x6850('0x31')]['filter']){_0x5175b2['where']=_[_0x6850('0x3c')](_0x5175b2[_0x6850('0x39')],{'$or':_['map'](_0x5175b2[_0x6850('0x33')],function(_0x14ae4d){var _0x56cddc={};_0x56cddc[_0x14ae4d]={'$like':'%'+_0x551c55[_0x6850('0x31')][_0x6850('0x3b')]+'%'};return _0x56cddc;})});}_0x5175b2=_[_0x6850('0x3c')]({},_0x5175b2,_0x551c55['options']);return _0x2a7575[_0x6850('0x4a')](_0x5175b2);}})['then'](function(_0xcc26d9){if(_0xcc26d9){_0x5e1dcd=_0xcc26d9[_0x6850('0x4d')];if(!_0x551c55['query'][_0x6850('0x35')](_0x6850('0x36'))){_0x5175b2['limit']=qs['limit'](_0x551c55['query'][_0x6850('0x1d')]);_0x5175b2[_0x6850('0x1c')]=qs[_0x6850('0x1c')](_0x551c55[_0x6850('0x31')]['offset']);}return _0x2a7575[_0x6850('0x4a')](_0x5175b2);}})[_0x6850('0x25')](function(_0x5210aa){if(_0x5210aa){return _0x5210aa?{'count':_0x5e1dcd,'rows':_0x5210aa}:null;}})[_0x6850('0x25')](respondWithResult(_0x57a948,null))['catch'](handleError(_0x57a948,null));};exports[_0x6850('0x4f')]=function(_0x5bdd05,_0x3a779e,_0x118f08){var _0x508129={};var _0x18dd94={};var _0x2635e0;var _0x18211a;return db[_0x6850('0x2a')]['findOne']({'where':{'id':_0x5bdd05[_0x6850('0x42')]['id']}})['then'](handleEntityNotFound(_0x3a779e,null))[_0x6850('0x25')](function(_0xbe67ff){if(_0xbe67ff){_0x2635e0=_0xbe67ff;_0x18dd94[_0x6850('0x2f')]=_[_0x6850('0x43')](db['FreshsalesField'][_0x6850('0x2b')]);_0x18dd94['query']=_['keys'](_0x5bdd05[_0x6850('0x31')]);_0x18dd94['filters']=_['intersection'](_0x18dd94['model'],_0x18dd94[_0x6850('0x31')]);_0x508129[_0x6850('0x33')]=_[_0x6850('0x44')](_0x18dd94['model'],qs[_0x6850('0x34')](_0x5bdd05[_0x6850('0x31')][_0x6850('0x34')]));_0x508129['attributes']=_0x508129[_0x6850('0x33')][_0x6850('0x4d')]?_0x508129[_0x6850('0x33')]:_0x18dd94['model'];_0x508129[_0x6850('0x37')]=qs[_0x6850('0x38')](_0x5bdd05[_0x6850('0x31')]['sort']);_0x508129[_0x6850('0x39')]=qs[_0x6850('0x32')](_[_0x6850('0x4e')](_0x5bdd05[_0x6850('0x31')],_0x18dd94[_0x6850('0x32')]));if(_0x5bdd05[_0x6850('0x31')][_0x6850('0x3b')]){_0x508129[_0x6850('0x39')]=_['merge'](_0x508129['where'],{'$or':_[_0x6850('0x30')](_0x508129['attributes'],function(_0x482cc1){var _0xaeb96d={};_0xaeb96d[_0x482cc1]={'$like':'%'+_0x5bdd05[_0x6850('0x31')][_0x6850('0x3b')]+'%'};return _0xaeb96d;})});}_0x508129=_[_0x6850('0x3c')]({},_0x508129,_0x5bdd05[_0x6850('0x46')]);return _0x2635e0['getDescriptions'](_0x508129);}})[_0x6850('0x25')](function(_0x1c7702){if(_0x1c7702){_0x18211a=_0x1c7702['length'];if(!_0x5bdd05[_0x6850('0x31')][_0x6850('0x35')]('nolimit')){_0x508129[_0x6850('0x1d')]=qs[_0x6850('0x1d')](_0x5bdd05[_0x6850('0x31')][_0x6850('0x1d')]);_0x508129[_0x6850('0x1c')]=qs[_0x6850('0x1c')](_0x5bdd05[_0x6850('0x31')][_0x6850('0x1c')]);}return _0x2635e0[_0x6850('0x4f')](_0x508129);}})[_0x6850('0x25')](function(_0x28e41a){if(_0x28e41a){return _0x28e41a?{'count':_0x18211a,'rows':_0x28e41a}:null;}})['then'](respondWithResult(_0x3a779e,null))[_0x6850('0x40')](handleError(_0x3a779e,null));};exports[_0x6850('0x50')]=function(_0xc5de45,_0x30f75a,_0x40080d){var _0x2b9269={};var _0x4f37a1={};var _0x38ebef;var _0x3fe6e4;return db[_0x6850('0x2a')][_0x6850('0x4b')]({'where':{'id':_0xc5de45[_0x6850('0x42')]['id']}})[_0x6850('0x25')](handleEntityNotFound(_0x30f75a,null))[_0x6850('0x25')](function(_0x5b6ffb){if(_0x5b6ffb){_0x38ebef=_0x5b6ffb;_0x4f37a1[_0x6850('0x2f')]=_[_0x6850('0x43')](db[_0x6850('0x4c')][_0x6850('0x2b')]);_0x4f37a1[_0x6850('0x31')]=_[_0x6850('0x43')](_0xc5de45['query']);_0x4f37a1[_0x6850('0x32')]=_[_0x6850('0x44')](_0x4f37a1[_0x6850('0x2f')],_0x4f37a1['query']);_0x2b9269[_0x6850('0x33')]=_[_0x6850('0x44')](_0x4f37a1[_0x6850('0x2f')],qs['fields'](_0xc5de45[_0x6850('0x31')][_0x6850('0x34')]));_0x2b9269[_0x6850('0x33')]=_0x2b9269[_0x6850('0x33')][_0x6850('0x4d')]?_0x2b9269[_0x6850('0x33')]:_0x4f37a1[_0x6850('0x2f')];_0x2b9269['order']=qs[_0x6850('0x38')](_0xc5de45['query'][_0x6850('0x38')]);_0x2b9269[_0x6850('0x39')]=qs['filters'](_[_0x6850('0x4e')](_0xc5de45['query'],_0x4f37a1[_0x6850('0x32')]));if(_0xc5de45[_0x6850('0x31')][_0x6850('0x3b')]){_0x2b9269[_0x6850('0x39')]=_['merge'](_0x2b9269[_0x6850('0x39')],{'$or':_[_0x6850('0x30')](_0x2b9269['attributes'],function(_0x1b11e2){var _0x29b3ef={};_0x29b3ef[_0x1b11e2]={'$like':'%'+_0xc5de45[_0x6850('0x31')][_0x6850('0x3b')]+'%'};return _0x29b3ef;})});}_0x2b9269=_[_0x6850('0x3c')]({},_0x2b9269,_0xc5de45[_0x6850('0x46')]);return _0x38ebef[_0x6850('0x50')](_0x2b9269);}})[_0x6850('0x25')](function(_0x3cdc60){if(_0x3cdc60){_0x3fe6e4=_0x3cdc60['length'];if(!_0xc5de45[_0x6850('0x31')][_0x6850('0x35')](_0x6850('0x36'))){_0x2b9269[_0x6850('0x1d')]=qs[_0x6850('0x1d')](_0xc5de45[_0x6850('0x31')][_0x6850('0x1d')]);_0x2b9269[_0x6850('0x1c')]=qs['offset'](_0xc5de45[_0x6850('0x31')]['offset']);}return _0x38ebef[_0x6850('0x50')](_0x2b9269);}})[_0x6850('0x25')](function(_0x22283c){if(_0x22283c){return _0x22283c?{'count':_0x3fe6e4,'rows':_0x22283c}:null;}})[_0x6850('0x25')](respondWithResult(_0x30f75a,null))[_0x6850('0x40')](handleError(_0x30f75a,null));};
\ No newline at end of file
+var _0x8cfa=['eml-format','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','path','sox','to-csv','lodash','squel','crypto','jsforce','querystring','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../mysqldb','sendStatus','status','end','json','offset','undefined','limit','count','Content-Range','apply','reject','save','update','then','error','stack','name','send','index','FreshsalesConfiguration','rawAttributes','fieldName','key','query','keys','filters','intersection','model','attributes','fields','hasOwnProperty','nolimit','order','sort','pick','merge','where','map','type','VIRTUAL','filter','options','includeAll','include','rows','catch','show','params','create','body','find','getSubjects','findOne','FreshsalesField','length','getDescriptions','getFields'];(function(_0xb8493a,_0x5a7636){var _0x1be485=function(_0x37df3b){while(--_0x37df3b){_0xb8493a['push'](_0xb8493a['shift']());}};_0x1be485(++_0x5a7636);}(_0x8cfa,0x1ec));var _0xa8cf=function(_0x5bec6f,_0x26e692){_0x5bec6f=_0x5bec6f-0x0;var _0x35b36d=_0x8cfa[_0x5bec6f];return _0x35b36d;};'use strict';var emlformat=require(_0xa8cf('0x0'));var rimraf=require('rimraf');var zipdir=require(_0xa8cf('0x1'));var jsonpatch=require(_0xa8cf('0x2'));var rp=require(_0xa8cf('0x3'));var moment=require(_0xa8cf('0x4'));var BPromise=require(_0xa8cf('0x5'));var Mustache=require(_0xa8cf('0x6'));var util=require('util');var path=require(_0xa8cf('0x7'));var sox=require(_0xa8cf('0x8'));var csv=require(_0xa8cf('0x9'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0xa8cf('0xa'));var squel=require(_0xa8cf('0xb'));var crypto=require(_0xa8cf('0xc'));var jsforce=require(_0xa8cf('0xd'));var deskjs=require('desk.js');var toCsv=require(_0xa8cf('0x9'));var querystring=require(_0xa8cf('0xe'));var Papa=require('papaparse');var Redis=require(_0xa8cf('0xf'));var authService=require(_0xa8cf('0x10'));var qs=require(_0xa8cf('0x11'));var as=require(_0xa8cf('0x12'));var hardwareService=require(_0xa8cf('0x13'));var logger=require(_0xa8cf('0x14'))(_0xa8cf('0x15'));var utils=require(_0xa8cf('0x16'));var config=require(_0xa8cf('0x17'));var licenseUtil=require('../../config/license/util');var db=require(_0xa8cf('0x18'))['db'];function respondWithStatusCode(_0x1f2c50,_0x1cda72){_0x1cda72=_0x1cda72||0xcc;return function(_0x3364d8){if(_0x3364d8){return _0x1f2c50[_0xa8cf('0x19')](_0x1cda72);}return _0x1f2c50[_0xa8cf('0x1a')](_0x1cda72)[_0xa8cf('0x1b')]();};}function respondWithResult(_0x1e8c6f,_0x4e9647){_0x4e9647=_0x4e9647||0xc8;return function(_0x1a9b12){if(_0x1a9b12){return _0x1e8c6f[_0xa8cf('0x1a')](_0x4e9647)[_0xa8cf('0x1c')](_0x1a9b12);}};}function respondWithFilteredResult(_0x321c48,_0x3cddec){return function(_0x273a67){if(_0x273a67){var _0xa1328a=typeof _0x3cddec[_0xa8cf('0x1d')]===_0xa8cf('0x1e')&&typeof _0x3cddec[_0xa8cf('0x1f')]===_0xa8cf('0x1e');var _0x465c97=_0x273a67[_0xa8cf('0x20')];var _0x3f6e7f=_0xa1328a?0x0:_0x3cddec[_0xa8cf('0x1d')];var _0x4647cd=_0xa1328a?_0x273a67['count']:_0x3cddec[_0xa8cf('0x1d')]+_0x3cddec[_0xa8cf('0x1f')];var _0x3ea358;if(_0x4647cd>=_0x465c97){_0x4647cd=_0x465c97;_0x3ea358=0xc8;}else{_0x3ea358=0xce;}_0x321c48[_0xa8cf('0x1a')](_0x3ea358);return _0x321c48['set'](_0xa8cf('0x21'),_0x3f6e7f+'-'+_0x4647cd+'/'+_0x465c97)['json'](_0x273a67);}return null;};}function patchUpdates(_0x21ed08){return function(_0x363c15){try{jsonpatch[_0xa8cf('0x22')](_0x363c15,_0x21ed08,!![]);}catch(_0x1abbb4){return BPromise[_0xa8cf('0x23')](_0x1abbb4);}return _0x363c15[_0xa8cf('0x24')]();};}function saveUpdates(_0x424985,_0x4297a4){return function(_0x29ed49){if(_0x29ed49){return _0x29ed49[_0xa8cf('0x25')](_0x424985)['then'](function(_0x59e106){return _0x59e106;});}return null;};}function removeEntity(_0x12e242,_0x1b24d5){return function(_0xff7389){if(_0xff7389){return _0xff7389['destroy']()[_0xa8cf('0x26')](function(){_0x12e242[_0xa8cf('0x1a')](0xcc)[_0xa8cf('0x1b')]();});}};}function handleEntityNotFound(_0x3a1e03,_0x5219ec){return function(_0x385ee0){if(!_0x385ee0){_0x3a1e03[_0xa8cf('0x19')](0x194);}return _0x385ee0;};}function handleError(_0x4ae74b,_0x45d1fb){_0x45d1fb=_0x45d1fb||0x1f4;return function(_0xfbfdff){logger[_0xa8cf('0x27')](_0xfbfdff[_0xa8cf('0x28')]);if(_0xfbfdff[_0xa8cf('0x29')]){delete _0xfbfdff[_0xa8cf('0x29')];}_0x4ae74b['status'](_0x45d1fb)[_0xa8cf('0x2a')](_0xfbfdff);};}exports[_0xa8cf('0x2b')]=function(_0x237338,_0x4fcc9e){var _0x5a743c={},_0x312a36={},_0x58a08f={'count':0x0,'rows':[]};var _0x10625b=_['map'](db[_0xa8cf('0x2c')][_0xa8cf('0x2d')],function(_0x42f181){return{'name':_0x42f181[_0xa8cf('0x2e')],'type':_0x42f181['type'][_0xa8cf('0x2f')]};});_0x312a36['model']=_['map'](_0x10625b,_0xa8cf('0x29'));_0x312a36[_0xa8cf('0x30')]=_[_0xa8cf('0x31')](_0x237338[_0xa8cf('0x30')]);_0x312a36[_0xa8cf('0x32')]=_[_0xa8cf('0x33')](_0x312a36[_0xa8cf('0x34')],_0x312a36['query']);_0x5a743c[_0xa8cf('0x35')]=_[_0xa8cf('0x33')](_0x312a36['model'],qs['fields'](_0x237338['query'][_0xa8cf('0x36')]));_0x5a743c[_0xa8cf('0x35')]=_0x5a743c[_0xa8cf('0x35')]['length']?_0x5a743c[_0xa8cf('0x35')]:_0x312a36[_0xa8cf('0x34')];if(!_0x237338[_0xa8cf('0x30')][_0xa8cf('0x37')](_0xa8cf('0x38'))){_0x5a743c[_0xa8cf('0x1f')]=qs['limit'](_0x237338[_0xa8cf('0x30')][_0xa8cf('0x1f')]);_0x5a743c[_0xa8cf('0x1d')]=qs[_0xa8cf('0x1d')](_0x237338[_0xa8cf('0x30')][_0xa8cf('0x1d')]);}_0x5a743c[_0xa8cf('0x39')]=qs['sort'](_0x237338[_0xa8cf('0x30')][_0xa8cf('0x3a')]);_0x5a743c['where']=qs['filters'](_[_0xa8cf('0x3b')](_0x237338['query'],_0x312a36[_0xa8cf('0x32')]),_0x10625b);if(_0x237338[_0xa8cf('0x30')]['filter']){_0x5a743c['where']=_[_0xa8cf('0x3c')](_0x5a743c[_0xa8cf('0x3d')],{'$or':_[_0xa8cf('0x3e')](_0x10625b,function(_0xc4b4f3){if(_0xc4b4f3[_0xa8cf('0x3f')]!==_0xa8cf('0x40')){var _0x1837d5={};_0x1837d5[_0xc4b4f3[_0xa8cf('0x29')]]={'$like':'%'+_0x237338[_0xa8cf('0x30')][_0xa8cf('0x41')]+'%'};return _0x1837d5;}})});}_0x5a743c=_[_0xa8cf('0x3c')]({},_0x5a743c,_0x237338[_0xa8cf('0x42')]);var _0x3efe44={'where':_0x5a743c[_0xa8cf('0x3d')]};return db['FreshsalesConfiguration'][_0xa8cf('0x20')](_0x3efe44)[_0xa8cf('0x26')](function(_0x1d4f5c){_0x58a08f[_0xa8cf('0x20')]=_0x1d4f5c;if(_0x237338[_0xa8cf('0x30')][_0xa8cf('0x43')]){_0x5a743c[_0xa8cf('0x44')]=[{'all':!![]}];}return db[_0xa8cf('0x2c')]['findAll'](_0x5a743c);})[_0xa8cf('0x26')](function(_0xe08b7d){_0x58a08f[_0xa8cf('0x45')]=_0xe08b7d;return _0x58a08f;})[_0xa8cf('0x26')](respondWithFilteredResult(_0x4fcc9e,_0x5a743c))[_0xa8cf('0x46')](handleError(_0x4fcc9e,null));};exports[_0xa8cf('0x47')]=function(_0x1891d8,_0x4d3297){var _0x146285={'raw':![],'where':{'id':_0x1891d8[_0xa8cf('0x48')]['id']}},_0x2c03e7={};_0x2c03e7[_0xa8cf('0x34')]=_[_0xa8cf('0x31')](db[_0xa8cf('0x2c')][_0xa8cf('0x2d')]);_0x2c03e7[_0xa8cf('0x30')]=_[_0xa8cf('0x31')](_0x1891d8[_0xa8cf('0x30')]);_0x2c03e7[_0xa8cf('0x32')]=_[_0xa8cf('0x33')](_0x2c03e7[_0xa8cf('0x34')],_0x2c03e7['query']);_0x146285['attributes']=_[_0xa8cf('0x33')](_0x2c03e7[_0xa8cf('0x34')],qs[_0xa8cf('0x36')](_0x1891d8[_0xa8cf('0x30')][_0xa8cf('0x36')]));_0x146285['attributes']=_0x146285[_0xa8cf('0x35')]['length']?_0x146285['attributes']:_0x2c03e7['model'];if(_0x1891d8[_0xa8cf('0x30')][_0xa8cf('0x43')]){_0x146285['include']=[{'all':!![]}];}_0x146285=_[_0xa8cf('0x3c')]({},_0x146285,_0x1891d8[_0xa8cf('0x42')]);return db[_0xa8cf('0x2c')]['find'](_0x146285)[_0xa8cf('0x26')](handleEntityNotFound(_0x4d3297,null))[_0xa8cf('0x26')](respondWithResult(_0x4d3297,null))[_0xa8cf('0x46')](handleError(_0x4d3297,null));};exports[_0xa8cf('0x49')]=function(_0x5a87df,_0x54fdf7){return db['FreshsalesConfiguration'][_0xa8cf('0x49')](_0x5a87df[_0xa8cf('0x4a')],{})[_0xa8cf('0x26')](respondWithResult(_0x54fdf7,0xc9))[_0xa8cf('0x46')](handleError(_0x54fdf7,null));};exports[_0xa8cf('0x25')]=function(_0xbc0448,_0x4cbdcd){if(_0xbc0448[_0xa8cf('0x4a')]['id']){delete _0xbc0448['body']['id'];}return db['FreshsalesConfiguration'][_0xa8cf('0x4b')]({'where':{'id':_0xbc0448['params']['id']}})['then'](handleEntityNotFound(_0x4cbdcd,null))[_0xa8cf('0x26')](saveUpdates(_0xbc0448[_0xa8cf('0x4a')],null))[_0xa8cf('0x26')](respondWithResult(_0x4cbdcd,null))['catch'](handleError(_0x4cbdcd,null));};exports['destroy']=function(_0x100fc1,_0x5896f5){return db[_0xa8cf('0x2c')][_0xa8cf('0x4b')]({'where':{'id':_0x100fc1['params']['id']}})[_0xa8cf('0x26')](handleEntityNotFound(_0x5896f5,null))['then'](removeEntity(_0x5896f5,null))[_0xa8cf('0x46')](handleError(_0x5896f5,null));};exports[_0xa8cf('0x4c')]=function(_0x4775ea,_0x1dcaa0,_0x378c88){var _0x47b4d6={};var _0x53bc55={};var _0x6ac78b;var _0xeebc95;return db[_0xa8cf('0x2c')][_0xa8cf('0x4d')]({'where':{'id':_0x4775ea[_0xa8cf('0x48')]['id']}})[_0xa8cf('0x26')](handleEntityNotFound(_0x1dcaa0,null))[_0xa8cf('0x26')](function(_0x265a1b){if(_0x265a1b){_0x6ac78b=_0x265a1b;_0x53bc55[_0xa8cf('0x34')]=_[_0xa8cf('0x31')](db[_0xa8cf('0x4e')][_0xa8cf('0x2d')]);_0x53bc55['query']=_[_0xa8cf('0x31')](_0x4775ea[_0xa8cf('0x30')]);_0x53bc55[_0xa8cf('0x32')]=_[_0xa8cf('0x33')](_0x53bc55['model'],_0x53bc55['query']);_0x47b4d6[_0xa8cf('0x35')]=_[_0xa8cf('0x33')](_0x53bc55[_0xa8cf('0x34')],qs['fields'](_0x4775ea[_0xa8cf('0x30')][_0xa8cf('0x36')]));_0x47b4d6['attributes']=_0x47b4d6[_0xa8cf('0x35')][_0xa8cf('0x4f')]?_0x47b4d6[_0xa8cf('0x35')]:_0x53bc55[_0xa8cf('0x34')];_0x47b4d6[_0xa8cf('0x39')]=qs[_0xa8cf('0x3a')](_0x4775ea[_0xa8cf('0x30')]['sort']);_0x47b4d6[_0xa8cf('0x3d')]=qs[_0xa8cf('0x32')](_[_0xa8cf('0x3b')](_0x4775ea[_0xa8cf('0x30')],_0x53bc55[_0xa8cf('0x32')]));if(_0x4775ea[_0xa8cf('0x30')][_0xa8cf('0x41')]){_0x47b4d6[_0xa8cf('0x3d')]=_[_0xa8cf('0x3c')](_0x47b4d6[_0xa8cf('0x3d')],{'$or':_[_0xa8cf('0x3e')](_0x47b4d6[_0xa8cf('0x35')],function(_0x382193){var _0x2ccce6={};_0x2ccce6[_0x382193]={'$like':'%'+_0x4775ea['query']['filter']+'%'};return _0x2ccce6;})});}_0x47b4d6=_[_0xa8cf('0x3c')]({},_0x47b4d6,_0x4775ea['options']);return _0x6ac78b[_0xa8cf('0x4c')](_0x47b4d6);}})[_0xa8cf('0x26')](function(_0x39f5f4){if(_0x39f5f4){_0xeebc95=_0x39f5f4[_0xa8cf('0x4f')];if(!_0x4775ea['query'][_0xa8cf('0x37')](_0xa8cf('0x38'))){_0x47b4d6['limit']=qs[_0xa8cf('0x1f')](_0x4775ea[_0xa8cf('0x30')]['limit']);_0x47b4d6['offset']=qs[_0xa8cf('0x1d')](_0x4775ea['query'][_0xa8cf('0x1d')]);}return _0x6ac78b[_0xa8cf('0x4c')](_0x47b4d6);}})[_0xa8cf('0x26')](function(_0x1f2ab3){if(_0x1f2ab3){return _0x1f2ab3?{'count':_0xeebc95,'rows':_0x1f2ab3}:null;}})[_0xa8cf('0x26')](respondWithResult(_0x1dcaa0,null))[_0xa8cf('0x46')](handleError(_0x1dcaa0,null));};exports['getDescriptions']=function(_0x320b6c,_0x27d7c7,_0x22863d){var _0x3b32b9={};var _0x41d5aa={};var _0x565d3b;var _0x4376ed;return db[_0xa8cf('0x2c')][_0xa8cf('0x4d')]({'where':{'id':_0x320b6c['params']['id']}})[_0xa8cf('0x26')](handleEntityNotFound(_0x27d7c7,null))[_0xa8cf('0x26')](function(_0x290989){if(_0x290989){_0x565d3b=_0x290989;_0x41d5aa[_0xa8cf('0x34')]=_[_0xa8cf('0x31')](db['FreshsalesField']['rawAttributes']);_0x41d5aa['query']=_['keys'](_0x320b6c[_0xa8cf('0x30')]);_0x41d5aa[_0xa8cf('0x32')]=_[_0xa8cf('0x33')](_0x41d5aa['model'],_0x41d5aa[_0xa8cf('0x30')]);_0x3b32b9[_0xa8cf('0x35')]=_[_0xa8cf('0x33')](_0x41d5aa['model'],qs[_0xa8cf('0x36')](_0x320b6c[_0xa8cf('0x30')][_0xa8cf('0x36')]));_0x3b32b9[_0xa8cf('0x35')]=_0x3b32b9[_0xa8cf('0x35')][_0xa8cf('0x4f')]?_0x3b32b9['attributes']:_0x41d5aa[_0xa8cf('0x34')];_0x3b32b9['order']=qs[_0xa8cf('0x3a')](_0x320b6c[_0xa8cf('0x30')][_0xa8cf('0x3a')]);_0x3b32b9[_0xa8cf('0x3d')]=qs[_0xa8cf('0x32')](_['pick'](_0x320b6c[_0xa8cf('0x30')],_0x41d5aa['filters']));if(_0x320b6c[_0xa8cf('0x30')][_0xa8cf('0x41')]){_0x3b32b9[_0xa8cf('0x3d')]=_[_0xa8cf('0x3c')](_0x3b32b9[_0xa8cf('0x3d')],{'$or':_[_0xa8cf('0x3e')](_0x3b32b9[_0xa8cf('0x35')],function(_0x3c8a32){var _0x5a06a1={};_0x5a06a1[_0x3c8a32]={'$like':'%'+_0x320b6c[_0xa8cf('0x30')]['filter']+'%'};return _0x5a06a1;})});}_0x3b32b9=_[_0xa8cf('0x3c')]({},_0x3b32b9,_0x320b6c[_0xa8cf('0x42')]);return _0x565d3b[_0xa8cf('0x50')](_0x3b32b9);}})[_0xa8cf('0x26')](function(_0x5e7452){if(_0x5e7452){_0x4376ed=_0x5e7452[_0xa8cf('0x4f')];if(!_0x320b6c[_0xa8cf('0x30')][_0xa8cf('0x37')](_0xa8cf('0x38'))){_0x3b32b9[_0xa8cf('0x1f')]=qs[_0xa8cf('0x1f')](_0x320b6c[_0xa8cf('0x30')]['limit']);_0x3b32b9[_0xa8cf('0x1d')]=qs[_0xa8cf('0x1d')](_0x320b6c[_0xa8cf('0x30')][_0xa8cf('0x1d')]);}return _0x565d3b['getDescriptions'](_0x3b32b9);}})[_0xa8cf('0x26')](function(_0xe2c32e){if(_0xe2c32e){return _0xe2c32e?{'count':_0x4376ed,'rows':_0xe2c32e}:null;}})['then'](respondWithResult(_0x27d7c7,null))['catch'](handleError(_0x27d7c7,null));};exports[_0xa8cf('0x51')]=function(_0x8601dd,_0x795fd4,_0x2f5db0){var _0x50ad8={};var _0x4c5db8={};var _0x66ae94;var _0x1ff835;return db[_0xa8cf('0x2c')]['findOne']({'where':{'id':_0x8601dd[_0xa8cf('0x48')]['id']}})[_0xa8cf('0x26')](handleEntityNotFound(_0x795fd4,null))['then'](function(_0x5421ad){if(_0x5421ad){_0x66ae94=_0x5421ad;_0x4c5db8[_0xa8cf('0x34')]=_['keys'](db[_0xa8cf('0x4e')]['rawAttributes']);_0x4c5db8['query']=_[_0xa8cf('0x31')](_0x8601dd['query']);_0x4c5db8[_0xa8cf('0x32')]=_[_0xa8cf('0x33')](_0x4c5db8['model'],_0x4c5db8[_0xa8cf('0x30')]);_0x50ad8[_0xa8cf('0x35')]=_[_0xa8cf('0x33')](_0x4c5db8['model'],qs[_0xa8cf('0x36')](_0x8601dd['query']['fields']));_0x50ad8[_0xa8cf('0x35')]=_0x50ad8[_0xa8cf('0x35')][_0xa8cf('0x4f')]?_0x50ad8['attributes']:_0x4c5db8[_0xa8cf('0x34')];_0x50ad8[_0xa8cf('0x39')]=qs[_0xa8cf('0x3a')](_0x8601dd[_0xa8cf('0x30')][_0xa8cf('0x3a')]);_0x50ad8['where']=qs[_0xa8cf('0x32')](_[_0xa8cf('0x3b')](_0x8601dd[_0xa8cf('0x30')],_0x4c5db8['filters']));if(_0x8601dd['query'][_0xa8cf('0x41')]){_0x50ad8['where']=_[_0xa8cf('0x3c')](_0x50ad8[_0xa8cf('0x3d')],{'$or':_[_0xa8cf('0x3e')](_0x50ad8[_0xa8cf('0x35')],function(_0x29264b){var _0x3a0f04={};_0x3a0f04[_0x29264b]={'$like':'%'+_0x8601dd[_0xa8cf('0x30')][_0xa8cf('0x41')]+'%'};return _0x3a0f04;})});}_0x50ad8=_[_0xa8cf('0x3c')]({},_0x50ad8,_0x8601dd[_0xa8cf('0x42')]);return _0x66ae94[_0xa8cf('0x51')](_0x50ad8);}})['then'](function(_0x502a72){if(_0x502a72){_0x1ff835=_0x502a72[_0xa8cf('0x4f')];if(!_0x8601dd['query'][_0xa8cf('0x37')]('nolimit')){_0x50ad8[_0xa8cf('0x1f')]=qs[_0xa8cf('0x1f')](_0x8601dd[_0xa8cf('0x30')][_0xa8cf('0x1f')]);_0x50ad8['offset']=qs[_0xa8cf('0x1d')](_0x8601dd[_0xa8cf('0x30')]['offset']);}return _0x66ae94[_0xa8cf('0x51')](_0x50ad8);}})['then'](function(_0x486f02){if(_0x486f02){return _0x486f02?{'count':_0x1ff835,'rows':_0x486f02}:null;}})['then'](respondWithResult(_0x795fd4,null))[_0xa8cf('0x46')](handleError(_0x795fd4,null));};
\ No newline at end of file