Documentation
¶
Index ¶
- Constants
- Variables
- func CheckFields(root []*Node, group string) [][]string
- func ContainerDoc(root []*Node, group string) string
- func Generate(kind string, seed ...any) (string, error)
- func GeneratedBy(root []*Node, group string, field []string) string
- func RequiredPathOf(a *Attribute) string
- func ValidVariableName(s string) error
- func ValidateField(root []*Node, group string, field []string, value any) error
- type Attribute
- func Attributes(attrs ...*Attribute) []*Attribute
- func Bool(name string, options ...Option) *Attribute
- func Bytes(name string, opts ...Option) *Attribute
- func Duration(name string, opts ...Option) *Attribute
- func Float(name string, options ...Option) *Attribute
- func Int(name string, options ...Option) *Attribute
- func String(name string, options ...Option) *Attribute
- func StringSlice(name string, options ...Option) *Attribute
- type AttributeValidator
- type Capability
- type ConditionSpec
- type DerivedBoolSpec
- type Engine
- type EnumBoolSpec
- type FieldCompletion
- type FieldRef
- type FiniteMatcher
- type GroupInfo
- type LocatedError
- type MethodCarrier
- type MethodSpec
- type NextValidation
- type Node
- func Define(match StringMatch, attrs []*Attribute, children ...*Node) *Node
- func DefineGroup(match string, children ...*Node) *Node
- func DefineIter(attrs []*Attribute, extra ...any) *Node
- func DefineIterGroup(attrs []*Attribute, children ...*Node) *Node
- func Root(attrs []*Attribute, children ...*Node) *Node
- type NodeOption
- func Addressing(caps ...Capability) NodeOption
- func AttachesToAll() NodeOption
- func Embeds(names ...string) NodeOption
- func GroupAnnotate(key string, val any) NodeOption
- func GroupDoc(text string) NodeOption
- func Icon(name string) NodeOption
- func Resource(schemaPkg, iface, specType, specPkg string) NodeOption
- func Section(id, title, doc string) NodeOption
- func SectionWhen(id, title, doc, field string, in ...string) NodeOption
- func Singular(goName string) NodeOption
- type ObjectDataType
- type OnlyWhenSpec
- type Option
- func Accessor(goName string) Option
- func Annotate(key string, val any) Option
- func Compat(path ...StringMatch) Option
- func Default[T any](val T) Option
- func DerivedBool(goName string, when map[string]bool, reconstruct map[bool]string) Option
- func Doc(title, desc string) Option
- func EmitValidation(key, validator string) Option
- func EnumBool(goName string, trueWhen, dropWhen []string, decompileAs [2]string) Option
- func Field(goName string) Option
- func Generated(kind string) Option
- func InSection(id string) Option
- func InSet[T string | int | float64](elms ...T) Option
- func IsCID() Option
- func IsEmail() Option
- func IsFqdn() Option
- func IsHttpMethod() Option
- func IsVariableName() Option
- func Key() Option
- func MinInt(min int) Option
- func NoAccessors() Option
- func NoGetter() Option
- func NoSetter() Option
- func NoStructField() Option
- func OnlyWhen(attr string, vals ...string) Option
- func Path(path ...StringMatch) Option
- func Ref(group string, opts ...RefOpt) Option
- func RepoBranch() Option
- func RepoName() Option
- func Required() Option
- func RequiredUnless(field string) Option
- func RequiredWhen(field string, in ...string) Option
- func ShowWhen(field string, in ...string) Option
- func StringShape(literals, prefixes []string) Option
- func Tag(key string) Option
- func Validator[T any](validator func(T) error) Option
- func WireDrop() Option
- type RefOpt
- type RefSpec
- type RequiredField
- type ScalarSpec
- type Schema
- type SectionSpec
- type SeerOps
- type SeerRef
- type ShapeSpec
- type StringMatch
- type StringMatchAll
- type StringMatcher
- type SupportedTypes
- type Type
- type ValidatedField
- type ValidationEmit
Constants ¶
const ( // GenCID mints a fresh CIDv0-shaped id: a base58 sha2-256 multihash over the // seed plus fresh randomness. Unique per call, and parses as a CID (see IsCID). GenCID = "cid" )
Known generator ids. A generated field names one of these; a consumer that doesn't recognize the id treats the field as read-only and leaves it alone.
Variables ¶
var NodeDefaultSeerLeaf = "config"
Functions ¶
func CheckFields ¶ added in v1.2.0
CheckFields returns the authored paths of every partial-checkable field of a resource group (dynamic Either/Key paths, which have no plain path, are skipped). Every addressable field is checkable: at minimum its declared type is enforced, and on top of that any single-value validator and reference existence. It is what a per-resource partial validation iterates.
func ContainerDoc ¶ added in v1.2.0
ContainerDoc returns the document name a container group's instances keep their own fields in ("config"), or "" when group is not a container. A container is a group whose iterator is ITSELF a group over all names (DefineIterGroup) — the same structural test dump.go uses to decide that its instances are directories holding nested resources.
func Generate ¶ added in v1.2.0
Generate mints a value for a generated field. seed is the caller's context (e.g. the resource's address); a generator MUST mix in its own entropy rather than rely on it, so two resources that share a seed still never collide and re-generating one never reproduces the old value.
func GeneratedBy ¶ added in v1.2.0
GeneratedBy reports the generator id declared for a field of a resource group, or "" when the field is authored (or unknown).
func RequiredPathOf ¶ added in v1.2.0
RequiredPathOf is an attribute's authored path as a display/lookup key, or "" when it sits at a dynamic (Either/Key) location with no plain path.
func ValidVariableName ¶ added in v1.3.0
ValidVariableName is the check IsVariableName installs, for callers that must refuse a name before it reaches a config.
func ValidateField ¶ added in v1.2.0
ValidateField runs the single-value validator for one field (by authored path) of a resource group against value. It distinguishes three outcomes so a caller can tell "valid" from "not recognized":
- the field is unknown (no attribute at that plain path) -> an "unknown field" error, so a typo'd path isn't silently reported as OK;
- the field is known but carries no single-value validator -> nil (valid, unconstrained);
- the field has a validator -> its result.
Before the validator, the value is checked against the field's DECLARED TYPE (bool / integer / string / string-array), so a type-only field — one whose sole constraint is its type — is still type-safe (a "true6" into a boolean, or a bare string into an array, is rejected, not stored as-is).
Fields at a dynamic (Either/Key) path have no plain path and read as unknown.
Types ¶
type Attribute ¶
type Attribute struct {
Name string
Type Type
Required bool
Key bool // means the value is the key of a map
Default any
Path []StringMatch
Compat []StringMatch
Validator AttributeValidator
Meta map[string]any // opaque codegen metadata; the engine never interprets it
}
func Attributes ¶
func Duration ¶ added in v1.2.0
Duration and Bytes are String attributes tagged with a ScalarSpec — the codec (authored "20s"/"32GB" <-> typed wire value) and the Go type a generator emits. The engine itself treats them exactly as strings; the ScalarSpec is inert data the driver (Parse/Format) and tcc-gen (GoType) read, so each scalar's meaning lives in one place instead of a switch in every consumer.
func StringSlice ¶
type AttributeValidator ¶
type Capability ¶ added in v1.2.0
type Capability interface {
String() string
}
Capability is an opaque object-addressing tag. The engine requires only that it name itself; the meaning of each value (e.g. "wasm" -> WasmModulePath) lives entirely in the code generator. It is an interface rather than a string alias so callers pass typed capability values, not arbitrary strings, and so richer behaviour can be added later without touching the engine.
type ConditionSpec ¶ added in v1.2.0
ConditionSpec is a simple static visibility condition: show the field or section only when a sibling attribute (Field) holds one of In. Presentation-only — a UI/CLI evaluates it; it never affects parsing or the compiled output. (For compile-time wire-projection gating, that's the separate OnlyWhen.)
type DerivedBoolSpec ¶ added in v1.2.0
type DerivedBoolSpec struct {
GoName string // synthesized bool struct-field name (Function.Secure)
When map[string]bool // source value -> the bool it yields
Reconstruct map[bool]string // bool -> the source value restored on decompile
}
DerivedBoolSpec is the compile/decompile contract for a DerivedBool attribute.
type Engine ¶
type EnumBoolSpec ¶ added in v1.2.0
type EnumBoolSpec struct {
GoName string // bool struct-field name (network-access -> Local/Public)
TrueWhen []string // source values that compile the bool to true
DropWhen []string // source values whose wire key is dropped after projection
DecompileAs [2]string // [falseVal, trueVal] restored on decompile
}
EnumBoolSpec is the compile/decompile contract for an EnumBool attribute.
type FieldCompletion ¶ added in v1.2.0
type FieldCompletion struct {
Values []string // fixed candidates: enum members + shape literals (e.g. ".")
RefGroup string // if non-empty, instances of this resource group are candidates
RefPrefix string // prefix to prepend to each referenced name (e.g. "libraries/")
}
FieldCompletion describes how a field's value can be completed.
func Completion ¶ added in v1.2.0
func Completion(root []*Node, group string, field []string) (fc FieldCompletion, found bool)
Completion returns the completion sources for one field of a resource group and whether the field is known (an attribute at that path, canonical or compat). found is false for an unknown path so a caller can distinguish "no candidates" (a known free-form field: cid/fqdn/pattern/plain string) from "unknown field".
type FieldRef ¶ added in v1.2.0
type FieldRef struct {
Path []string
Compat []string // nil if the field has no legacy alias
// AnyOf is every plain location the field may be authored at, when its
// declared path contains a FINITE matcher (Either). A storage's size lives
// at object/size or streaming/size depending on which block the author
// wrote — two static locations, not a dynamic one. AnyOf[0] == Path; nil
// when the path has no matcher.
AnyOf [][]string
}
FieldRef is where a field may be authored: its canonical path, plus the legacy alias that also satisfies it. Both matter for required-ness — the fixtures author a function's domains under the compat key, and a requirement that only looked at the canonical path would call them missing.
type FiniteMatcher ¶ added in v1.2.0
type FiniteMatcher interface {
StringMatcher
Values() []string
}
FiniteMatcher is a StringMatcher whose alternatives are known and enumerable, so a caller can expand a branching path into its concrete locations rather than resolving it against a document.
type GroupInfo ¶ added in v1.2.0
GroupInfo identifies one top-level group: the directory key it is authored under, the singular name the DSL declares for one instance ("" for a group that declares none, e.g. a leaf map), and whether its instances are containers holding resources of their own.
type LocatedError ¶ added in v1.2.0
LocatedError is an error carrying the source position it was found at, so a consumer attributes it to a file/line/column by reading fields instead of parsing the message. Error() renders exactly the "file:line:col: msg" form these errors have always had, so message-matching callers are unaffected.
func (*LocatedError) Error ¶ added in v1.2.0
func (e *LocatedError) Error() string
func (*LocatedError) Unwrap ¶ added in v1.2.0
func (e *LocatedError) Unwrap() error
type MethodCarrier ¶ added in v1.2.0
type MethodCarrier interface {
Capability
AddressingMethods() []MethodSpec
}
MethodCarrier is a Capability that also declares the object-addressing methods it generates. A generator reads AddressingMethods() to render them, so the capability's codegen meaning lives on the term — the generator needs neither a per-capability switch nor a dependency on where the capability is defined.
type MethodSpec ¶ added in v1.2.0
MethodSpec is one object-addressing method a capability contributes to a generated structureSpec struct: the Go method Name, its Params and Ret (as rendered source fragments), and the Args passed to the delegate. ViaTns picks the delegate form — <alias>.Tns().<Name>(args) when true, <alias>.<Name>(args) when false. "@" in Args expands to the method receiver. Carrying the method shape as data is what lets a generator render a capability's methods without a term-keyed switch. Generation-only; no runtime effect.
type NextValidation ¶
type NextValidation struct {
Key string `json:"key"` // identifier for the validation (e.g., "domain", "fqdn")
Value any `json:"value"` // value to validate
Validator string `json:"validator"` // validator name (e.g., "dns", "cid")
Context map[string]any `json:"context"` // extra context for validation
}
NextValidation represents a validation that needs to be performed externally. The compiler emits these during compilation, and it's up to the caller to implement and process these validations.
func NewNextValidation ¶
func NewNextValidation(key string, value any, validator string, context map[string]any) NextValidation
NewNextValidation creates a new NextValidation instance.
type Node ¶
type Node struct {
Group bool
Match StringMatch
Attributes []*Attribute
Children []*Node
Meta map[string]any // opaque codegen metadata; the engine never interprets it
}
func DefineGroup ¶
func DefineIter ¶
func DefineIterGroup ¶
func (*Node) With ¶ added in v1.2.0
func (n *Node) With(opts ...NodeOption) *Node
With applies node options to an already-built node and returns it, for the ctors that take only children (DefineGroup / DefineIterGroup) and so can't take options inline. Generation-only metadata; no runtime effect.
type NodeOption ¶ added in v1.2.0
type NodeOption func(*Node)
NodeOption mutates a node — the node-level analogue of Option. Passed to DefineIter to attach opaque metadata to the object template (the node each compiled resource-object matches), not to the parse rules.
func Addressing ¶ added in v1.2.0
func Addressing(caps ...Capability) NodeOption
Addressing records the set of TNS-key capabilities a compiled object has, for a generator to emit its path helpers. Generation-only; no runtime effect.
func AttachesToAll ¶ added in v1.2.0
func AttachesToAll() NodeOption
AttachesToAll marks a resource group as cross-cutting: every OTHER compiled resource carries a trailing derived []string field listing the instances of THIS kind attached to it. The generator names that universal field from this group's Resource iface and keys it by this group's config key (e.g. the smartops group -> a `SmartOps []string` field on every resource, key "smartops"). The compiler synthesizes the list from each resource's tags (driver.AttachAll reads this same annotation): a "<key>:<name>" tag adds <name>'s id to that resource's <key> list — it is never an authored key. Requires Resource(...) on the same node.
func Embeds ¶ added in v1.2.0
func Embeds(names ...string) NodeOption
Embeds records the structureSpec interface types a generated struct embeds (e.g. "Basic", "Indexer", "Wasm") — the object-addressing behaviours it exposes. Kept explicit (not derived from Addressing) because a few resources embed more than their capability flags imply (e.g. messaging embeds Wasm). Generation-only; no runtime effect.
func GroupAnnotate ¶ added in v1.2.0
func GroupAnnotate(key string, val any) NodeOption
GroupAnnotate attaches opaque metadata to a node. Like Annotate, the engine stores it and never interprets it — only code generators read it.
func GroupDoc ¶ added in v1.2.0
func GroupDoc(text string) NodeOption
GroupDoc is the node-level Doc: a human-readable description for a resource or container group, surfaced on its schema object. Documentation-only.
func Icon ¶ added in v1.2.0
func Icon(name string) NodeOption
Icon is a SEMANTIC icon hint for a resource group — "bolt", "database", "globe" — surfaced on its schema object so a UI/CLI picks a glyph from the DSL instead of keeping its own kind->icon table (three of them, in the web console's case). Deliberately a neutral key, not an asset path or an icon-set class: which library draws it stays the consumer's business, and a consumer that doesn't know the key just falls back to its default. Presentation-only.
func Resource ¶ added in v1.2.0
func Resource(schemaPkg, iface, specType, specPkg string) NodeOption
Resource declares the irregular Go names a resource generates into, so the generator needs no hardcoded per-resource table:
- schemaPkg: the pkg/schema/<dir> accessor package (usually the group name; "website" for the "websites" group).
- iface: the exported accessor interface, e.g. "Database", "SmartOps".
- specType: the structureSpec type, e.g. "Database", "SmartOp".
- specPkg: the pkg/specs/<dir> addressing-helper package.
Everything else — struct name, receiver, error noun, folder constant, import alias, file name — derives from these. Generation-only; no runtime effect.
func Section ¶ added in v1.2.0
func Section(id, title, doc string) NodeOption
Section declares a display section with an id, a short Title, and a longer description (Doc). Repeatable on a node; declaration order is display order. Fields join it with InSection(id). Schema-only — no compile/parse effect.
func SectionWhen ¶ added in v1.2.0
func SectionWhen(id, title, doc, field string, in ...string) NodeOption
SectionWhen is Section with a static visibility condition: the section is shown only when sibling attribute field holds one of in (e.g. the HTTP section only when a function's type is "http"/"https"). Schema-only.
func Singular ¶ added in v1.2.0
func Singular(goName string) NodeOption
Singular declares the Go type name a container group compiles to (e.g. the applications group -> "Application"). Required on any container group (one whose iterator holds resource sub-groups); the generator fails loudly rather than guess a singular from the plural key. Generation-only; no runtime effect.
type ObjectDataType ¶
type OnlyWhenSpec ¶ added in v1.2.0
OnlyWhenSpec gates a wire-key rename/emit on a sibling attribute's value.
type Option ¶
type Option func(*Attribute)
func Accessor ¶ added in v1.2.0
Accessor overrides the exported NAME of the pkg/schema getter/setter a generator emits for this attribute, when the config-key-derived name doesn't match the existing public API (e.g. fqdn -> FQDN, match -> ChannelMatch). Distinct from Field, which names the struct field. Generation-only.
func Annotate ¶ added in v1.2.0
Annotate attaches opaque metadata to an attribute. The engine stores it and never interprets it — only code generators (and other out-of-band tooling) read it. This is the generic hook that domain-specific vocabulary is built on.
func Compat ¶
func Compat(path ...StringMatch) Option
func DerivedBool ¶ added in v1.2.0
DerivedBool declares an attribute-level derived bool: a bool struct field named goName synthesized from THIS attribute's value (Function.Secure from type=="https"). `when` maps each source value to the bool it yields; `reconstruct` maps the bool back to a source value on decompile. It is attribute-level (unlike the removed node-level DerivedBools) so a generic driver knows the source attribute. The generator still emits `<goName> bool` alongside the source attribute's own field. Inert driver data this phase; the generator reads only GoName. No runtime effect.
func Doc ¶ added in v1.2.0
Doc documents an attribute for schema export: title is the human display name (how a UI/CLI titles the field, when the raw name reads poorly — id -> "ID", ttl -> "Time-To-Live"), desc the longer description. They become JSON Schema `title` and `description`. Either may be "" to omit it. Documentation-only: the engine and compiler ignore both. Distinct from the `description` CONFIG attribute some resources declare — this documents the field; that one IS a field.
func EmitValidation ¶ added in v1.2.0
EmitValidation declares a deferred validation to attach at compile time (domains -> EmitValidation("domain","dns")). Distinct from the load-time Validator(). Inert driver data — no effect this phase.
func EnumBool ¶ added in v1.2.0
EnumBool declares that this enum attribute projects to a bool struct field named goName (network-access -> Local/Public), replacing the attribute's own field. It carries the full compile/decompile contract a generic driver reads: values in trueWhen compile the bool true; values in dropWhen have their wire key deleted after projection (values in neither survive compile as-is, e.g. a database's authored "subnet"); decompileAs is the [false,true] pair the inverse restores. Generation reads only GoName; the rest is inert driver data this phase. No runtime effect (the hand-written passes still hardcode this).
func Field ¶ added in v1.2.0
Field overrides the Go struct field name a generator emits for this attribute, for cases where the config-key-derived name differs from the struct field (e.g. github-id -> RepoID). Generation-only; no runtime effect.
func Generated ¶ added in v1.2.0
Generated declares that this attribute's value is minted by a known generator rather than authored — a UI renders it read-only and fills it via Generate. Schema/tooling only: no compile, parse or validation effect (the field keeps whatever validator it declares).
func InSection ¶ added in v1.2.0
InSection assigns an attribute to a display section by id (see Section), telling a UI/CLI which section to render the field under. Explicit and independent of the field's Path. Schema-only — no compile or parse effect.
func IsHttpMethod ¶
func IsHttpMethod() Option
func IsVariableName ¶
func IsVariableName() Option
func NoAccessors ¶ added in v1.2.0
func NoAccessors() Option
NoAccessors suppresses BOTH generated pkg/schema accessors — neither is mechanical (a value transform, combined encryption, or deep github-* folded into a hand-written helper own this attribute's config surface). Note: the TS source facade is unaffected and still edits these keys. Generation-only.
func NoGetter ¶ added in v1.2.0
func NoGetter() Option
NoGetter suppresses the generated pkg/schema getter for this attribute — the read applies a value transform the DSL can't express (e.g. fqdn lower-cases). The setter is still emitted. Generation-only; no runtime effect.
func NoSetter ¶ added in v1.2.0
func NoSetter() Option
NoSetter suppresses the generated pkg/schema setter for this attribute — the write is folded into a combined hand-written helper (e.g. Channel/Bridges). The getter is still emitted. Generation-only; no runtime effect.
func NoStructField ¶ added in v1.2.0
func NoStructField() Option
NoStructField declares that this attribute projects to no structureSpec struct field (and no TS wire/session field) — folded elsewhere (encryption-type) or unimplemented (http-methods). Generation-only; no runtime effect.
func OnlyWhen ¶ added in v1.2.0
OnlyWhen makes an attribute's wire projection conditional on a sibling attribute's value (p2p-protocol renames to "service" only when type=="p2p"). Inert driver data — no generation or runtime effect this phase.
func Path ¶
func Path(path ...StringMatch) Option
func Ref ¶ added in v1.2.0
Ref declares that this attribute's value is a reference into another resource group. Inert driver data — no generation or runtime effect this phase.
func RepoBranch ¶ added in v1.2.0
func RepoBranch() Option
RepoBranch marks the attribute holding the git branch a repo-backed resource builds from (a sibling of the provider block). Introspection-only.
func RepoName ¶ added in v1.2.0
func RepoName() Option
RepoName marks the attribute holding a repository's full name (owner/repo) INSIDE its provider block — the value that says which repository backs the resource. It is what lets a tool extract the backing repo generically: the provider key is dynamic, so "the sub-object carrying the repo name" is the only stable handle, and this says which leaf that is instead of every consumer hardcoding "fullname". Introspection-only; no compile or runtime effect.
func RequiredUnless ¶ added in v1.2.0
RequiredUnless makes a field required UNLESS a sibling boolean attribute is true — a database's match is a literal key and must be there, unless useRegex turns it into a regular expression, where empty is a valid catch-all.
Deliberately not RequiredWhen with a negation. Two things differ, and the second is the one that bites: an ABSENT discriminator here means required (an unset bool is false), whereas RequiredWhen treats an absent discriminator as "condition cannot hold, so not required". Encoding it as a value list would also break silently, because the value is read as a bool on one side and compared as a string on the other.
func RequiredWhen ¶ added in v1.2.0
RequiredWhen makes a field required only when a sibling attribute holds one of the given values — a function's pubsub channel matters when its trigger type is pubsub and is meaningless otherwise, so requiring it unconditionally would reject every http function. Unlike ShowWhen this is NOT presentation: it is enforced at load exactly like Required(), and reported by partial validation.
Deliberately separate from ShowWhen. A field can be shown and optional (a timeout), so "required" cannot be inferred from "visible".
func ShowWhen ¶ added in v1.2.0
ShowWhen makes a field's display conditional: a UI/CLI shows it only when the sibling attribute Field holds one of in. Schema-only, static — no compile or parse effect.
func StringShape ¶ added in v1.2.0
StringShape constrains a string attribute to the given literals/prefixes, installing the derived load-time Validator AND recording the spec in Meta["shape"] so a generator can emit it. One source of truth: the closure is derived from the data, not hand-written beside it.
type RefSpec ¶ added in v1.2.0
RefSpec declares that an attribute value references another resource group, so a driver can resolve it to that group's compiled key, optionally under a key Prefix.
type RequiredField ¶ added in v1.2.0
type RequiredField struct {
FieldRef
When *FieldRef // the discriminator to read, nil when unconditional
WhenIn []string // ...required only if its value is one of these
// Unless inverts the sense AND the default: the field is required unless
// the discriminator (a bool) is true, and an ABSENT discriminator means
// required — an unset bool is false. RequiredWhen cannot express that:
// there, an absent discriminator means NOT required.
Unless bool
}
RequiredField is a field whose absence the compiler rejects, and the condition under which that applies. When is nil for an unconditional Required(); for a RequiredWhen it names the sibling that decides, and the values that trigger it.
func RequiredFields ¶ added in v1.2.0
func RequiredFields(root []*Node, group string) []RequiredField
RequiredFields returns a resource group's REQUIRED fields — the ones whose absence the compiler rejects at load — each with the condition that governs it. Partial validation has to ask for these separately: every other check runs against a value, and a missing field has none, so a loop over present values can only ever report a resource with nothing in it as valid.
A field at a dynamic (Either/Key) path is skipped, as everywhere else: it has no plain authored path to report against. Such a field can still be required in effect — a Key attribute with no match already fails at load.
type ScalarSpec ¶ added in v1.2.0
type ScalarSpec struct {
ID string
GoType string
Parse func(object.Selector[object.Refrence], string) error // authored -> wire
Format func(object.Selector[object.Refrence], string) error // wire -> authored
}
ScalarSpec is the whole meaning of a scalar-typed DSL term (Duration, Bytes): the codec that maps its authored string to/from the typed wire value, plus the Go struct-field type a generator emits. Carrying both on the term is what lets the driver read Parse/Format and tcc-gen read GoType without either restating a per-scalar switch — the term's meaning lives in exactly one place. Generic: the codecs touch only object.Selector, time and units, so engine keeps no taubyte dependency.
type Schema ¶
func SchemaDefinition ¶
type SectionSpec ¶ added in v1.2.0
type SectionSpec struct {
ID string
Title string
Doc string
When *ConditionSpec
}
SectionSpec declares a human-facing section for a resource's fields — how a UI or CLI groups them for display. It is presentation-only (no compile effect) and does NOT have to align with the authored nesting: a field under one Path can sit in a section with a field from another. Membership is explicit (see InSection), never derived from Path. Title is the short heading; Doc the longer blurb; When (optional) shows the whole section only when its condition holds.
type ShapeSpec ¶ added in v1.2.0
ShapeSpec constrains a string attribute to a closed set of forms: an exact Literal, or a value under one of a set of Prefixes. Unlike a hand-written Validator closure it is introspectable data, so the SAME spec both derives the load-time check and serializes to a schema (JSON Schema oneOf of const/pattern). Used for e.g. a function/smartop `source`: "." (inline) or "libraries/<name>".
type StringMatch ¶
type StringMatch any // string or PathMatcher
type StringMatchAll ¶
type StringMatchAll struct{}
func (StringMatchAll) Match ¶
func (StringMatchAll) Match(string) bool
func (StringMatchAll) String ¶
func (StringMatchAll) String() string
type StringMatcher ¶
func All ¶
func All() StringMatcher
func Either ¶
func Either(values ...string) StringMatcher
type ValidatedField ¶ added in v1.2.0
type ValidatedField struct {
Path []string
Validate AttributeValidator
}
ValidatedField pairs a resource field's authored path with the single-value validator the DSL declared for it.
func ValidatedFields ¶ added in v1.2.0
func ValidatedFields(root []*Node, group string) []ValidatedField
ValidatedFields returns every field of resource group `group` in root that carries a single-value validator. Fields at a dynamic (Either/Key) path are skipped — they have no plain authored path a caller can address.
type ValidationEmit ¶ added in v1.2.0
ValidationEmit declares a DEFERRED validation (engine.NextValidation) a driver should emit for the compiled resource under Key, using the named validator.