content

package
v0.42.0 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2026 License: MIT Imports: 31 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ContentTypeStatusDraft      = cmscontent.ContentTypeStatusDraft
	ContentTypeStatusActive     = cmscontent.ContentTypeStatusActive
	ContentTypeStatusDeprecated = cmscontent.ContentTypeStatusDeprecated
)
View Source
const (
	// EmbeddedBlocksKey is the payload key holding embedded blocks.
	EmbeddedBlocksKey = "blocks"
	// EmbeddedBlockTypeKey identifies the block type discriminator.
	EmbeddedBlockTypeKey = "_type"
	// EmbeddedBlockSchemaKey tracks the block schema version.
	EmbeddedBlockSchemaKey = "_schema"
	// EmbeddedBlockMetaKey stores system metadata alongside embedded blocks.
	EmbeddedBlockMetaKey = "_cms"
)
View Source
const (
	ConflictEmbeddedMissing = "embedded_missing"
	ConflictLegacyMissing   = "legacy_missing"
	ConflictTypeMismatch    = "type_mismatch"
	ConflictSchemaMismatch  = "schema_mismatch"
	ConflictContentMismatch = "content_mismatch"
	ConflictConfigMismatch  = "configuration_mismatch"
	ConflictAttrsMismatch   = "attribute_overrides_mismatch"
	ConflictMediaMismatch   = "media_bindings_mismatch"
)
View Source
const (
	NavigationStateInherit = "inherit"
	NavigationStateShow    = "show"
	NavigationStateHide    = "hide"

	NavigationOriginDefault  = "default"
	NavigationOriginOverride = "override"

	NavigationMergeAppend  = "append"
	NavigationMergePrepend = "prepend"
	NavigationMergeReplace = "replace"

	NavigationDuplicateByURL    = "by_url"
	NavigationDuplicateByTarget = "by_target"
	NavigationDuplicateNone     = "none"
)
View Source
const (
	ContentProjectionAdmin         = cmscontent.ContentProjectionAdmin
	ContentProjectionDerivedFields = cmscontent.ContentProjectionDerivedFields

	ProjectionTranslationModeAutoLoad = cmscontent.ProjectionTranslationModeAutoLoad
	ProjectionTranslationModeNoop     = cmscontent.ProjectionTranslationModeNoop
	ProjectionTranslationModeError    = cmscontent.ProjectionTranslationModeError

	TranslationConflictStrict = cmscontent.TranslationConflictStrict
)

Variables

