@sanity/client 6.19.0 → 6.20.0-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 +11 -1
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.d.cts +12 -15
- package/dist/index.browser.d.ts +12 -15
- package/dist/index.browser.js +11 -1
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +12 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +12 -15
- package/dist/index.d.ts +12 -15
- package/dist/index.js +12 -2
- package/dist/index.js.map +1 -1
- package/package.json +8 -8
- package/src/data/live.ts +14 -1
- package/src/types.ts +8 -15
- package/umd/sanityClient.js +11 -1
- package/umd/sanityClient.min.js +2 -2
package/dist/index.browser.d.cts
CHANGED
|
@@ -598,7 +598,7 @@ export declare type DeleteAction = {
|
|
|
598
598
|
/**
|
|
599
599
|
* Delete document history
|
|
600
600
|
*/
|
|
601
|
-
purge
|
|
601
|
+
purge?: boolean
|
|
602
602
|
}
|
|
603
603
|
|
|
604
604
|
/**
|
|
@@ -623,7 +623,7 @@ export declare type DiscardAction = {
|
|
|
623
623
|
/**
|
|
624
624
|
* Delete document history
|
|
625
625
|
*/
|
|
626
|
-
purge
|
|
626
|
+
purge?: boolean
|
|
627
627
|
}
|
|
628
628
|
|
|
629
629
|
/**
|
|
@@ -899,22 +899,25 @@ export declare type ListenParams = {
|
|
|
899
899
|
}
|
|
900
900
|
|
|
901
901
|
/**
|
|
902
|
-
* @
|
|
902
|
+
* @public
|
|
903
903
|
*/
|
|
904
904
|
export declare class LiveClient {
|
|
905
905
|
#private
|
|
906
906
|
constructor(client: SanityClient | ObservableSanityClient)
|
|
907
|
+
/**
|
|
908
|
+
* Requires `apiVersion` to be `2021-03-26` or later.
|
|
909
|
+
*/
|
|
907
910
|
events(): Observable<LiveEventMessage | LiveEventRestart>
|
|
908
911
|
}
|
|
909
912
|
|
|
910
|
-
/** @
|
|
913
|
+
/** @public */
|
|
911
914
|
export declare interface LiveEventMessage {
|
|
912
915
|
type: 'message'
|
|
913
916
|
id: string
|
|
914
917
|
tags: SyncTag[]
|
|
915
918
|
}
|
|
916
919
|
|
|
917
|
-
/** @
|
|
920
|
+
/** @public */
|
|
918
921
|
export declare interface LiveEventRestart {
|
|
919
922
|
type: 'restart'
|
|
920
923
|
}
|
|
@@ -1951,7 +1954,7 @@ export declare type PublishAction = {
|
|
|
1951
1954
|
/**
|
|
1952
1955
|
* Draft revision ID to match
|
|
1953
1956
|
*/
|
|
1954
|
-
ifDraftRevisionId
|
|
1957
|
+
ifDraftRevisionId?: string
|
|
1955
1958
|
/**
|
|
1956
1959
|
* Published document ID to replace
|
|
1957
1960
|
*/
|
|
@@ -1959,7 +1962,7 @@ export declare type PublishAction = {
|
|
|
1959
1962
|
/**
|
|
1960
1963
|
* Published revision ID to match
|
|
1961
1964
|
*/
|
|
1962
|
-
ifPublishedRevisionId
|
|
1965
|
+
ifPublishedRevisionId?: string
|
|
1963
1966
|
}
|
|
1964
1967
|
|
|
1965
1968
|
/** @public */
|
|
@@ -2022,7 +2025,7 @@ export declare interface RawQueryResponse<R> {
|
|
|
2022
2025
|
ms: number
|
|
2023
2026
|
result: R
|
|
2024
2027
|
resultSourceMap?: ContentSourceMap
|
|
2025
|
-
/**
|
|
2028
|
+
/** Requires `apiVersion` to be `2021-03-26` or later. */
|
|
2026
2029
|
syncTags?: SyncTag[]
|
|
2027
2030
|
}
|
|
2028
2031
|
|
|
@@ -2065,10 +2068,6 @@ export declare type ReconnectEvent = {
|
|
|
2065
2068
|
*/
|
|
2066
2069
|
export declare type ReplaceDraftAction = {
|
|
2067
2070
|
actionType: 'sanity.action.document.replaceDraft'
|
|
2068
|
-
/**
|
|
2069
|
-
* Draft document ID to replace, if it exists.
|
|
2070
|
-
*/
|
|
2071
|
-
draftId: string
|
|
2072
2071
|
/**
|
|
2073
2072
|
* Published document ID to create draft from, if draft does not exist
|
|
2074
2073
|
*/
|
|
@@ -2092,7 +2091,6 @@ export declare interface RequestObservableOptions extends Omit<RequestOptions, '
|
|
|
2092
2091
|
returnQuery?: boolean
|
|
2093
2092
|
resultSourceMap?: boolean | 'withKeyArraySelector'
|
|
2094
2093
|
perspective?: ClientPerspective
|
|
2095
|
-
/** @alpha this API is experimental and may change or even be removed */
|
|
2096
2094
|
lastLiveEventId?: string
|
|
2097
2095
|
}
|
|
2098
2096
|
|
|
@@ -2130,7 +2128,6 @@ export declare interface ResponseQueryOptions extends RequestOptions {
|
|
|
2130
2128
|
stega?: boolean | StegaConfig
|
|
2131
2129
|
cache?: 'next' extends keyof RequestInit ? RequestInit['cache'] : never
|
|
2132
2130
|
next?: ('next' extends keyof RequestInit ? RequestInit : never)['next']
|
|
2133
|
-
/** @alpha this API is experimental and may change or even be removed */
|
|
2134
2131
|
lastLiveEventId?: string | string[] | null
|
|
2135
2132
|
}
|
|
2136
2133
|
|
|
@@ -2831,7 +2828,7 @@ export {StudioBaseUrl}
|
|
|
2831
2828
|
|
|
2832
2829
|
export {StudioUrl}
|
|
2833
2830
|
|
|
2834
|
-
/** @
|
|
2831
|
+
/** @public */
|
|
2835
2832
|
export declare type SyncTag = `s1:${string}`
|
|
2836
2833
|
|
|
2837
2834
|
/** @public */
|
package/dist/index.browser.d.ts
CHANGED
|
@@ -598,7 +598,7 @@ export declare type DeleteAction = {
|
|
|
598
598
|
/**
|
|
599
599
|
* Delete document history
|
|
600
600
|
*/
|
|
601
|
-
purge
|
|
601
|
+
purge?: boolean
|
|
602
602
|
}
|
|
603
603
|
|
|
604
604
|
/**
|
|
@@ -623,7 +623,7 @@ export declare type DiscardAction = {
|
|
|
623
623
|
/**
|
|
624
624
|
* Delete document history
|
|
625
625
|
*/
|
|
626
|
-
purge
|
|
626
|
+
purge?: boolean
|
|
627
627
|
}
|
|
628
628
|
|
|
629
629
|
/**
|
|
@@ -899,22 +899,25 @@ export declare type ListenParams = {
|
|
|
899
899
|
}
|
|
900
900
|
|
|
901
901
|
/**
|
|
902
|
-
* @
|
|
902
|
+
* @public
|
|
903
903
|
*/
|
|
904
904
|
export declare class LiveClient {
|
|
905
905
|
#private
|
|
906
906
|
constructor(client: SanityClient | ObservableSanityClient)
|
|
907
|
+
/**
|
|
908
|
+
* Requires `apiVersion` to be `2021-03-26` or later.
|
|
909
|
+
*/
|
|
907
910
|
events(): Observable<LiveEventMessage | LiveEventRestart>
|
|
908
911
|
}
|
|
909
912
|
|
|
910
|
-
/** @
|
|
913
|
+
/** @public */
|
|
911
914
|
export declare interface LiveEventMessage {
|
|
912
915
|
type: 'message'
|
|
913
916
|
id: string
|
|
914
917
|
tags: SyncTag[]
|
|
915
918
|
}
|
|
916
919
|
|
|
917
|
-
/** @
|
|
920
|
+
/** @public */
|
|
918
921
|
export declare interface LiveEventRestart {
|
|
919
922
|
type: 'restart'
|
|
920
923
|
}
|
|
@@ -1951,7 +1954,7 @@ export declare type PublishAction = {
|
|
|
1951
1954
|
/**
|
|
1952
1955
|
* Draft revision ID to match
|
|
1953
1956
|
*/
|
|
1954
|
-
ifDraftRevisionId
|
|
1957
|
+
ifDraftRevisionId?: string
|
|
1955
1958
|
/**
|
|
1956
1959
|
* Published document ID to replace
|
|
1957
1960
|
*/
|
|
@@ -1959,7 +1962,7 @@ export declare type PublishAction = {
|
|
|
1959
1962
|
/**
|
|
1960
1963
|
* Published revision ID to match
|
|
1961
1964
|
*/
|
|
1962
|
-
ifPublishedRevisionId
|
|
1965
|
+
ifPublishedRevisionId?: string
|
|
1963
1966
|
}
|
|
1964
1967
|
|
|
1965
1968
|
/** @public */
|
|
@@ -2022,7 +2025,7 @@ export declare interface RawQueryResponse<R> {
|
|
|
2022
2025
|
ms: number
|
|
2023
2026
|
result: R
|
|
2024
2027
|
resultSourceMap?: ContentSourceMap
|
|
2025
|
-
/**
|
|
2028
|
+
/** Requires `apiVersion` to be `2021-03-26` or later. */
|
|
2026
2029
|
syncTags?: SyncTag[]
|
|
2027
2030
|
}
|
|
2028
2031
|
|
|
@@ -2065,10 +2068,6 @@ export declare type ReconnectEvent = {
|
|
|
2065
2068
|
*/
|
|
2066
2069
|
export declare type ReplaceDraftAction = {
|
|
2067
2070
|
actionType: 'sanity.action.document.replaceDraft'
|
|
2068
|
-
/**
|
|
2069
|
-
* Draft document ID to replace, if it exists.
|
|
2070
|
-
*/
|
|
2071
|
-
draftId: string
|
|
2072
2071
|
/**
|
|
2073
2072
|
* Published document ID to create draft from, if draft does not exist
|
|
2074
2073
|
*/
|
|
@@ -2092,7 +2091,6 @@ export declare interface RequestObservableOptions extends Omit<RequestOptions, '
|
|
|
2092
2091
|
returnQuery?: boolean
|
|
2093
2092
|
resultSourceMap?: boolean | 'withKeyArraySelector'
|
|
2094
2093
|
perspective?: ClientPerspective
|
|
2095
|
-
/** @alpha this API is experimental and may change or even be removed */
|
|
2096
2094
|
lastLiveEventId?: string
|
|
2097
2095
|
}
|
|
2098
2096
|
|
|
@@ -2130,7 +2128,6 @@ export declare interface ResponseQueryOptions extends RequestOptions {
|
|
|
2130
2128
|
stega?: boolean | StegaConfig
|
|
2131
2129
|
cache?: 'next' extends keyof RequestInit ? RequestInit['cache'] : never
|
|
2132
2130
|
next?: ('next' extends keyof RequestInit ? RequestInit : never)['next']
|
|
2133
|
-
/** @alpha this API is experimental and may change or even be removed */
|
|
2134
2131
|
lastLiveEventId?: string | string[] | null
|
|
2135
2132
|
}
|
|
2136
2133
|
|
|
@@ -2831,7 +2828,7 @@ export {StudioBaseUrl}
|
|
|
2831
2828
|
|
|
2832
2829
|
export {StudioUrl}
|
|
2833
2830
|
|
|
2834
|
-
/** @
|
|
2831
|
+
/** @public */
|
|
2835
2832
|
export declare type SyncTag = `s1:${string}`
|
|
2836
2833
|
|
|
2837
2834
|
/** @public */
|
package/dist/index.browser.js
CHANGED
|
@@ -935,12 +935,22 @@ var __accessCheck$4 = (obj, member, msg) => {
|
|
|
935
935
|
if (member.has(obj))
|
|
936
936
|
throw TypeError("Cannot add the same private member more than once");
|
|
937
937
|
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
938
|
-
}, __privateSet$4 = (obj, member, value, setter) => (__accessCheck$4(obj, member, "write to private field"), member.set(obj, value), value)
|
|
938
|
+
}, __privateSet$4 = (obj, member, value, setter) => (__accessCheck$4(obj, member, "write to private field"), member.set(obj, value), value);
|
|
939
|
+
const requiredApiVersion = "2021-03-26";
|
|
940
|
+
var _client$3;
|
|
939
941
|
class LiveClient {
|
|
940
942
|
constructor(client) {
|
|
941
943
|
__privateAdd$4(this, _client$3, void 0), __privateSet$4(this, _client$3, client);
|
|
942
944
|
}
|
|
945
|
+
/**
|
|
946
|
+
* Requires `apiVersion` to be `2021-03-26` or later.
|
|
947
|
+
*/
|
|
943
948
|
events() {
|
|
949
|
+
const apiVersion = __privateGet$4(this, _client$3).config().apiVersion.replace(/^v/, "");
|
|
950
|
+
if (apiVersion !== "X" && apiVersion < requiredApiVersion)
|
|
951
|
+
throw new Error(
|
|
952
|
+
`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.`
|
|
953
|
+
);
|
|
944
954
|
const path = _getDataUrl(__privateGet$4(this, _client$3), "live/events"), url = new URL(__privateGet$4(this, _client$3).getUrl(path, !1)), listenFor = ["restart", "message"];
|
|
945
955
|
return new Observable((observer) => {
|
|
946
956
|
let es, reconnectTimer, stopped = !1, unsubscribed = !1;
|