import type { z } from 'zod'; import type { ReferencePath } from '#src/references/types.js'; /** * Context passed to fix functions during the schema+data walk. * Contains only the path — fixes operate on local values without rootData access. */ export interface DefinitionFixContext { /** The absolute path to the current node in the data */ readonly path: ReferencePath; } /** * A fix function that silently transforms a value during the save pipeline. * Return the fixed value, or the original value if no fix is needed. */ export type DefinitionFix = (value: T, ctx: DefinitionFixContext) => T; /** * Metadata stored on a schema node annotated by `withFix`. * Exposed as readonly; the registry manages mutation internally. */ export interface FixSchemaMeta { readonly fixes: readonly DefinitionFix[]; } /** * Registry that stores fix metadata on Zod schema instances. * * Uses a WeakMap to avoid interfering with Zod's type system. * Annotated by `withFix()`; read by `applyDefinitionFixes()`. */ export declare const definitionFixRegistry: { add(schema: z.ZodType, fix: DefinitionFix): void; get(schema: z.ZodType): FixSchemaMeta | undefined; }; /** * Creates a schema decorator that registers a silent auto-fix. * * Used with `.apply()`: * ```typescript * z.object({ ... }).apply(withFix((value, ctx) => fixedValue)) * ``` * * @param fix - The fix function to register * @returns A function that decorates a schema with the fix */ export declare function withFix(fix: DefinitionFix>): (schema: T) => T; //# sourceMappingURL=definition-fix-registry.d.ts.map