store

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const APIVersion = "contextcart.dev/v1"
View Source
const ConfigFileName = "config.yaml"

Variables

View Source
var ErrNotFound = errors.New("not found")

Functions

func RequiredDirs

func RequiredDirs() []string

RequiredDirs returns the store directories required by v1.

func ValidateConfig

func ValidateConfig(cfg Config) error

ValidateConfig verifies supported config schema and required fields.

func WriteConfig

func WriteConfig(path string, cfg Config) error

WriteConfig writes a store config YAML file, creating the parent directory.

Types

type Config

type Config struct {
	APIVersion string   `yaml:"apiVersion"`
	CreatedAt  string   `yaml:"createdAt"`
	Defaults   Defaults `yaml:"defaults"`
}

Config is the versioned store configuration written to config.yaml.

func NewConfig

func NewConfig(createdAt time.Time) Config

NewConfig returns a default v1 store configuration.

func ReadConfig

func ReadConfig(path string) (Config, error)

ReadConfig reads and validates a store config YAML file.

type Defaults

type Defaults struct {
	PreferSymlink bool `yaml:"preferSymlink"`
}

Defaults contains store-wide default preferences.

type LocalStore

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

LocalStore is the file-backed ContextCart store rooted at a resolved home.

func New

func New(home string) *LocalStore

New creates a file-backed store for home.

func (*LocalStore) ConfigPath

func (s *LocalStore) ConfigPath() string

ConfigPath returns the store config.yaml path.

func (*LocalStore) Doctor

func (s *LocalStore) Doctor(ctx context.Context) error

Doctor verifies the v1 store layout, config schema, and readable component metadata files.

func (*LocalStore) GetComponent

func (s *LocalStore) GetComponent(ctx context.Context, ref components.Ref) (components.Component, error)

GetComponent loads a component by typed ID.

func (*LocalStore) GetLoadout

func (s *LocalStore) GetLoadout(ctx context.Context, id string) (loadouts.Loadout, error)

GetLoadout loads a loadout by ID.

func (*LocalStore) Home

func (s *LocalStore) Home() string

Home returns the resolved ContextCart home directory used by this store.

func (*LocalStore) Init

func (s *LocalStore) Init(ctx context.Context) error

Init creates the ContextCart store layout and writes config.yaml if missing.

func (*LocalStore) ListComponents

func (s *LocalStore) ListComponents(ctx context.Context, filter components.Filter) ([]components.ComponentSummary, error)

ListComponents returns component summaries matching the supplied filter.

func (*LocalStore) ListLoadouts

func (s *LocalStore) ListLoadouts(ctx context.Context) ([]loadouts.Summary, error)

ListLoadouts returns all loadout summaries in deterministic filename order.

func (*LocalStore) RemoveComponent

func (s *LocalStore) RemoveComponent(ctx context.Context, ref components.Ref) error

RemoveComponent removes a component record and payload directory from the store.

func (*LocalStore) RemoveLoadout

func (s *LocalStore) RemoveLoadout(ctx context.Context, id string) error

RemoveLoadout removes one loadout definition from the store.

func (*LocalStore) SaveComponent

func (s *LocalStore) SaveComponent(ctx context.Context, component components.Component) error

SaveComponent validates and writes a component record whose payload files are already present in its target store directory.

func (*LocalStore) SaveComponentFrom

func (s *LocalStore) SaveComponentFrom(ctx context.Context, component components.Component, sourceDir string) error

SaveComponentFrom validates and writes a component record, copying any payload files from sourceDir before persisting metadata.

func (*LocalStore) SaveLoadout

func (s *LocalStore) SaveLoadout(ctx context.Context, loadout loadouts.Loadout) error

SaveLoadout validates and writes one loadout definition.

Jump to

Keyboard shortcuts

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