@app-connect/core 1.7.37 → 1.7.38
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +17 -16
- package/dist/connector/developerPortal.d.ts +6 -0
- package/{connector → dist/connector}/developerPortal.js +29 -12
- package/dist/connector/mock.d.ts +1 -0
- package/{connector → dist/connector}/mock.js +33 -17
- package/dist/connector/proxy/engine.d.ts +10 -0
- package/dist/connector/proxy/engine.js +222 -0
- package/dist/connector/proxy/index.d.ts +5 -0
- package/dist/connector/proxy/index.js +511 -0
- package/dist/connector/registry.d.ts +1 -0
- package/dist/connector/registry.js +243 -0
- package/dist/handlers/admin.d.ts +1 -0
- package/{handlers → dist/handlers}/admin.js +137 -78
- package/dist/handlers/appointment.d.ts +9 -0
- package/{handlers → dist/handlers}/appointment.js +58 -29
- package/dist/handlers/auth.d.ts +9 -0
- package/{handlers → dist/handlers}/auth.js +68 -40
- package/dist/handlers/calldown.d.ts +10 -0
- package/dist/handlers/calldown.js +134 -0
- package/dist/handlers/contact.d.ts +1 -0
- package/{handlers → dist/handlers}/contact.js +61 -39
- package/dist/handlers/disposition.d.ts +1 -0
- package/{handlers → dist/handlers}/disposition.js +20 -10
- package/dist/handlers/log.d.ts +1 -0
- package/{handlers → dist/handlers}/log.js +91 -124
- package/dist/handlers/managedAuth.d.ts +1 -0
- package/{handlers → dist/handlers}/managedAuth.js +134 -61
- package/dist/handlers/managedOAuth.d.ts +13 -0
- package/{handlers → dist/handlers}/managedOAuth.js +102 -30
- package/dist/handlers/plugin.d.ts +1 -0
- package/{handlers → dist/handlers}/plugin.js +59 -27
- package/dist/handlers/user.d.ts +1 -0
- package/{handlers → dist/handlers}/user.js +45 -27
- package/dist/index.d.ts +1 -0
- package/{index.js → dist/index.js} +538 -449
- package/dist/jest.config.d.ts +1 -0
- package/dist/jest.config.js +65 -0
- package/dist/lib/analytics.d.ts +4 -0
- package/{lib → dist/lib}/analytics.js +8 -6
- package/dist/lib/authSession.d.ts +5 -0
- package/{lib → dist/lib}/authSession.js +15 -43
- package/dist/lib/cacheCleanup.d.ts +4 -0
- package/{lib → dist/lib}/cacheCleanup.js +5 -17
- package/dist/lib/callLogComposer.d.ts +109 -0
- package/{lib → dist/lib}/callLogComposer.js +157 -197
- package/dist/lib/callLogLookup.d.ts +6 -0
- package/{lib → dist/lib}/callLogLookup.js +12 -34
- package/dist/lib/constants.d.ts +6 -0
- package/dist/lib/constants.js +9 -0
- package/dist/lib/debugTracer.d.ts +17 -0
- package/{lib → dist/lib}/debugTracer.js +7 -83
- package/dist/lib/encode.d.ts +3 -0
- package/dist/lib/encode.js +50 -0
- package/dist/lib/errorHandler.d.ts +7 -0
- package/dist/lib/errorHandler.js +161 -0
- package/dist/lib/generalErrorMessage.d.ts +7 -0
- package/{lib → dist/lib}/generalErrorMessage.js +6 -6
- package/dist/lib/jwt.d.ts +4 -0
- package/dist/lib/jwt.js +18 -0
- package/dist/lib/logger.d.ts +24 -0
- package/dist/lib/logger.js +126 -0
- package/dist/lib/migrateCallLogsSchema.d.ts +32 -0
- package/{lib → dist/lib}/migrateCallLogsSchema.js +75 -160
- package/dist/lib/oauth.d.ts +4 -0
- package/{lib → dist/lib}/oauth.js +157 -160
- package/dist/lib/ringcentral.d.ts +24 -0
- package/dist/lib/ringcentral.js +226 -0
- package/dist/lib/s3ErrorLogReport.d.ts +4 -0
- package/{lib → dist/lib}/s3ErrorLogReport.js +11 -23
- package/dist/lib/sharedSMSComposer.d.ts +7 -0
- package/{lib → dist/lib}/sharedSMSComposer.js +21 -107
- package/dist/lib/util.d.ts +7 -0
- package/{lib → dist/lib}/util.js +9 -20
- package/dist/mcp/lib/oauthError.d.ts +1 -0
- package/dist/mcp/lib/oauthError.js +25 -0
- package/dist/mcp/lib/validator.d.ts +1 -0
- package/{mcp → dist/mcp}/lib/validator.js +16 -20
- package/dist/mcp/lib/widgetSessionToken.d.ts +1 -0
- package/dist/mcp/lib/widgetSessionToken.js +46 -0
- package/dist/mcp/mcpHandler.d.ts +8 -0
- package/{mcp → dist/mcp}/mcpHandler.js +98 -88
- package/dist/mcp/tools/cancelAppointment.d.ts +1 -0
- package/{mcp → dist/mcp}/tools/cancelAppointment.js +7 -16
- package/dist/mcp/tools/checkAuthStatus.d.ts +1 -0
- package/{mcp → dist/mcp}/tools/checkAuthStatus.js +21 -14
- package/dist/mcp/tools/confirmAppointment.d.ts +1 -0
- package/{mcp → dist/mcp}/tools/confirmAppointment.js +7 -16
- package/dist/mcp/tools/createAppointment.d.ts +1 -0
- package/{mcp → dist/mcp}/tools/createAppointment.js +7 -19
- package/dist/mcp/tools/createCallLog.d.ts +1 -0
- package/{mcp → dist/mcp}/tools/createCallLog.js +18 -29
- package/dist/mcp/tools/createContact.d.ts +1 -0
- package/{mcp → dist/mcp}/tools/createContact.js +8 -20
- package/dist/mcp/tools/createMessageLog.d.ts +1 -0
- package/{mcp → dist/mcp}/tools/createMessageLog.js +14 -26
- package/dist/mcp/tools/doAuth.d.ts +1 -0
- package/{mcp → dist/mcp}/tools/doAuth.js +17 -13
- package/dist/mcp/tools/findContactByName.d.ts +1 -0
- package/{mcp → dist/mcp}/tools/findContactByName.js +9 -15
- package/dist/mcp/tools/findContactByPhone.d.ts +1 -0
- package/{mcp → dist/mcp}/tools/findContactByPhone.js +8 -15
- package/dist/mcp/tools/getCallLog.d.ts +1 -0
- package/{mcp → dist/mcp}/tools/getCallLog.js +12 -21
- package/dist/mcp/tools/getGoogleFilePicker.d.ts +1 -0
- package/{mcp → dist/mcp}/tools/getGoogleFilePicker.js +9 -18
- package/dist/mcp/tools/getHelp.d.ts +1 -0
- package/{mcp → dist/mcp}/tools/getHelp.js +5 -6
- package/dist/mcp/tools/getPublicConnectors.d.ts +1 -0
- package/{mcp → dist/mcp}/tools/getPublicConnectors.js +19 -18
- package/dist/mcp/tools/getSessionInfo.d.ts +1 -0
- package/{mcp → dist/mcp}/tools/getSessionInfo.js +10 -16
- package/dist/mcp/tools/index.d.ts +8 -0
- package/dist/mcp/tools/index.js +50 -0
- package/dist/mcp/tools/listAppointments.d.ts +1 -0
- package/{mcp → dist/mcp}/tools/listAppointments.js +7 -19
- package/dist/mcp/tools/logout.d.ts +1 -0
- package/{mcp → dist/mcp}/tools/logout.js +16 -14
- package/dist/mcp/tools/rcGetCallLogs.d.ts +1 -0
- package/{mcp → dist/mcp}/tools/rcGetCallLogs.js +10 -8
- package/dist/mcp/tools/updateAppointment.d.ts +1 -0
- package/{mcp → dist/mcp}/tools/updateAppointment.js +17 -22
- package/dist/mcp/tools/updateCallLog.d.ts +1 -0
- package/{mcp → dist/mcp}/tools/updateCallLog.js +16 -26
- package/dist/models/accountDataModel.d.ts +3 -0
- package/dist/models/accountDataModel.js +39 -0
- package/dist/models/adminConfigModel.d.ts +2 -0
- package/dist/models/adminConfigModel.js +39 -0
- package/dist/models/cacheModel.d.ts +2 -0
- package/{models → dist/models}/cacheModel.js +7 -3
- package/dist/models/callDownListModel.d.ts +2 -0
- package/{models → dist/models}/callDownListModel.js +8 -4
- package/dist/models/callLogModel.d.ts +2 -0
- package/dist/models/callLogModel.js +43 -0
- package/dist/models/dynamo/connectorSchema.d.ts +2 -0
- package/dist/models/dynamo/connectorSchema.js +141 -0
- package/dist/models/dynamo/lockSchema.d.ts +2 -0
- package/{models → dist/models}/dynamo/lockSchema.js +5 -7
- package/dist/models/dynamo/noteCacheSchema.d.ts +2 -0
- package/{models → dist/models}/dynamo/noteCacheSchema.js +4 -6
- package/dist/models/llmSessionModel.d.ts +2 -0
- package/dist/models/llmSessionModel.js +21 -0
- package/dist/models/messageLogModel.d.ts +2 -0
- package/{models → dist/models}/messageLogModel.js +8 -4
- package/dist/models/sequelize.d.ts +2 -0
- package/dist/models/sequelize.js +68 -0
- package/dist/models/userModel.d.ts +2 -0
- package/dist/models/userModel.js +49 -0
- package/dist/package.json +100 -0
- package/dist/releaseNotes.json +1222 -0
- package/dist/tsconfig.json +14 -0
- package/dist/types/admin.d.ts +141 -0
- package/dist/types/analytics.d.ts +14 -0
- package/dist/types/appointment.d.ts +50 -0
- package/dist/types/auth.d.ts +137 -0
- package/dist/types/authSession.d.ts +35 -0
- package/dist/types/cacheCleanup.d.ts +12 -0
- package/dist/types/calldown.d.ts +54 -0
- package/dist/types/common.d.ts +46 -0
- package/dist/types/connector.d.ts +165 -0
- package/dist/types/contact.d.ts +125 -0
- package/dist/types/errorHandler.d.ts +60 -0
- package/dist/types/index.d.ts +76 -0
- package/dist/types/json.d.ts +9 -0
- package/dist/types/jwt.d.ts +8 -0
- package/dist/types/logging.d.ts +224 -0
- package/dist/types/managedAuth.d.ts +114 -0
- package/dist/types/managedOAuth.d.ts +59 -0
- package/dist/types/manifest.d.ts +120 -0
- package/dist/types/migration.d.ts +15 -0
- package/dist/types/plugin.d.ts +74 -0
- package/dist/types/ringcentral.d.ts +61 -0
- package/dist/types/s3ErrorLogReport.d.ts +16 -0
- package/dist/types/sharedSMSComposer.d.ts +105 -0
- package/dist/types/user.d.ts +46 -0
- package/dist/types/util.d.ts +7 -0
- package/package.json +34 -6
- package/releaseNotes.json +8 -0
- package/.env.test +0 -5
- package/connector/proxy/engine.js +0 -165
- package/connector/proxy/index.js +0 -500
- package/connector/registry.js +0 -252
- package/docs/README.md +0 -50
- package/docs/architecture.md +0 -94
- package/docs/connectors.md +0 -116
- package/docs/handlers.md +0 -128
- package/docs/libraries.md +0 -98
- package/docs/models.md +0 -146
- package/docs/routes.md +0 -119
- package/docs/tests.md +0 -73
- package/handlers/calldown.js +0 -99
- package/jest.config.js +0 -57
- package/lib/constants.js +0 -9
- package/lib/encode.js +0 -30
- package/lib/errorHandler.js +0 -218
- package/lib/jwt.js +0 -18
- package/lib/logger.js +0 -190
- package/lib/ringcentral.js +0 -267
- package/mcp/README.md +0 -420
- package/mcp/tools/index.js +0 -51
- package/mcp/ui/App/App.tsx +0 -358
- package/mcp/ui/App/components/AuthInfoForm.tsx +0 -113
- package/mcp/ui/App/components/AuthSuccess.tsx +0 -22
- package/mcp/ui/App/components/ConnectorList.tsx +0 -82
- package/mcp/ui/App/components/DebugPanel.tsx +0 -43
- package/mcp/ui/App/components/OAuthConnect.tsx +0 -270
- package/mcp/ui/App/lib/callTool.ts +0 -130
- package/mcp/ui/App/lib/debugLog.ts +0 -41
- package/mcp/ui/App/lib/developerPortal.ts +0 -111
- package/mcp/ui/App/main.css +0 -6
- package/mcp/ui/App/root.tsx +0 -13
- package/mcp/ui/dist/index.html +0 -53
- package/mcp/ui/vite.config.ts +0 -16
- package/models/accountDataModel.js +0 -34
- package/models/adminConfigModel.js +0 -35
- package/models/callLogModel.js +0 -39
- package/models/dynamo/connectorSchema.js +0 -146
- package/models/llmSessionModel.js +0 -17
- package/models/sequelize.js +0 -17
- package/models/userModel.js +0 -45
- package/test/connector/developerPortal.test.js +0 -166
- package/test/connector/mock.test.js +0 -131
- package/test/connector/proxy/engine.test.js +0 -211
- package/test/connector/proxy/index.test.js +0 -525
- package/test/connector/proxy/sample.json +0 -162
- package/test/connector/registry.test.js +0 -416
- package/test/handlers/admin.test.js +0 -960
- package/test/handlers/appointment.test.js +0 -260
- package/test/handlers/auth.test.js +0 -1096
- package/test/handlers/calldown.test.js +0 -310
- package/test/handlers/contact.test.js +0 -1014
- package/test/handlers/disposition.test.js +0 -396
- package/test/handlers/log.test.js +0 -1847
- package/test/handlers/managedAuth.test.js +0 -458
- package/test/handlers/managedOAuth.test.js +0 -262
- package/test/handlers/plugin.test.js +0 -429
- package/test/handlers/user.test.js +0 -381
- package/test/index.test.js +0 -301
- package/test/lib/analytics.test.js +0 -146
- package/test/lib/authSession.test.js +0 -173
- package/test/lib/cacheCleanup.test.js +0 -127
- package/test/lib/callLogComposer.test.js +0 -1231
- package/test/lib/debugTracer.test.js +0 -328
- package/test/lib/encode.test.js +0 -59
- package/test/lib/errorHandler.test.js +0 -246
- package/test/lib/generalErrorMessage.test.js +0 -82
- package/test/lib/jwt.test.js +0 -176
- package/test/lib/logger.test.js +0 -206
- package/test/lib/oauth.test.js +0 -359
- package/test/lib/ringcentral.test.js +0 -467
- package/test/lib/s3ErrorLogReport.test.js +0 -187
- package/test/lib/sharedSMSComposer.test.js +0 -1084
- package/test/lib/util.test.js +0 -329
- package/test/mcp/mcpHandler.test.js +0 -73
- package/test/mcp/mcpHandlerMore.test.js +0 -384
- package/test/mcp/tools/appointmentTools.test.js +0 -362
- package/test/mcp/tools/checkAuthStatus.test.js +0 -83
- package/test/mcp/tools/createCallLog.test.js +0 -436
- package/test/mcp/tools/createContact.test.js +0 -58
- package/test/mcp/tools/createMessageLog.test.js +0 -595
- package/test/mcp/tools/doAuth.test.js +0 -113
- package/test/mcp/tools/findContactByName.test.js +0 -275
- package/test/mcp/tools/findContactByPhone.test.js +0 -296
- package/test/mcp/tools/getCallLog.test.js +0 -298
- package/test/mcp/tools/getGoogleFilePicker.test.js +0 -281
- package/test/mcp/tools/getPublicConnectors.test.js +0 -107
- package/test/mcp/tools/getSessionInfo.test.js +0 -127
- package/test/mcp/tools/logout.test.js +0 -233
- package/test/mcp/tools/rcGetCallLogs.test.js +0 -56
- package/test/mcp/tools/updateCallLog.test.js +0 -360
- package/test/models/accountDataModel.test.js +0 -98
- package/test/models/callDownListModel.test.js +0 -125
- package/test/models/dynamo/connectorSchema.test.js +0 -189
- package/test/models/dynamo/lockSchema.test.js +0 -37
- package/test/models/dynamo/noteCacheSchema.test.js +0 -45
- package/test/models/llmSessionModel.test.js +0 -91
- package/test/models/models.test.js +0 -660
- package/test/routes/calldownRoutes.test.js +0 -224
- package/test/routes/coreRouterBroadRoutes.test.js +0 -855
- package/test/routes/dispositionRoutes.test.js +0 -192
- package/test/routes/managedAuthRoutes.test.js +0 -386
- package/test/routes/pluginRoutes.test.js +0 -262
- package/test/setup.js +0 -178
- /package/{mcp → dist/mcp}/ui/index.html +0 -0
- /package/{mcp → dist/mcp}/ui/package-lock.json +0 -0
- /package/{mcp → dist/mcp}/ui/package.json +0 -0
- /package/{mcp → dist/mcp}/ui/tsconfig.json +0 -0
package/connector/proxy/index.js
DELETED
|
@@ -1,500 +0,0 @@
|
|
|
1
|
-
/* eslint-disable no-param-reassign */
|
|
2
|
-
const { parsePhoneNumber } = require('awesome-phonenumber');
|
|
3
|
-
const moment = require('moment');
|
|
4
|
-
const {
|
|
5
|
-
performRequest,
|
|
6
|
-
mapFindContactResponse,
|
|
7
|
-
mapCreateCallLogResponse,
|
|
8
|
-
mapGetCallLogResponse,
|
|
9
|
-
getByPath,
|
|
10
|
-
} = require('./engine');
|
|
11
|
-
const { Connector } = require('../../models/dynamo/connectorSchema');
|
|
12
|
-
const { UserModel } = require('../../models/userModel');
|
|
13
|
-
const logger = require('../../lib/logger');
|
|
14
|
-
const { handleDatabaseError } = require('../../lib/errorHandler');
|
|
15
|
-
|
|
16
|
-
async function loadPlatformConfig(proxyId) {
|
|
17
|
-
if (!proxyId) {
|
|
18
|
-
return null;
|
|
19
|
-
}
|
|
20
|
-
try {
|
|
21
|
-
const proxyConfig = await Connector.getProxyConfig(proxyId);
|
|
22
|
-
return proxyConfig;
|
|
23
|
-
} catch (error) {
|
|
24
|
-
logger.error('Error getting proxy config: ', { proxyId, stack: error.stack });
|
|
25
|
-
return null;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
async function getAuthType({ proxyId, proxyConfig } = {}) {
|
|
30
|
-
const cfg = proxyConfig ? proxyConfig : (await loadPlatformConfig(proxyId));
|
|
31
|
-
if (!cfg) {
|
|
32
|
-
return 'apiKey';
|
|
33
|
-
}
|
|
34
|
-
return cfg.auth.type || 'apiKey';
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
async function getOauthInfo({ proxyId, proxyConfig, tokenUrl } = {}) {
|
|
38
|
-
const cfg = proxyConfig ? proxyConfig : (await loadPlatformConfig(proxyId));
|
|
39
|
-
if (!cfg) {
|
|
40
|
-
return {};
|
|
41
|
-
}
|
|
42
|
-
return {
|
|
43
|
-
clientId: cfg.auth.clientId,
|
|
44
|
-
clientSecret: cfg.auth.clientSecret,
|
|
45
|
-
accessTokenUri: tokenUrl || cfg.auth.tokenUrl,
|
|
46
|
-
redirectUri: cfg.auth.redirectUri,
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
function getBasicAuth({ apiKey }) {
|
|
51
|
-
return Buffer.from(`${apiKey}:`).toString('base64');
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
async function getUserInfo({ authHeader, hostname, additionalInfo, platform, apiKey, proxyId, proxyConfig, userEmail } = {}) {
|
|
55
|
-
const cfg = proxyConfig ? proxyConfig : (await loadPlatformConfig(proxyId));
|
|
56
|
-
if (!cfg || !cfg.operations?.getUserInfo) {
|
|
57
|
-
// Fallback if no getUserInfo operation defined
|
|
58
|
-
return {
|
|
59
|
-
successful: false,
|
|
60
|
-
returnMessage: {
|
|
61
|
-
messageType: 'warning',
|
|
62
|
-
message: `Could not load user information. The platform does not support getUserInfo operation.`,
|
|
63
|
-
ttl: 1000
|
|
64
|
-
}
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
const response = await performRequest({
|
|
68
|
-
config: cfg,
|
|
69
|
-
opName: 'getUserInfo',
|
|
70
|
-
inputs: {
|
|
71
|
-
additionalInfo,
|
|
72
|
-
apiKey,
|
|
73
|
-
hostname,
|
|
74
|
-
platform,
|
|
75
|
-
userEmail,
|
|
76
|
-
},
|
|
77
|
-
user: {},
|
|
78
|
-
authHeader
|
|
79
|
-
});
|
|
80
|
-
const map = cfg.operations.getUserInfo.responseMapping || {};
|
|
81
|
-
const responseCtx = {
|
|
82
|
-
body: response.data,
|
|
83
|
-
additionalInfo,
|
|
84
|
-
apiKey,
|
|
85
|
-
hostname,
|
|
86
|
-
platform,
|
|
87
|
-
};
|
|
88
|
-
const rawUserId = map.idPath ? getByPath(responseCtx, map.idPath) : undefined;
|
|
89
|
-
const id = `${rawUserId}-${platform}`;
|
|
90
|
-
const name = map.namePath ? getByPath(responseCtx, map.namePath) : rawUserId;
|
|
91
|
-
const timezoneName = map.timezoneNamePath ? getByPath(responseCtx, map.timezoneNamePath) : undefined;
|
|
92
|
-
const overridingApiKey = map.overridingApiKeyPath ? getByPath(responseCtx, map.overridingApiKeyPath) : undefined;
|
|
93
|
-
// platformAdditionalInfo mapping and cleanup
|
|
94
|
-
const platformAdditionalInfo = Object.assign({}, additionalInfo || {});
|
|
95
|
-
if (platformAdditionalInfo.password) delete platformAdditionalInfo.password;
|
|
96
|
-
if (map.platformAdditionalInfoPaths && typeof map.platformAdditionalInfoPaths === 'object') {
|
|
97
|
-
for (const [key, expr] of Object.entries(map.platformAdditionalInfoPaths)) {
|
|
98
|
-
platformAdditionalInfo[key] = getByPath(responseCtx, expr);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
const message = map.messagePath ? (getByPath(responseCtx, map.messagePath) || `Connected to ${platform}.`) : `Connected to ${platform}.`;
|
|
102
|
-
return {
|
|
103
|
-
successful: true,
|
|
104
|
-
platformUserInfo: Object.assign(
|
|
105
|
-
{ id, name },
|
|
106
|
-
timezoneName ? { timezoneName } : {},
|
|
107
|
-
overridingApiKey ? { overridingApiKey } : {},
|
|
108
|
-
Object.keys(platformAdditionalInfo).length ? { platformAdditionalInfo } : {}
|
|
109
|
-
),
|
|
110
|
-
returnMessage: {
|
|
111
|
-
messageType: 'success',
|
|
112
|
-
message,
|
|
113
|
-
ttl: 1000
|
|
114
|
-
}
|
|
115
|
-
};
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
async function getUserList({ user, authHeader, proxyConfig }) {
|
|
119
|
-
const cfg = proxyConfig ? proxyConfig : (await loadPlatformConfig(user?.platformAdditionalInfo?.proxyId));
|
|
120
|
-
if (!cfg.operations?.getUserList) {
|
|
121
|
-
return [];
|
|
122
|
-
}
|
|
123
|
-
const response = await performRequest({
|
|
124
|
-
config: cfg,
|
|
125
|
-
opName: 'getUserList',
|
|
126
|
-
inputs: { user },
|
|
127
|
-
user,
|
|
128
|
-
authHeader
|
|
129
|
-
});
|
|
130
|
-
const map = cfg.operations.getUserList.responseMapping || {};
|
|
131
|
-
const responseCtx = { body: response.data };
|
|
132
|
-
const userList = map.listPath ? getByPath(responseCtx, map.listPath) : [];
|
|
133
|
-
return (userList || []).map(item => ({
|
|
134
|
-
id: getByPath(item, map.idPath || 'id'),
|
|
135
|
-
name: getByPath(item, map.namePath || 'name'),
|
|
136
|
-
email: getByPath(item, map.emailPath || 'email'),
|
|
137
|
-
}));
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
async function unAuthorize({ user }) {
|
|
141
|
-
const cfg = await loadPlatformConfig(user?.platformAdditionalInfo?.proxyId);
|
|
142
|
-
if (cfg?.operations?.unAuthorize) {
|
|
143
|
-
await performRequest({
|
|
144
|
-
config: cfg,
|
|
145
|
-
opName: 'unAuthorize',
|
|
146
|
-
inputs: {},
|
|
147
|
-
user,
|
|
148
|
-
});
|
|
149
|
-
}
|
|
150
|
-
user.accessToken = '';
|
|
151
|
-
user.refreshToken = '';
|
|
152
|
-
try {
|
|
153
|
-
await user.save();
|
|
154
|
-
}
|
|
155
|
-
catch (error) {
|
|
156
|
-
return handleDatabaseError(error, 'Error saving user');
|
|
157
|
-
}
|
|
158
|
-
return {
|
|
159
|
-
successful: true,
|
|
160
|
-
returnMessage: {
|
|
161
|
-
messageType: 'success',
|
|
162
|
-
message: 'Logged out',
|
|
163
|
-
ttl: 1000
|
|
164
|
-
}
|
|
165
|
-
};
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
async function findContact({ user, authHeader, phoneNumber, overridingFormat, isExtension, proxyConfig }) {
|
|
169
|
-
const cfg = proxyConfig ? proxyConfig : (await loadPlatformConfig(user?.platformAdditionalInfo?.proxyId));
|
|
170
|
-
if (!cfg.operations?.findContact) {
|
|
171
|
-
return { successful: true, matchedContactInfo: [] };
|
|
172
|
-
}
|
|
173
|
-
let formattedPhoneNumber = phoneNumber.replace(' ', '+')
|
|
174
|
-
const parsedPhoneNumber = parsePhoneNumber(formattedPhoneNumber);
|
|
175
|
-
const response = await performRequest({
|
|
176
|
-
config: cfg,
|
|
177
|
-
opName: 'findContact',
|
|
178
|
-
inputs: { phoneNumber, parsedPhoneNumber, overridingFormat, isExtension },
|
|
179
|
-
user,
|
|
180
|
-
authHeader
|
|
181
|
-
});
|
|
182
|
-
const matchedContactInfo = mapFindContactResponse({ config: cfg, response, opName: 'findContact' });
|
|
183
|
-
return {
|
|
184
|
-
successful: true,
|
|
185
|
-
matchedContactInfo,
|
|
186
|
-
returnMessage: {
|
|
187
|
-
messageType: 'success',
|
|
188
|
-
message: `Found ${matchedContactInfo.length} contacts`,
|
|
189
|
-
ttl: 3000
|
|
190
|
-
}
|
|
191
|
-
};
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
async function createContact({ user, authHeader, phoneNumber, newContactName, newContactType, additionalSubmission, proxyConfig }) {
|
|
195
|
-
const cfg = proxyConfig ? proxyConfig : (await loadPlatformConfig(user?.platformAdditionalInfo?.proxyId));
|
|
196
|
-
if (!cfg.operations?.createContact) {
|
|
197
|
-
return { contactInfo: null, returnMessage: { message: 'Not supported', messageType: 'warning', ttl: 2000 } };
|
|
198
|
-
}
|
|
199
|
-
const response = await performRequest({
|
|
200
|
-
config: cfg,
|
|
201
|
-
opName: 'createContact',
|
|
202
|
-
inputs: { phoneNumber, newContactName, newContactType, additionalSubmission },
|
|
203
|
-
user,
|
|
204
|
-
authHeader
|
|
205
|
-
});
|
|
206
|
-
const map = cfg.operations.createContact.responseMapping || {};
|
|
207
|
-
const responseCtx = { body: response.data };
|
|
208
|
-
const contactInfo = map.idPath ? {
|
|
209
|
-
id: getByPath(responseCtx, map.idPath || 'body.id'),
|
|
210
|
-
name: getByPath(responseCtx, map.namePath || 'body.name'),
|
|
211
|
-
type: getByPath(responseCtx, map.typePath || 'body.type') || 'Contact',
|
|
212
|
-
} : null;
|
|
213
|
-
return { contactInfo, returnMessage: { message: 'Contact created', messageType: 'success', ttl: 2000 } };
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
async function findContactWithName({ user, authHeader, name, proxyConfig }) {
|
|
217
|
-
const cfg = proxyConfig ? proxyConfig : (await loadPlatformConfig(user?.platformAdditionalInfo?.proxyId));
|
|
218
|
-
if (!cfg.operations?.findContactWithName) {
|
|
219
|
-
return { successful: true, matchedContactInfo: [] };
|
|
220
|
-
}
|
|
221
|
-
const response = await performRequest({
|
|
222
|
-
config: cfg,
|
|
223
|
-
opName: 'findContactWithName',
|
|
224
|
-
inputs: { name },
|
|
225
|
-
user,
|
|
226
|
-
authHeader
|
|
227
|
-
});
|
|
228
|
-
const matchedContactInfo = mapFindContactResponse({ config: cfg, response, opName: 'findContactWithName' });
|
|
229
|
-
return {
|
|
230
|
-
successful: true,
|
|
231
|
-
matchedContactInfo,
|
|
232
|
-
returnMessage: {
|
|
233
|
-
messageType: 'success',
|
|
234
|
-
message: `Found ${matchedContactInfo.length} contacts`,
|
|
235
|
-
ttl: 3000
|
|
236
|
-
}
|
|
237
|
-
};
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
function getLogFormatType(platform, proxyConfig) {
|
|
241
|
-
return proxyConfig ? proxyConfig.meta?.logFormat : 'custom';
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
async function createCallLog({
|
|
245
|
-
user,
|
|
246
|
-
contactInfo,
|
|
247
|
-
authHeader,
|
|
248
|
-
callLog,
|
|
249
|
-
note,
|
|
250
|
-
additionalSubmission,
|
|
251
|
-
aiNote,
|
|
252
|
-
transcript,
|
|
253
|
-
ringSenseTranscript = '',
|
|
254
|
-
ringSenseSummary = '',
|
|
255
|
-
ringSenseAIScore = '',
|
|
256
|
-
ringSenseBulletedSummary = '',
|
|
257
|
-
ringSenseLink = '',
|
|
258
|
-
composedLogDetails,
|
|
259
|
-
hashedAccountId,
|
|
260
|
-
isFromSSCL,
|
|
261
|
-
proxyConfig = null,
|
|
262
|
-
}) {
|
|
263
|
-
const cfg = proxyConfig ? proxyConfig : (await loadPlatformConfig(user?.platformAdditionalInfo?.proxyId));
|
|
264
|
-
if (!cfg || !cfg.operations?.createCallLog) {
|
|
265
|
-
return { logId: undefined, returnMessage: { message: 'Not supported', messageType: 'warning', ttl: 2000 } };
|
|
266
|
-
}
|
|
267
|
-
const response = await performRequest({
|
|
268
|
-
config: cfg,
|
|
269
|
-
opName: 'createCallLog',
|
|
270
|
-
inputs: {
|
|
271
|
-
contactInfo,
|
|
272
|
-
callLog,
|
|
273
|
-
note,
|
|
274
|
-
additionalSubmission,
|
|
275
|
-
aiNote,
|
|
276
|
-
transcript,
|
|
277
|
-
composedLogDetails,
|
|
278
|
-
hashedAccountId,
|
|
279
|
-
isFromSSCL,
|
|
280
|
-
subject: callLog.customSubject ?? `${callLog.direction} Call ${callLog.direction === 'Outbound' ? 'to' : 'from'} ${contactInfo.name}`,
|
|
281
|
-
startTime: moment(callLog.startTime).utc().toISOString(),
|
|
282
|
-
endTime: moment(callLog.startTime).utc().add(callLog.duration, 'seconds').toISOString(),
|
|
283
|
-
ringSenseTranscript,
|
|
284
|
-
ringSenseSummary,
|
|
285
|
-
ringSenseAIScore,
|
|
286
|
-
ringSenseBulletedSummary,
|
|
287
|
-
ringSenseLink,
|
|
288
|
-
},
|
|
289
|
-
user,
|
|
290
|
-
authHeader
|
|
291
|
-
});
|
|
292
|
-
const { logId } = mapCreateCallLogResponse({ config: cfg, response });
|
|
293
|
-
return {
|
|
294
|
-
logId,
|
|
295
|
-
returnMessage: {
|
|
296
|
-
message: 'Call logged',
|
|
297
|
-
messageType: 'success',
|
|
298
|
-
ttl: 2000
|
|
299
|
-
}
|
|
300
|
-
};
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
async function getCallLog({ user, callLogId, contactId, authHeader, proxyConfig = null }) {
|
|
304
|
-
const cfg = proxyConfig ? proxyConfig : (await loadPlatformConfig(user?.platformAdditionalInfo?.proxyId));
|
|
305
|
-
if (!cfg || !cfg.operations?.getCallLog) {
|
|
306
|
-
return { callLogInfo: null, returnMessage: { message: 'Not supported', messageType: 'warning', ttl: 2000 } };
|
|
307
|
-
}
|
|
308
|
-
const response = await performRequest({
|
|
309
|
-
config: cfg,
|
|
310
|
-
opName: 'getCallLog',
|
|
311
|
-
inputs: { thirdPartyLogId: callLogId, contactId },
|
|
312
|
-
user,
|
|
313
|
-
authHeader
|
|
314
|
-
});
|
|
315
|
-
const mapped = mapGetCallLogResponse({ config: cfg, response });
|
|
316
|
-
return Object.assign(mapped, { returnMessage: { message: 'Call log fetched.', messageType: 'success', ttl: 3000 } });
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
async function updateCallLog({
|
|
320
|
-
user,
|
|
321
|
-
existingCallLog,
|
|
322
|
-
authHeader,
|
|
323
|
-
recordingLink,
|
|
324
|
-
recordingDownloadLink,
|
|
325
|
-
subject,
|
|
326
|
-
note,
|
|
327
|
-
startTime,
|
|
328
|
-
duration,
|
|
329
|
-
result,
|
|
330
|
-
aiNote,
|
|
331
|
-
transcript,
|
|
332
|
-
legs,
|
|
333
|
-
ringSenseTranscript = '',
|
|
334
|
-
ringSenseSummary = '',
|
|
335
|
-
ringSenseAIScore = '',
|
|
336
|
-
ringSenseBulletedSummary = '',
|
|
337
|
-
ringSenseLink = '',
|
|
338
|
-
additionalSubmission,
|
|
339
|
-
composedLogDetails,
|
|
340
|
-
existingCallLogDetails,
|
|
341
|
-
hashedAccountId,
|
|
342
|
-
isFromSSCL,
|
|
343
|
-
proxyConfig = null,
|
|
344
|
-
}) {
|
|
345
|
-
const cfg = proxyConfig ? proxyConfig : (await loadPlatformConfig(user?.platformAdditionalInfo?.proxyId));
|
|
346
|
-
if (!cfg || !cfg.operations?.updateCallLog) {
|
|
347
|
-
return { returnMessage: { message: 'Not supported', messageType: 'warning', ttl: 2000 } };
|
|
348
|
-
}
|
|
349
|
-
await performRequest({
|
|
350
|
-
config: cfg,
|
|
351
|
-
opName: 'updateCallLog',
|
|
352
|
-
inputs: {
|
|
353
|
-
thirdPartyLogId: existingCallLog?.thirdPartyLogId,
|
|
354
|
-
existingCallLog,
|
|
355
|
-
recordingLink,
|
|
356
|
-
recordingDownloadLink,
|
|
357
|
-
subject,
|
|
358
|
-
note,
|
|
359
|
-
startTime: moment(startTime).utc().toISOString(),
|
|
360
|
-
endTime: moment(startTime).utc().add(duration, 'seconds').toISOString(),
|
|
361
|
-
duration,
|
|
362
|
-
result,
|
|
363
|
-
aiNote,
|
|
364
|
-
transcript,
|
|
365
|
-
legs,
|
|
366
|
-
additionalSubmission,
|
|
367
|
-
composedLogDetails,
|
|
368
|
-
existingCallLogDetails,
|
|
369
|
-
hashedAccountId,
|
|
370
|
-
isFromSSCL,
|
|
371
|
-
ringSenseTranscript,
|
|
372
|
-
ringSenseSummary,
|
|
373
|
-
ringSenseAIScore,
|
|
374
|
-
ringSenseBulletedSummary,
|
|
375
|
-
ringSenseLink,
|
|
376
|
-
},
|
|
377
|
-
user,
|
|
378
|
-
authHeader
|
|
379
|
-
});
|
|
380
|
-
return {
|
|
381
|
-
updatedNote: null,
|
|
382
|
-
returnMessage: {
|
|
383
|
-
message: 'Call log updated.',
|
|
384
|
-
messageType: 'success',
|
|
385
|
-
ttl: 3000
|
|
386
|
-
}
|
|
387
|
-
};
|
|
388
|
-
}
|
|
389
|
-
|
|
390
|
-
async function upsertCallDisposition({ user, existingCallLog, authHeader, dispositions, proxyConfig }) {
|
|
391
|
-
const cfg = proxyConfig ? proxyConfig : (await loadPlatformConfig(user?.platformAdditionalInfo?.proxyId));
|
|
392
|
-
if (!cfg.operations?.upsertCallDisposition) {
|
|
393
|
-
return { returnMessage: { message: 'Not supported', messageType: 'warning', ttl: 2000 } };
|
|
394
|
-
}
|
|
395
|
-
await performRequest({
|
|
396
|
-
config: cfg,
|
|
397
|
-
opName: 'upsertCallDisposition',
|
|
398
|
-
inputs: { existingCallLog, dispositions, thirdPartyLogId: existingCallLog?.thirdPartyLogId },
|
|
399
|
-
user,
|
|
400
|
-
authHeader
|
|
401
|
-
});
|
|
402
|
-
return { logId: existingCallLog.thirdPartyLogId, returnMessage: { message: 'Disposition updated', messageType: 'success', ttl: 2000 } };
|
|
403
|
-
}
|
|
404
|
-
|
|
405
|
-
async function createMessageLog({ user, contactInfo, authHeader, message, additionalSubmission, recordingLink, faxDocLink, faxDownloadLink, imageLink, videoLink, proxyConfig }) {
|
|
406
|
-
const cfg = proxyConfig ? proxyConfig : (await loadPlatformConfig(user?.platformAdditionalInfo?.proxyId));
|
|
407
|
-
if (!cfg.operations?.createMessageLog) {
|
|
408
|
-
return { logId: undefined, returnMessage: { message: 'Not supported', messageType: 'warning', ttl: 2000 } };
|
|
409
|
-
}
|
|
410
|
-
const response = await performRequest({
|
|
411
|
-
config: cfg,
|
|
412
|
-
opName: 'createMessageLog',
|
|
413
|
-
inputs: {
|
|
414
|
-
contactInfo,
|
|
415
|
-
message,
|
|
416
|
-
additionalSubmission,
|
|
417
|
-
recordingLink,
|
|
418
|
-
faxDocLink,
|
|
419
|
-
faxDownloadLink,
|
|
420
|
-
imageLink,
|
|
421
|
-
videoLink,
|
|
422
|
-
creationTime: moment(message.creationTime).utc().toISOString(),
|
|
423
|
-
},
|
|
424
|
-
user,
|
|
425
|
-
authHeader
|
|
426
|
-
});
|
|
427
|
-
const map = cfg.operations.createMessageLog.responseMapping || {};
|
|
428
|
-
const responseCtx = { body: response.data };
|
|
429
|
-
const logId = getByPath(responseCtx, map.idPath || 'body.id');
|
|
430
|
-
return {
|
|
431
|
-
logId: logId ? String(logId) : undefined,
|
|
432
|
-
returnMessage: { message: 'Message logged', messageType: 'success', ttl: 1000 }
|
|
433
|
-
};
|
|
434
|
-
}
|
|
435
|
-
|
|
436
|
-
async function updateMessageLog({ user, contactInfo, existingMessageLog, message, authHeader, additionalSubmission, imageLink, videoLink, proxyConfig }) {
|
|
437
|
-
const cfg = proxyConfig ? proxyConfig : (await loadPlatformConfig(user?.platformAdditionalInfo?.proxyId));
|
|
438
|
-
if (!cfg.operations?.updateMessageLog) {
|
|
439
|
-
return { returnMessage: { message: 'Not supported', messageType: 'warning', ttl: 2000 } };
|
|
440
|
-
}
|
|
441
|
-
await performRequest({
|
|
442
|
-
config: cfg,
|
|
443
|
-
opName: 'updateMessageLog',
|
|
444
|
-
inputs: {
|
|
445
|
-
contactInfo,
|
|
446
|
-
existingMessageLog,
|
|
447
|
-
thirdPartyLogId: existingMessageLog?.thirdPartyLogId,
|
|
448
|
-
message,
|
|
449
|
-
additionalSubmission,
|
|
450
|
-
imageLink,
|
|
451
|
-
videoLink,
|
|
452
|
-
creationTime: moment(message.creationTime).utc().toISOString(),
|
|
453
|
-
},
|
|
454
|
-
user,
|
|
455
|
-
authHeader
|
|
456
|
-
});
|
|
457
|
-
return { returnMessage: { message: 'Message log updated', messageType: 'success', ttl: 3000 } };
|
|
458
|
-
}
|
|
459
|
-
|
|
460
|
-
async function getLicenseStatus({ userId, platform }) {
|
|
461
|
-
const user = await UserModel.findByPk(userId);
|
|
462
|
-
if (!user || !user.accessToken) {
|
|
463
|
-
return { isLicenseValid: false, licenseStatus: 'Invalid (User not found)', licenseStatusDescription: '' };
|
|
464
|
-
}
|
|
465
|
-
const proxyId = user.platformAdditionalInfo?.proxyId;
|
|
466
|
-
const cfg = await loadPlatformConfig(proxyId);
|
|
467
|
-
if (!cfg.operations?.getLicenseStatus) {
|
|
468
|
-
return { isLicenseValid: true, licenseStatus: 'Basic', licenseStatusDescription: '' };
|
|
469
|
-
}
|
|
470
|
-
const response = await performRequest({
|
|
471
|
-
config: cfg,
|
|
472
|
-
opName: 'getLicenseStatus',
|
|
473
|
-
inputs: { userId, platform },
|
|
474
|
-
user,
|
|
475
|
-
});
|
|
476
|
-
const map = cfg.operations.getLicenseStatus.responseMapping || {};
|
|
477
|
-
const responseCtx = { body: response.data };
|
|
478
|
-
const isLicenseValid = getByPath(responseCtx, map.isLicenseValidPath || 'body.isLicenseValid');
|
|
479
|
-
const licenseStatus = getByPath(responseCtx, map.licenseStatusPath || 'body.licenseStatus');
|
|
480
|
-
const licenseStatusDescription = getByPath(responseCtx, map.licenseStatusDescriptionPath || 'body.licenseStatusDescription');
|
|
481
|
-
return { isLicenseValid, licenseStatus, licenseStatusDescription };
|
|
482
|
-
}
|
|
483
|
-
|
|
484
|
-
exports.getAuthType = getAuthType;
|
|
485
|
-
exports.getOauthInfo = getOauthInfo;
|
|
486
|
-
exports.getBasicAuth = getBasicAuth;
|
|
487
|
-
exports.getUserInfo = getUserInfo;
|
|
488
|
-
exports.createCallLog = createCallLog;
|
|
489
|
-
exports.updateCallLog = updateCallLog;
|
|
490
|
-
exports.getCallLog = getCallLog;
|
|
491
|
-
exports.createMessageLog = createMessageLog;
|
|
492
|
-
exports.updateMessageLog = updateMessageLog;
|
|
493
|
-
exports.findContact = findContact;
|
|
494
|
-
exports.createContact = createContact;
|
|
495
|
-
exports.findContactWithName = findContactWithName;
|
|
496
|
-
exports.unAuthorize = unAuthorize;
|
|
497
|
-
exports.getLicenseStatus = getLicenseStatus;
|
|
498
|
-
exports.upsertCallDisposition = upsertCallDisposition;
|
|
499
|
-
exports.getUserList = getUserList;
|
|
500
|
-
exports.getLogFormatType = getLogFormatType;
|