wao 0.10.4 → 0.10.6

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.
@@ -11,8 +11,7 @@ var _base64url = _interopRequireDefault(require("base64url"));
11
11
  var _utils = require("./utils.js");
12
12
  var _weavedrive = _interopRequireDefault(require("./weavedrive.js"));
13
13
  var _ramda = require("ramda");
14
- var _WarpArBundles$defaul,
15
- _this = void 0;
14
+ var _WarpArBundles$defaul;
16
15
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
17
16
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
18
17
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
@@ -425,7 +424,6 @@ var _default = exports["default"] = function _default() {
425
424
  memory: memory,
426
425
  owner: owner,
427
426
  height: 0,
428
- //res: { [id]: res },
429
427
  results: [id]
430
428
  };
431
429
  if (!memory) {
@@ -507,7 +505,6 @@ var _default = exports["default"] = function _default() {
507
505
  res = _context3.sent;
508
506
  p.memory = res.Memory;
509
507
  delete res.Memory;
510
- //p.res[id] = res
511
508
  _context3.next = 103;
512
509
  break;
513
510
  case 102:
@@ -746,7 +743,6 @@ var _default = exports["default"] = function _default() {
746
743
  res = _context4.sent;
747
744
  p.memory = res.Memory;
748
745
  delete res.Memory;
749
- //p.res[opt.message] = res
750
746
  p.results.push(opt.message);
751
747
  _context4.next = 96;
752
748
  return mem.set(p, "env", opt.process);
@@ -1041,49 +1037,87 @@ var _default = exports["default"] = function _default() {
1041
1037
  return _ref11.apply(this, arguments);
1042
1038
  };
1043
1039
  }();
1040
+ var result = /*#__PURE__*/function () {
1041
+ var _ref12 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee6(opt) {
1042
+ var _yield$mem$get2;
1043
+ return _regeneratorRuntime().wrap(function _callee6$(_context6) {
1044
+ while (1) switch (_context6.prev = _context6.next) {
1045
+ case 0:
1046
+ _context6.next = 2;
1047
+ return mem.get("msgs", opt.message);
1048
+ case 2:
1049
+ _context6.t1 = _yield$mem$get2 = _context6.sent;
1050
+ _context6.t0 = _context6.t1 === null;
1051
+ if (_context6.t0) {
1052
+ _context6.next = 6;
1053
+ break;
1054
+ }
1055
+ _context6.t0 = _yield$mem$get2 === void 0;
1056
+ case 6:
1057
+ if (!_context6.t0) {
1058
+ _context6.next = 10;
1059
+ break;
1060
+ }
1061
+ _context6.t2 = void 0;
1062
+ _context6.next = 11;
1063
+ break;
1064
+ case 10:
1065
+ _context6.t2 = _yield$mem$get2.res;
1066
+ case 11:
1067
+ return _context6.abrupt("return", _context6.t2);
1068
+ case 12:
1069
+ case "end":
1070
+ return _context6.stop();
1071
+ }
1072
+ }, _callee6);
1073
+ }));
1074
+ return function result(_x10) {
1075
+ return _ref12.apply(this, arguments);
1076
+ };
1077
+ }();
1044
1078
  return {
1045
1079
  message: message,
1046
1080
  unmonitor: function () {
1047
- var _unmonitor = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee6(opt) {
1081
+ var _unmonitor = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee7(opt) {
1048
1082
  var p;
1049
- return _regeneratorRuntime().wrap(function _callee6$(_context6) {
1050
- while (1) switch (_context6.prev = _context6.next) {
1083
+ return _regeneratorRuntime().wrap(function _callee7$(_context7) {
1084
+ while (1) switch (_context7.prev = _context7.next) {
1051
1085
  case 0:
1052
- _context6.next = 2;
1086
+ _context7.next = 2;
1053
1087
  return mem.get("env", opt.process);
1054
1088
  case 2:
1055
- p = _context6.sent;
1089
+ p = _context7.sent;
1056
1090
  try {
1057
1091
  clearInterval(p.cron);
1058
1092
  p.cron = null;
1059
1093
  } catch (e) {}
1060
1094
  case 4:
1061
1095
  case "end":
1062
- return _context6.stop();
1096
+ return _context7.stop();
1063
1097
  }
1064
- }, _callee6);
1098
+ }, _callee7);
1065
1099
  }));
1066
- function unmonitor(_x10) {
1100
+ function unmonitor(_x11) {
1067
1101
  return _unmonitor.apply(this, arguments);
1068
1102
  }
1069
1103
  return unmonitor;
1070
1104
  }(),
1071
1105
  monitor: function () {
1072
- var _monitor = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee8(opt) {
1106
+ var _monitor = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee9(opt) {
1073
1107
  var p;
1074
- return _regeneratorRuntime().wrap(function _callee8$(_context8) {
1075
- while (1) switch (_context8.prev = _context8.next) {
1108
+ return _regeneratorRuntime().wrap(function _callee9$(_context9) {
1109
+ while (1) switch (_context9.prev = _context9.next) {
1076
1110
  case 0:
1077
- _context8.next = 2;
1111
+ _context9.next = 2;
1078
1112
  return mem.get("env", opt.process);
1079
1113
  case 2:
1080
- p = _context8.sent;
1114
+ p = _context9.sent;
1081
1115
  if ((0, _ramda.isNil)(p.cron)) {
1082
- p.cron = setInterval(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
1083
- return _regeneratorRuntime().wrap(function _callee7$(_context7) {
1084
- while (1) switch (_context7.prev = _context7.next) {
1116
+ p.cron = setInterval(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
1117
+ return _regeneratorRuntime().wrap(function _callee8$(_context8) {
1118
+ while (1) switch (_context8.prev = _context8.next) {
1085
1119
  case 0:
1086
- _context7.next = 2;
1120
+ _context8.next = 2;
1087
1121
  return message({
1088
1122
  tags: p.cronTags,
1089
1123
  process: opt.process,
@@ -1092,18 +1126,18 @@ var _default = exports["default"] = function _default() {
1092
1126
  });
1093
1127
  case 2:
1094
1128
  case "end":
1095
- return _context7.stop();
1129
+ return _context8.stop();
1096
1130
  }
1097
- }, _callee7);
1131
+ }, _callee8);
1098
1132
  })), p.span);
1099
1133
  }
1100
1134
  case 4:
1101
1135
  case "end":
1102
- return _context8.stop();
1136
+ return _context9.stop();
1103
1137
  }
1104
- }, _callee8);
1138
+ }, _callee9);
1105
1139
  }));
1106
- function monitor(_x11) {
1140
+ function monitor(_x12) {
1107
1141
  return _monitor.apply(this, arguments);
1108
1142
  }
1109
1143
  return monitor;
@@ -1111,49 +1145,10 @@ var _default = exports["default"] = function _default() {
1111
1145
  spawn: spawn,
1112
1146
  assign: _assign,
1113
1147
  ar: ar,
1114
- result: function () {
1115
- var _result = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee9(opt) {
1116
- var _yield$mem$get2;
1117
- return _regeneratorRuntime().wrap(function _callee9$(_context9) {
1118
- while (1) switch (_context9.prev = _context9.next) {
1119
- case 0:
1120
- _context9.next = 2;
1121
- return mem.get("msgs", opt.message);
1122
- case 2:
1123
- _context9.t1 = _yield$mem$get2 = _context9.sent;
1124
- _context9.t0 = _context9.t1 === null;
1125
- if (_context9.t0) {
1126
- _context9.next = 6;
1127
- break;
1128
- }
1129
- _context9.t0 = _yield$mem$get2 === void 0;
1130
- case 6:
1131
- if (!_context9.t0) {
1132
- _context9.next = 10;
1133
- break;
1134
- }
1135
- _context9.t2 = void 0;
1136
- _context9.next = 11;
1137
- break;
1138
- case 10:
1139
- _context9.t2 = _yield$mem$get2.res;
1140
- case 11:
1141
- return _context9.abrupt("return", _context9.t2);
1142
- case 12:
1143
- case "end":
1144
- return _context9.stop();
1145
- }
1146
- }, _callee9);
1147
- }));
1148
- function result(_x12) {
1149
- return _result.apply(this, arguments);
1150
- }
1151
- return result;
1152
- }(),
1148
+ result: result,
1153
1149
  results: function () {
1154
1150
  var _results = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee10(opt) {
1155
- var _opt$limit;
1156
- var p, results, limit, i, _i;
1151
+ var p, results, _ref14, _ref14$from, from, _ref14$to, to, _ref14$sort, sort, _ref14$limit, limit, _res, count, started, _iterator7, _step7, v;
1157
1152
  return _regeneratorRuntime().wrap(function _callee10$(_context10) {
1158
1153
  while (1) switch (_context10.prev = _context10.next) {
1159
1154
  case 0:
@@ -1161,75 +1156,86 @@ var _default = exports["default"] = function _default() {
1161
1156
  return mem.get("env", opt.process);
1162
1157
  case 2:
1163
1158
  p = _context10.sent;
1164
- results = [];
1165
- limit = (_opt$limit = opt.limit) !== null && _opt$limit !== void 0 ? _opt$limit : 25;
1166
- if (!(opt.sort === "DESC")) {
1167
- _context10.next = 22;
1159
+ if (p) {
1160
+ _context10.next = 5;
1161
+ break;
1162
+ }
1163
+ return _context10.abrupt("return", {
1164
+ edges: []
1165
+ });
1166
+ case 5:
1167
+ results = (p === null || p === void 0 ? void 0 : p.results) || [];
1168
+ _ref14 = opt || {}, _ref14$from = _ref14.from, from = _ref14$from === void 0 ? null : _ref14$from, _ref14$to = _ref14.to, to = _ref14$to === void 0 ? null : _ref14$to, _ref14$sort = _ref14.sort, sort = _ref14$sort === void 0 ? "ASC" : _ref14$sort, _ref14$limit = _ref14.limit, limit = _ref14$limit === void 0 ? 25 : _ref14$limit;
1169
+ if (sort === "DESC") results = (0, _ramda.reverse)(results);
1170
+ _res = [];
1171
+ count = 0;
1172
+ started = (0, _ramda.isNil)(from);
1173
+ _iterator7 = _createForOfIteratorHelper(results);
1174
+ _context10.prev = 12;
1175
+ _iterator7.s();
1176
+ case 14:
1177
+ if ((_step7 = _iterator7.n()).done) {
1178
+ _context10.next = 34;
1168
1179
  break;
1169
1180
  }
1170
- i = p.results.length - 1;
1171
- case 7:
1172
- if (!(0 < i)) {
1173
- _context10.next = 20;
1181
+ v = _step7.value;
1182
+ if (!started) {
1183
+ _context10.next = 31;
1174
1184
  break;
1175
1185
  }
1176
- _context10.t0 = results;
1177
- _context10.t1 = p.results[i];
1178
- _context10.next = 12;
1179
- return _this.result(p.results[i]);
1180
- case 12:
1186
+ _context10.t0 = _res;
1187
+ _context10.t1 = v;
1188
+ _context10.next = 21;
1189
+ return result({
1190
+ message: v
1191
+ });
1192
+ case 21:
1181
1193
  _context10.t2 = _context10.sent;
1182
1194
  _context10.t3 = {
1183
1195
  cursor: _context10.t1,
1184
1196
  node: _context10.t2
1185
1197
  };
1186
1198
  _context10.t0.push.call(_context10.t0, _context10.t3);
1187
- if (!(results.length >= limit)) {
1188
- _context10.next = 17;
1189
- break;
1190
- }
1191
- return _context10.abrupt("break", 20);
1192
- case 17:
1193
- i--;
1194
- _context10.next = 7;
1195
- break;
1196
- case 20:
1197
- _context10.next = 35;
1198
- break;
1199
- case 22:
1200
- _i = 0;
1201
- case 23:
1202
- if (!(_i < p.results.length)) {
1203
- _context10.next = 35;
1199
+ count++;
1200
+ if (!(!(0, _ramda.isNil)(to) && v === to)) {
1201
+ _context10.next = 27;
1204
1202
  break;
1205
1203
  }
1206
- _context10.t4 = results;
1207
- _context10.next = 27;
1208
- return _this.result(p.results[_i]);
1204
+ return _context10.abrupt("break", 34);
1209
1205
  case 27:
1210
- _context10.t5 = _context10.sent;
1211
- _context10.t6 = {
1212
- node: _context10.t5
1213
- };
1214
- _context10.t4.push.call(_context10.t4, _context10.t6);
1215
- if (!(results.length >= limit)) {
1216
- _context10.next = 32;
1206
+ if (!(limit <= count)) {
1207
+ _context10.next = 29;
1217
1208
  break;
1218
1209
  }
1219
- return _context10.abrupt("break", 35);
1210
+ return _context10.abrupt("break", 34);
1211
+ case 29:
1212
+ _context10.next = 32;
1213
+ break;
1214
+ case 31:
1215
+ if (from === v) started = true;
1220
1216
  case 32:
1221
- _i++;
1222
- _context10.next = 23;
1217
+ _context10.next = 14;
1223
1218
  break;
1224
- case 35:
1219
+ case 34:
1220
+ _context10.next = 39;
1221
+ break;
1222
+ case 36:
1223
+ _context10.prev = 36;
1224
+ _context10.t4 = _context10["catch"](12);
1225
+ _iterator7.e(_context10.t4);
1226
+ case 39:
1227
+ _context10.prev = 39;
1228
+ _iterator7.f();
1229
+ return _context10.finish(39);
1230
+ case 42:
1225
1231
  return _context10.abrupt("return", {
1226
- edges: results
1232
+ edges: _res
1227
1233
  });
1228
- case 36:
1234
+ case 43:
1229
1235
  case "end":
1230
1236
  return _context10.stop();
1231
1237
  }
1232
- }, _callee10);
1238
+ }, _callee10, null, [[12, 36, 39, 42]]);
1233
1239
  }));
1234
1240
  function results(_x13) {
1235
1241
  return _results.apply(this, arguments);
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.post("/dry-run", /*#__PURE__*/function () {
634
+ app.get("/state/:pid", /*#__PURE__*/function () {
635
635
  var _ref16 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee15(req, res) {
636
- var process, _req$body2, id, owner, tags, data, res2;
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
- _context15.next = 4;
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 = _context15.sent;
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 _context15.stop();
711
+ return _context16.stop();
664
712
  }
665
- }, _callee15);
713
+ }, _callee16);
666
714
  }));
667
- return function (_x28, _x29) {
668
- return _ref16.apply(this, arguments);
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 _ref17 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee16(req, res) {
673
- var _this4$mem$env$pid$re, _this4$mem$env$pid;
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 _callee16$(_context16) {
676
- while (1) switch (_context16.prev = _context16.next) {
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$pid = _this4.mem.env[pid]) === null || _this4$mem$env$pid === void 0 ? void 0 : _this4$mem$env$pid.results) !== null && _this4$mem$env$pid$re !== void 0 ? _this4$mem$env$pid$re : [];
681
- if (sort.toLowerCase() === "desc") results = (0, _ramda.reverse)(results);
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 : [];
729
+ if (sort === "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
- _context16.prev = 9;
735
+ _context17.prev = 9;
688
736
  _iterator.s();
689
737
  case 11:
690
738
  if ((_step = _iterator.n()).done) {
691
- _context16.next = 26;
739
+ _context17.next = 26;
692
740
  break;
693
741
  }
694
742
  v = _step.value;
695
743
  if (!started) {
696
- _context16.next = 22;
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
- _context16.next = 18;
753
+ _context17.next = 18;
706
754
  break;
707
755
  }
708
- return _context16.abrupt("break", 26);
756
+ return _context17.abrupt("break", 26);
709
757
  case 18:
710
758
  if (!(limit <= count)) {
711
- _context16.next = 20;
759
+ _context17.next = 20;
712
760
  break;
713
761
  }
714
- return _context16.abrupt("break", 26);
762
+ return _context17.abrupt("break", 26);
715
763
  case 20:
716
- _context16.next = 23;
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
- _context16.next = 11;
771
+ _context17.next = 11;
724
772
  break;
725
773
  case 26:
726
- _context16.next = 31;
774
+ _context17.next = 31;
727
775
  break;
728
776
  case 28:
729
- _context16.prev = 28;
730
- _context16.t0 = _context16["catch"](9);
731
- _iterator.e(_context16.t0);
777
+ _context17.prev = 28;
778
+ _context17.t0 = _context17["catch"](9);
779
+ _iterator.e(_context17.t0);
732
780
  case 31:
733
- _context16.prev = 31;
781
+ _context17.prev = 31;
734
782
  _iterator.f();
735
- return _context16.finish(31);
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 _context16.stop();
790
+ return _context17.stop();
743
791
  }
744
- }, _callee16, null, [[9, 28, 31, 34]]);
792
+ }, _callee17, null, [[9, 28, 31, 34]]);
745
793
  }));
