Help us shape the future of Go! Take the 2026 Go Developer Survey

blocktypes

package
v0.26.0 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package blocktypes assigns ordinary Blocks generated symbols from the resolved manifest. It does not replace persisted field identities or intern schemas.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Identifier

func Identifier(value string) string

Identifier derives a portable name from a resolved slug or field path.

func Shape

func Shape(block schema.BlockType) (string, error)

Shape is Shaper.Shape with a single-use memo.

func ValidName

func ValidName(name string) bool

ValidName limits explicit names to portable exported Go/TypeScript identifiers.

Types

type Catalog

type Catalog struct {
	// Fields indexes containers by the field IDs a definition traversal sees:
	// a resource's own fields by their stable IDs, and fields of blocks by
	// their definition-relative IDs. Generators therefore traverse blocks
	// through Definitions or a Variant's Block.
	Fields   map[schema.StableID]Field
	Variants []Variant
}

Catalog is a deterministic, generation-local index into resolved schemas. It is built from definitions: each block is cataloged once, not once per placement.

func Build

func Build(snapshot schema.Snapshot) (*Catalog, error)

Build validates naming and reuse without mutating the manifest. Labels and presentation metadata never participate in a block's resolved shape. Each definition is cataloged once per locale context, so the work is proportional to definitions, not to every path through the block graph. A variant is named by its definition's TypeName, or the slug in PascalCase, never by a placement.

func (*Catalog) DraftReadFields added in v0.14.0

func (catalog *Catalog) DraftReadFields(snapshot schema.Snapshot) map[schema.StableID]bool

DraftReadFields identifies authored fields that may be incomplete in a read, by the field IDs a definition traversal sees (see Catalog.Fields). Reused block families inherit this from every owning resource: a single named output type must describe both its published and unfinished occurrences.

type Field

type Field struct {
	Embedded      bool
	Name          string
	Discriminator string
	Identity      string
	Variants      []string
}

Field describes a named block container at an existing stable field identity.

type Shaper added in v0.15.0

type Shaper struct {
	// contains filtered or unexported fields
}

Shaper computes resolved block shapes, remembering each block's shape so a definition placed many times is encoded once.

func NewShaper added in v0.15.0

func NewShaper() *Shaper

NewShaper returns an empty shape memo. A Shaper is not safe for concurrent use.

func (*Shaper) Shape added in v0.15.0

func (s *Shaper) Shape(block schema.BlockType) (string, error)

Shape compares resolved value contracts, excluding placement and author-facing metadata. It deliberately retains defaults, validation and reference targets. Nested block types contribute their type name, discriminator and a digest of their own shape, so each block is encoded once however often it is nested.

type Variant

type Variant struct {
	Name          string
	Discriminator string
	Identity      string
	// Block is the family's representative: its shared definition view (see
	// schema.BlocksField.Definitions).
	Block schema.BlockType
}

Variant describes one reusable concrete generated type family.

Jump to

Keyboard shortcuts

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