Alternera.Plugin.Provisional.Editing behaviour (alternera_plugin_sdk v0.9.0)

Copy Markdown View Source

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.

What a plugin tells the pipeline editor about its steps, beyond its own step editor. Every callback is optional. A plugin that exports none starts with empty settings, has no starter, and its steps get the editor's plain treatment.

Summary

Types

The side of the exchange a step works on.

A step's starter: :settings, string keys, are merged into the step's settings, and :source is the text they hold, which the step editor gets back as its starter prop, to tell a generated source from an edited one.

Callbacks

Whether a step chooses between streaming and holding its body. The pipeline editor then always cues which it does, even on a side that nothing streams.

Whether the plugin's step editor draws a Configuration toggle (Alternera.Plugin.Editor.section_toggle/1), so that a section's ⋮ menu offers to fold it.

The settings a step of this plugin starts with when added on side.

The starter of a step on side whose input is body, or :error when there is nothing to build one from. mode is what the plugin's own editor passed to Alternera.Plugin.Editor.request_step_input/3, :full_body for a step just added.

Types

side()

@type side() :: :request | :response

The side of the exchange a step works on.

starter()

@type starter() :: %{settings: map(), source: String.t()}

A step's starter: :settings, string keys, are merged into the step's settings, and :source is the text they hold, which the step editor gets back as its starter prop, to tell a generated source from an edited one.

Callbacks

chooses_streaming?()

(optional)
@callback chooses_streaming?() :: boolean()

Whether a step chooses between streaming and holding its body. The pipeline editor then always cues which it does, even on a side that nothing streams.

configuration_toggle?()

(optional)
@callback configuration_toggle?() :: boolean()

Whether the plugin's step editor draws a Configuration toggle (Alternera.Plugin.Editor.section_toggle/1), so that a section's ⋮ menu offers to fold it.

initial_settings(side)

(optional)
@callback initial_settings(side()) :: map()

The settings a step of this plugin starts with when added on side.

starter(body, side, mode)

(optional)
@callback starter(body :: binary() | nil, side(), mode :: atom()) ::
  {:ok, starter()} | :error

The starter of a step on side whose input is body, or :error when there is nothing to build one from. mode is what the plugin's own editor passed to Alternera.Plugin.Editor.request_step_input/3, :full_body for a step just added.

A plugin that exports this has its step's input offered to its editor (the step_input? prop), and a step just added gets its starter in place of the initial settings when there is a body.