@bian-womp/spark-remote 0.3.19 → 0.3.21
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 +73 -2
- package/lib/cjs/index.cjs.map +1 -1
- package/lib/cjs/src/RemoteGraphLifecycleApi.d.ts +6 -1
- package/lib/cjs/src/RemoteGraphLifecycleApi.d.ts.map +1 -1
- package/lib/cjs/src/server/ServerCommandHandler.d.ts.map +1 -1
- package/lib/cjs/src/server/ServerRuntimeAdapter.d.ts.map +1 -1
- package/lib/esm/index.js +74 -3
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/src/RemoteGraphLifecycleApi.d.ts +6 -1
- package/lib/esm/src/RemoteGraphLifecycleApi.d.ts.map +1 -1
- package/lib/esm/src/server/ServerCommandHandler.d.ts.map +1 -1
- package/lib/esm/src/server/ServerRuntimeAdapter.d.ts.map +1 -1
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ServerCommandHandler.d.ts","sourceRoot":"","sources":["../../../../src/server/ServerCommandHandler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,QAAQ,EACR,OAAO,EACP,IAAI,EACJ,WAAW,EACX,UAAU,EACX,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAInE;;;GAGG;AACH,MAAM,MAAM,iBAAiB,GAAG,CAC9B,GAAG,EAAE,QAAQ,CAAC,OAAO,CAAC,EACtB,IAAI,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,KACtB,OAAO,CAAC,IAAI,CAAC,CAAC;AAEnB;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,CACzB,QAAQ,EAAE,QAAQ,CAAC;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,OAAO,EAAE,WAAW,CAAA;CAAE,CAAC,KACxD,IAAI,CAAC;AAEV,qBAAa,oBAAoB;IAI7B,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EAC7B,OAAO,CAAC,EAAE;QAChB,YAAY,CAAC,EAAE,YAAY,CAAC;QAC5B,UAAU,CAAC,EAAE,UAAU,CAAC;KACzB,YAAA;IAGH;;;OAGG;IACH,GAAG,CAAC,UAAU,EAAE,iBAAiB,GAAG,IAAI;IAIxC;;OAEG;IACG,aAAa,CACjB,GAAG,EAAE,QAAQ,CAAC,OAAO,CAAC,EACtB,GAAG,EAAE,CAAC,OAAO,CAAC,EAAE,IAAI,KAAK,IAAI,GAC5B,OAAO,CAAC,IAAI,CAAC;IAWhB;;OAEG;YACW,kBAAkB;IAgBhC;;OAEG;YACW,cAAc;IA2P5B;;OAEG;IACH,OAAO,CAAC,UAAU;IAuBlB;;;;OAIG;IACH,OAAO,CAAC,WAAW;CA+BpB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ServerRuntimeAdapter.d.ts","sourceRoot":"","sources":["../../../../src/server/ServerRuntimeAdapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,QAAQ,EACR,YAAY,EAIZ,eAAe,
|
|
1
|
+
{"version":3,"file":"ServerRuntimeAdapter.d.ts","sourceRoot":"","sources":["../../../../src/server/ServerRuntimeAdapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,QAAQ,EACR,YAAY,EAIZ,eAAe,EAGhB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACL,YAAY,EACZ,QAAQ,EACR,YAAY,EACZ,WAAW,EAGX,KAAK,iBAAiB,EACtB,KAAK,MAAM,EAKZ,MAAM,wBAAwB,CAAC;AAEhC;;;;;;;GAOG;AACH,MAAM,WAAW,oBACf,SAAQ,iBAAiB,EACvB,IAAI,CAAC,MAAM,EAAE,QAAQ,CAAC;IAExB,cAAc,CAAC,EAAE,MAAM,IAAI,CAAC;CAC7B;AAED,MAAM,WAAW,2BAA2B;IAC1C,QAAQ,EAAE,QAAQ,CAAC;IACnB,OAAO,EAAE,YAAY,CAAC;IACtB,YAAY,EAAE,YAAY,GAAG,SAAS,CAAC;IACvC,MAAM,EAAE,WAAW,GAAG,SAAS,CAAC;IAChC,OAAO,EAAE;QAAE,OAAO,CAAC,EAAE,eAAe,CAAA;KAAE,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAClE;AAED,MAAM,MAAM,6BAA6B,GAAG;KACzC,CAAC,IAAI,OAAO,CACX,MAAM,oBAAoB,EAC1B,iBAAiB,CAClB,CAAC,CAAC,EAAE,oBAAoB,CAAC,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,GACxD,CACE,QAAQ,EAAE,oBAAoB,CAAC,CAAC,CAAC,EACjC,OAAO,EAAE,2BAA2B,EACpC,GAAG,IAAI,EAAE,UAAU,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC,KACzC,UAAU,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC,GACxC,KAAK;CACV,CAAC;AAEF,wBAAsB,0BAA0B,CAC9C,EAAE,EAAE,MAAM,GAAG,SAAS,EACtB,cAAc,EAAE,CAAC,EAAE,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC,QAAQ,CAAC,EAClD,IAAI,EAAE,CAAC,CAAC,EAAE,QAAQ,CAAC,YAAY,CAAC,KAAK,IAAI,EACzC,UAAU,CAAC,EAAE,6BAA6B,GACzC,OAAO,CAAC,oBAAoB,CAAC,CAyZ/B"}
|
package/lib/esm/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { WebSocket } from 'ws';
|
|
2
|
-
import { GraphBuilder, parseJsonPath, setValueAtPathWithCreation, LocalEngine } from '@bian-womp/spark-graph';
|
|
2
|
+
import { GraphBuilder, buildValueConverter, convertSnapshot, parseJsonPath, setValueAtPathWithCreation, LocalEngine } from '@bian-womp/spark-graph';
|
|
3
3
|
|
|
4
4
|
class SeqGenerator {
|
|
5
5
|
constructor() {
|
|
@@ -518,6 +518,25 @@ async function createServerRuntimeAdapter(id, createRegistry, send, extensions)
|
|
|
518
518
|
});
|
|
519
519
|
await originalAdapter.setExtData(payload.extData || {});
|
|
520
520
|
},
|
|
521
|
+
convertSnapshot: async (converterConfig, options) => {
|
|
522
|
+
const snapshot = await originalAdapter.snapshotFull();
|
|
523
|
+
const converter = buildValueConverter(converterConfig);
|
|
524
|
+
const converted = convertSnapshot(snapshot, converter);
|
|
525
|
+
await originalAdapter.applySnapshotFull(converted, {
|
|
526
|
+
skipBuild: true,
|
|
527
|
+
});
|
|
528
|
+
return converted;
|
|
529
|
+
},
|
|
530
|
+
pause: async () => {
|
|
531
|
+
if (!graphRuntime)
|
|
532
|
+
return;
|
|
533
|
+
graphRuntime.pause();
|
|
534
|
+
},
|
|
535
|
+
resume: async () => {
|
|
536
|
+
if (!graphRuntime)
|
|
537
|
+
return;
|
|
538
|
+
graphRuntime.resume();
|
|
539
|
+
},
|
|
521
540
|
cancelNodeRuns: (nodeIds) => {
|
|
522
541
|
if (!graphRuntime)
|
|
523
542
|
return;
|
|
@@ -621,7 +640,7 @@ async function createServerRuntimeAdapter(id, createRegistry, send, extensions)
|
|
|
621
640
|
}
|
|
622
641
|
// Create new engine using shared factory
|
|
623
642
|
engine = new LocalEngine(graphRuntime, opts?.runMode);
|
|
624
|
-
engine.launch(opts?.invalidate);
|
|
643
|
+
engine.launch(opts?.invalidate, opts?.runMode, opts?.startPaused);
|
|
625
644
|
},
|
|
626
645
|
setRunMode: (runMode) => {
|
|
627
646
|
if (!engine)
|
|
@@ -694,6 +713,7 @@ async function createServerRuntimeAdapter(id, createRegistry, send, extensions)
|
|
|
694
713
|
snapshot: wrapMethod("snapshot", originalAdapter.snapshot),
|
|
695
714
|
snapshotFull: wrapMethod("snapshotFull", originalAdapter.snapshotFull),
|
|
696
715
|
applySnapshotFull: wrapMethod("applySnapshotFull", originalAdapter.applySnapshotFull),
|
|
716
|
+
convertSnapshot: wrapMethod("convertSnapshot", originalAdapter.convertSnapshot),
|
|
697
717
|
describeRegistry: wrapMethod("describeRegistry", originalAdapter.describeRegistry),
|
|
698
718
|
update: wrapMethod("update", originalAdapter.update),
|
|
699
719
|
setEnvironment: wrapMethod("setEnvironment", originalAdapter.setEnvironment),
|
|
@@ -701,6 +721,8 @@ async function createServerRuntimeAdapter(id, createRegistry, send, extensions)
|
|
|
701
721
|
commit: wrapMethod("commit", originalAdapter.commit),
|
|
702
722
|
undo: wrapMethod("undo", originalAdapter.undo),
|
|
703
723
|
redo: wrapMethod("redo", originalAdapter.redo),
|
|
724
|
+
pause: wrapMethod("pause", originalAdapter.pause),
|
|
725
|
+
resume: wrapMethod("resume", originalAdapter.resume),
|
|
704
726
|
launch: wrapMethod("launch", originalAdapter.launch),
|
|
705
727
|
// Engine methods
|
|
706
728
|
setInputs: wrapMethod("setInputs", originalAdapter.setInputs),
|
|
@@ -924,6 +946,23 @@ class RemoteGraphLifecycleApi {
|
|
|
924
946
|
},
|
|
925
947
|
});
|
|
926
948
|
}
|
|
949
|
+
async convertSnapshot(converterConfig, options) {
|
|
950
|
+
const transport = await this.ensureConnected();
|
|
951
|
+
const res = await transport.request({
|
|
952
|
+
message: {
|
|
953
|
+
type: "ConvertSnapshot",
|
|
954
|
+
payload: { converterConfig },
|
|
955
|
+
dry: options?.dry,
|
|
956
|
+
},
|
|
957
|
+
});
|
|
958
|
+
const payload = res?.message || {};
|
|
959
|
+
return (payload.snapshot || {
|
|
960
|
+
def: undefined,
|
|
961
|
+
environment: {},
|
|
962
|
+
inputs: {},
|
|
963
|
+
outputs: {},
|
|
964
|
+
});
|
|
965
|
+
}
|
|
927
966
|
async describeRegistry() {
|
|
928
967
|
const transport = await this.ensureConnected();
|
|
929
968
|
const res = await transport.request({
|
|
@@ -1012,6 +1051,18 @@ class RemoteGraphLifecycleApi {
|
|
|
1012
1051
|
const payload = res?.message || {};
|
|
1013
1052
|
return payload.success ?? false;
|
|
1014
1053
|
}
|
|
1054
|
+
async pause() {
|
|
1055
|
+
const transport = await this.ensureConnected();
|
|
1056
|
+
await transport.request({
|
|
1057
|
+
message: { type: "Pause" },
|
|
1058
|
+
});
|
|
1059
|
+
}
|
|
1060
|
+
async resume() {
|
|
1061
|
+
const transport = await this.ensureConnected();
|
|
1062
|
+
await transport.request({
|
|
1063
|
+
message: { type: "Resume" },
|
|
1064
|
+
});
|
|
1065
|
+
}
|
|
1015
1066
|
}
|
|
1016
1067
|
|
|
1017
1068
|
// Node-only transport using a UNIX domain socket.
|
|
@@ -1502,6 +1553,14 @@ class ServerCommandHandler {
|
|
|
1502
1553
|
ack();
|
|
1503
1554
|
break;
|
|
1504
1555
|
}
|
|
1556
|
+
case "ConvertSnapshot": {
|
|
1557
|
+
const converterConfig = msg.payload.converterConfig;
|
|
1558
|
+
const dry = msg.dry;
|
|
1559
|
+
this.logCommand("ConvertSnapshot", env, { dry });
|
|
1560
|
+
const converted = await this.adapter.convertSnapshot(converterConfig, { dry });
|
|
1561
|
+
ack({ snapshot: converted });
|
|
1562
|
+
break;
|
|
1563
|
+
}
|
|
1505
1564
|
case "Coerce": {
|
|
1506
1565
|
this.logCommand("Coerce", env, {
|
|
1507
1566
|
from: msg.payload.from,
|
|
@@ -1557,6 +1616,18 @@ class ServerCommandHandler {
|
|
|
1557
1616
|
ack({ success });
|
|
1558
1617
|
break;
|
|
1559
1618
|
}
|
|
1619
|
+
case "Pause": {
|
|
1620
|
+
this.logCommand("Pause", env);
|
|
1621
|
+
await this.adapter.pause();
|
|
1622
|
+
ack();
|
|
1623
|
+
break;
|
|
1624
|
+
}
|
|
1625
|
+
case "Resume": {
|
|
1626
|
+
this.logCommand("Resume", env);
|
|
1627
|
+
await this.adapter.resume();
|
|
1628
|
+
ack();
|
|
1629
|
+
break;
|
|
1630
|
+
}
|
|
1560
1631
|
default: {
|
|
1561
1632
|
this.logCommand("Unknown type", env);
|
|
1562
1633
|
ack();
|
|
@@ -1590,7 +1661,7 @@ class ServerCommandHandler {
|
|
|
1590
1661
|
* not node execution errors.
|
|
1591
1662
|
*/
|
|
1592
1663
|
handleError(env, err) {
|
|
1593
|
-
const errorMessage = `error handling command: ${String(err)}`;
|
|
1664
|
+
const errorMessage = `error handling command(${env.message.type}): ${String(err)}`;
|
|
1594
1665
|
if (this.options?.logHandler) {
|
|
1595
1666
|
this.options.logHandler("error", errorMessage, {
|
|
1596
1667
|
seq: env.seq,
|