@xata.io/client 0.13.1 → 0.13.2
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/CHANGELOG.md +10 -0
- package/dist/index.cjs +12 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +13 -11
- package/dist/index.mjs +12 -5
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
@@ -1,5 +1,15 @@
|
|
1
1
|
# @xata.io/client
|
2
2
|
|
3
|
+
## 0.13.2
|
4
|
+
|
5
|
+
### Patch Changes
|
6
|
+
|
7
|
+
- [#431](https://github.com/xataio/client-ts/pull/431) [`8f62024`](https://github.com/xataio/client-ts/commit/8f62024101028b981dc31a68fb258e89110d45dc) Thanks [@SferaDev](https://github.com/SferaDev)! - Include request ids in the error response
|
8
|
+
|
9
|
+
* [#429](https://github.com/xataio/client-ts/pull/429) [`bb102b4`](https://github.com/xataio/client-ts/commit/bb102b46b722d0a61996c42cda991c9f0080e464) Thanks [@SferaDev](https://github.com/SferaDev)! - Avoid detection of `Buffer` in edge runtime middleware
|
10
|
+
|
11
|
+
- [#428](https://github.com/xataio/client-ts/pull/428) [`06740ca`](https://github.com/xataio/client-ts/commit/06740cad216831216f0be8cf9de7e354c0ef9191) Thanks [@SferaDev](https://github.com/SferaDev)! - Improve selection types to make them more readable
|
12
|
+
|
3
13
|
## 0.13.1
|
4
14
|
|
5
15
|
### Patch Changes
|
package/dist/index.cjs
CHANGED
@@ -21,7 +21,8 @@ function toBase64(value) {
|
|
21
21
|
try {
|
22
22
|
return btoa(value);
|
23
23
|
} catch (err) {
|
24
|
-
|
24
|
+
const buf = Buffer;
|
25
|
+
return buf.from(value).toString("base64");
|
25
26
|
}
|
26
27
|
}
|
27
28
|
|
@@ -77,7 +78,7 @@ function getFetchImplementation(userFetch) {
|
|
77
78
|
return fetchImpl;
|
78
79
|
}
|
79
80
|
|
80
|
-
const VERSION = "0.13.
|
81
|
+
const VERSION = "0.13.2";
|
81
82
|
|
82
83
|
class ErrorWithCause extends Error {
|
83
84
|
constructor(message, options) {
|
@@ -85,15 +86,20 @@ class ErrorWithCause extends Error {
|
|
85
86
|
}
|
86
87
|
}
|
87
88
|
class FetcherError extends ErrorWithCause {
|
88
|
-
constructor(status, data) {
|
89
|
+
constructor(status, data, requestId) {
|
89
90
|
super(getMessage(data));
|
90
91
|
this.status = status;
|
91
92
|
this.errors = isBulkError(data) ? data.errors : void 0;
|
93
|
+
this.requestId = requestId;
|
92
94
|
if (data instanceof Error) {
|
93
95
|
this.stack = data.stack;
|
94
96
|
this.cause = data.cause;
|
95
97
|
}
|
96
98
|
}
|
99
|
+
toString() {
|
100
|
+
const error = super.toString();
|
101
|
+
return `[${this.status}] (${this.requestId ?? "Unknown"}): ${error}`;
|
102
|
+
}
|
97
103
|
}
|
98
104
|
function isBulkError(error) {
|
99
105
|
return isObject(error) && Array.isArray(error.errors);
|
@@ -170,14 +176,15 @@ async function fetch$1({
|
|
170
176
|
if (response.status === 204) {
|
171
177
|
return {};
|
172
178
|
}
|
179
|
+
const requestId = response.headers?.get("x-request-id") ?? void 0;
|
173
180
|
try {
|
174
181
|
const jsonResponse = await response.json();
|
175
182
|
if (response.ok) {
|
176
183
|
return jsonResponse;
|
177
184
|
}
|
178
|
-
throw new FetcherError(response.status, jsonResponse);
|
185
|
+
throw new FetcherError(response.status, jsonResponse, requestId);
|
179
186
|
} catch (error) {
|
180
|
-
throw new FetcherError(response.status, error);
|
187
|
+
throw new FetcherError(response.status, error, requestId);
|
181
188
|
}
|
182
189
|
}
|
183
190
|
|