@friggframework/devtools 2.0.0--canary.703.6a9383b.0 → 2.0.0--canary.704.79d9a63.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 (31) hide show
  1. package/README.md +14 -0
  2. package/frigg-cli/README.md +6 -0
  3. package/frigg-cli/__tests__/unit/dependencies.test.js +3 -5
  4. package/frigg-cli/__tests__/unit/utils/node-version.test.js +66 -0
  5. package/frigg-cli/index.js +3 -0
  6. package/frigg-cli/package.json +3 -3
  7. package/frigg-cli/utils/node-version.js +51 -0
  8. package/infrastructure/README.md +20 -0
  9. package/infrastructure/__tests__/package-patterns-composition.test.js +153 -0
  10. package/infrastructure/domains/admin-scripts/admin-script-builder.js +50 -46
  11. package/infrastructure/domains/admin-scripts/admin-script-builder.test.js +46 -7
  12. package/infrastructure/domains/database/migration-builder.js +182 -175
  13. package/infrastructure/domains/database/migration-builder.test.js +36 -5
  14. package/infrastructure/domains/integration/integration-builder.js +65 -80
  15. package/infrastructure/domains/integration/integration-builder.test.js +73 -30
  16. package/infrastructure/domains/shared/function-environments.js +1 -9
  17. package/infrastructure/domains/shared/function-environments.test.js +0 -14
  18. package/infrastructure/domains/shared/utilities/base-definition-factory.js +76 -122
  19. package/infrastructure/domains/shared/utilities/base-definition-factory.test.js +95 -26
  20. package/infrastructure/domains/shared/utilities/framework-version.js +14 -0
  21. package/infrastructure/domains/shared/utilities/framework-version.test.js +27 -0
  22. package/infrastructure/domains/shared/utilities/logging-config.js +3 -4
  23. package/infrastructure/domains/shared/utilities/logging-config.test.js +1 -2
  24. package/infrastructure/domains/shared/utilities/package-patterns.js +35 -0
  25. package/infrastructure/domains/shared/utilities/package-patterns.test.js +112 -0
  26. package/infrastructure/infrastructure-composer.js +0 -2
  27. package/infrastructure/infrastructure-composer.test.js +3 -3
  28. package/package.json +11 -8
  29. package/infrastructure/domains/integration/define-integration-provisioning.test.js +0 -59
  30. package/infrastructure/domains/scheduler/trigger-builder.js +0 -114
  31. package/infrastructure/domains/scheduler/trigger-builder.test.js +0 -82
@@ -620,28 +620,6 @@ describe('IntegrationBuilder', () => {
620
620
  ]);
621
621
  });
622
622
 
