Built motion from commit ffdca78c.|2.6.24
[motion2.git] / server / api / intFreshsalesConfiguration / intFreshsalesConfiguration.controller.js
index 368389d..6d0cbd0 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x3c86=['mustache','util','path','sox','to-csv','ejs','fs-extra','squel','crypto','jsforce','desk.js','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','sendStatus','status','end','offset','undefined','limit','count','Content-Range','json','reject','save','update','then','destroy','error','stack','name','send','index','map','FreshsalesConfiguration','rawAttributes','fieldName','type','model','query','filters','intersection','attributes','fields','hasOwnProperty','nolimit','order','sort','pick','filter','where','merge','VIRTUAL','options','include','rows','catch','show','params','keys','length','includeAll','find','create','body','FreshsalesField','getSubjects','getDescriptions','getFields','findOne','fast-json-patch','request-promise'];(function(_0x198446,_0x119c8f){var _0x38d7b7=function(_0x293752){while(--_0x293752){_0x198446['push'](_0x198446['shift']());}};_0x38d7b7(++_0x119c8f);}(_0x3c86,0x9a));var _0x63c8=function(_0x13d5bc,_0x3fce3c){_0x13d5bc=_0x13d5bc-0x0;var _0x4b8a40=_0x3c86[_0x13d5bc];return _0x4b8a40;};'use strict';var emlformat=require('eml-format');var rimraf=require('rimraf');var zipdir=require('zip-dir');var jsonpatch=require(_0x63c8('0x0'));var rp=require(_0x63c8('0x1'));var moment=require('moment');var BPromise=require('bluebird');var Mustache=require(_0x63c8('0x2'));var util=require(_0x63c8('0x3'));var path=require(_0x63c8('0x4'));var sox=require(_0x63c8('0x5'));var csv=require(_0x63c8('0x6'));var ejs=require(_0x63c8('0x7'));var fs=require('fs');var fs_extra=require(_0x63c8('0x8'));var _=require('lodash');var squel=require(_0x63c8('0x9'));var crypto=require(_0x63c8('0xa'));var jsforce=require(_0x63c8('0xb'));var deskjs=require(_0x63c8('0xc'));var toCsv=require('to-csv');var querystring=require('querystring');var Papa=require(_0x63c8('0xd'));var Redis=require(_0x63c8('0xe'));var authService=require(_0x63c8('0xf'));var qs=require(_0x63c8('0x10'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0x63c8('0x11'));var logger=require(_0x63c8('0x12'))(_0x63c8('0x13'));var utils=require(_0x63c8('0x14'));var config=require(_0x63c8('0x15'));var licenseUtil=require('../../config/license/util');var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x2446f8,_0x3ef223){_0x3ef223=_0x3ef223||0xcc;return function(_0x10249c){if(_0x10249c){return _0x2446f8[_0x63c8('0x16')](_0x3ef223);}return _0x2446f8[_0x63c8('0x17')](_0x3ef223)[_0x63c8('0x18')]();};}function respondWithResult(_0x3e1efa,_0x4232b4){_0x4232b4=_0x4232b4||0xc8;return function(_0x1e97de){if(_0x1e97de){return _0x3e1efa[_0x63c8('0x17')](_0x4232b4)['json'](_0x1e97de);}};}function respondWithFilteredResult(_0x3305a9,_0x2de327){return function(_0x36d1a8){if(_0x36d1a8){var _0x651389=typeof _0x2de327[_0x63c8('0x19')]===_0x63c8('0x1a')&&typeof _0x2de327[_0x63c8('0x1b')]===_0x63c8('0x1a');var _0x459c86=_0x36d1a8[_0x63c8('0x1c')];var _0x10ac4a=_0x651389?0x0:_0x2de327[_0x63c8('0x19')];var _0x45b265=_0x651389?_0x36d1a8[_0x63c8('0x1c')]:_0x2de327[_0x63c8('0x19')]+_0x2de327[_0x63c8('0x1b')];var _0xd6d52f;if(_0x45b265>=_0x459c86){_0x45b265=_0x459c86;_0xd6d52f=0xc8;}else{_0xd6d52f=0xce;}_0x3305a9[_0x63c8('0x17')](_0xd6d52f);return _0x3305a9['set'](_0x63c8('0x1d'),_0x10ac4a+'-'+_0x45b265+'/'+_0x459c86)[_0x63c8('0x1e')](_0x36d1a8);}return null;};}function patchUpdates(_0x4abdb4){return function(_0x4ad88f){try{jsonpatch['apply'](_0x4ad88f,_0x4abdb4,!![]);}catch(_0x3ea4c7){return BPromise[_0x63c8('0x1f')](_0x3ea4c7);}return _0x4ad88f[_0x63c8('0x20')]();};}function saveUpdates(_0x254bd7,_0x13d620){return function(_0x303bd4){if(_0x303bd4){return _0x303bd4[_0x63c8('0x21')](_0x254bd7)[_0x63c8('0x22')](function(_0x7d97df){return _0x7d97df;});}return null;};}function removeEntity(_0x131530,_0x5598d9){return function(_0x4bccfd){if(_0x4bccfd){return _0x4bccfd[_0x63c8('0x23')]()[_0x63c8('0x22')](function(){_0x131530[_0x63c8('0x17')](0xcc)[_0x63c8('0x18')]();});}};}function handleEntityNotFound(_0x40e6e6,_0xa59cac){return function(_0x3339f4){if(!_0x3339f4){_0x40e6e6['sendStatus'](0x194);}return _0x3339f4;};}function handleError(_0x1ecc29,_0x4680ef){_0x4680ef=_0x4680ef||0x1f4;return function(_0x457ae2){logger[_0x63c8('0x24')](_0x457ae2[_0x63c8('0x25')]);if(_0x457ae2[_0x63c8('0x26')]){delete _0x457ae2['name'];}_0x1ecc29[_0x63c8('0x17')](_0x4680ef)[_0x63c8('0x27')](_0x457ae2);};}exports[_0x63c8('0x28')]=function(_0x387150,_0x1b300a){var _0xf71dfc={},_0x373cef={},_0x3419c3={'count':0x0,'rows':[]};var _0x2573da=_[_0x63c8('0x29')](db[_0x63c8('0x2a')][_0x63c8('0x2b')],function(_0x189020){return{'name':_0x189020[_0x63c8('0x2c')],'type':_0x189020[_0x63c8('0x2d')]['key']};});_0x373cef[_0x63c8('0x2e')]=_[_0x63c8('0x29')](_0x2573da,_0x63c8('0x26'));_0x373cef[_0x63c8('0x2f')]=_['keys'](_0x387150[_0x63c8('0x2f')]);_0x373cef[_0x63c8('0x30')]=_[_0x63c8('0x31')](_0x373cef[_0x63c8('0x2e')],_0x373cef['query']);_0xf71dfc[_0x63c8('0x32')]=_[_0x63c8('0x31')](_0x373cef[_0x63c8('0x2e')],qs[_0x63c8('0x33')](_0x387150[_0x63c8('0x2f')]['fields']));_0xf71dfc['attributes']=_0xf71dfc['attributes']['length']?_0xf71dfc[_0x63c8('0x32')]:_0x373cef[_0x63c8('0x2e')];if(!_0x387150[_0x63c8('0x2f')][_0x63c8('0x34')](_0x63c8('0x35'))){_0xf71dfc[_0x63c8('0x1b')]=qs[_0x63c8('0x1b')](_0x387150[_0x63c8('0x2f')]['limit']);_0xf71dfc[_0x63c8('0x19')]=qs[_0x63c8('0x19')](_0x387150[_0x63c8('0x2f')]['offset']);}_0xf71dfc[_0x63c8('0x36')]=qs['sort'](_0x387150['query'][_0x63c8('0x37')]);_0xf71dfc['where']=qs[_0x63c8('0x30')](_[_0x63c8('0x38')](_0x387150[_0x63c8('0x2f')],_0x373cef[_0x63c8('0x30')]),_0x2573da);if(_0x387150['query'][_0x63c8('0x39')]){_0xf71dfc[_0x63c8('0x3a')]=_[_0x63c8('0x3b')](_0xf71dfc[_0x63c8('0x3a')],{'$or':_[_0x63c8('0x29')](_0x2573da,function(_0x2adf5){if(_0x2adf5[_0x63c8('0x2d')]!==_0x63c8('0x3c')){var _0x3aead5={};_0x3aead5[_0x2adf5['name']]={'$like':'%'+_0x387150[_0x63c8('0x2f')][_0x63c8('0x39')]+'%'};return _0x3aead5;}})});}_0xf71dfc=_[_0x63c8('0x3b')]({},_0xf71dfc,_0x387150[_0x63c8('0x3d')]);var _0x2cd375={'where':_0xf71dfc[_0x63c8('0x3a')]};return db['FreshsalesConfiguration'][_0x63c8('0x1c')](_0x2cd375)[_0x63c8('0x22')](function(_0x47f0d2){_0x3419c3['count']=_0x47f0d2;if(_0x387150['query']['includeAll']){_0xf71dfc[_0x63c8('0x3e')]=[{'all':!![]}];}return db[_0x63c8('0x2a')]['findAll'](_0xf71dfc);})['then'](function(_0x52fce4){_0x3419c3[_0x63c8('0x3f')]=_0x52fce4;return _0x3419c3;})['then'](respondWithFilteredResult(_0x1b300a,_0xf71dfc))[_0x63c8('0x40')](handleError(_0x1b300a,null));};exports[_0x63c8('0x41')]=function(_0x4265ee,_0x4830f3){var _0x17105f={'raw':![],'where':{'id':_0x4265ee[_0x63c8('0x42')]['id']}},_0x16fd1e={};_0x16fd1e[_0x63c8('0x2e')]=_[_0x63c8('0x43')](db[_0x63c8('0x2a')]['rawAttributes']);_0x16fd1e[_0x63c8('0x2f')]=_[_0x63c8('0x43')](_0x4265ee[_0x63c8('0x2f')]);_0x16fd1e[_0x63c8('0x30')]=_[_0x63c8('0x31')](_0x16fd1e['model'],_0x16fd1e['query']);_0x17105f[_0x63c8('0x32')]=_['intersection'](_0x16fd1e[_0x63c8('0x2e')],qs[_0x63c8('0x33')](_0x4265ee[_0x63c8('0x2f')][_0x63c8('0x33')]));_0x17105f[_0x63c8('0x32')]=_0x17105f[_0x63c8('0x32')][_0x63c8('0x44')]?_0x17105f[_0x63c8('0x32')]:_0x16fd1e[_0x63c8('0x2e')];if(_0x4265ee[_0x63c8('0x2f')][_0x63c8('0x45')]){_0x17105f[_0x63c8('0x3e')]=[{'all':!![]}];}_0x17105f=_['merge']({},_0x17105f,_0x4265ee['options']);return db[_0x63c8('0x2a')][_0x63c8('0x46')](_0x17105f)[_0x63c8('0x22')](handleEntityNotFound(_0x4830f3,null))[_0x63c8('0x22')](respondWithResult(_0x4830f3,null))['catch'](handleError(_0x4830f3,null));};exports['create']=function(_0x326a36,_0x4f55dc){return db[_0x63c8('0x2a')][_0x63c8('0x47')](_0x326a36[_0x63c8('0x48')],{})['then'](respondWithResult(_0x4f55dc,0xc9))[_0x63c8('0x40')](handleError(_0x4f55dc,null));};exports[_0x63c8('0x21')]=function(_0xf4fdd4,_0x5e51e2){if(_0xf4fdd4[_0x63c8('0x48')]['id']){delete _0xf4fdd4['body']['id'];}return db[_0x63c8('0x2a')][_0x63c8('0x46')]({'where':{'id':_0xf4fdd4[_0x63c8('0x42')]['id']}})[_0x63c8('0x22')](handleEntityNotFound(_0x5e51e2,null))[_0x63c8('0x22')](saveUpdates(_0xf4fdd4['body'],null))[_0x63c8('0x22')](respondWithResult(_0x5e51e2,null))[_0x63c8('0x40')](handleError(_0x5e51e2,null));};exports[_0x63c8('0x23')]=function(_0x2c1193,_0x3dad18){return db[_0x63c8('0x2a')][_0x63c8('0x46')]({'where':{'id':_0x2c1193[_0x63c8('0x42')]['id']}})[_0x63c8('0x22')](handleEntityNotFound(_0x3dad18,null))['then'](removeEntity(_0x3dad18,null))[_0x63c8('0x40')](handleError(_0x3dad18,null));};exports['getSubjects']=function(_0x36580a,_0x41695f,_0x5377ad){var _0x24a6bf={};var _0xc93e7c={};var _0x1e6bd4;var _0x4def08;return db['FreshsalesConfiguration']['findOne']({'where':{'id':_0x36580a[_0x63c8('0x42')]['id']}})[_0x63c8('0x22')](handleEntityNotFound(_0x41695f,null))[_0x63c8('0x22')](function(_0x24705d){if(_0x24705d){_0x1e6bd4=_0x24705d;_0xc93e7c[_0x63c8('0x2e')]=_['keys'](db[_0x63c8('0x49')][_0x63c8('0x2b')]);_0xc93e7c['query']=_[_0x63c8('0x43')](_0x36580a['query']);_0xc93e7c[_0x63c8('0x30')]=_[_0x63c8('0x31')](_0xc93e7c[_0x63c8('0x2e')],_0xc93e7c[_0x63c8('0x2f')]);_0x24a6bf['attributes']=_[_0x63c8('0x31')](_0xc93e7c['model'],qs[_0x63c8('0x33')](_0x36580a[_0x63c8('0x2f')][_0x63c8('0x33')]));_0x24a6bf[_0x63c8('0x32')]=_0x24a6bf[_0x63c8('0x32')][_0x63c8('0x44')]?_0x24a6bf[_0x63c8('0x32')]:_0xc93e7c['model'];_0x24a6bf[_0x63c8('0x36')]=qs[_0x63c8('0x37')](_0x36580a[_0x63c8('0x2f')][_0x63c8('0x37')]);_0x24a6bf['where']=qs['filters'](_['pick'](_0x36580a[_0x63c8('0x2f')],_0xc93e7c[_0x63c8('0x30')]));if(_0x36580a[_0x63c8('0x2f')][_0x63c8('0x39')]){_0x24a6bf['where']=_[_0x63c8('0x3b')](_0x24a6bf[_0x63c8('0x3a')],{'$or':_[_0x63c8('0x29')](_0x24a6bf[_0x63c8('0x32')],function(_0x30a6ea){var _0x17311e={};_0x17311e[_0x30a6ea]={'$like':'%'+_0x36580a['query'][_0x63c8('0x39')]+'%'};return _0x17311e;})});}_0x24a6bf=_['merge']({},_0x24a6bf,_0x36580a[_0x63c8('0x3d')]);return _0x1e6bd4[_0x63c8('0x4a')](_0x24a6bf);}})[_0x63c8('0x22')](function(_0x25954c){if(_0x25954c){_0x4def08=_0x25954c['length'];if(!_0x36580a['query'][_0x63c8('0x34')](_0x63c8('0x35'))){_0x24a6bf[_0x63c8('0x1b')]=qs[_0x63c8('0x1b')](_0x36580a[_0x63c8('0x2f')][_0x63c8('0x1b')]);_0x24a6bf[_0x63c8('0x19')]=qs['offset'](_0x36580a[_0x63c8('0x2f')][_0x63c8('0x19')]);}return _0x1e6bd4['getSubjects'](_0x24a6bf);}})[_0x63c8('0x22')](function(_0x53e764){if(_0x53e764){return _0x53e764?{'count':_0x4def08,'rows':_0x53e764}:null;}})[_0x63c8('0x22')](respondWithResult(_0x41695f,null))['catch'](handleError(_0x41695f,null));};exports[_0x63c8('0x4b')]=function(_0x4ea20c,_0x30bae1,_0x1eb9f7){var _0x3a7554={};var _0x343abd={};var _0x59ffdb;var _0x111051;return db[_0x63c8('0x2a')]['findOne']({'where':{'id':_0x4ea20c[_0x63c8('0x42')]['id']}})[_0x63c8('0x22')](handleEntityNotFound(_0x30bae1,null))[_0x63c8('0x22')](function(_0x36d6d9){if(_0x36d6d9){_0x59ffdb=_0x36d6d9;_0x343abd[_0x63c8('0x2e')]=_['keys'](db[_0x63c8('0x49')]['rawAttributes']);_0x343abd[_0x63c8('0x2f')]=_['keys'](_0x4ea20c[_0x63c8('0x2f')]);_0x343abd[_0x63c8('0x30')]=_[_0x63c8('0x31')](_0x343abd[_0x63c8('0x2e')],_0x343abd['query']);_0x3a7554[_0x63c8('0x32')]=_['intersection'](_0x343abd[_0x63c8('0x2e')],qs[_0x63c8('0x33')](_0x4ea20c['query'][_0x63c8('0x33')]));_0x3a7554[_0x63c8('0x32')]=_0x3a7554[_0x63c8('0x32')][_0x63c8('0x44')]?_0x3a7554[_0x63c8('0x32')]:_0x343abd['model'];_0x3a7554['order']=qs[_0x63c8('0x37')](_0x4ea20c[_0x63c8('0x2f')][_0x63c8('0x37')]);_0x3a7554[_0x63c8('0x3a')]=qs[_0x63c8('0x30')](_['pick'](_0x4ea20c[_0x63c8('0x2f')],_0x343abd['filters']));if(_0x4ea20c[_0x63c8('0x2f')][_0x63c8('0x39')]){_0x3a7554[_0x63c8('0x3a')]=_['merge'](_0x3a7554['where'],{'$or':_[_0x63c8('0x29')](_0x3a7554['attributes'],function(_0x3665a3){var _0x440fa2={};_0x440fa2[_0x3665a3]={'$like':'%'+_0x4ea20c['query'][_0x63c8('0x39')]+'%'};return _0x440fa2;})});}_0x3a7554=_[_0x63c8('0x3b')]({},_0x3a7554,_0x4ea20c[_0x63c8('0x3d')]);return _0x59ffdb['getDescriptions'](_0x3a7554);}})[_0x63c8('0x22')](function(_0x2a69a0){if(_0x2a69a0){_0x111051=_0x2a69a0['length'];if(!_0x4ea20c[_0x63c8('0x2f')][_0x63c8('0x34')]('nolimit')){_0x3a7554[_0x63c8('0x1b')]=qs['limit'](_0x4ea20c['query'][_0x63c8('0x1b')]);_0x3a7554[_0x63c8('0x19')]=qs[_0x63c8('0x19')](_0x4ea20c['query'][_0x63c8('0x19')]);}return _0x59ffdb['getDescriptions'](_0x3a7554);}})[_0x63c8('0x22')](function(_0x281b72){if(_0x281b72){return _0x281b72?{'count':_0x111051,'rows':_0x281b72}:null;}})[_0x63c8('0x22')](respondWithResult(_0x30bae1,null))['catch'](handleError(_0x30bae1,null));};exports[_0x63c8('0x4c')]=function(_0x5b750d,_0x31b5f5,_0x5e0482){var _0x3e0e0f={};var _0x55a76f={};var _0x29a29b;var _0x33e9df;return db[_0x63c8('0x2a')][_0x63c8('0x4d')]({'where':{'id':_0x5b750d[_0x63c8('0x42')]['id']}})[_0x63c8('0x22')](handleEntityNotFound(_0x31b5f5,null))[_0x63c8('0x22')](function(_0x3c8cbb){if(_0x3c8cbb){_0x29a29b=_0x3c8cbb;_0x55a76f['model']=_['keys'](db[_0x63c8('0x49')][_0x63c8('0x2b')]);_0x55a76f[_0x63c8('0x2f')]=_[_0x63c8('0x43')](_0x5b750d['query']);_0x55a76f[_0x63c8('0x30')]=_['intersection'](_0x55a76f['model'],_0x55a76f[_0x63c8('0x2f')]);_0x3e0e0f[_0x63c8('0x32')]=_[_0x63c8('0x31')](_0x55a76f[_0x63c8('0x2e')],qs[_0x63c8('0x33')](_0x5b750d[_0x63c8('0x2f')][_0x63c8('0x33')]));_0x3e0e0f[_0x63c8('0x32')]=_0x3e0e0f[_0x63c8('0x32')][_0x63c8('0x44')]?_0x3e0e0f['attributes']:_0x55a76f[_0x63c8('0x2e')];_0x3e0e0f['order']=qs[_0x63c8('0x37')](_0x5b750d[_0x63c8('0x2f')]['sort']);_0x3e0e0f['where']=qs[_0x63c8('0x30')](_['pick'](_0x5b750d[_0x63c8('0x2f')],_0x55a76f[_0x63c8('0x30')]));if(_0x5b750d[_0x63c8('0x2f')][_0x63c8('0x39')]){_0x3e0e0f[_0x63c8('0x3a')]=_[_0x63c8('0x3b')](_0x3e0e0f[_0x63c8('0x3a')],{'$or':_[_0x63c8('0x29')](_0x3e0e0f['attributes'],function(_0x5523f6){var _0x5be434={};_0x5be434[_0x5523f6]={'$like':'%'+_0x5b750d[_0x63c8('0x2f')]['filter']+'%'};return _0x5be434;})});}_0x3e0e0f=_[_0x63c8('0x3b')]({},_0x3e0e0f,_0x5b750d[_0x63c8('0x3d')]);return _0x29a29b['getFields'](_0x3e0e0f);}})['then'](function(_0x562272){if(_0x562272){_0x33e9df=_0x562272['length'];if(!_0x5b750d[_0x63c8('0x2f')][_0x63c8('0x34')](_0x63c8('0x35'))){_0x3e0e0f['limit']=qs[_0x63c8('0x1b')](_0x5b750d['query']['limit']);_0x3e0e0f['offset']=qs[_0x63c8('0x19')](_0x5b750d[_0x63c8('0x2f')][_0x63c8('0x19')]);}return _0x29a29b[_0x63c8('0x4c')](_0x3e0e0f);}})[_0x63c8('0x22')](function(_0x29d90e){if(_0x29d90e){return _0x29d90e?{'count':_0x33e9df,'rows':_0x29d90e}:null;}})[_0x63c8('0x22')](respondWithResult(_0x31b5f5,null))[_0x63c8('0x40')](handleError(_0x31b5f5,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