mirror of
https://github.com/badlogic/pi-mono.git
synced 2026-11-05 23:37:25 +00:00
feat(schema): add pi-schema, JSON Schema builders and validation without eval
@earendil-works/pi-schema compiles JSON Schema (drafts 2020-12 and 7) once into plain closures: no eval or new Function, so it runs under a strict CSP. It passes 2,222 of the 2,223 core tests of the official JSON-Schema-Test-Suite, checks Chord-style argument schemas within 1.2x of TypeBox's JIT, and keeps 3,200 compiled schemas in 7.9 MB (TypeBox: 54.7 MB). - compile(schema, options) returns a Validator: check() is the boolean check (a type guard for builder schemas), errors() reports each failure with a JSON Pointer path, missing and unknown fields at the field. - Builders (str, int, obj, opt, union, ...) return plain JSON Schema typed with the values it accepts (Static<typeof schema>). - Formats are an optional entry point (./formats), adapted from TypeBox (MIT). - Tests run the vendored suite (drafts 2020-12 and 7, with optional and format tests); npm run bench compares conformance, speed, setup cost, memory and bundle size with TypeBox, @cfworker/json-schema and omptype.
This commit is contained in:
parent
7ef8680abd
commit
fab2c5353e
255 changed files with 37963 additions and 2 deletions
|
|
@ -34,6 +34,8 @@
|
|||
"@earendil-works/pi-codemode/portable": ["./packages/codemode/src/portable.ts"],
|
||||
"@earendil-works/pi-codemode/source": ["./packages/codemode/src/source.ts"],
|
||||
"@earendil-works/pi-codemode/worker": ["./packages/codemode/src/runtime/worker.ts"],
|
||||
"@earendil-works/pi-schema": ["./packages/schema/src/index.ts"],
|
||||
"@earendil-works/pi-schema/formats": ["./packages/schema/src/formats/index.ts"],
|
||||
"@earendil-works/pi-mcp": ["./packages/mcp/src/index.ts"],
|
||||
"@earendil-works/pi-mcp/oauth": ["./packages/mcp/src/oauth/index.ts"],
|
||||
"@earendil-works/pi-mcp/testing": ["./packages/mcp/src/testing/index.ts"],
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue