@bian-womp/spark-graph 0.2.58 → 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 +44 -12
- package/lib/cjs/index.cjs.map +1 -1
- package/lib/cjs/src/index.d.ts +1 -1
- package/lib/cjs/src/index.d.ts.map +1 -1
- package/lib/cjs/src/misc/utils/merge.d.ts +13 -1
- package/lib/cjs/src/misc/utils/merge.d.ts.map +1 -1
- package/lib/cjs/src/runtime/GraphRuntime.d.ts.map +1 -1
- package/lib/esm/index.js +44 -12
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/src/index.d.ts +1 -1
- package/lib/esm/src/index.d.ts.map +1 -1
- package/lib/esm/src/misc/utils/merge.d.ts +13 -1
- package/lib/esm/src/misc/utils/merge.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
|
},
|
|
@@ -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
|
|
@@ -3766,7 +3768,14 @@ function mergeGraphDefinitions(target, source, converter) {
|
|
|
3766
3768
|
? transformedNode.resolvedHandles.inputs[handleId]
|
|
3767
3769
|
: transformedNode.resolvedHandles.inputs[handleId]?.typeId
|
|
3768
3770
|
: undefined;
|
|
3769
|
-
transformedInitialInputs[handleId] = converter(
|
|
3771
|
+
transformedInitialInputs[handleId] = converter({
|
|
3772
|
+
nodeId: newId,
|
|
3773
|
+
handleId,
|
|
3774
|
+
value,
|
|
3775
|
+
type: "initialInput",
|
|
3776
|
+
nodeTypeId,
|
|
3777
|
+
handleDataType,
|
|
3778
|
+
});
|
|
3770
3779
|
}
|
|
3771
3780
|
transformedNode.initialInputs = transformedInitialInputs;
|
|
3772
3781
|
}
|
|
@@ -3779,7 +3788,14 @@ function mergeGraphDefinitions(target, source, converter) {
|
|
|
3779
3788
|
? transformedNode.resolvedHandles.inputs[handleId]
|
|
3780
3789
|
: transformedNode.resolvedHandles.inputs[handleId]?.typeId
|
|
3781
3790
|
: undefined;
|
|
3782
|
-
transformedInputDefaults[handleId] = converter(
|
|
3791
|
+
transformedInputDefaults[handleId] = converter({
|
|
3792
|
+
nodeId: newId,
|
|
3793
|
+
handleId,
|
|
3794
|
+
value,
|
|
3795
|
+
type: "inputDefault",
|
|
3796
|
+
nodeTypeId,
|
|
3797
|
+
handleDataType,
|
|
3798
|
+
});
|
|
3783
3799
|
}
|
|
3784
3800
|
transformedNode.resolvedHandles = {
|
|
3785
3801
|
...transformedNode.resolvedHandles,
|
|
@@ -3877,7 +3893,14 @@ function mergeInputsOutputs(targetInputs, targetOutputs, sourceInputs, sourceOut
|
|
|
3877
3893
|
for (const [handleId, value] of Object.entries(inputs)) {
|
|
3878
3894
|
const handleDataType = handleTypeMap?.get(oldId)?.get(handleId);
|
|
3879
3895
|
transformedInputs[handleId] = converter
|
|
3880
|
-
? converter(
|
|
3896
|
+
? converter({
|
|
3897
|
+
nodeId: newId,
|
|
3898
|
+
handleId,
|
|
3899
|
+
value,
|
|
3900
|
+
type: "input",
|
|
3901
|
+
nodeTypeId,
|
|
3902
|
+
handleDataType,
|
|
3903
|
+
})
|
|
3881
3904
|
: value;
|
|
3882
3905
|
}
|
|
3883
3906
|
mergedInputs[newId] = mergedInputs[newId]
|
|
@@ -3896,7 +3919,15 @@ function mergeInputsOutputs(targetInputs, targetOutputs, sourceInputs, sourceOut
|
|
|
3896
3919
|
? getTypedOutputTypeId(value)
|
|
3897
3920
|
: undefined;
|
|
3898
3921
|
transformedOutputs[handleId] = converter
|
|
3899
|
-
? converter(
|
|
3922
|
+
? converter({
|
|
3923
|
+
nodeId: newId,
|
|
3924
|
+
handleId,
|
|
3925
|
+
value,
|
|
3926
|
+
type: "output",
|
|
3927
|
+
nodeTypeId,
|
|
3928
|
+
handleDataType,
|
|
3929
|
+
runtimeTypeId,
|
|
3930
|
+
})
|
|
3900
3931
|
: value;
|
|
3901
3932
|
}
|
|
3902
3933
|
mergedOutputs[newId] = mergedOutputs[newId]
|
|
@@ -3969,7 +4000,8 @@ function matchesPattern(value, pattern) {
|
|
|
3969
4000
|
* - value exists in valueMap
|
|
3970
4001
|
*/
|
|
3971
4002
|
function buildValueConverter(config) {
|
|
3972
|
-
return (
|
|
4003
|
+
return (converterConfig) => {
|
|
4004
|
+
const { nodeId, handleId, value, type, nodeTypeId, handleDataType, runtimeTypeId, } = converterConfig;
|
|
3973
4005
|
const isTyped = isTypedOutput(value);
|
|
3974
4006
|
for (const mapping of config.mappings) {
|
|
3975
4007
|
if (!matchesPattern(handleId, mapping.handleId))
|