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