@app-connect/core 1.7.25 → 1.7.27

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.
Files changed (138) hide show
  1. package/.env.test +5 -5
  2. package/README.md +441 -441
  3. package/connector/developerPortal.js +31 -31
  4. package/connector/mock.js +84 -77
  5. package/connector/proxy/engine.js +164 -164
  6. package/connector/proxy/index.js +500 -500
  7. package/connector/registry.js +252 -252
  8. package/docs/README.md +50 -50
  9. package/docs/architecture.md +93 -93
  10. package/docs/connectors.md +116 -116
  11. package/docs/handlers.md +125 -125
  12. package/docs/libraries.md +101 -101
  13. package/docs/models.md +144 -144
  14. package/docs/routes.md +115 -115
  15. package/docs/tests.md +73 -73
  16. package/handlers/admin.js +523 -523
  17. package/handlers/appointment.js +193 -0
  18. package/handlers/auth.js +320 -296
  19. package/handlers/calldown.js +99 -99
  20. package/handlers/contact.js +280 -280
  21. package/handlers/disposition.js +82 -80
  22. package/handlers/log.js +990 -973
  23. package/handlers/managedAuth.js +446 -446
  24. package/handlers/managedOAuth.js +247 -0
  25. package/handlers/plugin.js +208 -208
  26. package/handlers/user.js +142 -142
  27. package/index.js +3162 -2652
  28. package/jest.config.js +56 -56
  29. package/lib/analytics.js +54 -54
  30. package/lib/authSession.js +109 -109
  31. package/lib/cacheCleanup.js +21 -0
  32. package/lib/callLogComposer.js +898 -898
  33. package/lib/callLogLookup.js +34 -0
  34. package/lib/constants.js +8 -8
  35. package/lib/debugTracer.js +177 -177
  36. package/lib/encode.js +30 -30
  37. package/lib/errorHandler.js +218 -206
  38. package/lib/generalErrorMessage.js +41 -41
  39. package/lib/jwt.js +18 -18
  40. package/lib/logger.js +190 -190
  41. package/lib/migrateCallLogsSchema.js +116 -0
  42. package/lib/ringcentral.js +266 -266
  43. package/lib/s3ErrorLogReport.js +65 -65
  44. package/lib/sharedSMSComposer.js +471 -471
  45. package/lib/util.js +67 -67
  46. package/mcp/README.md +412 -395
  47. package/mcp/lib/validator.js +91 -91
  48. package/mcp/mcpHandler.js +425 -425
  49. package/mcp/tools/cancelAppointment.js +101 -0
  50. package/mcp/tools/checkAuthStatus.js +105 -105
  51. package/mcp/tools/confirmAppointment.js +101 -0
  52. package/mcp/tools/createAppointment.js +157 -0
  53. package/mcp/tools/createCallLog.js +327 -316
  54. package/mcp/tools/createContact.js +117 -117
  55. package/mcp/tools/createMessageLog.js +287 -287
  56. package/mcp/tools/doAuth.js +60 -60
  57. package/mcp/tools/findContactByName.js +93 -93
  58. package/mcp/tools/findContactByPhone.js +101 -101
  59. package/mcp/tools/getCallLog.js +111 -102
  60. package/mcp/tools/getGoogleFilePicker.js +99 -99
  61. package/mcp/tools/getHelp.js +43 -43
  62. package/mcp/tools/getPublicConnectors.js +94 -94
  63. package/mcp/tools/getSessionInfo.js +90 -90
  64. package/mcp/tools/index.js +51 -41
  65. package/mcp/tools/listAppointments.js +163 -0
  66. package/mcp/tools/logout.js +99 -96
  67. package/mcp/tools/rcGetCallLogs.js +65 -65
  68. package/mcp/tools/updateAppointment.js +154 -0
  69. package/mcp/tools/updateCallLog.js +130 -126
  70. package/mcp/ui/App/App.tsx +358 -358
  71. package/mcp/ui/App/components/AuthInfoForm.tsx +113 -113
  72. package/mcp/ui/App/components/AuthSuccess.tsx +22 -22
  73. package/mcp/ui/App/components/ConnectorList.tsx +82 -82
  74. package/mcp/ui/App/components/DebugPanel.tsx +43 -43
  75. package/mcp/ui/App/components/OAuthConnect.tsx +270 -270
  76. package/mcp/ui/App/lib/callTool.ts +130 -130
  77. package/mcp/ui/App/lib/debugLog.ts +41 -41
  78. package/mcp/ui/App/lib/developerPortal.ts +111 -111
  79. package/mcp/ui/App/main.css +5 -5
  80. package/mcp/ui/App/root.tsx +13 -13
  81. package/mcp/ui/index.html +13 -13
  82. package/mcp/ui/package-lock.json +6356 -6356
  83. package/mcp/ui/package.json +25 -25
  84. package/mcp/ui/tsconfig.json +26 -26
  85. package/mcp/ui/vite.config.ts +16 -16
  86. package/models/accountDataModel.js +33 -33
  87. package/models/adminConfigModel.js +35 -35
  88. package/models/cacheModel.js +30 -26
  89. package/models/callDownListModel.js +34 -34
  90. package/models/callLogModel.js +33 -27
  91. package/models/dynamo/connectorSchema.js +146 -146
  92. package/models/dynamo/lockSchema.js +24 -24
  93. package/models/dynamo/noteCacheSchema.js +29 -29
  94. package/models/llmSessionModel.js +17 -17
  95. package/models/messageLogModel.js +25 -25
  96. package/models/sequelize.js +16 -16
  97. package/models/userModel.js +45 -45
  98. package/package.json +1 -1
  99. package/releaseNotes.json +1101 -1081
  100. package/test/connector/proxy/engine.test.js +126 -126
  101. package/test/connector/proxy/index.test.js +279 -279
  102. package/test/connector/proxy/sample.json +161 -161
  103. package/test/connector/registry.test.js +415 -415
  104. package/test/handlers/admin.test.js +616 -616
  105. package/test/handlers/auth.test.js +1092 -1018
  106. package/test/handlers/contact.test.js +1014 -1014
  107. package/test/handlers/log.test.js +1298 -1160
  108. package/test/handlers/managedAuth.test.js +457 -457
  109. package/test/handlers/plugin.test.js +380 -380
  110. package/test/index.test.js +105 -105
  111. package/test/lib/cacheCleanup.test.js +42 -0
  112. package/test/lib/callLogComposer.test.js +1231 -1231
  113. package/test/lib/debugTracer.test.js +328 -328
  114. package/test/lib/jwt.test.js +176 -176
  115. package/test/lib/logger.test.js +206 -206
  116. package/test/lib/oauth.test.js +359 -359
  117. package/test/lib/ringcentral.test.js +467 -467
  118. package/test/lib/sharedSMSComposer.test.js +1084 -1084
  119. package/test/lib/util.test.js +329 -329
  120. package/test/mcp/tools/checkAuthStatus.test.js +83 -83
  121. package/test/mcp/tools/createCallLog.test.js +436 -436
  122. package/test/mcp/tools/createContact.test.js +58 -58
  123. package/test/mcp/tools/createMessageLog.test.js +595 -595
  124. package/test/mcp/tools/doAuth.test.js +113 -113
  125. package/test/mcp/tools/findContactByName.test.js +275 -275
  126. package/test/mcp/tools/findContactByPhone.test.js +296 -296
  127. package/test/mcp/tools/getCallLog.test.js +298 -298
  128. package/test/mcp/tools/getGoogleFilePicker.test.js +281 -281
  129. package/test/mcp/tools/getPublicConnectors.test.js +107 -107
  130. package/test/mcp/tools/getSessionInfo.test.js +127 -127
  131. package/test/mcp/tools/logout.test.js +233 -233
  132. package/test/mcp/tools/rcGetCallLogs.test.js +56 -56
  133. package/test/mcp/tools/updateCallLog.test.js +360 -360
  134. package/test/models/accountDataModel.test.js +98 -98
  135. package/test/models/dynamo/connectorSchema.test.js +189 -189
  136. package/test/models/models.test.js +568 -539
  137. package/test/routes/managedAuthRoutes.test.js +235 -104
  138. package/test/setup.js +178 -178
