@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.js CHANGED
@@ -586,6 +586,7 @@ function requestOptions(config, overrides = {}) {
586
586
  proxy: overrides.proxy || config.proxy,
587
587
  json: !0,
588
588
  withCredentials,
589
+ useDomainSharding: config.useDomainSharding,
589
590
  fetch: typeof overrides.fetch == "object" && typeof config.fetch == "object" ? { ...config.fetch, ...overrides.fetch } : overrides.fetch || config.fetch
590
591
  });
591
592
  }
@@ -855,9 +856,9 @@ function optionsFromFile(opts, file) {
855
856
  opts
856
857
  );
857
858
  }
858
- const UNSHARDED_URL_RE = /^https:\/\/([a-z0-9]+)\.api\.(sanity\..*)/, SHARDED_URL_RE = /^https:\/\/[a-z0-9]+\.api\.s(\d+)\.sanity\.(.*)/, domainSharder = getDomainSharder();
859
+ const UNSHARDED_URL_RE = /^https:\/\/([a-z0-9]+)\.api\.(sanity\..*)/, SHARDED_URL_RE = /^https:\/\/[a-z0-9]+\.api\.r(\d+)\.sanity\.(.*)/, domainSharder = getDomainSharder();
859
860
  function getDomainSharder(initialBuckets) {
860
- const buckets = new Array(10).fill(0, 0);
861
+ const buckets = new Array(3).fill(0, 0);
861
862
  function incrementBucketForUrl(url) {
862
863
  const shard = getShardFromUrl(url);
863
864
  shard !== null && buckets[shard]++;
@@ -874,11 +875,11 @@ function getDomainSharder(initialBuckets) {
874
875
  (smallest, count, index) => count < buckets[smallest] ? index : smallest,
875
876
  0
876
877
  );
877
- return `https://${projectId2}.api.s${bucket}.${rest}`;
878
+ return `https://${projectId2}.api.r${bucket + 1}.${rest}`;
878
879
  }
879
880
  function getShardFromUrl(url) {
880
881
  const [isMatch, shard] = url.match(SHARDED_URL_RE) || [];
881
- return isMatch ? parseInt(shard, 10) : null;
882
+ return isMatch ? parseInt(shard, 10) - 1 : null;
882
883
  }
883
884
  return {
884
885
  middleware: {
@@ -1570,7 +1571,6 @@ function defineCreateClientExports(envMiddleware, ClassConstructor) {
1570
1571
  maxRedirects: 0,
1571
1572
  maxRetries: config.maxRetries,
1572
1573
  retryDelay: config.retryDelay,
1573
- useDomainSharding: config.useDomainSharding,
1574
1574
  ...options
1575
1575
  }),
1576
1576
  config
@@ -1581,7 +1581,7 @@ function defineDeprecatedCreateClient(createClient2) {
1581
1581
  return printNoDefaultExport(), createClient2(config);
1582
1582
  };
1583
1583
  }
1584
- var name = "@sanity/client", version = "6.20.2-beta.0";
1584
+ var name = "@sanity/client", version = "6.20.2-beta.2";
1585
1585
  const middleware = [
1586
1586
  domainSharder.middleware,
1587
1587
  debug({ verbose: !0, namespace: "sanity:client" }),