dataflow-wasm 2.0.4

WebAssembly bindings for dataflow-rs workflow engine
Documentation

@goplasmatic/dataflow-wasm

WebAssembly bindings for dataflow-rs workflow engine

License: Apache 2.0 npm


WebAssembly bindings for dataflow-rs, enabling high-performance workflow execution in the browser. Run the same workflow engine that powers your Rust backend directly in JavaScript/TypeScript applications.

Features

  • Browser Execution - Run dataflow-rs workflows directly in the browser
  • Full Feature Parity - Same workflow engine as the native Rust version
  • TypeScript Support - Full type definitions included
  • Execution Tracing - Debug workflows with step-by-step execution traces

Installation

npm install @goplasmatic/dataflow-wasm

Quick Start

import init, { WasmEngine } from '@goplasmatic/dataflow-wasm';

// Initialize WASM module
await init();

// Define workflows
const workflows = [
  {
    id: 'my-workflow',
    name: 'My Workflow',
    tasks: [
      {
        id: 'task-1',
        name: 'Transform Data',
        function: {
          name: 'map',
          input: {
            mappings: [
              { path: 'data.output', logic: { var: 'data.input' } }
            ]
          }
        }
      }
    ]
  }
];

// Create engine
const engine = new WasmEngine(workflows);

// Process a message
const message = { data: { input: 'hello' }, metadata: {} };
const result = await engine.process(message);
console.log(result); // { data: { input: 'hello', output: 'hello' }, ... }

API

WasmEngine

class WasmEngine {
  constructor(workflows: Workflow[]);

  // Process a message through all workflows
  process(message: Message): Promise<Message>;

  // Process with execution trace for debugging
  processWithTrace(message: Message): Promise<ExecutionTrace>;
}

Types

interface Workflow {
  id: string;
  name: string;
  condition?: JsonLogicValue;
  tasks: Task[];
}

interface Task {
  id: string;
  name: string;
  condition?: JsonLogicValue;
  function: FunctionConfig;
}

interface Message {
  data: object;
  metadata: object;
  payload?: object;
  temp_data?: object;
}

interface ExecutionTrace {
  steps: ExecutionStep[];
  initial_message: Message;
  final_message: Message;
}

Building from Source

Requirements:

  • Rust 1.70+
  • wasm-pack
# Build WASM package
cd wasm
wasm-pack build --target web

# The output will be in wasm/pkg/

Related Packages

License

This project is licensed under the Apache License, Version 2.0. See the LICENSE file for details.