interfaces

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2025 License: MIT Imports: 8 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrJobNotFound reports missing jobs when looking them up by ID or key.
	ErrJobNotFound = errors.New("scheduler: job not found")
)

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 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 CacheProvider interface {
	Get(ctx context.Context, key string) (any, error)
	Set(ctx context.Context, key string, value any, ttl time.Duration) error
	Delete(ctx context.Context, key string) error
	Clear(ctx context.Context) error
}

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 ContentDeleteRequest

type ContentDeleteRequest struct {
	ID         uuid.UUID
	DeletedBy  uuid.UUID
	HardDelete bool
}

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 ContentRecord

type ContentRecord struct {
	ID           uuid.UUID
	ContentType  uuid.UUID
	Slug         string
	Status       string
	Translations []ContentTranslation
	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) (*ContentRecord, error)
	List(ctx context.Context) ([]*ContentRecord, 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
	Locale  string
	Title   string
	Summary *string
	Fields  map[string]any
}

ContentTranslation mirrors stored translation fields.

type ContentTranslationInput

type ContentTranslationInput struct {
	Locale  string
	Title   string
	Summary *string
	Fields  map[string]any
}

ContentTranslationInput represents localized fields provided during create/update.

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
	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 FieldsLogger

type FieldsLogger interface {
	WithFields(fields map[string]any) Logger
}

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 Formatter

type Formatter interface {
	Format(template string, args ...any) (string, error)
}

type FormatterRegistry

type FormatterRegistry interface {
	FuncMap(locale string) map[string]any
}

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 HelperConfig

type HelperConfig struct {
	LocaleKey         string
	TemplateHelperKey string
	OnMissing         MissingTranslationHandler
	Registry          FormatterRegistry
}

type Identity

type Identity interface {
	ID() string
	Username() string
	Email() string
	Role() string
}

type IdentityProvider

type IdentityProvider interface {
	VerifyIdentity(ctx context.Context, identifier, password string) (Identity, error)
	FindIdentityByIdentifier(ctx context.Context, identifier string) (Identity, error)
}

type ImportOptions

