@friggframework/devtools 2.0.0--canary.667.a0620c7.0 → 2.0.0--canary.682.451c957.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.
Files changed (62) hide show
  1. package/frigg-cli/README.md +30 -77
  2. package/frigg-cli/__tests__/unit/commands/deploy.test.js +24 -30
  3. package/frigg-cli/__tests__/unit/commands/doctor.test.js +6 -10
  4. package/frigg-cli/__tests__/unit/commands/generate-iam.test.js +0 -18
  5. package/frigg-cli/__tests__/unit/commands/install.test.js +341 -601
  6. package/frigg-cli/__tests__/unit/commands/ui.test.js +30 -31
  7. package/frigg-cli/__tests__/unit/dependencies.test.js +2 -6
  8. package/frigg-cli/generate-command/index.js +0 -1
  9. package/frigg-cli/generate-iam-command.js +0 -1
  10. package/frigg-cli/index.js +4 -9
  11. package/frigg-cli/index.test.js +158 -0
  12. package/frigg-cli/init-command/backend-first-handler.js +554 -397
  13. package/frigg-cli/init-command/index.js +35 -82
  14. package/frigg-cli/install-command/commit-changes.js +8 -40
  15. package/frigg-cli/install-command/environment-variables.js +0 -15
  16. package/frigg-cli/install-command/index.js +21 -96
  17. package/frigg-cli/install-command/install-package.js +4 -77
  18. package/frigg-cli/install-command/integration-file.js +11 -20
  19. package/frigg-cli/install-command/template.js +75 -102
  20. package/frigg-cli/install-command/validate-package.js +4 -36
  21. package/frigg-cli/package.json +1 -1
  22. package/frigg-cli/test/init-command.test.js +2 -9
  23. package/infrastructure/__tests__/management-api-gateway-routes.test.js +94 -40
  24. package/infrastructure/__tests__/postgres-config.test.js +835 -241
  25. package/infrastructure/__tests__/template-generation.test.js +8 -36
  26. package/infrastructure/docs/POSTGRES-CONFIGURATION.md +1 -21
  27. package/infrastructure/domains/admin-scripts/admin-script-builder.js +2 -6
  28. package/infrastructure/domains/admin-scripts/admin-script-builder.test.js +0 -30
  29. package/infrastructure/domains/database/aurora-builder.js +2 -13
  30. package/infrastructure/domains/database/aurora-builder.test.js +0 -22
  31. package/infrastructure/domains/health/application/use-cases/__tests__/mismatch-analyzer-method-name.test.js +8 -12
  32. package/infrastructure/domains/health/application/use-cases/__tests__/repair-via-import-use-case.test.js +7 -19
  33. package/infrastructure/domains/health/application/use-cases/run-health-check-use-case.test.js +8 -12
  34. package/infrastructure/domains/health/domain/services/__tests__/import-progress-monitor.test.js +18 -17
  35. package/infrastructure/domains/health/domain/services/__tests__/update-progress-monitor.test.js +2 -12
  36. package/infrastructure/domains/health/infrastructure/adapters/__tests__/orphan-detection-relationship-analysis.test.js +1 -8
  37. package/infrastructure/domains/health/infrastructure/adapters/aws-property-reconciler.test.js +2 -4
  38. package/infrastructure/domains/health/infrastructure/adapters/aws-resource-detector.test.js +0 -10
  39. package/infrastructure/domains/networking/vpc-builder.js +8 -18
  40. package/infrastructure/domains/networking/vpc-builder.test.js +12 -26
  41. package/infrastructure/domains/security/iam-generator.js +5 -112
  42. package/infrastructure/domains/security/iam-generator.test.js +0 -94
  43. package/infrastructure/domains/shared/cloudformation-discovery.test.js +6 -36
  44. package/infrastructure/domains/shared/utilities/base-definition-factory.js +27 -35
  45. package/infrastructure/domains/shared/utilities/base-definition-factory.test.js +49 -22
  46. package/infrastructure/infrastructure-composer.test.js +794 -268
  47. package/infrastructure/integration.test.js +381 -0
  48. package/infrastructure/scripts/build-prisma-layer.test.js +7 -28
  49. package/infrastructure/scripts/build-time-discovery.test.js +3 -18
  50. package/package.json +8 -10
  51. package/frigg-cli/__tests__/unit/commands/init.test.js +0 -688
  52. package/frigg-cli/init-command/deployment-modes.js +0 -7
  53. package/frigg-cli/init-command/safe-path.js +0 -58
  54. package/frigg-cli/init-command/scaffold-dependencies.js +0 -202
  55. package/frigg-cli/install-command/app-definition.js +0 -174
  56. package/frigg-cli/install-command/resolve-module.js +0 -69
  57. package/frigg-cli/templates/backend/README.md +0 -267
  58. package/frigg-cli/templates/backend/env.example +0 -20
  59. package/frigg-cli/templates/backend/gitignore +0 -10
  60. package/frigg-cli/templates/backend/index.js +0 -114
  61. package/frigg-cli/templates/backend/infrastructure.js +0 -20
  62. package/infrastructure/__tests__/scaffold-default-infrastructure.test.js +0 -148
