meta

package
v0.9.8 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package meta holds the identity primitives every domain entity carries: UUIDv7 id, DNS-1123 slug name, free-text display name, and provenance.

No I/O, no business logic — just value types and tiny pure helpers. Everything else (entity domain packages, storage, handlers) depends on this; it depends on nothing in the project.

Index

Constants

This section is empty.

Variables

View Source
var Validator = func() *validator.Validate {
	v := validator.New(validator.WithRequiredStructEnabled())
	if err := v.RegisterValidation("slug", isDNS1123Slug); err != nil {
		panic("meta: register slug validator: " + err.Error())
	}
	return v
}()

Validator is the shared go-playground/validator instance every entity package uses. Custom tags ("slug", "uuid7", ...) are registered here. Entities call Validator.Struct(...) from their Validate() methods.

Functions

func MarshalJSONB

func MarshalJSONB(m Metadata) ([]byte, error)

MarshalJSONB renders the JSONB-stored portion of a Metadata. ID, Name, and DisplayName live in their own SQL columns, so they are intentionally excluded from the JSONB blob to avoid duplication.

func NewID

func NewID() string

NewID returns a fresh UUIDv7 string. Centralized so every entity store stamps ids the same way.

Types

type Icon

type Icon struct {
	Path string `json:"path,omitempty" yaml:"path,omitempty"`
}

Icon describes a visual asset for a catalog entity (Provider, Host). Path is relative — typically "/provider/anthropic.svg" — and the frontend prefixes its own asset-base URL at render time. Relay does not serve the asset; this field is operator metadata.

type Metadata

type Metadata struct {
	ID          string            `json:"id,omitempty"          yaml:"id,omitempty"          validate:"omitempty,uuid"`
	Name        string            `json:"name"                  yaml:"name"                  validate:"required,slug"`
	DisplayName string            `json:"displayName,omitempty" yaml:"displayName,omitempty"`
	Description string            `json:"description,omitempty" yaml:"description,omitempty"`
	Owner       Owner             `json:"owner,omitempty"       yaml:"owner,omitempty"`
	Labels      map[string]string `json:"labels,omitempty"      yaml:"labels,omitempty"`
	CreatedAt   time.Time         `json:"createdAt,omitempty"   yaml:"-"`
	UpdatedAt   time.Time         `json:"updatedAt,omitempty"   yaml:"-"`

	// Dirty marks a row an operator has edited via the control API. Seed skips
	// dirty rows so re-seeding never clobbers operator changes (unless the run
	// is told to clear them). Server-authoritative: stamped on edit, never read
	// from manifest YAML.
	Dirty bool `json:"dirty,omitempty" yaml:"-"`
}

Metadata is the identity tuple stamped on every domain row.

  • ID is the immutable primary key (UUIDv7). Server-stamped on create.
  • Name is a stable DNS-1123 slug, unique-per-kind, mutable via the id-routed update path. Used in URLs and YAML refs.
  • DisplayName is free text shown in UI. Edits are free; nothing references it.
  • Description is free text documenting the row.
  • Owner identifies provenance.
  • Labels are arbitrary k/v selectors.
  • CreatedAt/UpdatedAt are server-derived, read-only provenance read from the row's dedicated columns (NOT the metadata JSONB — see MarshalJSONB, which serializes only Description/Owner/Labels). They are omitted from YAML manifests (yaml:"-") since seed/apply must not set them; the store stamps them on read.

func UnmarshalJSONB

func UnmarshalJSONB(id, name, displayName string, raw []byte) (Metadata, error)

UnmarshalJSONB reconstructs a Metadata from its column values plus the JSONB blob. raw may be empty (legacy rows or freshly-stamped placeholders).

type Owner

type Owner struct {
	Kind OwnerKind `json:"kind,omitempty" yaml:"kind,omitempty"`
	ID   string    `json:"id,omitempty"   yaml:"id,omitempty"`
}

Owner describes who created / manages a row. Kind=provider requires ID; the other kinds leave ID empty.

type OwnerKind

type OwnerKind string

OwnerKind enumerates provenance categories.

const (
	OwnerSystem   OwnerKind = "system"
	OwnerProvider OwnerKind = "provider"
	OwnerHost     OwnerKind = "host"
	OwnerUser     OwnerKind = "user"
)

Jump to

Keyboard shortcuts

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