Skip to main content

Module schema

Module schema 

Source
Expand description

The JSON Schema of the crosswalk format, the document the packages publish as schemas/crossmap.schema.json.

It describes a crosswalk as a document may be written, so what crate::parse_crosswalk fills in (the rule lists, a single-path rule’s to) is optional in it. It is written by hand here rather than derived from the parsed types, because those are the parsed form (no keep, a to on every rule), and because the document has to stay the one the TypeScript generator wrote from its Zod schemas, which it is byte for byte once canonicalised. What each rule may carry comes from the parser’s own tables, the names of formats, functions and directions from their types, and the path pattern from the constants of the path grammar, so the schema and the parser cannot list different fields; the tests check that the parser requires exactly the fields the schema requires.

The when field is a reference to trilean’s published predicate schema, pinned to TRILEAN_VERSION, rather than a copy of it, so the predicate grammar has one source of truth.

Constants§

PACKAGE_VERSION
The version of the crate, which names the published schema in its $id.
TRILEAN_VERSION
The version of the trilean npm package whose published schema the when reference names.

Functions§

json_schema
The JSON Schema document of the crosswalk format.
json_schema_text
The document as it is published: json_schema in its RFC 8785 canonical form, with no trailing newline, so the file’s bytes are exactly the canonical form of its own content.
path_pattern
The pattern a path string matches: the path grammar of crate::is_path, as an ECMAScript pattern with the u flag.
schema_id
The address of the schema this crate’s format is published as.
trilean_schema_id
The address of the trilean schema the when reference resolves in: the one published with TRILEAN_VERSION.