@friggframework/devtools 2.0.0--canary.667.a0620c7.0 → 2.0.0--canary.682.451c957.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 (62) hide show
  1. package/frigg-cli/README.md +30 -77
  2. package/frigg-cli/__tests__/unit/commands/deploy.test.js +24 -30
  3. package/frigg-cli/__tests__/unit/commands/doctor.test.js +6 -10
  4. package/frigg-cli/__tests__/unit/commands/generate-iam.test.js +0 -18
  5. package/frigg-cli/__tests__/unit/commands/install.test.js +341 -601
  6. package/frigg-cli/__tests__/unit/commands/ui.test.js +30 -31
  7. package/frigg-cli/__tests__/unit/dependencies.test.js +2 -6
  8. package/frigg-cli/generate-command/index.js +0 -1
  9. package/frigg-cli/generate-iam-command.js +0 -1
  10. package/frigg-cli/index.js +4 -9
  11. package/frigg-cli/index.test.js +158 -0
  12. package/frigg-cli/init-command/backend-first-handler.js +554 -397
  13. package/frigg-cli/init-command/index.js +35 -82
  14. package/frigg-cli/install-command/commit-changes.js +8 -40
  15. package/frigg-cli/install-command/environment-variables.js +0 -15
  16. package/frigg-cli/install-command/index.js +21 -96
  17. package/frigg-cli/install-command/install-package.js +4 -77
  18. package/frigg-cli/install-command/integration-file.js +11 -20
  19. package/frigg-cli/install-command/template.js +75 -102
  20. package/frigg-cli/install-command/validate-package.js +4 -36
  21. package/frigg-cli/package.json +1 -1
  22. package/frigg-cli/test/init-command.test.js +2 -9
  23. package/infrastructure/__tests__/management-api-gateway-routes.test.js +94 -40
  24. package/infrastructure/__tests__/postgres-config.test.js +835 -241
  25. package/infrastructure/__tests__/template-generation.test.js +8 -36
  26. package/infrastructure/docs/POSTGRES-CONFIGURATION.md +1 -21
  27. package/infrastructure/domains/admin-scripts/admin-script-builder.js +2 -6
  28. package/infrastructure/domains/admin-scripts/admin-script-builder.test.js +0 -30
  29. package/infrastructure/domains/database/aurora-builder.js +2 -13
  30. package/infrastructure/domains/database/aurora-builder.test.js +0 -22
  31. package/infrastructure/domains/health/application/use-cases/__tests__/mismatch-analyzer-method-name.test.js +8 -12
  32. package/infrastructure/domains/health/application/use-cases/__tests__/repair-via-import-use-case.test.js +7 -19
  33. package/infrastructure/domains/health/application/use-cases/run-health-check-use-case.test.js +8 -12
  34. package/infrastructure/domains/health/domain/services/__tests__/import-progress-monitor.test.js +18 -17
  35. package/infrastructure/domains/health/domain/services/__tests__/update-progress-monitor.test.js +2 -12
  36. package/infrastructure/domains/health/infrastructure/adapters/__tests__/orphan-detection-relationship-analysis.test.js +1 -8
  37. package/infrastructure/domains/health/infrastructure/adapters/aws-property-reconciler.test.js +2 -4
  38. package/infrastructure/domains/health/infrastructure/adapters/aws-resource-detector.test.js +0 -10
  39. package/infrastructure/domains/networking/vpc-builder.js +8 -18
  40. package/infrastructure/domains/networking/vpc-builder.test.js +12 -26
  41. package/infrastructure/domains/security/iam-generator.js +5 -112
  42. package/infrastructure/domains/security/iam-generator.test.js +0 -94
  43. package/infrastructure/domains/shared/cloudformation-discovery.test.js +6 -36
  44. package/infrastructure/domains/shared/utilities/base-definition-factory.js +27 -35
  45. package/infrastructure/domains/shared/utilities/base-definition-factory.test.js +49 -22
  46. package/infrastructure/infrastructure-composer.test.js +794 -268
  47. package/infrastructure/integration.test.js +381 -0
  48. package/infrastructure/scripts/build-prisma-layer.test.js +7 -28
  49. package/infrastructure/scripts/build-time-discovery.test.js +3 -18
  50. package/package.json +8 -10
  51. package/frigg-cli/__tests__/unit/commands/init.test.js +0 -688
  52. package/frigg-cli/init-command/deployment-modes.js +0 -7
  53. package/frigg-cli/init-command/safe-path.js +0 -58
  54. package/frigg-cli/init-command/scaffold-dependencies.js +0 -202
  55. package/frigg-cli/install-command/app-definition.js +0 -174
  56. package/frigg-cli/install-command/resolve-module.js +0 -69
  57. package/frigg-cli/templates/backend/README.md +0 -267
  58. package/frigg-cli/templates/backend/env.example +0 -20
  59. package/frigg-cli/templates/backend/gitignore +0 -10
  60. package/frigg-cli/templates/backend/index.js +0 -114
  61. package/frigg-cli/templates/backend/infrastructure.js +0 -20
  62. package/infrastructure/__tests__/scaffold-default-infrastructure.test.js +0 -148
@@ -99,16 +99,64 @@ describe('Base Definition Factory', () => {
99
99
  (e) => `${e.httpApi.method} ${e.httpApi.path}`
100
100
  )
101
101
  ).toEqual([
102
+ // v1 (deprecated, ADR-053)
102
103
  'ANY /api/integrations',
103
104
  'ANY /api/integrations/{proxy+}',
104
105
  'ANY /api/authorize',
105
106
  'ANY /api/entity',
106
107
  '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',
109
118
  ]);
110
119
  });
111
120
 
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
+
112
160
  it('should NOT include legacy dbMigrate function', () => {
113
161
  const result = createBaseDefinition({}, {}, {});
114
162
 
@@ -133,27 +181,6 @@ describe('Base Definition Factory', () => {
133
181
  expect(result.resources.Resources.ApiGatewayAlarm5xx).toBeDefined();
134
182
  });
135
183
 
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
-
157
184
  it('should include base IAM permissions', () => {
158
185
  const result = createBaseDefinition({}, {}, {});
159
186