arazzo

package
v0.38.7 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2026 License: MIT Imports: 22 Imported by: 2 modules, 1 package

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidArazzo             = errors.New("invalid arazzo document")
	ErrMissingArazzoField        = errors.New("missing required 'arazzo' field")
	ErrMissingInfo               = errors.New("missing required 'info' field")
	ErrMissingSourceDescriptions = errors.New("missing required 'sourceDescriptions' field")
	ErrEmptySourceDescriptions   = errors.New("sourceDescriptions must have at least one entry")
	ErrMissingWorkflows          = errors.New("missing required 'workflows' field")
	ErrEmptyWorkflows            = errors.New("workflows must have at least one entry")
)

Document errors

View Source
var (
	ErrMissingWorkflowId   = errors.New("missing required 'workflowId'")
	ErrMissingSteps        = errors.New("missing required 'steps'")
	ErrEmptySteps          = errors.New("steps must have at least one entry")
	ErrDuplicateWorkflowId = errors.New("duplicate workflowId")
)

Workflow errors

View Source
var (
	ErrMissingStepId         = errors.New("missing required 'stepId'")
	ErrDuplicateStepId       = errors.New("duplicate stepId within workflow")
	ErrStepMutualExclusion   = errors.New("step must have exactly one of operationId, operationPath, or workflowId")
	ErrExecutorNotConfigured = errors.New("executor is not configured")
)

Step errors

View Source
var (
	ErrMissingParameterName  = errors.New("missing required 'name'")
	ErrMissingParameterIn    = errors.New("missing required 'in' for operation parameter")
	ErrInvalidParameterIn    = errors.New("'in' must be path, query, header, or cookie")
	ErrMissingParameterValue = errors.New("missing required 'value'")
)

Parameter errors

View Source
var (
	ErrMissingActionName     = errors.New("missing required 'name'")
	ErrMissingActionType     = errors.New("missing required 'type'")
	ErrInvalidSuccessType    = errors.New("success action type must be 'end' or 'goto'")
	ErrInvalidFailureType    = errors.New("failure action type must be 'end', 'retry', or 'goto'")
	ErrActionMutualExclusion = errors.New("action cannot have both workflowId and stepId")
	ErrGotoRequiresTarget    = errors.New("goto action requires workflowId or stepId")
	ErrStepIdNotInWorkflow   = errors.New("stepId must reference a step in the current workflow")
)

Action errors

View Source
var (
	ErrInvalidExpression       = errors.New("invalid runtime expression")
	ErrUnknownExpressionPrefix = errors.New("unknown expression prefix")
)

Expression errors

View Source
var (
	ErrUnresolvedWorkflowRef  = errors.New("workflowId references unknown workflow")
	ErrUnresolvedSourceDesc   = errors.New("sourceDescription reference not found")
	ErrUnresolvedOperationRef = errors.New("operation reference not found")
	ErrOperationSourceMapping = errors.New("operation source mapping failed")
	ErrUnresolvedComponent    = errors.New("component reference not found")
	ErrCircularDependency     = errors.New("circular workflow dependency detected")
)

Reference errors

View Source
var (
	ErrMissingCondition = errors.New("missing required 'condition'")
)

Criterion errors

View Source
var (
	ErrSourceDescLoadFailed = errors.New("failed to load source description")
)

Source description errors

Functions

func ClearCriterionCaches deprecated

func ClearCriterionCaches()

ClearCriterionCaches is a no-op retained for backward compatibility. Criterion caches are now scoped per-Engine instance and cleared via Engine.ClearCaches().

Deprecated: Use Engine.ClearCaches() instead.

func EvaluateCriterion

func EvaluateCriterion(criterion *high.Criterion, exprCtx *expression.Context) (bool, error)

EvaluateCriterion evaluates a single criterion against an expression context. This standalone function does not use caching. For cached evaluation, use an Engine.

Types

type ArazzoDocumentFactory

type ArazzoDocumentFactory func(sourceURL string, bytes []byte) (*high.Arazzo, error)

ArazzoDocumentFactory creates a parsed Arazzo document from raw bytes. The sourceURL provides location context for relative reference resolution.

type Engine

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

Engine orchestrates the execution of Arazzo workflows. An Engine is NOT safe for concurrent use from multiple goroutines.

func NewEngine

func NewEngine(doc *high.Arazzo, executor Executor, sources []*ResolvedSource) *Engine

NewEngine creates a new Engine for executing Arazzo workflows.

func NewEngineWithConfig

func NewEngineWithConfig(doc *high.Arazzo, executor Executor, sources []*ResolvedSource, config *EngineConfig) *Engine

NewEngineWithConfig creates a new Engine with custom configuration.

func (*Engine) ClearCaches

func (e *Engine) ClearCaches()

ClearCaches resets all per-engine caches (expressions, regex, JSONPath).

func (*Engine) RunAll

func (e *Engine) RunAll(ctx context.Context, inputs map[string]map[string]any) (*RunResult, error)

RunAll executes all workflows in dependency order.

func (*Engine) RunWorkflow

func (e *Engine) RunWorkflow(ctx context.Context, workflowId string, inputs map[string]any) (*WorkflowResult, error)

RunWorkflow executes a single workflow by its ID.

type EngineConfig

