setup

package
v0.25.0 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2026 License: MIT Imports: 62 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// NavigationMenuCode is the default menu identifier for the admin sidebar.
	NavigationMenuCode = "admin_main"
	// SiteNavigationMenuCode is the default menu identifier for the public site navigation.
	SiteNavigationMenuCode = "site_main"
	// NavigationGroupMain is the parent node for primary navigation entries.
	NavigationGroupMain = NavigationMenuCode + ".nav-group-main"
	// NavigationGroupOthers groups secondary/utility links.
	NavigationGroupOthers = NavigationMenuCode + ".nav-group-others"
	// NavigationSectionContent wraps content-related modules (pages, posts, media).
	NavigationSectionContent = NavigationGroupMain + ".content"
	// NavigationSectionDashboard is the top-level dashboard link.
	NavigationSectionDashboard = NavigationGroupMain + ".dashboard"
	// NavigationSectionShop demonstrates a nested submenu.
	NavigationSectionShop = NavigationGroupMain + ".shop"
)
View Source
const (
	FeatureUserInvites      = "users.invite"
	FeaturePasswordReset    = "users.password_reset"
	FeatureSelfRegistration = "users.signup"
)

Variables

This section is empty.

Functions

func EnsureContentParentPermissions added in v0.25.0

func EnsureContentParentPermissions(ctx context.Context, menuSvc admin.CMSMenuService, menuCode, locale string) error

EnsureContentParentPermissions reconciles the persisted Content parent permissions so newly introduced content surfaces remain visible without forcing a full menu reset.

func EnsureDashboardFirst

func EnsureDashboardFirst(ctx context.Context, menuSvc admin.CMSMenuService, basePath, menuCode, locale string) error

EnsureDashboardFirst updates persisted menu item positions so Dashboard renders before Content. This is useful for persistent CMS backends where module menu items are only inserted once.

func EnsureDashboardFirstWithOptions added in v0.25.0

func EnsureDashboardFirstWithOptions(ctx context.Context, menuSvc admin.CMSMenuService, basePath, menuCode, locale string, opts EnsureDashboardFirstOptions) error

EnsureDashboardFirstWithOptions updates persisted menu ordering with optional content-parent tuning.

func LoadSeedGroup added in v0.24.0

func LoadSeedGroup(ctx context.Context, client *persistence.Client, cfg SeedConfig, group SeedGroup) error

LoadSeedGroup loads fixtures for a specific group (users, cms).

func NewDashboardRenderer

func NewDashboardRenderer() (admin.DashboardRenderer, error)

NewDashboardRenderer creates a template-based dashboard renderer

func NewGoUsersActivityAdapter

func NewGoUsersActivityAdapter(sink types.ActivitySink, repo types.ActivityRepository) admin.ActivitySink

NewGoUsersActivityAdapter bridges go-users activity sink/repo into admin.

func NewMediaPanelBuilder

func NewMediaPanelBuilder(store *stores.MediaStore) *admin.PanelBuilder

NewMediaPanelBuilder creates a panel builder for media

func NewPagesPanelBuilder

func NewPagesPanelBuilder(store stores.PageRepository) *admin.PanelBuilder

NewPagesPanelBuilder creates a panel builder for pages

func NewPostsPanelBuilder

func NewPostsPanelBuilder(store stores.PostRepository) *admin.PanelBuilder

NewPostsPanelBuilder creates a panel builder for posts

func NewSecureLinkManager added in v0.19.0

func NewSecureLinkManager() (userstypes.SecureLinkManager, error)

NewSecureLinkManager builds a securelink manager for onboarding flows.

func NewUserPanelBuilder

func NewUserPanelBuilder(store *stores.UserStore) *admin.PanelBuilder

NewUserPanelBuilder creates a panel builder for users

func NewUserProfilesPanelBuilder added in v0.24.0

func NewUserProfilesPanelBuilder(store *stores.UserProfileStore) *admin.PanelBuilder

NewUserProfilesPanelBuilder creates a panel builder for user profiles.

func PasswordPolicyHints added in v0.19.0

func PasswordPolicyHints() []string

PasswordPolicyHints returns UI hints for password requirements.

func RegisterSeedModels added in v0.24.0

func RegisterSeedModels()

RegisterSeedModels registers Bun models used by fixture files.

func RegisterSeedModelsOnDB added in v0.24.0

func RegisterSeedModelsOnDB(db *bun.DB)

