@bian-womp/spark-graph 0.2.59 → 0.2.60

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/cjs/index.cjs CHANGED
@@ -582,7 +582,7 @@ class GraphRuntime {
582
582
  const node = this.nodes.get(nodeId);
583
583
  return node?.outputs[output];
584
584
  }
585
- static buildEdgeConverters(srcDeclared, dstDeclared, registry) {
585
+ static buildEdgeConverters(srcDeclared, dstDeclared, registry, edgeLabel) {
586
586
  if (!dstDeclared || !srcDeclared) {
587
587
  return {};
588
588
  }
@@ -601,15 +601,15 @@ class GraphRuntime {
601
601
  const payload = getTypedOutputValue(v);
602
602
  if (isUnion) {
603
603
  if (!typeId) {
604
- throw new Error(`Typed output required for union source; allowed: ${srcTypes.join("|")}`);
604
+ throw new Error(`Typed output required for union source (${edgeLabel}); allowed: ${srcTypes.join("|")}`);
605
605
  }
606
606
  if (!srcTypes.includes(typeId)) {
607
- throw new Error(`Invalid typed output ${typeId}; allowed: ${srcTypes.join("|")}`);
607
+ throw new Error(`Invalid typed output ${typeId} (${edgeLabel}); allowed: ${srcTypes.join("|")}`);
608
608
  }
609
609
  }
610
610
  else if (typeId) {
611
611
  // Warn if typed output is used for non-union source
612
- console.warn(`Typed output ${typeId} is fed even though source is not union: ${srcDeclared} -> ${dstDeclared}`);
612
+ console.warn(`Typed output ${typeId} is fed even though source is not union (${edgeLabel}): ${srcDeclared} -> ${dstDeclared}`);
613
613
  }
614
614
  return { typeId: typeId || srcTypes[0], payload };
615
615
  };
@@ -639,7 +639,7 @@ class GraphRuntime {
639
639
  if (!res)
640
640
  return payload;
641
641
  if (res.kind === "async") {
642
- throw new Error("Async coercion required but convert used");
642
+ throw new Error(`Async coercion required but convert used (${edgeLabel})`);
643
643
  }
644
644
  return res.convert(payload);
645
645
  },
@@ -1138,7 +1138,7 @@ class GraphRuntime {
1138
1138
  if (resolved)
1139
1139
  dstDeclared = getInputTypeId(resolved.inputs, e.target.handle);
1140
1140
  }
1141
- const { convert, convertAsync } = GraphRuntime.buildEdgeConverters(srcDeclared, dstDeclared, registry);
1141
+ const { convert, convertAsync } = GraphRuntime.buildEdgeConverters(srcDeclared, dstDeclared, registry, `buildEdges: ${srcNode?.typeId || ""}.${e.source.nodeId}.${e.source.handle} -> ${dstNode?.typeId || ""}.${e.target.nodeId}.${e.target.handle}`);
1142
1142
  return {
1143
1143
  id: e.id,
1144
1144
  source: { ...e.source },
@@ -1168,6 +1168,8 @@ class GraphRuntime {
1168
1168
  this.resolvedByNode.set(nodeId, handles);
1169
1169
  // Recompute edge converter/type for edges where this node is source or target
1170
1170
  for (const e of this.edges) {
1171
+ const srcNode = this.nodes.get(e.source.nodeId);
1172
+ const dstNode = this.nodes.get(e.target.nodeId);
1171
1173
  let srcDeclared = e.effectiveTypeId; // Use effectiveTypeId as fallback
1172
1174
  let dstDeclared = e.dstDeclared;
1173
1175
  const oldDstDeclared = dstDeclared; // Track old value to detect resolution
@@ -1190,7 +1192,7 @@ class GraphRuntime {
1190
1192
  e.dstDeclared = dstDeclared;
1191
1193
  }
1192
1194
  }
1193
- const conv = GraphRuntime.buildEdgeConverters(srcDeclared, dstDeclared, registry);
1195
+ const conv = GraphRuntime.buildEdgeConverters(srcDeclared, dstDeclared, registry, `updateNodeHandles: ${srcNode?.typeId || ""}.${e.source.nodeId}.${e.source.handle} -> ${dstNode?.typeId || ""}.${e.target.nodeId}.${e.target.handle}`);
1194
1196
  e.convert = conv.convert;
1195
1197
  e.convertAsync = conv.convertAsync;
1196
1198
  // If target handle was just resolved (was undefined, now has a type), re-propagate values