pages

package
v0.60.8 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2026 License: MIT Imports: 35 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrContentRequired               = cmspages.ErrContentRequired
	ErrTemplateRequired              = cmspages.ErrTemplateRequired
	ErrSlugRequired                  = cmspages.ErrSlugRequired
	ErrSlugInvalid                   = cmspages.ErrSlugInvalid
	ErrSlugExists                    = cmspages.ErrSlugExists
	ErrPathExists                    = cmspages.ErrPathExists
	ErrPathConflict                  = cmspages.ErrPathConflict
	ErrUnknownLocale                 = cmspages.ErrUnknownLocale
	ErrInvalidLocale                 = cmspages.ErrInvalidLocale
	ErrSourceNotFound                = cmspages.ErrSourceNotFound
	ErrTranslationAlreadyExists      = cmspages.ErrTranslationAlreadyExists
	ErrTranslationInvariantViolation = cmspages.ErrTranslationInvariantViolation
	ErrDuplicateLocale               = cmspages.ErrDuplicateLocale
	ErrParentNotFound                = cmspages.ErrParentNotFound
	ErrNoPageTranslations            = cmspages.ErrNoPageTranslations
	ErrDefaultLocaleRequired         = cmspages.ErrDefaultLocaleRequired
	ErrTemplateUnknown               = cmspages.ErrTemplateUnknown
	ErrPageRequired                  = cmspages.ErrPageRequired
	ErrVersioningDisabled            = cmspages.ErrVersioningDisabled
	ErrPageVersionRequired           = cmspages.ErrPageVersionRequired
	ErrVersionAlreadyPublished       = cmspages.ErrVersionAlreadyPublished
	ErrVersionRetentionExceeded      = cmspages.ErrVersionRetentionExceeded
	ErrVersionConflict               = cmspages.ErrVersionConflict
	ErrSchedulingDisabled            = cmspages.ErrSchedulingDisabled
	ErrScheduleWindowInvalid         = cmspages.ErrScheduleWindowInvalid
	ErrScheduleTimestampInvalid      = cmspages.ErrScheduleTimestampInvalid
	ErrPageMediaReferenceRequired    = cmspages.ErrPageMediaReferenceRequired
	ErrPageSoftDeleteUnsupported     = cmspages.ErrPageSoftDeleteUnsupported
	ErrPageTranslationsDisabled      = cmspages.ErrPageTranslationsDisabled
	ErrPageTranslationNotFound       = cmspages.ErrPageTranslationNotFound
	ErrPageParentCycle               = cmspages.ErrPageParentCycle
	ErrPageDuplicateSlug             = cmspages.ErrPageDuplicateSlug
)
View Source
var PageVersionSnapshotSchema = cmspages.PageVersionSnapshotSchema

Functions

func NewAdminPageDBReadService added in v0.26.0

func NewAdminPageDBReadService(db *bun.DB, pageSvc Service, contentSvc content.Service, locales content.LocaleRepository, opts ...AdminPageReadOption) interfaces.AdminPageReadService

NewAdminPageDBReadService constructs a DB-backed admin page read service.

func NewAdminPageReadService added in v0.26.0

func NewAdminPageReadService(pageSvc Service, contentSvc content.Service, locales content.LocaleRepository, opts ...AdminPageReadOption) interfaces.AdminPageReadService

NewAdminPageReadService constructs the default admin read service.

func NewPageRepository

func NewPageRepository(db *bun.DB) repository.Repository[*Page]

func NewPageTranslationRepository

func NewPageTranslationRepository(db *bun.DB) repository.Repository[*PageTranslation]

func NewPageVersionRepository

func NewPageVersionRepository(db *bun.DB) repository.Repository[*PageVersion]

Types

type AdminPageReadOption added in v0.26.0

type AdminPageReadOption func(*adminPageReadService)

AdminPageReadOption configures the admin read service.

func WithAdminPageReadLogger added in v0.26.0

func WithAdminPageReadLogger(logger interfaces.Logger) AdminPageReadOption

WithAdminPageReadLogger overrides the logger used by the admin read service.

type BunPageRepository

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

func NewBunPageRepository

func NewBunPageRepository(db *bun.DB) *BunPageRepository

func NewBunPageRepositoryWithCache

func NewBunPageRepositoryWithCache(db *bun.DB, cacheService cache.CacheService, keySerializer cache.KeySerializer) *BunPageRepository

NewBunPageRepositoryWithCache constructs a PageRepository backed by bun with optional caching.

