@friggframework/devtools 2.0.0--canary.704.6a606c3.0 → 2.0.0--canary.703.12b980b.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 (65) hide show
  1. package/README.md +0 -14
  2. package/frigg-cli/README.md +30 -83
  3. package/frigg-cli/__tests__/unit/commands/deploy-subscriptions-step.test.js +35 -0
  4. package/frigg-cli/__tests__/unit/commands/generate-iam.test.js +0 -18
  5. package/frigg-cli/__tests__/unit/commands/install.test.js +341 -594
  6. package/frigg-cli/__tests__/unit/dependencies.test.js +5 -3
  7. package/frigg-cli/deploy-command/index.js +3 -0
  8. package/frigg-cli/deploy-command/subscriptions-step.js +44 -0
  9. package/frigg-cli/generate-command/index.js +0 -1
  10. package/frigg-cli/generate-iam-command.js +0 -1
  11. package/frigg-cli/index.js +6 -12
  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 +3 -3
  22. package/frigg-cli/test/init-command.test.js +2 -9
  23. package/infrastructure/README.md +0 -20
  24. package/infrastructure/docs/POSTGRES-CONFIGURATION.md +1 -21
  25. package/infrastructure/domains/admin-scripts/admin-script-builder.js +46 -50
  26. package/infrastructure/domains/admin-scripts/admin-script-builder.test.js +7 -46
  27. package/infrastructure/domains/database/aurora-builder.js +2 -13
  28. package/infrastructure/domains/database/aurora-builder.test.js +0 -22
  29. package/infrastructure/domains/database/migration-builder.js +175 -182
  30. package/infrastructure/domains/database/migration-builder.test.js +5 -36
  31. package/infrastructure/domains/integration/define-integration-provisioning.test.js +59 -0
  32. package/infrastructure/domains/integration/integration-builder.js +80 -65
  33. package/infrastructure/domains/integration/integration-builder.test.js +30 -73
  34. package/infrastructure/domains/scheduler/trigger-builder.js +114 -0
  35. package/infrastructure/domains/scheduler/trigger-builder.test.js +82 -0
  36. package/infrastructure/domains/security/iam-generator.js +5 -112
  37. package/infrastructure/domains/security/iam-generator.test.js +0 -94
  38. package/infrastructure/domains/shared/function-environments.js +9 -1
  39. package/infrastructure/domains/shared/function-environments.test.js +14 -0
  40. package/infrastructure/domains/shared/utilities/base-definition-factory.js +124 -83
  41. package/infrastructure/domains/shared/utilities/base-definition-factory.test.js +26 -116
  42. package/infrastructure/domains/shared/utilities/logging-config.js +4 -3
  43. package/infrastructure/domains/shared/utilities/logging-config.test.js +2 -1
  44. package/infrastructure/infrastructure-composer.js +2 -0
  45. package/infrastructure/infrastructure-composer.test.js +3 -3
  46. package/package.json +8 -13
  47. package/frigg-cli/__tests__/unit/commands/init.test.js +0 -688
  48. package/frigg-cli/__tests__/unit/utils/node-version.test.js +0 -66
  49. package/frigg-cli/init-command/deployment-modes.js +0 -7
  50. package/frigg-cli/init-command/safe-path.js +0 -58
  51. package/frigg-cli/init-command/scaffold-dependencies.js +0 -202
  52. package/frigg-cli/install-command/app-definition.js +0 -174
  53. package/frigg-cli/install-command/resolve-module.js +0 -69
  54. package/frigg-cli/templates/backend/README.md +0 -267
  55. package/frigg-cli/templates/backend/env.example +0 -20
  56. package/frigg-cli/templates/backend/gitignore +0 -10
  57. package/frigg-cli/templates/backend/index.js +0 -114
  58. package/frigg-cli/templates/backend/infrastructure.js +0 -20
  59. package/frigg-cli/utils/node-version.js +0 -51
  60. package/infrastructure/__tests__/package-patterns-composition.test.js +0 -153
  61. package/infrastructure/__tests__/scaffold-default-infrastructure.test.js +0 -148
  62. package/infrastructure/domains/shared/utilities/framework-version.js +0 -14
  63. package/infrastructure/domains/shared/utilities/framework-version.test.js +0 -27
  64. package/infrastructure/domains/shared/utilities/package-patterns.js +0 -35
  65. package/infrastructure/domains/shared/utilities/package-patterns.test.js +0 -112