View Source
var (
	ErrContentTypeSlugRequired = errors.New("content type: slug is required")
	ErrContentTypeSlugExists   = errors.New("content type: slug already exists")
)
View Source
var (
	ErrContentTypeRequired                   = cmscontent.ErrContentTypeRequired
	ErrSlugRequired                          = cmscontent.ErrSlugRequired
	ErrSlugInvalid                           = cmscontent.ErrSlugInvalid
	ErrSlugExists                            = cmscontent.ErrSlugExists
	ErrSlugConflict                          = cmscontent.ErrSlugConflict
	ErrNoTranslations                        = cmscontent.ErrNoTranslations
	ErrDefaultLocaleRequired                 = cmscontent.ErrDefaultLocaleRequired
	ErrDuplicateLocale                       = cmscontent.ErrDuplicateLocale
	ErrUnknownLocale                         = cmscontent.ErrUnknownLocale
	ErrInvalidLocale                         = cmscontent.ErrInvalidLocale
	ErrSourceNotFound                        = cmscontent.ErrSourceNotFound
	ErrTranslationAlreadyExists              = cmscontent.ErrTranslationAlreadyExists
	ErrTranslationInvariantViolation         = cmscontent.ErrTranslationInvariantViolation
	ErrContentSchemaInvalid                  = cmscontent.ErrContentSchemaInvalid
	ErrContentSoftDeleteUnsupported          = cmscontent.ErrContentSoftDeleteUnsupported
	ErrContentIDRequired                     = cmscontent.ErrContentIDRequired
	ErrContentMetadataInvalid                = cmscontent.ErrContentMetadataInvalid
	ErrVersioningDisabled                    = cmscontent.ErrVersioningDisabled
	ErrContentVersionRequired                = cmscontent.ErrContentVersionRequired
	ErrContentVersionConflict                = cmscontent.ErrContentVersionConflict
	ErrContentVersionAlreadyPublished        = cmscontent.ErrContentVersionAlreadyPublished
	ErrContentVersionRetentionExceeded       = cmscontent.ErrContentVersionRetentionExceeded
	ErrSchedulingDisabled                    = cmscontent.ErrSchedulingDisabled
	ErrScheduleWindowInvalid                 = cmscontent.ErrScheduleWindowInvalid
	ErrScheduleTimestampInvalid              = cmscontent.ErrScheduleTimestampInvalid
	ErrContentTranslationsDisabled           = cmscontent.ErrContentTranslationsDisabled
	ErrContentTranslationNotFound            = cmscontent.ErrContentTranslationNotFound
	ErrContentSchemaMigrationRequired        = cmscontent.ErrContentSchemaMigrationRequired
	ErrContentTranslationLookupUnsupported   = cmscontent.ErrContentTranslationLookupUnsupported
	ErrContentProjectionModeInvalid          = cmscontent.ErrContentProjectionModeInvalid
	ErrContentProjectionUnsupported          = cmscontent.ErrContentProjectionUnsupported
	ErrContentProjectionRequiresTranslations = cmscontent.ErrContentProjectionRequiresTranslations
	ErrEmbeddedBlocksResolverMissing         = cmscontent.ErrEmbeddedBlocksResolverMissing

	ErrContentTypeNameRequired        = cmscontent.ErrContentTypeNameRequired
	ErrContentTypeSchemaRequired      = cmscontent.ErrContentTypeSchemaRequired
	ErrContentTypeSchemaInvalid       = cmscontent.ErrContentTypeSchemaInvalid
	ErrContentTypeIDRequired          = cmscontent.ErrContentTypeIDRequired
	ErrContentTypeSlugInvalid         = cmscontent.ErrContentTypeSlugInvalid
	ErrContentTypeSchemaVersion       = cmscontent.ErrContentTypeSchemaVersion
	ErrContentTypeSchemaBreaking      = cmscontent.ErrContentTypeSchemaBreaking
	ErrContentTypeStatusInvalid       = cmscontent.ErrContentTypeStatusInvalid
	ErrContentTypeStatusChange        = cmscontent.ErrContentTypeStatusChange
	ErrContentTypeCapabilitiesInvalid = cmscontent.ErrContentTypeCapabilitiesInvalid
)
View Source
var ContentVersionSnapshotSchema = cmscontent.ContentVersionSnapshotSchema

Functions

func ApplyNavigationVisibilityMetadata added in v0.38.0

func ApplyNavigationVisibilityMetadata(record *Content)

ApplyNavigationVisibilityMetadata injects effective visibility metadata on read payloads.

func ApplyNavigationVisibilityToMetadata added in v0.38.0

func ApplyNavigationVisibilityToMetadata(contentType *ContentType, metadata map[string]any) map[string]any

ApplyNavigationVisibilityToMetadata computes navigation metadata for writes.

func DeriveContentTypeSlug added in v0.20.0

func DeriveContentTypeSlug(ct *ContentType) string

DeriveContentTypeSlug derives a deterministic slug for backfill/seed flows. Prefers explicit slug, then schema metadata, then normalized name.

func ExtractEmbeddedBlocks added in v0.21.0

func ExtractEmbeddedBlocks(payload map[string]any) ([]map[string]any, bool)

ExtractEmbeddedBlocks returns embedded block payloads from a translation content map.

func MergeEmbeddedBlocks added in v0.21.0

func MergeEmbeddedBlocks(payload map[string]any, blocks []map[string]any) map[string]any

MergeEmbeddedBlocks applies a blocks slice to the content payload, returning a copy.

func NewContentRepository

func NewContentRepository(db *bun.DB) repository.Repository[*Content]

func NewContentTranslationRepository

func NewContentTranslationRepository(db *bun.DB) repository.Repository[*ContentTranslation]

func NewContentTypeRepository

func NewContentTypeRepository(db *bun.DB) repository.Repository[*ContentType]

func NewContentVersionRepository

func NewContentVersionRepository(db *bun.DB) repository.Repository[*ContentVersion]

NewContentVersionRepository creates a repository for ContentVersion entities.

func NewLocaleRepository

func NewLocaleRepository(db *bun.DB) repository.Repository[*Locale]

func NormalizeLocale added in v0.21.0

func NormalizeLocale(code string) string

NormalizeLocale trims and lowercases locale codes for comparison.

func NormalizeNavigationOverrides added in v0.38.0

func NormalizeNavigationOverrides(raw any) (map[string]string, error)

NormalizeNavigationOverrides normalizes record-level _navigation tri-state overrides.