RegisterSeedModelsOnDB ensures seed models are registered for a specific Bun DB.

func RemoveLegacyTranslationToolsMenuItems added in v0.25.0

func RemoveLegacyTranslationToolsMenuItems(ctx context.Context, menuSvc admin.CMSMenuService, menuCode, locale string) error

RemoveLegacyTranslationToolsMenuItems removes translation links previously seeded under Tools. Translation navigation is rendered via the dedicated Translations menu in the UI.

func RemovePrimarySettingsMenuItems added in v0.25.0

func RemovePrimarySettingsMenuItems(ctx context.Context, menuSvc admin.CMSMenuService, menuCode, locale string) error

RemovePrimarySettingsMenuItems removes settings links from a primary menu. This keeps examples that use a dedicated utility menu from showing duplicates.

func ResolveUsersDSN

func ResolveUsersDSN() string

ResolveUsersDSN returns the SQLite DSN shared with the rest of the example (CMS).

func SeedAdminNavigation

func SeedAdminNavigation(ctx context.Context, menuSvc admin.CMSMenuService, cfg admin.Config, modules []admin.Module, gates featureGates, isDev bool) error

SeedAdminNavigation converges the example admin navigation menu so parent scaffolding, ordering, and module-contributed items remain deterministic across restarts.

When the CMS menu service is backed by go-cms, this uses cms.SeedMenu with Ensure enabled (and PruneUnspecified in development) so sibling ordering is repaired without ad-hoc resets.

func SeedUsers

func SeedUsers(ctx context.Context, deps stores.UserDependencies, preferenceRepo *preferences.Repository) error

SeedUsers inserts the demo users into SQLite and seeds preferences.

func SetupActivityWithGoUsers

func SetupActivityWithGoUsers() admin.ActivitySink

SetupActivityWithGoUsers provisions a go-users-compatible activity sink. It returns an admin.ActivitySink that logs to a go-users ActivitySink/Repository while retaining the admin UI fallback buffer via ActivitySinkAdapter.

func SetupAuth

SetupAuth wires go-auth middleware and authorizer with the admin orchestrator. It returns the admin authenticator adapter, the underlying RouteAuthenticator, the Auther, and the context key used for the auth cookie.

func SetupDashboard

func SetupDashboard(adm *admin.Admin, dataStores *stores.DataStores, basePath string)

SetupDashboard configures dashboard widgets for the admin panel

func SetupNavigation

func SetupNavigation(ctx context.Context, menuSvc admin.CMSMenuService, basePath, menuCode, locale string) error

SetupNavigation seeds the CMS menu service with grouped, translatable navigation.

func SetupPersistentCMS

func SetupPersistentCMS(ctx context.Context, defaultLocale, dsn string) (admin.CMSOptions, error)

SetupPersistentCMS wires a go-cms container backed by Bun/SQLite and applies migrations. DSN falls back to a temp file (under /tmp) when none is provided and can be overridden via CONTENT_DATABASE_DSN (preferred) or CMS_DATABASE_DSN to keep env parity with the existing example.

func SetupPersistentWorkflowRuntime added in v0.25.0

func SetupPersistentWorkflowRuntime(ctx context.Context, dsn string) (coreadmin.WorkflowRuntime, error)

SetupPersistentWorkflowRuntime wires a Bun-backed workflow runtime on the same DSN used by persistent CMS mode and applies workflow runtime migrations.

func SetupSettings

func SetupSettings(adm *admin.Admin)

SetupSettings configures settings definitions for the admin panel.

func SetupSettingsWithOptions

func SetupSettingsWithOptions(adm *admin.Admin)

SetupSettingsWithOptions swaps the settings backend to the go-options adapter.

Types

type ActivityFeedWidgetData added in v0.25.0

type ActivityFeedWidgetData struct {
	Entries []admin.ActivityEntry `json:"entries"`
}

type AuthOption added in v0.11.0

type AuthOption func(*authOptions)

AuthOption configures optional demo auth behavior.

func WithDefaultScope added in v0.11.0

func WithDefaultScope(tenantID, orgID string) AuthOption

WithDefaultScope injects tenant/org metadata into demo JWTs when available.

func WithPermissionResolverCacheTTL added in v0.25.0

func WithPermissionResolverCacheTTL(ttl time.Duration) AuthOption

WithPermissionResolverCacheTTL overrides resolver cache TTL (cross-request cache).

