API for rete-engine package - Rete.js

API for rete-engine package

DataflowEngine

src/dataflow-engine.ts

DataflowEngine is a plugin that integrates Dataflow with NodeEditor making it easy to use. Additionally, it provides a cache for the data of each node in order to avoid recurring calculations.

ts
class DataflowEngine<Schemes extends DataflowEngineScheme>
ParameterExtendsDescription
SchemesDataflowEngineScheme

Extends Scope<never, Root>

Listens nodecreated noderemoved

fetch

src/dataflow-engine.ts

Fetches output data of the node

ts
fetch(nodeId: string): Promise<Record<string, any>>

Throws Cancelled when reset is called while fetching data

ParameterTypeDescription
nodeIdstringNode id to fetch data from

Returns Promise<Record<string, any>>

fetchInputs

src/dataflow-engine.ts

Fetches input data for the node by fetching data for all its predecessors recursively.

ts
fetchInputs(nodeId: string): Promise<Record<string, any>>

Throws Cancelled when reset` is called while fetching data

ParameterTypeDescription
nodeIdstringNode id to fetch input data for

Returns Promise<Record<string, any>>

reset

src/dataflow-engine.ts

Resets the cache of the node and all its predecessors.

ts
reset(nodeId: string): void
ParameterTypeDescription
nodeIdstringNode id to reset. If not specified, all nodes will be reset.

Returns void

ControlFlowEngine

src/control-flow-engine.ts

ControlFlowEngine is a plugin that integrates ControlFlow with NodeEditor making it easy to use

ts
class ControlFlowEngine<Schemes extends ControlFlowEngineScheme>
ParameterExtendsDescription
SchemesControlFlowEngineScheme

Extends Scope<never, Root>

Listens nodecreated noderemoved

constructor

src/control-flow-engine.ts

ts
constructor(configure: Configure<Schemes>): ControlFlowEngine<Schemes>
ParameterTypeDescription
configureConfigure<Schemes>Allows to specify which inputs and outputs are part of the control flow

Returns ControlFlowEngine<Schemes>

execute

src/control-flow-engine.ts

Trigger execution starting from the specified node.

ts
execute(nodeId: string, input: string): void
ParameterTypeDescription
nodeIdstringNode id
inputstringInput key that will be considered as the initiator of the execution

Returns void

Dataflow

src/dataflow.ts

Dataflow is a class that allows to process nodes in a graph using Dataflow approach.

ts
class Dataflow<Schemes extends ClassicScheme>
ParameterExtendsDescription
SchemesClassicScheme

constructor

src/dataflow.ts

ts
constructor(editor: NodeEditor<Schemes>): Dataflow<Schemes>
ParameterTypeDescription
editorNodeEditor<Schemes>NodeEditor instance

Returns Dataflow<Schemes>

add

src/dataflow.ts

Adds the node to the dataflow.

ts
add(node: T, setup: DataflowNodeSetup<T, any, any>): void
ParameterTypeDescription
nodeTNode instance
setupDataflowNodeSetup<T, any, any>Set of functions that define how to process the node

Returns void

fetch

src/dataflow.ts

Fetches outputs of the node. This method recursively calls data function of the predecessor nodes until receives all of the required inputs and calls data function of the specified node.

ts
fetch(nodeId: string): Promise<Record<string, any>>
ParameterTypeDescription
nodeIdstringNode id

Returns Promise<Record<string, any>> Object with outputs

fetchInputs

src/dataflow.ts

Fetches inputs of the node. Unlike fetch method, this method doesn't call data function of the specified node (but does call data for predecessor nodes recursively).

ts
fetchInputs(nodeId: string): Promise<Record<string, any>>
ParameterTypeDescription
nodeIdstringNode id

Returns Promise<Record<string, any>> Object with inputs

remove

src/dataflow.ts

Removes the node from the dataflow.

ts
remove(nodeId: string): void
ParameterTypeDescription
nodeIdstringNode id

Returns void

ControlFlow

src/control-flow.ts

ControlFlow is a class that allows to execute nodes in a graph using Control flow approach.

ts
class ControlFlow<Schemes extends ClassicScheme>
ParameterExtendsDescription
SchemesClassicScheme

constructor

src/control-flow.ts

ts
constructor(editor: NodeEditor<Schemes>): ControlFlow<Schemes>
ParameterTypeDescription
editorNodeEditor<Schemes>NodeEditor instance

Returns ControlFlow<Schemes>

add

src/control-flow.ts

Adds the node to the control flow.

ts
add(node: T, setup: ControlFlowNodeSetup<T, (keyof T["inputs"])[], (keyof T["outputs"])[]>): void
ParameterTypeDescription
nodeTNode instance
setupControlFlowNodeSetup<T, (keyof T["inputs"])[], (keyof T["outputs"])[]>Set of functions that define how to execute the node

Returns void

execute

src/control-flow.ts

Execute the node and its successors (in case forward is called for some output).

ts
execute(nodeId: string, input: string): void
ParameterTypeDescription
nodeIdstringNode id
inputstringInput key that will be considered as the initiator of the execution

Returns void

remove

src/control-flow.ts

Removes the node from the control flow.

ts
remove(nodeId: string): void
ParameterTypeDescription
nodeIdstringNode id

Returns void

Cancelled

src/utils/cancellable.ts

Cancelled exception. Thrown when reset is called while fetching data.

ts
class Cancelled

Extends Error

ControlFlowNodeSetup

src/control-flow.ts

ControlFlowNodeSetup is a set of functions that define how to execute a node.

ts
type ControlFlowNodeSetup<
  T extends ClassicScheme["Node"],
  I extends (keyof T["inputs"])[],
  O extends (keyof T["outputs"])[],
> = { inputs: Function; outputs: Function; execute: unknown };
ParameterExtendsDescription
TClassicScheme["Node"]
I(keyof T["inputs"])[]
O(keyof T["outputs"])[]

DataflowNodeSetup

src/dataflow.ts

DataflowNodeSetup is a set of functions that define how to process a node.

ts
type DataflowNodeSetup<
  T extends ClassicScheme["Node"],
  I extends { [key in keyof T["inputs"]]: any },
  O extends { [key in keyof T["outputs"]]: any },
> = { inputs: Function; outputs: Function; data: unknown };
ParameterExtendsDescription
TClassicScheme["Node"]
I{ [key in keyof T["inputs"]]: any }
O{ [key in keyof T["outputs"]]: any }