Built motion from commit e0fa946e.|2.6.5
[motion2.git] / server / api / intSugarcrmConfiguration / intSugarcrmConfiguration.controller.js
index e99ebda..961fb71 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xa8c1=['sort','filter','where','merge','includeAll','include','findAll','rows','show','params','find','create','update','body','findOne','SugarcrmField','pick','options','getFields','nolimit','getSubjects','getDescriptions','html-pdf','eml-format','rimraf','fast-json-patch','request-promise','moment','mustache','util','path','sox','to-csv','ejs','lodash','squel','crypto','jsforce','querystring','../../components/auth/service','../../components/parsers/advancedSearch','../../config/license/hardware','api','../../config/utils','../../config/environment','../../config/license/util','jayson/promise','request','then','request\x20sent','SugarcrmConfiguration,\x20%s,\x20%s,\x20%s','stringify','error','SugarcrmConfiguration,\x20%s,\x20%s','message','info','result','catch','sendStatus','status','end','json','count','offset','limit','set','apply','save','destroy','name','send','index','map','SugarcrmConfiguration','rawAttributes','fieldName','type','query','keys','filters','intersection','model','attributes','fields','length','hasOwnProperty','order'];(function(_0x4d7116,_0xdb8175){var _0x4593dc=function(_0x51d44e){while(--_0x51d44e){_0x4d7116['push'](_0x4d7116['shift']());}};_0x4593dc(++_0xdb8175);}(_0xa8c1,0x172));var _0x1a8c=function(_0x1c470d,_0x81d66b){_0x1c470d=_0x1c470d-0x0;var _0x12141b=_0xa8c1[_0x1c470d];return _0x12141b;};'use strict';var pdf=require(_0x1a8c('0x0'));var emlformat=require(_0x1a8c('0x1'));var rimraf=require(_0x1a8c('0x2'));var zipdir=require('zip-dir');var jsonpatch=require(_0x1a8c('0x3'));var rp=require(_0x1a8c('0x4'));var moment=require(_0x1a8c('0x5'));var BPromise=require('bluebird');var Mustache=require(_0x1a8c('0x6'));var util=require(_0x1a8c('0x7'));var path=require(_0x1a8c('0x8'));var sox=require(_0x1a8c('0x9'));var csv=require(_0x1a8c('0xa'));var ejs=require(_0x1a8c('0xb'));var fs=require('fs');var _=require(_0x1a8c('0xc'));var squel=require(_0x1a8c('0xd'));var crypto=require(_0x1a8c('0xe'));var jsforce=require(_0x1a8c('0xf'));var deskjs=require('desk.js');var toCsv=require('to-csv');var querystring=require(_0x1a8c('0x10'));var Papa=require('papaparse');var Redis=require('ioredis');var authService=require(_0x1a8c('0x11'));var qs=require('../../components/parsers/qs');var as=require(_0x1a8c('0x12'));var hardwareService=require(_0x1a8c('0x13'));var logger=require('../../config/logger')(_0x1a8c('0x14'));var utils=require(_0x1a8c('0x15'));var config=require(_0x1a8c('0x16'));var licenseUtil=require(_0x1a8c('0x17'));var db=require('../../mysqldb')['db'];var jayson=require(_0x1a8c('0x18'));var client=jayson['client']['http']({'port':0x232a});function respondWithRpcPromise(_0x2a412a,_0x335eb6,_0x1bb0bf,_0x44e0d2){return new BPromise(function(_0x28fc55,_0x267f5e){var _0x38a7a5=_0x44e0d2||client;return _0x38a7a5[_0x1a8c('0x19')](_0x2a412a,_0x1bb0bf)[_0x1a8c('0x1a')](function(_0x550443){logger['info']('SugarcrmConfiguration,\x20%s,\x20%s',_0x335eb6,_0x1a8c('0x1b'));logger['debug'](_0x1a8c('0x1c'),_0x335eb6,_0x1a8c('0x1b'),JSON[_0x1a8c('0x1d')](_0x550443));if(_0x550443['error']){if(_0x550443[_0x1a8c('0x1e')]['code']===0x1f4){logger[_0x1a8c('0x1e')](_0x1a8c('0x1f'),_0x335eb6,_0x550443['error'][_0x1a8c('0x20')]);return _0x267f5e(_0x550443[_0x1a8c('0x1e')][_0x1a8c('0x20')]);}logger[_0x1a8c('0x1e')]('SugarcrmConfiguration,\x20%s,\x20%s',_0x335eb6,_0x550443['error'][_0x1a8c('0x20')]);return _0x28fc55(_0x550443['error'][_0x1a8c('0x20')]);}else{logger[_0x1a8c('0x21')](_0x1a8c('0x1f'),_0x335eb6,_0x1a8c('0x1b'));_0x28fc55(_0x550443[_0x1a8c('0x22')][_0x1a8c('0x20')]);}})[_0x1a8c('0x23')](function(_0x20df98){logger[_0x1a8c('0x1e')](_0x1a8c('0x1f'),_0x335eb6,_0x20df98);_0x267f5e(_0x20df98);});});}function respondWithStatusCode(_0x17411f,_0x170d95){_0x170d95=_0x170d95||0xcc;return function(_0x31532c){if(_0x31532c){return _0x17411f[_0x1a8c('0x24')](_0x170d95);}return _0x17411f[_0x1a8c('0x25')](_0x170d95)[_0x1a8c('0x26')]();};}function respondWithResult(_0x15ef1b,_0x383938){_0x383938=_0x383938||0xc8;return function(_0x355480){if(_0x355480){return _0x15ef1b[_0x1a8c('0x25')](_0x383938)[_0x1a8c('0x27')](_0x355480);}};}function respondWithFilteredResult(_0x42c890,_0x2844e2){return function(_0x5ede29){if(_0x5ede29){var _0x3d896c=_0x5ede29[_0x1a8c('0x28')],_0x25ed90=_0x2844e2[_0x1a8c('0x29')],_0x7a2f1e=_0x2844e2[_0x1a8c('0x29')]+_0x2844e2[_0x1a8c('0x2a')],_0x127808;if(_0x7a2f1e>=_0x3d896c){_0x7a2f1e=_0x3d896c;_0x127808=0xc8;}else{_0x127808=0xce;}_0x42c890[_0x1a8c('0x25')](_0x127808);return _0x42c890[_0x1a8c('0x2b')]('Content-Range',_0x25ed90+'-'+_0x7a2f1e+'/'+_0x3d896c)[_0x1a8c('0x27')](_0x5ede29);}return null;};}function patchUpdates(_0x175790){return function(_0x563f99){try{jsonpatch[_0x1a8c('0x2c')](_0x563f99,_0x175790,!![]);}catch(_0x434cec){return BPromise['reject'](_0x434cec);}return _0x563f99[_0x1a8c('0x2d')]();};}function saveUpdates(_0x2862a1,_0x415242){return function(_0x2a16dc){if(_0x2a16dc){return _0x2a16dc['update'](_0x2862a1)[_0x1a8c('0x1a')](function(_0x16e770){return _0x16e770;});}return null;};}function removeEntity(_0x149190,_0x1cd6c2){return function(_0x5868c2){if(_0x5868c2){return _0x5868c2[_0x1a8c('0x2e')]()[_0x1a8c('0x1a')](function(){_0x149190[_0x1a8c('0x25')](0xcc)[_0x1a8c('0x26')]();});}};}function handleEntityNotFound(_0x15ad47,_0xf10f58){return function(_0x219af6){if(!_0x219af6){_0x15ad47[_0x1a8c('0x24')](0x194);}return _0x219af6;};}function handleError(_0x28f9e2,_0x4ca06f){_0x4ca06f=_0x4ca06f||0x1f4;return function(_0x177637){logger[_0x1a8c('0x1e')](_0x177637['stack']);if(_0x177637[_0x1a8c('0x2f')]){delete _0x177637[_0x1a8c('0x2f')];}_0x28f9e2['status'](_0x4ca06f)[_0x1a8c('0x30')](_0x177637);};}exports[_0x1a8c('0x31')]=function(_0x48c8eb,_0x407216){var _0x3a444a={},_0x4a556c={},_0x3b1ec1={'count':0x0,'rows':[]};var _0x86e397=_[_0x1a8c('0x32')](db[_0x1a8c('0x33')][_0x1a8c('0x34')],function(_0x391694){return{'name':_0x391694[_0x1a8c('0x35')],'type':_0x391694[_0x1a8c('0x36')]['key']};});_0x4a556c['model']=_[_0x1a8c('0x32')](_0x86e397,'name');_0x4a556c[_0x1a8c('0x37')]=_[_0x1a8c('0x38')](_0x48c8eb[_0x1a8c('0x37')]);_0x4a556c[_0x1a8c('0x39')]=_[_0x1a8c('0x3a')](_0x4a556c[_0x1a8c('0x3b')],_0x4a556c[_0x1a8c('0x37')]);_0x3a444a[_0x1a8c('0x3c')]=_[_0x1a8c('0x3a')](_0x4a556c[_0x1a8c('0x3b')],qs[_0x1a8c('0x3d')](_0x48c8eb[_0x1a8c('0x37')][_0x1a8c('0x3d')]));_0x3a444a[_0x1a8c('0x3c')]=_0x3a444a[_0x1a8c('0x3c')][_0x1a8c('0x3e')]?_0x3a444a[_0x1a8c('0x3c')]:_0x4a556c[_0x1a8c('0x3b')];if(!_0x48c8eb[_0x1a8c('0x37')][_0x1a8c('0x3f')]('nolimit')){_0x3a444a['limit']=qs[_0x1a8c('0x2a')](_0x48c8eb[_0x1a8c('0x37')][_0x1a8c('0x2a')]);_0x3a444a[_0x1a8c('0x29')]=qs[_0x1a8c('0x29')](_0x48c8eb[_0x1a8c('0x37')][_0x1a8c('0x29')]);}_0x3a444a[_0x1a8c('0x40')]=qs[_0x1a8c('0x41')](_0x48c8eb['query'][_0x1a8c('0x41')]);_0x3a444a['where']=qs[_0x1a8c('0x39')](_['pick'](_0x48c8eb[_0x1a8c('0x37')],_0x4a556c[_0x1a8c('0x39')]),_0x86e397);if(_0x48c8eb[_0x1a8c('0x37')][_0x1a8c('0x42')]){_0x3a444a[_0x1a8c('0x43')]=_[_0x1a8c('0x44')](_0x3a444a[_0x1a8c('0x43')],{'$or':_[_0x1a8c('0x32')](_0x86e397,function(_0x39e11d){if(_0x39e11d[_0x1a8c('0x36')]!=='VIRTUAL'){var _0x2cda03={};_0x2cda03[_0x39e11d[_0x1a8c('0x2f')]]={'$like':'%'+_0x48c8eb[_0x1a8c('0x37')][_0x1a8c('0x42')]+'%'};return _0x2cda03;}})});}_0x3a444a=_[_0x1a8c('0x44')]({},_0x3a444a,_0x48c8eb['options']);var _0x117305={'where':_0x3a444a[_0x1a8c('0x43')]};return db[_0x1a8c('0x33')][_0x1a8c('0x28')](_0x117305)[_0x1a8c('0x1a')](function(_0x3ba2ca){_0x3b1ec1[_0x1a8c('0x28')]=_0x3ba2ca;if(_0x48c8eb[_0x1a8c('0x37')][_0x1a8c('0x45')]){_0x3a444a[_0x1a8c('0x46')]=[{'all':!![]}];}return db['SugarcrmConfiguration'][_0x1a8c('0x47')](_0x3a444a);})[_0x1a8c('0x1a')](function(_0x2b8ab4){_0x3b1ec1[_0x1a8c('0x48')]=_0x2b8ab4;return _0x3b1ec1;})[_0x1a8c('0x1a')](respondWithFilteredResult(_0x407216,_0x3a444a))[_0x1a8c('0x23')](handleError(_0x407216,null));};exports[_0x1a8c('0x49')]=function(_0x2b3cf4,_0x3e18e9){var _0x460730={'raw':![],'where':{'id':_0x2b3cf4[_0x1a8c('0x4a')]['id']}},_0x218719={};_0x218719['model']=_[_0x1a8c('0x38')](db[_0x1a8c('0x33')][_0x1a8c('0x34')]);_0x218719[_0x1a8c('0x37')]=_[_0x1a8c('0x38')](_0x2b3cf4['query']);_0x218719['filters']=_[_0x1a8c('0x3a')](_0x218719[_0x1a8c('0x3b')],_0x218719[_0x1a8c('0x37')]);_0x460730[_0x1a8c('0x3c')]=_['intersection'](_0x218719[_0x1a8c('0x3b')],qs[_0x1a8c('0x3d')](_0x2b3cf4[_0x1a8c('0x37')][_0x1a8c('0x3d')]));_0x460730[_0x1a8c('0x3c')]=_0x460730[_0x1a8c('0x3c')][_0x1a8c('0x3e')]?_0x460730['attributes']:_0x218719['model'];if(_0x2b3cf4[_0x1a8c('0x37')]['includeAll']){_0x460730[_0x1a8c('0x46')]=[{'all':!![]}];}_0x460730=_[_0x1a8c('0x44')]({},_0x460730,_0x2b3cf4['options']);return db[_0x1a8c('0x33')][_0x1a8c('0x4b')](_0x460730)[_0x1a8c('0x1a')](handleEntityNotFound(_0x3e18e9,null))['then'](respondWithResult(_0x3e18e9,null))[_0x1a8c('0x23')](handleError(_0x3e18e9,null));};exports[_0x1a8c('0x4c')]=function(_0x3e8585,_0x2249fb){return db['SugarcrmConfiguration'][_0x1a8c('0x4c')](_0x3e8585['body'],{})['then'](respondWithResult(_0x2249fb,0xc9))[_0x1a8c('0x23')](handleError(_0x2249fb,null));};exports[_0x1a8c('0x4d')]=function(_0x45855f,_0x3e3518){if(_0x45855f[_0x1a8c('0x4e')]['id']){delete _0x45855f['body']['id'];}return db[_0x1a8c('0x33')][_0x1a8c('0x4b')]({'where':{'id':_0x45855f['params']['id']}})[_0x1a8c('0x1a')](handleEntityNotFound(_0x3e3518,null))[_0x1a8c('0x1a')](saveUpdates(_0x45855f[_0x1a8c('0x4e')],null))[_0x1a8c('0x1a')](respondWithResult(_0x3e3518,null))['catch'](handleError(_0x3e3518,null));};exports[_0x1a8c('0x2e')]=function(_0x247705,_0x6c2ba1){return db[_0x1a8c('0x33')][_0x1a8c('0x4b')]({'where':{'id':_0x247705[_0x1a8c('0x4a')]['id']}})[_0x1a8c('0x1a')](handleEntityNotFound(_0x6c2ba1,null))[_0x1a8c('0x1a')](removeEntity(_0x6c2ba1,null))[_0x1a8c('0x23')](handleError(_0x6c2ba1,null));};exports['getFields']=function(_0x2ffdae,_0x3476f0,_0x5f1f89){var _0x36a3b5={};var _0x30baa8={};var _0x2e950a;var _0x314f2a;return db[_0x1a8c('0x33')][_0x1a8c('0x4f')]({'where':{'id':_0x2ffdae[_0x1a8c('0x4a')]['id']}})[_0x1a8c('0x1a')](handleEntityNotFound(_0x3476f0,null))[_0x1a8c('0x1a')](function(_0x184ad9){if(_0x184ad9){_0x2e950a=_0x184ad9;_0x30baa8['model']=_[_0x1a8c('0x38')](db[_0x1a8c('0x50')]['rawAttributes']);_0x30baa8[_0x1a8c('0x37')]=_[_0x1a8c('0x38')](_0x2ffdae[_0x1a8c('0x37')]);_0x30baa8[_0x1a8c('0x39')]=_[_0x1a8c('0x3a')](_0x30baa8[_0x1a8c('0x3b')],_0x30baa8[_0x1a8c('0x37')]);_0x36a3b5[_0x1a8c('0x3c')]=_[_0x1a8c('0x3a')](_0x30baa8['model'],qs[_0x1a8c('0x3d')](_0x2ffdae[_0x1a8c('0x37')][_0x1a8c('0x3d')]));_0x36a3b5['attributes']=_0x36a3b5['attributes'][_0x1a8c('0x3e')]?_0x36a3b5[_0x1a8c('0x3c')]:_0x30baa8[_0x1a8c('0x3b')];_0x36a3b5[_0x1a8c('0x40')]=qs['sort'](_0x2ffdae[_0x1a8c('0x37')][_0x1a8c('0x41')]);_0x36a3b5[_0x1a8c('0x43')]=qs['filters'](_[_0x1a8c('0x51')](_0x2ffdae[_0x1a8c('0x37')],_0x30baa8[_0x1a8c('0x39')]));if(_0x2ffdae[_0x1a8c('0x37')][_0x1a8c('0x42')]){_0x36a3b5[_0x1a8c('0x43')]=_[_0x1a8c('0x44')](_0x36a3b5[_0x1a8c('0x43')],{'$or':_[_0x1a8c('0x32')](_0x36a3b5[_0x1a8c('0x3c')],function(_0x1186c5){var _0x45ba91={};_0x45ba91[_0x1186c5]={'$like':'%'+_0x2ffdae['query'][_0x1a8c('0x42')]+'%'};return _0x45ba91;})});}_0x36a3b5=_[_0x1a8c('0x44')]({},_0x36a3b5,_0x2ffdae[_0x1a8c('0x52')]);return _0x2e950a[_0x1a8c('0x53')](_0x36a3b5);}})[_0x1a8c('0x1a')](function(_0x9f9d8f){if(_0x9f9d8f){_0x314f2a=_0x9f9d8f[_0x1a8c('0x3e')];if(!_0x2ffdae[_0x1a8c('0x37')][_0x1a8c('0x3f')](_0x1a8c('0x54'))){_0x36a3b5[_0x1a8c('0x2a')]=qs[_0x1a8c('0x2a')](_0x2ffdae[_0x1a8c('0x37')][_0x1a8c('0x2a')]);_0x36a3b5['offset']=qs['offset'](_0x2ffdae['query']['offset']);}return _0x2e950a[_0x1a8c('0x53')](_0x36a3b5);}})[_0x1a8c('0x1a')](function(_0x5c69a4){if(_0x5c69a4){return _0x5c69a4?{'count':_0x314f2a,'rows':_0x5c69a4}:null;}})[_0x1a8c('0x1a')](respondWithResult(_0x3476f0,null))[_0x1a8c('0x23')](handleError(_0x3476f0,null));};exports['getSubjects']=function(_0x1df5d6,_0x4e9d47,_0x3dbf25){var _0x523bb1={};var _0x70b8d={};var _0x26ee68;var _0x375adf;return db[_0x1a8c('0x33')][_0x1a8c('0x4f')]({'where':{'id':_0x1df5d6[_0x1a8c('0x4a')]['id']}})[_0x1a8c('0x1a')](handleEntityNotFound(_0x4e9d47,null))[_0x1a8c('0x1a')](function(_0x29d086){if(_0x29d086){_0x26ee68=_0x29d086;_0x70b8d['model']=_[_0x1a8c('0x38')](db[_0x1a8c('0x50')][_0x1a8c('0x34')]);_0x70b8d[_0x1a8c('0x37')]=_['keys'](_0x1df5d6[_0x1a8c('0x37')]);_0x70b8d['filters']=_[_0x1a8c('0x3a')](_0x70b8d['model'],_0x70b8d[_0x1a8c('0x37')]);_0x523bb1['attributes']=_[_0x1a8c('0x3a')](_0x70b8d[_0x1a8c('0x3b')],qs[_0x1a8c('0x3d')](_0x1df5d6['query'][_0x1a8c('0x3d')]));_0x523bb1[_0x1a8c('0x3c')]=_0x523bb1[_0x1a8c('0x3c')][_0x1a8c('0x3e')]?_0x523bb1[_0x1a8c('0x3c')]:_0x70b8d['model'];_0x523bb1[_0x1a8c('0x40')]=qs[_0x1a8c('0x41')](_0x1df5d6[_0x1a8c('0x37')][_0x1a8c('0x41')]);_0x523bb1[_0x1a8c('0x43')]=qs[_0x1a8c('0x39')](_[_0x1a8c('0x51')](_0x1df5d6[_0x1a8c('0x37')],_0x70b8d[_0x1a8c('0x39')]));if(_0x1df5d6[_0x1a8c('0x37')]['filter']){_0x523bb1[_0x1a8c('0x43')]=_['merge'](_0x523bb1[_0x1a8c('0x43')],{'$or':_[_0x1a8c('0x32')](_0x523bb1[_0x1a8c('0x3c')],function(_0x106154){var _0x55dd00={};_0x55dd00[_0x106154]={'$like':'%'+_0x1df5d6[_0x1a8c('0x37')][_0x1a8c('0x42')]+'%'};return _0x55dd00;})});}_0x523bb1=_[_0x1a8c('0x44')]({},_0x523bb1,_0x1df5d6[_0x1a8c('0x52')]);return _0x26ee68[_0x1a8c('0x55')](_0x523bb1);}})['then'](function(_0x33fe10){if(_0x33fe10){_0x375adf=_0x33fe10[_0x1a8c('0x3e')];if(!_0x1df5d6[_0x1a8c('0x37')]['hasOwnProperty'](_0x1a8c('0x54'))){_0x523bb1[_0x1a8c('0x2a')]=qs['limit'](_0x1df5d6[_0x1a8c('0x37')][_0x1a8c('0x2a')]);_0x523bb1[_0x1a8c('0x29')]=qs[_0x1a8c('0x29')](_0x1df5d6[_0x1a8c('0x37')][_0x1a8c('0x29')]);}return _0x26ee68[_0x1a8c('0x55')](_0x523bb1);}})[_0x1a8c('0x1a')](function(_0x16f3f6){if(_0x16f3f6){return _0x16f3f6?{'count':_0x375adf,'rows':_0x16f3f6}:null;}})['then'](respondWithResult(_0x4e9d47,null))[_0x1a8c('0x23')](handleError(_0x4e9d47,null));};exports[_0x1a8c('0x56')]=function(_0x3b21d1,_0x3be863,_0x4ac24d){var _0x1c18d0={};var _0x430892={};var _0x34e24f;var _0x721408;return db[_0x1a8c('0x33')][_0x1a8c('0x4f')]({'where':{'id':_0x3b21d1[_0x1a8c('0x4a')]['id']}})[_0x1a8c('0x1a')](handleEntityNotFound(_0x3be863,null))['then'](function(_0x49f327){if(_0x49f327){_0x34e24f=_0x49f327;_0x430892[_0x1a8c('0x3b')]=_[_0x1a8c('0x38')](db[_0x1a8c('0x50')]['rawAttributes']);_0x430892[_0x1a8c('0x37')]=_[_0x1a8c('0x38')](_0x3b21d1[_0x1a8c('0x37')]);_0x430892[_0x1a8c('0x39')]=_[_0x1a8c('0x3a')](_0x430892[_0x1a8c('0x3b')],_0x430892['query']);_0x1c18d0[_0x1a8c('0x3c')]=_['intersection'](_0x430892[_0x1a8c('0x3b')],qs[_0x1a8c('0x3d')](_0x3b21d1[_0x1a8c('0x37')]['fields']));_0x1c18d0[_0x1a8c('0x3c')]=_0x1c18d0[_0x1a8c('0x3c')][_0x1a8c('0x3e')]?_0x1c18d0['attributes']:_0x430892[_0x1a8c('0x3b')];_0x1c18d0[_0x1a8c('0x40')]=qs[_0x1a8c('0x41')](_0x3b21d1[_0x1a8c('0x37')][_0x1a8c('0x41')]);_0x1c18d0[_0x1a8c('0x43')]=qs[_0x1a8c('0x39')](_['pick'](_0x3b21d1[_0x1a8c('0x37')],_0x430892['filters']));if(_0x3b21d1[_0x1a8c('0x37')][_0x1a8c('0x42')]){_0x1c18d0[_0x1a8c('0x43')]=_['merge'](_0x1c18d0[_0x1a8c('0x43')],{'$or':_[_0x1a8c('0x32')](_0x1c18d0[_0x1a8c('0x3c')],function(_0x556ea5){var _0x5b56d7={};_0x5b56d7[_0x556ea5]={'$like':'%'+_0x3b21d1[_0x1a8c('0x37')]['filter']+'%'};return _0x5b56d7;})});}_0x1c18d0=_[_0x1a8c('0x44')]({},_0x1c18d0,_0x3b21d1[_0x1a8c('0x52')]);return _0x34e24f['getDescriptions'](_0x1c18d0);}})[_0x1a8c('0x1a')](function(_0x46e452){if(_0x46e452){_0x721408=_0x46e452[_0x1a8c('0x3e')];if(!_0x3b21d1[_0x1a8c('0x37')][_0x1a8c('0x3f')](_0x1a8c('0x54'))){_0x1c18d0[_0x1a8c('0x2a')]=qs[_0x1a8c('0x2a')](_0x3b21d1[_0x1a8c('0x37')]['limit']);_0x1c18d0[_0x1a8c('0x29')]=qs['offset'](_0x3b21d1[_0x1a8c('0x37')][_0x1a8c('0x29')]);}return _0x34e24f[_0x1a8c('0x56')](_0x1c18d0);}})[_0x1a8c('0x1a')](function(_0xf93b1c){if(_0xf93b1c){return _0xf93b1c?{'count':_0x721408,'rows':_0xf93b1c}:null;}})[_0x1a8c('0x1a')](respondWithResult(_0x3be863,null))['catch'](handleError(_0x3be863,null));};
\ No newline at end of file
+var _0xeebb=['fast-json-patch','request-promise','moment','bluebird','mustache','sox','to-csv','lodash','squel','jsforce','querystring','papaparse','ioredis','../../components/parsers/advancedSearch','../../config/license/hardware','api','../../config/environment','../../config/license/util','../../mysqldb','sendStatus','status','end','json','undefined','limit','count','offset','set','Content-Range','apply','save','destroy','then','error','name','send','index','map','SugarcrmConfiguration','rawAttributes','type','key','model','query','keys','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','sort','where','filter','merge','VIRTUAL','include','findAll','rows','catch','includeAll','options','find','create','body','update','params','findOne','SugarcrmField','order','pick','getFields','getSubjects','getDescriptions','eml-format','rimraf','zip-dir'];(function(_0x44adaa,_0x2188bd){var _0x55fcb8=function(_0x1c82b1){while(--_0x1c82b1){_0x44adaa['push'](_0x44adaa['shift']());}};_0x55fcb8(++_0x2188bd);}(_0xeebb,0x1d1));var _0xbeeb=function(_0x54f8a9,_0x45db5c){_0x54f8a9=_0x54f8a9-0x0;var _0x3d5cb5=_0xeebb[_0x54f8a9];return _0x3d5cb5;};'use strict';var emlformat=require(_0xbeeb('0x0'));var rimraf=require(_0xbeeb('0x1'));var zipdir=require(_0xbeeb('0x2'));var jsonpatch=require(_0xbeeb('0x3'));var rp=require(_0xbeeb('0x4'));var moment=require(_0xbeeb('0x5'));var BPromise=require(_0xbeeb('0x6'));var Mustache=require(_0xbeeb('0x7'));var util=require('util');var path=require('path');var sox=require(_0xbeeb('0x8'));var csv=require(_0xbeeb('0x9'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0xbeeb('0xa'));var squel=require(_0xbeeb('0xb'));var crypto=require('crypto');var jsforce=require(_0xbeeb('0xc'));var deskjs=require('desk.js');var toCsv=require(_0xbeeb('0x9'));var querystring=require(_0xbeeb('0xd'));var Papa=require(_0xbeeb('0xe'));var Redis=require(_0xbeeb('0xf'));var authService=require('../../components/auth/service');var qs=require('../../components/parsers/qs');var as=require(_0xbeeb('0x10'));var hardwareService=require(_0xbeeb('0x11'));var logger=require('../../config/logger')(_0xbeeb('0x12'));var utils=require('../../config/utils');var config=require(_0xbeeb('0x13'));var licenseUtil=require(_0xbeeb('0x14'));var db=require(_0xbeeb('0x15'))['db'];function respondWithStatusCode(_0x4eef0b,_0x49cf02){_0x49cf02=_0x49cf02||0xcc;return function(_0x548b61){if(_0x548b61){return _0x4eef0b[_0xbeeb('0x16')](_0x49cf02);}return _0x4eef0b[_0xbeeb('0x17')](_0x49cf02)[_0xbeeb('0x18')]();};}function respondWithResult(_0x156327,_0x46362b){_0x46362b=_0x46362b||0xc8;return function(_0x38a917){if(_0x38a917){return _0x156327['status'](_0x46362b)[_0xbeeb('0x19')](_0x38a917);}};}function respondWithFilteredResult(_0x5ddf44,_0x4a8a05){return function(_0x1b4183){if(_0x1b4183){var _0x4805db=typeof _0x4a8a05['offset']===_0xbeeb('0x1a')&&typeof _0x4a8a05[_0xbeeb('0x1b')]===_0xbeeb('0x1a');var _0x2dbd19=_0x1b4183[_0xbeeb('0x1c')];var _0x14192f=_0x4805db?0x0:_0x4a8a05[_0xbeeb('0x1d')];var _0x346350=_0x4805db?_0x1b4183[_0xbeeb('0x1c')]:_0x4a8a05['offset']+_0x4a8a05[_0xbeeb('0x1b')];var _0x2fed09;if(_0x346350>=_0x2dbd19){_0x346350=_0x2dbd19;_0x2fed09=0xc8;}else{_0x2fed09=0xce;}_0x5ddf44[_0xbeeb('0x17')](_0x2fed09);return _0x5ddf44[_0xbeeb('0x1e')](_0xbeeb('0x1f'),_0x14192f+'-'+_0x346350+'/'+_0x2dbd19)[_0xbeeb('0x19')](_0x1b4183);}return null;};}function patchUpdates(_0x50b08f){return function(_0xc8d472){try{jsonpatch[_0xbeeb('0x20')](_0xc8d472,_0x50b08f,!![]);}catch(_0x266b52){return BPromise['reject'](_0x266b52);}return _0xc8d472[_0xbeeb('0x21')]();};}function saveUpdates(_0x1b0c5a,_0x1563fb){return function(_0x368d4e){if(_0x368d4e){return _0x368d4e['update'](_0x1b0c5a)['then'](function(_0x53e2be){return _0x53e2be;});}return null;};}function removeEntity(_0x30fa87,_0x363a57){return function(_0x4e60da){if(_0x4e60da){return _0x4e60da[_0xbeeb('0x22')]()[_0xbeeb('0x23')](function(){_0x30fa87[_0xbeeb('0x17')](0xcc)[_0xbeeb('0x18')]();});}};}function handleEntityNotFound(_0x341ca2,_0x4d1f40){return function(_0xaae325){if(!_0xaae325){_0x341ca2[_0xbeeb('0x16')](0x194);}return _0xaae325;};}function handleError(_0x15592b,_0xceb495){_0xceb495=_0xceb495||0x1f4;return function(_0x421d84){logger[_0xbeeb('0x24')](_0x421d84['stack']);if(_0x421d84[_0xbeeb('0x25')]){delete _0x421d84[_0xbeeb('0x25')];}_0x15592b[_0xbeeb('0x17')](_0xceb495)[_0xbeeb('0x26')](_0x421d84);};}exports[_0xbeeb('0x27')]=function(_0x2e0c07,_0x56dcbd){var _0x4c78fc={},_0x5101e4={},_0x45b913={'count':0x0,'rows':[]};var _0x5039eb=_[_0xbeeb('0x28')](db[_0xbeeb('0x29')][_0xbeeb('0x2a')],function(_0x53849a){return{'name':_0x53849a['fieldName'],'type':_0x53849a[_0xbeeb('0x2b')][_0xbeeb('0x2c')]};});_0x5101e4[_0xbeeb('0x2d')]=_['map'](_0x5039eb,_0xbeeb('0x25'));_0x5101e4[_0xbeeb('0x2e')]=_[_0xbeeb('0x2f')](_0x2e0c07[_0xbeeb('0x2e')]);_0x5101e4[_0xbeeb('0x30')]=_[_0xbeeb('0x31')](_0x5101e4[_0xbeeb('0x2d')],_0x5101e4[_0xbeeb('0x2e')]);_0x4c78fc[_0xbeeb('0x32')]=_[_0xbeeb('0x31')](_0x5101e4[_0xbeeb('0x2d')],qs[_0xbeeb('0x33')](_0x2e0c07['query']['fields']));_0x4c78fc['attributes']=_0x4c78fc[_0xbeeb('0x32')][_0xbeeb('0x34')]?_0x4c78fc['attributes']:_0x5101e4['model'];if(!_0x2e0c07[_0xbeeb('0x2e')][_0xbeeb('0x35')](_0xbeeb('0x36'))){_0x4c78fc[_0xbeeb('0x1b')]=qs[_0xbeeb('0x1b')](_0x2e0c07[_0xbeeb('0x2e')][_0xbeeb('0x1b')]);_0x4c78fc[_0xbeeb('0x1d')]=qs[_0xbeeb('0x1d')](_0x2e0c07['query'][_0xbeeb('0x1d')]);}_0x4c78fc['order']=qs[_0xbeeb('0x37')](_0x2e0c07[_0xbeeb('0x2e')][_0xbeeb('0x37')]);_0x4c78fc[_0xbeeb('0x38')]=qs[_0xbeeb('0x30')](_['pick'](_0x2e0c07[_0xbeeb('0x2e')],_0x5101e4[_0xbeeb('0x30')]),_0x5039eb);if(_0x2e0c07[_0xbeeb('0x2e')][_0xbeeb('0x39')]){_0x4c78fc[_0xbeeb('0x38')]=_[_0xbeeb('0x3a')](_0x4c78fc[_0xbeeb('0x38')],{'$or':_[_0xbeeb('0x28')](_0x5039eb,function(_0xb0b6e8){if(_0xb0b6e8['type']!==_0xbeeb('0x3b')){var _0x19d550={};_0x19d550[_0xb0b6e8[_0xbeeb('0x25')]]={'$like':'%'+_0x2e0c07[_0xbeeb('0x2e')][_0xbeeb('0x39')]+'%'};return _0x19d550;}})});}_0x4c78fc=_[_0xbeeb('0x3a')]({},_0x4c78fc,_0x2e0c07['options']);var _0xd9cbe2={'where':_0x4c78fc[_0xbeeb('0x38')]};return db[_0xbeeb('0x29')]['count'](_0xd9cbe2)['then'](function(_0x43b7a8){_0x45b913[_0xbeeb('0x1c')]=_0x43b7a8;if(_0x2e0c07[_0xbeeb('0x2e')]['includeAll']){_0x4c78fc[_0xbeeb('0x3c')]=[{'all':!![]}];}return db[_0xbeeb('0x29')][_0xbeeb('0x3d')](_0x4c78fc);})[_0xbeeb('0x23')](function(_0x2f42d1){_0x45b913[_0xbeeb('0x3e')]=_0x2f42d1;return _0x45b913;})[_0xbeeb('0x23')](respondWithFilteredResult(_0x56dcbd,_0x4c78fc))[_0xbeeb('0x3f')](handleError(_0x56dcbd,null));};exports['show']=function(_0x196093,_0x4790ab){var _0x333251={'raw':![],'where':{'id':_0x196093['params']['id']}},_0x2f8fc5={};_0x2f8fc5[_0xbeeb('0x2d')]=_[_0xbeeb('0x2f')](db[_0xbeeb('0x29')][_0xbeeb('0x2a')]);_0x2f8fc5['query']=_[_0xbeeb('0x2f')](_0x196093[_0xbeeb('0x2e')]);_0x2f8fc5['filters']=_[_0xbeeb('0x31')](_0x2f8fc5[_0xbeeb('0x2d')],_0x2f8fc5[_0xbeeb('0x2e')]);_0x333251[_0xbeeb('0x32')]=_[_0xbeeb('0x31')](_0x2f8fc5[_0xbeeb('0x2d')],qs[_0xbeeb('0x33')](_0x196093[_0xbeeb('0x2e')][_0xbeeb('0x33')]));_0x333251[_0xbeeb('0x32')]=_0x333251[_0xbeeb('0x32')][_0xbeeb('0x34')]?_0x333251[_0xbeeb('0x32')]:_0x2f8fc5[_0xbeeb('0x2d')];if(_0x196093[_0xbeeb('0x2e')][_0xbeeb('0x40')]){_0x333251[_0xbeeb('0x3c')]=[{'all':!![]}];}_0x333251=_[_0xbeeb('0x3a')]({},_0x333251,_0x196093[_0xbeeb('0x41')]);return db[_0xbeeb('0x29')][_0xbeeb('0x42')](_0x333251)[_0xbeeb('0x23')](handleEntityNotFound(_0x4790ab,null))['then'](respondWithResult(_0x4790ab,null))[_0xbeeb('0x3f')](handleError(_0x4790ab,null));};exports[_0xbeeb('0x43')]=function(_0x4fea53,_0x332e6c){return db['SugarcrmConfiguration'][_0xbeeb('0x43')](_0x4fea53[_0xbeeb('0x44')],{})[_0xbeeb('0x23')](respondWithResult(_0x332e6c,0xc9))[_0xbeeb('0x3f')](handleError(_0x332e6c,null));};exports[_0xbeeb('0x45')]=function(_0x140638,_0x5798ef){if(_0x140638[_0xbeeb('0x44')]['id']){delete _0x140638[_0xbeeb('0x44')]['id'];}return db[_0xbeeb('0x29')][_0xbeeb('0x42')]({'where':{'id':_0x140638[_0xbeeb('0x46')]['id']}})[_0xbeeb('0x23')](handleEntityNotFound(_0x5798ef,null))['then'](saveUpdates(_0x140638['body'],null))['then'](respondWithResult(_0x5798ef,null))[_0xbeeb('0x3f')](handleError(_0x5798ef,null));};exports[_0xbeeb('0x22')]=function(_0x1b7f5d,_0x2cb3ef){return db[_0xbeeb('0x29')][_0xbeeb('0x42')]({'where':{'id':_0x1b7f5d[_0xbeeb('0x46')]['id']}})[_0xbeeb('0x23')](handleEntityNotFound(_0x2cb3ef,null))[_0xbeeb('0x23')](removeEntity(_0x2cb3ef,null))[_0xbeeb('0x3f')](handleError(_0x2cb3ef,null));};exports['getFields']=function(_0x35940a,_0x557dae,_0x40c73){var _0x2f54eb={};var _0x29579c={};var _0x25b1ef;var _0x1f8f1d;return db[_0xbeeb('0x29')][_0xbeeb('0x47')]({'where':{'id':_0x35940a[_0xbeeb('0x46')]['id']}})['then'](handleEntityNotFound(_0x557dae,null))[_0xbeeb('0x23')](function(_0x449a55){if(_0x449a55){_0x25b1ef=_0x449a55;_0x29579c['model']=_[_0xbeeb('0x2f')](db[_0xbeeb('0x48')][_0xbeeb('0x2a')]);_0x29579c[_0xbeeb('0x2e')]=_[_0xbeeb('0x2f')](_0x35940a[_0xbeeb('0x2e')]);_0x29579c[_0xbeeb('0x30')]=_['intersection'](_0x29579c[_0xbeeb('0x2d')],_0x29579c[_0xbeeb('0x2e')]);_0x2f54eb['attributes']=_[_0xbeeb('0x31')](_0x29579c[_0xbeeb('0x2d')],qs[_0xbeeb('0x33')](_0x35940a[_0xbeeb('0x2e')][_0xbeeb('0x33')]));_0x2f54eb[_0xbeeb('0x32')]=_0x2f54eb[_0xbeeb('0x32')][_0xbeeb('0x34')]?_0x2f54eb['attributes']:_0x29579c[_0xbeeb('0x2d')];_0x2f54eb[_0xbeeb('0x49')]=qs[_0xbeeb('0x37')](_0x35940a['query'][_0xbeeb('0x37')]);_0x2f54eb[_0xbeeb('0x38')]=qs['filters'](_[_0xbeeb('0x4a')](_0x35940a['query'],_0x29579c[_0xbeeb('0x30')]));if(_0x35940a[_0xbeeb('0x2e')]['filter']){_0x2f54eb[_0xbeeb('0x38')]=_['merge'](_0x2f54eb['where'],{'$or':_[_0xbeeb('0x28')](_0x2f54eb['attributes'],function(_0x201650){var _0x46658e={};_0x46658e[_0x201650]={'$like':'%'+_0x35940a['query'][_0xbeeb('0x39')]+'%'};return _0x46658e;})});}_0x2f54eb=_[_0xbeeb('0x3a')]({},_0x2f54eb,_0x35940a[_0xbeeb('0x41')]);return _0x25b1ef[_0xbeeb('0x4b')](_0x2f54eb);}})[_0xbeeb('0x23')](function(_0x491d12){if(_0x491d12){_0x1f8f1d=_0x491d12[_0xbeeb('0x34')];if(!_0x35940a[_0xbeeb('0x2e')][_0xbeeb('0x35')](_0xbeeb('0x36'))){_0x2f54eb[_0xbeeb('0x1b')]=qs[_0xbeeb('0x1b')](_0x35940a[_0xbeeb('0x2e')]['limit']);_0x2f54eb[_0xbeeb('0x1d')]=qs[_0xbeeb('0x1d')](_0x35940a[_0xbeeb('0x2e')][_0xbeeb('0x1d')]);}return _0x25b1ef[_0xbeeb('0x4b')](_0x2f54eb);}})[_0xbeeb('0x23')](function(_0x141edf){if(_0x141edf){return _0x141edf?{'count':_0x1f8f1d,'rows':_0x141edf}:null;}})[_0xbeeb('0x23')](respondWithResult(_0x557dae,null))['catch'](handleError(_0x557dae,null));};exports[_0xbeeb('0x4c')]=function(_0x1328c6,_0x270a0b,_0x29194d){var _0x635328={};var _0x502ad2={};var _0x1ac550;var _0x304200;return db[_0xbeeb('0x29')][_0xbeeb('0x47')]({'where':{'id':_0x1328c6['params']['id']}})[_0xbeeb('0x23')](handleEntityNotFound(_0x270a0b,null))[_0xbeeb('0x23')](function(_0x448617){if(_0x448617){_0x1ac550=_0x448617;_0x502ad2[_0xbeeb('0x2d')]=_[_0xbeeb('0x2f')](db[_0xbeeb('0x48')][_0xbeeb('0x2a')]);_0x502ad2[_0xbeeb('0x2e')]=_[_0xbeeb('0x2f')](_0x1328c6[_0xbeeb('0x2e')]);_0x502ad2[_0xbeeb('0x30')]=_['intersection'](_0x502ad2[_0xbeeb('0x2d')],_0x502ad2[_0xbeeb('0x2e')]);_0x635328['attributes']=_[_0xbeeb('0x31')](_0x502ad2[_0xbeeb('0x2d')],qs[_0xbeeb('0x33')](_0x1328c6[_0xbeeb('0x2e')]['fields']));_0x635328[_0xbeeb('0x32')]=_0x635328[_0xbeeb('0x32')][_0xbeeb('0x34')]?_0x635328[_0xbeeb('0x32')]:_0x502ad2[_0xbeeb('0x2d')];_0x635328[_0xbeeb('0x49')]=qs[_0xbeeb('0x37')](_0x1328c6[_0xbeeb('0x2e')][_0xbeeb('0x37')]);_0x635328[_0xbeeb('0x38')]=qs[_0xbeeb('0x30')](_[_0xbeeb('0x4a')](_0x1328c6['query'],_0x502ad2[_0xbeeb('0x30')]));if(_0x1328c6['query'][_0xbeeb('0x39')]){_0x635328['where']=_['merge'](_0x635328['where'],{'$or':_[_0xbeeb('0x28')](_0x635328[_0xbeeb('0x32')],function(_0x2ef0df){var _0x5a8f7c={};_0x5a8f7c[_0x2ef0df]={'$like':'%'+_0x1328c6['query'][_0xbeeb('0x39')]+'%'};return _0x5a8f7c;})});}_0x635328=_[_0xbeeb('0x3a')]({},_0x635328,_0x1328c6[_0xbeeb('0x41')]);return _0x1ac550[_0xbeeb('0x4c')](_0x635328);}})[_0xbeeb('0x23')](function(_0x2f2480){if(_0x2f2480){_0x304200=_0x2f2480[_0xbeeb('0x34')];if(!_0x1328c6['query'][_0xbeeb('0x35')]('nolimit')){_0x635328[_0xbeeb('0x1b')]=qs[_0xbeeb('0x1b')](_0x1328c6[_0xbeeb('0x2e')][_0xbeeb('0x1b')]);_0x635328['offset']=qs['offset'](_0x1328c6[_0xbeeb('0x2e')][_0xbeeb('0x1d')]);}return _0x1ac550['getSubjects'](_0x635328);}})['then'](function(_0x2e3604){if(_0x2e3604){return _0x2e3604?{'count':_0x304200,'rows':_0x2e3604}:null;}})[_0xbeeb('0x23')](respondWithResult(_0x270a0b,null))[_0xbeeb('0x3f')](handleError(_0x270a0b,null));};exports['getDescriptions']=function(_0x308782,_0x4db998,_0x3c5558){var _0x1a6a3c={};var _0x5d9b96={};var _0x473f2f;var _0x2b2159;return db['SugarcrmConfiguration'][_0xbeeb('0x47')]({'where':{'id':_0x308782[_0xbeeb('0x46')]['id']}})['then'](handleEntityNotFound(_0x4db998,null))[_0xbeeb('0x23')](function(_0x330292){if(_0x330292){_0x473f2f=_0x330292;_0x5d9b96[_0xbeeb('0x2d')]=_[_0xbeeb('0x2f')](db[_0xbeeb('0x48')]['rawAttributes']);_0x5d9b96['query']=_['keys'](_0x308782[_0xbeeb('0x2e')]);_0x5d9b96[_0xbeeb('0x30')]=_[_0xbeeb('0x31')](_0x5d9b96[_0xbeeb('0x2d')],_0x5d9b96[_0xbeeb('0x2e')]);_0x1a6a3c['attributes']=_[_0xbeeb('0x31')](_0x5d9b96[_0xbeeb('0x2d')],qs['fields'](_0x308782['query']['fields']));_0x1a6a3c[_0xbeeb('0x32')]=_0x1a6a3c[_0xbeeb('0x32')][_0xbeeb('0x34')]?_0x1a6a3c['attributes']:_0x5d9b96[_0xbeeb('0x2d')];_0x1a6a3c[_0xbeeb('0x49')]=qs[_0xbeeb('0x37')](_0x308782[_0xbeeb('0x2e')]['sort']);_0x1a6a3c[_0xbeeb('0x38')]=qs[_0xbeeb('0x30')](_[_0xbeeb('0x4a')](_0x308782[_0xbeeb('0x2e')],_0x5d9b96['filters']));if(_0x308782[_0xbeeb('0x2e')][_0xbeeb('0x39')]){_0x1a6a3c[_0xbeeb('0x38')]=_[_0xbeeb('0x3a')](_0x1a6a3c['where'],{'$or':_[_0xbeeb('0x28')](_0x1a6a3c[_0xbeeb('0x32')],function(_0x481cc6){var _0x94b269={};_0x94b269[_0x481cc6]={'$like':'%'+_0x308782[_0xbeeb('0x2e')][_0xbeeb('0x39')]+'%'};return _0x94b269;})});}_0x1a6a3c=_[_0xbeeb('0x3a')]({},_0x1a6a3c,_0x308782[_0xbeeb('0x41')]);return _0x473f2f[_0xbeeb('0x4d')](_0x1a6a3c);}})[_0xbeeb('0x23')](function(_0x50269e){if(_0x50269e){_0x2b2159=_0x50269e['length'];if(!_0x308782[_0xbeeb('0x2e')]['hasOwnProperty'](_0xbeeb('0x36'))){_0x1a6a3c[_0xbeeb('0x1b')]=qs['limit'](_0x308782[_0xbeeb('0x2e')][_0xbeeb('0x1b')]);_0x1a6a3c[_0xbeeb('0x1d')]=qs[_0xbeeb('0x1d')](_0x308782[_0xbeeb('0x2e')][_0xbeeb('0x1d')]);}return _0x473f2f['getDescriptions'](_0x1a6a3c);}})[_0xbeeb('0x23')](function(_0x4125be){if(_0x4125be){return _0x4125be?{'count':_0x2b2159,'rows':_0x4125be}:null;}})[_0xbeeb('0x23')](respondWithResult(_0x4db998,null))[_0xbeeb('0x3f')](handleError(_0x4db998,null));};
\ No newline at end of file