func SanitizeEmbeddedBlocks added in v0.21.0

func SanitizeEmbeddedBlocks(payload map[string]any) map[string]any

SanitizeEmbeddedBlocks removes system metadata keys from embedded blocks for validation.

Types

type BunContentRepository

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

func NewBunContentRepository

func NewBunContentRepository(db *bun.DB) *BunContentRepository

func NewBunContentRepositoryWithCache

func NewBunContentRepositoryWithCache(db *bun.DB, cacheService cache.CacheService, keySerializer cache.KeySerializer) *BunContentRepository

func (*BunContentRepository) Create

func (r *BunContentRepository) Create(ctx context.Context, record *Content) (*Content, error)

func (*BunContentRepository) CreateTranslation added in v0.36.0

func (r *BunContentRepository) CreateTranslation(ctx context.Context, contentID uuid.UUID, translation *ContentTranslation) (*ContentTranslation, error)

func (*BunContentRepository) CreateVersion

func (r *BunContentRepository) CreateVersion(ctx context.Context, version *ContentVersion) (*ContentVersion, error)

func (*BunContentRepository) Delete

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

func (*BunContentRepository) GetByID

func (r *BunContentRepository) GetByID(ctx context.Context, id uuid.UUID) (*Content, error)

func (*BunContentRepository) GetBySlug

func (r *BunContentRepository) GetBySlug(ctx context.Context, slug string, contentTypeID uuid.UUID, env ...string) (*Content, error)

func (*BunContentRepository) GetLatestVersion

func (r *BunContentRepository) GetLatestVersion(ctx context.Context, contentID uuid.UUID) (*ContentVersion, error)

func (*BunContentRepository) GetVersion

func (r *BunContentRepository) GetVersion(ctx context.Context, contentID uuid.UUID, number int) (*ContentVersion, error)

func (*BunContentRepository) List

func (*BunContentRepository) ListTranslations added in v0.21.0

func (r *BunContentRepository) ListTranslations(ctx context.Context, contentID uuid.UUID) ([]*ContentTranslation, error)

ListTranslations returns translations for a content record.

func (*BunContentRepository) ListVersions

func (r *BunContentRepository) ListVersions(ctx context.Context, contentID uuid.UUID) ([]*ContentVersion, error)

func (*BunContentRepository) ReplaceTranslations

func (r *BunContentRepository) ReplaceTranslations(ctx context.Context, contentID uuid.UUID, translations []*ContentTranslation) error

func (*BunContentRepository) Update

func (r *BunContentRepository) Update(ctx context.Context, record *Content) (*Content, error)

func (*BunContentRepository) UpdateVersion

func (r *BunContentRepository) UpdateVersion(ctx context.Context, version *ContentVersion) (*ContentVersion, error)

type BunContentTypeRepository

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

func NewBunContentTypeRepository

func NewBunContentTypeRepository(db *bun.DB) *BunContentTypeRepository

func NewBunContentTypeRepositoryWithCache

func NewBunContentTypeRepositoryWithCache(db *bun.DB, cacheService cache.CacheService, keySerializer cache.KeySerializer) *BunContentTypeRepository

func (*BunContentTypeRepository) Create added in v0.20.0

func (*BunContentTypeRepository) Delete added in v0.20.0

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

func (*BunContentTypeRepository) GetByID

func (*BunContentTypeRepository) GetBySlug added in v0.20.0

func (r *BunContentTypeRepository) GetBySlug(ctx context.Context, slug string, env ...string) (*ContentType, error)

func (*BunContentTypeRepository) List added in v0.20.0

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

func (*BunContentTypeRepository) Search added in v0.20.0

func (r *BunContentTypeRepository) Search(ctx context.Context, query string, env ...string) ([]*ContentType, error)

func (*BunContentTypeRepository) Update added in v0.20.0

type BunLocaleRepository

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

func NewBunLocaleRepository

func NewBunLocaleRepository(db *bun.DB) *BunLocaleRepository

func NewBunLocaleRepositoryWithCache

func NewBunLocaleRepositoryWithCache(db *bun.DB, cacheService cache.CacheService, keySerializer cache.KeySerializer) *BunLocaleRepository

NewBunLocaleRepositoryWithCache constructs a LocaleRepository with optional caching.

func (*BunLocaleRepository) GetByCode

func (r *BunLocaleRepository) GetByCode(ctx context.Context, code string) (*Locale, error)

