74 lines
3.5 KiB
Plaintext
74 lines
3.5 KiB
Plaintext
import { i as jsonSchemaValidator, n as JsonSchemaValidator, t as JsonSchemaType } from "./types-DUs7mGBv.mjs";
|
|
|
|
//#region ../core-internal/src/validators/cfWorkerProvider.d.ts
|
|
|
|
/**
|
|
* JSON Schema draft version supported by `@cfworker/json-schema`.
|
|
*/
|
|
type CfWorkerSchemaDraft = '4' | '7' | '2019-09' | '2020-12';
|
|
/**
|
|
* `@cfworker/json-schema`-backed JSON Schema validator. See
|
|
* `@modelcontextprotocol/{client,server}/validators/cf-worker` for the customisation entry point.
|
|
*
|
|
* Default dispatches on the schema's declared dialect: no `$schema` or 2020-12 → `'2020-12'`
|
|
* (SEP-1613); 2019-09 → `'2019-09'`; draft-07 or draft-06 → `'7'`. Schemas declaring any other `$schema` are rejected
|
|
* with a plain `Error`. Passing an explicit `draft` to the constructor
|
|
* overrides this — that draft is used for every schema regardless of `$schema`.
|
|
*
|
|
* Known draft-07 engine gap: `@cfworker/json-schema` does not treat draft-07 `dependencies` as
|
|
* a name→subschema map during `$ref` collection, so a dependency entry whose KEY collides with
|
|
* a JSON Schema keyword (`type`, `default`, `format`, `required`, `pattern`, …) and whose
|
|
* subschema contains a `$ref` throws `Unresolved $ref` at validation time when the dependency
|
|
* triggers — data-dependently, not at compile. The Node (classic Ajv) engine handles the same
|
|
* schema correctly. Callers that hit this receive the SDK's typed validation error (the throw
|
|
* is captured by the validation paths), and the deviation is pinned by a recorded-contract test.
|
|
*
|
|
* @example Use with default configuration (2020-12, shortcircuit on)
|
|
* ```ts source="./cfWorkerProvider.examples.ts#CfWorkerJsonSchemaValidator_default"
|
|
* const validator = new CfWorkerJsonSchemaValidator();
|
|
* ```
|
|
*
|
|
* @example Use with custom configuration
|
|
* ```ts source="./cfWorkerProvider.examples.ts#CfWorkerJsonSchemaValidator_customConfig"
|
|
* const validator = new CfWorkerJsonSchemaValidator({
|
|
* draft: '2020-12',
|
|
* shortcircuit: false // Report all errors
|
|
* });
|
|
* ```
|
|
*/
|
|
declare class CfWorkerJsonSchemaValidator implements jsonSchemaValidator {
|
|
private readonly shortcircuit;
|
|
/** Caller-supplied draft; when set, the `$schema` check is skipped (caller owns dialect). */
|
|
private readonly draft?;
|
|
/**
|
|
* Create a validator
|
|
*
|
|
* @param options - Configuration options
|
|
* @param options.shortcircuit - If `true`, stop validation after first error (default: `true`)
|
|
* @param options.draft - JSON Schema draft version to force for every schema. When set, the
|
|
* `$schema` dispatch is skipped. When omitted, the provider dispatches on each schema's
|
|
* declared `$schema` (2020-12, 2019-09, draft-07, draft-06; absent means 2020-12) and rejects others.
|
|
*/
|
|
constructor(options?: {
|
|
shortcircuit?: boolean;
|
|
draft?: CfWorkerSchemaDraft;
|
|
});
|
|
/**
|
|
* Pick the engine draft for a schema's declared dialect (a caller-forced `{draft}` bypasses
|
|
* this — do not second-guess by `$schema`). No `$schema` or 2020-12 → `'2020-12'`; 2019-09 →
|
|
* `'2019-09'`; draft-07 or draft-06 → `'7'`; anything else → `Error`.
|
|
*/
|
|
private _draftFor;
|
|
/**
|
|
* Create a validator for the given JSON Schema
|
|
*
|
|
* Unlike AJV, this validator is not cached internally
|
|
*
|
|
* @param schema - Standard JSON Schema object
|
|
* @returns A validator function that validates input data
|
|
*/
|
|
getValidator<T>(schema: JsonSchemaType): JsonSchemaValidator<T>;
|
|
}
|
|
//#endregion
|
|
export { CfWorkerSchemaDraft as n, CfWorkerJsonSchemaValidator as t };
|
|
//# sourceMappingURL=cfWorkerProvider-C03CSigr.d.mts.map |