@bian-womp/spark-workbench 0.3.17 → 0.3.19

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
@@ -889,7 +889,7 @@ class InMemoryWorkbench extends AbstractWorkbench {
889
889
  return this.customData.nodes?.[nodeId];
890
890
  }
891
891
  /**
892
- * Set custom data for a specific node.
892
+ * Set custom data for a specific node (supports partial updates).
893
893
  */
894
894
  setCustomNodeData(nodeId, data, options) {
895
895
  if (!this.customData.nodes) {
@@ -902,10 +902,23 @@ class InMemoryWorkbench extends AbstractWorkbench {
902
902
  }
903
903
  }
904
904
  else {
905
- this.customData.nodes[nodeId] = data;
905
+ // If merge is true, merge with existing data; otherwise replace
906
+ if (options?.merge && this.customData.nodes[nodeId]) {
907
+ this.customData.nodes[nodeId] = {
908
+ ...this.customData.nodes[nodeId],
909
+ ...data,
910
+ };
911
+ }
912
+ else {
913
+ this.customData.nodes[nodeId] = data;
914
+ }
906
915
  }
907
916
  this.emit("graphUiChanged", {
908
- change: { type: "customNodeData", nodeId, data },
917
+ change: {
918
+ type: "customNodeData",
919
+ nodeId,
920
+ data: this.customData.nodes?.[nodeId],
921
+ },
909
922
  ...options,
910
923
  });
911
924
  }
@@ -916,7 +929,7 @@ class InMemoryWorkbench extends AbstractWorkbench {
916
929
  return this.customData.edges?.[edgeId];
917
930
  }
918
931
  /**
919
- * Set custom data for a specific edge.
932
+ * Set custom data for a specific edge (supports partial updates).
920
933
  */
921
934
  setCustomEdgeData(edgeId, data, options) {
922
935
  if (!this.customData.edges) {
@@ -929,10 +942,23 @@ class InMemoryWorkbench extends AbstractWorkbench {
929
942
  }
930
943
  }
931
944
  else {
932
- this.customData.edges[edgeId] = data;
945
+ // If merge is true, merge with existing data; otherwise replace
946
+ if (options?.merge && this.customData.edges[edgeId]) {
947
+ this.customData.edges[edgeId] = {
948
+ ...this.customData.edges[edgeId],
949
+ ...data,
950
+ };
951
+ }
952
+ else {
953
+ this.customData.edges[edgeId] = data;
954
+ }
933
955
  }
934
956
  this.emit("graphUiChanged", {
935
- change: { type: "customEdgeData", edgeId, data },
957
+ change: {
958
+ type: "customEdgeData",
959
+ edgeId,
960
+ data: this.customData.edges?.[edgeId],
961
+ },
936
962
  ...options,
937
963
  });
938
964
  }
@@ -943,17 +969,26 @@ class InMemoryWorkbench extends AbstractWorkbench {
943
969
  return this.customData.meta;
944
970
  }
945
971
  /**
946
- * Set custom metadata.
972
+ * Set custom metadata (supports partial updates).
947
973
  */
948
974
  setCustomMetaData(meta, options) {
949
975
  if (meta === undefined) {
950
976
  delete this.customData.meta;
951
977
  }
952
978
  else {
953
- this.customData.meta = meta;
979
+ // If merge is true, merge with existing metadata; otherwise replace
980
+ if (options?.merge && this.customData.meta) {
981
+ this.customData.meta = {
982
+ ...this.customData.meta,
983
+ ...meta,
984
+ };
985
+ }
986
+ else {
987
+ this.customData.meta = meta;
988
+ }
954
989
  }
955
990
  this.emit("graphUiChanged", {
956
- change: { type: "customMetaData", meta },
991
+ change: { type: "customMetaData", meta: this.customData.meta },
957
992
  ...options,
958
993
  });
959
994
  }
@@ -4123,8 +4158,9 @@ function WorkbenchProvider({ wb, runner, overrides, uiVersion, children, }) {
4123
4158
  const err = nodeError.err;
4124
4159
  let errorSummary;
4125
4160
  if (err && typeof err === "object") {
4126
- const message = err.message || String(err);
4127
- const code = err.code || err.statusCode;
4161
+ const errAny = err;
4162
+ const message = errAny.userMessage || errAny.message || String(err);
4163
+ const code = errAny.statusCode || errAny.code;
4128
4164
  errorSummary = {
4129
4165
  message: typeof message === "string" ? message : String(message),
4130
4166
  code: typeof code === "number" ? code : undefined,
@@ -4140,7 +4176,7 @@ function WorkbenchProvider({ wb, runner, overrides, uiVersion, children, }) {
4140
4176
  ...s,
4141
4177
  [nodeId]: {
4142
4178
  ...s[nodeId],
4143
- lastError: nodeError.err,
4179
+ lastError: errorSummary,
4144
4180
  },
4145
4181
  }));
4146
4182
  // Mark this runId as errored
@@ -4228,6 +4264,10 @@ function WorkbenchProvider({ wb, runner, overrides, uiVersion, children, }) {
4228
4264
  // Start fallback animation window
4229
4265
  setFallbackStarts((prev) => ({ ...prev, [id]: now }));
4230
4266
  }
4267
+ else if (s.kind === "node-custom-data") {
4268
+ const id = s.nodeId;
4269
+ wb.setCustomNodeData(id, s.data, { commit: false, merge: true });
4270
+ }
4231
4271
  else if (s.kind === "node-progress") {
4232
4272
  const id = s.nodeId;
4233
4273
  setNodeStatus((prev) => ({