@stackframe/stack-shared 2.8.20 → 2.8.22

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 (61) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/config/schema.d.mts +67 -15
  3. package/dist/config/schema.d.ts +67 -15
  4. package/dist/config/schema.js +8 -4
  5. package/dist/config/schema.js.map +1 -1
  6. package/dist/esm/config/schema.js +8 -4
  7. package/dist/esm/config/schema.js.map +1 -1
  8. package/dist/esm/helpers/email-themes.js +45 -0
  9. package/dist/esm/helpers/email-themes.js.map +1 -0
  10. package/dist/esm/interface/admin-interface.js +71 -2
  11. package/dist/esm/interface/admin-interface.js.map +1 -1
  12. package/dist/esm/interface/client-interface.js +1 -1
  13. package/dist/esm/interface/client-interface.js.map +1 -1
  14. package/dist/esm/known-errors.js +13 -8
  15. package/dist/esm/known-errors.js.map +1 -1
  16. package/dist/esm/schema-fields.js +9 -1
  17. package/dist/esm/schema-fields.js.map +1 -1
  18. package/dist/esm/utils/errors.js +3 -0
  19. package/dist/esm/utils/errors.js.map +1 -1
  20. package/dist/esm/utils/esbuild.js +54 -45
  21. package/dist/esm/utils/esbuild.js.map +1 -1
  22. package/dist/esm/utils/json.js +4 -4
  23. package/dist/esm/utils/json.js.map +1 -1
  24. package/dist/esm/utils/react.js +45 -4
  25. package/dist/esm/utils/react.js.map +1 -1
  26. package/dist/helpers/email-themes.d.mts +13 -0
  27. package/dist/helpers/email-themes.d.ts +13 -0
  28. package/dist/helpers/email-themes.js +71 -0
  29. package/dist/helpers/email-themes.js.map +1 -0
  30. package/dist/interface/admin-interface.d.mts +40 -2
  31. package/dist/interface/admin-interface.d.ts +40 -2
  32. package/dist/interface/admin-interface.js +71 -2
  33. package/dist/interface/admin-interface.js.map +1 -1
  34. package/dist/interface/client-interface.js +1 -1
  35. package/dist/interface/client-interface.js.map +1 -1
  36. package/dist/interface/crud/projects.d.mts +7 -7
  37. package/dist/interface/crud/projects.d.ts +7 -7
  38. package/dist/known-errors.d.mts +2 -2
  39. package/dist/known-errors.d.ts +2 -2
  40. package/dist/known-errors.js +13 -8
  41. package/dist/known-errors.js.map +1 -1
  42. package/dist/schema-fields.d.mts +6 -2
  43. package/dist/schema-fields.d.ts +6 -2
  44. package/dist/schema-fields.js +10 -1
  45. package/dist/schema-fields.js.map +1 -1
  46. package/dist/utils/errors.js +3 -0
  47. package/dist/utils/errors.js.map +1 -1
  48. package/dist/utils/esbuild.js +54 -45
  49. package/dist/utils/esbuild.js.map +1 -1
  50. package/dist/utils/json.d.mts +2 -2
  51. package/dist/utils/json.d.ts +2 -2
  52. package/dist/utils/json.js +5 -5
  53. package/dist/utils/json.js.map +1 -1
  54. package/dist/utils/react.d.mts +30 -5
  55. package/dist/utils/react.d.ts +30 -5
  56. package/dist/utils/react.js +49 -5
  57. package/dist/utils/react.js.map +1 -1
  58. package/dist/utils/types.d.mts +3 -2
  59. package/dist/utils/types.d.ts +3 -2
  60. package/dist/utils/types.js.map +1 -1
  61. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @stackframe/stack-shared
2
2
 
3
+ ## 2.8.22
4
+
5
+ ### Patch Changes
6
+
7
+ - Various changes
8
+
9
+ ## 2.8.21
10
+
11
+ ### Patch Changes
12
+
13
+ - Various changes
14
+
3
15
  ## 2.8.20
4
16
 
5
17
  ### Patch Changes
@@ -69,7 +69,13 @@ declare const branchConfigSchema: yup.ObjectSchema<{} & {
69
69
  }> | undefined;
70
70
  } | undefined;
71
71
  } | undefined;
72
- emails: {};
72
+ emails: {
73
+ theme?: string | undefined;
74
+ themeList?: Record<string, {
75
+ displayName: string;
76
+ tsxSource: string;
77
+ }> | undefined;
78
+ };
73
79
  }, yup.AnyObject, {
74
80
  sourceOfTruth: undefined;
75
81
  rbac: {
@@ -112,7 +118,10 @@ declare const branchConfigSchema: yup.ObjectSchema<{} & {
112
118
  providers: undefined;
113
119
  };
114
120
  };
115
- emails: {};
121
+ emails: {
122
+ theme: undefined;
123
+ themeList: undefined;
124
+ };
116
125
  }, "">;
117
126
  declare const environmentConfigSchema: yup.ObjectSchema<{
118
127
  rbac: {
@@ -188,8 +197,13 @@ declare const environmentConfigSchema: yup.ObjectSchema<{
188
197
  }> | undefined;
189
198
  }) | undefined;
190
199
  }) | undefined;
191
- emails: Omit<{}, never> & {
192
- theme?: "default-light" | "default-dark" | undefined;
200
+ emails: Omit<{
201
+ theme?: string | undefined;
202
+ themeList?: Record<string, {
203
+ displayName: string;
204
+ tsxSource: string;
205
+ }> | undefined;
206
+ }, never> & {
193
207
  server: {
194
208
  host?: string | undefined;
195
209
  port?: number | undefined;
@@ -241,8 +255,13 @@ declare const environmentConfigSchema: yup.ObjectSchema<{
241
255
  }> | undefined;
242
256
  }) | undefined;
243
257
  }) | undefined;
244
- emails: Omit<{}, never> & {
245
- theme?: "default-light" | "default-dark" | undefined;
258
+ emails: Omit<{
259
+ theme?: string | undefined;
260
+ themeList?: Record<string, {
261
+ displayName: string;
262
+ tsxSource: string;
263
+ }> | undefined;
264
+ }, never> & {
246
265
  server: {
247
266
  host?: string | undefined;
248
267
  port?: number | undefined;
@@ -326,7 +345,10 @@ declare const environmentConfigSchema: yup.ObjectSchema<{
326
345
  providers: undefined;
327
346
  };
328
347
  };
329
- emails: {};
348
+ emails: {
349
+ theme: undefined;
350
+ themeList: undefined;
351
+ };
330
352
  };
331
353
  auth: {
332
354
  sourceOfTruth: undefined;
@@ -370,7 +392,10 @@ declare const environmentConfigSchema: yup.ObjectSchema<{
370
392
  providers: undefined;
371
393
  };
372
394
  };
373
- emails: {};
395
+ emails: {
396
+ theme: undefined;
397
+ themeList: undefined;
398
+ };
374
399
  };
375
400
  emails: {
376
401
  sourceOfTruth: undefined;
@@ -414,7 +439,10 @@ declare const environmentConfigSchema: yup.ObjectSchema<{
414
439
  providers: undefined;
415
440
  };
416
441
  };
417
- emails: {};
442
+ emails: {
443
+ theme: undefined;
444
+ themeList: undefined;
445
+ };
418
446
  };
419
447
  }, "">;
420
448
  declare const organizationConfigSchema: yup.ObjectSchema<{
@@ -491,8 +519,13 @@ declare const organizationConfigSchema: yup.ObjectSchema<{
491
519
  }> | undefined;
492
520
  }) | undefined;
493
521
  }) | undefined;
494
- emails: Omit<{}, never> & {
495
- theme?: "default-light" | "default-dark" | undefined;
522
+ emails: Omit<{
523
+ theme?: string | undefined;
524
+ themeList?: Record<string, {
525
+ displayName: string;
526
+ tsxSource: string;
527
+ }> | undefined;
528
+ }, never> & {
496
529
  server: {
497
530
  host?: string | undefined;
498
531
  port?: number | undefined;
@@ -568,7 +601,10 @@ declare const organizationConfigSchema: yup.ObjectSchema<{
568
601
  providers: undefined;
569
602
  };
570
603
  };
571
- emails: {};
604
+ emails: {
605
+ theme: undefined;
606
+ themeList: undefined;
607
+ };
572
608
  };
573
609
  auth: {
574
610
  sourceOfTruth: undefined;
@@ -612,7 +648,10 @@ declare const organizationConfigSchema: yup.ObjectSchema<{
612
648
  providers: undefined;
613
649
  };
614
650
  };
615
- emails: {};
651
+ emails: {
652
+ theme: undefined;
653
+ themeList: undefined;
654
+ };
616
655
  };
617
656
  emails: {
618
657
  sourceOfTruth: undefined;
@@ -656,7 +695,10 @@ declare const organizationConfigSchema: yup.ObjectSchema<{
656
695
  providers: undefined;
657
696
  };
658
697
  };
659
- emails: {};
698
+ emails: {
699
+ theme: undefined;
700
+ themeList: undefined;
701
+ };
660
702
  };
661
703
  }, "">;
662
704
  declare const projectConfigDefaults: {
@@ -718,7 +760,17 @@ declare const organizationConfigDefaults: {
718
760
  server: {
719
761
  isShared: true;
720
762
  };
721
- theme: "default-light";
763
+ theme: string;
764
+ themeList: {
765
+ "1df07ae6-abf3-4a40-83a5-a1a2cbe336ac": {
766
+ displayName: string;
767
+ tsxSource: string;
768
+ };
769
+ "a0172b5d-cff0-463b-83bb-85124697373a": {
770
+ displayName: string;
771
+ tsxSource: string;
772
+ };
773
+ };
722
774
  };
723
775
  };
724
776
  type DeepReplaceAllowFunctionsForObjects<T> = T extends object ? {
@@ -69,7 +69,13 @@ declare const branchConfigSchema: yup.ObjectSchema<{} & {
69
69
  }> | undefined;
70
70
  } | undefined;
71
71
  } | undefined;
72
- emails: {};
72
+ emails: {
73
+ theme?: string | undefined;
74
+ themeList?: Record<string, {
75
+ displayName: string;
76
+ tsxSource: string;
77
+ }> | undefined;
78
+ };
73
79
  }, yup.AnyObject, {
74
80
  sourceOfTruth: undefined;
75
81
  rbac: {
@@ -112,7 +118,10 @@ declare const branchConfigSchema: yup.ObjectSchema<{} & {
112
118
  providers: undefined;
113
119
  };
114
120
  };
115
- emails: {};
121
+ emails: {
122
+ theme: undefined;
123
+ themeList: undefined;
124
+ };
116
125
  }, "">;
117
126
  declare const environmentConfigSchema: yup.ObjectSchema<{
118
127
  rbac: {
@@ -188,8 +197,13 @@ declare const environmentConfigSchema: yup.ObjectSchema<{
188
197
  }> | undefined;
189
198
  }) | undefined;
190
199
  }) | undefined;
191
- emails: Omit<{}, never> & {
192
- theme?: "default-light" | "default-dark" | undefined;
200
+ emails: Omit<{
201
+ theme?: string | undefined;
202
+ themeList?: Record<string, {
203
+ displayName: string;
204
+ tsxSource: string;
205
+ }> | undefined;
206
+ }, never> & {
193
207
  server: {
194
208
  host?: string | undefined;
195
209
  port?: number | undefined;
@@ -241,8 +255,13 @@ declare const environmentConfigSchema: yup.ObjectSchema<{
241
255
  }> | undefined;
242
256
  }) | undefined;
243
257
  }) | undefined;
