@friggframework/devtools 2.0.0--canary.731.ffe61d3.0 → 2.0.0--canary.656.6eb85ab.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 (102) hide show
  1. package/frigg-cli/README.md +31 -115
  2. package/frigg-cli/__tests__/unit/commands/build.test.js +0 -3
  3. package/frigg-cli/__tests__/unit/commands/deploy.test.js +24 -33
  4. package/frigg-cli/__tests__/unit/commands/doctor.test.js +6 -10
  5. package/frigg-cli/__tests__/unit/commands/generate-iam.test.js +0 -18
  6. package/frigg-cli/__tests__/unit/commands/install.test.js +341 -601
  7. package/frigg-cli/__tests__/unit/commands/ui.test.js +30 -31
  8. package/frigg-cli/__tests__/unit/dependencies.test.js +2 -6
  9. package/frigg-cli/build-command/index.js +0 -6
  10. package/frigg-cli/deploy-command/index.js +0 -6
  11. package/frigg-cli/generate-command/index.js +0 -1
  12. package/frigg-cli/generate-iam-command.js +0 -1
  13. package/frigg-cli/index.js +5 -22
  14. package/frigg-cli/index.test.js +158 -0
  15. package/frigg-cli/init-command/backend-first-handler.js +551 -395
  16. package/frigg-cli/init-command/index.js +35 -82
  17. package/frigg-cli/install-command/commit-changes.js +8 -40
  18. package/frigg-cli/install-command/environment-variables.js +0 -15
  19. package/frigg-cli/install-command/index.js +21 -96
  20. package/frigg-cli/install-command/install-package.js +4 -77
  21. package/frigg-cli/install-command/integration-file.js +11 -20
  22. package/frigg-cli/install-command/template.js +75 -102
  23. package/frigg-cli/install-command/validate-package.js +4 -36
  24. package/frigg-cli/package.json +1 -1
  25. package/frigg-cli/start-command/index.js +0 -4
  26. package/frigg-cli/start-command/start-command.test.js +0 -3
  27. package/frigg-cli/test/init-command.test.js +2 -9
  28. package/infrastructure/README.md +5 -32
  29. package/infrastructure/__tests__/postgres-config.test.js +836 -245
  30. package/infrastructure/__tests__/scoped-environment.test.js +0 -3
  31. package/infrastructure/__tests__/ssm-preload-node-options.test.js +0 -3
  32. package/infrastructure/__tests__/template-generation.test.js +8 -39
  33. package/infrastructure/create-frigg-infrastructure.js +1 -4
  34. package/infrastructure/docs/POSTGRES-CONFIGURATION.md +98 -80
  35. package/infrastructure/domains/admin-scripts/admin-script-builder.js +2 -8
  36. package/infrastructure/domains/admin-scripts/admin-script-builder.test.js +6 -52
  37. package/infrastructure/domains/database/aurora-builder.js +2 -13
  38. package/infrastructure/domains/database/aurora-builder.test.js +0 -22
  39. package/infrastructure/domains/database/migration-builder.js +2 -21
  40. package/infrastructure/domains/database/migration-builder.test.js +6 -61
  41. package/infrastructure/domains/health/application/use-cases/__tests__/mismatch-analyzer-method-name.test.js +8 -12
  42. package/infrastructure/domains/health/application/use-cases/__tests__/repair-via-import-use-case.test.js +7 -19
  43. package/infrastructure/domains/health/application/use-cases/run-health-check-use-case.test.js +8 -12
  44. package/infrastructure/domains/health/domain/services/__tests__/import-progress-monitor.test.js +18 -17
  45. package/infrastructure/domains/health/domain/services/__tests__/update-progress-monitor.test.js +2 -12
  46. package/infrastructure/domains/health/infrastructure/adapters/__tests__/orphan-detection-relationship-analysis.test.js +1 -8
  47. package/infrastructure/domains/health/infrastructure/adapters/aws-property-reconciler.test.js +2 -4
  48. package/infrastructure/domains/health/infrastructure/adapters/aws-resource-detector.test.js +0 -10
  49. package/infrastructure/domains/integration/integration-builder.js +0 -2
  50. package/infrastructure/domains/integration/integration-builder.test.js +6 -22
  51. package/infrastructure/domains/networking/vpc-builder.js +8 -18
  52. package/infrastructure/domains/networking/vpc-builder.test.js +12 -26
  53. package/infrastructure/domains/security/iam-generator.js +5 -112
  54. package/infrastructure/domains/security/iam-generator.test.js +0 -94
  55. package/infrastructure/domains/shared/cloudformation-discovery.test.js +6 -36
  56. package/infrastructure/domains/shared/environment-builder.js +5 -31
  57. package/infrastructure/domains/shared/environment-builder.test.js +7 -93
  58. package/infrastructure/domains/shared/utilities/base-definition-factory.js +3 -39
  59. package/infrastructure/domains/shared/utilities/base-definition-factory.test.js +5 -85
  60. package/infrastructure/domains/shared/utilities/nested-node-modules.js +5 -6
  61. package/infrastructure/domains/shared/utilities/nested-node-modules.test.js +26 -20
  62. package/infrastructure/domains/shared/utilities/prisma-layer-manager.js +12 -92
  63. package/infrastructure/domains/shared/utilities/prisma-layer-manager.test.js +6 -158
  64. package/infrastructure/infrastructure-composer.js +1 -12
  65. package/infrastructure/infrastructure-composer.test.js +794 -339
  66. package/infrastructure/integration.test.js +381 -0
  67. package/infrastructure/scripts/build-prisma-layer.js +50 -136
  68. package/infrastructure/scripts/build-prisma-layer.test.js +7 -128
  69. package/infrastructure/scripts/build-time-discovery.test.js +3 -18
  70. package/package.json +10 -12
  71. package/frigg-cli/__tests__/unit/commands/init.test.js +0 -688
  72. package/frigg-cli/__tests__/unit/commands/validate-wiring.test.js +0 -92
  73. package/frigg-cli/init-command/deployment-modes.js +0 -7
  74. package/frigg-cli/init-command/safe-path.js +0 -58
  75. package/frigg-cli/init-command/scaffold-dependencies.js +0 -202
  76. package/frigg-cli/install-command/app-definition.js +0 -174
  77. package/frigg-cli/install-command/resolve-module.js +0 -69
  78. package/frigg-cli/templates/backend/README.md +0 -267
  79. package/frigg-cli/templates/backend/env.example +0 -20
  80. package/frigg-cli/templates/backend/gitignore +0 -10
  81. package/frigg-cli/templates/backend/index.js +0 -114
  82. package/frigg-cli/templates/backend/infrastructure.js +0 -20
  83. package/frigg-cli/validate-command/__tests__/init-validation.test.js +0 -63
  84. package/frigg-cli/validate-command/__tests__/integrations-checks.test.js +0 -133
  85. package/frigg-cli/validate-command/__tests__/validate-app-definition.test.js +0 -443
  86. package/frigg-cli/validate-command/__tests__/validate-command.test.js +0 -262
  87. package/frigg-cli/validate-command/checks/config.js +0 -504
  88. package/frigg-cli/validate-command/checks/integrations.js +0 -274
  89. package/frigg-cli/validate-command/format-report.js +0 -58
  90. package/frigg-cli/validate-command/index.js +0 -107
  91. package/frigg-cli/validate-command/load-app-definition.js +0 -105
  92. package/frigg-cli/validate-command/schema-issues.js +0 -154
  93. package/frigg-cli/validate-command/validate-app-definition.js +0 -60
  94. package/infrastructure/__tests__/helpers/bundled-prisma-engine-excludes.js +0 -39
  95. package/infrastructure/__tests__/management-api-gateway-routes.test.js +0 -284
  96. package/infrastructure/__tests__/scaffold-default-infrastructure.test.js +0 -151
  97. package/infrastructure/app-definition-schema-contract.test.js +0 -634
  98. package/infrastructure/create-frigg-infrastructure.test.js +0 -51
  99. package/infrastructure/domains/database/migration-engines.js +0 -93
  100. package/infrastructure/domains/database/migration-engines.test.js +0 -142
  101. package/infrastructure/domains/shared/lambda-architectures.js +0 -113
  102. package/infrastructure/domains/shared/lambda-architectures.test.js +0 -164
