Built motion from commit (unavailable).|2.5.23
[motion2.git] / server / api / intSugarcrmConfiguration / intSugarcrmConfiguration.controller.js
index a88a368..5bb9e04 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x89be=['index','map','rawAttributes','fieldName','type','key','model','query','filters','intersection','attributes','fields','length','hasOwnProperty','order','sort','where','merge','VIRTUAL','filter','SugarcrmConfiguration','count','include','findAll','rows','catch','show','params','keys','includeAll','options','create','body','find','getFields','pick','nolimit','getSubjects','findOne','SugarcrmField','html-pdf','eml-format','fast-json-patch','request-promise','path','ejs','lodash','crypto','jsforce','desk.js','to-csv','papaparse','../../components/auth/service','../../components/parsers/advancedSearch','../../config/license/hardware','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','jayson/promise','client','http','request','info','SugarcrmConfiguration,\x20%s,\x20%s','debug','error','code','message','request\x20sent','result','sendStatus','status','end','offset','limit','Content-Range','apply','save','update','then','destroy','stack','name','send'];(function(_0x2b2b33,_0x56606f){var _0x229157=function(_0x52b63e){while(--_0x52b63e){_0x2b2b33['push'](_0x2b2b33['shift']());}};_0x229157(++_0x56606f);}(_0x89be,0x180));var _0xe89b=function(_0x321bb2,_0x202794){_0x321bb2=_0x321bb2-0x0;var _0x9c12ed=_0x89be[_0x321bb2];return _0x9c12ed;};'use strict';var pdf=require(_0xe89b('0x0'));var emlformat=require(_0xe89b('0x1'));var rimraf=require('rimraf');var zipdir=require('zip-dir');var jsonpatch=require(_0xe89b('0x2'));var rp=require(_0xe89b('0x3'));var moment=require('moment');var BPromise=require('bluebird');var Mustache=require('mustache');var util=require('util');var path=require(_0xe89b('0x4'));var sox=require('sox');var csv=require('to-csv');var ejs=require(_0xe89b('0x5'));var fs=require('fs');var _=require(_0xe89b('0x6'));var squel=require('squel');var crypto=require(_0xe89b('0x7'));var jsforce=require(_0xe89b('0x8'));var deskjs=require(_0xe89b('0x9'));var toCsv=require(_0xe89b('0xa'));var querystring=require('querystring');var Papa=require(_0xe89b('0xb'));var Redis=require('ioredis');var authService=require(_0xe89b('0xc'));var qs=require('../../components/parsers/qs');var as=require(_0xe89b('0xd'));var hardwareService=require(_0xe89b('0xe'));var logger=require('../../config/logger')(_0xe89b('0xf'));var utils=require(_0xe89b('0x10'));var config=require(_0xe89b('0x11'));var licenseUtil=require(_0xe89b('0x12'));var db=require(_0xe89b('0x13'))['db'];var jayson=require(_0xe89b('0x14'));var client=jayson[_0xe89b('0x15')][_0xe89b('0x16')]({'port':0x232a});function respondWithRpcPromise(_0x5db334,_0x124fcc,_0x494ee3,_0x5f06b9){return new BPromise(function(_0x521132,_0x19123a){var _0x16da97=_0x5f06b9||client;return _0x16da97[_0xe89b('0x17')](_0x5db334,_0x494ee3)['then'](function(_0x8fa2e8){logger[_0xe89b('0x18')](_0xe89b('0x19'),_0x124fcc,'request\x20sent');logger[_0xe89b('0x1a')]('SugarcrmConfiguration,\x20%s,\x20%s,\x20%s',_0x124fcc,'request\x20sent',JSON['stringify'](_0x8fa2e8));if(_0x8fa2e8[_0xe89b('0x1b')]){if(_0x8fa2e8[_0xe89b('0x1b')][_0xe89b('0x1c')]===0x1f4){logger['error'](_0xe89b('0x19'),_0x124fcc,_0x8fa2e8[_0xe89b('0x1b')][_0xe89b('0x1d')]);return _0x19123a(_0x8fa2e8[_0xe89b('0x1b')][_0xe89b('0x1d')]);}logger[_0xe89b('0x1b')](_0xe89b('0x19'),_0x124fcc,_0x8fa2e8[_0xe89b('0x1b')][_0xe89b('0x1d')]);return _0x521132(_0x8fa2e8[_0xe89b('0x1b')][_0xe89b('0x1d')]);}else{logger[_0xe89b('0x18')](_0xe89b('0x19'),_0x124fcc,_0xe89b('0x1e'));_0x521132(_0x8fa2e8[_0xe89b('0x1f')][_0xe89b('0x1d')]);}})['catch'](function(_0x1d460b){logger[_0xe89b('0x1b')]('SugarcrmConfiguration,\x20%s,\x20%s',_0x124fcc,_0x1d460b);_0x19123a(_0x1d460b);});});}function respondWithStatusCode(_0x79c018,_0x7eec5b){_0x7eec5b=_0x7eec5b||0xcc;return function(_0x2d32fa){if(_0x2d32fa){return _0x79c018[_0xe89b('0x20')](_0x7eec5b);}return _0x79c018[_0xe89b('0x21')](_0x7eec5b)[_0xe89b('0x22')]();};}function respondWithResult(_0x4755bf,_0xa527cb){_0xa527cb=_0xa527cb||0xc8;return function(_0x47e99f){if(_0x47e99f){return _0x4755bf[_0xe89b('0x21')](_0xa527cb)['json'](_0x47e99f);}};}function respondWithFilteredResult(_0x3834bc,_0x162902){return function(_0x2a7e69){if(_0x2a7e69){var _0x38b4c2=_0x2a7e69['count'],_0x4e45d1=_0x162902['offset'],_0x136f57=_0x162902[_0xe89b('0x23')]+_0x162902[_0xe89b('0x24')],_0x280308;if(_0x136f57>=_0x38b4c2){_0x136f57=_0x38b4c2;_0x280308=0xc8;}else{_0x280308=0xce;}_0x3834bc[_0xe89b('0x21')](_0x280308);return _0x3834bc['set'](_0xe89b('0x25'),_0x4e45d1+'-'+_0x136f57+'/'+_0x38b4c2)['json'](_0x2a7e69);}return null;};}function patchUpdates(_0x5e2f65){return function(_0x52f725){try{jsonpatch[_0xe89b('0x26')](_0x52f725,_0x5e2f65,!![]);}catch(_0x13aa53){return BPromise['reject'](_0x13aa53);}return _0x52f725[_0xe89b('0x27')]();};}function saveUpdates(_0xad98c2,_0x4890ae){return function(_0x2d73a1){if(_0x2d73a1){return _0x2d73a1[_0xe89b('0x28')](_0xad98c2)[_0xe89b('0x29')](function(_0x16191f){return _0x16191f;});}return null;};}function removeEntity(_0x3d01c6,_0x54c0e6){return function(_0x35f18a){if(_0x35f18a){return _0x35f18a[_0xe89b('0x2a')]()[_0xe89b('0x29')](function(){_0x3d01c6[_0xe89b('0x21')](0xcc)[_0xe89b('0x22')]();});}};}function handleEntityNotFound(_0x45ef4f,_0x499fb3){return function(_0x4f2680){if(!_0x4f2680){_0x45ef4f[_0xe89b('0x20')](0x194);}return _0x4f2680;};}function handleError(_0x59861a,_0x571985){_0x571985=_0x571985||0x1f4;return function(_0x3ad173){logger['error'](_0x3ad173[_0xe89b('0x2b')]);if(_0x3ad173[_0xe89b('0x2c')]){delete _0x3ad173[_0xe89b('0x2c')];}_0x59861a['status'](_0x571985)[_0xe89b('0x2d')](_0x3ad173);};}exports[_0xe89b('0x2e')]=function(_0x2458a2,_0x430e41){var _0x5f5754={},_0x557128={},_0x3ef9f7={'count':0x0,'rows':[]};var _0x1cf832=_[_0xe89b('0x2f')](db['SugarcrmConfiguration'][_0xe89b('0x30')],function(_0x3a4332){return{'name':_0x3a4332[_0xe89b('0x31')],'type':_0x3a4332[_0xe89b('0x32')][_0xe89b('0x33')]};});_0x557128[_0xe89b('0x34')]=_[_0xe89b('0x2f')](_0x1cf832,_0xe89b('0x2c'));_0x557128[_0xe89b('0x35')]=_['keys'](_0x2458a2[_0xe89b('0x35')]);_0x557128[_0xe89b('0x36')]=_[_0xe89b('0x37')](_0x557128[_0xe89b('0x34')],_0x557128[_0xe89b('0x35')]);_0x5f5754[_0xe89b('0x38')]=_[_0xe89b('0x37')](_0x557128[_0xe89b('0x34')],qs[_0xe89b('0x39')](_0x2458a2[_0xe89b('0x35')][_0xe89b('0x39')]));_0x5f5754[_0xe89b('0x38')]=_0x5f5754[_0xe89b('0x38')][_0xe89b('0x3a')]?_0x5f5754['attributes']:_0x557128[_0xe89b('0x34')];if(!_0x2458a2['query'][_0xe89b('0x3b')]('nolimit')){_0x5f5754[_0xe89b('0x24')]=qs[_0xe89b('0x24')](_0x2458a2[_0xe89b('0x35')][_0xe89b('0x24')]);_0x5f5754[_0xe89b('0x23')]=qs[_0xe89b('0x23')](_0x2458a2[_0xe89b('0x35')][_0xe89b('0x23')]);}_0x5f5754[_0xe89b('0x3c')]=qs[_0xe89b('0x3d')](_0x2458a2[_0xe89b('0x35')][_0xe89b('0x3d')]);_0x5f5754['where']=qs[_0xe89b('0x36')](_['pick'](_0x2458a2[_0xe89b('0x35')],_0x557128[_0xe89b('0x36')]),_0x1cf832);if(_0x2458a2[_0xe89b('0x35')]['filter']){_0x5f5754[_0xe89b('0x3e')]=_[_0xe89b('0x3f')](_0x5f5754['where'],{'$or':_[_0xe89b('0x2f')](_0x1cf832,function(_0x503054){if(_0x503054[_0xe89b('0x32')]!==_0xe89b('0x40')){var _0x55e336={};_0x55e336[_0x503054[_0xe89b('0x2c')]]={'$like':'%'+_0x2458a2[_0xe89b('0x35')][_0xe89b('0x41')]+'%'};return _0x55e336;}})});}_0x5f5754=_[_0xe89b('0x3f')]({},_0x5f5754,_0x2458a2['options']);var _0x5c7e12={'where':_0x5f5754[_0xe89b('0x3e')]};return db[_0xe89b('0x42')][_0xe89b('0x43')](_0x5c7e12)[_0xe89b('0x29')](function(_0x475820){_0x3ef9f7[_0xe89b('0x43')]=_0x475820;if(_0x2458a2['query']['includeAll']){_0x5f5754[_0xe89b('0x44')]=[{'all':!![]}];}return db[_0xe89b('0x42')][_0xe89b('0x45')](_0x5f5754);})[_0xe89b('0x29')](function(_0x56b231){_0x3ef9f7[_0xe89b('0x46')]=_0x56b231;return _0x3ef9f7;})[_0xe89b('0x29')](respondWithFilteredResult(_0x430e41,_0x5f5754))[_0xe89b('0x47')](handleError(_0x430e41,null));};exports[_0xe89b('0x48')]=function(_0x32256d,_0x1b0258){var _0x50a45a={'raw':![],'where':{'id':_0x32256d[_0xe89b('0x49')]['id']}},_0x53dc4d={};_0x53dc4d[_0xe89b('0x34')]=_[_0xe89b('0x4a')](db[_0xe89b('0x42')][_0xe89b('0x30')]);_0x53dc4d['query']=_[_0xe89b('0x4a')](_0x32256d[_0xe89b('0x35')]);_0x53dc4d[_0xe89b('0x36')]=_['intersection'](_0x53dc4d[_0xe89b('0x34')],_0x53dc4d['query']);_0x50a45a['attributes']=_['intersection'](_0x53dc4d[_0xe89b('0x34')],qs['fields'](_0x32256d['query']['fields']));_0x50a45a[_0xe89b('0x38')]=_0x50a45a[_0xe89b('0x38')][_0xe89b('0x3a')]?_0x50a45a[_0xe89b('0x38')]:_0x53dc4d['model'];if(_0x32256d[_0xe89b('0x35')][_0xe89b('0x4b')]){_0x50a45a['include']=[{'all':!![]}];}_0x50a45a=_[_0xe89b('0x3f')]({},_0x50a45a,_0x32256d[_0xe89b('0x4c')]);return db[_0xe89b('0x42')]['find'](_0x50a45a)['then'](handleEntityNotFound(_0x1b0258,null))['then'](respondWithResult(_0x1b0258,null))[_0xe89b('0x47')](handleError(_0x1b0258,null));};exports[_0xe89b('0x4d')]=function(_0x59f73c,_0x4a0d65){return db[_0xe89b('0x42')][_0xe89b('0x4d')](_0x59f73c['body'],{})[_0xe89b('0x29')](respondWithResult(_0x4a0d65,0xc9))[_0xe89b('0x47')](handleError(_0x4a0d65,null));};exports[_0xe89b('0x28')]=function(_0x419cfb,_0x1e94f7){if(_0x419cfb[_0xe89b('0x4e')]['id']){delete _0x419cfb[_0xe89b('0x4e')]['id'];}return db[_0xe89b('0x42')][_0xe89b('0x4f')]({'where':{'id':_0x419cfb[_0xe89b('0x49')]['id']}})['then'](handleEntityNotFound(_0x1e94f7,null))[_0xe89b('0x29')](saveUpdates(_0x419cfb[_0xe89b('0x4e')],null))[_0xe89b('0x29')](respondWithResult(_0x1e94f7,null))[_0xe89b('0x47')](handleError(_0x1e94f7,null));};exports[_0xe89b('0x2a')]=function(_0x123f21,_0x344065){return db['SugarcrmConfiguration'][_0xe89b('0x4f')]({'where':{'id':_0x123f21[_0xe89b('0x49')]['id']}})[_0xe89b('0x29')](handleEntityNotFound(_0x344065,null))['then'](removeEntity(_0x344065,null))[_0xe89b('0x47')](handleError(_0x344065,null));};exports[_0xe89b('0x50')]=function(_0x10dd57,_0x16998d,_0x21878e){var _0x4ed83d={};var _0x5d3b13={};var _0x39d949;var _0x5e69ca;return db[_0xe89b('0x42')]['findOne']({'where':{'id':_0x10dd57[_0xe89b('0x49')]['id']}})['then'](handleEntityNotFound(_0x16998d,null))[_0xe89b('0x29')](function(_0x42128a){if(_0x42128a){_0x39d949=_0x42128a;_0x5d3b13[_0xe89b('0x34')]=_[_0xe89b('0x4a')](db['SugarcrmField'][_0xe89b('0x30')]);_0x5d3b13[_0xe89b('0x35')]=_['keys'](_0x10dd57[_0xe89b('0x35')]);_0x5d3b13['filters']=_[_0xe89b('0x37')](_0x5d3b13[_0xe89b('0x34')],_0x5d3b13['query']);_0x4ed83d[_0xe89b('0x38')]=_[_0xe89b('0x37')](_0x5d3b13['model'],qs['fields'](_0x10dd57['query'][_0xe89b('0x39')]));_0x4ed83d['attributes']=_0x4ed83d[_0xe89b('0x38')][_0xe89b('0x3a')]?_0x4ed83d[_0xe89b('0x38')]:_0x5d3b13[_0xe89b('0x34')];_0x4ed83d[_0xe89b('0x3c')]=qs[_0xe89b('0x3d')](_0x10dd57[_0xe89b('0x35')][_0xe89b('0x3d')]);_0x4ed83d[_0xe89b('0x3e')]=qs['filters'](_[_0xe89b('0x51')](_0x10dd57[_0xe89b('0x35')],_0x5d3b13[_0xe89b('0x36')]));if(_0x10dd57['query']['filter']){_0x4ed83d['where']=_[_0xe89b('0x3f')](_0x4ed83d[_0xe89b('0x3e')],{'$or':_['map'](_0x4ed83d[_0xe89b('0x38')],function(_0x1fdc43){var _0x1464a7={};_0x1464a7[_0x1fdc43]={'$like':'%'+_0x10dd57[_0xe89b('0x35')][_0xe89b('0x41')]+'%'};return _0x1464a7;})});}_0x4ed83d=_['merge']({},_0x4ed83d,_0x10dd57[_0xe89b('0x4c')]);return _0x39d949[_0xe89b('0x50')](_0x4ed83d);}})[_0xe89b('0x29')](function(_0x311ef7){if(_0x311ef7){_0x5e69ca=_0x311ef7['length'];if(!_0x10dd57['query'][_0xe89b('0x3b')](_0xe89b('0x52'))){_0x4ed83d[_0xe89b('0x24')]=qs[_0xe89b('0x24')](_0x10dd57[_0xe89b('0x35')][_0xe89b('0x24')]);_0x4ed83d[_0xe89b('0x23')]=qs['offset'](_0x10dd57[_0xe89b('0x35')]['offset']);}return _0x39d949[_0xe89b('0x50')](_0x4ed83d);}})[_0xe89b('0x29')](function(_0xf2c500){if(_0xf2c500){return _0xf2c500?{'count':_0x5e69ca,'rows':_0xf2c500}:null;}})[_0xe89b('0x29')](respondWithResult(_0x16998d,null))['catch'](handleError(_0x16998d,null));};exports[_0xe89b('0x53')]=function(_0x31363a,_0x2e26b8,_0x16c8d5){var _0x2c63ad={};var _0x323da7={};var _0x13c85e;var _0x4844ad;return db[_0xe89b('0x42')][_0xe89b('0x54')]({'where':{'id':_0x31363a['params']['id']}})[_0xe89b('0x29')](handleEntityNotFound(_0x2e26b8,null))[_0xe89b('0x29')](function(_0x479782){if(_0x479782){_0x13c85e=_0x479782;_0x323da7[_0xe89b('0x34')]=_[_0xe89b('0x4a')](db[_0xe89b('0x55')][_0xe89b('0x30')]);_0x323da7['query']=_['keys'](_0x31363a[_0xe89b('0x35')]);_0x323da7[_0xe89b('0x36')]=_[_0xe89b('0x37')](_0x323da7['model'],_0x323da7[_0xe89b('0x35')]);_0x2c63ad[_0xe89b('0x38')]=_['intersection'](_0x323da7['model'],qs[_0xe89b('0x39')](_0x31363a[_0xe89b('0x35')][_0xe89b('0x39')]));_0x2c63ad['attributes']=_0x2c63ad[_0xe89b('0x38')][_0xe89b('0x3a')]?_0x2c63ad[_0xe89b('0x38')]:_0x323da7['model'];_0x2c63ad['order']=qs['sort'](_0x31363a[_0xe89b('0x35')][_0xe89b('0x3d')]);_0x2c63ad[_0xe89b('0x3e')]=qs[_0xe89b('0x36')](_[_0xe89b('0x51')](_0x31363a[_0xe89b('0x35')],_0x323da7[_0xe89b('0x36')]));if(_0x31363a[_0xe89b('0x35')]['filter']){_0x2c63ad[_0xe89b('0x3e')]=_['merge'](_0x2c63ad['where'],{'$or':_[_0xe89b('0x2f')](_0x2c63ad['attributes'],function(_0x40690d){var _0x4367fa={};_0x4367fa[_0x40690d]={'$like':'%'+_0x31363a[_0xe89b('0x35')]['filter']+'%'};return _0x4367fa;})});}_0x2c63ad=_[_0xe89b('0x3f')]({},_0x2c63ad,_0x31363a[_0xe89b('0x4c')]);return _0x13c85e[_0xe89b('0x53')](_0x2c63ad);}})[_0xe89b('0x29')](function(_0x48a374){if(_0x48a374){_0x4844ad=_0x48a374['length'];if(!_0x31363a[_0xe89b('0x35')][_0xe89b('0x3b')]('nolimit')){_0x2c63ad[_0xe89b('0x24')]=qs[_0xe89b('0x24')](_0x31363a[_0xe89b('0x35')][_0xe89b('0x24')]);_0x2c63ad['offset']=qs[_0xe89b('0x23')](_0x31363a[_0xe89b('0x35')]['offset']);}return _0x13c85e['getSubjects'](_0x2c63ad);}})['then'](function(_0x5473a3){if(_0x5473a3){return _0x5473a3?{'count':_0x4844ad,'rows':_0x5473a3}:null;}})['then'](respondWithResult(_0x2e26b8,null))[_0xe89b('0x47')](handleError(_0x2e26b8,null));};exports['getDescriptions']=function(_0x296c91,_0x4a8c97,_0x4b3ec2){var _0x334c9c={};var _0x2da568={};var _0x2e4cbe;var _0x3f2d9e;return db[_0xe89b('0x42')]['findOne']({'where':{'id':_0x296c91['params']['id']}})[_0xe89b('0x29')](handleEntityNotFound(_0x4a8c97,null))[_0xe89b('0x29')](function(_0x8a7f36){if(_0x8a7f36){_0x2e4cbe=_0x8a7f36;_0x2da568['model']=_[_0xe89b('0x4a')](db[_0xe89b('0x55')][_0xe89b('0x30')]);_0x2da568[_0xe89b('0x35')]=_['keys'](_0x296c91[_0xe89b('0x35')]);_0x2da568[_0xe89b('0x36')]=_['intersection'](_0x2da568[_0xe89b('0x34')],_0x2da568[_0xe89b('0x35')]);_0x334c9c[_0xe89b('0x38')]=_['intersection'](_0x2da568[_0xe89b('0x34')],qs['fields'](_0x296c91[_0xe89b('0x35')][_0xe89b('0x39')]));_0x334c9c['attributes']=_0x334c9c[_0xe89b('0x38')][_0xe89b('0x3a')]?_0x334c9c[_0xe89b('0x38')]:_0x2da568[_0xe89b('0x34')];_0x334c9c[_0xe89b('0x3c')]=qs['sort'](_0x296c91['query'][_0xe89b('0x3d')]);_0x334c9c['where']=qs['filters'](_[_0xe89b('0x51')](_0x296c91['query'],_0x2da568['filters']));if(_0x296c91[_0xe89b('0x35')]['filter']){_0x334c9c[_0xe89b('0x3e')]=_[_0xe89b('0x3f')](_0x334c9c[_0xe89b('0x3e')],{'$or':_[_0xe89b('0x2f')](_0x334c9c[_0xe89b('0x38')],function(_0x1d350c){var _0x136d3d={};_0x136d3d[_0x1d350c]={'$like':'%'+_0x296c91[_0xe89b('0x35')][_0xe89b('0x41')]+'%'};return _0x136d3d;})});}_0x334c9c=_[_0xe89b('0x3f')]({},_0x334c9c,_0x296c91[_0xe89b('0x4c')]);return _0x2e4cbe['getDescriptions'](_0x334c9c);}})[_0xe89b('0x29')](function(_0x2ce5c7){if(_0x2ce5c7){_0x3f2d9e=_0x2ce5c7[_0xe89b('0x3a')];if(!_0x296c91[_0xe89b('0x35')][_0xe89b('0x3b')](_0xe89b('0x52'))){_0x334c9c[_0xe89b('0x24')]=qs[_0xe89b('0x24')](_0x296c91[_0xe89b('0x35')]['limit']);_0x334c9c[_0xe89b('0x23')]=qs[_0xe89b('0x23')](_0x296c91['query'][_0xe89b('0x23')]);}return _0x2e4cbe['getDescriptions'](_0x334c9c);}})[_0xe89b('0x29')](function(_0x38dd9c){if(_0x38dd9c){return _0x38dd9c?{'count':_0x3f2d9e,'rows':_0x38dd9c}:null;}})[_0xe89b('0x29')](respondWithResult(_0x4a8c97,null))['catch'](handleError(_0x4a8c97,null));};
\ No newline at end of file
+var _0xb135=['catch','status','end','json','count','offset','limit','Content-Range','apply','save','update','destroy','sendStatus','index','map','SugarcrmConfiguration','rawAttributes','fieldName','type','model','query','keys','filters','intersection','attributes','fields','length','hasOwnProperty','order','sort','pick','where','merge','name','options','includeAll','include','findAll','rows','show','create','body','find','params','getFields','findOne','filter','getSubjects','SugarcrmField','nolimit','getDescriptions','html-pdf','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','bluebird','mustache','path','sox','to-csv','ejs','squel','crypto','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','jayson/promise','http','then','SugarcrmConfiguration,\x20%s,\x20%s','request\x20sent','debug','SugarcrmConfiguration,\x20%s,\x20%s,\x20%s','error','code','message','info'];(function(_0x56a14f,_0x3c5ddc){var _0x20c96a=function(_0x3cf1ec){while(--_0x3cf1ec){_0x56a14f['push'](_0x56a14f['shift']());}};_0x20c96a(++_0x3c5ddc);}(_0xb135,0xe3));var _0x5b13=function(_0x5e05a8,_0x1bc248){_0x5e05a8=_0x5e05a8-0x0;var _0x5965ec=_0xb135[_0x5e05a8];return _0x5965ec;};'use strict';var pdf=require(_0x5b13('0x0'));var emlformat=require(_0x5b13('0x1'));var rimraf=require(_0x5b13('0x2'));var zipdir=require(_0x5b13('0x3'));var jsonpatch=require(_0x5b13('0x4'));var rp=require(_0x5b13('0x5'));var moment=require('moment');var BPromise=require(_0x5b13('0x6'));var Mustache=require(_0x5b13('0x7'));var util=require('util');var path=require(_0x5b13('0x8'));var sox=require(_0x5b13('0x9'));var csv=require(_0x5b13('0xa'));var ejs=require(_0x5b13('0xb'));var fs=require('fs');var _=require('lodash');var squel=require(_0x5b13('0xc'));var crypto=require(_0x5b13('0xd'));var jsforce=require('jsforce');var deskjs=require('desk.js');var toCsv=require(_0x5b13('0xa'));var querystring=require('querystring');var Papa=require(_0x5b13('0xe'));var Redis=require(_0x5b13('0xf'));var authService=require(_0x5b13('0x10'));var qs=require(_0x5b13('0x11'));var as=require(_0x5b13('0x12'));var hardwareService=require(_0x5b13('0x13'));var logger=require(_0x5b13('0x14'))(_0x5b13('0x15'));var utils=require(_0x5b13('0x16'));var config=require(_0x5b13('0x17'));var licenseUtil=require(_0x5b13('0x18'));var db=require(_0x5b13('0x19'))['db'];var jayson=require(_0x5b13('0x1a'));var client=jayson['client'][_0x5b13('0x1b')]({'port':0x232a});function respondWithRpcPromise(_0x4f412f,_0x2307ea,_0x4945bd,_0x81952f){return new BPromise(function(_0x57ecfd,_0x4dafc6){var _0x54d067=_0x81952f||client;return _0x54d067['request'](_0x4f412f,_0x4945bd)[_0x5b13('0x1c')](function(_0x45bc9f){logger['info'](_0x5b13('0x1d'),_0x2307ea,_0x5b13('0x1e'));logger[_0x5b13('0x1f')](_0x5b13('0x20'),_0x2307ea,'request\x20sent',JSON['stringify'](_0x45bc9f));if(_0x45bc9f[_0x5b13('0x21')]){if(_0x45bc9f[_0x5b13('0x21')][_0x5b13('0x22')]===0x1f4){logger[_0x5b13('0x21')](_0x5b13('0x1d'),_0x2307ea,_0x45bc9f['error'][_0x5b13('0x23')]);return _0x4dafc6(_0x45bc9f[_0x5b13('0x21')][_0x5b13('0x23')]);}logger['error']('SugarcrmConfiguration,\x20%s,\x20%s',_0x2307ea,_0x45bc9f[_0x5b13('0x21')][_0x5b13('0x23')]);return _0x57ecfd(_0x45bc9f[_0x5b13('0x21')]['message']);}else{logger[_0x5b13('0x24')]('SugarcrmConfiguration,\x20%s,\x20%s',_0x2307ea,'request\x20sent');_0x57ecfd(_0x45bc9f['result']['message']);}})[_0x5b13('0x25')](function(_0x2e6ab6){logger[_0x5b13('0x21')](_0x5b13('0x1d'),_0x2307ea,_0x2e6ab6);_0x4dafc6(_0x2e6ab6);});});}function respondWithStatusCode(_0x51230b,_0x3b3567){_0x3b3567=_0x3b3567||0xcc;return function(_0x55d5c0){if(_0x55d5c0){return _0x51230b['sendStatus'](_0x3b3567);}return _0x51230b[_0x5b13('0x26')](_0x3b3567)[_0x5b13('0x27')]();};}function respondWithResult(_0x2fbf43,_0x4a174e){_0x4a174e=_0x4a174e||0xc8;return function(_0x26da4d){if(_0x26da4d){return _0x2fbf43['status'](_0x4a174e)[_0x5b13('0x28')](_0x26da4d);}};}function respondWithFilteredResult(_0xc0ec75,_0x1a36f1){return function(_0x1594c0){if(_0x1594c0){var _0x95f449=_0x1594c0[_0x5b13('0x29')],_0x5793e8=_0x1a36f1[_0x5b13('0x2a')],_0x82a540=_0x1a36f1[_0x5b13('0x2a')]+_0x1a36f1[_0x5b13('0x2b')],_0xd785c9;if(_0x82a540>=_0x95f449){_0x82a540=_0x95f449;_0xd785c9=0xc8;}else{_0xd785c9=0xce;}_0xc0ec75['status'](_0xd785c9);return _0xc0ec75['set'](_0x5b13('0x2c'),_0x5793e8+'-'+_0x82a540+'/'+_0x95f449)['json'](_0x1594c0);}return null;};}function patchUpdates(_0x449f89){return function(_0xf36923){try{jsonpatch[_0x5b13('0x2d')](_0xf36923,_0x449f89,!![]);}catch(_0x1a76bb){return BPromise['reject'](_0x1a76bb);}return _0xf36923[_0x5b13('0x2e')]();};}function saveUpdates(_0x57482f,_0x67c6ae){return function(_0x3a33da){if(_0x3a33da){return _0x3a33da[_0x5b13('0x2f')](_0x57482f)[_0x5b13('0x1c')](function(_0x55e1cd){return _0x55e1cd;});}return null;};}function removeEntity(_0x28f282,_0x1b9eba){return function(_0x35e184){if(_0x35e184){return _0x35e184[_0x5b13('0x30')]()['then'](function(){_0x28f282[_0x5b13('0x26')](0xcc)[_0x5b13('0x27')]();});}};}function handleEntityNotFound(_0x16c9d5,_0x5256c2){return function(_0x1fd65e){if(!_0x1fd65e){_0x16c9d5[_0x5b13('0x31')](0x194);}return _0x1fd65e;};}function handleError(_0x2abda4,_0x254ea6){_0x254ea6=_0x254ea6||0x1f4;return function(_0xcdd3e5){logger[_0x5b13('0x21')](_0xcdd3e5['stack']);if(_0xcdd3e5['name']){delete _0xcdd3e5['name'];}_0x2abda4[_0x5b13('0x26')](_0x254ea6)['send'](_0xcdd3e5);};}exports[_0x5b13('0x32')]=function(_0x9a997f,_0x48cb9e){var _0x48a9a1={},_0x5a0778={},_0xd69fbf={'count':0x0,'rows':[]};var _0x26cfc1=_[_0x5b13('0x33')](db[_0x5b13('0x34')][_0x5b13('0x35')],function(_0x10e218){return{'name':_0x10e218[_0x5b13('0x36')],'type':_0x10e218[_0x5b13('0x37')]['key']};});_0x5a0778[_0x5b13('0x38')]=_[_0x5b13('0x33')](_0x26cfc1,'name');_0x5a0778[_0x5b13('0x39')]=_[_0x5b13('0x3a')](_0x9a997f[_0x5b13('0x39')]);_0x5a0778[_0x5b13('0x3b')]=_[_0x5b13('0x3c')](_0x5a0778['model'],_0x5a0778[_0x5b13('0x39')]);_0x48a9a1[_0x5b13('0x3d')]=_['intersection'](_0x5a0778[_0x5b13('0x38')],qs[_0x5b13('0x3e')](_0x9a997f[_0x5b13('0x39')]['fields']));_0x48a9a1['attributes']=_0x48a9a1[_0x5b13('0x3d')][_0x5b13('0x3f')]?_0x48a9a1[_0x5b13('0x3d')]:_0x5a0778['model'];if(!_0x9a997f[_0x5b13('0x39')][_0x5b13('0x40')]('nolimit')){_0x48a9a1[_0x5b13('0x2b')]=qs[_0x5b13('0x2b')](_0x9a997f[_0x5b13('0x39')][_0x5b13('0x2b')]);_0x48a9a1[_0x5b13('0x2a')]=qs['offset'](_0x9a997f[_0x5b13('0x39')][_0x5b13('0x2a')]);}_0x48a9a1[_0x5b13('0x41')]=qs[_0x5b13('0x42')](_0x9a997f[_0x5b13('0x39')][_0x5b13('0x42')]);_0x48a9a1['where']=qs[_0x5b13('0x3b')](_[_0x5b13('0x43')](_0x9a997f[_0x5b13('0x39')],_0x5a0778[_0x5b13('0x3b')]),_0x26cfc1);if(_0x9a997f[_0x5b13('0x39')]['filter']){_0x48a9a1[_0x5b13('0x44')]=_[_0x5b13('0x45')](_0x48a9a1[_0x5b13('0x44')],{'$or':_[_0x5b13('0x33')](_0x26cfc1,function(_0x166fd0){if(_0x166fd0['type']!=='VIRTUAL'){var _0x3837ee={};_0x3837ee[_0x166fd0[_0x5b13('0x46')]]={'$like':'%'+_0x9a997f[_0x5b13('0x39')]['filter']+'%'};return _0x3837ee;}})});}_0x48a9a1=_[_0x5b13('0x45')]({},_0x48a9a1,_0x9a997f[_0x5b13('0x47')]);var _0x5480a1={'where':_0x48a9a1[_0x5b13('0x44')]};return db[_0x5b13('0x34')][_0x5b13('0x29')](_0x5480a1)[_0x5b13('0x1c')](function(_0x568f18){_0xd69fbf[_0x5b13('0x29')]=_0x568f18;if(_0x9a997f[_0x5b13('0x39')][_0x5b13('0x48')]){_0x48a9a1[_0x5b13('0x49')]=[{'all':!![]}];}return db[_0x5b13('0x34')][_0x5b13('0x4a')](_0x48a9a1);})[_0x5b13('0x1c')](function(_0x51b2f2){_0xd69fbf[_0x5b13('0x4b')]=_0x51b2f2;return _0xd69fbf;})[_0x5b13('0x1c')](respondWithFilteredResult(_0x48cb9e,_0x48a9a1))[_0x5b13('0x25')](handleError(_0x48cb9e,null));};exports[_0x5b13('0x4c')]=function(_0xd1b9d8,_0x4cfc35){var _0x2b11ab={'raw':![],'where':{'id':_0xd1b9d8['params']['id']}},_0x50fd89={};_0x50fd89[_0x5b13('0x38')]=_[_0x5b13('0x3a')](db['SugarcrmConfiguration'][_0x5b13('0x35')]);_0x50fd89[_0x5b13('0x39')]=_[_0x5b13('0x3a')](_0xd1b9d8['query']);_0x50fd89[_0x5b13('0x3b')]=_[_0x5b13('0x3c')](_0x50fd89[_0x5b13('0x38')],_0x50fd89[_0x5b13('0x39')]);_0x2b11ab[_0x5b13('0x3d')]=_[_0x5b13('0x3c')](_0x50fd89['model'],qs['fields'](_0xd1b9d8[_0x5b13('0x39')][_0x5b13('0x3e')]));_0x2b11ab[_0x5b13('0x3d')]=_0x2b11ab[_0x5b13('0x3d')][_0x5b13('0x3f')]?_0x2b11ab[_0x5b13('0x3d')]:_0x50fd89[_0x5b13('0x38')];if(_0xd1b9d8['query'][_0x5b13('0x48')]){_0x2b11ab[_0x5b13('0x49')]=[{'all':!![]}];}_0x2b11ab=_[_0x5b13('0x45')]({},_0x2b11ab,_0xd1b9d8[_0x5b13('0x47')]);return db[_0x5b13('0x34')]['find'](_0x2b11ab)['then'](handleEntityNotFound(_0x4cfc35,null))[_0x5b13('0x1c')](respondWithResult(_0x4cfc35,null))['catch'](handleError(_0x4cfc35,null));};exports['create']=function(_0x2e229c,_0x524d7d){return db[_0x5b13('0x34')][_0x5b13('0x4d')](_0x2e229c[_0x5b13('0x4e')],{})[_0x5b13('0x1c')](respondWithResult(_0x524d7d,0xc9))[_0x5b13('0x25')](handleError(_0x524d7d,null));};exports[_0x5b13('0x2f')]=function(_0x58222a,_0x49b23c){if(_0x58222a[_0x5b13('0x4e')]['id']){delete _0x58222a['body']['id'];}return db[_0x5b13('0x34')]['find']({'where':{'id':_0x58222a['params']['id']}})['then'](handleEntityNotFound(_0x49b23c,null))[_0x5b13('0x1c')](saveUpdates(_0x58222a[_0x5b13('0x4e')],null))['then'](respondWithResult(_0x49b23c,null))[_0x5b13('0x25')](handleError(_0x49b23c,null));};exports[_0x5b13('0x30')]=function(_0x315092,_0x1d1f84){return db[_0x5b13('0x34')][_0x5b13('0x4f')]({'where':{'id':_0x315092[_0x5b13('0x50')]['id']}})[_0x5b13('0x1c')](handleEntityNotFound(_0x1d1f84,null))[_0x5b13('0x1c')](removeEntity(_0x1d1f84,null))[_0x5b13('0x25')](handleError(_0x1d1f84,null));};exports[_0x5b13('0x51')]=function(_0x895d70,_0x257a6b,_0x1cf7cf){var _0x33643b={};var _0x23500e={};var _0x46cc76;var _0x3b7c47;return db[_0x5b13('0x34')][_0x5b13('0x52')]({'where':{'id':_0x895d70[_0x5b13('0x50')]['id']}})[_0x5b13('0x1c')](handleEntityNotFound(_0x257a6b,null))['then'](function(_0x1e49a5){if(_0x1e49a5){_0x46cc76=_0x1e49a5;_0x23500e['model']=_[_0x5b13('0x3a')](db['SugarcrmField'][_0x5b13('0x35')]);_0x23500e[_0x5b13('0x39')]=_[_0x5b13('0x3a')](_0x895d70[_0x5b13('0x39')]);_0x23500e[_0x5b13('0x3b')]=_['intersection'](_0x23500e['model'],_0x23500e[_0x5b13('0x39')]);_0x33643b[_0x5b13('0x3d')]=_[_0x5b13('0x3c')](_0x23500e[_0x5b13('0x38')],qs[_0x5b13('0x3e')](_0x895d70[_0x5b13('0x39')][_0x5b13('0x3e')]));_0x33643b[_0x5b13('0x3d')]=_0x33643b['attributes'][_0x5b13('0x3f')]?_0x33643b[_0x5b13('0x3d')]:_0x23500e[_0x5b13('0x38')];_0x33643b[_0x5b13('0x41')]=qs[_0x5b13('0x42')](_0x895d70[_0x5b13('0x39')]['sort']);_0x33643b[_0x5b13('0x44')]=qs[_0x5b13('0x3b')](_[_0x5b13('0x43')](_0x895d70[_0x5b13('0x39')],_0x23500e[_0x5b13('0x3b')]));if(_0x895d70[_0x5b13('0x39')]['filter']){_0x33643b[_0x5b13('0x44')]=_[_0x5b13('0x45')](_0x33643b['where'],{'$or':_[_0x5b13('0x33')](_0x33643b[_0x5b13('0x3d')],function(_0x326218){var _0x1bfcd5={};_0x1bfcd5[_0x326218]={'$like':'%'+_0x895d70[_0x5b13('0x39')][_0x5b13('0x53')]+'%'};return _0x1bfcd5;})});}_0x33643b=_[_0x5b13('0x45')]({},_0x33643b,_0x895d70['options']);return _0x46cc76['getFields'](_0x33643b);}})['then'](function(_0x2f1713){if(_0x2f1713){_0x3b7c47=_0x2f1713[_0x5b13('0x3f')];if(!_0x895d70[_0x5b13('0x39')][_0x5b13('0x40')]('nolimit')){_0x33643b[_0x5b13('0x2b')]=qs[_0x5b13('0x2b')](_0x895d70[_0x5b13('0x39')]['limit']);_0x33643b[_0x5b13('0x2a')]=qs['offset'](_0x895d70[_0x5b13('0x39')]['offset']);}return _0x46cc76[_0x5b13('0x51')](_0x33643b);}})['then'](function(_0x2b48b8){if(_0x2b48b8){return _0x2b48b8?{'count':_0x3b7c47,'rows':_0x2b48b8}:null;}})[_0x5b13('0x1c')](respondWithResult(_0x257a6b,null))[_0x5b13('0x25')](handleError(_0x257a6b,null));};exports[_0x5b13('0x54')]=function(_0x4edb9a,_0x5c8cf1,_0xc0a816){var _0x567c71={};var _0xe568c1={};var _0x28555a;var _0x369c3f;return db[_0x5b13('0x34')][_0x5b13('0x52')]({'where':{'id':_0x4edb9a[_0x5b13('0x50')]['id']}})[_0x5b13('0x1c')](handleEntityNotFound(_0x5c8cf1,null))['then'](function(_0x8fc17){if(_0x8fc17){_0x28555a=_0x8fc17;_0xe568c1[_0x5b13('0x38')]=_['keys'](db[_0x5b13('0x55')][_0x5b13('0x35')]);_0xe568c1['query']=_['keys'](_0x4edb9a[_0x5b13('0x39')]);_0xe568c1[_0x5b13('0x3b')]=_[_0x5b13('0x3c')](_0xe568c1[_0x5b13('0x38')],_0xe568c1[_0x5b13('0x39')]);_0x567c71['attributes']=_[_0x5b13('0x3c')](_0xe568c1[_0x5b13('0x38')],qs['fields'](_0x4edb9a[_0x5b13('0x39')][_0x5b13('0x3e')]));_0x567c71[_0x5b13('0x3d')]=_0x567c71['attributes']['length']?_0x567c71['attributes']:_0xe568c1[_0x5b13('0x38')];_0x567c71['order']=qs[_0x5b13('0x42')](_0x4edb9a['query'][_0x5b13('0x42')]);_0x567c71[_0x5b13('0x44')]=qs[_0x5b13('0x3b')](_[_0x5b13('0x43')](_0x4edb9a[_0x5b13('0x39')],_0xe568c1['filters']));if(_0x4edb9a[_0x5b13('0x39')][_0x5b13('0x53')]){_0x567c71['where']=_[_0x5b13('0x45')](_0x567c71[_0x5b13('0x44')],{'$or':_[_0x5b13('0x33')](_0x567c71[_0x5b13('0x3d')],function(_0x4d9c79){var _0x57768a={};_0x57768a[_0x4d9c79]={'$like':'%'+_0x4edb9a[_0x5b13('0x39')][_0x5b13('0x53')]+'%'};return _0x57768a;})});}_0x567c71=_[_0x5b13('0x45')]({},_0x567c71,_0x4edb9a[_0x5b13('0x47')]);return _0x28555a[_0x5b13('0x54')](_0x567c71);}})['then'](function(_0xb4b0ec){if(_0xb4b0ec){_0x369c3f=_0xb4b0ec[_0x5b13('0x3f')];if(!_0x4edb9a['query']['hasOwnProperty'](_0x5b13('0x56'))){_0x567c71[_0x5b13('0x2b')]=qs['limit'](_0x4edb9a[_0x5b13('0x39')][_0x5b13('0x2b')]);_0x567c71[_0x5b13('0x2a')]=qs[_0x5b13('0x2a')](_0x4edb9a['query'][_0x5b13('0x2a')]);}return _0x28555a[_0x5b13('0x54')](_0x567c71);}})['then'](function(_0x356033){if(_0x356033){return _0x356033?{'count':_0x369c3f,'rows':_0x356033}:null;}})[_0x5b13('0x1c')](respondWithResult(_0x5c8cf1,null))[_0x5b13('0x25')](handleError(_0x5c8cf1,null));};exports[_0x5b13('0x57')]=function(_0x4aee11,_0x28f210,_0x220f6d){var _0x429606={};var _0x3a6f43={};var _0x55b23f;var _0x5f3830;return db[_0x5b13('0x34')]['findOne']({'where':{'id':_0x4aee11[_0x5b13('0x50')]['id']}})[_0x5b13('0x1c')](handleEntityNotFound(_0x28f210,null))['then'](function(_0x5d0bb6){if(_0x5d0bb6){_0x55b23f=_0x5d0bb6;_0x3a6f43[_0x5b13('0x38')]=_[_0x5b13('0x3a')](db[_0x5b13('0x55')][_0x5b13('0x35')]);_0x3a6f43[_0x5b13('0x39')]=_['keys'](_0x4aee11[_0x5b13('0x39')]);_0x3a6f43[_0x5b13('0x3b')]=_[_0x5b13('0x3c')](_0x3a6f43['model'],_0x3a6f43[_0x5b13('0x39')]);_0x429606[_0x5b13('0x3d')]=_[_0x5b13('0x3c')](_0x3a6f43[_0x5b13('0x38')],qs[_0x5b13('0x3e')](_0x4aee11['query'][_0x5b13('0x3e')]));_0x429606[_0x5b13('0x3d')]=_0x429606['attributes'][_0x5b13('0x3f')]?_0x429606['attributes']:_0x3a6f43[_0x5b13('0x38')];_0x429606[_0x5b13('0x41')]=qs['sort'](_0x4aee11[_0x5b13('0x39')][_0x5b13('0x42')]);_0x429606[_0x5b13('0x44')]=qs[_0x5b13('0x3b')](_[_0x5b13('0x43')](_0x4aee11[_0x5b13('0x39')],_0x3a6f43[_0x5b13('0x3b')]));if(_0x4aee11['query'][_0x5b13('0x53')]){_0x429606['where']=_[_0x5b13('0x45')](_0x429606['where'],{'$or':_[_0x5b13('0x33')](_0x429606[_0x5b13('0x3d')],function(_0x4538eb){var _0x7b1e7d={};_0x7b1e7d[_0x4538eb]={'$like':'%'+_0x4aee11[_0x5b13('0x39')][_0x5b13('0x53')]+'%'};return _0x7b1e7d;})});}_0x429606=_[_0x5b13('0x45')]({},_0x429606,_0x4aee11[_0x5b13('0x47')]);return _0x55b23f[_0x5b13('0x57')](_0x429606);}})[_0x5b13('0x1c')](function(_0x3a394a){if(_0x3a394a){_0x5f3830=_0x3a394a['length'];if(!_0x4aee11[_0x5b13('0x39')][_0x5b13('0x40')](_0x5b13('0x56'))){_0x429606[_0x5b13('0x2b')]=qs[_0x5b13('0x2b')](_0x4aee11[_0x5b13('0x39')][_0x5b13('0x2b')]);_0x429606[_0x5b13('0x2a')]=qs[_0x5b13('0x2a')](_0x4aee11[_0x5b13('0x39')][_0x5b13('0x2a')]);}return _0x55b23f['getDescriptions'](_0x429606);}})[_0x5b13('0x1c')](function(_0x596a94){if(_0x596a94){return _0x596a94?{'count':_0x5f3830,'rows':_0x596a94}:null;}})[_0x5b13('0x1c')](respondWithResult(_0x28f210,null))[_0x5b13('0x25')](handleError(_0x28f210,null));};
\ No newline at end of file