schema

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2026 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Overview

Package schema generates the editor capability catalogue (packages/editor/src/app/schema/capabilities.json) from the block and connector metadata registered in package core. The output types below mirror packages/editor/src/app/schema/types.ts; the generated JSON must satisfy those TypeScript interfaces.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Marshal

func Marshal(caps Capabilities) ([]byte, error)

Marshal renders a catalogue as the canonical capabilities.json bytes: 2-space indented, HTML escaping off (so &, <, > stay literal), with a trailing newline (json.Encoder appends one).

Types

type AddressBranches

type AddressBranches struct {
	Named    []string `json:"named,omitempty"`
	ByMember []string `json:"byMember,omitempty"`
	Note     string   `json:"note"`
}

AddressBranches mirrors types.ts AddressBranchesSpec: the branches a composite block exposes to a block address, as used by the debug features (breakpoints, spies, mocks) — `orders.checkHeader[else].api-call`. A block on the way to the address's target must always name one of these, even when the composite has a single obvious chain.

Named lists the branches addressed by a fixed name (`handle-errors[process]`). ByMember lists the slots whose branches are addressed by the member's own name, or by its index (`fork[notify]`, `switch[0]`) — the names are per-config, so only the slot holding them can be known from the schema.

type Block

type Block struct {
	Type        string  `json:"type"`
	Label       string  `json:"label"`
	Category    string  `json:"category"`
	Group       string  `json:"group,omitempty"`
	Icon        string  `json:"icon"`
	Description string  `json:"description"`
	Fields      []Field `json:"fields"`
	// AddressBranches is set only for composites — a leaf block has no branches to
	// descend into, and omits it.
	AddressBranches *AddressBranches `json:"addressBranches,omitempty"`
}

Block mirrors types.ts BlockSpec.

type Capabilities

type Capabilities struct {
	Blocks     []Block     `json:"blocks"`
	Connectors []Connector `json:"connectors"`
}

Capabilities mirrors types.ts Capabilities: the full catalogue.

func Generate

func Generate(reg *core.SchemaRegistry) (Capabilities, error)

Generate builds the capability catalogue from a schema metadata registry, reflecting each block's/connector's settings struct into its fields. Blocks and connectors are emitted in registration order. A settings struct with a bad tag or an uninferable field type fails generation with a located error.

type Connector

type Connector struct {
	Type     string   `json:"type"`
	Label    string   `json:"label"`
	Icon     string   `json:"icon,omitempty"`
	Category string   `json:"category,omitempty"`
	Settings []Field  `json:"settings"`
	Sources  []Source `json:"sources"`
}

Connector mirrors types.ts ConnectorSpec.

type Field

type Field struct {
	Name        string     `json:"name"`
	Label       string     `json:"label"`
	Type        FieldType  `json:"type"`
	Required    bool       `json:"required"`
	Default     any        `json:"default,omitempty"`
	Enum        []string   `json:"enum,omitempty"`
	ShowIf      *ShowIf    `json:"showIf,omitempty"`
	Description string     `json:"description,omitempty"`
	Ref         *Reference `json:"ref,omitempty"`
	Fields      []Field    `json:"fields,omitempty"`
}

Field mirrors types.ts FieldSpec. Field order here is the JSON key order the hand-written capabilities.json uses (showIf before description, ref and the nested fields after it), so generated entries match without reformatting. JSON objects are unordered, so this is purely for a clean diff.

type FieldType

type FieldType string

FieldType is the union of editor field kinds (see types.ts FieldType).

const (
	TypeString  FieldType = "string"
	TypeNumber  FieldType = "number"
	TypeBoolean FieldType = "boolean"
	TypeFlow    FieldType = "flow"
	TypeObject  FieldType = "object"
)

FieldType values. Only the first four are produced by inference; every other kind must be declared explicitly with an octo `type=` clause. Named as constants so the walker and description overlay reference them without repeating string literals.

type Reference

type Reference struct {
	Kind              string `json:"kind"`
	ConnectorType     string `json:"connectorType,omitempty"`
	ConnectorCategory string `json:"connectorCategory,omitempty"`
}

Reference mirrors types.ts ReferenceSpec: a field that points at another named entity (a connector by type or category, a flow, or a template resource).

type ShowIf

type ShowIf struct {
	Field  string `json:"field"`
	Equals string `json:"equals"`
}

ShowIf mirrors types.ts ShowIf: gate a field on a sibling's value.

type Source

type Source struct {
	Type   string  `json:"type"`
	Label  string  `json:"label"`
	Icon   string  `json:"icon,omitempty"`
	Fields []Field `json:"fields"`
}

Source mirrors types.ts SourceSpec.

Jump to

Keyboard shortcuts

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