Java Script
Java Script (java-script)
Section titled “Java Script (java-script)”Execute embedded JavaScript to transform events.
Transform Scripting Enterprise edition json
Related reference: Scripting Functions.
Discussion
Section titled “Discussion”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.
The embedded context does not install fetch or other network access, filesystem access, console, timers, module imports, pipeline variables, or credentials.
Minimal example
Section titled “Minimal example”actions: - java-script: {}JSON
{ "actions": [ { "java-script": {} } ]}Contents
Section titled “Contents”A ✓ marks a field that accepts a context variable such as
{{ VARIABLE }}.
Execution
Section titled “Execution”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
Section titled “General”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
Section titled “Source”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 ✓ |
lua-expression (string) |
Inline JavaScript source. Either source or path must be provided.Examples: 2 * count() |
|
path ✓ |
file-path (string) |
Path (relative to the job workspace) containing the JavaScript source. Examples: /path/to/file, c:\users\joe\data\file.txt |
Schema
Section titled “Schema”Bindings Table
Section titled “Bindings Table”| Binding | Value |
|---|---|
webhook_secret |
`${secret |
Key format: unknown. Value format: unknown.
Merge Options
Section titled “Merge Options”| 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. |