Skip to content

util

Module Step Summary
— util/base64 Encode or decode a string with base64 / base64url.
— util/generate_uuid Generate a random UUID v4.
— util/json_path_extract Extract a value out of nested data by dot-notation path.
— util/log Write a resolved value to stdout and the run log.
— util/parse_kv Parse a delimited key=value string and optionally select one key.
— util/validate_path Extract a value from a step output by dot-path, for a validate: block to assert on.

util/base64

Encode or decode a string with base64 / base64url.

The motivating case is the AAS Digital Twin Registry, whose API wants an identifier base64url-encoded before it goes into a request path.

Inputs

Parameter Type Required Default Also accepts Description
store_in_variable string no '' — Name of a context variable to also store the result in.
input string yes — — The string to encode or decode.
mode encode | decode no 'encode' — Direction of the conversion.
url_safe boolean no False — Use the URL-safe alphabet ('-'/'_' instead of '+'/'/'). Required for AAS/DTR identifiers.
strip_padding boolean no False — When encoding, drop trailing '=' padding. Ignored when decoding, where padding is always restored.

Output — the value assertions and returns: read

The encoded or decoded string.

Type: string

util/generate_uuid

Generate a random UUID v4.

A fresh identifier is produced on every call, so a test that needs a value no earlier run can collide with can mint one here.

Inputs

No fields.

Output — the value assertions and returns: read

The generated identifier — the output is the UUID string.

Type: string

util/json_path_extract

Extract a value out of nested data by dot-notation path.

Numeric segments index into lists (datasets.0.id) and a key[field=value] segment selects the first list element whose field equals value. Dots inside a predicate are not separators, so a value such as [interface='SUBMODEL-VALUE-3.1'] survives intact.

Inputs

Parameter Type Required Default Also accepts Description
store_in_variable string no '' — Name of a context variable to also store the result in.
input any yes — — Either the name of the context variable holding the data (e.g. 'datasets'), or the data itself when a '${{ }}' expression is passed — it resolves before the step runs.
path string yes — — Dot-notation path to the desired value, e.g. 'datasets.0.id'.

Output — the value assertions and returns: read

The value found at the path — whatever type the document holds there.

Type: any

util/log

Write a resolved value to stdout and the run log.

An authoring aid for inspecting what an expression resolved to; it asserts nothing and always passes. The value is echoed to stdout because the run report prints only step names, statuses, and errors.

Inputs

Parameter Type Required Default Also accepts Description
value any no None — The value to show — typically a '${{ }}' expression.
message string no '' — Label printed before the value; defaults to the step id.

Output — the value assertions and returns: read

The logged value, passed through unchanged.

Type: any

util/parse_kv

Parse a delimited key=value string and optionally select one key.

Pairs split on pair_separator and each pair on the first kv_separator only, so a value may itself contain that separator — a URL with a query string survives intact.

Inputs

Parameter Type Required Default Also accepts Description
store_in_variable string no '' — Name of a context variable to also store the result in.
input string yes — — The string to parse, e.g. an EDC 'subprotocolBody'.
pair_separator string no ';' — Separator between pairs.
kv_separator string no '=' — Separator between key and value.
select string no None — Return only this key's value; omit to return the whole parsed mapping.

Output — the value assertions and returns: read

The selected key's value when 'select' is given, else every parsed pair.

Type: string | object

util/validate_path

Extract a value from a step output by dot-path, for a validate: block to assert on.

Identical to util/json_path_extract — same inputs, same output — under a name that says what it is usually there for.

Inputs

Parameter Type Required Default Also accepts Description
store_in_variable string no '' — Name of a context variable to also store the result in.
input any yes — — Either the name of the context variable holding the data (e.g. 'datasets'), or the data itself when a '${{ }}' expression is passed — it resolves before the step runs.
path string yes — — Dot-notation path to the desired value, e.g. 'datasets.0.id'.

Output — the value assertions and returns: read

The value found at the path — whatever type the document holds there.

Type: any