@bian-womp/spark-remote 0.2.61 → 0.2.63

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/esm/index.js CHANGED
@@ -428,7 +428,7 @@ async function createRuntimeAdapter(createRegistry, send, extensions) {
428
428
  if (!def)
429
429
  return;
430
430
  // Only build if skipBuild is not true
431
- if (options?.skipBuild !== true) {
431
+ if (!options?.skipBuild) {
432
432
  await originalApi.build(def, payload.environment);
433
433
  }
434
434
  else if (!graphRuntime) {
@@ -472,42 +472,93 @@ async function createRuntimeAdapter(createRegistry, send, extensions) {
472
472
  const coercions = registry.listCoercions();
473
473
  return { types, categories, nodes, coercions, schemaVersion: 4 };
474
474
  },
475
- update: async (def) => {
475
+ update: async (def, options) => {
476
476
  if (!graphRuntime)
477
477
  return;
478
- graphRuntime.update(def, registry);
479
- send({
480
- message: {
481
- type: "invalidate",
482
- payload: { reason: "graph-updated" },
483
- },
484
- });
478
+ const wasPaused = graphRuntime.isPaused();
479
+ if (options?.dry && !wasPaused)
480
+ graphRuntime.pause();
481
+ try {
482
+ graphRuntime.update(def, registry);
483
+ send({
484
+ message: {
485
+ type: "invalidate",
486
+ payload: { reason: "graph-updated" },
487
+ },
488
+ });
489
+ }
490
+ finally {
491
+ if (options?.dry && !wasPaused)
492
+ graphRuntime.resume();
493
+ }
485
494
  },
486
495
  setEnvironment: (env, opts) => {
487
496
  if (!graphRuntime)
488
497
  return;
489
- if (opts?.merge) {
490
- const current = graphRuntime.getEnvironment();
491
- const next = { ...(current || {}), ...(env || {}) };
492
- graphRuntime.setEnvironment(next);
493
- return;
498
+ const wasPaused = graphRuntime.isPaused();
499
+ if (opts?.dry && !wasPaused)
500
+ graphRuntime.pause();
501
+ try {
502
+ if (opts?.merge) {
503
+ const current = graphRuntime.getEnvironment();
504
+ const next = { ...(current || {}), ...(env || {}) };
505
+ graphRuntime.setEnvironment(next);
506
+ }
507
+ else {
508
+ graphRuntime.setEnvironment(env);
509
+ }
510
+ }
511
+ finally {
512
+ if (opts?.dry && !wasPaused)
513
+ graphRuntime.resume();
494
514
  }
495
- graphRuntime.setEnvironment(env);
496
515
  },
497
- setInputs: (nodeId, inputs) => {
498
- if (engine) {
499
- engine.setInputs(nodeId, inputs);
516
+ setInputs: (nodeId, inputs, options) => {
517
+ if (!graphRuntime)
518
+ return;
519
+ const wasPaused = graphRuntime.isPaused();
520
+ if (options?.dry && !wasPaused)
521
+ graphRuntime.pause();
522
+ try {
523
+ if (engine) {
524
+ engine.setInputs(nodeId, inputs);
525
+ }
526
+ else {
527
+ graphRuntime.setInputs(nodeId, inputs);
528
+ }
500
529
  }
501
- else {
502
- graphRuntime?.setInputs(nodeId, inputs);
530
+ finally {
531
+ if (options?.dry && !wasPaused)
532
+ graphRuntime.resume();
503
533
  }
504
534
  },
505
- triggerExternal: (nodeId, event) => {
506
- if (engine) {
507
- engine.triggerExternal(nodeId, event);
535
+ copyOutputs: (fromNodeId, toNodeId, options) => {
536
+ if (!graphRuntime)
537
+ return;
538
+ // Get outputs from source node
539
+ const fromNode = graphRuntime.getNodeData(fromNodeId);
540
+ if (!fromNode?.outputs)
541
+ return;
542
+ // Copy outputs to target node using hydrate
543
+ graphRuntime.hydrate({ outputs: { [toNodeId]: { ...fromNode.outputs } } }, { reemit: !options?.dry });
544
+ },
545
+ triggerExternal: (nodeId, event, options) => {
546
+ if (!graphRuntime)
547
+ return;
548
+ const wasPaused = graphRuntime.isPaused();
549
+ if (options?.dry && !wasPaused)
550
+ graphRuntime.pause();
551
+ try {
552
+ if (engine) {
553
+ engine.triggerExternal(nodeId, event);
554
+ }
555
+ else {
556
+ graphRuntime.triggerExternal(nodeId, event);
557
+ }
508
558
  }
509
- else {
510
- graphRuntime?.triggerExternal(nodeId, event);
559
+ finally {
560
+ if (options?.dry && !wasPaused)
561
+ graphRuntime.resume();
511
562
  }
512
563
  },
513
564
  launch: (opts) => {
@@ -594,6 +645,7 @@ async function createRuntimeAdapter(createRegistry, send, extensions) {
594
645
  update: wrapMethod("update", originalApi.update),
595
646
  setEnvironment: wrapMethod("setEnvironment", originalApi.setEnvironment),
596
647
  setInputs: wrapMethod("setInputs", originalApi.setInputs),
648
+ copyOutputs: wrapMethod("copyOutputs", originalApi.copyOutputs),
597
649
  triggerExternal: wrapMethod("triggerExternal", originalApi.triggerExternal),
598
650
  step: wrapMethod("step", originalApi.step),
599
651
  computeNode: wrapMethod("computeNode", originalApi.computeNode),
@@ -643,14 +695,22 @@ class RemoteEngine {
643
695
  });
644
696
  }
645
697
  // Batch inputs for a single network round-trip
646
- setInputs(nodeId, inputs) {
698
+ setInputs(nodeId, inputs, options) {
647
699
  this.transport.send({
648
- message: { type: "SetInputs", payload: { nodeId, inputs } },
700
+ message: {
701
+ type: "SetInputs",
702
+ payload: { nodeId, inputs },
703
+ dry: options?.dry,
704
+ },
649
705
  });
650
706
  }
651
- triggerExternal(nodeId, event) {
707
+ triggerExternal(nodeId, event, options) {
652
708
  this.transport.send({
653
- message: { type: "TriggerExternal", payload: { nodeId, event } },
709
+ message: {
710
+ type: "TriggerExternal",
711
+ payload: { nodeId, event },
712
+ dry: options?.dry,
713
+ },
654
714
  });
655
715
  }
656
716
  on(event, handler) {
@@ -941,10 +1001,10 @@ class RuntimeApiClient {
941
1001
  },
942
1002
  });
943
1003
  }
944
- async update(def) {
1004
+ async update(def, options) {
945
1005
  const transport = await this.ensureConnected();
946
1006
  await transport.request({
947
- message: { type: "Update", payload: { def } },
1007
+ message: { type: "Update", payload: { def }, dry: options?.dry },
948
1008
  });
949
1009
  }
950
1010
  async describeRegistry() {
@@ -1004,6 +1064,7 @@ class RuntimeApiClient {
1004
1064
  message: {
1005
1065
  type: "SetEnvironment",
1006
1066
  payload: { environment, merge: opts?.merge },
1067
+ dry: opts?.dry,
1007
1068
  },
1008
1069
  });
1009
1070
  }
@@ -1015,6 +1076,16 @@ class RuntimeApiClient {
1015
1076
  const payload = res?.message || {};
1016
1077
  return payload.environment || {};
1017
1078
  }
1079
+ async copyOutputs(fromNodeId, toNodeId, options) {
1080
+ const transport = await this.ensureConnected();
1081
+ await transport.request({
1082
+ message: {
1083
+ type: "CopyOutputs",
1084
+ payload: { fromNodeId, toNodeId },
1085
+ dry: options?.dry,
1086
+ },
1087
+ });
1088
+ }
1018
1089
  async coerce(from, to, value) {
1019
1090
  const transport = await this.ensureConnected();
1020
1091
  const res = await transport.request({
@@ -1156,39 +1227,60 @@ class RuntimeApiServer {
1156
1227
  break;
1157
1228
  }
1158
1229
  case "Update": {
1230
+ const dry = msg.dry;
1159
1231
  this.logCommand("Update", env, {
1160
1232
  nodes: msg.payload.def.nodes?.length ?? 0,
1161
1233
  edges: msg.payload.def.edges?.length ?? 0,
1234
+ dry: !!dry,
1162
1235
  });
1163
- await this.runtimeApi.update(msg.payload.def);
1236
+ await this.runtimeApi.update(msg.payload.def, { dry });
1164
1237
  ack();
1165
1238
  break;
1166
1239
  }
1167
1240
  case "SetEnvironment": {
1168
- this.logCommand("SetEnvironment", env);
1241
+ const dry = msg.dry;
1242
+ this.logCommand("SetEnvironment", env, dry ? { dry: true } : undefined);
1169
1243
  this.runtimeApi.setEnvironment(msg.payload.environment, {
1170
1244
  merge: Boolean(msg.payload.merge),
1245
+ dry,
1171
1246
  });
1172
1247
  ack();
1173
1248
  break;
1174
1249
  }
1175
1250
  case "SetInputs": {
1251
+ const dry = msg.dry;
1176
1252
  this.logCommand("SetInputs", env, {
1177
1253
  nodeId: msg.payload.nodeId,
1178
1254
  keys: Object.keys(msg.payload.inputs || {}).join(","),
1255
+ dry: !!dry,
1179
1256
  });
1180
1257
  const nodeId = msg.payload.nodeId;
1181
1258
  const inputs = msg.payload.inputs;
1182
- this.runtimeApi.setInputs(nodeId, inputs);
1259
+ this.runtimeApi.setInputs(nodeId, inputs, { dry });
1260
+ ack();
1261
+ break;
1262
+ }
1263
+ case "CopyOutputs": {
1264
+ const dry = msg.dry;
1265
+ this.logCommand("CopyOutputs", env, {
1266
+ fromNodeId: msg.payload.fromNodeId,
1267
+ toNodeId: msg.payload.toNodeId,
1268
+ dry: !!dry,
1269
+ });
1270
+ this.runtimeApi.copyOutputs(msg.payload.fromNodeId, msg.payload.toNodeId, { dry });
1183
1271
  ack();
1184
1272
  break;
1185
1273
  }
1186
1274
  case "TriggerExternal": {
1275
+ const dry = msg.dry;
1187
1276
  this.logCommand("TriggerExternal", env, {
1188
1277
  nodeId: msg.payload.nodeId,
1189
1278
  event: summarize(msg.payload.event),
1279
+ dry: !!dry,
1280
+ });
1281
+ this.runtimeApi.triggerExternal(msg.payload.nodeId, msg.payload.event, {
1282
+ dry,
1190
1283
  });
1191
- this.runtimeApi.triggerExternal(msg.payload.nodeId, msg.payload.event);
1192
1284
  ack();
1193
1285
  break;
1194
1286
  }