Composition / foldkit-composition
The Document, and its two schemas
A Document is normalized: roots and each Region hold node ids, and nodes
stores each node once under its id. Because the node omits its own id field, a
node's key and identity stay in sync and each node occupies a single place.
There are two schemas, on purpose:
Composition.Document // tolerant: what is stored and read
Composition.Document.check(Composition.valid(Site)) // strict: what may be publishedThe tolerant codec accepts any well-formed Document, whatever Block names it
uses and with props as JSON. So a stored page always reads, an old revision
always restores, and content the deployment lacks survives. The strict check
runs validate and fails with every finding at its path. Store the first in
the Entity, and ask the second of the operation that publishes:
import { Entity } from 'foldkit-entity'
const Page = Entity.define('Page', Schema.Struct({
id: Schema.String,
title: Schema.String,
document: Composition.Document,
}))
const PublishPage = Entity.input(Page, Schema.Struct({
title: Page.fields.title.schema,
document: Composition.Document.check(Composition.valid(Site)),
}))appearance holds a node's look as names, such as { tone: 'accent' },
checked against the axes its Block offers (Appearance).
when lists the conditions a node shows under (Conditions),
and actions what its events run (Actions), as names and literal
input.