Skip to main content

Module expr

Module expr 

Source
Expand description

The closed expression set a workflow runs.

The schema generator parses every condition, set: value and {{ }} template of a workflow when it generates, refuses what is not in this set, and writes the result as the data types of this module (an Expr tree, a Template, a Tpl value). The engine evaluates them over the instance’s JSON context; nothing is parsed at run time.

What an expression can say:

  • paths into context, event, result, error and config, with .key and [n], and steps.<name>.completed; a missing key reads as null;
  • literals (null, booleans, numbers, strings, arrays) and duration literals (15m, 30d);
  • == != < <= > >=, && || !, + - * / %, a ?? b, a ? b : c, a in [..];
  • .length, .contains(x), .includes(x), .starts_with(x), .ends_with(x);
  • now(), new_uuid(), coalesce(a, b, ..), len(x);
  • a function the workflow declares under functions:, called through Funcs.

time + duration and time - duration add to an RFC 3339 text and answer one; < and friends compare two RFC 3339 texts as instants.

Structs§

NoFuncs
A Funcs that declares nothing: every call is an error.
Scope
What an expression reads.
Template
A string with {{ }} holes. A template that is one hole renders as that expression’s own value (a number stays a number, an object stays an object); anything else renders as text.

Enums§

BinOp
A binary operator.
Dur
A duration: fixed, or a template evaluated when it is needed ({{ context.minutes }}m).
Expr
A compiled expression.
Part
A piece of a template.
Root
Where a path starts.
Seg
One step of a path.
Tpl
A value of a step’s parameters: a literal, a template, or a map or list of them.

Traits§

Funcs
The functions a workflow declares under functions:, implemented by hand.

Functions§

canonical
The canonical text of a value as a wait key: strings as they are, null as null, a whole number without a fraction.
eval
Evaluate expr over scope.
holds
Evaluate expr and read the answer as a condition.
parse_duration
Read 30s, 15m, 24h, 7d, 2w, or a bare number of seconds, as seconds.
render
Render a parameter value.
render_duration
Render a duration: seconds, or a template read with parse_duration.
render_template
Render a template: one hole is that expression’s value, anything else is text.
text_of
The text of a value inside a larger template: strings as they are, null as nothing.
truthy
Whether v counts as true: not null, false, 0 or "".
wait_key
The key a wait is matched on: the canonical text of each value, in the order given, as a JSON array. Both the instance (from its context) and the event (from its payload) build it the same way, so equal values make equal keys.