package/docs/models.md CHANGED
@@ -1,144 +1,144 @@
1
- # Models
2
-
3
- The package uses Sequelize for durable application data and Dynamoose for selected config and cache workflows.
4
-
5
- ## Sequelize Models
6
-
7
- ### `models/sequelize.js`
8
-
9
- Creates the shared Sequelize instance from `DATABASE_URL`.
10
-
11
- ### `models/userModel.js`
12
-
13
- Stores CRM-authenticated users.
14
-
15
- | Field | Notes |
16
- | --- | --- |
17
- | `id` | Primary key; effectively `{crmUserId}-{platform}` |
18
- | `rcAccountId` | RingCentral account id |
19
- | `hostname` | CRM hostname or tenant host |
20
- | `timezoneName` | User timezone name when available |
21
- | `timezoneOffset` | Offset stored as a string |
22
- | `platform` | Connector platform name |
23
- | `accessToken` | OAuth access token or API key |
24
- | `refreshToken` | OAuth refresh token |
25
- | `tokenExpiry` | Access token expiry |
26
- | `platformAdditionalInfo` | Connector-specific metadata such as `proxyId` or token URL |
27
- | `hashedRcExtensionId` | Hashed RingCentral extension id |
28
- | `userSettings` | Per-user settings JSON |
29
-
30
- ### `models/callLogModel.js`
31
-
32
- Stores the mapping between telephony sessions and CRM call logs.
33
-
34
- | Field | Notes |
35
- | --- | --- |
36
- | `id` | Telephony call id |
37
- | `sessionId` | Session id; also part of the composite primary key |
38
- | `platform` | Connector platform |
39
- | `thirdPartyLogId` | CRM log id |
40
- | `userId` | App Connect user id |
41
- | `contactId` | CRM contact id used for the log |
42
-
43
- ### `models/messageLogModel.js`
44
-
45
- Stores message-log linkage records.
46
-
47
- | Field | Notes |
48
- | --- | --- |
49
- | `id` | Message id or conversation log id |
50
- | `platform` | Connector platform |
51
- | `conversationId` | Conversation identifier |
52
- | `conversationLogId` | Shared key used to group related message logs |
53
- | `thirdPartyLogId` | CRM log id |
54
- | `userId` | App Connect user id |
55
-
56
- ### `models/adminConfigModel.js`
57
-
58
- Stores account-level admin configuration.
59
-
60
- | Field | Notes |
61
- | --- | --- |
62
- | `id` | Hashed RingCentral account id |
63
- | `userSettings` | Account-level settings policy |
64
- | `customAdapter` | Obsolete field kept for compatibility |
65
- | `adminAccessToken` | RingCentral admin access token |
66
- | `adminRefreshToken` | RingCentral admin refresh token |
67
- | `adminTokenExpiry` | Admin token expiry |
68
- | `userMappings` | JSON mapping between CRM users and RingCentral extensions |
69
-
70
- ### `models/cacheModel.js`
71
-
72
- Stores temporary task state, mainly for async plugin work.
73
-
74
- | Field | Notes |
75
- | --- | --- |
76
- | `id` | Task id, commonly `{userId}-{uuid}` |
77
- | `status` | Task status such as `initialized`, `completed`, or `failed` |
78
- | `userId` | Owning user |
79
- | `cacheKey` | Logical task family |
80
- | `data` | Optional task payload |
81
- | `expiry` | Cleanup cutoff |
82
-
83
- ### `models/accountDataModel.js`
84
-
85
- Stores account-scoped cached data.
86
-
87
- Composite primary key:
88
-
89
- - `rcAccountId`
90
- - `platformName`
91
- - `dataKey`
92
-
93
- Main usage in current code:
94
-
95
- - cached contact lookups keyed as `contact-${phoneNumber}`
96
-
97
- Helper export:
98
-
99
- - `getOrRefreshAccountData()` which returns cached data unless `forceRefresh` is set
100
-
101
- ### `models/callDownListModel.js`
102
-
103
- Stores user-owned call-down queue items.
104
-
105
- | Field | Notes |
106
- | --- | --- |
107
- | `id` | Primary key |
108
- | `userId` | Owning user |
109
- | `contactId` | CRM contact id |
110
- | `contactType` | Contact entity type |
111
- | `status` | Queue state such as `scheduled` or `called` |
112
- | `scheduledAt` | Requested follow-up time |
113
- | `lastCallAt` | Last call timestamp |
114
-
115
- This model enables timestamps and indexes on `userId`, `status`, `scheduledAt`, and `userId + status`.
116
-
117
- ### `models/llmSessionModel.js`
118
-
119
- Stores a lightweight mapping from an LLM session id to a JWT token.
120
-
121
- ## Dynamoose Models
122
-
123
- ### `models/dynamo/connectorSchema.js`
124
-
125
- Stores connector metadata used by proxy integrations.
126
-
127
- Important role:
128
-
129
- - source of truth for `Connector.getProxyConfig(proxyId)`
130
-
131
- This schema is a dependency of auth, contact, log, admin, and proxy connector flows.
132
-
133
- ### `models/dynamo/lockSchema.js`
134
-
135
- Stores distributed lock state used by token refresh and similar coordination logic.
136
-
137
- ### `models/dynamo/noteCacheSchema.js`
138
-
139
- Stores note cache entries keyed by `sessionId`.
140
-
141
- Main usage:
142
-
143
- - `handlers/log.js` can read cached notes during server-side call logging
144
- - `saveNoteCache()` writes entries with a TTL
1
+ # Models
2
+
3
+ The package uses Sequelize for durable application data and Dynamoose for selected config and cache workflows.
4
+
5
+ ## Sequelize Models
6
+
7
+ ### `models/sequelize.js`
8
+
9
+ Creates the shared Sequelize instance from `DATABASE_URL`.
10
+
11
+ ### `models/userModel.js`
12
+
13
+ Stores CRM-authenticated users.
14
+
15
+ | Field | Notes |
16
+ | --- | --- |
17
+ | `id` | Primary key; effectively `{crmUserId}-{platform}` |
18
+ | `rcAccountId` | RingCentral account id |
19
+ | `hostname` | CRM hostname or tenant host |
20
+ | `timezoneName` | User timezone name when available |
21
+ | `timezoneOffset` | Offset stored as a string |
22
+ | `platform` | Connector platform name |
23
+ | `accessToken` | OAuth access token or API key |
24
+ | `refreshToken` | OAuth refresh token |
25
+ | `tokenExpiry` | Access token expiry |
26
+ | `platformAdditionalInfo` | Connector-specific metadata such as `proxyId` or token URL |
27
+ | `hashedRcExtensionId` | Hashed RingCentral extension id |
28
+ | `userSettings` | Per-user settings JSON |
29
+
30
+ ### `models/callLogModel.js`
31
+
32
+ Stores the mapping between telephony sessions and CRM call logs.
33
+
34
+ | Field | Notes |
35
+ | --- | --- |
36
+ | `id` | Telephony call id |
37
+ | `sessionId` | Session id; also part of the composite primary key |
38
+ | `platform` | Connector platform |
39
+ | `thirdPartyLogId` | CRM log id |
40
+ | `userId` | App Connect user id |
41
+ | `contactId` | CRM contact id used for the log |
42
+
43
+ ### `models/messageLogModel.js`
44
+
45
+ Stores message-log linkage records.
46
+
47
+ | Field | Notes |
48
+ | --- | --- |
49
+ | `id` | Message id or conversation log id |
50
+ | `platform` | Connector platform |
51
+ | `conversationId` | Conversation identifier |
52
+ | `conversationLogId` | Shared key used to group related message logs |
53
+ | `thirdPartyLogId` | CRM log id |
54
+ | `userId` | App Connect user id |
55
+
56
+ ### `models/adminConfigModel.js`
57
+
58
+ Stores account-level admin configuration.
59
+
60
+ | Field | Notes |
61
+ | --- | --- |
62
+ | `id` | Hashed RingCentral account id |
63
+ | `userSettings` | Account-level settings policy |
64
+ | `customAdapter` | Obsolete field kept for compatibility |
65
+ | `adminAccessToken` | RingCentral admin access token |
66
+ | `adminRefreshToken` | RingCentral admin refresh token |
67
+ | `adminTokenExpiry` | Admin token expiry |
68
+ | `userMappings` | JSON mapping between CRM users and RingCentral extensions |
69
+
70
+ ### `models/cacheModel.js`
71
+
72
+ Stores temporary task state, mainly for async plugin work.
73
+
74
+ | Field | Notes |
75
+ | --- | --- |
76
+ | `id` | Task id, commonly `{userId}-{uuid}` |
77
+ | `status` | Task status such as `initialized`, `completed`, or `failed` |
78
+ | `userId` | Owning user |
79
+ | `cacheKey` | Logical task family |
80
+ | `data` | Optional task payload |
81
+ | `expiry` | Cleanup cutoff |
82
+
83
+ ### `models/accountDataModel.js`
84
+
85
+ Stores account-scoped cached data.
86
+
87
+ Composite primary key:
88
+
89
+ - `rcAccountId`
90
+ - `platformName`
91
+ - `dataKey`
92
+
93
+ Main usage in current code:
94
+
95
+ - cached contact lookups keyed as `contact-${phoneNumber}`
96
+
97
+ Helper export:
98
+
99
+ - `getOrRefreshAccountData()` which returns cached data unless `forceRefresh` is set
100
+
101
+ ### `models/callDownListModel.js`
102
+
103
+ Stores user-owned call-down queue items.
104
+
105
+ | Field | Notes |
106
+ | --- | --- |
107
+ | `id` | Primary key |
108
+ | `userId` | Owning user |
109
+ | `contactId` | CRM contact id |
110
+ | `contactType` | Contact entity type |
111
+ | `status` | Queue state such as `scheduled` or `called` |
112
+ | `scheduledAt` | Requested follow-up time |
113
+ | `lastCallAt` | Last call timestamp |
114
+
115
+ This model enables timestamps and indexes on `userId`, `status`, `scheduledAt`, and `userId + status`.
116
+
117
+ ### `models/llmSessionModel.js`
118
+
119
+ Stores a lightweight mapping from an LLM session id to a JWT token.
120
+
121
+ ## Dynamoose Models
122
+
123
+ ### `models/dynamo/connectorSchema.js`
124
+
125
+ Stores connector metadata used by proxy integrations.
126
+
127
+ Important role:
128
+
129
+ - source of truth for `Connector.getProxyConfig(proxyId)`
130
+
131
+ This schema is a dependency of auth, contact, log, admin, and proxy connector flows.
132
+
133
+ ### `models/dynamo/lockSchema.js`
134
+
135
+ Stores distributed lock state used by token refresh and similar coordination logic.
136
+
137
+ ### `models/dynamo/noteCacheSchema.js`
138
+
139
+ Stores note cache entries keyed by `sessionId`.
140
+
141
+ Main usage:
142
+
143
+ - `handlers/log.js` can read cached notes during server-side call logging
144
+ - `saveNoteCache()` writes entries with a TTL
package/docs/routes.md CHANGED
@@ -1,115 +1,115 @@
1
- # Core Routes
2
-
3
- This page documents the non-MCP HTTP routes defined in `index.js`.
4
-
5
- ## Route Design Notes
6
-
7
- - Most routes accept a `jwtToken` query parameter and resolve the current user from it.
8
- - Many routes emit analytics using request headers such as `rc-extension-id`, `rc-account-id`, `user-agent`, `developer-author-name`, and `eventAddedVia`.
9
- - When the request header `is-debug` is set to `'true'`, route handlers can return `DebugTracer` output wrappers.
10
- - Several routes are marked obsolete in code but still present for compatibility.
11
-
12
- ## System And Metadata Routes
13
-
14
- | Method | Path | Purpose |
15
- | --- | --- | --- |
16
- | `GET` | `/releaseNotes` | Merges package release notes with connector release notes |
17
- | `GET` | `/crmManifest` | Returns a platform manifest, with optional server URL overrides |
18
- | `GET` | `/isAlive` | Simple health check returning `OK` |
19
- | `GET` | `/implementedInterfaces` | Reports which connector methods exist for a platform |
20
- | `GET` | `/serverVersionInfo` | Returns manifest version data; marked obsolete in code |
21
- | `GET` | `/.well-known/openai-apps-challenge` | Returns the ChatGPT verification code |
22
- | `GET` | `/.well-known/oauth-protected-resource` | OAuth protected-resource metadata |
23
- | `GET` | `/.well-known/oauth-authorization-server` | OAuth authorization-server metadata |
24
- | `GET` | `/oauth/authorize_shim` | Rebuilds OAuth params and redirects to RingCentral |
25
- | `POST` | `/oauth/register` | Returns RingCentral client credentials for the shim flow |
26
-
27
- ## Authentication Routes
28
-
29
- | Method | Path | Purpose |
30
- | --- | --- | --- |
31
- | `GET` | `/licenseStatus` | Checks connector-specific license status for the current user |
32
- | `GET` | `/authValidation` | Verifies the current CRM auth session |
33
- | `GET` | `/hostname` | Returns host-related info used during auth flows |
34
- | `GET` | `/oauth-callback` | Completes connector OAuth and persists the user |
35
- | `POST` | `/apiKeyLogin` | Handles API-key based login flows |
36
- | `GET` | `/apiKeyManagedAuthState` | Returns required-field readiness for shared API-key auth |
37
- | `POST` | `/unAuthorize` | Logs the user out of the CRM |
38
- | `GET` | `/userInfoHash` | Returns a hash derived from user information |
39
- | `GET` | `/ringcentral/oauth/callback` | Completes the admin RingCentral OAuth callback |
40
-
41
- ## Admin Routes
42
-
43
- | Method | Path | Purpose |
44
- | --- | --- | --- |
45
- | `POST` | `/admin/settings` | Validates RingCentral admin role and saves admin settings |
46
- | `GET` | `/admin/settings` | Returns admin settings for the current account |
47
- | `POST` | `/admin/userMapping` | Builds a mapping between CRM users and RingCentral extensions |
48
- | `POST` | `/admin/reinitializeUserMapping` | Rebuilds user mappings from scratch |
49
- | `GET` | `/admin/serverLoggingSettings` | Loads connector-specific server logging settings |
50
- | `POST` | `/admin/serverLoggingSettings` | Updates connector-specific server logging settings |
51
- | `GET` | `/admin/managedAuth` | Returns admin-facing managed-auth field definitions and masked stored values |
52
- | `POST` | `/admin/managedAuth` | Upserts org-level or extension-level managed auth values |
53
- | `GET` | `/ringcentral/admin/report` | Returns aggregated RingCentral call activity metrics |
54
- | `GET` | `/ringcentral/admin/userReport` | Returns per-extension call and SMS metrics |
55
-
56
- ## User Settings Routes
57
-
58
- | Method | Path | Purpose |
59
- | --- | --- | --- |
60
- | `GET` | `/user/preloadSettings` | Loads settings used to bootstrap client-side configuration |
61
- | `GET` | `/user/settings` | Returns merged user and admin settings |
62
- | `POST` | `/user/settings` | Updates per-user settings, with connector hooks when present |
63
-
64
- ## Contact Routes
65
-
66
- | Method | Path | Purpose |
67
- | --- | --- | --- |
68
- | `GET` | `/contact` | Finds contacts by phone number |
69
- | `POST` | `/contact` | Creates a new contact |
70
- | `GET` | `/custom/contact/search` | Finds contacts by name |
71
-
72
- ## Logging And Disposition Routes
73
-
74
- | Method | Path | Purpose |
75
- | --- | --- | --- |
76
- | `POST` | `/callLog/cacheNote` | Stores a temporary note for server-side call logging |
77
- | `GET` | `/callLog` | Looks up existing call logs by session id |
78
- | `POST` | `/callLog` | Creates a CRM call log and stores the local linkage record |
79
- | `PATCH` | `/callLog` | Updates an existing CRM call log |
80
- | `PUT` | `/callDisposition` | Upserts call disposition data through the connector |
81
- | `POST` | `/messageLog` | Creates or updates CRM logs for SMS, fax, and shared SMS |
82
-
83
- ## Call-Down Routes
84
-
85
- | Method | Path | Purpose |
86
- | --- | --- | --- |
87
- | `POST` | `/calldown` | Schedules a call-down item |
88
- | `GET` | `/calldown` | Lists the current user's call-down items |
89
- | `DELETE` | `/calldown/:id` | Removes a call-down item |
90
- | `PATCH` | `/calldown/:id` | Updates or marks a call-down item |
91
-
92
- ## Plugin And Debug Routes
93
-
94
- | Method | Path | Purpose |
95
- | --- | --- | --- |
96
- | `GET` | `/debug/report/url` | Returns a presigned URL for error log upload |
97
- | `POST` | `/pluginAsyncTask` | Returns async plugin task status and cleans up finished task cache entries |
98
-
99
- ## Development-Only Mock Routes
100
-
101
- These routes are only mounted when `IS_PROD === 'false'`.
102
-
103
- | Method | Path | Purpose |
104
- | --- | --- | --- |
105
- | `POST` | `/registerMockUser` | Creates a mock user |
106
- | `DELETE` | `/deleteMockUser` | Removes a mock user |
107
- | `GET` | `/mockCallLog` | Reads mock call logs |
108
- | `POST` | `/mockCallLog` | Creates a mock call log |
109
- | `DELETE` | `/mockCallLog` | Clears mock call logs |
110
-
111
- ## Operational Notes
112
-
113
- - `createCoreRouter()` currently contains a large amount of orchestration logic in addition to route registration.
114
- - Most route handlers duplicate a common pattern: decode JWT, load user, resolve connector, refresh auth, call handler, then track analytics.
115
- - If route count continues growing, this file is a strong candidate for modular route extraction by feature area.
1
+ # Core Routes
2
+
3
+ This page documents the non-MCP HTTP routes defined in `index.js`.
4
+
5
+ ## Route Design Notes
6
+
7
+ - Most routes accept a `jwtToken` query parameter and resolve the current user from it.
8
+ - Many routes emit analytics using request headers such as `rc-extension-id`, `rc-account-id`, `user-agent`, `developer-author-name`, and `eventAddedVia`.
9
+ - When the request header `is-debug` is set to `'true'`, route handlers can return `DebugTracer` output wrappers.
10
+ - Several routes are marked obsolete in code but still present for compatibility.
11
+
12
+ ## System And Metadata Routes
13
+
14
+ | Method | Path | Purpose |
15
+ | --- | --- | --- |
16
+ | `GET` | `/releaseNotes` | Merges package release notes with connector release notes |
17
+ | `GET` | `/crmManifest` | Returns a platform manifest, with optional server URL overrides |
18
+ | `GET` | `/isAlive` | Simple health check returning `OK` |
19
+ | `GET` | `/implementedInterfaces` | Reports which connector methods exist for a platform |
20
+ | `GET` | `/serverVersionInfo` | Returns manifest version data; marked obsolete in code |
21
+ | `GET` | `/.well-known/openai-apps-challenge` | Returns the ChatGPT verification code |
22
+ | `GET` | `/.well-known/oauth-protected-resource` | OAuth protected-resource metadata |
23
+ | `GET` | `/.well-known/oauth-authorization-server` | OAuth authorization-server metadata |
24
+ | `GET` | `/oauth/authorize_shim` | Rebuilds OAuth params and redirects to RingCentral |
25
+ | `POST` | `/oauth/register` | Returns RingCentral client credentials for the shim flow |
26
+
27
+ ## Authentication Routes
28
+
29
+ | Method | Path | Purpose |
30
+ | --- | --- | --- |
31
+ | `GET` | `/licenseStatus` | Checks connector-specific license status for the current user |
32
+ | `GET` | `/authValidation` | Verifies the current CRM auth session |
33
+ | `GET` | `/hostname` | Returns host-related info used during auth flows |
34
+ | `GET` | `/oauth-callback` | Completes connector OAuth and persists the user |
35
+ | `POST` | `/apiKeyLogin` | Handles API-key based login flows |
36
+ | `GET` | `/apiKeyManagedAuthState` | Returns required-field readiness for shared API-key auth |
37
+ | `POST` | `/unAuthorize` | Logs the user out of the CRM |
38
+ | `GET` | `/userInfoHash` | Returns a hash derived from user information |
39
+ | `GET` | `/ringcentral/oauth/callback` | Completes the admin RingCentral OAuth callback |
40
+
41
+ ## Admin Routes
42
+
43
+ | Method | Path | Purpose |
44
+ | --- | --- | --- |
45
+ | `POST` | `/admin/settings` | Validates RingCentral admin role and saves admin settings |
46
+ | `GET` | `/admin/settings` | Returns admin settings for the current account |
47
+ | `POST` | `/admin/userMapping` | Builds a mapping between CRM users and RingCentral extensions |
48
+ | `POST` | `/admin/reinitializeUserMapping` | Rebuilds user mappings from scratch |
49
+ | `GET` | `/admin/serverLoggingSettings` | Loads connector-specific server logging settings |
50
+ | `POST` | `/admin/serverLoggingSettings` | Updates connector-specific server logging settings |
51
+ | `GET` | `/admin/managedAuth` | Returns admin-facing managed-auth field definitions and masked stored values |
52
+ | `POST` | `/admin/managedAuth` | Upserts org-level or extension-level managed auth values |
53
+ | `GET` | `/ringcentral/admin/report` | Returns aggregated RingCentral call activity metrics |
54
+ | `GET` | `/ringcentral/admin/userReport` | Returns per-extension call and SMS metrics |
55
+
56
+ ## User Settings Routes
57
+
58
+ | Method | Path | Purpose |
59
+ | --- | --- | --- |
60
+ | `GET` | `/user/preloadSettings` | Loads settings used to bootstrap client-side configuration |
61
+ | `GET` | `/user/settings` | Returns merged user and admin settings |
62
+ | `POST` | `/user/settings` | Updates per-user settings, with connector hooks when present |
63
+
64
+ ## Contact Routes
65
+
66
+ | Method | Path | Purpose |
67
+ | --- | --- | --- |
68
+ | `GET` | `/contact` | Finds contacts by phone number |
69
+ | `POST` | `/contact` | Creates a new contact |
70
+ | `GET` | `/custom/contact/search` | Finds contacts by name |
71
+
72
+ ## Logging And Disposition Routes
73
+
74
+ | Method | Path | Purpose |
75
+ | --- | --- | --- |
76
+ | `POST` | `/callLog/cacheNote` | Stores a temporary note for server-side call logging |
77
+ | `GET` | `/callLog` | Looks up existing call logs by session id |
78
+ | `POST` | `/callLog` | Creates a CRM call log and stores the local linkage record |
79
+ | `PATCH` | `/callLog` | Updates an existing CRM call log |
80
+ | `PUT` | `/callDisposition` | Upserts call disposition data through the connector |
81
+ | `POST` | `/messageLog` | Creates or updates CRM logs for SMS, fax, and shared SMS |
82
+
83
+ ## Call-Down Routes
84
+
85
+ | Method | Path | Purpose |
86
+ | --- | --- | --- |
87
+ | `POST` | `/calldown` | Schedules a call-down item |
88
+ | `GET` | `/calldown` | Lists the current user's call-down items |
89
+ | `DELETE` | `/calldown/:id` | Removes a call-down item |
90
+ | `PATCH` | `/calldown/:id` | Updates or marks a call-down item |
91
+
92
+ ## Plugin And Debug Routes
93
+
94
+ | Method | Path | Purpose |
95
+ | --- | --- | --- |
96
+ | `GET` | `/debug/report/url` | Returns a presigned URL for error log upload |
97
+ | `POST` | `/pluginAsyncTask` | Returns async plugin task status and cleans up finished task cache entries |
98
+
99
+ ## Development-Only Mock Routes
100
+
101
+ These routes are only mounted when `IS_PROD === 'false'`.
102
+
103
+ | Method | Path | Purpose |
104
+ | --- | --- | --- |
105
+ | `POST` | `/registerMockUser` | Creates a mock user |
106
+ | `DELETE` | `/deleteMockUser` | Removes a mock user |
107
+ | `GET` | `/mockCallLog` | Reads mock call logs |
108
+ | `POST` | `/mockCallLog` | Creates a mock call log |
109
+ | `DELETE` | `/mockCallLog` | Clears mock call logs |
110
+
111
+ ## Operational Notes
112
+
113
+ - `createCoreRouter()` currently contains a large amount of orchestration logic in addition to route registration.
114
+ - Most route handlers duplicate a common pattern: decode JWT, load user, resolve connector, refresh auth, call handler, then track analytics.
115
+ - If route count continues growing, this file is a strong candidate for modular route extraction by feature area.
package/docs/tests.md CHANGED
@@ -1,73 +1,73 @@
1
- # Tests
2
-
3
- This page maps the non-MCP test suite under `packages/core/test`.
4
-
5
- ## Test Setup
6
-
7
- | File | Purpose |
8
- | --- | --- |
9
- | `test/setup.js` | Shared test bootstrapping for Jest |
10
- | `jest.config.js` | Package-local Jest configuration |
11
-
12
- ## Connector Tests
13
-
14
- | File | Coverage |
15
- | --- | --- |
16
- | `test/connector/registry.test.js` | Registry behavior, connector registration, and interface composition |
17
- | `test/connector/proxy/engine.test.js` | Proxy request rendering, auth header building, and response mapping |
18
- | `test/connector/proxy/index.test.js` | Proxy connector behavior across connector operations |
19
- | `test/connector/proxy/sample.json` | Sample proxy config fixture used by tests |
20
-
21
- ## Handler Tests
22
-
23
- | File | Coverage |
24
- | --- | --- |
25
- | `test/handlers/admin.test.js` | Admin settings and reporting behavior |
26
- | `test/handlers/auth.test.js` | OAuth, API-key login, and auth validation behavior |
27
- | `test/handlers/contact.test.js` | Contact lookup and creation flows |
28
- | `test/handlers/log.test.js` | Call-log and message-log workflows |
29
- | `test/handlers/plugin.test.js` | Async plugin task polling and cleanup |
30
- | `test/handlers/managedAuth.test.js` | Shared-auth field loading, encryption, masking, and login-time field resolution |
31
-
32
- ## Route Tests
33
-
34
- | File | Coverage |
35
- | --- | --- |
36
- | `test/routes/managedAuthRoutes.test.js` | Shared-auth API route behavior and validation paths |
37
-
38
- ## Library Tests
39
-
40
- | File | Coverage |
41
- | --- | --- |
42
- | `test/lib/callLogComposer.test.js` | Call-log formatting |
43
- | `test/lib/debugTracer.test.js` | Debug trace capture and serialization |
44
- | `test/lib/jwt.test.js` | JWT sign and verify helpers |
45
- | `test/lib/logger.test.js` | Logger behavior |
46
- | `test/lib/oauth.test.js` | OAuth client and token-refresh behavior |
47
- | `test/lib/ringcentral.test.js` | RingCentral API wrapper helpers |
48
- | `test/lib/sharedSMSComposer.test.js` | Shared-SMS formatting |
49
- | `test/lib/util.test.js` | Hashing, formatting, and utility helpers |
50
-
51
- ## Model Tests
52
-
53
- | File | Coverage |
54
- | --- | --- |
55
- | `test/models/models.test.js` | General Sequelize model behavior |
56
- | `test/models/accountDataModel.test.js` | Account-data cache behavior |
57
- | `test/models/dynamo/connectorSchema.test.js` | Dynamo-backed connector schema behavior |
58
-
59
- ## Coverage Gaps To Be Aware Of
60
-
61
- The current non-MCP test suite does not appear to have direct dedicated files for:
62
-
63
- - `handlers/calldown.js`
64
- - `handlers/disposition.js`
65
- - `lib/authSession.js`
66
- - `lib/encode.js`
67
- - `lib/errorHandler.js`
68
- - `lib/generalErrorMessage.js`
69
- - `lib/s3ErrorLogReport.js`
70
- - `models/callDownListModel.js`
71
- - `models/llmSessionModel.js`
72
- - `models/dynamo/lockSchema.js`
73
- - `models/dynamo/noteCacheSchema.js`
1
+ # Tests
2
+
3
+ This page maps the non-MCP test suite under `packages/core/test`.
4
+
5
+ ## Test Setup
6
+
7
+ | File | Purpose |
8
+ | --- | --- |
9
+ | `test/setup.js` | Shared test bootstrapping for Jest |
10
+ | `jest.config.js` | Package-local Jest configuration |
11
+
12
+ ## Connector Tests
13
+
14
+ | File | Coverage |
15
+ | --- | --- |
16
+ | `test/connector/registry.test.js` | Registry behavior, connector registration, and interface composition |
17
+ | `test/connector/proxy/engine.test.js` | Proxy request rendering, auth header building, and response mapping |
18
+ | `test/connector/proxy/index.test.js` | Proxy connector behavior across connector operations |
19
+ | `test/connector/proxy/sample.json` | Sample proxy config fixture used by tests |
20
+
21
+ ## Handler Tests
22
+
23
+ | File | Coverage |
24
+ | --- | --- |
25
+ | `test/handlers/admin.test.js` | Admin settings and reporting behavior |
26
+ | `test/handlers/auth.test.js` | OAuth, API-key login, and auth validation behavior |
27
+ | `test/handlers/contact.test.js` | Contact lookup and creation flows |
28
+ | `test/handlers/log.test.js` | Call-log and message-log workflows |
29
+ | `test/handlers/plugin.test.js` | Async plugin task polling and cleanup |
30
+ | `test/handlers/managedAuth.test.js` | Shared-auth field loading, encryption, masking, and login-time field resolution |
31
+
32
+ ## Route Tests
33
+
34
+ | File | Coverage |
35
+ | --- | --- |
36
+ | `test/routes/managedAuthRoutes.test.js` | Shared-auth API route behavior and validation paths |
37
+
38
+ ## Library Tests
39
+
40
+ | File | Coverage |
41
+ | --- | --- |
42
+ | `test/lib/callLogComposer.test.js` | Call-log formatting |
43
+ | `test/lib/debugTracer.test.js` | Debug trace capture and serialization |
44
+ | `test/lib/jwt.test.js` | JWT sign and verify helpers |
45
+ | `test/lib/logger.test.js` | Logger behavior |
46
+ | `test/lib/oauth.test.js` | OAuth client and token-refresh behavior |
47
+ | `test/lib/ringcentral.test.js` | RingCentral API wrapper helpers |
48
+ | `test/lib/sharedSMSComposer.test.js` | Shared-SMS formatting |
49
+ | `test/lib/util.test.js` | Hashing, formatting, and utility helpers |
50
+
51
+ ## Model Tests
52
+
53
+ | File | Coverage |
54
+ | --- | --- |
55
+ | `test/models/models.test.js` | General Sequelize model behavior |
56
+ | `test/models/accountDataModel.test.js` | Account-data cache behavior |
57
+ | `test/models/dynamo/connectorSchema.test.js` | Dynamo-backed connector schema behavior |
58
+
59
+ ## Coverage Gaps To Be Aware Of
60
+
61
+ The current non-MCP test suite does not appear to have direct dedicated files for:
62
+
63
+ - `handlers/calldown.js`
64
+ - `handlers/disposition.js`
65
+ - `lib/authSession.js`
66
+ - `lib/encode.js`
67
+ - `lib/errorHandler.js`
68
+ - `lib/generalErrorMessage.js`
69
+ - `lib/s3ErrorLogReport.js`
70
+ - `models/callDownListModel.js`
71
+ - `models/llmSessionModel.js`
72
+ - `models/dynamo/lockSchema.js`
73
+ - `models/dynamo/noteCacheSchema.js`