@bian-womp/spark-graph 0.2.59 → 0.2.61
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 +12 -7
- package/lib/cjs/index.cjs.map +1 -1
- package/lib/cjs/src/core/types.d.ts +2 -0
- package/lib/cjs/src/core/types.d.ts.map +1 -1
- package/lib/cjs/src/runtime/GraphRuntime.d.ts.map +1 -1
- package/lib/esm/index.js +12 -7
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/src/core/types.d.ts +2 -0
- package/lib/esm/src/core/types.d.ts.map +1 -1
- package/lib/esm/src/runtime/GraphRuntime.d.ts.map +1 -1
- package/package.json +2 -2
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(
|
|
642
|
+
throw new Error(`Async coercion required but convert used (${edgeLabel})`);
|
|
643
643
|
}
|
|
644
644
|
return res.convert(payload);
|
|
645
645
|
},
|
|
@@ -683,6 +683,7 @@ class GraphRuntime {
|
|
|
683
683
|
}
|
|
684
684
|
};
|
|
685
685
|
return {
|
|
686
|
+
nodeId,
|
|
686
687
|
state: node.state,
|
|
687
688
|
setState: (next) => Object.assign(node.state, next),
|
|
688
689
|
emit: emitHandler,
|
|
@@ -1077,6 +1078,7 @@ class GraphRuntime {
|
|
|
1077
1078
|
try {
|
|
1078
1079
|
if (typeof desc.resolveHandles === "function") {
|
|
1079
1080
|
const maybe = desc.resolveHandles({
|
|
1081
|
+
nodeId: n.nodeId,
|
|
1080
1082
|
environment: environment || {},
|
|
1081
1083
|
params: n.params,
|
|
1082
1084
|
inputs: undefined,
|
|
@@ -1138,7 +1140,7 @@ class GraphRuntime {
|
|
|
1138
1140
|
if (resolved)
|
|
1139
1141
|
dstDeclared = getInputTypeId(resolved.inputs, e.target.handle);
|
|
1140
1142
|
}
|
|
1141
|
-
const { convert, convertAsync } = GraphRuntime.buildEdgeConverters(srcDeclared, dstDeclared, registry);
|
|
1143
|
+
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
1144
|
return {
|
|
1143
1145
|
id: e.id,
|
|
1144
1146
|
source: { ...e.source },
|
|
@@ -1168,6 +1170,8 @@ class GraphRuntime {
|
|
|
1168
1170
|
this.resolvedByNode.set(nodeId, handles);
|
|
1169
1171
|
// Recompute edge converter/type for edges where this node is source or target
|
|
1170
1172
|
for (const e of this.edges) {
|
|
1173
|
+
const srcNode = this.nodes.get(e.source.nodeId);
|
|
1174
|
+
const dstNode = this.nodes.get(e.target.nodeId);
|
|
1171
1175
|
let srcDeclared = e.effectiveTypeId; // Use effectiveTypeId as fallback
|
|
1172
1176
|
let dstDeclared = e.dstDeclared;
|
|
1173
1177
|
const oldDstDeclared = dstDeclared; // Track old value to detect resolution
|
|
@@ -1190,7 +1194,7 @@ class GraphRuntime {
|
|
|
1190
1194
|
e.dstDeclared = dstDeclared;
|
|
1191
1195
|
}
|
|
1192
1196
|
}
|
|
1193
|
-
const conv = GraphRuntime.buildEdgeConverters(srcDeclared, dstDeclared, registry);
|
|
1197
|
+
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
1198
|
e.convert = conv.convert;
|
|
1195
1199
|
e.convertAsync = conv.convertAsync;
|
|
1196
1200
|
// If target handle was just resolved (was undefined, now has a type), re-propagate values
|
|
@@ -1668,6 +1672,7 @@ class GraphRuntime {
|
|
|
1668
1672
|
let r;
|
|
1669
1673
|
try {
|
|
1670
1674
|
const res = resolveHandles({
|
|
1675
|
+
nodeId,
|
|
1671
1676
|
environment: this.environment || {},
|
|
1672
1677
|
params: node.params,
|
|
1673
1678
|
inputs: node.inputs || {},
|