@friggframework/devtools 2.0.0--canary.704.6a606c3.0 → 2.0.0--canary.707.2702ff3.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 (81) hide show
  1. package/README.md +0 -14
  2. package/frigg-cli/README.md +30 -83
  3. package/frigg-cli/__tests__/unit/commands/generate-iam.test.js +0 -18
  4. package/frigg-cli/__tests__/unit/commands/install.test.js +341 -594
  5. package/frigg-cli/__tests__/unit/commands/provider-dispatch.test.js +140 -0
  6. package/frigg-cli/__tests__/unit/dependencies.test.js +5 -3
  7. package/frigg-cli/build-command/index.js +32 -1
  8. package/frigg-cli/db-setup-command/index.js +25 -0
  9. package/frigg-cli/deploy-command/index.js +50 -2
  10. package/frigg-cli/doctor-command/index.js +7 -0
  11. package/frigg-cli/generate-command/index.js +0 -1
  12. package/frigg-cli/generate-iam-command.js +7 -1
  13. package/frigg-cli/index.js +4 -12
  14. package/frigg-cli/init-command/backend-first-handler.js +554 -397
  15. package/frigg-cli/init-command/index.js +35 -82
  16. package/frigg-cli/install-command/commit-changes.js +8 -40
  17. package/frigg-cli/install-command/environment-variables.js +0 -15
  18. package/frigg-cli/install-command/index.js +21 -96
  19. package/frigg-cli/install-command/install-package.js +4 -77
  20. package/frigg-cli/install-command/integration-file.js +11 -20
  21. package/frigg-cli/install-command/template.js +75 -102
  22. package/frigg-cli/install-command/validate-package.js +4 -36
  23. package/frigg-cli/package.json +3 -3
  24. package/frigg-cli/repair-command/index.js +7 -0
  25. package/frigg-cli/start-command/index.js +58 -0
  26. package/frigg-cli/test/init-command.test.js +2 -9
  27. package/frigg-cli/utils/provider-helper.js +80 -0
  28. package/infrastructure/README.md +4 -22
  29. package/infrastructure/__tests__/compose-extension-prisma.test.js +168 -0
  30. package/infrastructure/__tests__/create-frigg-infrastructure-provider.test.js +64 -0
  31. package/infrastructure/__tests__/management-api-gateway-routes.test.js +335 -0
  32. package/infrastructure/__tests__/template-generation.test.js +7 -0
  33. package/infrastructure/compose-extension-prisma.js +73 -0
  34. package/infrastructure/create-frigg-infrastructure.js +14 -0
  35. package/infrastructure/docs/POSTGRES-CONFIGURATION.md +1 -21
  36. package/infrastructure/domains/admin-scripts/admin-script-builder.js +48 -56
  37. package/infrastructure/domains/admin-scripts/admin-script-builder.test.js +7 -76
  38. package/infrastructure/domains/database/aurora-builder.js +2 -13
  39. package/infrastructure/domains/database/aurora-builder.test.js +0 -22
  40. package/infrastructure/domains/database/migration-builder.js +175 -182
  41. package/infrastructure/domains/database/migration-builder.test.js +5 -36
  42. package/infrastructure/domains/integration/integration-builder.js +61 -65
  43. package/infrastructure/domains/integration/integration-builder.test.js +8 -73
  44. package/infrastructure/domains/parameters/offload-utils.js +1 -0
  45. package/infrastructure/domains/security/iam-generator.js +5 -112
  46. package/infrastructure/domains/security/iam-generator.test.js +0 -94
  47. package/infrastructure/domains/shared/environment-builder.js +12 -1
  48. package/infrastructure/domains/shared/environment-builder.test.js +20 -0
  49. package/infrastructure/domains/shared/types/app-definition.js +15 -1
  50. package/infrastructure/domains/shared/utilities/base-definition-factory.js +152 -93
  51. package/infrastructure/domains/shared/utilities/base-definition-factory.test.js +111 -117
  52. package/infrastructure/domains/shared/utilities/logging-config.js +4 -3
  53. package/infrastructure/domains/shared/utilities/logging-config.test.js +2 -1
  54. package/infrastructure/domains/shared/utilities/prisma-layer-manager.js +10 -0
  55. package/infrastructure/infrastructure-composer.js +13 -1
  56. package/infrastructure/infrastructure-composer.test.js +10 -3
  57. package/infrastructure/provider-build.js +126 -0
  58. package/infrastructure/scripts/build-prisma-layer.js +32 -5
  59. package/infrastructure/scripts/build-prisma-layer.test.js +35 -0
  60. package/package.json +8 -13
  61. package/test/npm-install-guard.js +104 -0
  62. package/test/npm-install-guard.test.js +53 -0
  63. package/frigg-cli/__tests__/unit/commands/init.test.js +0 -688
  64. package/frigg-cli/__tests__/unit/utils/node-version.test.js +0 -66
  65. package/frigg-cli/init-command/deployment-modes.js +0 -7
  66. package/frigg-cli/init-command/safe-path.js +0 -58
  67. package/frigg-cli/init-command/scaffold-dependencies.js +0 -202
  68. package/frigg-cli/install-command/app-definition.js +0 -174
  69. package/frigg-cli/install-command/resolve-module.js +0 -69
  70. package/frigg-cli/templates/backend/README.md +0 -267
  71. package/frigg-cli/templates/backend/env.example +0 -20
  72. package/frigg-cli/templates/backend/gitignore +0 -10
  73. package/frigg-cli/templates/backend/index.js +0 -114
  74. package/frigg-cli/templates/backend/infrastructure.js +0 -20
  75. package/frigg-cli/utils/node-version.js +0 -51
  76. package/infrastructure/__tests__/package-patterns-composition.test.js +0 -153
  77. package/infrastructure/__tests__/scaffold-default-infrastructure.test.js +0 -148
  78. package/infrastructure/domains/shared/utilities/framework-version.js +0 -14
  79. package/infrastructure/domains/shared/utilities/framework-version.test.js +0 -27
  80. package/infrastructure/domains/shared/utilities/package-patterns.js +0 -35
  81. package/infrastructure/domains/shared/utilities/package-patterns.test.js +0 -112
