@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/registry.js
DELETED
|
@@ -1,252 +0,0 @@
|
|
|
1
|
-
// core/src/connector/registry.js
|
|
2
|
-
const logger = require('../lib/logger');
|
|
3
|
-
class ConnectorRegistry {
|
|
4
|
-
constructor() {
|
|
5
|
-
this.connectors = new Map();
|
|
6
|
-
this.manifests = new Map();
|
|
7
|
-
this.releaseNotes = {};
|
|
8
|
-
this.platformInterfaces = new Map(); // Store interface functions per platform
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
setDefaultManifest(manifest) {
|
|
12
|
-
this.manifests.set('default', manifest);
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Register an interface function for a specific platform
|
|
17
|
-
* @param {string} platformName - Platform identifier (e.g., 'pipedrive', 'salesforce')
|
|
18
|
-
* @param {string} interfaceName - Interface function name (e.g., 'createCallLog', 'findContact')
|
|
19
|
-
* @param {Function} interfaceFunction - The interface function to register
|
|
20
|
-
*/
|
|
21
|
-
registerConnectorInterface(platformName, interfaceName, interfaceFunction) {
|
|
22
|
-
if (typeof interfaceFunction !== 'function') {
|
|
23
|
-
throw new Error(`Interface function must be a function, got: ${typeof interfaceFunction}`);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
if (!this.platformInterfaces.has(platformName)) {
|
|
27
|
-
this.platformInterfaces.set(platformName, new Map());
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
const platformInterfaceMap = this.platformInterfaces.get(platformName);
|
|
31
|
-
platformInterfaceMap.set(interfaceName, interfaceFunction);
|
|
32
|
-
|
|
33
|
-
logger.info(`Registered interface function: ${platformName}.${interfaceName}`);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Get registered interface functions for a platform
|
|
38
|
-
* @param {string} platformName - Platform identifier
|
|
39
|
-
* @returns {Map} Map of interface functions
|
|
40
|
-
*/
|
|
41
|
-
getPlatformInterfaces(platformName) {
|
|
42
|
-
return this.platformInterfaces.get(platformName) || new Map();
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* Check if an interface function is registered for a platform
|
|
47
|
-
* @param {string} platformName - Platform identifier
|
|
48
|
-
* @param {string} interfaceName - Interface function name
|
|
49
|
-
* @returns {boolean} True if interface is registered
|
|
50
|
-
*/
|
|
51
|
-
hasPlatformInterface(platformName, interfaceName) {
|
|
52
|
-
const platformInterfaceMap = this.platformInterfaces.get(platformName);
|
|
53
|
-
return platformInterfaceMap ? platformInterfaceMap.has(interfaceName) : false;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* Unregister an interface function for a platform
|
|
58
|
-
* @param {string} platformName - Platform identifier
|
|
59
|
-
* @param {string} interfaceName - Interface function name
|
|
60
|
-
*/
|
|
61
|
-
unregisterConnectorInterface(platformName, interfaceName) {
|
|
62
|
-
const platformInterfaceMap = this.platformInterfaces.get(platformName);
|
|
63
|
-
if (platformInterfaceMap && platformInterfaceMap.has(interfaceName)) {
|
|
64
|
-
platformInterfaceMap.delete(interfaceName);
|
|
65
|
-
logger.info(`Unregistered interface function: ${platformName}.${interfaceName}`);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* Register an connector with the core system
|
|
71
|
-
* @param {string} platform - Platform identifier (e.g., 'pipedrive', 'salesforce')
|
|
72
|
-
* @param {Object} connector - Connector implementation
|
|
73
|
-
* @param {Object} manifest - Connector manifest configuration
|
|
74
|
-
*/
|
|
75
|
-
registerConnector(platform, connector, manifest = null) {
|
|
76
|
-
// Validate connector interface
|
|
77
|
-
this.validateConnectorInterface(platform, connector);
|
|
78
|
-
|
|
79
|
-
this.connectors.set(platform, connector);
|
|
80
|
-
if (manifest) {
|
|
81
|
-
this.manifests.set(platform, manifest);
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
logger.info(`Registered connector: ${platform}`);
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
* Get connector by platform name with composed interfaces
|
|
89
|
-
* @param {string} platform - Platform identifier
|
|
90
|
-
* @returns {Object} Composed connector with interface functions
|
|
91
|
-
*/
|
|
92
|
-
getConnector(platform) {
|
|
93
|
-
let connector = this.connectors.get(platform);
|
|
94
|
-
const platformInterfaceMap = this.platformInterfaces.get(platform);
|
|
95
|
-
|
|
96
|
-
if (!connector && (!platformInterfaceMap || platformInterfaceMap.size === 0)) {
|
|
97
|
-
connector = this.connectors.get('proxy');
|
|
98
|
-
if (connector) {
|
|
99
|
-
return connector;
|
|
100
|
-
}
|
|
101
|
-
throw new Error(`Connector not found for platform: ${platform}`);
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
// If no connector but interfaces exist, create a composed object with just interfaces
|
|
105
|
-
if (!connector && platformInterfaceMap && platformInterfaceMap.size > 0) {
|
|
106
|
-
const composedConnector = {};
|
|
107
|
-
|
|
108
|
-
// Add interface functions to the composed connector
|
|
109
|
-
for (const [interfaceName, interfaceFunction] of platformInterfaceMap) {
|
|
110
|
-
composedConnector[interfaceName] = interfaceFunction;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
logger.info(`Returning interface-only connector for platform: ${platform}`);
|
|
114
|
-
return composedConnector;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
// If connector exists but no interfaces, return original connector
|
|
118
|
-
if (connector && (!platformInterfaceMap || platformInterfaceMap.size === 0)) {
|
|
119
|
-
return connector;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
// If both connector and interfaces exist, create a composed object
|
|
123
|
-
const composedConnector = Object.create(connector);
|
|
124
|
-
|
|
125
|
-
// Add interface functions to the composed connector
|
|
126
|
-
for (const [interfaceName, interfaceFunction] of platformInterfaceMap) {
|
|
127
|
-
// Only add if the interface doesn't already exist in the connector
|
|
128
|
-
if (!Object.prototype.hasOwnProperty.call(connector, interfaceName)) {
|
|
129
|
-
composedConnector[interfaceName] = interfaceFunction;
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
return composedConnector;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
/**
|
|
137
|
-
* Get the original connector without composed interfaces
|
|
138
|
-
* @param {string} platform - Platform identifier
|
|
139
|
-
* @returns {Object} Original connector implementation
|
|
140
|
-
*/
|
|
141
|
-
getOriginalConnector(platform) {
|
|
142
|
-
const connector = this.connectors.get(platform);
|
|
143
|
-
if (!connector) {
|
|
144
|
-
throw new Error(`Connector not found for platform: ${platform}`);
|
|
145
|
-
}
|
|
146
|
-
return connector;
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
/**
|
|
150
|
-
* Get manifest for a platform
|
|
151
|
-
* @param {string} platform - Platform identifier
|
|
152
|
-
* @returns {Object} Manifest configuration
|
|
153
|
-
*/
|
|
154
|
-
getManifest(platform, fallbackToDefault = false) {
|
|
155
|
-
let manifest = this.manifests.get(platform);
|
|
156
|
-
if (!manifest && fallbackToDefault) {
|
|
157
|
-
manifest = this.manifests.get('default');
|
|
158
|
-
}
|
|
159
|
-
if (!manifest) {
|
|
160
|
-
throw new Error(`Manifest not found for platform: ${platform}`);
|
|
161
|
-
}
|
|
162
|
-
return manifest;
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
/**
|
|
166
|
-
* Get all registered platforms
|
|
167
|
-
* @returns {Array<string>} Array of platform names
|
|
168
|
-
*/
|
|
169
|
-
getRegisteredPlatforms() {
|
|
170
|
-
return Array.from(this.connectors.keys());
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
/**
|
|
174
|
-
* Check if platform is registered
|
|
175
|
-
* @param {string} platform - Platform identifier
|
|
176
|
-
* @returns {boolean} True if platform is registered
|
|
177
|
-
*/
|
|
178
|
-
isRegistered(platform) {
|
|
179
|
-
return this.connectors.has(platform);
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
/**
|
|
183
|
-
* Validate that connector implements required interface
|
|
184
|
-
* @param {Object} connector - Connector to validate
|
|
185
|
-
*/
|
|
186
|
-
validateConnectorInterface(platform, connector) {
|
|
187
|
-
const requiredMethods = [
|
|
188
|
-
'createCallLog',
|
|
189
|
-
'updateCallLog',
|
|
190
|
-
];
|
|
191
|
-
|
|
192
|
-
for (const method of requiredMethods) {
|
|
193
|
-
if (typeof connector[method] !== 'function') {
|
|
194
|
-
throw new Error(`Connector ${platform} missing required method: ${method}`);
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
/**
|
|
200
|
-
* Unregister an connector
|
|
201
|
-
* @param {string} platform - Platform identifier
|
|
202
|
-
*/
|
|
203
|
-
unregisterConnector(platform) {
|
|
204
|
-
this.connectors.delete(platform);
|
|
205
|
-
this.manifests.delete(platform);
|
|
206
|
-
this.platformInterfaces.delete(platform);
|
|
207
|
-
logger.info(`Unregistered connector: ${platform}`);
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
setReleaseNotes(releaseNotes) {
|
|
211
|
-
this.releaseNotes = releaseNotes;
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
getReleaseNotes() {
|
|
215
|
-
return this.releaseNotes;
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
/**
|
|
219
|
-
* Get connector capabilities summary including composed interfaces
|
|
220
|
-
* @param {string} platform - Platform identifier
|
|
221
|
-
* @returns {Object} Connector capabilities
|
|
222
|
-
*/
|
|
223
|
-
async getConnectorCapabilities(platform) {
|
|
224
|
-
const originalConnector = this.getOriginalConnector(platform);
|
|
225
|
-
const composedConnector = this.getConnector(platform);
|
|
226
|
-
const platformInterfaceMap = this.getPlatformInterfaces(platform);
|
|
227
|
-
|
|
228
|
-
const capabilities = {
|
|
229
|
-
platform,
|
|
230
|
-
originalMethods: Object.keys(originalConnector),
|
|
231
|
-
composedMethods: Object.keys(composedConnector),
|
|
232
|
-
registeredInterfaces: Array.from(platformInterfaceMap.keys()),
|
|
233
|
-
authType: null
|
|
234
|
-
};
|
|
235
|
-
|
|
236
|
-
// Get auth type if available
|
|
237
|
-
if (typeof originalConnector.getAuthType === 'function') {
|
|
238
|
-
try {
|
|
239
|
-
capabilities.authType = await originalConnector.getAuthType();
|
|
240
|
-
} catch (error) {
|
|
241
|
-
logger.error('Error getting auth type', { stack: error.stack });
|
|
242
|
-
capabilities.authType = 'unknown';
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
return capabilities;
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
// Export singleton instance
|
|
251
|
-
const connectorRegistry = new ConnectorRegistry();
|
|
252
|
-
module.exports = connectorRegistry;
|
package/docs/README.md
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
# App Connect Core Docs
|
|
2
|
-
|
|
3
|
-
This docs set explains the maintained code under `packages/core`, excluding the `mcp/` subsystem.
|
|
4
|
-
|
|
5
|
-
Use it when you need to change shared backend behavior, trace a request through the framework, or understand which module owns a feature.
|
|
6
|
-
|
|
7
|
-
## Scope
|
|
8
|
-
|
|
9
|
-
Included:
|
|
10
|
-
|
|
11
|
-
- root package entrypoints and route assembly
|
|
12
|
-
- connector infrastructure
|
|
13
|
-
- handlers
|
|
14
|
-
- models, including DynamoDB-backed schemas used outside MCP
|
|
15
|
-
- shared libraries
|
|
16
|
-
- tests that cover the non-MCP package surface
|
|
17
|
-
|
|
18
|
-
Excluded:
|
|
19
|
-
|
|
20
|
-
- `mcp/`
|
|
21
|
-
- generated output such as `coverage/`
|
|
22
|
-
- vendored dependencies such as `node_modules/`
|
|
23
|
-
|
|
24
|
-
## Reading Order
|
|
25
|
-
|
|
26
|
-
1. [Architecture](architecture.md) for the runtime shape and request flow
|
|
27
|
-
2. [Routes](routes.md) for the HTTP surface in `index.js`
|
|
28
|
-
3. [Handlers](handlers.md) for shared business logic
|
|
29
|
-
4. [Connectors](connectors.md) for registration, proxy behavior, and developer-portal helpers
|
|
30
|
-
5. [Models](models.md) for persistence
|
|
31
|
-
6. [Libraries](libraries.md) for shared helpers and infrastructure code
|
|
32
|
-
7. [Tests](tests.md) for current automated coverage
|
|
33
|
-
|
|
34
|
-
## File Map
|
|
35
|
-
|
|
36
|
-
| Area | Files |
|
|
37
|
-
| --- | --- |
|
|
38
|
-
| Package root | `index.js`, `package.json`, `README.md`, `releaseNotes.json`, `jest.config.js` |
|
|
39
|
-
| Connectors | `connector/registry.js`, `connector/developerPortal.js`, `connector/mock.js`, `connector/proxy/index.js`, `connector/proxy/engine.js` |
|
|
40
|
-
| Handlers | `handlers/admin.js`, `handlers/auth.js`, `handlers/calldown.js`, `handlers/contact.js`, `handlers/disposition.js`, `handlers/log.js`, `handlers/plugin.js`, `handlers/managedAuth.js`, `handlers/user.js` |
|
|
41
|
-
| Sequelize models | `models/accountDataModel.js`, `models/adminConfigModel.js`, `models/cacheModel.js`, `models/callDownListModel.js`, `models/callLogModel.js`, `models/llmSessionModel.js`, `models/messageLogModel.js`, `models/sequelize.js`, `models/userModel.js` |
|
|
42
|
-
| DynamoDB models | `models/dynamo/connectorSchema.js`, `models/dynamo/lockSchema.js`, `models/dynamo/noteCacheSchema.js` |
|
|
43
|
-
| Libraries | `lib/analytics.js`, `lib/authSession.js`, `lib/callLogComposer.js`, `lib/constants.js`, `lib/debugTracer.js`, `lib/encode.js`, `lib/errorHandler.js`, `lib/generalErrorMessage.js`, `lib/jwt.js`, `lib/logger.js`, `lib/oauth.js`, `lib/ringcentral.js`, `lib/s3ErrorLogReport.js`, `lib/sharedSMSComposer.js`, `lib/util.js` |
|
|
44
|
-
| Tests | `test/setup.js`, `test/connector/**`, `test/handlers/**`, `test/lib/**`, `test/models/**`, `test/routes/**` excluding `test/mcp/**` |
|
|
45
|
-
|
|
46
|
-
## Relationship To The Package README
|
|
47
|
-
|
|
48
|
-
The package [README.md](../README.md) is still the best public-facing quick start.
|
|
49
|
-
|
|
50
|
-
This docs set is the maintainer-oriented reference for the internals behind that API surface.
|
package/docs/architecture.md
DELETED
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
# Core Architecture
|
|
2
|
-
|
|
3
|
-
This package is the reusable backend framework behind App Connect server deployments.
|
|
4
|
-
|
|
5
|
-
Its job is to expose a stable HTTP surface, persist shared state, and delegate CRM-specific work to registered connectors.
|
|
6
|
-
|
|
7
|
-
## Main Entry Points
|
|
8
|
-
|
|
9
|
-
`index.js` exports the package assembly surface:
|
|
10
|
-
|
|
11
|
-
| Export | Purpose |
|
|
12
|
-
| --- | --- |
|
|
13
|
-
| `createCoreApp(options)` | Builds an Express app, installs middleware, and mounts the shared router |
|
|
14
|
-
| `createCoreMiddleware()` | Returns the common JSON, XML, and CORS middleware stack |
|
|
15
|
-
| `createCoreRouter()` | Creates the shared route layer without creating a full app |
|
|
16
|
-
| `initializeCore(options)` | Initializes analytics and database synchronization |
|
|
17
|
-
| `connectorRegistry` | Global registry for manifests, release notes, connectors, and interface composition |
|
|
18
|
-
| `proxyConnector` | Proxy-driven connector implementation used for config-based integrations |
|
|
19
|
-
| `DebugTracer` | Request-level debug tracing helper |
|
|
20
|
-
|
|
21
|
-
## Runtime Responsibilities
|
|
22
|
-
|
|
23
|
-
`index.js` owns the framework assembly:
|
|
24
|
-
|
|
25
|
-
- configures local DynamoDB support when `DYNAMODB_LOCALHOST` is set
|
|
26
|
-
- installs an axios interceptor in local-style environments
|
|
27
|
-
- syncs Sequelize models on startup unless `DISABLE_SYNC_DB_TABLE` or `skipDatabaseInit` disables it
|
|
28
|
-
- adds the `hashedRcExtensionId` column to `users` if an older schema is missing it
|
|
29
|
-
- migrates `callLogs` to include `hashedExtensionId` in the local call-log identity key when an older schema is missing it
|
|
30
|
-
- mounts all shared HTTP routes
|
|
31
|
-
- exposes dev-only mock routes when `IS_PROD === 'false'`
|
|
32
|
-
|
|
33
|
-
## Request Flow
|
|
34
|
-
|
|
35
|
-
The non-MCP request path is:
|
|
36
|
-
|
|
37
|
-
1. Express receives a request through `createCoreApp()` or `createCoreRouter()`.
|
|
38
|
-
2. Core middleware parses JSON or XML and applies CORS defaults.
|
|
39
|
-
3. Route handlers in `index.js` decode JWTs, gather analytics metadata, and call a shared handler.
|
|
40
|
-
4. Handlers load the current user and connector, refresh auth if needed, and call the connector operation.
|
|
41
|
-
5. Models persist linkage data such as user sessions, call log ids, cached account data, and plugin task state.
|
|
42
|
-
6. Libraries compose payloads, normalize errors, emit analytics, and handle logging.
|
|
43
|
-
|
|
44
|
-
## Connector-Centered Design
|
|
45
|
-
|
|
46
|
-
The package keeps route shapes and handler logic shared across platforms by pushing CRM-specific behavior behind the connector interface.
|
|
47
|
-
|
|
48
|
-
Important consequences:
|
|
49
|
-
|
|
50
|
-
- handlers decide when to load a connector and how to authenticate against it
|
|
51
|
-
- connectors decide how to talk to a CRM
|
|
52
|
-
- proxy connectors make many integrations data-driven instead of code-driven
|
|
53
|
-
- registry-level interface composition lets a platform add methods without mutating the original connector object
|
|
54
|
-
|
|
55
|
-
## Persistence Layers
|
|
56
|
-
|
|
57
|
-
There are two storage styles in this package:
|
|
58
|
-
|
|
59
|
-
- Sequelize models for relational/shared application state
|
|
60
|
-
- Dynamoose models for selected operational state such as proxy connector definitions, distributed locks, and note cache entries
|
|
61
|
-
|
|
62
|
-
`AccountDataModel` also stores encrypted shared API-key auth values. Shared auth intentionally stays separate from `AdminConfigModel.userMappings`:
|
|
63
|
-
|
|
64
|
-
- `managed-auth-org` stores account-scoped encrypted auth field values
|
|
65
|
-
- `managed-auth-user` stores per-extension encrypted auth field values
|
|
66
|
-
- server-side logging user mapping continues to live in admin config and is not reused for managed auth
|
|
67
|
-
|
|
68
|
-
## Cross-Cutting Concerns
|
|
69
|
-
|
|
70
|
-
Several concerns are applied in multiple modules:
|
|
71
|
-
|
|
72
|
-
- OAuth refresh via `lib/oauth.js`
|
|
73
|
-
- RingCentral admin and reporting helpers via `lib/ringcentral.js`
|
|
74
|
-
- response-safe error shaping via `lib/errorHandler.js`
|
|
75
|
-
- analytics events via `lib/analytics.js`
|
|
76
|
-
- opt-in debug traces via `lib/debugTracer.js`
|
|
77
|
-
- structured server logging via `lib/logger.js`
|
|
78
|
-
|
|
79
|
-
## Important Environment Variables
|
|
80
|
-
|
|
81
|
-
| Variable | Why it matters |
|
|
82
|
-
| --- | --- |
|
|
83
|
-
| `DATABASE_URL` | Sequelize connection string |
|
|
84
|
-
| `DISABLE_SYNC_DB_TABLE` | Skips model sync in `initDB()` |
|
|
85
|
-
| `MIXPANEL_TOKEN` | Enables analytics tracking |
|
|
86
|
-
| `APP_SERVER_SECRET_KEY` | Signs and verifies JWTs and encrypts stored managed auth values |
|
|
87
|
-
| `HASH_KEY` | Hashes RingCentral account and extension identifiers |
|
|
88
|
-
| `DYNAMODB_LOCALHOST` | Points Dynamoose to a local endpoint |
|
|
89
|
-
| `IS_PROD` | Enables local-only logging and mock routes when set to `'false'` |
|
|
90
|
-
| `OVERRIDE_APP_SERVER` | Overrides manifest server URL in `GET /crmManifest` |
|
|
91
|
-
| `OVERRIDE_SERVER_SIDE_LOGGING_SERVER` | Overrides manifest server-side logging URL in `GET /crmManifest` |
|
|
92
|
-
| `RINGCENTRAL_SERVER` | Used by RingCentral OAuth and reporting helpers |
|
|
93
|
-
| `RINGCENTRAL_CLIENT_ID` | Used by RingCentral OAuth and reporting helpers |
|
|
94
|
-
| `RINGCENTRAL_CLIENT_SECRET` | Used by RingCentral OAuth and reporting helpers |
|
package/docs/connectors.md
DELETED
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
# Connectors
|
|
2
|
-
|
|
3
|
-
Connectors are the extension seam that lets the shared framework support multiple CRMs.
|
|
4
|
-
|
|
5
|
-
## Registry
|
|
6
|
-
|
|
7
|
-
`connector/registry.js` exports a singleton `ConnectorRegistry`.
|
|
8
|
-
|
|
9
|
-
### Responsibilities
|
|
10
|
-
|
|
11
|
-
- register connector implementations by platform name
|
|
12
|
-
- store manifests by platform
|
|
13
|
-
- store release notes
|
|
14
|
-
- register extra interface methods per platform
|
|
15
|
-
- compose registered interfaces onto a connector at read time
|
|
16
|
-
- fall back to the `proxy` connector when a platform-specific connector is missing
|
|
17
|
-
|
|
18
|
-
### Important behavior
|
|
19
|
-
|
|
20
|
-
| Method | Notes |
|
|
21
|
-
| --- | --- |
|
|
22
|
-
| `registerConnector()` | Validates that the connector implements `createCallLog` and `updateCallLog` |
|
|
23
|
-
| `getConnector()` | Returns the original connector, an interface-only connector, a composed connector, or the proxy connector fallback |
|
|
24
|
-
| `registerConnectorInterface()` | Adds methods without mutating the original connector object |
|
|
25
|
-
| `getManifest(platform, fallbackToDefault)` | Throws if no manifest exists |
|
|
26
|
-
| `getConnectorCapabilities()` | Summarizes original methods, composed methods, registered interfaces, and auth type |
|
|
27
|
-
|
|
28
|
-
## Proxy Connector
|
|
29
|
-
|
|
30
|
-
The proxy connector makes integrations configurable through stored connector metadata instead of custom connector code.
|
|
31
|
-
|
|
32
|
-
### Files
|
|
33
|
-
|
|
34
|
-
| File | Role |
|
|
35
|
-
| --- | --- |
|
|
36
|
-
| `connector/proxy/index.js` | User-facing connector implementation for auth, contacts, call logs, message logs, dispositions, and logout |
|
|
37
|
-
| `connector/proxy/engine.js` | Low-level request templating, auth header creation, and response mapping |
|
|
38
|
-
|
|
39
|
-
### What `proxy/index.js` does
|
|
40
|
-
|
|
41
|
-
- loads proxy config from `models/dynamo/connectorSchema.js`
|
|
42
|
-
- resolves auth type from config, defaulting to `apiKey`
|
|
43
|
-
- builds `getOauthInfo()` for OAuth-style proxy integrations
|
|
44
|
-
- performs `getUserInfo()`, `findContact()`, `createContact()`, `findContactWithName()`, `createCallLog()`, `getCallLog()`, `updateCallLog()`, `createMessageLog()`, `updateMessageLog()`, `upsertCallDisposition()`, and `getUserList()`
|
|
45
|
-
- clears stored tokens in `unAuthorize()`
|
|
46
|
-
- exposes connector-specific log format through `meta.logFormat`
|
|
47
|
-
|
|
48
|
-
### What `proxy/engine.js` does
|
|
49
|
-
|
|
50
|
-
- resolves dot-path expressions with `getByPath()`
|
|
51
|
-
- renders template strings like `{{ user.accessToken }}`
|
|
52
|
-
- recursively renders query params, headers, and bodies
|
|
53
|
-
- composes auth headers from operation-specific or global auth config
|
|
54
|
-
- performs axios requests from the rendered config
|
|
55
|
-
- maps contact and call-log responses into App Connect's shared shape
|
|
56
|
-
|
|
57
|
-
## Developer Portal Helpers
|
|
58
|
-
|
|
59
|
-
`connector/developerPortal.js` wraps public API calls to the App Connect Developer Portal.
|
|
60
|
-
|
|
61
|
-
Exports:
|
|
62
|
-
|
|
63
|
-
- `getPublicConnectorList()`
|
|
64
|
-
- `getConnectorManifest()`
|
|
65
|
-
|
|
66
|
-
These functions are small fetch helpers and return `null` on failure after logging.
|
|
67
|
-
|
|
68
|
-
## Mock Connector Helpers
|
|
69
|
-
|
|
70
|
-
`connector/mock.js` is not a full connector implementation. It is a development helper used by the dev-only mock routes.
|
|
71
|
-
|
|
72
|
-
Exports:
|
|
73
|
-
|
|
74
|
-
- `createUser()`
|
|
75
|
-
- `deleteUser()`
|
|
76
|
-
- `getCallLog()`
|
|
77
|
-
- `createCallLog()`
|
|
78
|
-
- `cleanUpMockLogs()`
|
|
79
|
-
|
|
80
|
-
## Connector Contract In Practice
|
|
81
|
-
|
|
82
|
-
The shared framework expects these methods most often:
|
|
83
|
-
|
|
84
|
-
- `getAuthType()`
|
|
85
|
-
- `getOauthInfo()` or `getBasicAuth()`
|
|
86
|
-
- `getUserInfo()`
|
|
87
|
-
- `authValidation()`
|
|
88
|
-
- `createCallLog()`
|
|
89
|
-
- `updateCallLog()`
|
|
90
|
-
- `getCallLog()`
|
|
91
|
-
- `createMessageLog()`
|
|
92
|
-
- `updateMessageLog()`
|
|
93
|
-
- `findContact()`
|
|
94
|
-
- `createContact()`
|
|
95
|
-
- `findContactWithName()`
|
|
96
|
-
- `unAuthorize()`
|
|
97
|
-
- optional methods such as `refreshUserInfo()`, `getUserList()`, `getLicenseStatus()`, `upsertCallDisposition()`, `getServerLoggingSettings()`, `updateServerLoggingSettings()`, and `onUpdateUserSettings()`
|
|
98
|
-
|
|
99
|
-
## API-Key Managed Auth Fields
|
|
100
|
-
|
|
101
|
-
`apiKey` connector manifests can now annotate auth fields in `platform.auth.apiKey.page.content[]` with:
|
|
102
|
-
|
|
103
|
-
- `managed?: boolean`
|
|
104
|
-
- `managedScope?: 'account' | 'user'`
|
|
105
|
-
- `hidden?: boolean`
|
|
106
|
-
|
|
107
|
-
Behavior:
|
|
108
|
-
|
|
109
|
-
- `managed: true` marks a field as eligible for admin-managed storage and server-side auto-fill
|
|
110
|
-
- `managedScope: 'account'` stores one encrypted value per RingCentral account
|
|
111
|
-
- `managedScope: 'user'` stores encrypted values per RingCentral extension inside that account
|
|
112
|
-
- `hidden: true` hides input field from users
|
|
113
|
-
- stored managed auth values are encrypted at rest by default
|
|
114
|
-
|
|
115
|
-
This does not change the connector runtime contract. `handlers/auth.onApiKeyLogin()` still resolves the manifest-driven auth payload and passes the final field map through `additionalInfo` into connector `getUserInfo()`. Existing connectors like Redtail that already read extra API-key fields from `additionalInfo` remain compatible.
|
|
116
|
-
|
package/docs/handlers.md
DELETED
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
# Handlers
|
|
2
|
-
|
|
3
|
-
Handlers contain the shared business workflows behind the route layer.
|
|
4
|
-
|
|
5
|
-
## Handler Overview
|
|
6
|
-
|
|
7
|
-
| File | Responsibility | Main exports |
|
|
8
|
-
| --- | --- | --- |
|
|
9
|
-
| `handlers/auth.js` | Connector login, OAuth callback handling, user persistence, and auth validation | `onOAuthCallback`, `onApiKeyLogin`, `authValidation`, `getLicenseStatus`, `onRingcentralOAuthCallback` |
|
|
10
|
-
| `handlers/contact.js` | Contact search, creation, and account-data caching | `findContact`, `createContact`, `findContactWithName` |
|
|
11
|
-
| `handlers/log.js` | Call logging, message logging, plugin execution, async plugin callbacks, call-log lookup, and note cache writes | `createCallLog`, `updateCallLog`, `createMessageLog`, `getCallLog`, `saveNoteCache`, `handleAsyncPluginCallback` |
|
|
12
|
-
| `handlers/admin.js` | Admin settings, RingCentral reporting, server logging settings, and user mapping | `validateAdminRole`, `upsertAdminSettings`, `getAdminSettings`, `updateAdminRcTokens`, `getServerLoggingSettings`, `updateServerLoggingSettings`, `getAdminReport`, `getUserReport`, `getUserMapping`, `reinitializeUserMapping` |
|
|
13
|
-
| `handlers/user.js` | User info refresh, user setting reads, admin/user setting merge, and updates | `refreshUserInfo`, `getUserSettingsByAdmin`, `getUserSettings`, `updateUserSettings` |
|
|
14
|
-
| `handlers/disposition.js` | Call-disposition writes against an existing log | `upsertCallDisposition` |
|
|
15
|
-
| `handlers/calldown.js` | User-owned call-down scheduling | `schedule`, `list`, `remove`, `markCalled`, `update` |
|
|
16
|
-
| `handlers/managedAuth.js` | Shared API-key auth field discovery, secure storage, and login-time field resolution | `getManagedAuthAdminSettings`, `getManagedAuthState`, `resolveApiKeyLoginFields`, `upsertOrgManagedAuthValues`, `upsertUserManagedAuthValues` |
|
|
17
|
-
|
|
18
|
-
## Common Execution Pattern
|
|
19
|
-
|
|
20
|
-
Most connector-backed handlers follow the same sequence:
|
|
21
|
-
|
|
22
|
-
1. Load the current `UserModel` row.
|
|
23
|
-
2. Derive `proxyId` and optional proxy configuration from `platformAdditionalInfo`.
|
|
24
|
-
3. Resolve the connector from `connectorRegistry`.
|
|
25
|
-
4. Ask the connector for its auth type.
|
|
26
|
-
5. Refresh OAuth tokens through `lib/oauth.js` or build API-key auth.
|
|
27
|
-
6. Call the connector method with normalized inputs.
|
|
28
|
-
7. Return a shared `successful` plus `returnMessage` shape.
|
|
29
|
-
|
|
30
|
-
## `auth.js`
|
|
31
|
-
|
|
32
|
-
Key behavior:
|
|
33
|
-
|
|
34
|
-
- `onOAuthCallback()` completes the external OAuth code exchange, calls `getUserInfo()`, and persists the user through `saveUserInfo()`.
|
|
35
|
-
- `onApiKeyLogin()` uses connector-provided basic-auth construction and the same user persistence path.
|
|
36
|
-
- `onApiKeyLogin()` resolves shared API-key fields from `handlers/managedAuth.js`, ignores end-user overrides for shared fields, and returns `missingRequiredFieldConsts` when required fields are missing.
|
|
37
|
-
- `saveUserInfo()` updates or creates `UserModel`, preserving existing `platformAdditionalInfo` keys and adding `proxyId`.
|
|
38
|
-
- `authValidation()` refreshes OAuth tokens when needed, then delegates session validation to the connector.
|
|
39
|
-
- `getLicenseStatus()` is connector-defined and only wrapped here.
|
|
40
|
-
- `onRingcentralOAuthCallback()` stores admin RingCentral tokens in `AdminConfigModel`.
|
|
41
|
-
|
|
42
|
-
## `contact.js`
|
|
43
|
-
|
|
44
|
-
Key behavior:
|
|
45
|
-
|
|
46
|
-
- `findContact()` checks `AccountDataModel` cache first using `contact-${phoneNumber}` as the data key.
|
|
47
|
-
- Found contacts are cached per `rcAccountId` and `platformName`.
|
|
48
|
-
- Cache refresh can be forced with `isForceRefreshAccountData`.
|
|
49
|
-
- Missing or expired users return warning-style response objects rather than throwing.
|
|
50
|
-
- `findContactWithName()` mirrors the phone lookup path without the account-data cache.
|
|
51
|
-
|
|
52
|
-
Known caveat called out in code:
|
|
53
|
-
|
|
54
|
-
- account-data contact caching assumes one RingCentral account does not need separate caches for multiple CRM platforms at the same time
|
|
55
|
-
|
|
56
|
-
## `log.js`
|
|
57
|
-
|
|
58
|
-
This is the heaviest handler in the package.
|
|
59
|
-
|
|
60
|
-
Key responsibilities:
|
|
61
|
-
|
|
62
|
-
- prevents duplicate call-log creation by checking `CallLogModel` on `sessionId` plus extension identity (`hashedExtensionId` first, with legacy `extensionNumber` fallback)
|
|
63
|
-
- loads note cache from DynamoDB when `USE_CACHE` and server-side call logging are enabled
|
|
64
|
-
- runs configured synchronous plugins before creating or updating logs
|
|
65
|
-
- dispatches configured asynchronous call plugins after call-log create or update succeeds
|
|
66
|
-
- handles async plugin callbacks by appending Agent notes on success or marking task cache as failed on failure
|
|
67
|
-
- composes log body content with `composeCallLog()` or `composeSharedSMSLog()`
|
|
68
|
-
- stores local mappings between telephony ids and CRM log ids
|
|
69
|
-
- handles normal SMS, fax, group SMS, and shared SMS cases
|
|
70
|
-
- enriches tracking metadata for analytics callers
|
|
71
|
-
|
|
72
|
-
Important persistence behavior:
|
|
73
|
-
|
|
74
|
-
- `CallLogModel` stores the App Connect to CRM mapping for call logs
|
|
75
|
-
- `MessageLogModel` stores the App Connect to CRM mapping for message logs
|
|
76
|
-
- `CacheModel` stores async plugin callback tasks with a one-week expiry; successful callbacks delete the task and failed callbacks keep the task with status `failed`
|
|
77
|
-
- `NoteCache` stores temporary notes keyed by session id
|
|
78
|
-
|
|
79
|
-
## `admin.js`
|
|
80
|
-
|
|
81
|
-
Key responsibilities:
|
|
82
|
-
|
|
83
|
-
- validates RingCentral admin role from the current extension token
|
|
84
|
-
- validates arbitrary RingCentral user tokens with `validateRcUserToken()`
|
|
85
|
-
- stores and reads account-level admin configuration
|
|
86
|
-
- stores admin OAuth tokens used for RingCentral reporting
|
|
87
|
-
- fetches call aggregation and user activity metrics from RingCentral
|
|
88
|
-
- delegates server-side logging settings to connector-specific methods when available
|
|
89
|
-
- builds CRM user to RingCentral extension mappings through `getUserList()`
|
|
90
|
-
|
|
91
|
-
## `user.js`
|
|
92
|
-
|
|
93
|
-
This module handles user-owned workflows that do not belong to login, contact, or logging handlers.
|
|
94
|
-
|
|
95
|
-
Rules implemented here:
|
|
96
|
-
|
|
97
|
-
- `refreshUserInfo()` loads the current user, refreshes OAuth credentials when needed or builds API-key auth, then delegates to the connector's `refreshUserInfo({ user, authHeader, proxyConfig })`
|
|
98
|
-
- if no admin settings exist, return user settings directly
|
|
99
|
-
- admin settings can override or hide user settings
|
|
100
|
-
- plugin settings merge at both the plugin level and nested config-field level
|
|
101
|
-
- connectors can intercept setting updates with `onUpdateUserSettings()`
|
|
102
|
-
|
|
103
|
-
## Smaller Handler Modules
|
|
104
|
-
|
|
105
|
-
`disposition.js`:
|
|
106
|
-
|
|
107
|
-
- requires an existing local call-log mapping before writing disposition data
|
|
108
|
-
|
|
109
|
-
`calldown.js`:
|
|
110
|
-
|
|
111
|
-
- decodes the JWT directly
|
|
112
|
-
- keeps operations scoped to the authenticated user
|
|
113
|
-
- supports schedule, list, remove, mark-as-called, and partial update flows
|
|
114
|
-
|
|
115
|
-
`plugin.js`:
|
|
116
|
-
|
|
117
|
-
- registers and unregisters account-level plugins
|
|
118
|
-
- validates plugin registration against RingCentral account identity
|
|
119
|
-
- reads plugin license status through the installed plugin profile
|
|
120
|
-
|
|
121
|
-
`managedAuth.js`:
|
|
122
|
-
|
|
123
|
-
- reads API-key field definitions from either the developer portal manifest or the connector registry manifest
|
|
124
|
-
- isolates managed field definitions with `managed: true` and `managedScope` (`account` or `user`)
|
|
125
|
-
- encrypts managed auth values before writing to `AccountDataModel`
|
|
126
|
-
- provides admin views with stored values using `{ hasValue, value }` while keeping database values encrypted at rest
|
|
127
|
-
- resolves login fields by merging stored managed values and non-managed end-user inputs
|
|
128
|
-
|