quran-md-plugin / node_modules /@modelcontextprotocol /sdk /dist /cjs /validation /cfworker-provider.js
Z User
phase7: MCP stdio smoke test (handshake + tools/list + get_roots 6:74) — 4/4 tests PASS
54a6341 quran-md-plugin / node_modules /@modelcontextprotocol /sdk /dist /cjs /validation /cfworker-provider.js
Download node_modules/@modelcontextprotocol/sdk/dist/cjs/validation/cfworker-provider.js from bravesigma/quran-md-plugin: direct link, hf CLI and curl.
- Browser
- Download file 2.37 kB
-
https://huggingface.co/datasets/bravesigma/quran-md-plugin/resolve/main/node_modules/%40modelcontextprotocol/sdk/dist/cjs/validation/cfworker-provider.js
- Command line
-
hf download hf://datasets/bravesigma/quran-md-plugin/node_modules/@modelcontextprotocol/sdk/dist/cjs/validation/cfworker-provider.js
-
curl -L -o cfworker-provider.js https://huggingface.co/datasets/bravesigma/quran-md-plugin/resolve/main/node_modules/%40modelcontextprotocol/sdk/dist/cjs/validation/cfworker-provider.js
2.37 kB
| ; | |
| /** | |
| * Cloudflare Worker-compatible JSON Schema validator provider | |
| * | |
| * This provider uses @cfworker/json-schema for validation without code generation, | |
| * making it compatible with edge runtimes like Cloudflare Workers that restrict | |
| * eval and new Function. | |
| */ | |
| Object.defineProperty(exports, "__esModule", { value: true }); | |
| exports.CfWorkerJsonSchemaValidator = void 0; | |
| const json_schema_1 = require("@cfworker/json-schema"); | |
| /** | |
| * | |
| * @example | |
| * ```typescript | |
| * // Use with default configuration (2020-12, shortcircuit) | |
| * const validator = new CfWorkerJsonSchemaValidator(); | |
| * | |
| * // Use with custom configuration | |
| * const validator = new CfWorkerJsonSchemaValidator({ | |
| * draft: '2020-12', | |
| * shortcircuit: false // Report all errors | |
| * }); | |
| * ``` | |
| */ | |
| class CfWorkerJsonSchemaValidator { | |
| /** | |
| * 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 use (default: '2020-12') | |
| */ | |
| constructor(options) { | |
| this.shortcircuit = options?.shortcircuit ?? true; | |
| this.draft = options?.draft ?? '2020-12'; | |
| } | |
| /** | |
| * 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(schema) { | |
| // Cast to the cfworker Schema type - our JsonSchemaType is structurally compatible | |
| const validator = new json_schema_1.Validator(schema, this.draft, this.shortcircuit); | |
| return (input) => { | |
| const result = validator.validate(input); | |
| if (result.valid) { | |
| return { | |
| valid: true, | |
| data: input, | |
| errorMessage: undefined | |
| }; | |
| } | |
| else { | |
| return { | |
| valid: false, | |
| data: undefined, | |
| errorMessage: result.errors.map(err => `${err.instanceLocation}: ${err.error}`).join('; ') | |
| }; | |
| } | |
| }; | |
| } | |
| } | |
| exports.CfWorkerJsonSchemaValidator = CfWorkerJsonSchemaValidator; | |
| //# sourceMappingURL=cfworker-provider.js.map |