@@ -4,11 +4,6 @@ const path = require('path');
4
4
  * Generate IAM CloudFormation template
5
5
  * @param {Object} options - Generation options
6
6
  * @param {string} [options.appName='Frigg'] - Application name
7
- * @param {string} [options.serviceName] - The osls service name the app deploys
8
- * under (Definition.name). Resource grants that match `*frigg*` are also
9
- * granted for `*<serviceName>*`, because `frigg deploy` names the stack,
10
- * functions, role, queues, topics, alarms, log groups, layer and buckets
11
- * after the service, not after "frigg".
12
7
  * @param {Object} [options.features={}] - Enabled features { vpc, kms, ssm, websockets }
13
8
  * @param {string} [options.userPrefix='frigg-deployment-user'] - IAM user name prefix
14
9
  * @param {string} [options.stackName='frigg-deployment-iam'] - CloudFormation stack name
@@ -21,8 +16,7 @@ function generateIAMCloudFormation(options = {}) {
21
16
  features = {},
22
17
  userPrefix = 'frigg-deployment-user',
23
18
  stackName = 'frigg-deployment-iam',
24
- ssmKmsKeyArn,
25
- serviceName,
19
+ ssmKmsKeyArn
26
20
  } = options;
27
21
 
28
22
  const deploymentUserName = userPrefix;
@@ -531,51 +525,6 @@ function generateIAMCloudFormation(options = {}) {
531
525
  },
532
526
  ];
533
527
 
534
- coreStatements.push(
535
- {
536
- Sid: 'FriggLambdaLayers',
537
- Effect: 'Allow',
538
- Action: [
539
- 'lambda:PublishLayerVersion',
540
- 'lambda:DeleteLayerVersion',
541
- 'lambda:GetLayerVersion',
542
- ],
543
- Resource: [
544
- {
545
- 'Fn::Sub':
546
- 'arn:aws:lambda:*:${AWS::AccountId}:layer:*frigg*',
547
- },
548
- {
549
- 'Fn::Sub':
550
- 'arn:aws:lambda:*:${AWS::AccountId}:layer:*frigg*:*',
551
- },
552
- ],
553
- },
554
- {
555
- // Buckets the app's stack creates (e.g. the migration-status
556
- // bucket); CloudFormation names them after the stack, in lower case.
557
- Sid: 'FriggAppBuckets',
558
- Effect: 'Allow',
559
- Action: [
560
- 's3:CreateBucket',
561
- 's3:DeleteBucket',
562
- 's3:PutBucketPolicy',
563
- 's3:DeleteBucketPolicy',
564
- 's3:PutBucketVersioning',
565
- 's3:PutBucketPublicAccessBlock',
566
- 's3:PutEncryptionConfiguration',
567
- 's3:PutLifecycleConfiguration',
568
- 's3:PutBucketTagging',
569
- 's3:GetBucketLocation',
570
- 's3:ListBucket',
571
- 's3:GetObject',
572
- 's3:PutObject',
573
- 's3:DeleteObject',
574
- ],
575
- Resource: ['arn:aws:s3:::*frigg*', 'arn:aws:s3:::*frigg*/*'],
576
- }
577
- );
578
-
579
528
  template.Resources.FriggCoreDeploymentPolicy = {
580
529
  Type: 'AWS::IAM::ManagedPolicy',
581
530
  Properties: {
@@ -819,59 +768,10 @@ function generateIAMCloudFormation(options = {}) {
819
768
  },
820
769
  };
821
770
 
822
- expandResourceNamePatterns(template, serviceName);
823
-
824
771
  // Convert to YAML
825
772
  return convertToYAML(template);
826
773
  }
827
774
 
