Documentation
¶
Overview ¶
Package workflows provides minimal registry types for workflow ent templates
Index ¶
- Variables
- func AllowBypassContext(ctx context.Context) context.Context
- func AllowBypassContextWithOrg(ctx context.Context) (context.Context, string, error)
- func AllowContext(ctx context.Context) context.Context
- func AllowContextWithOrg(ctx context.Context) (context.Context, string, error)
- func ApplyObjectFieldUpdates(ctx context.Context, client *generated.Client, ...) error
- func ApprovalDomains(doc models.WorkflowDefinitionDocument) ([][]string, error)
- func BuildAssignmentContext(ctx context.Context, client *generated.Client, instanceID string) (map[string]any, error)
- func BuildCELVars(obj *Object, changedFields []string, changedEdges []string, ...) map[string]any
- func BuildProposedChanges(m utils.GenericMutation, changedFields []string) map[string]any
- func BuildWorkflowActionContext(instance *generated.WorkflowInstance, obj *Object, actionKey string) (map[string]string, map[string]any)
- func CollectChangedFields(m utils.GenericMutation) []string
- func ComputeProposalHash(changes map[string]any) (string, error)
- func CreateWorkflowInstanceWithObjectRef(ctx context.Context, tx *generated.Tx, params WorkflowInstanceBuilderParams) (*generated.WorkflowInstance, *generated.WorkflowObjectRef, error)
- func DefinitionHasApprovalAction(doc models.WorkflowDefinitionDocument) bool
- func DefinitionMatchesTrigger(doc models.WorkflowDefinitionDocument, eventType string, ...) bool
- func DeriveDomainKey(fields []string) string
- func DeriveTriggerPrefilter(doc models.WorkflowDefinitionDocument) ([]string, []string)
- func EligibleWorkflowFields(objectType enums.WorkflowObjectType) map[string]struct{}
- func FieldsFromChanges(changes map[string]any) []string
- func FilterChangesForDomain(changes map[string]any, approvalFields []string) map[string]any
- func FindProposalForObjectRefs(ctx context.Context, client *generated.Client, objRefIDs []string, ...) (*generated.WorkflowProposal, error)
- func IsWorkflowBypass(ctx context.Context) bool
- func LoadWorkflowObject(ctx context.Context, client *generated.Client, schemaType string, ...) (any, error)
- func NewCELEnvWithConfig(cfg *Config) (*cel.Env, error)
- func NewCelEnv(opts ...ConfigOpts) (*cel.Env, error)
- func NormalizeStrings(input []string) []string
- func ObjectOwnerID(ctx context.Context, client *generated.Client, ...) (string, error)
- func ObjectRefIDs(ctx context.Context, client *generated.Client, obj *Object) ([]string, error)
- func OrganizationOwnerIDs(ctx context.Context, client *generated.Client, orgID string) ([]string, error)
- func RegisterAssignmentContextBuilder(builder AssignmentContextBuilder)
- func RegisterCELContextBuilder(builder CELContextBuilder)
- func RegisterObjectRefQueryBuilder(builder ObjectRefQueryBuilder)
- func RegisterObjectRefResolver(resolver func(*generated.WorkflowObjectRef) (*Object, bool))
- func ResolveOwnerID(ctx context.Context, ownerID string) (string, error)
- func StringField(node any, field string) (string, error)
- func StringSliceField(node any, field string) ([]string, error)
- func ValidateCELExpression(expression string) error
- func WithContext(ctx context.Context) context.Context
- func WorkflowMetadata() []generated.WorkflowObjectTypeInfo
- type ApprovalActionParams
- type AssignmentContextBuilder
- type CELConfig
- type CELContextBuilder
- type Config
- type ConfigOpts
- func WithCELComprehensionNestingLimit(limit int) ConfigOpts
- func WithCELCostLimit(limit uint64) ConfigOpts
- func WithCELCrossTypeNumericComparisons(enabled bool) ConfigOpts
- func WithCELEvalOptimize(enabled bool) ConfigOpts
- func WithCELExtendedValidations(enabled bool) ConfigOpts
- func WithCELIdentifierEscapeSyntax(enabled bool) ConfigOpts
- func WithCELInterruptCheckFrequency(freq uint) ConfigOpts
- func WithCELMacroCallTracking(enabled bool) ConfigOpts
- func WithCELOptionalTypes(enabled bool) ConfigOpts
- func WithCELParserExpressionSizeLimit(limit int) ConfigOpts
- func WithCELParserRecursionLimit(limit int) ConfigOpts
- func WithCELTimeout(timeout time.Duration) ConfigOpts
- func WithCELTrackState(enabled bool) ConfigOpts
- func WithConfig(cfg Config) ConfigOpts
- func WithEnabled(enabled bool) ConfigOpts
- type DomainChanges
- type EmitFailureDetails
- type EmitFailureMeta
- type EmitReceipt
- type FieldUpdateActionParams
- type IntegrationActionParams
- type NotificationActionParams
- type Object
- type ObjectRefQueryBuilder
- type TargetConfig
- type TargetedActionParams
- type WebhookActionParams
- type WorkflowBypassContextKey
- type WorkflowCreationError
- type WorkflowCreationStage
- type WorkflowInstanceBuilderParams
Constants ¶
This section is empty.
Variables ¶
var ( // ErrWorkflowNotFound is returned when a workflow instance cannot be found ErrWorkflowNotFound = errors.New("workflow instance not found") // ErrNoProposedChanges is returned when attempting to apply changes but none exist ErrNoProposedChanges = errors.New("no proposed changes to apply") // ErrWorkflowAlreadyActive is returned when trying to start a workflow on an object that already has one ErrWorkflowAlreadyActive = errors.New("workflow already active for this object") // ErrInvalidWorkflowState is returned when a workflow operation is attempted on an instance in an invalid state ErrInvalidWorkflowState = errors.New("invalid workflow state for this operation") // ErrInsufficientApprovals is returned when trying to complete a workflow without required approvals ErrInsufficientApprovals = errors.New("insufficient approvals to complete workflow") ErrUnauthorizedApproval = errors.New("user not authorized to approve this workflow") // ErrFieldNotWorkflowEligible is returned when proposed changes include non-eligible fields ErrFieldNotWorkflowEligible = errors.New("field is not eligible for workflow modification") // ErrUnsupportedObjectType is returned when a workflow is triggered for an unsupported object type ErrUnsupportedObjectType = errors.New("object type does not support workflows") // ErrMissingObjectID is returned when a workflow object is missing an ID ErrMissingObjectID = errors.New("workflow object is missing an ID") // ErrFailedToBuildCELEnv is returned when the CEL environment cannot be built ErrFailedToBuildCELEnv = errors.New("failed to build CEL environment") // ErrEmitFailureDetailsMissing is returned when emit failure details are empty ErrEmitFailureDetailsMissing = errors.New("emit failure details are missing") // ErrEmitNoEmitter is returned when an emitter is required but missing ErrEmitNoEmitter = errors.New("workflow emit requires an emitter") // ErrNilClient is returned when a workflow helper requires a client ErrNilClient = errors.New("workflow client is required") // ErrMissingOrganizationID is returned when an organization id is required ErrMissingOrganizationID = errors.New("organization id is required") // ErrApprovalActionParamsInvalid is returned when approval action params are invalid ErrApprovalActionParamsInvalid = errors.New("approval action params are invalid") // ErrStringFieldMarshal is returned when string field extraction cannot marshal the node ErrStringFieldMarshal = errors.New("failed to marshal node for string field extraction") // ErrStringFieldUnmarshal is returned when string field extraction cannot unmarshal the node ErrStringFieldUnmarshal = errors.New("failed to unmarshal node for string field extraction") // ErrStringFieldNil is returned when string field extraction receives a nil node ErrStringFieldNil = errors.New("string field node is nil") // ErrStringSliceFieldInvalid is returned when a string slice field contains non-string values ErrStringSliceFieldInvalid = errors.New("string slice field contains non-string values") )
Functions ¶
func AllowBypassContext ¶ added in v1.4.0
AllowBypassContext sets workflow bypass and allow decision for internal workflow operations.
func AllowBypassContextWithOrg ¶ added in v1.4.0
AllowBypassContextWithOrg returns an allow/bypass context plus the organization ID.
func AllowContext ¶ added in v1.4.0
AllowContext sets the ent privacy decision to allow for internal workflow operations.
func AllowContextWithOrg ¶ added in v1.4.0
AllowContextWithOrg returns an allow context plus the organization ID.
func ApplyObjectFieldUpdates ¶ added in v1.3.3
func ApplyObjectFieldUpdates(ctx context.Context, client *generated.Client, objectType enums.WorkflowObjectType, objectID string, updates map[string]any) error
ApplyObjectFieldUpdates applies updates to a workflow object via generated helpers.
func ApprovalDomains ¶ added in v1.5.3
func ApprovalDomains(doc models.WorkflowDefinitionDocument) ([][]string, error)
ApprovalDomains returns the distinct field sets used by approval actions in a definition It returns an error when approval action params cannot be parsed
func BuildAssignmentContext ¶ added in v1.3.3
func BuildAssignmentContext(ctx context.Context, client *generated.Client, instanceID string) (map[string]any, error)
BuildAssignmentContext calls the registered assignment context builder to get workflow runtime state. Returns nil if no builder is registered or instanceID is empty.
func BuildCELVars ¶ added in v1.3.3
func BuildCELVars(obj *Object, changedFields []string, changedEdges []string, addedIDs, removedIDs map[string][]string, eventType, userID string) map[string]any
BuildCELVars constructs the activation map for CEL evaluation, allowing generated builders to provide typed contexts instead of ad-hoc maps
func BuildProposedChanges ¶ added in v1.5.3
func BuildProposedChanges(m utils.GenericMutation, changedFields []string) map[string]any
BuildProposedChanges materializes mutation values (including cleared fields) for workflow proposals.
func BuildWorkflowActionContext ¶ added in v1.5.3
func BuildWorkflowActionContext(instance *generated.WorkflowInstance, obj *Object, actionKey string) (map[string]string, map[string]any)
BuildWorkflowActionContext returns the replacement map and base data for notifications/webhooks.
func CollectChangedFields ¶ added in v1.5.3
func CollectChangedFields(m utils.GenericMutation) []string
CollectChangedFields returns the union of modified and cleared fields from a mutation, filtered to only include fields eligible for workflow processing.
func ComputeProposalHash ¶ added in v1.5.3
ComputeProposalHash computes a SHA256 hash of a changes map with sorted keys
func CreateWorkflowInstanceWithObjectRef ¶ added in v1.5.3
func CreateWorkflowInstanceWithObjectRef(ctx context.Context, tx *generated.Tx, params WorkflowInstanceBuilderParams) (*generated.WorkflowInstance, *generated.WorkflowObjectRef, error)
CreateWorkflowInstanceWithObjectRef builds a workflow instance and its object ref in a single helper.
func DefinitionHasApprovalAction ¶ added in v1.5.3
func DefinitionHasApprovalAction(doc models.WorkflowDefinitionDocument) bool
DefinitionHasApprovalAction returns true if the workflow definition contains at least one approval action
func DefinitionMatchesTrigger ¶ added in v1.5.3
func DefinitionMatchesTrigger(doc models.WorkflowDefinitionDocument, eventType string, changedFields []string) bool
DefinitionMatchesTrigger reports whether the workflow definition has a trigger that matches the event type and changed fields.
func DeriveDomainKey ¶ added in v1.5.3
DeriveDomainKey generates a stable domain key from a sorted list of field names a "domain key" is a canonicalized list of approval fields used as a consistent ID for approval scope its used to identify which proposal/approval bucket a set of changes belongs to
func DeriveTriggerPrefilter ¶ added in v1.5.3
func DeriveTriggerPrefilter(doc models.WorkflowDefinitionDocument) ([]string, []string)
DeriveTriggerPrefilter extracts normalized trigger operations and fields/edges for query prefiltering. If any trigger omits fields/edges, field prefiltering is disabled
func EligibleWorkflowFields ¶ added in v1.5.3
func EligibleWorkflowFields(objectType enums.WorkflowObjectType) map[string]struct{}
EligibleWorkflowFields returns the set of fields eligible for workflow processing for a given object type.
func FieldsFromChanges ¶ added in v1.5.3
FieldsFromChanges returns the sorted field names present in a changes map
func FilterChangesForDomain ¶ added in v1.5.3
FilterChangesForDomain filters a mutation's changes to only include fields that belong to the specified approval domain
func FindProposalForObjectRefs ¶ added in v1.5.3
func FindProposalForObjectRefs(ctx context.Context, client *generated.Client, objRefIDs []string, domainKey string, priorityStates []enums.WorkflowProposalState, states []enums.WorkflowProposalState) (*generated.WorkflowProposal, error)
FindProposalForObjectRefs locates a workflow proposal for the given object refs and domain key. The lookup first honors priorityStates (each queried individually) before falling back to states (queried together).
func IsWorkflowBypass ¶ added in v1.4.0
IsWorkflowBypass checks if the context has workflow bypass enabled Used by workflow interceptors to skip approval routing for system operations
func LoadWorkflowObject ¶ added in v1.3.3
func LoadWorkflowObject(ctx context.Context, client *generated.Client, schemaType string, objectID string) (any, error)
LoadWorkflowObject loads an ent object that participates in workflows.
func NewCELEnvWithConfig ¶ added in v1.4.0
NewCELEnv builds the workflow CEL environment using the provided config
func NewCelEnv ¶ added in v1.4.0
func NewCelEnv(opts ...ConfigOpts) (*cel.Env, error)
NewCelEnv builds the workflow CEL environment using the provided options parameters
func NormalizeStrings ¶ added in v1.5.3
NormalizeStrings filters empty strings and returns unique values
func ObjectOwnerID ¶ added in v1.3.3
func ObjectOwnerID(ctx context.Context, client *generated.Client, objectType enums.WorkflowObjectType, objectID string) (string, error)
ObjectOwnerID resolves the owner ID for a workflow object via generated helpers.
func ObjectRefIDs ¶ added in v1.5.3
ObjectRefIDs returns workflow object ref IDs matching the workflow object.
func OrganizationOwnerIDs ¶ added in v1.3.3
func OrganizationOwnerIDs(ctx context.Context, client *generated.Client, orgID string) ([]string, error)
OrganizationOwnerIDs returns user IDs for owners of an organization.
func RegisterAssignmentContextBuilder ¶
func RegisterAssignmentContextBuilder(builder AssignmentContextBuilder)
RegisterAssignmentContextBuilder sets the assignment context builder for CEL evaluation. Only one builder is needed since the generated code provides a comprehensive implementation.
func RegisterCELContextBuilder ¶
func RegisterCELContextBuilder(builder CELContextBuilder)
RegisterCELContextBuilder adds a CEL context builder. Last registered wins.
func RegisterObjectRefQueryBuilder ¶
func RegisterObjectRefQueryBuilder(builder ObjectRefQueryBuilder)
RegisterObjectRefQueryBuilder adds a WorkflowObjectRef query builder to the registry.
func RegisterObjectRefResolver ¶
func RegisterObjectRefResolver(resolver func(*generated.WorkflowObjectRef) (*Object, bool))
RegisterObjectRefResolver adds a resolver to the registry.
func ResolveOwnerID ¶ added in v1.5.3
ResolveOwnerID returns the provided owner ID or derives it from the context when empty.
func StringField ¶ added in v1.3.3
StringField extracts a string field by name from a struct or pointer to struct It returns an error when decoding fails
func StringSliceField ¶ added in v1.5.3
StringSliceField extracts a string slice field by name from a struct or pointer to struct It returns an error when decoding fails
func ValidateCELExpression ¶ added in v1.5.3
ValidateCELExpression ensures the expression compiles against the standard workflow CEL environment.
func WithContext ¶ added in v1.4.0
WithContext sets the workflow bypass context Operations with this context will skip workflow approval interceptors
func WorkflowMetadata ¶ added in v1.3.3
func WorkflowMetadata() []generated.WorkflowObjectTypeInfo
WorkflowMetadata returns generated workflow-eligible schema metadata.
Types ¶
type ApprovalActionParams ¶ added in v1.5.3
type ApprovalActionParams struct {
// TargetedActionParams identifies the approval recipients
TargetedActionParams
// Required defaults to true when omitted
Required *bool `json:"required"`
// Label is an optional display label for the approval action
Label string `json:"label"`
// RequiredCount sets a quorum threshold (number of approvals needed) for this action
RequiredCount int `json:"required_count"`
// Fields lists the approval-gated fields for domain derivation
Fields []string `json:"fields,omitempty"`
}
ApprovalActionParams defines params for APPROVAL actions
type AssignmentContextBuilder ¶
type AssignmentContextBuilder func(ctx context.Context, client *generated.Client, instanceID string) (map[string]any, error)
AssignmentContextBuilder builds workflow runtime context (assignments, instance, initiator) for CEL evaluation. Generated code registers this to provide assignment state when evaluating NOTIFY action When expressions.
type CELConfig ¶ added in v1.4.0
type CELConfig struct {
// Timeout is the maximum duration allowed for evaluating a CEL expression
Timeout time.Duration `json:"timeout" koanf:"timeout" default:"100ms"`
// CostLimit caps the runtime cost of CEL evaluation, 0 disables the limit
CostLimit uint64 `json:"costlimit" koanf:"costlimit" default:"0"`
// InterruptCheckFrequency controls how often CEL checks for interrupts during comprehensions
InterruptCheckFrequency uint `json:"interruptcheckfrequency" koanf:"interruptcheckfrequency" default:"100"`
// ParserRecursionLimit caps the parser recursion depth, 0 uses CEL defaults
ParserRecursionLimit int `json:"parserrecursionlimit" koanf:"parserrecursionlimit" default:"250"`
// ParserExpressionSizeLimit caps expression size (code points), 0 uses CEL defaults
ParserExpressionSizeLimit int `json:"parserexpressionsizelimit" koanf:"parserexpressionsizelimit" default:"100000"`
// ComprehensionNestingLimit caps nested comprehensions, 0 disables the check
ComprehensionNestingLimit int `json:"comprehensionnestinglimit" koanf:"comprehensionnestinglimit" default:"0"`
// ExtendedValidations enables extra AST validations (regex, duration, timestamps, homogeneous aggregates)
ExtendedValidations bool `json:"extendedvalidations" koanf:"extendedvalidations" default:"true"`
// OptionalTypes enables CEL optional types and optional field syntax
OptionalTypes bool `json:"optionaltypes" koanf:"optionaltypes" default:"false"`
// IdentifierEscapeSyntax enables backtick escaped identifiers
IdentifierEscapeSyntax bool `json:"identifierescapesyntax" koanf:"identifierescapesyntax" default:"false"`
// CrossTypeNumericComparisons enables comparisons across numeric types
CrossTypeNumericComparisons bool `json:"crosstypenumericcomparisons" koanf:"crosstypenumericcomparisons" default:"false"`
// MacroCallTracking records macro calls in AST source info for debugging
MacroCallTracking bool `json:"macrocalltracking" koanf:"macrocalltracking" default:"false"`
// EvalOptimize enables evaluation-time optimizations for repeated program runs
EvalOptimize bool `json:"evaloptimize" koanf:"evaloptimize" default:"true"`
// TrackState enables evaluation state tracking for debugging
TrackState bool `json:"trackstate" koanf:"trackstate" default:"false"`
}
CELConfig contains CEL evaluation and validation settings for workflows
type CELContextBuilder ¶
type CELContextBuilder func(obj *Object, changedFields []string, changedEdges []string, addedIDs, removedIDs map[string][]string, eventType, userID string) map[string]any
CELContextBuilder can override how CEL activation variables are built per object type. Codegen can register specialized builders (e.g., to expose typed fields) by calling RegisterCELContextBuilder in an init() function.
type Config ¶ added in v1.4.0
type Config struct {
// Enabled determines if the workflows engine is enabled
Enabled bool `json:"enabled" koanf:"enabled" default:"false"`
// CEL contains configuration for CEL evaluation and validation
CEL CELConfig `json:"cel" koanf:"cel"`
}
Config contains the configuration for the workflows engine
func NewDefaultConfig ¶ added in v1.4.0
func NewDefaultConfig(opts ...ConfigOpts) *Config
NewDefaultConfig creates a new workflows config with default values applied.
type ConfigOpts ¶ added in v1.4.0
type ConfigOpts func(*Config)
ConfigOpts configures the Config
func WithCELComprehensionNestingLimit ¶ added in v1.4.0
func WithCELComprehensionNestingLimit(limit int) ConfigOpts
WithCELComprehensionNestingLimit sets the CEL comprehension nesting limit
func WithCELCostLimit ¶ added in v1.4.0
func WithCELCostLimit(limit uint64) ConfigOpts
WithCELCostLimit sets the CEL cost limit
func WithCELCrossTypeNumericComparisons ¶ added in v1.4.0
func WithCELCrossTypeNumericComparisons(enabled bool) ConfigOpts
WithCELCrossTypeNumericComparisons toggles CEL cross-type numeric comparisons
func WithCELEvalOptimize ¶ added in v1.4.0
func WithCELEvalOptimize(enabled bool) ConfigOpts
WithCELEvalOptimize toggles CEL evaluation optimizations
func WithCELExtendedValidations ¶ added in v1.4.0
func WithCELExtendedValidations(enabled bool) ConfigOpts
WithCELExtendedValidations toggles CEL extended validations
func WithCELIdentifierEscapeSyntax ¶ added in v1.4.0
func WithCELIdentifierEscapeSyntax(enabled bool) ConfigOpts
WithCELIdentifierEscapeSyntax toggles CEL identifier escape syntax
func WithCELInterruptCheckFrequency ¶ added in v1.4.0
func WithCELInterruptCheckFrequency(freq uint) ConfigOpts
WithCELInterruptCheckFrequency sets the CEL interrupt check frequency
func WithCELMacroCallTracking ¶ added in v1.4.0
func WithCELMacroCallTracking(enabled bool) ConfigOpts
WithCELMacroCallTracking toggles CEL macro call tracking
func WithCELOptionalTypes ¶ added in v1.4.0
func WithCELOptionalTypes(enabled bool) ConfigOpts
WithCELOptionalTypes toggles CEL optional types
func WithCELParserExpressionSizeLimit ¶ added in v1.4.0
func WithCELParserExpressionSizeLimit(limit int) ConfigOpts
WithCELParserExpressionSizeLimit sets the CEL parser expression size limit
func WithCELParserRecursionLimit ¶ added in v1.4.0
func WithCELParserRecursionLimit(limit int) ConfigOpts
WithCELParserRecursionLimit sets the CEL parser recursion limit
func WithCELTimeout ¶ added in v1.4.0
func WithCELTimeout(timeout time.Duration) ConfigOpts
WithCELTimeout sets the CEL evaluation timeout
func WithCELTrackState ¶ added in v1.4.0
func WithCELTrackState(enabled bool) ConfigOpts
WithCELTrackState toggles CEL evaluation state tracking
func WithConfig ¶ added in v1.4.0
func WithConfig(cfg Config) ConfigOpts
WithConfig applies all settings from a Config struct
func WithEnabled ¶ added in v1.4.0
func WithEnabled(enabled bool) ConfigOpts
WithEnabled sets the enabled field
type DomainChanges ¶ added in v1.5.3
type DomainChanges struct {
// DomainKey is the derived key for the approval field set
DomainKey string
// Fields lists the approval fields included in the domain
Fields []string
// Changes is the subset of proposed changes for the domain
Changes map[string]any
}
DomainChanges represents changes grouped by approval domain
func DomainChangesForDefinition ¶ added in v1.5.3
func DomainChangesForDefinition(doc models.WorkflowDefinitionDocument, proposedChanges map[string]any) ([]DomainChanges, error)
DomainChangesForDefinition splits proposed changes by approval domains for a workflow definition
func SplitChangesByDomains ¶ added in v1.5.3
func SplitChangesByDomains(changes map[string]any, domains [][]string) []DomainChanges
SplitChangesByDomains filters changes into per-domain buckets based on approval field sets
type EmitFailureDetails ¶ added in v1.5.3
type EmitFailureDetails struct {
// Topic is the soiree topic name
Topic string `json:"topic"`
// EventID is the idempotency key when available
EventID string `json:"event_id,omitempty"`
// Payload is the original event payload JSON
Payload json.RawMessage `json:"payload,omitempty"`
// Attempts is the number of emit attempts recorded
Attempts int `json:"attempts"`
// LastError is the most recent enqueue error
LastError string `json:"last_error,omitempty"`
// OriginalEventType is the workflow event type that failed
OriginalEventType enums.WorkflowEventType `json:"original_event_type"`
// ActionKey is the workflow action key when available
ActionKey string `json:"action_key,omitempty"`
// ActionIndex is the workflow action index when available
ActionIndex int `json:"action_index"`
// ObjectID is the workflow object id
ObjectID string `json:"object_id,omitempty"`
// ObjectType is the workflow object type
ObjectType enums.WorkflowObjectType `json:"object_type,omitempty"`
}
EmitFailureDetails stores failure context for deterministic re-emission
func NewEmitFailureDetails ¶ added in v1.5.3
func NewEmitFailureDetails(topic, eventID string, payload any, meta EmitFailureMeta, err error) (EmitFailureDetails, error)
NewEmitFailureDetails builds a failure payload, including a JSON-encoded event payload
func ParseEmitFailureDetails ¶ added in v1.5.3
func ParseEmitFailureDetails(raw json.RawMessage) (EmitFailureDetails, error)
ParseEmitFailureDetails decodes failure details from raw JSON
type EmitFailureMeta ¶ added in v1.5.3
type EmitFailureMeta struct {
// EventType is the workflow event type associated with the emit
EventType enums.WorkflowEventType
// ActionKey is the workflow action key when available
ActionKey string
// ActionIndex is the workflow action index when available
ActionIndex int
// ObjectID is the target object id
ObjectID string
// ObjectType is the target object type
ObjectType enums.WorkflowObjectType
}
EmitFailureMeta holds structured emit metadata for recovery
type EmitReceipt ¶ added in v1.5.3
type EmitReceipt struct {
// EventID is the event idempotency key when assigned
EventID string
// Enqueued reports whether the event was enqueued
Enqueued bool
// Err is the enqueue error when present
Err error
}
EmitReceipt captures enqueue status for workflow events
func EmitWorkflowEvent ¶ added in v1.5.3
func EmitWorkflowEvent[T any](ctx context.Context, emitter soiree.Emitter, topic soiree.TypedTopic[T], payload T, client any) EmitReceipt
EmitWorkflowEvent wraps and emits a typed workflow event, returning enqueue status
type FieldUpdateActionParams ¶ added in v1.5.3
type FieldUpdateActionParams struct {
// Updates maps field names to new values
Updates map[string]any `json:"updates"`
}
FieldUpdateActionParams defines params for FIELD_UPDATE actions
type IntegrationActionParams ¶ added in v1.5.3
type IntegrationActionParams struct {
// Integration is the integration identifier for the operation
Integration string `json:"integration"`
// Provider overrides the integration identifier when set
Provider string `json:"provider"`
// Operation is the integration operation name
Operation string `json:"operation"`
// Config holds the integration-specific configuration payload
Config map[string]any `json:"config"`
// TimeoutMS overrides the operation timeout in milliseconds
TimeoutMS int `json:"timeout_ms"`
// Retries overrides the retry count when non-zero
Retries int `json:"retries"`
// Force requests a refresh for the provider
Force bool `json:"force_refresh"`
// ClientForce requests a client-side refresh for the provider
ClientForce bool `json:"client_force"`
}
IntegrationActionParams defines params for INTEGRATION actions
type NotificationActionParams ¶ added in v1.5.3
type NotificationActionParams struct {
// TargetedActionParams identifies the notification recipients
TargetedActionParams
// Channels selects notification delivery channels
Channels []enums.Channel `json:"channels"`
// Topic sets an optional notification topic
Topic string `json:"topic"`
// Title is the notification title
Title string `json:"title"`
// Body is the notification body
Body string `json:"body"`
// Data is an optional payload merged into the notification data
Data map[string]any `json:"data"`
}
NotificationActionParams defines params for NOTIFICATION actions
type Object ¶
type Object struct {
// ID is the workflow object identifier.
ID string
// Type is the workflow object type.
Type enums.WorkflowObjectType
// Node is the concrete ent entity when available.
Node any
}
Object captures the workflow target along with its concrete ent entity when available.
func ObjectFromRef ¶ added in v1.3.3
func ObjectFromRef(ref *generated.WorkflowObjectRef) (*Object, error)
ObjectFromRef builds an Object from a WorkflowObjectRef record.
func (*Object) CELValue ¶ added in v1.3.3
CELValue exposes the value used inside CEL expressions. Prefer the concrete ent entity so expressions can access real fields.
func (*Object) ObservabilityFields ¶ added in v1.5.3
ObservabilityFields returns standard log fields for the object TODO MKA: move to code generated / dynamic construction to avoid manual updates when adding new schemas
type ObjectRefQueryBuilder ¶
type ObjectRefQueryBuilder func(*generated.WorkflowObjectRefQuery, *Object) (*generated.WorkflowObjectRefQuery, bool)
ObjectRefQueryBuilder allows generated code to register WorkflowObjectRef predicates per object type.
type TargetConfig ¶ added in v1.3.3
type TargetConfig struct {
// Type selects how targets are resolved.
Type enums.WorkflowTargetType `json:"type"`
// ID identifies the target resource for static targets.
ID string `json:"id,omitempty"`
// ResolverKey names the resolver used for dynamic targets.
ResolverKey string `json:"resolver_key,omitempty"`
}
TargetConfig defines who should receive workflow actions.
type TargetedActionParams ¶ added in v1.5.3
type TargetedActionParams struct {
// Targets identifies users, groups, roles, or resolvers to receive the action
Targets []TargetConfig `json:"targets"`
}
TargetedActionParams captures workflow action params that target recipients
type WebhookActionParams ¶ added in v1.5.3
type WebhookActionParams struct {
// URL is the webhook endpoint
URL string `json:"url"`
// Method is the HTTP method for the webhook request
Method string `json:"method"`
// Headers are additional HTTP headers for the webhook request
Headers map[string]string `json:"headers"`
// Payload is merged into the base webhook payload
Payload map[string]any `json:"payload"`
// TimeoutMS overrides the webhook timeout in milliseconds
TimeoutMS int `json:"timeout_ms"`
// Secret signs the webhook payload if provided
Secret string `json:"secret"`
// Retries overrides the retry count when non-zero
Retries int `json:"retries"`
// Optional override for the idempotency key header
IdempotencyKey string `json:"idempotency_key"`
}
WebhookActionParams defines params for WEBHOOK actions
type WorkflowBypassContextKey ¶ added in v1.4.0
type WorkflowBypassContextKey struct{}
WorkflowBypassContextKey is the context key for workflow bypass operations Used to bypass workflow approval checks during system operations (e.g., applying approved changes)
func FromContext ¶ added in v1.4.0
func FromContext(ctx context.Context) (WorkflowBypassContextKey, bool)
FromContext retrieves the workflow bypass context
type WorkflowCreationError ¶ added in v1.5.3
type WorkflowCreationError struct {
// Stage is the creation stage that failed
Stage WorkflowCreationStage
// Err is the underlying error
Err error
}
WorkflowCreationError wraps the underlying error and indicates what stage failed.
func (*WorkflowCreationError) Error ¶ added in v1.5.3
func (e *WorkflowCreationError) Error() string
Error formats the workflow creation error
func (*WorkflowCreationError) Unwrap ¶ added in v1.5.3
func (e *WorkflowCreationError) Unwrap() error
Unwrap returns the underlying error
type WorkflowCreationStage ¶ added in v1.5.3
type WorkflowCreationStage string
WorkflowCreationStage identifies which step failed when building instances/object refs.
const ( WorkflowCreationStageInstance WorkflowCreationStage = "instance" WorkflowCreationStageObjectRef WorkflowCreationStage = "object_ref" )
type WorkflowInstanceBuilderParams ¶ added in v1.5.3
type WorkflowInstanceBuilderParams struct {
// WorkflowDefinitionID is the definition id for the instance
WorkflowDefinitionID string
// DefinitionSnapshot is the snapshot of the workflow definition
DefinitionSnapshot models.WorkflowDefinitionDocument
// State is the initial workflow instance state
State enums.WorkflowInstanceState
// Context is the workflow instance context payload
Context models.WorkflowInstanceContext
// OwnerID is the organization owner id
OwnerID string
// ObjectType is the workflow object type
ObjectType enums.WorkflowObjectType
// ObjectID is the workflow object id
ObjectID string
}
WorkflowInstanceBuilderParams defines the inputs for creating a workflow instance + object ref.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package engine is the workflow engine for orchestrating workflow execution
|
Package engine is the workflow engine for orchestrating workflow execution |
|
Package observability provides logging and metrics wrappers and consistency for workflows there are several functions in this package that are geared towards reducing boilerplate overhead with the main callers by pre-setting common fields such as operation origin and trigger event so that inline within the workflow package we don't have crazy verbose log and metric statements making the code harder to read
|
Package observability provides logging and metrics wrappers and consistency for workflows there are several functions in this package that are geared towards reducing boilerplate overhead with the main callers by pre-setting common fields such as operation origin and trigger event so that inline within the workflow package we don't have crazy verbose log and metric statements making the code harder to read |
|
Package resolvers provides a registry for workflow target resolution functions
|
Package resolvers provides a registry for workflow target resolution functions |