@minamorl/root-core
v0.0.3
Published
## Event union ```ts type Create = { type: "Create"; id: string; value: unknown }; type Update = { type: "Update"; id: string; value: unknown }; type Delete = { type: "Delete"; id: string }; type Event = Create | Update | Delete; ```
Readme
@minamorl/root-core
Event union
type Create = { type: "Create"; id: string; value: unknown };
type Update = { type: "Update"; id: string; value: unknown };
type Delete = { type: "Delete"; id: string };
type Event = Create | Update | Delete;state() and compact()
state() scans the log, applying Create, Update, and Delete to build the current map. Update for missing ids is ignored. compact() snapshots state() and rewrites the log with only Create events for each surviving id.
Update without Create is ignored
const root = new Root();
root.commit({ type: "Update", id: "x", value: 1 });
root.state(); // {}Binary values and Blob storage
- Binary payloads may appear in event
valueasUint8Array | Bufferor asBinaryRef. BinaryRefis a content-addressed reference produced by aBlobAdapter:
type BinaryRef = {
kind: 'blob';
uri: string; // e.g. "blob:sha256-<64 hex>"
bytes: number;
contentType?: string; // optional
}In host/adapters wiring:
- Text-only adapters (WAL-NDJSON, SSE) never carry raw bytes; they only emit JSON containing
BinaryRef. - SQLite can inline small binaries (configurable threshold) as BLOBs and stores
BinaryRefas JSON. - A file-system
BlobFsAdapteris provided for local content-addressed storage.
Example: storing an image returns a blob:sha256-... URI that downstream consumers can resolve via the configured BlobAdapter.
