WorkflowDefinition
interface exported by @mwillbanks/tuil-workflow.
interface
Public interface exported by @mwillbanks/tuil-workflow.
export interface WorkflowDefinition<TState> {
readonly id: string;
readonly version: number;
readonly initialState: TState | (() => TState);
readonly steps: Readonly<Record<string, WorkflowStep<TState>>>;
readonly transitions: readonly WorkflowTransition<TState>[];
readonly persistence?: WorkflowPersistence<TState>;
readonly migrate?: (
persisted: PersistedWorkflow<unknown>,
signal: AbortSignal,
) => PersistedWorkflow<TState> | Promise<PersistedWorkflow<TState>>;
readonly exitGuard?: (
context: WorkflowContext<TState>,
) => boolean | Promise<boolean>;
readonly analytics?: (event: WorkflowEvent<TState>) => void;
readonly onObserverError?: (error: unknown) => void;
}Members
| Member | Type | Required | Description | Related types |
|---|---|---|---|---|
id | string | Yes | The id member uses the string contract. | — |
version | number | Yes | The version member uses the number contract. | — |
initialState | TState | (() => TState) | Yes | The initialState member uses the TState | (() => TState) contract. | — |
steps | Readonly<Record<string, WorkflowStep<TState>>> | Yes | The steps member uses the Readonly<Record<string, WorkflowStep<TState>>> contract. | WorkflowStep |
transitions | readonly WorkflowTransition<TState>[] | Yes | The transitions member uses the readonly WorkflowTransition<TState>[] contract. | WorkflowTransition |
persistence | WorkflowPersistence<TState> | undefined | No | The persistence member uses the WorkflowPersistence<TState> | undefined contract. | WorkflowPersistence |
migrate | ((persisted: PersistedWorkflow<unknown>, signal: AbortSignal) => PersistedWorkflow<TState> | Promise<PersistedWorkflow<TState>>) | undefined | No | The migrate member uses the ((persisted: PersistedWorkflow<unknown>, signal: AbortSignal) => PersistedWorkflow<TState> | Promise<PersistedWorkflow<TState>>) | undefined contract. | PersistedWorkflow |
exitGuard | ((context: WorkflowContext<TState>) => boolean | Promise<boolean>) | undefined | No | The exitGuard member uses the ((context: WorkflowContext<TState>) => boolean | Promise<boolean>) | undefined contract. | WorkflowContext |
analytics | ((event: WorkflowEvent<TState>) => void) | undefined | No | The analytics member uses the ((event: WorkflowEvent<TState>) => void) | undefined contract. | WorkflowEvent |
onObserverError | ((error: unknown) => void) | undefined | No | The onObserverError member uses the ((error: unknown) => void) | undefined contract. | — |
Parameters
This declaration has no public members.
Returns
This declaration does not return a value.
Throws
No thrown errors are documented for this declaration.
Related types
Source
View the secondary source reference