Loads catalog documents into A2UICore.Catalogs.
{:ok, catalog} = A2UIAgent.CatalogProvider.load_file("priv/catalogs/basic.json")
{:ok, catalog} =
A2UIAgent.CatalogProvider.load_document(document,
catalog_id: "acme/forms",
protocol_version: "v1.0"
)Both functions take :catalog_id and :protocol_version. Each one
supplies what the document omits and must agree with what the document
states: a document that declares "catalogId": "a" read with
catalog_id: "b" is an error, since one of the two is wrong. When
neither the document nor the options name the catalog or its protocol
version, loading fails, because nothing else can.
Every failure is an A2UICore.Error of category :catalog.
Summary
Functions
Loads a catalog from a decoded catalog document: a map, or a
Jason.OrderedObject (decoded with objects: :ordered_objects) to
keep its key order.
Like load_document/2, raising A2UICore.Error on failure.
Reads a catalog document from a filesystem path or a file:// URL.
Like load_file/2, raising A2UICore.Error on failure.
Types
Functions
@spec load_document(term(), [option()]) :: {:ok, A2UICore.Catalog.t()} | {:error, A2UICore.Error.t()}
Loads a catalog from a decoded catalog document: a map, or a
Jason.OrderedObject (decoded with objects: :ordered_objects) to
keep its key order.
@spec load_document!(term(), [option()]) :: A2UICore.Catalog.t()
Like load_document/2, raising A2UICore.Error on failure.
@spec load_file(String.t(), [option()]) :: {:ok, A2UICore.Catalog.t()} | {:error, A2UICore.Error.t()}
Reads a catalog document from a filesystem path or a file:// URL.
The file must hold a JSON object. Its key order orders the catalog's
components and functions, and the document A2UICore.Catalog.to_json/2
writes.
@spec load_file!(String.t(), [option()]) :: A2UICore.Catalog.t()
Like load_file/2, raising A2UICore.Error on failure.