func (*BunLocaleRepository) GetByID added in v0.30.0

func (r *BunLocaleRepository) GetByID(ctx context.Context, id uuid.UUID) (*Locale, error)

func (*BunLocaleRepository) List added in v0.42.0

func (r *BunLocaleRepository) List(ctx context.Context) ([]*Locale, error)

type Content

type Content = cmscontent.Content

type ContentGetOption added in v0.31.0

type ContentGetOption = cmscontent.ContentGetOption

ContentGetOption configures content get behavior. It reuses list option tokens.

type ContentListOption added in v0.30.1

type ContentListOption = cmscontent.ContentListOption

ContentListOption configures content list behavior. It is an alias to string to preserve the existing List(ctx, env ...string) call pattern.

func WithDerivedFields added in v0.35.0

func WithDerivedFields() ContentListOption

WithDerivedFields enables the canonical derived-content-fields projection.

func WithProjection added in v0.35.0

func WithProjection(name string) ContentListOption

WithProjection configures a named projection for list/get reads.

func WithProjectionMode added in v0.35.0

func WithProjectionMode(mode ProjectionTranslationMode) ContentListOption

WithProjectionMode controls projection behavior when translations are not loaded.

func WithTranslations added in v0.30.1

func WithTranslations() ContentListOption

WithTranslations preloads translations when listing content records.

type ContentPreview added in v0.21.0

type ContentPreview = cmscontent.ContentPreview

type ContentRepository

type ContentRepository interface {
	Create(ctx context.Context, record *Content) (*Content, error)
	GetByID(ctx context.Context, id uuid.UUID) (*Content, error)
	GetBySlug(ctx context.Context, slug string, contentTypeID uuid.UUID, env ...string) (*Content, error)
	List(ctx context.Context, env ...ContentListOption) ([]*Content, error)
	Update(ctx context.Context, record *Content) (*Content, error)
	CreateTranslation(ctx context.Context, contentID uuid.UUID, translation *ContentTranslation) (*ContentTranslation, error)
	ReplaceTranslations(ctx context.Context, contentID uuid.UUID, translations []*ContentTranslation) error
	Delete(ctx context.Context, id uuid.UUID, hardDelete bool) error
	CreateVersion(ctx context.Context, version *ContentVersion) (*ContentVersion, error)
	ListVersions(ctx context.Context, contentID uuid.UUID) ([]*ContentVersion, error)
	GetVersion(ctx context.Context, contentID uuid.UUID, number int) (*ContentVersion, error)
	GetLatestVersion(ctx context.Context, contentID uuid.UUID) (*ContentVersion, error)
	UpdateVersion(ctx context.Context, version *ContentVersion) (*ContentVersion, error)
}

ContentRepository abstracts storage operations for content entities.

type ContentTranslation

type ContentTranslation = cmscontent.ContentTranslation

type ContentTranslationInput

type ContentTranslationInput = cmscontent.ContentTranslationInput

type ContentTranslationReader added in v0.21.0

type ContentTranslationReader interface {
	ListTranslations(ctx context.Context, contentID uuid.UUID) ([]*ContentTranslation, error)
}

ContentTranslationReader exposes translation lookups without replacing the core repository interface.

type ContentType

type ContentType = cmscontent.ContentType

type ContentTypeCapabilityValidationError added in v0.38.0

type ContentTypeCapabilityValidationError = cmscontent.ContentTypeCapabilityValidationError

type ContentTypeOption added in v0.20.0

type ContentTypeOption func(*contentTypeService)

ContentTypeOption mutates the content type service.

func WithContentTypeActivityEmitter added in v0.23.0

func WithContentTypeActivityEmitter(emitter *activity.Emitter) ContentTypeOption

WithContentTypeActivityEmitter overrides the activity emitter for content types.

func WithContentTypeClock added in v0.20.0

func WithContentTypeClock(clock func() time.Time) ContentTypeOption

WithContentTypeClock overrides the clock used by the service.

func WithContentTypeDefaultEnvironmentKey added in v0.23.1

func WithContentTypeDefaultEnvironmentKey(key string) ContentTypeOption

WithContentTypeDefaultEnvironmentKey overrides the default environment key.

func WithContentTypeEnvironmentService added in v0.23.1

func WithContentTypeEnvironmentService(service cmsenv.Service) ContentTypeOption

WithContentTypeEnvironmentService wires the environment service for env resolution.

func WithContentTypeIDGenerator added in v0.20.0

func WithContentTypeIDGenerator(generator IDGenerator) ContentTypeOption

