@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.
- package/frigg-cli/README.md +115 -31
- package/frigg-cli/__tests__/unit/commands/build.test.js +3 -0
- package/frigg-cli/__tests__/unit/commands/deploy.test.js +33 -24
- package/frigg-cli/__tests__/unit/commands/doctor.test.js +10 -6
- package/frigg-cli/__tests__/unit/commands/generate-iam.test.js +18 -0
- package/frigg-cli/__tests__/unit/commands/init.test.js +688 -0
- package/frigg-cli/__tests__/unit/commands/install.test.js +601 -341
- package/frigg-cli/__tests__/unit/commands/ui.test.js +31 -30
- package/frigg-cli/__tests__/unit/commands/validate-wiring.test.js +92 -0
- package/frigg-cli/__tests__/unit/dependencies.test.js +6 -2
- package/frigg-cli/build-command/index.js +6 -0
- package/frigg-cli/deploy-command/index.js +6 -0
- package/frigg-cli/generate-command/index.js +1 -0
- package/frigg-cli/generate-iam-command.js +1 -0
- package/frigg-cli/index.js +22 -5
- package/frigg-cli/init-command/backend-first-handler.js +395 -551
- package/frigg-cli/init-command/deployment-modes.js +7 -0
- package/frigg-cli/init-command/index.js +82 -35
- package/frigg-cli/init-command/safe-path.js +58 -0
- package/frigg-cli/init-command/scaffold-dependencies.js +202 -0
- package/frigg-cli/install-command/app-definition.js +174 -0
- package/frigg-cli/install-command/commit-changes.js +40 -8
- package/frigg-cli/install-command/environment-variables.js +15 -0
- package/frigg-cli/install-command/index.js +96 -21
- package/frigg-cli/install-command/install-package.js +77 -4
- package/frigg-cli/install-command/integration-file.js +20 -11
- package/frigg-cli/install-command/resolve-module.js +69 -0
- package/frigg-cli/install-command/template.js +102 -75
- package/frigg-cli/install-command/validate-package.js +36 -4
- package/frigg-cli/package.json +1 -1
- package/frigg-cli/start-command/index.js +4 -0
- package/frigg-cli/start-command/start-command.test.js +3 -0
- package/frigg-cli/templates/backend/README.md +267 -0
- package/frigg-cli/templates/backend/env.example +20 -0
- package/frigg-cli/templates/backend/gitignore +10 -0
- package/frigg-cli/templates/backend/index.js +114 -0
- package/frigg-cli/templates/backend/infrastructure.js +20 -0
- package/frigg-cli/test/init-command.test.js +9 -2
- package/frigg-cli/validate-command/__tests__/init-validation.test.js +63 -0
- package/frigg-cli/validate-command/__tests__/integrations-checks.test.js +133 -0
- package/frigg-cli/validate-command/__tests__/validate-app-definition.test.js +443 -0
- package/frigg-cli/validate-command/__tests__/validate-command.test.js +262 -0
- package/frigg-cli/validate-command/checks/config.js +504 -0
- package/frigg-cli/validate-command/checks/integrations.js +274 -0
- package/frigg-cli/validate-command/format-report.js +58 -0
- package/frigg-cli/validate-command/index.js +107 -0
- package/frigg-cli/validate-command/load-app-definition.js +105 -0
- package/frigg-cli/validate-command/schema-issues.js +154 -0
- package/frigg-cli/validate-command/validate-app-definition.js +60 -0
- package/infrastructure/__tests__/management-api-gateway-routes.test.js +40 -94
- package/infrastructure/__tests__/postgres-config.test.js +241 -835
- package/infrastructure/__tests__/scaffold-default-infrastructure.test.js +148 -0
- package/infrastructure/__tests__/template-generation.test.js +36 -8
- package/infrastructure/app-definition-schema-contract.test.js +629 -0
- package/infrastructure/create-frigg-infrastructure.js +4 -1
- package/infrastructure/create-frigg-infrastructure.test.js +51 -0
- package/infrastructure/docs/POSTGRES-CONFIGURATION.md +80 -98
- package/infrastructure/domains/admin-scripts/admin-script-builder.js +6 -2
- package/infrastructure/domains/admin-scripts/admin-script-builder.test.js +30 -0
- package/infrastructure/domains/database/aurora-builder.js +13 -2
- package/infrastructure/domains/database/aurora-builder.test.js +22 -0
- package/infrastructure/domains/health/application/use-cases/__tests__/mismatch-analyzer-method-name.test.js +12 -8
- package/infrastructure/domains/health/application/use-cases/__tests__/repair-via-import-use-case.test.js +19 -7
- package/infrastructure/domains/health/application/use-cases/run-health-check-use-case.test.js +12 -8
- package/infrastructure/domains/health/domain/services/__tests__/import-progress-monitor.test.js +17 -18
- package/infrastructure/domains/health/domain/services/__tests__/update-progress-monitor.test.js +12 -2
- package/infrastructure/domains/health/infrastructure/adapters/__tests__/orphan-detection-relationship-analysis.test.js +8 -1
- package/infrastructure/domains/health/infrastructure/adapters/aws-property-reconciler.test.js +4 -2
- package/infrastructure/domains/health/infrastructure/adapters/aws-resource-detector.test.js +10 -0
- package/infrastructure/domains/networking/vpc-builder.js +18 -8
- package/infrastructure/domains/networking/vpc-builder.test.js +26 -12
- package/infrastructure/domains/security/iam-generator.js +112 -5
- package/infrastructure/domains/security/iam-generator.test.js +94 -0
- package/infrastructure/domains/shared/cloudformation-discovery.test.js +36 -6
- package/infrastructure/domains/shared/utilities/base-definition-factory.js +35 -27
- package/infrastructure/domains/shared/utilities/base-definition-factory.test.js +22 -49
- package/infrastructure/infrastructure-composer.test.js +268 -794
- package/infrastructure/scripts/build-prisma-layer.test.js +28 -7
- package/infrastructure/scripts/build-time-discovery.test.js +18 -3
- package/package.json +10 -8
- package/frigg-cli/index.test.js +0 -158
- package/infrastructure/integration.test.js +0 -381
|
@@ -10,24 +10,6 @@
|
|
|
10
10
|
const { buildEnvironment } = require('../environment-builder');
|
|
11
11
|
const { nestedNodeModulesExcludes } = require('./nested-node-modules');
|
|
12
12
|
const { buildLoggingProviderConfig } = require('./logging-config');
|
|
13
|
-
const {
|
|
14
|
-
getGatewayRoutes,
|
|
15
|
-
} = require('@friggframework/core/management-api/route-registry');
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* HTTP API events for one function, from core's Management API route
|
|
19
|
-
* registry (ADR-053): the same registry mounts the Express routers and
|
|
20
|
-
* builds the OpenAPI documents, so the three cannot drift.
|
|
21
|
-
*/
|
|
22
|
-
function managementApiEvents(AppDefinition, functionName) {
|
|
23
|
-
const managementApi = AppDefinition.managementApi || {};
|
|
24
|
-
return getGatewayRoutes({
|
|
25
|
-
v1: managementApi.v1 !== false,
|
|
26
|
-
proxy: managementApi.proxy?.enable === true,
|
|
27
|
-
})
|
|
28
|
-
.filter((route) => route.function === functionName)
|
|
29
|
-
.map(({ method, path }) => ({ httpApi: { path, method } }));
|
|
30
|
-
}
|
|
31
13
|
|
|
32
14
|
/**
|
|
33
15
|
* Create base serverless definition with core functions and resources
|
|
@@ -304,12 +286,35 @@ function createBaseDefinition(
|
|
|
304
286
|
...(usePrismaLayer && { layers: [{ Ref: 'PrismaLambdaLayer' }] }),
|
|
305
287
|
skipEsbuild: true, // Handlers in node_modules don't need bundling
|
|
306
288
|
package: skipEsbuildPackageConfig,
|
|
307
|
-
// Every
|
|
308
|
-
//
|
|
309
|
-
//
|
|
310
|
-
//
|
|
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
|
|
311
293
|
// __tests__/management-api-gateway-routes.test.js.
|
|
312
|
-
events:
|
|
294
|
+
events: [
|
|
295
|
+
{ httpApi: { path: '/api/integrations', method: 'ANY' } },
|
|
296
|
+
{
|
|
297
|
+
httpApi: {
|
|
298
|
+
path: '/api/integrations/{proxy+}',
|
|
299
|
+
method: 'ANY',
|
|
300
|
+
},
|
|
301
|
+
},
|
|
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
|
+
},
|
|
317
|
+
],
|
|
313
318
|
},
|
|
314
319
|
user: {
|
|
315
320
|
handler: 'node_modules/@friggframework/core/handlers/routers/user.handler',
|
|
@@ -326,8 +331,6 @@ function createBaseDefinition(
|
|
|
326
331
|
events: [
|
|
327
332
|
{ httpApi: { path: '/health', method: 'GET' } },
|
|
328
333
|
{ httpApi: { path: '/health/{proxy+}', method: 'GET' } },
|
|
329
|
-
// GET /api/meta and the OpenAPI documents: public, DB-free.
|
|
330
|
-
...managementApiEvents(AppDefinition, 'health'),
|
|
331
334
|
],
|
|
332
335
|
},
|
|
333
336
|
// Reporting is an admin operation (ADR-010): the report router runs on the admin-scripts Lambda, not as a standalone function here.
|
|
@@ -399,12 +402,18 @@ function createBaseDefinition(
|
|
|
399
402
|
},
|
|
400
403
|
},
|
|
401
404
|
},
|
|
405
|
+
// The functions above use `httpApi` events, so osls creates
|
|
406
|
+
// an HTTP API (API Gateway v2, logical ID HttpApi) with only
|
|
407
|
+
// the `$default` stage. HTTP APIs publish `5xx`, not the REST
|
|
408
|
+
// API metric `5XXError`, and the ApiId dimension identifies
|
|
409
|
+
// this API (a Stage dimension would have to be `$default`).
|
|
410
|
+
// https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-metrics.html
|
|
402
411
|
ApiGatewayAlarm5xx: {
|
|
403
412
|
Type: 'AWS::CloudWatch::Alarm',
|
|
404
413
|
Properties: {
|
|
405
414
|
AlarmDescription: 'API Gateway 5xx Errors',
|
|
406
415
|
Namespace: 'AWS/ApiGateway',
|
|
407
|
-
MetricName: '
|
|
416
|
+
MetricName: '5xx',
|
|
408
417
|
Statistic: 'Sum',
|
|
409
418
|
Threshold: 0,
|
|
410
419
|
ComparisonOperator: 'GreaterThanThreshold',
|
|
@@ -413,7 +422,6 @@ function createBaseDefinition(
|
|
|
413
422
|
AlarmActions: [{ Ref: 'InternalErrorBridgeTopic' }],
|
|
414
423
|
Dimensions: [
|
|
415
424
|
{ Name: 'ApiId', Value: { Ref: 'HttpApi' } },
|
|
416
|
-
{ Name: 'Stage', Value: '${self:provider.stage}' },
|
|
417
425
|
],
|
|
418
426
|
},
|
|
419
427
|
},
|
|
@@ -99,64 +99,16 @@ describe('Base Definition Factory', () => {
|
|
|
99
99
|
(e) => `${e.httpApi.method} ${e.httpApi.path}`
|
|
100
100
|
)
|
|
101
101
|
).toEqual([
|
|
102
|
-
// v1 (deprecated, ADR-053)
|
|
103
102
|
'ANY /api/integrations',
|
|
104
103
|
'ANY /api/integrations/{proxy+}',
|
|
105
104
|
'ANY /api/authorize',
|
|
106
105
|
'ANY /api/entity',
|
|
107
106
|
'ANY /api/entity/{proxy+}',
|
|
107
|
+
'ANY /api/entities',
|
|
108
108
|
'ANY /api/entities/{proxy+}',
|
|
109
|
-
// v2, per resource: never ANY /api/v2/{proxy+}, which would
|
|
110
|
-
// shadow /api/v2/reports on the admin-scripts Lambda
|
|
111
|
-
'ANY /api/v2/integrations',
|
|
112
|
-
'ANY /api/v2/integrations/{proxy+}',
|
|
113
|
-
'ANY /api/v2/entities',
|
|
114
|
-
'ANY /api/v2/entities/{proxy+}',
|
|
115
|
-
'ANY /api/v2/credentials',
|
|
116
|
-
'ANY /api/v2/credentials/{proxy+}',
|
|
117
|
-
'ANY /api/v2/authorize',
|
|
118
109
|
]);
|
|
119
110
|
});
|
|
120
111
|
|
|
121
|
-
it('takes the Management API routes from the core route registry', () => {
|
|
122
|
-
const { getGatewayRoutes } = require('@friggframework/core/management-api/route-registry');
|
|
123
|
-
const result = createBaseDefinition({}, {}, {});
|
|
124
|
-
const declared = (fn) =>
|
|
125
|
-
result.functions[fn].events
|
|
126
|
-
.map((e) => `${e.httpApi.method} ${e.httpApi.path}`)
|
|
127
|
-
.filter((route) => route.includes('/api/'));
|
|
128
|
-
const registry = (fn) =>
|
|
129
|
-
getGatewayRoutes()
|
|
130
|
-
.filter((r) => r.function === fn)
|
|
131
|
-
.map((r) => `${r.method} ${r.path}`);
|
|
132
|
-
expect(declared('auth')).toEqual(registry('auth'));
|
|
133
|
-
expect(declared('health')).toEqual(registry('health'));
|
|
134
|
-
});
|
|
135
|
-
|
|
136
|
-
it('serves /api/meta from the DB-free health function', () => {
|
|
137
|
-
const result = createBaseDefinition({}, {}, {});
|
|
138
|
-
expect(
|
|
139
|
-
result.functions.health.events.map((e) => `${e.httpApi.method} ${e.httpApi.path}`)
|
|
140
|
-
).toEqual([
|
|
141
|
-
'GET /health',
|
|
142
|
-
'GET /health/{proxy+}',
|
|
143
|
-
'GET /api/meta',
|
|
144
|
-
'GET /api/meta/{proxy+}',
|
|
145
|
-
]);
|
|
146
|
-
});
|
|
147
|
-
|
|
148
|
-
it('drops the v1 routes when managementApi.v1 is false, keeping the OAuth redirect', () => {
|
|
149
|
-
const result = createBaseDefinition({ managementApi: { v1: false } }, {}, {});
|
|
150
|
-
const routes = result.functions.auth.events.map(
|
|
151
|
-
(e) => `${e.httpApi.method} ${e.httpApi.path}`
|
|
152
|
-
);
|
|
153
|
-
expect(routes).not.toContain('ANY /api/integrations');
|
|
154
|
-
expect(routes).not.toContain('ANY /api/authorize');
|
|
155
|
-
expect(routes).not.toContain('ANY /api/entity');
|
|
156
|
-
expect(routes).toContain('GET /api/integrations/redirect/{appId}');
|
|
157
|
-
expect(routes).toContain('ANY /api/v2/integrations');
|
|
158
|
-
});
|
|
159
|
-
|
|
160
112
|
it('should NOT include legacy dbMigrate function', () => {
|
|
161
113
|
const result = createBaseDefinition({}, {}, {});
|
|
162
114
|
|
|
@@ -181,6 +133,27 @@ describe('Base Definition Factory', () => {
|
|
|
181
133
|
expect(result.resources.Resources.ApiGatewayAlarm5xx).toBeDefined();
|
|
182
134
|
});
|
|
183
135
|
|
|
136
|
+
it('alarms on the HTTP API 5xx metric of the API osls creates', () => {
|
|
137
|
+
// The Frigg functions use `httpApi` events, so osls creates an
|
|
138
|
+
// API Gateway v2 HTTP API (logical ID HttpApi) with only the
|
|
139
|
+
// `$default` stage. HTTP APIs publish `5xx` (REST APIs publish
|
|
140
|
+
// `5XXError`) with the ApiId dimension; a Stage dimension set to
|
|
141
|
+
// the deploy stage name would never match `$default`.
|
|
142
|
+
const result = createBaseDefinition({}, {}, {});
|
|
143
|
+
const usesHttpApi = Object.values(result.functions).some((fn) =>
|
|
144
|
+
(fn.events || []).some((event) => event.httpApi)
|
|
145
|
+
);
|
|
146
|
+
expect(usesHttpApi).toBe(true);
|
|
147
|
+
|
|
148
|
+
const alarm = result.resources.Resources.ApiGatewayAlarm5xx;
|
|
149
|
+
expect(alarm.Properties).toMatchObject({
|
|
150
|
+
Namespace: 'AWS/ApiGateway',
|
|
151
|
+
MetricName: '5xx',
|
|
152
|
+
Dimensions: [{ Name: 'ApiId', Value: { Ref: 'HttpApi' } }],
|
|
153
|
+
AlarmActions: [{ Ref: 'InternalErrorBridgeTopic' }],
|
|
154
|
+
});
|
|
155
|
+
});
|
|
156
|
+
|
|
184
157
|
it('should include base IAM permissions', () => {
|
|
185
158
|
const result = createBaseDefinition({}, {}, {});
|
|
186
159
|
|