@sanity/client 7.25.0 → 7.26.1

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/README.md CHANGED
@@ -919,7 +919,7 @@ if (stegaClean(post.imageLocation) === 'left') {
919
919
  }
920
920
  ```
921
921
 
922
- Properties that are never stega encoded keep their plain string types: keys starting with `_` (`_id`, `_type`, `_createdAt`, `_updatedAt`, `_key`, `_ref` and friends, so narrowing unions on `_type` keeps working), `slug.current` patterns, and Portable Text properties like `style`, `listItem` and `marks`. Everything else is assumed to be "poisoned", even if the stega `filter` skips it at runtime (URLs, dates and such), as a redundant `stegaClean` is harmless while a missing one is a bug.
922
+ Properties that are never stega encoded keep their plain string types: keys starting with `_` (`_id`, `_type`, `_createdAt`, `_updatedAt`, `_key`, `_ref` and friends, so narrowing unions on `_type` keeps working), `slug.current` patterns, Portable Text properties like `style`, `listItem` and `marks`, and symbol-keyed properties (like TypeGen's `internalGroqTypeReferenceTo` reference marker, which only exists in the type system since JSON can't contain symbol keys). Everything else is assumed to be "poisoned", even if the stega `filter` skips it at runtime (URLs, dates and such), as a redundant `stegaClean` is harmless while a missing one is a bug.
923
923
 
924
924
  If you type your query results manually, brand them with the `StegaBranded` helper type, or re-type already fetched data with the `stegaBrand` identity function:
925
925
 
@@ -1176,23 +1176,13 @@ function _requestObservable(client, httpRequest, options) {
1176
1176
  }, (Array.isArray(perspectiveOption) && perspectiveOption.length > 0 || // previewDrafts was renamed to drafts, but keep for backwards compat
1177
1177
  perspectiveOption === "previewDrafts" || perspectiveOption === "drafts") && useCdn && (useCdn = !1, printCdnPreviewDraftsWarning()));
1178
1178
  const variantOption = options.variant || config.variant;
1179
- if (typeof variantOption < "u" && (typeof variantOption == "string" && (options.query = {
1179
+ typeof variantOption == "string" && (options.query = {
1180
1180
  variant: variantOption,
1181
1181
  ...options.query
1182
- }), typeof variantOption == "object")) {
1183
- const variantConditions = Object.entries(variantOption), searchParams = variantConditionPairsToSearchParams(variantConditions).slice(0, 1);
1184
- if (variantConditions.length > 1) {
1185
- const formatter = new Intl.ListFormat("en");
1186
- console.warn(
1187
- `The Sanity client's beta \`variant\` option currently only supports one condition. Dropped: ${formatter.format(variantConditions.slice(1).map(([subject]) => JSON.stringify(subject)))}.`
1188
- );
1189
- }
1190
- options.query = {
1191
- ...Object.fromEntries(searchParams),
1192
- ...options.query
1193
- };
1194
- }
1195
- 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 });
1182
+ }), typeof variantOption == "object" && (options.query = {
1183
+ variantCondition: variantConditionsToQueryArray(variantOption),
1184
+ ...options.query
1185
+ }), 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 });
1196
1186
  }
1197
1187
  const reqOptions = requestOptions(
1198
1188
  config,
@@ -1267,11 +1257,8 @@ const resourceDataBase = (config) => {
1267
1257
  throw new Error(`Unsupported resource type: ${type.toString()}`);
1268
1258
  }
1269
1259
  };
1270
- function variantConditionPairsToSearchParams(variantConditionPairs) {
1271
- return variantConditionPairs.map(([condition, value]) => [
1272
- "variantCondition",
1273
- `${condition}:${value}`
1274
- ]);
1260
+ function variantConditionsToQueryArray(variantConditions) {
1261
+ return Object.entries(variantConditions).map(([condition, value]) => `${condition}:${value}`).toSorted();
1275
1262
  }
1276
1263
  function _generate(client, httpRequest, request) {
1277
1264
  const dataset2 = hasDataset(client.config());