import type { JSONSchema7, JSONSchema7Definition, JSONSchema7Type } from "json-schema"; import { type Deduplicator, type Intersector } from "../../array.js"; type SchemaKey = keyof JSONSchema7; /** * An assigner function operates at the schema-object level. * It receives the partially merged `target` and the original * `left` and `right` schemas. * * In most cases, it modifies and returns the `target` object, * but it may also return a completely new schema object if needed. * * Assigners are used for keywords that cannot be merged by simple * value-level functions, often because they interact with other * keywords or require holistic decisions. */ export type Assigner = (target: R, l: R, r: R) => R; /** * A merger function combines two values for a specific JSON Schema keyword. */ export type Merger = (a: T, b: T) => T; /** * A validation function that ensures consistency between two schema keywords. */ export type Check = (target: Required>) => boolean; export type CheckEntry = readonly [ A, B, Check ]; export declare function check(a: A, b: B, check: Check): CheckEntry; export interface MergeOptions { /** * Custom function to test whether a regular expression `subExpr` * is considered a subset of another `superExpr`. * @default Object.is */ isSubRegExp?: (subExpr: string, superExpr: string) => boolean; /** * Merger function for combining regular expression patterns * @default simplePatternsMerger */ mergePatterns?: Merger; /** * Intersector function for merging JSON values (enum keyword) * @default intersection */ intersectJson?: Intersector; /** * Deduplication strategy for JSON Schema definitions. * @default identity */ deduplicateJsonSchemaDef?: Deduplicator; /** * Fallback merger applied when no keyword-specific merger is defined. * @default identity */ defaultMerger?: Merger; /** * A mapping of schema keywords to merger functions. * * - A merger operates on **values of a single keyword** (`a`, `b` → merged value). * - When provided, a custom merger **overrides the default merger** for that keyword. */ mergers?: Partial<{ [K in SchemaKey]: Merger>; }>; /** * A collection of keyword groups with associated assigner functions. * * - An assigner operates at the **schema-object level** (`target`, `left`, `right`). * - Custom assigners are **appended** to the default assigners, * but can also **replace behavior** for specific keywords if they overlap. */ assigners?: Iterable<[SchemaKey[], Assigner]>; /** * Consistency checks to validate relationships between * pairs of schema keywords (e.g. `minimum` ≤ `maximum`). * * - A check ensures that two related keywords do not conflict. * - Providing this option **replaces the default checks** completely. * * @default DEFAULT_CHECKS */ checks?: Iterable>; } export declare const DEFAULT_CHECKS: (CheckEntry<"minimum", "maximum"> | CheckEntry<"exclusiveMinimum", "maximum"> | CheckEntry<"minimum", "exclusiveMaximum"> | CheckEntry<"exclusiveMinimum", "exclusiveMaximum"> | CheckEntry<"minLength", "maxLength"> | CheckEntry<"minItems", "maxItems"> | CheckEntry<"minProperties", "maxProperties">)[]; export declare function createMerger({ mergePatterns, isSubRegExp, intersectJson, deduplicateJsonSchemaDef, defaultMerger, assigners, mergers, checks, }?: MergeOptions): { mergeSchemaDefinitions: (left: JSONSchema7Definition, right: JSONSchema7Definition) => boolean | JSONSchema7; mergeArrayOfSchemaDefinitions: (schemas: JSONSchema7Definition[]) => JSONSchema7Definition; }; export {};