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