UNPKG

json-schema-describes-subset

Version:

Tools for static JSON schema analysis, including functions to determine if one schema describes a subset of another or if a schema describes the empty set or to convert a schema to its disjunctive normal form (DNF).

29 lines (28 loc) 1.24 kB
import { AllOfSchema, AnyOfSchema, type LogicLiteral, type LogicalCombination, type LogicalCombinationOfLiterals } from '../atomic-schema.js'; export type ConjunctionOfLiterals = AllOfSchema<LogicLiteral>; /** * DNF without simplifications using the internal {@link LogicLiteral} * */ export type RawDNF = AnyOfSchema<ConjunctionOfLiterals>; export declare function negate(schema: LogicalCombination): LogicalCombinationOfLiterals; /** * Makes all the `not`s move down, so that `NOT`s are exclusively in the * literals. `NOT`s are then resolved by applying {@link negateAtomicSchema}. * */ export declare function moveNotsToLiterals(schema: LogicalCombination): LogicalCombinationOfLiterals; /** * Also considered DNF but is not complete as the type {@link RawDNF} which is * always an `OR` of `AND`s of `LogicLiteral`s. * */ type RawDNFPart = RawDNF | ConjunctionOfLiterals | LogicLiteral; /** * Moves `AND`s down and `OR`s up to create the RawDNF. * */ export declare function logicalCombinationOfLiteralsToRawDNFPart(schema: LogicalCombinationOfLiterals): RawDNFPart; export declare function dnfPartToRawDNF(dnfPart: RawDNFPart): RawDNF; export declare function toRawDNF(schema: LogicalCombination): RawDNF; export {};