Built motion from commit 0900f080.|2.5.45
[motion2.git] / server / api / intSugarcrmConfiguration / intSugarcrmConfiguration.controller.js
index ff26489..54eee01 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 _0x19a4=['getDescriptions','rimraf','zip-dir','fast-json-patch','moment','util','path','sox','to-csv','fs-extra','squel','crypto','jsforce','desk.js','querystring','papaparse','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../mysqldb','status','end','offset','undefined','limit','count','set','Content-Range','json','apply','reject','save','then','destroy','stack','name','send','map','SugarcrmConfiguration','rawAttributes','fieldName','type','key','model','query','keys','intersection','attributes','fields','hasOwnProperty','order','sort','where','filters','pick','merge','VIRTUAL','options','includeAll','include','findAll','rows','show','length','find','catch','create','body','params','getFields','findOne','SugarcrmField','filter','nolimit','getSubjects'];(function(_0x36ed48,_0x1ee0d4){var _0x51c63a=function(_0x2d0a40){while(--_0x2d0a40){_0x36ed48['push'](_0x36ed48['shift']());}};_0x51c63a(++_0x1ee0d4);}(_0x19a4,0x1db));var _0x419a=function(_0x9101ec,_0x214313){_0x9101ec=_0x9101ec-0x0;var _0xfa829d=_0x19a4[_0x9101ec];return _0xfa829d;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0x419a('0x0'));var zipdir=require(_0x419a('0x1'));var jsonpatch=require(_0x419a('0x2'));var rp=require('request-promise');var moment=require(_0x419a('0x3'));var BPromise=require('bluebird');var Mustache=require('mustache');var util=require(_0x419a('0x4'));var path=require(_0x419a('0x5'));var sox=require(_0x419a('0x6'));var csv=require(_0x419a('0x7'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0x419a('0x8'));var _=require('lodash');var squel=require(_0x419a('0x9'));var crypto=require(_0x419a('0xa'));var jsforce=require(_0x419a('0xb'));var deskjs=require(_0x419a('0xc'));var toCsv=require(_0x419a('0x7'));var querystring=require(_0x419a('0xd'));var Papa=require(_0x419a('0xe'));var Redis=require('ioredis');var authService=require(_0x419a('0xf'));var qs=require(_0x419a('0x10'));var as=require(_0x419a('0x11'));var hardwareService=require(_0x419a('0x12'));var logger=require(_0x419a('0x13'))(_0x419a('0x14'));var utils=require(_0x419a('0x15'));var config=require('../../config/environment');var licenseUtil=require('../../config/license/util');var db=require(_0x419a('0x16'))['db'];function respondWithStatusCode(_0x121413,_0x2e718a){_0x2e718a=_0x2e718a||0xcc;return function(_0x58121e){if(_0x58121e){return _0x121413['sendStatus'](_0x2e718a);}return _0x121413[_0x419a('0x17')](_0x2e718a)[_0x419a('0x18')]();};}function respondWithResult(_0x22d0e6,_0x6a145){_0x6a145=_0x6a145||0xc8;return function(_0x4cc2ed){if(_0x4cc2ed){return _0x22d0e6[_0x419a('0x17')](_0x6a145)['json'](_0x4cc2ed);}};}function respondWithFilteredResult(_0x12037b,_0x20d782){return function(_0xa9c66){if(_0xa9c66){var _0x5eb4ae=typeof _0x20d782[_0x419a('0x19')]===_0x419a('0x1a')&&typeof _0x20d782[_0x419a('0x1b')]===_0x419a('0x1a');var _0x5470cb=_0xa9c66[_0x419a('0x1c')];var _0x4d3fb9=_0x5eb4ae?0x0:_0x20d782[_0x419a('0x19')];var _0x232a99=_0x5eb4ae?_0xa9c66[_0x419a('0x1c')]:_0x20d782[_0x419a('0x19')]+_0x20d782['limit'];var _0xa8ede2;if(_0x232a99>=_0x5470cb){_0x232a99=_0x5470cb;_0xa8ede2=0xc8;}else{_0xa8ede2=0xce;}_0x12037b[_0x419a('0x17')](_0xa8ede2);return _0x12037b[_0x419a('0x1d')](_0x419a('0x1e'),_0x4d3fb9+'-'+_0x232a99+'/'+_0x5470cb)[_0x419a('0x1f')](_0xa9c66);}return null;};}function patchUpdates(_0x37dae7){return function(_0x3e72f5){try{jsonpatch[_0x419a('0x20')](_0x3e72f5,_0x37dae7,!![]);}catch(_0x1217ca){return BPromise[_0x419a('0x21')](_0x1217ca);}return _0x3e72f5[_0x419a('0x22')]();};}function saveUpdates(_0x31167f,_0x5deaf6){return function(_0x34f55d){if(_0x34f55d){return _0x34f55d['update'](_0x31167f)[_0x419a('0x23')](function(_0x294825){return _0x294825;});}return null;};}function removeEntity(_0x369505,_0x11f6fc){return function(_0x2654c0){if(_0x2654c0){return _0x2654c0[_0x419a('0x24')]()[_0x419a('0x23')](function(){_0x369505[_0x419a('0x17')](0xcc)['end']();});}};}function handleEntityNotFound(_0x8b8ac3,_0x2427a8){return function(_0x16a3cd){if(!_0x16a3cd){_0x8b8ac3['sendStatus'](0x194);}return _0x16a3cd;};}function handleError(_0x576794,_0x592476){_0x592476=_0x592476||0x1f4;return function(_0x384265){logger['error'](_0x384265[_0x419a('0x25')]);if(_0x384265[_0x419a('0x26')]){delete _0x384265[_0x419a('0x26')];}_0x576794[_0x419a('0x17')](_0x592476)[_0x419a('0x27')](_0x384265);};}exports['index']=function(_0x26e5d9,_0x1a3020){var _0x551db1={},_0x51f8d6={},_0x5c57ee={'count':0x0,'rows':[]};var _0x28f702=_[_0x419a('0x28')](db[_0x419a('0x29')][_0x419a('0x2a')],function(_0x50db92){return{'name':_0x50db92[_0x419a('0x2b')],'type':_0x50db92[_0x419a('0x2c')][_0x419a('0x2d')]};});_0x51f8d6[_0x419a('0x2e')]=_['map'](_0x28f702,'name');_0x51f8d6[_0x419a('0x2f')]=_[_0x419a('0x30')](_0x26e5d9[_0x419a('0x2f')]);_0x51f8d6['filters']=_[_0x419a('0x31')](_0x51f8d6['model'],_0x51f8d6[_0x419a('0x2f')]);_0x551db1[_0x419a('0x32')]=_[_0x419a('0x31')](_0x51f8d6[_0x419a('0x2e')],qs[_0x419a('0x33')](_0x26e5d9[_0x419a('0x2f')][_0x419a('0x33')]));_0x551db1[_0x419a('0x32')]=_0x551db1[_0x419a('0x32')]['length']?_0x551db1['attributes']:_0x51f8d6['model'];if(!_0x26e5d9[_0x419a('0x2f')][_0x419a('0x34')]('nolimit')){_0x551db1[_0x419a('0x1b')]=qs[_0x419a('0x1b')](_0x26e5d9['query'][_0x419a('0x1b')]);_0x551db1[_0x419a('0x19')]=qs[_0x419a('0x19')](_0x26e5d9[_0x419a('0x2f')]['offset']);}_0x551db1[_0x419a('0x35')]=qs['sort'](_0x26e5d9['query'][_0x419a('0x36')]);_0x551db1[_0x419a('0x37')]=qs[_0x419a('0x38')](_[_0x419a('0x39')](_0x26e5d9[_0x419a('0x2f')],_0x51f8d6[_0x419a('0x38')]),_0x28f702);if(_0x26e5d9[_0x419a('0x2f')]['filter']){_0x551db1[_0x419a('0x37')]=_[_0x419a('0x3a')](_0x551db1[_0x419a('0x37')],{'$or':_[_0x419a('0x28')](_0x28f702,function(_0x45ab0b){if(_0x45ab0b[_0x419a('0x2c')]!==_0x419a('0x3b')){var _0x5db222={};_0x5db222[_0x45ab0b[_0x419a('0x26')]]={'$like':'%'+_0x26e5d9[_0x419a('0x2f')]['filter']+'%'};return _0x5db222;}})});}_0x551db1=_[_0x419a('0x3a')]({},_0x551db1,_0x26e5d9[_0x419a('0x3c')]);var _0x20e20e={'where':_0x551db1[_0x419a('0x37')]};return db[_0x419a('0x29')][_0x419a('0x1c')](_0x20e20e)[_0x419a('0x23')](function(_0x58eeb1){_0x5c57ee[_0x419a('0x1c')]=_0x58eeb1;if(_0x26e5d9[_0x419a('0x2f')][_0x419a('0x3d')]){_0x551db1[_0x419a('0x3e')]=[{'all':!![]}];}return db['SugarcrmConfiguration'][_0x419a('0x3f')](_0x551db1);})[_0x419a('0x23')](function(_0x2877da){_0x5c57ee[_0x419a('0x40')]=_0x2877da;return _0x5c57ee;})[_0x419a('0x23')](respondWithFilteredResult(_0x1a3020,_0x551db1))['catch'](handleError(_0x1a3020,null));};exports[_0x419a('0x41')]=function(_0xfae654,_0x1dd451){var _0x142d68={'raw':![],'where':{'id':_0xfae654['params']['id']}},_0x48bd47={};_0x48bd47['model']=_[_0x419a('0x30')](db[_0x419a('0x29')][_0x419a('0x2a')]);_0x48bd47['query']=_[_0x419a('0x30')](_0xfae654['query']);_0x48bd47[_0x419a('0x38')]=_[_0x419a('0x31')](_0x48bd47[_0x419a('0x2e')],_0x48bd47['query']);_0x142d68['attributes']=_['intersection'](_0x48bd47[_0x419a('0x2e')],qs['fields'](_0xfae654[_0x419a('0x2f')][_0x419a('0x33')]));_0x142d68[_0x419a('0x32')]=_0x142d68[_0x419a('0x32')][_0x419a('0x42')]?_0x142d68['attributes']:_0x48bd47[_0x419a('0x2e')];if(_0xfae654[_0x419a('0x2f')][_0x419a('0x3d')]){_0x142d68[_0x419a('0x3e')]=[{'all':!![]}];}_0x142d68=_[_0x419a('0x3a')]({},_0x142d68,_0xfae654[_0x419a('0x3c')]);return db[_0x419a('0x29')][_0x419a('0x43')](_0x142d68)[_0x419a('0x23')](handleEntityNotFound(_0x1dd451,null))[_0x419a('0x23')](respondWithResult(_0x1dd451,null))[_0x419a('0x44')](handleError(_0x1dd451,null));};exports['create']=function(_0x5e8aea,_0x5df708){return db[_0x419a('0x29')][_0x419a('0x45')](_0x5e8aea['body'],{})['then'](respondWithResult(_0x5df708,0xc9))[_0x419a('0x44')](handleError(_0x5df708,null));};exports['update']=function(_0x5e1bd5,_0x4b67b6){if(_0x5e1bd5['body']['id']){delete _0x5e1bd5[_0x419a('0x46')]['id'];}return db[_0x419a('0x29')][_0x419a('0x43')]({'where':{'id':_0x5e1bd5[_0x419a('0x47')]['id']}})['then'](handleEntityNotFound(_0x4b67b6,null))['then'](saveUpdates(_0x5e1bd5[_0x419a('0x46')],null))[_0x419a('0x23')](respondWithResult(_0x4b67b6,null))[_0x419a('0x44')](handleError(_0x4b67b6,null));};exports['destroy']=function(_0xd70019,_0x4b86db){return db[_0x419a('0x29')][_0x419a('0x43')]({'where':{'id':_0xd70019[_0x419a('0x47')]['id']}})[_0x419a('0x23')](handleEntityNotFound(_0x4b86db,null))[_0x419a('0x23')](removeEntity(_0x4b86db,null))[_0x419a('0x44')](handleError(_0x4b86db,null));};exports[_0x419a('0x48')]=function(_0x25c048,_0x123955,_0x599ccc){var _0x1860e3={};var _0x2e68dc={};var _0x5a25a0;var _0x2e3bb4;return db['SugarcrmConfiguration'][_0x419a('0x49')]({'where':{'id':_0x25c048[_0x419a('0x47')]['id']}})['then'](handleEntityNotFound(_0x123955,null))[_0x419a('0x23')](function(_0x34c8b1){if(_0x34c8b1){_0x5a25a0=_0x34c8b1;_0x2e68dc['model']=_['keys'](db[_0x419a('0x4a')][_0x419a('0x2a')]);_0x2e68dc[_0x419a('0x2f')]=_['keys'](_0x25c048[_0x419a('0x2f')]);_0x2e68dc[_0x419a('0x38')]=_[_0x419a('0x31')](_0x2e68dc[_0x419a('0x2e')],_0x2e68dc['query']);_0x1860e3[_0x419a('0x32')]=_[_0x419a('0x31')](_0x2e68dc[_0x419a('0x2e')],qs[_0x419a('0x33')](_0x25c048[_0x419a('0x2f')][_0x419a('0x33')]));_0x1860e3[_0x419a('0x32')]=_0x1860e3['attributes'][_0x419a('0x42')]?_0x1860e3[_0x419a('0x32')]:_0x2e68dc[_0x419a('0x2e')];_0x1860e3[_0x419a('0x35')]=qs[_0x419a('0x36')](_0x25c048[_0x419a('0x2f')][_0x419a('0x36')]);_0x1860e3[_0x419a('0x37')]=qs[_0x419a('0x38')](_['pick'](_0x25c048[_0x419a('0x2f')],_0x2e68dc[_0x419a('0x38')]));if(_0x25c048[_0x419a('0x2f')][_0x419a('0x4b')]){_0x1860e3['where']=_[_0x419a('0x3a')](_0x1860e3[_0x419a('0x37')],{'$or':_[_0x419a('0x28')](_0x1860e3[_0x419a('0x32')],function(_0x15e595){var _0x2c0d0e={};_0x2c0d0e[_0x15e595]={'$like':'%'+_0x25c048[_0x419a('0x2f')][_0x419a('0x4b')]+'%'};return _0x2c0d0e;})});}_0x1860e3=_[_0x419a('0x3a')]({},_0x1860e3,_0x25c048['options']);return _0x5a25a0[_0x419a('0x48')](_0x1860e3);}})['then'](function(_0x24295d){if(_0x24295d){_0x2e3bb4=_0x24295d[_0x419a('0x42')];if(!_0x25c048[_0x419a('0x2f')][_0x419a('0x34')](_0x419a('0x4c'))){_0x1860e3[_0x419a('0x1b')]=qs[_0x419a('0x1b')](_0x25c048[_0x419a('0x2f')][_0x419a('0x1b')]);_0x1860e3[_0x419a('0x19')]=qs[_0x419a('0x19')](_0x25c048[_0x419a('0x2f')][_0x419a('0x19')]);}return _0x5a25a0['getFields'](_0x1860e3);}})[_0x419a('0x23')](function(_0xe8805e){if(_0xe8805e){return _0xe8805e?{'count':_0x2e3bb4,'rows':_0xe8805e}:null;}})[_0x419a('0x23')](respondWithResult(_0x123955,null))[_0x419a('0x44')](handleError(_0x123955,null));};exports[_0x419a('0x4d')]=function(_0xed0a76,_0x5efc5d,_0x40f7d1){var _0x20407f={};var _0x56d8ff={};var _0x172d14;var _0x5c24e2;return db['SugarcrmConfiguration'][_0x419a('0x49')]({'where':{'id':_0xed0a76['params']['id']}})[_0x419a('0x23')](handleEntityNotFound(_0x5efc5d,null))['then'](function(_0xd23a5a){if(_0xd23a5a){_0x172d14=_0xd23a5a;_0x56d8ff['model']=_[_0x419a('0x30')](db['SugarcrmField'][_0x419a('0x2a')]);_0x56d8ff[_0x419a('0x2f')]=_[_0x419a('0x30')](_0xed0a76['query']);_0x56d8ff[_0x419a('0x38')]=_[_0x419a('0x31')](_0x56d8ff[_0x419a('0x2e')],_0x56d8ff[_0x419a('0x2f')]);_0x20407f[_0x419a('0x32')]=_['intersection'](_0x56d8ff['model'],qs[_0x419a('0x33')](_0xed0a76['query'][_0x419a('0x33')]));_0x20407f[_0x419a('0x32')]=_0x20407f[_0x419a('0x32')][_0x419a('0x42')]?_0x20407f['attributes']:_0x56d8ff[_0x419a('0x2e')];_0x20407f[_0x419a('0x35')]=qs[_0x419a('0x36')](_0xed0a76['query'][_0x419a('0x36')]);_0x20407f[_0x419a('0x37')]=qs[_0x419a('0x38')](_[_0x419a('0x39')](_0xed0a76[_0x419a('0x2f')],_0x56d8ff[_0x419a('0x38')]));if(_0xed0a76[_0x419a('0x2f')][_0x419a('0x4b')]){_0x20407f[_0x419a('0x37')]=_[_0x419a('0x3a')](_0x20407f[_0x419a('0x37')],{'$or':_[_0x419a('0x28')](_0x20407f[_0x419a('0x32')],function(_0x2308a4){var _0x22f788={};_0x22f788[_0x2308a4]={'$like':'%'+_0xed0a76[_0x419a('0x2f')][_0x419a('0x4b')]+'%'};return _0x22f788;})});}_0x20407f=_[_0x419a('0x3a')]({},_0x20407f,_0xed0a76[_0x419a('0x3c')]);return _0x172d14[_0x419a('0x4d')](_0x20407f);}})[_0x419a('0x23')](function(_0x4151ca){if(_0x4151ca){_0x5c24e2=_0x4151ca['length'];if(!_0xed0a76[_0x419a('0x2f')][_0x419a('0x34')](_0x419a('0x4c'))){_0x20407f['limit']=qs[_0x419a('0x1b')](_0xed0a76[_0x419a('0x2f')][_0x419a('0x1b')]);_0x20407f['offset']=qs[_0x419a('0x19')](_0xed0a76[_0x419a('0x2f')][_0x419a('0x19')]);}return _0x172d14[_0x419a('0x4d')](_0x20407f);}})['then'](function(_0x5b31f3){if(_0x5b31f3){return _0x5b31f3?{'count':_0x5c24e2,'rows':_0x5b31f3}:null;}})['then'](respondWithResult(_0x5efc5d,null))['catch'](handleError(_0x5efc5d,null));};exports[_0x419a('0x4e')]=function(_0xf85464,_0x109ad3,_0x4dc32c){var _0x1245a0={};var _0x26c957={};var _0x46fb8c;var _0x18f39d;return db[_0x419a('0x29')][_0x419a('0x49')]({'where':{'id':_0xf85464[_0x419a('0x47')]['id']}})['then'](handleEntityNotFound(_0x109ad3,null))['then'](function(_0x260b2d){if(_0x260b2d){_0x46fb8c=_0x260b2d;_0x26c957['model']=_[_0x419a('0x30')](db['SugarcrmField'][_0x419a('0x2a')]);_0x26c957[_0x419a('0x2f')]=_[_0x419a('0x30')](_0xf85464[_0x419a('0x2f')]);_0x26c957[_0x419a('0x38')]=_[_0x419a('0x31')](_0x26c957[_0x419a('0x2e')],_0x26c957[_0x419a('0x2f')]);_0x1245a0[_0x419a('0x32')]=_[_0x419a('0x31')](_0x26c957[_0x419a('0x2e')],qs['fields'](_0xf85464[_0x419a('0x2f')]['fields']));_0x1245a0[_0x419a('0x32')]=_0x1245a0[_0x419a('0x32')]['length']?_0x1245a0[_0x419a('0x32')]:_0x26c957[_0x419a('0x2e')];_0x1245a0[_0x419a('0x35')]=qs[_0x419a('0x36')](_0xf85464[_0x419a('0x2f')]['sort']);_0x1245a0[_0x419a('0x37')]=qs[_0x419a('0x38')](_[_0x419a('0x39')](_0xf85464['query'],_0x26c957[_0x419a('0x38')]));if(_0xf85464['query'][_0x419a('0x4b')]){_0x1245a0['where']=_['merge'](_0x1245a0['where'],{'$or':_['map'](_0x1245a0[_0x419a('0x32')],function(_0x26aaa4){var _0x5c63bc={};_0x5c63bc[_0x26aaa4]={'$like':'%'+_0xf85464[_0x419a('0x2f')][_0x419a('0x4b')]+'%'};return _0x5c63bc;})});}_0x1245a0=_[_0x419a('0x3a')]({},_0x1245a0,_0xf85464['options']);return _0x46fb8c[_0x419a('0x4e')](_0x1245a0);}})[_0x419a('0x23')](function(_0x5da86f){if(_0x5da86f){_0x18f39d=_0x5da86f[_0x419a('0x42')];if(!_0xf85464[_0x419a('0x2f')][_0x419a('0x34')](_0x419a('0x4c'))){_0x1245a0[_0x419a('0x1b')]=qs[_0x419a('0x1b')](_0xf85464[_0x419a('0x2f')][_0x419a('0x1b')]);_0x1245a0[_0x419a('0x19')]=qs[_0x419a('0x19')](_0xf85464[_0x419a('0x2f')][_0x419a('0x19')]);}return _0x46fb8c[_0x419a('0x4e')](_0x1245a0);}})[_0x419a('0x23')](function(_0x2fbd7b){if(_0x2fbd7b){return _0x2fbd7b?{'count':_0x18f39d,'rows':_0x2fbd7b}:null;}})['then'](respondWithResult(_0x109ad3,null))['catch'](handleError(_0x109ad3,null));};
\ No newline at end of file