@nocobase/sdk 2.0.0-alpha.7 → 2.0.0-alpha.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/APIClient.d.ts +1 -0
- package/lib/APIClient.js +21 -0
- package/package.json +2 -2
package/lib/APIClient.d.ts
CHANGED
package/lib/APIClient.js
CHANGED
|
@@ -294,6 +294,27 @@ const _APIClient = class _APIClient {
|
|
|
294
294
|
auth;
|
|
295
295
|
storage;
|
|
296
296
|
storagePrefix = "NOCOBASE_";
|
|
297
|
+
toErrMessages(error) {
|
|
298
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
299
|
+
if (typeof document !== "undefined" && typeof ((_a = error == null ? void 0 : error.response) == null ? void 0 : _a.data) === "string") {
|
|
300
|
+
const tempElement = document.createElement("div");
|
|
301
|
+
tempElement.innerHTML = (_b = error == null ? void 0 : error.response) == null ? void 0 : _b.data;
|
|
302
|
+
let message = tempElement.textContent || tempElement.innerText;
|
|
303
|
+
if (message.includes("Error occurred while trying")) {
|
|
304
|
+
message = "The application may be starting up. Please try again later.";
|
|
305
|
+
return [{ code: "APP_WARNING", message }];
|
|
306
|
+
}
|
|
307
|
+
if (message.includes("502 Bad Gateway")) {
|
|
308
|
+
message = "The application may be starting up. Please try again later.";
|
|
309
|
+
return [{ code: "APP_WARNING", message }];
|
|
310
|
+
}
|
|
311
|
+
return [{ message }];
|
|
312
|
+
}
|
|
313
|
+
if ((_d = (_c = error == null ? void 0 : error.response) == null ? void 0 : _c.data) == null ? void 0 : _d.error) {
|
|
314
|
+
return [(_f = (_e = error == null ? void 0 : error.response) == null ? void 0 : _e.data) == null ? void 0 : _f.error];
|
|
315
|
+
}
|
|
316
|
+
return ((_h = (_g = error == null ? void 0 : error.response) == null ? void 0 : _g.data) == null ? void 0 : _h.errors) || ((_j = (_i = error == null ? void 0 : error.response) == null ? void 0 : _i.data) == null ? void 0 : _j.messages) || ((_k = error == null ? void 0 : error.response) == null ? void 0 : _k.error) || [{ message: error.message || "Server error" }];
|
|
317
|
+
}
|
|
297
318
|
getHeaders() {
|
|
298
319
|
const headers = {};
|
|
299
320
|
if (this.auth.locale) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/sdk",
|
|
3
|
-
"version": "2.0.0-alpha.
|
|
3
|
+
"version": "2.0.0-alpha.8",
|
|
4
4
|
"license": "AGPL-3.0",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -11,5 +11,5 @@
|
|
|
11
11
|
"devDependencies": {
|
|
12
12
|
"axios-mock-adapter": "^1.20.0"
|
|
13
13
|
},
|
|
14
|
-
"gitHead": "
|
|
14
|
+
"gitHead": "ff91246a3914c72dc1f4000d85df10a16798ff78"
|
|
15
15
|
}
|