@sanity/client 6.20.2-beta.0 → 6.20.2-beta.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/dist/index.browser.cjs +5 -5
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.js +5 -5
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +6 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +6 -6
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/defineCreateClient.ts +0 -1
- package/src/http/domainSharding.ts +9 -4
- package/src/http/requestOptions.ts +1 -0
- package/umd/sanityClient.js +5 -5
- package/umd/sanityClient.min.js +1 -1
package/dist/index.browser.cjs
CHANGED
|
@@ -601,6 +601,7 @@ function requestOptions(config, overrides = {}) {
|
|
|
601
601
|
proxy: overrides.proxy || config.proxy,
|
|
602
602
|
json: !0,
|
|
603
603
|
withCredentials,
|
|
604
|
+
useDomainSharding: config.useDomainSharding,
|
|
604
605
|
fetch: typeof overrides.fetch == "object" && typeof config.fetch == "object" ? { ...config.fetch, ...overrides.fetch } : overrides.fetch || config.fetch
|
|
605
606
|
});
|
|
606
607
|
}
|
|
@@ -872,9 +873,9 @@ function optionsFromFile(opts, file) {
|
|
|
872
873
|
opts
|
|
873
874
|
);
|
|
874
875
|
}
|
|
875
|
-
const UNSHARDED_URL_RE = /^https:\/\/([a-z0-9]+)\.api\.(sanity\..*)/, SHARDED_URL_RE = /^https:\/\/[a-z0-9]+\.api\.
|
|
876
|
+
const UNSHARDED_URL_RE = /^https:\/\/([a-z0-9]+)\.api\.(sanity\..*)/, SHARDED_URL_RE = /^https:\/\/[a-z0-9]+\.api\.r(\d+)\.sanity\.(.*)/, domainSharder = getDomainSharder();
|
|
876
877
|
function getDomainSharder(initialBuckets) {
|
|
877
|
-
const buckets = new Array(
|
|
878
|
+
const buckets = new Array(3).fill(0, 0);
|
|
878
879
|
function incrementBucketForUrl(url) {
|
|
879
880
|
const shard = getShardFromUrl(url);
|
|
880
881
|
shard !== null && buckets[shard]++;
|
|
@@ -891,11 +892,11 @@ function getDomainSharder(initialBuckets) {
|
|
|
891
892
|
(smallest, count, index) => count < buckets[smallest] ? index : smallest,
|
|
892
893
|
0
|
|
893
894
|
);
|
|
894
|
-
return `https://${projectId2}.api.
|
|
895
|
+
return `https://${projectId2}.api.r${bucket + 1}.${rest}`;
|
|
895
896
|
}
|
|
896
897
|
function getShardFromUrl(url) {
|
|
897
898
|
const [isMatch, shard] = url.match(SHARDED_URL_RE) || [];
|
|
898
|
-
return isMatch ? parseInt(shard, 10) : null;
|
|
899
|
+
return isMatch ? parseInt(shard, 10) - 1 : null;
|
|
899
900
|
}
|
|
900
901
|
return {
|
|
901
902
|
middleware: {
|
|
@@ -1587,7 +1588,6 @@ function defineCreateClientExports(envMiddleware2, ClassConstructor) {
|
|
|
1587
1588
|
maxRedirects: 0,
|
|
1588
1589
|
maxRetries: config.maxRetries,
|
|
1589
1590
|
retryDelay: config.retryDelay,
|
|
1590
|
-
useDomainSharding: config.useDomainSharding,
|
|
1591
1591
|
...options
|
|
1592
1592
|
}),
|
|
1593
1593
|
config
|