@friggframework/devtools 2.0.0--canary.689.e2b05a4.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 (25) 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 -61
  15. package/infrastructure/domains/integration/integration-builder.test.js +73 -8
  16. package/infrastructure/domains/shared/utilities/base-definition-factory.js +76 -122
  17. package/infrastructure/domains/shared/utilities/base-definition-factory.test.js +95 -26
  18. package/infrastructure/domains/shared/utilities/framework-version.js +14 -0
  19. package/infrastructure/domains/shared/utilities/framework-version.test.js +27 -0
  20. package/infrastructure/domains/shared/utilities/logging-config.js +3 -4
  21. package/infrastructure/domains/shared/utilities/logging-config.test.js +1 -2
  22. package/infrastructure/domains/shared/utilities/package-patterns.js +35 -0
  23. package/infrastructure/domains/shared/utilities/package-patterns.test.js +112 -0
  24. package/infrastructure/infrastructure-composer.test.js +3 -3
  25. package/package.json +11 -8
package/README.md CHANGED
@@ -12,6 +12,20 @@ The devtools package includes the following main components:
12
12
  4. Local runner and deploy tooling
13
13
  5. Infrastructure
14
14
 
15
+ ## Requirements
16
+
17
+ - Node.js `^22.13.0 || >=24` on the machine that runs `frigg` (Node 23 and Node 22.0–22.12
18
+ are not supported by osls; the CLI exits with a message). Lambda functions run on
19
+ `nodejs22.x`.
20
+ - [osls](https://github.com/oss-serverless/osls) `^4.4.0` (installed with the CLI). Frigg
21
+ 2.0.1 moved from osls 3 to osls 4; see
22
+ [ADR-050](../../docs/architecture-decisions/050-osls-4.md) and the
23
+ [upgrade notes](../../docs/reference/aws-sdk-v3-osls-migration.md#osls-4-frigg-201).
24
+
25
+ If your `infrastructure.js` wrapper changes the composed definition, use
26
+ `package.patterns` (never `package.include`/`package.exclude`), do not set
27
+ `useDotenv: false`, and do not pin `frameworkVersion` to 3.x. osls 4 rejects all three.
28
+
15
29
  ## Frigg CLI
16
30
 
17
31
  The Frigg CLI is a command-line interface tool that helps developers manage and install API modules in their Frigg projects.
@@ -6,6 +6,12 @@ The Frigg CLI provides tools for building, deploying, and managing serverless in
6
6
 
7
7
  ---
8
8
 
9
+ **Requirements:** Node.js `^22.13.0 || >=24`. The CLI drives
10
+ [osls](https://github.com/oss-serverless/osls) `^4.4.0` (Frigg 2.0.1+,
11
+ [ADR-050](../../../docs/architecture-decisions/050-osls-4.md)); osls refuses Node 23 and
12
+ Node 22.0–22.12, so the CLI checks the version first and exits with a message. Set
13
+ `FRIGG_SKIP_NODE_VERSION_CHECK=true` to skip the CLI check.
14
+
9
15
  ## Command Reference
10
16
 
11
17
  ### Core Commands
@@ -24,17 +24,15 @@ describe('frigg-cli dependencies', () => {
24
24
  expect(oslsVersion).toMatch(/^[\^~]?\d+\.\d+\.\d+/);
25
25
  });
26
26
 
27
- it('should use osls version 3.40.1 or higher', () => {
27
+ it('should use osls 4.4.0 or higher within major 4 (ADR-050)', () => {
28
28
  const oslsVersion = packageJson.dependencies.osls;
29
29
 
30
30
  // Extract version number (remove ^ or ~ prefix)
31
31
  const versionNumber = oslsVersion.replace(/^[\^~]/, '');
32
32
  const [major, minor] = versionNumber.split('.').map(Number);
33
33
 
34
- expect(major).toBeGreaterThanOrEqual(3);
35
- if (major === 3) {
36
- expect(minor).toBeGreaterThanOrEqual(40);
37
- }
34
+ expect(major).toBe(4);
35
+ expect(minor).toBeGreaterThanOrEqual(4);
38
36
  });
39
37
  });
40
38
 
@@ -0,0 +1,66 @@
1
+ const {
2
+ SUPPORTED_NODE_RANGE,
3
+ checkNodeVersion,
4
+ enforceNodeVersion,
5
+ } = require('../../../utils/node-version');
6
+
7
+ describe('Node.js host version check (ADR-050)', () => {
8
+ it('uses the engines.node range from package.json', () => {
9
+ expect(SUPPORTED_NODE_RANGE).toBe(require('../../../package.json').engines.node);
10
+ expect(SUPPORTED_NODE_RANGE).toBe('^22.13.0 || >=24');
11
+ });
12
+
13
+ it.each([
14
+ ['22.13.0', true],
15
+ ['v22.20.1', true],
16
+ ['24.0.0', true],
17
+ ['v24.10.0', true],
18
+ ['25.1.0', true],
19
+ ['22.12.0', false],
20
+ ['v22.11.0', false],
21
+ ['23.5.0', false],
22
+ ['v23.11.1', false],
23
+ ['20.19.0', false],
24
+ ['18.20.0', false],
25
+ ])('Node %s supported: %s', (version, supported) => {
26
+ expect(checkNodeVersion(version).supported).toBe(supported);
27
+ });
28
+
29
+ it('explains the supported range and the fix when unsupported', () => {
30
+ const { message } = checkNodeVersion('v23.5.0');
31
+ expect(message).toContain('Node.js v23.5.0');
32
+ expect(message).toContain('^22.13.0 || >=24');
33
+ expect(message).toContain('Node 23');
34
+ expect(message).toContain('FRIGG_SKIP_NODE_VERSION_CHECK');
35
+ });
36
+
37
+ it('prints the message and exits 1 on an unsupported host', () => {
38
+ const log = jest.fn();
39
+ const exit = jest.fn();
40
+ const ok = enforceNodeVersion({ version: '23.5.0', env: {}, log, exit });
41
+ expect(ok).toBe(false);
42
+ expect(log).toHaveBeenCalledWith(expect.stringContaining('does not support Node.js'));
43
+ expect(exit).toHaveBeenCalledWith(1);
44
+ });
45
+
46
+ it('continues silently on a supported host', () => {
47
+ const log = jest.fn();
48
+ const exit = jest.fn();
49
+ expect(enforceNodeVersion({ version: '24.10.0', env: {}, log, exit })).toBe(true);
50
+ expect(log).not.toHaveBeenCalled();
51
+ expect(exit).not.toHaveBeenCalled();
52
+ });
53
+
54
+ it('can be bypassed with FRIGG_SKIP_NODE_VERSION_CHECK=true', () => {
55
+ const exit = jest.fn();
56
+ expect(
57
+ enforceNodeVersion({
58
+ version: '23.5.0',
59
+ env: { FRIGG_SKIP_NODE_VERSION_CHECK: 'true' },
60
+ log: jest.fn(),
61
+ exit,
62
+ })
63
+ ).toBe(true);
64
+ expect(exit).not.toHaveBeenCalled();
65
+ });
66
+ });
@@ -1,5 +1,8 @@
1
1
  #!/usr/bin/env node
2
2
 
3
+ // osls 4 needs Node ^22.13.0 || >=24 (ADR-050): fail early with a clear message.
4
+ require('./utils/node-version').enforceNodeVersion();
5
+
3
6
  // Version Detection Wrapper
4
7
  // This code runs when frigg-cli is installed globally
5
8
  // It checks for a local installation and prefers it if newer
@@ -26,7 +26,7 @@
26
26
  "lodash": "4.18.1",
27
27
  "node-cache": "^5.1.2",
28
28
  "open": "^8.4.2",
29
- "osls": "^3.58.0",
29
+ "osls": "^4.4.0",
30
30
  "semver": "^7.6.0",
31
31
  "validate-npm-package-name": "^5.0.0"
32
32
  },
@@ -55,9 +55,9 @@
55
55
  },
