@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/package.json
CHANGED
|
@@ -38,10 +38,11 @@ export default function defineCreateClientExports<
|
|
|
38
38
|
// Set the http client to use for requests, and its environment specific middleware
|
|
39
39
|
const defaultRequester = defineHttpRequest(envMiddleware)
|
|
40
40
|
|
|
41
|
-
const createClient = (config: ClientConfigType) =>
|
|
42
|
-
|
|
41
|
+
const createClient = (config: ClientConfigType) => {
|
|
42
|
+
const clientRequester = defineHttpRequest(envMiddleware)
|
|
43
|
+
return new ClassConstructor(
|
|
43
44
|
(options, requester) =>
|
|
44
|
-
(requester ||
|
|
45
|
+
(requester || clientRequester)({
|
|
45
46
|
maxRedirects: 0,
|
|
46
47
|
maxRetries: config.maxRetries,
|
|
47
48
|
retryDelay: config.retryDelay,
|
|
@@ -49,6 +50,7 @@ export default function defineCreateClientExports<
|
|
|
49
50
|
} as Any),
|
|
50
51
|
config,
|
|
51
52
|
)
|
|
53
|
+
}
|
|
52
54
|
|
|
53
55
|
return {requester: defaultRequester, createClient}
|
|
54
56
|
}
|
package/src/http/request.ts
CHANGED
|
@@ -17,13 +17,20 @@ const httpError = {
|
|
|
17
17
|
},
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
20
|
+
function printWarnings() {
|
|
21
|
+
const seen: Record<string, boolean> = {}
|
|
22
|
+
return {
|
|
23
|
+
onResponse: (res: Any) => {
|
|
24
|
+
const warn = res.headers['x-sanity-warning']
|
|
25
|
+
const warnings = Array.isArray(warn) ? warn : [warn]
|
|
26
|
+
for (const msg of warnings) {
|
|
27
|
+
if (!msg || seen[msg]) continue
|
|
28
|
+
seen[msg] = true
|
|
29
|
+
console.warn(msg) // eslint-disable-line no-console
|
|
30
|
+
}
|
|
31
|
+
return res
|
|
32
|
+
},
|
|
33
|
+
}
|
|
27
34
|
}
|
|
28
35
|
|
|
29
36
|
/** @internal */
|
|
@@ -31,7 +38,7 @@ export function defineHttpRequest(envMiddleware: Middlewares): Requester {
|
|
|
31
38
|
return getIt([
|
|
32
39
|
retry({shouldRetry}),
|
|
33
40
|
...envMiddleware,
|
|
34
|
-
printWarnings,
|
|
41
|
+
printWarnings(),
|
|
35
42
|
jsonRequest(),
|
|
36
43
|
jsonResponse(),
|
|
37
44
|
progress(),
|
package/umd/sanityClient.js
CHANGED
|
@@ -1924,17 +1924,23 @@
|
|
|
1924
1924
|
throw new ClientError(res);
|
|
1925
1925
|
return res;
|
|
1926
1926
|
}
|
|
1927
|
-
}, printWarnings = {
|
|
1928
|
-
onResponse: (res) => {
|
|
1929
|
-
const warn = res.headers["x-sanity-warning"];
|
|
1930
|
-
return (Array.isArray(warn) ? warn : [warn]).filter(Boolean).forEach((msg) => console.warn(msg)), res;
|
|
1931
|
-
}
|
|
1932
1927
|
};
|
|
1928
|
+
function printWarnings() {
|
|
1929
|
+
const seen = {};
|
|
1930
|
+
return {
|
|
1931
|
+
onResponse: (res) => {
|
|
1932
|
+
const warn = res.headers["x-sanity-warning"], warnings = Array.isArray(warn) ? warn : [warn];
|
|
1933
|
+
for (const msg of warnings)
|
|
1934
|
+
!msg || seen[msg] || (seen[msg] = true, console.warn(msg));
|
|
1935
|
+
return res;
|
|
1936
|
+
}
|
|
1937
|
+
};
|
|
1938
|
+
}
|
|
1933
1939
|
function defineHttpRequest(envMiddleware2) {
|
|
1934
1940
|
return p$1([
|
|
1935
1941
|
P({ shouldRetry }),
|
|
1936
1942
|
...envMiddleware2,
|
|
1937
|
-
printWarnings,
|
|
1943
|
+
printWarnings(),
|
|
1938
1944
|
x(),
|
|
1939
1945
|
E$1(),
|
|
1940
1946
|
S$1(),
|
|
@@ -3445,16 +3451,18 @@ ${selectionOpts}`);
|
|
|
3445
3451
|
}
|
|
3446
3452
|
}
|
|
3447
3453
|
function defineCreateClientExports(envMiddleware2, ClassConstructor) {
|
|
3448
|
-
|
|
3449
|
-
|
|
3450
|
-
|
|
3451
|
-
|
|
3452
|
-
|
|
3453
|
-
|
|
3454
|
-
|
|
3455
|
-
|
|
3456
|
-
|
|
3457
|
-
|
|
3454
|
+
return { requester: defineHttpRequest(envMiddleware2), createClient: (config) => {
|
|
3455
|
+
const clientRequester = defineHttpRequest(envMiddleware2);
|
|
3456
|
+
return new ClassConstructor(
|
|
3457
|
+
(options, requester2) => (requester2 || clientRequester)({
|
|
3458
|
+
maxRedirects: 0,
|
|
3459
|
+
maxRetries: config.maxRetries,
|
|
3460
|
+
retryDelay: config.retryDelay,
|
|
3461
|
+
...options
|
|
3462
|
+
}),
|
|
3463
|
+
config
|
|
3464
|
+
);
|
|
3465
|
+
} };
|
|
3458
3466
|
}
|
|
3459
3467
|
function defineDeprecatedCreateClient(createClient2) {
|
|
3460
3468
|
return function(config) {
|