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.
to_map/1 returns maps with string keys, and every value is a string, a
boolean, nil or a list. Any JSON encoder can encode it, and a JavaScript
client reads the same names:
%{
"resource" => "MyApp.Candidate",
"nodes" => [
%{"id" => "review", "kind" => "manual", "initial" => false,
"notes" => [%{"kind" => "policy", "name" => nil, "action" => nil,
"label" => "actor.role == :reviewer", "retry" => nil}]}
],
"edges" => [
%{"from" => "review", "to" => "escalated", "kind" => "timeout",
"name" => "escalation", "label" => "after 7 days", "condition" => nil,
"fallback" => false}
]
}render/2 encodes that map with Jason.
Summary
Functions
Encodes the map from to_map/1 as JSON with Jason.
Options
:pretty— indent the JSON. Defaults tofalse.
@spec to_map(AshWorkflow.Charts.Graph.t()) :: map()
The graph as maps with string keys, ready for any JSON encoder.