@friggframework/devtools 2.0.0--canary.682.451c957.0 → 2.0.0--canary.666.89f6545.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 (82) 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/__tests__/management-api-gateway-routes.test.js +40 -94
  51. package/infrastructure/__tests__/postgres-config.test.js +241 -835
  52. package/infrastructure/__tests__/scaffold-default-infrastructure.test.js +148 -0
  53. package/infrastructure/__tests__/template-generation.test.js +36 -8
  54. package/infrastructure/app-definition-schema-contract.test.js +629 -0
  55. package/infrastructure/create-frigg-infrastructure.js +4 -1
  56. package/infrastructure/create-frigg-infrastructure.test.js +51 -0
  57. package/infrastructure/docs/POSTGRES-CONFIGURATION.md +80 -98
  58. package/infrastructure/domains/admin-scripts/admin-script-builder.js +6 -2
  59. package/infrastructure/domains/admin-scripts/admin-script-builder.test.js +30 -0
  60. package/infrastructure/domains/database/aurora-builder.js +13 -2
  61. package/infrastructure/domains/database/aurora-builder.test.js +22 -0
  62. package/infrastructure/domains/health/application/use-cases/__tests__/mismatch-analyzer-method-name.test.js +12 -8
  63. package/infrastructure/domains/health/application/use-cases/__tests__/repair-via-import-use-case.test.js +19 -7
  64. package/infrastructure/domains/health/application/use-cases/run-health-check-use-case.test.js +12 -8
  65. package/infrastructure/domains/health/domain/services/__tests__/import-progress-monitor.test.js +17 -18
  66. package/infrastructure/domains/health/domain/services/__tests__/update-progress-monitor.test.js +12 -2
  67. package/infrastructure/domains/health/infrastructure/adapters/__tests__/orphan-detection-relationship-analysis.test.js +8 -1
  68. package/infrastructure/domains/health/infrastructure/adapters/aws-property-reconciler.test.js +4 -2
  69. package/infrastructure/domains/health/infrastructure/adapters/aws-resource-detector.test.js +10 -0
  70. package/infrastructure/domains/networking/vpc-builder.js +18 -8
  71. package/infrastructure/domains/networking/vpc-builder.test.js +26 -12
  72. package/infrastructure/domains/security/iam-generator.js +112 -5
  73. package/infrastructure/domains/security/iam-generator.test.js +94 -0
  74. package/infrastructure/domains/shared/cloudformation-discovery.test.js +36 -6
  75. package/infrastructure/domains/shared/utilities/base-definition-factory.js +35 -27
  76. package/infrastructure/domains/shared/utilities/base-definition-factory.test.js +22 -49
  77. package/infrastructure/infrastructure-composer.test.js +268 -794
  78. package/infrastructure/scripts/build-prisma-layer.test.js +28 -7
  79. package/infrastructure/scripts/build-time-discovery.test.js +18 -3
  80. package/package.json +10 -8
  81. package/frigg-cli/index.test.js +0 -158
  82. package/infrastructure/integration.test.js +0 -381
@@ -8,25 +8,49 @@ Frigg Framework supports automatic provisioning of Amazon Aurora Serverless v2 P
8
8
 
9
9
  ### Key Features
10
10
 
11
- - **Aurora Serverless v2**: Cost-efficient auto-scaling database (0.5-1.0 ACU default)
11
+ - **Aurora Serverless v2**: Cost-efficient auto-scaling database (0.5-4 ACU default)
12
12
  - **VPC Integration**: Deployed in same private subnets as Lambda functions
13
13
  - **Secrets Manager**: Automatic credential management and rotation
14
- - **Three Management Modes**: discover, create-new, use-existing
14
+ - **Management Modes**: discover, managed, use-existing, external (bring your own `DATABASE_URL`)
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
+
18
38
  ---
19
39
 
20
40
  ## Configuration Schema
21
41
 
22
42
  ### App Definition Structure
23
43
 