@@ -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
 
@@ -16,12 +16,6 @@
16
16
  const { InfrastructureBuilder, ValidationResult } = require('../shared/base-builder');
17
17
  const { isScopedEnvironmentActive } = require('../shared/function-environments');
18
18
  const { nestedNodeModulesExcludes } = require('../shared/utilities/nested-node-modules');
19
- const {
20
- resolveLambdaArchitecture,
21
- PRISMA_ENGINES_PACKAGE_DIR,
22
- prismaEngineFileNames,
23
- foreignPrismaEngineExcludes,
24
- } = require('../shared/lambda-architectures');
25
19
  const { MigrationResourceResolver } = require('./migration-resolver');
26
20
  const { createEmptyDiscoveryResult, ResourceOwnership } = require('../shared/types');
27
21
 
@@ -245,9 +239,6 @@ class MigrationBuilder extends InfrastructureBuilder {
245
239
  async createFunctionDefinitions(result, usePrismaLayer = true, appDefinition = {}) {
246
240
  console.log(' 🔍 DEBUG: createFunctionDefinitions called');
247
241
  console.log(' 🔍 DEBUG: result.functions is:', typeof result.functions, result.functions);
248
- const architecture = resolveLambdaArchitecture(appDefinition);
249
- const engineExcludes = foreignPrismaEngineExcludes(architecture.name);
250
- const engines = prismaEngineFileNames(architecture.prismaBinaryTarget);
251
242
  // Migration WORKER package config (needs Prisma CLI WASM files)
252
243
  const migrationWorkerPackageConfig = {
253
244
  individually: true,
@@ -302,14 +293,12 @@ class MigrationBuilder extends InfrastructureBuilder {
302
293
  'node_modules/@friggframework/core/handlers/routers/integration-*.js',
303
294
  'node_modules/@friggframework/core/handlers/workers/integration-*.js',
304
295
 
305
- // Exclude the engines of every platform and architecture this
306
- // stack does not run on
296
+ // Exclude wrong OS binaries
307
297
  '**/query-engine-darwin*',
308
298
  '**/schema-engine-darwin*',
309
299
  '**/libquery_engine-darwin*',
310
300
  '**/*-darwin-arm64*',
311
301
  '**/*-darwin*',
312
- ...engineExcludes,
313
302
 
314
303
  // Migration worker DOES need Prisma CLI WASM files (for migrate deploy)
315
304
  // Only exclude runtime engine WASM (query engine internals)
@@ -396,14 +385,12 @@ class MigrationBuilder extends InfrastructureBuilder {
396
385
  'node_modules/@friggframework/core/handlers/routers/integration-*.js',
397
386
  'node_modules/@friggframework/core/handlers/workers/**',
398
387
 
399
- // Exclude the engines of every platform and architecture this
400
- // stack does not run on
388
+ // Exclude wrong OS binaries
401
389
  '**/query-engine-darwin*',
402
390
  '**/schema-engine-darwin*',
403
391
  '**/libquery_engine-darwin*',
404
392
  '**/*-darwin-arm64*',
405
393
  '**/*-darwin*',
406
- ...engineExcludes,
407
394
 
408
395
  // Router doesn't run migrations - exclude ALL WASM files
409
396
  '**/runtime/*.wasm',
@@ -451,12 +438,6 @@ class MigrationBuilder extends InfrastructureBuilder {
451
438
  environment: {
452
439
  // Ensure migration functions get DATABASE_URL from provider.environment
453
440
  // Note: Serverless will merge this with provider.environment
454
-
455
- // Pin the migrate CLI to the shipped engines. With these set,
456
- // Prisma neither downloads an engine at cold start (into the
457
- // read-only /var/task) nor picks another file.
458
- PRISMA_SCHEMA_ENGINE_BINARY: `/var/task/${PRISMA_ENGINES_PACKAGE_DIR}/${engines.schemaEngine}`,
459
- PRISMA_QUERY_ENGINE_LIBRARY: `/var/task/${PRISMA_ENGINES_PACKAGE_DIR}/${engines.queryEngineLibrary}`,
460
441
  },
461
442
  events: [
462
443
  {
@@ -322,61 +322,6 @@ describe('MigrationBuilder', () => {
322
322
  });
323
323
  });
324
324
 
325
- describe('Lambda architecture (architecture)', () => {
326
- const baseAppDefinition = { database: { postgres: { enable: true } } };
327
- const workerAndRouter = (result) => [
328
- result.functions.dbMigrationWorker,
329
- result.functions.dbMigrationRouter,
330
- ];
331
-
332
- it.each([
333
- [undefined, 'rhel-openssl-3.0.x', 'linux-arm64-openssl-3.0.x'],
334
- ['x86_64', 'rhel-openssl-3.0.x', 'linux-arm64-openssl-3.0.x'],
335
- ['arm64', 'linux-arm64-openssl-3.0.x', 'rhel-openssl-3.0.x'],
336
- ])(
337
- 'with architecture %s the worker and router ship only the %s engines',
338
- async (architecture, target, otherTarget) => {
339
- const result = await builder.build(
340
- { ...baseAppDefinition, ...(architecture && { architecture }) },
341
- {}
342
- );
343
-
344
- for (const fn of workerAndRouter(result)) {
345
- expect(fn.package.exclude).toEqual(
346
- expect.arrayContaining([
347
- '**/libquery_engine-debian*',
348
- '**/libquery_engine-linux-musl*',
349
- `**/libquery_engine-${otherTarget}*`,
350
- ])
351
- );
352
- expect(fn.package.exclude).not.toContain(`**/libquery_engine-${target}*`);
353
- }
354
- }
355
- );
356
-
357
- it.each([
358
- [undefined, 'rhel-openssl-3.0.x'],
359
- ['x86_64', 'rhel-openssl-3.0.x'],
360
- ['arm64', 'linux-arm64-openssl-3.0.x'],
361
- ])(
362
- 'with architecture %s the worker pins the migrate CLI to the shipped %s engines',
363
- async (architecture, target) => {
364
- const result = await builder.build(
365
- { ...baseAppDefinition, ...(architecture && { architecture }) },
366
- {}
367
- );
368
-
369
- expect(result.functions.dbMigrationWorker.environment).toEqual(
370
- expect.objectContaining({
371
- PRISMA_SCHEMA_ENGINE_BINARY: `/var/task/node_modules/@prisma/engines/schema-engine-${target}`,
372
- PRISMA_QUERY_ENGINE_LIBRARY: `/var/task/node_modules/@prisma/engines/libquery_engine-${target}.so.node`,
373
- })
374
- );
375
- expect(result.functions.dbMigrationRouter.environment.PRISMA_SCHEMA_ENGINE_BINARY).toBeUndefined();
376
- }
377
- );
378
- });
379
-
380
325
  describe('scoped environment (lambda.scopedEnvironment)', () => {
381
326
  beforeEach(() => {
382
327
  delete process.env.FRIGG_SKIP_AWS_DISCOVERY;
@@ -487,23 +432,23 @@ describe('MigrationBuilder nested node_modules (lambda.keepNestedNodeModules)',
487
432
  result.functions.dbMigrationRouter,
488
433
  ];
489
434
 
490
- it('keeps nested node_modules by default, still excluding nested Frigg copies', async () => {
435
+ it('excludes every nested node_modules by default', async () => {
491
436
  const result = await new MigrationBuilder().build(baseAppDefinition, {});
492
437
 
493
438
  for (const fn of workerAndRouter(result)) {
494
- expect(fn.package.exclude).not.toContain('node_modules/**/node_modules/**');
495
- expect(fn.package.exclude).toContain('node_modules/**/node_modules/@friggframework/**');
439
+ expect(fn.package.exclude).toContain('node_modules/**/node_modules/**');
496
440
  }
497
441
  });
498
442
 
499
- it('excludes every nested node_modules when the app opts out', async () => {
443
+ it('keeps nested node_modules when the app opts in, still excluding nested Frigg copies', async () => {
500
444
  const result = await new MigrationBuilder().build(
501
- { ...baseAppDefinition, lambda: { keepNestedNodeModules: false } },
445
+ { ...baseAppDefinition, lambda: { keepNestedNodeModules: true } },
502
446
  {}
503
447
  );
504
448
 
505
449
  for (const fn of workerAndRouter(result)) {
506
- expect(fn.package.exclude).toContain('node_modules/**/node_modules/**');
450
+ expect(fn.package.exclude).not.toContain('node_modules/**/node_modules/**');
451
+ expect(fn.package.exclude).toContain('node_modules/**/node_modules/@friggframework/**');
507
452
  }
508
453
  });
509
454
  });
@@ -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',
@@ -32,7 +32,6 @@ const {
32
32
  const {
33
33
  nestedNodeModulesExcludes,
34
34
  } = require('../shared/utilities/nested-node-modules');
35
- const { bundledPrismaEngineExcludes } = require('../shared/lambda-architectures');
36
35
  const {
37
36
  INTEGRATION_QUEUE_MAX_RECEIVE_COUNT,
38
37
  QUEUE_MAX_RECEIVE_COUNT_ENV,
@@ -269,7 +268,6 @@ class IntegrationBuilder extends InfrastructureBuilder {
269
268
  'node_modules/@friggframework/core/generated/**',
270
269
  ]
271
270
  : []),
272
- ...bundledPrismaEngineExcludes(appDefinition, usePrismaLayer),
273
271
 
274
272
  ...nestedNodeModulesExcludes(appDefinition, usePrismaLayer),
275
273
 
@@ -10,7 +10,6 @@ const {
10
10
  } = require('@friggframework/core/queues/queue-delivery');
11
11
  const { IntegrationBuilder } = require('./integration-builder');
12
12
  const { ValidationResult } = require('../shared/base-builder');
13
- const { itBundlesOnlyTheTargetPrismaEngine } = require('../../__tests__/helpers/bundled-prisma-engine-excludes');
14
13
 
15
14
  describe('IntegrationBuilder', () => {
16
15
  let integrationBuilder;
@@ -1086,21 +1085,6 @@ describe('IntegrationBuilder', () => {
1086
1085
  });
1087
1086
 
1088
1087
 
1089
- describe('IntegrationBuilder Lambda architecture with usePrismaLambdaLayer=false', () => {
1090
- const functionsOf = async (usePrismaLambdaLayer, architecture) => {
1091
- const result = await new IntegrationBuilder().build(
1092
- {
1093
- integrations: [{ Definition: { name: 'crm' } }],
1094
- usePrismaLambdaLayer,
1095
- ...(architecture && { architecture }),
1096
- },
1097
- {}
1098
- );
1099
- return Object.values(result.functions);
1100
- };
1101
- itBundlesOnlyTheTargetPrismaEngine(functionsOf);
1102
- });
1103
-
1104
1088
  describe('IntegrationBuilder nested node_modules (lambda.keepNestedNodeModules)', () => {
1105
1089
  const appDefinition = (lambda) => ({
1106
1090
  integrations: [{ Definition: { name: 'test', webhooks: true } }],
@@ -1109,24 +1093,24 @@ describe('IntegrationBuilder nested node_modules (lambda.keepNestedNodeModules)'
1109
1093
  const packagedFunctions = (result) =>
1110
1094
  Object.values(result.functions).filter((fn) => fn.package?.exclude);
1111
1095
 
1112
- it('keeps nested node_modules by default, still excluding nested Frigg copies', async () => {
1096
+ it('excludes every nested node_modules by default', async () => {
1113
1097
  const result = await new IntegrationBuilder().build(appDefinition(), {});
1114
1098
 
1115
1099
  expect(packagedFunctions(result).length).toBeGreaterThan(0);
1116
1100
  for (const fn of packagedFunctions(result)) {
1117
- expect(fn.package.exclude).not.toContain('node_modules/**/node_modules/**');
1118
- expect(fn.package.exclude).toContain('node_modules/**/node_modules/@friggframework/**');
1101
+ expect(fn.package.exclude).toContain('node_modules/**/node_modules/**');
1119
1102
  }
1120
1103
  });
1121
1104
 
1122
- it('excludes every nested node_modules when the app opts out', async () => {
1105
+ it('keeps nested node_modules when the app opts in, still excluding nested Frigg copies', async () => {
1123
1106
  const result = await new IntegrationBuilder().build(
1124
- appDefinition({ keepNestedNodeModules: false }),
1107
+ appDefinition({ keepNestedNodeModules: true }),
1125
1108
  {}
1126
1109
  );
1127
1110
 
1128
1111
  for (const fn of packagedFunctions(result)) {
1129
- expect(fn.package.exclude).toContain('node_modules/**/node_modules/**');
1112
+ expect(fn.package.exclude).not.toContain('node_modules/**/node_modules/**');
1113
+ expect(fn.package.exclude).toContain('node_modules/**/node_modules/@friggframework/**');
1130
1114
  }
1131
1115
  });
1132
1116
  });
@@ -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