@@ -5,17 +5,6 @@
5
5
  * valid, consistent CloudFormation templates.
6
6
  */
7
7
 
8
- // Never touch AWS or the real Prisma layer from a unit test: discovery returns
9
- // nothing (a fresh account), and the layer build (npm install into
10
- // layers/prisma) is stubbed out.
11
- jest.mock('../domains/shared/resource-discovery', () => ({
12
- ...jest.requireActual('../domains/shared/resource-discovery'),
13
- gatherDiscoveredResources: jest.fn().mockResolvedValue({}),
14
- }));
15
- jest.mock('../domains/shared/utilities/prisma-layer-manager', () => ({
16
- ensurePrismaLayerExists: jest.fn().mockResolvedValue(undefined),
17
- }));
18
-
19
8
  const { composeServerlessDefinition } = require('../infrastructure-composer');
20
9
 
21
10
  describe('CloudFormation Template Generation', () => {
@@ -97,16 +86,11 @@ describe('CloudFormation Template Generation', () => {
97
86
 
98
87
  // Framework-generated resources (created by Serverless Framework, not our builders)
99
88
  const frameworkResources = ['HttpApi', 'HttpApiLogGroup'];
100
- // Serverless names each function's resource `<Name>LambdaFunction`
101
- // (e.g. dbMigrationWorker -> DbMigrationWorkerLambdaFunction).
102
- const functionResources = Object.keys(result.functions || {}).map(
103
- (name) => `${name.charAt(0).toUpperCase()}${name.slice(1)}LambdaFunction`
104
- );
105
89
 
106
- // Verify all Refs point to existing resources, layers, functions or framework resources
90
+ // Verify all Refs point to existing resources, layers, or framework resources
107
91
  refs.forEach(ref => {
108
92
  if (!frameworkResources.includes(ref)) {
109
- expect([...allIds, ...functionResources]).toContain(ref);
93
+ expect(allIds).toContain(ref);
110
94
  }
111
95
  });
112
96
  });
@@ -139,9 +123,7 @@ describe('CloudFormation Template Generation', () => {
139
123
  integrations: [
140
124
  { Definition: { name: 'slack' } }
141
125
  ],
142
- // Discovery is stubbed to an empty account, so the VPC must be
143
- // created explicitly; `auto` with no VPC found is a hard error.
144
- vpc: { enable: true, management: 'create-new' },
126
+ vpc: { enable: true },
145
127
  encryption: { fieldLevelEncryptionMethod: 'kms' }
146
128
  };
147
129
 
@@ -269,9 +251,7 @@ describe('CloudFormation Template Generation', () => {
269
251
  it('should create VPC resources when enabled', async () => {
270
252
  const appDefinition = {
271
253
  name: 'test-app',
272
- // Discovery is stubbed to an empty account, so the VPC must be
273
- // created explicitly; `auto` with no VPC found is a hard error.
274
- vpc: { enable: true, management: 'create-new' },
254
+ vpc: { enable: true },
275
255
  integrations: []
276
256
  };
277
257
 
@@ -284,9 +264,7 @@ describe('CloudFormation Template Generation', () => {
284
264
  it('should create subnets in VPC', async () => {
285
265
  const appDefinition = {
286
266
  name: 'test-app',
287
- // Discovery is stubbed to an empty account, so the VPC must be
288
- // created explicitly; `auto` with no VPC found is a hard error.
289
- vpc: { enable: true, management: 'create-new' },
267
+ vpc: { enable: true },
290
268
  integrations: []
291
269
  };
292
270
 
@@ -299,9 +277,7 @@ describe('CloudFormation Template Generation', () => {
299
277
  it('should create security group in VPC', async () => {
300
278
  const appDefinition = {
301
279
  name: 'test-app',
302
- // Discovery is stubbed to an empty account, so the VPC must be
303
- // created explicitly; `auto` with no VPC found is a hard error.
304
- vpc: { enable: true, management: 'create-new' },
280
+ vpc: { enable: true },
305
281
  integrations: []
306
282
  };
307
283
 
@@ -314,9 +290,7 @@ describe('CloudFormation Template Generation', () => {
314
290
  it('should configure Lambda functions with VPC', async () => {
315
291
  const appDefinition = {
316
292
  name: 'test-app',
317
- // Discovery is stubbed to an empty account, so the VPC must be
318
- // created explicitly; `auto` with no VPC found is a hard error.
319
- vpc: { enable: true, management: 'create-new' },
293
+ vpc: { enable: true },
320
294
  integrations: [
321
295
  { Definition: { name: 'slack' } }
322
296
  ]
@@ -453,9 +427,7 @@ describe('CloudFormation Template Generation', () => {
453
427
  { Definition: { name: 'slack' } },
454
428
  { Definition: { name: 'hubspot' } }
455
429
  ],
456
- // Discovery is stubbed to an empty account, so the VPC must be
457
- // created explicitly; `auto` with no VPC found is a hard error.
458
- vpc: { enable: true, management: 'create-new' },
430
+ vpc: { enable: true },
459
431
  encryption: { useDefaultKMSForFieldLevelEncryption: true },
460
432
  database: {
461
433
  type: 'postgresql',
@@ -11,30 +11,10 @@ Frigg Framework supports automatic provisioning of Amazon Aurora Serverless v2 P
11
11
  - **Aurora Serverless v2**: Cost-efficient auto-scaling database (0.5-1.0 ACU default)
12
12
  - **VPC Integration**: Deployed in same private subnets as Lambda functions
13
13
  - **Secrets Manager**: Automatic credential management and rotation
14
- - **Management Modes**: discover, create-new, use-existing, external (bring your own `DATABASE_URL`)
14
+ - **Three Management Modes**: discover, create-new, use-existing
15
15
  - **Security**: Private subnet deployment with security group isolation
16
16
  - **High Availability**: Multi-AZ deployment with automatic failover
17
17
 
18
- ### Bring your own PostgreSQL (`management: 'external'`)
19
-
20
- To connect to a PostgreSQL that Frigg does not manage (any hosted provider, or
21
- a database you run yourself), set `management: 'external'`. Frigg then creates
22
- and discovers no database resources (no RDS/Aurora, no Secrets Manager secret)
23
- and needs no VPC for the database; the app connects through `DATABASE_URL`.
24
- This check takes precedence over a top-level `managementMode`. The migration
25
- infrastructure is still composed, so migrations run against `DATABASE_URL`.
26
-
27
- ```javascript
28
- const appDefinition = {
29
- vpc: { enable: false },
30
- database: { postgres: { enable: true, management: 'external' } },
31
- environment: { DATABASE_URL: true }, // read from the shell that runs `frigg deploy` (not .env)
32
- };
33
- ```
34
-
35
- Use `sslmode=require` in the URL. This is the default for apps scaffolded by
36
- `frigg init`.
37
-
38
18
  ---
39
19
 
40
20
  ## Configuration Schema
@@ -141,12 +141,10 @@ class AdminScriptBuilder extends InfrastructureBuilder {
141
141
  }
142
142
 
143
143
  createAdminScriptQueue(result, appDefinition) {
144
- // Registered under custom so the serverless plugin creates it in LocalStack offline
145
- result.custom.AdminScriptQueue = '${self:service}-${self:provider.stage}-AdminScriptQueue';
146
144
  result.resources.AdminScriptQueue = {
147
145
  Type: 'AWS::SQS::Queue',
148
146
  Properties: {
149
- QueueName: '${self:custom.AdminScriptQueue}',
147
+ QueueName: '${self:service}-${self:provider.stage}-AdminScriptQueue',
150
148
  MessageRetentionPeriod: 86400, // 1 day
151
149
  VisibilityTimeout: 900, // 15 minutes (Lambda max)
152
150
  RedrivePolicy: {
@@ -266,12 +264,10 @@ class AdminScriptBuilder extends InfrastructureBuilder {
266
264
  }
267
265
 
268
266
  createReportQueue(result, appDefinition) {
269
- // Registered under custom so the serverless plugin creates it in LocalStack offline
270
- result.custom.ReportQueue = '${self:service}-${self:provider.stage}-ReportQueue';
271
267
  result.resources.ReportQueue = {
272
268
  Type: 'AWS::SQS::Queue',
273
269
  Properties: {
274
- QueueName: '${self:custom.ReportQueue}',
270
+ QueueName: '${self:service}-${self:provider.stage}-ReportQueue',
275
271
  MessageRetentionPeriod: 86400, // 1 day
276
272
  VisibilityTimeout: 900, // 15 minutes (Lambda max)
277
273
  RedrivePolicy: {
@@ -168,21 +168,6 @@ describe('AdminScriptBuilder', () => {
168
168
  expect(result.resources.AdminScriptQueue.Properties.VisibilityTimeout).toBe(900); // 15 minutes
169
169
  });
170
170
 
171
- it('registers AdminScriptQueue under custom so frigg start creates it locally', async () => {
172
- const appDefinition = {
173
- adminScripts: [{ Definition: { name: 'test-script' } }],
174
- };
175
-
176
- const result = await adminScriptBuilder.build(appDefinition, {});
177
-
178
- expect(result.custom.AdminScriptQueue).toBe(
179
- '${self:service}-${self:provider.stage}-AdminScriptQueue'
180
- );
181
- expect(result.resources.AdminScriptQueue.Properties.QueueName).toBe(
182
- '${self:custom.AdminScriptQueue}'
183
- );
184
- });
185
-
186
171
  it('should configure AdminScriptQueue redrive policy to InternalErrorQueue', async () => {
187
172
  const appDefinition = {
188
173
  adminScripts: [
@@ -636,21 +621,6 @@ describe('AdminScriptBuilder', () => {
636
621
  });
637
622
 
638
623
  describe('reports (ReportQueue + reportExecutor)', () => {
639
- it('registers ReportQueue under custom so frigg start creates it locally', async () => {
640
- const appDefinition = {
641
- reports: [{ Definition: { name: 'my-report', version: '1.0.0' } }],
642
- };
643
-
644
- const result = await adminScriptBuilder.build(appDefinition, {});
645
-
646
- expect(result.custom.ReportQueue).toBe(
647
- '${self:service}-${self:provider.stage}-ReportQueue'
648
- );
649
- expect(result.resources.ReportQueue.Properties.QueueName).toBe(
650
- '${self:custom.ReportQueue}'
651
- );
652
- });
653
-
654
624
  it('creates ReportQueue + reportExecutor and wires REPORT_QUEUE_URL when reports are present', async () => {
655
625
  const appDefinition = {
656
626
  reports: [{ Definition: { name: 'my-report', version: '1.0.0' } }],
@@ -64,18 +64,7 @@ class AuroraBuilder extends InfrastructureBuilder {
64
64
  return false;
65
65
  }
66
66
 
67
- const postgres = appDefinition.database?.postgres;
68
-
69
- // management='external': the app brings its own PostgreSQL (any
70
- // provider) and connects through DATABASE_URL. Frigg creates and
71
- // discovers no database resources and needs no VPC for it. This
72
- // check precedes managementMode, which otherwise always manages
73
- // Aurora. Migrations still run (MigrationBuilder) against DATABASE_URL.
74
- if (postgres?.management === 'external') {
75
- return false;
76
- }
77
-
78
- return postgres?.enable === true;
67
+ return appDefinition.database?.postgres?.enable === true;
79
68
  }
80
69
 
81
70
  getDependencies() {
@@ -93,7 +82,7 @@ class AuroraBuilder extends InfrastructureBuilder {
93
82
  const dbConfig = appDefinition.database.postgres;
94
83
 
95
84
  // Validate management mode
96
- const validModes = ['discover', 'managed', 'use-existing', 'external'];
85
+ const validModes = ['discover', 'managed', 'use-existing'];
97
86
  const management = dbConfig.management || 'discover';
98
87
  if (!validModes.includes(management)) {
99
88
  result.addError(`Invalid database.postgres.management: "${management}"`);
@@ -42,28 +42,6 @@ describe('AuroraBuilder', () => {
42
42
  expect(auroraBuilder.shouldExecute(appDefinition)).toBe(false);
43
43
  });
44
44
 
45
- it('should return false when Postgres is external (bring your own DATABASE_URL)', () => {
46
- const appDefinition = {
47
- database: {
48
- postgres: { enable: true, management: 'external' },
49
- },
50
- };
51
-
52
- expect(auroraBuilder.shouldExecute(appDefinition)).toBe(false);
53
- });
54
-
55
- it('should return false for external Postgres even with managementMode=managed', () => {
56
- const appDefinition = {
57
- managementMode: 'managed',
58
- vpcIsolation: 'isolated',
59
- database: {
60
- postgres: { enable: true, management: 'external' },
61
- },
62
- };
63
-
64
- expect(auroraBuilder.shouldExecute(appDefinition)).toBe(false);
65
- });
66
-
67
45
  it('should return false when database is not defined', () => {
68
46
  const appDefinition = {};
69
47
 
@@ -84,12 +84,10 @@ describe('MismatchAnalyzer Method Name Bug Fix', () => {
84
84
  driftStatus: 'MODIFIED',
85
85
  propertyDifferences: [
86
86
  {
87
- // Raw CloudFormation PropertyDifference shape, as passed through by
88
- // AWSStackRepository.getResourceDrift() (PascalCase, slash-separated path).
89
- PropertyPath: '/BucketEncryption/ServerSideEncryptionConfiguration/0/BucketKeyEnabled',
90
- ExpectedValue: 'true',
91
- ActualValue: 'false',
92
- DifferenceType: 'NOT_EQUAL',
87
+ propertyPath: 'BucketEncryption.Rules[0].BucketKeyEnabled',
88
+ expectedValue: true,
89
+ actualValue: false,
90
+ differenceType: 'NOT_EQUAL',
93
91
  },
94
92
  ],
95
93
  });
@@ -146,12 +144,10 @@ describe('MismatchAnalyzer Method Name Bug Fix', () => {
146
144
  actualProperties: { BucketEncryption: { enabled: false } },
147
145
  propertyDifferences: [
148
146
  {
149
- // Raw CloudFormation PropertyDifference shape, as passed through by
150
- // AWSStackRepository.getResourceDrift() (PascalCase, slash-separated path).
151
- PropertyPath: '/BucketEncryption/enabled',
152
- ExpectedValue: 'true',
153
- ActualValue: 'false',
154
- DifferenceType: 'NOT_EQUAL',
147
+ propertyPath: 'BucketEncryption.enabled',
148
+ expectedValue: true,
149
+ actualValue: false,
150
+ differenceType: 'NOT_EQUAL',
155
151
  },
156
152
  ],
157
153
  });
@@ -548,11 +548,7 @@ describe('RepairViaImportUseCase - importWithLogicalIdMapping', () => {
548
548
  expect(result.unmappedCount).toBe(2);
549
549
  });
550
550
 
551
- it('should warn about duplicate resources dropped for the same logical ID', async () => {
552
- // Since 6a0bba7b, importWithLogicalIdMapping() de-duplicates candidates
553
- // per logical ID and only warns about the candidates it dropped
554
- // (_checkForMultipleResources(duplicates)). Distinct logical IDs are not
555
- // duplicates and produce no warning.
551
+ it('should generate warnings for multiple resources of same type', async () => {
556
552
  // Arrange
557
553
  const stackIdentifier = {
558
554
  stackName: 'acme-integrations-dev',
@@ -592,7 +588,7 @@ describe('RepairViaImportUseCase - importWithLogicalIdMapping', () => {
592
588
  const buildTemplate = { resources: {} };
593
589
  const deployedTemplate = { resources: {} };
594
590
 
595
- // Three VPCs all mapped to the same logical ID
591
+ // Three VPCs mapped
596
592
  const mappings = [
597
593
  {
598
594
  logicalId: 'FriggVPC',
@@ -602,14 +598,14 @@ describe('RepairViaImportUseCase - importWithLogicalIdMapping', () => {
602
598
  confidence: 'high',
603
599
  },
604
600
  {
605
- logicalId: 'FriggVPC',
601
+ logicalId: 'FriggVPC2',
606
602
  physicalId: 'vpc-456',
607
603
  resourceType: 'AWS::EC2::VPC',
608
604
  matchMethod: 'contained-resources',
609
605
  confidence: 'high',
610
606
  },
611
607
  {
612
- logicalId: 'FriggVPC',
608
+ logicalId: 'FriggVPC3',
613
609
  physicalId: 'vpc-789',
614
610
  resourceType: 'AWS::EC2::VPC',
615
611
  matchMethod: 'tag',
@@ -632,21 +628,13 @@ describe('RepairViaImportUseCase - importWithLogicalIdMapping', () => {
632
628
  });
633
629
 
634
630
  // Assert
635
- // Nothing is referenced by the deployed template, so the first candidate
636
- // is kept and the other two are reported as duplicates.
637
631
  expect(result.success).toBe(true);
638
- expect(result.mappedCount).toBe(1);
639
- expect(result.mappings[0].physicalId).toBe('vpc-123');
640
- expect(result.duplicatesRemoved).toBe(2);
641
632
  expect(result.warnings).toHaveLength(1);
642
633
  expect(result.warnings[0].type).toBe('MULTIPLE_RESOURCES');
643
634
  expect(result.warnings[0].resourceType).toBe('AWS::EC2::VPC');
644
- expect(result.warnings[0].count).toBe(2);
645
- expect(result.warnings[0].message).toContain('Multiple VPCs detected (2)');
646
- expect(result.warnings[0].resources.map((r) => r.physicalId)).toEqual([
647
- 'vpc-456',
648
- 'vpc-789',
649
- ]);
635
+ expect(result.warnings[0].count).toBe(3);
636
+ expect(result.warnings[0].message).toContain('Multiple VPCs detected (3)');
637
+ expect(result.warnings[0].resources).toHaveLength(3);
650
638
  });
651
639
 
652
640
  it('should include build and deployed template paths in result', async () => {
@@ -133,12 +133,10 @@ describe('RunHealthCheckUseCase', () => {
133
133
  driftStatus: 'MODIFIED',
134
134
  propertyDifferences: [
135
135
  {
136
- // Raw CloudFormation PropertyDifference shape, as passed through by
137
- // AWSStackRepository.getResourceDrift() (PascalCase, slash-separated path).
138
- PropertyPath: '/EnableDnsSupport',
139
- ExpectedValue: 'true',
140
- ActualValue: 'false',
141
- DifferenceType: 'NOT_EQUAL',
136
+ propertyPath: 'Properties.EnableDnsSupport',
137
+ expectedValue: true,
138
+ actualValue: false,
139
+ differenceType: 'NOT_EQUAL',
142
140
  },
143
141
  ],
144
142
  });
@@ -310,12 +308,10 @@ describe('RunHealthCheckUseCase', () => {
310
308
  driftStatus: 'MODIFIED',
311
309
  propertyDifferences: [
312
310
  {
313
- // Raw CloudFormation PropertyDifference shape, as passed through by
314
- // AWSStackRepository.getResourceDrift() (PascalCase, slash-separated path).
315
- PropertyPath: '/EnableDnsSupport',
316
- ExpectedValue: 'true',
317
- ActualValue: 'false',
318
- DifferenceType: 'NOT_EQUAL',
311
+ propertyPath: 'Properties.EnableDnsSupport',
312
+ expectedValue: true,
313
+ actualValue: false,
314
+ differenceType: 'NOT_EQUAL',
319
315
  },
320
316
  ],
321
317
  });
@@ -412,23 +412,24 @@ describe('ImportProgressMonitor', () => {
412
412
 
413
413
  mockCloudFormationRepository.getStackStatus.mockResolvedValue('IMPORT_IN_PROGRESS');
414
414
 
415
- // Act & Assert - attach the rejection handler before advancing the fake
416
- // clock: the monitor rejects while the timers run, and an unobserved
417
- // rejection fails the test under Jest 30.
418
- const resultPromise = monitor.monitorImport({
419
- stackIdentifier,
420
- resourceLogicalIds,
421
- onProgress,
422
- });
423
- const assertion = expect(resultPromise).rejects.toThrow('Import operation timed out');
424
-
425
- // Advance timers beyond 5 minutes (300,000ms) in chunks
426
- // Simulate 151 polls (302 seconds = 302,000ms) to exceed timeout
427
- for (let i = 0; i < 151; i++) {
428
- await jest.advanceTimersByTimeAsync(2000);
429
- }
430
-
431
- await assertion;
415
+ // Act & Assert - wrap in expect().rejects to properly handle async rejection
416
+ await expect(
417
+ (async () => {
418
+ const resultPromise = monitor.monitorImport({
419
+ stackIdentifier,
420
+ resourceLogicalIds,
421
+ onProgress,
422
+ });
423
+
424
+ // Advance timers beyond 5 minutes (300,000ms) in chunks
425
+ // Simulate 151 polls (302 seconds = 302,000ms) to exceed timeout
426
+ for (let i = 0; i < 151; i++) {
427
+ await jest.advanceTimersByTimeAsync(2000);
428
+ }
429
+
430
+ return await resultPromise;
431
+ })()
432
+ ).rejects.toThrow('Import operation timed out');
432
433
  });
433
434
 
434
435
  it('should filter events by resourceLogicalIds', async () => {
@@ -302,14 +302,9 @@ describe('UpdateProgressMonitor', () => {
302
302
  onProgress: onProgressCallback,
303
303
  });
304
304
 
305
- // Attach the rejection handler before advancing the fake clock: the
306
- // monitor rejects while the timers run, and an unobserved rejection
307
- // fails the test under Jest 30.
308
- const assertion = expect(monitorPromise).rejects.toThrow('Update operation failed and rolled back');
309
-
310
305
  await jest.advanceTimersByTimeAsync(2000);
311
306
 
312
- await assertion;
307
+ await expect(monitorPromise).rejects.toThrow('Update operation failed and rolled back');
313
308
  });
314
309
  });
315
310
 
@@ -339,15 +334,10 @@ describe('UpdateProgressMonitor', () => {
339
334
  onProgress: onProgressCallback,
340
335
  });
341
336
 
342
- // Attach the rejection handler before advancing the fake clock: the
343
- // monitor rejects while the timers run, and an unobserved rejection
344
- // fails the test under Jest 30.
345
- const assertion = expect(monitorPromise).rejects.toThrow('Update operation timed out');
346
-
347
337
  // Advance past 5 minute timeout (300000ms)
348
338
  await jest.advanceTimersByTimeAsync(300000 + 2000);
349
339
 
350
- await assertion;
340
+ await expect(monitorPromise).rejects.toThrow('Update operation timed out');
351
341
  });
352
342
  });
353
343
 
@@ -82,14 +82,7 @@ jest.mock('@aws-sdk/client-kms', () => ({
82
82
  ListAliasesCommand: jest.fn(),
83
83
  }));
84
84
 
85
- // SKIPPED: red-phase TDD spec for a feature that was never implemented.
86
- // AWSResourceDetector has no findOrphanedResourcesWithRelationships() or
87
- // _extractReferencedResourceIds(); the design is in
88
- // domains/health/docs/ORPHAN-DETECTION-ANALYSIS.md. (A template-based variant of
89
- // the reference analysis lives in RepairViaImportUseCase._extractReferencedIdsFromTemplate.)
90
- // Un-skip when the relationship analysis is implemented.
91
- // Tracked in https://github.com/friggframework/frigg/issues/709
92
- describe.skip('Orphan Detection with Relationship Analysis (TDD)', () => {
85
+ describe('Orphan Detection with Relationship Analysis (TDD)', () => {
93
86
  let detector;
94
87
  let mockEC2Send;
95
88
  let mockRDSSend;
@@ -447,9 +447,7 @@ describe('AWSPropertyReconciler', () => {
447
447
  );
448
448
 
449
449
  expect(strategy.supportsTemplateUpdate).toBe(true);
450
- // Lambda supports direct resource-mode reconciliation
451
- // (UpdateFunctionConfiguration) since 6a0bba7b; template is still preferred.
452
- expect(strategy.supportsResourceUpdate).toBe(true);
450
+ expect(strategy.supportsResourceUpdate).toBe(false);
453
451
  expect(strategy.recommendedMode).toBe('template');
454
452
  expect(strategy.limitations).toContain(
455
453
  'VpcConfig changes may take several minutes to propagate'
@@ -661,7 +659,7 @@ describe('AWSPropertyReconciler', () => {
661
659
 
662
660
  expect(strategy).toEqual({
663
661
  supportsTemplateUpdate: true,
664
- supportsResourceUpdate: true, // resource mode via UpdateFunctionConfiguration
662
+ supportsResourceUpdate: false,
665
663
  recommendedMode: 'template',
666
664
  limitations: expect.arrayContaining([
667
665
  'VpcConfig changes may take several minutes to propagate',
@@ -441,16 +441,6 @@ describe('AWSResourceDetector', () => {
441
441
  describe('findOrphanedResources', () => {
442
442
  const StackIdentifier = require('../../domain/value-objects/stack-identifier');
443
443
 
444
- beforeEach(() => {
445
- // findOrphanedResources() scans every supported resource type
446
- // (EC2, RDS and KMS), not just the types in the stack, so every
447
- // client needs an (empty) response; each test overrides the one
448
- // service it is about.
449
- mockEC2Send.mockResolvedValue({});
450
- mockRDSSend.mockResolvedValue({});
451
- mockKMSSend.mockResolvedValue({});
452
- });
453
-
454
444
  it('should find orphaned RDS DBCluster with frigg:stack tag', async () => {
455
445
  const stackIdentifier = new StackIdentifier({
456
446
  stackName: 'my-app-prod',
@@ -439,14 +439,8 @@ class VpcBuilder extends InfrastructureBuilder {
439
439
  translated.vpc.ownership.subnets = 'external';
440
440
  }
441
441
 
442
- // Legacy options that warnIgnoredOptions() reports as ignored under
443
- // managementMode='managed' must really be ignored: applying them would
444
- // undo the ownership chosen above (e.g. vpc.management='discover' turning
445
- // managed+isolated's ownership.vpc='stack' back into 'auto').
446
- const honorLegacyModes = globalMode !== 'managed';
447
-
448
442
  // Handle legacy vpc.management modes
449
- const vpcManagement = honorLegacyModes ? appDefinition.vpc?.management : undefined;
443
+ const vpcManagement = appDefinition.vpc?.management;
450
444
  if (vpcManagement === 'create-new') {
451
445
  translated.vpc.ownership.vpc = 'stack';
452
446
  translated.vpc.ownership.securityGroup = 'stack';
@@ -472,7 +466,7 @@ class VpcBuilder extends InfrastructureBuilder {
472
466
  }
473
467
 
474
468
  // Handle legacy shareAcrossStages
475
- if (honorLegacyModes && appDefinition.vpc?.shareAcrossStages !== undefined) {
469
+ if (appDefinition.vpc?.shareAcrossStages !== undefined) {
476
470
  if (appDefinition.vpc.shareAcrossStages) {
477
471
  // Shared VPC - discover and reuse
478
472
  translated.vpc.ownership.vpc = 'auto';
@@ -487,7 +481,7 @@ class VpcBuilder extends InfrastructureBuilder {
487
481
  }
488
482
 
489
483
  // Handle legacy NAT Gateway management
490
- if (honorLegacyModes && appDefinition.vpc?.natGateway?.management === 'createAndManage') {
484
+ if (appDefinition.vpc?.natGateway?.management === 'createAndManage') {
491
485
  // Use 'auto' to allow discovering and reusing properly placed external NAT Gateways
492
486
  // The resolver will check if there's a good external NAT Gateway and reuse it,
493
487
  // or create a new one if needed (or if the existing one is misplaced)
@@ -499,10 +493,9 @@ class VpcBuilder extends InfrastructureBuilder {
499
493
  }
500
494
 
501
495
  // Handle legacy subnet management
502
- const subnetManagement = honorLegacyModes ? appDefinition.vpc?.subnets?.management : undefined;
503
- if (subnetManagement === 'create') {
496
+ if (appDefinition.vpc?.subnets?.management === 'create') {
504
497
  translated.vpc.ownership.subnets = 'stack';
505
- } else if (subnetManagement === 'use-existing' && appDefinition.vpc.subnets.ids) {
498
+ } else if (appDefinition.vpc?.subnets?.management === 'use-existing' && appDefinition.vpc.subnets.ids) {
506
499
  translated.vpc.ownership.subnets = 'external';
507
500
  translated.vpc.external.subnetIds = appDefinition.vpc.subnets.ids;
508
501
  }
@@ -698,11 +691,8 @@ class VpcBuilder extends InfrastructureBuilder {
698
691
  result.vpcConfig.securityGroupIds = [{ Ref: 'FriggLambdaSecurityGroup' }];
699
692
  console.log(' ✅ Security Group added to template');
700
693
  } else if (decision.ownership === ResourceOwnership.EXTERNAL) {
701
- // Use external security group IDs. createExternalDecision keeps the
702
- // full list in physicalIds; physicalId is only the first of them.
703
- const sgIds = decision.physicalIds?.length
704
- ? decision.physicalIds
705
- : Array.isArray(decision.physicalId) ? decision.physicalId : [decision.physicalId];
694
+ // Use external security group IDs
695
+ const sgIds = Array.isArray(decision.physicalId) ? decision.physicalId : [decision.physicalId];
706
696
  result.vpcConfig.securityGroupIds = sgIds;
707
697
  console.log(` ✓ Using external security group(s): ${sgIds.join(', ')}`);
708
698
  }
@@ -1185,7 +1175,7 @@ class VpcBuilder extends InfrastructureBuilder {
1185
1175
  const vpcId = result.vpcId;
1186
1176
 
1187
1177
  // Determine logical IDs based on what exists in stack for backwards compatibility
1188
- // CRITICAL: older production stacks use OLD naming (VPCEndpointS3, not FriggS3VPCEndpoint)
1178
+ // CRITICAL: Frontify production uses OLD naming (VPCEndpointS3, not FriggS3VPCEndpoint)
1189
1179
  const existingLogicalIds = discoveredResources?.existingLogicalIds || [];
1190
1180
 
1191
1181