Documentation
¶
Overview ¶
Package internal implements the workflow-plugin-cms plugin — the CMS engine used by gocodealone-multisite to serve multi-tenant content sites from a single workflow app.
Module types provided:
- cms.tenant_resolver — Host → tenant_id middleware (V1, V2)
- cms.static_serve_before_dynamic — static-wins routing (V3)
- cms.engine — page CRUD + render + dynamic-section substitution + theme resolver
- analytics.injection — per-tenant Google Analytics injection (delegated to workflow-plugin-analytics when present; V25)
Step types provided:
- step.cms_render_page — render a CMS page for the resolved tenant
- step.cms_bundle_activate — atomic-swap a fetched bundle into place
Index ¶
- Variables
- func CMSAdminContributionMetadata(authorized bool) map[string]string
- func DisableOverlay(overlay *StaticPageOverlay)
- func NewPlugin() sdk.PluginProvider
- func OverlayActiveForRender(overlay *StaticPageOverlay) bool
- func PagePubliclyRenderable(page *store.Page, now time.Time) bool
- func RenderPageDocument(page *store.Page, template PageTemplate, now time.Time) (string, bool, error)
- func RenderWidgetInstance(instance WidgetInstance, registry WidgetRegistry) (string, error)
- func ValidateNavigationItem(item NavigationItem) error
- func ValidatePublishedMediaReference(reference string, policy MediaPolicy) error
- func ValidateWidgetRegistry(registry WidgetRegistry) error
- func WithTenant(ctx context.Context, info TenantInfo) context.Context
- type AdminAPI
- type AdminContribution
- type CMSPlugin
- func (p *CMSPlugin) ContractRegistry() *pb.ContractRegistry
- func (p *CMSPlugin) CreateModule(typeName, name string, config map[string]any) (sdk.ModuleInstance, error)
- func (p *CMSPlugin) CreateStep(typeName, name string, config map[string]any) (sdk.StepInstance, error)
- func (p *CMSPlugin) Manifest() sdk.PluginManifest
- func (p *CMSPlugin) ModuleTypes() []string
- func (p *CMSPlugin) StepTypes() []string
- type MediaPolicy
- type NavStatus
- type NavTargetKind
- type NavigationItem
- type OverlayMode
- type OverlayPublishResult
- type OverlaySelector
- type OverlayStatus
- type PageTemplate
- type StaticPageOverlay
- type StaticPageOverlayInput
- type TenantInfo
- type TenantStore
- type WidgetInstance
- type WidgetRegistry
- type WidgetType
Constants ¶
This section is empty.
Variables ¶
var Version = "0.0.0"
Version is set at build time via -ldflags.
Functions ¶
func CMSAdminContributionMetadata ¶ added in v0.1.2
CMSAdminContributionMetadata returns API routes only after the host has already established admin authorization for this contribution.
func DisableOverlay ¶ added in v0.1.2
func DisableOverlay(overlay *StaticPageOverlay)
func OverlayActiveForRender ¶ added in v0.1.2
func OverlayActiveForRender(overlay *StaticPageOverlay) bool
func PagePubliclyRenderable ¶ added in v0.1.2
PagePubliclyRenderable reports whether a page should be served publicly at now. Admin preview flows should use a separate path and explicit authz.
func RenderPageDocument ¶ added in v0.1.2
func RenderPageDocument(page *store.Page, template PageTemplate, now time.Time) (string, bool, error)
RenderPageDocument renders a public CMS page. It returns rendered=false for non-public states so callers can continue to fallback routing without exposing draft or future content.
func RenderWidgetInstance ¶ added in v0.1.2
func RenderWidgetInstance(instance WidgetInstance, registry WidgetRegistry) (string, error)
func ValidateNavigationItem ¶ added in v0.1.2
func ValidateNavigationItem(item NavigationItem) error
func ValidatePublishedMediaReference ¶ added in v0.1.2
func ValidatePublishedMediaReference(reference string, policy MediaPolicy) error
func ValidateWidgetRegistry ¶ added in v0.1.2
func ValidateWidgetRegistry(registry WidgetRegistry) error
func WithTenant ¶
func WithTenant(ctx context.Context, info TenantInfo) context.Context
WithTenant returns a context carrying the resolved tenant.
Types ¶
type AdminAPI ¶
type AdminAPI struct {
ReloadFunc func() error
PreviewBase string
Audit *audit.Logger
AuditActor func(*http.Request) string
// contains filtered or unexported fields
}
AdminAPI is the HTTP surface for the multisite admin.
Per SPEC §I/T16: tenant CRUD, domain CRUD, page CRUD. Routes are mounted by the host at /api/v1/admin/* (see gocodealone-multisite app.yaml). The host wraps every endpoint with auth + authz middleware; this layer assumes the request is already authenticated.
Tenant scope for page endpoints comes from the URL path (/api/v1/admin/tenants/:id/pages...) — V12 isolation is enforced by passing tenantID as the first arg after ctx into every store call.
ReloadFunc is optional; when set, POST /api/v1/admin/reload invokes it to flush in-memory caches (tenant resolver, page renderer). See SPEC T31.
PreviewBase is the FQDN suffix for auto-provisioned preview subdomains. When non-empty, CreateTenant also creates a `<slug>.<preview_base>` domain row (V18 / T32). Empty disables auto-provision.
func NewAdminAPI ¶
func NewAdminAPI(tenants store.TenantAdminStore, pages store.PageStore) *AdminAPI
NewAdminAPI returns a handler using the given stores. Either store may be the in-memory implementation (default) or a postgres-backed production impl.
type AdminContribution ¶ added in v0.1.2
type AdminContribution struct {
ID string
Title string
Category string
Path string
RenderMode string
AppContext string
Permissions []string
Metadata map[string]string
Actions []string
}
AdminContribution describes a CMS admin surface in the shape expected by workflow-plugin-admin, without depending on that plugin's generated types.
func CMSAdminContribution ¶ added in v0.1.2
func CMSAdminContribution() AdminContribution
CMSAdminContribution returns the site-management admin surface metadata.
type CMSPlugin ¶
type CMSPlugin struct{}
CMSPlugin implements sdk.PluginProvider.
func (*CMSPlugin) ContractRegistry ¶ added in v0.1.2
func (p *CMSPlugin) ContractRegistry() *pb.ContractRegistry
ContractRegistry returns the CMS plugin's strict protobuf contracts.
func (*CMSPlugin) CreateModule ¶
func (p *CMSPlugin) CreateModule(typeName, name string, config map[string]any) (sdk.ModuleInstance, error)
CreateModule creates a module instance of the given type.
func (*CMSPlugin) CreateStep ¶
func (p *CMSPlugin) CreateStep(typeName, name string, config map[string]any) (sdk.StepInstance, error)
CreateStep creates a pipeline step instance of the given type.
func (*CMSPlugin) Manifest ¶
func (p *CMSPlugin) Manifest() sdk.PluginManifest
Manifest returns plugin metadata.
func (*CMSPlugin) ModuleTypes ¶
ModuleTypes returns the module types this plugin provides.
type MediaPolicy ¶ added in v0.1.2
type MediaPolicy struct {
AllowedObjectPrefixes []string `json:"allowed_object_prefixes"`
}
type NavigationItem ¶ added in v0.1.2
type NavigationItem struct {
}
func PublishedNavigation ¶ added in v0.1.2
func PublishedNavigation(items []NavigationItem, now time.Time) ([]NavigationItem, error)
type OverlayMode ¶ added in v0.1.2
type OverlayMode string
const ( OverlayModeReplace OverlayMode = "replace" OverlayModeAppend OverlayMode = "append" OverlayModePrepend OverlayMode = "prepend" OverlayModeRemove OverlayMode = "remove" )
type OverlayPublishResult ¶ added in v0.1.2
func PublishOverlay ¶ added in v0.1.2
func PublishOverlay(overlay *StaticPageOverlay, currentSourceHash string, force bool) (OverlayPublishResult, error)
type OverlaySelector ¶ added in v0.1.2
type OverlaySelector struct {
Selector string `json:"selector"`
Mode OverlayMode `json:"mode"`
}
type OverlayStatus ¶ added in v0.1.2
type OverlayStatus string
const ( OverlayStatusDraft OverlayStatus = "draft" OverlayStatusPublished OverlayStatus = "published" OverlayStatusConflictReview OverlayStatus = "conflict_review" OverlayStatusDisabled OverlayStatus = "disabled" )
type PageTemplate ¶ added in v0.1.2
PageTemplate is the shell used to wrap a CMS page body.
type StaticPageOverlay ¶ added in v0.1.2
type StaticPageOverlay struct {
TenantID int64
SourcePath string
SourceHash string
Selectors []OverlaySelector
DraftBlocks json.RawMessage
Status OverlayStatus
Enabled bool
}
func NewStaticPageOverlay ¶ added in v0.1.2
func NewStaticPageOverlay(input StaticPageOverlayInput) (*StaticPageOverlay, error)
type StaticPageOverlayInput ¶ added in v0.1.2
type StaticPageOverlayInput struct {
TenantID int64 `json:"tenant_id"`
SourcePath string `json:"source_path"`
SourceHash string `json:"source_hash"`
Selectors []OverlaySelector `json:"selectors"`
DraftBlocks json.RawMessage `json:"draft_blocks"`
}
type TenantInfo ¶
type TenantInfo struct {
TenantID int64
TenantSlug string
SubsiteLabel string // empty if no subsite scope
Kind string // "vanity" | "preview" | "subdomain"
}
TenantInfo is the resolved tenant + optional subsite for a request.
func TenantFromContext ¶
func TenantFromContext(ctx context.Context) (TenantInfo, bool)
TenantFromContext returns the tenant resolved upstream, or ok=false if none was set (request would not have reached this point through the normal flow).
type TenantStore ¶
type TenantStore interface {
// Lookup returns the tenant for an exact domain match. ok=false on miss.
Lookup(ctx context.Context, host string) (TenantInfo, bool)
// LookupBySlug resolves a preview subdomain pattern (<slug>.<base>).
LookupBySlug(ctx context.Context, slug string) (TenantInfo, bool)
}
TenantStore looks up tenants by domain. Host wires the production postgres-backed implementation at boot.
type WidgetInstance ¶ added in v0.1.2
type WidgetRegistry ¶ added in v0.1.2
type WidgetRegistry struct {
Types map[string]WidgetType `json:"types"`
}