wao 0.24.0 → 0.24.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 +493 -326
- package/cjs/hyperbeam.js +32 -2
- package/cjs/signer.js +352 -196
- package/cjs/utils.js +1 -0
- package/esm/hb.js +121 -81
- package/esm/hyperbeam.js +21 -4
- package/esm/signer.js +172 -27
- package/esm/utils.js +1 -0
- package/package.json +1 -1
package/cjs/hb.js
CHANGED
|
@@ -8,9 +8,12 @@ var _aoconnect = require("@permaweb/aoconnect");
|
|
|
8
8
|
var _ramda = require("ramda");
|
|
9
9
|
var _utils = require("./utils.js");
|
|
10
10
|
var _signer = require("./signer.js");
|
|
11
|
-
var
|
|
11
|
+
var _path4 = require("path");
|
|
12
12
|
var _fs = require("fs");
|
|
13
|
+
var _excluded = ["path"];
|
|
13
14
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
15
|
+
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var s = Object.getOwnPropertySymbols(e); for (r = 0; r < s.length; r++) o = s[r], t.includes(o) || {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
|
|
16
|
+
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (e.includes(n)) continue; t[n] = r[n]; } return t; }
|
|
14
17
|
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
15
18
|
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
16
19
|
function _toArray(r) { return _arrayWithHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableRest(); }
|
|
@@ -56,7 +59,11 @@ var HB = /*#__PURE__*/function () {
|
|
|
56
59
|
args = _args.length > 0 && _args[0] !== undefined ? _args[0] : {};
|
|
57
60
|
_context.t0 = _this;
|
|
58
61
|
_context.next = 4;
|
|
59
|
-
return _this.fetch(_this.path(
|
|
62
|
+
return _this.fetch(_this.path({
|
|
63
|
+
dev: "hyperbuddy",
|
|
64
|
+
path: "metrics",
|
|
65
|
+
json: false
|
|
66
|
+
}), false);
|
|
60
67
|
case 4:
|
|
61
68
|
_context.t1 = _context.sent;
|
|
62
69
|
return _context.abrupt("return", _context.t0.parseMetrics.call(_context.t0, _context.t1));
|
|
@@ -79,7 +86,7 @@ var HB = /*#__PURE__*/function () {
|
|
|
79
86
|
while (1) switch (_context2.prev = _context2.next) {
|
|
80
87
|
case 0:
|
|
81
88
|
_context2.next = 2;
|
|
82
|
-
return _this.
|
|
89
|
+
return _this.post(_objectSpread({
|
|
83
90
|
path: "/~json@1.0/commit"
|
|
84
91
|
}, args));
|
|
85
92
|
case 2:
|
|
@@ -101,7 +108,7 @@ var HB = /*#__PURE__*/function () {
|
|
|
101
108
|
while (1) switch (_context3.prev = _context3.next) {
|
|
102
109
|
case 0:
|
|
103
110
|
_context3.next = 2;
|
|
104
|
-
return _this.
|
|
111
|
+
return _this.post(_objectSpread({
|
|
105
112
|
path: "/~json@1.0/verify"
|
|
106
113
|
}, args));
|
|
107
114
|
case 2:
|
|
@@ -123,7 +130,7 @@ var HB = /*#__PURE__*/function () {
|
|
|
123
130
|
while (1) switch (_context4.prev = _context4.next) {
|
|
124
131
|
case 0:
|
|
125
132
|
_context4.next = 2;
|
|
126
|
-
return _this.
|
|
133
|
+
return _this.post(_objectSpread({
|
|
127
134
|
path: "/~json@1.0/deserialize"
|
|
128
135
|
}, args));
|
|
129
136
|
case 2:
|
|
@@ -145,7 +152,7 @@ var HB = /*#__PURE__*/function () {
|
|
|
145
152
|
while (1) switch (_context5.prev = _context5.next) {
|
|
146
153
|
case 0:
|
|
147
154
|
_context5.next = 2;
|
|
148
|
-
return _this.
|
|
155
|
+
return _this.post(_objectSpread({
|
|
149
156
|
path: "/~json@1.0/serialize"
|
|
150
157
|
}, args));
|
|
151
158
|
case 2:
|
|
@@ -184,7 +191,7 @@ var HB = /*#__PURE__*/function () {
|
|
|
184
191
|
break;
|
|
185
192
|
}
|
|
186
193
|
_context6.next = 5;
|
|
187
|
-
return _this.
|
|
194
|
+
return _this.post(_objectSpread({
|
|
188
195
|
path: "/~meta@1.0/info"
|
|
189
196
|
}, args));
|
|
190
197
|
case 5:
|
|
@@ -195,14 +202,22 @@ var HB = /*#__PURE__*/function () {
|
|
|
195
202
|
break;
|
|
196
203
|
}
|
|
197
204
|
_context6.next = 11;
|
|
198
|
-
return _this.fetch(_this.path(
|
|
205
|
+
return _this.fetch(_this.path({
|
|
206
|
+
dev: "meta",
|
|
207
|
+
path: "info/".concat(key),
|
|
208
|
+
json: (_args$json2 = args.json) !== null && _args$json2 !== void 0 ? _args$json2 : false
|
|
209
|
+
}), (_args$json3 = args.json) !== null && _args$json3 !== void 0 ? _args$json3 : false);
|
|
199
210
|
case 11:
|
|
200
211
|
_context6.t0 = _context6.sent;
|
|
201
212
|
_context6.next = 17;
|
|
202
213
|
break;
|
|
203
214
|
case 14:
|
|
204
215
|
_context6.next = 16;
|
|
205
|
-
return _this.fetch(_this.path(
|
|
216
|
+
return _this.fetch(_this.path({
|
|
217
|
+
dev: "meta",
|
|
218
|
+
path: "info",
|
|
219
|
+
json: json
|
|
220
|
+
}));
|
|
206
221
|
case 16:
|
|
207
222
|
_context6.t0 = _context6.sent;
|
|
208
223
|
case 17:
|
|
@@ -224,7 +239,10 @@ var HB = /*#__PURE__*/function () {
|
|
|
224
239
|
while (1) switch (_context7.prev = _context7.next) {
|
|
225
240
|
case 0:
|
|
226
241
|
_context7.next = 2;
|
|
227
|
-
return _this.fetch(_this.path(
|
|
242
|
+
return _this.fetch(_this.path({
|
|
243
|
+
dev: "meta",
|
|
244
|
+
path: "build"
|
|
245
|
+
}));
|
|
228
246
|
case 2:
|
|
229
247
|
return _context7.abrupt("return", _context7.sent);
|
|
230
248
|
case 3:
|
|
@@ -246,7 +264,7 @@ var HB = /*#__PURE__*/function () {
|
|
|
246
264
|
value: function _init(jwk) {
|
|
247
265
|
this.signer = (0, _aoconnect.createSigner)(jwk, this.url);
|
|
248
266
|
this.addr = (0, _utils.toAddr)(jwk.n);
|
|
249
|
-
this.
|
|
267
|
+
this.sign = (0, _signer.createRequest)({
|
|
250
268
|
signer: this.signer,
|
|
251
269
|
url: this.url
|
|
252
270
|
});
|
|
@@ -286,24 +304,19 @@ var HB = /*#__PURE__*/function () {
|
|
|
286
304
|
}, {
|
|
287
305
|
key: "send",
|
|
288
306
|
value: function () {
|
|
289
|
-
var _send2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee9(
|
|
307
|
+
var _send2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee9(msg) {
|
|
290
308
|
return _regeneratorRuntime().wrap(function _callee9$(_context9) {
|
|
291
309
|
while (1) switch (_context9.prev = _context9.next) {
|
|
292
310
|
case 0:
|
|
293
|
-
_context9.
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
case 3:
|
|
297
|
-
_context9.t1 = _context9.sent;
|
|
298
|
-
_context9.next = 6;
|
|
299
|
-
return (0, _context9.t0)(_context9.t1);
|
|
300
|
-
case 6:
|
|
311
|
+
_context9.next = 2;
|
|
312
|
+
return (0, _signer.send)(msg);
|
|
313
|
+
case 2:
|
|
301
314
|
return _context9.abrupt("return", _context9.sent);
|
|
302
|
-
case
|
|
315
|
+
case 3:
|
|
303
316
|
case "end":
|
|
304
317
|
return _context9.stop();
|
|
305
318
|
}
|
|
306
|
-
}, _callee9
|
|
319
|
+
}, _callee9);
|
|
307
320
|
}));
|
|
308
321
|
function send(_x7) {
|
|
309
322
|
return _send2.apply(this, arguments);
|
|
@@ -319,7 +332,7 @@ var HB = /*#__PURE__*/function () {
|
|
|
319
332
|
return _regeneratorRuntime().wrap(function _callee10$(_context10) {
|
|
320
333
|
while (1) switch (_context10.prev = _context10.next) {
|
|
321
334
|
case 0:
|
|
322
|
-
wasm = (0, _fs.readFileSync)((0,
|
|
335
|
+
wasm = (0, _fs.readFileSync)((0, _path4.resolve)(import.meta.dirname, "./lua/aos2-wamr.wasm"));
|
|
323
336
|
_context10.next = 3;
|
|
324
337
|
return this.cacheModule(wasm, "application/wasm");
|
|
325
338
|
case 3:
|
|
@@ -338,20 +351,20 @@ var HB = /*#__PURE__*/function () {
|
|
|
338
351
|
return getImage;
|
|
339
352
|
}()
|
|
340
353
|
}, {
|
|
341
|
-
key: "
|
|
354
|
+
key: "getLua",
|
|
342
355
|
value: function () {
|
|
343
|
-
var
|
|
344
|
-
var _this$
|
|
345
|
-
var
|
|
356
|
+
var _getLua = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {
|
|
357
|
+
var _this$lua;
|
|
358
|
+
var lua, id;
|
|
346
359
|
return _regeneratorRuntime().wrap(function _callee11$(_context11) {
|
|
347
360
|
while (1) switch (_context11.prev = _context11.next) {
|
|
348
361
|
case 0:
|
|
349
|
-
|
|
362
|
+
lua = (0, _fs.readFileSync)((0, _path4.resolve)(import.meta.dirname, "./lua/hyper-aos.lua"));
|
|
350
363
|
_context11.next = 3;
|
|
351
|
-
return this.cacheModule(
|
|
364
|
+
return this.cacheModule(lua, "application/lua");
|
|
352
365
|
case 3:
|
|
353
366
|
id = _context11.sent;
|
|
354
|
-
(_this$
|
|
367
|
+
(_this$lua = this.lua) !== null && _this$lua !== void 0 ? _this$lua : this.lua = id;
|
|
355
368
|
return _context11.abrupt("return", id);
|
|
356
369
|
case 6:
|
|
357
370
|
case "end":
|
|
@@ -359,96 +372,105 @@ var HB = /*#__PURE__*/function () {
|
|
|
359
372
|
}
|
|
360
373
|
}, _callee11, this);
|
|
361
374
|
}));
|
|
362
|
-
function getLegacy() {
|
|
363
|
-
return _getLegacy.apply(this, arguments);
|
|
364
|
-
}
|
|
365
|
-
return getLegacy;
|
|
366
|
-
}()
|
|
367
|
-
}, {
|
|
368
|
-
key: "getLua",
|
|
369
|
-
value: function () {
|
|
370
|
-
var _getLua = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
|
|
371
|
-
var _this$lua;
|
|
372
|
-
var lua, id;
|
|
373
|
-
return _regeneratorRuntime().wrap(function _callee12$(_context12) {
|
|
374
|
-
while (1) switch (_context12.prev = _context12.next) {
|
|
375
|
-
case 0:
|
|
376
|
-
lua = (0, _fs.readFileSync)((0, _path2.resolve)(import.meta.dirname, "./lua/hyper-aos.lua"));
|
|
377
|
-
_context12.next = 3;
|
|
378
|
-
return this.cacheModule(lua, "application/lua");
|
|
379
|
-
case 3:
|
|
380
|
-
id = _context12.sent;
|
|
381
|
-
(_this$lua = this.lua) !== null && _this$lua !== void 0 ? _this$lua : this.lua = id;
|
|
382
|
-
return _context12.abrupt("return", id);
|
|
383
|
-
case 6:
|
|
384
|
-
case "end":
|
|
385
|
-
return _context12.stop();
|
|
386
|
-
}
|
|
387
|
-
}, _callee12, this);
|
|
388
|
-
}));
|
|
389
375
|
function getLua() {
|
|
390
376
|
return _getLua.apply(this, arguments);
|
|
391
377
|
}
|
|
392
378
|
return getLua;
|
|
393
379
|
}()
|
|
394
380
|
}, {
|
|
395
|
-
key: "
|
|
381
|
+
key: "scheduleAOS",
|
|
396
382
|
value: function () {
|
|
397
|
-
var
|
|
383
|
+
var _scheduleAOS = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee12(_ref2) {
|
|
398
384
|
var _pid;
|
|
399
385
|
var pid, _ref2$action, action, _ref2$tags, tags, data, _tags, res, slot;
|
|
400
|
-
return _regeneratorRuntime().wrap(function
|
|
401
|
-
while (1) switch (
|
|
386
|
+
return _regeneratorRuntime().wrap(function _callee12$(_context12) {
|
|
387
|
+
while (1) switch (_context12.prev = _context12.next) {
|
|
402
388
|
case 0:
|
|
403
389
|
pid = _ref2.pid, _ref2$action = _ref2.action, action = _ref2$action === void 0 ? "Eval" : _ref2$action, _ref2$tags = _ref2.tags, tags = _ref2$tags === void 0 ? {} : _ref2$tags, data = _ref2.data;
|
|
404
390
|
(_pid = pid) !== null && _pid !== void 0 ? _pid : pid = this.pid;
|
|
405
391
|
_tags = (0, _ramda.mergeLeft)(tags, {
|
|
406
392
|
device: "process@1.0",
|
|
407
393
|
method: "POST",
|
|
408
|
-
path: "/".concat(pid, "/schedule"),
|
|
394
|
+
path: "/".concat(pid, "~process@1.0/schedule"),
|
|
409
395
|
scheduler: this.scheduler,
|
|
410
396
|
Type: "Message",
|
|
411
397
|
Action: action,
|
|
412
398
|
Target: pid
|
|
413
399
|
});
|
|
414
400
|
if (data) _tags.data = data;
|
|
415
|
-
|
|
416
|
-
return this.
|
|
401
|
+
_context12.next = 6;
|
|
402
|
+
return this.post(_tags);
|
|
417
403
|
case 6:
|
|
418
|
-
res =
|
|
419
|
-
slot = res.headers.
|
|
404
|
+
res = _context12.sent;
|
|
405
|
+
slot = res.headers.slot;
|
|
406
|
+
return _context12.abrupt("return", {
|
|
407
|
+
slot: slot,
|
|
408
|
+
res: res,
|
|
409
|
+
pid: pid
|
|
410
|
+
});
|
|
411
|
+
case 9:
|
|
412
|
+
case "end":
|
|
413
|
+
return _context12.stop();
|
|
414
|
+
}
|
|
415
|
+
}, _callee12, this);
|
|
416
|
+
}));
|
|
417
|
+
function scheduleAOS(_x8) {
|
|
418
|
+
return _scheduleAOS.apply(this, arguments);
|
|
419
|
+
}
|
|
420
|
+
return scheduleAOS;
|
|
421
|
+
}()
|
|
422
|
+
}, {
|
|
423
|
+
key: "messageAOS",
|
|
424
|
+
value: function () {
|
|
425
|
+
var _messageAOS = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee13(args) {
|
|
426
|
+
var _yield$this$scheduleA, slot, pid;
|
|
427
|
+
return _regeneratorRuntime().wrap(function _callee13$(_context13) {
|
|
428
|
+
while (1) switch (_context13.prev = _context13.next) {
|
|
429
|
+
case 0:
|
|
430
|
+
_context13.next = 2;
|
|
431
|
+
return this.scheduleAOS(args);
|
|
432
|
+
case 2:
|
|
433
|
+
_yield$this$scheduleA = _context13.sent;
|
|
434
|
+
slot = _yield$this$scheduleA.slot;
|
|
435
|
+
pid = _yield$this$scheduleA.pid;
|
|
420
436
|
_context13.t0 = slot;
|
|
421
|
-
_context13.next =
|
|
437
|
+
_context13.next = 8;
|
|
422
438
|
return this.computeAOS({
|
|
423
439
|
pid: pid,
|
|
424
440
|
slot: slot
|
|
425
441
|
});
|
|
426
|
-
case
|
|
442
|
+
case 8:
|
|
427
443
|
_context13.t1 = _context13.sent;
|
|
428
444
|
return _context13.abrupt("return", {
|
|
429
445
|
slot: _context13.t0,
|
|
430
446
|
outbox: _context13.t1
|
|
431
447
|
});
|
|
432
|
-
case
|
|
448
|
+
case 10:
|
|
433
449
|
case "end":
|
|
434
450
|
return _context13.stop();
|
|
435
451
|
}
|
|
436
452
|
}, _callee13, this);
|
|
437
453
|
}));
|
|
438
|
-
function messageAOS(
|
|
454
|
+
function messageAOS(_x9) {
|
|
439
455
|
return _messageAOS.apply(this, arguments);
|
|
440
456
|
}
|
|
441
457
|
return messageAOS;
|
|
442
458
|
}()
|
|
443
459
|
}, {
|
|
444
460
|
key: "path",
|
|
445
|
-
value: function path() {
|
|
446
|
-
var
|
|
447
|
-
var
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
461
|
+
value: function path(_ref3) {
|
|
462
|
+
var _path2;
|
|
463
|
+
var _ref3$dev = _ref3.dev,
|
|
464
|
+
dev = _ref3$dev === void 0 ? "message" : _ref3$dev,
|
|
465
|
+
_path = _ref3.path,
|
|
466
|
+
_ref3$json = _ref3.json,
|
|
467
|
+
json = _ref3$json === void 0 ? true : _ref3$json,
|
|
468
|
+
_ref3$params = _ref3.params,
|
|
469
|
+
params = _ref3$params === void 0 ? {} : _ref3$params,
|
|
470
|
+
_ref3$pid = _ref3.pid,
|
|
471
|
+
pid = _ref3$pid === void 0 ? "" : _ref3$pid,
|
|
472
|
+
_ref3$tail = _ref3.tail,
|
|
473
|
+
tail = _ref3$tail === void 0 ? "" : _ref3$tail;
|
|
452
474
|
if (!/@/.test(dev)) dev += "@1.0";
|
|
453
475
|
var _params = "";
|
|
454
476
|
if (!(0, _ramda.isEmpty)(params)) {
|
|
@@ -458,7 +480,8 @@ var HB = /*#__PURE__*/function () {
|
|
|
458
480
|
i++;
|
|
459
481
|
}
|
|
460
482
|
}
|
|
461
|
-
|
|
483
|
+
if (_path && !/^\//.test(_path)) _path = "/" + _path;
|
|
484
|
+
return "/".concat(pid, "~").concat(dev).concat((_path2 = _path) !== null && _path2 !== void 0 ? _path2 : "").concat(tail).concat(json ? "/~json@1.0/serialize" : "").concat(_params);
|
|
462
485
|
}
|
|
463
486
|
}, {
|
|
464
487
|
key: "text",
|
|
@@ -479,7 +502,14 @@ var HB = /*#__PURE__*/function () {
|
|
|
479
502
|
dev = "process";
|
|
480
503
|
}
|
|
481
504
|
_context14.next = 6;
|
|
482
|
-
return this.fetch(this.path(
|
|
505
|
+
return this.fetch(this.path({
|
|
506
|
+
dev: dev,
|
|
507
|
+
path: path,
|
|
508
|
+
json: false,
|
|
509
|
+
params: params,
|
|
510
|
+
pid: pid,
|
|
511
|
+
tail: tail
|
|
512
|
+
}), false);
|
|
483
513
|
case 6:
|
|
484
514
|
return _context14.abrupt("return", _context14.sent);
|
|
485
515
|
case 7:
|
|
@@ -488,7 +518,7 @@ var HB = /*#__PURE__*/function () {
|
|
|
488
518
|
}
|
|
489
519
|
}, _callee14, this);
|
|
490
520
|
}));
|
|
491
|
-
function text(
|
|
521
|
+
function text(_x10, _x11) {
|
|
492
522
|
return _text.apply(this, arguments);
|
|
493
523
|
}
|
|
494
524
|
return text;
|
|
@@ -496,7 +526,7 @@ var HB = /*#__PURE__*/function () {
|
|
|
496
526
|
}, {
|
|
497
527
|
key: "json",
|
|
498
528
|
value: function () {
|
|
499
|
-
var
|
|
529
|
+
var _json2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee15(dev, path) {
|
|
500
530
|
var params,
|
|
501
531
|
tail,
|
|
502
532
|
pid,
|
|
@@ -512,7 +542,14 @@ var HB = /*#__PURE__*/function () {
|
|
|
512
542
|
dev = "process";
|
|
513
543
|
}
|
|
514
544
|
_context15.next = 6;
|
|
515
|
-
return this.fetch(this.path(
|
|
545
|
+
return this.fetch(this.path({
|
|
546
|
+
dev: dev,
|
|
547
|
+
path: path,
|
|
548
|
+
json: true,
|
|
549
|
+
params: params,
|
|
550
|
+
pid: pid,
|
|
551
|
+
tail: tail
|
|
552
|
+
}));
|
|
516
553
|
case 6:
|
|
517
554
|
return _context15.abrupt("return", _context15.sent);
|
|
518
555
|
case 7:
|
|
@@ -521,8 +558,8 @@ var HB = /*#__PURE__*/function () {
|
|
|
521
558
|
}
|
|
522
559
|
}, _callee15, this);
|
|
523
560
|
}));
|
|
524
|
-
function json(
|
|
525
|
-
return
|
|
561
|
+
function json(_x12, _x13) {
|
|
562
|
+
return _json2.apply(this, arguments);
|
|
526
563
|
}
|
|
527
564
|
return json;
|
|
528
565
|
}()
|
|
@@ -537,7 +574,7 @@ var HB = /*#__PURE__*/function () {
|
|
|
537
574
|
};
|
|
538
575
|
return fetch;
|
|
539
576
|
}(/*#__PURE__*/function () {
|
|
540
|
-
var
|
|
577
|
+
var _ref4 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee16(path) {
|
|
541
578
|
var json,
|
|
542
579
|
_args16 = arguments;
|
|
543
580
|
return _regeneratorRuntime().wrap(function _callee16$(_context16) {
|
|
@@ -545,7 +582,7 @@ var HB = /*#__PURE__*/function () {
|
|
|
545
582
|
case 0:
|
|
546
583
|
json = _args16.length > 1 && _args16[1] !== undefined ? _args16[1] : true;
|
|
547
584
|
_context16.next = 3;
|
|
548
|
-
return fetch(url).then(function (r) {
|
|
585
|
+
return fetch(this.url + path).then(function (r) {
|
|
549
586
|
return json ? r.json() : r.text();
|
|
550
587
|
});
|
|
551
588
|
case 3:
|
|
@@ -554,24 +591,25 @@ var HB = /*#__PURE__*/function () {
|
|
|
554
591
|
case "end":
|
|
555
592
|
return _context16.stop();
|
|
556
593
|
}
|
|
557
|
-
}, _callee16);
|
|
594
|
+
}, _callee16, this);
|
|
558
595
|
}));
|
|
559
|
-
return function (
|
|
560
|
-
return
|
|
596
|
+
return function (_x14) {
|
|
597
|
+
return _ref4.apply(this, arguments);
|
|
561
598
|
};
|
|
562
599
|
}())
|
|
563
600
|
}, {
|
|
564
601
|
key: "computeAOS",
|
|
565
602
|
value: function () {
|
|
566
|
-
var _computeAOS = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee17(
|
|
603
|
+
var _computeAOS = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee17(_ref5) {
|
|
567
604
|
var pid, slot;
|
|
568
605
|
return _regeneratorRuntime().wrap(function _callee17$(_context17) {
|
|
569
606
|
while (1) switch (_context17.prev = _context17.next) {
|
|
570
607
|
case 0:
|
|
571
|
-
pid =
|
|
608
|
+
pid = _ref5.pid, slot = _ref5.slot;
|
|
572
609
|
_context17.next = 3;
|
|
573
|
-
return
|
|
574
|
-
|
|
610
|
+
return this.getJSON({
|
|
611
|
+
path: "/".concat(pid, "/compute/results/outbox"),
|
|
612
|
+
slot: slot
|
|
575
613
|
});
|
|
576
614
|
case 3:
|
|
577
615
|
return _context17.abrupt("return", _context17.sent);
|
|
@@ -581,7 +619,7 @@ var HB = /*#__PURE__*/function () {
|
|
|
581
619
|
}
|
|
582
620
|
}, _callee17, this);
|
|
583
621
|
}));
|
|
584
|
-
function computeAOS(
|
|
622
|
+
function computeAOS(_x15) {
|
|
585
623
|
return _computeAOS.apply(this, arguments);
|
|
586
624
|
}
|
|
587
625
|
return computeAOS;
|
|
@@ -589,15 +627,16 @@ var HB = /*#__PURE__*/function () {
|
|
|
589
627
|
}, {
|
|
590
628
|
key: "computeLua",
|
|
591
629
|
value: function () {
|
|
592
|
-
var _computeLua = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee18(
|
|
630
|
+
var _computeLua = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee18(_ref6) {
|
|
593
631
|
var pid, slot;
|
|
594
632
|
return _regeneratorRuntime().wrap(function _callee18$(_context18) {
|
|
595
633
|
while (1) switch (_context18.prev = _context18.next) {
|
|
596
634
|
case 0:
|
|
597
|
-
pid =
|
|
635
|
+
pid = _ref6.pid, slot = _ref6.slot;
|
|
598
636
|
_context18.next = 3;
|
|
599
|
-
return
|
|
600
|
-
|
|
637
|
+
return this.getJSON({
|
|
638
|
+
path: "/".concat(pid, "/compute/results"),
|
|
639
|
+
slot: slot
|
|
601
640
|
});
|
|
602
641
|
case 3:
|
|
603
642
|
return _context18.abrupt("return", _context18.sent);
|
|
@@ -607,7 +646,7 @@ var HB = /*#__PURE__*/function () {
|
|
|
607
646
|
}
|
|
608
647
|
}, _callee18, this);
|
|
609
648
|
}));
|
|
610
|
-
function computeLua(
|
|
649
|
+
function computeLua(_x16) {
|
|
611
650
|
return _computeLua.apply(this, arguments);
|
|
612
651
|
}
|
|
613
652
|
return computeLua;
|
|
@@ -615,25 +654,27 @@ var HB = /*#__PURE__*/function () {
|
|
|
615
654
|
}, {
|
|
616
655
|
key: "compute",
|
|
617
656
|
value: function () {
|
|
618
|
-
var _compute = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee19(
|
|
619
|
-
var pid, slot;
|
|
657
|
+
var _compute = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee19(_ref7) {
|
|
658
|
+
var pid, slot, _ref7$path, path;
|
|
620
659
|
return _regeneratorRuntime().wrap(function _callee19$(_context19) {
|
|
621
660
|
while (1) switch (_context19.prev = _context19.next) {
|
|
622
661
|
case 0:
|
|
623
|
-
pid =
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
662
|
+
pid = _ref7.pid, slot = _ref7.slot, _ref7$path = _ref7.path, path = _ref7$path === void 0 ? "" : _ref7$path;
|
|
663
|
+
if (path && !/^\//.test(path)) path = "/" + path;
|
|
664
|
+
_context19.next = 4;
|
|
665
|
+
return this.getJSON({
|
|
666
|
+
path: "/".concat(pid, "/compute").concat(path),
|
|
667
|
+
slot: slot
|
|
627
668
|
});
|
|
628
|
-
case 3:
|
|
629
|
-
return _context19.abrupt("return", _context19.sent);
|
|
630
669
|
case 4:
|
|
670
|
+
return _context19.abrupt("return", _context19.sent);
|
|
671
|
+
case 5:
|
|
631
672
|
case "end":
|
|
632
673
|
return _context19.stop();
|
|
633
674
|
}
|
|
634
675
|
}, _callee19, this);
|
|
635
676
|
}));
|
|
636
|
-
function compute(
|
|
677
|
+
function compute(_x17) {
|
|
637
678
|
return _compute.apply(this, arguments);
|
|
638
679
|
}
|
|
639
680
|
return compute;
|
|
@@ -641,12 +682,12 @@ var HB = /*#__PURE__*/function () {
|
|
|
641
682
|
}, {
|
|
642
683
|
key: "computeLegacy",
|
|
643
684
|
value: function () {
|
|
644
|
-
var _computeLegacy = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee20(
|
|
685
|
+
var _computeLegacy = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee20(_ref8) {
|
|
645
686
|
var pid, slot, json;
|
|
646
687
|
return _regeneratorRuntime().wrap(function _callee20$(_context20) {
|
|
647
688
|
while (1) switch (_context20.prev = _context20.next) {
|
|
648
689
|
case 0:
|
|
649
|
-
pid =
|
|
690
|
+
pid = _ref8.pid, slot = _ref8.slot;
|
|
650
691
|
_context20.next = 3;
|
|
651
692
|
return this.compute({
|
|
652
693
|
pid: pid,
|
|
@@ -661,7 +702,7 @@ var HB = /*#__PURE__*/function () {
|
|
|
661
702
|
}
|
|
662
703
|
}, _callee20, this);
|
|
663
704
|
}));
|
|
664
|
-
function computeLegacy(
|
|
705
|
+
function computeLegacy(_x18) {
|
|
665
706
|
return _computeLegacy.apply(this, arguments);
|
|
666
707
|
}
|
|
667
708
|
return computeLegacy;
|
|
@@ -673,6 +714,7 @@ var HB = /*#__PURE__*/function () {
|
|
|
673
714
|
var _this$scheduler;
|
|
674
715
|
var tags,
|
|
675
716
|
addr,
|
|
717
|
+
_tags,
|
|
676
718
|
res,
|
|
677
719
|
_args21 = arguments;
|
|
678
720
|
return _regeneratorRuntime().wrap(function _callee21$(_context21) {
|
|
@@ -686,23 +728,23 @@ var HB = /*#__PURE__*/function () {
|
|
|
686
728
|
case 3:
|
|
687
729
|
addr = _context21.sent;
|
|
688
730
|
(_this$scheduler = this.scheduler) !== null && _this$scheduler !== void 0 ? _this$scheduler : this.scheduler = addr;
|
|
689
|
-
|
|
690
|
-
return this.send((0, _ramda.mergeLeft)(tags, {
|
|
731
|
+
_tags = (0, _ramda.mergeLeft)(tags, {
|
|
691
732
|
device: "process@1.0",
|
|
692
733
|
path: "/schedule",
|
|
693
734
|
scheduler: this.scheduler,
|
|
694
735
|
"random-seed": seed(16),
|
|
695
736
|
Type: "Process",
|
|
696
|
-
"scheduler-device": "scheduler@1.0",
|
|
697
737
|
"execution-device": "test-device@1.0"
|
|
698
|
-
})
|
|
699
|
-
|
|
738
|
+
});
|
|
739
|
+
_context21.next = 8;
|
|
740
|
+
return this.post(_tags);
|
|
741
|
+
case 8:
|
|
700
742
|
res = _context21.sent;
|
|
701
743
|
return _context21.abrupt("return", {
|
|
702
744
|
res: res,
|
|
703
|
-
pid: res.headers.
|
|
745
|
+
pid: res.headers.process
|
|
704
746
|
});
|
|
705
|
-
case
|
|
747
|
+
case 10:
|
|
706
748
|
case "end":
|
|
707
749
|
return _context21.stop();
|
|
708
750
|
}
|
|
@@ -714,66 +756,114 @@ var HB = /*#__PURE__*/function () {
|
|
|
714
756
|
return spawn;
|
|
715
757
|
}()
|
|
716
758
|
}, {
|
|
717
|
-
key: "
|
|
759
|
+
key: "cacheModule2",
|
|
718
760
|
value: function () {
|
|
719
761
|
var _cacheModule = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee22(data, type) {
|
|
720
|
-
var
|
|
762
|
+
var _yield$this$spawn, pid, _yield$this$schedule, slot, msgs;
|
|
721
763
|
return _regeneratorRuntime().wrap(function _callee22$(_context22) {
|
|
722
764
|
while (1) switch (_context22.prev = _context22.next) {
|
|
723
765
|
case 0:
|
|
724
|
-
|
|
725
|
-
|
|
766
|
+
if (this.cache) {
|
|
767
|
+
_context22.next = 6;
|
|
768
|
+
break;
|
|
769
|
+
}
|
|
770
|
+
_context22.next = 3;
|
|
771
|
+
return this.spawn({});
|
|
772
|
+
case 3:
|
|
773
|
+
_yield$this$spawn = _context22.sent;
|
|
774
|
+
pid = _yield$this$spawn.pid;
|
|
775
|
+
this.cache = pid;
|
|
776
|
+
case 6:
|
|
777
|
+
_context22.next = 8;
|
|
778
|
+
return this.schedule({
|
|
779
|
+
data: data,
|
|
780
|
+
pid: this.cache,
|
|
781
|
+
"content-type": type
|
|
782
|
+
});
|
|
783
|
+
case 8:
|
|
784
|
+
_yield$this$schedule = _context22.sent;
|
|
785
|
+
slot = _yield$this$schedule.slot;
|
|
786
|
+
_context22.next = 12;
|
|
787
|
+
return this.messages({
|
|
788
|
+
pid: this.cache,
|
|
789
|
+
from: slot,
|
|
790
|
+
limit: 1
|
|
791
|
+
});
|
|
792
|
+
case 12:
|
|
793
|
+
msgs = _context22.sent;
|
|
794
|
+
return _context22.abrupt("return", msgs.edges[0].node.message.Id);
|
|
795
|
+
case 14:
|
|
796
|
+
case "end":
|
|
797
|
+
return _context22.stop();
|
|
798
|
+
}
|
|
799
|
+
}, _callee22, this);
|
|
800
|
+
}));
|
|
801
|
+
function cacheModule2(_x19, _x20) {
|
|
802
|
+
return _cacheModule.apply(this, arguments);
|
|
803
|
+
}
|
|
804
|
+
return cacheModule2;
|
|
805
|
+
}()
|
|
806
|
+
}, {
|
|
807
|
+
key: "cacheModule",
|
|
808
|
+
value: function () {
|
|
809
|
+
var _cacheModule2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee23(data, type) {
|
|
810
|
+
var res;
|
|
811
|
+
return _regeneratorRuntime().wrap(function _callee23$(_context23) {
|
|
812
|
+
while (1) switch (_context23.prev = _context23.next) {
|
|
813
|
+
case 0:
|
|
814
|
+
_context23.next = 2;
|
|
815
|
+
return this.post({
|
|
726
816
|
path: "/~wao@1.0/cache_module",
|
|
727
817
|
data: data,
|
|
728
818
|
type: type
|
|
729
819
|
});
|
|
730
820
|
case 2:
|
|
731
|
-
res =
|
|
732
|
-
return
|
|
821
|
+
res = _context23.sent;
|
|
822
|
+
return _context23.abrupt("return", res.headers.id);
|
|
733
823
|
case 4:
|
|
734
824
|
case "end":
|
|
735
|
-
return
|
|
825
|
+
return _context23.stop();
|
|
736
826
|
}
|
|
737
|
-
},
|
|
827
|
+
}, _callee23, this);
|
|
738
828
|
}));
|
|
739
|
-
function cacheModule(
|
|
740
|
-
return
|
|
829
|
+
function cacheModule(_x21, _x22) {
|
|
830
|
+
return _cacheModule2.apply(this, arguments);
|
|
741
831
|
}
|
|
742
832
|
return cacheModule;
|
|
743
833
|
}()
|
|
744
834
|
}, {
|
|
745
835
|
key: "message",
|
|
746
836
|
value: function () {
|
|
747
|
-
var _message = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function
|
|
748
|
-
var pid, _yield$this$
|
|
749
|
-
return _regeneratorRuntime().wrap(function
|
|
750
|
-
while (1) switch (
|
|
837
|
+
var _message = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee24(args) {
|
|
838
|
+
var pid, _yield$this$schedule2, slot, res;
|
|
839
|
+
return _regeneratorRuntime().wrap(function _callee24$(_context24) {
|
|
840
|
+
while (1) switch (_context24.prev = _context24.next) {
|
|
751
841
|
case 0:
|
|
752
842
|
pid = args.pid;
|
|
753
|
-
|
|
843
|
+
_context24.next = 3;
|
|
754
844
|
return this.schedule(args);
|
|
755
845
|
case 3:
|
|
756
|
-
_yield$this$
|
|
757
|
-
slot = _yield$this$
|
|
758
|
-
|
|
846
|
+
_yield$this$schedule2 = _context24.sent;
|
|
847
|
+
slot = _yield$this$schedule2.slot;
|
|
848
|
+
_context24.next = 7;
|
|
759
849
|
return this.compute({
|
|
760
850
|
pid: pid,
|
|
761
851
|
slot: slot
|
|
762
852
|
});
|
|
763
853
|
case 7:
|
|
764
|
-
res =
|
|
765
|
-
return
|
|
854
|
+
res = _context24.sent;
|
|
855
|
+
return _context24.abrupt("return", {
|
|
766
856
|
slot: slot,
|
|
767
857
|
pid: pid,
|
|
768
858
|
res: res
|
|
769
859
|
});
|
|
770
860
|
case 9:
|
|
771
861
|
case "end":
|
|
772
|
-
return
|
|
862
|
+
return _context24.stop();
|
|
773
863
|
}
|
|
774
|
-
},
|
|
864
|
+
}, _callee24, this);
|
|
775
865
|
}));
|
|
776
|
-
function message(
|
|
866
|
+
function message(_x23) {
|
|
777
867
|
return _message.apply(this, arguments);
|
|
778
868
|
}
|
|
779
869
|
return message;
|
|
@@ -781,22 +871,22 @@ var HB = /*#__PURE__*/function () {
|
|
|
781
871
|
}, {
|
|
782
872
|
key: "scheduleLegacy",
|
|
783
873
|
value: function () {
|
|
784
|
-
var _scheduleLegacy = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function
|
|
785
|
-
var
|
|
874
|
+
var _scheduleLegacy = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee25() {
|
|
875
|
+
var _ref9,
|
|
786
876
|
pid,
|
|
787
|
-
|
|
877
|
+
_ref9$action,
|
|
788
878
|
action,
|
|
789
|
-
|
|
879
|
+
_ref9$tags,
|
|
790
880
|
tags,
|
|
791
881
|
data,
|
|
792
882
|
scheduler,
|
|
793
|
-
|
|
794
|
-
return _regeneratorRuntime().wrap(function
|
|
795
|
-
while (1) switch (
|
|
883
|
+
_args25 = arguments;
|
|
884
|
+
return _regeneratorRuntime().wrap(function _callee25$(_context25) {
|
|
885
|
+
while (1) switch (_context25.prev = _context25.next) {
|
|
796
886
|
case 0:
|
|
797
|
-
|
|
887
|
+
_ref9 = _args25.length > 0 && _args25[0] !== undefined ? _args25[0] : {}, pid = _ref9.pid, _ref9$action = _ref9.action, action = _ref9$action === void 0 ? "Eval" : _ref9$action, _ref9$tags = _ref9.tags, tags = _ref9$tags === void 0 ? {} : _ref9$tags, data = _ref9.data, scheduler = _ref9.scheduler;
|
|
798
888
|
if (action) tags.Action = action;
|
|
799
|
-
|
|
889
|
+
_context25.next = 4;
|
|
800
890
|
return this.schedule({
|
|
801
891
|
pid: pid,
|
|
802
892
|
tags: tags,
|
|
@@ -804,12 +894,12 @@ var HB = /*#__PURE__*/function () {
|
|
|
804
894
|
scheduler: scheduler
|
|
805
895
|
});
|
|
806
896
|
case 4:
|
|
807
|
-
return
|
|
897
|
+
return _context25.abrupt("return", _context25.sent);
|
|
808
898
|
case 5:
|
|
809
899
|
case "end":
|
|
810
|
-
return
|
|
900
|
+
return _context25.stop();
|
|
811
901
|
}
|
|
812
|
-
},
|
|
902
|
+
}, _callee25, this);
|
|
813
903
|
}));
|
|
814
904
|
function scheduleLegacy() {
|
|
815
905
|
return _scheduleLegacy.apply(this, arguments);
|
|
@@ -819,20 +909,20 @@ var HB = /*#__PURE__*/function () {
|
|
|
819
909
|
}, {
|
|
820
910
|
key: "scheduleLua",
|
|
821
911
|
value: function () {
|
|
822
|
-
var _scheduleLua = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function
|
|
823
|
-
var
|
|
824
|
-
return _regeneratorRuntime().wrap(function
|
|
825
|
-
while (1) switch (
|
|
912
|
+
var _scheduleLua = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee26() {
|
|
913
|
+
var _args26 = arguments;
|
|
914
|
+
return _regeneratorRuntime().wrap(function _callee26$(_context26) {
|
|
915
|
+
while (1) switch (_context26.prev = _context26.next) {
|
|
826
916
|
case 0:
|
|
827
|
-
|
|
828
|
-
return this.scheduleLegacy.apply(this,
|
|
917
|
+
_context26.next = 2;
|
|
918
|
+
return this.scheduleLegacy.apply(this, _args26);
|
|
829
919
|
case 2:
|
|
830
|
-
return
|
|
920
|
+
return _context26.abrupt("return", _context26.sent);
|
|
831
921
|
case 3:
|
|
832
922
|
case "end":
|
|
833
|
-
return
|
|
923
|
+
return _context26.stop();
|
|
834
924
|
}
|
|
835
|
-
},
|
|
925
|
+
}, _callee26, this);
|
|
836
926
|
}));
|
|
837
927
|
function scheduleLua() {
|
|
838
928
|
return _scheduleLua.apply(this, arguments);
|
|
@@ -842,44 +932,41 @@ var HB = /*#__PURE__*/function () {
|
|
|
842
932
|
}, {
|
|
843
933
|
key: "schedule",
|
|
844
934
|
value: function () {
|
|
845
|
-
var _schedule = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function
|
|
846
|
-
var _pid2
|
|
847
|
-
var
|
|
935
|
+
var _schedule = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee27() {
|
|
936
|
+
var _pid2;
|
|
937
|
+
var _ref10,
|
|
848
938
|
pid,
|
|
849
|
-
|
|
939
|
+
_ref10$tags,
|
|
850
940
|
tags,
|
|
851
941
|
data,
|
|
852
|
-
scheduler,
|
|
853
942
|
_tags,
|
|
854
943
|
res,
|
|
855
|
-
|
|
856
|
-
return _regeneratorRuntime().wrap(function
|
|
857
|
-
while (1) switch (
|
|
944
|
+
_args27 = arguments;
|
|
945
|
+
return _regeneratorRuntime().wrap(function _callee27$(_context27) {
|
|
946
|
+
while (1) switch (_context27.prev = _context27.next) {
|
|
858
947
|
case 0:
|
|
859
|
-
|
|
948
|
+
_ref10 = _args27.length > 0 && _args27[0] !== undefined ? _args27[0] : {}, pid = _ref10.pid, _ref10$tags = _ref10.tags, tags = _ref10$tags === void 0 ? {} : _ref10$tags, data = _ref10.data;
|
|
860
949
|
(_pid2 = pid) !== null && _pid2 !== void 0 ? _pid2 : pid = this.pid;
|
|
861
|
-
(_scheduler = scheduler) !== null && _scheduler !== void 0 ? _scheduler : scheduler = this.scheduler;
|
|
862
950
|
_tags = (0, _ramda.mergeLeft)(tags, {
|
|
863
951
|
method: "POST",
|
|
864
952
|
path: "/".concat(pid, "/schedule"),
|
|
865
|
-
scheduler: scheduler,
|
|
866
953
|
Type: "Message",
|
|
867
954
|
Target: pid
|
|
868
955
|
});
|
|
869
956
|
if (data) _tags.data = data;
|
|
870
|
-
|
|
871
|
-
return this.
|
|
872
|
-
case
|
|
873
|
-
res =
|
|
874
|
-
return
|
|
875
|
-
slot: res.headers.
|
|
957
|
+
_context27.next = 6;
|
|
958
|
+
return this.post(_tags);
|
|
959
|
+
case 6:
|
|
960
|
+
res = _context27.sent;
|
|
961
|
+
return _context27.abrupt("return", {
|
|
962
|
+
slot: res.headers.slot,
|
|
876
963
|
res: res
|
|
877
964
|
});
|
|
878
|
-
case
|
|
965
|
+
case 8:
|
|
879
966
|
case "end":
|
|
880
|
-
return
|
|
967
|
+
return _context27.stop();
|
|
881
968
|
}
|
|
882
|
-
},
|
|
969
|
+
}, _callee27, this);
|
|
883
970
|
}));
|
|
884
971
|
function schedule() {
|
|
885
972
|
return _schedule.apply(this, arguments);
|
|
@@ -889,44 +976,44 @@ var HB = /*#__PURE__*/function () {
|
|
|
889
976
|
}, {
|
|
890
977
|
key: "spawnAOS",
|
|
891
978
|
value: function () {
|
|
892
|
-
var _spawnAOS = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function
|
|
979
|
+
var _spawnAOS = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee28(image) {
|
|
893
980
|
var _this$scheduler2, _image, _this$image2, _this$pid;
|
|
894
981
|
var addr, res, pid;
|
|
895
|
-
return _regeneratorRuntime().wrap(function
|
|
896
|
-
while (1) switch (
|
|
982
|
+
return _regeneratorRuntime().wrap(function _callee28$(_context28) {
|
|
983
|
+
while (1) switch (_context28.prev = _context28.next) {
|
|
897
984
|
case 0:
|
|
898
|
-
|
|
985
|
+
_context28.next = 2;
|
|
899
986
|
return this.dev.meta.info({
|
|
900
987
|
key: "address"
|
|
901
988
|
});
|
|
902
989
|
case 2:
|
|
903
|
-
addr =
|
|
990
|
+
addr = _context28.sent;
|
|
904
991
|
(_this$scheduler2 = this.scheduler) !== null && _this$scheduler2 !== void 0 ? _this$scheduler2 : this.scheduler = addr;
|
|
905
992
|
if (!((_image = image) !== null && _image !== void 0)) {
|
|
906
|
-
|
|
993
|
+
_context28.next = 8;
|
|
907
994
|
break;
|
|
908
995
|
}
|
|
909
996
|
_image;
|
|
910
|
-
|
|
997
|
+
_context28.next = 16;
|
|
911
998
|
break;
|
|
912
999
|
case 8:
|
|
913
1000
|
if (!((_this$image2 = this.image) !== null && _this$image2 !== void 0)) {
|
|
914
|
-
|
|
1001
|
+
_context28.next = 12;
|
|
915
1002
|
break;
|
|
916
1003
|
}
|
|
917
|
-
|
|
918
|
-
|
|
1004
|
+
_context28.t0 = _this$image2;
|
|
1005
|
+
_context28.next = 15;
|
|
919
1006
|
break;
|
|
920
1007
|
case 12:
|
|
921
|
-
|
|
1008
|
+
_context28.next = 14;
|
|
922
1009
|
return this.getImage();
|
|
923
1010
|
case 14:
|
|
924
|
-
|
|
1011
|
+
_context28.t0 = _context28.sent;
|
|
925
1012
|
case 15:
|
|
926
|
-
image =
|
|
1013
|
+
image = _context28.t0;
|
|
927
1014
|
case 16:
|
|
928
|
-
|
|
929
|
-
return this.
|
|
1015
|
+
_context28.next = 18;
|
|
1016
|
+
return this.post({
|
|
930
1017
|
device: "process@1.0",
|
|
931
1018
|
path: "/schedule",
|
|
932
1019
|
scheduler: this.scheduler,
|
|
@@ -937,29 +1024,28 @@ var HB = /*#__PURE__*/function () {
|
|
|
937
1024
|
"random-seed": seed(16),
|
|
938
1025
|
Type: "Process",
|
|
939
1026
|
image: image,
|
|
940
|
-
"scheduler-device": "scheduler@1.0",
|
|
941
1027
|
"execution-device": "stack@1.0",
|
|
942
|
-
"device-stack": ["wasi@1.0", "json-iface@1.0", "wasm-64@1.0", "multipass@1.0"],
|
|
1028
|
+
"device-stack": ["wasi@1.0", "json-iface@1.0", "wasm-64@1.0", "patch@1.0", "multipass@1.0"],
|
|
943
1029
|
"output-prefix": "wasm",
|
|
944
1030
|
"patch-from": "/results/outbox",
|
|
945
1031
|
"stack-keys": ["init", "compute", "snapshot", "normalize"],
|
|
946
1032
|
passes: 2
|
|
947
1033
|
});
|
|
948
1034
|
case 18:
|
|
949
|
-
res =
|
|
950
|
-
pid = res.headers.
|
|
1035
|
+
res = _context28.sent;
|
|
1036
|
+
pid = res.headers.process;
|
|
951
1037
|
(_this$pid = this.pid) !== null && _this$pid !== void 0 ? _this$pid : this.pid = pid;
|
|
952
|
-
return
|
|
1038
|
+
return _context28.abrupt("return", {
|
|
953
1039
|
pid: pid,
|
|
954
1040
|
res: res
|
|
955
1041
|
});
|
|
956
1042
|
case 22:
|
|
957
1043
|
case "end":
|
|
958
|
-
return
|
|
1044
|
+
return _context28.stop();
|
|
959
1045
|
}
|
|
960
|
-
},
|
|
1046
|
+
}, _callee28, this);
|
|
961
1047
|
}));
|
|
962
|
-
function spawnAOS(
|
|
1048
|
+
function spawnAOS(_x24) {
|
|
963
1049
|
return _spawnAOS.apply(this, arguments);
|
|
964
1050
|
}
|
|
965
1051
|
return spawnAOS;
|
|
@@ -967,44 +1053,44 @@ var HB = /*#__PURE__*/function () {
|
|
|
967
1053
|
}, {
|
|
968
1054
|
key: "spawnLua",
|
|
969
1055
|
value: function () {
|
|
970
|
-
var _spawnLua = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1056
|
+
var _spawnLua = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee29(lua) {
|
|
971
1057
|
var _this$scheduler3, _lua, _this$lua2, _this$pid2;
|
|
972
1058
|
var addr, res, pid;
|
|
973
|
-
return _regeneratorRuntime().wrap(function
|
|
974
|
-
while (1) switch (
|
|
1059
|
+
return _regeneratorRuntime().wrap(function _callee29$(_context29) {
|
|
1060
|
+
while (1) switch (_context29.prev = _context29.next) {
|
|
975
1061
|
case 0:
|
|
976
|
-
|
|
1062
|
+
_context29.next = 2;
|
|
977
1063
|
return this.dev.meta.info({
|
|
978
1064
|
key: "address"
|
|
979
1065
|
});
|
|
980
1066
|
case 2:
|
|
981
|
-
addr =
|
|
1067
|
+
addr = _context29.sent;
|
|
982
1068
|
(_this$scheduler3 = this.scheduler) !== null && _this$scheduler3 !== void 0 ? _this$scheduler3 : this.scheduler = addr;
|
|
983
1069
|
if (!((_lua = lua) !== null && _lua !== void 0)) {
|
|
984
|
-
|
|
1070
|
+
_context29.next = 8;
|
|
985
1071
|
break;
|
|
986
1072
|
}
|
|
987
1073
|
_lua;
|
|
988
|
-
|
|
1074
|
+
_context29.next = 16;
|
|
989
1075
|
break;
|
|
990
1076
|
case 8:
|
|
991
1077
|
if (!((_this$lua2 = this.lua) !== null && _this$lua2 !== void 0)) {
|
|
992
|
-
|
|
1078
|
+
_context29.next = 12;
|
|
993
1079
|
break;
|
|
994
1080
|
}
|
|
995
|
-
|
|
996
|
-
|
|
1081
|
+
_context29.t0 = _this$lua2;
|
|
1082
|
+
_context29.next = 15;
|
|
997
1083
|
break;
|
|
998
1084
|
case 12:
|
|
999
|
-
|
|
1085
|
+
_context29.next = 14;
|
|
1000
1086
|
return this.getLua();
|
|
1001
1087
|
case 14:
|
|
1002
|
-
|
|
1088
|
+
_context29.t0 = _context29.sent;
|
|
1003
1089
|
case 15:
|
|
1004
|
-
lua =
|
|
1090
|
+
lua = _context29.t0;
|
|
1005
1091
|
case 16:
|
|
1006
|
-
|
|
1007
|
-
return this.
|
|
1092
|
+
_context29.next = 18;
|
|
1093
|
+
return this.post({
|
|
1008
1094
|
device: "process@1.0",
|
|
1009
1095
|
path: "/schedule",
|
|
1010
1096
|
scheduler: this.scheduler,
|
|
@@ -1015,25 +1101,24 @@ var HB = /*#__PURE__*/function () {
|
|
|
1015
1101
|
"random-seed": seed(16),
|
|
1016
1102
|
Type: "Process",
|
|
1017
1103
|
module: lua,
|
|
1018
|
-
"scheduler-device": "scheduler@1.0",
|
|
1019
1104
|
"execution-device": "lua@5.3a",
|
|
1020
1105
|
"patch-from": "/results/outbox"
|
|
1021
1106
|
});
|
|
1022
1107
|
case 18:
|
|
1023
|
-
res =
|
|
1024
|
-
pid = res.headers.
|
|
1108
|
+
res = _context29.sent;
|
|
1109
|
+
pid = res.headers.process;
|
|
1025
1110
|
(_this$pid2 = this.pid) !== null && _this$pid2 !== void 0 ? _this$pid2 : this.pid = pid;
|
|
1026
|
-
return
|
|
1111
|
+
return _context29.abrupt("return", {
|
|
1027
1112
|
pid: pid,
|
|
1028
1113
|
res: res
|
|
1029
1114
|
});
|
|
1030
1115
|
case 22:
|
|
1031
1116
|
case "end":
|
|
1032
|
-
return
|
|
1117
|
+
return _context29.stop();
|
|
1033
1118
|
}
|
|
1034
|
-
},
|
|
1119
|
+
}, _callee29, this);
|
|
1035
1120
|
}));
|
|
1036
|
-
function spawnLua(
|
|
1121
|
+
function spawnLua(_x25) {
|
|
1037
1122
|
return _spawnLua.apply(this, arguments);
|
|
1038
1123
|
}
|
|
1039
1124
|
return spawnLua;
|
|
@@ -1120,41 +1205,68 @@ var HB = /*#__PURE__*/function () {
|
|
|
1120
1205
|
}
|
|
1121
1206
|
return _metrics;
|
|
1122
1207
|
}
|
|
1208
|
+
}, {
|
|
1209
|
+
key: "now",
|
|
1210
|
+
value: function () {
|
|
1211
|
+
var _now = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee30(_ref11) {
|
|
1212
|
+
var pid, _ref11$path, path;
|
|
1213
|
+
return _regeneratorRuntime().wrap(function _callee30$(_context30) {
|
|
1214
|
+
while (1) switch (_context30.prev = _context30.next) {
|
|
1215
|
+
case 0:
|
|
1216
|
+
pid = _ref11.pid, _ref11$path = _ref11.path, path = _ref11$path === void 0 ? "" : _ref11$path;
|
|
1217
|
+
if (path && !/^\//.test(path)) path = "/" + path;
|
|
1218
|
+
_context30.next = 4;
|
|
1219
|
+
return this.getJSON({
|
|
1220
|
+
path: "/".concat(pid, "/now").concat(path)
|
|
1221
|
+
});
|
|
1222
|
+
case 4:
|
|
1223
|
+
return _context30.abrupt("return", _context30.sent);
|
|
1224
|
+
case 5:
|
|
1225
|
+
case "end":
|
|
1226
|
+
return _context30.stop();
|
|
1227
|
+
}
|
|
1228
|
+
}, _callee30, this);
|
|
1229
|
+
}));
|
|
1230
|
+
function now(_x26) {
|
|
1231
|
+
return _now.apply(this, arguments);
|
|
1232
|
+
}
|
|
1233
|
+
return now;
|
|
1234
|
+
}()
|
|
1123
1235
|
}, {
|
|
1124
1236
|
key: "messages",
|
|
1125
1237
|
value: function () {
|
|
1126
|
-
var _messages = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1238
|
+
var _messages = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee32() {
|
|
1127
1239
|
var _this2 = this;
|
|
1128
|
-
var
|
|
1240
|
+
var _ref12,
|
|
1129
1241
|
pid,
|
|
1130
1242
|
from,
|
|
1131
1243
|
to,
|
|
1132
1244
|
limit,
|
|
1133
1245
|
params,
|
|
1134
1246
|
res,
|
|
1135
|
-
|
|
1136
|
-
return _regeneratorRuntime().wrap(function
|
|
1137
|
-
while (1) switch (
|
|
1247
|
+
_args32 = arguments;
|
|
1248
|
+
return _regeneratorRuntime().wrap(function _callee32$(_context32) {
|
|
1249
|
+
while (1) switch (_context32.prev = _context32.next) {
|
|
1138
1250
|
case 0:
|
|
1139
|
-
|
|
1251
|
+
_ref12 = _args32.length > 0 && _args32[0] !== undefined ? _args32[0] : {}, pid = _ref12.pid, from = _ref12.from, to = _ref12.to, limit = _ref12.limit;
|
|
1140
1252
|
params = "target=".concat(pid);
|
|
1141
1253
|
if ((0, _ramda.isNotNil)(from)) params += "&from=".concat(from);
|
|
1142
1254
|
if ((0, _ramda.isNotNil)(to)) params += "&to=".concat(to);
|
|
1143
1255
|
params += "&accept=application/aos-2";
|
|
1144
|
-
|
|
1256
|
+
_context32.next = 7;
|
|
1145
1257
|
return fetch("".concat(this.url, "/~scheduler@1.0/schedule?").concat(params)).then(function (r) {
|
|
1146
1258
|
return r.json();
|
|
1147
1259
|
});
|
|
1148
1260
|
case 7:
|
|
1149
|
-
res =
|
|
1261
|
+
res = _context32.sent;
|
|
1150
1262
|
if (res.page_info.has_next_page) {
|
|
1151
|
-
res.next = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1263
|
+
res.next = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee31() {
|
|
1152
1264
|
var from2;
|
|
1153
|
-
return _regeneratorRuntime().wrap(function
|
|
1154
|
-
while (1) switch (
|
|
1265
|
+
return _regeneratorRuntime().wrap(function _callee31$(_context31) {
|
|
1266
|
+
while (1) switch (_context31.prev = _context31.next) {
|
|
1155
1267
|
case 0:
|
|
1156
1268
|
from2 = (0, _ramda.last)(res.edges).cursor + 1;
|
|
1157
|
-
|
|
1269
|
+
_context31.next = 3;
|
|
1158
1270
|
return _this2.message({
|
|
1159
1271
|
pid: pid,
|
|
1160
1272
|
from: from2,
|
|
@@ -1162,20 +1274,20 @@ var HB = /*#__PURE__*/function () {
|
|
|
1162
1274
|
limit: limit
|
|
1163
1275
|
});
|
|
1164
1276
|
case 3:
|
|
1165
|
-
return
|
|
1277
|
+
return _context31.abrupt("return", _context31.sent);
|
|
1166
1278
|
case 4:
|
|
1167
1279
|
case "end":
|
|
1168
|
-
return
|
|
1280
|
+
return _context31.stop();
|
|
1169
1281
|
}
|
|
1170
|
-
},
|
|
1282
|
+
}, _callee31);
|
|
1171
1283
|
}));
|
|
1172
1284
|
}
|
|
1173
|
-
return
|
|
1285
|
+
return _context32.abrupt("return", res);
|
|
1174
1286
|
case 10:
|
|
1175
1287
|
case "end":
|
|
1176
|
-
return
|
|
1288
|
+
return _context32.stop();
|
|
1177
1289
|
}
|
|
1178
|
-
},
|
|
1290
|
+
}, _callee32, this);
|
|
1179
1291
|
}));
|
|
1180
1292
|
function messages() {
|
|
1181
1293
|
return _messages.apply(this, arguments);
|
|
@@ -1185,17 +1297,17 @@ var HB = /*#__PURE__*/function () {
|
|
|
1185
1297
|
}, {
|
|
1186
1298
|
key: "spawnLegacy",
|
|
1187
1299
|
value: function () {
|
|
1188
|
-
var _spawnLegacy = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1189
|
-
var
|
|
1300
|
+
var _spawnLegacy = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee33() {
|
|
1301
|
+
var _ref14,
|
|
1190
1302
|
module,
|
|
1191
|
-
|
|
1303
|
+
_ref14$tags,
|
|
1192
1304
|
tags,
|
|
1193
1305
|
data,
|
|
1194
|
-
|
|
1195
|
-
return _regeneratorRuntime().wrap(function
|
|
1196
|
-
while (1) switch (
|
|
1306
|
+
_args33 = arguments;
|
|
1307
|
+
return _regeneratorRuntime().wrap(function _callee33$(_context33) {
|
|
1308
|
+
while (1) switch (_context33.prev = _context33.next) {
|
|
1197
1309
|
case 0:
|
|
1198
|
-
|
|
1310
|
+
_ref14 = _args33.length > 0 && _args33[0] !== undefined ? _args33[0] : {}, module = _ref14.module, _ref14$tags = _ref14.tags, tags = _ref14$tags === void 0 ? {} : _ref14$tags, data = _ref14.data;
|
|
1199
1311
|
tags = (0, _ramda.mergeLeft)(tags, {
|
|
1200
1312
|
data: data,
|
|
1201
1313
|
Type: "Process",
|
|
@@ -1210,15 +1322,15 @@ var HB = /*#__PURE__*/function () {
|
|
|
1210
1322
|
"scheduler-device": "scheduler@1.0",
|
|
1211
1323
|
"execution-device": "genesis-wasm@1.0"
|
|
1212
1324
|
});
|
|
1213
|
-
|
|
1325
|
+
_context33.next = 4;
|
|
1214
1326
|
return this.spawn(tags);
|
|
1215
1327
|
case 4:
|
|
1216
|
-
return
|
|
1328
|
+
return _context33.abrupt("return", _context33.sent);
|
|
1217
1329
|
case 5:
|
|
1218
1330
|
case "end":
|
|
1219
|
-
return
|
|
1331
|
+
return _context33.stop();
|
|
1220
1332
|
}
|
|
1221
|
-
},
|
|
1333
|
+
}, _callee33, this);
|
|
1222
1334
|
}));
|
|
1223
1335
|
function spawnLegacy() {
|
|
1224
1336
|
return _spawnLegacy.apply(this, arguments);
|
|
@@ -1228,27 +1340,27 @@ var HB = /*#__PURE__*/function () {
|
|
|
1228
1340
|
}, {
|
|
1229
1341
|
key: "dryrun",
|
|
1230
1342
|
value: function () {
|
|
1231
|
-
var _dryrun = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1232
|
-
var
|
|
1233
|
-
|
|
1343
|
+
var _dryrun = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee34() {
|
|
1344
|
+
var _ref15,
|
|
1345
|
+
_ref15$tags,
|
|
1234
1346
|
tags,
|
|
1235
1347
|
pid,
|
|
1236
1348
|
action,
|
|
1237
1349
|
data,
|
|
1238
1350
|
json,
|
|
1239
1351
|
res,
|
|
1240
|
-
|
|
1241
|
-
return _regeneratorRuntime().wrap(function
|
|
1242
|
-
while (1) switch (
|
|
1352
|
+
_args34 = arguments;
|
|
1353
|
+
return _regeneratorRuntime().wrap(function _callee34$(_context34) {
|
|
1354
|
+
while (1) switch (_context34.prev = _context34.next) {
|
|
1243
1355
|
case 0:
|
|
1244
|
-
|
|
1356
|
+
_ref15 = _args34.length > 0 && _args34[0] !== undefined ? _args34[0] : {}, _ref15$tags = _ref15.tags, tags = _ref15$tags === void 0 ? {} : _ref15$tags, pid = _ref15.pid, action = _ref15.action, data = _ref15.data;
|
|
1245
1357
|
if (typeof action === "string") tags.Action = action;
|
|
1246
1358
|
json = {
|
|
1247
1359
|
Tags: (0, _utils.buildTags)(tags)
|
|
1248
1360
|
};
|
|
1249
1361
|
if (data) json.Data = data;
|
|
1250
|
-
|
|
1251
|
-
return this.
|
|
1362
|
+
_context34.next = 6;
|
|
1363
|
+
return this.post({
|
|
1252
1364
|
path: "/~relay@1.0/call",
|
|
1253
1365
|
"relay-method": "POST",
|
|
1254
1366
|
"relay-path": "/dry-run?process-id=".concat(pid),
|
|
@@ -1256,104 +1368,159 @@ var HB = /*#__PURE__*/function () {
|
|
|
1256
1368
|
body: JSON.stringify(json)
|
|
1257
1369
|
});
|
|
1258
1370
|
case 6:
|
|
1259
|
-
res =
|
|
1260
|
-
return
|
|
1371
|
+
res = _context34.sent;
|
|
1372
|
+
return _context34.abrupt("return", JSON.parse(res.body));
|
|
1261
1373
|
case 8:
|
|
1262
1374
|
case "end":
|
|
1263
|
-
return
|
|
1375
|
+
return _context34.stop();
|
|
1264
1376
|
}
|
|
1265
|
-
},
|
|
1377
|
+
}, _callee34, this);
|
|
1266
1378
|
}));
|
|
1267
1379
|
function dryrun() {
|
|
1268
1380
|
return _dryrun.apply(this, arguments);
|
|
1269
1381
|
}
|
|
1270
1382
|
return dryrun;
|
|
1271
1383
|
}()
|
|
1384
|
+
}, {
|
|
1385
|
+
key: "post",
|
|
1386
|
+
value: function () {
|
|
1387
|
+
var _post = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee35(obj, json) {
|
|
1388
|
+
var _json;
|
|
1389
|
+
return _regeneratorRuntime().wrap(function _callee35$(_context35) {
|
|
1390
|
+
while (1) switch (_context35.prev = _context35.next) {
|
|
1391
|
+
case 0:
|
|
1392
|
+
_json = json ? "/~json@1.0/serialize" : "";
|
|
1393
|
+
obj.path += _json;
|
|
1394
|
+
_context35.t0 = this;
|
|
1395
|
+
_context35.next = 5;
|
|
1396
|
+
return this.sign(obj);
|
|
1397
|
+
case 5:
|
|
1398
|
+
_context35.t1 = _context35.sent;
|
|
1399
|
+
_context35.next = 8;
|
|
1400
|
+
return _context35.t0.send.call(_context35.t0, _context35.t1);
|
|
1401
|
+
case 8:
|
|
1402
|
+
return _context35.abrupt("return", _context35.sent);
|
|
1403
|
+
case 9:
|
|
1404
|
+
case "end":
|
|
1405
|
+
return _context35.stop();
|
|
1406
|
+
}
|
|
1407
|
+
}, _callee35, this);
|
|
1408
|
+
}));
|
|
1409
|
+
function post(_x27, _x28) {
|
|
1410
|
+
return _post.apply(this, arguments);
|
|
1411
|
+
}
|
|
1412
|
+
return post;
|
|
1413
|
+
}()
|
|
1272
1414
|
}, {
|
|
1273
1415
|
key: "get",
|
|
1274
1416
|
value: function () {
|
|
1275
|
-
var _get = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1276
|
-
var
|
|
1277
|
-
|
|
1278
|
-
|
|
1417
|
+
var _get = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee36(_ref16) {
|
|
1418
|
+
var _path3;
|
|
1419
|
+
var path,
|
|
1420
|
+
params,
|
|
1421
|
+
json,
|
|
1422
|
+
_json,
|
|
1423
|
+
_params,
|
|
1424
|
+
i,
|
|
1425
|
+
k,
|
|
1426
|
+
response,
|
|
1427
|
+
headers,
|
|
1428
|
+
_args36 = arguments;
|
|
1429
|
+
return _regeneratorRuntime().wrap(function _callee36$(_context36) {
|
|
1430
|
+
while (1) switch (_context36.prev = _context36.next) {
|
|
1279
1431
|
case 0:
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1432
|
+
path = _ref16.path, params = _objectWithoutProperties(_ref16, _excluded);
|
|
1433
|
+
json = _args36.length > 1 && _args36[1] !== undefined ? _args36[1] : false;
|
|
1434
|
+
_json = json ? "/~json@1.0/serialize" : "";
|
|
1435
|
+
(_path3 = path) !== null && _path3 !== void 0 ? _path3 : path = "/~message@1.0";
|
|
1436
|
+
if (!/^\//.test(path)) path = "/" + path;
|
|
1437
|
+
_params = "";
|
|
1438
|
+
if (!(0, _ramda.isEmpty)(params)) {
|
|
1439
|
+
i = 0;
|
|
1440
|
+
for (k in params) {
|
|
1441
|
+
_params += "".concat(i === 0 ? "?" : "&").concat(k, "=").concat(params[k]);
|
|
1442
|
+
i++;
|
|
1443
|
+
}
|
|
1444
|
+
}
|
|
1445
|
+
_context36.next = 9;
|
|
1446
|
+
return fetch("".concat(this.url).concat(path).concat(_json).concat(_params));
|
|
1447
|
+
case 9:
|
|
1448
|
+
response = _context36.sent;
|
|
1449
|
+
headers = {};
|
|
1450
|
+
response.headers.forEach(function (v, k) {
|
|
1451
|
+
return headers[k] = v;
|
|
1286
1452
|
});
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1453
|
+
_context36.t0 = response;
|
|
1454
|
+
_context36.t1 = headers;
|
|
1455
|
+
_context36.next = 16;
|
|
1456
|
+
return response.text();
|
|
1457
|
+
case 16:
|
|
1458
|
+
_context36.t2 = _context36.sent;
|
|
1459
|
+
_context36.t3 = response.status;
|
|
1460
|
+
return _context36.abrupt("return", {
|
|
1461
|
+
response: _context36.t0,
|
|
1462
|
+
headers: _context36.t1,
|
|
1463
|
+
body: _context36.t2,
|
|
1464
|
+
status: _context36.t3
|
|
1465
|
+
});
|
|
1466
|
+
case 19:
|
|
1290
1467
|
case "end":
|
|
1291
|
-
return
|
|
1468
|
+
return _context36.stop();
|
|
1292
1469
|
}
|
|
1293
|
-
},
|
|
1470
|
+
}, _callee36, this);
|
|
1294
1471
|
}));
|
|
1295
|
-
function get(
|
|
1472
|
+
function get(_x29) {
|
|
1296
1473
|
return _get.apply(this, arguments);
|
|
1297
1474
|
}
|
|
1298
1475
|
return get;
|
|
1299
1476
|
}()
|
|
1300
1477
|
}, {
|
|
1301
|
-
key: "
|
|
1478
|
+
key: "postJSON",
|
|
1302
1479
|
value: function () {
|
|
1303
|
-
var
|
|
1304
|
-
var
|
|
1305
|
-
return _regeneratorRuntime().wrap(function
|
|
1306
|
-
while (1) switch (
|
|
1480
|
+
var _postJSON = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee37(args) {
|
|
1481
|
+
var res;
|
|
1482
|
+
return _regeneratorRuntime().wrap(function _callee37$(_context37) {
|
|
1483
|
+
while (1) switch (_context37.prev = _context37.next) {
|
|
1307
1484
|
case 0:
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
path: path,
|
|
1314
|
-
method: "POST"
|
|
1315
|
-
});
|
|
1316
|
-
case 3:
|
|
1317
|
-
return _context34.abrupt("return", _context34.sent);
|
|
1485
|
+
_context37.next = 2;
|
|
1486
|
+
return this.post(args, true);
|
|
1487
|
+
case 2:
|
|
1488
|
+
res = _context37.sent;
|
|
1489
|
+
return _context37.abrupt("return", JSON.parse(res.body));
|
|
1318
1490
|
case 4:
|
|
1319
1491
|
case "end":
|
|
1320
|
-
return
|
|
1492
|
+
return _context37.stop();
|
|
1321
1493
|
}
|
|
1322
|
-
},
|
|
1494
|
+
}, _callee37, this);
|
|
1323
1495
|
}));
|
|
1324
|
-
function
|
|
1325
|
-
return
|
|
1496
|
+
function postJSON(_x30) {
|
|
1497
|
+
return _postJSON.apply(this, arguments);
|
|
1326
1498
|
}
|
|
1327
|
-
return
|
|
1499
|
+
return postJSON;
|
|
1328
1500
|
}()
|
|
1329
1501
|
}, {
|
|
1330
|
-
key: "
|
|
1502
|
+
key: "getJSON",
|
|
1331
1503
|
value: function () {
|
|
1332
|
-
var
|
|
1333
|
-
var
|
|
1334
|
-
return _regeneratorRuntime().wrap(function
|
|
1335
|
-
while (1) switch (
|
|
1504
|
+
var _getJSON = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee38(args) {
|
|
1505
|
+
var res;
|
|
1506
|
+
return _regeneratorRuntime().wrap(function _callee38$(_context38) {
|
|
1507
|
+
while (1) switch (_context38.prev = _context38.next) {
|
|
1336
1508
|
case 0:
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
_context35.next = 5;
|
|
1344
|
-
return this._request(_tags);
|
|
1345
|
-
case 5:
|
|
1346
|
-
return _context35.abrupt("return", _context35.sent);
|
|
1347
|
-
case 6:
|
|
1509
|
+
_context38.next = 2;
|
|
1510
|
+
return this.get(args, true);
|
|
1511
|
+
case 2:
|
|
1512
|
+
res = _context38.sent;
|
|
1513
|
+
return _context38.abrupt("return", JSON.parse(res.body));
|
|
1514
|
+
case 4:
|
|
1348
1515
|
case "end":
|
|
1349
|
-
return
|
|
1516
|
+
return _context38.stop();
|
|
1350
1517
|
}
|
|
1351
|
-
},
|
|
1518
|
+
}, _callee38, this);
|
|
1352
1519
|
}));
|
|
1353
|
-
function
|
|
1354
|
-
return
|
|
1520
|
+
function getJSON(_x31) {
|
|
1521
|
+
return _getJSON.apply(this, arguments);
|
|
1355
1522
|
}
|
|
1356
|
-
return
|
|
1523
|
+
return getJSON;
|
|
1357
1524
|
}()
|
|
1358
1525
|
}]);
|
|
1359
1526
|
}();
|