ProtoRune.Lexicon (proto_rune v0.1.2)

Type definitions for the Intermediate Representation (IR) of AT Protocol Lexicons. This structure serves as a bridge between raw lexicon JSON and generated Elixir code.

Summary

Types

array_type()

@type array_type() ::
  {:array, type: field_type(), constraints: [{:max_length, pos_integer()}]}

definition()

@type definition() :: record() | object() | query() | procedure() | subscription()

definition_type()

@type definition_type() :: :record | :object | :query | :procedure

error()

@type error() :: %{name: String.t(), description: String.t() | nil}

field()

@type field() ::
  {name :: String.t(), type :: field_type(), description :: String.t() | nil}

field_type()

@type field_type() ::
  primitive_type() | array_type() | union_type() | reference_type()

io()

@type io() :: %{
  encoding: String.t(),
  description: String.t() | nil,
  schema: object() | reference_type() | union_type()
}

key_type()

@type key_type() :: :tid | :literal | :nsid | :any

module_path()

@type module_path() :: [String.t()]

number_constraints()

@type number_constraints() :: [minimum: number(), maximum: number()]

object()

@type object() :: %{
  type: :object,
  fields: [field()],
  required: [String.t()],
  description: String.t() | nil
}

parameters()

@type parameters() :: %{type: :params, required: [String.t()], props: [field()]}

primitive_type()

@type primitive_type() ::
  {:string, string_constraints()}
  | {:integer, number_constraints()}
  | {:boolean, []}
  | {:datetime, []}

procedure()

@type procedure() :: %{
  parameters: parameters() | nil,
  output: io() | nil,
  input: io() | nil,
  errors: [error()]
}

query()

@type query() :: %{
  parameters: parameters() | nil,
  output: io() | nil,
  errors: [error()]
}

record()

@type record() :: %{
  type: :record,
  key: key_type(),
  fields: [field()],
  required: [String.t()],
  description: String.t() | nil
}

reference_type()

@type reference_type() ::
  {:ref, local_ref :: String.t()}
  | {:ref, external_ref :: {:lexicon, String.t()}}

string_constraints()

@type string_constraints() :: [
  max_length: pos_integer(),
  max_graphemes: pos_integer(),
  format: string_format()
]

string_format()

@type string_format() :: :datetime | :language | :did | :handle | :at_uri | :nsid

subscription()

@type subscription() :: %{
  parameters: parameters(),
  errors: [error()],
  message: %{schema: union_type(), description: String.t() | nil}
}

t()

@type t() :: %{
  lexicon: integer(),
  id: String.t(),
  description: String.t() | nil,
  type: definition_type(),
  module_path: module_path(),
  definitions: %{required(String.t()) => definition()}
}

union_type()

@type union_type() ::
  {:union, types: [reference_type()], description: String.t() | nil}