cmsboot

package
v0.25.0 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BootstrapMenu

func BootstrapMenu(ctx context.Context, svc CMSMenuService, code string) error

BootstrapMenu ensures a menu exists for a given code.

Types

type CMSBlock

type CMSBlock struct {
	ID             string
	DefinitionID   string
	ContentID      string
	Region         string
	Locale         string
	Status         string
	Data           map[string]any
	Position       int
	BlockType      string
	BlockSchemaKey string
}

CMSBlock represents a block instance attached to content/pages.

type CMSBlockDefinition

type CMSBlockDefinition struct {
	ID              string
	Name            string
	Slug            string
	Type            string
	Description     string
	DescriptionSet  bool
	Icon            string
	IconSet         bool
	Category        string
	CategorySet     bool
	Status          string
	Environment     string
	Schema          map[string]any
	UISchema        map[string]any
	SchemaVersion   string
	MigrationStatus string
	Locale          string
}

CMSBlockDefinition describes a reusable block schema.

type CMSBlockDefinitionVersion added in v0.24.0

type CMSBlockDefinitionVersion struct {
	ID              string
	DefinitionID    string
	SchemaVersion   string
	Schema          map[string]any
	Defaults        map[string]any
	MigrationStatus string
	CreatedAt       time.Time
	UpdatedAt       time.Time
}

CMSBlockDefinitionVersion captures a specific block definition schema version.

type CMSContainer

type CMSContainer interface {
	WidgetService() CMSWidgetService
	MenuService() CMSMenuService
	ContentService() CMSContentService
	ContentTypeService() CMSContentTypeService
}

CMSContainer abstracts CMS services used by admin.

type CMSContent

type CMSContent struct {
	ID                     string
	Title                  string
	Slug                   string
	Locale                 string
	TranslationGroupID     string
	RequestedLocale        string
	ResolvedLocale         string
	AvailableLocales       []string
	MissingRequestedLocale bool
	ContentType            string
	ContentTypeSlug        string
	Status                 string
	Blocks                 []string
	EmbeddedBlocks         []map[string]any
	SchemaVersion          string
	Data                   map[string]any
	Metadata               map[string]any
}

CMSContent represents structured content managed by the CMS.

type CMSContentService

type CMSContentService interface {
	Pages(ctx context.Context, locale string) ([]CMSPage, error)
	Page(ctx context.Context, id, locale string) (*CMSPage, error)
	CreatePage(ctx context.Context, page CMSPage) (*CMSPage, error)
	UpdatePage(ctx context.Context, page CMSPage) (*CMSPage, error)
	DeletePage(ctx context.Context, id string) error
	Contents(ctx context.Context, locale string) ([]CMSContent, error)
	Content(ctx context.Context, id, locale string) (*CMSContent, error)
	CreateContent(ctx context.Context, content CMSContent) (*CMSContent, error)
	UpdateContent(ctx context.Context, content CMSContent) (*CMSContent, error)
	DeleteContent(ctx context.Context, id string) error
	BlockDefinitions(ctx context.Context) ([]CMSBlockDefinition, error)
	CreateBlockDefinition(ctx context.Context, def CMSBlockDefinition) (*CMSBlockDefinition, error)
	UpdateBlockDefinition(ctx context.Context, def CMSBlockDefinition) (*CMSBlockDefinition, error)
	DeleteBlockDefinition(ctx context.Context, id string) error
	BlockDefinitionVersions(ctx context.Context, id string) ([]CMSBlockDefinitionVersion, error)
	BlocksForContent(ctx context.Context, contentID, locale string) ([]CMSBlock, error)
	SaveBlock(ctx context.Context, block CMSBlock) (*CMSBlock, error)
	DeleteBlock(ctx context.Context, id string) error
}

CMSContentService manages pages/blocks backed by the CMS.

type CMSContentType added in v0.23.0

type CMSContentType struct {
	ID                   string
	Name                 string
	Slug                 string
	Description          string
	DescriptionSet       bool
	Environment          string
	Schema               map[string]any
	UISchema             map[string]any
	Capabilities         map[string]any
	ReplaceCapabilities  bool
	Icon                 string
	IconSet              bool
	Status               string
	AllowBreakingChanges bool
	CreatedAt            time.Time
	UpdatedAt            time.Time
}

CMSContentType describes a content type definition.

type CMSContentTypeService added in v0.23.0

type CMSContentTypeService interface {
	ContentTypes(ctx context.Context) ([]CMSContentType, error)
	ContentType(ctx context.Context, id string) (*CMSContentType, error)
	ContentTypeBySlug(ctx context.Context, slug string) (*CMSContentType, error)
	CreateContentType(ctx context.Context, contentType CMSContentType) (*CMSContentType, error)
	UpdateContentType(ctx context.Context, contentType CMSContentType) (*CMSContentType, error)
	DeleteContentType(ctx context.Context, id string) error
}

