@friggframework/core 2.0.0--canary.461.02fc54a.0 → 2.0.0--canary.461.651659d.0

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.
@@ -1,5 +1,16 @@
1
1
  const { Router } = require('express');
2
2
  const { createAppHandler } = require('./../app-handler-helpers');
3
+ const { loadAppDefinition } = require('./../app-definition-loader');
4
+ const { ModuleFactory } = require('../../modules/module-factory');
5
+ const {
6
+ getModulesDefinitionFromIntegrationClasses,
7
+ } = require('../../integrations/utils/map-integration-dto');
8
+ const {
9
+ createModuleRepository,
10
+ } = require('../../modules/repositories/module-repository-factory');
11
+ const {
12
+ createIntegrationRepository,
13
+ } = require('../../integrations/repositories/integration-repository-factory');
3
14
  const {
4
15
  createHealthCheckRepository,
5
16
  } = require('../../database/repositories/health-check-repository-factory');
@@ -22,6 +33,27 @@ const {
22
33
  const router = Router();
23
34
  const healthCheckRepository = createHealthCheckRepository();
24
35
 
36
+ // Load integrations and create factories just like auth router does
37
+ // This verifies the system can properly load integrations
38
+ let moduleFactory, integrationClasses;
39
+ try {
40
+ const appDef = loadAppDefinition();
41
+ integrationClasses = appDef.integrations || [];
42
+
43
+ const moduleRepository = createModuleRepository();
44
+ const moduleDefinitions = getModulesDefinitionFromIntegrationClasses(integrationClasses);
45
+
46
+ moduleFactory = new ModuleFactory({
47
+ moduleRepository,
48
+ moduleDefinitions,
49
+ });
50
+ } catch (error) {
51
+ console.error('Failed to load integrations for health check:', error.message);
52
+ // Factories will be undefined, health check will report unhealthy
53
+ moduleFactory = undefined;
54
+ integrationClasses = [];
55
+ }
56
+
25
57
  const testEncryptionUseCase = new TestEncryptionUseCase({
26
58
  healthCheckRepository,
27
59
  });
@@ -32,11 +64,9 @@ const checkEncryptionHealthUseCase = new CheckEncryptionHealthUseCase({
32
64
  testEncryptionUseCase,
33
65
  });
34
66
  const checkExternalApisHealthUseCase = new CheckExternalApisHealthUseCase();
35
- // Module/Integration factories not available in health check context
36
- // Pass undefined - the use case will handle gracefully
37
67
  const checkIntegrationsHealthUseCase = new CheckIntegrationsHealthUseCase({
38
- moduleFactory: undefined,
39
- integrationFactory: undefined,
68
+ moduleFactory,
69
+ integrationClasses,
40
70
  });
41
71
 
42
72
  const validateApiKey = (req, res, next) => {
@@ -1,20 +1,32 @@
1
1
  class CheckIntegrationsHealthUseCase {
2
- constructor({ moduleFactory, integrationFactory }) {
2
+ constructor({ moduleFactory, integrationClasses }) {
3
3
  this.moduleFactory = moduleFactory;
4
- this.integrationFactory = integrationFactory;
4
+ this.integrationClasses = integrationClasses;
5
5
  }
6
6
 
7
7
  execute() {
8
- const moduleTypes = (this.moduleFactory && Array.isArray(this.moduleFactory.moduleTypes))
9
- ? this.moduleFactory.moduleTypes
8
+ const moduleDefinitions = (this.moduleFactory && this.moduleFactory.moduleDefinitions)
9
+ ? this.moduleFactory.moduleDefinitions
10
10
  : [];
11
11
 
12
- const integrationTypes = (this.integrationFactory && Array.isArray(
13
- this.integrationFactory.integrationTypes
14
- ))
15
- ? this.integrationFactory.integrationTypes
12
+ const integrationClasses = Array.isArray(this.integrationClasses)
13
+ ? this.integrationClasses
16
14
  : [];
17
15
 
16
+ // Extract module names from definitions
17
+ const moduleTypes = Array.isArray(moduleDefinitions)
18
+ ? moduleDefinitions.map(def => def.moduleName || def.name || def.label || 'Unknown')
19
+ : [];
20
+
21
+ // Extract integration names from classes
22
+ const integrationNames = integrationClasses.map(IntegrationClass => {
23
+ try {
24
+ return IntegrationClass.Definition?.name || IntegrationClass.name || 'Unknown';
25
+ } catch {
26
+ return 'Unknown';
27
+ }
28
+ });
29
+
18
30
  return {
19
31
  status: 'healthy',
20
32
  modules: {
@@ -22,8 +34,8 @@ class CheckIntegrationsHealthUseCase {
22
34
  available: moduleTypes,
23
35
  },
24
36
  integrations: {
25
- count: integrationTypes.length,
26
- available: integrationTypes,
37
+ count: integrationNames.length,
38
+ available: integrationNames,
27
39
  },
28
40
  };
29
41
  }
@@ -10,16 +10,21 @@ describe('CheckIntegrationsHealthUseCase', () => {
10
10
  describe('execute()', () => {
11
11
  it('should return healthy status with module and integration counts', () => {
12
12
  const mockModuleFactory = {
13
- moduleTypes: ['HubSpot', 'Salesforce', 'Slack'],
13
+ moduleDefinitions: [
14
+ { moduleName: 'HubSpot' },
15
+ { moduleName: 'Salesforce' },
16
+ { moduleName: 'Slack' },
17
+ ],
14
18
  };
15
19
 
16
- const mockIntegrationFactory = {
17
- integrationTypes: ['HubSpot-to-Salesforce', 'Slack-Notifications'],
18
- };
20
+ const mockIntegrationClasses = [
21
+ { Definition: { name: 'HubSpot-to-Salesforce' } },
22
+ { Definition: { name: 'Slack-Notifications' } },
23
+ ];
19
24
 
20
25
  const useCase = new CheckIntegrationsHealthUseCase({
21
26
  moduleFactory: mockModuleFactory,
22
- integrationFactory: mockIntegrationFactory,
27
+ integrationClasses: mockIntegrationClasses,
23
28
  });
24
29
 
25
30
  const result = useCase.execute();
@@ -32,13 +37,13 @@ describe('CheckIntegrationsHealthUseCase', () => {
32
37
  });
33
38
 
34
39
  it('should handle undefined moduleFactory gracefully', () => {
35
- const mockIntegrationFactory = {
36
- integrationTypes: ['Integration1'],
37
- };
40
+ const mockIntegrationClasses = [
41
+ { Definition: { name: 'Integration1' } },
42
+ ];
38
43
 
39
44
  const useCase = new CheckIntegrationsHealthUseCase({
40
45
  moduleFactory: undefined,
41
- integrationFactory: mockIntegrationFactory,
46
+ integrationClasses: mockIntegrationClasses,
42
47
  });
43
48
 
44
49
  const result = useCase.execute();
@@ -49,14 +54,14 @@ describe('CheckIntegrationsHealthUseCase', () => {
49
54
  expect(result.integrations.count).toBe(1);
50
55
  });
51
56
 
52
- it('should handle undefined integrationFactory gracefully', () => {
57
+ it('should handle undefined integrationClasses gracefully', () => {
53
58
  const mockModuleFactory = {
54
- moduleTypes: ['Module1'],
59
+ moduleDefinitions: [{ moduleName: 'Module1' }],
55
60
  };
56
61
 
57
62
  const useCase = new CheckIntegrationsHealthUseCase({
58
63
  moduleFactory: mockModuleFactory,
59
- integrationFactory: undefined,
64
+ integrationClasses: undefined,
60
65
  });
61
66
 
62
67
  const result = useCase.execute();
@@ -67,10 +72,10 @@ describe('CheckIntegrationsHealthUseCase', () => {
67
72
  expect(result.integrations.available).toEqual([]);
68
73
  });
69
74
 
70
- it('should handle both factories being undefined', () => {
75
+ it('should handle both moduleFactory and integrationClasses being undefined', () => {
71
76
  const useCase = new CheckIntegrationsHealthUseCase({
72
77
  moduleFactory: undefined,
73
- integrationFactory: undefined,
78
+ integrationClasses: undefined,
74
79
  });
75
80
 
76
81
  const result = useCase.execute();
@@ -82,18 +87,14 @@ describe('CheckIntegrationsHealthUseCase', () => {
82
87
  expect(result.integrations.available).toEqual([]);
83
88
  });
84
89
 
85
- it('should handle non-array moduleTypes', () => {
90
+ it('should handle non-array moduleDefinitions', () => {
86
91
  const mockModuleFactory = {
87
- moduleTypes: 'not-an-array',
88
- };
89
-
90
- const mockIntegrationFactory = {
91
- integrationTypes: [],
92
+ moduleDefinitions: 'not-an-array',
92
93
  };
93
94
 
94
95
  const useCase = new CheckIntegrationsHealthUseCase({
95
96
  moduleFactory: mockModuleFactory,
96
- integrationFactory: mockIntegrationFactory,
97
+ integrationClasses: [],
97
98
  });
98
99
 
99
100
  const result = useCase.execute();
@@ -103,13 +104,12 @@ describe('CheckIntegrationsHealthUseCase', () => {
103
104
  expect(result.modules.available).toEqual([]);
104
105
  });
105
106
 
106
- it('should handle factories with missing moduleTypes/integrationTypes properties', () => {
107
- const mockModuleFactory = {}; // No moduleTypes property
108
- const mockIntegrationFactory = {}; // No integrationTypes property
107
+ it('should handle moduleFactory with missing moduleDefinitions property', () => {
108
+ const mockModuleFactory = {}; // No moduleDefinitions property
109
109
 
110
110
  const useCase = new CheckIntegrationsHealthUseCase({
111
111
  moduleFactory: mockModuleFactory,
112
- integrationFactory: mockIntegrationFactory,
112
+ integrationClasses: [],
113
113
  });
114
114
 
115
115
  const result = useCase.execute();
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@friggframework/core",
3
3
  "prettier": "@friggframework/prettier-config",
4
- "version": "2.0.0--canary.461.02fc54a.0",
4
+ "version": "2.0.0--canary.461.651659d.0",
5
5
  "dependencies": {
6
6
  "@aws-sdk/client-apigatewaymanagementapi": "^3.588.0",
7
7
  "@aws-sdk/client-kms": "^3.588.0",
@@ -37,9 +37,9 @@
37
37
  }
38
38
  },
39
39
  "devDependencies": {
40
- "@friggframework/eslint-config": "2.0.0--canary.461.02fc54a.0",
41
- "@friggframework/prettier-config": "2.0.0--canary.461.02fc54a.0",
42
- "@friggframework/test": "2.0.0--canary.461.02fc54a.0",
40
+ "@friggframework/eslint-config": "2.0.0--canary.461.651659d.0",
41
+ "@friggframework/prettier-config": "2.0.0--canary.461.651659d.0",
42
+ "@friggframework/test": "2.0.0--canary.461.651659d.0",
43
43
  "@prisma/client": "^6.17.0",
44
44
  "@types/lodash": "4.17.15",
45
45
  "@typescript-eslint/eslint-plugin": "^8.0.0",
@@ -79,5 +79,5 @@
79
79
  "publishConfig": {
80
80
  "access": "public"
81
81
  },
82
- "gitHead": "02fc54ae7404113a9cb68b70437ce2879a7d7e5f"
82
+ "gitHead": "651659d3282b05bcecf571281d5a1a7e19c156bf"
83
83
  }