623
- it('gives a provider of integration types the webhook routes of every type it provides', async () => {
624
- const appDefinition = {
625
- integrations: [
626
- { Definition: { name: 'stripe', webhooks: true } },
627
- {
628
- Definition: { name: 'integration-runtime', webhooks: { enabled: true } },
629
- IntegrationProvider: { resolve: async () => null, list: async () => [] },
630
- },
631
- ],
632
- };
633
-
634
- const result = await integrationBuilder.build(appDefinition, {});
635
-
636
- expect(result.functions['integration-runtimeWebhook'].events.map((e) => e.httpApi.path)).toEqual([
637
- '/api/integration-runtime-integration/webhooks',
638
- '/api/integration-runtime-integration/webhooks/{integrationId}',
639
- '/api/{integrationType}/webhooks',
640
- '/api/{integrationType}/webhooks/{integrationId}',
641
- ]);
642
- expect(result.functions.stripeWebhook.events).toHaveLength(2);
643
- });
644
-
645
623
  it('emits a dedicated per-binding function (namespaced) for Tier 3 extension routes; the main handler keeps only {proxy+}', async () => {
646
624
  const appDefinition = {
647
625
  integrations: [
@@ -908,8 +886,8 @@ describe('IntegrationBuilder', () => {
908
886
  const result = await integrationBuilder.build(appDefinition, {});
909
887
 
910
888
  expect(result.functions.testWebhook.package).toBeDefined();
911
- expect(result.functions.testWebhook.package.exclude).toContain('node_modules/aws-sdk/**');
912
- expect(result.functions.testWebhook.package.exclude).toContain('node_modules/@prisma/**');
889
+ expect(result.functions.testWebhook.package.patterns).toContain('!node_modules/aws-sdk/**');
890
+ expect(result.functions.testWebhook.package.patterns).toContain('!node_modules/@prisma/**');
913
891
  });
914
892
  });
915
893
 
@@ -1004,8 +982,8 @@ describe('IntegrationBuilder', () => {
1004
982
  expect(result.functions.asana.layers).toBeUndefined();
1005
983
  expect(result.functions.asanaQueueWorker.layers).toBeUndefined();
1006
984
  expect(result.functions.asanaWebhook.layers).toBeUndefined();
1007
- expect(result.functions.asana.package.exclude).not.toEqual(
1008
- expect.arrayContaining(['node_modules/@prisma/**'])
985
+ expect(result.functions.asana.package.patterns).not.toEqual(
986
+ expect.arrayContaining(['!node_modules/@prisma/**'])
1009
987
  );
1010
988
  });
1011
989
  });
@@ -1113,14 +1091,14 @@ describe('IntegrationBuilder nested node_modules (lambda.keepNestedNodeModules)'
1113
1091
  ...(lambda && { lambda }),
1114
1092
  });
1115
1093
  const packagedFunctions = (result) =>
1116
- Object.values(result.functions).filter((fn) => fn.package?.exclude);
1094
+ Object.values(result.functions).filter((fn) => fn.package?.patterns);
1117
1095
 
1118
1096
  it('excludes every nested node_modules by default', async () => {
1119
1097
  const result = await new IntegrationBuilder().build(appDefinition(), {});
1120
1098
 
1121
1099
  expect(packagedFunctions(result).length).toBeGreaterThan(0);
1122
1100
  for (const fn of packagedFunctions(result)) {
1123
- expect(fn.package.exclude).toContain('node_modules/**/node_modules/**');
1101
+ expect(fn.package.patterns).toContain('!node_modules/**/node_modules/**');
1124
1102
  }
1125
1103
  });
1126
1104
 
@@ -1131,8 +1109,73 @@ describe('IntegrationBuilder nested node_modules (lambda.keepNestedNodeModules)'
1131
1109
  );
1132
1110
 
