roboto-js 1.1.6 → 1.1.8
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 +78 -59
- package/dist/cjs/rbt_api.cjs +255 -209
- package/dist/esm/index.js +78 -59
- package/dist/esm/rbt_api.js +255 -209
- package/package.json +1 -1
- package/src/index.js +3 -0
- package/src/rbt_api.js +44 -11
package/dist/esm/rbt_api.js
CHANGED
|
@@ -107,21 +107,22 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
107
107
|
return _context2.abrupt("return", this._handleError(response));
|
|
108
108
|
case 7:
|
|
109
109
|
this.iac_session = response.data;
|
|
110
|
+
this.currentUser = this.iac_session ? new _rbt_user["default"](this.iac_session.user, this.axios) : null;
|
|
110
111
|
// update axios instance headers with authtoken
|
|
111
112
|
this.axios.defaults.headers.common['authtoken'] = response.data.authToken;
|
|
112
113
|
if (typeof localStorage != 'undefined') {
|
|
113
114
|
localStorage.setItem('authtoken', response.data.authToken);
|
|
114
115
|
}
|
|
115
116
|
return _context2.abrupt("return", response.data);
|
|
116
|
-
case
|
|
117
|
-
_context2.prev =
|
|
117
|
+
case 14:
|
|
118
|
+
_context2.prev = 14;
|
|
118
119
|
_context2.t0 = _context2["catch"](0);
|
|
119
120
|
this._handleError(_context2.t0);
|
|
120
|
-
case
|
|
121
|
+
case 17:
|
|
121
122
|
case "end":
|
|
122
123
|
return _context2.stop();
|
|
123
124
|
}
|
|
124
|
-
}, _callee2, this, [[0,
|
|
125
|
+
}, _callee2, this, [[0, 14]]);
|
|
125
126
|
}));
|
|
126
127
|
function login(_x) {
|
|
127
128
|
return _login.apply(this, arguments);
|
|
@@ -149,6 +150,7 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
149
150
|
case 6:
|
|
150
151
|
// Clear the iac_session and remove the auth token from axios headers
|
|
151
152
|
this.iac_session = null;
|
|
153
|
+
this.currentUser = null;
|
|
152
154
|
if (this.axios.defaults.headers.common['authtoken']) {
|
|
153
155
|
delete this.axios.defaults.headers.common['authtoken'];
|
|
154
156
|
}
|
|
@@ -160,15 +162,15 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
160
162
|
|
|
161
163
|
// Return some kind of success response or the response from the server
|
|
162
164
|
return _context3.abrupt("return", response.data);
|
|
163
|
-
case
|
|
164
|
-
_context3.prev =
|
|
165
|
+
case 13:
|
|
166
|
+
_context3.prev = 13;
|
|
165
167
|
_context3.t0 = _context3["catch"](0);
|
|
166
168
|
this._handleError(_context3.t0);
|
|
167
|
-
case
|
|
169
|
+
case 16:
|
|
168
170
|
case "end":
|
|
169
171
|
return _context3.stop();
|
|
170
172
|
}
|
|
171
|
-
}, _callee3, this, [[0,
|
|
173
|
+
}, _callee3, this, [[0, 13]]);
|
|
172
174
|
}));
|
|
173
175
|
function logout() {
|
|
174
176
|
return _logout.apply(this, arguments);
|
|
@@ -179,34 +181,42 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
179
181
|
key: "loadCurrentUser",
|
|
180
182
|
value: function () {
|
|
181
183
|
var _loadCurrentUser = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
|
|
182
|
-
var
|
|
184
|
+
var response;
|
|
183
185
|
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
184
186
|
while (1) switch (_context4.prev = _context4.next) {
|
|
185
187
|
case 0:
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
_context4.
|
|
192
|
-
|
|
193
|
-
|
|
188
|
+
_context4.prev = 0;
|
|
189
|
+
if (!this.currentUser) {
|
|
190
|
+
_context4.next = 3;
|
|
191
|
+
break;
|
|
192
|
+
}
|
|
193
|
+
return _context4.abrupt("return", this.currentUser);
|
|
194
|
+
case 3:
|
|
195
|
+
if (!this.authtoken) {
|
|
196
|
+
_context4.next = 10;
|
|
197
|
+
break;
|
|
198
|
+
}
|
|
199
|
+
_context4.next = 6;
|
|
200
|
+
return this.refreshAuthToken(this.authtoken);
|
|
201
|
+
case 6:
|
|
194
202
|
response = _context4.sent;
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
id: userData.id
|
|
203
|
+
this.currentUser = new _rbt_user["default"]({
|
|
204
|
+
id: response.user.id
|
|
198
205
|
}, this.axios);
|
|
199
|
-
|
|
200
|
-
return _context4.abrupt("return",
|
|
201
|
-
case
|
|
202
|
-
|
|
203
|
-
_context4.
|
|
204
|
-
return _context4.abrupt("return", this._handleError(_context4.t0));
|
|
206
|
+
this.currentUser.setData(response.user);
|
|
207
|
+
return _context4.abrupt("return", this.currentUser);
|
|
208
|
+
case 10:
|
|
209
|
+
this.currentUser = null;
|
|
210
|
+
return _context4.abrupt("return", null);
|
|
205
211
|
case 14:
|
|
212
|
+
_context4.prev = 14;
|
|
213
|
+
_context4.t0 = _context4["catch"](0);
|
|
214
|
+
return _context4.abrupt("return", this._handleError(_context4.t0));
|
|
215
|
+
case 17:
|
|
206
216
|
case "end":
|
|
207
217
|
return _context4.stop();
|
|
208
218
|
}
|
|
209
|
-
}, _callee4, this, [[
|
|
219
|
+
}, _callee4, this, [[0, 14]]);
|
|
210
220
|
}));
|
|
211
221
|
function loadCurrentUser() {
|
|
212
222
|
return _loadCurrentUser.apply(this, arguments);
|
|
@@ -214,38 +224,76 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
214
224
|
return loadCurrentUser;
|
|
215
225
|
}()
|
|
216
226
|
}, {
|
|
217
|
-
key: "
|
|
227
|
+
key: "confirmUserEmail",
|
|
218
228
|
value: function () {
|
|
219
|
-
var
|
|
220
|
-
var params,
|
|
229
|
+
var _confirmUserEmail = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(confirmCode) {
|
|
230
|
+
var params, response;
|
|
221
231
|
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
222
232
|
while (1) switch (_context5.prev = _context5.next) {
|
|
223
233
|
case 0:
|
|
224
234
|
params = {
|
|
225
|
-
|
|
235
|
+
emailConfirmCode: confirmCode
|
|
226
236
|
};
|
|
227
237
|
_context5.prev = 1;
|
|
228
238
|
_context5.next = 4;
|
|
229
|
-
return this.axios.post('/user_service/
|
|
239
|
+
return this.axios.post('/user_service/confirmUserEmail', [params]);
|
|
230
240
|
case 4:
|
|
231
241
|
response = _context5.sent;
|
|
232
|
-
|
|
242
|
+
if (!(response.data.ok === false)) {
|
|
243
|
+
_context5.next = 7;
|
|
244
|
+
break;
|
|
245
|
+
}
|
|
246
|
+
return _context5.abrupt("return", this._handleError(response));
|
|
247
|
+
case 7:
|
|
248
|
+
return _context5.abrupt("return", response.data);
|
|
249
|
+
case 10:
|
|
250
|
+
_context5.prev = 10;
|
|
251
|
+
_context5.t0 = _context5["catch"](1);
|
|
252
|
+
return _context5.abrupt("return", this._handleError(_context5.t0));
|
|
253
|
+
case 13:
|
|
254
|
+
case "end":
|
|
255
|
+
return _context5.stop();
|
|
256
|
+
}
|
|
257
|
+
}, _callee5, this, [[1, 10]]);
|
|
258
|
+
}));
|
|
259
|
+
function confirmUserEmail(_x2) {
|
|
260
|
+
return _confirmUserEmail.apply(this, arguments);
|
|
261
|
+
}
|
|
262
|
+
return confirmUserEmail;
|
|
263
|
+
}()
|
|
264
|
+
}, {
|
|
265
|
+
key: "loadUser",
|
|
266
|
+
value: function () {
|
|
267
|
+
var _loadUser = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(userId) {
|
|
268
|
+
var params, _response$data, response, userData, User;
|
|
269
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
270
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
271
|
+
case 0:
|
|
272
|
+
params = {
|
|
273
|
+
id: userId
|
|
274
|
+
};
|
|
275
|
+
_context6.prev = 1;
|
|
276
|
+
_context6.next = 4;
|
|
277
|
+
return this.axios.post('/user_service/loadUser', [params]);
|
|
278
|
+
case 4:
|
|
279
|
+
response = _context6.sent;
|
|
280
|
+
userData = response === null || response === void 0 || (_response$data = response.data) === null || _response$data === void 0 ? void 0 : _response$data.user;
|
|
233
281
|
User = new _rbt_user["default"]({
|
|
234
282
|
id: userData.id
|
|
235
283
|
}, this.axios);
|
|
236
284
|
User.setData(userData);
|
|
237
|
-
return
|
|
285
|
+
return _context6.abrupt("return", User);
|
|
238
286
|
case 11:
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
return
|
|
287
|
+
_context6.prev = 11;
|
|
288
|
+
_context6.t0 = _context6["catch"](1);
|
|
289
|
+
return _context6.abrupt("return", this._handleError(_context6.t0));
|
|
242
290
|
case 14:
|
|
243
291
|
case "end":
|
|
244
|
-
return
|
|
292
|
+
return _context6.stop();
|
|
245
293
|
}
|
|
246
|
-
},
|
|
294
|
+
}, _callee6, this, [[1, 11]]);
|
|
247
295
|
}));
|
|
248
|
-
function loadUser(
|
|
296
|
+
function loadUser(_x3) {
|
|
249
297
|
return _loadUser.apply(this, arguments);
|
|
250
298
|
}
|
|
251
299
|
return loadUser;
|
|
@@ -253,28 +301,29 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
253
301
|
}, {
|
|
254
302
|
key: "refreshAuthToken",
|
|
255
303
|
value: function () {
|
|
256
|
-
var _refreshAuthToken = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
304
|
+
var _refreshAuthToken = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(authtoken) {
|
|
257
305
|
var response;
|
|
258
|
-
return _regeneratorRuntime().wrap(function
|
|
259
|
-
while (1) switch (
|
|
306
|
+
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
307
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
260
308
|
case 0:
|
|
261
|
-
|
|
262
|
-
|
|
309
|
+
_context7.prev = 0;
|
|
310
|
+
_context7.next = 3;
|
|
263
311
|
return this.axios.post('/user_service/refreshAuthToken', [authtoken]);
|
|
264
312
|
case 3:
|
|
265
|
-
response =
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
313
|
+
response = _context7.sent;
|
|
314
|
+
debugger;
|
|
315
|
+
return _context7.abrupt("return", response.data);
|
|
316
|
+
case 8:
|
|
317
|
+
_context7.prev = 8;
|
|
318
|
+
_context7.t0 = _context7["catch"](0);
|
|
319
|
+
this._handleError(_context7.t0);
|
|
320
|
+
case 11:
|
|
272
321
|
case "end":
|
|
273
|
-
return
|
|
322
|
+
return _context7.stop();
|
|
274
323
|
}
|
|
275
|
-
},
|
|
324
|
+
}, _callee7, this, [[0, 8]]);
|
|
276
325
|
}));
|
|
277
|
-
function refreshAuthToken(
|
|
326
|
+
function refreshAuthToken(_x4) {
|
|
278
327
|
return _refreshAuthToken.apply(this, arguments);
|
|
279
328
|
}
|
|
280
329
|
return refreshAuthToken;
|
|
@@ -289,35 +338,32 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
289
338
|
}, {
|
|
290
339
|
key: "registerUser",
|
|
291
340
|
value: function () {
|
|
292
|
-
var _registerUser = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
341
|
+
var _registerUser = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
|
|
293
342
|
var dataHash,
|
|
294
343
|
response,
|
|
295
344
|
record,
|
|
296
|
-
|
|
297
|
-
return _regeneratorRuntime().wrap(function
|
|
298
|
-
while (1) switch (
|
|
345
|
+
_args8 = arguments;
|
|
346
|
+
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
|
|
347
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
299
348
|
case 0:
|
|
300
|
-
dataHash =
|
|
301
|
-
|
|
302
|
-
|
|
349
|
+
dataHash = _args8.length > 0 && _args8[0] !== undefined ? _args8[0] : {};
|
|
350
|
+
_context8.prev = 1;
|
|
351
|
+
_context8.next = 4;
|
|
303
352
|
return this.axios.post('/user_service/registerUser', [dataHash]);
|
|
304
353
|
case 4:
|
|
305
|
-
response =
|
|
354
|
+
response = _context8.sent;
|
|
306
355
|
record = response.data;
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
case 10:
|
|
312
|
-
_context7.prev = 10;
|
|
313
|
-
_context7.t0 = _context7["catch"](1);
|
|
356
|
+
return _context8.abrupt("return", new _rbt_user["default"](record, this.axios));
|
|
357
|
+
case 9:
|
|
358
|
+
_context8.prev = 9;
|
|
359
|
+
_context8.t0 = _context8["catch"](1);
|
|
314
360
|
debugger;
|
|
315
|
-
return
|
|
316
|
-
case
|
|
361
|
+
return _context8.abrupt("return", this._handleError(_context8.t0));
|
|
362
|
+
case 13:
|
|
317
363
|
case "end":
|
|
318
|
-
return
|
|
364
|
+
return _context8.stop();
|
|
319
365
|
}
|
|
320
|
-
},
|
|
366
|
+
}, _callee8, this, [[1, 9]]);
|
|
321
367
|
}));
|
|
322
368
|
function registerUser() {
|
|
323
369
|
return _registerUser.apply(this, arguments);
|
|
@@ -334,32 +380,32 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
334
380
|
}, {
|
|
335
381
|
key: "createFile",
|
|
336
382
|
value: function () {
|
|
337
|
-
var _createFile = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
383
|
+
var _createFile = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(dataHash) {
|
|
338
384
|
var response, record;
|
|
339
|
-
return _regeneratorRuntime().wrap(function
|
|
340
|
-
while (1) switch (
|
|
385
|
+
return _regeneratorRuntime().wrap(function _callee9$(_context9) {
|
|
386
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
341
387
|
case 0:
|
|
342
|
-
|
|
343
|
-
|
|
388
|
+
_context9.prev = 0;
|
|
389
|
+
_context9.next = 3;
|
|
344
390
|
return this.axios.post('/object_service/createObject', ['<@filekit.file>', dataHash]);
|
|
345
391
|
case 3:
|
|
346
|
-
response =
|
|
392
|
+
response = _context9.sent;
|
|
347
393
|
record = response.data;
|
|
348
394
|
if (dataHash) {
|
|
349
395
|
record.data = dataHash;
|
|
350
396
|
}
|
|
351
|
-
return
|
|
397
|
+
return _context9.abrupt("return", new _rbt_file["default"](record, this.axios, this.localDb));
|
|
352
398
|
case 9:
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
return
|
|
399
|
+
_context9.prev = 9;
|
|
400
|
+
_context9.t0 = _context9["catch"](0);
|
|
401
|
+
return _context9.abrupt("return", this._handleError(_context9.t0));
|
|
356
402
|
case 12:
|
|
357
403
|
case "end":
|
|
358
|
-
return
|
|
404
|
+
return _context9.stop();
|
|
359
405
|
}
|
|
360
|
-
},
|
|
406
|
+
}, _callee9, this, [[0, 9]]);
|
|
361
407
|
}));
|
|
362
|
-
function createFile(
|
|
408
|
+
function createFile(_x5) {
|
|
363
409
|
return _createFile.apply(this, arguments);
|
|
364
410
|
}
|
|
365
411
|
return createFile;
|
|
@@ -374,38 +420,38 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
374
420
|
}, {
|
|
375
421
|
key: "create",
|
|
376
422
|
value: function () {
|
|
377
|
-
var _create = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
423
|
+
var _create = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(type) {
|
|
378
424
|
var dataHash,
|
|
379
425
|
response,
|
|
380
426
|
record,
|
|
381
|
-
|
|
382
|
-
return _regeneratorRuntime().wrap(function
|
|
383
|
-
while (1) switch (
|
|
427
|
+
_args10 = arguments;
|
|
428
|
+
return _regeneratorRuntime().wrap(function _callee10$(_context10) {
|
|
429
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
384
430
|
case 0:
|
|
385
|
-
dataHash =
|
|
386
|
-
|
|
387
|
-
|
|
431
|
+
dataHash = _args10.length > 1 && _args10[1] !== undefined ? _args10[1] : {};
|
|
432
|
+
_context10.prev = 1;
|
|
433
|
+
_context10.next = 4;
|
|
388
434
|
return this.axios.post('/object_service/createObject', [type, dataHash]);
|
|
389
435
|
case 4:
|
|
390
|
-
response =
|
|
436
|
+
response = _context10.sent;
|
|
391
437
|
record = response.data;
|
|
392
438
|
if (dataHash) {
|
|
393
439
|
record.data = dataHash;
|
|
394
440
|
}
|
|
395
|
-
return
|
|
441
|
+
return _context10.abrupt("return", new _rbt_object["default"](record, this.axios, {
|
|
396
442
|
isNew: true
|
|
397
443
|
}));
|
|
398
444
|
case 10:
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
return
|
|
445
|
+
_context10.prev = 10;
|
|
446
|
+
_context10.t0 = _context10["catch"](1);
|
|
447
|
+
return _context10.abrupt("return", this._handleError(_context10.t0));
|
|
402
448
|
case 13:
|
|
403
449
|
case "end":
|
|
404
|
-
return
|
|
450
|
+
return _context10.stop();
|
|
405
451
|
}
|
|
406
|
-
},
|
|
452
|
+
}, _callee10, this, [[1, 10]]);
|
|
407
453
|
}));
|
|
408
|
-
function create(
|
|
454
|
+
function create(_x6) {
|
|
409
455
|
return _create.apply(this, arguments);
|
|
410
456
|
}
|
|
411
457
|
return create;
|
|
@@ -441,19 +487,19 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
441
487
|
}, {
|
|
442
488
|
key: "query",
|
|
443
489
|
value: function () {
|
|
444
|
-
var _query = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
490
|
+
var _query = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(type) {
|
|
445
491
|
var _this = this;
|
|
446
492
|
var params,
|
|
447
493
|
defaultOrderBy,
|
|
448
494
|
defaultLimit,
|
|
449
495
|
mergedParams,
|
|
450
496
|
response,
|
|
451
|
-
|
|
452
|
-
return _regeneratorRuntime().wrap(function
|
|
453
|
-
while (1) switch (
|
|
497
|
+
_args11 = arguments;
|
|
498
|
+
return _regeneratorRuntime().wrap(function _callee11$(_context11) {
|
|
499
|
+
while (1) switch (_context11.prev = _context11.next) {
|
|
454
500
|
case 0:
|
|
455
|
-
params =
|
|
456
|
-
|
|
501
|
+
params = _args11.length > 1 && _args11[1] !== undefined ? _args11[1] : {};
|
|
502
|
+
_context11.prev = 1;
|
|
457
503
|
params.type = type;
|
|
458
504
|
|
|
459
505
|
// Default ordering and pagination
|
|
@@ -470,15 +516,15 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
470
516
|
}
|
|
471
517
|
}; // Merge defaults with provided params
|
|
472
518
|
mergedParams = _objectSpread(_objectSpread(_objectSpread({}, defaultOrderBy), defaultLimit), params);
|
|
473
|
-
|
|
519
|
+
_context11.next = 8;
|
|
474
520
|
return this.axios.post('/object_service/queryObjects', [mergedParams]);
|
|
475
521
|
case 8:
|
|
476
|
-
response =
|
|
522
|
+
response = _context11.sent;
|
|
477
523
|
if (!(response.data.ok === false)) {
|
|
478
|
-
|
|
524
|
+
_context11.next = 11;
|
|
479
525
|
break;
|
|
480
526
|
}
|
|
481
|
-
return
|
|
527
|
+
return _context11.abrupt("return", this._handleError(response));
|
|
482
528
|
case 11:
|
|
483
529
|
// Process items into RbtObject instances
|
|
484
530
|
if (Array.isArray(response.data.items)) {
|
|
@@ -488,18 +534,18 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
488
534
|
});
|
|
489
535
|
});
|
|
490
536
|
}
|
|
491
|
-
return
|
|
537
|
+
return _context11.abrupt("return", response.data.items);
|
|
492
538
|
case 15:
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
return
|
|
539
|
+
_context11.prev = 15;
|
|
540
|
+
_context11.t0 = _context11["catch"](1);
|
|
541
|
+
return _context11.abrupt("return", this._handleError(_context11.t0));
|
|
496
542
|
case 18:
|
|
497
543
|
case "end":
|
|
498
|
-
return
|
|
544
|
+
return _context11.stop();
|
|
499
545
|
}
|
|
500
|
-
},
|
|
546
|
+
}, _callee11, this, [[1, 15]]);
|
|
501
547
|
}));
|
|
502
|
-
function query(
|
|
548
|
+
function query(_x7) {
|
|
503
549
|
return _query.apply(this, arguments);
|
|
504
550
|
}
|
|
505
551
|
return query;
|
|
@@ -515,47 +561,47 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
515
561
|
}, {
|
|
516
562
|
key: "load",
|
|
517
563
|
value: function () {
|
|
518
|
-
var _load = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
564
|
+
var _load = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(type, ids) {
|
|
519
565
|
var params,
|
|
520
566
|
mergedParams,
|
|
521
567
|
res,
|
|
522
|
-
|
|
523
|
-
return _regeneratorRuntime().wrap(function
|
|
524
|
-
while (1) switch (
|
|
568
|
+
_args12 = arguments;
|
|
569
|
+
return _regeneratorRuntime().wrap(function _callee12$(_context12) {
|
|
570
|
+
while (1) switch (_context12.prev = _context12.next) {
|
|
525
571
|
case 0:
|
|
526
|
-
params =
|
|
527
|
-
|
|
572
|
+
params = _args12.length > 2 && _args12[2] !== undefined ? _args12[2] : {};
|
|
573
|
+
_context12.prev = 1;
|
|
528
574
|
if (!Array.isArray(ids)) {
|
|
529
|
-
|
|
575
|
+
_context12.next = 7;
|
|
530
576
|
break;
|
|
531
577
|
}
|
|
532
578
|
mergedParams = _objectSpread(_objectSpread({}, params), {}, {
|
|
533
579
|
where: "id IN (" + ids.join(',') + ")"
|
|
534
580
|
});
|
|
535
|
-
return
|
|
581
|
+
return _context12.abrupt("return", this.query(type, mergedParams));
|
|
536
582
|
case 7:
|
|
537
583
|
mergedParams = _objectSpread(_objectSpread({}, params), {}, {
|
|
538
584
|
where: "id=" + ids
|
|
539
585
|
});
|
|
540
|
-
|
|
586
|
+
_context12.next = 10;
|
|
541
587
|
return this.query(type, mergedParams);
|
|
542
588
|
case 10:
|
|
543
|
-
res =
|
|
544
|
-
return
|
|
589
|
+
res = _context12.sent;
|
|
590
|
+
return _context12.abrupt("return", res[0]);
|
|
545
591
|
case 12:
|
|
546
|
-
|
|
592
|
+
_context12.next = 17;
|
|
547
593
|
break;
|
|
548
594
|
case 14:
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
return
|
|
595
|
+
_context12.prev = 14;
|
|
596
|
+
_context12.t0 = _context12["catch"](1);
|
|
597
|
+
return _context12.abrupt("return", this._handleError(_context12.t0));
|
|
552
598
|
case 17:
|
|
553
599
|
case "end":
|
|
554
|
-
return
|
|
600
|
+
return _context12.stop();
|
|
555
601
|
}
|
|
556
|
-
},
|
|
602
|
+
}, _callee12, this, [[1, 14]]);
|
|
557
603
|
}));
|
|
558
|
-
function load(
|
|
604
|
+
function load(_x8, _x9) {
|
|
559
605
|
return _load.apply(this, arguments);
|
|
560
606
|
}
|
|
561
607
|
return load;
|
|
@@ -576,7 +622,7 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
576
622
|
}, {
|
|
577
623
|
key: "runTask",
|
|
578
624
|
value: function () {
|
|
579
|
-
var _runTask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
625
|
+
var _runTask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
|
|
580
626
|
var params,
|
|
581
627
|
callbacks,
|
|
582
628
|
onProgress,
|
|
@@ -588,20 +634,20 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
588
634
|
status,
|
|
589
635
|
message,
|
|
590
636
|
output,
|
|
591
|
-
|
|
592
|
-
return _regeneratorRuntime().wrap(function
|
|
593
|
-
while (1) switch (
|
|
637
|
+
_args13 = arguments;
|
|
638
|
+
return _regeneratorRuntime().wrap(function _callee13$(_context13) {
|
|
639
|
+
while (1) switch (_context13.prev = _context13.next) {
|
|
594
640
|
case 0:
|
|
595
|
-
params =
|
|
596
|
-
callbacks =
|
|
641
|
+
params = _args13.length > 0 && _args13[0] !== undefined ? _args13[0] : {};
|
|
642
|
+
callbacks = _args13.length > 1 && _args13[1] !== undefined ? _args13[1] : {};
|
|
597
643
|
onProgress = callbacks.onProgress, onError = callbacks.onError, onFinish = callbacks.onFinish;
|
|
598
|
-
|
|
599
|
-
|
|
644
|
+
_context13.prev = 3;
|
|
645
|
+
_context13.next = 6;
|
|
600
646
|
return this.post('http://localhost:3004/runChain', params);
|
|
601
647
|
case 6:
|
|
602
|
-
response =
|
|
648
|
+
response = _context13.sent;
|
|
603
649
|
if (response) {
|
|
604
|
-
|
|
650
|
+
_context13.next = 9;
|
|
605
651
|
break;
|
|
606
652
|
}
|
|
607
653
|
throw new Error('Invalid server response');
|
|
@@ -609,7 +655,7 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
609
655
|
// Validate response structure
|
|
610
656
|
ok = response.ok, jobId = response.jobId, status = response.status, message = response.message, output = response.output;
|
|
611
657
|
if (!(!ok || typeof jobId !== 'string' || typeof status !== 'string')) {
|
|
612
|
-
|
|
658
|
+
_context13.next = 12;
|
|
613
659
|
break;
|
|
614
660
|
}
|
|
615
661
|
throw new Error('Invalid response structure');
|
|
@@ -627,7 +673,7 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
627
673
|
console.log('Finish (request) ', response);
|
|
628
674
|
onFinish(response);
|
|
629
675
|
}
|
|
630
|
-
return
|
|
676
|
+
return _context13.abrupt("return", {
|
|
631
677
|
ok: ok,
|
|
632
678
|
jobId: jobId,
|
|
633
679
|
status: status,
|
|
@@ -635,24 +681,24 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
635
681
|
output: output
|
|
636
682
|
});
|
|
637
683
|
case 18:
|
|
638
|
-
|
|
639
|
-
|
|
684
|
+
_context13.prev = 18;
|
|
685
|
+
_context13.t0 = _context13["catch"](3);
|
|
640
686
|
if (typeof onError === 'function') {
|
|
641
|
-
onError(
|
|
687
|
+
onError(_context13.t0);
|
|
642
688
|
} else {
|
|
643
|
-
console.error('Error in runTask:',
|
|
689
|
+
console.error('Error in runTask:', _context13.t0);
|
|
644
690
|
}
|
|
645
|
-
return
|
|
691
|
+
return _context13.abrupt("return", {
|
|
646
692
|
ok: false,
|
|
647
693
|
jobId: null,
|
|
648
694
|
status: 'ERROR',
|
|
649
|
-
error:
|
|
695
|
+
error: _context13.t0.message
|
|
650
696
|
});
|
|
651
697
|
case 22:
|
|
652
698
|
case "end":
|
|
653
|
-
return
|
|
699
|
+
return _context13.stop();
|
|
654
700
|
}
|
|
655
|
-
},
|
|
701
|
+
}, _callee13, this, [[3, 18]]);
|
|
656
702
|
}));
|
|
657
703
|
function runTask() {
|
|
658
704
|
return _runTask.apply(this, arguments);
|
|
@@ -672,26 +718,26 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
672
718
|
}, {
|
|
673
719
|
key: "pollTaskProgress",
|
|
674
720
|
value: function () {
|
|
675
|
-
var _pollTaskProgress = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
721
|
+
var _pollTaskProgress = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(jobId, callbacks) {
|
|
676
722
|
var _this2 = this;
|
|
677
723
|
var onProgress, onError, onFinish, checkProgress;
|
|
678
|
-
return _regeneratorRuntime().wrap(function
|
|
679
|
-
while (1) switch (
|
|
724
|
+
return _regeneratorRuntime().wrap(function _callee15$(_context15) {
|
|
725
|
+
while (1) switch (_context15.prev = _context15.next) {
|
|
680
726
|
case 0:
|
|
681
727
|
onProgress = callbacks.onProgress, onError = callbacks.onError, onFinish = callbacks.onFinish;
|
|
682
|
-
|
|
728
|
+
_context15.prev = 1;
|
|
683
729
|
checkProgress = /*#__PURE__*/function () {
|
|
684
|
-
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
730
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {
|
|
685
731
|
var response;
|
|
686
|
-
return _regeneratorRuntime().wrap(function
|
|
687
|
-
while (1) switch (
|
|
732
|
+
return _regeneratorRuntime().wrap(function _callee14$(_context14) {
|
|
733
|
+
while (1) switch (_context14.prev = _context14.next) {
|
|
688
734
|
case 0:
|
|
689
|
-
|
|
735
|
+
_context14.next = 2;
|
|
690
736
|
return _this2.get("http://localhost:3004/pollChainProgress", {
|
|
691
737
|
jobId: jobId
|
|
692
738
|
});
|
|
693
739
|
case 2:
|
|
694
|
-
response =
|
|
740
|
+
response = _context14.sent;
|
|
695
741
|
// If the task is still in progress, start polling for updates
|
|
696
742
|
if (response.status === 'DONE' && onFinish) {
|
|
697
743
|
// Provide the current progress to the callback function
|
|
@@ -714,28 +760,28 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
714
760
|
}
|
|
715
761
|
case 7:
|
|
716
762
|
case "end":
|
|
717
|
-
return
|
|
763
|
+
return _context14.stop();
|
|
718
764
|
}
|
|
719
|
-
},
|
|
765
|
+
}, _callee14);
|
|
720
766
|
}));
|
|
721
767
|
return function checkProgress() {
|
|
722
768
|
return _ref2.apply(this, arguments);
|
|
723
769
|
};
|
|
724
770
|
}();
|
|
725
771
|
checkProgress();
|
|
726
|
-
|
|
772
|
+
_context15.next = 9;
|
|
727
773
|
break;
|
|
728
774
|
case 6:
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
return
|
|
775
|
+
_context15.prev = 6;
|
|
776
|
+
_context15.t0 = _context15["catch"](1);
|
|
777
|
+
return _context15.abrupt("return", this._handleError(_context15.t0));
|
|
732
778
|
case 9:
|
|
733
779
|
case "end":
|
|
734
|
-
return
|
|
780
|
+
return _context15.stop();
|
|
735
781
|
}
|
|
736
|
-
},
|
|
782
|
+
}, _callee15, this, [[1, 6]]);
|
|
737
783
|
}));
|
|
738
|
-
function pollTaskProgress(
|
|
784
|
+
function pollTaskProgress(_x10, _x11) {
|
|
739
785
|
return _pollTaskProgress.apply(this, arguments);
|
|
740
786
|
}
|
|
741
787
|
return pollTaskProgress;
|
|
@@ -754,45 +800,45 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
754
800
|
}, {
|
|
755
801
|
key: "get",
|
|
756
802
|
value: function () {
|
|
757
|
-
var _get = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
803
|
+
var _get = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(endpoint) {
|
|
758
804
|
var params,
|
|
759
805
|
headers,
|
|
760
806
|
response,
|
|
761
|
-
|
|
762
|
-
return _regeneratorRuntime().wrap(function
|
|
763
|
-
while (1) switch (
|
|
807
|
+
_args16 = arguments;
|
|
808
|
+
return _regeneratorRuntime().wrap(function _callee16$(_context16) {
|
|
809
|
+
while (1) switch (_context16.prev = _context16.next) {
|
|
764
810
|
case 0:
|
|
765
|
-
params =
|
|
766
|
-
|
|
811
|
+
params = _args16.length > 1 && _args16[1] !== undefined ? _args16[1] : {};
|
|
812
|
+
_context16.prev = 1;
|
|
767
813
|
// Add the authToken to the headers
|
|
768
814
|
headers = {
|
|
769
815
|
authtoken: this.authtoken
|
|
770
816
|
}; // Make the GET request using Axios
|
|
771
|
-
|
|
817
|
+
_context16.next = 5;
|
|
772
818
|
return this.axios.get(endpoint, {
|
|
773
819
|
params: params,
|
|
774
820
|
headers: headers
|
|
775
821
|
});
|
|
776
822
|
case 5:
|
|
777
|
-
response =
|
|
823
|
+
response = _context16.sent;
|
|
778
824
|
if (!(response.data.ok === false)) {
|
|
779
|
-
|
|
825
|
+
_context16.next = 8;
|
|
780
826
|
break;
|
|
781
827
|
}
|
|
782
|
-
return
|
|
828
|
+
return _context16.abrupt("return", this._handleError(response));
|
|
783
829
|
case 8:
|
|
784
|
-
return
|
|
830
|
+
return _context16.abrupt("return", response.data);
|
|
785
831
|
case 11:
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
return
|
|
832
|
+
_context16.prev = 11;
|
|
833
|
+
_context16.t0 = _context16["catch"](1);
|
|
834
|
+
return _context16.abrupt("return", this._handleError(_context16.t0));
|
|
789
835
|
case 14:
|
|
790
836
|
case "end":
|
|
791
|
-
return
|
|
837
|
+
return _context16.stop();
|
|
792
838
|
}
|
|
793
|
-
},
|
|
839
|
+
}, _callee16, this, [[1, 11]]);
|
|
794
840
|
}));
|
|
795
|
-
function get(
|
|
841
|
+
function get(_x12) {
|
|
796
842
|
return _get.apply(this, arguments);
|
|
797
843
|
}
|
|
798
844
|
return get;
|
|
@@ -812,44 +858,44 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
812
858
|
}, {
|
|
813
859
|
key: "post",
|
|
814
860
|
value: function () {
|
|
815
|
-
var _post = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
861
|
+
var _post = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17(endpoint) {
|
|
816
862
|
var data,
|
|
817
863
|
headers,
|
|
818
864
|
response,
|
|
819
|
-
|
|
820
|
-
return _regeneratorRuntime().wrap(function
|
|
821
|
-
while (1) switch (
|
|
865
|
+
_args17 = arguments;
|
|
866
|
+
return _regeneratorRuntime().wrap(function _callee17$(_context17) {
|
|
867
|
+
while (1) switch (_context17.prev = _context17.next) {
|
|
822
868
|
case 0:
|
|
823
|
-
data =
|
|
824
|
-
|
|
869
|
+
data = _args17.length > 1 && _args17[1] !== undefined ? _args17[1] : {};
|
|
870
|
+
_context17.prev = 1;
|
|
825
871
|
// Add the authToken to the headers
|
|
826
872
|
headers = {
|
|
827
873
|
authtoken: this.authtoken
|
|
828
874
|
}; // Make the POST request using Axios
|
|
829
|
-
|
|
875
|
+
_context17.next = 5;
|
|
830
876
|
return this.axios.post(endpoint, data, {
|
|
831
877
|
headers: headers
|
|
832
878
|
});
|
|
833
879
|
case 5:
|
|
834
|
-
response =
|
|
880
|
+
response = _context17.sent;
|
|
835
881
|
if (!(response.data.ok === false)) {
|
|
836
|
-
|
|
882
|
+
_context17.next = 8;
|
|
837
883
|
break;
|
|
838
884
|
}
|
|
839
|
-
return
|
|
885
|
+
return _context17.abrupt("return", this._handleError(response));
|
|
840
886
|
case 8:
|
|
841
|
-
return
|
|
887
|
+
return _context17.abrupt("return", response.data);
|
|
842
888
|
case 11:
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
return
|
|
889
|
+
_context17.prev = 11;
|
|
890
|
+
_context17.t0 = _context17["catch"](1);
|
|
891
|
+
return _context17.abrupt("return", this._handleError(_context17.t0));
|
|
846
892
|
case 14:
|
|
847
893
|
case "end":
|
|
848
|
-
return
|
|
894
|
+
return _context17.stop();
|
|
849
895
|
}
|
|
850
|
-
},
|
|
896
|
+
}, _callee17, this, [[1, 11]]);
|
|
851
897
|
}));
|
|
852
|
-
function post(
|
|
898
|
+
function post(_x13) {
|
|
853
899
|
return _post.apply(this, arguments);
|
|
854
900
|
}
|
|
855
901
|
return post;
|