promotions

package
v0.60.8 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrContentTypeRequiredForSlugs = errors.New("promotions: content type required for content slugs")
	ErrContentTypeEnvMismatch      = errors.New("promotions: content type does not belong to source environment")
	ErrContentTypeFilterMismatch   = errors.New("promotions: content type id and slug do not match")
)

Functions

This section is empty.

Types

type EnvironmentRef

type EnvironmentRef struct {
	ID  uuid.UUID `json:"id"`
	Key string    `json:"key"`
}

EnvironmentRef references an environment in promotion responses.

type PromoteContentEntryRequest

type PromoteContentEntryRequest struct {
	ContentID           uuid.UUID      `json:"-"`
	TargetEnvironment   string         `json:"target_environment,omitempty"`
	TargetEnvironmentID *uuid.UUID     `json:"target_environment_id,omitempty"`
	Options             PromoteOptions `json:"options"`
}

PromoteContentEntryRequest describes a single content entry promotion.

type PromoteContentTypeRequest

type PromoteContentTypeRequest struct {
	ContentTypeID       uuid.UUID      `json:"-"`
	TargetEnvironment   string         `json:"target_environment,omitempty"`
	TargetEnvironmentID *uuid.UUID     `json:"target_environment_id,omitempty"`
	Options             PromoteOptions `json:"options"`
}

PromoteContentTypeRequest describes a single content type promotion.

type PromoteEnvironmentRequest

type PromoteEnvironmentRequest struct {
	SourceEnvironment string `json:"-"`
	TargetEnvironment string `json:"-"`

	Scope                PromoteScope   `json:"scope,omitempty"`
	ContentTypeIDs       []uuid.UUID    `json:"content_type_ids,omitempty"`
	ContentTypeSlugs     []string       `json:"content_type_slugs,omitempty"`
	ContentIDs           []uuid.UUID    `json:"content_ids,omitempty"`
	ContentSlugs         []string       `json:"content_slugs,omitempty"`
	ContentEntryTypeID   *uuid.UUID     `json:"content_entry_type_id,omitempty"`
	ContentEntryTypeSlug string         `json:"content_entry_type_slug,omitempty"`
	Options              PromoteOptions `json:"options"`
}

PromoteEnvironmentRequest describes a bulk environment promotion request.

type PromoteEnvironmentResult

type PromoteEnvironmentResult struct {
	SourceEnv EnvironmentRef `json:"source_env"`
	TargetEnv EnvironmentRef `json:"target_env"`
	Summary   PromoteSummary `json:"summary"`
	Items     []PromoteItem  `json:"items,omitempty"`
	Errors    []PromoteError `json:"errors,omitempty"`
}

PromoteEnvironmentResult captures the bulk promotion response.

type PromoteError

type PromoteError struct {
	Kind     string         `json:"kind"`
	SourceID uuid.UUID      `json:"source_id"`
	Error    string         `json:"error"`
	Details  map[string]any `json:"details,omitempty"`
}

PromoteError describes a promotion failure.

type PromoteItem

type PromoteItem struct {
	Kind     string         `json:"kind"`
	SourceID uuid.UUID      `json:"source_id"`
	TargetID uuid.UUID      `json:"target_id"`
	Status   string         `json:"status"`
	Message  string         `json:"message,omitempty"`
	Details  map[string]any `json:"details,omitempty"`
}

PromoteItem reports a single promoted entity.

type PromoteMode

type PromoteMode string

PromoteMode controls how conflicts are handled.

const (
	ModeStrict PromoteMode = "strict"
	ModeUpsert PromoteMode = "upsert"
)

type PromoteOptions

type PromoteOptions struct {
	AllowBreakingChanges bool        `json:"allow_breaking_changes,omitempty"`
	AllowDraft           bool        `json:"allow_draft,omitempty"`
	PromoteAsActive      bool        `json:"promote_as_active,omitempty"`
	PreferPublished      *bool       `json:"prefer_published,omitempty"`
	PromoteAsPublished   bool        `json:"promote_as_published,omitempty"`
	Mode                 PromoteMode `json:"mode,omitempty"`
	IncludeVersions      bool        `json:"include_versions,omitempty"`
	MigrateOnPromote     *bool       `json:"migrate_on_promote,omitempty"`
	AutoPromoteType      bool        `json:"auto_promote_type,omitempty"`
	Force                bool        `json:"force,omitempty"`
	DryRun               bool        `json:"dry_run,omitempty"`
}

PromoteOptions captures common promotion flags.

type PromoteScope

type PromoteScope string

PromoteScope describes the scope for bulk promotions.

const (
	ScopeContentTypes   PromoteScope = "content_types"
	ScopeContentEntries PromoteScope = "content_entries"
	ScopeAll            PromoteScope = "all"
)

type PromoteSummary

type PromoteSummary struct {
	ContentTypes   PromoteSummaryCounts `json:"content_types"`
	ContentEntries PromoteSummaryCounts `json:"content_entries"`
}

PromoteSummary aggregates counts for bulk promotions.

type PromoteSummaryCounts

type PromoteSummaryCounts struct {
	Created int `json:"created"`
	Updated int `json:"updated"`
	Skipped int `json:"skipped"`
	Failed  int `json:"failed"`
}

PromoteSummaryCounts reports bulk promotion counts per entity type.

type Service

type Service interface {
	PromoteEnvironment(ctx context.Context, req PromoteEnvironmentRequest) (*PromoteEnvironmentResult, error)
	PromoteContentType(ctx context.Context, req PromoteContentTypeRequest) (*PromoteItem, error)
	PromoteContentEntry(ctx context.Context, req PromoteContentEntryRequest) (*PromoteItem, error)
}

Service defines promotion orchestration across environments.

func NewService

func NewService(envSvc cmsenv.Service, contentTypes content.ContentTypeRepository, contents content.ContentRepository, locales content.LocaleRepository, opts ...ServiceOption) Service

NewService constructs the promotion service.

type ServiceOption

type ServiceOption func(*service)

ServiceOption configures the promotion service.

func WithActivityEmitter

func WithActivityEmitter(emitter *activity.Emitter) ServiceOption

WithActivityEmitter wires the activity emitter used for promotion events.

func WithBlockService

func WithBlockService(svc blocks.Service) ServiceOption

WithBlockService wires the block service used for definition promotion.

func WithClock

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

WithClock overrides the clock used for timestamps.

func WithDefaultEnvironmentKey

func WithDefaultEnvironmentKey(key string) ServiceOption

WithDefaultEnvironmentKey overrides the default environment key.

func WithEmbeddedBlocksResolver

func WithEmbeddedBlocksResolver(resolver content.EmbeddedBlocksResolver) ServiceOption

WithEmbeddedBlocksResolver wires the embedded blocks resolver used for content promotions.

func WithIDGenerator

func WithIDGenerator(generator func() uuid.UUID) ServiceOption

WithIDGenerator overrides the ID generator used for new records.

func WithSchemaMigrator

func WithSchemaMigrator(migrator *schema.Migrator) ServiceOption

WithSchemaMigrator wires the schema migrator used for content promotions.

Jump to

Keyboard shortcuts

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