Built motion from commit c738b9ac.|2.6.25
[motion2.git] / server / api / intSugarcrmConfiguration / intSugarcrmConfiguration.controller.js
index 83d4e0f..62c6eac 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xc4df=['map','rawAttributes','fieldName','key','model','filters','intersection','attributes','query','fields','length','nolimit','sort','where','pick','filter','merge','type','options','SugarcrmConfiguration','findAll','rows','params','keys','includeAll','include','find','catch','create','body','destroy','getFields','SugarcrmField','order','findOne','getSubjects','hasOwnProperty','getDescriptions','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','util','sox','to-csv','lodash','squel','crypto','jsforce','querystring','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','../../config/utils','../../config/environment','../../config/license/util','sendStatus','status','json','offset','undefined','limit','count','set','Content-Range','apply','reject','save','update','then','stack','name','send','index'];(function(_0x51bf62,_0xb1390e){var _0x28d7fb=function(_0x11ae6c){while(--_0x11ae6c){_0x51bf62['push'](_0x51bf62['shift']());}};_0x28d7fb(++_0xb1390e);}(_0xc4df,0x1b1));var _0xfc4d=function(_0x3ff3a3,_0x55c9af){_0x3ff3a3=_0x3ff3a3-0x0;var _0x5dad07=_0xc4df[_0x3ff3a3];return _0x5dad07;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0xfc4d('0x0'));var zipdir=require(_0xfc4d('0x1'));var jsonpatch=require(_0xfc4d('0x2'));var rp=require(_0xfc4d('0x3'));var moment=require(_0xfc4d('0x4'));var BPromise=require(_0xfc4d('0x5'));var Mustache=require('mustache');var util=require(_0xfc4d('0x6'));var path=require('path');var sox=require(_0xfc4d('0x7'));var csv=require(_0xfc4d('0x8'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0xfc4d('0x9'));var squel=require(_0xfc4d('0xa'));var crypto=require(_0xfc4d('0xb'));var jsforce=require(_0xfc4d('0xc'));var deskjs=require('desk.js');var toCsv=require(_0xfc4d('0x8'));var querystring=require(_0xfc4d('0xd'));var Papa=require('papaparse');var Redis=require(_0xfc4d('0xe'));var authService=require(_0xfc4d('0xf'));var qs=require(_0xfc4d('0x10'));var as=require(_0xfc4d('0x11'));var hardwareService=require(_0xfc4d('0x12'));var logger=require(_0xfc4d('0x13'))('api');var utils=require(_0xfc4d('0x14'));var config=require(_0xfc4d('0x15'));var licenseUtil=require(_0xfc4d('0x16'));var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x4d6dfb,_0x445a02){_0x445a02=_0x445a02||0xcc;return function(_0x20cb48){if(_0x20cb48){return _0x4d6dfb[_0xfc4d('0x17')](_0x445a02);}return _0x4d6dfb[_0xfc4d('0x18')](_0x445a02)['end']();};}function respondWithResult(_0x53a435,_0x5e1d5b){_0x5e1d5b=_0x5e1d5b||0xc8;return function(_0x10f944){if(_0x10f944){return _0x53a435['status'](_0x5e1d5b)[_0xfc4d('0x19')](_0x10f944);}};}function respondWithFilteredResult(_0x177458,_0x900b31){return function(_0x1f42bb){if(_0x1f42bb){var _0x21cfa1=typeof _0x900b31[_0xfc4d('0x1a')]===_0xfc4d('0x1b')&&typeof _0x900b31[_0xfc4d('0x1c')]===_0xfc4d('0x1b');var _0x567018=_0x1f42bb[_0xfc4d('0x1d')];var _0x5ee807=_0x21cfa1?0x0:_0x900b31[_0xfc4d('0x1a')];var _0x51e355=_0x21cfa1?_0x1f42bb[_0xfc4d('0x1d')]:_0x900b31[_0xfc4d('0x1a')]+_0x900b31[_0xfc4d('0x1c')];var _0x164950;if(_0x51e355>=_0x567018){_0x51e355=_0x567018;_0x164950=0xc8;}else{_0x164950=0xce;}_0x177458[_0xfc4d('0x18')](_0x164950);return _0x177458[_0xfc4d('0x1e')](_0xfc4d('0x1f'),_0x5ee807+'-'+_0x51e355+'/'+_0x567018)[_0xfc4d('0x19')](_0x1f42bb);}return null;};}function patchUpdates(_0x2e5380){return function(_0xfa5fba){try{jsonpatch[_0xfc4d('0x20')](_0xfa5fba,_0x2e5380,!![]);}catch(_0x1f4953){return BPromise[_0xfc4d('0x21')](_0x1f4953);}return _0xfa5fba[_0xfc4d('0x22')]();};}function saveUpdates(_0x2c76ae,_0x12bd9b){return function(_0x232b4c){if(_0x232b4c){return _0x232b4c[_0xfc4d('0x23')](_0x2c76ae)[_0xfc4d('0x24')](function(_0x2f2338){return _0x2f2338;});}return null;};}function removeEntity(_0x2f029a,_0x310b46){return function(_0x21dc7a){if(_0x21dc7a){return _0x21dc7a['destroy']()[_0xfc4d('0x24')](function(){_0x2f029a[_0xfc4d('0x18')](0xcc)['end']();});}};}function handleEntityNotFound(_0x3d721e,_0x5edd79){return function(_0x4746a2){if(!_0x4746a2){_0x3d721e[_0xfc4d('0x17')](0x194);}return _0x4746a2;};}function handleError(_0x5205a4,_0x170ec4){_0x170ec4=_0x170ec4||0x1f4;return function(_0x40ed2e){logger['error'](_0x40ed2e[_0xfc4d('0x25')]);if(_0x40ed2e[_0xfc4d('0x26')]){delete _0x40ed2e[_0xfc4d('0x26')];}_0x5205a4[_0xfc4d('0x18')](_0x170ec4)[_0xfc4d('0x27')](_0x40ed2e);};}exports[_0xfc4d('0x28')]=function(_0x46a994,_0x329e81){var _0x532c99={},_0x525625={},_0x580a05={'count':0x0,'rows':[]};var _0x34894d=_[_0xfc4d('0x29')](db['SugarcrmConfiguration'][_0xfc4d('0x2a')],function(_0x20a0f){return{'name':_0x20a0f[_0xfc4d('0x2b')],'type':_0x20a0f['type'][_0xfc4d('0x2c')]};});_0x525625[_0xfc4d('0x2d')]=_[_0xfc4d('0x29')](_0x34894d,'name');_0x525625['query']=_['keys'](_0x46a994['query']);_0x525625[_0xfc4d('0x2e')]=_[_0xfc4d('0x2f')](_0x525625[_0xfc4d('0x2d')],_0x525625['query']);_0x532c99[_0xfc4d('0x30')]=_['intersection'](_0x525625[_0xfc4d('0x2d')],qs['fields'](_0x46a994[_0xfc4d('0x31')][_0xfc4d('0x32')]));_0x532c99[_0xfc4d('0x30')]=_0x532c99[_0xfc4d('0x30')][_0xfc4d('0x33')]?_0x532c99[_0xfc4d('0x30')]:_0x525625[_0xfc4d('0x2d')];if(!_0x46a994[_0xfc4d('0x31')]['hasOwnProperty'](_0xfc4d('0x34'))){_0x532c99[_0xfc4d('0x1c')]=qs['limit'](_0x46a994[_0xfc4d('0x31')]['limit']);_0x532c99['offset']=qs[_0xfc4d('0x1a')](_0x46a994[_0xfc4d('0x31')][_0xfc4d('0x1a')]);}_0x532c99['order']=qs[_0xfc4d('0x35')](_0x46a994[_0xfc4d('0x31')]['sort']);_0x532c99[_0xfc4d('0x36')]=qs['filters'](_[_0xfc4d('0x37')](_0x46a994[_0xfc4d('0x31')],_0x525625[_0xfc4d('0x2e')]),_0x34894d);if(_0x46a994[_0xfc4d('0x31')][_0xfc4d('0x38')]){_0x532c99[_0xfc4d('0x36')]=_[_0xfc4d('0x39')](_0x532c99[_0xfc4d('0x36')],{'$or':_[_0xfc4d('0x29')](_0x34894d,function(_0x27c4e8){if(_0x27c4e8[_0xfc4d('0x3a')]!=='VIRTUAL'){var _0x191b10={};_0x191b10[_0x27c4e8[_0xfc4d('0x26')]]={'$like':'%'+_0x46a994[_0xfc4d('0x31')]['filter']+'%'};return _0x191b10;}})});}_0x532c99=_[_0xfc4d('0x39')]({},_0x532c99,_0x46a994[_0xfc4d('0x3b')]);var _0x4f0eee={'where':_0x532c99[_0xfc4d('0x36')]};return db[_0xfc4d('0x3c')][_0xfc4d('0x1d')](_0x4f0eee)[_0xfc4d('0x24')](function(_0xc38396){_0x580a05[_0xfc4d('0x1d')]=_0xc38396;if(_0x46a994[_0xfc4d('0x31')]['includeAll']){_0x532c99['include']=[{'all':!![]}];}return db[_0xfc4d('0x3c')][_0xfc4d('0x3d')](_0x532c99);})['then'](function(_0xde02d6){_0x580a05[_0xfc4d('0x3e')]=_0xde02d6;return _0x580a05;})[_0xfc4d('0x24')](respondWithFilteredResult(_0x329e81,_0x532c99))['catch'](handleError(_0x329e81,null));};exports['show']=function(_0x128945,_0x74955a){var _0x2e6984={'raw':![],'where':{'id':_0x128945[_0xfc4d('0x3f')]['id']}},_0xfda4eb={};_0xfda4eb[_0xfc4d('0x2d')]=_[_0xfc4d('0x40')](db[_0xfc4d('0x3c')][_0xfc4d('0x2a')]);_0xfda4eb[_0xfc4d('0x31')]=_[_0xfc4d('0x40')](_0x128945['query']);_0xfda4eb[_0xfc4d('0x2e')]=_['intersection'](_0xfda4eb['model'],_0xfda4eb[_0xfc4d('0x31')]);_0x2e6984['attributes']=_['intersection'](_0xfda4eb[_0xfc4d('0x2d')],qs[_0xfc4d('0x32')](_0x128945[_0xfc4d('0x31')][_0xfc4d('0x32')]));_0x2e6984['attributes']=_0x2e6984[_0xfc4d('0x30')][_0xfc4d('0x33')]?_0x2e6984[_0xfc4d('0x30')]:_0xfda4eb[_0xfc4d('0x2d')];if(_0x128945['query'][_0xfc4d('0x41')]){_0x2e6984[_0xfc4d('0x42')]=[{'all':!![]}];}_0x2e6984=_['merge']({},_0x2e6984,_0x128945[_0xfc4d('0x3b')]);return db[_0xfc4d('0x3c')][_0xfc4d('0x43')](_0x2e6984)[_0xfc4d('0x24')](handleEntityNotFound(_0x74955a,null))[_0xfc4d('0x24')](respondWithResult(_0x74955a,null))[_0xfc4d('0x44')](handleError(_0x74955a,null));};exports['create']=function(_0x49c2b7,_0x4b6f09){return db[_0xfc4d('0x3c')][_0xfc4d('0x45')](_0x49c2b7['body'],{})[_0xfc4d('0x24')](respondWithResult(_0x4b6f09,0xc9))[_0xfc4d('0x44')](handleError(_0x4b6f09,null));};exports[_0xfc4d('0x23')]=function(_0x4525e0,_0x43df6b){if(_0x4525e0[_0xfc4d('0x46')]['id']){delete _0x4525e0[_0xfc4d('0x46')]['id'];}return db[_0xfc4d('0x3c')][_0xfc4d('0x43')]({'where':{'id':_0x4525e0['params']['id']}})['then'](handleEntityNotFound(_0x43df6b,null))[_0xfc4d('0x24')](saveUpdates(_0x4525e0[_0xfc4d('0x46')],null))[_0xfc4d('0x24')](respondWithResult(_0x43df6b,null))[_0xfc4d('0x44')](handleError(_0x43df6b,null));};exports[_0xfc4d('0x47')]=function(_0x591e62,_0x4fd8a8){return db[_0xfc4d('0x3c')][_0xfc4d('0x43')]({'where':{'id':_0x591e62[_0xfc4d('0x3f')]['id']}})[_0xfc4d('0x24')](handleEntityNotFound(_0x4fd8a8,null))[_0xfc4d('0x24')](removeEntity(_0x4fd8a8,null))[_0xfc4d('0x44')](handleError(_0x4fd8a8,null));};exports[_0xfc4d('0x48')]=function(_0x525055,_0x219ba9,_0x5802af){var _0x55c96f={};var _0x44cf69={};var _0x358f5b;var _0x42d342;return db[_0xfc4d('0x3c')]['findOne']({'where':{'id':_0x525055[_0xfc4d('0x3f')]['id']}})[_0xfc4d('0x24')](handleEntityNotFound(_0x219ba9,null))['then'](function(_0x10b22e){if(_0x10b22e){_0x358f5b=_0x10b22e;_0x44cf69['model']=_[_0xfc4d('0x40')](db[_0xfc4d('0x49')][_0xfc4d('0x2a')]);_0x44cf69[_0xfc4d('0x31')]=_[_0xfc4d('0x40')](_0x525055[_0xfc4d('0x31')]);_0x44cf69[_0xfc4d('0x2e')]=_[_0xfc4d('0x2f')](_0x44cf69[_0xfc4d('0x2d')],_0x44cf69[_0xfc4d('0x31')]);_0x55c96f[_0xfc4d('0x30')]=_[_0xfc4d('0x2f')](_0x44cf69[_0xfc4d('0x2d')],qs[_0xfc4d('0x32')](_0x525055[_0xfc4d('0x31')][_0xfc4d('0x32')]));_0x55c96f[_0xfc4d('0x30')]=_0x55c96f[_0xfc4d('0x30')][_0xfc4d('0x33')]?_0x55c96f[_0xfc4d('0x30')]:_0x44cf69[_0xfc4d('0x2d')];_0x55c96f[_0xfc4d('0x4a')]=qs[_0xfc4d('0x35')](_0x525055[_0xfc4d('0x31')][_0xfc4d('0x35')]);_0x55c96f['where']=qs[_0xfc4d('0x2e')](_[_0xfc4d('0x37')](_0x525055[_0xfc4d('0x31')],_0x44cf69['filters']));if(_0x525055[_0xfc4d('0x31')][_0xfc4d('0x38')]){_0x55c96f[_0xfc4d('0x36')]=_[_0xfc4d('0x39')](_0x55c96f['where'],{'$or':_[_0xfc4d('0x29')](_0x55c96f[_0xfc4d('0x30')],function(_0x5e88f9){var _0x2a2f26={};_0x2a2f26[_0x5e88f9]={'$like':'%'+_0x525055[_0xfc4d('0x31')][_0xfc4d('0x38')]+'%'};return _0x2a2f26;})});}_0x55c96f=_[_0xfc4d('0x39')]({},_0x55c96f,_0x525055[_0xfc4d('0x3b')]);return _0x358f5b['getFields'](_0x55c96f);}})[_0xfc4d('0x24')](function(_0x54cb44){if(_0x54cb44){_0x42d342=_0x54cb44[_0xfc4d('0x33')];if(!_0x525055[_0xfc4d('0x31')]['hasOwnProperty']('nolimit')){_0x55c96f['limit']=qs['limit'](_0x525055[_0xfc4d('0x31')][_0xfc4d('0x1c')]);_0x55c96f[_0xfc4d('0x1a')]=qs[_0xfc4d('0x1a')](_0x525055[_0xfc4d('0x31')][_0xfc4d('0x1a')]);}return _0x358f5b[_0xfc4d('0x48')](_0x55c96f);}})[_0xfc4d('0x24')](function(_0x3611b4){if(_0x3611b4){return _0x3611b4?{'count':_0x42d342,'rows':_0x3611b4}:null;}})[_0xfc4d('0x24')](respondWithResult(_0x219ba9,null))[_0xfc4d('0x44')](handleError(_0x219ba9,null));};exports['getSubjects']=function(_0x221797,_0x742ac7,_0x10e428){var _0x102d85={};var _0x5d7d42={};var _0x18feef;var _0x5b0209;return db[_0xfc4d('0x3c')][_0xfc4d('0x4b')]({'where':{'id':_0x221797[_0xfc4d('0x3f')]['id']}})[_0xfc4d('0x24')](handleEntityNotFound(_0x742ac7,null))[_0xfc4d('0x24')](function(_0x2b1ff3){if(_0x2b1ff3){_0x18feef=_0x2b1ff3;_0x5d7d42[_0xfc4d('0x2d')]=_['keys'](db[_0xfc4d('0x49')][_0xfc4d('0x2a')]);_0x5d7d42['query']=_['keys'](_0x221797[_0xfc4d('0x31')]);_0x5d7d42[_0xfc4d('0x2e')]=_[_0xfc4d('0x2f')](_0x5d7d42[_0xfc4d('0x2d')],_0x5d7d42[_0xfc4d('0x31')]);_0x102d85[_0xfc4d('0x30')]=_[_0xfc4d('0x2f')](_0x5d7d42['model'],qs[_0xfc4d('0x32')](_0x221797[_0xfc4d('0x31')]['fields']));_0x102d85[_0xfc4d('0x30')]=_0x102d85[_0xfc4d('0x30')][_0xfc4d('0x33')]?_0x102d85[_0xfc4d('0x30')]:_0x5d7d42['model'];_0x102d85[_0xfc4d('0x4a')]=qs[_0xfc4d('0x35')](_0x221797[_0xfc4d('0x31')][_0xfc4d('0x35')]);_0x102d85['where']=qs['filters'](_[_0xfc4d('0x37')](_0x221797[_0xfc4d('0x31')],_0x5d7d42[_0xfc4d('0x2e')]));if(_0x221797[_0xfc4d('0x31')]['filter']){_0x102d85[_0xfc4d('0x36')]=_[_0xfc4d('0x39')](_0x102d85[_0xfc4d('0x36')],{'$or':_['map'](_0x102d85[_0xfc4d('0x30')],function(_0x371b58){var _0x50ea4c={};_0x50ea4c[_0x371b58]={'$like':'%'+_0x221797[_0xfc4d('0x31')][_0xfc4d('0x38')]+'%'};return _0x50ea4c;})});}_0x102d85=_['merge']({},_0x102d85,_0x221797[_0xfc4d('0x3b')]);return _0x18feef[_0xfc4d('0x4c')](_0x102d85);}})[_0xfc4d('0x24')](function(_0x4f30b5){if(_0x4f30b5){_0x5b0209=_0x4f30b5['length'];if(!_0x221797[_0xfc4d('0x31')][_0xfc4d('0x4d')](_0xfc4d('0x34'))){_0x102d85['limit']=qs[_0xfc4d('0x1c')](_0x221797['query']['limit']);_0x102d85['offset']=qs['offset'](_0x221797[_0xfc4d('0x31')]['offset']);}return _0x18feef[_0xfc4d('0x4c')](_0x102d85);}})['then'](function(_0x4681a6){if(_0x4681a6){return _0x4681a6?{'count':_0x5b0209,'rows':_0x4681a6}:null;}})[_0xfc4d('0x24')](respondWithResult(_0x742ac7,null))[_0xfc4d('0x44')](handleError(_0x742ac7,null));};exports['getDescriptions']=function(_0x49ed79,_0x283bbc,_0x558c11){var _0x32eb5c={};var _0x290699={};var _0x281ea3;var _0x2ed171;return db['SugarcrmConfiguration'][_0xfc4d('0x4b')]({'where':{'id':_0x49ed79[_0xfc4d('0x3f')]['id']}})[_0xfc4d('0x24')](handleEntityNotFound(_0x283bbc,null))[_0xfc4d('0x24')](function(_0x29fb55){if(_0x29fb55){_0x281ea3=_0x29fb55;_0x290699[_0xfc4d('0x2d')]=_[_0xfc4d('0x40')](db['SugarcrmField'][_0xfc4d('0x2a')]);_0x290699[_0xfc4d('0x31')]=_[_0xfc4d('0x40')](_0x49ed79[_0xfc4d('0x31')]);_0x290699[_0xfc4d('0x2e')]=_[_0xfc4d('0x2f')](_0x290699[_0xfc4d('0x2d')],_0x290699['query']);_0x32eb5c['attributes']=_[_0xfc4d('0x2f')](_0x290699[_0xfc4d('0x2d')],qs[_0xfc4d('0x32')](_0x49ed79[_0xfc4d('0x31')]['fields']));_0x32eb5c[_0xfc4d('0x30')]=_0x32eb5c[_0xfc4d('0x30')][_0xfc4d('0x33')]?_0x32eb5c[_0xfc4d('0x30')]:_0x290699[_0xfc4d('0x2d')];_0x32eb5c['order']=qs[_0xfc4d('0x35')](_0x49ed79[_0xfc4d('0x31')]['sort']);_0x32eb5c[_0xfc4d('0x36')]=qs['filters'](_[_0xfc4d('0x37')](_0x49ed79[_0xfc4d('0x31')],_0x290699[_0xfc4d('0x2e')]));if(_0x49ed79['query'][_0xfc4d('0x38')]){_0x32eb5c[_0xfc4d('0x36')]=_[_0xfc4d('0x39')](_0x32eb5c['where'],{'$or':_[_0xfc4d('0x29')](_0x32eb5c[_0xfc4d('0x30')],function(_0x14f528){var _0x1d5ca5={};_0x1d5ca5[_0x14f528]={'$like':'%'+_0x49ed79[_0xfc4d('0x31')][_0xfc4d('0x38')]+'%'};return _0x1d5ca5;})});}_0x32eb5c=_['merge']({},_0x32eb5c,_0x49ed79[_0xfc4d('0x3b')]);return _0x281ea3[_0xfc4d('0x4e')](_0x32eb5c);}})[_0xfc4d('0x24')](function(_0x4d558d){if(_0x4d558d){_0x2ed171=_0x4d558d[_0xfc4d('0x33')];if(!_0x49ed79['query'][_0xfc4d('0x4d')](_0xfc4d('0x34'))){_0x32eb5c[_0xfc4d('0x1c')]=qs[_0xfc4d('0x1c')](_0x49ed79[_0xfc4d('0x31')][_0xfc4d('0x1c')]);_0x32eb5c[_0xfc4d('0x1a')]=qs[_0xfc4d('0x1a')](_0x49ed79[_0xfc4d('0x31')][_0xfc4d('0x1a')]);}return _0x281ea3['getDescriptions'](_0x32eb5c);}})[_0xfc4d('0x24')](function(_0x586f44){if(_0x586f44){return _0x586f44?{'count':_0x2ed171,'rows':_0x586f44}:null;}})[_0xfc4d('0x24')](respondWithResult(_0x283bbc,null))[_0xfc4d('0x44')](handleError(_0x283bbc,null));};
\ No newline at end of file
+var _0xdf65=['squel','crypto','jsforce','querystring','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../mysqldb','sendStatus','end','json','offset','undefined','limit','count','Content-Range','apply','save','update','destroy','status','error','stack','name','send','index','SugarcrmConfiguration','fieldName','type','key','model','map','keys','filters','intersection','query','attributes','length','hasOwnProperty','nolimit','order','sort','where','pick','filter','VIRTUAL','merge','then','include','findAll','rows','show','params','rawAttributes','fields','includeAll','options','find','create','body','catch','getFields','findOne','SugarcrmField','getSubjects','getDescriptions','eml-format','zip-dir','fast-json-patch','request-promise','moment','util','path','sox','to-csv','ejs','fs-extra'];(function(_0xf3bf0b,_0x5c17ed){var _0x3e5c44=function(_0x111dd6){while(--_0x111dd6){_0xf3bf0b['push'](_0xf3bf0b['shift']());}};_0x3e5c44(++_0x5c17ed);}(_0xdf65,0x13d));var _0x5df6=function(_0x115149,_0x1fca9e){_0x115149=_0x115149-0x0;var _0x2a91dc=_0xdf65[_0x115149];return _0x2a91dc;};'use strict';var emlformat=require(_0x5df6('0x0'));var rimraf=require('rimraf');var zipdir=require(_0x5df6('0x1'));var jsonpatch=require(_0x5df6('0x2'));var rp=require(_0x5df6('0x3'));var moment=require(_0x5df6('0x4'));var BPromise=require('bluebird');var Mustache=require('mustache');var util=require(_0x5df6('0x5'));var path=require(_0x5df6('0x6'));var sox=require(_0x5df6('0x7'));var csv=require(_0x5df6('0x8'));var ejs=require(_0x5df6('0x9'));var fs=require('fs');var fs_extra=require(_0x5df6('0xa'));var _=require('lodash');var squel=require(_0x5df6('0xb'));var crypto=require(_0x5df6('0xc'));var jsforce=require(_0x5df6('0xd'));var deskjs=require('desk.js');var toCsv=require(_0x5df6('0x8'));var querystring=require(_0x5df6('0xe'));var Papa=require('papaparse');var Redis=require('ioredis');var authService=require(_0x5df6('0xf'));var qs=require(_0x5df6('0x10'));var as=require(_0x5df6('0x11'));var hardwareService=require(_0x5df6('0x12'));var logger=require(_0x5df6('0x13'))(_0x5df6('0x14'));var utils=require(_0x5df6('0x15'));var config=require(_0x5df6('0x16'));var licenseUtil=require('../../config/license/util');var db=require(_0x5df6('0x17'))['db'];function respondWithStatusCode(_0x10cf4f,_0xd8be85){_0xd8be85=_0xd8be85||0xcc;return function(_0x577f2a){if(_0x577f2a){return _0x10cf4f[_0x5df6('0x18')](_0xd8be85);}return _0x10cf4f['status'](_0xd8be85)[_0x5df6('0x19')]();};}function respondWithResult(_0x220aaa,_0x3b4c45){_0x3b4c45=_0x3b4c45||0xc8;return function(_0x50862c){if(_0x50862c){return _0x220aaa['status'](_0x3b4c45)[_0x5df6('0x1a')](_0x50862c);}};}function respondWithFilteredResult(_0x3aa495,_0x3ff0ad){return function(_0x4d2aa7){if(_0x4d2aa7){var _0x5281fb=typeof _0x3ff0ad[_0x5df6('0x1b')]===_0x5df6('0x1c')&&typeof _0x3ff0ad[_0x5df6('0x1d')]===_0x5df6('0x1c');var _0x339f70=_0x4d2aa7[_0x5df6('0x1e')];var _0x3827f7=_0x5281fb?0x0:_0x3ff0ad['offset'];var _0x38adc1=_0x5281fb?_0x4d2aa7['count']:_0x3ff0ad[_0x5df6('0x1b')]+_0x3ff0ad[_0x5df6('0x1d')];var _0x2e5de3;if(_0x38adc1>=_0x339f70){_0x38adc1=_0x339f70;_0x2e5de3=0xc8;}else{_0x2e5de3=0xce;}_0x3aa495['status'](_0x2e5de3);return _0x3aa495['set'](_0x5df6('0x1f'),_0x3827f7+'-'+_0x38adc1+'/'+_0x339f70)[_0x5df6('0x1a')](_0x4d2aa7);}return null;};}function patchUpdates(_0x5b3358){return function(_0x345ccc){try{jsonpatch[_0x5df6('0x20')](_0x345ccc,_0x5b3358,!![]);}catch(_0x55a71b){return BPromise['reject'](_0x55a71b);}return _0x345ccc[_0x5df6('0x21')]();};}function saveUpdates(_0x200dee,_0x19927b){return function(_0x439570){if(_0x439570){return _0x439570[_0x5df6('0x22')](_0x200dee)['then'](function(_0x338f5b){return _0x338f5b;});}return null;};}function removeEntity(_0x5851e2,_0x398539){return function(_0x2388e9){if(_0x2388e9){return _0x2388e9[_0x5df6('0x23')]()['then'](function(){_0x5851e2[_0x5df6('0x24')](0xcc)[_0x5df6('0x19')]();});}};}function handleEntityNotFound(_0x332a76,_0x242847){return function(_0x4ffbd7){if(!_0x4ffbd7){_0x332a76[_0x5df6('0x18')](0x194);}return _0x4ffbd7;};}function handleError(_0x3e61fd,_0x176495){_0x176495=_0x176495||0x1f4;return function(_0x13fbb8){logger[_0x5df6('0x25')](_0x13fbb8[_0x5df6('0x26')]);if(_0x13fbb8[_0x5df6('0x27')]){delete _0x13fbb8[_0x5df6('0x27')];}_0x3e61fd[_0x5df6('0x24')](_0x176495)[_0x5df6('0x28')](_0x13fbb8);};}exports[_0x5df6('0x29')]=function(_0x37f490,_0x60d6c8){var _0x1a4642={},_0x35a545={},_0x327f69={'count':0x0,'rows':[]};var _0x3d1dd7=_['map'](db[_0x5df6('0x2a')]['rawAttributes'],function(_0x516aea){return{'name':_0x516aea[_0x5df6('0x2b')],'type':_0x516aea[_0x5df6('0x2c')][_0x5df6('0x2d')]};});_0x35a545[_0x5df6('0x2e')]=_[_0x5df6('0x2f')](_0x3d1dd7,_0x5df6('0x27'));_0x35a545['query']=_[_0x5df6('0x30')](_0x37f490['query']);_0x35a545[_0x5df6('0x31')]=_[_0x5df6('0x32')](_0x35a545[_0x5df6('0x2e')],_0x35a545[_0x5df6('0x33')]);_0x1a4642[_0x5df6('0x34')]=_['intersection'](_0x35a545[_0x5df6('0x2e')],qs['fields'](_0x37f490['query']['fields']));_0x1a4642[_0x5df6('0x34')]=_0x1a4642[_0x5df6('0x34')][_0x5df6('0x35')]?_0x1a4642[_0x5df6('0x34')]:_0x35a545[_0x5df6('0x2e')];if(!_0x37f490[_0x5df6('0x33')][_0x5df6('0x36')](_0x5df6('0x37'))){_0x1a4642['limit']=qs[_0x5df6('0x1d')](_0x37f490['query'][_0x5df6('0x1d')]);_0x1a4642[_0x5df6('0x1b')]=qs[_0x5df6('0x1b')](_0x37f490[_0x5df6('0x33')][_0x5df6('0x1b')]);}_0x1a4642[_0x5df6('0x38')]=qs[_0x5df6('0x39')](_0x37f490['query'][_0x5df6('0x39')]);_0x1a4642[_0x5df6('0x3a')]=qs[_0x5df6('0x31')](_[_0x5df6('0x3b')](_0x37f490['query'],_0x35a545[_0x5df6('0x31')]),_0x3d1dd7);if(_0x37f490[_0x5df6('0x33')][_0x5df6('0x3c')]){_0x1a4642['where']=_['merge'](_0x1a4642[_0x5df6('0x3a')],{'$or':_[_0x5df6('0x2f')](_0x3d1dd7,function(_0x5ed024){if(_0x5ed024['type']!==_0x5df6('0x3d')){var _0x2c5343={};_0x2c5343[_0x5ed024[_0x5df6('0x27')]]={'$like':'%'+_0x37f490['query']['filter']+'%'};return _0x2c5343;}})});}_0x1a4642=_[_0x5df6('0x3e')]({},_0x1a4642,_0x37f490['options']);var _0x1608fb={'where':_0x1a4642[_0x5df6('0x3a')]};return db[_0x5df6('0x2a')]['count'](_0x1608fb)[_0x5df6('0x3f')](function(_0x34c152){_0x327f69[_0x5df6('0x1e')]=_0x34c152;if(_0x37f490[_0x5df6('0x33')]['includeAll']){_0x1a4642[_0x5df6('0x40')]=[{'all':!![]}];}return db[_0x5df6('0x2a')][_0x5df6('0x41')](_0x1a4642);})[_0x5df6('0x3f')](function(_0x549cc8){_0x327f69[_0x5df6('0x42')]=_0x549cc8;return _0x327f69;})[_0x5df6('0x3f')](respondWithFilteredResult(_0x60d6c8,_0x1a4642))['catch'](handleError(_0x60d6c8,null));};exports[_0x5df6('0x43')]=function(_0x49cf39,_0x52769c){var _0x5d6a66={'raw':![],'where':{'id':_0x49cf39[_0x5df6('0x44')]['id']}},_0x7f9d2={};_0x7f9d2[_0x5df6('0x2e')]=_[_0x5df6('0x30')](db['SugarcrmConfiguration'][_0x5df6('0x45')]);_0x7f9d2[_0x5df6('0x33')]=_[_0x5df6('0x30')](_0x49cf39['query']);_0x7f9d2[_0x5df6('0x31')]=_[_0x5df6('0x32')](_0x7f9d2['model'],_0x7f9d2[_0x5df6('0x33')]);_0x5d6a66['attributes']=_[_0x5df6('0x32')](_0x7f9d2[_0x5df6('0x2e')],qs[_0x5df6('0x46')](_0x49cf39['query']['fields']));_0x5d6a66[_0x5df6('0x34')]=_0x5d6a66[_0x5df6('0x34')]['length']?_0x5d6a66[_0x5df6('0x34')]:_0x7f9d2['model'];if(_0x49cf39['query'][_0x5df6('0x47')]){_0x5d6a66[_0x5df6('0x40')]=[{'all':!![]}];}_0x5d6a66=_[_0x5df6('0x3e')]({},_0x5d6a66,_0x49cf39[_0x5df6('0x48')]);return db[_0x5df6('0x2a')][_0x5df6('0x49')](_0x5d6a66)[_0x5df6('0x3f')](handleEntityNotFound(_0x52769c,null))[_0x5df6('0x3f')](respondWithResult(_0x52769c,null))['catch'](handleError(_0x52769c,null));};exports[_0x5df6('0x4a')]=function(_0x38e7ef,_0x2c62d7){return db[_0x5df6('0x2a')][_0x5df6('0x4a')](_0x38e7ef[_0x5df6('0x4b')],{})['then'](respondWithResult(_0x2c62d7,0xc9))[_0x5df6('0x4c')](handleError(_0x2c62d7,null));};exports[_0x5df6('0x22')]=function(_0x237f4c,_0x1a783e){if(_0x237f4c['body']['id']){delete _0x237f4c[_0x5df6('0x4b')]['id'];}return db['SugarcrmConfiguration']['find']({'where':{'id':_0x237f4c[_0x5df6('0x44')]['id']}})[_0x5df6('0x3f')](handleEntityNotFound(_0x1a783e,null))[_0x5df6('0x3f')](saveUpdates(_0x237f4c[_0x5df6('0x4b')],null))['then'](respondWithResult(_0x1a783e,null))['catch'](handleError(_0x1a783e,null));};exports[_0x5df6('0x23')]=function(_0x1edfb7,_0x4967bb){return db[_0x5df6('0x2a')][_0x5df6('0x49')]({'where':{'id':_0x1edfb7[_0x5df6('0x44')]['id']}})[_0x5df6('0x3f')](handleEntityNotFound(_0x4967bb,null))[_0x5df6('0x3f')](removeEntity(_0x4967bb,null))[_0x5df6('0x4c')](handleError(_0x4967bb,null));};exports[_0x5df6('0x4d')]=function(_0x6beec1,_0x46de68,_0x1d3feb){var _0x5dc51c={};var _0x40f2e5={};var _0x1b75cc;var _0x3ca3f5;return db[_0x5df6('0x2a')][_0x5df6('0x4e')]({'where':{'id':_0x6beec1[_0x5df6('0x44')]['id']}})[_0x5df6('0x3f')](handleEntityNotFound(_0x46de68,null))['then'](function(_0x565481){if(_0x565481){_0x1b75cc=_0x565481;_0x40f2e5[_0x5df6('0x2e')]=_[_0x5df6('0x30')](db[_0x5df6('0x4f')][_0x5df6('0x45')]);_0x40f2e5[_0x5df6('0x33')]=_[_0x5df6('0x30')](_0x6beec1[_0x5df6('0x33')]);_0x40f2e5['filters']=_[_0x5df6('0x32')](_0x40f2e5[_0x5df6('0x2e')],_0x40f2e5['query']);_0x5dc51c[_0x5df6('0x34')]=_[_0x5df6('0x32')](_0x40f2e5['model'],qs[_0x5df6('0x46')](_0x6beec1[_0x5df6('0x33')][_0x5df6('0x46')]));_0x5dc51c['attributes']=_0x5dc51c[_0x5df6('0x34')][_0x5df6('0x35')]?_0x5dc51c[_0x5df6('0x34')]:_0x40f2e5[_0x5df6('0x2e')];_0x5dc51c[_0x5df6('0x38')]=qs['sort'](_0x6beec1['query']['sort']);_0x5dc51c[_0x5df6('0x3a')]=qs[_0x5df6('0x31')](_[_0x5df6('0x3b')](_0x6beec1['query'],_0x40f2e5[_0x5df6('0x31')]));if(_0x6beec1['query'][_0x5df6('0x3c')]){_0x5dc51c[_0x5df6('0x3a')]=_[_0x5df6('0x3e')](_0x5dc51c[_0x5df6('0x3a')],{'$or':_['map'](_0x5dc51c['attributes'],function(_0x4ac672){var _0x3053c1={};_0x3053c1[_0x4ac672]={'$like':'%'+_0x6beec1[_0x5df6('0x33')][_0x5df6('0x3c')]+'%'};return _0x3053c1;})});}_0x5dc51c=_[_0x5df6('0x3e')]({},_0x5dc51c,_0x6beec1[_0x5df6('0x48')]);return _0x1b75cc[_0x5df6('0x4d')](_0x5dc51c);}})[_0x5df6('0x3f')](function(_0x348fc3){if(_0x348fc3){_0x3ca3f5=_0x348fc3['length'];if(!_0x6beec1['query'][_0x5df6('0x36')](_0x5df6('0x37'))){_0x5dc51c[_0x5df6('0x1d')]=qs[_0x5df6('0x1d')](_0x6beec1[_0x5df6('0x33')][_0x5df6('0x1d')]);_0x5dc51c[_0x5df6('0x1b')]=qs[_0x5df6('0x1b')](_0x6beec1[_0x5df6('0x33')]['offset']);}return _0x1b75cc['getFields'](_0x5dc51c);}})[_0x5df6('0x3f')](function(_0x97fffa){if(_0x97fffa){return _0x97fffa?{'count':_0x3ca3f5,'rows':_0x97fffa}:null;}})[_0x5df6('0x3f')](respondWithResult(_0x46de68,null))[_0x5df6('0x4c')](handleError(_0x46de68,null));};exports['getSubjects']=function(_0x5a189a,_0x3fd0b5,_0x390f9f){var _0x4b6237={};var _0x5e736e={};var _0x751c82;var _0xb273e;return db[_0x5df6('0x2a')][_0x5df6('0x4e')]({'where':{'id':_0x5a189a[_0x5df6('0x44')]['id']}})['then'](handleEntityNotFound(_0x3fd0b5,null))[_0x5df6('0x3f')](function(_0x41b3a7){if(_0x41b3a7){_0x751c82=_0x41b3a7;_0x5e736e[_0x5df6('0x2e')]=_[_0x5df6('0x30')](db['SugarcrmField'][_0x5df6('0x45')]);_0x5e736e[_0x5df6('0x33')]=_[_0x5df6('0x30')](_0x5a189a['query']);_0x5e736e[_0x5df6('0x31')]=_[_0x5df6('0x32')](_0x5e736e[_0x5df6('0x2e')],_0x5e736e[_0x5df6('0x33')]);_0x4b6237['attributes']=_['intersection'](_0x5e736e[_0x5df6('0x2e')],qs[_0x5df6('0x46')](_0x5a189a[_0x5df6('0x33')][_0x5df6('0x46')]));_0x4b6237[_0x5df6('0x34')]=_0x4b6237['attributes']['length']?_0x4b6237['attributes']:_0x5e736e[_0x5df6('0x2e')];_0x4b6237[_0x5df6('0x38')]=qs[_0x5df6('0x39')](_0x5a189a[_0x5df6('0x33')][_0x5df6('0x39')]);_0x4b6237['where']=qs['filters'](_[_0x5df6('0x3b')](_0x5a189a['query'],_0x5e736e[_0x5df6('0x31')]));if(_0x5a189a[_0x5df6('0x33')]['filter']){_0x4b6237['where']=_['merge'](_0x4b6237[_0x5df6('0x3a')],{'$or':_[_0x5df6('0x2f')](_0x4b6237['attributes'],function(_0x4ba447){var _0x5b8760={};_0x5b8760[_0x4ba447]={'$like':'%'+_0x5a189a[_0x5df6('0x33')][_0x5df6('0x3c')]+'%'};return _0x5b8760;})});}_0x4b6237=_[_0x5df6('0x3e')]({},_0x4b6237,_0x5a189a[_0x5df6('0x48')]);return _0x751c82[_0x5df6('0x50')](_0x4b6237);}})[_0x5df6('0x3f')](function(_0x3eebe4){if(_0x3eebe4){_0xb273e=_0x3eebe4['length'];if(!_0x5a189a[_0x5df6('0x33')]['hasOwnProperty'](_0x5df6('0x37'))){_0x4b6237[_0x5df6('0x1d')]=qs[_0x5df6('0x1d')](_0x5a189a[_0x5df6('0x33')][_0x5df6('0x1d')]);_0x4b6237[_0x5df6('0x1b')]=qs[_0x5df6('0x1b')](_0x5a189a[_0x5df6('0x33')][_0x5df6('0x1b')]);}return _0x751c82[_0x5df6('0x50')](_0x4b6237);}})[_0x5df6('0x3f')](function(_0xba102c){if(_0xba102c){return _0xba102c?{'count':_0xb273e,'rows':_0xba102c}:null;}})[_0x5df6('0x3f')](respondWithResult(_0x3fd0b5,null))[_0x5df6('0x4c')](handleError(_0x3fd0b5,null));};exports[_0x5df6('0x51')]=function(_0x27e596,_0x1597a4,_0x1641cc){var _0x3aeb80={};var _0x234c1f={};var _0x52ea14;var _0x3f06e2;return db[_0x5df6('0x2a')][_0x5df6('0x4e')]({'where':{'id':_0x27e596[_0x5df6('0x44')]['id']}})[_0x5df6('0x3f')](handleEntityNotFound(_0x1597a4,null))[_0x5df6('0x3f')](function(_0x30e721){if(_0x30e721){_0x52ea14=_0x30e721;_0x234c1f[_0x5df6('0x2e')]=_[_0x5df6('0x30')](db[_0x5df6('0x4f')]['rawAttributes']);_0x234c1f['query']=_['keys'](_0x27e596['query']);_0x234c1f['filters']=_[_0x5df6('0x32')](_0x234c1f[_0x5df6('0x2e')],_0x234c1f[_0x5df6('0x33')]);_0x3aeb80[_0x5df6('0x34')]=_[_0x5df6('0x32')](_0x234c1f['model'],qs[_0x5df6('0x46')](_0x27e596['query'][_0x5df6('0x46')]));_0x3aeb80[_0x5df6('0x34')]=_0x3aeb80['attributes'][_0x5df6('0x35')]?_0x3aeb80[_0x5df6('0x34')]:_0x234c1f['model'];_0x3aeb80[_0x5df6('0x38')]=qs[_0x5df6('0x39')](_0x27e596[_0x5df6('0x33')][_0x5df6('0x39')]);_0x3aeb80[_0x5df6('0x3a')]=qs['filters'](_['pick'](_0x27e596['query'],_0x234c1f['filters']));if(_0x27e596[_0x5df6('0x33')][_0x5df6('0x3c')]){_0x3aeb80[_0x5df6('0x3a')]=_[_0x5df6('0x3e')](_0x3aeb80[_0x5df6('0x3a')],{'$or':_[_0x5df6('0x2f')](_0x3aeb80['attributes'],function(_0x14c4f1){var _0x28fc43={};_0x28fc43[_0x14c4f1]={'$like':'%'+_0x27e596[_0x5df6('0x33')][_0x5df6('0x3c')]+'%'};return _0x28fc43;})});}_0x3aeb80=_[_0x5df6('0x3e')]({},_0x3aeb80,_0x27e596['options']);return _0x52ea14[_0x5df6('0x51')](_0x3aeb80);}})[_0x5df6('0x3f')](function(_0x49125b){if(_0x49125b){_0x3f06e2=_0x49125b[_0x5df6('0x35')];if(!_0x27e596[_0x5df6('0x33')]['hasOwnProperty'](_0x5df6('0x37'))){_0x3aeb80[_0x5df6('0x1d')]=qs[_0x5df6('0x1d')](_0x27e596[_0x5df6('0x33')]['limit']);_0x3aeb80['offset']=qs['offset'](_0x27e596[_0x5df6('0x33')][_0x5df6('0x1b')]);}return _0x52ea14[_0x5df6('0x51')](_0x3aeb80);}})[_0x5df6('0x3f')](function(_0x5504c9){if(_0x5504c9){return _0x5504c9?{'count':_0x3f06e2,'rows':_0x5504c9}:null;}})['then'](respondWithResult(_0x1597a4,null))['catch'](handleError(_0x1597a4,null));};
\ No newline at end of file