@sanity/client 6.29.1 → 7.0.1-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.map +1 -1
- package/dist/_chunks-cjs/stegaEncodeSourceMap.cjs.map +1 -1
- package/dist/_chunks-es/resolveEditInfo.js.map +1 -1
- package/dist/_chunks-es/stegaEncodeSourceMap.js.map +1 -1
- package/dist/index.browser.cjs +2 -14
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.d.cts +1366 -337
- package/dist/index.browser.d.ts +1366 -337
- package/dist/index.browser.js +2 -14
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +3 -15
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1366 -337
- package/dist/index.d.ts +1366 -337
- package/dist/index.js +3 -15
- package/dist/index.js.map +1 -1
- package/dist/stega.browser.d.cts +1403 -374
- package/dist/stega.browser.d.ts +1403 -374
- package/dist/stega.d.cts +1403 -374
- package/dist/stega.d.ts +1403 -374
- package/package.json +3 -2
- package/src/SanityClient.ts +1069 -17
- package/src/csm/draftUtils.ts +1 -1
- package/src/util/shareReplayLatest.ts +1 -1
- package/umd/sanityClient.js +2 -14
package/dist/index.browser.d.cts
CHANGED
|
@@ -1455,16 +1455,13 @@ export declare class ObservableProjectsClient {
|
|
|
1455
1455
|
}
|
|
1456
1456
|
|
|
1457
1457
|
/** @public */
|
|
1458
|
-
export declare class ObservableSanityClient {
|
|
1458
|
+
export declare class ObservableSanityClient implements ObservableSanityClientType {
|
|
1459
1459
|
#private
|
|
1460
1460
|
assets: ObservableAssetsClient
|
|
1461
1461
|
datasets: ObservableDatasetsClient
|
|
1462
1462
|
live: LiveClient
|
|
1463
1463
|
projects: ObservableProjectsClient
|
|
1464
1464
|
users: ObservableUsersClient
|
|
1465
|
-
/**
|
|
1466
|
-
* Instance properties
|
|
1467
|
-
*/
|
|
1468
1465
|
listen: typeof _listen
|
|
1469
1466
|
constructor(httpRequest: HttpRequest, config?: ClientConfig)
|
|
1470
1467
|
/**
|
|
@@ -1523,7 +1520,7 @@ export declare class ObservableSanityClient {
|
|
|
1523
1520
|
Q extends QueryWithoutParams | QueryParams = QueryParams,
|
|
1524
1521
|
const G extends string = string,
|
|
1525
1522
|
>(
|
|
1526
|
-
query:
|
|
1523
|
+
query: G,
|
|
1527
1524
|
params: Q extends QueryWithoutParams ? QueryWithoutParams : Q,
|
|
1528
1525
|
options: UnfilteredResponseQueryOptions,
|
|
1529
1526
|
): Observable<RawQueryResponse<ClientReturn<G, R>>>
|
|
@@ -1958,138 +1955,630 @@ export declare class ObservableSanityClient {
|
|
|
1958
1955
|
getDataUrl(operation: string, path?: string): string
|
|
1959
1956
|
}
|
|
1960
1957
|
|
|
1961
|
-
/**
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1958
|
+
/**
|
|
1959
|
+
* The interface implemented by the `ObservableSanityClient` class.
|
|
1960
|
+
* When writing code that wants to take an instance of `ObservableSanityClient` as input it's better to use this type,
|
|
1961
|
+
* as the `ObservableSanityClient` class has private properties and thus TypeScrict will consider the type incompatible
|
|
1962
|
+
* in cases where you might have multiple `@sanity/client` instances in your node_modules.
|
|
1963
|
+
* @public
|
|
1964
|
+
*/
|
|
1965
|
+
export declare interface ObservableSanityClientType extends SanityClientBase {
|
|
1966
|
+
assets: ObservableAssetsClient
|
|
1967
|
+
datasets: ObservableDatasetsClient
|
|
1968
|
+
projects: ObservableProjectsClient
|
|
1969
|
+
users: ObservableUsersClient
|
|
1965
1970
|
/**
|
|
1966
|
-
*
|
|
1971
|
+
* Clone the client - returns a new instance
|
|
1967
1972
|
*/
|
|
1968
|
-
clone():
|
|
1973
|
+
clone(): ObservableSanityClient
|
|
1969
1974
|
/**
|
|
1970
|
-
*
|
|
1975
|
+
* Clone the client with a new (partial) configuration.
|
|
1971
1976
|
*
|
|
1972
|
-
* @param
|
|
1977
|
+
* @param newConfig - New client configuration properties, shallowly merged with existing configuration
|
|
1973
1978
|
*/
|
|
1974
|
-
|
|
1975
|
-
options: TransactionFirstDocumentMutationOptions,
|
|
1976
|
-
): Observable<SanityDocument<R>>
|
|
1979
|
+
withConfig(newConfig?: Partial<ClientConfig>): ObservableSanityClient
|
|
1977
1980
|
/**
|
|
1978
|
-
*
|
|
1981
|
+
* Perform a GROQ-query against the configured dataset.
|
|
1979
1982
|
*
|
|
1980
|
-
* @param
|
|
1983
|
+
* @param query - GROQ-query to perform
|
|
1981
1984
|
*/
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
+
fetch<
|
|
1986
|
+
R = Any,
|
|
1987
|
+
Q extends QueryWithoutParams = QueryWithoutParams,
|
|
1988
|
+
const G extends string = string,
|
|
1989
|
+
>(
|
|
1990
|
+
query: G,
|
|
1991
|
+
params?: Q | QueryWithoutParams,
|
|
1992
|
+
): Observable<ClientReturn<G, R>>
|
|
1985
1993
|
/**
|
|
1986
|
-
*
|
|
1994
|
+
* Perform a GROQ-query against the configured dataset.
|
|
1987
1995
|
*
|
|
1988
|
-
* @param
|
|
1996
|
+
* @param query - GROQ-query to perform
|
|
1997
|
+
* @param params - Optional query parameters
|
|
1998
|
+
* @param options - Optional request options
|
|
1989
1999
|
*/
|
|
1990
|
-
|
|
2000
|
+
fetch<
|
|
2001
|
+
R = Any,
|
|
2002
|
+
Q extends QueryWithoutParams | QueryParams = QueryParams,
|
|
2003
|
+
const G extends string = string,
|
|
2004
|
+
>(
|
|
2005
|
+
query: G,
|
|
2006
|
+
params: Q extends QueryWithoutParams ? QueryWithoutParams : Q,
|
|
2007
|
+
options?: FilteredResponseQueryOptions,
|
|
2008
|
+
): Observable<ClientReturn<G, R>>
|
|
1991
2009
|
/**
|
|
1992
|
-
*
|
|
2010
|
+
* Perform a GROQ-query against the configured dataset.
|
|
1993
2011
|
*
|
|
1994
|
-
* @param
|
|
2012
|
+
* @param query - GROQ-query to perform
|
|
2013
|
+
* @param params - Optional query parameters
|
|
2014
|
+
* @param options - Request options
|
|
1995
2015
|
*/
|
|
1996
|
-
|
|
2016
|
+
fetch<
|
|
2017
|
+
R = Any,
|
|
2018
|
+
Q extends QueryWithoutParams | QueryParams = QueryParams,
|
|
2019
|
+
const G extends string = string,
|
|
2020
|
+
>(
|
|
2021
|
+
query: G,
|
|
2022
|
+
params: Q extends QueryWithoutParams ? QueryWithoutParams : Q,
|
|
2023
|
+
options: UnfilteredResponseQueryOptions,
|
|
2024
|
+
): Observable<RawQueryResponse<ClientReturn<G, R>>>
|
|
1997
2025
|
/**
|
|
1998
|
-
*
|
|
2026
|
+
* Perform a GROQ-query against the configured dataset.
|
|
1999
2027
|
*
|
|
2000
|
-
* @param
|
|
2028
|
+
* @param query - GROQ-query to perform
|
|
2029
|
+
* @param params - Optional query parameters
|
|
2030
|
+
* @param options - Request options
|
|
2001
2031
|
*/
|
|
2002
|
-
|
|
2032
|
+
fetch<
|
|
2033
|
+
R = Any,
|
|
2034
|
+
Q extends QueryWithoutParams | QueryParams = QueryParams,
|
|
2035
|
+
const G extends string = string,
|
|
2036
|
+
>(
|
|
2037
|
+
query: G,
|
|
2038
|
+
params: Q extends QueryWithoutParams ? QueryWithoutParams : Q,
|
|
2039
|
+
options: UnfilteredResponseWithoutQuery,
|
|
2040
|
+
): Observable<RawQuerylessQueryResponse<ClientReturn<G, R>>>
|
|
2003
2041
|
/**
|
|
2004
|
-
*
|
|
2005
|
-
* The operation is added to the current transaction, ready to be commited by `commit()`
|
|
2042
|
+
* Fetch a single document with the given ID.
|
|
2006
2043
|
*
|
|
2007
|
-
* @param
|
|
2008
|
-
* @param
|
|
2044
|
+
* @param id - Document ID to fetch
|
|
2045
|
+
* @param options - Request options
|
|
2009
2046
|
*/
|
|
2010
|
-
|
|
2047
|
+
getDocument<R extends Record<string, Any> = Record<string, Any>>(
|
|
2048
|
+
id: string,
|
|
2049
|
+
options?: {
|
|
2050
|
+
tag?: string
|
|
2051
|
+
},
|
|
2052
|
+
): Observable<SanityDocument<R> | undefined>
|
|
2011
2053
|
/**
|
|
2012
|
-
*
|
|
2013
|
-
*
|
|
2054
|
+
* Fetch multiple documents in one request.
|
|
2055
|
+
* Should be used sparingly - performing a query is usually a better option.
|
|
2056
|
+
* The order/position of documents is preserved based on the original array of IDs.
|
|
2057
|
+
* If any of the documents are missing, they will be replaced by a `null` entry in the returned array
|
|
2014
2058
|
*
|
|
2015
|
-
* @param
|
|
2059
|
+
* @param ids - Document IDs to fetch
|
|
2060
|
+
* @param options - Request options
|
|
2016
2061
|
*/
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
constructor(client: ObservableSanityClient, httpRequest: HttpRequest)
|
|
2062
|
+
getDocuments<R extends Record<string, Any> = Record<string, Any>>(
|
|
2063
|
+
ids: string[],
|
|
2064
|
+
options?: {
|
|
2065
|
+
tag?: string
|
|
2066
|
+
},
|
|
2067
|
+
): Observable<(SanityDocument<R> | null)[]>
|
|
2024
2068
|
/**
|
|
2025
|
-
*
|
|
2069
|
+
* Create a document. Requires a `_type` property. If no `_id` is provided, it will be generated by the database.
|
|
2070
|
+
* Returns an observable that resolves to the created document.
|
|
2026
2071
|
*
|
|
2027
|
-
* @param
|
|
2072
|
+
* @param document - Document to create
|
|
2073
|
+
* @param options - Mutation options
|
|
2028
2074
|
*/
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
/**
|
|
2035
|
-
* The listener connection has been established
|
|
2036
|
-
* note: it's usually a better option to use the 'welcome' event
|
|
2037
|
-
* @public
|
|
2038
|
-
*/
|
|
2039
|
-
export declare type OpenEvent = {
|
|
2040
|
-
type: 'open'
|
|
2041
|
-
}
|
|
2042
|
-
|
|
2043
|
-
/** @public */
|
|
2044
|
-
export declare class Patch extends BasePatch {
|
|
2045
|
-
#private
|
|
2046
|
-
constructor(selection: PatchSelection, operations?: PatchOperations, client?: SanityClient)
|
|
2075
|
+
create<R extends Record<string, Any> = Record<string, Any>>(
|
|
2076
|
+
document: SanityDocumentStub<R>,
|
|
2077
|
+
options: FirstDocumentMutationOptions,
|
|
2078
|
+
): Observable<SanityDocument<R>>
|
|
2047
2079
|
/**
|
|
2048
|
-
*
|
|
2080
|
+
* Create a document. Requires a `_type` property. If no `_id` is provided, it will be generated by the database.
|
|
2081
|
+
* Returns an observable that resolves to an array containing the created document.
|
|
2082
|
+
*
|
|
2083
|
+
* @param document - Document to create
|
|
2084
|
+
* @param options - Mutation options
|
|
2049
2085
|
*/
|
|
2050
|
-
|
|
2086
|
+
create<R extends Record<string, Any> = Record<string, Any>>(
|
|
2087
|
+
document: SanityDocumentStub<R>,
|
|
2088
|
+
options: AllDocumentsMutationOptions,
|
|
2089
|
+
): Observable<SanityDocument<R>[]>
|
|
2051
2090
|
/**
|
|
2052
|
-
*
|
|
2091
|
+
* Create a document. Requires a `_type` property. If no `_id` is provided, it will be generated by the database.
|
|
2092
|
+
* Returns an observable that resolves to a mutation result object containing the ID of the created document.
|
|
2053
2093
|
*
|
|
2054
|
-
* @param
|
|
2094
|
+
* @param document - Document to create
|
|
2095
|
+
* @param options - Mutation options
|
|
2055
2096
|
*/
|
|
2056
|
-
|
|
2097
|
+
create<R extends Record<string, Any> = Record<string, Any>>(
|
|
2098
|
+
document: SanityDocumentStub<R>,
|
|
2099
|
+
options: FirstDocumentIdMutationOptions,
|
|
2100
|
+
): Observable<SingleMutationResult>
|
|
2101
|
+
/**
|
|
2102
|
+
* Create a document. Requires a `_type` property. If no `_id` is provided, it will be generated by the database.
|
|
2103
|
+
* Returns an observable that resolves to a mutation result object containing the ID of the created document.
|
|
2104
|
+
*
|
|
2105
|
+
* @param document - Document to create
|
|
2106
|
+
* @param options - Mutation options
|
|
2107
|
+
*/
|
|
2108
|
+
create<R extends Record<string, Any> = Record<string, Any>>(
|
|
2109
|
+
document: SanityDocumentStub<R>,
|
|
2110
|
+
options: AllDocumentIdsMutationOptions,
|
|
2111
|
+
): Observable<MultipleMutationResult>
|
|
2112
|
+
/**
|
|
2113
|
+
* Create a document. Requires a `_type` property. If no `_id` is provided, it will be generated by the database.
|
|
2114
|
+
* Returns an observable that resolves to the created document.
|
|
2115
|
+
*
|
|
2116
|
+
* @param document - Document to create
|
|
2117
|
+
* @param options - Mutation options
|
|
2118
|
+
*/
|
|
2119
|
+
create<R extends Record<string, Any> = Record<string, Any>>(
|
|
2120
|
+
document: SanityDocumentStub<R>,
|
|
2121
|
+
options?: BaseMutationOptions,
|
|
2122
|
+
): Observable<SanityDocument<R>>
|
|
2123
|
+
/**
|
|
2124
|
+
* Create a document if no document with the same ID already exists.
|
|
2125
|
+
* Returns an observable that resolves to the created document.
|
|
2126
|
+
*
|
|
2127
|
+
* @param document - Document to create
|
|
2128
|
+
* @param options - Mutation options
|
|
2129
|
+
*/
|
|
2130
|
+
createIfNotExists<R extends Record<string, Any> = Record<string, Any>>(
|
|
2131
|
+
document: IdentifiedSanityDocumentStub<R>,
|
|
2057
2132
|
options: FirstDocumentMutationOptions,
|
|
2058
|
-
):
|
|
2133
|
+
): Observable<SanityDocument<R>>
|
|
2059
2134
|
/**
|
|
2060
|
-
*
|
|
2135
|
+
* Create a document if no document with the same ID already exists.
|
|
2136
|
+
* Returns an observable that resolves to an array containing the created document.
|
|
2061
2137
|
*
|
|
2062
|
-
* @param
|
|
2138
|
+
* @param document - Document to create
|
|
2139
|
+
* @param options - Mutation options
|
|
2063
2140
|
*/
|
|
2064
|
-
|
|
2141
|
+
createIfNotExists<R extends Record<string, Any> = Record<string, Any>>(
|
|
2142
|
+
document: IdentifiedSanityDocumentStub<R>,
|
|
2065
2143
|
options: AllDocumentsMutationOptions,
|
|
2066
|
-
):
|
|
2144
|
+
): Observable<SanityDocument<R>[]>
|
|
2067
2145
|
/**
|
|
2068
|
-
*
|
|
2146
|
+
* Create a document if no document with the same ID already exists.
|
|
2147
|
+
* Returns an observable that resolves to a mutation result object containing the ID of the created document.
|
|
2069
2148
|
*
|
|
2070
|
-
* @param
|
|
2149
|
+
* @param document - Document to create
|
|
2150
|
+
* @param options - Mutation options
|
|
2071
2151
|
*/
|
|
2072
|
-
|
|
2152
|
+
createIfNotExists<R extends Record<string, Any> = Record<string, Any>>(
|
|
2153
|
+
document: IdentifiedSanityDocumentStub<R>,
|
|
2154
|
+
options: FirstDocumentIdMutationOptions,
|
|
2155
|
+
): Observable<SingleMutationResult>
|
|
2073
2156
|
/**
|
|
2074
|
-
*
|
|
2157
|
+
* Create a document if no document with the same ID already exists.
|
|
2158
|
+
* Returns an observable that resolves to a mutation result object containing the ID of the created document.
|
|
2075
2159
|
*
|
|
2076
|
-
* @param
|
|
2160
|
+
* @param document - Document to create
|
|
2161
|
+
* @param options - Mutation options
|
|
2077
2162
|
*/
|
|
2078
|
-
|
|
2163
|
+
createIfNotExists<R extends Record<string, Any> = Record<string, Any>>(
|
|
2164
|
+
document: IdentifiedSanityDocumentStub<R>,
|
|
2165
|
+
options: AllDocumentIdsMutationOptions,
|
|
2166
|
+
): Observable<MultipleMutationResult>
|
|
2079
2167
|
/**
|
|
2080
|
-
*
|
|
2168
|
+
* Create a document if no document with the same ID already exists.
|
|
2169
|
+
* Returns an observable that resolves to the created document.
|
|
2081
2170
|
*
|
|
2082
|
-
* @param
|
|
2171
|
+
* @param document - Document to create
|
|
2172
|
+
* @param options - Mutation options
|
|
2083
2173
|
*/
|
|
2084
|
-
|
|
2174
|
+
createIfNotExists<R extends Record<string, Any> = Record<string, Any>>(
|
|
2175
|
+
document: IdentifiedSanityDocumentStub<R>,
|
|
2085
2176
|
options?: BaseMutationOptions,
|
|
2086
|
-
):
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2177
|
+
): Observable<SanityDocument<R>>
|
|
2178
|
+
/**
|
|
2179
|
+
* Create a document if it does not exist, or replace a document with the same document ID
|
|
2180
|
+
* Returns an observable that resolves to the created document.
|
|
2181
|
+
*
|
|
2182
|
+
* @param document - Document to either create or replace
|
|
2183
|
+
* @param options - Mutation options
|
|
2184
|
+
*/
|
|
2185
|
+
createOrReplace<R extends Record<string, Any> = Record<string, Any>>(
|
|
2186
|
+
document: IdentifiedSanityDocumentStub<R>,
|
|
2187
|
+
options: FirstDocumentMutationOptions,
|
|
2188
|
+
): Observable<SanityDocument<R>>
|
|
2189
|
+
/**
|
|
2190
|
+
* Create a document if it does not exist, or replace a document with the same document ID
|
|
2191
|
+
* Returns an observable that resolves to an array containing the created document.
|
|
2192
|
+
*
|
|
2193
|
+
* @param document - Document to either create or replace
|
|
2194
|
+
* @param options - Mutation options
|
|
2195
|
+
*/
|
|
2196
|
+
createOrReplace<R extends Record<string, Any> = Record<string, Any>>(
|
|
2197
|
+
document: IdentifiedSanityDocumentStub<R>,
|
|
2198
|
+
options: AllDocumentsMutationOptions,
|
|
2199
|
+
): Observable<SanityDocument<R>[]>
|
|
2200
|
+
/**
|
|
2201
|
+
* Create a document if it does not exist, or replace a document with the same document ID
|
|
2202
|
+
* Returns an observable that resolves to a mutation result object containing the ID of the created document.
|
|
2203
|
+
*
|
|
2204
|
+
* @param document - Document to either create or replace
|
|
2205
|
+
* @param options - Mutation options
|
|
2206
|
+
*/
|
|
2207
|
+
createOrReplace<R extends Record<string, Any> = Record<string, Any>>(
|
|
2208
|
+
document: IdentifiedSanityDocumentStub<R>,
|
|
2209
|
+
options: FirstDocumentIdMutationOptions,
|
|
2210
|
+
): Observable<SingleMutationResult>
|
|
2211
|
+
/**
|
|
2212
|
+
* Create a document if it does not exist, or replace a document with the same document ID
|
|
2213
|
+
* Returns an observable that resolves to a mutation result object containing the created document ID.
|
|
2214
|
+
*
|
|
2215
|
+
* @param document - Document to either create or replace
|
|
2216
|
+
* @param options - Mutation options
|
|
2217
|
+
*/
|
|
2218
|
+
createOrReplace<R extends Record<string, Any> = Record<string, Any>>(
|
|
2219
|
+
document: IdentifiedSanityDocumentStub<R>,
|
|
2220
|
+
options: AllDocumentIdsMutationOptions,
|
|
2221
|
+
): Observable<MultipleMutationResult>
|
|
2222
|
+
/**
|
|
2223
|
+
* Create a document if it does not exist, or replace a document with the same document ID
|
|
2224
|
+
* Returns an observable that resolves to the created document.
|
|
2225
|
+
*
|
|
2226
|
+
* @param document - Document to either create or replace
|
|
2227
|
+
* @param options - Mutation options
|
|
2228
|
+
*/
|
|
2229
|
+
createOrReplace<R extends Record<string, Any> = Record<string, Any>>(
|
|
2230
|
+
document: IdentifiedSanityDocumentStub<R>,
|
|
2231
|
+
options?: BaseMutationOptions,
|
|
2232
|
+
): Observable<SanityDocument<R>>
|
|
2233
|
+
/**
|
|
2234
|
+
* Deletes a document with the given document ID.
|
|
2235
|
+
* Returns an observable that resolves to the deleted document.
|
|
2236
|
+
*
|
|
2237
|
+
* @param id - Document ID to delete
|
|
2238
|
+
* @param options - Options for the mutation
|
|
2239
|
+
*/
|
|
2240
|
+
delete<R extends Record<string, Any> = Record<string, Any>>(
|
|
2241
|
+
id: string,
|
|
2242
|
+
options: FirstDocumentMutationOptions,
|
|
2243
|
+
): Observable<SanityDocument<R>>
|
|
2244
|
+
/**
|
|
2245
|
+
* Deletes a document with the given document ID.
|
|
2246
|
+
* Returns an observable that resolves to an array containing the deleted document.
|
|
2247
|
+
*
|
|
2248
|
+
* @param id - Document ID to delete
|
|
2249
|
+
* @param options - Options for the mutation
|
|
2250
|
+
*/
|
|
2251
|
+
delete<R extends Record<string, Any> = Record<string, Any>>(
|
|
2252
|
+
id: string,
|
|
2253
|
+
options: AllDocumentsMutationOptions,
|
|
2254
|
+
): Observable<SanityDocument<R>[]>
|
|
2255
|
+
/**
|
|
2256
|
+
* Deletes a document with the given document ID.
|
|
2257
|
+
* Returns an observable that resolves to a mutation result object containing the deleted document ID.
|
|
2258
|
+
*
|
|
2259
|
+
* @param id - Document ID to delete
|
|
2260
|
+
* @param options - Options for the mutation
|
|
2261
|
+
*/
|
|
2262
|
+
delete(id: string, options: FirstDocumentIdMutationOptions): Observable<SingleMutationResult>
|
|
2263
|
+
/**
|
|
2264
|
+
* Deletes a document with the given document ID.
|
|
2265
|
+
* Returns an observable that resolves to a mutation result object containing the deleted document ID.
|
|
2266
|
+
*
|
|
2267
|
+
* @param id - Document ID to delete
|
|
2268
|
+
* @param options - Options for the mutation
|
|
2269
|
+
*/
|
|
2270
|
+
delete(id: string, options: AllDocumentIdsMutationOptions): Observable<MultipleMutationResult>
|
|
2271
|
+
/**
|
|
2272
|
+
* Deletes a document with the given document ID.
|
|
2273
|
+
* Returns an observable that resolves to the deleted document.
|
|
2274
|
+
*
|
|
2275
|
+
* @param id - Document ID to delete
|
|
2276
|
+
* @param options - Options for the mutation
|
|
2277
|
+
*/
|
|
2278
|
+
delete<R extends Record<string, Any> = Record<string, Any>>(
|
|
2279
|
+
id: string,
|
|
2280
|
+
options?: BaseMutationOptions,
|
|
2281
|
+
): Observable<SanityDocument<R>>
|
|
2282
|
+
/**
|
|
2283
|
+
* Deletes one or more documents matching the given query or document ID.
|
|
2284
|
+
* Returns an observable that resolves to first deleted document.
|
|
2285
|
+
*
|
|
2286
|
+
* @param selection - An object with either an `id` or `query` key defining what to delete
|
|
2287
|
+
* @param options - Options for the mutation
|
|
2288
|
+
*/
|
|
2289
|
+
delete<R extends Record<string, Any> = Record<string, Any>>(
|
|
2290
|
+
selection: MutationSelection,
|
|
2291
|
+
options: FirstDocumentMutationOptions,
|
|
2292
|
+
): Observable<SanityDocument<R>>
|
|
2293
|
+
/**
|
|
2294
|
+
* Deletes one or more documents matching the given query or document ID.
|
|
2295
|
+
* Returns an observable that resolves to an array containing the deleted documents.
|
|
2296
|
+
*
|
|
2297
|
+
* @param selection - An object with either an `id` or `query` key defining what to delete
|
|
2298
|
+
* @param options - Options for the mutation
|
|
2299
|
+
*/
|
|
2300
|
+
delete<R extends Record<string, Any> = Record<string, Any>>(
|
|
2301
|
+
selection: MutationSelection,
|
|
2302
|
+
options: AllDocumentsMutationOptions,
|
|
2303
|
+
): Observable<SanityDocument<R>[]>
|
|
2304
|
+
/**
|
|
2305
|
+
* Deletes one or more documents matching the given query or document ID.
|
|
2306
|
+
* Returns an observable that resolves to a mutation result object containing the ID of the first deleted document.
|
|
2307
|
+
*
|
|
2308
|
+
* @param selection - An object with either an `id` or `query` key defining what to delete
|
|
2309
|
+
* @param options - Options for the mutation
|
|
2310
|
+
*/
|
|
2311
|
+
delete(
|
|
2312
|
+
selection: MutationSelection,
|
|
2313
|
+
options: FirstDocumentIdMutationOptions,
|
|
2314
|
+
): Observable<SingleMutationResult>
|
|
2315
|
+
/**
|
|
2316
|
+
* Deletes one or more documents matching the given query or document ID.
|
|
2317
|
+
* Returns an observable that resolves to a mutation result object containing the document IDs that were deleted.
|
|
2318
|
+
*
|
|
2319
|
+
* @param selection - An object with either an `id` or `query` key defining what to delete
|
|
2320
|
+
* @param options - Options for the mutation
|
|
2321
|
+
*/
|
|
2322
|
+
delete(
|
|
2323
|
+
selection: MutationSelection,
|
|
2324
|
+
options: AllDocumentIdsMutationOptions,
|
|
2325
|
+
): Observable<MultipleMutationResult>
|
|
2326
|
+
/**
|
|
2327
|
+
* Deletes one or more documents matching the given query or document ID.
|
|
2328
|
+
* Returns an observable that resolves to first deleted document.
|
|
2329
|
+
*
|
|
2330
|
+
* @param selection - An object with either an `id` or `query` key defining what to delete
|
|
2331
|
+
* @param options - Options for the mutation
|
|
2332
|
+
*/
|
|
2333
|
+
delete<R extends Record<string, Any> = Record<string, Any>>(
|
|
2334
|
+
selection: MutationSelection,
|
|
2335
|
+
options?: BaseMutationOptions,
|
|
2336
|
+
): Observable<SanityDocument<R>>
|
|
2337
|
+
/**
|
|
2338
|
+
* Perform mutation operations against the configured dataset
|
|
2339
|
+
* Returns an observable that resolves to the first mutated document.
|
|
2340
|
+
*
|
|
2341
|
+
* @param operations - Mutation operations to execute
|
|
2342
|
+
* @param options - Mutation options
|
|
2343
|
+
*/
|
|
2344
|
+
mutate<R extends Record<string, Any> = Record<string, Any>>(
|
|
2345
|
+
operations: Mutation<R>[] | ObservablePatch | ObservableTransaction,
|
|
2346
|
+
options: FirstDocumentMutationOptions,
|
|
2347
|
+
): Observable<SanityDocument<R>>
|
|
2348
|
+
/**
|
|
2349
|
+
* Perform mutation operations against the configured dataset.
|
|
2350
|
+
* Returns an observable that resolves to an array of the mutated documents.
|
|
2351
|
+
*
|
|
2352
|
+
* @param operations - Mutation operations to execute
|
|
2353
|
+
* @param options - Mutation options
|
|
2354
|
+
*/
|
|
2355
|
+
mutate<R extends Record<string, Any> = Record<string, Any>>(
|
|
2356
|
+
operations: Mutation<R>[] | ObservablePatch | ObservableTransaction,
|
|
2357
|
+
options: AllDocumentsMutationOptions,
|
|
2358
|
+
): Observable<SanityDocument<R>[]>
|
|
2359
|
+
/**
|
|
2360
|
+
* Perform mutation operations against the configured dataset
|
|
2361
|
+
* Returns an observable that resolves to a mutation result object containing the document ID of the first mutated document.
|
|
2362
|
+
*
|
|
2363
|
+
* @param operations - Mutation operations to execute
|
|
2364
|
+
* @param options - Mutation options
|
|
2365
|
+
*/
|
|
2366
|
+
mutate<R extends Record<string, Any> = Record<string, Any>>(
|
|
2367
|
+
operations: Mutation<R>[] | ObservablePatch | ObservableTransaction,
|
|
2368
|
+
options: FirstDocumentIdMutationOptions,
|
|
2369
|
+
): Observable<SingleMutationResult>
|
|
2370
|
+
/**
|
|
2371
|
+
* Perform mutation operations against the configured dataset
|
|
2372
|
+
* Returns an observable that resolves to a mutation result object containing the mutated document IDs.
|
|
2373
|
+
*
|
|
2374
|
+
* @param operations - Mutation operations to execute
|
|
2375
|
+
* @param options - Mutation options
|
|
2376
|
+
*/
|
|
2377
|
+
mutate<R extends Record<string, Any> = Record<string, Any>>(
|
|
2378
|
+
operations: Mutation<R>[] | ObservablePatch | ObservableTransaction,
|
|
2379
|
+
options: AllDocumentIdsMutationOptions,
|
|
2380
|
+
): Observable<MultipleMutationResult>
|
|
2381
|
+
/**
|
|
2382
|
+
* Perform mutation operations against the configured dataset
|
|
2383
|
+
* Returns an observable that resolves to the first mutated document.
|
|
2384
|
+
*
|
|
2385
|
+
* @param operations - Mutation operations to execute
|
|
2386
|
+
* @param options - Mutation options
|
|
2387
|
+
*/
|
|
2388
|
+
mutate<R extends Record<string, Any> = Record<string, Any>>(
|
|
2389
|
+
operations: Mutation<R>[] | ObservablePatch | ObservableTransaction,
|
|
2390
|
+
options?: BaseMutationOptions,
|
|
2391
|
+
): Observable<SanityDocument<R>>
|
|
2392
|
+
/**
|
|
2393
|
+
* Create a new buildable patch of operations to perform
|
|
2394
|
+
*
|
|
2395
|
+
* @param documentId - Document ID to patch
|
|
2396
|
+
* @param operations - Optional object of patch operations to initialize the patch instance with
|
|
2397
|
+
* @returns Patch instance - call `.commit()` to perform the operations defined
|
|
2398
|
+
*/
|
|
2399
|
+
patch(documentId: string, operations?: PatchOperations): ObservablePatch
|
|
2400
|
+
/**
|
|
2401
|
+
* Create a new buildable patch of operations to perform
|
|
2402
|
+
*
|
|
2403
|
+
* @param documentIds - Array of document IDs to patch
|
|
2404
|
+
* @param operations - Optional object of patch operations to initialize the patch instance with
|
|
2405
|
+
* @returns Patch instance - call `.commit()` to perform the operations defined
|
|
2406
|
+
*/
|
|
2407
|
+
patch(documentIds: string[], operations?: PatchOperations): ObservablePatch
|
|
2408
|
+
/**
|
|
2409
|
+
* Create a new buildable patch of operations to perform
|
|
2410
|
+
*
|
|
2411
|
+
* @param selection - An object with `query` and optional `params`, defining which document(s) to patch
|
|
2412
|
+
* @param operations - Optional object of patch operations to initialize the patch instance with
|
|
2413
|
+
* @returns Patch instance - call `.commit()` to perform the operations defined
|
|
2414
|
+
*/
|
|
2415
|
+
patch(selection: MutationSelection, operations?: PatchOperations): ObservablePatch
|
|
2416
|
+
/**
|
|
2417
|
+
* Create a new buildable patch of operations to perform
|
|
2418
|
+
*
|
|
2419
|
+
* @param selection - Document ID, an array of document IDs, or an object with `query` and optional `params`, defining which document(s) to patch
|
|
2420
|
+
* @param operations - Optional object of patch operations to initialize the patch instance with
|
|
2421
|
+
* @returns Patch instance - call `.commit()` to perform the operations defined
|
|
2422
|
+
*/
|
|
2423
|
+
patch(selection: PatchSelection, operations?: PatchOperations): ObservablePatch
|
|
2424
|
+
/**
|
|
2425
|
+
* Create a new transaction of mutations
|
|
2426
|
+
*
|
|
2427
|
+
* @param operations - Optional array of mutation operations to initialize the transaction instance with
|
|
2428
|
+
*/
|
|
2429
|
+
transaction<R extends Record<string, Any> = Record<string, Any>>(
|
|
2430
|
+
operations?: Mutation<R>[],
|
|
2431
|
+
): ObservableTransaction
|
|
2432
|
+
/**
|
|
2433
|
+
* Perform action operations against the configured dataset
|
|
2434
|
+
*
|
|
2435
|
+
* @param operations - Action operation(s) to execute
|
|
2436
|
+
* @param options - Action options
|
|
2437
|
+
*/
|
|
2438
|
+
action(
|
|
2439
|
+
operations: Action | Action[],
|
|
2440
|
+
options?: BaseActionOptions,
|
|
2441
|
+
): Observable<SingleActionResult | MultipleActionResult>
|
|
2442
|
+
/**
|
|
2443
|
+
* Perform an HTTP request against the Sanity API
|
|
2444
|
+
*
|
|
2445
|
+
* @param options - Request options
|
|
2446
|
+
*/
|
|
2447
|
+
request<R = Any>(options: RawRequestOptions): Observable<R>
|
|
2448
|
+
}
|
|
2449
|
+
|
|
2450
|
+
/** @public */
|
|
2451
|
+
export declare class ObservableTransaction extends BaseTransaction {
|
|
2452
|
+
#private
|
|
2453
|
+
constructor(operations?: Mutation[], client?: ObservableSanityClient, transactionId?: string)
|
|
2454
|
+
/**
|
|
2455
|
+
* Clones the transaction
|
|
2456
|
+
*/
|
|
2457
|
+
clone(): ObservableTransaction
|
|
2458
|
+
/**
|
|
2459
|
+
* Commit the transaction, returning an observable that produces the first mutated document
|
|
2460
|
+
*
|
|
2461
|
+
* @param options - Options for the mutation operation
|
|
2462
|
+
*/
|
|
2463
|
+
commit<R extends Record<string, Any>>(
|
|
2464
|
+
options: TransactionFirstDocumentMutationOptions,
|
|
2465
|
+
): Observable<SanityDocument<R>>
|
|
2466
|
+
/**
|
|
2467
|
+
* Commit the transaction, returning an observable that produces an array of the mutated documents
|
|
2468
|
+
*
|
|
2469
|
+
* @param options - Options for the mutation operation
|
|
2470
|
+
*/
|
|
2471
|
+
commit<R extends Record<string, Any>>(
|
|
2472
|
+
options: TransactionAllDocumentsMutationOptions,
|
|
2473
|
+
): Observable<SanityDocument<R>[]>
|
|
2474
|
+
/**
|
|
2475
|
+
* Commit the transaction, returning an observable that produces a mutation result object
|
|
2476
|
+
*
|
|
2477
|
+
* @param options - Options for the mutation operation
|
|
2478
|
+
*/
|
|
2479
|
+
commit(options: TransactionFirstDocumentIdMutationOptions): Observable<SingleMutationResult>
|
|
2480
|
+
/**
|
|
2481
|
+
* Commit the transaction, returning an observable that produces a mutation result object
|
|
2482
|
+
*
|
|
2483
|
+
* @param options - Options for the mutation operation
|
|
2484
|
+
*/
|
|
2485
|
+
commit(options: TransactionAllDocumentIdsMutationOptions): Observable<MultipleMutationResult>
|
|
2486
|
+
/**
|
|
2487
|
+
* Commit the transaction, returning an observable that produces a mutation result object
|
|
2488
|
+
*
|
|
2489
|
+
* @param options - Options for the mutation operation
|
|
2490
|
+
*/
|
|
2491
|
+
commit(options?: BaseMutationOptions): Observable<MultipleMutationResult>
|
|
2492
|
+
/**
|
|
2493
|
+
* Performs a patch on the given document ID. Can either be a builder function or an object of patch operations.
|
|
2494
|
+
* The operation is added to the current transaction, ready to be commited by `commit()`
|
|
2495
|
+
*
|
|
2496
|
+
* @param documentId - Document ID to perform the patch operation on
|
|
2497
|
+
* @param patchOps - Operations to perform, or a builder function
|
|
2498
|
+
*/
|
|
2499
|
+
patch(documentId: string, patchOps?: ObservablePatchBuilder | PatchOperations): this
|
|
2500
|
+
/**
|
|
2501
|
+
* Adds the given patch instance to the transaction.
|
|
2502
|
+
* The operation is added to the current transaction, ready to be commited by `commit()`
|
|
2503
|
+
*
|
|
2504
|
+
* @param patch - ObservablePatch to execute
|
|
2505
|
+
*/
|
|
2506
|
+
patch(patch: ObservablePatch): this
|
|
2507
|
+
}
|
|
2508
|
+
|
|
2509
|
+
/** @public */
|
|
2510
|
+
export declare class ObservableUsersClient {
|
|
2511
|
+
#private
|
|
2512
|
+
constructor(client: ObservableSanityClient, httpRequest: HttpRequest)
|
|
2513
|
+
/**
|
|
2514
|
+
* Fetch a user by user ID
|
|
2515
|
+
*
|
|
2516
|
+
* @param id - User ID of the user to fetch. If `me` is provided, a minimal response including the users role is returned.
|
|
2517
|
+
*/
|
|
2518
|
+
getById<T extends 'me' | string>(
|
|
2519
|
+
id: T,
|
|
2520
|
+
): Observable<T extends 'me' ? CurrentSanityUser : SanityUser>
|
|
2521
|
+
}
|
|
2522
|
+
|
|
2523
|
+
/**
|
|
2524
|
+
* The listener connection has been established
|
|
2525
|
+
* note: it's usually a better option to use the 'welcome' event
|
|
2526
|
+
* @public
|
|
2527
|
+
*/
|
|
2528
|
+
export declare type OpenEvent = {
|
|
2529
|
+
type: 'open'
|
|
2530
|
+
}
|
|
2531
|
+
|
|
2532
|
+
/** @public */
|
|
2533
|
+
export declare class Patch extends BasePatch {
|
|
2534
|
+
#private
|
|
2535
|
+
constructor(selection: PatchSelection, operations?: PatchOperations, client?: SanityClient)
|
|
2536
|
+
/**
|
|
2537
|
+
* Clones the patch
|
|
2538
|
+
*/
|
|
2539
|
+
clone(): Patch
|
|
2540
|
+
/**
|
|
2541
|
+
* Commit the patch, returning a promise that resolves to the first patched document
|
|
2542
|
+
*
|
|
2543
|
+
* @param options - Options for the mutation operation
|
|
2544
|
+
*/
|
|
2545
|
+
commit<R extends Record<string, Any> = Record<string, Any>>(
|
|
2546
|
+
options: FirstDocumentMutationOptions,
|
|
2547
|
+
): Promise<SanityDocument<R>>
|
|
2548
|
+
/**
|
|
2549
|
+
* Commit the patch, returning a promise that resolves to an array of the mutated documents
|
|
2550
|
+
*
|
|
2551
|
+
* @param options - Options for the mutation operation
|
|
2552
|
+
*/
|
|
2553
|
+
commit<R extends Record<string, Any> = Record<string, Any>>(
|
|
2554
|
+
options: AllDocumentsMutationOptions,
|
|
2555
|
+
): Promise<SanityDocument<R>[]>
|
|
2556
|
+
/**
|
|
2557
|
+
* Commit the patch, returning a promise that resolves to a mutation result object
|
|
2558
|
+
*
|
|
2559
|
+
* @param options - Options for the mutation operation
|
|
2560
|
+
*/
|
|
2561
|
+
commit(options: FirstDocumentIdMutationOptions): Promise<SingleMutationResult>
|
|
2562
|
+
/**
|
|
2563
|
+
* Commit the patch, returning a promise that resolves to a mutation result object
|
|
2564
|
+
*
|
|
2565
|
+
* @param options - Options for the mutation operation
|
|
2566
|
+
*/
|
|
2567
|
+
commit(options: AllDocumentIdsMutationOptions): Promise<MultipleMutationResult>
|
|
2568
|
+
/**
|
|
2569
|
+
* Commit the patch, returning a promise that resolves to the first patched document
|
|
2570
|
+
*
|
|
2571
|
+
* @param options - Options for the mutation operation
|
|
2572
|
+
*/
|
|
2573
|
+
commit<R extends Record<string, Any> = Record<string, Any>>(
|
|
2574
|
+
options?: BaseMutationOptions,
|
|
2575
|
+
): Promise<SanityDocument<R>>
|
|
2576
|
+
}
|
|
2577
|
+
|
|
2578
|
+
/** @public */
|
|
2579
|
+
export declare type PatchBuilder = (patch: Patch) => Patch
|
|
2580
|
+
|
|
2581
|
+
/** @internal */
|
|
2093
2582
|
export declare type PatchMutationOperation = PatchOperations & MutationSelection
|
|
2094
2583
|
|
|
2095
2584
|
/** @internal */
|
|
@@ -2133,275 +2622,818 @@ export declare class ProjectsClient {
|
|
|
2133
2622
|
#private
|
|
2134
2623
|
constructor(client: SanityClient, httpRequest: HttpRequest)
|
|
2135
2624
|
/**
|
|
2136
|
-
* Fetch a list of projects the authenticated user has access to.
|
|
2625
|
+
* Fetch a list of projects the authenticated user has access to.
|
|
2626
|
+
*
|
|
2627
|
+
* @param options - Options for the list request
|
|
2628
|
+
* @param options.includeMembers - Whether to include members in the response (default: true)
|
|
2629
|
+
*/
|
|
2630
|
+
list(options?: {includeMembers?: true}): Promise<SanityProject[]>
|
|
2631
|
+
list(options?: {includeMembers?: false}): Promise<Omit<SanityProject, 'members'>[]>
|
|
2632
|
+
/**
|
|
2633
|
+
* Fetch a project by project ID
|
|
2634
|
+
*
|
|
2635
|
+
* @param projectId - ID of the project to fetch
|
|
2636
|
+
*/
|
|
2637
|
+
getById(projectId: string): Promise<SanityProject>
|
|
2638
|
+
}
|
|
2639
|
+
|
|
2640
|
+
/**
|
|
2641
|
+
* Publishes a draft document.
|
|
2642
|
+
* If a published version of the document already exists this is replaced by the current draft document.
|
|
2643
|
+
* In either case the draft document is deleted.
|
|
2644
|
+
* The optional revision id parameters can be used for optimistic locking to ensure
|
|
2645
|
+
* that the draft and/or published versions of the document have not been changed by another client.
|
|
2646
|
+
*
|
|
2647
|
+
* @public
|
|
2648
|
+
*/
|
|
2649
|
+
export declare type PublishAction = {
|
|
2650
|
+
actionType: 'sanity.action.document.publish'
|
|
2651
|
+
/**
|
|
2652
|
+
* Draft document ID to publish
|
|
2653
|
+
*/
|
|
2654
|
+
draftId: string
|
|
2655
|
+
/**
|
|
2656
|
+
* Draft revision ID to match
|
|
2657
|
+
*/
|
|
2658
|
+
ifDraftRevisionId?: string
|
|
2659
|
+
/**
|
|
2660
|
+
* Published document ID to replace
|
|
2661
|
+
*/
|
|
2662
|
+
publishedId: string
|
|
2663
|
+
/**
|
|
2664
|
+
* Published revision ID to match
|
|
2665
|
+
*/
|
|
2666
|
+
ifPublishedRevisionId?: string
|
|
2667
|
+
}
|
|
2668
|
+
|
|
2669
|
+
/** @public */
|
|
2670
|
+
export declare type QueryOptions =
|
|
2671
|
+
| FilteredResponseQueryOptions
|
|
2672
|
+
| UnfilteredResponseQueryOptions
|
|
2673
|
+
| UnfilteredResponseWithoutQuery
|
|
2674
|
+
|
|
2675
|
+
/** @public */
|
|
2676
|
+
export declare interface QueryParams {
|
|
2677
|
+
[key: string]: any
|
|
2678
|
+
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2679
|
+
body?: never
|
|
2680
|
+
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2681
|
+
cache?: 'next' extends keyof RequestInit ? never : any
|
|
2682
|
+
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2683
|
+
filterResponse?: never
|
|
2684
|
+
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2685
|
+
headers?: never
|
|
2686
|
+
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2687
|
+
method?: never
|
|
2688
|
+
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2689
|
+
next?: 'next' extends keyof RequestInit ? never : any
|
|
2690
|
+
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2691
|
+
perspective?: never
|
|
2692
|
+
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2693
|
+
query?: never
|
|
2694
|
+
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2695
|
+
resultSourceMap?: never
|
|
2696
|
+
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2697
|
+
returnQuery?: never
|
|
2698
|
+
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2699
|
+
signal?: never
|
|
2700
|
+
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2701
|
+
stega?: never
|
|
2702
|
+
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2703
|
+
tag?: never
|
|
2704
|
+
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2705
|
+
timeout?: never
|
|
2706
|
+
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2707
|
+
token?: never
|
|
2708
|
+
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2709
|
+
useCdn?: never
|
|
2710
|
+
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2711
|
+
lastLiveEventId?: never
|
|
2712
|
+
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2713
|
+
cacheMode?: never
|
|
2714
|
+
}
|
|
2715
|
+
|
|
2716
|
+
/**
|
|
2717
|
+
* This type can be used with `client.fetch` to indicate that the query has no GROQ parameters.
|
|
2718
|
+
* @public
|
|
2719
|
+
*/
|
|
2720
|
+
export declare type QueryWithoutParams = Record<string, never> | undefined
|
|
2721
|
+
|
|
2722
|
+
/** @public */
|
|
2723
|
+
export declare type RawQuerylessQueryResponse<R> = Omit<RawQueryResponse<R>, 'query'>
|
|
2724
|
+
|
|
2725
|
+
/** @public */
|
|
2726
|
+
export declare interface RawQueryResponse<R> {
|
|
2727
|
+
query: string
|
|
2728
|
+
ms: number
|
|
2729
|
+
result: R
|
|
2730
|
+
resultSourceMap?: ContentSourceMap
|
|
2731
|
+
/** Requires `apiVersion` to be `2021-03-25` or later. */
|
|
2732
|
+
syncTags?: SyncTag[]
|
|
2733
|
+
}
|
|
2734
|
+
|
|
2735
|
+
/** @internal */
|
|
2736
|
+
export declare interface RawRequestOptions {
|
|
2737
|
+
url?: string
|
|
2738
|
+
uri?: string
|
|
2739
|
+
method?: string
|
|
2740
|
+
token?: string
|
|
2741
|
+
json?: boolean
|
|
2742
|
+
tag?: string
|
|
2743
|
+
useGlobalApi?: boolean
|
|
2744
|
+
withCredentials?: boolean
|
|
2745
|
+
query?: {
|
|
2746
|
+
[key: string]: string | string[]
|
|
2747
|
+
}
|
|
2748
|
+
headers?: {
|
|
2749
|
+
[key: string]: string
|
|
2750
|
+
}
|
|
2751
|
+
timeout?: number
|
|
2752
|
+
proxy?: string
|
|
2753
|
+
body?: Any
|
|
2754
|
+
maxRedirects?: number
|
|
2755
|
+
signal?: AbortSignal
|
|
2756
|
+
}
|
|
2757
|
+
|
|
2758
|
+
/**
|
|
2759
|
+
* The listener has been disconnected, and a reconnect attempt is scheduled.
|
|
2760
|
+
*
|
|
2761
|
+
* @public
|
|
2762
|
+
*/
|
|
2763
|
+
export declare type ReconnectEvent = {
|
|
2764
|
+
type: 'reconnect'
|
|
2765
|
+
}
|
|
2766
|
+
|
|
2767
|
+
/**
|
|
2768
|
+
* @public
|
|
2769
|
+
* @deprecated – The `r`-prefix is not required, use `string` instead
|
|
2770
|
+
*/
|
|
2771
|
+
export declare type ReleaseId = `r${string}`
|
|
2772
|
+
|
|
2773
|
+
/**
|
|
2774
|
+
* Replaces an existing draft document.
|
|
2775
|
+
* At least one of the draft or published versions of the document must exist.
|
|
2776
|
+
*
|
|
2777
|
+
* @public
|
|
2778
|
+
*/
|
|
2779
|
+
export declare type ReplaceDraftAction = {
|
|
2780
|
+
actionType: 'sanity.action.document.replaceDraft'
|
|
2781
|
+
/**
|
|
2782
|
+
* Published document ID to create draft from, if draft does not exist
|
|
2783
|
+
*/
|
|
2784
|
+
publishedId: string
|
|
2785
|
+
/**
|
|
2786
|
+
* Document to create if it does not already exist. Requires `_id` and `_type` properties.
|
|
2787
|
+
*/
|
|
2788
|
+
attributes: IdentifiedSanityDocumentStub
|
|
2789
|
+
}
|
|
2790
|
+
|
|
2791
|
+
/** @public */
|
|
2792
|
+
export declare const requester: Requester
|
|
2793
|
+
|
|
2794
|
+
/** @internal */
|
|
2795
|
+
export declare interface RequestObservableOptions extends Omit<RequestOptions, 'url'> {
|
|
2796
|
+
url?: string
|
|
2797
|
+
uri?: string
|
|
2798
|
+
canUseCdn?: boolean
|
|
2799
|
+
useCdn?: boolean
|
|
2800
|
+
tag?: string
|
|
2801
|
+
returnQuery?: boolean
|
|
2802
|
+
resultSourceMap?: boolean | 'withKeyArraySelector'
|
|
2803
|
+
perspective?: ClientPerspective
|
|
2804
|
+
lastLiveEventId?: string
|
|
2805
|
+
cacheMode?: 'noStale'
|
|
2806
|
+
}
|
|
2807
|
+
|
|
2808
|
+
/** @public */
|
|
2809
|
+
export declare interface RequestOptions {
|
|
2810
|
+
timeout?: number
|
|
2811
|
+
token?: string
|
|
2812
|
+
tag?: string
|
|
2813
|
+
headers?: Record<string, string>
|
|
2814
|
+
method?: string
|
|
2815
|
+
query?: Any
|
|
2816
|
+
body?: Any
|
|
2817
|
+
signal?: AbortSignal
|
|
2818
|
+
}
|
|
2819
|
+
|
|
2820
|
+
export {ResolveStudioUrl}
|
|
2821
|
+
|
|
2822
|
+
/** @public */
|
|
2823
|
+
export declare interface ResponseEvent<T = unknown> {
|
|
2824
|
+
type: 'response'
|
|
2825
|
+
body: T
|
|
2826
|
+
url: string
|
|
2827
|
+
method: string
|
|
2828
|
+
statusCode: number
|
|
2829
|
+
statusMessage?: string
|
|
2830
|
+
headers: Record<string, string>
|
|
2831
|
+
}
|
|
2832
|
+
|
|
2833
|
+
/** @public */
|
|
2834
|
+
export declare interface ResponseQueryOptions extends RequestOptions {
|
|
2835
|
+
perspective?: ClientPerspective
|
|
2836
|
+
resultSourceMap?: boolean | 'withKeyArraySelector'
|
|
2837
|
+
returnQuery?: boolean
|
|
2838
|
+
useCdn?: boolean
|
|
2839
|
+
stega?: boolean | StegaConfig
|
|
2840
|
+
cache?: 'next' extends keyof RequestInit ? RequestInit['cache'] : never
|
|
2841
|
+
next?: ('next' extends keyof RequestInit ? RequestInit : never)['next']
|
|
2842
|
+
lastLiveEventId?: string | string[] | null
|
|
2843
|
+
/**
|
|
2844
|
+
* When set to `noStale`, APICDN will not return a cached response if the content is stale.
|
|
2845
|
+
* Tradeoff between latency and freshness of content.
|
|
2846
|
+
*
|
|
2847
|
+
* Only to be used with live content queries and when useCdn is true.
|
|
2848
|
+
*/
|
|
2849
|
+
cacheMode?: 'noStale'
|
|
2850
|
+
}
|
|
2851
|
+
|
|
2852
|
+
/** @internal */
|
|
2853
|
+
export declare interface SanityAssetDocument extends SanityDocument {
|
|
2854
|
+
url: string
|
|
2855
|
+
path: string
|
|
2856
|
+
size: number
|
|
2857
|
+
assetId: string
|
|
2858
|
+
mimeType: string
|
|
2859
|
+
sha1hash: string
|
|
2860
|
+
extension: string
|
|
2861
|
+
uploadId?: string
|
|
2862
|
+
originalFilename?: string
|
|
2863
|
+
}
|
|
2864
|
+
|
|
2865
|
+
/** @public */
|
|
2866
|
+
export declare class SanityClient implements SanityClientType {
|
|
2867
|
+
#private
|
|
2868
|
+
assets: AssetsClient
|
|
2869
|
+
datasets: DatasetsClient
|
|
2870
|
+
live: LiveClient
|
|
2871
|
+
projects: ProjectsClient
|
|
2872
|
+
users: UsersClient
|
|
2873
|
+
/**
|
|
2874
|
+
* Observable version of the Sanity client, with the same configuration as the promise-based one
|
|
2875
|
+
*/
|
|
2876
|
+
observable: ObservableSanityClient
|
|
2877
|
+
listen: typeof _listen
|
|
2878
|
+
constructor(httpRequest: HttpRequest, config?: ClientConfig)
|
|
2879
|
+
/**
|
|
2880
|
+
* Clone the client - returns a new instance
|
|
2881
|
+
*/
|
|
2882
|
+
clone(): SanityClient
|
|
2883
|
+
/**
|
|
2884
|
+
* Returns the current client configuration
|
|
2885
|
+
*/
|
|
2886
|
+
config(): InitializedClientConfig
|
|
2887
|
+
/**
|
|
2888
|
+
* Reconfigure the client. Note that this _mutates_ the current client.
|
|
2889
|
+
*/
|
|
2890
|
+
config(newConfig?: Partial<ClientConfig>): this
|
|
2891
|
+
/**
|
|
2892
|
+
* Clone the client with a new (partial) configuration.
|
|
2893
|
+
*
|
|
2894
|
+
* @param newConfig - New client configuration properties, shallowly merged with existing configuration
|
|
2895
|
+
*/
|
|
2896
|
+
withConfig(newConfig?: Partial<ClientConfig>): SanityClient
|
|
2897
|
+
/**
|
|
2898
|
+
* Perform a GROQ-query against the configured dataset.
|
|
2899
|
+
*
|
|
2900
|
+
* @param query - GROQ-query to perform
|
|
2901
|
+
*/
|
|
2902
|
+
fetch<
|
|
2903
|
+
R = Any,
|
|
2904
|
+
Q extends QueryWithoutParams = QueryWithoutParams,
|
|
2905
|
+
const G extends string = string,
|
|
2906
|
+
>(query: G, params?: Q | QueryWithoutParams): Promise<ClientReturn<G, R>>
|
|
2907
|
+
/**
|
|
2908
|
+
* Perform a GROQ-query against the configured dataset.
|
|
2909
|
+
*
|
|
2910
|
+
* @param query - GROQ-query to perform
|
|
2911
|
+
* @param params - Optional query parameters
|
|
2912
|
+
* @param options - Optional request options
|
|
2913
|
+
*/
|
|
2914
|
+
fetch<
|
|
2915
|
+
R = Any,
|
|
2916
|
+
Q extends QueryWithoutParams | QueryParams = QueryParams,
|
|
2917
|
+
const G extends string = string,
|
|
2918
|
+
>(
|
|
2919
|
+
query: G,
|
|
2920
|
+
params: Q extends QueryWithoutParams ? QueryWithoutParams : Q,
|
|
2921
|
+
options?: FilteredResponseQueryOptions,
|
|
2922
|
+
): Promise<ClientReturn<G, R>>
|
|
2923
|
+
/**
|
|
2924
|
+
* Perform a GROQ-query against the configured dataset.
|
|
2925
|
+
*
|
|
2926
|
+
* @param query - GROQ-query to perform
|
|
2927
|
+
* @param params - Optional query parameters
|
|
2928
|
+
* @param options - Request options
|
|
2929
|
+
*/
|
|
2930
|
+
fetch<
|
|
2931
|
+
R = Any,
|
|
2932
|
+
Q extends QueryWithoutParams | QueryParams = QueryParams,
|
|
2933
|
+
const G extends string = string,
|
|
2934
|
+
>(
|
|
2935
|
+
query: G,
|
|
2936
|
+
params: Q extends QueryWithoutParams ? QueryWithoutParams : Q,
|
|
2937
|
+
options: UnfilteredResponseQueryOptions,
|
|
2938
|
+
): Promise<RawQueryResponse<ClientReturn<G, R>>>
|
|
2939
|
+
/**
|
|
2940
|
+
* Perform a GROQ-query against the configured dataset.
|
|
2941
|
+
*
|
|
2942
|
+
* @param query - GROQ-query to perform
|
|
2943
|
+
* @param params - Optional query parameters
|
|
2944
|
+
* @param options - Request options
|
|
2945
|
+
*/
|
|
2946
|
+
fetch<
|
|
2947
|
+
R = Any,
|
|
2948
|
+
Q extends QueryWithoutParams | QueryParams = QueryParams,
|
|
2949
|
+
const G extends string = string,
|
|
2950
|
+
>(
|
|
2951
|
+
query: G,
|
|
2952
|
+
params: Q extends QueryWithoutParams ? QueryWithoutParams : Q,
|
|
2953
|
+
options: UnfilteredResponseWithoutQuery,
|
|
2954
|
+
): Promise<RawQuerylessQueryResponse<ClientReturn<G, R>>>
|
|
2955
|
+
/**
|
|
2956
|
+
* Fetch a single document with the given ID.
|
|
2957
|
+
*
|
|
2958
|
+
* @param id - Document ID to fetch
|
|
2959
|
+
* @param options - Request options
|
|
2960
|
+
*/
|
|
2961
|
+
getDocument<R extends Record<string, Any> = Record<string, Any>>(
|
|
2962
|
+
id: string,
|
|
2963
|
+
options?: {
|
|
2964
|
+
signal?: AbortSignal
|
|
2965
|
+
tag?: string
|
|
2966
|
+
},
|
|
2967
|
+
): Promise<SanityDocument<R> | undefined>
|
|
2968
|
+
/**
|
|
2969
|
+
* Fetch multiple documents in one request.
|
|
2970
|
+
* Should be used sparingly - performing a query is usually a better option.
|
|
2971
|
+
* The order/position of documents is preserved based on the original array of IDs.
|
|
2972
|
+
* If any of the documents are missing, they will be replaced by a `null` entry in the returned array
|
|
2973
|
+
*
|
|
2974
|
+
* @param ids - Document IDs to fetch
|
|
2975
|
+
* @param options - Request options
|
|
2976
|
+
*/
|
|
2977
|
+
getDocuments<R extends Record<string, Any> = Record<string, Any>>(
|
|
2978
|
+
ids: string[],
|
|
2979
|
+
options?: {
|
|
2980
|
+
signal?: AbortSignal
|
|
2981
|
+
tag?: string
|
|
2982
|
+
},
|
|
2983
|
+
): Promise<(SanityDocument<R> | null)[]>
|
|
2984
|
+
/**
|
|
2985
|
+
* Create a document. Requires a `_type` property. If no `_id` is provided, it will be generated by the database.
|
|
2986
|
+
* Returns a promise that resolves to the created document.
|
|
2987
|
+
*
|
|
2988
|
+
* @param document - Document to create
|
|
2989
|
+
* @param options - Mutation options
|
|
2990
|
+
*/
|
|
2991
|
+
create<R extends Record<string, Any> = Record<string, Any>>(
|
|
2992
|
+
document: SanityDocumentStub<R>,
|
|
2993
|
+
options: FirstDocumentMutationOptions,
|
|
2994
|
+
): Promise<SanityDocument<R>>
|
|
2995
|
+
/**
|
|
2996
|
+
* Create a document. Requires a `_type` property. If no `_id` is provided, it will be generated by the database.
|
|
2997
|
+
* Returns a promise that resolves to an array containing the created document.
|
|
2998
|
+
*
|
|
2999
|
+
* @param document - Document to create
|
|
3000
|
+
* @param options - Mutation options
|
|
3001
|
+
*/
|
|
3002
|
+
create<R extends Record<string, Any> = Record<string, Any>>(
|
|
3003
|
+
document: SanityDocumentStub<R>,
|
|
3004
|
+
options: AllDocumentsMutationOptions,
|
|
3005
|
+
): Promise<SanityDocument<R>[]>
|
|
3006
|
+
/**
|
|
3007
|
+
* Create a document. Requires a `_type` property. If no `_id` is provided, it will be generated by the database.
|
|
3008
|
+
* Returns a promise that resolves to a mutation result object containing the ID of the created document.
|
|
3009
|
+
*
|
|
3010
|
+
* @param document - Document to create
|
|
3011
|
+
* @param options - Mutation options
|
|
3012
|
+
*/
|
|
3013
|
+
create<R extends Record<string, Any> = Record<string, Any>>(
|
|
3014
|
+
document: SanityDocumentStub<R>,
|
|
3015
|
+
options: FirstDocumentIdMutationOptions,
|
|
3016
|
+
): Promise<SingleMutationResult>
|
|
3017
|
+
/**
|
|
3018
|
+
* Create a document. Requires a `_type` property. If no `_id` is provided, it will be generated by the database.
|
|
3019
|
+
* Returns a promise that resolves to a mutation result object containing the ID of the created document.
|
|
3020
|
+
*
|
|
3021
|
+
* @param document - Document to create
|
|
3022
|
+
* @param options - Mutation options
|
|
3023
|
+
*/
|
|
3024
|
+
create<R extends Record<string, Any> = Record<string, Any>>(
|
|
3025
|
+
document: SanityDocumentStub<R>,
|
|
3026
|
+
options: AllDocumentIdsMutationOptions,
|
|
3027
|
+
): Promise<MultipleMutationResult>
|
|
3028
|
+
/**
|
|
3029
|
+
* Create a document. Requires a `_type` property. If no `_id` is provided, it will be generated by the database.
|
|
3030
|
+
* Returns a promise that resolves to the created document.
|
|
3031
|
+
*
|
|
3032
|
+
* @param document - Document to create
|
|
3033
|
+
* @param options - Mutation options
|
|
3034
|
+
*/
|
|
3035
|
+
create<R extends Record<string, Any> = Record<string, Any>>(
|
|
3036
|
+
document: SanityDocumentStub<R>,
|
|
3037
|
+
options?: BaseMutationOptions,
|
|
3038
|
+
): Promise<SanityDocument<R>>
|
|
3039
|
+
/**
|
|
3040
|
+
* Create a document if no document with the same ID already exists.
|
|
3041
|
+
* Returns a promise that resolves to the created document.
|
|
3042
|
+
*
|
|
3043
|
+
* @param document - Document to create
|
|
3044
|
+
* @param options - Mutation options
|
|
3045
|
+
*/
|
|
3046
|
+
createIfNotExists<R extends Record<string, Any> = Record<string, Any>>(
|
|
3047
|
+
document: IdentifiedSanityDocumentStub<R>,
|
|
3048
|
+
options: FirstDocumentMutationOptions,
|
|
3049
|
+
): Promise<SanityDocument<R>>
|
|
3050
|
+
/**
|
|
3051
|
+
* Create a document if no document with the same ID already exists.
|
|
3052
|
+
* Returns a promise that resolves to an array containing the created document.
|
|
3053
|
+
*
|
|
3054
|
+
* @param document - Document to create
|
|
3055
|
+
* @param options - Mutation options
|
|
3056
|
+
*/
|
|
3057
|
+
createIfNotExists<R extends Record<string, Any> = Record<string, Any>>(
|
|
3058
|
+
document: IdentifiedSanityDocumentStub<R>,
|
|
3059
|
+
options: AllDocumentsMutationOptions,
|
|
3060
|
+
): Promise<SanityDocument<R>[]>
|
|
3061
|
+
/**
|
|
3062
|
+
* Create a document if no document with the same ID already exists.
|
|
3063
|
+
* Returns a promise that resolves to a mutation result object containing the ID of the created document.
|
|
3064
|
+
*
|
|
3065
|
+
* @param document - Document to create
|
|
3066
|
+
* @param options - Mutation options
|
|
3067
|
+
*/
|
|
3068
|
+
createIfNotExists<R extends Record<string, Any> = Record<string, Any>>(
|
|
3069
|
+
document: IdentifiedSanityDocumentStub<R>,
|
|
3070
|
+
options: FirstDocumentIdMutationOptions,
|
|
3071
|
+
): Promise<SingleMutationResult>
|
|
3072
|
+
/**
|
|
3073
|
+
* Create a document if no document with the same ID already exists.
|
|
3074
|
+
* Returns a promise that resolves to a mutation result object containing the ID of the created document.
|
|
3075
|
+
*
|
|
3076
|
+
* @param document - Document to create
|
|
3077
|
+
* @param options - Mutation options
|
|
3078
|
+
*/
|
|
3079
|
+
createIfNotExists<R extends Record<string, Any> = Record<string, Any>>(
|
|
3080
|
+
document: IdentifiedSanityDocumentStub<R>,
|
|
3081
|
+
options: AllDocumentIdsMutationOptions,
|
|
3082
|
+
): Promise<MultipleMutationResult>
|
|
3083
|
+
/**
|
|
3084
|
+
* Create a document if no document with the same ID already exists.
|
|
3085
|
+
* Returns a promise that resolves to the created document.
|
|
3086
|
+
*
|
|
3087
|
+
* @param document - Document to create
|
|
3088
|
+
* @param options - Mutation options
|
|
3089
|
+
*/
|
|
3090
|
+
createIfNotExists<R extends Record<string, Any> = Record<string, Any>>(
|
|
3091
|
+
document: IdentifiedSanityDocumentStub<R>,
|
|
3092
|
+
options?: BaseMutationOptions,
|
|
3093
|
+
): Promise<SanityDocument<R>>
|
|
3094
|
+
/**
|
|
3095
|
+
* Create a document if it does not exist, or replace a document with the same document ID
|
|
3096
|
+
* Returns a promise that resolves to the created document.
|
|
3097
|
+
*
|
|
3098
|
+
* @param document - Document to either create or replace
|
|
3099
|
+
* @param options - Mutation options
|
|
3100
|
+
*/
|
|
3101
|
+
createOrReplace<R extends Record<string, Any> = Record<string, Any>>(
|
|
3102
|
+
document: IdentifiedSanityDocumentStub<R>,
|
|
3103
|
+
options: FirstDocumentMutationOptions,
|
|
3104
|
+
): Promise<SanityDocument<R>>
|
|
3105
|
+
/**
|
|
3106
|
+
* Create a document if it does not exist, or replace a document with the same document ID
|
|
3107
|
+
* Returns a promise that resolves to an array containing the created document.
|
|
3108
|
+
*
|
|
3109
|
+
* @param document - Document to either create or replace
|
|
3110
|
+
* @param options - Mutation options
|
|
3111
|
+
*/
|
|
3112
|
+
createOrReplace<R extends Record<string, Any> = Record<string, Any>>(
|
|
3113
|
+
document: IdentifiedSanityDocumentStub<R>,
|
|
3114
|
+
options: AllDocumentsMutationOptions,
|
|
3115
|
+
): Promise<SanityDocument<R>[]>
|
|
3116
|
+
/**
|
|
3117
|
+
* Create a document if it does not exist, or replace a document with the same document ID
|
|
3118
|
+
* Returns a promise that resolves to a mutation result object containing the ID of the created document.
|
|
3119
|
+
*
|
|
3120
|
+
* @param document - Document to either create or replace
|
|
3121
|
+
* @param options - Mutation options
|
|
3122
|
+
*/
|
|
3123
|
+
createOrReplace<R extends Record<string, Any> = Record<string, Any>>(
|
|
3124
|
+
document: IdentifiedSanityDocumentStub<R>,
|
|
3125
|
+
options: FirstDocumentIdMutationOptions,
|
|
3126
|
+
): Promise<SingleMutationResult>
|
|
3127
|
+
/**
|
|
3128
|
+
* Create a document if it does not exist, or replace a document with the same document ID
|
|
3129
|
+
* Returns a promise that resolves to a mutation result object containing the created document ID.
|
|
3130
|
+
*
|
|
3131
|
+
* @param document - Document to either create or replace
|
|
3132
|
+
* @param options - Mutation options
|
|
3133
|
+
*/
|
|
3134
|
+
createOrReplace<R extends Record<string, Any> = Record<string, Any>>(
|
|
3135
|
+
document: IdentifiedSanityDocumentStub<R>,
|
|
3136
|
+
options: AllDocumentIdsMutationOptions,
|
|
3137
|
+
): Promise<MultipleMutationResult>
|
|
3138
|
+
/**
|
|
3139
|
+
* Create a document if it does not exist, or replace a document with the same document ID
|
|
3140
|
+
* Returns a promise that resolves to the created document.
|
|
2137
3141
|
*
|
|
2138
|
-
* @param
|
|
2139
|
-
* @param options
|
|
3142
|
+
* @param document - Document to either create or replace
|
|
3143
|
+
* @param options - Mutation options
|
|
2140
3144
|
*/
|
|
2141
|
-
|
|
2142
|
-
|
|
3145
|
+
createOrReplace<R extends Record<string, Any> = Record<string, Any>>(
|
|
3146
|
+
document: IdentifiedSanityDocumentStub<R>,
|
|
3147
|
+
options?: BaseMutationOptions,
|
|
3148
|
+
): Promise<SanityDocument<R>>
|
|
2143
3149
|
/**
|
|
2144
|
-
*
|
|
3150
|
+
* Deletes a document with the given document ID.
|
|
3151
|
+
* Returns a promise that resolves to the deleted document.
|
|
2145
3152
|
*
|
|
2146
|
-
* @param
|
|
3153
|
+
* @param id - Document ID to delete
|
|
3154
|
+
* @param options - Options for the mutation
|
|
2147
3155
|
*/
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
* Publishes a draft document.
|
|
2153
|
-
* If a published version of the document already exists this is replaced by the current draft document.
|
|
2154
|
-
* In either case the draft document is deleted.
|
|
2155
|
-
* The optional revision id parameters can be used for optimistic locking to ensure
|
|
2156
|
-
* that the draft and/or published versions of the document have not been changed by another client.
|
|
2157
|
-
*
|
|
2158
|
-
* @public
|
|
2159
|
-
*/
|
|
2160
|
-
export declare type PublishAction = {
|
|
2161
|
-
actionType: 'sanity.action.document.publish'
|
|
3156
|
+
delete<R extends Record<string, Any> = Record<string, Any>>(
|
|
3157
|
+
id: string,
|
|
3158
|
+
options: FirstDocumentMutationOptions,
|
|
3159
|
+
): Promise<SanityDocument<R>>
|
|
2162
3160
|
/**
|
|
2163
|
-
*
|
|
3161
|
+
* Deletes a document with the given document ID.
|
|
3162
|
+
* Returns a promise that resolves to an array containing the deleted document.
|
|
3163
|
+
*
|
|
3164
|
+
* @param id - Document ID to delete
|
|
3165
|
+
* @param options - Options for the mutation
|
|
2164
3166
|
*/
|
|
2165
|
-
|
|
3167
|
+
delete<R extends Record<string, Any> = Record<string, Any>>(
|
|
3168
|
+
id: string,
|
|
3169
|
+
options: AllDocumentsMutationOptions,
|
|
3170
|
+
): Promise<SanityDocument<R>[]>
|
|
2166
3171
|
/**
|
|
2167
|
-
*
|
|
3172
|
+
* Deletes a document with the given document ID.
|
|
3173
|
+
* Returns a promise that resolves to a mutation result object containing the deleted document ID.
|
|
3174
|
+
*
|
|
3175
|
+
* @param id - Document ID to delete
|
|
3176
|
+
* @param options - Options for the mutation
|
|
2168
3177
|
*/
|
|
2169
|
-
|
|
3178
|
+
delete(id: string, options: FirstDocumentIdMutationOptions): Promise<SingleMutationResult>
|
|
2170
3179
|
/**
|
|
2171
|
-
*
|
|
3180
|
+
* Deletes a document with the given document ID.
|
|
3181
|
+
* Returns a promise that resolves to a mutation result object containing the deleted document ID.
|
|
3182
|
+
*
|
|
3183
|
+
* @param id - Document ID to delete
|
|
3184
|
+
* @param options - Options for the mutation
|
|
3185
|
+
*/
|
|
3186
|
+
delete(id: string, options: AllDocumentIdsMutationOptions): Promise<MultipleMutationResult>
|
|
3187
|
+
/**
|
|
3188
|
+
* Deletes a document with the given document ID.
|
|
3189
|
+
* Returns a promise that resolves to the deleted document.
|
|
3190
|
+
*
|
|
3191
|
+
* @param id - Document ID to delete
|
|
3192
|
+
* @param options - Options for the mutation
|
|
3193
|
+
*/
|
|
3194
|
+
delete<R extends Record<string, Any> = Record<string, Any>>(
|
|
3195
|
+
id: string,
|
|
3196
|
+
options?: BaseMutationOptions,
|
|
3197
|
+
): Promise<SanityDocument<R>>
|
|
3198
|
+
/**
|
|
3199
|
+
* Deletes one or more documents matching the given query or document ID.
|
|
3200
|
+
* Returns a promise that resolves to first deleted document.
|
|
3201
|
+
*
|
|
3202
|
+
* @param selection - An object with either an `id` or `query` key defining what to delete
|
|
3203
|
+
* @param options - Options for the mutation
|
|
3204
|
+
*/
|
|
3205
|
+
delete<R extends Record<string, Any> = Record<string, Any>>(
|
|
3206
|
+
selection: MutationSelection,
|
|
3207
|
+
options: FirstDocumentMutationOptions,
|
|
3208
|
+
): Promise<SanityDocument<R>>
|
|
3209
|
+
/**
|
|
3210
|
+
* Deletes one or more documents matching the given query or document ID.
|
|
3211
|
+
* Returns a promise that resolves to an array containing the deleted documents.
|
|
3212
|
+
*
|
|
3213
|
+
* @param selection - An object with either an `id` or `query` key defining what to delete
|
|
3214
|
+
* @param options - Options for the mutation
|
|
3215
|
+
*/
|
|
3216
|
+
delete<R extends Record<string, Any> = Record<string, Any>>(
|
|
3217
|
+
selection: MutationSelection,
|
|
3218
|
+
options: AllDocumentsMutationOptions,
|
|
3219
|
+
): Promise<SanityDocument<R>[]>
|
|
3220
|
+
/**
|
|
3221
|
+
* Deletes one or more documents matching the given query or document ID.
|
|
3222
|
+
* Returns a promise that resolves to a mutation result object containing the ID of the first deleted document.
|
|
3223
|
+
*
|
|
3224
|
+
* @param selection - An object with either an `id` or `query` key defining what to delete
|
|
3225
|
+
* @param options - Options for the mutation
|
|
3226
|
+
*/
|
|
3227
|
+
delete(
|
|
3228
|
+
selection: MutationSelection,
|
|
3229
|
+
options: FirstDocumentIdMutationOptions,
|
|
3230
|
+
): Promise<SingleMutationResult>
|
|
3231
|
+
/**
|
|
3232
|
+
* Deletes one or more documents matching the given query or document ID.
|
|
3233
|
+
* Returns a promise that resolves to a mutation result object containing the document IDs that were deleted.
|
|
3234
|
+
*
|
|
3235
|
+
* @param selection - An object with either an `id` or `query` key defining what to delete
|
|
3236
|
+
* @param options - Options for the mutation
|
|
3237
|
+
*/
|
|
3238
|
+
delete(
|
|
3239
|
+
selection: MutationSelection,
|
|
3240
|
+
options: AllDocumentIdsMutationOptions,
|
|
3241
|
+
): Promise<MultipleMutationResult>
|
|
3242
|
+
/**
|
|
3243
|
+
* Deletes one or more documents matching the given query or document ID.
|
|
3244
|
+
* Returns a promise that resolves to first deleted document.
|
|
3245
|
+
*
|
|
3246
|
+
* @param selection - An object with either an `id` or `query` key defining what to delete
|
|
3247
|
+
* @param options - Options for the mutation
|
|
3248
|
+
*/
|
|
3249
|
+
delete<R extends Record<string, Any> = Record<string, Any>>(
|
|
3250
|
+
selection: MutationSelection,
|
|
3251
|
+
options?: BaseMutationOptions,
|
|
3252
|
+
): Promise<SanityDocument<R>>
|
|
3253
|
+
/**
|
|
3254
|
+
* Perform mutation operations against the configured dataset
|
|
3255
|
+
* Returns a promise that resolves to the first mutated document.
|
|
3256
|
+
*
|
|
3257
|
+
* @param operations - Mutation operations to execute
|
|
3258
|
+
* @param options - Mutation options
|
|
3259
|
+
*/
|
|
3260
|
+
mutate<R extends Record<string, Any> = Record<string, Any>>(
|
|
3261
|
+
operations: Mutation<R>[] | Patch | Transaction,
|
|
3262
|
+
options: FirstDocumentMutationOptions,
|
|
3263
|
+
): Promise<SanityDocument<R>>
|
|
3264
|
+
/**
|
|
3265
|
+
* Perform mutation operations against the configured dataset.
|
|
3266
|
+
* Returns a promise that resolves to an array of the mutated documents.
|
|
3267
|
+
*
|
|
3268
|
+
* @param operations - Mutation operations to execute
|
|
3269
|
+
* @param options - Mutation options
|
|
3270
|
+
*/
|
|
3271
|
+
mutate<R extends Record<string, Any> = Record<string, Any>>(
|
|
3272
|
+
operations: Mutation<R>[] | Patch | Transaction,
|
|
3273
|
+
options: AllDocumentsMutationOptions,
|
|
3274
|
+
): Promise<SanityDocument<R>[]>
|
|
3275
|
+
/**
|
|
3276
|
+
* Perform mutation operations against the configured dataset
|
|
3277
|
+
* Returns a promise that resolves to a mutation result object containing the document ID of the first mutated document.
|
|
3278
|
+
*
|
|
3279
|
+
* @param operations - Mutation operations to execute
|
|
3280
|
+
* @param options - Mutation options
|
|
3281
|
+
*/
|
|
3282
|
+
mutate<R extends Record<string, Any> = Record<string, Any>>(
|
|
3283
|
+
operations: Mutation<R>[] | Patch | Transaction,
|
|
3284
|
+
options: FirstDocumentIdMutationOptions,
|
|
3285
|
+
): Promise<SingleMutationResult>
|
|
3286
|
+
/**
|
|
3287
|
+
* Perform mutation operations against the configured dataset
|
|
3288
|
+
* Returns a promise that resolves to a mutation result object containing the mutated document IDs.
|
|
3289
|
+
*
|
|
3290
|
+
* @param operations - Mutation operations to execute
|
|
3291
|
+
* @param options - Mutation options
|
|
3292
|
+
*/
|
|
3293
|
+
mutate<R extends Record<string, Any>>(
|
|
3294
|
+
operations: Mutation<R>[] | Patch | Transaction,
|
|
3295
|
+
options: AllDocumentIdsMutationOptions,
|
|
3296
|
+
): Promise<MultipleMutationResult>
|
|
3297
|
+
/**
|
|
3298
|
+
* Perform mutation operations against the configured dataset
|
|
3299
|
+
* Returns a promise that resolves to the first mutated document.
|
|
3300
|
+
*
|
|
3301
|
+
* @param operations - Mutation operations to execute
|
|
3302
|
+
* @param options - Mutation options
|
|
3303
|
+
*/
|
|
3304
|
+
mutate<R extends Record<string, Any> = Record<string, Any>>(
|
|
3305
|
+
operations: Mutation<R>[] | Patch | Transaction,
|
|
3306
|
+
options?: BaseMutationOptions,
|
|
3307
|
+
): Promise<SanityDocument<R>>
|
|
3308
|
+
/**
|
|
3309
|
+
* Create a new buildable patch of operations to perform
|
|
3310
|
+
*
|
|
3311
|
+
* @param documentId - Document ID to patch
|
|
3312
|
+
* @param operations - Optional object of patch operations to initialize the patch instance with
|
|
3313
|
+
* @returns Patch instance - call `.commit()` to perform the operations defined
|
|
3314
|
+
*/
|
|
3315
|
+
patch(documentId: string, operations?: PatchOperations): Patch
|
|
3316
|
+
/**
|
|
3317
|
+
* Create a new buildable patch of operations to perform
|
|
3318
|
+
*
|
|
3319
|
+
* @param documentIds - Array of document IDs to patch
|
|
3320
|
+
* @param operations - Optional object of patch operations to initialize the patch instance with
|
|
3321
|
+
* @returns Patch instance - call `.commit()` to perform the operations defined
|
|
3322
|
+
*/
|
|
3323
|
+
patch(documentIds: string[], operations?: PatchOperations): Patch
|
|
3324
|
+
/**
|
|
3325
|
+
* Create a new buildable patch of operations to perform
|
|
3326
|
+
*
|
|
3327
|
+
* @param selection - An object with `query` and optional `params`, defining which document(s) to patch
|
|
3328
|
+
* @param operations - Optional object of patch operations to initialize the patch instance with
|
|
3329
|
+
* @returns Patch instance - call `.commit()` to perform the operations defined
|
|
3330
|
+
*/
|
|
3331
|
+
patch(selection: MutationSelection, operations?: PatchOperations): Patch
|
|
3332
|
+
/**
|
|
3333
|
+
* Create a new transaction of mutations
|
|
3334
|
+
*
|
|
3335
|
+
* @param operations - Optional array of mutation operations to initialize the transaction instance with
|
|
3336
|
+
*/
|
|
3337
|
+
transaction<R extends Record<string, Any> = Record<string, Any>>(
|
|
3338
|
+
operations?: Mutation<R>[],
|
|
3339
|
+
): Transaction
|
|
3340
|
+
/**
|
|
3341
|
+
* Perform action operations against the configured dataset
|
|
3342
|
+
* Returns a promise that resolves to the transaction result
|
|
3343
|
+
*
|
|
3344
|
+
* @param operations - Action operation(s) to execute
|
|
3345
|
+
* @param options - Action options
|
|
3346
|
+
*/
|
|
3347
|
+
action(
|
|
3348
|
+
operations: Action | Action[],
|
|
3349
|
+
options?: BaseActionOptions,
|
|
3350
|
+
): Promise<SingleActionResult | MultipleActionResult>
|
|
3351
|
+
/**
|
|
3352
|
+
* Perform a request against the Sanity API
|
|
3353
|
+
* NOTE: Only use this for Sanity API endpoints, not for your own APIs!
|
|
3354
|
+
*
|
|
3355
|
+
* @param options - Request options
|
|
3356
|
+
* @returns Promise resolving to the response body
|
|
3357
|
+
*/
|
|
3358
|
+
request<R = Any>(options: RawRequestOptions): Promise<R>
|
|
3359
|
+
/**
|
|
3360
|
+
* Perform an HTTP request a `/data` sub-endpoint
|
|
3361
|
+
* NOTE: Considered internal, thus marked as deprecated. Use `request` instead.
|
|
3362
|
+
*
|
|
3363
|
+
* @deprecated - Use `request()` or your own HTTP library instead
|
|
3364
|
+
* @param endpoint - Endpoint to hit (mutate, query etc)
|
|
3365
|
+
* @param body - Request body
|
|
3366
|
+
* @param options - Request options
|
|
3367
|
+
* @internal
|
|
3368
|
+
*/
|
|
3369
|
+
dataRequest(endpoint: string, body: unknown, options?: BaseMutationOptions): Promise<Any>
|
|
3370
|
+
/**
|
|
3371
|
+
* Get a Sanity API URL for the URI provided
|
|
3372
|
+
*
|
|
3373
|
+
* @param uri - URI/path to build URL for
|
|
3374
|
+
* @param canUseCdn - Whether or not to allow using the API CDN for this route
|
|
2172
3375
|
*/
|
|
2173
|
-
|
|
3376
|
+
getUrl(uri: string, canUseCdn?: boolean): string
|
|
2174
3377
|
/**
|
|
2175
|
-
*
|
|
3378
|
+
* Get a Sanity API URL for the data operation and path provided
|
|
3379
|
+
*
|
|
3380
|
+
* @param operation - Data operation (eg `query`, `mutate`, `listen` or similar)
|
|
3381
|
+
* @param path - Path to append after the operation
|
|
2176
3382
|
*/
|
|
2177
|
-
|
|
2178
|
-
}
|
|
2179
|
-
|
|
2180
|
-
/** @public */
|
|
2181
|
-
export declare type QueryOptions =
|
|
2182
|
-
| FilteredResponseQueryOptions
|
|
2183
|
-
| UnfilteredResponseQueryOptions
|
|
2184
|
-
| UnfilteredResponseWithoutQuery
|
|
2185
|
-
|
|
2186
|
-
/** @public */
|
|
2187
|
-
export declare interface QueryParams {
|
|
2188
|
-
[key: string]: any
|
|
2189
|
-
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2190
|
-
body?: never
|
|
2191
|
-
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2192
|
-
cache?: 'next' extends keyof RequestInit ? never : any
|
|
2193
|
-
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2194
|
-
filterResponse?: never
|
|
2195
|
-
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2196
|
-
headers?: never
|
|
2197
|
-
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2198
|
-
method?: never
|
|
2199
|
-
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2200
|
-
next?: 'next' extends keyof RequestInit ? never : any
|
|
2201
|
-
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2202
|
-
perspective?: never
|
|
2203
|
-
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2204
|
-
query?: never
|
|
2205
|
-
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2206
|
-
resultSourceMap?: never
|
|
2207
|
-
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2208
|
-
returnQuery?: never
|
|
2209
|
-
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2210
|
-
signal?: never
|
|
2211
|
-
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2212
|
-
stega?: never
|
|
2213
|
-
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2214
|
-
tag?: never
|
|
2215
|
-
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2216
|
-
timeout?: never
|
|
2217
|
-
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2218
|
-
token?: never
|
|
2219
|
-
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2220
|
-
useCdn?: never
|
|
2221
|
-
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2222
|
-
lastLiveEventId?: never
|
|
2223
|
-
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2224
|
-
cacheMode?: never
|
|
2225
|
-
}
|
|
2226
|
-
|
|
2227
|
-
/**
|
|
2228
|
-
* This type can be used with `client.fetch` to indicate that the query has no GROQ parameters.
|
|
2229
|
-
* @public
|
|
2230
|
-
*/
|
|
2231
|
-
export declare type QueryWithoutParams = Record<string, never> | undefined
|
|
2232
|
-
|
|
2233
|
-
/** @public */
|
|
2234
|
-
export declare type RawQuerylessQueryResponse<R> = Omit<RawQueryResponse<R>, 'query'>
|
|
2235
|
-
|
|
2236
|
-
/** @public */
|
|
2237
|
-
export declare interface RawQueryResponse<R> {
|
|
2238
|
-
query: string
|
|
2239
|
-
ms: number
|
|
2240
|
-
result: R
|
|
2241
|
-
resultSourceMap?: ContentSourceMap
|
|
2242
|
-
/** Requires `apiVersion` to be `2021-03-25` or later. */
|
|
2243
|
-
syncTags?: SyncTag[]
|
|
2244
|
-
}
|
|
2245
|
-
|
|
2246
|
-
/** @internal */
|
|
2247
|
-
export declare interface RawRequestOptions {
|
|
2248
|
-
url?: string
|
|
2249
|
-
uri?: string
|
|
2250
|
-
method?: string
|
|
2251
|
-
token?: string
|
|
2252
|
-
json?: boolean
|
|
2253
|
-
tag?: string
|
|
2254
|
-
useGlobalApi?: boolean
|
|
2255
|
-
withCredentials?: boolean
|
|
2256
|
-
query?: {
|
|
2257
|
-
[key: string]: string | string[]
|
|
2258
|
-
}
|
|
2259
|
-
headers?: {
|
|
2260
|
-
[key: string]: string
|
|
2261
|
-
}
|
|
2262
|
-
timeout?: number
|
|
2263
|
-
proxy?: string
|
|
2264
|
-
body?: Any
|
|
2265
|
-
maxRedirects?: number
|
|
2266
|
-
signal?: AbortSignal
|
|
2267
|
-
}
|
|
2268
|
-
|
|
2269
|
-
/**
|
|
2270
|
-
* The listener has been disconnected, and a reconnect attempt is scheduled.
|
|
2271
|
-
*
|
|
2272
|
-
* @public
|
|
2273
|
-
*/
|
|
2274
|
-
export declare type ReconnectEvent = {
|
|
2275
|
-
type: 'reconnect'
|
|
3383
|
+
getDataUrl(operation: string, path?: string): string
|
|
2276
3384
|
}
|
|
2277
3385
|
|
|
2278
3386
|
/**
|
|
2279
|
-
*
|
|
2280
|
-
*
|
|
2281
|
-
*/
|
|
2282
|
-
export declare type ReleaseId = `r${string}`
|
|
2283
|
-
|
|
2284
|
-
/**
|
|
2285
|
-
* Replaces an existing draft document.
|
|
2286
|
-
* At least one of the draft or published versions of the document must exist.
|
|
2287
|
-
*
|
|
2288
|
-
* @public
|
|
3387
|
+
* Shared base type for the `SanityClient` and `ObservableSanityClient` classes.
|
|
3388
|
+
* TODO: refactor the Promise and Observable differences to use generics so we no longer suffer from all this duplication in TS docs
|
|
2289
3389
|
*/
|
|
2290
|
-
|
|
2291
|
-
|
|
3390
|
+
declare interface SanityClientBase {
|
|
3391
|
+
live: LiveClient
|
|
3392
|
+
listen: typeof _listen
|
|
2292
3393
|
/**
|
|
2293
|
-
*
|
|
3394
|
+
* Returns the current client configuration
|
|
2294
3395
|
*/
|
|
2295
|
-
|
|
3396
|
+
config(): InitializedClientConfig
|
|
2296
3397
|
/**
|
|
2297
|
-
*
|
|
3398
|
+
* Reconfigure the client. Note that this _mutates_ the current client.
|
|
2298
3399
|
*/
|
|
2299
|
-
|
|
2300
|
-
}
|
|
2301
|
-
|
|
2302
|
-
/** @public */
|
|
2303
|
-
export declare const requester: Requester
|
|
2304
|
-
|
|
2305
|
-
/** @internal */
|
|
2306
|
-
export declare interface RequestObservableOptions extends Omit<RequestOptions, 'url'> {
|
|
2307
|
-
url?: string
|
|
2308
|
-
uri?: string
|
|
2309
|
-
canUseCdn?: boolean
|
|
2310
|
-
useCdn?: boolean
|
|
2311
|
-
tag?: string
|
|
2312
|
-
returnQuery?: boolean
|
|
2313
|
-
resultSourceMap?: boolean | 'withKeyArraySelector'
|
|
2314
|
-
perspective?: ClientPerspective
|
|
2315
|
-
lastLiveEventId?: string
|
|
2316
|
-
cacheMode?: 'noStale'
|
|
2317
|
-
}
|
|
2318
|
-
|
|
2319
|
-
/** @public */
|
|
2320
|
-
export declare interface RequestOptions {
|
|
2321
|
-
timeout?: number
|
|
2322
|
-
token?: string
|
|
2323
|
-
tag?: string
|
|
2324
|
-
headers?: Record<string, string>
|
|
2325
|
-
method?: string
|
|
2326
|
-
query?: Any
|
|
2327
|
-
body?: Any
|
|
2328
|
-
signal?: AbortSignal
|
|
2329
|
-
}
|
|
2330
|
-
|
|
2331
|
-
export {ResolveStudioUrl}
|
|
2332
|
-
|
|
2333
|
-
/** @public */
|
|
2334
|
-
export declare interface ResponseEvent<T = unknown> {
|
|
2335
|
-
type: 'response'
|
|
2336
|
-
body: T
|
|
2337
|
-
url: string
|
|
2338
|
-
method: string
|
|
2339
|
-
statusCode: number
|
|
2340
|
-
statusMessage?: string
|
|
2341
|
-
headers: Record<string, string>
|
|
2342
|
-
}
|
|
2343
|
-
|
|
2344
|
-
/** @public */
|
|
2345
|
-
export declare interface ResponseQueryOptions extends RequestOptions {
|
|
2346
|
-
perspective?: ClientPerspective
|
|
2347
|
-
resultSourceMap?: boolean | 'withKeyArraySelector'
|
|
2348
|
-
returnQuery?: boolean
|
|
2349
|
-
useCdn?: boolean
|
|
2350
|
-
stega?: boolean | StegaConfig
|
|
2351
|
-
cache?: 'next' extends keyof RequestInit ? RequestInit['cache'] : never
|
|
2352
|
-
next?: ('next' extends keyof RequestInit ? RequestInit : never)['next']
|
|
2353
|
-
lastLiveEventId?: string | string[] | null
|
|
3400
|
+
config(newConfig?: Partial<ClientConfig>): this
|
|
2354
3401
|
/**
|
|
2355
|
-
*
|
|
2356
|
-
* Tradeoff between latency and freshness of content.
|
|
3402
|
+
* Get a Sanity API URL for the URI provided
|
|
2357
3403
|
*
|
|
2358
|
-
*
|
|
3404
|
+
* @param uri - URI/path to build URL for
|
|
3405
|
+
* @param canUseCdn - Whether or not to allow using the API CDN for this route
|
|
2359
3406
|
*/
|
|
2360
|
-
|
|
2361
|
-
|
|
2362
|
-
|
|
2363
|
-
|
|
2364
|
-
|
|
2365
|
-
|
|
2366
|
-
|
|
2367
|
-
|
|
2368
|
-
assetId: string
|
|
2369
|
-
mimeType: string
|
|
2370
|
-
sha1hash: string
|
|
2371
|
-
extension: string
|
|
2372
|
-
uploadId?: string
|
|
2373
|
-
originalFilename?: string
|
|
3407
|
+
getUrl(uri: string, canUseCdn?: boolean): string
|
|
3408
|
+
/**
|
|
3409
|
+
* Get a Sanity API URL for the data operation and path provided
|
|
3410
|
+
*
|
|
3411
|
+
* @param operation - Data operation (eg `query`, `mutate`, `listen` or similar)
|
|
3412
|
+
* @param path - Path to append after the operation
|
|
3413
|
+
*/
|
|
3414
|
+
getDataUrl(operation: string, path?: string): string
|
|
2374
3415
|
}
|
|
2375
3416
|
|
|
2376
|
-
/**
|
|
2377
|
-
|
|
2378
|
-
|
|
3417
|
+
/**
|
|
3418
|
+
* The interface implemented by the `SanityClient` class.
|
|
3419
|
+
* When writing code that wants to take an instance of `SanityClient` as input it's better to use this type,
|
|
3420
|
+
* as the `SanityClient` class has private properties and thus TypeScrict will consider the type incompatible
|
|
3421
|
+
* in cases where you might have multiple `@sanity/client` instances in your node_modules.
|
|
3422
|
+
* @public
|
|
3423
|
+
*/
|
|
3424
|
+
export declare interface SanityClientType extends SanityClientBase {
|
|
2379
3425
|
assets: AssetsClient
|
|
2380
3426
|
datasets: DatasetsClient
|
|
2381
|
-
live: LiveClient
|
|
2382
3427
|
projects: ProjectsClient
|
|
2383
3428
|
users: UsersClient
|
|
2384
3429
|
/**
|
|
2385
3430
|
* Observable version of the Sanity client, with the same configuration as the promise-based one
|
|
2386
3431
|
*/
|
|
2387
3432
|
observable: ObservableSanityClient
|
|
2388
|
-
/**
|
|
2389
|
-
* Instance properties
|
|
2390
|
-
*/
|
|
2391
|
-
listen: typeof _listen
|
|
2392
|
-
constructor(httpRequest: HttpRequest, config?: ClientConfig)
|
|
2393
3433
|
/**
|
|
2394
3434
|
* Clone the client - returns a new instance
|
|
2395
3435
|
*/
|
|
2396
3436
|
clone(): SanityClient
|
|
2397
|
-
/**
|
|
2398
|
-
* Returns the current client configuration
|
|
2399
|
-
*/
|
|
2400
|
-
config(): InitializedClientConfig
|
|
2401
|
-
/**
|
|
2402
|
-
* Reconfigure the client. Note that this _mutates_ the current client.
|
|
2403
|
-
*/
|
|
2404
|
-
config(newConfig?: Partial<ClientConfig>): this
|
|
2405
3437
|
/**
|
|
2406
3438
|
* Clone the client with a new (partial) configuration.
|
|
2407
3439
|
*
|
|
@@ -2417,7 +3449,10 @@ export declare class SanityClient {
|
|
|
2417
3449
|
R = Any,
|
|
2418
3450
|
Q extends QueryWithoutParams = QueryWithoutParams,
|
|
2419
3451
|
const G extends string = string,
|
|
2420
|
-
>(
|
|
3452
|
+
>(
|
|
3453
|
+
query: G,
|
|
3454
|
+
params?: Q | QueryWithoutParams,
|
|
3455
|
+
): Promise<ClientReturn<G, R>>
|
|
2421
3456
|
/**
|
|
2422
3457
|
* Perform a GROQ-query against the configured dataset.
|
|
2423
3458
|
*
|
|
@@ -2843,6 +3878,14 @@ export declare class SanityClient {
|
|
|
2843
3878
|
* @returns Patch instance - call `.commit()` to perform the operations defined
|
|
2844
3879
|
*/
|
|
2845
3880
|
patch(selection: MutationSelection, operations?: PatchOperations): Patch
|
|
3881
|
+
/**
|
|
3882
|
+
* Create a new buildable patch of operations to perform
|
|
3883
|
+
*
|
|
3884
|
+
* @param selection - Document ID, an array of document IDs, or an object with `query` and optional `params`, defining which document(s) to patch
|
|
3885
|
+
* @param operations - Optional object of patch operations to initialize the patch instance with
|
|
3886
|
+
* @returns Patch instance - call `.commit()` to perform the operations defined
|
|
3887
|
+
*/
|
|
3888
|
+
patch(selection: PatchSelection, operations?: PatchOperations): Patch
|
|
2846
3889
|
/**
|
|
2847
3890
|
* Create a new transaction of mutations
|
|
2848
3891
|
*
|
|
@@ -2881,20 +3924,6 @@ export declare class SanityClient {
|
|
|
2881
3924
|
* @internal
|
|
2882
3925
|
*/
|
|
2883
3926
|
dataRequest(endpoint: string, body: unknown, options?: BaseMutationOptions): Promise<Any>
|
|
2884
|
-
/**
|
|
2885
|
-
* Get a Sanity API URL for the URI provided
|
|
2886
|
-
*
|
|
2887
|
-
* @param uri - URI/path to build URL for
|
|
2888
|
-
* @param canUseCdn - Whether or not to allow using the API CDN for this route
|
|
2889
|
-
*/
|
|
2890
|
-
getUrl(uri: string, canUseCdn?: boolean): string
|
|
2891
|
-
/**
|
|
2892
|
-
* Get a Sanity API URL for the data operation and path provided
|
|
2893
|
-
*
|
|
2894
|
-
* @param operation - Data operation (eg `query`, `mutate`, `listen` or similar)
|
|
2895
|
-
* @param path - Path to append after the operation
|
|
2896
|
-
*/
|
|
2897
|
-
getDataUrl(operation: string, path?: string): string
|
|
2898
3927
|
}
|
|
2899
3928
|
|
|
2900
3929
|
/** @internal */
|