roboto-js 1.4.42 → 1.4.44

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$user, response;
338
+ var response, _response$user;
339
339
  return _regeneratorRuntime().wrap(function _callee7$(_context7) {
340
340
  while (1) switch (_context7.prev = _context7.next) {
341
341
  case 0:
@@ -347,7 +347,7 @@ 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 = 12;
350
+ _context7.next = 13;
351
351
  break;
352
352
  }
353
353
  _context7.next = 6;
@@ -360,23 +360,26 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
360
360
  }
361
361
  return _context7.abrupt("return", null);
362
362
  case 9:
363
- this.currentUser = new _rbt_user["default"]({
364
- id: response === null || response === void 0 || (_response$user = response.user) === null || _response$user === void 0 ? void 0 : _response$user.id
365
- }, this.axios);
366
- this.currentUser.setData(response.user);
363
+ if (response !== null && response !== void 0 && response.user) {
364
+ this.currentUser = new _rbt_user["default"]({
365
+ id: response === null || response === void 0 || (_response$user = response.user) === null || _response$user === void 0 ? void 0 : _response$user.id
366
+ }, this.axios);
367
+ this.currentUser.setData(response.user);
368
+ }
367
369
  return _context7.abrupt("return", this.currentUser);
368
- case 12:
370
+ case 13:
369
371
  this.currentUser = null;
372
+ case 14:
370
373
  return _context7.abrupt("return", null);
371
- case 16:
372
- _context7.prev = 16;
374
+ case 17:
375
+ _context7.prev = 17;
373
376
  _context7.t0 = _context7["catch"](0);
374
377
  return _context7.abrupt("return", this._handleError(_context7.t0));
375
- case 19:
378
+ case 20:
376
379
  case "end":
377
380
  return _context7.stop();
378
381
  }
379
- }, _callee7, this, [[0, 16]]);
382
+ }, _callee7, this, [[0, 17]]);
380
383
  }));
381
384
  function loadCurrentUser() {
382
385
  return _loadCurrentUser.apply(this, arguments);
@@ -1117,11 +1120,11 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
1117
1120
  value: (function () {
1118
1121
  var _pollTaskProgress = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(jobId, callbacks) {
1119
1122
  var _this3 = this;
1120
- var onProgress, onError, onStopped, onDone, checkProgress;
1123
+ var onProgress, onError, onStopped, onWaiting, onDone, checkProgress;
1121
1124
  return _regeneratorRuntime().wrap(function _callee21$(_context21) {
1122
1125
  while (1) switch (_context21.prev = _context21.next) {
1123
1126
  case 0:
1124
- onProgress = callbacks.onProgress, onError = callbacks.onError, onStopped = callbacks.onStopped, onDone = callbacks.onDone;
1127
+ onProgress = callbacks.onProgress, onError = callbacks.onError, onStopped = callbacks.onStopped, onWaiting = callbacks.onWaiting, onDone = callbacks.onDone;
1125
1128
  _context21.prev = 1;
1126
1129
  checkProgress = /*#__PURE__*/function () {
1127
1130
  var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20() {
@@ -1149,6 +1152,10 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
1149
1152
  // Provide the current progress to the callback function
1150
1153
  onStopped(response);
1151
1154
  }
1155
+ if (response.status === 'WAITING' && onWaiting) {
1156
+ // Provide the current progress to the callback function
1157
+ onWaiting(response);
1158
+ }
1152
1159
 
1153
1160
  // Provide the current progress to the callback function
1154
1161
  if (response.status == 'RUNNING') {
@@ -1159,7 +1166,7 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
1159
1166
  if (['RUNNING', 'STOPPING'].includes(response.status)) {
1160
1167
  setTimeout(checkProgress, 2000); // Poll every 2 seconds
1161
1168
  }
1162
- case 8:
1169
+ case 9:
1163
1170
  case "end":
1164
1171
  return _context20.stop();
1165
1172
  }
@@ -167,16 +167,18 @@ export default class RbtApi {
167
167
  if (this.authtoken) {
168
168
  let response = await this.refreshAuthToken(this.authtoken);
169
169
  if (!response) return null;
170
- this.currentUser = new RbtUser({
171
- id: response?.user?.id
172
- }, this.axios);
173
- this.currentUser.setData(response.user);
170
+ if (response?.user) {
171
+ this.currentUser = new RbtUser({
172
+ id: response?.user?.id
173
+ }, this.axios);
174
+ this.currentUser.setData(response.user);
175
+ }
174
176
  return this.currentUser;
175
-
176
177
  //this.currentOrg = new RbtObject(response.organization, this.axios);
177
178
  //this.currentOrg.type = '<@iac.organization>';
179
+ } else {
180
+ this.currentUser = null;
178
181
  }
179
- this.currentUser = null;
180
182
  return null;
181
183
  } catch (e) {
182
184
  return this._handleError(e);
@@ -644,6 +646,7 @@ export default class RbtApi {
644
646
  onProgress,
645
647
  onError,
646
648
  onStopped,
649
+ onWaiting,
647
650
  onDone
648
651
  } = callbacks;
649
652
  try {
@@ -666,6 +669,10 @@ export default class RbtApi {
666
669
  // Provide the current progress to the callback function
667
670
  onStopped(response);
668
671
  }
672
+ if (response.status === 'WAITING' && onWaiting) {
673
+ // Provide the current progress to the callback function
674
+ onWaiting(response);
675
+ }
669
676
 
670
677
  // Provide the current progress to the callback function
671
678
  if (response.status == 'RUNNING') {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "roboto-js",
3
- "version": "1.4.42",
3
+ "version": "1.4.44",
4
4
  "type": "module",
5
5
  "description": "",
6
6
  "main": "dist/cjs/index.cjs",
package/src/rbt_api.js CHANGED
@@ -208,16 +208,21 @@ export default class RbtApi {
208
208
  let response = await this.refreshAuthToken(this.authtoken);
209
209
  if(!response) return null;
210
210
 
211
- this.currentUser = new RbtUser({ id: response?.user?.id }, this.axios);
212
- this.currentUser.setData(response.user);
213
- return this.currentUser;
211
+ if(response?.user){
212
+
213
+ this.currentUser = new RbtUser({ id: response?.user?.id }, this.axios);
214
+ this.currentUser.setData(response.user);
215
+
216
+ }
214
217
 
218
+ return this.currentUser;
215
219
  //this.currentOrg = new RbtObject(response.organization, this.axios);
216
220
  //this.currentOrg.type = '<@iac.organization>';
217
221
 
218
222
  }
219
-
220
- this.currentUser = null;
223
+ else{
224
+ this.currentUser = null;
225
+ }
221
226
  return null;
222
227
 
223
228
  }
@@ -689,7 +694,7 @@ export default class RbtApi {
689
694
  * the task is completed or an error occurs.
690
695
  */
691
696
  async pollTaskProgress(jobId, callbacks) {
692
- const { onProgress, onError, onStopped, onDone } = callbacks;
697
+ const { onProgress, onError, onStopped, onWaiting, onDone } = callbacks;
693
698
  try {
694
699
  const checkProgress = async () => {
695
700
  const response = await this.get(`/task_service/pollChainProgress`, { jobId: jobId });
@@ -708,6 +713,10 @@ export default class RbtApi {
708
713
  // Provide the current progress to the callback function
709
714
  onStopped(response);
710
715
  }
716
+ if (response.status === 'WAITING' && onWaiting){
717
+ // Provide the current progress to the callback function
718
+ onWaiting(response);
719
+ }
711
720
 
712
721
  // Provide the current progress to the callback function
713
722
  if(response.status == 'RUNNING'){