@friggframework/devtools 2.0.0-next.122 → 2.0.0-next.124

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 (29) hide show
  1. package/frigg-cli/README.md +38 -1
  2. package/frigg-cli/__tests__/unit/commands/build.test.js +3 -0
  3. package/frigg-cli/__tests__/unit/commands/deploy.test.js +3 -0
  4. package/frigg-cli/__tests__/unit/commands/validate-wiring.test.js +92 -0
  5. package/frigg-cli/build-command/index.js +6 -0
  6. package/frigg-cli/deploy-command/index.js +6 -0
  7. package/frigg-cli/index.js +13 -1
  8. package/frigg-cli/init-command/backend-first-handler.js +48 -47
  9. package/frigg-cli/start-command/index.js +4 -0
  10. package/frigg-cli/start-command/start-command.test.js +3 -0
  11. package/frigg-cli/validate-command/__tests__/init-validation.test.js +63 -0
  12. package/frigg-cli/validate-command/__tests__/integrations-checks.test.js +133 -0
  13. package/frigg-cli/validate-command/__tests__/validate-app-definition.test.js +443 -0
  14. package/frigg-cli/validate-command/__tests__/validate-command.test.js +262 -0
  15. package/frigg-cli/validate-command/checks/config.js +504 -0
  16. package/frigg-cli/validate-command/checks/integrations.js +274 -0
  17. package/frigg-cli/validate-command/format-report.js +58 -0
  18. package/frigg-cli/validate-command/index.js +107 -0
  19. package/frigg-cli/validate-command/load-app-definition.js +105 -0
  20. package/frigg-cli/validate-command/schema-issues.js +154 -0
  21. package/frigg-cli/validate-command/validate-app-definition.js +60 -0
  22. package/infrastructure/__tests__/management-api-gateway-routes.test.js +281 -0
  23. package/infrastructure/app-definition-schema-contract.test.js +629 -0
  24. package/infrastructure/create-frigg-infrastructure.js +4 -1
  25. package/infrastructure/create-frigg-infrastructure.test.js +51 -0
  26. package/infrastructure/docs/POSTGRES-CONFIGURATION.md +60 -98
  27. package/infrastructure/domains/shared/utilities/base-definition-factory.js +19 -0
  28. package/infrastructure/domains/shared/utilities/base-definition-factory.test.js +13 -1
  29. package/package.json +7 -7
@@ -8,10 +8,10 @@ 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
- - **Management Modes**: discover, create-new, use-existing, external (bring your own `DATABASE_URL`)
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
 
@@ -41,12 +41,16 @@ Use `sslmode=require` in the URL. This is the default for apps scaffolded by
41
41
 
42
42
  ### App Definition Structure
43
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
+
44
48
  ```javascript
45
49
  // backend/index.js
46
50
  const appDefinition = {
47
51
  name: 'my-frigg-app',
48
52
 
49
- // Enable VPC deployment (required for Aurora)
53
+ // VPC Configuration (required for Aurora)
50
54
  vpc: {
51
55
  enable: true,
52
56
  },
@@ -56,34 +60,24 @@ const appDefinition = {
56
60
  postgres: {
57
61
  enable: true,
58
62
 
59
- // Management mode: 'discover' | 'create-new' | 'use-existing'
63
+ // 'discover' (also when omitted) | 'managed' | 'use-existing'
64
+ // Ignored when managementMode is 'managed' or 'existing'.
60
65
  management: 'discover',
61
66
 
62
- // Basic Configuration
63
- databaseName: 'frigg_db',
64
- masterUsername: 'frigg_admin',
65
-
66
- // Engine Configuration
67
- engine: 'aurora-postgresql',
68
- engineVersion: '15.3',
69
-
70
- // Scaling Configuration (Aurora Serverless v2)
71
- scaling: {
72
- minCapacity: 0.5, // ACUs (0.5 = ~1GB RAM, ~$43/month)
73
- maxCapacity: 1.0, // ACUs (1.0 = ~2GB RAM, ~$87/month)
74
- },
67
+ database: 'frigg', // database name (default 'frigg')
68
+ username: 'postgres', // master user (default 'postgres')
69
+ engineVersion: '15.13', // Aurora PostgreSQL version (default '15.13')
75
70
 
76
- // Backup Configuration
77
- backupRetentionDays: 7,
78
- 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
79
74
 
80
- // Security & Advanced
81
- deletionProtection: true,
82
- enablePerformanceInsights: false,
75
+ publiclyAccessible: false, // default false (private subnets)
76
+ autoCreateCredentials: false, // discover only: create a secret for a discovered cluster
83
77
 
84
- // For use-existing mode
85
- clusterIdentifier: 'my-existing-cluster',
86
- secretArn: 'arn:aws:secretsmanager:...',
78
+ // use-existing only
79
+ // endpoint: 'mydb.cluster-abc123.us-east-1.rds.amazonaws.com',
80
+ // port: 5432,
87
81
  }
88
82
  }
89
83
  };
@@ -93,13 +87,17 @@ module.exports = {
93
87
  };
94
88
  ```
