@sanity/client 7.23.2 → 7.25.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/README.md +42 -1
- package/dist/_chunks-cjs/stegaClean.cjs.map +1 -1
- package/dist/_chunks-es/stegaClean.js.map +1 -1
- 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.cjs +4 -0
- package/dist/stega.browser.cjs.map +1 -1
- package/dist/stega.browser.d.cts +176 -1
- package/dist/stega.browser.d.ts +176 -1
- package/dist/stega.browser.js +4 -0
- package/dist/stega.browser.js.map +1 -1
- package/dist/stega.cjs +4 -0
- package/dist/stega.cjs.map +1 -1
- package/dist/stega.d.cts +176 -1
- package/dist/stega.d.ts +176 -1
- package/dist/stega.js +4 -0
- package/dist/stega.js.map +1 -1
- package/package.json +2 -1
- package/src/data/dataMethods.ts +40 -0
- package/src/stega/index.ts +2 -1
- package/src/stega/stegaBrand.ts +111 -0
- package/src/stega/stegaClean.ts +23 -2
- package/src/types.ts +26 -0
- package/umd/sanityClient.js +26 -1
- package/umd/sanityClient.min.js +2 -2
package/dist/index.browser.d.cts
CHANGED
|
@@ -725,6 +725,10 @@ export declare interface ClientConfig {
|
|
|
725
725
|
* @defaultValue 'published'
|
|
726
726
|
*/
|
|
727
727
|
perspective?: ClientPerspective
|
|
728
|
+
/**
|
|
729
|
+
* @beta
|
|
730
|
+
*/
|
|
731
|
+
variant?: ClientVariant
|
|
728
732
|
apiHost?: string
|
|
729
733
|
/**
|
|
730
734
|
@remarks
|
|
@@ -888,6 +892,18 @@ export declare type ClientReturn<
|
|
|
888
892
|
Fallback = Any,
|
|
889
893
|
> = GroqString extends keyof SanityQueries ? SanityQueries[GroqString] : Fallback
|
|
890
894
|
|
|
895
|
+
/**
|
|
896
|
+
* @public
|
|
897
|
+
* @beta
|
|
898
|
+
*/
|
|
899
|
+
export declare type ClientVariant = ClientVariantConditions | string
|
|
900
|
+
|
|
901
|
+
/**
|
|
902
|
+
* @public
|
|
903
|
+
* @beta
|
|
904
|
+
*/
|
|
905
|
+
export declare type ClientVariantConditions = Record<string, string>
|
|
906
|
+
|
|
891
907
|
/**
|
|
892
908
|
* Sanity API specific EventSource handler shared between the listen and live APIs
|
|
893
909
|
*
|
|
@@ -4356,6 +4372,8 @@ export declare interface QueryParams {
|
|
|
4356
4372
|
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
4357
4373
|
perspective?: never
|
|
4358
4374
|
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
4375
|
+
variant?: never
|
|
4376
|
+
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
4359
4377
|
query?: never
|
|
4360
4378
|
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
4361
4379
|
resultSourceMap?: never
|
|
@@ -4893,6 +4911,10 @@ export declare interface RequestObservableOptions extends Omit<RequestOptions, '
|
|
|
4893
4911
|
returnQuery?: boolean
|
|
4894
4912
|
resultSourceMap?: boolean | 'withKeyArraySelector'
|
|
4895
4913
|
perspective?: ClientPerspective
|
|
4914
|
+
/**
|
|
4915
|
+
* @beta
|
|
4916
|
+
*/
|
|
4917
|
+
variant?: ClientVariant
|
|
4896
4918
|
lastLiveEventId?: string
|
|
4897
4919
|
cacheMode?: 'noStale'
|
|
4898
4920
|
}
|
|
@@ -4938,6 +4960,10 @@ export declare interface ResponseEvent<T = unknown> {
|
|
|
4938
4960
|
/** @public */
|
|
4939
4961
|
export declare interface ResponseQueryOptions extends RequestOptions {
|
|
4940
4962
|
perspective?: ClientPerspective
|
|
4963
|
+
/**
|
|
4964
|
+
* @beta
|
|
4965
|
+
*/
|
|
4966
|
+
variant?: ClientVariant
|
|
4941
4967
|
resultSourceMap?: boolean | 'withKeyArraySelector'
|
|
4942
4968
|
returnQuery?: boolean
|
|
4943
4969
|
useCdn?: boolean
|
package/dist/index.browser.d.ts
CHANGED
|
@@ -725,6 +725,10 @@ export declare interface ClientConfig {
|
|
|
725
725
|
* @defaultValue 'published'
|
|
726
726
|
*/
|
|
727
727
|
perspective?: ClientPerspective
|
|
728
|
+
/**
|
|
729
|
+
* @beta
|
|
730
|
+
*/
|
|
731
|
+
variant?: ClientVariant
|
|
728
732
|
apiHost?: string
|
|
729
733
|
/**
|
|
730
734
|
@remarks
|
|
@@ -888,6 +892,18 @@ export declare type ClientReturn<
|
|
|
888
892
|
Fallback = Any,
|
|
889
893
|
> = GroqString extends keyof SanityQueries ? SanityQueries[GroqString] : Fallback
|
|
890
894
|
|
|
895
|
+
/**
|
|
896
|
+
* @public
|
|
897
|
+
* @beta
|
|
898
|
+
*/
|
|
899
|
+
export declare type ClientVariant = ClientVariantConditions | string
|
|
900
|
+
|
|
901
|
+
/**
|
|
902
|
+
* @public
|
|
903
|
+
* @beta
|
|
904
|
+
*/
|
|
905
|
+
export declare type ClientVariantConditions = Record<string, string>
|
|
906
|
+
|
|
891
907
|
/**
|
|
892
908
|
* Sanity API specific EventSource handler shared between the listen and live APIs
|
|
893
909
|
*
|
|
@@ -4356,6 +4372,8 @@ export declare interface QueryParams {
|
|
|
4356
4372
|
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
4357
4373
|
perspective?: never
|
|
4358
4374
|
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
4375
|
+
variant?: never
|
|
4376
|
+
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
4359
4377
|
query?: never
|
|
4360
4378
|
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
4361
4379
|
resultSourceMap?: never
|
|
@@ -4893,6 +4911,10 @@ export declare interface RequestObservableOptions extends Omit<RequestOptions, '
|
|
|
4893
4911
|
returnQuery?: boolean
|
|
4894
4912
|
resultSourceMap?: boolean | 'withKeyArraySelector'
|
|
4895
4913
|
perspective?: ClientPerspective
|
|
4914
|
+
/**
|
|
4915
|
+
* @beta
|
|
4916
|
+
*/
|
|
4917
|
+
variant?: ClientVariant
|
|
4896
4918
|
lastLiveEventId?: string
|
|
4897
4919
|
cacheMode?: 'noStale'
|
|
4898
4920
|
}
|
|
@@ -4938,6 +4960,10 @@ export declare interface ResponseEvent<T = unknown> {
|
|
|
4938
4960
|
/** @public */
|
|
4939
4961
|
export declare interface ResponseQueryOptions extends RequestOptions {
|
|
4940
4962
|
perspective?: ClientPerspective
|
|
4963
|
+
/**
|
|
4964
|
+
* @beta
|
|
4965
|
+
*/
|
|
4966
|
+
variant?: ClientVariant
|
|
4941
4967
|
resultSourceMap?: boolean | 'withKeyArraySelector'
|
|
4942
4968
|
returnQuery?: boolean
|
|
4943
4969
|
useCdn?: boolean
|
package/dist/index.browser.js
CHANGED
|
@@ -1110,6 +1110,7 @@ function _dataRequest(client, httpRequest, endpoint, body, options = {}) {
|
|
|
1110
1110
|
tag,
|
|
1111
1111
|
returnQuery,
|
|
1112
1112
|
perspective: options.perspective,
|
|
1113
|
+
variant: options.variant,
|
|
1113
1114
|
resultSourceMap: options.resultSourceMap,
|
|
1114
1115
|
lastLiveEventId: Array.isArray(lastLiveEventId) ? lastLiveEventId[0] : lastLiveEventId,
|
|
1115
1116
|
cacheMode,
|
|
@@ -1157,7 +1158,25 @@ function _requestObservable(client, httpRequest, options) {
|
|
|
1157
1158
|
perspective: Array.isArray(perspectiveOption) ? perspectiveOption.join(",") : perspectiveOption,
|
|
1158
1159
|
...options.query
|
|
1159
1160
|
}, (Array.isArray(perspectiveOption) && perspectiveOption.length > 0 || // previewDrafts was renamed to drafts, but keep for backwards compat
|
|
1160
|
-
perspectiveOption === "previewDrafts" || perspectiveOption === "drafts") && useCdn && (useCdn = !1, printCdnPreviewDraftsWarning()))
|
|
1161
|
+
perspectiveOption === "previewDrafts" || perspectiveOption === "drafts") && useCdn && (useCdn = !1, printCdnPreviewDraftsWarning()));
|
|
1162
|
+
const variantOption = options.variant || config.variant;
|
|
1163
|
+
if (typeof variantOption < "u" && (typeof variantOption == "string" && (options.query = {
|
|
1164
|
+
variant: variantOption,
|
|
1165
|
+
...options.query
|
|
1166
|
+
}), typeof variantOption == "object")) {
|
|
1167
|
+
const variantConditions = Object.entries(variantOption), searchParams = variantConditionPairsToSearchParams(variantConditions).slice(0, 1);
|
|
1168
|
+
if (variantConditions.length > 1) {
|
|
1169
|
+
const formatter = new Intl.ListFormat("en");
|
|
1170
|
+
console.warn(
|
|
1171
|
+
`The Sanity client's beta \`variant\` option currently only supports one condition. Dropped: ${formatter.format(variantConditions.slice(1).map(([subject]) => JSON.stringify(subject)))}.`
|
|
1172
|
+
);
|
|
1173
|
+
}
|
|
1174
|
+
options.query = {
|
|
1175
|
+
...Object.fromEntries(searchParams),
|
|
1176
|
+
...options.query
|
|
1177
|
+
};
|
|
1178
|
+
}
|
|
1179
|
+
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 });
|
|
1161
1180
|
}
|
|
1162
1181
|
const reqOptions = requestOptions(
|
|
1163
1182
|
config,
|
|
@@ -1232,6 +1251,12 @@ const resourceDataBase = (config) => {
|
|
|
1232
1251
|
throw new Error(`Unsupported resource type: ${type.toString()}`);
|
|
1233
1252
|
}
|
|
1234
1253
|
};
|
|
1254
|
+
function variantConditionPairsToSearchParams(variantConditionPairs) {
|
|
1255
|
+
return variantConditionPairs.map(([condition, value]) => [
|
|
1256
|
+
"variantCondition",
|
|
1257
|
+
`${condition}:${value}`
|
|
1258
|
+
]);
|
|
1259
|
+
}
|
|
1235
1260
|
function _generate(client, httpRequest, request) {
|
|
1236
1261
|
const dataset2 = hasDataset(client.config());
|
|
1237
1262
|
return _request(client, httpRequest, {
|