commit()
The commit method finalizes a workflow definition, validating its structure and making it ready for execution. When calling .commit()
, the workflow validates:
- No circular dependencies between steps
- All paths must have an end point
- No unreachable steps
- No duplicate step IDs
- Variable references to non-existent steps
Usage
workflow
.step(stepA)
.then(stepB)
.commit();
Returns
workflow:
Workflow
The validated workflow instance
Error Handling
try {
workflow
.step(stepA)
.after(['stepB', 'stepC'])
.step(stepD)
.commit();
} catch (error) {
if (error instanceof ValidationError) {
console.log(error.type); // 'circular_dependency' | 'no_terminal_path' | 'unreachable_step'
console.log(error.details);
}
}
Validation Error Types
circular_dependency:
string
Steps form a circular reference
no_terminal_path:
string
Path has no end point
unreachable_step:
string
Step cannot be reached from workflow start
duplicate_step_id:
string
Multiple steps share the same ID
Related