Built motion from commit ffdca78c.|2.6.24
[motion2.git] / server / api / intFreshsalesConfiguration / intFreshsalesConfiguration.controller.js
index 31748fd..6d0cbd0 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xdbb4=['desk.js','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','sendStatus','status','json','offset','undefined','limit','count','apply','reject','save','update','then','destroy','end','error','name','send','map','FreshsalesConfiguration','rawAttributes','fieldName','type','key','model','query','filters','attributes','intersection','fields','length','hasOwnProperty','nolimit','order','sort','where','merge','VIRTUAL','includeAll','include','findAll','rows','catch','show','params','keys','options','find','create','body','getSubjects','findOne','pick','filter','getDescriptions','getFields','FreshsalesField','eml-format','rimraf','zip-dir','moment','bluebird','mustache','util','path','to-csv','ejs','lodash','squel','crypto','jsforce'];(function(_0x1dd3c5,_0x5144bb){var _0x4ac733=function(_0x534930){while(--_0x534930){_0x1dd3c5['push'](_0x1dd3c5['shift']());}};_0x4ac733(++_0x5144bb);}(_0xdbb4,0x1d8));var _0x4dbb=function(_0x210ed6,_0x3dffa7){_0x210ed6=_0x210ed6-0x0;var _0x353e65=_0xdbb4[_0x210ed6];return _0x353e65;};'use strict';var emlformat=require(_0x4dbb('0x0'));var rimraf=require(_0x4dbb('0x1'));var zipdir=require(_0x4dbb('0x2'));var jsonpatch=require('fast-json-patch');var rp=require('request-promise');var moment=require(_0x4dbb('0x3'));var BPromise=require(_0x4dbb('0x4'));var Mustache=require(_0x4dbb('0x5'));var util=require(_0x4dbb('0x6'));var path=require(_0x4dbb('0x7'));var sox=require('sox');var csv=require(_0x4dbb('0x8'));var ejs=require(_0x4dbb('0x9'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0x4dbb('0xa'));var squel=require(_0x4dbb('0xb'));var crypto=require(_0x4dbb('0xc'));var jsforce=require(_0x4dbb('0xd'));var deskjs=require(_0x4dbb('0xe'));var toCsv=require(_0x4dbb('0x8'));var querystring=require('querystring');var Papa=require(_0x4dbb('0xf'));var Redis=require(_0x4dbb('0x10'));var authService=require(_0x4dbb('0x11'));var qs=require(_0x4dbb('0x12'));var as=require(_0x4dbb('0x13'));var hardwareService=require('../../config/license/hardware');var logger=require(_0x4dbb('0x14'))(_0x4dbb('0x15'));var utils=require(_0x4dbb('0x16'));var config=require(_0x4dbb('0x17'));var licenseUtil=require(_0x4dbb('0x18'));var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x27f2b8,_0x1e5cb7){_0x1e5cb7=_0x1e5cb7||0xcc;return function(_0x325212){if(_0x325212){return _0x27f2b8[_0x4dbb('0x19')](_0x1e5cb7);}return _0x27f2b8[_0x4dbb('0x1a')](_0x1e5cb7)['end']();};}function respondWithResult(_0x30bfdb,_0x46af26){_0x46af26=_0x46af26||0xc8;return function(_0x432567){if(_0x432567){return _0x30bfdb['status'](_0x46af26)[_0x4dbb('0x1b')](_0x432567);}};}function respondWithFilteredResult(_0x5a1c41,_0x197783){return function(_0x1ed92d){if(_0x1ed92d){var _0x2ef9a0=typeof _0x197783[_0x4dbb('0x1c')]===_0x4dbb('0x1d')&&typeof _0x197783[_0x4dbb('0x1e')]==='undefined';var _0x3f5130=_0x1ed92d[_0x4dbb('0x1f')];var _0x1c3b05=_0x2ef9a0?0x0:_0x197783['offset'];var _0x2abbc5=_0x2ef9a0?_0x1ed92d[_0x4dbb('0x1f')]:_0x197783[_0x4dbb('0x1c')]+_0x197783['limit'];var _0x3710f7;if(_0x2abbc5>=_0x3f5130){_0x2abbc5=_0x3f5130;_0x3710f7=0xc8;}else{_0x3710f7=0xce;}_0x5a1c41[_0x4dbb('0x1a')](_0x3710f7);return _0x5a1c41['set']('Content-Range',_0x1c3b05+'-'+_0x2abbc5+'/'+_0x3f5130)[_0x4dbb('0x1b')](_0x1ed92d);}return null;};}function patchUpdates(_0x2a28ff){return function(_0x399a31){try{jsonpatch[_0x4dbb('0x20')](_0x399a31,_0x2a28ff,!![]);}catch(_0x84160e){return BPromise[_0x4dbb('0x21')](_0x84160e);}return _0x399a31[_0x4dbb('0x22')]();};}function saveUpdates(_0x43fb67,_0x29005c){return function(_0xd891f4){if(_0xd891f4){return _0xd891f4[_0x4dbb('0x23')](_0x43fb67)[_0x4dbb('0x24')](function(_0x38f867){return _0x38f867;});}return null;};}function removeEntity(_0x479742,_0x18267f){return function(_0x5e5f34){if(_0x5e5f34){return _0x5e5f34[_0x4dbb('0x25')]()[_0x4dbb('0x24')](function(){_0x479742[_0x4dbb('0x1a')](0xcc)[_0x4dbb('0x26')]();});}};}function handleEntityNotFound(_0x381f63,_0x5d9c83){return function(_0x34db28){if(!_0x34db28){_0x381f63[_0x4dbb('0x19')](0x194);}return _0x34db28;};}function handleError(_0xc8624,_0x4d5e87){_0x4d5e87=_0x4d5e87||0x1f4;return function(_0x459503){logger[_0x4dbb('0x27')](_0x459503['stack']);if(_0x459503[_0x4dbb('0x28')]){delete _0x459503['name'];}_0xc8624[_0x4dbb('0x1a')](_0x4d5e87)[_0x4dbb('0x29')](_0x459503);};}exports['index']=function(_0x392758,_0x4d8cfd){var _0x53f979={},_0x22f837={},_0x2eada3={'count':0x0,'rows':[]};var _0x40202c=_[_0x4dbb('0x2a')](db[_0x4dbb('0x2b')][_0x4dbb('0x2c')],function(_0x2d435d){return{'name':_0x2d435d[_0x4dbb('0x2d')],'type':_0x2d435d[_0x4dbb('0x2e')][_0x4dbb('0x2f')]};});_0x22f837[_0x4dbb('0x30')]=_['map'](_0x40202c,'name');_0x22f837[_0x4dbb('0x31')]=_['keys'](_0x392758[_0x4dbb('0x31')]);_0x22f837[_0x4dbb('0x32')]=_['intersection'](_0x22f837[_0x4dbb('0x30')],_0x22f837[_0x4dbb('0x31')]);_0x53f979[_0x4dbb('0x33')]=_[_0x4dbb('0x34')](_0x22f837['model'],qs['fields'](_0x392758['query'][_0x4dbb('0x35')]));_0x53f979['attributes']=_0x53f979[_0x4dbb('0x33')][_0x4dbb('0x36')]?_0x53f979[_0x4dbb('0x33')]:_0x22f837['model'];if(!_0x392758[_0x4dbb('0x31')][_0x4dbb('0x37')](_0x4dbb('0x38'))){_0x53f979[_0x4dbb('0x1e')]=qs[_0x4dbb('0x1e')](_0x392758[_0x4dbb('0x31')][_0x4dbb('0x1e')]);_0x53f979[_0x4dbb('0x1c')]=qs[_0x4dbb('0x1c')](_0x392758[_0x4dbb('0x31')][_0x4dbb('0x1c')]);}_0x53f979[_0x4dbb('0x39')]=qs[_0x4dbb('0x3a')](_0x392758[_0x4dbb('0x31')]['sort']);_0x53f979[_0x4dbb('0x3b')]=qs['filters'](_['pick'](_0x392758[_0x4dbb('0x31')],_0x22f837['filters']),_0x40202c);if(_0x392758[_0x4dbb('0x31')]['filter']){_0x53f979[_0x4dbb('0x3b')]=_[_0x4dbb('0x3c')](_0x53f979[_0x4dbb('0x3b')],{'$or':_[_0x4dbb('0x2a')](_0x40202c,function(_0x5849bf){if(_0x5849bf[_0x4dbb('0x2e')]!==_0x4dbb('0x3d')){var _0x9bf3d6={};_0x9bf3d6[_0x5849bf[_0x4dbb('0x28')]]={'$like':'%'+_0x392758['query']['filter']+'%'};return _0x9bf3d6;}})});}_0x53f979=_[_0x4dbb('0x3c')]({},_0x53f979,_0x392758['options']);var _0x434cde={'where':_0x53f979[_0x4dbb('0x3b')]};return db[_0x4dbb('0x2b')][_0x4dbb('0x1f')](_0x434cde)[_0x4dbb('0x24')](function(_0x51e4a3){_0x2eada3[_0x4dbb('0x1f')]=_0x51e4a3;if(_0x392758['query'][_0x4dbb('0x3e')]){_0x53f979[_0x4dbb('0x3f')]=[{'all':!![]}];}return db[_0x4dbb('0x2b')][_0x4dbb('0x40')](_0x53f979);})[_0x4dbb('0x24')](function(_0x116941){_0x2eada3[_0x4dbb('0x41')]=_0x116941;return _0x2eada3;})['then'](respondWithFilteredResult(_0x4d8cfd,_0x53f979))[_0x4dbb('0x42')](handleError(_0x4d8cfd,null));};exports[_0x4dbb('0x43')]=function(_0x5193e7,_0x48946e){var _0xe125fe={'raw':![],'where':{'id':_0x5193e7[_0x4dbb('0x44')]['id']}},_0x5c59b8={};_0x5c59b8[_0x4dbb('0x30')]=_[_0x4dbb('0x45')](db[_0x4dbb('0x2b')][_0x4dbb('0x2c')]);_0x5c59b8[_0x4dbb('0x31')]=_['keys'](_0x5193e7['query']);_0x5c59b8['filters']=_[_0x4dbb('0x34')](_0x5c59b8[_0x4dbb('0x30')],_0x5c59b8['query']);_0xe125fe[_0x4dbb('0x33')]=_[_0x4dbb('0x34')](_0x5c59b8[_0x4dbb('0x30')],qs[_0x4dbb('0x35')](_0x5193e7['query'][_0x4dbb('0x35')]));_0xe125fe[_0x4dbb('0x33')]=_0xe125fe['attributes'][_0x4dbb('0x36')]?_0xe125fe['attributes']:_0x5c59b8['model'];if(_0x5193e7[_0x4dbb('0x31')][_0x4dbb('0x3e')]){_0xe125fe[_0x4dbb('0x3f')]=[{'all':!![]}];}_0xe125fe=_[_0x4dbb('0x3c')]({},_0xe125fe,_0x5193e7[_0x4dbb('0x46')]);return db[_0x4dbb('0x2b')][_0x4dbb('0x47')](_0xe125fe)[_0x4dbb('0x24')](handleEntityNotFound(_0x48946e,null))[_0x4dbb('0x24')](respondWithResult(_0x48946e,null))[_0x4dbb('0x42')](handleError(_0x48946e,null));};exports[_0x4dbb('0x48')]=function(_0x7f6f19,_0x4644a2){return db['FreshsalesConfiguration'][_0x4dbb('0x48')](_0x7f6f19[_0x4dbb('0x49')],{})[_0x4dbb('0x24')](respondWithResult(_0x4644a2,0xc9))['catch'](handleError(_0x4644a2,null));};exports['update']=function(_0x1b4b4c,_0x377171){if(_0x1b4b4c[_0x4dbb('0x49')]['id']){delete _0x1b4b4c[_0x4dbb('0x49')]['id'];}return db[_0x4dbb('0x2b')]['find']({'where':{'id':_0x1b4b4c['params']['id']}})[_0x4dbb('0x24')](handleEntityNotFound(_0x377171,null))[_0x4dbb('0x24')](saveUpdates(_0x1b4b4c[_0x4dbb('0x49')],null))['then'](respondWithResult(_0x377171,null))[_0x4dbb('0x42')](handleError(_0x377171,null));};exports[_0x4dbb('0x25')]=function(_0x58aec6,_0x3f56d8){return db[_0x4dbb('0x2b')]['find']({'where':{'id':_0x58aec6['params']['id']}})['then'](handleEntityNotFound(_0x3f56d8,null))[_0x4dbb('0x24')](removeEntity(_0x3f56d8,null))[_0x4dbb('0x42')](handleError(_0x3f56d8,null));};exports[_0x4dbb('0x4a')]=function(_0x5d5292,_0x9cc9ba,_0x31effe){var _0x4c8021={};var _0xe434a1={};var _0x2e94b3;var _0x577fbb;return db[_0x4dbb('0x2b')][_0x4dbb('0x4b')]({'where':{'id':_0x5d5292[_0x4dbb('0x44')]['id']}})[_0x4dbb('0x24')](handleEntityNotFound(_0x9cc9ba,null))[_0x4dbb('0x24')](function(_0x424e2d){if(_0x424e2d){_0x2e94b3=_0x424e2d;_0xe434a1[_0x4dbb('0x30')]=_[_0x4dbb('0x45')](db['FreshsalesField'][_0x4dbb('0x2c')]);_0xe434a1[_0x4dbb('0x31')]=_[_0x4dbb('0x45')](_0x5d5292[_0x4dbb('0x31')]);_0xe434a1['filters']=_[_0x4dbb('0x34')](_0xe434a1[_0x4dbb('0x30')],_0xe434a1[_0x4dbb('0x31')]);_0x4c8021['attributes']=_[_0x4dbb('0x34')](_0xe434a1[_0x4dbb('0x30')],qs[_0x4dbb('0x35')](_0x5d5292[_0x4dbb('0x31')][_0x4dbb('0x35')]));_0x4c8021[_0x4dbb('0x33')]=_0x4c8021[_0x4dbb('0x33')][_0x4dbb('0x36')]?_0x4c8021[_0x4dbb('0x33')]:_0xe434a1[_0x4dbb('0x30')];_0x4c8021['order']=qs['sort'](_0x5d5292[_0x4dbb('0x31')]['sort']);_0x4c8021[_0x4dbb('0x3b')]=qs[_0x4dbb('0x32')](_[_0x4dbb('0x4c')](_0x5d5292[_0x4dbb('0x31')],_0xe434a1[_0x4dbb('0x32')]));if(_0x5d5292[_0x4dbb('0x31')][_0x4dbb('0x4d')]){_0x4c8021['where']=_[_0x4dbb('0x3c')](_0x4c8021['where'],{'$or':_[_0x4dbb('0x2a')](_0x4c8021[_0x4dbb('0x33')],function(_0x58e5ed){var _0x4018bc={};_0x4018bc[_0x58e5ed]={'$like':'%'+_0x5d5292[_0x4dbb('0x31')][_0x4dbb('0x4d')]+'%'};return _0x4018bc;})});}_0x4c8021=_[_0x4dbb('0x3c')]({},_0x4c8021,_0x5d5292['options']);return _0x2e94b3[_0x4dbb('0x4a')](_0x4c8021);}})[_0x4dbb('0x24')](function(_0x3d597d){if(_0x3d597d){_0x577fbb=_0x3d597d[_0x4dbb('0x36')];if(!_0x5d5292[_0x4dbb('0x31')][_0x4dbb('0x37')](_0x4dbb('0x38'))){_0x4c8021[_0x4dbb('0x1e')]=qs[_0x4dbb('0x1e')](_0x5d5292[_0x4dbb('0x31')][_0x4dbb('0x1e')]);_0x4c8021[_0x4dbb('0x1c')]=qs[_0x4dbb('0x1c')](_0x5d5292['query']['offset']);}return _0x2e94b3[_0x4dbb('0x4a')](_0x4c8021);}})[_0x4dbb('0x24')](function(_0x25234a){if(_0x25234a){return _0x25234a?{'count':_0x577fbb,'rows':_0x25234a}:null;}})[_0x4dbb('0x24')](respondWithResult(_0x9cc9ba,null))[_0x4dbb('0x42')](handleError(_0x9cc9ba,null));};exports[_0x4dbb('0x4e')]=function(_0x5cd9aa,_0x7a449,_0x2d571b){var _0x2e9a11={};var _0x3f8745={};var _0x334a91;var _0x3d384a;return db[_0x4dbb('0x2b')][_0x4dbb('0x4b')]({'where':{'id':_0x5cd9aa['params']['id']}})['then'](handleEntityNotFound(_0x7a449,null))[_0x4dbb('0x24')](function(_0x35f9ef){if(_0x35f9ef){_0x334a91=_0x35f9ef;_0x3f8745[_0x4dbb('0x30')]=_['keys'](db['FreshsalesField'][_0x4dbb('0x2c')]);_0x3f8745[_0x4dbb('0x31')]=_[_0x4dbb('0x45')](_0x5cd9aa['query']);_0x3f8745[_0x4dbb('0x32')]=_[_0x4dbb('0x34')](_0x3f8745[_0x4dbb('0x30')],_0x3f8745[_0x4dbb('0x31')]);_0x2e9a11[_0x4dbb('0x33')]=_[_0x4dbb('0x34')](_0x3f8745['model'],qs[_0x4dbb('0x35')](_0x5cd9aa[_0x4dbb('0x31')]['fields']));_0x2e9a11[_0x4dbb('0x33')]=_0x2e9a11[_0x4dbb('0x33')][_0x4dbb('0x36')]?_0x2e9a11[_0x4dbb('0x33')]:_0x3f8745['model'];_0x2e9a11[_0x4dbb('0x39')]=qs[_0x4dbb('0x3a')](_0x5cd9aa[_0x4dbb('0x31')]['sort']);_0x2e9a11['where']=qs[_0x4dbb('0x32')](_[_0x4dbb('0x4c')](_0x5cd9aa['query'],_0x3f8745[_0x4dbb('0x32')]));if(_0x5cd9aa['query'][_0x4dbb('0x4d')]){_0x2e9a11[_0x4dbb('0x3b')]=_[_0x4dbb('0x3c')](_0x2e9a11[_0x4dbb('0x3b')],{'$or':_[_0x4dbb('0x2a')](_0x2e9a11[_0x4dbb('0x33')],function(_0x42e64d){var _0x3563e2={};_0x3563e2[_0x42e64d]={'$like':'%'+_0x5cd9aa[_0x4dbb('0x31')][_0x4dbb('0x4d')]+'%'};return _0x3563e2;})});}_0x2e9a11=_[_0x4dbb('0x3c')]({},_0x2e9a11,_0x5cd9aa[_0x4dbb('0x46')]);return _0x334a91[_0x4dbb('0x4e')](_0x2e9a11);}})['then'](function(_0xe47706){if(_0xe47706){_0x3d384a=_0xe47706[_0x4dbb('0x36')];if(!_0x5cd9aa[_0x4dbb('0x31')][_0x4dbb('0x37')](_0x4dbb('0x38'))){_0x2e9a11[_0x4dbb('0x1e')]=qs['limit'](_0x5cd9aa[_0x4dbb('0x31')][_0x4dbb('0x1e')]);_0x2e9a11['offset']=qs['offset'](_0x5cd9aa['query'][_0x4dbb('0x1c')]);}return _0x334a91['getDescriptions'](_0x2e9a11);}})[_0x4dbb('0x24')](function(_0x2f30cc){if(_0x2f30cc){return _0x2f30cc?{'count':_0x3d384a,'rows':_0x2f30cc}:null;}})['then'](respondWithResult(_0x7a449,null))[_0x4dbb('0x42')](handleError(_0x7a449,null));};exports[_0x4dbb('0x4f')]=function(_0x1be6c3,_0x5484b9,_0x2a89e0){var _0x2ed7e1={};var _0x388536={};var _0x4e9249;var _0x44983b;return db['FreshsalesConfiguration'][_0x4dbb('0x4b')]({'where':{'id':_0x1be6c3['params']['id']}})[_0x4dbb('0x24')](handleEntityNotFound(_0x5484b9,null))[_0x4dbb('0x24')](function(_0x42f08c){if(_0x42f08c){_0x4e9249=_0x42f08c;_0x388536['model']=_['keys'](db[_0x4dbb('0x50')][_0x4dbb('0x2c')]);_0x388536[_0x4dbb('0x31')]=_[_0x4dbb('0x45')](_0x1be6c3[_0x4dbb('0x31')]);_0x388536['filters']=_[_0x4dbb('0x34')](_0x388536[_0x4dbb('0x30')],_0x388536[_0x4dbb('0x31')]);_0x2ed7e1[_0x4dbb('0x33')]=_[_0x4dbb('0x34')](_0x388536[_0x4dbb('0x30')],qs[_0x4dbb('0x35')](_0x1be6c3[_0x4dbb('0x31')][_0x4dbb('0x35')]));_0x2ed7e1['attributes']=_0x2ed7e1['attributes'][_0x4dbb('0x36')]?_0x2ed7e1['attributes']:_0x388536[_0x4dbb('0x30')];_0x2ed7e1['order']=qs[_0x4dbb('0x3a')](_0x1be6c3[_0x4dbb('0x31')]['sort']);_0x2ed7e1[_0x4dbb('0x3b')]=qs[_0x4dbb('0x32')](_[_0x4dbb('0x4c')](_0x1be6c3[_0x4dbb('0x31')],_0x388536[_0x4dbb('0x32')]));if(_0x1be6c3['query']['filter']){_0x2ed7e1[_0x4dbb('0x3b')]=_['merge'](_0x2ed7e1[_0x4dbb('0x3b')],{'$or':_['map'](_0x2ed7e1[_0x4dbb('0x33')],function(_0xcce667){var _0x325b99={};_0x325b99[_0xcce667]={'$like':'%'+_0x1be6c3[_0x4dbb('0x31')]['filter']+'%'};return _0x325b99;})});}_0x2ed7e1=_[_0x4dbb('0x3c')]({},_0x2ed7e1,_0x1be6c3[_0x4dbb('0x46')]);return _0x4e9249[_0x4dbb('0x4f')](_0x2ed7e1);}})['then'](function(_0x365504){if(_0x365504){_0x44983b=_0x365504[_0x4dbb('0x36')];if(!_0x1be6c3[_0x4dbb('0x31')][_0x4dbb('0x37')](_0x4dbb('0x38'))){_0x2ed7e1['limit']=qs[_0x4dbb('0x1e')](_0x1be6c3['query'][_0x4dbb('0x1e')]);_0x2ed7e1['offset']=qs[_0x4dbb('0x1c')](_0x1be6c3[_0x4dbb('0x31')]['offset']);}return _0x4e9249[_0x4dbb('0x4f')](_0x2ed7e1);}})[_0x4dbb('0x24')](function(_0x165403){if(_0x165403){return _0x165403?{'count':_0x44983b,'rows':_0x165403}:null;}})[_0x4dbb('0x24')](respondWithResult(_0x5484b9,null))[_0x4dbb('0x42')](handleError(_0x5484b9,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