import { i as DiagnosticsOptions } from "../diagnostics-mftUZI7c.mjs"; import { i as OpenApiVersionInfo, r as JsonSchemaDraft } from "../version-BEBx10ND.mjs"; //#region src/core/normalise.d.ts /** * Per-node transform applied by {@link deepNormalise} when no * diagnostics context needs to be threaded — see * {@link NodeTransformWithContext} for the variant used by the JSON * Schema normalisation path. * * @group Adapter */ type NodeTransform = (node: Record) => Record; /** * Deep-normalise a JSON Schema object by applying a per-node transform * and recursing into every sub-schema location. * * The optional `visited` set guards against shared object references and * cycles introduced upstream (e.g. by the OpenAPI bundler's * `structuredClone`-based inlining of external refs). The walk skips * already-seen nodes by returning the original reference rather than * recursing forever. */ declare function deepNormalise(schema: Record, transform: NodeTransform, visited?: WeakSet): Record; /** * Per-node context threaded through `deepNormaliseWithContext`. * * Carries the diagnostics sink and the JSON Pointer to the current * node so per-node transforms can emit pointer-accurate diagnostics * when they translate or reject legacy constructs. * * `documentHasDynamicAnchor` is set once at the entry point by scanning * the input for any `$dynamicAnchor`/`$recursiveAnchor` keyword. Per- * node transforms read it to decide whether a `$dynamicRef`/`$recursiveRef` * rewrite needs a `dynamic-ref-degraded` diagnostic — a ref pointing at * an anchor in the document body cannot be statically resolved without * losing dynamic-scope semantics, while a document with no dynamic * anchors at all has no semantics to lose. * * `documentHasRecursiveAnchor` is the same idea for Draft 2019-09's * `$recursiveAnchor` keyword. * * `declaredDraft` carries the draft the normaliser is operating under * (when known) so per-node transforms can emit `keyword-out-of-draft` * diagnostics for keywords introduced in a later draft. */ interface NodeContext { diagnostics: DiagnosticsOptions | undefined; pointer: string; documentHasDynamicAnchor: boolean; documentHasRecursiveAnchor: boolean; declaredDraft: JsonSchemaDraft | undefined; } /** * Per-node transform applied by {@link deepNormaliseWithContext}. * Receives the supplied {@link NodeContext} alongside the node so * draft-specific rewrites can emit diagnostics with accurate pointers. * * @group Adapter */ type NodeTransformWithContext = (node: Record, ctx: NodeContext) => Record; /** * Deep-normalise a JSON Schema object, threading a context (diagnostics * sink + JSON Pointer) through each recursive call. Used by the JSON * Schema normalisation path so per-node transforms can emit diagnostics * with accurate pointers. * * Mirrors `deepNormalise` structurally — keep the two in sync when * adding new sub-schema locations. */ declare function deepNormaliseWithContext(schema: Record, transform: NodeTransformWithContext, ctx: NodeContext): Record; /** * Normalise Draft 04 `exclusiveMinimum`/`exclusiveMaximum` from boolean * to number form, plus the other Draft 04 translations applied to a * single node. * * In Draft 04: * - `exclusiveMinimum: true` + `minimum: 5` → value must be \> 5 * - `exclusiveMinimum: false` (or absent) + `minimum: 5` → value must be \>= 5 * * In Draft 06+: * - `exclusiveMinimum: 5` → value must be \> 5 (no separate `minimum`) * - `minimum: 5` → value must be \>= 5 * * The transform converts boolean form to number form so the walker can * treat `exclusiveMinimum`/`exclusiveMaximum` uniformly as numbers. * * This function preserves the no-context signature for the OpenAPI 3.0 * and Swagger 2.0 normalisers that compose it directly. The JSON Schema * normalisation path uses the internal `normaliseDraft04NodeWithContext` * helper via `deepNormaliseWithContext` to thread diagnostics. */ declare function normaliseDraft04Node(node: Record): Record; /** * Pick the per-node transform that normalises a single Schema Object to * canonical Draft 2020-12 form for the supplied draft. Exposed so the * OpenAPI 3.1 path can honour a non-default `jsonSchemaDialect` * declaration by routing each Schema Object through the matching * transform without re-implementing the dispatch. */ declare function selectDraftTransform(draft: JsonSchemaDraft): NodeTransformWithContext; /** * Scan a JSON document body for the presence of a named keyword * anywhere in the structure. Walks both arrays and objects without * regard to schema-vs-data position — the caller is responsible for * passing a keyword whose presence is meaningful at any depth. * * Cycle-safe: cyclic references introduced by the OpenAPI bundler's * `structuredClone` of external refs are short-circuited via the * `visited` set so the scan terminates. */ declare function documentContainsKeyword(value: unknown, keyword: string, visited?: WeakSet): boolean; /** * Normalise a JSON Schema to canonical Draft 2020-12 form. * Deep-clones the input — the original is never mutated. * * When `diagnostics` is supplied, per-node transforms emit diagnostics * for legacy-keyword rewrites and invalid constructs (e.g. `divisibleBy` * conflicts, non-string entries in a `dependentRequired` array, legacy * `dependencies` reaching the 2020-12 path). */ declare function normaliseJsonSchema(schema: Record, draft: JsonSchemaDraft, diagnostics?: DiagnosticsOptions): Record; /** * Normalise an OpenAPI document's schemas for walker consumption. * Handles version-specific keyword transformations. * * Returns the same object reference if no normalisation is needed * (OpenAPI 3.1.x), or a deep-cloned normalised copy otherwise. */ declare function normaliseOpenApiSchemas(doc: Record, version: OpenApiVersionInfo, diagnostics?: DiagnosticsOptions): Record; //#endregion export { NodeContext, NodeTransform, NodeTransformWithContext, deepNormalise, deepNormaliseWithContext, documentContainsKeyword, normaliseDraft04Node, normaliseJsonSchema, normaliseOpenApiSchemas, selectDraftTransform };