Documentation
¶
Index ¶
- Constants
- Variables
- type Action
- type ActivityRecord
- type ActivitySink
- type AdminPageGetOptions
- type AdminPageIncludeDefaults
- type AdminPageIncludeOptions
- type AdminPageListOptions
- type AdminPageReadService
- type AdminPageRecord
- type ApplyEventRequest
- type ApplyEventResponse
- type AuthClaims
- type AuthService
- type Authenticator
- type CacheProvider
- type CommandEffect
- type Config
- type ContentCreateRequest
- type ContentCreateTranslationRequest
- type ContentDeleteRequest
- type ContentDeleteTranslationRequest
- type ContentReadOptions
- type ContentRecord
- type ContentService
- type ContentTranslation
- type ContentTranslationCreator
- type ContentTranslationInput
- type ContentTypeCreateRequest
- type ContentTypeDeleteRequest
- type ContentTypeRecord
- type ContentTypeService
- type ContentTypeUpdateRequest
- type ContentUpdateRequest
- type ContentUpdateTranslationRequest
- type CultureService
- type Document
- type DynamicTargetDefinition
- type DynamicTargetResolver
- type Effect
- type EmitEvent
- type ExecutionContext
- type FieldsLogger
- type Formatter
- type FormatterRegistry
- type FrontMatter
- type Guard
- type GuardDefinition
- type GuardRejection
- type HelperConfig
- type Identity
- type IdentityProvider
- type ImportOptions
- type ImportResult
- type Job
- type JobSpec
- type JobStatus
- type LoadOptions
- type Logger
- type LoggerProvider
- type LoginPayload
- type MachineDefinition
- type MarkdownParser
- type MarkdownService
- type MediaAsset
- type MediaMetadata
- type MediaProvider
- type MediaReference
- type MediaResolveRequest
- type MediaResource
- type MissingTranslationHandler
- type PageCreateRequest
- type PageDeleteRequest
- type PageDeleteTranslationRequest
- type PageDuplicateRequest
- type PageMoveRequest
- type PageReadOptions
- type PageRecord
- type PageService
- type PageTranslation
- type PageTranslationInput
- type PageUpdateRequest
- type PageUpdateTranslationRequest
- type ParseOptions
- type ParsedShortcode
- type RequiredFieldsValidationStrategy
- type ResourceRoleProvider
- type Result
- type RoleCapableSession
- type Rows
- type Scheduler
- type Service
- type Session
- type ShortcodeContext
- type ShortcodeDefinition
- type ShortcodeHandler
- type ShortcodeMetrics
- type ShortcodeParam
- type ShortcodeParamType
- type ShortcodeParser
- type ShortcodeProcessOptions
- type ShortcodeRegistry
- type ShortcodeRenderer
- type ShortcodeSanitizer
- type ShortcodeSchema
- type ShortcodeService
- type ShortcodeValidator
- type SignedURL
- type Snapshot
- type SnapshotRequest
- type StateDefinition
- type StepDefinition
- type StorageCapabilityReporter
- type StorageProvider
- type StorageReloadable
- type SyncOptions
- type SyncResult
- type TargetInfo
- type TemplateHelperProvider
- type TemplateRenderer
- type TokenService
- type Transaction
- type TransitionDefinition
- type TransitionInfo
- type TransitionResult
- type TransitionWorkflowDefinition
- type TranslationBundle
- type TranslationCheckOptions
- type TranslationMeta
- type Translator
- type TranslatorWithMetadata
- type UserRole
- type WorkflowDefinition
- type WorkflowDefinitionStore
- type WorkflowEngine
- type WorkflowMessage
- type WorkflowNodeDefinition
- type WorkflowState
- type WorkflowStateDefinition
- type WorkflowTransition
Constants ¶
const DefaultWorkflowMessageType = "go-cms.workflow"
Variables ¶
var ( // ErrJobNotFound reports missing jobs when looking them up by ID or key. ErrJobNotFound = errors.New("scheduler: job not found") )
var ErrTranslationMissing = errors.New("translation missing")
ErrTranslationMissing is returned when a requested locale translation is missing.
Functions ¶
This section is empty.
Types ¶
type ActivityRecord ¶ added in v0.5.0
type ActivityRecord = usertypes.ActivityRecord
ActivityRecord mirrors the go-users activity record contract so downstream packages can depend on a single type.
type ActivitySink ¶ added in v0.5.0
type ActivitySink interface {
Log(ctx context.Context, record ActivityRecord) error
}
ActivitySink captures activity events; implementations are expected to satisfy the go-users ActivitySink contract.
type AdminPageGetOptions ¶ added in v0.26.0
type AdminPageGetOptions struct {
Locale string
FallbackLocale string
AllowMissingTranslations bool
IncludeContent bool
IncludeBlocks bool
IncludeData bool
EnvironmentKey string
DefaultIncludes *AdminPageIncludeDefaults
}
AdminPageGetOptions defines the admin page detail read contract.
type AdminPageIncludeDefaults ¶ added in v0.26.0
type AdminPageIncludeDefaults struct {
List AdminPageIncludeOptions
Get AdminPageIncludeOptions
}
AdminPageIncludeDefaults defines default include behavior per endpoint.
type AdminPageIncludeOptions ¶ added in v0.26.0
AdminPageIncludeOptions declares optional heavy-field inclusion for admin reads.
type AdminPageListOptions ¶ added in v0.26.0
type AdminPageListOptions struct {
Locale string
FallbackLocale string
AllowMissingTranslations bool
IncludeContent bool
IncludeBlocks bool
IncludeData bool
EnvironmentKey string
DefaultIncludes *AdminPageIncludeDefaults
Page int
PerPage int
SortBy string
SortDesc bool
Search string
Filters map[string]any
Fields []string
}
AdminPageListOptions defines the admin page list read contract.
Behavior contract:
- Locale resolution: if a translation exists for Locale, use it and set ResolvedLocale = Locale.
- If missing and FallbackLocale is set, use it and set ResolvedLocale = FallbackLocale.
- If still missing, return a record with empty localized fields while preserving identifiers/status.
- RequestedLocale is always set to Locale, even when missing, to avoid UI ambiguity.
- When IncludeData is true, translation content/meta fields are merged into Data (path/meta/summary/tags/etc) and used for Content/Meta fallbacks.
- Blocks payload: when IncludeBlocks is true, prefer embedded blocks arrays; fall back to legacy []string block IDs when embedded blocks are absent. Blocks is omitted unless IncludeBlocks is true.
- Content preserves structure when it is not a simple string.
type AdminPageReadService ¶ added in v0.26.0
type AdminPageReadService interface {
List(ctx context.Context, opts AdminPageListOptions) ([]AdminPageRecord, int, error)
Get(ctx context.Context, id string, opts AdminPageGetOptions) (*AdminPageRecord, error)
}
AdminPageReadService exposes list and detail reads for admin page records.
type AdminPageRecord ¶ added in v0.26.0
type AdminPageRecord struct {
ID uuid.UUID
ContentID uuid.UUID
TranslationGroupID *uuid.UUID
TemplateID uuid.UUID
Title string
Slug string
Path string
RequestedLocale string
ResolvedLocale string
Translation TranslationBundle[PageTranslation] `json:"translation"`
ContentTranslation TranslationBundle[ContentTranslation] `json:"content_translation"`
Status string
ParentID *uuid.UUID
MetaTitle string
MetaDescription string
Summary *string
Tags []string
SchemaVersion string
Data map[string]any
Content any
Blocks any
PreviewURL string
PublishedAt *time.Time
CreatedAt *time.Time
UpdatedAt *time.Time
}
AdminPageRecord defines the admin read model projection for a page entry.
type ApplyEventRequest ¶ added in v0.37.0
type ApplyEventRequest = flow.ApplyEventRequest[WorkflowMessage]
type ApplyEventResponse ¶ added in v0.37.0
type ApplyEventResponse = flow.ApplyEventResponse[WorkflowMessage]
type AuthClaims ¶
type AuthClaims interface {
Subject() string
UserID() string
Role() string
CanRead(resource string) bool
CanEdit(resource string) bool
CanCreate(resource string) bool
CanDelete(resource string) bool
HasRole(role string) bool
IsAtLeast(minRole string) bool
Expires() time.Time
IssuedAt() time.Time
}
AuthClaims matches go-auth AuthClaims behaviour.
type AuthService ¶
type AuthService interface {
Authenticator() Authenticator
TokenService() TokenService
TemplateHelpers() map[string]any
}
type Authenticator ¶
type Authenticator interface {
Login(ctx context.Context, identifier, password string) (string, error)
Impersonate(ctx context.Context, identifier string) (string, error)
SessionFromToken(token string) (Session, error)
IdentityFromSession(ctx context.Context, session Session) (Identity, error)
TokenService() TokenService
}
type CacheProvider ¶
type CommandEffect ¶ added in v0.37.0
type CommandEffect = flow.CommandEffect
type Config ¶
type Config interface {
GetSigningKey() string
GetSigningMethod() string
GetContextKey() string
GetTokenExpiration() int
GetExtendedTokenDuration() int
GetTokenLookup() string
GetAuthScheme() string
GetIssuer() string
GetAudience() []string
GetRejectedRouteKey() string
GetRejectedRouteDefault() string
}
type ContentCreateRequest ¶
type ContentCreateRequest struct {
ContentTypeID uuid.UUID
Slug string
Status string
CreatedBy uuid.UUID
UpdatedBy uuid.UUID
Translations []ContentTranslationInput
Metadata map[string]any
AllowMissingTranslations bool
}
ContentCreateRequest captures the details required to create a content record.
type ContentCreateTranslationRequest ¶ added in v0.36.0
type ContentCreateTranslationRequest struct {
SourceID uuid.UUID
SourceLocale string
TargetLocale string
EnvironmentKey string
ActorID uuid.UUID
Status string
}
ContentCreateTranslationRequest clones an existing locale into a new locale.
type ContentDeleteRequest ¶
ContentDeleteRequest captures the information required to remove content. When HardDelete is false, implementations may opt for soft-deletion where supported.
type ContentDeleteTranslationRequest ¶ added in v0.2.0
type ContentDeleteTranslationRequest struct {
ContentID uuid.UUID
Locale string
DeletedBy uuid.UUID
}
ContentDeleteTranslationRequest removes a locale entry.
type ContentReadOptions ¶ added in v0.28.0
type ContentReadOptions struct {
Locale string
FallbackLocale string
AllowMissingTranslations bool
IncludeAvailableLocales bool
EnvironmentKey string
}
ContentReadOptions defines read-time locale resolution and metadata behaviour.
Behavior contract:
- RequestedLocale always echoes Locale, even when missing.
- If a translation exists for Locale, Translation.Requested/Resolved point to it and ResolvedLocale = Locale.
- If missing and FallbackLocale exists, Translation.Requested is nil, Resolved uses the fallback locale, and FallbackUsed=true.
- If missing with no fallback, Translation.Requested/Resolved are nil and ResolvedLocale is empty.
- AllowMissingTranslations=false should return ErrTranslationMissing when Locale is set and missing.
- List reads never hard-fail on missing translations; they return bundle metadata instead.
- IncludeAvailableLocales populates Translation.Meta.AvailableLocales for the content bundle only.
type ContentRecord ¶
type ContentRecord struct {
ID uuid.UUID
ContentType uuid.UUID
ContentTypeSlug string
Slug string
Status string
Translation TranslationBundle[ContentTranslation] `json:"translation"`
Metadata map[string]any
}
ContentRecord reflects the persisted state returned by the content service.
type ContentService ¶
type ContentService interface {
Create(ctx context.Context, req ContentCreateRequest) (*ContentRecord, error)
Update(ctx context.Context, req ContentUpdateRequest) (*ContentRecord, error)
GetBySlug(ctx context.Context, slug string, opts ContentReadOptions) (*ContentRecord, error)
List(ctx context.Context, opts ContentReadOptions) ([]*ContentRecord, 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)
Delete(ctx context.Context, req ContentDeleteRequest) error
UpdateTranslation(ctx context.Context, req ContentUpdateTranslationRequest) (*ContentTranslation, error)
DeleteTranslation(ctx context.Context, req ContentDeleteTranslationRequest) error
}
ContentService abstracts the CMS content service so markdown imports can provision or update records without depending on internal implementations.
type ContentTranslation ¶
type ContentTranslation struct {
ID uuid.UUID
TranslationGroupID *uuid.UUID `json:"translation_group_id,omitempty"`
Locale string
Title string
Summary *string
Fields map[string]any
}
ContentTranslation mirrors stored translation fields.
type ContentTranslationCreator ¶ added in v0.36.0
type ContentTranslationCreator interface {
CreateTranslation(ctx context.Context, req ContentCreateTranslationRequest) (*ContentRecord, error)
}
ContentTranslationCreator is an additive capability interface for first-class translation creation.
type ContentTranslationInput ¶
type ContentTranslationInput struct {
Locale string
Title string
Summary *string
Fields map[string]any
Blocks []map[string]any
}
ContentTranslationInput represents localized fields provided during create/update.
type ContentTypeCreateRequest ¶ added in v0.20.0
type ContentTypeCreateRequest struct {
Name string
Slug string
Description *string
Schema map[string]any
Capabilities map[string]any
Icon *string
EnvironmentKey string
}
ContentTypeCreateRequest captures fields required to create a content type.
type ContentTypeDeleteRequest ¶ added in v0.20.0
ContentTypeDeleteRequest captures data to delete a content type.
type ContentTypeRecord ¶ added in v0.20.0
type ContentTypeRecord struct {
ID uuid.UUID
Name string
Slug string
Description *string
Schema map[string]any
Capabilities map[string]any
Icon *string
}
ContentTypeRecord reflects a stored content type.
type ContentTypeService ¶ added in v0.20.0
type ContentTypeService interface {
Create(ctx context.Context, req ContentTypeCreateRequest) (*ContentTypeRecord, error)
Update(ctx context.Context, req ContentTypeUpdateRequest) (*ContentTypeRecord, error)
Delete(ctx context.Context, req ContentTypeDeleteRequest) error
Get(ctx context.Context, id uuid.UUID) (*ContentTypeRecord, error)
GetBySlug(ctx context.Context, slug string, env ...string) (*ContentTypeRecord, error)
List(ctx context.Context, env ...string) ([]*ContentTypeRecord, error)
Search(ctx context.Context, query string, env ...string) ([]*ContentTypeRecord, error)
}
ContentTypeService abstracts content type management for adapters.
type ContentTypeUpdateRequest ¶ added in v0.20.0
type ContentTypeUpdateRequest struct {
ID uuid.UUID
Name *string
Slug *string
Description *string
Schema map[string]any
Capabilities map[string]any
Icon *string
}
ContentTypeUpdateRequest captures fields for updating a content type.
type ContentUpdateRequest ¶
type ContentUpdateRequest struct {
ID uuid.UUID
Status string
UpdatedBy uuid.UUID
Translations []ContentTranslationInput
Metadata map[string]any
AllowMissingTranslations bool
}
ContentUpdateRequest captures the mutable fields for an existing content record.
type ContentUpdateTranslationRequest ¶ added in v0.2.0
type ContentUpdateTranslationRequest struct {
ContentID uuid.UUID
Locale string
Title string
Summary *string
Fields map[string]any
Blocks []map[string]any
UpdatedBy uuid.UUID
}
ContentUpdateTranslationRequest updates a single locale entry.
type CultureService ¶
type CultureService interface {
GetCurrencyCode(locale string) (string, error)
GetCurrency(locale string) (any, error)
GetSupportNumber(locale string) (string, error)
GetList(locale, name string) ([]string, error)
GetMeasurementPreference(locale, measurementType string) (any, error)
ConvertMeasurement(locale string, value float64, fromUnit, measurementType string) (float64, string, string, error)
}
type Document ¶
type Document struct {
FilePath string
Locale string
FrontMatter FrontMatter
Body []byte
BodyHTML []byte
LastModified time.Time
// Checksum stores a digest of the original file content (typically SHA-256)
// so sync workflows can detect changes without re-importing unchanged files.
Checksum []byte
}
Document represents a Markdown file with parsed metadata and content. The struct is shared between the interfaces package and internal implementations so consumers can depend on a stable contract.
type DynamicTargetDefinition ¶ added in v0.37.0
type DynamicTargetDefinition = flow.DynamicTargetDefinition
type DynamicTargetResolver ¶ added in v0.37.0
type DynamicTargetResolver = flow.DynamicTargetResolver[WorkflowMessage]
type ExecutionContext ¶ added in v0.37.0
type ExecutionContext = flow.ExecutionContext
type FieldsLogger ¶
FieldsLogger is an optional extension for attaching persistent structured fields to a logger. Providers that support this behaviour should return a new logger with the supplied fields applied on every log entry. Logger implementations exported during the Observability phase are expected to satisfy this interface even though WithFields is promoted onto Logger.
type FormatterRegistry ¶
type FrontMatter ¶
type FrontMatter struct {
Title string `yaml:"title" json:"title"`
Slug string `yaml:"slug" json:"slug"`
Summary string `yaml:"summary" json:"summary"`
Status string `yaml:"status" json:"status"`
Template string `yaml:"template" json:"template"`
Tags []string `yaml:"tags" json:"tags"`
Author string `yaml:"author" json:"author"`
Date time.Time `yaml:"date" json:"date"`
Draft bool `yaml:"draft" json:"draft"`
Custom map[string]any `yaml:",inline" json:"custom"`
Raw map[string]any `yaml:"-" json:"raw"`
}
FrontMatter models metadata extracted from Markdown files. Fields align with the canonical examples in docs/FEAT_MARKDOWN.md and remain flexible thanks to the Custom map for template- or domain-specific values.
type Guard ¶ added in v0.37.0
type Guard = flow.Guard[WorkflowMessage]
type GuardDefinition ¶ added in v0.37.0
type GuardDefinition = flow.GuardDefinition
type GuardRejection ¶ added in v0.37.0
type GuardRejection = flow.GuardRejection
type HelperConfig ¶
type HelperConfig struct {
LocaleKey string
TemplateHelperKey string
OnMissing MissingTranslationHandler
Registry FormatterRegistry
}
type IdentityProvider ¶
type ImportOptions ¶
type ImportOptions struct {
ContentTypeID uuid.UUID
AuthorID uuid.UUID
DryRun bool
EnvironmentKey string
ContentAllowMissingTranslations bool
ProcessShortcodes bool
}
ImportOptions controls how Markdown documents are converted into CMS content. UUID fields reference existing CMS entities (content types, authors, etc.).
type ImportResult ¶
type ImportResult struct {
CreatedContentIDs []uuid.UUID
UpdatedContentIDs []uuid.UUID
SkippedContentIDs []uuid.UUID
Errors []error
}
ImportResult reports the outcome of a single import operation, exposing counts and IDs so callers can audit behaviour or trigger follow-up actions.
type Job ¶
type Job struct {
JobSpec
ID string
Attempt int
LastError string
Status JobStatus
CreatedAt time.Time
UpdatedAt time.Time
}
Job represents a stored job entry with metadata managed by the scheduler implementation.
type JobSpec ¶
type JobSpec struct {
// Key uniquely identifies the job so that new requests can safely replace existing entries.
Key string
// Type describes the action to perform (e.g. cms.content.publish).
Type string
// RunAt specifies when the job should execute.
RunAt time.Time
// Payload carries contextual data required by the worker.
Payload map[string]any
// MaxAttempts limits retries when a worker reports failure. Zero means unlimited.
MaxAttempts int
}
JobSpec captures the required information to enqueue a job.
type LoadOptions ¶
type LoadOptions struct {
Recursive *bool
Pattern string
LocalePatterns map[string]string
Parser ParseOptions
}
LoadOptions fine-tunes how documents are discovered and parsed from disk.
type Logger ¶
type Logger interface {
Trace(msg string, args ...any)
Debug(msg string, args ...any)
Info(msg string, args ...any)
Warn(msg string, args ...any)
Error(msg string, args ...any)
Fatal(msg string, args ...any)
// WithFields returns a child logger that will attach the provided fields
// to every emitted log entry. Implementations should avoid mutating the
// current instance so callers can safely reuse loggers across requests.
WithFields(fields map[string]any) Logger
// WithContext returns a logger that binds the supplied context and should
// propagate correlation identifiers when available.
WithContext(ctx context.Context) Logger
}
Logger defines the leveled logging contract expected by the CMS runtime. The interface is promoted during Phase 7 (Observability) so advanced deployments can supply structured logging while keeping console fallbacks viable for simpler setups. It mirrors github.com/goliatone/go-logger, allowing host applications to forward their preferred provider without additional adapters.
type LoggerProvider ¶
LoggerProvider exposes named loggers. Implementations can return the same instance for every name or scope loggers (e.g. module-based children). Phase 7 expects container wiring to request names like "cms.pages" or "cms.scheduler" so operators can filter logs per module.
type LoginPayload ¶
type MachineDefinition ¶ added in v0.37.0
type MachineDefinition = flow.MachineDefinition
type MarkdownParser ¶
type MarkdownParser interface {
// Parse converts Markdown into HTML using the parser's default settings.
Parse(markdown []byte) ([]byte, error)
// ParseWithOptions converts Markdown into HTML using the supplied overrides.
ParseWithOptions(markdown []byte, opts ParseOptions) ([]byte, error)
}
MarkdownParser defines how raw Markdown bytes are converted into HTML. Implementations should follow the file-centric workflows captured in docs/FEAT_MARKDOWN.md, supporting reusable parser instances and extension toggles so hosts can tailor rendering without rewriting the core service.
type MarkdownService ¶
type MarkdownService interface {
Load(ctx context.Context, path string, opts LoadOptions) (*Document, error)
LoadDirectory(ctx context.Context, dir string, opts LoadOptions) ([]*Document, error)
Render(ctx context.Context, markdown []byte, opts ParseOptions) ([]byte, error)
RenderDocument(ctx context.Context, doc *Document, opts ParseOptions) ([]byte, error)
Import(ctx context.Context, doc *Document, opts ImportOptions) (*ImportResult, error)
ImportDirectory(ctx context.Context, dir string, opts ImportOptions) (*ImportResult, error)
Sync(ctx context.Context, dir string, opts SyncOptions) (*SyncResult, error)
}
MarkdownService exposes the high-level file workflows described in docs/FEAT_MARKDOWN.md Option 1, enabling hosts to load Markdown documents, convert them into HTML, and synchronise them with CMS content.
type MediaAsset ¶
type MediaAsset struct {
Reference MediaReference
Source *MediaResource
Renditions map[string]*MediaResource
Metadata MediaMetadata
}
MediaAsset encapsulates metadata and resolved resources for a media item.
type MediaMetadata ¶
type MediaMetadata struct {
ID string
Name string
Description string
MimeType string
Size int64
Width int
Height int
Duration time.Duration
AltText string
Caption string
Tags []string
Attributes map[string]any
Checksums map[string]string
CreatedAt time.Time
UpdatedAt time.Time
CreatedBy string
UpdatedBy string
}
MediaMetadata captures descriptive properties of the media asset.
type MediaProvider ¶
type MediaProvider interface {
// Resolve fetches a single media asset using the supplied request parameters.
Resolve(ctx context.Context, req MediaResolveRequest) (*MediaAsset, error)
// ResolveBatch fetches multiple media assets. Implementations should de-duplicate references internally.
ResolveBatch(ctx context.Context, reqs []MediaResolveRequest) (map[string]*MediaAsset, error)
// Invalidate clears cached lookups for the provided references, allowing subsequent resolve calls to refresh state.
Invalidate(ctx context.Context, refs ...MediaReference) error
}
MediaProvider supplies metadata and access details for externally managed assets.
type MediaReference ¶
type MediaReference struct {
ID string
Path string
Collection string
Locale string
Variant string
Attributes map[string]string
}
MediaReference uniquely identifies a media asset within the provider.
type MediaResolveRequest ¶
type MediaResolveRequest struct {
Reference MediaReference
Renditions []string
IncludeSource bool
IncludeSignedURLs bool
SignedURLTTL time.Duration
Purpose string
Context map[string]string
}
MediaResolveRequest controls which parts of an asset should be resolved.
type MediaResource ¶
type MediaResource struct {
URL string
SignedURL *SignedURL
MimeType string
Size int64
Width int
Height int
Duration time.Duration
Hash string
LastModified time.Time
Metadata map[string]any
}
MediaResource describes a concrete file representation (original or derivative).
type PageCreateRequest ¶
type PageCreateRequest struct {
ContentID uuid.UUID
TemplateID uuid.UUID
ParentID *uuid.UUID
Slug string
Status string
CreatedBy uuid.UUID
UpdatedBy uuid.UUID
Translations []PageTranslationInput
Metadata map[string]any
AllowMissingTranslations bool
}
PageCreateRequest captures the required fields to create a page backed by content.
type PageDeleteRequest ¶
PageDeleteRequest captures the information required to remove a page.
type PageDeleteTranslationRequest ¶ added in v0.2.0
PageDeleteTranslationRequest removes a translation entry.
type PageDuplicateRequest ¶ added in v0.2.0
type PageDuplicateRequest struct {
PageID uuid.UUID
Slug string
ParentID *uuid.UUID
Status string
CreatedBy uuid.UUID
UpdatedBy uuid.UUID
}
PageDuplicateRequest clones an existing page with overrides.
type PageMoveRequest ¶ added in v0.2.0
PageMoveRequest updates the parent relationship.
type PageReadOptions ¶ added in v0.28.0
type PageReadOptions struct {
Locale string
FallbackLocale string
AllowMissingTranslations bool
IncludeAvailableLocales bool
EnvironmentKey string
}
PageReadOptions defines read-time locale resolution and metadata behaviour.
Behavior contract:
- RequestedLocale always echoes Locale, even when missing.
- If a translation exists for Locale, Translation.Requested/Resolved point to it and ResolvedLocale = Locale.
- If missing and FallbackLocale exists, Translation.Requested is nil, Resolved uses the fallback locale, and FallbackUsed=true.
- If missing with no fallback, Translation.Requested/Resolved are nil and ResolvedLocale is empty.
- AllowMissingTranslations=false should return ErrTranslationMissing when Locale is set and missing.
- List reads never hard-fail on missing translations; they return bundle metadata instead.
- IncludeAvailableLocales populates Translation.Meta.AvailableLocales for the page bundle only.
- Page and content translation bundles resolve independently (no forced cross-bundle fallback).
type PageRecord ¶
type PageRecord struct {
ID uuid.UUID
ContentID uuid.UUID
TemplateID uuid.UUID
Slug string
Status string
Translation TranslationBundle[PageTranslation] `json:"translation"`
ContentTranslation TranslationBundle[ContentTranslation] `json:"content_translation"`
Metadata map[string]any
}
PageRecord reflects stored page details.
type PageService ¶
type PageService interface {
Create(ctx context.Context, req PageCreateRequest) (*PageRecord, error)
Update(ctx context.Context, req PageUpdateRequest) (*PageRecord, error)
GetBySlug(ctx context.Context, slug string, opts PageReadOptions) (*PageRecord, error)
List(ctx context.Context, opts PageReadOptions) ([]*PageRecord, 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)
Delete(ctx context.Context, req PageDeleteRequest) error
UpdateTranslation(ctx context.Context, req PageUpdateTranslationRequest) (*PageTranslation, error)
DeleteTranslation(ctx context.Context, req PageDeleteTranslationRequest) error
Move(ctx context.Context, req PageMoveRequest) (*PageRecord, error)
Duplicate(ctx context.Context, req PageDuplicateRequest) (*PageRecord, error)
}
PageService abstracts page orchestration for CMS page records.
type PageTranslation ¶
type PageTranslation struct {
ID uuid.UUID
TranslationGroupID *uuid.UUID `json:"translation_group_id,omitempty"`
Locale string
Title string
Path string
Summary *string
Fields map[string]any
}
PageTranslation mirrors persisted page translations.
type PageTranslationInput ¶
type PageTranslationInput struct {
Locale string
Title string
Path string
Summary *string
Fields map[string]any
}
PageTranslationInput describes localized routing attributes.
type PageUpdateRequest ¶
type PageUpdateRequest struct {
ID uuid.UUID
TemplateID *uuid.UUID
Status string
UpdatedBy uuid.UUID
Translations []PageTranslationInput
Metadata map[string]any
AllowMissingTranslations bool
}
PageUpdateRequest mutates an existing page.
type PageUpdateTranslationRequest ¶ added in v0.2.0
type PageUpdateTranslationRequest struct {
PageID uuid.UUID
Locale string
Title string
Path string
Summary *string
Fields map[string]any
UpdatedBy uuid.UUID
}
PageUpdateTranslationRequest mutates a single translation entry.
type ParseOptions ¶
type ParseOptions struct {
Extensions []string
Sanitize bool
HardWraps bool
SafeMode bool
ProcessShortcodes bool
ShortcodeOptions ShortcodeProcessOptions
}
ParseOptions customises Markdown parsing behaviour, keeping option names readable for configuration unmarshalling and CLI flags.
type ParsedShortcode ¶ added in v0.2.0
ParsedShortcode represents a parsed invocation discovered by the parser layer.
type RequiredFieldsValidationStrategy ¶ added in v0.29.0
type RequiredFieldsValidationStrategy string
RequiredFieldsValidationStrategy controls how translation checks handle required-field keys that are not supported by the entity or schema.
const ( RequiredFieldsValidationError RequiredFieldsValidationStrategy = "error" RequiredFieldsValidationWarn RequiredFieldsValidationStrategy = "warn" RequiredFieldsValidationIgnore RequiredFieldsValidationStrategy = "ignore" )
type ResourceRoleProvider ¶
type RoleCapableSession ¶
type RoleCapableSession interface {
Session
CanRead(resource string) bool
CanEdit(resource string) bool
CanCreate(resource string) bool
CanDelete(resource string) bool
HasRole(role string) bool
IsAtLeast(minRole UserRole) bool
}
RoleCapableSession extends Session with role helpers.
type Scheduler ¶
type Scheduler interface {
// Enqueue registers a job for future execution. If a job with the same key already exists,
// it is replaced with the new definition to keep scheduling idempotent.
Enqueue(ctx context.Context, spec JobSpec) (*Job, error)
// Cancel marks the job as cancelled so it will not be executed.
Cancel(ctx context.Context, id string) error
// CancelByKey cancels the job associated to the supplied unique key.
CancelByKey(ctx context.Context, key string) error
// Get returns the stored job by identifier.
Get(ctx context.Context, id string) (*Job, error)
// GetByKey returns the stored job that matches the supplied key.
GetByKey(ctx context.Context, key string) (*Job, error)
// ListDue returns pending jobs scheduled to run at or before the supplied instant.
ListDue(ctx context.Context, until time.Time, limit int) ([]*Job, error)
// MarkDone marks the job as successfully processed.
MarkDone(ctx context.Context, id string) error
// MarkFailed updates the job after a failed attempt.
MarkFailed(ctx context.Context, id string, err error) error
}
Scheduler coordinates delayed execution of jobs such as publish/unpublish actions.
type Service ¶
type Service interface {
Translator() Translator
Culture() CultureService
TemplateHelpers(cfg HelperConfig) map[string]any
DefaultLocale() string
}
type Session ¶
type Session interface {
GetUserID() string
GetUserUUID() (uuid.UUID, error)
GetAudience() []string
GetIssuer() string
GetIssuedAt() *time.Time
GetData() map[string]any
}
Session mirrors go-auth Session interface.
type ShortcodeContext ¶ added in v0.2.0
type ShortcodeContext struct {
Context context.Context
Locale string
Cache CacheProvider
Sanitizer ShortcodeSanitizer
}
ShortcodeContext provides runtime metadata surfaced during rendering.
type ShortcodeDefinition ¶ added in v0.2.0
type ShortcodeDefinition struct {
Name string
Version string
Description string
Category string
Icon string
AllowInner bool
Async bool
CacheTTL time.Duration
Schema ShortcodeSchema
Template string
Handler ShortcodeHandler
}
ShortcodeDefinition captures the metadata, validation schema, and template references that the registry stores.
type ShortcodeHandler ¶ added in v0.2.0
type ShortcodeHandler func(ctx ShortcodeContext, params map[string]any, inner string) (template.HTML, error)
ShortcodeHandler executes the shortcode with resolved parameters.
type ShortcodeMetrics ¶ added in v0.2.0
type ShortcodeMetrics interface {
// ObserveRenderDuration captures the elapsed time for a single shortcode render attempt.
ObserveRenderDuration(shortcode string, duration time.Duration)
// IncrementRenderError increments a counter tracking render failures.
IncrementRenderError(shortcode string)
// IncrementCacheHit records when a cached value satisfied a render request.
IncrementCacheHit(shortcode string)
}
ShortcodeMetrics records telemetry emitted during shortcode rendering.
type ShortcodeParam ¶ added in v0.2.0
type ShortcodeParam struct {
Name string
Type ShortcodeParamType
Required bool
Default any
Validate ShortcodeValidator
}
ShortcodeParam describes a single parameter, including optional custom validation.
type ShortcodeParamType ¶ added in v0.2.0
type ShortcodeParamType string
ShortcodeParamType enumerates the supported parameter coercions.
const ( ShortcodeParamString ShortcodeParamType = "string" ShortcodeParamInt ShortcodeParamType = "int" ShortcodeParamBool ShortcodeParamType = "bool" ShortcodeParamArray ShortcodeParamType = "array" ShortcodeParamURL ShortcodeParamType = "url" )
type ShortcodeParser ¶ added in v0.2.0
type ShortcodeParser interface {
Parse(content string) ([]ParsedShortcode, error)
Extract(content string) (placeholders string, shortcodes []ParsedShortcode, err error)
}
ShortcodeParser extracts shortcode invocations from arbitrary content.
type ShortcodeProcessOptions ¶ added in v0.2.0
type ShortcodeProcessOptions struct {
Locale string
Cache CacheProvider
Sanitizer ShortcodeSanitizer
EnableWordPress bool
}
ShortcodeProcessOptions customises shortcode processing behaviour for a given invocation.
type ShortcodeRegistry ¶ added in v0.2.0
type ShortcodeRegistry interface {
// Register stores a definition and returns an error when a shortcode
// with the same name already exists or the definition fails validation.
Register(definition ShortcodeDefinition) error
// Get returns the definition for the supplied shortcode name.
Get(name string) (ShortcodeDefinition, bool)
// List exposes the current catalogue, sorted at the implementor's discretion.
List() []ShortcodeDefinition
// Remove deletes the shortcode from the registry. Removing an unknown shortcode
// must be a no-op.
Remove(name string)
}
ShortcodeRegistry describes the lifecycle contract for registering and resolving shortcode definitions. Implementations must be safe for concurrent use and honour the validation semantics documented in SHORTCODE_TDD.md.
type ShortcodeRenderer ¶ added in v0.2.0
type ShortcodeRenderer interface {
Render(ctx ShortcodeContext, shortcode string, params map[string]any, inner string) (template.HTML, error)
RenderAsync(ctx ShortcodeContext, shortcode string, params map[string]any, inner string) (<-chan template.HTML, <-chan error)
}
ShortcodeRenderer executes a shortcode definition and returns HTML output.
type ShortcodeSanitizer ¶ added in v0.2.0
type ShortcodeSanitizer interface {
Sanitize(html string) (string, error)
ValidateURL(raw string) error
ValidateAttributes(attrs map[string]any) error
}
ShortcodeSanitizer encapsulates sanitisation helpers applied after rendering.
type ShortcodeSchema ¶ added in v0.2.0
type ShortcodeSchema struct {
Params []ShortcodeParam
Defaults map[string]any
}
ShortcodeSchema defines the contract for parameters accepted by a shortcode.
type ShortcodeService ¶ added in v0.2.0
type ShortcodeService interface {
// Process scans the provided content, rendering any shortcode invocations using the supplied options.
Process(ctx context.Context, content string, opts ShortcodeProcessOptions) (string, error)
// Render executes a single shortcode directly via the renderer pipeline.
Render(ctx ShortcodeContext, shortcode string, params map[string]any, inner string) (template.HTML, error)
}
ShortcodeService exposes high-level helpers for rendering shortcodes embedded in arbitrary content.
type ShortcodeValidator ¶ added in v0.2.0
ShortcodeValidator allows definitions to perform custom validation.
type SignedURL ¶
SignedURL represents an expiring URL that grants temporary access to a media resource.
type SnapshotRequest ¶ added in v0.37.0
type SnapshotRequest = flow.SnapshotRequest[WorkflowMessage]
type StateDefinition ¶ added in v0.37.0
type StateDefinition = flow.StateDefinition
type StepDefinition ¶ added in v0.37.0
type StepDefinition = flow.StepDefinition
type StorageCapabilityReporter ¶ added in v0.2.0
type StorageCapabilityReporter interface {
Capabilities() storage.Capabilities
}
StorageCapabilityReporter mirrors storage.CapabilityReporter for compatibility.
type StorageProvider ¶
StorageProvider preserves backwards compatibility for callers still importing the legacy interface location. Implementations should prefer satisfying pkg/storage.Provider (and optional mix-ins) directly.
type StorageReloadable ¶ added in v0.2.0
StorageReloadable mirrors storage.Reloadable for compatibility.
type SyncOptions ¶
type SyncOptions struct {
ImportOptions
DeleteOrphaned bool
UpdateExisting bool
}
SyncOptions extends ImportOptions to handle update/delete semantics for repeated synchronisation runs.
type SyncResult ¶
SyncResult summarises a bulk sync run across many files.
type TargetInfo ¶ added in v0.37.0
type TargetInfo = flow.TargetInfo
type TemplateHelperProvider ¶
type TemplateHelperProvider interface {
TemplateHelpers(translator Translator, cfg HelperConfig) map[string]any
}
type TemplateRenderer ¶
type TemplateRenderer interface {
Render(name string, data any, out ...io.Writer) (string, error)
RenderTemplate(name string, data any, out ...io.Writer) (string, error)
RenderString(templateContent string, data any, out ...io.Writer) (string, error)
RegisterFilter(name string, fn func(input any, param any) (any, error)) error
GlobalContext(data any) error
}
type TokenService ¶
type TokenService interface {
Generate(identity Identity, resourceRoles map[string]string) (string, error)
Validate(token string) (AuthClaims, error)
}
TokenService provides JWT operations.
type Transaction ¶
type Transaction = storage.Transaction
Transaction aliases the new storage.Transaction type.
type TransitionDefinition ¶ added in v0.37.0
type TransitionDefinition = flow.TransitionDefinition
type TransitionInfo ¶ added in v0.37.0
type TransitionInfo = flow.TransitionInfo
type TransitionResult ¶ added in v0.2.0
type TransitionResult = flow.TransitionResult[WorkflowMessage]
type TransitionWorkflowDefinition ¶ added in v0.37.0
type TransitionWorkflowDefinition = flow.TransitionWorkflowDefinition
type TranslationBundle ¶ added in v0.28.0
type TranslationBundle[T any] struct { Meta TranslationMeta `json:"meta"` Requested *T `json:"requested"` Resolved *T `json:"resolved"` }
TranslationBundle wraps requested/resolved translations with locale metadata.
type TranslationCheckOptions ¶ added in v0.29.0
type TranslationCheckOptions struct {
State string
Environment string
Version string
RequiredFields map[string][]string
RequiredFieldsStrategy RequiredFieldsValidationStrategy
}
TranslationCheckOptions configures translation completeness checks.
RequiredFields keys are locale codes (case-insensitive). The per-locale field list follows these rules:
- Pages: field keys refer to page translation fields: title, path, summary, seo_title, seo_description.
- Content: field keys refer to schema field paths in the content translation payload (e.g., body, seo.title).
Unknown required-field keys are handled according to RequiredFieldsStrategy (defaults to "error"). For pages, Version is ignored unless translation snapshots are introduced in the page versioning workflow.
type TranslationMeta ¶ added in v0.28.0
type TranslationMeta struct {
RequestedLocale string `json:"requested_locale"`
ResolvedLocale string `json:"resolved_locale"`
// AvailableLocales is scoped to the bundle's underlying entity (page vs content),
// not a union across multiple bundles.
AvailableLocales []string `json:"available_locales"`
MissingRequestedLocale bool `json:"missing_requested_locale"`
FallbackUsed bool `json:"fallback_used"`
PrimaryLocale string `json:"primary_locale"`
}
TranslationMeta describes locale resolution for a translated record.
type Translator ¶
type TranslatorWithMetadata ¶
type WorkflowDefinition ¶ added in v0.2.0
type WorkflowDefinition = flow.MachineDefinition
type WorkflowDefinitionStore ¶ added in v0.2.0
type WorkflowDefinitionStore interface {
ListWorkflowDefinitions(ctx context.Context) ([]MachineDefinition, error)
}
WorkflowDefinitionStore exposes workflow definitions sourced from external storage.
type WorkflowEngine ¶ added in v0.2.0
type WorkflowEngine interface {
ApplyEvent(ctx context.Context, req ApplyEventRequest) (*ApplyEventResponse, error)
Snapshot(ctx context.Context, req SnapshotRequest) (*Snapshot, error)
RegisterMachine(ctx context.Context, definition MachineDefinition) error
RegisterGuard(name string, guard Guard) error
RegisterDynamicTarget(name string, resolver DynamicTargetResolver) error
RegisterAction(name string, action Action) error
}
WorkflowEngine coordinates lifecycle transitions using canonical FSM envelopes.
type WorkflowMessage ¶ added in v0.37.0
type WorkflowMessage struct {
TypeName string `json:"type,omitempty"`
Payload map[string]any `json:"payload,omitempty"`
}
WorkflowMessage is the canonical workflow payload consumed by FSM envelopes.
func (WorkflowMessage) Type ¶ added in v0.37.0
func (m WorkflowMessage) Type() string
Type satisfies go-command's command.Message contract.
type WorkflowNodeDefinition ¶ added in v0.37.0
type WorkflowNodeDefinition = flow.WorkflowNodeDefinition
type WorkflowState ¶ added in v0.2.0
type WorkflowState = string
type WorkflowStateDefinition ¶ added in v0.2.0
type WorkflowStateDefinition = flow.StateDefinition
type WorkflowTransition ¶ added in v0.2.0
type WorkflowTransition = flow.TransitionDefinition