@bian-womp/spark-remote 0.3.0 → 0.3.2

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
@@ -557,9 +557,8 @@ async function createServerRuntimeAdapter(id, createRegistry, send, extensions)
557
557
  update: async (def, options) => {
558
558
  if (!graphRuntime)
559
559
  return;
560
- const wasPaused = graphRuntime.isPaused();
561
- if (options?.dry && !wasPaused)
562
- graphRuntime.pause();
560
+ // Use requestPause for dry mode to temporarily pause without affecting base run mode
561
+ const releasePause = options?.dry ? graphRuntime.requestPause() : null;
563
562
  try {
564
563
  graphRuntime.update(def, registry);
565
564
  send({
@@ -570,16 +569,14 @@ async function createServerRuntimeAdapter(id, createRegistry, send, extensions)
570
569
  });
571
570
  }
572
571
  finally {
573
- if (options?.dry && !wasPaused)
574
- graphRuntime.resume();
572
+ releasePause?.();
575
573
  }
576
574
  },
577
575
  setEnvironment: async (env, opts) => {
578
576
  if (!graphRuntime)
579
577
  return;
580
- const wasPaused = graphRuntime.isPaused();
581
- if (opts?.dry && !wasPaused)
582
- graphRuntime.pause();
578
+ // Use requestPause for dry mode to temporarily pause without affecting base run mode
579
+ const releasePause = opts?.dry ? graphRuntime.requestPause() : null;
583
580
  try {
584
581
  if (opts?.merge) {
585
582
  const current = graphRuntime.getEnvironment();
@@ -591,8 +588,7 @@ async function createServerRuntimeAdapter(id, createRegistry, send, extensions)
591
588
  }
592
589
  }
593
590
  finally {
594
- if (opts?.dry && !wasPaused)
595
- graphRuntime.resume();
591
+ releasePause?.();
596
592
  }
597
593
  },
598
594
  setInputs: (nodeId, inputs, options) => {
@@ -620,7 +616,7 @@ async function createServerRuntimeAdapter(id, createRegistry, send, extensions)
620
616
  engine = undefined;
621
617
  }
622
618
  // Create new engine using shared factory
623
- engine = new sparkGraph.UnifiedEngine(graphRuntime, opts?.runMode);
619
+ engine = new sparkGraph.LocalEngine(graphRuntime, opts?.runMode);
624
620
  engine.launch(opts?.invalidate);
625
621
  },
626
622
  setRunMode: (runMode) => {
@@ -769,13 +765,8 @@ class RemoteEngine {
769
765
  this.emit("stats", msg.payload);
770
766
  }
771
767
  }
