Lexgen.Lexicon (lexgen v1.0.0)

Stores information about a Lexicon source JSON file.

According to the AT Protocol Lexicon Specification:

  • A Lexicon is a JSON file.
  • Each Lexicon can have AT MOST one primary type.
  • Each record and some object types require the use of a special $type key. This should be the Lexicon's NSID.
  • References to the "main" definition of a Lexicon should always exclude the suffix (#main). While some scenarios accept using a suffix of #main, some scenarios do not, but all scenarios accept omitting the suffix for a "main" definition.

Summary

Functions

Parses a Lexicon JSON string into a Lexicon struct. Also accepts a JSON-decoded map.

Parses a single definition from a Lexicon JSON file.

Parses the defs object from a Lexicon JSON file. This assumes that defs in the Lexicon struct is an unmodified map from the decoded JSON source.

Splits an NSID into two components: the "namespace" and the "id".

Converts an NSID into a title-cased string.

Types

t()

@type t() :: %Lexgen.Lexicon{
  defs: [map()],
  id: binary(),
  id_title: binary(),
  ns: binary(),
  ns_title: binary(),
  nsid: binary(),
  nsid_title: binary()
}

Functions

constraint_keys(arg1)

parse(json)

Parses a Lexicon JSON string into a Lexicon struct. Also accepts a JSON-decoded map.

parse_def(lexicon, key, def)

Parses a single definition from a Lexicon JSON file.

parse_defs(lexicon)

Parses the defs object from a Lexicon JSON file. This assumes that defs in the Lexicon struct is an unmodified map from the decoded JSON source.

parse_output(lexicon, arg2)

split_nsid(nsid)

@spec split_nsid(binary()) :: {binary(), binary()}

Splits an NSID into two components: the "namespace" and the "id".

For example, app.bsky.feed.getFeed would split into app.bsky.feed and getFeed.

title_nsid(nsid)

@spec title_nsid(binary()) :: binary()

Converts an NSID into a title-cased string.

For example, app.bsky.feed.getFeed becomes App.Bsky.Feed.GetFeed.