@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.
@@ -2152,7 +2152,7 @@ export declare function _listen<R extends Record<string, Any> = Record<string, A
2152
2152
  */
2153
2153
  export declare function _listen<
2154
2154
  R extends Record<string, Any> = Record<string, Any>,
2155
- Opts extends ListenOptions = ListenOptions,
2155
+ Opts extends ListenOptions | ResumableListenOptions = ListenOptions | ResumableListenOptions,
2156
2156
  >(
2157
2157
  this: SanityClient | ObservableSanityClient,
2158
2158
  query: string,
@@ -2161,9 +2161,11 @@ export declare function _listen<
2161
2161
  ): Observable<ListenEventFromOptions<R, Opts>>
2162
2162
 
2163
2163
  /** @public */
2164
- export declare type ListenEvent<R extends Record<string, Any>> =
2164
+ export declare type ListenEvent<R extends Record<string, Any> = Record<string, Any>> =
2165
2165
  | MutationEvent<R>
2166
2166
  | ReconnectEvent
2167
+ | WelcomeBackEvent
2168
+ | ResetEvent
2167
2169
  | WelcomeEvent
2168
2170
  | OpenEvent
2169
2171
 
@@ -2178,9 +2180,9 @@ export declare type ListenEvent<R extends Record<string, Any>> =
2178
2180
  */
2179
2181
  declare type ListenEventFromOptions<
2180
2182
  R extends Record<string, Any> = Record<string, Any>,
2181
- Opts extends ListenOptions | undefined = undefined,
2182
- > = Opts extends ListenOptions
2183
- ? Opts['events'] extends ListenEventName[]
2183
+ Opts extends ListenOptions | ResumableListenOptions | undefined = undefined,
2184
+ > = Opts extends ListenOptions | ResumableListenOptions
2185
+ ? Opts['events'] extends (ResumableListenEventNames | ListenEventName)[]
2184
2186
  ? MapListenEventNamesToListenEvents<R, Opts['events']>
2185
2187
  : ListenEvent<R>
2186
2188
  : MutationEvent<R>