56
56
  "homepage": "https://github.com/friggframework/frigg#readme",
57
57
  "engines": {
58
- "node": ">=18"
58
+ "node": "^22.13.0 || >=24"
59
59
  },
60
60
  "publishConfig": {
61
61
  "access": "public"
62
62
  }
63
- }
63
+ }
@@ -0,0 +1,51 @@
1
+ /**
2
+ * Node.js host version check for the Frigg CLI.
3
+ *
4
+ * osls 4 supports `^20.19.0 || ^22.13.0 || >=24`; Frigg's floor is Node 22, so
5
+ * the CLI runs on `^22.13.0 || >=24` (ADR-050). Node 23 and Node 22.0-22.12 are
6
+ * excluded. The range is read from this package's `engines.node`, so the check
7
+ * and the published metadata cannot drift.
8
+ */
9
+ const semver = require('semver');
10
+ const { engines } = require('../package.json');
11
+
12
+ const SUPPORTED_NODE_RANGE = engines.node;
13
+ const SKIP_ENV = 'FRIGG_SKIP_NODE_VERSION_CHECK';
14
+
15
+ function checkNodeVersion(version = process.versions.node, range = SUPPORTED_NODE_RANGE) {
16
+ const coerced = semver.coerce(version);
17
+ if (coerced && semver.satisfies(coerced, range)) {
18
+ return { supported: true, version, range };
19
+ }
20
+ return {
21
+ supported: false,
22
+ version,
23
+ range,
24
+ message: [
25
+ `Frigg CLI does not support Node.js v${String(version).replace(/^v/, '')}.`,
26
+ `Supported versions: ${range} (the range osls 4 supports at or above Frigg's Node 22 floor).`,
27
+ 'Node 23 and Node 22.0-22.12 are not supported. Install Node 22.13+ or Node 24+, for example `nvm install 24`.',
28
+ `To run anyway, set ${SKIP_ENV}=true (osls may fail).`,
29
+ ].join('\n'),
30
+ };
31
+ }
32
+
33
+ /**
34
+ * Print a clear error and exit when the host Node.js is unsupported.
35
+ * @returns {boolean} true when the CLI may continue
36
+ */
37
+ function enforceNodeVersion({
38
+ version = process.versions.node,
39
+ env = process.env,
40
+ log = console.error,
41
+ exit = process.exit,
42
+ } = {}) {
43
+ if (env[SKIP_ENV] === 'true') return true;
44
+ const result = checkNodeVersion(version);
45
+ if (result.supported) return true;
46
+ log(result.message);
47
+ exit(1);
48
+ return false;
49
+ }
50
+
51
+ module.exports = { SUPPORTED_NODE_RANGE, checkNodeVersion, enforceNodeVersion };
@@ -207,6 +207,26 @@ STAGE=production
207
207
  SERVICE_NAME=my-frigg-app
