@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
@@ -886,8 +886,8 @@ describe('IntegrationBuilder', () => {
886
886
  const result = await integrationBuilder.build(appDefinition, {});
887
887
 
888
888
  expect(result.functions.testWebhook.package).toBeDefined();
889
- expect(result.functions.testWebhook.package.patterns).toContain('!node_modules/aws-sdk/**');
890
- expect(result.functions.testWebhook.package.patterns).toContain('!node_modules/@prisma/**');
889
+ expect(result.functions.testWebhook.package.exclude).toContain('node_modules/aws-sdk/**');
890
+ expect(result.functions.testWebhook.package.exclude).toContain('node_modules/@prisma/**');
891
891
  });
892
892
  });
893
893
 
@@ -982,8 +982,8 @@ describe('IntegrationBuilder', () => {
982
982
  expect(result.functions.asana.layers).toBeUndefined();
983
983
  expect(result.functions.asanaQueueWorker.layers).toBeUndefined();
984
984
  expect(result.functions.asanaWebhook.layers).toBeUndefined();
985
- expect(result.functions.asana.package.patterns).not.toEqual(
986
- expect.arrayContaining(['!node_modules/@prisma/**'])
985
+ expect(result.functions.asana.package.exclude).not.toEqual(
986
+ expect.arrayContaining(['node_modules/@prisma/**'])
987
987
  );
988
988
  });
989
989
  });
@@ -1091,14 +1091,14 @@ describe('IntegrationBuilder nested node_modules (lambda.keepNestedNodeModules)'
1091
1091
  ...(lambda && { lambda }),
1092
1092
  });
1093
1093
  const packagedFunctions = (result) =>
1094
- Object.values(result.functions).filter((fn) => fn.package?.patterns);
1094
+ Object.values(result.functions).filter((fn) => fn.package?.exclude);
1095
1095
 
1096
1096
  it('excludes every nested node_modules by default', async () => {
1097
1097
  const result = await new IntegrationBuilder().build(appDefinition(), {});
1098
1098
 
1099
1099
  expect(packagedFunctions(result).length).toBeGreaterThan(0);
1100
1100
  for (const fn of packagedFunctions(result)) {
1101
- expect(fn.package.patterns).toContain('!node_modules/**/node_modules/**');
1101
+ expect(fn.package.exclude).toContain('node_modules/**/node_modules/**');
1102
1102
  }
1103
1103
  });
1104
1104
 
@@ -1109,73 +1109,8 @@ describe('IntegrationBuilder nested node_modules (lambda.keepNestedNodeModules)'
1109
1109
  );
1110
1110
 
