mix exosphere.gen.lexicons (Exosphere v0.5.0)

Copy Markdown View Source

Generates Elixir modules from the lexicon JSON files vendored under priv/lexicons, for every supported source.

mix exosphere.gen.lexicons

Pass a source to scope generation to one namespace; each source writes to its own tree under lib/exosphere:

mix exosphere.gen.lexicons app.bsky          # → lib/exosphere/bsky/**
mix exosphere.gen.lexicons community.lexicon # → lib/exosphere/community/**
mix exosphere.gen.lexicons com.atproto       # → lib/exosphere/atproto/**

With --check, regenerates in memory and exits non-zero if any tracked generated file would change (used in CI to catch drift). The check only covers the selected source.

mix exosphere.gen.lexicons --check
mix exosphere.gen.lexicons --check community.lexicon

Fetch lexicons published by a repository (as com.atproto.lexicon.schema records) before generating, vendoring them under priv/lexicons so the result is reproducible on later runs:

mix exosphere.gen.lexicons --from did:plc:abc123 [--pds https://pds.example.com]

The PDS is found via DID resolution unless --pds is given. Lexicons from authorities without a namespace rule generate under their full NSID segments (e.g. com.example.postExosphere.Com.Example.Post).

By default the vendored priv/lexicons of this project is the source. Host apps point at their own lexicon directory and output tree:

mix exosphere.gen.lexicons --dir priv/lexicons \
  --out lib/oysters --namespace Oysters --map pub.oysters=Lexicons

--dir scopes generation to that directory's lexicons while the vendored corpus (resolved absolutely, from the exosphere dependency's own priv — not the caller's) is still parsed for ref resolution. Refs into the corpus point at the library's compiled modules — a record referencing com.atproto.repo.strongRef gets Exosphere.ATProto.Repo.StrongRef, not a duplicate struct under the host namespace. --out sets the output directory (default lib/exosphere) and --namespace the module root (default Exosphere). --map authority=Suffix (repeatable) strips the authority segments the way the built-in rules do for app.bsky — with the example above, pub.oysters.postOysters.Lexicons.Post rather than the stuttering Oysters.Pub.Oysters.Post.

Generation is deterministic: the same vendored lexicons always produce the same files, so output can be reviewed with git diff. Refs the corpus can not resolve (fields that degrade to term()) are reported as warnings.