1133
1111
  for (const fn of packagedFunctions(result)) {
1134
- expect(fn.package.exclude).not.toContain('node_modules/**/node_modules/**');
1135
- expect(fn.package.exclude).toContain('node_modules/**/node_modules/@friggframework/**');
1112
+ expect(fn.package.patterns).not.toContain('!node_modules/**/node_modules/**');
1113
+ expect(fn.package.patterns).toContain('!node_modules/**/node_modules/@friggframework/**');
1114
+ }
1115
+ });
1116
+ });
1117
+
1118
+ describe('IntegrationBuilder function package patterns (ADR-050)', () => {
1119
+ const appDefinition = {
1120
+ integrations: [
1121
+ {
1122
+ Definition: {
1123
+ name: 'hubspot',
1124
+ webhooks: true,
1125
+ extensions: {
1126
+ hubspotWebhooks: {
1127
+ extension: {
1128
+ name: 'hubspot-webhooks',
1129
+ routes: [
1130
+ {
1131
+ path: '/webhooks',
1132
+ method: 'POST',
1133
+ event: 'HUBSPOT_WEBHOOK_RECEIVED',
1134
+ },
1135
+ ],
1136
+ events: {
1137
+ HUBSPOT_WEBHOOK_RECEIVED: {
1138
+ type: 'LIFE_CYCLE_EVENT',
1139
+ handler: () => {},
1140
+ },
1141
+ },
1142
+ },
1143
+ handlers: {},
1144
+ },
1145
+ },
1146
+ },
1147
+ },
1148
+ ],
1149
+ };
1150
+
1151
+ it('emits package.patterns, never include/exclude, on every function it packages', async () => {
1152
+ const result = await new IntegrationBuilder().build(appDefinition, {});
1153
+
1154
+ const expected = [
1155
+ 'hubspot',
1156
+ 'hubspotWebhook',
1157
+ 'hubspot__hubspotWebhooks',
1158
+ 'hubspotQueueWorker',
1159
+ 'dlqProcessor',
1160
+ ];
1161
+ for (const name of expected) {
1162
+ const pkg = result.functions[name]?.package;
1163
+ expect(pkg).toBeDefined();
1164
+ expect(pkg).not.toHaveProperty('include');
1165
+ expect(pkg).not.toHaveProperty('exclude');
1166
+ // Integration functions only exclude, so every pattern is negated.
1167
+ expect(pkg.patterns.length).toBeGreaterThan(0);
1168
+ expect(pkg.patterns.every((p) => p.startsWith('!'))).toBe(true);
1169
+ expect(pkg.patterns).toEqual(
1170
+ expect.arrayContaining([
1171
+ '!node_modules/aws-sdk/**',
1172
+ '!node_modules/@prisma/**',
1173
+ '!node_modules/**/node_modules/**',
1174
+ '!node_modules/osls/**',
1175
+ '!test/**',
1176
+ ])
1177
+ );
1178
+ expect(pkg.patterns).not.toContain('!src/**');
1136
1179
  }
1137
1180
  });
1138
1181
  });
