Built motion from commit 497d3d92.|2.5.43
[motion2.git] / server / api / intSugarcrmConfiguration / intSugarcrmConfiguration.controller.js
index ff26489..4e9577b 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xf428=['../../config/license/util','../../mysqldb','client','request','then','info','SugarcrmConfiguration,\x20%s,\x20%s','request\x20sent','debug','SugarcrmConfiguration,\x20%s,\x20%s,\x20%s','stringify','error','code','message','catch','sendStatus','end','status','json','count','offset','set','Content-Range','destroy','stack','index','map','SugarcrmConfiguration','rawAttributes','type','model','keys','query','filters','attributes','intersection','fields','length','hasOwnProperty','limit','sort','where','filter','merge','VIRTUAL','options','includeAll','include','rows','show','params','create','body','update','find','getFields','findOne','SugarcrmField','order','pick','nolimit','getSubjects','getDescriptions','html-pdf','eml-format','rimraf','fast-json-patch','request-promise','moment','bluebird','mustache','path','ejs','lodash','squel','crypto','desk.js','to-csv','querystring','papaparse','ioredis','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment'];(function(_0x3dd15e,_0x1f0015){var _0x231fd0=function(_0x4f680a){while(--_0x4f680a){_0x3dd15e['push'](_0x3dd15e['shift']());}};_0x231fd0(++_0x1f0015);}(_0xf428,0x1f2));var _0x8f42=function(_0xd86b32,_0x3c525a){_0xd86b32=_0xd86b32-0x0;var _0x455841=_0xf428[_0xd86b32];return _0x455841;};'use strict';var pdf=require(_0x8f42('0x0'));var emlformat=require(_0x8f42('0x1'));var rimraf=require(_0x8f42('0x2'));var zipdir=require('zip-dir');var jsonpatch=require(_0x8f42('0x3'));var rp=require(_0x8f42('0x4'));var moment=require(_0x8f42('0x5'));var BPromise=require(_0x8f42('0x6'));var Mustache=require(_0x8f42('0x7'));var util=require('util');var path=require(_0x8f42('0x8'));var sox=require('sox');var csv=require('to-csv');var ejs=require(_0x8f42('0x9'));var fs=require('fs');var _=require(_0x8f42('0xa'));var squel=require(_0x8f42('0xb'));var crypto=require(_0x8f42('0xc'));var jsforce=require('jsforce');var deskjs=require(_0x8f42('0xd'));var toCsv=require(_0x8f42('0xe'));var querystring=require(_0x8f42('0xf'));var Papa=require(_0x8f42('0x10'));var Redis=require(_0x8f42('0x11'));var authService=require('../../components/auth/service');var qs=require('../../components/parsers/qs');var as=require(_0x8f42('0x12'));var hardwareService=require(_0x8f42('0x13'));var logger=require(_0x8f42('0x14'))(_0x8f42('0x15'));var utils=require(_0x8f42('0x16'));var config=require(_0x8f42('0x17'));var licenseUtil=require(_0x8f42('0x18'));var db=require(_0x8f42('0x19'))['db'];var jayson=require('jayson/promise');var client=jayson[_0x8f42('0x1a')]['http']({'port':0x232a});function respondWithRpcPromise(_0x1f00ca,_0x4f94ad,_0x52b450,_0x2d422e){return new BPromise(function(_0x11342d,_0x544771){var _0x1b5e3d=_0x2d422e||client;return _0x1b5e3d[_0x8f42('0x1b')](_0x1f00ca,_0x52b450)[_0x8f42('0x1c')](function(_0x3e82c2){logger[_0x8f42('0x1d')](_0x8f42('0x1e'),_0x4f94ad,_0x8f42('0x1f'));logger[_0x8f42('0x20')](_0x8f42('0x21'),_0x4f94ad,'request\x20sent',JSON[_0x8f42('0x22')](_0x3e82c2));if(_0x3e82c2[_0x8f42('0x23')]){if(_0x3e82c2['error'][_0x8f42('0x24')]===0x1f4){logger[_0x8f42('0x23')](_0x8f42('0x1e'),_0x4f94ad,_0x3e82c2[_0x8f42('0x23')]['message']);return _0x544771(_0x3e82c2[_0x8f42('0x23')][_0x8f42('0x25')]);}logger[_0x8f42('0x23')](_0x8f42('0x1e'),_0x4f94ad,_0x3e82c2[_0x8f42('0x23')][_0x8f42('0x25')]);return _0x11342d(_0x3e82c2[_0x8f42('0x23')][_0x8f42('0x25')]);}else{logger[_0x8f42('0x1d')](_0x8f42('0x1e'),_0x4f94ad,_0x8f42('0x1f'));_0x11342d(_0x3e82c2['result'][_0x8f42('0x25')]);}})[_0x8f42('0x26')](function(_0x1d83ea){logger[_0x8f42('0x23')]('SugarcrmConfiguration,\x20%s,\x20%s',_0x4f94ad,_0x1d83ea);_0x544771(_0x1d83ea);});});}function respondWithStatusCode(_0x2b70,_0x32669d){_0x32669d=_0x32669d||0xcc;return function(_0x123671){if(_0x123671){return _0x2b70[_0x8f42('0x27')](_0x32669d);}return _0x2b70['status'](_0x32669d)[_0x8f42('0x28')]();};}function respondWithResult(_0x3e8a3b,_0x2e3c58){_0x2e3c58=_0x2e3c58||0xc8;return function(_0x431761){if(_0x431761){return _0x3e8a3b[_0x8f42('0x29')](_0x2e3c58)[_0x8f42('0x2a')](_0x431761);}};}function respondWithFilteredResult(_0x5dbd3a,_0x315b47){return function(_0x48eae0){if(_0x48eae0){var _0x3854ef=_0x48eae0[_0x8f42('0x2b')],_0x1955ab=_0x315b47[_0x8f42('0x2c')],_0x548b4a=_0x315b47['offset']+_0x315b47['limit'],_0xe542ed;if(_0x548b4a>=_0x3854ef){_0x548b4a=_0x3854ef;_0xe542ed=0xc8;}else{_0xe542ed=0xce;}_0x5dbd3a['status'](_0xe542ed);return _0x5dbd3a[_0x8f42('0x2d')](_0x8f42('0x2e'),_0x1955ab+'-'+_0x548b4a+'/'+_0x3854ef)[_0x8f42('0x2a')](_0x48eae0);}return null;};}function patchUpdates(_0x40d77e){return function(_0x4a00a8){try{jsonpatch['apply'](_0x4a00a8,_0x40d77e,!![]);}catch(_0x47f181){return BPromise['reject'](_0x47f181);}return _0x4a00a8['save']();};}function saveUpdates(_0xb71c04,_0x11be0f){return function(_0x14dc97){if(_0x14dc97){return _0x14dc97['update'](_0xb71c04)[_0x8f42('0x1c')](function(_0x45e637){return _0x45e637;});}return null;};}function removeEntity(_0x3a0bd6,_0x3daf1d){return function(_0x49b74c){if(_0x49b74c){return _0x49b74c[_0x8f42('0x2f')]()[_0x8f42('0x1c')](function(){_0x3a0bd6[_0x8f42('0x29')](0xcc)[_0x8f42('0x28')]();});}};}function handleEntityNotFound(_0x4d3858,_0x458d63){return function(_0x254afd){if(!_0x254afd){_0x4d3858['sendStatus'](0x194);}return _0x254afd;};}function handleError(_0x271de9,_0x37ef30){_0x37ef30=_0x37ef30||0x1f4;return function(_0x43b6f5){logger[_0x8f42('0x23')](_0x43b6f5[_0x8f42('0x30')]);if(_0x43b6f5['name']){delete _0x43b6f5['name'];}_0x271de9[_0x8f42('0x29')](_0x37ef30)['send'](_0x43b6f5);};}exports[_0x8f42('0x31')]=function(_0x48df3e,_0x47a4dc){var _0x5740b8={},_0x49d741={},_0x23e0e8={'count':0x0,'rows':[]};var _0x1bae7f=_[_0x8f42('0x32')](db[_0x8f42('0x33')][_0x8f42('0x34')],function(_0x32fb35){return{'name':_0x32fb35['fieldName'],'type':_0x32fb35[_0x8f42('0x35')]['key']};});_0x49d741[_0x8f42('0x36')]=_['map'](_0x1bae7f,'name');_0x49d741['query']=_[_0x8f42('0x37')](_0x48df3e[_0x8f42('0x38')]);_0x49d741[_0x8f42('0x39')]=_['intersection'](_0x49d741[_0x8f42('0x36')],_0x49d741['query']);_0x5740b8[_0x8f42('0x3a')]=_[_0x8f42('0x3b')](_0x49d741['model'],qs[_0x8f42('0x3c')](_0x48df3e['query'][_0x8f42('0x3c')]));_0x5740b8[_0x8f42('0x3a')]=_0x5740b8['attributes'][_0x8f42('0x3d')]?_0x5740b8[_0x8f42('0x3a')]:_0x49d741['model'];if(!_0x48df3e[_0x8f42('0x38')][_0x8f42('0x3e')]('nolimit')){_0x5740b8[_0x8f42('0x3f')]=qs[_0x8f42('0x3f')](_0x48df3e[_0x8f42('0x38')][_0x8f42('0x3f')]);_0x5740b8[_0x8f42('0x2c')]=qs[_0x8f42('0x2c')](_0x48df3e['query'][_0x8f42('0x2c')]);}_0x5740b8['order']=qs[_0x8f42('0x40')](_0x48df3e[_0x8f42('0x38')][_0x8f42('0x40')]);_0x5740b8[_0x8f42('0x41')]=qs[_0x8f42('0x39')](_['pick'](_0x48df3e[_0x8f42('0x38')],_0x49d741[_0x8f42('0x39')]),_0x1bae7f);if(_0x48df3e['query'][_0x8f42('0x42')]){_0x5740b8[_0x8f42('0x41')]=_[_0x8f42('0x43')](_0x5740b8[_0x8f42('0x41')],{'$or':_[_0x8f42('0x32')](_0x1bae7f,function(_0x4372ca){if(_0x4372ca[_0x8f42('0x35')]!==_0x8f42('0x44')){var _0x33a57e={};_0x33a57e[_0x4372ca['name']]={'$like':'%'+_0x48df3e[_0x8f42('0x38')]['filter']+'%'};return _0x33a57e;}})});}_0x5740b8=_[_0x8f42('0x43')]({},_0x5740b8,_0x48df3e[_0x8f42('0x45')]);var _0x1c6a05={'where':_0x5740b8[_0x8f42('0x41')]};return db['SugarcrmConfiguration'][_0x8f42('0x2b')](_0x1c6a05)[_0x8f42('0x1c')](function(_0x35a5c7){_0x23e0e8[_0x8f42('0x2b')]=_0x35a5c7;if(_0x48df3e[_0x8f42('0x38')][_0x8f42('0x46')]){_0x5740b8[_0x8f42('0x47')]=[{'all':!![]}];}return db[_0x8f42('0x33')]['findAll'](_0x5740b8);})[_0x8f42('0x1c')](function(_0x15c62b){_0x23e0e8[_0x8f42('0x48')]=_0x15c62b;return _0x23e0e8;})[_0x8f42('0x1c')](respondWithFilteredResult(_0x47a4dc,_0x5740b8))[_0x8f42('0x26')](handleError(_0x47a4dc,null));};exports[_0x8f42('0x49')]=function(_0x3f2af2,_0x3ef3e1){var _0x2ac359={'raw':![],'where':{'id':_0x3f2af2[_0x8f42('0x4a')]['id']}},_0x1d1fd0={};_0x1d1fd0[_0x8f42('0x36')]=_['keys'](db[_0x8f42('0x33')][_0x8f42('0x34')]);_0x1d1fd0[_0x8f42('0x38')]=_[_0x8f42('0x37')](_0x3f2af2[_0x8f42('0x38')]);_0x1d1fd0[_0x8f42('0x39')]=_[_0x8f42('0x3b')](_0x1d1fd0[_0x8f42('0x36')],_0x1d1fd0['query']);_0x2ac359[_0x8f42('0x3a')]=_['intersection'](_0x1d1fd0[_0x8f42('0x36')],qs[_0x8f42('0x3c')](_0x3f2af2['query'][_0x8f42('0x3c')]));_0x2ac359[_0x8f42('0x3a')]=_0x2ac359[_0x8f42('0x3a')]['length']?_0x2ac359[_0x8f42('0x3a')]:_0x1d1fd0[_0x8f42('0x36')];if(_0x3f2af2[_0x8f42('0x38')][_0x8f42('0x46')]){_0x2ac359[_0x8f42('0x47')]=[{'all':!![]}];}_0x2ac359=_[_0x8f42('0x43')]({},_0x2ac359,_0x3f2af2['options']);return db[_0x8f42('0x33')]['find'](_0x2ac359)[_0x8f42('0x1c')](handleEntityNotFound(_0x3ef3e1,null))[_0x8f42('0x1c')](respondWithResult(_0x3ef3e1,null))[_0x8f42('0x26')](handleError(_0x3ef3e1,null));};exports[_0x8f42('0x4b')]=function(_0x6a58d8,_0x2e8f79){return db['SugarcrmConfiguration'][_0x8f42('0x4b')](_0x6a58d8[_0x8f42('0x4c')],{})[_0x8f42('0x1c')](respondWithResult(_0x2e8f79,0xc9))['catch'](handleError(_0x2e8f79,null));};exports[_0x8f42('0x4d')]=function(_0x3f2832,_0x23c551){if(_0x3f2832[_0x8f42('0x4c')]['id']){delete _0x3f2832[_0x8f42('0x4c')]['id'];}return db[_0x8f42('0x33')][_0x8f42('0x4e')]({'where':{'id':_0x3f2832[_0x8f42('0x4a')]['id']}})['then'](handleEntityNotFound(_0x23c551,null))[_0x8f42('0x1c')](saveUpdates(_0x3f2832[_0x8f42('0x4c')],null))[_0x8f42('0x1c')](respondWithResult(_0x23c551,null))[_0x8f42('0x26')](handleError(_0x23c551,null));};exports[_0x8f42('0x2f')]=function(_0x19133f,_0x13e50a){return db['SugarcrmConfiguration'][_0x8f42('0x4e')]({'where':{'id':_0x19133f[_0x8f42('0x4a')]['id']}})[_0x8f42('0x1c')](handleEntityNotFound(_0x13e50a,null))[_0x8f42('0x1c')](removeEntity(_0x13e50a,null))[_0x8f42('0x26')](handleError(_0x13e50a,null));};exports[_0x8f42('0x4f')]=function(_0x141d03,_0x532b18,_0xea79bb){var _0x2aaa9e={};var _0x37b533={};var _0x43c10a;var _0x2b8db5;return db[_0x8f42('0x33')][_0x8f42('0x50')]({'where':{'id':_0x141d03[_0x8f42('0x4a')]['id']}})[_0x8f42('0x1c')](handleEntityNotFound(_0x532b18,null))[_0x8f42('0x1c')](function(_0x33c11a){if(_0x33c11a){_0x43c10a=_0x33c11a;_0x37b533[_0x8f42('0x36')]=_[_0x8f42('0x37')](db[_0x8f42('0x51')][_0x8f42('0x34')]);_0x37b533['query']=_[_0x8f42('0x37')](_0x141d03['query']);_0x37b533[_0x8f42('0x39')]=_[_0x8f42('0x3b')](_0x37b533[_0x8f42('0x36')],_0x37b533[_0x8f42('0x38')]);_0x2aaa9e[_0x8f42('0x3a')]=_[_0x8f42('0x3b')](_0x37b533[_0x8f42('0x36')],qs[_0x8f42('0x3c')](_0x141d03[_0x8f42('0x38')][_0x8f42('0x3c')]));_0x2aaa9e[_0x8f42('0x3a')]=_0x2aaa9e[_0x8f42('0x3a')][_0x8f42('0x3d')]?_0x2aaa9e[_0x8f42('0x3a')]:_0x37b533[_0x8f42('0x36')];_0x2aaa9e[_0x8f42('0x52')]=qs[_0x8f42('0x40')](_0x141d03[_0x8f42('0x38')][_0x8f42('0x40')]);_0x2aaa9e[_0x8f42('0x41')]=qs[_0x8f42('0x39')](_[_0x8f42('0x53')](_0x141d03['query'],_0x37b533['filters']));if(_0x141d03[_0x8f42('0x38')][_0x8f42('0x42')]){_0x2aaa9e[_0x8f42('0x41')]=_['merge'](_0x2aaa9e[_0x8f42('0x41')],{'$or':_[_0x8f42('0x32')](_0x2aaa9e[_0x8f42('0x3a')],function(_0x4128ec){var _0x1f209e={};_0x1f209e[_0x4128ec]={'$like':'%'+_0x141d03[_0x8f42('0x38')][_0x8f42('0x42')]+'%'};return _0x1f209e;})});}_0x2aaa9e=_[_0x8f42('0x43')]({},_0x2aaa9e,_0x141d03[_0x8f42('0x45')]);return _0x43c10a[_0x8f42('0x4f')](_0x2aaa9e);}})[_0x8f42('0x1c')](function(_0x144c8f){if(_0x144c8f){_0x2b8db5=_0x144c8f[_0x8f42('0x3d')];if(!_0x141d03['query']['hasOwnProperty'](_0x8f42('0x54'))){_0x2aaa9e['limit']=qs[_0x8f42('0x3f')](_0x141d03[_0x8f42('0x38')]['limit']);_0x2aaa9e['offset']=qs[_0x8f42('0x2c')](_0x141d03[_0x8f42('0x38')][_0x8f42('0x2c')]);}return _0x43c10a['getFields'](_0x2aaa9e);}})['then'](function(_0x374bfd){if(_0x374bfd){return _0x374bfd?{'count':_0x2b8db5,'rows':_0x374bfd}:null;}})[_0x8f42('0x1c')](respondWithResult(_0x532b18,null))[_0x8f42('0x26')](handleError(_0x532b18,null));};exports[_0x8f42('0x55')]=function(_0x33f7a7,_0xf27c06,_0x2d842f){var _0x4d9915={};var _0x5bf018={};var _0xaf214b;var _0x2f2efb;return db[_0x8f42('0x33')][_0x8f42('0x50')]({'where':{'id':_0x33f7a7[_0x8f42('0x4a')]['id']}})[_0x8f42('0x1c')](handleEntityNotFound(_0xf27c06,null))['then'](function(_0x2b9c72){if(_0x2b9c72){_0xaf214b=_0x2b9c72;_0x5bf018[_0x8f42('0x36')]=_[_0x8f42('0x37')](db[_0x8f42('0x51')][_0x8f42('0x34')]);_0x5bf018['query']=_[_0x8f42('0x37')](_0x33f7a7[_0x8f42('0x38')]);_0x5bf018[_0x8f42('0x39')]=_['intersection'](_0x5bf018[_0x8f42('0x36')],_0x5bf018['query']);_0x4d9915['attributes']=_[_0x8f42('0x3b')](_0x5bf018[_0x8f42('0x36')],qs[_0x8f42('0x3c')](_0x33f7a7[_0x8f42('0x38')]['fields']));_0x4d9915[_0x8f42('0x3a')]=_0x4d9915[_0x8f42('0x3a')]['length']?_0x4d9915['attributes']:_0x5bf018[_0x8f42('0x36')];_0x4d9915[_0x8f42('0x52')]=qs[_0x8f42('0x40')](_0x33f7a7['query'][_0x8f42('0x40')]);_0x4d9915['where']=qs[_0x8f42('0x39')](_[_0x8f42('0x53')](_0x33f7a7[_0x8f42('0x38')],_0x5bf018['filters']));if(_0x33f7a7[_0x8f42('0x38')]['filter']){_0x4d9915['where']=_[_0x8f42('0x43')](_0x4d9915[_0x8f42('0x41')],{'$or':_[_0x8f42('0x32')](_0x4d9915[_0x8f42('0x3a')],function(_0x327d5f){var _0x351c2e={};_0x351c2e[_0x327d5f]={'$like':'%'+_0x33f7a7[_0x8f42('0x38')][_0x8f42('0x42')]+'%'};return _0x351c2e;})});}_0x4d9915=_['merge']({},_0x4d9915,_0x33f7a7[_0x8f42('0x45')]);return _0xaf214b[_0x8f42('0x55')](_0x4d9915);}})[_0x8f42('0x1c')](function(_0x5dff48){if(_0x5dff48){_0x2f2efb=_0x5dff48[_0x8f42('0x3d')];if(!_0x33f7a7['query']['hasOwnProperty'](_0x8f42('0x54'))){_0x4d9915['limit']=qs['limit'](_0x33f7a7[_0x8f42('0x38')][_0x8f42('0x3f')]);_0x4d9915[_0x8f42('0x2c')]=qs[_0x8f42('0x2c')](_0x33f7a7[_0x8f42('0x38')][_0x8f42('0x2c')]);}return _0xaf214b[_0x8f42('0x55')](_0x4d9915);}})[_0x8f42('0x1c')](function(_0x1fb013){if(_0x1fb013){return _0x1fb013?{'count':_0x2f2efb,'rows':_0x1fb013}:null;}})[_0x8f42('0x1c')](respondWithResult(_0xf27c06,null))[_0x8f42('0x26')](handleError(_0xf27c06,null));};exports[_0x8f42('0x56')]=function(_0x5c5b1c,_0x4ca880,_0x404b3b){var _0x766bc6={};var _0x563706={};var _0x387170;var _0x4778ff;return db['SugarcrmConfiguration'][_0x8f42('0x50')]({'where':{'id':_0x5c5b1c[_0x8f42('0x4a')]['id']}})[_0x8f42('0x1c')](handleEntityNotFound(_0x4ca880,null))[_0x8f42('0x1c')](function(_0x12d138){if(_0x12d138){_0x387170=_0x12d138;_0x563706[_0x8f42('0x36')]=_[_0x8f42('0x37')](db[_0x8f42('0x51')]['rawAttributes']);_0x563706['query']=_[_0x8f42('0x37')](_0x5c5b1c[_0x8f42('0x38')]);_0x563706[_0x8f42('0x39')]=_['intersection'](_0x563706[_0x8f42('0x36')],_0x563706[_0x8f42('0x38')]);_0x766bc6[_0x8f42('0x3a')]=_[_0x8f42('0x3b')](_0x563706[_0x8f42('0x36')],qs['fields'](_0x5c5b1c[_0x8f42('0x38')][_0x8f42('0x3c')]));_0x766bc6[_0x8f42('0x3a')]=_0x766bc6[_0x8f42('0x3a')]['length']?_0x766bc6[_0x8f42('0x3a')]:_0x563706[_0x8f42('0x36')];_0x766bc6[_0x8f42('0x52')]=qs[_0x8f42('0x40')](_0x5c5b1c['query'][_0x8f42('0x40')]);_0x766bc6[_0x8f42('0x41')]=qs[_0x8f42('0x39')](_[_0x8f42('0x53')](_0x5c5b1c[_0x8f42('0x38')],_0x563706['filters']));if(_0x5c5b1c[_0x8f42('0x38')][_0x8f42('0x42')]){_0x766bc6[_0x8f42('0x41')]=_[_0x8f42('0x43')](_0x766bc6[_0x8f42('0x41')],{'$or':_[_0x8f42('0x32')](_0x766bc6[_0x8f42('0x3a')],function(_0x1b526e){var _0x324197={};_0x324197[_0x1b526e]={'$like':'%'+_0x5c5b1c['query'][_0x8f42('0x42')]+'%'};return _0x324197;})});}_0x766bc6=_[_0x8f42('0x43')]({},_0x766bc6,_0x5c5b1c[_0x8f42('0x45')]);return _0x387170[_0x8f42('0x56')](_0x766bc6);}})[_0x8f42('0x1c')](function(_0xbba0d){if(_0xbba0d){_0x4778ff=_0xbba0d[_0x8f42('0x3d')];if(!_0x5c5b1c['query'][_0x8f42('0x3e')](_0x8f42('0x54'))){_0x766bc6[_0x8f42('0x3f')]=qs[_0x8f42('0x3f')](_0x5c5b1c[_0x8f42('0x38')][_0x8f42('0x3f')]);_0x766bc6[_0x8f42('0x2c')]=qs[_0x8f42('0x2c')](_0x5c5b1c[_0x8f42('0x38')][_0x8f42('0x2c')]);}return _0x387170[_0x8f42('0x56')](_0x766bc6);}})['then'](function(_0xd6da6c){if(_0xd6da6c){return _0xd6da6c?{'count':_0x4778ff,'rows':_0xd6da6c}:null;}})[_0x8f42('0x1c')](respondWithResult(_0x4ca880,null))[_0x8f42('0x26')](handleError(_0x4ca880,null));};
\ No newline at end of file
+var _0x18bb=['error','stack','name','index','rawAttributes','model','map','filters','intersection','query','attributes','fields','length','hasOwnProperty','order','sort','filter','where','merge','VIRTUAL','SugarcrmConfiguration','include','findAll','rows','catch','show','params','keys','includeAll','options','find','create','body','getFields','findOne','SugarcrmField','nolimit','getSubjects','pick','getDescriptions','rimraf','zip-dir','fast-json-patch','bluebird','util','path','sox','ejs','fs-extra','squel','crypto','jsforce','desk.js','to-csv','querystring','papaparse','../../components/auth/service','../../components/parsers/advancedSearch','../../config/logger','api','../../config/utils','../../config/license/util','../../mysqldb','sendStatus','status','end','offset','undefined','limit','count','set','Content-Range','json','reject','save','then','destroy'];(function(_0x3d9c7e,_0x2f192c){var _0x5d6c3c=function(_0x677147){while(--_0x677147){_0x3d9c7e['push'](_0x3d9c7e['shift']());}};_0x5d6c3c(++_0x2f192c);}(_0x18bb,0x10f));var _0xb18b=function(_0x47e549,_0x2e53d6){_0x47e549=_0x47e549-0x0;var _0x251374=_0x18bb[_0x47e549];return _0x251374;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0xb18b('0x0'));var zipdir=require(_0xb18b('0x1'));var jsonpatch=require(_0xb18b('0x2'));var rp=require('request-promise');var moment=require('moment');var BPromise=require(_0xb18b('0x3'));var Mustache=require('mustache');var util=require(_0xb18b('0x4'));var path=require(_0xb18b('0x5'));var sox=require(_0xb18b('0x6'));var csv=require('to-csv');var ejs=require(_0xb18b('0x7'));var fs=require('fs');var fs_extra=require(_0xb18b('0x8'));var _=require('lodash');var squel=require(_0xb18b('0x9'));var crypto=require(_0xb18b('0xa'));var jsforce=require(_0xb18b('0xb'));var deskjs=require(_0xb18b('0xc'));var toCsv=require(_0xb18b('0xd'));var querystring=require(_0xb18b('0xe'));var Papa=require(_0xb18b('0xf'));var Redis=require('ioredis');var authService=require(_0xb18b('0x10'));var qs=require('../../components/parsers/qs');var as=require(_0xb18b('0x11'));var hardwareService=require('../../config/license/hardware');var logger=require(_0xb18b('0x12'))(_0xb18b('0x13'));var utils=require(_0xb18b('0x14'));var config=require('../../config/environment');var licenseUtil=require(_0xb18b('0x15'));var db=require(_0xb18b('0x16'))['db'];function respondWithStatusCode(_0x33cf28,_0x18d74){_0x18d74=_0x18d74||0xcc;return function(_0x2557ef){if(_0x2557ef){return _0x33cf28[_0xb18b('0x17')](_0x18d74);}return _0x33cf28[_0xb18b('0x18')](_0x18d74)[_0xb18b('0x19')]();};}function respondWithResult(_0x1ec3d9,_0x2839f5){_0x2839f5=_0x2839f5||0xc8;return function(_0x3c031b){if(_0x3c031b){return _0x1ec3d9[_0xb18b('0x18')](_0x2839f5)['json'](_0x3c031b);}};}function respondWithFilteredResult(_0xf0b4b8,_0x423bf4){return function(_0x3284f4){if(_0x3284f4){var _0x244cf5=typeof _0x423bf4[_0xb18b('0x1a')]===_0xb18b('0x1b')&&typeof _0x423bf4[_0xb18b('0x1c')]==='undefined';var _0x47acaa=_0x3284f4[_0xb18b('0x1d')];var _0x22e55f=_0x244cf5?0x0:_0x423bf4[_0xb18b('0x1a')];var _0x3b9aa2=_0x244cf5?_0x3284f4[_0xb18b('0x1d')]:_0x423bf4['offset']+_0x423bf4['limit'];var _0xab9040;if(_0x3b9aa2>=_0x47acaa){_0x3b9aa2=_0x47acaa;_0xab9040=0xc8;}else{_0xab9040=0xce;}_0xf0b4b8[_0xb18b('0x18')](_0xab9040);return _0xf0b4b8[_0xb18b('0x1e')](_0xb18b('0x1f'),_0x22e55f+'-'+_0x3b9aa2+'/'+_0x47acaa)[_0xb18b('0x20')](_0x3284f4);}return null;};}function patchUpdates(_0x17005d){return function(_0x4495ac){try{jsonpatch['apply'](_0x4495ac,_0x17005d,!![]);}catch(_0x2b1b0a){return BPromise[_0xb18b('0x21')](_0x2b1b0a);}return _0x4495ac[_0xb18b('0x22')]();};}function saveUpdates(_0x1819ca,_0x17ae75){return function(_0x1a66a3){if(_0x1a66a3){return _0x1a66a3['update'](_0x1819ca)[_0xb18b('0x23')](function(_0x423b93){return _0x423b93;});}return null;};}function removeEntity(_0x4796f9,_0x104c74){return function(_0x5140ac){if(_0x5140ac){return _0x5140ac[_0xb18b('0x24')]()[_0xb18b('0x23')](function(){_0x4796f9[_0xb18b('0x18')](0xcc)[_0xb18b('0x19')]();});}};}function handleEntityNotFound(_0x1c3e72,_0x322094){return function(_0x1f3dbd){if(!_0x1f3dbd){_0x1c3e72['sendStatus'](0x194);}return _0x1f3dbd;};}function handleError(_0x199eab,_0x3ddace){_0x3ddace=_0x3ddace||0x1f4;return function(_0x362e07){logger[_0xb18b('0x25')](_0x362e07[_0xb18b('0x26')]);if(_0x362e07[_0xb18b('0x27')]){delete _0x362e07['name'];}_0x199eab[_0xb18b('0x18')](_0x3ddace)['send'](_0x362e07);};}exports[_0xb18b('0x28')]=function(_0x29ff95,_0x110665){var _0x8a0b5d={},_0x1ef6d7={},_0xc62dfe={'count':0x0,'rows':[]};var _0x25b542=_['map'](db['SugarcrmConfiguration'][_0xb18b('0x29')],function(_0x148390){return{'name':_0x148390['fieldName'],'type':_0x148390['type']['key']};});_0x1ef6d7[_0xb18b('0x2a')]=_[_0xb18b('0x2b')](_0x25b542,'name');_0x1ef6d7['query']=_['keys'](_0x29ff95['query']);_0x1ef6d7[_0xb18b('0x2c')]=_[_0xb18b('0x2d')](_0x1ef6d7[_0xb18b('0x2a')],_0x1ef6d7[_0xb18b('0x2e')]);_0x8a0b5d[_0xb18b('0x2f')]=_[_0xb18b('0x2d')](_0x1ef6d7[_0xb18b('0x2a')],qs[_0xb18b('0x30')](_0x29ff95[_0xb18b('0x2e')]['fields']));_0x8a0b5d[_0xb18b('0x2f')]=_0x8a0b5d['attributes'][_0xb18b('0x31')]?_0x8a0b5d[_0xb18b('0x2f')]:_0x1ef6d7['model'];if(!_0x29ff95[_0xb18b('0x2e')][_0xb18b('0x32')]('nolimit')){_0x8a0b5d[_0xb18b('0x1c')]=qs[_0xb18b('0x1c')](_0x29ff95[_0xb18b('0x2e')][_0xb18b('0x1c')]);_0x8a0b5d[_0xb18b('0x1a')]=qs['offset'](_0x29ff95['query'][_0xb18b('0x1a')]);}_0x8a0b5d[_0xb18b('0x33')]=qs[_0xb18b('0x34')](_0x29ff95[_0xb18b('0x2e')][_0xb18b('0x34')]);_0x8a0b5d['where']=qs['filters'](_['pick'](_0x29ff95[_0xb18b('0x2e')],_0x1ef6d7[_0xb18b('0x2c')]),_0x25b542);if(_0x29ff95[_0xb18b('0x2e')][_0xb18b('0x35')]){_0x8a0b5d[_0xb18b('0x36')]=_[_0xb18b('0x37')](_0x8a0b5d[_0xb18b('0x36')],{'$or':_['map'](_0x25b542,function(_0x21123a){if(_0x21123a['type']!==_0xb18b('0x38')){var _0x3a1378={};_0x3a1378[_0x21123a[_0xb18b('0x27')]]={'$like':'%'+_0x29ff95[_0xb18b('0x2e')]['filter']+'%'};return _0x3a1378;}})});}_0x8a0b5d=_['merge']({},_0x8a0b5d,_0x29ff95['options']);var _0x4485e1={'where':_0x8a0b5d['where']};return db[_0xb18b('0x39')][_0xb18b('0x1d')](_0x4485e1)[_0xb18b('0x23')](function(_0x1e677e){_0xc62dfe[_0xb18b('0x1d')]=_0x1e677e;if(_0x29ff95[_0xb18b('0x2e')]['includeAll']){_0x8a0b5d[_0xb18b('0x3a')]=[{'all':!![]}];}return db['SugarcrmConfiguration'][_0xb18b('0x3b')](_0x8a0b5d);})[_0xb18b('0x23')](function(_0x31d515){_0xc62dfe[_0xb18b('0x3c')]=_0x31d515;return _0xc62dfe;})[_0xb18b('0x23')](respondWithFilteredResult(_0x110665,_0x8a0b5d))[_0xb18b('0x3d')](handleError(_0x110665,null));};exports[_0xb18b('0x3e')]=function(_0x320b3a,_0x3493bc){var _0xa24a87={'raw':![],'where':{'id':_0x320b3a[_0xb18b('0x3f')]['id']}},_0x3294b3={};_0x3294b3[_0xb18b('0x2a')]=_[_0xb18b('0x40')](db['SugarcrmConfiguration'][_0xb18b('0x29')]);_0x3294b3['query']=_['keys'](_0x320b3a[_0xb18b('0x2e')]);_0x3294b3[_0xb18b('0x2c')]=_['intersection'](_0x3294b3[_0xb18b('0x2a')],_0x3294b3['query']);_0xa24a87['attributes']=_[_0xb18b('0x2d')](_0x3294b3[_0xb18b('0x2a')],qs[_0xb18b('0x30')](_0x320b3a[_0xb18b('0x2e')]['fields']));_0xa24a87[_0xb18b('0x2f')]=_0xa24a87[_0xb18b('0x2f')][_0xb18b('0x31')]?_0xa24a87[_0xb18b('0x2f')]:_0x3294b3[_0xb18b('0x2a')];if(_0x320b3a[_0xb18b('0x2e')][_0xb18b('0x41')]){_0xa24a87[_0xb18b('0x3a')]=[{'all':!![]}];}_0xa24a87=_[_0xb18b('0x37')]({},_0xa24a87,_0x320b3a[_0xb18b('0x42')]);return db[_0xb18b('0x39')][_0xb18b('0x43')](_0xa24a87)[_0xb18b('0x23')](handleEntityNotFound(_0x3493bc,null))['then'](respondWithResult(_0x3493bc,null))[_0xb18b('0x3d')](handleError(_0x3493bc,null));};exports[_0xb18b('0x44')]=function(_0xddbf3f,_0x10da4f){return db[_0xb18b('0x39')][_0xb18b('0x44')](_0xddbf3f[_0xb18b('0x45')],{})['then'](respondWithResult(_0x10da4f,0xc9))[_0xb18b('0x3d')](handleError(_0x10da4f,null));};exports['update']=function(_0xf497c2,_0x470482){if(_0xf497c2[_0xb18b('0x45')]['id']){delete _0xf497c2[_0xb18b('0x45')]['id'];}return db[_0xb18b('0x39')]['find']({'where':{'id':_0xf497c2[_0xb18b('0x3f')]['id']}})[_0xb18b('0x23')](handleEntityNotFound(_0x470482,null))['then'](saveUpdates(_0xf497c2[_0xb18b('0x45')],null))[_0xb18b('0x23')](respondWithResult(_0x470482,null))['catch'](handleError(_0x470482,null));};exports['destroy']=function(_0x2af86d,_0x856ff8){return db['SugarcrmConfiguration'][_0xb18b('0x43')]({'where':{'id':_0x2af86d[_0xb18b('0x3f')]['id']}})[_0xb18b('0x23')](handleEntityNotFound(_0x856ff8,null))[_0xb18b('0x23')](removeEntity(_0x856ff8,null))[_0xb18b('0x3d')](handleError(_0x856ff8,null));};exports[_0xb18b('0x46')]=function(_0x2e5a40,_0x337361,_0x3c0cec){var _0x4f0d0b={};var _0x3a2920={};var _0x2da5da;var _0x407999;return db[_0xb18b('0x39')][_0xb18b('0x47')]({'where':{'id':_0x2e5a40[_0xb18b('0x3f')]['id']}})[_0xb18b('0x23')](handleEntityNotFound(_0x337361,null))[_0xb18b('0x23')](function(_0x429d0c){if(_0x429d0c){_0x2da5da=_0x429d0c;_0x3a2920[_0xb18b('0x2a')]=_[_0xb18b('0x40')](db[_0xb18b('0x48')][_0xb18b('0x29')]);_0x3a2920[_0xb18b('0x2e')]=_[_0xb18b('0x40')](_0x2e5a40[_0xb18b('0x2e')]);_0x3a2920[_0xb18b('0x2c')]=_[_0xb18b('0x2d')](_0x3a2920['model'],_0x3a2920['query']);_0x4f0d0b[_0xb18b('0x2f')]=_[_0xb18b('0x2d')](_0x3a2920[_0xb18b('0x2a')],qs['fields'](_0x2e5a40[_0xb18b('0x2e')][_0xb18b('0x30')]));_0x4f0d0b[_0xb18b('0x2f')]=_0x4f0d0b[_0xb18b('0x2f')][_0xb18b('0x31')]?_0x4f0d0b['attributes']:_0x3a2920[_0xb18b('0x2a')];_0x4f0d0b[_0xb18b('0x33')]=qs['sort'](_0x2e5a40['query']['sort']);_0x4f0d0b[_0xb18b('0x36')]=qs[_0xb18b('0x2c')](_['pick'](_0x2e5a40['query'],_0x3a2920['filters']));if(_0x2e5a40['query'][_0xb18b('0x35')]){_0x4f0d0b[_0xb18b('0x36')]=_[_0xb18b('0x37')](_0x4f0d0b[_0xb18b('0x36')],{'$or':_[_0xb18b('0x2b')](_0x4f0d0b[_0xb18b('0x2f')],function(_0x4c4750){var _0x366828={};_0x366828[_0x4c4750]={'$like':'%'+_0x2e5a40['query'][_0xb18b('0x35')]+'%'};return _0x366828;})});}_0x4f0d0b=_['merge']({},_0x4f0d0b,_0x2e5a40['options']);return _0x2da5da['getFields'](_0x4f0d0b);}})[_0xb18b('0x23')](function(_0x464c9e){if(_0x464c9e){_0x407999=_0x464c9e['length'];if(!_0x2e5a40[_0xb18b('0x2e')][_0xb18b('0x32')](_0xb18b('0x49'))){_0x4f0d0b[_0xb18b('0x1c')]=qs[_0xb18b('0x1c')](_0x2e5a40[_0xb18b('0x2e')]['limit']);_0x4f0d0b[_0xb18b('0x1a')]=qs[_0xb18b('0x1a')](_0x2e5a40[_0xb18b('0x2e')][_0xb18b('0x1a')]);}return _0x2da5da['getFields'](_0x4f0d0b);}})['then'](function(_0x1cdaf1){if(_0x1cdaf1){return _0x1cdaf1?{'count':_0x407999,'rows':_0x1cdaf1}:null;}})[_0xb18b('0x23')](respondWithResult(_0x337361,null))[_0xb18b('0x3d')](handleError(_0x337361,null));};exports[_0xb18b('0x4a')]=function(_0x2f10da,_0x4f4783,_0x2d09c9){var _0x3171da={};var _0x470b38={};var _0x12783a;var _0x4fcac1;return db[_0xb18b('0x39')][_0xb18b('0x47')]({'where':{'id':_0x2f10da[_0xb18b('0x3f')]['id']}})['then'](handleEntityNotFound(_0x4f4783,null))[_0xb18b('0x23')](function(_0x159de6){if(_0x159de6){_0x12783a=_0x159de6;_0x470b38[_0xb18b('0x2a')]=_[_0xb18b('0x40')](db[_0xb18b('0x48')]['rawAttributes']);_0x470b38['query']=_[_0xb18b('0x40')](_0x2f10da['query']);_0x470b38[_0xb18b('0x2c')]=_['intersection'](_0x470b38[_0xb18b('0x2a')],_0x470b38[_0xb18b('0x2e')]);_0x3171da[_0xb18b('0x2f')]=_['intersection'](_0x470b38[_0xb18b('0x2a')],qs[_0xb18b('0x30')](_0x2f10da[_0xb18b('0x2e')][_0xb18b('0x30')]));_0x3171da['attributes']=_0x3171da[_0xb18b('0x2f')][_0xb18b('0x31')]?_0x3171da[_0xb18b('0x2f')]:_0x470b38[_0xb18b('0x2a')];_0x3171da[_0xb18b('0x33')]=qs[_0xb18b('0x34')](_0x2f10da[_0xb18b('0x2e')][_0xb18b('0x34')]);_0x3171da[_0xb18b('0x36')]=qs['filters'](_[_0xb18b('0x4b')](_0x2f10da[_0xb18b('0x2e')],_0x470b38[_0xb18b('0x2c')]));if(_0x2f10da[_0xb18b('0x2e')][_0xb18b('0x35')]){_0x3171da['where']=_[_0xb18b('0x37')](_0x3171da[_0xb18b('0x36')],{'$or':_[_0xb18b('0x2b')](_0x3171da['attributes'],function(_0x4dc266){var _0x2476eb={};_0x2476eb[_0x4dc266]={'$like':'%'+_0x2f10da['query']['filter']+'%'};return _0x2476eb;})});}_0x3171da=_[_0xb18b('0x37')]({},_0x3171da,_0x2f10da['options']);return _0x12783a[_0xb18b('0x4a')](_0x3171da);}})[_0xb18b('0x23')](function(_0x296953){if(_0x296953){_0x4fcac1=_0x296953['length'];if(!_0x2f10da[_0xb18b('0x2e')][_0xb18b('0x32')]('nolimit')){_0x3171da[_0xb18b('0x1c')]=qs[_0xb18b('0x1c')](_0x2f10da[_0xb18b('0x2e')]['limit']);_0x3171da['offset']=qs[_0xb18b('0x1a')](_0x2f10da[_0xb18b('0x2e')]['offset']);}return _0x12783a[_0xb18b('0x4a')](_0x3171da);}})[_0xb18b('0x23')](function(_0x2f8b9b){if(_0x2f8b9b){return _0x2f8b9b?{'count':_0x4fcac1,'rows':_0x2f8b9b}:null;}})[_0xb18b('0x23')](respondWithResult(_0x4f4783,null))[_0xb18b('0x3d')](handleError(_0x4f4783,null));};exports[_0xb18b('0x4c')]=function(_0x21e88c,_0x5f3ec4,_0x4a1e16){var _0x2b3ef3={};var _0x4ee020={};var _0x3b77ce;var _0xe00288;return db[_0xb18b('0x39')][_0xb18b('0x47')]({'where':{'id':_0x21e88c['params']['id']}})[_0xb18b('0x23')](handleEntityNotFound(_0x5f3ec4,null))[_0xb18b('0x23')](function(_0xc4cdf3){if(_0xc4cdf3){_0x3b77ce=_0xc4cdf3;_0x4ee020[_0xb18b('0x2a')]=_[_0xb18b('0x40')](db[_0xb18b('0x48')]['rawAttributes']);_0x4ee020[_0xb18b('0x2e')]=_[_0xb18b('0x40')](_0x21e88c['query']);_0x4ee020[_0xb18b('0x2c')]=_[_0xb18b('0x2d')](_0x4ee020[_0xb18b('0x2a')],_0x4ee020[_0xb18b('0x2e')]);_0x2b3ef3['attributes']=_[_0xb18b('0x2d')](_0x4ee020[_0xb18b('0x2a')],qs[_0xb18b('0x30')](_0x21e88c['query'][_0xb18b('0x30')]));_0x2b3ef3[_0xb18b('0x2f')]=_0x2b3ef3[_0xb18b('0x2f')][_0xb18b('0x31')]?_0x2b3ef3[_0xb18b('0x2f')]:_0x4ee020[_0xb18b('0x2a')];_0x2b3ef3[_0xb18b('0x33')]=qs[_0xb18b('0x34')](_0x21e88c[_0xb18b('0x2e')][_0xb18b('0x34')]);_0x2b3ef3[_0xb18b('0x36')]=qs[_0xb18b('0x2c')](_[_0xb18b('0x4b')](_0x21e88c['query'],_0x4ee020[_0xb18b('0x2c')]));if(_0x21e88c[_0xb18b('0x2e')][_0xb18b('0x35')]){_0x2b3ef3[_0xb18b('0x36')]=_[_0xb18b('0x37')](_0x2b3ef3['where'],{'$or':_[_0xb18b('0x2b')](_0x2b3ef3[_0xb18b('0x2f')],function(_0x216151){var _0x118f74={};_0x118f74[_0x216151]={'$like':'%'+_0x21e88c[_0xb18b('0x2e')][_0xb18b('0x35')]+'%'};return _0x118f74;})});}_0x2b3ef3=_[_0xb18b('0x37')]({},_0x2b3ef3,_0x21e88c[_0xb18b('0x42')]);return _0x3b77ce[_0xb18b('0x4c')](_0x2b3ef3);}})[_0xb18b('0x23')](function(_0x5118e5){if(_0x5118e5){_0xe00288=_0x5118e5[_0xb18b('0x31')];if(!_0x21e88c['query'][_0xb18b('0x32')](_0xb18b('0x49'))){_0x2b3ef3['limit']=qs[_0xb18b('0x1c')](_0x21e88c[_0xb18b('0x2e')][_0xb18b('0x1c')]);_0x2b3ef3[_0xb18b('0x1a')]=qs[_0xb18b('0x1a')](_0x21e88c['query']['offset']);}return _0x3b77ce[_0xb18b('0x4c')](_0x2b3ef3);}})[_0xb18b('0x23')](function(_0x155270){if(_0x155270){return _0x155270?{'count':_0xe00288,'rows':_0x155270}:null;}})[_0xb18b('0x23')](respondWithResult(_0x5f3ec4,null))['catch'](handleError(_0x5f3ec4,null));};
\ No newline at end of file