# `Alternera.PluginHosts.Definition`
[🔗](https://github.com/10e-ab/alternera-camel/blob/v0.9.0/alternera_plugin_hosts/lib/alternera/plugin_hosts/definition.ex#L1)

A document of operations written in a step, not read from a host's files
(a Camel step's routes "written here"), and how it reaches the host's
members: by content, so the proxy keeps no member, restart or release in
step with what it holds.

Its identity is its hash: the tenant, the text and the values it reads,
so two tenants, two revisions and an unsaved draft are three documents,
and a changed value is a new one. A call names the hash; a member that
does not hold it answers `unknown_definition`, and the caller sends the
document in a `define` frame (`Host.define/3`) to that member and calls
again, once (`PluginHosts.Pool`, `PluginHosts.HttpCall`). A member that
restarted, or a reload that removed what it held, learns it on the next
call that needs it.

Only a kind that takes definitions (`c:PluginHosts.Kind.definitions?/0`)
and a host whose entry has `written_routes` accept one
(`PluginHosts.written_routes?/3`).

The values are the tenant variables the text references, each resolved
(`Plugin.Secret.values/4`), secrets included: they travel beside the
text, which is never substituted. The struct's `Inspect` leaves them out,
and `scrub/2` takes the secrets out of what the host says back. The hash
is keyed with the installation's fingerprint key
(`c:Alternera.Plugin.Host.fingerprint_key/0`), as a saved output's
fingerprint is: it names a definition in calls, route ids and recorded
headers, and a plain digest of a known text would let a short secret be
guessed from it.

# `t`

```elixir
@type t() :: %Alternera.PluginHosts.Definition{
  hash: String.t(),
  tenant: String.t(),
  text: String.t(),
  values: %{required(String.t()) =&gt; String.t()}
}
```

# `frame`

```elixir
@spec frame(t()) :: map()
```

The `define` frame's payload.

# `new`

```elixir
@spec new(String.t() | nil, String.t(), %{required(String.t()) =&gt; String.t()}) :: t()
```

The document `text` of `tenant`, reading `values` (a name, or
`secret.NAME`, to its text), with its hash: 32 lower-case hex digits of
the HMAC-SHA-256 of all three under the fingerprint key.

# `scrub`

```elixir
@spec scrub(term(), t() | nil) :: term()
```

`value` (text, or a map or list of it at any depth) with the
definition's secret values replaced by their references
(`Plugin.Secret.scrub/2`); nil passes.

# `unknown?`

Whether a call's error says the member does not hold the definition it named.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
