@bian-womp/spark-graph 0.2.29 → 0.2.30
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 +23 -8
- package/lib/cjs/index.cjs.map +1 -1
- package/lib/cjs/src/runtime/GraphRuntime.d.ts +2 -28
- package/lib/cjs/src/runtime/GraphRuntime.d.ts.map +1 -1
- package/lib/esm/index.js +23 -8
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/src/runtime/GraphRuntime.d.ts +2 -28
- package/lib/esm/src/runtime/GraphRuntime.d.ts.map +1 -1
- package/package.json +2 -2
package/lib/cjs/index.cjs
CHANGED
|
@@ -984,7 +984,7 @@ class GraphRuntime {
|
|
|
984
984
|
return def.edges.map((e) => {
|
|
985
985
|
const srcNode = def.nodes.find((n) => n.nodeId === e.source.nodeId);
|
|
986
986
|
const dstNode = def.nodes.find((n) => n.nodeId === e.target.nodeId);
|
|
987
|
-
let effectiveTypeId = e.typeId;
|
|
987
|
+
let effectiveTypeId = e.typeId; // Start with original
|
|
988
988
|
let srcDeclared;
|
|
989
989
|
let dstDeclared;
|
|
990
990
|
if (srcNode) {
|
|
@@ -993,6 +993,7 @@ class GraphRuntime {
|
|
|
993
993
|
srcDeclared = resolved.outputs[e.source.handle];
|
|
994
994
|
}
|
|
995
995
|
if (!effectiveTypeId) {
|
|
996
|
+
// Infer if not explicitly set
|
|
996
997
|
effectiveTypeId = Array.isArray(srcDeclared)
|
|
997
998
|
? srcDeclared[0]
|
|
998
999
|
: srcDeclared;
|
|
@@ -1007,7 +1008,8 @@ class GraphRuntime {
|
|
|
1007
1008
|
id: e.id,
|
|
1008
1009
|
source: { ...e.source },
|
|
1009
1010
|
target: { ...e.target },
|
|
1010
|
-
typeId:
|
|
1011
|
+
typeId: e.typeId, // Preserve original (may be undefined)
|
|
1012
|
+
effectiveTypeId: effectiveTypeId ?? "untyped", // Always present
|
|
1011
1013
|
convert,
|
|
1012
1014
|
convertAsync,
|
|
1013
1015
|
srcUnionTypes: Array.isArray(srcDeclared)
|
|
@@ -1031,18 +1033,18 @@ class GraphRuntime {
|
|
|
1031
1033
|
this.resolvedByNode.set(nodeId, handles);
|
|
1032
1034
|
// Recompute edge converter/type for edges where this node is source or target
|
|
1033
1035
|
for (const e of this.edges) {
|
|
1034
|
-
let srcDeclared = e.
|
|
1036
|
+
let srcDeclared = e.effectiveTypeId; // Use effectiveTypeId as fallback
|
|
1035
1037
|
let dstDeclared = e.dstDeclared;
|
|
1036
1038
|
if (e.source.nodeId === nodeId) {
|
|
1037
1039
|
const resolved = this.resolvedByNode.get(nodeId);
|
|
1038
1040
|
srcDeclared = resolved
|
|
1039
1041
|
? resolved.outputs[e.source.handle]
|
|
1040
1042
|
: srcDeclared;
|
|
1041
|
-
//
|
|
1043
|
+
// Update effectiveTypeId if original wasn't explicit
|
|
1042
1044
|
if (!e.typeId) {
|
|
1043
|
-
e.
|
|
1044
|
-
? srcDeclared?.[0]
|
|
1045
|
-
: srcDeclared;
|
|
1045
|
+
e.effectiveTypeId = Array.isArray(srcDeclared)
|
|
1046
|
+
? srcDeclared?.[0] ?? "untyped"
|
|
1047
|
+
: srcDeclared ?? "untyped";
|
|
1046
1048
|
}
|
|
1047
1049
|
}
|
|
1048
1050
|
if (e.target.nodeId === nodeId) {
|
|
@@ -1165,10 +1167,23 @@ class GraphRuntime {
|
|
|
1165
1167
|
getGraphDef() {
|
|
1166
1168
|
const nodes = Array.from(this.nodes.values()).map((n) => {
|
|
1167
1169
|
const resolved = this.resolvedByNode.get(n.nodeId);
|
|
1170
|
+
// Collect user-provided inputs (inputs without inbound edges)
|
|
1171
|
+
const initialInputs = {};
|
|
1172
|
+
for (const [handle, value] of Object.entries(n.inputs)) {
|
|
1173
|
+
const hasInbound = this.edges.some((e) => e.target.nodeId === n.nodeId && e.target.handle === handle);
|
|
1174
|
+
if (!hasInbound && value !== undefined) {
|
|
1175
|
+
// Clone to avoid shared references
|
|
1176
|
+
initialInputs[handle] =
|
|
1177
|
+
typeof structuredClone === "function"
|
|
1178
|
+
? structuredClone(value)
|
|
1179
|
+
: JSON.parse(JSON.stringify(value));
|
|
1180
|
+
}
|
|
1181
|
+
}
|
|
1168
1182
|
return {
|
|
1169
1183
|
nodeId: n.nodeId,
|
|
1170
1184
|
typeId: n.typeId,
|
|
1171
1185
|
params: n.params ? { ...n.params } : undefined,
|
|
1186
|
+
initialInputs: Object.keys(initialInputs).length > 0 ? initialInputs : undefined,
|
|
1172
1187
|
resolvedHandles: resolved ? { ...resolved } : undefined,
|
|
1173
1188
|
};
|
|
1174
1189
|
});
|
|
@@ -1176,7 +1191,7 @@ class GraphRuntime {
|
|
|
1176
1191
|
id: e.id,
|
|
1177
1192
|
source: { nodeId: e.source.nodeId, handle: e.source.handle },
|
|
1178
1193
|
target: { nodeId: e.target.nodeId, handle: e.target.handle },
|
|
1179
|
-
typeId: e.typeId
|
|
1194
|
+
typeId: e.typeId, // Only export original typeId (may be undefined)
|
|
1180
1195
|
}));
|
|
1181
1196
|
return { nodes, edges };
|
|
1182
1197
|
}
|