State
In a workflow, each state acts as a checkpoint. If a task fails, the workflow remains at that state, ensuring no progress is lost. Once a state changes, it becomes the new starting point for subsequent actions, meaning all future operations begin from that updated state. This approach ensures stability and consistency throughout the workflow process.
Allowed Actions
You can only perform actions that are listed in the action array of the current state in which the workflow resides.
Interface
interface State {
name: string;
actions: Action[];
}
interface Action {
name: string;
when?: string;
who?: any[]; // default []
on: {
[eventName: string]: {
name: string;
type: 'ACTION' | 'STATE';
};
};
}
Example
{
"name": "example_workflow",
"maxChainCount": 10,
"states": [
{
"name": "start",
"actions": [
{
"name": "manual_action_1", // After completing this action, the state transit to the final stage
"on": {
"done": {
"name": "final",
"type": "STATE"
}
}
},
{
"name": "manual_action_2", // After completing this action, it will find and perform action named chained_action
"on": {
"done": {
"name": "chained_action",
"type": "ACTION"
},
"error": {
"name": "final",
"type": "STATE"
}
}
},
{
"name": "chained_action", // After completing this action, the state transit to the final stage
"on": {
"done": {
"name": "final",
"type": "STATE"
}
}
}
]
},
{
"name": "final",
"actions": []
}
]
}