pinokiod 1.2.21 → 1.2.22
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/kernel/api/index.js +46 -36
- package/package.json +1 -1
package/kernel/api/index.js
CHANGED
|
@@ -575,6 +575,50 @@ class Api {
|
|
|
575
575
|
rpc.next = null
|
|
576
576
|
}
|
|
577
577
|
|
|
578
|
+
if (rpc.hasOwnProperty("when")) {
|
|
579
|
+
console.log("rpc.when", { rpc })
|
|
580
|
+
// if rpc.when is false, don't run this and go to the next step
|
|
581
|
+
if (!rpc.when) {
|
|
582
|
+
if (typeof rpc.next === "undefined" || rpc.next === null) {
|
|
583
|
+
// last call
|
|
584
|
+
if (script.daemon) {
|
|
585
|
+
this.ondata({
|
|
586
|
+
id: request.path,
|
|
587
|
+
type: "start",
|
|
588
|
+
data: {
|
|
589
|
+
title: "Started",
|
|
590
|
+
description: "All scripts finished running. Running in daemon mode..."
|
|
591
|
+
}
|
|
592
|
+
})
|
|
593
|
+
} else {
|
|
594
|
+
// no next rpc to execute. Finish
|
|
595
|
+
this.kernel.memory.local[request.path] = {}
|
|
596
|
+
this.ondata({
|
|
597
|
+
id: request.path,
|
|
598
|
+
type: "event",
|
|
599
|
+
data: "stop",
|
|
600
|
+
rpc,
|
|
601
|
+
rawrpc
|
|
602
|
+
})
|
|
603
|
+
await this.stop({
|
|
604
|
+
params: {
|
|
605
|
+
uri: request.path
|
|
606
|
+
}
|
|
607
|
+
})
|
|
608
|
+
}
|
|
609
|
+
return
|
|
610
|
+
} else {
|
|
611
|
+
// still ongoing
|
|
612
|
+
let next_rpc = script.run[rpc.next]
|
|
613
|
+
console.log("NEXT RPC", next_rpc, i, rpc.next)
|
|
614
|
+
if (next_rpc) {
|
|
615
|
+
return { request, rawrpc: next_rpc, input: null, step: rpc.next, total: script.run.length }
|
|
616
|
+
}
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
|
|
578
622
|
try {
|
|
579
623
|
this.ondata({
|
|
580
624
|
id: request.path,
|
|
@@ -724,42 +768,8 @@ class Api {
|
|
|
724
768
|
|
|
725
769
|
} else {
|
|
726
770
|
// still going
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
let next_rpc = script.run[i]
|
|
730
|
-
console.log("NEXT RPC", next_rpc)
|
|
731
|
-
if (next_rpc) {
|
|
732
|
-
return { request, rawrpc: next_rpc, input: result, step: i, total: script.run.length }
|
|
733
|
-
}
|
|
734
|
-
}
|
|
735
|
-
|
|
736
|
-
// if all the steps are null, end.
|
|
737
|
-
if (script.daemon) {
|
|
738
|
-
this.ondata({
|
|
739
|
-
id: request.path,
|
|
740
|
-
type: "start",
|
|
741
|
-
data: {
|
|
742
|
-
title: "Started",
|
|
743
|
-
description: "All scripts finished running. Running in daemon mode..."
|
|
744
|
-
}
|
|
745
|
-
})
|
|
746
|
-
} else {
|
|
747
|
-
// no next rpc to execute. Finish
|
|
748
|
-
this.kernel.memory.local[request.path] = {}
|
|
749
|
-
this.ondata({
|
|
750
|
-
id: request.path,
|
|
751
|
-
type: "event",
|
|
752
|
-
data: "stop",
|
|
753
|
-
rpc,
|
|
754
|
-
rawrpc
|
|
755
|
-
})
|
|
756
|
-
await this.stop({
|
|
757
|
-
params: {
|
|
758
|
-
uri: request.path
|
|
759
|
-
}
|
|
760
|
-
})
|
|
761
|
-
}
|
|
762
|
-
//return { request, rawrpc: next_rpc, input: result, step: rpc.next, total: script.run.length }
|
|
771
|
+
let next_rpc = script.run[rpc.next]
|
|
772
|
+
return { request, rawrpc: next_rpc, input: result, step: rpc.next, total: script.run.length }
|
|
763
773
|
}
|
|
764
774
|
|
|
765
775
|
} catch (e) {
|