95
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
+
96
94
  ---
97
95
 
98
96
  ## Management Modes
99
97
 
100
98
  ### 1. Discover Mode (Default)
101
99
 
102
- 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.
103
101
 
104
102
  ```javascript
105
103
  database: {
@@ -120,63 +118,56 @@ database: {
120
118
 
121
119
  ---
122
120
 
123
- ### 2. Create-New Mode
121
+ ### 2. Managed Mode
124
122
 
125
- Always creates a new Aurora cluster, even if existing clusters are found.
123
+ Creates the cluster, instance, subnet group and secret in the stack.
126
124
 
127
125
  ```javascript
128
126
  database: {
129
127
  postgres: {
130
128
  enable: true,
131
- management: 'create-new',
132
-
133
- // Customization options
134
- databaseName: 'my_app_db',
135
- masterUsername: 'admin',
136
- engineVersion: '15.3',
137
- scaling: {
138
- minCapacity: 1.0,
139
- maxCapacity: 2.0,
140
- },
141
- backupRetentionDays: 14,
142
- deletionProtection: true,
129
+ management: 'managed',
130
+ minCapacity: 1,
131
+ maxCapacity: 2,
143
132
  }
144
133
  }
145
134
  ```
146
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
+
147
139
  **Best For**: Production environments where you want dedicated database resources.
148
140
 
149
141
  ---
150
142
 
151
143
  ### 3. Use-Existing Mode
152
144
 
153
- Uses a specific existing Aurora cluster by identifier.
145
+ Connects to an existing PostgreSQL endpoint without creating database resources.
154
146
 
155
147
  ```javascript
156
148
  database: {
157
149
  postgres: {
158
150
  enable: true,
159
151
  management: 'use-existing',
160
-
161
- // Required: existing cluster identifier
162
- clusterIdentifier: 'my-existing-aurora-cluster',
163
-
164
- // Optional: secret ARN (discovered if not provided)
165
- secretArn: 'arn:aws:secretsmanager:us-east-1:123456789012:secret:my-db-secret',
166
-
167
- // Database name to connect to
168
- 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',
169
156
  }
170
157
  }
171
158
  ```
172
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
+
173
164
  **Best For**: Shared database scenarios or when you manage Aurora outside of Frigg.
174
165
 
175
166
  ---
176
167
 
177
168
  ## Created AWS Resources
178
169
 
179
- 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:
180
171
 
181
172
  ### 1. RDS DB Subnet Group
182
173
  - **Name**: `{service}-{stage}-db-subnet-group`
@@ -241,17 +232,15 @@ database: {
241
232
  database: {
242
233
  postgres: {
243
234
  enable: true,
244
- scaling: {
245
- minCapacity: 1.0, // Higher baseline for production
246
- maxCapacity: 4.0, // Handle traffic spikes
247
- },
248
- backupRetentionDays: 30, // Longer retention
249
- enablePerformanceInsights: true, // Monitoring
250
- deletionProtection: true, // Prevent accidental deletion
235
+ minCapacity: 1, // Higher baseline for production
236
+ maxCapacity: 4, // Handle traffic spikes
251
237
  }
252
238
  }
253
239
  ```
