@friggframework/devtools 2.0.0--canary.517.8e1c21c.0 → 2.0.0--canary.517.559ad7e.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.
- package/infrastructure/domains/admin-scripts/admin-script-builder.js +22 -11
- package/infrastructure/domains/admin-scripts/admin-script-builder.test.js +6 -5
- package/infrastructure/domains/database/migration-builder.js +17 -3
- package/infrastructure/domains/database/migration-builder.test.js +4 -3
- package/package.json +7 -7
|
@@ -70,10 +70,10 @@ class AdminScriptBuilder extends InfrastructureBuilder {
|
|
|
70
70
|
this.createAdminScriptQueue(result);
|
|
71
71
|
|
|
72
72
|
// Create Lambda function for script execution
|
|
73
|
-
this.createScriptExecutorFunction(result, usePrismaLayer);
|
|
73
|
+
this.createScriptExecutorFunction(appDefinition, result, usePrismaLayer);
|
|
74
74
|
|
|
75
75
|
// Create API routes for script management
|
|
76
|
-
this.createAdminScriptRoutes(result, usePrismaLayer);
|
|
76
|
+
this.createAdminScriptRoutes(appDefinition, result, usePrismaLayer);
|
|
77
77
|
|
|
78
78
|
// Phase 2: Create EventBridge Scheduler resources
|
|
79
79
|
if (adminConfig.enableScheduling) {
|
|
@@ -125,11 +125,11 @@ class AdminScriptBuilder extends InfrastructureBuilder {
|
|
|
125
125
|
console.log(' ✓ Created AdminScriptQueue');
|
|
126
126
|
}
|
|
127
127
|
|
|
128
|
-
createScriptExecutorFunction(result, usePrismaLayer) {
|
|
128
|
+
createScriptExecutorFunction(appDefinition, result, usePrismaLayer) {
|
|
129
129
|
result.functions.adminScriptExecutor = {
|
|
130
130
|
handler: 'node_modules/@friggframework/admin-scripts/src/infrastructure/script-executor-handler.handler',
|
|
131
131
|
skipEsbuild: true,
|
|
132
|
-
package: this.skipEsbuildPackageConfig(usePrismaLayer),
|
|
132
|
+
package: this.skipEsbuildPackageConfig(appDefinition, usePrismaLayer),
|
|
133
133
|
...(usePrismaLayer && { layers: [{ Ref: 'PrismaLambdaLayer' }] }),
|
|
134
134
|
timeout: 900, // 15 minutes max
|
|
135
135
|
memorySize: 1024,
|
|
@@ -145,11 +145,11 @@ class AdminScriptBuilder extends InfrastructureBuilder {
|
|
|
145
145
|
console.log(' ✓ Created adminScriptExecutor function');
|
|
146
146
|
}
|
|
147
147
|
|
|
148
|
-
createAdminScriptRoutes(result, usePrismaLayer) {
|
|
148
|
+
createAdminScriptRoutes(appDefinition, result, usePrismaLayer) {
|
|
149
149
|
result.functions.adminScriptRouter = {
|
|
150
150
|
handler: 'node_modules/@friggframework/admin-scripts/src/infrastructure/admin-script-router.handler',
|
|
151
151
|
skipEsbuild: true,
|
|
152
|
-
package: this.skipEsbuildPackageConfig(usePrismaLayer),
|
|
152
|
+
package: this.skipEsbuildPackageConfig(appDefinition, usePrismaLayer),
|
|
153
153
|
...(usePrismaLayer && { layers: [{ Ref: 'PrismaLambdaLayer' }] }),
|
|
154
154
|
timeout: 30,
|
|
155
155
|
events: [
|
|
@@ -181,8 +181,14 @@ class AdminScriptBuilder extends InfrastructureBuilder {
|
|
|
181
181
|
|
|
182
182
|
// Without this, the skipEsbuild functions package the whole node_modules
|
|
183
183
|
// closure (aws-sdk, Prisma, dev deps) and blow past Lambda's 250 MB limit.
|
|
184
|
-
|
|
184
|
+
// Mirrors the exclusions the framework's other node_modules handlers use.
|
|
185
|
+
skipEsbuildPackageConfig(appDefinition, usePrismaLayer) {
|
|
186
|
+
const tlsCAFile = appDefinition?.database?.documentDB?.tlsCAFile;
|
|
185
187
|
return {
|
|
188
|
+
include: [
|
|
189
|
+
// Handlers connect to the DB, so ship the DocumentDB CA cert.
|
|
190
|
+
...(tlsCAFile ? [tlsCAFile.replace(/^\.\//, '')] : []),
|
|
191
|
+
],
|
|
186
192
|
exclude: [
|
|
187
193
|
'node_modules/aws-sdk/**',
|
|
188
194
|
'node_modules/@aws-sdk/**',
|
|
@@ -212,10 +218,13 @@ class AdminScriptBuilder extends InfrastructureBuilder {
|
|
|
212
218
|
'node_modules/serverless-offline-sqs/**',
|
|
213
219
|
'node_modules/serverless-dotenv-plugin/**',
|
|
214
220
|
'node_modules/serverless-kms-grants/**',
|
|
221
|
+
// Never deploy secrets or the lockfile.
|
|
215
222
|
'.env',
|
|
216
223
|
'.env.*',
|
|
217
224
|
'**/.env',
|
|
218
225
|
'**/.env.*',
|
|
226
|
+
'.frigg-credentials.json',
|
|
227
|
+
'package-lock.json',
|
|
219
228
|
'test/**',
|
|
220
229
|
'layers/**',
|
|
221
230
|
'coverage/**',
|
|
@@ -268,12 +277,14 @@ class AdminScriptBuilder extends InfrastructureBuilder {
|
|
|
268
277
|
},
|
|
269
278
|
};
|
|
270
279
|
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
//
|
|
274
|
-
//
|
|
280
|
+
// Router-scoped, not shared provider env. Two reasons: broadcasting the
|
|
281
|
+
// resource references to every function creates CloudFormation circular
|
|
282
|
+
// deps; and SCHEDULER_PROVIDER='aws' is only valid for the admin-script
|
|
283
|
+
// adapter (the router's sole consumer) — core's scheduler factory, used
|
|
284
|
+
// by integration Lambdas, rejects 'aws', so it must not leak app-wide.
|
|
275
285
|
result.functions.adminScriptRouter.environment = {
|
|
276
286
|
...(result.functions.adminScriptRouter.environment || {}),
|
|
287
|
+
SCHEDULER_PROVIDER: 'aws',
|
|
277
288
|
SCHEDULER_ROLE_ARN: {
|
|
278
289
|
'Fn::GetAtt': ['AdminScriptSchedulerRole', 'Arn'],
|
|
279
290
|
},
|
|
@@ -389,12 +389,13 @@ describe('AdminScriptBuilder', () => {
|
|
|
389
389
|
expect(result.resources.AdminScriptScheduleGroup).toBeDefined();
|
|
390
390
|
expect(result.resources.AdminScriptScheduleGroup.Type).toBe('AWS::Scheduler::ScheduleGroup');
|
|
391
391
|
|
|
392
|
-
//
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
//
|
|
396
|
-
// the shared provider env) to avoid CloudFormation circular deps.
|
|
392
|
+
// Scheduler env vars are scoped to the router function (not the
|
|
393
|
+
// shared provider env): resource refs would create CloudFormation
|
|
394
|
+
// circular deps, and SCHEDULER_PROVIDER='aws' would break core's
|
|
395
|
+
// scheduler factory (rejects 'aws') for every other Lambda.
|
|
397
396
|
const routerEnv = result.functions.adminScriptRouter.environment;
|
|
397
|
+
expect(routerEnv.SCHEDULER_PROVIDER).toBe('aws');
|
|
398
|
+
expect(result.environment.SCHEDULER_PROVIDER).toBeUndefined();
|
|
398
399
|
expect(routerEnv.SCHEDULER_ROLE_ARN).toEqual({
|
|
399
400
|
'Fn::GetAtt': ['AdminScriptSchedulerRole', 'Arn'],
|
|
400
401
|
});
|
|
@@ -466,9 +466,23 @@ class MigrationBuilder extends InfrastructureBuilder {
|
|
|
466
466
|
// Note: Serverless will merge this with provider.environment
|
|
467
467
|
},
|
|
468
468
|
events: [
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
469
|
+
// Paths must match the Express router in core's db-migration.js,
|
|
470
|
+
// which mounts under /admin/db-migrate (consolidated with the
|
|
471
|
+
// other admin endpoints). A mismatch routes API Gateway to the
|
|
472
|
+
// Lambda but Express 404s ("Cannot POST /db-migrate").
|
|
473
|
+
{
|
|
474
|
+
httpApi: {
|
|
475
|
+
path: '/admin/db-migrate/status',
|
|
476
|
+
method: 'GET',
|
|
477
|
+
},
|
|
478
|
+
},
|
|
479
|
+
{ httpApi: { path: '/admin/db-migrate', method: 'POST' } },
|
|
480
|
+
{
|
|
481
|
+
httpApi: {
|
|
482
|
+
path: '/admin/db-migrate/{processId}',
|
|
483
|
+
method: 'GET',
|
|
484
|
+
},
|
|
485
|
+
},
|
|
472
486
|
],
|
|
473
487
|
};
|
|
474
488
|
console.log(' ✓ Created dbMigrationRouter function');
|
|
@@ -230,14 +230,15 @@ describe('MigrationBuilder', () => {
|
|
|
230
230
|
expect(result.functions.dbMigrationRouter.timeout).toBe(30);
|
|
231
231
|
expect(result.functions.dbMigrationRouter.memorySize).toBe(512);
|
|
232
232
|
expect(result.functions.dbMigrationRouter.events).toHaveLength(3);
|
|
233
|
+
// Must match core's Express router mounted under /admin/db-migrate.
|
|
233
234
|
expect(result.functions.dbMigrationRouter.events).toContainEqual({
|
|
234
|
-
httpApi: { path: '/db-migrate/status', method: 'GET' },
|
|
235
|
+
httpApi: { path: '/admin/db-migrate/status', method: 'GET' },
|
|
235
236
|
});
|
|
236
237
|
expect(result.functions.dbMigrationRouter.events).toContainEqual({
|
|
237
|
-
httpApi: { path: '/db-migrate', method: 'POST' },
|
|
238
|
+
httpApi: { path: '/admin/db-migrate', method: 'POST' },
|
|
238
239
|
});
|
|
239
240
|
expect(result.functions.dbMigrationRouter.events).toContainEqual({
|
|
240
|
-
httpApi: { path: '/db-migrate/{processId}', method: 'GET' },
|
|
241
|
+
httpApi: { path: '/admin/db-migrate/{processId}', method: 'GET' },
|
|
241
242
|
});
|
|
242
243
|
});
|
|
243
244
|
|
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--canary.517.
|
|
4
|
+
"version": "2.0.0--canary.517.559ad7e.0",
|
|
5
5
|
"bin": {
|
|
6
6
|
"frigg": "./frigg-cli/index.js"
|
|
7
7
|
},
|
|
@@ -25,9 +25,9 @@
|
|
|
25
25
|
"@babel/eslint-parser": "^7.18.9",
|
|
26
26
|
"@babel/parser": "^7.25.3",
|
|
27
27
|
"@babel/traverse": "^7.25.3",
|
|
28
|
-
"@friggframework/core": "2.0.0--canary.517.
|
|
29
|
-
"@friggframework/schemas": "2.0.0--canary.517.
|
|
30
|
-
"@friggframework/test": "2.0.0--canary.517.
|
|
28
|
+
"@friggframework/core": "2.0.0--canary.517.559ad7e.0",
|
|
29
|
+
"@friggframework/schemas": "2.0.0--canary.517.559ad7e.0",
|
|
30
|
+
"@friggframework/test": "2.0.0--canary.517.559ad7e.0",
|
|
31
31
|
"@hapi/boom": "^10.0.1",
|
|
32
32
|
"@inquirer/prompts": "^5.3.8",
|
|
33
33
|
"axios": "^1.18.0",
|
|
@@ -55,8 +55,8 @@
|
|
|
55
55
|
"validate-npm-package-name": "^5.0.0"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
|
-
"@friggframework/eslint-config": "2.0.0--canary.517.
|
|
59
|
-
"@friggframework/prettier-config": "2.0.0--canary.517.
|
|
58
|
+
"@friggframework/eslint-config": "2.0.0--canary.517.559ad7e.0",
|
|
59
|
+
"@friggframework/prettier-config": "2.0.0--canary.517.559ad7e.0",
|
|
60
60
|
"aws-sdk-client-mock": "^4.1.0",
|
|
61
61
|
"aws-sdk-client-mock-jest": "^4.1.0",
|
|
62
62
|
"jest": "^30.1.3",
|
|
@@ -88,5 +88,5 @@
|
|
|
88
88
|
"publishConfig": {
|
|
89
89
|
"access": "public"
|
|
90
90
|
},
|
|
91
|
-
"gitHead": "
|
|
91
|
+
"gitHead": "559ad7ed62bf320273a70e2bb9e30ec67a026355"
|
|
92
92
|
}
|