How Scripting Works¶
Fluxify executes your JavaScript code using a custom Virtual Machine (VM) wrapper found in @fluxify/lib.
The execution Flow¶
- Parsing: When a block encounters a field starting with
js:or a script block, it isolates the code. - Context Injection: The system creates a temporary "Context" object. This includes the
inputdata, global variables (vars), and helper functions. - Sandboxed Run: The code is executed inside a V8 sandbox (using Node.js
vmmodule). This isolates it from the host server. - Result Handling:
- If the script returns a value, it is captured.
- If the script is asynchronous (
async/await), the system waits for the promise to resolve. - The result is passed back to the workflow as the block's output.
Syntax¶
You can write standard JavaScript (ES6+).
Example: Simple Calculation¶
Example: Using Globals¶
const userId = vars.currentUserId;
logger.logInfo("Processing for user: " + userId);
return { success: true };