208
208
  ```
209
209
 
210
+ ## Packaging (osls 4)
211
+
212
+ The composed definition targets osls `^4.4.0`
213
+ ([ADR-050](../../../docs/architecture-decisions/050-osls-4.md)):
214
+
215
+ - `frameworkVersion` is `OSLS_FRAMEWORK_VERSION` (`^4.4.0`,
216
+ `domains/shared/utilities/framework-version.js`). It is the single place the version is set.
217
+ - Every packaged function gets `package.patterns`, built by `toPackagePatterns({ include, exclude })`
218
+ (`domains/shared/utilities/package-patterns.js`): excludes negated first, then includes. Builders
219
+ keep plain include/exclude lists and pass them through the helper; never emit
220
+ `package.include`/`package.exclude`. `nestedNodeModulesExcludes()` output goes through the same
221
+ helper.
222
+ - `useDotenv: true` is emitted only for `osls offline` (`frigg start`); otherwise the key is absent.
223
+ - `custom.esbuild.exclude` is a serverless-esbuild option and stays as it is.
224
+
225
+ `__tests__/package-patterns-composition.test.js` walks every function of a fully featured
226
+ definition and fails if any of these rules is broken. Size budget: each function under 100 MB
227
+ unzipped, function + layers under 200 MB (Lambda's hard limit is 250 MB); see
228
+ [the measurements](../../../docs/reference/aws-sdk-v3-osls-migration.md#package-size-budget).
229
+
210
230
  ## Lambda Layers
211
231
 
212
232
  ### Prisma Layer
@@ -0,0 +1,153 @@
1
+ /**
2
+ * Composer-level guard for ADR-050 (osls 4).
3
+ *
4
+ * osls 4 rejects package.include / package.exclude at every level and only
5
+ * accepts `useDotenv: true` (or no key). Walk every function of a fully
6
+ * featured composed definition and assert Frigg emits neither.
7
+ */
8
+
9
+ const { composeServerlessDefinition } = require('../infrastructure-composer');
10
+
11
+ jest.mock('../domains/shared/resource-discovery', () => {
12
+ const originalModule = jest.requireActual('../domains/shared/resource-discovery');
13
+ return {
14
+ ...originalModule,
15
+ gatherDiscoveredResources: jest.fn().mockResolvedValue({
16
+ defaultVpcId: 'vpc-123456',
17
+ defaultSecurityGroupId: 'sg-123456',
18
+ privateSubnetId1: 'subnet-123456',
19
+ privateSubnetId2: 'subnet-789012',
20
+ defaultKmsKeyId:
21
+ 'arn:aws:kms:us-east-1:123456789012:key/12345678-1234-1234-1234-123456789012',
22
+ auroraClusterEndpoint: 'test-cluster.cluster-abc123.us-east-1.rds.amazonaws.com',
23
+ auroraPort: 5432,
24
+ }),
25
+ };
26
+ });
27
+
28
+ const featuredApp = () => ({
29
+ name: 'featured-app',
30
+ provider: 'aws',
31
+ vpc: { enable: true },
32
+ encryption: { useDefaultKMSForFieldLevelEncryption: true },
33
+ database: {
34
+ postgres: { enable: true },
35
+ documentDB: { tlsCAFile: './global-bundle.pem' },
36
+ },
37
+ adminScripts: [{ Definition: { name: 'fixThings' } }],
38
+ reports: [{ Definition: { name: 'usageReport' } }],
39
+ integrations: [
40
+ {
41
+ Definition: {
42
+ name: 'hubspot',
43
+ webhooks: true,
44
+ extensions: {
45
+ hubspotWebhooks: {
46
+ extension: {
47
+ name: 'hubspot-webhooks',
48
+ routes: [
49
+ {
50
+ path: '/webhooks',
51
+ method: 'POST',
52
+ event: 'HUBSPOT_WEBHOOK_RECEIVED',
53
+ },
54
+ ],
55
+ events: {
56
+ HUBSPOT_WEBHOOK_RECEIVED: {
57
+ type: 'LIFE_CYCLE_EVENT',
58
+ handler: () => {},
59
+ },
60
+ },
61
+ },
62
+ handlers: {},
63
+ },
64
+ },
65
+ },
66
+ },
67
+ { Definition: { name: 'slack' } },
68
+ ],
69
+ });
70
+
71
+ describe('composed definition is valid for osls 4 packaging (ADR-050)', () => {
72
+ const originalArgv = process.argv;
73
+
74
+ beforeEach(() => {
75
+ delete process.env.FRIGG_SKIP_AWS_DISCOVERY;
76
+ });
77
+
78
+ afterEach(() => {
79
+ process.argv = originalArgv;
80
+ });
81
+
82
+ it('no function, the service or a layer carries package.include or package.exclude', async () => {
83
+ process.argv = ['node', 'osls', 'package', '--stage', 'prod'];
84
+ const definition = await composeServerlessDefinition(featuredApp());
85
+
86
+ expect(definition.package).not.toHaveProperty('include');
87
+ expect(definition.package).not.toHaveProperty('exclude');
88
+ for (const layer of Object.values(definition.layers || {})) {
89
+ expect(layer.package?.include).toBeUndefined();
90
+ expect(layer.package?.exclude).toBeUndefined();
91
+ }
92
+
93
+ const functionNames = Object.keys(definition.functions);
94
+ expect(functionNames).toEqual(
95
+ expect.arrayContaining([
96
+ 'auth',
97
+ 'user',
98
+ 'health',
99
+ 'hubspot',
100
+ 'hubspotWebhook',
101
+ 'hubspot__hubspotWebhooks',
102
+ 'hubspotQueueWorker',
103
+ 'slack',
104
+ 'slackQueueWorker',
105
+ 'dlqProcessor',
106
+ 'dbMigrationWorker',
107
+ 'dbMigrationRouter',
108
+ 'adminScriptExecutor',
109
+ 'adminScriptRouter',
110
+ ])
111
+ );
112
+
113
+ for (const [name, fn] of Object.entries(definition.functions)) {
114
+ if (!fn.package) continue;
115
+ expect({ name, include: fn.package.include }).toEqual({ name, include: undefined });
116
+ expect({ name, exclude: fn.package.exclude }).toEqual({ name, exclude: undefined });
117
+ expect(Array.isArray(fn.package.patterns)).toBe(true);
118
+
119
+ // Excludes first, then includes: once a positive pattern appears,
120
+ // no negated pattern may follow it.
121
+ const firstInclude = fn.package.patterns.findIndex((p) => !p.startsWith('!'));
122
+ if (firstInclude !== -1) {
123
+ expect(
124
+ fn.package.patterns.slice(firstInclude).every((p) => !p.startsWith('!'))
125
+ ).toBe(true);
126
+ }
127
+ }
128
+
129
+ // The skipEsbuild core and admin functions re-add the DocumentDB CA file.
130
+ for (const name of ['auth', 'user', 'health', 'adminScriptExecutor', 'adminScriptRouter']) {
131
+ const { patterns } = definition.functions[name].package;
132
+ expect(patterns[patterns.length - 1]).toBe('global-bundle.pem');
133
+ }
134
+ });
135
+
136
+ it.each([['package'], ['deploy']])('never emits useDotenv for `osls %s`', async (command) => {
137
+ process.argv = ['node', 'osls', command, '--stage', 'prod'];
138
+ const definition = await composeServerlessDefinition(featuredApp());
139
+
140
+ expect(definition).not.toHaveProperty('useDotenv');
141
+ });
142
+
143
+ it('emits useDotenv: true for `osls offline`', async () => {
144
+ process.argv = ['node', 'osls', 'offline', '--stage', 'dev'];
145
+ process.env.FRIGG_SKIP_AWS_DISCOVERY = 'true';
146
+ try {
147
+ const definition = await composeServerlessDefinition(featuredApp());
148
+ expect(definition.useDotenv).toBe(true);
149
+ } finally {
150
+ delete process.env.FRIGG_SKIP_AWS_DISCOVERY;
151
+ }
152
+ });
153
+ });
@@ -16,6 +16,7 @@
16
16
  const { InfrastructureBuilder, ValidationResult } = require('../shared/base-builder');
17
17
  const { isScopedEnvironmentActive } = require('../shared/function-environments');
18
18
  const { nestedNodeModulesExcludes } = require('../shared/utilities/nested-node-modules');
19
+ const { toPackagePatterns } = require('../shared/utilities/package-patterns');
19
20
 
20
21
  class AdminScriptBuilder extends InfrastructureBuilder {
21
22
  constructor() {
@@ -397,52 +398,55 @@ class AdminScriptBuilder extends InfrastructureBuilder {
397
398
  skipEsbuildPackageConfig(appDefinition, usePrismaLayer) {
398
399
  const tlsCAFile = appDefinition?.database?.documentDB?.tlsCAFile;
399
400
  return {
400
- include: [
401
- // Handlers connect to the DB, so ship the DocumentDB CA cert.
402
- ...(tlsCAFile ? [tlsCAFile.replace(/^\.\//, '')] : []),
403
- ],
404
- exclude: [
405
- 'node_modules/aws-sdk/**',
406
- 'node_modules/@aws-sdk/**',
407
- ...(usePrismaLayer
408
- ? [
409
- 'node_modules/@prisma/**',
410
- 'node_modules/.prisma/**',
411
- 'node_modules/prisma/**',
412
- 'node_modules/@friggframework/core/generated/**',
413
- ]
414
- : []),
415
- ...nestedNodeModulesExcludes(appDefinition, usePrismaLayer),
416
- 'node_modules/@friggframework/test/**',
417
- 'node_modules/@friggframework/eslint-config/**',
418
- 'node_modules/@friggframework/prettier-config/**',
419
- 'node_modules/jest/**',
420
- 'node_modules/prettier/**',
421
- 'node_modules/eslint/**',
422
- 'node_modules/esbuild/**',
423
- 'node_modules/@esbuild/**',
424
- 'node_modules/typescript/**',
425
- 'node_modules/webpack/**',
426
- 'node_modules/osls/**',
427
- 'node_modules/serverless-esbuild/**',
428
- 'node_modules/serverless-jetpack/**',
429
- 'node_modules/serverless-offline/**',
430
- 'node_modules/serverless-offline-sqs/**',
431
- 'node_modules/serverless-dotenv-plugin/**',
432
- 'node_modules/serverless-kms-grants/**',
433
- // Never deploy secrets or the lockfile.
434
- '.env',
435
- '.env.*',
436
- '**/.env',
437
- '**/.env.*',
438
- '.frigg-credentials.json',
439
- 'package-lock.json',
440
- 'test/**',
441
- 'layers/**',
442
- 'coverage/**',
443
- '**/*.test.js',
444
- '**/*.spec.js',
445
- ],
401
+ // osls 4 only reads package.patterns (ADR-050): excludes first, then includes.
402
+ patterns: toPackagePatterns({
403
+ include: [
404
+ // Handlers connect to the DB, so ship the DocumentDB CA cert.
405
+ ...(tlsCAFile ? [tlsCAFile.replace(/^\.\//, '')] : []),
406
+ ],
407
+ exclude: [
408
+ 'node_modules/aws-sdk/**',
409
+ 'node_modules/@aws-sdk/**',
410
+ ...(usePrismaLayer
411
+ ? [
412
+ 'node_modules/@prisma/**',
413
+ 'node_modules/.prisma/**',
414
+ 'node_modules/prisma/**',
415
+ 'node_modules/@friggframework/core/generated/**',
416
+ ]
417
+ : []),
418
+ ...nestedNodeModulesExcludes(appDefinition, usePrismaLayer),
419
+ 'node_modules/@friggframework/test/**',
420
+ 'node_modules/@friggframework/eslint-config/**',
421
+ 'node_modules/@friggframework/prettier-config/**',
422
+ 'node_modules/jest/**',
423
+ 'node_modules/prettier/**',
424
+ 'node_modules/eslint/**',
425
+ 'node_modules/esbuild/**',
426
+ 'node_modules/@esbuild/**',
427
+ 'node_modules/typescript/**',
428
+ 'node_modules/webpack/**',
429
+ 'node_modules/osls/**',
430
+ 'node_modules/serverless-esbuild/**',
431
+ 'node_modules/serverless-jetpack/**',
432
+ 'node_modules/serverless-offline/**',
433
+ 'node_modules/serverless-offline-sqs/**',
434
+ 'node_modules/serverless-dotenv-plugin/**',
435
+ 'node_modules/serverless-kms-grants/**',
436
+ // Never deploy secrets or the lockfile.
437
+ '.env',
438
+ '.env.*',
439
+ '**/.env',
440
+ '**/.env.*',
441
+ '.frigg-credentials.json',
442
+ 'package-lock.json',
443
+ 'test/**',
444
+ 'layers/**',
445
+ 'coverage/**',
446
+ '**/*.test.js',
447
+ '**/*.spec.js',
448
+ ],
449
+ }),
446
450
  };
447
451
  }
448
452
 
@@ -285,11 +285,11 @@ describe('AdminScriptBuilder', () => {
285
285
  result.functions.adminScriptExecutor,
286
286
  result.functions.adminScriptRouter,
287
287
  ]) {
288
- expect(fn.package.exclude).toEqual(
288
+ expect(fn.package.patterns).toEqual(
289
289
  expect.arrayContaining([
290
- 'node_modules/aws-sdk/**',
291
- 'node_modules/@aws-sdk/**',
292
- 'node_modules/@prisma/**',
290
+ '!node_modules/aws-sdk/**',
291
+ '!node_modules/@aws-sdk/**',
292
+ '!node_modules/@prisma/**',
293
293
  ])
294
294
  );
295
295
  }
@@ -1029,7 +1029,7 @@ describe('AdminScriptBuilder nested node_modules (lambda.keepNestedNodeModules)'
1029
1029
  const result = await new AdminScriptBuilder().build(appDefinition(), {});
1030
1030
 
1031
1031
  for (const fn of executorAndRouter(result)) {
1032
- expect(fn.package.exclude).toContain('node_modules/**/node_modules/**');
1032
+ expect(fn.package.patterns).toContain('!node_modules/**/node_modules/**');
1033
1033
  }
1034
1034
  });
1035
1035
 
@@ -1040,8 +1040,47 @@ describe('AdminScriptBuilder nested node_modules (lambda.keepNestedNodeModules)'
1040
1040
  );
1041
1041
 
1042
1042
  for (const fn of executorAndRouter(result)) {
1043
- expect(fn.package.exclude).not.toContain('node_modules/**/node_modules/**');
1044
- expect(fn.package.exclude).toContain('node_modules/**/node_modules/@friggframework/**');
1043
+ expect(fn.package.patterns).not.toContain('!node_modules/**/node_modules/**');
1044
+ expect(fn.package.patterns).toContain('!node_modules/**/node_modules/@friggframework/**');
1045
1045
  }
1046
1046
  });
1047
1047
  });
1048
+
1049
+ describe('AdminScriptBuilder function package patterns (ADR-050)', () => {
1050
+ it('emits package.patterns, never include/exclude, on every skipEsbuild function', async () => {
1051
+ const result = await new AdminScriptBuilder().build(
1052
+ {
1053
+ adminScripts: [{ Definition: { name: 'test-script' } }],
1054
+ reports: [{ Definition: { name: 'test-report' } }],
1055
+ },
1056
+ {}
1057
+ );
1058
+
1059
+ const packaged = Object.entries(result.functions).filter(([, fn]) => fn.package);
1060
+ expect(packaged.map(([name]) => name)).toEqual(
1061
+ expect.arrayContaining(['adminScriptExecutor', 'adminScriptRouter'])
1062
+ );
1063
+ for (const [, fn] of packaged) {
1064
+ expect(fn.package).not.toHaveProperty('include');
1065
+ expect(fn.package).not.toHaveProperty('exclude');
1066
+ expect(fn.package.patterns.every((p) => p.startsWith('!'))).toBe(true);
1067
+ expect(fn.package.patterns).toEqual(
1068
+ expect.arrayContaining(['!node_modules/aws-sdk/**', '!.env', '!test/**'])
1069
+ );
1070
+ }
1071
+ });
1072
+
1073
+ it('re-adds the DocumentDB CA file after every exclude', async () => {
1074
+ const result = await new AdminScriptBuilder().build(
1075
+ {
1076
+ adminScripts: [{ Definition: { name: 'test-script' } }],
1077
+ database: { documentDB: { tlsCAFile: './global-bundle.pem' } },
1078
+ },
1079
+ {}
1080
+ );
1081
+
1082
+ const { patterns } = result.functions.adminScriptExecutor.package;
1083
+ expect(patterns[patterns.length - 1]).toBe('global-bundle.pem');
1084
+ expect(patterns.slice(0, -1).every((p) => p.startsWith('!'))).toBe(true);
1085
+ });
1086
+ });