The YAML schema as a string
A record mapping type names to their parsed NamedType definitions
const yaml = `
Position:
x: float(precision=0.01)
y: float(precision=0.01)
Player:
name: string
score: uint
position: Position
Direction:
- up
- down
- left
- right
`;
const types = parseSchemaYml(yaml);
const api = load<Player>(types.Player);
// Load schema from file
import { readFileSync } from "fs";
const schema = parseSchemaYml(readFileSync("schema.yml", "utf-8"));
const api = load(schema.GameState);
YAML schema syntax:
string, int, uint, float, booleanint(min=0, max=100), float(precision=0.01)Type[] (array), Type? (optional), <Key, Value> (record)position: Position)
Parse a YAML schema definition into Delta-Pack type objects.
This function converts a YAML schema string into a record of named types that can be passed to load. Use this when you want to define schemas in YAML files rather than TypeScript code.