embedded

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package embedded interprets the resolved, bounded envelope declared by a plugin. It knows no plugin node vocabulary and never traverses payload JSON: callers return schema-owned payloads to their ordinary field traversal.

Index

Constants

View Source
const (
	MaxDepth = 64
	MaxNodes = 10000
	MaxWork  = 100000
)

Variables

This section is empty.

Functions

func CompareEvolution

func CompareEvolution(before, after schema.Field, compare func(string, []schema.BlockType, []schema.BlockType) error) (schema.Field, error)

CompareEvolution checks embedded descriptor topology separately from ordinary child schema evolution. Moving a payload boundary requires an explicit data transform; adding ordinary fields/variants uses the adapter's existing rules. The returned field has the prior types solely for the caller's outer-shape comparison; neither input is mutated.

func DescendantPath

func DescendantPath(fields []schema.Field, path string) bool

DescendantPath identifies an ordinary field reached through an embedded payload boundary. The plugin root itself remains an ordinary stored field.

func HasFields

func HasFields(field schema.Field) bool

HasFields reports whether the field owns embedded schemas.

func RewriteCollectionReferences

func RewriteCollectionReferences(field schema.Field, value store.Value, before, after string, transform func(Occurrence) (store.Values, error)) (store.Value, bool, error)

RewriteCollectionReferences composes declared envelope references with the caller's ordinary payload traversal. The interpreter establishes boundaries first; the second bounded pass visits envelope JSON only, skipping every schema-owned payload (including JSON that resembles an envelope reference).

func SchemaFields

func SchemaFields(field schema.Field, visit func([]schema.Field))

SchemaFields visits declared payload schemas, without inspecting any values.

func Transform

func Transform(field schema.Field, value store.Value, prefix string, budget *Budget, transform func(Occurrence) (store.Values, error)) (store.Value, error)

Transform processes each declared payload exactly once. Mutable callback inputs and returned maps remain detached from document storage.

func TransformValue

func TransformValue(field schema.Field, value store.Value, prefix string, budget *Budget, transform func(ReadOccurrence) (store.Value, bool, error)) (store.Value, error)

TransformValue processes immutable payloads in admission order. A callback reports whether it changed its payload; unchanged envelope branches are reused. Errors return the original field value, including after earlier callbacks ran.

func ValidateValue

func ValidateValue(field schema.Field, value store.Value, path string, allLocales bool, budget *Budget) error

ValidateValue is the field-root counterpart of ValidateValues.

func ValidateValues

func ValidateValues(fields []schema.Field, values store.Values, prefix string, allLocales bool, budget *Budget) error

ValidateValues preflights declared envelopes before consumers whose ordinary traversal assumes admitted values. It does not validate ordinary field values. allLocales describes canonical storage, rather than a selected-locale view.

func Visit

func Visit(field schema.Field, value store.Value, prefix string, budget *Budget, visitor func(ReadOccurrence) error) error

Visit observes immutable payloads with the same admission, budgets and order as TransformValue, including callbacks visited before a later structural error.

Types

type Budget

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

Budget is shared across nested ordinary fields and plugin envelopes during a pass. A new budget describes a new bounded pass, not a new embedded field.

func NewBudget

func NewBudget() *Budget

func NewWorkBudget

func NewWorkBudget() *Budget

NewWorkBudget bounds repeated admitted traversal in one hook phase. Each pass has its own node ceiling; aggregate work may not exceed MaxWork.

func (*Budget) Enter

func (b *Budget) Enter(path string) error

func (*Budget) Leave

func (b *Budget) Leave()

type Error

type Error struct{ Issue schema.Issue }

Error contains only structural diagnostics, never an opaque plugin payload.

func (*Error) Error

func (e *Error) Error() string

type Occurrence

type Occurrence struct {
	Tree        schema.EmbeddedTree
	Case        schema.EmbeddedTreeCase
	Type        schema.BlockType
	Fields      []schema.Field
	Payload     store.Values
	RuntimePath string
	Identity    string
	Key         string
}

Occurrence is one schema-owned payload. Identity is stable under structural moves within this tree. Callers namespace it by the containing occurrence.

func Occurrences

func Occurrences(field schema.Field, value store.Value, prefix string, budget *Budget) ([]Occurrence, error)

Occurrences is the read-only view of Transform. It validates the same envelope and returns detached payloads; no callback can mutate its source document.

type ReadOccurrence

type ReadOccurrence struct {
	Tree        schema.EmbeddedTree
	Case        schema.EmbeddedTreeCase
	Type        schema.BlockType
	Fields      []schema.Field
	Payload     store.Value
	RuntimePath string
	Identity    string
	Key         string
}

ReadOccurrence exposes an immutable payload to internal readers and transforms. Its metadata and visitation order are identical to Occurrence.

Jump to

Keyboard shortcuts

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