import type { z } from 'zod'; import type { ReferencePath } from '#src/references/types.js'; /** * The context passed to visitors during a schema walk. * Carries the current path and entity context. */ export interface SchemaWalkContext { /** The absolute path to the current node in the data. */ readonly path: ReferencePath; /** The entity ID of the closest ancestor entity (undefined at root level). */ readonly entityId: string | undefined; /** Path relative to the closest ancestor entity (or absolute if at root). */ readonly entityRelativePath: ReferencePath; } /** * A visitor that plugs into `walkDataWithSchema`. * * Called for every node in the schema tree. The visitor receives the schema * instance and can call its own registry internally. 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 SchemaNodeVisitor { visit(schema: z.ZodType, data: unknown, ctx: SchemaWalkContext): (() => void) | undefined; } /** * Walks a Zod schema structure in parallel with parsed data, invoking * registered visitors whenever schema nodes are encountered. * * Each visitor's `visit()` is called for every node. If it returns a cleanup * function, that function is called after all children have been visited — * similar to the React `useEffect` cleanup pattern. * * The walker is entity-aware: it detects entity boundaries via * `definitionRefRegistry` annotations and tracks the current entity ID and * relative path, exposing them through `SchemaWalkContext`. * * Only serializable, structurally-traversable schema types are supported. * Non-serializable types (transform, custom, file, symbol, promise, function, * lazy, etc.) will throw at walk time. * * Discriminated unions are fully supported. Plain `z.union()` is allowed only * when every option is a leaf type (string, enum, or literal); otherwise it throws. */ export declare function walkDataWithSchema(schema: z.ZodType, data: unknown, visitors: readonly SchemaNodeVisitor[]): void; //# sourceMappingURL=walk-data-with-schema.d.ts.map