import type { ZodTypeAny } from "zod"; import type { Prng } from "@zod4-mock/locale-core"; export interface ZodDef { type: string; check?: string; format?: string; shape?: Record; element?: ZodTypeAny; entries?: Record; values?: unknown[]; innerType?: ZodTypeAny; options?: ZodTypeAny[]; optionsMap?: Map; discriminator?: string; in?: ZodTypeAny; out?: ZodTypeAny; items?: ZodTypeAny[]; rest?: ZodTypeAny; keyType?: ZodTypeAny; valueType?: ZodTypeAny; left?: ZodTypeAny; right?: ZodTypeAny; getter?: () => ZodTypeAny; defaultValue?: () => unknown; checks?: ZodCheck[]; } export interface ZodCheck { check: string; minimum?: number; maximum?: number; length?: number; value?: unknown; inclusive?: boolean; format?: string; prefix?: string; suffix?: string; includes?: string; pattern?: RegExp; } export declare function def(schema: ZodTypeAny): ZodDef; export declare function checks(schema: ZodTypeAny): ZodCheck[]; /** Recursively unwraps modifiers like .optional(), .nullable(), .default(), etc. */ export declare function unwrap(schema: ZodTypeAny): ZodTypeAny; /** Unwraps the schema and returns its core ZodDef. */ export declare function getLeafDef(schema: ZodTypeAny): ZodDef; /** * B63 — strip outer `optional` / `nullable` wrappers, returning the inner * schema and the list of stripped wrapper types in outer-to-inner order. * * Shared by `WorldImpl.generate` (which rolls absent per wrapper) and * `explainSchema` (which discards the list). Restricted to * `optional`/`nullable` (not `default`/`readonly`/`catch`/`brand`) to match * the byte-identical pre-extraction loop semantics at both sites. */ export declare function stripOuterOptionalNullable(schema: ZodTypeAny): { inner: ZodTypeAny; wrappers: Array<"optional" | "nullable">; }; /** * B31 — collapses the `while (d.type === "lazy")` loop that previously * appeared in four near-identical places (`world.ts` ×3 + `explain.ts` ×1). * * Walks `z.lazy(...)` references to their resolved targets. When a `cache` * is supplied (the per-world `lazyCache`) the resolved getter result is * memoized so repeated unwraps of the same outer lazy don't call the user's * getter twice — this is the existing `WorldImpl` semantics. `explain.ts` * passes no cache and gets the previous one-shot behaviour. * * Module-level (not an instance method) so the cache-less explain site * shares the same code path. */ export declare function resolveLazyChain(schema: ZodTypeAny, cache?: WeakMap): ZodTypeAny; /** * B30 — collapses the optional/nullable/default unwrap loop that previously * appeared in two near-identical places (`world.ts:generateObjectFields` + * `collection.ts:generateZodObject`). * * Walks the `.optional()` / `.nullable()` / `.default()` wrapper chain on a * single field's schema. At each layer rolls `prng.random() < optProb`; on * the first absent roll the loop breaks and returns the appropriate absent * resolution. Otherwise the chain is fully unwrapped and `inner` carries the * non-wrapper schema for downstream generation. * * PRNG consumption: exactly one `prng.random()` per wrapper layer, terminated * on first absent roll (matching the two original sites byte-for-byte). * * `allowAbsent` — when `false`, every layer still rolls `prng.random()` but * the absent branch is never taken (the chain is fully unwrapped). This * preserves the world.ts call-site semantics where a non-undefined * `fieldOverride` suppresses the absent branch while still consuming PRNG * state at each layer. * * Return shape: * - `absent === null` — generate from `inner` normally. * - `{ kind: "skip" }` — optional layer with no captured `.default()` * fallback; the caller assigns `undefined` * (and typically `continue`s). * - `{ kind: "default", value }` — assign `value` verbatim. Used for: * • `.default()` absent (value = the default), * • `.optional()` absent with a previously captured fallback, * • `.nullable()` absent (value = `null`). */ export type UnwrappedAbsent = { kind: "skip"; } | { kind: "default"; value: unknown; }; export declare function unwrapOptionalChainForField(fieldSchema: ZodTypeAny, prng: Prng, optProb: number, allowAbsent?: boolean): { inner: ZodTypeAny; absent: UnwrappedAbsent | null; }; /** Runs the 5-stage string-modifier pipeline (see B29). */ export declare function applyStringModifiers(value: string, allChecks: ZodCheck[]): string; /** Runs the number-modifier pipeline (see B29). */ export declare function applyNumberModifiers(value: number, allChecks: ZodCheck[]): number; /** * Applies formatting modifiers (case, trim, transform) to a value based on the schema. * * B29: thin dispatcher over the two split pipelines. Most callers don't statically * know whether the value is a string or a number (e.g. `generateFromKey` returns * `unknown`), so this shim keeps the runtime type-routing at one place. Callers * that DO know the type (e.g. `generateZodString`) can call * `applyStringModifiers` / `applyNumberModifiers` directly. */ export declare function applyModifiers(value: unknown, schema: ZodTypeAny): unknown; //# sourceMappingURL=zod-def.d.ts.map