The editor of a plugin host step (PluginHosts.Step): Plugins.Camel.Editor
and Plugins.Command.Editor are LiveComponents that hand update/3,
handle_event/4 and render/2 here with their t/0, which names the
step (PluginHosts.Step) and its wording. It is mounted by the pipeline
editor once per step.
Host (<prefix>-host): a select of the kind's plugin hosts the tenant
may call (PluginHosts.names_for/2). Hosts are the installation's,
configured in the application environment of the kind's plugin
(c:PluginHosts.Kind.hosts_app/0, hosts); with
none configured a callout says so (<prefix>-no-hosts). A stored host
the list does not have (not configured, or not open to this tenant) is
shown as its name with a note (<prefix>-host-unknown); the step fails
unavailable when it runs. For a host on the list, under the select:
its protocol (<prefix>-protocol, PluginHosts.describe/2), a pill
saying whether its calls are recorded (<prefix>-recording, in words,
so colour is not the only signal) and what that means
(<prefix>-recording-note): over HTTP each call is an exchange of its
own; over the port there is no exchange, and only playing the step in
the preview saves the input and the answer (the step's record).
Operation (<prefix>-operation, labelled with the step's op_label,
"Route" for Camel; the setting is its op_key): when the chosen host is
running, a select of the operations its catalogue lists
(PluginHosts.catalogue/3), the chosen one's description under it
(<prefix>-operation-description); a stored operation the catalogue
does not list is kept and marked (<prefix>-operation-unknown). When
the host is not running, a text field and a note that the list is not
available (<prefix>-operation-offline). The catalogue is a call to
the host's pool, so it is read in update/2 and after a change, only
when the host differs from the one last read.
Written here (a step with definitions?, Camel): when the chosen host
takes written routes (PluginHosts.written_routes?/3), or the step holds
a document, a segmented control under the host (<prefix>-route-source,
buttons <prefix>-route-source-host and <prefix>-route-source-written)
says where the operation is. Written here puts a starter document in
definition (and main as the operation when none is named) and shows
it in a YAML editor: the proxy's YamlText hook (CodeMirror in the
lua_editor.js bundle, language camel_yaml), written out here as the
proxy's yaml_text_editor writes it, since a package cannot call that
component. Its element is <prefix>-definition (phx-update="ignore",
the stand-in textarea <prefix>-definition-source), its events
"written_routes_open" (answered with "written_routes:set", the
stored text) and "written_routes_change" {text}, stored as typed; a
document the pipeline editor replaces goes to it as "written_routes:set".
The save error is <prefix>-definition-error, which the hook puts on
the editor as aria-invalid and aria-describedby. The operation is
then a text field, the entry (<prefix>-operation, a suggest_input
offering the document's routes as the last check read them, noted by
<prefix>-operation-entry-note), and nothing of the host's catalogue
shows: no select, description, unknown or offline note. On the host
drops definition and keeps the operation.
Check (written here): the host checks the document without running
it (PluginHosts.Step.check/3, off the LiveView with start_async)
when the editor opens, and again whenever the document, the host, the
entry, the input rows' names and destinations or Send a body change;
read-only editors check too, as they only show. The findings the host
places on a line go to the editor as "written_routes:diagnostics";
<prefix>-definition-check (data-outcome checking, ok,
problems or unavailable) says how it went, errors and warnings
counted in words, and <prefix>-definition-findings lists the host's
findings, each with its word and line. What the entry route reads feeds
the listed inputs below, as a host route's catalogue entry does, so
those findings are not repeated in the list. A host that takes no
written routes or is not the tenant's shows no status. A document on a host that takes none is kept,
with a warning (<prefix>-definition-unavailable). Try calls the
written entry, and an error the host places in the document shows its
line and column (<prefix>-try-result-where).
Completion (written here): once the editor has opened, and when the
host changes, the host's vocabulary (PluginHosts.vocabulary/4, off the
LiveView) goes to the editor as "written_routes:schema", with the
tenant's variable and secret names (variables, names only) and the
input rows (inputs, {name, as}); a change of the rows alone goes as
"written_routes:schema" with merge: true and only inputs, and each
check's routes go the same way as routes. A fetch
first empties the schema (%{}), so a host that takes no written routes
or cannot answer (logged) leaves the editor without completion rather
than with the last host's. The databases behind the host's listed data
sources are read when the editor asks, "written_routes_describe"
%{"bean"} (the names of its tables, views and procedures) or with
"table" / "procedure" %{"schema", "name"} (one's columns or
parameters), each once per vocabulary (PluginHosts.describe/6, off the
LiveView); the answer goes as "written_routes:schema" with at, the
path in the schema to put value at (["databases", bean, "names"],
[…, "columns" | "parameters", "<schema>.<name>"]), and a failure
(logged) as %{"error" => message, "retry" => boolean} there: one
that may pass (a host not ready, a database busy, slow or unreachable)
may be asked again after 10 s, any other never in
this vocabulary.
Reload (<prefix>-reload), beside the operation's label when the
host is running and its entry allows it (PluginHosts.reloadable?/3)
but does not reload on its own; one that does (PluginHosts.auto_reload?/3)
shows Auto reload is on (<prefix>-auto-reload) instead, and the
editor reads its catalogue again on every update and event and when the
operation's select gets focus (refresh_catalogue). Reload
has the host read its operations again (PluginHosts.reload/3) off the
LiveView (start_async; the plugin's editor hands handle_async/4
here), then lists the operations it got back. <prefix>-reload-status
says how many it serves, or why it kept the old ones.
Listed inputs (<prefix>-listed): when the chosen operation's
catalogue entry has inputs (each a name, an as, optionally
required and description; a Camel host reads them from the route,
"inputs_from": "expressions"), they are listed under it, leaving out
what the step cannot send (a name it refuses; without destinations,
anything but a field). Each item (<prefix>-listed-<i>, its
data-status sent, body, elsewhere or missing) has an Add
button when missing (<prefix>-listed-<i>-add), which appends a row with
an empty value and, with destinations, its as; Add the n missing
(<prefix>-listed-add-all) shows with two or more. A row whose name the
list does not have, or has going elsewhere, is noted
(<prefix>-input-<n>-listed), the latter with a button that moves it
(<prefix>-input-<n>-listed-fix). The list is advice; save does not
read it.
Inputs (inputs): free rows, each a name
(<prefix>-input-<n>-name, checked with Plugin.Input.name?/1, a bad one
marked <prefix>-input-<n>-name-error but stored: save refuses it) and a
value template (<prefix>-input-<n>-value), with Leave out when
empty (<prefix>-input-<n>-omit) and a remove button
(<prefix>-input-<n>-remove); Add input is <prefix>-input-add. A
row stored with from (a place, set through the API) shows that place
as the value's placeholder and is kept until a value replaces it. For a
step with destinations (input_destinations?, Camel), each row has a
segmented control of where it goes (<prefix>-input-<n>-as, one button
<prefix>-input-<n>-as-<field|header|property>, stored as the row's
as), the default one marked when none is stored; with a body Field is
not offered, and ticking Send a body turns a stored Field into the
default, a header.
Send a body (<prefix>-send-body): ticked, the call carries a body
read from source, stored explicitly (ticking stores the side's whole
body, LocationPicker.default_body/2); unticked, source and
content_type go. While ticked, the LocationPicker of role source
(<prefix>-loc-source-…, in <prefix>-locations) and Content type
(<prefix>-content-type, content_type, dropped when empty), each with
its save error under it (<prefix>-loc-source-error,
<prefix>-content-type-error), and a note (<prefix>-body-note), a
warning callout when the chosen host does not serve HTTP
(PluginHosts.http?/3), so its call fails.
To (targets), the TargetList of the step's one output, body
(the operation's answer, PluginHosts.Step.outputs/0), as a Call step's.
Try (<prefix>-try, opened by <prefix>-try-toggle), when the
host is open to the tenant and lists the chosen operation: a sample per
named input row (<prefix>-try-<n>, the row's value when it holds no
template), a sample body (<prefix>-try-body) when the step sends one,
and Call (<prefix>-try-run), one real call off the LiveView
(PluginHosts.Step.try_call/5). <prefix>-try-result (data-outcome
ok or error) shows the body, the headers and the trace, or the
error, where it failed and the trace.
Every change keeps the settings it does not touch.
Assigns from the pipeline editor: id, prefix, node_key,
settings (with the step's side in direction), errors,
read_only, tenant_id, json_paths, name_hints, steps_before
and notify. The
settings go to the pipeline editor with
Plugin.Editor.notify_step_settings_changed/2.
Summary
Types
A plugin's editor: step, its PluginHosts.Step; intro, the sentence
under the Configuration toggle; op_label, the operation field's label
("Route"); op_choose, its select's empty choice ("Choose a route...");
op_placeholder, its text field's placeholder when the host is not
running.
Functions
The LiveComponent's handle_async/3: a Reload's, a Try's or a check's result.
The LiveComponent's handle_event/3.
The LiveComponent's render/1.
The LiveComponent's update/2.
Types
@type t() :: %Alternera.PluginHosts.StepEditor{ intro: String.t(), op_choose: String.t(), op_label: String.t(), op_placeholder: String.t(), step: Alternera.PluginHosts.Step.t() }
A plugin's editor: step, its PluginHosts.Step; intro, the sentence
under the Configuration toggle; op_label, the operation field's label
("Route"); op_choose, its select's empty choice ("Choose a route...");
op_placeholder, its text field's placeholder when the host is not
running.
Functions
The LiveComponent's handle_async/3: a Reload's, a Try's or a check's result.
The LiveComponent's handle_event/3.
The LiveComponent's render/1.
The LiveComponent's update/2.