@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
@@ -0,0 +1,120 @@
1
+ import type { JsonObject, JsonValue } from './json';
2
+
3
+ export type ConnectorAuthType = 'oauth' | 'apiKey' | (string & {});
4
+
5
+ export interface AuthorInfo {
6
+ name?: string;
7
+ websiteUrl?: string;
8
+ [key: string]: JsonValue | undefined;
9
+ }
10
+
11
+ export interface EnvironmentSelection {
12
+ const: string;
13
+ name: string;
14
+ [key: string]: JsonValue;
15
+ }
16
+
17
+ export interface ConnectorEnvironment {
18
+ type: 'fixed' | 'dynamic' | 'selectable' | (string & {});
19
+ url?: string;
20
+ urlIdentifier?: string;
21
+ instructions?: string[];
22
+ selections?: EnvironmentSelection[];
23
+ [key: string]: JsonValue | undefined;
24
+ }
25
+
26
+ export interface PageField {
27
+ const: string;
28
+ title?: string;
29
+ type?: string;
30
+ required?: boolean;
31
+ default?: JsonValue;
32
+ [key: string]: JsonValue | undefined;
33
+ }
34
+
35
+ export interface OAuthManifestConfig {
36
+ authUrl?: string;
37
+ clientId?: string;
38
+ redirectUri?: string;
39
+ scope?: string;
40
+ customState?: string;
41
+ [key: string]: JsonValue | undefined;
42
+ }
43
+
44
+ export interface ApiKeyManifestConfig {
45
+ page?: {
46
+ title?: string;
47
+ content?: PageField[];
48
+ [key: string]: JsonValue | undefined;
49
+ };
50
+ [key: string]: JsonValue | undefined;
51
+ }
52
+
53
+ export interface ManifestAuthConfig {
54
+ type: ConnectorAuthType;
55
+ oauth?: OAuthManifestConfig;
56
+ apiKey?: ApiKeyManifestConfig;
57
+ [key: string]: JsonValue | undefined;
58
+ }
59
+
60
+ export interface ServerSideLoggingConfig {
61
+ url?: string;
62
+ useAdminAssignedUserToken?: boolean;
63
+ enableUserMapping?: boolean;
64
+ additionalFields?: PageField[];
65
+ [key: string]: JsonValue | undefined;
66
+ }
67
+
68
+ export interface ContactTypeConfig {
69
+ id?: string;
70
+ name?: string;
71
+ type?: string;
72
+ [key: string]: JsonValue | undefined;
73
+ }
74
+
75
+ export interface PlatformPageConfig {
76
+ useContactSearch?: boolean;
77
+ disableContactCache?: boolean;
78
+ callLog?: JsonObject;
79
+ messageLog?: JsonObject;
80
+ [key: string]: JsonValue | undefined;
81
+ }
82
+
83
+ export interface PlatformManifest {
84
+ name: string;
85
+ displayName?: string;
86
+ developer?: AuthorInfo;
87
+ environment?: ConnectorEnvironment;
88
+ urlIdentifier?: string;
89
+ embedUrls?: string[];
90
+ logoUrl?: string;
91
+ documentationUrl?: string;
92
+ releaseNotesUrl?: string;
93
+ getSupportUrl?: string;
94
+ writeReviewUrl?: string;
95
+ auth: ManifestAuthConfig;
96
+ serverSideLogging?: ServerSideLoggingConfig;
97
+ contactTypes?: ContactTypeConfig[];
98
+ contactPageUrl?: string;
99
+ enableFallbackContactPageUrl?: boolean;
100
+ fallbackContactPageUrl?: string;
101
+ logPageUrl?: string;
102
+ canOpenLogPage?: boolean;
103
+ settings?: JsonValue[];
104
+ page?: PlatformPageConfig;
105
+ requestConfig?: JsonObject;
106
+ enableExtensionNumberLoggingSetting?: boolean;
107
+ trackSmsTypingDuration?: boolean;
108
+ rcAdditionalSubmission?: string[];
109
+ override?: JsonObject;
110
+ [key: string]: JsonValue | undefined;
111
+ }
112
+
113
+ export interface AppConnectManifest {
114
+ serverUrl?: string;
115
+ redirectUri?: string;
116
+ author?: AuthorInfo;
117
+ platforms: Record<string, PlatformManifest>;
118
+ version?: string;
119
+ [key: string]: JsonValue | undefined;
120
+ }
@@ -0,0 +1,15 @@
1
+ export type SequelizeLike = any;
2
+
3
+ export type SequelizeTransactionLike = any;
4
+
5
+ export type TableDescription = Record<string, unknown>;
6
+
7
+ export interface PostgresClientLike {
8
+ query(sql: string, params?: unknown[]): Promise<{ rows: any[] }>;
9
+ }
10
+
11
+ export interface MigrationLogger {
12
+ info?(message: string, context?: Record<string, unknown>): void;
13
+ warn?(message: string, context?: Record<string, unknown>): void;
14
+ error?(message: string, context?: Record<string, unknown>): void;
15
+ }
@@ -0,0 +1,74 @@
1
+ import type { JsonObject } from './json';
2
+ import type { PlatformManifest } from './manifest';
3
+
4
+ export type PluginAccess = 'public' | 'private' | 'shared' | (string & {});
5
+
6
+ export type PluginLogType = 'call' | 'sms' | 'fax' | (string & {});
7
+
8
+ export interface PluginManifest extends PlatformManifest {
9
+ endpointUrl: string;
10
+ supportedLogTypes: PluginLogType[];
11
+ isAsync?: boolean;
12
+ tokenSyncUrl?: string;
13
+ userRegisterEndpointUrl?: string;
14
+ licenseStatusUrl?: string;
15
+ jwtToken?: string;
16
+ phase?: string;
17
+ access?: PluginAccess;
18
+ }
19
+
20
+ export interface InstalledPlugin {
21
+ id: string;
22
+ data: PluginManifest;
23
+ }
24
+
25
+ export interface AsyncPluginTaskData {
26
+ type: 'asyncPluginTask';
27
+ asyncTaskId: string;
28
+ callbackUrl: string;
29
+ pluginId: string;
30
+ platform: string;
31
+ logType: PluginLogType;
32
+ operation: string;
33
+ userId: string | number;
34
+ rcAccountId?: string | number;
35
+ sessionId?: string;
36
+ extensionNumber?: string;
37
+ hashedExtensionId?: string;
38
+ callLogId?: string | number;
39
+ thirdPartyLogId?: string | number;
40
+ contactId?: string | number;
41
+ incomingData: unknown;
42
+ hashedAccountId?: string;
43
+ isFromSSCL?: boolean;
44
+ [key: string]: unknown;
45
+ }
46
+
47
+ export interface PluginInvocationBody {
48
+ data: unknown;
49
+ config?: JsonObject | null;
50
+ asyncTaskId?: string;
51
+ callbackUrl?: string;
52
+ hashedExtensionId?: string;
53
+ }
54
+
55
+ export interface PluginLicenseStatus {
56
+ licenseStatus: boolean;
57
+ licenseStatusDescription?: string;
58
+ [key: string]: unknown;
59
+ }
60
+
61
+ export interface ResolvePluginManifestResult {
62
+ pluginData: {
63
+ platforms?: Record<string, PluginManifest>;
64
+ [key: string]: unknown;
65
+ };
66
+ pluginManifest: PluginManifest;
67
+ platformKey: string;
68
+ }
69
+
70
+ export interface RegisterPluginAccountResult {
71
+ successful: true;
72
+ registerUrl: string;
73
+ jwtToken: string;
74
+ }
@@ -0,0 +1,61 @@
1
+ export interface RingCentralOptions {
2
+ server: string;
3
+ clientId: string;
4
+ clientSecret: string;
5
+ redirectUri: string;
6
+ }
7
+
8
+ export interface RingCentralToken {
9
+ access_token?: string;
10
+ refresh_token?: string;
11
+ token_type?: string;
12
+ expires_in?: string | number;
13
+ refresh_token_expires_in?: string | number;
14
+ expire_time?: number;
15
+ refresh_token_expire_time?: number;
16
+ [key: string]: unknown;
17
+ }
18
+
19
+ export interface RingCentralLoginUrlParams {
20
+ state?: string;
21
+ }
22
+
23
+ export interface RingCentralGenerateTokenParams {
24
+ code: string;
25
+ }
26
+
27
+ export interface RingCentralRequestOptions {
28
+ server?: string;
29
+ path: string;
30
+ query?: Record<string, any>;
31
+ body?: unknown;
32
+ method: string;
33
+ accept?: string;
34
+ }
35
+
36
+ export interface RingCentralFetchResponse {
37
+ status: string | number;
38
+ json(): Promise<any>;
39
+ text(): Promise<string>;
40
+ [key: string]: unknown;
41
+ }
42
+
43
+ export interface RingCentralSubscriptionParams {
44
+ eventFilters: string[];
45
+ webhookUri: string;
46
+ }
47
+
48
+ export interface RingCentralCallsAggregationParams {
49
+ token: RingCentralToken;
50
+ timezone: string;
51
+ timeFrom: string;
52
+ timeTo: string;
53
+ groupBy: string;
54
+ }
55
+
56
+ export interface RingCentralPaginatedDataParams {
57
+ extensionId?: string | number;
58
+ token: RingCentralToken;
59
+ timeFrom: string;
60
+ timeTo: string;
61
+ }
@@ -0,0 +1,16 @@
1
+ export interface S3ErrorLogMetadata {
2
+ [key: string]: string | number | boolean | undefined;
3
+ }
4
+
5
+ export interface UploadUrlParams {
6
+ userId: string;
7
+ platform: string;
8
+ metadata?: S3ErrorLogMetadata;
9
+ }
10
+
11
+ export interface AwsSdkErrorLike extends Error {
12
+ $metadata?: {
13
+ httpStatusCode?: number;
14
+ [key: string]: unknown;
15
+ };
16
+ }
@@ -0,0 +1,105 @@
1
+ export type SharedSMSLogFormat = 'text/plain' | 'text/html' | 'text/markdown' | (string & {});
2
+
3
+ export interface SharedSMSNamedParty {
4
+ name?: string;
5
+ [key: string]: unknown;
6
+ }
7
+
8
+ export interface SharedSMSEntity {
9
+ recordType?: string;
10
+ creationTime?: any;
11
+ direction?: string;
12
+ author?: SharedSMSNamedParty;
13
+ from?: SharedSMSNamedParty | null;
14
+ initiator?: SharedSMSNamedParty;
15
+ assignee?: SharedSMSNamedParty;
16
+ text?: string;
17
+ subject?: string;
18
+ body?: string;
19
+ [key: string]: unknown;
20
+ }
21
+
22
+ export interface SharedSMSMessage {
23
+ lastModifiedTime?: any;
24
+ [key: string]: unknown;
25
+ }
26
+
27
+ export interface SharedSMSOwner {
28
+ name?: string;
29
+ extensionType?: string;
30
+ extensionId?: string | number;
31
+ [key: string]: unknown;
32
+ }
33
+
34
+ export interface SharedSMSConversation {
35
+ creationTime?: any;
36
+ messages: SharedSMSMessage[];
37
+ entities?: SharedSMSEntity[];
38
+ owner?: SharedSMSOwner;
39
+ [key: string]: unknown;
40
+ }
41
+
42
+ export interface ComposeSharedSMSLogParams {
43
+ logFormat?: SharedSMSLogFormat;
44
+ conversation: SharedSMSConversation;
45
+ contactName: string;
46
+ timezoneOffset?: string | number;
47
+ }
48
+
49
+ export interface SharedSMSLogContent {
50
+ subject: string;
51
+ body: string;
52
+ }
53
+
54
+ export interface SharedSMSOwnerInfo {
55
+ type: 'callQueue' | 'user';
56
+ name: string;
57
+ extensionId?: string | number;
58
+ }
59
+
60
+ export interface SharedSMSEntityCounts {
61
+ messageCount: number;
62
+ noteCount: number;
63
+ }
64
+
65
+ export interface SharedSMSProcessedEntry {
66
+ type: string;
67
+ creationTime: any;
68
+ content: string;
69
+ }
70
+
71
+ export interface ComposeSharedSMSBodyParams extends ComposeSharedSMSLogParams {
72
+ conversationCreatedDate: any;
73
+ conversationUpdatedDate: any;
74
+ logFormat: SharedSMSLogFormat;
75
+ }
76
+
77
+ export interface ProcessSharedSMSEntitiesParams {
78
+ entities: SharedSMSEntity[];
79
+ timezoneOffset?: string | number;
80
+ logFormat: SharedSMSLogFormat;
81
+ contactName: string;
82
+ }
83
+
84
+ export interface ProcessSharedSMSEntityParams extends Omit<ProcessSharedSMSEntitiesParams, 'entities'> {
85
+ entity: SharedSMSEntity;
86
+ }
87
+
88
+ export interface FormatSharedSMSEntryParams {
89
+ entity: SharedSMSEntity;
90
+ formattedTime: string;
91
+ creationTime: any;
92
+ logFormat: SharedSMSLogFormat;
93
+ contactName?: string;
94
+ }
95
+
96
+ export interface ComposeSharedSMSFormattedBodyParams {
97
+ conversationCreatedDate: any;
98
+ conversationUpdatedDate: any;
99
+ contactName: string;
100
+ agents: string[];
101
+ ownerInfo: SharedSMSOwnerInfo | null;
102
+ messageCount: number;
103
+ noteCount: number;
104
+ formattedEntries: SharedSMSProcessedEntry[];
105
+ }
@@ -0,0 +1,46 @@
1
+ import type { ReturnMessage, UserSettings } from './common';
2
+
3
+ export interface TraceLogger {
4
+ trace(event: string, data?: unknown): void;
5
+ traceError(event: string, error: unknown, data?: unknown): void;
6
+ }
7
+
8
+ export interface RefreshUserInfoParams {
9
+ platform: string;
10
+ userId: string | number;
11
+ tracer?: TraceLogger;
12
+ }
13
+
14
+ export interface HandlerResult {
15
+ successful?: boolean;
16
+ returnMessage?: ReturnMessage;
17
+ isRevokeUserSession?: boolean;
18
+ [key: string]: unknown;
19
+ }
20
+
21
+ export interface UserSettingsByAdminParams {
22
+ rcAccessToken?: string;
23
+ rcAccountId?: string | number | null;
24
+ }
25
+
26
+ export interface UserSettingsByAdminResult {
27
+ userSettings?: UserSettings;
28
+ }
29
+
30
+ export interface GetUserSettingsParams extends UserSettingsByAdminParams {
31
+ user?: {
32
+ userSettings?: UserSettings;
33
+ [key: string]: unknown;
34
+ } | null;
35
+ }
36
+
37
+ export interface UpdateUserSettingsParams {
38
+ user: {
39
+ userSettings?: UserSettings;
40
+ update(values: { userSettings: UserSettings }): Promise<unknown>;
41
+ [key: string]: unknown;
42
+ };
43
+ userSettings?: UserSettings;
44
+ settingKeysToRemove: string[];
45
+ platformName: string;
46
+ }
@@ -0,0 +1,7 @@
1
+ export interface MostRecentDateParams {
2
+ allDateValues: Array<number | null | undefined>;
3
+ }
4
+
5
+ export type SecondsInput = any;
6
+
7
+ export type MediaLinkInput = string | null | undefined;
package/package.json CHANGED
@@ -1,8 +1,28 @@
1
1
  {
2
2
  "name": "@app-connect/core",
3
- "version": "1.7.37",
3
+ "version": "1.7.38",
4
4
  "description": "RingCentral App Connect Core",
5
- "main": "index.js",
5
+ "main": "dist/index.js",
6
+ "types": "dist/types/index.d.ts",
7
+ "exports": {
8
+ ".": {
9
+ "types": "./dist/types/index.d.ts",
10
+ "require": "./dist/index.js",
11
+ "default": "./dist/index.js"
12
+ },
13
+ "./package.json": "./package.json",
14
+ "./types": {
15
+ "types": "./dist/types/index.d.ts"
16
+ },
17
+ "./types/*": {
18
+ "types": "./dist/types/*.d.ts"
19
+ },
20
+ "./*": {
21
+ "types": "./dist/*.d.ts",
22
+ "require": "./dist/*.js",
23
+ "default": "./dist/*.js"
24
+ }
25
+ },
6
26
  "repository": {
7
27
  "type": "git",
8
28
  "url": "git+https://github.com/ringcentral/rc-unified-crm-extension.git"
@@ -11,6 +31,11 @@
11
31
  "RingCentral",
12
32
  "App Connect"
13
33
  ],
34
+ "files": [
35
+ "dist",
36
+ "README.md",
37
+ "releaseNotes.json"
38
+ ],
14
39
  "author": "RingCentral Labs",
15
40
  "license": "MIT",
16
41
  "peerDependencies": {
@@ -26,6 +51,7 @@
26
51
  "@aws-sdk/client-s3": "^3.947.0",
27
52
  "@aws-sdk/s3-request-presigner": "^3.947.0",
28
53
  "@modelcontextprotocol/sdk": "^1.26.0",
54
+ "@types/express": "^4.17.25",
29
55
  "awesome-phonenumber": "^5.6.0",
30
56
  "body-parser": "^1.20.4",
31
57
  "body-parser-xml": "^2.0.5",
@@ -41,10 +67,12 @@
41
67
  "ua-parser-js": "^1.0.38"
42
68
  },
43
69
  "scripts": {
44
- "test": "jest",
45
- "test:watch": "jest --watch",
46
- "test:coverage": "jest --coverage",
47
- "test:ci": "jest --ci --coverage --watchAll=false"
70
+ "test": "cd ../.. && npm run build:ts && cd packages/core && npm run test:raw",
71
+ "test:raw": "jest --config ../../.ts-build/packages/core/jest.config.js",
72
+ "test:watch": "cd ../.. && npm run build:ts && cd packages/core && jest --config ../../.ts-build/packages/core/jest.config.js --watch",
73
+ "test:coverage": "cd ../.. && npm run build:ts && cd packages/core && jest --config ../../.ts-build/packages/core/jest.config.js --coverage",
74
+ "test:ci": "cd ../.. && npm run build:ts && cd packages/core && jest --config ../../.ts-build/packages/core/jest.config.js --ci --coverage --watchAll=false",
75
+ "prepack": "cd ../.. && npm run build:ts"
48
76
  },
49
77
  "devDependencies": {
50
78
  "@eslint/js": "^9.22.0",
package/releaseNotes.json CHANGED
@@ -1,4 +1,12 @@
1
1
  {
2
+ "1.7.38": {
3
+ "global": [
4
+ {
5
+ "type": "Fix",
6
+ "description": "Security patches"
7
+ }
8
+ ]
9
+ },
2
10
  "1.7.37": {
3
11
  "global": [
4
12
  {
package/.env.test DELETED
@@ -1,5 +0,0 @@
1
- NODE_ENV=test
2
- APP_SERVER_SECRET_KEY='test-secret-key'
3
- HASH_KEY='test-hash-key'
4
- DISABLE_SYNC_DB_TABLE='true'
5
- DATABASE_URL='sqlite::memory:'
@@ -1,165 +0,0 @@
1
- const axios = require('axios');
2
-
3
- function getByPath(obj, path) {
4
- if (!path || path === '$') return obj;
5
- const parts = path.split('.');
6
- let cur = obj;
7
- for (const p of parts) {
8
- if (cur == null) return undefined;
9
- cur = cur[p];
10
- }
11
- return cur;
12
- }
13
-
14
- function renderTemplateString(template, context) {
15
- if (typeof template !== 'string') return template;
16
- // if only template value, return value with stringify
17
- const onlyVarName = template.match(/^\{\{\s*([^}]+?)\s*\}\}$/);
18
- if (onlyVarName) {
19
- return getByPath(context, onlyVarName[1]);
20
- }
21
- return template.replace(/\{\{\s*([^}]+?)\s*\}\}/g, (_, expr) => {
22
- const value = getByPath(context, expr.trim());
23
- return value == null ? '' : String(value);
24
- });
25
- }
26
-
27
- function renderDeep(input, context) {
28
- if (input == null) return input;
29
- if (typeof input === 'string') return renderTemplateString(input, context);
30
- if (Array.isArray(input)) return input.map(v => renderDeep(v, context));
31
- if (typeof input === 'object') {
32
- const out = {};
33
- for (const [k, v] of Object.entries(input)) {
34
- out[k] = renderDeep(v, context);
35
- }
36
- return out;
37
- }
38
- return input;
39
- }
40
-
41
- function joinUrl(baseUrl, path) {
42
- if (!baseUrl) return path;
43
- if (!path) return baseUrl;
44
- if (path.startsWith('http://') || path.startsWith('https://')) return path;
45
- return `${baseUrl.replace(/\/$/, '')}/${path.replace(/^\//, '')}`;
46
- }
47
-
48
- function getAuthHeaderFromAuthConfig({ auth, context, authHeader }) {
49
- const authHeaders = {};
50
- const headerName = auth?.headerName || 'Authorization';
51
- if (auth && auth.credentialTemplate) {
52
- const credentials = renderTemplateString(auth.credentialTemplate, context);
53
- const encode = auth.encode === 'none' ? false : true;
54
- const token = encode ? Buffer.from(credentials).toString('base64') : credentials;
55
- authHeaders[headerName] = auth.scheme ? `${auth.scheme} ${token}` : token;
56
- } else if (authHeader) {
57
- authHeaders[headerName] = authHeader;
58
- } else if (auth && auth.type === 'oauth' && context.user) {
59
- authHeaders[headerName] = `${auth.scheme || 'Bearer'} ${context.user.accessToken}`;
60
- }
61
- return authHeaders;
62
- }
63
-
64
- function buildHeaders({ config, operation, authHeader, context }) {
65
- const headers = renderDeep(Object.assign({}, config.requestDefaults?.defaultHeaders || {}), context);
66
- const renderedOpHeaders = renderDeep(operation?.headers || {}, context);
67
- for (const [k, v] of Object.entries(renderedOpHeaders)) headers[k] = v;
68
-
69
- // Per-operation auth override
70
- const authHeaders = getAuthHeaderFromAuthConfig({
71
- auth: operation?.auth || config.auth,
72
- context,
73
- authHeader
74
- });
75
- for (const [k, v] of Object.entries(authHeaders)) headers[k] = v;
76
- return headers;
77
- }
78
-
79
- async function performRequest({ config, opName, inputs, user, authHeader }) {
80
- const op = config.operations?.[opName];
81
- if (!op) return null;
82
- const accessToken = user?.accessToken ?? inputs?.apiKey ?? '';
83
- const context = Object.assign({}, inputs, {
84
- user: user ? {
85
- accessToken,
86
- id: user.id?.split('-')[0],
87
- hostname: user.hostname,
88
- timezoneName: user.timezoneName,
89
- timezoneOffset: user.timezoneOffset,
90
- platform: user.platform,
91
- platformAdditionalInfo: user.platformAdditionalInfo,
92
- refreshToken: user.refreshToken,
93
- tokenExpiry: user.tokenExpiry,
94
- } : {
95
- accessToken,
96
- },
97
- authHeader,
98
- apiKey: accessToken,
99
- secretKey: config.secretKey,
100
- });
101
- const url = joinUrl(config.requestDefaults?.baseUrl, renderTemplateString(op.url, context));
102
- const method = (op.method || 'GET').toUpperCase();
103
- const headers = buildHeaders({ config, operation: op, authHeader, context });
104
- const params = renderDeep(op.query || {}, context);
105
- const data = renderDeep(op.body || {}, context);
106
- const timeout = (config.requestDefaults?.timeoutSeconds || 30) * 1000;
107
- const axiosParams = { url, method, headers, params, data, timeout };
108
- const response = await axios(axiosParams);
109
- return response;
110
- }
111
-
112
- function mapFindContactResponse({ config, response, opName = 'findContact' }) {
113
- const map = config.operations?.[opName]?.responseMapping;
114
- if (!map) return [];
115
- const __ctx = { body: response.data };
116
- const list = getByPath(__ctx, map.listPath || 'body') || [];
117
- const itemMap = map.item || {};
118
- return list.map(it => {
119
- return {
120
- id: getByPath(it, itemMap.idPath || 'id'),
121
- name: getByPath(it, itemMap.namePath || 'name') || '',
122
- phone: getByPath(it, itemMap.phonePath || 'phone') || undefined,
123
- type: getByPath(it, itemMap.typePath || 'type') || 'Contact',
124
- title: getByPath(it, itemMap.titlePath || 'title') || "",
125
- company: getByPath(it, itemMap.companyPath || 'company') || "",
126
- createdDate: getByPath(it, itemMap.createdDatePath || 'createdDate') || undefined,
127
- mostRecentActivityDate: getByPath(it, itemMap.mostRecentActivityDatePath || 'mostRecentActivityDate') || undefined,
128
- additionalInfo: getByPath(it, itemMap.additionalInfoPath || 'additionalInfo') || null
129
- };
130
- });
131
- }
132
-
133
- function mapCreateCallLogResponse({ config, response }) {
134
- const map = config.operations?.createCallLog?.responseMapping;
135
- if (!map) return { logId: undefined };
136
- const __ctx = { body: response.data };
137
- const logId = getByPath(__ctx, map.idPath || 'body.id');
138
-
139
- return { logId: logId ? String(logId) : undefined };
140
- }
141
-
142
- function mapGetCallLogResponse({ config, response }) {
143
- const map = config.operations?.getCallLog?.responseMapping || {};
144
- const __ctx = { body: response.data };
145
- const subject = getByPath(__ctx, map.subjectPath || 'body.subject');
146
- const note = getByPath(__ctx, map.notePath || 'body.note');
147
- const fullBody = getByPath(__ctx, map.fullBodyPath || 'body.note');
148
- const fullLogResponse = response.data;
149
- return {
150
- callLogInfo: { subject, note, fullBody, fullLogResponse }
151
- };
152
- }
153
-
154
- module.exports = {
155
- getByPath,
156
- renderTemplateString,
157
- renderDeep,
158
- joinUrl,
159
- performRequest,
160
- mapFindContactResponse,
161
- mapCreateCallLogResponse,
162
- mapGetCallLogResponse
163
- };
164
-
165
-