Documentation
¶
Index ¶
- Constants
- Variables
- func NewMenuItemRepository(db *bun.DB) repository.Repository[*MenuItem]
- func NewMenuItemTranslationRepository(db *bun.DB) repository.Repository[*MenuItemTranslation]
- func NewMenuLocationBindingRepository(db *bun.DB) repository.Repository[*MenuLocationBinding]
- func NewMenuRepository(db *bun.DB) repository.Repository[*Menu]
- func NewMenuViewProfileRepository(db *bun.DB) repository.Repository[*MenuViewProfile]
- type AddMenuItemInput
- type AddMenuItemTranslationInput
- type BulkReorderMenuItemsInput
- type BunMenuItemRepository
- func (r *BunMenuItemRepository) BulkUpdateHierarchy(ctx context.Context, items []*MenuItem) error
- func (r *BunMenuItemRepository) BulkUpdateParentLinks(ctx context.Context, items []*MenuItem) error
- func (r *BunMenuItemRepository) Create(ctx context.Context, item *MenuItem) (*MenuItem, error)
- func (r *BunMenuItemRepository) Delete(ctx context.Context, id uuid.UUID) error
- func (r *BunMenuItemRepository) GetByID(ctx context.Context, id uuid.UUID) (*MenuItem, error)
- func (r *BunMenuItemRepository) GetByMenuAndCanonicalKey(ctx context.Context, menuID uuid.UUID, key string) (*MenuItem, error)
- func (r *BunMenuItemRepository) GetByMenuAndExternalCode(ctx context.Context, menuID uuid.UUID, code string) (*MenuItem, error)
- func (r *BunMenuItemRepository) InvalidateCache(ctx context.Context) error
- func (r *BunMenuItemRepository) ListByMenu(ctx context.Context, menuID uuid.UUID) ([]*MenuItem, error)
- func (r *BunMenuItemRepository) ListChildren(ctx context.Context, parentID uuid.UUID) ([]*MenuItem, error)
- func (r *BunMenuItemRepository) ResetMenuContents(ctx context.Context, menuID uuid.UUID) (itemsDeleted int, translationsDeleted int, err error)
- func (r *BunMenuItemRepository) Update(ctx context.Context, item *MenuItem) (*MenuItem, error)
- type BunMenuItemTranslationRepository
- func (r *BunMenuItemTranslationRepository) Create(ctx context.Context, translation *MenuItemTranslation) (*MenuItemTranslation, error)
- func (r *BunMenuItemTranslationRepository) Delete(ctx context.Context, id uuid.UUID) error
- func (r *BunMenuItemTranslationRepository) GetByMenuItemAndLocale(ctx context.Context, menuItemID uuid.UUID, localeID uuid.UUID) (*MenuItemTranslation, error)
- func (r *BunMenuItemTranslationRepository) InvalidateCache(ctx context.Context) error
- func (r *BunMenuItemTranslationRepository) ListByMenuItem(ctx context.Context, menuItemID uuid.UUID) ([]*MenuItemTranslation, error)
- func (r *BunMenuItemTranslationRepository) Update(ctx context.Context, translation *MenuItemTranslation) (*MenuItemTranslation, error)
- type BunMenuLocationBindingRepository
- func (r *BunMenuLocationBindingRepository) Create(ctx context.Context, binding *MenuLocationBinding) (*MenuLocationBinding, error)
- func (r *BunMenuLocationBindingRepository) Delete(ctx context.Context, id uuid.UUID) error
- func (r *BunMenuLocationBindingRepository) GetByID(ctx context.Context, id uuid.UUID) (*MenuLocationBinding, error)
- func (r *BunMenuLocationBindingRepository) InvalidateCache(ctx context.Context) error
- func (r *BunMenuLocationBindingRepository) List(ctx context.Context, env ...string) ([]*MenuLocationBinding, error)
- func (r *BunMenuLocationBindingRepository) ListByLocation(ctx context.Context, location string, env ...string) ([]*MenuLocationBinding, error)
- func (r *BunMenuLocationBindingRepository) Update(ctx context.Context, binding *MenuLocationBinding) (*MenuLocationBinding, error)
- type BunMenuRepository
- func (r *BunMenuRepository) Create(ctx context.Context, menu *Menu) (*Menu, error)
- func (r *BunMenuRepository) Delete(ctx context.Context, id uuid.UUID) error
- func (r *BunMenuRepository) GetByCode(ctx context.Context, code string, env ...string) (*Menu, error)
- func (r *BunMenuRepository) GetByID(ctx context.Context, id uuid.UUID) (*Menu, error)
- func (r *BunMenuRepository) GetByLocation(ctx context.Context, location string, env ...string) (*Menu, error)
- func (r *BunMenuRepository) InvalidateCache(ctx context.Context) error
- func (r *BunMenuRepository) List(ctx context.Context, env ...string) ([]*Menu, error)
- func (r *BunMenuRepository) Update(ctx context.Context, menu *Menu) (*Menu, error)
- type BunMenuViewProfileRepository
- func (r *BunMenuViewProfileRepository) Create(ctx context.Context, profile *MenuViewProfile) (*MenuViewProfile, error)
- func (r *BunMenuViewProfileRepository) Delete(ctx context.Context, id uuid.UUID) error
- func (r *BunMenuViewProfileRepository) GetByCode(ctx context.Context, code string, env ...string) (*MenuViewProfile, error)
- func (r *BunMenuViewProfileRepository) GetByID(ctx context.Context, id uuid.UUID) (*MenuViewProfile, error)
- func (r *BunMenuViewProfileRepository) InvalidateCache(ctx context.Context) error
- func (r *BunMenuViewProfileRepository) List(ctx context.Context, env ...string) ([]*MenuViewProfile, error)
- func (r *BunMenuViewProfileRepository) Update(ctx context.Context, profile *MenuViewProfile) (*MenuViewProfile, error)
- type ContentMenuMembership
- type ContentRepository
- type ContentTypeRepository
- type CreateMenuInput
- type DeleteMenuItemRequest
- type DeleteMenuRequest
- type IDGenerator
- type ItemOrder
- type LocaleRepository
- type Menu
- type MenuIDDeriver
- type MenuInUseError
- type MenuItem
- type MenuItemRepository
- type MenuItemTranslation
- type MenuItemTranslationInput
- type MenuItemTranslationRepository
- type MenuLocationBinding
- type MenuLocationBindingRepository
- type MenuQueryOptions
- type MenuRepository
- type MenuUsageBinding
- type MenuUsageResolver
- type MenuViewProfile
- type MenuViewProfileRepository
- type NavigationNode
- type NotFoundError
- type PageRepository
- type ParentResolver
- type ReconcileMenuRequest
- type ReconcileResult
- type ReorderMenuItemsInput
- type ResetMenuCounts
- type ResolveRequest
- type ResolvedMenu
- type ResolvedMenuPreview
- type Service
- type ServiceOption
- func WithActivityEmitter(emitter *activity.Emitter) ServiceOption
- func WithAuditRecorder(recorder jobs.AuditRecorder) ServiceOption
- func WithBindingDuplicatePolicy(policy string) ServiceOption
- func WithClock(clock func() time.Time) ServiceOption
- func WithContentRepository(repo ContentRepository) ServiceOption
- func WithContentTypeRepository(repo ContentTypeRepository) ServiceOption
- func WithDefaultEnvironmentKey(key string) ServiceOption
- func WithEnvironmentService(envSvc cmsenv.Service) ServiceOption
- func WithForgivingMenuBootstrap(enabled bool) ServiceOption
- func WithIDGenerator(generator IDGenerator) ServiceOption
- func WithMaxMenuDepth(depth int) ServiceOption
- func WithMenuIDDeriver(deriver MenuIDDeriver) ServiceOption
- func WithMenuLocationBindingRepository(repo MenuLocationBindingRepository) ServiceOption
- func WithMenuUsageResolver(resolver MenuUsageResolver) ServiceOption
- func WithMenuViewProfileRepository(repo MenuViewProfileRepository) ServiceOption
- func WithPageRepository(repo PageRepository) ServiceOption
- func WithParentResolver(resolver ParentResolver) ServiceOption
- func WithReconcileOnResolveNavigation(enabled bool) ServiceOption
- func WithRecordIDGenerator(generator func() uuid.UUID) ServiceOption
- func WithRequireActiveEnvironment(required bool) ServiceOption
- func WithRequireExplicitEnvironment(required bool) ServiceOption
- func WithRequireTranslations(required bool) ServiceOption
- func WithTranslationState(state *translationconfig.State) ServiceOption
- func WithTranslationsEnabled(enabled bool) ServiceOption
- func WithURLResolver(resolver URLResolver) ServiceOption
- type URLKitResolver
- type URLKitResolverOptions
- type URLResolver
- type UpdateMenuItemInput
- type UpsertMenuInput
- type UpsertMenuItemInput
- type UpsertMenuItemTranslationInput
- type UpsertMenuLocationBindingInput
- type UpsertMenuViewProfileInput
Constants ¶
const ( MenuItemTypeItem = cmsmenus.MenuItemTypeItem MenuItemTypeGroup = cmsmenus.MenuItemTypeGroup MenuItemTypeSeparator = cmsmenus.MenuItemTypeSeparator MenuStatusDraft = cmsmenus.MenuStatusDraft MenuStatusPublished = cmsmenus.MenuStatusPublished )
const ( MenuViewModeFull = "full" MenuViewModeTopLevelLimit = "top_level_limit" MenuViewModeMaxDepth = "max_depth" MenuViewModeIncludeIDs = "include_ids" MenuViewModeExcludeIDs = "exclude_ids" MenuViewModeComposed = "composed" MenuBindingPolicySingle = "single" MenuBindingPolicyPriorityMulti = "priority_multi" MenuContributionDuplicateByURL = content.NavigationDuplicateByURL MenuContributionDuplicateByTarget = content.NavigationDuplicateByTarget MenuContributionDuplicateNone = content.NavigationDuplicateNone )
Variables ¶
var ( ErrMenuCodeRequired = errors.New("menus: code is required") ErrMenuCodeInvalid = errors.New("menus: code must contain only letters, numbers, hyphen, or underscore") ErrMenuCodeExists = errors.New("menus: code already exists") ErrMenuNotFound = errors.New("menus: menu not found") ErrMenuInUse = errors.New("menus: menu is assigned to an active theme") ErrMenuItemNotFound = errors.New("menus: menu item not found") ErrMenuItemParentInvalid = errors.New("menus: parent menu item invalid") ErrMenuItemCycle = errors.New("menus: hierarchy creates a cycle") ErrMenuItemPosition = errors.New("menus: position must be zero or positive") ErrMenuItemTargetMissing = errors.New("menus: target type is required") ErrMenuItemTranslations = errors.New("menus: at least one translation is required") ErrMenuItemDuplicateLocale = errors.New("menus: duplicate translation locale provided") ErrMenuItemHasChildren = errors.New("menus: menu item has children; enable cascade to delete") ErrUnknownLocale = errors.New("menus: locale is unknown") ErrTranslationExists = errors.New("menus: translation already exists for locale") ErrTranslationLabelRequired = errors.New("menus: translation label is required") ErrMenuItemPageNotFound = errors.New("menus: page target not found") ErrMenuItemPageSlugRequired = errors.New("menus: page target requires slug") ErrMenuItemTypeInvalid = errors.New("menus: menu item type is invalid") ErrMenuItemParentUnsupported = errors.New("menus: parent cannot accept children") ErrMenuItemSeparatorFields = errors.New("menus: separators cannot have targets, children, labels, icons, or badges") ErrMenuItemGroupFields = errors.New("menus: groups cannot define targets, icons, or badges") ErrMenuItemCollapsibleWithoutChildren = errors.New("menus: collapsible menus require children") ErrMenuItemCollapsedWithoutCollapsible = errors.New("menus: collapsed menus must be marked collapsible") ErrMenuItemTranslationTextRequired = errors.New("menus: translation requires label or translation key") ErrMenuItemDepthExceeded = errors.New("menus: hierarchy exceeds maximum depth") ErrMenuLocationBindingNotFound = errors.New("menus: menu location binding not found") ErrMenuViewProfileNotFound = errors.New("menus: menu view profile not found") ErrMenuStatusInvalid = errors.New("menus: menu status is invalid") ErrMenuViewModeInvalid = errors.New("menus: menu view profile mode is invalid") )
Functions ¶
func NewMenuItemRepository ¶
func NewMenuItemRepository(db *bun.DB) repository.Repository[*MenuItem]
NewMenuItemRepository creates a repository for MenuItem entities.
func NewMenuItemTranslationRepository ¶
func NewMenuItemTranslationRepository(db *bun.DB) repository.Repository[*MenuItemTranslation]
NewMenuItemTranslationRepository creates a repository for MenuItemTranslation entities.
func NewMenuLocationBindingRepository ¶ added in v0.38.0
func NewMenuLocationBindingRepository(db *bun.DB) repository.Repository[*MenuLocationBinding]
NewMenuLocationBindingRepository creates a repository for MenuLocationBinding entities.
func NewMenuRepository ¶
func NewMenuRepository(db *bun.DB) repository.Repository[*Menu]
NewMenuRepository creates a repository for Menu entities.
func NewMenuViewProfileRepository ¶ added in v0.38.0
func NewMenuViewProfileRepository(db *bun.DB) repository.Repository[*MenuViewProfile]
NewMenuViewProfileRepository creates a repository for MenuViewProfile entities.
Types ¶
type AddMenuItemInput ¶
type AddMenuItemInput struct {
ID *uuid.UUID
MenuID uuid.UUID
ParentID *uuid.UUID
// ParentCode allows callers to reference parents using string codes when UUIDs are not available.
ParentCode string
ExternalCode string
CanonicalKey string
// Position is a 0-based insertion index among siblings.
// Values past the end are clamped to append.
Position int
Type string
Target map[string]any
Icon string
Badge map[string]any
Permissions []string
Classes []string
Styles map[string]string
Collapsible bool
Collapsed bool
Metadata map[string]any
CreatedBy uuid.UUID
UpdatedBy uuid.UUID
Translations []MenuItemTranslationInput
AllowMissingTranslations bool
}
AddMenuItemInput captures the data required to register a new menu item.
type AddMenuItemTranslationInput ¶
type AddMenuItemTranslationInput struct {
ItemID uuid.UUID
Locale string
Label string
LabelKey string
GroupTitle string
GroupTitleKey string
URLOverride *string
}
AddMenuItemTranslationInput adds or updates localized metadata for an item.
type BulkReorderMenuItemsInput ¶ added in v0.2.0
type BulkReorderMenuItemsInput struct {
MenuID uuid.UUID
Items []ItemOrder
// UpdatedBy records the actor requesting the reorder for auditing purposes.
UpdatedBy uuid.UUID
// Version optionally captures optimistic-lock metadata for future use.
Version *int
}
ReorderMenuItemsInput defines a new hierarchical ordering for menu items. BulkReorderMenuItemsInput defines a new hierarchical ordering for menu items.
type BunMenuItemRepository ¶
type BunMenuItemRepository struct {
// contains filtered or unexported fields
}
BunMenuItemRepository implements MenuItemRepository with optional caching.
func NewBunMenuItemRepository ¶
func NewBunMenuItemRepository(db *bun.DB) *BunMenuItemRepository
NewBunMenuItemRepository creates a menu item repository without caching.
func NewBunMenuItemRepositoryWithCache ¶
func NewBunMenuItemRepositoryWithCache(db *bun.DB, cacheService cache.CacheService, serializer cache.KeySerializer) *BunMenuItemRepository
NewBunMenuItemRepositoryWithCache creates a menu item repository with caching services.
func (*BunMenuItemRepository) BulkUpdateHierarchy ¶ added in v0.2.0
func (r *BunMenuItemRepository) BulkUpdateHierarchy(ctx context.Context, items []*MenuItem) error
func (*BunMenuItemRepository) BulkUpdateParentLinks ¶ added in v0.10.0
func (r *BunMenuItemRepository) BulkUpdateParentLinks(ctx context.Context, items []*MenuItem) error
func (*BunMenuItemRepository) GetByMenuAndCanonicalKey ¶ added in v0.10.0
func (*BunMenuItemRepository) GetByMenuAndExternalCode ¶ added in v0.10.0
func (*BunMenuItemRepository) InvalidateCache ¶
func (r *BunMenuItemRepository) InvalidateCache(ctx context.Context) error
func (*BunMenuItemRepository) ListByMenu ¶
func (*BunMenuItemRepository) ListChildren ¶
func (*BunMenuItemRepository) ResetMenuContents ¶ added in v0.12.0
type BunMenuItemTranslationRepository ¶
type BunMenuItemTranslationRepository struct {
// contains filtered or unexported fields
}
BunMenuItemTranslationRepository implements MenuItemTranslationRepository with optional caching.
func NewBunMenuItemTranslationRepository ¶
func NewBunMenuItemTranslationRepository(db *bun.DB) *BunMenuItemTranslationRepository
NewBunMenuItemTranslationRepository creates a translation repository without caching.
func NewBunMenuItemTranslationRepositoryWithCache ¶
func NewBunMenuItemTranslationRepositoryWithCache(db *bun.DB, cacheService cache.CacheService, serializer cache.KeySerializer) *BunMenuItemTranslationRepository
NewBunMenuItemTranslationRepositoryWithCache creates a translation repository with caching services.
func (*BunMenuItemTranslationRepository) Create ¶
func (r *BunMenuItemTranslationRepository) Create(ctx context.Context, translation *MenuItemTranslation) (*MenuItemTranslation, error)
func (*BunMenuItemTranslationRepository) GetByMenuItemAndLocale ¶
func (r *BunMenuItemTranslationRepository) GetByMenuItemAndLocale(ctx context.Context, menuItemID uuid.UUID, localeID uuid.UUID) (*MenuItemTranslation, error)
func (*BunMenuItemTranslationRepository) InvalidateCache ¶
func (r *BunMenuItemTranslationRepository) InvalidateCache(ctx context.Context) error
func (*BunMenuItemTranslationRepository) ListByMenuItem ¶
func (r *BunMenuItemTranslationRepository) ListByMenuItem(ctx context.Context, menuItemID uuid.UUID) ([]*MenuItemTranslation, error)
func (*BunMenuItemTranslationRepository) Update ¶
func (r *BunMenuItemTranslationRepository) Update(ctx context.Context, translation *MenuItemTranslation) (*MenuItemTranslation, error)
type BunMenuLocationBindingRepository ¶ added in v0.38.0
type BunMenuLocationBindingRepository struct {
// contains filtered or unexported fields
}
BunMenuLocationBindingRepository implements MenuLocationBindingRepository with optional caching.
func NewBunMenuLocationBindingRepository ¶ added in v0.38.0
func NewBunMenuLocationBindingRepository(db *bun.DB) *BunMenuLocationBindingRepository
NewBunMenuLocationBindingRepository creates a location binding repository without caching.
func NewBunMenuLocationBindingRepositoryWithCache ¶ added in v0.38.0
func NewBunMenuLocationBindingRepositoryWithCache(db *bun.DB, cacheService cache.CacheService, serializer cache.KeySerializer) *BunMenuLocationBindingRepository
NewBunMenuLocationBindingRepositoryWithCache creates a location binding repository with caching.
func (*BunMenuLocationBindingRepository) Create ¶ added in v0.38.0
func (r *BunMenuLocationBindingRepository) Create(ctx context.Context, binding *MenuLocationBinding) (*MenuLocationBinding, error)
func (*BunMenuLocationBindingRepository) GetByID ¶ added in v0.38.0
func (r *BunMenuLocationBindingRepository) GetByID(ctx context.Context, id uuid.UUID) (*MenuLocationBinding, error)
func (*BunMenuLocationBindingRepository) InvalidateCache ¶ added in v0.38.0
func (r *BunMenuLocationBindingRepository) InvalidateCache(ctx context.Context) error
func (*BunMenuLocationBindingRepository) List ¶ added in v0.38.0
func (r *BunMenuLocationBindingRepository) List(ctx context.Context, env ...string) ([]*MenuLocationBinding, error)
func (*BunMenuLocationBindingRepository) ListByLocation ¶ added in v0.38.0
func (r *BunMenuLocationBindingRepository) ListByLocation(ctx context.Context, location string, env ...string) ([]*MenuLocationBinding, error)
func (*BunMenuLocationBindingRepository) Update ¶ added in v0.38.0
func (r *BunMenuLocationBindingRepository) Update(ctx context.Context, binding *MenuLocationBinding) (*MenuLocationBinding, error)
type BunMenuRepository ¶
type BunMenuRepository struct {
// contains filtered or unexported fields
}
BunMenuRepository implements MenuRepository with optional caching.
func NewBunMenuRepository ¶
func NewBunMenuRepository(db *bun.DB) *BunMenuRepository
NewBunMenuRepository creates a menu repository without caching.
func NewBunMenuRepositoryWithCache ¶
func NewBunMenuRepositoryWithCache(db *bun.DB, cacheService cache.CacheService, serializer cache.KeySerializer) *BunMenuRepository
NewBunMenuRepositoryWithCache creates a menu repository with caching services.
func (*BunMenuRepository) GetByLocation ¶ added in v0.19.0
func (*BunMenuRepository) InvalidateCache ¶
func (r *BunMenuRepository) InvalidateCache(ctx context.Context) error
type BunMenuViewProfileRepository ¶ added in v0.38.0
type BunMenuViewProfileRepository struct {
// contains filtered or unexported fields
}
BunMenuViewProfileRepository implements MenuViewProfileRepository with optional caching.
func NewBunMenuViewProfileRepository ¶ added in v0.38.0
func NewBunMenuViewProfileRepository(db *bun.DB) *BunMenuViewProfileRepository
NewBunMenuViewProfileRepository creates a menu view profile repository without caching.
func NewBunMenuViewProfileRepositoryWithCache ¶ added in v0.38.0
func NewBunMenuViewProfileRepositoryWithCache(db *bun.DB, cacheService cache.CacheService, serializer cache.KeySerializer) *BunMenuViewProfileRepository
NewBunMenuViewProfileRepositoryWithCache creates a menu view profile repository with caching.
func (*BunMenuViewProfileRepository) Create ¶ added in v0.38.0
func (r *BunMenuViewProfileRepository) Create(ctx context.Context, profile *MenuViewProfile) (*MenuViewProfile, error)
func (*BunMenuViewProfileRepository) GetByCode ¶ added in v0.38.0
func (r *BunMenuViewProfileRepository) GetByCode(ctx context.Context, code string, env ...string) (*MenuViewProfile, error)
func (*BunMenuViewProfileRepository) GetByID ¶ added in v0.38.0
func (r *BunMenuViewProfileRepository) GetByID(ctx context.Context, id uuid.UUID) (*MenuViewProfile, error)
func (*BunMenuViewProfileRepository) InvalidateCache ¶ added in v0.38.0
func (r *BunMenuViewProfileRepository) InvalidateCache(ctx context.Context) error
func (*BunMenuViewProfileRepository) List ¶ added in v0.38.0
func (r *BunMenuViewProfileRepository) List(ctx context.Context, env ...string) ([]*MenuViewProfile, error)
func (*BunMenuViewProfileRepository) Update ¶ added in v0.38.0
func (r *BunMenuViewProfileRepository) Update(ctx context.Context, profile *MenuViewProfile) (*MenuViewProfile, error)
type ContentMenuMembership ¶ added in v0.38.0
type ContentMenuMembership struct {
ContentID uuid.UUID `json:"content_id"`
ContentTypeID uuid.UUID `json:"content_type_id"`
ContentTypeSlug string `json:"content_type_slug,omitempty"`
ContentSlug string `json:"content_slug,omitempty"`
Location string `json:"location"`
Visible bool `json:"visible"`
Origin string `json:"origin,omitempty"`
VisibilityState string `json:"visibility_state,omitempty"`
MergeMode string `json:"merge_mode,omitempty"`
DuplicatePolicy string `json:"duplicate_policy,omitempty"`
URL string `json:"url,omitempty"`
Label string `json:"label,omitempty"`
SortOrder *int `json:"sort_order,omitempty"`
}
ContentMenuMembership reports computed content contribution membership for a location.
type ContentRepository ¶ added in v0.38.0
type ContentRepository interface {
List(ctx context.Context, env ...content.ContentListOption) ([]*content.Content, error)
}
ContentRepository reads content entries used for content-driven menu contributions.
type ContentTypeRepository ¶ added in v0.38.0
type ContentTypeRepository interface {
List(ctx context.Context, env ...string) ([]*content.ContentType, error)
}
ContentTypeRepository reads content type metadata used for navigation capabilities.
type CreateMenuInput ¶
type CreateMenuInput struct {
Code string
Location string
Description *string
Status string
Locale *string
TranslationID *uuid.UUID
CreatedBy uuid.UUID
UpdatedBy uuid.UUID
EnvironmentKey string
}
CreateMenuInput captures the information required to register a menu.
type DeleteMenuItemRequest ¶ added in v0.2.0
DeleteMenuItemRequest captures the data required to remove a menu item.
type DeleteMenuRequest ¶ added in v0.2.0
type DeleteMenuRequest struct {
MenuID uuid.UUID
DeletedBy uuid.UUID
// Force bypasses guard rails such as theme bindings when true.
Force bool
}
DeleteMenuRequest captures the data required to remove a menu.
type IDGenerator ¶
type IDGenerator func(AddMenuItemInput) uuid.UUID
IDGenerator produces unique identifiers. It receives the normalized AddMenuItemInput so callers can derive deterministic IDs from payload fields.
type LocaleRepository ¶
type LocaleRepository interface {
GetByCode(ctx context.Context, code string) (*content.Locale, error)
}
LocaleRepository resolves locales by code.
type MenuIDDeriver ¶ added in v0.12.0
MenuIDDeriver produces deterministic menu UUIDs from the stable menu code.
type MenuInUseError ¶ added in v0.2.0
type MenuInUseError struct {
MenuID uuid.UUID
Bindings []MenuUsageBinding
}
MenuInUseError surfaces guard-rail failures for menu deletions.
func (*MenuInUseError) Error ¶ added in v0.2.0
func (e *MenuInUseError) Error() string
func (*MenuInUseError) Unwrap ¶ added in v0.2.0
func (e *MenuInUseError) Unwrap() error
type MenuItemRepository ¶
type MenuItemRepository interface {
Create(ctx context.Context, item *MenuItem) (*MenuItem, error)
GetByID(ctx context.Context, id uuid.UUID) (*MenuItem, error)
GetByMenuAndCanonicalKey(ctx context.Context, menuID uuid.UUID, key string) (*MenuItem, error)
GetByMenuAndExternalCode(ctx context.Context, menuID uuid.UUID, code string) (*MenuItem, error)
ListByMenu(ctx context.Context, menuID uuid.UUID) ([]*MenuItem, error)
ListChildren(ctx context.Context, parentID uuid.UUID) ([]*MenuItem, error)
Update(ctx context.Context, item *MenuItem) (*MenuItem, error)
Delete(ctx context.Context, id uuid.UUID) error
// BulkUpdateHierarchy persists parent/position updates for multiple items atomically.
BulkUpdateHierarchy(ctx context.Context, items []*MenuItem) error
// BulkUpdateParentLinks persists parent_id/parent_ref/position updates for multiple items atomically.
BulkUpdateParentLinks(ctx context.Context, items []*MenuItem) error
}
MenuItemRepository exposes persistence operations for menu items.
func NewMemoryMenuItemRepository ¶
func NewMemoryMenuItemRepository() MenuItemRepository
NewMemoryMenuItemRepository constructs an in-memory repository for menu items.
type MenuItemTranslation ¶
type MenuItemTranslation = cmsmenus.MenuItemTranslation
type MenuItemTranslationInput ¶
type MenuItemTranslationInput struct {
Locale string
Label string
LabelKey string
GroupTitle string
GroupTitleKey string
URLOverride *string
}
MenuItemTranslationInput describes localized metadata for a menu item.
type MenuItemTranslationRepository ¶
type MenuItemTranslationRepository interface {
Create(ctx context.Context, translation *MenuItemTranslation) (*MenuItemTranslation, error)
GetByMenuItemAndLocale(ctx context.Context, menuItemID uuid.UUID, localeID uuid.UUID) (*MenuItemTranslation, error)
ListByMenuItem(ctx context.Context, menuItemID uuid.UUID) ([]*MenuItemTranslation, error)
Update(ctx context.Context, translation *MenuItemTranslation) (*MenuItemTranslation, error)
Delete(ctx context.Context, id uuid.UUID) error
}
MenuItemTranslationRepository exposes persistence operations for menu item translations.
func NewMemoryMenuItemTranslationRepository ¶
func NewMemoryMenuItemTranslationRepository() MenuItemTranslationRepository
NewMemoryMenuItemTranslationRepository constructs an in-memory repository for menu item translations.
type MenuLocationBinding ¶ added in v0.38.0
type MenuLocationBinding = cmsmenus.MenuLocationBinding
type MenuLocationBindingRepository ¶ added in v0.38.0
type MenuLocationBindingRepository interface {
Create(ctx context.Context, binding *MenuLocationBinding) (*MenuLocationBinding, error)
GetByID(ctx context.Context, id uuid.UUID) (*MenuLocationBinding, error)
ListByLocation(ctx context.Context, location string, env ...string) ([]*MenuLocationBinding, error)
List(ctx context.Context, env ...string) ([]*MenuLocationBinding, error)
Update(ctx context.Context, binding *MenuLocationBinding) (*MenuLocationBinding, error)
Delete(ctx context.Context, id uuid.UUID) error
}
MenuLocationBindingRepository persists menu location binding records.
func NewMemoryMenuLocationBindingRepository ¶ added in v0.38.0
func NewMemoryMenuLocationBindingRepository() MenuLocationBindingRepository
NewMemoryMenuLocationBindingRepository constructs an in-memory location binding repository.
type MenuQueryOptions ¶ added in v0.38.0
type MenuRepository ¶
type MenuRepository interface {
Create(ctx context.Context, menu *Menu) (*Menu, error)
GetByID(ctx context.Context, id uuid.UUID) (*Menu, error)
GetByCode(ctx context.Context, code string, env ...string) (*Menu, error)
GetByLocation(ctx context.Context, location string, env ...string) (*Menu, error)
List(ctx context.Context, env ...string) ([]*Menu, error)
Update(ctx context.Context, menu *Menu) (*Menu, error)
Delete(ctx context.Context, id uuid.UUID) error
}
MenuRepository exposes persistence operations for menu records.
func NewMemoryMenuRepository ¶
func NewMemoryMenuRepository() MenuRepository
NewMemoryMenuRepository constructs an in-memory repository for menus
type MenuUsageBinding ¶ added in v0.2.0
MenuUsageBinding describes an active menu reference inside a theme/location pair.
type MenuUsageResolver ¶ added in v0.2.0
type MenuUsageResolver interface {
ResolveMenuUsage(ctx context.Context, menuID uuid.UUID) ([]MenuUsageBinding, error)
}
MenuUsageResolver reports whether menus are currently bound to active themes/locations.
type MenuViewProfile ¶ added in v0.38.0
type MenuViewProfile = cmsmenus.MenuViewProfile
type MenuViewProfileRepository ¶ added in v0.38.0
type MenuViewProfileRepository interface {
Create(ctx context.Context, profile *MenuViewProfile) (*MenuViewProfile, error)
GetByID(ctx context.Context, id uuid.UUID) (*MenuViewProfile, error)
GetByCode(ctx context.Context, code string, env ...string) (*MenuViewProfile, error)
List(ctx context.Context, env ...string) ([]*MenuViewProfile, error)
Update(ctx context.Context, profile *MenuViewProfile) (*MenuViewProfile, error)
Delete(ctx context.Context, id uuid.UUID) error
}
MenuViewProfileRepository persists menu view projection profiles.
func NewMemoryMenuViewProfileRepository ¶ added in v0.38.0
func NewMemoryMenuViewProfileRepository() MenuViewProfileRepository
NewMemoryMenuViewProfileRepository constructs an in-memory view profile repository.
type NavigationNode ¶
type NavigationNode struct {
}
NavigationNode represents a localized menu item ready for presentation.
type NotFoundError ¶
NotFoundError is returned when a menu resource cannot be located.
func (*NotFoundError) Error ¶
func (e *NotFoundError) Error() string
type PageRepository ¶
type PageRepository interface {
GetByID(ctx context.Context, id uuid.UUID) (*pages.Page, error)
GetBySlug(ctx context.Context, slug string, env ...string) (*pages.Page, error)
}
PageRepository looks up pages for menu target validation and navigation resolution.
type ParentResolver ¶ added in v0.7.0
type ParentResolver func(ctx context.Context, code string, input AddMenuItemInput) (*uuid.UUID, error)
ParentResolver maps caller-provided parent codes (non-UUID) into UUIDs before validation.
type ReconcileMenuRequest ¶ added in v0.10.0
ReconcileMenuRequest triggers a parent-link reconciliation pass for a menu.
type ReconcileResult ¶ added in v0.10.0
ReconcileResult reports how many items were linked during reconciliation.
type ReorderMenuItemsInput ¶
type ReorderMenuItemsInput = BulkReorderMenuItemsInput
ReorderMenuItemsInput is retained for backward compatibility but mirrors BulkReorderMenuItemsInput. Deprecated: use BulkReorderMenuItemsInput instead.
type ResetMenuCounts ¶ added in v0.12.0
type ResolveRequest ¶
ResolveRequest carries the context required for URL resolvers to build links.
type ResolvedMenu ¶ added in v0.38.0
type ResolvedMenu struct {
Location string `json:"location"`
RequestedLocale string `json:"requested_locale,omitempty"`
ResolvedLocale string `json:"resolved_locale,omitempty"`
Menu *Menu `json:"menu,omitempty"`
Menus []*Menu `json:"menus,omitempty"`
Binding *MenuLocationBinding `json:"binding,omitempty"`
Bindings []*MenuLocationBinding `json:"bindings,omitempty"`
ViewProfile *MenuViewProfile `json:"view_profile,omitempty"`
Items []NavigationNode `json:"items,omitempty"`
ContentMembership []ContentMenuMembership `json:"content_membership,omitempty"`
Preview ResolvedMenuPreview `json:"preview"`
FamilyID *uuid.UUID `json:"family_id,omitempty"`
}
type ResolvedMenuPreview ¶ added in v0.38.0
type ResolvedMenuPreview struct {
IncludeDrafts bool `json:"include_drafts"`
PreviewTokenPresent bool `json:"preview_token_present"`
MenuStatus string `json:"menu_status,omitempty"`
BindingStatus string `json:"binding_status,omitempty"`
ViewProfileStatus string `json:"view_profile_status,omitempty"`
}
type Service ¶
type Service interface {
CreateMenu(ctx context.Context, input CreateMenuInput) (*Menu, error)
GetOrCreateMenu(ctx context.Context, input CreateMenuInput) (*Menu, error)
UpsertMenu(ctx context.Context, input UpsertMenuInput) (*Menu, error)
MenuByCode(ctx context.Context, code string, locale string, opts MenuQueryOptions, env ...string) (*ResolvedMenu, error)
MenuByLocation(ctx context.Context, location string, locale string, opts MenuQueryOptions, env ...string) (*ResolvedMenu, error)
ResolveLocationBinding(ctx context.Context, location, locale string, opts MenuQueryOptions, env ...string) (*MenuLocationBinding, error)
ApplyViewProfile(ctx context.Context, menu *Menu, profileCode string, opts MenuQueryOptions, env ...string) (*Menu, error)
UpsertMenuLocationBinding(ctx context.Context, input UpsertMenuLocationBindingInput) (*MenuLocationBinding, error)
UpsertMenuViewProfile(ctx context.Context, input UpsertMenuViewProfileInput) (*MenuViewProfile, error)
GetMenu(ctx context.Context, id uuid.UUID) (*Menu, error)
GetMenuByCode(ctx context.Context, code string, env ...string) (*Menu, error)
GetMenuByLocation(ctx context.Context, location string, env ...string) (*Menu, error)
DeleteMenu(ctx context.Context, req DeleteMenuRequest) error
ResetMenuByCode(ctx context.Context, code string, actor uuid.UUID, force bool, env ...string) error
AddMenuItem(ctx context.Context, input AddMenuItemInput) (*MenuItem, error)
UpsertMenuItem(ctx context.Context, input UpsertMenuItemInput) (*MenuItem, error)
UpdateMenuItem(ctx context.Context, input UpdateMenuItemInput) (*MenuItem, error)
DeleteMenuItem(ctx context.Context, req DeleteMenuItemRequest) error
BulkReorderMenuItems(ctx context.Context, input BulkReorderMenuItemsInput) ([]*MenuItem, error)
ReconcileMenu(ctx context.Context, req ReconcileMenuRequest) (*ReconcileResult, error)
AddMenuItemTranslation(ctx context.Context, input AddMenuItemTranslationInput) (*MenuItemTranslation, error)
UpsertMenuItemTranslation(ctx context.Context, input UpsertMenuItemTranslationInput) (*MenuItemTranslation, error)
GetMenuItemByExternalCode(ctx context.Context, menuCode string, externalCode string, env ...string) (*MenuItem, error)
InvalidateCache(ctx context.Context) error
}
Service describes menu management capabilities.
func NewService ¶
func NewService(menuRepo MenuRepository, itemRepo MenuItemRepository, trRepo MenuItemTranslationRepository, localeRepo LocaleRepository, opts ...ServiceOption) Service
NewService constructs a menu service instance.
type ServiceOption ¶
type ServiceOption func(*service)
ServiceOption configures menu service behaviour.
func WithActivityEmitter ¶ added in v0.5.0
func WithActivityEmitter(emitter *activity.Emitter) ServiceOption
WithActivityEmitter wires the activity emitter used for activity records.
func WithAuditRecorder ¶ added in v0.12.0
func WithAuditRecorder(recorder jobs.AuditRecorder) ServiceOption
func WithBindingDuplicatePolicy ¶ added in v0.38.0
func WithBindingDuplicatePolicy(policy string) ServiceOption
WithBindingDuplicatePolicy configures how duplicate location bindings are handled.
func WithClock ¶
func WithClock(clock func() time.Time) ServiceOption
WithClock overrides the internal time source.
func WithContentRepository ¶ added in v0.38.0
func WithContentRepository(repo ContentRepository) ServiceOption
WithContentRepository wires the content repository used for content-driven contributions.
func WithContentTypeRepository ¶ added in v0.38.0
func WithContentTypeRepository(repo ContentTypeRepository) ServiceOption
WithContentTypeRepository wires the content-type repository used for contribution capability lookup.
func WithDefaultEnvironmentKey ¶ added in v0.23.1
func WithDefaultEnvironmentKey(key string) ServiceOption
WithDefaultEnvironmentKey overrides the default environment key.
func WithEnvironmentService ¶ added in v0.23.1
func WithEnvironmentService(envSvc cmsenv.Service) ServiceOption
WithEnvironmentService wires the environment service for env resolution.
func WithForgivingMenuBootstrap ¶ added in v0.10.0
func WithForgivingMenuBootstrap(enabled bool) ServiceOption
WithForgivingMenuBootstrap enables order-independent menu seeding: missing parents are deferred, collapsible flags are tolerated until children exist, and reconciliation runs automatically after writes and before navigation resolution.
func WithIDGenerator ¶
func WithIDGenerator(generator IDGenerator) ServiceOption
WithIDGenerator overrides the ID generator.
func WithMaxMenuDepth ¶ added in v0.38.0
func WithMaxMenuDepth(depth int) ServiceOption
WithMaxMenuDepth controls menu hierarchy guard rails. Zero or negative disables depth checks.
func WithMenuIDDeriver ¶ added in v0.12.0
func WithMenuIDDeriver(deriver MenuIDDeriver) ServiceOption
WithMenuIDDeriver overrides menu ID derivation so callers can generate stable UUIDs from menu codes.
func WithMenuLocationBindingRepository ¶ added in v0.38.0
func WithMenuLocationBindingRepository(repo MenuLocationBindingRepository) ServiceOption
WithMenuLocationBindingRepository wires persistent location bindings used by runtime reads.
func WithMenuUsageResolver ¶ added in v0.2.0
func WithMenuUsageResolver(resolver MenuUsageResolver) ServiceOption
WithMenuUsageResolver injects a dependency that reports active menu bindings.
func WithMenuViewProfileRepository ¶ added in v0.38.0
func WithMenuViewProfileRepository(repo MenuViewProfileRepository) ServiceOption
WithMenuViewProfileRepository wires persistent view profiles used for menu projections.
func WithPageRepository ¶
func WithPageRepository(repo PageRepository) ServiceOption
WithPageRepository wires the page repository used for target validation and URL resolution.
func WithParentResolver ¶ added in v0.7.0
func WithParentResolver(resolver ParentResolver) ServiceOption
WithParentResolver wires a resolver used to translate non-UUID parent references into UUIDs.
func WithReconcileOnResolveNavigation ¶ added in v0.10.0
func WithReconcileOnResolveNavigation(enabled bool) ServiceOption
WithReconcileOnResolveNavigation controls whether ResolveNavigation runs reconciliation first.
func WithRecordIDGenerator ¶ added in v0.7.0
func WithRecordIDGenerator(generator func() uuid.UUID) ServiceOption
WithRecordIDGenerator overrides the ID generator used for non-menu-item records (menus, translations). Menu item IDs remain governed by WithIDGenerator.
func WithRequireActiveEnvironment ¶ added in v0.23.1
func WithRequireActiveEnvironment(required bool) ServiceOption
WithRequireActiveEnvironment blocks operations on inactive environments.
func WithRequireExplicitEnvironment ¶ added in v0.23.1
func WithRequireExplicitEnvironment(required bool) ServiceOption
WithRequireExplicitEnvironment enforces explicit environment selection.
func WithRequireTranslations ¶ added in v0.2.0
func WithRequireTranslations(required bool) ServiceOption
WithRequireTranslations controls whether menu items must include translations.
func WithTranslationState ¶ added in v0.16.0
func WithTranslationState(state *translationconfig.State) ServiceOption
WithTranslationState wires a shared, runtime-configurable translation state.
func WithTranslationsEnabled ¶ added in v0.2.0
func WithTranslationsEnabled(enabled bool) ServiceOption
WithTranslationsEnabled toggles translation handling.
func WithURLResolver ¶
func WithURLResolver(resolver URLResolver) ServiceOption
WithURLResolver overrides the default URL resolver used by the menu service.
type URLKitResolver ¶
type URLKitResolver struct {
// contains filtered or unexported fields
}
URLKitResolver resolves menu URLs using a go-urlkit RouteManager.
func NewURLKitResolver ¶
func NewURLKitResolver(opts URLKitResolverOptions) *URLKitResolver
NewURLKitResolver constructs a resolver backed by go-urlkit.
func (*URLKitResolver) Resolve ¶
func (r *URLKitResolver) Resolve(ctx context.Context, req ResolveRequest) (string, error)
Resolve builds a URL using the configured route manager.
type URLKitResolverOptions ¶
type URLKitResolverOptions struct {
Manager *urlkit.RouteManager
DefaultGroup string
LocaleGroups map[string]string
DefaultRoute string
SlugParam string
LocaleParam string
LocaleIDParam string
RouteField string
ParamsField string
QueryField string
}
URLKitResolverOptions configures the go-urlkit backed resolver.
type URLResolver ¶
type URLResolver interface {
Resolve(ctx context.Context, req ResolveRequest) (string, error)
}
URLResolver allows callers to override how menu URLs are generated.
type UpdateMenuItemInput ¶
type UpdateMenuItemInput struct {
ItemID uuid.UUID
Type *string
Target map[string]any
Icon *string
Badge map[string]any
Permissions []string
Classes []string
Styles map[string]string
Collapsible *bool
Collapsed *bool
Metadata map[string]any
// Position is a 0-based insertion index among siblings.
// Values past the end are clamped to append. Nil leaves the current position unchanged.
Position *int
ParentID *uuid.UUID
UpdatedBy uuid.UUID
}
UpdateMenuItemInput captures mutable fields for a menu item.
type UpsertMenuInput ¶ added in v0.10.0
type UpsertMenuInput struct {
Code string
Location string
Description *string
Status string
Locale *string
TranslationID *uuid.UUID
Actor uuid.UUID
EnvironmentKey string
}
UpsertMenuInput captures the information required to create or update a menu by code.
type UpsertMenuItemInput ¶ added in v0.10.0
type UpsertMenuItemInput struct {
MenuID *uuid.UUID
MenuCode string
MenuDescription *string
EnvironmentKey string
// ExternalCode is a stable human-friendly identifier used for both dedupe and parent linking.
ExternalCode string
// CanonicalKey optionally overrides the dedupe key; when empty, it is derived from ExternalCode or the target.
CanonicalKey string
ParentID *uuid.UUID
ParentCode string
// Position is a 0-based insertion index among siblings.
// When nil, new items default to append (clamped to sibling length).
Position *int
Type string
Target map[string]any
Icon string
Badge map[string]any
Permissions []string
Classes []string
Styles map[string]string
Collapsible bool
Collapsed bool
Metadata map[string]any
Actor uuid.UUID
Translations []MenuItemTranslationInput
AllowMissingTranslations bool
}
UpsertMenuItemInput upserts a menu item by canonical identity. It supports resolving the target menu by code and deferring parent links when enabled.
type UpsertMenuItemTranslationInput ¶ added in v0.12.0
type UpsertMenuItemTranslationInput = AddMenuItemTranslationInput
UpsertMenuItemTranslationInput adds or updates localized metadata for an item.