settings

package
v0.21.1 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2026 License: MIT Imports: 3 Imported by: 0

README

admin/internal/settings

Settings bootstrap defaults and form helpers.

Purpose

  • Derive/register default settings definitions and system-scoped bootstrap values.
  • Provide helpers used by settings forms/adapters without coupling to admin.Admin.

Key Files

  • bootstrap.go: Default definitions + bootstrap application helpers.
  • form_helpers.go: Shared helpers for settings form rendering/adapters.

Dependencies

  • Pure helpers: should depend only on stdlib and minimal function callbacks.
  • Must not import peer feature packages.

Where To Change X

  • Default setting keys/values: bootstrap.go.
  • Form schema shaping: form_helpers.go.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AllowedScopes

func AllowedScopes(scopes []string) []string

AllowedScopes converts a slice of scope identifiers into strings.

func BootstrapDefaults

func BootstrapDefaults(ctx context.Context, cfg BootstrapConfig, register func(DefaultDefinition), applySystem func(context.Context, map[string]any) error) error

BootstrapDefaults registers default settings definitions and applies system values.

func CloneAnyMapValue

func CloneAnyMapValue(input map[string]any) map[string]any

CloneAnyMapValue deep-copies a map[string]any tree.

func EnsureAdminMeta

func EnsureAdminMeta(field map[string]any) map[string]any

EnsureAdminMeta ensures the x-admin metadata container exists on a field.

func EnsureSchemaProperties

func EnsureSchemaProperties(schema map[string]any) map[string]any

EnsureSchemaProperties guarantees an object schema with properties map.

func ExtractSchema

func ExtractSchema(doc opts.SchemaDocument) map[string]any

ExtractSchema returns the root schema from a go-options document.

func ExtractSchemaFromOpenAPI

func ExtractSchemaFromOpenAPI(document map[string]any) map[string]any

ExtractSchemaFromOpenAPI pulls the first requestBody schema from an OpenAPI document.

func MapType

func MapType(t string) string

MapType normalizes admin setting field types to JSON schema types.

func MapWidget

func MapWidget(widget string, fieldType string) string

MapWidget determines a widget hint from an explicit widget or field type.

func SchemaField

func SchemaField(raw any) map[string]any

SchemaField clones a field definition into a mutable map.

func SortRequiredKeys

func SortRequiredKeys(keys map[string]struct{}) []string

SortRequiredKeys sorts required field keys for stable schemas.

Types

type BootstrapConfig

type BootstrapConfig struct {
	Title            string
	DefaultLocale    string
	Theme            string
	DashboardEnabled bool
	SearchEnabled    bool
}

BootstrapConfig captures the inputs needed to derive default settings.

type DefaultDefinition

type DefaultDefinition struct {
	Key         string
	Title       string
	Description string
	Default     any
	Type        string
	Group       string
}

DefaultDefinition describes a basic setting definition used for bootstrap.

func DefaultDefinitions

func DefaultDefinitions(cfg BootstrapConfig) ([]DefaultDefinition, map[string]any)

DefaultDefinitions returns the bootstrap definitions and system-scoped values.

Jump to

Keyboard shortcuts

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