Skip to main content

Module: Script

Run a rhai script against configuration-declared input connectors and emit configuration-declared output connectors.

Each declared input becomes an input connector and is bound in the script as a variable named after its key. The script's final expression must be an object map whose entries match the declared output keys; each declared output becomes an output connector fed from that map. Adding or removing entries in the inputs/outputs lists reshapes the node's connectors.

The script is compiled and validated when the node is saved: syntax errors, empty or duplicate keys, and invalid types are rejected in the editor rather than at parse-run time.

Example
Inputs: price (Number), qty (Number)
Outputs: total (Number), taxed (Number)
Script:
#{ total: price * qty, taxed: (price * qty) * 1.2 }

Input: price = 10, qty = 3
Output: total = 30, taxed = 36

Sandbox and limits

The script runs in a hardened sandbox with no file or network access. eval, import, export, print and debug are disabled (using them is a compile error). Firm ceilings apply:

  • 1,000,000 operations per run (infinite loops are aborted)
  • 32 call levels, 64 expression-nesting depth
  • 1 MiB max string size, 100,000 max array/map entries
  • 64 KiB max script source size

Value conversion

Input values are converted to natural rhai values (whole numbers become integers, other numbers become floats; arrays, objects and JSON become rhai arrays/maps; dates and times become strings). Output values are coerced back to each output's declared type: Date expects YYYY-MM-DD, Time expects HH:MM:SS, and a value that cannot be coerced fails the node. A missing output key, or a script whose final expression is not an object map, is an error.

Parameters

Scriptrequired

The rhai source code. Each input is bound as a variable named after its key; the final expression must be an object map whose entries match the declared output keys. Compiled and checked on save.

Inputs

List of declared inputs. Each entry has a key (connector key and script variable name — unique and non-empty), a label (shown on the node) and a type. Each entry becomes an input connector.

Outputs

List of declared outputs. Each entry has a key (read from the returned object map — unique and non-empty), a label and a type. Each entry becomes an output connector.

Input

Declared inputsrequired

One connector per entry of the Inputs parameter, typed as configured and labeled with the entry's label. All declared inputs are required.

Output

Declared outputs

One connector per entry of the Outputs parameter, carrying the value read by key from the object map the script returns, coerced to the declared type.