44
+ These are the keys the Aurora builder reads (see `database.postgres` in
45
+ `packages/schemas/schemas/app-definition.schema.json`). `frigg validate`
46
+ rejects any other key under `database.postgres`.
47
+
24
48
  ```javascript
25
49
  // backend/index.js
26
50
  const appDefinition = {
27
51
  name: 'my-frigg-app',
28
52
 
29
- // Enable VPC deployment (required for Aurora)
53
+ // VPC Configuration (required for Aurora)
30
54
  vpc: {
31
55
  enable: true,
32
56
  },
@@ -36,34 +60,24 @@ const appDefinition = {
36
60
  postgres: {
37
61
  enable: true,
38
62
 
39
- // Management mode: 'discover' | 'create-new' | 'use-existing'
63
+ // 'discover' (also when omitted) | 'managed' | 'use-existing'
64
+ // Ignored when managementMode is 'managed' or 'existing'.
40
65
  management: 'discover',
41
66
 
42
- // Basic Configuration
43
- databaseName: 'frigg_db',
44
- masterUsername: 'frigg_admin',
45
-
46
- // Engine Configuration
47
- engine: 'aurora-postgresql',
48
- engineVersion: '15.3',
49
-
50
- // Scaling Configuration (Aurora Serverless v2)
51
- scaling: {
52
- minCapacity: 0.5, // ACUs (0.5 = ~1GB RAM, ~$43/month)
53
- maxCapacity: 1.0, // ACUs (1.0 = ~2GB RAM, ~$87/month)
54
- },
67
+ database: 'frigg', // database name (default 'frigg')
68
+ username: 'postgres', // master user (default 'postgres')
69
+ engineVersion: '15.13', // Aurora PostgreSQL version (default '15.13')
55
70
 
56
- // Backup Configuration
57
- backupRetentionDays: 7,
58
- preferredBackupWindow: '03:00-04:00',
71
+ // Aurora Serverless v2 capacity, in ACUs (0.5-128)
72
+ minCapacity: 0.5, // default 0.5
73
+ maxCapacity: 4, // default 4
59
74
 
60
- // Security & Advanced
61
- deletionProtection: true,
62
- enablePerformanceInsights: false,
75
+ publiclyAccessible: false, // default false (private subnets)
76
+ autoCreateCredentials: false, // discover only: create a secret for a discovered cluster
63
77
 
64
- // For use-existing mode
65
- clusterIdentifier: 'my-existing-cluster',
66
- secretArn: 'arn:aws:secretsmanager:...',
78
+ // use-existing only
79
+ // endpoint: 'mydb.cluster-abc123.us-east-1.rds.amazonaws.com',
80
+ // port: 5432,
67
81
  }
68
82
  }
69
83
  };
@@ -73,13 +87,17 @@ module.exports = {
73
87
  };
74
88
  ```
75
89
 
90
+ Backup retention (7 days), the backup and maintenance windows and deletion
91
+ settings are fixed by the builder and are not configurable through the app
92
+ definition.
93
+
76
94
  ---
77
95
 
78
96
  ## Management Modes
79
97
 
80
98
  ### 1. Discover Mode (Default)
81
99
 
82
- Automatically discovers existing Aurora clusters or creates new one if none found.
100
+ Discovers an existing Aurora cluster, or creates a new one in the stack if none is found.
83
101
 
84
102
  ```javascript
85
103
  database: {
@@ -100,63 +118,56 @@ database: {
100
118
 
101
119
  ---
102
120
 
103
- ### 2. Create-New Mode
121
+ ### 2. Managed Mode
104
122
 
105
- Always creates a new Aurora cluster, even if existing clusters are found.
123
+ Creates the cluster, instance, subnet group and secret in the stack.
106
124
 
107
125
  ```javascript
108
126
  database: {
109
127
  postgres: {
110
128
  enable: true,
111
- management: 'create-new',
112
-
113
- // Customization options
114
- databaseName: 'my_app_db',
115
- masterUsername: 'admin',
116
- engineVersion: '15.3',
117
- scaling: {
118
- minCapacity: 1.0,
119
- maxCapacity: 2.0,
120
- },
121
- backupRetentionDays: 14,
122
- deletionProtection: true,
129
+ management: 'managed',
130
+ minCapacity: 1,
131
+ maxCapacity: 2,
123
132
  }
124
133
  }
125
134
  ```
126
135
 
136
+ With the top-level `managementMode: 'managed'` (and `vpcIsolation: 'isolated'`),
137
+ Frigg manages the database per stage and `database.postgres.management` is ignored.
138
+
127
139
  **Best For**: Production environments where you want dedicated database resources.
128
140
 
129
141
  ---
130
142
 
131
143
  ### 3. Use-Existing Mode
132
144
 
133
- Uses a specific existing Aurora cluster by identifier.
145
+ Connects to an existing PostgreSQL endpoint without creating database resources.
134
146
 
135
147
  ```javascript
