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

Copy Markdown View Source

Provisional: added for the Response cache, and a change to it needs a changelog line but no new major (docs/USER_PLUGINS_DESIGN.md).

A step's settings checked where the step stands, on a save. init/1 sees the settings alone; a plugin whose settings name things only the pipeline knows (the side a condition is read on, the proxy's cache vocabulary) exports flow_errors/2, which the proxy's flow check calls with the whole stored step and its place, after its own checks of where the step may stand have passed. The messages it answers are the step's, prefixed with its label by the proxy.

The checks it needs of the proxy go through Alternera.Plugin.Host:

On the SDK's test host (Alternera.Plugin.Test.Host), as in a plugin's own tests, the conditions are checked for their shape only and the cache settings not at all.

Summary

Types

Where the step stands: its section and the side it runs on (:request, :response, :implementation for an Implementation's own steps, or :on_error).

Callbacks

What is wrong with step (the stored step, string keys: "settings", "id", "on_error"…) at place, as messages; [] when nothing is.

Functions

Whether a cache key template reads the request body.

What is wrong with a cache's settings (string keys), as a cache container's are checked.

What is wrong with conditions read on side (:request or :response), one message per wrong condition, "condition <n>: …" (1-based).

Types

place()

@type place() :: %{
  section: :before | :implementation | :after | :on_error,
  side: atom()
}

Where the step stands: its section and the side it runs on (:request, :response, :implementation for an Implementation's own steps, or :on_error).

Callbacks

flow_errors(step, place)

@callback flow_errors(step :: map(), place()) :: [String.t()]

What is wrong with step (the stored step, string keys: "settings", "id", "on_error"…) at place, as messages; [] when nothing is.

Functions

cache_key_reads_body?(key)

@spec cache_key_reads_body?(term()) :: boolean()

Whether a cache key template reads the request body.

cache_settings_errors(settings)

@spec cache_settings_errors(map()) :: [String.t()]

What is wrong with a cache's settings (string keys), as a cache container's are checked.

condition_errors(conditions, side)

@spec condition_errors(term(), :request | :response) :: [String.t()]

What is wrong with conditions read on side (:request or :response), one message per wrong condition, "condition <n>: …" (1-based).