Version adapter behaviour and the shared envelope-extraction pipeline.
Each protocol version implements the c:Adapter behaviour; the shared
extract/3 pipeline (a faithful port of the reference
BaseVersionAdapter.extract_operations) drives them:
- recursion/pointer preflight (
A2UICore.Validation.Integrity), - payload unwrapping —
nil/[]are no-ops, lists recurse per item (pre-checking the single-action rule for every item first), and{"messages": [...]}wrappers recurse into the list, - per-message checks, in this order:
exactly one action key (with the reference's two distinct error
messages), action payload must be an object,
surfaceIdmust be a string when present,versionpresence and compatibility, - schema validation against the version's vendored envelope
document — the message-type
$defsentry selected by the action key (mirroring the reference's discriminated dispatch) with the active catalog bound to thecatalog.jsonplaceholder, - operation construction via
extract_operations/2.
Summary
Types
Adapter options: :catalog binds the catalog schema the envelope's
catalog.json references resolve against — a catalog schema map, or
:permissive for a stand-in that accepts any component object, theme
and well-formed function call (the processor checks components against
the catalog each surface actually uses).
Functions
The version adapter behaviour. All callbacks are pure.
Extracts canonical operations from a raw payload using adapter.
Types
@type opts() :: keyword()
Adapter options: :catalog binds the catalog schema the envelope's
catalog.json references resolve against — a catalog schema map, or
:permissive for a stand-in that accepts any component object, theme
and well-formed function call (the processor checks components against
the catalog each surface actually uses).
Callbacks
Functions
The version adapter behaviour. All callbacks are pure.
@spec extract(module(), term(), opts()) :: {:ok, [A2UICore.Message.Operation.t()]} | {:error, A2UICore.Error.t()}
Extracts canonical operations from a raw payload using adapter.
Returns {:ok, operations} or {:error, error}.