Documentation
¶
Index ¶
- Variables
- func BuiltinTypeFunctions() map[string]function.Function
- func BuiltinTypeVariables(schemas ...string) map[string]cty.Value
- func DiscoverFiles(patterns ...string) ([]string, error)
- func FormatByteSize(bytes int64) string
- func ValidateFormat(format string) error
- type Args
- type ByteSize
- type Connection
- type Contact
- type DataType
- type Duration
- type Expr
- type Field
- type Format
- type GoHandler
- type GoRequest
- type IgnoreRules
- type License
- type Manifest
- type OpenAPI
- type OpenAPIServer
- type OpenAPITag
- type Parser
- type RecordSeq
- type Request
- type Route
- type SQLCatch
- type Schema
- type Scope
- type Server
- type Step
- type StepDecoder
- type StepDocs
- type StepExecutionContext
- type StepExecutor
- type StepGo
- type StepHTTP
- type StepRegistry
- type StepRespond
- type StepSQL
- type StepSpec
- type StepStarlark
- type StepStream
- type StepValidator
- type StepValkey
- type Telemetry
- type TypeSpec
Constants ¶
This section is empty.
Variables ¶
var ErrPipelineHalted = errors.New("pipeline execution halted")
ErrPipelineHalted signals that a terminal step or error catch completed the response.
Functions ¶
func BuiltinTypeFunctions ¶ added in v0.2.1
BuiltinTypeFunctions returns constructors exposed during manifest evaluation.
func BuiltinTypeVariables ¶ added in v0.2.1
BuiltinTypeVariables returns identifiers allowing unquoted syntax like type = string or type = User.
func DiscoverFiles ¶ added in v0.2.0
DiscoverFiles resolves globs, traverses directories, filters out hidden files and ignored paths, and returns a deduplicated, sorted list of .hcl file paths.
func FormatByteSize ¶ added in v0.2.1
FormatByteSize formats a byte count into a compact human-readable representation. Unaligned values within a magnitude tier fall back to exact byte counts.
func ValidateFormat ¶ added in v0.2.1
ValidateFormat reports whether format is an allowed OpenAPI semantic constraint. An empty or whitespace-only string is considered valid (no constraint).
Types ¶
type Args ¶ added in v0.2.1
Args represents evaluated key-value arguments supplied to a native Go step handler.
func (Args) Bind ¶ added in v0.2.1
Bind serializes arguments to JSON and deserializes them into the destination struct pointer.
func (Args) Get ¶ added in v0.2.1
Get retrieves the argument associated with key and coerces it to type T. It returns (zero, false) if the key is missing, nil, or cannot be coerced to T.
func (Args) GetOr ¶ added in v0.2.1
GetOr retrieves the argument at key coerced to type T, returning fallback if absent or incompatible.
type ByteSize ¶ added in v0.2.1
type ByteSize int64
ByteSize represents a quantity of bytes.
func ParseByteSize ¶ added in v0.2.1
ParseByteSize converts a size string (e.g. "10MB", "1.5GiB", "1048576") into ByteSize.
type Connection ¶
type Connection struct {
Type string
Name string
Engine string
Source string
URL string
MaxOpen int
MaxIdle int
}
Connection defines external database connection pools and cache instances.
type Contact ¶ added in v0.2.1
type Contact struct {
Name string `hcl:"name,optional"`
Email string `hcl:"email,optional"`
URL string `hcl:"url,optional"`
}
Contact contains API maintainer details exported in the specification info block.
type DataType ¶ added in v0.2.1
type DataType string
DataType represents an OpenAPI 3.1 primitive or collection type.
type Duration ¶ added in v0.2.1
Duration wraps time.Duration to represent human-configured intervals.
func ParseDuration ¶ added in v0.2.1
ParseDuration parses a human-readable duration string into a Duration. An empty string, whitespace-only string, or "0" yields a zero duration.
type Expr ¶ added in v0.2.1
type Expr interface {
Eval(scope Scope) (any, error)
EvalBool(scope Scope) (bool, error)
EvalMap(scope Scope) (map[string]any, error)
String() string
Raw() hcl.Expression
}
Expr represents a compiled HCL expression ready for evaluation against a Scope.
type Field ¶
type Field struct {
Name string
Type TypeSpec
Required bool
Format Format
Default any
Description string
Min *float64
Max *float64
MinLength *int
MaxLength *int
Enum []string
}
Field specifies validation constraints and documentation metadata for a model attribute.
type Format ¶ added in v0.2.1
type Format string
Format defines semantic string constraints specified by OpenAPI.
type GoHandler ¶ added in v0.2.1
GoHandler defines the function signature for custom Go step callbacks registered on the runtime.
type GoRequest ¶ added in v0.2.1
GoRequest encapsulates the input arguments and active HTTP request passed to a GoHandler.
type IgnoreRules ¶ added in v0.2.0
type IgnoreRules struct {
// contains filtered or unexported fields
}
IgnoreRules holds compiled ignore patterns loaded from a .hclapiignore file.
func LoadIgnoreRules ¶ added in v0.2.0
func LoadIgnoreRules(rootDir string) (*IgnoreRules, error)
LoadIgnoreRules reads an optional .hclapiignore file from rootDir. If the file does not exist, an empty ruleset is returned without error.
type License ¶ added in v0.2.1
License describes legal licensing terms for the exposed API contract.
type Manifest ¶ added in v0.1.3
type Manifest struct {
Server Server
OpenAPI OpenAPI
Telemetry Telemetry
Connections map[string]Connection
Schemas map[string]Schema
Routes []Route
}
Manifest represents the compiled, validated AST for an entire API service.
func Load ¶ added in v0.1.3
Load discovers, reads, merges, and compiles HCL files into a validated Manifest using default steps.
type OpenAPI ¶ added in v0.2.1
type OpenAPI struct {
Title string `hcl:"title,optional"`
Version string `hcl:"version,optional"`
Description string `hcl:"description,optional"`
Servers []OpenAPIServer `hcl:"servers,optional"`
Tags []OpenAPITag `hcl:"tags,optional"`
Contact *Contact `hcl:"contact,block"`
License *License `hcl:"license,block"`
}
OpenAPI holds document metadata exported into OpenAPI 3.1 specifications.
type OpenAPIServer ¶
type OpenAPIServer struct {
URL string `hcl:"url" cty:"url"`
Description string `hcl:"description,optional" cty:"description"`
}
OpenAPIServer defines a deployment origin in the generated specification.
type OpenAPITag ¶
type OpenAPITag struct {
Name string `hcl:"name" cty:"name"`
Description string `hcl:"description,optional" cty:"description"`
}
OpenAPITag groups operations inside interactive documentation portals.
type Parser ¶ added in v0.2.1
type Parser struct {
// contains filtered or unexported fields
}
Parser coordinates file discovery, HCL parsing, and AST compilation using a configurable StepRegistry.
func NewParser ¶ added in v0.2.1
func NewParser(registry *StepRegistry) *Parser
NewParser constructs a Parser configured with the supplied StepRegistry. If registry is nil, DefaultStepRegistry is used.
type RecordSeq ¶ added in v0.2.1
RecordSeq defines the standard Go iterator yielding record items and potential errors.
type Request ¶ added in v0.2.1
type Request struct {
Path map[string]Field
Query map[string]Field
Headers map[string]Field
Body map[string]Field
BodyRef string
}
Request defines validation constraints across incoming HTTP request coordinates.
type Route ¶ added in v0.2.1
type Route struct {
Method string
Path string
Summary string
Tag string
Hidden bool
Request *Request
Steps []Step
}
Route binds an HTTP method and URL pattern to an ordered pipeline of steps.
func (Route) HasTerminalStep ¶ added in v0.2.1
HasTerminalStep reports whether the route contains at least one response-producing step.
type SQLCatch ¶ added in v0.2.1
SQLCatch specifies interception criteria for database driver errors.
type Schema ¶
Schema represents a reusable domain model for payload validation and egress filtering.
type Scope ¶ added in v0.2.1
type Scope struct {
Request map[string]any
Steps map[string]any
Headers map[string]string
Now time.Time
}
Scope encapsulates the runtime execution state supplied to an Expr during evaluation.
type Server ¶
type Server struct {
Host string
Port int
ReadTimeout Duration
WriteTimeout Duration
MaxBodySize ByteSize
}
Server defines listener addresses, transport limits, and network timeouts.
type StepDecoder ¶ added in v0.2.1
type StepDecoder func(name string, body hcl.Body, evalCtx *hcl.EvalContext, funcs map[string]function.Function) (Step, error)
StepDecoder decodes an HCL block into a concrete Step implementation.
type StepDocs ¶ added in v0.2.1
StepDocs renders and streams an interactive API documentation portal.
It delegates template execution to docs.Render using precompiled, embedded HTML viewer templates (Scalar, Swagger UI, Redoc, or Stoplight Elements), or an optional user-defined template file on disk.
Upon execution, it sets the Content-Type header to "text/html; charset=utf-8", flushes the compiled HTML bytes, and halts pipeline progression by returning ErrPipelineHalted.
func (*StepDocs) ExecuteStep ¶ added in v0.2.1
ExecuteStep implements StepExecutor. It compiles the viewer template and streams the resulting HTML page to the response writer.
func (*StepDocs) IsTerminal ¶ added in v0.2.1
IsTerminal implements Step and returns true.
func (*StepDocs) StepName ¶ added in v0.2.1
StepName implements Step and returns the step identifier.
func (*StepDocs) StepWhen ¶ added in v0.2.1
StepWhen implements Step and returns the conditional execution guard.
func (*StepDocs) ValidateStep ¶ added in v0.2.1
ValidateStep implements StepValidator. It verifies that the renderer is one of the supported portal technologies and that any custom template file exists on disk.
type StepExecutionContext ¶ added in v0.2.1
type StepExecutionContext interface {
SQL(name string) (*sql.DB, error)
Valkey(name string) (valkey.Client, error)
GoHandler(name string) (GoHandler, error)
HTTPClient() *http.Client
ResponseWriter() http.ResponseWriter
ResponseController() *http.ResponseController
OpenAPISpec(format string) ([]byte, string, error)
Scope() Scope
Schemas() map[string]Schema
}
StepExecutionContext supplies runtime dependencies and request state to steps during execution.
type StepExecutor ¶ added in v0.2.1
type StepExecutor interface {
ExecuteStep(ctx context.Context, ec StepExecutionContext) (any, error)
}
StepExecutor is implemented by steps that execute runtime request logic.
type StepGo ¶ added in v0.2.1
StepGo invokes a custom Go callback function registered on the runtime engine.
func (*StepGo) ExecuteStep ¶ added in v0.2.1
ExecuteStep implements StepExecutor. It resolves the registered handler, evaluates arguments, executes the callback behind a panic boundary, and captures returned data or error problems.
func (*StepGo) IsTerminal ¶ added in v0.2.1
IsTerminal implements Step and returns false.
func (*StepGo) ValidateStep ¶ added in v0.2.1
ValidateStep implements StepValidator. It verifies that the callback identifier is non-empty.
type StepHTTP ¶ added in v0.2.1
type StepHTTP struct {
Name string
Method string
URL Expr
Body Expr
When Expr
Timeout Duration
Headers map[string]string
Stream bool
}
StepHTTP makes outbound HTTP calls to external APIs.
In standard execution, response bodies up to 10MB are buffered, automatically parsed as JSON if applicable, and published to context as steps.<name>.status and steps.<name>.body. When Stream is true, buffering is skipped and the live socket is exported as an io.ReadCloser under steps.<name>.stream.
func (*StepHTTP) ExecuteStep ¶ added in v0.2.1
ExecuteStep implements StepExecutor. It resolves dynamic URLs and request bodies, injects headers, enforces request deadlines, and executes the call via the engine client.
func (*StepHTTP) IsTerminal ¶ added in v0.2.1
IsTerminal implements Step and returns false.
func (*StepHTTP) ValidateStep ¶ added in v0.2.1
ValidateStep implements StepValidator. It verifies that the URL expression is declared and that the configured HTTP verb matches a standard HTTP method.
type StepRegistry ¶ added in v0.2.1
type StepRegistry struct {
// contains filtered or unexported fields
}
StepRegistry manages step decoders and generates dynamic HCL block schemas without global state.
func DefaultStepRegistry ¶ added in v0.2.1
func DefaultStepRegistry() *StepRegistry
DefaultStepRegistry returns a pre-configured registry containing all standard built-in steps.
func NewStepRegistry ¶ added in v0.2.1
func NewStepRegistry() *StepRegistry
NewStepRegistry returns an empty, isolated step registry.
func (*StepRegistry) BlockHeaderSchemas ¶ added in v0.2.1
func (r *StepRegistry) BlockHeaderSchemas() []hcl.BlockHeaderSchema
BlockHeaderSchemas exports the block schemas for all registered step keywords, allowing the route parser to dynamically accept direct keywords.
func (*StepRegistry) Decode ¶ added in v0.2.1
func (r *StepRegistry) Decode(block *hcl.Block, evalCtx *hcl.EvalContext, funcs map[string]function.Function) (Step, error)
Decode resolves the matching decoder for block.Type and compiles the block into a Step.
func (*StepRegistry) Register ¶ added in v0.2.1
func (r *StepRegistry) Register(keyword string, labelNames []string, decoder StepDecoder)
Register adds a step decoder for a specific HCL block keyword and its expected labels.
type StepRespond ¶ added in v0.2.1
type StepRespond struct {
Status int
Headers map[string]string
When Expr
Body Expr
Schema *TypeSpec
InlineFields map[string]Field
}
StepRespond terminates pipeline execution, serializes the response payload, applies schema-based egress field masking, and streams the HTTP response to the client.
A respond step may declare a contract using an explicit named TypeSpec reference via Schema, an explicit inline schema block via InlineFields, or omit both to allow the compiler to statically infer the response shape directly from the Body expression.
func (*StepRespond) ExecuteStep ¶ added in v0.2.1
func (r *StepRespond) ExecuteStep(ctx context.Context, ec StepExecutionContext) (any, error)
ExecuteStep implements StepExecutor. It serializes the body, applies named or inline schema masking, sets headers, and streams the wire response.
func (*StepRespond) IsTerminal ¶ added in v0.2.1
func (r *StepRespond) IsTerminal() bool
IsTerminal implements Step and returns true.
func (*StepRespond) StepName ¶ added in v0.2.1
func (r *StepRespond) StepName() string
StepName implements Step and returns the step identifier.
func (*StepRespond) StepWhen ¶ added in v0.2.1
func (r *StepRespond) StepWhen() Expr
StepWhen implements Step and returns the conditional execution guard.
func (*StepRespond) ValidateStep ¶ added in v0.2.1
func (r *StepRespond) ValidateStep(m *Manifest) error
ValidateStep implements StepValidator. It verifies that the HTTP status code is valid, ensures that Schema and InlineFields are mutually exclusive, and checks that all referenced models exist.
type StepSQL ¶ added in v0.2.1
type StepSQL struct {
Name string
Connection string
Query string
Args Expr
When Expr
Stream bool
Catches []SQLCatch
// contains filtered or unexported fields
}
StepSQL executes parameterized relational database queries against configured pools.
func (*StepSQL) ExecuteStep ¶ added in v0.2.1
ExecuteStep implements StepExecutor.
func (*StepSQL) IsTerminal ¶ added in v0.2.1
IsTerminal implements Step and returns false.
func (*StepSQL) ValidateStep ¶ added in v0.2.1
ValidateStep implements StepValidator.
type StepSpec ¶ added in v0.2.1
StepSpec serves the compiled OpenAPI specification in JSON or YAML format with ETag caching.
When incoming requests include a matching If-None-Match header, StepSpec returns HTTP 304 Not Modified without re-transmitting the document payload.
func (*StepSpec) ExecuteStep ¶ added in v0.2.1
ExecuteStep implements StepExecutor. It retrieves pre-cached specification bytes and ETag headers, verifies conditional cache headers, and streams the document to the client.
func (*StepSpec) IsTerminal ¶ added in v0.2.1
IsTerminal implements Step and returns true.
func (*StepSpec) ValidateStep ¶ added in v0.2.1
ValidateStep implements StepValidator. It verifies that the format is either "json" or "yaml".
type StepStarlark ¶ added in v0.2.1
type StepStarlark struct {
Name string
Source string
When Expr
// contains filtered or unexported fields
}
StepStarlark executes a sandboxed, deterministic Starlark (Python dialect) script for in-memory payload transformation, field enrichment, and filtering.
Scripts run in a hermetic runtime without access to the host filesystem, network, or environment variables. Execution is bounded by an instruction budget of 100,000 steps to guarantee termination and prevent runaway loops or unbounded recursion.
The script must declare an entrypoint function with the signature:
def execute(ctx):
...
return result
The return value is unmarshaled into native Go types and published to the request scope as steps.<name>.result.
func (*StepStarlark) ExecuteStep ¶ added in v0.2.1
func (s *StepStarlark) ExecuteStep(ctx context.Context, ec StepExecutionContext) (any, error)
ExecuteStep implements StepExecutor. It populates the execution context dictionary, bounds execution with a 100,000 instruction limit, and returns the unpacked result.
func (*StepStarlark) IsTerminal ¶ added in v0.2.1
func (s *StepStarlark) IsTerminal() bool
IsTerminal implements Step and returns false.
func (*StepStarlark) StepName ¶ added in v0.2.1
func (s *StepStarlark) StepName() string
StepName implements Step.
func (*StepStarlark) StepWhen ¶ added in v0.2.1
func (s *StepStarlark) StepWhen() Expr
StepWhen implements Step.
func (*StepStarlark) ValidateStep ¶ added in v0.2.1
func (s *StepStarlark) ValidateStep(m *Manifest) error
ValidateStep implements StepValidator. It compiles the script at boot time, verifies syntax validity, and ensures that an 'execute(ctx)' callable entrypoint is exported.
type StepStream ¶ added in v0.2.1
type StepStream struct {
Format string
Source Expr
Event string
Heartbeat Duration
Retry Duration
FlushEvery int
Headers map[string]string
ContentType string
Schema *TypeSpec
When Expr
}
StepStream consumes a data stream and flushes items according to the declared protocol.
func (*StepStream) ExecuteStep ¶ added in v0.2.1
func (s *StepStream) ExecuteStep(ctx context.Context, ec StepExecutionContext) (any, error)
ExecuteStep implements StepExecutor.
func (*StepStream) IsTerminal ¶ added in v0.2.1
func (s *StepStream) IsTerminal() bool
IsTerminal implements Step.
func (*StepStream) StepName ¶ added in v0.2.1
func (s *StepStream) StepName() string
StepName implements Step.
func (*StepStream) StepWhen ¶ added in v0.2.1
func (s *StepStream) StepWhen() Expr
StepWhen implements Step.
func (*StepStream) ValidateStep ¶ added in v0.2.1
func (s *StepStream) ValidateStep(m *Manifest) error
ValidateStep implements StepValidator.
type StepValidator ¶ added in v0.2.1
StepValidator is an optional interface implemented by AST step definitions that require semantic verification against the compiled manifest topology.
type StepValkey ¶ added in v0.2.1
type StepValkey struct {
Name string
Connection string
Op string
Key Expr
Value Expr
Channel Expr
TTL Duration
When Expr
}
StepValkey executes caching commands or Pub/Sub subscriptions against Valkey or Redis.
Key-value commands ("get", "set", "del") publish execution metadata to context:
- "get": sets steps.<name>.found (bool) and steps.<name>.value (unmarshaled JSON or string). A cache miss doesn't return an error; it sets found = false and value = nil.
- "set": serializes the payload, sets expiration if configured, and sets steps.<name>.success = true.
- "del": removes the key and sets steps.<name>.success = true.
The "subscribe" operation produces a continuous RecordSeq iterator under steps.<name>.stream, allowing live messages to be piped directly into a terminal StepStream (e.g. SSE).
func (*StepValkey) ExecuteStep ¶ added in v0.2.1
func (v *StepValkey) ExecuteStep(ctx context.Context, ec StepExecutionContext) (any, error)
ExecuteStep implements StepExecutor. It performs caching operations or builds a live subscription iterator based on the declared operation.
func (*StepValkey) IsTerminal ¶ added in v0.2.1
func (v *StepValkey) IsTerminal() bool
IsTerminal implements Step and returns false.
func (*StepValkey) StepName ¶ added in v0.2.1
func (v *StepValkey) StepName() string
StepName implements Step.
func (*StepValkey) StepWhen ¶ added in v0.2.1
func (v *StepValkey) StepWhen() Expr
StepWhen implements Step.
func (*StepValkey) ValidateStep ¶ added in v0.2.1
func (v *StepValkey) ValidateStep(m *Manifest) error
ValidateStep implements StepValidator. It verifies connection presence and type, operation keywords, and required parameter expressions for each operation mode.
type Telemetry ¶ added in v0.2.1
type Telemetry struct {
ServiceName string `hcl:"service_name,optional"`
LogLevel string `hcl:"log_level,optional"`
LogFormat string `hcl:"log_format,optional"`
Redact []string `hcl:"redact,optional"`
}
Telemetry configures structured logging output, log level thresholds, and key redaction.
type TypeSpec ¶ added in v0.2.1
TypeSpec encapsulates a scalar primitive, custom schema reference, or nested list.
Because TypeSpec contains a pointer field (ElemType), instances must never be compared using Go == or != operators. Use TypeSpec.Equal instead.
func ListType ¶ added in v0.2.1
ListType constructs a TypeSpec representing an array of the specified element type.
func ObjectType ¶ added in v0.2.1
ObjectType constructs a TypeSpec referencing a declared schema model.
func ParseTypeSpec ¶ added in v0.2.1
ParseTypeSpec parses a type string, accepting primitives, schema identifiers, and collection wrappers using list(T).
func ScalarType ¶ added in v0.2.1
ScalarType constructs a TypeSpec for primitive scalar types.
func TypeSpecFromCty ¶ added in v0.2.1
TypeSpecFromCty converts an evaluated cty.Value into a verified TypeSpec.
func (TypeSpec) ElementSchemaRef ¶ added in v0.2.1
ElementSchemaRef recursively traverses nested lists to locate the underlying schema identifier, returning an empty string if the element is a scalar primitive.
func (TypeSpec) Equal ¶ added in v0.2.1
Equal performs a deep equality comparison against another TypeSpec.
func (TypeSpec) IsArray ¶ added in v0.2.1
IsArray reports whether the specification represents a list or array.
func (TypeSpec) IsObject ¶ added in v0.2.1
IsObject reports whether the specification represents a single object or schema reference.