746
- return function (_x30, _x31) {
747
- return _ref17.apply(this, arguments);
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/cjs/utils.js CHANGED
@@ -705,9 +705,7 @@ var allChecked = exports.allChecked = function allChecked(check, res, from) {
705
705
  _checks = false;
706
706
  } else {
707
707
  var ok = true;
708
- if (!(0, _ramda.isNil)(v.data)) {
709
- if (!checkVal(res, v.data)) ok = false;
710
- }
708
+ if (!(0, _ramda.isNil)(v.data)) if (!checkVal(res, v.data)) ok = false;
711
709
  for (var k in (_v$tags = v.tags) !== null && _v$tags !== void 0 ? _v$tags : {}) {
712
710
  var _v$tags;
713
711
  if (!checkVal(res, v.tags[k], k)) ok = false;
package/esm/ao.js CHANGED
@@ -27,6 +27,7 @@ import {
27
27
  isNil,
28
28
  includes,
29
29
  map,
30
+ reverse,
30
31
  } from "ramda"
31
32
 
32
33
  import {
@@ -384,22 +385,37 @@ class AO {
384
385
  check = [],
385
386
  get,
386
387
  timeout = 0,
388
+ mode = "aoconnect",
387
389
  }) {
388
390
  let err = null
389
391
  ;({ jwk, err } = await this.ar.checkWallet({ jwk }))
390
392
  if (err) return { err }
393
+ let anchors = {}
391
394
  const getNewTxs = async (pid, _txs, _txmap) => {
392
- const txs = await this.ar.gql.txs({
393
- recipient: pid,
394
- fields: ["id", "recipient", "tags", { owner: ["address"] }],
395
- })
396
- for (const v of txs) {
397
- if (isNil(_txmap[v.id])) {
398
- const t = ltags(v.tags)
399
- if (t.type === "Message") {
400
- v.from = t["from-process"] ?? v.owner?.address
401
- _txs.unshift(v)
402
- _txmap[v.id] = { checked: false, ref: t["x-reference"] }
395
+ if (mode === "gql") {
396
+ const txs = await this.ar.gql.txs({
397
+ recipient: pid,
398
+ fields: ["id", "recipient", "tags", { owner: ["address"] }],
399
+ })
400
+ for (const v of txs) {
401
+ if (isNil(_txmap[v.id])) {
402
+ const t = ltags(v.tags)
403
+ if (t.type === "Message") {
404
+ v.from = t["from-process"] ?? v.owner?.address
405
+ _txs.unshift(v)
406
+ _txmap[v.id] = { checked: false, ref: t["x-reference"] }
407
+ }
408
+ }
409
+ }
410
+ } else {
411
+ for (let v of reverse(await this.res({ pid }))) {
412
+ if (isNil(_txmap[v.cursor])) {
413
+ _txmap[v.cursor] = { checked: false, res: v }
414
+ _txs.unshift({ id: v.cursor })
415
+ console.log("new shit is here", v.cursor, v)
416
+ for (let v2 of v.Messages || []) {
417
+ console.log(v2)
418
+ }
403
419
  }
404
420
  }
405
421
  }
@@ -407,7 +423,7 @@ class AO {
407
423
  const checkOut = async (get, _txs, _txmap, out) => {
408
424
  for (let v of _txs) {
409
425
  if (isNil(_txmap[v.id].res)) {
410
- const res = await this.result({ process: pid, message: v.id })
426
+ const res = await this.res({ pid, mid: v.id })
411
427
  _txmap[v.id].res = res
412
428
  }
413
429
  if (!isNil(_txmap[v.id].res) && _txmap[v.id].out !== true) {
@@ -439,14 +455,20 @@ class AO {
439
455
  for (let v of _txs) {
440
456
  if (!_txmap[v.id].checked) {
441
457
  _txmap[v.id].checked = true
442
- const _res = await this.result({ process: pid, message: v.id })
443
- if (isNil(res)) {
444
- res = _res
445
- mid = v.id
446
- results.push({ mid, res })
458
+ if (isNil(_txmap[v.id].res)) {
459
+ const _res = await this.res({ pid, mid: v.id })
460
+ if (isNil(res)) {
461
+ res = _res
462
+ mid = v.id
463
+ results.push({ mid, res })
464
+ }
465
+ _txmap[v.id].res = _res
466
+ }
467
+ if (!isNil(check) && check.length > 0) {
468
+ checked = allChecked(check, _txmap[v.id].res, v.from)
469
+ } else {
470
+ checked = true
447
471
  }
448
- _txmap[v.id].res = _res
449
- checked = allChecked(check, _res, v.from)
450
472
  if (checked) break
451
473
  }
452
474
  }
@@ -486,7 +508,7 @@ class AO {
486
508
  message: mid,
487
509
  signer: this.toSigner(jwk),
488
510
  })
489
- res = await this.result({ process: pid, message: mid })
511
+ res = await this.res({ pid, mid })
490
512
  if (!res) err = "something went wrong"
491
513
  if (res.Error) err = res.Error
492
514
  else {
@@ -523,7 +545,16 @@ class AO {
523
545
  }
524
546
  return { res, err, out }
525
547
  }
526
-
548
+ async res({ pid, mid, limit, asc, from, to }) {
549
+ if (!mid) {
550
+ let sort = asc ? "ASC" : "DESC"
551
+ const res = await this.results({ process: pid, limit, sort, from, to })
552
+ if (!res.edges) return null
553
+ return map(v => ({ cursor: v.cursor, ...v.node }))(res.edges)
554
+ } else {
555
+ return await this.result({ process: pid, message: mid })
556
+ }
557
+ }
527
558
  async eval({ pid, jwk, data }) {
528
559
  const fns = [
529
560
  {