Built motion from commit 85328c08.|2.5.50
[motion2.git] / server / api / intSalesforceConfiguration / intSalesforceConfiguration.controller.js
index 889373a..c3a930b 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x31f0=['model','query','intersection','attributes','fields','length','hasOwnProperty','nolimit','sort','where','filters','pick','filter','VIRTUAL','merge','options','includeAll','include','findAll','show','params','keys','find','create','body','update','getFields','order','getSubjects','findOne','SalesforceField','getDescriptions','html-pdf','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','path','to-csv','squel','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','../../config/utils','../../mysqldb','jayson/promise','client','http','then','info','SalesforceConfiguration,\x20%s,\x20%s','debug','SalesforceConfiguration,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error','code','message','result','catch','sendStatus','status','end','json','count','offset','limit','set','Content-Range','apply','save','destroy','stack','name','send','map','SalesforceConfiguration','rawAttributes','fieldName','type','key'];(function(_0xe6894,_0x5a1755){var _0x4e2ea7=function(_0x535e0a){while(--_0x535e0a){_0xe6894['push'](_0xe6894['shift']());}};_0x4e2ea7(++_0x5a1755);}(_0x31f0,0x1f1));var _0x031f=function(_0x1f05a8,_0x195e47){_0x1f05a8=_0x1f05a8-0x0;var _0x51cb4e=_0x31f0[_0x1f05a8];return _0x51cb4e;};'use strict';var pdf=require(_0x031f('0x0'));var emlformat=require(_0x031f('0x1'));var rimraf=require(_0x031f('0x2'));var zipdir=require(_0x031f('0x3'));var jsonpatch=require(_0x031f('0x4'));var rp=require(_0x031f('0x5'));var moment=require(_0x031f('0x6'));var BPromise=require(_0x031f('0x7'));var Mustache=require(_0x031f('0x8'));var util=require('util');var path=require(_0x031f('0x9'));var sox=require('sox');var csv=require(_0x031f('0xa'));var ejs=require('ejs');var fs=require('fs');var _=require('lodash');var squel=require(_0x031f('0xb'));var crypto=require(_0x031f('0xc'));var jsforce=require(_0x031f('0xd'));var deskjs=require(_0x031f('0xe'));var toCsv=require(_0x031f('0xa'));var querystring=require(_0x031f('0xf'));var Papa=require(_0x031f('0x10'));var Redis=require(_0x031f('0x11'));var authService=require(_0x031f('0x12'));var qs=require(_0x031f('0x13'));var as=require(_0x031f('0x14'));var hardwareService=require(_0x031f('0x15'));var logger=require(_0x031f('0x16'))('api');var utils=require(_0x031f('0x17'));var config=require('../../config/environment');var licenseUtil=require('../../config/license/util');var db=require(_0x031f('0x18'))['db'];var jayson=require(_0x031f('0x19'));var client=jayson[_0x031f('0x1a')][_0x031f('0x1b')]({'port':0x232a});function respondWithRpcPromise(_0x40e594,_0x512292,_0x51cf19,_0x1b8094){return new BPromise(function(_0x33581a,_0x56553f){var _0xd67d27=_0x1b8094||client;return _0xd67d27['request'](_0x40e594,_0x51cf19)[_0x031f('0x1c')](function(_0x1ea1a8){logger[_0x031f('0x1d')](_0x031f('0x1e'),_0x512292,'request\x20sent');logger[_0x031f('0x1f')](_0x031f('0x20'),_0x512292,_0x031f('0x21'),JSON[_0x031f('0x22')](_0x1ea1a8));if(_0x1ea1a8[_0x031f('0x23')]){if(_0x1ea1a8['error'][_0x031f('0x24')]===0x1f4){logger[_0x031f('0x23')](_0x031f('0x1e'),_0x512292,_0x1ea1a8[_0x031f('0x23')][_0x031f('0x25')]);return _0x56553f(_0x1ea1a8[_0x031f('0x23')]['message']);}logger[_0x031f('0x23')]('SalesforceConfiguration,\x20%s,\x20%s',_0x512292,_0x1ea1a8[_0x031f('0x23')][_0x031f('0x25')]);return _0x33581a(_0x1ea1a8['error'][_0x031f('0x25')]);}else{logger[_0x031f('0x1d')](_0x031f('0x1e'),_0x512292,_0x031f('0x21'));_0x33581a(_0x1ea1a8[_0x031f('0x26')][_0x031f('0x25')]);}})[_0x031f('0x27')](function(_0x6cda95){logger[_0x031f('0x23')]('SalesforceConfiguration,\x20%s,\x20%s',_0x512292,_0x6cda95);_0x56553f(_0x6cda95);});});}function respondWithStatusCode(_0x41ce3d,_0xfcd9c9){_0xfcd9c9=_0xfcd9c9||0xcc;return function(_0x62c1e){if(_0x62c1e){return _0x41ce3d[_0x031f('0x28')](_0xfcd9c9);}return _0x41ce3d[_0x031f('0x29')](_0xfcd9c9)[_0x031f('0x2a')]();};}function respondWithResult(_0x41e442,_0x27ac22){_0x27ac22=_0x27ac22||0xc8;return function(_0x196cd6){if(_0x196cd6){return _0x41e442[_0x031f('0x29')](_0x27ac22)[_0x031f('0x2b')](_0x196cd6);}};}function respondWithFilteredResult(_0x2d1fd9,_0x25fbfe){return function(_0xa10fa0){if(_0xa10fa0){var _0x3de130=_0xa10fa0[_0x031f('0x2c')],_0x4bd5cb=_0x25fbfe['offset'],_0x499d4f=_0x25fbfe[_0x031f('0x2d')]+_0x25fbfe[_0x031f('0x2e')],_0x268e57;if(_0x499d4f>=_0x3de130){_0x499d4f=_0x3de130;_0x268e57=0xc8;}else{_0x268e57=0xce;}_0x2d1fd9[_0x031f('0x29')](_0x268e57);return _0x2d1fd9[_0x031f('0x2f')](_0x031f('0x30'),_0x4bd5cb+'-'+_0x499d4f+'/'+_0x3de130)[_0x031f('0x2b')](_0xa10fa0);}return null;};}function patchUpdates(_0x3def20){return function(_0x35a663){try{jsonpatch[_0x031f('0x31')](_0x35a663,_0x3def20,!![]);}catch(_0x4b47e2){return BPromise['reject'](_0x4b47e2);}return _0x35a663[_0x031f('0x32')]();};}function saveUpdates(_0x7bd8e9,_0x8ff6f4){return function(_0x2efdf7){if(_0x2efdf7){return _0x2efdf7['update'](_0x7bd8e9)[_0x031f('0x1c')](function(_0x290bf7){return _0x290bf7;});}return null;};}function removeEntity(_0x153959,_0x1e0fc1){return function(_0x34c004){if(_0x34c004){return _0x34c004[_0x031f('0x33')]()['then'](function(){_0x153959[_0x031f('0x29')](0xcc)[_0x031f('0x2a')]();});}};}function handleEntityNotFound(_0x49e585,_0x16bfc9){return function(_0x18a663){if(!_0x18a663){_0x49e585[_0x031f('0x28')](0x194);}return _0x18a663;};}function handleError(_0x2cbf96,_0xbc36b2){_0xbc36b2=_0xbc36b2||0x1f4;return function(_0x473999){logger[_0x031f('0x23')](_0x473999[_0x031f('0x34')]);if(_0x473999['name']){delete _0x473999[_0x031f('0x35')];}_0x2cbf96[_0x031f('0x29')](_0xbc36b2)[_0x031f('0x36')](_0x473999);};}exports['index']=function(_0x5beab8,_0x258c88){var _0x47b9c2={},_0x2524f2={},_0x430ce0={'count':0x0,'rows':[]};var _0x4d190c=_[_0x031f('0x37')](db[_0x031f('0x38')][_0x031f('0x39')],function(_0x4b4b27){return{'name':_0x4b4b27[_0x031f('0x3a')],'type':_0x4b4b27[_0x031f('0x3b')][_0x031f('0x3c')]};});_0x2524f2[_0x031f('0x3d')]=_[_0x031f('0x37')](_0x4d190c,_0x031f('0x35'));_0x2524f2[_0x031f('0x3e')]=_['keys'](_0x5beab8['query']);_0x2524f2['filters']=_[_0x031f('0x3f')](_0x2524f2[_0x031f('0x3d')],_0x2524f2[_0x031f('0x3e')]);_0x47b9c2[_0x031f('0x40')]=_[_0x031f('0x3f')](_0x2524f2[_0x031f('0x3d')],qs[_0x031f('0x41')](_0x5beab8[_0x031f('0x3e')]['fields']));_0x47b9c2['attributes']=_0x47b9c2[_0x031f('0x40')][_0x031f('0x42')]?_0x47b9c2['attributes']:_0x2524f2['model'];if(!_0x5beab8[_0x031f('0x3e')][_0x031f('0x43')](_0x031f('0x44'))){_0x47b9c2[_0x031f('0x2e')]=qs[_0x031f('0x2e')](_0x5beab8[_0x031f('0x3e')][_0x031f('0x2e')]);_0x47b9c2[_0x031f('0x2d')]=qs['offset'](_0x5beab8[_0x031f('0x3e')]['offset']);}_0x47b9c2['order']=qs[_0x031f('0x45')](_0x5beab8[_0x031f('0x3e')][_0x031f('0x45')]);_0x47b9c2[_0x031f('0x46')]=qs[_0x031f('0x47')](_[_0x031f('0x48')](_0x5beab8[_0x031f('0x3e')],_0x2524f2[_0x031f('0x47')]),_0x4d190c);if(_0x5beab8[_0x031f('0x3e')][_0x031f('0x49')]){_0x47b9c2[_0x031f('0x46')]=_['merge'](_0x47b9c2['where'],{'$or':_[_0x031f('0x37')](_0x4d190c,function(_0x922449){if(_0x922449[_0x031f('0x3b')]!==_0x031f('0x4a')){var _0x53c661={};_0x53c661[_0x922449[_0x031f('0x35')]]={'$like':'%'+_0x5beab8[_0x031f('0x3e')][_0x031f('0x49')]+'%'};return _0x53c661;}})});}_0x47b9c2=_[_0x031f('0x4b')]({},_0x47b9c2,_0x5beab8[_0x031f('0x4c')]);var _0x287da0={'where':_0x47b9c2[_0x031f('0x46')]};return db[_0x031f('0x38')][_0x031f('0x2c')](_0x287da0)['then'](function(_0x3f4974){_0x430ce0[_0x031f('0x2c')]=_0x3f4974;if(_0x5beab8[_0x031f('0x3e')][_0x031f('0x4d')]){_0x47b9c2[_0x031f('0x4e')]=[{'all':!![]}];}return db['SalesforceConfiguration'][_0x031f('0x4f')](_0x47b9c2);})[_0x031f('0x1c')](function(_0x4ee1e2){_0x430ce0['rows']=_0x4ee1e2;return _0x430ce0;})[_0x031f('0x1c')](respondWithFilteredResult(_0x258c88,_0x47b9c2))[_0x031f('0x27')](handleError(_0x258c88,null));};exports[_0x031f('0x50')]=function(_0x58e11d,_0xbd880d){var _0x386c2d={'raw':![],'where':{'id':_0x58e11d[_0x031f('0x51')]['id']}},_0x10c3a5={};_0x10c3a5[_0x031f('0x3d')]=_['keys'](db['SalesforceConfiguration']['rawAttributes']);_0x10c3a5[_0x031f('0x3e')]=_[_0x031f('0x52')](_0x58e11d['query']);_0x10c3a5['filters']=_[_0x031f('0x3f')](_0x10c3a5[_0x031f('0x3d')],_0x10c3a5['query']);_0x386c2d[_0x031f('0x40')]=_[_0x031f('0x3f')](_0x10c3a5['model'],qs[_0x031f('0x41')](_0x58e11d['query'][_0x031f('0x41')]));_0x386c2d[_0x031f('0x40')]=_0x386c2d[_0x031f('0x40')][_0x031f('0x42')]?_0x386c2d[_0x031f('0x40')]:_0x10c3a5[_0x031f('0x3d')];if(_0x58e11d[_0x031f('0x3e')][_0x031f('0x4d')]){_0x386c2d[_0x031f('0x4e')]=[{'all':!![]}];}_0x386c2d=_[_0x031f('0x4b')]({},_0x386c2d,_0x58e11d[_0x031f('0x4c')]);return db[_0x031f('0x38')][_0x031f('0x53')](_0x386c2d)[_0x031f('0x1c')](handleEntityNotFound(_0xbd880d,null))['then'](respondWithResult(_0xbd880d,null))[_0x031f('0x27')](handleError(_0xbd880d,null));};exports[_0x031f('0x54')]=function(_0x4cbb89,_0x11faaf){return db['SalesforceConfiguration'][_0x031f('0x54')](_0x4cbb89[_0x031f('0x55')],{})[_0x031f('0x1c')](respondWithResult(_0x11faaf,0xc9))[_0x031f('0x27')](handleError(_0x11faaf,null));};exports[_0x031f('0x56')]=function(_0x3aa7bb,_0x2c3982){if(_0x3aa7bb[_0x031f('0x55')]['id']){delete _0x3aa7bb[_0x031f('0x55')]['id'];}return db[_0x031f('0x38')]['find']({'where':{'id':_0x3aa7bb[_0x031f('0x51')]['id']}})['then'](handleEntityNotFound(_0x2c3982,null))[_0x031f('0x1c')](saveUpdates(_0x3aa7bb[_0x031f('0x55')],null))[_0x031f('0x1c')](respondWithResult(_0x2c3982,null))[_0x031f('0x27')](handleError(_0x2c3982,null));};exports[_0x031f('0x33')]=function(_0x100282,_0x40d801){return db[_0x031f('0x38')][_0x031f('0x53')]({'where':{'id':_0x100282[_0x031f('0x51')]['id']}})['then'](handleEntityNotFound(_0x40d801,null))['then'](removeEntity(_0x40d801,null))[_0x031f('0x27')](handleError(_0x40d801,null));};exports[_0x031f('0x57')]=function(_0xa26e25,_0x32e56d,_0x487471){var _0x3a0f7f={};var _0xd91846={};var _0x48bbd5;var _0x24266f;return db['SalesforceConfiguration']['findOne']({'where':{'id':_0xa26e25[_0x031f('0x51')]['id']}})[_0x031f('0x1c')](handleEntityNotFound(_0x32e56d,null))[_0x031f('0x1c')](function(_0x267a88){if(_0x267a88){_0x48bbd5=_0x267a88;_0xd91846[_0x031f('0x3d')]=_[_0x031f('0x52')](db['SalesforceField'][_0x031f('0x39')]);_0xd91846[_0x031f('0x3e')]=_[_0x031f('0x52')](_0xa26e25['query']);_0xd91846[_0x031f('0x47')]=_[_0x031f('0x3f')](_0xd91846[_0x031f('0x3d')],_0xd91846[_0x031f('0x3e')]);_0x3a0f7f[_0x031f('0x40')]=_[_0x031f('0x3f')](_0xd91846[_0x031f('0x3d')],qs[_0x031f('0x41')](_0xa26e25[_0x031f('0x3e')]['fields']));_0x3a0f7f[_0x031f('0x40')]=_0x3a0f7f[_0x031f('0x40')][_0x031f('0x42')]?_0x3a0f7f[_0x031f('0x40')]:_0xd91846['model'];_0x3a0f7f[_0x031f('0x58')]=qs[_0x031f('0x45')](_0xa26e25[_0x031f('0x3e')][_0x031f('0x45')]);_0x3a0f7f[_0x031f('0x46')]=qs[_0x031f('0x47')](_['pick'](_0xa26e25[_0x031f('0x3e')],_0xd91846[_0x031f('0x47')]));if(_0xa26e25[_0x031f('0x3e')][_0x031f('0x49')]){_0x3a0f7f['where']=_[_0x031f('0x4b')](_0x3a0f7f[_0x031f('0x46')],{'$or':_[_0x031f('0x37')](_0x3a0f7f[_0x031f('0x40')],function(_0x5db144){var _0x382a64={};_0x382a64[_0x5db144]={'$like':'%'+_0xa26e25['query']['filter']+'%'};return _0x382a64;})});}_0x3a0f7f=_[_0x031f('0x4b')]({},_0x3a0f7f,_0xa26e25['options']);return _0x48bbd5['getFields'](_0x3a0f7f);}})[_0x031f('0x1c')](function(_0xb0cd9b){if(_0xb0cd9b){_0x24266f=_0xb0cd9b[_0x031f('0x42')];if(!_0xa26e25[_0x031f('0x3e')][_0x031f('0x43')](_0x031f('0x44'))){_0x3a0f7f[_0x031f('0x2e')]=qs[_0x031f('0x2e')](_0xa26e25[_0x031f('0x3e')]['limit']);_0x3a0f7f[_0x031f('0x2d')]=qs['offset'](_0xa26e25[_0x031f('0x3e')][_0x031f('0x2d')]);}return _0x48bbd5[_0x031f('0x57')](_0x3a0f7f);}})[_0x031f('0x1c')](function(_0x3217ad){if(_0x3217ad){return _0x3217ad?{'count':_0x24266f,'rows':_0x3217ad}:null;}})[_0x031f('0x1c')](respondWithResult(_0x32e56d,null))[_0x031f('0x27')](handleError(_0x32e56d,null));};exports[_0x031f('0x59')]=function(_0x46506b,_0x2c36ca,_0x5468e9){var _0x22acfb={};var _0x329d06={};var _0x56aa1f;var _0x3a1431;return db['SalesforceConfiguration'][_0x031f('0x5a')]({'where':{'id':_0x46506b['params']['id']}})[_0x031f('0x1c')](handleEntityNotFound(_0x2c36ca,null))['then'](function(_0x2cab85){if(_0x2cab85){_0x56aa1f=_0x2cab85;_0x329d06[_0x031f('0x3d')]=_[_0x031f('0x52')](db[_0x031f('0x5b')][_0x031f('0x39')]);_0x329d06[_0x031f('0x3e')]=_[_0x031f('0x52')](_0x46506b[_0x031f('0x3e')]);_0x329d06[_0x031f('0x47')]=_[_0x031f('0x3f')](_0x329d06[_0x031f('0x3d')],_0x329d06[_0x031f('0x3e')]);_0x22acfb[_0x031f('0x40')]=_['intersection'](_0x329d06['model'],qs['fields'](_0x46506b[_0x031f('0x3e')]['fields']));_0x22acfb['attributes']=_0x22acfb[_0x031f('0x40')][_0x031f('0x42')]?_0x22acfb[_0x031f('0x40')]:_0x329d06['model'];_0x22acfb[_0x031f('0x58')]=qs['sort'](_0x46506b[_0x031f('0x3e')][_0x031f('0x45')]);_0x22acfb[_0x031f('0x46')]=qs['filters'](_[_0x031f('0x48')](_0x46506b['query'],_0x329d06[_0x031f('0x47')]));if(_0x46506b[_0x031f('0x3e')][_0x031f('0x49')]){_0x22acfb[_0x031f('0x46')]=_[_0x031f('0x4b')](_0x22acfb[_0x031f('0x46')],{'$or':_[_0x031f('0x37')](_0x22acfb[_0x031f('0x40')],function(_0x3f8184){var _0x1bf8a1={};_0x1bf8a1[_0x3f8184]={'$like':'%'+_0x46506b[_0x031f('0x3e')][_0x031f('0x49')]+'%'};return _0x1bf8a1;})});}_0x22acfb=_[_0x031f('0x4b')]({},_0x22acfb,_0x46506b[_0x031f('0x4c')]);return _0x56aa1f['getSubjects'](_0x22acfb);}})[_0x031f('0x1c')](function(_0x249c42){if(_0x249c42){_0x3a1431=_0x249c42[_0x031f('0x42')];if(!_0x46506b[_0x031f('0x3e')][_0x031f('0x43')]('nolimit')){_0x22acfb['limit']=qs[_0x031f('0x2e')](_0x46506b[_0x031f('0x3e')]['limit']);_0x22acfb['offset']=qs[_0x031f('0x2d')](_0x46506b[_0x031f('0x3e')][_0x031f('0x2d')]);}return _0x56aa1f[_0x031f('0x59')](_0x22acfb);}})['then'](function(_0x4d9de7){if(_0x4d9de7){return _0x4d9de7?{'count':_0x3a1431,'rows':_0x4d9de7}:null;}})[_0x031f('0x1c')](respondWithResult(_0x2c36ca,null))['catch'](handleError(_0x2c36ca,null));};exports['getDescriptions']=function(_0x48fbb2,_0x223e42,_0x603bfd){var _0x2f5b41={};var _0x2a3564={};var _0x5e2a3f;var _0xae96fe;return db[_0x031f('0x38')]['findOne']({'where':{'id':_0x48fbb2[_0x031f('0x51')]['id']}})[_0x031f('0x1c')](handleEntityNotFound(_0x223e42,null))[_0x031f('0x1c')](function(_0x5b3df0){if(_0x5b3df0){_0x5e2a3f=_0x5b3df0;_0x2a3564[_0x031f('0x3d')]=_[_0x031f('0x52')](db['SalesforceField']['rawAttributes']);_0x2a3564[_0x031f('0x3e')]=_[_0x031f('0x52')](_0x48fbb2[_0x031f('0x3e')]);_0x2a3564[_0x031f('0x47')]=_[_0x031f('0x3f')](_0x2a3564[_0x031f('0x3d')],_0x2a3564[_0x031f('0x3e')]);_0x2f5b41[_0x031f('0x40')]=_[_0x031f('0x3f')](_0x2a3564[_0x031f('0x3d')],qs[_0x031f('0x41')](_0x48fbb2[_0x031f('0x3e')][_0x031f('0x41')]));_0x2f5b41[_0x031f('0x40')]=_0x2f5b41[_0x031f('0x40')][_0x031f('0x42')]?_0x2f5b41['attributes']:_0x2a3564[_0x031f('0x3d')];_0x2f5b41[_0x031f('0x58')]=qs['sort'](_0x48fbb2[_0x031f('0x3e')][_0x031f('0x45')]);_0x2f5b41[_0x031f('0x46')]=qs[_0x031f('0x47')](_[_0x031f('0x48')](_0x48fbb2[_0x031f('0x3e')],_0x2a3564[_0x031f('0x47')]));if(_0x48fbb2[_0x031f('0x3e')][_0x031f('0x49')]){_0x2f5b41['where']=_[_0x031f('0x4b')](_0x2f5b41[_0x031f('0x46')],{'$or':_[_0x031f('0x37')](_0x2f5b41[_0x031f('0x40')],function(_0x46a6a3){var _0xda84cf={};_0xda84cf[_0x46a6a3]={'$like':'%'+_0x48fbb2[_0x031f('0x3e')]['filter']+'%'};return _0xda84cf;})});}_0x2f5b41=_['merge']({},_0x2f5b41,_0x48fbb2[_0x031f('0x4c')]);return _0x5e2a3f[_0x031f('0x5c')](_0x2f5b41);}})[_0x031f('0x1c')](function(_0x369441){if(_0x369441){_0xae96fe=_0x369441[_0x031f('0x42')];if(!_0x48fbb2[_0x031f('0x3e')][_0x031f('0x43')](_0x031f('0x44'))){_0x2f5b41[_0x031f('0x2e')]=qs[_0x031f('0x2e')](_0x48fbb2['query'][_0x031f('0x2e')]);_0x2f5b41[_0x031f('0x2d')]=qs[_0x031f('0x2d')](_0x48fbb2[_0x031f('0x3e')][_0x031f('0x2d')]);}return _0x5e2a3f['getDescriptions'](_0x2f5b41);}})[_0x031f('0x1c')](function(_0x143ebb){if(_0x143ebb){return _0x143ebb?{'count':_0xae96fe,'rows':_0x143ebb}:null;}})[_0x031f('0x1c')](respondWithResult(_0x223e42,null))['catch'](handleError(_0x223e42,null));};
\ No newline at end of file
+var _0x966a=['fs-extra','squel','crypto','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/environment','../../config/license/util','../../mysqldb','sendStatus','status','json','undefined','offset','set','apply','reject','update','then','destroy','error','name','send','index','SalesforceConfiguration','rawAttributes','fieldName','type','key','model','map','query','keys','intersection','fields','attributes','length','hasOwnProperty','nolimit','limit','order','sort','filters','pick','filter','merge','where','VIRTUAL','count','includeAll','findAll','rows','catch','show','params','include','options','find','create','body','getFields','findOne','SalesforceField','getSubjects','getDescriptions','eml-format','zip-dir','fast-json-patch','moment','bluebird','util','sox','to-csv'];(function(_0x3ba5a4,_0x1ab3a2){var _0x361851=function(_0x2711bb){while(--_0x2711bb){_0x3ba5a4['push'](_0x3ba5a4['shift']());}};_0x361851(++_0x1ab3a2);}(_0x966a,0x138));var _0xa966=function(_0x4f140e,_0x574bee){_0x4f140e=_0x4f140e-0x0;var _0x357343=_0x966a[_0x4f140e];return _0x357343;};'use strict';var emlformat=require(_0xa966('0x0'));var rimraf=require('rimraf');var zipdir=require(_0xa966('0x1'));var jsonpatch=require(_0xa966('0x2'));var rp=require('request-promise');var moment=require(_0xa966('0x3'));var BPromise=require(_0xa966('0x4'));var Mustache=require('mustache');var util=require(_0xa966('0x5'));var path=require('path');var sox=require(_0xa966('0x6'));var csv=require(_0xa966('0x7'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0xa966('0x8'));var _=require('lodash');var squel=require(_0xa966('0x9'));var crypto=require(_0xa966('0xa'));var jsforce=require('jsforce');var deskjs=require(_0xa966('0xb'));var toCsv=require('to-csv');var querystring=require(_0xa966('0xc'));var Papa=require(_0xa966('0xd'));var Redis=require(_0xa966('0xe'));var authService=require(_0xa966('0xf'));var qs=require(_0xa966('0x10'));var as=require(_0xa966('0x11'));var hardwareService=require(_0xa966('0x12'));var logger=require(_0xa966('0x13'))(_0xa966('0x14'));var utils=require('../../config/utils');var config=require(_0xa966('0x15'));var licenseUtil=require(_0xa966('0x16'));var db=require(_0xa966('0x17'))['db'];function respondWithStatusCode(_0x3db2cd,_0xd1da87){_0xd1da87=_0xd1da87||0xcc;return function(_0x142d18){if(_0x142d18){return _0x3db2cd[_0xa966('0x18')](_0xd1da87);}return _0x3db2cd[_0xa966('0x19')](_0xd1da87)['end']();};}function respondWithResult(_0x3f5dc5,_0x274f7a){_0x274f7a=_0x274f7a||0xc8;return function(_0xc97088){if(_0xc97088){return _0x3f5dc5['status'](_0x274f7a)[_0xa966('0x1a')](_0xc97088);}};}function respondWithFilteredResult(_0x4785cc,_0x1bd295){return function(_0x1d71d1){if(_0x1d71d1){var _0x23a2f4=typeof _0x1bd295['offset']==='undefined'&&typeof _0x1bd295['limit']===_0xa966('0x1b');var _0x594a7c=_0x1d71d1['count'];var _0x3baa56=_0x23a2f4?0x0:_0x1bd295[_0xa966('0x1c')];var _0x8ae17a=_0x23a2f4?_0x1d71d1['count']:_0x1bd295['offset']+_0x1bd295['limit'];var _0x3251a2;if(_0x8ae17a>=_0x594a7c){_0x8ae17a=_0x594a7c;_0x3251a2=0xc8;}else{_0x3251a2=0xce;}_0x4785cc[_0xa966('0x19')](_0x3251a2);return _0x4785cc[_0xa966('0x1d')]('Content-Range',_0x3baa56+'-'+_0x8ae17a+'/'+_0x594a7c)['json'](_0x1d71d1);}return null;};}function patchUpdates(_0x1195c1){return function(_0xae541d){try{jsonpatch[_0xa966('0x1e')](_0xae541d,_0x1195c1,!![]);}catch(_0x49fcac){return BPromise[_0xa966('0x1f')](_0x49fcac);}return _0xae541d['save']();};}function saveUpdates(_0x11a22e,_0x4e5a86){return function(_0x11cbf7){if(_0x11cbf7){return _0x11cbf7[_0xa966('0x20')](_0x11a22e)[_0xa966('0x21')](function(_0x3311ce){return _0x3311ce;});}return null;};}function removeEntity(_0x23f1bb,_0x1945b6){return function(_0x46f7e8){if(_0x46f7e8){return _0x46f7e8[_0xa966('0x22')]()[_0xa966('0x21')](function(){_0x23f1bb['status'](0xcc)['end']();});}};}function handleEntityNotFound(_0x550dcc,_0x3a8f13){return function(_0x566003){if(!_0x566003){_0x550dcc[_0xa966('0x18')](0x194);}return _0x566003;};}function handleError(_0x58125b,_0x3c8bbe){_0x3c8bbe=_0x3c8bbe||0x1f4;return function(_0x2fe9f5){logger[_0xa966('0x23')](_0x2fe9f5['stack']);if(_0x2fe9f5[_0xa966('0x24')]){delete _0x2fe9f5[_0xa966('0x24')];}_0x58125b['status'](_0x3c8bbe)[_0xa966('0x25')](_0x2fe9f5);};}exports[_0xa966('0x26')]=function(_0x58a77f,_0x4c8ec1){var _0x4277d2={},_0x18f7d9={},_0x28ceb2={'count':0x0,'rows':[]};var _0x4e959e=_['map'](db[_0xa966('0x27')][_0xa966('0x28')],function(_0x3ad2fd){return{'name':_0x3ad2fd[_0xa966('0x29')],'type':_0x3ad2fd[_0xa966('0x2a')][_0xa966('0x2b')]};});_0x18f7d9[_0xa966('0x2c')]=_[_0xa966('0x2d')](_0x4e959e,_0xa966('0x24'));_0x18f7d9[_0xa966('0x2e')]=_[_0xa966('0x2f')](_0x58a77f[_0xa966('0x2e')]);_0x18f7d9['filters']=_[_0xa966('0x30')](_0x18f7d9['model'],_0x18f7d9[_0xa966('0x2e')]);_0x4277d2['attributes']=_[_0xa966('0x30')](_0x18f7d9[_0xa966('0x2c')],qs[_0xa966('0x31')](_0x58a77f[_0xa966('0x2e')][_0xa966('0x31')]));_0x4277d2['attributes']=_0x4277d2[_0xa966('0x32')][_0xa966('0x33')]?_0x4277d2[_0xa966('0x32')]:_0x18f7d9[_0xa966('0x2c')];if(!_0x58a77f[_0xa966('0x2e')][_0xa966('0x34')](_0xa966('0x35'))){_0x4277d2[_0xa966('0x36')]=qs[_0xa966('0x36')](_0x58a77f[_0xa966('0x2e')][_0xa966('0x36')]);_0x4277d2[_0xa966('0x1c')]=qs[_0xa966('0x1c')](_0x58a77f['query'][_0xa966('0x1c')]);}_0x4277d2[_0xa966('0x37')]=qs['sort'](_0x58a77f['query'][_0xa966('0x38')]);_0x4277d2['where']=qs[_0xa966('0x39')](_[_0xa966('0x3a')](_0x58a77f[_0xa966('0x2e')],_0x18f7d9[_0xa966('0x39')]),_0x4e959e);if(_0x58a77f[_0xa966('0x2e')][_0xa966('0x3b')]){_0x4277d2['where']=_[_0xa966('0x3c')](_0x4277d2[_0xa966('0x3d')],{'$or':_[_0xa966('0x2d')](_0x4e959e,function(_0x2b60ed){if(_0x2b60ed[_0xa966('0x2a')]!==_0xa966('0x3e')){var _0x3147e1={};_0x3147e1[_0x2b60ed[_0xa966('0x24')]]={'$like':'%'+_0x58a77f[_0xa966('0x2e')]['filter']+'%'};return _0x3147e1;}})});}_0x4277d2=_[_0xa966('0x3c')]({},_0x4277d2,_0x58a77f['options']);var _0x5ebdc1={'where':_0x4277d2[_0xa966('0x3d')]};return db[_0xa966('0x27')][_0xa966('0x3f')](_0x5ebdc1)[_0xa966('0x21')](function(_0x1fa8fd){_0x28ceb2[_0xa966('0x3f')]=_0x1fa8fd;if(_0x58a77f[_0xa966('0x2e')][_0xa966('0x40')]){_0x4277d2['include']=[{'all':!![]}];}return db[_0xa966('0x27')][_0xa966('0x41')](_0x4277d2);})['then'](function(_0x14c3b2){_0x28ceb2[_0xa966('0x42')]=_0x14c3b2;return _0x28ceb2;})[_0xa966('0x21')](respondWithFilteredResult(_0x4c8ec1,_0x4277d2))[_0xa966('0x43')](handleError(_0x4c8ec1,null));};exports[_0xa966('0x44')]=function(_0x283e94,_0x2f51a1){var _0x251933={'raw':![],'where':{'id':_0x283e94[_0xa966('0x45')]['id']}},_0x50e5f0={};_0x50e5f0[_0xa966('0x2c')]=_[_0xa966('0x2f')](db[_0xa966('0x27')]['rawAttributes']);_0x50e5f0[_0xa966('0x2e')]=_['keys'](_0x283e94['query']);_0x50e5f0[_0xa966('0x39')]=_[_0xa966('0x30')](_0x50e5f0[_0xa966('0x2c')],_0x50e5f0['query']);_0x251933['attributes']=_[_0xa966('0x30')](_0x50e5f0[_0xa966('0x2c')],qs[_0xa966('0x31')](_0x283e94[_0xa966('0x2e')][_0xa966('0x31')]));_0x251933[_0xa966('0x32')]=_0x251933[_0xa966('0x32')][_0xa966('0x33')]?_0x251933['attributes']:_0x50e5f0[_0xa966('0x2c')];if(_0x283e94[_0xa966('0x2e')]['includeAll']){_0x251933[_0xa966('0x46')]=[{'all':!![]}];}_0x251933=_[_0xa966('0x3c')]({},_0x251933,_0x283e94[_0xa966('0x47')]);return db['SalesforceConfiguration'][_0xa966('0x48')](_0x251933)[_0xa966('0x21')](handleEntityNotFound(_0x2f51a1,null))[_0xa966('0x21')](respondWithResult(_0x2f51a1,null))[_0xa966('0x43')](handleError(_0x2f51a1,null));};exports[_0xa966('0x49')]=function(_0x447f87,_0xe62e44){return db[_0xa966('0x27')][_0xa966('0x49')](_0x447f87[_0xa966('0x4a')],{})[_0xa966('0x21')](respondWithResult(_0xe62e44,0xc9))[_0xa966('0x43')](handleError(_0xe62e44,null));};exports[_0xa966('0x20')]=function(_0x486b6d,_0x55797d){if(_0x486b6d[_0xa966('0x4a')]['id']){delete _0x486b6d['body']['id'];}return db[_0xa966('0x27')][_0xa966('0x48')]({'where':{'id':_0x486b6d[_0xa966('0x45')]['id']}})[_0xa966('0x21')](handleEntityNotFound(_0x55797d,null))[_0xa966('0x21')](saveUpdates(_0x486b6d[_0xa966('0x4a')],null))['then'](respondWithResult(_0x55797d,null))[_0xa966('0x43')](handleError(_0x55797d,null));};exports[_0xa966('0x22')]=function(_0x500b53,_0x150a2b){return db[_0xa966('0x27')][_0xa966('0x48')]({'where':{'id':_0x500b53[_0xa966('0x45')]['id']}})[_0xa966('0x21')](handleEntityNotFound(_0x150a2b,null))[_0xa966('0x21')](removeEntity(_0x150a2b,null))[_0xa966('0x43')](handleError(_0x150a2b,null));};exports[_0xa966('0x4b')]=function(_0x546b74,_0x49112e,_0x43ccf8){var _0x31c267={};var _0xc22d5f={};var _0x209627;var _0x2f87a4;return db[_0xa966('0x27')][_0xa966('0x4c')]({'where':{'id':_0x546b74[_0xa966('0x45')]['id']}})[_0xa966('0x21')](handleEntityNotFound(_0x49112e,null))[_0xa966('0x21')](function(_0x5ec695){if(_0x5ec695){_0x209627=_0x5ec695;_0xc22d5f['model']=_['keys'](db[_0xa966('0x4d')][_0xa966('0x28')]);_0xc22d5f['query']=_[_0xa966('0x2f')](_0x546b74[_0xa966('0x2e')]);_0xc22d5f[_0xa966('0x39')]=_['intersection'](_0xc22d5f[_0xa966('0x2c')],_0xc22d5f[_0xa966('0x2e')]);_0x31c267[_0xa966('0x32')]=_[_0xa966('0x30')](_0xc22d5f[_0xa966('0x2c')],qs[_0xa966('0x31')](_0x546b74['query'][_0xa966('0x31')]));_0x31c267[_0xa966('0x32')]=_0x31c267['attributes'][_0xa966('0x33')]?_0x31c267[_0xa966('0x32')]:_0xc22d5f[_0xa966('0x2c')];_0x31c267[_0xa966('0x37')]=qs[_0xa966('0x38')](_0x546b74['query'][_0xa966('0x38')]);_0x31c267[_0xa966('0x3d')]=qs[_0xa966('0x39')](_[_0xa966('0x3a')](_0x546b74[_0xa966('0x2e')],_0xc22d5f['filters']));if(_0x546b74['query'][_0xa966('0x3b')]){_0x31c267[_0xa966('0x3d')]=_[_0xa966('0x3c')](_0x31c267[_0xa966('0x3d')],{'$or':_[_0xa966('0x2d')](_0x31c267[_0xa966('0x32')],function(_0x1bede2){var _0x2e8c78={};_0x2e8c78[_0x1bede2]={'$like':'%'+_0x546b74[_0xa966('0x2e')][_0xa966('0x3b')]+'%'};return _0x2e8c78;})});}_0x31c267=_['merge']({},_0x31c267,_0x546b74[_0xa966('0x47')]);return _0x209627['getFields'](_0x31c267);}})['then'](function(_0x5d7c7e){if(_0x5d7c7e){_0x2f87a4=_0x5d7c7e[_0xa966('0x33')];if(!_0x546b74[_0xa966('0x2e')][_0xa966('0x34')](_0xa966('0x35'))){_0x31c267[_0xa966('0x36')]=qs[_0xa966('0x36')](_0x546b74[_0xa966('0x2e')][_0xa966('0x36')]);_0x31c267['offset']=qs['offset'](_0x546b74[_0xa966('0x2e')][_0xa966('0x1c')]);}return _0x209627[_0xa966('0x4b')](_0x31c267);}})['then'](function(_0x3b11a1){if(_0x3b11a1){return _0x3b11a1?{'count':_0x2f87a4,'rows':_0x3b11a1}:null;}})['then'](respondWithResult(_0x49112e,null))[_0xa966('0x43')](handleError(_0x49112e,null));};exports[_0xa966('0x4e')]=function(_0xa4ff3d,_0xfab5e6,_0x4577a1){var _0x1283d8={};var _0x110ba7={};var _0x3c7dbe;var _0x18ee46;return db[_0xa966('0x27')][_0xa966('0x4c')]({'where':{'id':_0xa4ff3d[_0xa966('0x45')]['id']}})[_0xa966('0x21')](handleEntityNotFound(_0xfab5e6,null))[_0xa966('0x21')](function(_0x54987f){if(_0x54987f){_0x3c7dbe=_0x54987f;_0x110ba7[_0xa966('0x2c')]=_[_0xa966('0x2f')](db[_0xa966('0x4d')][_0xa966('0x28')]);_0x110ba7[_0xa966('0x2e')]=_[_0xa966('0x2f')](_0xa4ff3d['query']);_0x110ba7[_0xa966('0x39')]=_['intersection'](_0x110ba7[_0xa966('0x2c')],_0x110ba7[_0xa966('0x2e')]);_0x1283d8['attributes']=_[_0xa966('0x30')](_0x110ba7[_0xa966('0x2c')],qs[_0xa966('0x31')](_0xa4ff3d[_0xa966('0x2e')][_0xa966('0x31')]));_0x1283d8[_0xa966('0x32')]=_0x1283d8[_0xa966('0x32')][_0xa966('0x33')]?_0x1283d8[_0xa966('0x32')]:_0x110ba7[_0xa966('0x2c')];_0x1283d8[_0xa966('0x37')]=qs[_0xa966('0x38')](_0xa4ff3d[_0xa966('0x2e')][_0xa966('0x38')]);_0x1283d8[_0xa966('0x3d')]=qs[_0xa966('0x39')](_['pick'](_0xa4ff3d[_0xa966('0x2e')],_0x110ba7[_0xa966('0x39')]));if(_0xa4ff3d['query'][_0xa966('0x3b')]){_0x1283d8[_0xa966('0x3d')]=_[_0xa966('0x3c')](_0x1283d8[_0xa966('0x3d')],{'$or':_[_0xa966('0x2d')](_0x1283d8[_0xa966('0x32')],function(_0x7fe45e){var _0x4883d9={};_0x4883d9[_0x7fe45e]={'$like':'%'+_0xa4ff3d[_0xa966('0x2e')]['filter']+'%'};return _0x4883d9;})});}_0x1283d8=_[_0xa966('0x3c')]({},_0x1283d8,_0xa4ff3d[_0xa966('0x47')]);return _0x3c7dbe['getSubjects'](_0x1283d8);}})[_0xa966('0x21')](function(_0x4fa156){if(_0x4fa156){_0x18ee46=_0x4fa156[_0xa966('0x33')];if(!_0xa4ff3d[_0xa966('0x2e')][_0xa966('0x34')](_0xa966('0x35'))){_0x1283d8[_0xa966('0x36')]=qs[_0xa966('0x36')](_0xa4ff3d['query'][_0xa966('0x36')]);_0x1283d8[_0xa966('0x1c')]=qs[_0xa966('0x1c')](_0xa4ff3d[_0xa966('0x2e')][_0xa966('0x1c')]);}return _0x3c7dbe[_0xa966('0x4e')](_0x1283d8);}})[_0xa966('0x21')](function(_0x46347a){if(_0x46347a){return _0x46347a?{'count':_0x18ee46,'rows':_0x46347a}:null;}})[_0xa966('0x21')](respondWithResult(_0xfab5e6,null))['catch'](handleError(_0xfab5e6,null));};exports[_0xa966('0x4f')]=function(_0x15d055,_0x2b1b12,_0x860fff){var _0x14daa0={};var _0x22b697={};var _0x44e816;var _0x3bb0bf;return db['SalesforceConfiguration'][_0xa966('0x4c')]({'where':{'id':_0x15d055[_0xa966('0x45')]['id']}})['then'](handleEntityNotFound(_0x2b1b12,null))[_0xa966('0x21')](function(_0x1e843a){if(_0x1e843a){_0x44e816=_0x1e843a;_0x22b697['model']=_[_0xa966('0x2f')](db['SalesforceField']['rawAttributes']);_0x22b697[_0xa966('0x2e')]=_[_0xa966('0x2f')](_0x15d055[_0xa966('0x2e')]);_0x22b697[_0xa966('0x39')]=_[_0xa966('0x30')](_0x22b697[_0xa966('0x2c')],_0x22b697[_0xa966('0x2e')]);_0x14daa0['attributes']=_['intersection'](_0x22b697[_0xa966('0x2c')],qs['fields'](_0x15d055[_0xa966('0x2e')]['fields']));_0x14daa0[_0xa966('0x32')]=_0x14daa0[_0xa966('0x32')][_0xa966('0x33')]?_0x14daa0[_0xa966('0x32')]:_0x22b697[_0xa966('0x2c')];_0x14daa0[_0xa966('0x37')]=qs[_0xa966('0x38')](_0x15d055[_0xa966('0x2e')][_0xa966('0x38')]);_0x14daa0[_0xa966('0x3d')]=qs[_0xa966('0x39')](_[_0xa966('0x3a')](_0x15d055[_0xa966('0x2e')],_0x22b697[_0xa966('0x39')]));if(_0x15d055['query']['filter']){_0x14daa0[_0xa966('0x3d')]=_[_0xa966('0x3c')](_0x14daa0[_0xa966('0x3d')],{'$or':_['map'](_0x14daa0['attributes'],function(_0x1f2b05){var _0x2b1522={};_0x2b1522[_0x1f2b05]={'$like':'%'+_0x15d055[_0xa966('0x2e')][_0xa966('0x3b')]+'%'};return _0x2b1522;})});}_0x14daa0=_['merge']({},_0x14daa0,_0x15d055[_0xa966('0x47')]);return _0x44e816[_0xa966('0x4f')](_0x14daa0);}})[_0xa966('0x21')](function(_0x15709e){if(_0x15709e){_0x3bb0bf=_0x15709e[_0xa966('0x33')];if(!_0x15d055['query']['hasOwnProperty'](_0xa966('0x35'))){_0x14daa0[_0xa966('0x36')]=qs[_0xa966('0x36')](_0x15d055[_0xa966('0x2e')]['limit']);_0x14daa0['offset']=qs[_0xa966('0x1c')](_0x15d055[_0xa966('0x2e')]['offset']);}return _0x44e816[_0xa966('0x4f')](_0x14daa0);}})[_0xa966('0x21')](function(_0xec87ad){if(_0xec87ad){return _0xec87ad?{'count':_0x3bb0bf,'rows':_0xec87ad}:null;}})[_0xa966('0x21')](respondWithResult(_0x2b1b12,null))[_0xa966('0x43')](handleError(_0x2b1b12,null));};
\ No newline at end of file