@sanity/client 6.22.1-bundle-perspective → 6.22.2-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/_chunks-cjs/resolveEditInfo.cjs +2 -1
- package/dist/_chunks-cjs/resolveEditInfo.cjs.map +1 -1
- package/dist/_chunks-cjs/stegaClean.cjs +2 -1
- package/dist/_chunks-cjs/stegaClean.cjs.map +1 -1
- package/dist/_chunks-cjs/stegaEncodeSourceMap.cjs +2 -1
- package/dist/_chunks-cjs/stegaEncodeSourceMap.cjs.map +1 -1
- package/dist/_chunks-es/resolveEditInfo.js +2 -1
- package/dist/_chunks-es/resolveEditInfo.js.map +1 -1
- package/dist/_chunks-es/stegaClean.js +2 -1
- package/dist/_chunks-es/stegaClean.js.map +1 -1
- package/dist/_chunks-es/stegaEncodeSourceMap.js +2 -1
- package/dist/_chunks-es/stegaEncodeSourceMap.js.map +1 -1
- package/dist/csm.cjs +2 -1
- package/dist/csm.cjs.map +1 -1
- package/dist/csm.js +2 -1
- package/dist/csm.js.map +1 -1
- package/dist/index.browser.cjs +10 -10
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.d.cts +13 -7
- package/dist/index.browser.d.ts +13 -7
- package/dist/index.browser.js +10 -10
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +11 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +13 -7
- package/dist/index.d.ts +13 -7
- package/dist/index.js +11 -11
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/data/dataMethods.ts +0 -9
- package/src/data/live.ts +16 -7
- package/src/types.ts +10 -6
- package/umd/sanityClient.js +16 -15
- package/umd/sanityClient.min.js +2 -2
package/dist/index.browser.d.cts
CHANGED
|
@@ -331,7 +331,6 @@ export declare interface ClientConfig {
|
|
|
331
331
|
token?: string
|
|
332
332
|
/** @defaultValue 'raw' */
|
|
333
333
|
perspective?: ClientPerspective
|
|
334
|
-
bundlePerspective?: string
|
|
335
334
|
apiHost?: string
|
|
336
335
|
apiVersion?: string
|
|
337
336
|
proxy?: string
|
|
@@ -923,7 +922,7 @@ export declare class LiveClient {
|
|
|
923
922
|
}?: {
|
|
924
923
|
/** @alpha this API is experimental and may change or even be removed */
|
|
925
924
|
includeDrafts?: boolean
|
|
926
|
-
}): Observable<LiveEventMessage | LiveEventRestart>
|
|
925
|
+
}): Observable<LiveEventMessage | LiveEventRestart | LiveEventReconnect | LiveEventWelcome>
|
|
927
926
|
}
|
|
928
927
|
|
|
929
928
|
/** @public */
|
|
@@ -933,9 +932,20 @@ export declare interface LiveEventMessage {
|
|
|
933
932
|
tags: SyncTag[]
|
|
934
933
|
}
|
|
935
934
|
|
|
935
|
+
/** @public */
|
|
936
|
+
export declare interface LiveEventReconnect {
|
|
937
|
+
type: 'reconnect'
|
|
938
|
+
}
|
|
939
|
+
|
|
936
940
|
/** @public */
|
|
937
941
|
export declare interface LiveEventRestart {
|
|
938
942
|
type: 'restart'
|
|
943
|
+
id: string
|
|
944
|
+
}
|
|
945
|
+
|
|
946
|
+
/** @public */
|
|
947
|
+
export declare interface LiveEventWelcome {
|
|
948
|
+
type: 'welcome'
|
|
939
949
|
}
|
|
940
950
|
|
|
941
951
|
/** @public */
|
|
@@ -2018,8 +2028,6 @@ export declare interface QueryParams {
|
|
|
2018
2028
|
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2019
2029
|
perspective?: never
|
|
2020
2030
|
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2021
|
-
bundlePerspective?: never
|
|
2022
|
-
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2023
2031
|
query?: never
|
|
2024
2032
|
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2025
2033
|
resultSourceMap?: never
|
|
@@ -2122,7 +2130,6 @@ export declare interface RequestObservableOptions extends Omit<RequestOptions, '
|
|
|
2122
2130
|
returnQuery?: boolean
|
|
2123
2131
|
resultSourceMap?: boolean | 'withKeyArraySelector'
|
|
2124
2132
|
perspective?: ClientPerspective
|
|
2125
|
-
bundlePerspective?: string
|
|
2126
2133
|
lastLiveEventId?: string
|
|
2127
2134
|
}
|
|
2128
2135
|
|
|
@@ -2154,7 +2161,6 @@ export declare interface ResponseEvent<T = unknown> {
|
|
|
2154
2161
|
/** @public */
|
|
2155
2162
|
export declare interface ResponseQueryOptions extends RequestOptions {
|
|
2156
2163
|
perspective?: ClientPerspective
|
|
2157
|
-
bundlePerspective?: string
|
|
2158
2164
|
resultSourceMap?: boolean | 'withKeyArraySelector'
|
|
2159
2165
|
returnQuery?: boolean
|
|
2160
2166
|
useCdn?: boolean
|
|
@@ -2711,7 +2717,7 @@ export declare type SanityDocument<T extends Record<string, Any> = Record<string
|
|
|
2711
2717
|
_createdAt: string
|
|
2712
2718
|
_updatedAt: string
|
|
2713
2719
|
/**
|
|
2714
|
-
* Present when `perspective` is set to `previewDrafts`
|
|
2720
|
+
* Present when `perspective` is set to `previewDrafts`
|
|
2715
2721
|
*/
|
|
2716
2722
|
_originalId?: string
|
|
2717
2723
|
}
|
package/dist/index.browser.d.ts
CHANGED
|
@@ -331,7 +331,6 @@ export declare interface ClientConfig {
|
|
|
331
331
|
token?: string
|
|
332
332
|
/** @defaultValue 'raw' */
|
|
333
333
|
perspective?: ClientPerspective
|
|
334
|
-
bundlePerspective?: string
|
|
335
334
|
apiHost?: string
|
|
336
335
|
apiVersion?: string
|
|
337
336
|
proxy?: string
|
|
@@ -923,7 +922,7 @@ export declare class LiveClient {
|
|
|
923
922
|
}?: {
|
|
924
923
|
/** @alpha this API is experimental and may change or even be removed */
|
|
925
924
|
includeDrafts?: boolean
|
|
926
|
-
}): Observable<LiveEventMessage | LiveEventRestart>
|
|
925
|
+
}): Observable<LiveEventMessage | LiveEventRestart | LiveEventReconnect | LiveEventWelcome>
|
|
927
926
|
}
|
|
928
927
|
|
|
929
928
|
/** @public */
|
|
@@ -933,9 +932,20 @@ export declare interface LiveEventMessage {
|
|
|
933
932
|
tags: SyncTag[]
|
|
934
933
|
}
|
|
935
934
|
|
|
935
|
+
/** @public */
|
|
936
|
+
export declare interface LiveEventReconnect {
|
|
937
|
+
type: 'reconnect'
|
|
938
|
+
}
|
|
939
|
+
|
|
936
940
|
/** @public */
|
|
937
941
|
export declare interface LiveEventRestart {
|
|
938
942
|
type: 'restart'
|
|
943
|
+
id: string
|
|
944
|
+
}
|
|
945
|
+
|
|
946
|
+
/** @public */
|
|
947
|
+
export declare interface LiveEventWelcome {
|
|
948
|
+
type: 'welcome'
|
|
939
949
|
}
|
|
940
950
|
|
|
941
951
|
/** @public */
|
|
@@ -2018,8 +2028,6 @@ export declare interface QueryParams {
|
|
|
2018
2028
|
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2019
2029
|
perspective?: never
|
|
2020
2030
|
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2021
|
-
bundlePerspective?: never
|
|
2022
|
-
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2023
2031
|
query?: never
|
|
2024
2032
|
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2025
2033
|
resultSourceMap?: never
|
|
@@ -2122,7 +2130,6 @@ export declare interface RequestObservableOptions extends Omit<RequestOptions, '
|
|
|
2122
2130
|
returnQuery?: boolean
|
|
2123
2131
|
resultSourceMap?: boolean | 'withKeyArraySelector'
|
|
2124
2132
|
perspective?: ClientPerspective
|
|
2125
|
-
bundlePerspective?: string
|
|
2126
2133
|
lastLiveEventId?: string
|
|
2127
2134
|
}
|
|
2128
2135
|
|
|
@@ -2154,7 +2161,6 @@ export declare interface ResponseEvent<T = unknown> {
|
|
|
2154
2161
|
/** @public */
|
|
2155
2162
|
export declare interface ResponseQueryOptions extends RequestOptions {
|
|
2156
2163
|
perspective?: ClientPerspective
|
|
2157
|
-
bundlePerspective?: string
|
|
2158
2164
|
resultSourceMap?: boolean | 'withKeyArraySelector'
|
|
2159
2165
|
returnQuery?: boolean
|
|
2160
2166
|
useCdn?: boolean
|
|
@@ -2711,7 +2717,7 @@ export declare type SanityDocument<T extends Record<string, Any> = Record<string
|
|
|
2711
2717
|
_createdAt: string
|
|
2712
2718
|
_updatedAt: string
|
|
2713
2719
|
/**
|
|
2714
|
-
* Present when `perspective` is set to `previewDrafts`
|
|
2720
|
+
* Present when `perspective` is set to `previewDrafts`
|
|
2715
2721
|
*/
|
|
2716
2722
|
_originalId?: string
|
|
2717
2723
|
}
|
package/dist/index.browser.js
CHANGED
|
@@ -87,7 +87,8 @@ function defineHttpRequest(envMiddleware2) {
|
|
|
87
87
|
]);
|
|
88
88
|
}
|
|
89
89
|
function shouldRetry(err, attempt, options) {
|
|
90
|
-
if (options.maxRetries === 0)
|
|
90
|
+
if (options.maxRetries === 0)
|
|
91
|
+
return !1;
|
|
91
92
|
const isSafe = options.method === "GET" || options.method === "HEAD", isQuery = (options.uri || options.url).startsWith("/data/query"), isRetriableResponse = err.response && (err.response.statusCode === 429 || err.response.statusCode === 502 || err.response.statusCode === 503);
|
|
92
93
|
return (isSafe || isQuery) && isRetriableResponse ? !0 : retry.shouldRetry(err, attempt, options);
|
|
93
94
|
}
|
|
@@ -696,7 +697,6 @@ function _dataRequest(client, httpRequest, endpoint, body, options = {}) {
|
|
|
696
697
|
tag,
|
|
697
698
|
returnQuery,
|
|
698
699
|
perspective: options.perspective,
|
|
699
|
-
bundlePerspective: options.bundlePerspective,
|
|
700
700
|
resultSourceMap: options.resultSourceMap,
|
|
701
701
|
lastLiveEventId: Array.isArray(lastLiveEventId) ? lastLiveEventId[0] : lastLiveEventId,
|
|
702
702
|
canUseCdn: isQuery,
|
|
@@ -734,8 +734,8 @@ function _requestObservable(client, httpRequest, options) {
|
|
|
734
734
|
if (tag && options.tag !== null && (options.query = { tag: requestTag(tag), ...options.query }), ["GET", "HEAD", "POST"].indexOf(options.method || "GET") >= 0 && uri.indexOf("/data/query/") === 0) {
|
|
735
735
|
const resultSourceMap = options.resultSourceMap ?? config.resultSourceMap;
|
|
736
736
|
resultSourceMap !== void 0 && resultSourceMap !== !1 && (options.query = { resultSourceMap, ...options.query });
|
|
737
|
-
const perspective = options.perspective || config.perspective
|
|
738
|
-
typeof perspective == "string" && perspective !== "raw" && (validateApiPerspective(perspective), options.query = { perspective, ...options.query }, perspective === "previewDrafts" && useCdn && (useCdn = !1, printCdnPreviewDraftsWarning())),
|
|
737
|
+
const perspective = options.perspective || config.perspective;
|
|
738
|
+
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 });
|
|
739
739
|
}
|
|
740
740
|
const reqOptions = requestOptions(
|
|
741
741
|
config,
|
|
@@ -929,14 +929,14 @@ class LiveClient {
|
|
|
929
929
|
events({
|
|
930
930
|
includeDrafts = !1
|
|
931
931
|
} = {}) {
|
|
932
|
-
const { apiVersion: _apiVersion, token } = this.#client.config(), apiVersion = _apiVersion.replace(/^v/, "");
|
|
932
|
+
const { apiVersion: _apiVersion, token, withCredentials } = this.#client.config(), apiVersion = _apiVersion.replace(/^v/, "");
|
|
933
933
|
if (apiVersion !== "X" && apiVersion < requiredApiVersion)
|
|
934
934
|
throw new Error(
|
|
935
935
|
`The live events API requires API version ${requiredApiVersion} or later. The current API version is ${apiVersion}. Please update your API version to use this feature.`
|
|
936
936
|
);
|
|
937
|
-
if (includeDrafts && !token)
|
|
937
|
+
if (includeDrafts && !token && !withCredentials)
|
|
938
938
|
throw new Error(
|
|
939
|
-
"The live events API requires a token when 'includeDrafts: true'. Please update your client configuration. The token should have the lowest possible access role."
|
|
939
|
+
"The live events API requires a token or withCredentials when 'includeDrafts: true'. Please update your client configuration. The token should have the lowest possible access role."
|
|
940
940
|
);
|
|
941
941
|
if (includeDrafts && apiVersion !== "X")
|
|
942
942
|
throw new Error(
|
|
@@ -944,10 +944,10 @@ class LiveClient {
|
|
|
944
944
|
);
|
|
945
945
|
const path = _getDataUrl(this.#client, "live/events"), url = new URL(this.#client.getUrl(path, !1));
|
|
946
946
|
includeDrafts && url.searchParams.set("includeDrafts", "true");
|
|
947
|
-
const listenFor = ["restart", "message"], esOptions = {};
|
|
947
|
+
const listenFor = ["restart", "message", "welcome", "reconnect"], esOptions = {};
|
|
948
948
|
return includeDrafts && token && (esOptions.headers = {
|
|
949
949
|
Authorization: `Bearer ${token}`
|
|
950
|
-
}), new Observable((observer) => {
|
|
950
|
+
}), includeDrafts && withCredentials && (esOptions.withCredentials = !0), new Observable((observer) => {
|
|
951
951
|
let es, reconnectTimer, stopped = !1, unsubscribed = !1;
|
|
952
952
|
open();
|
|
953
953
|
function onError(evt) {
|
|
@@ -972,7 +972,7 @@ class LiveClient {
|
|
|
972
972
|
}
|
|
973
973
|
}
|
|
974
974
|
async function getEventSource() {
|
|
975
|
-
const EventSourceImplementation = typeof EventSource > "u" || esOptions.headers ? (await import("@sanity/eventsource")).default : EventSource;
|
|
975
|
+
const EventSourceImplementation = typeof EventSource > "u" || esOptions.headers || esOptions.withCredentials ? (await import("@sanity/eventsource")).default : EventSource;
|
|
976
976
|
if (unsubscribed)
|
|
977
977
|
return;
|
|
978
978
|
const evs = new EventSourceImplementation(url.toString(), esOptions);
|