828
- const FRIGG_NAME_PATTERN = '*frigg*';
829
-
830
- /**
831
- * Next to every policy resource that matches `*frigg*`, add the same
832
- * resource for `*<serviceName>*` (lower case for S3 bucket ARNs), so an app
833
- * that is not named "frigg" can manage its own stack resources.
834
- *
835
- * @param {Object} template - CloudFormation template (mutated)
836
- * @param {string} [serviceName]
837
- */
838
- function expandResourceNamePatterns(template, serviceName) {
839
- if (!serviceName || /frigg/i.test(serviceName)) {
840
- return;
841
- }
842
- const servicePattern = `*${serviceName}*`;
843
- const expand = (resource) => {
844
- const value =
845
- typeof resource === 'string'
846
- ? resource
847
- : resource && resource['Fn::Sub'];
848
- if (typeof value !== 'string' || !value.includes(FRIGG_NAME_PATTERN)) {
849
- return [resource];
850
- }
851
- const pattern = value.startsWith('arn:aws:s3:::')
852
- ? servicePattern.toLowerCase()
853
- : servicePattern;
854
- const scoped = value.split(FRIGG_NAME_PATTERN).join(pattern);
855
- return [
856
- resource,
857
- typeof resource === 'string' ? scoped : { 'Fn::Sub': scoped },
858
- ];
859
- };
860
-
861
- for (const resource of Object.values(template.Resources)) {
862
- const statements = resource?.Properties?.PolicyDocument?.Statement;
863
- if (!Array.isArray(statements)) continue;
864
- for (const statement of statements) {
865
- if (statement.Resource === undefined) continue;
866
- const expanded = [].concat(statement.Resource).flatMap(expand);
867
- statement.Resource =
868
- Array.isArray(statement.Resource) || expanded.length > 1
869
- ? expanded
870
- : expanded[0];
871
- }
872
- }
873
- }
874
-
875
775
  /**
876
776
  * Convert JavaScript object to CloudFormation YAML
877
777
  * @param {Object} obj - JavaScript object
@@ -896,7 +796,8 @@ function getFeatureSummary(appDefinition) {
896
796
  const features = {
897
797
  core: true, // Always enabled
898
798
  vpc: appDefinition.vpc?.enable === true,
899
- kms: appDefinition.encryption?.fieldLevelEncryptionMethod === 'kms',
799
+ kms:
800
+ appDefinition.encryption?.fieldLevelEncryptionMethod === 'kms',
900
801
  ssm: appDefinition.ssm?.enable === true,
901
802
  websockets: appDefinition.websockets?.enable === true,
902
803
  };
@@ -907,8 +808,6 @@ function getFeatureSummary(appDefinition) {
907
808
  features,
908
809
  integrationCount,
909
810
  appName: appDefinition.name || 'Unnamed Frigg App',
910
- // What createBaseDefinition uses as the osls service name.
911
- serviceName: appDefinition.name || 'create-frigg-app',
912
811
  ssmKmsKeyArn: appDefinition.ssm?.kmsKeyArn,
913
812
  };
914
813
  }
@@ -918,10 +817,7 @@ function getFeatureSummary(appDefinition) {
918
817
  * @returns {Object} Basic IAM policy document
919
818
  */
920
819
  function generateBasicIAMPolicy() {
921
- const basicPolicyPath = path.join(
922
- __dirname,
923
- 'templates/iam-policy-basic.json'
924
- );
820
+ const basicPolicyPath = path.join(__dirname, 'templates/iam-policy-basic.json');
925
821
  return require(basicPolicyPath);
926
822
  }
927
823
 
@@ -930,10 +826,7 @@ function generateBasicIAMPolicy() {
930
826
  * @returns {Object} Full IAM policy document
931
827
  */
932
828
  function generateFullIAMPolicy() {
933
- const fullPolicyPath = path.join(
934
- __dirname,
935
- 'templates/iam-policy-full.json'
936
- );
829
+ const fullPolicyPath = path.join(__dirname, 'templates/iam-policy-full.json');
937
830
  return require(fullPolicyPath);
938
831
  }
939
832
 
@@ -313,98 +313,4 @@ describe('IAM Generator', () => {
313
313
  expect(yaml).toContain('CredentialsSecretArn:');
314
314
  });
315
315
  });
