@sanity/client 6.15.17-canary.1 → 6.15.17
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 +18 -6
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.js +18 -6
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +19 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +19 -7
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/defineCreateClient.ts +9 -2
- package/src/http/request.ts +15 -5
- package/umd/sanityClient.js +18 -6
- package/umd/sanityClient.min.js +2 -2
package/dist/index.browser.cjs
CHANGED
|
@@ -82,9 +82,18 @@ const httpError = {
|
|
|
82
82
|
return (Array.isArray(warn) ? warn : [warn]).filter(Boolean).forEach((msg) => console.warn(msg)), res;
|
|
83
83
|
}
|
|
84
84
|
};
|
|
85
|
-
function defineHttpRequest(envMiddleware2
|
|
85
|
+
function defineHttpRequest(envMiddleware2, {
|
|
86
|
+
maxRetries = 5,
|
|
87
|
+
retryDelay
|
|
88
|
+
}) {
|
|
86
89
|
const request = getIt.getIt([
|
|
87
|
-
middleware.retry({
|
|
90
|
+
maxRetries > 0 ? middleware.retry({
|
|
91
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
92
|
+
retryDelay,
|
|
93
|
+
// This option is typed incorrectly in get-it.
|
|
94
|
+
maxRetries,
|
|
95
|
+
shouldRetry
|
|
96
|
+
}) : {},
|
|
88
97
|
...envMiddleware2,
|
|
89
98
|
printWarnings,
|
|
90
99
|
middleware.jsonRequest(),
|
|
@@ -99,8 +108,6 @@ function defineHttpRequest(envMiddleware2) {
|
|
|
99
108
|
return httpRequest.defaultRequester = request, httpRequest;
|
|
100
109
|
}
|
|
101
110
|
function shouldRetry(err, attempt, options) {
|
|
102
|
-
if (options.maxRetries === 0)
|
|
103
|
-
return !1;
|
|
104
111
|
const isSafe = options.method === "GET" || options.method === "HEAD", isQuery = (options.uri || options.url).startsWith("/data/query"), isRetriableResponse = err.response && (err.response.statusCode === 429 || err.response.statusCode === 502 || err.response.statusCode === 503);
|
|
105
112
|
return (isSafe || isQuery) && isRetriableResponse ? !0 : middleware.retry.shouldRetry(err, attempt, options);
|
|
106
113
|
}
|
|
@@ -1420,8 +1427,13 @@ const _SanityClient = class _SanityClient2 {
|
|
|
1420
1427
|
_clientConfig2 = /* @__PURE__ */ new WeakMap(), _httpRequest2 = /* @__PURE__ */ new WeakMap();
|
|
1421
1428
|
let SanityClient = _SanityClient;
|
|
1422
1429
|
function defineCreateClientExports(envMiddleware2, ClassConstructor) {
|
|
1423
|
-
|
|
1424
|
-
|
|
1430
|
+
return { requester: defineHttpRequest(envMiddleware2, {}).defaultRequester, createClient: (config) => new ClassConstructor(
|
|
1431
|
+
defineHttpRequest(envMiddleware2, {
|
|
1432
|
+
maxRetries: config.maxRetries,
|
|
1433
|
+
retryDelay: config.retryDelay
|
|
1434
|
+
}),
|
|
1435
|
+
config
|
|
1436
|
+
) };
|
|
1425
1437
|
}
|
|
1426
1438
|
function defineDeprecatedCreateClient(createClient2) {
|
|
1427
1439
|
return function(config) {
|