@sanity/client 6.24.4 → 6.25.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/dist/index.browser.cjs +24 -16
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.js +24 -16
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +25 -17
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +25 -17
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/defineCreateClient.ts +5 -3
- package/src/http/request.ts +15 -8
- package/umd/sanityClient.js +24 -16
- package/umd/sanityClient.min.js +2 -2
package/dist/index.browser.js
CHANGED
|
@@ -81,17 +81,23 @@ const httpError = {
|
|
|
81
81
|
throw new ClientError(res);
|
|
82
82
|
return res;
|
|
83
83
|
}
|
|
84
|
-
}, printWarnings = {
|
|
85
|
-
onResponse: (res) => {
|
|
86
|
-
const warn = res.headers["x-sanity-warning"];
|
|
87
|
-
return (Array.isArray(warn) ? warn : [warn]).filter(Boolean).forEach((msg) => console.warn(msg)), res;
|
|
88
|
-
}
|
|
89
84
|
};
|
|
85
|
+
function printWarnings() {
|
|
86
|
+
const seen = {};
|
|
87
|
+
return {
|
|
88
|
+
onResponse: (res) => {
|
|
89
|
+
const warn = res.headers["x-sanity-warning"], warnings = Array.isArray(warn) ? warn : [warn];
|
|
90
|
+
for (const msg of warnings)
|
|
91
|
+
!msg || seen[msg] || (seen[msg] = !0, console.warn(msg));
|
|
92
|
+
return res;
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
}
|
|
90
96
|
function defineHttpRequest(envMiddleware2) {
|
|
91
97
|
return getIt([
|
|
92
98
|
retry({ shouldRetry }),
|
|
93
99
|
...envMiddleware2,
|
|
94
|
-
printWarnings,
|
|
100
|
+
printWarnings(),
|
|
95
101
|
jsonRequest(),
|
|
96
102
|
jsonResponse(),
|
|
97
103
|
progress(),
|
|
@@ -1602,16 +1608,18 @@ class SanityClient {
|
|
|
1602
1608
|
}
|
|
1603
1609
|
}
|
|
1604
1610
|
function defineCreateClientExports(envMiddleware2, ClassConstructor) {
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1611
|
+
return { requester: defineHttpRequest(envMiddleware2), createClient: (config) => {
|
|
1612
|
+
const clientRequester = defineHttpRequest(envMiddleware2);
|
|
1613
|
+
return new ClassConstructor(
|
|
1614
|
+
(options, requester2) => (requester2 || clientRequester)({
|
|
1615
|
+
maxRedirects: 0,
|
|
1616
|
+
maxRetries: config.maxRetries,
|
|
1617
|
+
retryDelay: config.retryDelay,
|
|
1618
|
+
...options
|
|
1619
|
+
}),
|
|
1620
|
+
config
|
|
1621
|
+
);
|
|
1622
|
+
} };
|
|
1615
1623
|
}
|
|
1616
1624
|
function defineDeprecatedCreateClient(createClient2) {
|
|
1617
1625
|
return function(config) {
|