softflow24 / data-river

MIT License
4 stars 0 forks source link

Implement a node graph with ID-based configuration and WebSocket/browser-based result handling #36

Open c0rtexR opened 3 days ago

c0rtexR commented 3 days ago

Task: Implement a node graph with ID-based configuration and WebSocket/browser-based result handling


Task Overview:
Develop a node graph structure where each block has a unique ID and configuration setup to handle task execution. Ensure that nodes can pass values and receive results, with real-time updates provided either through WebSockets or directly in the browser for simpler blocks.


SMART Criteria

Specific 🎯:
Create a workflow system where each node is defined by:

Measurable 📏:
Success will be measured by:

Achievable 🚀:
This task is achievable using existing WebSocket and browser APIs for real-time data transfer, along with a node-based configuration model that can be dynamically updated.

Relevant 🎯:
Implementing this node graph with configuration and result handling is crucial for the data-river editor to support complex workflows while maintaining real-time feedback for users.

Time-bound ⏳:
This task should be completed within 2 weeks to allow sufficient time for testing the performance of both WebSocket and browser-based approaches.


Subtasks 📝


Acceptance Criteria ✅


Additional Notes 🗒

c0rtexR commented 3 days ago

example graph

const workflowDefinition = {
  nodes: [
    {
      id: 'node-1',
      type: 'restCall',
      inputKeys: [], 
      outputKeys: ['apiResponse'],
      config: {
        method: 'GET',
        url: 'https://jsonplaceholder.typicode.com/todos/1',
        headers: {},
      },
    },
    {
      id: 'node-2',
      type: 'processData',
      inputKeys: ['apiResponse'],
      outputKeys: ['processedData'],
      config: {},
    },
    {
      id: 'node-3',
      type: 'optionalRestCall',
      inputKeys: [],
      outputKeys: ['optionalData'],
      onError: 'continue',
      activityOptions: {
        startToCloseTimeout: '30 seconds',
        retry: {
          maximumAttempts: 2,
        },
      },
      config: {
        method: 'GET',
        url: 'https://example.com/optional-data',
      },
    },
    {
      id: 'node-4',
      type: 'conditionNode',
      inputKeys: ['processedData'],
      condition: 'processedData.completed === true',
      trueBranch: 'node-5',
      falseBranch: 'node-6',
    },
    {
      id: 'node-5',
      type: 'parallelNode',
      branches: ['node-7', 'node-8'],
    },
    {
      id: 'node-6',
      type: 'scriptNode',
      inputKeys: ['processedData'],
      outputKeys: ['scriptOutput'],
      script: `
        const data = processedData;
        const result = { ...data, extraInfo: 'Added by script' };
        return result;
      `,
    }       
  ],
  edges: [
    { source: 'node-1', target: 'node-2' },
    { source: 'node-2', target: 'node-3' },
  ],
};