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.
@@ -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 _callee10(params) {
305
+ var _create = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(params) {
287
306
  var data,
288
- _args10 = arguments;
289
- return _regeneratorRuntime().wrap(function _callee10$(_context10) {
290
- while (1) switch (_context10.prev = _context10.next) {
307
+ _args11 = arguments;
308
+ return _regeneratorRuntime().wrap(function _callee11$(_context11) {
309
+ while (1) switch (_context11.prev = _context11.next) {
291
310
  case 0:
292
- data = _args10.length > 1 && _args10[1] !== undefined ? _args10[1] : {};
293
- return _context10.abrupt("return", this.api.create(params, data));
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 _context10.stop();
315
+ return _context11.stop();
297
316
  }
298
- }, _callee10, this);
317
+ }, _callee11, this);
299
318
  }));
300
- function create(_x5) {
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 _callee11(type, ids, options) {
309
- return _regeneratorRuntime().wrap(function _callee11$(_context11) {
310
- while (1) switch (_context11.prev = _context11.next) {
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 _context11.abrupt("return", this.api.load(type, ids, options));
331
+ return _context12.abrupt("return", this.api.load(type, ids, options));
313
332
  case 1:
314
333
  case "end":
315
- return _context11.stop();
334
+ return _context12.stop();
316
335
  }
317
- }, _callee11, this);
336
+ }, _callee12, this);
318
337
  }));
319
- function load(_x6, _x7, _x8) {
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 _callee12(type, params) {
328
- return _regeneratorRuntime().wrap(function _callee12$(_context12) {
329
- while (1) switch (_context12.prev = _context12.next) {
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 _context12.abrupt("return", this.api.query(type, params));
350
+ return _context13.abrupt("return", this.api.query(type, params));
332
351
  case 1:
333
352
  case "end":
334
- return _context12.stop();
353
+ return _context13.stop();
335
354
  }
336
- }, _callee12, this);
355
+ }, _callee13, this);
337
356
  }));
338
- function query(_x9, _x10) {
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 _callee13(params, callbacks) {
349
- return _regeneratorRuntime().wrap(function _callee13$(_context13) {
350
- while (1) switch (_context13.prev = _context13.next) {
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 _context13.abrupt("return", this.api.runTask(params, callbacks));
371
+ return _context14.abrupt("return", this.api.runTask(params, callbacks));
353
372
  case 1:
354
373
  case "end":
355
- return _context13.stop();
374
+ return _context14.stop();
356
375
  }
357
- }, _callee13, this);
376
+ }, _callee14, this);
358
377
  }));
359
- function runTask(_x11, _x12) {
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 _callee14(params) {
368
- return _regeneratorRuntime().wrap(function _callee14$(_context14) {
369
- while (1) switch (_context14.prev = _context14.next) {
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 _context14.abrupt("return", this.api.pollTaskProgress(params));
390
+ return _context15.abrupt("return", this.api.pollTaskProgress(params));
372
391
  case 1:
373
392
  case "end":
374
- return _context14.stop();
393
+ return _context15.stop();
375
394
  }
376
- }, _callee14, this);
395
+ }, _callee15, this);
377
396
  }));
378
- function pollTaskProgress(_x13) {
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 _callee15(endpoint, params) {
389
- return _regeneratorRuntime().wrap(function _callee15$(_context15) {
390
- while (1) switch (_context15.prev = _context15.next) {
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 _context15.abrupt("return", this.api.get(endpoint, params));
411
+ return _context16.abrupt("return", this.api.get(endpoint, params));
393
412
  case 1:
394
413
  case "end":
395
- return _context15.stop();
414
+ return _context16.stop();
396
415
  }
397
- }, _callee15, this);
416
+ }, _callee16, this);
398
417
  }));
399
- function get(_x14, _x15) {
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 _callee16(endpoint, data) {
408
- return _regeneratorRuntime().wrap(function _callee16$(_context16) {
409
- while (1) switch (_context16.prev = _context16.next) {
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 _context16.abrupt("return", this.api.post(endpoint, data));
430
+ return _context17.abrupt("return", this.api.post(endpoint, data));
412
431
  case 1:
413
432
  case "end":
414
- return _context16.stop();
433
+ return _context17.stop();
415
434
  }
416
- }, _callee16, this);
435
+ }, _callee17, this);
417
436
  }));
