import type { Json, SerializedSchema } from "@valbuild/core"; /** * Can this value, taken from one schema, be written into another? * * The question restore asks, and it is NOT the question validation asks. * Validation checks a value against the schema it belongs to. This compares two * schemas — the one a value was stored under and the one it is being written * into — because a restore moves a value across a schema change, and possibly * across paths. * * Three answers, not two. `unknown` is where the comparison genuinely cannot * decide, and it exists so that an editor is told "we are not sure" rather than * being given a confident answer we made up. Treating unknown as compatible * writes values that break; treating it as incompatible blocks restores that * would have been fine. */ export type Compatibility = { status: "compatible"; } | { status: "incompatible"; reason: IncompatibleReason; } | { status: "unknown"; message: string; }; export type IncompatibleReason = { kind: "type-changed"; from: string; to: string; } | { kind: "no-matching-variant"; variants: string[]; } | { kind: "unknown-field"; keys: string[]; } | { kind: "missing-required"; keys: string[]; } | { kind: "not-optional"; } | { kind: "literal-changed"; from: string; to: string; } | { kind: "different-module"; from: string; to: string; }; /** * A sentence an editor can act on, for the popup that explains a refusal. * * Kept beside the reasons rather than in the UI so that adding a reason without * wording for it is a type error rather than a blank dialog. */ export declare function explainIncompatible(reason: IncompatibleReason): string; export declare function checkCompatibility(from: { schema: SerializedSchema; value: Json; }, to: { schema: SerializedSchema; }): Compatibility;