@app-connect/core 1.7.8 → 1.7.11

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 (69) hide show
  1. package/connector/developerPortal.js +43 -0
  2. package/connector/proxy/index.js +10 -3
  3. package/connector/registry.js +8 -6
  4. package/handlers/admin.js +44 -21
  5. package/handlers/auth.js +97 -69
  6. package/handlers/calldown.js +10 -4
  7. package/handlers/contact.js +45 -112
  8. package/handlers/disposition.js +4 -142
  9. package/handlers/log.js +174 -259
  10. package/handlers/user.js +19 -6
  11. package/index.js +310 -122
  12. package/lib/analytics.js +3 -1
  13. package/lib/authSession.js +68 -0
  14. package/lib/callLogComposer.js +498 -420
  15. package/lib/errorHandler.js +206 -0
  16. package/lib/jwt.js +2 -0
  17. package/lib/logger.js +190 -0
  18. package/lib/oauth.js +21 -12
  19. package/lib/ringcentral.js +2 -10
  20. package/lib/sharedSMSComposer.js +471 -0
  21. package/mcp/SupportedPlatforms.md +12 -0
  22. package/mcp/lib/validator.js +91 -0
  23. package/mcp/mcpHandler.js +166 -0
  24. package/mcp/tools/checkAuthStatus.js +90 -0
  25. package/mcp/tools/collectAuthInfo.js +86 -0
  26. package/mcp/tools/createCallLog.js +299 -0
  27. package/mcp/tools/createMessageLog.js +283 -0
  28. package/mcp/tools/doAuth.js +185 -0
  29. package/mcp/tools/findContactByName.js +87 -0
  30. package/mcp/tools/findContactByPhone.js +96 -0
  31. package/mcp/tools/getCallLog.js +98 -0
  32. package/mcp/tools/getHelp.js +39 -0
  33. package/mcp/tools/getPublicConnectors.js +46 -0
  34. package/mcp/tools/index.js +58 -0
  35. package/mcp/tools/logout.js +63 -0
  36. package/mcp/tools/rcGetCallLogs.js +73 -0
  37. package/mcp/tools/setConnector.js +64 -0
  38. package/mcp/tools/updateCallLog.js +122 -0
  39. package/models/accountDataModel.js +34 -0
  40. package/models/cacheModel.js +3 -0
  41. package/package.json +6 -4
  42. package/releaseNotes.json +36 -0
  43. package/test/connector/registry.test.js +145 -0
  44. package/test/handlers/admin.test.js +583 -0
  45. package/test/handlers/auth.test.js +355 -0
  46. package/test/handlers/contact.test.js +852 -0
  47. package/test/handlers/log.test.js +872 -0
  48. package/test/lib/callLogComposer.test.js +1231 -0
  49. package/test/lib/debugTracer.test.js +328 -0
  50. package/test/lib/logger.test.js +206 -0
  51. package/test/lib/oauth.test.js +359 -0
  52. package/test/lib/ringcentral.test.js +473 -0
  53. package/test/lib/sharedSMSComposer.test.js +1084 -0
  54. package/test/lib/util.test.js +282 -0
  55. package/test/mcp/tools/collectAuthInfo.test.js +192 -0
  56. package/test/mcp/tools/createCallLog.test.js +412 -0
  57. package/test/mcp/tools/createMessageLog.test.js +580 -0
  58. package/test/mcp/tools/doAuth.test.js +363 -0
  59. package/test/mcp/tools/findContactByName.test.js +263 -0
  60. package/test/mcp/tools/findContactByPhone.test.js +284 -0
  61. package/test/mcp/tools/getCallLog.test.js +286 -0
  62. package/test/mcp/tools/getPublicConnectors.test.js +128 -0
  63. package/test/mcp/tools/logout.test.js +169 -0
  64. package/test/mcp/tools/setConnector.test.js +177 -0
  65. package/test/mcp/tools/updateCallLog.test.js +346 -0
  66. package/test/models/accountDataModel.test.js +98 -0
  67. package/test/models/dynamo/connectorSchema.test.js +189 -0
  68. package/test/models/models.test.js +539 -0
  69. package/test/setup.js +176 -176
package/lib/analytics.js CHANGED
@@ -1,10 +1,12 @@
1
1
  const Mixpanel = require('mixpanel');
2
2
  const parser = require('ua-parser-js');
3
+ const logger = require('./logger');
3
4
  let packageJson = null;
4
5
  try {
5
6
  packageJson = require('../package.json');
6
7
  }
7
8
  catch (e) {
9
+ logger.warn('Error loading package.json', { stack: e.stack });
8
10
  packageJson = require('../../package.json');
9
11
  }
10
12
  const appName = 'App Connect';
@@ -49,5 +51,5 @@ exports.track = function track({ eventName, interfaceName, connectorName, accoun
49
51
  author,
50
52
  ...extras
51
53
  });
52
- console.log(`Event: ${eventName}`);
54
+ logger.info(`Event: ${eventName}`);
53
55
  }
@@ -0,0 +1,68 @@
1
+ /**
2
+ * Auth Session Helper
3
+ *
4
+ * Helper functions for managing OAuth auth sessions using CacheModel
5
+ */
6
+
7
+ const { CacheModel } = require('../models/cacheModel');
8
+
9
+ const AUTH_SESSION_PREFIX = 'auth-session';
10
+ const SESSION_EXPIRY_MINUTES = 5;
11
+
12
+ /**
13
+ * Create a new auth session
14
+ */
15
+ async function createAuthSession(sessionId, data) {
16
+ await CacheModel.create({
17
+ id: `${AUTH_SESSION_PREFIX}-${sessionId}`,
18
+ cacheKey: AUTH_SESSION_PREFIX,
19
+ userId: sessionId,
20
+ status: 'pending',
21
+ data: {
22
+ ...data,
23
+ createdAt: new Date().toISOString()
24
+ },
25
+ expiry: new Date(Date.now() + SESSION_EXPIRY_MINUTES * 60 * 1000)
26
+ });
27
+ }
28
+
29
+ /**
30
+ * Get an auth session by ID
31
+ */
32
+ async function getAuthSession(sessionId) {
33
+ const record = await CacheModel.findByPk(`${AUTH_SESSION_PREFIX}-${sessionId}`);
34
+
35
+ if (!record) return null;
36
+
37
+ return {
38
+ sessionId: record.userId,
39
+ status: record.status,
40
+ ...record.data
41
+ };
42
+ }
43
+
44
+ /**
45
+ * Update an auth session
46
+ */
47
+ async function updateAuthSession(sessionId, data) {
48
+ const record = await CacheModel.findByPk(`${AUTH_SESSION_PREFIX}-${sessionId}`);
49
+
50
+ if (!record) return;
51
+
52
+ const existingData = record.data || {};
53
+ await record.update({
54
+ status: data.status || record.status,
55
+ data: {
56
+ ...existingData,
57
+ ...data,
58
+ updatedAt: new Date().toISOString()
59
+ }
60
+ });
61
+ }
62
+
63
+ module.exports = {
64
+ createAuthSession,
65
+ getAuthSession,
66
+ updateAuthSession
67
+ };
68
+