@faable/faable 1.5.17-next.21 → 1.5.17-next.22
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/api/FaableApi.js +17 -54
- package/package.json +1 -1
package/dist/api/FaableApi.js
CHANGED
|
@@ -1,29 +1,5 @@
|
|
|
1
|
-
import { __decorate } from 'tslib';
|
|
2
1
|
import { create_base_client } from './base_client.js';
|
|
3
2
|
|
|
4
|
-
function handleError() {
|
|
5
|
-
return function (target, propertyKey, descriptor) {
|
|
6
|
-
const method = descriptor.value;
|
|
7
|
-
descriptor.value = async function (...args) {
|
|
8
|
-
try {
|
|
9
|
-
return await method.bind(this).apply(target, args);
|
|
10
|
-
}
|
|
11
|
-
catch (error) {
|
|
12
|
-
const e = error;
|
|
13
|
-
if (e.isAxiosError) {
|
|
14
|
-
const res = e.response;
|
|
15
|
-
if (res) {
|
|
16
|
-
throw new Error(`FaableApi ${e.config.url} ${res.status}: ${res?.data.message}`, { cause: error });
|
|
17
|
-
}
|
|
18
|
-
else {
|
|
19
|
-
throw new Error(`FaableApi ${e.message}`, { cause: error });
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
throw error;
|
|
23
|
-
}
|
|
24
|
-
};
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
3
|
const firstPage = async (res) => {
|
|
28
4
|
const items = (await res).results;
|
|
29
5
|
return items;
|
|
@@ -51,6 +27,23 @@ class FaableApi {
|
|
|
51
27
|
// Do something with request error
|
|
52
28
|
return Promise.reject(error);
|
|
53
29
|
});
|
|
30
|
+
this.client.interceptors.response.use((response) => response, (error) => {
|
|
31
|
+
const e = error;
|
|
32
|
+
if (e.isAxiosError) {
|
|
33
|
+
const res = e.response;
|
|
34
|
+
const url = e.config?.url || "";
|
|
35
|
+
if (res) {
|
|
36
|
+
const serverMessage = res.data?.message || res.statusText || "Unknown Error";
|
|
37
|
+
throw new Error(`FaableApi ${url} ${res.status}: ${serverMessage}`, {
|
|
38
|
+
cause: error,
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
throw new Error(`FaableApi ${url} ${e.message}`, { cause: error });
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
throw error;
|
|
46
|
+
});
|
|
54
47
|
}
|
|
55
48
|
static create(config = {}) {
|
|
56
49
|
return new FaableApi(config);
|
|
@@ -86,35 +79,5 @@ class FaableApi {
|
|
|
86
79
|
return data(this.client.get(`/auth/me`));
|
|
87
80
|
}
|
|
88
81
|
}
|
|
89
|
-
__decorate([
|
|
90
|
-
handleError()
|
|
91
|
-
], FaableApi.prototype, "list", null);
|
|
92
|
-
__decorate([
|
|
93
|
-
handleError()
|
|
94
|
-
], FaableApi.prototype, "getBySlug", null);
|
|
95
|
-
__decorate([
|
|
96
|
-
handleError()
|
|
97
|
-
], FaableApi.prototype, "getApp", null);
|
|
98
|
-
__decorate([
|
|
99
|
-
handleError()
|
|
100
|
-
], FaableApi.prototype, "getRegistry", null);
|
|
101
|
-
__decorate([
|
|
102
|
-
handleError()
|
|
103
|
-
], FaableApi.prototype, "createDeployment", null);
|
|
104
|
-
__decorate([
|
|
105
|
-
handleError()
|
|
106
|
-
], FaableApi.prototype, "getAppSecrets", null);
|
|
107
|
-
__decorate([
|
|
108
|
-
handleError()
|
|
109
|
-
], FaableApi.prototype, "updateApp", null);
|
|
110
|
-
__decorate([
|
|
111
|
-
handleError()
|
|
112
|
-
], FaableApi.prototype, "getDeviceCode", null);
|
|
113
|
-
__decorate([
|
|
114
|
-
handleError()
|
|
115
|
-
], FaableApi.prototype, "getDeviceToken", null);
|
|
116
|
-
__decorate([
|
|
117
|
-
handleError()
|
|
118
|
-
], FaableApi.prototype, "getMe", null);
|
|
119
82
|
|
|
120
83
|
export { FaableApi };
|