wao 0.10.2 → 0.10.4

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 CHANGED
@@ -340,6 +340,22 @@ var Server = /*#__PURE__*/function () {
340
340
  return _ref8.apply(this, arguments);
341
341
  };
342
342
  }());
343
+ app.get("*", /*#__PURE__*/function () {
344
+ var _ref9 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee8(req, res) {
345
+ return _regeneratorRuntime().wrap(function _callee8$(_context8) {
346
+ while (1) switch (_context8.prev = _context8.next) {
347
+ case 0:
348
+ console.log("what");
349
+ case 1:
350
+ case "end":
351
+ return _context8.stop();
352
+ }
353
+ }, _callee8);
354
+ }));
355
+ return function (_x15, _x16) {
356
+ return _ref9.apply(this, arguments);
357
+ };
358
+ }());
343
359
  var server = app.listen(this.ports.ar, function () {
344
360
  console.log("AR on port ".concat(_this.ports.ar));
345
361
  });
@@ -358,11 +374,11 @@ var Server = /*#__PURE__*/function () {
358
374
  return res.send("ao messenger unit");
359
375
  });
360
376
  app.post("/monitor/:id", /*#__PURE__*/function () {
361
- var _ref9 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee8(req, res) {
362
- return _regeneratorRuntime().wrap(function _callee8$(_context8) {
363
- while (1) switch (_context8.prev = _context8.next) {
377
+ var _ref10 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee9(req, res) {
378
+ return _regeneratorRuntime().wrap(function _callee9$(_context9) {
379
+ while (1) switch (_context9.prev = _context9.next) {
364
380
  case 0:
365
- _context8.next = 2;
381
+ _context9.next = 2;
366
382
  return _this2.monitor({
367
383
  process: req.params.id
368
384
  });
@@ -373,20 +389,20 @@ var Server = /*#__PURE__*/function () {
373
389
  });
374
390
  case 3:
375
391
  case "end":
376
- return _context8.stop();
392
+ return _context9.stop();
377
393
  }
378
- }, _callee8);
394
+ }, _callee9);
379
395
  }));
380
- return function (_x15, _x16) {
381
- return _ref9.apply(this, arguments);
396
+ return function (_x17, _x18) {
397
+ return _ref10.apply(this, arguments);
382
398
  };
383
399
  }());
384
400
  app["delete"]("/monitor/:id", /*#__PURE__*/function () {
385
- var _ref10 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee9(req, res) {
386
- return _regeneratorRuntime().wrap(function _callee9$(_context9) {
387
- while (1) switch (_context9.prev = _context9.next) {
401
+ var _ref11 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee10(req, res) {
402
+ return _regeneratorRuntime().wrap(function _callee10$(_context10) {
403
+ while (1) switch (_context10.prev = _context10.next) {
388
404
  case 0:
389
- _context9.next = 2;
405
+ _context10.next = 2;
390
406
  return _this2.unmonitor({
391
407
  process: req.params.id
392
408
  });
@@ -397,57 +413,57 @@ var Server = /*#__PURE__*/function () {
397
413
  });
398
414
  case 3:
399
415
  case "end":
400
- return _context9.stop();
416
+ return _context10.stop();
401
417
  }
402
- }, _callee9);
418
+ }, _callee10);
403
419
  }));
404
- return function (_x17, _x18) {
405
- return _ref10.apply(this, arguments);
420
+ return function (_x19, _x20) {
421
+ return _ref11.apply(this, arguments);
406
422
  };
407
423
  }());
