import type { GenericId, GenericValidator, ObjectType, OptionalProperty, PropertyValidators, Validator, VAny, VArray, VBoolean, VBytes, VFloat64, VId, VInt64, VLiteral, VNull, VObject, VOptional, VRecord, VString, VUnion } from "convex/values"; import * as zCore from "zod/v4/core"; import * as z from "zod/v4"; import type { ActionBuilder, ArgsArrayToObject, DefaultFunctionArgs, FunctionVisibility, GenericActionCtx, GenericDataModel, GenericMutationCtx, GenericQueryCtx, MutationBuilder, QueryBuilder, TableNamesInDataModel } from "convex/server"; import { type Expand } from "../index.js"; import type { Customization, Registration } from "./customFunctions.js"; import { type VRequired } from "../validators.js"; /** * zCustomQuery is like customQuery, but allows validation via zod. * You can define custom behavior on top of `query` or `internalQuery` * by passing a function that modifies the ctx and args. Or NoOp to do nothing. * * Example usage: * ```ts * const myQueryBuilder = zCustomQuery(query, { * args: { sessionId: v.id("sessions") }, * input: async (ctx, args) => { * const user = await getUserOrNull(ctx); * const session = await db.get(sessionId); * const db = wrapDatabaseReader({ user }, ctx.db, rlsRules); * return { ctx: { db, user, session }, args: {} }; * }, * }); * * // Using the custom builder * export const getSomeData = myQueryBuilder({ * args: { someArg: z.string() }, * handler: async (ctx, args) => { * const { db, user, session, scheduler } = ctx; * const { someArg } = args; * // ... * } * }); * ``` * * Simple usage only modifying ctx: * ```ts * const myInternalQuery = zCustomQuery( * internalQuery, * customCtx(async (ctx) => { * return { * // Throws an exception if the user isn't logged in * user: await getUserByTokenIdentifier(ctx), * }; * }) * ); * * // Using it * export const getUser = myInternalQuery({ * args: { email: z.string().email() }, * handler: async (ctx, args) => { * console.log(args.email); * return ctx.user; * }, * }); * * @param query The query to be modified. Usually `query` or `internalQuery` * from `_generated/server`. * @param customization The customization to be applied to the query, changing ctx and args. * @returns A new query builder using zod validation to define queries. */ export declare function zCustomQuery, CustomMadeArgs extends Record, Visibility extends FunctionVisibility, DataModel extends GenericDataModel, ExtraArgs extends Record = object>(query: QueryBuilder, customization: Customization, CustomArgsValidator, CustomCtx, CustomMadeArgs, ExtraArgs>): CustomBuilder<"query", CustomArgsValidator, CustomCtx, CustomMadeArgs, GenericQueryCtx, Visibility, ExtraArgs>; /** * zCustomMutation is like customMutation, but allows validation via zod. * You can define custom behavior on top of `mutation` or `internalMutation` * by passing a function that modifies the ctx and args. Or NoOp to do nothing. * * Example usage: * ```ts * const myMutationBuilder = zCustomMutation(mutation, { * args: { sessionId: v.id("sessions") }, * input: async (ctx, args) => { * const user = await getUserOrNull(ctx); * const session = await db.get(sessionId); * const db = wrapDatabaseReader({ user }, ctx.db, rlsRules); * return { ctx: { db, user, session }, args: {} }; * }, * }); * * // Using the custom builder * export const getSomeData = myMutationBuilder({ * args: { someArg: z.string() }, * handler: async (ctx, args) => { * const { db, user, session, scheduler } = ctx; * const { someArg } = args; * // ... * } * }); * ``` * * Simple usage only modifying ctx: * ```ts * const myInternalMutation = zCustomMutation( * internalMutation, * customCtx(async (ctx) => { * return { * // Throws an exception if the user isn't logged in * user: await getUserByTokenIdentifier(ctx), * }; * }) * ); * * // Using it * export const getUser = myInternalMutation({ * args: { email: z.string().email() }, * handler: async (ctx, args) => { * console.log(args.email); * return ctx.user; * }, * }); * * @param mutation The mutation to be modified. Usually `mutation` or `internalMutation` * from `_generated/server`. * @param customization The customization to be applied to the mutation, changing ctx and args. * @returns A new mutation builder using zod validation to define queries. */ export declare function zCustomMutation, CustomMadeArgs extends Record, Visibility extends FunctionVisibility, DataModel extends GenericDataModel, ExtraArgs extends Record = object>(mutation: MutationBuilder, customization: Customization, CustomArgsValidator, CustomCtx, CustomMadeArgs, ExtraArgs>): CustomBuilder<"mutation", CustomArgsValidator, CustomCtx, CustomMadeArgs, GenericMutationCtx, Visibility, ExtraArgs>; /** * zCustomAction is like customAction, but allows validation via zod. * You can define custom behavior on top of `action` or `internalAction` * by passing a function that modifies the ctx and args. Or NoOp to do nothing. * * Example usage: * ```ts * const myActionBuilder = zCustomAction(action, { * args: { sessionId: v.id("sessions") }, * input: async (ctx, args) => { * const user = await getUserOrNull(ctx); * const session = await db.get(sessionId); * const db = wrapDatabaseReader({ user }, ctx.db, rlsRules); * return { ctx: { db, user, session }, args: {} }; * }, * }); * * // Using the custom builder * export const getSomeData = myActionBuilder({ * args: { someArg: z.string() }, * handler: async (ctx, args) => { * const { db, user, session, scheduler } = ctx; * const { someArg } = args; * // ... * } * }); * ``` * * Simple usage only modifying ctx: * ```ts * const myInternalAction = zCustomAction( * internalAction, * customCtx(async (ctx) => { * return { * // Throws an exception if the user isn't logged in * user: await getUserByTokenIdentifier(ctx), * }; * }) * ); * * // Using it * export const getUser = myInternalAction({ * args: { email: z.string().email() }, * handler: async (ctx, args) => { * console.log(args.email); * return ctx.user; * }, * }); * * @param action The action to be modified. Usually `action` or `internalAction` * from `_generated/server`. * @param customization The customization to be applied to the action, changing ctx and args. * @returns A new action builder using zod validation to define queries. */ export declare function zCustomAction, CustomMadeArgs extends Record, Visibility extends FunctionVisibility, DataModel extends GenericDataModel, ExtraArgs extends Record = object>(action: ActionBuilder, customization: Customization, CustomArgsValidator, CustomCtx, CustomMadeArgs, ExtraArgs>): CustomBuilder<"action", CustomArgsValidator, CustomCtx, CustomMadeArgs, GenericActionCtx, Visibility, ExtraArgs>; /** * Creates a validator for a Convex `Id`. * * - When **used within Zod**, it will only check that the ID is a string. * - When **converted to a Convex validator** (e.g. through {@link zodToConvex}), * it will check that it's for the right table. * * @param tableName - The table that the `Id` references. i.e. `Id` * @returns A Zod schema representing a Convex `Id` */ export declare const zid: = TableNamesInDataModel>(tableName: TableName) => Zid; /** The type of Convex validators in Zod */ export type Zid = z.ZodCustom, string> & zCore.$ZodRecordKey; /** * Useful to get the input context type for a custom function using Zod. */ export type ZCustomCtx = Builder extends CustomBuilder ? Overwrite : never; /** * Turns a Zod or Zod Mini validator into a Convex validator. * * The Convex validator will be as close to possible to the Zod validator, * but might be broader than the Zod validator: * * ```ts * zodToConvex(z.string().email()) // → v.string() * ``` * * This function is useful when running the Zod validator _after_ running the Convex validator * (i.e. the Convex validator validates the input of the Zod validator). Hence, the Convex types * will match the _input type_ of Zod transformations: * ```ts * zodToConvex(z.object({ * name: z.string().default("Nicolas"), * })) // → v.object({ name: v.optional(v.string()) }) * * zodToConvex(z.object({ * name: z.string().transform(s => s.length) * })) // → v.object({ name: v.string() }) * ```` * * This function is useful for: * * **Validating function arguments with Zod**: through {@link zCustomQuery}, * {@link zCustomMutation} and {@link zCustomAction}, you can define the argument validation logic * using Zod validators instead of Convex validators. `zodToConvex` will generate a Convex validator * from your Zod validator. This will allow you to: * - validate at run time that Convex IDs are from the right table (using {@link zid}) * - allow some features of Convex to understand the expected shape of the arguments * (e.g. argument validation/prefilling in the function runner on the Convex dashboard) * - still run the full Zod validation when the function runs * (which is useful for more advanced Zod validators like `z.string().email()`) * * **Validating data after reading it from the database**: if you want to write your DB schema * with Zod, you can run Zod whenever you read from the database to check that the data * still matches the schema. Note that this approach won’t ensure that the data stored in the DB * matches the Zod schema; see * https://stack.convex.dev/typescript-zod-function-validation#can-i-use-zod-to-define-my-database-types-too * for more details. * * Note that some values might be valid in Zod but not in Convex, * in the same way that valid JavaScript values might not be valid * Convex values for the corresponding Convex type. * (see the limits of Convex data types on https://docs.convex.dev/database/types). * * ``` * ┌─────────────────────────────────────┬─────────────────────────────────────┐ * │ **zodToConvex** │ zodOutputToConvex │ * ├─────────────────────────────────────┼─────────────────────────────────────┤ * │ For when the Zod validator runs │ For when the Zod validator runs │ * │ _after_ the Convex validator │ _before_ the Convex validator │ * ├─────────────────────────────────────┼─────────────────────────────────────┤ * │ Convex types use the _input types_ │ Convex types use the _return types_ │ * │ of Zod transformations │ of Zod transformations │ * ├─────────────────────────────────────┼─────────────────────────────────────┤ * │ The Convex validator can be less │ The Convex validator can be less │ * │ strict (i.e. some inputs might be │ strict (i.e. the type in Convex can │ * │ accepted by Convex then rejected │ be less precise than the type in │ * │ by Zod) │ the Zod output) │ * ├─────────────────────────────────────┼─────────────────────────────────────┤ * │ When using Zod schemas │ When using Zod schemas │ * │ for function definitions: │ for function definitions: │ * │ used for _arguments_ │ used for _return values_ │ * ├─────────────────────────────────────┼─────────────────────────────────────┤ * │ When validating contents of the │ When validating contents of the │ * │ database with a Zod schema: │ database with a Zod schema: │ * │ used to validate data │ used to validate data │ * │ _after reading_ │ _before writing_ │ * └─────────────────────────────────────┴─────────────────────────────────────┘ * ``` * * @param zod Zod validator can be a Zod object, or a Zod type like `z.string()` * @returns Convex Validator (e.g. `v.string()` from "convex/values") * @throws If there is no equivalent Convex validator for the value (e.g. `z.date()`) */ export declare function zodToConvex(validator: Z): ConvexValidatorFromZod; /** * Converts a Zod or Zod Mini validator to a Convex validator that checks the value _after_ * it has been validated (and possibly transformed) by the Zod validator. * * This is similar to {@link zodToConvex}, but is meant for cases where the Convex * validator runs _after_ the Zod validator. Thus, the Convex type refers to the * _output_ type of the Zod transformations: * ```ts * zodOutputToConvex(z.object({ * name: z.string().default("Nicolas"), * })) // → v.object({ name: v.string() }) * * zodOutputToConvex(z.object({ * name: z.string().transform(s => s.length) * })) // → v.object({ name: v.number() }) * ```` * * This function can be useful for: * - **Validating function return values with Zod**: through {@link zCustomQuery}, * {@link zCustomMutation} and {@link zCustomAction}, you can define the `returns` property * of a function using Zod validators instead of Convex validators. * - **Validating data after reading it from the database**: if you want to write your DB schema * Zod validators, you can run Zod whenever you write to the database to ensure your data matches * the expected format. Note that this approach won’t ensure that the data stored in the DB * isn’t modified manually in a way that doesn’t match your Zod schema; see * https://stack.convex.dev/typescript-zod-function-validation#can-i-use-zod-to-define-my-database-types-too * for more details. * * ``` * ┌─────────────────────────────────────┬─────────────────────────────────────┐ * │ zodToConvex │ **zodOutputToConvex** │ * ├─────────────────────────────────────┼─────────────────────────────────────┤ * │ For when the Zod validator runs │ For when the Zod validator runs │ * │ _after_ the Convex validator │ _before_ the Convex validator │ * ├─────────────────────────────────────┼─────────────────────────────────────┤ * │ Convex types use the _input types_ │ Convex types use the _return types_ │ * │ of Zod transformations │ of Zod transformations │ * ├─────────────────────────────────────┼─────────────────────────────────────┤ * │ The Convex validator can be less │ The Convex validator can be less │ * │ strict (i.e. some inputs might be │ strict (i.e. the type in Convex can │ * │ accepted by Convex then rejected │ be less precise than the type in │ * │ by Zod) │ the Zod output) │ * ├─────────────────────────────────────┼─────────────────────────────────────┤ * │ When using Zod schemas │ When using Zod schemas │ * │ for function definitions: │ for function definitions: │ * │ used for _arguments_ │ used for _return values_ │ * ├─────────────────────────────────────┼─────────────────────────────────────┤ * │ When validating contents of the │ When validating contents of the │ * │ database with a Zod schema: │ database with a Zod schema: │ * │ used to validate data │ used to validate data │ * │ _after reading_ │ _before writing_ │ * └─────────────────────────────────────┴─────────────────────────────────────┘ * ``` * * @param z The zod validator * @returns Convex Validator (e.g. `v.string()` from "convex/values") * @throws If there is no equivalent Convex validator for the value (e.g. `z.date()`) */ export declare function zodOutputToConvex(validator: Z): ConvexValidatorFromZodOutput; type ZodFields = Record; /** * Like {@link zodToConvex}, but it takes in a bare object, as expected by Convex * function arguments, or the argument to {@link defineTable}. * * ```ts * zodToConvexFields({ * name: z.string().default("Nicolas"), * }) // → { name: v.optional(v.string()) } * ``` * * @param fields Object with string keys and Zod validators as values * @returns Object with the same keys, but with Convex validators as values */ export declare function zodToConvexFields(fields: Fields): { [k in keyof Fields]: Fields[k] extends zCore.$ZodType ? ConvexValidatorFromZod : never; }; /** * Like {@link zodOutputToConvex}, but it takes in a bare object, as expected by * Convex function arguments, or the argument to {@link defineTable}. * * ```ts * zodOutputToConvexFields({ * name: z.string().default("Nicolas"), * }) // → { name: v.string() } * ``` * * This is different from {@link zodToConvexFields} because it generates the * Convex validator for the output of the Zod validator, not the input; * see the documentation of {@link zodToConvex} and {@link zodOutputToConvex} * for more details. * * @param zod Object with string keys and Zod validators as values * @returns Object with the same keys, but with Convex validators as values */ export declare function zodOutputToConvexFields(fields: Fields): { [k in keyof Fields]: ConvexValidatorFromZodOutput; }; /** * Turns a Convex validator into a Zod validator. * * This is useful when you want to use types you defined using Convex validators * with external libraries that expect to receive a Zod validator. * * ```ts * convexToZod(v.string()) // → z.string() * ``` * * This function returns Zod validators, not Zod Mini validators. * * @param convexValidator Convex validator can be any validator from "convex/values" e.g. `v.string()` * @returns Zod validator (e.g. `z.string()`) with inferred type matching the Convex validator */ export declare function convexToZod(convexValidator: V): ZodValidatorFromConvex; /** * Like {@link convexToZod}, but it takes in a bare object, as expected by Convex * function arguments, or the argument to {@link defineTable}. * * ```ts * convexToZodFields({ * name: v.string(), * }) // → { name: z.string() } * ``` * * @param convexValidators Object with string keys and Convex validators as values * @returns Object with the same keys, but with Zod validators as values */ export declare function convexToZodFields(convexValidators: C): { [k in keyof C]: ZodValidatorFromConvex; }; /** * Zod helper for adding Convex system fields to a record to return. * * ```ts * withSystemFields("users", { * name: z.string(), * }) * // → { * // name: z.string(), * // _id: zid("users"), * // _creationTime: z.number(), * // } * ``` * * @param tableName - The table where records are from, i.e. Doc * @param zObject - Validators for the user-defined fields on the document. * @returns Zod shape for use with `z.object(shape)` that includes system fields. */ export declare function withSystemFields(tableName: Table, zObject: T): T & { _id: Zid
; _creationTime: z.ZodNumber; }; /** * A builder that customizes a Convex function, whether or not it validates * arguments. If the customization requires arguments, however, the resulting * builder will require argument validation too. */ export type CustomBuilder, CustomMadeArgs extends Record, InputCtx, Visibility extends FunctionVisibility, ExtraArgs extends Record> = { | void, ReturnsZodValidator extends zCore.$ZodType | ZodFields | void = void, ReturnValue extends ReturnValueInput = any>(func: ({ /** * Specify the arguments to the function as a Zod validator. */ args?: ArgsValidator; handler: (ctx: Overwrite, ...args: ArgsForHandlerType, CustomMadeArgs>) => ReturnValue; /** * Validates the value returned by the function. * Note: you can't pass an object directly without wrapping it * in `z.object()`. */ returns?: ReturnsZodValidator; /** * If true, the function will not be validated by Convex, * in case you're seeing performance issues with validating twice. */ skipConvexValidation?: boolean; } & { [key in keyof ExtraArgs as key extends "args" | "handler" | "skipConvexValidation" | "returns" ? never : key]: ExtraArgs[key]; }) | { (ctx: Overwrite, ...args: ArgsForHandlerType, CustomMadeArgs>): ReturnValue; }): Registration ? ArgsInput : ArgsInput extends [infer A] ? [Expand>] : [ObjectType]>, ReturnsZodValidator extends void ? ReturnValue : ReturnValueOutput>; }; type ArgsForHandlerType], CustomMadeArgs extends Record> = CustomMadeArgs extends Record ? OneOrZeroArgs : OneOrZeroArgs extends [infer A] ? [Expand] : [CustomMadeArgs]; type NullToUndefinedOrNull = T extends null ? T | undefined | void : T; type Returns = Promise> | NullToUndefinedOrNull; type ReturnValueInput = [ReturnsValidator] extends [zCore.$ZodType] ? Returns> : [ReturnsValidator] extends [ZodFields] ? Returns>> : any; type ReturnValueOutput = [ReturnsValidator] extends [zCore.$ZodType] ? Returns> : [ReturnsValidator] extends [ZodFields] ? Returns>> : any; type ArgsInput | void> = [ ArgsValidator ] extends [zCore.$ZodObject] ? [zCore.input] : ArgsValidator extends Record ? [ {} ] : [ArgsValidator] extends [Record] ? [zCore.input>] : OneArgArray; type ArgsOutput | void> = [ArgsValidator] extends [zCore.$ZodObject] ? [zCore.output] : [ArgsValidator] extends [ZodFields] ? [zCore.output>] : OneArgArray; type Overwrite = Omit & U; type OneArgArray = [ ArgsObject ]; /** * Return type of {@link zodToConvex}. */ export type ConvexValidatorFromZod = IsUnknownOrAny extends true ? GenericValidator : Z extends zCore.$ZodDefault ? VOptional> : Z extends zCore.$ZodPipe ? ConvexValidatorFromZod : ConvexValidatorFromZodCommon; /** * Return type of {@link zodOutputToConvex}. */ export type ConvexValidatorFromZodOutput = IsUnknownOrAny extends true ? GenericValidator : Z extends zCore.$ZodDefault ? VRequired> : Z extends zCore.$ZodPipe ? ConvexValidatorFromZodOutput : Z extends zCore.$ZodOptional ? VOptional> : Z extends zCore.$ZodNullable ? ConvexValidatorFromZodOutput extends Validator ? VUnion["type"] | null | undefined, [ VRequired>, VNull ], "optional", ConvexValidatorFromZodOutput["fieldPaths"]> : VUnion["type"] | null, [ VRequired>, VNull ], IsOptional, ConvexValidatorFromZodOutput["fieldPaths"]> : ConvexValidatorFromZodCommon; type ConvexValidatorFromZodCommon = Z extends Zid ? VId> : Z extends zCore.$ZodString ? VString, IsOptional> : Z extends zCore.$ZodNumber ? VFloat64, IsOptional> : Z extends zCore.$ZodNaN ? VFloat64, IsOptional> : Z extends zCore.$ZodBigInt ? VInt64, IsOptional> : Z extends zCore.$ZodBoolean ? VBoolean, IsOptional> : Z extends zCore.$ZodNull ? VNull, IsOptional> : Z extends zCore.$ZodUnknown ? VAny : Z extends zCore.$ZodAny ? VAny, "required"> : Z extends zCore.$ZodArray ? ConvexValidatorFromZod extends GenericValidator ? VArray["type"][], ConvexValidatorFromZod, IsOptional> : never : Z extends zCore.$ZodObject> ? VObject, ConvexObjectFromZodShape, IsOptional> : Z extends zCore.$ZodNever ? VUnion : Z extends zCore.$ZodUnion ? ConvexUnionValidatorFromZod : Z extends zCore.$ZodTuple ? VArray["type"]> : Array["type"] | zCore.infer>, null extends Rest ? ConvexUnionValidatorFromZod : ConvexUnionValidatorFromZod<[ ...Inner, Rest extends zCore.$ZodType ? Rest : never ]>, IsOptional> : Z extends zCore.$ZodLiteral ? ConvexLiteralFromZod : Z extends zCore.$ZodEnum ? VUnion, keyof EnumContents extends string ? { [K in keyof EnumContents]: VLiteral; }[keyof EnumContents][] : never, IsOptional> : Z extends zCore.$ZodOptional ? VOptional> : Z extends zCore.$ZodNonOptional ? VRequired> : Z extends zCore.$ZodNullable ? ConvexValidatorFromZod extends Validator ? VUnion["type"] | null | undefined, [ VRequired>, VNull ], "optional", ConvexValidatorFromZod["fieldPaths"]> : VUnion["type"] | null, [ VRequired>, VNull ], IsOptional, ConvexValidatorFromZod["fieldPaths"]> : Z extends zCore.$ZodBranded ? Inner extends zCore.$ZodString ? VString, IsOptional> : Inner extends zCore.$ZodNumber ? VFloat64, IsOptional> : Inner extends zCore.$ZodBigInt ? VInt64, IsOptional> : Inner extends zCore.$ZodObject> ? VObject & zCore.$brand, ConvexObjectFromZodShape, IsOptional> : ConvexValidatorFromZod : Z extends zCore.$ZodRecord ? ConvexValidatorFromZodRecord : Z extends zCore.$ZodReadonly ? ConvexValidatorFromZod : Z extends zCore.$ZodLazy ? ConvexValidatorFromZod : Z extends zCore.$ZodTemplateLiteral ? VString : Z extends zCore.$ZodCatch ? ConvexValidatorFromZod : Z extends zCore.$ZodTransform ? VAny : Z extends zCore.$ZodCustom ? VAny : Z extends zCore.$ZodIntersection ? VAny : IsConvexUnencodableType extends true ? never : GenericValidator; type ConvexUnionValidatorFromZod = VUnion["type"], T extends readonly [ infer Head extends zCore.$ZodType, ...infer Tail extends zCore.$ZodType[] ] ? [ VRequired>, ...ConvexUnionValidatorFromZodMembers ] : T extends readonly [] ? [] : Validator[], "required", ConvexValidatorFromZod["fieldPaths"]>; type ConvexUnionValidatorFromZodMembers = T extends readonly [ infer Head extends zCore.$ZodType, ...infer Tail extends zCore.$ZodType[] ] ? [ VRequired>, ...ConvexUnionValidatorFromZodMembers ] : T extends readonly [] ? [] : Validator[]; type ConvexObjectFromZodShape> = Fields extends infer F ? { [K in keyof F]: F[K] extends zCore.$ZodType ? ConvexValidatorFromZod : Validator; } : never; type ConvexObjectValidatorFromRecord = VObject; } : MakeUndefinedPropertiesOptional<{ [K in Key]: zCore.infer; }>, IsPartial extends "partial" ? { [K in Key]: VOptional>; } : { [K in Key]: ConvexValidatorFromZod; }, IsOptional>; type MakeUndefinedPropertiesOptional = Expand<{ [K in keyof Obj as undefined extends Obj[K] ? never : K]: Obj[K]; } & { [K in keyof Obj as undefined extends Obj[K] ? K : never]?: Obj[K]; }>; type ConvexValidatorFromZodRecord = Key extends zCore.$ZodString | Zid | zCore.$ZodUnion[]> ? VRecord, NotUndefined>>, VRequired>, VRequired>, IsOptional> : Key extends zCore.$ZodLiteral ? ConvexObjectValidatorFromRecord : Key extends zCore.$ZodUnion ? ConvexObjectValidatorFromRecord extends string ? zCore.infer : never, Value, IsOptional, Key extends zCore.$partial ? "partial" : "full"> : VRecord>>, VString, VRequired>, IsOptional>; type IsConvexUnencodableType = Z extends zCore.$ZodDate | zCore.$ZodSymbol | zCore.$ZodMap | zCore.$ZodSet | zCore.$ZodPromise | zCore.$ZodFile | zCore.$ZodFunction | zCore.$ZodUndefined | zCore.$ZodVoid ? true : false; type IsUnion = T extends unknown ? [U] extends [T] ? false : true : false; type ConvexLiteralFromZod = undefined extends Literal ? never : [ Literal ] extends [null] ? VNull : IsUnion extends true ? VUnion : never>, IsOptional, never> : VLiteral; type IsUnknownOrAny = 0 extends 1 & T ? true : unknown extends T ? true : false; /** * Better type conversion from a Convex validator to a Zod validator * where the output is not a generic ZodType but it's more specific. * * This allows you to use methods specific to the Zod type (e.g. `.email()` for `z.ZodString`). * * ```ts * ZodValidatorFromConvex // → z.ZodString * ``` */ export type ZodValidatorFromConvex = V extends Validator ? z.ZodOptional>> : ZodFromValidatorBase; export type ZodFromValidatorBase = V extends VId ? Zid>> : V extends VString ? BrandIfBranded : V extends VFloat64 ? BrandIfBranded : V extends VInt64 ? z.ZodBigInt : V extends VBoolean ? z.ZodBoolean : V extends VNull ? z.ZodNull : V extends VArray ? Element extends VArray ? z.ZodArray : z.ZodArray> : V extends VObject> ? z.ZodObject, zCore.$strict> : V extends VBytes ? never : V extends VLiteral ? z.ZodLiteral> : V extends VRecord ? z.ZodRecord, ZodFromValidatorBase> : V extends VUnion ? z.ZodNever : V extends VUnion ? ZodValidatorFromConvex : V extends VUnion ? z.ZodUnion, ...{ [K in keyof Rest]: ZodValidatorFromConvex; } ]> : V extends VUnion ? [GenericValidator] extends [E] ? z.ZodUnion : z.ZodUnion[]> : V extends VAny ? z.ZodAny : never; type BrandIfBranded = InnerType extends zCore.$brand ? zCore.$ZodBranded : Validator; type StringValidator = Validator; type ZodFromStringValidator = V extends VId> ? Zid : V extends VString ? BrandIfBranded : V extends VLiteral ? z.ZodLiteral : V extends VUnion ? z.ZodNever : V extends VUnion ? ZodFromStringValidator : V extends VUnion ? z.ZodUnion, ...{ [K in keyof Rest]: ZodFromStringValidator; } ]> : never; type ZodShapeFromConvexObject> = Fields extends infer F ? { [K in keyof F]: F[K] extends GenericValidator ? ZodValidatorFromConvex : never; } : never; type NotUndefined = Exclude; type TableNameFromType = T extends GenericId ? TableName : string; export {}; //# sourceMappingURL=zod4.d.ts.map