@wizestudio/schema
v0.1.2
Published
The WizeStudio layout document, manifest and token schemas. Zero runtime dependencies.
Readme
@wizestudio/schema
The WizeStudio data model — layout documents, widget manifests, design tokens, and the validation and migration that keep them honest. Zero runtime dependencies.
Where this sits
WizeStudio is a visual page builder for headless CMS platforms. It never stores HTML: a page is a normalized JSON document, the developer owns the React components, and a renderer turns one into the other.
This package is the root of that system's dependency graph. The editing engine (@wizestudio/core), the renderers, the editor and the CMS adapters all depend on the types declared here; this package depends on nothing. It imports no UI framework, touches no DOM and knows about no CMS — constraints enforced in CI rather than by convention, because a guarantee that relies on developer memory is not a guarantee.
Install it directly when you read or write layout documents outside the editor: a migration script, a custom renderer, a build step that validates stored content before it reaches production.
Install
npm install @wizestudio/schemaUsage
import { buildDocument, literal, validateDocument, widgetType } from '@wizestudio/schema';
const document = buildDocument({
type: widgetType('wize/section'),
children: [{ type: widgetType('wize/heading'), props: { text: literal('Hello') } }],
});
const result = validateDocument(document);
if (!result.ok) {
for (const issue of result.errors) console.error(issue.path, issue.message);
}buildDocument accepts a nested description and returns the flat document the rest of the system uses. That inversion is the point: the stored shape is { root, nodes: Record<NodeId, LayoutNode> } with each node holding slots: Record<string, NodeId[]>, because nesting makes every hot path in an editor a recursive walk. The cost is that referential integrity — orphans, cycles, dangling children, multiple roots — becomes an invariant to check rather than a property of the shape, which is what validateDocument is for. It reports every problem it finds rather than the first.
Forward compatibility is deliberate: an unknown style property or breakpoint is a warning, never an error, so a page authored in a newer editor still opens in an older renderer.
Key exports
| Area | Exports |
|---|---|
| Documents | LayoutDocument, LayoutNode, createNode, createEmptyDocument, buildDocument, DOCUMENT_SCHEMA_VERSION |
| Prop values | PropValue = literal | binding | globalRef, with isLiteral / isBinding / isGlobal |
| Styles | BREAKPOINTS, STYLE_PROPERTIES, STYLE_STATES, cascadeFor, raw, token |
| Tokens | TokenSet, tokenRef, parseTokenRef, resolveToken, tokenCssVariable |
| Manifests | WidgetManifest, SlotDefinition, UiSchema, Migration, ManifestBundle |
| Validation | inspectDocument, validateDocument, assertDocument, isLayoutNode |
| Migration | migrateDocument, migrateNode, migrateDocumentNodes, needsMigration |
| Blocks | Block, createBlockInstance, isBlockInstance, referencedBlocks |
| Data sources | DataSource, FilterExpression, FILTER_OPERATORS |
| Identity | NodeId, WidgetType, createIdFactory, widgetType, isNodeId |
Every prop value has been literal | binding | global since v1 precisely so that dynamic binding could arrive later without a document migration — the schema always allowed the union member the authoring UI eventually wrote.
Licence
MIT.
WizeStudio is open core, and this package is on the production render path. It is MIT deliberately and contains no licensing code of any kind, which is what makes "a lapsed subscription cannot break your live site" a property of the build rather than a promise. core, canvas-bridge, renderer-react, renderer-next and cli are MIT for the same reason; the authoring side — editor, plugin-strapi, components, cms-strapi — is commercial.
