Skip to content

Types

All public types are exported from the package root (reflow-ts).

Persisted data

typescript
type PersistedPrimitive = string | number | boolean | null | undefined | Date
type PersistedValue = PersistedPrimitive | PersistedValue[] | { [key: string]: PersistedValue }

Everything stored as workflow input or step output must be a PersistedValue. See Storage.

Runs and steps

typescript
type RunStatus = 'pending' | 'running' | 'completed' | 'failed' | 'cancelled'
type StepStatus = 'pending' | 'running' | 'completed' | 'completed-early' | 'failed'
TypeShape
WorkflowRun{ id, workflow, input, idempotencyKey, status, createdAt, updatedAt }
ClaimedRunWorkflowRun & { leaseId }
StepResult{ id, runId, name, status, output, error, attempts, createdAt, updatedAt }
RunInfo{ run: WorkflowRun; steps: StepResult[] } — returned by getRunStatus()
CreateRunResult{ run: WorkflowRun; created: boolean } — returned by storage.createRun()
RetryConfig{ maxAttempts, backoff, initialDelayMs?, timeoutMs? }

Workflow & engine types

TypePurpose
Workflow<TName, TInput, TPrev, TSteps>The workflow builder type
AnyWorkflowA workflow with any parameters (for collections)
StepContextThe object passed to step handlers
StepConfigThe config-object form of .step()
StepDefinitionInternal step representation exposed on the workflow
ParallelBranch / InferBranchOutputBranch handler type and its output inference
ExecutionUnitA sequential step or a parallel group
FailureContextThe object passed to onFailure
Engine / EngineConfig / EngineHooksEngine surface
EngineEvent / EngineEventOf / StreamOptions / ResultStreamEvents & streams
EnqueueOptions{ idempotencyKey? }
StorageAdapterCustom storage contract

Inference helpers

For building typed wrappers around Reflow:

typescript
type InferInput<W>        // extract a workflow's input type
type InferSteps<W>        // extract a workflow's accumulated steps map
type WorkflowInputMap<T>  // { [name]: inputType } across a workflow tuple
type WorkflowStepsMap<T>  // { [name]: stepsRecord } across a workflow tuple

WorkflowInputMap is what powers enqueue()'s type-safety — it maps each registered workflow name to its required input shape.

Released under the MIT License.