@getriebe/workflow
Execute workflow definitions and snapshot running instances.
Source revision 49560371f6cd34d30383df5619df46969c594ae4.
Additional import paths:
@getriebe/workflow/node
ActivityLoop
Section titled “ActivityLoop”export interface ActivityLoop { readonly condition: WorkflowExpression; readonly testBefore: boolean; readonly maximum?: number;}EXPRESSION_SCRIPT_FORMAT
Section titled “EXPRESSION_SCRIPT_FORMAT”export declare const EXPRESSION_SCRIPT_FORMAT = "application/vnd.getriebe.expression-v1";JAVASCRIPT_SCRIPT_FORMAT
Section titled “JAVASCRIPT_SCRIPT_FORMAT”export declare const JAVASCRIPT_SCRIPT_FORMAT = "text/javascript";MultiInstance
Section titled “MultiInstance”export type MultiInstance = { readonly inputField: string; readonly outputField: string; readonly completionCondition?: MultiInstanceCompletionCondition; readonly sequential?: boolean;} & ({ readonly resourceId: string; readonly roleByItem?: never;} | { readonly resourceId?: never; readonly roleByItem: Readonly<Record<string, string>>;});MultiInstanceCompletionCondition
Section titled “MultiInstanceCompletionCondition”export interface MultiInstanceCompletionCondition extends WorkflowExpression { readonly outputItem: string;}ParallelMultiInstance
Section titled “ParallelMultiInstance”export interface ParallelMultiInstance { readonly inputField: string; readonly outputField: string; readonly completionCondition?: MultiInstanceCompletionCondition; readonly sequential?: false; readonly resourceId?: never; readonly roleByItem: Readonly<Record<string, string>>;}ScriptEvaluator
Section titled “ScriptEvaluator”export interface ScriptEvaluator { readonly format: string; compile(source: string, inputs: Readonly<Record<string, ValueKind>>, output: ValueKind): (inputs: Readonly<Record<string, EncodedProcessValue>>) => unknown;}SequenceFlow
Section titled “SequenceFlow”export interface SequenceFlow { readonly id: string; readonly source: string; readonly target: string; readonly condition?: WorkflowExpression;}splitCalledElementId
Section titled “splitCalledElementId”export declare function splitCalledElementId(id: string): { readonly callId: string; readonly elementId: string;} | undefined;WaitingParallelJoin
Section titled “WaitingParallelJoin”export interface WaitingParallelJoin { readonly nodeId: string; readonly arrived: readonly string[]; readonly waitingFor: readonly string[]; readonly scopeExecutionId?: string;}Workflow
Section titled “Workflow”export declare class Workflow { constructor(definition: WorkflowDefinition, options?: WorkflowOptions); start(): WorkflowInstance; startMessage(type: MessageType, payload: unknown): { readonly instance: WorkflowInstance; readonly data: ProcessData; }; waitingParallelJoins(instance: WorkflowInstance): readonly WaitingParallelJoin[]; advance(instance: WorkflowInstance, rootData?: ProcessData, options?: { readonly now?: number; }): WorkflowAdvance; writeScopeData(instance: WorkflowInstance, executionId: string, updates: ProcessData): WorkflowInstance; faultServiceActivity(instance: WorkflowInstance, id: string, errorCode: string): WorkflowAdvance; completeActivity(instance: WorkflowInstance, id: string, result?: boolean): WorkflowAdvance; fireDueTimer(instance: WorkflowInstance, now: number, id?: string | undefined): WorkflowTimerResult; restore(snapshot: string): WorkflowInstance;}WorkflowActivity
Section titled “WorkflowActivity”export interface WorkflowActivity { readonly id: string; readonly nodeId: string; readonly kind: WorkflowActivityKind; readonly iteration: number; readonly dueAt?: number; readonly reminderAt?: number; readonly scopeExecutionId?: string; readonly roundInputs?: Readonly<Record<string, EncodedProcessValue>>; readonly multiInstance?: { readonly roundId: string; readonly index: number; readonly item: string; readonly resourceId: string; };}WorkflowActivityError
Section titled “WorkflowActivityError”export declare class WorkflowActivityError extends Error { readonly code = "not-active"; constructor(id: string);}WorkflowActivityKind
Section titled “WorkflowActivityKind”export type WorkflowActivityKind = "userTask" | "serviceTask" | "sendTask" | "messageCatch";WorkflowActivityResultError
Section titled “WorkflowActivityResultError”export declare class WorkflowActivityResultError extends TypeError { constructor(message: string);}WorkflowAdvance
Section titled “WorkflowAdvance”export interface WorkflowAdvance { readonly instance: WorkflowInstance; readonly executedNodeId?: string; readonly activatedActivity?: WorkflowActivity; readonly activatedActivities?: readonly WorkflowActivity[]; readonly completedActivity?: WorkflowActivity; readonly multiInstanceCompletion?: { readonly vote: boolean; readonly withdrawnActivities: readonly WorkflowActivity[]; }; readonly completionConditionError?: { readonly nodeId: string; readonly message: string; }; readonly dataUpdates?: ProcessData; readonly decision?: WorkflowDecision; readonly script?: WorkflowScriptCompletion; readonly callStarted?: WorkflowCallExecution; readonly callReturn?: WorkflowCallExecution; readonly modeledError?: WorkflowModeledError; readonly termination?: ScopeWithdrawal;}WorkflowCallActivity
Section titled “WorkflowCallActivity”export interface WorkflowCallActivity { readonly id: string; readonly kind: "callActivity"; readonly target: WorkflowDefinition; readonly inputs: readonly WorkflowCallBinding[]; readonly outputs: readonly WorkflowCallBinding[];}WorkflowCallBinding
Section titled “WorkflowCallBinding”export interface WorkflowCallBinding { readonly source: string; readonly target: string; readonly kind: ValueKind;}WorkflowCallExecution
Section titled “WorkflowCallExecution”export interface WorkflowCallExecution { readonly nodeId: string; readonly executionId: string; readonly targetVersionId: string; readonly scopeExecutionId?: string;}WorkflowDecision
Section titled “WorkflowDecision”export interface WorkflowDecision { readonly executionId: string; readonly nodeId: string; readonly tableId: string; readonly ruleId: string; readonly scopeExecutionId?: string;}WorkflowDecisionTable
Section titled “WorkflowDecisionTable”export interface WorkflowDecisionTable { readonly tableId: string; readonly inputField: string; readonly outputField: string; readonly rules: readonly DecisionRule[];}WorkflowDefinition
Section titled “WorkflowDefinition”export interface WorkflowDefinition extends WorkflowScope { readonly id: string;}WorkflowDefinitionError
Section titled “WorkflowDefinitionError”export declare class WorkflowDefinitionError extends Error { readonly code: WorkflowDefinitionErrorCode; readonly elementId: string | undefined; constructor(code: WorkflowDefinitionErrorCode, message: string, elementId?: string, options?: ErrorOptions);}WorkflowDefinitionErrorCode
Section titled “WorkflowDefinitionErrorCode”export type WorkflowDefinitionErrorCode = "invalid-id" | "duplicate-id" | "unknown-node" | "unsupported-node" | "invalid-start" | "invalid-connections" | "invalid-condition" | "invalid-loop" | "invalid-activity" | "invalid-timer" | "invalid-call-binding" | "invalid-bpmn-error" | "invalid-multi-instance" | "disconnected";WorkflowExpression
Section titled “WorkflowExpression”export interface WorkflowExpression { readonly source: string; readonly language: string;}WorkflowFailure
Section titled “WorkflowFailure”export type WorkflowFailure = { readonly code: "deadlock";} | { readonly code: "unhandled-bpmn-error"; readonly nodeId: string; readonly errorCode: string;} | { readonly code: "firing-rejected" | "no-matching-route"; readonly nodeId: string;} | { readonly code: "condition-error" | "invalid-multi-instance-input" | "invalid-decision-input" | "script-task-error" | "invalid-call-input" | "invalid-call-output"; readonly nodeId: string; readonly message: string;};WorkflowInstance
Section titled “WorkflowInstance”declare class WorkflowInstance { readonly activities: readonly WorkflowActivity[]; readonly scopeExecutions: readonly WorkflowScopeExecution[]; readonly intermediateTimers: readonly WorkflowIntermediateTimer[]; readonly scopeTimers: readonly WorkflowScopeTimer[]; constructor(state: State, definitionKey: string, activities: readonly WorkflowActivity[], scopeExecutions: readonly WorkflowScopeExecution[], intermediateTimers: readonly WorkflowIntermediateTimer[], scopeTimers: readonly WorkflowScopeTimer[]); get status(): WorkflowStatus; get reachedEnds(): readonly string[]; get nextTimer(): WorkflowTimer | undefined; scopeDeadlines(scopeExecutionId: string | undefined): readonly WorkflowScopeTimer[]; effectiveDueAt(activity: WorkflowActivity): number | undefined; get failure(): WorkflowFailure | undefined; snapshot(): string;}WorkflowIntermediateTimer
Section titled “WorkflowIntermediateTimer”export interface WorkflowIntermediateTimer extends WorkflowTimer { readonly nodeId: string; readonly scopeExecutionId?: string;}WorkflowModeledError
Section titled “WorkflowModeledError”export interface WorkflowModeledError { readonly errorCode: string; readonly throwNodeId: string; readonly scopeExecutionId?: string; readonly handlerNodeId?: string; readonly handlerExecutionId?: string; readonly handlerActivityId?: string;}WorkflowNode
Section titled “WorkflowNode”export type WorkflowNode = FlowNode & ({ readonly kind: "start" | "step" | "end" | "xor" | "and" | Exclude<WorkflowActivityKind, "serviceTask">;} | { readonly kind: "serviceTask"; readonly errorCodes?: readonly string[];} | { readonly kind: "businessRuleTask"; readonly decision: WorkflowDecisionTable;} | WorkflowMessageStart | WorkflowScriptTask | WorkflowCallActivity | { readonly kind: "subProcess"; readonly scope: WorkflowScope;} | { readonly kind: "intermediateTimer"; readonly durationMs: number;} | { readonly kind: "terminateEnd";} | { readonly kind: "errorEnd"; readonly errorCode: string;} | { readonly kind: "boundaryError"; readonly attachedTo: string; readonly errorCode: string;} | { readonly kind: "boundaryTimer"; readonly attachedTo: string; readonly interrupting?: boolean; readonly durationMs: number;});WorkflowOptions
Section titled “WorkflowOptions”export interface WorkflowOptions { readonly scriptEvaluators?: readonly ScriptEvaluator[];}WorkflowScope
Section titled “WorkflowScope”export interface WorkflowScope { readonly nodes: readonly WorkflowNode[]; readonly flows: readonly SequenceFlow[]; readonly fields?: Readonly<Record<string, ValueKind>>;}WorkflowScopeExecution
Section titled “WorkflowScopeExecution”export interface WorkflowScopeExecution { readonly id: string; readonly nodeId: string; readonly parentId?: string; readonly targetVersionId?: string; readonly fields: Readonly<Record<string, ValueKind>>; readonly data: ProcessData;}WorkflowScopeTimer
Section titled “WorkflowScopeTimer”export interface WorkflowScopeTimer extends WorkflowIntermediateTimer { readonly scopeExecutionId: string;}WorkflowScriptCompletion
Section titled “WorkflowScriptCompletion”export interface WorkflowScriptCompletion { readonly executionId: string; readonly nodeId: string; readonly scopeExecutionId?: string;}WorkflowScriptTask
Section titled “WorkflowScriptTask”export interface WorkflowScriptTask { readonly id: string; readonly kind: "scriptTask"; readonly scriptFormat: string; readonly script: string; readonly inputs: readonly { readonly name: string; readonly kind: ValueKind; readonly source: string; }[]; readonly outputs: readonly [ { readonly name: string; readonly kind: ValueKind; readonly target: string; } ];}WorkflowStatus
Section titled “WorkflowStatus”export type WorkflowStatus = "running" | "completed" | "failed";WorkflowTimeError
Section titled “WorkflowTimeError”export declare class WorkflowTimeError extends RangeError { constructor(message: string);}WorkflowTimer
Section titled “WorkflowTimer”export interface WorkflowTimer { readonly activityId: string; readonly dueAt: number;}WorkflowTimerResult
Section titled “WorkflowTimerResult”export type WorkflowTimerResult = { readonly status: "ignored" | "failed"; readonly instance: WorkflowInstance;} | { readonly status: "fired"; readonly instance: WorkflowInstance; readonly timer: WorkflowTimer; readonly executedNodeId: string; readonly termination?: ScopeWithdrawal;};