roboto-js 1.9.7 → 1.9.9
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 +106 -84
- package/dist/cjs/rbt_api.cjs +372 -257
- package/dist/cjs/version.cjs +2 -2
- package/dist/esm/index.js +106 -84
- package/dist/esm/rbt_api.js +372 -257
- package/dist/esm/version.js +2 -2
- package/package.json +1 -1
- package/src/index.js +3 -0
- package/src/rbt_api.js +81 -0
- package/src/version.js +2 -2
package/dist/cjs/rbt_api.cjs
CHANGED
|
@@ -1040,14 +1040,129 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
1040
1040
|
value: function getCurrentOrganization() {
|
|
1041
1041
|
return this.currentOrganization;
|
|
1042
1042
|
}
|
|
1043
|
+
|
|
1044
|
+
/**
|
|
1045
|
+
* Select and link an organization to the current user
|
|
1046
|
+
* This adds the organization to the user's organizations array (if not already there)
|
|
1047
|
+
* and sets it as the current organization preference
|
|
1048
|
+
*
|
|
1049
|
+
* @param {string} orgId - Organization ID to select
|
|
1050
|
+
* @param {string} role - Role for the user in this organization (default: 'owner')
|
|
1051
|
+
* @returns {Promise<RbtObject>} The selected organization
|
|
1052
|
+
*/
|
|
1053
|
+
}, {
|
|
1054
|
+
key: "selectCurrentOrganization",
|
|
1055
|
+
value: (function () {
|
|
1056
|
+
var _selectCurrentOrganization = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17(orgId) {
|
|
1057
|
+
var role,
|
|
1058
|
+
org,
|
|
1059
|
+
user,
|
|
1060
|
+
userOrgs,
|
|
1061
|
+
orgExists,
|
|
1062
|
+
modData,
|
|
1063
|
+
_args17 = arguments;
|
|
1064
|
+
return _regeneratorRuntime().wrap(function _callee17$(_context17) {
|
|
1065
|
+
while (1) switch (_context17.prev = _context17.next) {
|
|
1066
|
+
case 0:
|
|
1067
|
+
role = _args17.length > 1 && _args17[1] !== undefined ? _args17[1] : 'owner';
|
|
1068
|
+
_context17.prev = 1;
|
|
1069
|
+
if (this.currentUser) {
|
|
1070
|
+
_context17.next = 7;
|
|
1071
|
+
break;
|
|
1072
|
+
}
|
|
1073
|
+
_context17.next = 5;
|
|
1074
|
+
return this.loadCurrentUser();
|
|
1075
|
+
case 5:
|
|
1076
|
+
if (this.currentUser) {
|
|
1077
|
+
_context17.next = 7;
|
|
1078
|
+
break;
|
|
1079
|
+
}
|
|
1080
|
+
throw new Error('Must be logged in to select organization');
|
|
1081
|
+
case 7:
|
|
1082
|
+
_context17.next = 9;
|
|
1083
|
+
return this.get('<@iac.organization>', orgId);
|
|
1084
|
+
case 9:
|
|
1085
|
+
org = _context17.sent;
|
|
1086
|
+
if (org) {
|
|
1087
|
+
_context17.next = 12;
|
|
1088
|
+
break;
|
|
1089
|
+
}
|
|
1090
|
+
throw new Error("Organization ".concat(orgId, " not found or not accessible"));
|
|
1091
|
+
case 12:
|
|
1092
|
+
_context17.next = 14;
|
|
1093
|
+
return this.loadUser(this.currentUser.id);
|
|
1094
|
+
case 14:
|
|
1095
|
+
user = _context17.sent;
|
|
1096
|
+
if (user) {
|
|
1097
|
+
_context17.next = 17;
|
|
1098
|
+
break;
|
|
1099
|
+
}
|
|
1100
|
+
throw new Error('Failed to load user object');
|
|
1101
|
+
case 17:
|
|
1102
|
+
// Update user's organizations array
|
|
1103
|
+
userOrgs = user.get('organizations') || [];
|
|
1104
|
+
orgExists = userOrgs.some(function (o) {
|
|
1105
|
+
return (o === null || o === void 0 ? void 0 : o.id) === orgId;
|
|
1106
|
+
});
|
|
1107
|
+
if (!orgExists) {
|
|
1108
|
+
userOrgs.unshift({
|
|
1109
|
+
id: orgId,
|
|
1110
|
+
roles: [role]
|
|
1111
|
+
});
|
|
1112
|
+
user.set('organizations', userOrgs);
|
|
1113
|
+
} else {}
|
|
1114
|
+
|
|
1115
|
+
// Set as current organization preference - handle both nested path formats
|
|
1116
|
+
modData = user.get('mod') || {};
|
|
1117
|
+
modData.currentOrgId = orgId;
|
|
1118
|
+
user.set('mod', modData);
|
|
1119
|
+
|
|
1120
|
+
// Save user record
|
|
1121
|
+
_context17.next = 25;
|
|
1122
|
+
return user.save();
|
|
1123
|
+
case 25:
|
|
1124
|
+
// Clear cached organization to force reload
|
|
1125
|
+
this.currentOrganization = null;
|
|
1126
|
+
|
|
1127
|
+
// Update the current user reference
|
|
1128
|
+
this.currentUser = user;
|
|
1129
|
+
|
|
1130
|
+
// Set the new current organization
|
|
1131
|
+
this.currentOrganization = org;
|
|
1132
|
+
|
|
1133
|
+
// Update cache
|
|
1134
|
+
if (!this.localStorageAdaptor) {
|
|
1135
|
+
_context17.next = 31;
|
|
1136
|
+
break;
|
|
1137
|
+
}
|
|
1138
|
+
_context17.next = 31;
|
|
1139
|
+
return this.localStorageAdaptor.setItem('currentOrgId', orgId);
|
|
1140
|
+
case 31:
|
|
1141
|
+
return _context17.abrupt("return", org);
|
|
1142
|
+
case 34:
|
|
1143
|
+
_context17.prev = 34;
|
|
1144
|
+
_context17.t0 = _context17["catch"](1);
|
|
1145
|
+
console.error('[RbtApi] Error in selectCurrentOrganization:', _context17.t0);
|
|
1146
|
+
return _context17.abrupt("return", this._handleError(_context17.t0));
|
|
1147
|
+
case 38:
|
|
1148
|
+
case "end":
|
|
1149
|
+
return _context17.stop();
|
|
1150
|
+
}
|
|
1151
|
+
}, _callee17, this, [[1, 34]]);
|
|
1152
|
+
}));
|
|
1153
|
+
function selectCurrentOrganization(_x8) {
|
|
1154
|
+
return _selectCurrentOrganization.apply(this, arguments);
|
|
1155
|
+
}
|
|
1156
|
+
return selectCurrentOrganization;
|
|
1157
|
+
}())
|
|
1043
1158
|
}, {
|
|
1044
1159
|
key: "loadUser",
|
|
1045
1160
|
value: function () {
|
|
1046
|
-
var _loadUser = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1161
|
+
var _loadUser = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(userId) {
|
|
1047
1162
|
var _this5 = this;
|
|
1048
1163
|
var params, cacheKey, now, existing, p;
|
|
1049
|
-
return _regeneratorRuntime().wrap(function
|
|
1050
|
-
while (1) switch (
|
|
1164
|
+
return _regeneratorRuntime().wrap(function _callee19$(_context19) {
|
|
1165
|
+
while (1) switch (_context19.prev = _context19.next) {
|
|
1051
1166
|
case 0:
|
|
1052
1167
|
params = {
|
|
1053
1168
|
id: userId
|
|
@@ -1056,53 +1171,53 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
1056
1171
|
now = Date.now();
|
|
1057
1172
|
existing = this.requestCache[cacheKey];
|
|
1058
1173
|
if (!(existing && now - existing.time < 10000)) {
|
|
1059
|
-
|
|
1174
|
+
_context19.next = 6;
|
|
1060
1175
|
break;
|
|
1061
1176
|
}
|
|
1062
|
-
return
|
|
1177
|
+
return _context19.abrupt("return", existing.val);
|
|
1063
1178
|
case 6:
|
|
1064
|
-
|
|
1065
|
-
p = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1179
|
+
_context19.prev = 6;
|
|
1180
|
+
p = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {
|
|
1066
1181
|
var _response$data;
|
|
1067
1182
|
var response, userData, User;
|
|
1068
|
-
return _regeneratorRuntime().wrap(function
|
|
1069
|
-
while (1) switch (
|
|
1183
|
+
return _regeneratorRuntime().wrap(function _callee18$(_context18) {
|
|
1184
|
+
while (1) switch (_context18.prev = _context18.next) {
|
|
1070
1185
|
case 0:
|
|
1071
|
-
|
|
1186
|
+
_context18.next = 2;
|
|
1072
1187
|
return _this5.axios.post('/user_service/loadUser', [params]);
|
|
1073
1188
|
case 2:
|
|
1074
|
-
response =
|
|
1189
|
+
response = _context18.sent;
|
|
1075
1190
|
userData = response === null || response === void 0 || (_response$data = response.data) === null || _response$data === void 0 ? void 0 : _response$data.user;
|
|
1076
1191
|
User = new _rbt_user["default"]({
|
|
1077
1192
|
id: userData.id
|
|
1078
1193
|
}, _this5.axios);
|
|
1079
1194
|
User.setData(userData);
|
|
1080
|
-
return
|
|
1195
|
+
return _context18.abrupt("return", User);
|
|
1081
1196
|
case 7:
|
|
1082
1197
|
case "end":
|
|
1083
|
-
return
|
|
1198
|
+
return _context18.stop();
|
|
1084
1199
|
}
|
|
1085
|
-
},
|
|
1200
|
+
}, _callee18);
|
|
1086
1201
|
}))();
|
|
1087
1202
|
this.requestCache[cacheKey] = {
|
|
1088
1203
|
val: p,
|
|
1089
1204
|
time: now
|
|
1090
1205
|
};
|
|
1091
|
-
|
|
1206
|
+
_context19.next = 11;
|
|
1092
1207
|
return p;
|
|
1093
1208
|
case 11:
|
|
1094
|
-
return
|
|
1209
|
+
return _context19.abrupt("return", _context19.sent);
|
|
1095
1210
|
case 14:
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
return
|
|
1211
|
+
_context19.prev = 14;
|
|
1212
|
+
_context19.t0 = _context19["catch"](6);
|
|
1213
|
+
return _context19.abrupt("return", this._handleError(_context19.t0));
|
|
1099
1214
|
case 17:
|
|
1100
1215
|
case "end":
|
|
1101
|
-
return
|
|
1216
|
+
return _context19.stop();
|
|
1102
1217
|
}
|
|
1103
|
-
},
|
|
1218
|
+
}, _callee19, this, [[6, 14]]);
|
|
1104
1219
|
}));
|
|
1105
|
-
function loadUser(
|
|
1220
|
+
function loadUser(_x9) {
|
|
1106
1221
|
return _loadUser.apply(this, arguments);
|
|
1107
1222
|
}
|
|
1108
1223
|
return loadUser;
|
|
@@ -1110,53 +1225,53 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
1110
1225
|
}, {
|
|
1111
1226
|
key: "refreshAuthToken",
|
|
1112
1227
|
value: function () {
|
|
1113
|
-
var _refreshAuthToken = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1228
|
+
var _refreshAuthToken = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(authtoken) {
|
|
1114
1229
|
var promise, response;
|
|
1115
|
-
return _regeneratorRuntime().wrap(function
|
|
1116
|
-
while (1) switch (
|
|
1230
|
+
return _regeneratorRuntime().wrap(function _callee20$(_context20) {
|
|
1231
|
+
while (1) switch (_context20.prev = _context20.next) {
|
|
1117
1232
|
case 0:
|
|
1118
1233
|
if (this.appServiceHost) {
|
|
1119
|
-
|
|
1234
|
+
_context20.next = 2;
|
|
1120
1235
|
break;
|
|
1121
1236
|
}
|
|
1122
|
-
return
|
|
1237
|
+
return _context20.abrupt("return", false);
|
|
1123
1238
|
case 2:
|
|
1124
1239
|
if (!this.requestCache[authtoken]) {
|
|
1125
|
-
|
|
1240
|
+
_context20.next = 4;
|
|
1126
1241
|
break;
|
|
1127
1242
|
}
|
|
1128
|
-
return
|
|
1243
|
+
return _context20.abrupt("return", this.requestCache[authtoken]);
|
|
1129
1244
|
case 4:
|
|
1130
|
-
|
|
1245
|
+
_context20.prev = 4;
|
|
1131
1246
|
//console.log('RBTTOK Req', authtoken);
|
|
1132
1247
|
// Create a new promise for the token refresh and store it in the cache
|
|
1133
1248
|
promise = this.axios.post('/user_service/refreshAuthToken', [authtoken]);
|
|
1134
1249
|
this.requestCache[authtoken] = promise;
|
|
1135
1250
|
|
|
1136
1251
|
// Await the promise to get the response
|
|
1137
|
-
|
|
1252
|
+
_context20.next = 9;
|
|
1138
1253
|
return promise;
|
|
1139
1254
|
case 9:
|
|
1140
|
-
response =
|
|
1255
|
+
response = _context20.sent;
|
|
1141
1256
|
//console.log('RBTTOK Response ',response);
|
|
1142
1257
|
// Once the promise resolves, delete it from the cache to allow future refreshes
|
|
1143
1258
|
delete this.requestCache[authtoken];
|
|
1144
1259
|
|
|
1145
1260
|
// Return the response data
|
|
1146
|
-
return
|
|
1261
|
+
return _context20.abrupt("return", response.data);
|
|
1147
1262
|
case 14:
|
|
1148
|
-
|
|
1149
|
-
|
|
1263
|
+
_context20.prev = 14;
|
|
1264
|
+
_context20.t0 = _context20["catch"](4);
|
|
1150
1265
|
// On error, remove the cached promise to allow retries
|
|
1151
1266
|
delete this.requestCache[authtoken];
|
|
1152
|
-
this._handleError(
|
|
1267
|
+
this._handleError(_context20.t0);
|
|
1153
1268
|
case 18:
|
|
1154
1269
|
case "end":
|
|
1155
|
-
return
|
|
1270
|
+
return _context20.stop();
|
|
1156
1271
|
}
|
|
1157
|
-
},
|
|
1272
|
+
}, _callee20, this, [[4, 14]]);
|
|
1158
1273
|
}));
|
|
1159
|
-
function refreshAuthToken(
|
|
1274
|
+
function refreshAuthToken(_x10) {
|
|
1160
1275
|
return _refreshAuthToken.apply(this, arguments);
|
|
1161
1276
|
}
|
|
1162
1277
|
return refreshAuthToken;
|
|
@@ -1187,31 +1302,31 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
1187
1302
|
}, {
|
|
1188
1303
|
key: "registerUser",
|
|
1189
1304
|
value: function () {
|
|
1190
|
-
var _registerUser = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1305
|
+
var _registerUser = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21() {
|
|
1191
1306
|
var dataHash,
|
|
1192
1307
|
response,
|
|
1193
1308
|
record,
|
|
1194
|
-
|
|
1195
|
-
return _regeneratorRuntime().wrap(function
|
|
1196
|
-
while (1) switch (
|
|
1309
|
+
_args21 = arguments;
|
|
1310
|
+
return _regeneratorRuntime().wrap(function _callee21$(_context21) {
|
|
1311
|
+
while (1) switch (_context21.prev = _context21.next) {
|
|
1197
1312
|
case 0:
|
|
1198
|
-
dataHash =
|
|
1199
|
-
|
|
1200
|
-
|
|
1313
|
+
dataHash = _args21.length > 0 && _args21[0] !== undefined ? _args21[0] : {};
|
|
1314
|
+
_context21.prev = 1;
|
|
1315
|
+
_context21.next = 4;
|
|
1201
1316
|
return this.axios.post('/user_service/registerUser', [dataHash]);
|
|
1202
1317
|
case 4:
|
|
1203
|
-
response =
|
|
1318
|
+
response = _context21.sent;
|
|
1204
1319
|
record = response.data;
|
|
1205
|
-
return
|
|
1320
|
+
return _context21.abrupt("return", new _rbt_user["default"](record, this.axios));
|
|
1206
1321
|
case 9:
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
return
|
|
1322
|
+
_context21.prev = 9;
|
|
1323
|
+
_context21.t0 = _context21["catch"](1);
|
|
1324
|
+
return _context21.abrupt("return", this._handleError(_context21.t0));
|
|
1210
1325
|
case 12:
|
|
1211
1326
|
case "end":
|
|
1212
|
-
return
|
|
1327
|
+
return _context21.stop();
|
|
1213
1328
|
}
|
|
1214
|
-
},
|
|
1329
|
+
}, _callee21, this, [[1, 9]]);
|
|
1215
1330
|
}));
|
|
1216
1331
|
function registerUser() {
|
|
1217
1332
|
return _registerUser.apply(this, arguments);
|
|
@@ -1228,32 +1343,32 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
1228
1343
|
}, {
|
|
1229
1344
|
key: "createFile",
|
|
1230
1345
|
value: (function () {
|
|
1231
|
-
var _createFile = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1346
|
+
var _createFile = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(dataHash) {
|
|
1232
1347
|
var response, record;
|
|
1233
|
-
return _regeneratorRuntime().wrap(function
|
|
1234
|
-
while (1) switch (
|
|
1348
|
+
return _regeneratorRuntime().wrap(function _callee22$(_context22) {
|
|
1349
|
+
while (1) switch (_context22.prev = _context22.next) {
|
|
1235
1350
|
case 0:
|
|
1236
|
-
|
|
1237
|
-
|
|
1351
|
+
_context22.prev = 0;
|
|
1352
|
+
_context22.next = 3;
|
|
1238
1353
|
return this.axios.post('/object_service/createObject', ['<@filekit.file>', dataHash]);
|
|
1239
1354
|
case 3:
|
|
1240
|
-
response =
|
|
1355
|
+
response = _context22.sent;
|
|
1241
1356
|
record = response.data;
|
|
1242
1357
|
if (dataHash) {
|
|
1243
1358
|
record.data = dataHash;
|
|
1244
1359
|
}
|
|
1245
|
-
return
|
|
1360
|
+
return _context22.abrupt("return", new _rbt_file["default"](record, this.axios, this.localDb));
|
|
1246
1361
|
case 9:
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
return
|
|
1362
|
+
_context22.prev = 9;
|
|
1363
|
+
_context22.t0 = _context22["catch"](0);
|
|
1364
|
+
return _context22.abrupt("return", this._handleError(_context22.t0));
|
|
1250
1365
|
case 12:
|
|
1251
1366
|
case "end":
|
|
1252
|
-
return
|
|
1367
|
+
return _context22.stop();
|
|
1253
1368
|
}
|
|
1254
|
-
},
|
|
1369
|
+
}, _callee22, this, [[0, 9]]);
|
|
1255
1370
|
}));
|
|
1256
|
-
function createFile(
|
|
1371
|
+
function createFile(_x11) {
|
|
1257
1372
|
return _createFile.apply(this, arguments);
|
|
1258
1373
|
}
|
|
1259
1374
|
return createFile;
|
|
@@ -1261,35 +1376,35 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
1261
1376
|
}, {
|
|
1262
1377
|
key: "loadFile",
|
|
1263
1378
|
value: function () {
|
|
1264
|
-
var _loadFile = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1379
|
+
var _loadFile = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(id) {
|
|
1265
1380
|
var response, record;
|
|
1266
|
-
return _regeneratorRuntime().wrap(function
|
|
1267
|
-
while (1) switch (
|
|
1381
|
+
return _regeneratorRuntime().wrap(function _callee23$(_context23) {
|
|
1382
|
+
while (1) switch (_context23.prev = _context23.next) {
|
|
1268
1383
|
case 0:
|
|
1269
|
-
|
|
1270
|
-
|
|
1384
|
+
_context23.prev = 0;
|
|
1385
|
+
_context23.next = 3;
|
|
1271
1386
|
return this.load('<@filekit.file>', id);
|
|
1272
1387
|
case 3:
|
|
1273
|
-
response =
|
|
1388
|
+
response = _context23.sent;
|
|
1274
1389
|
if (response) {
|
|
1275
|
-
|
|
1390
|
+
_context23.next = 6;
|
|
1276
1391
|
break;
|
|
1277
1392
|
}
|
|
1278
|
-
return
|
|
1393
|
+
return _context23.abrupt("return", null);
|
|
1279
1394
|
case 6:
|
|
1280
1395
|
record = response.toRecord();
|
|
1281
|
-
return
|
|
1396
|
+
return _context23.abrupt("return", new _rbt_file["default"](record, this.axios, this.localDb));
|
|
1282
1397
|
case 10:
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
return
|
|
1398
|
+
_context23.prev = 10;
|
|
1399
|
+
_context23.t0 = _context23["catch"](0);
|
|
1400
|
+
return _context23.abrupt("return", this._handleError(_context23.t0));
|
|
1286
1401
|
case 13:
|
|
1287
1402
|
case "end":
|
|
1288
|
-
return
|
|
1403
|
+
return _context23.stop();
|
|
1289
1404
|
}
|
|
1290
|
-
},
|
|
1405
|
+
}, _callee23, this, [[0, 10]]);
|
|
1291
1406
|
}));
|
|
1292
|
-
function loadFile(
|
|
1407
|
+
function loadFile(_x12) {
|
|
1293
1408
|
return _loadFile.apply(this, arguments);
|
|
1294
1409
|
}
|
|
1295
1410
|
return loadFile;
|
|
@@ -1297,39 +1412,39 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
1297
1412
|
}, {
|
|
1298
1413
|
key: "loadFiles",
|
|
1299
1414
|
value: function () {
|
|
1300
|
-
var _loadFiles = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1415
|
+
var _loadFiles = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(ids) {
|
|
1301
1416
|
var _this6 = this;
|
|
1302
1417
|
var responses;
|
|
1303
|
-
return _regeneratorRuntime().wrap(function
|
|
1304
|
-
while (1) switch (
|
|
1418
|
+
return _regeneratorRuntime().wrap(function _callee24$(_context24) {
|
|
1419
|
+
while (1) switch (_context24.prev = _context24.next) {
|
|
1305
1420
|
case 0:
|
|
1306
|
-
|
|
1307
|
-
|
|
1421
|
+
_context24.prev = 0;
|
|
1422
|
+
_context24.next = 3;
|
|
1308
1423
|
return this.load('<@filekit.file>', ids);
|
|
1309
1424
|
case 3:
|
|
1310
|
-
responses =
|
|
1425
|
+
responses = _context24.sent;
|
|
1311
1426
|
if (!(!responses || !Array.isArray(responses))) {
|
|
1312
|
-
|
|
1427
|
+
_context24.next = 6;
|
|
1313
1428
|
break;
|
|
1314
1429
|
}
|
|
1315
|
-
return
|
|
1430
|
+
return _context24.abrupt("return", []);
|
|
1316
1431
|
case 6:
|
|
1317
|
-
return
|
|
1432
|
+
return _context24.abrupt("return", responses.map(function (response) {
|
|
1318
1433
|
var record = response.toRecord();
|
|
1319
1434
|
return new _rbt_file["default"](record, _this6.axios, _this6.localDb);
|
|
1320
1435
|
}));
|
|
1321
1436
|
case 9:
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
this._handleError(
|
|
1325
|
-
return
|
|
1437
|
+
_context24.prev = 9;
|
|
1438
|
+
_context24.t0 = _context24["catch"](0);
|
|
1439
|
+
this._handleError(_context24.t0); // Handle errors (log or process as needed)
|
|
1440
|
+
return _context24.abrupt("return", []);
|
|
1326
1441
|
case 13:
|
|
1327
1442
|
case "end":
|
|
1328
|
-
return
|
|
1443
|
+
return _context24.stop();
|
|
1329
1444
|
}
|
|
1330
|
-
},
|
|
1445
|
+
}, _callee24, this, [[0, 9]]);
|
|
1331
1446
|
}));
|
|
1332
|
-
function loadFiles(
|
|
1447
|
+
function loadFiles(_x13) {
|
|
1333
1448
|
return _loadFiles.apply(this, arguments);
|
|
1334
1449
|
}
|
|
1335
1450
|
return loadFiles;
|
|
@@ -1345,42 +1460,42 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
1345
1460
|
}, {
|
|
1346
1461
|
key: "create",
|
|
1347
1462
|
value: (function () {
|
|
1348
|
-
var _create = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1463
|
+
var _create = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25(type) {
|
|
1349
1464
|
var dataHash,
|
|
1350
1465
|
options,
|
|
1351
1466
|
response,
|
|
1352
1467
|
record,
|
|
1353
|
-
|
|
1354
|
-
return _regeneratorRuntime().wrap(function
|
|
1355
|
-
while (1) switch (
|
|
1468
|
+
_args25 = arguments;
|
|
1469
|
+
return _regeneratorRuntime().wrap(function _callee25$(_context25) {
|
|
1470
|
+
while (1) switch (_context25.prev = _context25.next) {
|
|
1356
1471
|
case 0:
|
|
1357
|
-
dataHash =
|
|
1358
|
-
options =
|
|
1359
|
-
|
|
1360
|
-
|
|
1472
|
+
dataHash = _args25.length > 1 && _args25[1] !== undefined ? _args25[1] : {};
|
|
1473
|
+
options = _args25.length > 2 && _args25[2] !== undefined ? _args25[2] : {};
|
|
1474
|
+
_context25.prev = 2;
|
|
1475
|
+
_context25.next = 5;
|
|
1361
1476
|
return this.axios.post('/object_service/createObject', [type, dataHash]);
|
|
1362
1477
|
case 5:
|
|
1363
|
-
response =
|
|
1478
|
+
response = _context25.sent;
|
|
1364
1479
|
record = response.data;
|
|
1365
1480
|
if (dataHash) {
|
|
1366
1481
|
record.data = dataHash;
|
|
1367
1482
|
}
|
|
1368
|
-
return
|
|
1483
|
+
return _context25.abrupt("return", new _rbt_object["default"](record, this.axios, {
|
|
1369
1484
|
isNew: true,
|
|
1370
1485
|
websocketClient: this.websocketClient,
|
|
1371
1486
|
enableRealtime: options.enableRealtime || false
|
|
1372
1487
|
}));
|
|
1373
1488
|
case 11:
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
return
|
|
1489
|
+
_context25.prev = 11;
|
|
1490
|
+
_context25.t0 = _context25["catch"](2);
|
|
1491
|
+
return _context25.abrupt("return", this._handleError(_context25.t0));
|
|
1377
1492
|
case 14:
|
|
1378
1493
|
case "end":
|
|
1379
|
-
return
|
|
1494
|
+
return _context25.stop();
|
|
1380
1495
|
}
|
|
1381
|
-
},
|
|
1496
|
+
}, _callee25, this, [[2, 11]]);
|
|
1382
1497
|
}));
|
|
1383
|
-
function create(
|
|
1498
|
+
function create(_x14) {
|
|
1384
1499
|
return _create.apply(this, arguments);
|
|
1385
1500
|
}
|
|
1386
1501
|
return create;
|
|
@@ -1423,7 +1538,7 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
1423
1538
|
}, {
|
|
1424
1539
|
key: "query",
|
|
1425
1540
|
value: (function () {
|
|
1426
|
-
var _query = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1541
|
+
var _query = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(type) {
|
|
1427
1542
|
var _this7 = this;
|
|
1428
1543
|
var params,
|
|
1429
1544
|
paramsKey,
|
|
@@ -1436,12 +1551,12 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
1436
1551
|
cacheEntry,
|
|
1437
1552
|
responsePromise,
|
|
1438
1553
|
processingPromise,
|
|
1439
|
-
|
|
1440
|
-
return _regeneratorRuntime().wrap(function
|
|
1441
|
-
while (1) switch (
|
|
1554
|
+
_args26 = arguments;
|
|
1555
|
+
return _regeneratorRuntime().wrap(function _callee26$(_context26) {
|
|
1556
|
+
while (1) switch (_context26.prev = _context26.next) {
|
|
1442
1557
|
case 0:
|
|
1443
|
-
params =
|
|
1444
|
-
|
|
1558
|
+
params = _args26.length > 1 && _args26[1] !== undefined ? _args26[1] : {};
|
|
1559
|
+
_context26.prev = 1;
|
|
1445
1560
|
//console.log('RBTAPI.query INIT', type, params);
|
|
1446
1561
|
// Validate parameters - reject invalid parameter names
|
|
1447
1562
|
validParams = ['type', 'where', 'orderBy', 'limit', 'resolveReferences', 'requestAttrs', 'excludeAttrs', 'timeout', 'enableRealtime'];
|
|
@@ -1449,7 +1564,7 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
1449
1564
|
return !validParams.includes(key);
|
|
1450
1565
|
});
|
|
1451
1566
|
if (!(invalidParams.length > 0)) {
|
|
1452
|
-
|
|
1567
|
+
_context26.next = 6;
|
|
1453
1568
|
break;
|
|
1454
1569
|
}
|
|
1455
1570
|
throw new Error("Invalid query parameter(s): ".concat(invalidParams.join(', '), ". Valid parameters are: ").concat(validParams.join(', ')));
|
|
@@ -1476,10 +1591,10 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
1476
1591
|
paramsKey = JSON.stringify(mergedParams);
|
|
1477
1592
|
cacheEntry = this.requestCache[paramsKey];
|
|
1478
1593
|
if (!(cacheEntry && currentTime - cacheEntry.time < 10000)) {
|
|
1479
|
-
|
|
1594
|
+
_context26.next = 16;
|
|
1480
1595
|
break;
|
|
1481
1596
|
}
|
|
1482
|
-
return
|
|
1597
|
+
return _context26.abrupt("return", cacheEntry.val);
|
|
1483
1598
|
case 16:
|
|
1484
1599
|
// Create the response promise
|
|
1485
1600
|
responsePromise = this.axios.post('/object_service/queryObjects', [mergedParams]); // Cache the promise of processing data, not just the raw response
|
|
@@ -1496,23 +1611,23 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
1496
1611
|
};
|
|
1497
1612
|
|
|
1498
1613
|
// Await the processing promise for this call to get processed data
|
|
1499
|
-
|
|
1614
|
+
_context26.next = 21;
|
|
1500
1615
|
return processingPromise;
|
|
1501
1616
|
case 21:
|
|
1502
|
-
return
|
|
1617
|
+
return _context26.abrupt("return", _context26.sent);
|
|
1503
1618
|
case 24:
|
|
1504
|
-
|
|
1505
|
-
|
|
1619
|
+
_context26.prev = 24;
|
|
1620
|
+
_context26.t0 = _context26["catch"](1);
|
|
1506
1621
|
delete this.requestCache[paramsKey]; // Ensure cache cleanup on error
|
|
1507
1622
|
//console.log('RBTAPI.query ERROR', paramsKey, e);
|
|
1508
|
-
return
|
|
1623
|
+
return _context26.abrupt("return", this._handleError(_context26.t0));
|
|
1509
1624
|
case 28:
|
|
1510
1625
|
case "end":
|
|
1511
|
-
return
|
|
1626
|
+
return _context26.stop();
|
|
1512
1627
|
}
|
|
1513
|
-
},
|
|
1628
|
+
}, _callee26, this, [[1, 24]]);
|
|
1514
1629
|
}));
|
|
1515
|
-
function query(
|
|
1630
|
+
function query(_x15) {
|
|
1516
1631
|
return _query.apply(this, arguments);
|
|
1517
1632
|
}
|
|
1518
1633
|
return query;
|
|
@@ -1556,7 +1671,7 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
1556
1671
|
}, {
|
|
1557
1672
|
key: "load",
|
|
1558
1673
|
value: (function () {
|
|
1559
|
-
var _load = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1674
|
+
var _load = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(type, ids) {
|
|
1560
1675
|
var _this9 = this;
|
|
1561
1676
|
var params,
|
|
1562
1677
|
mergedParams,
|
|
@@ -1589,17 +1704,17 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
1589
1704
|
pendingKey,
|
|
1590
1705
|
missLogKey,
|
|
1591
1706
|
loadPromise,
|
|
1592
|
-
|
|
1593
|
-
return _regeneratorRuntime().wrap(function
|
|
1594
|
-
while (1) switch (
|
|
1707
|
+
_args28 = arguments;
|
|
1708
|
+
return _regeneratorRuntime().wrap(function _callee28$(_context28) {
|
|
1709
|
+
while (1) switch (_context28.prev = _context28.next) {
|
|
1595
1710
|
case 0:
|
|
1596
|
-
params =
|
|
1711
|
+
params = _args28.length > 2 && _args28[2] !== undefined ? _args28[2] : {};
|
|
1597
1712
|
if (type == '<@iac.user>') {
|
|
1598
1713
|
debugger;
|
|
1599
1714
|
}
|
|
1600
|
-
|
|
1715
|
+
_context28.prev = 2;
|
|
1601
1716
|
if (!Array.isArray(ids)) {
|
|
1602
|
-
|
|
1717
|
+
_context28.next = 25;
|
|
1603
1718
|
break;
|
|
1604
1719
|
}
|
|
1605
1720
|
// For array requests, check cache for each ID and only load missing ones
|
|
@@ -1636,7 +1751,7 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
1636
1751
|
}
|
|
1637
1752
|
loadedObjects = [];
|
|
1638
1753
|
if (!(missingIds.length > 0)) {
|
|
1639
|
-
|
|
1754
|
+
_context28.next = 19;
|
|
1640
1755
|
break;
|
|
1641
1756
|
}
|
|
1642
1757
|
// Only log bulk cache miss once
|
|
@@ -1650,10 +1765,10 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
1650
1765
|
mergedParams = _objectSpread(_objectSpread({}, queryParams), {}, {
|
|
1651
1766
|
where: "id IN (\"".concat(missingIds.join("\",\""), "\")")
|
|
1652
1767
|
});
|
|
1653
|
-
|
|
1768
|
+
_context28.next = 16;
|
|
1654
1769
|
return this.query(type, mergedParams);
|
|
1655
1770
|
case 16:
|
|
1656
|
-
loadedObjects =
|
|
1771
|
+
loadedObjects = _context28.sent;
|
|
1657
1772
|
// Cache the newly loaded objects
|
|
1658
1773
|
_iterator4 = _createForOfIteratorHelper(loadedObjects);
|
|
1659
1774
|
try {
|
|
@@ -1695,13 +1810,13 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
1695
1810
|
} finally {
|
|
1696
1811
|
_iterator5.f();
|
|
1697
1812
|
}
|
|
1698
|
-
return
|
|
1813
|
+
return _context28.abrupt("return", result);
|
|
1699
1814
|
case 25:
|
|
1700
1815
|
// For single object requests, check cache first
|
|
1701
1816
|
_cacheKey3 = "".concat(type, ":").concat(ids);
|
|
1702
1817
|
_cached = this._objectCache.get(_cacheKey3);
|
|
1703
1818
|
if (!_cached) {
|
|
1704
|
-
|
|
1819
|
+
_context28.next = 32;
|
|
1705
1820
|
break;
|
|
1706
1821
|
}
|
|
1707
1822
|
// Only log cache hits once per object to reduce spam
|
|
@@ -1714,18 +1829,18 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
1714
1829
|
if (params.enableRealtime && !_cached._realtime) {
|
|
1715
1830
|
_cached._initRealtime();
|
|
1716
1831
|
}
|
|
1717
|
-
return
|
|
1832
|
+
return _context28.abrupt("return", _cached);
|
|
1718
1833
|
case 32:
|
|
1719
1834
|
// Check if we're already loading this object
|
|
1720
1835
|
pendingKey = "".concat(type, ":").concat(ids);
|
|
1721
1836
|
if (!this._pendingLoads.has(pendingKey)) {
|
|
1722
|
-
|
|
1837
|
+
_context28.next = 37;
|
|
1723
1838
|
break;
|
|
1724
1839
|
}
|
|
1725
|
-
|
|
1840
|
+
_context28.next = 36;
|
|
1726
1841
|
return this._pendingLoads.get(pendingKey);
|
|
1727
1842
|
case 36:
|
|
1728
|
-
return
|
|
1843
|
+
return _context28.abrupt("return", _context28.sent);
|
|
1729
1844
|
case 37:
|
|
1730
1845
|
// Only log cache miss once per object to reduce spam
|
|
1731
1846
|
missLogKey = "miss:".concat(_cacheKey3);
|
|
@@ -1734,21 +1849,21 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
1734
1849
|
}
|
|
1735
1850
|
|
|
1736
1851
|
// Create the loading promise and store it to prevent duplicate requests
|
|
1737
|
-
loadPromise = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1852
|
+
loadPromise = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27() {
|
|
1738
1853
|
var _enableRealtime, _queryParams, res, _obj2, _setLogKey;
|
|
1739
|
-
return _regeneratorRuntime().wrap(function
|
|
1740
|
-
while (1) switch (
|
|
1854
|
+
return _regeneratorRuntime().wrap(function _callee27$(_context27) {
|
|
1855
|
+
while (1) switch (_context27.prev = _context27.next) {
|
|
1741
1856
|
case 0:
|
|
1742
|
-
|
|
1857
|
+
_context27.prev = 0;
|
|
1743
1858
|
// Remove load-specific params that shouldn't be passed to query
|
|
1744
1859
|
_enableRealtime = params.enableRealtime, _queryParams = _objectWithoutProperties(params, _excluded2);
|
|
1745
1860
|
mergedParams = _objectSpread(_objectSpread({}, _queryParams), {}, {
|
|
1746
1861
|
where: "id=\"".concat(ids, "\"")
|
|
1747
1862
|
});
|
|
1748
|
-
|
|
1863
|
+
_context27.next = 5;
|
|
1749
1864
|
return _this9.query(type, mergedParams);
|
|
1750
1865
|
case 5:
|
|
1751
|
-
res =
|
|
1866
|
+
res = _context27.sent;
|
|
1752
1867
|
_obj2 = res[0];
|
|
1753
1868
|
if (_obj2) {
|
|
1754
1869
|
// Cache the loaded object
|
|
@@ -1760,37 +1875,37 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
1760
1875
|
_this9._loggedCacheEvents.add(_setLogKey);
|
|
1761
1876
|
}
|
|
1762
1877
|
}
|
|
1763
|
-
return
|
|
1878
|
+
return _context27.abrupt("return", _obj2);
|
|
1764
1879
|
case 9:
|
|
1765
|
-
|
|
1880
|
+
_context27.prev = 9;
|
|
1766
1881
|
// Remove from pending loads
|
|
1767
1882
|
_this9._pendingLoads["delete"](pendingKey);
|
|
1768
|
-
return
|
|
1883
|
+
return _context27.finish(9);
|
|
1769
1884
|
case 12:
|
|
1770
1885
|
case "end":
|
|
1771
|
-
return
|
|
1886
|
+
return _context27.stop();
|
|
1772
1887
|
}
|
|
1773
|
-
},
|
|
1888
|
+
}, _callee27, null, [[0,, 9, 12]]);
|
|
1774
1889
|
}))(); // Store the promise so other concurrent requests can await it
|
|
1775
1890
|
this._pendingLoads.set(pendingKey, loadPromise);
|
|
1776
|
-
|
|
1891
|
+
_context28.next = 43;
|
|
1777
1892
|
return loadPromise;
|
|
1778
1893
|
case 43:
|
|
1779
|
-
return
|
|
1894
|
+
return _context28.abrupt("return", _context28.sent);
|
|
1780
1895
|
case 44:
|
|
1781
|
-
|
|
1896
|
+
_context28.next = 49;
|
|
1782
1897
|
break;
|
|
1783
1898
|
case 46:
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
return
|
|
1899
|
+
_context28.prev = 46;
|
|
1900
|
+
_context28.t0 = _context28["catch"](2);
|
|
1901
|
+
return _context28.abrupt("return", this._handleError(_context28.t0));
|
|
1787
1902
|
case 49:
|
|
1788
1903
|
case "end":
|
|
1789
|
-
return
|
|
1904
|
+
return _context28.stop();
|
|
1790
1905
|
}
|
|
1791
|
-
},
|
|
1906
|
+
}, _callee28, this, [[2, 46]]);
|
|
1792
1907
|
}));
|
|
1793
|
-
function load(
|
|
1908
|
+
function load(_x16, _x17) {
|
|
1794
1909
|
return _load.apply(this, arguments);
|
|
1795
1910
|
}
|
|
1796
1911
|
return load;
|
|
@@ -1908,7 +2023,7 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
1908
2023
|
}, {
|
|
1909
2024
|
key: "runTask",
|
|
1910
2025
|
value: (function () {
|
|
1911
|
-
var _runTask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2026
|
+
var _runTask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29() {
|
|
1912
2027
|
var params,
|
|
1913
2028
|
callbacks,
|
|
1914
2029
|
onProgress,
|
|
@@ -1923,20 +2038,20 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
1923
2038
|
message,
|
|
1924
2039
|
output,
|
|
1925
2040
|
errorResponse,
|
|
1926
|
-
|
|
1927
|
-
return _regeneratorRuntime().wrap(function
|
|
1928
|
-
while (1) switch (
|
|
2041
|
+
_args29 = arguments;
|
|
2042
|
+
return _regeneratorRuntime().wrap(function _callee29$(_context29) {
|
|
2043
|
+
while (1) switch (_context29.prev = _context29.next) {
|
|
1929
2044
|
case 0:
|
|
1930
|
-
params =
|
|
1931
|
-
callbacks =
|
|
2045
|
+
params = _args29.length > 0 && _args29[0] !== undefined ? _args29[0] : {};
|
|
2046
|
+
callbacks = _args29.length > 1 && _args29[1] !== undefined ? _args29[1] : {};
|
|
1932
2047
|
onProgress = callbacks.onProgress, onError = callbacks.onError, onStopped = callbacks.onStopped, onWaiting = callbacks.onWaiting, onDone = callbacks.onDone;
|
|
1933
|
-
|
|
1934
|
-
|
|
2048
|
+
_context29.prev = 3;
|
|
2049
|
+
_context29.next = 6;
|
|
1935
2050
|
return this.post('/task_service/runChain', params);
|
|
1936
2051
|
case 6:
|
|
1937
|
-
response =
|
|
2052
|
+
response = _context29.sent;
|
|
1938
2053
|
if (response) {
|
|
1939
|
-
|
|
2054
|
+
_context29.next = 9;
|
|
1940
2055
|
break;
|
|
1941
2056
|
}
|
|
1942
2057
|
throw new Error('Invalid server response');
|
|
@@ -1944,7 +2059,7 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
1944
2059
|
// Validate response structure
|
|
1945
2060
|
ok = response.ok, jobId = response.jobId, status = response.status, message = response.message, output = response.output;
|
|
1946
2061
|
if (!(!ok || typeof jobId !== 'string' || typeof status !== 'string')) {
|
|
1947
|
-
|
|
2062
|
+
_context29.next = 12;
|
|
1948
2063
|
break;
|
|
1949
2064
|
}
|
|
1950
2065
|
throw new Error('Invalid response structure');
|
|
@@ -1970,7 +2085,7 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
1970
2085
|
//console.log('Finish (request) ',response); s
|
|
1971
2086
|
onDone(response);
|
|
1972
2087
|
}
|
|
1973
|
-
return
|
|
2088
|
+
return _context29.abrupt("return", {
|
|
1974
2089
|
ok: ok,
|
|
1975
2090
|
jobId: jobId,
|
|
1976
2091
|
status: status,
|
|
@@ -1978,21 +2093,21 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
1978
2093
|
output: output
|
|
1979
2094
|
});
|
|
1980
2095
|
case 20:
|
|
1981
|
-
|
|
1982
|
-
|
|
2096
|
+
_context29.prev = 20;
|
|
2097
|
+
_context29.t0 = _context29["catch"](3);
|
|
1983
2098
|
// Standardize error format to match task response object
|
|
1984
2099
|
// Support RbtError format with label and message
|
|
1985
2100
|
errorResponse = {
|
|
1986
2101
|
ok: false,
|
|
1987
2102
|
jobId: null,
|
|
1988
2103
|
status: 'ERROR',
|
|
1989
|
-
message:
|
|
1990
|
-
label:
|
|
2104
|
+
message: _context29.t0.message || _context29.t0.toString() || 'Unknown error',
|
|
2105
|
+
label: _context29.t0.label || _context29.t0.name || 'Error',
|
|
1991
2106
|
output: {
|
|
1992
|
-
error:
|
|
1993
|
-
label:
|
|
1994
|
-
stack:
|
|
1995
|
-
originalError:
|
|
2107
|
+
error: _context29.t0.message,
|
|
2108
|
+
label: _context29.t0.label,
|
|
2109
|
+
stack: _context29.t0.stack,
|
|
2110
|
+
originalError: _context29.t0
|
|
1996
2111
|
}
|
|
1997
2112
|
};
|
|
1998
2113
|
if (typeof onError === 'function') {
|
|
@@ -2000,12 +2115,12 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
2000
2115
|
} else {
|
|
2001
2116
|
console.error('Error in runTask:', errorResponse.message);
|
|
2002
2117
|
}
|
|
2003
|
-
return
|
|
2118
|
+
return _context29.abrupt("return", errorResponse);
|
|
2004
2119
|
case 25:
|
|
2005
2120
|
case "end":
|
|
2006
|
-
return
|
|
2121
|
+
return _context29.stop();
|
|
2007
2122
|
}
|
|
2008
|
-
},
|
|
2123
|
+
}, _callee29, this, [[3, 20]]);
|
|
2009
2124
|
}));
|
|
2010
2125
|
function runTask() {
|
|
2011
2126
|
return _runTask.apply(this, arguments);
|
|
@@ -2015,37 +2130,37 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
2015
2130
|
}, {
|
|
2016
2131
|
key: "stopJob",
|
|
2017
2132
|
value: function () {
|
|
2018
|
-
var _stopJob = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2133
|
+
var _stopJob = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30() {
|
|
2019
2134
|
var params,
|
|
2020
2135
|
callbacks,
|
|
2021
2136
|
response,
|
|
2022
|
-
|
|
2023
|
-
return _regeneratorRuntime().wrap(function
|
|
2024
|
-
while (1) switch (
|
|
2137
|
+
_args30 = arguments;
|
|
2138
|
+
return _regeneratorRuntime().wrap(function _callee30$(_context30) {
|
|
2139
|
+
while (1) switch (_context30.prev = _context30.next) {
|
|
2025
2140
|
case 0:
|
|
2026
|
-
params =
|
|
2027
|
-
callbacks =
|
|
2028
|
-
|
|
2029
|
-
|
|
2141
|
+
params = _args30.length > 0 && _args30[0] !== undefined ? _args30[0] : {};
|
|
2142
|
+
callbacks = _args30.length > 1 && _args30[1] !== undefined ? _args30[1] : {};
|
|
2143
|
+
_context30.prev = 2;
|
|
2144
|
+
_context30.next = 5;
|
|
2030
2145
|
return this.post('/task_service/stopJob', params);
|
|
2031
2146
|
case 5:
|
|
2032
|
-
response =
|
|
2147
|
+
response = _context30.sent;
|
|
2033
2148
|
if (response) {
|
|
2034
|
-
|
|
2149
|
+
_context30.next = 8;
|
|
2035
2150
|
break;
|
|
2036
2151
|
}
|
|
2037
2152
|
throw new Error('Invalid server response');
|
|
2038
2153
|
case 8:
|
|
2039
|
-
return
|
|
2154
|
+
return _context30.abrupt("return", true);
|
|
2040
2155
|
case 11:
|
|
2041
|
-
|
|
2042
|
-
|
|
2156
|
+
_context30.prev = 11;
|
|
2157
|
+
_context30.t0 = _context30["catch"](2);
|
|
2043
2158
|
throw 'Error in stopJob';
|
|
2044
2159
|
case 14:
|
|
2045
2160
|
case "end":
|
|
2046
|
-
return
|
|
2161
|
+
return _context30.stop();
|
|
2047
2162
|
}
|
|
2048
|
-
},
|
|
2163
|
+
}, _callee30, this, [[2, 11]]);
|
|
2049
2164
|
}));
|
|
2050
2165
|
function stopJob() {
|
|
2051
2166
|
return _stopJob.apply(this, arguments);
|
|
@@ -2093,26 +2208,26 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
2093
2208
|
}, {
|
|
2094
2209
|
key: "pollTaskProgress",
|
|
2095
2210
|
value: (function () {
|
|
2096
|
-
var _pollTaskProgress = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2211
|
+
var _pollTaskProgress = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32(jobId, callbacks) {
|
|
2097
2212
|
var _this10 = this;
|
|
2098
2213
|
var onProgress, onError, onStopped, onWaiting, onDone, _callbacks$pollingInt, pollingInterval, checkProgress;
|
|
2099
|
-
return _regeneratorRuntime().wrap(function
|
|
2100
|
-
while (1) switch (
|
|
2214
|
+
return _regeneratorRuntime().wrap(function _callee32$(_context32) {
|
|
2215
|
+
while (1) switch (_context32.prev = _context32.next) {
|
|
2101
2216
|
case 0:
|
|
2102
2217
|
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;
|
|
2103
|
-
|
|
2218
|
+
_context32.prev = 1;
|
|
2104
2219
|
checkProgress = /*#__PURE__*/function () {
|
|
2105
|
-
var _ref9 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2220
|
+
var _ref9 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31() {
|
|
2106
2221
|
var response;
|
|
2107
|
-
return _regeneratorRuntime().wrap(function
|
|
2108
|
-
while (1) switch (
|
|
2222
|
+
return _regeneratorRuntime().wrap(function _callee31$(_context31) {
|
|
2223
|
+
while (1) switch (_context31.prev = _context31.next) {
|
|
2109
2224
|
case 0:
|
|
2110
|
-
|
|
2225
|
+
_context31.next = 2;
|
|
2111
2226
|
return _this10.get("/task_service/pollChainProgress", {
|
|
2112
2227
|
jobId: jobId
|
|
2113
2228
|
});
|
|
2114
2229
|
case 2:
|
|
2115
|
-
response =
|
|
2230
|
+
response = _context31.sent;
|
|
2116
2231
|
// If the task is still in progress, start polling for updates
|
|
2117
2232
|
if (response.status === 'DONE' && onDone) {
|
|
2118
2233
|
// Provide the current progress to the callback function
|
|
@@ -2143,28 +2258,28 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
2143
2258
|
}
|
|
2144
2259
|
case 9:
|
|
2145
2260
|
case "end":
|
|
2146
|
-
return
|
|
2261
|
+
return _context31.stop();
|
|
2147
2262
|
}
|
|
2148
|
-
},
|
|
2263
|
+
}, _callee31);
|
|
2149
2264
|
}));
|
|
2150
2265
|
return function checkProgress() {
|
|
2151
2266
|
return _ref9.apply(this, arguments);
|
|
2152
2267
|
};
|
|
2153
2268
|
}();
|
|
2154
2269
|
checkProgress();
|
|
2155
|
-
|
|
2270
|
+
_context32.next = 9;
|
|
2156
2271
|
break;
|
|
2157
2272
|
case 6:
|
|
2158
|
-
|
|
2159
|
-
|
|
2160
|
-
return
|
|
2273
|
+
_context32.prev = 6;
|
|
2274
|
+
_context32.t0 = _context32["catch"](1);
|
|
2275
|
+
return _context32.abrupt("return", this._handleError(_context32.t0));
|
|
2161
2276
|
case 9:
|
|
2162
2277
|
case "end":
|
|
2163
|
-
return
|
|
2278
|
+
return _context32.stop();
|
|
2164
2279
|
}
|
|
2165
|
-
},
|
|
2280
|
+
}, _callee32, this, [[1, 6]]);
|
|
2166
2281
|
}));
|
|
2167
|
-
function pollTaskProgress(
|
|
2282
|
+
function pollTaskProgress(_x18, _x19) {
|
|
2168
2283
|
return _pollTaskProgress.apply(this, arguments);
|
|
2169
2284
|
}
|
|
2170
2285
|
return pollTaskProgress;
|
|
@@ -2185,18 +2300,18 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
2185
2300
|
}, {
|
|
2186
2301
|
key: "get",
|
|
2187
2302
|
value: (function () {
|
|
2188
|
-
var _get = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2303
|
+
var _get = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33(endpoint) {
|
|
2189
2304
|
var params,
|
|
2190
2305
|
customHeaders,
|
|
2191
2306
|
config,
|
|
2192
2307
|
response,
|
|
2193
|
-
|
|
2194
|
-
return _regeneratorRuntime().wrap(function
|
|
2195
|
-
while (1) switch (
|
|
2308
|
+
_args33 = arguments;
|
|
2309
|
+
return _regeneratorRuntime().wrap(function _callee33$(_context33) {
|
|
2310
|
+
while (1) switch (_context33.prev = _context33.next) {
|
|
2196
2311
|
case 0:
|
|
2197
|
-
params =
|
|
2198
|
-
customHeaders =
|
|
2199
|
-
|
|
2312
|
+
params = _args33.length > 1 && _args33[1] !== undefined ? _args33[1] : {};
|
|
2313
|
+
customHeaders = _args33.length > 2 && _args33[2] !== undefined ? _args33[2] : null;
|
|
2314
|
+
_context33.prev = 2;
|
|
2200
2315
|
// Build request config
|
|
2201
2316
|
config = {
|
|
2202
2317
|
params: params
|
|
@@ -2211,28 +2326,28 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
2211
2326
|
// Otherwise, don't set config.headers at all - let axios use its defaults
|
|
2212
2327
|
|
|
2213
2328
|
// Make the GET request using Axios
|
|
2214
|
-
|
|
2329
|
+
_context33.next = 7;
|
|
2215
2330
|
return this.axios.get(endpoint, config);
|
|
2216
2331
|
case 7:
|
|
2217
|
-
response =
|
|
2332
|
+
response = _context33.sent;
|
|
2218
2333
|
if (!(response.data.ok === false)) {
|
|
2219
|
-
|
|
2334
|
+
_context33.next = 10;
|
|
2220
2335
|
break;
|
|
2221
2336
|
}
|
|
2222
|
-
return
|
|
2337
|
+
return _context33.abrupt("return", this._handleError(response));
|
|
2223
2338
|
case 10:
|
|
2224
|
-
return
|
|
2339
|
+
return _context33.abrupt("return", response.data);
|
|
2225
2340
|
case 13:
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
return
|
|
2341
|
+
_context33.prev = 13;
|
|
2342
|
+
_context33.t0 = _context33["catch"](2);
|
|
2343
|
+
return _context33.abrupt("return", this._handleError(_context33.t0));
|
|
2229
2344
|
case 16:
|
|
2230
2345
|
case "end":
|
|
2231
|
-
return
|
|
2346
|
+
return _context33.stop();
|
|
2232
2347
|
}
|
|
2233
|
-
},
|
|
2348
|
+
}, _callee33, this, [[2, 13]]);
|
|
2234
2349
|
}));
|
|
2235
|
-
function get(
|
|
2350
|
+
function get(_x20) {
|
|
2236
2351
|
return _get.apply(this, arguments);
|
|
2237
2352
|
}
|
|
2238
2353
|
return get;
|
|
@@ -2253,44 +2368,44 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
2253
2368
|
}, {
|
|
2254
2369
|
key: "post",
|
|
2255
2370
|
value: (function () {
|
|
2256
|
-
var _post = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2371
|
+
var _post = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34(endpoint) {
|
|
2257
2372
|
var data,
|
|
2258
2373
|
headers,
|
|
2259
2374
|
response,
|
|
2260
|
-
|
|
2261
|
-
return _regeneratorRuntime().wrap(function
|
|
2262
|
-
while (1) switch (
|
|
2375
|
+
_args34 = arguments;
|
|
2376
|
+
return _regeneratorRuntime().wrap(function _callee34$(_context34) {
|
|
2377
|
+
while (1) switch (_context34.prev = _context34.next) {
|
|
2263
2378
|
case 0:
|
|
2264
|
-
data =
|
|
2265
|
-
|
|
2379
|
+
data = _args34.length > 1 && _args34[1] !== undefined ? _args34[1] : {};
|
|
2380
|
+
_context34.prev = 1;
|
|
2266
2381
|
// Add the authToken to the headers
|
|
2267
2382
|
headers = {
|
|
2268
2383
|
authtoken: this.authtoken
|
|
2269
2384
|
}; // Make the POST request using Axios
|
|
2270
|
-
|
|
2385
|
+
_context34.next = 5;
|
|
2271
2386
|
return this.axios.post(endpoint, data, {
|
|
2272
2387
|
headers: headers
|
|
2273
2388
|
});
|
|
2274
2389
|
case 5:
|
|
2275
|
-
response =
|
|
2390
|
+
response = _context34.sent;
|
|
2276
2391
|
if (!(response.data.ok === false)) {
|
|
2277
|
-
|
|
2392
|
+
_context34.next = 8;
|
|
2278
2393
|
break;
|
|
2279
2394
|
}
|
|
2280
|
-
return
|
|
2395
|
+
return _context34.abrupt("return", this._handleError(response));
|
|
2281
2396
|
case 8:
|
|
2282
|
-
return
|
|
2397
|
+
return _context34.abrupt("return", response.data);
|
|
2283
2398
|
case 11:
|
|
2284
|
-
|
|
2285
|
-
|
|
2286
|
-
return
|
|
2399
|
+
_context34.prev = 11;
|
|
2400
|
+
_context34.t0 = _context34["catch"](1);
|
|
2401
|
+
return _context34.abrupt("return", this._handleError(_context34.t0));
|
|
2287
2402
|
case 14:
|
|
2288
2403
|
case "end":
|
|
2289
|
-
return
|
|
2404
|
+
return _context34.stop();
|
|
2290
2405
|
}
|
|
2291
|
-
},
|
|
2406
|
+
}, _callee34, this, [[1, 11]]);
|
|
2292
2407
|
}));
|
|
2293
|
-
function post(
|
|
2408
|
+
function post(_x21) {
|
|
2294
2409
|
return _post.apply(this, arguments);
|
|
2295
2410
|
}
|
|
2296
2411
|
return post;
|