lexica

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 20, 2026 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Overview

Package lexica provides a Lexicon representation and associated code generators.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ManifestIncludes

func ManifestIncludes(nsid, name string) bool

Types

type Catalog

type Catalog struct {
	Lexicons []*Lexicon
}

func NewCatalog

func NewCatalog() *Catalog

func (*Catalog) GenerateCallCommands

func (catalog *Catalog) GenerateCallCommands(root string) error

func (*Catalog) GenerateCheckCommands

func (catalog *Catalog) GenerateCheckCommands(root string) error

func (*Catalog) GenerateXRPCHandlers

func (catalog *Catalog) GenerateXRPCHandlers(root string) error

func (*Catalog) Load

func (catalog *Catalog) Load(root string, lint bool) error

func (*Catalog) LoadLexicon

func (catalog *Catalog) LoadLexicon(path string, lint bool) error

type Def

type Def struct {
	Type        string `json:"type"`
	Description string `json:"description"`

	// object
	Required   []string            `json:"required,omitempty"`
	Properties map[string]Property `json:"properties,omitempty"`

	// query
	Parameters *Parameters `json:"parameters,omitempty"`
	Output     *Output     `json:"output,omitempty"`

	// procedure
	Input *Input `json:"input,omitempty"`

	// array
	Items *Items `json:"items,omitempty"`

	// permission-set
	Permissions []*Permission `json:"permissions,omitempty"`

	// record
	Record *Schema `json:"record,omitempty"`

	// subscription
	Message *Message `json:"message,omitempty"`
}

func (*Def) Validate

func (def *Def) Validate(path string) error

func (*Def) ValidateProcedure

func (def *Def) ValidateProcedure(path string) error

func (*Def) ValidateQuery

func (def *Def) ValidateQuery(path string) error

type Input

type Input struct {
	Encoding string `json:"encoding"`
	Schema   Schema `json:"schema"`
}

type Items

type Items struct {
	Type string   `json:"type,omitempty"`
	Ref  string   `json:"ref,omitempty"`
	Refs []string `json:"refs,omitempty"`
}

type Lexicon

type Lexicon struct {
	Lexicon     int             `json:"lexicon"`
	Id          string          `json:"id"`
	Description string          `json:"description"`
	Defs        map[string]*Def `json:"defs"`
}

https://atproto.com/specs/lexicon#lexicon-files

func LookupLexicon

func LookupLexicon(id string) *Lexicon

func (*Lexicon) Lookup

func (lexicon *Lexicon) Lookup(id string) *Def

func (*Lexicon) Validate

func (lexicon *Lexicon) Validate(path string) error

type Manifest

type Manifest struct {
	IDs []string `json:"ids"`
}

func BuildManifest

func BuildManifest(filename string) (*Manifest, error)

func (*Manifest) AddDependencies

func (manifest *Manifest) AddDependencies(l *Lexicon, def *Def) error

func (*Manifest) AddDependenciesForArray

func (manifest *Manifest) AddDependenciesForArray(l *Lexicon, def *Def) error

func (*Manifest) AddDependenciesForDef

func (manifest *Manifest) AddDependenciesForDef(l *Lexicon, def *Def) error

func (*Manifest) AddDependenciesForProperties

func (manifest *Manifest) AddDependenciesForProperties(l *Lexicon, properties map[string]Property) error

func (*Manifest) AddDependenciesForSubscription

func (manifest *Manifest) AddDependenciesForSubscription(l *Lexicon, def *Def) error

type Message

type Message struct {
	Description string `json:"description"`
	Schema      Schema `json:"schema"`
}

type Output

type Output struct {
	Encoding string `json:"encoding"`
	Schema   Schema `json:"schema"`
}

type Parameters

type Parameters struct {
	Type       string              `json:"type"`
	Properties map[string]Property `json:"properties"`
}

type Permission

type Permission struct {
	Type           string   `json:"type,omitempty"`
	Resource       string   `json:"resource,omitempty"`
	Actions        []string `json:"action,omitempty"`
	Collections    []string `json:"collection,omitempty"`
	InheritAud     bool     `json:"inheritAud,omitempty"`
	LexiconMethods []string `json:"lxm,omitempty"`
}

type Property

type Property struct {
	Type       string              `json:"type,omitempty"`
	Ref        string              `json:"ref,omitempty"`
	Refs       []string            `json:"refs,omitempty"`
	Items      *Items              `json:"items,omitempty"`
	Minimum    int64               `json:"minimum,omitempty"`
	Maximum    int64               `json:"maximum,omitempty"`
	Default    any                 `json:"default,omitempty"`
	Required   []string            `json:"required,omitempty"`
	Properties map[string]Property `json:"properties,omitempty"`
}

type Schema

type Schema struct {
	Type       string              `json:"type"`
	Ref        string              `json:"ref,omitempty"`
	Refs       []string            `json:"refs,omitempty"`
	Required   []string            `json:"required,omitempty"`
	Properties map[string]Property `json:"properties,omitempty"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL