/** * Runtime validation against the spec JSON Schemas, using ajv. * * The spec ships draft 2020-12 schemas with internal `$defs` (no cross-file * `$ref`s). We register every schema under its `$id` so ajv can resolve any * `#/$defs/...` pointer within it, then expose: * * - `validateAt(schemaRef, instance)` — validate against a spec-relative ref like * `events/stream-chunk.schema.json` or `actions/send-message.schema.json#/$defs/Request` * (the exact form used by `conformance/fixtures.json`). * - `validateEvent` / `validateAction` — convenience validators that pick the * right schema from a frame's discriminator and validate it. * * Schemas are loaded from the spec directory on disk. This module is Node-only * (it reads files); it is intended for build/test/server use, not the browser * bundle. The wire client (`client.ts`) does not import it — validation is opt-in. */ import { type ErrorObject as AjvError } from 'ajv/dist/2020.js'; import type { ActionType, EventType } from './types.js'; /** Default location of the spec dir relative to this source file (../../spec). */ export declare const DEFAULT_SPEC_DIR: string; export interface ValidationResult { valid: boolean; errors: AjvError[]; } export declare class ProtocolValidator { private readonly ajv; /** spec-relative file path → the schema's `$id` (used to build `$ref`-able URIs). */ private readonly fileToId; private readonly cache; private constructor(); /** Load every `*.schema.json` under `specDir` and register it with ajv. */ static load(specDir?: string): Promise; /** * Validate `instance` against a spec-relative schema ref. The ref is the form * used in `fixtures.json`: a file path, optionally with a JSON-pointer fragment * into the schema's `$defs` (e.g. `actions/ping.schema.json#/$defs/Request`). */ validateAt(schemaRef: string, instance: unknown): ValidationResult; /** Validate a server event frame by selecting the schema from its `type`. */ validateEvent(frame: { type: EventType; } & Record): ValidationResult; /** Validate a client action frame by selecting the schema from its `action`. */ validateAction(frame: { action: ActionType; } & Record): ValidationResult; private compile; } /** Render ajv errors into a single human-readable string. */ export declare function formatErrors(errors: AjvError[]): string; //# sourceMappingURL=validate.d.ts.map