pinokiod 1.2.20 → 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 +45 -3
- package/package.json +1 -1
package/kernel/api/index.js
CHANGED
|
@@ -527,6 +527,7 @@ class Api {
|
|
|
527
527
|
// replace {{{ }}} with {{ }}
|
|
528
528
|
rpc = this.kernel.template.flatten(rpc)
|
|
529
529
|
|
|
530
|
+
|
|
530
531
|
// 6. rpc must have method names
|
|
531
532
|
if (rpc.method) {
|
|
532
533
|
|
|
@@ -574,6 +575,50 @@ class Api {
|
|
|
574
575
|
rpc.next = null
|
|
575
576
|
}
|
|
576
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
|
+
|
|
577
622
|
try {
|
|
578
623
|
this.ondata({
|
|
579
624
|
id: request.path,
|
|
@@ -809,9 +854,6 @@ class Api {
|
|
|
809
854
|
let concurrency = (rawrpc.queue ? 1 : 10);
|
|
810
855
|
|
|
811
856
|
// queue_id
|
|
812
|
-
if (rawrpc.queue) {
|
|
813
|
-
} else {
|
|
814
|
-
}
|
|
815
857
|
|
|
816
858
|
let queue_id
|
|
817
859
|
if (rawrpc.uri) {
|