Pure Elixir reducer for conversation transcript SSE/PubSub frames.
Applies document deltas with H.Document.apply_ops/2.
Summary
Functions
Applies a commit payload (decoded map or JSON binary).
Applies an ephemeral payload (decoded map or JSON binary) to docs["live"]
without advancing seq or mutating committed_docs.
Applies a snapshot payload (decoded map or JSON binary).
Creates a new empty H.Transcript reducer state.
Prepends an older page of entries in ascending order without duplicates and
updates before_entry_id and has_more.
Types
Functions
@spec apply_commit(t(), map() | binary()) :: {:ok, t(), %{appended_entries: [map()]}} | {:gap, t()} | {:stale, t()} | {:error, term()}
Applies a commit payload (decoded map or JSON binary).
Returns:
{:gap, t}whent.seqisnilorframe_seq > t.seq + 1(caller should resnapshot){:stale, t}whenframe_seq <= t.seq{:ok, updated, %{appended_entries: new_entries}}whenframe_seq == t.seq + 1
Applies an ephemeral payload (decoded map or JSON binary) to docs["live"]
without advancing seq or mutating committed_docs.
Returns :ignored when t.seq == nil or base_seq != t.seq.
Applies a snapshot payload (decoded map or JSON binary).
Sets seq, deduplicates and orders entries, updates before_entry_id and
has_more, and resets both committed_docs and docs.
Creates a new empty H.Transcript reducer state.
Prepends an older page of entries in ascending order without duplicates and
updates before_entry_id and has_more.