AshWorkflow.Transformers.AddActions (AshWorkflow v0.6.0)

Copy Markdown View Source

Generates and modifies Ash actions based on workflow step declarations.

Adds or modifies the following actions on the resource:

  • Transition actions (for manual steps) — one :update action per declared transition entity. Each includes:

    • BuiltinChanges.transition_state(target) to move the state
    • AshWorkflow.Changes.RecordEvent (triggered_by: :manual) to write through state_entered_at and append a log row if a transition_log is configured
  • Automatic step action injection — for automatic steps, the user defines their own update action with business logic. This transformer finds that action by the step's action name and appends transition_state and RecordEvent (triggered_by: :automatic) changes to it. Raises at compile time if the action is not defined on the resource.

  • Timeout transition actions — for timeouts with transition_to, generates a hidden update action named __timeout_<step>_<name> that transitions to the target state and records the event (triggered_by: :timeout).

  • Undo action — when the workflow declares an undo block, a single :undo update action that rewinds the record to the state before its most recent undoable state change. Not atomic: the target is only known after reading the transition log.

  • Primary read action — if the workflow has automatic steps (which generate Oban triggers) and no primary read action is defined, generates one with keyset pagination enabled (required by ash_oban).

Also adds a resource-global change RecordEvent, on: [:create] (triggered_by: :initial), since workflows are started through the user's own create action rather than a generated one — there is no per-action call site to inject into for that event.

Summary

Functions

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

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

Name of the hidden action a transition timeout performs.

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

Name of the generated undo action.

Functions

after?(arg1)

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.

timeout_action_name(step, timeout)

Name of the hidden action a transition timeout performs.

Scoped by step so the same timeout name can be used on more than one step, the way transition names can.

transform(dsl)

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

undo_action_name()

@spec undo_action_name() :: atom()

Name of the generated undo action.