244
- emails: Omit<{}, never> & {
245
- theme?: "default-light" | "default-dark" | undefined;
258
+ emails: Omit<{
259
+ theme?: string | undefined;
260
+ themeList?: Record<string, {
261
+ displayName: string;
262
+ tsxSource: string;
263
+ }> | undefined;
264
+ }, never> & {
246
265
  server: {
247
266
  host?: string | undefined;
248
267
  port?: number | undefined;
@@ -326,7 +345,10 @@ declare const environmentConfigSchema: yup.ObjectSchema<{
326
345
  providers: undefined;
327
346
  };
328
347
  };
329
- emails: {};
348
+ emails: {
349
+ theme: undefined;
350
+ themeList: undefined;
351
+ };
330
352
  };
331
353
  auth: {
332
354
  sourceOfTruth: undefined;
@@ -370,7 +392,10 @@ declare const environmentConfigSchema: yup.ObjectSchema<{
370
392
  providers: undefined;
371
393
  };
372
394
  };
373
- emails: {};
395
+ emails: {
396
+ theme: undefined;
397
+ themeList: undefined;
398
+ };
374
399
  };
375
400
  emails: {
376
401
  sourceOfTruth: undefined;
@@ -414,7 +439,10 @@ declare const environmentConfigSchema: yup.ObjectSchema<{
414
439
  providers: undefined;
415
440
  };
416
441
  };
417
- emails: {};
442
+ emails: {
443
+ theme: undefined;
444
+ themeList: undefined;
445
+ };
418
446
  };
419
447
  }, "">;
420
448
  declare const organizationConfigSchema: yup.ObjectSchema<{
@@ -491,8 +519,13 @@ declare const organizationConfigSchema: yup.ObjectSchema<{
491
519
  }> | undefined;
492
520
  }) | undefined;
493
521
  }) | undefined;
494
- emails: Omit<{}, never> & {
495
- theme?: "default-light" | "default-dark" | undefined;
522
+ emails: Omit<{
523
+ theme?: string | undefined;
524
+ themeList?: Record<string, {
525
+ displayName: string;
526
+ tsxSource: string;
527
+ }> | undefined;
528
+ }, never> & {
496
529
  server: {
497
530
  host?: string | undefined;
498
531
  port?: number | undefined;
@@ -568,7 +601,10 @@ declare const organizationConfigSchema: yup.ObjectSchema<{
568
601
  providers: undefined;
569
602
  };
570
603
  };
571
- emails: {};
604
+ emails: {
605
+ theme: undefined;
606
+ themeList: undefined;
607
+ };
572
608
  };
573
609
  auth: {
574
610
  sourceOfTruth: undefined;
@@ -612,7 +648,10 @@ declare const organizationConfigSchema: yup.ObjectSchema<{
612
648
  providers: undefined;
613
649
  };
614
650
  };
615
- emails: {};
651
+ emails: {
652
+ theme: undefined;
653
+ themeList: undefined;
654
+ };
616
655
  };
617
656
  emails: {
618
657
  sourceOfTruth: undefined;
@@ -656,7 +695,10 @@ declare const organizationConfigSchema: yup.ObjectSchema<{
656
695
  providers: undefined;
657
696
  };
658
697
  };
659
- emails: {};
698
+ emails: {
699
+ theme: undefined;
700
+ themeList: undefined;
701
+ };
660
702
  };
661
703
  }, "">;
662
704
  declare const projectConfigDefaults: {
@@ -718,7 +760,17 @@ declare const organizationConfigDefaults: {
718
760
  server: {
719
761
  isShared: true;
720
762
  };
721
- theme: "default-light";
763
+ theme: string;
764
+ themeList: {
765
+ "1df07ae6-abf3-4a40-83a5-a1a2cbe336ac": {
766
+ displayName: string;
767
+ tsxSource: string;
768
+ };
769
+ "a0172b5d-cff0-463b-83bb-85124697373a": {
770
+ displayName: string;
771
+ tsxSource: string;
772
+ };
773
+ };
722
774
  };
723
775
  };
724
776
  type DeepReplaceAllowFunctionsForObjects<T> = T extends object ? {
@@ -46,6 +46,7 @@ var schemaFields = __toESM(require("../schema-fields.js"));
46
46
  var import_schema_fields = require("../schema-fields.js");
47
47
  var import_oauth = require("../utils/oauth.js");
48
48
  var import_objects = require("../utils/objects.js");
49
+ var import_email_themes = require("../helpers/email-themes.js");
49
50
  var configLevels = ["project", "branch", "environment", "organization"];
50
51
  var permissionRegex = /^\$?[a-z0-9_:]+$/;
51
52
  var customPermissionRegex = /^[a-z0-9_:]+$/;
@@ -133,7 +134,10 @@ var branchConfigSchema = projectConfigSchema.omit(["sourceOfTruth"]).concat((0,
133
134
  apiKeys: branchApiKeysSchema,
134
135
  domains: branchDomain,
135
136
  auth: branchAuthSchema,
136
- emails: (0, import_schema_fields.yupObject)({})
137
+ emails: (0, import_schema_fields.yupObject)({
138
+ theme: schemaFields.emailThemeSchema.optional(),
139
+ themeList: schemaFields.emailThemeListSchema.optional()
140
+ })
137
141
  }));
