@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.cjs
CHANGED
|
@@ -97,17 +97,23 @@ const httpError = {
|
|
|
97
97
|
throw new ClientError(res);
|
|
98
98
|
return res;
|
|
99
99
|
}
|
|
100
|
-
}, printWarnings = {
|
|
101
|
-
onResponse: (res) => {
|
|
102
|
-
const warn = res.headers["x-sanity-warning"];
|
|
103
|
-
return (Array.isArray(warn) ? warn : [warn]).filter(Boolean).forEach((msg) => console.warn(msg)), res;
|
|
104
|
-
}
|
|
105
100
|
};
|
|
101
|
+
function printWarnings() {
|
|
102
|
+
const seen = {};
|
|
103
|
+
return {
|
|
104
|
+
onResponse: (res) => {
|
|
105
|
+
const warn = res.headers["x-sanity-warning"], warnings = Array.isArray(warn) ? warn : [warn];
|
|
106
|
+
for (const msg of warnings)
|
|
107
|
+
!msg || seen[msg] || (seen[msg] = !0, console.warn(msg));
|
|
108
|
+
return res;
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
}
|
|
106
112
|
function defineHttpRequest(envMiddleware2) {
|
|
107
113
|
return getIt.getIt([
|
|
108
114
|
middleware.retry({ shouldRetry }),
|
|
109
115
|
...envMiddleware2,
|
|
110
|
-
printWarnings,
|
|
116
|
+
printWarnings(),
|
|
111
117
|
middleware.jsonRequest(),
|
|
112
118
|
middleware.jsonResponse(),
|
|
113
119
|
middleware.progress(),
|
|
@@ -1620,16 +1626,18 @@ class SanityClient {
|
|
|
1620
1626
|
}
|
|
1621
1627
|
}
|
|
1622
1628
|
function defineCreateClientExports(envMiddleware2, ClassConstructor) {
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1629
|
+
return { requester: defineHttpRequest(envMiddleware2), createClient: (config) => {
|
|
1630
|
+
const clientRequester = defineHttpRequest(envMiddleware2);
|
|
1631
|
+
return new ClassConstructor(
|
|
1632
|
+
(options, requester2) => (requester2 || clientRequester)({
|
|
1633
|
+
maxRedirects: 0,
|
|
1634
|
+
maxRetries: config.maxRetries,
|
|
1635
|
+
retryDelay: config.retryDelay,
|
|
1636
|
+
...options
|
|
1637
|
+
}),
|
|
1638
|
+
config
|
|
1639
|
+
);
|
|
1640
|
+
} };
|
|
1633
1641
|
}
|
|
1634
1642
|
function defineDeprecatedCreateClient(createClient2) {
|
|
1635
1643
|
return function(config) {
|