What a step reads, writes and resolves, derived from its stored settings
by walking the plugin's settings_schema/0.
A schema field takes an optional role, which says what its value means to
the exchange:
:location: aPlugin.Locationthe step reads;:target: aPlugin.Locationthe step writes;:template: text with${…}the step resolves against the exchange (a value that is not text is not a template), or a map of name to such text, each value a template at[..., name]labelled"<template_label> <name>".secrecy(:secret, the default,:plain, or:upstream: secret in a request step, plain in a response or answer step, for a value that goes to the client there) is whattemplates/1answers for it and whatPlugin.Inputs.resolve/2allows: a:plaintemplate refuses a secret. In a list item it is labelled by the item (item_label) withlabel_suffixadded inexchange_templates/1; elsewhere bytemplate_label, and without one it is left out there (a body that may carry JavaScript's own${…});:targets: a To list (Plugin.Targets.schema_field/2), walked as a list whose rows'toare:targets, or, without the list, the settings' single"target"(the formPlugin.Targets.parse/3takes); acall/3plugin's outputs go through its rows (Plugin.CallAdapter).
A :list field whose item holds fields is walked item by item, and its
item_label names each item ("Set value" gives "Set value 2"). One
whose item is %{tag: key, variants: [%{value: v, fields: [...]}]} is
walked the same way, each item with the fields of the variant its key
names. A field
without a role, and a value that does not parse, adds nothing: init/1
refuses settings, the signature only describes them.
A directional plugin (use Alternera.Plugin, directional: true) has its
"direction" read too (Location.direction/1).
Every entry carries at, the settings path it came from (["values", 0, "from"]), which is what a rename would rewrite.
What a plugin adds
A plugin may define signature(settings, derived) (Alternera.Plugin.signature/2)
to add what its schema cannot say: reads, writes and templates. It gets
the derived signature and returns it with more added; extend/2 checks
that nothing derived went and that the direction stayed. Only there may a
write entry name a whole part, part_entry/1 (%{in: :request_headers, name: :any}, %{in: :vars, name: :any}), for a write whose place is
known only at run time (a header named by tenant data, a variable a
script names). A part entry is a declaration: strict inputs accept any
write of its kind, masking covers the part, and it is never a place a
step writes to. The schema derivation stays exact.
Three flags say what no entry can. reads_any: true is a step that may
read anything of the exchange, beyond the places its reads name: a
script whose text reaches the exchange as a whole (Script's req,
vars and steps tables). It reads the view itself
(Plugin.Inputs.view/1, refused to any other step), strict inputs
accept every read, and the step uses the exchange (exchange?/1). Such
a signature may still name the places it is known to read, a whole part
among them (part_entry/1), for what follows from its reads (the body
phase, follows?/1, keeps_request_body?/1); a body it reads it must
name, since the host hands a step only the bodies its signature reads or
writes, besides its phase's own (bodies/1). secret_references: true is a step that may reach a secret without a template the runner
resolves for it (a script naming tenant.secret): what it writes may
then hold a stamped reference, so the recording's masking scans the
parts it writes (secret_references?/1 of a call/3 plugin answers
it). tenant_vars: true is a step that reads the tenant's variables by
a name no template shows (a script's tenant.var(name)), so the runner
loads the tenant's variable scope for it, as it does for a step whose
templates name a variable; a plugin whose every step does says
tenant_vars: true to use Alternera.Plugin instead. Each is false
unless signature/2 sets it, and it may not clear one the derivation
set.
Summary
Functions
The bodies the step reads or writes, each once. A host hands the step
these in its view besides its phase's own, and no other
(Location.only_bodies/2): a reads_any step names each body it reads
as well, which strict inputs check (Plugin.Inputs).
The signature of settings under schema; directional? reads "direction".
Whether the step touches the exchange at all (one that reads_any does).
The labelled templates as exchange_templates/1 answers them.
Checks what a plugin's signature/2 returned against the derived
signature it was given: {:ok, signature}, or {:error, message} when it
is no signature, changes the direction, drops a derived entry, reads a
whole part without reads_any, clears a flag the derivation set, or
writes a part entry of a kind that has no named places.
Whether a head step must run after the body step before it: it reads a step
output or a variable, and either is neutral or writes only what an
Implementation's own steps make (Location.answer_write?/1).
Whether a response-side step reads the request's body, which must then be kept.
Whether it can run in either phase of its side: it touches the exchange
(exchange?/1), reads no body and writes only variables. A step that
writes nothing but reads (a call that only sends) is neutral; one that
touches nothing (Configuration) is not.
An entry for every place of kind (:query, :request_headers,
:response_headers or :vars; :steps as a read only), for a plugin's
own signature/2.
Whether entry names a whole part (part_entry/1).
The parts it writes (Provisional.Analysis.part/0), each once.
The bodies the step reads and writes only at a path: a host may hand it
such a body held in a file as the handle it is, unread, since every read
of it is a JSON path read, which Location.read/2 makes from the file,
and every write a JSON path write, which Location.write/3 makes over
the file without reading it whole (JsonDoc's pieces). A reads_any
step names none.
The bodies of path_only_bodies/1 the step never writes: a host may
hand it such a body held in a file even where it does not take back
what the step leaves in it (another phase's body in its view), since the
step only reads it.
The phase the step runs in: its side's body phase when it reads or writes that side's own body, else its side's head phase. A step that touches nothing (Configuration, a static Return) runs in its side's head phase too, so it runs at all.
The templates as templates/1 answers them.
Types
@type entry() :: %{ location: Alternera.Plugin.Location.t(), at: [String.t() | non_neg_integer()] }
@type template() :: %{ text: String.t(), at: [String.t() | non_neg_integer()], secrecy: :secret | :plain, label: String.t() | nil }
Functions
@spec bodies(t()) :: [:request_body | :response_body]
The bodies the step reads or writes, each once. A host hands the step
these in its view besides its phase's own, and no other
(Location.only_bodies/2): a reads_any step names each body it reads
as well, which strict inputs check (Plugin.Inputs).
The signature of settings under schema; directional? reads "direction".
Whether the step touches the exchange at all (one that reads_any does).
The labelled templates as exchange_templates/1 answers them.
Checks what a plugin's signature/2 returned against the derived
signature it was given: {:ok, signature}, or {:error, message} when it
is no signature, changes the direction, drops a derived entry, reads a
whole part without reads_any, clears a flag the derivation set, or
writes a part entry of a kind that has no named places.
Whether a head step must run after the body step before it: it reads a step
output or a variable, and either is neutral or writes only what an
Implementation's own steps make (Location.answer_write?/1).
Whether a response-side step reads the request's body, which must then be kept.
Whether it can run in either phase of its side: it touches the exchange
(exchange?/1), reads no body and writes only variables. A step that
writes nothing but reads (a call that only sends) is neutral; one that
touches nothing (Configuration) is not.
An entry for every place of kind (:query, :request_headers,
:response_headers or :vars; :steps as a read only), for a plugin's
own signature/2.
Whether entry names a whole part (part_entry/1).
The parts it writes (Provisional.Analysis.part/0), each once.
@spec path_only_bodies(t()) :: [:request_body | :response_body]
The bodies the step reads and writes only at a path: a host may hand it
such a body held in a file as the handle it is, unread, since every read
of it is a JSON path read, which Location.read/2 makes from the file,
and every write a JSON path write, which Location.write/3 makes over
the file without reading it whole (JsonDoc's pieces). A reads_any
step names none.
@spec path_read_bodies(t()) :: [:request_body | :response_body]
The bodies of path_only_bodies/1 the step never writes: a host may
hand it such a body held in a file even where it does not take back
what the step leaves in it (another phase's body in its view), since the
step only reads it.
@spec requirements(t()) :: [Alternera.Plugin.phase()]
The phase the step runs in: its side's body phase when it reads or writes that side's own body, else its side's head phase. A step that touches nothing (Configuration, a static Return) runs in its side's head phase too, so it runs at all.
The templates as templates/1 answers them.