UNPKG

zod-compiler

Version:

Compile Zod schemas to fast parsers or TypeScript types

675 lines (635 loc) 30.8 kB
import z from 'zod'; import ts from 'typescript'; import { ParseStatus, CompiledParser } from './standalone.js'; export { CompiledParser } from './standalone.js'; /** * In JavaScript, there exist two main types of values - primitives like strings, numbers, and booleans; and objects like * arrays, `Map`s, `Set`s, and, well, *objects*. Two primitives with equal value are equal to each other: `42 === 42` and * `"foo" === "foo"`, however ***two objects will never be equal to each other***: `{} !== {}`, `[] !== []`. * * Since `zod-compiler` outputs source code which is then {@linkcode eval}uated, it has to get values defined in types * like `z.literal()` or `.default()` or `.catch()` from *somewhere*; for primitive types this is fine, and the value can * be directly pasted into the source code. However, for objects, this can lead to unexpected behavior if you, for example, * expect values returned by `.default()` to be equal to the original value provided in the schema definition. * * The default inlining mode is {@linkcode Default}, which inlines *primitives*, but not *objects*. This means that * any object values are defined as a **dependency**; they are the *exact same values* taken from the schema definition * that the compiled parser can use via a reference. This behavior provides the best compatibility for in-source usage of * `zod-compiler`. * * For **standalone** builds, however, that would mean that you'd have to provide these dependency references to the parser. * `zc.compile()` returns a dependency array which you could then pass to `standalone()`, though you'd have to figure * out where those values come from and extract them out of your source tree. Alternatively, the {@linkcode InliningMode.Aggressive Aggressive} * inlining mode *will* attempt to inline objects, arrays, `Map`s, and `Set`s. This does mean that these values would * no longer be equivalent to their definition, but there's a good chance you don't depend on that behavior anyway. */ declare enum InliningMode { /** Does not inline any values; they will all be added as dependencies. */ None = 0, /** Inlines most primitives: strings, numbers, `BigInt`s, booleans, and `null`/`undefined`. */ Default = 1, /** * Like {@linkcode InliningMode.Default Default}, but also inlines objects, arrays, `Map`s and `Set`s, and regular * expressions. * * Symbols and functions cannot be inlined. */ Aggressive = 2 } declare class Dependencies { private readonly verifierContext; private readonly inliningMode; private readonly _dependencies; constructor(verifierContext: ts.Expression, inliningMode: InliningMode); add(value: any): ts.Expression; addOrInline(value: any): ts.Expression; get dependencies(): readonly any[]; } interface IGeneratorContext { get dependencies(): Dependencies; get input(): ts.Expression; get verifierContext(): ts.Expression; prelude(): Iterable<ts.Statement>; postlude(): Iterable<ts.Statement>; outputs(expr: ts.Expression): Iterable<ts.Statement>; withInput(expr: ts.Expression): this; report(issue: ts.Expression, input?: ts.Expression): Iterable<ts.Statement>; status(status: ParseStatus | ts.Expression, allowShortCircuiting?: boolean): Iterable<ts.Statement>; } declare enum ZcParsedType { string = "string", nan = "nan", number = "number", integer = "integer", float = "float", boolean = "boolean", date = "date", bigint = "bigint", symbol = "symbol", function = "function", undefined = "undefined", null = "null", array = "array", object = "object", unknown = "unknown", promise = "promise", void = "void", never = "never", map = "map", set = "set" } declare class Path { private readonly parts; protected constructor(parts: ts.Expression[]); static empty(): Path; get isEmpty(): boolean; clone(): Path; push(fragment: string | number | ts.Expression): Path; serialize(): ts.ArrayLiteralExpression; } declare abstract class AbstractCompiledType<TZod extends z.ZodType> { protected readonly type: TZod; constructor(type: TZod); abstract compileType(): ts.TypeNode; abstract compileParser(ctx: IGeneratorContext, path: Path): Iterable<ts.Statement>; } declare function compilable<TZod extends z.ZodTypeAny>(type: TZod): AbstractCompiledType<TZod>; type Primitive = string | number | symbol | bigint | boolean | null | undefined; type Scalars = Primitive | Primitive[]; type typeToFlattenedError<T, U = string> = { formErrors: U[]; fieldErrors: { [P in keyof T]?: U[]; }; }; declare enum ZcIssueCode { invalid_type = "invalid_type", invalid_literal = "invalid_literal", custom = "custom", invalid_union = "invalid_union", invalid_union_discriminator = "invalid_union_discriminator", invalid_enum_value = "invalid_enum_value", unrecognized_keys = "unrecognized_keys", invalid_arguments = "invalid_arguments", invalid_return_type = "invalid_return_type", invalid_date = "invalid_date", invalid_string = "invalid_string", too_small = "too_small", too_big = "too_big", invalid_intersection_types = "invalid_intersection_types", not_multiple_of = "not_multiple_of", not_finite = "not_finite" } interface ZcIssueBase { path: (string | number)[]; message?: string; } interface ZcInvalidTypeIssue extends ZcIssueBase { code: ZcIssueCode.invalid_type; expected: ZcParsedType; received: ZcParsedType; } interface ZcInvalidLiteralIssue extends ZcIssueBase { code: ZcIssueCode.invalid_literal; expected: unknown; received: unknown; } interface ZcUnrecognizedKeysIssue extends ZcIssueBase { code: ZcIssueCode.unrecognized_keys; keys: string[]; } interface ZcInvalidUnionIssue extends ZcIssueBase { code: ZcIssueCode.invalid_union; unionErrors: ZcError[]; } interface ZcInvalidUnionDiscriminatorIssue extends ZcIssueBase { code: ZcIssueCode.invalid_union_discriminator; options: Primitive[]; } interface ZcInvalidEnumValueIssue extends ZcIssueBase { code: ZcIssueCode.invalid_enum_value; received: string | number; options: (string | number)[]; } interface ZcInvalidArgumentsIssue extends ZcIssueBase { code: ZcIssueCode.invalid_arguments; argumentsError: ZcError; } interface ZcInvalidReturnTypeIssue extends ZcIssueBase { code: ZcIssueCode.invalid_return_type; returnTypeError: ZcError; } interface ZcInvalidDateIssue extends ZcIssueBase { code: ZcIssueCode.invalid_date; } type StringValidation = 'email' | 'url' | 'emoji' | 'uuid' | 'nanoid' | 'regex' | 'cuid' | 'cuid2' | 'ulid' | 'datetime' | 'date' | 'time' | 'duration' | 'ip' | 'cidr' | 'base64' | 'jwt' | 'base64url' | { includes: string; position?: number; } | { startsWith: string; } | { endsWith: string; }; interface ZcInvalidStringIssue extends ZcIssueBase { code: ZcIssueCode.invalid_string; validation: StringValidation; } interface ZcTooSmallIssue extends ZcIssueBase { code: ZcIssueCode.too_small; minimum: number | bigint; inclusive: boolean; exact?: boolean; type: 'array' | 'string' | 'number' | 'set' | 'date' | 'bigint'; } interface ZcTooBigIssue extends ZcIssueBase { code: ZcIssueCode.too_big; maximum: number | bigint; inclusive: boolean; exact?: boolean; type: 'array' | 'string' | 'number' | 'set' | 'date' | 'bigint'; } interface ZcInvalidIntersectionTypesIssue extends ZcIssueBase { code: ZcIssueCode.invalid_intersection_types; } interface ZcNotMultipleOfIssue extends ZcIssueBase { code: ZcIssueCode.not_multiple_of; multipleOf: number | bigint; } interface ZcNotFiniteIssue extends ZcIssueBase { code: ZcIssueCode.not_finite; } interface ZcCustomIssue extends ZcIssueBase { code: ZcIssueCode.custom; params?: { [k: string]: any; }; } type DenormalizedError = { [k: string]: DenormalizedError | string[]; }; type ZcIssueOptionalMessage = ZcInvalidTypeIssue | ZcInvalidLiteralIssue | ZcUnrecognizedKeysIssue | ZcInvalidUnionIssue | ZcInvalidUnionDiscriminatorIssue | ZcInvalidEnumValueIssue | ZcInvalidArgumentsIssue | ZcInvalidReturnTypeIssue | ZcInvalidDateIssue | ZcInvalidStringIssue | ZcTooSmallIssue | ZcTooBigIssue | ZcInvalidIntersectionTypesIssue | ZcNotMultipleOfIssue | ZcNotFiniteIssue | ZcCustomIssue; type ZcIssue = ZcIssueOptionalMessage & { fatal?: boolean; message: string; }; type recursiveZcFormattedError<T> = T extends [any, ...any[]] ? { [K in keyof T]?: ZcFormattedError<T[K]>; } : T extends any[] ? { [k: number]: ZcFormattedError<T[number]>; } : T extends object ? { [K in keyof T]?: ZcFormattedError<T[K]>; } : unknown; type ZcFormattedError<T, U = string> = { _errors: U[]; } & recursiveZcFormattedError<NonNullable<T>>; declare class ZcError<T = any> extends Error { issues: ZcIssue[]; get errors(): ZcIssue[]; constructor(issues: ZcIssue[]); format(): ZcFormattedError<T>; format<U>(mapper: (issue: ZcIssue) => U): ZcFormattedError<T, U>; static create(issues: ZcIssue[]): ZcError; toString(): string; get message(): string; get isEmpty(): boolean; addIssue(sub: ZcIssue): void; addIssues(subs?: ZcIssue[]): void; flatten(): typeToFlattenedError<T>; flatten<U>(mapper?: (issue: ZcIssue) => U): typeToFlattenedError<T, U>; get formErrors(): typeToFlattenedError<T>; } type IssueData = Omit<ZcIssueOptionalMessage, 'path'> & { path?: (string | number)[]; fatal?: boolean; }; type ErrorMapCtx = { defaultError: string; data: any; }; type ZcErrorMap = (issue: ZcIssueOptionalMessage, ctx: ErrorMapCtx) => { message: string; }; declare class ZcAny extends AbstractCompiledType<z.ZodAny> { compileType(): ts.TypeNode; compileParser(ctx: IGeneratorContext, path: Path): Iterable<ts.Statement>; } declare class ZcArray<TZod extends z.ZodType> extends AbstractCompiledType<z.ZodArray<TZod>> { compileType(): ts.TypeNode; compileParser(ctx: IGeneratorContext, path: Path): Generator<ts.Statement>; } declare class ZcBigInt extends AbstractCompiledType<z.ZodBigInt> { compileType(): ts.TypeNode; compileParser(ctx: IGeneratorContext, path: Path): Iterable<ts.Statement>; } declare class ZcBoolean extends AbstractCompiledType<z.ZodBoolean> { compileType(): ts.TypeNode; compileParser(ctx: IGeneratorContext, path: Path): Iterable<ts.Statement>; } declare class ZcBranded<TZod extends z.ZodTypeAny, B extends string | number | symbol> extends AbstractCompiledType<z.ZodBranded<TZod, B>> { compileType(): ts.TypeNode; compileParser(ctx: IGeneratorContext, path: Path): Iterable<ts.Statement>; } declare class ZcCatch<TZod extends z.ZodType> extends AbstractCompiledType<z.ZodCatch<TZod>> { compileType(): ts.TypeNode; compileParser(ctx: IGeneratorContext, path: Path): Generator<ts.Statement>; } declare class ZcDate extends AbstractCompiledType<z.ZodDate> { compileType(): ts.TypeNode; compileParser(ctx: IGeneratorContext, path: Path): Iterable<ts.Statement>; } declare class ZcDefault<TZod extends z.ZodType> extends AbstractCompiledType<z.ZodDefault<TZod>> { compileType(): ts.TypeNode; compileParser(ctx: IGeneratorContext, path: Path): Generator<ts.Statement>; } declare class ZcDiscriminatedUnion<TDiscriminator extends string, TOptions extends readonly z.ZodDiscriminatedUnionOption<TDiscriminator>[]> extends AbstractCompiledType<z.ZodDiscriminatedUnion<TDiscriminator, TOptions>> { compileType(): ts.TypeNode; compileParser(ctx: IGeneratorContext, path: Path): Iterable<ts.Statement>; } declare class ZcEnum<T extends [string, ...string[]]> extends AbstractCompiledType<z.ZodEnum<T>> { compileType(): ts.TypeNode; compileParser(ctx: IGeneratorContext, path: Path): Iterable<ts.Statement>; } declare class ZcIntersection<T extends z.ZodTypeAny, U extends z.ZodTypeAny> extends AbstractCompiledType<z.ZodIntersection<T, U>> { compileType(): ts.TypeNode; compileParser(ctx: IGeneratorContext, path: Path): Generator<ts.Statement>; private _generateSide; } declare class ZcLiteral<T> extends AbstractCompiledType<z.ZodLiteral<T>> { compileType(): ts.TypeNode; compileParser(ctx: IGeneratorContext, path: Path): Iterable<ts.Statement>; } declare class ZcMap<K extends z.ZodTypeAny, V extends z.ZodTypeAny> extends AbstractCompiledType<z.ZodMap<K, V>> { compileType(): ts.TypeNode; compileParser(ctx: IGeneratorContext, path: Path): Generator<ts.Statement>; } declare class ZcNaN extends AbstractCompiledType<z.ZodNaN> { compileType(): ts.TypeNode; compileParser(ctx: IGeneratorContext, path: Path): Iterable<ts.Statement>; } declare class ZcNativeEnum<T extends z.EnumLike> extends AbstractCompiledType<z.ZodNativeEnum<T>> { compileType(): ts.TypeNode; compileParser(ctx: IGeneratorContext, path: Path): Iterable<ts.Statement>; } declare class ZcNever extends AbstractCompiledType<z.ZodNever> { compileType(): ts.TypeNode; compileParser(ctx: IGeneratorContext, path: Path): Iterable<ts.Statement>; } declare class ZcNull extends AbstractCompiledType<z.ZodNull> { compileType(): ts.TypeNode; compileParser(ctx: IGeneratorContext, path: Path): Iterable<ts.Statement>; } declare class ZcNullable<TZod extends z.ZodType> extends AbstractCompiledType<z.ZodNullable<TZod>> { compileType(): ts.TypeNode; compileParser(ctx: IGeneratorContext, path: Path): Generator<ts.Statement>; } declare class ZcNumber extends AbstractCompiledType<z.ZodNumber> { compileType(): ts.TypeNode; compileParser(ctx: IGeneratorContext, path: Path): Iterable<ts.Statement>; } declare class ZcObject<TZod extends z.ZodRawShape> extends AbstractCompiledType<z.ZodObject<TZod>> { canSkipTypeCheck: boolean; compileType(): ts.TypeNode; compileParser(ctx: IGeneratorContext, path: Path): Generator<ts.Statement>; } declare class ZcOptional<TZod extends z.ZodType> extends AbstractCompiledType<z.ZodOptional<TZod>> { compileType(): ts.TypeNode; compileParser(ctx: IGeneratorContext, path: Path): Generator<ts.Statement>; } declare class ZcReadonly<TZod extends z.ZodTypeAny> extends AbstractCompiledType<z.ZodReadonly<TZod>> { compileType(): ts.TypeNode; compileParser(ctx: IGeneratorContext, path: Path): Iterable<ts.Statement>; } declare class ZcRecord<K extends z.KeySchema, V extends z.ZodTypeAny> extends AbstractCompiledType<z.ZodRecord<K, V>> { compileType(): ts.TypeNode; compileParser(ctx: IGeneratorContext, path: Path): Generator<ts.Statement>; } declare class ZcSet<TZod extends z.ZodType> extends AbstractCompiledType<z.ZodSet<TZod>> { compileType(): ts.TypeNode; compileParser(ctx: IGeneratorContext, path: Path): Generator<ts.Statement>; } declare class ZcString extends AbstractCompiledType<z.ZodString> { compileType(): ts.TypeNode; compileParser(ctx: IGeneratorContext, path: Path): Iterable<ts.Statement>; private static _basicCheck; } declare class ZcSymbol extends AbstractCompiledType<z.ZodSymbol> { compileType(): ts.TypeNode; compileParser(ctx: IGeneratorContext, path: Path): Iterable<ts.Statement>; } declare class ZcTuple<T extends [z.ZodTypeAny, ...z.ZodTypeAny[]] | [], TRest extends z.ZodTypeAny | null = null> extends AbstractCompiledType<z.ZodTuple<T, TRest>> { compileType(): ts.TypeNode; compileParser(ctx: IGeneratorContext, path: Path): Generator<ts.Statement>; } declare class ZcUndefined extends AbstractCompiledType<z.ZodUndefined> { compileType(): ts.TypeNode; compileParser(ctx: IGeneratorContext, path: Path): Iterable<ts.Statement>; } declare class ZcUnion<T extends z.ZodUnionOptions> extends AbstractCompiledType<z.ZodUnion<T>> { compileType(): ts.TypeNode; compileParser(ctx: IGeneratorContext, path: Path): Generator<ts.Statement>; } declare class ZcUnknown extends AbstractCompiledType<z.ZodUnknown> { compileType(): ts.TypeNode; compileParser(ctx: IGeneratorContext, path: Path): Iterable<ts.Statement>; } declare class ZcVoid extends AbstractCompiledType<z.ZodVoid> { compileType(): ts.TypeNode; compileParser(ctx: IGeneratorContext, path: Path): Iterable<ts.Statement>; } interface CompileOptions<Standalone extends boolean = false> { /** * Outputs a **standalone** parser. * * The compiler part of `zod-compiler` depends on Zod and TypeScript -- the latter being a very large dependency. If * you'd wish to deploy a compiled Zod parser to i.e. a different repository separate from your schema definition, or * if you just want a dependency-free parser, you can enable this option to instead output a *standalone parser*. * * {@linkcode compile compile()} will then return a {@linkcode StandaloneOutput} with the parser's source code as a function. * This source code can be placed in a module, imported, and the function passed to {@linkcode standalone standalone} * (in the `zod-compiler/standalone` module) to create the exact same parser `compile()` normally would - now without * any dependencies! */ standalone?: Standalone; /** * Controls how values are inlined in the generated code. For more information, see {@linkcode InliningMode}. * * For in-source usage of `zod-compiler`, this need not be changed from `Default`. However, for * {@link CompileOptions.standalone standalone}-compiled schemas, you'll probably want to use {@linkcode InliningMode.Aggressive Aggressive} * for easier deployment. * * @default InliningMode.Default */ inlining?: InliningMode; } /** The output of a {@link CompileOptions.standalone standalone} compilation. */ interface StandaloneOutput { /** * The source code of the compiled parser function. * * This is in the form: * ```ts ignore * function (input, ctx) { * ... * } * ``` */ source: string; /** * The list of **dependency** values this parser requires. * * When the {@link InliningMode inlining mode} is not set to {@linkcode InliningMode.Aggressive Aggressive}, object * values defined in `z.literal()` or via `.default()` or `.catch()` are referenced via a **dependency**; these dependencies * must then be passed to {@linkcode standalone standalone()}. See {@linkcode InliningMode} for more information. * * Compiling with `inlining: InliningMode.Aggressive` outputs a parser with no dependencies; object values will be * serialized directly in source code. */ dependencies: readonly any[]; /** `true` if this parser has any dependencies. */ readonly hasDependencies: boolean; } interface CompiledNonStandaloneParser<TZod extends z.ZodTypeAny> extends CompiledParser<TZod['_output']> { schema: TZod; } /** * Compile a Zod schema for use out-of-source. * * This outputs a {@linkcode StandaloneOutput} which can be used to create a regular {@linkcode CompiledParser} via * {@linkcode standalone standalone()}: * ```ts * import z from 'zod'; * * const schema = z.string(); * * const output = compile(schema, { standalone: true }); * console.log(output.source); // function (input, ctx) { ... } * * // put that source in a module and then `import` it... * const parserFn = Function(`return ${output.source}`)(); * * import standalone from 'zod-compiler/standalone'; * const parser = standalone(parserFn); * * console.log(parser.safeParse('Hello, world!')); // { success: true, data: ... } * ``` */ declare function compile<TZod extends z.ZodTypeAny>(schema: TZod, options: CompileOptions<true>): StandaloneOutput; /** * Compile a Zod schema to an accelerated parser. * ```ts * import z from 'zod'; * * const schema = z.string(); * * const fastSchema = compile(schema); * console.log(fastSchema.safeParse('Hello, world!')); // { success: true, data: ... } * ``` */ declare function compile<TZod extends z.ZodTypeAny>(schema: TZod, options?: CompileOptions<false>): CompiledNonStandaloneParser<TZod>; declare function compile<TZod extends z.ZodTypeAny>(schema: TZod, options?: CompileOptions<boolean>): StandaloneOutput | CompiledNonStandaloneParser<TZod>; interface TypesOptions { /** * Output the schema as a type alias in the form of `export type Schema = ...` (where `Schema` is configurable via * {@linkcode TypesOptions.schemaName schemaName}). * * Setting to `false` will return the type definition directly: * ``` * import z from 'zod'; * import zc from 'zod-compiler'; * * const schema = z.string(); * * console.log(zc.types(schema, { asExport: true })); * // export type Schema = string; * console.log(zc.types(schema, { asExport: false })); * // string * ``` * * @default true */ asExport?: boolean; /** * The name of the generated schema when {@linkcode TypesOptions.asExport asExport} is `true` (the default). * * ``` * import z from 'zod'; * import zc from 'zod-compiler'; * * const schema = z.string(); * * console.log(zc.types(schema)); * // export type Schema = string; * console.log(zc.types(schema, { schemaName: 'MyStructure' })); * // export type MyStructure = string; * ``` * * @default "Schema" */ schemaName?: string; } /** * Exports the `schema` to a TypeScript type definition. * * ```ts * import z from 'zod'; * import zc from 'zod-compiler'; * * const schema = z.string(); * * console.log(zc.types(schema)); * // export type Schema = string; * ``` */ declare function types<TZod extends z.ZodTypeAny>(schema: TZod, options?: TypesOptions): string; type zc_AbstractCompiledType<TZod extends z.ZodType> = AbstractCompiledType<TZod>; declare const zc_AbstractCompiledType: typeof AbstractCompiledType; type zc_CompileOptions<Standalone extends boolean = false> = CompileOptions<Standalone>; type zc_CompiledNonStandaloneParser<TZod extends z.ZodTypeAny> = CompiledNonStandaloneParser<TZod>; declare const zc_CompiledParser: typeof CompiledParser; type zc_DenormalizedError = DenormalizedError; type zc_ErrorMapCtx = ErrorMapCtx; type zc_InliningMode = InliningMode; declare const zc_InliningMode: typeof InliningMode; type zc_IssueData = IssueData; type zc_Primitive = Primitive; type zc_Scalars = Scalars; type zc_StandaloneOutput = StandaloneOutput; type zc_StringValidation = StringValidation; type zc_TypesOptions = TypesOptions; type zc_ZcAny = ZcAny; declare const zc_ZcAny: typeof ZcAny; type zc_ZcArray<TZod extends z.ZodType> = ZcArray<TZod>; declare const zc_ZcArray: typeof ZcArray; type zc_ZcBigInt = ZcBigInt; declare const zc_ZcBigInt: typeof ZcBigInt; type zc_ZcBoolean = ZcBoolean; declare const zc_ZcBoolean: typeof ZcBoolean; type zc_ZcBranded<TZod extends z.ZodTypeAny, B extends string | number | symbol> = ZcBranded<TZod, B>; declare const zc_ZcBranded: typeof ZcBranded; type zc_ZcCatch<TZod extends z.ZodType> = ZcCatch<TZod>; declare const zc_ZcCatch: typeof ZcCatch; type zc_ZcCustomIssue = ZcCustomIssue; type zc_ZcDate = ZcDate; declare const zc_ZcDate: typeof ZcDate; type zc_ZcDefault<TZod extends z.ZodType> = ZcDefault<TZod>; declare const zc_ZcDefault: typeof ZcDefault; type zc_ZcDiscriminatedUnion<TDiscriminator extends string, TOptions extends readonly z.ZodDiscriminatedUnionOption<TDiscriminator>[]> = ZcDiscriminatedUnion<TDiscriminator, TOptions>; declare const zc_ZcDiscriminatedUnion: typeof ZcDiscriminatedUnion; type zc_ZcEnum<T extends [string, ...string[]]> = ZcEnum<T>; declare const zc_ZcEnum: typeof ZcEnum; type zc_ZcError<T = any> = ZcError<T>; declare const zc_ZcError: typeof ZcError; type zc_ZcErrorMap = ZcErrorMap; type zc_ZcFormattedError<T, U = string> = ZcFormattedError<T, U>; type zc_ZcIntersection<T extends z.ZodTypeAny, U extends z.ZodTypeAny> = ZcIntersection<T, U>; declare const zc_ZcIntersection: typeof ZcIntersection; type zc_ZcInvalidArgumentsIssue = ZcInvalidArgumentsIssue; type zc_ZcInvalidDateIssue = ZcInvalidDateIssue; type zc_ZcInvalidEnumValueIssue = ZcInvalidEnumValueIssue; type zc_ZcInvalidIntersectionTypesIssue = ZcInvalidIntersectionTypesIssue; type zc_ZcInvalidLiteralIssue = ZcInvalidLiteralIssue; type zc_ZcInvalidReturnTypeIssue = ZcInvalidReturnTypeIssue; type zc_ZcInvalidStringIssue = ZcInvalidStringIssue; type zc_ZcInvalidTypeIssue = ZcInvalidTypeIssue; type zc_ZcInvalidUnionDiscriminatorIssue = ZcInvalidUnionDiscriminatorIssue; type zc_ZcInvalidUnionIssue = ZcInvalidUnionIssue; type zc_ZcIssue = ZcIssue; type zc_ZcIssueBase = ZcIssueBase; type zc_ZcIssueCode = ZcIssueCode; declare const zc_ZcIssueCode: typeof ZcIssueCode; type zc_ZcIssueOptionalMessage = ZcIssueOptionalMessage; type zc_ZcLiteral<T> = ZcLiteral<T>; declare const zc_ZcLiteral: typeof ZcLiteral; type zc_ZcMap<K extends z.ZodTypeAny, V extends z.ZodTypeAny> = ZcMap<K, V>; declare const zc_ZcMap: typeof ZcMap; type zc_ZcNaN = ZcNaN; declare const zc_ZcNaN: typeof ZcNaN; type zc_ZcNativeEnum<T extends z.EnumLike> = ZcNativeEnum<T>; declare const zc_ZcNativeEnum: typeof ZcNativeEnum; type zc_ZcNever = ZcNever; declare const zc_ZcNever: typeof ZcNever; type zc_ZcNotFiniteIssue = ZcNotFiniteIssue; type zc_ZcNotMultipleOfIssue = ZcNotMultipleOfIssue; type zc_ZcNull = ZcNull; declare const zc_ZcNull: typeof ZcNull; type zc_ZcNullable<TZod extends z.ZodType> = ZcNullable<TZod>; declare const zc_ZcNullable: typeof ZcNullable; type zc_ZcNumber = ZcNumber; declare const zc_ZcNumber: typeof ZcNumber; type zc_ZcObject<TZod extends z.ZodRawShape> = ZcObject<TZod>; declare const zc_ZcObject: typeof ZcObject; type zc_ZcOptional<TZod extends z.ZodType> = ZcOptional<TZod>; declare const zc_ZcOptional: typeof ZcOptional; type zc_ZcReadonly<TZod extends z.ZodTypeAny> = ZcReadonly<TZod>; declare const zc_ZcReadonly: typeof ZcReadonly; type zc_ZcRecord<K extends z.KeySchema, V extends z.ZodTypeAny> = ZcRecord<K, V>; declare const zc_ZcRecord: typeof ZcRecord; type zc_ZcSet<TZod extends z.ZodType> = ZcSet<TZod>; declare const zc_ZcSet: typeof ZcSet; type zc_ZcString = ZcString; declare const zc_ZcString: typeof ZcString; type zc_ZcSymbol = ZcSymbol; declare const zc_ZcSymbol: typeof ZcSymbol; type zc_ZcTooBigIssue = ZcTooBigIssue; type zc_ZcTooSmallIssue = ZcTooSmallIssue; type zc_ZcTuple<T extends [z.ZodTypeAny, ...z.ZodTypeAny[]] | [], TRest extends z.ZodTypeAny | null = null> = ZcTuple<T, TRest>; declare const zc_ZcTuple: typeof ZcTuple; type zc_ZcUndefined = ZcUndefined; declare const zc_ZcUndefined: typeof ZcUndefined; type zc_ZcUnion<T extends z.ZodUnionOptions> = ZcUnion<T>; declare const zc_ZcUnion: typeof ZcUnion; type zc_ZcUnknown = ZcUnknown; declare const zc_ZcUnknown: typeof ZcUnknown; type zc_ZcUnrecognizedKeysIssue = ZcUnrecognizedKeysIssue; type zc_ZcVoid = ZcVoid; declare const zc_ZcVoid: typeof ZcVoid; declare const zc_compilable: typeof compilable; declare const zc_compile: typeof compile; type zc_typeToFlattenedError<T, U = string> = typeToFlattenedError<T, U>; declare const zc_types: typeof types; declare namespace zc { export { zc_AbstractCompiledType as AbstractCompiledType, zc_CompiledParser as CompiledParser, zc_InliningMode as InliningMode, zc_ZcAny as ZcAny, zc_ZcArray as ZcArray, zc_ZcBigInt as ZcBigInt, zc_ZcBoolean as ZcBoolean, zc_ZcBranded as ZcBranded, zc_ZcCatch as ZcCatch, zc_ZcDate as ZcDate, zc_ZcDefault as ZcDefault, zc_ZcDiscriminatedUnion as ZcDiscriminatedUnion, zc_ZcEnum as ZcEnum, zc_ZcError as ZcError, zc_ZcIntersection as ZcIntersection, zc_ZcIssueCode as ZcIssueCode, zc_ZcLiteral as ZcLiteral, zc_ZcMap as ZcMap, zc_ZcNaN as ZcNaN, zc_ZcNativeEnum as ZcNativeEnum, zc_ZcNever as ZcNever, zc_ZcNull as ZcNull, zc_ZcNullable as ZcNullable, zc_ZcNumber as ZcNumber, zc_ZcObject as ZcObject, zc_ZcOptional as ZcOptional, zc_ZcReadonly as ZcReadonly, zc_ZcRecord as ZcRecord, zc_ZcSet as ZcSet, zc_ZcString as ZcString, zc_ZcSymbol as ZcSymbol, zc_ZcTuple as ZcTuple, zc_ZcUndefined as ZcUndefined, zc_ZcUnion as ZcUnion, zc_ZcUnknown as ZcUnknown, zc_ZcVoid as ZcVoid, zc_compilable as compilable, zc_compile as compile, zc_types as types }; export type { zc_CompileOptions as CompileOptions, zc_CompiledNonStandaloneParser as CompiledNonStandaloneParser, zc_DenormalizedError as DenormalizedError, zc_ErrorMapCtx as ErrorMapCtx, zc_IssueData as IssueData, zc_Primitive as Primitive, zc_Scalars as Scalars, zc_StandaloneOutput as StandaloneOutput, zc_StringValidation as StringValidation, zc_TypesOptions as TypesOptions, zc_ZcCustomIssue as ZcCustomIssue, zc_ZcErrorMap as ZcErrorMap, zc_ZcFormattedError as ZcFormattedError, zc_ZcInvalidArgumentsIssue as ZcInvalidArgumentsIssue, zc_ZcInvalidDateIssue as ZcInvalidDateIssue, zc_ZcInvalidEnumValueIssue as ZcInvalidEnumValueIssue, zc_ZcInvalidIntersectionTypesIssue as ZcInvalidIntersectionTypesIssue, zc_ZcInvalidLiteralIssue as ZcInvalidLiteralIssue, zc_ZcInvalidReturnTypeIssue as ZcInvalidReturnTypeIssue, zc_ZcInvalidStringIssue as ZcInvalidStringIssue, zc_ZcInvalidTypeIssue as ZcInvalidTypeIssue, zc_ZcInvalidUnionDiscriminatorIssue as ZcInvalidUnionDiscriminatorIssue, zc_ZcInvalidUnionIssue as ZcInvalidUnionIssue, zc_ZcIssue as ZcIssue, zc_ZcIssueBase as ZcIssueBase, zc_ZcIssueOptionalMessage as ZcIssueOptionalMessage, zc_ZcNotFiniteIssue as ZcNotFiniteIssue, zc_ZcNotMultipleOfIssue as ZcNotMultipleOfIssue, zc_ZcTooBigIssue as ZcTooBigIssue, zc_ZcTooSmallIssue as ZcTooSmallIssue, zc_ZcUnrecognizedKeysIssue as ZcUnrecognizedKeysIssue, zc_typeToFlattenedError as typeToFlattenedError }; } export { AbstractCompiledType, InliningMode, ZcAny, ZcArray, ZcBigInt, ZcBoolean, ZcBranded, ZcCatch, ZcDate, ZcDefault, ZcDiscriminatedUnion, ZcEnum, ZcError, ZcIntersection, ZcIssueCode, ZcLiteral, ZcMap, ZcNaN, ZcNativeEnum, ZcNever, ZcNull, ZcNullable, ZcNumber, ZcObject, ZcOptional, ZcReadonly, ZcRecord, ZcSet, ZcString, ZcSymbol, ZcTuple, ZcUndefined, ZcUnion, ZcUnknown, ZcVoid, compilable, compile, zc as default, types }; export type { CompileOptions, CompiledNonStandaloneParser, DenormalizedError, ErrorMapCtx, IssueData, Primitive, Scalars, StandaloneOutput, StringValidation, TypesOptions, ZcCustomIssue, ZcErrorMap, ZcFormattedError, ZcInvalidArgumentsIssue, ZcInvalidDateIssue, ZcInvalidEnumValueIssue, ZcInvalidIntersectionTypesIssue, ZcInvalidLiteralIssue, ZcInvalidReturnTypeIssue, ZcInvalidStringIssue, ZcInvalidTypeIssue, ZcInvalidUnionDiscriminatorIssue, ZcInvalidUnionIssue, ZcIssue, ZcIssueBase, ZcIssueOptionalMessage, ZcNotFiniteIssue, ZcNotMultipleOfIssue, ZcTooBigIssue, ZcTooSmallIssue, ZcUnrecognizedKeysIssue, typeToFlattenedError };