Advanced Realtime Mode
Use advanced mode when you want protocol events instead of a pre-materialized row set.
If your UI only needs current rows, use live() or liveTable() first. They expose onCheckpoint too, so durable resume does not require raw event handling.
liveEvents(sql, onEvent, options?) is the low-level API.
Low-level SQL events
Use this path for protocol tooling, debugging, custom reconciliation, or event processors that need direct access to subscription_ack, initial_data_batch, change, and error frames.
Options
batchSizechunks the initial snapshot from the server.lastRowsincludes the last N rows before live changes begin.fromresumes from a knownSeqIdcheckpoint.autoFetchBatchescontrols whether the client asks for remaining startup batches automatically.onCheckpointfires whenever the SDK observes a newer applied sequence ID.onErrorreceives protocol error frames without forcing your event callback to branch on every error.
Checkpoints
The checkpoint is a single SeqId. Snapshot and commit boundaries stay server-owned.
Event model
Use runtime enums from @kalamdb/client:
Common sequence:
subscription_ack- one or more
initial_data_batch changeevents withinsert,update, ordelete- optional
error
SQL safety for dynamic filters
liveEvents() accepts a SQL string. For dynamic values:
- Prefer validated numeric IDs before interpolation.
- Do not interpolate raw user text directly into SQL.
Related docs
SHARED table ownership and resume domains
Clustered servers default to shared_shards = 4. Each SHARED table owns exactly one Raft group. CREATE persists table_options.shared_shard_id and a fresh history_incarnation in replicated table metadata. Increasing the configured count places new tables across the expanded set; existing owners do not change. Do not remove a shard that owns tables. Legacy metadata without an owner stays on shard 0. Moving existing data requires explicit export/import into a fresh history.
_version = (raft_log_index << 16) | ordinal is ordered only within its table’s domain. Different tables on the same shard can interleave, so per-table versions can have gaps. Transactions spanning different owner groups are rejected.
A SHARED subscription acknowledgement includes batch_control.version_domain with history_incarnation, table_id, scope_id (the shared owner), and partition_id (currently null). Persist this complete envelope together with the last safely consumed version. Resume by supplying both options.from and options.version_domain. Missing envelopes, another table/group/history, and unsupported partitions are rejected as stale cursors. Take a fresh snapshot after CURSOR_EXPIRED; do not reuse the old domain.
The Rust transport preserves the acknowledgement domain for automatic reconnect. In TypeScript, use versionDomain with from when restoring a persisted checkpoint; it serializes as version_domain. Treat the domain as opaque and never infer it from the numeric version.