136
148
  database: {
137
149
  postgres: {
138
150
  enable: true,
139
151
  management: 'use-existing',
140
-
141
- // Required: existing cluster identifier
142
- clusterIdentifier: 'my-existing-aurora-cluster',
143
-
144
- // Optional: secret ARN (discovered if not provided)
145
- secretArn: 'arn:aws:secretsmanager:us-east-1:123456789012:secret:my-db-secret',
146
-
147
- // Database name to connect to
148
- databaseName: 'frigg_db',
152
+ endpoint: 'my-cluster.cluster-abc123.us-east-1.rds.amazonaws.com', // required
153
+ port: 5432,
154
+ database: 'frigg_db',
155
+ username: 'frigg_admin',
149
156
  }
150
157
  }
151
158
  ```
152
159
 
160
+ To use an existing cluster by identifier instead, use the ownership form:
161
+ `ownership: { cluster: 'external', instance: 'external' }` with
162
+ `external: { clusterIdentifier, instanceIdentifier, secretArn }`.
163
+
153
164
  **Best For**: Shared database scenarios or when you manage Aurora outside of Frigg.
154
165
 
155
166
  ---
156
167
 
157
168
  ## Created AWS Resources
158
169
 
159
- When provisioning Aurora (`create-new` or `discover` mode without existing cluster), Frigg creates:
170
+ When provisioning Aurora (`managed`, or `discover` mode without an existing cluster), Frigg creates:
160
171
 
161
172
  ### 1. RDS DB Subnet Group
162
173
  - **Name**: `{service}-{stage}-db-subnet-group`
@@ -221,17 +232,15 @@ database: {
221
232
  database: {
222
233
  postgres: {
223
234
  enable: true,
224
- scaling: {
225
- minCapacity: 1.0, // Higher baseline for production
226
- maxCapacity: 4.0, // Handle traffic spikes
227
- },
228
- backupRetentionDays: 30, // Longer retention
229
- enablePerformanceInsights: true, // Monitoring
230
- deletionProtection: true, // Prevent accidental deletion
235
+ minCapacity: 1, // Higher baseline for production
236
+ maxCapacity: 4, // Handle traffic spikes
231
237
  }
232
238
  }
233
239
  ```
234
240
 
241
+ Backup retention, Performance Insights and deletion protection are not
242
+ configurable through the app definition; change them on the cluster.
243
+
235
244
  **Estimated Monthly Costs**:
236
245
  - **Baseline**: $87/month (1.0 ACU minimum)
237
246
  - **Peak Traffic**: $348/month (4.0 ACU maximum)
@@ -276,15 +285,9 @@ const users = await prismaClient.user.findMany();
276
285
 
277
286
  ### 4. Deletion Protection
278
287
 
279
- ```javascript
280
- database: {
281
- postgres: {
282
- deletionProtection: true, // Prevents accidental deletion
283
- }
284
- }
285
- ```
286
-
287
- **Important**: When enabled, you must manually disable deletion protection in AWS console before stack deletion.
288
+ Deletion protection is not configurable through the app definition. Enable it
289
+ on the cluster in the AWS console (or with the AWS CLI); you must then disable
290
+ it before deleting the stack.
288
291
 
289
292
  ---
290
293
 
@@ -384,7 +387,7 @@ DB_TYPE=postgresql
384
387
  database: {
385
388
  postgres: {
386
389
  enable: true,
387
- management: 'create-new',
390
+ management: 'managed',
388
391
  }
389
392
  }
390
393
  ```
@@ -411,7 +414,7 @@ DB_TYPE=postgresql
411
414
  database: {
412
415
  postgres: {
413
416
  enable: true,
414
- management: 'create-new',
417
+ management: 'managed',
415
418
  }
416
419
  }
417
420
  ```
@@ -456,13 +459,13 @@ DB_TYPE=postgresql
456
459
 
457
460
  **Error**:
458
461
  ```
459
- No Aurora cluster found in discovery mode. Set management to "create-new"...
462
+ No Aurora cluster found in discovery mode. Set management to "managed" or provide endpoint with "use-existing".
460
463
  ```
461
464
 
462
465
  **Solution**:
463
466
  1. Check VPC is enabled: `vpc.enable: true`
