offline_sync library

Classes

BaseHlc
Base class for HLC timestamps.
CrdtDataAttemptedValue
Authored field value retained while the domain column holds a projection.
CrdtDataAttemptedValueAttachRowRepository
CrdtDataAttemptedValueInclude
CrdtDataAttemptedValueIncludeList
CrdtDataAttemptedValueRepository
CrdtDataAttemptedValueTable
CrdtDataAttemptedValueUpdateTable
CrdtDataDeleted
CRDT visibility generation table.
CrdtDataDeletedAttachRowRepository
CrdtDataDeletedInclude
CrdtDataDeletedIncludeList
CrdtDataDeletedRepository
CrdtDataDeletedTable
CrdtDataDeletedUpdateTable
CrdtDataField
CRDT data table.
CrdtDataFieldAttachRowRepository
CrdtDataFieldInclude
CrdtDataFieldIncludeList
CrdtDataFieldRepository
CrdtDataFieldTable
CrdtDataFieldUpdateTable
CrdtDataRow
CRDT data rows table.
CrdtDataRowAttachRepository
CrdtDataRowAttachRowRepository
CrdtDataRowInclude
CrdtDataRowIncludeList
CrdtDataRowRepository
CrdtDataRowTable
CrdtDataRowUpdateTable
CrdtMergeChange
A remote CRDT change to merge.
CrdtMergeDelete
A remote visibility CLFlag update to merge.
CrdtMergeInsert
A remote row insertion to merge.
CrdtMergeUpdate
A remote field update to merge.
CrdtMutationRecorder
Persists additional CRDT rows after a mutating ORM operation completes.
CrdtNode
CRDT nodes table.
CrdtNodeInclude
CrdtNodeIncludeList
CrdtNodeRepository
CrdtNodeTable
CrdtNodeUpdateTable
CrdtSchemaColumn
CRDT schema columns table.
CrdtSchemaColumnAttachRowRepository
CrdtSchemaColumnInclude
CrdtSchemaColumnIncludeList
CrdtSchemaColumnRepository
CrdtSchemaColumnTable
CrdtSchemaColumnUpdateTable
CrdtSchemaRegistry
Manages the CRDT schema for a database.
CrdtSchemaTable
CRDT schema tables table.
CrdtSchemaTableInclude
CrdtSchemaTableIncludeList
CrdtSchemaTableRepository
CrdtSchemaTableTable
CrdtSchemaTableUpdateTable
Hlc
A Hybrid Logical Clock implementation that supports both ISO 8601 and Unix timestamp formats. The datetime component has millisecond precision and is always stored in UTC.
HlcManager
A manager for Hlc instances that is used to generate unique timestamps for CRDT operations.
OfflineSyncClient
High-level client sync helpers built on top of a CRDT stream transport.
OfflineSyncClose
Marks a graceful end of a one-shot sync session.
OfflineSyncConnect
Session handshake sent once by each peer before any space work.
OfflineSyncCycleBatch
One sync cycle's inbound frames.
OfflineSyncDatabase
Database proxy that runs insert/update/delete ORM operations inside a transaction to record each change in the CRDT tables.
OfflineSyncDatabaseContext
Process-level CRDT database metadata shared by ephemeral database wrappers.
OfflineSyncDatabaseSession
Wraps a DatabaseSession to provide a OfflineSyncDatabase as DatabaseSession.db.
OfflineSyncEndOfBatch
Marks the end of a framed sync batch.
OfflineSyncEngine
The shared CRDT synchronization logic used by both client and server nodes.
OfflineSyncIdleTimeout
Marks a timeout of an idle sync session.
OfflineSyncIntegrityViolation
Durable record of a terminal CRDT sync integrity violation.
OfflineSyncIntegrityViolationInclude
OfflineSyncIntegrityViolationIncludeList
OfflineSyncIntegrityViolationRepository
OfflineSyncIntegrityViolationTable
OfflineSyncIntegrityViolationUpdateTable
OfflineSyncMergeChunk
A chunk of merge changes carried inside a framed sync batch.
OfflineSyncSinceHlc
Per-space checkpoint sent by each peer before the first visit to a space.
OfflineSyncSpace
CRDT spaces table.
OfflineSyncSpaceAttachRepository
OfflineSyncSpaceAttachRowRepository
OfflineSyncSpaceDetachRowRepository
OfflineSyncSpaceGrant
A single space a peer announces in a OfflineSyncSpaceSet.
OfflineSyncSpaceInclude
OfflineSyncSpaceIncludeList
OfflineSyncSpaceManager
A manager for OfflineSyncSpace instances.
OfflineSyncSpaceMember
Authorization membership for shared CRDT spaces.
OfflineSyncSpaceMemberAttachRowRepository
OfflineSyncSpaceMemberInclude
OfflineSyncSpaceMemberIncludeList
OfflineSyncSpaceMemberRepository
OfflineSyncSpaceMembership
Resolves shared-space membership from the offline_sync_space_members table.
OfflineSyncSpaceMemberTable
OfflineSyncSpaceMemberUpdateTable
OfflineSyncSpaceNode
A CRDT node's participation and checkpoint state within one space.
OfflineSyncSpaceNodeAttachRowRepository
OfflineSyncSpaceNodeInclude
OfflineSyncSpaceNodeIncludeList
OfflineSyncSpaceNodeRepository
OfflineSyncSpaceNodeTable
OfflineSyncSpaceNodeUpdateTable
OfflineSyncSpaceRepository
OfflineSyncSpaceSet
Authoritative or informational space set exchanged at the start of a cycle.
OfflineSyncSpaceTable
OfflineSyncSpaceUpdateTable
OfflineSyncStreamEvent
A CRDT sync event sent over a bidirectional stream.
OfflineSyncSubscription
A running continuous CRDT sync session.

