* Resolve a path of subgraph node IDs into a list of subgraph nodes. * Not intended to be run from subgraphs. * @param nodeIds An ordered list of node IDs, from the root graph to the most nested subgraph node * @returns An ordered list of nested subgraph nodes.
(nodeIds: readonly NodeId[])
| 1576 | * @returns An ordered list of nested subgraph nodes. |
| 1577 | */ |
| 1578 | resolveSubgraphIdPath(nodeIds: readonly NodeId[]): SubgraphNode[] { |
| 1579 | const result: SubgraphNode[] = [] |
| 1580 | let currentGraph: GraphOrSubgraph = this.rootGraph |
| 1581 | |
| 1582 | for (const nodeId of nodeIds) { |
| 1583 | const node: LGraphNode | null = currentGraph.getNodeById(nodeId) |
| 1584 | if (!node) throw new Error(`Node [${nodeId}] not found. ID Path: ${nodeIds.join(":")}`) |
| 1585 | if (!node.isSubgraphNode()) throw new Error(`Node [${nodeId}] is not a SubgraphNode. ID Path: ${nodeIds.join(":")}`) |
| 1586 | |
| 1587 | result.push(node) |
| 1588 | currentGraph = node.subgraph |
| 1589 | } |
| 1590 | |
| 1591 | return result |
| 1592 | } |
| 1593 | |
| 1594 | /** |
| 1595 | * Creates a Object containing all the info about this graph, it can be serialized |
no test coverage detected