# `AshWorkflow.Charts.Format`
[🔗](https://github.com/team-alembic/ash_workflow/blob/v0.12.0/lib/ash_workflow/charts/format.ex#L1)

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.

# `condition`

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

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

# `deadline`

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

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

# `duration`

```elixir
@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`

```elixir
@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 an `on_signal`, `⏱`
  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`

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

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

# `kind_text`

```elixir
@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`

```elixir
@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`

```elixir
@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.
* An `on_signal` that runs an action is `📨`, the signal and the action.

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

# `policy`

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

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

# `retry`

```elixir
@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`

```elixir
@spec undo(AshWorkflow.Entities.Undo.t()) :: String.t()
```

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

---

*Consult [api-reference.md](api-reference.md) for complete listing*