WithContentTypeIDGenerator overrides the ID generator used by the service.

func WithContentTypeRequireActiveEnvironment added in v0.23.1

func WithContentTypeRequireActiveEnvironment(required bool) ContentTypeOption

WithContentTypeRequireActiveEnvironment blocks operations on inactive environments.

func WithContentTypeRequireExplicitEnvironment added in v0.23.1

func WithContentTypeRequireExplicitEnvironment(required bool) ContentTypeOption

WithContentTypeRequireExplicitEnvironment enforces explicit environment selection.

func WithContentTypeSlugNormalizer added in v0.20.0

func WithContentTypeSlugNormalizer(normalizer slug.Normalizer) ContentTypeOption

WithContentTypeSlugNormalizer overrides the slug normalizer used by the service.

func WithContentTypeValidators added in v0.23.0

func WithContentTypeValidators(validators ...ContentTypeValidator) ContentTypeOption

WithContentTypeValidators appends validators applied on create/update.

type ContentTypeRepository

type ContentTypeRepository interface {
	Create(ctx context.Context, record *ContentType) (*ContentType, error)
	GetByID(ctx context.Context, id uuid.UUID) (*ContentType, error)
	GetBySlug(ctx context.Context, slug string, env ...string) (*ContentType, error)
	List(ctx context.Context, env ...string) ([]*ContentType, error)
	Search(ctx context.Context, query string, env ...string) ([]*ContentType, error)
	Update(ctx context.Context, record *ContentType) (*ContentType, error)
	Delete(ctx context.Context, id uuid.UUID, hardDelete bool) error
}

ContentTypeRepository resolves content types.

type ContentTypeSchemaSnapshot added in v0.23.0

type ContentTypeSchemaSnapshot = cmscontent.ContentTypeSchemaSnapshot

type ContentTypeService added in v0.20.0

type ContentTypeService = cmscontent.ContentTypeService

func NewContentTypeService added in v0.20.0

func NewContentTypeService(repo ContentTypeRepository, opts ...ContentTypeOption) ContentTypeService

NewContentTypeService constructs a content type service.

type ContentTypeValidator added in v0.23.0

type ContentTypeValidator func(ctx context.Context, record *ContentType) error

ContentTypeValidator runs custom validation logic for content types.

type ContentVersion

type ContentVersion = cmscontent.ContentVersion

type ContentVersionSnapshot

type ContentVersionSnapshot = cmscontent.ContentVersionSnapshot

type CreateContentDraftRequest

type CreateContentDraftRequest = cmscontent.CreateContentDraftRequest

type CreateContentRequest

type CreateContentRequest = cmscontent.CreateContentRequest

type CreateContentTranslationRequest added in v0.36.0

type CreateContentTranslationRequest = cmscontent.CreateContentTranslationRequest

type CreateContentTypeRequest added in v0.20.0

type CreateContentTypeRequest = cmscontent.CreateContentTypeRequest

type DeleteContentRequest

type DeleteContentRequest = cmscontent.DeleteContentRequest

type DeleteContentTranslationRequest added in v0.2.0

type DeleteContentTranslationRequest = cmscontent.DeleteContentTranslationRequest

type DeleteContentTypeRequest added in v0.20.0

type DeleteContentTypeRequest = cmscontent.DeleteContentTypeRequest

type EmbeddedBlockConflict added in v0.21.0

type EmbeddedBlockConflict struct {
	ContentID        uuid.UUID      `json:"content_id"`
	PageID           uuid.UUID      `json:"page_id"`
	Locale           string         `json:"locale,omitempty"`
	Region           string         `json:"region,omitempty"`
	Index            int            `json:"index,omitempty"`
	Issue            string         `json:"issue"`
	EmbeddedType     string         `json:"embedded_type,omitempty"`
	LegacyType       string         `json:"legacy_type,omitempty"`
	EmbeddedSchema   string         `json:"embedded_schema,omitempty"`
	LegacySchema     string         `json:"legacy_schema,omitempty"`
	LegacyInstanceID uuid.UUID      `json:"legacy_instance_id,omitempty"`
	Details          map[string]any `json:"details,omitempty"`
}

EmbeddedBlockConflict describes mismatches between embedded and legacy block payloads.

type EmbeddedBlockValidationError added in v0.21.0

type EmbeddedBlockValidationError struct {
	Mode   EmbeddedBlockValidationMode
	Issues []EmbeddedBlockValidationIssue
}