254
240
 
241
+ Backup retention, Performance Insights and deletion protection are not
242
+ configurable through the app definition; change them on the cluster.
243
+
255
244
  **Estimated Monthly Costs**:
256
245
  - **Baseline**: $87/month (1.0 ACU minimum)
257
246
  - **Peak Traffic**: $348/month (4.0 ACU maximum)
@@ -296,15 +285,9 @@ const users = await prismaClient.user.findMany();
296
285
 
297
286
  ### 4. Deletion Protection
298
287
 
299
- ```javascript
300
- database: {
301
- postgres: {
302
- deletionProtection: true, // Prevents accidental deletion
303
- }
304
- }
305
- ```
306
-
307
- **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.
308
291
 
309
292
  ---
310
293
 
@@ -404,7 +387,7 @@ DB_TYPE=postgresql
404
387
  database: {
405
388
  postgres: {
406
389
  enable: true,
407
- management: 'create-new',
390
+ management: 'managed',
408
391
  }
409
392
  }
410
393
  ```
@@ -431,7 +414,7 @@ DB_TYPE=postgresql
431
414
  database: {
432
415
  postgres: {
433
416
  enable: true,
434
- management: 'create-new',
417
+ management: 'managed',
435
418
  }
436
419
  }
437
420
  ```
@@ -476,13 +459,13 @@ DB_TYPE=postgresql
476
459
 
477
460
  **Error**:
478
461
  ```
479
- 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".
480
463
  ```
481
464
 
482
465
  **Solution**:
483
466
  1. Check VPC is enabled: `vpc.enable: true`
484
- 2. Set management mode: `management: 'create-new'`
485
- 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: '...'`
486
469
 
487
470
  ---
488
471
 
@@ -564,41 +547,20 @@ Cannot create Aurora cluster: InsufficientDBInstanceCapacity
564
547
 
565
548
  ## Advanced Configuration
566
549
 
567
- ### Custom Backup Window
568
-
569
- ```javascript
570
- database: {
571
- postgres: {
572
- enable: true,
573
- backupRetentionDays: 30,
574
- preferredBackupWindow: '02:00-03:00', // UTC
575
- }
576
- }
577
- ```
578
-
579
- ### Enhanced Monitoring
580
-
581
- ```javascript
582
- database: {
583
- postgres: {
584
- enable: true,
585
- enablePerformanceInsights: true,
586
- // Performance Insights retention: 7 days (default) or 731 days
587
- }
588
- }
589
- ```
590
-
591
550
  ### Custom Engine Version
592
551
 
593
552
  ```javascript
594
553
  database: {
595
554
  postgres: {
596
555
  enable: true,
597
- engineVersion: '14.6', // Default: 15.3
556
+ engineVersion: '16.4', // Default: 15.13
598
557
  }
599
558
  }
