Types
FlowContext
Section titled “FlowContext”Passed to every step handler.
interface FlowContext<TInput, TDeps extends BaseFlowDependencies, TState> { readonly input: Readonly<TInput>; state: TState; deps: TDeps; meta: FlowMeta; signal: AbortSignal;}| Property | Description |
|---|---|
input | Original input, readonly. Never changes during execution. |
state | Accumulated state from prior steps. Each step’s return merges into this. |
deps | Dependencies injected via .execute(). |
meta | Runtime metadata (see FlowMeta). |
signal | Combined abort signal from flow timeout, step timeout, and external signal. |
BaseFlowDependencies
Section titled “BaseFlowDependencies”The base contract for flow dependencies. Both db and eventPublisher are optional — you only need to provide them when your flow uses .transaction() or .event() steps respectively.
type BaseFlowDependencies = { db?: DatabaseClient; eventPublisher?: FlowEventPublisher;};Extend this with your own dependencies:
type MyDeps = { db: DrizzleClient; eventPublisher: MyPublisher; logger: Logger;};FlowMeta
Section titled “FlowMeta”Runtime metadata available via ctx.meta.
interface FlowMeta { flowName: string; startedAt: Date; currentStep?: string; correlationId?: string;}RetryOptions
Section titled “RetryOptions”Configuration for .withRetry().
interface RetryOptions { maxAttempts: number; delayMs: number; backoffMultiplier?: number; maxDelayMs?: number; shouldRetry?: (error: Error) => boolean; stepTimeout?: number;}FlowEvent
Section titled “FlowEvent”The object returned by event builders, enriched with metadata before publishing.
interface FlowEvent { eventType: string; [key: string]: unknown;}The correlationId is automatically added by Prose before publishing — you don’t need to include it in your event builders.
FlowEventPublisher
Section titled “FlowEventPublisher”Interface for the eventPublisher dependency.
interface FlowEventPublisher { publish(channel: string, event: FlowEvent): Promise<void> | void;}DatabaseClient
Section titled “DatabaseClient”Interface for the db dependency used by .transaction() steps. The TTx generic parameter represents your ORM’s native transaction type.
interface DatabaseClient<TTx = unknown> { transaction<T>(fn: (tx: TTx) => Promise<T>): Promise<T>;}When you provide a typed DatabaseClient (e.g. from Drizzle), Prose infers TTx and passes it as the tx argument in .transaction() step handlers — no manual casting needed.
TxClientOf
Section titled “TxClientOf”Utility type that extracts the transaction client type from your dependencies. Useful when extracting transaction step handlers into standalone functions.
type TxClientOf<TDeps extends BaseFlowDependencies> = TDeps extends { db: DatabaseClient<infer TTx> } ? TTx : unknown;Define it once in your application types and reuse across extracted step functions:
import type { TxClientOf } from '@celom/prose';
type Tx = TxClientOf<AppDeps>; // e.g. DrizzleTransactionSee the transactions guide for the full pattern.
MergeStrategy
Section titled “MergeStrategy”Strategy for .parallel() result merging.
type MergeStrategy = 'shallow' | 'error-on-conflict' | 'deep';ValidationIssue
Section titled “ValidationIssue”Field-level validation error detail.
interface ValidationIssue { field: string; message: string; value?: unknown;}