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
- func CompareEvolution(before, after schema.Field, ...) (schema.Field, error)
- func DescendantPath(fields []schema.Field, path string) bool
- func HasFields(field schema.Field) bool
- func RewriteCollectionReferences(field schema.Field, value store.Value, before, after string, ...) (store.Value, bool, error)
- func SchemaFields(field schema.Field, visit func([]schema.Field))
- func Transform(field schema.Field, value store.Value, prefix string, budget *Budget, ...) (store.Value, error)
- func TransformValue(field schema.Field, value store.Value, prefix string, budget *Budget, ...) (store.Value, error)
- func ValidateValue(field schema.Field, value store.Value, path string, allLocales bool, ...) error
- func ValidateValues(fields []schema.Field, values store.Values, prefix string, allLocales bool, ...) error
- func Visit(field schema.Field, value store.Value, prefix string, budget *Budget, ...) error
- type Budget
- type Error
- type Occurrence
- type ReadOccurrence
Constants ¶
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. compare receives each case's shared definition views, the same values at every placement, so a caller can compare each definition once. The returned field has the prior types solely for the caller's outer-shape comparison; neither input is mutated.
func DescendantPath ¶
DescendantPath identifies a path that crosses an embedded payload boundary among fields and their groups and arrays: the path of a plugin field that declares embedded schemas, followed by more segments. The plugin root itself remains an ordinary stored field. A block definition's fields have their own definition-relative paths, so the walk never enters block definitions.
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 ¶
SchemaFields visits declared payload schemas, without inspecting any values. Registered payload blocks are their shared definitions.
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.
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 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.
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. Type and Fields describe the payload's block definition: a registered block is its shared definition view, whose paths and IDs are definition-relative.
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.