oxa-types
v0.1.0
Published
TypeScript type definitions generated from the OXA schema
Downloads
37
Readme
oxa-types
TypeScript type definitions generated from the OXA JSON Schema.
Installation
npm install oxa-typesUsage
import type { Document, Block, Inline, Paragraph, Text } from "oxa-types";
const doc: Document = {
type: "Document",
metadata: {},
title: [{ type: "Text", value: "Hello", classes: [], data: {} }],
children: [
{
type: "Paragraph",
classes: [],
data: {},
children: [{ type: "Text", value: "World", classes: [], data: {} }],
},
],
};The types include discriminated unions for Block and Inline, enabling type-safe pattern matching:
function getTextContent(inline: Inline): string {
switch (inline.type) {
case "Text":
return inline.value;
case "Strong":
return inline.children.map(getTextContent).join("");
}
}Development
Types are auto-generated from the YAML schemas in schema/. To regenerate:
pnpm codegen tsSee the contributing guide for more details on schema development.
