Help us shape the future of Go! Take the 2026 Go Developer Survey

model

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package model defines Flowi's domain types as plain data. It performs no I/O and holds no behaviour beyond small structural helpers; storage, validation and execution live in other packages.

Index

Constants

View Source
const (
	ProtocolWS    = "ws"
	ProtocolSSE   = "sse"
	ProtocolMQTT  = "mqtt"
	ProtocolKafka = "kafka"
	ProtocolAMQP  = "amqp" // AMQP 0-9-1 (RabbitMQ and compatible)
	ProtocolNATS  = "nats"

	// ProtocolAMQP10 is AMQP 1.0 (ActiveMQ Artemis, Qpid, IBM MQ, RabbitMQ 4 ...), a different protocol from AMQP 0-9-1.
	ProtocolAMQP10 = "amqp10"

	// Managed messaging and Redis (ADR 0019).
	ProtocolRedis      = "redis"
	ProtocolSQS        = "sqs"
	ProtocolSNS        = "sns"
	ProtocolServiceBus = "servicebus"
	ProtocolPubSub     = "pubsub"
)

The async protocols a request can speak.

View Source
const (
	AuthDefault  = "default"  // the provider's own credential lookup
	AuthExplicit = "explicit" // the credential bindings of the request
)

Values of the `auth` binding of the cloud protocols.

View Source
const (
	AuthAPIKey    = "apikey"
	AuthDigest    = "digest"
	AuthOAuth2    = "oauth2"
	AuthOAuth1    = "oauth1"
	AuthAWSSigV4  = "aws_sigv4"
	AuthJWT       = "jwt"
	AuthHawk      = "hawk"
	AuthMutualTLS = "mtls"
	AuthNTLM      = "ntlm"
	AuthHTTPSig   = "httpsig" // RFC 9421 HTTP Message Signatures
	AuthDPoP      = "dpop"    // RFC 9449 proof of possession
)

The authentication schemes a request version can name in its auth block (beyond a plain Authorization header, which the Auth tab also writes).

View Source
const (
	DriverPostgres = "postgres"
	DriverMySQL    = "mysql"
	DriverMariaDB  = "mariadb"
	DriverSQLite   = "sqlite"
)

The dataset drivers.

View Source
const (
	GRPCSchemePlaintext = "grpc"
	GRPCSchemeTLS       = "grpcs"
)

The URL schemes of a gRPC server.

View Source
const (
	OutcomeSuccess = "success"
	OutcomeFailure = "failure"
)

The two outcomes every step has unless a request says otherwise: it passed (success) or it failed (failure: the request, its hooks or its asserts failed, or it could not be sent).

View Source
const (
	OverlaySet    = "set"    // give a field or entry a value
	OverlayRemove = "remove" // take an entry away
	OverlayAdd    = "add"    // append a line to a list (assert)
	OverlayMerge  = "merge"  // merge-patch a JSON body
)

Operation verbs of a flowi overlay.

View Source
const (
	AsyncSendOnly     = "send"
	AsyncReceiveOnly  = "receive"
	AsyncRequestReply = "request_reply"
)

The actions an Async version can have.

View Source
const DefaultDatasetLimit = 1000

DefaultDatasetLimit is how many rows a dataset request keeps when it sets no limit.

View Source
const ProtocolVerbGRPC = "GRPC"

ProtocolVerbGRPC is what a gRPC request shows where an HTTP request shows its method.

Variables

View Source
var (
	ErrEnvironmentBase = errors.New("base environment not found")
	ErrEnvironmentLoop = errors.New("environments extend each other in a loop")
)

Errors EnvironmentChain wraps, so a caller can tell a missing base from a loop.

Functions

func AsyncBindings

func AsyncBindings(p string) []string

AsyncBindings are the binding names protocol p understands.

func AsyncCredentials

func AsyncCredentials(p string) []string

AsyncCredentials are the binding names of protocol p that hold credentials.

func AsyncProtocols

func AsyncProtocols() []string

AsyncProtocols lists the protocols in catalogue order.

func AsyncSchemes

func AsyncSchemes(p string) []string

AsyncSchemes are the URL schemes a server of protocol p may use.

func AuthParams

func AuthParams(authType string) []string

