catalog

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package catalog loads and validates the usecase catalog embedded in the binary (catalog.yml): the server's well-known bundles, grouped into usecases a client sets up with one call, dependencies included.

A usecase is a set of bundles installed together plus the usecases it requires; every bundle is one created root under a permanent `system:<name>/v<n>` id, declaring a type objects carry, a miniapp the client opens, records on the root, or several of those. Client contract: docs/28-well-known-bundles.md.

Validation here is structural and pure — ids, handles, the dependency graph, relation links, module rules — and collects every problem rather than the first, with its yaml path. What needs the server's descriptor gate (slug against kind, option shapes, miniapp values) is layered on top by the server package; both run at boot, in `make test` and in `make catalog-validate`.

Index

Constants

View Source
const (
	CodeBadYAML        = "catalog.bad_yaml"
	CodeUnknownField   = "catalog.unknown_field"
	CodeBadId          = "catalog.bad_id"
	CodeDuplicate      = "catalog.duplicate"
	CodeMissing        = "catalog.missing"
	CodeBadField       = "catalog.bad_field"
	CodeUnknownUsecase = "catalog.unknown_usecase"
	CodeCycle          = "catalog.cycle"
	CodeBrokenLink     = "catalog.broken_link"
	CodeBadMiniapp     = "catalog.bad_miniapp"
)

Problem codes.

View Source
const BundleIdPattern = "system:<name>/v<n>"

BundleIdPattern is the grammar of a catalog bundle id, for messages.

Variables

This section is empty.

Functions

func Embedded

func Embedded() []byte

Embedded returns the catalog shipped with the binary.

func Load

func Load(src []byte, opts Options) (*Catalog, Problems)

Load decodes a catalog and runs the pure validation, returning every finding. The catalog is nil only when the source did not decode; with structural problems it is still returned, so a caller layering more checks on top can report everything in one pass — but Get and Order are trustworthy only when Problems is empty.

Types

type Catalog

type Catalog struct {
	Usecases []api.CatalogUsecase
	// contains filtered or unexported fields
}

Catalog is a loaded, structurally valid catalog.

func (*Catalog) Get

func (c *Catalog) Get(id string) (api.CatalogUsecase, bool)

Get returns the usecase with the id.

func (*Catalog) Order

func (c *Catalog) Order(id string) ([]api.CatalogUsecase, bool)

Order returns the usecase's transitive dependency closure in setup order — dependencies first, each once, the requested usecase last. Deterministic: requires are walked in declaration order.

type Options

type Options struct {
	// KnownTypeIds are the registered (built-in) type and collection
	// ids of the server: reserved against catalog xKeys, and valid
	// relation targets. `any`, `type` and `collection` are always
	// included.
	KnownTypeIds []string
	// RootTypeIds are the registered type ids a bare bundle root may
	// name as its `rootType`.
	RootTypeIds []string
}

Options tune the pure validation with what only the server knows.

type Problem

type Problem struct {
	// Path is the yaml path of the offending node
	// (`usecases[3].bundles[1].type.properties[2].xFormat`).
	Path    string
	Code    string
	Message string
}

Problem is one validation finding: where, what, why.

func (Problem) String

func (p Problem) String() string

type Problems

type Problems []Problem

Problems is the error a validation returns — every problem found, in document order.

func (Problems) Error

func (ps Problems) Error() string

Directories

Path Synopsis
cmd
catalog-validate command
catalog-validate checks the usecase catalog embedded in the binary and any candidate files given as arguments, printing one line per problem (`<source>: <path>: <code>: <message>`) and exiting 1 on any.
catalog-validate checks the usecase catalog embedded in the binary and any candidate files given as arguments, printing one line per problem (`<source>: <path>: <code>: <message>`) and exiting 1 on any.

Jump to

Keyboard shortcuts

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