type ImportOptions struct {
	ContentTypeID                   uuid.UUID
	AuthorID                        uuid.UUID
	CreatePages                     bool
	TemplateID                      *uuid.UUID
	DryRun                          bool
	ContentAllowMissingTranslations bool
	PageAllowMissingTranslations    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 JobStatus

type JobStatus string

JobStatus describes the lifecycle of a scheduled job.

const (
	JobStatusPending   JobStatus = "pending"
	JobStatusCompleted JobStatus = "completed"
	JobStatusCanceled  JobStatus = "canceled"
	JobStatusFailed    JobStatus = "failed"
)

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

type LoggerProvider interface {
	GetLogger(name string) Logger
}

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 LoginPayload interface {
	GetIdentifier() string
	GetPassword() string
	GetExtendedSession() bool
}

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 MissingTranslationHandler

type MissingTranslationHandler func(locale, key string, args []any, err error) string

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

type PageDeleteRequest struct {
	ID         uuid.UUID
	DeletedBy  uuid.UUID
	HardDelete bool
}

PageDeleteRequest captures the information required to remove a page.

type PageDeleteTranslationRequest added in v0.2.0

type PageDeleteTranslationRequest struct {
	PageID    uuid.UUID
	Locale    string
	DeletedBy uuid.UUID
}

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

type PageMoveRequest struct {
	PageID      uuid.UUID
	NewParentID *uuid.UUID
	ActorID     uuid.UUID
}

PageMoveRequest updates the parent relationship.

type PageRecord

type PageRecord struct {
	ID           uuid.UUID
	ContentID    uuid.UUID
	TemplateID   uuid.UUID
	Slug         string
	Status       string
	Translations []PageTranslation
	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) (*PageRecord, error)
	List(ctx context.Context) ([]*PageRecord, 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 markdown imports.

type PageTranslation

type PageTranslation struct {
	ID      uuid.UUID
	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

type ParsedShortcode struct {
	Name   string
	Params map[string]any
	Inner  string
}

ParsedShortcode represents a parsed invocation discovered by the parser layer.

type ResourceRoleProvider

type ResourceRoleProvider interface {
	FindResourceRoles(ctx context.Context, identity Identity) (map[string]string, error)
}

type Result

type Result = storage.Result

Result aliases the new storage.Result type.

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 Rows

type Rows = storage.Rows

Rows aliases the new storage.Rows type.

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

type ShortcodeValidator func(value any) error

ShortcodeValidator allows definitions to perform custom validation.

type SignedURL

type SignedURL struct {
	URL       string
	Method    string
	Headers   map[string]string
	ExpiresAt time.Time
}

SignedURL represents an expiring URL that grants temporary access to a media resource.

type StorageCapabilityReporter added in v0.2.0

type StorageCapabilityReporter interface {
	Capabilities() storage.Capabilities
}

StorageCapabilityReporter mirrors storage.CapabilityReporter for compatibility.

type StorageProvider

type StorageProvider = storage.Provider

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

type StorageReloadable interface {
	Reload(ctx context.Context, cfg storage.Config) error
}

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

type SyncResult struct {
	Created int
	Updated int
	Deleted int
	Skipped int
	Errors  []error
}

SyncResult summarises a bulk sync run across many files.

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 TransitionInput added in v0.2.0

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

TransitionInput captures the data required to run a workflow transition.

type TransitionQuery added in v0.2.0

type TransitionQuery struct {
	EntityType string
	State      WorkflowState
	Context    map[string]any
}

TransitionQuery describes the state for which transitions should be listed.

type TransitionResult added in v0.2.0

type TransitionResult struct {
	EntityID      uuid.UUID
	EntityType    string
	Transition    string
	FromState     WorkflowState
	ToState       WorkflowState
	CompletedAt   time.Time
	ActorID       uuid.UUID
	Metadata      map[string]any
	Events        []WorkflowEvent
	Notifications []WorkflowNotification
}

TransitionResult describes the outcome of a workflow transition.

type Translator

type Translator interface {
	Translate(locale, key string, args ...any) (string, error)
}

type TranslatorWithMetadata

type TranslatorWithMetadata interface {
	TranslatorWithMetadata(locale, key string, args ...any) (string, map[string]any, error)
}

type UserRole

type UserRole string
const (
	RoleGuest  UserRole = "guest"
	RoleMember UserRole = "member"
	RoleAdmin  UserRole = "admin"
	RoleOwner  UserRole = "owner"
)

func (UserRole) CanCreate

func (r UserRole) CanCreate() bool

func (UserRole) CanDelete

func (r UserRole) CanDelete() bool

func (UserRole) CanEdit

func (r UserRole) CanEdit() bool

func (UserRole) CanRead

func (r UserRole) CanRead() bool

func (UserRole) IsAtLeast

func (r UserRole) IsAtLeast(minRole UserRole) bool

func (UserRole) IsValid

func (r UserRole) IsValid() bool

type WorkflowAuthorizer added in v0.2.0

type WorkflowAuthorizer interface {
	AuthorizeTransition(ctx context.Context, input TransitionInput, guard string) error
}

WorkflowAuthorizer evaluates guard expressions attached to workflow transitions. Returning nil authorises the transition; returning an error prevents it.

type WorkflowDefinition added in v0.2.0

type WorkflowDefinition struct {
	EntityType   string
	InitialState WorkflowState
	States       []WorkflowStateDefinition
	Transitions  []WorkflowTransition
}

WorkflowDefinition describes a state machine for a specific entity type.

type WorkflowDefinitionStore added in v0.2.0

type WorkflowDefinitionStore interface {
	ListWorkflowDefinitions(ctx context.Context) ([]WorkflowDefinition, error)
}

WorkflowDefinitionStore exposes workflow definitions sourced from external storage.

type WorkflowEngine added in v0.2.0

type WorkflowEngine interface {
	// Transition applies the named transition (or explicit state change) to the entity.
	Transition(ctx context.Context, input TransitionInput) (*TransitionResult, error)
	// AvailableTransitions lists the possible transitions from the supplied state.
	AvailableTransitions(ctx context.Context, query TransitionQuery) ([]WorkflowTransition, error)
	// RegisterWorkflow installs or replaces a workflow definition for the given entity type.
	RegisterWorkflow(ctx context.Context, definition WorkflowDefinition) error
}

WorkflowEngine coordinates lifecycle transitions for domain entities.

type WorkflowEvent added in v0.2.0

type WorkflowEvent struct {
	Name      string
	Timestamp time.Time
	Payload   map[string]any
}

WorkflowEvent represents an emitted domain event during a transition.

type WorkflowNotification added in v0.2.0

type WorkflowNotification struct {
	Channel string
	Message string
	Data    map[string]any
}

WorkflowNotification represents a downstream notification request driven by a transition.

type WorkflowState added in v0.2.0

type WorkflowState string

WorkflowState represents a lifecycle stage understood by workflow engines.

type WorkflowStateDefinition added in v0.2.0

type WorkflowStateDefinition struct {
	Name        WorkflowState
	Description string
	Terminal    bool
}

WorkflowStateDefinition documents a workflow state.

type WorkflowTransition added in v0.2.0

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

WorkflowTransition declares an allowed transition between two states.

Jump to

Keyboard shortcuts

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