Sync / foldkit-durable

ReplayResult

type · packages/durable/src/journal.ts:376

type ReplayResult<Operation, Snapshot> =
  | {
      readonly _tag: 'Operations'
      readonly epoch: string
      readonly cursor: Cursor
      readonly operations: ReadonlyArray<Committed<Operation>>
      readonly hasMore: boolean
    }
  | {
      readonly _tag: 'Snapshot'
      readonly epoch: string
      readonly cursor: Cursor
      readonly snapshot: Snapshot
      readonly reason: 'epoch-changed' | 'compacted' | 'cursor-ahead'
    }

The outcome of replay for a reconnecting client: either the incremental operations committed after the client's cursor, or the authoritative snapshot when the client's epoch changed, its cursor fell behind the compaction floor, or its cursor is ahead of the document.