@sanity/client 6.22.5 → 6.23.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 +3 -2
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.d.cts +11 -0
- package/dist/index.browser.d.ts +11 -0
- package/dist/index.browser.js +3 -2
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +4 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +11 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +4 -3
- package/dist/index.js.map +1 -1
- package/package.json +12 -12
- package/src/data/dataMethods.ts +6 -1
- package/src/types.ts +12 -0
- package/umd/sanityClient.js +3 -2
- package/umd/sanityClient.min.js +1 -1
package/dist/index.browser.d.cts
CHANGED
|
@@ -2061,6 +2061,8 @@ export declare interface QueryParams {
|
|
|
2061
2061
|
useCdn?: never
|
|
2062
2062
|
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2063
2063
|
lastLiveEventId?: never
|
|
2064
|
+
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2065
|
+
cacheMode?: never
|
|
2064
2066
|
}
|
|
2065
2067
|
|
|
2066
2068
|
/**
|
|
@@ -2102,6 +2104,7 @@ export declare interface RawRequestOptions {
|
|
|
2102
2104
|
proxy?: string
|
|
2103
2105
|
body?: Any
|
|
2104
2106
|
maxRedirects?: number
|
|
2107
|
+
signal?: AbortSignal
|
|
2105
2108
|
}
|
|
2106
2109
|
|
|
2107
2110
|
/**
|
|
@@ -2145,6 +2148,7 @@ export declare interface RequestObservableOptions extends Omit<RequestOptions, '
|
|
|
2145
2148
|
resultSourceMap?: boolean | 'withKeyArraySelector'
|
|
2146
2149
|
perspective?: ClientPerspective
|
|
2147
2150
|
lastLiveEventId?: string
|
|
2151
|
+
cacheMode?: 'noStale'
|
|
2148
2152
|
}
|
|
2149
2153
|
|
|
2150
2154
|
/** @public */
|
|
@@ -2182,6 +2186,13 @@ export declare interface ResponseQueryOptions extends RequestOptions {
|
|
|
2182
2186
|
cache?: 'next' extends keyof RequestInit ? RequestInit['cache'] : never
|
|
2183
2187
|
next?: ('next' extends keyof RequestInit ? RequestInit : never)['next']
|
|
2184
2188
|
lastLiveEventId?: string | string[] | null
|
|
2189
|
+
/**
|
|
2190
|
+
* When set to `noStale`, APICDN will not return a cached response if the content is stale.
|
|
2191
|
+
* Tradeoff between latency and freshness of content.
|
|
2192
|
+
*
|
|
2193
|
+
* Only to be used with live content queries and when useCdn is true.
|
|
2194
|
+
*/
|
|
2195
|
+
cacheMode?: 'noStale'
|
|
2185
2196
|
}
|
|
2186
2197
|
|
|
2187
2198
|
/** @internal */
|
package/dist/index.browser.d.ts
CHANGED
|
@@ -2061,6 +2061,8 @@ export declare interface QueryParams {
|
|
|
2061
2061
|
useCdn?: never
|
|
2062
2062
|
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2063
2063
|
lastLiveEventId?: never
|
|
2064
|
+
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2065
|
+
cacheMode?: never
|
|
2064
2066
|
}
|
|
2065
2067
|
|
|
2066
2068
|
/**
|
|
@@ -2102,6 +2104,7 @@ export declare interface RawRequestOptions {
|
|
|
2102
2104
|
proxy?: string
|
|
2103
2105
|
body?: Any
|
|
2104
2106
|
maxRedirects?: number
|
|
2107
|
+
signal?: AbortSignal
|
|
2105
2108
|
}
|
|
2106
2109
|
|
|
2107
2110
|
/**
|
|
@@ -2145,6 +2148,7 @@ export declare interface RequestObservableOptions extends Omit<RequestOptions, '
|
|
|
2145
2148
|
resultSourceMap?: boolean | 'withKeyArraySelector'
|
|
2146
2149
|
perspective?: ClientPerspective
|
|
2147
2150
|
lastLiveEventId?: string
|
|
2151
|
+
cacheMode?: 'noStale'
|
|
2148
2152
|
}
|
|
2149
2153
|
|
|
2150
2154
|
/** @public */
|
|
@@ -2182,6 +2186,13 @@ export declare interface ResponseQueryOptions extends RequestOptions {
|
|
|
2182
2186
|
cache?: 'next' extends keyof RequestInit ? RequestInit['cache'] : never
|
|
2183
2187
|
next?: ('next' extends keyof RequestInit ? RequestInit : never)['next']
|
|
2184
2188
|
lastLiveEventId?: string | string[] | null
|
|
2189
|
+
/**
|
|
2190
|
+
* When set to `noStale`, APICDN will not return a cached response if the content is stale.
|
|
2191
|
+
* Tradeoff between latency and freshness of content.
|
|
2192
|
+
*
|
|
2193
|
+
* Only to be used with live content queries and when useCdn is true.
|
|
2194
|
+
*/
|
|
2195
|
+
cacheMode?: 'noStale'
|
|
2185
2196
|
}
|
|
2186
2197
|
|
|
2187
2198
|
/** @internal */
|
package/dist/index.browser.js
CHANGED
|
@@ -698,7 +698,7 @@ function _action(client, httpRequest, actions, options) {
|
|
|
698
698
|
);
|
|
699
699
|
}
|
|
700
700
|
function _dataRequest(client, httpRequest, endpoint, body, options = {}) {
|
|
701
|
-
const isMutation = endpoint === "mutate", isAction = endpoint === "actions", isQuery = endpoint === "query", strQuery = isMutation || isAction ? "" : encodeQueryString(body), useGet = !isMutation && !isAction && strQuery.length < getQuerySizeLimit, stringQuery = useGet ? strQuery : "", returnFirst = options.returnFirst, { timeout, token, tag, headers, returnQuery, lastLiveEventId } = options, uri = _getDataUrl(client, endpoint, stringQuery), reqOptions = {
|
|
701
|
+
const isMutation = endpoint === "mutate", isAction = endpoint === "actions", isQuery = endpoint === "query", strQuery = isMutation || isAction ? "" : encodeQueryString(body), useGet = !isMutation && !isAction && strQuery.length < getQuerySizeLimit, stringQuery = useGet ? strQuery : "", returnFirst = options.returnFirst, { timeout, token, tag, headers, returnQuery, lastLiveEventId, cacheMode } = options, uri = _getDataUrl(client, endpoint, stringQuery), reqOptions = {
|
|
702
702
|
method: useGet ? "GET" : "POST",
|
|
703
703
|
uri,
|
|
704
704
|
json: !0,
|
|
@@ -712,6 +712,7 @@ function _dataRequest(client, httpRequest, endpoint, body, options = {}) {
|
|
|
712
712
|
perspective: options.perspective,
|
|
713
713
|
resultSourceMap: options.resultSourceMap,
|
|
714
714
|
lastLiveEventId: Array.isArray(lastLiveEventId) ? lastLiveEventId[0] : lastLiveEventId,
|
|
715
|
+
cacheMode,
|
|
715
716
|
canUseCdn: isQuery,
|
|
716
717
|
signal: options.signal,
|
|
717
718
|
fetch: options.fetch,
|
|
@@ -748,7 +749,7 @@ function _requestObservable(client, httpRequest, options) {
|
|
|
748
749
|
const resultSourceMap = options.resultSourceMap ?? config.resultSourceMap;
|
|
749
750
|
resultSourceMap !== void 0 && resultSourceMap !== !1 && (options.query = { resultSourceMap, ...options.query });
|
|
750
751
|
const perspective = options.perspective || config.perspective;
|
|
751
|
-
typeof perspective == "string" && perspective !== "raw" && (validateApiPerspective(perspective), options.query = { perspective, ...options.query }, perspective === "previewDrafts" && useCdn && (useCdn = !1, printCdnPreviewDraftsWarning())), options.lastLiveEventId && (options.query = { ...options.query, lastLiveEventId: options.lastLiveEventId }), options.returnQuery === !1 && (options.query = { returnQuery: "false", ...options.query });
|
|
752
|
+
typeof perspective == "string" && perspective !== "raw" && (validateApiPerspective(perspective), options.query = { perspective, ...options.query }, perspective === "previewDrafts" && useCdn && (useCdn = !1, printCdnPreviewDraftsWarning())), 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 });
|
|
752
753
|
}
|
|
753
754
|
const reqOptions = requestOptions(
|
|
754
755
|
config,
|