API Reference AshWorkflow v#0.10.0

Copy Markdown View Source

Modules

Declarative workflow orchestration for Ash Framework.

Ash calculation that returns the list of user-facing actions available for a workflow record's current step.

Ash calculation that returns the name of the workflow's current step.

Ash calculation listing the timeouts and every entries still ahead of a record in its current step, soonest first.

Ash calculation that returns the list of all workflow step names.

Ash calculation that maps each transition of a record's current step to the step it would move the record to, as AshWorkflow.Info.transition_target/3 resolves it.

An Ash change that evaluates an automatic step's on_success routes to determine the transition target.

An Ash change that evaluates conditional routes at runtime to determine the transition target.

Records a workflow event: writes through state_entered_at and, if a transition_log is configured, appends one row describing what happened.

Refuses a transition built from a stale record: the update writes only if the row still holds the values the transition decided from.

Performs the state half of an undo: resolves the row to reverse, rewinds the record to that row's from_state, and hands the row to AshWorkflow.Changes.RecordEvent through the changeset context so the new log row can point at it.

Draws a workflow as a diagram.

The contract a diagram format implements.

Draws an AshWorkflow.Charts.Graph as a Graphviz DOT diagram: the steps, edges and labels of AshWorkflow.Charts.Mermaid, with colour and line styles. The dot command of Graphviz draws DOT as SVG, PNG or PDF.

Writes DSL values out as the short phrases a chart shows.

The diagram model every AshWorkflow.Charts backend draws from.

One way a record can move from one step to another, as AshWorkflow.Charts.Graph.build/2 gives it to a chart backend.

One step of a workflow, as AshWorkflow.Charts.Graph.build/2 gives it to a chart backend.

Something a step does without leaving it, attached to its AshWorkflow.Charts.Graph.Node.

An AshWorkflow.Charts.Graph as plain data, for a client that draws the workflow itself: D3 with a layout library such as dagre or ELK.js, Cytoscape, React Flow, or a LiveView hook.

Draws an AshWorkflow.Charts.Graph as a Mermaid stateDiagram-v2.

The colours of the charts that AshWorkflow.Charts.Dot draws, for each theme. A backend that draws in colour reads them here, so every such chart has the same look.

Re-exports Ash policy check helpers for use inside workflow step blocks.

The duration tuple a timeout measures with fire_after and a retry block waits with backoff.

Configures actor capture on a transition_log.

Defines a recurring action entity with its configuration schema.

Defines the failure policy for a step's or timeout's generated work.

A conditional target for a transition. Evaluated at runtime using Ash.Expr.eval/2.

Defines a workflow step entity with its configuration schema.

Defines a workflow timeout entity with its configuration schema.

A named transition from a manual step to another step.

Configures an opt-in transition log for a workflow.

Configures undo for a workflow.

Returned (or raised) when an automatic step's action succeeds but none of its on_success routes match the resulting record.

Raised (or returned) when undo is called on a record that cannot be rewound.

Introspection helpers for AshWorkflow resources.

The behaviour a module implements to run a workflow's scheduled work.

Answers whether this node is the one that should arm timers.

Runs a workflow's scheduled work through ash_oban. The default scheduler.

Fires scheduled work by arming a timer for each deadline, rather than polling for records whose deadline has passed.

One unit of scheduled work a workflow declares, in AshWorkflow's own terms.

The :telemetry events AshWorkflow emits.

Generates and modifies Ash actions based on workflow step declarations.

Adds the state_entered_at attribute if not already defined on the resource.

Generates workflow calculations on the resource.

Generates code interface definitions for workflow actions.

Adds the composite indexes that the generated Oban triggers need, for resources using AshPostgres.DataLayer.

Generates Ash policies from workflow step declarations.

Adds a public has_many :transitions relationship to the transition_log resource when one is configured.

Describes the workflow's scheduled work, then hands it to the selected scheduler.

Generates ash_state_machine configuration from workflow steps.

Runtime helpers shared by AshWorkflow.Changes.RecordEvent and the generated state_at/2 and history/1 code interface functions.

Runtime resolution for the generated undo action: decides whether a record may be rewound, and to where.

Verifies that an every's until bound is coherent, and that its last_fired_field — explicit or generated — is a column every can safely own.

Rejects a retry block declared on a step nothing is scheduled for.

Verifies that a workflow declaring a policy has an authorizer to enforce it.

Verifies that timeout field and fire_at options are valid.

Verifies that each action timeout's <step>_<timeout>_fired_at column is one the timeout can safely own.

Rejects timeouts and every entities whose deadline is shorter than the selected scheduler can honour.

Verifies that a configured transition_log resource has the schema AshWorkflow.Changes.RecordEvent and the state_at/2/history/1 code interface depend on.

Verifies that undo is coherently configured.

Verifies that workflow step declarations are valid and internally consistent.

Mix Tasks

Seeds an approximate :initial transition-log row for existing records.

Prints or writes a diagram of each AshWorkflow resource.

Scaffolds a transition log resource for a workflow

Installs AshWorkflow, along with AshOban, AshStateMachine and Oban