Built motion from commit e02f907f.|2.6.14
[motion2.git] / server / api / intFreshsalesConfiguration / intFreshsalesConfiguration.controller.js
index 10ea6be..4e1efb4 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x7fbe=['model','query','keys','filters','intersection','fields','attributes','length','hasOwnProperty','nolimit','limit','order','sort','where','VIRTUAL','filter','merge','options','include','findAll','params','includeAll','find','catch','update','body','getSubjects','findOne','FreshsalesField','pick','getDescriptions','getFields','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','sox','to-csv','ejs','lodash','squel','jsforce','desk.js','querystring','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','jayson/promise','client','http','request','FreshsalesConfiguration,\x20%s,\x20%s','request\x20sent','debug','FreshsalesConfiguration,\x20%s,\x20%s,\x20%s','stringify','error','message','info','result','end','status','json','count','offset','set','Content-Range','apply','save','then','destroy','stack','name','send','map','FreshsalesConfiguration','rawAttributes','fieldName','type','key'];(function(_0x334b41,_0x36d415){var _0x21daa0=function(_0x42785f){while(--_0x42785f){_0x334b41['push'](_0x334b41['shift']());}};_0x21daa0(++_0x36d415);}(_0x7fbe,0x1ec));var _0xe7fb=function(_0x4571ae,_0x5309bf){_0x4571ae=_0x4571ae-0x0;var _0x52b48b=_0x7fbe[_0x4571ae];return _0x52b48b;};'use strict';var pdf=require('html-pdf');var emlformat=require('eml-format');var rimraf=require(_0xe7fb('0x0'));var zipdir=require(_0xe7fb('0x1'));var jsonpatch=require(_0xe7fb('0x2'));var rp=require(_0xe7fb('0x3'));var moment=require(_0xe7fb('0x4'));var BPromise=require(_0xe7fb('0x5'));var Mustache=require(_0xe7fb('0x6'));var util=require(_0xe7fb('0x7'));var path=require(_0xe7fb('0x8'));var sox=require(_0xe7fb('0x9'));var csv=require(_0xe7fb('0xa'));var ejs=require(_0xe7fb('0xb'));var fs=require('fs');var _=require(_0xe7fb('0xc'));var squel=require(_0xe7fb('0xd'));var crypto=require('crypto');var jsforce=require(_0xe7fb('0xe'));var deskjs=require(_0xe7fb('0xf'));var toCsv=require(_0xe7fb('0xa'));var querystring=require(_0xe7fb('0x10'));var Papa=require('papaparse');var Redis=require('ioredis');var authService=require(_0xe7fb('0x11'));var qs=require(_0xe7fb('0x12'));var as=require(_0xe7fb('0x13'));var hardwareService=require(_0xe7fb('0x14'));var logger=require(_0xe7fb('0x15'))(_0xe7fb('0x16'));var utils=require(_0xe7fb('0x17'));var config=require(_0xe7fb('0x18'));var licenseUtil=require(_0xe7fb('0x19'));var db=require(_0xe7fb('0x1a'))['db'];var jayson=require(_0xe7fb('0x1b'));var client=jayson[_0xe7fb('0x1c')][_0xe7fb('0x1d')]({'port':0x232a});function respondWithRpcPromise(_0x45fe75,_0x7fe4d3,_0x598729,_0x278b75){return new BPromise(function(_0x2225e5,_0x5573ab){var _0x30015a=_0x278b75||client;return _0x30015a[_0xe7fb('0x1e')](_0x45fe75,_0x598729)['then'](function(_0xa76acf){logger['info'](_0xe7fb('0x1f'),_0x7fe4d3,_0xe7fb('0x20'));logger[_0xe7fb('0x21')](_0xe7fb('0x22'),_0x7fe4d3,'request\x20sent',JSON[_0xe7fb('0x23')](_0xa76acf));if(_0xa76acf['error']){if(_0xa76acf[_0xe7fb('0x24')]['code']===0x1f4){logger[_0xe7fb('0x24')](_0xe7fb('0x1f'),_0x7fe4d3,_0xa76acf[_0xe7fb('0x24')][_0xe7fb('0x25')]);return _0x5573ab(_0xa76acf['error'][_0xe7fb('0x25')]);}logger['error'](_0xe7fb('0x1f'),_0x7fe4d3,_0xa76acf['error'][_0xe7fb('0x25')]);return _0x2225e5(_0xa76acf['error'][_0xe7fb('0x25')]);}else{logger[_0xe7fb('0x26')]('FreshsalesConfiguration,\x20%s,\x20%s',_0x7fe4d3,_0xe7fb('0x20'));_0x2225e5(_0xa76acf[_0xe7fb('0x27')][_0xe7fb('0x25')]);}})['catch'](function(_0x469d50){logger[_0xe7fb('0x24')]('FreshsalesConfiguration,\x20%s,\x20%s',_0x7fe4d3,_0x469d50);_0x5573ab(_0x469d50);});});}function respondWithStatusCode(_0x5bea27,_0x52f08b){_0x52f08b=_0x52f08b||0xcc;return function(_0x35e4db){if(_0x35e4db){return _0x5bea27['sendStatus'](_0x52f08b);}return _0x5bea27['status'](_0x52f08b)[_0xe7fb('0x28')]();};}function respondWithResult(_0x32e8b2,_0x2996ae){_0x2996ae=_0x2996ae||0xc8;return function(_0x4f6c73){if(_0x4f6c73){return _0x32e8b2[_0xe7fb('0x29')](_0x2996ae)[_0xe7fb('0x2a')](_0x4f6c73);}};}function respondWithFilteredResult(_0x390f32,_0x1ceed8){return function(_0x392d75){if(_0x392d75){var _0x16237a=_0x392d75[_0xe7fb('0x2b')],_0x380130=_0x1ceed8[_0xe7fb('0x2c')],_0x59e015=_0x1ceed8[_0xe7fb('0x2c')]+_0x1ceed8['limit'],_0x5df9f2;if(_0x59e015>=_0x16237a){_0x59e015=_0x16237a;_0x5df9f2=0xc8;}else{_0x5df9f2=0xce;}_0x390f32[_0xe7fb('0x29')](_0x5df9f2);return _0x390f32[_0xe7fb('0x2d')](_0xe7fb('0x2e'),_0x380130+'-'+_0x59e015+'/'+_0x16237a)[_0xe7fb('0x2a')](_0x392d75);}return null;};}function patchUpdates(_0x219554){return function(_0x1256d4){try{jsonpatch[_0xe7fb('0x2f')](_0x1256d4,_0x219554,!![]);}catch(_0x3dd0be){return BPromise['reject'](_0x3dd0be);}return _0x1256d4[_0xe7fb('0x30')]();};}function saveUpdates(_0x1742f3,_0x29d1ca){return function(_0x547a04){if(_0x547a04){return _0x547a04['update'](_0x1742f3)[_0xe7fb('0x31')](function(_0x4a9fea){return _0x4a9fea;});}return null;};}function removeEntity(_0xac56b4,_0x2f8774){return function(_0xe49053){if(_0xe49053){return _0xe49053[_0xe7fb('0x32')]()['then'](function(){_0xac56b4[_0xe7fb('0x29')](0xcc)[_0xe7fb('0x28')]();});}};}function handleEntityNotFound(_0x18ed83,_0x2f8818){return function(_0x2d650d){if(!_0x2d650d){_0x18ed83['sendStatus'](0x194);}return _0x2d650d;};}function handleError(_0x256694,_0x121d19){_0x121d19=_0x121d19||0x1f4;return function(_0x209eaa){logger[_0xe7fb('0x24')](_0x209eaa[_0xe7fb('0x33')]);if(_0x209eaa[_0xe7fb('0x34')]){delete _0x209eaa[_0xe7fb('0x34')];}_0x256694[_0xe7fb('0x29')](_0x121d19)[_0xe7fb('0x35')](_0x209eaa);};}exports['index']=function(_0x44d8cf,_0x29ef52){var _0x2593e3={},_0x56e17b={},_0x1de75a={'count':0x0,'rows':[]};var _0x3502dc=_[_0xe7fb('0x36')](db[_0xe7fb('0x37')][_0xe7fb('0x38')],function(_0x35b828){return{'name':_0x35b828[_0xe7fb('0x39')],'type':_0x35b828[_0xe7fb('0x3a')][_0xe7fb('0x3b')]};});_0x56e17b[_0xe7fb('0x3c')]=_[_0xe7fb('0x36')](_0x3502dc,_0xe7fb('0x34'));_0x56e17b[_0xe7fb('0x3d')]=_[_0xe7fb('0x3e')](_0x44d8cf[_0xe7fb('0x3d')]);_0x56e17b[_0xe7fb('0x3f')]=_[_0xe7fb('0x40')](_0x56e17b[_0xe7fb('0x3c')],_0x56e17b[_0xe7fb('0x3d')]);_0x2593e3['attributes']=_[_0xe7fb('0x40')](_0x56e17b[_0xe7fb('0x3c')],qs[_0xe7fb('0x41')](_0x44d8cf[_0xe7fb('0x3d')]['fields']));_0x2593e3[_0xe7fb('0x42')]=_0x2593e3[_0xe7fb('0x42')][_0xe7fb('0x43')]?_0x2593e3[_0xe7fb('0x42')]:_0x56e17b['model'];if(!_0x44d8cf[_0xe7fb('0x3d')][_0xe7fb('0x44')](_0xe7fb('0x45'))){_0x2593e3[_0xe7fb('0x46')]=qs[_0xe7fb('0x46')](_0x44d8cf[_0xe7fb('0x3d')]['limit']);_0x2593e3[_0xe7fb('0x2c')]=qs[_0xe7fb('0x2c')](_0x44d8cf[_0xe7fb('0x3d')]['offset']);}_0x2593e3[_0xe7fb('0x47')]=qs[_0xe7fb('0x48')](_0x44d8cf['query']['sort']);_0x2593e3['where']=qs['filters'](_['pick'](_0x44d8cf[_0xe7fb('0x3d')],_0x56e17b[_0xe7fb('0x3f')]),_0x3502dc);if(_0x44d8cf[_0xe7fb('0x3d')]['filter']){_0x2593e3[_0xe7fb('0x49')]=_['merge'](_0x2593e3[_0xe7fb('0x49')],{'$or':_[_0xe7fb('0x36')](_0x3502dc,function(_0x4d29d3){if(_0x4d29d3[_0xe7fb('0x3a')]!==_0xe7fb('0x4a')){var _0x240efa={};_0x240efa[_0x4d29d3[_0xe7fb('0x34')]]={'$like':'%'+_0x44d8cf['query'][_0xe7fb('0x4b')]+'%'};return _0x240efa;}})});}_0x2593e3=_[_0xe7fb('0x4c')]({},_0x2593e3,_0x44d8cf[_0xe7fb('0x4d')]);var _0x56a84f={'where':_0x2593e3[_0xe7fb('0x49')]};return db[_0xe7fb('0x37')][_0xe7fb('0x2b')](_0x56a84f)[_0xe7fb('0x31')](function(_0xc07c40){_0x1de75a['count']=_0xc07c40;if(_0x44d8cf[_0xe7fb('0x3d')]['includeAll']){_0x2593e3[_0xe7fb('0x4e')]=[{'all':!![]}];}return db[_0xe7fb('0x37')][_0xe7fb('0x4f')](_0x2593e3);})[_0xe7fb('0x31')](function(_0x15cec3){_0x1de75a['rows']=_0x15cec3;return _0x1de75a;})[_0xe7fb('0x31')](respondWithFilteredResult(_0x29ef52,_0x2593e3))['catch'](handleError(_0x29ef52,null));};exports['show']=function(_0x12c828,_0x3d740f){var _0x16327f={'raw':![],'where':{'id':_0x12c828[_0xe7fb('0x50')]['id']}},_0x589555={};_0x589555[_0xe7fb('0x3c')]=_['keys'](db['FreshsalesConfiguration'][_0xe7fb('0x38')]);_0x589555[_0xe7fb('0x3d')]=_[_0xe7fb('0x3e')](_0x12c828[_0xe7fb('0x3d')]);_0x589555[_0xe7fb('0x3f')]=_[_0xe7fb('0x40')](_0x589555[_0xe7fb('0x3c')],_0x589555[_0xe7fb('0x3d')]);_0x16327f['attributes']=_[_0xe7fb('0x40')](_0x589555['model'],qs[_0xe7fb('0x41')](_0x12c828[_0xe7fb('0x3d')]['fields']));_0x16327f[_0xe7fb('0x42')]=_0x16327f['attributes'][_0xe7fb('0x43')]?_0x16327f['attributes']:_0x589555[_0xe7fb('0x3c')];if(_0x12c828['query'][_0xe7fb('0x51')]){_0x16327f['include']=[{'all':!![]}];}_0x16327f=_[_0xe7fb('0x4c')]({},_0x16327f,_0x12c828[_0xe7fb('0x4d')]);return db[_0xe7fb('0x37')][_0xe7fb('0x52')](_0x16327f)[_0xe7fb('0x31')](handleEntityNotFound(_0x3d740f,null))[_0xe7fb('0x31')](respondWithResult(_0x3d740f,null))[_0xe7fb('0x53')](handleError(_0x3d740f,null));};exports['create']=function(_0x5d20dc,_0x20aa55){return db['FreshsalesConfiguration']['create'](_0x5d20dc['body'],{})['then'](respondWithResult(_0x20aa55,0xc9))['catch'](handleError(_0x20aa55,null));};exports[_0xe7fb('0x54')]=function(_0x34dd69,_0xd2fd76){if(_0x34dd69[_0xe7fb('0x55')]['id']){delete _0x34dd69['body']['id'];}return db[_0xe7fb('0x37')][_0xe7fb('0x52')]({'where':{'id':_0x34dd69[_0xe7fb('0x50')]['id']}})['then'](handleEntityNotFound(_0xd2fd76,null))['then'](saveUpdates(_0x34dd69[_0xe7fb('0x55')],null))[_0xe7fb('0x31')](respondWithResult(_0xd2fd76,null))[_0xe7fb('0x53')](handleError(_0xd2fd76,null));};exports['destroy']=function(_0x27f860,_0x3d946b){return db[_0xe7fb('0x37')][_0xe7fb('0x52')]({'where':{'id':_0x27f860['params']['id']}})['then'](handleEntityNotFound(_0x3d946b,null))[_0xe7fb('0x31')](removeEntity(_0x3d946b,null))[_0xe7fb('0x53')](handleError(_0x3d946b,null));};exports[_0xe7fb('0x56')]=function(_0x2f61b1,_0x3b0147,_0x5dd7c8){var _0x9c45a={};var _0x349a2a={};var _0x23755b;var _0x590d7a;return db['FreshsalesConfiguration'][_0xe7fb('0x57')]({'where':{'id':_0x2f61b1[_0xe7fb('0x50')]['id']}})[_0xe7fb('0x31')](handleEntityNotFound(_0x3b0147,null))[_0xe7fb('0x31')](function(_0x40f546){if(_0x40f546){_0x23755b=_0x40f546;_0x349a2a[_0xe7fb('0x3c')]=_['keys'](db[_0xe7fb('0x58')][_0xe7fb('0x38')]);_0x349a2a[_0xe7fb('0x3d')]=_[_0xe7fb('0x3e')](_0x2f61b1[_0xe7fb('0x3d')]);_0x349a2a[_0xe7fb('0x3f')]=_['intersection'](_0x349a2a[_0xe7fb('0x3c')],_0x349a2a['query']);_0x9c45a[_0xe7fb('0x42')]=_[_0xe7fb('0x40')](_0x349a2a[_0xe7fb('0x3c')],qs[_0xe7fb('0x41')](_0x2f61b1['query']['fields']));_0x9c45a[_0xe7fb('0x42')]=_0x9c45a[_0xe7fb('0x42')][_0xe7fb('0x43')]?_0x9c45a[_0xe7fb('0x42')]:_0x349a2a[_0xe7fb('0x3c')];_0x9c45a['order']=qs[_0xe7fb('0x48')](_0x2f61b1['query'][_0xe7fb('0x48')]);_0x9c45a['where']=qs['filters'](_[_0xe7fb('0x59')](_0x2f61b1[_0xe7fb('0x3d')],_0x349a2a[_0xe7fb('0x3f')]));if(_0x2f61b1['query'][_0xe7fb('0x4b')]){_0x9c45a[_0xe7fb('0x49')]=_[_0xe7fb('0x4c')](_0x9c45a[_0xe7fb('0x49')],{'$or':_[_0xe7fb('0x36')](_0x9c45a['attributes'],function(_0x404498){var _0x3c153a={};_0x3c153a[_0x404498]={'$like':'%'+_0x2f61b1['query'][_0xe7fb('0x4b')]+'%'};return _0x3c153a;})});}_0x9c45a=_[_0xe7fb('0x4c')]({},_0x9c45a,_0x2f61b1['options']);return _0x23755b[_0xe7fb('0x56')](_0x9c45a);}})['then'](function(_0x2705ef){if(_0x2705ef){_0x590d7a=_0x2705ef[_0xe7fb('0x43')];if(!_0x2f61b1[_0xe7fb('0x3d')]['hasOwnProperty'](_0xe7fb('0x45'))){_0x9c45a[_0xe7fb('0x46')]=qs[_0xe7fb('0x46')](_0x2f61b1[_0xe7fb('0x3d')][_0xe7fb('0x46')]);_0x9c45a[_0xe7fb('0x2c')]=qs[_0xe7fb('0x2c')](_0x2f61b1[_0xe7fb('0x3d')]['offset']);}return _0x23755b['getSubjects'](_0x9c45a);}})[_0xe7fb('0x31')](function(_0x3a674e){if(_0x3a674e){return _0x3a674e?{'count':_0x590d7a,'rows':_0x3a674e}:null;}})[_0xe7fb('0x31')](respondWithResult(_0x3b0147,null))['catch'](handleError(_0x3b0147,null));};exports['getDescriptions']=function(_0x1ac1fd,_0x2b071c,_0xad7c53){var _0x1df857={};var _0x2d558c={};var _0x336fd3;var _0x188e57;return db[_0xe7fb('0x37')][_0xe7fb('0x57')]({'where':{'id':_0x1ac1fd[_0xe7fb('0x50')]['id']}})[_0xe7fb('0x31')](handleEntityNotFound(_0x2b071c,null))[_0xe7fb('0x31')](function(_0x12b91f){if(_0x12b91f){_0x336fd3=_0x12b91f;_0x2d558c['model']=_['keys'](db[_0xe7fb('0x58')][_0xe7fb('0x38')]);_0x2d558c[_0xe7fb('0x3d')]=_[_0xe7fb('0x3e')](_0x1ac1fd[_0xe7fb('0x3d')]);_0x2d558c['filters']=_[_0xe7fb('0x40')](_0x2d558c[_0xe7fb('0x3c')],_0x2d558c[_0xe7fb('0x3d')]);_0x1df857[_0xe7fb('0x42')]=_[_0xe7fb('0x40')](_0x2d558c[_0xe7fb('0x3c')],qs[_0xe7fb('0x41')](_0x1ac1fd[_0xe7fb('0x3d')][_0xe7fb('0x41')]));_0x1df857['attributes']=_0x1df857[_0xe7fb('0x42')]['length']?_0x1df857[_0xe7fb('0x42')]:_0x2d558c[_0xe7fb('0x3c')];_0x1df857[_0xe7fb('0x47')]=qs[_0xe7fb('0x48')](_0x1ac1fd[_0xe7fb('0x3d')]['sort']);_0x1df857[_0xe7fb('0x49')]=qs[_0xe7fb('0x3f')](_[_0xe7fb('0x59')](_0x1ac1fd[_0xe7fb('0x3d')],_0x2d558c[_0xe7fb('0x3f')]));if(_0x1ac1fd[_0xe7fb('0x3d')][_0xe7fb('0x4b')]){_0x1df857[_0xe7fb('0x49')]=_[_0xe7fb('0x4c')](_0x1df857[_0xe7fb('0x49')],{'$or':_[_0xe7fb('0x36')](_0x1df857[_0xe7fb('0x42')],function(_0x3a68c0){var _0x300a7c={};_0x300a7c[_0x3a68c0]={'$like':'%'+_0x1ac1fd['query']['filter']+'%'};return _0x300a7c;})});}_0x1df857=_['merge']({},_0x1df857,_0x1ac1fd[_0xe7fb('0x4d')]);return _0x336fd3[_0xe7fb('0x5a')](_0x1df857);}})[_0xe7fb('0x31')](function(_0x2789f0){if(_0x2789f0){_0x188e57=_0x2789f0['length'];if(!_0x1ac1fd[_0xe7fb('0x3d')][_0xe7fb('0x44')](_0xe7fb('0x45'))){_0x1df857[_0xe7fb('0x46')]=qs['limit'](_0x1ac1fd[_0xe7fb('0x3d')]['limit']);_0x1df857[_0xe7fb('0x2c')]=qs[_0xe7fb('0x2c')](_0x1ac1fd[_0xe7fb('0x3d')][_0xe7fb('0x2c')]);}return _0x336fd3[_0xe7fb('0x5a')](_0x1df857);}})['then'](function(_0x3ffd6c){if(_0x3ffd6c){return _0x3ffd6c?{'count':_0x188e57,'rows':_0x3ffd6c}:null;}})['then'](respondWithResult(_0x2b071c,null))[_0xe7fb('0x53')](handleError(_0x2b071c,null));};exports['getFields']=function(_0x2aeeed,_0x38f52c,_0x4c37cd){var _0x2b6d69={};var _0x31642f={};var _0xb19e94;var _0x4181fd;return db['FreshsalesConfiguration'][_0xe7fb('0x57')]({'where':{'id':_0x2aeeed[_0xe7fb('0x50')]['id']}})[_0xe7fb('0x31')](handleEntityNotFound(_0x38f52c,null))['then'](function(_0x11d5b6){if(_0x11d5b6){_0xb19e94=_0x11d5b6;_0x31642f['model']=_['keys'](db['FreshsalesField'][_0xe7fb('0x38')]);_0x31642f[_0xe7fb('0x3d')]=_['keys'](_0x2aeeed[_0xe7fb('0x3d')]);_0x31642f[_0xe7fb('0x3f')]=_[_0xe7fb('0x40')](_0x31642f[_0xe7fb('0x3c')],_0x31642f[_0xe7fb('0x3d')]);_0x2b6d69[_0xe7fb('0x42')]=_[_0xe7fb('0x40')](_0x31642f[_0xe7fb('0x3c')],qs[_0xe7fb('0x41')](_0x2aeeed[_0xe7fb('0x3d')][_0xe7fb('0x41')]));_0x2b6d69[_0xe7fb('0x42')]=_0x2b6d69[_0xe7fb('0x42')][_0xe7fb('0x43')]?_0x2b6d69[_0xe7fb('0x42')]:_0x31642f[_0xe7fb('0x3c')];_0x2b6d69[_0xe7fb('0x47')]=qs[_0xe7fb('0x48')](_0x2aeeed[_0xe7fb('0x3d')][_0xe7fb('0x48')]);_0x2b6d69['where']=qs[_0xe7fb('0x3f')](_[_0xe7fb('0x59')](_0x2aeeed[_0xe7fb('0x3d')],_0x31642f[_0xe7fb('0x3f')]));if(_0x2aeeed[_0xe7fb('0x3d')][_0xe7fb('0x4b')]){_0x2b6d69[_0xe7fb('0x49')]=_['merge'](_0x2b6d69['where'],{'$or':_[_0xe7fb('0x36')](_0x2b6d69['attributes'],function(_0x2f486){var _0x496205={};_0x496205[_0x2f486]={'$like':'%'+_0x2aeeed['query'][_0xe7fb('0x4b')]+'%'};return _0x496205;})});}_0x2b6d69=_[_0xe7fb('0x4c')]({},_0x2b6d69,_0x2aeeed[_0xe7fb('0x4d')]);return _0xb19e94[_0xe7fb('0x5b')](_0x2b6d69);}})[_0xe7fb('0x31')](function(_0x38cc9e){if(_0x38cc9e){_0x4181fd=_0x38cc9e['length'];if(!_0x2aeeed[_0xe7fb('0x3d')][_0xe7fb('0x44')](_0xe7fb('0x45'))){_0x2b6d69[_0xe7fb('0x46')]=qs[_0xe7fb('0x46')](_0x2aeeed[_0xe7fb('0x3d')]['limit']);_0x2b6d69['offset']=qs['offset'](_0x2aeeed[_0xe7fb('0x3d')][_0xe7fb('0x2c')]);}return _0xb19e94[_0xe7fb('0x5b')](_0x2b6d69);}})['then'](function(_0xfa895b){if(_0xfa895b){return _0xfa895b?{'count':_0x4181fd,'rows':_0xfa895b}:null;}})['then'](respondWithResult(_0x38f52c,null))[_0xe7fb('0x53')](handleError(_0x38f52c,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