@sanity/client 6.22.5 → 6.22.6-canary.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 +9 -0
- package/dist/index.browser.d.ts +9 -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 +9 -0
- package/dist/index.d.ts +9 -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 +10 -0
- package/umd/sanityClient.js +3 -2
- package/umd/sanityClient.min.js +1 -1
package/dist/index.browser.d.cts
CHANGED
|
@@ -2102,6 +2102,7 @@ export declare interface RawRequestOptions {
|
|
|
2102
2102
|
proxy?: string
|
|
2103
2103
|
body?: Any
|
|
2104
2104
|
maxRedirects?: number
|
|
2105
|
+
signal?: AbortSignal
|
|
2105
2106
|
}
|
|
2106
2107
|
|
|
2107
2108
|
/**
|
|
@@ -2145,6 +2146,7 @@ export declare interface RequestObservableOptions extends Omit<RequestOptions, '
|
|
|
2145
2146
|
resultSourceMap?: boolean | 'withKeyArraySelector'
|
|
2146
2147
|
perspective?: ClientPerspective
|
|
2147
2148
|
lastLiveEventId?: string
|
|
2149
|
+
cacheMode?: 'noStale'
|
|
2148
2150
|
}
|
|
2149
2151
|
|
|
2150
2152
|
/** @public */
|
|
@@ -2182,6 +2184,13 @@ export declare interface ResponseQueryOptions extends RequestOptions {
|
|
|
2182
2184
|
cache?: 'next' extends keyof RequestInit ? RequestInit['cache'] : never
|
|
2183
2185
|
next?: ('next' extends keyof RequestInit ? RequestInit : never)['next']
|
|
2184
2186
|
lastLiveEventId?: string | string[] | null
|
|
2187
|
+
/**
|
|
2188
|
+
* When set to `noStale`, APICDN will not return a cached response if the content is stale.
|
|
2189
|
+
* Tradeoff between latency and freshness of content.
|
|
2190
|
+
*
|
|
2191
|
+
* Only to be used with live content queries and when useCdn is true.
|
|
2192
|
+
*/
|
|
2193
|
+
cacheMode?: 'noStale'
|
|
2185
2194
|
}
|
|
2186
2195
|
|
|
2187
2196
|
/** @internal */
|
package/dist/index.browser.d.ts
CHANGED
|
@@ -2102,6 +2102,7 @@ export declare interface RawRequestOptions {
|
|
|
2102
2102
|
proxy?: string
|
|
2103
2103
|
body?: Any
|
|
2104
2104
|
maxRedirects?: number
|
|
2105
|
+
signal?: AbortSignal
|
|
2105
2106
|
}
|
|
2106
2107
|
|
|
2107
2108
|
/**
|
|
@@ -2145,6 +2146,7 @@ export declare interface RequestObservableOptions extends Omit<RequestOptions, '
|
|
|
2145
2146
|
resultSourceMap?: boolean | 'withKeyArraySelector'
|
|
2146
2147
|
perspective?: ClientPerspective
|
|
2147
2148
|
lastLiveEventId?: string
|
|
2149
|
+
cacheMode?: 'noStale'
|
|
2148
2150
|
}
|
|
2149
2151
|
|
|
2150
2152
|
/** @public */
|
|
@@ -2182,6 +2184,13 @@ export declare interface ResponseQueryOptions extends RequestOptions {
|
|
|
2182
2184
|
cache?: 'next' extends keyof RequestInit ? RequestInit['cache'] : never
|
|
2183
2185
|
next?: ('next' extends keyof RequestInit ? RequestInit : never)['next']
|
|
2184
2186
|
lastLiveEventId?: string | string[] | null
|
|
2187
|
+
/**
|
|
2188
|
+
* When set to `noStale`, APICDN will not return a cached response if the content is stale.
|
|
2189
|
+
* Tradeoff between latency and freshness of content.
|
|
2190
|
+
*
|
|
2191
|
+
* Only to be used with live content queries and when useCdn is true.
|
|
2192
|
+
*/
|
|
2193
|
+
cacheMode?: 'noStale'
|
|
2185
2194
|
}
|
|
2186
2195
|
|
|
2187
2196
|
/** @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,
|