Documentation
¶
Overview ¶
Package memorywrite holds shared list-mode helpers used by the memory write components (addMemory, updateMemory, upsertMemory).
When list mode is enabled, the component evaluates a list expression at execute time and writes one memory row per element, exposing each element as a configurable iteration variable for the per-item value expressions.
Index ¶
- Constants
- func AppendUniqueRecords(records []core.CanvasMemoryRecord, positions map[uuid.UUID]int, ...) []core.CanvasMemoryRecord
- func FieldNames(pairs []NameValuePair) []string
- func RecordValues(records []core.CanvasMemoryRecord) []any
- func ResolveAllItemValues(items []any, mode ListMode, pairs []NameValuePair, ...) ([]map[string]any, error)
- func ResolvePairs(pairs []NameValuePair, variables map[string]any, ...) (map[string]any, error)
- func ResolveValue(value any, variables map[string]any, expressions core.ExpressionContext) (any, error)
- type ListMode
- type NameValuePair
Constants ¶
const DefaultItemVariable = "item"
Variables ¶
This section is empty.
Functions ¶
func AppendUniqueRecords ¶
func AppendUniqueRecords( records []core.CanvasMemoryRecord, positions map[uuid.UUID]int, next []core.CanvasMemoryRecord, ) []core.CanvasMemoryRecord
AppendUniqueRecords appends records by physical memory ID. If a record is seen again, its latest values replace the previous entry without increasing the reported count.
func FieldNames ¶
func FieldNames(pairs []NameValuePair) []string
FieldNames returns the trimmed, deduplicated field names from a list of pairs in declaration order. Pairs with empty names are skipped.
func RecordValues ¶
func RecordValues(records []core.CanvasMemoryRecord) []any
RecordValues returns the value payloads used by component outputs while keeping record IDs internal to the execution context.
func ResolveAllItemValues ¶
func ResolveAllItemValues( items []any, mode ListMode, pairs []NameValuePair, expressions core.ExpressionContext, ) ([]map[string]any, error)
ResolveAllItemValues evaluates valueList for every list element before any memory writes run, so expression failures do not leave partial writes.
func ResolvePairs ¶
func ResolvePairs(pairs []NameValuePair, variables map[string]any, expressions core.ExpressionContext) (map[string]any, error)
ResolvePairs evaluates each pair's value with the provided variables and returns a map keyed by trimmed name. Pairs with empty names are skipped.
func ResolveValue ¶
func ResolveValue(value any, variables map[string]any, expressions core.ExpressionContext) (any, error)
ResolveValue evaluates a single value field for a per-item iteration.
String values are evaluated as bare expr expressions with the iteration variables merged in. Anything else (already resolved at Build time, for example via a {{ }} template) is returned unchanged so that the same resolved value is written for every list element.
Types ¶
type ListMode ¶
type ListMode struct {
IterateList bool `mapstructure:"iterateList" json:"iterateList,omitempty"`
ListSource string `mapstructure:"listSource" json:"listSource,omitempty"`
ItemVariable string `mapstructure:"itemVariable" json:"itemVariable,omitempty"`
}
ListMode captures the optional list-mode configuration shared by every memory write component.
func (ListMode) EvaluateList ¶
func (m ListMode) EvaluateList(expressions core.ExpressionContext) ([]any, error)
EvaluateList resolves the configured list expression to a slice of items. It accepts []any directly or coerces common slice/array shapes.
type NameValuePair ¶
NameValuePair is the common shape for configured name/value field lists.