maket_state
Manage a document's live state with schema-validated data and immutable snapshot history. Init, update, patch, or restore revisions.
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. The target interface is document-owned standard HTML/CSS: Mustache interpolation is display-only. Editable terminal values must be declared explicitly with data-maket-bind on (boolean), (string), (string enum), or (single-value editor). Use state.foo at the root and relative foo inside {{#state.items}} sections. Maket resolves transient JSON Pointers and synchronizes the store; it does not generate or style controls. init — attach a schema and initial data to a static document (revision 1; no expected_revision). get — read the schema and 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.
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. | |
| expected_revision | No | Current revision required by update, patch, change_schema, and restore; not used by init. |