@@ -9,9 +9,27 @@
9
9
 
10
10
  const { buildEnvironment } = require('../environment-builder');
11
11
  const { nestedNodeModulesExcludes } = require('./nested-node-modules');
12
- const { toPackagePatterns } = require('./package-patterns');
13
12
  const { buildLoggingProviderConfig } = require('./logging-config');
14
- const { OSLS_FRAMEWORK_VERSION } = require('./framework-version');
13
+ const {
14
+ getGatewayRoutes,
15
+ } = require('@friggframework/core/management-api/route-registry');
16
+
17
+ /**
18
+ * HTTP API events for one function, from core's route registry (ADR-053):
19
+ * the same registry mounts the Express routers and builds the OpenAPI
20
+ * documents, so the three cannot drift. It also lists /api/docs and the core
21
+ * extensions' admin routes (/admin/<name>, served by the auth Lambda).
22
+ */
23
+ function managementApiEvents(AppDefinition, functionName) {
24
+ const managementApi = AppDefinition.managementApi || {};
25
+ return getGatewayRoutes({
26
+ v1: managementApi.v1 !== false,
27
+ proxy: managementApi.proxy?.enable === true,
28
+ coreExtensions: AppDefinition.coreExtensions,
29
+ })
30
+ .filter((route) => route.function === functionName)
31
+ .map(({ method, path }) => ({ httpApi: { path, method } }));
32
+ }
15
33
 
