import type { z, ZodArray } from 'zod'; /** * A merge rule attached to a Zod schema node via `withMergeRule`. * Controls how `mergeDataWithSchema` combines current and desired values at that node. * * - `replace`: Always replace current with desired (same as default leaf behavior) * - `by-key`: Merge array items by key — items in current not present in desired are kept */ export type MergeRule = { readonly kind: 'replace'; } | { readonly kind: 'by-key'; readonly getKey: (item: unknown) => string; }; /** * Retrieves the merge rule attached to a schema node, if any. */ export declare function getMergeRule(schema: z.ZodType): MergeRule | undefined; /** * Creates a schema decorator that registers a merge rule on the schema node. * * ```typescript * z.object({ ... }).apply(withMergeRule({ kind: 'replace' })) * ``` * * @param rule - The merge rule to attach * @returns A function that decorates a schema with the rule */ export declare function withMergeRule(rule: MergeRule): (schema: T) => T; /** * Creates a schema decorator that registers a `by-key` merge rule on an array schema. * * Infers the element type from the array schema so `getKey` is strongly typed. * * ```typescript * z * .array(z.object({ ref: z.string(), value: z.number() })) * .apply(withByKeyMergeRule({ getKey: (item) => item.ref })) * ``` * * @param options - Options with a typed `getKey` function * @returns A schema decorator that annotates the array node with a by-key merge rule */ export declare function withByKeyMergeRule(options: { getKey: (item: z.output[number]) => string; }): (schema: T) => T; //# sourceMappingURL=merge-rule-registry.d.ts.map