@app-connect/core 1.7.36 → 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 (287) 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} +548 -450
  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/dist/lib/migrateCallLogsSchema.js +339 -0
  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 +13 -1
  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/migrateCallLogsSchema.js +0 -237
  198. package/lib/ringcentral.js +0 -267
  199. package/mcp/README.md +0 -420
  200. package/mcp/tools/index.js +0 -51
  201. package/mcp/ui/App/App.tsx +0 -358
  202. package/mcp/ui/App/components/AuthInfoForm.tsx +0 -113
  203. package/mcp/ui/App/components/AuthSuccess.tsx +0 -22
  204. package/mcp/ui/App/components/ConnectorList.tsx +0 -82
  205. package/mcp/ui/App/components/DebugPanel.tsx +0 -43
  206. package/mcp/ui/App/components/OAuthConnect.tsx +0 -270
  207. package/mcp/ui/App/lib/callTool.ts +0 -130
  208. package/mcp/ui/App/lib/debugLog.ts +0 -41
  209. package/mcp/ui/App/lib/developerPortal.ts +0 -111
  210. package/mcp/ui/App/main.css +0 -6
  211. package/mcp/ui/App/root.tsx +0 -13
  212. package/mcp/ui/dist/index.html +0 -53
  213. package/mcp/ui/vite.config.ts +0 -16
  214. package/models/accountDataModel.js +0 -34
  215. package/models/adminConfigModel.js +0 -35
  216. package/models/callLogModel.js +0 -39
  217. package/models/dynamo/connectorSchema.js +0 -146
  218. package/models/llmSessionModel.js +0 -17
  219. package/models/sequelize.js +0 -17
  220. package/models/userModel.js +0 -45
  221. package/test/connector/developerPortal.test.js +0 -166
  222. package/test/connector/mock.test.js +0 -131
  223. package/test/connector/proxy/engine.test.js +0 -211
  224. package/test/connector/proxy/index.test.js +0 -525
  225. package/test/connector/proxy/sample.json +0 -162
  226. package/test/connector/registry.test.js +0 -416
  227. package/test/handlers/admin.test.js +0 -960
  228. package/test/handlers/appointment.test.js +0 -260
  229. package/test/handlers/auth.test.js +0 -1096
  230. package/test/handlers/calldown.test.js +0 -310
  231. package/test/handlers/contact.test.js +0 -1014
  232. package/test/handlers/disposition.test.js +0 -396
  233. package/test/handlers/log.test.js +0 -1847
  234. package/test/handlers/managedAuth.test.js +0 -458
  235. package/test/handlers/managedOAuth.test.js +0 -262
  236. package/test/handlers/plugin.test.js +0 -429
  237. package/test/handlers/user.test.js +0 -381
  238. package/test/index.test.js +0 -301
  239. package/test/lib/analytics.test.js +0 -146
  240. package/test/lib/authSession.test.js +0 -173
  241. package/test/lib/cacheCleanup.test.js +0 -127
  242. package/test/lib/callLogComposer.test.js +0 -1231
  243. package/test/lib/debugTracer.test.js +0 -328
  244. package/test/lib/encode.test.js +0 -59
  245. package/test/lib/errorHandler.test.js +0 -246
  246. package/test/lib/generalErrorMessage.test.js +0 -82
  247. package/test/lib/jwt.test.js +0 -176
  248. package/test/lib/logger.test.js +0 -206
  249. package/test/lib/oauth.test.js +0 -359
  250. package/test/lib/ringcentral.test.js +0 -467
  251. package/test/lib/s3ErrorLogReport.test.js +0 -187
  252. package/test/lib/sharedSMSComposer.test.js +0 -1084
  253. package/test/lib/util.test.js +0 -329
  254. package/test/mcp/mcpHandler.test.js +0 -73
  255. package/test/mcp/mcpHandlerMore.test.js +0 -384
  256. package/test/mcp/tools/appointmentTools.test.js +0 -362
  257. package/test/mcp/tools/checkAuthStatus.test.js +0 -83
  258. package/test/mcp/tools/createCallLog.test.js +0 -436
  259. package/test/mcp/tools/createContact.test.js +0 -58
  260. package/test/mcp/tools/createMessageLog.test.js +0 -595
  261. package/test/mcp/tools/doAuth.test.js +0 -113
  262. package/test/mcp/tools/findContactByName.test.js +0 -275
  263. package/test/mcp/tools/findContactByPhone.test.js +0 -296
  264. package/test/mcp/tools/getCallLog.test.js +0 -298
  265. package/test/mcp/tools/getGoogleFilePicker.test.js +0 -281
  266. package/test/mcp/tools/getPublicConnectors.test.js +0 -107
  267. package/test/mcp/tools/getSessionInfo.test.js +0 -127
  268. package/test/mcp/tools/logout.test.js +0 -233
  269. package/test/mcp/tools/rcGetCallLogs.test.js +0 -56
  270. package/test/mcp/tools/updateCallLog.test.js +0 -360
  271. package/test/models/accountDataModel.test.js +0 -98
  272. package/test/models/callDownListModel.test.js +0 -125
  273. package/test/models/dynamo/connectorSchema.test.js +0 -189
  274. package/test/models/dynamo/lockSchema.test.js +0 -37
  275. package/test/models/dynamo/noteCacheSchema.test.js +0 -45
  276. package/test/models/llmSessionModel.test.js +0 -91
  277. package/test/models/models.test.js +0 -660
  278. package/test/routes/calldownRoutes.test.js +0 -224
  279. package/test/routes/coreRouterBroadRoutes.test.js +0 -855
  280. package/test/routes/dispositionRoutes.test.js +0 -192
  281. package/test/routes/managedAuthRoutes.test.js +0 -386
  282. package/test/routes/pluginRoutes.test.js +0 -262
  283. package/test/setup.js +0 -178
  284. /package/{mcp → dist/mcp}/ui/index.html +0 -0
  285. /package/{mcp → dist/mcp}/ui/package-lock.json +0 -0
  286. /package/{mcp → dist/mcp}/ui/package.json +0 -0
  287. /package/{mcp → dist/mcp}/ui/tsconfig.json +0 -0
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+ // @ts-check
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ const path = require('path');
5
+ function getCoreRoot() {
6
+ const maybeBuildRoot = path.resolve(__dirname, '..', '..');
7
+ if (path.basename(maybeBuildRoot) === '.ts-build') {
8
+ return path.resolve(maybeBuildRoot, '..', 'packages', 'core');
9
+ }
10
+ return __dirname;
11
+ }
12
+ const CORE_ROOT = getCoreRoot();
13
+ module.exports = {
14
+ rootDir: CORE_ROOT,
15
+ // Test environment
16
+ testEnvironment: 'node',
17
+ moduleFileExtensions: ['js', 'json', 'node', 'ts'],
18
+ transform: {
19
+ '^.+\\.js$': 'babel-jest',
20
+ '^.+\\.ts$': '<rootDir>/../../.ts-build/scripts/jestTsTransformer.js'
21
+ },
22
+ // Test file patterns
23
+ testMatch: [
24
+ '<rootDir>/test/**/*.test.ts',
25
+ '<rootDir>/**/*.test.ts'
26
+ ],
27
+ // Setup files
28
+ setupFilesAfterEnv: [
29
+ '<rootDir>/test/setup.ts'
30
+ ],
31
+ // Coverage configuration
32
+ collectCoverage: true,
33
+ coverageDirectory: '<rootDir>/coverage',
34
+ coverageReporters: ['text', 'lcov', 'html'],
35
+ coveragePathIgnorePatterns: [
36
+ '/node_modules/',
37
+ '/test/',
38
+ '/coverage/',
39
+ 'jest.config.js',
40
+ 'setup.ts'
41
+ ],
42
+ // Module resolution
43
+ moduleDirectories: ['node_modules', '<rootDir>'],
44
+ moduleNameMapper: {
45
+ '^@app-connect/core$': '<rootDir>/index',
46
+ '^@app-connect/core/(.*)$': '<rootDir>/$1'
47
+ },
48
+ // Test timeout
49
+ testTimeout: 30000,
50
+ // Reporters
51
+ reporters: ['default'],
52
+ // Ignore patterns
53
+ modulePathIgnorePatterns: [
54
+ '<rootDir>/node_modules/',
55
+ '<rootDir>/coverage/',
56
+ '<rootDir>/dist/',
57
+ '<rootDir>/test-results/'
58
+ ],
59
+ // Clear mocks between tests
60
+ clearMocks: true,
61
+ // Restore mocks between tests
62
+ restoreMocks: true,
63
+ // Verbose output
64
+ verbose: true
65
+ };
@@ -0,0 +1,4 @@
1
+ import type { AnalyticsTrackParams } from '../types';
2
+ declare function init(): void;
3
+ declare function track({ eventName, interfaceName, connectorName, accountId, extensionId, success, requestDuration, userAgent, ip, author, eventAddedVia, extras }: AnalyticsTrackParams): void;
4
+ export { init, track };
@@ -1,7 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.init = init;
4
+ exports.track = track;
1
5
  const Mixpanel = require('mixpanel');
