Expand description
Conversion from EureDocument to SchemaDocument
This module provides functionality to convert Eure documents containing schema definitions into SchemaDocument structures.
§Schema Syntax
Schema types are defined using the following syntax:
Primitives (shorthands via inline code):
`text`,`integer`,`float`,`boolean`,`null`,`any``text.rust`,`text.email`,`text.plaintext`
Primitives with constraints:
@ field {
$variant = "text"
min-length = 3
max-length = 20
pattern = `^[a-z]+$`
}Array: [`text`] or { $variant = "array", item = `text`, ... }
Tuple: (`text`, `integer`) or { $variant = "tuple", elements = [...] }
Record: { name = `text`, age = `integer` }
Union with named variants:
@ field {
$variant = "union"
variants.success = { data = `any` }
variants.error = { message = `text` }
variants.error.$ext-type.unambiguous = true // optional, for catch-all variants
$variant-repr = "untagged" // optional
}Literal: Any constant value (e.g., { = "active", $variant = "literal" }, 42, true)
Type reference: `$types.my-type` or `$types.namespace.type`
Enums§
- Conversion
Error - Errors that can occur during document to schema conversion
Functions§
- document_
to_ schema - Convert an EureDocument containing schema definitions to a SchemaDocument
Type Aliases§
- Schema
Source Map - Mapping from schema node IDs to their source document node IDs. Used for propagating origin information for error formatting.