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
- type Module
- func (m *Module) Capabilities() []string
- func (m *Module) Init(_ kernel.Kernel) error
- func (m *Module) Migrations() fs.FS
- func (m *Module) Name() string
- func (m *Module) Optional() []string
- func (m *Module) RegisterDualRoutes(r kernel.DualAuthRegistrar)
- func (m *Module) RegisterPublicRoutes(router chi.Router)
- func (m *Module) Requires() []string
- func (m *Module) Shutdown() error
- func (m *Module) Version() string
- type Option
- func WithCapabilityResolver(resolve kernel.CapabilityResolver) Option
- func WithConfig(config catalogapi.Config) Option
- func WithLogger(logger kernel.Logger) Option
- func WithPostTypes(checker catalogapi.PostTypeChecker) Option
- func WithService(service *catalogdomain.Service) Option
- func WithSlugResolver(resolver catalogapi.ProductSlugResolver) Option
Constants ¶
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 ¶
New builds the module and constructs both handlers once, so the admin and public surfaces share the adopted service.
func (*Module) Capabilities ¶
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 ¶
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 ¶
Migrations returns the embedded migration filesystem, laid out per driver subdirectory (the core migration runner selects via Driver.MigrationDir).
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 ¶
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 ¶
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.
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 ¶
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 |
|---|---|
|
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. |