772
- launch(invalidate, runMode) {
773
- this.transport.send({
774
- message: {
775
- type: "Launch",
776
- payload: { runMode, invalidate },
777
- },
778
- });
768
+ launch() {
769
+ throw new Error("RemoteEngine.launch() is not supported. Use GraphLifecycleApi.launch() instead.");
779
770
  }
780
771
  setRunMode(runMode) {
781
772
  this.transport.send({
@@ -1387,7 +1378,7 @@ class ServerCommandHandler {
1387
1378
  case "SetEnvironment": {
1388
1379
  const dry = msg.dry;
1389
1380
  this.logCommand("SetEnvironment", env, dry ? { dry: true } : undefined);
1390
- this.adapter.setEnvironment(msg.payload.environment, {
1381
+ await this.adapter.setEnvironment(msg.payload.environment, {
1391
1382
  merge: Boolean(msg.payload.merge),
1392
1383
  dry,
1393
1384
  });
@@ -1403,7 +1394,7 @@ class ServerCommandHandler {
1403
1394
  });
1404
1395
  const nodeId = msg.payload.nodeId;
1405
1396
  const inputs = decodeInputsFromTransport(msg.payload.inputs);
1406
- this.adapter.setInputs(nodeId, inputs, { dry });
1397
+ await this.adapter.setInputs(nodeId, inputs, { dry });
1407
1398
  ack();
1408
1399
  break;
1409
1400
  }
@@ -1414,7 +1405,7 @@ class ServerCommandHandler {
1414
1405
  toNodeId: msg.payload.toNodeId,
1415
1406
  dry: !!dry,
1416
1407
  });
1417
- this.adapter.copyOutputs(msg.payload.fromNodeId, msg.payload.toNodeId, {
1408
+ await this.adapter.copyOutputs(msg.payload.fromNodeId, msg.payload.toNodeId, {
1418
1409
  dry,
1419
1410
  });
1420
1411
  ack();
@@ -1427,7 +1418,7 @@ class ServerCommandHandler {
1427
1418
  event: summarize(msg.payload.event),
1428
1419
  dry: !!dry,
1429
1420
  });
1430
- this.adapter.triggerExternal(msg.payload.nodeId, msg.payload.event, {
1421
+ await this.adapter.triggerExternal(msg.payload.nodeId, msg.payload.event, {
1431
1422
  dry,
1432
1423
  });
1433
1424
  ack();
@@ -1441,14 +1432,14 @@ class ServerCommandHandler {
1441
1432
  runMode: launchPayload.runMode,
1442
1433
  invalidate: launchPayload.invalidate,
1443
1434
  });
1444
- this.adapter.launch(launchPayload);
1435
+ await this.adapter.launch(launchPayload);
1445
1436
  ack();
1446
1437
  break;
1447
1438
  }
1448
1439
  case "SetRunMode": {
1449
1440
  const setRunModePayload = msg.payload;
1450
1441
  this.logCommand("SetRunMode", env, setRunModePayload);
1451
- this.adapter.setRunMode(setRunModePayload.runMode);
1442
+ await this.adapter.setRunMode(setRunModePayload.runMode);
1452
1443
  ack();
1453
1444
  break;
1454
1445
  }
@@ -1470,7 +1461,7 @@ class ServerCommandHandler {
1470
1461
  case "CancelNodeRuns": {
1471
1462
  const cancelPayload = msg.payload;
1472
1463
  this.logCommand("CancelNodeRuns", env, cancelPayload);
1473
- this.adapter.cancelNodeRuns(cancelPayload.nodeIds);
1464
+ await this.adapter.cancelNodeRuns(cancelPayload.nodeIds);
1474
1465
  ack();
1475
1466
  break;
1476
1467
  }
@@ -1482,19 +1473,19 @@ class ServerCommandHandler {
1482
1473
  }
1483
1474
  case "Snapshot": {
1484
1475
  this.logCommand("Snapshot", env);
1485
- const snap = this.adapter.snapshot();
1476
+ const snap = await this.adapter.snapshot();
1486
1477
  ack({ snapshot: snap });
1487
1478
  break;
1488
1479
  }
1489
1480
  case "SnapshotFull": {
1490
1481
  this.logCommand("SnapshotFull", env);
1491
- const snap = this.adapter.snapshotFull();
1482
+ const snap = await this.adapter.snapshotFull();
1492
1483
  ack({ snapshot: snap });
1493
1484
  break;
1494
1485
  }
1495
1486
  case "GetEnvironment": {
1496
1487
  this.logCommand("GetEnvironment", env);
1497
- const environment = this.adapter.getEnvironment();
1488
+ const environment = await this.adapter.getEnvironment();
1498
1489
  ack({ environment });
1499
1490
  break;
1500
1491
  }
@@ -1516,7 +1507,7 @@ class ServerCommandHandler {
1516
1507
  }
1517
1508
  case "DescribeRegistry": {
1518
1509
  this.logCommand("DescribeRegistry", env);
1519
- const desc = this.adapter.describeRegistry();
1510
+ const desc = await this.adapter.describeRegistry();
1520
1511
  ack({ registry: desc });
1521
1512
  break;
1522
1513
  }
@@ -1527,13 +1518,13 @@ class ServerCommandHandler {
1527
1518
  break;
1528
1519
  }
1529
1520
  case "SetExtData": {
1530
- this.adapter.setExtData(msg.payload);
1521
+ await this.adapter.setExtData(msg.payload);
1531
1522
  ack();
1532
1523
  break;
1533
1524
  }
1534
1525
  case "Dispose": {
1535
1526
  this.logCommand("Dispose", env);
1536
- this.adapter.dispose();
1527
+ await this.adapter.dispose();
1537
1528
  ack();
1538
1529
  break;
1539
1530
  }