JavaScript Transform
Runs a bounded JavaScript transform over automation data.
@lainstack/js/transform · Data
How to use it
Section titled “How to use it”JavaScript Transform runs a short script over named inputs and returns the outputs you declare. Choose it to reshape, compute or filter data that no built-in block covers, for example mapping a list into a list of records or summing a field.
Choose a built-in block first when one fits:
@lainstack/flow/set-valuebuilds a typed value from literals and references, without code.@lainstack/data/apply-shapechecks an existing value against a shape and does not change it.@lainstack/data/parse-jsonparses JSON text.
Traps:
- The script sees only its named inputs. Map every value it needs into
inputs. An input cannot be unset or an optional reference. - The output is one record under
result, with one field per declared output. Downstream blocks read paths such asresult.total. Every top-level output must be required, and there must be at least one. rejectUndeclaredFieldsis always true, so a field outside the output schema fails the step.automation.block.availableReferencesbuilds paths from the block type’s output schema and any pinned sample. That schema declares no fields belowresult, so those paths show origin “sample” and appear only after a sample is pinned. See guidereferences.
Before writing or changing the script, read guide javascript.transform.
Settings
Section titled “Settings”| Setting | Key | Type | Details |
|---|---|---|---|
| Named inputs (required) | inputs |
Value | Named Value Inputs become frozen JavaScript variables. |
| Script (required) | script |
Text | Declare each output with const or let. The preview below shows its fields. At most 50,000 characters. |
| Output schema (required) | outputSchema |
Value | |
| Timeout | timeoutMs |
Number | Maximum script execution duration in milliseconds. |