16
34
  /**
17
35
  * Create base serverless definition with core functions and resources
@@ -39,95 +57,143 @@ function createBaseDefinition(
39
57
  const loggingConfig = buildLoggingProviderConfig(AppDefinition.logging);
40
58
 
41
59
  // Package config for handlers that skip esbuild (need node_modules dependencies)
42
- // Include backend src/ and index.js since handlers load the app definition.
43
- // osls 4 only reads package.patterns (ADR-050): excludes first, then includes.
60
+ // Include backend src/ and index.js since handlers load the app definition
44
61
  const skipEsbuildPackageConfig = {
45
- patterns: toPackagePatterns({
46
- // Explicitly include project files that handlers need
47
- include: [
48
- // Include DocumentDB TLS certificate if configured
49
- ...(AppDefinition.database?.documentDB?.tlsCAFile
50
- ? [AppDefinition.database.documentDB.tlsCAFile.replace(/^\.\//, '')]
51
- : []),
52
- ],
53
- exclude: [
54
- // Exclude Prisma (provided via Lambda Layer)
55
- ...(usePrismaLayer ? [
56
- 'node_modules/@prisma/**',
57
- 'node_modules/.prisma/**',
58
- 'node_modules/prisma/**',
59
- 'node_modules/@friggframework/core/generated/**',
60
- ] : []),
62
+ // Explicitly include project files that handlers need
63
+ include: [
64
+ // Include DocumentDB TLS certificate if configured
65
+ ...(AppDefinition.database?.documentDB?.tlsCAFile
66
+ ? [AppDefinition.database.documentDB.tlsCAFile.replace(/^\.\//, '')]
67
+ : []),
68
+ ],
69
+ exclude: [
70
+ // Exclude Prisma (provided via Lambda Layer)
71
+ ...(usePrismaLayer ? [
72
+ 'node_modules/@prisma/**',
73
+ 'node_modules/.prisma/**',
74
+ 'node_modules/prisma/**',
75
+ 'node_modules/@friggframework/core/generated/**',
76
+ ] : []),
61
77
 
62
- // Exclude AWS SDK (provided by Lambda runtime)
63
- 'node_modules/aws-sdk/**',
64
- 'node_modules/@aws-sdk/**',
78
+ // Exclude AWS SDK (provided by Lambda runtime)
79
+ 'node_modules/aws-sdk/**',
80
+ 'node_modules/@aws-sdk/**',
65
81
 
66
- // Exclude dev/test dependencies
67
- 'node_modules/@friggframework/test/**',
68
- 'node_modules/@friggframework/eslint-config/**',
69
- 'node_modules/@friggframework/prettier-config/**',
70
- 'node_modules/jest/**',
71
- 'node_modules/prettier/**',
72
- 'node_modules/eslint/**',
82
+ // Exclude dev/test dependencies
83
+ 'node_modules/@friggframework/test/**',
84
+ 'node_modules/@friggframework/eslint-config/**',
85
+ 'node_modules/@friggframework/prettier-config/**',
86
+ 'node_modules/jest/**',
87
+ 'node_modules/prettier/**',
88
+ 'node_modules/eslint/**',
73
89
 
74
- ...nestedNodeModulesExcludes(AppDefinition, usePrismaLayer),
90
+ ...nestedNodeModulesExcludes(AppDefinition, usePrismaLayer),
75
91
 
76
- // Exclude build tools (not needed at runtime)
77
- 'node_modules/esbuild/**',
78
- 'node_modules/@esbuild/**',
79
- 'node_modules/typescript/**',
80
- 'node_modules/webpack/**',
81
- 'node_modules/osls/**',
82
- 'node_modules/serverless-esbuild/**',
83
- 'node_modules/serverless-jetpack/**',
84
- 'node_modules/serverless-offline/**',
85
- 'node_modules/serverless-offline-sqs/**',
86
- 'node_modules/serverless-dotenv-plugin/**',
87
- 'node_modules/serverless-kms-grants/**',
88
- // Note: DO NOT exclude serverless-http - it's a runtime dependency!
92
+ // Exclude build tools (not needed at runtime)
93
+ 'node_modules/esbuild/**',
94
+ 'node_modules/@esbuild/**',
95
+ 'node_modules/typescript/**',
96
+ 'node_modules/webpack/**',
97
+ 'node_modules/osls/**',
98
+ 'node_modules/serverless-esbuild/**',
99
+ 'node_modules/serverless-jetpack/**',
100
+ 'node_modules/serverless-offline/**',
101
+ 'node_modules/serverless-offline-sqs/**',
102
+ 'node_modules/serverless-dotenv-plugin/**',
103
+ 'node_modules/serverless-kms-grants/**',
104
+ // Note: DO NOT exclude serverless-http - it's a runtime dependency!
89
105
 
90
- // Exclude local dev files and environment files (NEVER deploy .env files!)
91
- '.env',
92
- '.env.*',
93
- '.env.local',
94
- '.env.*.local',
95
- '**/.env',
96
- '**/.env.*',
97
- 'deploy.log',
98
- '.env.backup',
99
- 'docker-compose.yml',
100
- 'jest.config.js',
101
- 'jest.unit.config.js',
102
- '.eslintrc.json',
103
- '.prettierrc',
104
- '.prettierignore',
105
- '.markdownlintignore',
106
- 'package-lock.json',
106
+ // Exclude local dev files and environment files (NEVER deploy .env files!)
107
+ '.env',
108
+ '.env.*',
109
+ '.env.local',
110
+ '.env.*.local',
111
+ '**/.env',
112
+ '**/.env.*',
113
+ 'deploy.log',
114
+ '.env.backup',
115
+ 'docker-compose.yml',
116
+ 'jest.config.js',
117
+ 'jest.unit.config.js',
118
+ '.eslintrc.json',
119
+ '.prettierrc',
120
+ '.prettierignore',
121
+ '.markdownlintignore',
122
+ 'package-lock.json',
107
123
 
