Built motion from commit 980b26c3.|2.6.29
[motion2.git] / server / api / intFreshsalesConfiguration / intFreshsalesConfiguration.controller.js
index 83e6f05..28a0d5a 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xe6ff=['count','set','Content-Range','json','apply','save','then','destroy','error','stack','name','send','index','map','FreshsalesConfiguration','rawAttributes','fieldName','type','key','model','keys','query','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','order','sort','where','pick','filter','merge','VIRTUAL','options','includeAll','findAll','rows','show','params','include','catch','create','body','update','find','getSubjects','findOne','FreshsalesField','getDescriptions','getFields','eml-format','rimraf','zip-dir','request-promise','moment','bluebird','mustache','path','sox','to-csv','ejs','fs-extra','lodash','squel','crypto','jsforce','desk.js','querystring','papaparse','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','sendStatus','status','end','offset','undefined','limit'];(function(_0x53f2a1,_0x3385ad){var _0x30ecfa=function(_0xb13736){while(--_0xb13736){_0x53f2a1['push'](_0x53f2a1['shift']());}};_0x30ecfa(++_0x3385ad);}(_0xe6ff,0x8d));var _0xfe6f=function(_0x2aea9e,_0x1f587f){_0x2aea9e=_0x2aea9e-0x0;var _0x430b92=_0xe6ff[_0x2aea9e];return _0x430b92;};'use strict';var emlformat=require(_0xfe6f('0x0'));var rimraf=require(_0xfe6f('0x1'));var zipdir=require(_0xfe6f('0x2'));var jsonpatch=require('fast-json-patch');var rp=require(_0xfe6f('0x3'));var moment=require(_0xfe6f('0x4'));var BPromise=require(_0xfe6f('0x5'));var Mustache=require(_0xfe6f('0x6'));var util=require('util');var path=require(_0xfe6f('0x7'));var sox=require(_0xfe6f('0x8'));var csv=require(_0xfe6f('0x9'));var ejs=require(_0xfe6f('0xa'));var fs=require('fs');var fs_extra=require(_0xfe6f('0xb'));var _=require(_0xfe6f('0xc'));var squel=require(_0xfe6f('0xd'));var crypto=require(_0xfe6f('0xe'));var jsforce=require(_0xfe6f('0xf'));var deskjs=require(_0xfe6f('0x10'));var toCsv=require(_0xfe6f('0x9'));var querystring=require(_0xfe6f('0x11'));var Papa=require(_0xfe6f('0x12'));var Redis=require('ioredis');var authService=require(_0xfe6f('0x13'));var qs=require(_0xfe6f('0x14'));var as=require(_0xfe6f('0x15'));var hardwareService=require(_0xfe6f('0x16'));var logger=require(_0xfe6f('0x17'))(_0xfe6f('0x18'));var utils=require(_0xfe6f('0x19'));var config=require(_0xfe6f('0x1a'));var licenseUtil=require(_0xfe6f('0x1b'));var db=require(_0xfe6f('0x1c'))['db'];function respondWithStatusCode(_0x2bd05c,_0x1fff95){_0x1fff95=_0x1fff95||0xcc;return function(_0x38a86b){if(_0x38a86b){return _0x2bd05c[_0xfe6f('0x1d')](_0x1fff95);}return _0x2bd05c[_0xfe6f('0x1e')](_0x1fff95)[_0xfe6f('0x1f')]();};}function respondWithResult(_0x1206b2,_0x17eb4f){_0x17eb4f=_0x17eb4f||0xc8;return function(_0x38d599){if(_0x38d599){return _0x1206b2[_0xfe6f('0x1e')](_0x17eb4f)['json'](_0x38d599);}};}function respondWithFilteredResult(_0x224fa9,_0x1a6643){return function(_0x43a6ce){if(_0x43a6ce){var _0x235da1=typeof _0x1a6643[_0xfe6f('0x20')]===_0xfe6f('0x21')&&typeof _0x1a6643[_0xfe6f('0x22')]==='undefined';var _0x5f39f5=_0x43a6ce[_0xfe6f('0x23')];var _0x3006c6=_0x235da1?0x0:_0x1a6643['offset'];var _0x213c3d=_0x235da1?_0x43a6ce[_0xfe6f('0x23')]:_0x1a6643[_0xfe6f('0x20')]+_0x1a6643[_0xfe6f('0x22')];var _0x138ecd;if(_0x213c3d>=_0x5f39f5){_0x213c3d=_0x5f39f5;_0x138ecd=0xc8;}else{_0x138ecd=0xce;}_0x224fa9[_0xfe6f('0x1e')](_0x138ecd);return _0x224fa9[_0xfe6f('0x24')](_0xfe6f('0x25'),_0x3006c6+'-'+_0x213c3d+'/'+_0x5f39f5)[_0xfe6f('0x26')](_0x43a6ce);}return null;};}function patchUpdates(_0x4a8b87){return function(_0x5b006f){try{jsonpatch[_0xfe6f('0x27')](_0x5b006f,_0x4a8b87,!![]);}catch(_0x90fd9c){return BPromise['reject'](_0x90fd9c);}return _0x5b006f[_0xfe6f('0x28')]();};}function saveUpdates(_0x389a04,_0x3eb524){return function(_0x4fdd38){if(_0x4fdd38){return _0x4fdd38['update'](_0x389a04)[_0xfe6f('0x29')](function(_0x1719ed){return _0x1719ed;});}return null;};}function removeEntity(_0x58756b,_0x3a5f8c){return function(_0x1637dd){if(_0x1637dd){return _0x1637dd[_0xfe6f('0x2a')]()['then'](function(){_0x58756b[_0xfe6f('0x1e')](0xcc)[_0xfe6f('0x1f')]();});}};}function handleEntityNotFound(_0x1d6c24,_0x1ccca3){return function(_0x275e04){if(!_0x275e04){_0x1d6c24[_0xfe6f('0x1d')](0x194);}return _0x275e04;};}function handleError(_0x585c1a,_0x2afcaa){_0x2afcaa=_0x2afcaa||0x1f4;return function(_0x9b9211){logger[_0xfe6f('0x2b')](_0x9b9211[_0xfe6f('0x2c')]);if(_0x9b9211['name']){delete _0x9b9211[_0xfe6f('0x2d')];}_0x585c1a[_0xfe6f('0x1e')](_0x2afcaa)[_0xfe6f('0x2e')](_0x9b9211);};}exports[_0xfe6f('0x2f')]=function(_0x1d3d7a,_0x44d3a8){var _0x5def2b={},_0x2cdc0d={},_0x3df1a2={'count':0x0,'rows':[]};var _0x144274=_[_0xfe6f('0x30')](db[_0xfe6f('0x31')][_0xfe6f('0x32')],function(_0x4b068f){return{'name':_0x4b068f[_0xfe6f('0x33')],'type':_0x4b068f[_0xfe6f('0x34')][_0xfe6f('0x35')]};});_0x2cdc0d[_0xfe6f('0x36')]=_[_0xfe6f('0x30')](_0x144274,'name');_0x2cdc0d['query']=_[_0xfe6f('0x37')](_0x1d3d7a[_0xfe6f('0x38')]);_0x2cdc0d[_0xfe6f('0x39')]=_[_0xfe6f('0x3a')](_0x2cdc0d[_0xfe6f('0x36')],_0x2cdc0d[_0xfe6f('0x38')]);_0x5def2b[_0xfe6f('0x3b')]=_['intersection'](_0x2cdc0d[_0xfe6f('0x36')],qs['fields'](_0x1d3d7a[_0xfe6f('0x38')][_0xfe6f('0x3c')]));_0x5def2b[_0xfe6f('0x3b')]=_0x5def2b[_0xfe6f('0x3b')][_0xfe6f('0x3d')]?_0x5def2b[_0xfe6f('0x3b')]:_0x2cdc0d[_0xfe6f('0x36')];if(!_0x1d3d7a[_0xfe6f('0x38')][_0xfe6f('0x3e')](_0xfe6f('0x3f'))){_0x5def2b[_0xfe6f('0x22')]=qs[_0xfe6f('0x22')](_0x1d3d7a['query'][_0xfe6f('0x22')]);_0x5def2b[_0xfe6f('0x20')]=qs[_0xfe6f('0x20')](_0x1d3d7a[_0xfe6f('0x38')][_0xfe6f('0x20')]);}_0x5def2b[_0xfe6f('0x40')]=qs[_0xfe6f('0x41')](_0x1d3d7a[_0xfe6f('0x38')][_0xfe6f('0x41')]);_0x5def2b[_0xfe6f('0x42')]=qs[_0xfe6f('0x39')](_[_0xfe6f('0x43')](_0x1d3d7a[_0xfe6f('0x38')],_0x2cdc0d[_0xfe6f('0x39')]),_0x144274);if(_0x1d3d7a[_0xfe6f('0x38')][_0xfe6f('0x44')]){_0x5def2b[_0xfe6f('0x42')]=_[_0xfe6f('0x45')](_0x5def2b[_0xfe6f('0x42')],{'$or':_[_0xfe6f('0x30')](_0x144274,function(_0x1991ac){if(_0x1991ac[_0xfe6f('0x34')]!==_0xfe6f('0x46')){var _0xcadbdd={};_0xcadbdd[_0x1991ac['name']]={'$like':'%'+_0x1d3d7a['query'][_0xfe6f('0x44')]+'%'};return _0xcadbdd;}})});}_0x5def2b=_[_0xfe6f('0x45')]({},_0x5def2b,_0x1d3d7a[_0xfe6f('0x47')]);var _0x15860f={'where':_0x5def2b[_0xfe6f('0x42')]};return db['FreshsalesConfiguration'][_0xfe6f('0x23')](_0x15860f)[_0xfe6f('0x29')](function(_0x5c1908){_0x3df1a2['count']=_0x5c1908;if(_0x1d3d7a[_0xfe6f('0x38')][_0xfe6f('0x48')]){_0x5def2b['include']=[{'all':!![]}];}return db[_0xfe6f('0x31')][_0xfe6f('0x49')](_0x5def2b);})[_0xfe6f('0x29')](function(_0xa56fad){_0x3df1a2[_0xfe6f('0x4a')]=_0xa56fad;return _0x3df1a2;})[_0xfe6f('0x29')](respondWithFilteredResult(_0x44d3a8,_0x5def2b))['catch'](handleError(_0x44d3a8,null));};exports[_0xfe6f('0x4b')]=function(_0x59cc98,_0x4eb0cd){var _0x2d79cc={'raw':![],'where':{'id':_0x59cc98[_0xfe6f('0x4c')]['id']}},_0x4559c0={};_0x4559c0[_0xfe6f('0x36')]=_[_0xfe6f('0x37')](db[_0xfe6f('0x31')]['rawAttributes']);_0x4559c0[_0xfe6f('0x38')]=_[_0xfe6f('0x37')](_0x59cc98[_0xfe6f('0x38')]);_0x4559c0[_0xfe6f('0x39')]=_[_0xfe6f('0x3a')](_0x4559c0[_0xfe6f('0x36')],_0x4559c0[_0xfe6f('0x38')]);_0x2d79cc[_0xfe6f('0x3b')]=_[_0xfe6f('0x3a')](_0x4559c0[_0xfe6f('0x36')],qs[_0xfe6f('0x3c')](_0x59cc98[_0xfe6f('0x38')]['fields']));_0x2d79cc[_0xfe6f('0x3b')]=_0x2d79cc['attributes'][_0xfe6f('0x3d')]?_0x2d79cc['attributes']:_0x4559c0[_0xfe6f('0x36')];if(_0x59cc98['query'][_0xfe6f('0x48')]){_0x2d79cc[_0xfe6f('0x4d')]=[{'all':!![]}];}_0x2d79cc=_[_0xfe6f('0x45')]({},_0x2d79cc,_0x59cc98[_0xfe6f('0x47')]);return db[_0xfe6f('0x31')]['find'](_0x2d79cc)[_0xfe6f('0x29')](handleEntityNotFound(_0x4eb0cd,null))[_0xfe6f('0x29')](respondWithResult(_0x4eb0cd,null))[_0xfe6f('0x4e')](handleError(_0x4eb0cd,null));};exports[_0xfe6f('0x4f')]=function(_0x32d0e4,_0x1e60bd){return db[_0xfe6f('0x31')][_0xfe6f('0x4f')](_0x32d0e4[_0xfe6f('0x50')],{})[_0xfe6f('0x29')](respondWithResult(_0x1e60bd,0xc9))[_0xfe6f('0x4e')](handleError(_0x1e60bd,null));};exports[_0xfe6f('0x51')]=function(_0x27c38e,_0x2c9483){if(_0x27c38e['body']['id']){delete _0x27c38e[_0xfe6f('0x50')]['id'];}return db[_0xfe6f('0x31')][_0xfe6f('0x52')]({'where':{'id':_0x27c38e[_0xfe6f('0x4c')]['id']}})[_0xfe6f('0x29')](handleEntityNotFound(_0x2c9483,null))[_0xfe6f('0x29')](saveUpdates(_0x27c38e['body'],null))[_0xfe6f('0x29')](respondWithResult(_0x2c9483,null))['catch'](handleError(_0x2c9483,null));};exports[_0xfe6f('0x2a')]=function(_0x53352b,_0x4241a7){return db[_0xfe6f('0x31')][_0xfe6f('0x52')]({'where':{'id':_0x53352b[_0xfe6f('0x4c')]['id']}})[_0xfe6f('0x29')](handleEntityNotFound(_0x4241a7,null))['then'](removeEntity(_0x4241a7,null))['catch'](handleError(_0x4241a7,null));};exports[_0xfe6f('0x53')]=function(_0x1468c1,_0x3d5c72,_0x263eb0){var _0x4af221={};var _0x54c09b={};var _0x26e918;var _0x29febb;return db['FreshsalesConfiguration'][_0xfe6f('0x54')]({'where':{'id':_0x1468c1[_0xfe6f('0x4c')]['id']}})[_0xfe6f('0x29')](handleEntityNotFound(_0x3d5c72,null))[_0xfe6f('0x29')](function(_0x1a383c){if(_0x1a383c){_0x26e918=_0x1a383c;_0x54c09b[_0xfe6f('0x36')]=_[_0xfe6f('0x37')](db[_0xfe6f('0x55')][_0xfe6f('0x32')]);_0x54c09b[_0xfe6f('0x38')]=_[_0xfe6f('0x37')](_0x1468c1[_0xfe6f('0x38')]);_0x54c09b[_0xfe6f('0x39')]=_[_0xfe6f('0x3a')](_0x54c09b[_0xfe6f('0x36')],_0x54c09b[_0xfe6f('0x38')]);_0x4af221[_0xfe6f('0x3b')]=_[_0xfe6f('0x3a')](_0x54c09b[_0xfe6f('0x36')],qs[_0xfe6f('0x3c')](_0x1468c1['query'][_0xfe6f('0x3c')]));_0x4af221[_0xfe6f('0x3b')]=_0x4af221[_0xfe6f('0x3b')]['length']?_0x4af221[_0xfe6f('0x3b')]:_0x54c09b[_0xfe6f('0x36')];_0x4af221['order']=qs[_0xfe6f('0x41')](_0x1468c1[_0xfe6f('0x38')][_0xfe6f('0x41')]);_0x4af221[_0xfe6f('0x42')]=qs['filters'](_[_0xfe6f('0x43')](_0x1468c1[_0xfe6f('0x38')],_0x54c09b[_0xfe6f('0x39')]));if(_0x1468c1[_0xfe6f('0x38')][_0xfe6f('0x44')]){_0x4af221[_0xfe6f('0x42')]=_[_0xfe6f('0x45')](_0x4af221[_0xfe6f('0x42')],{'$or':_[_0xfe6f('0x30')](_0x4af221[_0xfe6f('0x3b')],function(_0x4a5a17){var _0x413c93={};_0x413c93[_0x4a5a17]={'$like':'%'+_0x1468c1['query'][_0xfe6f('0x44')]+'%'};return _0x413c93;})});}_0x4af221=_[_0xfe6f('0x45')]({},_0x4af221,_0x1468c1[_0xfe6f('0x47')]);return _0x26e918[_0xfe6f('0x53')](_0x4af221);}})[_0xfe6f('0x29')](function(_0x25a6ea){if(_0x25a6ea){_0x29febb=_0x25a6ea[_0xfe6f('0x3d')];if(!_0x1468c1['query'][_0xfe6f('0x3e')](_0xfe6f('0x3f'))){_0x4af221[_0xfe6f('0x22')]=qs[_0xfe6f('0x22')](_0x1468c1[_0xfe6f('0x38')][_0xfe6f('0x22')]);_0x4af221['offset']=qs[_0xfe6f('0x20')](_0x1468c1[_0xfe6f('0x38')][_0xfe6f('0x20')]);}return _0x26e918[_0xfe6f('0x53')](_0x4af221);}})[_0xfe6f('0x29')](function(_0x1336eb){if(_0x1336eb){return _0x1336eb?{'count':_0x29febb,'rows':_0x1336eb}:null;}})[_0xfe6f('0x29')](respondWithResult(_0x3d5c72,null))[_0xfe6f('0x4e')](handleError(_0x3d5c72,null));};exports['getDescriptions']=function(_0x5d2b3e,_0x3a75f2,_0x231846){var _0x128460={};var _0x582cd2={};var _0x58c0d2;var _0x272177;return db[_0xfe6f('0x31')]['findOne']({'where':{'id':_0x5d2b3e[_0xfe6f('0x4c')]['id']}})[_0xfe6f('0x29')](handleEntityNotFound(_0x3a75f2,null))['then'](function(_0x3debf3){if(_0x3debf3){_0x58c0d2=_0x3debf3;_0x582cd2[_0xfe6f('0x36')]=_['keys'](db[_0xfe6f('0x55')]['rawAttributes']);_0x582cd2[_0xfe6f('0x38')]=_[_0xfe6f('0x37')](_0x5d2b3e[_0xfe6f('0x38')]);_0x582cd2[_0xfe6f('0x39')]=_[_0xfe6f('0x3a')](_0x582cd2[_0xfe6f('0x36')],_0x582cd2[_0xfe6f('0x38')]);_0x128460[_0xfe6f('0x3b')]=_[_0xfe6f('0x3a')](_0x582cd2[_0xfe6f('0x36')],qs[_0xfe6f('0x3c')](_0x5d2b3e[_0xfe6f('0x38')][_0xfe6f('0x3c')]));_0x128460['attributes']=_0x128460[_0xfe6f('0x3b')][_0xfe6f('0x3d')]?_0x128460['attributes']:_0x582cd2[_0xfe6f('0x36')];_0x128460[_0xfe6f('0x40')]=qs[_0xfe6f('0x41')](_0x5d2b3e['query']['sort']);_0x128460[_0xfe6f('0x42')]=qs[_0xfe6f('0x39')](_[_0xfe6f('0x43')](_0x5d2b3e[_0xfe6f('0x38')],_0x582cd2[_0xfe6f('0x39')]));if(_0x5d2b3e[_0xfe6f('0x38')][_0xfe6f('0x44')]){_0x128460[_0xfe6f('0x42')]=_['merge'](_0x128460[_0xfe6f('0x42')],{'$or':_['map'](_0x128460[_0xfe6f('0x3b')],function(_0x411558){var _0x2efba3={};_0x2efba3[_0x411558]={'$like':'%'+_0x5d2b3e[_0xfe6f('0x38')]['filter']+'%'};return _0x2efba3;})});}_0x128460=_[_0xfe6f('0x45')]({},_0x128460,_0x5d2b3e[_0xfe6f('0x47')]);return _0x58c0d2[_0xfe6f('0x56')](_0x128460);}})[_0xfe6f('0x29')](function(_0x5108ee){if(_0x5108ee){_0x272177=_0x5108ee['length'];if(!_0x5d2b3e[_0xfe6f('0x38')][_0xfe6f('0x3e')](_0xfe6f('0x3f'))){_0x128460[_0xfe6f('0x22')]=qs[_0xfe6f('0x22')](_0x5d2b3e[_0xfe6f('0x38')]['limit']);_0x128460['offset']=qs['offset'](_0x5d2b3e[_0xfe6f('0x38')]['offset']);}return _0x58c0d2[_0xfe6f('0x56')](_0x128460);}})['then'](function(_0x15f831){if(_0x15f831){return _0x15f831?{'count':_0x272177,'rows':_0x15f831}:null;}})['then'](respondWithResult(_0x3a75f2,null))[_0xfe6f('0x4e')](handleError(_0x3a75f2,null));};exports[_0xfe6f('0x57')]=function(_0x24760c,_0x16fd9,_0x122a3b){var _0x29dd28={};var _0xa8e804={};var _0x2fc9ae;var _0x43a2dc;return db['FreshsalesConfiguration'][_0xfe6f('0x54')]({'where':{'id':_0x24760c[_0xfe6f('0x4c')]['id']}})[_0xfe6f('0x29')](handleEntityNotFound(_0x16fd9,null))[_0xfe6f('0x29')](function(_0xcec1d6){if(_0xcec1d6){_0x2fc9ae=_0xcec1d6;_0xa8e804['model']=_['keys'](db[_0xfe6f('0x55')][_0xfe6f('0x32')]);_0xa8e804['query']=_['keys'](_0x24760c[_0xfe6f('0x38')]);_0xa8e804[_0xfe6f('0x39')]=_[_0xfe6f('0x3a')](_0xa8e804['model'],_0xa8e804[_0xfe6f('0x38')]);_0x29dd28[_0xfe6f('0x3b')]=_[_0xfe6f('0x3a')](_0xa8e804[_0xfe6f('0x36')],qs['fields'](_0x24760c[_0xfe6f('0x38')][_0xfe6f('0x3c')]));_0x29dd28[_0xfe6f('0x3b')]=_0x29dd28[_0xfe6f('0x3b')][_0xfe6f('0x3d')]?_0x29dd28[_0xfe6f('0x3b')]:_0xa8e804[_0xfe6f('0x36')];_0x29dd28[_0xfe6f('0x40')]=qs[_0xfe6f('0x41')](_0x24760c[_0xfe6f('0x38')][_0xfe6f('0x41')]);_0x29dd28[_0xfe6f('0x42')]=qs['filters'](_['pick'](_0x24760c[_0xfe6f('0x38')],_0xa8e804[_0xfe6f('0x39')]));if(_0x24760c[_0xfe6f('0x38')][_0xfe6f('0x44')]){_0x29dd28[_0xfe6f('0x42')]=_[_0xfe6f('0x45')](_0x29dd28[_0xfe6f('0x42')],{'$or':_[_0xfe6f('0x30')](_0x29dd28[_0xfe6f('0x3b')],function(_0x2859b5){var _0x51408c={};_0x51408c[_0x2859b5]={'$like':'%'+_0x24760c[_0xfe6f('0x38')][_0xfe6f('0x44')]+'%'};return _0x51408c;})});}_0x29dd28=_[_0xfe6f('0x45')]({},_0x29dd28,_0x24760c['options']);return _0x2fc9ae[_0xfe6f('0x57')](_0x29dd28);}})['then'](function(_0x4bfa0b){if(_0x4bfa0b){_0x43a2dc=_0x4bfa0b[_0xfe6f('0x3d')];if(!_0x24760c[_0xfe6f('0x38')][_0xfe6f('0x3e')](_0xfe6f('0x3f'))){_0x29dd28[_0xfe6f('0x22')]=qs[_0xfe6f('0x22')](_0x24760c['query'][_0xfe6f('0x22')]);_0x29dd28[_0xfe6f('0x20')]=qs[_0xfe6f('0x20')](_0x24760c[_0xfe6f('0x38')][_0xfe6f('0x20')]);}return _0x2fc9ae[_0xfe6f('0x57')](_0x29dd28);}})[_0xfe6f('0x29')](function(_0x193582){if(_0x193582){return _0x193582?{'count':_0x43a2dc,'rows':_0x193582}:null;}})[_0xfe6f('0x29')](respondWithResult(_0x16fd9,null))[_0xfe6f('0x4e')](handleError(_0x16fd9,null));};
\ No newline at end of file
+var _0xf20f=['json','offset','limit','undefined','count','set','Content-Range','apply','reject','save','update','then','error','stack','name','send','index','map','fieldName','type','model','keys','query','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','order','sort','where','pick','filter','merge','VIRTUAL','FreshsalesConfiguration','includeAll','rows','params','include','options','find','catch','create','body','FreshsalesField','rawAttributes','getSubjects','getDescriptions','getFields','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','sox','to-csv','lodash','crypto','jsforce','desk.js','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','sendStatus','status','end'];(function(_0x27fdf5,_0x354ff1){var _0x257cf2=function(_0x5bd1b8){while(--_0x5bd1b8){_0x27fdf5['push'](_0x27fdf5['shift']());}};_0x257cf2(++_0x354ff1);}(_0xf20f,0x1c9));var _0xff20=function(_0x299f1e,_0x341eff){_0x299f1e=_0x299f1e-0x0;var _0x1789fa=_0xf20f[_0x299f1e];return _0x1789fa;};'use strict';var emlformat=require(_0xff20('0x0'));var rimraf=require(_0xff20('0x1'));var zipdir=require(_0xff20('0x2'));var jsonpatch=require(_0xff20('0x3'));var rp=require(_0xff20('0x4'));var moment=require(_0xff20('0x5'));var BPromise=require(_0xff20('0x6'));var Mustache=require(_0xff20('0x7'));var util=require(_0xff20('0x8'));var path=require(_0xff20('0x9'));var sox=require(_0xff20('0xa'));var csv=require(_0xff20('0xb'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0xff20('0xc'));var squel=require('squel');var crypto=require(_0xff20('0xd'));var jsforce=require(_0xff20('0xe'));var deskjs=require(_0xff20('0xf'));var toCsv=require(_0xff20('0xb'));var querystring=require('querystring');var Papa=require('papaparse');var Redis=require(_0xff20('0x10'));var authService=require(_0xff20('0x11'));var qs=require(_0xff20('0x12'));var as=require(_0xff20('0x13'));var hardwareService=require(_0xff20('0x14'));var logger=require('../../config/logger')(_0xff20('0x15'));var utils=require(_0xff20('0x16'));var config=require(_0xff20('0x17'));var licenseUtil=require(_0xff20('0x18'));var db=require(_0xff20('0x19'))['db'];function respondWithStatusCode(_0x1ab2cc,_0x42b2fc){_0x42b2fc=_0x42b2fc||0xcc;return function(_0x326b9c){if(_0x326b9c){return _0x1ab2cc[_0xff20('0x1a')](_0x42b2fc);}return _0x1ab2cc[_0xff20('0x1b')](_0x42b2fc)[_0xff20('0x1c')]();};}function respondWithResult(_0x5a1bee,_0x11e026){_0x11e026=_0x11e026||0xc8;return function(_0x32efd9){if(_0x32efd9){return _0x5a1bee[_0xff20('0x1b')](_0x11e026)[_0xff20('0x1d')](_0x32efd9);}};}function respondWithFilteredResult(_0x4f9c14,_0x56455e){return function(_0x33c2ff){if(_0x33c2ff){var _0x332505=typeof _0x56455e[_0xff20('0x1e')]==='undefined'&&typeof _0x56455e[_0xff20('0x1f')]===_0xff20('0x20');var _0xa01582=_0x33c2ff[_0xff20('0x21')];var _0x3684ae=_0x332505?0x0:_0x56455e[_0xff20('0x1e')];var _0x12ac50=_0x332505?_0x33c2ff[_0xff20('0x21')]:_0x56455e['offset']+_0x56455e['limit'];var _0x3223b4;if(_0x12ac50>=_0xa01582){_0x12ac50=_0xa01582;_0x3223b4=0xc8;}else{_0x3223b4=0xce;}_0x4f9c14[_0xff20('0x1b')](_0x3223b4);return _0x4f9c14[_0xff20('0x22')](_0xff20('0x23'),_0x3684ae+'-'+_0x12ac50+'/'+_0xa01582)[_0xff20('0x1d')](_0x33c2ff);}return null;};}function patchUpdates(_0x496fd2){return function(_0x2ecffb){try{jsonpatch[_0xff20('0x24')](_0x2ecffb,_0x496fd2,!![]);}catch(_0x23f4be){return BPromise[_0xff20('0x25')](_0x23f4be);}return _0x2ecffb[_0xff20('0x26')]();};}function saveUpdates(_0x2edac4,_0xfd65f1){return function(_0x515811){if(_0x515811){return _0x515811[_0xff20('0x27')](_0x2edac4)[_0xff20('0x28')](function(_0x4ab3d2){return _0x4ab3d2;});}return null;};}function removeEntity(_0x5037c2,_0x443fe9){return function(_0x1f26ef){if(_0x1f26ef){return _0x1f26ef['destroy']()['then'](function(){_0x5037c2[_0xff20('0x1b')](0xcc)[_0xff20('0x1c')]();});}};}function handleEntityNotFound(_0x268df5,_0x426a37){return function(_0x40d8c1){if(!_0x40d8c1){_0x268df5[_0xff20('0x1a')](0x194);}return _0x40d8c1;};}function handleError(_0x425c33,_0x5c1f8b){_0x5c1f8b=_0x5c1f8b||0x1f4;return function(_0x15773c){logger[_0xff20('0x29')](_0x15773c[_0xff20('0x2a')]);if(_0x15773c[_0xff20('0x2b')]){delete _0x15773c[_0xff20('0x2b')];}_0x425c33[_0xff20('0x1b')](_0x5c1f8b)[_0xff20('0x2c')](_0x15773c);};}exports[_0xff20('0x2d')]=function(_0x20aa1a,_0x226ef8){var _0x968290={},_0x1b0137={},_0x3bd90c={'count':0x0,'rows':[]};var _0x15cad3=_[_0xff20('0x2e')](db['FreshsalesConfiguration']['rawAttributes'],function(_0x3ba56f){return{'name':_0x3ba56f[_0xff20('0x2f')],'type':_0x3ba56f[_0xff20('0x30')]['key']};});_0x1b0137[_0xff20('0x31')]=_['map'](_0x15cad3,_0xff20('0x2b'));_0x1b0137['query']=_[_0xff20('0x32')](_0x20aa1a[_0xff20('0x33')]);_0x1b0137[_0xff20('0x34')]=_[_0xff20('0x35')](_0x1b0137[_0xff20('0x31')],_0x1b0137[_0xff20('0x33')]);_0x968290[_0xff20('0x36')]=_['intersection'](_0x1b0137[_0xff20('0x31')],qs[_0xff20('0x37')](_0x20aa1a[_0xff20('0x33')][_0xff20('0x37')]));_0x968290[_0xff20('0x36')]=_0x968290[_0xff20('0x36')][_0xff20('0x38')]?_0x968290['attributes']:_0x1b0137[_0xff20('0x31')];if(!_0x20aa1a[_0xff20('0x33')][_0xff20('0x39')](_0xff20('0x3a'))){_0x968290['limit']=qs[_0xff20('0x1f')](_0x20aa1a[_0xff20('0x33')][_0xff20('0x1f')]);_0x968290[_0xff20('0x1e')]=qs['offset'](_0x20aa1a[_0xff20('0x33')][_0xff20('0x1e')]);}_0x968290[_0xff20('0x3b')]=qs[_0xff20('0x3c')](_0x20aa1a[_0xff20('0x33')][_0xff20('0x3c')]);_0x968290[_0xff20('0x3d')]=qs[_0xff20('0x34')](_[_0xff20('0x3e')](_0x20aa1a[_0xff20('0x33')],_0x1b0137[_0xff20('0x34')]),_0x15cad3);if(_0x20aa1a[_0xff20('0x33')][_0xff20('0x3f')]){_0x968290[_0xff20('0x3d')]=_[_0xff20('0x40')](_0x968290[_0xff20('0x3d')],{'$or':_[_0xff20('0x2e')](_0x15cad3,function(_0x338599){if(_0x338599[_0xff20('0x30')]!==_0xff20('0x41')){var _0x4ef362={};_0x4ef362[_0x338599['name']]={'$like':'%'+_0x20aa1a[_0xff20('0x33')][_0xff20('0x3f')]+'%'};return _0x4ef362;}})});}_0x968290=_[_0xff20('0x40')]({},_0x968290,_0x20aa1a['options']);var _0x2dbae8={'where':_0x968290[_0xff20('0x3d')]};return db[_0xff20('0x42')][_0xff20('0x21')](_0x2dbae8)[_0xff20('0x28')](function(_0x4b871e){_0x3bd90c[_0xff20('0x21')]=_0x4b871e;if(_0x20aa1a[_0xff20('0x33')][_0xff20('0x43')]){_0x968290['include']=[{'all':!![]}];}return db[_0xff20('0x42')]['findAll'](_0x968290);})[_0xff20('0x28')](function(_0x4686af){_0x3bd90c[_0xff20('0x44')]=_0x4686af;return _0x3bd90c;})[_0xff20('0x28')](respondWithFilteredResult(_0x226ef8,_0x968290))['catch'](handleError(_0x226ef8,null));};exports['show']=function(_0x2439d6,_0x40f17c){var _0xfb3ead={'raw':![],'where':{'id':_0x2439d6[_0xff20('0x45')]['id']}},_0x1fe98b={};_0x1fe98b['model']=_[_0xff20('0x32')](db[_0xff20('0x42')]['rawAttributes']);_0x1fe98b[_0xff20('0x33')]=_[_0xff20('0x32')](_0x2439d6[_0xff20('0x33')]);_0x1fe98b[_0xff20('0x34')]=_[_0xff20('0x35')](_0x1fe98b[_0xff20('0x31')],_0x1fe98b[_0xff20('0x33')]);_0xfb3ead[_0xff20('0x36')]=_[_0xff20('0x35')](_0x1fe98b['model'],qs['fields'](_0x2439d6[_0xff20('0x33')][_0xff20('0x37')]));_0xfb3ead[_0xff20('0x36')]=_0xfb3ead[_0xff20('0x36')][_0xff20('0x38')]?_0xfb3ead[_0xff20('0x36')]:_0x1fe98b[_0xff20('0x31')];if(_0x2439d6['query'][_0xff20('0x43')]){_0xfb3ead[_0xff20('0x46')]=[{'all':!![]}];}_0xfb3ead=_[_0xff20('0x40')]({},_0xfb3ead,_0x2439d6[_0xff20('0x47')]);return db[_0xff20('0x42')][_0xff20('0x48')](_0xfb3ead)['then'](handleEntityNotFound(_0x40f17c,null))[_0xff20('0x28')](respondWithResult(_0x40f17c,null))[_0xff20('0x49')](handleError(_0x40f17c,null));};exports['create']=function(_0x195cab,_0xa99631){return db['FreshsalesConfiguration'][_0xff20('0x4a')](_0x195cab[_0xff20('0x4b')],{})[_0xff20('0x28')](respondWithResult(_0xa99631,0xc9))['catch'](handleError(_0xa99631,null));};exports[_0xff20('0x27')]=function(_0x2f4e75,_0x2a7a68){if(_0x2f4e75['body']['id']){delete _0x2f4e75[_0xff20('0x4b')]['id'];}return db['FreshsalesConfiguration'][_0xff20('0x48')]({'where':{'id':_0x2f4e75[_0xff20('0x45')]['id']}})[_0xff20('0x28')](handleEntityNotFound(_0x2a7a68,null))[_0xff20('0x28')](saveUpdates(_0x2f4e75[_0xff20('0x4b')],null))[_0xff20('0x28')](respondWithResult(_0x2a7a68,null))['catch'](handleError(_0x2a7a68,null));};exports['destroy']=function(_0x263e65,_0x1244ee){return db['FreshsalesConfiguration'][_0xff20('0x48')]({'where':{'id':_0x263e65[_0xff20('0x45')]['id']}})[_0xff20('0x28')](handleEntityNotFound(_0x1244ee,null))['then'](removeEntity(_0x1244ee,null))[_0xff20('0x49')](handleError(_0x1244ee,null));};exports['getSubjects']=function(_0x4d4104,_0xf28e3f,_0x43e44e){var _0x1bcf51={};var _0x1c1534={};var _0x33be42;var _0x1399ad;return db[_0xff20('0x42')]['findOne']({'where':{'id':_0x4d4104[_0xff20('0x45')]['id']}})[_0xff20('0x28')](handleEntityNotFound(_0xf28e3f,null))[_0xff20('0x28')](function(_0x31faf4){if(_0x31faf4){_0x33be42=_0x31faf4;_0x1c1534[_0xff20('0x31')]=_[_0xff20('0x32')](db[_0xff20('0x4c')][_0xff20('0x4d')]);_0x1c1534[_0xff20('0x33')]=_[_0xff20('0x32')](_0x4d4104[_0xff20('0x33')]);_0x1c1534[_0xff20('0x34')]=_[_0xff20('0x35')](_0x1c1534['model'],_0x1c1534[_0xff20('0x33')]);_0x1bcf51[_0xff20('0x36')]=_['intersection'](_0x1c1534[_0xff20('0x31')],qs[_0xff20('0x37')](_0x4d4104[_0xff20('0x33')][_0xff20('0x37')]));_0x1bcf51[_0xff20('0x36')]=_0x1bcf51['attributes']['length']?_0x1bcf51[_0xff20('0x36')]:_0x1c1534['model'];_0x1bcf51[_0xff20('0x3b')]=qs['sort'](_0x4d4104['query'][_0xff20('0x3c')]);_0x1bcf51['where']=qs['filters'](_[_0xff20('0x3e')](_0x4d4104[_0xff20('0x33')],_0x1c1534[_0xff20('0x34')]));if(_0x4d4104['query'][_0xff20('0x3f')]){_0x1bcf51[_0xff20('0x3d')]=_['merge'](_0x1bcf51[_0xff20('0x3d')],{'$or':_[_0xff20('0x2e')](_0x1bcf51['attributes'],function(_0x2a4fb2){var _0x24bf15={};_0x24bf15[_0x2a4fb2]={'$like':'%'+_0x4d4104['query'][_0xff20('0x3f')]+'%'};return _0x24bf15;})});}_0x1bcf51=_['merge']({},_0x1bcf51,_0x4d4104[_0xff20('0x47')]);return _0x33be42[_0xff20('0x4e')](_0x1bcf51);}})[_0xff20('0x28')](function(_0x288f88){if(_0x288f88){_0x1399ad=_0x288f88[_0xff20('0x38')];if(!_0x4d4104['query'][_0xff20('0x39')](_0xff20('0x3a'))){_0x1bcf51[_0xff20('0x1f')]=qs[_0xff20('0x1f')](_0x4d4104[_0xff20('0x33')][_0xff20('0x1f')]);_0x1bcf51[_0xff20('0x1e')]=qs['offset'](_0x4d4104[_0xff20('0x33')][_0xff20('0x1e')]);}return _0x33be42[_0xff20('0x4e')](_0x1bcf51);}})['then'](function(_0x442e4a){if(_0x442e4a){return _0x442e4a?{'count':_0x1399ad,'rows':_0x442e4a}:null;}})[_0xff20('0x28')](respondWithResult(_0xf28e3f,null))['catch'](handleError(_0xf28e3f,null));};exports[_0xff20('0x4f')]=function(_0x54c0a3,_0x52bc4d,_0xdcf72f){var _0xddde16={};var _0x540e75={};var _0x52649f;var _0x288eb9;return db[_0xff20('0x42')]['findOne']({'where':{'id':_0x54c0a3[_0xff20('0x45')]['id']}})[_0xff20('0x28')](handleEntityNotFound(_0x52bc4d,null))['then'](function(_0x3442a7){if(_0x3442a7){_0x52649f=_0x3442a7;_0x540e75[_0xff20('0x31')]=_[_0xff20('0x32')](db['FreshsalesField'][_0xff20('0x4d')]);_0x540e75[_0xff20('0x33')]=_[_0xff20('0x32')](_0x54c0a3['query']);_0x540e75['filters']=_[_0xff20('0x35')](_0x540e75[_0xff20('0x31')],_0x540e75[_0xff20('0x33')]);_0xddde16[_0xff20('0x36')]=_[_0xff20('0x35')](_0x540e75['model'],qs['fields'](_0x54c0a3[_0xff20('0x33')][_0xff20('0x37')]));_0xddde16[_0xff20('0x36')]=_0xddde16[_0xff20('0x36')]['length']?_0xddde16[_0xff20('0x36')]:_0x540e75[_0xff20('0x31')];_0xddde16['order']=qs[_0xff20('0x3c')](_0x54c0a3[_0xff20('0x33')][_0xff20('0x3c')]);_0xddde16['where']=qs[_0xff20('0x34')](_[_0xff20('0x3e')](_0x54c0a3[_0xff20('0x33')],_0x540e75[_0xff20('0x34')]));if(_0x54c0a3[_0xff20('0x33')][_0xff20('0x3f')]){_0xddde16[_0xff20('0x3d')]=_[_0xff20('0x40')](_0xddde16[_0xff20('0x3d')],{'$or':_[_0xff20('0x2e')](_0xddde16[_0xff20('0x36')],function(_0x4dcfac){var _0x26381c={};_0x26381c[_0x4dcfac]={'$like':'%'+_0x54c0a3[_0xff20('0x33')]['filter']+'%'};return _0x26381c;})});}_0xddde16=_[_0xff20('0x40')]({},_0xddde16,_0x54c0a3['options']);return _0x52649f[_0xff20('0x4f')](_0xddde16);}})[_0xff20('0x28')](function(_0x81d0b1){if(_0x81d0b1){_0x288eb9=_0x81d0b1[_0xff20('0x38')];if(!_0x54c0a3[_0xff20('0x33')][_0xff20('0x39')]('nolimit')){_0xddde16[_0xff20('0x1f')]=qs['limit'](_0x54c0a3[_0xff20('0x33')][_0xff20('0x1f')]);_0xddde16['offset']=qs[_0xff20('0x1e')](_0x54c0a3['query']['offset']);}return _0x52649f[_0xff20('0x4f')](_0xddde16);}})[_0xff20('0x28')](function(_0x1dc9d3){if(_0x1dc9d3){return _0x1dc9d3?{'count':_0x288eb9,'rows':_0x1dc9d3}:null;}})[_0xff20('0x28')](respondWithResult(_0x52bc4d,null))[_0xff20('0x49')](handleError(_0x52bc4d,null));};exports['getFields']=function(_0x3c78ca,_0x4a4887,_0x5ba7cd){var _0x8d5d93={};var _0x4dd18e={};var _0x4a296b;var _0x4cc238;return db['FreshsalesConfiguration']['findOne']({'where':{'id':_0x3c78ca[_0xff20('0x45')]['id']}})['then'](handleEntityNotFound(_0x4a4887,null))[_0xff20('0x28')](function(_0x344508){if(_0x344508){_0x4a296b=_0x344508;_0x4dd18e[_0xff20('0x31')]=_[_0xff20('0x32')](db[_0xff20('0x4c')][_0xff20('0x4d')]);_0x4dd18e[_0xff20('0x33')]=_[_0xff20('0x32')](_0x3c78ca[_0xff20('0x33')]);_0x4dd18e[_0xff20('0x34')]=_['intersection'](_0x4dd18e['model'],_0x4dd18e[_0xff20('0x33')]);_0x8d5d93['attributes']=_[_0xff20('0x35')](_0x4dd18e['model'],qs[_0xff20('0x37')](_0x3c78ca[_0xff20('0x33')][_0xff20('0x37')]));_0x8d5d93[_0xff20('0x36')]=_0x8d5d93[_0xff20('0x36')][_0xff20('0x38')]?_0x8d5d93['attributes']:_0x4dd18e[_0xff20('0x31')];_0x8d5d93[_0xff20('0x3b')]=qs[_0xff20('0x3c')](_0x3c78ca['query']['sort']);_0x8d5d93[_0xff20('0x3d')]=qs[_0xff20('0x34')](_[_0xff20('0x3e')](_0x3c78ca['query'],_0x4dd18e[_0xff20('0x34')]));if(_0x3c78ca[_0xff20('0x33')]['filter']){_0x8d5d93[_0xff20('0x3d')]=_[_0xff20('0x40')](_0x8d5d93[_0xff20('0x3d')],{'$or':_[_0xff20('0x2e')](_0x8d5d93[_0xff20('0x36')],function(_0x48df6c){var _0x3a35d0={};_0x3a35d0[_0x48df6c]={'$like':'%'+_0x3c78ca[_0xff20('0x33')][_0xff20('0x3f')]+'%'};return _0x3a35d0;})});}_0x8d5d93=_[_0xff20('0x40')]({},_0x8d5d93,_0x3c78ca[_0xff20('0x47')]);return _0x4a296b[_0xff20('0x50')](_0x8d5d93);}})['then'](function(_0x9e3b59){if(_0x9e3b59){_0x4cc238=_0x9e3b59[_0xff20('0x38')];if(!_0x3c78ca[_0xff20('0x33')][_0xff20('0x39')](_0xff20('0x3a'))){_0x8d5d93[_0xff20('0x1f')]=qs['limit'](_0x3c78ca[_0xff20('0x33')]['limit']);_0x8d5d93['offset']=qs[_0xff20('0x1e')](_0x3c78ca[_0xff20('0x33')][_0xff20('0x1e')]);}return _0x4a296b[_0xff20('0x50')](_0x8d5d93);}})[_0xff20('0x28')](function(_0x36e95b){if(_0x36e95b){return _0x36e95b?{'count':_0x4cc238,'rows':_0x36e95b}:null;}})['then'](respondWithResult(_0x4a4887,null))[_0xff20('0x49')](handleError(_0x4a4887,null));};
\ No newline at end of file