AshWorkflow.Charts.Format (AshWorkflow v0.10.0)

Copy Markdown View Source

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

AshWorkflow.Charts.Graph calls the functions for DSL values, so every backend gets the same text for a deadline, a retry, a policy or a condition.

kind_text/1, node_text/1, edge_text/1 and note_text/1 turn a node or an edge of the graph into a label. The Mermaid and DOT backends call them, so both charts use the same words. A custom AshWorkflow.Charts.Backend can call them too.

Summary

Functions

A route's when expression, or nil for a route without one.

The deadline of a timeout entry from AshWorkflow.Info.workflow_graph/1.

A duration tuple as text, in the singular for one unit: {1, :days} is "1 day" and {7, :days} is "7 days".

The label of an AshWorkflow.Charts.Graph.Edge: a symbol for its kind, then its text.

The schedule of an every entry from AshWorkflow.Info.workflow_graph/1.

The text of a step kind: "⚙️ automatic", "✋ manual" or "⏳ wait state". The gear carries U+FE0F, so it draws as a colour emoji, the same as the other two.

The text inside a step box, for a chart that puts the notes in the step: the step's name, then kind_text/1 on the next line, then the notes under a — rule, one per line, as note_text/1 writes them.

A step's policy check, through the check's own describe/1 when it has one.

The retry policy of a step, or nil when the step makes one attempt only.

The label of an undo edge, with the window when the undo block sets within: "undo" or "undo within 1 hour".

Functions

condition(expression)

@spec condition(term()) :: String.t() | nil

A route's when expression, or nil for a route without one.

deadline(map)

@spec deadline(map()) :: String.t()

The deadline of a timeout entry from AshWorkflow.Info.workflow_graph/1.

duration(arg)

@spec duration(AshWorkflow.Duration.t()) :: String.t()

A duration tuple as text, in the singular for one unit: {1, :days} is "1 day" and {7, :days} is "7 days".

edge_text(edge)

@spec edge_text(AshWorkflow.Charts.Graph.Edge.t()) :: String.t()

The label of an AshWorkflow.Charts.Graph.Edge: a symbol for its kind, then its text.

  • ⚙ for on_success, ✖ for on_error, ⏱ for a timeout and ↶ for undo. A transition has no symbol.
  • A timeout gives its name before its deadline: ⏱ auto_escalate after 4 hours.
  • A conditional route adds when and its condition. The fallback route of a conditional on_success adds otherwise.

every(map)

@spec every(map()) :: String.t()

The schedule of an every entry from AshWorkflow.Info.workflow_graph/1.

kind_text(atom)

@spec kind_text(:automatic | :manual | :wait_state) :: String.t()

The text of a step kind: "⚙️ automatic", "✋ manual" or "⏳ wait state". The gear carries U+FE0F, so it draws as a colour emoji, the same as the other two.

node_text(node)

@spec node_text(AshWorkflow.Charts.Graph.Node.t()) :: String.t()

The text inside a step box, for a chart that puts the notes in the step: the step's name, then kind_text/1 on the next line, then the notes under a — rule, one per line, as note_text/1 writes them.

A terminal step has no kind line, but it keeps its notes.

note_text(note)

@spec note_text(AshWorkflow.Charts.Graph.Note.t()) :: String.t()

The text of an AshWorkflow.Charts.Graph.Note.

  • A policy note is policy: and the check, and a retry note is retry: and the policy.
  • A timeout that runs an action is ⏱, its deadline and the action.
  • An every is ↻, its schedule and the action.

A timeout or an every with its own retry adds , retry: and the policy.

policy(module)

@spec policy(term()) :: String.t() | nil

A step's policy check, through the check's own describe/1 when it has one.

retry(arg1)

@spec retry(AshWorkflow.Entities.Retry.t() | nil) :: String.t() | nil

The retry policy of a step, or nil when the step makes one attempt only.

undo(undo)

The label of an undo edge, with the window when the undo block sets within: "undo" or "undo within 1 hour".