Documentation
¶
Index ¶
- Variables
- type CreatePageDraftRequest
- type CreatePageRequest
- type DeletePageRequest
- type DeletePageTranslationRequest
- type DuplicatePageRequest
- type InvalidLocaleError
- type MovePageRequest
- type Page
- type PageBlockPlacement
- type PagePreview
- type PageTranslation
- type PageTranslationInput
- type PageVersion
- type PageVersionSnapshot
- type PathConflictError
- type PreviewPageDraftRequest
- type PublishPageDraftRequest
- type RestorePageVersionRequest
- type SchedulePageRequest
- type Service
- type SourceNotFoundError
- type TranslationAlreadyExistsError
- type TranslationCheckOptions
- type TranslationInvariantViolationError
- type UpdatePageRequest
- type UpdatePageTranslationRequest
- type WidgetPlacementSnapshot
Constants ¶
This section is empty.
Variables ¶
var ( ErrContentRequired = errors.New("pages: content does not exist") ErrTemplateRequired = errors.New("pages: template is required") ErrSlugRequired = errors.New("pages: slug is required") ErrSlugInvalid = errors.New("pages: slug contains invalid characters") ErrSlugExists = errors.New("pages: slug already exists") ErrPathExists = errors.New("pages: translation path already exists") ErrPathConflict = errors.New("pages: path conflict") ErrUnknownLocale = errors.New("pages: unknown locale") ErrInvalidLocale = errors.New("pages: invalid locale") ErrSourceNotFound = errors.New("pages: source not found") ErrTranslationAlreadyExists = errors.New("pages: translation already exists") ErrTranslationInvariantViolation = errors.New("pages: translation invariant violation") ErrDuplicateLocale = errors.New("pages: duplicate locale provided") ErrParentNotFound = errors.New("pages: parent page not found") ErrNoPageTranslations = errors.New("pages: at least one translation is required") ErrDefaultLocaleRequired = errors.New("pages: default locale translation is required") ErrTemplateUnknown = errors.New("pages: template not found") ErrPageRequired = errors.New("pages: page id required") ErrVersioningDisabled = errors.New("pages: versioning feature disabled") ErrPageVersionRequired = errors.New("pages: version identifier required") ErrVersionAlreadyPublished = errors.New("pages: version already published") ErrVersionRetentionExceeded = errors.New("pages: version retention limit reached") ErrVersionConflict = errors.New("pages: base version mismatch") ErrSchedulingDisabled = errors.New("pages: scheduling feature disabled") ErrScheduleWindowInvalid = errors.New("pages: publish_at must be before unpublish_at") ErrScheduleTimestampInvalid = errors.New("pages: schedule timestamp is invalid") ErrPageMediaReferenceRequired = errors.New("pages: media reference requires id or path") ErrPageSoftDeleteUnsupported = errors.New("pages: soft delete not supported") ErrPageTranslationsDisabled = errors.New("pages: translations feature disabled") ErrPageTranslationNotFound = errors.New("pages: translation not found") ErrPageParentCycle = errors.New("pages: parent assignment creates hierarchy cycle") ErrPageDuplicateSlug = errors.New("pages: unable to determine unique duplicate slug") )
var PageVersionSnapshotSchema = map[string]any{ "type": "object", "properties": map[string]any{ "regions": map[string]any{ "type": "object", "additionalProperties": map[string]any{ "type": "array", "items": map[string]any{ "$ref": "#/$defs/blockPlacement", }, }, }, "blocks": map[string]any{ "type": "array", "items": map[string]any{"$ref": "#/$defs/blockPlacement"}, }, "widgets": map[string]any{ "type": "object", "additionalProperties": map[string]any{ "type": "array", "items": map[string]any{"$ref": "#/$defs/widgetPlacement"}, }, }, "metadata": map[string]any{ "type": "object", "additionalProperties": true, }, "media": map[string]any{ "type": "object", "additionalProperties": map[string]any{ "type": "array", "items": map[string]any{"$ref": "#/$defs/mediaBinding"}, }, }, }, "$defs": map[string]any{ "blockPlacement": map[string]any{ "type": "object", "required": []string{"region", "position", "block_id", "instance_id"}, "properties": map[string]any{ "region": map[string]any{"type": "string"}, "position": map[string]any{ "type": "integer", "minimum": 0, }, "block_id": map[string]any{"type": "string", "format": "uuid"}, "instance_id": map[string]any{"type": "string", "format": "uuid"}, "version": map[string]any{ "type": []any{"integer", "null"}, }, "snapshot": map[string]any{ "type": "object", "additionalProperties": true, }, }, }, "widgetPlacement": map[string]any{ "type": "object", "required": []string{"area", "widget_id", "instance_id"}, "properties": map[string]any{ "area": map[string]any{"type": "string"}, "widget_id": map[string]any{"type": "string", "format": "uuid"}, "instance_id": map[string]any{"type": "string", "format": "uuid"}, "configuration": map[string]any{ "type": "object", "additionalProperties": true, }, }, }, "mediaBinding": map[string]any{ "type": "object", "required": []string{"slot", "reference"}, "properties": map[string]any{ "slot": map[string]any{"type": "string"}, "reference": map[string]any{ "type": "object", "additionalProperties": true, "properties": map[string]any{ "id": map[string]any{"type": "string"}, "path": map[string]any{"type": "string"}, "collection": map[string]any{"type": "string"}, "locale": map[string]any{"type": "string"}, "variant": map[string]any{"type": "string"}, "attributes": map[string]any{ "type": "object", "additionalProperties": true, }, }, }, "renditions": map[string]any{ "type": "array", "items": map[string]any{"type": "string"}, }, "required": map[string]any{ "type": "array", "items": map[string]any{"type": "string"}, }, "locale": map[string]any{"type": "string"}, "fallback_locale": map[string]any{"type": "string"}, "gallery": map[string]any{"type": "boolean"}, "position": map[string]any{ "type": "integer", "minimum": 0, }, "metadata": map[string]any{ "type": "object", "additionalProperties": true, }, }, }, }, }
PageVersionSnapshotSchema documents the JSON schema enforced for page snapshots.
Functions ¶
This section is empty.
Types ¶
type CreatePageDraftRequest ¶ added in v0.33.0
type CreatePageDraftRequest struct {
PageID uuid.UUID
Snapshot PageVersionSnapshot
CreatedBy uuid.UUID
UpdatedBy uuid.UUID
BaseVersion *int
}
CreatePageDraftRequest captures the data required to create a page version draft.
type CreatePageRequest ¶ added in v0.33.0
type CreatePageRequest struct {
ContentID uuid.UUID
TemplateID uuid.UUID
ParentID *uuid.UUID
Slug string
Status string
EnvironmentKey string
CreatedBy uuid.UUID
UpdatedBy uuid.UUID
Translations []PageTranslationInput
AllowMissingTranslations bool
}
CreatePageRequest captures the payload required to create a page.
type DeletePageRequest ¶ added in v0.33.0
DeletePageRequest captures the information required to delete a page.
type DeletePageTranslationRequest ¶ added in v0.33.0
DeletePageTranslationRequest removes a locale from a page.
type DuplicatePageRequest ¶ added in v0.33.0
type DuplicatePageRequest struct {
PageID uuid.UUID
Slug string
ParentID *uuid.UUID
Status string
CreatedBy uuid.UUID
UpdatedBy uuid.UUID
}
DuplicatePageRequest clones a page, allowing optional overrides.
type InvalidLocaleError ¶ added in v0.36.0
type InvalidLocaleError struct {
EntityID uuid.UUID
SourceLocale string
TargetLocale string
Environment string
}
InvalidLocaleError captures invalid locale inputs for translation operations.
func (*InvalidLocaleError) Error ¶ added in v0.36.0
func (e *InvalidLocaleError) Error() string
func (*InvalidLocaleError) Unwrap ¶ added in v0.36.0
func (e *InvalidLocaleError) Unwrap() error
type MovePageRequest ¶ added in v0.33.0
MovePageRequest updates the hierarchical parent for a page.
type Page ¶
type Page struct {
bun.BaseModel `bun:"table:pages,alias:p"`
ID uuid.UUID `bun:",pk,type:uuid" json:"id"`
ContentID uuid.UUID `bun:"content_id,notnull,type:uuid" json:"content_id"`
CurrentVersion int `bun:"current_version,notnull,default:1" json:"current_version"`
PublishedVersion *int `bun:"published_version" json:"published_version,omitempty"`
ParentID *uuid.UUID `bun:"parent_id,type:uuid" json:"parent_id,omitempty"`
TemplateID uuid.UUID `bun:"template_id,notnull,type:uuid" json:"template_id"`
Slug string `bun:"slug,notnull" json:"slug"`
PrimaryLocale string `bun:"primary_locale" json:"primary_locale,omitempty"`
Status string `bun:"status,notnull,default:'draft'" json:"status"`
PublishAt *time.Time `bun:"publish_at,nullzero" json:"publish_at,omitempty"`
UnpublishAt *time.Time `bun:"unpublish_at,nullzero" json:"unpublish_at,omitempty"`
PublishedAt *time.Time `bun:"published_at,nullzero" json:"published_at,omitempty"`
PublishedBy *uuid.UUID `bun:"published_by,type:uuid" json:"published_by,omitempty"`
EnvironmentID uuid.UUID `bun:"environment_id,type:uuid" json:"environment_id,omitempty"`
CreatedBy uuid.UUID `bun:"created_by,notnull,type:uuid" json:"created_by"`
UpdatedBy uuid.UUID `bun:"updated_by,notnull,type:uuid" json:"updated_by"`
DeletedAt *time.Time `bun:"deleted_at,nullzero" json:"deleted_at,omitempty"`
CreatedAt time.Time `bun:"created_at,nullzero,default:current_timestamp" json:"created_at"`
UpdatedAt time.Time `bun:"updated_at,nullzero,default:current_timestamp" json:"updated_at"`
Content *content.Content `bun:"rel:belongs-to,join:content_id=id" json:"content,omitempty"`
Translations []*PageTranslation `bun:"rel:has-many,join:id=page_id" json:"translations,omitempty"`
Versions []*PageVersion `bun:"rel:has-many,join:id=page_id" json:"versions,omitempty"`
Blocks []*blocks.Instance `bun:"-" json:"blocks,omitempty"`
Widgets map[string][]*widgets.ResolvedWidget `bun:"-" json:"widgets,omitempty"`
EffectiveStatus domain.Status `bun:"-" json:"effective_status"`
IsVisible bool `bun:"-" json:"is_visible"`
}
Page captures hierarchical page metadata.
type PageBlockPlacement ¶
type PageBlockPlacement struct {
Region string `json:"region"`
Position int `json:"position"`
BlockID uuid.UUID `json:"block_id"`
InstanceID uuid.UUID `json:"instance_id"`
Version *int `json:"version,omitempty"`
Snapshot map[string]any `json:"snapshot,omitempty"`
}
PageBlockPlacement describes a block instance captured in a snapshot.
type PagePreview ¶ added in v0.33.0
type PagePreview struct {
Page *Page
Version *PageVersion
}
PagePreview bundles a preview record with the requested version snapshot.
type PageTranslation ¶
type PageTranslation struct {
bun.BaseModel `bun:"table:page_translations,alias:pt"`
ID uuid.UUID `bun:",pk,type:uuid" json:"id"`
PageID uuid.UUID `bun:"page_id,notnull,type:uuid" json:"page_id"`
LocaleID uuid.UUID `bun:"locale_id,notnull,type:uuid" json:"locale_id"`
FamilyID *uuid.UUID `bun:"family_id,type:uuid,nullzero" json:"family_id,omitempty"`
Title string `bun:"title,notnull" json:"title"`
Path string `bun:"path,notnull" json:"path"`
SEOTitle *string `bun:"seo_title" json:"seo_title,omitempty"`
SEODescription *string `bun:"seo_description" json:"seo_description,omitempty"`
Summary *string `bun:"summary" json:"summary,omitempty"`
MediaBindings media.BindingSet `bun:"media_bindings,type:jsonb" json:"media_bindings,omitempty"`
ResolvedMedia map[string][]*media.Attachment `bun:"-" json:"media,omitempty"`
Locale string `bun:"-" json:"locale,omitempty"`
DeletedAt *time.Time `bun:"deleted_at,nullzero" json:"deleted_at,omitempty"`
CreatedAt time.Time `bun:"created_at,nullzero,default:current_timestamp" json:"created_at"`
UpdatedAt time.Time `bun:"updated_at,nullzero,default:current_timestamp" json:"updated_at"`
}
PageTranslation stores localized page metadata.
type PageTranslationInput ¶ added in v0.33.0
type PageTranslationInput struct {
Locale string
Title string
Path string
Summary *string
MediaBindings media.BindingSet
}
PageTranslationInput represents localized routing information.
type PageVersion ¶
type PageVersion struct {
bun.BaseModel `bun:"table:page_versions,alias:pv"`
ID uuid.UUID `bun:",pk,type:uuid" json:"id"`
PageID uuid.UUID `bun:"page_id,notnull,type:uuid" json:"page_id"`
Version int `bun:"version,notnull" json:"version"`
Status domain.Status `bun:"status,notnull,default:'draft'" json:"status"`
Snapshot PageVersionSnapshot `bun:"snapshot,type:jsonb,notnull" json:"snapshot"`
DeletedAt *time.Time `bun:"deleted_at,nullzero" json:"deleted_at,omitempty"`
CreatedBy uuid.UUID `bun:"created_by,notnull,type:uuid" json:"created_by"`
CreatedAt time.Time `bun:"created_at,nullzero,default:current_timestamp" json:"created_at"`
PublishedAt *time.Time `bun:"published_at,nullzero" json:"published_at,omitempty"`
PublishedBy *uuid.UUID `bun:"published_by,type:uuid" json:"published_by,omitempty"`
Page *Page `bun:"rel:belongs-to,join:page_id=id" json:"page,omitempty"`
}
PageVersion snapshots structural layout for history/versioning.
type PageVersionSnapshot ¶
type PageVersionSnapshot struct {
Regions map[string][]PageBlockPlacement `json:"regions,omitempty"`
Blocks []PageBlockPlacement `json:"blocks,omitempty"`
Widgets map[string][]WidgetPlacementSnapshot `json:"widgets,omitempty"`
Metadata map[string]any `json:"metadata,omitempty"`
Media media.BindingSet `json:"media,omitempty"`
}
PageVersionSnapshot captures layout, block, and widget placements at publish time.
type PathConflictError ¶ added in v0.36.0
type PathConflictError struct {
EntityID uuid.UUID
SourceLocale string
TargetLocale string
Environment string
Path string
}
PathConflictError captures path conflicts surfaced by create-translation commands.
func (*PathConflictError) Error ¶ added in v0.36.0
func (e *PathConflictError) Error() string
func (*PathConflictError) Unwrap ¶ added in v0.36.0
func (e *PathConflictError) Unwrap() error
type PreviewPageDraftRequest ¶ added in v0.33.0
type PreviewPageDraftRequest struct {
PageID uuid.UUID
Version int
ContentSnapshot *content.ContentVersionSnapshot
}
PreviewPageDraftRequest captures the inputs required to preview a draft version.
type PublishPageDraftRequest ¶ added in v0.33.0
type PublishPageDraftRequest struct {
PageID uuid.UUID
Version int
PublishedBy uuid.UUID
PublishedAt *time.Time
}
PublishPageDraftRequest captures the inputs required to publish a draft version.
type RestorePageVersionRequest ¶ added in v0.33.0
RestorePageVersionRequest captures the request to restore a historical version as a draft.
type SchedulePageRequest ¶ added in v0.33.0
type SchedulePageRequest struct {
PageID uuid.UUID
PublishAt *time.Time
UnpublishAt *time.Time
ScheduledBy uuid.UUID
}
SchedulePageRequest captures scheduling input for page publish/unpublish windows.
type Service ¶ added in v0.33.0
type Service interface {
Create(ctx context.Context, req CreatePageRequest) (*Page, error)
Get(ctx context.Context, id uuid.UUID) (*Page, error)
List(ctx context.Context, env ...string) ([]*Page, error)
CheckTranslations(ctx context.Context, id uuid.UUID, required []string, opts TranslationCheckOptions) ([]string, error)
AvailableLocales(ctx context.Context, id uuid.UUID, opts TranslationCheckOptions) ([]string, error)
Update(ctx context.Context, req UpdatePageRequest) (*Page, error)
Delete(ctx context.Context, req DeletePageRequest) error
UpdateTranslation(ctx context.Context, req UpdatePageTranslationRequest) (*PageTranslation, error)
DeleteTranslation(ctx context.Context, req DeletePageTranslationRequest) error
Move(ctx context.Context, req MovePageRequest) (*Page, error)
Duplicate(ctx context.Context, req DuplicatePageRequest) (*Page, error)
Schedule(ctx context.Context, req SchedulePageRequest) (*Page, error)
CreateDraft(ctx context.Context, req CreatePageDraftRequest) (*PageVersion, error)
PublishDraft(ctx context.Context, req PublishPageDraftRequest) (*PageVersion, error)
PreviewDraft(ctx context.Context, req PreviewPageDraftRequest) (*PagePreview, error)
ListVersions(ctx context.Context, pageID uuid.UUID) ([]*PageVersion, error)
RestoreVersion(ctx context.Context, req RestorePageVersionRequest) (*PageVersion, error)
}
Service describes page management capabilities.
type SourceNotFoundError ¶ added in v0.36.0
SourceNotFoundError captures missing source entity lookups for translation creation.
func (*SourceNotFoundError) Error ¶ added in v0.36.0
func (e *SourceNotFoundError) Error() string
func (*SourceNotFoundError) Unwrap ¶ added in v0.36.0
func (e *SourceNotFoundError) Unwrap() error
type TranslationAlreadyExistsError ¶ added in v0.36.0
type TranslationAlreadyExistsError struct {
EntityID uuid.UUID
SourceLocale string
TargetLocale string
FamilyID *uuid.UUID
ExistingID uuid.UUID
Environment string
}
TranslationAlreadyExistsError captures duplicate translation conflicts.
func (*TranslationAlreadyExistsError) Error ¶ added in v0.36.0
func (e *TranslationAlreadyExistsError) Error() string
func (*TranslationAlreadyExistsError) Unwrap ¶ added in v0.36.0
func (e *TranslationAlreadyExistsError) Unwrap() error
type TranslationCheckOptions ¶ added in v0.33.0
type TranslationCheckOptions = interfaces.TranslationCheckOptions
TranslationCheckOptions configures translation completeness checks.
type TranslationInvariantViolationError ¶ added in v0.36.0
type TranslationInvariantViolationError struct {
EntityID uuid.UUID
SourceLocale string
TargetLocale string
FamilyID *uuid.UUID
Environment string
Message string
}
TranslationInvariantViolationError captures invariant failures in translation grouping operations.
func (*TranslationInvariantViolationError) Error ¶ added in v0.36.0
func (e *TranslationInvariantViolationError) Error() string
func (*TranslationInvariantViolationError) Unwrap ¶ added in v0.36.0
func (e *TranslationInvariantViolationError) Unwrap() error
type UpdatePageRequest ¶ added in v0.33.0
type UpdatePageRequest struct {
ID uuid.UUID
TemplateID *uuid.UUID
Status string
EnvironmentKey string
UpdatedBy uuid.UUID
Translations []PageTranslationInput
AllowMissingTranslations bool
}
UpdatePageRequest captures the mutable fields for an existing page.
type UpdatePageTranslationRequest ¶ added in v0.33.0
type UpdatePageTranslationRequest struct {
PageID uuid.UUID
Locale string
Title string
Path string
Summary *string
MediaBindings media.BindingSet
UpdatedBy uuid.UUID
}
UpdatePageTranslationRequest mutates a specific translation for a page.
type WidgetPlacementSnapshot ¶
type WidgetPlacementSnapshot struct {
Area string `json:"area"`
WidgetID uuid.UUID `json:"widget_id"`
InstanceID uuid.UUID `json:"instance_id"`
Configuration map[string]any `json:"configuration,omitempty"`
}
WidgetPlacementSnapshot describes widget placement state for a snapshot.