@fuaran-ui/schema
v0.5.0
Published
TypeScript shape of the Fuaran UI §4b typed record contract — tagged unions for every NodeKind / LayoutKind / DisplayKind / InputKind / VisKind / Spec, branded NodeId / FragmentId, bounded primitives, and declarative Defaults.* constants. One conformant h
Downloads
1,366
Maintainers
Readme
@fuaran-ui/schema
The TypeScript shape of the Fuaran UI typed record contract (§4b). This package is the foundational layer of the @fuaran-ui/* set: the types every other package is built on.
It is one conformant host of the canonical Fuaran wire format, declared language-neutrally in WIRE_FORMAT.md (the fuaran-specification repo: spec + schema + conformance corpus). The F# Fuaran.UI tier is the other host. The spec + its conformance corpus — not any single implementation — are the authority.
What's in here
types.ts— tagged unions for everyNodeKind/LayoutKind/DisplayKind/InputKind/VisKind/Binding/Action/TextSource/CellFormat, every spec record (MetricSpec,DashboardSpec,TabsSpec, …), and branded primitives (NodeId,FragmentId,ApiEndpoint,IconSource). F# discriminated unions become TS unions discriminated by akind: '<CaseName>'literal; F#optionbecomes an optional property (absent key = the wire format's "field absent" /Nonesemantics —undefined, nevernull).defaults.ts— a typed default for every spec, composed with object spread:{ ...defaults.metric, label: ... }.bounded.ts— parse-don't-validate bounded scalars:nonEmptyString,boundedString,boundedInt,fraction. The constructor is the only way to obtain the branded type; out-of-range input throwsBoundedConstructionError.result.ts— the vanillaResult<T, E>discriminated union.
Usage
import { type Node, type NodeKind, defaults, boundedInt } from '@fuaran-ui/schema';
// A bounded value is in-range by construction:
const cols = boundedInt(1, 12, 4); // BoundedInt<1, 12>
// Compose specs from defaults:
const metricSpec = { ...defaults.metric, format: { kind: 'Currency', code: 'GBP' } as const };To author trees ergonomically, use the smart constructors in @fuaran-ui/ui rather than building Node literals by hand.
Stability
The wire-format-mirroring surface of this package is stable (see ../../STABILITY.md), governed by the wire-format forward-coupling rule.
Licence
Apache 2.0. See ../../LICENSE.
