@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.
Files changed (286) hide show
  1. package/README.md +17 -16
  2. package/dist/connector/developerPortal.d.ts +6 -0
  3. package/{connector → dist/connector}/developerPortal.js +29 -12
  4. package/dist/connector/mock.d.ts +1 -0
  5. package/{connector → dist/connector}/mock.js +33 -17
  6. package/dist/connector/proxy/engine.d.ts +10 -0
  7. package/dist/connector/proxy/engine.js +222 -0
  8. package/dist/connector/proxy/index.d.ts +5 -0
  9. package/dist/connector/proxy/index.js +511 -0
  10. package/dist/connector/registry.d.ts +1 -0
  11. package/dist/connector/registry.js +243 -0
  12. package/dist/handlers/admin.d.ts +1 -0
  13. package/{handlers → dist/handlers}/admin.js +137 -78
  14. package/dist/handlers/appointment.d.ts +9 -0
  15. package/{handlers → dist/handlers}/appointment.js +58 -29
  16. package/dist/handlers/auth.d.ts +9 -0
  17. package/{handlers → dist/handlers}/auth.js +68 -40
  18. package/dist/handlers/calldown.d.ts +10 -0
  19. package/dist/handlers/calldown.js +134 -0
  20. package/dist/handlers/contact.d.ts +1 -0
  21. package/{handlers → dist/handlers}/contact.js +61 -39
  22. package/dist/handlers/disposition.d.ts +1 -0
  23. package/{handlers → dist/handlers}/disposition.js +20 -10
  24. package/dist/handlers/log.d.ts +1 -0
  25. package/{handlers → dist/handlers}/log.js +91 -124
  26. package/dist/handlers/managedAuth.d.ts +1 -0
  27. package/{handlers → dist/handlers}/managedAuth.js +134 -61
  28. package/dist/handlers/managedOAuth.d.ts +13 -0
  29. package/{handlers → dist/handlers}/managedOAuth.js +102 -30
  30. package/dist/handlers/plugin.d.ts +1 -0
  31. package/{handlers → dist/handlers}/plugin.js +59 -27
  32. package/dist/handlers/user.d.ts +1 -0
  33. package/{handlers → dist/handlers}/user.js +45 -27
  34. package/dist/index.d.ts +1 -0
  35. package/{index.js → dist/index.js} +538 -449
  36. package/dist/jest.config.d.ts +1 -0
  37. package/dist/jest.config.js +65 -0
  38. package/dist/lib/analytics.d.ts +4 -0
  39. package/{lib → dist/lib}/analytics.js +8 -6
  40. package/dist/lib/authSession.d.ts +5 -0
  41. package/{lib → dist/lib}/authSession.js +15 -43
  42. package/dist/lib/cacheCleanup.d.ts +4 -0
  43. package/{lib → dist/lib}/cacheCleanup.js +5 -17
  44. package/dist/lib/callLogComposer.d.ts +109 -0
  45. package/{lib → dist/lib}/callLogComposer.js +157 -197
  46. package/dist/lib/callLogLookup.d.ts +6 -0
  47. package/{lib → dist/lib}/callLogLookup.js +12 -34
  48. package/dist/lib/constants.d.ts +6 -0
  49. package/dist/lib/constants.js +9 -0
  50. package/dist/lib/debugTracer.d.ts +17 -0
  51. package/{lib → dist/lib}/debugTracer.js +7 -83
  52. package/dist/lib/encode.d.ts +3 -0
  53. package/dist/lib/encode.js +50 -0
  54. package/dist/lib/errorHandler.d.ts +7 -0
  55. package/dist/lib/errorHandler.js +161 -0
  56. package/dist/lib/generalErrorMessage.d.ts +7 -0
  57. package/{lib → dist/lib}/generalErrorMessage.js +6 -6
  58. package/dist/lib/jwt.d.ts +4 -0
  59. package/dist/lib/jwt.js +18 -0
  60. package/dist/lib/logger.d.ts +24 -0
  61. package/dist/lib/logger.js +126 -0
  62. package/dist/lib/migrateCallLogsSchema.d.ts +32 -0
  63. package/{lib → dist/lib}/migrateCallLogsSchema.js +75 -160
  64. package/dist/lib/oauth.d.ts +4 -0
  65. package/{lib → dist/lib}/oauth.js +157 -160
  66. package/dist/lib/ringcentral.d.ts +24 -0
  67. package/dist/lib/ringcentral.js +226 -0
  68. package/dist/lib/s3ErrorLogReport.d.ts +4 -0
  69. package/{lib → dist/lib}/s3ErrorLogReport.js +11 -23
  70. package/dist/lib/sharedSMSComposer.d.ts +7 -0
  71. package/{lib → dist/lib}/sharedSMSComposer.js +21 -107
  72. package/dist/lib/util.d.ts +7 -0
  73. package/{lib → dist/lib}/util.js +9 -20
  74. package/dist/mcp/lib/oauthError.d.ts +1 -0
  75. package/dist/mcp/lib/oauthError.js +25 -0
  76. package/dist/mcp/lib/validator.d.ts +1 -0
  77. package/{mcp → dist/mcp}/lib/validator.js +16 -20
  78. package/dist/mcp/lib/widgetSessionToken.d.ts +1 -0
  79. package/dist/mcp/lib/widgetSessionToken.js +46 -0
  80. package/dist/mcp/mcpHandler.d.ts +8 -0
  81. package/{mcp → dist/mcp}/mcpHandler.js +98 -88
  82. package/dist/mcp/tools/cancelAppointment.d.ts +1 -0
  83. package/{mcp → dist/mcp}/tools/cancelAppointment.js +7 -16
  84. package/dist/mcp/tools/checkAuthStatus.d.ts +1 -0
  85. package/{mcp → dist/mcp}/tools/checkAuthStatus.js +21 -14
  86. package/dist/mcp/tools/confirmAppointment.d.ts +1 -0
  87. package/{mcp → dist/mcp}/tools/confirmAppointment.js +7 -16
  88. package/dist/mcp/tools/createAppointment.d.ts +1 -0
  89. package/{mcp → dist/mcp}/tools/createAppointment.js +7 -19
  90. package/dist/mcp/tools/createCallLog.d.ts +1 -0
  91. package/{mcp → dist/mcp}/tools/createCallLog.js +18 -29
  92. package/dist/mcp/tools/createContact.d.ts +1 -0
  93. package/{mcp → dist/mcp}/tools/createContact.js +8 -20
  94. package/dist/mcp/tools/createMessageLog.d.ts +1 -0
  95. package/{mcp → dist/mcp}/tools/createMessageLog.js +14 -26
  96. package/dist/mcp/tools/doAuth.d.ts +1 -0
  97. package/{mcp → dist/mcp}/tools/doAuth.js +17 -13
  98. package/dist/mcp/tools/findContactByName.d.ts +1 -0
  99. package/{mcp → dist/mcp}/tools/findContactByName.js +9 -15
  100. package/dist/mcp/tools/findContactByPhone.d.ts +1 -0
  101. package/{mcp → dist/mcp}/tools/findContactByPhone.js +8 -15
  102. package/dist/mcp/tools/getCallLog.d.ts +1 -0
  103. package/{mcp → dist/mcp}/tools/getCallLog.js +12 -21
  104. package/dist/mcp/tools/getGoogleFilePicker.d.ts +1 -0
  105. package/{mcp → dist/mcp}/tools/getGoogleFilePicker.js +9 -18
  106. package/dist/mcp/tools/getHelp.d.ts +1 -0
  107. package/{mcp → dist/mcp}/tools/getHelp.js +5 -6
  108. package/dist/mcp/tools/getPublicConnectors.d.ts +1 -0
  109. package/{mcp → dist/mcp}/tools/getPublicConnectors.js +19 -18
  110. package/dist/mcp/tools/getSessionInfo.d.ts +1 -0
  111. package/{mcp → dist/mcp}/tools/getSessionInfo.js +10 -16
  112. package/dist/mcp/tools/index.d.ts +8 -0
  113. package/dist/mcp/tools/index.js +50 -0
  114. package/dist/mcp/tools/listAppointments.d.ts +1 -0
  115. package/{mcp → dist/mcp}/tools/listAppointments.js +7 -19
  116. package/dist/mcp/tools/logout.d.ts +1 -0
  117. package/{mcp → dist/mcp}/tools/logout.js +16 -14
  118. package/dist/mcp/tools/rcGetCallLogs.d.ts +1 -0
  119. package/{mcp → dist/mcp}/tools/rcGetCallLogs.js +10 -8
  120. package/dist/mcp/tools/updateAppointment.d.ts +1 -0
  121. package/{mcp → dist/mcp}/tools/updateAppointment.js +17 -22
  122. package/dist/mcp/tools/updateCallLog.d.ts +1 -0
  123. package/{mcp → dist/mcp}/tools/updateCallLog.js +16 -26
  124. package/dist/models/accountDataModel.d.ts +3 -0
  125. package/dist/models/accountDataModel.js +39 -0
  126. package/dist/models/adminConfigModel.d.ts +2 -0
  127. package/dist/models/adminConfigModel.js +39 -0
  128. package/dist/models/cacheModel.d.ts +2 -0
  129. package/{models → dist/models}/cacheModel.js +7 -3
  130. package/dist/models/callDownListModel.d.ts +2 -0
  131. package/{models → dist/models}/callDownListModel.js +8 -4
  132. package/dist/models/callLogModel.d.ts +2 -0
  133. package/dist/models/callLogModel.js +43 -0
  134. package/dist/models/dynamo/connectorSchema.d.ts +2 -0
  135. package/dist/models/dynamo/connectorSchema.js +141 -0
  136. package/dist/models/dynamo/lockSchema.d.ts +2 -0
  137. package/{models → dist/models}/dynamo/lockSchema.js +5 -7
  138. package/dist/models/dynamo/noteCacheSchema.d.ts +2 -0
  139. package/{models → dist/models}/dynamo/noteCacheSchema.js +4 -6
  140. package/dist/models/llmSessionModel.d.ts +2 -0
  141. package/dist/models/llmSessionModel.js +21 -0
  142. package/dist/models/messageLogModel.d.ts +2 -0
  143. package/{models → dist/models}/messageLogModel.js +8 -4
  144. package/dist/models/sequelize.d.ts +2 -0
  145. package/dist/models/sequelize.js +68 -0
  146. package/dist/models/userModel.d.ts +2 -0
  147. package/dist/models/userModel.js +49 -0
  148. package/dist/package.json +100 -0
  149. package/dist/releaseNotes.json +1222 -0
  150. package/dist/tsconfig.json +14 -0
  151. package/dist/types/admin.d.ts +141 -0
  152. package/dist/types/analytics.d.ts +14 -0
  153. package/dist/types/appointment.d.ts +50 -0
  154. package/dist/types/auth.d.ts +137 -0
  155. package/dist/types/authSession.d.ts +35 -0
  156. package/dist/types/cacheCleanup.d.ts +12 -0
  157. package/dist/types/calldown.d.ts +54 -0
  158. package/dist/types/common.d.ts +46 -0
  159. package/dist/types/connector.d.ts +165 -0
  160. package/dist/types/contact.d.ts +125 -0
  161. package/dist/types/errorHandler.d.ts +60 -0
  162. package/dist/types/index.d.ts +76 -0
  163. package/dist/types/json.d.ts +9 -0
  164. package/dist/types/jwt.d.ts +8 -0
  165. package/dist/types/logging.d.ts +224 -0
  166. package/dist/types/managedAuth.d.ts +114 -0
  167. package/dist/types/managedOAuth.d.ts +59 -0
  168. package/dist/types/manifest.d.ts +120 -0
  169. package/dist/types/migration.d.ts +15 -0
  170. package/dist/types/plugin.d.ts +74 -0
  171. package/dist/types/ringcentral.d.ts +61 -0
  172. package/dist/types/s3ErrorLogReport.d.ts +16 -0
  173. package/dist/types/sharedSMSComposer.d.ts +105 -0
  174. package/dist/types/user.d.ts +46 -0
  175. package/dist/types/util.d.ts +7 -0
  176. package/package.json +34 -6
  177. package/releaseNotes.json +8 -0
  178. package/.env.test +0 -5
  179. package/connector/proxy/engine.js +0 -165
  180. package/connector/proxy/index.js +0 -500
  181. package/connector/registry.js +0 -252
  182. package/docs/README.md +0 -50
  183. package/docs/architecture.md +0 -94
  184. package/docs/connectors.md +0 -116
  185. package/docs/handlers.md +0 -128
  186. package/docs/libraries.md +0 -98
  187. package/docs/models.md +0 -146
  188. package/docs/routes.md +0 -119
  189. package/docs/tests.md +0 -73
  190. package/handlers/calldown.js +0 -99
  191. package/jest.config.js +0 -57
  192. package/lib/constants.js +0 -9
  193. package/lib/encode.js +0 -30
  194. package/lib/errorHandler.js +0 -218
  195. package/lib/jwt.js +0 -18
  196. package/lib/logger.js +0 -190
  197. package/lib/ringcentral.js +0 -267
  198. package/mcp/README.md +0 -420
  199. package/mcp/tools/index.js +0 -51
  200. package/mcp/ui/App/App.tsx +0 -358
  201. package/mcp/ui/App/components/AuthInfoForm.tsx +0 -113
  202. package/mcp/ui/App/components/AuthSuccess.tsx +0 -22
  203. package/mcp/ui/App/components/ConnectorList.tsx +0 -82
  204. package/mcp/ui/App/components/DebugPanel.tsx +0 -43
  205. package/mcp/ui/App/components/OAuthConnect.tsx +0 -270
  206. package/mcp/ui/App/lib/callTool.ts +0 -130
  207. package/mcp/ui/App/lib/debugLog.ts +0 -41
  208. package/mcp/ui/App/lib/developerPortal.ts +0 -111
  209. package/mcp/ui/App/main.css +0 -6
  210. package/mcp/ui/App/root.tsx +0 -13
  211. package/mcp/ui/dist/index.html +0 -53
  212. package/mcp/ui/vite.config.ts +0 -16
  213. package/models/accountDataModel.js +0 -34
  214. package/models/adminConfigModel.js +0 -35
  215. package/models/callLogModel.js +0 -39
  216. package/models/dynamo/connectorSchema.js +0 -146
  217. package/models/llmSessionModel.js +0 -17
  218. package/models/sequelize.js +0 -17
  219. package/models/userModel.js +0 -45
  220. package/test/connector/developerPortal.test.js +0 -166
  221. package/test/connector/mock.test.js +0 -131
  222. package/test/connector/proxy/engine.test.js +0 -211
  223. package/test/connector/proxy/index.test.js +0 -525
  224. package/test/connector/proxy/sample.json +0 -162
  225. package/test/connector/registry.test.js +0 -416
  226. package/test/handlers/admin.test.js +0 -960
  227. package/test/handlers/appointment.test.js +0 -260
  228. package/test/handlers/auth.test.js +0 -1096
  229. package/test/handlers/calldown.test.js +0 -310
  230. package/test/handlers/contact.test.js +0 -1014
  231. package/test/handlers/disposition.test.js +0 -396
  232. package/test/handlers/log.test.js +0 -1847
  233. package/test/handlers/managedAuth.test.js +0 -458
  234. package/test/handlers/managedOAuth.test.js +0 -262
  235. package/test/handlers/plugin.test.js +0 -429
  236. package/test/handlers/user.test.js +0 -381
  237. package/test/index.test.js +0 -301
  238. package/test/lib/analytics.test.js +0 -146
  239. package/test/lib/authSession.test.js +0 -173
  240. package/test/lib/cacheCleanup.test.js +0 -127
  241. package/test/lib/callLogComposer.test.js +0 -1231
  242. package/test/lib/debugTracer.test.js +0 -328
  243. package/test/lib/encode.test.js +0 -59
  244. package/test/lib/errorHandler.test.js +0 -246
  245. package/test/lib/generalErrorMessage.test.js +0 -82
  246. package/test/lib/jwt.test.js +0 -176
  247. package/test/lib/logger.test.js +0 -206
  248. package/test/lib/oauth.test.js +0 -359
  249. package/test/lib/ringcentral.test.js +0 -467
  250. package/test/lib/s3ErrorLogReport.test.js +0 -187
  251. package/test/lib/sharedSMSComposer.test.js +0 -1084
  252. package/test/lib/util.test.js +0 -329
  253. package/test/mcp/mcpHandler.test.js +0 -73
  254. package/test/mcp/mcpHandlerMore.test.js +0 -384
  255. package/test/mcp/tools/appointmentTools.test.js +0 -362
  256. package/test/mcp/tools/checkAuthStatus.test.js +0 -83
  257. package/test/mcp/tools/createCallLog.test.js +0 -436
  258. package/test/mcp/tools/createContact.test.js +0 -58
  259. package/test/mcp/tools/createMessageLog.test.js +0 -595
  260. package/test/mcp/tools/doAuth.test.js +0 -113
  261. package/test/mcp/tools/findContactByName.test.js +0 -275
  262. package/test/mcp/tools/findContactByPhone.test.js +0 -296
  263. package/test/mcp/tools/getCallLog.test.js +0 -298
  264. package/test/mcp/tools/getGoogleFilePicker.test.js +0 -281
  265. package/test/mcp/tools/getPublicConnectors.test.js +0 -107
  266. package/test/mcp/tools/getSessionInfo.test.js +0 -127
  267. package/test/mcp/tools/logout.test.js +0 -233
  268. package/test/mcp/tools/rcGetCallLogs.test.js +0 -56
  269. package/test/mcp/tools/updateCallLog.test.js +0 -360
  270. package/test/models/accountDataModel.test.js +0 -98
  271. package/test/models/callDownListModel.test.js +0 -125
  272. package/test/models/dynamo/connectorSchema.test.js +0 -189
  273. package/test/models/dynamo/lockSchema.test.js +0 -37
  274. package/test/models/dynamo/noteCacheSchema.test.js +0 -45
  275. package/test/models/llmSessionModel.test.js +0 -91
  276. package/test/models/models.test.js +0 -660
  277. package/test/routes/calldownRoutes.test.js +0 -224
  278. package/test/routes/coreRouterBroadRoutes.test.js +0 -855
  279. package/test/routes/dispositionRoutes.test.js +0 -192
  280. package/test/routes/managedAuthRoutes.test.js +0 -386
  281. package/test/routes/pluginRoutes.test.js +0 -262
  282. package/test/setup.js +0 -178
  283. /package/{mcp → dist/mcp}/ui/index.html +0 -0
  284. /package/{mcp → dist/mcp}/ui/package-lock.json +0 -0
  285. /package/{mcp → dist/mcp}/ui/package.json +0 -0
  286. /package/{mcp → dist/mcp}/ui/tsconfig.json +0 -0
