A2UICore.Catalog.Document (A2UICore v0.1.1)

Copy Markdown View Source

Reads a catalog document into the parts of an A2UICore.Catalog (parse/2) and writes those parts back as a document (build/1), so that build(parse(document)) equals document, apart from the components and functions that $defs.anyComponent / $defs.anyFunction leave out.

Each component and function keeps its definition as written; the top-level fields ($schema, $id, title, description, protocolVersion, instructions, the theme and where it sits, the form of functions, the unions, unknown keys) are kept beside them.

A document read as a Jason.OrderedObject is kept too, and the document written back follows its key order.

Summary

Functions

Writes a catalog's parts back as its document (A2UICore.Catalog.to_json/2), as ordered objects: the top-level fields in a fixed order ($schema, $id, protocolVersion, title, description, catalogId, instructions, unknown keys, components, functions, the theme, $defs), and what was read from a document in that document's order.

Reads a catalog document (a map, or a Jason.OrderedObject decoded with objects: :ordered_objects, whose key order then orders the components and functions). Options: :catalog_id, :protocol_version.

Converts Jason.OrderedObjects in term to maps.

Functions

build(catalog)

(since 0.1.0)

Writes a catalog's parts back as its document (A2UICore.Catalog.to_json/2), as ordered objects: the top-level fields in a fixed order ($schema, $id, protocolVersion, title, description, catalogId, instructions, unknown keys, components, functions, the theme, $defs), and what was read from a document in that document's order.

parse(document, options)

(since 0.1.0)
@spec parse(map() | Jason.OrderedObject.t(), keyword()) ::
  {:ok, map()} | {:error, A2UICore.Error.t()}

Reads a catalog document (a map, or a Jason.OrderedObject decoded with objects: :ordered_objects, whose key order then orders the components and functions). Options: :catalog_id, :protocol_version.

to_plain(term)

(since 0.1.0)
@spec to_plain(term()) :: term()

Converts Jason.OrderedObjects in term to maps.