Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrMarkdownFeatureDisabled is returned when the markdown feature flag is disabled at runtime. ErrMarkdownFeatureDisabled = errors.New("markdown command: feature disabled") )
Functions ¶
This section is empty.
Types ¶
type FeatureGates ¶
type FeatureGates struct {
MarkdownEnabled func() bool
}
FeatureGates exposes runtime feature toggles required by markdown command handlers. Callers should supply closures that read from cms.Config.Features.Markdown so handlers stay decoupled from configuration while honouring feature flags.
type ImportDirectoryCommand ¶
type ImportDirectoryCommand struct {
// Directory selects the filesystem path (relative or absolute) to load Markdown files from.
Directory string `json:"directory"`
// ContentTypeID assigns the target CMS content type for imported documents.
ContentTypeID uuid.UUID `json:"content_type_id,omitempty"`
// AuthorID sets the author reference recorded on created content entities.
AuthorID uuid.UUID `json:"author_id,omitempty"`
// ContentAllowMissingTranslations bypasses translation validation when creating content records.
ContentAllowMissingTranslations bool `json:"content_allow_missing_translations,omitempty"`
// DryRun toggles preview mode to collect import diffs without persisting changes.
DryRun bool `json:"dry_run,omitempty"`
}
ImportDirectoryCommand triggers a filesystem walk for Markdown documents under the provided Directory. The command mirrors markdown.Service ImportDirectory semantics, allowing callers to supply import options that map directly onto interfaces.ImportOptions for content creation.
func (ImportDirectoryCommand) Type ¶
func (ImportDirectoryCommand) Type() string
Type implements command.Message.
func (ImportDirectoryCommand) Validate ¶
func (cmd ImportDirectoryCommand) Validate() error
Validate ensures directory input is present before handlers execute.
type ImportDirectoryHandler ¶
type ImportDirectoryHandler struct {
// contains filtered or unexported fields
}
ImportDirectoryHandler orchestrates Markdown directory imports.
func NewImportDirectoryHandler ¶
func NewImportDirectoryHandler(service interfaces.MarkdownService, logger interfaces.Logger, gates FeatureGates, opts ...ImportDirectoryOption) *ImportDirectoryHandler
NewImportDirectoryHandler creates a handler bound to the supplied Markdown service.
func (*ImportDirectoryHandler) CLIHandler ¶ added in v0.3.0
func (h *ImportDirectoryHandler) CLIHandler() any
CLIHandler exposes the import handler for CLI registration.
func (*ImportDirectoryHandler) CLIOptions ¶ added in v0.3.0
func (h *ImportDirectoryHandler) CLIOptions() command.CLIConfig
CLIOptions describes the CLI metadata for markdown import.
func (*ImportDirectoryHandler) Execute ¶
func (h *ImportDirectoryHandler) Execute(ctx context.Context, msg ImportDirectoryCommand) error
Execute satisfies command.Commander[ImportDirectoryCommand].
type ImportDirectoryOption ¶ added in v0.3.0
type ImportDirectoryOption func(*ImportDirectoryHandler)
ImportDirectoryOption customises the import handler.
func ImportDirectoryWithTimeout ¶ added in v0.3.0
func ImportDirectoryWithTimeout(timeout time.Duration) ImportDirectoryOption
ImportDirectoryWithTimeout overrides the default execution timeout.
type SyncDirectoryCommand ¶
type SyncDirectoryCommand struct {
// Directory selects the filesystem path (relative or absolute) to load Markdown files from.
Directory string `json:"directory"`
// ContentTypeID assigns the target CMS content type for imported documents.
ContentTypeID uuid.UUID `json:"content_type_id,omitempty"`
// AuthorID sets the author reference recorded on created content entities.
AuthorID uuid.UUID `json:"author_id,omitempty"`
// ContentAllowMissingTranslations bypasses translation validation when creating content records.
ContentAllowMissingTranslations bool `json:"content_allow_missing_translations,omitempty"`
// DryRun toggles preview mode to collect import diffs without persisting changes.
DryRun bool `json:"dry_run,omitempty"`
// DeleteOrphaned removes CMS records without matching Markdown files when true.
DeleteOrphaned bool `json:"delete_orphaned,omitempty"`
// UpdateExisting overwrites existing CMS records when Markdown files have changed.
UpdateExisting bool `json:"update_existing,omitempty"`
}
SyncDirectoryCommand orchestrates a Markdown sync run for the provided Directory, applying deletion or update flags consistent with interfaces.SyncOptions.
func (SyncDirectoryCommand) Type ¶
func (SyncDirectoryCommand) Type() string
Type implements command.Message.
func (SyncDirectoryCommand) Validate ¶
func (cmd SyncDirectoryCommand) Validate() error
Validate ensures directory input is present before handlers execute.
type SyncDirectoryHandler ¶
type SyncDirectoryHandler struct {
// contains filtered or unexported fields
}
SyncDirectoryHandler orchestrates Markdown sync workflows.
func NewSyncDirectoryHandler ¶
func NewSyncDirectoryHandler(service interfaces.MarkdownService, logger interfaces.Logger, gates FeatureGates, opts ...SyncDirectoryOption) *SyncDirectoryHandler
NewSyncDirectoryHandler creates a handler bound to the supplied Markdown service.
func (*SyncDirectoryHandler) CLIHandler ¶ added in v0.3.0
func (h *SyncDirectoryHandler) CLIHandler() any
CLIHandler exposes the sync handler for CLI registration.
func (*SyncDirectoryHandler) CLIOptions ¶ added in v0.3.0
func (h *SyncDirectoryHandler) CLIOptions() command.CLIConfig
CLIOptions describes the CLI metadata for markdown sync.
func (*SyncDirectoryHandler) Execute ¶
func (h *SyncDirectoryHandler) Execute(ctx context.Context, msg SyncDirectoryCommand) error
Execute satisfies command.Commander[SyncDirectoryCommand].
type SyncDirectoryOption ¶ added in v0.3.0
type SyncDirectoryOption func(*SyncDirectoryHandler)
SyncDirectoryOption customises the sync handler.
func SyncDirectoryWithTimeout ¶ added in v0.3.0
func SyncDirectoryWithTimeout(timeout time.Duration) SyncDirectoryOption
SyncDirectoryWithTimeout overrides the default execution timeout.