package/docs/libraries.md DELETED
@@ -1,98 +0,0 @@
1
- # Libraries
2
-
3
- The `lib/` directory contains cross-cutting helpers used by routes, handlers, and connectors.
4
-
5
- ## Infrastructure And Security
6
-
7
- | File | Responsibility |
8
- | --- | --- |
9
- | `lib/jwt.js` | Signs and verifies long-lived JWTs with `APP_SERVER_SECRET_KEY` |
10
- | `lib/oauth.js` | Builds OAuth clients and refreshes access tokens with lock protection |
11
- | `lib/authSession.js` | Stores and updates auth-session records used by auth flows |
12
- | `lib/encode.js` | Small encoding and decoding helpers for encrypted values |
13
- | `lib/errorHandler.js` | Normalizes API and database errors and exports Express error middleware |
14
- | `lib/logger.js` | Structured logger plus exported `Logger` class and log-level constants |
15
- | `lib/debugTracer.js` | Request-scoped trace collector used when debug mode is enabled |
16
- | `lib/s3ErrorLogReport.js` | S3 bucket setup and presigned upload URL generation for debug reports |
17
-
18
- ## RingCentral And Analytics Helpers
19
-
20
- | File | Responsibility |
21
- | --- | --- |
22
- | `lib/ringcentral.js` | RingCentral API wrapper plus token-validity helpers |
23
- | `lib/analytics.js` | Mixpanel initialization and event tracking |
24
- | `lib/generalErrorMessage.js` | Shared user-facing warning messages for auth and rate-limit cases |
25
-
26
- ## Formatting And Utility Helpers
27
-
28
- | File | Responsibility |
29
- | --- | --- |
30
- | `lib/callLogComposer.js` | Builds plain text, HTML, or Markdown call-log bodies |
31
- | `lib/sharedSMSComposer.js` | Builds shared-SMS conversation log content |
32
- | `lib/constants.js` | Defines `LOG_DETAILS_FORMAT_TYPE` values |
33
- | `lib/util.js` | Hashing, timezone lookup, media-reader links, plugin setting extraction, and date helpers |
34
-
35
- ## Notes By File
36
-
37
- ### `lib/analytics.js`
38
-
39
- - no-op unless `MIXPANEL_TOKEN` is present
40
- - attaches package version, app name, connector name, browser, OS, device, and caller metadata to events
41
- - requires `extensionId` to emit an event
42
-
43
- ### `lib/jwt.js`
44
-
45
- - `generateJwt()` signs with a very long expiration window
46
- - `decodeJwt()` logs and returns `null` on verification failure instead of throwing
47
-
48
- ### `lib/errorHandler.js`
49
-
50
- Exports:
51
-
52
- - `handleApiError()`
53
- - `handleDatabaseError()`
54
- - `asyncHandler()`
55
- - `errorMiddleware()`
56
- - `getOperationErrorMessage()`
57
-
58
- Notable behavior:
59
-
60
- - HTTP 429 becomes a rate-limit warning
61
- - HTTP 4xx up to 409 becomes an authorization-style warning
62
- - everything else becomes an operation-specific warning response
63
-
64
- ### `lib/callLogComposer.js`
65
-
66
- This module centralizes log-body generation for call logs.
67
-
68
- It supports:
69
-
70
- - plain text
71
- - HTML
72
- - Markdown
73
- - note insertion
74
- - session id, subject, duration, result, recording, and timestamp formatting
75
- - transcript and AI note insertion
76
- - leg journey formatting
77
- - ACE transcript, summary, score, bullet summary, and deep link sections
78
-
79
- ### `lib/sharedSMSComposer.js`
80
-
81
- This module formats shared SMS conversations for CRM logging.
82
-
83
- It handles:
84
-
85
- - message, note, and assignment entities
86
- - owner and assignee metadata
87
- - per-format output generation
88
- - summary counts and formatted timeline entries
89
-
90
- ### `lib/util.js`
91
-
92
- Exports:
93
-
94
- - `getTimeZone()`
95
- - `getHashValue()`
96
- - `secondsToHoursMinutesSeconds()`
97
- - `getMostRecentDate()`
98
- - `getMediaReaderLinkByPlatformMediaLink()`
package/docs/models.md DELETED
@@ -1,146 +0,0 @@
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
- | `extensionNumber` | Legacy RingCentral extension number identity; part of the composite primary key |
39
- | `hashedExtensionId` | Hashed RingCentral extension id used for current call-log identity; part of the composite primary key |
40
- | `platform` | Connector platform |
41
- | `thirdPartyLogId` | CRM log id |
42
- | `userId` | App Connect user id |
43
- | `contactId` | CRM contact id used for the log |
44
-
45
- ### `models/messageLogModel.js`
46
-
47
- Stores message-log linkage records.
48
-
49
- | Field | Notes |
50
- | --- | --- |
51
- | `id` | Message id or conversation log id |
52
- | `platform` | Connector platform |
53
- | `conversationId` | Conversation identifier |
54
- | `conversationLogId` | Shared key used to group related message logs |
55
- | `thirdPartyLogId` | CRM log id |
56
- | `userId` | App Connect user id |
57
-
58
- ### `models/adminConfigModel.js`
59
-
60
- Stores account-level admin configuration.
61
-
62
- | Field | Notes |
63
- | --- | --- |
64
- | `id` | Hashed RingCentral account id |
65
- | `userSettings` | Account-level settings policy |
66
- | `customAdapter` | Obsolete field kept for compatibility |
67
- | `adminAccessToken` | RingCentral admin access token |
68
- | `adminRefreshToken` | RingCentral admin refresh token |
69
- | `adminTokenExpiry` | Admin token expiry |
70
- | `userMappings` | JSON mapping between CRM users and RingCentral extensions |
71
-
72
- ### `models/cacheModel.js`
73
-
74
- Stores temporary task state, mainly for async plugin work.
75
-
76
- | Field | Notes |
77
- | --- | --- |
78
- | `id` | Task id. Async plugin callback tasks use the UUID sent to the plugin as `asyncTaskId`. |
79
- | `status` | Task status such as `pending`, `initialized`, `completed`, or `failed` |
80
- | `userId` | Owning user |
81
- | `cacheKey` | Logical task family. Async plugin tasks use `asyncPluginTask-<pluginId>`. |
82
- | `data` | Optional task payload. Async plugin tasks keep callback URL, plugin id, call-log lookup fields, original plugin input, and failure `message` when a callback fails. |
83
- | `expiry` | Cleanup cutoff. Async plugin callback tasks expire after one week. |
84
-
85
- ### `models/accountDataModel.js`
86
-
87
- Stores account-scoped cached data.
88
-
89
- Composite primary key:
90
-
91
- - `rcAccountId`
92
- - `platformName`
93
- - `dataKey`
94
-
95
- Main usage in current code:
96
-
97
- - cached contact lookups keyed as `contact-${phoneNumber}`
98
-
99
- Helper export:
100
-
101
- - `getOrRefreshAccountData()` which returns cached data unless `forceRefresh` is set
102
-
103
- ### `models/callDownListModel.js`
104
-
105
- Stores user-owned call-down queue items.
106
-
107
- | Field | Notes |
108
- | --- | --- |
109
- | `id` | Primary key |
110
- | `userId` | Owning user |
111
- | `contactId` | CRM contact id |
112
- | `contactType` | Contact entity type |
113
- | `status` | Queue state such as `scheduled` or `called` |
114
- | `scheduledAt` | Requested follow-up time |
115
- | `lastCallAt` | Last call timestamp |
116
-
117
- This model enables timestamps and indexes on `userId`, `status`, `scheduledAt`, and `userId + status`.
118
-
119
- ### `models/llmSessionModel.js`
120
-
121
- Stores a lightweight mapping from an LLM session id to a JWT token.
122
-
123
- ## Dynamoose Models
124
-
125
- ### `models/dynamo/connectorSchema.js`
126
-
127
- Stores connector metadata used by proxy integrations.
128
-
129
- Important role:
130
-
131
- - source of truth for `Connector.getProxyConfig(proxyId)`
132
-
133
- This schema is a dependency of auth, contact, log, admin, and proxy connector flows.
134
-
135
- ### `models/dynamo/lockSchema.js`
136
-
137
- Stores distributed lock state used by token refresh and similar coordination logic.
138
-
139
- ### `models/dynamo/noteCacheSchema.js`
140
-
141
- Stores note cache entries keyed by `sessionId`.
142
-
143
- Main usage:
144
-
145
- - `handlers/log.js` can read cached notes during server-side call logging
146
- - `saveNoteCache()` writes entries with a TTL
package/docs/routes.md DELETED
@@ -1,119 +0,0 @@
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
- | `POST` | `/user/refreshInfo` | Refreshes connector-owned CRM user information for the current user |
62
- | `GET` | `/user/settings` | Returns merged user and admin settings |
63
- | `POST` | `/user/settings` | Updates per-user settings, with connector hooks when present |
64
-
65
- ## Contact Routes
66
-
67
- | Method | Path | Purpose |
68
- | --- | --- | --- |
69
- | `GET` | `/contact` | Finds contacts by phone number |
70
- | `POST` | `/contact` | Creates a new contact |
71
- | `GET` | `/custom/contact/search` | Finds contacts by name |
72
-
73
- ## Logging And Disposition Routes
74
-
75
- | Method | Path | Purpose |
76
- | --- | --- | --- |
77
- | `POST` | `/callLog/cacheNote` | Stores a temporary note for server-side call logging |
78
- | `GET` | `/callLog` | Looks up existing call logs by session id plus extension identity |
79
- | `POST` | `/callLog` | Creates a CRM call log and stores the local linkage record |
80
- | `PATCH` | `/callLog` | Updates an existing CRM call log |
81
- | `PUT` | `/callDisposition` | Upserts call disposition data through the connector |
82
- | `POST` | `/messageLog` | Creates or updates CRM logs for SMS, fax, and shared SMS |
83
-
84
- ## Call-Down Routes
85
-
86
- | Method | Path | Purpose |
87
- | --- | --- | --- |
88
- | `POST` | `/calldown` | Schedules a call-down item |
89
- | `GET` | `/calldown` | Lists the current user's call-down items |
90
- | `DELETE` | `/calldown/:id` | Removes a call-down item |
91
- | `PATCH` | `/calldown/:id` | Updates or marks a call-down item |
92
-
93
- ## Plugin And Debug Routes
94
-
95
- | Method | Path | Purpose |
96
- | --- | --- | --- |
97
- | `GET` | `/debug/report/url` | Returns a presigned URL for error log upload |
98
- | `POST` | `/plugin/async-callback/:taskId` | Receives async plugin completion callbacks for call-log tasks |
99
- | `POST` | `/plugin/register` | Registers an account-level plugin and stores returned plugin auth data |
100
- | `DELETE` | `/plugin/unregister` | Removes account-level plugin auth and settings |
101
- | `GET` | `/plugin/licenseStatus` | Reads license status for an installed plugin |
102
-
103
- ## Development-Only Mock Routes
104
-
105
- These routes are only mounted when `IS_PROD === 'false'`.
106
-
107
- | Method | Path | Purpose |
108
- | --- | --- | --- |
109
- | `POST` | `/registerMockUser` | Creates a mock user |
110
- | `DELETE` | `/deleteMockUser` | Removes a mock user |
111
- | `GET` | `/mockCallLog` | Reads mock call logs |
112
- | `POST` | `/mockCallLog` | Creates a mock call log |
113
- | `DELETE` | `/mockCallLog` | Clears mock call logs |
114
-
115
- ## Operational Notes
116
-
117
- - `createCoreRouter()` currently contains a large amount of orchestration logic in addition to route registration.
118
- - Most route handlers duplicate a common pattern: decode JWT, load user, resolve connector, refresh auth, call handler, then track analytics.
119
- - If route count continues growing, this file is a strong candidate for modular route extraction by feature area.
package/docs/tests.md DELETED
@@ -1,73 +0,0 @@
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,99 +0,0 @@
1
- const { UserModel } = require('../models/userModel');
2
- const { CallDownListModel } = require('../models/callDownListModel');
3
- const { Op } = require('sequelize');
4
- const jwt = require('../lib/jwt');
5
- const { handleDatabaseError } = require('../lib/errorHandler');
6
-
7
- async function schedule({ jwtToken, body }) {
8
- const unAuthData = jwt.decodeJwt(jwtToken);
9
- if (!unAuthData?.id) throw new Error('Unauthorized');
10
- const user = await UserModel.findByPk(unAuthData.id);
11
- if (!user) throw new Error('User not found');
12
- const crypto = require('crypto');
13
- const recordId = crypto.randomBytes(16).toString('hex');
14
- const payload = {
15
- id: recordId,
16
- userId: user.id,
17
- contactId: body.contactId?.toString?.() ?? body.contactId,
18
- contactType: body.contactType ?? 'contact',
19
- contactName: body.contactName ?? '',
20
- phoneNumber: body.phoneNumber ?? '',
21
- status: 'scheduled',
22
- scheduledAt: body.scheduledAt ? new Date(body.scheduledAt) : null,
23
- lastCallAt: null
24
- };
25
- await CallDownListModel.create(payload);
26
- return { id: recordId };
27
- }
28
-
29
- async function list({ jwtToken, status }) {
30
- const unAuthData = jwt.decodeJwt(jwtToken);
31
- if (!unAuthData?.id) throw new Error('Unauthorized');
32
- const statusParam = (status || 'All').toString().toLowerCase();
33
- const whereClause = { userId: unAuthData.id };
34
- if (statusParam === 'called') whereClause.status = 'called';
35
- else if (['not called', 'not_called', 'notcalled'].includes(statusParam)) whereClause.status = { [Op.ne]: 'called' };
36
- const items = await CallDownListModel.findAll({ where: whereClause, order: [["scheduledAt", "ASC"]] });
37
- return { items };
38
- }
39
-
40
- async function remove({ jwtToken, id }) {
41
- const unAuthData = jwt.decodeJwt(jwtToken);
42
- if (!unAuthData?.id) throw new Error('Unauthorized');
43
- const deleted = await CallDownListModel.destroy({ where: { id, userId: unAuthData.id } });
44
- if (!deleted) throw new Error('Not found');
45
- return { successful: true };
46
- }
47
-
48
- async function markCalled({ jwtToken, id, lastCallAt }) {
49
- const unAuthData = jwt.decodeJwt(jwtToken);
50
- if (!unAuthData?.id) throw new Error('Unauthorized');
51
- const when = lastCallAt ? new Date(lastCallAt) : new Date();
52
- try {
53
- const [affected] = await CallDownListModel.update({ status: 'called', lastCallAt: when }, { where: { id, userId: unAuthData.id } });
54
- if (!affected) throw new Error('Not found');
55
- return { successful: true };
56
- }
57
- catch (error) {
58
- return handleDatabaseError(error, 'Error marking call as called', { id, userId: unAuthData.id });
59
- }
60
- }
61
-
62
- async function update({ jwtToken, id, updateData }) {
63
- const unAuthData = jwt.decodeJwt(jwtToken);
64
- if (!unAuthData?.id) throw new Error('Unauthorized');
65
-
66
- // Prepare the update object with only valid fields
67
- const allowedFields = ['contactId', 'contactType', 'contactName', 'phoneNumber', 'status', 'scheduledAt', 'lastCallAt', 'note'];
68
- const updateObject = {};
69
-
70
- // Filter and prepare update data
71
- Object.keys(updateData).forEach(key => {
72
- if (allowedFields.includes(key)) {
73
- let value = updateData[key];
74
-
75
- // Handle date fields
76
- if ((key === 'scheduledAt' || key === 'lastCallAt') && value) {
77
- value = new Date(value);
78
- }
79
-
80
- updateObject[key] = value;
81
- }
82
- });
83
-
84
- // If no valid fields to update, throw error
85
- if (Object.keys(updateObject).length === 0) {
86
- throw new Error('No valid fields to update');
87
- }
88
-
89
- const [affected] = await CallDownListModel.update(updateObject, { where: { id, userId: unAuthData.id } });
90
- if (!affected) throw new Error('Not found');
91
- return { successful: true };
92
- }
93
-
94
- exports.schedule = schedule;
95
- exports.list = list;
96
- exports.remove = remove;
97
- exports.markCalled = markCalled;
98
- exports.update = update;
99
-
package/jest.config.js DELETED
@@ -1,57 +0,0 @@
1
- const path = require('path');
2
-
3
- module.exports = {
4
- // Test environment
5
- testEnvironment: 'node',
6
-
7
- // Test file patterns
8
- testMatch: [
9
- '<rootDir>/test/**/*.test.js',
10
- '<rootDir>/**/*.test.js'
11
- ],
12
-
13
- // Setup files
14
- setupFilesAfterEnv: [
15
- '<rootDir>/test/setup.js'
16
- ],
17
-
18
- // Coverage configuration
19
- collectCoverage: true,
20
- coverageDirectory: '<rootDir>/coverage',
21
- coverageReporters: ['text', 'lcov', 'html'],
22
- coveragePathIgnorePatterns: [
23
- '/node_modules/',
24
- '/test/',
25
- '/coverage/',
26
- 'jest.config.js',
27
- 'setup.js'
28
- ],
29
-
30
- // Module resolution
31
- moduleDirectories: ['node_modules', '<rootDir>'],
32
- moduleNameMapper: {
33
- '^@app-connect/core/(.*)$': '<rootDir>/$1'
34
- },
35
-
36
- // Test timeout
37
- testTimeout: 30000,
38
-
39
- // Reporters
40
- reporters: ['default'],
41
-
42
- // Ignore patterns
43
- modulePathIgnorePatterns: [
44
- '<rootDir>/node_modules/',
45
- '<rootDir>/coverage/',
46
- '<rootDir>/test-results/'
47
- ],
48
-
49
- // Clear mocks between tests
50
- clearMocks: true,
51
-
52
- // Restore mocks between tests
53
- restoreMocks: true,
54
-
55
- // Verbose output
56
- verbose: true
57
- };
package/lib/constants.js DELETED
@@ -1,9 +0,0 @@
1
- const LOG_DETAILS_FORMAT_TYPE = {
2
- PLAIN_TEXT: 'text/plain',
3
- HTML: 'text/html',
4
- MARKDOWN: 'text/markdown'
5
- };
6
-
7
- module.exports = {
8
- LOG_DETAILS_FORMAT_TYPE
9
- };
package/lib/encode.js DELETED
@@ -1,30 +0,0 @@
1
- const crypto = require('crypto');
2
-
3
- function getCipherKey() {
4
- if (!process.env.APP_SERVER_SECRET_KEY) {
5
- throw new Error('APP_SERVER_SECRET_KEY is not defined');
6
- }
7
- if (process.env.APP_SERVER_SECRET_KEY.length < 32) {
8
- // pad secret key with spaces if it is less than 32 bytes
9
- return process.env.APP_SERVER_SECRET_KEY.padEnd(32, ' ');
10
- }
11
- if (process.env.APP_SERVER_SECRET_KEY.length > 32) {
12
- // truncate secret key if it is more than 32 bytes
13
- return process.env.APP_SERVER_SECRET_KEY.slice(0, 32);
14
- }
15
- return process.env.APP_SERVER_SECRET_KEY;
16
- }
17
-
18
- function encode(data) {
19
- const cipher = crypto.createCipheriv('aes-256-cbc', getCipherKey(), Buffer.alloc(16, 0));
20
- return cipher.update(data, 'utf8', 'hex') + cipher.final('hex');
21
- }
22
-
23
- function decoded(encryptedData) {
24
- const decipher = crypto.createDecipheriv('aes-256-cbc', getCipherKey(), Buffer.alloc(16, 0));
25
- return decipher.update(encryptedData, 'hex', 'utf8') + decipher.final('utf8');
26
- }
27
-
28
-
29
- exports.encode = encode;
30
- exports.decoded = decoded;