Kotoba.Collab.Document (Kotoba v0.8.0)

Copy Markdown View Source

The versioned collaboration document and its semantic operations.

Nodes and Unicode scalar values have persistent identities. Deleted values remain as anchors, so an offline insertion does not depend on a current array index.

The wire format uses string keys. Issho orders the transactions, keeps their receipts and journal (Kotoba.Issho); this module is the state and its operations. A transaction is atomic: its resulting tree must pass the node, nesting, URL and feature checks.

Summary

Functions

The state after a transaction's operations, all or none. The resulting tree is checked by validate/2.

Creates a collaboration state from server-owned content.

Returns a cryptographically random identifier suitable for epochs and operations.

Exports the editing state as the existing Kotoba document envelope.

A document saved by Kotoba before Issho (its own authority, protocol 1) as an Issho document: the same epoch, revision, journal and receipts.

Validates and renders a snapshot on the server.

Functions

apply_ops(state, ops)

The state after a transaction's operations, all or none. The resulting tree is checked by validate/2.

new(content \\ nil, opts \\ [])

Creates a collaboration state from server-owned content.

random_id()

Returns a cryptographically random identifier suitable for epochs and operations.

to_envelope(state)

Exports the editing state as the existing Kotoba document envelope.

upgrade(stored)

A document saved by Kotoba before Issho (its own authority, protocol 1) as an Issho document: the same epoch, revision, journal and receipts.

validate(state, opts \\ [])

Validates and renders a snapshot on the server.