Built motion from commit (unavailable).|2.5.26
[motion2.git] / server / api / intSugarcrmConfiguration / intSugarcrmConfiguration.controller.js
index aaa01b5..1126a74 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xc64c=['index','map','SugarcrmConfiguration','rawAttributes','type','model','keys','query','filters','attributes','intersection','fields','order','sort','where','pick','filter','merge','VIRTUAL','options','include','findAll','rows','show','params','length','create','body','find','destroy','getFields','findOne','nolimit','getSubjects','SugarcrmField','hasOwnProperty','getDescriptions','eml-format','request-promise','bluebird','mustache','path','sox','to-csv','ejs','lodash','squel','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/advancedSearch','../../config/license/hardware','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','jayson/promise','request','info','SugarcrmConfiguration,\x20%s,\x20%s','debug','SugarcrmConfiguration,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error','message','result','catch','sendStatus','status','end','json','offset','limit','set','Content-Range','apply','reject','update','then','name','send'];(function(_0x52f1f9,_0x171046){var _0x178fc2=function(_0x170f57){while(--_0x170f57){_0x52f1f9['push'](_0x52f1f9['shift']());}};_0x178fc2(++_0x171046);}(_0xc64c,0x181));var _0xcc64=function(_0x74892f,_0x1e981b){_0x74892f=_0x74892f-0x0;var _0x10ee61=_0xc64c[_0x74892f];return _0x10ee61;};'use strict';var pdf=require('html-pdf');var emlformat=require(_0xcc64('0x0'));var rimraf=require('rimraf');var zipdir=require('zip-dir');var jsonpatch=require('fast-json-patch');var rp=require(_0xcc64('0x1'));var moment=require('moment');var BPromise=require(_0xcc64('0x2'));var Mustache=require(_0xcc64('0x3'));var util=require('util');var path=require(_0xcc64('0x4'));var sox=require(_0xcc64('0x5'));var csv=require(_0xcc64('0x6'));var ejs=require(_0xcc64('0x7'));var fs=require('fs');var _=require(_0xcc64('0x8'));var squel=require(_0xcc64('0x9'));var crypto=require(_0xcc64('0xa'));var jsforce=require(_0xcc64('0xb'));var deskjs=require(_0xcc64('0xc'));var toCsv=require(_0xcc64('0x6'));var querystring=require(_0xcc64('0xd'));var Papa=require(_0xcc64('0xe'));var Redis=require(_0xcc64('0xf'));var authService=require(_0xcc64('0x10'));var qs=require('../../components/parsers/qs');var as=require(_0xcc64('0x11'));var hardwareService=require(_0xcc64('0x12'));var logger=require('../../config/logger')(_0xcc64('0x13'));var utils=require(_0xcc64('0x14'));var config=require(_0xcc64('0x15'));var licenseUtil=require(_0xcc64('0x16'));var db=require(_0xcc64('0x17'))['db'];var jayson=require(_0xcc64('0x18'));var client=jayson['client']['http']({'port':0x232a});function respondWithRpcPromise(_0x24766f,_0x3590d1,_0xb49adc,_0x2b35a1){return new BPromise(function(_0x19a700,_0xfaa782){var _0x3eaeda=_0x2b35a1||client;return _0x3eaeda[_0xcc64('0x19')](_0x24766f,_0xb49adc)['then'](function(_0x4d9e40){logger[_0xcc64('0x1a')](_0xcc64('0x1b'),_0x3590d1,'request\x20sent');logger[_0xcc64('0x1c')](_0xcc64('0x1d'),_0x3590d1,_0xcc64('0x1e'),JSON[_0xcc64('0x1f')](_0x4d9e40));if(_0x4d9e40[_0xcc64('0x20')]){if(_0x4d9e40[_0xcc64('0x20')]['code']===0x1f4){logger[_0xcc64('0x20')](_0xcc64('0x1b'),_0x3590d1,_0x4d9e40[_0xcc64('0x20')]['message']);return _0xfaa782(_0x4d9e40['error'][_0xcc64('0x21')]);}logger['error'](_0xcc64('0x1b'),_0x3590d1,_0x4d9e40[_0xcc64('0x20')][_0xcc64('0x21')]);return _0x19a700(_0x4d9e40[_0xcc64('0x20')]['message']);}else{logger[_0xcc64('0x1a')](_0xcc64('0x1b'),_0x3590d1,_0xcc64('0x1e'));_0x19a700(_0x4d9e40[_0xcc64('0x22')][_0xcc64('0x21')]);}})[_0xcc64('0x23')](function(_0x501f2f){logger[_0xcc64('0x20')](_0xcc64('0x1b'),_0x3590d1,_0x501f2f);_0xfaa782(_0x501f2f);});});}function respondWithStatusCode(_0x432587,_0x4c8f5c){_0x4c8f5c=_0x4c8f5c||0xcc;return function(_0x37232f){if(_0x37232f){return _0x432587[_0xcc64('0x24')](_0x4c8f5c);}return _0x432587[_0xcc64('0x25')](_0x4c8f5c)[_0xcc64('0x26')]();};}function respondWithResult(_0x28c13d,_0x58c7c8){_0x58c7c8=_0x58c7c8||0xc8;return function(_0x3a3ed1){if(_0x3a3ed1){return _0x28c13d['status'](_0x58c7c8)[_0xcc64('0x27')](_0x3a3ed1);}};}function respondWithFilteredResult(_0x408989,_0x56c8d3){return function(_0x5aa1c7){if(_0x5aa1c7){var _0x1203a9=_0x5aa1c7['count'],_0x22089c=_0x56c8d3[_0xcc64('0x28')],_0x843dc9=_0x56c8d3[_0xcc64('0x28')]+_0x56c8d3[_0xcc64('0x29')],_0x4effa2;if(_0x843dc9>=_0x1203a9){_0x843dc9=_0x1203a9;_0x4effa2=0xc8;}else{_0x4effa2=0xce;}_0x408989[_0xcc64('0x25')](_0x4effa2);return _0x408989[_0xcc64('0x2a')](_0xcc64('0x2b'),_0x22089c+'-'+_0x843dc9+'/'+_0x1203a9)[_0xcc64('0x27')](_0x5aa1c7);}return null;};}function patchUpdates(_0x57cf8f){return function(_0x13668e){try{jsonpatch[_0xcc64('0x2c')](_0x13668e,_0x57cf8f,!![]);}catch(_0x1d70da){return BPromise[_0xcc64('0x2d')](_0x1d70da);}return _0x13668e['save']();};}function saveUpdates(_0x422fc8,_0x4fc9c2){return function(_0x33642e){if(_0x33642e){return _0x33642e[_0xcc64('0x2e')](_0x422fc8)[_0xcc64('0x2f')](function(_0x4f0f04){return _0x4f0f04;});}return null;};}function removeEntity(_0x45aa9a,_0xac7a66){return function(_0xc09344){if(_0xc09344){return _0xc09344['destroy']()[_0xcc64('0x2f')](function(){_0x45aa9a['status'](0xcc)[_0xcc64('0x26')]();});}};}function handleEntityNotFound(_0x657ce8,_0x231fe2){return function(_0xb9d582){if(!_0xb9d582){_0x657ce8['sendStatus'](0x194);}return _0xb9d582;};}function handleError(_0x34b545,_0x5e76ce){_0x5e76ce=_0x5e76ce||0x1f4;return function(_0x2df9bc){logger[_0xcc64('0x20')](_0x2df9bc['stack']);if(_0x2df9bc[_0xcc64('0x30')]){delete _0x2df9bc['name'];}_0x34b545[_0xcc64('0x25')](_0x5e76ce)[_0xcc64('0x31')](_0x2df9bc);};}exports[_0xcc64('0x32')]=function(_0x59163f,_0xf8de38){var _0x54ddc6={},_0xe49d28={},_0x1660eb={'count':0x0,'rows':[]};var _0x1c59a9=_[_0xcc64('0x33')](db[_0xcc64('0x34')][_0xcc64('0x35')],function(_0x32c9e1){return{'name':_0x32c9e1['fieldName'],'type':_0x32c9e1[_0xcc64('0x36')]['key']};});_0xe49d28[_0xcc64('0x37')]=_[_0xcc64('0x33')](_0x1c59a9,_0xcc64('0x30'));_0xe49d28['query']=_[_0xcc64('0x38')](_0x59163f[_0xcc64('0x39')]);_0xe49d28[_0xcc64('0x3a')]=_['intersection'](_0xe49d28[_0xcc64('0x37')],_0xe49d28[_0xcc64('0x39')]);_0x54ddc6[_0xcc64('0x3b')]=_[_0xcc64('0x3c')](_0xe49d28['model'],qs[_0xcc64('0x3d')](_0x59163f[_0xcc64('0x39')][_0xcc64('0x3d')]));_0x54ddc6[_0xcc64('0x3b')]=_0x54ddc6[_0xcc64('0x3b')]['length']?_0x54ddc6[_0xcc64('0x3b')]:_0xe49d28['model'];if(!_0x59163f[_0xcc64('0x39')]['hasOwnProperty']('nolimit')){_0x54ddc6[_0xcc64('0x29')]=qs[_0xcc64('0x29')](_0x59163f[_0xcc64('0x39')][_0xcc64('0x29')]);_0x54ddc6[_0xcc64('0x28')]=qs['offset'](_0x59163f[_0xcc64('0x39')][_0xcc64('0x28')]);}_0x54ddc6[_0xcc64('0x3e')]=qs[_0xcc64('0x3f')](_0x59163f['query'][_0xcc64('0x3f')]);_0x54ddc6[_0xcc64('0x40')]=qs[_0xcc64('0x3a')](_[_0xcc64('0x41')](_0x59163f['query'],_0xe49d28[_0xcc64('0x3a')]),_0x1c59a9);if(_0x59163f[_0xcc64('0x39')][_0xcc64('0x42')]){_0x54ddc6['where']=_[_0xcc64('0x43')](_0x54ddc6[_0xcc64('0x40')],{'$or':_[_0xcc64('0x33')](_0x1c59a9,function(_0xfc4ffe){if(_0xfc4ffe[_0xcc64('0x36')]!==_0xcc64('0x44')){var _0x1eef94={};_0x1eef94[_0xfc4ffe[_0xcc64('0x30')]]={'$like':'%'+_0x59163f['query'][_0xcc64('0x42')]+'%'};return _0x1eef94;}})});}_0x54ddc6=_[_0xcc64('0x43')]({},_0x54ddc6,_0x59163f[_0xcc64('0x45')]);var _0x3dc3bf={'where':_0x54ddc6[_0xcc64('0x40')]};return db[_0xcc64('0x34')]['count'](_0x3dc3bf)[_0xcc64('0x2f')](function(_0x4ddc6b){_0x1660eb['count']=_0x4ddc6b;if(_0x59163f[_0xcc64('0x39')]['includeAll']){_0x54ddc6[_0xcc64('0x46')]=[{'all':!![]}];}return db[_0xcc64('0x34')][_0xcc64('0x47')](_0x54ddc6);})[_0xcc64('0x2f')](function(_0x5eb055){_0x1660eb[_0xcc64('0x48')]=_0x5eb055;return _0x1660eb;})[_0xcc64('0x2f')](respondWithFilteredResult(_0xf8de38,_0x54ddc6))[_0xcc64('0x23')](handleError(_0xf8de38,null));};exports[_0xcc64('0x49')]=function(_0x2ef851,_0x375fd6){var _0x196005={'raw':![],'where':{'id':_0x2ef851[_0xcc64('0x4a')]['id']}},_0x24f27d={};_0x24f27d['model']=_['keys'](db[_0xcc64('0x34')][_0xcc64('0x35')]);_0x24f27d[_0xcc64('0x39')]=_[_0xcc64('0x38')](_0x2ef851[_0xcc64('0x39')]);_0x24f27d[_0xcc64('0x3a')]=_[_0xcc64('0x3c')](_0x24f27d[_0xcc64('0x37')],_0x24f27d[_0xcc64('0x39')]);_0x196005[_0xcc64('0x3b')]=_['intersection'](_0x24f27d[_0xcc64('0x37')],qs['fields'](_0x2ef851[_0xcc64('0x39')][_0xcc64('0x3d')]));_0x196005[_0xcc64('0x3b')]=_0x196005[_0xcc64('0x3b')][_0xcc64('0x4b')]?_0x196005['attributes']:_0x24f27d['model'];if(_0x2ef851[_0xcc64('0x39')]['includeAll']){_0x196005['include']=[{'all':!![]}];}_0x196005=_[_0xcc64('0x43')]({},_0x196005,_0x2ef851['options']);return db['SugarcrmConfiguration']['find'](_0x196005)[_0xcc64('0x2f')](handleEntityNotFound(_0x375fd6,null))[_0xcc64('0x2f')](respondWithResult(_0x375fd6,null))[_0xcc64('0x23')](handleError(_0x375fd6,null));};exports['create']=function(_0x32b75f,_0x4b4680){return db[_0xcc64('0x34')][_0xcc64('0x4c')](_0x32b75f[_0xcc64('0x4d')],{})['then'](respondWithResult(_0x4b4680,0xc9))[_0xcc64('0x23')](handleError(_0x4b4680,null));};exports[_0xcc64('0x2e')]=function(_0x51461d,_0x2c5587){if(_0x51461d[_0xcc64('0x4d')]['id']){delete _0x51461d[_0xcc64('0x4d')]['id'];}return db['SugarcrmConfiguration'][_0xcc64('0x4e')]({'where':{'id':_0x51461d[_0xcc64('0x4a')]['id']}})['then'](handleEntityNotFound(_0x2c5587,null))[_0xcc64('0x2f')](saveUpdates(_0x51461d[_0xcc64('0x4d')],null))[_0xcc64('0x2f')](respondWithResult(_0x2c5587,null))[_0xcc64('0x23')](handleError(_0x2c5587,null));};exports[_0xcc64('0x4f')]=function(_0x329181,_0x467dac){return db[_0xcc64('0x34')][_0xcc64('0x4e')]({'where':{'id':_0x329181['params']['id']}})[_0xcc64('0x2f')](handleEntityNotFound(_0x467dac,null))['then'](removeEntity(_0x467dac,null))[_0xcc64('0x23')](handleError(_0x467dac,null));};exports[_0xcc64('0x50')]=function(_0x43da8f,_0x8735df,_0x3ae369){var _0x39a504={};var _0x1830bf={};var _0x57b64e;var _0x221956;return db[_0xcc64('0x34')][_0xcc64('0x51')]({'where':{'id':_0x43da8f[_0xcc64('0x4a')]['id']}})[_0xcc64('0x2f')](handleEntityNotFound(_0x8735df,null))[_0xcc64('0x2f')](function(_0x4f17a4){if(_0x4f17a4){_0x57b64e=_0x4f17a4;_0x1830bf[_0xcc64('0x37')]=_[_0xcc64('0x38')](db['SugarcrmField']['rawAttributes']);_0x1830bf[_0xcc64('0x39')]=_['keys'](_0x43da8f[_0xcc64('0x39')]);_0x1830bf[_0xcc64('0x3a')]=_[_0xcc64('0x3c')](_0x1830bf[_0xcc64('0x37')],_0x1830bf[_0xcc64('0x39')]);_0x39a504['attributes']=_[_0xcc64('0x3c')](_0x1830bf[_0xcc64('0x37')],qs['fields'](_0x43da8f[_0xcc64('0x39')][_0xcc64('0x3d')]));_0x39a504[_0xcc64('0x3b')]=_0x39a504[_0xcc64('0x3b')][_0xcc64('0x4b')]?_0x39a504['attributes']:_0x1830bf[_0xcc64('0x37')];_0x39a504[_0xcc64('0x3e')]=qs[_0xcc64('0x3f')](_0x43da8f[_0xcc64('0x39')][_0xcc64('0x3f')]);_0x39a504[_0xcc64('0x40')]=qs[_0xcc64('0x3a')](_[_0xcc64('0x41')](_0x43da8f[_0xcc64('0x39')],_0x1830bf['filters']));if(_0x43da8f[_0xcc64('0x39')][_0xcc64('0x42')]){_0x39a504['where']=_[_0xcc64('0x43')](_0x39a504[_0xcc64('0x40')],{'$or':_[_0xcc64('0x33')](_0x39a504[_0xcc64('0x3b')],function(_0x40ad89){var _0x4a4a37={};_0x4a4a37[_0x40ad89]={'$like':'%'+_0x43da8f['query'][_0xcc64('0x42')]+'%'};return _0x4a4a37;})});}_0x39a504=_[_0xcc64('0x43')]({},_0x39a504,_0x43da8f['options']);return _0x57b64e[_0xcc64('0x50')](_0x39a504);}})[_0xcc64('0x2f')](function(_0x78c82e){if(_0x78c82e){_0x221956=_0x78c82e['length'];if(!_0x43da8f[_0xcc64('0x39')]['hasOwnProperty'](_0xcc64('0x52'))){_0x39a504[_0xcc64('0x29')]=qs[_0xcc64('0x29')](_0x43da8f[_0xcc64('0x39')][_0xcc64('0x29')]);_0x39a504['offset']=qs['offset'](_0x43da8f['query'][_0xcc64('0x28')]);}return _0x57b64e[_0xcc64('0x50')](_0x39a504);}})[_0xcc64('0x2f')](function(_0x4162f9){if(_0x4162f9){return _0x4162f9?{'count':_0x221956,'rows':_0x4162f9}:null;}})[_0xcc64('0x2f')](respondWithResult(_0x8735df,null))[_0xcc64('0x23')](handleError(_0x8735df,null));};exports[_0xcc64('0x53')]=function(_0x12772a,_0x4877f1,_0x14893b){var _0x118090={};var _0x32eaaa={};var _0x128787;var _0x381fd5;return db[_0xcc64('0x34')]['findOne']({'where':{'id':_0x12772a[_0xcc64('0x4a')]['id']}})[_0xcc64('0x2f')](handleEntityNotFound(_0x4877f1,null))[_0xcc64('0x2f')](function(_0x36af68){if(_0x36af68){_0x128787=_0x36af68;_0x32eaaa[_0xcc64('0x37')]=_[_0xcc64('0x38')](db[_0xcc64('0x54')]['rawAttributes']);_0x32eaaa[_0xcc64('0x39')]=_['keys'](_0x12772a[_0xcc64('0x39')]);_0x32eaaa[_0xcc64('0x3a')]=_[_0xcc64('0x3c')](_0x32eaaa[_0xcc64('0x37')],_0x32eaaa[_0xcc64('0x39')]);_0x118090[_0xcc64('0x3b')]=_[_0xcc64('0x3c')](_0x32eaaa[_0xcc64('0x37')],qs[_0xcc64('0x3d')](_0x12772a[_0xcc64('0x39')][_0xcc64('0x3d')]));_0x118090[_0xcc64('0x3b')]=_0x118090[_0xcc64('0x3b')][_0xcc64('0x4b')]?_0x118090[_0xcc64('0x3b')]:_0x32eaaa[_0xcc64('0x37')];_0x118090[_0xcc64('0x3e')]=qs[_0xcc64('0x3f')](_0x12772a[_0xcc64('0x39')][_0xcc64('0x3f')]);_0x118090[_0xcc64('0x40')]=qs[_0xcc64('0x3a')](_[_0xcc64('0x41')](_0x12772a[_0xcc64('0x39')],_0x32eaaa[_0xcc64('0x3a')]));if(_0x12772a['query'][_0xcc64('0x42')]){_0x118090[_0xcc64('0x40')]=_[_0xcc64('0x43')](_0x118090[_0xcc64('0x40')],{'$or':_[_0xcc64('0x33')](_0x118090[_0xcc64('0x3b')],function(_0x44e622){var _0x36354d={};_0x36354d[_0x44e622]={'$like':'%'+_0x12772a[_0xcc64('0x39')][_0xcc64('0x42')]+'%'};return _0x36354d;})});}_0x118090=_['merge']({},_0x118090,_0x12772a[_0xcc64('0x45')]);return _0x128787[_0xcc64('0x53')](_0x118090);}})[_0xcc64('0x2f')](function(_0x52b6f1){if(_0x52b6f1){_0x381fd5=_0x52b6f1[_0xcc64('0x4b')];if(!_0x12772a[_0xcc64('0x39')][_0xcc64('0x55')](_0xcc64('0x52'))){_0x118090[_0xcc64('0x29')]=qs[_0xcc64('0x29')](_0x12772a[_0xcc64('0x39')][_0xcc64('0x29')]);_0x118090[_0xcc64('0x28')]=qs[_0xcc64('0x28')](_0x12772a[_0xcc64('0x39')][_0xcc64('0x28')]);}return _0x128787[_0xcc64('0x53')](_0x118090);}})[_0xcc64('0x2f')](function(_0x2ba703){if(_0x2ba703){return _0x2ba703?{'count':_0x381fd5,'rows':_0x2ba703}:null;}})[_0xcc64('0x2f')](respondWithResult(_0x4877f1,null))[_0xcc64('0x23')](handleError(_0x4877f1,null));};exports['getDescriptions']=function(_0x56704c,_0x58249e,_0x1b7f3a){var _0x10350c={};var _0x1e2c2b={};var _0x55b787;var _0x5e41d7;return db['SugarcrmConfiguration'][_0xcc64('0x51')]({'where':{'id':_0x56704c[_0xcc64('0x4a')]['id']}})['then'](handleEntityNotFound(_0x58249e,null))[_0xcc64('0x2f')](function(_0x19f1ca){if(_0x19f1ca){_0x55b787=_0x19f1ca;_0x1e2c2b[_0xcc64('0x37')]=_[_0xcc64('0x38')](db['SugarcrmField']['rawAttributes']);_0x1e2c2b[_0xcc64('0x39')]=_['keys'](_0x56704c[_0xcc64('0x39')]);_0x1e2c2b[_0xcc64('0x3a')]=_['intersection'](_0x1e2c2b[_0xcc64('0x37')],_0x1e2c2b[_0xcc64('0x39')]);_0x10350c[_0xcc64('0x3b')]=_['intersection'](_0x1e2c2b[_0xcc64('0x37')],qs[_0xcc64('0x3d')](_0x56704c[_0xcc64('0x39')]['fields']));_0x10350c[_0xcc64('0x3b')]=_0x10350c[_0xcc64('0x3b')][_0xcc64('0x4b')]?_0x10350c[_0xcc64('0x3b')]:_0x1e2c2b['model'];_0x10350c['order']=qs[_0xcc64('0x3f')](_0x56704c[_0xcc64('0x39')]['sort']);_0x10350c[_0xcc64('0x40')]=qs['filters'](_[_0xcc64('0x41')](_0x56704c[_0xcc64('0x39')],_0x1e2c2b[_0xcc64('0x3a')]));if(_0x56704c['query'][_0xcc64('0x42')]){_0x10350c[_0xcc64('0x40')]=_[_0xcc64('0x43')](_0x10350c[_0xcc64('0x40')],{'$or':_[_0xcc64('0x33')](_0x10350c[_0xcc64('0x3b')],function(_0x5620b9){var _0x56aa45={};_0x56aa45[_0x5620b9]={'$like':'%'+_0x56704c['query'][_0xcc64('0x42')]+'%'};return _0x56aa45;})});}_0x10350c=_[_0xcc64('0x43')]({},_0x10350c,_0x56704c[_0xcc64('0x45')]);return _0x55b787[_0xcc64('0x56')](_0x10350c);}})[_0xcc64('0x2f')](function(_0x443651){if(_0x443651){_0x5e41d7=_0x443651['length'];if(!_0x56704c[_0xcc64('0x39')][_0xcc64('0x55')](_0xcc64('0x52'))){_0x10350c[_0xcc64('0x29')]=qs[_0xcc64('0x29')](_0x56704c['query']['limit']);_0x10350c[_0xcc64('0x28')]=qs[_0xcc64('0x28')](_0x56704c[_0xcc64('0x39')][_0xcc64('0x28')]);}return _0x55b787[_0xcc64('0x56')](_0x10350c);}})[_0xcc64('0x2f')](function(_0x3d93f2){if(_0x3d93f2){return _0x3d93f2?{'count':_0x5e41d7,'rows':_0x3d93f2}:null;}})['then'](respondWithResult(_0x58249e,null))[_0xcc64('0x23')](handleError(_0x58249e,null));};
\ No newline at end of file
+var _0x2ef4=['filters','intersection','attributes','fields','hasOwnProperty','nolimit','sort','filter','where','merge','type','VIRTUAL','includeAll','findAll','show','params','options','find','create','body','update','findOne','SugarcrmField','rawAttributes','length','order','pick','getFields','getSubjects','getDescriptions','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','util','path','sox','to-csv','fs-extra','squel','crypto','jsforce','desk.js','papaparse','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/logger','api','../../config/environment','../../config/license/util','../../mysqldb','jayson/promise','http','request','then','info','SugarcrmConfiguration,\x20%s,\x20%s','SugarcrmConfiguration,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error','code','message','catch','sendStatus','status','json','count','offset','limit','set','Content-Range','apply','reject','destroy','end','stack','name','send','index','map','SugarcrmConfiguration','fieldName','model','query','keys'];(function(_0x5e8d8b,_0x3defdb){var _0xc38051=function(_0x12dca7){while(--_0x12dca7){_0x5e8d8b['push'](_0x5e8d8b['shift']());}};_0xc38051(++_0x3defdb);}(_0x2ef4,0x1e0));var _0x42ef=function(_0x4c3953,_0x571b3a){_0x4c3953=_0x4c3953-0x0;var _0x28362e=_0x2ef4[_0x4c3953];return _0x28362e;};'use strict';var emlformat=require(_0x42ef('0x0'));var rimraf=require(_0x42ef('0x1'));var zipdir=require(_0x42ef('0x2'));var jsonpatch=require(_0x42ef('0x3'));var rp=require(_0x42ef('0x4'));var moment=require(_0x42ef('0x5'));var BPromise=require(_0x42ef('0x6'));var Mustache=require('mustache');var util=require(_0x42ef('0x7'));var path=require(_0x42ef('0x8'));var sox=require(_0x42ef('0x9'));var csv=require(_0x42ef('0xa'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0x42ef('0xb'));var _=require('lodash');var squel=require(_0x42ef('0xc'));var crypto=require(_0x42ef('0xd'));var jsforce=require(_0x42ef('0xe'));var deskjs=require(_0x42ef('0xf'));var toCsv=require(_0x42ef('0xa'));var querystring=require('querystring');var Papa=require(_0x42ef('0x10'));var Redis=require('ioredis');var authService=require(_0x42ef('0x11'));var qs=require(_0x42ef('0x12'));var as=require(_0x42ef('0x13'));var hardwareService=require('../../config/license/hardware');var logger=require(_0x42ef('0x14'))(_0x42ef('0x15'));var utils=require('../../config/utils');var config=require(_0x42ef('0x16'));var licenseUtil=require(_0x42ef('0x17'));var db=require(_0x42ef('0x18'))['db'];var jayson=require(_0x42ef('0x19'));var client=jayson['client'][_0x42ef('0x1a')]({'port':0x232a});function respondWithRpcPromise(_0x4b21f4,_0x35fab8,_0xa0560f,_0x50f5ca){return new BPromise(function(_0x1114fa,_0x52658a){var _0x5d501b=_0x50f5ca||client;return _0x5d501b[_0x42ef('0x1b')](_0x4b21f4,_0xa0560f)[_0x42ef('0x1c')](function(_0x1ebcac){logger[_0x42ef('0x1d')](_0x42ef('0x1e'),_0x35fab8,'request\x20sent');logger['debug'](_0x42ef('0x1f'),_0x35fab8,_0x42ef('0x20'),JSON[_0x42ef('0x21')](_0x1ebcac));if(_0x1ebcac[_0x42ef('0x22')]){if(_0x1ebcac['error'][_0x42ef('0x23')]===0x1f4){logger['error'](_0x42ef('0x1e'),_0x35fab8,_0x1ebcac[_0x42ef('0x22')][_0x42ef('0x24')]);return _0x52658a(_0x1ebcac[_0x42ef('0x22')]['message']);}logger[_0x42ef('0x22')]('SugarcrmConfiguration,\x20%s,\x20%s',_0x35fab8,_0x1ebcac[_0x42ef('0x22')][_0x42ef('0x24')]);return _0x1114fa(_0x1ebcac[_0x42ef('0x22')][_0x42ef('0x24')]);}else{logger[_0x42ef('0x1d')](_0x42ef('0x1e'),_0x35fab8,_0x42ef('0x20'));_0x1114fa(_0x1ebcac['result'][_0x42ef('0x24')]);}})[_0x42ef('0x25')](function(_0xca1345){logger[_0x42ef('0x22')](_0x42ef('0x1e'),_0x35fab8,_0xca1345);_0x52658a(_0xca1345);});});}function respondWithStatusCode(_0x285e21,_0x49e348){_0x49e348=_0x49e348||0xcc;return function(_0x3baede){if(_0x3baede){return _0x285e21[_0x42ef('0x26')](_0x49e348);}return _0x285e21[_0x42ef('0x27')](_0x49e348)['end']();};}function respondWithResult(_0x401a4f,_0x26e106){_0x26e106=_0x26e106||0xc8;return function(_0x5d327c){if(_0x5d327c){return _0x401a4f[_0x42ef('0x27')](_0x26e106)[_0x42ef('0x28')](_0x5d327c);}};}function respondWithFilteredResult(_0x2416d0,_0xa3e16a){return function(_0xfbb535){if(_0xfbb535){var _0x433f95=_0xfbb535[_0x42ef('0x29')],_0x3e0bab=_0xa3e16a[_0x42ef('0x2a')],_0x5ee9f9=_0xa3e16a['offset']+_0xa3e16a[_0x42ef('0x2b')],_0x2483e6;if(_0x5ee9f9>=_0x433f95){_0x5ee9f9=_0x433f95;_0x2483e6=0xc8;}else{_0x2483e6=0xce;}_0x2416d0[_0x42ef('0x27')](_0x2483e6);return _0x2416d0[_0x42ef('0x2c')](_0x42ef('0x2d'),_0x3e0bab+'-'+_0x5ee9f9+'/'+_0x433f95)[_0x42ef('0x28')](_0xfbb535);}return null;};}function patchUpdates(_0x2593ad){return function(_0x54f3cb){try{jsonpatch[_0x42ef('0x2e')](_0x54f3cb,_0x2593ad,!![]);}catch(_0x29216c){return BPromise[_0x42ef('0x2f')](_0x29216c);}return _0x54f3cb['save']();};}function saveUpdates(_0x157bca,_0x104a0c){return function(_0x22c996){if(_0x22c996){return _0x22c996['update'](_0x157bca)[_0x42ef('0x1c')](function(_0xaa4846){return _0xaa4846;});}return null;};}function removeEntity(_0x2ff201,_0x3b46f8){return function(_0x38d816){if(_0x38d816){return _0x38d816[_0x42ef('0x30')]()[_0x42ef('0x1c')](function(){_0x2ff201[_0x42ef('0x27')](0xcc)[_0x42ef('0x31')]();});}};}function handleEntityNotFound(_0x53584f,_0x1b1bc4){return function(_0x2e401f){if(!_0x2e401f){_0x53584f[_0x42ef('0x26')](0x194);}return _0x2e401f;};}function handleError(_0x2d15aa,_0x486a51){_0x486a51=_0x486a51||0x1f4;return function(_0x223ba2){logger[_0x42ef('0x22')](_0x223ba2[_0x42ef('0x32')]);if(_0x223ba2[_0x42ef('0x33')]){delete _0x223ba2[_0x42ef('0x33')];}_0x2d15aa[_0x42ef('0x27')](_0x486a51)[_0x42ef('0x34')](_0x223ba2);};}exports[_0x42ef('0x35')]=function(_0x26b88e,_0x2cdf19){var _0x577ec2={},_0x1499a5={},_0x387ff0={'count':0x0,'rows':[]};var _0x29c6b0=_[_0x42ef('0x36')](db[_0x42ef('0x37')]['rawAttributes'],function(_0x4dcdcc){return{'name':_0x4dcdcc[_0x42ef('0x38')],'type':_0x4dcdcc['type']['key']};});_0x1499a5[_0x42ef('0x39')]=_[_0x42ef('0x36')](_0x29c6b0,_0x42ef('0x33'));_0x1499a5[_0x42ef('0x3a')]=_[_0x42ef('0x3b')](_0x26b88e['query']);_0x1499a5[_0x42ef('0x3c')]=_[_0x42ef('0x3d')](_0x1499a5['model'],_0x1499a5['query']);_0x577ec2[_0x42ef('0x3e')]=_[_0x42ef('0x3d')](_0x1499a5['model'],qs[_0x42ef('0x3f')](_0x26b88e[_0x42ef('0x3a')][_0x42ef('0x3f')]));_0x577ec2[_0x42ef('0x3e')]=_0x577ec2[_0x42ef('0x3e')]['length']?_0x577ec2[_0x42ef('0x3e')]:_0x1499a5[_0x42ef('0x39')];if(!_0x26b88e[_0x42ef('0x3a')][_0x42ef('0x40')](_0x42ef('0x41'))){_0x577ec2[_0x42ef('0x2b')]=qs['limit'](_0x26b88e[_0x42ef('0x3a')]['limit']);_0x577ec2[_0x42ef('0x2a')]=qs[_0x42ef('0x2a')](_0x26b88e[_0x42ef('0x3a')][_0x42ef('0x2a')]);}_0x577ec2['order']=qs['sort'](_0x26b88e[_0x42ef('0x3a')][_0x42ef('0x42')]);_0x577ec2['where']=qs[_0x42ef('0x3c')](_['pick'](_0x26b88e['query'],_0x1499a5[_0x42ef('0x3c')]),_0x29c6b0);if(_0x26b88e[_0x42ef('0x3a')][_0x42ef('0x43')]){_0x577ec2[_0x42ef('0x44')]=_[_0x42ef('0x45')](_0x577ec2[_0x42ef('0x44')],{'$or':_[_0x42ef('0x36')](_0x29c6b0,function(_0x29725d){if(_0x29725d[_0x42ef('0x46')]!==_0x42ef('0x47')){var _0x12c77d={};_0x12c77d[_0x29725d['name']]={'$like':'%'+_0x26b88e[_0x42ef('0x3a')][_0x42ef('0x43')]+'%'};return _0x12c77d;}})});}_0x577ec2=_[_0x42ef('0x45')]({},_0x577ec2,_0x26b88e['options']);var _0x3c002e={'where':_0x577ec2['where']};return db[_0x42ef('0x37')]['count'](_0x3c002e)[_0x42ef('0x1c')](function(_0x19633d){_0x387ff0['count']=_0x19633d;if(_0x26b88e[_0x42ef('0x3a')][_0x42ef('0x48')]){_0x577ec2['include']=[{'all':!![]}];}return db[_0x42ef('0x37')][_0x42ef('0x49')](_0x577ec2);})[_0x42ef('0x1c')](function(_0xc8722f){_0x387ff0['rows']=_0xc8722f;return _0x387ff0;})[_0x42ef('0x1c')](respondWithFilteredResult(_0x2cdf19,_0x577ec2))[_0x42ef('0x25')](handleError(_0x2cdf19,null));};exports[_0x42ef('0x4a')]=function(_0x11aecf,_0x5e5b39){var _0x36877e={'raw':![],'where':{'id':_0x11aecf[_0x42ef('0x4b')]['id']}},_0x7f3465={};_0x7f3465[_0x42ef('0x39')]=_[_0x42ef('0x3b')](db[_0x42ef('0x37')]['rawAttributes']);_0x7f3465['query']=_['keys'](_0x11aecf[_0x42ef('0x3a')]);_0x7f3465[_0x42ef('0x3c')]=_[_0x42ef('0x3d')](_0x7f3465[_0x42ef('0x39')],_0x7f3465[_0x42ef('0x3a')]);_0x36877e[_0x42ef('0x3e')]=_['intersection'](_0x7f3465[_0x42ef('0x39')],qs[_0x42ef('0x3f')](_0x11aecf[_0x42ef('0x3a')]['fields']));_0x36877e['attributes']=_0x36877e[_0x42ef('0x3e')]['length']?_0x36877e[_0x42ef('0x3e')]:_0x7f3465['model'];if(_0x11aecf[_0x42ef('0x3a')]['includeAll']){_0x36877e['include']=[{'all':!![]}];}_0x36877e=_[_0x42ef('0x45')]({},_0x36877e,_0x11aecf[_0x42ef('0x4c')]);return db['SugarcrmConfiguration'][_0x42ef('0x4d')](_0x36877e)[_0x42ef('0x1c')](handleEntityNotFound(_0x5e5b39,null))[_0x42ef('0x1c')](respondWithResult(_0x5e5b39,null))['catch'](handleError(_0x5e5b39,null));};exports[_0x42ef('0x4e')]=function(_0x353ba6,_0x24b118){return db[_0x42ef('0x37')][_0x42ef('0x4e')](_0x353ba6[_0x42ef('0x4f')],{})['then'](respondWithResult(_0x24b118,0xc9))[_0x42ef('0x25')](handleError(_0x24b118,null));};exports[_0x42ef('0x50')]=function(_0x353b27,_0x76632b){if(_0x353b27['body']['id']){delete _0x353b27['body']['id'];}return db['SugarcrmConfiguration'][_0x42ef('0x4d')]({'where':{'id':_0x353b27[_0x42ef('0x4b')]['id']}})[_0x42ef('0x1c')](handleEntityNotFound(_0x76632b,null))[_0x42ef('0x1c')](saveUpdates(_0x353b27['body'],null))[_0x42ef('0x1c')](respondWithResult(_0x76632b,null))[_0x42ef('0x25')](handleError(_0x76632b,null));};exports[_0x42ef('0x30')]=function(_0x382aa2,_0x34a8b7){return db[_0x42ef('0x37')][_0x42ef('0x4d')]({'where':{'id':_0x382aa2['params']['id']}})[_0x42ef('0x1c')](handleEntityNotFound(_0x34a8b7,null))[_0x42ef('0x1c')](removeEntity(_0x34a8b7,null))['catch'](handleError(_0x34a8b7,null));};exports['getFields']=function(_0x566b62,_0x293417,_0x3acc31){var _0x1dd495={};var _0x4985bc={};var _0x4020d6;var _0x295cc4;return db[_0x42ef('0x37')][_0x42ef('0x51')]({'where':{'id':_0x566b62[_0x42ef('0x4b')]['id']}})[_0x42ef('0x1c')](handleEntityNotFound(_0x293417,null))[_0x42ef('0x1c')](function(_0x303967){if(_0x303967){_0x4020d6=_0x303967;_0x4985bc[_0x42ef('0x39')]=_[_0x42ef('0x3b')](db[_0x42ef('0x52')][_0x42ef('0x53')]);_0x4985bc['query']=_[_0x42ef('0x3b')](_0x566b62[_0x42ef('0x3a')]);_0x4985bc[_0x42ef('0x3c')]=_[_0x42ef('0x3d')](_0x4985bc[_0x42ef('0x39')],_0x4985bc['query']);_0x1dd495[_0x42ef('0x3e')]=_[_0x42ef('0x3d')](_0x4985bc[_0x42ef('0x39')],qs[_0x42ef('0x3f')](_0x566b62[_0x42ef('0x3a')]['fields']));_0x1dd495[_0x42ef('0x3e')]=_0x1dd495[_0x42ef('0x3e')][_0x42ef('0x54')]?_0x1dd495[_0x42ef('0x3e')]:_0x4985bc['model'];_0x1dd495[_0x42ef('0x55')]=qs['sort'](_0x566b62[_0x42ef('0x3a')][_0x42ef('0x42')]);_0x1dd495[_0x42ef('0x44')]=qs[_0x42ef('0x3c')](_[_0x42ef('0x56')](_0x566b62[_0x42ef('0x3a')],_0x4985bc['filters']));if(_0x566b62[_0x42ef('0x3a')][_0x42ef('0x43')]){_0x1dd495['where']=_[_0x42ef('0x45')](_0x1dd495[_0x42ef('0x44')],{'$or':_['map'](_0x1dd495[_0x42ef('0x3e')],function(_0x14355c){var _0x2c0659={};_0x2c0659[_0x14355c]={'$like':'%'+_0x566b62[_0x42ef('0x3a')]['filter']+'%'};return _0x2c0659;})});}_0x1dd495=_['merge']({},_0x1dd495,_0x566b62['options']);return _0x4020d6[_0x42ef('0x57')](_0x1dd495);}})[_0x42ef('0x1c')](function(_0xa2859d){if(_0xa2859d){_0x295cc4=_0xa2859d[_0x42ef('0x54')];if(!_0x566b62[_0x42ef('0x3a')][_0x42ef('0x40')](_0x42ef('0x41'))){_0x1dd495['limit']=qs[_0x42ef('0x2b')](_0x566b62[_0x42ef('0x3a')][_0x42ef('0x2b')]);_0x1dd495['offset']=qs[_0x42ef('0x2a')](_0x566b62[_0x42ef('0x3a')][_0x42ef('0x2a')]);}return _0x4020d6[_0x42ef('0x57')](_0x1dd495);}})[_0x42ef('0x1c')](function(_0x3f8b8c){if(_0x3f8b8c){return _0x3f8b8c?{'count':_0x295cc4,'rows':_0x3f8b8c}:null;}})['then'](respondWithResult(_0x293417,null))[_0x42ef('0x25')](handleError(_0x293417,null));};exports['getSubjects']=function(_0x514b89,_0x1488ed,_0x142e95){var _0x44f533={};var _0x18b752={};var _0x527766;var _0x1f18cb;return db['SugarcrmConfiguration']['findOne']({'where':{'id':_0x514b89[_0x42ef('0x4b')]['id']}})[_0x42ef('0x1c')](handleEntityNotFound(_0x1488ed,null))[_0x42ef('0x1c')](function(_0x384b75){if(_0x384b75){_0x527766=_0x384b75;_0x18b752[_0x42ef('0x39')]=_[_0x42ef('0x3b')](db[_0x42ef('0x52')][_0x42ef('0x53')]);_0x18b752[_0x42ef('0x3a')]=_['keys'](_0x514b89[_0x42ef('0x3a')]);_0x18b752[_0x42ef('0x3c')]=_[_0x42ef('0x3d')](_0x18b752[_0x42ef('0x39')],_0x18b752[_0x42ef('0x3a')]);_0x44f533[_0x42ef('0x3e')]=_['intersection'](_0x18b752[_0x42ef('0x39')],qs['fields'](_0x514b89[_0x42ef('0x3a')]['fields']));_0x44f533[_0x42ef('0x3e')]=_0x44f533[_0x42ef('0x3e')][_0x42ef('0x54')]?_0x44f533[_0x42ef('0x3e')]:_0x18b752[_0x42ef('0x39')];_0x44f533['order']=qs[_0x42ef('0x42')](_0x514b89[_0x42ef('0x3a')][_0x42ef('0x42')]);_0x44f533[_0x42ef('0x44')]=qs[_0x42ef('0x3c')](_[_0x42ef('0x56')](_0x514b89['query'],_0x18b752[_0x42ef('0x3c')]));if(_0x514b89[_0x42ef('0x3a')]['filter']){_0x44f533[_0x42ef('0x44')]=_[_0x42ef('0x45')](_0x44f533[_0x42ef('0x44')],{'$or':_[_0x42ef('0x36')](_0x44f533[_0x42ef('0x3e')],function(_0x5a16e4){var _0x2b3a30={};_0x2b3a30[_0x5a16e4]={'$like':'%'+_0x514b89[_0x42ef('0x3a')][_0x42ef('0x43')]+'%'};return _0x2b3a30;})});}_0x44f533=_['merge']({},_0x44f533,_0x514b89[_0x42ef('0x4c')]);return _0x527766[_0x42ef('0x58')](_0x44f533);}})[_0x42ef('0x1c')](function(_0x5d5330){if(_0x5d5330){_0x1f18cb=_0x5d5330[_0x42ef('0x54')];if(!_0x514b89['query'][_0x42ef('0x40')](_0x42ef('0x41'))){_0x44f533['limit']=qs[_0x42ef('0x2b')](_0x514b89[_0x42ef('0x3a')][_0x42ef('0x2b')]);_0x44f533[_0x42ef('0x2a')]=qs['offset'](_0x514b89['query'][_0x42ef('0x2a')]);}return _0x527766[_0x42ef('0x58')](_0x44f533);}})[_0x42ef('0x1c')](function(_0x44fc89){if(_0x44fc89){return _0x44fc89?{'count':_0x1f18cb,'rows':_0x44fc89}:null;}})[_0x42ef('0x1c')](respondWithResult(_0x1488ed,null))[_0x42ef('0x25')](handleError(_0x1488ed,null));};exports[_0x42ef('0x59')]=function(_0x355624,_0x3574cf,_0x4080b5){var _0x3789e3={};var _0x1e545a={};var _0x351614;var _0x13b730;return db[_0x42ef('0x37')][_0x42ef('0x51')]({'where':{'id':_0x355624[_0x42ef('0x4b')]['id']}})['then'](handleEntityNotFound(_0x3574cf,null))[_0x42ef('0x1c')](function(_0x11fd43){if(_0x11fd43){_0x351614=_0x11fd43;_0x1e545a['model']=_['keys'](db[_0x42ef('0x52')][_0x42ef('0x53')]);_0x1e545a['query']=_[_0x42ef('0x3b')](_0x355624[_0x42ef('0x3a')]);_0x1e545a[_0x42ef('0x3c')]=_['intersection'](_0x1e545a[_0x42ef('0x39')],_0x1e545a[_0x42ef('0x3a')]);_0x3789e3[_0x42ef('0x3e')]=_[_0x42ef('0x3d')](_0x1e545a['model'],qs[_0x42ef('0x3f')](_0x355624[_0x42ef('0x3a')][_0x42ef('0x3f')]));_0x3789e3['attributes']=_0x3789e3[_0x42ef('0x3e')][_0x42ef('0x54')]?_0x3789e3[_0x42ef('0x3e')]:_0x1e545a[_0x42ef('0x39')];_0x3789e3[_0x42ef('0x55')]=qs[_0x42ef('0x42')](_0x355624[_0x42ef('0x3a')]['sort']);_0x3789e3['where']=qs[_0x42ef('0x3c')](_['pick'](_0x355624[_0x42ef('0x3a')],_0x1e545a['filters']));if(_0x355624[_0x42ef('0x3a')]['filter']){_0x3789e3['where']=_[_0x42ef('0x45')](_0x3789e3[_0x42ef('0x44')],{'$or':_[_0x42ef('0x36')](_0x3789e3[_0x42ef('0x3e')],function(_0x20c76c){var _0x547147={};_0x547147[_0x20c76c]={'$like':'%'+_0x355624[_0x42ef('0x3a')]['filter']+'%'};return _0x547147;})});}_0x3789e3=_[_0x42ef('0x45')]({},_0x3789e3,_0x355624['options']);return _0x351614[_0x42ef('0x59')](_0x3789e3);}})['then'](function(_0x529a40){if(_0x529a40){_0x13b730=_0x529a40[_0x42ef('0x54')];if(!_0x355624['query']['hasOwnProperty']('nolimit')){_0x3789e3[_0x42ef('0x2b')]=qs['limit'](_0x355624[_0x42ef('0x3a')]['limit']);_0x3789e3[_0x42ef('0x2a')]=qs[_0x42ef('0x2a')](_0x355624[_0x42ef('0x3a')][_0x42ef('0x2a')]);}return _0x351614['getDescriptions'](_0x3789e3);}})[_0x42ef('0x1c')](function(_0x1a1eeb){if(_0x1a1eeb){return _0x1a1eeb?{'count':_0x13b730,'rows':_0x1a1eeb}:null;}})[_0x42ef('0x1c')](respondWithResult(_0x3574cf,null))['catch'](handleError(_0x3574cf,null));};
\ No newline at end of file