transform.script runs a typed TypeScript function in a secure WebAssembly
(QuickJS) sandbox. Reach for it whenever a transformation is deterministic but
too involved for a LiquidJS template, array map/filter/reduce, multi-step
calculations, conditional branching, date arithmetic, or regex parsing.
When to use Script vs LiquidJS
A good rule: if the logic spans more than two or three lines, use a script.
The contract
The function must be namedscript. Its parameter names come from the
inputs map, but their order is independent of YAML/JSON key order. Its
return-type annotation is this step’s output schema. There is no separate
outputSchema: field.
- Parameter names must equal the configured input keys. Enforced at push time.
- The
: Rreturn annotation is mandatory and is derived to JSON Schema, so downstream steps autocomplete against it. A too-loose annotation (such asunknown) leaves downstream field references unresolvable. - No
async,import(), orrequire(), the sandbox has no module loader and the worker calls the function synchronously.
Example
{ subtotal, tax, total } is the output schema, so a later step can read
{{ steps.calculate-totals.output.total }}.
Configuration
Configuration goes inside the step’swith: block.
record<string, string>
Named inputs mapped from template expressions. Keys become function parameters; parameter order is independent of YAML/JSON key order:
inputs: { items, taxRate } accepts function script(taxRate: …, items: …): R { … }.string
required
TypeScript function declaration. Must be
function script(args): R { … } where parameter names exactly match the configured input keys in any order and R is a return type annotation. The annotation IS this step’s output schema.number
default:"5000"
Max execution time in milliseconds (default: 5000)
number
default:"10485760"
Max memory in bytes (default: 10MB)
Output
Returnsunknown. Value returned from script. Validated at runtime against the JSON Schema derived from the function’s return type annotation.