@@ -1,5 +1,3 @@
1
- const { hasTriggers } = require('@friggframework/core/integrations/triggers');
2
-
3
1
  /**
4
2
  * Per-function environment scoping (ADR-027)
5
3
  *
@@ -49,8 +47,7 @@ function applyFunctionEnvironments(functions, functionEnvironments = {}) {
49
47
  /**
50
48
  * Function names the integration builder creates for one integration.
51
49
  * Wire contract: must stay in sync with
52
- * IntegrationBuilder.createFunctionDefinitions (and TriggerBuilder for
53
- * `${name}Triggers`) — a drift here surfaces as a
50
+ * IntegrationBuilder.createFunctionDefinitions — a drift here surfaces as a
54
51
  * hard unknown-function error at compose time, not a silent var drop.
55
52
  *
56
53
  * @param {Object} integration - entry from appDefinition.integrations
@@ -65,11 +62,6 @@ function getIntegrationFunctionNames(integration) {
65
62
  names.splice(1, 0, `${name}Webhook`);
66
63
  }
67
64
 
68
- // TriggerBuilder (ADR-055): the tick function, which sends trigger runs to this integration's queue.
69
- if (hasTriggers(integration)) {
70
- names.push(`${name}Triggers`);
71
- }
72
-
73
65
  for (const [bindingKey, binding] of Object.entries(
74
66
  integration.Definition.extensions || {}
75
67
  )) {
@@ -67,20 +67,6 @@ describe('function-environments', () => {
67
67
  ).not.toContain('hubspotWebhook');
68
68
  });
69
69
 
70
- it('includes the trigger tick function when the integration declares triggers (ADR-055)', () => {
71
- expect(
72
- getIntegrationFunctionNames({
73
- Definition: { name: 'hubspot', triggers: { poll: { every: '15m', handler: 'poll' } } },
74
- })
75
- ).toEqual(['hubspot', 'hubspotQueueWorker', 'hubspotTriggers']);
76
- expect(
77
- getIntegrationFunctionNames({ Definition: { name: 'dd', instanceTriggers: { tick: '5m' } } })
78
- ).toContain('ddTriggers');
79
- expect(
80
- getIntegrationFunctionNames({ Definition: { name: 'hubspot', triggers: {} } })
81
- ).not.toContain('hubspotTriggers');
82
- });
83
-
84
70
  it('includes one function per routed extension binding, sanitized', () => {
85
71
  const names = getIntegrationFunctionNames({
86
72
  Definition: {
@@ -9,7 +9,9 @@
9
9
 
10
10
  const { buildEnvironment } = require('../environment-builder');
11
11
  const { nestedNodeModulesExcludes } = require('./nested-node-modules');
12
+ const { toPackagePatterns } = require('./package-patterns');
12
13
  const { buildLoggingProviderConfig } = require('./logging-config');
14
+ const { OSLS_FRAMEWORK_VERSION } = require('./framework-version');
13
15
 
14
16
  /**
15
17
  * Create base serverless definition with core functions and resources
@@ -37,143 +39,95 @@ function createBaseDefinition(
37
39
  const loggingConfig = buildLoggingProviderConfig(AppDefinition.logging);
38
40
 
39
41
  // Package config for handlers that skip esbuild (need node_modules dependencies)
40
- // Include backend src/ and index.js since handlers load the app definition
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.
41
44
  const skipEsbuildPackageConfig = {
42
- // Explicitly include project files that handlers need
43
- include: [
44
- // Include DocumentDB TLS certificate if configured
45
- ...(AppDefinition.database?.documentDB?.tlsCAFile
46
- ? [AppDefinition.database.documentDB.tlsCAFile.replace(/^\.\//, '')]
47
- : []),
48
- ],
49
- exclude: [
50
- // Exclude Prisma (provided via Lambda Layer)
51
- ...(usePrismaLayer ? [
52
- 'node_modules/@prisma/**',
53
- 'node_modules/.prisma/**',
54
- 'node_modules/prisma/**',
55
- 'node_modules/@friggframework/core/generated/**',
56
- ] : []),
57
-
58
- // Exclude AWS SDK (provided by Lambda runtime)
59
- 'node_modules/aws-sdk/**',
60
- 'node_modules/@aws-sdk/**',
61
-
62
- // Exclude dev/test dependencies
63
- 'node_modules/@friggframework/test/**',
64
- 'node_modules/@friggframework/eslint-config/**',
65
- 'node_modules/@friggframework/prettier-config/**',
66
- 'node_modules/jest/**',
67
- 'node_modules/prettier/**',
68
- 'node_modules/eslint/**',
69
-
70
- ...nestedNodeModulesExcludes(AppDefinition, usePrismaLayer),
71
-
72
- // Exclude build tools (not needed at runtime)
73
- 'node_modules/esbuild/**',
74
- 'node_modules/@esbuild/**',
75
- 'node_modules/typescript/**',
76
- 'node_modules/webpack/**',
77
- 'node_modules/osls/**',
78
- 'node_modules/serverless-esbuild/**',
79
- 'node_modules/serverless-jetpack/**',
80
- 'node_modules/serverless-offline/**',
81
- 'node_modules/serverless-offline-sqs/**',
82
- 'node_modules/serverless-dotenv-plugin/**',
83
- 'node_modules/serverless-kms-grants/**',
84
- // Note: DO NOT exclude serverless-http - it's a runtime dependency!
85
-
86
- // Exclude local dev files and environment files (NEVER deploy .env files!)
87
- '.env',
88
- '.env.*',
89
- '.env.local',
90
- '.env.*.local',
91
- '**/.env',
92
- '**/.env.*',
93
- 'deploy.log',
94
- '.env.backup',
95
- 'docker-compose.yml',
96
- 'jest.config.js',
97
- 'jest.unit.config.js',
98
- '.eslintrc.json',
99
- '.prettierrc',
100
- '.prettierignore',
101
- '.markdownlintignore',
102
- 'package-lock.json',
103
-
104
- // Exclude test files and layers (keep src/ - needed for app definition and integrations)
105
- 'test/**',
106
- 'layers/**',
107
- 'coverage/**',
108
- // Note: DO NOT exclude src/** - handlers need src/integrations and src/api-modules at runtime
109
- '**/*.test.js',
110
- '**/*.spec.js',
111
- '**/.claude-flow/**',
112
- '**/.swarm/**',
113
- ],
114
- };
115
-
116
- // Function-level package config to exclude Prisma and AWS SDK
117
- const functionPackageConfig = {
118
- exclude: [
119
- // Exclude AWS SDK (already in Lambda runtime or externalized by esbuild)
120
- 'node_modules/aws-sdk/**',
121
- 'node_modules/@aws-sdk/**',
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
+ ] : []),
122
61
 