2
6
  const parser = require('ua-parser-js');
3
7
  const logger = require('./logger');
4
- let packageJson = null;
8
+ let packageJson;
5
9
  try {
6
10
  packageJson = require('../package.json');
7
11
  }
@@ -13,15 +17,13 @@ const appName = 'App Connect';
13
17
  const defaultEventAddedVia = 'server';
14
18
  const version = packageJson.version;
15
19
  let mixpanel = null;
16
-
17
- exports.init = function init() {
20
+ function init() {
18
21
  if (!process.env.MIXPANEL_TOKEN) {
19
22
  return;
20
23
  }
21
24
  mixpanel = Mixpanel.init(process.env.MIXPANEL_TOKEN);
22
25
  }
23
-
24
- exports.track = function track({ eventName, interfaceName, connectorName, accountId, extensionId, success, requestDuration, userAgent, ip, author, eventAddedVia, extras = null }) {
26
+ function track({ eventName, interfaceName, connectorName, accountId, extensionId, success, requestDuration, userAgent, ip, author, eventAddedVia, extras = null }) {
25
27
  if (!mixpanel || !extensionId) {
26
28
  return;
27
29
  }
@@ -52,4 +54,4 @@ exports.track = function track({ eventName, interfaceName, connectorName, accoun
52
54
  ...extras
53
55
  });
54
56
  logger.info(`Event: ${eventName}`);
55
- }
57
+ }
@@ -0,0 +1,5 @@
1
+ import type { AuthSessionCreateData, AuthSessionResult, AuthSessionUpdateData } from '../types';
2
+ declare function createAuthSession(sessionId: string, data: AuthSessionCreateData): Promise<void>;
3
+ declare function getAuthSession(sessionId: string): Promise<AuthSessionResult | null>;
4
+ declare function updateAuthSession(sessionId: string, data: AuthSessionUpdateData): Promise<void>;
5
+ export { createAuthSession, getAuthSession, updateAuthSession };
@@ -1,46 +1,36 @@
1
- /**
2
- * Auth Session Helper
3
- *
4
- * Helper functions for managing OAuth auth sessions using CacheModel
5
- */
6
-
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createAuthSession = createAuthSession;
4
+ exports.getAuthSession = getAuthSession;
5
+ exports.updateAuthSession = updateAuthSession;
7
6
  const { CacheModel } = require('../models/cacheModel');
8
-
9
7
  const AUTH_SESSION_PREFIX = 'auth-session';
10
8
  const PENDING_SESSION_EXPIRY_MINUTES = 5;
11
9
  const SETTLED_SESSION_EXPIRY_MINUTES = 15;
12
-
13
10
  function getSessionRecordId(sessionId) {
14
11
  return `${AUTH_SESSION_PREFIX}-${sessionId}`;
15
12
  }
16
-
17
13
  function getExpiry(minutes) {
18
14
  return new Date(Date.now() + minutes * 60 * 1000);
19
15
  }
20
-
21
16
  function isExpired(record) {
22
17
  return Boolean(record?.expiry && record.expiry <= new Date());
23
18
  }
24
-
25
- /**
26
- * Create (or reset) an auth session.
27
- * If a record already exists for the sessionId (e.g., user retries auth within
28
- * the same ChatGPT conversation), it is reset to 'pending' so polling works
29
- * correctly for the new attempt.
30
- */
31
19
  async function createAuthSession(sessionId, data) {
32
20
  const id = getSessionRecordId(sessionId);
33
21
  const expiry = getExpiry(PENDING_SESSION_EXPIRY_MINUTES);
34
22
  const sessionData = {
35
23
  platform: data.platform,
36
24
  hostname: data.hostname || '',
25
+ rcExtensionId: data.rcExtensionId,
26
+ openaiSessionId: data.openaiSessionId,
37
27
  createdAt: new Date().toISOString(),
38
28
  };
39
-
40
29
  const existing = await CacheModel.findByPk(id);
41
30
  if (existing) {
42
31
  await existing.update({ status: 'pending', data: sessionData, expiry });
43
- } else {
32
+ }
33
+ else {
44
34
  await CacheModel.create({
45
35
  id,
46
36
  cacheKey: AUTH_SESSION_PREFIX,
@@ -51,15 +41,10 @@ async function createAuthSession(sessionId, data) {
51
41
  });
52
42
  }
53
43
  }
54
-
55
- /**
56
- * Get an auth session by ID
57
- */
58
44
  async function getAuthSession(sessionId) {
59
45
  const record = await CacheModel.findByPk(getSessionRecordId(sessionId));
60
-
61
- if (!record) return null;
62
-
46
+ if (!record)
47
+ return null;
63
48
  if (isExpired(record)) {
64
49
  if (record.status !== 'expired') {
65
50
  await record.update({ status: 'expired' });
@@ -67,25 +52,19 @@ async function getAuthSession(sessionId) {
67
52
  return {
68
53
  sessionId: record.userId,
69
54
  status: 'expired',
70
- ...record.data
55
+ ...(record.data || {})
71
56
  };
72
57
  }
73
-
74
58
  return {
75
59
  sessionId: record.userId,
76
60
  status: record.status,
77
- ...record.data
61
+ ...(record.data || {})
78
62
  };
79
63
  }
80
-
81
- /**
82
- * Update an auth session
83
- */
84
64
  async function updateAuthSession(sessionId, data) {
85
65
  const record = await CacheModel.findByPk(getSessionRecordId(sessionId));
86
-
87
- if (!record) return;
88
-
66
+ if (!record)
67
+ return;
89
68
  const existingData = record.data || {};
90
69
  const nextStatus = data.status || record.status;
91
70
  await record.update({
@@ -100,10 +79,3 @@ async function updateAuthSession(sessionId, data) {
100
79
  : getExpiry(SETTLED_SESSION_EXPIRY_MINUTES)
101
80
  });
102
81
  }
103
-
104
- module.exports = {
105
- createAuthSession,
106
- getAuthSession,
107
- updateAuthSession
108
- };
109
-
@@ -0,0 +1,4 @@
1
+ import type { AccountContactCleanupOptions, CacheCleanupOptions } from '../types';
2
+ declare function clearExpiredCache({ now }?: CacheCleanupOptions): Promise<number>;
3
+ declare function clearExpiredAccountContactData({ now, retentionMonths }?: AccountContactCleanupOptions): Promise<number>;
4
+ export { clearExpiredAccountContactData, clearExpiredCache };
@@ -1,31 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.clearExpiredAccountContactData = clearExpiredAccountContactData;
4
+ exports.clearExpiredCache = clearExpiredCache;
1
5
  const { Op } = require('sequelize');
2
6
  const { CacheModel } = require('../models/cacheModel');
3
7
  const { AccountDataModel } = require('../models/accountDataModel');
4
8
  const logger = require('./logger');
5
-
6
9
  const ACCOUNT_CONTACT_DATA_KEY_PATTERN = 'contact-%';
7
10
  const ACCOUNT_CONTACT_DATA_RETENTION_MONTHS = 3;
8
-
9
11
  async function clearExpiredCache({ now = new Date() } = {}) {
10
12
  const cacheDeletedCount = await clearExpiredCacheRows({ now });
11
13
  const accountContactDataDeletedCount = await clearExpiredAccountContactData({ now });
12
14
  const deletedCount = cacheDeletedCount + accountContactDataDeletedCount;
13
-
14
15
  logger.info('Expired cache cleanup completed', {
15
16
  deletedCount,
16
17
  cacheDeletedCount,
17
18
  accountContactDataDeletedCount
18
19
  });
19
-
20
20
  return deletedCount;
21
21
  }
22
-
23
22
  function getAccountContactDataCutoffDate({ now, retentionMonths }) {
24
23
  const cutoffDate = new Date(now.getTime());
25
24
  cutoffDate.setMonth(cutoffDate.getMonth() - retentionMonths);
26
25
  return cutoffDate;
27
26
  }
28
-
29
27
  async function clearExpiredCacheRows({ now }) {
30
28
  return CacheModel.destroy({
31
29
  where: {
@@ -35,13 +33,8 @@ async function clearExpiredCacheRows({ now }) {
35
33
  }
36
34
  });
37
35
  }
38
-
39
- async function clearExpiredAccountContactData({
40
- now = new Date(),
41
- retentionMonths = ACCOUNT_CONTACT_DATA_RETENTION_MONTHS
42
- } = {}) {
36
+ async function clearExpiredAccountContactData({ now = new Date(), retentionMonths = ACCOUNT_CONTACT_DATA_RETENTION_MONTHS } = {}) {
43
37
  const cutoffDate = getAccountContactDataCutoffDate({ now, retentionMonths });
44
-
45
38
  return AccountDataModel.destroy({
46
39
  where: {
47
40
  dataKey: {
@@ -53,8 +46,3 @@ async function clearExpiredAccountContactData({
53
46
  }
54
47
  });
55
48
  }
56
-
57
- module.exports = {
58
- clearExpiredAccountContactData,
59
- clearExpiredCache
60
- };
@@ -0,0 +1,109 @@
1
+ import type { ComposeCallLogParams } from '../types';
2
+ /**
3
+ * Centralized call log composition module
4
+ * Supports both plain text and HTML formats used across different CRM connectors
5
+ */
6
+ /**
7
+ * Compose call log details based on user settings and format type
8
+ * @param {ComposeCallLogParams} params - Composition parameters
9
+ * @returns {string} Composed log body
10
+ */
11
+ declare function composeCallLog(params: ComposeCallLogParams): string;
12
+ /**
13
+ * Upsert functions for different log components
14
+ */
15
+ declare function upsertCallAgentNote({ body, note, logFormat }: {
16
+ body: any;
17
+ note: any;
18
+ logFormat: any;
19
+ }): any;
20
+ declare function upsertCallSessionId({ body, id, logFormat }: {
21
+ body: any;
22
+ id: any;
23
+ logFormat: any;
24
+ }): any;
25
+ declare function upsertRingCentralUserName({ body, userName, logFormat }: {
26
+ body: any;
27
+ userName: any;
28
+ logFormat: any;
29
+ }): any;
30
+ declare function upsertRingCentralNumberAndExtension({ body, number, extension, logFormat }: {
31
+ body: any;
32
+ number: any;
33
+ extension: any;
34
+ logFormat: any;
35
+ }): any;
36
+ declare function upsertCallSubject({ body, subject, logFormat }: {
37
+ body: any;
38
+ subject: any;
39
+ logFormat: any;
40
+ }): any;
41
+ declare function upsertContactPhoneNumber({ body, phoneNumber, direction, logFormat }: {
42
+ body: any;
43
+ phoneNumber: any;
44
+ direction: any;
45
+ logFormat: any;
46
+ }): any;
47
+ declare function upsertCallDateTime({ body, startTime, timezoneOffset, logFormat, logDateFormat }: {
48
+ body: any;
49
+ startTime: any;
50
+ timezoneOffset: any;
51
+ logFormat: any;
52
+ logDateFormat: any;
53
+ }): any;
54
+ declare function upsertCallDuration({ body, duration, logFormat }: {
55
+ body: any;
56
+ duration: any;
57
+ logFormat: any;
58
+ }): any;
59
+ declare function upsertCallResult({ body, result, logFormat }: {
60
+ body: any;
61
+ result: any;
62
+ logFormat: any;
63
+ }): any;
64
+ declare function upsertCallRecording({ body, recordingLink, logFormat }: {
65
+ body: any;
66
+ recordingLink: any;
67
+ logFormat: any;
68
+ }): any;
69
+ declare function upsertAiNote({ body, aiNote, logFormat }: {
70
+ body: any;
71
+ aiNote: any;
72
+ logFormat: any;
73
+ }): any;
74
+ declare function upsertTranscript({ body, transcript, logFormat }: {
75
+ body: any;
76
+ transcript: any;
77
+ logFormat: any;
78
+ }): any;
79
+ declare function upsertLegs({ body, legs, logFormat }: {
80
+ body: any;
81
+ legs: any;
82
+ logFormat: any;
83
+ }): any;
84
+ declare function upsertRingSenseTranscript({ body, transcript, logFormat }: {
85
+ body: any;
86
+ transcript: any;
87
+ logFormat: any;
88
+ }): any;
89
+ declare function upsertRingSenseSummary({ body, summary, logFormat }: {
90
+ body: any;
91
+ summary: any;
92
+ logFormat: any;
93
+ }): any;
94
+ declare function upsertRingSenseAIScore({ body, score, logFormat }: {
95
+ body: any;
96
+ score: any;
97
+ logFormat: any;
98
+ }): any;
99
+ declare function upsertRingSenseBulletedSummary({ body, summary, logFormat }: {
100
+ body: any;
101
+ summary: any;
102
+ logFormat: any;
103
+ }): any;
104
+ declare function upsertRingSenseLink({ body, link, logFormat }: {
105
+ body: any;
106
+ link: any;
107
+ logFormat: any;
108
+ }): any;
109
+ export { composeCallLog, upsertCallAgentNote, upsertCallSessionId, upsertRingCentralUserName, upsertRingCentralNumberAndExtension, upsertCallSubject, upsertContactPhoneNumber, upsertCallDateTime, upsertCallDuration, upsertCallResult, upsertCallRecording, upsertAiNote, upsertTranscript, upsertLegs, upsertRingSenseTranscript, upsertRingSenseSummary, upsertRingSenseAIScore, upsertRingSenseBulletedSummary, upsertRingSenseLink, };