Macaw.Frame.Diagrams.PageFlow (macaw_frame v0.1.0)

Copy Markdown View Source

diagrams.page_flow (spec/13 §7.5): how data flows through a Macaw page, from its sources through the state its controls change to the cells that show it, drawn as a layered flowchart over the layered step in a layout frame, as SVG with no script.

Its data is the shape macaw's Macaw.Page.Graph.describe/1 answers (macaw#451), %{nodes, edges}, each list a slot's rows: nodes (id, kind, label) and edges (source, target, label), the shape's other fields read by nothing. rows/1 turns the shape into those rows, judged. Each kind is drawn by its own shape and named in words on its left, never by color alone: a source is a cylinder, a derived source a hexagon, a state a stadium, an export a parallelogram and a cell a rectangle.

Like every diagram it is its text form's design: Macaw.Frame.TextForms.PageFlow walks the flow as a nested list, source by source, so the same flow is authored as text, read as text by a person who can't see the drawing, or bound to sources. text/2 writes a described flow in that form.

iex> Macaw.Frame.Diagrams.PageFlow.id()
"diagrams.page_flow"

Summary

Functions

What it draws, for a person and a builder's library.

A small page's data flow exactly as Macaw.Page.Graph.describe/1 answers it (spec/13 §7.5), copied from macaw's answer (2026-11-19): a services feed shown by two stat cells and read, with the health.service export of the health.filter state, by the busy derived source; the notes surface mirrors the export into a state its latency cell's request reads.

Its fixtures (spec/14 §1): a small page's data flow as describe/1 answers it (example/0), written in the text form, a feed and a derived source over an export, a mirror, and three cells.

The fragment: the text form's design, its direction a parameter.

The fragment's id in the catalog store.

What the fragment is: a whole design, or layers placed in one.

The kinds of a page's nodes (spec/13 §7.5), in flow order.

Its namespace (spec/13 §2).

Its parameters (spec/13 §3, §7.5): the conventions, its description naming each kind's shape, its margin leaving room on the left for the kind word beside a box, and direction, TB by default.

The slots' rows of a page's described data flow (spec/13 §7.5): of %{nodes, edges} as Macaw.Page.Graph.describe/1 answers it (keys and kinds by atom or by spelling), {:ok, %{"nodes" => rows, "edges" => rows}}, each row string-keyed with the fields the slots read and each kind by its spelling; or every fault at once by path: a shape that is no such map {[], {:type, :described}}, a node or an edge that is no map {[:nodes, i], {:type, :map}}, an id, a label or an end that is no text {[:nodes, i, :id], {:type, :text}}, a kind of none of kinds/0 {[:nodes, i, :kind], {:kind, spelling}}, an id given twice {[:nodes, i, :id], {:duplicate, id}} and an end naming no node {[:edges, i, :source], {:unknown_node, id}}.

The shape each kind is drawn by (spec/13 §7.5).

Its slots: the text form's nodes (id, kind, label) and edges (source, target, label).

A described flow written in the text form (spec/13 §7.5), under a header of direction ("TB" by default): {:ok, text}, the described flow's faults as rows/1 gives them, or {:error, [{[], {:type, :text}}]} for a flow the form can't write (a name or a label holding a line break or an arrow).

The parameters a read text sets: its header's direction.

Its text form (spec/13 §7.5): the flow walked as a nested list.

Functions

doc()

@spec doc() :: String.t()

What it draws, for a person and a builder's library.

example()

@spec example() :: %{nodes: [map()], edges: [map()]}

A small page's data flow exactly as Macaw.Page.Graph.describe/1 answers it (spec/13 §7.5), copied from macaw's answer (2026-11-19): a services feed shown by two stat cells and read, with the health.service export of the health.filter state, by the busy derived source; the notes surface mirrors the export into a state its latency cell's request reads.

fixtures()

@spec fixtures() :: [map()]

Its fixtures (spec/14 §1): a small page's data flow as describe/1 answers it (example/0), written in the text form, a feed and a derived source over an export, a mirror, and three cells.

fragment()

@spec fragment() :: map()

The fragment: the text form's design, its direction a parameter.

id()

@spec id() :: String.t()

The fragment's id in the catalog store.

kind()

@spec kind() :: :design | :layers

What the fragment is: a whole design, or layers placed in one.

kinds()

@spec kinds() :: [String.t(), ...]

The kinds of a page's nodes (spec/13 §7.5), in flow order.

namespace()

@spec namespace() :: :charts | :maps | :diagrams

Its namespace (spec/13 §2).

parameters()

@spec parameters() :: [{String.t(), map()}]

Its parameters (spec/13 §3, §7.5): the conventions, its description naming each kind's shape, its margin leaving room on the left for the kind word beside a box, and direction, TB by default.

rows(described)

@spec rows(term()) ::
  {:ok, %{required(String.t()) => [%{required(String.t()) => term()}]}}
  | {:error, [Macaw.Base.Fault.t(), ...]}

The slots' rows of a page's described data flow (spec/13 §7.5): of %{nodes, edges} as Macaw.Page.Graph.describe/1 answers it (keys and kinds by atom or by spelling), {:ok, %{"nodes" => rows, "edges" => rows}}, each row string-keyed with the fields the slots read and each kind by its spelling; or every fault at once by path: a shape that is no such map {[], {:type, :described}}, a node or an edge that is no map {[:nodes, i], {:type, :map}}, an id, a label or an end that is no text {[:nodes, i, :id], {:type, :text}}, a kind of none of kinds/0 {[:nodes, i, :kind], {:kind, spelling}}, an id given twice {[:nodes, i, :id], {:duplicate, id}} and an end naming no node {[:edges, i, :source], {:unknown_node, id}}.

shapes()

@spec shapes() :: %{required(String.t()) => String.t()}

The shape each kind is drawn by (spec/13 §7.5).

slots()

@spec slots() :: %{required(String.t()) => map()}

Its slots: the text form's nodes (id, kind, label) and edges (source, target, label).

text(described, direction \\ "TB")

@spec text(term(), String.t()) ::
  {:ok, String.t()} | {:error, [Macaw.Base.Fault.t(), ...]}

A described flow written in the text form (spec/13 §7.5), under a header of direction ("TB" by default): {:ok, text}, the described flow's faults as rows/1 gives them, or {:error, [{[], {:type, :text}}]} for a flow the form can't write (a name or a label holding a line break or an arrow).

text_bind(arg1)

@spec text_bind(map()) :: %{required(String.t()) => term()}

The parameters a read text sets: its header's direction.

text_form()

@spec text_form() :: module()

Its text form (spec/13 §7.5): the flow walked as a nested list.