On this page

JavaScript

Transform inputs with an isolated JavaScript module and explicitly declared outputs.

Use the JavaScript node for transformations, calculations, or combining supported capability calls. For a single HTTP request without transformation, HTTP Request usually needs less configuration.

Module and ports

Code is an ES module whose default export receives (inputs, context) and returns business outputs, or a Promise of those outputs.

export default ({ name, prefix }) => ({
  message: `${prefix}, ${name}!`
});

Declare custom output schemas through config.outputs. Bind named inputs directly, with optional constraints in config.inputs. The public interface owns module identities and runtime assembly.

{
  "op": "node.add", "as": "greet", "type": "code", "name": "Compose greeting",
  "code": "export default ({name, prefix}) => ({message: `${prefix}, ${name}!`});",
  "config": { "outputs": { "message": { "schema": { "type": "string" }, "nullable": false } } },
  "inputs": {
    "name": { "kind": "value", "value": "Ada" },
    "prefix": { "kind": "value", "value": "Hello" }
  }
}
Start supplies a name, Value supplies a prefix, Code combines them, and Outputs declares the workflow result.

Start supplies a name, Value supplies a prefix, Code combines them, and Outputs declares the workflow result.
Input
{"name":"Ada"}
Expected result
{"message":"Hello, Ada!"}
Before running
An Open Flow deployment is needed to execute or import this example. The preview itself runs offline.
Download workflow

Runtime boundaries

The supported Node built-ins form a compatibility subset. A fresh in-memory filesystem starts at /tmp for each Task. It does not expose the host disk or persist into the next invocation. Arbitrary packages, dynamic imports, and CommonJS require are unavailable.

Use explicit Code capabilities for Connector Actions, workflow calls, and HTTP hosts. context.fetch is bounded by the declared hosts and the deployment’s current Engine Contract. It does not inherit platform credentials or grant unrestricted networking.

Persistent results and failures

Return JSON business outputs. Use the supported Artifact interface for Run-owned bytes, and explicit Flow State for cross-Run business values. Virtual files and local globals are not durable stores.

Code supports Task retries and handled errors. A retry repeats the whole module and can repeat external operations. Resource limits, cancellation, and unknown outcomes retain their runtime boundaries.

Sources

Search