@sanity/client 7.12.0 → 7.13.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 +4 -6
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.d.cts +55 -7
- package/dist/index.browser.d.ts +55 -7
- package/dist/index.browser.js +4 -6
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +5 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +55 -7
- package/dist/index.d.ts +55 -7
- package/dist/index.js +5 -7
- package/dist/index.js.map +1 -1
- package/dist/stega.browser.d.cts +55 -7
- package/dist/stega.browser.d.ts +55 -7
- package/dist/stega.d.cts +55 -7
- package/dist/stega.d.ts +55 -7
- package/package.json +4 -4
- package/src/SanityClient.ts +2 -2
- package/src/data/listen.ts +65 -15
- package/src/types.ts +5 -2
- package/umd/sanityClient.js +4 -6
package/dist/index.browser.d.cts
CHANGED
|
@@ -1973,22 +1973,41 @@ export declare function _listen<R extends Record<string, Any> = Record<string, A
|
|
|
1973
1973
|
* @param options - Optional listener options
|
|
1974
1974
|
* @public
|
|
1975
1975
|
*/
|
|
1976
|
-
export declare function _listen<
|
|
1976
|
+
export declare function _listen<
|
|
1977
|
+
R extends Record<string, Any> = Record<string, Any>,
|
|
1978
|
+
Opts extends ListenOptions = ListenOptions,
|
|
1979
|
+
>(
|
|
1977
1980
|
this: SanityClient | ObservableSanityClient,
|
|
1978
1981
|
query: string,
|
|
1979
1982
|
params?: ListenParams,
|
|
1980
|
-
options?:
|
|
1981
|
-
): Observable<
|
|
1983
|
+
options?: Opts,
|
|
1984
|
+
): Observable<ListenEventFromOptions<R, Opts>>
|
|
1982
1985
|
|
|
1983
1986
|
/** @public */
|
|
1984
1987
|
export declare type ListenEvent<R extends Record<string, Any>> =
|
|
1985
1988
|
| MutationEvent<R>
|
|
1986
|
-
| ChannelErrorEvent
|
|
1987
|
-
| DisconnectEvent
|
|
1988
1989
|
| ReconnectEvent
|
|
1989
1990
|
| WelcomeEvent
|
|
1990
1991
|
| OpenEvent
|
|
1991
1992
|
|
|
1993
|
+
/**
|
|
1994
|
+
* Maps a ListenOptions object and returns the Listen events opted for, e.g:
|
|
1995
|
+
* ```
|
|
1996
|
+
* type Test = ListenEventFromOptions<Doc, {events: ['welcome', 'mutation']}>
|
|
1997
|
+
* // ^? WelcomeEvent | MutationEvent<Doc>
|
|
1998
|
+
* ```
|
|
1999
|
+
*
|
|
2000
|
+
* @public
|
|
2001
|
+
*/
|
|
2002
|
+
declare type ListenEventFromOptions<
|
|
2003
|
+
R extends Record<string, Any> = Record<string, Any>,
|
|
2004
|
+
Opts extends ListenOptions | undefined = undefined,
|
|
2005
|
+
> = Opts extends ListenOptions
|
|
2006
|
+
? Opts['events'] extends ListenEventName[]
|
|
2007
|
+
? MapListenEventNamesToListenEvents<R, Opts['events']>
|
|
2008
|
+
: ListenEvent<R>
|
|
2009
|
+
: MutationEvent<R>
|
|
2010
|
+
|
|
1992
2011
|
/** @public */
|
|
1993
2012
|
export declare type ListenEventName =
|
|
1994
2013
|
/** A mutation was performed */
|
|
@@ -1997,6 +2016,11 @@ export declare type ListenEventName =
|
|
|
1997
2016
|
| 'welcome'
|
|
1998
2017
|
/** The listener has been disconnected, and a reconnect attempt is scheduled */
|
|
1999
2018
|
| 'reconnect'
|
|
2019
|
+
/**
|
|
2020
|
+
* The listener connection has been established
|
|
2021
|
+
* note: it's usually a better option to use the 'welcome' event
|
|
2022
|
+
*/
|
|
2023
|
+
| 'open'
|
|
2000
2024
|
|
|
2001
2025
|
/** @public */
|
|
2002
2026
|
export declare interface ListenOptions {
|
|
@@ -2131,6 +2155,30 @@ export declare type Logger =
|
|
|
2131
2155
|
Pick<typeof console, 'debug' | 'error' | 'groupCollapsed' | 'groupEnd' | 'log' | 'table'>
|
|
2132
2156
|
>
|
|
2133
2157
|
|
|
2158
|
+
/**
|
|
2159
|
+
* Maps an array of listen events names to their corresponding listen event type, e.g:
|
|
2160
|
+
* ```
|
|
2161
|
+
* type Test = MapListenEventNamesToListenEvents<Doc, ['welcome']>
|
|
2162
|
+
* // ^? WelcomeEvent
|
|
2163
|
+
* ```
|
|
2164
|
+
*
|
|
2165
|
+
* @public
|
|
2166
|
+
*/
|
|
2167
|
+
declare type MapListenEventNamesToListenEvents<
|
|
2168
|
+
R extends Record<string, Any> = Record<string, Any>,
|
|
2169
|
+
Events extends ListenEventName[] = ListenEventName[],
|
|
2170
|
+
> = Events extends (infer E)[]
|
|
2171
|
+
? E extends 'welcome'
|
|
2172
|
+
? WelcomeEvent
|
|
2173
|
+
: E extends 'mutation'
|
|
2174
|
+
? MutationEvent<R>
|
|
2175
|
+
: E extends 'reconnect'
|
|
2176
|
+
? ReconnectEvent
|
|
2177
|
+
: E extends 'open'
|
|
2178
|
+
? OpenEvent
|
|
2179
|
+
: never
|
|
2180
|
+
: never
|
|
2181
|
+
|
|
2134
2182
|
/** @public */
|
|
2135
2183
|
export declare type MediaLibraryAssetInstanceIdentifier = string | SanityReference
|
|
2136
2184
|
|
|
@@ -3289,7 +3337,7 @@ export declare class ObservableSanityClient {
|
|
|
3289
3337
|
createVersion(
|
|
3290
3338
|
args: {
|
|
3291
3339
|
baseId: string
|
|
3292
|
-
releaseId
|
|
3340
|
+
releaseId?: string
|
|
3293
3341
|
publishedId: string
|
|
3294
3342
|
ifBaseRevisionId?: string
|
|
3295
3343
|
},
|
|
@@ -5102,7 +5150,7 @@ export declare class SanityClient {
|
|
|
5102
5150
|
args: {
|
|
5103
5151
|
publishedId: string
|
|
5104
5152
|
baseId: string
|
|
5105
|
-
releaseId
|
|
5153
|
+
releaseId?: string
|
|
5106
5154
|
ifBaseRevisionId?: string
|
|
5107
5155
|
},
|
|
5108
5156
|
options?: BaseActionOptions,
|
package/dist/index.browser.d.ts
CHANGED
|
@@ -1973,22 +1973,41 @@ export declare function _listen<R extends Record<string, Any> = Record<string, A
|
|
|
1973
1973
|
* @param options - Optional listener options
|
|
1974
1974
|
* @public
|
|
1975
1975
|
*/
|
|
1976
|
-
export declare function _listen<
|
|
1976
|
+
export declare function _listen<
|
|
1977
|
+
R extends Record<string, Any> = Record<string, Any>,
|
|
1978
|
+
Opts extends ListenOptions = ListenOptions,
|
|
1979
|
+
>(
|
|
1977
1980
|
this: SanityClient | ObservableSanityClient,
|
|
1978
1981
|
query: string,
|
|
1979
1982
|
params?: ListenParams,
|
|
1980
|
-
options?:
|
|
1981
|
-
): Observable<
|
|
1983
|
+
options?: Opts,
|
|
1984
|
+
): Observable<ListenEventFromOptions<R, Opts>>
|
|
1982
1985
|
|
|
1983
1986
|
/** @public */
|
|
1984
1987
|
export declare type ListenEvent<R extends Record<string, Any>> =
|
|
1985
1988
|
| MutationEvent<R>
|
|
1986
|
-
| ChannelErrorEvent
|
|
1987
|
-
| DisconnectEvent
|
|
1988
1989
|
| ReconnectEvent
|
|
1989
1990
|
| WelcomeEvent
|
|
1990
1991
|
| OpenEvent
|
|
1991
1992
|
|
|
1993
|
+
/**
|
|
1994
|
+
* Maps a ListenOptions object and returns the Listen events opted for, e.g:
|
|
1995
|
+
* ```
|
|
1996
|
+
* type Test = ListenEventFromOptions<Doc, {events: ['welcome', 'mutation']}>
|
|
1997
|
+
* // ^? WelcomeEvent | MutationEvent<Doc>
|
|
1998
|
+
* ```
|
|
1999
|
+
*
|
|
2000
|
+
* @public
|
|
2001
|
+
*/
|
|
2002
|
+
declare type ListenEventFromOptions<
|
|
2003
|
+
R extends Record<string, Any> = Record<string, Any>,
|
|
2004
|
+
Opts extends ListenOptions | undefined = undefined,
|
|
2005
|
+
> = Opts extends ListenOptions
|
|
2006
|
+
? Opts['events'] extends ListenEventName[]
|
|
2007
|
+
? MapListenEventNamesToListenEvents<R, Opts['events']>
|
|
2008
|
+
: ListenEvent<R>
|
|
2009
|
+
: MutationEvent<R>
|
|
2010
|
+
|
|
1992
2011
|
/** @public */
|
|
1993
2012
|
export declare type ListenEventName =
|
|
1994
2013
|
/** A mutation was performed */
|
|
@@ -1997,6 +2016,11 @@ export declare type ListenEventName =
|
|
|
1997
2016
|
| 'welcome'
|
|
1998
2017
|
/** The listener has been disconnected, and a reconnect attempt is scheduled */
|
|
1999
2018
|
| 'reconnect'
|
|
2019
|
+
/**
|
|
2020
|
+
* The listener connection has been established
|
|
2021
|
+
* note: it's usually a better option to use the 'welcome' event
|
|
2022
|
+
*/
|
|
2023
|
+
| 'open'
|
|
2000
2024
|
|
|
2001
2025
|
/** @public */
|
|
2002
2026
|
export declare interface ListenOptions {
|
|
@@ -2131,6 +2155,30 @@ export declare type Logger =
|
|
|
2131
2155
|
Pick<typeof console, 'debug' | 'error' | 'groupCollapsed' | 'groupEnd' | 'log' | 'table'>
|
|
2132
2156
|
>
|
|
2133
2157
|
|
|
2158
|
+
/**
|
|
2159
|
+
* Maps an array of listen events names to their corresponding listen event type, e.g:
|
|
2160
|
+
* ```
|
|
2161
|
+
* type Test = MapListenEventNamesToListenEvents<Doc, ['welcome']>
|
|
2162
|
+
* // ^? WelcomeEvent
|
|
2163
|
+
* ```
|
|
2164
|
+
*
|
|
2165
|
+
* @public
|
|
2166
|
+
*/
|
|
2167
|
+
declare type MapListenEventNamesToListenEvents<
|
|
2168
|
+
R extends Record<string, Any> = Record<string, Any>,
|
|
2169
|
+
Events extends ListenEventName[] = ListenEventName[],
|
|
2170
|
+
> = Events extends (infer E)[]
|
|
2171
|
+
? E extends 'welcome'
|
|
2172
|
+
? WelcomeEvent
|
|
2173
|
+
: E extends 'mutation'
|
|
2174
|
+
? MutationEvent<R>
|
|
2175
|
+
: E extends 'reconnect'
|
|
2176
|
+
? ReconnectEvent
|
|
2177
|
+
: E extends 'open'
|
|
2178
|
+
? OpenEvent
|
|
2179
|
+
: never
|
|
2180
|
+
: never
|
|
2181
|
+
|
|
2134
2182
|
/** @public */
|
|
2135
2183
|
export declare type MediaLibraryAssetInstanceIdentifier = string | SanityReference
|
|
2136
2184
|
|
|
@@ -3289,7 +3337,7 @@ export declare class ObservableSanityClient {
|
|
|
3289
3337
|
createVersion(
|
|
3290
3338
|
args: {
|
|
3291
3339
|
baseId: string
|
|
3292
|
-
releaseId
|
|
3340
|
+
releaseId?: string
|
|
3293
3341
|
publishedId: string
|
|
3294
3342
|
ifBaseRevisionId?: string
|
|
3295
3343
|
},
|
|
@@ -5102,7 +5150,7 @@ export declare class SanityClient {
|
|
|
5102
5150
|
args: {
|
|
5103
5151
|
publishedId: string
|
|
5104
5152
|
baseId: string
|
|
5105
|
-
releaseId
|
|
5153
|
+
releaseId?: string
|
|
5106
5154
|
ifBaseRevisionId?: string
|
|
5107
5155
|
},
|
|
5108
5156
|
options?: BaseActionOptions,
|
package/dist/index.browser.js
CHANGED
|
@@ -1386,12 +1386,10 @@ function _listen(query, params, opts = {}) {
|
|
|
1386
1386
|
), listenFor).pipe(
|
|
1387
1387
|
reconnectOnConnectionFailure(),
|
|
1388
1388
|
filter((event) => listenFor.includes(event.type)),
|
|
1389
|
-
map(
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
})
|
|
1394
|
-
)
|
|
1389
|
+
map((event) => ({
|
|
1390
|
+
type: event.type,
|
|
1391
|
+
..."data" in event ? event.data : {}
|
|
1392
|
+
}))
|
|
1395
1393
|
);
|
|
1396
1394
|
}
|
|
1397
1395
|
function shareReplayLatest(configOrPredicate, config) {
|