roboto-js 1.4.11 → 1.4.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/rbt_api.cjs +291 -272
- package/dist/esm/rbt_api.js +21 -32
- package/package.json +1 -1
- package/src/rbt_api.js +30 -30
package/dist/cjs/rbt_api.cjs
CHANGED
|
@@ -191,53 +191,72 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
191
191
|
return _login.apply(this, arguments);
|
|
192
192
|
}
|
|
193
193
|
return login;
|
|
194
|
-
}()
|
|
195
|
-
//
|
|
196
|
-
// try {
|
|
197
|
-
// debugger;
|
|
198
|
-
// const response = await this.post('/api/account/registerOrSigninOauth', userData );
|
|
199
|
-
//
|
|
200
|
-
// if (response.ok === false) {
|
|
201
|
-
// return this._handleError(response);
|
|
202
|
-
// }
|
|
203
|
-
//
|
|
204
|
-
// this.iac_session = response;
|
|
205
|
-
// this.currentUser = (this.iac_session)? new RbtUser(this.iac_session.user, this.axios): null;
|
|
206
|
-
// // update axios instance headers with authtoken
|
|
207
|
-
// this.axios.defaults.headers.common['authtoken'] = response.authToken;
|
|
208
|
-
// this.authtoken = response.authToken;
|
|
209
|
-
//
|
|
210
|
-
// if(this.localStorageAdaptor){
|
|
211
|
-
// await this.localStorageAdaptor.setItem('authtoken', response.authToken);
|
|
212
|
-
// }
|
|
213
|
-
//
|
|
214
|
-
// return response;
|
|
215
|
-
//
|
|
216
|
-
// } catch (e) {
|
|
217
|
-
//
|
|
218
|
-
// this._handleError(e);
|
|
219
|
-
// }
|
|
220
|
-
//
|
|
221
|
-
// }
|
|
222
|
-
)
|
|
194
|
+
}())
|
|
223
195
|
}, {
|
|
224
|
-
key: "
|
|
196
|
+
key: "loginWithOauth",
|
|
225
197
|
value: function () {
|
|
226
|
-
var
|
|
198
|
+
var _loginWithOauth = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(userData) {
|
|
227
199
|
var response;
|
|
228
200
|
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
229
201
|
while (1) switch (_context4.prev = _context4.next) {
|
|
230
202
|
case 0:
|
|
231
203
|
_context4.prev = 0;
|
|
232
204
|
_context4.next = 3;
|
|
233
|
-
return this.
|
|
205
|
+
return this.post('/api/account/registerOrSigninOauth', userData);
|
|
234
206
|
case 3:
|
|
235
207
|
response = _context4.sent;
|
|
236
|
-
if (!(response.
|
|
208
|
+
if (!(response.ok === false)) {
|
|
237
209
|
_context4.next = 6;
|
|
238
210
|
break;
|
|
239
211
|
}
|
|
240
212
|
return _context4.abrupt("return", this._handleError(response));
|
|
213
|
+
case 6:
|
|
214
|
+
this.iac_session = response;
|
|
215
|
+
this.currentUser = this.iac_session ? new _rbt_user["default"](this.iac_session.user, this.axios) : null;
|
|
216
|
+
// update axios instance headers with authtoken
|
|
217
|
+
this.axios.defaults.headers.common['authtoken'] = response.authToken;
|
|
218
|
+
this.authtoken = response.authToken;
|
|
219
|
+
if (!this.localStorageAdaptor) {
|
|
220
|
+
_context4.next = 13;
|
|
221
|
+
break;
|
|
222
|
+
}
|
|
223
|
+
_context4.next = 13;
|
|
224
|
+
return this.localStorageAdaptor.setItem('authtoken', response.authToken);
|
|
225
|
+
case 13:
|
|
226
|
+
return _context4.abrupt("return", response);
|
|
227
|
+
case 16:
|
|
228
|
+
_context4.prev = 16;
|
|
229
|
+
_context4.t0 = _context4["catch"](0);
|
|
230
|
+
this._handleError(_context4.t0);
|
|
231
|
+
case 19:
|
|
232
|
+
case "end":
|
|
233
|
+
return _context4.stop();
|
|
234
|
+
}
|
|
235
|
+
}, _callee4, this, [[0, 16]]);
|
|
236
|
+
}));
|
|
237
|
+
function loginWithOauth(_x3) {
|
|
238
|
+
return _loginWithOauth.apply(this, arguments);
|
|
239
|
+
}
|
|
240
|
+
return loginWithOauth;
|
|
241
|
+
}()
|
|
242
|
+
}, {
|
|
243
|
+
key: "logout",
|
|
244
|
+
value: function () {
|
|
245
|
+
var _logout = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
|
|
246
|
+
var response;
|
|
247
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
248
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
249
|
+
case 0:
|
|
250
|
+
_context5.prev = 0;
|
|
251
|
+
_context5.next = 3;
|
|
252
|
+
return this.axios.post('/user_service/logoutUser');
|
|
253
|
+
case 3:
|
|
254
|
+
response = _context5.sent;
|
|
255
|
+
if (!(response.data.ok === false)) {
|
|
256
|
+
_context5.next = 6;
|
|
257
|
+
break;
|
|
258
|
+
}
|
|
259
|
+
return _context5.abrupt("return", this._handleError(response));
|
|
241
260
|
case 6:
|
|
242
261
|
// Clear the iac_session and remove the auth token from axios headers
|
|
243
262
|
this.iac_session = null;
|
|
@@ -249,22 +268,22 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
249
268
|
|
|
250
269
|
// Clear localStorage if it's being used
|
|
251
270
|
if (!this.localStorageAdaptor) {
|
|
252
|
-
|
|
271
|
+
_context5.next = 13;
|
|
253
272
|
break;
|
|
254
273
|
}
|
|
255
|
-
|
|
274
|
+
_context5.next = 13;
|
|
256
275
|
return this.localStorageAdaptor.removeItem('authtoken');
|
|
257
276
|
case 13:
|
|
258
|
-
return
|
|
277
|
+
return _context5.abrupt("return", response.data);
|
|
259
278
|
case 16:
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
this._handleError(
|
|
279
|
+
_context5.prev = 16;
|
|
280
|
+
_context5.t0 = _context5["catch"](0);
|
|
281
|
+
this._handleError(_context5.t0);
|
|
263
282
|
case 19:
|
|
264
283
|
case "end":
|
|
265
|
-
return
|
|
284
|
+
return _context5.stop();
|
|
266
285
|
}
|
|
267
|
-
},
|
|
286
|
+
}, _callee5, this, [[0, 16]]);
|
|
268
287
|
}));
|
|
269
288
|
function logout() {
|
|
270
289
|
return _logout.apply(this, arguments);
|
|
@@ -281,43 +300,43 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
281
300
|
}, {
|
|
282
301
|
key: "loadCurrentUser",
|
|
283
302
|
value: function () {
|
|
284
|
-
var _loadCurrentUser = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
303
|
+
var _loadCurrentUser = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
|
|
285
304
|
var response;
|
|
286
|
-
return _regeneratorRuntime().wrap(function
|
|
287
|
-
while (1) switch (
|
|
305
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
306
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
288
307
|
case 0:
|
|
289
|
-
|
|
308
|
+
_context6.prev = 0;
|
|
290
309
|
if (!this.currentUser) {
|
|
291
|
-
|
|
310
|
+
_context6.next = 3;
|
|
292
311
|
break;
|
|
293
312
|
}
|
|
294
|
-
return
|
|
313
|
+
return _context6.abrupt("return", this.currentUser);
|
|
295
314
|
case 3:
|
|
296
315
|
if (!this.authtoken) {
|
|
297
|
-
|
|
316
|
+
_context6.next = 10;
|
|
298
317
|
break;
|
|
299
318
|
}
|
|
300
|
-
|
|
319
|
+
_context6.next = 6;
|
|
301
320
|
return this.refreshAuthToken(this.authtoken);
|
|
302
321
|
case 6:
|
|
303
|
-
response =
|
|
322
|
+
response = _context6.sent;
|
|
304
323
|
this.currentUser = new _rbt_user["default"]({
|
|
305
324
|
id: response.user.id
|
|
306
325
|
}, this.axios);
|
|
307
326
|
this.currentUser.setData(response.user);
|
|
308
|
-
return
|
|
327
|
+
return _context6.abrupt("return", this.currentUser);
|
|
309
328
|
case 10:
|
|
310
329
|
this.currentUser = null;
|
|
311
|
-
return
|
|
330
|
+
return _context6.abrupt("return", null);
|
|
312
331
|
case 14:
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
return
|
|
332
|
+
_context6.prev = 14;
|
|
333
|
+
_context6.t0 = _context6["catch"](0);
|
|
334
|
+
return _context6.abrupt("return", this._handleError(_context6.t0));
|
|
316
335
|
case 17:
|
|
317
336
|
case "end":
|
|
318
|
-
return
|
|
337
|
+
return _context6.stop();
|
|
319
338
|
}
|
|
320
|
-
},
|
|
339
|
+
}, _callee6, this, [[0, 14]]);
|
|
321
340
|
}));
|
|
322
341
|
function loadCurrentUser() {
|
|
323
342
|
return _loadCurrentUser.apply(this, arguments);
|
|
@@ -327,37 +346,37 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
327
346
|
}, {
|
|
328
347
|
key: "confirmUserEmail",
|
|
329
348
|
value: function () {
|
|
330
|
-
var _confirmUserEmail = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
349
|
+
var _confirmUserEmail = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(confirmCode) {
|
|
331
350
|
var params, response;
|
|
332
|
-
return _regeneratorRuntime().wrap(function
|
|
333
|
-
while (1) switch (
|
|
351
|
+
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
352
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
334
353
|
case 0:
|
|
335
354
|
params = {
|
|
336
355
|
emailConfirmCode: confirmCode
|
|
337
356
|
};
|
|
338
|
-
|
|
339
|
-
|
|
357
|
+
_context7.prev = 1;
|
|
358
|
+
_context7.next = 4;
|
|
340
359
|
return this.axios.post('/user_service/confirmUserEmail', [params]);
|
|
341
360
|
case 4:
|
|
342
|
-
response =
|
|
361
|
+
response = _context7.sent;
|
|
343
362
|
if (!(response.data.ok === false)) {
|
|
344
|
-
|
|
363
|
+
_context7.next = 7;
|
|
345
364
|
break;
|
|
346
365
|
}
|
|
347
|
-
return
|
|
366
|
+
return _context7.abrupt("return", this._handleError(response));
|
|
348
367
|
case 7:
|
|
349
|
-
return
|
|
368
|
+
return _context7.abrupt("return", response.data);
|
|
350
369
|
case 10:
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
return
|
|
370
|
+
_context7.prev = 10;
|
|
371
|
+
_context7.t0 = _context7["catch"](1);
|
|
372
|
+
return _context7.abrupt("return", this._handleError(_context7.t0));
|
|
354
373
|
case 13:
|
|
355
374
|
case "end":
|
|
356
|
-
return
|
|
375
|
+
return _context7.stop();
|
|
357
376
|
}
|
|
358
|
-
},
|
|
377
|
+
}, _callee7, this, [[1, 10]]);
|
|
359
378
|
}));
|
|
360
|
-
function confirmUserEmail(
|
|
379
|
+
function confirmUserEmail(_x4) {
|
|
361
380
|
return _confirmUserEmail.apply(this, arguments);
|
|
362
381
|
}
|
|
363
382
|
return confirmUserEmail;
|
|
@@ -365,21 +384,21 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
365
384
|
}, {
|
|
366
385
|
key: "loadCurrentUserExtended",
|
|
367
386
|
value: function () {
|
|
368
|
-
var _loadCurrentUserExtended = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
387
|
+
var _loadCurrentUserExtended = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
|
|
369
388
|
var currentUser;
|
|
370
|
-
return _regeneratorRuntime().wrap(function
|
|
371
|
-
while (1) switch (
|
|
389
|
+
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
|
|
390
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
372
391
|
case 0:
|
|
373
|
-
|
|
392
|
+
_context8.next = 2;
|
|
374
393
|
return this.loadCurrentUser();
|
|
375
394
|
case 2:
|
|
376
|
-
currentUser =
|
|
377
|
-
return
|
|
395
|
+
currentUser = _context8.sent;
|
|
396
|
+
return _context8.abrupt("return", this.loadUser(currentUser.id));
|
|
378
397
|
case 4:
|
|
379
398
|
case "end":
|
|
380
|
-
return
|
|
399
|
+
return _context8.stop();
|
|
381
400
|
}
|
|
382
|
-
},
|
|
401
|
+
}, _callee8, this);
|
|
383
402
|
}));
|
|
384
403
|
function loadCurrentUserExtended() {
|
|
385
404
|
return _loadCurrentUserExtended.apply(this, arguments);
|
|
@@ -389,36 +408,36 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
389
408
|
}, {
|
|
390
409
|
key: "loadUser",
|
|
391
410
|
value: function () {
|
|
392
|
-
var _loadUser = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
411
|
+
var _loadUser = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(userId) {
|
|
393
412
|
var params, _response$data, response, userData, User;
|
|
394
|
-
return _regeneratorRuntime().wrap(function
|
|
395
|
-
while (1) switch (
|
|
413
|
+
return _regeneratorRuntime().wrap(function _callee9$(_context9) {
|
|
414
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
396
415
|
case 0:
|
|
397
416
|
params = {
|
|
398
417
|
id: userId
|
|
399
418
|
};
|
|
400
|
-
|
|
401
|
-
|
|
419
|
+
_context9.prev = 1;
|
|
420
|
+
_context9.next = 4;
|
|
402
421
|
return this.axios.post('/user_service/loadUser', [params]);
|
|
403
422
|
case 4:
|
|
404
|
-
response =
|
|
423
|
+
response = _context9.sent;
|
|
405
424
|
userData = response === null || response === void 0 || (_response$data = response.data) === null || _response$data === void 0 ? void 0 : _response$data.user;
|
|
406
425
|
User = new _rbt_user["default"]({
|
|
407
426
|
id: userData.id
|
|
408
427
|
}, this.axios);
|
|
409
428
|
User.setData(userData);
|
|
410
|
-
return
|
|
429
|
+
return _context9.abrupt("return", User);
|
|
411
430
|
case 11:
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
return
|
|
431
|
+
_context9.prev = 11;
|
|
432
|
+
_context9.t0 = _context9["catch"](1);
|
|
433
|
+
return _context9.abrupt("return", this._handleError(_context9.t0));
|
|
415
434
|
case 14:
|
|
416
435
|
case "end":
|
|
417
|
-
return
|
|
436
|
+
return _context9.stop();
|
|
418
437
|
}
|
|
419
|
-
},
|
|
438
|
+
}, _callee9, this, [[1, 11]]);
|
|
420
439
|
}));
|
|
421
|
-
function loadUser(
|
|
440
|
+
function loadUser(_x5) {
|
|
422
441
|
return _loadUser.apply(this, arguments);
|
|
423
442
|
}
|
|
424
443
|
return loadUser;
|
|
@@ -426,29 +445,29 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
426
445
|
}, {
|
|
427
446
|
key: "refreshAuthToken",
|
|
428
447
|
value: function () {
|
|
429
|
-
var _refreshAuthToken = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
448
|
+
var _refreshAuthToken = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(authtoken) {
|
|
430
449
|
var response;
|
|
431
|
-
return _regeneratorRuntime().wrap(function
|
|
432
|
-
while (1) switch (
|
|
450
|
+
return _regeneratorRuntime().wrap(function _callee10$(_context10) {
|
|
451
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
433
452
|
case 0:
|
|
434
|
-
|
|
435
|
-
|
|
453
|
+
_context10.prev = 0;
|
|
454
|
+
_context10.next = 3;
|
|
436
455
|
return this.axios.post('/user_service/refreshAuthToken', [authtoken]);
|
|
437
456
|
case 3:
|
|
438
|
-
response =
|
|
457
|
+
response = _context10.sent;
|
|
439
458
|
debugger;
|
|
440
|
-
return
|
|
459
|
+
return _context10.abrupt("return", response.data);
|
|
441
460
|
case 8:
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
this._handleError(
|
|
461
|
+
_context10.prev = 8;
|
|
462
|
+
_context10.t0 = _context10["catch"](0);
|
|
463
|
+
this._handleError(_context10.t0);
|
|
445
464
|
case 11:
|
|
446
465
|
case "end":
|
|
447
|
-
return
|
|
466
|
+
return _context10.stop();
|
|
448
467
|
}
|
|
449
|
-
},
|
|
468
|
+
}, _callee10, this, [[0, 8]]);
|
|
450
469
|
}));
|
|
451
|
-
function refreshAuthToken(
|
|
470
|
+
function refreshAuthToken(_x6) {
|
|
452
471
|
return _refreshAuthToken.apply(this, arguments);
|
|
453
472
|
}
|
|
454
473
|
return refreshAuthToken;
|
|
@@ -463,32 +482,32 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
463
482
|
}, {
|
|
464
483
|
key: "registerUser",
|
|
465
484
|
value: (function () {
|
|
466
|
-
var _registerUser = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
485
|
+
var _registerUser = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {
|
|
467
486
|
var dataHash,
|
|
468
487
|
response,
|
|
469
488
|
record,
|
|
470
|
-
|
|
471
|
-
return _regeneratorRuntime().wrap(function
|
|
472
|
-
while (1) switch (
|
|
489
|
+
_args11 = arguments;
|
|
490
|
+
return _regeneratorRuntime().wrap(function _callee11$(_context11) {
|
|
491
|
+
while (1) switch (_context11.prev = _context11.next) {
|
|
473
492
|
case 0:
|
|
474
|
-
dataHash =
|
|
475
|
-
|
|
476
|
-
|
|
493
|
+
dataHash = _args11.length > 0 && _args11[0] !== undefined ? _args11[0] : {};
|
|
494
|
+
_context11.prev = 1;
|
|
495
|
+
_context11.next = 4;
|
|
477
496
|
return this.axios.post('/user_service/registerUser', [dataHash]);
|
|
478
497
|
case 4:
|
|
479
|
-
response =
|
|
498
|
+
response = _context11.sent;
|
|
480
499
|
record = response.data;
|
|
481
|
-
return
|
|
500
|
+
return _context11.abrupt("return", new _rbt_user["default"](record, this.axios));
|
|
482
501
|
case 9:
|
|
483
|
-
|
|
484
|
-
|
|
502
|
+
_context11.prev = 9;
|
|
503
|
+
_context11.t0 = _context11["catch"](1);
|
|
485
504
|
debugger;
|
|
486
|
-
return
|
|
505
|
+
return _context11.abrupt("return", this._handleError(_context11.t0));
|
|
487
506
|
case 13:
|
|
488
507
|
case "end":
|
|
489
|
-
return
|
|
508
|
+
return _context11.stop();
|
|
490
509
|
}
|
|
491
|
-
},
|
|
510
|
+
}, _callee11, this, [[1, 9]]);
|
|
492
511
|
}));
|
|
493
512
|
function registerUser() {
|
|
494
513
|
return _registerUser.apply(this, arguments);
|
|
@@ -506,32 +525,32 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
506
525
|
}, {
|
|
507
526
|
key: "createFile",
|
|
508
527
|
value: (function () {
|
|
509
|
-
var _createFile = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
528
|
+
var _createFile = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(dataHash) {
|
|
510
529
|
var response, record;
|
|
511
|
-
return _regeneratorRuntime().wrap(function
|
|
512
|
-
while (1) switch (
|
|
530
|
+
return _regeneratorRuntime().wrap(function _callee12$(_context12) {
|
|
531
|
+
while (1) switch (_context12.prev = _context12.next) {
|
|
513
532
|
case 0:
|
|
514
|
-
|
|
515
|
-
|
|
533
|
+
_context12.prev = 0;
|
|
534
|
+
_context12.next = 3;
|
|
516
535
|
return this.axios.post('/object_service/createObject', ['<@filekit.file>', dataHash]);
|
|
517
536
|
case 3:
|
|
518
|
-
response =
|
|
537
|
+
response = _context12.sent;
|
|
519
538
|
record = response.data;
|
|
520
539
|
if (dataHash) {
|
|
521
540
|
record.data = dataHash;
|
|
522
541
|
}
|
|
523
|
-
return
|
|
542
|
+
return _context12.abrupt("return", new _rbt_file["default"](record, this.axios, this.localDb));
|
|
524
543
|
case 9:
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
return
|
|
544
|
+
_context12.prev = 9;
|
|
545
|
+
_context12.t0 = _context12["catch"](0);
|
|
546
|
+
return _context12.abrupt("return", this._handleError(_context12.t0));
|
|
528
547
|
case 12:
|
|
529
548
|
case "end":
|
|
530
|
-
return
|
|
549
|
+
return _context12.stop();
|
|
531
550
|
}
|
|
532
|
-
},
|
|
551
|
+
}, _callee12, this, [[0, 9]]);
|
|
533
552
|
}));
|
|
534
|
-
function createFile(
|
|
553
|
+
function createFile(_x7) {
|
|
535
554
|
return _createFile.apply(this, arguments);
|
|
536
555
|
}
|
|
537
556
|
return createFile;
|
|
@@ -539,35 +558,35 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
539
558
|
}, {
|
|
540
559
|
key: "loadFile",
|
|
541
560
|
value: function () {
|
|
542
|
-
var _loadFile = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
561
|
+
var _loadFile = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(id) {
|
|
543
562
|
var response, record;
|
|
544
|
-
return _regeneratorRuntime().wrap(function
|
|
545
|
-
while (1) switch (
|
|
563
|
+
return _regeneratorRuntime().wrap(function _callee13$(_context13) {
|
|
564
|
+
while (1) switch (_context13.prev = _context13.next) {
|
|
546
565
|
case 0:
|
|
547
|
-
|
|
548
|
-
|
|
566
|
+
_context13.prev = 0;
|
|
567
|
+
_context13.next = 3;
|
|
549
568
|
return this.load('<@filekit.file>', id);
|
|
550
569
|
case 3:
|
|
551
|
-
response =
|
|
570
|
+
response = _context13.sent;
|
|
552
571
|
if (response) {
|
|
553
|
-
|
|
572
|
+
_context13.next = 6;
|
|
554
573
|
break;
|
|
555
574
|
}
|
|
556
|
-
return
|
|
575
|
+
return _context13.abrupt("return", null);
|
|
557
576
|
case 6:
|
|
558
577
|
record = response.toRecord();
|
|
559
|
-
return
|
|
578
|
+
return _context13.abrupt("return", new _rbt_file["default"](record, this.axios, this.localDb));
|
|
560
579
|
case 10:
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
return
|
|
580
|
+
_context13.prev = 10;
|
|
581
|
+
_context13.t0 = _context13["catch"](0);
|
|
582
|
+
return _context13.abrupt("return", this._handleError(_context13.t0));
|
|
564
583
|
case 13:
|
|
565
584
|
case "end":
|
|
566
|
-
return
|
|
585
|
+
return _context13.stop();
|
|
567
586
|
}
|
|
568
|
-
},
|
|
587
|
+
}, _callee13, this, [[0, 10]]);
|
|
569
588
|
}));
|
|
570
|
-
function loadFile(
|
|
589
|
+
function loadFile(_x8) {
|
|
571
590
|
return _loadFile.apply(this, arguments);
|
|
572
591
|
}
|
|
573
592
|
return loadFile;
|
|
@@ -582,38 +601,38 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
582
601
|
}, {
|
|
583
602
|
key: "create",
|
|
584
603
|
value: (function () {
|
|
585
|
-
var _create = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
604
|
+
var _create = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14(type) {
|
|
586
605
|
var dataHash,
|
|
587
606
|
response,
|
|
588
607
|
record,
|
|
589
|
-
|
|
590
|
-
return _regeneratorRuntime().wrap(function
|
|
591
|
-
while (1) switch (
|
|
608
|
+
_args14 = arguments;
|
|
609
|
+
return _regeneratorRuntime().wrap(function _callee14$(_context14) {
|
|
610
|
+
while (1) switch (_context14.prev = _context14.next) {
|
|
592
611
|
case 0:
|
|
593
|
-
dataHash =
|
|
594
|
-
|
|
595
|
-
|
|
612
|
+
dataHash = _args14.length > 1 && _args14[1] !== undefined ? _args14[1] : {};
|
|
613
|
+
_context14.prev = 1;
|
|
614
|
+
_context14.next = 4;
|
|
596
615
|
return this.axios.post('/object_service/createObject', [type, dataHash]);
|
|
597
616
|
case 4:
|
|
598
|
-
response =
|
|
617
|
+
response = _context14.sent;
|
|
599
618
|
record = response.data;
|
|
600
619
|
if (dataHash) {
|
|
601
620
|
record.data = dataHash;
|
|
602
621
|
}
|
|
603
|
-
return
|
|
622
|
+
return _context14.abrupt("return", new _rbt_object["default"](record, this.axios, {
|
|
604
623
|
isNew: true
|
|
605
624
|
}));
|
|
606
625
|
case 10:
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
return
|
|
626
|
+
_context14.prev = 10;
|
|
627
|
+
_context14.t0 = _context14["catch"](1);
|
|
628
|
+
return _context14.abrupt("return", this._handleError(_context14.t0));
|
|
610
629
|
case 13:
|
|
611
630
|
case "end":
|
|
612
|
-
return
|
|
631
|
+
return _context14.stop();
|
|
613
632
|
}
|
|
614
|
-
},
|
|
633
|
+
}, _callee14, this, [[1, 10]]);
|
|
615
634
|
}));
|
|
616
|
-
function create(
|
|
635
|
+
function create(_x9) {
|
|
617
636
|
return _create.apply(this, arguments);
|
|
618
637
|
}
|
|
619
638
|
return create;
|
|
@@ -650,19 +669,19 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
650
669
|
}, {
|
|
651
670
|
key: "query",
|
|
652
671
|
value: (function () {
|
|
653
|
-
var _query = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
672
|
+
var _query = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(type) {
|
|
654
673
|
var _this = this;
|
|
655
674
|
var params,
|
|
656
675
|
defaultOrderBy,
|
|
657
676
|
defaultLimit,
|
|
658
677
|
mergedParams,
|
|
659
678
|
response,
|
|
660
|
-
|
|
661
|
-
return _regeneratorRuntime().wrap(function
|
|
662
|
-
while (1) switch (
|
|
679
|
+
_args15 = arguments;
|
|
680
|
+
return _regeneratorRuntime().wrap(function _callee15$(_context15) {
|
|
681
|
+
while (1) switch (_context15.prev = _context15.next) {
|
|
663
682
|
case 0:
|
|
664
|
-
params =
|
|
665
|
-
|
|
683
|
+
params = _args15.length > 1 && _args15[1] !== undefined ? _args15[1] : {};
|
|
684
|
+
_context15.prev = 1;
|
|
666
685
|
params.type = type;
|
|
667
686
|
|
|
668
687
|
// Default ordering and pagination
|
|
@@ -679,15 +698,15 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
679
698
|
}
|
|
680
699
|
}; // Merge defaults with provided params
|
|
681
700
|
mergedParams = _objectSpread(_objectSpread(_objectSpread({}, defaultOrderBy), defaultLimit), params);
|
|
682
|
-
|
|
701
|
+
_context15.next = 8;
|
|
683
702
|
return this.axios.post('/object_service/queryObjects', [mergedParams]);
|
|
684
703
|
case 8:
|
|
685
|
-
response =
|
|
704
|
+
response = _context15.sent;
|
|
686
705
|
if (!(response.data.ok === false)) {
|
|
687
|
-
|
|
706
|
+
_context15.next = 11;
|
|
688
707
|
break;
|
|
689
708
|
}
|
|
690
|
-
return
|
|
709
|
+
return _context15.abrupt("return", this._handleError(response));
|
|
691
710
|
case 11:
|
|
692
711
|
// Process items into RbtObject instances
|
|
693
712
|
if (Array.isArray(response.data.items)) {
|
|
@@ -697,18 +716,18 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
697
716
|
});
|
|
698
717
|
});
|
|
699
718
|
}
|
|
700
|
-
return
|
|
719
|
+
return _context15.abrupt("return", response.data.items);
|
|
701
720
|
case 15:
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
return
|
|
721
|
+
_context15.prev = 15;
|
|
722
|
+
_context15.t0 = _context15["catch"](1);
|
|
723
|
+
return _context15.abrupt("return", this._handleError(_context15.t0));
|
|
705
724
|
case 18:
|
|
706
725
|
case "end":
|
|
707
|
-
return
|
|
726
|
+
return _context15.stop();
|
|
708
727
|
}
|
|
709
|
-
},
|
|
728
|
+
}, _callee15, this, [[1, 15]]);
|
|
710
729
|
}));
|
|
711
|
-
function query(
|
|
730
|
+
function query(_x10) {
|
|
712
731
|
return _query.apply(this, arguments);
|
|
713
732
|
}
|
|
714
733
|
return query;
|
|
@@ -725,47 +744,47 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
725
744
|
}, {
|
|
726
745
|
key: "load",
|
|
727
746
|
value: (function () {
|
|
728
|
-
var _load = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
747
|
+
var _load = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(type, ids) {
|
|
729
748
|
var params,
|
|
730
749
|
mergedParams,
|
|
731
750
|
res,
|
|
732
|
-
|
|
733
|
-
return _regeneratorRuntime().wrap(function
|
|
734
|
-
while (1) switch (
|
|
751
|
+
_args16 = arguments;
|
|
752
|
+
return _regeneratorRuntime().wrap(function _callee16$(_context16) {
|
|
753
|
+
while (1) switch (_context16.prev = _context16.next) {
|
|
735
754
|
case 0:
|
|
736
|
-
params =
|
|
737
|
-
|
|
755
|
+
params = _args16.length > 2 && _args16[2] !== undefined ? _args16[2] : {};
|
|
756
|
+
_context16.prev = 1;
|
|
738
757
|
if (!Array.isArray(ids)) {
|
|
739
|
-
|
|
758
|
+
_context16.next = 7;
|
|
740
759
|
break;
|
|
741
760
|
}
|
|
742
761
|
mergedParams = _objectSpread(_objectSpread({}, params), {}, {
|
|
743
|
-
where: "id IN (
|
|
762
|
+
where: "id IN (\"".concat(ids.join("\",\""), "\")")
|
|
744
763
|
});
|
|
745
|
-
return
|
|
764
|
+
return _context16.abrupt("return", this.query(type, mergedParams));
|
|
746
765
|
case 7:
|
|
747
766
|
mergedParams = _objectSpread(_objectSpread({}, params), {}, {
|
|
748
|
-
where: "id
|
|
767
|
+
where: "id=\"".concat(ids, "\"")
|
|
749
768
|
});
|
|
750
|
-
|
|
769
|
+
_context16.next = 10;
|
|
751
770
|
return this.query(type, mergedParams);
|
|
752
771
|
case 10:
|
|
753
|
-
res =
|
|
754
|
-
return
|
|
772
|
+
res = _context16.sent;
|
|
773
|
+
return _context16.abrupt("return", res[0]);
|
|
755
774
|
case 12:
|
|
756
|
-
|
|
775
|
+
_context16.next = 17;
|
|
757
776
|
break;
|
|
758
777
|
case 14:
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
return
|
|
778
|
+
_context16.prev = 14;
|
|
779
|
+
_context16.t0 = _context16["catch"](1);
|
|
780
|
+
return _context16.abrupt("return", this._handleError(_context16.t0));
|
|
762
781
|
case 17:
|
|
763
782
|
case "end":
|
|
764
|
-
return
|
|
783
|
+
return _context16.stop();
|
|
765
784
|
}
|
|
766
|
-
},
|
|
785
|
+
}, _callee16, this, [[1, 14]]);
|
|
767
786
|
}));
|
|
768
|
-
function load(
|
|
787
|
+
function load(_x11, _x12) {
|
|
769
788
|
return _load.apply(this, arguments);
|
|
770
789
|
}
|
|
771
790
|
return load;
|
|
@@ -787,7 +806,7 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
787
806
|
}, {
|
|
788
807
|
key: "runTask",
|
|
789
808
|
value: (function () {
|
|
790
|
-
var _runTask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
809
|
+
var _runTask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {
|
|
791
810
|
var params,
|
|
792
811
|
callbacks,
|
|
793
812
|
onProgress,
|
|
@@ -799,20 +818,20 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
799
818
|
status,
|
|
800
819
|
message,
|
|
801
820
|
output,
|
|
802
|
-
|
|
803
|
-
return _regeneratorRuntime().wrap(function
|
|
804
|
-
while (1) switch (
|
|
821
|
+
_args17 = arguments;
|
|
822
|
+
return _regeneratorRuntime().wrap(function _callee17$(_context17) {
|
|
823
|
+
while (1) switch (_context17.prev = _context17.next) {
|
|
805
824
|
case 0:
|
|
806
|
-
params =
|
|
807
|
-
callbacks =
|
|
825
|
+
params = _args17.length > 0 && _args17[0] !== undefined ? _args17[0] : {};
|
|
826
|
+
callbacks = _args17.length > 1 && _args17[1] !== undefined ? _args17[1] : {};
|
|
808
827
|
onProgress = callbacks.onProgress, onError = callbacks.onError, onFinish = callbacks.onFinish;
|
|
809
|
-
|
|
810
|
-
|
|
828
|
+
_context17.prev = 3;
|
|
829
|
+
_context17.next = 6;
|
|
811
830
|
return this.post('/task_service/runChain', params);
|
|
812
831
|
case 6:
|
|
813
|
-
response =
|
|
832
|
+
response = _context17.sent;
|
|
814
833
|
if (response) {
|
|
815
|
-
|
|
834
|
+
_context17.next = 9;
|
|
816
835
|
break;
|
|
817
836
|
}
|
|
818
837
|
throw new Error('Invalid server response');
|
|
@@ -820,7 +839,7 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
820
839
|
// Validate response structure
|
|
821
840
|
ok = response.ok, jobId = response.jobId, status = response.status, message = response.message, output = response.output;
|
|
822
841
|
if (!(!ok || typeof jobId !== 'string' || typeof status !== 'string')) {
|
|
823
|
-
|
|
842
|
+
_context17.next = 12;
|
|
824
843
|
break;
|
|
825
844
|
}
|
|
826
845
|
throw new Error('Invalid response structure');
|
|
@@ -838,7 +857,7 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
838
857
|
console.log('Finish (request) ', response);
|
|
839
858
|
onFinish(response);
|
|
840
859
|
}
|
|
841
|
-
return
|
|
860
|
+
return _context17.abrupt("return", {
|
|
842
861
|
ok: ok,
|
|
843
862
|
jobId: jobId,
|
|
844
863
|
status: status,
|
|
@@ -846,24 +865,24 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
846
865
|
output: output
|
|
847
866
|
});
|
|
848
867
|
case 18:
|
|
849
|
-
|
|
850
|
-
|
|
868
|
+
_context17.prev = 18;
|
|
869
|
+
_context17.t0 = _context17["catch"](3);
|
|
851
870
|
if (typeof onError === 'function') {
|
|
852
|
-
onError(
|
|
871
|
+
onError(_context17.t0);
|
|
853
872
|
} else {
|
|
854
|
-
console.error('Error in runTask:',
|
|
873
|
+
console.error('Error in runTask:', _context17.t0);
|
|
855
874
|
}
|
|
856
|
-
return
|
|
875
|
+
return _context17.abrupt("return", {
|
|
857
876
|
ok: false,
|
|
858
877
|
jobId: null,
|
|
859
878
|
status: 'ERROR',
|
|
860
|
-
error:
|
|
879
|
+
error: _context17.t0.message
|
|
861
880
|
});
|
|
862
881
|
case 22:
|
|
863
882
|
case "end":
|
|
864
|
-
return
|
|
883
|
+
return _context17.stop();
|
|
865
884
|
}
|
|
866
|
-
},
|
|
885
|
+
}, _callee17, this, [[3, 18]]);
|
|
867
886
|
}));
|
|
868
887
|
function runTask() {
|
|
869
888
|
return _runTask.apply(this, arguments);
|
|
@@ -884,26 +903,26 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
884
903
|
}, {
|
|
885
904
|
key: "pollTaskProgress",
|
|
886
905
|
value: (function () {
|
|
887
|
-
var _pollTaskProgress = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
906
|
+
var _pollTaskProgress = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(jobId, callbacks) {
|
|
888
907
|
var _this2 = this;
|
|
889
908
|
var onProgress, onError, onFinish, checkProgress;
|
|
890
|
-
return _regeneratorRuntime().wrap(function
|
|
891
|
-
while (1) switch (
|
|
909
|
+
return _regeneratorRuntime().wrap(function _callee19$(_context19) {
|
|
910
|
+
while (1) switch (_context19.prev = _context19.next) {
|
|
892
911
|
case 0:
|
|
893
912
|
onProgress = callbacks.onProgress, onError = callbacks.onError, onFinish = callbacks.onFinish;
|
|
894
|
-
|
|
913
|
+
_context19.prev = 1;
|
|
895
914
|
checkProgress = /*#__PURE__*/function () {
|
|
896
|
-
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
915
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {
|
|
897
916
|
var response;
|
|
898
|
-
return _regeneratorRuntime().wrap(function
|
|
899
|
-
while (1) switch (
|
|
917
|
+
return _regeneratorRuntime().wrap(function _callee18$(_context18) {
|
|
918
|
+
while (1) switch (_context18.prev = _context18.next) {
|
|
900
919
|
case 0:
|
|
901
|
-
|
|
920
|
+
_context18.next = 2;
|
|
902
921
|
return _this2.get("/task_service/pollChainProgress", {
|
|
903
922
|
jobId: jobId
|
|
904
923
|
});
|
|
905
924
|
case 2:
|
|
906
|
-
response =
|
|
925
|
+
response = _context18.sent;
|
|
907
926
|
// If the task is still in progress, start polling for updates
|
|
908
927
|
if (response.status === 'DONE' && onFinish) {
|
|
909
928
|
// Provide the current progress to the callback function
|
|
@@ -926,28 +945,28 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
926
945
|
}
|
|
927
946
|
case 7:
|
|
928
947
|
case "end":
|
|
929
|
-
return
|
|
948
|
+
return _context18.stop();
|
|
930
949
|
}
|
|
931
|
-
},
|
|
950
|
+
}, _callee18);
|
|
932
951
|
}));
|
|
933
952
|
return function checkProgress() {
|
|
934
953
|
return _ref2.apply(this, arguments);
|
|
935
954
|
};
|
|
936
955
|
}();
|
|
937
956
|
checkProgress();
|
|
938
|
-
|
|
957
|
+
_context19.next = 9;
|
|
939
958
|
break;
|
|
940
959
|
case 6:
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
return
|
|
960
|
+
_context19.prev = 6;
|
|
961
|
+
_context19.t0 = _context19["catch"](1);
|
|
962
|
+
return _context19.abrupt("return", this._handleError(_context19.t0));
|
|
944
963
|
case 9:
|
|
945
964
|
case "end":
|
|
946
|
-
return
|
|
965
|
+
return _context19.stop();
|
|
947
966
|
}
|
|
948
|
-
},
|
|
967
|
+
}, _callee19, this, [[1, 6]]);
|
|
949
968
|
}));
|
|
950
|
-
function pollTaskProgress(
|
|
969
|
+
function pollTaskProgress(_x13, _x14) {
|
|
951
970
|
return _pollTaskProgress.apply(this, arguments);
|
|
952
971
|
}
|
|
953
972
|
return pollTaskProgress;
|
|
@@ -967,46 +986,46 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
967
986
|
}, {
|
|
968
987
|
key: "get",
|
|
969
988
|
value: (function () {
|
|
970
|
-
var _get = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
989
|
+
var _get = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(endpoint) {
|
|
971
990
|
var params,
|
|
972
991
|
headers,
|
|
973
992
|
response,
|
|
974
|
-
|
|
975
|
-
return _regeneratorRuntime().wrap(function
|
|
976
|
-
while (1) switch (
|
|
993
|
+
_args20 = arguments;
|
|
994
|
+
return _regeneratorRuntime().wrap(function _callee20$(_context20) {
|
|
995
|
+
while (1) switch (_context20.prev = _context20.next) {
|
|
977
996
|
case 0:
|
|
978
|
-
params =
|
|
997
|
+
params = _args20.length > 1 && _args20[1] !== undefined ? _args20[1] : {};
|
|
979
998
|
debugger;
|
|
980
|
-
|
|
999
|
+
_context20.prev = 2;
|
|
981
1000
|
// Add the authToken to the headers
|
|
982
1001
|
headers = {
|
|
983
1002
|
authtoken: this.authtoken
|
|
984
1003
|
}; // Make the GET request using Axios
|
|
985
|
-
|
|
1004
|
+
_context20.next = 6;
|
|
986
1005
|
return this.axios.get(endpoint, {
|
|
987
1006
|
params: params,
|
|
988
1007
|
headers: headers
|
|
989
1008
|
});
|
|
990
1009
|
case 6:
|
|
991
|
-
response =
|
|
1010
|
+
response = _context20.sent;
|
|
992
1011
|
if (!(response.data.ok === false)) {
|
|
993
|
-
|
|
1012
|
+
_context20.next = 9;
|
|
994
1013
|
break;
|
|
995
1014
|
}
|
|
996
|
-
return
|
|
1015
|
+
return _context20.abrupt("return", this._handleError(response));
|
|
997
1016
|
case 9:
|
|
998
|
-
return
|
|
1017
|
+
return _context20.abrupt("return", response.data);
|
|
999
1018
|
case 12:
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
return
|
|
1019
|
+
_context20.prev = 12;
|
|
1020
|
+
_context20.t0 = _context20["catch"](2);
|
|
1021
|
+
return _context20.abrupt("return", this._handleError(_context20.t0));
|
|
1003
1022
|
case 15:
|
|
1004
1023
|
case "end":
|
|
1005
|
-
return
|
|
1024
|
+
return _context20.stop();
|
|
1006
1025
|
}
|
|
1007
|
-
},
|
|
1026
|
+
}, _callee20, this, [[2, 12]]);
|
|
1008
1027
|
}));
|
|
1009
|
-
function get(
|
|
1028
|
+
function get(_x15) {
|
|
1010
1029
|
return _get.apply(this, arguments);
|
|
1011
1030
|
}
|
|
1012
1031
|
return get;
|
|
@@ -1027,44 +1046,44 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
1027
1046
|
}, {
|
|
1028
1047
|
key: "post",
|
|
1029
1048
|
value: (function () {
|
|
1030
|
-
var _post = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1049
|
+
var _post = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(endpoint) {
|
|
1031
1050
|
var data,
|
|
1032
1051
|
headers,
|
|
1033
1052
|
response,
|
|
1034
|
-
|
|
1035
|
-
return _regeneratorRuntime().wrap(function
|
|
1036
|
-
while (1) switch (
|
|
1053
|
+
_args21 = arguments;
|
|
1054
|
+
return _regeneratorRuntime().wrap(function _callee21$(_context21) {
|
|
1055
|
+
while (1) switch (_context21.prev = _context21.next) {
|
|
1037
1056
|
case 0:
|
|
1038
|
-
data =
|
|
1039
|
-
|
|
1057
|
+
data = _args21.length > 1 && _args21[1] !== undefined ? _args21[1] : {};
|
|
1058
|
+
_context21.prev = 1;
|
|
1040
1059
|
// Add the authToken to the headers
|
|
1041
1060
|
headers = {
|
|
1042
1061
|
authtoken: this.authtoken
|
|
1043
1062
|
}; // Make the POST request using Axios
|
|
1044
|
-
|
|
1063
|
+
_context21.next = 5;
|
|
1045
1064
|
return this.axios.post(endpoint, data, {
|
|
1046
1065
|
headers: headers
|
|
1047
1066
|
});
|
|
1048
1067
|
case 5:
|
|
1049
|
-
response =
|
|
1068
|
+
response = _context21.sent;
|
|
1050
1069
|
if (!(response.data.ok === false)) {
|
|
1051
|
-
|
|
1070
|
+
_context21.next = 8;
|
|
1052
1071
|
break;
|
|
1053
1072
|
}
|
|
1054
|
-
return
|
|
1073
|
+
return _context21.abrupt("return", this._handleError(response));
|
|
1055
1074
|
case 8:
|
|
1056
|
-
return
|
|
1075
|
+
return _context21.abrupt("return", response.data);
|
|
1057
1076
|
case 11:
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
return
|
|
1077
|
+
_context21.prev = 11;
|
|
1078
|
+
_context21.t0 = _context21["catch"](1);
|
|
1079
|
+
return _context21.abrupt("return", this._handleError(_context21.t0));
|
|
1061
1080
|
case 14:
|
|
1062
1081
|
case "end":
|
|
1063
|
-
return
|
|
1082
|
+
return _context21.stop();
|
|
1064
1083
|
}
|
|
1065
|
-
},
|
|
1084
|
+
}, _callee21, this, [[1, 11]]);
|
|
1066
1085
|
}));
|
|
1067
|
-
function post(
|
|
1086
|
+
function post(_x16) {
|
|
1068
1087
|
return _post.apply(this, arguments);
|
|
1069
1088
|
}
|
|
1070
1089
|
return post;
|
package/dist/esm/rbt_api.js
CHANGED
|
@@ -93,36 +93,25 @@ export default class RbtApi {
|
|
|
93
93
|
this._handleError(e);
|
|
94
94
|
}
|
|
95
95
|
}
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
// }
|
|
116
|
-
//
|
|
117
|
-
// return response;
|
|
118
|
-
//
|
|
119
|
-
// } catch (e) {
|
|
120
|
-
//
|
|
121
|
-
// this._handleError(e);
|
|
122
|
-
// }
|
|
123
|
-
//
|
|
124
|
-
// }
|
|
125
|
-
|
|
96
|
+
async loginWithOauth(userData) {
|
|
97
|
+
try {
|
|
98
|
+
const response = await this.post('/api/account/registerOrSigninOauth', userData);
|
|
99
|
+
if (response.ok === false) {
|
|
100
|
+
return this._handleError(response);
|
|
101
|
+
}
|
|
102
|
+
this.iac_session = response;
|
|
103
|
+
this.currentUser = this.iac_session ? new RbtUser(this.iac_session.user, this.axios) : null;
|
|
104
|
+
// update axios instance headers with authtoken
|
|
105
|
+
this.axios.defaults.headers.common['authtoken'] = response.authToken;
|
|
106
|
+
this.authtoken = response.authToken;
|
|
107
|
+
if (this.localStorageAdaptor) {
|
|
108
|
+
await this.localStorageAdaptor.setItem('authtoken', response.authToken);
|
|
109
|
+
}
|
|
110
|
+
return response;
|
|
111
|
+
} catch (e) {
|
|
112
|
+
this._handleError(e);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
126
115
|
async logout() {
|
|
127
116
|
try {
|
|
128
117
|
// Call logout endpoint if necessary. Here, I assume there's a '/user_service/logoutUser' endpoint.
|
|
@@ -379,13 +368,13 @@ export default class RbtApi {
|
|
|
379
368
|
if (Array.isArray(ids)) {
|
|
380
369
|
mergedParams = {
|
|
381
370
|
...params,
|
|
382
|
-
where:
|
|
371
|
+
where: `id IN ("${ids.join(`","`)}")`
|
|
383
372
|
};
|
|
384
373
|
return this.query(type, mergedParams);
|
|
385
374
|
} else {
|
|
386
375
|
mergedParams = {
|
|
387
376
|
...params,
|
|
388
|
-
where:
|
|
377
|
+
where: `id="${ids}"`
|
|
389
378
|
};
|
|
390
379
|
let res = await this.query(type, mergedParams);
|
|
391
380
|
return res[0];
|
package/package.json
CHANGED
package/src/rbt_api.js
CHANGED
|
@@ -111,34 +111,34 @@ export default class RbtApi {
|
|
|
111
111
|
}
|
|
112
112
|
}
|
|
113
113
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
114
|
+
async loginWithOauth(userData){
|
|
115
|
+
|
|
116
|
+
try {
|
|
117
|
+
|
|
118
|
+
const response = await this.post('/api/account/registerOrSigninOauth', userData );
|
|
119
|
+
|
|
120
|
+
if (response.ok === false) {
|
|
121
|
+
return this._handleError(response);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
this.iac_session = response;
|
|
125
|
+
this.currentUser = (this.iac_session)? new RbtUser(this.iac_session.user, this.axios): null;
|
|
126
|
+
// update axios instance headers with authtoken
|
|
127
|
+
this.axios.defaults.headers.common['authtoken'] = response.authToken;
|
|
128
|
+
this.authtoken = response.authToken;
|
|
129
|
+
|
|
130
|
+
if(this.localStorageAdaptor){
|
|
131
|
+
await this.localStorageAdaptor.setItem('authtoken', response.authToken);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
return response;
|
|
135
|
+
|
|
136
|
+
} catch (e) {
|
|
137
|
+
|
|
138
|
+
this._handleError(e);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
}
|
|
142
142
|
|
|
143
143
|
async logout() {
|
|
144
144
|
try {
|
|
@@ -423,11 +423,11 @@ export default class RbtApi {
|
|
|
423
423
|
let mergedParams;
|
|
424
424
|
|
|
425
425
|
if(Array.isArray(ids)){
|
|
426
|
-
mergedParams = { ...params, where:
|
|
426
|
+
mergedParams = { ...params, where: `id IN ("${ids.join(`","`)}")` };
|
|
427
427
|
return this.query(type, mergedParams);
|
|
428
428
|
}
|
|
429
429
|
else{
|
|
430
|
-
mergedParams = { ...params, where:
|
|
430
|
+
mergedParams = { ...params, where: `id="${ids}"` };
|
|
431
431
|
let res = await this.query(type, mergedParams);
|
|
432
432
|
return res[0];
|
|
433
433
|
}
|