316
-
317
- describe("scoping to the app's own resources", () => {
318
- const yaml = require('js-yaml');
319
- const policyResources = (template, policy) =>
320
- template.Resources[
321
- policy
322
- ].Properties.PolicyDocument.Statement.flatMap((statement) =>
323
- [].concat(statement.Resource)
324
- ).map((r) => (typeof r === 'string' ? r : r['Fn::Sub']));
325
-
326
- // `frigg deploy` names everything after the service (Definition.name):
327
- // stack my-app-prod, functions my-app-prod-auth, role
328
- // my-app-prod-us-east-1-lambdaRole, queues my-app-internal-error-queue-prod
329
- // and my-app-prod-DbMigrationQueue, layer my-app-prisma-prod, and
330
- // CloudFormation-named topics, alarms and buckets prefixed my-app-prod.
331
- const generate = (appDefinition) => {
332
- const summary = getFeatureSummary(appDefinition);
333
- return yaml.load(
334
- generateIAMCloudFormation({
335
- appName: summary.appName,
336
- serviceName: summary.serviceName,
337
- features: summary.features,
338
- })
339
- );
340
- };
341
-
342
- it('reports the service name osls deploys under', () => {
343
- expect(getFeatureSummary({ name: 'my-app' }).serviceName).toBe(
344
- 'my-app'
345
- );
346
- expect(getFeatureSummary({}).serviceName).toBe('create-frigg-app');
347
- });
348
-
349
- it('lets an app whose name does not contain "frigg" deploy its stack and resources', () => {
350
- const resources = policyResources(
351
- generate({ name: 'my-app' }),
352
- 'FriggCoreDeploymentPolicy'
353
- );
354
-
355
- for (const expected of [
356
- 'arn:aws:cloudformation:*:${AWS::AccountId}:stack/*my-app*/*',
357
- 'arn:aws:lambda:*:${AWS::AccountId}:function:*my-app*',
358
- 'arn:aws:iam::${AWS::AccountId}:role/*my-app*',
359
- 'arn:aws:sqs:*:${AWS::AccountId}:*my-app*',
360
- 'arn:aws:sns:*:${AWS::AccountId}:*my-app*',
361
- 'arn:aws:logs:*:${AWS::AccountId}:log-group:/aws/lambda/*my-app*',
362
- 'arn:aws:logs:*:${AWS::AccountId}:log-group:/aws/lambda/*my-app*:*',
363
- 'arn:aws:cloudwatch:*:${AWS::AccountId}:alarm:*my-app*',
364
- 'arn:aws:lambda:*:${AWS::AccountId}:layer:*my-app*',
365
- 'arn:aws:lambda:*:${AWS::AccountId}:layer:*my-app*:*',
366
- 'arn:aws:s3:::*my-app*',
367
- 'arn:aws:s3:::*my-app*/*',
368
- ]) {
369
- expect(resources).toContain(expected);
370
- }
371
- // Existing grants for frigg-named resources are kept.
372
- expect(resources).toContain(
373
- 'arn:aws:lambda:*:${AWS::AccountId}:function:*frigg*'
374
- );
375
- });
376
-
377
- it('matches S3 bucket names in lower case', () => {
378
- const resources = policyResources(
379
- generate({ name: 'MyApp' }),
380
- 'FriggCoreDeploymentPolicy'
381
- );
382
- expect(resources).toContain('arn:aws:s3:::*myapp*');
383
- });
384
-
385
- it('scopes the SSM parameter grant to the app too', () => {
386
- const template = generate({
387
- name: 'my-app',
388
- ssm: { enable: true },
389
- });
390
- const resources = policyResources(template, 'FriggSSMPolicy');
391
- expect(resources).toContain(
392
- 'arn:aws:ssm:*:${AWS::AccountId}:parameter/*my-app*'
393
- );
394
- });
395
-
396
- it('does not duplicate grants for an app named frigg', () => {
397
- const resources = policyResources(
398
- generate({ name: 'frigg' }),
399
- 'FriggCoreDeploymentPolicy'
400
- );
401
- expect(
402
- resources.filter(
403
- (r) =>
404
- r ===
405
- 'arn:aws:lambda:*:${AWS::AccountId}:function:*frigg*'
406
- )
407
- ).toHaveLength(1);
408
- });
409
- });
410
316
  });
