schema

package
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2026 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Overview

Package schema is the settings schema contract shared by Ether's own settings pages and, later, plugin settings (docs/extend/SPEC.md §5.5).

The server serves schemas as settingsSchema descriptors; the console's SchemaForm renders them and never keeps its own copy. Labels and help are extend.Text: built-ins declare them with extend.T so the i18n extractor carries them into the console catalogue, and plugins will carry $t keys.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuiltinDescriptors

func BuiltinDescriptors() ([]extend.Descriptor, error)

BuiltinDescriptors wraps Builtins as settingsSchema descriptors ready for extend.Registry.Register.

func F

func F(v float64) *float64

F takes the address of a number bound for a field literal.

func Known

func Known(k Kind) bool

Known reports whether k is a field kind both sides render.

func ValidateSchema

func ValidateSchema(s Schema, forPlugin bool) error

ValidateSchema checks a schema itself. Plugin schemas (forPlugin) may not use the json kind and must follow the copy rules of SPEC §5.5.

func ValidateValues

func ValidateValues(s Schema, values map[string]any) map[string]string

ValidateValues checks values against s and returns field errors keyed by JSON pointer ("/port", "/rtxVideo/mode"). Missing optional fields are fine; keys the schema does not name are ignored so newer servers can add fields without breaking older stored settings. Plugin settings use this before their own /ether/configure check.

Types

type Builtin

type Builtin struct {
	ID string `json:"id"`
	// ConfigKey is the config.json section the form edits, when it edits one.
	ConfigKey string      `json:"configKey,omitempty"`
	Label     extend.Text `json:"label"`
	Schema    Schema      `json:"schema"`
}

Builtin is one built-in settings form served as a descriptor.

func Builtins

func Builtins() []Builtin

Builtins are Ether's own settings forms, served as settingsSchema descriptors. They moved here from web/src/pages/settings/schema.ts with the same copy, order and grouping; testdata/builtins.json is the golden the mock console backend is held to.

type Field

type Field struct {
	Key   string      `json:"key"`
	Label extend.Text `json:"label"`
	Help  extend.Text `json:"help,omitempty"`
	Kind  Kind        `json:"kind"`

	Placeholder string   `json:"placeholder,omitempty"`
	Wide        bool     `json:"wide,omitempty"`
	Min         *float64 `json:"min,omitempty"`
	Max         *float64 `json:"max,omitempty"`
	Step        *float64 `json:"step,omitempty"`
	// Unit is shown beside number and bytes inputs ("GiB", "p", "chunks").
	Unit extend.Text `json:"unit,omitempty"`
	// Numeric stores select, list, multiSelect and orderedList values as
	// numbers instead of strings.
	Numeric  bool `json:"numeric,omitempty"`
	Required bool `json:"required,omitempty"`

	Options []Option `json:"options,omitempty"`
	// OptionsFrom names a runtime option source (a plugin's
	// GET /ether/options/{field}) used when Options is empty.
	OptionsFrom string  `json:"optionsFrom,omitempty"`
	Fields      []Field `json:"fields,omitempty"` // KindGroup only
}

Field is one setting. Only the fields a kind uses are set.

func (Field) MarshalJSON

func (f Field) MarshalJSON() ([]byte, error)

MarshalJSON drops empty Text values (encoding/json keeps zero structs despite omitempty), so served schemas carry no "help": {} noise.

type Group

type Group struct {
	ID          string      `json:"id,omitempty"`
	Title       extend.Text `json:"title,omitempty"`
	Description extend.Text `json:"description,omitempty"`
	Fields      []Field     `json:"fields"`
	More        []Field     `json:"more,omitempty"`
}

Group is one section of a schema. More holds the advanced fields the console shows after "More options".

func (Group) MarshalJSON

func (g Group) MarshalJSON() ([]byte, error)

MarshalJSON drops an empty title and description.

type Kind

type Kind string

Kind names one field editor. The console mirrors this list in web/src/pages/settings/SchemaForm.tsx.

const (
	KindGroup    Kind = "group"
	KindText     Kind = "text"
	KindSecret   Kind = "secret"
	KindDuration Kind = "duration"
	KindReadonly Kind = "readonly"
	KindNumber   Kind = "number"
	KindBool     Kind = "bool"
	KindSelect   Kind = "select"
	KindList     Kind = "list"
	KindBytes    Kind = "bytes"
	// KindJSON is built-ins only; plugin schemas may not use it.
	KindJSON        Kind = "json"
	KindHidden      Kind = "hidden"
	KindMultiSelect Kind = "multiSelect"
	KindOrderedList Kind = "orderedList"
	// KindLanguage is an ISO 639 language (optionally with a region, en-US).
	KindLanguage   Kind = "language"
	KindViewer     Kind = "viewer"
	KindCollection Kind = "collection"
	// KindFolder is a folder path on the server. Plugin schemas may use it
	// only with the folders permission.
	KindFolder Kind = "folder"
	KindURL    Kind = "url"
	// KindTitle is one catalogue title, picked with TitleSearch.
	KindTitle Kind = "title"
)

type Option

type Option struct {
	Value string      `json:"value"`
	Label extend.Text `json:"label"`
}

Option is one choice for select, multiSelect and orderedList fields.

type Schema

type Schema struct {
	Groups []Group `json:"groups"`
}

Schema is a full settings form.

func (Schema) Meta

func (s Schema) Meta(configKey string) extend.SettingsSchemaMeta

Meta wraps the schema as a settingsSchema descriptor's Meta.

Jump to

Keyboard shortcuts

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