418
- function post(_x16, _x17) {
437
+ function post(_x17, _x18) {
419
438
  return _post.apply(this, arguments);
420
439
  }
421
440
  return post;
@@ -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 _callee11(type) {
524
+ var _create = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(type) {
496
525
  var dataHash,
497
526
  response,
498
527
  record,
499
- _args11 = arguments;
500
- return _regeneratorRuntime().wrap(function _callee11$(_context11) {
501
- while (1) switch (_context11.prev = _context11.next) {
528
+ _args12 = arguments;
529
+ return _regeneratorRuntime().wrap(function _callee12$(_context12) {
530
+ while (1) switch (_context12.prev = _context12.next) {
502
531
  case 0:
503
- dataHash = _args11.length > 1 && _args11[1] !== undefined ? _args11[1] : {};
504
- _context11.prev = 1;
505
- _context11.next = 4;
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 = _context11.sent;
537
+ response = _context12.sent;
509
538
  record = response.data;
510
539
  if (dataHash) {
511
540
  record.data = dataHash;
512
541
  }
513
- return _context11.abrupt("return", new _rbt_object["default"](record, this.axios, {
542
+ return _context12.abrupt("return", new _rbt_object["default"](record, this.axios, {
514
543
  isNew: true
515
544
  }));
516
545
  case 10:
517
- _context11.prev = 10;
518
- _context11.t0 = _context11["catch"](1);
519
- return _context11.abrupt("return", this._handleError(_context11.t0));
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 _context11.stop();
551
+ return _context12.stop();
523
552
  }
524
- }, _callee11, this, [[1, 10]]);
553
+ }, _callee12, this, [[1, 10]]);
525
554
  }));
526
- function create(_x7) {
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 _callee12(type) {
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
- _args12 = arguments;
571
- return _regeneratorRuntime().wrap(function _callee12$(_context12) {
572
- while (1) switch (_context12.prev = _context12.next) {
599
+ _args13 = arguments;
600
+ return _regeneratorRuntime().wrap(function _callee13$(_context13) {
601
+ while (1) switch (_context13.prev = _context13.next) {
573
602
  case 0:
574
- params = _args12.length > 1 && _args12[1] !== undefined ? _args12[1] : {};
575
- _context12.prev = 1;
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
- _context12.next = 8;
621
+ _context13.next = 8;
593
622
  return this.axios.post('/object_service/queryObjects', [mergedParams]);
594
623
  case 8:
595
- response = _context12.sent;
624
+ response = _context13.sent;
596
625
  if (!(response.data.ok === false)) {
597
- _context12.next = 11;
626
+ _context13.next = 11;
598
627
  break;
599
628
  }
600
- return _context12.abrupt("return", this._handleError(response));
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 _context12.abrupt("return", response.data.items);
639
+ return _context13.abrupt("return", response.data.items);
611
640
  case 15:
612
- _context12.prev = 15;
613
- _context12.t0 = _context12["catch"](1);
614
- return _context12.abrupt("return", this._handleError(_context12.t0));
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 _context12.stop();
646
+ return _context13.stop();
618
647
  }
619
- }, _callee12, this, [[1, 15]]);
648
+ }, _callee13, this, [[1, 15]]);
620
649
  }));
621
- function query(_x8) {
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 _callee13(type, ids) {
667
+ var _load = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14(type, ids) {
639
668
  var params,
640
669
  mergedParams,
641
670
  res,
642
- _args13 = arguments;
643
- return _regeneratorRuntime().wrap(function _callee13$(_context13) {
644
- while (1) switch (_context13.prev = _context13.next) {
671
+ _args14 = arguments;
672
+ return _regeneratorRuntime().wrap(function _callee14$(_context14) {
673
+ while (1) switch (_context14.prev = _context14.next) {
645
674
  case 0:
646
- params = _args13.length > 2 && _args13[2] !== undefined ? _args13[2] : {};
647
- _context13.prev = 1;
675
+ params = _args14.length > 2 && _args14[2] !== undefined ? _args14[2] : {};
676
+ _context14.prev = 1;
648
677
  if (!Array.isArray(ids)) {
649
- _context13.next = 7;
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 _context13.abrupt("return", this.query(type, mergedParams));
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
- _context13.next = 10;
689
+ _context14.next = 10;
661
690
  return this.query(type, mergedParams);
662
691
  case 10:
663
- res = _context13.sent;
664
- return _context13.abrupt("return", res[0]);
692
+ res = _context14.sent;
693
+ return _context14.abrupt("return", res[0]);
665
694
  case 12:
666
- _context13.next = 17;
695
+ _context14.next = 17;
667
696
  break;
668
697
  case 14:
669
- _context13.prev = 14;
670
- _context13.t0 = _context13["catch"](1);
671
- return _context13.abrupt("return", this._handleError(_context13.t0));
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 _context13.stop();
703
+ return _context14.stop();
675
704
  }
676
- }, _callee13, this, [[1, 14]]);
705
+ }, _callee14, this, [[1, 14]]);
677
706
  }));
678
- function load(_x9, _x10) {
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 _callee14() {
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
- _args14 = arguments;
713
- return _regeneratorRuntime().wrap(function _callee14$(_context14) {
714
- while (1) switch (_context14.prev = _context14.next) {
741
+ _args15 = arguments;
742
+ return _regeneratorRuntime().wrap(function _callee15$(_context15) {
743
+ while (1) switch (_context15.prev = _context15.next) {
715
744
  case 0:
716
- params = _args14.length > 0 && _args14[0] !== undefined ? _args14[0] : {};
717
- callbacks = _args14.length > 1 && _args14[1] !== undefined ? _args14[1] : {};
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
- _context14.prev = 3;
720
- _context14.next = 6;
748
+ _context15.prev = 3;
749
+ _context15.next = 6;
721
750
  return this.post('/task_service/runChain', params);
722
751
  case 6:
723
- response = _context14.sent;
752
+ response = _context15.sent;
724
753
  if (response) {
725
- _context14.next = 9;
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
- _context14.next = 12;
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 _context14.abrupt("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
- _context14.prev = 18;
760
- _context14.t0 = _context14["catch"](3);
788
+ _context15.prev = 18;
789
+ _context15.t0 = _context15["catch"](3);
761
790
  if (typeof onError === 'function') {
762
- onError(_context14.t0);
791
+ onError(_context15.t0);
763
792
  } else {
764
- console.error('Error in runTask:', _context14.t0);
793
+ console.error('Error in runTask:', _context15.t0);
765
794
  }
766
- return _context14.abrupt("return", {
795
+ return _context15.abrupt("return", {
767
796
  ok: false,
768
797
  jobId: null,
769
798
  status: 'ERROR',
770
- error: _context14.t0.message
799
+ error: _context15.t0.message
771
800
  });
772
801
  case 22:
773
802
  case "end":
774
- return _context14.stop();
803
+ return _context15.stop();
775
804
  }
776
- }, _callee14, this, [[3, 18]]);
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 _callee16(jobId, callbacks) {
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 _callee16$(_context16) {
801
- while (1) switch (_context16.prev = _context16.next) {
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
- _context16.prev = 1;
833
+ _context17.prev = 1;
805
834
  checkProgress = /*#__PURE__*/function () {
806
- var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {
835
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {
807
836
  var response;
808
- return _regeneratorRuntime().wrap(function _callee15$(_context15) {
809
- while (1) switch (_context15.prev = _context15.next) {
837
+ return _regeneratorRuntime().wrap(function _callee16$(_context16) {
838
+ while (1) switch (_context16.prev = _context16.next) {
810
839
  case 0:
811
- _context15.next = 2;
840
+ _context16.next = 2;
812
841
  return _this2.get("/task_service/pollChainProgress", {
813
842
  jobId: jobId
814
843
  });
815
844
  case 2:
816
- response = _context15.sent;
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 _context15.stop();
868
+ return _context16.stop();
840
869
  }
841
- }, _callee15);
870
+ }, _callee16);
842
871
  }));
843
872
  return function checkProgress() {
844
873
  return _ref2.apply(this, arguments);
845
874
  };
846
875
  }();
847
876
  checkProgress();
848
- _context16.next = 9;
877
+ _context17.next = 9;
849
878
  break;
850
879
  case 6:
851
- _context16.prev = 6;
852
- _context16.t0 = _context16["catch"](1);
853
- return _context16.abrupt("return", this._handleError(_context16.t0));
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 _context16.stop();
885
+ return _context17.stop();
857
886
  }
858
- }, _callee16, this, [[1, 6]]);
887
+ }, _callee17, this, [[1, 6]]);
859
888
  }));
860
- function pollTaskProgress(_x11, _x12) {
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 _callee17(endpoint) {
909
+ var _get = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(endpoint) {
881
910
  var params,
882
911
  headers,
883
912
  response,
884
- _args17 = arguments;
885
- return _regeneratorRuntime().wrap(function _callee17$(_context17) {
886
- while (1) switch (_context17.prev = _context17.next) {
913
+ _args18 = arguments;
914
+ return _regeneratorRuntime().wrap(function _callee18$(_context18) {
915
+ while (1) switch (_context18.prev = _context18.next) {
887
916
  case 0:
888
- params = _args17.length > 1 && _args17[1] !== undefined ? _args17[1] : {};
917
+ params = _args18.length > 1 && _args18[1] !== undefined ? _args18[1] : {};
889
918
  debugger;
890
- _context17.prev = 2;
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
- _context17.next = 6;
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 = _context17.sent;
930
+ response = _context18.sent;
902
931
  if (!(response.data.ok === false)) {
903
- _context17.next = 9;
932
+ _context18.next = 9;
904
933
  break;
905
934
  }
906
- return _context17.abrupt("return", this._handleError(response));
935
+ return _context18.abrupt("return", this._handleError(response));
907
936
  case 9:
908
- return _context17.abrupt("return", response.data);
937
+ return _context18.abrupt("return", response.data);
909
938
  case 12:
910
- _context17.prev = 12;
911
- _context17.t0 = _context17["catch"](2);
912
- return _context17.abrupt("return", this._handleError(_context17.t0));
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 _context17.stop();
944
+ return _context18.stop();
916
945
  }
917
- }, _callee17, this, [[2, 12]]);
946
+ }, _callee18, this, [[2, 12]]);
918
947
  }));
919
- function get(_x13) {
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 _callee18(endpoint) {
969
+ var _post = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(endpoint) {
941
970
  var data,
942
971
  headers,
943
972
  response,
944
- _args18 = arguments;
945
- return _regeneratorRuntime().wrap(function _callee18$(_context18) {
946
- while (1) switch (_context18.prev = _context18.next) {
973
+ _args19 = arguments;
974
+ return _regeneratorRuntime().wrap(function _callee19$(_context19) {
975
+ while (1) switch (_context19.prev = _context19.next) {
947
976
  case 0:
948
- data = _args18.length > 1 && _args18[1] !== undefined ? _args18[1] : {};
949
- _context18.prev = 1;
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
- _context18.next = 5;
983
+ _context19.next = 5;
955
984
  return this.axios.post(endpoint, data, {
956
985
  headers: headers
957
986
  });
958
987
  case 5:
959
- response = _context18.sent;
988
+ response = _context19.sent;
960
989
  if (!(response.data.ok === false)) {
961
- _context18.next = 8;
990
+ _context19.next = 8;
962
991
  break;
963
992
  }
964
- return _context18.abrupt("return", this._handleError(response));
993
+ return _context19.abrupt("return", this._handleError(response));
965
994
  case 8:
966
- return _context18.abrupt("return", response.data);
995
+ return _context19.abrupt("return", response.data);
967
996
  case 11:
968
- _context18.prev = 11;
969
- _context18.t0 = _context18["catch"](1);
970
- return _context18.abrupt("return", this._handleError(_context18.t0));
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 _context18.stop();
1002
+ return _context19.stop();
974
1003
  }
975
- }, _callee18, this, [[1, 11]]);
1004
+ }, _callee19, this, [[1, 11]]);
976
1005
  }));
977
- function post(_x14) {
1006
+ function post(_x15) {
978
1007
  return _post.apply(this, arguments);
979
1008
  }
980
1009
  return post;
package/dist/esm/index.js CHANGED
@@ -96,6 +96,9 @@ export default class Roboto {
96
96
  async createFile(data = {}) {
97
97
  return this.api.createFile(data);
98
98
  }
99
+ async loadFile(id) {
100
+ return this.api.loadFile(id);
101
+ }
99
102
 
100
103
  //
101
104
  //
@@ -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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "roboto-js",
3
- "version": "1.3.11",
3
+ "version": "1.3.13",
4
4
  "type": "module",
5
5
  "description": "",
6
6
  "main": "dist/cjs/index.cjs",
package/src/index.js CHANGED
@@ -110,6 +110,9 @@ export default class Roboto{
110
110
  async createFile(data={}){
111
111
  return this.api.createFile(data);
112
112
  }
113
+ async loadFile(id){
114
+ return this.api.loadFile(id);
115
+ }
113
116
 
114
117
  //
115
118
  //
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.