@friggframework/core 2.0.0--canary.461.72d9698.0 → 2.0.0--canary.461.efcd1bf.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,6 +1,8 @@
1
1
  const { Router } = require('express');
2
- const { moduleFactory, integrationFactory } = require('./../backend-utils');
3
2
  const { createAppHandler } = require('./../app-handler-helpers');
3
+ const { loadAppDefinition } = require('./../app-definition-loader');
4
+ const { ModuleFactory } = require('../../modules/module-factory');
5
+ const { IntegrationFactory } = require('../../integrations/integration-factory');
4
6
  const {
5
7
  createHealthCheckRepository,
6
8
  } = require('../../database/repositories/health-check-repository-factory');
@@ -22,6 +24,35 @@ const {
22
24
 
23
25
  const router = Router();
24
26
  const healthCheckRepository = createHealthCheckRepository();
27
+
28
+ // Load app definition to get integration classes for factory creation
29
+ let moduleFactory, integrationFactory;
30
+ try {
31
+ const { integrations: integrationClasses } = loadAppDefinition();
32
+ const {
33
+ createModuleRepository,
34
+ } = require('../../modules/repositories/module-repository-factory');
35
+ const {
36
+ createIntegrationRepository,
37
+ } = require('../../integrations/repositories/integration-repository-factory');
38
+
39
+ const moduleRepository = createModuleRepository();
40
+ const integrationRepository = createIntegrationRepository();
41
+
42
+ moduleFactory = new ModuleFactory({
43
+ moduleRepository,
44
+ integrationClasses,
45
+ });
46
+
47
+ integrationFactory = new IntegrationFactory({
48
+ integrationRepository,
49
+ integrationClasses,
50
+ });
51
+ } catch (error) {
52
+ console.warn('Could not initialize module/integration factories for health check:', error.message);
53
+ // Factories will be undefined, health check will handle gracefully
54
+ }
55
+
25
56
  const testEncryptionUseCase = new TestEncryptionUseCase({
26
57
  healthCheckRepository,
27
58
  });
@@ -142,10 +173,10 @@ const detectVpcConfiguration = async () => {
142
173
  }
143
174
 
144
175
  // Check if Lambda is in VPC using VPC_ENABLED env var set by infrastructure
145
- results.isInVpc = process.env.VPC_ENABLED === 'true' ||
146
- (!results.hasInternetAccess && results.canResolvePublicDns) ||
176
+ results.isInVpc = process.env.VPC_ENABLED === 'true' ||
177
+ (!results.hasInternetAccess && results.canResolvePublicDns) ||
147
178
  results.vpcEndpoints.length > 0;
148
-
179
+
149
180
  results.canConnectToAws =
150
181
  results.hasInternetAccess || results.vpcEndpoints.length > 0;
151
182
  } catch (error) {
@@ -5,13 +5,13 @@ class CheckIntegrationsHealthUseCase {
5
5
  }
6
6
 
7
7
  execute() {
8
- const moduleTypes = Array.isArray(this.moduleFactory.moduleTypes)
8
+ const moduleTypes = (this.moduleFactory && Array.isArray(this.moduleFactory.moduleTypes))
9
9
  ? this.moduleFactory.moduleTypes
10
10
  : [];
11
11
 
12
- const integrationTypes = Array.isArray(
12
+ const integrationTypes = (this.integrationFactory && Array.isArray(
13
13
  this.integrationFactory.integrationTypes
14
- )
14
+ ))
15
15
  ? this.integrationFactory.integrationTypes
16
16
  : [];
17
17
 
@@ -0,0 +1,125 @@
1
+ /**
2
+ * Tests for CheckIntegrationsHealthUseCase
3
+ *
4
+ * Tests integration and module factory health checking
5
+ */
6
+
7
+ const { CheckIntegrationsHealthUseCase } = require('./check-integrations-health-use-case');
8
+
9
+ describe('CheckIntegrationsHealthUseCase', () => {
10
+ describe('execute()', () => {
11
+ it('should return healthy status with module and integration counts', () => {
12
+ const mockModuleFactory = {
13
+ moduleTypes: ['HubSpot', 'Salesforce', 'Slack'],
14
+ };
15
+
16
+ const mockIntegrationFactory = {
17
+ integrationTypes: ['HubSpot-to-Salesforce', 'Slack-Notifications'],
18
+ };
19
+
20
+ const useCase = new CheckIntegrationsHealthUseCase({
21
+ moduleFactory: mockModuleFactory,
22
+ integrationFactory: mockIntegrationFactory,
23
+ });
24
+
25
+ const result = useCase.execute();
26
+
27
+ expect(result.status).toBe('healthy');
28
+ expect(result.modules.count).toBe(3);
29
+ expect(result.modules.available).toEqual(['HubSpot', 'Salesforce', 'Slack']);
30
+ expect(result.integrations.count).toBe(2);
31
+ expect(result.integrations.available).toEqual(['HubSpot-to-Salesforce', 'Slack-Notifications']);
32
+ });
33
+
34
+ it('should handle undefined moduleFactory gracefully', () => {
35
+ const mockIntegrationFactory = {
36
+ integrationTypes: ['Integration1'],
37
+ };
38
+
39
+ const useCase = new CheckIntegrationsHealthUseCase({
40
+ moduleFactory: undefined,
41
+ integrationFactory: mockIntegrationFactory,
42
+ });
43
+
44
+ const result = useCase.execute();
45
+
46
+ expect(result.status).toBe('healthy');
47
+ expect(result.modules.count).toBe(0);
48
+ expect(result.modules.available).toEqual([]);
49
+ expect(result.integrations.count).toBe(1);
50
+ });
51
+
52
+ it('should handle undefined integrationFactory gracefully', () => {
53
+ const mockModuleFactory = {
54
+ moduleTypes: ['Module1'],
55
+ };
56
+
57
+ const useCase = new CheckIntegrationsHealthUseCase({
58
+ moduleFactory: mockModuleFactory,
59
+ integrationFactory: undefined,
60
+ });
61
+
62
+ const result = useCase.execute();
63
+
64
+ expect(result.status).toBe('healthy');
65
+ expect(result.modules.count).toBe(1);
66
+ expect(result.integrations.count).toBe(0);
67
+ expect(result.integrations.available).toEqual([]);
68
+ });
69
+
70
+ it('should handle both factories being undefined', () => {
71
+ const useCase = new CheckIntegrationsHealthUseCase({
72
+ moduleFactory: undefined,
73
+ integrationFactory: undefined,
74
+ });
75
+
76
+ const result = useCase.execute();
77
+
78
+ expect(result.status).toBe('healthy');
79
+ expect(result.modules.count).toBe(0);
80
+ expect(result.modules.available).toEqual([]);
81
+ expect(result.integrations.count).toBe(0);
82
+ expect(result.integrations.available).toEqual([]);
83
+ });
84
+
85
+ it('should handle non-array moduleTypes', () => {
86
+ const mockModuleFactory = {
87
+ moduleTypes: 'not-an-array',
88
+ };
89
+
90
+ const mockIntegrationFactory = {
91
+ integrationTypes: [],
92
+ };
93
+
94
+ const useCase = new CheckIntegrationsHealthUseCase({
95
+ moduleFactory: mockModuleFactory,
96
+ integrationFactory: mockIntegrationFactory,
97
+ });
98
+
99
+ const result = useCase.execute();
100
+
101
+ expect(result.status).toBe('healthy');
102
+ expect(result.modules.count).toBe(0);
103
+ expect(result.modules.available).toEqual([]);
104
+ });
105
+
106
+ it('should handle factories with missing moduleTypes/integrationTypes properties', () => {
107
+ const mockModuleFactory = {}; // No moduleTypes property
108
+ const mockIntegrationFactory = {}; // No integrationTypes property
109
+
110
+ const useCase = new CheckIntegrationsHealthUseCase({
111
+ moduleFactory: mockModuleFactory,
112
+ integrationFactory: mockIntegrationFactory,
113
+ });
114
+
115
+ const result = useCase.execute();
116
+
117
+ expect(result.status).toBe('healthy');
118
+ expect(result.modules.count).toBe(0);
119
+ expect(result.modules.available).toEqual([]);
120
+ expect(result.integrations.count).toBe(0);
121
+ expect(result.integrations.available).toEqual([]);
122
+ });
123
+ });
124
+ });
125
+
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.72d9698.0",
4
+ "version": "2.0.0--canary.461.efcd1bf.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.72d9698.0",
41
- "@friggframework/prettier-config": "2.0.0--canary.461.72d9698.0",
42
- "@friggframework/test": "2.0.0--canary.461.72d9698.0",
40
+ "@friggframework/eslint-config": "2.0.0--canary.461.efcd1bf.0",
41
+ "@friggframework/prettier-config": "2.0.0--canary.461.efcd1bf.0",
42
+ "@friggframework/test": "2.0.0--canary.461.efcd1bf.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": "72d96987ab9b7936004379553385781c13d1a692"
82
+ "gitHead": "efcd1bfb036c4bb846bed987625891a4c48324f1"
83
83
  }