@friggframework/devtools 2.0.0--canary.658.e11f3b0.0 → 2.0.0--canary.737.83b4e17.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 +115 -31
  2. package/frigg-cli/__tests__/unit/commands/build.test.js +3 -0
  3. package/frigg-cli/__tests__/unit/commands/deploy.test.js +33 -24
  4. package/frigg-cli/__tests__/unit/commands/doctor.test.js +10 -6
  5. package/frigg-cli/__tests__/unit/commands/generate-iam.test.js +18 -0
  6. package/frigg-cli/__tests__/unit/commands/init.test.js +688 -0
  7. package/frigg-cli/__tests__/unit/commands/install.test.js +601 -341
  8. package/frigg-cli/__tests__/unit/commands/ui.test.js +31 -30
  9. package/frigg-cli/__tests__/unit/commands/validate-wiring.test.js +92 -0
  10. package/frigg-cli/__tests__/unit/dependencies.test.js +6 -2
  11. package/frigg-cli/build-command/index.js +6 -0
  12. package/frigg-cli/deploy-command/index.js +6 -0
  13. package/frigg-cli/generate-command/index.js +1 -0
  14. package/frigg-cli/generate-iam-command.js +1 -0
  15. package/frigg-cli/index.js +22 -5
  16. package/frigg-cli/init-command/backend-first-handler.js +395 -551
  17. package/frigg-cli/init-command/deployment-modes.js +7 -0
  18. package/frigg-cli/init-command/index.js +82 -35
  19. package/frigg-cli/init-command/safe-path.js +58 -0
  20. package/frigg-cli/init-command/scaffold-dependencies.js +202 -0
  21. package/frigg-cli/install-command/app-definition.js +174 -0
  22. package/frigg-cli/install-command/commit-changes.js +40 -8
  23. package/frigg-cli/install-command/environment-variables.js +15 -0
  24. package/frigg-cli/install-command/index.js +96 -21
  25. package/frigg-cli/install-command/install-package.js +77 -4
  26. package/frigg-cli/install-command/integration-file.js +20 -11
  27. package/frigg-cli/install-command/resolve-module.js +69 -0
  28. package/frigg-cli/install-command/template.js +102 -75
  29. package/frigg-cli/install-command/validate-package.js +36 -4
  30. package/frigg-cli/package.json +1 -1
  31. package/frigg-cli/start-command/index.js +4 -0
  32. package/frigg-cli/start-command/start-command.test.js +3 -0
  33. package/frigg-cli/templates/backend/README.md +267 -0
  34. package/frigg-cli/templates/backend/env.example +20 -0
  35. package/frigg-cli/templates/backend/gitignore +10 -0
  36. package/frigg-cli/templates/backend/index.js +114 -0
  37. package/frigg-cli/templates/backend/infrastructure.js +20 -0
  38. package/frigg-cli/test/init-command.test.js +9 -2
  39. package/frigg-cli/validate-command/__tests__/init-validation.test.js +63 -0
  40. package/frigg-cli/validate-command/__tests__/integrations-checks.test.js +133 -0
  41. package/frigg-cli/validate-command/__tests__/validate-app-definition.test.js +443 -0
  42. package/frigg-cli/validate-command/__tests__/validate-command.test.js +262 -0
  43. package/frigg-cli/validate-command/checks/config.js +504 -0
  44. package/frigg-cli/validate-command/checks/integrations.js +274 -0
  45. package/frigg-cli/validate-command/format-report.js +58 -0
  46. package/frigg-cli/validate-command/index.js +107 -0
  47. package/frigg-cli/validate-command/load-app-definition.js +105 -0
  48. package/frigg-cli/validate-command/schema-issues.js +154 -0
  49. package/frigg-cli/validate-command/validate-app-definition.js +60 -0
  50. package/infrastructure/README.md +32 -5
  51. package/infrastructure/__tests__/helpers/bundled-prisma-engine-excludes.js +39 -0
  52. package/infrastructure/__tests__/management-api-gateway-routes.test.js +284 -0
  53. package/infrastructure/__tests__/postgres-config.test.js +245 -836
  54. package/infrastructure/__tests__/scaffold-default-infrastructure.test.js +151 -0
  55. package/infrastructure/__tests__/scoped-environment.test.js +3 -0
  56. package/infrastructure/__tests__/ssm-preload-node-options.test.js +3 -0
  57. package/infrastructure/__tests__/template-generation.test.js +39 -8
  58. package/infrastructure/app-definition-schema-contract.test.js +634 -0
  59. package/infrastructure/create-frigg-infrastructure.js +4 -1
  60. package/infrastructure/create-frigg-infrastructure.test.js +51 -0
  61. package/infrastructure/docs/POSTGRES-CONFIGURATION.md +80 -98
  62. package/infrastructure/domains/admin-scripts/admin-script-builder.js +8 -2
  63. package/infrastructure/domains/admin-scripts/admin-script-builder.test.js +52 -6
  64. package/infrastructure/domains/database/aurora-builder.js +13 -2
  65. package/infrastructure/domains/database/aurora-builder.test.js +22 -0
  66. package/infrastructure/domains/database/migration-builder.js +21 -2
  67. package/infrastructure/domains/database/migration-builder.test.js +61 -6
  68. package/infrastructure/domains/database/migration-engines.js +93 -0
  69. package/infrastructure/domains/database/migration-engines.test.js +142 -0
  70. package/infrastructure/domains/health/application/use-cases/__tests__/mismatch-analyzer-method-name.test.js +12 -8
  71. package/infrastructure/domains/health/application/use-cases/__tests__/repair-via-import-use-case.test.js +19 -7
  72. package/infrastructure/domains/health/application/use-cases/run-health-check-use-case.test.js +12 -8
  73. package/infrastructure/domains/health/domain/services/__tests__/import-progress-monitor.test.js +17 -18
  74. package/infrastructure/domains/health/domain/services/__tests__/update-progress-monitor.test.js +12 -2
  75. package/infrastructure/domains/health/infrastructure/adapters/__tests__/orphan-detection-relationship-analysis.test.js +8 -1
  76. package/infrastructure/domains/health/infrastructure/adapters/aws-property-reconciler.test.js +4 -2
  77. package/infrastructure/domains/health/infrastructure/adapters/aws-resource-detector.test.js +10 -0
  78. package/infrastructure/domains/integration/integration-builder.js +2 -0
  79. package/infrastructure/domains/integration/integration-builder.test.js +22 -6
  80. package/infrastructure/domains/networking/vpc-builder.js +18 -8
  81. package/infrastructure/domains/networking/vpc-builder.test.js +26 -12
  82. package/infrastructure/domains/security/iam-generator.js +112 -5
  83. package/infrastructure/domains/security/iam-generator.test.js +94 -0
  84. package/infrastructure/domains/shared/cloudformation-discovery.test.js +36 -6
  85. package/infrastructure/domains/shared/environment-builder.js +31 -5
  86. package/infrastructure/domains/shared/environment-builder.test.js +93 -7
  87. package/infrastructure/domains/shared/lambda-architectures.js +113 -0
  88. package/infrastructure/domains/shared/lambda-architectures.test.js +164 -0
  89. package/infrastructure/domains/shared/utilities/base-definition-factory.js +39 -3
  90. package/infrastructure/domains/shared/utilities/base-definition-factory.test.js +85 -5
  91. package/infrastructure/domains/shared/utilities/nested-node-modules.js +6 -5
  92. package/infrastructure/domains/shared/utilities/nested-node-modules.test.js +20 -26
  93. package/infrastructure/domains/shared/utilities/prisma-layer-manager.js +92 -12
  94. package/infrastructure/domains/shared/utilities/prisma-layer-manager.test.js +158 -6
  95. package/infrastructure/infrastructure-composer.js +12 -1
  96. package/infrastructure/infrastructure-composer.test.js +339 -794
  97. package/infrastructure/scripts/build-prisma-layer.js +136 -50
  98. package/infrastructure/scripts/build-prisma-layer.test.js +128 -7
  99. package/infrastructure/scripts/build-time-discovery.test.js +18 -3
  100. package/package.json +12 -10
  101. package/frigg-cli/index.test.js +0 -158
  102. package/infrastructure/integration.test.js +0 -381
