kalam_sync library

Local-first persistence, durable actions, and synchronization for KalamDB.

Classes

AckEvent
Subscription acknowledged — contains schema metadata.
Auth
Authentication methods for connecting to KalamDB.
BasicAuth
HTTP Basic Auth credentials.
ChangeEvent
A change event from a live subscription.
ConnectEvent
Fired when WebSocket connection is established and authenticated.
ConnectionErrorEvent
Fired when a connection/protocol error occurs.
ConnectionErrorInfo
Error details from a connection or protocol failure.
ConnectionEvent
A connection lifecycle event emitted by the KalamDB client.
ConnectionHandlers
Optional connection lifecycle callbacks.
DeleteEvent
One or more rows were deleted.
DisconnectEvent
Fired when WebSocket connection closes.
DisconnectReason
Reason why a WebSocket connection closed.
ErrorDetail
Error details from the server.
InitialDataBatch
Batch of initial snapshot rows.
InsertEvent
One or more rows were inserted.
JwtAuth
JWT bearer token authentication.
Kalam
One account-scoped local-first KalamDB session.
KalamAccountIdentity
Cache and outbox ownership. A database must never cross this boundary.
KalamAction
Marks one module method as a durable offline action.
KalamActionCodec<T>
Converts a typed action payload to and from durable JSON values.
KalamActionContext
Runtime values and durable named steps available to an action executor.
KalamActionDefinition<T>
A typed, versioned durable action registered once by the application.
KalamActionDraft
Immutable input used to create one durable action.
KalamActionModule
Groups related generated actions under one stable namespace.
KalamActionPayload
Generates a durable JSON codec for a small immutable action payload.
KalamActionRecord
Public read model for one action stored in the durable outbox.
KalamActionRegistry
Immutable lookup of the app's registered action definitions.
KalamActionRunner
Enqueues typed actions and flushes the durable outbox in FIFO order.
KalamAuthRecovery
One in-flight token refresh, then pause and resume of the same session.
KalamCachedRow
One server-shaped JSON row in Kalam's local mirror.
KalamCatchUpResult
Outcome of a bounded, isolate-safe HTTP catch-up pass.
KalamCellValue
Type-safe wrapper for a single cell value in a KalamDB query result row.
KalamChange<T>
One ordered backend table change ready to apply to the local cache.
KalamCheckpoint
Last server sequence durably committed for one subscription.
KalamClient
KalamDB client for Dart and Flutter.
KalamColumn<T>
KalamColumns
KalamCompiledQuery
KalamConsumeContext
Side-effect handle available while a durable consumer applies one event.
KalamDatabaseFactory
KalamDecodedRow<T>
KalamDeferredEmitter<T>
Holds a value briefly so a short transition does not reach the listener.
KalamDeletedRow<T>
KalamDmlPayload
One generic direct-DML action; Drift continues to own the row types.
KalamEventConsumer
A widget- or service-scoped durable subscription.
KalamFileDownload
Bytes and HTTP metadata from a file download response.
KalamFileRef
Type-safe file reference for KalamDB FILE columns.
KalamFileRefData
Data shape for a file reference stored in a KalamDB FILE column.
KalamFileUpload
Multipart upload payload for SQL FILE("placeholder") expressions.
KalamFlutterDatabaseFactory
KalamFullRow<T>
KalamLinkTransport
Adapts the existing shared kalam_link socket to the sync engine.
KalamLogger
Global SDK logger.
KalamMutationResult
KalamOptimisticMutation
One local row mutation committed atomically with a custom action.
KalamOptimisticRow
Pending row metadata committed with a durable action.
KalamOrder
KalamOrderKey
KalamPartialRow<T>
KalamPredicate
KalamRemoteBatch
One server delivery that is acknowledged only after durable local apply.
KalamRemoteChange
One decoded row change delivered by a synchronization batch.
KalamRemoteTable<Row>
One remote table addressed by the existing KalamClient query and live APIs.
KalamReplicaOverlay<T>
Pure merge of authoritative rows and SDK-owned optimistic row state.
KalamRetryPolicy
Retry limits and exponential backoff for a durable action.
KalamRowSyncState
SDK-owned metadata associated with a server-shaped row.
KalamScope
Provides one Kalam session and coordinates it with Flutter lifecycle.
KalamSyncCoordinator
Coordinates durable consumers, connection state, and outbox flushing.
KalamSyncedRow<T>
A Drift-generated row paired with SDK-owned local synchronization state.
KalamSyncState
Immutable state suitable for Flutter builders and state providers.
KalamSyncStore
Single-writer access to Kalam's private persistence tables.
KalamSyncSubscription
Handle returned for a widget- or service-scoped sync consumer.
KalamSyncTransport
Small seam that keeps synchronization independent from the socket client.
KalamTableBinding<T>
Binds generated Drift row types to Kalam's durable table policy.
KalamTableClient<Row>
Bound table manager. Maps omit absent fields; a present null is SQL NULL.
KalamTableQuery<Row>
Immutable filter over one remote table.
KalamTableSpec<T>
Generated metadata and codecs for one Drift-owned application table.
LiveCheckpoint
Checkpoint emitted after a live stream advances.
LiveEventDelivery
One live event whose reconnect progress advances only after acknowledgement.
LogEntry
A single log entry emitted by the SDK.
LoginResponse
Login response containing tokens and user info.
LoginUserInfo
User information returned after login.
NoAuth
No authentication.
QueryResponse
Response from a query execution.
QueryResult
A single result set from a query execution.
ReceiveEvent
Debug hook for raw inbound messages.
ResolvedKalamDatabase
SchemaField
Column metadata from a query result.
SendEvent
Debug hook for raw outbound messages.
SubscriptionError
Server-side error on this subscription.
SubscriptionInfo
Read-only snapshot of an active subscription's metadata.
UpdateEvent
One or more rows were updated.
VersionId
Opaque row version. Not a timestamp or Snowflake.

