A derived source's map and JSON forms (spec/15 §2): an adapter at the edge, moved from
macaw_data (dco-tek/macaw/macaw#478 decision 2, #480). The source is the term,
Macaw.Data.Derived, judged by its new/1.
The form is written and read by macaw_layers' JSON adapter (Macaw.Layers.Form) under
the kernel's tags and the source's own: names as strings, per's :identity a $atom,
times $time, an input {name, window} as {"$input": [name, window]}, a source's name
{"$source": name}, {:identity, input} as {"$identity": input}, and the output
schema in Macaw.Definition.Schema's map form. No atom is made from a document.
A derived source holds no URL: one the document holds (a $url at a window's bound) is
{path, {:url, reason}} under the kernel's closed policy, never quoting it.
Summary
Functions
One fault of reading a derived source as a line a person reads: a reason the kernel's
reader gives (a limit, a URL, a tag) in macaw_layers' words (Macaw.Layers.Words), its
schema's as Macaw.Definition.Schema.format_error/1 words them, under schema, and every
other as Macaw.Data.Derived.format_error/1 words it. A URL is never quoted.
The derived source a JSON document holds: as from_map/2, its bytes and nesting held to
the limits before it is decoded.
As from_json/2, raising ArgumentError naming every fault.
The derived source a map form holds: through macaw_layers' gates
(Macaw.Layers.Form.gates/3: the depth and item limits, the version), read by its tag
table and keys, making no atom, its schema by Macaw.Definition.Schema.from_map/1, then
judged by Macaw.Data.Derived.new/1. limits: tightens the limits. {:ok, source}, or
every fault by path.
As from_map/2, raising ArgumentError naming every fault.
The source's JSON form: to_map/1, stamped "$version" and encoded.
The source's map form, JSON-ready: {:ok, map}, or every value without a form, by path
(a window's time not in Etc/UTC is {:type, :term}). from_map(map) == {:ok, source}.
Functions
@spec format_error(Macaw.Base.Fault.t()) :: String.t()
One fault of reading a derived source as a line a person reads: a reason the kernel's
reader gives (a limit, a URL, a tag) in macaw_layers' words (Macaw.Layers.Words), its
schema's as Macaw.Definition.Schema.format_error/1 words them, under schema, and every
other as Macaw.Data.Derived.format_error/1 words it. A URL is never quoted.
iex> Macaw.Definition.Derived.format_error({[:from, 0, :window, :window, 0], {:url, :scheme}})
"from.0.window.window.0: the URL's scheme is refused: this host does not allow it"
@spec from_json(binary(), keyword()) :: {:ok, Macaw.Data.Derived.t()} | {:error, [Macaw.Base.Fault.t(), ...]}
The derived source a JSON document holds: as from_map/2, its bytes and nesting held to
the limits before it is decoded.
@spec from_json!(binary(), keyword()) :: Macaw.Data.Derived.t()
As from_json/2, raising ArgumentError naming every fault.
@spec from_map(map(), keyword()) :: {:ok, Macaw.Data.Derived.t()} | {:error, [Macaw.Base.Fault.t(), ...]}
The derived source a map form holds: through macaw_layers' gates
(Macaw.Layers.Form.gates/3: the depth and item limits, the version), read by its tag
table and keys, making no atom, its schema by Macaw.Definition.Schema.from_map/1, then
judged by Macaw.Data.Derived.new/1. limits: tightens the limits. {:ok, source}, or
every fault by path.
@spec from_map!(map(), keyword()) :: Macaw.Data.Derived.t()
As from_map/2, raising ArgumentError naming every fault.
@spec to_json(Macaw.Data.Derived.t()) :: {:ok, String.t()} | {:error, [Macaw.Base.Fault.t(), ...]}
The source's JSON form: to_map/1, stamped "$version" and encoded.
@spec to_map(Macaw.Data.Derived.t()) :: {:ok, map()} | {:error, [Macaw.Base.Fault.t(), ...]}
The source's map form, JSON-ready: {:ok, map}, or every value without a form, by path
(a window's time not in Etc/UTC is {:type, :term}). from_map(map) == {:ok, source}.