ChainGraph API Documentation / @badaitech/chaingraph-types / Flow
Class: Flow
Defined in: packages/chaingraph-types/src/flow/flow.ts:52
Interface representing a flow (graph) that contains nodes and edges.
Implements
Constructors
Constructor
new Flow(
metadata):Flow
Defined in: packages/chaingraph-types/src/flow/flow.ts:81
Parameters
metadata
Partial<FlowMetadata> = {}
Returns
Flow
Properties
_isDisabledPropagationEvents
protected_isDisabledPropagationEvents:boolean=false
Defined in: packages/chaingraph-types/src/flow/flow.ts:68
Flag to indicate if the flow is currently disabled for propagation events
edges
readonlyedges:Map<string,IEdge>
Defined in: packages/chaingraph-types/src/flow/flow.ts:56
Map of edges in the flow
Implementation of
eventQueue
protectedeventQueue:EventQueue<FlowEvent<FlowEventType>>
Defined in: packages/chaingraph-types/src/flow/flow.ts:59
id
readonlyid:string
Defined in: packages/chaingraph-types/src/flow/flow.ts:53
Unique identifier for the flow
Implementation of
metadata
readonlymetadata:FlowMetadata
Defined in: packages/chaingraph-types/src/flow/flow.ts:54
Metadata about the flow
Implementation of
nodes
readonlynodes:Map<string,INode>
Defined in: packages/chaingraph-types/src/flow/flow.ts:55
Map of nodes in the flow
Implementation of
Methods
addEdge()
addEdge(
edge,disableEvents?):Promise<void>
Defined in: packages/chaingraph-types/src/flow/flow.ts:383
Adds an edge to the flow.
Parameters
edge
The edge to add.
disableEvents?
boolean
Returns
Promise<void>
Implementation of
addEdges()
addEdges(
edges,disableEvents?):Promise<void>
Defined in: packages/chaingraph-types/src/flow/flow.ts:428
Adds multiple edges to the flow.
Parameters
edges
IEdge[]
The edges to add.
disableEvents?
boolean
If true, events will not be triggered for each edge added.
Returns
Promise<void>
A promise that resolves when all edges have been added.
Implementation of
addEdgeSync()
addEdgeSync(
edge):void
Defined in: packages/chaingraph-types/src/flow/flow.ts:370
Adds an edge to the flow synchronously, without triggering events.
Parameters
edge
The edge to add.
Returns
void
Implementation of
addNode()
addNode(
node,disableEvents?):Promise<INode>
Defined in: packages/chaingraph-types/src/flow/flow.ts:125
Adds a node to the flow.
Parameters
node
The node to add.
disableEvents?
boolean
Returns
Promise<INode>
Implementation of
addNodes()
addNodes(
nodes,disableEvents?):Promise<INode[]>
Defined in: packages/chaingraph-types/src/flow/flow.ts:141
Adds multiple nodes to the flow.
Parameters
nodes
INode[]
The nodes to add.
disableEvents?
boolean
If true, events will not be triggered for each node added.
Returns
Promise<INode[]>
An array of added nodes.
Implementation of
addNodesSync()
addNodesSync(
nodes):INode[]
Defined in: packages/chaingraph-types/src/flow/flow.ts:163
Adds a nodes to the flow synchronously, without triggering events.
Parameters
nodes
INode[]
The nodes to add.
Returns
INode[]
An array of added nodes.
Implementation of
addNodeSync()
addNodeSync(
node):INode
Defined in: packages/chaingraph-types/src/flow/flow.ts:108
Adds a node to the flow synchronously, without triggering events.
Parameters
node
The node to add.
Returns
The added node.
Implementation of
clone()
clone():
Promise<IFlow>
Defined in: packages/chaingraph-types/src/flow/flow.ts:958
Clone the flow
Returns
Promise<IFlow>
A new instance of the flow
Implementation of
connectPorts()
connectPorts(
sourceNodeId,sourcePortId,targetNodeId,targetPortId):Promise<Edge>
Defined in: packages/chaingraph-types/src/flow/flow.ts:541
Connects two nodes via their ports.
Parameters
sourceNodeId
string
The ID of the source node.
sourcePortId
string
The ID of the source port.
targetNodeId
string
The ID of the target node.
targetPortId
string
The ID of the target port.
Returns
Promise<Edge>
Implementation of
deserialize()
deserialize(
data,nodeRegistry?):IFlow
Defined in: packages/chaingraph-types/src/flow/flow.ts:1029
Deserialize the flow from JSON
Parameters
data
unknown
JSON data to deserialize
nodeRegistry?
Optional node registry for custom node types
Returns
Deserialized flow instance
Implementation of
disconnectPorts()
disconnectPorts(
sourceNodeId,sourcePortId,targetNodeId,targetPortId):Promise<void>
Defined in: packages/chaingraph-types/src/flow/flow.ts:633
Disconnects two nodes via their ports.
Parameters
sourceNodeId
string
The ID of the source node.
sourcePortId
string
The ID of the source port.
targetNodeId
string
The ID of the target node.
targetPortId
string
The ID of the target port.
Returns
Promise<void>
Implementation of
dispose()
dispose():
Promise<void>
Defined in: packages/chaingraph-types/src/flow/flow.ts:734
Disposes the flow and its resources.
Returns
Promise<void>
Implementation of
filterEdges()
filterEdges(
predicate):IEdge[]
Defined in: packages/chaingraph-types/src/flow/flow.ts:730
Parameters
predicate
(edge) => boolean
Returns
IEdge[]
Implementation of
getIncomingEdges()
getIncomingEdges(
node):IEdge[]
Defined in: packages/chaingraph-types/src/flow/flow.ts:722
Parameters
node
Returns
IEdge[]
Implementation of
getOutgoingEdges()
getOutgoingEdges(
node):IEdge[]
Defined in: packages/chaingraph-types/src/flow/flow.ts:726
Parameters
node
Returns
IEdge[]
Implementation of
onEvent()
onEvent(
handler): () =>void
Defined in: packages/chaingraph-types/src/flow/flow.ts:767
Subscribe to flow events
Parameters
handler
(event) => void | Promise<void>
The event handler
Returns
():
void
Returns
void
Implementation of
removeEdge()
removeEdge(
edgeId):Promise<void>
Defined in: packages/chaingraph-types/src/flow/flow.ts:474
Removes an edge from the flow.
Parameters
edgeId
string
The ID of the edge to remove.
Returns
Promise<void>
Implementation of
removeEdges()
removeEdges(
edgeIds):Promise<void>
Defined in: packages/chaingraph-types/src/flow/flow.ts:469
Removes multiple edges from the flow.
Parameters
edgeIds
string[]
The IDs of the edges to remove.
Returns
Promise<void>
Implementation of
removeNode()
removeNode(
nodeId):Promise<void>
Defined in: packages/chaingraph-types/src/flow/flow.ts:234
Removes a node from the flow.
Parameters
nodeId
string
The ID of the node to remove.
Returns
Promise<void>
Implementation of
removePort()
removePort(
nodeId,portId):Promise<void>
Defined in: packages/chaingraph-types/src/flow/flow.ts:290
Remove a port from a node, including all child ports and their connections
Parameters
nodeId
string
portId
string
Returns
Promise<void>
Implementation of
replaceEdge()
replaceEdge(
edgeId,newEdge):void
Defined in: packages/chaingraph-types/src/flow/flow.ts:459
Replace an existing edge with a new one. This is useful when updating edge references after transfer.
Parameters
edgeId
string
The ID of the edge to replace
newEdge
The new edge to replace with
Returns
void
serialize()
serialize():
object
Defined in: packages/chaingraph-types/src/flow/flow.ts:1005
Serialize the flow to JSON
Returns
object
JSON representation of the flow
edges
edges:
unknown[]
id
id:
string
metadata
metadata:
FlowMetadata
nodes
nodes:
unknown[]
Implementation of
setEdges()
setEdges(
edges):void
Defined in: packages/chaingraph-types/src/flow/flow.ts:422
Sets all edges in the flow, replacing any existing edges.
Parameters
edges
IEdge[]
The edges to set.
Returns
void
Implementation of
setIsDisabledPropagationEvents()
setIsDisabledPropagationEvents(
value):void
Defined in: packages/chaingraph-types/src/flow/flow.ts:1120
Set the execution state of the flow
Parameters
value
boolean
True if the flow is currently executing, false otherwise
Returns
void
Implementation of
IFlow.setIsDisabledPropagationEvents
updateNode()
updateNode(
node):Promise<void>
Defined in: packages/chaingraph-types/src/flow/flow.ts:173
Updates a node in the flow and triggers an event.
Parameters
node
Returns
Promise<void>
Implementation of
updateNodes()
updateNodes(
nodes):Promise<void>
Defined in: packages/chaingraph-types/src/flow/flow.ts:204
Updates multiple nodes in the flow and triggers an event.
Parameters
nodes
INode[]
Returns
Promise<void>
Implementation of
validate()
validate():
Promise<boolean>
Defined in: packages/chaingraph-types/src/flow/flow.ts:703
Validates the entire flow.
Returns
Promise<boolean>
A promise that resolves to true if the flow is valid.
Implementation of
deserialize()
staticdeserialize(data,nodeRegistry?):IFlow
Defined in: packages/chaingraph-types/src/flow/flow.ts:1115
Parameters
data
unknown