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. The returned field has the prior types solely for the caller's outer-shape comparison; neither input is mutated.
func DescendantPath ¶
DescendantPath identifies an ordinary field reached through an embedded payload boundary. The plugin root itself remains an ordinary stored field.
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.
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.
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.