type EngineConfig struct {
	RetainResponseBodies bool // If false, nil out response bodies after extracting outputs

	// SleepFunc, when non-nil, replaces the engine's default wait between
	// retry attempts (a failure action's retryAfter). The engine calls it
	// with the workflow context and the retryAfter duration; returning an
	// error aborts the workflow, exactly as a cancelled context does with
	// the default sleeper.
	//
	// Injecting it lets a host substitute its own timer: a durable workflow
	// runtime (Temporal, DBOS, Restate) passes its replay-safe durable
	// sleep — a real time.Timer inside a replayed workflow body would block
	// the scheduler or break determinism — and tests pass a recording fake
	// to avoid real waits. Nil uses the default context-aware timer.
	SleepFunc func(ctx context.Context, d time.Duration) error
}

EngineConfig configures engine behavior.

type ExecutionRequest

type ExecutionRequest struct {
	Source        *ResolvedSource
	OperationID   string
	OperationPath string
	Method        string
	Parameters    map[string]any
	RequestBody   any
	ContentType   string
}

ExecutionRequest represents a request to execute an API operation.

type ExecutionResponse

type ExecutionResponse struct {
	StatusCode int
	Headers    map[string][]string
	Body       any
	URL        string // Actual request URL (populated by Executor)
	Method     string // HTTP method used (populated by Executor)
}

ExecutionResponse represents the response from an API operation execution.

type Executor

type Executor interface {
	Execute(ctx context.Context, req *ExecutionRequest) (*ExecutionResponse, error)
}

Executor defines the interface for executing API calls.

type OpenAPIDocumentFactory

type OpenAPIDocumentFactory func(sourceURL string, bytes []byte) (*v3high.Document, error)

OpenAPIDocumentFactory creates a parsed OpenAPI document from raw bytes. The sourceURL provides location context for relative reference resolution.

type ResolveConfig

type ResolveConfig struct {
	OpenAPIFactory OpenAPIDocumentFactory // Creates *v3high.Document from bytes
	ArazzoFactory  ArazzoDocumentFactory  // Creates *high.Arazzo from bytes
	BaseURL        string
	HTTPHandler    func(url string) ([]byte, error)
	HTTPClient     *http.Client
	FSRoots        []string

	Timeout        time.Duration // Per-source fetch timeout (default: 30s)
	MaxBodySize    int64         // Max response body in bytes (default: 10MB)
	AllowedSchemes []string      // URL scheme allowlist (default: ["https", "http", "file"])
	AllowedHosts   []string      // Host allowlist (nil = allow all)
	MaxSources     int           // Max source descriptions to resolve (default: 50)
}

ResolveConfig configures how source descriptions are resolved.

type ResolvedSource

type ResolvedSource struct {
	Name            string           // SourceDescription name
	URL             string           // Resolved URL
	Type            string           // "openapi" or "arazzo"
	OpenAPIDocument *v3high.Document // Non-nil when Type == "openapi"
	ArazzoDocument  *high.Arazzo     // Non-nil when Type == "arazzo"
}

ResolvedSource represents a successfully resolved source description.

func ResolveSources

func ResolveSources(doc *high.Arazzo, config *ResolveConfig) ([]*ResolvedSource, error)

ResolveSources resolves all source descriptions in an Arazzo document.

type RunResult

type RunResult struct {
	Workflows []*WorkflowResult
	Success   bool
	Duration  time.Duration
}

RunResult represents the result of executing all workflows.

type StepFailureError

type StepFailureError struct {
	StepId         string
	CriterionIndex int // -1 if not criterion-related
	Message        string
	Cause          error
}

StepFailureError represents a step execution failure with structured context.

func (*StepFailureError) Error

func (e *StepFailureError) Error() string

func (*StepFailureError) Unwrap

func (e *StepFailureError) Unwrap() error

type StepResult

type StepResult struct {
	StepId     string
	Success    bool
	StatusCode int
	Outputs    map[string]any
	Error      error
	Duration   time.Duration
	Retries    int
}

StepResult represents the result of executing a single step.

type ValidationError

type ValidationError struct {
	Path   string // e.g. "workflows[0].steps[2].parameters[1]"
	Line   int
	Column int
	Cause  error
}

ValidationError represents a structured validation error with source location.

func (*ValidationError) Error

func (e *ValidationError) Error() string

func (*ValidationError) Unwrap

func (e *ValidationError) Unwrap() error

type ValidationResult

type ValidationResult struct {
	Errors   []*ValidationError
	Warnings []*Warning
}

ValidationResult holds all validation errors and warnings.

func Validate

func Validate(doc *high.Arazzo) *ValidationResult

Validate performs structural validation of an Arazzo document. Returns nil if the document is valid; callers should nil-check the result before accessing Errors or Warnings.

func (*ValidationResult) Error

func (r *ValidationResult) Error() string

Error implements the error interface, returning all errors as a combined string.

func (*ValidationResult) HasErrors

func (r *ValidationResult) HasErrors() bool

HasErrors returns true if there are any validation errors.

func (*ValidationResult) HasWarnings

func (r *ValidationResult) HasWarnings() bool

HasWarnings returns true if there are any validation warnings.

func (*ValidationResult) Unwrap

func (r *ValidationResult) Unwrap() []error

Unwrap returns the individual validation errors for use with errors.Is/As (Go 1.20+).

type Warning

type Warning struct {
	Path    string
	Line    int
	Column  int
	Message string
}

Warning represents a non-fatal validation issue.

func (*Warning) String

func (w *Warning) String() string

type WorkflowResult

type WorkflowResult struct {
	WorkflowId string
	Success    bool
	Inputs     map[string]any
	Outputs    map[string]any
	Steps      []*StepResult
	Error      error
	Duration   time.Duration
}

WorkflowResult represents the result of executing a single workflow.

Directories

Path Synopsis
Package expression implements the Arazzo runtime expression parser and evaluator.
Package expression implements the Arazzo runtime expression parser and evaluator.

Jump to

Keyboard shortcuts

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