600
559
  ```
601
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
+
602
564
  ### Read Replicas (Not Supported Yet)
603
565
 
604
566
  Frigg currently provisions a single Aurora instance. For read replicas:
@@ -286,6 +286,11 @@ function createBaseDefinition(
286
286
  ...(usePrismaLayer && { layers: [{ Ref: 'PrismaLambdaLayer' }] }),
287
287
  skipEsbuild: true, // Handlers in node_modules don't need bundling
288
288
  package: skipEsbuildPackageConfig,
289
+ // Every path prefix the core integration router
290
+ // (createIntegrationRouter) registers must be routed here;
291
+ // HTTP API has no implicit catch-all, so an unlisted prefix
292
+ // 404s at the gateway before Express sees it. Guarded by
293
+ // __tests__/management-api-gateway-routes.test.js.
289
294
  events: [
290
295
  { httpApi: { path: '/api/integrations', method: 'ANY' } },
291
296
  {
@@ -295,6 +300,20 @@ function createBaseDefinition(
295
300
  },
296
301
  },
297
302
  { httpApi: { path: '/api/authorize', method: 'ANY' } },
303
+ { httpApi: { path: '/api/entity', method: 'ANY' } },
304
+ {
305
+ httpApi: {
306
+ path: '/api/entity/{proxy+}',
307
+ method: 'ANY',
308
+ },
309
+ },
310
+ { httpApi: { path: '/api/entities', method: 'ANY' } },
311
+ {
312
+ httpApi: {
313
+ path: '/api/entities/{proxy+}',
314
+ method: 'ANY',
315
+ },
316
+ },
298
317
  ],
299
318
  },
300
319
  user: {
@@ -94,7 +94,19 @@ describe('Base Definition Factory', () => {
94
94
 
95
95
  expect(result.functions.auth.handler).toBe('node_modules/@friggframework/core/handlers/routers/auth.handler');
96
96
  expect(result.functions.auth.layers).toEqual([{ Ref: 'PrismaLambdaLayer' }]);
97
- expect(result.functions.auth.events).toHaveLength(3);
97
+ expect(
98
+ result.functions.auth.events.map(
99
+ (e) => `${e.httpApi.method} ${e.httpApi.path}`
100
+ )
101
+ ).toEqual([
102
+ 'ANY /api/integrations',
103
+ 'ANY /api/integrations/{proxy+}',
104
+ 'ANY /api/authorize',
105
+ 'ANY /api/entity',
106
+ 'ANY /api/entity/{proxy+}',
107
+ 'ANY /api/entities',
108
+ 'ANY /api/entities/{proxy+}',
109
+ ]);
98
110
  });
99
111
 
100
112
  it('should NOT include legacy dbMigrate function', () => {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@friggframework/devtools",
3
3
  "prettier": "@friggframework/prettier-config",
4
- "version": "2.0.0-next.122",
4
+ "version": "2.0.0-next.124",
5
5
  "bin": {
6
6
  "frigg": "./frigg-cli/index.js"
7
7
  },
@@ -28,9 +28,9 @@
28
28
  "@babel/eslint-parser": "^7.18.9",
29
29
  "@babel/parser": "^7.25.3",
30
30
  "@babel/traverse": "^7.25.3",
31
- "@friggframework/core": "2.0.0-next.122",
32
- "@friggframework/schemas": "2.0.0-next.122",
33
- "@friggframework/test": "2.0.0-next.122",
31
+ "@friggframework/core": "2.0.0-next.124",
32
+ "@friggframework/schemas": "2.0.0-next.124",
33
+ "@friggframework/test": "2.0.0-next.124",
34
34
  "@hapi/boom": "^10.0.1",
35
35
  "@inquirer/prompts": "^5.3.8",
36
36
  "axios": "^1.18.0",
@@ -58,8 +58,8 @@
58
58
  "validate-npm-package-name": "^5.0.0"
59
59
  },
60
60
  "devDependencies": {
61
- "@friggframework/eslint-config": "2.0.0-next.122",
62
- "@friggframework/prettier-config": "2.0.0-next.122",
61
+ "@friggframework/eslint-config": "2.0.0-next.124",
62
+ "@friggframework/prettier-config": "2.0.0-next.124",
63
63
  "aws-sdk-client-mock": "^4.1.0",
64
64
  "aws-sdk-client-mock-jest": "^4.1.0",
65
65
  "jest": "^30.1.3",
@@ -91,5 +91,5 @@
91
91
  "publishConfig": {
92
92
  "access": "public"
93
93
  },
94
- "gitHead": "d9e2755c836c7cfb4f2de7a8e3d003c6d7167d03"
94
+ "gitHead": "679a3f0f550136151563c34f9a8c7680b88b6984"
95
95
  }