AuthParams lists the parameter names a scheme understands, in the order a form shows them; nil for an unknown scheme.

func AuthSecretParams

func AuthSecretParams(authType string) []string

AuthSecretParams are the parameters of a scheme that hold credentials, which a description or a snippet must not write out.

func AuthTypes

func AuthTypes() []string

AuthTypes lists the schemes in documentation order.

func CloudProtocol

func CloudProtocol(p string) bool

CloudProtocol reports whether p is a cloud service with an `auth` mode: the provider's default login, or the explicit credential bindings.

func DatasetDrivers

func DatasetDrivers() []string

DatasetDrivers lists the drivers in the order a picker shows them.

func DefaultEnvColour

func DefaultEnvColour(name string) string

DefaultEnvColour is the colour a new environment of that name starts with: red for a name that begins with "prod" (any case), since that is the environment where a slip costs the most.

func EnvColours

func EnvColours() []string

EnvColours are the colours an environment can be marked with.

func GRPCTarget

func GRPCTarget(server string) (hostport string, useTLS bool)

GRPCTarget is the host and port to dial and whether to use TLS. A scheme decides; a bare host:port is plaintext for the local machine (localhost, 127.0.0.1, ::1) and TLS for any other host.

func GRPCTargetURL

func GRPCTargetURL(server, method string) string

GRPCTargetURL is where a gRPC call goes, for display: the server with the scheme the call will use, then the method. A templated server is shown as written, since its scheme is only known when it runs.

func InputTypes

func InputTypes() []string

InputTypes are the types a flow input or output may declare; "" means any.

func JoinURL

func JoinURL(server, channel string) string

JoinURL puts a channel after a server URL: "wss://h" and "events" give "wss://h/events"; an empty channel leaves the server alone.

func KnownMethod

func KnownMethod(name string) (spelling string, known bool)

KnownMethod says whether name is a method Flowi knows by name, ignoring case, and returns its usual spelling. Method names are case-sensitive on the wire: "query" is not QUERY, so a lower-case known name is worth a warning.

func KnownProtocol

func KnownProtocol(p string) bool

KnownProtocol reports whether p is an async protocol.

func MoreMethods

func MoreMethods() []string

MoreMethods are other methods in use that a person may need: the WebDAV and CalDAV family and SEARCH (registered with IANA), LINK and UNLINK, and PURGE, which CDNs and caches use and which is not registered.

func NodeColors

func NodeColors() []string

NodeColors are the colours a person may give a step on the canvas. A step with no colour is drawn in its category's colour.

func NormalizeServer

func NormalizeServer(protocol, server string) string

NormalizeServer writes out the scheme of a server that left it off: a NATS or Kafka server is often written as host:port, a Service Bus one as the namespace host. A templated server, one with a scheme and one of a protocol with several schemes are returned as given.

func ProtocolOfVerb

func ProtocolOfVerb(verb string) string

ProtocolOfVerb is the protocol a verb stands for, or "" when it is not one (an HTTP method).

func ProtocolVerb

func ProtocolVerb(protocol string) string

ProtocolVerb is the short upper-case name a protocol shows where an HTTP request shows its method: MQTT, WS, … BUS for Service Bus and AMQP1 for AMQP 1.0.

func RedactedTarget

func RedactedTarget(target string) string

RedactedTarget hides the password of user:password@ in a URL-like target, for anything recorded or shown. A user name alone is left as it is.

func RemovedNodeTypes

func RemovedNodeTypes() map[NodeType]string

RemovedNodeTypes maps a node type that no longer exists to what replaces it, so a file that still uses one fails with a message that says what to write instead.

func SplitMethod

func SplitMethod(m string) (service, method string, ok bool)

