wao 0.10.4 → 0.10.5
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/cjs/server.js +80 -32
- package/esm/server.js +12 -0
- package/package.json +1 -1
package/cjs/server.js
CHANGED
|
@@ -631,15 +631,63 @@ var Server = /*#__PURE__*/function () {
|
|
|
631
631
|
return _ref15.apply(this, arguments);
|
|
632
632
|
};
|
|
633
633
|
}());
|
|
634
|
-
app.
|
|
634
|
+
app.get("/state/:pid", /*#__PURE__*/function () {
|
|
635
635
|
var _ref16 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee15(req, res) {
|
|
636
|
-
var
|
|
636
|
+
var _yield$_this4$mem$env, _this4$mem$env$pid;
|
|
637
|
+
var pid, memory;
|
|
637
638
|
return _regeneratorRuntime().wrap(function _callee15$(_context15) {
|
|
638
639
|
while (1) switch (_context15.prev = _context15.next) {
|
|
640
|
+
case 0:
|
|
641
|
+
pid = req.params.pid;
|
|
642
|
+
_context15.next = 3;
|
|
643
|
+
return (_this4$mem$env$pid = _this4.mem.env[pid]) === null || _this4$mem$env$pid === void 0 ? void 0 : _this4$mem$env$pid.memory;
|
|
644
|
+
case 3:
|
|
645
|
+
_context15.t1 = _yield$_this4$mem$env = _context15.sent;
|
|
646
|
+
_context15.t0 = _context15.t1 !== null;
|
|
647
|
+
if (!_context15.t0) {
|
|
648
|
+
_context15.next = 7;
|
|
649
|
+
break;
|
|
650
|
+
}
|
|
651
|
+
_context15.t0 = _yield$_this4$mem$env !== void 0;
|
|
652
|
+
case 7:
|
|
653
|
+
if (!_context15.t0) {
|
|
654
|
+
_context15.next = 11;
|
|
655
|
+
break;
|
|
656
|
+
}
|
|
657
|
+
_context15.t2 = _yield$_this4$mem$env;
|
|
658
|
+
_context15.next = 12;
|
|
659
|
+
break;
|
|
660
|
+
case 11:
|
|
661
|
+
_context15.t2 = null;
|
|
662
|
+
case 12:
|
|
663
|
+
memory = _context15.t2;
|
|
664
|
+
if (!memory) {
|
|
665
|
+
res.status(404);
|
|
666
|
+
res.json({
|
|
667
|
+
error: "TransactionNotFound: Process ".concat(pid, " was not found on gateway")
|
|
668
|
+
});
|
|
669
|
+
} else {
|
|
670
|
+
res.send(Buffer.from(memory));
|
|
671
|
+
}
|
|
672
|
+
case 14:
|
|
673
|
+
case "end":
|
|
674
|
+
return _context15.stop();
|
|
675
|
+
}
|
|
676
|
+
}, _callee15);
|
|
677
|
+
}));
|
|
678
|
+
return function (_x28, _x29) {
|
|
679
|
+
return _ref16.apply(this, arguments);
|
|
680
|
+
};
|
|
681
|
+
}());
|
|
682
|
+
app.post("/dry-run", /*#__PURE__*/function () {
|
|
683
|
+
var _ref17 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee16(req, res) {
|
|
684
|
+
var process, _req$body2, id, owner, tags, data, res2;
|
|
685
|
+
return _regeneratorRuntime().wrap(function _callee16$(_context16) {
|
|
686
|
+
while (1) switch (_context16.prev = _context16.next) {
|
|
639
687
|
case 0:
|
|
640
688
|
process = req.query["process-id"];
|
|
641
689
|
_req$body2 = req.body, id = _req$body2.Id, owner = _req$body2.Owner, tags = _req$body2.Tags, data = _req$body2.Data;
|
|
642
|
-
|
|
690
|
+
_context16.next = 4;
|
|
643
691
|
return _this4.dryrun({
|
|
644
692
|
id: id,
|
|
645
693
|
owner: owner,
|
|
@@ -648,7 +696,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
648
696
|
process: process
|
|
649
697
|
});
|
|
650
698
|
case 4:
|
|
651
|
-
res2 =
|
|
699
|
+
res2 = _context16.sent;
|
|
652
700
|
if (!res2) {
|
|
653
701
|
res.status(400);
|
|
654
702
|
res.json({
|
|
@@ -660,40 +708,40 @@ var Server = /*#__PURE__*/function () {
|
|
|
660
708
|
}
|
|
661
709
|
case 6:
|
|
662
710
|
case "end":
|
|
663
|
-
return
|
|
711
|
+
return _context16.stop();
|
|
664
712
|
}
|
|
665
|
-
},
|
|
713
|
+
}, _callee16);
|
|
666
714
|
}));
|
|
667
|
-
return function (
|
|
668
|
-
return
|
|
715
|
+
return function (_x30, _x31) {
|
|
716
|
+
return _ref17.apply(this, arguments);
|
|
669
717
|
};
|
|
670
718
|
}());
|
|
671
719
|
app.get("/results/:pid", /*#__PURE__*/function () {
|
|
672
|
-
var
|
|
673
|
-
var _this4$mem$env$pid$re, _this4$mem$env$
|
|
720
|
+
var _ref18 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee17(req, res) {
|
|
721
|
+
var _this4$mem$env$pid$re, _this4$mem$env$pid2;
|
|
674
722
|
var pid, _req$query, _req$query$from, from, _req$query$to, to, _req$query$sort, sort, _req$query$limit, limit, results, _res, i, count, started, _iterator, _step, v, _this4$mem$msgs$v;
|
|
675
|
-
return _regeneratorRuntime().wrap(function
|
|
676
|
-
while (1) switch (
|
|
723
|
+
return _regeneratorRuntime().wrap(function _callee17$(_context17) {
|
|
724
|
+
while (1) switch (_context17.prev = _context17.next) {
|
|
677
725
|
case 0:
|
|
678
726
|
pid = req.params.pid;
|
|
679
727
|
_req$query = req.query, _req$query$from = _req$query.from, from = _req$query$from === void 0 ? null : _req$query$from, _req$query$to = _req$query.to, to = _req$query$to === void 0 ? null : _req$query$to, _req$query$sort = _req$query.sort, sort = _req$query$sort === void 0 ? "ASC" : _req$query$sort, _req$query$limit = _req$query.limit, limit = _req$query$limit === void 0 ? 25 : _req$query$limit;
|
|
680
|
-
results = (_this4$mem$env$pid$re = (_this4$mem$env$
|
|
728
|
+
results = (_this4$mem$env$pid$re = (_this4$mem$env$pid2 = _this4.mem.env[pid]) === null || _this4$mem$env$pid2 === void 0 ? void 0 : _this4$mem$env$pid2.results) !== null && _this4$mem$env$pid$re !== void 0 ? _this4$mem$env$pid$re : [];
|
|
681
729
|
if (sort.toLowerCase() === "desc") results = (0, _ramda.reverse)(results);
|
|
682
730
|
_res = [];
|
|
683
731
|
i = 1;
|
|
684
732
|
count = 0;
|
|
685
733
|
started = (0, _ramda.isNil)(from);
|
|
686
734
|
_iterator = _createForOfIteratorHelper(results);
|
|
687
|
-
|
|
735
|
+
_context17.prev = 9;
|
|
688
736
|
_iterator.s();
|
|
689
737
|
case 11:
|
|
690
738
|
if ((_step = _iterator.n()).done) {
|
|
691
|
-
|
|
739
|
+
_context17.next = 26;
|
|
692
740
|
break;
|
|
693
741
|
}
|
|
694
742
|
v = _step.value;
|
|
695
743
|
if (!started) {
|
|
696
|
-
|
|
744
|
+
_context17.next = 22;
|
|
697
745
|
break;
|
|
698
746
|
}
|
|
699
747
|
_res.push({
|
|
@@ -702,49 +750,49 @@ var Server = /*#__PURE__*/function () {
|
|
|
702
750
|
});
|
|
703
751
|
count++;
|
|
704
752
|
if (!(!(0, _ramda.isNil)(to) && v === to)) {
|
|
705
|
-
|
|
753
|
+
_context17.next = 18;
|
|
706
754
|
break;
|
|
707
755
|
}
|
|
708
|
-
return
|
|
756
|
+
return _context17.abrupt("break", 26);
|
|
709
757
|
case 18:
|
|
710
758
|
if (!(limit <= count)) {
|
|
711
|
-
|
|
759
|
+
_context17.next = 20;
|
|
712
760
|
break;
|
|
713
761
|
}
|
|
714
|
-
return
|
|
762
|
+
return _context17.abrupt("break", 26);
|
|
715
763
|
case 20:
|
|
716
|
-
|
|
764
|
+
_context17.next = 23;
|
|
717
765
|
break;
|
|
718
766
|
case 22:
|
|
719
767
|
if (from === v) started = true;
|
|
720
768
|
case 23:
|
|
721
769
|
i++;
|
|
722
770
|
case 24:
|
|
723
|
-
|
|
771
|
+
_context17.next = 11;
|
|
724
772
|
break;
|
|
725
773
|
case 26:
|
|
726
|
-
|
|
774
|
+
_context17.next = 31;
|
|
727
775
|
break;
|
|
728
776
|
case 28:
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
_iterator.e(
|
|
777
|
+
_context17.prev = 28;
|
|
778
|
+
_context17.t0 = _context17["catch"](9);
|
|
779
|
+
_iterator.e(_context17.t0);
|
|
732
780
|
case 31:
|
|
733
|
-
|
|
781
|
+
_context17.prev = 31;
|
|
734
782
|
_iterator.f();
|
|
735
|
-
return
|
|
783
|
+
return _context17.finish(31);
|
|
736
784
|
case 34:
|
|
737
785
|
res.json({
|
|
738
786
|
edges: _res
|
|
739
787
|
});
|
|
740
788
|
case 35:
|
|
741
789
|
case "end":
|
|
742
|
-
return
|
|
790
|
+
return _context17.stop();
|
|
743
791
|
}
|
|
744
|
-
},
|
|
792
|
+
}, _callee17, null, [[9, 28, 31, 34]]);
|
|
745
793
|
}));
|
|
746
|
-
return function (
|
|
747
|
-
return
|
|
794
|
+
return function (_x32, _x33) {
|
|
795
|
+
return _ref18.apply(this, arguments);
|
|
748
796
|
};
|
|
749
797
|
}());
|
|
750
798
|
var server = app.listen(this.ports.cu, function () {
|
package/esm/server.js
CHANGED
|
@@ -271,6 +271,18 @@ class Server {
|
|
|
271
271
|
})
|
|
272
272
|
res.json(res2)
|
|
273
273
|
})
|
|
274
|
+
app.get("/state/:pid", async (req, res) => {
|
|
275
|
+
const pid = req.params.pid
|
|
276
|
+
const memory = (await this.mem.env[pid]?.memory) ?? null
|
|
277
|
+
if (!memory) {
|
|
278
|
+
res.status(404)
|
|
279
|
+
res.json({
|
|
280
|
+
error: `TransactionNotFound: Process ${pid} was not found on gateway`,
|
|
281
|
+
})
|
|
282
|
+
} else {
|
|
283
|
+
res.send(Buffer.from(memory))
|
|
284
|
+
}
|
|
285
|
+
})
|
|
274
286
|
app.post("/dry-run", async (req, res) => {
|
|
275
287
|
const process = req.query["process-id"]
|
|
276
288
|
const { Id: id, Owner: owner, Tags: tags, Data: data } = req.body
|