Skip to content

Java Script

Execute embedded JavaScript to transform events.

Transform Scripting Licensed editions json

Related reference: Scripting Functions.

java-script runs one global function for each JSON event in an embedded QuickJS runtime. Define the function named by entry-point (or transform when it is omitted); LyftData calls it as fn(event, ctx). Host helpers are available under ctx.lyft; use the generated Functions reference for their names, signatures, and feature availability.

Return value Result
The mutated input event object Replaces the payload.
A new object Merges its fields with the input according to merge (default unless-exists).
null Drops the event.
An array Fans out into multiple events.

The merge setting applies only when the function returns a new object. Mutating and returning the input event replaces the payload instead; it does not apply the merge policy. Time and memory limits are opt-in action settings, and each event gets a fresh JavaScript runtime, so globals do not persist between events; use the host store for cross-event state.

Inline source is literal by default: {{...}} and ${...} inside it are not Job templates, so JavaScript template literals retain their native meaning. Supply values with named bindings and read ctx.bindings.name. Set interpolate: true only when source interpolation is deliberately required; existing Jobs that relied on source templates must migrate to bindings or explicitly opt in. Files loaded with path remain literal.

The embedded context does not install fetch or other network access, filesystem access, console, timers, module imports, pipeline variables, or credentials.

actions:
- java-script: {}
JSON
{
"actions": [
{
"java-script": {}
}
]
}

A ✓ marks a field that accepts a context variable such as {{ VARIABLE }}.

Execution
Field Type Required Description
entry-point string Name of the exported function to invoke (defaults to transform).
merge Merge When returning an object, merge strategy to apply (defaults to unless-exists).
Allowed values: overwrite, error, unless-exists
timeout-ms ✓ number (integer) Maximum wall-clock execution time per event in milliseconds.
Examples: 42, 1.2e-10
memory-limit-bytes ✓ number (integer) Maximum QuickJS heap usage while executing (bytes).
Examples: 42, 1.2e-10
General
Field Type Required Description
description string Short summary shown next to the action in the editor.
condition lua-expression (string) Only run this action if the specified condition is met.
Examples: 2 * count()
Source
Field Type Required Description
bindings map (string) Named string values resolved independently from JavaScript source and exposed through frozen ctx.bindings. Binding/deploy authority is secret-use authority because trusted JavaScript can deliberately reveal a value.
source ✓ javascript-source (string) Inline JavaScript source. Either source or path must be provided.
Examples: export function transform(event) { return event; }
interpolate ✓ boolean (bool) Opt in to context and event interpolation in inline source. Source is literal by default; prefer named bindings for values.
Default: false
path ✓ file-path (string) Path (relative to the job workspace) containing the JavaScript source.
Examples: /path/to/file, c:\users\joe\data\file.txt
Binding Value
webhook_secret `${secret

Key format: unknown. Value format: unknown.

Value Aliases Name Description
overwrite overwrite Replace fields that already exist on the input event.
error error Reject a returned field when it already exists on the input event.
unless-exists unless-exists Keep the input value when a returned field already exists.