PersistentAI API Documentation / @persistentai/fireflow-types / Flow
Class: Flow
Defined in: packages/fireflow-types/src/flow/flow.ts:42
Interface representing a flow (graph) that contains nodes and edges.
Implements
Constructors
Constructor
new Flow(
metadata?):Flow
Defined in: packages/fireflow-types/src/flow/flow.ts:75
Parameters
metadata?
Partial<FlowMetadata> = {}
Returns
Flow
Properties
_isDisabledPropagationEvents
protected_isDisabledPropagationEvents:boolean=false
Defined in: packages/fireflow-types/src/flow/flow.ts:62
Flag to indicate if the flow is currently disabled for propagation events
edges
readonlyedges:Map<string,IEdge>
Defined in: packages/fireflow-types/src/flow/flow.ts:46
Map of edges in the flow
Implementation of
eventQueue
protectedeventQueue:EventQueue<FlowEvent<FlowEventType>>
Defined in: packages/fireflow-types/src/flow/flow.ts:53
id
readonlyid:string
Defined in: packages/fireflow-types/src/flow/flow.ts:43
Unique identifier for the flow
Implementation of
metadata
readonlymetadata:FlowMetadata
Defined in: packages/fireflow-types/src/flow/flow.ts:44
Metadata about the flow
Implementation of
nodes
readonlynodes:Map<string,INode>
Defined in: packages/fireflow-types/src/flow/flow.ts:45
Map of nodes in the flow
Implementation of
Methods
addEdge()
addEdge(
edge,disableEvents?):Promise<void>
Defined in: packages/fireflow-types/src/flow/flow.ts:362
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/fireflow-types/src/flow/flow.ts:407
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/fireflow-types/src/flow/flow.ts:349
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/fireflow-types/src/flow/flow.ts:119
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/fireflow-types/src/flow/flow.ts:135
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/fireflow-types/src/flow/flow.ts:157
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/fireflow-types/src/flow/flow.ts:102
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/fireflow-types/src/flow/flow.ts:964
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/fireflow-types/src/flow/flow.ts:546
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/fireflow-types/src/flow/flow.ts:1035
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/fireflow-types/src/flow/flow.ts:638
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/fireflow-types/src/flow/flow.ts:739
Disposes the flow and its resources.
Returns
Promise<void>
Implementation of
filterEdges()
filterEdges(
predicate):IEdge[]
Defined in: packages/fireflow-types/src/flow/flow.ts:735
Parameters
predicate
(edge) => boolean
Returns
IEdge[]
Implementation of
getIncomingEdges()
getIncomingEdges(
node):IEdge[]
Defined in: packages/fireflow-types/src/flow/flow.ts:727
Parameters
node
Returns
IEdge[]
Implementation of
getOutgoingEdges()
getOutgoingEdges(
node):IEdge[]
Defined in: packages/fireflow-types/src/flow/flow.ts:731
Parameters
node
Returns
IEdge[]
Implementation of
onEvent()
onEvent(
handler): () =>void
Defined in: packages/fireflow-types/src/flow/flow.ts:772
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/fireflow-types/src/flow/flow.ts:448
Removes an edge from the flow.
Parameters
edgeId
string
The ID of the edge to remove.
Returns
Promise<void>
Implementation of
removeNode()
removeNode(
nodeId):Promise<void>
Defined in: packages/fireflow-types/src/flow/flow.ts:228
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/fireflow-types/src/flow/flow.ts:284
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/fireflow-types/src/flow/flow.ts:438
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/fireflow-types/src/flow/flow.ts:1011
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/fireflow-types/src/flow/flow.ts:401
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/fireflow-types/src/flow/flow.ts:1126
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
updateEdgeMetadata()
updateEdgeMetadata(
edgeId,metadata):Promise<void>
Defined in: packages/fireflow-types/src/flow/flow.ts:520
Update edge metadata and emit event
Parameters
edgeId
string
The ID of the edge to update
metadata
Partial<IEdge["metadata"]>
Partial metadata to merge with existing metadata
Returns
Promise<void>
updateNode()
updateNode(
node):Promise<void>
Defined in: packages/fireflow-types/src/flow/flow.ts:167
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/fireflow-types/src/flow/flow.ts:198
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/fireflow-types/src/flow/flow.ts:708
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/fireflow-types/src/flow/flow.ts:1121
Parameters
data
unknown