maket_state
Attach a JSON Schema, durable data, and immutable revision history to one living document; then initialize, update, patch, validate, restore, or set retention.
Instructions
When to use: attach durable data and immutable snapshot history to one living document.
Document state is separate from collections and mail merge. A state-backed document renders Mustache variables, sections, inverted sections, and loops from its latest revision. Every mutation stores a complete validated schema + data snapshot. History is unbounded unless the document has a revision retention.
The page interface is HTML/CSS, a JSON Forms template, or HTML embedding the current form at . Configure the form with maket_page set_form. HTML uses display-only Mustache plus explicit data-maket-bind controls. JSON Forms uses the document-state JSON Schema and data, with an optional UI schema. Both formats resolve to the same JSON Pointer patches and revisioned store.
init — attach a schema and initial data to a static document (revision 1; no expected_revision).
get — read the schema, the revision retention (retention, null when unbounded), and the current revision.
update — append a complete state snapshot; expected_revision is required.
patch — apply RFC 6902 JSON Patch operations; expected_revision is required.
validate_schema — validate a proposed schema against current or supplied data without saving.
change_schema — atomically replace the schema and append compatible data; expected_revision is required.
history — list immutable revisions newest first.
revision — read one revision.
restore — append a new revision containing an older schema + data snapshot; expected_revision is required.
set_retention — keep retention previous revisions besides the current one and delete older ones now and after every later write; 0 keeps only the current state, null restores unbounded history. Applies to Workspace items and collection projections too.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| doc | Yes | Target document name. | |
| data | No | Complete state object required by init/update; optional compatible data for schema validation/change. | |
| patch | No | RFC 6902 operations required by action=patch. | |
| action | Yes | Document-state operation to perform. | |
| schema | No | JSON Schema required by init, validate_schema, and change_schema. | |
| revision | No | Historical revision required by revision and restore. | |
| retention | No | For set_retention: number of previous revisions kept besides the current one (0 keeps only the current state); null keeps the full history again. | |
| expected_revision | No | Current revision required by update, patch, change_schema, and restore; not used by init. |