@bian-womp/spark-graph 0.3.39 → 0.3.41
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 +24 -28
- package/lib/cjs/index.cjs.map +1 -1
- package/lib/cjs/src/core/type-utils.d.ts +5 -5
- package/lib/cjs/src/core/type-utils.d.ts.map +1 -1
- package/lib/cjs/src/core/types.d.ts +1 -1
- package/lib/cjs/src/core/types.d.ts.map +1 -1
- package/lib/cjs/src/index.d.ts +2 -2
- package/lib/cjs/src/index.d.ts.map +1 -1
- package/lib/cjs/src/misc/utils/merge.d.ts.map +1 -1
- package/lib/esm/index.js +22 -26
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/src/core/type-utils.d.ts +5 -5
- package/lib/esm/src/core/type-utils.d.ts.map +1 -1
- package/lib/esm/src/core/types.d.ts +1 -1
- package/lib/esm/src/core/types.d.ts.map +1 -1
- package/lib/esm/src/index.d.ts +2 -2
- package/lib/esm/src/index.d.ts.map +1 -1
- package/lib/esm/src/misc/utils/merge.d.ts.map +1 -1
- package/package.json +2 -2
package/lib/cjs/index.cjs
CHANGED
|
@@ -3,18 +3,18 @@
|
|
|
3
3
|
function typed(typeId, value) {
|
|
4
4
|
return { __spark_type: typeId, __spark_value: value };
|
|
5
5
|
}
|
|
6
|
-
function
|
|
6
|
+
function isTyped(v) {
|
|
7
7
|
return (!!v &&
|
|
8
8
|
typeof v === "object" &&
|
|
9
9
|
Object.prototype.hasOwnProperty.call(v, "__spark_type"));
|
|
10
10
|
}
|
|
11
|
-
function
|
|
12
|
-
if (
|
|
11
|
+
function unwrapTypeId(v) {
|
|
12
|
+
if (isTyped(v))
|
|
13
13
|
return String(v.__spark_type);
|
|
14
14
|
return undefined;
|
|
15
15
|
}
|
|
16
|
-
function
|
|
17
|
-
if (
|
|
16
|
+
function unwrapValue(v) {
|
|
17
|
+
if (isTyped(v))
|
|
18
18
|
return v.__spark_value;
|
|
19
19
|
return v;
|
|
20
20
|
}
|
|
@@ -1597,8 +1597,8 @@ function buildEdgeConverters(srcDeclared, dstDeclared, registry, edgeLabel) {
|
|
|
1597
1597
|
const hasAsync = coercions.some((r) => r?.kind === "async");
|
|
1598
1598
|
// Helper to extract and validate typed output for unions
|
|
1599
1599
|
const extractPayload = (v) => {
|
|
1600
|
-
const typeId =
|
|
1601
|
-
const payload =
|
|
1600
|
+
const typeId = unwrapTypeId(v);
|
|
1601
|
+
const payload = unwrapValue(v);
|
|
1602
1602
|
if (isSrcUnion) {
|
|
1603
1603
|
if (!typeId) {
|
|
1604
1604
|
throw new Error(`Typed output required for union source (${edgeLabel}); allowed: ${srcTypes.join("|")}`);
|
|
@@ -1980,7 +1980,7 @@ class EdgePropagator {
|
|
|
1980
1980
|
handle: srcHandle,
|
|
1981
1981
|
value,
|
|
1982
1982
|
io: "output",
|
|
1983
|
-
runtimeTypeId:
|
|
1983
|
+
runtimeTypeId: unwrapTypeId(value),
|
|
1984
1984
|
});
|
|
1985
1985
|
return true;
|
|
1986
1986
|
}
|
|
@@ -2039,8 +2039,8 @@ class EdgePropagator {
|
|
|
2039
2039
|
*/
|
|
2040
2040
|
validateUnionType(edge, value, srcNodeId) {
|
|
2041
2041
|
const isUnion = Array.isArray(edge.srcUnionTypes);
|
|
2042
|
-
const
|
|
2043
|
-
if (isUnion && !
|
|
2042
|
+
const isTypedValue = isTyped(value);
|
|
2043
|
+
if (isUnion && !isTypedValue) {
|
|
2044
2044
|
const err = new Error(`Output ${srcNodeId}.${edge.source.handle} requires typed value for union output (allowed: ${edge.srcUnionTypes.join("|")})`);
|
|
2045
2045
|
this.eventEmitter.emit("error", {
|
|
2046
2046
|
kind: "edge-convert",
|
|
@@ -2211,7 +2211,7 @@ class EdgePropagator {
|
|
|
2211
2211
|
handle: edge.target.handle,
|
|
2212
2212
|
value,
|
|
2213
2213
|
io: "input",
|
|
2214
|
-
runtimeTypeId:
|
|
2214
|
+
runtimeTypeId: unwrapTypeId(value),
|
|
2215
2215
|
});
|
|
2216
2216
|
this.handleResolver.scheduleRecomputeHandles(edge.target.nodeId);
|
|
2217
2217
|
}
|
|
@@ -3431,7 +3431,7 @@ class GraphRuntime {
|
|
|
3431
3431
|
handle: h,
|
|
3432
3432
|
value: clonedValue,
|
|
3433
3433
|
io: "input",
|
|
3434
|
-
runtimeTypeId:
|
|
3434
|
+
runtimeTypeId: unwrapTypeId(clonedValue),
|
|
3435
3435
|
});
|
|
3436
3436
|
nodeChanged = true;
|
|
3437
3437
|
}
|
|
@@ -3452,7 +3452,7 @@ class GraphRuntime {
|
|
|
3452
3452
|
handle: h,
|
|
3453
3453
|
value: clonedValue,
|
|
3454
3454
|
io: "output",
|
|
3455
|
-
runtimeTypeId:
|
|
3455
|
+
runtimeTypeId: unwrapTypeId(clonedValue),
|
|
3456
3456
|
});
|
|
3457
3457
|
}
|
|
3458
3458
|
}
|
|
@@ -5980,9 +5980,7 @@ function collectValuesToConvert(values, nodeTypeMap, inputHandleTypeMap, outputH
|
|
|
5980
5980
|
const nodeTypeId = nodeTypeMap.get(nodeId);
|
|
5981
5981
|
for (const [handleId, value] of Object.entries(nodeValues)) {
|
|
5982
5982
|
const handleDataType = handleTypeMap.get(nodeId)?.get(handleId);
|
|
5983
|
-
const runtimeTypeId =
|
|
5984
|
-
? getTypedOutputTypeId(value)
|
|
5985
|
-
: undefined;
|
|
5983
|
+
const runtimeTypeId = isTyped(value) ? unwrapTypeId(value) : undefined;
|
|
5986
5984
|
toConvert.push({
|
|
5987
5985
|
nodeId,
|
|
5988
5986
|
originalNodeId: nodeId,
|
|
@@ -6075,9 +6073,7 @@ function mergeInputsOutputs(targetInputs, targetOutputs, sourceInputs, sourceOut
|
|
|
6075
6073
|
const nodeTypeId = nodeTypeMap?.get(oldId);
|
|
6076
6074
|
for (const [handleId, value] of Object.entries(outputs)) {
|
|
6077
6075
|
const handleDataType = outputHandleTypeMap?.get(oldId)?.get(handleId);
|
|
6078
|
-
const runtimeTypeId =
|
|
6079
|
-
? getTypedOutputTypeId(value)
|
|
6080
|
-
: undefined;
|
|
6076
|
+
const runtimeTypeId = isTyped(value) ? unwrapTypeId(value) : undefined;
|
|
6081
6077
|
outputsToConvert.push({
|
|
6082
6078
|
nodeId: newId,
|
|
6083
6079
|
originalNodeId: oldId,
|
|
@@ -6200,7 +6196,7 @@ function matchesPattern(value, pattern) {
|
|
|
6200
6196
|
function buildValueConverter(config) {
|
|
6201
6197
|
return (converterConfig) => {
|
|
6202
6198
|
const { nodeId, handleId, value, type, nodeTypeId, handleDataType, runtimeTypeId, } = converterConfig;
|
|
6203
|
-
const
|
|
6199
|
+
const isValueTyped = isTyped(value);
|
|
6204
6200
|
for (const mapping of config.mappings) {
|
|
6205
6201
|
if (mapping.type && mapping.type !== type)
|
|
6206
6202
|
continue;
|
|
@@ -6220,9 +6216,9 @@ function buildValueConverter(config) {
|
|
|
6220
6216
|
if (!matchesPattern(runtimeTypeId, mapping.runtimeTypeId))
|
|
6221
6217
|
continue;
|
|
6222
6218
|
}
|
|
6223
|
-
if (mapping.transformTypedValue &&
|
|
6224
|
-
const innerValue =
|
|
6225
|
-
const typedTypeId =
|
|
6219
|
+
if (mapping.transformTypedValue && isValueTyped) {
|
|
6220
|
+
const innerValue = unwrapValue(value);
|
|
6221
|
+
const typedTypeId = unwrapTypeId(value);
|
|
6226
6222
|
if (!typedTypeId)
|
|
6227
6223
|
continue;
|
|
6228
6224
|
if (mapping.path !== undefined) {
|
|
@@ -6296,8 +6292,8 @@ function buildValueConverter(config) {
|
|
|
6296
6292
|
}
|
|
6297
6293
|
if (mapping.path !== undefined) {
|
|
6298
6294
|
let pathSegments = parseJsonPath(mapping.path);
|
|
6299
|
-
if (
|
|
6300
|
-
const typedTypeId =
|
|
6295
|
+
if (isValueTyped) {
|
|
6296
|
+
const typedTypeId = unwrapTypeId(value);
|
|
6301
6297
|
if (typedTypeId) {
|
|
6302
6298
|
const firstSegment = pathSegments[0];
|
|
6303
6299
|
const firstSegmentStr = typeof firstSegment === "string"
|
|
@@ -6393,12 +6389,10 @@ exports.getEffectiveInputs = getEffectiveInputs;
|
|
|
6393
6389
|
exports.getInputDeclaredTypes = getInputDeclaredTypes;
|
|
6394
6390
|
exports.getInputHandleMetadata = getInputHandleMetadata;
|
|
6395
6391
|
exports.getInputTypeId = getInputTypeId;
|
|
6396
|
-
exports.getTypedOutputTypeId = getTypedOutputTypeId;
|
|
6397
|
-
exports.getTypedOutputValue = getTypedOutputValue;
|
|
6398
6392
|
exports.getValueAtPath = getValueAtPath;
|
|
6399
6393
|
exports.installLogging = installLogging;
|
|
6400
6394
|
exports.isInputPrivate = isInputPrivate;
|
|
6401
|
-
exports.
|
|
6395
|
+
exports.isTyped = isTyped;
|
|
6402
6396
|
exports.mergeInputHandleDescriptors = mergeInputHandleDescriptors;
|
|
6403
6397
|
exports.mergeRuntimeState = mergeRuntimeState;
|
|
6404
6398
|
exports.mergeSnapshots = mergeSnapshots;
|
|
@@ -6409,4 +6403,6 @@ exports.registerProgressNodes = registerProgressNodes;
|
|
|
6409
6403
|
exports.setValueAtPath = setValueAtPath;
|
|
6410
6404
|
exports.setValueAtPathWithCreation = setValueAtPathWithCreation;
|
|
6411
6405
|
exports.typed = typed;
|
|
6406
|
+
exports.unwrapTypeId = unwrapTypeId;
|
|
6407
|
+
exports.unwrapValue = unwrapValue;
|
|
6412
6408
|
//# sourceMappingURL=index.cjs.map
|