func (*BunPageRepository) Create

func (r *BunPageRepository) Create(ctx context.Context, record *Page) (*Page, error)

func (*BunPageRepository) CreateVersion

func (r *BunPageRepository) CreateVersion(ctx context.Context, version *PageVersion) (*PageVersion, error)

func (*BunPageRepository) Delete

func (r *BunPageRepository) Delete(ctx context.Context, id uuid.UUID, hardDelete bool) error

func (*BunPageRepository) GetByID

func (r *BunPageRepository) GetByID(ctx context.Context, id uuid.UUID) (*Page, error)

func (*BunPageRepository) GetBySlug

func (r *BunPageRepository) GetBySlug(ctx context.Context, slug string, env ...string) (*Page, error)

func (*BunPageRepository) GetLatestVersion

func (r *BunPageRepository) GetLatestVersion(ctx context.Context, pageID uuid.UUID) (*PageVersion, error)

func (*BunPageRepository) GetVersion

func (r *BunPageRepository) GetVersion(ctx context.Context, pageID uuid.UUID, number int) (*PageVersion, error)

func (*BunPageRepository) List

func (r *BunPageRepository) List(ctx context.Context, env ...string) ([]*Page, error)

func (*BunPageRepository) ListTranslations added in v0.30.0

func (r *BunPageRepository) ListTranslations(ctx context.Context, pageID uuid.UUID) ([]*PageTranslation, error)

ListTranslations returns translations for a page record.

func (*BunPageRepository) ListVersions

func (r *BunPageRepository) ListVersions(ctx context.Context, pageID uuid.UUID) ([]*PageVersion, error)

func (*BunPageRepository) ReplaceTranslations

func (r *BunPageRepository) ReplaceTranslations(ctx context.Context, pageID uuid.UUID, translations []*PageTranslation) error

func (*BunPageRepository) Update

func (r *BunPageRepository) Update(ctx context.Context, record *Page) (*Page, error)

func (*BunPageRepository) UpdateVersion

func (r *BunPageRepository) UpdateVersion(ctx context.Context, version *PageVersion) (*PageVersion, error)

type ContentRepository

type ContentRepository interface {
	GetByID(ctx context.Context, id uuid.UUID) (*content.Content, error)
}

ContentRepository allows lookups for existing content.

type CreatePageDraftRequest

type CreatePageDraftRequest = cmspages.CreatePageDraftRequest

type CreatePageRequest

type CreatePageRequest = cmspages.CreatePageRequest

type DeletePageRequest

type DeletePageRequest = cmspages.DeletePageRequest

type DeletePageTranslationRequest added in v0.2.0

type DeletePageTranslationRequest = cmspages.DeletePageTranslationRequest

type DuplicatePageRequest added in v0.2.0

type DuplicatePageRequest = cmspages.DuplicatePageRequest

type IDGenerator

type IDGenerator func() uuid.UUID

IDGenerator5 produces unique identifier for page entiteis

type InvalidLocaleError added in v0.36.0

type InvalidLocaleError = cmspages.InvalidLocaleError

type LocaleRepository

type LocaleRepository interface {
	GetByCode(ctx context.Context, code string) (*content.Locale, error)
	GetByID(ctx context.Context, id uuid.UUID) (*content.Locale, error)
}

LocaleRepository resolves locales.

type MemoryPageRepository

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

MemoryPageRepository is an in-memory page store for scaffolding/tests.

func NewMemoryPageRepository

func NewMemoryPageRepository() *MemoryPageRepository

NewMemoryPageRepository constructs the repository.

func (*MemoryPageRepository) Create

func (m *MemoryPageRepository) Create(_ context.Context, record *Page) (*Page, error)

Create inserts the supplied page.

func (*MemoryPageRepository) CreateVersion

func (m *MemoryPageRepository) CreateVersion(_ context.Context, version *PageVersion) (*PageVersion, error)

CreateVersion appends a version to the supplied page.

func (*MemoryPageRepository) Delete

func (m *MemoryPageRepository) Delete(_ context.Context, id uuid.UUID, hardDelete bool) error

Delete removes the page and associated versions when hard delete is requested.

func (*MemoryPageRepository) GetByID

func (m *MemoryPageRepository) GetByID(_ context.Context, id uuid.UUID) (*Page, error)

GetByID retrieves a page by identifier.

func (*MemoryPageRepository) GetBySlug

