A2UIAgent.Express.SchemaHelper (A2UIAgent v0.1.1)

Copy Markdown View Source

What Express reads from a catalog: each component's properties in positional order, each function's parameters, and the facts about a property's schema that decide how an argument compiles.

A component's positional order is its own properties in the order its schema declares them, then the properties it inherits through allOf, leaving out id, component and catalogId. A component can take checks when it declares a property holding a list of CheckRules, or inherits one from a common type such as Checkable; an inherited check property comes last.

The helper reads the catalog document (A2UICore.Catalog.to_json/2, in the order it was read) with its local and peer references written inline, and resolves references to the common types against the common types of the protocol version it is built for.

Summary

Functions

Whether a property takes an action: its schema refers to the common Action type, directly or through allOf, oneOf or anyOf.

Whether a value written for schema may be a data binding: the schema, or one it reaches through $ref, allOf, oneOf or anyOf, is an object schema with a path or @path property.

The helpers for catalogs, in order, built for protocol version. The catalogs are first linked to each other (A2UICore.Catalog.link_catalogs/1), so that references between them resolve.

The property a component's checks go in, or nil if it takes none.

The name of the common type a $ref points to (common_types.json#/$defs/<Name>, also as an absolute URL or under definitions), or nil.

Whether the catalog defines component name.

A component's description, from its schema or the first allOf member that has one.

A component's properties in positional order.

The properties a component requires.

Whether the catalog defines function name.

A function's description, or nil.

A function's parameters in positional order.

The schema of a function parameter, or nil.

The parameters a function requires.

The helper for one catalog, built for protocol version.

Whether a property holds a list of option objects (items with label and value properties), so that plain strings are written as options.

The values a component property's schema enumerates, or nil.

The schema of a component property, or nil.

The keys that mark a data binding and a function call in version: @path and @call from v1.0, path and call before.

The schema at key below schema: the item schema for "items", else the schema of property key (or of any additional property), found through $ref, allOf, oneOf and anyOf. nil when the schema declares none.

Types

t()

(since 0.1.0)
@type t() :: %A2UIAgent.Express.SchemaHelper{
  catalog: A2UICore.Catalog.t(),
  catalog_id: String.t(),
  check_properties: %{optional(String.t()) => String.t()},
  common_defs: term(),
  component_names: [String.t()],
  component_properties: %{optional(String.t()) => [String.t()]},
  component_required: %{optional(String.t()) => [String.t()]},
  components: %{optional(String.t()) => term()},
  document: term(),
  function_names: [String.t()],
  function_properties: %{optional(String.t()) => [String.t()]},
  function_required: %{optional(String.t()) => [String.t()]},
  functions: %{optional(String.t()) => term()},
  inherited_check_schemas: %{optional(String.t()) => term()},
  keys: %{path: String.t(), call: String.t()},
  property_enums: %{optional({String.t(), String.t()}) => list()}
}

Functions

action_slot?(schema)

(since 0.1.0)
@spec action_slot?(term()) :: boolean()

Whether a property takes an action: its schema refers to the common Action type, directly or through allOf, oneOf or anyOf.

admits_path?(helper, schema)

(since 0.1.0)
@spec admits_path?(t(), term()) :: boolean()

Whether a value written for schema may be a data binding: the schema, or one it reaches through $ref, allOf, oneOf or anyOf, is an object schema with a path or @path property.

build_all(catalogs, version)

(since 0.1.0)
@spec build_all([A2UICore.Catalog.t()], String.t()) :: [t()]

The helpers for catalogs, in order, built for protocol version. The catalogs are first linked to each other (A2UICore.Catalog.link_catalogs/1), so that references between them resolve.

check_property(helper, name)

(since 0.1.0)
@spec check_property(t(), String.t()) :: String.t() | nil

The property a component's checks go in, or nil if it takes none.

common_def_name(ref)

(since 0.1.0)
@spec common_def_name(term()) :: String.t() | nil

The name of the common type a $ref points to (common_types.json#/$defs/<Name>, also as an absolute URL or under definitions), or nil.

iex> A2UIAgent.Express.SchemaHelper.common_def_name("common_types.json#/$defs/Action")
"Action"
iex> A2UIAgent.Express.SchemaHelper.common_def_name("#/$defs/Action")
nil

component?(schema_helper, name)

(since 0.1.0)
@spec component?(t(), String.t()) :: boolean()

Whether the catalog defines component name.

component_description(helper, name)

(since 0.1.0)
@spec component_description(t(), String.t()) :: String.t() | nil

A component's description, from its schema or the first allOf member that has one.

component_properties(helper, name)

(since 0.1.0)
@spec component_properties(t(), String.t()) :: [String.t()]

A component's properties in positional order.

component_required(helper, name)

(since 0.1.0)
@spec component_required(t(), String.t()) :: [String.t()]

The properties a component requires.

function?(schema_helper, name)

(since 0.1.0)
@spec function?(t(), String.t()) :: boolean()

Whether the catalog defines function name.

function_description(helper, name)

(since 0.1.0)
@spec function_description(t(), String.t()) :: String.t() | nil

A function's description, or nil.

function_properties(helper, name)

(since 0.1.0)
@spec function_properties(t(), String.t()) :: [String.t()]

A function's parameters in positional order.

function_property_schema(helper, function, property)

(since 0.1.0)
@spec function_property_schema(t(), String.t(), String.t()) :: term()

The schema of a function parameter, or nil.

function_required(helper, name)

(since 0.1.0)
@spec function_required(t(), String.t()) :: [String.t()]

The parameters a function requires.

new(catalog, version)

(since 0.1.0)
@spec new(A2UICore.Catalog.t(), String.t()) :: t()

The helper for one catalog, built for protocol version.

option_objects?(schema)

(since 0.1.0)
@spec option_objects?(term()) :: boolean()

Whether a property holds a list of option objects (items with label and value properties), so that plain strings are written as options.

property_enum(helper, component, property)

(since 0.1.0)
@spec property_enum(t(), String.t(), String.t()) :: list() | nil

The values a component property's schema enumerates, or nil.

property_schema(helper, component, property)

(since 0.1.0)
@spec property_schema(t(), String.t(), String.t()) :: term()

The schema of a component property, or nil.

reserved_keys(version)

(since 0.1.0)
@spec reserved_keys(String.t()) :: %{path: String.t(), call: String.t()}

The keys that mark a data binding and a function call in version: @path and @call from v1.0, path and call before.

subschema(helper, schema, key)

(since 0.1.0)
@spec subschema(t(), term(), String.t()) :: term()

The schema at key below schema: the item schema for "items", else the schema of property key (or of any additional property), found through $ref, allOf, oneOf and anyOf. nil when the schema declares none.