@typedblite/runtime
@typedblite/runtime on Node: everything the browser entry has, plus the node:sqlite binding and
the SSE hub (ADR-009 D3).
The engine: TypeQLite on SQLite, with a change log, replication and full-text search. Start with TypeDBLiteInterpreter.
import { TypeDBLiteInterpreter } from '@typedblite/runtime';
const db = new TypeDBLiteInterpreter('./app.db'); // or ':memory:'db.define(` define entity person, owns name @key; attribute name, value string;`);db.execute(`insert $p isa person, has name "Alice";`);
const { rows } = db.query(` match $p isa person, has name $n; select $n;`);console.log(rows[0].n.asString()); // AliceEverything below is grouped by what it is for: the engine, what it takes and answers with, and the parts that let two stores converge. The guides say how they fit together: Embedding the runtime covers the engine and its reports, and Replication and search covers the change log, the sync hub and the full-text index. For what a version promises, see Versions and compatibility.
Engine
Section titled “Engine”The interpreter that runs TypeQLite against SQLite, the cells and reports it answers with, and SqliteEngine, the
same engine behind an async interface.
| Name | Description |
|---|---|
| SqliteEngine | A SQLite engine behind TypeDBLiteDatabase’s five methods. |
| TypeDBLiteInterpreter | The engine: executes TypeQLite against SQLite. Open a database with new TypeDBLiteInterpreter(path), define a schema, then execute writes and query reads. |
| TypeDBLiteValue | A result cell: a concept, the way the TypeDB driver hands one back. A cell carries what it is: |
| EngineRow | One result row, shaped the way rowString and rowNumber read it. |
| QueryTrace | What the engine did for ONE query() call — counts, never times, so a regression test can assert that a join is not a cartesian product (a real performance defect: one subSkillsIn call evaluated ~211,000 combinations and took 32 s). |
| TypeDBLiteOptions | How an interpreter opens its database and runs queries: the third argument of its constructor. |
| TypeDBLiteSchemaSnapshot | The schema applied to a database, as sorted lists: what schemaSnapshot() returns. |
| WriteReport | What execute() reports: its diagnostics, and what its last write pipeline answers. |
| ConceptKind | What a row cell can be — the driver’s Concept kinds TypeDBLite answers with. |
| GivenRows | The rows a given stage receives (given.feature): one record per row, keyed by variable name without its $. null is an absent value — admitted only for a variable declared optional (?). |
Diagnostics
Section titled “Diagnostics”How a refusal or a warning is reported: the codes a program can branch on, and the diagnostic an error carries.
| Name | Description |
|---|---|
| ExecutionReport | What running a statement reports besides its rows: facts about the run, and the diagnostics of a refusal. |
| DiagnosticCodeValue | One of the codes in DiagnosticCode. |
| DIAGNOSTIC_SOURCE | The source of every diagnostic the engine produces. |
| DiagnosticCode | Codes are stable identifiers a consumer can branch on; messages are for people. |
| MAX_DIAGNOSTICS | The cap ADR-004 Decision 5 requires. |
| WHOLE_DOCUMENT | The range used when a statement can be located but a term inside it cannot. |
| diagnosticOf | The diagnostic attached to an error the engine threw, or undefined for any other error. Branch on its code, not on the message. |
Change log
Section titled “Change log”Every committed write is recorded as a revision. The log is what replication reads and applies, and what compaction trims.
| Name | Description |
|---|---|
| ChangeLog | A store’s change log: every committed change as a revision, in commit order, with each thing’s revision tree, its conflicts, compaction, and the full-text index kept with it. Reached as db.changeLog. It is what replicateOnce and TypeDBLiteReplicator read from and apply to. |
| ChangeRecord | One revision in the change log: what since() returns, and what replication sends. |
| CompactionOptions | How much history compact may keep behind each leaf. |
| CompactionReport | What compact did. |
| EntityIdentity | What a thing is, resolved to node-independent terms. Captured before a delete removes it. |
| entityId | The identity a change log records an entity under. |
| isReplicable | Whether an entity id names something two nodes could agree on. |
Full-text search
Section titled “Full-text search”The index kept current by the change log, reached as db.changeLog.fullText.
| Name | Description |
|---|---|
| FullTextIndex | Full-text search over a store’s things, in SQLite’s FTS5. It is kept current by the change log as things are written, and reached through db.changeLog.fullText. |
| SearchHit | One result of a full-text search. |
Replication
Section titled “Replication”Converging two change logs: once on demand with replicateOnce, or continuously against a hub with
TypeDBLiteReplicator.
| Name | Description |
|---|---|
| TypeDBLiteReplicator | Replicates a local change log against a remote hub over HTTP. |
| ReplicateOptions | How replicateOnce replicates. |
| ReplicationEndpoint | What replication needs of a store. ChangeLog satisfies it structurally. |
| ReplicationEvents | What a continuous replication reports as it runs. All are optional. |
| ReplicationOptions | How TypeDBLiteReplicator replicates. |
| ReplicationSession | A running continuous replication. |
| SyncCursor | A position in each direction’s log. |
| SyncOutcome | What one replication did. |
| JsonValue | A JSON value: null, a boolean, a number, a string, or an array or object of them. A fetch answers with one per result. |
| SyncDirection | Which way a replication moves changes: push sends the local ones, pull takes the remote ones, duplex does both. |
| SyncErrorClass | Whether a failure can be waited out. terminal means the replication has stopped and will fail the same way again (a change that cannot be applied); transient is a connection or a push that may work on a later attempt. |
| SyncStatus | Where a continuous replication is: syncing while it is receiving, ready once it has caught up (and still running), failed after an error, idle after it is canceled. |
| replicateOnce | Replicate once, in the requested direction, and report where to resume. |
Change stream
Section titled “Change stream”The hub’s server-sent-events stream of changes, and the client that follows it. Serving a stream needs Node;
following one needs only fetch.
| Name | Description |
|---|---|
| ChangeStreamClient | The spoke’s side of a hub’s change stream: subscribes to the hub’s server-sent events and pushes revisions to it. Reconnects on a dropped connection, resuming from the last change it delivered. |
| ChangeStreamClientOptions | How a ChangeStreamClient connects and retries. |
| ChangeStreamHandlers | What a subscription calls as the hub’s stream delivers changes and as its own state changes. |
| ChangeStreamOptions | How a hub serves its change stream: polling, batch size, port and the limits that protect it. |
| ChangeStreamSubscription | A running subscription to a hub’s change stream. |
| createChangeStreamHandler | The change stream as a request handler, so a hub can mount it under its own routes and put its own authentication in front. |
| serveChangeStream | Serve a change log over HTTP on its own port. |
SQLite binding
Section titled “SQLite binding”The synchronous SQLite surface the engine runs against, and the opener for Node’s node:sqlite. A browser passes
openWasmSqlite from @typedblite/runtime/wasm instead.
| Name | Description |
|---|---|
| SqliteDatabase | The synchronous SQLite surface TypeDBLite’s interpreter runs against. |
| SqliteRunResult | What run reports. Only changes is read — see SqliteStatement.run. |
| SqliteStatement | A prepared statement. The overloads mirror node:sqlite’s: positional parameters, or one named-parameter object (optionally followed by positional ones). |
| SqliteNamedParameters | Named parameters, keyed WITHOUT the :/@/$ prefix. |
| SqliteOpener | Opens a database at location (:memory: or a path the binding understands). |
| SqliteParameter | A value bound to a statement parameter, or read back from a column. |
| SqliteRow | A row as SQLite returns it: column name to value. |
| openNodeSqlite | The default binding: node:sqlite. |
Canonical form
Section titled “Canonical form”Re-exported from @typedblite/content-revision: the state a revision covers.
CanonicalAttribute
Section titled “CanonicalAttribute”Re-exports CanonicalAttribute
CanonicalRole
Section titled “CanonicalRole”Re-exports CanonicalRole
EntityState
Section titled “EntityState”Re-exports EntityState
Revisions
Section titled “Revisions”Re-exported from @typedblite/content-revision: the revision a change log records for each write, and the leaves of a
thing’s revision tree.
Re-exports Leaf
Revision
Section titled “Revision”Re-exports Revision
RevisionInput
Section titled “RevisionInput”Re-exports RevisionInput
TypeDBLite is an independent open-source project, built on TypeDB with thanks. It is not affiliated with, sponsored by, or endorsed by TypeDB Ltd. Released under the MPL-2.0 license.