AshWorkflow.Transformers.AddStateMachine (AshWorkflow v0.6.0)

Copy Markdown View Source

Generates ash_state_machine configuration from workflow steps.

Injects the following into the resource's state_machine DSL:

  • state_attribute — the workflow's state_attribute, when it declares one.
  • initial_states — set to the step with initial: true, or the first non-terminal step by declaration order if none is marked.
  • default_initial_state — same as above
  • Transitions for each step type:
    • Automatic stepstransition :step_action, from: [:step_name], to: [...], where to is every target across the step's on_success entries. If on_error is set, a transition named __on_error_<step> to the error state is added — declared on the error handler action rather than on the step's own action, since that is what AshOban invokes when the step fails.
    • Manual steps — one transition per declared transition entity, e.g. transition :approve, from: [:review], to: [:approved]
    • Undoable transitions — when the workflow declares an undo block, two :undo transitions per undoable edge, one in each direction, so both a rewind and a subsequent redo are permitted.
    • Timeouts with transition_to — a transition named __timeout_<step>_<name>, e.g. transition :__timeout_review_escalation, from: [:review], to: [:escalated]

Must run before all AshStateMachine.Transformers.* so that the state machine extension sees the generated states and transitions.

Summary

Functions

after?(_)

Callback implementation for Spark.Dsl.Transformer.after?/1.

after_compile?()

Callback implementation for Spark.Dsl.Transformer.after_compile?/0.

before?(arg1)

Callback implementation for Spark.Dsl.Transformer.before?/1.

transform(dsl)

Callback implementation for Spark.Dsl.Transformer.transform/1.