@sanity/client 7.24.0 → 7.26.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.js CHANGED
@@ -978,23 +978,13 @@ function _requestObservable(client, httpRequest, options) {
978
978
  }, (Array.isArray(perspectiveOption) && perspectiveOption.length > 0 || // previewDrafts was renamed to drafts, but keep for backwards compat
979
979
  perspectiveOption === "previewDrafts" || perspectiveOption === "drafts") && useCdn && (useCdn = !1, printCdnPreviewDraftsWarning()));
980
980
  const variantOption = options.variant || config.variant;
981
- if (typeof variantOption < "u" && (typeof variantOption == "string" && (options.query = {
981
+ typeof variantOption == "string" && (options.query = {
982
982
  variant: variantOption,
983
983
  ...options.query
984
- }), typeof variantOption == "object")) {
985
- const variantConditions = Object.entries(variantOption), searchParams = variantConditionPairsToSearchParams(variantConditions).slice(0, 1);
986
- if (variantConditions.length > 1) {
987
- const formatter = new Intl.ListFormat("en");
988
- console.warn(
989
- `The Sanity client's beta \`variant\` option currently only supports one condition. Dropped: ${formatter.format(variantConditions.slice(1).map(([subject]) => JSON.stringify(subject)))}.`
990
- );
991
- }
992
- options.query = {
993
- ...Object.fromEntries(searchParams),
994
- ...options.query
995
- };
996
- }
997
- options.lastLiveEventId && (options.query = { ...options.query, lastLiveEventId: options.lastLiveEventId }), options.returnQuery === !1 && (options.query = { returnQuery: "false", ...options.query }), useCdn && options.cacheMode == "noStale" && (options.query = { cacheMode: "noStale", ...options.query });
984
+ }), typeof variantOption == "object" && (options.query = {
985
+ variantCondition: variantConditionsToQueryArray(variantOption),
986
+ ...options.query
987
+ }), options.lastLiveEventId && (options.query = { ...options.query, lastLiveEventId: options.lastLiveEventId }), options.returnQuery === !1 && (options.query = { returnQuery: "false", ...options.query }), useCdn && options.cacheMode == "noStale" && (options.query = { cacheMode: "noStale", ...options.query });
998
988
  }
999
989
  const reqOptions = requestOptions(
1000
990
  config,
@@ -1069,11 +1059,8 @@ const resourceDataBase = (config) => {
1069
1059
  throw new Error(`Unsupported resource type: ${type.toString()}`);
1070
1060
  }
1071
1061
  };
1072
- function variantConditionPairsToSearchParams(variantConditionPairs) {
1073
- return variantConditionPairs.map(([condition, value]) => [
1074
- "variantCondition",
1075
- `${condition}:${value}`
1076
- ]);
1062
+ function variantConditionsToQueryArray(variantConditions) {
1063
+ return Object.entries(variantConditions).map(([condition, value]) => `${condition}:${value}`).toSorted();
1077
1064
  }
1078
1065
  function _generate(client, httpRequest, request) {
1079
1066
  const dataset2 = hasDataset(client.config());
@@ -2879,7 +2866,7 @@ function defineDeprecatedCreateClient(createClient2) {
2879
2866
  return printNoDefaultExport(), createClient2(config);
2880
2867
  };
2881
2868
  }
2882
- var name = "@sanity/client", version = "7.24.0";
2869
+ var name = "@sanity/client", version = "7.26.0";
2883
2870
  const middleware = [
2884
2871
  debug({ verbose: !0, namespace: "sanity:client" }),
2885
2872
  headers({ "User-Agent": `${name} ${version}` }),