@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.
@@ -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\.s(\d+)\.sanity\.(.*)/, domainSharder = getDomainSharder();
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(10).fill(0, 0);
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.s${bucket}.${rest}`;
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