Built motion from commit 10af8726.|2.6.34
[motion2.git] / server / api / intSalesforceAccount / intSalesforceAccount.controller.js
index 267b7f4..1898a9f 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x761f=['lastIndexOf','password','concat','ticketType','sobject','OwnerId','ActivityDate','IsReminderSet','IsRecurrence','int','email','textarea','phone','remove','includes','custom','picklistValues','label','value','boolean','true','False','false','test','statusCode','getFields,\x20%s,\x20%s,\x20%s','send','Wrong\x20credentials','html-pdf','eml-format','rimraf','zip-dir','fast-json-patch','bluebird','sox','ejs','lodash','squel','crypto','desk.js','to-csv','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/license/util','../../mysqldb','../../components/integrations/configuration','jayson/promise','http','request','info','SalesforceAccount,\x20%s,\x20%s','request\x20sent','SalesforceAccount,\x20%s,\x20%s,\x20%s','stringify','error','message','result','sendStatus','status','end','json','count','offset','limit','set','Content-Range','save','update','then','destroy','stack','name','index','SalesforceAccount','rawAttributes','fieldName','key','query','keys','filters','attributes','intersection','model','fields','hasOwnProperty','sort','where','pick','merge','map','type','VIRTUAL','options','includeAll','findAll','rows','show','params','length','create','body','find','catch','getConfigurations','findOne','SalesforceConfiguration','filter','nolimit','addConfiguration','getSubjects','channel','Descriptions','getDescriptions','SalesforceField','Subjects','Task','clientSecret','username','securityToken','remoteUri','substring'];(function(_0x2e7b71,_0x30eb38){var _0x3831b4=function(_0x1015b4){while(--_0x1015b4){_0x2e7b71['push'](_0x2e7b71['shift']());}};_0x3831b4(++_0x30eb38);}(_0x761f,0x11e));var _0xf761=function(_0xd2f4ac,_0x5aa8e5){_0xd2f4ac=_0xd2f4ac-0x0;var _0x9757b2=_0x761f[_0xd2f4ac];return _0x9757b2;};'use strict';var pdf=require(_0xf761('0x0'));var emlformat=require(_0xf761('0x1'));var rimraf=require(_0xf761('0x2'));var zipdir=require(_0xf761('0x3'));var jsonpatch=require(_0xf761('0x4'));var rp=require('request-promise');var moment=require('moment');var BPromise=require(_0xf761('0x5'));var Mustache=require('mustache');var util=require('util');var path=require('path');var sox=require(_0xf761('0x6'));var csv=require('to-csv');var ejs=require(_0xf761('0x7'));var fs=require('fs');var _=require(_0xf761('0x8'));var squel=require(_0xf761('0x9'));var crypto=require(_0xf761('0xa'));var jsforce=require('jsforce');var deskjs=require(_0xf761('0xb'));var toCsv=require(_0xf761('0xc'));var querystring=require(_0xf761('0xd'));var Papa=require(_0xf761('0xe'));var Redis=require(_0xf761('0xf'));var authService=require(_0xf761('0x10'));var qs=require(_0xf761('0x11'));var as=require(_0xf761('0x12'));var hardwareService=require(_0xf761('0x13'));var logger=require(_0xf761('0x14'))(_0xf761('0x15'));var utils=require(_0xf761('0x16'));var config=require('../../config/environment');var licenseUtil=require(_0xf761('0x17'));var db=require(_0xf761('0x18'))['db'];var integrations=require(_0xf761('0x19'));var jayson=require(_0xf761('0x1a'));var client=jayson['client'][_0xf761('0x1b')]({'port':0x232a});function respondWithRpcPromise(_0x15bdbb,_0x36ddca,_0x413e17,_0x28039e){return new BPromise(function(_0x2f6719,_0x55eaa4){var _0x3b49ba=_0x28039e||client;return _0x3b49ba[_0xf761('0x1c')](_0x15bdbb,_0x413e17)['then'](function(_0x3df081){logger[_0xf761('0x1d')](_0xf761('0x1e'),_0x36ddca,_0xf761('0x1f'));logger['debug'](_0xf761('0x20'),_0x36ddca,_0xf761('0x1f'),JSON[_0xf761('0x21')](_0x3df081));if(_0x3df081['error']){if(_0x3df081['error']['code']===0x1f4){logger[_0xf761('0x22')](_0xf761('0x1e'),_0x36ddca,_0x3df081[_0xf761('0x22')][_0xf761('0x23')]);return _0x55eaa4(_0x3df081[_0xf761('0x22')][_0xf761('0x23')]);}logger['error']('SalesforceAccount,\x20%s,\x20%s',_0x36ddca,_0x3df081[_0xf761('0x22')][_0xf761('0x23')]);return _0x2f6719(_0x3df081[_0xf761('0x22')]['message']);}else{logger[_0xf761('0x1d')](_0xf761('0x1e'),_0x36ddca,_0xf761('0x1f'));_0x2f6719(_0x3df081[_0xf761('0x24')]['message']);}})['catch'](function(_0x6fa14a){logger[_0xf761('0x22')](_0xf761('0x1e'),_0x36ddca,_0x6fa14a);_0x55eaa4(_0x6fa14a);});});}function respondWithStatusCode(_0xdf1dad,_0x4253d1){_0x4253d1=_0x4253d1||0xcc;return function(_0x5b627a){if(_0x5b627a){return _0xdf1dad[_0xf761('0x25')](_0x4253d1);}return _0xdf1dad[_0xf761('0x26')](_0x4253d1)[_0xf761('0x27')]();};}function respondWithResult(_0x29fc97,_0x48d7f6){_0x48d7f6=_0x48d7f6||0xc8;return function(_0x4b8bec){if(_0x4b8bec){return _0x29fc97[_0xf761('0x26')](_0x48d7f6)[_0xf761('0x28')](_0x4b8bec);}};}function respondWithFilteredResult(_0x279fb0,_0x5ca468){return function(_0x3eb3e2){if(_0x3eb3e2){var _0x30464c=_0x3eb3e2[_0xf761('0x29')],_0x3d5b2c=_0x5ca468[_0xf761('0x2a')],_0x7ba306=_0x5ca468[_0xf761('0x2a')]+_0x5ca468[_0xf761('0x2b')],_0x3fa2eb;if(_0x7ba306>=_0x30464c){_0x7ba306=_0x30464c;_0x3fa2eb=0xc8;}else{_0x3fa2eb=0xce;}_0x279fb0[_0xf761('0x26')](_0x3fa2eb);return _0x279fb0[_0xf761('0x2c')](_0xf761('0x2d'),_0x3d5b2c+'-'+_0x7ba306+'/'+_0x30464c)[_0xf761('0x28')](_0x3eb3e2);}return null;};}function patchUpdates(_0x4db7df){return function(_0x428f1e){try{jsonpatch['apply'](_0x428f1e,_0x4db7df,!![]);}catch(_0x47f798){return BPromise['reject'](_0x47f798);}return _0x428f1e[_0xf761('0x2e')]();};}function saveUpdates(_0x2891c7,_0x49229b){return function(_0x2758dd){if(_0x2758dd){return _0x2758dd[_0xf761('0x2f')](_0x2891c7)[_0xf761('0x30')](function(_0x34be6b){return _0x34be6b;});}return null;};}function removeEntity(_0x22f418,_0x5021fd){return function(_0x5d0807){if(_0x5d0807){return _0x5d0807[_0xf761('0x31')]()[_0xf761('0x30')](function(){_0x22f418[_0xf761('0x26')](0xcc)[_0xf761('0x27')]();});}};}function handleEntityNotFound(_0x2151ad,_0x3247b4){return function(_0x26f962){if(!_0x26f962){_0x2151ad['sendStatus'](0x194);}return _0x26f962;};}function handleError(_0x376284,_0x3008b2){_0x3008b2=_0x3008b2||0x1f4;return function(_0x306f01){logger[_0xf761('0x22')](_0x306f01[_0xf761('0x32')]);if(_0x306f01[_0xf761('0x33')]){delete _0x306f01[_0xf761('0x33')];}_0x376284[_0xf761('0x26')](_0x3008b2)['send'](_0x306f01);};}exports[_0xf761('0x34')]=function(_0x1fd44e,_0x567b1f){var _0x2596ed={},_0x352095={},_0x3ee17f={'count':0x0,'rows':[]};var _0x2fb701=_['map'](db[_0xf761('0x35')][_0xf761('0x36')],function(_0x56b006){return{'name':_0x56b006[_0xf761('0x37')],'type':_0x56b006['type'][_0xf761('0x38')]};});_0x352095['model']=_['map'](_0x2fb701,_0xf761('0x33'));_0x352095[_0xf761('0x39')]=_[_0xf761('0x3a')](_0x1fd44e['query']);_0x352095[_0xf761('0x3b')]=_['intersection'](_0x352095['model'],_0x352095['query']);_0x2596ed[_0xf761('0x3c')]=_[_0xf761('0x3d')](_0x352095[_0xf761('0x3e')],qs[_0xf761('0x3f')](_0x1fd44e[_0xf761('0x39')][_0xf761('0x3f')]));_0x2596ed[_0xf761('0x3c')]=_0x2596ed['attributes']['length']?_0x2596ed[_0xf761('0x3c')]:_0x352095['model'];if(!_0x1fd44e[_0xf761('0x39')][_0xf761('0x40')]('nolimit')){_0x2596ed[_0xf761('0x2b')]=qs[_0xf761('0x2b')](_0x1fd44e[_0xf761('0x39')][_0xf761('0x2b')]);_0x2596ed[_0xf761('0x2a')]=qs[_0xf761('0x2a')](_0x1fd44e[_0xf761('0x39')]['offset']);}_0x2596ed['order']=qs[_0xf761('0x41')](_0x1fd44e[_0xf761('0x39')][_0xf761('0x41')]);_0x2596ed[_0xf761('0x42')]=qs[_0xf761('0x3b')](_[_0xf761('0x43')](_0x1fd44e[_0xf761('0x39')],_0x352095[_0xf761('0x3b')]),_0x2fb701);if(_0x1fd44e['query']['filter']){_0x2596ed[_0xf761('0x42')]=_[_0xf761('0x44')](_0x2596ed[_0xf761('0x42')],{'$or':_[_0xf761('0x45')](_0x2fb701,function(_0xbeeb1a){if(_0xbeeb1a[_0xf761('0x46')]!==_0xf761('0x47')){var _0x5b6386={};_0x5b6386[_0xbeeb1a['name']]={'$like':'%'+_0x1fd44e[_0xf761('0x39')]['filter']+'%'};return _0x5b6386;}})});}_0x2596ed=_[_0xf761('0x44')]({},_0x2596ed,_0x1fd44e[_0xf761('0x48')]);var _0x3a86a3={'where':_0x2596ed[_0xf761('0x42')]};return db[_0xf761('0x35')][_0xf761('0x29')](_0x3a86a3)['then'](function(_0x3a0b2d){_0x3ee17f[_0xf761('0x29')]=_0x3a0b2d;if(_0x1fd44e[_0xf761('0x39')][_0xf761('0x49')]){_0x2596ed['include']=[{'all':!![]}];}return db[_0xf761('0x35')][_0xf761('0x4a')](_0x2596ed);})[_0xf761('0x30')](function(_0x3bf9e7){_0x3ee17f[_0xf761('0x4b')]=_0x3bf9e7;return _0x3ee17f;})[_0xf761('0x30')](respondWithFilteredResult(_0x567b1f,_0x2596ed))['catch'](handleError(_0x567b1f,null));};exports[_0xf761('0x4c')]=function(_0x530753,_0x40443d){var _0x238f70={'raw':![],'where':{'id':_0x530753[_0xf761('0x4d')]['id']}},_0x27b42c={};_0x27b42c[_0xf761('0x3e')]=_[_0xf761('0x3a')](db['SalesforceAccount'][_0xf761('0x36')]);_0x27b42c['query']=_['keys'](_0x530753[_0xf761('0x39')]);_0x27b42c[_0xf761('0x3b')]=_[_0xf761('0x3d')](_0x27b42c[_0xf761('0x3e')],_0x27b42c['query']);_0x238f70[_0xf761('0x3c')]=_[_0xf761('0x3d')](_0x27b42c[_0xf761('0x3e')],qs[_0xf761('0x3f')](_0x530753[_0xf761('0x39')][_0xf761('0x3f')]));_0x238f70['attributes']=_0x238f70[_0xf761('0x3c')][_0xf761('0x4e')]?_0x238f70[_0xf761('0x3c')]:_0x27b42c[_0xf761('0x3e')];if(_0x530753[_0xf761('0x39')][_0xf761('0x49')]){_0x238f70['include']=[{'all':!![]}];}_0x238f70=_[_0xf761('0x44')]({},_0x238f70,_0x530753[_0xf761('0x48')]);return db['SalesforceAccount']['find'](_0x238f70)[_0xf761('0x30')](handleEntityNotFound(_0x40443d,null))[_0xf761('0x30')](respondWithResult(_0x40443d,null))['catch'](handleError(_0x40443d,null));};exports[_0xf761('0x4f')]=function(_0x3a1267,_0x5a481c){return db[_0xf761('0x35')][_0xf761('0x4f')](_0x3a1267['body'],{})[_0xf761('0x30')](respondWithResult(_0x5a481c,0xc9))['catch'](handleError(_0x5a481c,null));};exports[_0xf761('0x2f')]=function(_0x14db2a,_0x558515){if(_0x14db2a[_0xf761('0x50')]['id']){delete _0x14db2a['body']['id'];}return db['SalesforceAccount'][_0xf761('0x51')]({'where':{'id':_0x14db2a[_0xf761('0x4d')]['id']}})[_0xf761('0x30')](handleEntityNotFound(_0x558515,null))['then'](saveUpdates(_0x14db2a[_0xf761('0x50')],null))[_0xf761('0x30')](respondWithResult(_0x558515,null))['catch'](handleError(_0x558515,null));};exports[_0xf761('0x31')]=function(_0x1eaf16,_0x3d6c07){return db[_0xf761('0x35')][_0xf761('0x51')]({'where':{'id':_0x1eaf16['params']['id']}})['then'](handleEntityNotFound(_0x3d6c07,null))['then'](removeEntity(_0x3d6c07,null))[_0xf761('0x52')](handleError(_0x3d6c07,null));};exports[_0xf761('0x53')]=function(_0x3d1037,_0xc0e378,_0x39663d){var _0x1c4eb3={};var _0x4f74db={};var _0x144735;var _0x5b0b99;return db[_0xf761('0x35')][_0xf761('0x54')]({'where':{'id':_0x3d1037['params']['id']}})[_0xf761('0x30')](handleEntityNotFound(_0xc0e378,null))[_0xf761('0x30')](function(_0x5ae163){if(_0x5ae163){_0x144735=_0x5ae163;_0x4f74db['model']=_['keys'](db[_0xf761('0x55')][_0xf761('0x36')]);_0x4f74db[_0xf761('0x39')]=_['keys'](_0x3d1037[_0xf761('0x39')]);_0x4f74db[_0xf761('0x3b')]=_['intersection'](_0x4f74db[_0xf761('0x3e')],_0x4f74db[_0xf761('0x39')]);_0x1c4eb3[_0xf761('0x3c')]=_[_0xf761('0x3d')](_0x4f74db[_0xf761('0x3e')],qs[_0xf761('0x3f')](_0x3d1037['query'][_0xf761('0x3f')]));_0x1c4eb3['attributes']=_0x1c4eb3[_0xf761('0x3c')][_0xf761('0x4e')]?_0x1c4eb3[_0xf761('0x3c')]:_0x4f74db[_0xf761('0x3e')];_0x1c4eb3['order']=qs[_0xf761('0x41')](_0x3d1037[_0xf761('0x39')][_0xf761('0x41')]);_0x1c4eb3['where']=qs[_0xf761('0x3b')](_['pick'](_0x3d1037[_0xf761('0x39')],_0x4f74db[_0xf761('0x3b')]));if(_0x3d1037[_0xf761('0x39')][_0xf761('0x56')]){_0x1c4eb3[_0xf761('0x42')]=_['merge'](_0x1c4eb3[_0xf761('0x42')],{'$or':_[_0xf761('0x45')](_0x1c4eb3['attributes'],function(_0x317cf9){var _0x5dfc91={};_0x5dfc91[_0x317cf9]={'$like':'%'+_0x3d1037[_0xf761('0x39')][_0xf761('0x56')]+'%'};return _0x5dfc91;})});}_0x1c4eb3=_[_0xf761('0x44')]({},_0x1c4eb3,_0x3d1037[_0xf761('0x48')]);return _0x144735[_0xf761('0x53')](_0x1c4eb3);}})[_0xf761('0x30')](function(_0x2e5578){if(_0x2e5578){_0x5b0b99=_0x2e5578['length'];if(!_0x3d1037['query'][_0xf761('0x40')](_0xf761('0x57'))){_0x1c4eb3[_0xf761('0x2b')]=qs[_0xf761('0x2b')](_0x3d1037[_0xf761('0x39')][_0xf761('0x2b')]);_0x1c4eb3[_0xf761('0x2a')]=qs[_0xf761('0x2a')](_0x3d1037[_0xf761('0x39')][_0xf761('0x2a')]);}return _0x144735['getConfigurations'](_0x1c4eb3);}})[_0xf761('0x30')](function(_0x4f171e){if(_0x4f171e){return _0x4f171e?{'count':_0x5b0b99,'rows':_0x4f171e}:null;}})['then'](respondWithResult(_0xc0e378,null))[_0xf761('0x52')](handleError(_0xc0e378,null));};exports[_0xf761('0x58')]=function(_0x3af3ff,_0x12d74c,_0x4251ff){if(_0x3af3ff['body']['id']){delete _0x3af3ff[_0xf761('0x50')]['id'];}return db[_0xf761('0x35')]['findOne']({'where':{'id':_0x3af3ff['params']['id']}})[_0xf761('0x30')](handleEntityNotFound(_0x12d74c,null))[_0xf761('0x30')](function(_0x4c0186){if(_0x4c0186){_0x3af3ff[_0xf761('0x50')]['AccountId']=_0x4c0186['id'];_0x3af3ff[_0xf761('0x50')]['Subjects']=integrations[_0xf761('0x59')](_0x3af3ff['body'][_0xf761('0x5a')],_0x3af3ff[_0xf761('0x50')][_0xf761('0x46')]);_0x3af3ff[_0xf761('0x50')][_0xf761('0x5b')]=integrations[_0xf761('0x5c')](_0x3af3ff[_0xf761('0x50')][_0xf761('0x5a')],_0x3af3ff['body']['type']);return db['SalesforceConfiguration'][_0xf761('0x4f')](_0x3af3ff['body'],{'include':[{'model':db[_0xf761('0x5d')],'as':_0xf761('0x5e')},{'model':db['SalesforceField'],'as':_0xf761('0x5b')}]});}return null;})['then'](respondWithResult(_0x12d74c,null))[_0xf761('0x52')](handleError(_0x12d74c,null));};exports['getFields']=function(_0x226dcc,_0x3b4209,_0x517310){var _0x44f952;var _0x278308='';var _0x41034c=_0xf761('0x5f');return db[_0xf761('0x35')][_0xf761('0x54')]({'where':{'id':_0x226dcc[_0xf761('0x4d')]['id']},'attributes':['id','remoteUri','clientId',_0xf761('0x60'),_0xf761('0x61'),'password',_0xf761('0x62')]})[_0xf761('0x30')](handleEntityNotFound(_0x3b4209,null))[_0xf761('0x30')](function(_0x2838a4){if(_0x2838a4){_0x278308=_0x2838a4[_0xf761('0x63')];var _0x12eedb=_0x278308['slice'](-0x1);if(_0x12eedb==='/'){_0x278308=_0x278308[_0xf761('0x64')](0x0,_0x278308[_0xf761('0x65')](_0x12eedb));}_0x44f952=new jsforce['Connection']({'oauth2':{'loginUrl':_0x278308,'clientId':_0x2838a4['clientId'],'clientSecret':_0x2838a4[_0xf761('0x60')]}});return _0x44f952['login'](_0x2838a4[_0xf761('0x61')],_0x2838a4[_0xf761('0x66')][_0xf761('0x67')](_0x2838a4['securityToken']));}})[_0xf761('0x30')](function(_0x56acb5){if(_0x56acb5){if(!_['isNil'](_0x226dcc[_0xf761('0x39')]['ticketType'])){_0x41034c=_0x226dcc[_0xf761('0x39')][_0xf761('0x68')];}return _0x44f952[_0xf761('0x69')](_0x41034c)['describe']();}})[_0xf761('0x30')](function(_0x45dca6){var _0x197517=[_0xf761('0x6a'),_0xf761('0x6b'),_0xf761('0x6c'),_0xf761('0x6d'),'Subject','Description'];var _0xa3e1d2=['string',_0xf761('0x6e'),'picklist','boolean',_0xf761('0x6f'),_0xf761('0x70'),_0xf761('0x71')];if(_0x45dca6){_[_0xf761('0x72')](_0x45dca6[_0xf761('0x3f')],function(_0x393328){return _0x197517[_0xf761('0x73')](_0x393328[_0xf761('0x33')])||!_0xa3e1d2['includes'](_0x393328[_0xf761('0x46')]);});return{'count':_0x45dca6[_0xf761('0x3f')][_0xf761('0x4e')],'rows':_['map'](_0x45dca6['fields'],function(_0xfef59f){return{'id':_0xfef59f[_0xf761('0x33')],'name':_0xfef59f['label'],'custom':_0xfef59f[_0xf761('0x74')],'options':_0xfef59f[_0xf761('0x75')]['length']>0x0?_[_0xf761('0x45')](_0xfef59f['picklistValues'],function(_0x75f2d5){return{'name':_0x75f2d5[_0xf761('0x76')],'value':_0x75f2d5[_0xf761('0x77')]};}):_0xfef59f[_0xf761('0x46')]==_0xf761('0x78')?[{'name':'True','value':_0xf761('0x79')},{'name':_0xf761('0x7a'),'value':_0xf761('0x7b')}]:[]};})};}})[_0xf761('0x30')](respondWithResult(_0x3b4209,null))['catch'](function(_0x7ed7c0){var _0x478f8a=_0x226dcc[_0xf761('0x39')][_0xf761('0x7c')]?0x1f4:_0x7ed7c0[_0xf761('0x7d')]||0x1f4;logger[_0xf761('0x22')](_0xf761('0x7e'),'getFields',_0x478f8a,JSON[_0xf761('0x21')](_0x7ed7c0));delete _0x7ed7c0[_0xf761('0x33')];if(_0x478f8a===0x191){_0x478f8a=0x190;}_0x3b4209[_0xf761('0x26')](_0x478f8a)[_0xf761('0x7f')](_0x226dcc[_0xf761('0x39')][_0xf761('0x7c')]?{'message':_0xf761('0x80'),'statusCode':_0x7ed7c0['statusCode']}:_0x7ed7c0);});};
\ No newline at end of file
+var _0x012c=['mustache','util','path','ejs','fs-extra','squel','jsforce','to-csv','querystring','ioredis','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/logger','api','../../config/utils','../../config/environment','../../mysqldb','sendStatus','status','json','offset','undefined','limit','count','set','Content-Range','apply','save','update','destroy','then','end','error','stack','name','send','index','map','SalesforceAccount','rawAttributes','fieldName','type','key','query','keys','filters','intersection','model','fields','attributes','length','hasOwnProperty','nolimit','order','sort','filter','where','VIRTUAL','includeAll','findAll','rows','show','include','options','find','catch','create','body','params','SalesforceConfiguration','pick','merge','getConfigurations','findOne','getSubjects','channel','Descriptions','getDescriptions','Subjects','getFields','Task','remoteUri','clientSecret','password','slice','lastIndexOf','Connection','clientId','login','username','securityToken','ticketType','describe','OwnerId','IsRecurrence','Subject','Description','string','int','boolean','email','textarea','phone','includes','label','custom','picklistValues','value','True','true','False','false','test','statusCode','getFields,\x20%s,\x20%s,\x20%s','Wrong\x20credentials','eml-format','rimraf','fast-json-patch','request-promise','moment','bluebird'];(function(_0x1cfa0d,_0x4391f2){var _0xe33279=function(_0x3ce7c1){while(--_0x3ce7c1){_0x1cfa0d['push'](_0x1cfa0d['shift']());}};_0xe33279(++_0x4391f2);}(_0x012c,0xee));var _0xc012=function(_0x284240,_0x555b56){_0x284240=_0x284240-0x0;var _0x390667=_0x012c[_0x284240];return _0x390667;};'use strict';var emlformat=require(_0xc012('0x0'));var rimraf=require(_0xc012('0x1'));var zipdir=require('zip-dir');var jsonpatch=require(_0xc012('0x2'));var rp=require(_0xc012('0x3'));var moment=require(_0xc012('0x4'));var BPromise=require(_0xc012('0x5'));var Mustache=require(_0xc012('0x6'));var util=require(_0xc012('0x7'));var path=require(_0xc012('0x8'));var sox=require('sox');var csv=require('to-csv');var ejs=require(_0xc012('0x9'));var fs=require('fs');var fs_extra=require(_0xc012('0xa'));var _=require('lodash');var squel=require(_0xc012('0xb'));var crypto=require('crypto');var jsforce=require(_0xc012('0xc'));var deskjs=require('desk.js');var toCsv=require(_0xc012('0xd'));var querystring=require(_0xc012('0xe'));var Papa=require('papaparse');var Redis=require(_0xc012('0xf'));var authService=require('../../components/auth/service');var qs=require(_0xc012('0x10'));var as=require(_0xc012('0x11'));var hardwareService=require('../../config/license/hardware');var logger=require(_0xc012('0x12'))(_0xc012('0x13'));var utils=require(_0xc012('0x14'));var config=require(_0xc012('0x15'));var licenseUtil=require('../../config/license/util');var db=require(_0xc012('0x16'))['db'];var integrations=require('../../components/integrations/configuration');function respondWithStatusCode(_0x247196,_0x36f74a){_0x36f74a=_0x36f74a||0xcc;return function(_0x487055){if(_0x487055){return _0x247196[_0xc012('0x17')](_0x36f74a);}return _0x247196[_0xc012('0x18')](_0x36f74a)['end']();};}function respondWithResult(_0x87087a,_0x179757){_0x179757=_0x179757||0xc8;return function(_0x550cf7){if(_0x550cf7){return _0x87087a['status'](_0x179757)[_0xc012('0x19')](_0x550cf7);}};}function respondWithFilteredResult(_0x28adca,_0x5f0f0d){return function(_0x215119){if(_0x215119){var _0x9f0200=typeof _0x5f0f0d[_0xc012('0x1a')]===_0xc012('0x1b')&&typeof _0x5f0f0d[_0xc012('0x1c')]===_0xc012('0x1b');var _0x458356=_0x215119[_0xc012('0x1d')];var _0x4f326e=_0x9f0200?0x0:_0x5f0f0d[_0xc012('0x1a')];var _0x1ae5f9=_0x9f0200?_0x215119[_0xc012('0x1d')]:_0x5f0f0d[_0xc012('0x1a')]+_0x5f0f0d['limit'];var _0xa6b20f;if(_0x1ae5f9>=_0x458356){_0x1ae5f9=_0x458356;_0xa6b20f=0xc8;}else{_0xa6b20f=0xce;}_0x28adca[_0xc012('0x18')](_0xa6b20f);return _0x28adca[_0xc012('0x1e')](_0xc012('0x1f'),_0x4f326e+'-'+_0x1ae5f9+'/'+_0x458356)[_0xc012('0x19')](_0x215119);}return null;};}function patchUpdates(_0x1c0cdf){return function(_0x5838da){try{jsonpatch[_0xc012('0x20')](_0x5838da,_0x1c0cdf,!![]);}catch(_0x406cd9){return BPromise['reject'](_0x406cd9);}return _0x5838da[_0xc012('0x21')]();};}function saveUpdates(_0x2e2917,_0x241368){return function(_0x37015e){if(_0x37015e){return _0x37015e[_0xc012('0x22')](_0x2e2917)['then'](function(_0x4ec582){return _0x4ec582;});}return null;};}function removeEntity(_0x394f86,_0xd63610){return function(_0x37463c){if(_0x37463c){return _0x37463c[_0xc012('0x23')]()[_0xc012('0x24')](function(){_0x394f86['status'](0xcc)[_0xc012('0x25')]();});}};}function handleEntityNotFound(_0x23045c,_0x31d128){return function(_0x589252){if(!_0x589252){_0x23045c[_0xc012('0x17')](0x194);}return _0x589252;};}function handleError(_0x4eb069,_0x262d3a){_0x262d3a=_0x262d3a||0x1f4;return function(_0x43a954){logger[_0xc012('0x26')](_0x43a954[_0xc012('0x27')]);if(_0x43a954[_0xc012('0x28')]){delete _0x43a954['name'];}_0x4eb069['status'](_0x262d3a)[_0xc012('0x29')](_0x43a954);};}exports[_0xc012('0x2a')]=function(_0x13038c,_0x1ab031){var _0x3ef96a={},_0x49c0db={},_0x4fa37f={'count':0x0,'rows':[]};var _0x18518c=_[_0xc012('0x2b')](db[_0xc012('0x2c')][_0xc012('0x2d')],function(_0x1419ff){return{'name':_0x1419ff[_0xc012('0x2e')],'type':_0x1419ff[_0xc012('0x2f')][_0xc012('0x30')]};});_0x49c0db['model']=_['map'](_0x18518c,_0xc012('0x28'));_0x49c0db[_0xc012('0x31')]=_[_0xc012('0x32')](_0x13038c[_0xc012('0x31')]);_0x49c0db[_0xc012('0x33')]=_[_0xc012('0x34')](_0x49c0db['model'],_0x49c0db[_0xc012('0x31')]);_0x3ef96a['attributes']=_['intersection'](_0x49c0db[_0xc012('0x35')],qs[_0xc012('0x36')](_0x13038c[_0xc012('0x31')]['fields']));_0x3ef96a[_0xc012('0x37')]=_0x3ef96a[_0xc012('0x37')][_0xc012('0x38')]?_0x3ef96a[_0xc012('0x37')]:_0x49c0db['model'];if(!_0x13038c['query'][_0xc012('0x39')](_0xc012('0x3a'))){_0x3ef96a['limit']=qs[_0xc012('0x1c')](_0x13038c[_0xc012('0x31')]['limit']);_0x3ef96a[_0xc012('0x1a')]=qs[_0xc012('0x1a')](_0x13038c['query'][_0xc012('0x1a')]);}_0x3ef96a[_0xc012('0x3b')]=qs[_0xc012('0x3c')](_0x13038c[_0xc012('0x31')]['sort']);_0x3ef96a['where']=qs[_0xc012('0x33')](_['pick'](_0x13038c['query'],_0x49c0db[_0xc012('0x33')]),_0x18518c);if(_0x13038c[_0xc012('0x31')][_0xc012('0x3d')]){_0x3ef96a[_0xc012('0x3e')]=_['merge'](_0x3ef96a['where'],{'$or':_[_0xc012('0x2b')](_0x18518c,function(_0x36ca84){if(_0x36ca84[_0xc012('0x2f')]!==_0xc012('0x3f')){var _0x45ed09={};_0x45ed09[_0x36ca84[_0xc012('0x28')]]={'$like':'%'+_0x13038c[_0xc012('0x31')][_0xc012('0x3d')]+'%'};return _0x45ed09;}})});}_0x3ef96a=_['merge']({},_0x3ef96a,_0x13038c['options']);var _0x1e36a8={'where':_0x3ef96a['where']};return db[_0xc012('0x2c')]['count'](_0x1e36a8)[_0xc012('0x24')](function(_0x1a000b){_0x4fa37f[_0xc012('0x1d')]=_0x1a000b;if(_0x13038c[_0xc012('0x31')][_0xc012('0x40')]){_0x3ef96a['include']=[{'all':!![]}];}return db['SalesforceAccount'][_0xc012('0x41')](_0x3ef96a);})[_0xc012('0x24')](function(_0x41bb19){_0x4fa37f[_0xc012('0x42')]=_0x41bb19;return _0x4fa37f;})[_0xc012('0x24')](respondWithFilteredResult(_0x1ab031,_0x3ef96a))['catch'](handleError(_0x1ab031,null));};exports[_0xc012('0x43')]=function(_0x4bdb41,_0x53f2bc){var _0x16ecf3={'raw':![],'where':{'id':_0x4bdb41['params']['id']}},_0x4bca79={};_0x4bca79[_0xc012('0x35')]=_['keys'](db[_0xc012('0x2c')][_0xc012('0x2d')]);_0x4bca79[_0xc012('0x31')]=_[_0xc012('0x32')](_0x4bdb41['query']);_0x4bca79[_0xc012('0x33')]=_['intersection'](_0x4bca79['model'],_0x4bca79[_0xc012('0x31')]);_0x16ecf3[_0xc012('0x37')]=_[_0xc012('0x34')](_0x4bca79[_0xc012('0x35')],qs[_0xc012('0x36')](_0x4bdb41[_0xc012('0x31')][_0xc012('0x36')]));_0x16ecf3[_0xc012('0x37')]=_0x16ecf3['attributes'][_0xc012('0x38')]?_0x16ecf3[_0xc012('0x37')]:_0x4bca79[_0xc012('0x35')];if(_0x4bdb41[_0xc012('0x31')][_0xc012('0x40')]){_0x16ecf3[_0xc012('0x44')]=[{'all':!![]}];}_0x16ecf3=_['merge']({},_0x16ecf3,_0x4bdb41[_0xc012('0x45')]);return db[_0xc012('0x2c')][_0xc012('0x46')](_0x16ecf3)[_0xc012('0x24')](handleEntityNotFound(_0x53f2bc,null))[_0xc012('0x24')](respondWithResult(_0x53f2bc,null))[_0xc012('0x47')](handleError(_0x53f2bc,null));};exports[_0xc012('0x48')]=function(_0x56dc8e,_0x566f83){return db[_0xc012('0x2c')][_0xc012('0x48')](_0x56dc8e['body'],{})[_0xc012('0x24')](respondWithResult(_0x566f83,0xc9))[_0xc012('0x47')](handleError(_0x566f83,null));};exports['update']=function(_0x4df923,_0x1a745d){if(_0x4df923[_0xc012('0x49')]['id']){delete _0x4df923['body']['id'];}return db[_0xc012('0x2c')]['find']({'where':{'id':_0x4df923['params']['id']}})[_0xc012('0x24')](handleEntityNotFound(_0x1a745d,null))[_0xc012('0x24')](saveUpdates(_0x4df923[_0xc012('0x49')],null))[_0xc012('0x24')](respondWithResult(_0x1a745d,null))[_0xc012('0x47')](handleError(_0x1a745d,null));};exports[_0xc012('0x23')]=function(_0x19837d,_0xae71bb){return db['SalesforceAccount']['find']({'where':{'id':_0x19837d[_0xc012('0x4a')]['id']}})['then'](handleEntityNotFound(_0xae71bb,null))[_0xc012('0x24')](removeEntity(_0xae71bb,null))['catch'](handleError(_0xae71bb,null));};exports['getConfigurations']=function(_0x228243,_0x15e2f0,_0x55f69c){var _0x197996={};var _0x46a576={};var _0x1c0f28;var _0x50288e;return db[_0xc012('0x2c')]['findOne']({'where':{'id':_0x228243[_0xc012('0x4a')]['id']}})['then'](handleEntityNotFound(_0x15e2f0,null))[_0xc012('0x24')](function(_0x3a8705){if(_0x3a8705){_0x1c0f28=_0x3a8705;_0x46a576[_0xc012('0x35')]=_[_0xc012('0x32')](db[_0xc012('0x4b')]['rawAttributes']);_0x46a576[_0xc012('0x31')]=_['keys'](_0x228243[_0xc012('0x31')]);_0x46a576[_0xc012('0x33')]=_[_0xc012('0x34')](_0x46a576[_0xc012('0x35')],_0x46a576[_0xc012('0x31')]);_0x197996[_0xc012('0x37')]=_[_0xc012('0x34')](_0x46a576[_0xc012('0x35')],qs[_0xc012('0x36')](_0x228243[_0xc012('0x31')]['fields']));_0x197996[_0xc012('0x37')]=_0x197996['attributes']['length']?_0x197996[_0xc012('0x37')]:_0x46a576[_0xc012('0x35')];_0x197996[_0xc012('0x3b')]=qs[_0xc012('0x3c')](_0x228243[_0xc012('0x31')][_0xc012('0x3c')]);_0x197996[_0xc012('0x3e')]=qs[_0xc012('0x33')](_[_0xc012('0x4c')](_0x228243[_0xc012('0x31')],_0x46a576[_0xc012('0x33')]));if(_0x228243[_0xc012('0x31')][_0xc012('0x3d')]){_0x197996[_0xc012('0x3e')]=_['merge'](_0x197996[_0xc012('0x3e')],{'$or':_[_0xc012('0x2b')](_0x197996['attributes'],function(_0x74c9ee){var _0x11cc76={};_0x11cc76[_0x74c9ee]={'$like':'%'+_0x228243[_0xc012('0x31')]['filter']+'%'};return _0x11cc76;})});}_0x197996=_[_0xc012('0x4d')]({},_0x197996,_0x228243[_0xc012('0x45')]);return _0x1c0f28['getConfigurations'](_0x197996);}})[_0xc012('0x24')](function(_0x1a8c95){if(_0x1a8c95){_0x50288e=_0x1a8c95[_0xc012('0x38')];if(!_0x228243[_0xc012('0x31')][_0xc012('0x39')]('nolimit')){_0x197996[_0xc012('0x1c')]=qs[_0xc012('0x1c')](_0x228243[_0xc012('0x31')][_0xc012('0x1c')]);_0x197996['offset']=qs['offset'](_0x228243[_0xc012('0x31')][_0xc012('0x1a')]);}return _0x1c0f28[_0xc012('0x4e')](_0x197996);}})[_0xc012('0x24')](function(_0x4c3372){if(_0x4c3372){return _0x4c3372?{'count':_0x50288e,'rows':_0x4c3372}:null;}})[_0xc012('0x24')](respondWithResult(_0x15e2f0,null))['catch'](handleError(_0x15e2f0,null));};exports['addConfiguration']=function(_0x3c1afd,_0x99c728,_0x1ab9cd){if(_0x3c1afd[_0xc012('0x49')]['id']){delete _0x3c1afd['body']['id'];}return db['SalesforceAccount'][_0xc012('0x4f')]({'where':{'id':_0x3c1afd[_0xc012('0x4a')]['id']}})[_0xc012('0x24')](handleEntityNotFound(_0x99c728,null))[_0xc012('0x24')](function(_0x3e0371){if(_0x3e0371){_0x3c1afd['body']['AccountId']=_0x3e0371['id'];_0x3c1afd[_0xc012('0x49')]['Subjects']=integrations[_0xc012('0x50')](_0x3c1afd[_0xc012('0x49')][_0xc012('0x51')],_0x3c1afd[_0xc012('0x49')][_0xc012('0x2f')]);_0x3c1afd[_0xc012('0x49')][_0xc012('0x52')]=integrations[_0xc012('0x53')](_0x3c1afd[_0xc012('0x49')]['channel'],_0x3c1afd['body']['type']);return db[_0xc012('0x4b')][_0xc012('0x48')](_0x3c1afd['body'],{'include':[{'model':db['SalesforceField'],'as':_0xc012('0x54')},{'model':db['SalesforceField'],'as':_0xc012('0x52')}]});}return null;})[_0xc012('0x24')](respondWithResult(_0x99c728,null))['catch'](handleError(_0x99c728,null));};exports[_0xc012('0x55')]=function(_0xa7a835,_0x541b1d,_0x56a604){var _0x3d586c;var _0x502111='';var _0x2b2d6b=_0xc012('0x56');return db[_0xc012('0x2c')]['findOne']({'where':{'id':_0xa7a835[_0xc012('0x4a')]['id']},'attributes':['id',_0xc012('0x57'),'clientId',_0xc012('0x58'),'username',_0xc012('0x59'),'securityToken']})[_0xc012('0x24')](handleEntityNotFound(_0x541b1d,null))[_0xc012('0x24')](function(_0x5d5072){if(_0x5d5072){_0x502111=_0x5d5072[_0xc012('0x57')];var _0x5dac05=_0x502111[_0xc012('0x5a')](-0x1);if(_0x5dac05==='/'){_0x502111=_0x502111['substring'](0x0,_0x502111[_0xc012('0x5b')](_0x5dac05));}_0x3d586c=new jsforce[(_0xc012('0x5c'))]({'oauth2':{'loginUrl':_0x502111,'clientId':_0x5d5072[_0xc012('0x5d')],'clientSecret':_0x5d5072[_0xc012('0x58')]}});return _0x3d586c[_0xc012('0x5e')](_0x5d5072[_0xc012('0x5f')],_0x5d5072[_0xc012('0x59')]['concat'](_0x5d5072[_0xc012('0x60')]));}})[_0xc012('0x24')](function(_0xd24906){if(_0xd24906){if(!_['isNil'](_0xa7a835['query'][_0xc012('0x61')])){_0x2b2d6b=_0xa7a835[_0xc012('0x31')][_0xc012('0x61')];}return _0x3d586c['sobject'](_0x2b2d6b)[_0xc012('0x62')]();}})[_0xc012('0x24')](function(_0x596613){var _0x247496=[_0xc012('0x63'),'ActivityDate','IsReminderSet',_0xc012('0x64'),_0xc012('0x65'),_0xc012('0x66')];var _0x2a67ee=[_0xc012('0x67'),_0xc012('0x68'),'picklist',_0xc012('0x69'),_0xc012('0x6a'),_0xc012('0x6b'),_0xc012('0x6c')];if(_0x596613){_['remove'](_0x596613[_0xc012('0x36')],function(_0x137eea){return _0x247496[_0xc012('0x6d')](_0x137eea[_0xc012('0x28')])||!_0x2a67ee['includes'](_0x137eea[_0xc012('0x2f')]);});return{'count':_0x596613[_0xc012('0x36')][_0xc012('0x38')],'rows':_[_0xc012('0x2b')](_0x596613['fields'],function(_0x1303a5){return{'id':_0x1303a5[_0xc012('0x28')],'name':_0x1303a5[_0xc012('0x6e')],'custom':_0x1303a5[_0xc012('0x6f')],'options':_0x1303a5['picklistValues']['length']>0x0?_['map'](_0x1303a5[_0xc012('0x70')],function(_0x2d5bd3){return{'name':_0x2d5bd3['label'],'value':_0x2d5bd3[_0xc012('0x71')]};}):_0x1303a5[_0xc012('0x2f')]==_0xc012('0x69')?[{'name':_0xc012('0x72'),'value':_0xc012('0x73')},{'name':_0xc012('0x74'),'value':_0xc012('0x75')}]:[]};})};}})[_0xc012('0x24')](respondWithResult(_0x541b1d,null))[_0xc012('0x47')](function(_0x29028b){var _0x3de3e7=_0xa7a835[_0xc012('0x31')][_0xc012('0x76')]?0x1f4:_0x29028b[_0xc012('0x77')]||0x1f4;logger[_0xc012('0x26')](_0xc012('0x78'),_0xc012('0x55'),_0x3de3e7,JSON['stringify'](_0x29028b));delete _0x29028b[_0xc012('0x28')];if(_0x3de3e7===0x191){_0x3de3e7=0x190;}_0x541b1d[_0xc012('0x18')](_0x3de3e7)[_0xc012('0x29')](_0xa7a835['query']['test']?{'message':_0xc012('0x79'),'statusCode':_0x29028b[_0xc012('0x77')]}:_0x29028b);});};
\ No newline at end of file