EmbeddedBlockValidationError aggregates embedded block validation failures.

func (*EmbeddedBlockValidationError) Error added in v0.21.0

type EmbeddedBlockValidationIssue added in v0.21.0

type EmbeddedBlockValidationIssue struct {
	Locale  string `json:"locale,omitempty"`
	Index   int    `json:"index,omitempty"`
	Type    string `json:"type,omitempty"`
	Schema  string `json:"schema,omitempty"`
	Field   string `json:"field,omitempty"`
	Message string `json:"message,omitempty"`
}

EmbeddedBlockValidationIssue captures validation failures with block context.

type EmbeddedBlockValidationMode added in v0.21.0

type EmbeddedBlockValidationMode string

EmbeddedBlockValidationMode controls how strict validation should be.

const (
	EmbeddedBlockValidationDraft  EmbeddedBlockValidationMode = "draft"
	EmbeddedBlockValidationStrict EmbeddedBlockValidationMode = "strict"
)

type EmbeddedBlocksResolver added in v0.21.0

type EmbeddedBlocksResolver interface {
	SyncEmbeddedBlocks(ctx context.Context, contentID uuid.UUID, translations []ContentTranslationInput, actor uuid.UUID) error
	MergeLegacyBlocks(ctx context.Context, record *Content) error
	MigrateEmbeddedBlocks(ctx context.Context, locale string, blocks []map[string]any) ([]map[string]any, error)
	ValidateEmbeddedBlocks(ctx context.Context, locale string, blocks []map[string]any, mode EmbeddedBlockValidationMode) error
	ValidateBlockAvailability(ctx context.Context, contentType string, availability cmsschema.BlockAvailability, blocks []map[string]any) error
}

EmbeddedBlocksResolver bridges embedded blocks to legacy block instances.

type IDGenerator

type IDGenerator func() uuid.UUID

IDGenerator returns the identifier used for newly created records.

type InvalidLocaleError added in v0.36.0

type InvalidLocaleError = cmscontent.InvalidLocaleError

type Locale

type Locale = cmscontent.Locale

type LocaleRepository

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

LocaleRepository resolves locales by code.

type MemoryContentRepository

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

MemoryContentRepository is an "in memory" implementation for scaffolding and tests.

func NewMemoryContentRepository

func NewMemoryContentRepository() *MemoryContentRepository

NewMemoryContentRepository creates an empty "in memory" content repository.

func (*MemoryContentRepository) Create

func (m *MemoryContentRepository) Create(_ context.Context, record *Content) (*Content, error)

Create inserts the supplied content.

func (*MemoryContentRepository) CreateTranslation added in v0.36.0

func (m *MemoryContentRepository) CreateTranslation(_ context.Context, contentID uuid.UUID, translation *ContentTranslation) (*ContentTranslation, error)

CreateTranslation inserts a single translation for an existing content record.

func (*MemoryContentRepository) CreateVersion

func (m *MemoryContentRepository) CreateVersion(_ context.Context, version *ContentVersion) (*ContentVersion, error)

CreateVersion appends a new version snapshot for the supplied content entity.

func (*MemoryContentRepository) Delete

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

Delete removes the content record and its associated versions when hard delete is requested.

func (*MemoryContentRepository) GetByID

GetByID retrieves content by identifier.

func (*MemoryContentRepository) GetBySlug

func (m *MemoryContentRepository) GetBySlug(_ context.Context, slug string, contentTypeID uuid.UUID, env ...string) (*Content, error)

GetBySlug retrieves content by slug, returning NotFoundError when absent.

func (*MemoryContentRepository) GetLatestVersion

func (m *MemoryContentRepository) GetLatestVersion(_ context.Context, contentID uuid.UUID) (*ContentVersion, error)

GetLatestVersion retrieves the most recent version for a content entity.

func (*MemoryContentRepository) GetVersion

func (m *MemoryContentRepository) GetVersion(_ context.Context, contentID uuid.UUID, number int) (*ContentVersion, error)

GetVersion retrieves a specific content version by number.

func (*MemoryContentRepository) List

List returns all content entries.

func (*MemoryContentRepository) ListTranslations added in v0.21.0

func (m *MemoryContentRepository) ListTranslations(_ context.Context, contentID uuid.UUID) ([]*ContentTranslation, error)

ListTranslations returns stored translations for a content entry.

func (*MemoryContentRepository) ListVersions

func (m *MemoryContentRepository) ListVersions(_ context.Context, contentID uuid.UUID) ([]*ContentVersion, error)