123
- // Exclude Prisma (provided via Lambda Layer)
124
- ...(usePrismaLayer ? [
125
- 'node_modules/@prisma/**',
126
- 'node_modules/.prisma/**',
127
- 'node_modules/prisma/**',
128
- 'node_modules/@friggframework/core/generated/**',
129
- ] : []),
62
+ // Exclude AWS SDK (provided by Lambda runtime)
63
+ 'node_modules/aws-sdk/**',
64
+ 'node_modules/@aws-sdk/**',
130
65
 
131
- // Exclude nested node_modules from symlinked frigg packages (for npm link development)
132
- 'node_modules/@friggframework/core/node_modules/**',
133
- 'node_modules/@friggframework/devtools/node_modules/**',
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/**',
134
73
 
135
- // Exclude environment files (NEVER deploy .env files!)
136
- '.env',
137
- '.env.*',
138
- '.env.local',
139
- '.env.*.local',
140
- '**/.env',
141
- '**/.env.*',
74
+ ...nestedNodeModulesExcludes(AppDefinition, usePrismaLayer),
142
75
 
143
- // Exclude development/test files from backend project
144
- 'coverage/**',
145
- 'test/**',
146
- 'src/**',
147
- 'layers/**',
148
- '**/*.test.js',
149
- '**/*.spec.js',
150
- '.git/**',
151
- '.github/**',
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!
152
89
 
153
- // Exclude AI assistant and development artifacts
154
- '**/.claude-flow/**',
155
- '**/.swarm/**',
156
- '**/CLAUDE.md',
157
- '**/README.md',
158
- '**/*.md',
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',
159
107
 
160
- // Exclude config and meta files from core
161
- 'node_modules/@friggframework/core/.eslintrc.json',
162
- 'node_modules/@friggframework/core/.gitignore',
163
- 'node_modules/@friggframework/core/jest.config.js',
164
- 'node_modules/@friggframework/core/CHANGELOG.md',
165
- ],
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
+ }),
166
119
  };
167
120
 
