Skip to content
Prose v0.3.2

Types

Passed to every step handler.

interface FlowContext<TInput, TDeps extends BaseFlowDependencies, TState> {
readonly input: Readonly<TInput>;
state: TState;
deps: TDeps;
meta: FlowMeta;
signal: AbortSignal;
}
PropertyDescription
inputOriginal input, readonly. Never changes during execution.
stateAccumulated state from prior steps. Each step’s return merges into this.
depsDependencies injected via .execute().
metaRuntime metadata (see FlowMeta).
signalCombined abort signal from flow timeout, step timeout, and external signal.

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;
};

Runtime metadata available via ctx.meta.

interface FlowMeta {
flowName: string;
startedAt: Date;
currentStep?: string;
correlationId?: string;
}

Configuration for .withRetry().

interface RetryOptions {
maxAttempts: number;
delayMs: number;
backoffMultiplier?: number;
maxDelayMs?: number;
shouldRetry?: (error: Error) => boolean;
stepTimeout?: number;
}

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.

Interface for the eventPublisher dependency.

interface FlowEventPublisher {
publish(channel: string, event: FlowEvent): Promise<void> | void;
}

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.

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. DrizzleTransaction

See the transactions guide for the full pattern.

Strategy for .parallel() result merging.

type MergeStrategy = 'shallow' | 'error-on-conflict' | 'deep';

Field-level validation error detail.

interface ValidationIssue {
field: string;
message: string;
value?: unknown;
}