Built motion from commit 497d3d92.|2.5.43
[motion2.git] / server / api / intSugarcrmConfiguration / intSugarcrmConfiguration.controller.js
index 7c0c4f8..4e9577b 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x8ac0=['papaparse','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','api','../../config/environment','../../config/license/util','../../mysqldb','jayson/promise','http','request','info','SugarcrmConfiguration,\x20%s,\x20%s','request\x20sent','debug','SugarcrmConfiguration,\x20%s,\x20%s,\x20%s','error','code','message','result','catch','sendStatus','status','end','json','count','offset','limit','set','Content-Range','apply','reject','save','destroy','then','stack','name','map','SugarcrmConfiguration','rawAttributes','type','key','query','intersection','model','attributes','fields','length','nolimit','order','sort','filters','filter','where','merge','VIRTUAL','options','includeAll','include','findAll','rows','show','params','keys','find','create','body','getFields','findOne','SugarcrmField','pick','hasOwnProperty','getSubjects','getDescriptions','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','util','sox','ejs','squel','jsforce','desk.js','to-csv','querystring'];(function(_0x3e8643,_0x18d174){var _0x18198f=function(_0x3677ad){while(--_0x3677ad){_0x3e8643['push'](_0x3e8643['shift']());}};_0x18198f(++_0x18d174);}(_0x8ac0,0xfe));var _0x08ac=function(_0x454207,_0xe465c3){_0x454207=_0x454207-0x0;var _0x10e6b0=_0x8ac0[_0x454207];return _0x10e6b0;};'use strict';var pdf=require('html-pdf');var emlformat=require(_0x08ac('0x0'));var rimraf=require(_0x08ac('0x1'));var zipdir=require(_0x08ac('0x2'));var jsonpatch=require(_0x08ac('0x3'));var rp=require(_0x08ac('0x4'));var moment=require(_0x08ac('0x5'));var BPromise=require(_0x08ac('0x6'));var Mustache=require(_0x08ac('0x7'));var util=require(_0x08ac('0x8'));var path=require('path');var sox=require(_0x08ac('0x9'));var csv=require('to-csv');var ejs=require(_0x08ac('0xa'));var fs=require('fs');var _=require('lodash');var squel=require(_0x08ac('0xb'));var crypto=require('crypto');var jsforce=require(_0x08ac('0xc'));var deskjs=require(_0x08ac('0xd'));var toCsv=require(_0x08ac('0xe'));var querystring=require(_0x08ac('0xf'));var Papa=require(_0x08ac('0x10'));var Redis=require('ioredis');var authService=require('../../components/auth/service');var qs=require(_0x08ac('0x11'));var as=require(_0x08ac('0x12'));var hardwareService=require(_0x08ac('0x13'));var logger=require('../../config/logger')(_0x08ac('0x14'));var utils=require('../../config/utils');var config=require(_0x08ac('0x15'));var licenseUtil=require(_0x08ac('0x16'));var db=require(_0x08ac('0x17'))['db'];var jayson=require(_0x08ac('0x18'));var client=jayson['client'][_0x08ac('0x19')]({'port':0x232a});function respondWithRpcPromise(_0x37fbab,_0x4f8de0,_0x380532,_0x420c54){return new BPromise(function(_0x256ff0,_0x43e74f){var _0x53f958=_0x420c54||client;return _0x53f958[_0x08ac('0x1a')](_0x37fbab,_0x380532)['then'](function(_0x996c81){logger[_0x08ac('0x1b')](_0x08ac('0x1c'),_0x4f8de0,_0x08ac('0x1d'));logger[_0x08ac('0x1e')](_0x08ac('0x1f'),_0x4f8de0,_0x08ac('0x1d'),JSON['stringify'](_0x996c81));if(_0x996c81[_0x08ac('0x20')]){if(_0x996c81[_0x08ac('0x20')][_0x08ac('0x21')]===0x1f4){logger[_0x08ac('0x20')](_0x08ac('0x1c'),_0x4f8de0,_0x996c81['error']['message']);return _0x43e74f(_0x996c81[_0x08ac('0x20')][_0x08ac('0x22')]);}logger[_0x08ac('0x20')]('SugarcrmConfiguration,\x20%s,\x20%s',_0x4f8de0,_0x996c81[_0x08ac('0x20')][_0x08ac('0x22')]);return _0x256ff0(_0x996c81['error'][_0x08ac('0x22')]);}else{logger[_0x08ac('0x1b')]('SugarcrmConfiguration,\x20%s,\x20%s',_0x4f8de0,'request\x20sent');_0x256ff0(_0x996c81[_0x08ac('0x23')][_0x08ac('0x22')]);}})[_0x08ac('0x24')](function(_0x51c60f){logger[_0x08ac('0x20')](_0x08ac('0x1c'),_0x4f8de0,_0x51c60f);_0x43e74f(_0x51c60f);});});}function respondWithStatusCode(_0x2cd274,_0x1bb590){_0x1bb590=_0x1bb590||0xcc;return function(_0x29e1bf){if(_0x29e1bf){return _0x2cd274[_0x08ac('0x25')](_0x1bb590);}return _0x2cd274[_0x08ac('0x26')](_0x1bb590)[_0x08ac('0x27')]();};}function respondWithResult(_0xd99234,_0x2a52d9){_0x2a52d9=_0x2a52d9||0xc8;return function(_0x71cc6d){if(_0x71cc6d){return _0xd99234['status'](_0x2a52d9)[_0x08ac('0x28')](_0x71cc6d);}};}function respondWithFilteredResult(_0x395d49,_0x5b82c6){return function(_0x287faa){if(_0x287faa){var _0x297902=_0x287faa[_0x08ac('0x29')],_0x5c7444=_0x5b82c6['offset'],_0x150ab2=_0x5b82c6[_0x08ac('0x2a')]+_0x5b82c6[_0x08ac('0x2b')],_0x77c937;if(_0x150ab2>=_0x297902){_0x150ab2=_0x297902;_0x77c937=0xc8;}else{_0x77c937=0xce;}_0x395d49[_0x08ac('0x26')](_0x77c937);return _0x395d49[_0x08ac('0x2c')](_0x08ac('0x2d'),_0x5c7444+'-'+_0x150ab2+'/'+_0x297902)[_0x08ac('0x28')](_0x287faa);}return null;};}function patchUpdates(_0x58af97){return function(_0x11680b){try{jsonpatch[_0x08ac('0x2e')](_0x11680b,_0x58af97,!![]);}catch(_0x550f8c){return BPromise[_0x08ac('0x2f')](_0x550f8c);}return _0x11680b[_0x08ac('0x30')]();};}function saveUpdates(_0x3aa227,_0x3890c7){return function(_0x1b739a){if(_0x1b739a){return _0x1b739a['update'](_0x3aa227)['then'](function(_0x5b6420){return _0x5b6420;});}return null;};}function removeEntity(_0x1f6eba,_0x185a1f){return function(_0x23985e){if(_0x23985e){return _0x23985e[_0x08ac('0x31')]()[_0x08ac('0x32')](function(){_0x1f6eba['status'](0xcc)['end']();});}};}function handleEntityNotFound(_0x284925,_0x2d42e8){return function(_0x3c1124){if(!_0x3c1124){_0x284925[_0x08ac('0x25')](0x194);}return _0x3c1124;};}function handleError(_0x3cd7b5,_0x49d29f){_0x49d29f=_0x49d29f||0x1f4;return function(_0x35553d){logger['error'](_0x35553d[_0x08ac('0x33')]);if(_0x35553d['name']){delete _0x35553d[_0x08ac('0x34')];}_0x3cd7b5[_0x08ac('0x26')](_0x49d29f)['send'](_0x35553d);};}exports['index']=function(_0x24d268,_0x1d0630){var _0x57957e={},_0xb898c={},_0x40d846={'count':0x0,'rows':[]};var _0x38c5fc=_[_0x08ac('0x35')](db[_0x08ac('0x36')][_0x08ac('0x37')],function(_0x46cd41){return{'name':_0x46cd41['fieldName'],'type':_0x46cd41[_0x08ac('0x38')][_0x08ac('0x39')]};});_0xb898c['model']=_[_0x08ac('0x35')](_0x38c5fc,_0x08ac('0x34'));_0xb898c[_0x08ac('0x3a')]=_['keys'](_0x24d268['query']);_0xb898c['filters']=_[_0x08ac('0x3b')](_0xb898c[_0x08ac('0x3c')],_0xb898c[_0x08ac('0x3a')]);_0x57957e[_0x08ac('0x3d')]=_[_0x08ac('0x3b')](_0xb898c[_0x08ac('0x3c')],qs[_0x08ac('0x3e')](_0x24d268[_0x08ac('0x3a')][_0x08ac('0x3e')]));_0x57957e[_0x08ac('0x3d')]=_0x57957e['attributes'][_0x08ac('0x3f')]?_0x57957e[_0x08ac('0x3d')]:_0xb898c[_0x08ac('0x3c')];if(!_0x24d268[_0x08ac('0x3a')]['hasOwnProperty'](_0x08ac('0x40'))){_0x57957e['limit']=qs['limit'](_0x24d268[_0x08ac('0x3a')]['limit']);_0x57957e[_0x08ac('0x2a')]=qs['offset'](_0x24d268[_0x08ac('0x3a')][_0x08ac('0x2a')]);}_0x57957e[_0x08ac('0x41')]=qs['sort'](_0x24d268[_0x08ac('0x3a')][_0x08ac('0x42')]);_0x57957e['where']=qs[_0x08ac('0x43')](_['pick'](_0x24d268[_0x08ac('0x3a')],_0xb898c[_0x08ac('0x43')]),_0x38c5fc);if(_0x24d268[_0x08ac('0x3a')][_0x08ac('0x44')]){_0x57957e[_0x08ac('0x45')]=_[_0x08ac('0x46')](_0x57957e[_0x08ac('0x45')],{'$or':_[_0x08ac('0x35')](_0x38c5fc,function(_0x3f29cb){if(_0x3f29cb[_0x08ac('0x38')]!==_0x08ac('0x47')){var _0x5e7483={};_0x5e7483[_0x3f29cb[_0x08ac('0x34')]]={'$like':'%'+_0x24d268[_0x08ac('0x3a')][_0x08ac('0x44')]+'%'};return _0x5e7483;}})});}_0x57957e=_[_0x08ac('0x46')]({},_0x57957e,_0x24d268[_0x08ac('0x48')]);var _0x50588f={'where':_0x57957e[_0x08ac('0x45')]};return db['SugarcrmConfiguration']['count'](_0x50588f)[_0x08ac('0x32')](function(_0x2cf23c){_0x40d846['count']=_0x2cf23c;if(_0x24d268[_0x08ac('0x3a')][_0x08ac('0x49')]){_0x57957e[_0x08ac('0x4a')]=[{'all':!![]}];}return db[_0x08ac('0x36')][_0x08ac('0x4b')](_0x57957e);})['then'](function(_0x1f0bad){_0x40d846[_0x08ac('0x4c')]=_0x1f0bad;return _0x40d846;})[_0x08ac('0x32')](respondWithFilteredResult(_0x1d0630,_0x57957e))[_0x08ac('0x24')](handleError(_0x1d0630,null));};exports[_0x08ac('0x4d')]=function(_0x28e9ad,_0x189f11){var _0x437fba={'raw':![],'where':{'id':_0x28e9ad[_0x08ac('0x4e')]['id']}},_0x5ea634={};_0x5ea634[_0x08ac('0x3c')]=_[_0x08ac('0x4f')](db[_0x08ac('0x36')][_0x08ac('0x37')]);_0x5ea634['query']=_['keys'](_0x28e9ad[_0x08ac('0x3a')]);_0x5ea634[_0x08ac('0x43')]=_[_0x08ac('0x3b')](_0x5ea634['model'],_0x5ea634[_0x08ac('0x3a')]);_0x437fba[_0x08ac('0x3d')]=_['intersection'](_0x5ea634[_0x08ac('0x3c')],qs[_0x08ac('0x3e')](_0x28e9ad[_0x08ac('0x3a')][_0x08ac('0x3e')]));_0x437fba['attributes']=_0x437fba[_0x08ac('0x3d')][_0x08ac('0x3f')]?_0x437fba[_0x08ac('0x3d')]:_0x5ea634[_0x08ac('0x3c')];if(_0x28e9ad[_0x08ac('0x3a')][_0x08ac('0x49')]){_0x437fba['include']=[{'all':!![]}];}_0x437fba=_['merge']({},_0x437fba,_0x28e9ad[_0x08ac('0x48')]);return db[_0x08ac('0x36')][_0x08ac('0x50')](_0x437fba)[_0x08ac('0x32')](handleEntityNotFound(_0x189f11,null))[_0x08ac('0x32')](respondWithResult(_0x189f11,null))[_0x08ac('0x24')](handleError(_0x189f11,null));};exports[_0x08ac('0x51')]=function(_0x4d8f41,_0xb0a9b5){return db['SugarcrmConfiguration'][_0x08ac('0x51')](_0x4d8f41[_0x08ac('0x52')],{})[_0x08ac('0x32')](respondWithResult(_0xb0a9b5,0xc9))[_0x08ac('0x24')](handleError(_0xb0a9b5,null));};exports['update']=function(_0x4a93c6,_0x3a7a2f){if(_0x4a93c6[_0x08ac('0x52')]['id']){delete _0x4a93c6[_0x08ac('0x52')]['id'];}return db['SugarcrmConfiguration'][_0x08ac('0x50')]({'where':{'id':_0x4a93c6[_0x08ac('0x4e')]['id']}})[_0x08ac('0x32')](handleEntityNotFound(_0x3a7a2f,null))[_0x08ac('0x32')](saveUpdates(_0x4a93c6[_0x08ac('0x52')],null))[_0x08ac('0x32')](respondWithResult(_0x3a7a2f,null))[_0x08ac('0x24')](handleError(_0x3a7a2f,null));};exports['destroy']=function(_0x43f194,_0x24766a){return db[_0x08ac('0x36')]['find']({'where':{'id':_0x43f194[_0x08ac('0x4e')]['id']}})[_0x08ac('0x32')](handleEntityNotFound(_0x24766a,null))[_0x08ac('0x32')](removeEntity(_0x24766a,null))['catch'](handleError(_0x24766a,null));};exports[_0x08ac('0x53')]=function(_0x1b6328,_0x5ca564,_0x4b4279){var _0x5e3958={};var _0x45979a={};var _0x58352e;var _0x7d703;return db['SugarcrmConfiguration'][_0x08ac('0x54')]({'where':{'id':_0x1b6328['params']['id']}})['then'](handleEntityNotFound(_0x5ca564,null))[_0x08ac('0x32')](function(_0xc51a90){if(_0xc51a90){_0x58352e=_0xc51a90;_0x45979a['model']=_[_0x08ac('0x4f')](db[_0x08ac('0x55')]['rawAttributes']);_0x45979a['query']=_[_0x08ac('0x4f')](_0x1b6328[_0x08ac('0x3a')]);_0x45979a[_0x08ac('0x43')]=_[_0x08ac('0x3b')](_0x45979a[_0x08ac('0x3c')],_0x45979a['query']);_0x5e3958[_0x08ac('0x3d')]=_[_0x08ac('0x3b')](_0x45979a[_0x08ac('0x3c')],qs[_0x08ac('0x3e')](_0x1b6328['query'][_0x08ac('0x3e')]));_0x5e3958[_0x08ac('0x3d')]=_0x5e3958[_0x08ac('0x3d')][_0x08ac('0x3f')]?_0x5e3958[_0x08ac('0x3d')]:_0x45979a['model'];_0x5e3958[_0x08ac('0x41')]=qs[_0x08ac('0x42')](_0x1b6328[_0x08ac('0x3a')][_0x08ac('0x42')]);_0x5e3958['where']=qs[_0x08ac('0x43')](_[_0x08ac('0x56')](_0x1b6328[_0x08ac('0x3a')],_0x45979a[_0x08ac('0x43')]));if(_0x1b6328[_0x08ac('0x3a')][_0x08ac('0x44')]){_0x5e3958['where']=_[_0x08ac('0x46')](_0x5e3958[_0x08ac('0x45')],{'$or':_[_0x08ac('0x35')](_0x5e3958[_0x08ac('0x3d')],function(_0x3494fc){var _0x20af9e={};_0x20af9e[_0x3494fc]={'$like':'%'+_0x1b6328[_0x08ac('0x3a')]['filter']+'%'};return _0x20af9e;})});}_0x5e3958=_['merge']({},_0x5e3958,_0x1b6328[_0x08ac('0x48')]);return _0x58352e[_0x08ac('0x53')](_0x5e3958);}})[_0x08ac('0x32')](function(_0x1e0672){if(_0x1e0672){_0x7d703=_0x1e0672[_0x08ac('0x3f')];if(!_0x1b6328['query'][_0x08ac('0x57')](_0x08ac('0x40'))){_0x5e3958['limit']=qs[_0x08ac('0x2b')](_0x1b6328[_0x08ac('0x3a')]['limit']);_0x5e3958[_0x08ac('0x2a')]=qs[_0x08ac('0x2a')](_0x1b6328['query']['offset']);}return _0x58352e['getFields'](_0x5e3958);}})[_0x08ac('0x32')](function(_0xd74d3f){if(_0xd74d3f){return _0xd74d3f?{'count':_0x7d703,'rows':_0xd74d3f}:null;}})['then'](respondWithResult(_0x5ca564,null))[_0x08ac('0x24')](handleError(_0x5ca564,null));};exports[_0x08ac('0x58')]=function(_0x22e856,_0x5b48e4,_0x1a6665){var _0x550fd9={};var _0x5e35d7={};var _0x12a60d;var _0x55694d;return db['SugarcrmConfiguration'][_0x08ac('0x54')]({'where':{'id':_0x22e856[_0x08ac('0x4e')]['id']}})['then'](handleEntityNotFound(_0x5b48e4,null))[_0x08ac('0x32')](function(_0x4a0d1e){if(_0x4a0d1e){_0x12a60d=_0x4a0d1e;_0x5e35d7[_0x08ac('0x3c')]=_[_0x08ac('0x4f')](db[_0x08ac('0x55')]['rawAttributes']);_0x5e35d7[_0x08ac('0x3a')]=_[_0x08ac('0x4f')](_0x22e856['query']);_0x5e35d7[_0x08ac('0x43')]=_[_0x08ac('0x3b')](_0x5e35d7[_0x08ac('0x3c')],_0x5e35d7[_0x08ac('0x3a')]);_0x550fd9[_0x08ac('0x3d')]=_[_0x08ac('0x3b')](_0x5e35d7['model'],qs[_0x08ac('0x3e')](_0x22e856[_0x08ac('0x3a')][_0x08ac('0x3e')]));_0x550fd9[_0x08ac('0x3d')]=_0x550fd9[_0x08ac('0x3d')][_0x08ac('0x3f')]?_0x550fd9[_0x08ac('0x3d')]:_0x5e35d7[_0x08ac('0x3c')];_0x550fd9[_0x08ac('0x41')]=qs[_0x08ac('0x42')](_0x22e856[_0x08ac('0x3a')]['sort']);_0x550fd9[_0x08ac('0x45')]=qs[_0x08ac('0x43')](_[_0x08ac('0x56')](_0x22e856[_0x08ac('0x3a')],_0x5e35d7['filters']));if(_0x22e856[_0x08ac('0x3a')][_0x08ac('0x44')]){_0x550fd9[_0x08ac('0x45')]=_[_0x08ac('0x46')](_0x550fd9['where'],{'$or':_[_0x08ac('0x35')](_0x550fd9[_0x08ac('0x3d')],function(_0x174299){var _0x175436={};_0x175436[_0x174299]={'$like':'%'+_0x22e856[_0x08ac('0x3a')]['filter']+'%'};return _0x175436;})});}_0x550fd9=_['merge']({},_0x550fd9,_0x22e856[_0x08ac('0x48')]);return _0x12a60d['getSubjects'](_0x550fd9);}})[_0x08ac('0x32')](function(_0x310518){if(_0x310518){_0x55694d=_0x310518['length'];if(!_0x22e856[_0x08ac('0x3a')]['hasOwnProperty']('nolimit')){_0x550fd9[_0x08ac('0x2b')]=qs[_0x08ac('0x2b')](_0x22e856[_0x08ac('0x3a')][_0x08ac('0x2b')]);_0x550fd9['offset']=qs[_0x08ac('0x2a')](_0x22e856[_0x08ac('0x3a')][_0x08ac('0x2a')]);}return _0x12a60d[_0x08ac('0x58')](_0x550fd9);}})['then'](function(_0x125202){if(_0x125202){return _0x125202?{'count':_0x55694d,'rows':_0x125202}:null;}})['then'](respondWithResult(_0x5b48e4,null))[_0x08ac('0x24')](handleError(_0x5b48e4,null));};exports[_0x08ac('0x59')]=function(_0x4049cf,_0x20b339,_0x363577){var _0x512e56={};var _0x53a733={};var _0x2d9507;var _0x368af2;return db[_0x08ac('0x36')][_0x08ac('0x54')]({'where':{'id':_0x4049cf[_0x08ac('0x4e')]['id']}})[_0x08ac('0x32')](handleEntityNotFound(_0x20b339,null))[_0x08ac('0x32')](function(_0x2e87bf){if(_0x2e87bf){_0x2d9507=_0x2e87bf;_0x53a733[_0x08ac('0x3c')]=_[_0x08ac('0x4f')](db[_0x08ac('0x55')][_0x08ac('0x37')]);_0x53a733[_0x08ac('0x3a')]=_[_0x08ac('0x4f')](_0x4049cf[_0x08ac('0x3a')]);_0x53a733[_0x08ac('0x43')]=_[_0x08ac('0x3b')](_0x53a733['model'],_0x53a733[_0x08ac('0x3a')]);_0x512e56[_0x08ac('0x3d')]=_['intersection'](_0x53a733[_0x08ac('0x3c')],qs['fields'](_0x4049cf[_0x08ac('0x3a')]['fields']));_0x512e56[_0x08ac('0x3d')]=_0x512e56[_0x08ac('0x3d')][_0x08ac('0x3f')]?_0x512e56[_0x08ac('0x3d')]:_0x53a733[_0x08ac('0x3c')];_0x512e56[_0x08ac('0x41')]=qs[_0x08ac('0x42')](_0x4049cf[_0x08ac('0x3a')]['sort']);_0x512e56[_0x08ac('0x45')]=qs['filters'](_['pick'](_0x4049cf[_0x08ac('0x3a')],_0x53a733[_0x08ac('0x43')]));if(_0x4049cf[_0x08ac('0x3a')][_0x08ac('0x44')]){_0x512e56[_0x08ac('0x45')]=_[_0x08ac('0x46')](_0x512e56[_0x08ac('0x45')],{'$or':_['map'](_0x512e56['attributes'],function(_0xafe9c9){var _0x1bba82={};_0x1bba82[_0xafe9c9]={'$like':'%'+_0x4049cf['query'][_0x08ac('0x44')]+'%'};return _0x1bba82;})});}_0x512e56=_[_0x08ac('0x46')]({},_0x512e56,_0x4049cf[_0x08ac('0x48')]);return _0x2d9507[_0x08ac('0x59')](_0x512e56);}})['then'](function(_0x42a7ee){if(_0x42a7ee){_0x368af2=_0x42a7ee[_0x08ac('0x3f')];if(!_0x4049cf[_0x08ac('0x3a')][_0x08ac('0x57')]('nolimit')){_0x512e56[_0x08ac('0x2b')]=qs[_0x08ac('0x2b')](_0x4049cf[_0x08ac('0x3a')][_0x08ac('0x2b')]);_0x512e56[_0x08ac('0x2a')]=qs['offset'](_0x4049cf[_0x08ac('0x3a')][_0x08ac('0x2a')]);}return _0x2d9507[_0x08ac('0x59')](_0x512e56);}})[_0x08ac('0x32')](function(_0x176368){if(_0x176368){return _0x176368?{'count':_0x368af2,'rows':_0x176368}:null;}})[_0x08ac('0x32')](respondWithResult(_0x20b339,null))[_0x08ac('0x24')](handleError(_0x20b339,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