138
142
  var environmentConfigSchema = branchConfigSchema.concat((0, import_schema_fields.yupObject)({
139
143
  auth: branchConfigSchema.getNested("auth").concat((0, import_schema_fields.yupObject)({
@@ -162,8 +166,7 @@ var environmentConfigSchema = branchConfigSchema.concat((0, import_schema_fields
162
166
  password: schemaFields.emailPasswordSchema.optional().nonEmpty(),
163
167
  senderName: schemaFields.emailSenderNameSchema.optional().nonEmpty(),
164
168
  senderEmail: schemaFields.emailSenderEmailSchema.optional().nonEmpty()
165
- }),
166
- theme: schemaFields.emailThemeSchema.optional()
169
+ })
167
170
  }).optional()),
168
171
  domains: branchConfigSchema.getNested("domains").concat((0, import_schema_fields.yupObject)({
169
172
  trustedDomains: (0, import_schema_fields.yupRecord)(
@@ -235,7 +238,8 @@ var organizationConfigDefaults = {
235
238
  server: {
236
239
  isShared: true
237
240
  },
238
- theme: "default-light"
241
+ theme: import_email_themes.DEFAULT_EMAIL_THEME_ID,
242
+ themeList: import_email_themes.DEFAULT_EMAIL_THEMES
239
243
  }
240
244
  };
241
245
  function applyDefaults(defaults, config) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/config/schema.ts"],"sourcesContent":["import * as yup from \"yup\";\nimport * as schemaFields from \"../schema-fields\";\nimport { yupBoolean, yupObject, yupRecord, yupString, yupUnion } from \"../schema-fields\";\nimport { allProviders } from \"../utils/oauth\";\nimport { DeepMerge, DeepPartial, get, has, isObjectLike, mapValues, set } from \"../utils/objects\";\nimport { Config, NormalizesTo } from \"./format\";\n\n// NOTE: The validation schemas in here are all schematic validators, not sanity-check validators.\n// For more info, see ./README.md\n\n\nexport const configLevels = ['project', 'branch', 'environment', 'organization'] as const;\nexport type ConfigLevel = typeof configLevels[number];\nconst permissionRegex = /^\\$?[a-z0-9_:]+$/;\nconst customPermissionRegex = /^[a-z0-9_:]+$/;\n\n/**\n * All fields that can be overridden at this level.\n */\nexport const projectConfigSchema = yupObject({\n sourceOfTruth: yupUnion(\n yupObject({\n type: yupString().oneOf(['hosted']).optional(),\n }).defined(),\n yupObject({\n type: yupString().oneOf(['neon']).optional(),\n connectionStrings: yupRecord(\n yupString().defined(),\n yupString().defined(),\n ).defined(),\n }).defined(),\n yupObject({\n type: yupString().oneOf(['postgres']).optional(),\n connectionString: yupString().defined()\n }).defined(),\n ).optional(),\n});\n\n// --- NEW RBAC Schema ---\nconst branchRbacDefaultPermissions = yupRecord(\n yupString().optional().matches(permissionRegex),\n yupBoolean().isTrue().optional(),\n).optional();\n\nconst branchRbacSchema = yupObject({\n permissions: yupRecord(\n yupString().optional().matches(customPermissionRegex),\n yupObject({\n description: yupString().optional(),\n scope: yupString().oneOf(['team', 'project']).optional(),\n containedPermissionIds: yupRecord(\n yupString().optional().matches(permissionRegex),\n yupBoolean().isTrue().optional()\n ).optional(),\n }).optional(),\n ).optional(),\n defaultPermissions: yupObject({\n teamCreator: branchRbacDefaultPermissions,\n teamMember: branchRbacDefaultPermissions,\n signUp: branchRbacDefaultPermissions,\n }).optional(),\n}).optional();\n// --- END NEW RBAC Schema ---\n\n// --- NEW API Keys Schema ---\nconst branchApiKeysSchema = yupObject({\n enabled: yupObject({\n team: yupBoolean().optional(),\n user: yupBoolean().optional(),\n }).optional(),\n}).optional();\n// --- END NEW API Keys Schema ---\n\n\nconst branchAuthSchema = yupObject({\n allowSignUp: yupBoolean().optional(),\n password: yupObject({\n allowSignIn: yupBoolean().optional(),\n }).optional(),\n otp: yupObject({\n allowSignIn: yupBoolean().optional(),\n }).optional(),\n passkey: yupObject({\n allowSignIn: yupBoolean().optional(),\n }).optional(),\n oauth: yupObject({\n accountMergeStrategy: yupString().oneOf(['link_method', 'raise_error', 'allow_duplicates']).optional(),\n providers: yupRecord(\n yupString().optional().matches(permissionRegex),\n yupObject({\n type: yupString().oneOf(allProviders).optional(),\n allowSignIn: yupBoolean().optional(),\n allowConnectedAccounts: yupBoolean().optional(),\n }).defined(),\n ).optional(),\n }).optional(),\n}).optional();\n\nconst branchDomain = yupObject({\n allowLocalhost: yupBoolean().optional(),\n}).optional();\n\nexport const branchConfigSchema = projectConfigSchema.omit(['sourceOfTruth']).concat(yupObject({\n rbac: branchRbacSchema,\n\n teams: yupObject({\n createPersonalTeamOnSignUp: yupBoolean().optional(),\n allowClientTeamCreation: yupBoolean().optional(),\n }).optional(),\n\n users: yupObject({\n allowClientUserDeletion: yupBoolean().optional(),\n }).optional(),\n\n apiKeys: branchApiKeysSchema,\n\n domains: branchDomain,\n\n auth: branchAuthSchema,\n\n emails: yupObject({}),\n}));\n\n\nexport const environmentConfigSchema = branchConfigSchema.concat(yupObject({\n auth: branchConfigSchema.getNested(\"auth\").concat(yupObject({\n oauth: branchConfigSchema.getNested(\"auth\").getNested(\"oauth\").concat(yupObject({\n providers: yupRecord(\n yupString().optional().matches(permissionRegex),\n yupObject({\n type: yupString().oneOf(allProviders).optional(),\n isShared: yupBoolean().optional(),\n clientId: schemaFields.oauthClientIdSchema.optional(),\n clientSecret: schemaFields.oauthClientSecretSchema.optional(),\n facebookConfigId: schemaFields.oauthFacebookConfigIdSchema.optional(),\n microsoftTenantId: schemaFields.oauthMicrosoftTenantIdSchema.optional(),\n allowSignIn: yupBoolean().optional(),\n allowConnectedAccounts: yupBoolean().optional(),\n }),\n ).optional(),\n }).optional()),\n })),\n\n emails: branchConfigSchema.getNested(\"emails\").concat(yupObject({\n server: yupObject({\n isShared: yupBoolean().optional(),\n host: schemaFields.emailHostSchema.optional().nonEmpty(),\n port: schemaFields.emailPortSchema.optional(),\n username: schemaFields.emailUsernameSchema.optional().nonEmpty(),\n password: schemaFields.emailPasswordSchema.optional().nonEmpty(),\n senderName: schemaFields.emailSenderNameSchema.optional().nonEmpty(),\n senderEmail: schemaFields.emailSenderEmailSchema.optional().nonEmpty(),\n }),\n theme: schemaFields.emailThemeSchema.optional(),\n }).optional()),\n\n domains: branchConfigSchema.getNested(\"domains\").concat(yupObject({\n trustedDomains: yupRecord(\n yupString().uuid().optional(),\n yupObject({\n baseUrl: schemaFields.urlSchema.optional(),\n handlerPath: schemaFields.handlerPathSchema.optional(),\n }),\n ).optional(),\n })),\n}));\n\nexport const organizationConfigSchema = environmentConfigSchema.concat(yupObject({}));\n\n\n// Defaults\n// these are objects that are merged together to form the rendered config (see ./README.md)\n// Wherever an object could be used as a value, a function can instead be used to generate the default values on a per-key basis\n// NOTE: These values are the defaults of the schema, NOT the defaults for newly created projects. The values here signify what `null` means for each property. If you want new projects by default to have a certain value set to true, you should update the corresponding function in the backend instead.\nexport const projectConfigDefaults = {\n sourceOfTruth: {\n type: 'hosted',\n },\n} satisfies DeepReplaceAllowFunctionsForObjects<ProjectConfigStrippedNormalizedOverride>;\n\nexport const branchConfigDefaults = {} satisfies DeepReplaceAllowFunctionsForObjects<BranchConfigStrippedNormalizedOverride>;\n\nexport const environmentConfigDefaults = {} satisfies DeepReplaceAllowFunctionsForObjects<EnvironmentConfigStrippedNormalizedOverride>;\n\nexport const organizationConfigDefaults = {\n rbac: {\n permissions: (key: string) => ({}),\n defaultPermissions: {\n teamCreator: {},\n teamMember: {},\n signUp: {},\n },\n },\n\n apiKeys: {\n enabled: {\n team: false,\n user: false,\n },\n },\n\n teams: {\n createPersonalTeamOnSignUp: false,\n allowClientTeamCreation: false,\n },\n\n users: {\n allowClientUserDeletion: false,\n },\n\n domains: {\n allowLocalhost: false,\n trustedDomains: (key: string) => ({\n handlerPath: '/handler',\n }),\n },\n\n auth: {\n allowSignUp: true,\n password: {\n allowSignIn: false,\n },\n otp: {\n allowSignIn: false,\n },\n passkey: {\n allowSignIn: false,\n },\n oauth: {\n accountMergeStrategy: 'link_method',\n providers: (key: string) => ({\n isShared: true,\n allowSignIn: false,\n allowConnectedAccounts: false,\n }),\n },\n },\n\n emails: {\n server: {\n isShared: true,\n },\n theme: 'default-light',\n },\n} satisfies DeepReplaceAllowFunctionsForObjects<OrganizationConfigStrippedNormalizedOverride>;\n\nexport type DeepReplaceAllowFunctionsForObjects<T> = T extends object ? { [K in keyof T]: DeepReplaceAllowFunctionsForObjects<T[K]> } | ((arg: keyof T) => DeepReplaceAllowFunctionsForObjects<T[keyof T]>) : T;\nexport type DeepReplaceFunctionsWithObjects<T> = T extends (arg: infer K extends string) => infer R ? DeepReplaceFunctionsWithObjects<Record<K, R>> : (T extends object ? { [K in keyof T]: DeepReplaceFunctionsWithObjects<T[K]> } : T);\nexport type ApplyDefaults<D extends object | ((key: string) => unknown), C extends object> = DeepMerge<DeepReplaceFunctionsWithObjects<D>, C>;\nexport function applyDefaults<D extends object | ((key: string) => unknown), C extends object>(defaults: D, config: C): ApplyDefaults<D, C> {\n const res: any = typeof defaults === 'function' ? {} : mapValues(defaults, v => typeof v === 'function' ? {} : (typeof v === 'object' ? applyDefaults(v as any, {}) : v));\n for (const [key, mergeValue] of Object.entries(config)) {\n const baseValue = typeof defaults === 'function' ? defaults(key) : (has(defaults, key as any) ? get(defaults, key as any) : undefined);\n if (baseValue !== undefined) {\n if (isObjectLike(baseValue) && isObjectLike(mergeValue)) {\n set(res, key, applyDefaults(baseValue, mergeValue));\n continue;\n }\n }\n set(res, key, mergeValue);\n }\n return res as any;\n}\nundefined?.test(\"applyDefaults\", ({ expect }) => {\n expect(applyDefaults({ a: 1 }, { a: 2 })).toEqual({ a: 2 });\n expect(applyDefaults({ a: { b: 1 } }, { a: { c: 2 } })).toEqual({ a: { b: 1, c: 2 } });\n expect(applyDefaults((key: string) => ({ b: key }), { a: {} })).toEqual({ a: { b: \"a\" } });\n expect(applyDefaults({ a: (key: string) => ({ b: key }) }, { a: { c: { d: 1 } } })).toEqual({ a: { c: { b: \"c\", d: 1 } } });\n expect(applyDefaults({ a: (key: string) => ({ b: key }) }, {})).toEqual({ a: {} });\n expect(applyDefaults({ a: { b: (key: string) => ({ b: key }) } }, {})).toEqual({ a: { b: {} } });\n});\n\n// Normalized overrides\nexport type ProjectConfigNormalizedOverride = yup.InferType<typeof projectConfigSchema>;\nexport type BranchConfigNormalizedOverride = yup.InferType<typeof branchConfigSchema>;\nexport type EnvironmentConfigNormalizedOverride = yup.InferType<typeof environmentConfigSchema>;\nexport type OrganizationConfigNormalizedOverride = yup.InferType<typeof organizationConfigSchema>;\n\n// Normalized overrides, but only the fields that will NOT be overridden by a future level anymore\nexport type ProjectConfigStrippedNormalizedOverride = Omit<ProjectConfigNormalizedOverride,\n | keyof BranchConfigNormalizedOverride\n | keyof EnvironmentConfigNormalizedOverride\n | keyof OrganizationConfigNormalizedOverride\n>;\nexport type BranchConfigStrippedNormalizedOverride = Omit<BranchConfigNormalizedOverride,\n | keyof EnvironmentConfigNormalizedOverride\n | keyof OrganizationConfigNormalizedOverride\n>;\nexport type EnvironmentConfigStrippedNormalizedOverride = Omit<EnvironmentConfigNormalizedOverride,\n | keyof OrganizationConfigNormalizedOverride\n>;\nexport type OrganizationConfigStrippedNormalizedOverride = OrganizationConfigNormalizedOverride;\n\n// Overrides\nexport type ProjectConfigOverride = NormalizesTo<ProjectConfigNormalizedOverride>;\nexport type BranchConfigOverride = NormalizesTo<BranchConfigNormalizedOverride>;\nexport type EnvironmentConfigOverride = NormalizesTo<EnvironmentConfigNormalizedOverride>;\nexport type OrganizationConfigOverride = NormalizesTo<OrganizationConfigNormalizedOverride>;\n\n// Override overrides (used to update the overrides)\nexport type ProjectConfigOverrideOverride = Config & DeepPartial<ProjectConfigOverride>;\nexport type BranchConfigOverrideOverride = Config & DeepPartial<BranchConfigOverride>;\nexport type EnvironmentConfigOverrideOverride = Config & DeepPartial<EnvironmentConfigOverride>;\nexport type OrganizationConfigOverrideOverride = Config & DeepPartial<OrganizationConfigOverride>;\n\n// Incomplete configs\nexport type ProjectIncompleteConfig = ApplyDefaults<typeof projectConfigDefaults, ProjectConfigNormalizedOverride>;\nexport type BranchIncompleteConfig = ApplyDefaults<typeof branchConfigDefaults, ProjectIncompleteConfig & BranchConfigNormalizedOverride>;\nexport type EnvironmentIncompleteConfig = ApplyDefaults<typeof environmentConfigDefaults, BranchIncompleteConfig & EnvironmentConfigNormalizedOverride>;\nexport type OrganizationIncompleteConfig = ApplyDefaults<typeof organizationConfigDefaults, EnvironmentIncompleteConfig & OrganizationConfigNormalizedOverride>;\n\n// Rendered configs\nexport type ProjectRenderedConfig = Omit<ProjectIncompleteConfig,\n | keyof BranchConfigNormalizedOverride\n | keyof EnvironmentConfigNormalizedOverride\n | keyof OrganizationConfigNormalizedOverride\n>;\nexport type BranchRenderedConfig = Omit<BranchIncompleteConfig,\n | keyof EnvironmentConfigNormalizedOverride\n | keyof OrganizationConfigNormalizedOverride\n>;\nexport type EnvironmentRenderedConfig = Omit<EnvironmentIncompleteConfig,\n | keyof OrganizationConfigNormalizedOverride\n>;\nexport type OrganizationRenderedConfig = OrganizationIncompleteConfig;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,mBAA8B;AAC9B,2BAAsE;AACtE,mBAA6B;AAC7B,qBAA+E;AAOxE,IAAM,eAAe,CAAC,WAAW,UAAU,eAAe,cAAc;AAE/E,IAAM,kBAAkB;AACxB,IAAM,wBAAwB;AAKvB,IAAM,0BAAsB,gCAAU;AAAA,EAC3C,mBAAe;AAAA,QACb,gCAAU;AAAA,MACR,UAAM,gCAAU,EAAE,MAAM,CAAC,QAAQ,CAAC,EAAE,SAAS;AAAA,IAC/C,CAAC,EAAE,QAAQ;AAAA,QACX,gCAAU;AAAA,MACR,UAAM,gCAAU,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,SAAS;AAAA,MAC3C,uBAAmB;AAAA,YACjB,gCAAU,EAAE,QAAQ;AAAA,YACpB,gCAAU,EAAE,QAAQ;AAAA,MACtB,EAAE,QAAQ;AAAA,IACZ,CAAC,EAAE,QAAQ;AAAA,QACX,gCAAU;AAAA,MACR,UAAM,gCAAU,EAAE,MAAM,CAAC,UAAU,CAAC,EAAE,SAAS;AAAA,MAC/C,sBAAkB,gCAAU,EAAE,QAAQ;AAAA,IACxC,CAAC,EAAE,QAAQ;AAAA,EACb,EAAE,SAAS;AACb,CAAC;AAGD,IAAM,mCAA+B;AAAA,MACnC,gCAAU,EAAE,SAAS,EAAE,QAAQ,eAAe;AAAA,MAC9C,iCAAW,EAAE,OAAO,EAAE,SAAS;AACjC,EAAE,SAAS;AAEX,IAAM,uBAAmB,gCAAU;AAAA,EACjC,iBAAa;AAAA,QACX,gCAAU,EAAE,SAAS,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Aa,SAAS,SAAK,6BAAa,UAAU,GAAG;AACvD,gCAAI,KAAK,KAAK,cAAc,WAAW,UAAU,CAAC;AAClD;AAAA,MACF;AAAA,IACF;AACA,4BAAI,KAAK,KAAK,UAAU;AAAA,EAC1B;AACA,SAAO;AACT;","names":[]}
1
+ {"version":3,"sources":["../../src/config/schema.ts"],"sourcesContent":["import * as yup from \"yup\";\nimport * as schemaFields from \"../schema-fields\";\nimport { yupBoolean, yupObject, yupRecord, yupString, yupUnion } from \"../schema-fields\";\nimport { allProviders } from \"../utils/oauth\";\nimport { DeepMerge, DeepPartial, get, has, isObjectLike, mapValues, set } from \"../utils/objects\";\nimport { Config, NormalizesTo } from \"./format\";\nimport { DEFAULT_EMAIL_THEME_ID, DEFAULT_EMAIL_THEMES } from \"../helpers/email-themes\";\n\n// NOTE: The validation schemas in here are all schematic validators, not sanity-check validators.\n// For more info, see ./README.md\n\n\nexport const configLevels = ['project', 'branch', 'environment', 'organization'] as const;\nexport type ConfigLevel = typeof configLevels[number];\nconst permissionRegex = /^\\$?[a-z0-9_:]+$/;\nconst customPermissionRegex = /^[a-z0-9_:]+$/;\n\n/**\n * All fields that can be overridden at this level.\n */\nexport const projectConfigSchema = yupObject({\n sourceOfTruth: yupUnion(\n yupObject({\n type: yupString().oneOf(['hosted']).optional(),\n }).defined(),\n yupObject({\n type: yupString().oneOf(['neon']).optional(),\n connectionStrings: yupRecord(\n yupString().defined(),\n yupString().defined(),\n ).defined(),\n }).defined(),\n yupObject({\n type: yupString().oneOf(['postgres']).optional(),\n connectionString: yupString().defined()\n }).defined(),\n ).optional(),\n});\n\n// --- NEW RBAC Schema ---\nconst branchRbacDefaultPermissions = yupRecord(\n yupString().optional().matches(permissionRegex),\n yupBoolean().isTrue().optional(),\n).optional();\n\nconst branchRbacSchema = yupObject({\n permissions: yupRecord(\n yupString().optional().matches(customPermissionRegex),\n yupObject({\n description: yupString().optional(),\n scope: yupString().oneOf(['team', 'project']).optional(),\n containedPermissionIds: yupRecord(\n yupString().optional().matches(permissionRegex),\n yupBoolean().isTrue().optional()\n ).optional(),\n }).optional(),\n ).optional(),\n defaultPermissions: yupObject({\n teamCreator: branchRbacDefaultPermissions,\n teamMember: branchRbacDefaultPermissions,\n signUp: branchRbacDefaultPermissions,\n }).optional(),\n}).optional();\n// --- END NEW RBAC Schema ---\n\n// --- NEW API Keys Schema ---\nconst branchApiKeysSchema = yupObject({\n enabled: yupObject({\n team: yupBoolean().optional(),\n user: yupBoolean().optional(),\n }).optional(),\n}).optional();\n// --- END NEW API Keys Schema ---\n\n\nconst branchAuthSchema = yupObject({\n allowSignUp: yupBoolean().optional(),\n password: yupObject({\n allowSignIn: yupBoolean().optional(),\n }).optional(),\n otp: yupObject({\n allowSignIn: yupBoolean().optional(),\n }).optional(),\n passkey: yupObject({\n allowSignIn: yupBoolean().optional(),\n }).optional(),\n oauth: yupObject({\n accountMergeStrategy: yupString().oneOf(['link_method', 'raise_error', 'allow_duplicates']).optional(),\n providers: yupRecord(\n yupString().optional().matches(permissionRegex),\n yupObject({\n type: yupString().oneOf(allProviders).optional(),\n allowSignIn: yupBoolean().optional(),\n allowConnectedAccounts: yupBoolean().optional(),\n }).defined(),\n ).optional(),\n }).optional(),\n}).optional();\n\nconst branchDomain = yupObject({\n allowLocalhost: yupBoolean().optional(),\n}).optional();\n\nexport const branchConfigSchema = projectConfigSchema.omit(['sourceOfTruth']).concat(yupObject({\n rbac: branchRbacSchema,\n\n teams: yupObject({\n createPersonalTeamOnSignUp: yupBoolean().optional(),\n allowClientTeamCreation: yupBoolean().optional(),\n }).optional(),\n\n users: yupObject({\n allowClientUserDeletion: yupBoolean().optional(),\n }).optional(),\n\n apiKeys: branchApiKeysSchema,\n\n domains: branchDomain,\n\n auth: branchAuthSchema,\n\n emails: yupObject({\n theme: schemaFields.emailThemeSchema.optional(),\n themeList: schemaFields.emailThemeListSchema.optional(),\n }),\n\n}));\n\n\nexport const environmentConfigSchema = branchConfigSchema.concat(yupObject({\n auth: branchConfigSchema.getNested(\"auth\").concat(yupObject({\n oauth: branchConfigSchema.getNested(\"auth\").getNested(\"oauth\").concat(yupObject({\n providers: yupRecord(\n yupString().optional().matches(permissionRegex),\n yupObject({\n type: yupString().oneOf(allProviders).optional(),\n isShared: yupBoolean().optional(),\n clientId: schemaFields.oauthClientIdSchema.optional(),\n clientSecret: schemaFields.oauthClientSecretSchema.optional(),\n facebookConfigId: schemaFields.oauthFacebookConfigIdSchema.optional(),\n microsoftTenantId: schemaFields.oauthMicrosoftTenantIdSchema.optional(),\n allowSignIn: yupBoolean().optional(),\n allowConnectedAccounts: yupBoolean().optional(),\n }),\n ).optional(),\n }).optional()),\n })),\n\n emails: branchConfigSchema.getNested(\"emails\").concat(yupObject({\n server: yupObject({\n isShared: yupBoolean().optional(),\n host: schemaFields.emailHostSchema.optional().nonEmpty(),\n port: schemaFields.emailPortSchema.optional(),\n username: schemaFields.emailUsernameSchema.optional().nonEmpty(),\n password: schemaFields.emailPasswordSchema.optional().nonEmpty(),\n senderName: schemaFields.emailSenderNameSchema.optional().nonEmpty(),\n senderEmail: schemaFields.emailSenderEmailSchema.optional().nonEmpty(),\n }),\n }).optional()),\n\n domains: branchConfigSchema.getNested(\"domains\").concat(yupObject({\n trustedDomains: yupRecord(\n yupString().uuid().optional(),\n yupObject({\n baseUrl: schemaFields.urlSchema.optional(),\n handlerPath: schemaFields.handlerPathSchema.optional(),\n }),\n ).optional(),\n })),\n}));\n\nexport const organizationConfigSchema = environmentConfigSchema.concat(yupObject({}));\n\n\n// Defaults\n// these are objects that are merged together to form the rendered config (see ./README.md)\n// Wherever an object could be used as a value, a function can instead be used to generate the default values on a per-key basis\n// NOTE: These values are the defaults of the schema, NOT the defaults for newly created projects. The values here signify what `null` means for each property. If you want new projects by default to have a certain value set to true, you should update the corresponding function in the backend instead.\nexport const projectConfigDefaults = {\n sourceOfTruth: {\n type: 'hosted',\n },\n} satisfies DeepReplaceAllowFunctionsForObjects<ProjectConfigStrippedNormalizedOverride>;\n\nexport const branchConfigDefaults = {} satisfies DeepReplaceAllowFunctionsForObjects<BranchConfigStrippedNormalizedOverride>;\n\nexport const environmentConfigDefaults = {} satisfies DeepReplaceAllowFunctionsForObjects<EnvironmentConfigStrippedNormalizedOverride>;\n\nexport const organizationConfigDefaults = {\n rbac: {\n permissions: (key: string) => ({}),\n defaultPermissions: {\n teamCreator: {},\n teamMember: {},\n signUp: {},\n },\n },\n\n apiKeys: {\n enabled: {\n team: false,\n user: false,\n },\n },\n\n teams: {\n createPersonalTeamOnSignUp: false,\n allowClientTeamCreation: false,\n },\n\n users: {\n allowClientUserDeletion: false,\n },\n\n domains: {\n allowLocalhost: false,\n trustedDomains: (key: string) => ({\n handlerPath: '/handler',\n }),\n },\n\n auth: {\n allowSignUp: true,\n password: {\n allowSignIn: false,\n },\n otp: {\n allowSignIn: false,\n },\n passkey: {\n allowSignIn: false,\n },\n oauth: {\n accountMergeStrategy: 'link_method',\n providers: (key: string) => ({\n isShared: true,\n allowSignIn: false,\n allowConnectedAccounts: false,\n }),\n },\n },\n\n emails: {\n server: {\n isShared: true,\n },\n theme: DEFAULT_EMAIL_THEME_ID,\n themeList: DEFAULT_EMAIL_THEMES,\n },\n} satisfies DeepReplaceAllowFunctionsForObjects<OrganizationConfigStrippedNormalizedOverride>;\n\nexport type DeepReplaceAllowFunctionsForObjects<T> = T extends object ? { [K in keyof T]: DeepReplaceAllowFunctionsForObjects<T[K]> } | ((arg: keyof T) => DeepReplaceAllowFunctionsForObjects<T[keyof T]>) : T;\nexport type DeepReplaceFunctionsWithObjects<T> = T extends (arg: infer K extends string) => infer R ? DeepReplaceFunctionsWithObjects<Record<K, R>> : (T extends object ? { [K in keyof T]: DeepReplaceFunctionsWithObjects<T[K]> } : T);\nexport type ApplyDefaults<D extends object | ((key: string) => unknown), C extends object> = DeepMerge<DeepReplaceFunctionsWithObjects<D>, C>;\nexport function applyDefaults<D extends object | ((key: string) => unknown), C extends object>(defaults: D, config: C): ApplyDefaults<D, C> {\n const res: any = typeof defaults === 'function' ? {} : mapValues(defaults, v => typeof v === 'function' ? {} : (typeof v === 'object' ? applyDefaults(v as any, {}) : v));\n for (const [key, mergeValue] of Object.entries(config)) {\n const baseValue = typeof defaults === 'function' ? defaults(key) : (has(defaults, key as any) ? get(defaults, key as any) : undefined);\n if (baseValue !== undefined) {\n if (isObjectLike(baseValue) && isObjectLike(mergeValue)) {\n set(res, key, applyDefaults(baseValue, mergeValue));\n continue;\n }\n }\n set(res, key, mergeValue);\n }\n return res as any;\n}\nundefined?.test(\"applyDefaults\", ({ expect }) => {\n expect(applyDefaults({ a: 1 }, { a: 2 })).toEqual({ a: 2 });\n expect(applyDefaults({ a: { b: 1 } }, { a: { c: 2 } })).toEqual({ a: { b: 1, c: 2 } });\n expect(applyDefaults((key: string) => ({ b: key }), { a: {} })).toEqual({ a: { b: \"a\" } });\n expect(applyDefaults({ a: (key: string) => ({ b: key }) }, { a: { c: { d: 1 } } })).toEqual({ a: { c: { b: \"c\", d: 1 } } });\n expect(applyDefaults({ a: (key: string) => ({ b: key }) }, {})).toEqual({ a: {} });\n expect(applyDefaults({ a: { b: (key: string) => ({ b: key }) } }, {})).toEqual({ a: { b: {} } });\n});\n\n// Normalized overrides\nexport type ProjectConfigNormalizedOverride = yup.InferType<typeof projectConfigSchema>;\nexport type BranchConfigNormalizedOverride = yup.InferType<typeof branchConfigSchema>;\nexport type EnvironmentConfigNormalizedOverride = yup.InferType<typeof environmentConfigSchema>;\nexport type OrganizationConfigNormalizedOverride = yup.InferType<typeof organizationConfigSchema>;\n\n// Normalized overrides, but only the fields that will NOT be overridden by a future level anymore\nexport type ProjectConfigStrippedNormalizedOverride = Omit<ProjectConfigNormalizedOverride,\n | keyof BranchConfigNormalizedOverride\n | keyof EnvironmentConfigNormalizedOverride\n | keyof OrganizationConfigNormalizedOverride\n>;\nexport type BranchConfigStrippedNormalizedOverride = Omit<BranchConfigNormalizedOverride,\n | keyof EnvironmentConfigNormalizedOverride\n | keyof OrganizationConfigNormalizedOverride\n>;\nexport type EnvironmentConfigStrippedNormalizedOverride = Omit<EnvironmentConfigNormalizedOverride,\n | keyof OrganizationConfigNormalizedOverride\n>;\nexport type OrganizationConfigStrippedNormalizedOverride = OrganizationConfigNormalizedOverride;\n\n// Overrides\nexport type ProjectConfigOverride = NormalizesTo<ProjectConfigNormalizedOverride>;\nexport type BranchConfigOverride = NormalizesTo<BranchConfigNormalizedOverride>;\nexport type EnvironmentConfigOverride = NormalizesTo<EnvironmentConfigNormalizedOverride>;\nexport type OrganizationConfigOverride = NormalizesTo<OrganizationConfigNormalizedOverride>;\n\n// Override overrides (used to update the overrides)\nexport type ProjectConfigOverrideOverride = Config & DeepPartial<ProjectConfigOverride>;\nexport type BranchConfigOverrideOverride = Config & DeepPartial<BranchConfigOverride>;\nexport type EnvironmentConfigOverrideOverride = Config & DeepPartial<EnvironmentConfigOverride>;\nexport type OrganizationConfigOverrideOverride = Config & DeepPartial<OrganizationConfigOverride>;\n\n// Incomplete configs\nexport type ProjectIncompleteConfig = ApplyDefaults<typeof projectConfigDefaults, ProjectConfigNormalizedOverride>;\nexport type BranchIncompleteConfig = ApplyDefaults<typeof branchConfigDefaults, ProjectIncompleteConfig & BranchConfigNormalizedOverride>;\nexport type EnvironmentIncompleteConfig = ApplyDefaults<typeof environmentConfigDefaults, BranchIncompleteConfig & EnvironmentConfigNormalizedOverride>;\nexport type OrganizationIncompleteConfig = ApplyDefaults<typeof organizationConfigDefaults, EnvironmentIncompleteConfig & OrganizationConfigNormalizedOverride>;\n\n// Rendered configs\nexport type ProjectRenderedConfig = Omit<ProjectIncompleteConfig,\n | keyof BranchConfigNormalizedOverride\n | keyof EnvironmentConfigNormalizedOverride\n | keyof OrganizationConfigNormalizedOverride\n>;\nexport type BranchRenderedConfig = Omit<BranchIncompleteConfig,\n | keyof EnvironmentConfigNormalizedOverride\n | keyof OrganizationConfigNormalizedOverride\n>;\nexport type EnvironmentRenderedConfig = Omit<EnvironmentIncompleteConfig,\n | keyof Or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a,UAAU,GAAG;AACvD,gCAAI,KAAK,KAAK,cAAc,WAAW,UAAU,CAAC;AAClD;AAAA,MACF;AAAA,IACF;AACA,4BAAI,KAAK,KAAK,UAAU;AAAA,EAC1B;AACA,SAAO;AACT;","names":[]}
@@ -3,6 +3,7 @@ import * as schemaFields from "../schema-fields.js";
3
3
  import { yupBoolean, yupObject, yupRecord, yupString, yupUnion } from "../schema-fields.js";
4
4
  import { allProviders } from "../utils/oauth.js";
5
5
  import { get, has, isObjectLike, mapValues, set } from "../utils/objects.js";
6
+ import { DEFAULT_EMAIL_THEME_ID, DEFAULT_EMAIL_THEMES } from "../helpers/email-themes.js";
6
7
  var configLevels = ["project", "branch", "environment", "organization"];
7
8
  var permissionRegex = /^\$?[a-z0-9_:]+$/;
8
9
  var customPermissionRegex = /^[a-z0-9_:]+$/;
@@ -90,7 +91,10 @@ var branchConfigSchema = projectConfigSchema.omit(["sourceOfTruth"]).concat(yupO
90
91
  apiKeys: branchApiKeysSchema,
91
92
  domains: branchDomain,
92
93
  auth: branchAuthSchema,
93
- emails: yupObject({})
94
+ emails: yupObject({
95
+ theme: schemaFields.emailThemeSchema.optional(),
96
+ themeList: schemaFields.emailThemeListSchema.optional()
97
+ })
94
98
  }));
95
99
  var environmentConfigSchema = branchConfigSchema.concat(yupObject({
96
100
  auth: branchConfigSchema.getNested("auth").concat(yupObject({
@@ -119,8 +123,7 @@ var environmentConfigSchema = branchConfigSchema.concat(yupObject({
119
123
  password: schemaFields.emailPasswordSchema.optional().nonEmpty(),
120
124
  senderName: schemaFields.emailSenderNameSchema.optional().nonEmpty(),
121
125
  senderEmail: schemaFields.emailSenderEmailSchema.optional().nonEmpty()
122
- }),
123
- theme: schemaFields.emailThemeSchema.optional()
126
+ })
124
127
  }).optional()),
125
128
  domains: branchConfigSchema.getNested("domains").concat(yupObject({
126
129
  trustedDomains: yupRecord(
@@ -192,7 +195,8 @@ var organizationConfigDefaults = {
192
195
  server: {
193
196
  isShared: true
194
197
  },
195
- theme: "default-light"
198
+ theme: DEFAULT_EMAIL_THEME_ID,
199
+ themeList: DEFAULT_EMAIL_THEMES
196
200
  }
197
201
  };
198
202
  function applyDefaults(defaults, config) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/config/schema.ts"],"sourcesContent":["import * as yup from \"yup\";\nimport * as schemaFields from \"../schema-fields\";\nimport { yupBoolean, yupObject, yupRecord, yupString, yupUnion } from \"../schema-fields\";\nimport { allProviders } from \"../utils/oauth\";\nimport { DeepMerge, DeepPartial, get, has, isObjectLike, mapValues, set } from \"../utils/objects\";\nimport { Config, NormalizesTo } from \"./format\";\n\n// NOTE: The validation schemas in here are all schematic validators, not sanity-check validators.\n// For more info, see ./README.md\n\n\nexport const configLevels = ['project', 'branch', 'environment', 'organization'] as const;\nexport type ConfigLevel = typeof configLevels[number];\nconst permissionRegex = /^\\$?[a-z0-9_:]+$/;\nconst customPermissionRegex = /^[a-z0-9_:]+$/;\n\n/**\n * All fields that can be overridden at this level.\n */\nexport const projectConfigSchema = yupObject({\n sourceOfTruth: yupUnion(\n yupObject({\n type: yupString().oneOf(['hosted']).optional(),\n }).defined(),\n yupObject({\n type: yupString().oneOf(['neon']).optional(),\n connectionStrings: yupRecord(\n yupString().defined(),\n yupString().defined(),\n ).defined(),\n }).defined(),\n yupObject({\n type: yupString().oneOf(['postgres']).optional(),\n connectionString: yupString().defined()\n }).defined(),\n ).optional(),\n});\n\n// --- NEW RBAC Schema ---\nconst branchRbacDefaultPermissions = yupRecord(\n yupString().optional().matches(permissionRegex),\n yupBoolean().isTrue().optional(),\n).optional();\n\nconst branchRbacSchema = yupObject({\n permissions: yupRecord(\n yupString().optional().matches(customPermissionRegex),\n yupObject({\n description: yupString().optional(),\n scope: yupString().oneOf(['team', 'project']).optional(),\n containedPermissionIds: yupRecord(\n yupString().optional().matches(permissionRegex),\n yupBoolean().isTrue().optional()\n ).optional(),\n }).optional(),\n ).optional(),\n defaultPermissions: yupObject({\n teamCreator: branchRbacDefaultPermissions,\n teamMember: branchRbacDefaultPermissions,\n signUp: branchRbacDefaultPermissions,\n }).optional(),\n}).optional();\n// --- END NEW RBAC Schema ---\n\n// --- NEW API Keys Schema ---\nconst branchApiKeysSchema = yupObject({\n enabled: yupObject({\n team: yupBoolean().optional(),\n user: yupBoolean().optional(),\n }).optional(),\n}).optional();\n// --- END NEW API Keys Schema ---\n\n\nconst branchAuthSchema = yupObject({\n allowSignUp: yupBoolean().optional(),\n password: yupObject({\n allowSignIn: yupBoolean().optional(),\n }).optional(),\n otp: yupObject({\n allowSignIn: yupBoolean().optional(),\n }).optional(),\n passkey: yupObject({\n allowSignIn: yupBoolean().optional(),\n }).optional(),\n oauth: yupObject({\n accountMergeStrategy: yupString().oneOf(['link_method', 'raise_error', 'allow_duplicates']).optional(),\n providers: yupRecord(\n yupString().optional().matches(permissionRegex),\n yupObject({\n type: yupString().oneOf(allProviders).optional(),\n allowSignIn: yupBoolean().optional(),\n allowConnectedAccounts: yupBoolean().optional(),\n }).defined(),\n ).optional(),\n }).optional(),\n}).optional();\n\nconst branchDomain = yupObject({\n allowLocalhost: yupBoolean().optional(),\n}).optional();\n\nexport const branchConfigSchema = projectConfigSchema.omit(['sourceOfTruth']).concat(yupObject({\n rbac: branchRbacSchema,\n\n teams: yupObject({\n createPersonalTeamOnSignUp: yupBoolean().optional(),\n allowClientTeamCreation: yupBoolean().optional(),\n }).optional(),\n\n users: yupObject({\n allowClientUserDeletion: yupBoolean().optional(),\n }).optional(),\n\n apiKeys: branchApiKeysSchema,\n\n domains: branchDomain,\n\n auth: branchAuthSchema,\n\n emails: yupObject({}),\n}));\n\n\nexport const environmentConfigSchema = branchConfigSchema.concat(yupObject({\n auth: branchConfigSchema.getNested(\"auth\").concat(yupObject({\n oauth: branchConfigSchema.getNested(\"auth\").getNested(\"oauth\").concat(yupObject({\n providers: yupRecord(\n yupString().optional().matches(permissionRegex),\n yupObject({\n type: yupString().oneOf(allProviders).optional(),\n isShared: yupBoolean().optional(),\n clientId: schemaFields.oauthClientIdSchema.optional(),\n clientSecret: schemaFields.oauthClientSecretSchema.optional(),\n facebookConfigId: schemaFields.oauthFacebookConfigIdSchema.optional(),\n microsoftTenantId: schemaFields.oauthMicrosoftTenantIdSchema.optional(),\n allowSignIn: yupBoolean().optional(),\n allowConnectedAccounts: yupBoolean().optional(),\n }),\n ).optional(),\n }).optional()),\n })),\n\n emails: branchConfigSchema.getNested(\"emails\").concat(yupObject({\n server: yupObject({\n isShared: yupBoolean().optional(),\n host: schemaFields.emailHostSchema.optional().nonEmpty(),\n port: schemaFields.emailPortSchema.optional(),\n username: schemaFields.emailUsernameSchema.optional().nonEmpty(),\n password: schemaFields.emailPasswordSchema.optional().nonEmpty(),\n senderName: schemaFields.emailSenderNameSchema.optional().nonEmpty(),\n senderEmail: schemaFields.emailSenderEmailSchema.optional().nonEmpty(),\n }),\n theme: schemaFields.emailThemeSchema.optional(),\n }).optional()),\n\n domains: branchConfigSchema.getNested(\"domains\").concat(yupObject({\n trustedDomains: yupRecord(\n yupString().uuid().optional(),\n yupObject({\n baseUrl: schemaFields.urlSchema.optional(),\n handlerPath: schemaFields.handlerPathSchema.optional(),\n }),\n ).optional(),\n })),\n}));\n\nexport const organizationConfigSchema = environmentConfigSchema.concat(yupObject({}));\n\n\n// Defaults\n// these are objects that are merged together to form the rendered config (see ./README.md)\n// Wherever an object could be used as a value, a function can instead be used to generate the default values on a per-key basis\n// NOTE: These values are the defaults of the schema, NOT the defaults for newly created projects. The values here signify what `null` means for each property. If you want new projects by default to have a certain value set to true, you should update the corresponding function in the backend instead.\nexport const projectConfigDefaults = {\n sourceOfTruth: {\n type: 'hosted',\n },\n} satisfies DeepReplaceAllowFunctionsForObjects<ProjectConfigStrippedNormalizedOverride>;\n\nexport const branchConfigDefaults = {} satisfies DeepReplaceAllowFunctionsForObjects<BranchConfigStrippedNormalizedOverride>;\n\nexport const environmentConfigDefaults = {} satisfies DeepReplaceAllowFunctionsForObjects<EnvironmentConfigStrippedNormalizedOverride>;\n\nexport const organizationConfigDefaults = {\n rbac: {\n permissions: (key: string) => ({}),\n defaultPermissions: {\n teamCreator: {},\n teamMember: {},\n signUp: {},\n },\n },\n\n apiKeys: {\n enabled: {\n team: false,\n user: false,\n },\n },\n\n teams: {\n createPersonalTeamOnSignUp: false,\n allowClientTeamCreation: false,\n },\n\n users: {\n allowClientUserDeletion: false,\n },\n\n domains: {\n allowLocalhost: false,\n trustedDomains: (key: string) => ({\n handlerPath: '/handler',\n }),\n },\n\n auth: {\n allowSignUp: true,\n password: {\n allowSignIn: false,\n },\n otp: {\n allowSignIn: false,\n },\n passkey: {\n allowSignIn: false,\n },\n oauth: {\n accountMergeStrategy: 'link_method',\n providers: (key: string) => ({\n isShared: true,\n allowSignIn: false,\n allowConnectedAccounts: false,\n }),\n },\n },\n\n emails: {\n server: {\n isShared: true,\n },\n theme: 'default-light',\n },\n} satisfies DeepReplaceAllowFunctionsForObjects<OrganizationConfigStrippedNormalizedOverride>;\n\nexport type DeepReplaceAllowFunctionsForObjects<T> = T extends object ? { [K in keyof T]: DeepReplaceAllowFunctionsForObjects<T[K]> } | ((arg: keyof T) => DeepReplaceAllowFunctionsForObjects<T[keyof T]>) : T;\nexport type DeepReplaceFunctionsWithObjects<T> = T extends (arg: infer K extends string) => infer R ? DeepReplaceFunctionsWithObjects<Record<K, R>> : (T extends object ? { [K in keyof T]: DeepReplaceFunctionsWithObjects<T[K]> } : T);\nexport type ApplyDefaults<D extends object | ((key: string) => unknown), C extends object> = DeepMerge<DeepReplaceFunctionsWithObjects<D>, C>;\nexport function applyDefaults<D extends object | ((key: string) => unknown), C extends object>(defaults: D, config: C): ApplyDefaults<D, C> {\n const res: any = typeof defaults === 'function' ? {} : mapValues(defaults, v => typeof v === 'function' ? {} : (typeof v === 'object' ? applyDefaults(v as any, {}) : v));\n for (const [key, mergeValue] of Object.entries(config)) {\n const baseValue = typeof defaults === 'function' ? defaults(key) : (has(defaults, key as any) ? get(defaults, key as any) : undefined);\n if (baseValue !== undefined) {\n if (isObjectLike(baseValue) && isObjectLike(mergeValue)) {\n set(res, key, applyDefaults(baseValue, mergeValue));\n continue;\n }\n }\n set(res, key, mergeValue);\n }\n return res as any;\n}\nundefined?.test(\"applyDefaults\", ({ expect }) => {\n expect(applyDefaults({ a: 1 }, { a: 2 })).toEqual({ a: 2 });\n expect(applyDefaults({ a: { b: 1 } }, { a: { c: 2 } })).toEqual({ a: { b: 1, c: 2 } });\n expect(applyDefaults((key: string) => ({ b: key }), { a: {} })).toEqual({ a: { b: \"a\" } });\n expect(applyDefaults({ a: (key: string) => ({ b: key }) }, { a: { c: { d: 1 } } })).toEqual({ a: { c: { b: \"c\", d: 1 } } });\n expect(applyDefaults({ a: (key: string) => ({ b: key }) }, {})).toEqual({ a: {} });\n expect(applyDefaults({ a: { b: (key: string) => ({ b: key }) } }, {})).toEqual({ a: { b: {} } });\n});\n\n// Normalized overrides\nexport type ProjectConfigNormalizedOverride = yup.InferType<typeof projectConfigSchema>;\nexport type BranchConfigNormalizedOverride = yup.InferType<typeof branchConfigSchema>;\nexport type EnvironmentConfigNormalizedOverride = yup.InferType<typeof environmentConfigSchema>;\nexport type OrganizationConfigNormalizedOverride = yup.InferType<typeof organizationConfigSchema>;\n\n// Normalized overrides, but only the fields that will NOT be overridden by a future level anymore\nexport type ProjectConfigStrippedNormalizedOverride = Omit<ProjectConfigNormalizedOverride,\n | keyof BranchConfigNormalizedOverride\n | keyof EnvironmentConfigNormalizedOverride\n | keyof OrganizationConfigNormalizedOverride\n>;\nexport type BranchConfigStrippedNormalizedOverride = Omit<BranchConfigNormalizedOverride,\n | keyof EnvironmentConfigNormalizedOverride\n | keyof OrganizationConfigNormalizedOverride\n>;\nexport type EnvironmentConfigStrippedNormalizedOverride = Omit<EnvironmentConfigNormalizedOverride,\n | keyof OrganizationConfigNormalizedOverride\n>;\nexport type OrganizationConfigStrippedNormalizedOverride = OrganizationConfigNormalizedOverride;\n\n// Overrides\nexport type ProjectConfigOverride = NormalizesTo<ProjectConfigNormalizedOverride>;\nexport type BranchConfigOverride = NormalizesTo<BranchConfigNormalizedOverride>;\nexport type EnvironmentConfigOverride = NormalizesTo<EnvironmentConfigNormalizedOverride>;\nexport type OrganizationConfigOverride = NormalizesTo<OrganizationConfigNormalizedOverride>;\n\n// Override overrides (used to update the overrides)\nexport type ProjectConfigOverrideOverride = Config & DeepPartial<ProjectConfigOverride>;\nexport type BranchConfigOverrideOverride = Config & DeepPartial<BranchConfigOverride>;\nexport type EnvironmentConfigOverrideOverride = Config & DeepPartial<EnvironmentConfigOverride>;\nexport type OrganizationConfigOverrideOverride = Config & DeepPartial<OrganizationConfigOverride>;\n\n// Incomplete configs\nexport type ProjectIncompleteConfig = ApplyDefaults<typeof projectConfigDefaults, ProjectConfigNormalizedOverride>;\nexport type BranchIncompleteConfig = ApplyDefaults<typeof branchConfigDefaults, ProjectIncompleteConfig & BranchConfigNormalizedOverride>;\nexport type EnvironmentIncompleteConfig = ApplyDefaults<typeof environmentConfigDefaults, BranchIncompleteConfig & EnvironmentConfigNormalizedOverride>;\nexport type OrganizationIncompleteConfig = ApplyDefaults<typeof organizationConfigDefaults, EnvironmentIncompleteConfig & OrganizationConfigNormalizedOverride>;\n\n// Rendered configs\nexport type ProjectRenderedConfig = Omit<ProjectIncompleteConfig,\n | keyof BranchConfigNormalizedOverride\n | keyof EnvironmentConfigNormalizedOverride\n | keyof OrganizationConfigNormalizedOverride\n>;\nexport type BranchRenderedConfig = Omit<BranchIncompleteConfig,\n | keyof EnvironmentConfigNormalizedOverride\n | keyof OrganizationConfigNormalizedOverride\n>;\nexport type EnvironmentRenderedConfig = Omit<EnvironmentIncompleteConfig,\n | keyof OrganizationConfigNormalizedOverride\n>;\nexport type OrganizationRenderedConfig = OrganizationIncompleteConfig;\n"],"mappings":";AACA,YAAY,kBAAkB;AAC9B,SAAS,YAAY,WAAW,WAAW,WAAW,gBAAgB;AACtE,SAAS,oBAAoB;AAC7B,SAAiC,KAAK,KAAK,cAAc,WAAW,W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AAAA,IACJ,aAAa;AAAA,IACb,UAAU;AAAA,MACR,aAAa;AAAA,IACf;AAAA,IACA,KAAK;AAAA,MACH,aAAa;AAAA,IACf;AAAA,IACA,SAAS;AAAA,MACP,aAAa;AAAA,IACf;AAAA,IACA,OAAO;AAAA,MACL,sBAAsB;AAAA,MACtB,WAAW,CAAC,SAAiB;AAAA,QAC3B,UAAU;AAAA,QACV,aAAa;AAAA,QACb,wBAAwB;AAAA,MAC1B;AAAA,IACF;AAAA,EACF;AAAA,EAEA,QAAQ;AAAA,IACN,QAAQ;AAAA,MACN,UAAU;AAAA,IACZ;AAAA,IACA,OAAO;AAAA,EACT;AACF;AAKO,SAAS,cAA+E,UAAa,QAAgC;AAC1I,QAAM,MAAW,OAAO,aAAa,aAAa,CAAC,IAAI,UAAU,UAAU,OAAK,OAAO,MAAM,aAAa,CAAC,IAAK,OAAO,MAAM,WAAW,cAAc,GAAU,CAAC,CAAC,IAAI,CAAE;AACxK,aAAW,CAAC,KAAK,UAAU,KAAK,OAAO,QAAQ,MAAM,GAAG;AACtD,UAAM,YAAY,OAAO,aAAa,aAAa,SAAS,GAAG,IAAK,IAAI,UAAU,GAAU,IAAI,IAAI,UAAU,GAAU,IAAI;AAC5H,QAAI,cAAc,QAAW;AAC3B,UAAI,aAAa,SAAS,KAAK,aAAa,UAAU,GAAG;AACvD,YAAI,KAAK,KAAK,cAAc,WAAW,UAAU,CAAC;AAClD;AAAA,MACF;AAAA,IACF;AACA,QAAI,KAAK,KAAK,UAAU;AAAA,EAC1B;AACA,SAAO;AACT;","names":[]}
1
+ {"version":3,"sources":["../../../src/config/schema.ts"],"sourcesContent":["import * as yup from \"yup\";\nimport * as schemaFields from \"../schema-fields\";\nimport { yupBoolean, yupObject, yupRecord, yupString, yupUnion } from \"../schema-fields\";\nimport { allProviders } from \"../utils/oauth\";\nimport { DeepMerge, DeepPartial, get, has, isObjectLike, mapValues, set } from \"../utils/objects\";\nimport { Config, NormalizesTo } from \"./format\";\nimport { DEFAULT_EMAIL_THEME_ID, DEFAULT_EMAIL_THEMES } from \"../helpers/email-themes\";\n\n// NOTE: The validation schemas in here are all schematic validators, not sanity-check validators.\n// For more info, see ./README.md\n\n\nexport const configLevels = ['project', 'branch', 'environment', 'organization'] as const;\nexport type ConfigLevel = typeof configLevels[number];\nconst permissionRegex = /^\\$?[a-z0-9_:]+$/;\nconst customPermissionRegex = /^[a-z0-9_:]+$/;\n\n/**\n * All fields that can be overridden at this level.\n */\nexport const projectConfigSchema = yupObject({\n sourceOfTruth: yupUnion(\n yupObject({\n type: yupString().oneOf(['hosted']).optional(),\n }).defined(),\n yupObject({\n type: yupString().oneOf(['neon']).optional(),\n connectionStrings: yupRecord(\n yupString().defined(),\n yupString().defined(),\n ).defined(),\n }).defined(),\n yupObject({\n type: yupString().oneOf(['postgres']).optional(),\n connectionString: yupString().defined()\n }).defined(),\n ).optional(),\n});\n\n// --- NEW RBAC Schema ---\nconst branchRbacDefaultPermissions = yupRecord(\n yupString().optional().matches(permissionRegex),\n yupBoolean().isTrue().optional(),\n).optional();\n\nconst branchRbacSchema = yupObject({\n permissions: yupRecord(\n yupString().optional().matches(customPermissionRegex),\n yupObject({\n description: yupString().optional(),\n scope: yupString().oneOf(['team', 'project']).optional(),\n containedPermissionIds: yupRecord(\n yupString().optional().matches(permissionRegex),\n yupBoolean().isTrue().optional()\n ).optional(),\n }).optional(),\n ).optional(),\n defaultPermissions: yupObject({\n teamCreator: branchRbacDefaultPermissions,\n teamMember: branchRbacDefaultPermissions,\n signUp: branchRbacDefaultPermissions,\n }).optional(),\n}).optional();\n// --- END NEW RBAC Schema ---\n\n// --- NEW API Keys Schema ---\nconst branchApiKeysSchema = yupObject({\n enabled: yupObject({\n team: yupBoolean().optional(),\n user: yupBoolean().optional(),\n }).optional(),\n}).optional();\n// --- END NEW API Keys Schema ---\n\n\nconst branchAuthSchema = yupObject({\n allowSignUp: yupBoolean().optional(),\n password: yupObject({\n allowSignIn: yupBoolean().optional(),\n }).optional(),\n otp: yupObject({\n allowSignIn: yupBoolean().optional(),\n }).optional(),\n passkey: yupObject({\n allowSignIn: yupBoolean().optional(),\n }).optional(),\n oauth: yupObject({\n accountMergeStrategy: yupString().oneOf(['link_method', 'raise_error', 'allow_duplicates']).optional(),\n providers: yupRecord(\n yupString().optional().matches(permissionRegex),\n yupObject({\n type: yupString().oneOf(allProviders).optional(),\n allowSignIn: yupBoolean().optional(),\n allowConnectedAccounts: yupBoolean().optional(),\n }).defined(),\n ).optional(),\n }).optional(),\n}).optional();\n\nconst branchDomain = yupObject({\n allowLocalhost: yupBoolean().optional(),\n}).optional();\n\nexport const branchConfigSchema = projectConfigSchema.omit(['sourceOfTruth']).concat(yupObject({\n rbac: branchRbacSchema,\n\n teams: yupObject({\n createPersonalTeamOnSignUp: yupBoolean().optional(),\n allowClientTeamCreation: yupBoolean().optional(),\n }).optional(),\n\n users: yupObject({\n allowClientUserDeletion: yupBoolean().optional(),\n }).optional(),\n\n apiKeys: branchApiKeysSchema,\n\n domains: branchDomain,\n\n auth: branchAuthSchema,\n\n emails: yupObject({\n theme: schemaFields.emailThemeSchema.optional(),\n themeList: schemaFields.emailThemeListSchema.optional(),\n }),\n\n}));\n\n\nexport const environmentConfigSchema = branchConfigSchema.concat(yupObject({\n auth: branchConfigSchema.getNested(\"auth\").concat(yupObject({\n oauth: branchConfigSchema.getNested(\"auth\").getNested(\"oauth\").concat(yupObject({\n providers: yupRecord(\n yupString().optional().matches(permissionRegex),\n yupObject({\n type: yupString().oneOf(allProviders).optional(),\n isShared: yupBoolean().optional(),\n clientId: schemaFields.oauthClientIdSchema.optional(),\n clientSecret: schemaFields.oauthClientSecretSchema.optional(),\n facebookConfigId: schemaFields.oauthFacebookConfigIdSchema.optional(),\n microsoftTenantId: schemaFields.oauthMicrosoftTenantIdSchema.optional(),\n allowSignIn: yupBoolean().optional(),\n allowConnectedAccounts: yupBoolean().optional(),\n }),\n ).optional(),\n }).optional()),\n })),\n\n emails: branchConfigSchema.getNested(\"emails\").concat(yupObject({\n server: yupObject({\n isShared: yupBoolean().optional(),\n host: schemaFields.emailHostSchema.optional().nonEmpty(),\n port: schemaFields.emailPortSchema.optional(),\n username: schemaFields.emailUsernameSchema.optional().nonEmpty(),\n password: schemaFields.emailPasswordSchema.optional().nonEmpty(),\n senderName: schemaFields.emailSenderNameSchema.optional().nonEmpty(),\n senderEmail: schemaFields.emailSenderEmailSchema.optional().nonEmpty(),\n }),\n }).optional()),\n\n domains: branchConfigSchema.getNested(\"domains\").concat(yupObject({\n trustedDomains: yupRecord(\n yupString().uuid().optional(),\n yupObject({\n baseUrl: schemaFields.urlSchema.optional(),\n handlerPath: schemaFields.handlerPathSchema.optional(),\n }),\n ).optional(),\n })),\n}));\n\nexport const organizationConfigSchema = environmentConfigSchema.concat(yupObject({}));\n\n\n// Defaults\n// these are objects that are merged together to form the rendered config (see ./README.md)\n// Wherever an object could be used as a value, a function can instead be used to generate the default values on a per-key basis\n// NOTE: These values are the defaults of the schema, NOT the defaults for newly created projects. The values here signify what `null` means for each property. If you want new projects by default to have a certain value set to true, you should update the corresponding function in the backend instead.\nexport const projectConfigDefaults = {\n sourceOfTruth: {\n type: 'hosted',\n },\n} satisfies DeepReplaceAllowFunctionsForObjects<ProjectConfigStrippedNormalizedOverride>;\n\nexport const branchConfigDefaults = {} satisfies DeepReplaceAllowFunctionsForObjects<BranchConfigStrippedNormalizedOverride>;\n\nexport const environmentConfigDefaults = {} satisfies DeepReplaceAllowFunctionsForObjects<EnvironmentConfigStrippedNormalizedOverride>;\n\nexport const organizationConfigDefaults = {\n rbac: {\n permissions: (key: string) => ({}),\n defaultPermissions: {\n teamCreator: {},\n teamMember: {},\n signUp: {},\n },\n },\n\n apiKeys: {\n enabled: {\n team: false,\n user: false,\n },\n },\n\n teams: {\n createPersonalTeamOnSignUp: false,\n allowClientTeamCreation: false,\n },\n\n users: {\n allowClientUserDeletion: false,\n },\n\n domains: {\n allowLocalhost: false,\n trustedDomains: (key: string) => ({\n handlerPath: '/handler',\n }),\n },\n\n auth: {\n allowSignUp: true,\n password: {\n allowSignIn: false,\n },\n otp: {\n allowSignIn: false,\n },\n passkey: {\n allowSignIn: false,\n },\n oauth: {\n accountMergeStrategy: 'link_method',\n providers: (key: string) => ({\n isShared: true,\n allowSignIn: false,\n allowConnectedAccounts: false,\n }),\n },\n },\n\n emails: {\n server: {\n isShared: true,\n },\n theme: DEFAULT_EMAIL_THEME_ID,\n themeList: DEFAULT_EMAIL_THEMES,\n },\n} satisfies DeepReplaceAllowFunctionsForObjects<OrganizationConfigStrippedNormalizedOverride>;\n\nexport type DeepReplaceAllowFunctionsForObjects<T> = T extends object ? { [K in keyof T]: DeepReplaceAllowFunctionsForObjects<T[K]> } | ((arg: keyof T) => DeepReplaceAllowFunctionsForObjects<T[keyof T]>) : T;\nexport type DeepReplaceFunctionsWithObjects<T> = T extends (arg: infer K extends string) => infer R ? DeepReplaceFunctionsWithObjects<Record<K, R>> : (T extends object ? { [K in keyof T]: DeepReplaceFunctionsWithObjects<T[K]> } : T);\nexport type ApplyDefaults<D extends object | ((key: string) => unknown), C extends object> = DeepMerge<DeepReplaceFunctionsWithObjects<D>, C>;\nexport function applyDefaults<D extends object | ((key: string) => unknown), C extends object>(defaults: D, config: C): ApplyDefaults<D, C> {\n const res: any = typeof defaults === 'function' ? {} : mapValues(defaults, v => typeof v === 'function' ? {} : (typeof v === 'object' ? applyDefaults(v as any, {}) : v));\n for (const [key, mergeValue] of Object.entries(config)) {\n const baseValue = typeof defaults === 'function' ? defaults(key) : (has(defaults, key as any) ? get(defaults, key as any) : undefined);\n if (baseValue !== undefined) {\n if (isObjectLike(baseValue) && isObjectLike(mergeValue)) {\n set(res, key, applyDefaults(baseValue, mergeValue));\n continue;\n }\n }\n set(res, key, mergeValue);\n }\n return res as any;\n}\nundefined?.test(\"applyDefaults\", ({ expect }) => {\n expect(applyDefaults({ a: 1 }, { a: 2 })).toEqual({ a: 2 });\n expect(applyDefaults({ a: { b: 1 } }, { a: { c: 2 } })).toEqual({ a: { b: 1, c: 2 } });\n expect(applyDefaults((key: string) => ({ b: key }), { a: {} })).toEqual({ a: { b: \"a\" } });\n expect(applyDefaults({ a: (key: string) => ({ b: key }) }, { a: { c: { d: 1 } } })).toEqual({ a: { c: { b: \"c\", d: 1 } } });\n expect(applyDefaults({ a: (key: string) => ({ b: key }) }, {})).toEqual({ a: {} });\n expect(applyDefaults({ a: { b: (key: string) => ({ b: key }) } }, {})).toEqual({ a: { b: {} } });\n});\n\n// Normalized overrides\nexport type ProjectConfigNormalizedOverride = yup.InferType<typeof projectConfigSchema>;\nexport type BranchConfigNormalizedOverride = yup.InferType<typeof branchConfigSchema>;\nexport type EnvironmentConfigNormalizedOverride = yup.InferType<typeof environmentConfigSchema>;\nexport type OrganizationConfigNormalizedOverride = yup.InferType<typeof organizationConfigSchema>;\n\n// Normalized overrides, but only the fields that will NOT be overridden by a future level anymore\nexport type ProjectConfigStrippedNormalizedOverride = Omit<ProjectConfigNormalizedOverride,\n | keyof BranchConfigNormalizedOverride\n | keyof EnvironmentConfigNormalizedOverride\n | keyof OrganizationConfigNormalizedOverride\n>;\nexport type BranchConfigStrippedNormalizedOverride = Omit<BranchConfigNormalizedOverride,\n | keyof EnvironmentConfigNormalizedOverride\n | keyof OrganizationConfigNormalizedOverride\n>;\nexport type EnvironmentConfigStrippedNormalizedOverride = Omit<EnvironmentConfigNormalizedOverride,\n | keyof OrganizationConfigNormalizedOverride\n>;\nexport type OrganizationConfigStrippedNormalizedOverride = OrganizationConfigNormalizedOverride;\n\n// Overrides\nexport type ProjectConfigOverride = NormalizesTo<ProjectConfigNormalizedOverride>;\nexport type BranchConfigOverride = NormalizesTo<BranchConfigNormalizedOverride>;\nexport type EnvironmentConfigOverride = NormalizesTo<EnvironmentConfigNormalizedOverride>;\nexport type OrganizationConfigOverride = NormalizesTo<OrganizationConfigNormalizedOverride>;\n\n// Override overrides (used to update the overrides)\nexport type ProjectConfigOverrideOverride = Config & DeepPartial<ProjectConfigOverride>;\nexport type BranchConfigOverrideOverride = Config & DeepPartial<BranchConfigOverride>;\nexport type EnvironmentConfigOverrideOverride = Config & DeepPartial<EnvironmentConfigOverride>;\nexport type OrganizationConfigOverrideOverride = Config & DeepPartial<OrganizationConfigOverride>;\n\n// Incomplete configs\nexport type ProjectIncompleteConfig = ApplyDefaults<typeof projectConfigDefaults, ProjectConfigNormalizedOverride>;\nexport type BranchIncompleteConfig = ApplyDefaults<typeof branchConfigDefaults, ProjectIncompleteConfig & BranchConfigNormalizedOverride>;\nexport type EnvironmentIncompleteConfig = ApplyDefaults<typeof environmentConfigDefaults, BranchIncompleteConfig & EnvironmentConfigNormalizedOverride>;\nexport type OrganizationIncompleteConfig = ApplyDefaults<typeof organizationConfigDefaults, EnvironmentIncompleteConfig & OrganizationConfigNormalizedOverride>;\n\n// Rendered configs\nexport type ProjectRenderedConfig = Omit<ProjectIncompleteConfig,\n | keyof BranchConfigNormalizedOverride\n | keyof EnvironmentConfigNormalizedOverride\n | keyof OrganizationConfigNormalizedOverride\n>;\nexport type BranchRenderedConfig = Omit<BranchIncompleteConfig,\n | keyof EnvironmentConfigNormalizedOverride\n | keyof OrganizationConfigNormalizedOverride\n>;\nexport type EnvironmentRenderedConfig = Omit<EnvironmentIncompleteConfig,\n | keyof OrganizationConfigNormalizedOverride\n>;\nexport type OrganizationRenderedConfig = OrganizationIncompleteConfig;\n"],"mappings":";AACA,YAAY,kBAAkB;AAC9B,SAAS,YAAY,WAAW,WAAW,WAAW,gBAAgB;AACtE,SAAS,oBAAoB;AAC7B,SAAiC,KAAK,KAAK,cAAc,WAAW,WAAW;AAE/E,SAAS,wBAAwB,4BAA4B;AAMtD,IAAM,eAAe,CAAC,WAAW,UAAU,eAAe,cAAc;AAE/E,IAAM,kBAAkB;AACxB,IAAM,wBAAwB;AAKvB,IAAM,sBAAsB,UAAU;AAAA,EAC3C,eAAe;AAAA,IACb,UAAU;AAAA,MACR,MAAM,UAAU,EAAE,MAAM,CAAC,QAAQ,CA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AAA,MACL,sBAAsB;AAAA,MACtB,WAAW,CAAC,SAAiB;AAAA,QAC3B,UAAU;AAAA,QACV,aAAa;AAAA,QACb,wBAAwB;AAAA,MAC1B;AAAA,IACF;AAAA,EACF;AAAA,EAEA,QAAQ;AAAA,IACN,QAAQ;AAAA,MACN,UAAU;AAAA,IACZ;AAAA,IACA,OAAO;AAAA,IACP,WAAW;AAAA,EACb;AACF;AAKO,SAAS,cAA+E,UAAa,QAAgC;AAC1I,QAAM,MAAW,OAAO,aAAa,aAAa,CAAC,IAAI,UAAU,UAAU,OAAK,OAAO,MAAM,aAAa,CAAC,IAAK,OAAO,MAAM,WAAW,cAAc,GAAU,CAAC,CAAC,IAAI,CAAE;AACxK,aAAW,CAAC,KAAK,UAAU,KAAK,OAAO,QAAQ,MAAM,GAAG;AACtD,UAAM,YAAY,OAAO,aAAa,aAAa,SAAS,GAAG,IAAK,IAAI,UAAU,GAAU,IAAI,IAAI,UAAU,GAAU,IAAI;AAC5H,QAAI,cAAc,QAAW;AAC3B,UAAI,aAAa,SAAS,KAAK,aAAa,UAAU,GAAG;AACvD,YAAI,KAAK,KAAK,cAAc,WAAW,UAAU,CAAC;AAClD;AAAA,MACF;AAAA,IACF;AACA,QAAI,KAAK,KAAK,UAAU;AAAA,EAC1B;AACA,SAAO;AACT;","names":[]}
@@ -0,0 +1,45 @@
1
+ // src/helpers/email-themes.ts
2
+ var LightEmailTheme = `import { Html, Tailwind, Body } from '@react-email/components';
3
+ function EmailTheme({ children }: { children: React.ReactNode }) {
4
+ return (
5
+ <Html>
6
+ <Tailwind>
7
+ <Body>
8
+ <div className="bg-white text-slate-800 p-4 rounded-lg max-w-[600px] mx-auto leading-relaxed">
9
+ {children}
10
+ </div>
11
+ </Body>
12
+ </Tailwind>
13
+ </Html>
14
+ );
15
+ }`;
16
+ var DarkEmailTheme = `import { Html, Tailwind, Body } from '@react-email/components';
17
+ function EmailTheme({ children }: { children: React.ReactNode }) {
18
+ return (
19
+ <Html>
20
+ <Tailwind>
21
+ <Body>
22
+ <div className="bg-slate-900 text-slate-100 p-4 rounded-lg max-w-[600px] mx-auto leading-relaxed">
23
+ {children}
24
+ </div>
25
+ </Body>
26
+ </Tailwind>
27
+ </Html>
28
+ );
29
+ }`;
30
+ var DEFAULT_EMAIL_THEME_ID = "1df07ae6-abf3-4a40-83a5-a1a2cbe336ac";
31
+ var DEFAULT_EMAIL_THEMES = {
32
+ [DEFAULT_EMAIL_THEME_ID]: {
33
+ displayName: "default-light",
34
+ tsxSource: LightEmailTheme
35
+ },
36
+ "a0172b5d-cff0-463b-83bb-85124697373a": {
37
+ displayName: "default-dark",
38
+ tsxSource: DarkEmailTheme
39
+ }
40
+ };
41
+ export {
42
+ DEFAULT_EMAIL_THEMES,
43
+ DEFAULT_EMAIL_THEME_ID
44
+ };
45
+ //# sourceMappingURL=email-themes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/helpers/email-themes.ts"],"sourcesContent":["const LightEmailTheme = `import { Html, Tailwind, Body } from '@react-email/components';\nfunction EmailTheme({ children }: { children: React.ReactNode }) {\n return (\n <Html>\n <Tailwind>\n <Body>\n <div className=\"bg-white text-slate-800 p-4 rounded-lg max-w-[600px] mx-auto leading-relaxed\">\n {children}\n </div>\n </Body>\n </Tailwind>\n </Html>\n );\n}`;\n\n\nconst DarkEmailTheme = `import { Html, Tailwind, Body } from '@react-email/components';\nfunction EmailTheme({ children }: { children: React.ReactNode }) {\n return (\n <Html>\n <Tailwind>\n <Body>\n <div className=\"bg-slate-900 text-slate-100 p-4 rounded-lg max-w-[600px] mx-auto leading-relaxed\">\n {children}\n </div>\n </Body>\n </Tailwind>\n </Html>\n );\n}`;\n\nexport const DEFAULT_EMAIL_THEME_ID = \"1df07ae6-abf3-4a40-83a5-a1a2cbe336ac\";\n\nexport const DEFAULT_EMAIL_THEMES = {\n [DEFAULT_EMAIL_THEME_ID]: {\n displayName: 'default-light',\n tsxSource: LightEmailTheme,\n },\n \"a0172b5d-cff0-463b-83bb-85124697373a\": {\n displayName: 'default-dark',\n tsxSource: DarkEmailTheme,\n },\n};\n\n"],"mappings":";AAAA,IAAM,kBAAkB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAgBxB,IAAM,iBAAiB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAehB,IAAM,yBAAyB;AAE/B,IAAM,uBAAuB;AAAA,EAClC,CAAC,sBAAsB,GAAG;AAAA,IACxB,aAAa;AAAA,IACb,WAAW;AAAA,EACb;AAAA,EACA,wCAAwC;AAAA,IACtC,aAAa;AAAA,IACb,WAAW;AAAA,EACb;AACF;","names":[]}