roboto-js 1.1.1 → 1.1.3
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 +86 -67
- package/dist/cjs/rbt_api.cjs +215 -167
- package/dist/cjs/rbt_object.cjs +20 -2
- package/dist/esm/index.js +86 -67
- package/dist/esm/rbt_api.js +215 -167
- package/dist/esm/rbt_object.js +20 -2
- package/package.json +1 -1
- package/src/index.js +3 -0
- package/src/rbt_api.js +32 -2
- package/src/rbt_object.js +20 -3
package/dist/cjs/rbt_api.cjs
CHANGED
|
@@ -129,37 +129,84 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
129
129
|
return login;
|
|
130
130
|
}()
|
|
131
131
|
}, {
|
|
132
|
-
key: "
|
|
132
|
+
key: "logout",
|
|
133
133
|
value: function () {
|
|
134
|
-
var
|
|
135
|
-
var
|
|
134
|
+
var _logout = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
|
|
135
|
+
var response;
|
|
136
136
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
137
137
|
while (1) switch (_context3.prev = _context3.next) {
|
|
138
|
+
case 0:
|
|
139
|
+
_context3.prev = 0;
|
|
140
|
+
_context3.next = 3;
|
|
141
|
+
return this.axios.post('/user_service/logoutUser');
|
|
142
|
+
case 3:
|
|
143
|
+
response = _context3.sent;
|
|
144
|
+
if (!(response.data.ok === false)) {
|
|
145
|
+
_context3.next = 6;
|
|
146
|
+
break;
|
|
147
|
+
}
|
|
148
|
+
return _context3.abrupt("return", this._handleError(response));
|
|
149
|
+
case 6:
|
|
150
|
+
// Clear the iac_session and remove the auth token from axios headers
|
|
151
|
+
this.iac_session = null;
|
|
152
|
+
if (this.axios.defaults.headers.common['authtoken']) {
|
|
153
|
+
delete this.axios.defaults.headers.common['authtoken'];
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
// Clear localStorage if it's being used
|
|
157
|
+
if (typeof localStorage !== 'undefined') {
|
|
158
|
+
localStorage.removeItem('authtoken');
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
// Return some kind of success response or the response from the server
|
|
162
|
+
return _context3.abrupt("return", response.data);
|
|
163
|
+
case 12:
|
|
164
|
+
_context3.prev = 12;
|
|
165
|
+
_context3.t0 = _context3["catch"](0);
|
|
166
|
+
this._handleError(_context3.t0);
|
|
167
|
+
case 15:
|
|
168
|
+
case "end":
|
|
169
|
+
return _context3.stop();
|
|
170
|
+
}
|
|
171
|
+
}, _callee3, this, [[0, 12]]);
|
|
172
|
+
}));
|
|
173
|
+
function logout() {
|
|
174
|
+
return _logout.apply(this, arguments);
|
|
175
|
+
}
|
|
176
|
+
return logout;
|
|
177
|
+
}()
|
|
178
|
+
}, {
|
|
179
|
+
key: "loadCurrentUser",
|
|
180
|
+
value: function () {
|
|
181
|
+
var _loadCurrentUser = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
|
|
182
|
+
var params, _response$data, response, userData, User;
|
|
183
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
184
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
138
185
|
case 0:
|
|
139
186
|
// TODO - get the actual user from the session
|
|
140
187
|
params = {
|
|
141
188
|
id: 'superuser_tom'
|
|
142
189
|
};
|
|
143
|
-
|
|
144
|
-
|
|
190
|
+
_context4.prev = 1;
|
|
191
|
+
_context4.next = 4;
|
|
145
192
|
return this.axios.post('/user_service/loadUser', [params]);
|
|
146
193
|
case 4:
|
|
147
|
-
response =
|
|
194
|
+
response = _context4.sent;
|
|
148
195
|
userData = response === null || response === void 0 || (_response$data = response.data) === null || _response$data === void 0 ? void 0 : _response$data.user;
|
|
149
196
|
User = new _rbt_user["default"]({
|
|
150
197
|
id: userData.id
|
|
151
198
|
}, this.axios);
|
|
152
199
|
User.setData(userData);
|
|
153
|
-
return
|
|
200
|
+
return _context4.abrupt("return", User);
|
|
154
201
|
case 11:
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
return
|
|
202
|
+
_context4.prev = 11;
|
|
203
|
+
_context4.t0 = _context4["catch"](1);
|
|
204
|
+
return _context4.abrupt("return", this._handleError(_context4.t0));
|
|
158
205
|
case 14:
|
|
159
206
|
case "end":
|
|
160
|
-
return
|
|
207
|
+
return _context4.stop();
|
|
161
208
|
}
|
|
162
|
-
},
|
|
209
|
+
}, _callee4, this, [[1, 11]]);
|
|
163
210
|
}));
|
|
164
211
|
function loadCurrentUser() {
|
|
165
212
|
return _loadCurrentUser.apply(this, arguments);
|
|
@@ -169,26 +216,26 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
169
216
|
}, {
|
|
170
217
|
key: "refreshAuthToken",
|
|
171
218
|
value: function () {
|
|
172
|
-
var _refreshAuthToken = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
219
|
+
var _refreshAuthToken = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(authtoken) {
|
|
173
220
|
var response;
|
|
174
|
-
return _regeneratorRuntime().wrap(function
|
|
175
|
-
while (1) switch (
|
|
221
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
222
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
176
223
|
case 0:
|
|
177
|
-
|
|
178
|
-
|
|
224
|
+
_context5.prev = 0;
|
|
225
|
+
_context5.next = 3;
|
|
179
226
|
return this.axios.post('/user_service/refreshAuthToken', [authtoken]);
|
|
180
227
|
case 3:
|
|
181
|
-
response =
|
|
182
|
-
return
|
|
228
|
+
response = _context5.sent;
|
|
229
|
+
return _context5.abrupt("return", response.data);
|
|
183
230
|
case 7:
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
this._handleError(
|
|
231
|
+
_context5.prev = 7;
|
|
232
|
+
_context5.t0 = _context5["catch"](0);
|
|
233
|
+
this._handleError(_context5.t0);
|
|
187
234
|
case 10:
|
|
188
235
|
case "end":
|
|
189
|
-
return
|
|
236
|
+
return _context5.stop();
|
|
190
237
|
}
|
|
191
|
-
},
|
|
238
|
+
}, _callee5, this, [[0, 7]]);
|
|
192
239
|
}));
|
|
193
240
|
function refreshAuthToken(_x2) {
|
|
194
241
|
return _refreshAuthToken.apply(this, arguments);
|
|
@@ -205,34 +252,35 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
205
252
|
}, {
|
|
206
253
|
key: "registerUser",
|
|
207
254
|
value: function () {
|
|
208
|
-
var _registerUser = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
255
|
+
var _registerUser = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
|
|
209
256
|
var dataHash,
|
|
210
257
|
response,
|
|
211
258
|
record,
|
|
212
|
-
|
|
213
|
-
return _regeneratorRuntime().wrap(function
|
|
214
|
-
while (1) switch (
|
|
259
|
+
_args6 = arguments;
|
|
260
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
261
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
215
262
|
case 0:
|
|
216
|
-
dataHash =
|
|
217
|
-
|
|
218
|
-
|
|
263
|
+
dataHash = _args6.length > 0 && _args6[0] !== undefined ? _args6[0] : {};
|
|
264
|
+
_context6.prev = 1;
|
|
265
|
+
_context6.next = 4;
|
|
219
266
|
return this.axios.post('/user_service/registerUser', [dataHash]);
|
|
220
267
|
case 4:
|
|
221
|
-
response =
|
|
268
|
+
response = _context6.sent;
|
|
222
269
|
record = response.data;
|
|
223
270
|
if (dataHash) {
|
|
224
271
|
record.data = dataHash;
|
|
225
272
|
}
|
|
226
|
-
return
|
|
273
|
+
return _context6.abrupt("return", new _rbt_user["default"](record, this.axios));
|
|
227
274
|
case 10:
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
275
|
+
_context6.prev = 10;
|
|
276
|
+
_context6.t0 = _context6["catch"](1);
|
|
277
|
+
debugger;
|
|
278
|
+
return _context6.abrupt("return", this._handleError(_context6.t0));
|
|
279
|
+
case 14:
|
|
232
280
|
case "end":
|
|
233
|
-
return
|
|
281
|
+
return _context6.stop();
|
|
234
282
|
}
|
|
235
|
-
},
|
|
283
|
+
}, _callee6, this, [[1, 10]]);
|
|
236
284
|
}));
|
|
237
285
|
function registerUser() {
|
|
238
286
|
return _registerUser.apply(this, arguments);
|
|
@@ -249,30 +297,30 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
249
297
|
}, {
|
|
250
298
|
key: "createFile",
|
|
251
299
|
value: function () {
|
|
252
|
-
var _createFile = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
300
|
+
var _createFile = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(dataHash) {
|
|
253
301
|
var response, record;
|
|
254
|
-
return _regeneratorRuntime().wrap(function
|
|
255
|
-
while (1) switch (
|
|
302
|
+
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
303
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
256
304
|
case 0:
|
|
257
|
-
|
|
258
|
-
|
|
305
|
+
_context7.prev = 0;
|
|
306
|
+
_context7.next = 3;
|
|
259
307
|
return this.axios.post('/object_service/createObject', ['<@filekit.file>', dataHash]);
|
|
260
308
|
case 3:
|
|
261
|
-
response =
|
|
309
|
+
response = _context7.sent;
|
|
262
310
|
record = response.data;
|
|
263
311
|
if (dataHash) {
|
|
264
312
|
record.data = dataHash;
|
|
265
313
|
}
|
|
266
|
-
return
|
|
314
|
+
return _context7.abrupt("return", new _rbt_file["default"](record, this.axios, this.localDb));
|
|
267
315
|
case 9:
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
return
|
|
316
|
+
_context7.prev = 9;
|
|
317
|
+
_context7.t0 = _context7["catch"](0);
|
|
318
|
+
return _context7.abrupt("return", this._handleError(_context7.t0));
|
|
271
319
|
case 12:
|
|
272
320
|
case "end":
|
|
273
|
-
return
|
|
321
|
+
return _context7.stop();
|
|
274
322
|
}
|
|
275
|
-
},
|
|
323
|
+
}, _callee7, this, [[0, 9]]);
|
|
276
324
|
}));
|
|
277
325
|
function createFile(_x3) {
|
|
278
326
|
return _createFile.apply(this, arguments);
|
|
@@ -289,36 +337,36 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
289
337
|
}, {
|
|
290
338
|
key: "create",
|
|
291
339
|
value: function () {
|
|
292
|
-
var _create = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
340
|
+
var _create = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(type) {
|
|
293
341
|
var dataHash,
|
|
294
342
|
response,
|
|
295
343
|
record,
|
|
296
|
-
|
|
297
|
-
return _regeneratorRuntime().wrap(function
|
|
298
|
-
while (1) switch (
|
|
344
|
+
_args8 = arguments;
|
|
345
|
+
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
|
|
346
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
299
347
|
case 0:
|
|
300
|
-
dataHash =
|
|
301
|
-
|
|
302
|
-
|
|
348
|
+
dataHash = _args8.length > 1 && _args8[1] !== undefined ? _args8[1] : {};
|
|
349
|
+
_context8.prev = 1;
|
|
350
|
+
_context8.next = 4;
|
|
303
351
|
return this.axios.post('/object_service/createObject', [type, dataHash]);
|
|
304
352
|
case 4:
|
|
305
|
-
response =
|
|
353
|
+
response = _context8.sent;
|
|
306
354
|
record = response.data;
|
|
307
355
|
if (dataHash) {
|
|
308
356
|
record.data = dataHash;
|
|
309
357
|
}
|
|
310
|
-
return
|
|
358
|
+
return _context8.abrupt("return", new _rbt_object["default"](record, this.axios, {
|
|
311
359
|
isNew: true
|
|
312
360
|
}));
|
|
313
361
|
case 10:
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
return
|
|
362
|
+
_context8.prev = 10;
|
|
363
|
+
_context8.t0 = _context8["catch"](1);
|
|
364
|
+
return _context8.abrupt("return", this._handleError(_context8.t0));
|
|
317
365
|
case 13:
|
|
318
366
|
case "end":
|
|
319
|
-
return
|
|
367
|
+
return _context8.stop();
|
|
320
368
|
}
|
|
321
|
-
},
|
|
369
|
+
}, _callee8, this, [[1, 10]]);
|
|
322
370
|
}));
|
|
323
371
|
function create(_x4) {
|
|
324
372
|
return _create.apply(this, arguments);
|
|
@@ -356,19 +404,19 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
356
404
|
}, {
|
|
357
405
|
key: "query",
|
|
358
406
|
value: function () {
|
|
359
|
-
var _query = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
407
|
+
var _query = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(type) {
|
|
360
408
|
var _this = this;
|
|
361
409
|
var params,
|
|
362
410
|
defaultOrderBy,
|
|
363
411
|
defaultLimit,
|
|
364
412
|
mergedParams,
|
|
365
413
|
response,
|
|
366
|
-
|
|
367
|
-
return _regeneratorRuntime().wrap(function
|
|
368
|
-
while (1) switch (
|
|
414
|
+
_args9 = arguments;
|
|
415
|
+
return _regeneratorRuntime().wrap(function _callee9$(_context9) {
|
|
416
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
369
417
|
case 0:
|
|
370
|
-
params =
|
|
371
|
-
|
|
418
|
+
params = _args9.length > 1 && _args9[1] !== undefined ? _args9[1] : {};
|
|
419
|
+
_context9.prev = 1;
|
|
372
420
|
params.type = type;
|
|
373
421
|
|
|
374
422
|
// Default ordering and pagination
|
|
@@ -385,15 +433,15 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
385
433
|
}
|
|
386
434
|
}; // Merge defaults with provided params
|
|
387
435
|
mergedParams = _objectSpread(_objectSpread(_objectSpread({}, defaultOrderBy), defaultLimit), params);
|
|
388
|
-
|
|
436
|
+
_context9.next = 8;
|
|
389
437
|
return this.axios.post('/object_service/queryObjects', [mergedParams]);
|
|
390
438
|
case 8:
|
|
391
|
-
response =
|
|
439
|
+
response = _context9.sent;
|
|
392
440
|
if (!(response.data.ok === false)) {
|
|
393
|
-
|
|
441
|
+
_context9.next = 11;
|
|
394
442
|
break;
|
|
395
443
|
}
|
|
396
|
-
return
|
|
444
|
+
return _context9.abrupt("return", this._handleError(response));
|
|
397
445
|
case 11:
|
|
398
446
|
// Process items into RbtObject instances
|
|
399
447
|
if (Array.isArray(response.data.items)) {
|
|
@@ -403,16 +451,16 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
403
451
|
});
|
|
404
452
|
});
|
|
405
453
|
}
|
|
406
|
-
return
|
|
454
|
+
return _context9.abrupt("return", response.data.items);
|
|
407
455
|
case 15:
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
return
|
|
456
|
+
_context9.prev = 15;
|
|
457
|
+
_context9.t0 = _context9["catch"](1);
|
|
458
|
+
return _context9.abrupt("return", this._handleError(_context9.t0));
|
|
411
459
|
case 18:
|
|
412
460
|
case "end":
|
|
413
|
-
return
|
|
461
|
+
return _context9.stop();
|
|
414
462
|
}
|
|
415
|
-
},
|
|
463
|
+
}, _callee9, this, [[1, 15]]);
|
|
416
464
|
}));
|
|
417
465
|
function query(_x5) {
|
|
418
466
|
return _query.apply(this, arguments);
|
|
@@ -430,45 +478,45 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
430
478
|
}, {
|
|
431
479
|
key: "load",
|
|
432
480
|
value: function () {
|
|
433
|
-
var _load = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
481
|
+
var _load = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(type, ids) {
|
|
434
482
|
var params,
|
|
435
483
|
mergedParams,
|
|
436
484
|
res,
|
|
437
|
-
|
|
438
|
-
return _regeneratorRuntime().wrap(function
|
|
439
|
-
while (1) switch (
|
|
485
|
+
_args10 = arguments;
|
|
486
|
+
return _regeneratorRuntime().wrap(function _callee10$(_context10) {
|
|
487
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
440
488
|
case 0:
|
|
441
|
-
params =
|
|
442
|
-
|
|
489
|
+
params = _args10.length > 2 && _args10[2] !== undefined ? _args10[2] : {};
|
|
490
|
+
_context10.prev = 1;
|
|
443
491
|
if (!Array.isArray(ids)) {
|
|
444
|
-
|
|
492
|
+
_context10.next = 7;
|
|
445
493
|
break;
|
|
446
494
|
}
|
|
447
495
|
mergedParams = _objectSpread(_objectSpread({}, params), {}, {
|
|
448
496
|
where: "id IN (" + ids.join(',') + ")"
|
|
449
497
|
});
|
|
450
|
-
return
|
|
498
|
+
return _context10.abrupt("return", this.query(type, mergedParams));
|
|
451
499
|
case 7:
|
|
452
500
|
mergedParams = _objectSpread(_objectSpread({}, params), {}, {
|
|
453
501
|
where: "id=" + ids
|
|
454
502
|
});
|
|
455
|
-
|
|
503
|
+
_context10.next = 10;
|
|
456
504
|
return this.query(type, mergedParams);
|
|
457
505
|
case 10:
|
|
458
|
-
res =
|
|
459
|
-
return
|
|
506
|
+
res = _context10.sent;
|
|
507
|
+
return _context10.abrupt("return", res[0]);
|
|
460
508
|
case 12:
|
|
461
|
-
|
|
509
|
+
_context10.next = 17;
|
|
462
510
|
break;
|
|
463
511
|
case 14:
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
return
|
|
512
|
+
_context10.prev = 14;
|
|
513
|
+
_context10.t0 = _context10["catch"](1);
|
|
514
|
+
return _context10.abrupt("return", this._handleError(_context10.t0));
|
|
467
515
|
case 17:
|
|
468
516
|
case "end":
|
|
469
|
-
return
|
|
517
|
+
return _context10.stop();
|
|
470
518
|
}
|
|
471
|
-
},
|
|
519
|
+
}, _callee10, this, [[1, 14]]);
|
|
472
520
|
}));
|
|
473
521
|
function load(_x6, _x7) {
|
|
474
522
|
return _load.apply(this, arguments);
|
|
@@ -491,7 +539,7 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
491
539
|
}, {
|
|
492
540
|
key: "runTask",
|
|
493
541
|
value: function () {
|
|
494
|
-
var _runTask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
542
|
+
var _runTask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {
|
|
495
543
|
var params,
|
|
496
544
|
callbacks,
|
|
497
545
|
onProgress,
|
|
@@ -503,20 +551,20 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
503
551
|
status,
|
|
504
552
|
message,
|
|
505
553
|
output,
|
|
506
|
-
|
|
507
|
-
return _regeneratorRuntime().wrap(function
|
|
508
|
-
while (1) switch (
|
|
554
|
+
_args11 = arguments;
|
|
555
|
+
return _regeneratorRuntime().wrap(function _callee11$(_context11) {
|
|
556
|
+
while (1) switch (_context11.prev = _context11.next) {
|
|
509
557
|
case 0:
|
|
510
|
-
params =
|
|
511
|
-
callbacks =
|
|
558
|
+
params = _args11.length > 0 && _args11[0] !== undefined ? _args11[0] : {};
|
|
559
|
+
callbacks = _args11.length > 1 && _args11[1] !== undefined ? _args11[1] : {};
|
|
512
560
|
onProgress = callbacks.onProgress, onError = callbacks.onError, onFinish = callbacks.onFinish;
|
|
513
|
-
|
|
514
|
-
|
|
561
|
+
_context11.prev = 3;
|
|
562
|
+
_context11.next = 6;
|
|
515
563
|
return this.post('http://localhost:3004/runChain', params);
|
|
516
564
|
case 6:
|
|
517
|
-
response =
|
|
565
|
+
response = _context11.sent;
|
|
518
566
|
if (response) {
|
|
519
|
-
|
|
567
|
+
_context11.next = 9;
|
|
520
568
|
break;
|
|
521
569
|
}
|
|
522
570
|
throw new Error('Invalid server response');
|
|
@@ -524,7 +572,7 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
524
572
|
// Validate response structure
|
|
525
573
|
ok = response.ok, jobId = response.jobId, status = response.status, message = response.message, output = response.output;
|
|
526
574
|
if (!(!ok || typeof jobId !== 'string' || typeof status !== 'string')) {
|
|
527
|
-
|
|
575
|
+
_context11.next = 12;
|
|
528
576
|
break;
|
|
529
577
|
}
|
|
530
578
|
throw new Error('Invalid response structure');
|
|
@@ -542,7 +590,7 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
542
590
|
console.log('Finish (request) ', response);
|
|
543
591
|
onFinish(response);
|
|
544
592
|
}
|
|
545
|
-
return
|
|
593
|
+
return _context11.abrupt("return", {
|
|
546
594
|
ok: ok,
|
|
547
595
|
jobId: jobId,
|
|
548
596
|
status: status,
|
|
@@ -550,24 +598,24 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
550
598
|
output: output
|
|
551
599
|
});
|
|
552
600
|
case 18:
|
|
553
|
-
|
|
554
|
-
|
|
601
|
+
_context11.prev = 18;
|
|
602
|
+
_context11.t0 = _context11["catch"](3);
|
|
555
603
|
if (typeof onError === 'function') {
|
|
556
|
-
onError(
|
|
604
|
+
onError(_context11.t0);
|
|
557
605
|
} else {
|
|
558
|
-
console.error('Error in runTask:',
|
|
606
|
+
console.error('Error in runTask:', _context11.t0);
|
|
559
607
|
}
|
|
560
|
-
return
|
|
608
|
+
return _context11.abrupt("return", {
|
|
561
609
|
ok: false,
|
|
562
610
|
jobId: null,
|
|
563
611
|
status: 'ERROR',
|
|
564
|
-
error:
|
|
612
|
+
error: _context11.t0.message
|
|
565
613
|
});
|
|
566
614
|
case 22:
|
|
567
615
|
case "end":
|
|
568
|
-
return
|
|
616
|
+
return _context11.stop();
|
|
569
617
|
}
|
|
570
|
-
},
|
|
618
|
+
}, _callee11, this, [[3, 18]]);
|
|
571
619
|
}));
|
|
572
620
|
function runTask() {
|
|
573
621
|
return _runTask.apply(this, arguments);
|
|
@@ -587,26 +635,26 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
587
635
|
}, {
|
|
588
636
|
key: "pollTaskProgress",
|
|
589
637
|
value: function () {
|
|
590
|
-
var _pollTaskProgress = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
638
|
+
var _pollTaskProgress = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(jobId, callbacks) {
|
|
591
639
|
var _this2 = this;
|
|
592
640
|
var onProgress, onError, onFinish, checkProgress;
|
|
593
|
-
return _regeneratorRuntime().wrap(function
|
|
594
|
-
while (1) switch (
|
|
641
|
+
return _regeneratorRuntime().wrap(function _callee13$(_context13) {
|
|
642
|
+
while (1) switch (_context13.prev = _context13.next) {
|
|
595
643
|
case 0:
|
|
596
644
|
onProgress = callbacks.onProgress, onError = callbacks.onError, onFinish = callbacks.onFinish;
|
|
597
|
-
|
|
645
|
+
_context13.prev = 1;
|
|
598
646
|
checkProgress = /*#__PURE__*/function () {
|
|
599
|
-
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
647
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
|
|
600
648
|
var response;
|
|
601
|
-
return _regeneratorRuntime().wrap(function
|
|
602
|
-
while (1) switch (
|
|
649
|
+
return _regeneratorRuntime().wrap(function _callee12$(_context12) {
|
|
650
|
+
while (1) switch (_context12.prev = _context12.next) {
|
|
603
651
|
case 0:
|
|
604
|
-
|
|
652
|
+
_context12.next = 2;
|
|
605
653
|
return _this2.get("http://localhost:3004/pollChainProgress", {
|
|
606
654
|
jobId: jobId
|
|
607
655
|
});
|
|
608
656
|
case 2:
|
|
609
|
-
response =
|
|
657
|
+
response = _context12.sent;
|
|
610
658
|
// If the task is still in progress, start polling for updates
|
|
611
659
|
if (response.status === 'DONE' && onFinish) {
|
|
612
660
|
// Provide the current progress to the callback function
|
|
@@ -629,26 +677,26 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
629
677
|
}
|
|
630
678
|
case 7:
|
|
631
679
|
case "end":
|
|
632
|
-
return
|
|
680
|
+
return _context12.stop();
|
|
633
681
|
}
|
|
634
|
-
},
|
|
682
|
+
}, _callee12);
|
|
635
683
|
}));
|
|
636
684
|
return function checkProgress() {
|
|
637
685
|
return _ref2.apply(this, arguments);
|
|
638
686
|
};
|
|
639
687
|
}();
|
|
640
688
|
checkProgress();
|
|
641
|
-
|
|
689
|
+
_context13.next = 9;
|
|
642
690
|
break;
|
|
643
691
|
case 6:
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
return
|
|
692
|
+
_context13.prev = 6;
|
|
693
|
+
_context13.t0 = _context13["catch"](1);
|
|
694
|
+
return _context13.abrupt("return", this._handleError(_context13.t0));
|
|
647
695
|
case 9:
|
|
648
696
|
case "end":
|
|
649
|
-
return
|
|
697
|
+
return _context13.stop();
|
|
650
698
|
}
|
|
651
|
-
},
|
|
699
|
+
}, _callee13, this, [[1, 6]]);
|
|
652
700
|
}));
|
|
653
701
|
function pollTaskProgress(_x8, _x9) {
|
|
654
702
|
return _pollTaskProgress.apply(this, arguments);
|
|
@@ -669,43 +717,43 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
669
717
|
}, {
|
|
670
718
|
key: "get",
|
|
671
719
|
value: function () {
|
|
672
|
-
var _get = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
720
|
+
var _get = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14(endpoint) {
|
|
673
721
|
var params,
|
|
674
722
|
headers,
|
|
675
723
|
response,
|
|
676
|
-
|
|
677
|
-
return _regeneratorRuntime().wrap(function
|
|
678
|
-
while (1) switch (
|
|
724
|
+
_args14 = arguments;
|
|
725
|
+
return _regeneratorRuntime().wrap(function _callee14$(_context14) {
|
|
726
|
+
while (1) switch (_context14.prev = _context14.next) {
|
|
679
727
|
case 0:
|
|
680
|
-
params =
|
|
681
|
-
|
|
728
|
+
params = _args14.length > 1 && _args14[1] !== undefined ? _args14[1] : {};
|
|
729
|
+
_context14.prev = 1;
|
|
682
730
|
// Add the authToken to the headers
|
|
683
731
|
headers = {
|
|
684
732
|
authtoken: this.authtoken
|
|
685
733
|
}; // Make the GET request using Axios
|
|
686
|
-
|
|
734
|
+
_context14.next = 5;
|
|
687
735
|
return this.axios.get(endpoint, {
|
|
688
736
|
params: params,
|
|
689
737
|
headers: headers
|
|
690
738
|
});
|
|
691
739
|
case 5:
|
|
692
|
-
response =
|
|
740
|
+
response = _context14.sent;
|
|
693
741
|
if (!(response.data.ok === false)) {
|
|
694
|
-
|
|
742
|
+
_context14.next = 8;
|
|
695
743
|
break;
|
|
696
744
|
}
|
|
697
|
-
return
|
|
745
|
+
return _context14.abrupt("return", this._handleError(response));
|
|
698
746
|
case 8:
|
|
699
|
-
return
|
|
747
|
+
return _context14.abrupt("return", response.data);
|
|
700
748
|
case 11:
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
return
|
|
749
|
+
_context14.prev = 11;
|
|
750
|
+
_context14.t0 = _context14["catch"](1);
|
|
751
|
+
return _context14.abrupt("return", this._handleError(_context14.t0));
|
|
704
752
|
case 14:
|
|
705
753
|
case "end":
|
|
706
|
-
return
|
|
754
|
+
return _context14.stop();
|
|
707
755
|
}
|
|
708
|
-
},
|
|
756
|
+
}, _callee14, this, [[1, 11]]);
|
|
709
757
|
}));
|
|
710
758
|
function get(_x10) {
|
|
711
759
|
return _get.apply(this, arguments);
|
|
@@ -727,42 +775,42 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
727
775
|
}, {
|
|
728
776
|
key: "post",
|
|
729
777
|
value: function () {
|
|
730
|
-
var _post = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
778
|
+
var _post = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(endpoint) {
|
|
731
779
|
var data,
|
|
732
780
|
headers,
|
|
733
781
|
response,
|
|
734
|
-
|
|
735
|
-
return _regeneratorRuntime().wrap(function
|
|
736
|
-
while (1) switch (
|
|
782
|
+
_args15 = arguments;
|
|
783
|
+
return _regeneratorRuntime().wrap(function _callee15$(_context15) {
|
|
784
|
+
while (1) switch (_context15.prev = _context15.next) {
|
|
737
785
|
case 0:
|
|
738
|
-
data =
|
|
739
|
-
|
|
786
|
+
data = _args15.length > 1 && _args15[1] !== undefined ? _args15[1] : {};
|
|
787
|
+
_context15.prev = 1;
|
|
740
788
|
// Add the authToken to the headers
|
|
741
789
|
headers = {
|
|
742
790
|
authtoken: this.authtoken
|
|
743
791
|
}; // Make the POST request using Axios
|
|
744
|
-
|
|
792
|
+
_context15.next = 5;
|
|
745
793
|
return this.axios.post(endpoint, data, {
|
|
746
794
|
headers: headers
|
|
747
795
|
});
|
|
748
796
|
case 5:
|
|
749
|
-
response =
|
|
797
|
+
response = _context15.sent;
|
|
750
798
|
if (!(response.data.ok === false)) {
|
|
751
|
-
|
|
799
|
+
_context15.next = 8;
|
|
752
800
|
break;
|
|
753
801
|
}
|
|
754
|
-
return
|
|
802
|
+
return _context15.abrupt("return", this._handleError(response));
|
|
755
803
|
case 8:
|
|
756
|
-
return
|
|
804
|
+
return _context15.abrupt("return", response.data);
|
|
757
805
|
case 11:
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
return
|
|
806
|
+
_context15.prev = 11;
|
|
807
|
+
_context15.t0 = _context15["catch"](1);
|
|
808
|
+
return _context15.abrupt("return", this._handleError(_context15.t0));
|
|
761
809
|
case 14:
|
|
762
810
|
case "end":
|
|
763
|
-
return
|
|
811
|
+
return _context15.stop();
|
|
764
812
|
}
|
|
765
|
-
},
|
|
813
|
+
}, _callee15, this, [[1, 11]]);
|
|
766
814
|
}));
|
|
767
815
|
function post(_x11) {
|
|
768
816
|
return _post.apply(this, arguments);
|