1111
1111
  for (const fn of packagedFunctions(result)) {
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/**');
1112
+ expect(fn.package.exclude).not.toContain('node_modules/**/node_modules/**');
1113
+ expect(fn.package.exclude).toContain('node_modules/**/node_modules/@friggframework/**');
1179
1114
  }
1180
1115
  });
1181
1116
  });
@@ -40,6 +40,7 @@ const FRAMEWORK_ENV_BLOCKLIST = new Set([
40
40
  'KMS_KEY_ARN',
41
41
  'AES_KEY',
42
42
  'AES_KEY_ID',
43
+ 'FRIGG_ENCRYPTION_DISABLED',
43
44
  'DATABASE_URL',
44
45
  'DATABASE_HOST',
45
46
  'DATABASE_PORT',
@@ -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
  });
@@ -72,6 +72,16 @@ function addLoggingEnv(appDefinition, envVars) {
72
72
  envVars.FRIGG_LOG_LEVEL = normalized;
73
73
  }
74
74
 
75
+ // Field-level encryption fails closed in a deployed stage with no key (core's
76
+ // encryption-config.js). `fieldLevelEncryptionMethod: 'none'` is the explicit,
77
+ // documented way to run a stage in plaintext; core logs a warning on every
78
+ // cold start while it is set.
79
+ function addEncryptionEnv(appDefinition, envVars) {
80
+ if (appDefinition?.encryption?.fieldLevelEncryptionMethod === 'none') {
81
+ envVars.FRIGG_ENCRYPTION_DISABLED = 'true';
82
+ }
83
+ }
84
+
75
85
  /**
76
86
  * Get environment variables from AppDefinition
77
87
  *
@@ -149,6 +159,7 @@ function getAppEnvironmentVars(appDefinition) {
149
159
  }
150
160
 
151
161
  addLoggingEnv(appDefinition, envVars);
162
+ addEncryptionEnv(appDefinition, envVars);
152
163
 
153
164
  if (envKeys.length > 0) {
154
165
  console.log(
@@ -187,7 +198,7 @@ function getAppEnvironmentVars(appDefinition) {
187
198
  function buildEnvironment(appEnvironmentVars, discoveredResources) {
188
199
  const environment = {
189
200
  ...appEnvironmentVars,
190
- STAGE: '${self:provider.stage}', // Used by encryption bypass logic
201
+ STAGE: '${self:provider.stage}', // Read by core: e.g. the local-only encryption bypass
191
202
  FRIGG_STACK: '${self:service}',
192
203
  FRIGG_STAGE: '${self:provider.stage}',
193
204
  FRIGG_REGION: '${self:provider.region}',
@@ -468,6 +468,26 @@ describe('Environment Builder', () => {
468
468
  });
469
469
  });
470
470
 
471
+ describe('field-level encryption opt-out', () => {
472
+ it("emits FRIGG_ENCRYPTION_DISABLED=true for fieldLevelEncryptionMethod: 'none'", () => {
473
+ const result = getAppEnvironmentVars({
474
+ encryption: { fieldLevelEncryptionMethod: 'none' },
475
+ });
476
+
477
+ expect(result.FRIGG_ENCRYPTION_DISABLED).toBe('true');
478
+ });
479
+
480
+ it.each([
481
+ ['kms', { fieldLevelEncryptionMethod: 'kms' }],
482
+ ['aes', { fieldLevelEncryptionMethod: 'aes' }],
483
+ ['no encryption block', undefined],
484
+ ])('does not opt out for %s', (_label, encryption) => {
485
+ const result = getAppEnvironmentVars({ encryption });
486
+
487
+ expect(result.FRIGG_ENCRYPTION_DISABLED).toBeUndefined();
488
+ });
489
+ });
490
+
471
491
  describe('buildEnvironment()', () => {
472
492
  it('should combine app vars with standard Frigg variables', () => {
473
493
  const appEnvironmentVars = {
@@ -129,7 +129,7 @@
129
129
  * @typedef {Object} AppDefinition
130
130
  * @property {string} name - Application name
131
131
  * @property {string} stage - Deployment stage (e.g., 'dev', 'production')
132
- * @property {string} provider - Cloud provider (e.g., 'aws')
132
+ * @property {string} provider - Deployment provider: 'aws' (serverless/Lambda) or 'netlify' (@friggframework/provider-netlify)
133
133
  * @property {string} region - AWS region
134
134
  *
135
135
  * @property {VpcDefinition} [vpc] - VPC configuration
@@ -144,6 +144,20 @@
144
144
  * @property {AdminConfig} [admin] - Admin configuration
145
145
  *
146
146
  * @property {Object} [environment] - Environment variables
147
+ *
148
+ * @property {ExtensionDefinition[]} [coreExtensions] - Core (app-level) extensions that add custom Prisma models, encrypted fields, admin routes and bootstrap hooks (not an integration's Definition.extensions, nor ADR-017's keyed appDefinition.extensions)
149
+ */
150
+
151
+ /**
152
+ * App-level extension: custom models, encryption, admin routes and bootstrap
153
+ * @typedef {Object} ExtensionDefinition
154
+ * @property {string} name - Unique identifier for this extension
155
+ * @property {string} [schema] - Absolute path to a .prisma schema fragment
156
+ * @property {Object<string, {fields: string[]}>} [encryption] - Model name → encrypted fields mapping
157
+ * @property {Object} [routes] - Express router configuration
158
+ * @property {string} routes.path - Base URL path for the extension routes: /admin/<segment>..., never /api (/admin/scripts, /admin/db-migrate and /admin/queue are reserved); served by the auth function
159
+ * @property {Function|Object} routes.handler - Router factory (prisma, appDefinition) → Router, or { router } object
160
+ * @property {Function} [bootstrap] - Async function (prisma, appDefinition) → void, run by initializeApp()
147
161
  */
148
162
 
149
163
  /**