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 ValidateSchema ¶
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 ¶
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.
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 ¶
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 ¶
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" )