108
- // Exclude test files and layers (keep src/ - needed for app definition and integrations)
109
- 'test/**',
110
- 'layers/**',
111
- 'coverage/**',
112
- // Note: DO NOT exclude src/** - handlers need src/integrations and src/api-modules at runtime
113
- '**/*.test.js',
114
- '**/*.spec.js',
115
- '**/.claude-flow/**',
116
- '**/.swarm/**',
117
- ],
118
- }),
124
+ // Exclude test files and layers (keep src/ - needed for app definition and integrations)
125
+ 'test/**',
126
+ 'layers/**',
127
+ 'coverage/**',
128
+ // Note: DO NOT exclude src/** - handlers need src/integrations and src/api-modules at runtime
129
+ '**/*.test.js',
130
+ '**/*.spec.js',
131
+ '**/.claude-flow/**',
132
+ '**/.swarm/**',
133
+ ],
134
+ };
135
+
136
+ // Function-level package config to exclude Prisma and AWS SDK
137
+ const functionPackageConfig = {
138
+ exclude: [
139
+ // Exclude AWS SDK (already in Lambda runtime or externalized by esbuild)
140
+ 'node_modules/aws-sdk/**',
141
+ 'node_modules/@aws-sdk/**',
142
+
143
+ // Exclude Prisma (provided via Lambda Layer)
144
+ ...(usePrismaLayer ? [
145
+ 'node_modules/@prisma/**',
146
+ 'node_modules/.prisma/**',
147
+ 'node_modules/prisma/**',
148
+ 'node_modules/@friggframework/core/generated/**',
149
+ ] : []),
150
+
151
+ // Exclude nested node_modules from symlinked frigg packages (for npm link development)
152
+ 'node_modules/@friggframework/core/node_modules/**',
153
+ 'node_modules/@friggframework/devtools/node_modules/**',
154
+
155
+ // Exclude environment files (NEVER deploy .env files!)
156
+ '.env',
157
+ '.env.*',
158
+ '.env.local',
159
+ '.env.*.local',
160
+ '**/.env',
161
+ '**/.env.*',
162
+
163
+ // Exclude development/test files from backend project
164
+ 'coverage/**',
165
+ 'test/**',
166
+ 'src/**',
167
+ 'layers/**',
168
+ '**/*.test.js',
169
+ '**/*.spec.js',
170
+ '.git/**',
171
+ '.github/**',
172
+
173
+ // Exclude AI assistant and development artifacts
174
+ '**/.claude-flow/**',
175
+ '**/.swarm/**',
176
+ '**/CLAUDE.md',
177
+ '**/README.md',
178
+ '**/*.md',
179
+
180
+ // Exclude config and meta files from core
181
+ 'node_modules/@friggframework/core/.eslintrc.json',
182
+ 'node_modules/@friggframework/core/.gitignore',
183
+ 'node_modules/@friggframework/core/jest.config.js',
184
+ 'node_modules/@friggframework/core/CHANGELOG.md',
185
+ ],
119
186
  };
120
187
 