ListVersions returns every stored version for a content entity.

func (*MemoryContentRepository) ReplaceTranslations

func (m *MemoryContentRepository) ReplaceTranslations(_ context.Context, contentID uuid.UUID, translations []*ContentTranslation) error

ReplaceTranslations swaps the translations associated with a content record.

func (*MemoryContentRepository) Update

func (m *MemoryContentRepository) Update(_ context.Context, record *Content) (*Content, error)

Update persists metadata changes for content records.

func (*MemoryContentRepository) UpdateVersion

func (m *MemoryContentRepository) UpdateVersion(_ context.Context, version *ContentVersion) (*ContentVersion, error)

UpdateVersion mutates metadata for a stored content version.

type MemoryContentTypeRepository

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

MemoryContentTypeRepository stores content types "in memory".

func NewMemoryContentTypeRepository

func NewMemoryContentTypeRepository() *MemoryContentTypeRepository

NewMemoryContentTypeRepository constructs the repository.

func (*MemoryContentTypeRepository) Create added in v0.20.0

Create inserts a content type record.

func (*MemoryContentTypeRepository) Delete added in v0.20.0

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

Delete removes a content type.

func (*MemoryContentTypeRepository) GetByID

GetByID fetches a content type.

func (*MemoryContentTypeRepository) GetBySlug added in v0.20.0

func (m *MemoryContentTypeRepository) GetBySlug(_ context.Context, slug string, env ...string) (*ContentType, error)

GetBySlug fetches a content type by slug.

func (*MemoryContentTypeRepository) List added in v0.20.0

List returns all content types.

func (*MemoryContentTypeRepository) Put

Put inserts or replaces a content type.

func (*MemoryContentTypeRepository) Search added in v0.20.0

func (m *MemoryContentTypeRepository) Search(ctx context.Context, query string, env ...string) ([]*ContentType, error)

Search returns content types whose name or slug contains the query.

func (*MemoryContentTypeRepository) Update added in v0.20.0

Update updates an existing content type.

type MemoryLocaleRepository

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

MemoryLocaleRepository stores locales by code.

func NewMemoryLocaleRepository

func NewMemoryLocaleRepository() *MemoryLocaleRepository

NewMemoryLocaleRepository constructs the repository.

func (*MemoryLocaleRepository) Count added in v0.16.0

func (m *MemoryLocaleRepository) Count() int

Count returns the number of locales stored in memory.

func (*MemoryLocaleRepository) GetByCode

func (m *MemoryLocaleRepository) GetByCode(_ context.Context, code string) (*Locale, error)

GetByCode resolves a locale by code (case-insensitive).

func (*MemoryLocaleRepository) GetByID added in v0.30.0

func (m *MemoryLocaleRepository) GetByID(_ context.Context, id uuid.UUID) (*Locale, error)

GetByID resolves a locale by identifier.

func (*MemoryLocaleRepository) List added in v0.42.0

List returns all locales in a stable order with the default locale first.

func (*MemoryLocaleRepository) Put

func (m *MemoryLocaleRepository) Put(locale *Locale)

Put inserts or replaces a locale.

type NavigationConfig struct {
	Enabled               bool
	EligibleLocations     []string
	DefaultLocations      []string
	DefaultVisible        bool
	AllowInstanceOverride bool
	LabelField            string
	URLField              string
	MergeMode             string
	DuplicatePolicy       string
}

NavigationConfig captures normalized content-type navigation capability values.

func ReadNavigationConfig added in v0.38.0

func ReadNavigationConfig(contentType *ContentType) NavigationConfig

ReadNavigationConfig resolves canonical navigation capability settings.

type NavigationVisibilityResult struct {
	Config                 NavigationConfig
	Overrides              map[string]string
	EffectiveVisibility    map[string]bool
	Origins                map[string]string
	EffectiveState         map[string]string
	EffectiveMenuLocations []string
}

NavigationVisibilityResult reports effective per-location visibility and origin.

func ResolveNavigationVisibility added in v0.38.0

func ResolveNavigationVisibility(contentType *ContentType, metadata map[string]any) NavigationVisibilityResult

ResolveNavigationVisibility computes effective visibility for every eligible location.

type NotFoundError

type NotFoundError struct {
	Resource string
	Key      string
}

NotFoundError represents missing records from repository lookups.

func (*NotFoundError) Error

func (e *NotFoundError) Error() string

type PreviewContentDraftRequest added in v0.21.0

