refs

package
v0.3.0-beta.2 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package refs validates loop template and CEL references against one namespace.

Index

Constants

View Source
const (
	// CodeUnknownReference identifies an unknown namespace root or symbol.
	CodeUnknownReference = "unknown_reference"
	// CodeUnresolvablePath identifies a known symbol with a missing child path.
	CodeUnresolvablePath = "unresolvable_path"
	// CodeItemOutsideFanout identifies item/index usage outside fan-out scope.
	CodeItemOutsideFanout = "item_outside_fanout"
	// CodeConditionNotBool identifies a CEL expression that does not return bool.
	CodeConditionNotBool = "condition_not_bool"
)

Variables

This section is empty.

Functions

func RenderTemplateString

func RenderTemplateString(name string, raw string, data any) (string, error)

RenderTemplateString parses and executes one runtime interpolation template with the same curated functions and missing-key behavior used by CompileTemplate.

Types

type Condition

type Condition struct {
	Raw        string
	Program    cel.Program
	References []Reference
}

Condition is a compiled CEL bool expression plus validated references.

type ConditionCompiler

type ConditionCompiler struct {
	// contains filtered or unexported fields
}

ConditionCompiler compiles CEL expressions over the shared namespace.

func NewConditionCompiler

func NewConditionCompiler(
	namespace Namespace,
	opts ...ConditionCompilerOption,
) (*ConditionCompiler, error)

NewConditionCompiler builds a CEL environment for the shared namespace.

func (*ConditionCompiler) Compile

func (c *ConditionCompiler) Compile(raw string) (*Condition, error)

Compile parses, validates, checks, and caches a CEL bool expression.

type ConditionCompilerOption

type ConditionCompilerOption func(*ConditionCompiler)

ConditionCompilerOption configures a condition compiler.

func WithCostLimit

func WithCostLimit(limit uint64) ConditionCompilerOption

WithCostLimit overrides the CEL runtime cost limit.

type Error

type Error struct {
	Code    string
	Path    []string
	Message string
}

Error reports a namespace validation failure.

func (*Error) Error

func (e *Error) Error() string

type Namespace

type Namespace struct {
	Inputs       map[string]Schema
	Nodes        map[string]NodeSchema
	AllowFanout  bool
	AllowTrigger bool
	AllowEvent   bool
}

Namespace is the single reference namespace consumed by templates and CEL.

func (Namespace) ValidatePath

func (n Namespace) ValidatePath(path []string) *Error

ValidatePath checks a dotted path against the namespace.

type NodeSchema

type NodeSchema struct {
	Output    Schema
	HasOutput bool
}

NodeSchema exposes the referenceable output/status shape for one node.

type Reference

type Reference struct {
	Raw  string
	Path []string
}

Reference records one resolved template or CEL path.

type Schema

type Schema map[string]any

Schema is a permissive JSON-schema-compatible shape used for path validation.

type Template

type Template struct {
	Raw        string
	Parsed     *template.Template
	References []Reference
}

Template is a parsed value interpolation template plus validated references.

func CompileTemplate

func CompileTemplate(name string, raw string, namespace Namespace) (*Template, error)

CompileTemplate parses and validates one Go text/template string.

Jump to

Keyboard shortcuts

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