@sanity/client 7.14.1 → 7.15.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 +1 -0
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.d.cts +92 -12
- package/dist/index.browser.d.ts +92 -12
- package/dist/index.browser.js +1 -0
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +2 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +92 -12
- package/dist/index.d.ts +92 -12
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/stega.browser.d.cts +92 -12
- package/dist/stega.browser.d.ts +92 -12
- package/dist/stega.d.cts +92 -12
- package/dist/stega.d.ts +92 -12
- package/package.json +1 -1
- package/src/data/listen.ts +21 -9
- package/src/types.ts +78 -4
- package/umd/sanityClient.js +1 -0
- package/umd/sanityClient.min.js +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1987,7 +1987,7 @@ export declare function _listen<R extends Record<string, Any> = Record<string, A
|
|
|
1987
1987
|
*/
|
|
1988
1988
|
export declare function _listen<
|
|
1989
1989
|
R extends Record<string, Any> = Record<string, Any>,
|
|
1990
|
-
Opts extends ListenOptions = ListenOptions,
|
|
1990
|
+
Opts extends ListenOptions | ResumableListenOptions = ListenOptions | ResumableListenOptions,
|
|
1991
1991
|
>(
|
|
1992
1992
|
this: SanityClient | ObservableSanityClient,
|
|
1993
1993
|
query: string,
|
|
@@ -1996,9 +1996,11 @@ export declare function _listen<
|
|
|
1996
1996
|
): Observable<ListenEventFromOptions<R, Opts>>
|
|
1997
1997
|
|
|
1998
1998
|
/** @public */
|
|
1999
|
-
export declare type ListenEvent<R extends Record<string, Any>> =
|
|
1999
|
+
export declare type ListenEvent<R extends Record<string, Any> = Record<string, Any>> =
|
|
2000
2000
|
| MutationEvent<R>
|
|
2001
2001
|
| ReconnectEvent
|
|
2002
|
+
| WelcomeBackEvent
|
|
2003
|
+
| ResetEvent
|
|
2002
2004
|
| WelcomeEvent
|
|
2003
2005
|
| OpenEvent
|
|
2004
2006
|
|
|
@@ -2013,9 +2015,9 @@ export declare type ListenEvent<R extends Record<string, Any>> =
|
|
|
2013
2015
|
*/
|
|
2014
2016
|
declare type ListenEventFromOptions<
|
|
2015
2017
|
R extends Record<string, Any> = Record<string, Any>,
|
|
2016
|
-
Opts extends ListenOptions | undefined = undefined,
|
|
2017
|
-
> = Opts extends ListenOptions
|
|
2018
|
-
? Opts['events'] extends ListenEventName[]
|
|
2018
|
+
Opts extends ListenOptions | ResumableListenOptions | undefined = undefined,
|
|
2019
|
+
> = Opts extends ListenOptions | ResumableListenOptions
|
|
2020
|
+
? Opts['events'] extends (ResumableListenEventNames | ListenEventName)[]
|
|
2019
2021
|
? MapListenEventNamesToListenEvents<R, Opts['events']>
|
|
2020
2022
|
: ListenEvent<R>
|
|
2021
2023
|
: MutationEvent<R>
|
|
@@ -2068,7 +2070,7 @@ export declare interface ListenOptions {
|
|
|
2068
2070
|
visibility?: 'transaction' | 'query'
|
|
2069
2071
|
/**
|
|
2070
2072
|
* Array of event names to include in the observable. By default, only mutation events are included.
|
|
2071
|
-
*
|
|
2073
|
+
* Note: `welcomeback` and `reset` events requires `enableResume: true`
|
|
2072
2074
|
* @defaultValue `['mutation']`
|
|
2073
2075
|
*/
|
|
2074
2076
|
events?: ListenEventName[]
|
|
@@ -2088,6 +2090,13 @@ export declare interface ListenOptions {
|
|
|
2088
2090
|
* @defaultValue `undefined`
|
|
2089
2091
|
*/
|
|
2090
2092
|
tag?: string
|
|
2093
|
+
/**
|
|
2094
|
+
* If this is enabled, the client will normally resume events upon reconnect
|
|
2095
|
+
* When if enabling this, you should also add the `reset` to the events array and handle the case where the backend is unable to resume.
|
|
2096
|
+
* @beta
|
|
2097
|
+
* @defaultValue `false`
|
|
2098
|
+
*/
|
|
2099
|
+
enableResume?: boolean
|
|
2091
2100
|
}
|
|
2092
2101
|
|
|
2093
2102
|
/** @public */
|
|
@@ -2178,7 +2187,10 @@ export declare type Logger =
|
|
|
2178
2187
|
*/
|
|
2179
2188
|
declare type MapListenEventNamesToListenEvents<
|
|
2180
2189
|
R extends Record<string, Any> = Record<string, Any>,
|
|
2181
|
-
Events extends ListenEventName[] =
|
|
2190
|
+
Events extends (ResumableListenEventNames | ListenEventName)[] = (
|
|
2191
|
+
| ResumableListenEventNames
|
|
2192
|
+
| ListenEventName
|
|
2193
|
+
)[],
|
|
2182
2194
|
> = Events extends (infer E)[]
|
|
2183
2195
|
? E extends 'welcome'
|
|
2184
2196
|
? WelcomeEvent
|
|
@@ -2186,9 +2198,13 @@ declare type MapListenEventNamesToListenEvents<
|
|
|
2186
2198
|
? MutationEvent<R>
|
|
2187
2199
|
: E extends 'reconnect'
|
|
2188
2200
|
? ReconnectEvent
|
|
2189
|
-
: E extends '
|
|
2190
|
-
?
|
|
2191
|
-
:
|
|
2201
|
+
: E extends 'welcomeback'
|
|
2202
|
+
? WelcomeBackEvent
|
|
2203
|
+
: E extends 'reset'
|
|
2204
|
+
? ResetEvent
|
|
2205
|
+
: E extends 'open'
|
|
2206
|
+
? OpenEvent
|
|
2207
|
+
: never
|
|
2192
2208
|
: never
|
|
2193
2209
|
|
|
2194
2210
|
/** @public */
|
|
@@ -4730,6 +4746,19 @@ export declare interface RequestOptions {
|
|
|
4730
4746
|
signal?: AbortSignal
|
|
4731
4747
|
}
|
|
4732
4748
|
|
|
4749
|
+
/**
|
|
4750
|
+
* The listener can't be resumed or otherwise need to reset its local state
|
|
4751
|
+
*
|
|
4752
|
+
* If resumability is unavailable, even listeners created with `enableResume: true` may still
|
|
4753
|
+
* emit `welcome` when reconnected. Subscribers should therefore treat `welcome` after a reconnect
|
|
4754
|
+
* the same way they would otherwise treat a `reset` event.
|
|
4755
|
+
*
|
|
4756
|
+
* @public
|
|
4757
|
+
*/
|
|
4758
|
+
export declare type ResetEvent = {
|
|
4759
|
+
type: 'reset'
|
|
4760
|
+
}
|
|
4761
|
+
|
|
4733
4762
|
export {ResolveStudioUrl}
|
|
4734
4763
|
|
|
4735
4764
|
/** @public */
|
|
@@ -4762,6 +4791,32 @@ export declare interface ResponseQueryOptions extends RequestOptions {
|
|
|
4762
4791
|
cacheMode?: 'noStale'
|
|
4763
4792
|
}
|
|
4764
4793
|
|
|
4794
|
+
/** @public */
|
|
4795
|
+
export declare type ResumableListenEventNames =
|
|
4796
|
+
| ListenEventName
|
|
4797
|
+
/** The listener has reconnected and successfully resumed from where it left off */
|
|
4798
|
+
| 'welcomeback'
|
|
4799
|
+
/** The listener can't be resumed or otherwise need to reset its local state */
|
|
4800
|
+
| 'reset'
|
|
4801
|
+
|
|
4802
|
+
/** @public */
|
|
4803
|
+
export declare interface ResumableListenOptions
|
|
4804
|
+
extends Omit<ListenOptions, 'events' | 'enableResume'> {
|
|
4805
|
+
/**
|
|
4806
|
+
* If this is enabled, the client will normally resume events upon reconnect
|
|
4807
|
+
* Note that you should also subscribe to `reset`-events and handle the case where the backend is unable to resume
|
|
4808
|
+
* @beta
|
|
4809
|
+
* @defaultValue `false`
|
|
4810
|
+
*/
|
|
4811
|
+
enableResume: true
|
|
4812
|
+
/**
|
|
4813
|
+
* Array of event names to include in the observable. By default, only mutation events are included.
|
|
4814
|
+
*
|
|
4815
|
+
* @defaultValue `['mutation']`
|
|
4816
|
+
*/
|
|
4817
|
+
events?: ResumableListenEventNames[]
|
|
4818
|
+
}
|
|
4819
|
+
|
|
4765
4820
|
/** @internal */
|
|
4766
4821
|
export declare interface SanityAssetDocument extends SanityDocument {
|
|
4767
4822
|
url: string
|
|
@@ -6490,8 +6545,33 @@ export declare interface VideoPlaybackTokens {
|
|
|
6490
6545
|
}
|
|
6491
6546
|
|
|
6492
6547
|
/**
|
|
6493
|
-
*
|
|
6494
|
-
*
|
|
6548
|
+
* Emitted when the listener reconnects and successfully resumes from
|
|
6549
|
+
* its previous position.
|
|
6550
|
+
*
|
|
6551
|
+
* Even if the listener is created with `enableResume: true`, resume support
|
|
6552
|
+
* may not be available. In that case, a reconnect will emit `welcome`
|
|
6553
|
+
* instead of `welcomeback`.
|
|
6554
|
+
*
|
|
6555
|
+
* If resumability is unavailable, even listeners created with `enableResume: true` may still
|
|
6556
|
+
* emit `welcome` when reconnected. Subscribers should therefore treat `welcome` after a reconnect
|
|
6557
|
+
* the same way they would otherwise treat a `reset` event.
|
|
6558
|
+
*
|
|
6559
|
+
* @public
|
|
6560
|
+
*/
|
|
6561
|
+
export declare type WelcomeBackEvent = {
|
|
6562
|
+
type: 'welcomeback'
|
|
6563
|
+
listenerName: string
|
|
6564
|
+
}
|
|
6565
|
+
|
|
6566
|
+
/**
|
|
6567
|
+
* Emitted when the listener connection has been successfully established
|
|
6568
|
+
* and is ready to receive events.
|
|
6569
|
+
*
|
|
6570
|
+
* If the listener was created with `enableResume: true` and resume support
|
|
6571
|
+
* is available, the `welcome` event will only be emitted on the initial
|
|
6572
|
+
* connection. On subsequent reconnects, a `welcomeback` event will be
|
|
6573
|
+
* emitted instead, followed by any events that were missed while the
|
|
6574
|
+
* connection was disconnected.
|
|
6495
6575
|
*
|
|
6496
6576
|
* @public
|
|
6497
6577
|
*/
|
package/dist/index.d.ts
CHANGED
|
@@ -1987,7 +1987,7 @@ export declare function _listen<R extends Record<string, Any> = Record<string, A
|
|
|
1987
1987
|
*/
|
|
1988
1988
|
export declare function _listen<
|
|
1989
1989
|
R extends Record<string, Any> = Record<string, Any>,
|
|
1990
|
-
Opts extends ListenOptions = ListenOptions,
|
|
1990
|
+
Opts extends ListenOptions | ResumableListenOptions = ListenOptions | ResumableListenOptions,
|
|
1991
1991
|
>(
|
|
1992
1992
|
this: SanityClient | ObservableSanityClient,
|
|
1993
1993
|
query: string,
|
|
@@ -1996,9 +1996,11 @@ export declare function _listen<
|
|
|
1996
1996
|
): Observable<ListenEventFromOptions<R, Opts>>
|
|
1997
1997
|
|
|
1998
1998
|
/** @public */
|
|
1999
|
-
export declare type ListenEvent<R extends Record<string, Any>> =
|
|
1999
|
+
export declare type ListenEvent<R extends Record<string, Any> = Record<string, Any>> =
|
|
2000
2000
|
| MutationEvent<R>
|
|
2001
2001
|
| ReconnectEvent
|
|
2002
|
+
| WelcomeBackEvent
|
|
2003
|
+
| ResetEvent
|
|
2002
2004
|
| WelcomeEvent
|
|
2003
2005
|
| OpenEvent
|
|
2004
2006
|
|
|
@@ -2013,9 +2015,9 @@ export declare type ListenEvent<R extends Record<string, Any>> =
|
|
|
2013
2015
|
*/
|
|
2014
2016
|
declare type ListenEventFromOptions<
|
|
2015
2017
|
R extends Record<string, Any> = Record<string, Any>,
|
|
2016
|
-
Opts extends ListenOptions | undefined = undefined,
|
|
2017
|
-
> = Opts extends ListenOptions
|
|
2018
|
-
? Opts['events'] extends ListenEventName[]
|
|
2018
|
+
Opts extends ListenOptions | ResumableListenOptions | undefined = undefined,
|
|
2019
|
+
> = Opts extends ListenOptions | ResumableListenOptions
|
|
2020
|
+
? Opts['events'] extends (ResumableListenEventNames | ListenEventName)[]
|
|
2019
2021
|
? MapListenEventNamesToListenEvents<R, Opts['events']>
|
|
2020
2022
|
: ListenEvent<R>
|
|
2021
2023
|
: MutationEvent<R>
|
|
@@ -2068,7 +2070,7 @@ export declare interface ListenOptions {
|
|
|
2068
2070
|
visibility?: 'transaction' | 'query'
|
|
2069
2071
|
/**
|
|
2070
2072
|
* Array of event names to include in the observable. By default, only mutation events are included.
|
|
2071
|
-
*
|
|
2073
|
+
* Note: `welcomeback` and `reset` events requires `enableResume: true`
|
|
2072
2074
|
* @defaultValue `['mutation']`
|
|
2073
2075
|
*/
|
|
2074
2076
|
events?: ListenEventName[]
|
|
@@ -2088,6 +2090,13 @@ export declare interface ListenOptions {
|
|
|
2088
2090
|
* @defaultValue `undefined`
|
|
2089
2091
|
*/
|
|
2090
2092
|
tag?: string
|
|
2093
|
+
/**
|
|
2094
|
+
* If this is enabled, the client will normally resume events upon reconnect
|
|
2095
|
+
* When if enabling this, you should also add the `reset` to the events array and handle the case where the backend is unable to resume.
|
|
2096
|
+
* @beta
|
|
2097
|
+
* @defaultValue `false`
|
|
2098
|
+
*/
|
|
2099
|
+
enableResume?: boolean
|
|
2091
2100
|
}
|
|
2092
2101
|
|
|
2093
2102
|
/** @public */
|
|
@@ -2178,7 +2187,10 @@ export declare type Logger =
|
|
|
2178
2187
|
*/
|
|
2179
2188
|
declare type MapListenEventNamesToListenEvents<
|
|
2180
2189
|
R extends Record<string, Any> = Record<string, Any>,
|
|
2181
|
-
Events extends ListenEventName[] =
|
|
2190
|
+
Events extends (ResumableListenEventNames | ListenEventName)[] = (
|
|
2191
|
+
| ResumableListenEventNames
|
|
2192
|
+
| ListenEventName
|
|
2193
|
+
)[],
|
|
2182
2194
|
> = Events extends (infer E)[]
|
|
2183
2195
|
? E extends 'welcome'
|
|
2184
2196
|
? WelcomeEvent
|
|
@@ -2186,9 +2198,13 @@ declare type MapListenEventNamesToListenEvents<
|
|
|
2186
2198
|
? MutationEvent<R>
|
|
2187
2199
|
: E extends 'reconnect'
|
|
2188
2200
|
? ReconnectEvent
|
|
2189
|
-
: E extends '
|
|
2190
|
-
?
|
|
2191
|
-
:
|
|
2201
|
+
: E extends 'welcomeback'
|
|
2202
|
+
? WelcomeBackEvent
|
|
2203
|
+
: E extends 'reset'
|
|
2204
|
+
? ResetEvent
|
|
2205
|
+
: E extends 'open'
|
|
2206
|
+
? OpenEvent
|
|
2207
|
+
: never
|
|
2192
2208
|
: never
|
|
2193
2209
|
|
|
2194
2210
|
/** @public */
|
|
@@ -4730,6 +4746,19 @@ export declare interface RequestOptions {
|
|
|
4730
4746
|
signal?: AbortSignal
|
|
4731
4747
|
}
|
|
4732
4748
|
|
|
4749
|
+
/**
|
|
4750
|
+
* The listener can't be resumed or otherwise need to reset its local state
|
|
4751
|
+
*
|
|
4752
|
+
* If resumability is unavailable, even listeners created with `enableResume: true` may still
|
|
4753
|
+
* emit `welcome` when reconnected. Subscribers should therefore treat `welcome` after a reconnect
|
|
4754
|
+
* the same way they would otherwise treat a `reset` event.
|
|
4755
|
+
*
|
|
4756
|
+
* @public
|
|
4757
|
+
*/
|
|
4758
|
+
export declare type ResetEvent = {
|
|
4759
|
+
type: 'reset'
|
|
4760
|
+
}
|
|
4761
|
+
|
|
4733
4762
|
export {ResolveStudioUrl}
|
|
4734
4763
|
|
|
4735
4764
|
/** @public */
|
|
@@ -4762,6 +4791,32 @@ export declare interface ResponseQueryOptions extends RequestOptions {
|
|
|
4762
4791
|
cacheMode?: 'noStale'
|
|
4763
4792
|
}
|
|
4764
4793
|
|
|
4794
|
+
/** @public */
|
|
4795
|
+
export declare type ResumableListenEventNames =
|
|
4796
|
+
| ListenEventName
|
|
4797
|
+
/** The listener has reconnected and successfully resumed from where it left off */
|
|
4798
|
+
| 'welcomeback'
|
|
4799
|
+
/** The listener can't be resumed or otherwise need to reset its local state */
|
|
4800
|
+
| 'reset'
|
|
4801
|
+
|
|
4802
|
+
/** @public */
|
|
4803
|
+
export declare interface ResumableListenOptions
|
|
4804
|
+
extends Omit<ListenOptions, 'events' | 'enableResume'> {
|
|
4805
|
+
/**
|
|
4806
|
+
* If this is enabled, the client will normally resume events upon reconnect
|
|
4807
|
+
* Note that you should also subscribe to `reset`-events and handle the case where the backend is unable to resume
|
|
4808
|
+
* @beta
|
|
4809
|
+
* @defaultValue `false`
|
|
4810
|
+
*/
|
|
4811
|
+
enableResume: true
|
|
4812
|
+
/**
|
|
4813
|
+
* Array of event names to include in the observable. By default, only mutation events are included.
|
|
4814
|
+
*
|
|
4815
|
+
* @defaultValue `['mutation']`
|
|
4816
|
+
*/
|
|
4817
|
+
events?: ResumableListenEventNames[]
|
|
4818
|
+
}
|
|
4819
|
+
|
|
4765
4820
|
/** @internal */
|
|
4766
4821
|
export declare interface SanityAssetDocument extends SanityDocument {
|
|
4767
4822
|
url: string
|
|
@@ -6490,8 +6545,33 @@ export declare interface VideoPlaybackTokens {
|
|
|
6490
6545
|
}
|
|
6491
6546
|
|
|
6492
6547
|
/**
|
|
6493
|
-
*
|
|
6494
|
-
*
|
|
6548
|
+
* Emitted when the listener reconnects and successfully resumes from
|
|
6549
|
+
* its previous position.
|
|
6550
|
+
*
|
|
6551
|
+
* Even if the listener is created with `enableResume: true`, resume support
|
|
6552
|
+
* may not be available. In that case, a reconnect will emit `welcome`
|
|
6553
|
+
* instead of `welcomeback`.
|
|
6554
|
+
*
|
|
6555
|
+
* If resumability is unavailable, even listeners created with `enableResume: true` may still
|
|
6556
|
+
* emit `welcome` when reconnected. Subscribers should therefore treat `welcome` after a reconnect
|
|
6557
|
+
* the same way they would otherwise treat a `reset` event.
|
|
6558
|
+
*
|
|
6559
|
+
* @public
|
|
6560
|
+
*/
|
|
6561
|
+
export declare type WelcomeBackEvent = {
|
|
6562
|
+
type: 'welcomeback'
|
|
6563
|
+
listenerName: string
|
|
6564
|
+
}
|
|
6565
|
+
|
|
6566
|
+
/**
|
|
6567
|
+
* Emitted when the listener connection has been successfully established
|
|
6568
|
+
* and is ready to receive events.
|
|
6569
|
+
*
|
|
6570
|
+
* If the listener was created with `enableResume: true` and resume support
|
|
6571
|
+
* is available, the `welcome` event will only be emitted on the initial
|
|
6572
|
+
* connection. On subsequent reconnects, a `welcomeback` event will be
|
|
6573
|
+
* emitted instead, followed by any events that were missed while the
|
|
6574
|
+
* connection was disconnected.
|
|
6495
6575
|
*
|
|
6496
6576
|
* @public
|
|
6497
6577
|
*/
|
package/dist/index.js
CHANGED
|
@@ -1211,6 +1211,7 @@ const MAX_URL_LENGTH = 14800, possibleOptions = [
|
|
|
1211
1211
|
"includeAllVersions",
|
|
1212
1212
|
"visibility",
|
|
1213
1213
|
"effectFormat",
|
|
1214
|
+
"enableResume",
|
|
1214
1215
|
"tag"
|
|
1215
1216
|
], defaultOptions = {
|
|
1216
1217
|
includeResult: !0
|
|
@@ -2676,7 +2677,7 @@ function defineDeprecatedCreateClient(createClient2) {
|
|
|
2676
2677
|
return printNoDefaultExport(), createClient2(config);
|
|
2677
2678
|
};
|
|
2678
2679
|
}
|
|
2679
|
-
var name = "@sanity/client", version = "7.
|
|
2680
|
+
var name = "@sanity/client", version = "7.15.0";
|
|
2680
2681
|
const middleware = [
|
|
2681
2682
|
debug({ verbose: !0, namespace: "sanity:client" }),
|
|
2682
2683
|
headers({ "User-Agent": `${name} ${version}` }),
|