@@ -322,6 +322,61 @@ 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
+
325
380
  describe('scoped environment (lambda.scopedEnvironment)', () => {
326
381
  beforeEach(() => {
327
382
  delete process.env.FRIGG_SKIP_AWS_DISCOVERY;
@@ -432,23 +487,23 @@ describe('MigrationBuilder nested node_modules (lambda.keepNestedNodeModules)',
432
487
  result.functions.dbMigrationRouter,
433
488
  ];
434
489
 
435
- it('excludes every nested node_modules by default', async () => {
490
+ it('keeps nested node_modules by default, still excluding nested Frigg copies', async () => {
436
491
  const result = await new MigrationBuilder().build(baseAppDefinition, {});
437
492
 
438
493
  for (const fn of workerAndRouter(result)) {
439
- expect(fn.package.exclude).toContain('node_modules/**/node_modules/**');
494
+ expect(fn.package.exclude).not.toContain('node_modules/**/node_modules/**');
495
+ expect(fn.package.exclude).toContain('node_modules/**/node_modules/@friggframework/**');
440
496
  }
441
497
  });
442
498
 
443
- it('keeps nested node_modules when the app opts in, still excluding nested Frigg copies', async () => {
499
+ it('excludes every nested node_modules when the app opts out', async () => {
444
500
  const result = await new MigrationBuilder().build(
445
- { ...baseAppDefinition, lambda: { keepNestedNodeModules: true } },
501
+ { ...baseAppDefinition, lambda: { keepNestedNodeModules: false } },
446
502
  {}
447
503
  );
448
504
 
449
505
  for (const fn of workerAndRouter(result)) {
450
- expect(fn.package.exclude).not.toContain('node_modules/**/node_modules/**');
451
- expect(fn.package.exclude).toContain('node_modules/**/node_modules/@friggframework/**');
506
+ expect(fn.package.exclude).toContain('node_modules/**/node_modules/**');
452
507
  }
453
508
  });
454
509
  });
@@ -0,0 +1,93 @@
1
+ /**
2
+ * Migration worker engines
3
+ *
4
+ * Domain Layer - Hexagonal Architecture
5
+ *
6
+ * The migration worker runs the Prisma CLI, which needs the schema engine
7
+ * and the query engine library for the Lambda architecture it runs on. Both
8
+ * ship from node_modules/@prisma/engines/, where the @prisma/engines
9
+ * postinstall put the deploy host's own engines. This fetches the deployed
10
+ * architecture's pair before packaging, and fails packaging when either is
11
+ * still missing, so a worker can never try to download an engine into the
12
+ * read-only /var/task at cold start.
13
+ */
14
+
15
+ const fs = require('fs');
16
+ const path = require('path');
17
+ const { execFileSync } = require('child_process');
18
+ const { prismaEngineFileNames, PRISMA_ENGINES_PACKAGE_DIR } = require('../shared/lambda-architectures');
19
+
20
+ function resolveEnginesDir(cwd) {
21
+ const enginesDir = path.join(cwd, PRISMA_ENGINES_PACKAGE_DIR);
22
+ if (!fs.existsSync(path.join(enginesDir, 'scripts', 'postinstall.js'))) {
23
+ throw new Error(
24
+ `@prisma/engines was not found at ${enginesDir}.\n` +
25
+ 'The app must have prisma installed in its own node_modules, not only in a hoisted parent: ' +
26
+ 'the migration worker ships its engines from the app\'s node_modules.'
27
+ );
28
+ }
29
+ return enginesDir;
30
+ }
31
+
32
+ /**
33
+ * Runs the @prisma/engines postinstall for one target. It downloads only
34
+ * the engines that are missing, so the host's own engines stay. The host's
35
+ * pinned engine paths are hidden from it: with them set, the postinstall
36
+ * skips those engines instead of downloading them.
37
+ */
38
+ function runEnginesPostinstall({ enginesDir, prismaBinaryTarget }) {
39
+ const hostEnv = { ...process.env };
40
+ delete hostEnv.PRISMA_SCHEMA_ENGINE_BINARY;
41
+ delete hostEnv.PRISMA_QUERY_ENGINE_LIBRARY;
42
+ execFileSync(
43
+ process.execPath,
44
+ [path.join(enginesDir, 'scripts', 'postinstall.js')],
45
+ {
46
+ cwd: enginesDir,
47
+ stdio: 'inherit',
48
+ env: { ...hostEnv, PRISMA_CLI_BINARY_TARGETS: prismaBinaryTarget },
49
+ }
50
+ );
51
+ }
52
+
53
+ /**
54
+ * @param {Object} options
55
+ * @param {string} options.prismaBinaryTarget - The engine the deployed architecture loads
56
+ * @param {string} [options.cwd] - The app root
57
+ * @param {string} [options.enginesDir] - node_modules/@prisma/engines of the app
58
+ * @param {Function} [options.fetchEngines] - Fetches the target's engines into enginesDir
59
+ * @throws {Error} When either engine is missing after the fetch
60
+ */
61
+ async function ensureMigrationEngines({
62
+ prismaBinaryTarget,
63
+ cwd = process.cwd(),
64
+ enginesDir = resolveEnginesDir(cwd),
65
+ fetchEngines = runEnginesPostinstall,
66
+ }) {
67
+ const engineNames = Object.values(prismaEngineFileNames(prismaBinaryTarget));
68
+ const missing = () =>
69
+ engineNames.filter((name) => !fs.existsSync(path.join(enginesDir, name)));
70
+
71
+ if (missing().length === 0) {
72
+ console.log(`✓ Prisma ${prismaBinaryTarget} migration engines present in ${enginesDir}`);
73
+ return;
74
+ }
75
+
76
+ console.log(
77
+ `📦 Fetching ${missing().join(', ')} (Prisma ${prismaBinaryTarget}) into ${enginesDir}...`
78
+ );
79
+ fetchEngines({ enginesDir, prismaBinaryTarget });
80
+
81
+ const stillMissing = missing();
82
+ if (stillMissing.length > 0) {
83
+ throw new Error(
84
+ `Prisma migration engines for ${prismaBinaryTarget} are missing after the fetch: ` +
85
+ `${stillMissing.join(', ')} (in ${enginesDir}).\n` +
86
+ "The deploy host must reach Prisma's engine CDN (binaries.prisma.sh) at package time."
87
+ );
88
+ }
89
+ }
90
+
91
+ module.exports = {
92
+ ensureMigrationEngines,
93
+ };
@@ -0,0 +1,142 @@
1
+ const fs = require('fs');
2
+ const os = require('os');
3
+ const path = require('path');
4
+ const { ensureMigrationEngines } = require('./migration-engines');
5
+
6
+ describe('ensureMigrationEngines()', () => {
7
+ const target = 'linux-arm64-openssl-3.0.x';
8
+ const schemaEngine = `schema-engine-${target}`;
9
+ const queryEngineLibrary = `libquery_engine-${target}.so.node`;
10
+ let enginesDir;
11
+
12
+ const writeEngines = (...names) => {
13
+ for (const name of names) {
14
+ fs.writeFileSync(path.join(enginesDir, name), '');
15
+ }
16
+ };
17
+
18
+ beforeEach(() => {
19
+ enginesDir = fs.mkdtempSync(path.join(os.tmpdir(), 'frigg-prisma-engines-'));
20
+ });
21
+
22
+ afterEach(() => {
23
+ fs.rmSync(enginesDir, { recursive: true, force: true });
24
+ });
25
+
26
+ it('fetches nothing when both engines for the target are already present', async () => {
27
+ writeEngines(schemaEngine, queryEngineLibrary);
28
+ const fetchEngines = jest.fn();
29
+
30
+ await ensureMigrationEngines({ prismaBinaryTarget: target, enginesDir, fetchEngines });
31
+
32
+ expect(fetchEngines).not.toHaveBeenCalled();
33
+ });
34
+
35
+ it('fetches the target engines into the engines directory when one is missing', async () => {
36
+ writeEngines(schemaEngine);
37
+ const fetchEngines = jest.fn(({ enginesDir: dir }) => {
38
+ fs.writeFileSync(path.join(dir, queryEngineLibrary), '');
39
+ });
40
+
41
+ await ensureMigrationEngines({ prismaBinaryTarget: target, enginesDir, fetchEngines });
42
+
43
+ expect(fetchEngines).toHaveBeenCalledWith({ enginesDir, prismaBinaryTarget: target });
44
+ });
45
+
46
+ it.each([
47
+ ['the schema engine', [queryEngineLibrary], schemaEngine],
48
+ ['the query engine library', [schemaEngine], queryEngineLibrary],
49
+ ['both engines', [], `${schemaEngine}, ${queryEngineLibrary}`],
50
+ ])('fails packaging naming %s when the fetch leaves it missing', async (_, present, missing) => {
51
+ writeEngines(...present);
52
+ const fetchEngines = jest.fn();
53
+
54
+ await expect(
55
+ ensureMigrationEngines({ prismaBinaryTarget: target, enginesDir, fetchEngines })
56
+ ).rejects.toThrow(missing);
57
+ });
58
+
59
+ describe('resolving the engines directory from cwd', () => {
60
+ let root;
61
+
62
+ const installEngines = (dir) => {
63
+ const engines = path.join(dir, 'node_modules', '@prisma', 'engines');
64
+ fs.mkdirSync(path.join(engines, 'scripts'), { recursive: true });
65
+ fs.writeFileSync(path.join(engines, 'scripts', 'postinstall.js'), '');
66
+ return engines;
67
+ };
68
+
69
+ beforeEach(() => {
70
+ root = fs.mkdtempSync(path.join(os.tmpdir(), 'frigg-app-root-'));
71
+ });
72
+
73
+ afterEach(() => {
74
+ fs.rmSync(root, { recursive: true, force: true });
75
+ });
76
+
77
+ it("uses the engines in the app's own node_modules", async () => {
78
+ const appDir = path.join(root, 'app');
79
+ const appEngines = installEngines(appDir);
80
+ fs.writeFileSync(path.join(appEngines, schemaEngine), '');
81
+ fs.writeFileSync(path.join(appEngines, queryEngineLibrary), '');
82
+ const fetchEngines = jest.fn();
83
+
84
+ await ensureMigrationEngines({ prismaBinaryTarget: target, cwd: appDir, fetchEngines });
85
+
86
+ expect(fetchEngines).not.toHaveBeenCalled();
87
+ });
88
+
89
+ it('fails with a readable error when only a parent directory has the engines', async () => {
90
+ installEngines(root);
91
+ const appDir = path.join(root, 'app');
92
+ fs.mkdirSync(appDir);
93
+ const fetchEngines = jest.fn();
94
+
95
+ const failure = ensureMigrationEngines({
96
+ prismaBinaryTarget: target,
97
+ cwd: appDir,
98
+ fetchEngines,
99
+ });
100
+
101
+ await expect(failure).rejects.toThrow(/prisma.*own node_modules.*hoisted parent/is);
102
+ await expect(failure).rejects.not.toHaveProperty('code', 'MODULE_NOT_FOUND');
103
+ expect(fetchEngines).not.toHaveBeenCalled();
104
+ });
105
+ });
106
+
107
+ describe('running the @prisma/engines postinstall', () => {
108
+ const pinnedEngineVars = ['PRISMA_SCHEMA_ENGINE_BINARY', 'PRISMA_QUERY_ENGINE_LIBRARY'];
109
+ let appDir;
110
+ let seenEnvPath;
111
+
112
+ beforeEach(() => {
113
+ appDir = fs.mkdtempSync(path.join(os.tmpdir(), 'frigg-app-'));
114
+ const engines = path.join(appDir, 'node_modules', '@prisma', 'engines');
115
+ fs.mkdirSync(path.join(engines, 'scripts'), { recursive: true });
116
+ seenEnvPath = path.join(appDir, 'seen-env.json');
117
+ fs.writeFileSync(
118
+ path.join(engines, 'scripts', 'postinstall.js'),
119
+ `const fs = require('fs');
120
+ fs.writeFileSync(${JSON.stringify(seenEnvPath)}, JSON.stringify(process.env));
121
+ for (const name of ${JSON.stringify([schemaEngine, queryEngineLibrary])}) fs.writeFileSync(name, '');`
122
+ );
123
+ });
124
+
125
+ afterEach(() => {
126
+ fs.rmSync(appDir, { recursive: true, force: true });
127
+ pinnedEngineVars.forEach((name) => delete process.env[name]);
128
+ });
129
+
130
+ it("hides the host's pinned engine paths, so the postinstall does not skip the download", async () => {
131
+ pinnedEngineVars.forEach((name) => {
132
+ process.env[name] = `/host/${name}`;
133
+ });
134
+
135
+ await ensureMigrationEngines({ prismaBinaryTarget: target, cwd: appDir });
136
+
137
+ const seenEnv = JSON.parse(fs.readFileSync(seenEnvPath, 'utf-8'));
138
+ expect(seenEnv.PRISMA_CLI_BINARY_TARGETS).toBe(target);
139
+ pinnedEngineVars.forEach((name) => expect(seenEnv).not.toHaveProperty(name));
140
+ });
141
+ });
142
+ });
@@ -84,10 +84,12 @@ describe('MismatchAnalyzer Method Name Bug Fix', () => {
84
84
  driftStatus: 'MODIFIED',
85
85
  propertyDifferences: [
86
86
  {
87
- propertyPath: 'BucketEncryption.Rules[0].BucketKeyEnabled',
88
- expectedValue: true,
89
- actualValue: false,
90
- differenceType: 'NOT_EQUAL',
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',
91
93
  },
92
94
  ],
93
95
  });
@@ -144,10 +146,12 @@ describe('MismatchAnalyzer Method Name Bug Fix', () => {
144
146
  actualProperties: { BucketEncryption: { enabled: false } },
145
147
  propertyDifferences: [
146
148
  {
147
- propertyPath: 'BucketEncryption.enabled',
148
- expectedValue: true,
149
- actualValue: false,
150
- differenceType: 'NOT_EQUAL',
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',
151
155
  },
152
156
  ],
153
157
  });
@@ -548,7 +548,11 @@ describe('RepairViaImportUseCase - importWithLogicalIdMapping', () => {
548
548
  expect(result.unmappedCount).toBe(2);
549
549
  });
550
550
 
551
- it('should generate warnings for multiple resources of same type', async () => {
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.
552
556
  // Arrange
553
557
  const stackIdentifier = {
554
558
  stackName: 'acme-integrations-dev',
@@ -588,7 +592,7 @@ describe('RepairViaImportUseCase - importWithLogicalIdMapping', () => {
588
592
  const buildTemplate = { resources: {} };
589
593
  const deployedTemplate = { resources: {} };
590
594
 
591
- // Three VPCs mapped
595
+ // Three VPCs all mapped to the same logical ID
592
596
  const mappings = [
593
597
  {
594
598
  logicalId: 'FriggVPC',
@@ -598,14 +602,14 @@ describe('RepairViaImportUseCase - importWithLogicalIdMapping', () => {
598
602
  confidence: 'high',
599
603
  },
600
604
  {
601
- logicalId: 'FriggVPC2',
605
+ logicalId: 'FriggVPC',
602
606
  physicalId: 'vpc-456',
603
607
  resourceType: 'AWS::EC2::VPC',
604
608
  matchMethod: 'contained-resources',
605
609
  confidence: 'high',
606
610
  },
607
611
  {
608
- logicalId: 'FriggVPC3',
612
+ logicalId: 'FriggVPC',
609
613
  physicalId: 'vpc-789',
610
614
  resourceType: 'AWS::EC2::VPC',
611
615
  matchMethod: 'tag',
@@ -628,13 +632,21 @@ describe('RepairViaImportUseCase - importWithLogicalIdMapping', () => {
628
632
  });
629
633
 
630
634
  // Assert
635
+ // Nothing is referenced by the deployed template, so the first candidate
636
+ // is kept and the other two are reported as duplicates.
631
637
  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);
632
641
  expect(result.warnings).toHaveLength(1);
633
642
  expect(result.warnings[0].type).toBe('MULTIPLE_RESOURCES');
634
643
  expect(result.warnings[0].resourceType).toBe('AWS::EC2::VPC');
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);
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
+ ]);
638
650
  });
639
651
 
640
652
  it('should include build and deployed template paths in result', async () => {
@@ -133,10 +133,12 @@ describe('RunHealthCheckUseCase', () => {
133
133
  driftStatus: 'MODIFIED',
134
134
  propertyDifferences: [
135
135
  {
136
- propertyPath: 'Properties.EnableDnsSupport',
137
- expectedValue: true,
138
- actualValue: false,
139
- differenceType: 'NOT_EQUAL',
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',
140
142
  },
141
143
  ],
142
144
  });
@@ -308,10 +310,12 @@ describe('RunHealthCheckUseCase', () => {
308
310
  driftStatus: 'MODIFIED',
309
311
  propertyDifferences: [
310
312
  {
311
- propertyPath: 'Properties.EnableDnsSupport',
312
- expectedValue: true,
313
- actualValue: false,
314
- differenceType: 'NOT_EQUAL',
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',
315
319
  },
316
320
  ],
317
321
  });
@@ -412,24 +412,23 @@ describe('ImportProgressMonitor', () => {
412
412
 
413
413
  mockCloudFormationRepository.getStackStatus.mockResolvedValue('IMPORT_IN_PROGRESS');
414
414
 
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');
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;
433
432
  });
434
433
 
435
434
  it('should filter events by resourceLogicalIds', async () => {
@@ -302,9 +302,14 @@ 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
+
305
310
  await jest.advanceTimersByTimeAsync(2000);
306
311
 
307
- await expect(monitorPromise).rejects.toThrow('Update operation failed and rolled back');
312
+ await assertion;
308
313
  });
309
314
  });
310
315
 
@@ -334,10 +339,15 @@ describe('UpdateProgressMonitor', () => {
334
339
  onProgress: onProgressCallback,
335
340
  });
336
341
 
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
+
337
347
  // Advance past 5 minute timeout (300000ms)
338
348
  await jest.advanceTimersByTimeAsync(300000 + 2000);
339
349
 
340
- await expect(monitorPromise).rejects.toThrow('Update operation timed out');
350
+ await assertion;
341
351
  });
342
352
  });
343
353
 
@@ -82,7 +82,14 @@ jest.mock('@aws-sdk/client-kms', () => ({
82
82
  ListAliasesCommand: jest.fn(),
83
83
  }));
84
84
 
85
- describe('Orphan Detection with Relationship Analysis (TDD)', () => {
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)', () => {
86
93
  let detector;
87
94
  let mockEC2Send;
88
95
  let mockRDSSend;
@@ -447,7 +447,9 @@ describe('AWSPropertyReconciler', () => {
447
447
  );
448
448
 
449
449
  expect(strategy.supportsTemplateUpdate).toBe(true);
450
- expect(strategy.supportsResourceUpdate).toBe(false);
450
+ // Lambda supports direct resource-mode reconciliation
451
+ // (UpdateFunctionConfiguration) since 6a0bba7b; template is still preferred.
452
+ expect(strategy.supportsResourceUpdate).toBe(true);
451
453
  expect(strategy.recommendedMode).toBe('template');
452
454
  expect(strategy.limitations).toContain(
453
455
  'VpcConfig changes may take several minutes to propagate'
@@ -659,7 +661,7 @@ describe('AWSPropertyReconciler', () => {
659
661
 
660
662
  expect(strategy).toEqual({
661
663
  supportsTemplateUpdate: true,
662
- supportsResourceUpdate: false,
664
+ supportsResourceUpdate: true, // resource mode via UpdateFunctionConfiguration
663
665
  recommendedMode: 'template',
664
666
  limitations: expect.arrayContaining([
665
667
  'VpcConfig changes may take several minutes to propagate',
@@ -441,6 +441,16 @@ 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
+
444
454
  it('should find orphaned RDS DBCluster with frigg:stack tag', async () => {
445
455
  const stackIdentifier = new StackIdentifier({
446
456
  stackName: 'my-app-prod',
@@ -32,6 +32,7 @@ const {
32
32
  const {
33
33
  nestedNodeModulesExcludes,
34
34
  } = require('../shared/utilities/nested-node-modules');
35
+ const { bundledPrismaEngineExcludes } = require('../shared/lambda-architectures');
35
36
  const {
36
37
  INTEGRATION_QUEUE_MAX_RECEIVE_COUNT,
37
38
  QUEUE_MAX_RECEIVE_COUNT_ENV,
@@ -268,6 +269,7 @@ class IntegrationBuilder extends InfrastructureBuilder {
268
269
  'node_modules/@friggframework/core/generated/**',
269
270
  ]
270
271
  : []),
272
+ ...bundledPrismaEngineExcludes(appDefinition, usePrismaLayer),
271
273
 
272
274
  ...nestedNodeModulesExcludes(appDefinition, usePrismaLayer),
273
275