registry

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package registry provides a component registry with manifest validation. ComponentSpec manifests describe what a component accepts (properties, data inputs, events, actions) and what constraints it has.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuiltinProfiles

func BuiltinProfiles() map[string]*uispec.ProfileConstraints

BuiltinProfiles returns the default profile constraint definitions.

func CheckVersionCompat

func CheckVersionCompat(requested, registered string) error

CheckVersionCompat reports whether a registered component version satisfies a version requested by a page. Supported request forms:

""       any version (no constraint)
"1"      same major (1.x.x)
"1.2"    same major.minor (1.2.x)
"1.2.3"  exact
"^1.2"   same major, and registered >= requested
"^1.2.3" same major, and registered >= requested

func RegisterAnalyticsComponents

func RegisterAnalyticsComponents(r *Registry) error

RegisterAnalyticsComponents adds the analytics namespace components to the registry: line-chart, bar-chart, metric, table, filter, gauge.

func RegisterApplicationComponents

func RegisterApplicationComponents(r *Registry) error

RegisterApplicationComponents adds the application namespace components to the registry: input, select, checkbox, form, record-detail, record-list, action-bar, badge. These are the form/record/action primitives used by the application and portal profiles.

func RegisterAssistantComponents

func RegisterAssistantComponents(r *Registry) error

RegisterAssistantComponents adds the assistant namespace components to the registry: thread, composer, thread-list, tool-call, run-status.

func RegisterBuiltins

func RegisterBuiltins(r *Registry) error

RegisterBuiltins registers all built-in component families (core + analytics + assistant + application).

func RegisterCoreComponents

func RegisterCoreComponents(r *Registry) error

RegisterCoreComponents adds the core namespace components to the registry: card, text, image, tabs, button, modal.

func ValidateProfile

func ValidateProfile(page *uispec.PageSpec) error

ValidateProfile checks that a PageSpec conforms to its declared profile. Returns nil if no profile is set (unconstrained).

func ValidateProperties

func ValidateProperties(schema json.RawMessage, props map[string]any) []string

ValidateProperties checks a component instance's properties against the manifest's propertiesSchema. String values containing ${...} expressions are skipped for type and enum checks because they resolve at runtime.

Types

type ComponentSpec

type ComponentSpec struct {
	ID                string               `json:"id"`
	Version           string               `json:"version"`
	Category          string               `json:"category"`
	Namespace         string               `json:"namespace"`
	Runtime           string               `json:"runtime"`
	Entrypoint        string               `json:"entrypoint"`
	PropertiesSchema  json.RawMessage      `json:"propertiesSchema,omitempty"`
	DataInputs        map[string]DataInput `json:"dataInputs,omitempty"`
	Events            map[string]EventDef  `json:"events,omitempty"`
	Actions           []string             `json:"actions,omitempty"`
	LayoutConstraints *LayoutConstraints   `json:"layoutConstraints,omitempty"`
	Capabilities      []string             `json:"capabilities,omitempty"`
	DesignSystem      *DesignSystemRef     `json:"designSystem,omitempty"`
}

ComponentSpec is the manifest for a registered component.

func ParseManifest

func ParseManifest(data []byte) (*ComponentSpec, error)

ParseManifest decodes a ComponentSpec manifest from JSON.

type DataInput

type DataInput struct {
	Type        string `json:"type"`
	Description string `json:"description,omitempty"`
	Required    bool   `json:"required,omitempty"`
}

DataInput describes one named data slot a component can bind to.

type DesignSystemRef

type DesignSystemRef struct {
	Tokens   []string `json:"tokens,omitempty"`
	Variants []string `json:"variants,omitempty"`
}

DesignSystemRef links a component to design tokens.

type EventDef

type EventDef struct {
	Description string          `json:"description,omitempty"`
	Schema      json.RawMessage `json:"schema,omitempty"`
}

EventDef describes an event a component can emit.

type LayoutConstraints

type LayoutConstraints struct {
	MinWidth  string   `json:"minWidth,omitempty"`
	MinHeight string   `json:"minHeight,omitempty"`
	MaxWidth  string   `json:"maxWidth,omitempty"`
	MaxHeight string   `json:"maxHeight,omitempty"`
	AllowedIn []string `json:"allowedIn,omitempty"`
}

LayoutConstraints restrict where and how a component may be placed.

type Registry

type Registry struct {
	// contains filtered or unexported fields
}

Registry is an in-memory store of ComponentSpec manifests.

func New

func New() *Registry

New creates an empty registry.

func NewWithBuiltins

func NewWithBuiltins() (*Registry, error)

NewWithBuiltins creates a registry pre-loaded with all built-in components.

func (*Registry) Count

func (r *Registry) Count() int

Count returns the number of registered components.

func (*Registry) Get

func (r *Registry) Get(id string) *ComponentSpec

Get retrieves a component manifest by ID. Returns nil if not found.

func (*Registry) Has

func (r *Registry) Has(id string) bool

Has returns true if a component with the given ID is registered.

func (*Registry) List

func (r *Registry) List() []*ComponentSpec

List returns all registered component manifests.

func (*Registry) ListByNamespace

func (r *Registry) ListByNamespace(ns string) []*ComponentSpec

ListByNamespace returns components matching the given namespace.

func (*Registry) LoadManifest

func (r *Registry) LoadManifest(data []byte) error

LoadManifest parses a JSON manifest and registers it.

func (*Registry) LoadManifestDir

func (r *Registry) LoadManifestDir(dir string) (int, error)

LoadManifestDir registers every *.json manifest in a directory (non-recursive). Returns the number of manifests loaded.

func (*Registry) LoadManifestFile

func (r *Registry) LoadManifestFile(path string) error

LoadManifestFile reads a JSON manifest from a file and registers it.

func (*Registry) Register

func (r *Registry) Register(spec *ComponentSpec) error

Register adds or replaces a component manifest in the registry. The component ID must be in "namespace.name" format.

func (*Registry) ValidatePage

func (r *Registry) ValidatePage(page *uispec.PageSpec) error

ValidatePage checks that a PageSpec references only registered components and that data bindings reference declared data inputs.

type ValidationError

type ValidationError struct {
	Errors []string
}

ValidationError collects all problems found during validation.

func (*ValidationError) Error

func (e *ValidationError) Error() string

Jump to

Keyboard shortcuts

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