@@ -1,3 +1,5 @@
1
+ const { hasTriggers } = require('@friggframework/core/integrations/triggers');
2
+
1
3
  /**
2
4
  * Per-function environment scoping (ADR-027)
3
5
  *
@@ -47,7 +49,8 @@ function applyFunctionEnvironments(functions, functionEnvironments = {}) {
47
49
  /**
48
50
  * Function names the integration builder creates for one integration.
49
51
  * Wire contract: must stay in sync with
50
- * IntegrationBuilder.createFunctionDefinitions — a drift here surfaces as a
52
+ * IntegrationBuilder.createFunctionDefinitions (and TriggerBuilder for
53
+ * `${name}Triggers`) — a drift here surfaces as a
51
54
  * hard unknown-function error at compose time, not a silent var drop.
52
55
  *
53
56
  * @param {Object} integration - entry from appDefinition.integrations
@@ -62,6 +65,11 @@ function getIntegrationFunctionNames(integration) {
62
65
  names.splice(1, 0, `${name}Webhook`);
63
66
  }
64
67
 
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
+
65
73
  for (const [bindingKey, binding] of Object.entries(
66
74
  integration.Definition.extensions || {}
67
75
  )) {
@@ -67,6 +67,20 @@ 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
+
70
84
  it('includes one function per routed extension binding, sanitized', () => {
71
85
  const names = getIntegrationFunctionNames({
72
86
  Definition: {
@@ -9,9 +9,7 @@
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');
15
13
 
16
14
  /**
17
15
  * Create base serverless definition with core functions and resources
@@ -39,95 +37,143 @@ function createBaseDefinition(
39
37
  const loggingConfig = buildLoggingProviderConfig(AppDefinition.logging);
40
38
 
41
39
  // 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.
40
+ // Include backend src/ and index.js since handlers load the app definition
44
41
  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
- ] : []),
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
+ ] : []),
61
57
 
62
- // Exclude AWS SDK (provided by Lambda runtime)
63
- 'node_modules/aws-sdk/**',
64
- 'node_modules/@aws-sdk/**',
58
+ // Exclude AWS SDK (provided by Lambda runtime)
59
+ 'node_modules/aws-sdk/**',
60
+ 'node_modules/@aws-sdk/**',
65
61
 
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/**',
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/**',
73
69
 
74
- ...nestedNodeModulesExcludes(AppDefinition, usePrismaLayer),
70
+ ...nestedNodeModulesExcludes(AppDefinition, usePrismaLayer),
75
71
 
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!
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!
89
85
 
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',
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',
107
103
 
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
- }),
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/**',
122
+
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
+ ] : []),
130
+
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/**',
134
+
135
+ // Exclude environment files (NEVER deploy .env files!)
136
+ '.env',
137
+ '.env.*',
138
+ '.env.local',
139
+ '.env.*.local',
140
+ '**/.env',
141
+ '**/.env.*',
142
+
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/**',
152
+
153
+ // Exclude AI assistant and development artifacts
154
+ '**/.claude-flow/**',
155
+ '**/.swarm/**',
156
+ '**/CLAUDE.md',
157
+ '**/README.md',
158
+ '**/*.md',
159
+
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
+ ],
119
166
  };
120
167
 
121
168
  return {
122
- frameworkVersion: OSLS_FRAMEWORK_VERSION,
169
+ frameworkVersion: loggingConfig.frameworkVersion || '>=3.17.0',
123
170
  service: AppDefinition.name || 'create-frigg-app',
124
171
  package: {
125
172
  individually: true,
126
173
  },
127
174
  // 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 }),
175
+ // Production deployments should use environment vars from infrastructure
176
+ useDotenv: process.argv.includes('offline'),
131
177
  provider: {
132
178
  name: AppDefinition.provider || 'aws',
133
179
  ...(process.env.AWS_PROFILE && { profile: process.env.AWS_PROFILE }),
@@ -337,18 +383,12 @@ function createBaseDefinition(
337
383
  },
338
384
  },
339
385
  },
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
386
  ApiGatewayAlarm5xx: {
347
387
  Type: 'AWS::CloudWatch::Alarm',
348
388
  Properties: {
349
389
  AlarmDescription: 'API Gateway 5xx Errors',
350
390
  Namespace: 'AWS/ApiGateway',
351
- MetricName: '5xx',
391
+ MetricName: '5XXError',
352
392
  Statistic: 'Sum',
353
393
  Threshold: 0,
354
394
  ComparisonOperator: 'GreaterThanThreshold',
@@ -357,6 +397,7 @@ function createBaseDefinition(
357
397
  AlarmActions: [{ Ref: 'InternalErrorBridgeTopic' }],
358
398
  Dimensions: [
359
399
  { Name: 'ApiId', Value: { Ref: 'HttpApi' } },
400
+ { Name: 'Stage', Value: '${self:provider.stage}' },
360
401
  ],
361
402
  },
362
403
  },