MCPcopy
hub / github.com/simstudioai/sim / createDAGNode

Function createDAGNode

packages/testing/src/factories/dag.factory.ts:65–89  ·  view source on GitHub ↗
(options: DAGNodeFactoryOptions = {})

Source from the content-addressed store, hash-verified

63 * ```
64 */
65export function createDAGNode(options: DAGNodeFactoryOptions = {}): DAGNode {
66 const id = options.id ?? `node-${generateRandomString(6)}`
67 const block =
68 options.block ??
69 createSerializedBlock({
70 id,
71 type: options.type ?? 'function',
72 params: options.params,
73 })
74
75 const outgoingEdges = new Map<string, DAGEdge>()
76 if (options.outgoingEdges) {
77 options.outgoingEdges.forEach((edge, i) => {
78 outgoingEdges.set(`edge-${i}`, edge)
79 })
80 }
81
82 return {
83 id,
84 block,
85 outgoingEdges,
86 incomingEdges: new Set(options.incomingEdges ?? []),
87 metadata: options.metadata ?? {},
88 }
89}
90
91/**
92 * Creates a DAG structure from a list of node IDs.

Callers 3

createDAGFunction · 0.85
createDAGFromNodesFunction · 0.85
createLinearDAGFunction · 0.85

Calls 3

generateRandomStringFunction · 0.90
createSerializedBlockFunction · 0.90
setMethod · 0.65

Tested by

no test coverage detected