func (m *MemoryPageRepository) GetBySlug(_ context.Context, slug string, env ...string) (*Page, error)

GetBySlug retrieves a page by slug.

func (*MemoryPageRepository) GetLatestVersion

func (m *MemoryPageRepository) GetLatestVersion(_ context.Context, pageID uuid.UUID) (*PageVersion, error)

GetLatestVersion retrieves the most recent version of a page.

func (*MemoryPageRepository) GetVersion

func (m *MemoryPageRepository) GetVersion(_ context.Context, pageID uuid.UUID, number int) (*PageVersion, error)

GetVersion retrieves a specific version number for a page.

func (*MemoryPageRepository) List

func (m *MemoryPageRepository) List(_ context.Context, env ...string) ([]*Page, error)

List returns every page.

func (*MemoryPageRepository) ListTranslations added in v0.30.0

func (m *MemoryPageRepository) ListTranslations(_ context.Context, pageID uuid.UUID) ([]*PageTranslation, error)

ListTranslations returns stored translations for a page.

func (*MemoryPageRepository) ListVersions

func (m *MemoryPageRepository) ListVersions(_ context.Context, pageID uuid.UUID) ([]*PageVersion, error)

ListVersions returns all recorded versions for a page.

func (*MemoryPageRepository) ReplaceTranslations

func (m *MemoryPageRepository) ReplaceTranslations(_ context.Context, pageID uuid.UUID, translations []*PageTranslation) error

ReplaceTranslations swaps the translations associated with a page.

func (*MemoryPageRepository) Update

func (m *MemoryPageRepository) Update(_ context.Context, record *Page) (*Page, error)

Update persists metadata changes for a page.

func (*MemoryPageRepository) UpdateVersion

func (m *MemoryPageRepository) UpdateVersion(_ context.Context, version *PageVersion) (*PageVersion, error)

UpdateVersion mutates stored metadata for a page version.

type MovePageRequest added in v0.2.0

type MovePageRequest = cmspages.MovePageRequest

type Page

type Page = cmspages.Page

type PageBlockPlacement

type PageBlockPlacement = cmspages.PageBlockPlacement

type PageNotFoundError

type PageNotFoundError struct {
	Key string
}

PageNotFoundError indicates missing page records.

func (*PageNotFoundError) Error

func (e *PageNotFoundError) Error() string

type PagePreview added in v0.21.0

type PagePreview = cmspages.PagePreview

type PageRepository

type PageRepository interface {
	Create(ctx context.Context, record *Page) (*Page, error)
	GetByID(ctx context.Context, id uuid.UUID) (*Page, error)
	GetBySlug(ctx context.Context, slug string, env ...string) (*Page, error)
	List(ctx context.Context, env ...string) ([]*Page, error)
	Update(ctx context.Context, record *Page) (*Page, error)
	ReplaceTranslations(ctx context.Context, pageID uuid.UUID, translations []*PageTranslation) error
	Delete(ctx context.Context, id uuid.UUID, hardDelete bool) error
	CreateVersion(ctx context.Context, version *PageVersion) (*PageVersion, error)
	ListVersions(ctx context.Context, pageID uuid.UUID) ([]*PageVersion, error)
	GetVersion(ctx context.Context, pageID uuid.UUID, number int) (*PageVersion, error)
	GetLatestVersion(ctx context.Context, pageID uuid.UUID) (*PageVersion, error)
	UpdateVersion(ctx context.Context, version *PageVersion) (*PageVersion, error)
}

PageRepository abstracts storage operations for pages.

type PageTranslation

type PageTranslation = cmspages.PageTranslation

type PageTranslationInput

type PageTranslationInput = cmspages.PageTranslationInput

type PageTranslationReader added in v0.30.0

type PageTranslationReader interface {
	ListTranslations(ctx context.Context, pageID uuid.UUID) ([]*PageTranslation, error)
}

PageTranslationReader exposes translation lookups when page records omit translations.

type PageVersion

type PageVersion = cmspages.PageVersion

type PageVersionNotFoundError

type PageVersionNotFoundError struct {
	PageID  uuid.UUID
	Version int
}

func (*PageVersionNotFoundError) Error

func (e *PageVersionNotFoundError) Error() string

type PageVersionSnapshot

type PageVersionSnapshot = cmspages.PageVersionSnapshot

type PathConflictError added in v0.36.0

type PathConflictError = cmspages.PathConflictError

type PreviewPageDraftRequest added in v0.21.0

type PreviewPageDraftRequest = cmspages.PreviewPageDraftRequest

