Built motion from commit e1760111.|2.6.18
[motion2.git] / server / api / intSugarcrmConfiguration / intSugarcrmConfiguration.controller.js
index b5daa48..08f0380 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xa134=['message','result','catch','sendStatus','status','json','count','offset','Content-Range','apply','reject','save','then','end','stack','name','send','index','map','type','model','query','keys','filters','intersection','attributes','fields','length','hasOwnProperty','limit','order','sort','pick','where','merge','VIRTUAL','filter','options','SugarcrmConfiguration','include','findAll','rows','show','includeAll','find','create','body','destroy','params','findOne','getFields','nolimit','getSubjects','SugarcrmField','rawAttributes','getDescriptions','html-pdf','rimraf','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','sox','to-csv','ejs','lodash','squel','crypto','jsforce','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/license/util','../../mysqldb','jayson/promise','client','http','request','info','request\x20sent','debug','SugarcrmConfiguration,\x20%s,\x20%s,\x20%s','stringify','error','code','SugarcrmConfiguration,\x20%s,\x20%s'];(function(_0x93a816,_0x2651f6){var _0x5de744=function(_0xd6bbb){while(--_0xd6bbb){_0x93a816['push'](_0x93a816['shift']());}};_0x5de744(++_0x2651f6);}(_0xa134,0x1b4));var _0x4a13=function(_0x3dd15e,_0x1f0015){_0x3dd15e=_0x3dd15e-0x0;var _0x231fd0=_0xa134[_0x3dd15e];return _0x231fd0;};'use strict';var pdf=require(_0x4a13('0x0'));var emlformat=require('eml-format');var rimraf=require(_0x4a13('0x1'));var zipdir=require('zip-dir');var jsonpatch=require(_0x4a13('0x2'));var rp=require(_0x4a13('0x3'));var moment=require(_0x4a13('0x4'));var BPromise=require(_0x4a13('0x5'));var Mustache=require(_0x4a13('0x6'));var util=require(_0x4a13('0x7'));var path=require(_0x4a13('0x8'));var sox=require(_0x4a13('0x9'));var csv=require(_0x4a13('0xa'));var ejs=require(_0x4a13('0xb'));var fs=require('fs');var _=require(_0x4a13('0xc'));var squel=require(_0x4a13('0xd'));var crypto=require(_0x4a13('0xe'));var jsforce=require(_0x4a13('0xf'));var deskjs=require('desk.js');var toCsv=require(_0x4a13('0xa'));var querystring=require('querystring');var Papa=require(_0x4a13('0x10'));var Redis=require(_0x4a13('0x11'));var authService=require(_0x4a13('0x12'));var qs=require(_0x4a13('0x13'));var as=require(_0x4a13('0x14'));var hardwareService=require(_0x4a13('0x15'));var logger=require(_0x4a13('0x16'))(_0x4a13('0x17'));var utils=require(_0x4a13('0x18'));var config=require('../../config/environment');var licenseUtil=require(_0x4a13('0x19'));var db=require(_0x4a13('0x1a'))['db'];var jayson=require(_0x4a13('0x1b'));var client=jayson[_0x4a13('0x1c')][_0x4a13('0x1d')]({'port':0x232a});function respondWithRpcPromise(_0x2ee312,_0x323aa1,_0x237a8a,_0xd69ef9){return new BPromise(function(_0x5bd681,_0x3c9435){var _0x4a36a8=_0xd69ef9||client;return _0x4a36a8[_0x4a13('0x1e')](_0x2ee312,_0x237a8a)['then'](function(_0x30cd24){logger[_0x4a13('0x1f')]('SugarcrmConfiguration,\x20%s,\x20%s',_0x323aa1,_0x4a13('0x20'));logger[_0x4a13('0x21')](_0x4a13('0x22'),_0x323aa1,_0x4a13('0x20'),JSON[_0x4a13('0x23')](_0x30cd24));if(_0x30cd24['error']){if(_0x30cd24[_0x4a13('0x24')][_0x4a13('0x25')]===0x1f4){logger['error'](_0x4a13('0x26'),_0x323aa1,_0x30cd24[_0x4a13('0x24')][_0x4a13('0x27')]);return _0x3c9435(_0x30cd24[_0x4a13('0x24')]['message']);}logger['error'](_0x4a13('0x26'),_0x323aa1,_0x30cd24[_0x4a13('0x24')][_0x4a13('0x27')]);return _0x5bd681(_0x30cd24[_0x4a13('0x24')]['message']);}else{logger[_0x4a13('0x1f')]('SugarcrmConfiguration,\x20%s,\x20%s',_0x323aa1,_0x4a13('0x20'));_0x5bd681(_0x30cd24[_0x4a13('0x28')]['message']);}})[_0x4a13('0x29')](function(_0x5d280f){logger['error'](_0x4a13('0x26'),_0x323aa1,_0x5d280f);_0x3c9435(_0x5d280f);});});}function respondWithStatusCode(_0x238376,_0xf56f5d){_0xf56f5d=_0xf56f5d||0xcc;return function(_0x1dcd3e){if(_0x1dcd3e){return _0x238376[_0x4a13('0x2a')](_0xf56f5d);}return _0x238376[_0x4a13('0x2b')](_0xf56f5d)['end']();};}function respondWithResult(_0xb8dadb,_0x55fe78){_0x55fe78=_0x55fe78||0xc8;return function(_0x405765){if(_0x405765){return _0xb8dadb[_0x4a13('0x2b')](_0x55fe78)[_0x4a13('0x2c')](_0x405765);}};}function respondWithFilteredResult(_0x2efcda,_0x19d7d8){return function(_0x4ca699){if(_0x4ca699){var _0x255ae0=_0x4ca699[_0x4a13('0x2d')],_0xa601b6=_0x19d7d8['offset'],_0xf4ade9=_0x19d7d8[_0x4a13('0x2e')]+_0x19d7d8['limit'],_0x322460;if(_0xf4ade9>=_0x255ae0){_0xf4ade9=_0x255ae0;_0x322460=0xc8;}else{_0x322460=0xce;}_0x2efcda[_0x4a13('0x2b')](_0x322460);return _0x2efcda['set'](_0x4a13('0x2f'),_0xa601b6+'-'+_0xf4ade9+'/'+_0x255ae0)[_0x4a13('0x2c')](_0x4ca699);}return null;};}function patchUpdates(_0xc90916){return function(_0x5799f7){try{jsonpatch[_0x4a13('0x30')](_0x5799f7,_0xc90916,!![]);}catch(_0x497608){return BPromise[_0x4a13('0x31')](_0x497608);}return _0x5799f7[_0x4a13('0x32')]();};}function saveUpdates(_0x8c7526,_0x1e3374){return function(_0x405f9e){if(_0x405f9e){return _0x405f9e['update'](_0x8c7526)[_0x4a13('0x33')](function(_0x23329a){return _0x23329a;});}return null;};}function removeEntity(_0x499917,_0x3b1bdd){return function(_0x230d6a){if(_0x230d6a){return _0x230d6a['destroy']()[_0x4a13('0x33')](function(){_0x499917['status'](0xcc)[_0x4a13('0x34')]();});}};}function handleEntityNotFound(_0x426ffd,_0x300191){return function(_0xccef75){if(!_0xccef75){_0x426ffd['sendStatus'](0x194);}return _0xccef75;};}function handleError(_0x329d09,_0x5bb829){_0x5bb829=_0x5bb829||0x1f4;return function(_0x49f1b0){logger[_0x4a13('0x24')](_0x49f1b0[_0x4a13('0x35')]);if(_0x49f1b0[_0x4a13('0x36')]){delete _0x49f1b0[_0x4a13('0x36')];}_0x329d09['status'](_0x5bb829)[_0x4a13('0x37')](_0x49f1b0);};}exports[_0x4a13('0x38')]=function(_0x287c69,_0x19271a){var _0x553f13={},_0x46d030={},_0x447c19={'count':0x0,'rows':[]};var _0x5dcc59=_[_0x4a13('0x39')](db['SugarcrmConfiguration']['rawAttributes'],function(_0xb9fdbb){return{'name':_0xb9fdbb['fieldName'],'type':_0xb9fdbb[_0x4a13('0x3a')]['key']};});_0x46d030[_0x4a13('0x3b')]=_[_0x4a13('0x39')](_0x5dcc59,_0x4a13('0x36'));_0x46d030[_0x4a13('0x3c')]=_[_0x4a13('0x3d')](_0x287c69['query']);_0x46d030[_0x4a13('0x3e')]=_[_0x4a13('0x3f')](_0x46d030['model'],_0x46d030['query']);_0x553f13[_0x4a13('0x40')]=_['intersection'](_0x46d030[_0x4a13('0x3b')],qs[_0x4a13('0x41')](_0x287c69[_0x4a13('0x3c')][_0x4a13('0x41')]));_0x553f13['attributes']=_0x553f13[_0x4a13('0x40')][_0x4a13('0x42')]?_0x553f13[_0x4a13('0x40')]:_0x46d030['model'];if(!_0x287c69['query'][_0x4a13('0x43')]('nolimit')){_0x553f13['limit']=qs[_0x4a13('0x44')](_0x287c69[_0x4a13('0x3c')][_0x4a13('0x44')]);_0x553f13[_0x4a13('0x2e')]=qs[_0x4a13('0x2e')](_0x287c69['query'][_0x4a13('0x2e')]);}_0x553f13[_0x4a13('0x45')]=qs['sort'](_0x287c69[_0x4a13('0x3c')][_0x4a13('0x46')]);_0x553f13['where']=qs['filters'](_[_0x4a13('0x47')](_0x287c69[_0x4a13('0x3c')],_0x46d030[_0x4a13('0x3e')]),_0x5dcc59);if(_0x287c69['query']['filter']){_0x553f13[_0x4a13('0x48')]=_[_0x4a13('0x49')](_0x553f13['where'],{'$or':_[_0x4a13('0x39')](_0x5dcc59,function(_0x5ae0b0){if(_0x5ae0b0['type']!==_0x4a13('0x4a')){var _0x3be0b2={};_0x3be0b2[_0x5ae0b0['name']]={'$like':'%'+_0x287c69['query'][_0x4a13('0x4b')]+'%'};return _0x3be0b2;}})});}_0x553f13=_[_0x4a13('0x49')]({},_0x553f13,_0x287c69[_0x4a13('0x4c')]);var _0x38ab00={'where':_0x553f13[_0x4a13('0x48')]};return db[_0x4a13('0x4d')][_0x4a13('0x2d')](_0x38ab00)['then'](function(_0x6a77e4){_0x447c19[_0x4a13('0x2d')]=_0x6a77e4;if(_0x287c69[_0x4a13('0x3c')]['includeAll']){_0x553f13[_0x4a13('0x4e')]=[{'all':!![]}];}return db[_0x4a13('0x4d')][_0x4a13('0x4f')](_0x553f13);})['then'](function(_0xb83c80){_0x447c19[_0x4a13('0x50')]=_0xb83c80;return _0x447c19;})[_0x4a13('0x33')](respondWithFilteredResult(_0x19271a,_0x553f13))['catch'](handleError(_0x19271a,null));};exports[_0x4a13('0x51')]=function(_0xdd017d,_0x4c5580){var _0x3428a5={'raw':![],'where':{'id':_0xdd017d['params']['id']}},_0x27ef6b={};_0x27ef6b[_0x4a13('0x3b')]=_[_0x4a13('0x3d')](db[_0x4a13('0x4d')]['rawAttributes']);_0x27ef6b['query']=_['keys'](_0xdd017d[_0x4a13('0x3c')]);_0x27ef6b[_0x4a13('0x3e')]=_[_0x4a13('0x3f')](_0x27ef6b['model'],_0x27ef6b[_0x4a13('0x3c')]);_0x3428a5[_0x4a13('0x40')]=_[_0x4a13('0x3f')](_0x27ef6b[_0x4a13('0x3b')],qs[_0x4a13('0x41')](_0xdd017d[_0x4a13('0x3c')][_0x4a13('0x41')]));_0x3428a5['attributes']=_0x3428a5[_0x4a13('0x40')][_0x4a13('0x42')]?_0x3428a5[_0x4a13('0x40')]:_0x27ef6b['model'];if(_0xdd017d[_0x4a13('0x3c')][_0x4a13('0x52')]){_0x3428a5[_0x4a13('0x4e')]=[{'all':!![]}];}_0x3428a5=_[_0x4a13('0x49')]({},_0x3428a5,_0xdd017d['options']);return db[_0x4a13('0x4d')][_0x4a13('0x53')](_0x3428a5)['then'](handleEntityNotFound(_0x4c5580,null))[_0x4a13('0x33')](respondWithResult(_0x4c5580,null))[_0x4a13('0x29')](handleError(_0x4c5580,null));};exports[_0x4a13('0x54')]=function(_0x525ca2,_0x52f183){return db[_0x4a13('0x4d')][_0x4a13('0x54')](_0x525ca2[_0x4a13('0x55')],{})[_0x4a13('0x33')](respondWithResult(_0x52f183,0xc9))['catch'](handleError(_0x52f183,null));};exports['update']=function(_0x55c3b7,_0x4d42b1){if(_0x55c3b7[_0x4a13('0x55')]['id']){delete _0x55c3b7[_0x4a13('0x55')]['id'];}return db[_0x4a13('0x4d')]['find']({'where':{'id':_0x55c3b7['params']['id']}})[_0x4a13('0x33')](handleEntityNotFound(_0x4d42b1,null))['then'](saveUpdates(_0x55c3b7[_0x4a13('0x55')],null))['then'](respondWithResult(_0x4d42b1,null))[_0x4a13('0x29')](handleError(_0x4d42b1,null));};exports[_0x4a13('0x56')]=function(_0x54afef,_0x4f75d4){return db[_0x4a13('0x4d')][_0x4a13('0x53')]({'where':{'id':_0x54afef[_0x4a13('0x57')]['id']}})[_0x4a13('0x33')](handleEntityNotFound(_0x4f75d4,null))[_0x4a13('0x33')](removeEntity(_0x4f75d4,null))[_0x4a13('0x29')](handleError(_0x4f75d4,null));};exports['getFields']=function(_0x25a8b4,_0x2a4a6e,_0x5b76ea){var _0x5e564c={};var _0x17939b={};var _0x492b58;var _0x37c2d6;return db[_0x4a13('0x4d')][_0x4a13('0x58')]({'where':{'id':_0x25a8b4['params']['id']}})[_0x4a13('0x33')](handleEntityNotFound(_0x2a4a6e,null))[_0x4a13('0x33')](function(_0x2504e0){if(_0x2504e0){_0x492b58=_0x2504e0;_0x17939b[_0x4a13('0x3b')]=_['keys'](db['SugarcrmField']['rawAttributes']);_0x17939b[_0x4a13('0x3c')]=_[_0x4a13('0x3d')](_0x25a8b4['query']);_0x17939b[_0x4a13('0x3e')]=_[_0x4a13('0x3f')](_0x17939b['model'],_0x17939b[_0x4a13('0x3c')]);_0x5e564c[_0x4a13('0x40')]=_[_0x4a13('0x3f')](_0x17939b[_0x4a13('0x3b')],qs['fields'](_0x25a8b4[_0x4a13('0x3c')][_0x4a13('0x41')]));_0x5e564c[_0x4a13('0x40')]=_0x5e564c['attributes'][_0x4a13('0x42')]?_0x5e564c[_0x4a13('0x40')]:_0x17939b['model'];_0x5e564c[_0x4a13('0x45')]=qs['sort'](_0x25a8b4[_0x4a13('0x3c')][_0x4a13('0x46')]);_0x5e564c['where']=qs['filters'](_[_0x4a13('0x47')](_0x25a8b4[_0x4a13('0x3c')],_0x17939b[_0x4a13('0x3e')]));if(_0x25a8b4[_0x4a13('0x3c')][_0x4a13('0x4b')]){_0x5e564c[_0x4a13('0x48')]=_[_0x4a13('0x49')](_0x5e564c[_0x4a13('0x48')],{'$or':_[_0x4a13('0x39')](_0x5e564c[_0x4a13('0x40')],function(_0x4cb212){var _0x457140={};_0x457140[_0x4cb212]={'$like':'%'+_0x25a8b4['query']['filter']+'%'};return _0x457140;})});}_0x5e564c=_[_0x4a13('0x49')]({},_0x5e564c,_0x25a8b4[_0x4a13('0x4c')]);return _0x492b58[_0x4a13('0x59')](_0x5e564c);}})['then'](function(_0x510f43){if(_0x510f43){_0x37c2d6=_0x510f43[_0x4a13('0x42')];if(!_0x25a8b4['query'][_0x4a13('0x43')](_0x4a13('0x5a'))){_0x5e564c['limit']=qs['limit'](_0x25a8b4[_0x4a13('0x3c')][_0x4a13('0x44')]);_0x5e564c[_0x4a13('0x2e')]=qs[_0x4a13('0x2e')](_0x25a8b4[_0x4a13('0x3c')][_0x4a13('0x2e')]);}return _0x492b58[_0x4a13('0x59')](_0x5e564c);}})[_0x4a13('0x33')](function(_0x18f2d5){if(_0x18f2d5){return _0x18f2d5?{'count':_0x37c2d6,'rows':_0x18f2d5}:null;}})[_0x4a13('0x33')](respondWithResult(_0x2a4a6e,null))[_0x4a13('0x29')](handleError(_0x2a4a6e,null));};exports[_0x4a13('0x5b')]=function(_0x4e9414,_0x1a1ad9,_0x184cc6){var _0x12d964={};var _0x3e4c57={};var _0x2bfc43;var _0x324f11;return db['SugarcrmConfiguration']['findOne']({'where':{'id':_0x4e9414['params']['id']}})[_0x4a13('0x33')](handleEntityNotFound(_0x1a1ad9,null))[_0x4a13('0x33')](function(_0x15d629){if(_0x15d629){_0x2bfc43=_0x15d629;_0x3e4c57[_0x4a13('0x3b')]=_['keys'](db[_0x4a13('0x5c')][_0x4a13('0x5d')]);_0x3e4c57['query']=_['keys'](_0x4e9414['query']);_0x3e4c57['filters']=_[_0x4a13('0x3f')](_0x3e4c57['model'],_0x3e4c57[_0x4a13('0x3c')]);_0x12d964[_0x4a13('0x40')]=_[_0x4a13('0x3f')](_0x3e4c57[_0x4a13('0x3b')],qs[_0x4a13('0x41')](_0x4e9414[_0x4a13('0x3c')][_0x4a13('0x41')]));_0x12d964['attributes']=_0x12d964[_0x4a13('0x40')][_0x4a13('0x42')]?_0x12d964[_0x4a13('0x40')]:_0x3e4c57[_0x4a13('0x3b')];_0x12d964[_0x4a13('0x45')]=qs['sort'](_0x4e9414[_0x4a13('0x3c')][_0x4a13('0x46')]);_0x12d964[_0x4a13('0x48')]=qs[_0x4a13('0x3e')](_['pick'](_0x4e9414[_0x4a13('0x3c')],_0x3e4c57[_0x4a13('0x3e')]));if(_0x4e9414[_0x4a13('0x3c')][_0x4a13('0x4b')]){_0x12d964[_0x4a13('0x48')]=_[_0x4a13('0x49')](_0x12d964[_0x4a13('0x48')],{'$or':_['map'](_0x12d964[_0x4a13('0x40')],function(_0x3890ef){var _0x3ab1b6={};_0x3ab1b6[_0x3890ef]={'$like':'%'+_0x4e9414[_0x4a13('0x3c')][_0x4a13('0x4b')]+'%'};return _0x3ab1b6;})});}_0x12d964=_[_0x4a13('0x49')]({},_0x12d964,_0x4e9414['options']);return _0x2bfc43[_0x4a13('0x5b')](_0x12d964);}})['then'](function(_0x36335a){if(_0x36335a){_0x324f11=_0x36335a[_0x4a13('0x42')];if(!_0x4e9414[_0x4a13('0x3c')][_0x4a13('0x43')](_0x4a13('0x5a'))){_0x12d964['limit']=qs[_0x4a13('0x44')](_0x4e9414[_0x4a13('0x3c')][_0x4a13('0x44')]);_0x12d964[_0x4a13('0x2e')]=qs[_0x4a13('0x2e')](_0x4e9414[_0x4a13('0x3c')]['offset']);}return _0x2bfc43['getSubjects'](_0x12d964);}})[_0x4a13('0x33')](function(_0xa4c2e8){if(_0xa4c2e8){return _0xa4c2e8?{'count':_0x324f11,'rows':_0xa4c2e8}:null;}})['then'](respondWithResult(_0x1a1ad9,null))[_0x4a13('0x29')](handleError(_0x1a1ad9,null));};exports[_0x4a13('0x5e')]=function(_0x5c768f,_0x372798,_0x1a39ed){var _0x10116f={};var _0x44dd32={};var _0x2fc63d;var _0x338d52;return db['SugarcrmConfiguration'][_0x4a13('0x58')]({'where':{'id':_0x5c768f[_0x4a13('0x57')]['id']}})['then'](handleEntityNotFound(_0x372798,null))[_0x4a13('0x33')](function(_0x409e90){if(_0x409e90){_0x2fc63d=_0x409e90;_0x44dd32[_0x4a13('0x3b')]=_[_0x4a13('0x3d')](db[_0x4a13('0x5c')][_0x4a13('0x5d')]);_0x44dd32['query']=_[_0x4a13('0x3d')](_0x5c768f[_0x4a13('0x3c')]);_0x44dd32['filters']=_[_0x4a13('0x3f')](_0x44dd32[_0x4a13('0x3b')],_0x44dd32['query']);_0x10116f[_0x4a13('0x40')]=_['intersection'](_0x44dd32[_0x4a13('0x3b')],qs[_0x4a13('0x41')](_0x5c768f[_0x4a13('0x3c')][_0x4a13('0x41')]));_0x10116f[_0x4a13('0x40')]=_0x10116f[_0x4a13('0x40')][_0x4a13('0x42')]?_0x10116f[_0x4a13('0x40')]:_0x44dd32[_0x4a13('0x3b')];_0x10116f[_0x4a13('0x45')]=qs['sort'](_0x5c768f[_0x4a13('0x3c')]['sort']);_0x10116f[_0x4a13('0x48')]=qs[_0x4a13('0x3e')](_[_0x4a13('0x47')](_0x5c768f[_0x4a13('0x3c')],_0x44dd32[_0x4a13('0x3e')]));if(_0x5c768f[_0x4a13('0x3c')][_0x4a13('0x4b')]){_0x10116f[_0x4a13('0x48')]=_[_0x4a13('0x49')](_0x10116f[_0x4a13('0x48')],{'$or':_[_0x4a13('0x39')](_0x10116f[_0x4a13('0x40')],function(_0x2bbf4b){var _0x44ead7={};_0x44ead7[_0x2bbf4b]={'$like':'%'+_0x5c768f[_0x4a13('0x3c')]['filter']+'%'};return _0x44ead7;})});}_0x10116f=_[_0x4a13('0x49')]({},_0x10116f,_0x5c768f[_0x4a13('0x4c')]);return _0x2fc63d[_0x4a13('0x5e')](_0x10116f);}})[_0x4a13('0x33')](function(_0x573ee2){if(_0x573ee2){_0x338d52=_0x573ee2['length'];if(!_0x5c768f[_0x4a13('0x3c')][_0x4a13('0x43')](_0x4a13('0x5a'))){_0x10116f['limit']=qs[_0x4a13('0x44')](_0x5c768f['query'][_0x4a13('0x44')]);_0x10116f[_0x4a13('0x2e')]=qs['offset'](_0x5c768f[_0x4a13('0x3c')][_0x4a13('0x2e')]);}return _0x2fc63d[_0x4a13('0x5e')](_0x10116f);}})['then'](function(_0x3b7027){if(_0x3b7027){return _0x3b7027?{'count':_0x338d52,'rows':_0x3b7027}:null;}})['then'](respondWithResult(_0x372798,null))[_0x4a13('0x29')](handleError(_0x372798,null));};
\ No newline at end of file
+var _0xc776=['fs-extra','lodash','squel','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../config/logger','api','../../config/environment','../../config/license/util','sendStatus','status','json','offset','undefined','limit','count','apply','reject','save','update','then','end','stack','name','send','index','map','rawAttributes','fieldName','type','key','model','query','filters','intersection','attributes','length','nolimit','order','sort','where','pick','filter','merge','options','includeAll','include','SugarcrmConfiguration','findAll','rows','catch','show','params','keys','fields','find','create','body','findOne','getFields','hasOwnProperty','SugarcrmField','getSubjects','getDescriptions','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','mustache','util','path','sox','to-csv'];(function(_0xe8717e,_0x3e4490){var _0x35fe19=function(_0x586c18){while(--_0x586c18){_0xe8717e['push'](_0xe8717e['shift']());}};_0x35fe19(++_0x3e4490);}(_0xc776,0x18a));var _0x6c77=function(_0x3fd60a,_0x217502){_0x3fd60a=_0x3fd60a-0x0;var _0x2aa415=_0xc776[_0x3fd60a];return _0x2aa415;};'use strict';var emlformat=require(_0x6c77('0x0'));var rimraf=require(_0x6c77('0x1'));var zipdir=require(_0x6c77('0x2'));var jsonpatch=require(_0x6c77('0x3'));var rp=require(_0x6c77('0x4'));var moment=require(_0x6c77('0x5'));var BPromise=require('bluebird');var Mustache=require(_0x6c77('0x6'));var util=require(_0x6c77('0x7'));var path=require(_0x6c77('0x8'));var sox=require(_0x6c77('0x9'));var csv=require(_0x6c77('0xa'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0x6c77('0xb'));var _=require(_0x6c77('0xc'));var squel=require(_0x6c77('0xd'));var crypto=require(_0x6c77('0xe'));var jsforce=require(_0x6c77('0xf'));var deskjs=require(_0x6c77('0x10'));var toCsv=require(_0x6c77('0xa'));var querystring=require(_0x6c77('0x11'));var Papa=require(_0x6c77('0x12'));var Redis=require(_0x6c77('0x13'));var authService=require(_0x6c77('0x14'));var qs=require(_0x6c77('0x15'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require('../../config/license/hardware');var logger=require(_0x6c77('0x16'))(_0x6c77('0x17'));var utils=require('../../config/utils');var config=require(_0x6c77('0x18'));var licenseUtil=require(_0x6c77('0x19'));var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x43bf53,_0x3fc944){_0x3fc944=_0x3fc944||0xcc;return function(_0xc9b555){if(_0xc9b555){return _0x43bf53[_0x6c77('0x1a')](_0x3fc944);}return _0x43bf53[_0x6c77('0x1b')](_0x3fc944)['end']();};}function respondWithResult(_0x45c16c,_0x3a9034){_0x3a9034=_0x3a9034||0xc8;return function(_0x5eee2a){if(_0x5eee2a){return _0x45c16c[_0x6c77('0x1b')](_0x3a9034)[_0x6c77('0x1c')](_0x5eee2a);}};}function respondWithFilteredResult(_0x3952c4,_0x26dd41){return function(_0x737a87){if(_0x737a87){var _0x44ba2b=typeof _0x26dd41[_0x6c77('0x1d')]===_0x6c77('0x1e')&&typeof _0x26dd41[_0x6c77('0x1f')]==='undefined';var _0x4fbaad=_0x737a87[_0x6c77('0x20')];var _0xc64982=_0x44ba2b?0x0:_0x26dd41[_0x6c77('0x1d')];var _0x43f4ec=_0x44ba2b?_0x737a87['count']:_0x26dd41[_0x6c77('0x1d')]+_0x26dd41[_0x6c77('0x1f')];var _0x1df74a;if(_0x43f4ec>=_0x4fbaad){_0x43f4ec=_0x4fbaad;_0x1df74a=0xc8;}else{_0x1df74a=0xce;}_0x3952c4['status'](_0x1df74a);return _0x3952c4['set']('Content-Range',_0xc64982+'-'+_0x43f4ec+'/'+_0x4fbaad)[_0x6c77('0x1c')](_0x737a87);}return null;};}function patchUpdates(_0x530ec6){return function(_0x40efa0){try{jsonpatch[_0x6c77('0x21')](_0x40efa0,_0x530ec6,!![]);}catch(_0x562b58){return BPromise[_0x6c77('0x22')](_0x562b58);}return _0x40efa0[_0x6c77('0x23')]();};}function saveUpdates(_0x358099,_0x1ba542){return function(_0x5d0de0){if(_0x5d0de0){return _0x5d0de0[_0x6c77('0x24')](_0x358099)[_0x6c77('0x25')](function(_0x1846b5){return _0x1846b5;});}return null;};}function removeEntity(_0x4e4ca4,_0x325dc1){return function(_0x33e99c){if(_0x33e99c){return _0x33e99c['destroy']()[_0x6c77('0x25')](function(){_0x4e4ca4['status'](0xcc)[_0x6c77('0x26')]();});}};}function handleEntityNotFound(_0x24566c,_0x4fd58d){return function(_0x1a412f){if(!_0x1a412f){_0x24566c[_0x6c77('0x1a')](0x194);}return _0x1a412f;};}function handleError(_0x55655f,_0x403891){_0x403891=_0x403891||0x1f4;return function(_0x509bb4){logger['error'](_0x509bb4[_0x6c77('0x27')]);if(_0x509bb4[_0x6c77('0x28')]){delete _0x509bb4[_0x6c77('0x28')];}_0x55655f[_0x6c77('0x1b')](_0x403891)[_0x6c77('0x29')](_0x509bb4);};}exports[_0x6c77('0x2a')]=function(_0x2ccb6a,_0x1c6cc6){var _0x17d88a={},_0x3d0567={},_0x166ec6={'count':0x0,'rows':[]};var _0x133a84=_[_0x6c77('0x2b')](db['SugarcrmConfiguration'][_0x6c77('0x2c')],function(_0x1118ae){return{'name':_0x1118ae[_0x6c77('0x2d')],'type':_0x1118ae[_0x6c77('0x2e')][_0x6c77('0x2f')]};});_0x3d0567[_0x6c77('0x30')]=_[_0x6c77('0x2b')](_0x133a84,_0x6c77('0x28'));_0x3d0567[_0x6c77('0x31')]=_['keys'](_0x2ccb6a[_0x6c77('0x31')]);_0x3d0567[_0x6c77('0x32')]=_[_0x6c77('0x33')](_0x3d0567[_0x6c77('0x30')],_0x3d0567[_0x6c77('0x31')]);_0x17d88a[_0x6c77('0x34')]=_[_0x6c77('0x33')](_0x3d0567[_0x6c77('0x30')],qs['fields'](_0x2ccb6a[_0x6c77('0x31')]['fields']));_0x17d88a[_0x6c77('0x34')]=_0x17d88a[_0x6c77('0x34')][_0x6c77('0x35')]?_0x17d88a[_0x6c77('0x34')]:_0x3d0567[_0x6c77('0x30')];if(!_0x2ccb6a['query']['hasOwnProperty'](_0x6c77('0x36'))){_0x17d88a['limit']=qs[_0x6c77('0x1f')](_0x2ccb6a[_0x6c77('0x31')][_0x6c77('0x1f')]);_0x17d88a[_0x6c77('0x1d')]=qs[_0x6c77('0x1d')](_0x2ccb6a[_0x6c77('0x31')][_0x6c77('0x1d')]);}_0x17d88a[_0x6c77('0x37')]=qs[_0x6c77('0x38')](_0x2ccb6a[_0x6c77('0x31')][_0x6c77('0x38')]);_0x17d88a[_0x6c77('0x39')]=qs[_0x6c77('0x32')](_[_0x6c77('0x3a')](_0x2ccb6a[_0x6c77('0x31')],_0x3d0567['filters']),_0x133a84);if(_0x2ccb6a[_0x6c77('0x31')][_0x6c77('0x3b')]){_0x17d88a[_0x6c77('0x39')]=_['merge'](_0x17d88a[_0x6c77('0x39')],{'$or':_['map'](_0x133a84,function(_0x221266){if(_0x221266[_0x6c77('0x2e')]!=='VIRTUAL'){var _0x3c048d={};_0x3c048d[_0x221266[_0x6c77('0x28')]]={'$like':'%'+_0x2ccb6a['query'][_0x6c77('0x3b')]+'%'};return _0x3c048d;}})});}_0x17d88a=_[_0x6c77('0x3c')]({},_0x17d88a,_0x2ccb6a[_0x6c77('0x3d')]);var _0x23af76={'where':_0x17d88a['where']};return db['SugarcrmConfiguration'][_0x6c77('0x20')](_0x23af76)[_0x6c77('0x25')](function(_0x512612){_0x166ec6[_0x6c77('0x20')]=_0x512612;if(_0x2ccb6a['query'][_0x6c77('0x3e')]){_0x17d88a[_0x6c77('0x3f')]=[{'all':!![]}];}return db[_0x6c77('0x40')][_0x6c77('0x41')](_0x17d88a);})['then'](function(_0x439767){_0x166ec6[_0x6c77('0x42')]=_0x439767;return _0x166ec6;})[_0x6c77('0x25')](respondWithFilteredResult(_0x1c6cc6,_0x17d88a))[_0x6c77('0x43')](handleError(_0x1c6cc6,null));};exports[_0x6c77('0x44')]=function(_0x5f39c2,_0x218e00){var _0x29609c={'raw':![],'where':{'id':_0x5f39c2[_0x6c77('0x45')]['id']}},_0x248c48={};_0x248c48[_0x6c77('0x30')]=_['keys'](db[_0x6c77('0x40')][_0x6c77('0x2c')]);_0x248c48[_0x6c77('0x31')]=_[_0x6c77('0x46')](_0x5f39c2[_0x6c77('0x31')]);_0x248c48[_0x6c77('0x32')]=_[_0x6c77('0x33')](_0x248c48[_0x6c77('0x30')],_0x248c48[_0x6c77('0x31')]);_0x29609c['attributes']=_[_0x6c77('0x33')](_0x248c48[_0x6c77('0x30')],qs['fields'](_0x5f39c2[_0x6c77('0x31')][_0x6c77('0x47')]));_0x29609c[_0x6c77('0x34')]=_0x29609c[_0x6c77('0x34')][_0x6c77('0x35')]?_0x29609c[_0x6c77('0x34')]:_0x248c48[_0x6c77('0x30')];if(_0x5f39c2[_0x6c77('0x31')]['includeAll']){_0x29609c[_0x6c77('0x3f')]=[{'all':!![]}];}_0x29609c=_[_0x6c77('0x3c')]({},_0x29609c,_0x5f39c2[_0x6c77('0x3d')]);return db['SugarcrmConfiguration'][_0x6c77('0x48')](_0x29609c)[_0x6c77('0x25')](handleEntityNotFound(_0x218e00,null))[_0x6c77('0x25')](respondWithResult(_0x218e00,null))['catch'](handleError(_0x218e00,null));};exports[_0x6c77('0x49')]=function(_0x717fa4,_0x709dbb){return db[_0x6c77('0x40')][_0x6c77('0x49')](_0x717fa4[_0x6c77('0x4a')],{})[_0x6c77('0x25')](respondWithResult(_0x709dbb,0xc9))[_0x6c77('0x43')](handleError(_0x709dbb,null));};exports[_0x6c77('0x24')]=function(_0x625a9f,_0x49bf05){if(_0x625a9f[_0x6c77('0x4a')]['id']){delete _0x625a9f[_0x6c77('0x4a')]['id'];}return db['SugarcrmConfiguration'][_0x6c77('0x48')]({'where':{'id':_0x625a9f[_0x6c77('0x45')]['id']}})[_0x6c77('0x25')](handleEntityNotFound(_0x49bf05,null))['then'](saveUpdates(_0x625a9f['body'],null))[_0x6c77('0x25')](respondWithResult(_0x49bf05,null))[_0x6c77('0x43')](handleError(_0x49bf05,null));};exports['destroy']=function(_0x4c1f25,_0x570964){return db[_0x6c77('0x40')]['find']({'where':{'id':_0x4c1f25['params']['id']}})[_0x6c77('0x25')](handleEntityNotFound(_0x570964,null))[_0x6c77('0x25')](removeEntity(_0x570964,null))[_0x6c77('0x43')](handleError(_0x570964,null));};exports['getFields']=function(_0x134ff9,_0x5ae7d9,_0x3477b9){var _0x316b5c={};var _0x299bcf={};var _0x4fbd6f;var _0x45116a;return db['SugarcrmConfiguration'][_0x6c77('0x4b')]({'where':{'id':_0x134ff9['params']['id']}})[_0x6c77('0x25')](handleEntityNotFound(_0x5ae7d9,null))['then'](function(_0x189f82){if(_0x189f82){_0x4fbd6f=_0x189f82;_0x299bcf[_0x6c77('0x30')]=_[_0x6c77('0x46')](db['SugarcrmField'][_0x6c77('0x2c')]);_0x299bcf['query']=_['keys'](_0x134ff9[_0x6c77('0x31')]);_0x299bcf[_0x6c77('0x32')]=_[_0x6c77('0x33')](_0x299bcf[_0x6c77('0x30')],_0x299bcf['query']);_0x316b5c[_0x6c77('0x34')]=_[_0x6c77('0x33')](_0x299bcf[_0x6c77('0x30')],qs[_0x6c77('0x47')](_0x134ff9['query'][_0x6c77('0x47')]));_0x316b5c['attributes']=_0x316b5c[_0x6c77('0x34')][_0x6c77('0x35')]?_0x316b5c[_0x6c77('0x34')]:_0x299bcf['model'];_0x316b5c[_0x6c77('0x37')]=qs['sort'](_0x134ff9[_0x6c77('0x31')][_0x6c77('0x38')]);_0x316b5c[_0x6c77('0x39')]=qs['filters'](_[_0x6c77('0x3a')](_0x134ff9['query'],_0x299bcf[_0x6c77('0x32')]));if(_0x134ff9['query']['filter']){_0x316b5c[_0x6c77('0x39')]=_[_0x6c77('0x3c')](_0x316b5c[_0x6c77('0x39')],{'$or':_[_0x6c77('0x2b')](_0x316b5c[_0x6c77('0x34')],function(_0x53105b){var _0x1bf3f3={};_0x1bf3f3[_0x53105b]={'$like':'%'+_0x134ff9[_0x6c77('0x31')][_0x6c77('0x3b')]+'%'};return _0x1bf3f3;})});}_0x316b5c=_['merge']({},_0x316b5c,_0x134ff9['options']);return _0x4fbd6f[_0x6c77('0x4c')](_0x316b5c);}})[_0x6c77('0x25')](function(_0x4f7b3e){if(_0x4f7b3e){_0x45116a=_0x4f7b3e[_0x6c77('0x35')];if(!_0x134ff9[_0x6c77('0x31')][_0x6c77('0x4d')](_0x6c77('0x36'))){_0x316b5c[_0x6c77('0x1f')]=qs[_0x6c77('0x1f')](_0x134ff9['query'][_0x6c77('0x1f')]);_0x316b5c[_0x6c77('0x1d')]=qs[_0x6c77('0x1d')](_0x134ff9['query'][_0x6c77('0x1d')]);}return _0x4fbd6f[_0x6c77('0x4c')](_0x316b5c);}})[_0x6c77('0x25')](function(_0x52ced0){if(_0x52ced0){return _0x52ced0?{'count':_0x45116a,'rows':_0x52ced0}:null;}})[_0x6c77('0x25')](respondWithResult(_0x5ae7d9,null))[_0x6c77('0x43')](handleError(_0x5ae7d9,null));};exports['getSubjects']=function(_0x41cb8a,_0xb2f3ed,_0xd7feb){var _0x45ed05={};var _0x2fe1ff={};var _0xf10ffe;var _0x411e9e;return db[_0x6c77('0x40')]['findOne']({'where':{'id':_0x41cb8a[_0x6c77('0x45')]['id']}})[_0x6c77('0x25')](handleEntityNotFound(_0xb2f3ed,null))[_0x6c77('0x25')](function(_0x13630f){if(_0x13630f){_0xf10ffe=_0x13630f;_0x2fe1ff[_0x6c77('0x30')]=_[_0x6c77('0x46')](db[_0x6c77('0x4e')]['rawAttributes']);_0x2fe1ff[_0x6c77('0x31')]=_[_0x6c77('0x46')](_0x41cb8a[_0x6c77('0x31')]);_0x2fe1ff['filters']=_['intersection'](_0x2fe1ff[_0x6c77('0x30')],_0x2fe1ff[_0x6c77('0x31')]);_0x45ed05['attributes']=_['intersection'](_0x2fe1ff[_0x6c77('0x30')],qs[_0x6c77('0x47')](_0x41cb8a[_0x6c77('0x31')][_0x6c77('0x47')]));_0x45ed05[_0x6c77('0x34')]=_0x45ed05[_0x6c77('0x34')][_0x6c77('0x35')]?_0x45ed05[_0x6c77('0x34')]:_0x2fe1ff[_0x6c77('0x30')];_0x45ed05['order']=qs[_0x6c77('0x38')](_0x41cb8a[_0x6c77('0x31')][_0x6c77('0x38')]);_0x45ed05['where']=qs[_0x6c77('0x32')](_['pick'](_0x41cb8a['query'],_0x2fe1ff[_0x6c77('0x32')]));if(_0x41cb8a[_0x6c77('0x31')][_0x6c77('0x3b')]){_0x45ed05[_0x6c77('0x39')]=_['merge'](_0x45ed05['where'],{'$or':_[_0x6c77('0x2b')](_0x45ed05[_0x6c77('0x34')],function(_0x2c2de4){var _0x42c7a1={};_0x42c7a1[_0x2c2de4]={'$like':'%'+_0x41cb8a[_0x6c77('0x31')][_0x6c77('0x3b')]+'%'};return _0x42c7a1;})});}_0x45ed05=_[_0x6c77('0x3c')]({},_0x45ed05,_0x41cb8a[_0x6c77('0x3d')]);return _0xf10ffe[_0x6c77('0x4f')](_0x45ed05);}})['then'](function(_0x3b8a3b){if(_0x3b8a3b){_0x411e9e=_0x3b8a3b[_0x6c77('0x35')];if(!_0x41cb8a[_0x6c77('0x31')][_0x6c77('0x4d')](_0x6c77('0x36'))){_0x45ed05['limit']=qs[_0x6c77('0x1f')](_0x41cb8a[_0x6c77('0x31')]['limit']);_0x45ed05[_0x6c77('0x1d')]=qs[_0x6c77('0x1d')](_0x41cb8a[_0x6c77('0x31')][_0x6c77('0x1d')]);}return _0xf10ffe[_0x6c77('0x4f')](_0x45ed05);}})[_0x6c77('0x25')](function(_0x20fc0b){if(_0x20fc0b){return _0x20fc0b?{'count':_0x411e9e,'rows':_0x20fc0b}:null;}})[_0x6c77('0x25')](respondWithResult(_0xb2f3ed,null))[_0x6c77('0x43')](handleError(_0xb2f3ed,null));};exports[_0x6c77('0x50')]=function(_0x2970de,_0x2a5f0d,_0x4e7c0d){var _0x2a07df={};var _0x1b0cff={};var _0x438c10;var _0x360577;return db['SugarcrmConfiguration']['findOne']({'where':{'id':_0x2970de[_0x6c77('0x45')]['id']}})[_0x6c77('0x25')](handleEntityNotFound(_0x2a5f0d,null))['then'](function(_0xc6debb){if(_0xc6debb){_0x438c10=_0xc6debb;_0x1b0cff[_0x6c77('0x30')]=_[_0x6c77('0x46')](db['SugarcrmField'][_0x6c77('0x2c')]);_0x1b0cff[_0x6c77('0x31')]=_[_0x6c77('0x46')](_0x2970de[_0x6c77('0x31')]);_0x1b0cff['filters']=_['intersection'](_0x1b0cff['model'],_0x1b0cff[_0x6c77('0x31')]);_0x2a07df[_0x6c77('0x34')]=_[_0x6c77('0x33')](_0x1b0cff[_0x6c77('0x30')],qs[_0x6c77('0x47')](_0x2970de[_0x6c77('0x31')]['fields']));_0x2a07df['attributes']=_0x2a07df[_0x6c77('0x34')][_0x6c77('0x35')]?_0x2a07df[_0x6c77('0x34')]:_0x1b0cff[_0x6c77('0x30')];_0x2a07df['order']=qs[_0x6c77('0x38')](_0x2970de['query'][_0x6c77('0x38')]);_0x2a07df[_0x6c77('0x39')]=qs['filters'](_[_0x6c77('0x3a')](_0x2970de[_0x6c77('0x31')],_0x1b0cff[_0x6c77('0x32')]));if(_0x2970de['query'][_0x6c77('0x3b')]){_0x2a07df['where']=_[_0x6c77('0x3c')](_0x2a07df[_0x6c77('0x39')],{'$or':_['map'](_0x2a07df[_0x6c77('0x34')],function(_0x1f5856){var _0x76c9f={};_0x76c9f[_0x1f5856]={'$like':'%'+_0x2970de[_0x6c77('0x31')][_0x6c77('0x3b')]+'%'};return _0x76c9f;})});}_0x2a07df=_['merge']({},_0x2a07df,_0x2970de[_0x6c77('0x3d')]);return _0x438c10[_0x6c77('0x50')](_0x2a07df);}})[_0x6c77('0x25')](function(_0x57cf1d){if(_0x57cf1d){_0x360577=_0x57cf1d['length'];if(!_0x2970de[_0x6c77('0x31')][_0x6c77('0x4d')](_0x6c77('0x36'))){_0x2a07df[_0x6c77('0x1f')]=qs[_0x6c77('0x1f')](_0x2970de[_0x6c77('0x31')][_0x6c77('0x1f')]);_0x2a07df['offset']=qs[_0x6c77('0x1d')](_0x2970de[_0x6c77('0x31')][_0x6c77('0x1d')]);}return _0x438c10[_0x6c77('0x50')](_0x2a07df);}})['then'](function(_0x58817d){if(_0x58817d){return _0x58817d?{'count':_0x360577,'rows':_0x58817d}:null;}})[_0x6c77('0x25')](respondWithResult(_0x2a5f0d,null))['catch'](handleError(_0x2a5f0d,null));};
\ No newline at end of file