catalog

package
v0.0.0-...-74adf86 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2026 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Catalog

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

Catalog holds all catalog entities loaded from git

func NewCatalog

func NewCatalog(commit string) *Catalog

NewCatalog creates a new empty catalog

func (*Catalog) AddCategory

func (c *Catalog) AddCategory(cat *Category)

AddCategory adds a category to the catalog

func (*Catalog) AddCategoryFromMarkdown

func (c *Catalog) AddCategoryFromMarkdown(filename, content string) error

AddCategoryFromMarkdown parses markdown and adds category

func (*Catalog) AddCollection

func (c *Catalog) AddCollection(coll *Collection)

AddCollection adds a collection to the catalog

func (*Catalog) AddCollectionFromMarkdown

func (c *Catalog) AddCollectionFromMarkdown(filename, content string) error

AddCollectionFromMarkdown parses markdown and adds collection

func (*Catalog) AddProduct

func (c *Catalog) AddProduct(p *Product)

AddProduct adds a product to the catalog

func (*Catalog) AddProductFromMarkdown

func (c *Catalog) AddProductFromMarkdown(filename, content string) error

AddProductFromMarkdown parses markdown and adds product

func (*Catalog) AllCategories

func (c *Catalog) AllCategories() []*Category

AllCategories returns all categories

func (*Catalog) AllCollections

func (c *Catalog) AllCollections() []*Collection

AllCollections returns all collections

func (*Catalog) AllProducts

func (c *Catalog) AllProducts() []*Product

AllProducts returns all products

func (*Catalog) BuildCategoryHierarchy

func (c *Catalog) BuildCategoryHierarchy()

BuildCategoryHierarchy builds parent-child relationships and computes path/depth for all categories in the catalog

func (*Catalog) CategoryCount

func (c *Catalog) CategoryCount() int

CategoryCount returns the number of categories

func (*Catalog) CollectionCount

func (c *Catalog) CollectionCount() int

CollectionCount returns the number of collections

func (*Catalog) Commit

func (c *Catalog) Commit() string

Commit returns the git commit SHA

func (*Catalog) GetCategory

func (c *Catalog) GetCategory(id string) (*Category, bool)

GetCategory retrieves a category by ID

func (*Catalog) GetCategoryBySlug

func (c *Catalog) GetCategoryBySlug(slug string) (*Category, bool)

GetCategoryBySlug retrieves a category by slug

func (*Catalog) GetCollection

func (c *Catalog) GetCollection(id string) (*Collection, bool)

GetCollection retrieves a collection by ID

func (*Catalog) GetCollectionBySlug

func (c *Catalog) GetCollectionBySlug(slug string) (*Collection, bool)

GetCollectionBySlug retrieves a collection by slug

func (*Catalog) GetProduct

func (c *Catalog) GetProduct(id string) (*Product, bool)

GetProduct retrieves a product by ID

func (*Catalog) GetProductBySKU

func (c *Catalog) GetProductBySKU(sku string) (*Product, bool)

GetProductBySKU retrieves a product by SKU

func (*Catalog) LoadedAt

func (c *Catalog) LoadedAt() time.Time

LoadedAt returns when the catalog was loaded

func (*Catalog) ProductCount

func (c *Catalog) ProductCount() int

ProductCount returns the number of products

type Category

type Category struct {
	ID           string    `yaml:"id"`
	Name         string    `yaml:"name"`
	Slug         string    `yaml:"slug"`
	ParentID     *string   `yaml:"parent_id"`
	DisplayOrder int       `yaml:"display_order"`
	CreatedAt    time.Time `yaml:"created_at"`
	UpdatedAt    time.Time `yaml:"updated_at"`
	Body         string    `yaml:"-"`

	// Computed fields (built by BuildCategoryHierarchy)
	Parent   *Category   `yaml:"-"`
	Children []*Category `yaml:"-"`
	Path     []*Category `yaml:"-"` // Root to current
	Depth    int         `yaml:"-"`
}

Category represents a hierarchical classification

type Collection

type Collection struct {
	ID           string    `yaml:"id"`
	Name         string    `yaml:"name"`
	Slug         string    `yaml:"slug"`
	DisplayOrder int       `yaml:"display_order"`
	ProductIDs   []string  `yaml:"product_ids"`
	CreatedAt    time.Time `yaml:"created_at"`
	UpdatedAt    time.Time `yaml:"updated_at"`
	Body         string    `yaml:"-"`
}

Collection represents a flat grouping of products

type Loader

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

Loader loads catalog data from git repository

func NewLoader

func NewLoader(repoPath string, logger *zap.Logger) *Loader

NewLoader creates a new catalog loader

func (*Loader) LoadFromHEAD

func (l *Loader) LoadFromHEAD(ctx context.Context) (*Catalog, error)

LoadFromHEAD loads catalog from the current HEAD commit

func (*Loader) LoadFromLatestTag

func (l *Loader) LoadFromLatestTag(ctx context.Context) (*Catalog, error)

LoadFromLatestTag loads catalog from the latest release tag

func (*Loader) LoadFromTag

func (l *Loader) LoadFromTag(ctx context.Context, tag string) (*Catalog, error)

LoadFromTag loads catalog from a specific release tag

type Product

type Product struct {
	ID                string                 `yaml:"id"`
	SKU               string                 `yaml:"sku"`
	Title             string                 `yaml:"title"`
	Price             float64                `yaml:"price"`
	Currency          string                 `yaml:"currency"`
	InventoryStatus   string                 `yaml:"inventory_status"`
	InventoryQuantity *int                   `yaml:"inventory_quantity"`
	CategoryID        string                 `yaml:"category_id"`
	CollectionIDs     []string               `yaml:"collection_ids"`
	Images            []string               `yaml:"images"`
	Metadata          map[string]interface{} `yaml:"metadata"`
	CreatedAt         time.Time              `yaml:"created_at"`
	UpdatedAt         time.Time              `yaml:"updated_at"`
	Body              string                 `yaml:"-"` // Markdown body
}

Product represents a sellable item

Jump to

Keyboard shortcuts

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