Enums

KalamActionStatus
Durable lifecycle of a queued action.
KalamChangeKind
KalamDmlOperation
KalamRowSyncPhase
Local synchronization phase for one row.
KalamSessionPlan
Whether Kalam.open should create, replace, or keep the account session.
KalamSyncMode
Controls how local writes are handled for a synchronized table.
KalamSyncPhase
High-level state of the local-first synchronization engine.
KalamTransportConnection
Level
Levels to control logging output. Logging can be enabled to include all levels above certain Level.
Role
Typed user role values returned by the auth APIs.

Constants

kalamDmlActionKey → const String

Functions

bindSqlParams(String sql, List<Object?>? params) → String
Binds $1, $2, ... placeholders into a SQL string.
kalamDmlAction(Future<KalamClient> client()) → KalamActionDefinition<KalamDmlPayload>
planKalamSession({required String? existingSubject, required String userId}) → KalamSessionPlan
Token refresh for the same user keeps the session. A different user replaces it.
quoteKalamIdent(String ident) → String
Quotes one SQL identifier. The value is a name, never a literal.
quoteKalamTable(String tableId) → String
Quotes schema.table or a single table name.
resolveKalamDatabase({required KalamAccountIdentity identity, GeneratedDatabase? database, KalamDatabaseConstructor? databaseConstructor, KalamDatabaseFactory databaseFactory = const KalamFlutterDatabaseFactory(), KalamExecutorOpener? openExecutor}) → Future<ResolvedKalamDatabase>
Opens the one session database, or adopts one the application already opened.
routineExceptionFromPayload(int statusCode, Object? payload) → KalamRoutineException
sqlLiteral(Object? value) → String

Typedefs

AuthProvider = Future<Auth> Function()
Async authentication provider callback.
KalamActionClock = DateTime Function()
KalamActionExecutor<T> = Future<void> Function(KalamActionContext context, T payload)
KalamChangeApplier = FutureOr<void> Function(KalamRemoteChange change)
KalamChangeConsumer = FutureOr<void> Function(KalamRemoteChange change, KalamConsumeContext context)
KalamClock = DateTime Function()
KalamDatabaseConstructor = GeneratedDatabase Function(QueryExecutor executor)
KalamExecutorOpener = Future<QueryExecutor> Function(KalamAccountIdentity identity)
KalamRowDelete = Future<void> Function(String rowKey)
KalamRowUpsert<T> = Future<void> Function(T row)
KalamRowWatch<T> = Stream<List<T>> Function()
KalamTransportFactory = Future<KalamSyncTransport> Function()
LogLevel = Level
Backward-compatible alias for old SDK naming.
LogListener = void Function(LogEntry entry)
Callback signature for receiving log entries.

Exceptions / Errors

KalamPermanentActionException
Marks an action error as non-retryable.
KalamRoutineException
Failure returned by KalamClient.invokeRoutine.
KalamSubscriptionException