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 ¶
- func BuiltinProfiles() map[string]*uispec.ProfileConstraints
- func CheckVersionCompat(requested, registered string) error
- func RegisterAnalyticsComponents(r *Registry) error
- func RegisterApplicationComponents(r *Registry) error
- func RegisterAssistantComponents(r *Registry) error
- func RegisterBuiltins(r *Registry) error
- func RegisterCoreComponents(r *Registry) error
- func ValidateProfile(page *uispec.PageSpec) error
- func ValidateProperties(schema json.RawMessage, props map[string]any) []string
- type ComponentSpec
- type DataInput
- type DesignSystemRef
- type EventDef
- type LayoutConstraints
- type Registry
- func (r *Registry) Count() int
- func (r *Registry) Get(id string) *ComponentSpec
- func (r *Registry) Has(id string) bool
- func (r *Registry) List() []*ComponentSpec
- func (r *Registry) ListByNamespace(ns string) []*ComponentSpec
- func (r *Registry) LoadManifest(data []byte) error
- func (r *Registry) LoadManifestDir(dir string) (int, error)
- func (r *Registry) LoadManifestFile(path string) error
- func (r *Registry) Register(spec *ComponentSpec) error
- func (r *Registry) ValidatePage(page *uispec.PageSpec) error
- type ValidationError
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 ¶
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 ¶
RegisterAnalyticsComponents adds the analytics namespace components to the registry: line-chart, bar-chart, metric, table, filter, gauge.
func RegisterApplicationComponents ¶
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 ¶
RegisterAssistantComponents adds the assistant namespace components to the registry: thread, composer, thread-list, tool-call, run-status.
func RegisterBuiltins ¶
RegisterBuiltins registers all built-in component families (core + analytics + assistant + application).
func RegisterCoreComponents ¶
RegisterCoreComponents adds the core namespace components to the registry: card, text, image, tabs, button, modal.
func ValidateProfile ¶
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 NewWithBuiltins ¶
NewWithBuiltins creates a registry pre-loaded with all built-in 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) 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 ¶
LoadManifest parses a JSON manifest and registers it.
func (*Registry) LoadManifestDir ¶
LoadManifestDir registers every *.json manifest in a directory (non-recursive). Returns the number of manifests loaded.
func (*Registry) LoadManifestFile ¶
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.
type ValidationError ¶
type ValidationError struct {
Errors []string
}
ValidationError collects all problems found during validation.
func (*ValidationError) Error ¶
func (e *ValidationError) Error() string