type ChartWidgetData added in v0.25.0

type ChartWidgetData struct {
	ChartType       string         `json:"chart_type"`
	Title           string         `json:"title"`
	Subtitle        string         `json:"subtitle,omitempty"`
	Theme           string         `json:"theme"`
	ChartAssetsHost string         `json:"chart_assets_host"`
	ChartOptions    map[string]any `json:"chart_options"`
	FooterNote      string         `json:"footer_note,omitempty"`
}

type ContentStatsWidgetData added in v0.25.0

type ContentStatsWidgetData struct {
	Type      string `json:"type"`
	StatType  string `json:"stat_type"`
	Published int    `json:"published"`
	Draft     int    `json:"draft"`
	Scheduled int    `json:"scheduled"`
}

type EnsureDashboardFirstOptions added in v0.25.0

type EnsureDashboardFirstOptions struct {
	// EnsureContentParentPath controls whether a path is injected into the Content parent target
	// when it is missing. Keeping it false allows the parent to remain non-clickable.
	EnsureContentParentPath bool
}

EnsureDashboardFirstOptions customizes dashboard/content menu reconciliation behavior.

type GoUsersPreferencesStore

type GoUsersPreferencesStore = quickstart.GoUsersPreferencesStore

GoUsersPreferencesStore bridges go-users preferences into the admin preferences contract.

func NewGoUsersPreferencesStore

func NewGoUsersPreferencesStore(repo types.PreferenceRepository) (*GoUsersPreferencesStore, error)

NewGoUsersPreferencesStore builds a preferences store backed by go-users.

type LegacyChartSampleWidgetData added in v0.25.0

type LegacyChartSampleWidgetData struct {
	Disabled bool `json:"disabled"`
}
type NavigationIntegrityReport struct {
	MenuCode        string
	Locale          string
	NodeCount       int
	RootCount       int
	OrphanCount     int
	CycleCount      int
	SelfParentCount int
	RepairedCount   int
}

NavigationIntegrityReport captures lightweight health metrics for a persisted menu tree.

func AnalyzeNavigationIntegrity added in v0.25.0

func AnalyzeNavigationIntegrity(items []admin.MenuItem, menuCode, locale string) NavigationIntegrityReport

AnalyzeNavigationIntegrity summarizes the current in-memory navigation tree shape.

func LogNavigationIntegritySummary added in v0.25.0

func LogNavigationIntegritySummary(ctx context.Context, menuSvc admin.CMSMenuService, menuCode, locale string) (NavigationIntegrityReport, error)

LogNavigationIntegritySummary emits a compact startup health summary for persisted navigation.

func RepairNavigationIntegrity added in v0.25.0

func RepairNavigationIntegrity(ctx context.Context, menuSvc admin.CMSMenuService, menuCode, locale string) (NavigationIntegrityReport, error)

RepairNavigationIntegrity repairs known menu corruption patterns and returns a health report.

func (r NavigationIntegrityReport) HasIssues() bool

type OnboardingNotifier

type OnboardingNotifier struct {
	Notifications admin.NotificationService
	Activity      types.ActivitySink
}

OnboardingNotifier fans out invite/reset activity into notifications.

func SetupUsers

SetupUsers wires a go-users stack against the shared SQLite DB (runs migrations).

func SetupUsersWithMigrations added in v0.19.0

SetupUsersWithMigrations wires a go-users stack with a custom migrations registrar.

func (*OnboardingNotifier) HandleActivity

func (n *OnboardingNotifier) HandleActivity(ctx context.Context, record types.ActivityRecord)

HandleActivity attaches to go-users hooks to emit example notifications.

type QuickActionWidgetItem added in v0.25.0

type QuickActionWidgetItem struct {
	Label       string `json:"label"`
	URL         string `json:"url"`
	Icon        string `json:"icon,omitempty"`
	Method      string `json:"method,omitempty"`
	Description string `json:"description,omitempty"`
}

type QuickActionsWidgetData added in v0.25.0

type QuickActionsWidgetData struct {
	Actions []QuickActionWidgetItem `json:"actions"`
}

type RegistrationConfig

type RegistrationConfig struct {
	Mode      RegistrationMode
	Allowlist []string
}

RegistrationConfig controls self-registration guardrails.

func DefaultRegistrationConfig

func DefaultRegistrationConfig() RegistrationConfig

DefaultRegistrationConfig returns a closed registration mode with a sample allowlist.