@@ -2233,7 +2235,7 @@ export declare interface ListenOptions {
2233
2235
  visibility?: 'transaction' | 'query'
2234
2236
  /**
2235
2237
  * Array of event names to include in the observable. By default, only mutation events are included.
2236
- *
2238
+ * Note: `welcomeback` and `reset` events requires `enableResume: true`
2237
2239
  * @defaultValue `['mutation']`
2238
2240
  */
2239
2241
  events?: ListenEventName[]
@@ -2253,6 +2255,13 @@ export declare interface ListenOptions {
2253
2255
  * @defaultValue `undefined`
2254
2256
  */
2255
2257
  tag?: string
2258
+ /**
2259
+ * If this is enabled, the client will normally resume events upon reconnect
2260
+ * 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.
2261
+ * @beta
2262
+ * @defaultValue `false`
2263
+ */
2264
+ enableResume?: boolean
2256
2265
  }
2257
2266
 
2258
2267
  /** @public */
@@ -2350,7 +2359,10 @@ declare type Logger_2 =
2350
2359
  */
2351
2360
  declare type MapListenEventNamesToListenEvents<
2352
2361
  R extends Record<string, Any> = Record<string, Any>,
2353
- Events extends ListenEventName[] = ListenEventName[],
2362
+ Events extends (ResumableListenEventNames | ListenEventName)[] = (
2363
+ | ResumableListenEventNames
2364
+ | ListenEventName
2365
+ )[],
2354
2366
  > = Events extends (infer E)[]
2355
2367
  ? E extends 'welcome'
2356
2368
  ? WelcomeEvent
@@ -2358,9 +2370,13 @@ declare type MapListenEventNamesToListenEvents<
2358
2370
  ? MutationEvent<R>
2359
2371
  : E extends 'reconnect'
2360
2372
  ? ReconnectEvent
2361
- : E extends 'open'
2362
- ? OpenEvent
2363
- : never
2373
+ : E extends 'welcomeback'
2374
+ ? WelcomeBackEvent
2375
+ : E extends 'reset'
2376
+ ? ResetEvent
2377
+ : E extends 'open'
2378
+ ? OpenEvent
2379
+ : never
2364
2380
  : never
2365
2381
 
2366
2382
  /** @public */
@@ -4911,6 +4927,19 @@ export declare interface RequestOptions {
4911
4927
  signal?: AbortSignal
4912
4928
  }
4913
4929
 
4930
+ /**
4931
+ * The listener can't be resumed or otherwise need to reset its local state
4932
+ *
4933
+ * If resumability is unavailable, even listeners created with `enableResume: true` may still
4934
+ * emit `welcome` when reconnected. Subscribers should therefore treat `welcome` after a reconnect
4935
+ * the same way they would otherwise treat a `reset` event.
4936
+ *
4937
+ * @public
4938
+ */
4939
+ export declare type ResetEvent = {
4940
+ type: 'reset'
4941
+ }
4942
+
4914
4943
  /** @alpha */
4915
4944
  export declare type ResolveStudioUrl = (
4916
4945
  sourceDocument: ContentSourceMapDocuments_2[number],
@@ -4946,6 +4975,32 @@ export declare interface ResponseQueryOptions extends RequestOptions {
4946
4975
  cacheMode?: 'noStale'
4947
4976
  }
4948
4977
 
4978
+ /** @public */
4979
+ export declare type ResumableListenEventNames =
4980
+ | ListenEventName
4981
+ /** The listener has reconnected and successfully resumed from where it left off */
4982
+ | 'welcomeback'
4983
+ /** The listener can't be resumed or otherwise need to reset its local state */
4984
+ | 'reset'
4985
+
4986
+ /** @public */
4987
+ export declare interface ResumableListenOptions
4988
+ extends Omit<ListenOptions, 'events' | 'enableResume'> {
4989
+ /**
4990
+ * If this is enabled, the client will normally resume events upon reconnect
4991
+ * Note that you should also subscribe to `reset`-events and handle the case where the backend is unable to resume
4992
+ * @beta
4993
+ * @defaultValue `false`
4994
+ */
4995
+ enableResume: true
4996
+ /**
4997
+ * Array of event names to include in the observable. By default, only mutation events are included.
4998
+ *
4999
+ * @defaultValue `['mutation']`
5000
+ */
5001
+ events?: ResumableListenEventNames[]
5002
+ }
5003
+
4949
5004
  /** @internal */
4950
5005
  export declare interface SanityAssetDocument extends SanityDocument {
4951
5006
  url: string
@@ -6751,8 +6806,33 @@ export declare interface VideoPlaybackTokens {
6751
6806
  }
6752
6807
 
6753
6808
  /**
6754
- * The listener has been established, and will start receiving events.
6755
- * Note that this is also emitted upon _reconnection_.
6809
+ * Emitted when the listener reconnects and successfully resumes from
6810
+ * its previous position.
6811
+ *
6812
+ * Even if the listener is created with `enableResume: true`, resume support
6813
+ * may not be available. In that case, a reconnect will emit `welcome`
6814
+ * instead of `welcomeback`.
6815
+ *
6816
+ * If resumability is unavailable, even listeners created with `enableResume: true` may still
6817
+ * emit `welcome` when reconnected. Subscribers should therefore treat `welcome` after a reconnect
6818
+ * the same way they would otherwise treat a `reset` event.
6819
+ *
6820
+ * @public
6821
+ */
6822
+ export declare type WelcomeBackEvent = {
6823
+ type: 'welcomeback'
6824
+ listenerName: string
6825
+ }
6826
+
6827
+ /**
6828
+ * Emitted when the listener connection has been successfully established
6829
+ * and is ready to receive events.
6830
+ *
6831
+ * If the listener was created with `enableResume: true` and resume support
6832
+ * is available, the `welcome` event will only be emitted on the initial
6833
+ * connection. On subsequent reconnects, a `welcomeback` event will be
6834
+ * emitted instead, followed by any events that were missed while the
6835
+ * connection was disconnected.
6756
6836
  *
6757
6837
  * @public
6758
6838
  */
@@ -2152,7 +2152,7 @@ export declare function _listen<R extends Record<string, Any> = Record<string, A
2152
2152
  */
2153
2153
  export declare function _listen<
2154
2154
  R extends Record<string, Any> = Record<string, Any>,
2155
- Opts extends ListenOptions = ListenOptions,
2155
+ Opts extends ListenOptions | ResumableListenOptions = ListenOptions | ResumableListenOptions,
2156
2156
  >(
2157
2157
  this: SanityClient | ObservableSanityClient,
2158
2158
  query: string,
@@ -2161,9 +2161,11 @@ export declare function _listen<
2161
2161
  ): Observable<ListenEventFromOptions<R, Opts>>
2162
2162
 
2163
2163
  /** @public */
2164
- export declare type ListenEvent<R extends Record<string, Any>> =
2164
+ export declare type ListenEvent<R extends Record<string, Any> = Record<string, Any>> =
2165
2165
  | MutationEvent<R>
2166
2166
  | ReconnectEvent
2167
+ | WelcomeBackEvent
2168
+ | ResetEvent
2167
2169
  | WelcomeEvent
2168
2170
  | OpenEvent
2169
2171
 
@@ -2178,9 +2180,9 @@ export declare type ListenEvent<R extends Record<string, Any>> =
2178
2180
  */
2179
2181
  declare type ListenEventFromOptions<
2180
2182
  R extends Record<string, Any> = Record<string, Any>,
2181
- Opts extends ListenOptions | undefined = undefined,
2182
- > = Opts extends ListenOptions
2183
- ? Opts['events'] extends ListenEventName[]
2183
+ Opts extends ListenOptions | ResumableListenOptions | undefined = undefined,
2184
+ > = Opts extends ListenOptions | ResumableListenOptions
2185
+ ? Opts['events'] extends (ResumableListenEventNames | ListenEventName)[]
2184
2186
  ? MapListenEventNamesToListenEvents<R, Opts['events']>
2185
2187
  : ListenEvent<R>
2186
2188
  : MutationEvent<R>
@@ -2233,7 +2235,7 @@ export declare interface ListenOptions {
2233
2235
  visibility?: 'transaction' | 'query'
2234
2236
  /**
2235
2237
  * Array of event names to include in the observable. By default, only mutation events are included.
2236
- *
2238
+ * Note: `welcomeback` and `reset` events requires `enableResume: true`
2237
2239
  * @defaultValue `['mutation']`
2238
2240
  */
2239
2241
  events?: ListenEventName[]
@@ -2253,6 +2255,13 @@ export declare interface ListenOptions {
2253
2255
  * @defaultValue `undefined`
2254
2256
  */
2255
2257
  tag?: string
2258
+ /**
2259
+ * If this is enabled, the client will normally resume events upon reconnect
2260
+ * 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.
2261
+ * @beta
2262
+ * @defaultValue `false`
2263
+ */
2264
+ enableResume?: boolean
2256
2265
  }
2257
2266
 
2258
2267
  /** @public */
@@ -2350,7 +2359,10 @@ declare type Logger_2 =
2350
2359
  */
2351
2360
  declare type MapListenEventNamesToListenEvents<
2352
2361
  R extends Record<string, Any> = Record<string, Any>,
2353
- Events extends ListenEventName[] = ListenEventName[],
2362
+ Events extends (ResumableListenEventNames | ListenEventName)[] = (
2363
+ | ResumableListenEventNames
2364
+ | ListenEventName
2365
+ )[],
2354
2366
  > = Events extends (infer E)[]
2355
2367
  ? E extends 'welcome'
2356
2368
  ? WelcomeEvent
@@ -2358,9 +2370,13 @@ declare type MapListenEventNamesToListenEvents<
2358
2370
  ? MutationEvent<R>
2359
2371
  : E extends 'reconnect'
2360
2372
  ? ReconnectEvent
2361
- : E extends 'open'
2362
- ? OpenEvent
2363
- : never
2373
+ : E extends 'welcomeback'
2374
+ ? WelcomeBackEvent
2375
+ : E extends 'reset'
2376
+ ? ResetEvent
2377
+ : E extends 'open'
2378
+ ? OpenEvent
2379
+ : never
2364
2380
  : never
2365
2381
 
2366
2382
  /** @public */
@@ -4911,6 +4927,19 @@ export declare interface RequestOptions {
4911
4927
  signal?: AbortSignal
4912
4928
  }
4913
4929
 
4930
+ /**
4931
+ * The listener can't be resumed or otherwise need to reset its local state
4932
+ *
4933
+ * If resumability is unavailable, even listeners created with `enableResume: true` may still
4934
+ * emit `welcome` when reconnected. Subscribers should therefore treat `welcome` after a reconnect
4935
+ * the same way they would otherwise treat a `reset` event.
4936
+ *
4937
+ * @public
4938
+ */
4939
+ export declare type ResetEvent = {
4940
+ type: 'reset'
4941
+ }
4942
+
4914
4943
  /** @alpha */
4915
4944
  export declare type ResolveStudioUrl = (
4916
4945
  sourceDocument: ContentSourceMapDocuments_2[number],
@@ -4946,6 +4975,32 @@ export declare interface ResponseQueryOptions extends RequestOptions {
4946
4975
  cacheMode?: 'noStale'
4947
4976
  }
4948
4977
 
4978
+ /** @public */
4979
+ export declare type ResumableListenEventNames =
4980
+ | ListenEventName
4981
+ /** The listener has reconnected and successfully resumed from where it left off */
4982
+ | 'welcomeback'
4983
+ /** The listener can't be resumed or otherwise need to reset its local state */
4984
+ | 'reset'
4985
+
4986
+ /** @public */
4987
+ export declare interface ResumableListenOptions
4988
+ extends Omit<ListenOptions, 'events' | 'enableResume'> {
4989
+ /**
4990
+ * If this is enabled, the client will normally resume events upon reconnect
4991
+ * Note that you should also subscribe to `reset`-events and handle the case where the backend is unable to resume
4992
+ * @beta
4993
+ * @defaultValue `false`
4994
+ */
4995
+ enableResume: true
4996
+ /**
4997
+ * Array of event names to include in the observable. By default, only mutation events are included.
4998
+ *
4999
+ * @defaultValue `['mutation']`
5000
+ */
5001
+ events?: ResumableListenEventNames[]
5002
+ }
5003
+
4949
5004
  /** @internal */
4950
5005
  export declare interface SanityAssetDocument extends SanityDocument {
4951
5006
  url: string
@@ -6751,8 +6806,33 @@ export declare interface VideoPlaybackTokens {
6751
6806
  }
6752
6807
 
6753
6808
  /**
6754
- * The listener has been established, and will start receiving events.
6755
- * Note that this is also emitted upon _reconnection_.
6809
+ * Emitted when the listener reconnects and successfully resumes from
6810
+ * its previous position.
6811
+ *
6812
+ * Even if the listener is created with `enableResume: true`, resume support
6813
+ * may not be available. In that case, a reconnect will emit `welcome`
6814
+ * instead of `welcomeback`.
6815
+ *
6816
+ * If resumability is unavailable, even listeners created with `enableResume: true` may still
6817
+ * emit `welcome` when reconnected. Subscribers should therefore treat `welcome` after a reconnect
6818
+ * the same way they would otherwise treat a `reset` event.
6819
+ *
6820
+ * @public
6821
+ */
6822
+ export declare type WelcomeBackEvent = {
6823
+ type: 'welcomeback'
6824
+ listenerName: string
6825
+ }
6826
+
6827
+ /**
6828
+ * Emitted when the listener connection has been successfully established
6829
+ * and is ready to receive events.
6830
+ *
6831
+ * If the listener was created with `enableResume: true` and resume support
6832
+ * is available, the `welcome` event will only be emitted on the initial
6833
+ * connection. On subsequent reconnects, a `welcomeback` event will be
6834
+ * emitted instead, followed by any events that were missed while the
6835
+ * connection was disconnected.
6756
6836
  *
6757
6837
  * @public
6758
6838
  */
package/dist/stega.d.cts CHANGED
@@ -2152,7 +2152,7 @@ export declare function _listen<R extends Record<string, Any> = Record<string, A
2152
2152
  */
2153
2153
  export declare function _listen<
2154
2154
  R extends Record<string, Any> = Record<string, Any>,
2155
- Opts extends ListenOptions = ListenOptions,
2155
+ Opts extends ListenOptions | ResumableListenOptions = ListenOptions | ResumableListenOptions,
2156
2156
  >(
2157
2157
  this: SanityClient | ObservableSanityClient,
2158
2158
  query: string,
@@ -2161,9 +2161,11 @@ export declare function _listen<
2161
2161
  ): Observable<ListenEventFromOptions<R, Opts>>
2162
2162
 
2163
2163
  /** @public */
2164
- export declare type ListenEvent<R extends Record<string, Any>> =
2164
+ export declare type ListenEvent<R extends Record<string, Any> = Record<string, Any>> =
2165
2165
  | MutationEvent<R>
2166
2166
  | ReconnectEvent
2167
+ | WelcomeBackEvent
2168
+ | ResetEvent
2167
2169
  | WelcomeEvent
2168
2170
  | OpenEvent
2169
2171
 
@@ -2178,9 +2180,9 @@ export declare type ListenEvent<R extends Record<string, Any>> =
2178
2180
  */
2179
2181
  declare type ListenEventFromOptions<
2180
2182
  R extends Record<string, Any> = Record<string, Any>,
2181
- Opts extends ListenOptions | undefined = undefined,
2182
- > = Opts extends ListenOptions
2183
- ? Opts['events'] extends ListenEventName[]
2183
+ Opts extends ListenOptions | ResumableListenOptions | undefined = undefined,
2184
+ > = Opts extends ListenOptions | ResumableListenOptions
2185
+ ? Opts['events'] extends (ResumableListenEventNames | ListenEventName)[]
2184
2186
  ? MapListenEventNamesToListenEvents<R, Opts['events']>
2185
2187
  : ListenEvent<R>
2186
2188
  : MutationEvent<R>
@@ -2233,7 +2235,7 @@ export declare interface ListenOptions {
2233
2235
  visibility?: 'transaction' | 'query'
2234
2236
  /**
2235
2237
  * Array of event names to include in the observable. By default, only mutation events are included.
2236
- *
2238
+ * Note: `welcomeback` and `reset` events requires `enableResume: true`
2237
2239
  * @defaultValue `['mutation']`
2238
2240
  */
2239
2241
  events?: ListenEventName[]
@@ -2253,6 +2255,13 @@ export declare interface ListenOptions {
2253
2255
  * @defaultValue `undefined`
2254
2256
  */
2255
2257
  tag?: string
2258
+ /**
2259
+ * If this is enabled, the client will normally resume events upon reconnect
2260
+ * 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.
2261
+ * @beta
2262
+ * @defaultValue `false`
2263
+ */
2264
+ enableResume?: boolean
2256
2265
  }
2257
2266
 
2258
2267
  /** @public */
@@ -2350,7 +2359,10 @@ declare type Logger_2 =
2350
2359
  */
2351
2360
  declare type MapListenEventNamesToListenEvents<
2352
2361
  R extends Record<string, Any> = Record<string, Any>,
2353
- Events extends ListenEventName[] = ListenEventName[],
2362
+ Events extends (ResumableListenEventNames | ListenEventName)[] = (
2363
+ | ResumableListenEventNames
2364
+ | ListenEventName
2365
+ )[],
2354
2366
  > = Events extends (infer E)[]
2355
2367
  ? E extends 'welcome'
2356
2368
  ? WelcomeEvent
@@ -2358,9 +2370,13 @@ declare type MapListenEventNamesToListenEvents<
2358
2370
  ? MutationEvent<R>
2359
2371
  : E extends 'reconnect'
2360
2372
  ? ReconnectEvent
2361
- : E extends 'open'
2362
- ? OpenEvent
2363
- : never
2373
+ : E extends 'welcomeback'
2374
+ ? WelcomeBackEvent
2375
+ : E extends 'reset'
2376
+ ? ResetEvent
2377
+ : E extends 'open'
2378
+ ? OpenEvent
2379
+ : never
2364
2380
  : never
2365
2381
 
2366
2382
  /** @public */
@@ -4911,6 +4927,19 @@ export declare interface RequestOptions {
4911
4927
  signal?: AbortSignal
4912
4928
  }
4913
4929
 
4930
+ /**
4931
+ * The listener can't be resumed or otherwise need to reset its local state
4932
+ *
4933
+ * If resumability is unavailable, even listeners created with `enableResume: true` may still
4934
+ * emit `welcome` when reconnected. Subscribers should therefore treat `welcome` after a reconnect
4935
+ * the same way they would otherwise treat a `reset` event.
4936
+ *
4937
+ * @public
4938
+ */
4939
+ export declare type ResetEvent = {
4940
+ type: 'reset'
4941
+ }
4942
+
4914
4943
  /** @alpha */
4915
4944
  export declare type ResolveStudioUrl = (
4916
4945
  sourceDocument: ContentSourceMapDocuments_2[number],
@@ -4946,6 +4975,32 @@ export declare interface ResponseQueryOptions extends RequestOptions {
4946
4975
  cacheMode?: 'noStale'
4947
4976
  }
4948
4977
 
4978
+ /** @public */
4979
+ export declare type ResumableListenEventNames =
4980
+ | ListenEventName
4981
+ /** The listener has reconnected and successfully resumed from where it left off */
4982
+ | 'welcomeback'
4983
+ /** The listener can't be resumed or otherwise need to reset its local state */
4984
+ | 'reset'
4985
+
4986
+ /** @public */
4987
+ export declare interface ResumableListenOptions
4988
+ extends Omit<ListenOptions, 'events' | 'enableResume'> {
4989
+ /**
4990
+ * If this is enabled, the client will normally resume events upon reconnect
4991
+ * Note that you should also subscribe to `reset`-events and handle the case where the backend is unable to resume
4992
+ * @beta
4993
+ * @defaultValue `false`
4994
+ */
4995
+ enableResume: true
4996
+ /**
4997
+ * Array of event names to include in the observable. By default, only mutation events are included.
4998
+ *
4999
+ * @defaultValue `['mutation']`
5000
+ */
5001
+ events?: ResumableListenEventNames[]
5002
+ }
5003
+
4949
5004
  /** @internal */
4950
5005
  export declare interface SanityAssetDocument extends SanityDocument {
4951
5006
  url: string
@@ -6751,8 +6806,33 @@ export declare interface VideoPlaybackTokens {
6751
6806
  }
6752
6807
 
6753
6808
  /**
6754
- * The listener has been established, and will start receiving events.
6755
- * Note that this is also emitted upon _reconnection_.
6809
+ * Emitted when the listener reconnects and successfully resumes from
6810
+ * its previous position.
6811
+ *
6812
+ * Even if the listener is created with `enableResume: true`, resume support
6813
+ * may not be available. In that case, a reconnect will emit `welcome`
6814
+ * instead of `welcomeback`.
6815
+ *
6816
+ * If resumability is unavailable, even listeners created with `enableResume: true` may still
6817
+ * emit `welcome` when reconnected. Subscribers should therefore treat `welcome` after a reconnect
6818
+ * the same way they would otherwise treat a `reset` event.
6819
+ *
6820
+ * @public
6821
+ */
6822
+ export declare type WelcomeBackEvent = {
6823
+ type: 'welcomeback'
6824
+ listenerName: string
6825
+ }
6826
+
6827
+ /**
6828
+ * Emitted when the listener connection has been successfully established
6829
+ * and is ready to receive events.
6830
+ *
6831
+ * If the listener was created with `enableResume: true` and resume support
6832
+ * is available, the `welcome` event will only be emitted on the initial
6833
+ * connection. On subsequent reconnects, a `welcomeback` event will be
6834
+ * emitted instead, followed by any events that were missed while the
6835
+ * connection was disconnected.
6756
6836
  *
6757
6837
  * @public
6758
6838
  */
package/dist/stega.d.ts CHANGED
@@ -2152,7 +2152,7 @@ export declare function _listen<R extends Record<string, Any> = Record<string, A
2152
2152
  */
2153
2153
  export declare function _listen<
2154
2154
  R extends Record<string, Any> = Record<string, Any>,
2155
- Opts extends ListenOptions = ListenOptions,
2155
+ Opts extends ListenOptions | ResumableListenOptions = ListenOptions | ResumableListenOptions,
2156
2156
  >(
2157
2157
  this: SanityClient | ObservableSanityClient,
2158
2158
  query: string,
@@ -2161,9 +2161,11 @@ export declare function _listen<
2161
2161
  ): Observable<ListenEventFromOptions<R, Opts>>
2162
2162
 
2163
2163
  /** @public */
2164
- export declare type ListenEvent<R extends Record<string, Any>> =
2164
+ export declare type ListenEvent<R extends Record<string, Any> = Record<string, Any>> =
2165
2165
  | MutationEvent<R>
2166
2166
  | ReconnectEvent
2167
+ | WelcomeBackEvent
2168
+ | ResetEvent
2167
2169
  | WelcomeEvent
2168
2170
  | OpenEvent
2169
2171
 
@@ -2178,9 +2180,9 @@ export declare type ListenEvent<R extends Record<string, Any>> =
2178
2180
  */
2179
2181
  declare type ListenEventFromOptions<
2180
2182
  R extends Record<string, Any> = Record<string, Any>,
2181
- Opts extends ListenOptions | undefined = undefined,
2182
- > = Opts extends ListenOptions
2183
- ? Opts['events'] extends ListenEventName[]
2183
+ Opts extends ListenOptions | ResumableListenOptions | undefined = undefined,
2184
+ > = Opts extends ListenOptions | ResumableListenOptions
2185
+ ? Opts['events'] extends (ResumableListenEventNames | ListenEventName)[]
2184
2186
  ? MapListenEventNamesToListenEvents<R, Opts['events']>
2185
2187
  : ListenEvent<R>
2186
2188
  : MutationEvent<R>
@@ -2233,7 +2235,7 @@ export declare interface ListenOptions {
2233
2235
  visibility?: 'transaction' | 'query'
2234
2236
  /**
2235
2237
  * Array of event names to include in the observable. By default, only mutation events are included.
2236
- *
2238
+ * Note: `welcomeback` and `reset` events requires `enableResume: true`
2237
2239
  * @defaultValue `['mutation']`
2238
2240
  */
2239
2241
  events?: ListenEventName[]
@@ -2253,6 +2255,13 @@ export declare interface ListenOptions {
2253
2255
  * @defaultValue `undefined`
2254
2256
  */
2255
2257
  tag?: string
2258
+ /**
2259
+ * If this is enabled, the client will normally resume events upon reconnect
2260
+ * 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.
2261
+ * @beta
2262
+ * @defaultValue `false`
2263
+ */
2264
+ enableResume?: boolean
2256
2265
  }
2257
2266
 
2258
2267
  /** @public */
@@ -2350,7 +2359,10 @@ declare type Logger_2 =
2350
2359
  */
2351
2360
  declare type MapListenEventNamesToListenEvents<
2352
2361
  R extends Record<string, Any> = Record<string, Any>,
2353
- Events extends ListenEventName[] = ListenEventName[],
2362
+ Events extends (ResumableListenEventNames | ListenEventName)[] = (
2363
+ | ResumableListenEventNames
2364
+ | ListenEventName
2365
+ )[],
2354
2366
  > = Events extends (infer E)[]
2355
2367
  ? E extends 'welcome'
2356
2368
  ? WelcomeEvent
@@ -2358,9 +2370,13 @@ declare type MapListenEventNamesToListenEvents<
2358
2370
  ? MutationEvent<R>
2359
2371
  : E extends 'reconnect'
2360
2372
  ? ReconnectEvent
2361
- : E extends 'open'
2362
- ? OpenEvent
2363
- : never
2373
+ : E extends 'welcomeback'
2374
+ ? WelcomeBackEvent
2375
+ : E extends 'reset'
2376
+ ? ResetEvent
2377
+ : E extends 'open'
2378
+ ? OpenEvent
2379
+ : never
2364
2380
  : never
2365
2381
 
2366
2382
  /** @public */
@@ -4911,6 +4927,19 @@ export declare interface RequestOptions {
4911
4927
  signal?: AbortSignal
4912
4928
  }
4913
4929
 
4930
+ /**
4931
+ * The listener can't be resumed or otherwise need to reset its local state
4932
+ *
4933
+ * If resumability is unavailable, even listeners created with `enableResume: true` may still
4934
+ * emit `welcome` when reconnected. Subscribers should therefore treat `welcome` after a reconnect
4935
+ * the same way they would otherwise treat a `reset` event.
4936
+ *
4937
+ * @public
4938
+ */
4939
+ export declare type ResetEvent = {
4940
+ type: 'reset'
4941
+ }
4942
+
4914
4943
  /** @alpha */
4915
4944
  export declare type ResolveStudioUrl = (
4916
4945
  sourceDocument: ContentSourceMapDocuments_2[number],
@@ -4946,6 +4975,32 @@ export declare interface ResponseQueryOptions extends RequestOptions {
4946
4975
  cacheMode?: 'noStale'
4947
4976
  }
4948
4977
 
4978
+ /** @public */
4979
+ export declare type ResumableListenEventNames =
4980
+ | ListenEventName
4981
+ /** The listener has reconnected and successfully resumed from where it left off */
4982
+ | 'welcomeback'
4983
+ /** The listener can't be resumed or otherwise need to reset its local state */
4984
+ | 'reset'
4985
+
4986
+ /** @public */
4987
+ export declare interface ResumableListenOptions
4988
+ extends Omit<ListenOptions, 'events' | 'enableResume'> {
4989
+ /**
4990
+ * If this is enabled, the client will normally resume events upon reconnect
4991
+ * Note that you should also subscribe to `reset`-events and handle the case where the backend is unable to resume
4992
+ * @beta
4993
+ * @defaultValue `false`
4994
+ */
4995
+ enableResume: true
4996
+ /**
4997
+ * Array of event names to include in the observable. By default, only mutation events are included.
4998
+ *
4999
+ * @defaultValue `['mutation']`
5000
+ */
5001
+ events?: ResumableListenEventNames[]
5002
+ }
5003
+
4949
5004
  /** @internal */
4950
5005
  export declare interface SanityAssetDocument extends SanityDocument {
4951
5006
  url: string
@@ -6751,8 +6806,33 @@ export declare interface VideoPlaybackTokens {
6751
6806
  }
6752
6807
 
6753
6808
  /**
6754
- * The listener has been established, and will start receiving events.
6755
- * Note that this is also emitted upon _reconnection_.
6809
+ * Emitted when the listener reconnects and successfully resumes from
6810
+ * its previous position.
6811
+ *
6812
+ * Even if the listener is created with `enableResume: true`, resume support
6813
+ * may not be available. In that case, a reconnect will emit `welcome`
6814
+ * instead of `welcomeback`.
6815
+ *
6816
+ * If resumability is unavailable, even listeners created with `enableResume: true` may still
6817
+ * emit `welcome` when reconnected. Subscribers should therefore treat `welcome` after a reconnect
6818
+ * the same way they would otherwise treat a `reset` event.
6819
+ *
6820
+ * @public
6821
+ */
6822
+ export declare type WelcomeBackEvent = {
6823
+ type: 'welcomeback'
6824
+ listenerName: string
6825
+ }
6826
+
6827
+ /**
6828
+ * Emitted when the listener connection has been successfully established
6829
+ * and is ready to receive events.
6830
+ *
6831
+ * If the listener was created with `enableResume: true` and resume support
6832
+ * is available, the `welcome` event will only be emitted on the initial
6833
+ * connection. On subsequent reconnects, a `welcomeback` event will be
6834
+ * emitted instead, followed by any events that were missed while the
6835
+ * connection was disconnected.
6756
6836
  *
6757
6837
  * @public
6758
6838
  */