408
424
  app.post("/", /*#__PURE__*/function () {
409
- var _ref11 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee10(req, res) {
410
- var binary, valid, type, item, _tags, err, _res;
411
- return _regeneratorRuntime().wrap(function _callee10$(_context10) {
412
- while (1) switch (_context10.prev = _context10.next) {
425
+ var _ref12 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee11(req, res) {
426
+ var binary, valid, type, item, _tags, err, _res2;
427
+ return _regeneratorRuntime().wrap(function _callee11$(_context11) {
428
+ while (1) switch (_context11.prev = _context11.next) {
413
429
  case 0:
414
430
  binary = req.body;
415
- _context10.next = 3;
431
+ _context11.next = 3;
416
432
  return _arbundles.DataItem.verify(binary);
417
433
  case 3:
418
- valid = _context10.sent;
434
+ valid = _context11.sent;
419
435
  type = null;
420
436
  item = null;
421
437
  if (valid) item = new _arbundles.DataItem(binary);
422
438
  _tags = (0, _utils.tags)(item.tags);
423
439
  err = null;
424
440
  if (!(_tags.Type === "Process")) {
425
- _context10.next = 16;
441
+ _context11.next = 16;
426
442
  break;
427
443
  }
428
- _context10.next = 12;
444
+ _context11.next = 12;
429
445
  return _this2.spawn({
430
446
  item: item,
431
447
  module: _tags.Module,
432
448
  scheduler: _tags.Scheduler
433
449
  });
434
450
  case 12:
435
- _res = _context10.sent;
436
- if (!_res) err = "bad requrest";
437
- _context10.next = 22;
451
+ _res2 = _context11.sent;
452
+ if (!_res2) err = "bad requrest";
453
+ _context11.next = 22;
438
454
  break;
439
455
  case 16:
440
456
  if (!(_tags.Type === "Message")) {
441
- _context10.next = 21;
457
+ _context11.next = 21;
442
458
  break;
443
459
  }
444
- _context10.next = 19;
460
+ _context11.next = 19;
445
461
  return _this2.message({
446
462
  item: item,
447
463
  process: item.target
448
464
  });
449
465
  case 19:
450
- _context10.next = 22;
466
+ _context11.next = 22;
451
467
  break;
452
468
  case 21:
453
469
  err = true;
@@ -464,12 +480,12 @@ var Server = /*#__PURE__*/function () {
464
480
  }
465
481
  case 23:
466
482
  case "end":
467
- return _context10.stop();
483
+ return _context11.stop();
468
484
  }
469
- }, _callee10);
485
+ }, _callee11);
470
486
  }));
471
- return function (_x19, _x20) {
472
- return _ref11.apply(this, arguments);
487
+ return function (_x21, _x22) {
488
+ return _ref12.apply(this, arguments);
473
489
  };
474
490
  }());
475
491
  var server = app.listen(this.ports.mu, function () {
@@ -502,23 +518,23 @@ var Server = /*#__PURE__*/function () {
502
518
  var _this3$mem$env$pid$re, _this3$mem$env$pid;
503
519
  var pid = req.params.pid;
504
520
  var edges = (0, _ramda.map)(/*#__PURE__*/function () {
505
- var _ref12 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee11(v) {
521
+ var _ref13 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee12(v) {
506
522
  var _mtx$anchor, _tx$anchor;
507
523
  var tx, _tags, mid, mtx;
508
- return _regeneratorRuntime().wrap(function _callee11$(_context11) {
509
- while (1) switch (_context11.prev = _context11.next) {
524
+ return _regeneratorRuntime().wrap(function _callee12$(_context12) {
525
+ while (1) switch (_context12.prev = _context12.next) {
510
526
  case 0:
511
- _context11.next = 2;
527
+ _context12.next = 2;
512
528
  return _this3.mem.getTx(v);
513
529
  case 2:
514
- tx = _context11.sent;
530
+ tx = _context12.sent;
515
531
  _tags = (0, _utils.tags)(v.tags);
516
532
  mid = _tags.Message;
517
- _context11.next = 7;
533
+ _context12.next = 7;
518
534
  return _this3.mem.getTx(mid);
519
535
  case 7:
520
- mtx = _context11.sent;
521
- return _context11.abrupt("return", {
536
+ mtx = _context12.sent;
537
+ return _context12.abrupt("return", {
522
538
  cursor: v,
523
539
  node: {
524
540
  message: {
@@ -542,12 +558,12 @@ var Server = /*#__PURE__*/function () {
542
558
  });
543
559
  case 9:
544
560
  case "end":
545
- return _context11.stop();
561
+ return _context12.stop();
546
562
  }
547
- }, _callee11);
563
+ }, _callee12);
548
564
  }));
549
- return function (_x21) {
550
- return _ref12.apply(this, arguments);
565
+ return function (_x23) {
566
+ return _ref13.apply(this, arguments);
551
567
  };
552
568
  }())((0, _ramda.reverse)((_this3$mem$env$pid$re = (_this3$mem$env$pid = _this3.mem.env[pid]) === null || _this3$mem$env$pid === void 0 ? void 0 : _this3$mem$env$pid.results) !== null && _this3$mem$env$pid$re !== void 0 ? _this3$mem$env$pid$re : [])); // need mod
553
569
  res.json({
@@ -557,6 +573,22 @@ var Server = /*#__PURE__*/function () {
557
573
  edges: edges
558
574
  });
559
575
  });
576
+ app.get("*", /*#__PURE__*/function () {
577
+ var _ref14 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee13(req, res) {
578
+ return _regeneratorRuntime().wrap(function _callee13$(_context13) {
579
+ while (1) switch (_context13.prev = _context13.next) {
580
+ case 0:
581
+ console.log("what2");
582
+ case 1:
583
+ case "end":
584
+ return _context13.stop();
585
+ }
586
+ }, _callee13);
587
+ }));
588
+ return function (_x24, _x25) {
589
+ return _ref14.apply(this, arguments);
590
+ };
591
+ }());
560
592
  var server = app.listen(this.ports.su, function () {
561
593
  return console.log("SU on port ".concat(_this3.ports.su));
562
594
  });
@@ -576,38 +608,38 @@ var Server = /*#__PURE__*/function () {
576
608
  });
577
609
  });
578
610
  app.get("/result/:mid", /*#__PURE__*/function () {
579
- var _ref13 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee12(req, res) {
611
+ var _ref15 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee14(req, res) {
580
612
  var res2;
581
- return _regeneratorRuntime().wrap(function _callee12$(_context12) {
582
- while (1) switch (_context12.prev = _context12.next) {
613
+ return _regeneratorRuntime().wrap(function _callee14$(_context14) {
614
+ while (1) switch (_context14.prev = _context14.next) {
583
615
  case 0:
584
- _context12.next = 2;
616
+ _context14.next = 2;
585
617
  return _this4.result({
586
618
  message: req.params.mid,
587
619
  process: req.query["process-id"]
588
620
  });
589
621
  case 2:
590
- res2 = _context12.sent;
622
+ res2 = _context14.sent;
591
623
  res.json(res2);
592
624
  case 4:
593
625
  case "end":
594
- return _context12.stop();
626
+ return _context14.stop();
595
627
  }
596
- }, _callee12);
628
+ }, _callee14);
597
629
  }));
598
- return function (_x22, _x23) {
599
- return _ref13.apply(this, arguments);
630
+ return function (_x26, _x27) {
631
+ return _ref15.apply(this, arguments);
600
632
  };
601
633
  }());
602
634
  app.post("/dry-run", /*#__PURE__*/function () {
603
- var _ref14 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee13(req, res) {
635
+ var _ref16 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee15(req, res) {
604
636
  var process, _req$body2, id, owner, tags, data, res2;
605
- return _regeneratorRuntime().wrap(function _callee13$(_context13) {
606
- while (1) switch (_context13.prev = _context13.next) {
637
+ return _regeneratorRuntime().wrap(function _callee15$(_context15) {
638
+ while (1) switch (_context15.prev = _context15.next) {
607
639
  case 0:
608
640
  process = req.query["process-id"];
609
641
  _req$body2 = req.body, id = _req$body2.Id, owner = _req$body2.Owner, tags = _req$body2.Tags, data = _req$body2.Data;
610
- _context13.next = 4;
642
+ _context15.next = 4;
611
643
  return _this4.dryrun({
612
644
  id: id,
613
645
  owner: owner,
@@ -616,7 +648,7 @@ var Server = /*#__PURE__*/function () {
616
648
  process: process
617
649
  });
618
650
  case 4:
619
- res2 = _context13.sent;
651
+ res2 = _context15.sent;
620
652
  if (!res2) {
621
653
  res.status(400);
622
654
  res.json({
@@ -628,12 +660,91 @@ var Server = /*#__PURE__*/function () {
628
660
  }
629
661
  case 6:
630
662
  case "end":
631
- return _context13.stop();
663
+ return _context15.stop();
632
664
  }
633
- }, _callee13);
665
+ }, _callee15);
634
666
  }));
635
- return function (_x24, _x25) {
636
- return _ref14.apply(this, arguments);
667
+ return function (_x28, _x29) {
668
+ return _ref16.apply(this, arguments);
669
+ };
670
+ }());
671
+ 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;
674
+ 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) {
677
+ case 0:
678
+ pid = req.params.pid;
679
+ _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);
682
+ _res = [];
683
+ i = 1;
684
+ count = 0;
685
+ started = (0, _ramda.isNil)(from);
686
+ _iterator = _createForOfIteratorHelper(results);
687
+ _context16.prev = 9;
688
+ _iterator.s();
689
+ case 11:
690
+ if ((_step = _iterator.n()).done) {
691
+ _context16.next = 26;
692
+ break;
693
+ }
694
+ v = _step.value;
695
+ if (!started) {
696
+ _context16.next = 22;
697
+ break;
698
+ }
699
+ _res.push({
700
+ cursor: v,
701
+ node: (_this4$mem$msgs$v = _this4.mem.msgs[v]) === null || _this4$mem$msgs$v === void 0 ? void 0 : _this4$mem$msgs$v.res
702
+ });
703
+ count++;
704
+ if (!(!(0, _ramda.isNil)(to) && v === to)) {
705
+ _context16.next = 18;
706
+ break;
707
+ }
708
+ return _context16.abrupt("break", 26);
709
+ case 18:
710
+ if (!(limit <= count)) {
711
+ _context16.next = 20;
712
+ break;
713
+ }
714
+ return _context16.abrupt("break", 26);
715
+ case 20:
716
+ _context16.next = 23;
717
+ break;
718
+ case 22:
719
+ if (from === v) started = true;
720
+ case 23:
721
+ i++;
722
+ case 24:
723
+ _context16.next = 11;
724
+ break;
725
+ case 26:
726
+ _context16.next = 31;
727
+ break;
728
+ case 28:
729
+ _context16.prev = 28;
730
+ _context16.t0 = _context16["catch"](9);
731
+ _iterator.e(_context16.t0);
732
+ case 31:
733
+ _context16.prev = 31;
734
+ _iterator.f();
735
+ return _context16.finish(31);
736
+ case 34:
737
+ res.json({
738
+ edges: _res
739
+ });
740
+ case 35:
741
+ case "end":
742
+ return _context16.stop();
743
+ }
744
+ }, _callee16, null, [[9, 28, 31, 34]]);
745
+ }));
746
+ return function (_x30, _x31) {
747
+ return _ref17.apply(this, arguments);
637
748
  };
638
749
  }());
639
750
  var server = app.listen(this.ports.cu, function () {
@@ -647,11 +758,11 @@ var Server = /*#__PURE__*/function () {
647
758
  var _this5 = this;
648
759
  return new Promise(function (res) {
649
760
  var count = 0;
650
- var _iterator = _createForOfIteratorHelper(_this5.servers),
651
- _step;
761
+ var _iterator2 = _createForOfIteratorHelper(_this5.servers),
762
+ _step2;
652
763
  try {
653
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
654
- var v = _step.value;
764
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
765
+ var v = _step2.value;
655
766
  v.close(function () {
656
767
  count += 1;
657
768
  if (count >= 4) {
@@ -661,9 +772,9 @@ var Server = /*#__PURE__*/function () {
661
772
  });
662
773
  }
663
774
  } catch (err) {
664
- _iterator.e(err);
775
+ _iterator2.e(err);
665
776
  } finally {
666
- _iterator.f();
777
+ _iterator2.f();
667
778
  }
668
779
  });
669
780
  }
package/esm/server.js CHANGED
@@ -6,7 +6,7 @@ import { tags, toGraphObj, optAO } from "./utils.js"
6
6
  import { connect } from "./aoconnect.js"
7
7
  import { GQL, cu, su, mu } from "./test.js"
8
8
  import bodyParser from "body-parser"
9
- import { keys, map, reverse } from "ramda"
9
+ import { keys, map, isNil, reverse } from "ramda"
10
10
 
11
11
  class Server {
12
12
  constructor({
@@ -148,7 +148,9 @@ class Server {
148
148
  res.json({ id: req.body.id })
149
149
  }
150
150
  })
151
-
151
+ app.get("*", async (req, res) => {
152
+ console.log("what")
153
+ })
152
154
  const server = app.listen(this.ports.ar, () => {
153
155
  console.log(`AR on port ${this.ports.ar}`)
154
156
  })
@@ -246,6 +248,10 @@ class Server {
246
248
  })(reverse(this.mem.env[pid]?.results ?? [])) // need mod
247
249
  res.json({ page_info: { has_next_page: false }, edges })
248
250
  })
251
+ app.get("*", async (req, res) => {
252
+ console.log("what2")
253
+ })
254
+
249
255
  const server = app.listen(this.ports.su, () =>
250
256
  console.log(`SU on port ${this.ports.su}`),
251
257
  )
@@ -277,6 +283,28 @@ class Server {
277
283
  res.json(res2)
278
284
  }
279
285
  })
286
+ app.get("/results/:pid", async (req, res) => {
287
+ const pid = req.params.pid
288
+ const { from = null, to = null, sort = "ASC", limit = 25 } = req.query
289
+ let results = this.mem.env[pid]?.results ?? []
290
+ if (sort.toLowerCase() === "desc") results = reverse(results)
291
+ let _res = []
292
+ let i = 1
293
+ let count = 0
294
+ let started = isNil(from)
295
+ for (let v of results) {
296
+ if (started) {
297
+ _res.push({ cursor: v, node: this.mem.msgs[v]?.res })
298
+ count++
299
+ if (!isNil(to) && v === to) break
300
+ if (limit <= count) break
301
+ } else if (from === v) started = true
302
+
303
+ i++
304
+ }
305
+ res.json({ edges: _res })
306
+ })
307
+
280
308
  const server = app.listen(this.ports.cu, () =>
281
309
  console.log(`CU on port ${this.ports.cu}`),
282
310
  )
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wao",
3
- "version": "0.10.2",
3
+ "version": "0.10.4",
4
4
  "bin": {
5
5
  "wao": "./cjs/cli.js",
6
6
  "wao-esm": "./esm/cli.js"