Enums

CrdtDataDeletedReason
Why a synced user tombstone changed row visibility.
CrdtDataRowVisibility
Materialized visibility state for a CRDT row.
CrdtProjectionReason
Why a domain column currently differs from its authored value.
OfflineSyncPeerMode
How a peer decides which spaces it syncs.
OfflineSyncSpaceRole
CRDT access role for a member of a shared space.
OfflineSyncViolationOperation
Merge or sync operation that observed an integrity violation.
OfflineSyncViolationType
High-level category of a durable CRDT sync integrity violation.

Extensions

BaseHlcToHlc on BaseHlc
Extensions for BaseHlc to convert it to an Hlc.
CrdtDataDeletedExtension on CrdtDataDeleted
Extensions for the CrdtDataDeleted class.
CrdtDataDeletedReasonExtension on CrdtDataDeletedReason
Extensions for the CrdtDataDeletedReason enum.
CrdtDataFieldExtension on CrdtDataField
Extensions for the CrdtDataField class.
CrdtDataRowExtension on CrdtDataRow
Extensions for the CrdtDataRow class.
CrdtDataRowVisibilityExtension on CrdtDataRowVisibility
Extensions for the CrdtDataRowVisibility enum.
CrdtMergeChangeExtension on CrdtMergeChange
Convenience helpers shared by every merge change.
CrdtMergeChangeStreamExtension on Stream<CrdtMergeChange>
Helpers for grouping merge changes into stream payload batches.
CrdtMergeInsertExtension on CrdtMergeInsert
Convenience helpers for insert changes.
CrdtMergeRecorderExtension on CrdtMutationRecorder
Adds merge-specific behavior to CrdtMutationRecorder.
CrdtMergeSetExtension on CrdtMergeSet
CRDT merge helpers for CrdtMergeSet.
HlcMax on Iterable<Hlc>
Extensions for an Iterable of Hlc.
IncludeTombstonedRows on Table
Extension on Table that exposes includeHiddenRows for use in where clauses to bypass the CRDT tombstone/visibility filter.
OfflineSyncClientExtension on ServerpodClientShared
Exposes CRDT sync helpers from a generated client.
OfflineSyncDatabaseAccess on DatabaseSession
Convenience access to a CRDT-aware database from a wrapped session.
OfflineSyncSpaceRoleWriteAccess on OfflineSyncSpaceRole?
CRDT write capability for a space role.
OfflineSyncStreamEventStreamExtension on StreamIterator<OfflineSyncStreamEvent>
Extensions for stream iterators of OfflineSyncStreamEvent.
SpaceUuidFilter on Table
Extension on Table that exposes spaceEquals for use in where clauses to restrict membership-wide reads to a single space.

Properties

crdtRowLastVisibleVisibilityIndex int
Last serialized index that still represents a visible CRDT row.
final
spaceForTransaction Map<Transaction, OfflineSyncSpace>
Map of transaction hashes to the space they are associated with.
final
userForTransaction Map<Transaction, UuidValue>
Map of transaction hashes to the authenticated user associated with them.
final

Typedefs

CrdtMergeMetadataLookup = ({Map<String, Set<String>> columnNamesByTable, Map<String, Set<UuidValue>> rowIdsByTable})
Merge metadata extracted from a CrdtMergeSet.
CrdtMergeSet = List<CrdtMergeChange>
A group of CRDT merge changes collected for one sync batch.
DomainRowOwner = ({bool exists, int? spaceId})
A tuple representing the ownership of a domain row.
DomainRowOwnerCache = Map<(String, UuidValue), DomainRowOwner>
A cache of domain row owners by table name and row id.
OfflineSyncOnMergeSuccess = FutureOr<void> Function(UuidValue spaceUuid, Hlc syncedHlc)
Callback function for when a merge is successful.
OfflineSyncTransport = Stream<OfflineSyncStreamEvent> Function({required Stream<OfflineSyncStreamEvent> changes, required bool once})
Opens the remote half of a CRDT sync stream.

Exceptions / Errors

ClockDriftException
Exception thrown when the clock drift exceeds the maximum allowed.
DuplicateNodeException
Exception thrown when a duplicate node is detected.
OfflineSyncException
Base type for CRDT sync session failures.
OfflineSyncIntegrityViolationException
Thrown when sync observes terminal CRDT metadata/domain-row inconsistency.
OfflineSyncSchemaReconciliationException
Thrown when CRDT schema reconciliation cannot be applied safely.
OfflineSyncSpaceMembershipException
Thrown when a user attempts to act in a space they are not a member of.
OfflineSyncSpaceRoleException
Thrown when a user attempts to write in a space with a non-writable role.
OfflineSyncStreamClosedException
Thrown when the inbound sync stream closes before an expected event arrives.
OfflineSyncTablesHashMismatchException
Thrown when the sync tables hash sent by a peer does not match locally.
OfflineSyncUnexpectedEventException<T extends OfflineSyncStreamEvent>
Thrown when the inbound sync stream delivers an event of the wrong type.
OverflowException
Exception thrown when the timestamp counter overflows.