@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
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
// @ts-check
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
const jwt = /** @type {any} */ (require('../../lib/jwt'));
|
|
5
|
+
const connectorRegistry = /** @type {any} */ (require('../../connector/registry'));
|
|
6
|
+
const appointmentCore = /** @type {any} */ (require('../../handlers/appointment'));
|
|
5
7
|
/**
|
|
6
8
|
* MCP Tool: Update Appointment
|
|
7
9
|
*
|
|
8
10
|
* Updates (reschedules or edits) an existing appointment/event in the CRM platform.
|
|
9
11
|
*/
|
|
10
|
-
|
|
11
12
|
const toolDefinition = {
|
|
12
13
|
name: 'updateAppointment',
|
|
13
14
|
description: '⚠️ REQUIRES CRM CONNECTION. | Update or reschedule an existing appointment or event in the CRM platform. Provide only the fields you want to change alongside the appointmentId.',
|
|
@@ -66,7 +67,6 @@ const toolDefinition = {
|
|
|
66
67
|
destructiveHint: false
|
|
67
68
|
}
|
|
68
69
|
};
|
|
69
|
-
|
|
70
70
|
/**
|
|
71
71
|
* Execute the updateAppointment tool
|
|
72
72
|
* @param {Object} args
|
|
@@ -77,54 +77,50 @@ const toolDefinition = {
|
|
|
77
77
|
* @param {string} [args.startTimeUtc] - New ISO 8601 UTC start time
|
|
78
78
|
* @param {number} [args.durationMinutes] - New duration in minutes
|
|
79
79
|
* @param {Array} [args.contacts] - Updated attendee contact IDs
|
|
80
|
-
* @returns {
|
|
80
|
+
* @returns {Promise<any>} Result with updated appointment data
|
|
81
81
|
*/
|
|
82
82
|
async function execute(args) {
|
|
83
83
|
try {
|
|
84
84
|
const { jwtToken, appointmentId, title, summary, startTimeUtc, durationMinutes, contacts } = args;
|
|
85
|
-
|
|
86
85
|
if (!jwtToken) {
|
|
87
86
|
throw new Error('Please go to Settings and authorize CRM platform');
|
|
88
87
|
}
|
|
89
|
-
|
|
90
88
|
if (!appointmentId) {
|
|
91
89
|
throw new Error('appointmentId is required');
|
|
92
90
|
}
|
|
93
|
-
|
|
94
91
|
const decodedToken = jwt.decodeJwt(jwtToken);
|
|
95
92
|
if (!decodedToken) {
|
|
96
93
|
throw new Error('Invalid JWT token');
|
|
97
94
|
}
|
|
98
95
|
const { id: userId, platform } = decodedToken;
|
|
99
|
-
|
|
100
96
|
if (!userId) {
|
|
101
97
|
throw new Error('Invalid JWT token: userId not found');
|
|
102
98
|
}
|
|
103
|
-
|
|
104
99
|
const platformModule = connectorRegistry.getConnector(platform);
|
|
105
100
|
if (!platformModule) {
|
|
106
101
|
throw new Error(`Platform connector not found for: ${platform}`);
|
|
107
102
|
}
|
|
108
|
-
|
|
109
103
|
if (!platformModule.updateAppointment) {
|
|
110
104
|
throw new Error(`updateAppointment is not implemented for platform: ${platform}`);
|
|
111
105
|
}
|
|
112
|
-
|
|
113
106
|
// Build the patch body from only the fields the caller supplied
|
|
114
107
|
const patchBody = {};
|
|
115
|
-
if (title !== undefined)
|
|
116
|
-
|
|
117
|
-
if (
|
|
118
|
-
|
|
119
|
-
if (
|
|
120
|
-
|
|
108
|
+
if (title !== undefined)
|
|
109
|
+
patchBody.title = title;
|
|
110
|
+
if (summary !== undefined)
|
|
111
|
+
patchBody.summary = summary;
|
|
112
|
+
if (startTimeUtc !== undefined)
|
|
113
|
+
patchBody.startTimeUtc = startTimeUtc;
|
|
114
|
+
if (durationMinutes !== undefined)
|
|
115
|
+
patchBody.durationMinutes = Number(durationMinutes);
|
|
116
|
+
if (contacts !== undefined)
|
|
117
|
+
patchBody.contacts = contacts;
|
|
121
118
|
const { successful, appointment, returnMessage } = await appointmentCore.updateAppointment({
|
|
122
119
|
platform,
|
|
123
120
|
userId,
|
|
124
121
|
appointmentId,
|
|
125
122
|
patchBody
|
|
126
123
|
});
|
|
127
|
-
|
|
128
124
|
if (successful) {
|
|
129
125
|
return {
|
|
130
126
|
success: true,
|
|
@@ -149,6 +145,5 @@ async function execute(args) {
|
|
|
149
145
|
};
|
|
150
146
|
}
|
|
151
147
|
}
|
|
152
|
-
|
|
153
148
|
exports.definition = toolDefinition;
|
|
154
149
|
exports.execute = execute;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
// @ts-check
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
const jwt = /** @type {any} */ (require('../../lib/jwt'));
|
|
5
|
+
const connectorRegistry = /** @type {any} */ (require('../../connector/registry'));
|
|
6
|
+
const logCore = /** @type {any} */ (require('../../handlers/log'));
|
|
7
|
+
const util = /** @type {any} */ (require('../../lib/util'));
|
|
6
8
|
/**
|
|
7
9
|
* MCP Tool: Update Call Log
|
|
8
|
-
*
|
|
10
|
+
*
|
|
9
11
|
* This tool updates an existing call log in the CRM platform.
|
|
10
12
|
*/
|
|
11
|
-
|
|
12
13
|
const toolDefinition = {
|
|
13
14
|
name: 'updateCallLog',
|
|
14
15
|
description: '⚠️ REQUIRES AUTHENTICATION: User must first authenticate using the "auth" tool to obtain a JWT token before using this tool. | Update an existing call log in the CRM platform. Returns the updated log ID if successful.',
|
|
@@ -50,55 +51,46 @@ const toolDefinition = {
|
|
|
50
51
|
required: ['jwtToken', 'incomingData']
|
|
51
52
|
}
|
|
52
53
|
};
|
|
53
|
-
|
|
54
54
|
/**
|
|
55
55
|
* Execute the updateCallLog tool
|
|
56
56
|
* @param {Object} args - The tool arguments
|
|
57
57
|
* @param {string} args.jwtToken - JWT token with user and platform info
|
|
58
58
|
* @param {Object} args.incomingData - Call log update data
|
|
59
|
-
* @returns {
|
|
59
|
+
* @returns {Promise<any>} Result object with updated log ID
|
|
60
60
|
*/
|
|
61
61
|
async function execute(args) {
|
|
62
62
|
try {
|
|
63
63
|
const { jwtToken, incomingData } = args;
|
|
64
|
-
|
|
65
64
|
// Decode JWT to get userId and platform
|
|
66
65
|
const decodedToken = jwt.decodeJwt(jwtToken);
|
|
67
66
|
if (!decodedToken) {
|
|
68
67
|
throw new Error('Invalid JWT token');
|
|
69
68
|
}
|
|
70
69
|
const { id: userId, platform } = decodedToken;
|
|
71
|
-
|
|
72
70
|
if (!userId) {
|
|
73
71
|
throw new Error('Invalid JWT token: userId not found');
|
|
74
72
|
}
|
|
75
|
-
|
|
76
73
|
// Get the platform connector module
|
|
77
74
|
const platformModule = connectorRegistry.getConnector(platform);
|
|
78
|
-
|
|
79
75
|
if (!platformModule) {
|
|
80
76
|
throw new Error(`Platform connector not found for: ${platform}`);
|
|
81
77
|
}
|
|
82
|
-
|
|
83
78
|
// Check if updateCallLog is implemented
|
|
84
79
|
if (!platformModule.updateCallLog) {
|
|
85
80
|
throw new Error(`updateCallLog is not implemented for platform: ${platform}`);
|
|
86
81
|
}
|
|
87
|
-
|
|
88
82
|
// Calculate hashed account ID
|
|
89
|
-
const hashedAccountId = incomingData.accountId
|
|
90
|
-
? util.getHashValue(incomingData.accountId, process.env.HASH_KEY)
|
|
83
|
+
const hashedAccountId = incomingData.accountId
|
|
84
|
+
? util.getHashValue(incomingData.accountId, process.env.HASH_KEY)
|
|
91
85
|
: undefined;
|
|
92
|
-
|
|
93
86
|
// Call the updateCallLog method
|
|
94
|
-
const { successful, logId, updatedNote, returnMessage } = await logCore.updateCallLog({
|
|
95
|
-
platform,
|
|
96
|
-
userId,
|
|
97
|
-
incomingData,
|
|
87
|
+
const { successful, logId, updatedNote, returnMessage } = await logCore.updateCallLog({
|
|
88
|
+
platform,
|
|
89
|
+
userId,
|
|
90
|
+
incomingData,
|
|
98
91
|
hashedAccountId,
|
|
99
|
-
isFromSSCL: false
|
|
92
|
+
isFromSSCL: false
|
|
100
93
|
});
|
|
101
|
-
|
|
102
94
|
if (successful) {
|
|
103
95
|
return {
|
|
104
96
|
success: true,
|
|
@@ -124,7 +116,5 @@ async function execute(args) {
|
|
|
124
116
|
};
|
|
125
117
|
}
|
|
126
118
|
}
|
|
127
|
-
|
|
128
119
|
exports.definition = toolDefinition;
|
|
129
120
|
exports.execute = execute;
|
|
130
|
-
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AccountDataModel = void 0;
|
|
4
|
+
exports.getOrRefreshAccountData = getOrRefreshAccountData;
|
|
5
|
+
const Sequelize = require('sequelize');
|
|
6
|
+
const { sequelize: rawSequelize } = require('./sequelize');
|
|
7
|
+
const sequelize = rawSequelize;
|
|
8
|
+
// Model for account data with composite primary key
|
|
9
|
+
const AccountDataModel = sequelize.define('accountData', {
|
|
10
|
+
rcAccountId: {
|
|
11
|
+
type: Sequelize.STRING,
|
|
12
|
+
primaryKey: true,
|
|
13
|
+
},
|
|
14
|
+
platformName: {
|
|
15
|
+
type: Sequelize.STRING,
|
|
16
|
+
primaryKey: true,
|
|
17
|
+
},
|
|
18
|
+
dataKey: {
|
|
19
|
+
type: Sequelize.STRING,
|
|
20
|
+
primaryKey: true,
|
|
21
|
+
},
|
|
22
|
+
data: {
|
|
23
|
+
type: Sequelize.JSON,
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
exports.AccountDataModel = AccountDataModel;
|
|
27
|
+
async function getOrRefreshAccountData({ rcAccountId, platformName, dataKey, forceRefresh, fetchFn }) {
|
|
28
|
+
const existing = await AccountDataModel.findOne({ where: { rcAccountId, platformName, dataKey } });
|
|
29
|
+
if (existing && !forceRefresh)
|
|
30
|
+
return existing.data;
|
|
31
|
+
const fresh = await fetchFn();
|
|
32
|
+
if (existing) {
|
|
33
|
+
await existing.update({ data: fresh });
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
await AccountDataModel.create({ rcAccountId, platformName, dataKey, data: fresh });
|
|
37
|
+
}
|
|
38
|
+
return fresh;
|
|
39
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AdminConfigModel = void 0;
|
|
4
|
+
const Sequelize = require('sequelize');
|
|
5
|
+
const { sequelize: rawSequelize } = require('./sequelize');
|
|
6
|
+
const sequelize = rawSequelize;
|
|
7
|
+
// Model for Admin data
|
|
8
|
+
const AdminConfigModel = sequelize.define('adminConfigs', {
|
|
9
|
+
// hashed rc account ID
|
|
10
|
+
id: {
|
|
11
|
+
type: Sequelize.STRING,
|
|
12
|
+
primaryKey: true,
|
|
13
|
+
},
|
|
14
|
+
userSettings: {
|
|
15
|
+
type: Sequelize.JSON
|
|
16
|
+
},
|
|
17
|
+
// Obsolete
|
|
18
|
+
customAdapter: {
|
|
19
|
+
type: Sequelize.JSON
|
|
20
|
+
},
|
|
21
|
+
adminAccessToken: {
|
|
22
|
+
type: Sequelize.STRING(512),
|
|
23
|
+
},
|
|
24
|
+
adminRefreshToken: {
|
|
25
|
+
type: Sequelize.STRING(512),
|
|
26
|
+
},
|
|
27
|
+
adminTokenExpiry: {
|
|
28
|
+
type: Sequelize.DATE
|
|
29
|
+
},
|
|
30
|
+
// Array of:
|
|
31
|
+
// {
|
|
32
|
+
// crmUserId: string,
|
|
33
|
+
// rcExtensionId: array of strings
|
|
34
|
+
// }
|
|
35
|
+
userMappings: {
|
|
36
|
+
type: Sequelize.JSON
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
exports.AdminConfigModel = AdminConfigModel;
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CacheModel = void 0;
|
|
1
4
|
const Sequelize = require('sequelize');
|
|
2
|
-
const { sequelize } = require('./sequelize');
|
|
3
|
-
|
|
5
|
+
const { sequelize: rawSequelize } = require('./sequelize');
|
|
6
|
+
const sequelize = rawSequelize;
|
|
4
7
|
// Model for cache data
|
|
5
|
-
|
|
8
|
+
const CacheModel = sequelize.define('cache', {
|
|
6
9
|
// id = {userId}-{cacheKey}
|
|
7
10
|
id: {
|
|
8
11
|
type: Sequelize.STRING,
|
|
@@ -28,3 +31,4 @@ exports.CacheModel = sequelize.define('cache', {
|
|
|
28
31
|
{ fields: ['expiry'] }
|
|
29
32
|
]
|
|
30
33
|
});
|
|
34
|
+
exports.CacheModel = CacheModel;
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CallDownListModel = void 0;
|
|
1
4
|
const Sequelize = require('sequelize');
|
|
2
|
-
const { sequelize } = require('./sequelize');
|
|
3
|
-
|
|
4
|
-
|
|
5
|
+
const { sequelize: rawSequelize } = require('./sequelize');
|
|
6
|
+
const sequelize = rawSequelize;
|
|
7
|
+
const CallDownListModel = sequelize.define('callDownLists', {
|
|
5
8
|
id: {
|
|
6
9
|
type: Sequelize.STRING,
|
|
7
10
|
primaryKey: true,
|
|
@@ -32,4 +35,5 @@ exports.CallDownListModel = sequelize.define('callDownLists', {
|
|
|
32
35
|
{ fields: ['scheduledAt'] },
|
|
33
36
|
{ fields: ['userId', 'status'] }
|
|
34
37
|
]
|
|
35
|
-
});
|
|
38
|
+
});
|
|
39
|
+
exports.CallDownListModel = CallDownListModel;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CallLogModel = void 0;
|
|
4
|
+
const Sequelize = require('sequelize');
|
|
5
|
+
const { sequelize: rawSequelize } = require('./sequelize');
|
|
6
|
+
const sequelize = rawSequelize;
|
|
7
|
+
// Model for User data
|
|
8
|
+
const CallLogModel = sequelize.define('callLogs', {
|
|
9
|
+
// callId
|
|
10
|
+
id: {
|
|
11
|
+
type: Sequelize.STRING,
|
|
12
|
+
primaryKey: true,
|
|
13
|
+
},
|
|
14
|
+
sessionId: {
|
|
15
|
+
type: Sequelize.STRING,
|
|
16
|
+
primaryKey: true,
|
|
17
|
+
},
|
|
18
|
+
extensionNumber: {
|
|
19
|
+
type: Sequelize.STRING,
|
|
20
|
+
primaryKey: true,
|
|
21
|
+
allowNull: false,
|
|
22
|
+
defaultValue: '',
|
|
23
|
+
},
|
|
24
|
+
hashedExtensionId: {
|
|
25
|
+
type: Sequelize.STRING,
|
|
26
|
+
primaryKey: true,
|
|
27
|
+
allowNull: false,
|
|
28
|
+
defaultValue: '',
|
|
29
|
+
},
|
|
30
|
+
platform: {
|
|
31
|
+
type: Sequelize.STRING,
|
|
32
|
+
},
|
|
33
|
+
thirdPartyLogId: {
|
|
34
|
+
type: Sequelize.STRING,
|
|
35
|
+
},
|
|
36
|
+
userId: {
|
|
37
|
+
type: Sequelize.STRING,
|
|
38
|
+
},
|
|
39
|
+
contactId: {
|
|
40
|
+
type: Sequelize.STRING,
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
exports.CallLogModel = CallLogModel;
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Connector = void 0;
|
|
4
|
+
const dynamoose = require('dynamoose');
|
|
5
|
+
const crypto = require('crypto');
|
|
6
|
+
const CONNECTOR_STATUS = {
|
|
7
|
+
PRIVATE: 'private',
|
|
8
|
+
UNDER_REVIEW: 'under_review',
|
|
9
|
+
APPROVED: 'approved',
|
|
10
|
+
REJECTED: 'rejected',
|
|
11
|
+
};
|
|
12
|
+
const connectorSchema = new dynamoose.Schema({
|
|
13
|
+
accountId: {
|
|
14
|
+
type: String,
|
|
15
|
+
hashKey: true,
|
|
16
|
+
},
|
|
17
|
+
id: {
|
|
18
|
+
type: String,
|
|
19
|
+
rangeKey: true,
|
|
20
|
+
},
|
|
21
|
+
// Reference to original connector (for partition records)
|
|
22
|
+
originalAccountId: {
|
|
23
|
+
type: String,
|
|
24
|
+
required: false, // Only set for partition records (under_review, approved)
|
|
25
|
+
},
|
|
26
|
+
// Basic Information
|
|
27
|
+
name: {
|
|
28
|
+
type: String,
|
|
29
|
+
required: true,
|
|
30
|
+
},
|
|
31
|
+
displayName: String,
|
|
32
|
+
description: String,
|
|
33
|
+
iconUrl: String,
|
|
34
|
+
// Status and Workflow
|
|
35
|
+
status: {
|
|
36
|
+
type: String,
|
|
37
|
+
required: true,
|
|
38
|
+
enum: Object.values(CONNECTOR_STATUS),
|
|
39
|
+
default: CONNECTOR_STATUS.PRIVATE,
|
|
40
|
+
index: {
|
|
41
|
+
name: 'statusIdIndex',
|
|
42
|
+
global: true,
|
|
43
|
+
rangeKey: 'id',
|
|
44
|
+
project: ['accountId', 'name', 'displayName', 'developer', 'originalAccountId'],
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
creatorId: String,
|
|
48
|
+
// Developer Information
|
|
49
|
+
developer: {
|
|
50
|
+
type: Object,
|
|
51
|
+
schema: {
|
|
52
|
+
name: String,
|
|
53
|
+
websiteUrl: String,
|
|
54
|
+
supportUrl: String,
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
// Manifest Management
|
|
58
|
+
manifest: {
|
|
59
|
+
type: Object,
|
|
60
|
+
required: true,
|
|
61
|
+
},
|
|
62
|
+
proxyConfig: {
|
|
63
|
+
type: Object,
|
|
64
|
+
required: false,
|
|
65
|
+
},
|
|
66
|
+
proxyId: {
|
|
67
|
+
type: String,
|
|
68
|
+
index: {
|
|
69
|
+
name: 'proxyIdIndex',
|
|
70
|
+
global: true,
|
|
71
|
+
project: ['id', 'accountId', 'creatorId', 'name', 'displayName', 'status', 'developer', 'originalAccountId', 'proxyConfig'],
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
// Review and Approval
|
|
75
|
+
submittedAt: Number,
|
|
76
|
+
reviewedBy: String,
|
|
77
|
+
reviewedAt: Number,
|
|
78
|
+
reviewNotes: String,
|
|
79
|
+
rejectionReason: String,
|
|
80
|
+
demoAccounts: String,
|
|
81
|
+
// Usage and Analytics
|
|
82
|
+
usageCount: {
|
|
83
|
+
type: Number,
|
|
84
|
+
default: 0,
|
|
85
|
+
},
|
|
86
|
+
lastUsedAt: Number,
|
|
87
|
+
allowedAccounts: {
|
|
88
|
+
type: Array,
|
|
89
|
+
schema: [String],
|
|
90
|
+
},
|
|
91
|
+
encodedSecretKey: String,
|
|
92
|
+
}, {
|
|
93
|
+
saveUnknown: ['manifest.**', 'proxyConfig.**'],
|
|
94
|
+
timestamps: true,
|
|
95
|
+
});
|
|
96
|
+
const tableOptions = {
|
|
97
|
+
prefix: process.env.DEVELOPER_DYNAMODB_TABLE_PREFIX,
|
|
98
|
+
};
|
|
99
|
+
if (process.env.NODE_ENV === 'production') {
|
|
100
|
+
tableOptions.create = false;
|
|
101
|
+
tableOptions.waitForActive = false;
|
|
102
|
+
}
|
|
103
|
+
const Connector = dynamoose.model('connectors', connectorSchema, tableOptions);
|
|
104
|
+
exports.Connector = Connector;
|
|
105
|
+
function getDeveloperCipherKey() {
|
|
106
|
+
if (!process.env.DEVELOPER_APP_SERVER_SECRET_KEY) {
|
|
107
|
+
throw new Error('DEVELOPER_APP_SERVER_SECRET_KEY is not defined');
|
|
108
|
+
}
|
|
109
|
+
if (process.env.DEVELOPER_APP_SERVER_SECRET_KEY.length < 32) {
|
|
110
|
+
// pad secret key with spaces if it is less than 32 bytes
|
|
111
|
+
return process.env.DEVELOPER_APP_SERVER_SECRET_KEY.padEnd(32, ' ');
|
|
112
|
+
}
|
|
113
|
+
if (process.env.DEVELOPER_APP_SERVER_SECRET_KEY.length > 32) {
|
|
114
|
+
// truncate secret key if it is more than 32 bytes
|
|
115
|
+
return process.env.DEVELOPER_APP_SERVER_SECRET_KEY.slice(0, 32);
|
|
116
|
+
}
|
|
117
|
+
return process.env.DEVELOPER_APP_SERVER_SECRET_KEY;
|
|
118
|
+
}
|
|
119
|
+
function decode(encryptedData) {
|
|
120
|
+
const decipher = crypto.createDecipheriv('aes-256-cbc', getDeveloperCipherKey(), Buffer.alloc(16, 0));
|
|
121
|
+
return decipher.update(encryptedData, 'hex', 'utf8') + decipher.final('utf8');
|
|
122
|
+
}
|
|
123
|
+
// ADD static method to get connector by proxyId
|
|
124
|
+
const ConnectorWithProxyConfig = Connector;
|
|
125
|
+
ConnectorWithProxyConfig.getProxyConfig = async (proxyId) => {
|
|
126
|
+
const connectors = await Connector
|
|
127
|
+
.query('proxyId')
|
|
128
|
+
.eq(proxyId)
|
|
129
|
+
.using('proxyIdIndex')
|
|
130
|
+
.exec();
|
|
131
|
+
if (connectors.length > 0) {
|
|
132
|
+
const proxyConfig = connectors[0].proxyConfig;
|
|
133
|
+
const encodedSecretKey = connectors[0].encodedSecretKey;
|
|
134
|
+
const secretKey = encodedSecretKey ? decode(encodedSecretKey) : null;
|
|
135
|
+
if (secretKey) {
|
|
136
|
+
proxyConfig.secretKey = secretKey;
|
|
137
|
+
}
|
|
138
|
+
return proxyConfig;
|
|
139
|
+
}
|
|
140
|
+
return null;
|
|
141
|
+
};
|
|
@@ -1,25 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Lock = void 0;
|
|
1
4
|
const dynamoose = require('dynamoose');
|
|
2
|
-
|
|
3
5
|
const lockSchema = new dynamoose.Schema({
|
|
4
6
|
userId: {
|
|
5
7
|
type: String,
|
|
6
8
|
hashKey: true
|
|
7
9
|
},
|
|
8
10
|
ttl: {
|
|
9
|
-
|
|
11
|
+
type: Number
|
|
10
12
|
}
|
|
11
13
|
});
|
|
12
|
-
|
|
13
14
|
const tableOptions = {
|
|
14
15
|
prefix: process.env.DYNAMODB_TABLE_PREFIX,
|
|
15
16
|
expires: 60 // 60 seconds
|
|
16
17
|
};
|
|
17
|
-
|
|
18
18
|
if (process.env.NODE_ENV === 'production') {
|
|
19
19
|
tableOptions.create = false;
|
|
20
20
|
tableOptions.waitForActive = false;
|
|
21
21
|
}
|
|
22
|
-
|
|
23
22
|
const Lock = dynamoose.model('-token-refresh-lock', lockSchema, tableOptions);
|
|
24
|
-
|
|
25
|
-
exports.Lock = Lock;
|
|
23
|
+
exports.Lock = Lock;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NoteCache = void 0;
|
|
1
4
|
const dynamoose = require('dynamoose');
|
|
2
|
-
|
|
3
5
|
const noteCacheSchema = new dynamoose.Schema({
|
|
4
6
|
sessionId: {
|
|
5
7
|
type: String,
|
|
@@ -14,17 +16,13 @@ const noteCacheSchema = new dynamoose.Schema({
|
|
|
14
16
|
required: true,
|
|
15
17
|
},
|
|
16
18
|
});
|
|
17
|
-
|
|
18
19
|
const tableOptions = {
|
|
19
20
|
prefix: process.env.DYNAMODB_TABLE_PREFIX,
|
|
20
21
|
expires: 60 // 60 seconds
|
|
21
22
|
};
|
|
22
|
-
|
|
23
23
|
if (process.env.NODE_ENV === 'production') {
|
|
24
24
|
tableOptions.create = false;
|
|
25
25
|
tableOptions.waitForActive = false;
|
|
26
26
|
}
|
|
27
|
-
|
|
28
27
|
const NoteCache = dynamoose.model('-note-cache', noteCacheSchema, tableOptions);
|
|
29
|
-
|
|
30
|
-
exports.NoteCache = NoteCache;
|
|
28
|
+
exports.NoteCache = NoteCache;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LlmSessionModel = void 0;
|
|
4
|
+
const Sequelize = require('sequelize');
|
|
5
|
+
const { sequelize: rawSequelize } = require('./sequelize');
|
|
6
|
+
const sequelize = rawSequelize;
|
|
7
|
+
// Model for Admin data
|
|
8
|
+
const LlmSessionModel = sequelize.define('llmSessions', {
|
|
9
|
+
// LLM session ID
|
|
10
|
+
id: {
|
|
11
|
+
type: Sequelize.STRING,
|
|
12
|
+
primaryKey: true,
|
|
13
|
+
},
|
|
14
|
+
jwtToken: {
|
|
15
|
+
type: Sequelize.STRING,
|
|
16
|
+
},
|
|
17
|
+
expiry: {
|
|
18
|
+
type: Sequelize.DATE
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
exports.LlmSessionModel = LlmSessionModel;
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MessageLogModel = void 0;
|
|
1
4
|
const Sequelize = require('sequelize');
|
|
2
|
-
const { sequelize } = require('./sequelize');
|
|
3
|
-
|
|
5
|
+
const { sequelize: rawSequelize } = require('./sequelize');
|
|
6
|
+
const sequelize = rawSequelize;
|
|
4
7
|
// Model for User data
|
|
5
|
-
|
|
8
|
+
const MessageLogModel = sequelize.define('messageLogs', {
|
|
6
9
|
id: {
|
|
7
10
|
type: Sequelize.STRING,
|
|
8
11
|
primaryKey: true,
|
|
@@ -13,7 +16,7 @@ exports.MessageLogModel = sequelize.define('messageLogs', {
|
|
|
13
16
|
conversationId: {
|
|
14
17
|
type: Sequelize.STRING,
|
|
15
18
|
},
|
|
16
|
-
conversationLogId:{
|
|
19
|
+
conversationLogId: {
|
|
17
20
|
type: Sequelize.STRING,
|
|
18
21
|
},
|
|
19
22
|
thirdPartyLogId: {
|
|
@@ -23,3 +26,4 @@ exports.MessageLogModel = sequelize.define('messageLogs', {
|
|
|
23
26
|
type: Sequelize.STRING,
|
|
24
27
|
}
|
|
25
28
|
});
|
|
29
|
+
exports.MessageLogModel = MessageLogModel;
|