roboto-js 1.4.39 → 1.4.41

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.
@@ -335,7 +335,7 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
335
335
  key: "loadCurrentUser",
336
336
  value: function () {
337
337
  var _loadCurrentUser = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
338
- var response;
338
+ var _response$user, response;
339
339
  return _regeneratorRuntime().wrap(function _callee7$(_context7) {
340
340
  while (1) switch (_context7.prev = _context7.next) {
341
341
  case 0:
@@ -347,30 +347,36 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
347
347
  return _context7.abrupt("return", this.currentUser);
348
348
  case 3:
349
349
  if (!this.authtoken) {
350
- _context7.next = 10;
350
+ _context7.next = 12;
351
351
  break;
352
352
  }
353
353
  _context7.next = 6;
354
354
  return this.refreshAuthToken(this.authtoken);
355
355
  case 6:
356
356
  response = _context7.sent;
357
+ if (response) {
358
+ _context7.next = 9;
359
+ break;
360
+ }
361
+ return _context7.abrupt("return", null);
362
+ case 9:
357
363
  this.currentUser = new _rbt_user["default"]({
358
- id: response.user.id
364
+ id: response === null || response === void 0 || (_response$user = response.user) === null || _response$user === void 0 ? void 0 : _response$user.id
359
365
  }, this.axios);
360
366
  this.currentUser.setData(response.user);
361
367
  return _context7.abrupt("return", this.currentUser);
362
- case 10:
368
+ case 12:
363
369
  this.currentUser = null;
364
370
  return _context7.abrupt("return", null);
365
- case 14:
366
- _context7.prev = 14;
371
+ case 16:
372
+ _context7.prev = 16;
367
373
  _context7.t0 = _context7["catch"](0);
368
374
  return _context7.abrupt("return", this._handleError(_context7.t0));
369
- case 17:
375
+ case 19:
370
376
  case "end":
371
377
  return _context7.stop();
372
378
  }
373
- }, _callee7, this, [[0, 14]]);
379
+ }, _callee7, this, [[0, 16]]);
374
380
  }));
375
381
  function loadCurrentUser() {
376
382
  return _loadCurrentUser.apply(this, arguments);
@@ -969,6 +975,7 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
969
975
  onProgress,
970
976
  onError,
971
977
  onStopped,
978
+ onWaiting,
972
979
  onDone,
973
980
  response,
974
981
  ok,
@@ -982,7 +989,7 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
982
989
  case 0:
983
990
  params = _args18.length > 0 && _args18[0] !== undefined ? _args18[0] : {};
984
991
  callbacks = _args18.length > 1 && _args18[1] !== undefined ? _args18[1] : {};
985
- onProgress = callbacks.onProgress, onError = callbacks.onError, onStopped = callbacks.onStopped, onDone = callbacks.onDone;
992
+ onProgress = callbacks.onProgress, onError = callbacks.onError, onStopped = callbacks.onStopped, onWaiting = callbacks.onWaiting, onDone = callbacks.onDone;
986
993
  _context18.prev = 3;
987
994
  _context18.next = 6;
988
995
  return this.post('/task_service/runChain', params);
@@ -1014,6 +1021,10 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
1014
1021
  // Provide the current progress to the callback function
1015
1022
  onStopped(response);
1016
1023
  }
1024
+ if (status === 'WAITING' && onWaiting) {
1025
+ // Provide the current progress to the callback function
1026
+ onWaiting(response);
1027
+ }
1017
1028
  if (status === 'DONE' && onDone) {
1018
1029
  // Provide the current progress to the callback function
1019
1030
  console.log('Finish (request) ', response);
@@ -1026,8 +1037,8 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
1026
1037
  message: message,
1027
1038
  output: output
1028
1039
  });
1029
- case 19:
1030
- _context18.prev = 19;
1040
+ case 20:
1041
+ _context18.prev = 20;
1031
1042
  _context18.t0 = _context18["catch"](3);
1032
1043
  if (typeof onError === 'function') {
1033
1044
  onError(_context18.t0);
@@ -1040,11 +1051,11 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
1040
1051
  status: 'ERROR',
1041
1052
  error: _context18.t0.message
1042
1053
  });
1043
- case 23:
1054
+ case 24:
1044
1055
  case "end":
1045
1056
  return _context18.stop();
1046
1057
  }
1047
- }, _callee18, this, [[3, 19]]);
1058
+ }, _callee18, this, [[3, 20]]);
1048
1059
  }));
1049
1060
  function runTask() {
1050
1061
  return _runTask.apply(this, arguments);
@@ -166,8 +166,9 @@ export default class RbtApi {
166
166
  }
167
167
  if (this.authtoken) {
168
168
  let response = await this.refreshAuthToken(this.authtoken);
169
+ if (!response) return null;
169
170
  this.currentUser = new RbtUser({
170
- id: response.user.id
171
+ id: response?.user?.id
171
172
  }, this.axios);
172
173
  this.currentUser.setData(response.user);
173
174
  return this.currentUser;
@@ -551,6 +552,7 @@ export default class RbtApi {
551
552
  onProgress,
552
553
  onError,
553
554
  onStopped,
555
+ onWaiting,
554
556
  onDone
555
557
  } = callbacks;
556
558
  try {
@@ -584,6 +586,10 @@ export default class RbtApi {
584
586
  // Provide the current progress to the callback function
585
587
  onStopped(response);
586
588
  }
589
+ if (status === 'WAITING' && onWaiting) {
590
+ // Provide the current progress to the callback function
591
+ onWaiting(response);
592
+ }
587
593
  if (status === 'DONE' && onDone) {
588
594
  // Provide the current progress to the callback function
589
595
  console.log('Finish (request) ', response);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "roboto-js",
3
- "version": "1.4.39",
3
+ "version": "1.4.41",
4
4
  "type": "module",
5
5
  "description": "",
6
6
  "main": "dist/cjs/index.cjs",
package/src/rbt_api.js CHANGED
@@ -206,7 +206,9 @@ export default class RbtApi {
206
206
  if(this.authtoken){
207
207
 
208
208
  let response = await this.refreshAuthToken(this.authtoken);
209
- this.currentUser = new RbtUser({ id: response.user.id }, this.axios);
209
+ if(!response) return null;
210
+
211
+ this.currentUser = new RbtUser({ id: response?.user?.id }, this.axios);
210
212
  this.currentUser.setData(response.user);
211
213
  return this.currentUser;
212
214
 
@@ -607,7 +609,7 @@ export default class RbtApi {
607
609
  * }
608
610
  */
609
611
  async runTask(params = {}, callbacks = {}) {
610
- const { onProgress, onError, onStopped, onDone } = callbacks;
612
+ const { onProgress, onError, onStopped, onWaiting, onDone } = callbacks;
611
613
 
612
614
  try {
613
615
  const response = await this.post('/task_service/runChain', params);
@@ -634,6 +636,10 @@ export default class RbtApi {
634
636
  // Provide the current progress to the callback function
635
637
  onStopped(response);
636
638
  }
639
+ if (status === 'WAITING' && onWaiting){
640
+ // Provide the current progress to the callback function
641
+ onWaiting(response);
642
+ }
637
643
  if (status === 'DONE' && onDone){
638
644
  // Provide the current progress to the callback function
639
645
  console.log('Finish (request) ',response);