mutations

package
v1.11.0 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package mutations provides shared helpers for extracting, normalizing, and cloning mutation field change data across eventing and workflow trigger contexts.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildProposedChanges

func BuildProposedChanges(source ProposedChangeSource, changedFields []string) map[string]any

BuildProposedChanges materializes mutation values including explicit clears

func ChangedAndClearedFields

func ChangedAndClearedFields(source FieldChangeSource) (changed []string, cleared []string)

ChangedAndClearedFields returns normalized changed and cleared field lists from a mutation source

func CloneAnyMap

func CloneAnyMap(values map[string]any) map[string]any

CloneAnyMap deep-copies map values while dropping blank keys

func CloneStringSliceMap

func CloneStringSliceMap(values map[string][]string) map[string][]string

CloneStringSliceMap deep-copies map values while dropping blank keys

func NormalizeStrings

func NormalizeStrings(values []string) []string

NormalizeStrings trims, deduplicates, and drops empty string values

Types

type ChangeSet

type ChangeSet struct {
	// ChangedFields captures updated/cleared fields for the mutation
	ChangedFields []string
	// ChangedEdges captures changed edge names
	ChangedEdges []string
	// AddedIDs captures edge IDs added by edge name
	AddedIDs map[string][]string
	// RemovedIDs captures edge IDs removed by edge name
	RemovedIDs map[string][]string
	// ProposedChanges captures field-level proposed values
	ProposedChanges map[string]any
}

ChangeSet captures mutation deltas shared across eventing and workflow trigger contexts

func NewChangeSet

func NewChangeSet(changedFields, changedEdges []string, addedIDs, removedIDs map[string][]string, proposedChanges map[string]any) ChangeSet

NewChangeSet builds a cloned change set from raw change payload values

func (ChangeSet) Clone

func (set ChangeSet) Clone() ChangeSet

Clone returns a copy of the change set and its map-backed values

type FieldChangeSource

type FieldChangeSource interface {
	Fields() []string
	ClearedFields() []string
}

FieldChangeSource captures the mutation accessors needed to derive changed and cleared field lists

type ProposedChangeSource

type ProposedChangeSource interface {
	ClearedFields() []string
	Field(string) (ent.Value, bool)
}

ProposedChangeSource captures the mutation accessors needed to build proposed changes

Jump to

Keyboard shortcuts

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