CMSContentTypeService manages content type definitions.

type CMSMenuService

type CMSMenuService interface {
	CreateMenu(ctx context.Context, code string) (*Menu, error)
	AddMenuItem(ctx context.Context, menuCode string, item MenuItem) error
	UpdateMenuItem(ctx context.Context, menuCode string, item MenuItem) error
	DeleteMenuItem(ctx context.Context, menuCode, id string) error
	ReorderMenu(ctx context.Context, menuCode string, orderedIDs []string) error
	Menu(ctx context.Context, code, locale string) (*Menu, error)
	MenuByLocation(ctx context.Context, location, locale string) (*Menu, error)
}

CMSMenuService manages CMS-backed menus.

type CMSPage

type CMSPage struct {
	ID                     string
	Title                  string
	Slug                   string
	TemplateID             string
	Locale                 string
	TranslationGroupID     string
	RequestedLocale        string
	ResolvedLocale         string
	AvailableLocales       []string
	MissingRequestedLocale bool
	ParentID               string
	Blocks                 []string
	EmbeddedBlocks         []map[string]any
	SchemaVersion          string
	SEO                    map[string]any
	Status                 string
	Data                   map[string]any
	Metadata               map[string]any
	PreviewURL             string
}

CMSPage represents a page managed by the CMS.

type CMSWidgetService

type CMSWidgetService interface {
	RegisterAreaDefinition(ctx context.Context, def WidgetAreaDefinition) error
	RegisterDefinition(ctx context.Context, def WidgetDefinition) error
	DeleteDefinition(ctx context.Context, code string) error
	Areas() []WidgetAreaDefinition
	Definitions() []WidgetDefinition
	SaveInstance(ctx context.Context, instance WidgetInstance) (*WidgetInstance, error)
	DeleteInstance(ctx context.Context, id string) error
	ListInstances(ctx context.Context, filter WidgetInstanceFilter) ([]WidgetInstance, error)
}

CMSWidgetService registers dashboard widget areas/definitions.

type EnsureOptions

type EnsureOptions struct {
	Container          CMSContainer
	WidgetService      CMSWidgetService
	MenuService        CMSMenuService
	ContentService     CMSContentService
	ContentTypeService CMSContentTypeService
	RequireCMS         bool
	BuildContainer     func(context.Context) (CMSContainer, error)
	FallbackContainer  func() CMSContainer
}

EnsureOptions configure CMS container resolution.

type EnsureResult

type EnsureResult struct {
	Container          CMSContainer
	WidgetService      CMSWidgetService
	MenuService        CMSMenuService
	ContentService     CMSContentService
	ContentTypeService CMSContentTypeService
}

EnsureResult returns resolved CMS container/services.

func Ensure

func Ensure(ctx context.Context, opts EnsureOptions) (EnsureResult, error)

Ensure resolves a CMS container and required services, using builders or fallbacks when enabled.

type Menu = navinternal.Menu

Menu represents a simple CMS menu tree.

type MenuItem = navinternal.MenuItem

MenuItem describes a single navigation node.

type TransitionInput added in v0.22.0

type TransitionInput struct {
	EntityID     string
	EntityType   string
	CurrentState string
	Transition   string
	TargetState  string
	ActorID      string
	Metadata     map[string]any
}

TransitionInput captures the data required to run a workflow transition.

type TransitionResult added in v0.22.0

type TransitionResult struct {
	EntityID    string
	EntityType  string
	Transition  string
	FromState   string
	ToState     string
	CompletedAt time.Time
	ActorID     string
	Metadata    map[string]any
}

TransitionResult describes the outcome of a workflow transition.

type WidgetAreaDefinition

type WidgetAreaDefinition = dashinternal.WidgetAreaDefinition

WidgetAreaDefinition captures CMS widget area metadata.

type WidgetDefinition

type WidgetDefinition = dashinternal.WidgetDefinition

WidgetDefinition captures admin widget metadata.

type WidgetInstance

type WidgetInstance = dashinternal.WidgetInstance

WidgetInstance links a widget definition to a specific area/page.

type WidgetInstanceFilter

type WidgetInstanceFilter = dashinternal.WidgetInstanceFilter

WidgetInstanceFilter narrows widget instance queries.

type WorkflowEngine added in v0.22.0

type WorkflowEngine interface {
	// Transition applies the named transition (or explicit state change) to the entity.
	Transition(ctx context.Context, input TransitionInput) (*TransitionResult, error)
	// AvailableTransitions lists the possible transitions from the supplied state.
	AvailableTransitions(ctx context.Context, entityType, state string) ([]WorkflowTransition, error)
}

WorkflowEngine coordinates lifecycle transitions for domain entities.

type WorkflowTransition added in v0.22.0

type WorkflowTransition struct {
	Name        string
	Description string
	From        string
	To          string
	Guard       string
}

WorkflowTransition declares an allowed transition between two states.

Jump to

Keyboard shortcuts

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