ProcessData
Overview
Section titled “Overview”ProcessData is the base interface every saga state extends. It declares a single required field — correlationId — that the framework uses to key the row in the ISagaStore. Your own saga-state types add whatever extra fields the business logic needs.
The companion types ConcurrencyToken and FoundSaga<TData> describe the values an ISagaStore returns: an opaque optimistic-concurrency token, and a { data, concurrencyToken } pair handed back from findByCorrelationId.
Import
Section titled “Import”import type { ConcurrencyToken, FoundSaga, ProcessData,} from '@serviceconnect/core';ProcessData
Section titled “ProcessData”export interface ProcessData { correlationId: string;}correlationId(required) — the saga’s identity. Returned by eachProcessHandler.correlate(message)call and used by theISagaStoreas the row key. The framework sets it for you when astartsWithhandler creates a new saga; you do not need to mutate it insidehandle.
Extend the interface with whatever state your saga needs:
interface OrderState extends ProcessData { status: 'pending' | 'paid' | 'shipped'; itemCount: number; totalCents: number;}State is a plain mutable object — mutate it in handle(message, data, context) and the bus persists the result.
ConcurrencyToken
Section titled “ConcurrencyToken”export type ConcurrencyToken = string;The opaque optimistic-concurrency token returned by ISagaStore.insert and ISagaStore.update. The bus holds onto the token across a handle call and passes it back as expectedToken on the next update; if the row was changed between load and save the store should throw ConcurrencyError and the bus retries with the fresh state. Applications never construct or inspect a ConcurrencyToken directly — it is an implementation detail of the store.
FoundSaga
Section titled “FoundSaga”export interface FoundSaga<TData extends ProcessData> { readonly data: TData; readonly concurrencyToken: ConcurrencyToken;}The value returned by ISagaStore.findByCorrelationId when a row exists. data is the deserialised saga state; concurrencyToken is the token to pass back into update. findByCorrelationId returns undefined instead of a FoundSaga when no row exists for the given correlationId.