import { JsonValue } from "cojson"; import { z } from "../zodReExport.js"; type OptionalInSchema = { _zod: { optin: "optional"; }; }; /** * Get type from Zod schema definition. * * Similar to `z.infer`, but we manually traverse Zod types to ensure we only allow what we can handle */ export type TypeOfZodSchema = S extends z.core.$ZodOptional ? TypeOfZodSchema | undefined : S extends z.core.$ZodNullable ? TypeOfZodSchema | null : S extends z.ZodJSONSchema ? JsonValue : S extends z.core.$ZodUnion ? TypeOfZodSchema : S extends z.core.$ZodIntersection ? TypeOfZodSchema & TypeOfZodSchema : S extends z.core.$ZodObject ? /** * Cannot use {@link PartialOnUndefined} because evaluating TypeOfZodSchema * to know if the value can be undefined does not work with recursive types. */ { -readonly [key in keyof Shape as Shape[key] extends OptionalInSchema ? never : key]: TypeOfZodSchema; } & { -readonly [key in keyof Shape as Shape[key] extends OptionalInSchema ? key : never]?: TypeOfZodSchema; } : S extends z.core.$ZodRecord ? Key extends z.core.$partial ? Partial, TypeOfZodSchema>> : Record, TypeOfZodSchema> : S extends z.core.$ZodArray ? TypeOfZodSchema[] : S extends z.core.$ZodTuple ? { [key in keyof Items]: TypeOfZodSchema; } : S extends z.core.$ZodString ? string : S extends z.core.$ZodNumber ? number : S extends z.core.$ZodBoolean ? boolean : S extends z.core.$ZodLiteral ? Literal : S extends z.core.$ZodDate ? Date : S extends z.core.$ZodEnum ? Enum[keyof Enum] : S extends z.core.$ZodTemplateLiteral ? pattern : S extends z.core.$ZodReadonly ? TypeOfZodSchema : S extends z.core.$ZodDefault ? TypeOfZodSchema : S extends z.core.$ZodCodec ? Out["_zod"]["output"] : S extends z.core.$ZodCatch ? TypeOfZodSchema : never; export {}; //# sourceMappingURL=TypeOfZodSchema.d.ts.map