roboto-js 1.5.6 → 1.6.0
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/client_test.js +1 -1
- package/dist/cjs/index.cjs +7 -3
- package/dist/cjs/rbt_api.cjs +388 -349
- package/dist/esm/index.js +7 -3
- package/dist/esm/rbt_api.js +20 -6
- package/package.json +1 -1
- package/src/index.js +7 -2
- package/src/rbt_api.js +26 -5
package/dist/cjs/rbt_api.cjs
CHANGED
|
@@ -26,20 +26,19 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
|
|
|
26
26
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
27
27
|
var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
28
28
|
function RbtApi(_ref) {
|
|
29
|
-
var
|
|
30
|
-
|
|
29
|
+
var baseUrl = _ref.baseUrl,
|
|
30
|
+
accesskey = _ref.accesskey,
|
|
31
31
|
_ref$authtoken = _ref.authtoken,
|
|
32
32
|
authtoken = _ref$authtoken === void 0 ? null : _ref$authtoken,
|
|
33
|
-
_ref$
|
|
34
|
-
|
|
33
|
+
_ref$apikey = _ref.apikey,
|
|
34
|
+
apikey = _ref$apikey === void 0 ? null : _ref$apikey,
|
|
35
35
|
_ref$localStorageAdap = _ref.localStorageAdaptor,
|
|
36
36
|
localStorageAdaptor = _ref$localStorageAdap === void 0 ? null : _ref$localStorageAdap;
|
|
37
37
|
_classCallCheck(this, RbtApi);
|
|
38
38
|
this.axios = _axios["default"].create({
|
|
39
39
|
baseURL: baseUrl,
|
|
40
40
|
headers: {
|
|
41
|
-
'accesskey': accesskey
|
|
42
|
-
//'authtoken': authTokenToUse
|
|
41
|
+
'accesskey': accesskey
|
|
43
42
|
}
|
|
44
43
|
});
|
|
45
44
|
if (localStorageAdaptor) {
|
|
@@ -65,7 +64,12 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
65
64
|
this.requestCache = {};
|
|
66
65
|
|
|
67
66
|
// Use the storageAdaptor to get the authToken, if available
|
|
68
|
-
|
|
67
|
+
if (authtoken) {
|
|
68
|
+
this.initAuthToken(authtoken);
|
|
69
|
+
}
|
|
70
|
+
if (apikey) {
|
|
71
|
+
this.initApiKey(apikey);
|
|
72
|
+
}
|
|
69
73
|
}
|
|
70
74
|
_createClass(RbtApi, [{
|
|
71
75
|
key: "initAuthToken",
|
|
@@ -97,13 +101,42 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
97
101
|
return initAuthToken;
|
|
98
102
|
}()
|
|
99
103
|
}, {
|
|
100
|
-
key: "
|
|
104
|
+
key: "initApiKey",
|
|
101
105
|
value: function () {
|
|
102
|
-
var
|
|
106
|
+
var _initApiKey = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(apikey) {
|
|
103
107
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
104
108
|
while (1) switch (_context2.prev = _context2.next) {
|
|
105
109
|
case 0:
|
|
106
|
-
|
|
110
|
+
if (!(!apikey && this.localStorageAdaptor)) {
|
|
111
|
+
_context2.next = 4;
|
|
112
|
+
break;
|
|
113
|
+
}
|
|
114
|
+
_context2.next = 3;
|
|
115
|
+
return this.localStorageAdaptor.getItem('apikey');
|
|
116
|
+
case 3:
|
|
117
|
+
apikey = _context2.sent;
|
|
118
|
+
case 4:
|
|
119
|
+
this.apikey = apikey;
|
|
120
|
+
this.axios.defaults.headers.common['apikey'] = this.apikey;
|
|
121
|
+
case 6:
|
|
122
|
+
case "end":
|
|
123
|
+
return _context2.stop();
|
|
124
|
+
}
|
|
125
|
+
}, _callee2, this);
|
|
126
|
+
}));
|
|
127
|
+
function initApiKey(_x2) {
|
|
128
|
+
return _initApiKey.apply(this, arguments);
|
|
129
|
+
}
|
|
130
|
+
return initApiKey;
|
|
131
|
+
}()
|
|
132
|
+
}, {
|
|
133
|
+
key: "initLocalDb",
|
|
134
|
+
value: function () {
|
|
135
|
+
var _initLocalDb = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
|
|
136
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
137
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
138
|
+
case 0:
|
|
139
|
+
_context3.next = 2;
|
|
107
140
|
return (0, _idb.openDB)('RBTFileDatabase', 1, {
|
|
108
141
|
upgrade: function upgrade(db) {
|
|
109
142
|
if (!db.objectStoreNames.contains('files')) {
|
|
@@ -114,12 +147,12 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
114
147
|
}
|
|
115
148
|
});
|
|
116
149
|
case 2:
|
|
117
|
-
this.localDb =
|
|
150
|
+
this.localDb = _context3.sent;
|
|
118
151
|
case 3:
|
|
119
152
|
case "end":
|
|
120
|
-
return
|
|
153
|
+
return _context3.stop();
|
|
121
154
|
}
|
|
122
|
-
},
|
|
155
|
+
}, _callee3, this);
|
|
123
156
|
}));
|
|
124
157
|
function initLocalDb() {
|
|
125
158
|
return _initLocalDb.apply(this, arguments);
|
|
@@ -145,30 +178,30 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
145
178
|
}, {
|
|
146
179
|
key: "registerTypedefs",
|
|
147
180
|
value: function () {
|
|
148
|
-
var _registerTypedefs = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
181
|
+
var _registerTypedefs = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(typedefs) {
|
|
149
182
|
var response;
|
|
150
|
-
return _regeneratorRuntime().wrap(function
|
|
151
|
-
while (1) switch (
|
|
183
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
184
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
152
185
|
case 0:
|
|
153
|
-
|
|
154
|
-
|
|
186
|
+
_context4.prev = 0;
|
|
187
|
+
_context4.next = 3;
|
|
155
188
|
return this.axios.post('/api/doctree/registerTypedefs', [{
|
|
156
189
|
typedefs: typedefs
|
|
157
190
|
}]);
|
|
158
191
|
case 3:
|
|
159
|
-
response =
|
|
160
|
-
return
|
|
192
|
+
response = _context4.sent;
|
|
193
|
+
return _context4.abrupt("return", response.data);
|
|
161
194
|
case 7:
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
this._handleError(
|
|
195
|
+
_context4.prev = 7;
|
|
196
|
+
_context4.t0 = _context4["catch"](0);
|
|
197
|
+
this._handleError(_context4.t0);
|
|
165
198
|
case 10:
|
|
166
199
|
case "end":
|
|
167
|
-
return
|
|
200
|
+
return _context4.stop();
|
|
168
201
|
}
|
|
169
|
-
},
|
|
202
|
+
}, _callee4, this, [[0, 7]]);
|
|
170
203
|
}));
|
|
171
|
-
function registerTypedefs(
|
|
204
|
+
function registerTypedefs(_x3) {
|
|
172
205
|
return _registerTypedefs.apply(this, arguments);
|
|
173
206
|
}
|
|
174
207
|
return registerTypedefs;
|
|
@@ -185,13 +218,13 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
185
218
|
}, {
|
|
186
219
|
key: "login",
|
|
187
220
|
value: (function () {
|
|
188
|
-
var _login = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
221
|
+
var _login = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(params) {
|
|
189
222
|
var response;
|
|
190
|
-
return _regeneratorRuntime().wrap(function
|
|
191
|
-
while (1) switch (
|
|
223
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
224
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
192
225
|
case 0:
|
|
193
|
-
|
|
194
|
-
|
|
226
|
+
_context5.prev = 0;
|
|
227
|
+
_context5.next = 3;
|
|
195
228
|
return this.axios.post('/user_service/loginUser', [{
|
|
196
229
|
email: params.email,
|
|
197
230
|
password: params.password ? _cryptoJs["default"].MD5(params.password).toString(_cryptoJs["default"].enc.Hex) : null,
|
|
@@ -201,12 +234,12 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
201
234
|
code: params.code || null // single-use signon code (password resets)
|
|
202
235
|
}]);
|
|
203
236
|
case 3:
|
|
204
|
-
response =
|
|
237
|
+
response = _context5.sent;
|
|
205
238
|
if (!(response.data.ok === false)) {
|
|
206
|
-
|
|
239
|
+
_context5.next = 6;
|
|
207
240
|
break;
|
|
208
241
|
}
|
|
209
|
-
return
|
|
242
|
+
return _context5.abrupt("return", this._handleError(response));
|
|
210
243
|
case 6:
|
|
211
244
|
this.iac_session = response.data;
|
|
212
245
|
this.currentUser = this.iac_session ? new _rbt_user["default"](this.iac_session.user, this.axios) : null;
|
|
@@ -214,24 +247,24 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
214
247
|
this.axios.defaults.headers.common['authtoken'] = response.data.authToken;
|
|
215
248
|
this.authtoken = response.data.authToken;
|
|
216
249
|
if (!this.localStorageAdaptor) {
|
|
217
|
-
|
|
250
|
+
_context5.next = 13;
|
|
218
251
|
break;
|
|
219
252
|
}
|
|
220
|
-
|
|
253
|
+
_context5.next = 13;
|
|
221
254
|
return this.localStorageAdaptor.setItem('authtoken', response.data.authToken);
|
|
222
255
|
case 13:
|
|
223
|
-
return
|
|
256
|
+
return _context5.abrupt("return", response.data);
|
|
224
257
|
case 16:
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
this._handleError(
|
|
258
|
+
_context5.prev = 16;
|
|
259
|
+
_context5.t0 = _context5["catch"](0);
|
|
260
|
+
this._handleError(_context5.t0);
|
|
228
261
|
case 19:
|
|
229
262
|
case "end":
|
|
230
|
-
return
|
|
263
|
+
return _context5.stop();
|
|
231
264
|
}
|
|
232
|
-
},
|
|
265
|
+
}, _callee5, this, [[0, 16]]);
|
|
233
266
|
}));
|
|
234
|
-
function login(
|
|
267
|
+
function login(_x4) {
|
|
235
268
|
return _login.apply(this, arguments);
|
|
236
269
|
}
|
|
237
270
|
return login;
|
|
@@ -239,21 +272,21 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
239
272
|
}, {
|
|
240
273
|
key: "loginWithOauth",
|
|
241
274
|
value: function () {
|
|
242
|
-
var _loginWithOauth = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
275
|
+
var _loginWithOauth = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(userData) {
|
|
243
276
|
var response;
|
|
244
|
-
return _regeneratorRuntime().wrap(function
|
|
245
|
-
while (1) switch (
|
|
277
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
278
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
246
279
|
case 0:
|
|
247
|
-
|
|
248
|
-
|
|
280
|
+
_context6.prev = 0;
|
|
281
|
+
_context6.next = 3;
|
|
249
282
|
return this.post('/api/account/registerOrSigninOauth', userData);
|
|
250
283
|
case 3:
|
|
251
|
-
response =
|
|
284
|
+
response = _context6.sent;
|
|
252
285
|
if (!(response.ok === false)) {
|
|
253
|
-
|
|
286
|
+
_context6.next = 6;
|
|
254
287
|
break;
|
|
255
288
|
}
|
|
256
|
-
return
|
|
289
|
+
return _context6.abrupt("return", this._handleError(response));
|
|
257
290
|
case 6:
|
|
258
291
|
this.iac_session = response;
|
|
259
292
|
this.currentUser = this.iac_session ? new _rbt_user["default"](this.iac_session.user, this.axios) : null;
|
|
@@ -261,24 +294,24 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
261
294
|
this.axios.defaults.headers.common['authtoken'] = response.authToken;
|
|
262
295
|
this.authtoken = response.authToken;
|
|
263
296
|
if (!this.localStorageAdaptor) {
|
|
264
|
-
|
|
297
|
+
_context6.next = 13;
|
|
265
298
|
break;
|
|
266
299
|
}
|
|
267
|
-
|
|
300
|
+
_context6.next = 13;
|
|
268
301
|
return this.localStorageAdaptor.setItem('authtoken', response.authToken);
|
|
269
302
|
case 13:
|
|
270
|
-
return
|
|
303
|
+
return _context6.abrupt("return", response);
|
|
271
304
|
case 16:
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
this._handleError(
|
|
305
|
+
_context6.prev = 16;
|
|
306
|
+
_context6.t0 = _context6["catch"](0);
|
|
307
|
+
this._handleError(_context6.t0);
|
|
275
308
|
case 19:
|
|
276
309
|
case "end":
|
|
277
|
-
return
|
|
310
|
+
return _context6.stop();
|
|
278
311
|
}
|
|
279
|
-
},
|
|
312
|
+
}, _callee6, this, [[0, 16]]);
|
|
280
313
|
}));
|
|
281
|
-
function loginWithOauth(
|
|
314
|
+
function loginWithOauth(_x5) {
|
|
282
315
|
return _loginWithOauth.apply(this, arguments);
|
|
283
316
|
}
|
|
284
317
|
return loginWithOauth;
|
|
@@ -286,21 +319,21 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
286
319
|
}, {
|
|
287
320
|
key: "logout",
|
|
288
321
|
value: function () {
|
|
289
|
-
var _logout = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
322
|
+
var _logout = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
|
|
290
323
|
var response;
|
|
291
|
-
return _regeneratorRuntime().wrap(function
|
|
292
|
-
while (1) switch (
|
|
324
|
+
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
325
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
293
326
|
case 0:
|
|
294
|
-
|
|
295
|
-
|
|
327
|
+
_context7.prev = 0;
|
|
328
|
+
_context7.next = 3;
|
|
296
329
|
return this.axios.post('/user_service/logoutUser');
|
|
297
330
|
case 3:
|
|
298
|
-
response =
|
|
331
|
+
response = _context7.sent;
|
|
299
332
|
if (!(response.data.ok === false)) {
|
|
300
|
-
|
|
333
|
+
_context7.next = 6;
|
|
301
334
|
break;
|
|
302
335
|
}
|
|
303
|
-
return
|
|
336
|
+
return _context7.abrupt("return", this._handleError(response));
|
|
304
337
|
case 6:
|
|
305
338
|
// Clear the iac_session and remove the auth token from axios headers
|
|
306
339
|
this.iac_session = null;
|
|
@@ -312,22 +345,22 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
312
345
|
|
|
313
346
|
// Clear localStorage if it's being used
|
|
314
347
|
if (!this.localStorageAdaptor) {
|
|
315
|
-
|
|
348
|
+
_context7.next = 13;
|
|
316
349
|
break;
|
|
317
350
|
}
|
|
318
|
-
|
|
351
|
+
_context7.next = 13;
|
|
319
352
|
return this.localStorageAdaptor.removeItem('authtoken');
|
|
320
353
|
case 13:
|
|
321
|
-
return
|
|
354
|
+
return _context7.abrupt("return", response.data);
|
|
322
355
|
case 16:
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
this._handleError(
|
|
356
|
+
_context7.prev = 16;
|
|
357
|
+
_context7.t0 = _context7["catch"](0);
|
|
358
|
+
this._handleError(_context7.t0);
|
|
326
359
|
case 19:
|
|
327
360
|
case "end":
|
|
328
|
-
return
|
|
361
|
+
return _context7.stop();
|
|
329
362
|
}
|
|
330
|
-
},
|
|
363
|
+
}, _callee7, this, [[0, 16]]);
|
|
331
364
|
}));
|
|
332
365
|
function logout() {
|
|
333
366
|
return _logout.apply(this, arguments);
|
|
@@ -344,52 +377,58 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
344
377
|
}, {
|
|
345
378
|
key: "loadCurrentUser",
|
|
346
379
|
value: function () {
|
|
347
|
-
var _loadCurrentUser = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
380
|
+
var _loadCurrentUser = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
|
|
348
381
|
var response, _response$user;
|
|
349
|
-
return _regeneratorRuntime().wrap(function
|
|
350
|
-
while (1) switch (
|
|
382
|
+
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
|
|
383
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
351
384
|
case 0:
|
|
352
|
-
|
|
385
|
+
_context8.prev = 0;
|
|
353
386
|
if (!this.currentUser) {
|
|
354
|
-
|
|
387
|
+
_context8.next = 3;
|
|
355
388
|
break;
|
|
356
389
|
}
|
|
357
|
-
return
|
|
390
|
+
return _context8.abrupt("return", this.currentUser);
|
|
358
391
|
case 3:
|
|
392
|
+
if (!this.apikey) {
|
|
393
|
+
_context8.next = 7;
|
|
394
|
+
break;
|
|
395
|
+
}
|
|
396
|
+
return _context8.abrupt("return", null);
|
|
397
|
+
case 7:
|
|
359
398
|
if (!this.authtoken) {
|
|
360
|
-
|
|
399
|
+
_context8.next = 17;
|
|
361
400
|
break;
|
|
362
401
|
}
|
|
363
|
-
|
|
402
|
+
_context8.next = 10;
|
|
364
403
|
return this.refreshAuthToken(this.authtoken);
|
|
365
|
-
case
|
|
366
|
-
response =
|
|
404
|
+
case 10:
|
|
405
|
+
response = _context8.sent;
|
|
367
406
|
if (response) {
|
|
368
|
-
|
|
407
|
+
_context8.next = 13;
|
|
369
408
|
break;
|
|
370
409
|
}
|
|
371
|
-
return
|
|
372
|
-
case
|
|
410
|
+
return _context8.abrupt("return", null);
|
|
411
|
+
case 13:
|
|
373
412
|
if (response !== null && response !== void 0 && response.user) {
|
|
374
413
|
this.currentUser = new _rbt_user["default"]({
|
|
375
414
|
id: response === null || response === void 0 || (_response$user = response.user) === null || _response$user === void 0 ? void 0 : _response$user.id
|
|
376
415
|
}, this.axios);
|
|
377
416
|
this.currentUser.setData(response.user);
|
|
378
417
|
}
|
|
379
|
-
return
|
|
380
|
-
case 13:
|
|
381
|
-
this.currentUser = null;
|
|
382
|
-
case 14:
|
|
383
|
-
return _context7.abrupt("return", null);
|
|
418
|
+
return _context8.abrupt("return", this.currentUser);
|
|
384
419
|
case 17:
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
return
|
|
388
|
-
case
|
|
420
|
+
this.currentUser = null;
|
|
421
|
+
case 18:
|
|
422
|
+
return _context8.abrupt("return", null);
|
|
423
|
+
case 21:
|
|
424
|
+
_context8.prev = 21;
|
|
425
|
+
_context8.t0 = _context8["catch"](0);
|
|
426
|
+
return _context8.abrupt("return", this._handleError(_context8.t0));
|
|
427
|
+
case 24:
|
|
389
428
|
case "end":
|
|
390
|
-
return
|
|
429
|
+
return _context8.stop();
|
|
391
430
|
}
|
|
392
|
-
},
|
|
431
|
+
}, _callee8, this, [[0, 21]]);
|
|
393
432
|
}));
|
|
394
433
|
function loadCurrentUser() {
|
|
395
434
|
return _loadCurrentUser.apply(this, arguments);
|
|
@@ -399,37 +438,37 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
399
438
|
}, {
|
|
400
439
|
key: "confirmUserEmail",
|
|
401
440
|
value: function () {
|
|
402
|
-
var _confirmUserEmail = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
441
|
+
var _confirmUserEmail = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(confirmCode) {
|
|
403
442
|
var params, response;
|
|
404
|
-
return _regeneratorRuntime().wrap(function
|
|
405
|
-
while (1) switch (
|
|
443
|
+
return _regeneratorRuntime().wrap(function _callee9$(_context9) {
|
|
444
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
406
445
|
case 0:
|
|
407
446
|
params = {
|
|
408
447
|
emailConfirmCode: confirmCode
|
|
409
448
|
};
|
|
410
|
-
|
|
411
|
-
|
|
449
|
+
_context9.prev = 1;
|
|
450
|
+
_context9.next = 4;
|
|
412
451
|
return this.axios.post('/user_service/confirmUserEmail', [params]);
|
|
413
452
|
case 4:
|
|
414
|
-
response =
|
|
453
|
+
response = _context9.sent;
|
|
415
454
|
if (!(response.data.ok === false)) {
|
|
416
|
-
|
|
455
|
+
_context9.next = 7;
|
|
417
456
|
break;
|
|
418
457
|
}
|
|
419
|
-
return
|
|
458
|
+
return _context9.abrupt("return", this._handleError(response));
|
|
420
459
|
case 7:
|
|
421
|
-
return
|
|
460
|
+
return _context9.abrupt("return", response.data);
|
|
422
461
|
case 10:
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
return
|
|
462
|
+
_context9.prev = 10;
|
|
463
|
+
_context9.t0 = _context9["catch"](1);
|
|
464
|
+
return _context9.abrupt("return", this._handleError(_context9.t0));
|
|
426
465
|
case 13:
|
|
427
466
|
case "end":
|
|
428
|
-
return
|
|
467
|
+
return _context9.stop();
|
|
429
468
|
}
|
|
430
|
-
},
|
|
469
|
+
}, _callee9, this, [[1, 10]]);
|
|
431
470
|
}));
|
|
432
|
-
function confirmUserEmail(
|
|
471
|
+
function confirmUserEmail(_x6) {
|
|
433
472
|
return _confirmUserEmail.apply(this, arguments);
|
|
434
473
|
}
|
|
435
474
|
return confirmUserEmail;
|
|
@@ -437,27 +476,27 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
437
476
|
}, {
|
|
438
477
|
key: "loadCurrentUserExtended",
|
|
439
478
|
value: function () {
|
|
440
|
-
var _loadCurrentUserExtended = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
479
|
+
var _loadCurrentUserExtended = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
|
|
441
480
|
var currentUser;
|
|
442
|
-
return _regeneratorRuntime().wrap(function
|
|
443
|
-
while (1) switch (
|
|
481
|
+
return _regeneratorRuntime().wrap(function _callee10$(_context10) {
|
|
482
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
444
483
|
case 0:
|
|
445
|
-
|
|
484
|
+
_context10.next = 2;
|
|
446
485
|
return this.loadCurrentUser();
|
|
447
486
|
case 2:
|
|
448
|
-
currentUser =
|
|
487
|
+
currentUser = _context10.sent;
|
|
449
488
|
if (!currentUser) {
|
|
450
|
-
|
|
489
|
+
_context10.next = 7;
|
|
451
490
|
break;
|
|
452
491
|
}
|
|
453
|
-
return
|
|
492
|
+
return _context10.abrupt("return", this.loadUser(currentUser.id));
|
|
454
493
|
case 7:
|
|
455
|
-
return
|
|
494
|
+
return _context10.abrupt("return", null);
|
|
456
495
|
case 8:
|
|
457
496
|
case "end":
|
|
458
|
-
return
|
|
497
|
+
return _context10.stop();
|
|
459
498
|
}
|
|
460
|
-
},
|
|
499
|
+
}, _callee10, this);
|
|
461
500
|
}));
|
|
462
501
|
function loadCurrentUserExtended() {
|
|
463
502
|
return _loadCurrentUserExtended.apply(this, arguments);
|
|
@@ -467,36 +506,36 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
467
506
|
}, {
|
|
468
507
|
key: "loadUser",
|
|
469
508
|
value: function () {
|
|
470
|
-
var _loadUser = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
509
|
+
var _loadUser = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(userId) {
|
|
471
510
|
var params, _response$data, response, userData, User;
|
|
472
|
-
return _regeneratorRuntime().wrap(function
|
|
473
|
-
while (1) switch (
|
|
511
|
+
return _regeneratorRuntime().wrap(function _callee11$(_context11) {
|
|
512
|
+
while (1) switch (_context11.prev = _context11.next) {
|
|
474
513
|
case 0:
|
|
475
514
|
params = {
|
|
476
515
|
id: userId
|
|
477
516
|
};
|
|
478
|
-
|
|
479
|
-
|
|
517
|
+
_context11.prev = 1;
|
|
518
|
+
_context11.next = 4;
|
|
480
519
|
return this.axios.post('/user_service/loadUser', [params]);
|
|
481
520
|
case 4:
|
|
482
|
-
response =
|
|
521
|
+
response = _context11.sent;
|
|
483
522
|
userData = response === null || response === void 0 || (_response$data = response.data) === null || _response$data === void 0 ? void 0 : _response$data.user;
|
|
484
523
|
User = new _rbt_user["default"]({
|
|
485
524
|
id: userData.id
|
|
486
525
|
}, this.axios);
|
|
487
526
|
User.setData(userData);
|
|
488
|
-
return
|
|
527
|
+
return _context11.abrupt("return", User);
|
|
489
528
|
case 11:
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
return
|
|
529
|
+
_context11.prev = 11;
|
|
530
|
+
_context11.t0 = _context11["catch"](1);
|
|
531
|
+
return _context11.abrupt("return", this._handleError(_context11.t0));
|
|
493
532
|
case 14:
|
|
494
533
|
case "end":
|
|
495
|
-
return
|
|
534
|
+
return _context11.stop();
|
|
496
535
|
}
|
|
497
|
-
},
|
|
536
|
+
}, _callee11, this, [[1, 11]]);
|
|
498
537
|
}));
|
|
499
|
-
function loadUser(
|
|
538
|
+
function loadUser(_x7) {
|
|
500
539
|
return _loadUser.apply(this, arguments);
|
|
501
540
|
}
|
|
502
541
|
return loadUser;
|
|
@@ -504,54 +543,54 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
504
543
|
}, {
|
|
505
544
|
key: "refreshAuthToken",
|
|
506
545
|
value: function () {
|
|
507
|
-
var _refreshAuthToken = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
546
|
+
var _refreshAuthToken = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(authtoken) {
|
|
508
547
|
var promise, response;
|
|
509
|
-
return _regeneratorRuntime().wrap(function
|
|
510
|
-
while (1) switch (
|
|
548
|
+
return _regeneratorRuntime().wrap(function _callee12$(_context12) {
|
|
549
|
+
while (1) switch (_context12.prev = _context12.next) {
|
|
511
550
|
case 0:
|
|
512
551
|
if (this.appServiceHost) {
|
|
513
|
-
|
|
552
|
+
_context12.next = 3;
|
|
514
553
|
break;
|
|
515
554
|
}
|
|
516
555
|
console.warn('RBTTOK not initialized');
|
|
517
|
-
return
|
|
556
|
+
return _context12.abrupt("return", false);
|
|
518
557
|
case 3:
|
|
519
558
|
if (!this.requestCache[authtoken]) {
|
|
520
|
-
|
|
559
|
+
_context12.next = 5;
|
|
521
560
|
break;
|
|
522
561
|
}
|
|
523
|
-
return
|
|
562
|
+
return _context12.abrupt("return", this.requestCache[authtoken]);
|
|
524
563
|
case 5:
|
|
525
|
-
|
|
564
|
+
_context12.prev = 5;
|
|
526
565
|
//console.log('RBTTOK Req', authtoken);
|
|
527
566
|
// Create a new promise for the token refresh and store it in the cache
|
|
528
567
|
promise = this.axios.post('/user_service/refreshAuthToken', [authtoken]);
|
|
529
568
|
this.requestCache[authtoken] = promise;
|
|
530
569
|
|
|
531
570
|
// Await the promise to get the response
|
|
532
|
-
|
|
571
|
+
_context12.next = 10;
|
|
533
572
|
return promise;
|
|
534
573
|
case 10:
|
|
535
|
-
response =
|
|
574
|
+
response = _context12.sent;
|
|
536
575
|
//console.log('RBTTOK Response ',response);
|
|
537
576
|
// Once the promise resolves, delete it from the cache to allow future refreshes
|
|
538
577
|
delete this.requestCache[authtoken];
|
|
539
578
|
|
|
540
579
|
// Return the response data
|
|
541
|
-
return
|
|
580
|
+
return _context12.abrupt("return", response.data);
|
|
542
581
|
case 15:
|
|
543
|
-
|
|
544
|
-
|
|
582
|
+
_context12.prev = 15;
|
|
583
|
+
_context12.t0 = _context12["catch"](5);
|
|
545
584
|
// On error, remove the cached promise to allow retries
|
|
546
585
|
delete this.requestCache[authtoken];
|
|
547
|
-
this._handleError(
|
|
586
|
+
this._handleError(_context12.t0);
|
|
548
587
|
case 19:
|
|
549
588
|
case "end":
|
|
550
|
-
return
|
|
589
|
+
return _context12.stop();
|
|
551
590
|
}
|
|
552
|
-
},
|
|
591
|
+
}, _callee12, this, [[5, 15]]);
|
|
553
592
|
}));
|
|
554
|
-
function refreshAuthToken(
|
|
593
|
+
function refreshAuthToken(_x8) {
|
|
555
594
|
return _refreshAuthToken.apply(this, arguments);
|
|
556
595
|
}
|
|
557
596
|
return refreshAuthToken;
|
|
@@ -582,31 +621,31 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
582
621
|
}, {
|
|
583
622
|
key: "registerUser",
|
|
584
623
|
value: function () {
|
|
585
|
-
var _registerUser = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
624
|
+
var _registerUser = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
|
|
586
625
|
var dataHash,
|
|
587
626
|
response,
|
|
588
627
|
record,
|
|
589
|
-
|
|
590
|
-
return _regeneratorRuntime().wrap(function
|
|
591
|
-
while (1) switch (
|
|
628
|
+
_args13 = arguments;
|
|
629
|
+
return _regeneratorRuntime().wrap(function _callee13$(_context13) {
|
|
630
|
+
while (1) switch (_context13.prev = _context13.next) {
|
|
592
631
|
case 0:
|
|
593
|
-
dataHash =
|
|
594
|
-
|
|
595
|
-
|
|
632
|
+
dataHash = _args13.length > 0 && _args13[0] !== undefined ? _args13[0] : {};
|
|
633
|
+
_context13.prev = 1;
|
|
634
|
+
_context13.next = 4;
|
|
596
635
|
return this.axios.post('/user_service/registerUser', [dataHash]);
|
|
597
636
|
case 4:
|
|
598
|
-
response =
|
|
637
|
+
response = _context13.sent;
|
|
599
638
|
record = response.data;
|
|
600
|
-
return
|
|
639
|
+
return _context13.abrupt("return", new _rbt_user["default"](record, this.axios));
|
|
601
640
|
case 9:
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
return
|
|
641
|
+
_context13.prev = 9;
|
|
642
|
+
_context13.t0 = _context13["catch"](1);
|
|
643
|
+
return _context13.abrupt("return", this._handleError(_context13.t0));
|
|
605
644
|
case 12:
|
|
606
645
|
case "end":
|
|
607
|
-
return
|
|
646
|
+
return _context13.stop();
|
|
608
647
|
}
|
|
609
|
-
},
|
|
648
|
+
}, _callee13, this, [[1, 9]]);
|
|
610
649
|
}));
|
|
611
650
|
function registerUser() {
|
|
612
651
|
return _registerUser.apply(this, arguments);
|
|
@@ -623,32 +662,32 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
623
662
|
}, {
|
|
624
663
|
key: "createFile",
|
|
625
664
|
value: (function () {
|
|
626
|
-
var _createFile = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
665
|
+
var _createFile = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14(dataHash) {
|
|
627
666
|
var response, record;
|
|
628
|
-
return _regeneratorRuntime().wrap(function
|
|
629
|
-
while (1) switch (
|
|
667
|
+
return _regeneratorRuntime().wrap(function _callee14$(_context14) {
|
|
668
|
+
while (1) switch (_context14.prev = _context14.next) {
|
|
630
669
|
case 0:
|
|
631
|
-
|
|
632
|
-
|
|
670
|
+
_context14.prev = 0;
|
|
671
|
+
_context14.next = 3;
|
|
633
672
|
return this.axios.post('/object_service/createObject', ['<@filekit.file>', dataHash]);
|
|
634
673
|
case 3:
|
|
635
|
-
response =
|
|
674
|
+
response = _context14.sent;
|
|
636
675
|
record = response.data;
|
|
637
676
|
if (dataHash) {
|
|
638
677
|
record.data = dataHash;
|
|
639
678
|
}
|
|
640
|
-
return
|
|
679
|
+
return _context14.abrupt("return", new _rbt_file["default"](record, this.axios, this.localDb));
|
|
641
680
|
case 9:
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
return
|
|
681
|
+
_context14.prev = 9;
|
|
682
|
+
_context14.t0 = _context14["catch"](0);
|
|
683
|
+
return _context14.abrupt("return", this._handleError(_context14.t0));
|
|
645
684
|
case 12:
|
|
646
685
|
case "end":
|
|
647
|
-
return
|
|
686
|
+
return _context14.stop();
|
|
648
687
|
}
|
|
649
|
-
},
|
|
688
|
+
}, _callee14, this, [[0, 9]]);
|
|
650
689
|
}));
|
|
651
|
-
function createFile(
|
|
690
|
+
function createFile(_x9) {
|
|
652
691
|
return _createFile.apply(this, arguments);
|
|
653
692
|
}
|
|
654
693
|
return createFile;
|
|
@@ -656,35 +695,35 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
656
695
|
}, {
|
|
657
696
|
key: "loadFile",
|
|
658
697
|
value: function () {
|
|
659
|
-
var _loadFile = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
698
|
+
var _loadFile = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(id) {
|
|
660
699
|
var response, record;
|
|
661
|
-
return _regeneratorRuntime().wrap(function
|
|
662
|
-
while (1) switch (
|
|
700
|
+
return _regeneratorRuntime().wrap(function _callee15$(_context15) {
|
|
701
|
+
while (1) switch (_context15.prev = _context15.next) {
|
|
663
702
|
case 0:
|
|
664
|
-
|
|
665
|
-
|
|
703
|
+
_context15.prev = 0;
|
|
704
|
+
_context15.next = 3;
|
|
666
705
|
return this.load('<@filekit.file>', id);
|
|
667
706
|
case 3:
|
|
668
|
-
response =
|
|
707
|
+
response = _context15.sent;
|
|
669
708
|
if (response) {
|
|
670
|
-
|
|
709
|
+
_context15.next = 6;
|
|
671
710
|
break;
|
|
672
711
|
}
|
|
673
|
-
return
|
|
712
|
+
return _context15.abrupt("return", null);
|
|
674
713
|
case 6:
|
|
675
714
|
record = response.toRecord();
|
|
676
|
-
return
|
|
715
|
+
return _context15.abrupt("return", new _rbt_file["default"](record, this.axios, this.localDb));
|
|
677
716
|
case 10:
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
return
|
|
717
|
+
_context15.prev = 10;
|
|
718
|
+
_context15.t0 = _context15["catch"](0);
|
|
719
|
+
return _context15.abrupt("return", this._handleError(_context15.t0));
|
|
681
720
|
case 13:
|
|
682
721
|
case "end":
|
|
683
|
-
return
|
|
722
|
+
return _context15.stop();
|
|
684
723
|
}
|
|
685
|
-
},
|
|
724
|
+
}, _callee15, this, [[0, 10]]);
|
|
686
725
|
}));
|
|
687
|
-
function loadFile(
|
|
726
|
+
function loadFile(_x10) {
|
|
688
727
|
return _loadFile.apply(this, arguments);
|
|
689
728
|
}
|
|
690
729
|
return loadFile;
|
|
@@ -692,39 +731,39 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
692
731
|
}, {
|
|
693
732
|
key: "loadFiles",
|
|
694
733
|
value: function () {
|
|
695
|
-
var _loadFiles = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
734
|
+
var _loadFiles = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(ids) {
|
|
696
735
|
var _this = this;
|
|
697
736
|
var responses;
|
|
698
|
-
return _regeneratorRuntime().wrap(function
|
|
699
|
-
while (1) switch (
|
|
737
|
+
return _regeneratorRuntime().wrap(function _callee16$(_context16) {
|
|
738
|
+
while (1) switch (_context16.prev = _context16.next) {
|
|
700
739
|
case 0:
|
|
701
|
-
|
|
702
|
-
|
|
740
|
+
_context16.prev = 0;
|
|
741
|
+
_context16.next = 3;
|
|
703
742
|
return this.load('<@filekit.file>', ids);
|
|
704
743
|
case 3:
|
|
705
|
-
responses =
|
|
744
|
+
responses = _context16.sent;
|
|
706
745
|
if (!(!responses || !Array.isArray(responses))) {
|
|
707
|
-
|
|
746
|
+
_context16.next = 6;
|
|
708
747
|
break;
|
|
709
748
|
}
|
|
710
|
-
return
|
|
749
|
+
return _context16.abrupt("return", []);
|
|
711
750
|
case 6:
|
|
712
|
-
return
|
|
751
|
+
return _context16.abrupt("return", responses.map(function (response) {
|
|
713
752
|
var record = response.toRecord();
|
|
714
753
|
return new _rbt_file["default"](record, _this.axios, _this.localDb);
|
|
715
754
|
}));
|
|
716
755
|
case 9:
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
this._handleError(
|
|
720
|
-
return
|
|
756
|
+
_context16.prev = 9;
|
|
757
|
+
_context16.t0 = _context16["catch"](0);
|
|
758
|
+
this._handleError(_context16.t0); // Handle errors (log or process as needed)
|
|
759
|
+
return _context16.abrupt("return", []);
|
|
721
760
|
case 13:
|
|
722
761
|
case "end":
|
|
723
|
-
return
|
|
762
|
+
return _context16.stop();
|
|
724
763
|
}
|
|
725
|
-
},
|
|
764
|
+
}, _callee16, this, [[0, 9]]);
|
|
726
765
|
}));
|
|
727
|
-
function loadFiles(
|
|
766
|
+
function loadFiles(_x11) {
|
|
728
767
|
return _loadFiles.apply(this, arguments);
|
|
729
768
|
}
|
|
730
769
|
return loadFiles;
|
|
@@ -739,40 +778,40 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
739
778
|
}, {
|
|
740
779
|
key: "create",
|
|
741
780
|
value: (function () {
|
|
742
|
-
var _create = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
781
|
+
var _create = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17(type) {
|
|
743
782
|
var dataHash,
|
|
744
783
|
response,
|
|
745
784
|
record,
|
|
746
|
-
|
|
747
|
-
return _regeneratorRuntime().wrap(function
|
|
748
|
-
while (1) switch (
|
|
785
|
+
_args17 = arguments;
|
|
786
|
+
return _regeneratorRuntime().wrap(function _callee17$(_context17) {
|
|
787
|
+
while (1) switch (_context17.prev = _context17.next) {
|
|
749
788
|
case 0:
|
|
750
|
-
dataHash =
|
|
751
|
-
|
|
789
|
+
dataHash = _args17.length > 1 && _args17[1] !== undefined ? _args17[1] : {};
|
|
790
|
+
_context17.prev = 1;
|
|
752
791
|
debugger;
|
|
753
|
-
|
|
792
|
+
_context17.next = 5;
|
|
754
793
|
return this.axios.post('/object_service/createObject', [type, dataHash]);
|
|
755
794
|
case 5:
|
|
756
|
-
response =
|
|
795
|
+
response = _context17.sent;
|
|
757
796
|
record = response.data;
|
|
758
797
|
if (dataHash) {
|
|
759
798
|
record.data = dataHash;
|
|
760
799
|
}
|
|
761
800
|
debugger;
|
|
762
|
-
return
|
|
801
|
+
return _context17.abrupt("return", new _rbt_object["default"](record, this.axios, {
|
|
763
802
|
isNew: true
|
|
764
803
|
}));
|
|
765
804
|
case 12:
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
return
|
|
805
|
+
_context17.prev = 12;
|
|
806
|
+
_context17.t0 = _context17["catch"](1);
|
|
807
|
+
return _context17.abrupt("return", this._handleError(_context17.t0));
|
|
769
808
|
case 15:
|
|
770
809
|
case "end":
|
|
771
|
-
return
|
|
810
|
+
return _context17.stop();
|
|
772
811
|
}
|
|
773
|
-
},
|
|
812
|
+
}, _callee17, this, [[1, 12]]);
|
|
774
813
|
}));
|
|
775
|
-
function create(
|
|
814
|
+
function create(_x12) {
|
|
776
815
|
return _create.apply(this, arguments);
|
|
777
816
|
}
|
|
778
817
|
return create;
|
|
@@ -851,7 +890,7 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
851
890
|
}, {
|
|
852
891
|
key: "query",
|
|
853
892
|
value: (function () {
|
|
854
|
-
var _query = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
893
|
+
var _query = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(type) {
|
|
855
894
|
var _this2 = this;
|
|
856
895
|
var params,
|
|
857
896
|
defaultOrderBy,
|
|
@@ -862,12 +901,12 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
862
901
|
cacheEntry,
|
|
863
902
|
responsePromise,
|
|
864
903
|
processingPromise,
|
|
865
|
-
|
|
866
|
-
return _regeneratorRuntime().wrap(function
|
|
867
|
-
while (1) switch (
|
|
904
|
+
_args18 = arguments;
|
|
905
|
+
return _regeneratorRuntime().wrap(function _callee18$(_context18) {
|
|
906
|
+
while (1) switch (_context18.prev = _context18.next) {
|
|
868
907
|
case 0:
|
|
869
|
-
params =
|
|
870
|
-
|
|
908
|
+
params = _args18.length > 1 && _args18[1] !== undefined ? _args18[1] : {};
|
|
909
|
+
_context18.prev = 1;
|
|
871
910
|
//console.log('RBTAPI.query INIT', type, params);
|
|
872
911
|
params.type = type;
|
|
873
912
|
|
|
@@ -889,10 +928,10 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
889
928
|
_paramsKey = JSON.stringify(mergedParams);
|
|
890
929
|
cacheEntry = this.requestCache[_paramsKey];
|
|
891
930
|
if (!(cacheEntry && currentTime - cacheEntry.time < 10000)) {
|
|
892
|
-
|
|
931
|
+
_context18.next = 11;
|
|
893
932
|
break;
|
|
894
933
|
}
|
|
895
|
-
return
|
|
934
|
+
return _context18.abrupt("return", cacheEntry.val);
|
|
896
935
|
case 11:
|
|
897
936
|
// Create the response promise
|
|
898
937
|
responsePromise = this.axios.post('/object_service/queryObjects', [mergedParams]); // Cache the promise of processing data, not just the raw response
|
|
@@ -909,23 +948,23 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
909
948
|
};
|
|
910
949
|
|
|
911
950
|
// Await the processing promise for this call to get processed data
|
|
912
|
-
|
|
951
|
+
_context18.next = 16;
|
|
913
952
|
return processingPromise;
|
|
914
953
|
case 16:
|
|
915
|
-
return
|
|
954
|
+
return _context18.abrupt("return", _context18.sent);
|
|
916
955
|
case 19:
|
|
917
|
-
|
|
918
|
-
|
|
956
|
+
_context18.prev = 19;
|
|
957
|
+
_context18.t0 = _context18["catch"](1);
|
|
919
958
|
delete this.requestCache[paramsKey]; // Ensure cache cleanup on error
|
|
920
959
|
//console.log('RBTAPI.query ERROR', paramsKey, e);
|
|
921
|
-
return
|
|
960
|
+
return _context18.abrupt("return", this._handleError(_context18.t0));
|
|
922
961
|
case 23:
|
|
923
962
|
case "end":
|
|
924
|
-
return
|
|
963
|
+
return _context18.stop();
|
|
925
964
|
}
|
|
926
|
-
},
|
|
965
|
+
}, _callee18, this, [[1, 19]]);
|
|
927
966
|
}));
|
|
928
|
-
function query(
|
|
967
|
+
function query(_x13) {
|
|
929
968
|
return _query.apply(this, arguments);
|
|
930
969
|
}
|
|
931
970
|
return query;
|
|
@@ -959,47 +998,47 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
959
998
|
}, {
|
|
960
999
|
key: "load",
|
|
961
1000
|
value: (function () {
|
|
962
|
-
var _load = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1001
|
+
var _load = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(type, ids) {
|
|
963
1002
|
var params,
|
|
964
1003
|
mergedParams,
|
|
965
1004
|
res,
|
|
966
|
-
|
|
967
|
-
return _regeneratorRuntime().wrap(function
|
|
968
|
-
while (1) switch (
|
|
1005
|
+
_args19 = arguments;
|
|
1006
|
+
return _regeneratorRuntime().wrap(function _callee19$(_context19) {
|
|
1007
|
+
while (1) switch (_context19.prev = _context19.next) {
|
|
969
1008
|
case 0:
|
|
970
|
-
params =
|
|
971
|
-
|
|
1009
|
+
params = _args19.length > 2 && _args19[2] !== undefined ? _args19[2] : {};
|
|
1010
|
+
_context19.prev = 1;
|
|
972
1011
|
if (!Array.isArray(ids)) {
|
|
973
|
-
|
|
1012
|
+
_context19.next = 7;
|
|
974
1013
|
break;
|
|
975
1014
|
}
|
|
976
1015
|
mergedParams = _objectSpread(_objectSpread({}, params), {}, {
|
|
977
1016
|
where: "id IN (\"".concat(ids.join("\",\""), "\")")
|
|
978
1017
|
});
|
|
979
|
-
return
|
|
1018
|
+
return _context19.abrupt("return", this.query(type, mergedParams));
|
|
980
1019
|
case 7:
|
|
981
1020
|
mergedParams = _objectSpread(_objectSpread({}, params), {}, {
|
|
982
1021
|
where: "id=\"".concat(ids, "\"")
|
|
983
1022
|
});
|
|
984
|
-
|
|
1023
|
+
_context19.next = 10;
|
|
985
1024
|
return this.query(type, mergedParams);
|
|
986
1025
|
case 10:
|
|
987
|
-
res =
|
|
988
|
-
return
|
|
1026
|
+
res = _context19.sent;
|
|
1027
|
+
return _context19.abrupt("return", res[0]);
|
|
989
1028
|
case 12:
|
|
990
|
-
|
|
1029
|
+
_context19.next = 17;
|
|
991
1030
|
break;
|
|
992
1031
|
case 14:
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
return
|
|
1032
|
+
_context19.prev = 14;
|
|
1033
|
+
_context19.t0 = _context19["catch"](1);
|
|
1034
|
+
return _context19.abrupt("return", this._handleError(_context19.t0));
|
|
996
1035
|
case 17:
|
|
997
1036
|
case "end":
|
|
998
|
-
return
|
|
1037
|
+
return _context19.stop();
|
|
999
1038
|
}
|
|
1000
|
-
},
|
|
1039
|
+
}, _callee19, this, [[1, 14]]);
|
|
1001
1040
|
}));
|
|
1002
|
-
function load(
|
|
1041
|
+
function load(_x14, _x15) {
|
|
1003
1042
|
return _load.apply(this, arguments);
|
|
1004
1043
|
}
|
|
1005
1044
|
return load;
|
|
@@ -1026,7 +1065,7 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
1026
1065
|
}, {
|
|
1027
1066
|
key: "runTask",
|
|
1028
1067
|
value: (function () {
|
|
1029
|
-
var _runTask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1068
|
+
var _runTask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20() {
|
|
1030
1069
|
var params,
|
|
1031
1070
|
callbacks,
|
|
1032
1071
|
onProgress,
|
|
@@ -1040,20 +1079,20 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
1040
1079
|
status,
|
|
1041
1080
|
message,
|
|
1042
1081
|
output,
|
|
1043
|
-
|
|
1044
|
-
return _regeneratorRuntime().wrap(function
|
|
1045
|
-
while (1) switch (
|
|
1082
|
+
_args20 = arguments;
|
|
1083
|
+
return _regeneratorRuntime().wrap(function _callee20$(_context20) {
|
|
1084
|
+
while (1) switch (_context20.prev = _context20.next) {
|
|
1046
1085
|
case 0:
|
|
1047
|
-
params =
|
|
1048
|
-
callbacks =
|
|
1086
|
+
params = _args20.length > 0 && _args20[0] !== undefined ? _args20[0] : {};
|
|
1087
|
+
callbacks = _args20.length > 1 && _args20[1] !== undefined ? _args20[1] : {};
|
|
1049
1088
|
onProgress = callbacks.onProgress, onError = callbacks.onError, onStopped = callbacks.onStopped, onWaiting = callbacks.onWaiting, onDone = callbacks.onDone;
|
|
1050
|
-
|
|
1051
|
-
|
|
1089
|
+
_context20.prev = 3;
|
|
1090
|
+
_context20.next = 6;
|
|
1052
1091
|
return this.post('/task_service/runChain', params);
|
|
1053
1092
|
case 6:
|
|
1054
|
-
response =
|
|
1093
|
+
response = _context20.sent;
|
|
1055
1094
|
if (response) {
|
|
1056
|
-
|
|
1095
|
+
_context20.next = 9;
|
|
1057
1096
|
break;
|
|
1058
1097
|
}
|
|
1059
1098
|
throw new Error('Invalid server response');
|
|
@@ -1061,7 +1100,7 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
1061
1100
|
// Validate response structure
|
|
1062
1101
|
ok = response.ok, jobId = response.jobId, status = response.status, message = response.message, output = response.output;
|
|
1063
1102
|
if (!(!ok || typeof jobId !== 'string' || typeof status !== 'string')) {
|
|
1064
|
-
|
|
1103
|
+
_context20.next = 12;
|
|
1065
1104
|
break;
|
|
1066
1105
|
}
|
|
1067
1106
|
throw new Error('Invalid response structure');
|
|
@@ -1087,7 +1126,7 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
1087
1126
|
//console.log('Finish (request) ',response);
|
|
1088
1127
|
onDone(response);
|
|
1089
1128
|
}
|
|
1090
|
-
return
|
|
1129
|
+
return _context20.abrupt("return", {
|
|
1091
1130
|
ok: ok,
|
|
1092
1131
|
jobId: jobId,
|
|
1093
1132
|
status: status,
|
|
@@ -1095,24 +1134,24 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
1095
1134
|
output: output
|
|
1096
1135
|
});
|
|
1097
1136
|
case 20:
|
|
1098
|
-
|
|
1099
|
-
|
|
1137
|
+
_context20.prev = 20;
|
|
1138
|
+
_context20.t0 = _context20["catch"](3);
|
|
1100
1139
|
if (typeof onError === 'function') {
|
|
1101
|
-
onError(
|
|
1140
|
+
onError(_context20.t0);
|
|
1102
1141
|
} else {
|
|
1103
|
-
console.error('Error in runTask:',
|
|
1142
|
+
console.error('Error in runTask:', _context20.t0);
|
|
1104
1143
|
}
|
|
1105
|
-
return
|
|
1144
|
+
return _context20.abrupt("return", {
|
|
1106
1145
|
ok: false,
|
|
1107
1146
|
jobId: null,
|
|
1108
1147
|
status: 'ERROR',
|
|
1109
|
-
error:
|
|
1148
|
+
error: _context20.t0.message
|
|
1110
1149
|
});
|
|
1111
1150
|
case 24:
|
|
1112
1151
|
case "end":
|
|
1113
|
-
return
|
|
1152
|
+
return _context20.stop();
|
|
1114
1153
|
}
|
|
1115
|
-
},
|
|
1154
|
+
}, _callee20, this, [[3, 20]]);
|
|
1116
1155
|
}));
|
|
1117
1156
|
function runTask() {
|
|
1118
1157
|
return _runTask.apply(this, arguments);
|
|
@@ -1122,37 +1161,37 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
1122
1161
|
}, {
|
|
1123
1162
|
key: "stopJob",
|
|
1124
1163
|
value: function () {
|
|
1125
|
-
var _stopJob = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1164
|
+
var _stopJob = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21() {
|
|
1126
1165
|
var params,
|
|
1127
1166
|
callbacks,
|
|
1128
1167
|
response,
|
|
1129
|
-
|
|
1130
|
-
return _regeneratorRuntime().wrap(function
|
|
1131
|
-
while (1) switch (
|
|
1168
|
+
_args21 = arguments;
|
|
1169
|
+
return _regeneratorRuntime().wrap(function _callee21$(_context21) {
|
|
1170
|
+
while (1) switch (_context21.prev = _context21.next) {
|
|
1132
1171
|
case 0:
|
|
1133
|
-
params =
|
|
1134
|
-
callbacks =
|
|
1135
|
-
|
|
1136
|
-
|
|
1172
|
+
params = _args21.length > 0 && _args21[0] !== undefined ? _args21[0] : {};
|
|
1173
|
+
callbacks = _args21.length > 1 && _args21[1] !== undefined ? _args21[1] : {};
|
|
1174
|
+
_context21.prev = 2;
|
|
1175
|
+
_context21.next = 5;
|
|
1137
1176
|
return this.post('/task_service/stopJob', params);
|
|
1138
1177
|
case 5:
|
|
1139
|
-
response =
|
|
1178
|
+
response = _context21.sent;
|
|
1140
1179
|
if (response) {
|
|
1141
|
-
|
|
1180
|
+
_context21.next = 8;
|
|
1142
1181
|
break;
|
|
1143
1182
|
}
|
|
1144
1183
|
throw new Error('Invalid server response');
|
|
1145
1184
|
case 8:
|
|
1146
|
-
return
|
|
1185
|
+
return _context21.abrupt("return", true);
|
|
1147
1186
|
case 11:
|
|
1148
|
-
|
|
1149
|
-
|
|
1187
|
+
_context21.prev = 11;
|
|
1188
|
+
_context21.t0 = _context21["catch"](2);
|
|
1150
1189
|
throw 'Error in stopJob';
|
|
1151
1190
|
case 14:
|
|
1152
1191
|
case "end":
|
|
1153
|
-
return
|
|
1192
|
+
return _context21.stop();
|
|
1154
1193
|
}
|
|
1155
|
-
},
|
|
1194
|
+
}, _callee21, this, [[2, 11]]);
|
|
1156
1195
|
}));
|
|
1157
1196
|
function stopJob() {
|
|
1158
1197
|
return _stopJob.apply(this, arguments);
|
|
@@ -1172,26 +1211,26 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
1172
1211
|
}, {
|
|
1173
1212
|
key: "pollTaskProgress",
|
|
1174
1213
|
value: (function () {
|
|
1175
|
-
var _pollTaskProgress = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1214
|
+
var _pollTaskProgress = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(jobId, callbacks) {
|
|
1176
1215
|
var _this4 = this;
|
|
1177
1216
|
var onProgress, onError, onStopped, onWaiting, onDone, _callbacks$pollingInt, pollingInterval, checkProgress;
|
|
1178
|
-
return _regeneratorRuntime().wrap(function
|
|
1179
|
-
while (1) switch (
|
|
1217
|
+
return _regeneratorRuntime().wrap(function _callee23$(_context23) {
|
|
1218
|
+
while (1) switch (_context23.prev = _context23.next) {
|
|
1180
1219
|
case 0:
|
|
1181
1220
|
onProgress = callbacks.onProgress, onError = callbacks.onError, onStopped = callbacks.onStopped, onWaiting = callbacks.onWaiting, onDone = callbacks.onDone, _callbacks$pollingInt = callbacks.pollingInterval, pollingInterval = _callbacks$pollingInt === void 0 ? 2000 : _callbacks$pollingInt;
|
|
1182
|
-
|
|
1221
|
+
_context23.prev = 1;
|
|
1183
1222
|
checkProgress = /*#__PURE__*/function () {
|
|
1184
|
-
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1223
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22() {
|
|
1185
1224
|
var response;
|
|
1186
|
-
return _regeneratorRuntime().wrap(function
|
|
1187
|
-
while (1) switch (
|
|
1225
|
+
return _regeneratorRuntime().wrap(function _callee22$(_context22) {
|
|
1226
|
+
while (1) switch (_context22.prev = _context22.next) {
|
|
1188
1227
|
case 0:
|
|
1189
|
-
|
|
1228
|
+
_context22.next = 2;
|
|
1190
1229
|
return _this4.get("/task_service/pollChainProgress", {
|
|
1191
1230
|
jobId: jobId
|
|
1192
1231
|
});
|
|
1193
1232
|
case 2:
|
|
1194
|
-
response =
|
|
1233
|
+
response = _context22.sent;
|
|
1195
1234
|
// If the task is still in progress, start polling for updates
|
|
1196
1235
|
if (response.status === 'DONE' && onDone) {
|
|
1197
1236
|
// Provide the current progress to the callback function
|
|
@@ -1222,28 +1261,28 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
1222
1261
|
}
|
|
1223
1262
|
case 9:
|
|
1224
1263
|
case "end":
|
|
1225
|
-
return
|
|
1264
|
+
return _context22.stop();
|
|
1226
1265
|
}
|
|
1227
|
-
},
|
|
1266
|
+
}, _callee22);
|
|
1228
1267
|
}));
|
|
1229
1268
|
return function checkProgress() {
|
|
1230
1269
|
return _ref2.apply(this, arguments);
|
|
1231
1270
|
};
|
|
1232
1271
|
}();
|
|
1233
1272
|
checkProgress();
|
|
1234
|
-
|
|
1273
|
+
_context23.next = 9;
|
|
1235
1274
|
break;
|
|
1236
1275
|
case 6:
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
return
|
|
1276
|
+
_context23.prev = 6;
|
|
1277
|
+
_context23.t0 = _context23["catch"](1);
|
|
1278
|
+
return _context23.abrupt("return", this._handleError(_context23.t0));
|
|
1240
1279
|
case 9:
|
|
1241
1280
|
case "end":
|
|
1242
|
-
return
|
|
1281
|
+
return _context23.stop();
|
|
1243
1282
|
}
|
|
1244
|
-
},
|
|
1283
|
+
}, _callee23, this, [[1, 6]]);
|
|
1245
1284
|
}));
|
|
1246
|
-
function pollTaskProgress(
|
|
1285
|
+
function pollTaskProgress(_x16, _x17) {
|
|
1247
1286
|
return _pollTaskProgress.apply(this, arguments);
|
|
1248
1287
|
}
|
|
1249
1288
|
return pollTaskProgress;
|
|
@@ -1263,45 +1302,45 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
1263
1302
|
}, {
|
|
1264
1303
|
key: "get",
|
|
1265
1304
|
value: (function () {
|
|
1266
|
-
var _get = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1305
|
+
var _get = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(endpoint) {
|
|
1267
1306
|
var params,
|
|
1268
1307
|
headers,
|
|
1269
1308
|
response,
|
|
1270
|
-
|
|
1271
|
-
return _regeneratorRuntime().wrap(function
|
|
1272
|
-
while (1) switch (
|
|
1309
|
+
_args24 = arguments;
|
|
1310
|
+
return _regeneratorRuntime().wrap(function _callee24$(_context24) {
|
|
1311
|
+
while (1) switch (_context24.prev = _context24.next) {
|
|
1273
1312
|
case 0:
|
|
1274
|
-
params =
|
|
1275
|
-
|
|
1313
|
+
params = _args24.length > 1 && _args24[1] !== undefined ? _args24[1] : {};
|
|
1314
|
+
_context24.prev = 1;
|
|
1276
1315
|
// Add the authToken to the headers
|
|
1277
1316
|
headers = {
|
|
1278
1317
|
authtoken: this.authtoken
|
|
1279
1318
|
}; // Make the GET request using Axios
|
|
1280
|
-
|
|
1319
|
+
_context24.next = 5;
|
|
1281
1320
|
return this.axios.get(endpoint, {
|
|
1282
1321
|
params: params,
|
|
1283
1322
|
headers: headers
|
|
1284
1323
|
});
|
|
1285
1324
|
case 5:
|
|
1286
|
-
response =
|
|
1325
|
+
response = _context24.sent;
|
|
1287
1326
|
if (!(response.data.ok === false)) {
|
|
1288
|
-
|
|
1327
|
+
_context24.next = 8;
|
|
1289
1328
|
break;
|
|
1290
1329
|
}
|
|
1291
|
-
return
|
|
1330
|
+
return _context24.abrupt("return", this._handleError(response));
|
|
1292
1331
|
case 8:
|
|
1293
|
-
return
|
|
1332
|
+
return _context24.abrupt("return", response.data);
|
|
1294
1333
|
case 11:
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
return
|
|
1334
|
+
_context24.prev = 11;
|
|
1335
|
+
_context24.t0 = _context24["catch"](1);
|
|
1336
|
+
return _context24.abrupt("return", this._handleError(_context24.t0));
|
|
1298
1337
|
case 14:
|
|
1299
1338
|
case "end":
|
|
1300
|
-
return
|
|
1339
|
+
return _context24.stop();
|
|
1301
1340
|
}
|
|
1302
|
-
},
|
|
1341
|
+
}, _callee24, this, [[1, 11]]);
|
|
1303
1342
|
}));
|
|
1304
|
-
function get(
|
|
1343
|
+
function get(_x18) {
|
|
1305
1344
|
return _get.apply(this, arguments);
|
|
1306
1345
|
}
|
|
1307
1346
|
return get;
|
|
@@ -1322,44 +1361,44 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
1322
1361
|
}, {
|
|
1323
1362
|
key: "post",
|
|
1324
1363
|
value: (function () {
|
|
1325
|
-
var _post = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1364
|
+
var _post = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25(endpoint) {
|
|
1326
1365
|
var data,
|
|
1327
1366
|
headers,
|
|
1328
1367
|
response,
|
|
1329
|
-
|
|
1330
|
-
return _regeneratorRuntime().wrap(function
|
|
1331
|
-
while (1) switch (
|
|
1368
|
+
_args25 = arguments;
|
|
1369
|
+
return _regeneratorRuntime().wrap(function _callee25$(_context25) {
|
|
1370
|
+
while (1) switch (_context25.prev = _context25.next) {
|
|
1332
1371
|
case 0:
|
|
1333
|
-
data =
|
|
1334
|
-
|
|
1372
|
+
data = _args25.length > 1 && _args25[1] !== undefined ? _args25[1] : {};
|
|
1373
|
+
_context25.prev = 1;
|
|
1335
1374
|
// Add the authToken to the headers
|
|
1336
1375
|
headers = {
|
|
1337
1376
|
authtoken: this.authtoken
|
|
1338
1377
|
}; // Make the POST request using Axios
|
|
1339
|
-
|
|
1378
|
+
_context25.next = 5;
|
|
1340
1379
|
return this.axios.post(endpoint, data, {
|
|
1341
1380
|
headers: headers
|
|
1342
1381
|
});
|
|
1343
1382
|
case 5:
|
|
1344
|
-
response =
|
|
1383
|
+
response = _context25.sent;
|
|
1345
1384
|
if (!(response.data.ok === false)) {
|
|
1346
|
-
|
|
1385
|
+
_context25.next = 8;
|
|
1347
1386
|
break;
|
|
1348
1387
|
}
|
|
1349
|
-
return
|
|
1388
|
+
return _context25.abrupt("return", this._handleError(response));
|
|
1350
1389
|
case 8:
|
|
1351
|
-
return
|
|
1390
|
+
return _context25.abrupt("return", response.data);
|
|
1352
1391
|
case 11:
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
return
|
|
1392
|
+
_context25.prev = 11;
|
|
1393
|
+
_context25.t0 = _context25["catch"](1);
|
|
1394
|
+
return _context25.abrupt("return", this._handleError(_context25.t0));
|
|
1356
1395
|
case 14:
|
|
1357
1396
|
case "end":
|
|
1358
|
-
return
|
|
1397
|
+
return _context25.stop();
|
|
1359
1398
|
}
|
|
1360
|
-
},
|
|
1399
|
+
}, _callee25, this, [[1, 11]]);
|
|
1361
1400
|
}));
|
|
1362
|
-
function post(
|
|
1401
|
+
function post(_x19) {
|
|
1363
1402
|
return _post.apply(this, arguments);
|
|
1364
1403
|
}
|
|
1365
1404
|
return post;
|