catalog

package module
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2026 License: MIT Imports: 7 Imported by: 2 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

catalog

The commerce catalog module: native pricing, variant matrices, stock, and SKUs keyed to a configured product post type. Products are content items — this module owns the commerce structure and its surfaces.

Config

[catalog]
post_type = "product"   # the registered post type carrying products (required)
currency = "IDR"        # display currency for public payloads (required)

Init fails closed when the post type is not registered or the currency is missing — a misconfigured commerce edition never serves an empty catalog silently.

Owns

  • catalog_products / catalog_variants tables (module migration, schema_migrations_catalog); prices are integer minor units.
  • GET/PUT /api/v1/catalog/products/{contentID} — admin commerce data (protected realm; mutations gated by the catalog.manage capability).
  • GET /api/v1/public/catalog/products/{slug} — public commerce payload (price, sale price, stock posture, variant matrix with effective prices, currency) for a published product.
  • catalog.manage capability (contributed via RoleProvider).

Seams

  • PostTypeChecker — registry check (composition root adapts the post-type service).
  • ProductSlugResolver — published-product slug → content ID (composition root adapts the content service).
  • kernel.CapabilityResolver — admin mutation gate.
  • kernel.Logger.

Not here (yet)

Variant stock decrements ride the payments phase; storefront rendering rides the theme-storefront module; customer accounts and vouchers are v2 per the commerce proposal.

Documentation

Overview

Package catalog is the official commerce catalog module: native pricing, variant matrices, stock, and SKUs keyed to a configured product post type. Products are content items; this module owns the commerce structure and its admin/public surfaces.

Index

Constants

View Source
const (
	// Name is the registry key for this module.
	Name = "catalog"

	// Version is the module version reported via Module.Version.
	Version = "0.1.0"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Module

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

Module is the catalog kernel module.

func New

func New(options ...Option) *Module

New builds the module and constructs both handlers once, so the admin and public surfaces share the adopted service.

func (*Module) Capabilities

func (m *Module) Capabilities() []string

Capabilities contributes the module's permission to the registry so the resolver can grant it (Admin implicitly, custom roles via config when declared).

func (*Module) Init

func (m *Module) Init(_ kernel.Kernel) error

Init validates the adopted configuration: the configured product type must exist in the registry and the currency must be set — a misconfigured commerce edition fails startup loudly instead of serving an empty catalog.

func (*Module) Migrations

func (m *Module) Migrations() fs.FS

Migrations returns the embedded migration filesystem, laid out per driver subdirectory (the core migration runner selects via Driver.MigrationDir).

func (*Module) Name

func (m *Module) Name() string

Name returns the registry key.

func (*Module) Optional

func (m *Module) Optional() []string

Optional lists soft dependencies. None.

func (*Module) RegisterDualRoutes

func (m *Module) RegisterDualRoutes(r kernel.DualAuthRegistrar)

RegisterDualRoutes declares the admin surface for dual-realm mounting: core serves every path on both the agent stack (Bearer API key) and the browser stack (CSRF plus JWT), dispatched by credential — so AI agents maintain catalog records with the same API key they use for content while the admin SPA keeps working unchanged. Same handlers, same in-handler capability checks on both realms.

func (*Module) RegisterPublicRoutes

func (m *Module) RegisterPublicRoutes(router chi.Router)

RegisterPublicRoutes mounts the public product payload on the anonymous group (public rate limit applied by core): commerce data by slug for themes and headless frontends.

func (*Module) Requires

func (m *Module) Requires() []string

Requires lists hard dependencies. Products are content items: the content engine is core, and the post-type registry is adopted through the checker seam, so the module depends on nothing in the module graph.

func (*Module) Shutdown

func (m *Module) Shutdown() error

Shutdown releases nothing: the module holds no runtime resources.

func (*Module) Version

func (m *Module) Version() string

Version returns the module version.

type Option

type Option func(*Module)

Option configures a Module. The composition root supplies every option; direct construction without options yields a standalone module that fails its Init (no config) and serves nothing.

func WithCapabilityResolver

func WithCapabilityResolver(resolve kernel.CapabilityResolver) Option

WithCapabilityResolver attaches the capability resolver gating admin mutations. Without one every mutation is denied (fail closed).

func WithConfig

func WithConfig(config catalogapi.Config) Option

WithConfig sets the operator knobs: the product post-type slug and the display currency for public payloads.

func WithLogger

func WithLogger(logger kernel.Logger) Option

WithLogger attaches the module logger. Without one failures are dropped (discard sink).

func WithPostTypes

func WithPostTypes(checker catalogapi.PostTypeChecker) Option

WithPostTypes attaches the post-type registry check. Without one Init fails: the module refuses to start when it cannot verify its product type.

func WithService

func WithService(service *catalogdomain.Service) Option

WithService adopts the catalog domain service (composition root).

func WithSlugResolver

func WithSlugResolver(resolver catalogapi.ProductSlugResolver) Option

WithSlugResolver attaches the published-product slug lookup for the public surface. Without one the public endpoint resolves nothing.

Directories

Path Synopsis
api
Package api hosts the catalog module's HTTP surfaces: the admin product-commerce endpoints (protected realm) and the public product payload (anonymous realm).
Package api hosts the catalog module's HTTP surfaces: the admin product-commerce endpoints (protected realm) and the public product payload (anonymous realm).
Package catalog is the official commerce catalog module: native pricing, variant matrices, stock, and SKUs for a configured product post type.
Package catalog is the official commerce catalog module: native pricing, variant matrices, stock, and SKUs for a configured product post type.
Package store is the single-source catalog repository: one implementation against *sql.DB plus a kernel Dialect, following the comments/media store pattern.
Package store is the single-source catalog repository: one implementation against *sql.DB plus a kernel Dialect, following the comments/media store pattern.
Package testutil provides the kernel fixture module tests run against.
Package testutil provides the kernel fixture module tests run against.

Jump to

Keyboard shortcuts

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