Built motion from commit (unavailable).|2.5.25
[motion2.git] / server / api / intSugarcrmConfiguration / intSugarcrmConfiguration.controller.js
index f819021..16e97de 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x2f7b=['Content-Range','apply','reject','save','then','destroy','stack','name','send','index','map','SugarcrmConfiguration','fieldName','type','key','model','query','filters','intersection','fields','attributes','length','nolimit','limit','order','sort','where','filter','merge','VIRTUAL','include','rows','show','params','keys','includeAll','options','find','create','body','update','getFields','findOne','SugarcrmField','pick','getSubjects','hasOwnProperty','rawAttributes','getDescriptions','html-pdf','eml-format','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','path','sox','squel','jsforce','desk.js','to-csv','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','jayson/promise','client','http','request','info','request\x20sent','debug','SugarcrmConfiguration,\x20%s,\x20%s,\x20%s','stringify','error','code','message','SugarcrmConfiguration,\x20%s,\x20%s','result','catch','sendStatus','status','end','json','count','offset','set'];(function(_0x15dbb6,_0x3752a1){var _0x17490b=function(_0x2fecab){while(--_0x2fecab){_0x15dbb6['push'](_0x15dbb6['shift']());}};_0x17490b(++_0x3752a1);}(_0x2f7b,0x1b5));var _0xb2f7=function(_0x24ee4b,_0x32b79e){_0x24ee4b=_0x24ee4b-0x0;var _0x56014c=_0x2f7b[_0x24ee4b];return _0x56014c;};'use strict';var pdf=require(_0xb2f7('0x0'));var emlformat=require(_0xb2f7('0x1'));var rimraf=require('rimraf');var zipdir=require(_0xb2f7('0x2'));var jsonpatch=require(_0xb2f7('0x3'));var rp=require(_0xb2f7('0x4'));var moment=require(_0xb2f7('0x5'));var BPromise=require(_0xb2f7('0x6'));var Mustache=require(_0xb2f7('0x7'));var util=require('util');var path=require(_0xb2f7('0x8'));var sox=require(_0xb2f7('0x9'));var csv=require('to-csv');var ejs=require('ejs');var fs=require('fs');var _=require('lodash');var squel=require(_0xb2f7('0xa'));var crypto=require('crypto');var jsforce=require(_0xb2f7('0xb'));var deskjs=require(_0xb2f7('0xc'));var toCsv=require(_0xb2f7('0xd'));var querystring=require(_0xb2f7('0xe'));var Papa=require(_0xb2f7('0xf'));var Redis=require(_0xb2f7('0x10'));var authService=require(_0xb2f7('0x11'));var qs=require(_0xb2f7('0x12'));var as=require(_0xb2f7('0x13'));var hardwareService=require('../../config/license/hardware');var logger=require(_0xb2f7('0x14'))(_0xb2f7('0x15'));var utils=require(_0xb2f7('0x16'));var config=require(_0xb2f7('0x17'));var licenseUtil=require(_0xb2f7('0x18'));var db=require(_0xb2f7('0x19'))['db'];var jayson=require(_0xb2f7('0x1a'));var client=jayson[_0xb2f7('0x1b')][_0xb2f7('0x1c')]({'port':0x232a});function respondWithRpcPromise(_0x5cdfc4,_0x4858e9,_0x42225c,_0x4aa9c1){return new BPromise(function(_0x269496,_0x3019d3){var _0x83669b=_0x4aa9c1||client;return _0x83669b[_0xb2f7('0x1d')](_0x5cdfc4,_0x42225c)['then'](function(_0x25b472){logger[_0xb2f7('0x1e')]('SugarcrmConfiguration,\x20%s,\x20%s',_0x4858e9,_0xb2f7('0x1f'));logger[_0xb2f7('0x20')](_0xb2f7('0x21'),_0x4858e9,_0xb2f7('0x1f'),JSON[_0xb2f7('0x22')](_0x25b472));if(_0x25b472[_0xb2f7('0x23')]){if(_0x25b472[_0xb2f7('0x23')][_0xb2f7('0x24')]===0x1f4){logger[_0xb2f7('0x23')]('SugarcrmConfiguration,\x20%s,\x20%s',_0x4858e9,_0x25b472['error'][_0xb2f7('0x25')]);return _0x3019d3(_0x25b472[_0xb2f7('0x23')][_0xb2f7('0x25')]);}logger[_0xb2f7('0x23')](_0xb2f7('0x26'),_0x4858e9,_0x25b472[_0xb2f7('0x23')]['message']);return _0x269496(_0x25b472['error'][_0xb2f7('0x25')]);}else{logger['info'](_0xb2f7('0x26'),_0x4858e9,'request\x20sent');_0x269496(_0x25b472[_0xb2f7('0x27')]['message']);}})[_0xb2f7('0x28')](function(_0x309fe5){logger[_0xb2f7('0x23')](_0xb2f7('0x26'),_0x4858e9,_0x309fe5);_0x3019d3(_0x309fe5);});});}function respondWithStatusCode(_0x1716b0,_0x55b2a6){_0x55b2a6=_0x55b2a6||0xcc;return function(_0x870018){if(_0x870018){return _0x1716b0[_0xb2f7('0x29')](_0x55b2a6);}return _0x1716b0[_0xb2f7('0x2a')](_0x55b2a6)[_0xb2f7('0x2b')]();};}function respondWithResult(_0x10dc7b,_0x37c67e){_0x37c67e=_0x37c67e||0xc8;return function(_0x300b58){if(_0x300b58){return _0x10dc7b[_0xb2f7('0x2a')](_0x37c67e)[_0xb2f7('0x2c')](_0x300b58);}};}function respondWithFilteredResult(_0x412c82,_0x470282){return function(_0x3a951b){if(_0x3a951b){var _0x7578a=_0x3a951b[_0xb2f7('0x2d')],_0x3a9d96=_0x470282[_0xb2f7('0x2e')],_0x3023e0=_0x470282[_0xb2f7('0x2e')]+_0x470282['limit'],_0x13d992;if(_0x3023e0>=_0x7578a){_0x3023e0=_0x7578a;_0x13d992=0xc8;}else{_0x13d992=0xce;}_0x412c82['status'](_0x13d992);return _0x412c82[_0xb2f7('0x2f')](_0xb2f7('0x30'),_0x3a9d96+'-'+_0x3023e0+'/'+_0x7578a)['json'](_0x3a951b);}return null;};}function patchUpdates(_0x1f7e21){return function(_0x16574f){try{jsonpatch[_0xb2f7('0x31')](_0x16574f,_0x1f7e21,!![]);}catch(_0x2893e9){return BPromise[_0xb2f7('0x32')](_0x2893e9);}return _0x16574f[_0xb2f7('0x33')]();};}function saveUpdates(_0x5e28ec,_0x322252){return function(_0x2f1113){if(_0x2f1113){return _0x2f1113['update'](_0x5e28ec)[_0xb2f7('0x34')](function(_0x59bdd8){return _0x59bdd8;});}return null;};}function removeEntity(_0x28201f,_0x5329cc){return function(_0x4126d2){if(_0x4126d2){return _0x4126d2[_0xb2f7('0x35')]()['then'](function(){_0x28201f['status'](0xcc)['end']();});}};}function handleEntityNotFound(_0x45018a,_0x2b7964){return function(_0x171894){if(!_0x171894){_0x45018a['sendStatus'](0x194);}return _0x171894;};}function handleError(_0x236106,_0x2b0168){_0x2b0168=_0x2b0168||0x1f4;return function(_0x1fca95){logger[_0xb2f7('0x23')](_0x1fca95[_0xb2f7('0x36')]);if(_0x1fca95[_0xb2f7('0x37')]){delete _0x1fca95[_0xb2f7('0x37')];}_0x236106['status'](_0x2b0168)[_0xb2f7('0x38')](_0x1fca95);};}exports[_0xb2f7('0x39')]=function(_0xa93c79,_0xbf05d){var _0x4fd2e6={},_0x4d9adb={},_0x4fba0d={'count':0x0,'rows':[]};var _0x51e906=_[_0xb2f7('0x3a')](db[_0xb2f7('0x3b')]['rawAttributes'],function(_0x1aac29){return{'name':_0x1aac29[_0xb2f7('0x3c')],'type':_0x1aac29[_0xb2f7('0x3d')][_0xb2f7('0x3e')]};});_0x4d9adb[_0xb2f7('0x3f')]=_[_0xb2f7('0x3a')](_0x51e906,_0xb2f7('0x37'));_0x4d9adb[_0xb2f7('0x40')]=_['keys'](_0xa93c79[_0xb2f7('0x40')]);_0x4d9adb[_0xb2f7('0x41')]=_[_0xb2f7('0x42')](_0x4d9adb[_0xb2f7('0x3f')],_0x4d9adb[_0xb2f7('0x40')]);_0x4fd2e6['attributes']=_['intersection'](_0x4d9adb[_0xb2f7('0x3f')],qs[_0xb2f7('0x43')](_0xa93c79[_0xb2f7('0x40')][_0xb2f7('0x43')]));_0x4fd2e6[_0xb2f7('0x44')]=_0x4fd2e6[_0xb2f7('0x44')][_0xb2f7('0x45')]?_0x4fd2e6[_0xb2f7('0x44')]:_0x4d9adb[_0xb2f7('0x3f')];if(!_0xa93c79[_0xb2f7('0x40')]['hasOwnProperty'](_0xb2f7('0x46'))){_0x4fd2e6[_0xb2f7('0x47')]=qs['limit'](_0xa93c79['query'][_0xb2f7('0x47')]);_0x4fd2e6['offset']=qs[_0xb2f7('0x2e')](_0xa93c79[_0xb2f7('0x40')][_0xb2f7('0x2e')]);}_0x4fd2e6[_0xb2f7('0x48')]=qs[_0xb2f7('0x49')](_0xa93c79['query'][_0xb2f7('0x49')]);_0x4fd2e6[_0xb2f7('0x4a')]=qs[_0xb2f7('0x41')](_['pick'](_0xa93c79['query'],_0x4d9adb[_0xb2f7('0x41')]),_0x51e906);if(_0xa93c79[_0xb2f7('0x40')][_0xb2f7('0x4b')]){_0x4fd2e6[_0xb2f7('0x4a')]=_[_0xb2f7('0x4c')](_0x4fd2e6[_0xb2f7('0x4a')],{'$or':_[_0xb2f7('0x3a')](_0x51e906,function(_0x20fe03){if(_0x20fe03[_0xb2f7('0x3d')]!==_0xb2f7('0x4d')){var _0x199375={};_0x199375[_0x20fe03['name']]={'$like':'%'+_0xa93c79['query'][_0xb2f7('0x4b')]+'%'};return _0x199375;}})});}_0x4fd2e6=_['merge']({},_0x4fd2e6,_0xa93c79['options']);var _0x37fa62={'where':_0x4fd2e6[_0xb2f7('0x4a')]};return db['SugarcrmConfiguration'][_0xb2f7('0x2d')](_0x37fa62)[_0xb2f7('0x34')](function(_0x1dfa4e){_0x4fba0d[_0xb2f7('0x2d')]=_0x1dfa4e;if(_0xa93c79[_0xb2f7('0x40')]['includeAll']){_0x4fd2e6[_0xb2f7('0x4e')]=[{'all':!![]}];}return db[_0xb2f7('0x3b')]['findAll'](_0x4fd2e6);})[_0xb2f7('0x34')](function(_0x17db0b){_0x4fba0d[_0xb2f7('0x4f')]=_0x17db0b;return _0x4fba0d;})[_0xb2f7('0x34')](respondWithFilteredResult(_0xbf05d,_0x4fd2e6))[_0xb2f7('0x28')](handleError(_0xbf05d,null));};exports[_0xb2f7('0x50')]=function(_0x41bafc,_0x28cc7c){var _0x54a089={'raw':![],'where':{'id':_0x41bafc[_0xb2f7('0x51')]['id']}},_0x1398a7={};_0x1398a7[_0xb2f7('0x3f')]=_[_0xb2f7('0x52')](db[_0xb2f7('0x3b')]['rawAttributes']);_0x1398a7['query']=_['keys'](_0x41bafc[_0xb2f7('0x40')]);_0x1398a7[_0xb2f7('0x41')]=_[_0xb2f7('0x42')](_0x1398a7[_0xb2f7('0x3f')],_0x1398a7['query']);_0x54a089[_0xb2f7('0x44')]=_[_0xb2f7('0x42')](_0x1398a7[_0xb2f7('0x3f')],qs['fields'](_0x41bafc[_0xb2f7('0x40')]['fields']));_0x54a089[_0xb2f7('0x44')]=_0x54a089[_0xb2f7('0x44')][_0xb2f7('0x45')]?_0x54a089[_0xb2f7('0x44')]:_0x1398a7[_0xb2f7('0x3f')];if(_0x41bafc[_0xb2f7('0x40')][_0xb2f7('0x53')]){_0x54a089['include']=[{'all':!![]}];}_0x54a089=_[_0xb2f7('0x4c')]({},_0x54a089,_0x41bafc[_0xb2f7('0x54')]);return db[_0xb2f7('0x3b')][_0xb2f7('0x55')](_0x54a089)[_0xb2f7('0x34')](handleEntityNotFound(_0x28cc7c,null))[_0xb2f7('0x34')](respondWithResult(_0x28cc7c,null))['catch'](handleError(_0x28cc7c,null));};exports[_0xb2f7('0x56')]=function(_0x48ea41,_0xe8e96e){return db[_0xb2f7('0x3b')]['create'](_0x48ea41[_0xb2f7('0x57')],{})[_0xb2f7('0x34')](respondWithResult(_0xe8e96e,0xc9))[_0xb2f7('0x28')](handleError(_0xe8e96e,null));};exports[_0xb2f7('0x58')]=function(_0x336a90,_0x5274ed){if(_0x336a90[_0xb2f7('0x57')]['id']){delete _0x336a90['body']['id'];}return db[_0xb2f7('0x3b')][_0xb2f7('0x55')]({'where':{'id':_0x336a90[_0xb2f7('0x51')]['id']}})[_0xb2f7('0x34')](handleEntityNotFound(_0x5274ed,null))[_0xb2f7('0x34')](saveUpdates(_0x336a90[_0xb2f7('0x57')],null))[_0xb2f7('0x34')](respondWithResult(_0x5274ed,null))[_0xb2f7('0x28')](handleError(_0x5274ed,null));};exports['destroy']=function(_0x9679b4,_0x3d2991){return db[_0xb2f7('0x3b')]['find']({'where':{'id':_0x9679b4[_0xb2f7('0x51')]['id']}})[_0xb2f7('0x34')](handleEntityNotFound(_0x3d2991,null))[_0xb2f7('0x34')](removeEntity(_0x3d2991,null))[_0xb2f7('0x28')](handleError(_0x3d2991,null));};exports[_0xb2f7('0x59')]=function(_0x5a24e6,_0x51a29e,_0x277af2){var _0x5461a2={};var _0x315f63={};var _0x31f09b;var _0xadd34a;return db[_0xb2f7('0x3b')][_0xb2f7('0x5a')]({'where':{'id':_0x5a24e6['params']['id']}})[_0xb2f7('0x34')](handleEntityNotFound(_0x51a29e,null))[_0xb2f7('0x34')](function(_0x58bcbc){if(_0x58bcbc){_0x31f09b=_0x58bcbc;_0x315f63[_0xb2f7('0x3f')]=_['keys'](db[_0xb2f7('0x5b')]['rawAttributes']);_0x315f63[_0xb2f7('0x40')]=_['keys'](_0x5a24e6[_0xb2f7('0x40')]);_0x315f63[_0xb2f7('0x41')]=_['intersection'](_0x315f63[_0xb2f7('0x3f')],_0x315f63[_0xb2f7('0x40')]);_0x5461a2[_0xb2f7('0x44')]=_[_0xb2f7('0x42')](_0x315f63[_0xb2f7('0x3f')],qs[_0xb2f7('0x43')](_0x5a24e6[_0xb2f7('0x40')]['fields']));_0x5461a2['attributes']=_0x5461a2[_0xb2f7('0x44')][_0xb2f7('0x45')]?_0x5461a2[_0xb2f7('0x44')]:_0x315f63['model'];_0x5461a2[_0xb2f7('0x48')]=qs[_0xb2f7('0x49')](_0x5a24e6[_0xb2f7('0x40')][_0xb2f7('0x49')]);_0x5461a2[_0xb2f7('0x4a')]=qs[_0xb2f7('0x41')](_[_0xb2f7('0x5c')](_0x5a24e6[_0xb2f7('0x40')],_0x315f63[_0xb2f7('0x41')]));if(_0x5a24e6[_0xb2f7('0x40')]['filter']){_0x5461a2[_0xb2f7('0x4a')]=_[_0xb2f7('0x4c')](_0x5461a2[_0xb2f7('0x4a')],{'$or':_[_0xb2f7('0x3a')](_0x5461a2[_0xb2f7('0x44')],function(_0x10c792){var _0x111c77={};_0x111c77[_0x10c792]={'$like':'%'+_0x5a24e6[_0xb2f7('0x40')][_0xb2f7('0x4b')]+'%'};return _0x111c77;})});}_0x5461a2=_[_0xb2f7('0x4c')]({},_0x5461a2,_0x5a24e6[_0xb2f7('0x54')]);return _0x31f09b['getFields'](_0x5461a2);}})[_0xb2f7('0x34')](function(_0x35e1de){if(_0x35e1de){_0xadd34a=_0x35e1de[_0xb2f7('0x45')];if(!_0x5a24e6[_0xb2f7('0x40')]['hasOwnProperty'](_0xb2f7('0x46'))){_0x5461a2[_0xb2f7('0x47')]=qs[_0xb2f7('0x47')](_0x5a24e6[_0xb2f7('0x40')][_0xb2f7('0x47')]);_0x5461a2[_0xb2f7('0x2e')]=qs['offset'](_0x5a24e6['query'][_0xb2f7('0x2e')]);}return _0x31f09b[_0xb2f7('0x59')](_0x5461a2);}})['then'](function(_0x3a8513){if(_0x3a8513){return _0x3a8513?{'count':_0xadd34a,'rows':_0x3a8513}:null;}})[_0xb2f7('0x34')](respondWithResult(_0x51a29e,null))['catch'](handleError(_0x51a29e,null));};exports['getSubjects']=function(_0x4b8e92,_0xae33d0,_0x14ddf3){var _0x1d2cce={};var _0x367043={};var _0x592f2a;var _0x231e7c;return db[_0xb2f7('0x3b')][_0xb2f7('0x5a')]({'where':{'id':_0x4b8e92['params']['id']}})[_0xb2f7('0x34')](handleEntityNotFound(_0xae33d0,null))[_0xb2f7('0x34')](function(_0x38c783){if(_0x38c783){_0x592f2a=_0x38c783;_0x367043[_0xb2f7('0x3f')]=_[_0xb2f7('0x52')](db[_0xb2f7('0x5b')]['rawAttributes']);_0x367043[_0xb2f7('0x40')]=_[_0xb2f7('0x52')](_0x4b8e92[_0xb2f7('0x40')]);_0x367043['filters']=_[_0xb2f7('0x42')](_0x367043[_0xb2f7('0x3f')],_0x367043[_0xb2f7('0x40')]);_0x1d2cce[_0xb2f7('0x44')]=_[_0xb2f7('0x42')](_0x367043[_0xb2f7('0x3f')],qs[_0xb2f7('0x43')](_0x4b8e92[_0xb2f7('0x40')][_0xb2f7('0x43')]));_0x1d2cce[_0xb2f7('0x44')]=_0x1d2cce[_0xb2f7('0x44')]['length']?_0x1d2cce[_0xb2f7('0x44')]:_0x367043[_0xb2f7('0x3f')];_0x1d2cce[_0xb2f7('0x48')]=qs['sort'](_0x4b8e92[_0xb2f7('0x40')][_0xb2f7('0x49')]);_0x1d2cce[_0xb2f7('0x4a')]=qs[_0xb2f7('0x41')](_['pick'](_0x4b8e92[_0xb2f7('0x40')],_0x367043['filters']));if(_0x4b8e92[_0xb2f7('0x40')][_0xb2f7('0x4b')]){_0x1d2cce[_0xb2f7('0x4a')]=_['merge'](_0x1d2cce[_0xb2f7('0x4a')],{'$or':_[_0xb2f7('0x3a')](_0x1d2cce[_0xb2f7('0x44')],function(_0x13cf4c){var _0x438143={};_0x438143[_0x13cf4c]={'$like':'%'+_0x4b8e92['query'][_0xb2f7('0x4b')]+'%'};return _0x438143;})});}_0x1d2cce=_['merge']({},_0x1d2cce,_0x4b8e92[_0xb2f7('0x54')]);return _0x592f2a[_0xb2f7('0x5d')](_0x1d2cce);}})[_0xb2f7('0x34')](function(_0x54ea48){if(_0x54ea48){_0x231e7c=_0x54ea48[_0xb2f7('0x45')];if(!_0x4b8e92['query'][_0xb2f7('0x5e')](_0xb2f7('0x46'))){_0x1d2cce['limit']=qs[_0xb2f7('0x47')](_0x4b8e92[_0xb2f7('0x40')][_0xb2f7('0x47')]);_0x1d2cce[_0xb2f7('0x2e')]=qs['offset'](_0x4b8e92['query'][_0xb2f7('0x2e')]);}return _0x592f2a['getSubjects'](_0x1d2cce);}})[_0xb2f7('0x34')](function(_0x272eae){if(_0x272eae){return _0x272eae?{'count':_0x231e7c,'rows':_0x272eae}:null;}})[_0xb2f7('0x34')](respondWithResult(_0xae33d0,null))[_0xb2f7('0x28')](handleError(_0xae33d0,null));};exports['getDescriptions']=function(_0x17a1b9,_0x4d567a,_0x33ae8f){var _0x545b7e={};var _0x1a3853={};var _0x3d247d;var _0x4cc617;return db[_0xb2f7('0x3b')][_0xb2f7('0x5a')]({'where':{'id':_0x17a1b9[_0xb2f7('0x51')]['id']}})[_0xb2f7('0x34')](handleEntityNotFound(_0x4d567a,null))[_0xb2f7('0x34')](function(_0x10c1b0){if(_0x10c1b0){_0x3d247d=_0x10c1b0;_0x1a3853[_0xb2f7('0x3f')]=_[_0xb2f7('0x52')](db[_0xb2f7('0x5b')][_0xb2f7('0x5f')]);_0x1a3853[_0xb2f7('0x40')]=_[_0xb2f7('0x52')](_0x17a1b9['query']);_0x1a3853['filters']=_[_0xb2f7('0x42')](_0x1a3853[_0xb2f7('0x3f')],_0x1a3853[_0xb2f7('0x40')]);_0x545b7e[_0xb2f7('0x44')]=_[_0xb2f7('0x42')](_0x1a3853[_0xb2f7('0x3f')],qs[_0xb2f7('0x43')](_0x17a1b9[_0xb2f7('0x40')][_0xb2f7('0x43')]));_0x545b7e[_0xb2f7('0x44')]=_0x545b7e['attributes'][_0xb2f7('0x45')]?_0x545b7e[_0xb2f7('0x44')]:_0x1a3853[_0xb2f7('0x3f')];_0x545b7e[_0xb2f7('0x48')]=qs['sort'](_0x17a1b9[_0xb2f7('0x40')][_0xb2f7('0x49')]);_0x545b7e[_0xb2f7('0x4a')]=qs[_0xb2f7('0x41')](_[_0xb2f7('0x5c')](_0x17a1b9['query'],_0x1a3853[_0xb2f7('0x41')]));if(_0x17a1b9[_0xb2f7('0x40')]['filter']){_0x545b7e[_0xb2f7('0x4a')]=_['merge'](_0x545b7e[_0xb2f7('0x4a')],{'$or':_['map'](_0x545b7e[_0xb2f7('0x44')],function(_0x2c8304){var _0x31082c={};_0x31082c[_0x2c8304]={'$like':'%'+_0x17a1b9['query']['filter']+'%'};return _0x31082c;})});}_0x545b7e=_[_0xb2f7('0x4c')]({},_0x545b7e,_0x17a1b9[_0xb2f7('0x54')]);return _0x3d247d[_0xb2f7('0x60')](_0x545b7e);}})['then'](function(_0x560ed9){if(_0x560ed9){_0x4cc617=_0x560ed9[_0xb2f7('0x45')];if(!_0x17a1b9[_0xb2f7('0x40')][_0xb2f7('0x5e')](_0xb2f7('0x46'))){_0x545b7e[_0xb2f7('0x47')]=qs[_0xb2f7('0x47')](_0x17a1b9['query'][_0xb2f7('0x47')]);_0x545b7e[_0xb2f7('0x2e')]=qs[_0xb2f7('0x2e')](_0x17a1b9['query'][_0xb2f7('0x2e')]);}return _0x3d247d[_0xb2f7('0x60')](_0x545b7e);}})[_0xb2f7('0x34')](function(_0x3a6d98){if(_0x3a6d98){return _0x3a6d98?{'count':_0x4cc617,'rows':_0x3a6d98}:null;}})[_0xb2f7('0x34')](respondWithResult(_0x4d567a,null))[_0xb2f7('0x28')](handleError(_0x4d567a,null));};
\ No newline at end of file
+var _0x67d4=['filters','intersection','attributes','length','hasOwnProperty','order','sort','where','pick','filter','merge','VIRTUAL','options','includeAll','include','findAll','rows','show','params','fields','find','body','getFields','findOne','SugarcrmField','nolimit','getSubjects','getDescriptions','html-pdf','eml-format','request-promise','mustache','sox','to-csv','lodash','squel','crypto','jsforce','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/utils','../../config/environment','jayson/promise','client','http','request','then','info','SugarcrmConfiguration,\x20%s,\x20%s','request\x20sent','debug','SugarcrmConfiguration,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','catch','sendStatus','status','end','json','count','offset','limit','set','Content-Range','reject','save','update','destroy','stack','name','send','index','map','SugarcrmConfiguration','rawAttributes','type','key','model','keys','query'];(function(_0x4c61a6,_0x398856){var _0x37c4b4=function(_0x29bd5b){while(--_0x29bd5b){_0x4c61a6['push'](_0x4c61a6['shift']());}};_0x37c4b4(++_0x398856);}(_0x67d4,0x11e));var _0x467d=function(_0x9c973a,_0x3be2e1){_0x9c973a=_0x9c973a-0x0;var _0x11e031=_0x67d4[_0x9c973a];return _0x11e031;};'use strict';var pdf=require(_0x467d('0x0'));var emlformat=require(_0x467d('0x1'));var rimraf=require('rimraf');var zipdir=require('zip-dir');var jsonpatch=require('fast-json-patch');var rp=require(_0x467d('0x2'));var moment=require('moment');var BPromise=require('bluebird');var Mustache=require(_0x467d('0x3'));var util=require('util');var path=require('path');var sox=require(_0x467d('0x4'));var csv=require(_0x467d('0x5'));var ejs=require('ejs');var fs=require('fs');var _=require(_0x467d('0x6'));var squel=require(_0x467d('0x7'));var crypto=require(_0x467d('0x8'));var jsforce=require(_0x467d('0x9'));var deskjs=require('desk.js');var toCsv=require(_0x467d('0x5'));var querystring=require('querystring');var Papa=require('papaparse');var Redis=require(_0x467d('0xa'));var authService=require(_0x467d('0xb'));var qs=require(_0x467d('0xc'));var as=require(_0x467d('0xd'));var hardwareService=require(_0x467d('0xe'));var logger=require('../../config/logger')('api');var utils=require(_0x467d('0xf'));var config=require(_0x467d('0x10'));var licenseUtil=require('../../config/license/util');var db=require('../../mysqldb')['db'];var jayson=require(_0x467d('0x11'));var client=jayson[_0x467d('0x12')][_0x467d('0x13')]({'port':0x232a});function respondWithRpcPromise(_0x2db993,_0x308429,_0x4f96ba,_0x295ed2){return new BPromise(function(_0x2ef9fb,_0x12a885){var _0x48ce0e=_0x295ed2||client;return _0x48ce0e[_0x467d('0x14')](_0x2db993,_0x4f96ba)[_0x467d('0x15')](function(_0x557ddb){logger[_0x467d('0x16')](_0x467d('0x17'),_0x308429,_0x467d('0x18'));logger[_0x467d('0x19')](_0x467d('0x1a'),_0x308429,_0x467d('0x18'),JSON[_0x467d('0x1b')](_0x557ddb));if(_0x557ddb[_0x467d('0x1c')]){if(_0x557ddb['error'][_0x467d('0x1d')]===0x1f4){logger[_0x467d('0x1c')](_0x467d('0x17'),_0x308429,_0x557ddb[_0x467d('0x1c')][_0x467d('0x1e')]);return _0x12a885(_0x557ddb[_0x467d('0x1c')]['message']);}logger[_0x467d('0x1c')](_0x467d('0x17'),_0x308429,_0x557ddb['error'][_0x467d('0x1e')]);return _0x2ef9fb(_0x557ddb[_0x467d('0x1c')][_0x467d('0x1e')]);}else{logger['info'](_0x467d('0x17'),_0x308429,'request\x20sent');_0x2ef9fb(_0x557ddb[_0x467d('0x1f')][_0x467d('0x1e')]);}})[_0x467d('0x20')](function(_0x4df5c9){logger[_0x467d('0x1c')]('SugarcrmConfiguration,\x20%s,\x20%s',_0x308429,_0x4df5c9);_0x12a885(_0x4df5c9);});});}function respondWithStatusCode(_0xd7e970,_0x123fe9){_0x123fe9=_0x123fe9||0xcc;return function(_0x3c83ba){if(_0x3c83ba){return _0xd7e970[_0x467d('0x21')](_0x123fe9);}return _0xd7e970[_0x467d('0x22')](_0x123fe9)[_0x467d('0x23')]();};}function respondWithResult(_0x455820,_0x34ad2e){_0x34ad2e=_0x34ad2e||0xc8;return function(_0x421039){if(_0x421039){return _0x455820[_0x467d('0x22')](_0x34ad2e)[_0x467d('0x24')](_0x421039);}};}function respondWithFilteredResult(_0x938257,_0x9ca88){return function(_0xf815b0){if(_0xf815b0){var _0xa34272=_0xf815b0[_0x467d('0x25')],_0x2a8d04=_0x9ca88['offset'],_0x24f86f=_0x9ca88[_0x467d('0x26')]+_0x9ca88[_0x467d('0x27')],_0x534e0f;if(_0x24f86f>=_0xa34272){_0x24f86f=_0xa34272;_0x534e0f=0xc8;}else{_0x534e0f=0xce;}_0x938257[_0x467d('0x22')](_0x534e0f);return _0x938257[_0x467d('0x28')](_0x467d('0x29'),_0x2a8d04+'-'+_0x24f86f+'/'+_0xa34272)[_0x467d('0x24')](_0xf815b0);}return null;};}function patchUpdates(_0x2cb8bb){return function(_0x36bd91){try{jsonpatch['apply'](_0x36bd91,_0x2cb8bb,!![]);}catch(_0x579965){return BPromise[_0x467d('0x2a')](_0x579965);}return _0x36bd91[_0x467d('0x2b')]();};}function saveUpdates(_0x59f483,_0x223066){return function(_0x243dc6){if(_0x243dc6){return _0x243dc6[_0x467d('0x2c')](_0x59f483)[_0x467d('0x15')](function(_0x1344ce){return _0x1344ce;});}return null;};}function removeEntity(_0x2cd251,_0xdef816){return function(_0x193475){if(_0x193475){return _0x193475[_0x467d('0x2d')]()[_0x467d('0x15')](function(){_0x2cd251[_0x467d('0x22')](0xcc)[_0x467d('0x23')]();});}};}function handleEntityNotFound(_0x50430c,_0x1be9f4){return function(_0x542bf3){if(!_0x542bf3){_0x50430c['sendStatus'](0x194);}return _0x542bf3;};}function handleError(_0x544f3c,_0x1c3921){_0x1c3921=_0x1c3921||0x1f4;return function(_0x5c9b93){logger['error'](_0x5c9b93[_0x467d('0x2e')]);if(_0x5c9b93[_0x467d('0x2f')]){delete _0x5c9b93[_0x467d('0x2f')];}_0x544f3c[_0x467d('0x22')](_0x1c3921)[_0x467d('0x30')](_0x5c9b93);};}exports[_0x467d('0x31')]=function(_0x3bc5c2,_0xba2785){var _0x25f2e3={},_0x5b8b84={},_0x5f3a70={'count':0x0,'rows':[]};var _0x36f929=_[_0x467d('0x32')](db[_0x467d('0x33')][_0x467d('0x34')],function(_0xdd6b3a){return{'name':_0xdd6b3a['fieldName'],'type':_0xdd6b3a[_0x467d('0x35')][_0x467d('0x36')]};});_0x5b8b84[_0x467d('0x37')]=_['map'](_0x36f929,'name');_0x5b8b84['query']=_[_0x467d('0x38')](_0x3bc5c2[_0x467d('0x39')]);_0x5b8b84[_0x467d('0x3a')]=_[_0x467d('0x3b')](_0x5b8b84['model'],_0x5b8b84['query']);_0x25f2e3[_0x467d('0x3c')]=_['intersection'](_0x5b8b84[_0x467d('0x37')],qs['fields'](_0x3bc5c2['query']['fields']));_0x25f2e3['attributes']=_0x25f2e3['attributes'][_0x467d('0x3d')]?_0x25f2e3['attributes']:_0x5b8b84[_0x467d('0x37')];if(!_0x3bc5c2[_0x467d('0x39')][_0x467d('0x3e')]('nolimit')){_0x25f2e3['limit']=qs[_0x467d('0x27')](_0x3bc5c2[_0x467d('0x39')]['limit']);_0x25f2e3[_0x467d('0x26')]=qs[_0x467d('0x26')](_0x3bc5c2[_0x467d('0x39')][_0x467d('0x26')]);}_0x25f2e3[_0x467d('0x3f')]=qs[_0x467d('0x40')](_0x3bc5c2[_0x467d('0x39')][_0x467d('0x40')]);_0x25f2e3[_0x467d('0x41')]=qs[_0x467d('0x3a')](_[_0x467d('0x42')](_0x3bc5c2[_0x467d('0x39')],_0x5b8b84[_0x467d('0x3a')]),_0x36f929);if(_0x3bc5c2['query'][_0x467d('0x43')]){_0x25f2e3[_0x467d('0x41')]=_[_0x467d('0x44')](_0x25f2e3['where'],{'$or':_[_0x467d('0x32')](_0x36f929,function(_0x21c390){if(_0x21c390[_0x467d('0x35')]!==_0x467d('0x45')){var _0x356c7e={};_0x356c7e[_0x21c390['name']]={'$like':'%'+_0x3bc5c2[_0x467d('0x39')]['filter']+'%'};return _0x356c7e;}})});}_0x25f2e3=_['merge']({},_0x25f2e3,_0x3bc5c2[_0x467d('0x46')]);var _0xb5a080={'where':_0x25f2e3['where']};return db[_0x467d('0x33')]['count'](_0xb5a080)[_0x467d('0x15')](function(_0x464b33){_0x5f3a70[_0x467d('0x25')]=_0x464b33;if(_0x3bc5c2[_0x467d('0x39')][_0x467d('0x47')]){_0x25f2e3[_0x467d('0x48')]=[{'all':!![]}];}return db[_0x467d('0x33')][_0x467d('0x49')](_0x25f2e3);})[_0x467d('0x15')](function(_0x2334f7){_0x5f3a70[_0x467d('0x4a')]=_0x2334f7;return _0x5f3a70;})[_0x467d('0x15')](respondWithFilteredResult(_0xba2785,_0x25f2e3))['catch'](handleError(_0xba2785,null));};exports[_0x467d('0x4b')]=function(_0x36d807,_0x597a5d){var _0x528a9d={'raw':![],'where':{'id':_0x36d807[_0x467d('0x4c')]['id']}},_0x5ed732={};_0x5ed732['model']=_[_0x467d('0x38')](db[_0x467d('0x33')][_0x467d('0x34')]);_0x5ed732['query']=_[_0x467d('0x38')](_0x36d807[_0x467d('0x39')]);_0x5ed732['filters']=_[_0x467d('0x3b')](_0x5ed732['model'],_0x5ed732[_0x467d('0x39')]);_0x528a9d['attributes']=_[_0x467d('0x3b')](_0x5ed732[_0x467d('0x37')],qs[_0x467d('0x4d')](_0x36d807[_0x467d('0x39')][_0x467d('0x4d')]));_0x528a9d[_0x467d('0x3c')]=_0x528a9d['attributes'][_0x467d('0x3d')]?_0x528a9d[_0x467d('0x3c')]:_0x5ed732[_0x467d('0x37')];if(_0x36d807[_0x467d('0x39')][_0x467d('0x47')]){_0x528a9d[_0x467d('0x48')]=[{'all':!![]}];}_0x528a9d=_['merge']({},_0x528a9d,_0x36d807[_0x467d('0x46')]);return db['SugarcrmConfiguration'][_0x467d('0x4e')](_0x528a9d)['then'](handleEntityNotFound(_0x597a5d,null))[_0x467d('0x15')](respondWithResult(_0x597a5d,null))['catch'](handleError(_0x597a5d,null));};exports['create']=function(_0x2d1216,_0x1a8c99){return db[_0x467d('0x33')]['create'](_0x2d1216[_0x467d('0x4f')],{})[_0x467d('0x15')](respondWithResult(_0x1a8c99,0xc9))[_0x467d('0x20')](handleError(_0x1a8c99,null));};exports['update']=function(_0x5c0983,_0x108ffe){if(_0x5c0983[_0x467d('0x4f')]['id']){delete _0x5c0983['body']['id'];}return db['SugarcrmConfiguration'][_0x467d('0x4e')]({'where':{'id':_0x5c0983[_0x467d('0x4c')]['id']}})[_0x467d('0x15')](handleEntityNotFound(_0x108ffe,null))[_0x467d('0x15')](saveUpdates(_0x5c0983['body'],null))[_0x467d('0x15')](respondWithResult(_0x108ffe,null))[_0x467d('0x20')](handleError(_0x108ffe,null));};exports[_0x467d('0x2d')]=function(_0x381572,_0x1c7cfa){return db['SugarcrmConfiguration'][_0x467d('0x4e')]({'where':{'id':_0x381572[_0x467d('0x4c')]['id']}})[_0x467d('0x15')](handleEntityNotFound(_0x1c7cfa,null))[_0x467d('0x15')](removeEntity(_0x1c7cfa,null))['catch'](handleError(_0x1c7cfa,null));};exports[_0x467d('0x50')]=function(_0x272a63,_0x293725,_0x2ccb3c){var _0x459e69={};var _0x5a2282={};var _0x30a3bd;var _0x52e541;return db['SugarcrmConfiguration'][_0x467d('0x51')]({'where':{'id':_0x272a63[_0x467d('0x4c')]['id']}})[_0x467d('0x15')](handleEntityNotFound(_0x293725,null))['then'](function(_0x208f20){if(_0x208f20){_0x30a3bd=_0x208f20;_0x5a2282[_0x467d('0x37')]=_[_0x467d('0x38')](db[_0x467d('0x52')][_0x467d('0x34')]);_0x5a2282[_0x467d('0x39')]=_['keys'](_0x272a63[_0x467d('0x39')]);_0x5a2282[_0x467d('0x3a')]=_['intersection'](_0x5a2282[_0x467d('0x37')],_0x5a2282[_0x467d('0x39')]);_0x459e69['attributes']=_[_0x467d('0x3b')](_0x5a2282[_0x467d('0x37')],qs[_0x467d('0x4d')](_0x272a63[_0x467d('0x39')][_0x467d('0x4d')]));_0x459e69['attributes']=_0x459e69[_0x467d('0x3c')][_0x467d('0x3d')]?_0x459e69['attributes']:_0x5a2282[_0x467d('0x37')];_0x459e69['order']=qs[_0x467d('0x40')](_0x272a63[_0x467d('0x39')][_0x467d('0x40')]);_0x459e69['where']=qs[_0x467d('0x3a')](_[_0x467d('0x42')](_0x272a63[_0x467d('0x39')],_0x5a2282[_0x467d('0x3a')]));if(_0x272a63[_0x467d('0x39')][_0x467d('0x43')]){_0x459e69[_0x467d('0x41')]=_['merge'](_0x459e69[_0x467d('0x41')],{'$or':_[_0x467d('0x32')](_0x459e69[_0x467d('0x3c')],function(_0x5d56a4){var _0xe1df76={};_0xe1df76[_0x5d56a4]={'$like':'%'+_0x272a63[_0x467d('0x39')][_0x467d('0x43')]+'%'};return _0xe1df76;})});}_0x459e69=_[_0x467d('0x44')]({},_0x459e69,_0x272a63[_0x467d('0x46')]);return _0x30a3bd[_0x467d('0x50')](_0x459e69);}})[_0x467d('0x15')](function(_0x103360){if(_0x103360){_0x52e541=_0x103360[_0x467d('0x3d')];if(!_0x272a63[_0x467d('0x39')][_0x467d('0x3e')](_0x467d('0x53'))){_0x459e69[_0x467d('0x27')]=qs[_0x467d('0x27')](_0x272a63[_0x467d('0x39')][_0x467d('0x27')]);_0x459e69[_0x467d('0x26')]=qs[_0x467d('0x26')](_0x272a63[_0x467d('0x39')][_0x467d('0x26')]);}return _0x30a3bd[_0x467d('0x50')](_0x459e69);}})[_0x467d('0x15')](function(_0x4b6cf8){if(_0x4b6cf8){return _0x4b6cf8?{'count':_0x52e541,'rows':_0x4b6cf8}:null;}})[_0x467d('0x15')](respondWithResult(_0x293725,null))['catch'](handleError(_0x293725,null));};exports[_0x467d('0x54')]=function(_0x56db2b,_0x1a3fcd,_0x57487b){var _0x36f608={};var _0x5151a4={};var _0x3719f4;var _0x28f93a;return db['SugarcrmConfiguration']['findOne']({'where':{'id':_0x56db2b['params']['id']}})[_0x467d('0x15')](handleEntityNotFound(_0x1a3fcd,null))[_0x467d('0x15')](function(_0x5ca2f8){if(_0x5ca2f8){_0x3719f4=_0x5ca2f8;_0x5151a4['model']=_[_0x467d('0x38')](db['SugarcrmField'][_0x467d('0x34')]);_0x5151a4[_0x467d('0x39')]=_[_0x467d('0x38')](_0x56db2b[_0x467d('0x39')]);_0x5151a4['filters']=_[_0x467d('0x3b')](_0x5151a4[_0x467d('0x37')],_0x5151a4[_0x467d('0x39')]);_0x36f608[_0x467d('0x3c')]=_[_0x467d('0x3b')](_0x5151a4[_0x467d('0x37')],qs['fields'](_0x56db2b[_0x467d('0x39')][_0x467d('0x4d')]));_0x36f608[_0x467d('0x3c')]=_0x36f608[_0x467d('0x3c')][_0x467d('0x3d')]?_0x36f608['attributes']:_0x5151a4[_0x467d('0x37')];_0x36f608[_0x467d('0x3f')]=qs[_0x467d('0x40')](_0x56db2b['query'][_0x467d('0x40')]);_0x36f608[_0x467d('0x41')]=qs['filters'](_[_0x467d('0x42')](_0x56db2b[_0x467d('0x39')],_0x5151a4[_0x467d('0x3a')]));if(_0x56db2b[_0x467d('0x39')][_0x467d('0x43')]){_0x36f608[_0x467d('0x41')]=_[_0x467d('0x44')](_0x36f608[_0x467d('0x41')],{'$or':_[_0x467d('0x32')](_0x36f608[_0x467d('0x3c')],function(_0x462172){var _0x1f3778={};_0x1f3778[_0x462172]={'$like':'%'+_0x56db2b['query']['filter']+'%'};return _0x1f3778;})});}_0x36f608=_['merge']({},_0x36f608,_0x56db2b['options']);return _0x3719f4[_0x467d('0x54')](_0x36f608);}})[_0x467d('0x15')](function(_0x84e95a){if(_0x84e95a){_0x28f93a=_0x84e95a[_0x467d('0x3d')];if(!_0x56db2b['query']['hasOwnProperty'](_0x467d('0x53'))){_0x36f608[_0x467d('0x27')]=qs[_0x467d('0x27')](_0x56db2b[_0x467d('0x39')][_0x467d('0x27')]);_0x36f608[_0x467d('0x26')]=qs['offset'](_0x56db2b[_0x467d('0x39')][_0x467d('0x26')]);}return _0x3719f4[_0x467d('0x54')](_0x36f608);}})[_0x467d('0x15')](function(_0x130222){if(_0x130222){return _0x130222?{'count':_0x28f93a,'rows':_0x130222}:null;}})[_0x467d('0x15')](respondWithResult(_0x1a3fcd,null))[_0x467d('0x20')](handleError(_0x1a3fcd,null));};exports['getDescriptions']=function(_0x58e5d7,_0x26e524,_0xa59e7b){var _0x28cf0c={};var _0x18d9ca={};var _0x4d1ea5;var _0x5bc683;return db[_0x467d('0x33')]['findOne']({'where':{'id':_0x58e5d7['params']['id']}})[_0x467d('0x15')](handleEntityNotFound(_0x26e524,null))['then'](function(_0xd59c0f){if(_0xd59c0f){_0x4d1ea5=_0xd59c0f;_0x18d9ca['model']=_[_0x467d('0x38')](db[_0x467d('0x52')]['rawAttributes']);_0x18d9ca[_0x467d('0x39')]=_[_0x467d('0x38')](_0x58e5d7[_0x467d('0x39')]);_0x18d9ca['filters']=_[_0x467d('0x3b')](_0x18d9ca[_0x467d('0x37')],_0x18d9ca[_0x467d('0x39')]);_0x28cf0c[_0x467d('0x3c')]=_[_0x467d('0x3b')](_0x18d9ca[_0x467d('0x37')],qs[_0x467d('0x4d')](_0x58e5d7[_0x467d('0x39')][_0x467d('0x4d')]));_0x28cf0c[_0x467d('0x3c')]=_0x28cf0c['attributes'][_0x467d('0x3d')]?_0x28cf0c[_0x467d('0x3c')]:_0x18d9ca[_0x467d('0x37')];_0x28cf0c[_0x467d('0x3f')]=qs[_0x467d('0x40')](_0x58e5d7[_0x467d('0x39')]['sort']);_0x28cf0c['where']=qs[_0x467d('0x3a')](_[_0x467d('0x42')](_0x58e5d7[_0x467d('0x39')],_0x18d9ca[_0x467d('0x3a')]));if(_0x58e5d7[_0x467d('0x39')]['filter']){_0x28cf0c[_0x467d('0x41')]=_[_0x467d('0x44')](_0x28cf0c[_0x467d('0x41')],{'$or':_[_0x467d('0x32')](_0x28cf0c['attributes'],function(_0x5bfa1b){var _0x56184b={};_0x56184b[_0x5bfa1b]={'$like':'%'+_0x58e5d7[_0x467d('0x39')]['filter']+'%'};return _0x56184b;})});}_0x28cf0c=_[_0x467d('0x44')]({},_0x28cf0c,_0x58e5d7[_0x467d('0x46')]);return _0x4d1ea5[_0x467d('0x55')](_0x28cf0c);}})['then'](function(_0x5aea34){if(_0x5aea34){_0x5bc683=_0x5aea34[_0x467d('0x3d')];if(!_0x58e5d7[_0x467d('0x39')][_0x467d('0x3e')](_0x467d('0x53'))){_0x28cf0c[_0x467d('0x27')]=qs[_0x467d('0x27')](_0x58e5d7[_0x467d('0x39')]['limit']);_0x28cf0c[_0x467d('0x26')]=qs[_0x467d('0x26')](_0x58e5d7[_0x467d('0x39')]['offset']);}return _0x4d1ea5['getDescriptions'](_0x28cf0c);}})[_0x467d('0x15')](function(_0x2c84c1){if(_0x2c84c1){return _0x2c84c1?{'count':_0x5bc683,'rows':_0x2c84c1}:null;}})['then'](respondWithResult(_0x26e524,null))['catch'](handleError(_0x26e524,null));};
\ No newline at end of file