import type { z } from 'zod'; /** * Represents a single step in navigating through a schema structure. * * - `object-key`: navigate into an object property * - `tuple-index`: navigate into a specific tuple position * - `discriminated-union-array`: enter an array and pick the unique element * matching a discriminator value * - `array`: descend into a plain array's element schema (non-deterministic) * - `record`: descend into a record's value schema (non-deterministic) */ export type SchemaPathElement = { type: 'object-key'; key: string; } | { type: 'tuple-index'; index: number; } | { type: 'discriminated-union-array'; discriminatorKey: string; value: string; } | { type: 'array'; } | { type: 'record'; }; /** * The context passed to visitors during a schema structure walk. * Carries the current path as `SchemaPathElement[]`. */ export interface SchemaStructureWalkContext { /** The absolute path to the current node in the schema. */ readonly path: SchemaPathElement[]; } /** * A visitor that plugs into `walkSchemaStructure`. * * Called for every node in the schema tree. If the visitor returns a * cleanup function, it will be called after all children have been visited — * similar to the React `useEffect` cleanup pattern. */ export interface SchemaStructureVisitor { visit(schema: z.ZodType, ctx: SchemaStructureWalkContext): (() => void) | undefined; } /** * Walks a Zod schema structure (without data) invoking registered visitors * at every schema node. * * Unlike `walkDataWithSchema`, this operates on the schema alone. * Every structural descent produces a path element: * - Object keys → `object-key` * - Tuple indices → `tuple-index` * - Arrays of discriminated unions → `discriminated-union-array` (one per branch) * - Plain arrays → `array` * - Records → `record` * - Discriminated unions on objects are transparent (no path element) * * Uses a `Set` circular-reference guard with delete-on-backtrack * so the same schema can appear at different paths. */ export declare function walkSchemaStructure(schema: z.ZodType, visitors: readonly SchemaStructureVisitor[]): void; //# sourceMappingURL=walk-schema-structure.d.ts.map