464
- 2. Set management mode: `management: 'create-new'`
465
- 3. Or provide cluster identifier: `clusterIdentifier: 'my-cluster'`
467
+ 2. Set management mode: `management: 'managed'`
468
+ 3. Or connect to a known endpoint: `management: 'use-existing'`, `endpoint: '...'`
466
469
 
467
470
  ---
468
471
 
@@ -544,41 +547,20 @@ Cannot create Aurora cluster: InsufficientDBInstanceCapacity
544
547
 
545
548
  ## Advanced Configuration
546
549
 
547
- ### Custom Backup Window
548
-
549
- ```javascript
550
- database: {
551
- postgres: {
552
- enable: true,
553
- backupRetentionDays: 30,
554
- preferredBackupWindow: '02:00-03:00', // UTC
555
- }
556
- }
557
- ```
558
-
559
- ### Enhanced Monitoring
560
-
561
- ```javascript
562
- database: {
563
- postgres: {
564
- enable: true,
565
- enablePerformanceInsights: true,
566
- // Performance Insights retention: 7 days (default) or 731 days
567
- }
568
- }
569
- ```
570
-
571
550
  ### Custom Engine Version
572
551
 
573
552
  ```javascript
574
553
  database: {
575
554
  postgres: {
576
555
  enable: true,
577
- engineVersion: '14.6', // Default: 15.3
556
+ engineVersion: '16.4', // Default: 15.13
578
557
  }
579
558
  }
580
559
  ```
581
560
 
561
+ The backup window, backup retention and Performance Insights are set by the
562
+ builder and are not configurable through the app definition.
563
+
582
564
  ### Read Replicas (Not Supported Yet)
583
565
 
584
566
  Frigg currently provisions a single Aurora instance. For read replicas:
@@ -141,10 +141,12 @@ 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';
144
146
  result.resources.AdminScriptQueue = {
145
147
  Type: 'AWS::SQS::Queue',
146
148
  Properties: {
147
- QueueName: '${self:service}-${self:provider.stage}-AdminScriptQueue',
149
+ QueueName: '${self:custom.AdminScriptQueue}',
148
150
  MessageRetentionPeriod: 86400, // 1 day
149
151
  VisibilityTimeout: 900, // 15 minutes (Lambda max)
150
152
  RedrivePolicy: {
@@ -264,10 +266,12 @@ class AdminScriptBuilder extends InfrastructureBuilder {
264
266
  }
265
267
 
266
268
  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';
267
271
  result.resources.ReportQueue = {
268
272
  Type: 'AWS::SQS::Queue',
269
273
  Properties: {
270
- QueueName: '${self:service}-${self:provider.stage}-ReportQueue',
274
+ QueueName: '${self:custom.ReportQueue}',
271
275
  MessageRetentionPeriod: 86400, // 1 day
272
276
  VisibilityTimeout: 900, // 15 minutes (Lambda max)
273
277
  RedrivePolicy: {
@@ -168,6 +168,21 @@ 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
+
171
186
  it('should configure AdminScriptQueue redrive policy to InternalErrorQueue', async () => {
172
187
  const appDefinition = {
173
188
  adminScripts: [
@@ -621,6 +636,21 @@ describe('AdminScriptBuilder', () => {
621
636
  });
622
637
 
623
638
  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
+
624
654
  it('creates ReportQueue + reportExecutor and wires REPORT_QUEUE_URL when reports are present', async () => {
625
655
  const appDefinition = {
626
656
  reports: [{ Definition: { name: 'my-report', version: '1.0.0' } }],
@@ -64,7 +64,18 @@ class AuroraBuilder extends InfrastructureBuilder {
64
64
  return false;
65
65
  }
66
66
 
67
- return appDefinition.database?.postgres?.enable === true;
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;
68
79
  }
69
80
 
70
81
  getDependencies() {
@@ -82,7 +93,7 @@ class AuroraBuilder extends InfrastructureBuilder {
82
93
  const dbConfig = appDefinition.database.postgres;
83
94
 
84
95
  // Validate management mode
85
- const validModes = ['discover', 'managed', 'use-existing'];
96
+ const validModes = ['discover', 'managed', 'use-existing', 'external'];
86
97
  const management = dbConfig.management || 'discover';
87
98
  if (!validModes.includes(management)) {
88
99
  result.addError(`Invalid database.postgres.management: "${management}"`);
@@ -42,6 +42,28 @@ 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
+
45
67
  it('should return false when database is not defined', () => {
46
68
  const appDefinition = {};
47
69
 
@@ -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