type PublishPageDraftRequest added in v0.33.0

type PublishPageDraftRequest = cmspages.PublishPageDraftRequest

type PublishPagePublishRequest

type PublishPagePublishRequest = cmspages.PublishPageDraftRequest

type RestorePageVersionRequest

type RestorePageVersionRequest = cmspages.RestorePageVersionRequest

type SchedulePageRequest

type SchedulePageRequest = cmspages.SchedulePageRequest

type Service

type Service = cmspages.Service

func NewService

func NewService(pages PageRepository, contentRepo ContentRepository, locales LocaleRepository, opts ...ServiceOption) Service

NewService constructs a page service with the required dependencies.

type ServiceOption

type ServiceOption func(*pageService)

ServiceOption mutates the service configuration.

func WithActivityEmitter added in v0.5.0

func WithActivityEmitter(emitter *activity.Emitter) ServiceOption

WithActivityEmitter wires the activity emitter used for activity records.

func WithBlockService

func WithBlockService(service blocks.Service) ServiceOption

func WithDefaultEnvironmentKey added in v0.23.1

func WithDefaultEnvironmentKey(key string) ServiceOption

WithDefaultEnvironmentKey overrides the default environment key.

func WithDefaultLocale added in v0.20.0

func WithDefaultLocale(locale string, required bool) ServiceOption

WithDefaultLocale sets the locale required for default fallback handling.

func WithEmbeddedBlockBridge added in v0.21.0

func WithEmbeddedBlockBridge(bridge *blocks.EmbeddedBlockBridge) ServiceOption

WithEmbeddedBlockBridge wires an embedded block bridge for read-path fallback.

func WithEnvironmentService added in v0.23.1

func WithEnvironmentService(service cmsenv.Service) ServiceOption

WithEnvironmentService wires the environment service for env resolution.

func WithIDGenerator

func WithIDGenerator(generator IDGenerator) ServiceOption

func WithLifecycleEmitter added in v0.43.0

func WithLifecycleEmitter(emitter *lifecycle.Emitter) ServiceOption

WithLifecycleEmitter wires the lifecycle emitter used for root-record lifecycle events.

func WithLogger

func WithLogger(logger interfaces.Logger) ServiceOption

func WithMediaService

func WithMediaService(svc media.Service) ServiceOption

func WithPageClock

func WithPageClock(clock func() time.Time) ServiceOption

WithPageClock overrides the internal clock.

func WithPageVersionRetentionLimit

func WithPageVersionRetentionLimit(limit int) ServiceOption

WithPageVersionRetentionLimit constrains how many versions are retained per page.

func WithPageVersioningEnabled

func WithPageVersioningEnabled(enabled bool) ServiceOption

WithPageVersioningEnabled toggles versioning specific capabilities.

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 the service enforces translation presence.

func WithScheduler

func WithScheduler(scheduler interfaces.Scheduler) ServiceOption

WithScheduler wires the scheduler used to enqueue publish/unpublish jobs.

func WithSchedulingEnabled

func WithSchedulingEnabled(enabled bool) ServiceOption

WithSchedulingEnabled toggles scheduling workflows.

func WithThemeService

func WithThemeService(svc themes.Service) ServiceOption

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 entirely.

func WithWidgetService

func WithWidgetService(svc widgets.Service) ServiceOption

func WithWorkflowEngine added in v0.2.0

func WithWorkflowEngine(engine interfaces.WorkflowEngine) ServiceOption

WithWorkflowEngine wires the workflow engine responsible for state transitions.

type SourceNotFoundError added in v0.36.0

type SourceNotFoundError = cmspages.SourceNotFoundError

type TranslationAlreadyExistsError added in v0.36.0

type TranslationAlreadyExistsError = cmspages.TranslationAlreadyExistsError

type TranslationCheckOptions added in v0.33.0

type TranslationCheckOptions = cmspages.TranslationCheckOptions

type TranslationInvariantViolationError added in v0.36.0

type TranslationInvariantViolationError = cmspages.TranslationInvariantViolationError

type UpdatePageRequest

type UpdatePageRequest = cmspages.UpdatePageRequest

type UpdatePageTranslationRequest added in v0.2.0

type UpdatePageTranslationRequest = cmspages.UpdatePageTranslationRequest

type WidgetPlacementSnapshot

type WidgetPlacementSnapshot = cmspages.WidgetPlacementSnapshot

Jump to

Keyboard shortcuts

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