Cite.Wire (Cite v0.1.0)

Copy Markdown View Source

Values to request maps.

The one place passages and compiled questions become the maps a client receives: atom keys become strings, and placeholders become backticked paths, built by text_path/1 and text_path/2. Past this edge a client sees string-keyed maps, lists, and scalars, and a Cite.Wire.Object wherever key order matters. Internal.

Summary

Functions

One passage on the wire: id, text, and the meta keys show names.

Passages on the wire as one object keyed by id, in source order, each with only the meta keys show names. A plain map would lose that order past 32 entries, and the model reads neighbours.

One compiled question on the wire. paths maps each placeholder name to its path in the request's state; a question with no placeholders in its text or focus compares the fallback paths.

The path to the text of the passage filling a role: household.text.

The path to a passage's text under the source's as: utterances.U014.text.

Functions

passage(passage, show)

@spec passage(Cite.Passage.t(), [atom() | String.t()]) :: map()

One passage on the wire: id, text, and the meta keys show names.

passages(passages, show)

@spec passages([Cite.Passage.t()], [atom() | String.t()]) :: Cite.Wire.Object.t()

Passages on the wire as one object keyed by id, in source order, each with only the meta keys show names. A plain map would lose that order past 32 entries, and the model reads neighbours.

question(question, paths, fallback)

@spec question(Cite.Policy.Question.t(), %{required(String.t()) => String.t()}, [
  String.t()
]) :: map()

One compiled question on the wire. paths maps each placeholder name to its path in the request's state; a question with no placeholders in its text or focus compares the fallback paths.

text_path(role)

@spec text_path(atom()) :: String.t()

The path to the text of the passage filling a role: household.text.

text_path(as, id)

@spec text_path(String.t(), String.t()) :: String.t()

The path to a passage's text under the source's as: utterances.U014.text.