121
188
  return {
122
- frameworkVersion: OSLS_FRAMEWORK_VERSION,
189
+ frameworkVersion: loggingConfig.frameworkVersion || '>=3.17.0',
123
190
  service: AppDefinition.name || 'create-frigg-app',
124
191
  package: {
125
192
  individually: true,
126
193
  },
127
194
  // Only use .env for local development (offline mode)
128
- // Production deployments should use environment vars from infrastructure.
129
- // Emitted only when true: osls 4 accepts `useDotenv: true` or no key (ADR-050).
130
- ...(process.argv.includes('offline') && { useDotenv: true }),
195
+ // Production deployments should use environment vars from infrastructure
196
+ useDotenv: process.argv.includes('offline'),
131
197
  provider: {
132
198
  name: AppDefinition.provider || 'aws',
133
199
  ...(process.env.AWS_PROFILE && { profile: process.env.AWS_PROFILE }),
@@ -240,16 +306,12 @@ function createBaseDefinition(
240
306
  ...(usePrismaLayer && { layers: [{ Ref: 'PrismaLambdaLayer' }] }),
241
307
  skipEsbuild: true, // Handlers in node_modules don't need bundling
242
308
  package: skipEsbuildPackageConfig,
243
- events: [
244
- { httpApi: { path: '/api/integrations', method: 'ANY' } },
245
- {
246
- httpApi: {
247
- path: '/api/integrations/{proxy+}',
248
- method: 'ANY',
249
- },
250
- },
251
- { httpApi: { path: '/api/authorize', method: 'ANY' } },
252
- ],
309
+ // Every Management API path the auth Lambda serves (v1, v2 per
310
+ // resource, the OAuth redirect) comes from core's route
311
+ // registry. HTTP API has no implicit catch-all, so an unlisted
312
+ // prefix 404s at the gateway before Express sees it. Guarded by
313
+ // __tests__/management-api-gateway-routes.test.js.
314
+ events: managementApiEvents(AppDefinition, 'auth'),
253
315
  },
254
316
  user: {
255
317
  handler: 'node_modules/@friggframework/core/handlers/routers/user.handler',
@@ -266,6 +328,8 @@ function createBaseDefinition(
266
328
  events: [
267
329
  { httpApi: { path: '/health', method: 'GET' } },
268
330
  { httpApi: { path: '/health/{proxy+}', method: 'GET' } },
331
+ // GET /api/meta and the OpenAPI documents: public, DB-free.
332
+ ...managementApiEvents(AppDefinition, 'health'),
269
333
  ],
270
334
  },
271
335
  // Reporting is an admin operation (ADR-010): the report router runs on the admin-scripts Lambda, not as a standalone function here.
@@ -337,18 +401,12 @@ function createBaseDefinition(
337
401
  },
338
402
  },
339
403
  },
340
- // The functions above use `httpApi` events, so osls creates
341
- // an HTTP API (API Gateway v2, logical ID HttpApi) with only
342
- // the `$default` stage. HTTP APIs publish `5xx`, not the REST
343
- // API metric `5XXError`, and the ApiId dimension identifies
344
- // this API (a Stage dimension would have to be `$default`).
345
- // https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-metrics.html
346
404
  ApiGatewayAlarm5xx: {
347
405
  Type: 'AWS::CloudWatch::Alarm',
348
406
  Properties: {
349
407
  AlarmDescription: 'API Gateway 5xx Errors',
350
408
  Namespace: 'AWS/ApiGateway',
351
- MetricName: '5xx',
409
+ MetricName: '5XXError',
352
410
  Statistic: 'Sum',
353
411
  Threshold: 0,
354
412
  ComparisonOperator: 'GreaterThanThreshold',
@@ -357,6 +415,7 @@ function createBaseDefinition(
357
415
  AlarmActions: [{ Ref: 'InternalErrorBridgeTopic' }],
358
416
  Dimensions: [
359
417
  { Name: 'ApiId', Value: { Ref: 'HttpApi' } },
418
+ { Name: 'Stage', Value: '${self:provider.stage}' },
360
419
  ],
361
420
  },
362
421
  },
@@ -5,7 +5,6 @@
5
5
  */
6
6
 
7
7
  const { createBaseDefinition } = require('./base-definition-factory');
8
- const { OSLS_FRAMEWORK_VERSION } = require('./framework-version');
9
8
 
10
9
  describe('Base Definition Factory', () => {
11
10
  beforeEach(() => {
@@ -24,7 +23,7 @@ describe('Base Definition Factory', () => {
24
23
  const result = createBaseDefinition(appDefinition, appEnvironmentVars, discoveredResources);
25
24
 
26
25
  expect(result.service).toBe('test-app');
27
- expect(result.frameworkVersion).toBe(OSLS_FRAMEWORK_VERSION);
26
+ expect(result.frameworkVersion).toBe('>=3.17.0');
28
27
  expect(result.provider.name).toBe('aws');
29
28
  expect(result.provider.runtime).toBe('nodejs22.x');
30
29
  expect(result.provider.timeout).toBe(29);
@@ -95,7 +94,91 @@ describe('Base Definition Factory', () => {
95
94
 
96
95
  expect(result.functions.auth.handler).toBe('node_modules/@friggframework/core/handlers/routers/auth.handler');
97
96
  expect(result.functions.auth.layers).toEqual([{ Ref: 'PrismaLambdaLayer' }]);
98
- 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
+ // v1 (deprecated, ADR-053)
103
+ 'ANY /api/integrations',
104
+ 'ANY /api/integrations/{proxy+}',
105
+ 'ANY /api/authorize',
106
+ 'ANY /api/entity',
107
+ 'ANY /api/entity/{proxy+}',
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
+ ]);
119
+ });
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
+ // Redirects to /api/meta/openapi/v2.json (ADR-053 docs path)
146
+ 'GET /api/docs',
147
+ ]);
148
+ });
149
+
150
+ it('routes each core extension admin path (and below) to the auth function', () => {
151
+ const result = createBaseDefinition(
152
+ {
153
+ coreExtensions: [
154
+ { name: 'db-credentials', routes: { path: '/admin/oauth-credentials' } },
155
+ { name: 'no-routes' },
156
+ ],
157
+ },
158
+ {},
159
+ {}
160
+ );
161
+ const routes = result.functions.auth.events.map(
162
+ (e) => `${e.httpApi.method} ${e.httpApi.path}`
163
+ );
164
+ expect(routes).toContain('ANY /admin/oauth-credentials');
165
+ expect(routes).toContain('ANY /admin/oauth-credentials/{proxy+}');
166
+ // Never a catch-all that would shadow /admin/scripts or /admin/db-migrate.
167
+ expect(routes).not.toContain('ANY /admin/{proxy+}');
168
+ // The HTTP queue route is for hosts without SQS, never AWS.
169
+ expect(JSON.stringify(result.functions)).not.toContain('/admin/queue');
170
+ });
171
+
172
+ it('drops the v1 routes when managementApi.v1 is false, keeping the OAuth redirect', () => {
173
+ const result = createBaseDefinition({ managementApi: { v1: false } }, {}, {});
174
+ const routes = result.functions.auth.events.map(
175
+ (e) => `${e.httpApi.method} ${e.httpApi.path}`
176
+ );
177
+ expect(routes).not.toContain('ANY /api/integrations');
178
+ expect(routes).not.toContain('ANY /api/authorize');
179
+ expect(routes).not.toContain('ANY /api/entity');
180
+ expect(routes).toContain('GET /api/integrations/redirect/{appId}');
181
+ expect(routes).toContain('ANY /api/v2/integrations');
99
182
  });
100
183
 
101
184
  it('should NOT include legacy dbMigrate function', () => {
@@ -122,27 +205,6 @@ describe('Base Definition Factory', () => {
122
205
  expect(result.resources.Resources.ApiGatewayAlarm5xx).toBeDefined();
123
206
  });
124
207
 
125
- it('alarms on the HTTP API 5xx metric of the API osls creates', () => {
126
- // The Frigg functions use `httpApi` events, so osls creates an
127
- // API Gateway v2 HTTP API (logical ID HttpApi) with only the
128
- // `$default` stage. HTTP APIs publish `5xx` (REST APIs publish
129
- // `5XXError`) with the ApiId dimension; a Stage dimension set to
130
- // the deploy stage name would never match `$default`.
131
- const result = createBaseDefinition({}, {}, {});
132
- const usesHttpApi = Object.values(result.functions).some((fn) =>
133
- (fn.events || []).some((event) => event.httpApi)
134
- );
135
- expect(usesHttpApi).toBe(true);
136
-
137
- const alarm = result.resources.Resources.ApiGatewayAlarm5xx;
138
- expect(alarm.Properties).toMatchObject({
139
- Namespace: 'AWS/ApiGateway',
140
- MetricName: '5xx',
141
- Dimensions: [{ Name: 'ApiId', Value: { Ref: 'HttpApi' } }],
142
- AlarmActions: [{ Ref: 'InternalErrorBridgeTopic' }],
143
- });
144
- });
145
-
146
208
  it('should include base IAM permissions', () => {
147
209
  const result = createBaseDefinition({}, {}, {});
148
210
 
@@ -258,75 +320,12 @@ describe('Base Definition Factory', () => {
258
320
  expect(result.package.individually).toBe(true);
259
321
  });
260
322
 
261
- describe('useDotenv (ADR-050)', () => {
262
- const originalArgv = process.argv;
263
- afterEach(() => {
264
- process.argv = originalArgv;
265
- });
266
-
267
- it.each([['package'], ['deploy'], ['print']])(
268
- 'omits useDotenv for `osls %s` (osls 4 only accepts true)',
269
- (command) => {
270
- process.argv = ['node', 'osls', command, '--stage', 'prod'];
271
- const result = createBaseDefinition({}, {}, {});
272
-
273
- expect(result).not.toHaveProperty('useDotenv');
274
- expect(result.plugins).not.toContain('serverless-dotenv-plugin');
275
- }
276
- );
277
-
278
- it('sets useDotenv: true for `osls offline`', () => {
279
- process.argv = ['node', 'osls', 'offline', '--stage', 'dev'];
280
- const result = createBaseDefinition({}, {}, {});
281
-
282
- expect(result.useDotenv).toBe(true);
283
- expect(result.plugins).toContain('serverless-dotenv-plugin');
284
- });
285
- });
286
-
287
- describe('function package patterns (ADR-050)', () => {
288
- it('emits package.patterns and no include/exclude on auth, user and health', () => {
289
- const result = createBaseDefinition({}, {}, {});
290
-
291
- for (const fn of ['auth', 'user', 'health']) {
292
- const pkg = result.functions[fn].package;
293
- expect(pkg).not.toHaveProperty('include');
294
- expect(pkg).not.toHaveProperty('exclude');
295
- expect(Array.isArray(pkg.patterns)).toBe(true);
296
- expect(pkg.patterns).toEqual(
297
- expect.arrayContaining([
298
- '!node_modules/aws-sdk/**',
299
- '!node_modules/@aws-sdk/**',
300
- '!.env',
301
- '!**/.env.*',
302
- '!package-lock.json',
303
- '!test/**',
304
- '!layers/**',
305
- ])
306
- );
307
- // No exclude pattern removes src/: handlers load the app definition from it.
308
- expect(pkg.patterns).not.toContain('!src/**');
309
- }
310
- });
311
-
312
- it('puts the DocumentDB CA file after every exclude so it is re-added', () => {
313
- const result = createBaseDefinition(
314
- { database: { documentDB: { tlsCAFile: './certs/global-bundle.pem' } } },
315
- {},
316
- {}
317
- );
318
- const { patterns } = result.functions.auth.package;
319
-
320
- expect(patterns[patterns.length - 1]).toBe('certs/global-bundle.pem');
321
- expect(patterns.slice(0, -1).every((p) => p.startsWith('!'))).toBe(true);
322
- });
323
+ it('should enable dotenv only in offline mode', () => {
324
+ const result = createBaseDefinition({}, {}, {});
323
325
 
324
- it('emits only negated excludes when no CA file is configured', () => {
325
- const result = createBaseDefinition({}, {}, {});
326
- expect(
327
- result.functions.auth.package.patterns.every((p) => p.startsWith('!'))
328
- ).toBe(true);
329
- });
326
+ // useDotenv is conditional - only true when process.argv includes 'offline'
327
+ expect(result.useDotenv).toBeDefined();
328
+ expect(typeof result.useDotenv).toBe('boolean');
330
329
  });
331
330
 
332
331
  describe('usePrismaLayer configuration', () => {
@@ -335,12 +334,12 @@ describe('Base Definition Factory', () => {
335
334
 
336
335
  expect(result.layers.prisma).toBeDefined();
337
336
  expect(result.functions.auth.layers).toEqual([{ Ref: 'PrismaLambdaLayer' }]);
338
- expect(result.functions.auth.package.patterns).toEqual(
337
+ expect(result.functions.auth.package.exclude).toEqual(
339
338
  expect.arrayContaining([
340
- '!node_modules/@prisma/**',
341
- '!node_modules/.prisma/**',
342
- '!node_modules/prisma/**',
343
- '!node_modules/@friggframework/core/generated/**',
339
+ 'node_modules/@prisma/**',
340
+ 'node_modules/.prisma/**',
341
+ 'node_modules/prisma/**',
342
+ 'node_modules/@friggframework/core/generated/**',
344
343
  ])
345
344
  );
346
345
  expect(result.custom.esbuild.external).toEqual(
@@ -353,12 +352,12 @@ describe('Base Definition Factory', () => {
353
352
 
354
353
  expect(result.layers).toEqual({});
355
354
  expect(result.functions.auth.layers).toBeUndefined();
356
- expect(result.functions.auth.package.patterns).not.toEqual(
355
+ expect(result.functions.auth.package.exclude).not.toEqual(
357
356
  expect.arrayContaining([
358
- '!node_modules/@prisma/**',
359
- '!node_modules/.prisma/**',
360
- '!node_modules/prisma/**',
361
- '!node_modules/@friggframework/core/generated/**',
357
+ 'node_modules/@prisma/**',
358
+ 'node_modules/.prisma/**',
359
+ 'node_modules/prisma/**',
360
+ 'node_modules/@friggframework/core/generated/**',
362
361
  ])
363
362
  );
364
363
  expect(result.custom.esbuild.external).not.toEqual(
@@ -382,7 +381,7 @@ describe('nested node_modules (lambda.keepNestedNodeModules)', () => {
382
381
  const result = build({ name: 'test-app' });
383
382
 
384
383
  for (const fn of ['auth', 'user', 'health']) {
385
- expect(result.functions[fn].package.patterns).toContain('!node_modules/**/node_modules/**');
384
+ expect(result.functions[fn].package.exclude).toContain('node_modules/**/node_modules/**');
386
385
  }
387
386
  });
388
387
 
@@ -390,13 +389,13 @@ describe('nested node_modules (lambda.keepNestedNodeModules)', () => {
390
389
  const result = build({ name: 'test-app', lambda: { keepNestedNodeModules: true } });
391
390
 
392
391
  for (const fn of ['auth', 'user', 'health']) {
393
- const { patterns } = result.functions[fn].package;
394
- expect(patterns).not.toContain('!node_modules/**/node_modules/**');
395
- expect(patterns).toEqual(
392
+ const { exclude } = result.functions[fn].package;
393
+ expect(exclude).not.toContain('node_modules/**/node_modules/**');
394
+ expect(exclude).toEqual(
396
395
  expect.arrayContaining([
397
- '!node_modules/**/node_modules/@friggframework/**',
398
- '!node_modules/**/node_modules/@aws-sdk/**',
399
- '!node_modules/**/node_modules/@prisma/**',
396
+ 'node_modules/**/node_modules/@friggframework/**',
397
+ 'node_modules/**/node_modules/@aws-sdk/**',
398
+ 'node_modules/**/node_modules/@prisma/**',
400
399
  ])
401
400
  );
402
401
  }
@@ -412,14 +411,14 @@ describe('logging (ADR-048)', () => {
412
411
 
413
412
  expect(result.provider.logs).toBeUndefined();
414
413
  expect(result.provider.logRetentionInDays).toBeUndefined();
415
- expect(result.frameworkVersion).toBe(OSLS_FRAMEWORK_VERSION);
414
+ expect(result.frameworkVersion).toBe('>=3.17.0');
416
415
  });
417
416
 
418
417
  it('validates logging.level but leaves the Lambda log format and frameworkVersion alone by default', () => {
419
418
  const result = build({ level: 'warn' });
420
419
 
421
420
  expect(result.provider.logs).toBeUndefined();
422
- expect(result.frameworkVersion).toBe(OSLS_FRAMEWORK_VERSION);
421
+ expect(result.frameworkVersion).toBe('>=3.17.0');
423
422
  });
424
423
 
425
424
  it.each(['verbose', 'warning', '', 3])('throws on unknown level %p', (level) => {
@@ -431,12 +430,7 @@ describe('logging (ADR-048)', () => {
431
430
 
432
431
  expect(result.provider.logRetentionInDays).toBe(30);
433
432
  expect(result.provider.logs).toBeUndefined();
434
- expect(result.frameworkVersion).toBe(OSLS_FRAMEWORK_VERSION);
435
- });
436
-
437
- it('keeps the single osls frameworkVersion even when the Lambda LoggingConfig is on (ADR-050)', () => {
438
- const result = build({ level: 'warn' });
439
- expect(result.frameworkVersion).toBe('^4.4.0');
433
+ expect(result.frameworkVersion).toBe('>=3.17.0');
440
434
  });
441
435
 
442
436
  it('accepts 1096, which CloudWatch allows but the osls schema omits', () => {
@@ -6,8 +6,8 @@ const RETENTION_DAYS = [
6
6
  2192, 2557, 2922, 3288, 3653,
7
7
  ];
8
8
 
9
- // provider.logs.lambda compiles to LoggingConfig from osls 3.58.0; the base
10
- // definition's single frameworkVersion (^4.4.0, ADR-050) already covers it.
9
+ // First osls version that compiles provider.logs.lambda into LoggingConfig.
10
+ const LOGGING_CONFIG_FRAMEWORK_VERSION = '>=3.58.0';
11
11
 
12
12
  // ADR-048 Open question 3: off until the Phase 0 spike proves Lambda JSON mode
13
13
  // keeps direct fd 1 lines intact. Until then Lambda stays on Text and
@@ -39,7 +39,7 @@ function validateRetentionInDays(retentionInDays) {
39
39
  *
40
40
  * @param {Object} [logging] - appDefinition.logging
41
41
  * @param {{ lambdaJson?: boolean }} [options]
42
- * @returns {{ provider?: Object }}
42
+ * @returns {{ frameworkVersion?: string, provider?: Object }}
43
43
  */
44
44
  function buildLoggingProviderConfig(
45
45
  logging,
@@ -53,6 +53,7 @@ function buildLoggingProviderConfig(
53
53
  if (logging.level !== undefined) {
54
54
  const level = normalizeLogLevel(logging.level);
55
55
  if (lambdaJson) {
56
+ result.frameworkVersion = LOGGING_CONFIG_FRAMEWORK_VERSION;
56
57
  provider.logs = {
57
58
  lambda: {
58
59
  logFormat: 'JSON',