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