168
121
  return {
169
- frameworkVersion: loggingConfig.frameworkVersion || '>=3.17.0',
122
+ frameworkVersion: OSLS_FRAMEWORK_VERSION,
170
123
  service: AppDefinition.name || 'create-frigg-app',
171
124
  package: {
172
125
  individually: true,
173
126
  },
174
127
  // Only use .env for local development (offline mode)
175
- // Production deployments should use environment vars from infrastructure
176
- useDotenv: process.argv.includes('offline'),
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 }),
177
131
  provider: {
178
132
  name: AppDefinition.provider || 'aws',
179
133
  ...(process.env.AWS_PROFILE && { profile: process.env.AWS_PROFILE }),
@@ -5,6 +5,7 @@
5
5
  */
6
6
 
7
7
  const { createBaseDefinition } = require('./base-definition-factory');
8
+ const { OSLS_FRAMEWORK_VERSION } = require('./framework-version');
8
9
 
9
10
  describe('Base Definition Factory', () => {
10
11
  beforeEach(() => {
@@ -23,7 +24,7 @@ describe('Base Definition Factory', () => {
23
24
  const result = createBaseDefinition(appDefinition, appEnvironmentVars, discoveredResources);
24
25
 
25
26
  expect(result.service).toBe('test-app');
26
- expect(result.frameworkVersion).toBe('>=3.17.0');
27
+ expect(result.frameworkVersion).toBe(OSLS_FRAMEWORK_VERSION);
27
28
  expect(result.provider.name).toBe('aws');
28
29
  expect(result.provider.runtime).toBe('nodejs22.x');
29
30
  expect(result.provider.timeout).toBe(29);
@@ -236,12 +237,75 @@ describe('Base Definition Factory', () => {
236
237
  expect(result.package.individually).toBe(true);
237
238
  });
238
239
 
239
- it('should enable dotenv only in offline mode', () => {
240
- const result = createBaseDefinition({}, {}, {});
240
+ describe('useDotenv (ADR-050)', () => {
241
+ const originalArgv = process.argv;
242
+ afterEach(() => {
243
+ process.argv = originalArgv;
244
+ });
245
+
246
+ it.each([['package'], ['deploy'], ['print']])(
247
+ 'omits useDotenv for `osls %s` (osls 4 only accepts true)',
248
+ (command) => {
249
+ process.argv = ['node', 'osls', command, '--stage', 'prod'];
250
+ const result = createBaseDefinition({}, {}, {});
251
+
252
+ expect(result).not.toHaveProperty('useDotenv');
253
+ expect(result.plugins).not.toContain('serverless-dotenv-plugin');
254
+ }
255
+ );
256
+
257
+ it('sets useDotenv: true for `osls offline`', () => {
258
+ process.argv = ['node', 'osls', 'offline', '--stage', 'dev'];
259
+ const result = createBaseDefinition({}, {}, {});
241
260
 
242
- // useDotenv is conditional - only true when process.argv includes 'offline'
243
- expect(result.useDotenv).toBeDefined();
244
- expect(typeof result.useDotenv).toBe('boolean');
261
+ expect(result.useDotenv).toBe(true);
262
+ expect(result.plugins).toContain('serverless-dotenv-plugin');
263
+ });
264
+ });
265
+
266
+ describe('function package patterns (ADR-050)', () => {
267
+ it('emits package.patterns and no include/exclude on auth, user and health', () => {
268
+ const result = createBaseDefinition({}, {}, {});
269
+
270
+ for (const fn of ['auth', 'user', 'health']) {
271
+ const pkg = result.functions[fn].package;
272
+ expect(pkg).not.toHaveProperty('include');
273
+ expect(pkg).not.toHaveProperty('exclude');
274
+ expect(Array.isArray(pkg.patterns)).toBe(true);
275
+ expect(pkg.patterns).toEqual(
276
+ expect.arrayContaining([
277
+ '!node_modules/aws-sdk/**',
278
+ '!node_modules/@aws-sdk/**',
279
+ '!.env',
280
+ '!**/.env.*',
281
+ '!package-lock.json',
282
+ '!test/**',
283
+ '!layers/**',
284
+ ])
285
+ );
286
+ // No exclude pattern removes src/: handlers load the app definition from it.
287
+ expect(pkg.patterns).not.toContain('!src/**');
288
+ }
289
+ });
290
+
291
+ it('puts the DocumentDB CA file after every exclude so it is re-added', () => {
292
+ const result = createBaseDefinition(
293
+ { database: { documentDB: { tlsCAFile: './certs/global-bundle.pem' } } },
294
+ {},
295
+ {}
296
+ );
297
+ const { patterns } = result.functions.auth.package;
298
+
299
+ expect(patterns[patterns.length - 1]).toBe('certs/global-bundle.pem');
300
+ expect(patterns.slice(0, -1).every((p) => p.startsWith('!'))).toBe(true);
301
+ });
302
+
303
+ it('emits only negated excludes when no CA file is configured', () => {
304
+ const result = createBaseDefinition({}, {}, {});
305
+ expect(
306
+ result.functions.auth.package.patterns.every((p) => p.startsWith('!'))
307
+ ).toBe(true);
308
+ });
245
309
  });
246
310
 
247
311
  describe('usePrismaLayer configuration', () => {
@@ -250,12 +314,12 @@ describe('Base Definition Factory', () => {
250
314
 
251
315
  expect(result.layers.prisma).toBeDefined();
252
316
  expect(result.functions.auth.layers).toEqual([{ Ref: 'PrismaLambdaLayer' }]);
253
- expect(result.functions.auth.package.exclude).toEqual(
317
+ expect(result.functions.auth.package.patterns).toEqual(
254
318
  expect.arrayContaining([
255
- 'node_modules/@prisma/**',
256
- 'node_modules/.prisma/**',
257
- 'node_modules/prisma/**',
258
- 'node_modules/@friggframework/core/generated/**',
319
+ '!node_modules/@prisma/**',
320
+ '!node_modules/.prisma/**',
321
+ '!node_modules/prisma/**',
322
+ '!node_modules/@friggframework/core/generated/**',
259
323
  ])
260
324
  );
261
325
  expect(result.custom.esbuild.external).toEqual(
@@ -268,12 +332,12 @@ describe('Base Definition Factory', () => {
268
332
 
269
333
  expect(result.layers).toEqual({});
270
334
  expect(result.functions.auth.layers).toBeUndefined();
271
- expect(result.functions.auth.package.exclude).not.toEqual(
335
+ expect(result.functions.auth.package.patterns).not.toEqual(
272
336
  expect.arrayContaining([
273
- 'node_modules/@prisma/**',
274
- 'node_modules/.prisma/**',
275
- 'node_modules/prisma/**',
276
- 'node_modules/@friggframework/core/generated/**',
337
+ '!node_modules/@prisma/**',
338
+ '!node_modules/.prisma/**',
339
+ '!node_modules/prisma/**',
340
+ '!node_modules/@friggframework/core/generated/**',
277
341
  ])
278
342
  );
279
343
  expect(result.custom.esbuild.external).not.toEqual(
@@ -297,7 +361,7 @@ describe('nested node_modules (lambda.keepNestedNodeModules)', () => {
297
361
  const result = build({ name: 'test-app' });
298
362
 
299
363
  for (const fn of ['auth', 'user', 'health']) {
300
- expect(result.functions[fn].package.exclude).toContain('node_modules/**/node_modules/**');
364
+ expect(result.functions[fn].package.patterns).toContain('!node_modules/**/node_modules/**');
301
365
  }
302
366
  });
303
367
 
@@ -305,13 +369,13 @@ describe('nested node_modules (lambda.keepNestedNodeModules)', () => {
305
369
  const result = build({ name: 'test-app', lambda: { keepNestedNodeModules: true } });
306
370
 
307
371
  for (const fn of ['auth', 'user', 'health']) {
308
- const { exclude } = result.functions[fn].package;
309
- expect(exclude).not.toContain('node_modules/**/node_modules/**');
310
- expect(exclude).toEqual(
372
+ const { patterns } = result.functions[fn].package;
373
+ expect(patterns).not.toContain('!node_modules/**/node_modules/**');
374
+ expect(patterns).toEqual(
311
375
  expect.arrayContaining([
312
- 'node_modules/**/node_modules/@friggframework/**',
313
- 'node_modules/**/node_modules/@aws-sdk/**',
314
- 'node_modules/**/node_modules/@prisma/**',
376
+ '!node_modules/**/node_modules/@friggframework/**',
377
+ '!node_modules/**/node_modules/@aws-sdk/**',
378
+ '!node_modules/**/node_modules/@prisma/**',
315
379
  ])
316
380
  );
317
381
  }
@@ -327,14 +391,14 @@ describe('logging (ADR-048)', () => {
327
391
 
328
392
  expect(result.provider.logs).toBeUndefined();
329
393
  expect(result.provider.logRetentionInDays).toBeUndefined();
330
- expect(result.frameworkVersion).toBe('>=3.17.0');
394
+ expect(result.frameworkVersion).toBe(OSLS_FRAMEWORK_VERSION);
331
395
  });
332
396
 
333
397
  it('validates logging.level but leaves the Lambda log format and frameworkVersion alone by default', () => {
334
398
  const result = build({ level: 'warn' });
335
399
 
336
400
  expect(result.provider.logs).toBeUndefined();
337
- expect(result.frameworkVersion).toBe('>=3.17.0');
401
+ expect(result.frameworkVersion).toBe(OSLS_FRAMEWORK_VERSION);
338
402
  });
339
403
 
340
404
  it.each(['verbose', 'warning', '', 3])('throws on unknown level %p', (level) => {
@@ -346,7 +410,12 @@ describe('logging (ADR-048)', () => {
346
410
 
347
411
  expect(result.provider.logRetentionInDays).toBe(30);
348
412
  expect(result.provider.logs).toBeUndefined();
349
- expect(result.frameworkVersion).toBe('>=3.17.0');
413
+ expect(result.frameworkVersion).toBe(OSLS_FRAMEWORK_VERSION);
414
+ });
415
+
416
+ it('keeps the single osls frameworkVersion even when the Lambda LoggingConfig is on (ADR-050)', () => {
417
+ const result = build({ level: 'warn' });
418
+ expect(result.frameworkVersion).toBe('^4.4.0');
350
419
  });
351
420
 
352
421
  it('accepts 1096, which CloudWatch allows but the osls schema omits', () => {
@@ -0,0 +1,14 @@
1
+ /**
2
+ * osls framework version
3
+ *
4
+ * Utility Layer - Hexagonal Architecture
5
+ *
6
+ * The single `frameworkVersion` every composed definition emits (ADR-050).
7
+ * It matches the osls range in devtools and frigg-cli, so an app whose own
8
+ * package.json still resolves osls 3 fails at once with
9
+ * FRAMEWORK_VERSION_MISMATCH instead of packaging a different artifact.
10
+ * It subsumes the ADR-048 LoggingConfig floor (>=3.58.0).
11
+ */
12
+ const OSLS_FRAMEWORK_VERSION = '^4.4.0';
13
+
14
+ module.exports = { OSLS_FRAMEWORK_VERSION };
@@ -0,0 +1,27 @@
1
+ const { OSLS_FRAMEWORK_VERSION } = require('./framework-version');
2
+ const semver = require('semver');
3
+
4
+ describe('OSLS_FRAMEWORK_VERSION (ADR-050)', () => {
5
+ it('is the osls 4 range Frigg targets', () => {
6
+ expect(OSLS_FRAMEWORK_VERSION).toBe('^4.4.0');
7
+ });
8
+
9
+ it.each([
10
+ ['4.4.0', true],
11
+ ['4.9.1', true],
12
+ ['4.3.9', false],
13
+ ['3.78.0', false],
14
+ ['5.0.0', false],
15
+ ])('osls %s satisfies it: %s', (version, expected) => {
16
+ // osls compares frameworkVersion with semver.satisfies and fails
17
+ // with FRAMEWORK_VERSION_MISMATCH otherwise.
18
+ expect(semver.satisfies(version, OSLS_FRAMEWORK_VERSION)).toBe(expected);
19
+ });
20
+
21
+ it('matches the osls range devtools and frigg-cli depend on', () => {
22
+ const devtools = require('../../../../package.json');
23
+ const cli = require('../../../../frigg-cli/package.json');
24
+ expect(devtools.devDependencies.osls).toBe(OSLS_FRAMEWORK_VERSION);
25
+ expect(cli.dependencies.osls).toBe(OSLS_FRAMEWORK_VERSION);
26
+ });
27
+ });