/** * Merging of the JSON Schemas of intersections whose members are definitions. * * Zod represents an intersection with `allOf`. In output JSON Schemas, objects reject the * properties they do not declare (`additionalProperties: false`), so `allOf` of two objects with * different properties does not validate any object, while `z.intersection` merges them (each * object strips the properties it does not declare, and the results are merged). Zod 4.5+ merges * the objects of an intersection into one object, but not the ones that are definitions, which * are only a reference: the members of intersections with definitions are merged here, with the * rules of Zod, into the same `allOf` array, so every JSON Schema that holds it (e.g. wrappers of * the intersection) gets the merged object. */ type Json = Record; /** Name of the definition a reference points to (`#/$defs/`, `#/definitions/`). */ export declare function getDefinitionName(ref: unknown): string | undefined; /** * Merges the intersections of a conversion once the definitions of their members are known. * Zod calls the `override` of the definitions in any order, so the intersections wait for them. */ export declare class IntersectionMerger { private readonly annotations; private definitions; private intersections; private arrays; constructor(annotations: ReadonlySet); /** Forgets the JSON Schemas of the previous conversion. */ reset(): void; addDefinition(name: string, json: Json): void; addIntersection(json: Json, isDefinition: boolean, sources: string[]): void; /** Merges the intersections whose members are known. */ mergeReady(): void; /** Merges an intersection. Returns `false` if it has to wait for its members. */ private merge; /** * References that can replace a merged intersection: its members that are references, and the * definitions it comes from, referenced like its members (`$defs` or `definitions`). Names * that would be encoded in references are not referenced, as the encoding depends on Zod. */ private getReferences; /** * Removes the annotations that a referenced definition already has (e.g. the description of * the intersection that a copy references): Zod can call the override of a copy before its * intersection is merged, when the copy does not reference the definition yet. */ private removeReferencedAnnotations; /** * Leaves a merged intersection as the merged object. A reference is only left as `$ref` in a * definition: Zod reads the JSON Schema of other schemas after the `override` to build the ones * that come from them, and copies `$ref` next to their other keywords (which are ignored next * to `$ref` before draft 2019-09). */ private unwrap; private isReference; /** References to definitions of the conversion (not to the ones Zod names `__schema`). */ private isDefinitionReference; /** * Object that a member stands for: an object, or the definition that a reference points to. * `undefined` if it is not known yet, `null` if it is not an object that can be merged. */ private resolve; /** * Merges objects with the rules of Zod: the properties of all of them (a property declared by * several ones has to satisfy all of them), the required properties of all of them, and the * properties they do not declare are rejected only if all of them reject them. */ private mergeObjects; } export {};