@sanity/client 7.23.1 → 7.24.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.browser.cjs +26 -1
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.d.cts +26 -0
- package/dist/index.browser.d.ts +26 -0
- package/dist/index.browser.js +26 -1
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +27 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +26 -0
- package/dist/index.d.ts +26 -0
- package/dist/index.js +27 -2
- package/dist/index.js.map +1 -1
- package/dist/stega.browser.d.cts +26 -0
- package/dist/stega.browser.d.ts +26 -0
- package/dist/stega.d.cts +26 -0
- package/dist/stega.d.ts +26 -0
- package/package.json +2 -2
- package/src/data/dataMethods.ts +40 -0
- package/src/types.ts +26 -0
- package/umd/sanityClient.js +35 -25
- package/umd/sanityClient.min.js +2 -2
package/dist/index.browser.cjs
CHANGED
|
@@ -1126,6 +1126,7 @@ function _dataRequest(client, httpRequest, endpoint, body, options = {}) {
|
|
|
1126
1126
|
tag,
|
|
1127
1127
|
returnQuery,
|
|
1128
1128
|
perspective: options.perspective,
|
|
1129
|
+
variant: options.variant,
|
|
1129
1130
|
resultSourceMap: options.resultSourceMap,
|
|
1130
1131
|
lastLiveEventId: Array.isArray(lastLiveEventId) ? lastLiveEventId[0] : lastLiveEventId,
|
|
1131
1132
|
cacheMode,
|
|
@@ -1173,7 +1174,25 @@ function _requestObservable(client, httpRequest, options) {
|
|
|
1173
1174
|
perspective: Array.isArray(perspectiveOption) ? perspectiveOption.join(",") : perspectiveOption,
|
|
1174
1175
|
...options.query
|
|
1175
1176
|
}, (Array.isArray(perspectiveOption) && perspectiveOption.length > 0 || // previewDrafts was renamed to drafts, but keep for backwards compat
|
|
1176
|
-
perspectiveOption === "previewDrafts" || perspectiveOption === "drafts") && useCdn && (useCdn = !1, printCdnPreviewDraftsWarning()))
|
|
1177
|
+
perspectiveOption === "previewDrafts" || perspectiveOption === "drafts") && useCdn && (useCdn = !1, printCdnPreviewDraftsWarning()));
|
|
1178
|
+
const variantOption = options.variant || config.variant;
|
|
1179
|
+
if (typeof variantOption < "u" && (typeof variantOption == "string" && (options.query = {
|
|
1180
|
+
variant: variantOption,
|
|
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 });
|
|
1177
1196
|
}
|
|
1178
1197
|
const reqOptions = requestOptions(
|
|
1179
1198
|
config,
|
|
@@ -1248,6 +1267,12 @@ const resourceDataBase = (config) => {
|
|
|
1248
1267
|
throw new Error(`Unsupported resource type: ${type.toString()}`);
|
|
1249
1268
|
}
|
|
1250
1269
|
};
|
|
1270
|
+
function variantConditionPairsToSearchParams(variantConditionPairs) {
|
|
1271
|
+
return variantConditionPairs.map(([condition, value]) => [
|
|
1272
|
+
"variantCondition",
|
|
1273
|
+
`${condition}:${value}`
|
|
1274
|
+
]);
|
|
1275
|
+
}
|
|
1251
1276
|
function _generate(client, httpRequest, request) {
|
|
1252
1277
|
const dataset2 = hasDataset(client.config());
|
|
1253
1278
|
return _request(client, httpRequest, {
|