@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/README.md
CHANGED
|
@@ -376,7 +376,8 @@ The core package provides the following API endpoints:
|
|
|
376
376
|
|
|
377
377
|
The core package uses the following environment variables:
|
|
378
378
|
|
|
379
|
-
- `DATABASE_URL` - Database connection string for Sequelize ORM
|
|
379
|
+
- `DATABASE_URL` - Database connection string for Sequelize ORM. SQLite and Postgres URLs are supported.
|
|
380
|
+
- `DATABASE_SSL` - Optional Postgres SSL override. When unset, localhost database hosts use SSL off and other Postgres hosts use SSL on.
|
|
380
381
|
- `DISABLE_SYNC_DB_TABLE` - Skip database table synchronization
|
|
381
382
|
- `OVERRIDE_APP_SERVER` - Override app server URL in manifests
|
|
382
383
|
- `HASH_KEY` - Key for hashing user information
|
|
@@ -415,24 +416,24 @@ The core package uses the following environment variables:
|
|
|
415
416
|
```
|
|
416
417
|
Core Package
|
|
417
418
|
├── Handlers (Business Logic)
|
|
418
|
-
│ ├── auth.
|
|
419
|
-
│ ├── contact.
|
|
420
|
-
│ ├── log.
|
|
421
|
-
│ ├── admin.
|
|
422
|
-
│ ├── user.
|
|
423
|
-
│ └── disposition.
|
|
419
|
+
│ ├── auth.ts - Authentication logic
|
|
420
|
+
│ ├── contact.ts - Contact management
|
|
421
|
+
│ ├── log.ts - Call/message logging
|
|
422
|
+
│ ├── admin.ts - Admin operations
|
|
423
|
+
│ ├── user.ts - User management
|
|
424
|
+
│ └── disposition.ts - Call disposition
|
|
424
425
|
├── Models (Data Layer)
|
|
425
|
-
│ ├── userModel.
|
|
426
|
-
│ ├── callLogModel.
|
|
427
|
-
│ ├── messageLogModel.
|
|
428
|
-
│ ├── adminConfigModel.
|
|
429
|
-
│ └── cacheModel.
|
|
426
|
+
│ ├── userModel.ts
|
|
427
|
+
│ ├── callLogModel.ts
|
|
428
|
+
│ ├── messageLogModel.ts
|
|
429
|
+
│ ├── adminConfigModel.ts
|
|
430
|
+
│ └── cacheModel.ts
|
|
430
431
|
├── Utils (Utilities)
|
|
431
|
-
│ ├── jwt.
|
|
432
|
-
│ ├── analytics.
|
|
433
|
-
│ └── util.
|
|
432
|
+
│ ├── jwt.ts - JWT operations
|
|
433
|
+
│ ├── analytics.ts - Analytics tracking
|
|
434
|
+
│ └── util.ts - General utilities
|
|
434
435
|
├── Connector Registry
|
|
435
|
-
│ └── registry.
|
|
436
|
+
│ └── registry.ts - CRM connector management
|
|
436
437
|
└── API Layer
|
|
437
438
|
├── createCoreApp() - Complete app setup
|
|
438
439
|
├── createCoreRouter() - Route management
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/** @typedef {import('../types').ConnectorManifest} ConnectorManifest */
|
|
2
|
+
/** @typedef {import('../types').DeveloperPortalConnectorList} DeveloperPortalConnectorList */
|
|
3
|
+
/** @typedef {import('../types').DeveloperPortalPrivateConnectorList} DeveloperPortalPrivateConnectorList */
|
|
4
|
+
/** @typedef {import('../types').GetConnectorManifestParams} GetConnectorManifestParams */
|
|
5
|
+
/** @typedef {import('../types').GetPrivateConnectorListParams} GetPrivateConnectorListParams */
|
|
6
|
+
export {};
|
|
@@ -1,32 +1,49 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
// @ts-check
|
|
3
|
+
/** @typedef {import('../types').ConnectorManifest} ConnectorManifest */
|
|
4
|
+
/** @typedef {import('../types').DeveloperPortalConnectorList} DeveloperPortalConnectorList */
|
|
5
|
+
/** @typedef {import('../types').DeveloperPortalPrivateConnectorList} DeveloperPortalPrivateConnectorList */
|
|
6
|
+
/** @typedef {import('../types').GetConnectorManifestParams} GetConnectorManifestParams */
|
|
7
|
+
/** @typedef {import('../types').GetPrivateConnectorListParams} GetPrivateConnectorListParams */
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
const axios = /** @type {any} */ (require('axios'));
|
|
10
|
+
const logger = require('../lib/logger');
|
|
11
|
+
/**
|
|
12
|
+
* @returns {Promise<DeveloperPortalConnectorList | null>}
|
|
13
|
+
*/
|
|
5
14
|
async function getPublicConnectorList() {
|
|
6
15
|
try {
|
|
7
16
|
const response = await axios.get('https://appconnect.labs.ringcentral.com/public-api/connectors');
|
|
8
17
|
return response.data;
|
|
9
|
-
}
|
|
18
|
+
}
|
|
19
|
+
catch (error) {
|
|
10
20
|
logger.error('Error getting public connector list:', error);
|
|
11
21
|
return null;
|
|
12
22
|
}
|
|
13
23
|
}
|
|
14
|
-
|
|
24
|
+
/**
|
|
25
|
+
* @param {GetPrivateConnectorListParams} params
|
|
26
|
+
* @returns {Promise<DeveloperPortalPrivateConnectorList | null>}
|
|
27
|
+
*/
|
|
15
28
|
async function getPrivateConnectorList({ rcAccountId }) {
|
|
16
29
|
try {
|
|
17
30
|
const response = await axios.get(`https://appconnect.labs.ringcentral.com/public-api/connectors/internal?accountId=${rcAccountId}`);
|
|
18
31
|
return response.data;
|
|
19
|
-
}
|
|
32
|
+
}
|
|
33
|
+
catch (error) {
|
|
20
34
|
logger.error('Error getting private connector list:', error);
|
|
21
35
|
return null;
|
|
22
36
|
}
|
|
23
37
|
}
|
|
24
|
-
|
|
38
|
+
/**
|
|
39
|
+
* @param {GetConnectorManifestParams} params
|
|
40
|
+
* @returns {Promise<ConnectorManifest | null>}
|
|
41
|
+
*/
|
|
25
42
|
async function getConnectorManifest({ rcAccountId, connectorId, isPrivate = false }) {
|
|
26
43
|
try {
|
|
27
44
|
let response = null;
|
|
28
45
|
if (isPrivate) {
|
|
29
|
-
const privateConnectorList = await getPrivateConnectorList({ rcAccountId });
|
|
46
|
+
const privateConnectorList = /** @type {DeveloperPortalPrivateConnectorList} */ (await getPrivateConnectorList({ rcAccountId }));
|
|
30
47
|
if (privateConnectorList.privateConnectors.some(connector => connector.id === connectorId)) {
|
|
31
48
|
response = await axios.get(`https://appconnect.labs.ringcentral.com/public-api/connectors/${connectorId}/manifest?access=internal&type=connector&accountId=${rcAccountId}`);
|
|
32
49
|
}
|
|
@@ -42,11 +59,11 @@ async function getConnectorManifest({ rcAccountId, connectorId, isPrivate = fals
|
|
|
42
59
|
response = await axios.get(`https://appconnect.labs.ringcentral.com/public-api/connectors/${connectorId}/manifest`);
|
|
43
60
|
}
|
|
44
61
|
return response.data;
|
|
45
|
-
}
|
|
62
|
+
}
|
|
63
|
+
catch (error) {
|
|
46
64
|
logger.error('Error getting connector manifest:', error);
|
|
47
65
|
return null;
|
|
48
66
|
}
|
|
49
67
|
}
|
|
50
|
-
|
|
51
68
|
exports.getPublicConnectorList = getPublicConnectorList;
|
|
52
|
-
exports.getConnectorManifest = getConnectorManifest;
|
|
69
|
+
exports.getConnectorManifest = getConnectorManifest;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,13 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
// This mock is to run high traffic tests on the server
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const {
|
|
5
|
-
const
|
|
6
|
-
const {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
// @ts-check
|
|
5
|
+
const { UserModel: UserModelImport } = require("../models/userModel");
|
|
6
|
+
const { CallLogModel: CallLogModelImport } = require("../models/callLogModel");
|
|
7
|
+
const shortid = /** @type {any} */ (require("shortid"));
|
|
8
|
+
const { buildCallLogSessionWhere, findMatchingCallLog, } = require('../lib/callLogLookup');
|
|
9
|
+
const UserModel = /** @type {any} */ (UserModelImport);
|
|
10
|
+
const CallLogModel = /** @type {any} */ (CallLogModelImport);
|
|
11
|
+
/** @typedef {import('../types').MockCallLogMatchResult} MockCallLogMatchResult */
|
|
12
|
+
/** @typedef {import('../types').MockCreateCallLogParams} MockCreateCallLogParams */
|
|
13
|
+
/** @typedef {import('../types').MockGetCallLogParams} MockGetCallLogParams */
|
|
14
|
+
/** @typedef {import('../types').PersistedCallLogIdentity} PersistedCallLogIdentity */
|
|
15
|
+
/**
|
|
16
|
+
* @returns {Promise<unknown>}
|
|
17
|
+
*/
|
|
11
18
|
async function createUser() {
|
|
12
19
|
let mockUser = await UserModel.findByPk('mockUser');
|
|
13
20
|
if (!mockUser) {
|
|
@@ -17,7 +24,9 @@ async function createUser() {
|
|
|
17
24
|
}
|
|
18
25
|
return mockUser;
|
|
19
26
|
}
|
|
20
|
-
|
|
27
|
+
/**
|
|
28
|
+
* @returns {Promise<boolean>}
|
|
29
|
+
*/
|
|
21
30
|
async function deleteUser() {
|
|
22
31
|
let mockUser = await UserModel.findByPk('mockUser');
|
|
23
32
|
if (mockUser) {
|
|
@@ -26,19 +35,23 @@ async function deleteUser() {
|
|
|
26
35
|
}
|
|
27
36
|
return false;
|
|
28
37
|
}
|
|
29
|
-
|
|
38
|
+
/**
|
|
39
|
+
* @param {MockGetCallLogParams} params
|
|
40
|
+
* @returns {Promise<MockCallLogMatchResult[]>}
|
|
41
|
+
*/
|
|
30
42
|
async function getCallLog({ sessionIds, extensionNumber, hashedExtensionId }) {
|
|
31
43
|
const sessionIdsArray = sessionIds.split(',');
|
|
32
44
|
const extensionNumberValue = extensionNumber?.toString() ?? '';
|
|
33
45
|
const hashedExtensionIdValue = hashedExtensionId?.toString() ?? '';
|
|
34
|
-
const callLogs = await CallLogModel.findAll({
|
|
46
|
+
const callLogs = /** @type {PersistedCallLogIdentity[]} */ (await CallLogModel.findAll({
|
|
35
47
|
where: buildCallLogSessionWhere({
|
|
36
48
|
sessionIds: sessionIdsArray,
|
|
37
49
|
extensionNumber: extensionNumberValue,
|
|
38
50
|
hashedExtensionId: hashedExtensionIdValue,
|
|
39
51
|
}),
|
|
40
52
|
order: [['hashedExtensionId', 'ASC'], ['extensionNumber', 'ASC']]
|
|
41
|
-
});
|
|
53
|
+
}));
|
|
54
|
+
/** @type {MockCallLogMatchResult[]} */
|
|
42
55
|
const logs = [];
|
|
43
56
|
for (const sId of sessionIdsArray) {
|
|
44
57
|
const callLog = findMatchingCallLog(callLogs, sId, extensionNumberValue, hashedExtensionIdValue);
|
|
@@ -49,10 +62,12 @@ async function getCallLog({ sessionIds, extensionNumber, hashedExtensionId }) {
|
|
|
49
62
|
logs.push({ sessionId: callLog.sessionId, matched: true, logId: 'mockThirdPartyLogId' });
|
|
50
63
|
}
|
|
51
64
|
}
|
|
52
|
-
|
|
53
65
|
return logs;
|
|
54
66
|
}
|
|
55
|
-
|
|
67
|
+
/**
|
|
68
|
+
* @param {MockCreateCallLogParams} params
|
|
69
|
+
* @returns {Promise<void>}
|
|
70
|
+
*/
|
|
56
71
|
async function createCallLog({ sessionId, extensionNumber, hashedExtensionId }) {
|
|
57
72
|
const extensionNumberValue = extensionNumber?.toString() ?? '';
|
|
58
73
|
const hashedExtensionIdValue = hashedExtensionId?.toString() ?? '';
|
|
@@ -73,7 +88,9 @@ async function createCallLog({ sessionId, extensionNumber, hashedExtensionId })
|
|
|
73
88
|
});
|
|
74
89
|
}
|
|
75
90
|
}
|
|
76
|
-
|
|
91
|
+
/**
|
|
92
|
+
* @returns {Promise<void>}
|
|
93
|
+
*/
|
|
77
94
|
async function cleanUpMockLogs() {
|
|
78
95
|
await CallLogModel.destroy({
|
|
79
96
|
where: {
|
|
@@ -81,7 +98,6 @@ async function cleanUpMockLogs() {
|
|
|
81
98
|
}
|
|
82
99
|
});
|
|
83
100
|
}
|
|
84
|
-
|
|
85
101
|
exports.createUser = createUser;
|
|
86
102
|
exports.deleteUser = deleteUser;
|
|
87
103
|
exports.getCallLog = getCallLog;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** @typedef {import('../../types').MapFindContactResponseParams} MapFindContactResponseParams */
|
|
2
|
+
/** @typedef {import('../../types').MapProxyResponseParams} MapProxyResponseParams */
|
|
3
|
+
/** @typedef {import('../../types').PerformProxyRequestParams} PerformProxyRequestParams */
|
|
4
|
+
/** @typedef {import('../../types').ProxyAuthConfig} ProxyAuthConfig */
|
|
5
|
+
/** @typedef {import('../../types').ProxyConfig} ProxyConfig */
|
|
6
|
+
/** @typedef {import('../../types').ProxyContactInfo} ProxyContactInfo */
|
|
7
|
+
/** @typedef {import('../../types').ProxyOperationConfig} ProxyOperationConfig */
|
|
8
|
+
/** @typedef {import('../../types').ProxyResponse} ProxyResponse */
|
|
9
|
+
/** @typedef {Record<string, any>} TemplateContext */
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// @ts-check
|
|
3
|
+
/** @typedef {import('../../types').MapFindContactResponseParams} MapFindContactResponseParams */
|
|
4
|
+
/** @typedef {import('../../types').MapProxyResponseParams} MapProxyResponseParams */
|
|
5
|
+
/** @typedef {import('../../types').PerformProxyRequestParams} PerformProxyRequestParams */
|
|
6
|
+
/** @typedef {import('../../types').ProxyAuthConfig} ProxyAuthConfig */
|
|
7
|
+
/** @typedef {import('../../types').ProxyConfig} ProxyConfig */
|
|
8
|
+
/** @typedef {import('../../types').ProxyContactInfo} ProxyContactInfo */
|
|
9
|
+
/** @typedef {import('../../types').ProxyOperationConfig} ProxyOperationConfig */
|
|
10
|
+
/** @typedef {import('../../types').ProxyResponse} ProxyResponse */
|
|
11
|
+
/** @typedef {Record<string, any>} TemplateContext */
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
const axios = /** @type {any} */ (require('axios'));
|
|
14
|
+
/**
|
|
15
|
+
* @param {any} obj
|
|
16
|
+
* @param {string | undefined} path
|
|
17
|
+
* @returns {any}
|
|
18
|
+
*/
|
|
19
|
+
function getByPath(obj, path) {
|
|
20
|
+
if (!path || path === '$')
|
|
21
|
+
return obj;
|
|
22
|
+
const parts = path.split('.');
|
|
23
|
+
let cur = obj;
|
|
24
|
+
for (const p of parts) {
|
|
25
|
+
if (cur == null)
|
|
26
|
+
return undefined;
|
|
27
|
+
cur = cur[p];
|
|
28
|
+
}
|
|
29
|
+
return cur;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* @param {any} template
|
|
33
|
+
* @param {TemplateContext} context
|
|
34
|
+
* @returns {any}
|
|
35
|
+
*/
|
|
36
|
+
function renderTemplateString(template, context) {
|
|
37
|
+
if (typeof template !== 'string')
|
|
38
|
+
return template;
|
|
39
|
+
// if only template value, return value with stringify
|
|
40
|
+
const onlyVarName = template.match(/^\{\{\s*([^}]+?)\s*\}\}$/);
|
|
41
|
+
if (onlyVarName) {
|
|
42
|
+
return getByPath(context, onlyVarName[1]);
|
|
43
|
+
}
|
|
44
|
+
return template.replace(/\{\{\s*([^}]+?)\s*\}\}/g, (_, expr) => {
|
|
45
|
+
const value = getByPath(context, expr.trim());
|
|
46
|
+
return value == null ? '' : String(value);
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* @param {any} input
|
|
51
|
+
* @param {TemplateContext} context
|
|
52
|
+
* @returns {any}
|
|
53
|
+
*/
|
|
54
|
+
function renderDeep(input, context) {
|
|
55
|
+
if (input == null)
|
|
56
|
+
return input;
|
|
57
|
+
if (typeof input === 'string')
|
|
58
|
+
return renderTemplateString(input, context);
|
|
59
|
+
if (Array.isArray(input))
|
|
60
|
+
return input.map(v => renderDeep(v, context));
|
|
61
|
+
if (typeof input === 'object') {
|
|
62
|
+
const out = {};
|
|
63
|
+
for (const [k, v] of Object.entries(input)) {
|
|
64
|
+
out[k] = renderDeep(v, context);
|
|
65
|
+
}
|
|
66
|
+
return out;
|
|
67
|
+
}
|
|
68
|
+
return input;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* @param {string | undefined} baseUrl
|
|
72
|
+
* @param {string | undefined} path
|
|
73
|
+
* @returns {string | undefined}
|
|
74
|
+
*/
|
|
75
|
+
function joinUrl(baseUrl, path) {
|
|
76
|
+
if (!baseUrl)
|
|
77
|
+
return path;
|
|
78
|
+
if (!path)
|
|
79
|
+
return baseUrl;
|
|
80
|
+
if (path.startsWith('http://') || path.startsWith('https://'))
|
|
81
|
+
return path;
|
|
82
|
+
return `${baseUrl.replace(/\/$/, '')}/${path.replace(/^\//, '')}`;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* @param {{ auth?: ProxyAuthConfig, context: TemplateContext, authHeader?: string }} params
|
|
86
|
+
* @returns {Record<string, any>}
|
|
87
|
+
*/
|
|
88
|
+
function getAuthHeaderFromAuthConfig({ auth, context, authHeader }) {
|
|
89
|
+
const authHeaders = {};
|
|
90
|
+
const headerName = auth?.headerName || 'Authorization';
|
|
91
|
+
if (auth && auth.credentialTemplate) {
|
|
92
|
+
const credentials = renderTemplateString(auth.credentialTemplate, context);
|
|
93
|
+
const encode = auth.encode === 'none' ? false : true;
|
|
94
|
+
const token = encode ? Buffer.from(credentials).toString('base64') : credentials;
|
|
95
|
+
authHeaders[headerName] = auth.scheme ? `${auth.scheme} ${token}` : token;
|
|
96
|
+
}
|
|
97
|
+
else if (authHeader) {
|
|
98
|
+
authHeaders[headerName] = authHeader;
|
|
99
|
+
}
|
|
100
|
+
else if (auth && auth.type === 'oauth' && context.user) {
|
|
101
|
+
authHeaders[headerName] = `${auth.scheme || 'Bearer'} ${context.user.accessToken}`;
|
|
102
|
+
}
|
|
103
|
+
return authHeaders;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* @param {{ config: ProxyConfig, operation?: ProxyOperationConfig, authHeader?: string, context: TemplateContext }} params
|
|
107
|
+
* @returns {Record<string, any>}
|
|
108
|
+
*/
|
|
109
|
+
function buildHeaders({ config, operation, authHeader, context }) {
|
|
110
|
+
const headers = renderDeep(Object.assign({}, config.requestDefaults?.defaultHeaders || {}), context);
|
|
111
|
+
const renderedOpHeaders = renderDeep(operation?.headers || {}, context);
|
|
112
|
+
for (const [k, v] of Object.entries(renderedOpHeaders))
|
|
113
|
+
headers[k] = v;
|
|
114
|
+
// Per-operation auth override
|
|
115
|
+
const authHeaders = getAuthHeaderFromAuthConfig({
|
|
116
|
+
auth: operation?.auth || config.auth,
|
|
117
|
+
context,
|
|
118
|
+
authHeader
|
|
119
|
+
});
|
|
120
|
+
for (const [k, v] of Object.entries(authHeaders))
|
|
121
|
+
headers[k] = v;
|
|
122
|
+
return headers;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* @param {PerformProxyRequestParams} params
|
|
126
|
+
* @returns {Promise<ProxyResponse | null>}
|
|
127
|
+
*/
|
|
128
|
+
async function performRequest({ config, opName, inputs, user, authHeader }) {
|
|
129
|
+
const op = config.operations?.[opName];
|
|
130
|
+
if (!op)
|
|
131
|
+
return null;
|
|
132
|
+
const accessToken = user?.accessToken ?? inputs?.apiKey ?? '';
|
|
133
|
+
const context = Object.assign({}, inputs, {
|
|
134
|
+
user: user ? {
|
|
135
|
+
accessToken,
|
|
136
|
+
id: user.id?.split('-')[0],
|
|
137
|
+
hostname: user.hostname,
|
|
138
|
+
timezoneName: user.timezoneName,
|
|
139
|
+
timezoneOffset: user.timezoneOffset,
|
|
140
|
+
platform: user.platform,
|
|
141
|
+
platformAdditionalInfo: user.platformAdditionalInfo,
|
|
142
|
+
refreshToken: user.refreshToken,
|
|
143
|
+
tokenExpiry: user.tokenExpiry,
|
|
144
|
+
} : {
|
|
145
|
+
accessToken,
|
|
146
|
+
},
|
|
147
|
+
authHeader,
|
|
148
|
+
apiKey: accessToken,
|
|
149
|
+
secretKey: config.secretKey,
|
|
150
|
+
});
|
|
151
|
+
const url = joinUrl(config.requestDefaults?.baseUrl, renderTemplateString(op.url, context));
|
|
152
|
+
const method = (op.method || 'GET').toUpperCase();
|
|
153
|
+
const headers = buildHeaders({ config, operation: op, authHeader, context });
|
|
154
|
+
const params = renderDeep(op.query || {}, context);
|
|
155
|
+
const data = renderDeep(op.body || {}, context);
|
|
156
|
+
const timeout = (config.requestDefaults?.timeoutSeconds || 30) * 1000;
|
|
157
|
+
const axiosParams = { url, method, headers, params, data, timeout };
|
|
158
|
+
const response = await axios(axiosParams);
|
|
159
|
+
return response;
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* @param {MapFindContactResponseParams} params
|
|
163
|
+
* @returns {ProxyContactInfo[]}
|
|
164
|
+
*/
|
|
165
|
+
function mapFindContactResponse({ config, response, opName = 'findContact' }) {
|
|
166
|
+
const map = config.operations?.[opName]?.responseMapping;
|
|
167
|
+
if (!map)
|
|
168
|
+
return [];
|
|
169
|
+
const __ctx = { body: response.data };
|
|
170
|
+
const list = /** @type {any[]} */ (getByPath(__ctx, map.listPath || 'body') || []);
|
|
171
|
+
const itemMap = map.item || {};
|
|
172
|
+
return list.map(it => {
|
|
173
|
+
return {
|
|
174
|
+
id: getByPath(it, itemMap.idPath || 'id'),
|
|
175
|
+
name: getByPath(it, itemMap.namePath || 'name') || '',
|
|
176
|
+
phone: getByPath(it, itemMap.phonePath || 'phone') || undefined,
|
|
177
|
+
type: getByPath(it, itemMap.typePath || 'type') || 'Contact',
|
|
178
|
+
title: getByPath(it, itemMap.titlePath || 'title') || "",
|
|
179
|
+
company: getByPath(it, itemMap.companyPath || 'company') || "",
|
|
180
|
+
createdDate: getByPath(it, itemMap.createdDatePath || 'createdDate') || undefined,
|
|
181
|
+
mostRecentActivityDate: getByPath(it, itemMap.mostRecentActivityDatePath || 'mostRecentActivityDate') || undefined,
|
|
182
|
+
additionalInfo: getByPath(it, itemMap.additionalInfoPath || 'additionalInfo') || null
|
|
183
|
+
};
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* @param {MapProxyResponseParams} params
|
|
188
|
+
* @returns {{ logId?: string }}
|
|
189
|
+
*/
|
|
190
|
+
function mapCreateCallLogResponse({ config, response }) {
|
|
191
|
+
const map = config.operations?.createCallLog?.responseMapping;
|
|
192
|
+
if (!map)
|
|
193
|
+
return { logId: undefined };
|
|
194
|
+
const __ctx = { body: response.data };
|
|
195
|
+
const logId = getByPath(__ctx, map.idPath || 'body.id');
|
|
196
|
+
return { logId: logId ? String(logId) : undefined };
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* @param {MapProxyResponseParams} params
|
|
200
|
+
* @returns {{ callLogInfo: { subject: any, note: any, fullBody: any, fullLogResponse: unknown } }}
|
|
201
|
+
*/
|
|
202
|
+
function mapGetCallLogResponse({ config, response }) {
|
|
203
|
+
const map = config.operations?.getCallLog?.responseMapping || {};
|
|
204
|
+
const __ctx = { body: response.data };
|
|
205
|
+
const subject = getByPath(__ctx, map.subjectPath || 'body.subject');
|
|
206
|
+
const note = getByPath(__ctx, map.notePath || 'body.note');
|
|
207
|
+
const fullBody = getByPath(__ctx, map.fullBodyPath || 'body.note');
|
|
208
|
+
const fullLogResponse = response.data;
|
|
209
|
+
return {
|
|
210
|
+
callLogInfo: { subject, note, fullBody, fullLogResponse }
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
module.exports = {
|
|
214
|
+
getByPath,
|
|
215
|
+
renderTemplateString,
|
|
216
|
+
renderDeep,
|
|
217
|
+
joinUrl,
|
|
218
|
+
performRequest,
|
|
219
|
+
mapFindContactResponse,
|
|
220
|
+
mapCreateCallLogResponse,
|
|
221
|
+
mapGetCallLogResponse
|
|
222
|
+
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/** @typedef {import('../../types').OperationFailureResult} OperationFailureResult */
|
|
2
|
+
/** @typedef {import('../../types').ProxyConfig} ProxyConfig */
|
|
3
|
+
/** @typedef {import('../../types').ProxyResponse} ProxyResponse */
|
|
4
|
+
/** @typedef {import('../../types').ReturnMessage} ReturnMessage */
|
|
5
|
+
export {};
|