roboto-js 1.3.11 → 1.3.13
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/dist/cjs/index.cjs +70 -51
- package/dist/cjs/rbt_api.cjs +152 -123
- package/dist/esm/index.js +3 -0
- package/dist/esm/rbt_api.js +10 -0
- package/package.json +1 -1
- package/src/index.js +3 -0
- package/src/rbt_api.js +14 -0
package/dist/cjs/index.cjs
CHANGED
|
@@ -277,27 +277,46 @@ var Roboto = exports["default"] = /*#__PURE__*/function () {
|
|
|
277
277
|
return _createFile.apply(this, arguments);
|
|
278
278
|
}
|
|
279
279
|
return createFile;
|
|
280
|
+
}()
|
|
281
|
+
}, {
|
|
282
|
+
key: "loadFile",
|
|
283
|
+
value: function () {
|
|
284
|
+
var _loadFile = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(id) {
|
|
285
|
+
return _regeneratorRuntime().wrap(function _callee10$(_context10) {
|
|
286
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
287
|
+
case 0:
|
|
288
|
+
return _context10.abrupt("return", this.api.loadFile(id));
|
|
289
|
+
case 1:
|
|
290
|
+
case "end":
|
|
291
|
+
return _context10.stop();
|
|
292
|
+
}
|
|
293
|
+
}, _callee10, this);
|
|
294
|
+
}));
|
|
295
|
+
function loadFile(_x5) {
|
|
296
|
+
return _loadFile.apply(this, arguments);
|
|
297
|
+
}
|
|
298
|
+
return loadFile;
|
|
280
299
|
}() //
|
|
281
300
|
//
|
|
282
301
|
//
|
|
283
302
|
}, {
|
|
284
303
|
key: "create",
|
|
285
304
|
value: function () {
|
|
286
|
-
var _create = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
305
|
+
var _create = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(params) {
|
|
287
306
|
var data,
|
|
288
|
-
|
|
289
|
-
return _regeneratorRuntime().wrap(function
|
|
290
|
-
while (1) switch (
|
|
307
|
+
_args11 = arguments;
|
|
308
|
+
return _regeneratorRuntime().wrap(function _callee11$(_context11) {
|
|
309
|
+
while (1) switch (_context11.prev = _context11.next) {
|
|
291
310
|
case 0:
|
|
292
|
-
data =
|
|
293
|
-
return
|
|
311
|
+
data = _args11.length > 1 && _args11[1] !== undefined ? _args11[1] : {};
|
|
312
|
+
return _context11.abrupt("return", this.api.create(params, data));
|
|
294
313
|
case 2:
|
|
295
314
|
case "end":
|
|
296
|
-
return
|
|
315
|
+
return _context11.stop();
|
|
297
316
|
}
|
|
298
|
-
},
|
|
317
|
+
}, _callee11, this);
|
|
299
318
|
}));
|
|
300
|
-
function create(
|
|
319
|
+
function create(_x6) {
|
|
301
320
|
return _create.apply(this, arguments);
|
|
302
321
|
}
|
|
303
322
|
return create;
|
|
@@ -305,18 +324,18 @@ var Roboto = exports["default"] = /*#__PURE__*/function () {
|
|
|
305
324
|
}, {
|
|
306
325
|
key: "load",
|
|
307
326
|
value: function () {
|
|
308
|
-
var _load = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
309
|
-
return _regeneratorRuntime().wrap(function
|
|
310
|
-
while (1) switch (
|
|
327
|
+
var _load = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(type, ids, options) {
|
|
328
|
+
return _regeneratorRuntime().wrap(function _callee12$(_context12) {
|
|
329
|
+
while (1) switch (_context12.prev = _context12.next) {
|
|
311
330
|
case 0:
|
|
312
|
-
return
|
|
331
|
+
return _context12.abrupt("return", this.api.load(type, ids, options));
|
|
313
332
|
case 1:
|
|
314
333
|
case "end":
|
|
315
|
-
return
|
|
334
|
+
return _context12.stop();
|
|
316
335
|
}
|
|
317
|
-
},
|
|
336
|
+
}, _callee12, this);
|
|
318
337
|
}));
|
|
319
|
-
function load(
|
|
338
|
+
function load(_x7, _x8, _x9) {
|
|
320
339
|
return _load.apply(this, arguments);
|
|
321
340
|
}
|
|
322
341
|
return load;
|
|
@@ -324,18 +343,18 @@ var Roboto = exports["default"] = /*#__PURE__*/function () {
|
|
|
324
343
|
}, {
|
|
325
344
|
key: "query",
|
|
326
345
|
value: function () {
|
|
327
|
-
var _query = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
328
|
-
return _regeneratorRuntime().wrap(function
|
|
329
|
-
while (1) switch (
|
|
346
|
+
var _query = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(type, params) {
|
|
347
|
+
return _regeneratorRuntime().wrap(function _callee13$(_context13) {
|
|
348
|
+
while (1) switch (_context13.prev = _context13.next) {
|
|
330
349
|
case 0:
|
|
331
|
-
return
|
|
350
|
+
return _context13.abrupt("return", this.api.query(type, params));
|
|
332
351
|
case 1:
|
|
333
352
|
case "end":
|
|
334
|
-
return
|
|
353
|
+
return _context13.stop();
|
|
335
354
|
}
|
|
336
|
-
},
|
|
355
|
+
}, _callee13, this);
|
|
337
356
|
}));
|
|
338
|
-
function query(
|
|
357
|
+
function query(_x10, _x11) {
|
|
339
358
|
return _query.apply(this, arguments);
|
|
340
359
|
}
|
|
341
360
|
return query;
|
|
@@ -345,18 +364,18 @@ var Roboto = exports["default"] = /*#__PURE__*/function () {
|
|
|
345
364
|
}, {
|
|
346
365
|
key: "runTask",
|
|
347
366
|
value: function () {
|
|
348
|
-
var _runTask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
349
|
-
return _regeneratorRuntime().wrap(function
|
|
350
|
-
while (1) switch (
|
|
367
|
+
var _runTask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14(params, callbacks) {
|
|
368
|
+
return _regeneratorRuntime().wrap(function _callee14$(_context14) {
|
|
369
|
+
while (1) switch (_context14.prev = _context14.next) {
|
|
351
370
|
case 0:
|
|
352
|
-
return
|
|
371
|
+
return _context14.abrupt("return", this.api.runTask(params, callbacks));
|
|
353
372
|
case 1:
|
|
354
373
|
case "end":
|
|
355
|
-
return
|
|
374
|
+
return _context14.stop();
|
|
356
375
|
}
|
|
357
|
-
},
|
|
376
|
+
}, _callee14, this);
|
|
358
377
|
}));
|
|
359
|
-
function runTask(
|
|
378
|
+
function runTask(_x12, _x13) {
|
|
360
379
|
return _runTask.apply(this, arguments);
|
|
361
380
|
}
|
|
362
381
|
return runTask;
|
|
@@ -364,18 +383,18 @@ var Roboto = exports["default"] = /*#__PURE__*/function () {
|
|
|
364
383
|
}, {
|
|
365
384
|
key: "pollTaskProgress",
|
|
366
385
|
value: function () {
|
|
367
|
-
var _pollTaskProgress = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
368
|
-
return _regeneratorRuntime().wrap(function
|
|
369
|
-
while (1) switch (
|
|
386
|
+
var _pollTaskProgress = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(params) {
|
|
387
|
+
return _regeneratorRuntime().wrap(function _callee15$(_context15) {
|
|
388
|
+
while (1) switch (_context15.prev = _context15.next) {
|
|
370
389
|
case 0:
|
|
371
|
-
return
|
|
390
|
+
return _context15.abrupt("return", this.api.pollTaskProgress(params));
|
|
372
391
|
case 1:
|
|
373
392
|
case "end":
|
|
374
|
-
return
|
|
393
|
+
return _context15.stop();
|
|
375
394
|
}
|
|
376
|
-
},
|
|
395
|
+
}, _callee15, this);
|
|
377
396
|
}));
|
|
378
|
-
function pollTaskProgress(
|
|
397
|
+
function pollTaskProgress(_x14) {
|
|
379
398
|
return _pollTaskProgress.apply(this, arguments);
|
|
380
399
|
}
|
|
381
400
|
return pollTaskProgress;
|
|
@@ -385,18 +404,18 @@ var Roboto = exports["default"] = /*#__PURE__*/function () {
|
|
|
385
404
|
}, {
|
|
386
405
|
key: "get",
|
|
387
406
|
value: function () {
|
|
388
|
-
var _get = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
389
|
-
return _regeneratorRuntime().wrap(function
|
|
390
|
-
while (1) switch (
|
|
407
|
+
var _get = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(endpoint, params) {
|
|
408
|
+
return _regeneratorRuntime().wrap(function _callee16$(_context16) {
|
|
409
|
+
while (1) switch (_context16.prev = _context16.next) {
|
|
391
410
|
case 0:
|
|
392
|
-
return
|
|
411
|
+
return _context16.abrupt("return", this.api.get(endpoint, params));
|
|
393
412
|
case 1:
|
|
394
413
|
case "end":
|
|
395
|
-
return
|
|
414
|
+
return _context16.stop();
|
|
396
415
|
}
|
|
397
|
-
},
|
|
416
|
+
}, _callee16, this);
|
|
398
417
|
}));
|
|
399
|
-
function get(
|
|
418
|
+
function get(_x15, _x16) {
|
|
400
419
|
return _get.apply(this, arguments);
|
|
401
420
|
}
|
|
402
421
|
return get;
|
|
@@ -404,18 +423,18 @@ var Roboto = exports["default"] = /*#__PURE__*/function () {
|
|
|
404
423
|
}, {
|
|
405
424
|
key: "post",
|
|
406
425
|
value: function () {
|
|
407
|
-
var _post = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
408
|
-
return _regeneratorRuntime().wrap(function
|
|
409
|
-
while (1) switch (
|
|
426
|
+
var _post = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17(endpoint, data) {
|
|
427
|
+
return _regeneratorRuntime().wrap(function _callee17$(_context17) {
|
|
428
|
+
while (1) switch (_context17.prev = _context17.next) {
|
|
410
429
|
case 0:
|
|
411
|
-
return
|
|
430
|
+
return _context17.abrupt("return", this.api.post(endpoint, data));
|
|
412
431
|
case 1:
|
|
413
432
|
case "end":
|
|
414
|
-
return
|
|
433
|
+
return _context17.stop();
|
|
415
434
|
}
|
|
416
|
-
},
|
|
435
|
+
}, _callee17, this);
|
|
417
436
|
}));
|
|
418
|
-
function post(
|
|
437
|
+
function post(_x17, _x18) {
|
|
419
438
|
return _post.apply(this, arguments);
|
|
420
439
|
}
|
|
421
440
|
return post;
|
package/dist/cjs/rbt_api.cjs
CHANGED
|
@@ -480,6 +480,36 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
480
480
|
return _createFile.apply(this, arguments);
|
|
481
481
|
}
|
|
482
482
|
return createFile;
|
|
483
|
+
}())
|
|
484
|
+
}, {
|
|
485
|
+
key: "loadFile",
|
|
486
|
+
value: function () {
|
|
487
|
+
var _loadFile = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(id) {
|
|
488
|
+
var response, record;
|
|
489
|
+
return _regeneratorRuntime().wrap(function _callee11$(_context11) {
|
|
490
|
+
while (1) switch (_context11.prev = _context11.next) {
|
|
491
|
+
case 0:
|
|
492
|
+
_context11.prev = 0;
|
|
493
|
+
_context11.next = 3;
|
|
494
|
+
return this.axios.post('/object_service/createObject', ['<@filekit.file>', id]);
|
|
495
|
+
case 3:
|
|
496
|
+
response = _context11.sent;
|
|
497
|
+
record = response.data;
|
|
498
|
+
return _context11.abrupt("return", new _rbt_file["default"](record, this.axios, this.localDb));
|
|
499
|
+
case 8:
|
|
500
|
+
_context11.prev = 8;
|
|
501
|
+
_context11.t0 = _context11["catch"](0);
|
|
502
|
+
return _context11.abrupt("return", this._handleError(_context11.t0));
|
|
503
|
+
case 11:
|
|
504
|
+
case "end":
|
|
505
|
+
return _context11.stop();
|
|
506
|
+
}
|
|
507
|
+
}, _callee11, this, [[0, 8]]);
|
|
508
|
+
}));
|
|
509
|
+
function loadFile(_x7) {
|
|
510
|
+
return _loadFile.apply(this, arguments);
|
|
511
|
+
}
|
|
512
|
+
return loadFile;
|
|
483
513
|
}()
|
|
484
514
|
/**
|
|
485
515
|
* Creates a new object of the given type.
|
|
@@ -488,42 +518,41 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
488
518
|
* @param {Object} dataHash - The data for the new object.
|
|
489
519
|
* @returns {Promise<RbtObject>} - The newly created object as an RbtObject.
|
|
490
520
|
*/
|
|
491
|
-
)
|
|
492
521
|
}, {
|
|
493
522
|
key: "create",
|
|
494
523
|
value: (function () {
|
|
495
|
-
var _create = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
524
|
+
var _create = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(type) {
|
|
496
525
|
var dataHash,
|
|
497
526
|
response,
|
|
498
527
|
record,
|
|
499
|
-
|
|
500
|
-
return _regeneratorRuntime().wrap(function
|
|
501
|
-
while (1) switch (
|
|
528
|
+
_args12 = arguments;
|
|
529
|
+
return _regeneratorRuntime().wrap(function _callee12$(_context12) {
|
|
530
|
+
while (1) switch (_context12.prev = _context12.next) {
|
|
502
531
|
case 0:
|
|
503
|
-
dataHash =
|
|
504
|
-
|
|
505
|
-
|
|
532
|
+
dataHash = _args12.length > 1 && _args12[1] !== undefined ? _args12[1] : {};
|
|
533
|
+
_context12.prev = 1;
|
|
534
|
+
_context12.next = 4;
|
|
506
535
|
return this.axios.post('/object_service/createObject', [type, dataHash]);
|
|
507
536
|
case 4:
|
|
508
|
-
response =
|
|
537
|
+
response = _context12.sent;
|
|
509
538
|
record = response.data;
|
|
510
539
|
if (dataHash) {
|
|
511
540
|
record.data = dataHash;
|
|
512
541
|
}
|
|
513
|
-
return
|
|
542
|
+
return _context12.abrupt("return", new _rbt_object["default"](record, this.axios, {
|
|
514
543
|
isNew: true
|
|
515
544
|
}));
|
|
516
545
|
case 10:
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
return
|
|
546
|
+
_context12.prev = 10;
|
|
547
|
+
_context12.t0 = _context12["catch"](1);
|
|
548
|
+
return _context12.abrupt("return", this._handleError(_context12.t0));
|
|
520
549
|
case 13:
|
|
521
550
|
case "end":
|
|
522
|
-
return
|
|
551
|
+
return _context12.stop();
|
|
523
552
|
}
|
|
524
|
-
},
|
|
553
|
+
}, _callee12, this, [[1, 10]]);
|
|
525
554
|
}));
|
|
526
|
-
function create(
|
|
555
|
+
function create(_x8) {
|
|
527
556
|
return _create.apply(this, arguments);
|
|
528
557
|
}
|
|
529
558
|
return create;
|
|
@@ -560,19 +589,19 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
560
589
|
}, {
|
|
561
590
|
key: "query",
|
|
562
591
|
value: (function () {
|
|
563
|
-
var _query = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
592
|
+
var _query = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(type) {
|
|
564
593
|
var _this = this;
|
|
565
594
|
var params,
|
|
566
595
|
defaultOrderBy,
|
|
567
596
|
defaultLimit,
|
|
568
597
|
mergedParams,
|
|
569
598
|
response,
|
|
570
|
-
|
|
571
|
-
return _regeneratorRuntime().wrap(function
|
|
572
|
-
while (1) switch (
|
|
599
|
+
_args13 = arguments;
|
|
600
|
+
return _regeneratorRuntime().wrap(function _callee13$(_context13) {
|
|
601
|
+
while (1) switch (_context13.prev = _context13.next) {
|
|
573
602
|
case 0:
|
|
574
|
-
params =
|
|
575
|
-
|
|
603
|
+
params = _args13.length > 1 && _args13[1] !== undefined ? _args13[1] : {};
|
|
604
|
+
_context13.prev = 1;
|
|
576
605
|
params.type = type;
|
|
577
606
|
|
|
578
607
|
// Default ordering and pagination
|
|
@@ -589,15 +618,15 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
589
618
|
}
|
|
590
619
|
}; // Merge defaults with provided params
|
|
591
620
|
mergedParams = _objectSpread(_objectSpread(_objectSpread({}, defaultOrderBy), defaultLimit), params);
|
|
592
|
-
|
|
621
|
+
_context13.next = 8;
|
|
593
622
|
return this.axios.post('/object_service/queryObjects', [mergedParams]);
|
|
594
623
|
case 8:
|
|
595
|
-
response =
|
|
624
|
+
response = _context13.sent;
|
|
596
625
|
if (!(response.data.ok === false)) {
|
|
597
|
-
|
|
626
|
+
_context13.next = 11;
|
|
598
627
|
break;
|
|
599
628
|
}
|
|
600
|
-
return
|
|
629
|
+
return _context13.abrupt("return", this._handleError(response));
|
|
601
630
|
case 11:
|
|
602
631
|
// Process items into RbtObject instances
|
|
603
632
|
if (Array.isArray(response.data.items)) {
|
|
@@ -607,18 +636,18 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
607
636
|
});
|
|
608
637
|
});
|
|
609
638
|
}
|
|
610
|
-
return
|
|
639
|
+
return _context13.abrupt("return", response.data.items);
|
|
611
640
|
case 15:
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
return
|
|
641
|
+
_context13.prev = 15;
|
|
642
|
+
_context13.t0 = _context13["catch"](1);
|
|
643
|
+
return _context13.abrupt("return", this._handleError(_context13.t0));
|
|
615
644
|
case 18:
|
|
616
645
|
case "end":
|
|
617
|
-
return
|
|
646
|
+
return _context13.stop();
|
|
618
647
|
}
|
|
619
|
-
},
|
|
648
|
+
}, _callee13, this, [[1, 15]]);
|
|
620
649
|
}));
|
|
621
|
-
function query(
|
|
650
|
+
function query(_x9) {
|
|
622
651
|
return _query.apply(this, arguments);
|
|
623
652
|
}
|
|
624
653
|
return query;
|
|
@@ -635,47 +664,47 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
635
664
|
}, {
|
|
636
665
|
key: "load",
|
|
637
666
|
value: (function () {
|
|
638
|
-
var _load = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
667
|
+
var _load = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14(type, ids) {
|
|
639
668
|
var params,
|
|
640
669
|
mergedParams,
|
|
641
670
|
res,
|
|
642
|
-
|
|
643
|
-
return _regeneratorRuntime().wrap(function
|
|
644
|
-
while (1) switch (
|
|
671
|
+
_args14 = arguments;
|
|
672
|
+
return _regeneratorRuntime().wrap(function _callee14$(_context14) {
|
|
673
|
+
while (1) switch (_context14.prev = _context14.next) {
|
|
645
674
|
case 0:
|
|
646
|
-
params =
|
|
647
|
-
|
|
675
|
+
params = _args14.length > 2 && _args14[2] !== undefined ? _args14[2] : {};
|
|
676
|
+
_context14.prev = 1;
|
|
648
677
|
if (!Array.isArray(ids)) {
|
|
649
|
-
|
|
678
|
+
_context14.next = 7;
|
|
650
679
|
break;
|
|
651
680
|
}
|
|
652
681
|
mergedParams = _objectSpread(_objectSpread({}, params), {}, {
|
|
653
682
|
where: "id IN (" + ids.join(',') + ")"
|
|
654
683
|
});
|
|
655
|
-
return
|
|
684
|
+
return _context14.abrupt("return", this.query(type, mergedParams));
|
|
656
685
|
case 7:
|
|
657
686
|
mergedParams = _objectSpread(_objectSpread({}, params), {}, {
|
|
658
687
|
where: "id=" + ids
|
|
659
688
|
});
|
|
660
|
-
|
|
689
|
+
_context14.next = 10;
|
|
661
690
|
return this.query(type, mergedParams);
|
|
662
691
|
case 10:
|
|
663
|
-
res =
|
|
664
|
-
return
|
|
692
|
+
res = _context14.sent;
|
|
693
|
+
return _context14.abrupt("return", res[0]);
|
|
665
694
|
case 12:
|
|
666
|
-
|
|
695
|
+
_context14.next = 17;
|
|
667
696
|
break;
|
|
668
697
|
case 14:
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
return
|
|
698
|
+
_context14.prev = 14;
|
|
699
|
+
_context14.t0 = _context14["catch"](1);
|
|
700
|
+
return _context14.abrupt("return", this._handleError(_context14.t0));
|
|
672
701
|
case 17:
|
|
673
702
|
case "end":
|
|
674
|
-
return
|
|
703
|
+
return _context14.stop();
|
|
675
704
|
}
|
|
676
|
-
},
|
|
705
|
+
}, _callee14, this, [[1, 14]]);
|
|
677
706
|
}));
|
|
678
|
-
function load(
|
|
707
|
+
function load(_x10, _x11) {
|
|
679
708
|
return _load.apply(this, arguments);
|
|
680
709
|
}
|
|
681
710
|
return load;
|
|
@@ -697,7 +726,7 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
697
726
|
}, {
|
|
698
727
|
key: "runTask",
|
|
699
728
|
value: (function () {
|
|
700
|
-
var _runTask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
729
|
+
var _runTask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {
|
|
701
730
|
var params,
|
|
702
731
|
callbacks,
|
|
703
732
|
onProgress,
|
|
@@ -709,20 +738,20 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
709
738
|
status,
|
|
710
739
|
message,
|
|
711
740
|
output,
|
|
712
|
-
|
|
713
|
-
return _regeneratorRuntime().wrap(function
|
|
714
|
-
while (1) switch (
|
|
741
|
+
_args15 = arguments;
|
|
742
|
+
return _regeneratorRuntime().wrap(function _callee15$(_context15) {
|
|
743
|
+
while (1) switch (_context15.prev = _context15.next) {
|
|
715
744
|
case 0:
|
|
716
|
-
params =
|
|
717
|
-
callbacks =
|
|
745
|
+
params = _args15.length > 0 && _args15[0] !== undefined ? _args15[0] : {};
|
|
746
|
+
callbacks = _args15.length > 1 && _args15[1] !== undefined ? _args15[1] : {};
|
|
718
747
|
onProgress = callbacks.onProgress, onError = callbacks.onError, onFinish = callbacks.onFinish;
|
|
719
|
-
|
|
720
|
-
|
|
748
|
+
_context15.prev = 3;
|
|
749
|
+
_context15.next = 6;
|
|
721
750
|
return this.post('/task_service/runChain', params);
|
|
722
751
|
case 6:
|
|
723
|
-
response =
|
|
752
|
+
response = _context15.sent;
|
|
724
753
|
if (response) {
|
|
725
|
-
|
|
754
|
+
_context15.next = 9;
|
|
726
755
|
break;
|
|
727
756
|
}
|
|
728
757
|
throw new Error('Invalid server response');
|
|
@@ -730,7 +759,7 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
730
759
|
// Validate response structure
|
|
731
760
|
ok = response.ok, jobId = response.jobId, status = response.status, message = response.message, output = response.output;
|
|
732
761
|
if (!(!ok || typeof jobId !== 'string' || typeof status !== 'string')) {
|
|
733
|
-
|
|
762
|
+
_context15.next = 12;
|
|
734
763
|
break;
|
|
735
764
|
}
|
|
736
765
|
throw new Error('Invalid response structure');
|
|
@@ -748,7 +777,7 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
748
777
|
console.log('Finish (request) ', response);
|
|
749
778
|
onFinish(response);
|
|
750
779
|
}
|
|
751
|
-
return
|
|
780
|
+
return _context15.abrupt("return", {
|
|
752
781
|
ok: ok,
|
|
753
782
|
jobId: jobId,
|
|
754
783
|
status: status,
|
|
@@ -756,24 +785,24 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
756
785
|
output: output
|
|
757
786
|
});
|
|
758
787
|
case 18:
|
|
759
|
-
|
|
760
|
-
|
|
788
|
+
_context15.prev = 18;
|
|
789
|
+
_context15.t0 = _context15["catch"](3);
|
|
761
790
|
if (typeof onError === 'function') {
|
|
762
|
-
onError(
|
|
791
|
+
onError(_context15.t0);
|
|
763
792
|
} else {
|
|
764
|
-
console.error('Error in runTask:',
|
|
793
|
+
console.error('Error in runTask:', _context15.t0);
|
|
765
794
|
}
|
|
766
|
-
return
|
|
795
|
+
return _context15.abrupt("return", {
|
|
767
796
|
ok: false,
|
|
768
797
|
jobId: null,
|
|
769
798
|
status: 'ERROR',
|
|
770
|
-
error:
|
|
799
|
+
error: _context15.t0.message
|
|
771
800
|
});
|
|
772
801
|
case 22:
|
|
773
802
|
case "end":
|
|
774
|
-
return
|
|
803
|
+
return _context15.stop();
|
|
775
804
|
}
|
|
776
|
-
},
|
|
805
|
+
}, _callee15, this, [[3, 18]]);
|
|
777
806
|
}));
|
|
778
807
|
function runTask() {
|
|
779
808
|
return _runTask.apply(this, arguments);
|
|
@@ -794,26 +823,26 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
794
823
|
}, {
|
|
795
824
|
key: "pollTaskProgress",
|
|
796
825
|
value: (function () {
|
|
797
|
-
var _pollTaskProgress = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
826
|
+
var _pollTaskProgress = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17(jobId, callbacks) {
|
|
798
827
|
var _this2 = this;
|
|
799
828
|
var onProgress, onError, onFinish, checkProgress;
|
|
800
|
-
return _regeneratorRuntime().wrap(function
|
|
801
|
-
while (1) switch (
|
|
829
|
+
return _regeneratorRuntime().wrap(function _callee17$(_context17) {
|
|
830
|
+
while (1) switch (_context17.prev = _context17.next) {
|
|
802
831
|
case 0:
|
|
803
832
|
onProgress = callbacks.onProgress, onError = callbacks.onError, onFinish = callbacks.onFinish;
|
|
804
|
-
|
|
833
|
+
_context17.prev = 1;
|
|
805
834
|
checkProgress = /*#__PURE__*/function () {
|
|
806
|
-
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
835
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {
|
|
807
836
|
var response;
|
|
808
|
-
return _regeneratorRuntime().wrap(function
|
|
809
|
-
while (1) switch (
|
|
837
|
+
return _regeneratorRuntime().wrap(function _callee16$(_context16) {
|
|
838
|
+
while (1) switch (_context16.prev = _context16.next) {
|
|
810
839
|
case 0:
|
|
811
|
-
|
|
840
|
+
_context16.next = 2;
|
|
812
841
|
return _this2.get("/task_service/pollChainProgress", {
|
|
813
842
|
jobId: jobId
|
|
814
843
|
});
|
|
815
844
|
case 2:
|
|
816
|
-
response =
|
|
845
|
+
response = _context16.sent;
|
|
817
846
|
// If the task is still in progress, start polling for updates
|
|
818
847
|
if (response.status === 'DONE' && onFinish) {
|
|
819
848
|
// Provide the current progress to the callback function
|
|
@@ -836,28 +865,28 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
836
865
|
}
|
|
837
866
|
case 7:
|
|
838
867
|
case "end":
|
|
839
|
-
return
|
|
868
|
+
return _context16.stop();
|
|
840
869
|
}
|
|
841
|
-
},
|
|
870
|
+
}, _callee16);
|
|
842
871
|
}));
|
|
843
872
|
return function checkProgress() {
|
|
844
873
|
return _ref2.apply(this, arguments);
|
|
845
874
|
};
|
|
846
875
|
}();
|
|
847
876
|
checkProgress();
|
|
848
|
-
|
|
877
|
+
_context17.next = 9;
|
|
849
878
|
break;
|
|
850
879
|
case 6:
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
return
|
|
880
|
+
_context17.prev = 6;
|
|
881
|
+
_context17.t0 = _context17["catch"](1);
|
|
882
|
+
return _context17.abrupt("return", this._handleError(_context17.t0));
|
|
854
883
|
case 9:
|
|
855
884
|
case "end":
|
|
856
|
-
return
|
|
885
|
+
return _context17.stop();
|
|
857
886
|
}
|
|
858
|
-
},
|
|
887
|
+
}, _callee17, this, [[1, 6]]);
|
|
859
888
|
}));
|
|
860
|
-
function pollTaskProgress(
|
|
889
|
+
function pollTaskProgress(_x12, _x13) {
|
|
861
890
|
return _pollTaskProgress.apply(this, arguments);
|
|
862
891
|
}
|
|
863
892
|
return pollTaskProgress;
|
|
@@ -877,46 +906,46 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
877
906
|
}, {
|
|
878
907
|
key: "get",
|
|
879
908
|
value: (function () {
|
|
880
|
-
var _get = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
909
|
+
var _get = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(endpoint) {
|
|
881
910
|
var params,
|
|
882
911
|
headers,
|
|
883
912
|
response,
|
|
884
|
-
|
|
885
|
-
return _regeneratorRuntime().wrap(function
|
|
886
|
-
while (1) switch (
|
|
913
|
+
_args18 = arguments;
|
|
914
|
+
return _regeneratorRuntime().wrap(function _callee18$(_context18) {
|
|
915
|
+
while (1) switch (_context18.prev = _context18.next) {
|
|
887
916
|
case 0:
|
|
888
|
-
params =
|
|
917
|
+
params = _args18.length > 1 && _args18[1] !== undefined ? _args18[1] : {};
|
|
889
918
|
debugger;
|
|
890
|
-
|
|
919
|
+
_context18.prev = 2;
|
|
891
920
|
// Add the authToken to the headers
|
|
892
921
|
headers = {
|
|
893
922
|
authtoken: this.authtoken
|
|
894
923
|
}; // Make the GET request using Axios
|
|
895
|
-
|
|
924
|
+
_context18.next = 6;
|
|
896
925
|
return this.axios.get(endpoint, {
|
|
897
926
|
params: params,
|
|
898
927
|
headers: headers
|
|
899
928
|
});
|
|
900
929
|
case 6:
|
|
901
|
-
response =
|
|
930
|
+
response = _context18.sent;
|
|
902
931
|
if (!(response.data.ok === false)) {
|
|
903
|
-
|
|
932
|
+
_context18.next = 9;
|
|
904
933
|
break;
|
|
905
934
|
}
|
|
906
|
-
return
|
|
935
|
+
return _context18.abrupt("return", this._handleError(response));
|
|
907
936
|
case 9:
|
|
908
|
-
return
|
|
937
|
+
return _context18.abrupt("return", response.data);
|
|
909
938
|
case 12:
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
return
|
|
939
|
+
_context18.prev = 12;
|
|
940
|
+
_context18.t0 = _context18["catch"](2);
|
|
941
|
+
return _context18.abrupt("return", this._handleError(_context18.t0));
|
|
913
942
|
case 15:
|
|
914
943
|
case "end":
|
|
915
|
-
return
|
|
944
|
+
return _context18.stop();
|
|
916
945
|
}
|
|
917
|
-
},
|
|
946
|
+
}, _callee18, this, [[2, 12]]);
|
|
918
947
|
}));
|
|
919
|
-
function get(
|
|
948
|
+
function get(_x14) {
|
|
920
949
|
return _get.apply(this, arguments);
|
|
921
950
|
}
|
|
922
951
|
return get;
|
|
@@ -937,44 +966,44 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
937
966
|
}, {
|
|
938
967
|
key: "post",
|
|
939
968
|
value: (function () {
|
|
940
|
-
var _post = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
969
|
+
var _post = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(endpoint) {
|
|
941
970
|
var data,
|
|
942
971
|
headers,
|
|
943
972
|
response,
|
|
944
|
-
|
|
945
|
-
return _regeneratorRuntime().wrap(function
|
|
946
|
-
while (1) switch (
|
|
973
|
+
_args19 = arguments;
|
|
974
|
+
return _regeneratorRuntime().wrap(function _callee19$(_context19) {
|
|
975
|
+
while (1) switch (_context19.prev = _context19.next) {
|
|
947
976
|
case 0:
|
|
948
|
-
data =
|
|
949
|
-
|
|
977
|
+
data = _args19.length > 1 && _args19[1] !== undefined ? _args19[1] : {};
|
|
978
|
+
_context19.prev = 1;
|
|
950
979
|
// Add the authToken to the headers
|
|
951
980
|
headers = {
|
|
952
981
|
authtoken: this.authtoken
|
|
953
982
|
}; // Make the POST request using Axios
|
|
954
|
-
|
|
983
|
+
_context19.next = 5;
|
|
955
984
|
return this.axios.post(endpoint, data, {
|
|
956
985
|
headers: headers
|
|
957
986
|
});
|
|
958
987
|
case 5:
|
|
959
|
-
response =
|
|
988
|
+
response = _context19.sent;
|
|
960
989
|
if (!(response.data.ok === false)) {
|
|
961
|
-
|
|
990
|
+
_context19.next = 8;
|
|
962
991
|
break;
|
|
963
992
|
}
|
|
964
|
-
return
|
|
993
|
+
return _context19.abrupt("return", this._handleError(response));
|
|
965
994
|
case 8:
|
|
966
|
-
return
|
|
995
|
+
return _context19.abrupt("return", response.data);
|
|
967
996
|
case 11:
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
return
|
|
997
|
+
_context19.prev = 11;
|
|
998
|
+
_context19.t0 = _context19["catch"](1);
|
|
999
|
+
return _context19.abrupt("return", this._handleError(_context19.t0));
|
|
971
1000
|
case 14:
|
|
972
1001
|
case "end":
|
|
973
|
-
return
|
|
1002
|
+
return _context19.stop();
|
|
974
1003
|
}
|
|
975
|
-
},
|
|
1004
|
+
}, _callee19, this, [[1, 11]]);
|
|
976
1005
|
}));
|
|
977
|
-
function post(
|
|
1006
|
+
function post(_x15) {
|
|
978
1007
|
return _post.apply(this, arguments);
|
|
979
1008
|
}
|
|
980
1009
|
return post;
|
package/dist/esm/index.js
CHANGED
package/dist/esm/rbt_api.js
CHANGED
|
@@ -225,6 +225,16 @@ export default class RbtApi {
|
|
|
225
225
|
return this._handleError(e);
|
|
226
226
|
}
|
|
227
227
|
}
|
|
228
|
+
async loadFile(id) {
|
|
229
|
+
//return this.create('<@filekit.file>', dataHash);
|
|
230
|
+
try {
|
|
231
|
+
const response = await this.axios.post('/object_service/createObject', ['<@filekit.file>', id]);
|
|
232
|
+
const record = response.data;
|
|
233
|
+
return new RbtFile(record, this.axios, this.localDb);
|
|
234
|
+
} catch (e) {
|
|
235
|
+
return this._handleError(e);
|
|
236
|
+
}
|
|
237
|
+
}
|
|
228
238
|
|
|
229
239
|
/**
|
|
230
240
|
* Creates a new object of the given type.
|
package/package.json
CHANGED
package/src/index.js
CHANGED
package/src/rbt_api.js
CHANGED
|
@@ -278,6 +278,20 @@ export default class RbtApi {
|
|
|
278
278
|
}
|
|
279
279
|
}
|
|
280
280
|
|
|
281
|
+
async loadFile(id){
|
|
282
|
+
|
|
283
|
+
//return this.create('<@filekit.file>', dataHash);
|
|
284
|
+
try {
|
|
285
|
+
const response = await this.axios.post('/object_service/createObject', ['<@filekit.file>', id]);
|
|
286
|
+
const record = response.data;
|
|
287
|
+
return new RbtFile(record, this.axios, this.localDb);
|
|
288
|
+
|
|
289
|
+
} catch (e) {
|
|
290
|
+
return this._handleError(e);
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
}
|
|
294
|
+
|
|
281
295
|
|
|
282
296
|
/**
|
|
283
297
|
* Creates a new object of the given type.
|