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' | 'sleeping' | 'waiting' | 'completed' | 'failed' | 'cancelled'
type TerminalRunStatus = 'completed' | 'failed' | 'cancelled'
type StepStatus =
  | 'pending' | 'running' | 'completed' | 'completed-early'
  | 'skipped' | 'sleeping' | 'waiting' | 'retrying' | 'failed'

RUN_STATUSES and STEP_STATUSES are exported as readonly arrays of every value, for building filters or validating input.

TypeShape
WorkflowRun{ id, workflow, input, idempotencyKey, status, createdAt, updatedAt, startedAt, finishedAt, output, error, wakeAt, waitingFor } — see Inspecting runs
RunError{ stepName, message, code } — why a failed run failed; code is the error's string code, or null
ClaimedRunWorkflowRun & { leaseId }
StepResult{ id, runId, name, status, output, error, attempts, createdAt, updatedAt, startedAt, history } — history is a StepAttempt[]
StepAttempt{ startedAt, finishedAt, error } — one attempt at a step's handler; error is null for the one that succeeded
RunCountsRecord<RunStatus, number> — returned by countRuns()
PruneOptions{ olderThan, statuses? } — what engine.prune() deletes
RunInfo{ run: WorkflowRun; steps: StepResult[] } — returned by getRunStatus()
CreateRunResult{ run: WorkflowRun; created: boolean } — returned by storage.createRun()
WorkflowSchedule{ key, workflow, input, recurrence, nextRunAt, createdAt, updatedAt } — a registered schedule
ScheduleRecurrence{ kind: 'interval'; intervalMs } | { kind: 'cron'; expression } — how a schedule repeats
ScheduleSpecWhat engine.schedule() accepts: number | { every } | { cron }
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?, delay?, startAt? }
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.