@stackframe/stack-shared 2.8.22 → 2.8.27

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 (164) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/dist/config/format.d.mts +20 -5
  3. package/dist/config/format.d.ts +20 -5
  4. package/dist/config/format.js +39 -14
  5. package/dist/config/format.js.map +1 -1
  6. package/dist/config/schema.d.mts +816 -294
  7. package/dist/config/schema.d.ts +816 -294
  8. package/dist/config/schema.js +471 -82
  9. package/dist/config/schema.js.map +1 -1
  10. package/dist/crud.d.mts +1 -0
  11. package/dist/crud.d.ts +1 -0
  12. package/dist/esm/config/format.js +37 -14
  13. package/dist/esm/config/format.js.map +1 -1
  14. package/dist/esm/config/schema.js +460 -78
  15. package/dist/esm/config/schema.js.map +1 -1
  16. package/dist/esm/helpers/emails.js +185 -0
  17. package/dist/esm/helpers/emails.js.map +1 -0
  18. package/dist/esm/interface/admin-interface.js +58 -36
  19. package/dist/esm/interface/admin-interface.js.map +1 -1
  20. package/dist/esm/interface/client-interface.js +41 -0
  21. package/dist/esm/interface/client-interface.js.map +1 -1
  22. package/dist/esm/interface/crud/{oauth.js → connected-accounts.js} +2 -2
  23. package/dist/esm/interface/crud/connected-accounts.js.map +1 -0
  24. package/dist/esm/interface/crud/oauth-providers.js +87 -0
  25. package/dist/esm/interface/crud/oauth-providers.js.map +1 -0
  26. package/dist/esm/interface/crud/projects.js +7 -5
  27. package/dist/esm/interface/crud/projects.js.map +1 -1
  28. package/dist/esm/interface/server-interface.js +51 -0
  29. package/dist/esm/interface/server-interface.js.map +1 -1
  30. package/dist/esm/known-errors.js +34 -1
  31. package/dist/esm/known-errors.js.map +1 -1
  32. package/dist/esm/schema-fields.js +112 -24
  33. package/dist/esm/schema-fields.js.map +1 -1
  34. package/dist/esm/utils/currencies.js +52 -0
  35. package/dist/esm/utils/currencies.js.map +1 -0
  36. package/dist/esm/utils/dates.js +55 -1
  37. package/dist/esm/utils/dates.js.map +1 -1
  38. package/dist/esm/utils/errors.js.map +1 -1
  39. package/dist/esm/utils/esbuild.js +14 -4
  40. package/dist/esm/utils/esbuild.js.map +1 -1
  41. package/dist/esm/utils/oauth.js +1 -1
  42. package/dist/esm/utils/oauth.js.map +1 -1
  43. package/dist/esm/utils/objects.js +2 -0
  44. package/dist/esm/utils/objects.js.map +1 -1
  45. package/dist/esm/utils/strings.js +4 -0
  46. package/dist/esm/utils/strings.js.map +1 -1
  47. package/dist/esm/utils/types.js +45 -0
  48. package/dist/esm/utils/types.js.map +1 -1
  49. package/dist/helpers/emails.d.mts +50 -0
  50. package/dist/helpers/emails.d.ts +50 -0
  51. package/dist/helpers/emails.js +216 -0
  52. package/dist/helpers/emails.js.map +1 -0
  53. package/dist/helpers/password.d.mts +1 -0
  54. package/dist/helpers/password.d.ts +1 -0
  55. package/dist/helpers/production-mode.d.mts +1 -0
  56. package/dist/helpers/production-mode.d.ts +1 -0
  57. package/dist/index.d.mts +3 -3
  58. package/dist/index.d.ts +3 -3
  59. package/dist/interface/admin-interface.d.mts +24 -15
  60. package/dist/interface/admin-interface.d.ts +24 -15
  61. package/dist/interface/admin-interface.js +58 -36
  62. package/dist/interface/admin-interface.js.map +1 -1
  63. package/dist/interface/client-interface.d.mts +25 -1
  64. package/dist/interface/client-interface.d.ts +25 -1
  65. package/dist/interface/client-interface.js +41 -0
  66. package/dist/interface/client-interface.js.map +1 -1
  67. package/dist/interface/crud/{oauth.d.mts → connected-accounts.d.mts} +1 -0
  68. package/dist/interface/crud/{oauth.d.ts → connected-accounts.d.ts} +1 -0
  69. package/dist/interface/crud/{oauth.js → connected-accounts.js} +5 -5
  70. package/dist/interface/crud/connected-accounts.js.map +1 -0
  71. package/dist/interface/crud/contact-channels.d.mts +1 -0
  72. package/dist/interface/crud/contact-channels.d.ts +1 -0
  73. package/dist/interface/crud/current-user.d.mts +1 -0
  74. package/dist/interface/crud/current-user.d.ts +1 -0
  75. package/dist/interface/crud/email-templates.d.mts +1 -0
  76. package/dist/interface/crud/email-templates.d.ts +1 -0
  77. package/dist/interface/crud/emails.d.mts +1 -0
  78. package/dist/interface/crud/emails.d.ts +1 -0
  79. package/dist/interface/crud/internal-api-keys.d.mts +1 -0
  80. package/dist/interface/crud/internal-api-keys.d.ts +1 -0
  81. package/dist/interface/crud/notification-preferences.d.mts +1 -0
  82. package/dist/interface/crud/notification-preferences.d.ts +1 -0
  83. package/dist/interface/crud/oauth-providers.d.mts +173 -0
  84. package/dist/interface/crud/oauth-providers.d.ts +173 -0
  85. package/dist/interface/crud/oauth-providers.js +107 -0
  86. package/dist/interface/crud/oauth-providers.js.map +1 -0
  87. package/dist/interface/crud/project-api-keys.d.mts +1 -0
  88. package/dist/interface/crud/project-api-keys.d.ts +1 -0
  89. package/dist/interface/crud/project-permissions.d.mts +1 -0
  90. package/dist/interface/crud/project-permissions.d.ts +1 -0
  91. package/dist/interface/crud/projects.d.mts +16 -12
  92. package/dist/interface/crud/projects.d.ts +16 -12
  93. package/dist/interface/crud/projects.js +5 -3
  94. package/dist/interface/crud/projects.js.map +1 -1
  95. package/dist/interface/crud/sessions.d.mts +1 -0
  96. package/dist/interface/crud/sessions.d.ts +1 -0
  97. package/dist/interface/crud/svix-token.d.mts +1 -0
  98. package/dist/interface/crud/svix-token.d.ts +1 -0
  99. package/dist/interface/crud/team-invitation-details.d.mts +1 -0
  100. package/dist/interface/crud/team-invitation-details.d.ts +1 -0
  101. package/dist/interface/crud/team-invitation.d.mts +1 -0
  102. package/dist/interface/crud/team-invitation.d.ts +1 -0
  103. package/dist/interface/crud/team-member-profiles.d.mts +1 -0
  104. package/dist/interface/crud/team-member-profiles.d.ts +1 -0
  105. package/dist/interface/crud/team-memberships.d.mts +1 -0
  106. package/dist/interface/crud/team-memberships.d.ts +1 -0
  107. package/dist/interface/crud/team-permissions.d.mts +1 -0
  108. package/dist/interface/crud/team-permissions.d.ts +1 -0
  109. package/dist/interface/crud/teams.d.mts +1 -0
  110. package/dist/interface/crud/teams.d.ts +1 -0
  111. package/dist/interface/crud/users.d.mts +1 -0
  112. package/dist/interface/crud/users.d.ts +1 -0
  113. package/dist/interface/server-interface.d.mts +46 -1
  114. package/dist/interface/server-interface.d.ts +46 -1
  115. package/dist/interface/server-interface.js +51 -0
  116. package/dist/interface/server-interface.js.map +1 -1
  117. package/dist/known-errors.d.mts +9 -0
  118. package/dist/known-errors.d.ts +9 -0
  119. package/dist/known-errors.js +34 -1
  120. package/dist/known-errors.js.map +1 -1
  121. package/dist/schema-fields.d.mts +51 -7
  122. package/dist/schema-fields.d.ts +51 -7
  123. package/dist/schema-fields.js +128 -24
  124. package/dist/schema-fields.js.map +1 -1
  125. package/dist/utils/currencies.d.mts +39 -0
  126. package/dist/utils/currencies.d.ts +39 -0
  127. package/dist/utils/currencies.js +78 -0
  128. package/dist/utils/currencies.js.map +1 -0
  129. package/dist/utils/dates.d.mts +5 -1
  130. package/dist/utils/dates.d.ts +5 -1
  131. package/dist/utils/dates.js +58 -2
  132. package/dist/utils/dates.js.map +1 -1
  133. package/dist/utils/errors.d.mts +9 -0
  134. package/dist/utils/errors.d.ts +9 -0
  135. package/dist/utils/errors.js.map +1 -1
  136. package/dist/utils/esbuild.d.mts +3 -0
  137. package/dist/utils/esbuild.d.ts +3 -0
  138. package/dist/utils/esbuild.js +14 -4
  139. package/dist/utils/esbuild.js.map +1 -1
  140. package/dist/utils/oauth.d.mts +2 -2
  141. package/dist/utils/oauth.d.ts +2 -2
  142. package/dist/utils/oauth.js +1 -1
  143. package/dist/utils/oauth.js.map +1 -1
  144. package/dist/utils/objects.d.mts +23 -8
  145. package/dist/utils/objects.d.ts +23 -8
  146. package/dist/utils/objects.js +2 -0
  147. package/dist/utils/objects.js.map +1 -1
  148. package/dist/utils/strings.d.mts +3 -1
  149. package/dist/utils/strings.d.ts +3 -1
  150. package/dist/utils/strings.js +5 -0
  151. package/dist/utils/strings.js.map +1 -1
  152. package/dist/utils/types.d.mts +73 -2
  153. package/dist/utils/types.d.ts +73 -2
  154. package/dist/utils/types.js +54 -0
  155. package/dist/utils/types.js.map +1 -1
  156. package/package.json +1 -1
  157. package/dist/esm/helpers/email-themes.js +0 -45
  158. package/dist/esm/helpers/email-themes.js.map +0 -1
  159. package/dist/esm/interface/crud/oauth.js.map +0 -1
  160. package/dist/helpers/email-themes.d.mts +0 -13
  161. package/dist/helpers/email-themes.d.ts +0 -13
  162. package/dist/helpers/email-themes.js +0 -71
  163. package/dist/helpers/email-themes.js.map +0 -1
  164. package/dist/interface/crud/oauth.js.map +0 -1
