import { tsDnaSeq, tsDnaParserFn, tsDnaValidatorFn } from '@ytrynot/dna/toJs'; export { tsDnaParserFn as DnaParseFn, tsDnaValidatorFn as DnaValidatorFn, parser, toJS, validator } from '@ytrynot/dna/toJs'; /** * Error thrown when a JSON Schema feature is outside the supported scope. * * DNA-SChema only supports JSON Schema draft 2020-12 with internal references * (internal `$ref`, `$defs`, `$id`). External references, remote schemas, and * unsupported draft versions trigger this error. */ declare class OutOfScopeError extends Error { /** * @param feature - Human-readable description of the unsupported feature that triggered the error. */ constructor(feature: string); } /** * Resolves a JSON Pointer (`#/path/to/node`) against a schema root object. * * Implements RFC 6901 JSON Pointer resolution restricted to internal fragments * (pointers starting with `#`). Performs `~0`/`~1` escape decoding on each * segment. * * @param pointer - The JSON Pointer string to resolve (must start with `#`, or be empty for the root). * @param root - The root schema object to resolve the pointer against. * @returns A tuple `[target, pointer]` where `target` is the resolved node and * `pointer` is the original pointer string, or `undefined` if the pointer is * not an internal fragment or a segment cannot be resolved. */ declare function resolvePointer(pointer: string, root: any): any | undefined; /** * Converts a JSON Schema 2020-12 document into DNA bytecode. * * This is the primary entry point of the schvalid package. It performs a * stack-based traversal of the schema, resolving internal `$ref`, `$defs`, * `$anchor`, and `$dynamicAnchor` references, and emits a compact DNA * sequence (`tsDnaSeq`) that can be compiled by `@ytrynot/dna`'s `validator` * or `parser`. * * Only JSON Schema draft 2020-12 is supported. External references (HTTP/URN * `$ref`, remote files) are out of scope and will throw `OutOfScopeError`. * * @param root - The JSON Schema root node (an object or boolean). * @param rootPath - The base URI/path for the root schema (defaults to `"#"`). * @param options - Optional compilation flags. * - `formatAssertion` — enable `format` keyword validation (default: `false`, per Draft 2020-12). * - `strict` — enable strict JSON Schema validation (default: `true`). * - `validateSchema` — validate the schema against 2020-12 meta-rules (default: `true`). * @returns The generated DNA bytecode sequence (`tsDnaSeq`). * @throws {Error} if `root` is not an object or boolean, or is `null`. * @throws {OutOfScopeError} if the schema declares an unsupported `$schema` version. */ declare function jschemaToDna(root: any, rootPath?: string, options?: { formatAssertion?: boolean; strict?: boolean; validateSchema?: boolean; }): tsDnaSeq; type tsCompileOptions = { /** Enable format validation (default: false, per Draft 2020-12) */ formatAssertion?: boolean; /** Enable strict JSON Schema validation (default: true) */ strict?: boolean; /** Validate schema against JSON Schema 2020-12 rules (default: true) */ validateSchema?: boolean; }; /** * Builds a hybrid parser directly from DNA bytecode (compiles `validate`/`parse` * ONCE, then delegates to `combineFast`). See `combineFast` for the full * behavior/trade-off documentation. */ declare const parserFast: (dna: tsDnaSeq) => tsDnaParserFn; /** * Schvalid builder API - compile schema once, validate many times * @param mode - "validation" for boolean result, "parser" for detailed errors, * "fast" for the hybrid validate-then-parse (see `parserFast`), "all" for validate + parse + parseFast * @returns Compiler function */ declare function schvalid(mode: "validation"): { compile(schema: any, options?: tsCompileOptions): tsDnaValidatorFn; }; declare function schvalid(mode: "parser"): { compile(schema: any, options?: tsCompileOptions): tsDnaParserFn; }; declare function schvalid(mode: "fast"): { compile(schema: any, options?: tsCompileOptions): tsDnaParserFn; }; declare function schvalid(mode: "all"): { compile(schema: any, options?: tsCompileOptions): { validate: tsDnaValidatorFn; parse: tsDnaParserFn; parseFast: tsDnaParserFn; }; }; export { OutOfScopeError, jschemaToDna, parserFast, resolvePointer, schvalid };