@sanity/client 7.23.2 → 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 +1 -1
- package/src/data/dataMethods.ts +40 -0
- package/src/types.ts +26 -0
- package/umd/sanityClient.js +26 -1
- package/umd/sanityClient.min.js +2 -2
package/dist/index.cjs
CHANGED
|
@@ -942,6 +942,7 @@ function _dataRequest(client, httpRequest, endpoint, body, options = {}) {
|
|
|
942
942
|
tag,
|
|
943
943
|
returnQuery,
|
|
944
944
|
perspective: options.perspective,
|
|
945
|
+
variant: options.variant,
|
|
945
946
|
resultSourceMap: options.resultSourceMap,
|
|
946
947
|
lastLiveEventId: Array.isArray(lastLiveEventId) ? lastLiveEventId[0] : lastLiveEventId,
|
|
947
948
|
cacheMode,
|
|
@@ -989,7 +990,25 @@ function _requestObservable(client, httpRequest, options) {
|
|
|
989
990
|
perspective: Array.isArray(perspectiveOption) ? perspectiveOption.join(",") : perspectiveOption,
|
|
990
991
|
...options.query
|
|
991
992
|
}, (Array.isArray(perspectiveOption) && perspectiveOption.length > 0 || // previewDrafts was renamed to drafts, but keep for backwards compat
|
|
992
|
-
perspectiveOption === "previewDrafts" || perspectiveOption === "drafts") && useCdn && (useCdn = !1, config.printCdnPreviewDraftsWarning()))
|
|
993
|
+
perspectiveOption === "previewDrafts" || perspectiveOption === "drafts") && useCdn && (useCdn = !1, config.printCdnPreviewDraftsWarning()));
|
|
994
|
+
const variantOption = options.variant || config$1.variant;
|
|
995
|
+
if (typeof variantOption < "u" && (typeof variantOption == "string" && (options.query = {
|
|
996
|
+
variant: variantOption,
|
|
997
|
+
...options.query
|
|
998
|
+
}), typeof variantOption == "object")) {
|
|
999
|
+
const variantConditions = Object.entries(variantOption), searchParams = variantConditionPairsToSearchParams(variantConditions).slice(0, 1);
|
|
1000
|
+
if (variantConditions.length > 1) {
|
|
1001
|
+
const formatter = new Intl.ListFormat("en");
|
|
1002
|
+
console.warn(
|
|
1003
|
+
`The Sanity client's beta \`variant\` option currently only supports one condition. Dropped: ${formatter.format(variantConditions.slice(1).map(([subject]) => JSON.stringify(subject)))}.`
|
|
1004
|
+
);
|
|
1005
|
+
}
|
|
1006
|
+
options.query = {
|
|
1007
|
+
...Object.fromEntries(searchParams),
|
|
1008
|
+
...options.query
|
|
1009
|
+
};
|
|
1010
|
+
}
|
|
1011
|
+
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 });
|
|
993
1012
|
}
|
|
994
1013
|
const reqOptions = requestOptions(
|
|
995
1014
|
config$1,
|
|
@@ -1064,6 +1083,12 @@ const resourceDataBase = (config2) => {
|
|
|
1064
1083
|
throw new Error(`Unsupported resource type: ${type.toString()}`);
|
|
1065
1084
|
}
|
|
1066
1085
|
};
|
|
1086
|
+
function variantConditionPairsToSearchParams(variantConditionPairs) {
|
|
1087
|
+
return variantConditionPairs.map(([condition, value]) => [
|
|
1088
|
+
"variantCondition",
|
|
1089
|
+
`${condition}:${value}`
|
|
1090
|
+
]);
|
|
1091
|
+
}
|
|
1067
1092
|
function _generate(client, httpRequest, request) {
|
|
1068
1093
|
const dataset = config.hasDataset(client.config());
|
|
1069
1094
|
return _request(client, httpRequest, {
|
|
@@ -2868,7 +2893,7 @@ function defineDeprecatedCreateClient(createClient2) {
|
|
|
2868
2893
|
return config.printNoDefaultExport(), createClient2(config$1);
|
|
2869
2894
|
};
|
|
2870
2895
|
}
|
|
2871
|
-
var name = "@sanity/client", version = "7.
|
|
2896
|
+
var name = "@sanity/client", version = "7.24.0";
|
|
2872
2897
|
const middleware = [
|
|
2873
2898
|
middleware$1.debug({ verbose: !0, namespace: "sanity:client" }),
|
|
2874
2899
|
middleware$1.headers({ "User-Agent": `${name} ${version}` }),
|