# alternera_plugin_sdk v0.9.0 - Table of Contents > The contract an Alternera pipeline plugin implements: the Alternera.Plugin behaviour, the step modules under it, and a test kit that needs no proxy. ## Pages - [alternera_plugin_sdk](readme.md) ## Modules - [Alternera.Plugin](Alternera.Plugin.md): The contract every plugin implements. A plugin is a capability a pipeline step can use; the step carries the plugin's id and its settings. - [Alternera.Plugin.Application](Alternera.Plugin.Application.md): The SDK's own processes, started with the `:alternera_plugin_sdk` application, so the proxy and a package's tests get them alike: the collector of the steps' memory peaks (`Plugin.Provisional.HeapPeak.Collector`). - [Alternera.Plugin.Body](Alternera.Plugin.Body.md): A body a pipeline holds, as the codecs hand it to the steps: in memory (`{:inline, binary}`) or spooled to a file in the body storage directory (`{:file, path, size}`, `Proxy.BodySpool`). - [Alternera.Plugin.BodyFilter](Alternera.Plugin.BodyFilter.md): A streaming step's filter: the module a `call/3` plugin declared with `use Alternera.Plugin, streams: true` names when its `call/3` answers `{:stream, first, {module, state}, writes}`. - [Alternera.Plugin.BodyObserver](Alternera.Plugin.BodyObserver.md): What sees a response body as it leaves, read-only: the module a holding step's `leave/3` names in `{:observe_body, {module, state}, summary}` at its Close (`Plugin.CallAdapter`). - [Alternera.Plugin.CallAdapter](Alternera.Plugin.CallAdapter.md): The plugin model: one callback, `call(inputs, opts, context)`, inputs in and writes out, and `leave/3` for a plugin whose step holds something for the rest of the exchange; and what a host asks of a plugin. The host runs a step through `run/6`, which calls `head/5` or `body/5`, gives back what a step held through `release/4`, and runs a streaming step through `stream_init/3`, `stream_chunk/2`, `stream_finish/1` and `stream_abort/2`; their results are the runner's own vocabulary (`{:cont, message, extras}` for a head, `{:ok, body, summary[, extras]}` for a body, a hold, `{:skip_to_after, …}`, `{:answer_below_close, …}`). - [Alternera.Plugin.Error](Alternera.Plugin.Error.md): What a plugin needs to know about a step's failure before it raises one: the rule for an error type and the cap on a failed call's response body. The error itself, with the pipeline's own types and what the runner records, is `Pipelines.Runner.Error`, which takes both from here. - [Alternera.Plugin.HeaderCatalogue](Alternera.Plugin.HeaderCatalogue.md): The HTTP headers an editor suggests when nothing was recorded: the common request and response header names, each with a line saying what it is, and the values typically written into each. - [Alternera.Plugin.Host](Alternera.Plugin.Host.md): What the plugin SDK asks of the application around it. Resolving a template needs two things only the running pipelines know: the tenant's variables and the methods the tenant's pipelines allow for a request. Reading a body needs the application's in-memory limit, and work on a body loaded whole a claim on the application's memory. A call out of the proxy (`Plugin.Provisional.Outbound`) goes through the application's forward side, and a saved output's fingerprint (`Plugin.Provisional.SavedOutput`) is keyed with the application's secret. A rate (`Plugin.Provisional.Rate`) is counted by the application's counter, and a stamped secret reference is shown unstamped by the application's rule (`Outbound.unstamp/1`). A response cache step's lookup, single flight and fill (`Plugin.Provisional.ResponseCache`) are the application's response cache. The credentials a request is sent with (`Plugin.Provisional.Credentials`) and the signed-in caller an upstream is told of (`Plugin.Provisional.Identity`) are the application's. A step's settings checked against the flow (`Plugin.Provisional.Checks`) are checked with the application's own conditions and cache vocabulary. A file a user uploads into a step (`Plugin.Provisional.Files`) is kept in the application's storage. A map is written as YAML (`write_yaml/1`) by the application's writer. A resource record is read by its lookup key (`resource_get/3`) and a resource's action is run (`resource_run/5`), both optional callbacks, by the application's resources. The SDK asks through this behaviour, so it names no module of the application. The application names the implementation under `:host` - [Alternera.Plugin.Input](Alternera.Plugin.Input.md): An input of the call a pipeline runs in, as a step reads it: the rule for its name and its value at a path. `Plugin.Provisional.Inputs` parses and resolves the inputs a step passes. - [Alternera.Plugin.Inputs](Alternera.Plugin.Inputs.md): What a `call/3` step may read. - [Alternera.Plugin.JsonArrayStream](Alternera.Plugin.JsonArrayStream.md): Splits a top-level JSON array that arrives in pieces into its elements' text, so a step can work on a large array an element at a time: the Map plugin's `each` over the root and a Script's `each(record)` stream through it. Pieces may be cut anywhere, inside a string or an escape included. - [Alternera.Plugin.JsonDoc](Alternera.Plugin.JsonDoc.md): A JSON text read through its index (`Plugin.JsonIndex`) instead of decoded whole: a body in memory, or a body spooled to a file (`Plugin.Body`), which is then read by position and never loaded. - [Alternera.Plugin.JsonIndex](Alternera.Plugin.JsonIndex.md): A sparse index of a JSON text: where its large values start and end, so a reader can find a value without decoding the text (`Plugin.JsonDoc`). - [Alternera.Plugin.JsonPath](Alternera.Plugin.JsonPath.md): The JSON paths and literals the body plugins share (`Plugins.Transform`, `Plugins.Map`, `Plugin.Location`). - [Alternera.Plugin.Location](Alternera.Plugin.Location.md): The places of an exchange a pipeline step reads from (its source) and writes to (its target), shared by every plugin that has one, so each addresses, validates, describes, reads and writes them the same way. - [Alternera.Plugin.MediaType](Alternera.Plugin.MediaType.md): What kind of body a `Content-Type` names: JSON (`application/json`, `text/json`, any `+json` type), XML (`application/xml`, `text/xml`, any `+xml` type) or neither. - [Alternera.Plugin.MigrationGuides](Alternera.Plugin.MigrationGuides.md): Reads a migration guides file: the Markdown a plugin declares with `use Alternera.Plugin, migration_guides: "…"`, and the proxy's own shipped guides, in one format. - [Alternera.Plugin.Provisional.Analysis](Alternera.Plugin.Provisional.Analysis.md): Provisional: added for Script, and a change to it needs a changelog line but no new major (`docs/USER_PLUGINS_DESIGN.md`). The namespace has nothing to do with the context's `:provisional?` key. - [Alternera.Plugin.Provisional.Cache](Alternera.Plugin.Provisional.Cache.md): Provisional: added for Validate, and a change to it needs a changelog line but no new major (`docs/USER_PLUGINS_DESIGN.md`). The namespace has nothing to do with the context's `:provisional?` key. - [Alternera.Plugin.Provisional.Calls](Alternera.Plugin.Provisional.Calls.md): Provisional: added for Script, and a change to it needs a changelog line but no new major (`docs/USER_PLUGINS_DESIGN.md`). The namespace has nothing to do with the context's `:provisional?` key. - [Alternera.Plugin.Provisional.Checks](Alternera.Plugin.Provisional.Checks.md): Provisional: added for the Response cache, and a change to it needs a changelog line but no new major (`docs/USER_PLUGINS_DESIGN.md`). - [Alternera.Plugin.Provisional.ChildEnv](Alternera.Plugin.Provisional.ChildEnv.md): The environment a plugin gives an OS process it starts. - [Alternera.Plugin.Provisional.Credentials](Alternera.Plugin.Provisional.Credentials.md): Provisional: added for Authorize, and a change to it needs a changelog line but no new major (`docs/USER_PLUGINS_DESIGN.md`). - [Alternera.Plugin.Provisional.Editing](Alternera.Plugin.Provisional.Editing.md): Provisional: added for Script, and a change to it needs a changelog line but no new major (`docs/USER_PLUGINS_DESIGN.md`). The namespace has nothing to do with the context's `:provisional?` key. - [Alternera.Plugin.Provisional.Files](Alternera.Plugin.Provisional.Files.md): Provisional: added for the WebAssembly module plugin, the first plugin that keeps a file a user uploads into a step, and kept here until a second plugin uses it. - [Alternera.Plugin.Provisional.HeapPeak](Alternera.Plugin.Provisional.HeapPeak.md): Provisional: added for the runner and Script, and a change to it needs a changelog line but no new major (`docs/USER_PLUGINS_DESIGN.md`). - [Alternera.Plugin.Provisional.HeapPeak.Collector](Alternera.Plugin.Provisional.HeapPeak.Collector.md): The one process the node's metered steps report their garbage collections to (`Plugin.Provisional.HeapPeak`). It owns one trace session for as long as it lives and is that session's tracer: putting a process under a meter turns the session's `:garbage_collection` trace on for that process, and stopping the meter turns it off, each a few microseconds. A session per meter cost about 15 ms a step to take down (`:trace.session_destroy/1`, measured with 5,300 modules loaded). - [Alternera.Plugin.Provisional.Hold](Alternera.Plugin.Provisional.Hold.md): Provisional: added for the Throttle and Circuit breaker steps, and a change to it needs a changelog line but no new major (`docs/USER_PLUGINS_DESIGN.md`). - [Alternera.Plugin.Provisional.Identity](Alternera.Plugin.Provisional.Identity.md): Provisional: added for Assert caller, and a change to it needs a changelog line but no new major (`docs/USER_PLUGINS_DESIGN.md`). - [Alternera.Plugin.Provisional.Inputs](Alternera.Plugin.Provisional.Inputs.md): Provisional: moved here from the Call step for plugins that pass inputs on, and a change to it needs a changelog line but no new major (`docs/USER_PLUGINS_DESIGN.md`). The namespace has nothing to do with the context's `:provisional?` key. - [Alternera.Plugin.Provisional.JsonSchema](Alternera.Plugin.Provisional.JsonSchema.md): Provisional: added for Validate JSON and the proxy's `json_schema` test assertions, so that every JSON Schema check reads a schema the same way, reports a mismatch the same way and compiles a schema once. A change to it needs a changelog line but no new major (`docs/USER_PLUGINS_DESIGN.md`). - [Alternera.Plugin.Provisional.JsonSchema.AnyFormat](Alternera.Plugin.Provisional.JsonSchema.AnyFormat.md): The last of `Provisional.JsonSchema`'s format validators: it claims every `format` the ones before it do not know and checks nothing, so an unknown format is ignored, as `JsonXema` ignored it, instead of refusing the schema (`JSV` refuses a format no validator claims). - [Alternera.Plugin.Provisional.Outbound](Alternera.Plugin.Provisional.Outbound.md): Provisional: added for plugins that run processes of their own, and a change to it needs a changelog line but no new major (`docs/USER_PLUGINS_DESIGN.md`). The namespace has nothing to do with the context's `:provisional?` key. - [Alternera.Plugin.Provisional.Rate](Alternera.Plugin.Provisional.Rate.md): Provisional: added for Rate limit, and a change to it needs a changelog line but no new major (`docs/USER_PLUGINS_DESIGN.md`). - [Alternera.Plugin.Provisional.Reads](Alternera.Plugin.Provisional.Reads.md): Provisional: added for Script, and a change to it needs a changelog line but no new major (`docs/USER_PLUGINS_DESIGN.md`). The namespace has nothing to do with the context's `:provisional?` key. - [Alternera.Plugin.Provisional.Reductions](Alternera.Plugin.Provisional.Reductions.md): Provisional: added for Script, and a change to it needs a changelog line but no new major (`docs/USER_PLUGINS_DESIGN.md`). The namespace has nothing to do with the context's `:provisional?` key. - [Alternera.Plugin.Provisional.ResponseCache](Alternera.Plugin.Provisional.ResponseCache.md): Provisional: added for the Response cache step, and a change to it needs a changelog line but no new major (`docs/USER_PLUGINS_DESIGN.md`). - [Alternera.Plugin.Provisional.SavedOutput](Alternera.Plugin.Provisional.SavedOutput.md): Provisional: moved here from the Request step for plugins that reach outside the proxy, and a change to it needs a changelog line but no new major (`docs/USER_PLUGINS_DESIGN.md`). The namespace has nothing to do with the context's `:provisional?` key. - [Alternera.Plugin.Provisional.SecretReads](Alternera.Plugin.Provisional.SecretReads.md): Provisional: added for the Script step, and a change to it needs a changelog line but no new major (`docs/USER_PLUGINS_DESIGN.md`). - [Alternera.Plugin.Provisional.Source](Alternera.Plugin.Provisional.Source.md): Provisional: added for consuming queues from a pipeline trigger, and a change to it needs a changelog line but no new major (`docs/USER_PLUGINS_DESIGN.md`). - [Alternera.Plugin.Provisional.StepHeap](Alternera.Plugin.Provisional.StepHeap.md): The heap a step's process may reach while it holds a body. The runner limits a plugin's body phase with it when the body is past the inline threshold, and `Plugins.Script.Sandbox` limits every Script run, which is why a body-sized limit has a floor: a small body still gets room for the script's own work. - [Alternera.Plugin.Provisional.Store](Alternera.Plugin.Provisional.Store.md): Provisional: added for Script, and a change to it needs a changelog line but no new major (`docs/USER_PLUGINS_DESIGN.md`). The namespace has nothing to do with the context's `:provisional?` key. - [Alternera.Plugin.Provisional.Tools](Alternera.Plugin.Provisional.Tools.md): Provisional: added for the Camel step's written routes, and a change to it needs a changelog line but no new major (`docs/USER_PLUGINS_DESIGN.md`). The namespace has nothing to do with the context's `:provisional?` key. - [Alternera.Plugin.Provisional.Upstream](Alternera.Plugin.Provisional.Upstream.md): Provisional: added for plugins that run processes of their own, and a change to it needs a changelog line but no new major (`docs/USER_PLUGINS_DESIGN.md`). The namespace has nothing to do with the context's `:provisional?` key. - [Alternera.Plugin.Recipes](Alternera.Plugin.Recipes.md): Reads a recipes file: the Markdown a plugin declares with `use Alternera.Plugin, recipes: "…"`, and the proxy's own recipe files, in one format. - [Alternera.Plugin.RowError](Alternera.Plugin.RowError.md): Reads back a save error about one row of a list in a step's settings, for an editor that shows it at that row. - [Alternera.Plugin.Secret](Alternera.Plugin.Secret.md): A tenant secret's value, for the step that must use it in-process: an HMAC or JWT signing key, a password a native driver takes. Every other step leaves `{{secret.NAME}}` as written and the proxy puts the value in where the request leaves it (`Plugin.Template`). - [Alternera.Plugin.Signature](Alternera.Plugin.Signature.md): What a step reads, writes and resolves, derived from its stored settings by walking the plugin's `settings_schema/0`. - [Alternera.Plugin.StepOutputs](Alternera.Plugin.StepOutputs.md): The values a step leaves in the exchange under its id, for later steps of the same pipeline to read (spec 056 S2): a Request's `body`, `status` and `headers`, a Script's returned `body` and its named `outputs`, a Transform's or a Map's `body`, a Validate's `valid` and `errors`, a pivot's returned `status` and `headers`. - [Alternera.Plugin.Targets](Alternera.Plugin.Targets.md): A step's To list: which of the values its plugin registers (`Alternera.Plugin`'s `outputs/0`) go where. - [Alternera.Plugin.Template](Alternera.Plugin.Template.md): Resolves a template a step's settings hold (a Respond body or header, a Fail message) against the exchange view (`Plugin.Location.view/0`), the way a Rewrite value is resolved (`Plugin.Variables.resolve/2`): `${var.}` from the view's variables (`${var..}` a value inside one), `${error.}` from the error a catch or On error handles, `${steps..}` from the view's step outputs (`Plugin.StepOutputs`, with an optional key or path after it), `${input.}` from the inputs of the call the pipeline runs in (`Pipelines.CallInputs`), and the request's `${method}`, `${path}`, `${client_ip}`, `${request_id}` and `${timestamp}`, a value of the pipeline's path template, `${path.}` (`Pipelines.PathParams`), and `${allowed_methods}` (`Pipelines.AllowedMethods`); and the tenant's variables, `{{NAME}}` and `{{secret.NAME}}`, from the view's `tenant_vars` (`Pipelines.TenantVars`), which the runner puts on the view of a step that references one. - [Alternera.Plugin.Test](Alternera.Plugin.Test.md): What a plugin's own tests build on, with no proxy around: a well-formed context, a way to run a step's `call/3` in a phase the way the runner does (through `Plugin.CallAdapter`), and the checks of the contract as plain predicates, so they work under any test framework. `Alternera.Plugin.Test.Contract` turns the predicates into ExUnit tests. - [Alternera.Plugin.Test.Contract](Alternera.Plugin.Test.Contract.md): The contract of `Alternera.Plugin` as ExUnit tests, for a plugin's own suite. `plugin_contract/2` writes a `describe` block of tests over the predicates of `Alternera.Plugin.Test`, so a plugin in another Mix project is checked the way the proxy checks its built-in ones - [Alternera.Plugin.Test.Host](Alternera.Plugin.Test.Host.md): A `Alternera.Plugin.Host` for a plugin's own project, where there is no proxy to ask. It is the SDK's default, so a plugin's tests need no setup; the proxy names its own host in its config, which replaces it. - [Alternera.Plugin.Test.MemorySource](Alternera.Plugin.Test.MemorySource.md): A message source (`Alternera.Plugin.Provisional.Source`) over a queue held in memory, for tests of the code that consumes a source, with no broker around. - [Alternera.Plugin.Test.ResponseCacheFill](Alternera.Plugin.Test.ResponseCacheFill.md): The test host's response-cache fill (`Alternera.Plugin.Test.Host`): a `Plugin.BodyObserver` that gathers the body and keeps the response in the calling process when it ends cleanly, and keeps nothing on an abort. - [Alternera.Plugin.ValueType](Alternera.Plugin.ValueType.md): The value types a declared parameter or context entry can have: `text`, `number`, `boolean` and `json`. - [Alternera.Plugin.Variables](Alternera.Plugin.Variables.md): The template language of a step's settings: `${…}` placeholders and tenant variable references resolved against the data of an exchange, and the request facts they read. What only the running pipelines know comes through `Plugin.Host`. - Exceptions - [Alternera.Plugin.UnresolvedVariableError](Alternera.Plugin.UnresolvedVariableError.md): Raised when a step's `{{NAME}}` or `{{secret.NAME}}` reference has no value (`Pipelines.TenantVars.resolve!/3`). The runner turns it into the step's failure with error type `unresolved_variable` (`Pipelines.Runner`, around every `call/3`), so a plugin that resolves deep inside its own code (a header rewrite, a template) needs no error path of its own. The message names the reference, never a value.