type PreviewContentDraftRequest = cmscontent.PreviewContentDraftRequest

type ProjectionTranslationMode added in v0.35.0

type ProjectionTranslationMode = cmscontent.ProjectionTranslationMode

type PublishContentDraftRequest

type PublishContentDraftRequest = cmscontent.PublishContentDraftRequest

type RestoreContentVersionRequest

type RestoreContentVersionRequest = cmscontent.RestoreContentVersionRequest

type ScheduleContentRequest

type ScheduleContentRequest = cmscontent.ScheduleContentRequest

type Service

type Service = cmscontent.Service

func NewService

func NewService(contents ContentRepository, types ContentTypeRepository, locales LocaleRepository, opts ...ServiceOption) Service

NewService constructs a content service with the required dependencies.

type ServiceOption

type ServiceOption func(*service)

ServiceOption configures the service at construction time.

func WithActivityEmitter added in v0.5.0

func WithActivityEmitter(emitter *activity.Emitter) ServiceOption

WithActivityEmitter wires the activity emitter used for activity records.

func WithClock

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

WithClock overrides the clock used to stamp records.

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 WithEmbeddedBlocksResolver added in v0.21.0

func WithEmbeddedBlocksResolver(resolver EmbeddedBlocksResolver) ServiceOption

WithEmbeddedBlocksResolver wires the embedded blocks bridge (dual-write + fallback).

func WithEnvironmentService added in v0.23.1

func WithEnvironmentService(envSvc cmsenv.Service) ServiceOption

WithEnvironmentService wires the environment service for env resolution.

func WithIDGenerator

func WithIDGenerator(generator IDGenerator) ServiceOption

WithIDGenerator overrides the generator used to create identifiers.

func WithLogger

func WithLogger(logger interfaces.Logger) ServiceOption

WithLogger assigns the logger used by the service. When omitted, a no-op logger is used.

func WithProjectionTranslationMode added in v0.35.0

func WithProjectionTranslationMode(mode ProjectionTranslationMode) ServiceOption

WithProjectionTranslationMode configures projection behavior when translations are not explicitly requested for reads.

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 translations are mandatory.

func WithScheduler

func WithScheduler(scheduler interfaces.Scheduler) ServiceOption

WithScheduler overrides the scheduler used to register publish/unpublish jobs.

func WithSchedulingEnabled

func WithSchedulingEnabled(enabled bool) ServiceOption

WithSchedulingEnabled toggles scheduling-related workflows.

func WithSchemaMigrator added in v0.21.0

func WithSchemaMigrator(migrator *cmsschema.Migrator) ServiceOption

WithSchemaMigrator configures schema migrations for publish-time upgrades.

func WithSlugNormalizer added in v0.20.0

func WithSlugNormalizer(normalizer slug.Normalizer) ServiceOption

WithSlugNormalizer overrides the slug normalizer used by the service.

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 WithVersionRetentionLimit

func WithVersionRetentionLimit(limit int) ServiceOption

WithVersionRetentionLimit constrains how many versions are retained per content entity.

func WithVersioningEnabled

func WithVersioningEnabled(enabled bool) ServiceOption

WithVersioningEnabled toggles the versioning workflow for the service.

type SlugConflictError added in v0.36.0

type SlugConflictError = cmscontent.SlugConflictError

type SourceNotFoundError added in v0.36.0

type SourceNotFoundError = cmscontent.SourceNotFoundError

type TranslationAlreadyExistsError added in v0.36.0

type TranslationAlreadyExistsError = cmscontent.TranslationAlreadyExistsError

type TranslationCheckOptions added in v0.33.0

type TranslationCheckOptions = cmscontent.TranslationCheckOptions

type TranslationConflictStrategy added in v0.36.0

type TranslationConflictStrategy = cmscontent.TranslationConflictStrategy

type TranslationCreator added in v0.36.0

type TranslationCreator = cmscontent.TranslationCreator

type TranslationInvariantViolationError added in v0.36.0

type TranslationInvariantViolationError = cmscontent.TranslationInvariantViolationError

type UpdateContentRequest

type UpdateContentRequest = cmscontent.UpdateContentRequest

type UpdateContentTranslationRequest added in v0.2.0

type UpdateContentTranslationRequest = cmscontent.UpdateContentTranslationRequest

type UpdateContentTypeRequest added in v0.20.0

type UpdateContentTypeRequest = cmscontent.UpdateContentTypeRequest

Jump to

Keyboard shortcuts

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