@@ -1,4 +1,6 @@
1
1
  import * as yup from 'yup';
2
+ import { Currency } from './utils/currencies.mjs';
3
+ import { Interval, DayInterval } from './utils/dates.mjs';
2
4
 
3
5
  declare module "yup" {
4
6
  interface StringSchema<TType, TContext, TDefault, TFlags> {
@@ -6,8 +8,24 @@ declare module "yup" {
6
8
  empty(): StringSchema<TType, TContext, TDefault, TFlags>;
7
9
  }
8
10
  interface Schema<TType, TContext, TDefault, TFlags> {
11
+ hasNested<K extends keyof NonNullable<TType>>(path: K): boolean;
9
12
  getNested<K extends keyof NonNullable<TType>>(path: K): yup.Schema<NonNullable<TType>[K], TContext, TDefault, TFlags>;
10
- concat<U extends yup.AnySchema>(schema: U): yup.Schema<Omit<NonNullable<TType>, keyof yup.InferType<U>> & yup.InferType<U> | (TType & (null | undefined)), TContext, TDefault, TFlags>;
13
+ concat<U extends yup.AnySchema>(schema: U): yup.Schema<Omit<NonNullable<TType>, keyof yup.InferType<U>> & yup.InferType<U> | (TType & (null | undefined)), TContext, Omit<NonNullable<TDefault>, keyof U['__default']> & U['__default'] | (TDefault & (null | undefined)), TFlags>;
14
+ }
15
+ interface CustomSchemaMetadata {
16
+ stackSchemaInfo?: {
17
+ type: "object" | "array" | "string" | "number" | "boolean" | "date" | "mixed" | "never";
18
+ } | {
19
+ type: "tuple";
20
+ items: yup.AnySchema[];
21
+ } | {
22
+ type: "union";
23
+ items: yup.AnySchema[];
24
+ } | {
25
+ type: "record";
26
+ keySchema: yup.StringSchema<any>;
27
+ valueSchema: yup.AnySchema;
28
+ };
11
29
  }
12
30
  }
13
31
  declare function yupValidate<S extends yup.ISchema<any>>(schema: S, obj: unknown, options?: yup.ValidateOptions & {
@@ -24,11 +42,14 @@ declare function yupBoolean<A extends boolean, B extends yup.Maybe<yup.AnyObject
24
42
  declare function yupDate<A extends Date, B extends yup.Maybe<yup.AnyObject> = yup.AnyObject>(...args: Parameters<typeof yup.date<A, B>>): yup.DateSchema<Date | undefined, yup.AnyObject, undefined, "">;
25
43
  declare function yupMixed<A extends {}>(...args: Parameters<typeof yup.mixed<A>>): yup.MixedSchema<A | undefined, yup.AnyObject, undefined, "">;
26
44
  declare function yupArray<A extends yup.Maybe<yup.AnyObject> = yup.AnyObject, B = any>(...args: Parameters<typeof yup.array<A, B>>): yup.ArraySchema<B[] | undefined, A, undefined, "">;
27
- declare function yupTuple<T extends [unknown, ...unknown[]]>(...args: Parameters<typeof yup.tuple<T>>): yup.TupleSchema<T | undefined, yup.AnyObject, undefined, "">;
45
+ declare function yupTuple<T extends [unknown, ...unknown[]]>(schemas: {
46
+ [K in keyof T]: yup.Schema<T[K]>;
47
+ }): yup.TupleSchema<T | undefined, yup.AnyObject, undefined, "">;
48
+ declare function yupObjectWithAutoDefault<A extends yup.Maybe<yup.AnyObject>, B extends yup.ObjectShape>(...args: Parameters<typeof yup.object<A, B>>): yup.ObjectSchema<yup.TypeFromShape<B, yup.AnyObject> extends infer T ? T extends yup.TypeFromShape<B, yup.AnyObject> ? T extends {} ? { [k in keyof T]: T[k]; } : T : never : never, yup.AnyObject, yup.DefaultFromShape<B> extends infer T_1 ? T_1 extends yup.DefaultFromShape<B> ? T_1 extends {} ? { [k_1 in keyof T_1]: T_1[k_1]; } : T_1 : never : never, "">;
28
49
  declare function yupObject<A extends yup.Maybe<yup.AnyObject>, B extends yup.ObjectShape>(...args: Parameters<typeof yup.object<A, B>>): yup.ObjectSchema<yup.TypeFromShape<B, yup.AnyObject> extends infer T ? T extends yup.TypeFromShape<B, yup.AnyObject> ? T extends {} ? { [k in keyof T]: T[k]; } : T : never : never, yup.AnyObject, yup.DefaultFromShape<B> extends infer T_1 ? T_1 extends yup.DefaultFromShape<B> ? T_1 extends {} ? { [k_1 in keyof T_1]: T_1[k_1]; } : T_1 : never : never, "">;
29
50
  declare function yupNever(): yup.MixedSchema<never>;
30
- declare function yupUnion<T extends yup.ISchema<any>[]>(...args: T): yup.MixedSchema<yup.InferType<T[number]>>;
31
- declare function yupRecord<K extends yup.StringSchema, T extends yup.AnySchema>(keySchema: K, valueSchema: T): yup.MixedSchema<Record<string, yup.InferType<T>>>;
51
+ declare function yupUnion<T extends yup.AnySchema[]>(...args: T): yup.MixedSchema<yup.InferType<T[number]>>;
52
+ declare function yupRecord<K extends yup.StringSchema, T extends yup.AnySchema>(keySchema: K, valueSchema: T): yup.MixedSchema<Record<yup.InferType<K> & string, yup.InferType<T>>>;
32
53
  declare function ensureObjectSchema<T extends yup.AnyObject>(schema: yup.Schema<T>): yup.ObjectSchema<T> & typeof schema;
33
54
  declare const adaptSchema: yup.MixedSchema<typeof StackAdaptSentinel | undefined, yup.AnyObject, undefined, "">;
34
55
  /**
@@ -40,6 +61,16 @@ declare const jsonStringSchema: yup.StringSchema<string | undefined, yup.AnyObje
40
61
  declare const jsonStringOrEmptySchema: yup.StringSchema<string | undefined, yup.AnyObject, undefined, "">;
41
62
  declare const base64Schema: yup.StringSchema<string | undefined, yup.AnyObject, undefined, "">;
42
63
  declare const passwordSchema: yup.StringSchema<string | undefined, yup.AnyObject, undefined, "">;
64
+ declare const intervalSchema: yup.TupleSchema<Interval | undefined, yup.AnyObject, undefined, "">;
65
+ declare const dayIntervalSchema: yup.TupleSchema<DayInterval | undefined, yup.AnyObject, undefined, "">;
66
+ declare const intervalOrNeverSchema: yup.MixedSchema<"never" | Interval, yup.AnyObject, undefined, "">;
67
+ declare const dayIntervalOrNeverSchema: yup.MixedSchema<"never" | DayInterval, yup.AnyObject, undefined, "">;
68
+ /**
69
+ * This schema is useful for fields where the user can specify the ID, such as price IDs. It is particularly common
70
+ * for IDs in the config schema.
71
+ */
72
+ declare const userSpecifiedIdSchema: (idName: `${string}Id`) => yup.StringSchema<string | undefined, yup.AnyObject, undefined, "">;
73
+ declare const moneyAmountSchema: (currency: Currency) => yup.StringSchema<string | undefined, yup.AnyObject, undefined, "">;
43
74
  /**
44
75
  * A stricter email schema that does some additional checks for UX input. (Some emails are allowed by the spec, for
45
76
  * example `test@localhost` or `abc@gmail`, but almost certainly a user input error.)
@@ -67,7 +98,7 @@ declare const projectClientTeamCreationEnabledSchema: yup.BooleanSchema<boolean
67
98
  declare const projectClientUserDeletionEnabledSchema: yup.BooleanSchema<boolean | undefined, yup.AnyObject, undefined, "">;
68
99
  declare const projectSignUpEnabledSchema: yup.BooleanSchema<boolean | undefined, yup.AnyObject, undefined, "">;
69
100
  declare const projectCredentialEnabledSchema: yup.BooleanSchema<boolean | undefined, yup.AnyObject, undefined, "">;
70
- declare const oauthIdSchema: yup.StringSchema<"apple" | "x" | "google" | "github" | "microsoft" | "spotify" | "facebook" | "discord" | "gitlab" | "bitbucket" | "linkedin" | undefined, yup.AnyObject, undefined, "">;
101
+ declare const oauthIdSchema: yup.StringSchema<"apple" | "x" | "google" | "github" | "microsoft" | "spotify" | "facebook" | "discord" | "gitlab" | "bitbucket" | "linkedin" | "twitch" | undefined, yup.AnyObject, undefined, "">;
71
102
  declare const oauthEnabledSchema: yup.BooleanSchema<boolean | undefined, yup.AnyObject, undefined, "">;
72
103
  declare const oauthTypeSchema: yup.StringSchema<"shared" | "standard" | undefined, yup.AnyObject, undefined, "">;
73
104
  declare const oauthClientIdSchema: yup.StringSchema<string | undefined, yup.AnyObject, undefined, "">;
@@ -88,6 +119,13 @@ declare const emailThemeListSchema: yup.MixedSchema<Record<string, {
88
119
  displayName: string;
89
120
  tsxSource: string;
90
121
  }>, yup.AnyObject, undefined, "">;
122
+ declare const templateThemeIdSchema: yup.MixedSchema<string | false | undefined, yup.AnyObject, undefined, "">;
123
+ declare const emailTemplateListSchema: yup.MixedSchema<Record<string, {
124
+ themeId?: string | false | undefined;
125
+ displayName: string;
126
+ tsxSource: string;
127
+ }>, yup.AnyObject, undefined, "">;
128
+ declare const customerTypeSchema: yup.StringSchema<"user" | "team" | "organization" | undefined, yup.AnyObject, undefined, "">;
91
129
  declare class ReplaceFieldWithOwnUserId extends Error {
92
130
  readonly path: string;
93
131
  constructor(path: string);
@@ -106,7 +144,7 @@ declare const userClientReadOnlyMetadataSchema: yup.MixedSchema<{} | null, yup.A
106
144
  declare const userServerMetadataSchema: yup.MixedSchema<{} | null, yup.AnyObject, undefined, "">;
107
145
  declare const userOAuthProviderSchema: yup.ObjectSchema<{
108
146
  id: string;
109
- type: "apple" | "x" | "google" | "github" | "microsoft" | "spotify" | "facebook" | "discord" | "gitlab" | "bitbucket" | "linkedin";
147
+ type: "apple" | "x" | "google" | "github" | "microsoft" | "spotify" | "facebook" | "discord" | "gitlab" | "bitbucket" | "linkedin" | "twitch";
110
148
  provider_user_id: string;
111
149
  }, yup.AnyObject, {
112
150
  id: undefined;
@@ -160,9 +198,15 @@ declare const contactChannelValueSchema: yup.StringSchema<string | undefined, yu
160
198
  declare const contactChannelUsedForAuthSchema: yup.BooleanSchema<boolean | undefined, yup.AnyObject, undefined, "">;
161
199
  declare const contactChannelIsVerifiedSchema: yup.BooleanSchema<boolean | undefined, yup.AnyObject, undefined, "">;
162
200
  declare const contactChannelIsPrimarySchema: yup.BooleanSchema<boolean | undefined, yup.AnyObject, undefined, "">;
201
+ declare const oauthProviderIdSchema: yup.StringSchema<string | undefined, yup.AnyObject, undefined, "">;
202
+ declare const oauthProviderEmailSchema: yup.StringSchema<string | undefined, yup.AnyObject, undefined, "">;
203
+ declare const oauthProviderTypeSchema: yup.StringSchema<"apple" | "x" | "google" | "github" | "microsoft" | "spotify" | "facebook" | "discord" | "gitlab" | "bitbucket" | "linkedin" | "twitch" | undefined, yup.AnyObject, undefined, "">;
204
+ declare const oauthProviderAllowSignInSchema: yup.BooleanSchema<boolean | undefined, yup.AnyObject, undefined, "">;
205
+ declare const oauthProviderAllowConnectedAccountsSchema: yup.BooleanSchema<boolean | undefined, yup.AnyObject, undefined, "">;
206
+ declare const oauthProviderAccountIdSchema: yup.StringSchema<string | undefined, yup.AnyObject, undefined, "">;
163
207
  declare const basicAuthorizationHeaderSchema: yup.StringSchema<string | undefined, yup.AnyObject, undefined, "">;
164
208
  declare const neonAuthorizationHeaderSchema: yup.StringSchema<string | undefined, yup.AnyObject, undefined, "">;
165
209
  declare function yupDefinedWhen<S extends yup.AnyObject>(schema: S, triggers: Record<string, any>): S;
166
210
  declare function yupDefinedAndNonEmptyWhen<S extends yup.StringSchema>(schema: S, triggers: Record<string, any>): S;
167
211
 
168
- export { ReplaceFieldWithOwnUserId, StackAdaptSentinel, accessTokenResponseSchema, adaptSchema, adminAuthTypeSchema, base64Schema, basicAuthorizationHeaderSchema, clientOrHigherAuthTypeSchema, contactChannelIdSchema, contactChannelIsPrimarySchema, contactChannelIsVerifiedSchema, contactChannelTypeSchema, contactChannelUsedForAuthSchema, contactChannelValueSchema, containedPermissionIdsSchema, customPermissionDefinitionIdSchema, emailHostSchema, emailOtpSignInCallbackUrlSchema, emailPasswordSchema, emailPortSchema, emailSchema, emailSenderEmailSchema, emailSenderNameSchema, emailThemeListSchema, emailThemeSchema, emailTypeSchema, emailUsernameSchema, emailVerificationCallbackUrlSchema, ensureObjectSchema, handlerPathSchema, jsonSchema, jsonStringOrEmptySchema, jsonStringSchema, neonAuthorizationHeaderSchema, oauthAccountMergeStrategySchema, oauthClientIdSchema, oauthClientSecretSchema, oauthEnabledSchema, oauthFacebookConfigIdSchema, oauthIdSchema, oauthMicrosoftTenantIdSchema, oauthTypeSchema, passwordSchema, permissionDefinitionIdSchema, primaryEmailAuthEnabledSchema, primaryEmailSchema, primaryEmailVerifiedSchema, profileImageUrlSchema, projectAllowLocalhostSchema, projectBranchIdSchema, projectClientTeamCreationEnabledSchema, projectClientUserDeletionEnabledSchema, projectConfigIdSchema, projectCreateTeamOnSignUpSchema, projectCreatedAtMillisSchema, projectCredentialEnabledSchema, projectDescriptionSchema, projectDisplayNameSchema, projectIdSchema, projectIsProductionModeSchema, projectMagicLinkEnabledSchema, projectPasskeyEnabledSchema, projectSignUpEnabledSchema, refreshTokenResponseSchema, selectedTeamIdSchema, serverOrHigherAuthTypeSchema, signInEmailSchema, signInResponseSchema, signedUpAtMillisSchema, strictEmailSchema, teamClientMetadataSchema, teamClientReadOnlyMetadataSchema, teamCreatedAtMillisSchema, teamCreatorUserIdSchema, teamDisplayNameSchema, teamIdSchema, teamInvitationCallbackUrlSchema, teamInvitationEmailSchema, teamMemberDisplayNameSchema, teamMemberProfileImageUrlSchema, teamPermissionDescriptionSchema, teamProfileImageUrlSchema, teamServerMetadataSchema, teamSystemPermissions, urlSchema, userClientMetadataSchema, userClientReadOnlyMetadataSchema, userDisplayNameSchema, userHasPasswordSchema, userIdOrMeSchema, userIdSchema, userLastActiveAtMillisSchema, userOAuthProviderSchema, userOtpAuthEnabledMutationSchema, userOtpAuthEnabledSchema, userPasskeyAuthEnabledSchema, userPasswordHashMutationSchema, userPasswordMutationSchema, userServerMetadataSchema, userTotpSecretMutationSchema, yupArray, yupBoolean, yupDate, yupDefinedAndNonEmptyWhen, yupDefinedWhen, yupMixed, yupNever, yupNumber, yupObject, yupRecord, yupString, yupTuple, yupUnion, yupValidate };
212
+ export { ReplaceFieldWithOwnUserId, StackAdaptSentinel, accessTokenResponseSchema, adaptSchema, adminAuthTypeSchema, base64Schema, basicAuthorizationHeaderSchema, clientOrHigherAuthTypeSchema, contactChannelIdSchema, contactChannelIsPrimarySchema, contactChannelIsVerifiedSchema, contactChannelTypeSchema, contactChannelUsedForAuthSchema, contactChannelValueSchema, containedPermissionIdsSchema, customPermissionDefinitionIdSchema, customerTypeSchema, dayIntervalOrNeverSchema, dayIntervalSchema, emailHostSchema, emailOtpSignInCallbackUrlSchema, emailPasswordSchema, emailPortSchema, emailSchema, emailSenderEmailSchema, emailSenderNameSchema, emailTemplateListSchema, emailThemeListSchema, emailThemeSchema, emailTypeSchema, emailUsernameSchema, emailVerificationCallbackUrlSchema, ensureObjectSchema, handlerPathSchema, intervalOrNeverSchema, intervalSchema, jsonSchema, jsonStringOrEmptySchema, jsonStringSchema, moneyAmountSchema, neonAuthorizationHeaderSchema, oauthAccountMergeStrategySchema, oauthClientIdSchema, oauthClientSecretSchema, oauthEnabledSchema, oauthFacebookConfigIdSchema, oauthIdSchema, oauthMicrosoftTenantIdSchema, oauthProviderAccountIdSchema, oauthProviderAllowConnectedAccountsSchema, oauthProviderAllowSignInSchema, oauthProviderEmailSchema, oauthProviderIdSchema, oauthProviderTypeSchema, oauthTypeSchema, passwordSchema, permissionDefinitionIdSchema, primaryEmailAuthEnabledSchema, primaryEmailSchema, primaryEmailVerifiedSchema, profileImageUrlSchema, projectAllowLocalhostSchema, projectBranchIdSchema, projectClientTeamCreationEnabledSchema, projectClientUserDeletionEnabledSchema, projectConfigIdSchema, projectCreateTeamOnSignUpSchema, projectCreatedAtMillisSchema, projectCredentialEnabledSchema, projectDescriptionSchema, projectDisplayNameSchema, projectIdSchema, projectIsProductionModeSchema, projectMagicLinkEnabledSchema, projectPasskeyEnabledSchema, projectSignUpEnabledSchema, refreshTokenResponseSchema, selectedTeamIdSchema, serverOrHigherAuthTypeSchema, signInEmailSchema, signInResponseSchema, signedUpAtMillisSchema, strictEmailSchema, teamClientMetadataSchema, teamClientReadOnlyMetadataSchema, teamCreatedAtMillisSchema, teamCreatorUserIdSchema, teamDisplayNameSchema, teamIdSchema, teamInvitationCallbackUrlSchema, teamInvitationEmailSchema, teamMemberDisplayNameSchema, teamMemberProfileImageUrlSchema, teamPermissionDescriptionSchema, teamProfileImageUrlSchema, teamServerMetadataSchema, teamSystemPermissions, templateThemeIdSchema, urlSchema, userClientMetadataSchema, userClientReadOnlyMetadataSchema, userDisplayNameSchema, userHasPasswordSchema, userIdOrMeSchema, userIdSchema, userLastActiveAtMillisSchema, userOAuthProviderSchema, userOtpAuthEnabledMutationSchema, userOtpAuthEnabledSchema, userPasskeyAuthEnabledSchema, userPasswordHashMutationSchema, userPasswordMutationSchema, userServerMetadataSchema, userSpecifiedIdSchema, userTotpSecretMutationSchema, yupArray, yupBoolean, yupDate, yupDefinedAndNonEmptyWhen, yupDefinedWhen, yupMixed, yupNever, yupNumber, yupObject, yupObjectWithAutoDefault, yupRecord, yupString, yupTuple, yupUnion, yupValidate };
@@ -1,4 +1,6 @@
1
1
  import * as yup from 'yup';
2
+ import { Currency } from './utils/currencies.js';
3
+ import { Interval, DayInterval } from './utils/dates.js';
2
4
 
3
5
  declare module "yup" {
4
6
  interface StringSchema<TType, TContext, TDefault, TFlags> {
@@ -6,8 +8,24 @@ declare module "yup" {
6
8
  empty(): StringSchema<TType, TContext, TDefault, TFlags>;
7
9
  }
8
10
  interface Schema<TType, TContext, TDefault, TFlags> {
11
+ hasNested<K extends keyof NonNullable<TType>>(path: K): boolean;
9
12
  getNested<K extends keyof NonNullable<TType>>(path: K): yup.Schema<NonNullable<TType>[K], TContext, TDefault, TFlags>;
10
- concat<U extends yup.AnySchema>(schema: U): yup.Schema<Omit<NonNullable<TType>, keyof yup.InferType<U>> & yup.InferType<U> | (TType & (null | undefined)), TContext, TDefault, TFlags>;
13
+ concat<U extends yup.AnySchema>(schema: U): yup.Schema<Omit<NonNullable<TType>, keyof yup.InferType<U>> & yup.InferType<U> | (TType & (null | undefined)), TContext, Omit<NonNullable<TDefault>, keyof U['__default']> & U['__default'] | (TDefault & (null | undefined)), TFlags>;
14
+ }
15
+ interface CustomSchemaMetadata {
16
+ stackSchemaInfo?: {
17
+ type: "object" | "array" | "string" | "number" | "boolean" | "date" | "mixed" | "never";
18
+ } | {
19
+ type: "tuple";
20
+ items: yup.AnySchema[];
21
+ } | {
22
+ type: "union";
23
+ items: yup.AnySchema[];
24
+ } | {
25
+ type: "record";
26
+ keySchema: yup.StringSchema<any>;
27
+ valueSchema: yup.AnySchema;
28
+ };
11
29
  }
12
30
  }
13
31
  declare function yupValidate<S extends yup.ISchema<any>>(schema: S, obj: unknown, options?: yup.ValidateOptions & {
@@ -24,11 +42,14 @@ declare function yupBoolean<A extends boolean, B extends yup.Maybe<yup.AnyObject
24
42
  declare function yupDate<A extends Date, B extends yup.Maybe<yup.AnyObject> = yup.AnyObject>(...args: Parameters<typeof yup.date<A, B>>): yup.DateSchema<Date | undefined, yup.AnyObject, undefined, "">;
25
43
  declare function yupMixed<A extends {}>(...args: Parameters<typeof yup.mixed<A>>): yup.MixedSchema<A | undefined, yup.AnyObject, undefined, "">;
26
44
  declare function yupArray<A extends yup.Maybe<yup.AnyObject> = yup.AnyObject, B = any>(...args: Parameters<typeof yup.array<A, B>>): yup.ArraySchema<B[] | undefined, A, undefined, "">;
27
- declare function yupTuple<T extends [unknown, ...unknown[]]>(...args: Parameters<typeof yup.tuple<T>>): yup.TupleSchema<T | undefined, yup.AnyObject, undefined, "">;
45
+ declare function yupTuple<T extends [unknown, ...unknown[]]>(schemas: {
46
+ [K in keyof T]: yup.Schema<T[K]>;
47
+ }): yup.TupleSchema<T | undefined, yup.AnyObject, undefined, "">;
48
+ declare function yupObjectWithAutoDefault<A extends yup.Maybe<yup.AnyObject>, B extends yup.ObjectShape>(...args: Parameters<typeof yup.object<A, B>>): yup.ObjectSchema<yup.TypeFromShape<B, yup.AnyObject> extends infer T ? T extends yup.TypeFromShape<B, yup.AnyObject> ? T extends {} ? { [k in keyof T]: T[k]; } : T : never : never, yup.AnyObject, yup.DefaultFromShape<B> extends infer T_1 ? T_1 extends yup.DefaultFromShape<B> ? T_1 extends {} ? { [k_1 in keyof T_1]: T_1[k_1]; } : T_1 : never : never, "">;
28
49
  declare function yupObject<A extends yup.Maybe<yup.AnyObject>, B extends yup.ObjectShape>(...args: Parameters<typeof yup.object<A, B>>): yup.ObjectSchema<yup.TypeFromShape<B, yup.AnyObject> extends infer T ? T extends yup.TypeFromShape<B, yup.AnyObject> ? T extends {} ? { [k in keyof T]: T[k]; } : T : never : never, yup.AnyObject, yup.DefaultFromShape<B> extends infer T_1 ? T_1 extends yup.DefaultFromShape<B> ? T_1 extends {} ? { [k_1 in keyof T_1]: T_1[k_1]; } : T_1 : never : never, "">;
29
50
  declare function yupNever(): yup.MixedSchema<never>;
30
- declare function yupUnion<T extends yup.ISchema<any>[]>(...args: T): yup.MixedSchema<yup.InferType<T[number]>>;
31
- declare function yupRecord<K extends yup.StringSchema, T extends yup.AnySchema>(keySchema: K, valueSchema: T): yup.MixedSchema<Record<string, yup.InferType<T>>>;
51
+ declare function yupUnion<T extends yup.AnySchema[]>(...args: T): yup.MixedSchema<yup.InferType<T[number]>>;
52
+ declare function yupRecord<K extends yup.StringSchema, T extends yup.AnySchema>(keySchema: K, valueSchema: T): yup.MixedSchema<Record<yup.InferType<K> & string, yup.InferType<T>>>;
32
53
  declare function ensureObjectSchema<T extends yup.AnyObject>(schema: yup.Schema<T>): yup.ObjectSchema<T> & typeof schema;
33
54
  declare const adaptSchema: yup.MixedSchema<typeof StackAdaptSentinel | undefined, yup.AnyObject, undefined, "">;
34
55
  /**
@@ -40,6 +61,16 @@ declare const jsonStringSchema: yup.StringSchema<string | undefined, yup.AnyObje
40
61
  declare const jsonStringOrEmptySchema: yup.StringSchema<string | undefined, yup.AnyObject, undefined, "">;
41
62
  declare const base64Schema: yup.StringSchema<string | undefined, yup.AnyObject, undefined, "">;
42
63
  declare const passwordSchema: yup.StringSchema<string | undefined, yup.AnyObject, undefined, "">;
64
+ declare const intervalSchema: yup.TupleSchema<Interval | undefined, yup.AnyObject, undefined, "">;
65
+ declare const dayIntervalSchema: yup.TupleSchema<DayInterval | undefined, yup.AnyObject, undefined, "">;
66
+ declare const intervalOrNeverSchema: yup.MixedSchema<"never" | Interval, yup.AnyObject, undefined, "">;
67
+ declare const dayIntervalOrNeverSchema: yup.MixedSchema<"never" | DayInterval, yup.AnyObject, undefined, "">;
68
+ /**
69
+ * This schema is useful for fields where the user can specify the ID, such as price IDs. It is particularly common
70
+ * for IDs in the config schema.
71
+ */
72
+ declare const userSpecifiedIdSchema: (idName: `${string}Id`) => yup.StringSchema<string | undefined, yup.AnyObject, undefined, "">;
73
+ declare const moneyAmountSchema: (currency: Currency) => yup.StringSchema<string | undefined, yup.AnyObject, undefined, "">;
43
74
  /**
44
75
  * A stricter email schema that does some additional checks for UX input. (Some emails are allowed by the spec, for
45
76
  * example `test@localhost` or `abc@gmail`, but almost certainly a user input error.)
@@ -67,7 +98,7 @@ declare const projectClientTeamCreationEnabledSchema: yup.BooleanSchema<boolean
67
98
  declare const projectClientUserDeletionEnabledSchema: yup.BooleanSchema<boolean | undefined, yup.AnyObject, undefined, "">;
68
99
  declare const projectSignUpEnabledSchema: yup.BooleanSchema<boolean | undefined, yup.AnyObject, undefined, "">;
69
100
  declare const projectCredentialEnabledSchema: yup.BooleanSchema<boolean | undefined, yup.AnyObject, undefined, "">;
70
- declare const oauthIdSchema: yup.StringSchema<"apple" | "x" | "google" | "github" | "microsoft" | "spotify" | "facebook" | "discord" | "gitlab" | "bitbucket" | "linkedin" | undefined, yup.AnyObject, undefined, "">;
101
+ declare const oauthIdSchema: yup.StringSchema<"apple" | "x" | "google" | "github" | "microsoft" | "spotify" | "facebook" | "discord" | "gitlab" | "bitbucket" | "linkedin" | "twitch" | undefined, yup.AnyObject, undefined, "">;
71
102
  declare const oauthEnabledSchema: yup.BooleanSchema<boolean | undefined, yup.AnyObject, undefined, "">;
72
103
  declare const oauthTypeSchema: yup.StringSchema<"shared" | "standard" | undefined, yup.AnyObject, undefined, "">;
73
104
  declare const oauthClientIdSchema: yup.StringSchema<string | undefined, yup.AnyObject, undefined, "">;
@@ -88,6 +119,13 @@ declare const emailThemeListSchema: yup.MixedSchema<Record<string, {
88
119
  displayName: string;
89
120
  tsxSource: string;
90
121
  }>, yup.AnyObject, undefined, "">;
122
+ declare const templateThemeIdSchema: yup.MixedSchema<string | false | undefined, yup.AnyObject, undefined, "">;
123
+ declare const emailTemplateListSchema: yup.MixedSchema<Record<string, {
124
+ themeId?: string | false | undefined;
125
+ displayName: string;
126
+ tsxSource: string;
127
+ }>, yup.AnyObject, undefined, "">;
128
+ declare const customerTypeSchema: yup.StringSchema<"user" | "team" | "organization" | undefined, yup.AnyObject, undefined, "">;
91
129
  declare class ReplaceFieldWithOwnUserId extends Error {
92
130
  readonly path: string;
93
131
  constructor(path: string);
@@ -106,7 +144,7 @@ declare const userClientReadOnlyMetadataSchema: yup.MixedSchema<{} | null, yup.A
106
144
  declare const userServerMetadataSchema: yup.MixedSchema<{} | null, yup.AnyObject, undefined, "">;
107
145
  declare const userOAuthProviderSchema: yup.ObjectSchema<{
108
146
  id: string;
109
- type: "apple" | "x" | "google" | "github" | "microsoft" | "spotify" | "facebook" | "discord" | "gitlab" | "bitbucket" | "linkedin";
147
+ type: "apple" | "x" | "google" | "github" | "microsoft" | "spotify" | "facebook" | "discord" | "gitlab" | "bitbucket" | "linkedin" | "twitch";
110
148
  provider_user_id: string;
111
149
  }, yup.AnyObject, {
112
150
  id: undefined;
@@ -160,9 +198,15 @@ declare const contactChannelValueSchema: yup.StringSchema<string | undefined, yu
160
198
  declare const contactChannelUsedForAuthSchema: yup.BooleanSchema<boolean | undefined, yup.AnyObject, undefined, "">;
161
199
  declare const contactChannelIsVerifiedSchema: yup.BooleanSchema<boolean | undefined, yup.AnyObject, undefined, "">;
162
200
  declare const contactChannelIsPrimarySchema: yup.BooleanSchema<boolean | undefined, yup.AnyObject, undefined, "">;
201
+ declare const oauthProviderIdSchema: yup.StringSchema<string | undefined, yup.AnyObject, undefined, "">;
202
+ declare const oauthProviderEmailSchema: yup.StringSchema<string | undefined, yup.AnyObject, undefined, "">;
203
+ declare const oauthProviderTypeSchema: yup.StringSchema<"apple" | "x" | "google" | "github" | "microsoft" | "spotify" | "facebook" | "discord" | "gitlab" | "bitbucket" | "linkedin" | "twitch" | undefined, yup.AnyObject, undefined, "">;
204
+ declare const oauthProviderAllowSignInSchema: yup.BooleanSchema<boolean | undefined, yup.AnyObject, undefined, "">;
205
+ declare const oauthProviderAllowConnectedAccountsSchema: yup.BooleanSchema<boolean | undefined, yup.AnyObject, undefined, "">;
206
+ declare const oauthProviderAccountIdSchema: yup.StringSchema<string | undefined, yup.AnyObject, undefined, "">;
163
207
  declare const basicAuthorizationHeaderSchema: yup.StringSchema<string | undefined, yup.AnyObject, undefined, "">;
164
208
  declare const neonAuthorizationHeaderSchema: yup.StringSchema<string | undefined, yup.AnyObject, undefined, "">;
165
209
  declare function yupDefinedWhen<S extends yup.AnyObject>(schema: S, triggers: Record<string, any>): S;
166
210
  declare function yupDefinedAndNonEmptyWhen<S extends yup.StringSchema>(schema: S, triggers: Record<string, any>): S;
167
211
 
168
- export { ReplaceFieldWithOwnUserId, StackAdaptSentinel, accessTokenResponseSchema, adaptSchema, adminAuthTypeSchema, base64Schema, basicAuthorizationHeaderSchema, clientOrHigherAuthTypeSchema, contactChannelIdSchema, contactChannelIsPrimarySchema, contactChannelIsVerifiedSchema, contactChannelTypeSchema, contactChannelUsedForAuthSchema, contactChannelValueSchema, containedPermissionIdsSchema, customPermissionDefinitionIdSchema, emailHostSchema, emailOtpSignInCallbackUrlSchema, emailPasswordSchema, emailPortSchema, emailSchema, emailSenderEmailSchema, emailSenderNameSchema, emailThemeListSchema, emailThemeSchema, emailTypeSchema, emailUsernameSchema, emailVerificationCallbackUrlSchema, ensureObjectSchema, handlerPathSchema, jsonSchema, jsonStringOrEmptySchema, jsonStringSchema, neonAuthorizationHeaderSchema, oauthAccountMergeStrategySchema, oauthClientIdSchema, oauthClientSecretSchema, oauthEnabledSchema, oauthFacebookConfigIdSchema, oauthIdSchema, oauthMicrosoftTenantIdSchema, oauthTypeSchema, passwordSchema, permissionDefinitionIdSchema, primaryEmailAuthEnabledSchema, primaryEmailSchema, primaryEmailVerifiedSchema, profileImageUrlSchema, projectAllowLocalhostSchema, projectBranchIdSchema, projectClientTeamCreationEnabledSchema, projectClientUserDeletionEnabledSchema, projectConfigIdSchema, projectCreateTeamOnSignUpSchema, projectCreatedAtMillisSchema, projectCredentialEnabledSchema, projectDescriptionSchema, projectDisplayNameSchema, projectIdSchema, projectIsProductionModeSchema, projectMagicLinkEnabledSchema, projectPasskeyEnabledSchema, projectSignUpEnabledSchema, refreshTokenResponseSchema, selectedTeamIdSchema, serverOrHigherAuthTypeSchema, signInEmailSchema, signInResponseSchema, signedUpAtMillisSchema, strictEmailSchema, teamClientMetadataSchema, teamClientReadOnlyMetadataSchema, teamCreatedAtMillisSchema, teamCreatorUserIdSchema, teamDisplayNameSchema, teamIdSchema, teamInvitationCallbackUrlSchema, teamInvitationEmailSchema, teamMemberDisplayNameSchema, teamMemberProfileImageUrlSchema, teamPermissionDescriptionSchema, teamProfileImageUrlSchema, teamServerMetadataSchema, teamSystemPermissions, urlSchema, userClientMetadataSchema, userClientReadOnlyMetadataSchema, userDisplayNameSchema, userHasPasswordSchema, userIdOrMeSchema, userIdSchema, userLastActiveAtMillisSchema, userOAuthProviderSchema, userOtpAuthEnabledMutationSchema, userOtpAuthEnabledSchema, userPasskeyAuthEnabledSchema, userPasswordHashMutationSchema, userPasswordMutationSchema, userServerMetadataSchema, userTotpSecretMutationSchema, yupArray, yupBoolean, yupDate, yupDefinedAndNonEmptyWhen, yupDefinedWhen, yupMixed, yupNever, yupNumber, yupObject, yupRecord, yupString, yupTuple, yupUnion, yupValidate };
212
+ export { ReplaceFieldWithOwnUserId, StackAdaptSentinel, accessTokenResponseSchema, adaptSchema, adminAuthTypeSchema, base64Schema, basicAuthorizationHeaderSchema, clientOrHigherAuthTypeSchema, contactChannelIdSchema, contactChannelIsPrimarySchema, contactChannelIsVerifiedSchema, contactChannelTypeSchema, contactChannelUsedForAuthSchema, contactChannelValueSchema, containedPermissionIdsSchema, customPermissionDefinitionIdSchema, customerTypeSchema, dayIntervalOrNeverSchema, dayIntervalSchema, emailHostSchema, emailOtpSignInCallbackUrlSchema, emailPasswordSchema, emailPortSchema, emailSchema, emailSenderEmailSchema, emailSenderNameSchema, emailTemplateListSchema, emailThemeListSchema, emailThemeSchema, emailTypeSchema, emailUsernameSchema, emailVerificationCallbackUrlSchema, ensureObjectSchema, handlerPathSchema, intervalOrNeverSchema, intervalSchema, jsonSchema, jsonStringOrEmptySchema, jsonStringSchema, moneyAmountSchema, neonAuthorizationHeaderSchema, oauthAccountMergeStrategySchema, oauthClientIdSchema, oauthClientSecretSchema, oauthEnabledSchema, oauthFacebookConfigIdSchema, oauthIdSchema, oauthMicrosoftTenantIdSchema, oauthProviderAccountIdSchema, oauthProviderAllowConnectedAccountsSchema, oauthProviderAllowSignInSchema, oauthProviderEmailSchema, oauthProviderIdSchema, oauthProviderTypeSchema, oauthTypeSchema, passwordSchema, permissionDefinitionIdSchema, primaryEmailAuthEnabledSchema, primaryEmailSchema, primaryEmailVerifiedSchema, profileImageUrlSchema, projectAllowLocalhostSchema, projectBranchIdSchema, projectClientTeamCreationEnabledSchema, projectClientUserDeletionEnabledSchema, projectConfigIdSchema, projectCreateTeamOnSignUpSchema, projectCreatedAtMillisSchema, projectCredentialEnabledSchema, projectDescriptionSchema, projectDisplayNameSchema, projectIdSchema, projectIsProductionModeSchema, projectMagicLinkEnabledSchema, projectPasskeyEnabledSchema, projectSignUpEnabledSchema, refreshTokenResponseSchema, selectedTeamIdSchema, serverOrHigherAuthTypeSchema, signInEmailSchema, signInResponseSchema, signedUpAtMillisSchema, strictEmailSchema, teamClientMetadataSchema, teamClientReadOnlyMetadataSchema, teamCreatedAtMillisSchema, teamCreatorUserIdSchema, teamDisplayNameSchema, teamIdSchema, teamInvitationCallbackUrlSchema, teamInvitationEmailSchema, teamMemberDisplayNameSchema, teamMemberProfileImageUrlSchema, teamPermissionDescriptionSchema, teamProfileImageUrlSchema, teamServerMetadataSchema, teamSystemPermissions, templateThemeIdSchema, urlSchema, userClientMetadataSchema, userClientReadOnlyMetadataSchema, userDisplayNameSchema, userHasPasswordSchema, userIdOrMeSchema, userIdSchema, userLastActiveAtMillisSchema, userOAuthProviderSchema, userOtpAuthEnabledMutationSchema, userOtpAuthEnabledSchema, userPasskeyAuthEnabledSchema, userPasswordHashMutationSchema, userPasswordMutationSchema, userServerMetadataSchema, userSpecifiedIdSchema, userTotpSecretMutationSchema, yupArray, yupBoolean, yupDate, yupDefinedAndNonEmptyWhen, yupDefinedWhen, yupMixed, yupNever, yupNumber, yupObject, yupObjectWithAutoDefault, yupRecord, yupString, yupTuple, yupUnion, yupValidate };
@@ -45,6 +45,9 @@ __export(schema_fields_exports, {
45
45
  contactChannelValueSchema: () => contactChannelValueSchema,
46
46
  containedPermissionIdsSchema: () => containedPermissionIdsSchema,
47
47
  customPermissionDefinitionIdSchema: () => customPermissionDefinitionIdSchema,
48
+ customerTypeSchema: () => customerTypeSchema,
49
+ dayIntervalOrNeverSchema: () => dayIntervalOrNeverSchema,
50
+ dayIntervalSchema: () => dayIntervalSchema,
48
51
  emailHostSchema: () => emailHostSchema,
49
52
  emailOtpSignInCallbackUrlSchema: () => emailOtpSignInCallbackUrlSchema,
50
53
  emailPasswordSchema: () => emailPasswordSchema,
@@ -52,6 +55,7 @@ __export(schema_fields_exports, {
52
55
  emailSchema: () => emailSchema,
53
56
  emailSenderEmailSchema: () => emailSenderEmailSchema,
54
57
  emailSenderNameSchema: () => emailSenderNameSchema,
58
+ emailTemplateListSchema: () => emailTemplateListSchema,
55
59
  emailThemeListSchema: () => emailThemeListSchema,
56
60
  emailThemeSchema: () => emailThemeSchema,
57
61
  emailTypeSchema: () => emailTypeSchema,
@@ -59,9 +63,12 @@ __export(schema_fields_exports, {
59
63
  emailVerificationCallbackUrlSchema: () => emailVerificationCallbackUrlSchema,
60
64
  ensureObjectSchema: () => ensureObjectSchema,
61
65
  handlerPathSchema: () => handlerPathSchema,
66
+ intervalOrNeverSchema: () => intervalOrNeverSchema,
67
+ intervalSchema: () => intervalSchema,
62
68
  jsonSchema: () => jsonSchema,
63
69
  jsonStringOrEmptySchema: () => jsonStringOrEmptySchema,
64
70
  jsonStringSchema: () => jsonStringSchema,
71
+ moneyAmountSchema: () => moneyAmountSchema,
65
72
  neonAuthorizationHeaderSchema: () => neonAuthorizationHeaderSchema,
66
73
  oauthAccountMergeStrategySchema: () => oauthAccountMergeStrategySchema,
67
74
  oauthClientIdSchema: () => oauthClientIdSchema,
@@ -70,6 +77,12 @@ __export(schema_fields_exports, {
70
77
  oauthFacebookConfigIdSchema: () => oauthFacebookConfigIdSchema,
71
78
  oauthIdSchema: () => oauthIdSchema,
72
79
  oauthMicrosoftTenantIdSchema: () => oauthMicrosoftTenantIdSchema,
80
+ oauthProviderAccountIdSchema: () => oauthProviderAccountIdSchema,
81
+ oauthProviderAllowConnectedAccountsSchema: () => oauthProviderAllowConnectedAccountsSchema,
82
+ oauthProviderAllowSignInSchema: () => oauthProviderAllowSignInSchema,
83
+ oauthProviderEmailSchema: () => oauthProviderEmailSchema,
84
+ oauthProviderIdSchema: () => oauthProviderIdSchema,
85
+ oauthProviderTypeSchema: () => oauthProviderTypeSchema,
73
86
  oauthTypeSchema: () => oauthTypeSchema,
74
87
  passwordSchema: () => passwordSchema,
75
88
  permissionDefinitionIdSchema: () => permissionDefinitionIdSchema,
@@ -113,6 +126,7 @@ __export(schema_fields_exports, {
113
126
  teamProfileImageUrlSchema: () => teamProfileImageUrlSchema,
114
127
  teamServerMetadataSchema: () => teamServerMetadataSchema,
115
128
  teamSystemPermissions: () => teamSystemPermissions,
129
+ templateThemeIdSchema: () => templateThemeIdSchema,
116
130
  urlSchema: () => urlSchema,
117
131
  userClientMetadataSchema: () => userClientMetadataSchema,
118
132
  userClientReadOnlyMetadataSchema: () => userClientReadOnlyMetadataSchema,
@@ -128,6 +142,7 @@ __export(schema_fields_exports, {
128
142
  userPasswordHashMutationSchema: () => userPasswordHashMutationSchema,
129
143
  userPasswordMutationSchema: () => userPasswordMutationSchema,
130
144
  userServerMetadataSchema: () => userServerMetadataSchema,
145
+ userSpecifiedIdSchema: () => userSpecifiedIdSchema,
131
146
  userTotpSecretMutationSchema: () => userTotpSecretMutationSchema,
132
147
  yupArray: () => yupArray,
133
148
  yupBoolean: () => yupBoolean,
@@ -138,6 +153,7 @@ __export(schema_fields_exports, {
138
153
  yupNever: () => yupNever,
139
154
  yupNumber: () => yupNumber,
140
155
  yupObject: () => yupObject,
156
+ yupObjectWithAutoDefault: () => yupObjectWithAutoDefault,
141
157
  yupRecord: () => yupRecord,
142
158
  yupString: () => yupString,
143
159
  yupTuple: () => yupTuple,
@@ -152,6 +168,7 @@ var import_errors = require("./utils/errors.js");
152
168
  var import_http = require("./utils/http.js");
153
169
  var import_oauth = require("./utils/oauth.js");
154
170
  var import_objects = require("./utils/objects.js");
171
+ var import_strings = require("./utils/strings.js");
155
172
  var import_urls = require("./utils/urls.js");
156
173
  var import_uuids = require("./utils/uuids.js");
157
174
  yup.addMethod(yup.string, "nonEmpty", function(message) {
@@ -163,9 +180,37 @@ yup.addMethod(yup.string, "nonEmpty", function(message) {
163
180
  }
164
181
  );
165
182
  });
183
+ yup.addMethod(yup.Schema, "hasNested", function(path) {
184
+ if (!path.match(/^[a-zA-Z0-9_$:-]+$/)) throw new import_errors.StackAssertionError(`yupSchema.hasNested can currently only be used with alphanumeric keys, underscores, dollar signs, colons, and hyphens. Fix this in the future. Provided key: ${JSON.stringify(path)}`);
185
+ const schemaInfo = this.meta()?.stackSchemaInfo;
186
+ if (schemaInfo?.type === "record") {
187
+ return schemaInfo.keySchema.isValidSync(path);
188
+ } else if (schemaInfo?.type === "union") {
189
+ return schemaInfo.items.some((s) => s.hasNested(path));
190
+ } else {
191
+ try {
192
+ yup.reach(this, path);
193
+ return true;
194
+ } catch (e) {
195
+ if (e instanceof Error && e.message.includes("The schema does not contain the path")) {
196
+ return false;
197
+ }
198
+ throw e;
199
+ }
200
+ }
201
+ });
166
202
  yup.addMethod(yup.Schema, "getNested", function(path) {
167
- if (!path.match(/^[a-zA-Z_][a-zA-Z0-9_]*$/)) throw new import_errors.StackAssertionError(`yupSchema.getNested can currently only be used with alphanumeric keys. Fix this in the future. Provided key: ${path}`);
168
- return yup.reach(this, path);
203
+ if (!path.match(/^[a-zA-Z0-9_$:-]+$/)) throw new import_errors.StackAssertionError(`yupSchema.getNested can currently only be used with alphanumeric keys, underscores, dollar signs, colons, and hyphens. Fix this in the future. Provided key: ${path}`);
204
+ if (!this.hasNested(path)) throw new import_errors.StackAssertionError(`Tried to call yupSchema.getNested, but key is not present in the schema. Provided key: ${path}`, { path, schema: this });
205
+ const schemaInfo = this.meta()?.stackSchemaInfo;
206
+ if (schemaInfo?.type === "record") {
207
+ return schemaInfo.valueSchema;
208
+ } else if (schemaInfo?.type === "union") {
209
+ const schemasWithNested = schemaInfo.items.filter((s) => s.hasNested(path));
210
+ return yupUnion(...schemasWithNested.map((s) => s.getNested(path)));
211
+ } else {
212
+ return yup.reach(this, path);
213
+ }
169
214
  });
170
215
  async function yupValidate(schema, obj, options) {
171
216
  try {
@@ -220,27 +265,31 @@ var _createdAtMillisDescription = (identify) => `The time the ${identify} was cr
220
265
  var _signedUpAtMillisDescription = `The time the user signed up ${_atMillisDescription}`;
221
266
  var _lastActiveAtMillisDescription = `The time the user was last active ${_atMillisDescription}`;
222
267
  function yupString(...args) {
223
- return yup.string(...args);
268
+ return yup.string(...args).meta({ stackSchemaInfo: { type: "string" } });
224
269
  }
225
270
  function yupNumber(...args) {
226
- return yup.number(...args);
271
+ return yup.number(...args).meta({ stackSchemaInfo: { type: "number" } });
227
272
  }
228
273
  function yupBoolean(...args) {
229
- return yup.boolean(...args);
274
+ return yup.boolean(...args).meta({ stackSchemaInfo: { type: "boolean" } });
230
275
  }
231
276
  function yupDate(...args) {
232
- return yup.date(...args);
277
+ return yup.date(...args).meta({ stackSchemaInfo: { type: "date" } });
233
278
  }
234
- function yupMixed(...args) {
279
+ function _yupMixedInternal(...args) {
235
280
  return yup.mixed(...args);
236
281
  }
282
+ function yupMixed(...args) {
283
+ return _yupMixedInternal(...args).meta({ stackSchemaInfo: { type: "mixed" } });
284
+ }
237
285
  function yupArray(...args) {
238
- return yup.array(...args);
286
+ return yup.array(...args).meta({ stackSchemaInfo: { type: "array" } });
239
287
  }
240
- function yupTuple(...args) {
241
- return yup.tuple(...args);
288
+ function yupTuple(schemas) {
289
+ if (schemas.length === 0) throw new Error("yupTuple must have at least one schema");
290
+ return yup.tuple(schemas).meta({ stackSchemaInfo: { type: "tuple", items: schemas } });
242
291
  }
243
- function yupObject(...args) {
292
+ function yupObjectWithAutoDefault(...args) {
244
293
  const object2 = yup.object(...args).test(
245
294
  "no-unknown-object-properties",
246
295
  ({ path }) => `${path} contains unknown properties`,
@@ -260,21 +309,20 @@ function yupObject(...args) {
260
309
  }
261
310
  return true;
262
311
  }
263
- );
312
+ ).meta({ stackSchemaInfo: { type: "object" } });
313
+ return object2;
314
+ }
315
+ function yupObject(...args) {
316
+ const object2 = yupObjectWithAutoDefault(...args);
264
317
  return object2.default(void 0);
265
318
  }
266
319
  function yupNever() {
267
- return yupMixed().test("never", "This value should never be reached", () => false);
320
+ return _yupMixedInternal().meta({ stackSchemaInfo: { type: "never" } }).test("never", "This value should never be reached", () => false);
268
321
  }
269
322
  function yupUnion(...args) {
270
323
  if (args.length === 0) throw new Error("yupUnion must have at least one schema");
271
- const [first] = args;
272
- const firstDesc = first.describe();
273
- for (const schema of args) {
274
- const desc = schema.describe();
275
- if (desc.type !== firstDesc.type) throw new import_errors.StackAssertionError(`yupUnion must have schemas of the same type (got: ${firstDesc.type} and ${desc.type})`, { first, schema, firstDesc, desc });
276
- }
277
- return yupMixed().test("is-one-of", "Invalid value", async (value, context) => {
324
+ return _yupMixedInternal().meta({ stackSchemaInfo: { type: "union", items: args } }).test("is-one-of", "Invalid value", async (value, context) => {
325
+ if (value == null) return true;
278
326
  const errors = [];
279
327
  for (const schema of args) {
280
328
  try {
@@ -285,14 +333,18 @@ function yupUnion(...args) {
285
333
  }
286
334
  }
287
335
  return context.createError({
288
- message: `${context.path} is not matched by any of the provided schemas:
289
- ${errors.map((e, i) => " Schema " + i + ": \n " + e.errors.join("\n ")).join("\n")}`,
336
+ message: import_strings.deindent`
337
+ ${context.path} is not matched by any of the provided schemas:
338
+ ${errors.map((e, i) => import_strings.deindent`
339
+ Schema ${i}:
340
+ ${e.errors.join("\n")}
341
+ `).join("\n")}`,
290
342
  path: context.path
291
343
  });
292
344
  });
293
345
  }
294
346
  function yupRecord(keySchema, valueSchema) {
295
- return yupObject().unknown(true).test(
347
+ return yupObject().meta({ stackSchemaInfo: { type: "record", keySchema, valueSchema } }).unknown(true).test(
296
348
  "record",
297
349
  "${path} must be a record of valid values",
298
350
  async function(value, context) {
@@ -360,6 +412,22 @@ var base64Schema = yupString().test("is-base64", (params) => `${params.path} is
360
412
  return (0, import_bytes.isBase64)(value);
361
413
  });
362
414
  var passwordSchema = yupString().max(70);
415
+ var intervalSchema = yupTuple([yupNumber().min(0).integer().defined(), yupString().oneOf(["millisecond", "second", "minute", "hour", "day", "week", "month", "year"]).defined()]);
416
+ var dayIntervalSchema = yupTuple([yupNumber().min(0).integer().defined(), yupString().oneOf(["day", "week", "month", "year"]).defined()]);
417
+ var intervalOrNeverSchema = yupUnion(intervalSchema.defined(), yupString().oneOf(["never"]).defined());
418
+ var dayIntervalOrNeverSchema = yupUnion(dayIntervalSchema.defined(), yupString().oneOf(["never"]).defined());
419
+ var userSpecifiedIdSchema = (idName) => yupString().matches(/^[a-zA-Z_][a-zA-Z0-9_-]*$/);
420
+ var moneyAmountSchema = (currency) => yupString().test("money-amount", "Invalid money amount", (value, context) => {
421
+ if (value == null) return true;
422
+ const regex = /^([0-9]+)(\.([0-9]+))?$/;
423
+ const match = value.match(regex);
424
+ if (!match) return context.createError({ message: "Money amount must be in the format of <number> or <number>.<number>" });
425
+ const whole = match[1];
426
+ const decimals = match[3];
427
+ if (decimals && decimals.length > currency.decimals) return context.createError({ message: `Too many decimals; ${currency.code} only has ${currency.decimals} decimals` });
428
+ if (whole !== "0" && whole.startsWith("0")) return context.createError({ message: "Money amount must not have leading zeros" });
429
+ return true;
430
+ });
363
431
  var strictEmailSchema = (message) => yupString().email(message).matches(/^[^.]+(\.[^.]+)*@.*\.[^.][^.]+$/, message);
364
432
  var emailSchema = yupString().email();
365
433
  var clientOrHigherAuthTypeSchema = yupString().oneOf(["client", "server", "admin"]).defined();
@@ -400,10 +468,24 @@ var emailThemeSchema = yupString().meta({ openapiField: { description: "Email th
400
468
  var emailThemeListSchema = yupRecord(
401
469
  yupString().uuid(),
402
470
  yupObject({
403
- displayName: yupString().meta({ openapiField: { description: "Email theme name", exampleValue: "default-light" } }).defined(),
471
+ displayName: yupString().meta({ openapiField: { description: "Email theme name", exampleValue: "Default Light" } }).defined(),
404
472
  tsxSource: yupString().meta({ openapiField: { description: "Email theme source code tsx component" } }).defined()
405
473
  })
406
474
  ).meta({ openapiField: { description: "Record of email theme IDs to their display name and source code" } });
475
+ var templateThemeIdSchema = yupMixed().test((v) => v === void 0 || v === false || v === null || typeof v === "string" && (0, import_uuids.isUuid)(v)).meta({ openapiField: { description: "Email theme id for the template" } }).optional();
476
+ var emailTemplateListSchema = yupRecord(
477
+ yupString().uuid(),
478
+ yupObject({
479
+ displayName: yupString().meta({ openapiField: { description: "Email template name", exampleValue: "Email Verification" } }).defined(),
480
+ tsxSource: yupString().meta({ openapiField: { description: "Email template source code tsx component" } }).defined(),
481
+ // themeId can be one of three values:
482
+ // 1. A valid theme id
483
+ // 2. false, which means the template uses no theme
484
+ // 3. undefined/not given, which means the template uses the project's active theme
485
+ themeId: templateThemeIdSchema
486
+ })
487
+ ).meta({ openapiField: { description: "Record of email template IDs to their display name and source code" } });
488
+ var customerTypeSchema = yupString().oneOf(["user", "team", "organization"]);
407
489
  var ReplaceFieldWithOwnUserId = class extends Error {
408
490
  constructor(path) {
409
491
  super(`This error should be caught by whoever validated the schema, and the field in the path '${path}' should be replaced with the current user's id. This is a workaround to yup not providing access to the context inside the transform function.`);
@@ -494,6 +576,12 @@ var contactChannelValueSchema = yupString().when("type", {
494
576
  var contactChannelUsedForAuthSchema = yupBoolean().meta({ openapiField: { description: "Whether the contact channel is used for authentication. If this is set to `true`, the user will be able to sign in with the contact channel with password or OTP.", exampleValue: true } });
495
577
  var contactChannelIsVerifiedSchema = yupBoolean().meta({ openapiField: { description: "Whether the contact channel has been verified. If this is set to `true`, the contact channel has been verified to belong to the user.", exampleValue: true } });
496
578
  var contactChannelIsPrimarySchema = yupBoolean().meta({ openapiField: { description: "Whether the contact channel is the primary contact channel. If this is set to `true`, it will be used for authentication and notifications by default.", exampleValue: true } });
579
+ var oauthProviderIdSchema = yupString().uuid().meta({ openapiField: { description: _idDescription("OAuth provider"), exampleValue: "b3d396b8-c574-4c80-97b3-50031675ceb2" } });
580
+ var oauthProviderEmailSchema = emailSchema.meta({ openapiField: { description: "Email of the OAuth provider. This is used to display and identify the OAuth provider in the UI.", exampleValue: "test@gmail.com" } });
581
+ var oauthProviderTypeSchema = yupString().oneOf(import_oauth.allProviders).meta({ openapiField: { description: `OAuth provider type, one of ${import_oauth.allProviders.map((x) => `\`${x}\``).join(", ")}`, exampleValue: "google" } });
582
+ var oauthProviderAllowSignInSchema = yupBoolean().meta({ openapiField: { description: "Whether the user can use this OAuth provider to sign in. Only one OAuth provider per type can have this set to `true`.", exampleValue: true } });
583
+ var oauthProviderAllowConnectedAccountsSchema = yupBoolean().meta({ openapiField: { description: "Whether the user can use this OAuth provider as connected account. Multiple OAuth providers per type can have this set to `true`.", exampleValue: true } });
584
+ var oauthProviderAccountIdSchema = yupString().meta({ openapiField: { description: "Account ID of the OAuth provider. This uniquely identifies the account on the provider side.", exampleValue: "google-account-id-12345" } });
497
585
  var basicAuthorizationHeaderSchema = yupString().test("is-basic-authorization-header", 'Authorization header must be in the format "Basic <base64>"', (value) => {
498
586
  if (!value) return true;
499
587
  return (0, import_http.decodeBasicAuthorizationHeader)(value) !== null;
@@ -539,6 +627,9 @@ function yupDefinedAndNonEmptyWhen(schema, triggers) {
539
627
  contactChannelValueSchema,
540
628
  containedPermissionIdsSchema,
541
629
  customPermissionDefinitionIdSchema,
630
+ customerTypeSchema,
631
+ dayIntervalOrNeverSchema,
632
+ dayIntervalSchema,
542
633
  emailHostSchema,
543
634
  emailOtpSignInCallbackUrlSchema,
544
635
  emailPasswordSchema,
@@ -546,6 +637,7 @@ function yupDefinedAndNonEmptyWhen(schema, triggers) {
546
637
  emailSchema,
547
638
  emailSenderEmailSchema,
548
639
  emailSenderNameSchema,
640
+ emailTemplateListSchema,
549
641
  emailThemeListSchema,
550
642
  emailThemeSchema,
551
643
  emailTypeSchema,
@@ -553,9 +645,12 @@ function yupDefinedAndNonEmptyWhen(schema, triggers) {
553
645
  emailVerificationCallbackUrlSchema,
554
646
  ensureObjectSchema,
555
647
  handlerPathSchema,
648
+ intervalOrNeverSchema,
649
+ intervalSchema,
556
650
  jsonSchema,
557
651
  jsonStringOrEmptySchema,
558
652
  jsonStringSchema,
653
+ moneyAmountSchema,
559
654
  neonAuthorizationHeaderSchema,
560
655
  oauthAccountMergeStrategySchema,
561
656
  oauthClientIdSchema,
@@ -564,6 +659,12 @@ function yupDefinedAndNonEmptyWhen(schema, triggers) {
564
659
  oauthFacebookConfigIdSchema,
565
660
  oauthIdSchema,
566
661
  oauthMicrosoftTenantIdSchema,
662
+ oauthProviderAccountIdSchema,
663
+ oauthProviderAllowConnectedAccountsSchema,
664
+ oauthProviderAllowSignInSchema,
665
+ oauthProviderEmailSchema,
666
+ oauthProviderIdSchema,
667
+ oauthProviderTypeSchema,
567
668
  oauthTypeSchema,
568
669
  passwordSchema,
569
670
  permissionDefinitionIdSchema,
@@ -607,6 +708,7 @@ function yupDefinedAndNonEmptyWhen(schema, triggers) {
607
708
  teamProfileImageUrlSchema,
608
709
  teamServerMetadataSchema,
609
710
  teamSystemPermissions,
711
+ templateThemeIdSchema,
610
712
  urlSchema,
611
713
  userClientMetadataSchema,
612
714
  userClientReadOnlyMetadataSchema,
@@ -622,6 +724,7 @@ function yupDefinedAndNonEmptyWhen(schema, triggers) {
622
724
  userPasswordHashMutationSchema,
623
725
  userPasswordMutationSchema,
624
726
  userServerMetadataSchema,
727
+ userSpecifiedIdSchema,
625
728
  userTotpSecretMutationSchema,
626
729
  yupArray,
627
730
  yupBoolean,
@@ -632,6 +735,7 @@ function yupDefinedAndNonEmptyWhen(schema, triggers) {
632
735
  yupNever,
633
736
  yupNumber,
634
737
  yupObject,
738
+ yupObjectWithAutoDefault,
635
739
  yupRecord,
636
740
  yupString,
637
741
  yupTuple,