Documentation
¶
Overview ¶
Package arazzo imports Arazzo 1.0/1.1 workflows as Flowi flows and exports flows as Arazzo 1.0.1. Both are pure transforms over model values. Flowi and Arazzo overlap but do not match: every element that does not carry over is reported (FLW-IMPORT-001, FLW-EXPORT-001/002) and, on import, kept visible as a note node — nothing is guessed.
Index ¶
- Constants
- func DecodeFlow(file, path string, data []byte, o FlowOptions) (model.Flow, diag.List)
- func Describe(c model.Collection, schemas SchemaLookup) ([]byte, error)
- func DescribeAsync(c model.Collection, schemas AsyncSchemaLookup) ([]byte, error)
- func EncodeFlow(f model.Flow, o FlowOptions) ([]byte, diag.List, error)
- func Export(flows []model.Flow, o ExportOptions) ([]byte, diag.List)
- type AsyncSchemaLookup
- type CustomStep
- type ExportOptions
- type FlowBody
- type FlowOptions
- type Limit
- type Operation
- type Options
- type Param
- type Resolver
- type Result
- type SchemaLookup
- type SourceDescription
Constants ¶
const AsyncSource = "flowi-async"
AsyncSource is the name of the generated AsyncAPI description in a document's sourceDescriptions.
const BuiltinOperation = "flowiCustomStep"
BuiltinOperation is the operation a custom step calls: a step for a node Arazzo has no word for. The generated description declares it, so the step resolves in any Arazzo tool, which cannot run it; Flowi runs the node it stands for.
const FlowPrefix = "arazzo/"
FlowPrefix is where imported workflows go, under flows/.
const FlowVersion = "1.1.0"
FlowVersion is the Arazzo version flows are stored as (flows/*.arazzo.yaml).
const Version = "1.0.1"
Version is the Arazzo version Export writes. Step fields 1.0.1 lacks (dependsOn, timeout) are written as x-flowi-* extensions, which Import reads back.
Variables ¶
This section is empty.
Functions ¶
func DecodeFlow ¶
DecodeFlow reads a flow from an Arazzo document. A document Flowi wrote carries x-flowi-flow, which is trusted; if the standard part of a step no longer matches what that data derives, the step was edited elsewhere: FLW-ARAZZO-001, and Flowi's data is used. A foreign document (no extension) is read through the importer: its first workflow becomes the flow, and what has no Flowi equivalent is reported by Import.
func Describe ¶
func Describe(c model.Collection, schemas SchemaLookup) ([]byte, error)
Describe writes the OpenAPI description of a collection's requests: one operation per request version, so an Arazzo step can name a hand-made request by operationId. It is derived (rewritten whenever the requests or their schemas change) and never edited. It carries parameter names, never values, and always declares the built-in operation custom steps call.
func DescribeAsync ¶
func DescribeAsync(c model.Collection, schemas AsyncSchemaLookup) ([]byte, error)
DescribeAsync writes the AsyncAPI 3.0 description of a collection's async requests: one operation per async request version, so an Arazzo step can name one by operationId. Like Describe it is derived and never edited, and carries no credentials. It returns nil when the collection has no async request.
func EncodeFlow ¶
EncodeFlow writes f as an Arazzo document with one workflow. The standard parts (steps, success criteria, outputs, inputs) are derived for other Arazzo tools; a node Arazzo cannot express becomes a custom step. The flow's own data is kept whole in the workflow's x-flowi-flow, which is what Flowi reads back, so the round trip loses nothing.
func Export ¶
Export writes flows as one Arazzo document (plan Decision 5). Request nodes become steps; asserts and map-form extracts directly after a request become its successCriteria and outputs; subflows of exported flows become workflowId steps. Other nodes are listed in the workflow's x-flowi-skipped and reported.
Types ¶
type AsyncSchemaLookup ¶
type AsyncSchemaLookup interface {
RequestSchema(r model.Request, version string) (map[string]any, bool)
MessageSchema(r model.Request, version string) (map[string]any, bool)
}
AsyncSchemaLookup gives DescribeAsync the schemas learned for an async request version: the payload it sends and the payload of the messages it receives. Either may be absent; a nil lookup describes payloads loosely.
type CustomStep ¶
type CustomStep struct {
Node string // the node's id
Type string // the node's type
Index int // its place among the flow's top-level nodes ($.nodes[Index])
}
CustomStep is a node of a flow that Arazzo cannot express: its step calls the built-in operation and only Flowi can run it.
func CustomSteps ¶
func CustomSteps(f model.Flow, r Resolver) []CustomStep
CustomSteps lists the top-level nodes of f that become custom steps in its Arazzo form. Nodes folded into another step (an assert after a request) are standard, and so are nodes inside containers: the container is the custom step.
type ExportOptions ¶
type ExportOptions struct {
Resolve Resolver
// Source names the OpenAPI source description the steps call;
// SourceURL is its url (default "./<Source>.openapi.yaml").
Source string
SourceURL string
// AsyncSourceURL is the url of the AsyncAPI source description a flow
// with async steps adds (default "./requests.asyncapi.yaml").
AsyncSourceURL string
Title string // info.title (default: the first flow's name)
}
ExportOptions configure Export.
type FlowBody ¶
type FlowBody interface {
EncodeFlow(model.Flow) ([]byte, error)
DecodeFlow(file, path string, data []byte) (model.Flow, diag.List)
}
FlowBody is the YAML form of a flow's own data (the store's flow codec). It is kept whole inside the document as x-flowi-flow, so nothing a flow holds can be lost by the Arazzo form.
type FlowOptions ¶
type FlowOptions struct {
Body FlowBody
Resolve Resolver
// Sources are the document's source descriptions; the first is the
// collection's generated description and must be named "flowi".
Sources []SourceDescription
NewID func() model.ID // an id for a flow read from a foreign document
}
FlowOptions configure EncodeFlow and DecodeFlow.
type Limit ¶
Limit is something an otherwise standard Arazzo step cannot say: What is "reply" (the request also waits for a reply) or "match" (it filters the messages it counts). Flowi keeps both; other Arazzo tools do not see them.
type Operation ¶
type Operation struct {
ID string
Params map[string]Param
// Async operations (AsyncAPI) set the rest: Source names the source
// description the operation is in ("" → the OpenAPI one), Action is send
// or receive, Timeout is how long a receive waits, and Reply and Match
// say the request also waits for a reply, or filters the messages it
// counts: neither has a place in an Arazzo step.
Source string
Action string
Timeout time.Duration
Reply bool
Match bool
// Custom names a kind of request that has no standard description ("gRPC call", "dataset query"): its step is
// a custom one that keeps the call in x-flowi-flow. Empty for a request that has one.
Custom string
}
Operation is what export needs to know about a request: its OpenAPI operationId and its parameters by with key (openapi.ParamKey of the name). With keys that are not parameters are sent as body fields.
type Param ¶
type Param struct {
Name, In string
}
Param is an OpenAPI parameter: its real name and where it goes ("path", "query", "header" or "cookie").
type Resolver ¶
type Resolver interface {
RequestFor(operationID string) (model.Ref, string, bool)
OperationOf(call model.RequestCall) (Operation, bool)
}
Resolver maps between operations and the collection's requests. RequestFor returns the request an operation was imported as and the version label that operation is ("" when any version will do). OperationOf describes the operation a request call runs, and is false when the call runs a version no operation is known for.
func NewResolver ¶
func NewResolver(c model.Collection) Resolver
NewResolver resolves the operations Describe declares: the operation a request call runs, and the request behind an operationId.
type Result ¶
Result is what an Arazzo document becomes: one flow per workflow, with Path relative to flows/ (arazzo/<workflowId>).
type SchemaLookup ¶
type SchemaLookup interface {
RequestSchema(r model.Request, version string) (map[string]any, bool)
ResponseSchemas(r model.Request, version string) map[int]map[string]any
}
SchemaLookup gives Describe the schemas learned (or imported) for a request version: the body it sends and the body of each response status. Either may be absent; a nil lookup describes bodies loosely.
type SourceDescription ¶
type SourceDescription struct{ Name, URL, Type string }
SourceDescription is one entry of a document's sourceDescriptions.