@stackframe/stack-shared 2.8.10 → 2.8.11

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @stackframe/stack-shared
2
2
 
3
+ ## 2.8.11
4
+
5
+ ### Patch Changes
6
+
7
+ - Various changes
8
+
3
9
  ## 2.8.10
4
10
 
5
11
  ### Patch Changes
@@ -1,7 +1,7 @@
1
1
  import * as yup from 'yup';
2
- import { DeepMerge } from '../utils/objects.cjs';
2
+ import { DeepMerge, DeepPartial } from '../utils/objects.cjs';
3
3
  import { PrettifyType } from '../utils/types.cjs';
4
- import { NormalizesTo } from './format.cjs';
4
+ import { NormalizesTo, Config } from './format.cjs';
5
5
 
6
6
  declare const configLevels: readonly ["project", "branch", "environment", "organization"];
7
7
  type ConfigLevel = typeof configLevels[number];
@@ -13,7 +13,7 @@ declare const branchConfigSchema: yup.ObjectSchema<{} & {
13
13
  rbac: {
14
14
  permissions?: Record<string, {
15
15
  description?: string | undefined;
16
- scope?: "project" | "team" | undefined;
16
+ scope?: "team" | "project" | undefined;
17
17
  containedPermissionIds?: Record<string, true | undefined> | undefined;
18
18
  } | undefined> | undefined;
19
19
  defaultPermissions?: {
@@ -106,7 +106,7 @@ declare const environmentConfigSchema: yup.ObjectSchema<{
106
106
  rbac: {
107
107
  permissions?: Record<string, {
108
108
  description?: string | undefined;
109
- scope?: "project" | "team" | undefined;
109
+ scope?: "team" | "project" | undefined;
110
110
  containedPermissionIds?: Record<string, true | undefined> | undefined;
111
111
  } | undefined> | undefined;
112
112
  defaultPermissions?: {
@@ -403,7 +403,7 @@ declare const organizationConfigSchema: yup.ObjectSchema<{
403
403
  rbac: {
404
404
  permissions?: Record<string, {
405
405
  description?: string | undefined;
406
- scope?: "project" | "team" | undefined;
406
+ scope?: "team" | "project" | undefined;
407
407
  containedPermissionIds?: Record<string, true | undefined> | undefined;
408
408
  } | undefined> | undefined;
409
409
  defaultPermissions?: {
@@ -681,6 +681,7 @@ declare const organizationConfigDefaults: {
681
681
  oauth: {
682
682
  accountMergeStrategy: "link_method";
683
683
  providers: (key: string) => {
684
+ isShared: true;
684
685
  allowSignIn: false;
685
686
  allowConnectedAccounts: false;
686
687
  };
@@ -712,6 +713,10 @@ type ProjectConfigOverride = NormalizesTo<ProjectConfigNormalizedOverride>;
712
713
  type BranchConfigOverride = NormalizesTo<BranchConfigNormalizedOverride>;
713
714
  type EnvironmentConfigOverride = NormalizesTo<EnvironmentConfigNormalizedOverride>;
714
715
  type OrganizationConfigOverride = NormalizesTo<OrganizationConfigNormalizedOverride>;
716
+ type ProjectConfigOverrideOverride = Config & DeepPartial<ProjectConfigOverride>;
717
+ type BranchConfigOverrideOverride = Config & DeepPartial<BranchConfigOverride>;
718
+ type EnvironmentConfigOverrideOverride = Config & DeepPartial<EnvironmentConfigOverride>;
719
+ type OrganizationConfigOverrideOverride = Config & DeepPartial<OrganizationConfigOverride>;
715
720
  type ProjectIncompleteConfig = ProjectConfigNormalizedOverride;
716
721
  type BranchIncompleteConfig = ProjectIncompleteConfig & BranchConfigNormalizedOverride;
717
722
  type EnvironmentIncompleteConfig = BranchIncompleteConfig & EnvironmentConfigNormalizedOverride;
@@ -721,4 +726,4 @@ type BranchRenderedConfig = PrettifyType<ProjectRenderedConfig & ApplyDefaults<t
721
726
  type EnvironmentRenderedConfig = PrettifyType<BranchRenderedConfig & ApplyDefaults<typeof environmentConfigDefaults, EnvironmentConfigStrippedNormalizedOverride>>;
722
727
  type OrganizationRenderedConfig = PrettifyType<EnvironmentRenderedConfig & ApplyDefaults<typeof organizationConfigDefaults, OrganizationConfigStrippedNormalizedOverride>>;
723
728
 
724
- export { type ApplyDefaults, type BranchConfigNormalizedOverride, type BranchConfigOverride, type BranchConfigStrippedNormalizedOverride, type BranchIncompleteConfig, type BranchRenderedConfig, type ConfigLevel, type DeepReplaceAllowFunctionsForObjects, type DeepReplaceFunctionsWithObjects, type EnvironmentConfigNormalizedOverride, type EnvironmentConfigOverride, type EnvironmentConfigStrippedNormalizedOverride, type EnvironmentIncompleteConfig, type EnvironmentRenderedConfig, type OrganizationConfigNormalizedOverride, type OrganizationConfigOverride, type OrganizationConfigStrippedNormalizedOverride, type OrganizationIncompleteConfig, type OrganizationRenderedConfig, type ProjectConfigNormalizedOverride, type ProjectConfigOverride, type ProjectConfigStrippedNormalizedOverride, type ProjectIncompleteConfig, type ProjectRenderedConfig, applyDefaults, branchConfigDefaults, branchConfigSchema, configLevels, environmentConfigDefaults, environmentConfigSchema, organizationConfigDefaults, organizationConfigSchema, projectConfigDefaults, projectConfigSchema };
729
+ export { type ApplyDefaults, type BranchConfigNormalizedOverride, type BranchConfigOverride, type BranchConfigOverrideOverride, type BranchConfigStrippedNormalizedOverride, type BranchIncompleteConfig, type BranchRenderedConfig, type ConfigLevel, type DeepReplaceAllowFunctionsForObjects, type DeepReplaceFunctionsWithObjects, type EnvironmentConfigNormalizedOverride, type EnvironmentConfigOverride, type EnvironmentConfigOverrideOverride, type EnvironmentConfigStrippedNormalizedOverride, type EnvironmentIncompleteConfig, type EnvironmentRenderedConfig, type OrganizationConfigNormalizedOverride, type OrganizationConfigOverride, type OrganizationConfigOverrideOverride, type OrganizationConfigStrippedNormalizedOverride, type OrganizationIncompleteConfig, type OrganizationRenderedConfig, type ProjectConfigNormalizedOverride, type ProjectConfigOverride, type ProjectConfigOverrideOverride, type ProjectConfigStrippedNormalizedOverride, type ProjectIncompleteConfig, type ProjectRenderedConfig, applyDefaults, branchConfigDefaults, branchConfigSchema, configLevels, environmentConfigDefaults, environmentConfigSchema, organizationConfigDefaults, organizationConfigSchema, projectConfigDefaults, projectConfigSchema };
@@ -1,7 +1,7 @@
1
1
  import * as yup from 'yup';
2
- import { DeepMerge } from '../utils/objects.js';
2
+ import { DeepMerge, DeepPartial } from '../utils/objects.js';
3
3
  import { PrettifyType } from '../utils/types.js';
4
- import { NormalizesTo } from './format.js';
4
+ import { NormalizesTo, Config } from './format.js';
5
5
 
6
6
  declare const configLevels: readonly ["project", "branch", "environment", "organization"];
7
7
  type ConfigLevel = typeof configLevels[number];
@@ -13,7 +13,7 @@ declare const branchConfigSchema: yup.ObjectSchema<{} & {
13
13
  rbac: {
14
14
  permissions?: Record<string, {
15
15
  description?: string | undefined;
16
- scope?: "project" | "team" | undefined;
16
+ scope?: "team" | "project" | undefined;
17
17
  containedPermissionIds?: Record<string, true | undefined> | undefined;
18
18
  } | undefined> | undefined;
19
19
  defaultPermissions?: {
@@ -106,7 +106,7 @@ declare const environmentConfigSchema: yup.ObjectSchema<{
106
106
  rbac: {
107
107
  permissions?: Record<string, {
108
108
  description?: string | undefined;
109
- scope?: "project" | "team" | undefined;
109
+ scope?: "team" | "project" | undefined;
110
110
  containedPermissionIds?: Record<string, true | undefined> | undefined;
111
111
  } | undefined> | undefined;
112
112
  defaultPermissions?: {
@@ -403,7 +403,7 @@ declare const organizationConfigSchema: yup.ObjectSchema<{
403
403
  rbac: {
404
404
  permissions?: Record<string, {
405
405
  description?: string | undefined;
406
- scope?: "project" | "team" | undefined;
406
+ scope?: "team" | "project" | undefined;
407
407
  containedPermissionIds?: Record<string, true | undefined> | undefined;
408
408
  } | undefined> | undefined;
409
409
  defaultPermissions?: {
@@ -681,6 +681,7 @@ declare const organizationConfigDefaults: {
681
681
  oauth: {
682
682
  accountMergeStrategy: "link_method";
683
683
  providers: (key: string) => {
684
+ isShared: true;
684
685
  allowSignIn: false;
685
686
  allowConnectedAccounts: false;
686
687
  };
@@ -712,6 +713,10 @@ type ProjectConfigOverride = NormalizesTo<ProjectConfigNormalizedOverride>;
712
713
  type BranchConfigOverride = NormalizesTo<BranchConfigNormalizedOverride>;
713
714
  type EnvironmentConfigOverride = NormalizesTo<EnvironmentConfigNormalizedOverride>;
714
715
  type OrganizationConfigOverride = NormalizesTo<OrganizationConfigNormalizedOverride>;
716
+ type ProjectConfigOverrideOverride = Config & DeepPartial<ProjectConfigOverride>;
717
+ type BranchConfigOverrideOverride = Config & DeepPartial<BranchConfigOverride>;
718
+ type EnvironmentConfigOverrideOverride = Config & DeepPartial<EnvironmentConfigOverride>;
719
+ type OrganizationConfigOverrideOverride = Config & DeepPartial<OrganizationConfigOverride>;
715
720
  type ProjectIncompleteConfig = ProjectConfigNormalizedOverride;
716
721
  type BranchIncompleteConfig = ProjectIncompleteConfig & BranchConfigNormalizedOverride;
717
722
  type EnvironmentIncompleteConfig = BranchIncompleteConfig & EnvironmentConfigNormalizedOverride;
@@ -721,4 +726,4 @@ type BranchRenderedConfig = PrettifyType<ProjectRenderedConfig & ApplyDefaults<t
721
726
  type EnvironmentRenderedConfig = PrettifyType<BranchRenderedConfig & ApplyDefaults<typeof environmentConfigDefaults, EnvironmentConfigStrippedNormalizedOverride>>;
722
727
  type OrganizationRenderedConfig = PrettifyType<EnvironmentRenderedConfig & ApplyDefaults<typeof organizationConfigDefaults, OrganizationConfigStrippedNormalizedOverride>>;
723
728
 
724
- export { type ApplyDefaults, type BranchConfigNormalizedOverride, type BranchConfigOverride, type BranchConfigStrippedNormalizedOverride, type BranchIncompleteConfig, type BranchRenderedConfig, type ConfigLevel, type DeepReplaceAllowFunctionsForObjects, type DeepReplaceFunctionsWithObjects, type EnvironmentConfigNormalizedOverride, type EnvironmentConfigOverride, type EnvironmentConfigStrippedNormalizedOverride, type EnvironmentIncompleteConfig, type EnvironmentRenderedConfig, type OrganizationConfigNormalizedOverride, type OrganizationConfigOverride, type OrganizationConfigStrippedNormalizedOverride, type OrganizationIncompleteConfig, type OrganizationRenderedConfig, type ProjectConfigNormalizedOverride, type ProjectConfigOverride, type ProjectConfigStrippedNormalizedOverride, type ProjectIncompleteConfig, type ProjectRenderedConfig, applyDefaults, branchConfigDefaults, branchConfigSchema, configLevels, environmentConfigDefaults, environmentConfigSchema, organizationConfigDefaults, organizationConfigSchema, projectConfigDefaults, projectConfigSchema };
729
+ export { type ApplyDefaults, type BranchConfigNormalizedOverride, type BranchConfigOverride, type BranchConfigOverrideOverride, type BranchConfigStrippedNormalizedOverride, type BranchIncompleteConfig, type BranchRenderedConfig, type ConfigLevel, type DeepReplaceAllowFunctionsForObjects, type DeepReplaceFunctionsWithObjects, type EnvironmentConfigNormalizedOverride, type EnvironmentConfigOverride, type EnvironmentConfigOverrideOverride, type EnvironmentConfigStrippedNormalizedOverride, type EnvironmentIncompleteConfig, type EnvironmentRenderedConfig, type OrganizationConfigNormalizedOverride, type OrganizationConfigOverride, type OrganizationConfigOverrideOverride, type OrganizationConfigStrippedNormalizedOverride, type OrganizationIncompleteConfig, type OrganizationRenderedConfig, type ProjectConfigNormalizedOverride, type ProjectConfigOverride, type ProjectConfigOverrideOverride, type ProjectConfigStrippedNormalizedOverride, type ProjectIncompleteConfig, type ProjectRenderedConfig, applyDefaults, branchConfigDefaults, branchConfigSchema, configLevels, environmentConfigDefaults, environmentConfigSchema, organizationConfigDefaults, organizationConfigSchema, projectConfigDefaults, projectConfigSchema };
@@ -48,6 +48,7 @@ var import_oauth = require("../utils/oauth");
48
48
  var import_objects = require("../utils/objects");
49
49
  var configLevels = ["project", "branch", "environment", "organization"];
50
50
  var permissionRegex = /^\$?[a-z0-9_:]+$/;
51
+ var customPermissionRegex = /^[a-z0-9_:]+$/;
51
52
  var projectConfigSchema = (0, import_schema_fields.yupObject)({});
52
53
  var branchRbacDefaultPermissions = (0, import_schema_fields.yupRecord)(
53
54
  (0, import_schema_fields.yupString)().optional().matches(permissionRegex),
@@ -55,7 +56,7 @@ var branchRbacDefaultPermissions = (0, import_schema_fields.yupRecord)(
55
56
  ).optional();
56
57
  var branchRbacSchema = (0, import_schema_fields.yupObject)({
57
58
  permissions: (0, import_schema_fields.yupRecord)(
58
- (0, import_schema_fields.yupString)().optional().matches(permissionRegex),
59
+ (0, import_schema_fields.yupString)().optional().matches(customPermissionRegex),
59
60
  (0, import_schema_fields.yupObject)({
60
61
  description: (0, import_schema_fields.yupString)().optional(),
61
62
  scope: (0, import_schema_fields.yupString)().oneOf(["team", "project"]).optional(),
@@ -202,6 +203,7 @@ var organizationConfigDefaults = {
202
203
  oauth: {
203
204
  accountMergeStrategy: "link_method",
204
205
  providers: (key) => ({
206
+ isShared: true,
205
207
  allowSignIn: false,
206
208
  allowConnectedAccounts: false
207
209
  })
@@ -214,7 +216,7 @@ var organizationConfigDefaults = {
214
216
  }
215
217
  };
216
218
  function applyDefaults(defaults, config) {
217
- const res = { ...typeof defaults === "function" ? {} : defaults };
219
+ const res = typeof defaults === "function" ? {} : (0, import_objects.mapValues)(defaults, (v) => typeof v === "function" ? {} : typeof v === "object" ? applyDefaults(v, {}) : v);
218
220
  for (const [key, mergeValue] of Object.entries(config)) {
219
221
  const baseValue = typeof defaults === "function" ? defaults(key) : (0, import_objects.has)(defaults, key) ? (0, import_objects.get)(defaults, key) : void 0;
220
222
  if (baseValue !== void 0) {
@@ -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 } from \"../schema-fields\";\nimport { allProviders } from \"../utils/oauth\";\nimport { DeepMerge, get, has, isObjectLike, set } from \"../utils/objects\";\nimport { PrettifyType } from \"../utils/types\";\nimport { 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_:]+$/;\n\n/**\n * All fields that can be overridden at this level.\n */\nexport const projectConfigSchema = yupObject({});\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(permissionRegex),\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.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 }).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\nexport const projectConfigDefaults = {} 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 allowSignIn: false,\n allowConnectedAccounts: false,\n }),\n },\n },\n\n emails: {\n server: {\n isShared: true,\n },\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' ? {} : defaults };\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});\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, without the properties that may be overridden still\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// Incomplete configs\nexport type ProjectIncompleteConfig = ProjectConfigNormalizedOverride;\nexport type BranchIncompleteConfig = ProjectIncompleteConfig & BranchConfigNormalizedOverride;\nexport type EnvironmentIncompleteConfig = BranchIncompleteConfig & EnvironmentConfigNormalizedOverride;\nexport type OrganizationIncompleteConfig = EnvironmentIncompleteConfig & OrganizationConfigNormalizedOverride;\n\n// Rendered configs\nexport type ProjectRenderedConfig = PrettifyType<ApplyDefaults<typeof projectConfigDefaults, ProjectConfigStrippedNormalizedOverride>>;\nexport type BranchRenderedConfig = PrettifyType<ProjectRenderedConfig & ApplyDefaults<typeof branchConfigDefaults, BranchConfigStrippedNormalizedOverride>>;\nexport type EnvironmentRenderedConfig = PrettifyType<BranchRenderedConfig & ApplyDefaults<typeof environmentConfigDefaults, EnvironmentConfigStrippedNormalizedOverride>>;\nexport type OrganizationRenderedConfig = PrettifyType<EnvironmentRenderedConfig & ApplyDefaults<typeof organizationConfigDefaults, OrganizationConfigStrippedNormalizedOverride>>;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,mBAA8B;AAC9B,2BAA4D;AAC5D,mBAA6B;AAC7B,qBAAuD;AAQhD,IAAM,eAAe,CAAC,WAAW,UAAU,eAAe,cAAc;AAE/E,IAAM,kBAAkB;AAKjB,IAAM,0BAAsB,gCAAU,CAAC,CAAC;AAG/C,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,EAAE,QAAQ,eAAe;AAAA,QAC9C,gCAAU;AAAA,MACR,iBAAa,gCAAU,EAAE,SAAS;AAAA,MAClC,WAAO,gCAAU,EAAE,MAAM,CAAC,QAAQ,SAAS,CAAC,EAAE,SAAS;AAAA,MACvD,4BAAwB;AAAA,YACtB,g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EAC3B;AAAA,EAEA,SAAS;AAAA,IACP,gBAAgB;AAAA,IAChB,gBAAgB,CAAC,SAAiB;AAAA,MAChC,aAAa;AAAA,IACf;AAAA,EACF;AAAA,EAEA,MAAM;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,aAAa;AAAA,QACb,wBAAwB;AAAA,MAC1B;AAAA,IACF;AAAA,EACF;AAAA,EAEA,QAAQ;AAAA,IACN,QAAQ;AAAA,MACN,UAAU;AAAA,IACZ;AAAA,EACF;AACF;AAKO,SAAS,cAA+E,UAAa,QAAgC;AAC1I,QAAM,MAAW,EAAE,GAAG,OAAO,aAAa,aAAa,CAAC,IAAI,SAAS;AACrE,aAAW,CAAC,KAAK,UAAU,KAAK,OAAO,QAAQ,MAAM,GAAG;AACtD,UAAM,YAAY,OAAO,aAAa,aAAa,SAAS,GAAG,QAAK,oBAAI,UAAU,GAAU,QAAI,oBAAI,UAAU,GAAU,IAAI;AAC5H,QAAI,cAAc,QAAW;AAC3B,cAAI,6BAAa,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 } from \"../schema-fields\";\nimport { allProviders } from \"../utils/oauth\";\nimport { DeepMerge, DeepPartial, get, has, isObjectLike, mapValues, set } from \"../utils/objects\";\nimport { PrettifyType } from \"../utils/types\";\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\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.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 }).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\nexport const projectConfigDefaults = {} 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 },\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, without the properties that may be overridden still\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 = ProjectConfigNormalizedOverride;\nexport type BranchIncompleteConfig = ProjectIncompleteConfig & BranchConfigNormalizedOverride;\nexport type EnvironmentIncompleteConfig = BranchIncompleteConfig & EnvironmentConfigNormalizedOverride;\nexport type OrganizationIncompleteConfig = EnvironmentIncompleteConfig & OrganizationConfigNormalizedOverride;\n\n// Rendered configs\nexport type ProjectRenderedConfig = PrettifyType<ApplyDefaults<typeof projectConfigDefaults, ProjectConfigStrippedNormalizedOverride>>;\nexport type BranchRenderedConfig = PrettifyType<ProjectRenderedConfig & ApplyDefaults<typeof branchConfigDefaults, BranchConfigStrippedNormalizedOverride>>;\nexport type EnvironmentRenderedConfig = PrettifyType<BranchRenderedConfig & ApplyDefaults<typeof environmentConfigDefaults, EnvironmentConfigStrippedNormalizedOverride>>;\nexport type OrganizationRenderedConfig = PrettifyType<EnvironmentRenderedConfig & ApplyDefaults<typeof organizationConfigDefaults, OrganizationConfigStrippedNormalizedOverride>>;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,mBAA8B;AAC9B,2BAA4D;AAC5D,mBAA6B;AAC7B,qBAA+E;AAQxE,IAAM,eAAe,CAAC,WAAW,UAAU,eAAe,cAAc;AAE/E,IAAM,kBAAkB;AACxB,IAAM,wBAAwB;AAKvB,IAAM,0BAAsB,gCAAU,CAAC,CAAC;AAG/C,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,EAAE,QAAQ,qBAAqB;AAAA,QACpD,gCAAU;AAAA,MACR,iBAAa,gCAAU,EAAE,SAAS;AAAA,MAClC,WAAO,gCAAU,EAAE,MAAM,CAAC,QAAQ,SAAS,CAAC,EAAE,SAAS;AAAA,MACvD,4BAAwB;AAAA,YACtB,gCAAU,EAAE,SAAS,EAAE,QAAQ,eAAe;AAAA,YAC9C,iCAAW,EAAE,OAAO,EAAE,SAAS;AAAA,MACjC,EAAE,SAAS;AAAA,IACb,CAAC,EAAE,SAAS;AAAA,EACd,EAAE,SAAS;AAAA,EACX,wBAAoB,gCAAU;AAAA,IAC5B,aAAa;AAAA,IACb,YAAY;AAAA,IACZ,QAAQ;AAAA,EACV,CAAC,EAAE,SAAS;AACd,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Aa;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,EACF;AACF;AAKO,SAAS,cAA+E,UAAa,QAAgC;AAC1I,QAAM,MAAW,OAAO,aAAa,aAAa,CAAC,QAAI,0BAAU,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,QAAK,oBAAI,UAAU,GAAU,QAAI,oBAAI,UAAU,GAAU,IAAI;AAC5H,QAAI,cAAc,QAAW;AAC3B,cAAI,6BAAa,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":[]}
@@ -2,9 +2,10 @@
2
2
  import * as schemaFields from "../schema-fields";
3
3
  import { yupBoolean, yupObject, yupRecord, yupString } from "../schema-fields";
4
4
  import { allProviders } from "../utils/oauth";
5
- import { get, has, isObjectLike, set } from "../utils/objects";
5
+ import { get, has, isObjectLike, mapValues, set } from "../utils/objects";
6
6
  var configLevels = ["project", "branch", "environment", "organization"];
7
7
  var permissionRegex = /^\$?[a-z0-9_:]+$/;
8
+ var customPermissionRegex = /^[a-z0-9_:]+$/;
8
9
  var projectConfigSchema = yupObject({});
9
10
  var branchRbacDefaultPermissions = yupRecord(
10
11
  yupString().optional().matches(permissionRegex),
@@ -12,7 +13,7 @@ var branchRbacDefaultPermissions = yupRecord(
12
13
  ).optional();
13
14
  var branchRbacSchema = yupObject({
14
15
  permissions: yupRecord(
15
- yupString().optional().matches(permissionRegex),
16
+ yupString().optional().matches(customPermissionRegex),
16
17
  yupObject({
17
18
  description: yupString().optional(),
18
19
  scope: yupString().oneOf(["team", "project"]).optional(),
@@ -159,6 +160,7 @@ var organizationConfigDefaults = {
159
160
  oauth: {
160
161
  accountMergeStrategy: "link_method",
161
162
  providers: (key) => ({
163
+ isShared: true,
162
164
  allowSignIn: false,
163
165
  allowConnectedAccounts: false
164
166
  })
@@ -171,7 +173,7 @@ var organizationConfigDefaults = {
171
173
  }
172
174
  };
173
175
  function applyDefaults(defaults, config) {
174
- const res = { ...typeof defaults === "function" ? {} : defaults };
176
+ const res = typeof defaults === "function" ? {} : mapValues(defaults, (v) => typeof v === "function" ? {} : typeof v === "object" ? applyDefaults(v, {}) : v);
175
177
  for (const [key, mergeValue] of Object.entries(config)) {
176
178
  const baseValue = typeof defaults === "function" ? defaults(key) : has(defaults, key) ? get(defaults, key) : void 0;
177
179
  if (baseValue !== void 0) {
@@ -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 } from \"../schema-fields\";\nimport { allProviders } from \"../utils/oauth\";\nimport { DeepMerge, get, has, isObjectLike, set } from \"../utils/objects\";\nimport { PrettifyType } from \"../utils/types\";\nimport { 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_:]+$/;\n\n/**\n * All fields that can be overridden at this level.\n */\nexport const projectConfigSchema = yupObject({});\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(permissionRegex),\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.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 }).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\nexport const projectConfigDefaults = {} 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 allowSignIn: false,\n allowConnectedAccounts: false,\n }),\n },\n },\n\n emails: {\n server: {\n isShared: true,\n },\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' ? {} : defaults };\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});\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, without the properties that may be overridden still\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// Incomplete configs\nexport type ProjectIncompleteConfig = ProjectConfigNormalizedOverride;\nexport type BranchIncompleteConfig = ProjectIncompleteConfig & BranchConfigNormalizedOverride;\nexport type EnvironmentIncompleteConfig = BranchIncompleteConfig & EnvironmentConfigNormalizedOverride;\nexport type OrganizationIncompleteConfig = EnvironmentIncompleteConfig & OrganizationConfigNormalizedOverride;\n\n// Rendered configs\nexport type ProjectRenderedConfig = PrettifyType<ApplyDefaults<typeof projectConfigDefaults, ProjectConfigStrippedNormalizedOverride>>;\nexport type BranchRenderedConfig = PrettifyType<ProjectRenderedConfig & ApplyDefaults<typeof branchConfigDefaults, BranchConfigStrippedNormalizedOverride>>;\nexport type EnvironmentRenderedConfig = PrettifyType<BranchRenderedConfig & ApplyDefaults<typeof environmentConfigDefaults, EnvironmentConfigStrippedNormalizedOverride>>;\nexport type OrganizationRenderedConfig = PrettifyType<EnvironmentRenderedConfig & ApplyDefaults<typeof organizationConfigDefaults, OrganizationConfigStrippedNormalizedOverride>>;\n"],"mappings":";AACA,YAAY,kBAAkB;AAC9B,SAAS,YAAY,WAAW,WAAW,iBAAiB;AAC5D,SAAS,oBAAoB;AAC7B,SAAoB,KAAK,KAAK,cAAc,WAAW;AAQhD,IAAM,eAAe,CAAC,WAAW,UAAU,eAAe,cAAc;AAE/E,IAAM,kBAAkB;AAKjB,IAAM,sBAAsB,UAAU,CAAC,CAAC;AAG/C,IAAM,+BAA+B;AAAA,EACnC,UAAU,EAAE,SAAS,EAAE,QAAQ,eAAe;AAAA,EAC9C,WAAW,EAAE,OAAO,EAAE,SAAS;AACjC,EAAE,SAAS;AAEX,IAAM,mBAAmB,UAAU;AAAA,EACjC,aAAa;AAAA,IACX,UAAU,EAAE,SAAS,EAAE,QAAQ,eAAe;AAAA,IAC9C,UAAU;AAAA,MACR,aAAa,UAAU,EAAE,SAAS;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A,EAEA,OAAO;AAAA,IACL,yBAAyB;AAAA,EAC3B;AAAA,EAEA,SAAS;AAAA,IACP,gBAAgB;AAAA,IAChB,gBAAgB,CAAC,SAAiB;AAAA,MAChC,aAAa;AAAA,IACf;AAAA,EACF;AAAA,EAEA,MAAM;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,aAAa;AAAA,QACb,wBAAwB;AAAA,MAC1B;AAAA,IACF;AAAA,EACF;AAAA,EAEA,QAAQ;AAAA,IACN,QAAQ;AAAA,MACN,UAAU;AAAA,IACZ;AAAA,EACF;AACF;AAKO,SAAS,cAA+E,UAAa,QAAgC;AAC1I,QAAM,MAAW,EAAE,GAAG,OAAO,aAAa,aAAa,CAAC,IAAI,SAAS;AACrE,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 } from \"../schema-fields\";\nimport { allProviders } from \"../utils/oauth\";\nimport { DeepMerge, DeepPartial, get, has, isObjectLike, mapValues, set } from \"../utils/objects\";\nimport { PrettifyType } from \"../utils/types\";\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\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.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 }).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\nexport const projectConfigDefaults = {} 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 },\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, without the properties that may be overridden still\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 = ProjectConfigNormalizedOverride;\nexport type BranchIncompleteConfig = ProjectIncompleteConfig & BranchConfigNormalizedOverride;\nexport type EnvironmentIncompleteConfig = BranchIncompleteConfig & EnvironmentConfigNormalizedOverride;\nexport type OrganizationIncompleteConfig = EnvironmentIncompleteConfig & OrganizationConfigNormalizedOverride;\n\n// Rendered configs\nexport type ProjectRenderedConfig = PrettifyType<ApplyDefaults<typeof projectConfigDefaults, ProjectConfigStrippedNormalizedOverride>>;\nexport type BranchRenderedConfig = PrettifyType<ProjectRenderedConfig & ApplyDefaults<typeof branchConfigDefaults, BranchConfigStrippedNormalizedOverride>>;\nexport type EnvironmentRenderedConfig = PrettifyType<BranchRenderedConfig & ApplyDefaults<typeof environmentConfigDefaults, EnvironmentConfigStrippedNormalizedOverride>>;\nexport type OrganizationRenderedConfig = PrettifyType<EnvironmentRenderedConfig & ApplyDefaults<typeof organizationConfigDefaults, OrganizationConfigStrippedNormalizedOverride>>;\n"],"mappings":";AACA,YAAY,kBAAkB;AAC9B,SAAS,YAAY,WAAW,WAAW,iBAAiB;AAC5D,SAAS,oBAAoB;AAC7B,SAAiC,KAAK,KAAK,cAAc,WAAW,WAAW;AAQxE,IAAM,eAAe,CAAC,WAAW,UAAU,eAAe,cAAc;AAE/E,IAAM,kBAAkB;AACxB,IAAM,wBAAwB;AAKvB,IAAM,sBAAsB,UAAU,CAAC,CAAC;AAG/C,IAAM,+BAA+B;AAAA,EACnC,UAAU,EAAE,SAAS,EAAE,QAAQ,eAAe;AAAA,EAC9C,WAAW,EAAE,OAAO,EAAE,SAAS;AACjC,EAAE,SAAS;AAEX,IAAM,mBAAmB,UAAU;AAAA,EACjC,aAAa;AAAA,IACX,UAAU,EAAE,SAAS,EAAE,QAAQ,qBAAqB;AAAA,IACpD,UAAU;AAAA,MACR,aAAa,UAAU,EAAE,SAAS;AAAA,MAClC,OAAO,UAAU,EAAE,MAAM,CAAC,QAAQ,SAAS,CAAC,EAAE,SAAS;AAAA,MACvD,wBAAwB;AAAA,QACtB,UAAU,EAAE,SAAS,EAAE,QAAQ,eAAe;AAAA,QAC9C,WAAW,EAAE,OAAO,EAAE,SAAS;AAAA,MACjC,EAAE,SAAS;AAAA,IACb,CAAC,EAAE,SAAS;AAAA,EACd,EAAE,SAAS;AAAA,EACX,oBAAoB,UAAU;AAAA,IAC5B,aAAa;AAAA,IACb,YAAY;AAAA,IACZ,QAAQ;AAAA,EACV,CAAC,EAAE,SAAS;AACd,CAAC,EAAE,SAAS;AAIZ,IAAM,sBAA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;AAAA,QACV,aAAa;AAAA,QACb,wBAAwB;AAAA,MAC1B;AAAA,IACF;AAAA,EACF;AAAA,EAEA,QAAQ;AAAA,IACN,QAAQ;AAAA,MACN,UAAU;AAAA,IACZ;AAAA,EACF;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":[]}
@@ -7,21 +7,14 @@ var teamPermissionSchema = yupObject({
7
7
  }).defined();
8
8
  var oauthProviderSchema = yupObject({
9
9
  id: schemaFields.oauthIdSchema.defined(),
10
- enabled: schemaFields.oauthEnabledSchema.defined(),
11
10
  type: schemaFields.oauthTypeSchema.defined(),
12
11
  client_id: schemaFields.yupDefinedAndNonEmptyWhen(
13
12
  schemaFields.oauthClientIdSchema,
14
- {
15
- type: "standard",
16
- enabled: true
17
- }
13
+ { type: "standard" }
18
14
  ),
19
15
  client_secret: schemaFields.yupDefinedAndNonEmptyWhen(
20
16
  schemaFields.oauthClientSecretSchema,
21
- {
22
- type: "standard",
23
- enabled: true
24
- }
17
+ { type: "standard" }
25
18
  ),
26
19
  // extra params
27
20
  facebook_config_id: schemaFields.oauthFacebookConfigIdSchema.optional(),
@@ -64,7 +57,6 @@ var projectsCrudAdminReadSchema = yupObject({
64
57
  user_count: schemaFields.projectUserCountSchema.defined(),
65
58
  is_production_mode: schemaFields.projectIsProductionModeSchema.defined(),
66
59
  config: yupObject({
67
- id: schemaFields.projectConfigIdSchema.defined(),
68
60
  allow_localhost: schemaFields.projectAllowLocalhostSchema.defined(),
69
61
  sign_up_enabled: schemaFields.projectSignUpEnabledSchema.defined(),
70
62
  credential_enabled: schemaFields.projectCredentialEnabledSchema.defined(),
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/interface/crud/projects.ts"],"sourcesContent":["import { CrudTypeOf, createCrud } from \"../../crud\";\nimport * as schemaFields from \"../../schema-fields\";\nimport { yupArray, yupObject, yupString } from \"../../schema-fields\";\n\nconst teamPermissionSchema = yupObject({\n id: yupString().defined(),\n}).defined();\n\nconst oauthProviderSchema = yupObject({\n id: schemaFields.oauthIdSchema.defined(),\n enabled: schemaFields.oauthEnabledSchema.defined(),\n type: schemaFields.oauthTypeSchema.defined(),\n client_id: schemaFields.yupDefinedAndNonEmptyWhen(\n schemaFields.oauthClientIdSchema,\n {\n type: 'standard',\n enabled: true,\n },\n ),\n client_secret: schemaFields.yupDefinedAndNonEmptyWhen(\n schemaFields.oauthClientSecretSchema,\n {\n type: 'standard',\n enabled: true,\n },\n ),\n\n // extra params\n facebook_config_id: schemaFields.oauthFacebookConfigIdSchema.optional(),\n microsoft_tenant_id: schemaFields.oauthMicrosoftTenantIdSchema.optional(),\n});\n\nconst enabledOAuthProviderSchema = yupObject({\n id: schemaFields.oauthIdSchema.defined(),\n});\n\nexport const emailConfigSchema = yupObject({\n type: schemaFields.emailTypeSchema.defined(),\n host: schemaFields.yupDefinedAndNonEmptyWhen(schemaFields.emailHostSchema, {\n type: 'standard',\n }),\n port: schemaFields.yupDefinedWhen(schemaFields.emailPortSchema, {\n type: 'standard',\n }),\n username: schemaFields.yupDefinedAndNonEmptyWhen(schemaFields.emailUsernameSchema, {\n type: 'standard',\n }),\n password: schemaFields.yupDefinedAndNonEmptyWhen(schemaFields.emailPasswordSchema, {\n type: 'standard',\n }),\n sender_name: schemaFields.yupDefinedAndNonEmptyWhen(schemaFields.emailSenderNameSchema, {\n type: 'standard',\n }),\n sender_email: schemaFields.yupDefinedAndNonEmptyWhen(schemaFields.emailSenderEmailSchema, {\n type: 'standard',\n }),\n});\n\nexport const emailConfigWithoutPasswordSchema = emailConfigSchema.pick(['type', 'host', 'port', 'username', 'sender_name', 'sender_email']);\n\nconst domainSchema = yupObject({\n domain: schemaFields.urlSchema.defined()\n .matches(/^https?:\\/\\//, 'URL must start with http:// or https://')\n .meta({ openapiField: { description: 'URL. Must start with http:// or https://', exampleValue: 'https://example.com' } }),\n handler_path: schemaFields.handlerPathSchema.defined(),\n});\n\nexport const projectsCrudAdminReadSchema = yupObject({\n id: schemaFields.projectIdSchema.defined(),\n display_name: schemaFields.projectDisplayNameSchema.defined(),\n description: schemaFields.projectDescriptionSchema.nonNullable().defined(),\n created_at_millis: schemaFields.projectCreatedAtMillisSchema.defined(),\n user_count: schemaFields.projectUserCountSchema.defined(),\n is_production_mode: schemaFields.projectIsProductionModeSchema.defined(),\n config: yupObject({\n id: schemaFields.projectConfigIdSchema.defined(),\n allow_localhost: schemaFields.projectAllowLocalhostSchema.defined(),\n sign_up_enabled: schemaFields.projectSignUpEnabledSchema.defined(),\n credential_enabled: schemaFields.projectCredentialEnabledSchema.defined(),\n magic_link_enabled: schemaFields.projectMagicLinkEnabledSchema.defined(),\n passkey_enabled: schemaFields.projectPasskeyEnabledSchema.defined(),\n // TODO: remove this\n client_team_creation_enabled: schemaFields.projectClientTeamCreationEnabledSchema.defined(),\n client_user_deletion_enabled: schemaFields.projectClientUserDeletionEnabledSchema.defined(),\n allow_user_api_keys: schemaFields.yupBoolean().defined(),\n allow_team_api_keys: schemaFields.yupBoolean().defined(),\n oauth_providers: yupArray(oauthProviderSchema.defined()).defined(),\n enabled_oauth_providers: yupArray(enabledOAuthProviderSchema.defined()).defined().meta({ openapiField: { hidden: true } }),\n domains: yupArray(domainSchema.defined()).defined(),\n email_config: emailConfigSchema.defined(),\n create_team_on_sign_up: schemaFields.projectCreateTeamOnSignUpSchema.defined(),\n team_creator_default_permissions: yupArray(teamPermissionSchema.defined()).defined(),\n team_member_default_permissions: yupArray(teamPermissionSchema.defined()).defined(),\n user_default_permissions: yupArray(teamPermissionSchema.defined()).defined(),\n oauth_account_merge_strategy: schemaFields.oauthAccountMergeStrategySchema.defined(),\n }).defined(),\n}).defined();\n\nexport const projectsCrudClientReadSchema = yupObject({\n id: schemaFields.projectIdSchema.defined(),\n display_name: schemaFields.projectDisplayNameSchema.defined(),\n config: yupObject({\n sign_up_enabled: schemaFields.projectSignUpEnabledSchema.defined(),\n credential_enabled: schemaFields.projectCredentialEnabledSchema.defined(),\n magic_link_enabled: schemaFields.projectMagicLinkEnabledSchema.defined(),\n passkey_enabled: schemaFields.projectPasskeyEnabledSchema.defined(),\n client_team_creation_enabled: schemaFields.projectClientTeamCreationEnabledSchema.defined(),\n client_user_deletion_enabled: schemaFields.projectClientUserDeletionEnabledSchema.defined(),\n allow_user_api_keys: schemaFields.yupBoolean().defined(),\n allow_team_api_keys: schemaFields.yupBoolean().defined(),\n enabled_oauth_providers: yupArray(enabledOAuthProviderSchema.defined()).defined().meta({ openapiField: { hidden: true } }),\n }).defined(),\n}).defined();\n\n\nexport const projectsCrudAdminUpdateSchema = yupObject({\n display_name: schemaFields.projectDisplayNameSchema.optional(),\n description: schemaFields.projectDescriptionSchema.optional(),\n is_production_mode: schemaFields.projectIsProductionModeSchema.optional(),\n config: yupObject({\n sign_up_enabled: schemaFields.projectSignUpEnabledSchema.optional(),\n credential_enabled: schemaFields.projectCredentialEnabledSchema.optional(),\n magic_link_enabled: schemaFields.projectMagicLinkEnabledSchema.optional(),\n passkey_enabled: schemaFields.projectPasskeyEnabledSchema.optional(),\n client_team_creation_enabled: schemaFields.projectClientTeamCreationEnabledSchema.optional(),\n client_user_deletion_enabled: schemaFields.projectClientUserDeletionEnabledSchema.optional(),\n allow_localhost: schemaFields.projectAllowLocalhostSchema.optional(),\n allow_user_api_keys: schemaFields.yupBoolean().optional(),\n allow_team_api_keys: schemaFields.yupBoolean().optional(),\n email_config: emailConfigSchema.optional().default(undefined),\n domains: yupArray(domainSchema.defined()).optional().default(undefined),\n oauth_providers: yupArray(oauthProviderSchema.defined()).optional().default(undefined),\n create_team_on_sign_up: schemaFields.projectCreateTeamOnSignUpSchema.optional(),\n team_creator_default_permissions: yupArray(teamPermissionSchema.defined()).optional(),\n team_member_default_permissions: yupArray(teamPermissionSchema.defined()).optional(),\n user_default_permissions: yupArray(teamPermissionSchema.defined()).optional(),\n oauth_account_merge_strategy: schemaFields.oauthAccountMergeStrategySchema.optional(),\n }).optional().default(undefined),\n}).defined();\n\nexport const projectsCrudAdminCreateSchema = projectsCrudAdminUpdateSchema.concat(yupObject({\n display_name: schemaFields.projectDisplayNameSchema.defined(),\n}).defined());\n\nexport const projectsCrudAdminDeleteSchema = schemaFields.yupMixed();\n\nexport const clientProjectsCrud = createCrud({\n clientReadSchema: projectsCrudClientReadSchema,\n docs: {\n clientRead: {\n summary: 'Get the current project',\n description: 'Get the current project information including display name, OAuth providers and authentication methods. Useful for display the available login options to the user.',\n tags: ['Projects'],\n },\n },\n});\nexport type ClientProjectsCrud = CrudTypeOf<typeof clientProjectsCrud>;\n\nexport const projectsCrud = createCrud({\n adminReadSchema: projectsCrudAdminReadSchema,\n adminUpdateSchema: projectsCrudAdminUpdateSchema,\n adminDeleteSchema: projectsCrudAdminDeleteSchema,\n docs: {\n adminRead: {\n summary: 'Get the current project',\n description: 'Get the current project information and configuration including display name, OAuth providers, email configuration, etc.',\n tags: ['Projects'],\n },\n adminUpdate: {\n summary: 'Update the current project',\n description: 'Update the current project information and configuration including display name, OAuth providers, email configuration, etc.',\n tags: ['Projects'],\n },\n adminDelete: {\n summary: 'Delete the current project',\n description: 'Delete the current project and all associated data (including users, teams, API keys, project configs, etc.). Be careful, this action is irreversible.',\n tags: ['Projects'],\n },\n },\n});\nexport type ProjectsCrud = CrudTypeOf<typeof projectsCrud>;\n\nexport const adminUserProjectsCrud = createCrud({\n clientReadSchema: projectsCrudAdminReadSchema,\n clientCreateSchema: projectsCrudAdminCreateSchema,\n docs: {\n clientList: {\n hidden: true,\n },\n clientCreate: {\n hidden: true,\n },\n },\n});\nexport type AdminUserProjectsCrud = CrudTypeOf<typeof adminUserProjectsCrud>;\n"],"mappings":";AAAA,SAAqB,kBAAkB;AACvC,YAAY,kBAAkB;AAC9B,SAAS,UAAU,WAAW,iBAAiB;AAE/C,IAAM,uBAAuB,UAAU;AAAA,EACrC,IAAI,UAAU,EAAE,QAAQ;AAC1B,CAAC,EAAE,QAAQ;AAEX,IAAM,sBAAsB,UAAU;AAAA,EACpC,IAAiB,2BAAc,QAAQ;AAAA,EACvC,SAAsB,gCAAmB,QAAQ;AAAA,EACjD,MAAmB,6BAAgB,QAAQ;AAAA,EAC3C,WAAwB;AAAA,IACT;AAAA,IACb;AAAA,MACE,MAAM;AAAA,MACN,SAAS;AAAA,IACX;AAAA,EACF;AAAA,EACA,eAA4B;AAAA,IACb;AAAA,IACb;AAAA,MACE,MAAM;AAAA,MACN,SAAS;AAAA,IACX;AAAA,EACF;AAAA;AAAA,EAGA,oBAAiC,yCAA4B,SAAS;AAAA,EACtE,qBAAkC,0CAA6B,SAAS;AAC1E,CAAC;AAED,IAAM,6BAA6B,UAAU;AAAA,EAC3C,IAAiB,2BAAc,QAAQ;AACzC,CAAC;AAEM,IAAM,oBAAoB,UAAU;AAAA,EACzC,MAAmB,6BAAgB,QAAQ;AAAA,EAC3C,MAAmB,uCAAuC,8BAAiB;AAAA,IACzE,MAAM;AAAA,EACR,CAAC;AAAA,EACD,MAAmB,4BAA4B,8BAAiB;AAAA,IAC9D,MAAM;AAAA,EACR,CAAC;AAAA,EACD,UAAuB,uCAAuC,kCAAqB;AAAA,IACjF,MAAM;AAAA,EACR,CAAC;AAAA,EACD,UAAuB,uCAAu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EACrC,iBAAiB;AAAA,EACjB,mBAAmB;AAAA,EACnB,mBAAmB;AAAA,EACnB,MAAM;AAAA,IACJ,WAAW;AAAA,MACT,SAAS;AAAA,MACT,aAAa;AAAA,MACb,MAAM,CAAC,UAAU;AAAA,IACnB;AAAA,IACA,aAAa;AAAA,MACX,SAAS;AAAA,MACT,aAAa;AAAA,MACb,MAAM,CAAC,UAAU;AAAA,IACnB;AAAA,IACA,aAAa;AAAA,MACX,SAAS;AAAA,MACT,aAAa;AAAA,MACb,MAAM,CAAC,UAAU;AAAA,IACnB;AAAA,EACF;AACF,CAAC;AAGM,IAAM,wBAAwB,WAAW;AAAA,EAC9C,kBAAkB;AAAA,EAClB,oBAAoB;AAAA,EACpB,MAAM;AAAA,IACJ,YAAY;AAAA,MACV,QAAQ;AAAA,IACV;AAAA,IACA,cAAc;AAAA,MACZ,QAAQ;AAAA,IACV;AAAA,EACF;AACF,CAAC;","names":[]}
1
+ {"version":3,"sources":["../../../../src/interface/crud/projects.ts"],"sourcesContent":["import { CrudTypeOf, createCrud } from \"../../crud\";\nimport * as schemaFields from \"../../schema-fields\";\nimport { yupArray, yupObject, yupString } from \"../../schema-fields\";\n\nconst teamPermissionSchema = yupObject({\n id: yupString().defined(),\n}).defined();\n\nconst oauthProviderSchema = yupObject({\n id: schemaFields.oauthIdSchema.defined(),\n type: schemaFields.oauthTypeSchema.defined(),\n client_id: schemaFields.yupDefinedAndNonEmptyWhen(\n schemaFields.oauthClientIdSchema,\n { type: 'standard' },\n ),\n client_secret: schemaFields.yupDefinedAndNonEmptyWhen(\n schemaFields.oauthClientSecretSchema,\n { type: 'standard' },\n ),\n\n // extra params\n facebook_config_id: schemaFields.oauthFacebookConfigIdSchema.optional(),\n microsoft_tenant_id: schemaFields.oauthMicrosoftTenantIdSchema.optional(),\n});\n\nconst enabledOAuthProviderSchema = yupObject({\n id: schemaFields.oauthIdSchema.defined(),\n});\n\nexport const emailConfigSchema = yupObject({\n type: schemaFields.emailTypeSchema.defined(),\n host: schemaFields.yupDefinedAndNonEmptyWhen(schemaFields.emailHostSchema, {\n type: 'standard',\n }),\n port: schemaFields.yupDefinedWhen(schemaFields.emailPortSchema, {\n type: 'standard',\n }),\n username: schemaFields.yupDefinedAndNonEmptyWhen(schemaFields.emailUsernameSchema, {\n type: 'standard',\n }),\n password: schemaFields.yupDefinedAndNonEmptyWhen(schemaFields.emailPasswordSchema, {\n type: 'standard',\n }),\n sender_name: schemaFields.yupDefinedAndNonEmptyWhen(schemaFields.emailSenderNameSchema, {\n type: 'standard',\n }),\n sender_email: schemaFields.yupDefinedAndNonEmptyWhen(schemaFields.emailSenderEmailSchema, {\n type: 'standard',\n }),\n});\n\nexport const emailConfigWithoutPasswordSchema = emailConfigSchema.pick(['type', 'host', 'port', 'username', 'sender_name', 'sender_email']);\n\nconst domainSchema = yupObject({\n domain: schemaFields.urlSchema.defined()\n .matches(/^https?:\\/\\//, 'URL must start with http:// or https://')\n .meta({ openapiField: { description: 'URL. Must start with http:// or https://', exampleValue: 'https://example.com' } }),\n handler_path: schemaFields.handlerPathSchema.defined(),\n});\n\nexport const projectsCrudAdminReadSchema = yupObject({\n id: schemaFields.projectIdSchema.defined(),\n display_name: schemaFields.projectDisplayNameSchema.defined(),\n description: schemaFields.projectDescriptionSchema.nonNullable().defined(),\n created_at_millis: schemaFields.projectCreatedAtMillisSchema.defined(),\n user_count: schemaFields.projectUserCountSchema.defined(),\n is_production_mode: schemaFields.projectIsProductionModeSchema.defined(),\n config: yupObject({\n allow_localhost: schemaFields.projectAllowLocalhostSchema.defined(),\n sign_up_enabled: schemaFields.projectSignUpEnabledSchema.defined(),\n credential_enabled: schemaFields.projectCredentialEnabledSchema.defined(),\n magic_link_enabled: schemaFields.projectMagicLinkEnabledSchema.defined(),\n passkey_enabled: schemaFields.projectPasskeyEnabledSchema.defined(),\n // TODO: remove this\n client_team_creation_enabled: schemaFields.projectClientTeamCreationEnabledSchema.defined(),\n client_user_deletion_enabled: schemaFields.projectClientUserDeletionEnabledSchema.defined(),\n allow_user_api_keys: schemaFields.yupBoolean().defined(),\n allow_team_api_keys: schemaFields.yupBoolean().defined(),\n oauth_providers: yupArray(oauthProviderSchema.defined()).defined(),\n enabled_oauth_providers: yupArray(enabledOAuthProviderSchema.defined()).defined().meta({ openapiField: { hidden: true } }),\n domains: yupArray(domainSchema.defined()).defined(),\n email_config: emailConfigSchema.defined(),\n create_team_on_sign_up: schemaFields.projectCreateTeamOnSignUpSchema.defined(),\n team_creator_default_permissions: yupArray(teamPermissionSchema.defined()).defined(),\n team_member_default_permissions: yupArray(teamPermissionSchema.defined()).defined(),\n user_default_permissions: yupArray(teamPermissionSchema.defined()).defined(),\n oauth_account_merge_strategy: schemaFields.oauthAccountMergeStrategySchema.defined(),\n }).defined(),\n}).defined();\n\nexport const projectsCrudClientReadSchema = yupObject({\n id: schemaFields.projectIdSchema.defined(),\n display_name: schemaFields.projectDisplayNameSchema.defined(),\n config: yupObject({\n sign_up_enabled: schemaFields.projectSignUpEnabledSchema.defined(),\n credential_enabled: schemaFields.projectCredentialEnabledSchema.defined(),\n magic_link_enabled: schemaFields.projectMagicLinkEnabledSchema.defined(),\n passkey_enabled: schemaFields.projectPasskeyEnabledSchema.defined(),\n client_team_creation_enabled: schemaFields.projectClientTeamCreationEnabledSchema.defined(),\n client_user_deletion_enabled: schemaFields.projectClientUserDeletionEnabledSchema.defined(),\n allow_user_api_keys: schemaFields.yupBoolean().defined(),\n allow_team_api_keys: schemaFields.yupBoolean().defined(),\n enabled_oauth_providers: yupArray(enabledOAuthProviderSchema.defined()).defined().meta({ openapiField: { hidden: true } }),\n }).defined(),\n}).defined();\n\n\nexport const projectsCrudAdminUpdateSchema = yupObject({\n display_name: schemaFields.projectDisplayNameSchema.optional(),\n description: schemaFields.projectDescriptionSchema.optional(),\n is_production_mode: schemaFields.projectIsProductionModeSchema.optional(),\n config: yupObject({\n sign_up_enabled: schemaFields.projectSignUpEnabledSchema.optional(),\n credential_enabled: schemaFields.projectCredentialEnabledSchema.optional(),\n magic_link_enabled: schemaFields.projectMagicLinkEnabledSchema.optional(),\n passkey_enabled: schemaFields.projectPasskeyEnabledSchema.optional(),\n client_team_creation_enabled: schemaFields.projectClientTeamCreationEnabledSchema.optional(),\n client_user_deletion_enabled: schemaFields.projectClientUserDeletionEnabledSchema.optional(),\n allow_localhost: schemaFields.projectAllowLocalhostSchema.optional(),\n allow_user_api_keys: schemaFields.yupBoolean().optional(),\n allow_team_api_keys: schemaFields.yupBoolean().optional(),\n email_config: emailConfigSchema.optional().default(undefined),\n domains: yupArray(domainSchema.defined()).optional().default(undefined),\n oauth_providers: yupArray(oauthProviderSchema.defined()).optional().default(undefined),\n create_team_on_sign_up: schemaFields.projectCreateTeamOnSignUpSchema.optional(),\n team_creator_default_permissions: yupArray(teamPermissionSchema.defined()).optional(),\n team_member_default_permissions: yupArray(teamPermissionSchema.defined()).optional(),\n user_default_permissions: yupArray(teamPermissionSchema.defined()).optional(),\n oauth_account_merge_strategy: schemaFields.oauthAccountMergeStrategySchema.optional(),\n }).optional().default(undefined),\n}).defined();\n\nexport const projectsCrudAdminCreateSchema = projectsCrudAdminUpdateSchema.concat(yupObject({\n display_name: schemaFields.projectDisplayNameSchema.defined(),\n}).defined());\n\nexport const projectsCrudAdminDeleteSchema = schemaFields.yupMixed();\n\nexport const clientProjectsCrud = createCrud({\n clientReadSchema: projectsCrudClientReadSchema,\n docs: {\n clientRead: {\n summary: 'Get the current project',\n description: 'Get the current project information including display name, OAuth providers and authentication methods. Useful for display the available login options to the user.',\n tags: ['Projects'],\n },\n },\n});\nexport type ClientProjectsCrud = CrudTypeOf<typeof clientProjectsCrud>;\n\nexport const projectsCrud = createCrud({\n adminReadSchema: projectsCrudAdminReadSchema,\n adminUpdateSchema: projectsCrudAdminUpdateSchema,\n adminDeleteSchema: projectsCrudAdminDeleteSchema,\n docs: {\n adminRead: {\n summary: 'Get the current project',\n description: 'Get the current project information and configuration including display name, OAuth providers, email configuration, etc.',\n tags: ['Projects'],\n },\n adminUpdate: {\n summary: 'Update the current project',\n description: 'Update the current project information and configuration including display name, OAuth providers, email configuration, etc.',\n tags: ['Projects'],\n },\n adminDelete: {\n summary: 'Delete the current project',\n description: 'Delete the current project and all associated data (including users, teams, API keys, project configs, etc.). Be careful, this action is irreversible.',\n tags: ['Projects'],\n },\n },\n});\nexport type ProjectsCrud = CrudTypeOf<typeof projectsCrud>;\n\nexport const adminUserProjectsCrud = createCrud({\n clientReadSchema: projectsCrudAdminReadSchema,\n clientCreateSchema: projectsCrudAdminCreateSchema,\n docs: {\n clientList: {\n hidden: true,\n },\n clientCreate: {\n hidden: true,\n },\n },\n});\nexport type AdminUserProjectsCrud = CrudTypeOf<typeof adminUserProjectsCrud>;\n"],"mappings":";AAAA,SAAqB,kBAAkB;AACvC,YAAY,kBAAkB;AAC9B,SAAS,UAAU,WAAW,iBAAiB;AAE/C,IAAM,uBAAuB,UAAU;AAAA,EACrC,IAAI,UAAU,EAAE,QAAQ;AAC1B,CAAC,EAAE,QAAQ;AAEX,IAAM,sBAAsB,UAAU;AAAA,EACpC,IAAiB,2BAAc,QAAQ;AAAA,EACvC,MAAmB,6BAAgB,QAAQ;AAAA,EAC3C,WAAwB;AAAA,IACT;AAAA,IACb,EAAE,MAAM,WAAW;AAAA,EACrB;AAAA,EACA,eAA4B;AAAA,IACb;AAAA,IACb,EAAE,MAAM,WAAW;AAAA,EACrB;AAAA;AAAA,EAGA,oBAAiC,yCAA4B,SAAS;AAAA,EACtE,qBAAkC,0CAA6B,SAAS;AAC1E,CAAC;AAED,IAAM,6BAA6B,UAAU;AAAA,EAC3C,IAAiB,2BAAc,QAAQ;AACzC,CAAC;AAEM,IAAM,oBAAoB,UAAU;AAAA,EACzC,MAAmB,6BAAgB,QAAQ;AAAA,EAC3C,MAAmB,uCAAuC,8BAAiB;AAAA,IACzE,MAAM;AAAA,EACR,CAAC;AAAA,EACD,MAAmB,4BAA4B,8BAAiB;AAAA,IAC9D,MAAM;AAAA,EACR,CAAC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,IACnB;AAAA,EACF;AACF,CAAC;AAGM,IAAM,eAAe,WAAW;AAAA,EACrC,iBAAiB;AAAA,EACjB,mBAAmB;AAAA,EACnB,mBAAmB;AAAA,EACnB,MAAM;AAAA,IACJ,WAAW;AAAA,MACT,SAAS;AAAA,MACT,aAAa;AAAA,MACb,MAAM,CAAC,UAAU;AAAA,IACnB;AAAA,IACA,aAAa;AAAA,MACX,SAAS;AAAA,MACT,aAAa;AAAA,MACb,MAAM,CAAC,UAAU;AAAA,IACnB;AAAA,IACA,aAAa;AAAA,MACX,SAAS;AAAA,MACT,aAAa;AAAA,MACb,MAAM,CAAC,UAAU;AAAA,IACnB;AAAA,EACF;AACF,CAAC;AAGM,IAAM,wBAAwB,WAAW;AAAA,EAC9C,kBAAkB;AAAA,EAClB,oBAAoB;AAAA,EACpB,MAAM;AAAA,IACJ,YAAY;AAAA,MACV,QAAQ;AAAA,IACV;AAAA,IACA,cAAc;AAAA,MACZ,QAAQ;AAAA,IACV;AAAA,EACF;AACF,CAAC;","names":[]}
@@ -720,6 +720,20 @@ var PermissionNotFound = createKnownErrorConstructor(
720
720
  ],
721
721
  (json) => [json.permission_id]
722
722
  );
723
+ var PermissionScopeMismatch = createKnownErrorConstructor(
724
+ KnownError,
725
+ "WRONG_PERMISSION_SCOPE",
726
+ (permissionId, expectedScope, actualScope) => [
727
+ 404,
728
+ `Permission ${JSON.stringify(permissionId)} not found. (It was found for a different scope ${JSON.stringify(actualScope)}, but scope ${JSON.stringify(expectedScope)} was expected.)`,
729
+ {
730
+ permission_id: permissionId,
731
+ expected_scope: expectedScope,
732
+ actual_scope: actualScope
733
+ }
734
+ ],
735
+ (json) => [json.permission_id, json.expected_scope, json.actual_scope]
736
+ );
723
737
  var ContainedPermissionNotFound = createKnownErrorConstructor(
724
738
  KnownError,
725
739
  "CONTAINED_PERMISSION_NOT_FOUND",
@@ -1177,6 +1191,7 @@ var KnownErrors = {
1177
1191
  PasskeyWebAuthnError,
1178
1192
  PasskeyAuthenticationFailed,
1179
1193
  PermissionNotFound,
1194
+ PermissionScopeMismatch,
1180
1195
  ContainedPermissionNotFound,
1181
1196
  TeamNotFound,
1182
1197
  TeamMembershipNotFound,