Navigation

JS Script Component

Execute custom JavaScript logic for advanced data processing.

Last updated:

The JS Script Component is the "Swiss Army Knife" of DataLensia pipelines. It allows you to write custom code to handle complex transformations that aren't possible with standard visual nodes.

⚙️ Configuration

  • Script Editor: A full Monaco editor with syntax highlighting for writing your JavaScript logic.

🧪 Execution Context

Your script has access to several global variables:

VariableDescription
inputThe primary input data (usually from the first upstream connection).
inputsAn array of all inputs from all connected upstream nodes.
getValue(path)Helper to get a value from input using dot notation.
getValueByPath(data, path)Helper to get a value from any object using dot notation.

🛡️ Security & Sandbox

Scripts are executed in a highly restricted sandbox:

  • No Network Access: fetch, XMLHttpRequest, etc., are disabled.
  • No DOM Access: window, document, and navigator are undefined.
  • No Storage Access: localStorage and cookies are blocked.
  • Strict Mode: All scripts run in JavaScript "Strict Mode".

💡 Example

// Calculate total order value with a custom tax rate
return input.map(record => ({
  ...record,
  total: record.price * (1 + (record.taxRate / 100)),
  category: record.price > 100 ? 'Premium' : 'Standard'
}));

🚀 Pro Tip

Use the inputs array when this node is connected to multiple parents to perform custom joins or comparisons between data streams.