# `Macaw.Frame.Document.Migration`
[🔗](https://github.com/dcoai/macaw_frame/blob/v0.1.0/lib/macaw/frame/document/migration.ex#L1)

The frame document's version line and its canonical value (spec/02 §9.1).

**The line starts at 1.** visualize's line and its migrations (its singular `frame`,
its flat style keys, its filled lines) are not carried over: a frame document is never
in visualize's shapes. `current/0` is `1` until a change needs a migration, and `step/2`
holds the pure steps, one per version, each producing a value that validates at its
target; there is none yet.

**Within a version a read value is canonical** (`canonical/1`): names as strings (an
atom given in Elixir is read as its string), a member of an enumeration spelled as a
string as the member, a style's shorthands as its parts, a text given as parts as its
string, a bare color atom as its typed color. The walk reads every
value by the schema's type at its position, so only a name is rewritten into a string
and only a color position's atom into a color; it stops at a struct, as every walk over
a design does (§1.7), but for a variable's and a fact's names. It is idempotent.

    iex> Macaw.Frame.Document.Migration.canonical(%{frames: %{main: %{kind: :cartesian}},
    ...>   styles: %{bad: %{fill: :red}}})
    %{frames: %{"main" => %{kind: "cartesian"}},
      styles: %{"bad" => %{fill: %{type: :solid, color: {:color, "red"}}}}}

# `canonical`

```elixir
@spec canonical(term()) :: term()
```

A design in its canonical shape (§9.1); any term that is no map as it is.

# `canonical`

```elixir
@spec canonical(term(), term()) :: term()
```

A node of `kind` alone in its canonical shape: a fragment's body. A kind the schema does
not have reads its value's names only.

    iex> Macaw.Frame.Document.Migration.canonical(%{stroke: :blue}, :style)
    %{stroke: %{type: :solid, color: {:color, "blue"}}}

# `current`

```elixir
@spec current() :: pos_integer()
```

The type's current version (§9.1): `1`.

# `step`

```elixir
@spec step(term(), term()) :: {:ok, map()} | {:error, [Macaw.Base.Fault.t(), ...]}
```

The document at `from` migrated to `from + 1`. The line has no step yet, so every
version asked for is `{:error, [{[], {:no_step, from}}]}`; the kernel never asks for one
while `current/0` is `1`.

---

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