Alternera. PluginWasmFramework. Uses
(alternera_plugin_wasm_framework v0.9.0)
Copy Markdown
View Source
The named parameters an uploaded module declares, and how a step's bindings turn them into the tenant's own stores, pipelines, variables and secrets.
A module declares what it reaches in one custom section,
alternera.uses, holding UTF-8 JSON:
{"stores": {"sessions": ["get", "put"]},
"pipelines": ["enrich"],
"variables": ["region"],
"secrets": ["api_key"]}Every key is optional. A store parameter names the operations the
module uses on it (get, put, update, delete, list); a
pipeline, variable or secret parameter is a name alone. A parameter
name is 1 to 64 characters of letters, digits, _, . and -.
The guest calls a host operation with its own parameter name
(store.get with ["sessions", key]); the step's settings bind each
parameter to a real name ("bindings", bindings/1), and the host
translates the call (translate/3) and refuses one the declaration
does not cover. The binding is the grant: a module reaches exactly the
stores, pipelines, variables and secrets its step names. log is
always allowed and is no parameter.
The declaration is read from the module's bytes when the module is
prepared and kept with the compiled module, so what is enforced is
bound to the digest that runs. A module with no section declares
nothing and may only log. Shipped languages have no declaration
(nil): their scripts call by real name.
Summary
Types
A step's bindings: for each kind, parameter name to real name.
A declaration: each store parameter with the operations used on it, and the pipeline, variable and secret parameters.
Functions
Reads a step's bindings setting: for each kind, a map of parameter
name to a real name. Nil is no bindings.
Checks bindings against a declaration: every declared parameter bound, none bound that is not declared. Answers the problems, each naming the parameter.
Whether the declaration names nothing.
The kinds, as the settings and the section name them.
A kind's label in a message (Store).
The declaration's parameters, kind by kind, each as {name, ops} (ops
nil for a kind with none): what the step editor lists.
Reads a module's declaration from its custom sections' contents (none, or exactly one): an empty declaration when there is none.
The section's name.
The declaration as the JSON-ready map a step's display keeps.
Translates a host call's arguments through the declaration and the
bindings: the parameter name in the first argument becomes the bound
name. log passes untouched; an operation outside the declaration is
refused with a message for the guest.
Types
A step's bindings: for each kind, parameter name to real name.
@type t() :: %Alternera.PluginWasmFramework.Uses{ pipelines: [String.t()], secrets: [String.t()], stores: %{required(String.t()) => [String.t()]}, variables: [String.t()] }
A declaration: each store parameter with the operations used on it, and the pipeline, variable and secret parameters.
Functions
Reads a step's bindings setting: for each kind, a map of parameter
name to a real name. Nil is no bindings.
Checks bindings against a declaration: every declared parameter bound, none bound that is not declared. Answers the problems, each naming the parameter.
Whether the declaration names nothing.
@spec kinds() :: [String.t()]
The kinds, as the settings and the section name them.
A kind's label in a message (Store).
The declaration's parameters, kind by kind, each as {name, ops} (ops
nil for a kind with none): what the step editor lists.
Reads a module's declaration from its custom sections' contents (none, or exactly one): an empty declaration when there is none.
@spec section() :: String.t()
The section's name.
The declaration as the JSON-ready map a step's display keeps.
@spec translate(String.t(), list(), {t(), bindings()}) :: {:ok, list()} | {:error, String.t(), String.t()}
Translates a host call's arguments through the declaration and the
bindings: the parameter name in the first argument becomes the bound
name. log passes untouched; an operation outside the declaration is
refused with a message for the guest.