func (RegistrationConfig) AllowsEmail

func (c RegistrationConfig) AllowsEmail(email string) bool

AllowsEmail reports whether the email is permitted under the current allowlist.

type RegistrationMode

type RegistrationMode string

RegistrationMode governs whether self-registration is open, restricted, or disabled.

const (
	RegistrationClosed    RegistrationMode = "closed"
	RegistrationAllowlist RegistrationMode = "allowlist"
	RegistrationOpen      RegistrationMode = "open"
)

type SecureLinkUIConfig added in v0.19.0

type SecureLinkUIConfig struct {
	QueryKey string
	AsQuery  bool
}

SecureLinkUIConfig exposes link parsing details for UI templates.

func SecureLinkUIConfigFromEnv added in v0.19.0

func SecureLinkUIConfigFromEnv() SecureLinkUIConfig

SecureLinkUIConfigFromEnv returns securelink parsing defaults for templates.

type SeedConfig added in v0.24.0

type SeedConfig struct {
	Enabled          bool
	Truncate         bool
	IgnoreDuplicates bool
}

SeedConfig controls fixture loading behavior.

func SeedConfigFromEnv added in v0.24.0

func SeedConfigFromEnv() SeedConfig

SeedConfigFromEnv builds the seed config from environment variables.

type SeedGroup added in v0.24.0

type SeedGroup string

SeedGroup scopes which fixture folder to load.

const (
	SeedGroupUsers SeedGroup = "users"
	SeedGroupCMS   SeedGroup = "cms"
)

type SeedUserProfile added in v0.24.0

type SeedUserProfile struct {
	bun.BaseModel `bun:"table:user_profiles"`

	UserID      uuid.UUID      `bun:"user_id,pk,type:uuid"`
	DisplayName string         `bun:"display_name"`
	AvatarURL   string         `bun:"avatar_url"`
	Locale      string         `bun:"locale"`
	Timezone    string         `bun:"timezone"`
	Bio         string         `bun:"bio"`
	Contact     map[string]any `bun:"contact,type:jsonb"`
	Metadata    map[string]any `bun:"metadata,type:jsonb"`
	TenantID    uuid.UUID      `bun:"tenant_id,type:uuid"`
	OrgID       uuid.UUID      `bun:"org_id,type:uuid"`
	CreatedAt   time.Time      `bun:"created_at"`
	CreatedBy   uuid.UUID      `bun:"created_by,type:uuid"`
	UpdatedAt   time.Time      `bun:"updated_at"`
	UpdatedBy   uuid.UUID      `bun:"updated_by,type:uuid"`
}

SeedUserProfile mirrors the user_profiles table for fixture loading.

type StorageStatsWidgetData added in v0.25.0

type StorageStatsWidgetData struct {
	Type       string `json:"type"`
	StatType   string `json:"stat_type"`
	Used       string `json:"used"`
	Total      string `json:"total"`
	Percentage int    `json:"percentage"`
}

type SystemHealthWidgetData added in v0.25.0

type SystemHealthWidgetData struct {
	Status     string `json:"status"`
	Uptime     string `json:"uptime"`
	APILatency string `json:"api_latency"`
	DBStatus   string `json:"db_status"`
}

type UserMigrationsPhase added in v0.19.0

type UserMigrationsPhase int

UserMigrationsPhase identifies which migrations should be registered.

const (
	UserMigrationsAuth UserMigrationsPhase = iota
	UserMigrationsCore
)

type UserMigrationsRegistrar added in v0.19.0

type UserMigrationsRegistrar func(*persistence.Client, UserMigrationsPhase) error

UserMigrationsRegistrar registers migrations for the given phase.

func QuickstartUserMigrations added in v0.19.0

func QuickstartUserMigrations() UserMigrationsRegistrar

QuickstartUserMigrations returns a registrar that uses quickstart defaults.

type UserProfileOverviewWidgetData added in v0.25.0

type UserProfileOverviewWidgetData struct {
	Values map[string]string `json:"values"`
}

type UserStatsWidgetData added in v0.25.0

type UserStatsWidgetData struct {
	Type     string `json:"type"`
	StatType string `json:"stat_type"`
	Total    int    `json:"total"`
	Active   int    `json:"active"`
	NewToday int    `json:"new_today"`
	Trend    string `json:"trend"`
	TrendUp  bool   `json:"trend_up"`
}

Jump to

Keyboard shortcuts

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