Alternera.Plugin.Editor.TemplateSuggestions (alternera_plugin_editor v0.9.0)

Copy Markdown View Source

The ${…} references a template field suggests (SuggestInput in "template" mode): the references Plugin.Template resolves that this step is known to have, each with a line saying what it reads.

base/1 is what the pipeline knows (name_hints, as LocationPicker takes them): the request facts, the pipeline's path template parameters (:path, ${path.<name>}), its own input parameters (:input, ${input.<name>}) and the fields a json one's schema declares (:input_fields, {"<name>.<field>", type}, ${input.<name>.<field>}), the variables its steps write (:vars, ${var.<name>}) and its declared context names (:context, ${context.<name>}), then the fields of the signed-in caller (${caller.<field>}, Plugin.Variables), offered everywhere since any pipeline may be reached by a caller who signed in (a proxy user at either door, a token at a reverse site) and each reads as nothing for one who did not. The fields of the error being handled (${error.<field>}) come only when name_hints has :error, which the pipeline editor puts there for a step inside a Try's catch or On error, where the error is set. steps/1 adds the outputs of the steps before this one (steps_before, %{id, outputs}), a keyed output's known keys each as a reference of its own. Names only, never values.

for_step/1 is what a step editor calls: the JSON for its template fields from its own name_hints and steps_before; for_cache_key/1 is the same for a cache's Key, narrowed to what a cache key reads.

Summary

Functions

The request facts and what name_hints names, as suggestion entries.

The default key as a cache Key field suggests it: the whole template, labelled as what it is, the method and the full URL an empty Key uses.

The line under a cache Key field saying what an empty Key uses.

A cache Key field's placeholder: an empty Key is not empty of meaning.

base and the steps' entries as the JSON SuggestInput reads, or nil when there are none; literals (literals/1) come first.

The error fields a step handling an error is told of, for name_hints' :error.

What a cache Key field suggests, as the JSON SuggestInput reads: first the whole default key as a literal (cache_key_default/0), then the references step_entries/1 gives that the key's grammar accepts (Provisional.ResponseCache.key_facts/0 and key_kinds/0; a key holding any other ${…} is refused on save), with the URL parts (${scheme}, ${host}, ${port}, ${query}) after ${path}, and last ${header.<name>} for the source exchange's request headers and the header catalogue's. ${body} is left out: a Key is read on the request head.

The ${…} references a step editor's template fields offer, as the JSON SuggestInput reads: step_entries/1 of its assigns. literals come first (json/2).

entries as the JSON SuggestInput reads, nil when there are none, after literals: whole values the field may hold as they are (a header's typical values, %{value, description}), marked literal: true.

The constants a field of a parameter of type suggests before the references, each written as it is (literal: true): true and false for a boolean, none for another type.

base/1 of a step editor's name_hints and the outputs of its steps_before, both props of the editor contract: worked out once in a render and shared by its fields through json/2.

The outputs of the steps before, as suggestion entries.

Types

entry()

@type entry() :: %{value: String.t(), label: String.t(), description: String.t()}

Functions

base(name_hints)

@spec base(map() | nil) :: [entry()]

The request facts and what name_hints names, as suggestion entries.

cache_key_default()

@spec cache_key_default() :: map()

The default key as a cache Key field suggests it: the whole template, labelled as what it is, the method and the full URL an empty Key uses.

cache_key_hint()

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

The line under a cache Key field saying what an empty Key uses.

cache_key_placeholder()

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

A cache Key field's placeholder: an empty Key is not empty of meaning.

encode(base, steps_before, literals \\ [])

@spec encode([entry()] | nil, [map()] | nil, [map()]) :: String.t() | nil

base and the steps' entries as the JSON SuggestInput reads, or nil when there are none; literals (literals/1) come first.

error_hints()

@spec error_hints() :: [{String.t(), nil}]

The error fields a step handling an error is told of, for name_hints' :error.

for_cache_key(assigns)

@spec for_cache_key(map()) :: String.t()

What a cache Key field suggests, as the JSON SuggestInput reads: first the whole default key as a literal (cache_key_default/0), then the references step_entries/1 gives that the key's grammar accepts (Provisional.ResponseCache.key_facts/0 and key_kinds/0; a key holding any other ${…} is refused on save), with the URL parts (${scheme}, ${host}, ${port}, ${query}) after ${path}, and last ${header.<name>} for the source exchange's request headers and the header catalogue's. ${body} is left out: a Key is read on the request head.

for_step(assigns, literals \\ [])

@spec for_step(map(), [map()] | nil) :: String.t() | nil

The ${…} references a step editor's template fields offer, as the JSON SuggestInput reads: step_entries/1 of its assigns. literals come first (json/2).

json(literals, entries)

@spec json([map()] | nil, [entry()]) :: String.t() | nil

entries as the JSON SuggestInput reads, nil when there are none, after literals: whole values the field may hold as they are (a header's typical values, %{value, description}), marked literal: true.

literals(arg1)

@spec literals(String.t() | nil) :: [map()]

The constants a field of a parameter of type suggests before the references, each written as it is (literal: true): true and false for a boolean, none for another type.

step_entries(assigns)

@spec step_entries(map()) :: [entry()]

base/1 of a step editor's name_hints and the outputs of its steps_before, both props of the editor contract: worked out once in a render and shared by its fields through json/2.

steps(steps_before)

@spec steps([map()] | nil) :: [entry()]

The outputs of the steps before, as suggestion entries.