wao 0.22.1 → 0.22.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/cjs/hb.js +85 -91
- package/cjs/test.js +6 -0
- package/cjs/workspace/package.json +1 -1
- package/cjs/workspace/test/hyperbeam.js +30 -0
- package/esm/hb.js +19 -23
- package/esm/test.js +2 -1
- package/esm/workspace/package.json +1 -1
- package/esm/workspace/test/hyperbeam.js +30 -0
- package/package.json +1 -1
package/cjs/hb.js
CHANGED
|
@@ -509,23 +509,25 @@ var HB = /*#__PURE__*/function () {
|
|
|
509
509
|
}, {
|
|
510
510
|
key: "compute",
|
|
511
511
|
value: function () {
|
|
512
|
-
var _compute = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee16(
|
|
512
|
+
var _compute = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee16(_ref5) {
|
|
513
|
+
var pid, slot;
|
|
513
514
|
return _regeneratorRuntime().wrap(function _callee16$(_context16) {
|
|
514
515
|
while (1) switch (_context16.prev = _context16.next) {
|
|
515
516
|
case 0:
|
|
516
|
-
|
|
517
|
+
pid = _ref5.pid, slot = _ref5.slot;
|
|
518
|
+
_context16.next = 3;
|
|
517
519
|
return fetch("".concat(this.url, "/").concat(pid, "/compute/serialize~json@1.0?slot=").concat(slot)).then(function (r) {
|
|
518
520
|
return r.json();
|
|
519
521
|
});
|
|
520
|
-
case 2:
|
|
521
|
-
return _context16.abrupt("return", _context16.sent);
|
|
522
522
|
case 3:
|
|
523
|
+
return _context16.abrupt("return", _context16.sent);
|
|
524
|
+
case 4:
|
|
523
525
|
case "end":
|
|
524
526
|
return _context16.stop();
|
|
525
527
|
}
|
|
526
528
|
}, _callee16, this);
|
|
527
529
|
}));
|
|
528
|
-
function compute(_x15
|
|
530
|
+
function compute(_x15) {
|
|
529
531
|
return _compute.apply(this, arguments);
|
|
530
532
|
}
|
|
531
533
|
return compute;
|
|
@@ -533,23 +535,27 @@ var HB = /*#__PURE__*/function () {
|
|
|
533
535
|
}, {
|
|
534
536
|
key: "computeLegacy",
|
|
535
537
|
value: function () {
|
|
536
|
-
var _computeLegacy = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee17(
|
|
537
|
-
var json;
|
|
538
|
+
var _computeLegacy = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee17(_ref6) {
|
|
539
|
+
var pid, slot, json;
|
|
538
540
|
return _regeneratorRuntime().wrap(function _callee17$(_context17) {
|
|
539
541
|
while (1) switch (_context17.prev = _context17.next) {
|
|
540
542
|
case 0:
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
543
|
+
pid = _ref6.pid, slot = _ref6.slot;
|
|
544
|
+
_context17.next = 3;
|
|
545
|
+
return this.compute({
|
|
546
|
+
pid: pid,
|
|
547
|
+
slot: slot
|
|
548
|
+
});
|
|
549
|
+
case 3:
|
|
544
550
|
json = _context17.sent;
|
|
545
551
|
return _context17.abrupt("return", JSON.parse(json.results.json.body));
|
|
546
|
-
case
|
|
552
|
+
case 5:
|
|
547
553
|
case "end":
|
|
548
554
|
return _context17.stop();
|
|
549
555
|
}
|
|
550
556
|
}, _callee17, this);
|
|
551
557
|
}));
|
|
552
|
-
function computeLegacy(
|
|
558
|
+
function computeLegacy(_x16) {
|
|
553
559
|
return _computeLegacy.apply(this, arguments);
|
|
554
560
|
}
|
|
555
561
|
return computeLegacy;
|
|
@@ -558,11 +564,9 @@ var HB = /*#__PURE__*/function () {
|
|
|
558
564
|
key: "spawn",
|
|
559
565
|
value: function () {
|
|
560
566
|
var _spawn = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {
|
|
561
|
-
var _this$scheduler
|
|
567
|
+
var _this$scheduler;
|
|
562
568
|
var tags,
|
|
563
569
|
addr,
|
|
564
|
-
spawned,
|
|
565
|
-
pid,
|
|
566
570
|
res,
|
|
567
571
|
_args18 = arguments;
|
|
568
572
|
return _regeneratorRuntime().wrap(function _callee18$(_context18) {
|
|
@@ -587,19 +591,12 @@ var HB = /*#__PURE__*/function () {
|
|
|
587
591
|
"execution-device": "wao@1.0"
|
|
588
592
|
}));
|
|
589
593
|
case 7:
|
|
590
|
-
spawned = _context18.sent;
|
|
591
|
-
pid = spawned.headers.get("process");
|
|
592
|
-
(_this$pid = this.pid) !== null && _this$pid !== void 0 ? _this$pid : this.pid = pid;
|
|
593
|
-
_context18.next = 12;
|
|
594
|
-
return this.compute(pid, 0);
|
|
595
|
-
case 12:
|
|
596
594
|
res = _context18.sent;
|
|
597
595
|
return _context18.abrupt("return", {
|
|
598
|
-
|
|
599
|
-
pid:
|
|
600
|
-
res: res
|
|
596
|
+
res: res,
|
|
597
|
+
pid: res.headers.get("process")
|
|
601
598
|
});
|
|
602
|
-
case
|
|
599
|
+
case 9:
|
|
603
600
|
case "end":
|
|
604
601
|
return _context18.stop();
|
|
605
602
|
}
|
|
@@ -613,40 +610,35 @@ var HB = /*#__PURE__*/function () {
|
|
|
613
610
|
}, {
|
|
614
611
|
key: "message",
|
|
615
612
|
value: function () {
|
|
616
|
-
var _message = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee19() {
|
|
617
|
-
var
|
|
618
|
-
pid,
|
|
619
|
-
slot,
|
|
620
|
-
scheduled,
|
|
621
|
-
res,
|
|
622
|
-
_args19 = arguments;
|
|
613
|
+
var _message = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee19(args) {
|
|
614
|
+
var pid, slot, res;
|
|
623
615
|
return _regeneratorRuntime().wrap(function _callee19$(_context19) {
|
|
624
616
|
while (1) switch (_context19.prev = _context19.next) {
|
|
625
617
|
case 0:
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
618
|
+
pid = args.pid;
|
|
619
|
+
_context19.next = 3;
|
|
620
|
+
return this.schedule(args);
|
|
621
|
+
case 3:
|
|
622
|
+
slot = _context19.sent;
|
|
623
|
+
_context19.next = 6;
|
|
624
|
+
return this.compute({
|
|
625
|
+
pid: pid,
|
|
626
|
+
slot: slot
|
|
627
|
+
});
|
|
628
|
+
case 6:
|
|
636
629
|
res = _context19.sent;
|
|
637
630
|
return _context19.abrupt("return", {
|
|
638
631
|
slot: slot,
|
|
639
632
|
pid: pid,
|
|
640
|
-
res: res
|
|
641
|
-
scheduled: scheduled
|
|
633
|
+
res: res
|
|
642
634
|
});
|
|
643
|
-
case
|
|
635
|
+
case 8:
|
|
644
636
|
case "end":
|
|
645
637
|
return _context19.stop();
|
|
646
638
|
}
|
|
647
639
|
}, _callee19, this);
|
|
648
640
|
}));
|
|
649
|
-
function message() {
|
|
641
|
+
function message(_x17) {
|
|
650
642
|
return _message.apply(this, arguments);
|
|
651
643
|
}
|
|
652
644
|
return message;
|
|
@@ -656,24 +648,22 @@ var HB = /*#__PURE__*/function () {
|
|
|
656
648
|
value: function () {
|
|
657
649
|
var _schedule = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee20() {
|
|
658
650
|
var _pid2, _scheduler;
|
|
659
|
-
var
|
|
651
|
+
var _ref7,
|
|
660
652
|
pid,
|
|
661
|
-
|
|
653
|
+
_ref7$tags,
|
|
662
654
|
tags,
|
|
663
655
|
data,
|
|
664
656
|
scheduler,
|
|
665
657
|
_tags,
|
|
666
658
|
res,
|
|
667
|
-
slot,
|
|
668
659
|
_args20 = arguments;
|
|
669
660
|
return _regeneratorRuntime().wrap(function _callee20$(_context20) {
|
|
670
661
|
while (1) switch (_context20.prev = _context20.next) {
|
|
671
662
|
case 0:
|
|
672
|
-
|
|
663
|
+
_ref7 = _args20.length > 0 && _args20[0] !== undefined ? _args20[0] : {}, pid = _ref7.pid, _ref7$tags = _ref7.tags, tags = _ref7$tags === void 0 ? {} : _ref7$tags, data = _ref7.data, scheduler = _ref7.scheduler;
|
|
673
664
|
(_pid2 = pid) !== null && _pid2 !== void 0 ? _pid2 : pid = this.pid;
|
|
674
665
|
(_scheduler = scheduler) !== null && _scheduler !== void 0 ? _scheduler : scheduler = this.scheduler;
|
|
675
666
|
_tags = (0, _ramda.mergeLeft)(tags, {
|
|
676
|
-
device: "process@1.0",
|
|
677
667
|
method: "POST",
|
|
678
668
|
path: "/".concat(pid, "/schedule"),
|
|
679
669
|
scheduler: scheduler,
|
|
@@ -685,13 +675,11 @@ var HB = /*#__PURE__*/function () {
|
|
|
685
675
|
return this.send(_tags);
|
|
686
676
|
case 7:
|
|
687
677
|
res = _context20.sent;
|
|
688
|
-
slot = res.headers.get("slot");
|
|
689
678
|
return _context20.abrupt("return", {
|
|
690
|
-
slot: slot,
|
|
691
|
-
res: res
|
|
692
|
-
pid: pid
|
|
679
|
+
slot: res.headers.get("slot"),
|
|
680
|
+
res: res
|
|
693
681
|
});
|
|
694
|
-
case
|
|
682
|
+
case 9:
|
|
695
683
|
case "end":
|
|
696
684
|
return _context20.stop();
|
|
697
685
|
}
|
|
@@ -706,7 +694,7 @@ var HB = /*#__PURE__*/function () {
|
|
|
706
694
|
key: "spawnAOS",
|
|
707
695
|
value: function () {
|
|
708
696
|
var _spawnAOS = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee21(image) {
|
|
709
|
-
var _this$scheduler2, _image, _this$image, _this$
|
|
697
|
+
var _this$scheduler2, _image, _this$image, _this$pid;
|
|
710
698
|
var addr, res, pid;
|
|
711
699
|
return _regeneratorRuntime().wrap(function _callee21$(_context21) {
|
|
712
700
|
while (1) switch (_context21.prev = _context21.next) {
|
|
@@ -764,15 +752,18 @@ var HB = /*#__PURE__*/function () {
|
|
|
764
752
|
case 18:
|
|
765
753
|
res = _context21.sent;
|
|
766
754
|
pid = res.headers.get("process");
|
|
767
|
-
(_this$
|
|
768
|
-
return _context21.abrupt("return",
|
|
755
|
+
(_this$pid = this.pid) !== null && _this$pid !== void 0 ? _this$pid : this.pid = pid;
|
|
756
|
+
return _context21.abrupt("return", {
|
|
757
|
+
pid: pid,
|
|
758
|
+
res: res
|
|
759
|
+
});
|
|
769
760
|
case 22:
|
|
770
761
|
case "end":
|
|
771
762
|
return _context21.stop();
|
|
772
763
|
}
|
|
773
764
|
}, _callee21, this);
|
|
774
765
|
}));
|
|
775
|
-
function spawnAOS(
|
|
766
|
+
function spawnAOS(_x18) {
|
|
776
767
|
return _spawnAOS.apply(this, arguments);
|
|
777
768
|
}
|
|
778
769
|
return spawnAOS;
|
|
@@ -864,8 +855,8 @@ var HB = /*#__PURE__*/function () {
|
|
|
864
855
|
value: function () {
|
|
865
856
|
var _messages = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee23() {
|
|
866
857
|
var _this2 = this;
|
|
867
|
-
var
|
|
868
|
-
|
|
858
|
+
var _ref8,
|
|
859
|
+
pid,
|
|
869
860
|
from,
|
|
870
861
|
to,
|
|
871
862
|
limit,
|
|
@@ -875,8 +866,8 @@ var HB = /*#__PURE__*/function () {
|
|
|
875
866
|
return _regeneratorRuntime().wrap(function _callee23$(_context23) {
|
|
876
867
|
while (1) switch (_context23.prev = _context23.next) {
|
|
877
868
|
case 0:
|
|
878
|
-
|
|
879
|
-
params = "target=".concat(
|
|
869
|
+
_ref8 = _args23.length > 0 && _args23[0] !== undefined ? _args23[0] : {}, pid = _ref8.pid, from = _ref8.from, to = _ref8.to, limit = _ref8.limit;
|
|
870
|
+
params = "target=".concat(pid);
|
|
880
871
|
if ((0, _ramda.isNotNil)(from)) params += "&from=".concat(from);
|
|
881
872
|
if ((0, _ramda.isNotNil)(to)) params += "&to=".concat(to);
|
|
882
873
|
params += "&accept=application/aos-2";
|
|
@@ -895,7 +886,7 @@ var HB = /*#__PURE__*/function () {
|
|
|
895
886
|
from2 = (0, _ramda.last)(res.edges).cursor + 1;
|
|
896
887
|
_context22.next = 3;
|
|
897
888
|
return _this2.message({
|
|
898
|
-
|
|
889
|
+
pid: pid,
|
|
899
890
|
from: from2,
|
|
900
891
|
to: to,
|
|
901
892
|
limit: limit
|
|
@@ -922,11 +913,11 @@ var HB = /*#__PURE__*/function () {
|
|
|
922
913
|
return messages;
|
|
923
914
|
}()
|
|
924
915
|
}, {
|
|
925
|
-
key: "
|
|
916
|
+
key: "spawnLegacy",
|
|
926
917
|
value: function () {
|
|
927
|
-
var
|
|
928
|
-
var
|
|
929
|
-
|
|
918
|
+
var _spawnLegacy = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee24() {
|
|
919
|
+
var _ref10,
|
|
920
|
+
_ref10$tags,
|
|
930
921
|
tags,
|
|
931
922
|
data,
|
|
932
923
|
res,
|
|
@@ -934,7 +925,7 @@ var HB = /*#__PURE__*/function () {
|
|
|
934
925
|
return _regeneratorRuntime().wrap(function _callee24$(_context24) {
|
|
935
926
|
while (1) switch (_context24.prev = _context24.next) {
|
|
936
927
|
case 0:
|
|
937
|
-
|
|
928
|
+
_ref10 = _args24.length > 0 && _args24[0] !== undefined ? _args24[0] : {}, _ref10$tags = _ref10.tags, tags = _ref10$tags === void 0 ? {} : _ref10$tags, data = _ref10.data;
|
|
938
929
|
tags = (0, _ramda.mergeLeft)(tags, {
|
|
939
930
|
data: data,
|
|
940
931
|
Type: "Process",
|
|
@@ -955,17 +946,20 @@ var HB = /*#__PURE__*/function () {
|
|
|
955
946
|
});
|
|
956
947
|
case 4:
|
|
957
948
|
res = _context24.sent;
|
|
958
|
-
return _context24.abrupt("return",
|
|
949
|
+
return _context24.abrupt("return", {
|
|
950
|
+
pid: res.process,
|
|
951
|
+
res: res
|
|
952
|
+
});
|
|
959
953
|
case 6:
|
|
960
954
|
case "end":
|
|
961
955
|
return _context24.stop();
|
|
962
956
|
}
|
|
963
957
|
}, _callee24, this);
|
|
964
958
|
}));
|
|
965
|
-
function
|
|
966
|
-
return
|
|
959
|
+
function spawnLegacy() {
|
|
960
|
+
return _spawnLegacy.apply(this, arguments);
|
|
967
961
|
}
|
|
968
|
-
return
|
|
962
|
+
return spawnLegacy;
|
|
969
963
|
}()
|
|
970
964
|
/*
|
|
971
965
|
async scheduleLegacy({ tags = {}, data, process, action = "Eval" } = {}) {
|
|
@@ -984,10 +978,10 @@ var HB = /*#__PURE__*/function () {
|
|
|
984
978
|
key: "dryrun",
|
|
985
979
|
value: (function () {
|
|
986
980
|
var _dryrun = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee25() {
|
|
987
|
-
var
|
|
988
|
-
|
|
981
|
+
var _ref11,
|
|
982
|
+
_ref11$tags,
|
|
989
983
|
tags,
|
|
990
|
-
|
|
984
|
+
pid,
|
|
991
985
|
action,
|
|
992
986
|
data,
|
|
993
987
|
json,
|
|
@@ -996,7 +990,7 @@ var HB = /*#__PURE__*/function () {
|
|
|
996
990
|
return _regeneratorRuntime().wrap(function _callee25$(_context25) {
|
|
997
991
|
while (1) switch (_context25.prev = _context25.next) {
|
|
998
992
|
case 0:
|
|
999
|
-
|
|
993
|
+
_ref11 = _args25.length > 0 && _args25[0] !== undefined ? _args25[0] : {}, _ref11$tags = _ref11.tags, tags = _ref11$tags === void 0 ? {} : _ref11$tags, pid = _ref11.pid, action = _ref11.action, data = _ref11.data;
|
|
1000
994
|
if (typeof action === "string") tags.Action = action;
|
|
1001
995
|
json = {
|
|
1002
996
|
Tags: (0, _utils.buildTags)(tags)
|
|
@@ -1006,7 +1000,7 @@ var HB = /*#__PURE__*/function () {
|
|
|
1006
1000
|
return this.send({
|
|
1007
1001
|
path: "/~relay@1.0/call",
|
|
1008
1002
|
"relay-method": "POST",
|
|
1009
|
-
"relay-path": "/dry-run?process-id=".concat(
|
|
1003
|
+
"relay-path": "/dry-run?process-id=".concat(pid),
|
|
1010
1004
|
"content-type": "application/json",
|
|
1011
1005
|
body: JSON.stringify(json)
|
|
1012
1006
|
});
|
|
@@ -1027,12 +1021,12 @@ var HB = /*#__PURE__*/function () {
|
|
|
1027
1021
|
}, {
|
|
1028
1022
|
key: "get",
|
|
1029
1023
|
value: function () {
|
|
1030
|
-
var _get = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee26(
|
|
1031
|
-
var device,
|
|
1024
|
+
var _get = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee26(_ref12) {
|
|
1025
|
+
var device, _ref12$path, path;
|
|
1032
1026
|
return _regeneratorRuntime().wrap(function _callee26$(_context26) {
|
|
1033
1027
|
while (1) switch (_context26.prev = _context26.next) {
|
|
1034
1028
|
case 0:
|
|
1035
|
-
device =
|
|
1029
|
+
device = _ref12.device, _ref12$path = _ref12.path, path = _ref12$path === void 0 ? "~meta@1.0/info" : _ref12$path;
|
|
1036
1030
|
_context26.next = 3;
|
|
1037
1031
|
return this.request({
|
|
1038
1032
|
device: device,
|
|
@@ -1047,7 +1041,7 @@ var HB = /*#__PURE__*/function () {
|
|
|
1047
1041
|
}
|
|
1048
1042
|
}, _callee26, this);
|
|
1049
1043
|
}));
|
|
1050
|
-
function get(
|
|
1044
|
+
function get(_x19) {
|
|
1051
1045
|
return _get.apply(this, arguments);
|
|
1052
1046
|
}
|
|
1053
1047
|
return get;
|
|
@@ -1055,12 +1049,12 @@ var HB = /*#__PURE__*/function () {
|
|
|
1055
1049
|
}, {
|
|
1056
1050
|
key: "post",
|
|
1057
1051
|
value: function () {
|
|
1058
|
-
var _post = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee27(
|
|
1059
|
-
var device, tags,
|
|
1052
|
+
var _post = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee27(_ref13) {
|
|
1053
|
+
var device, tags, _ref13$path, path;
|
|
1060
1054
|
return _regeneratorRuntime().wrap(function _callee27$(_context27) {
|
|
1061
1055
|
while (1) switch (_context27.prev = _context27.next) {
|
|
1062
1056
|
case 0:
|
|
1063
|
-
device =
|
|
1057
|
+
device = _ref13.device, tags = _ref13.tags, _ref13$path = _ref13.path, path = _ref13$path === void 0 ? "/schedule" : _ref13$path;
|
|
1064
1058
|
_context27.next = 3;
|
|
1065
1059
|
return this.request({
|
|
1066
1060
|
tags: tags,
|
|
@@ -1076,7 +1070,7 @@ var HB = /*#__PURE__*/function () {
|
|
|
1076
1070
|
}
|
|
1077
1071
|
}, _callee27, this);
|
|
1078
1072
|
}));
|
|
1079
|
-
function post(
|
|
1073
|
+
function post(_x20) {
|
|
1080
1074
|
return _post.apply(this, arguments);
|
|
1081
1075
|
}
|
|
1082
1076
|
return post;
|
|
@@ -1084,12 +1078,12 @@ var HB = /*#__PURE__*/function () {
|
|
|
1084
1078
|
}, {
|
|
1085
1079
|
key: "request",
|
|
1086
1080
|
value: function () {
|
|
1087
|
-
var _request = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee28(
|
|
1088
|
-
var device, tags,
|
|
1081
|
+
var _request = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee28(_ref14) {
|
|
1082
|
+
var device, tags, _ref14$method, method, _ref14$path, path, _tags;
|
|
1089
1083
|
return _regeneratorRuntime().wrap(function _callee28$(_context28) {
|
|
1090
1084
|
while (1) switch (_context28.prev = _context28.next) {
|
|
1091
1085
|
case 0:
|
|
1092
|
-
device =
|
|
1086
|
+
device = _ref14.device, tags = _ref14.tags, _ref14$method = _ref14.method, method = _ref14$method === void 0 ? "POST" : _ref14$method, _ref14$path = _ref14.path, path = _ref14$path === void 0 ? "/schedule" : _ref14$path;
|
|
1093
1087
|
_tags = (0, _ramda.mergeLeft)(tags, {
|
|
1094
1088
|
path: path,
|
|
1095
1089
|
method: method
|
|
@@ -1105,7 +1099,7 @@ var HB = /*#__PURE__*/function () {
|
|
|
1105
1099
|
}
|
|
1106
1100
|
}, _callee28, this);
|
|
1107
1101
|
}));
|
|
1108
|
-
function request(
|
|
1102
|
+
function request(_x21) {
|
|
1109
1103
|
return _request.apply(this, arguments);
|
|
1110
1104
|
}
|
|
1111
1105
|
return request;
|
package/cjs/test.js
CHANGED
|
@@ -103,6 +103,12 @@ Object.defineProperty(exports, "su", {
|
|
|
103
103
|
return _accounts.su;
|
|
104
104
|
}
|
|
105
105
|
});
|
|
106
|
+
Object.defineProperty(exports, "toAddr", {
|
|
107
|
+
enumerable: true,
|
|
108
|
+
get: function get() {
|
|
109
|
+
return _utils.toAddr;
|
|
110
|
+
}
|
|
111
|
+
});
|
|
106
112
|
Object.defineProperty(exports, "wait", {
|
|
107
113
|
enumerable: true,
|
|
108
114
|
get: function get() {
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import assert from "assert"
|
|
2
|
+
import { describe, it, before, after, beforeEach } from "node:test"
|
|
3
|
+
import { wait, toAddr } from "wao/test"
|
|
4
|
+
import { HyperBEAM, HB } from "wao"
|
|
5
|
+
import { resolve } from "path"
|
|
6
|
+
import { readFileSync } from "fs"
|
|
7
|
+
|
|
8
|
+
const cwd = "../../HyperBEAM"
|
|
9
|
+
const wallet = ".wallet.json"
|
|
10
|
+
|
|
11
|
+
describe("HyperBEAM", function () {
|
|
12
|
+
let hbeam, hb, jwk
|
|
13
|
+
|
|
14
|
+
before(async () => {
|
|
15
|
+
hbeam = new HyperBEAM({ cwd, wallet })
|
|
16
|
+
jwk = JSON.parse(
|
|
17
|
+
readFileSync(resolve(import.meta.dirname, cwd, wallet), "utf8")
|
|
18
|
+
)
|
|
19
|
+
await wait(5000)
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
beforeEach(async () => (hb = await new HB({}).init(jwk)))
|
|
23
|
+
|
|
24
|
+
after(async () => hbeam.kill())
|
|
25
|
+
|
|
26
|
+
it("should run a HyperBEAM node", async () => {
|
|
27
|
+
const info = await hb.meta.info()
|
|
28
|
+
assert.equal(info.address, toAddr(jwk.n))
|
|
29
|
+
})
|
|
30
|
+
})
|
package/esm/hb.js
CHANGED
|
@@ -136,21 +136,21 @@ class HB {
|
|
|
136
136
|
).then(r => r.json())
|
|
137
137
|
}
|
|
138
138
|
|
|
139
|
-
async compute(pid, slot) {
|
|
139
|
+
async compute({ pid, slot }) {
|
|
140
140
|
return await fetch(
|
|
141
141
|
`${this.url}/${pid}/compute/serialize~json@1.0?slot=${slot}`
|
|
142
142
|
).then(r => r.json())
|
|
143
143
|
}
|
|
144
144
|
|
|
145
|
-
async computeLegacy(pid, slot) {
|
|
146
|
-
const json = await this.compute(pid, slot)
|
|
145
|
+
async computeLegacy({ pid, slot }) {
|
|
146
|
+
const json = await this.compute({ pid, slot })
|
|
147
147
|
return JSON.parse(json.results.json.body)
|
|
148
148
|
}
|
|
149
149
|
|
|
150
150
|
async spawn(tags = {}) {
|
|
151
151
|
const addr = await this.meta.info({ key: "address" })
|
|
152
152
|
this.scheduler ??= addr
|
|
153
|
-
const
|
|
153
|
+
const res = await this.send(
|
|
154
154
|
mergeLeft(tags, {
|
|
155
155
|
device: "process@1.0",
|
|
156
156
|
path: "/schedule",
|
|
@@ -161,23 +161,20 @@ class HB {
|
|
|
161
161
|
"execution-device": "wao@1.0",
|
|
162
162
|
})
|
|
163
163
|
)
|
|
164
|
-
|
|
165
|
-
this.pid ??= pid
|
|
166
|
-
const res = await this.compute(pid, 0)
|
|
167
|
-
return { spawned: res, pid, res }
|
|
164
|
+
return { res, pid: res.headers.get("process") }
|
|
168
165
|
}
|
|
169
166
|
|
|
170
|
-
async message(
|
|
171
|
-
const
|
|
172
|
-
const
|
|
173
|
-
|
|
167
|
+
async message(args) {
|
|
168
|
+
const pid = args.pid
|
|
169
|
+
const slot = await this.schedule(args)
|
|
170
|
+
const res = await this.compute({ pid, slot })
|
|
171
|
+
return { slot, pid, res }
|
|
174
172
|
}
|
|
175
173
|
|
|
176
174
|
async schedule({ pid, tags = {}, data, scheduler } = {}) {
|
|
177
175
|
pid ??= this.pid
|
|
178
176
|
scheduler ??= this.scheduler
|
|
179
177
|
let _tags = mergeLeft(tags, {
|
|
180
|
-
device: "process@1.0",
|
|
181
178
|
method: "POST",
|
|
182
179
|
path: `/${pid}/schedule`,
|
|
183
180
|
scheduler,
|
|
@@ -186,8 +183,7 @@ class HB {
|
|
|
186
183
|
})
|
|
187
184
|
if (data) _tags.data = data
|
|
188
185
|
let res = await this.send(_tags)
|
|
189
|
-
|
|
190
|
-
return { slot, res, pid }
|
|
186
|
+
return { slot: res.headers.get("slot"), res }
|
|
191
187
|
}
|
|
192
188
|
|
|
193
189
|
async spawnAOS(image) {
|
|
@@ -220,7 +216,7 @@ class HB {
|
|
|
220
216
|
})
|
|
221
217
|
const pid = res.headers.get("process")
|
|
222
218
|
this.pid ??= pid
|
|
223
|
-
return pid
|
|
219
|
+
return { pid, res }
|
|
224
220
|
}
|
|
225
221
|
|
|
226
222
|
parseMetrics(txt) {
|
|
@@ -255,8 +251,8 @@ class HB {
|
|
|
255
251
|
return _metrics
|
|
256
252
|
}
|
|
257
253
|
|
|
258
|
-
async messages({
|
|
259
|
-
let params = `target=${
|
|
254
|
+
async messages({ pid, from, to, limit } = {}) {
|
|
255
|
+
let params = `target=${pid}`
|
|
260
256
|
if (isNotNil(from)) params += `&from=${from}`
|
|
261
257
|
if (isNotNil(to)) params += `&to=${to}`
|
|
262
258
|
params += `&accept=application/aos-2`
|
|
@@ -266,13 +262,13 @@ class HB {
|
|
|
266
262
|
if (res.page_info.has_next_page) {
|
|
267
263
|
res.next = async () => {
|
|
268
264
|
const from2 = last(res.edges).cursor + 1
|
|
269
|
-
return await this.message({
|
|
265
|
+
return await this.message({ pid, from: from2, to, limit })
|
|
270
266
|
}
|
|
271
267
|
}
|
|
272
268
|
return res
|
|
273
269
|
}
|
|
274
270
|
|
|
275
|
-
async
|
|
271
|
+
async spawnLegacy({ tags = {}, data } = {}) {
|
|
276
272
|
tags = mergeLeft(tags, {
|
|
277
273
|
data,
|
|
278
274
|
Type: "Process",
|
|
@@ -288,7 +284,7 @@ class HB {
|
|
|
288
284
|
"execution-device": "genesis-wasm@1.0",
|
|
289
285
|
})
|
|
290
286
|
const res = await this.post({ tags })
|
|
291
|
-
return res.process
|
|
287
|
+
return { pid: res.process, res }
|
|
292
288
|
}
|
|
293
289
|
|
|
294
290
|
/*
|
|
@@ -305,14 +301,14 @@ class HB {
|
|
|
305
301
|
}
|
|
306
302
|
*/
|
|
307
303
|
|
|
308
|
-
async dryrun({ tags = {},
|
|
304
|
+
async dryrun({ tags = {}, pid, action, data } = {}) {
|
|
309
305
|
if (typeof action === "string") tags.Action = action
|
|
310
306
|
let json = { Tags: buildTags(tags) }
|
|
311
307
|
if (data) json.Data = data
|
|
312
308
|
const res = await this.send({
|
|
313
309
|
path: "/~relay@1.0/call",
|
|
314
310
|
"relay-method": "POST",
|
|
315
|
-
"relay-path": `/dry-run?process-id=${
|
|
311
|
+
"relay-path": `/dry-run?process-id=${pid}`,
|
|
316
312
|
"content-type": "application/json",
|
|
317
313
|
body: JSON.stringify(json),
|
|
318
314
|
})
|
package/esm/test.js
CHANGED
|
@@ -6,7 +6,7 @@ import AO from "./tao.js"
|
|
|
6
6
|
import AR from "./tar.js"
|
|
7
7
|
import GQL from "./tgql.js"
|
|
8
8
|
import ArMem from "./armem.js"
|
|
9
|
-
import { dirname, wait } from "./utils.js"
|
|
9
|
+
import { toAddr, dirname, wait } from "./utils.js"
|
|
10
10
|
import { Testnet, Src, setup, ok, fail } from "./helpers.js"
|
|
11
11
|
import Server from "./server.js"
|
|
12
12
|
import Adaptor from "./adaptor.js"
|
|
@@ -18,6 +18,7 @@ const scheduler = "_GQ33BkPtZrqxA84vM8Zk-N2aO0toNNu_C-l-rawrBA"
|
|
|
18
18
|
const HyperBEAM = "./hyperbeam.js"
|
|
19
19
|
|
|
20
20
|
export {
|
|
21
|
+
toAddr,
|
|
21
22
|
wait,
|
|
22
23
|
HyperBEAM,
|
|
23
24
|
Adaptor,
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import assert from "assert"
|
|
2
|
+
import { describe, it, before, after, beforeEach } from "node:test"
|
|
3
|
+
import { wait, toAddr } from "wao/test"
|
|
4
|
+
import { HyperBEAM, HB } from "wao"
|
|
5
|
+
import { resolve } from "path"
|
|
6
|
+
import { readFileSync } from "fs"
|
|
7
|
+
|
|
8
|
+
const cwd = "../../HyperBEAM"
|
|
9
|
+
const wallet = ".wallet.json"
|
|
10
|
+
|
|
11
|
+
describe("HyperBEAM", function () {
|
|
12
|
+
let hbeam, hb, jwk
|
|
13
|
+
|
|
14
|
+
before(async () => {
|
|
15
|
+
hbeam = new HyperBEAM({ cwd, wallet })
|
|
16
|
+
jwk = JSON.parse(
|
|
17
|
+
readFileSync(resolve(import.meta.dirname, cwd, wallet), "utf8")
|
|
18
|
+
)
|
|
19
|
+
await wait(5000)
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
beforeEach(async () => (hb = await new HB({}).init(jwk)))
|
|
23
|
+
|
|
24
|
+
after(async () => hbeam.kill())
|
|
25
|
+
|
|
26
|
+
it("should run a HyperBEAM node", async () => {
|
|
27
|
+
const info = await hb.meta.info()
|
|
28
|
+
assert.equal(info.address, toAddr(jwk.n))
|
|
29
|
+
})
|
|
30
|
+
})
|