SplitMethod splits package.Service/Method into the service and method names. A leading slash (grpcurl's way of writing it) is allowed.

func StandardMethods

func StandardMethods() []string

StandardMethods are the HTTP methods of the core standards, in the order a picker offers them. QUERY is RFC 10008 (June 2026): a safe, idempotent request that carries a body.

func TargetURL

func TargetURL(protocol, server, channel string) string

TargetURL is where an async request goes, for display and for the protocols that connect to a path: the server and channel joined. For SSE the channel names the event to keep, not a path, so the server alone is the URL.

func ValidMethod

func ValidMethod(name string) bool

ValidMethod says whether name can be sent as an HTTP method: a token (RFC 9110), which is one or more of letters, digits and !#$%&'*+-.^_`|~ and nothing else. It does not say the server knows it.

func ValidOutcomeName

func ValidOutcomeName(name string) bool

ValidOutcomeName says whether name can name an outcome: letters, digits, '-' and '_', not starting with '-'. A ':' is how an after_outcome entry joins a step and an outcome, so it cannot be in the name.

Types

type Arrow

type Arrow struct {
	From      string
	OnSuccess bool
	OnFailure bool
	On        []string
}

Arrow is a line into a step: the step it leaves, and the outcomes of that step that take it. Success and failure have flags; any other outcome of the step's request is named in On.

func (Arrow) Takes

func (a Arrow) Takes(outcome string) bool

Takes says whether the outcome (success, failure or a name from the request's outcomes) takes the arrow.

type Async

type Async struct {
	Protocol string // ws, sse, mqtt, kafka, amqp or nats
	Server   string // templated; e.g. mqtt://host:1883
	Channel  string // topic, subject, queue, or routing key
	Send     *AsyncSend
	Receive  *AsyncReceive
	// Binding is the protocol's own options (qos, key, exchange, …), in
	// file order; the allowed names depend on the protocol.
	Binding []KeyValue
}

Async is what an async request version does: it sends a message to a channel, receives messages from it, or both (request and reply).

func (Async) Action

func (a Async) Action() string

Action is send, receive or request_reply; "" when neither side is set.

type AsyncReceive

type AsyncReceive struct {
	Count   int
	Timeout time.Duration
	// Match, when set, is an expression a message must satisfy to count.
	Match string
}

AsyncReceive says which messages an async request waits for. Count 0 means 1 and Timeout 0 means 30s when it runs.

type AsyncSend

type AsyncSend struct {
	Body    Body
	Headers []KeyValue
}

AsyncSend is the message an async request sends.

type Auth

type Auth struct {
	Type   string
	Params []KeyValue
}

Auth is a version's authentication scheme and its parameters, in file order. Every value is a template, so credentials come from the vault ({{secret.client_secret}}) and never sit in the file.

type Blueprint

type Blueprint struct {
	Meta
	Path string
	// Phase says which hooks of a request the blueprint's nodes can be: "pre"
	// or "post"; empty means post. It does not matter to a blueprint used to
	// make a flow.
	Phase  string
	Params []Param
	// Outcomes are the outcomes a request starts with when it is seeded from the blueprint (see Outcome): the
	// same list for the request's opening version, unless that already writes its own.
	Outcomes []Outcome
	Body     Flow
	File     string
}

Blueprint is a flow template with declared parameters (design §4.8). Body holds the flow's inputs, outputs, execution, run settings and nodes; its identity fields are unused. Using a blueprint makes an ordinary flow and leaves no link back. Path is relative to blueprints/ without the suffix.

type Body

type Body struct {
	JSON      string
	Text      string
	File      string
	Form      []KeyValue
	Multipart []Field
}

Body is a request body. At most one field is set.

type Branch

type Branch struct {
	ID    string
	Nodes []Node
}

Branch is one lane of a parallel node.

type Case

type Case struct {
	When  string
	Nodes []Node
}

Case is one arm of a condition node's switch.

type Collection

type Collection struct {
	Root         string
	Manifest     Manifest
	Folders      []Folder
	Environments []Environment
	Requests     []Request
	Flows        []Flow
	Blueprints   []Blueprint
	Overlays     []Overlay
}

Collection is everything loaded from one collection directory.

func (Collection) FlowTags

func (c Collection) FlowTags(f Flow) []string

FlowTags lists the tags of f: those of the folders it sits under, outermost first, then its own. A tag appears once, and the list is sorted.

func (Collection) FlowsTagged

func (c Collection) FlowsTagged(tag string) []Flow

FlowsTagged lists the flows that carry tag, in file order.

func (Collection) RequestTags

func (c Collection) RequestTags(r Request) []string

RequestTags lists the tags of r, as FlowTags does for a flow.

type Dataset

type Dataset struct {
	// Driver is the store: postgres, mysql, mariadb or sqlite.
	Driver string
	// Server is the connection string, templated: a postgres:// or mysql:// URL, or for sqlite a file path
	// relative to the collection.
	Server string
	// Query is one SELECT (or WITH, VALUES, SHOW, EXPLAIN, DESCRIBE) statement. It is not templated: values go in
	// Params, which are sent to the store separately from the statement, so a value can never change what the
	// statement means.
	Query string
	// Params are the values of the query's placeholders, in order, templated. Placeholders are $1, $2 … for postgres
	// and sqlite, and ? for mysql, mariadb and sqlite.
	Params []string
	// Limit is the most rows kept; 0 means DefaultDatasetLimit. More rows than that are cut and the result says so.
	Limit int
}

Dataset is what a dataset request version does: it runs one read-only query against a data store and keeps the rows it returns.

type Dependency

type Dependency struct {
	ID   ID
	Name string
	Repo string // optional clone URL shown when the dependency is not mounted
}

Dependency is another collection this one references.

type EnvVar

type EnvVar struct {
	Name   string
	Value  string // the text form; for VarJSON, JSON text
	Secret bool
	// Kind says what Value is read as. "" is text. A number, a boolean or an object keeps its type when
	// the variable is used on its own, so {"n": {{env.count}}} sends a number and not "5".
	Kind VarKind
}

EnvVar is one environment variable. When Secret is set, Value is empty: the value lives in the workspace vault.

func (EnvVar) Typed

func (v EnvVar) Typed() (any, error)

Typed returns the value as its kind says: text, an int64 or float64, a bool, or the decoded JSON. A value that does not fit its kind is an error naming the variable.

type Environment

type Environment struct {
	Meta
	Vars []EnvVar
	File string
	// Colour marks the environment wherever it is chosen, so that one is not mistaken for another.
	// It is one of EnvColours(), or empty for the default; an unknown name is shown as the default.
	Colour string
	// Extends names the environment this one builds on: its plain variables apply unless this one sets the same name.
	// Secrets are not inherited, because a secret's value lives in the vault under the environment that declares it.
	Extends string
	// Scope is the vault scope of this environment's secrets. Empty means
	// the owning collection; global environments carry the workspace scope.
	Scope ID
}

Environment is a named set of variables. Name defaults to the file stem.

func EnvironmentChain

func EnvironmentChain(envs []Environment, name string) ([]Environment, error)

EnvironmentChain lists the environment called name and the ones it extends, base first. A base that is not in envs, or a loop, is an error that names the environment at fault.

type Exchange

type Exchange uint8

Exchange is which directions a request has: what it sends and what it receives.

const (
	// SendOnly sends and does not wait for an answer (a published message).
	SendOnly Exchange = iota + 1
	// ReceiveOnly waits for what arrives and sends nothing (a subscription).
	ReceiveOnly
	// SendReceive sends and receives the answer (an HTTP request, a gRPC call, a query, request and reply).
	SendReceive
)

The exchanges.

func (Exchange) Receives

func (e Exchange) Receives() bool

Receives reports whether the request receives something.

func (Exchange) Sends

func (e Exchange) Sends() bool

Sends reports whether the request sends something.

func (Exchange) String

func (e Exchange) String() string

String is the exchange as written in documents.

type Execution

type Execution struct {
	MaxConcurrency int
	RateLimit      string
	HostRateLimits []KeyValue
	OnBranchError  string
}

Execution controls where concurrency is allowed to go. RateLimit applies to every host; HostRateLimits to the hosts they name.

type Extraction

type Extraction struct {
	Name   string
	From   string
	Path   string
	Header string
	Cookie string
	Regex  string
}

Extraction names a value taken from a response. From is one of body, header, cookie or status; the matching selector field is set.

type Family

type Family string

Family is the kind of conversation a request has with what it talks to. Every request version belongs to exactly one family; what differs inside a family (an HTTP method, a message protocol, a SQL driver) is that family's own detail. New kinds of request are new families, not new branches in the code that handles the existing ones.

const (
	// FamilyHTTP is a request and its response over HTTP.
	FamilyHTTP Family = "http"
	// FamilyRPC is a call of a method of a remote service (gRPC).
	FamilyRPC Family = "rpc"
	// FamilyMessaging is a message sent to or received from a channel (WebSocket, SSE, MQTT, Kafka, AMQP, NATS, …).
	FamilyMessaging Family = "messaging"
	// FamilyDataset is a query of a data store, answered with rows (SQL).
	FamilyDataset Family = "dataset"
)

The families.

type Field

type Field struct {
	Key   string
	Value any
}

Field is an ordered key with an arbitrary YAML value: string, bool, int64, float64, []any, []Field or nil.

type Flow

type Flow struct {
	Meta
	// Tags label the flow for `flowi run --tag`; the tags of its folders apply as well.
	Tags          []string
	Path          string
	PreferVersion string
	Inputs        []Input
	Outputs       []Output // rendered when the flow ends, in this order
	Execution     Execution
	Run           *RunTill
	Nodes         []Node
	File          string
}

Flow is a graph of nodes. Path is relative to flows/ without the .flow.yaml suffix.

type Folder

type Folder struct {
	Dir      string
	Settings Settings
	Hooks    Hooks
	// Order lists the names of the folder's entries (a request or flow without its
	// file suffix, or a sub-folder's name) in the order they are shown. Entries it
	// does not name follow, by name; a name that matches nothing is ignored.
	Order []string
	// Tags apply to every flow and request under the folder.
	Tags []string
	File string
}

Folder holds the settings and hooks of one _folder.yaml. Dir is relative to the collection root and slash-separated, e.g. "requests/auth".

type GRPC

type GRPC struct {
	// Server is grpc://host:port (plaintext), grpcs://host:port (TLS) or a bare
	// host:port; templated, e.g. {{env.api}}.
	Server string
	// Method is package.Service/Method.
	Method string
	// Body is the request message, as JSON (or text holding JSON).
	Body Body
	// Proto lists .proto files, relative to the collection. Empty: the schema
	// is asked of the server by reflection.
	Proto []string
	// Import lists the roots .proto imports are resolved against, relative to
	// the collection.
	Import []string
	// Receive says which messages of a server stream to keep; unused for a
	// unary call. Count 0 means 1 and Timeout 0 means 30s when it runs.
	Receive *AsyncReceive
	// Web makes the call over gRPC-Web: an HTTP POST to Server, which is then
	// an http:// or https:// address, for a proxy or gateway that speaks it.
	// It needs Proto files (such a proxy has no reflection) and a method that
	// does not stream from the client.
	Web bool
}

GRPC is what a gRPC request version does: it calls one method of a service with a JSON message and reads the response (one message, or a stream).

type HookControl

type HookControl struct {
	Mode string
	Skip []string
}

HookControl decides which API hooks a request node runs. Mode is "all" (default) or "none"; Skip lists "pre", "post" and/or "message".

type HookStep

type HookStep struct {
	Flow   *Ref
	Inline []Node
}

HookStep is one pre or post hook: a reusable flow or inline nodes. Exactly one of Flow and Inline is set.

type Hooks

type Hooks struct {
	Pre     []HookStep
	Post    []HookStep
	Message []HookStep
}

Hooks are the steps attached to an API at some scope: Pre runs before the request is sent and Post after its response. Message runs for each message a message request keeps, as it arrives, in the order Pre does; requests that receive no messages never run it.

type ID

type ID string

ID is a ULID in canonical upper-case form.

type Input

type Input struct {
	Name    string
	Type    string
	Default string
}

Input is a declared flow input with an optional type and default template. A flow keeps its inputs in the order they were written: the Start card shows them in that order.

type KeyValue

type KeyValue struct {
	Key   string
	Value string
	// Description says what the entry is for; only requests keep it (query,
	// headers, variables).
	Description string
}

KeyValue is an ordered string pair (headers, query parameters, inputs).

type Layout

type Layout struct {
	Flow      ID
	Nodes     map[string]Point // manual positions by node id
	Collapsed []string         // collapsed action strips, by first node id
	File      string
}

Layout is a flow's *.layout.yaml: canvas positions only, kept apart from the flow so moving nodes never changes the flow file (design §4.7).

type Manifest

type Manifest struct {
	Format int
	Meta
	DependsOn []Dependency
	// Variables are the collection's own values, read as {{collection_var.name}}
	// by its requests and flows. The selected environment overrides one of
	// the same name, so the value that differs per API (a base URL) can still
	// differ per environment.
	Variables []KeyValue
	Settings  Settings
	Hooks     Hooks
	File      string
}

Manifest is the content of a collection's flowi.yaml.

type Meta

type Meta struct {
	ID          ID
	Name        string
	Description string
}

Meta is the identity shared by every entity.

type Mount

type Mount struct {
	ID   ID
	Path string // as the user gave it; may start with "~"
}

Mount is a collection loaded into a workspace from a directory.

type Node

type Node struct {
	ID          string
	Type        NodeType
	Name        string
	Description string
	Needs       []string
	// AfterFailureOf lists the steps of the same list whose failure starts this one. Needs and
	// AfterFailureOf are the arrows into a step: a name in Needs is an arrow taken when that step
	// succeeds, one in AfterFailureOf when it fails, one in both whichever way it ends. With neither,
	// the step follows the step before it, on success.
	AfterFailureOf []string
	// AfterOutcome lists "step:outcome" entries: the step starts this one when its request ends with that
	// outcome (one of the outcomes the request names, or success or failure).
	AfterOutcome []string
	// Unlinked says the step has no arrow into it: it does not follow the step before it. The arrow from that step
	// was taken away on purpose. It is ignored when the step has arrows of its own.
	Unlinked   bool
	When       string
	Concurrent bool
	OnError    string
	Timeout    time.Duration
	// Attach names a request or subflow node of the same list that this node is shown
	// with: the canvas draws them as one block. It is a view only; the run order is
	// the list order, as always.
	Attach string
	// AttachAt says where, around that request, the canvas draws the node: "above" or
	// "below" it in a stack, or "" beside it (before it in the list is drawn left of it,
	// after it right of it). Like Attach it is a view only.
	AttachAt string
	// Color is a colour from NodeColors the canvas draws the step in; "" for
	// the category's own. It is cosmetic: a run never reads it.
	Color string

	Request  *RequestCall
	Subflow  *SubflowCall
	Body     []Node
	Branches []Branch
	Then     []Node
	Else     []Node
	Cases    []Case
	// Values are what a set node writes, in order; a later one may read an
	// earlier one. A set node with a target (and no values) writes one
	// variable or request field instead.
	Values []SetValue
	Params []Field
}

Node is one step of a flow. Only the fields relevant to its Type are set. Type-specific options without a typed field are kept, in file order, in Params until the engine milestone types them.

func (Node) Arrows

func (n Node) Arrows(previous string) []Arrow

Arrows are the lines into n. previous is the id of the step before n in its list ("" for the first): a step with no needs, after_failure_of or after_outcome follows it, on success. A step with any arrow of its own has only those; it no longer follows the step before it.

func (Node) Children

func (n Node) Children() [][]Node

Children returns the node's non-empty nested node lists in a fixed order: body, branches, then, else, cases.

type NodeType

type NodeType string

NodeType names a kind of flow node.

func NodeTypes

func NodeTypes() []NodeType

NodeTypes returns every node type in catalogue order.

type Outcome

type Outcome struct {
	Name     string
	When     string
	Disabled bool // kept in the list, but never matched
	// Color is one of NodeColors, for the port and arrows of the outcome; "" is the outcome's own (green for
	// success, red for failure, blue for a named one). Description says what it is for, shown beside it.
	Color       string
	Description string
}

Outcome is a named way a request can end, which an arrow can follow. A step has every outcome whose rule holds once the request and its hooks have run, so a response can be `success` and `ok` at once. success and failure are built in: their rule is "the request passed" and "it failed", and they have no When. Any other name has a When, an expression over the response (`status in [200, 201]`).

func DefaultOutcomes

func DefaultOutcomes() []Outcome

DefaultOutcomes is the list of a request that writes none: success and failure.

func (Outcome) Builtin

func (o Outcome) Builtin() bool

Builtin says whether the outcome is success or failure, whose rule the engine knows.

type Output

type Output struct {
	Name  string
	Type  string
	Value string
}

Output is a value a flow hands back when it ends: a subflow's caller reads it as nodes.<id>.<name>, and the End card shows it. Value is a template rendered in the flow's final scope.

type Overlay

type Overlay struct {
	Name        string
	Description string
	Shared      []OverlayOp
	Requests    []RequestOverlay
	File        string
}

Overlay is a flowi overlay: a named set of changes laid over a request version at send time (the same request as a VIP customer, a delayed request, one with a bad token). Shared applies to every request that uses the overlay; each RequestOverlay applies to its request after that.

type OverlayOp

type OverlayOp struct {
	Verb  string
	Path  string
	Value any
	Was   any
}

OverlayOp is one change a flowi overlay makes to a request version. Path says where (url, headers.X-Tier, body.json, assert, ...); Was is what the base held when the overlay was saved, used to report drift later.

type Param

type Param struct {
	Name        string
	Type        ParamType
	Description string
	Default     string
}

Param is one declared blueprint parameter. A parameter without a Default must be given a value when the blueprint is used.

type ParamType

type ParamType string

ParamType is the kind of value a blueprint parameter takes.

const (
	ParamString     ParamType = "string"
	ParamInt        ParamType = "int"
	ParamBool       ParamType = "bool"
	ParamRequestRef ParamType = "request-ref"
	ParamFlowRef    ParamType = "flow-ref"
)

Parameter types. A request-ref or flow-ref parameter fills the places in the blueprint's nodes that name a request or a subflow ({param: name}); the other types become inputs of the flow made from the blueprint.

func ParamTypes

func ParamTypes() []ParamType

ParamTypes lists the parameter types in documentation order.

type Point

type Point struct{ X, Y int64 }

Point is a canvas position in canvas units.

type Ref

type Ref struct {
	Collection string
	ID         ID
	Path       string
	// Param, set only inside a blueprint, names the blueprint parameter
	// that fills this reference when the blueprint is used; ID and Path are
	// then empty.
	Param string
}

Ref points at a request or flow. Collection is empty for the referencing collection itself, otherwise the name or id of a declared dependency. ID is authoritative; Path is a readable hint that tools repair.

type Request

type Request struct {
	Meta
	// Tags label the request; the tags of its folders apply as well.
	Tags      []string
	Path      string
	Operation string // the OpenAPI operationId of its first version; Arazzo steps refer to it
	Default   string
	Versions  []RequestVersion
	Hooks     Hooks
	File      string

	// Edit is the one dirty edit: an autosaved working copy of a version.
	// Runs, serve and the CLI ignore it; only the GUI sends it. EditBase is
	// the label of the version it started from.
	Edit     *RequestVersion
	EditBase string
	// EditOverlay names the flowi overlay the edit was made with laid over
	// its base version: the edit then shows the overlay's changes too, and the
	// window restores the overlay choice with it. "" when there was none.
	EditOverlay string
}

Request is a saved API request with one or more versions. Path is relative to requests/ without the .req.yaml suffix, e.g. "auth/login".

type RequestCall

type RequestCall struct {
	Request Ref
	Version string
	// Overlay names a flowi overlay of the request's collection laid over the
	// version, "" for none.
	Overlay string
	// Open names a connection this step opens and leaves open for later steps
	// (an async request that can be kept open: WebSocket, MQTT 5, NATS); ""
	// for none. The step's own send and receive run on it.
	Open string
	// Over names a connection an earlier step opened: this step sends and
	// receives over it instead of connecting.
	Over string
	// Close ends the connection Over names once this step has run. A
	// connection still open when the run ends is closed then.
	Close   bool
	Hooks   HookControl
	With    []KeyValue
	Headers []KeyValue
	// Outcomes, when set, are this step's outcomes in place of the request version's own: the same request
	// can end in different ways in different flows. See Outcome.
	Outcomes []Outcome
}

RequestCall is the configuration of a request node.

type RequestOverlay

type RequestOverlay struct {
	Request ID
	// Path is a readable hint at the request; Request is authoritative.
	Path string
	Ops  []OverlayOp
}

RequestOverlay is the part of an overlay that only one request needs.

type RequestVersion

type RequestVersion struct {
	Label string
	// Name is a short title for the version ("Before the tax change"); the label
	// ("1.1") stays what it is called everywhere else. Docs is its description.
	Name    string
	Method  string
	URL     string
	Query   []KeyValue
	Headers []KeyValue
	Body    Body
	Extract []Extraction
	Assert  []string
	// Outcomes are the named ways the request can end (see Outcome). None (or an empty list): success and failure.
	Outcomes []Outcome
	Settings Settings
	Hooks    Hooks
	// Variables are the version's default values for {{var.name}}; the
	// environment's variable of the same name wins.
	Variables []KeyValue
	// Docs is the version's documentation, written as Markdown.
	Docs string
	// Auth, when set, signs or authenticates the request when it is sent: an
	// API key, Digest, OAuth 2.0 or 1.0a, AWS Signature v4, a signed JWT, Hawk
	// or a client certificate. The Authorization header of Headers is the
	// simple form of the same thing.
	Auth *Auth
	// Async, when set, makes this an async (message) request instead of an
	// HTTP one: Method, Query and Body are then unused.
	Async *Async
	// GRPC, when set, makes this a gRPC call instead of an HTTP request. The
	// version's Headers are the call's metadata; Method, URL, Query and Body
	// are unused.
	GRPC *GRPC
	// Dataset, when set, makes this a query of a data store instead of an HTTP
	// request. The version's Headers, Method, URL, Query and Body are unused.
	Dataset *Dataset
}

RequestVersion is one complete definition of a request.

func (RequestVersion) EffectiveOutcomes

func (v RequestVersion) EffectiveOutcomes() []Outcome

EffectiveOutcomes is the version's outcomes: the ones written, or success and failure when it writes none. A written list is the whole list: leaving success out removes it, and the steps that follow on success then never run. An empty list is the same as none (a request always has an outcome): the editor does not let the last one be removed, and a nil list does not survive the trip to the window as different from empty.

func (RequestVersion) Exchange

func (v RequestVersion) Exchange() Exchange

Exchange is which directions the version has. Only messaging varies: a published message sends, a subscription receives, request and reply does both; every other family sends and receives the answer.

func (RequestVersion) Family

func (v RequestVersion) Family() Family

Family is the family of the version: the block that is set decides, and a version with none is HTTP.

type RunTill

type RunTill struct {
	Until         string
	MaxIterations int
	MaxDuration   time.Duration
	Interval      time.Duration
}

RunTill repeats a whole flow until a condition or limit.

type Schedule

type Schedule struct {
	Name       string // unique within the workspace; names the schedule in logs and commands
	Flow       string // a flow path or id
	Collection string // optional: a collection name or id when Flow is ambiguous
	Cron       string // five fields, or @hourly, @daily, …
	Env        string // environment name; "" uses defaults.environment
	Inputs     []KeyValue
	TZ         string // IANA zone name; "" is the machine's zone
	Disabled   bool
}

Schedule runs a flow on a cron schedule while `flowi serve` is running. Schedules are personal, so they live in workspace.yaml, not in a collection.

type SetValue

type SetValue struct {
	Name  string
	From  string
	Value any
	// Where, for From "response", is "body", "header", "cookie" or "status";
	// Path, Header, Cookie and Regex then say which part (a body regex wins
	// over the path).
	Where  string
	Path   string
	Header string
	Cookie string
	Regex  string
	Seed   int64
}

SetValue is one value a set node writes into the variable Name.

From says where the value comes from: "expr" (the default; Value is a template or expression), "literal" (Value as written, never evaluated), "response" (a part of the last response, named by Where) or "generate" (Value is a template using generators such as {{$uuid-v4}}; Seed makes it repeatable on its own).

type Settings

type Settings map[string]any

Settings maps dotted setting keys ("http.max_redirects") to values that the settings package has already validated.

type SubflowCall

type SubflowCall struct {
	Flow Ref
	With []KeyValue
}

SubflowCall is the configuration of a subflow node.

type VarKind

type VarKind string

VarKind is the type of a variable's value.

const (
	VarString  VarKind = ""
	VarNumber  VarKind = "number"
	VarBoolean VarKind = "boolean"
	VarJSON    VarKind = "json" // an object or a list, held as JSON text
)

Variable kinds.

type Workspace

type Workspace struct {
	Meta
	Collections []Mount
	Schedules   []Schedule
	Settings    Settings
	File        string
}

Workspace is the content of workspace.yaml.

Jump to

Keyboard shortcuts

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