@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/stega.d.ts
CHANGED
|
@@ -69,7 +69,7 @@ export declare type AssetMetadataType =
|
|
|
69
69
|
| 'none'
|
|
70
70
|
|
|
71
71
|
/** @internal */
|
|
72
|
-
export declare class AssetsClient {
|
|
72
|
+
export declare class AssetsClient implements AssetsClientType {
|
|
73
73
|
#private
|
|
74
74
|
constructor(client: SanityClient, httpRequest: HttpRequest)
|
|
75
75
|
/**
|
|
@@ -110,6 +110,52 @@ export declare class AssetsClient {
|
|
|
110
110
|
): Promise<SanityAssetDocument | SanityImageAssetDocument>
|
|
111
111
|
}
|
|
112
112
|
|
|
113
|
+
/**
|
|
114
|
+
* The interface implemented by the `AssetsClient` class.
|
|
115
|
+
* When writing code that wants to take an instance of `AssetsClient` as input it's better to use this type,
|
|
116
|
+
* as the `AssetsClient` class has private properties and thus TypeScript will consider the type incompatible
|
|
117
|
+
* in cases where you might have multiple `@sanity/client` instances in your node_modules.
|
|
118
|
+
* @public
|
|
119
|
+
*/
|
|
120
|
+
declare interface AssetsClientType {
|
|
121
|
+
/**
|
|
122
|
+
* Uploads a file asset to the configured dataset
|
|
123
|
+
*
|
|
124
|
+
* @param assetType - Asset type (file)
|
|
125
|
+
* @param body - Asset content - can be a browser File instance, a Blob, a Node.js Buffer instance or a Node.js ReadableStream.
|
|
126
|
+
* @param options - Options to use for the upload
|
|
127
|
+
*/
|
|
128
|
+
upload(
|
|
129
|
+
assetType: 'file',
|
|
130
|
+
body: UploadBody,
|
|
131
|
+
options?: UploadClientConfig,
|
|
132
|
+
): Promise<SanityAssetDocument>
|
|
133
|
+
/**
|
|
134
|
+
* Uploads an image asset to the configured dataset
|
|
135
|
+
*
|
|
136
|
+
* @param assetType - Asset type (image)
|
|
137
|
+
* @param body - Asset content - can be a browser File instance, a Blob, a Node.js Buffer instance or a Node.js ReadableStream.
|
|
138
|
+
* @param options - Options to use for the upload
|
|
139
|
+
*/
|
|
140
|
+
upload(
|
|
141
|
+
assetType: 'image',
|
|
142
|
+
body: UploadBody,
|
|
143
|
+
options?: UploadClientConfig,
|
|
144
|
+
): Promise<SanityImageAssetDocument>
|
|
145
|
+
/**
|
|
146
|
+
* Uploads a file or an image asset to the configured dataset
|
|
147
|
+
*
|
|
148
|
+
* @param assetType - Asset type (file/image)
|
|
149
|
+
* @param body - Asset content - can be a browser File instance, a Blob, a Node.js Buffer instance or a Node.js ReadableStream.
|
|
150
|
+
* @param options - Options to use for the upload
|
|
151
|
+
*/
|
|
152
|
+
upload(
|
|
153
|
+
assetType: 'file' | 'image',
|
|
154
|
+
body: UploadBody,
|
|
155
|
+
options?: UploadClientConfig,
|
|
156
|
+
): Promise<SanityAssetDocument | SanityImageAssetDocument>
|
|
157
|
+
}
|
|
158
|
+
|
|
113
159
|
/** @internal */
|
|
114
160
|
export declare type AttributeSet = {
|
|
115
161
|
[key: string]: Any
|
|
@@ -1463,7 +1509,7 @@ export declare type MutationSelectionQueryParams = {
|
|
|
1463
1509
|
}
|
|
1464
1510
|
|
|
1465
1511
|
/** @internal */
|
|
1466
|
-
export declare class ObservableAssetsClient {
|
|
1512
|
+
export declare class ObservableAssetsClient implements ObservableAssetsClientType {
|
|
1467
1513
|
#private
|
|
1468
1514
|
constructor(client: ObservableSanityClient, httpRequest: HttpRequest)
|
|
1469
1515
|
/**
|
|
@@ -1516,6 +1562,64 @@ export declare class ObservableAssetsClient {
|
|
|
1516
1562
|
>
|
|
1517
1563
|
}
|
|
1518
1564
|
|
|
1565
|
+
/**
|
|
1566
|
+
* The interface implemented by the `ObservableAssetsClient` class.
|
|
1567
|
+
* When writing code that wants to take an instance of `ObservableAssetsClient` as input it's better to use this type,
|
|
1568
|
+
* as the `ObservableAssetsClient` class has private properties and thus TypeScript will consider the type incompatible
|
|
1569
|
+
* in cases where you might have multiple `@sanity/client` instances in your node_modules.
|
|
1570
|
+
* @public
|
|
1571
|
+
*/
|
|
1572
|
+
declare interface ObservableAssetsClientType {
|
|
1573
|
+
/**
|
|
1574
|
+
* Uploads a file asset to the configured dataset
|
|
1575
|
+
*
|
|
1576
|
+
* @param assetType - Asset type (file)
|
|
1577
|
+
* @param body - Asset content - can be a browser File instance, a Blob, a Node.js Buffer instance or a Node.js ReadableStream.
|
|
1578
|
+
* @param options - Options to use for the upload
|
|
1579
|
+
*/
|
|
1580
|
+
upload(
|
|
1581
|
+
assetType: 'file',
|
|
1582
|
+
body: UploadBody,
|
|
1583
|
+
options?: UploadClientConfig,
|
|
1584
|
+
): Observable<
|
|
1585
|
+
HttpRequestEvent<{
|
|
1586
|
+
document: SanityAssetDocument
|
|
1587
|
+
}>
|
|
1588
|
+
>
|
|
1589
|
+
/**
|
|
1590
|
+
* Uploads an image asset to the configured dataset
|
|
1591
|
+
*
|
|
1592
|
+
* @param assetType - Asset type (image)
|
|
1593
|
+
* @param body - Asset content - can be a browser File instance, a Blob, a Node.js Buffer instance or a Node.js ReadableStream.
|
|
1594
|
+
* @param options - Options to use for the upload
|
|
1595
|
+
*/
|
|
1596
|
+
upload(
|
|
1597
|
+
assetType: 'image',
|
|
1598
|
+
body: UploadBody,
|
|
1599
|
+
options?: UploadClientConfig,
|
|
1600
|
+
): Observable<
|
|
1601
|
+
HttpRequestEvent<{
|
|
1602
|
+
document: SanityImageAssetDocument
|
|
1603
|
+
}>
|
|
1604
|
+
>
|
|
1605
|
+
/**
|
|
1606
|
+
* Uploads a file or an image asset to the configured dataset
|
|
1607
|
+
*
|
|
1608
|
+
* @param assetType - Asset type (file/image)
|
|
1609
|
+
* @param body - Asset content - can be a browser File instance, a Blob, a Node.js Buffer instance or a Node.js ReadableStream.
|
|
1610
|
+
* @param options - Options to use for the upload
|
|
1611
|
+
*/
|
|
1612
|
+
upload(
|
|
1613
|
+
assetType: 'file' | 'image',
|
|
1614
|
+
body: UploadBody,
|
|
1615
|
+
options?: UploadClientConfig,
|
|
1616
|
+
): Observable<
|
|
1617
|
+
HttpRequestEvent<{
|
|
1618
|
+
document: SanityAssetDocument | SanityImageAssetDocument
|
|
1619
|
+
}>
|
|
1620
|
+
>
|
|
1621
|
+
}
|
|
1622
|
+
|
|
1519
1623
|
/** @internal */
|
|
1520
1624
|
export declare class ObservableDatasetsClient {
|
|
1521
1625
|
#private
|
|
@@ -1632,16 +1736,13 @@ export declare class ObservableProjectsClient {
|
|
|
1632
1736
|
}
|
|
1633
1737
|
|
|
1634
1738
|
/** @public */
|
|
1635
|
-
export declare class ObservableSanityClient {
|
|
1739
|
+
export declare class ObservableSanityClient implements ObservableSanityClientType {
|
|
1636
1740
|
#private
|
|
1637
1741
|
assets: ObservableAssetsClient
|
|
1638
1742
|
datasets: ObservableDatasetsClient
|
|
1639
1743
|
live: LiveClient
|
|
1640
1744
|
projects: ObservableProjectsClient
|
|
1641
1745
|
users: ObservableUsersClient
|
|
1642
|
-
/**
|
|
1643
|
-
* Instance properties
|
|
1644
|
-
*/
|
|
1645
1746
|
listen: typeof _listen
|
|
1646
1747
|
constructor(httpRequest: HttpRequest, config?: ClientConfig)
|
|
1647
1748
|
/**
|
|
@@ -1700,7 +1801,7 @@ export declare class ObservableSanityClient {
|
|
|
1700
1801
|
Q extends QueryWithoutParams | QueryParams = QueryParams,
|
|
1701
1802
|
const G extends string = string,
|
|
1702
1803
|
>(
|
|
1703
|
-
query:
|
|
1804
|
+
query: G,
|
|
1704
1805
|
params: Q extends QueryWithoutParams ? QueryWithoutParams : Q,
|
|
1705
1806
|
options: UnfilteredResponseQueryOptions,
|
|
1706
1807
|
): Observable<RawQueryResponse<ClientReturn<G, R>>>
|
|
@@ -2136,453 +2237,1496 @@ export declare class ObservableSanityClient {
|
|
|
2136
2237
|
}
|
|
2137
2238
|
|
|
2138
2239
|
/**
|
|
2139
|
-
*
|
|
2240
|
+
* The interface implemented by the `ObservableSanityClient` class.
|
|
2241
|
+
* When writing code that wants to take an instance of `ObservableSanityClient` as input it's better to use this type,
|
|
2242
|
+
* as the `ObservableSanityClient` class has private properties and thus TypeScrict will consider the type incompatible
|
|
2243
|
+
* in cases where you might have multiple `@sanity/client` instances in your node_modules.
|
|
2140
2244
|
* @public
|
|
2141
2245
|
*/
|
|
2142
|
-
export declare
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
constructor(operations?: Mutation[], client?: ObservableSanityClient, transactionId?: string)
|
|
2246
|
+
export declare interface ObservableSanityClientType extends SanityClientBase {
|
|
2247
|
+
assets: ObservableAssetsClient
|
|
2248
|
+
datasets: ObservableDatasetsClient
|
|
2249
|
+
projects: ObservableProjectsClient
|
|
2250
|
+
users: ObservableUsersClient
|
|
2148
2251
|
/**
|
|
2149
|
-
*
|
|
2252
|
+
* Clone the client - returns a new instance
|
|
2150
2253
|
*/
|
|
2151
|
-
clone():
|
|
2254
|
+
clone(): ObservableSanityClientType
|
|
2152
2255
|
/**
|
|
2153
|
-
*
|
|
2154
|
-
*
|
|
2155
|
-
* @param options - Options for the mutation operation
|
|
2256
|
+
* Returns the current client configuration
|
|
2156
2257
|
*/
|
|
2157
|
-
|
|
2158
|
-
options: TransactionFirstDocumentMutationOptions,
|
|
2159
|
-
): Observable<SanityDocument<R>>
|
|
2258
|
+
config(): InitializedClientConfig
|
|
2160
2259
|
/**
|
|
2161
|
-
*
|
|
2162
|
-
*
|
|
2163
|
-
* @param options - Options for the mutation operation
|
|
2260
|
+
* Reconfigure the client. Note that this _mutates_ the current client.
|
|
2164
2261
|
*/
|
|
2165
|
-
|
|
2166
|
-
options: TransactionAllDocumentsMutationOptions,
|
|
2167
|
-
): Observable<SanityDocument<R>[]>
|
|
2262
|
+
config(newConfig?: Partial<ClientConfig>): ObservableSanityClientType
|
|
2168
2263
|
/**
|
|
2169
|
-
*
|
|
2264
|
+
* Clone the client with a new (partial) configuration.
|
|
2170
2265
|
*
|
|
2171
|
-
* @param
|
|
2266
|
+
* @param newConfig - New client configuration properties, shallowly merged with existing configuration
|
|
2172
2267
|
*/
|
|
2173
|
-
|
|
2268
|
+
withConfig(newConfig?: Partial<ClientConfig>): ObservableSanityClientType
|
|
2174
2269
|
/**
|
|
2175
|
-
*
|
|
2270
|
+
* Perform a GROQ-query against the configured dataset.
|
|
2176
2271
|
*
|
|
2177
|
-
* @param
|
|
2272
|
+
* @param query - GROQ-query to perform
|
|
2178
2273
|
*/
|
|
2179
|
-
|
|
2274
|
+
fetch<
|
|
2275
|
+
R = Any,
|
|
2276
|
+
Q extends QueryWithoutParams = QueryWithoutParams,
|
|
2277
|
+
const G extends string = string,
|
|
2278
|
+
>(
|
|
2279
|
+
query: G,
|
|
2280
|
+
params?: Q | QueryWithoutParams,
|
|
2281
|
+
): Observable<ClientReturn<G, R>>
|
|
2180
2282
|
/**
|
|
2181
|
-
*
|
|
2283
|
+
* Perform a GROQ-query against the configured dataset.
|
|
2182
2284
|
*
|
|
2183
|
-
* @param
|
|
2285
|
+
* @param query - GROQ-query to perform
|
|
2286
|
+
* @param params - Optional query parameters
|
|
2287
|
+
* @param options - Optional request options
|
|
2184
2288
|
*/
|
|
2185
|
-
|
|
2289
|
+
fetch<
|
|
2290
|
+
R = Any,
|
|
2291
|
+
Q extends QueryWithoutParams | QueryParams = QueryParams,
|
|
2292
|
+
const G extends string = string,
|
|
2293
|
+
>(
|
|
2294
|
+
query: G,
|
|
2295
|
+
params: Q extends QueryWithoutParams ? QueryWithoutParams : Q,
|
|
2296
|
+
options?: FilteredResponseQueryOptions,
|
|
2297
|
+
): Observable<ClientReturn<G, R>>
|
|
2186
2298
|
/**
|
|
2187
|
-
*
|
|
2188
|
-
* The operation is added to the current transaction, ready to be commited by `commit()`
|
|
2299
|
+
* Perform a GROQ-query against the configured dataset.
|
|
2189
2300
|
*
|
|
2190
|
-
* @param
|
|
2191
|
-
* @param
|
|
2301
|
+
* @param query - GROQ-query to perform
|
|
2302
|
+
* @param params - Optional query parameters
|
|
2303
|
+
* @param options - Request options
|
|
2192
2304
|
*/
|
|
2193
|
-
|
|
2305
|
+
fetch<
|
|
2306
|
+
R = Any,
|
|
2307
|
+
Q extends QueryWithoutParams | QueryParams = QueryParams,
|
|
2308
|
+
const G extends string = string,
|
|
2309
|
+
>(
|
|
2310
|
+
query: G,
|
|
2311
|
+
params: Q extends QueryWithoutParams ? QueryWithoutParams : Q,
|
|
2312
|
+
options: UnfilteredResponseQueryOptions,
|
|
2313
|
+
): Observable<RawQueryResponse<ClientReturn<G, R>>>
|
|
2194
2314
|
/**
|
|
2195
|
-
*
|
|
2196
|
-
* The operation is added to the current transaction, ready to be commited by `commit()`
|
|
2315
|
+
* Perform a GROQ-query against the configured dataset.
|
|
2197
2316
|
*
|
|
2198
|
-
* @param
|
|
2317
|
+
* @param query - GROQ-query to perform
|
|
2318
|
+
* @param params - Optional query parameters
|
|
2319
|
+
* @param options - Request options
|
|
2199
2320
|
*/
|
|
2200
|
-
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
|
|
2205
|
-
|
|
2206
|
-
|
|
2321
|
+
fetch<
|
|
2322
|
+
R = Any,
|
|
2323
|
+
Q extends QueryWithoutParams | QueryParams = QueryParams,
|
|
2324
|
+
const G extends string = string,
|
|
2325
|
+
>(
|
|
2326
|
+
query: G,
|
|
2327
|
+
params: Q extends QueryWithoutParams ? QueryWithoutParams : Q,
|
|
2328
|
+
options: UnfilteredResponseWithoutQuery,
|
|
2329
|
+
): Observable<RawQuerylessQueryResponse<ClientReturn<G, R>>>
|
|
2207
2330
|
/**
|
|
2208
|
-
* Fetch a
|
|
2331
|
+
* Fetch a single document with the given ID.
|
|
2209
2332
|
*
|
|
2210
|
-
* @param id -
|
|
2333
|
+
* @param id - Document ID to fetch
|
|
2334
|
+
* @param options - Request options
|
|
2211
2335
|
*/
|
|
2212
|
-
|
|
2213
|
-
id:
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
* The listener connection has been established
|
|
2219
|
-
* note: it's usually a better option to use the 'welcome' event
|
|
2220
|
-
* @public
|
|
2221
|
-
*/
|
|
2222
|
-
export declare type OpenEvent = {
|
|
2223
|
-
type: 'open'
|
|
2224
|
-
}
|
|
2225
|
-
|
|
2226
|
-
/** @public */
|
|
2227
|
-
export declare class Patch extends BasePatch {
|
|
2228
|
-
#private
|
|
2229
|
-
constructor(selection: PatchSelection, operations?: PatchOperations, client?: SanityClient)
|
|
2336
|
+
getDocument<R extends Record<string, Any> = Record<string, Any>>(
|
|
2337
|
+
id: string,
|
|
2338
|
+
options?: {
|
|
2339
|
+
tag?: string
|
|
2340
|
+
},
|
|
2341
|
+
): Observable<SanityDocument<R> | undefined>
|
|
2230
2342
|
/**
|
|
2231
|
-
*
|
|
2343
|
+
* Fetch multiple documents in one request.
|
|
2344
|
+
* Should be used sparingly - performing a query is usually a better option.
|
|
2345
|
+
* The order/position of documents is preserved based on the original array of IDs.
|
|
2346
|
+
* If any of the documents are missing, they will be replaced by a `null` entry in the returned array
|
|
2347
|
+
*
|
|
2348
|
+
* @param ids - Document IDs to fetch
|
|
2349
|
+
* @param options - Request options
|
|
2232
2350
|
*/
|
|
2233
|
-
|
|
2351
|
+
getDocuments<R extends Record<string, Any> = Record<string, Any>>(
|
|
2352
|
+
ids: string[],
|
|
2353
|
+
options?: {
|
|
2354
|
+
tag?: string
|
|
2355
|
+
},
|
|
2356
|
+
): Observable<(SanityDocument<R> | null)[]>
|
|
2234
2357
|
/**
|
|
2235
|
-
*
|
|
2358
|
+
* Create a document. Requires a `_type` property. If no `_id` is provided, it will be generated by the database.
|
|
2359
|
+
* Returns an observable that resolves to the created document.
|
|
2236
2360
|
*
|
|
2237
|
-
* @param
|
|
2361
|
+
* @param document - Document to create
|
|
2362
|
+
* @param options - Mutation options
|
|
2238
2363
|
*/
|
|
2239
|
-
|
|
2364
|
+
create<R extends Record<string, Any> = Record<string, Any>>(
|
|
2365
|
+
document: SanityDocumentStub<R>,
|
|
2240
2366
|
options: FirstDocumentMutationOptions,
|
|
2241
|
-
):
|
|
2367
|
+
): Observable<SanityDocument<R>>
|
|
2242
2368
|
/**
|
|
2243
|
-
*
|
|
2369
|
+
* Create a document. Requires a `_type` property. If no `_id` is provided, it will be generated by the database.
|
|
2370
|
+
* Returns an observable that resolves to an array containing the created document.
|
|
2371
|
+
*
|
|
2372
|
+
* @param document - Document to create
|
|
2373
|
+
* @param options - Mutation options
|
|
2374
|
+
*/
|
|
2375
|
+
create<R extends Record<string, Any> = Record<string, Any>>(
|
|
2376
|
+
document: SanityDocumentStub<R>,
|
|
2377
|
+
options: AllDocumentsMutationOptions,
|
|
2378
|
+
): Observable<SanityDocument<R>[]>
|
|
2379
|
+
/**
|
|
2380
|
+
* Create a document. Requires a `_type` property. If no `_id` is provided, it will be generated by the database.
|
|
2381
|
+
* Returns an observable that resolves to a mutation result object containing the ID of the created document.
|
|
2382
|
+
*
|
|
2383
|
+
* @param document - Document to create
|
|
2384
|
+
* @param options - Mutation options
|
|
2385
|
+
*/
|
|
2386
|
+
create<R extends Record<string, Any> = Record<string, Any>>(
|
|
2387
|
+
document: SanityDocumentStub<R>,
|
|
2388
|
+
options: FirstDocumentIdMutationOptions,
|
|
2389
|
+
): Observable<SingleMutationResult>
|
|
2390
|
+
/**
|
|
2391
|
+
* Create a document. Requires a `_type` property. If no `_id` is provided, it will be generated by the database.
|
|
2392
|
+
* Returns an observable that resolves to a mutation result object containing the ID of the created document.
|
|
2393
|
+
*
|
|
2394
|
+
* @param document - Document to create
|
|
2395
|
+
* @param options - Mutation options
|
|
2396
|
+
*/
|
|
2397
|
+
create<R extends Record<string, Any> = Record<string, Any>>(
|
|
2398
|
+
document: SanityDocumentStub<R>,
|
|
2399
|
+
options: AllDocumentIdsMutationOptions,
|
|
2400
|
+
): Observable<MultipleMutationResult>
|
|
2401
|
+
/**
|
|
2402
|
+
* Create a document. Requires a `_type` property. If no `_id` is provided, it will be generated by the database.
|
|
2403
|
+
* Returns an observable that resolves to the created document.
|
|
2404
|
+
*
|
|
2405
|
+
* @param document - Document to create
|
|
2406
|
+
* @param options - Mutation options
|
|
2407
|
+
*/
|
|
2408
|
+
create<R extends Record<string, Any> = Record<string, Any>>(
|
|
2409
|
+
document: SanityDocumentStub<R>,
|
|
2410
|
+
options?: BaseMutationOptions,
|
|
2411
|
+
): Observable<SanityDocument<R>>
|
|
2412
|
+
/**
|
|
2413
|
+
* Create a document if no document with the same ID already exists.
|
|
2414
|
+
* Returns an observable that resolves to the created document.
|
|
2415
|
+
*
|
|
2416
|
+
* @param document - Document to create
|
|
2417
|
+
* @param options - Mutation options
|
|
2418
|
+
*/
|
|
2419
|
+
createIfNotExists<R extends Record<string, Any> = Record<string, Any>>(
|
|
2420
|
+
document: IdentifiedSanityDocumentStub<R>,
|
|
2421
|
+
options: FirstDocumentMutationOptions,
|
|
2422
|
+
): Observable<SanityDocument<R>>
|
|
2423
|
+
/**
|
|
2424
|
+
* Create a document if no document with the same ID already exists.
|
|
2425
|
+
* Returns an observable that resolves to an array containing the created document.
|
|
2426
|
+
*
|
|
2427
|
+
* @param document - Document to create
|
|
2428
|
+
* @param options - Mutation options
|
|
2429
|
+
*/
|
|
2430
|
+
createIfNotExists<R extends Record<string, Any> = Record<string, Any>>(
|
|
2431
|
+
document: IdentifiedSanityDocumentStub<R>,
|
|
2432
|
+
options: AllDocumentsMutationOptions,
|
|
2433
|
+
): Observable<SanityDocument<R>[]>
|
|
2434
|
+
/**
|
|
2435
|
+
* Create a document if no document with the same ID already exists.
|
|
2436
|
+
* Returns an observable that resolves to a mutation result object containing the ID of the created document.
|
|
2437
|
+
*
|
|
2438
|
+
* @param document - Document to create
|
|
2439
|
+
* @param options - Mutation options
|
|
2440
|
+
*/
|
|
2441
|
+
createIfNotExists<R extends Record<string, Any> = Record<string, Any>>(
|
|
2442
|
+
document: IdentifiedSanityDocumentStub<R>,
|
|
2443
|
+
options: FirstDocumentIdMutationOptions,
|
|
2444
|
+
): Observable<SingleMutationResult>
|
|
2445
|
+
/**
|
|
2446
|
+
* Create a document if no document with the same ID already exists.
|
|
2447
|
+
* Returns an observable that resolves to a mutation result object containing the ID of the created document.
|
|
2448
|
+
*
|
|
2449
|
+
* @param document - Document to create
|
|
2450
|
+
* @param options - Mutation options
|
|
2451
|
+
*/
|
|
2452
|
+
createIfNotExists<R extends Record<string, Any> = Record<string, Any>>(
|
|
2453
|
+
document: IdentifiedSanityDocumentStub<R>,
|
|
2454
|
+
options: AllDocumentIdsMutationOptions,
|
|
2455
|
+
): Observable<MultipleMutationResult>
|
|
2456
|
+
/**
|
|
2457
|
+
* Create a document if no document with the same ID already exists.
|
|
2458
|
+
* Returns an observable that resolves to the created document.
|
|
2459
|
+
*
|
|
2460
|
+
* @param document - Document to create
|
|
2461
|
+
* @param options - Mutation options
|
|
2462
|
+
*/
|
|
2463
|
+
createIfNotExists<R extends Record<string, Any> = Record<string, Any>>(
|
|
2464
|
+
document: IdentifiedSanityDocumentStub<R>,
|
|
2465
|
+
options?: BaseMutationOptions,
|
|
2466
|
+
): Observable<SanityDocument<R>>
|
|
2467
|
+
/**
|
|
2468
|
+
* Create a document if it does not exist, or replace a document with the same document ID
|
|
2469
|
+
* Returns an observable that resolves to the created document.
|
|
2470
|
+
*
|
|
2471
|
+
* @param document - Document to either create or replace
|
|
2472
|
+
* @param options - Mutation options
|
|
2473
|
+
*/
|
|
2474
|
+
createOrReplace<R extends Record<string, Any> = Record<string, Any>>(
|
|
2475
|
+
document: IdentifiedSanityDocumentStub<R>,
|
|
2476
|
+
options: FirstDocumentMutationOptions,
|
|
2477
|
+
): Observable<SanityDocument<R>>
|
|
2478
|
+
/**
|
|
2479
|
+
* Create a document if it does not exist, or replace a document with the same document ID
|
|
2480
|
+
* Returns an observable that resolves to an array containing the created document.
|
|
2481
|
+
*
|
|
2482
|
+
* @param document - Document to either create or replace
|
|
2483
|
+
* @param options - Mutation options
|
|
2484
|
+
*/
|
|
2485
|
+
createOrReplace<R extends Record<string, Any> = Record<string, Any>>(
|
|
2486
|
+
document: IdentifiedSanityDocumentStub<R>,
|
|
2487
|
+
options: AllDocumentsMutationOptions,
|
|
2488
|
+
): Observable<SanityDocument<R>[]>
|
|
2489
|
+
/**
|
|
2490
|
+
* Create a document if it does not exist, or replace a document with the same document ID
|
|
2491
|
+
* Returns an observable that resolves to a mutation result object containing the ID of the created document.
|
|
2492
|
+
*
|
|
2493
|
+
* @param document - Document to either create or replace
|
|
2494
|
+
* @param options - Mutation options
|
|
2495
|
+
*/
|
|
2496
|
+
createOrReplace<R extends Record<string, Any> = Record<string, Any>>(
|
|
2497
|
+
document: IdentifiedSanityDocumentStub<R>,
|
|
2498
|
+
options: FirstDocumentIdMutationOptions,
|
|
2499
|
+
): Observable<SingleMutationResult>
|
|
2500
|
+
/**
|
|
2501
|
+
* Create a document if it does not exist, or replace a document with the same document ID
|
|
2502
|
+
* Returns an observable that resolves to a mutation result object containing the created document ID.
|
|
2503
|
+
*
|
|
2504
|
+
* @param document - Document to either create or replace
|
|
2505
|
+
* @param options - Mutation options
|
|
2506
|
+
*/
|
|
2507
|
+
createOrReplace<R extends Record<string, Any> = Record<string, Any>>(
|
|
2508
|
+
document: IdentifiedSanityDocumentStub<R>,
|
|
2509
|
+
options: AllDocumentIdsMutationOptions,
|
|
2510
|
+
): Observable<MultipleMutationResult>
|
|
2511
|
+
/**
|
|
2512
|
+
* Create a document if it does not exist, or replace a document with the same document ID
|
|
2513
|
+
* Returns an observable that resolves to the created document.
|
|
2514
|
+
*
|
|
2515
|
+
* @param document - Document to either create or replace
|
|
2516
|
+
* @param options - Mutation options
|
|
2517
|
+
*/
|
|
2518
|
+
createOrReplace<R extends Record<string, Any> = Record<string, Any>>(
|
|
2519
|
+
document: IdentifiedSanityDocumentStub<R>,
|
|
2520
|
+
options?: BaseMutationOptions,
|
|
2521
|
+
): Observable<SanityDocument<R>>
|
|
2522
|
+
/**
|
|
2523
|
+
* Deletes a document with the given document ID.
|
|
2524
|
+
* Returns an observable that resolves to the deleted document.
|
|
2525
|
+
*
|
|
2526
|
+
* @param id - Document ID to delete
|
|
2527
|
+
* @param options - Options for the mutation
|
|
2528
|
+
*/
|
|
2529
|
+
delete<R extends Record<string, Any> = Record<string, Any>>(
|
|
2530
|
+
id: string,
|
|
2531
|
+
options: FirstDocumentMutationOptions,
|
|
2532
|
+
): Observable<SanityDocument<R>>
|
|
2533
|
+
/**
|
|
2534
|
+
* Deletes a document with the given document ID.
|
|
2535
|
+
* Returns an observable that resolves to an array containing the deleted document.
|
|
2536
|
+
*
|
|
2537
|
+
* @param id - Document ID to delete
|
|
2538
|
+
* @param options - Options for the mutation
|
|
2539
|
+
*/
|
|
2540
|
+
delete<R extends Record<string, Any> = Record<string, Any>>(
|
|
2541
|
+
id: string,
|
|
2542
|
+
options: AllDocumentsMutationOptions,
|
|
2543
|
+
): Observable<SanityDocument<R>[]>
|
|
2544
|
+
/**
|
|
2545
|
+
* Deletes a document with the given document ID.
|
|
2546
|
+
* Returns an observable that resolves to a mutation result object containing the deleted document ID.
|
|
2547
|
+
*
|
|
2548
|
+
* @param id - Document ID to delete
|
|
2549
|
+
* @param options - Options for the mutation
|
|
2550
|
+
*/
|
|
2551
|
+
delete(id: string, options: FirstDocumentIdMutationOptions): Observable<SingleMutationResult>
|
|
2552
|
+
/**
|
|
2553
|
+
* Deletes a document with the given document ID.
|
|
2554
|
+
* Returns an observable that resolves to a mutation result object containing the deleted document ID.
|
|
2555
|
+
*
|
|
2556
|
+
* @param id - Document ID to delete
|
|
2557
|
+
* @param options - Options for the mutation
|
|
2558
|
+
*/
|
|
2559
|
+
delete(id: string, options: AllDocumentIdsMutationOptions): Observable<MultipleMutationResult>
|
|
2560
|
+
/**
|
|
2561
|
+
* Deletes a document with the given document ID.
|
|
2562
|
+
* Returns an observable that resolves to the deleted document.
|
|
2563
|
+
*
|
|
2564
|
+
* @param id - Document ID to delete
|
|
2565
|
+
* @param options - Options for the mutation
|
|
2566
|
+
*/
|
|
2567
|
+
delete<R extends Record<string, Any> = Record<string, Any>>(
|
|
2568
|
+
id: string,
|
|
2569
|
+
options?: BaseMutationOptions,
|
|
2570
|
+
): Observable<SanityDocument<R>>
|
|
2571
|
+
/**
|
|
2572
|
+
* Deletes one or more documents matching the given query or document ID.
|
|
2573
|
+
* Returns an observable that resolves to first deleted document.
|
|
2574
|
+
*
|
|
2575
|
+
* @param selection - An object with either an `id` or `query` key defining what to delete
|
|
2576
|
+
* @param options - Options for the mutation
|
|
2577
|
+
*/
|
|
2578
|
+
delete<R extends Record<string, Any> = Record<string, Any>>(
|
|
2579
|
+
selection: MutationSelection,
|
|
2580
|
+
options: FirstDocumentMutationOptions,
|
|
2581
|
+
): Observable<SanityDocument<R>>
|
|
2582
|
+
/**
|
|
2583
|
+
* Deletes one or more documents matching the given query or document ID.
|
|
2584
|
+
* Returns an observable that resolves to an array containing the deleted documents.
|
|
2585
|
+
*
|
|
2586
|
+
* @param selection - An object with either an `id` or `query` key defining what to delete
|
|
2587
|
+
* @param options - Options for the mutation
|
|
2588
|
+
*/
|
|
2589
|
+
delete<R extends Record<string, Any> = Record<string, Any>>(
|
|
2590
|
+
selection: MutationSelection,
|
|
2591
|
+
options: AllDocumentsMutationOptions,
|
|
2592
|
+
): Observable<SanityDocument<R>[]>
|
|
2593
|
+
/**
|
|
2594
|
+
* Deletes one or more documents matching the given query or document ID.
|
|
2595
|
+
* Returns an observable that resolves to a mutation result object containing the ID of the first deleted document.
|
|
2596
|
+
*
|
|
2597
|
+
* @param selection - An object with either an `id` or `query` key defining what to delete
|
|
2598
|
+
* @param options - Options for the mutation
|
|
2599
|
+
*/
|
|
2600
|
+
delete(
|
|
2601
|
+
selection: MutationSelection,
|
|
2602
|
+
options: FirstDocumentIdMutationOptions,
|
|
2603
|
+
): Observable<SingleMutationResult>
|
|
2604
|
+
/**
|
|
2605
|
+
* Deletes one or more documents matching the given query or document ID.
|
|
2606
|
+
* Returns an observable that resolves to a mutation result object containing the document IDs that were deleted.
|
|
2607
|
+
*
|
|
2608
|
+
* @param selection - An object with either an `id` or `query` key defining what to delete
|
|
2609
|
+
* @param options - Options for the mutation
|
|
2610
|
+
*/
|
|
2611
|
+
delete(
|
|
2612
|
+
selection: MutationSelection,
|
|
2613
|
+
options: AllDocumentIdsMutationOptions,
|
|
2614
|
+
): Observable<MultipleMutationResult>
|
|
2615
|
+
/**
|
|
2616
|
+
* Deletes one or more documents matching the given query or document ID.
|
|
2617
|
+
* Returns an observable that resolves to first deleted document.
|
|
2618
|
+
*
|
|
2619
|
+
* @param selection - An object with either an `id` or `query` key defining what to delete
|
|
2620
|
+
* @param options - Options for the mutation
|
|
2621
|
+
*/
|
|
2622
|
+
delete<R extends Record<string, Any> = Record<string, Any>>(
|
|
2623
|
+
selection: MutationSelection,
|
|
2624
|
+
options?: BaseMutationOptions,
|
|
2625
|
+
): Observable<SanityDocument<R>>
|
|
2626
|
+
/**
|
|
2627
|
+
* Perform mutation operations against the configured dataset
|
|
2628
|
+
* Returns an observable that resolves to the first mutated document.
|
|
2629
|
+
*
|
|
2630
|
+
* @param operations - Mutation operations to execute
|
|
2631
|
+
* @param options - Mutation options
|
|
2632
|
+
*/
|
|
2633
|
+
mutate<R extends Record<string, Any> = Record<string, Any>>(
|
|
2634
|
+
operations: Mutation<R>[] | ObservablePatch | ObservableTransaction,
|
|
2635
|
+
options: FirstDocumentMutationOptions,
|
|
2636
|
+
): Observable<SanityDocument<R>>
|
|
2637
|
+
/**
|
|
2638
|
+
* Perform mutation operations against the configured dataset.
|
|
2639
|
+
* Returns an observable that resolves to an array of the mutated documents.
|
|
2640
|
+
*
|
|
2641
|
+
* @param operations - Mutation operations to execute
|
|
2642
|
+
* @param options - Mutation options
|
|
2643
|
+
*/
|
|
2644
|
+
mutate<R extends Record<string, Any> = Record<string, Any>>(
|
|
2645
|
+
operations: Mutation<R>[] | ObservablePatch | ObservableTransaction,
|
|
2646
|
+
options: AllDocumentsMutationOptions,
|
|
2647
|
+
): Observable<SanityDocument<R>[]>
|
|
2648
|
+
/**
|
|
2649
|
+
* Perform mutation operations against the configured dataset
|
|
2650
|
+
* Returns an observable that resolves to a mutation result object containing the document ID of the first mutated document.
|
|
2651
|
+
*
|
|
2652
|
+
* @param operations - Mutation operations to execute
|
|
2653
|
+
* @param options - Mutation options
|
|
2654
|
+
*/
|
|
2655
|
+
mutate<R extends Record<string, Any> = Record<string, Any>>(
|
|
2656
|
+
operations: Mutation<R>[] | ObservablePatch | ObservableTransaction,
|
|
2657
|
+
options: FirstDocumentIdMutationOptions,
|
|
2658
|
+
): Observable<SingleMutationResult>
|
|
2659
|
+
/**
|
|
2660
|
+
* Perform mutation operations against the configured dataset
|
|
2661
|
+
* Returns an observable that resolves to a mutation result object containing the mutated document IDs.
|
|
2662
|
+
*
|
|
2663
|
+
* @param operations - Mutation operations to execute
|
|
2664
|
+
* @param options - Mutation options
|
|
2665
|
+
*/
|
|
2666
|
+
mutate<R extends Record<string, Any> = Record<string, Any>>(
|
|
2667
|
+
operations: Mutation<R>[] | ObservablePatch | ObservableTransaction,
|
|
2668
|
+
options: AllDocumentIdsMutationOptions,
|
|
2669
|
+
): Observable<MultipleMutationResult>
|
|
2670
|
+
/**
|
|
2671
|
+
* Perform mutation operations against the configured dataset
|
|
2672
|
+
* Returns an observable that resolves to the first mutated document.
|
|
2673
|
+
*
|
|
2674
|
+
* @param operations - Mutation operations to execute
|
|
2675
|
+
* @param options - Mutation options
|
|
2676
|
+
*/
|
|
2677
|
+
mutate<R extends Record<string, Any> = Record<string, Any>>(
|
|
2678
|
+
operations: Mutation<R>[] | ObservablePatch | ObservableTransaction,
|
|
2679
|
+
options?: BaseMutationOptions,
|
|
2680
|
+
): Observable<SanityDocument<R>>
|
|
2681
|
+
/**
|
|
2682
|
+
* Create a new buildable patch of operations to perform
|
|
2683
|
+
*
|
|
2684
|
+
* @param documentId - Document ID to patch
|
|
2685
|
+
* @param operations - Optional object of patch operations to initialize the patch instance with
|
|
2686
|
+
* @returns Patch instance - call `.commit()` to perform the operations defined
|
|
2687
|
+
*/
|
|
2688
|
+
patch(documentId: string, operations?: PatchOperations): ObservablePatch
|
|
2689
|
+
/**
|
|
2690
|
+
* Create a new buildable patch of operations to perform
|
|
2691
|
+
*
|
|
2692
|
+
* @param documentIds - Array of document IDs to patch
|
|
2693
|
+
* @param operations - Optional object of patch operations to initialize the patch instance with
|
|
2694
|
+
* @returns Patch instance - call `.commit()` to perform the operations defined
|
|
2695
|
+
*/
|
|
2696
|
+
patch(documentIds: string[], operations?: PatchOperations): ObservablePatch
|
|
2697
|
+
/**
|
|
2698
|
+
* Create a new buildable patch of operations to perform
|
|
2699
|
+
*
|
|
2700
|
+
* @param selection - An object with `query` and optional `params`, defining which document(s) to patch
|
|
2701
|
+
* @param operations - Optional object of patch operations to initialize the patch instance with
|
|
2702
|
+
* @returns Patch instance - call `.commit()` to perform the operations defined
|
|
2703
|
+
*/
|
|
2704
|
+
patch(selection: MutationSelection, operations?: PatchOperations): ObservablePatch
|
|
2705
|
+
/**
|
|
2706
|
+
* Create a new buildable patch of operations to perform
|
|
2707
|
+
*
|
|
2708
|
+
* @param selection - Document ID, an array of document IDs, or an object with `query` and optional `params`, defining which document(s) to patch
|
|
2709
|
+
* @param operations - Optional object of patch operations to initialize the patch instance with
|
|
2710
|
+
* @returns Patch instance - call `.commit()` to perform the operations defined
|
|
2711
|
+
*/
|
|
2712
|
+
patch(selection: PatchSelection, operations?: PatchOperations): ObservablePatch
|
|
2713
|
+
/**
|
|
2714
|
+
* Create a new transaction of mutations
|
|
2715
|
+
*
|
|
2716
|
+
* @param operations - Optional array of mutation operations to initialize the transaction instance with
|
|
2717
|
+
*/
|
|
2718
|
+
transaction<R extends Record<string, Any> = Record<string, Any>>(
|
|
2719
|
+
operations?: Mutation<R>[],
|
|
2720
|
+
): ObservableTransaction
|
|
2721
|
+
/**
|
|
2722
|
+
* Perform action operations against the configured dataset
|
|
2723
|
+
*
|
|
2724
|
+
* @param operations - Action operation(s) to execute
|
|
2725
|
+
* @param options - Action options
|
|
2726
|
+
*/
|
|
2727
|
+
action(
|
|
2728
|
+
operations: Action | Action[],
|
|
2729
|
+
options?: BaseActionOptions,
|
|
2730
|
+
): Observable<SingleActionResult | MultipleActionResult>
|
|
2731
|
+
/**
|
|
2732
|
+
* Perform an HTTP request against the Sanity API
|
|
2733
|
+
*
|
|
2734
|
+
* @param options - Request options
|
|
2735
|
+
*/
|
|
2736
|
+
request<R = Any>(options: RawRequestOptions): Observable<R>
|
|
2737
|
+
}
|
|
2738
|
+
|
|
2739
|
+
/**
|
|
2740
|
+
* @deprecated -- Use `import {ObservableSanityClient} from '@sanity/client'` instead
|
|
2741
|
+
* @public
|
|
2742
|
+
*/
|
|
2743
|
+
export declare class ObservableSanityStegaClient extends ObservableSanityClient {}
|
|
2744
|
+
|
|
2745
|
+
/** @public */
|
|
2746
|
+
export declare class ObservableTransaction extends BaseTransaction {
|
|
2747
|
+
#private
|
|
2748
|
+
constructor(operations?: Mutation[], client?: ObservableSanityClient, transactionId?: string)
|
|
2749
|
+
/**
|
|
2750
|
+
* Clones the transaction
|
|
2751
|
+
*/
|
|
2752
|
+
clone(): ObservableTransaction
|
|
2753
|
+
/**
|
|
2754
|
+
* Commit the transaction, returning an observable that produces the first mutated document
|
|
2755
|
+
*
|
|
2756
|
+
* @param options - Options for the mutation operation
|
|
2757
|
+
*/
|
|
2758
|
+
commit<R extends Record<string, Any>>(
|
|
2759
|
+
options: TransactionFirstDocumentMutationOptions,
|
|
2760
|
+
): Observable<SanityDocument<R>>
|
|
2761
|
+
/**
|
|
2762
|
+
* Commit the transaction, returning an observable that produces an array of the mutated documents
|
|
2763
|
+
*
|
|
2764
|
+
* @param options - Options for the mutation operation
|
|
2765
|
+
*/
|
|
2766
|
+
commit<R extends Record<string, Any>>(
|
|
2767
|
+
options: TransactionAllDocumentsMutationOptions,
|
|
2768
|
+
): Observable<SanityDocument<R>[]>
|
|
2769
|
+
/**
|
|
2770
|
+
* Commit the transaction, returning an observable that produces a mutation result object
|
|
2771
|
+
*
|
|
2772
|
+
* @param options - Options for the mutation operation
|
|
2773
|
+
*/
|
|
2774
|
+
commit(options: TransactionFirstDocumentIdMutationOptions): Observable<SingleMutationResult>
|
|
2775
|
+
/**
|
|
2776
|
+
* Commit the transaction, returning an observable that produces a mutation result object
|
|
2777
|
+
*
|
|
2778
|
+
* @param options - Options for the mutation operation
|
|
2779
|
+
*/
|
|
2780
|
+
commit(options: TransactionAllDocumentIdsMutationOptions): Observable<MultipleMutationResult>
|
|
2781
|
+
/**
|
|
2782
|
+
* Commit the transaction, returning an observable that produces a mutation result object
|
|
2783
|
+
*
|
|
2784
|
+
* @param options - Options for the mutation operation
|
|
2785
|
+
*/
|
|
2786
|
+
commit(options?: BaseMutationOptions): Observable<MultipleMutationResult>
|
|
2787
|
+
/**
|
|
2788
|
+
* Performs a patch on the given document ID. Can either be a builder function or an object of patch operations.
|
|
2789
|
+
* The operation is added to the current transaction, ready to be commited by `commit()`
|
|
2790
|
+
*
|
|
2791
|
+
* @param documentId - Document ID to perform the patch operation on
|
|
2792
|
+
* @param patchOps - Operations to perform, or a builder function
|
|
2793
|
+
*/
|
|
2794
|
+
patch(documentId: string, patchOps?: ObservablePatchBuilder | PatchOperations): this
|
|
2795
|
+
/**
|
|
2796
|
+
* Adds the given patch instance to the transaction.
|
|
2797
|
+
* The operation is added to the current transaction, ready to be commited by `commit()`
|
|
2798
|
+
*
|
|
2799
|
+
* @param patch - ObservablePatch to execute
|
|
2800
|
+
*/
|
|
2801
|
+
patch(patch: ObservablePatch): this
|
|
2802
|
+
}
|
|
2803
|
+
|
|
2804
|
+
/** @public */
|
|
2805
|
+
export declare class ObservableUsersClient {
|
|
2806
|
+
#private
|
|
2807
|
+
constructor(client: ObservableSanityClient, httpRequest: HttpRequest)
|
|
2808
|
+
/**
|
|
2809
|
+
* Fetch a user by user ID
|
|
2810
|
+
*
|
|
2811
|
+
* @param id - User ID of the user to fetch. If `me` is provided, a minimal response including the users role is returned.
|
|
2812
|
+
*/
|
|
2813
|
+
getById<T extends 'me' | string>(
|
|
2814
|
+
id: T,
|
|
2815
|
+
): Observable<T extends 'me' ? CurrentSanityUser : SanityUser>
|
|
2816
|
+
}
|
|
2817
|
+
|
|
2818
|
+
/**
|
|
2819
|
+
* The listener connection has been established
|
|
2820
|
+
* note: it's usually a better option to use the 'welcome' event
|
|
2821
|
+
* @public
|
|
2822
|
+
*/
|
|
2823
|
+
export declare type OpenEvent = {
|
|
2824
|
+
type: 'open'
|
|
2825
|
+
}
|
|
2826
|
+
|
|
2827
|
+
/** @public */
|
|
2828
|
+
export declare class Patch extends BasePatch {
|
|
2829
|
+
#private
|
|
2830
|
+
constructor(selection: PatchSelection, operations?: PatchOperations, client?: SanityClient)
|
|
2831
|
+
/**
|
|
2832
|
+
* Clones the patch
|
|
2833
|
+
*/
|
|
2834
|
+
clone(): Patch
|
|
2835
|
+
/**
|
|
2836
|
+
* Commit the patch, returning a promise that resolves to the first patched document
|
|
2837
|
+
*
|
|
2838
|
+
* @param options - Options for the mutation operation
|
|
2839
|
+
*/
|
|
2840
|
+
commit<R extends Record<string, Any> = Record<string, Any>>(
|
|
2841
|
+
options: FirstDocumentMutationOptions,
|
|
2842
|
+
): Promise<SanityDocument<R>>
|
|
2843
|
+
/**
|
|
2844
|
+
* Commit the patch, returning a promise that resolves to an array of the mutated documents
|
|
2845
|
+
*
|
|
2846
|
+
* @param options - Options for the mutation operation
|
|
2847
|
+
*/
|
|
2848
|
+
commit<R extends Record<string, Any> = Record<string, Any>>(
|
|
2849
|
+
options: AllDocumentsMutationOptions,
|
|
2850
|
+
): Promise<SanityDocument<R>[]>
|
|
2851
|
+
/**
|
|
2852
|
+
* Commit the patch, returning a promise that resolves to a mutation result object
|
|
2853
|
+
*
|
|
2854
|
+
* @param options - Options for the mutation operation
|
|
2855
|
+
*/
|
|
2856
|
+
commit(options: FirstDocumentIdMutationOptions): Promise<SingleMutationResult>
|
|
2857
|
+
/**
|
|
2858
|
+
* Commit the patch, returning a promise that resolves to a mutation result object
|
|
2859
|
+
*
|
|
2860
|
+
* @param options - Options for the mutation operation
|
|
2861
|
+
*/
|
|
2862
|
+
commit(options: AllDocumentIdsMutationOptions): Promise<MultipleMutationResult>
|
|
2863
|
+
/**
|
|
2864
|
+
* Commit the patch, returning a promise that resolves to the first patched document
|
|
2865
|
+
*
|
|
2866
|
+
* @param options - Options for the mutation operation
|
|
2867
|
+
*/
|
|
2868
|
+
commit<R extends Record<string, Any> = Record<string, Any>>(
|
|
2869
|
+
options?: BaseMutationOptions,
|
|
2870
|
+
): Promise<SanityDocument<R>>
|
|
2871
|
+
}
|
|
2872
|
+
|
|
2873
|
+
/** @public */
|
|
2874
|
+
export declare type PatchBuilder = (patch: Patch) => Patch
|
|
2875
|
+
|
|
2876
|
+
/** @internal */
|
|
2877
|
+
export declare type PatchMutationOperation = PatchOperations & MutationSelection
|
|
2878
|
+
|
|
2879
|
+
/** @internal */
|
|
2880
|
+
export declare interface PatchOperations {
|
|
2881
|
+
set?: {
|
|
2882
|
+
[key: string]: Any
|
|
2883
|
+
}
|
|
2884
|
+
setIfMissing?: {
|
|
2885
|
+
[key: string]: Any
|
|
2886
|
+
}
|
|
2887
|
+
diffMatchPatch?: {
|
|
2888
|
+
[key: string]: Any
|
|
2889
|
+
}
|
|
2890
|
+
unset?: string[]
|
|
2891
|
+
inc?: {
|
|
2892
|
+
[key: string]: number
|
|
2893
|
+
}
|
|
2894
|
+
dec?: {
|
|
2895
|
+
[key: string]: number
|
|
2896
|
+
}
|
|
2897
|
+
insert?: InsertPatch
|
|
2898
|
+
ifRevisionID?: string
|
|
2899
|
+
}
|
|
2900
|
+
|
|
2901
|
+
/** @internal */
|
|
2902
|
+
export declare type PatchSelection = string | string[] | MutationSelection
|
|
2903
|
+
|
|
2904
|
+
/** @public */
|
|
2905
|
+
declare interface ProgressEvent_2 {
|
|
2906
|
+
type: 'progress'
|
|
2907
|
+
stage: 'upload' | 'download'
|
|
2908
|
+
percent: number
|
|
2909
|
+
total?: number
|
|
2910
|
+
loaded?: number
|
|
2911
|
+
lengthComputable: boolean
|
|
2912
|
+
}
|
|
2913
|
+
export {ProgressEvent_2 as ProgressEvent}
|
|
2914
|
+
|
|
2915
|
+
/** @internal */
|
|
2916
|
+
export declare class ProjectsClient {
|
|
2917
|
+
#private
|
|
2918
|
+
constructor(client: SanityClient, httpRequest: HttpRequest)
|
|
2919
|
+
/**
|
|
2920
|
+
* Fetch a list of projects the authenticated user has access to.
|
|
2921
|
+
*
|
|
2922
|
+
* @param options - Options for the list request
|
|
2923
|
+
* @param options.includeMembers - Whether to include members in the response (default: true)
|
|
2924
|
+
*/
|
|
2925
|
+
list(options?: {includeMembers?: true}): Promise<SanityProject[]>
|
|
2926
|
+
list(options?: {includeMembers?: false}): Promise<Omit<SanityProject, 'members'>[]>
|
|
2927
|
+
/**
|
|
2928
|
+
* Fetch a project by project ID
|
|
2929
|
+
*
|
|
2930
|
+
* @param projectId - ID of the project to fetch
|
|
2931
|
+
*/
|
|
2932
|
+
getById(projectId: string): Promise<SanityProject>
|
|
2933
|
+
}
|
|
2934
|
+
|
|
2935
|
+
/**
|
|
2936
|
+
* Publishes a draft document.
|
|
2937
|
+
* If a published version of the document already exists this is replaced by the current draft document.
|
|
2938
|
+
* In either case the draft document is deleted.
|
|
2939
|
+
* The optional revision id parameters can be used for optimistic locking to ensure
|
|
2940
|
+
* that the draft and/or published versions of the document have not been changed by another client.
|
|
2941
|
+
*
|
|
2942
|
+
* @public
|
|
2943
|
+
*/
|
|
2944
|
+
export declare type PublishAction = {
|
|
2945
|
+
actionType: 'sanity.action.document.publish'
|
|
2946
|
+
/**
|
|
2947
|
+
* Draft document ID to publish
|
|
2948
|
+
*/
|
|
2949
|
+
draftId: string
|
|
2950
|
+
/**
|
|
2951
|
+
* Draft revision ID to match
|
|
2952
|
+
*/
|
|
2953
|
+
ifDraftRevisionId?: string
|
|
2954
|
+
/**
|
|
2955
|
+
* Published document ID to replace
|
|
2956
|
+
*/
|
|
2957
|
+
publishedId: string
|
|
2958
|
+
/**
|
|
2959
|
+
* Published revision ID to match
|
|
2960
|
+
*/
|
|
2961
|
+
ifPublishedRevisionId?: string
|
|
2962
|
+
}
|
|
2963
|
+
|
|
2964
|
+
/** @public */
|
|
2965
|
+
export declare type QueryOptions =
|
|
2966
|
+
| FilteredResponseQueryOptions
|
|
2967
|
+
| UnfilteredResponseQueryOptions
|
|
2968
|
+
| UnfilteredResponseWithoutQuery
|
|
2969
|
+
|
|
2970
|
+
/** @public */
|
|
2971
|
+
export declare interface QueryParams {
|
|
2972
|
+
[key: string]: any
|
|
2973
|
+
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2974
|
+
body?: never
|
|
2975
|
+
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2976
|
+
cache?: 'next' extends keyof RequestInit ? never : any
|
|
2977
|
+
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2978
|
+
filterResponse?: never
|
|
2979
|
+
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2980
|
+
headers?: never
|
|
2981
|
+
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2982
|
+
method?: never
|
|
2983
|
+
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2984
|
+
next?: 'next' extends keyof RequestInit ? never : any
|
|
2985
|
+
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2986
|
+
perspective?: never
|
|
2987
|
+
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2988
|
+
query?: never
|
|
2989
|
+
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2990
|
+
resultSourceMap?: never
|
|
2991
|
+
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2992
|
+
returnQuery?: never
|
|
2993
|
+
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2994
|
+
signal?: never
|
|
2995
|
+
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2996
|
+
stega?: never
|
|
2997
|
+
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2998
|
+
tag?: never
|
|
2999
|
+
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
3000
|
+
timeout?: never
|
|
3001
|
+
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
3002
|
+
token?: never
|
|
3003
|
+
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
3004
|
+
useCdn?: never
|
|
3005
|
+
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
3006
|
+
lastLiveEventId?: never
|
|
3007
|
+
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
3008
|
+
cacheMode?: never
|
|
3009
|
+
}
|
|
3010
|
+
|
|
3011
|
+
/**
|
|
3012
|
+
* This type can be used with `client.fetch` to indicate that the query has no GROQ parameters.
|
|
3013
|
+
* @public
|
|
3014
|
+
*/
|
|
3015
|
+
export declare type QueryWithoutParams = Record<string, never> | undefined
|
|
3016
|
+
|
|
3017
|
+
/** @public */
|
|
3018
|
+
export declare type RawQuerylessQueryResponse<R> = Omit<RawQueryResponse<R>, 'query'>
|
|
3019
|
+
|
|
3020
|
+
/** @public */
|
|
3021
|
+
export declare interface RawQueryResponse<R> {
|
|
3022
|
+
query: string
|
|
3023
|
+
ms: number
|
|
3024
|
+
result: R
|
|
3025
|
+
resultSourceMap?: ContentSourceMap
|
|
3026
|
+
/** Requires `apiVersion` to be `2021-03-25` or later. */
|
|
3027
|
+
syncTags?: SyncTag[]
|
|
3028
|
+
}
|
|
3029
|
+
|
|
3030
|
+
/** @internal */
|
|
3031
|
+
export declare interface RawRequestOptions {
|
|
3032
|
+
url?: string
|
|
3033
|
+
uri?: string
|
|
3034
|
+
method?: string
|
|
3035
|
+
token?: string
|
|
3036
|
+
json?: boolean
|
|
3037
|
+
tag?: string
|
|
3038
|
+
useGlobalApi?: boolean
|
|
3039
|
+
withCredentials?: boolean
|
|
3040
|
+
query?: {
|
|
3041
|
+
[key: string]: string | string[]
|
|
3042
|
+
}
|
|
3043
|
+
headers?: {
|
|
3044
|
+
[key: string]: string
|
|
3045
|
+
}
|
|
3046
|
+
timeout?: number
|
|
3047
|
+
proxy?: string
|
|
3048
|
+
body?: Any
|
|
3049
|
+
maxRedirects?: number
|
|
3050
|
+
signal?: AbortSignal
|
|
3051
|
+
}
|
|
3052
|
+
|
|
3053
|
+
/**
|
|
3054
|
+
* The listener has been disconnected, and a reconnect attempt is scheduled.
|
|
3055
|
+
*
|
|
3056
|
+
* @public
|
|
3057
|
+
*/
|
|
3058
|
+
export declare type ReconnectEvent = {
|
|
3059
|
+
type: 'reconnect'
|
|
3060
|
+
}
|
|
3061
|
+
|
|
3062
|
+
/**
|
|
3063
|
+
* @public
|
|
3064
|
+
* @deprecated – The `r`-prefix is not required, use `string` instead
|
|
3065
|
+
*/
|
|
3066
|
+
export declare type ReleaseId = `r${string}`
|
|
3067
|
+
|
|
3068
|
+
/**
|
|
3069
|
+
* Replaces an existing draft document.
|
|
3070
|
+
* At least one of the draft or published versions of the document must exist.
|
|
3071
|
+
*
|
|
3072
|
+
* @public
|
|
3073
|
+
*/
|
|
3074
|
+
export declare type ReplaceDraftAction = {
|
|
3075
|
+
actionType: 'sanity.action.document.replaceDraft'
|
|
3076
|
+
/**
|
|
3077
|
+
* Published document ID to create draft from, if draft does not exist
|
|
3078
|
+
*/
|
|
3079
|
+
publishedId: string
|
|
3080
|
+
/**
|
|
3081
|
+
* Document to create if it does not already exist. Requires `_id` and `_type` properties.
|
|
3082
|
+
*/
|
|
3083
|
+
attributes: IdentifiedSanityDocumentStub
|
|
3084
|
+
}
|
|
3085
|
+
|
|
3086
|
+
/**
|
|
3087
|
+
* @deprecated -- Use `import {requester} from '@sanity/client'` instead
|
|
3088
|
+
* @public
|
|
3089
|
+
*/
|
|
3090
|
+
export declare const requester: Requester
|
|
3091
|
+
|
|
3092
|
+
/** @internal */
|
|
3093
|
+
export declare interface RequestObservableOptions extends Omit<RequestOptions, 'url'> {
|
|
3094
|
+
url?: string
|
|
3095
|
+
uri?: string
|
|
3096
|
+
canUseCdn?: boolean
|
|
3097
|
+
useCdn?: boolean
|
|
3098
|
+
tag?: string
|
|
3099
|
+
returnQuery?: boolean
|
|
3100
|
+
resultSourceMap?: boolean | 'withKeyArraySelector'
|
|
3101
|
+
perspective?: ClientPerspective
|
|
3102
|
+
lastLiveEventId?: string
|
|
3103
|
+
cacheMode?: 'noStale'
|
|
3104
|
+
}
|
|
3105
|
+
|
|
3106
|
+
/** @public */
|
|
3107
|
+
export declare interface RequestOptions {
|
|
3108
|
+
timeout?: number
|
|
3109
|
+
token?: string
|
|
3110
|
+
tag?: string
|
|
3111
|
+
headers?: Record<string, string>
|
|
3112
|
+
method?: string
|
|
3113
|
+
query?: Any
|
|
3114
|
+
body?: Any
|
|
3115
|
+
signal?: AbortSignal
|
|
3116
|
+
}
|
|
3117
|
+
|
|
3118
|
+
/** @alpha */
|
|
3119
|
+
export declare type ResolveStudioUrl = (
|
|
3120
|
+
sourceDocument: ContentSourceMapDocuments_2[number],
|
|
3121
|
+
) => StudioUrl
|
|
3122
|
+
|
|
3123
|
+
/** @public */
|
|
3124
|
+
export declare interface ResponseEvent<T = unknown> {
|
|
3125
|
+
type: 'response'
|
|
3126
|
+
body: T
|
|
3127
|
+
url: string
|
|
3128
|
+
method: string
|
|
3129
|
+
statusCode: number
|
|
3130
|
+
statusMessage?: string
|
|
3131
|
+
headers: Record<string, string>
|
|
3132
|
+
}
|
|
3133
|
+
|
|
3134
|
+
/** @public */
|
|
3135
|
+
export declare interface ResponseQueryOptions extends RequestOptions {
|
|
3136
|
+
perspective?: ClientPerspective
|
|
3137
|
+
resultSourceMap?: boolean | 'withKeyArraySelector'
|
|
3138
|
+
returnQuery?: boolean
|
|
3139
|
+
useCdn?: boolean
|
|
3140
|
+
stega?: boolean | StegaConfig
|
|
3141
|
+
cache?: 'next' extends keyof RequestInit ? RequestInit['cache'] : never
|
|
3142
|
+
next?: ('next' extends keyof RequestInit ? RequestInit : never)['next']
|
|
3143
|
+
lastLiveEventId?: string | string[] | null
|
|
3144
|
+
/**
|
|
3145
|
+
* When set to `noStale`, APICDN will not return a cached response if the content is stale.
|
|
3146
|
+
* Tradeoff between latency and freshness of content.
|
|
3147
|
+
*
|
|
3148
|
+
* Only to be used with live content queries and when useCdn is true.
|
|
3149
|
+
*/
|
|
3150
|
+
cacheMode?: 'noStale'
|
|
3151
|
+
}
|
|
3152
|
+
|
|
3153
|
+
/** @internal */
|
|
3154
|
+
export declare interface SanityAssetDocument extends SanityDocument {
|
|
3155
|
+
url: string
|
|
3156
|
+
path: string
|
|
3157
|
+
size: number
|
|
3158
|
+
assetId: string
|
|
3159
|
+
mimeType: string
|
|
3160
|
+
sha1hash: string
|
|
3161
|
+
extension: string
|
|
3162
|
+
uploadId?: string
|
|
3163
|
+
originalFilename?: string
|
|
3164
|
+
}
|
|
3165
|
+
|
|
3166
|
+
/** @public */
|
|
3167
|
+
export declare class SanityClient implements SanityClientType {
|
|
3168
|
+
#private
|
|
3169
|
+
assets: AssetsClient
|
|
3170
|
+
datasets: DatasetsClient
|
|
3171
|
+
live: LiveClient
|
|
3172
|
+
projects: ProjectsClient
|
|
3173
|
+
users: UsersClient
|
|
3174
|
+
/**
|
|
3175
|
+
* Observable version of the Sanity client, with the same configuration as the promise-based one
|
|
3176
|
+
*/
|
|
3177
|
+
observable: ObservableSanityClient
|
|
3178
|
+
listen: typeof _listen
|
|
3179
|
+
constructor(httpRequest: HttpRequest, config?: ClientConfig)
|
|
3180
|
+
/**
|
|
3181
|
+
* Clone the client - returns a new instance
|
|
3182
|
+
*/
|
|
3183
|
+
clone(): SanityClient
|
|
3184
|
+
/**
|
|
3185
|
+
* Returns the current client configuration
|
|
3186
|
+
*/
|
|
3187
|
+
config(): InitializedClientConfig
|
|
3188
|
+
/**
|
|
3189
|
+
* Reconfigure the client. Note that this _mutates_ the current client.
|
|
3190
|
+
*/
|
|
3191
|
+
config(newConfig?: Partial<ClientConfig>): this
|
|
3192
|
+
/**
|
|
3193
|
+
* Clone the client with a new (partial) configuration.
|
|
3194
|
+
*
|
|
3195
|
+
* @param newConfig - New client configuration properties, shallowly merged with existing configuration
|
|
3196
|
+
*/
|
|
3197
|
+
withConfig(newConfig?: Partial<ClientConfig>): SanityClient
|
|
3198
|
+
/**
|
|
3199
|
+
* Perform a GROQ-query against the configured dataset.
|
|
3200
|
+
*
|
|
3201
|
+
* @param query - GROQ-query to perform
|
|
3202
|
+
*/
|
|
3203
|
+
fetch<
|
|
3204
|
+
R = Any,
|
|
3205
|
+
Q extends QueryWithoutParams = QueryWithoutParams,
|
|
3206
|
+
const G extends string = string,
|
|
3207
|
+
>(query: G, params?: Q | QueryWithoutParams): Promise<ClientReturn<G, R>>
|
|
3208
|
+
/**
|
|
3209
|
+
* Perform a GROQ-query against the configured dataset.
|
|
3210
|
+
*
|
|
3211
|
+
* @param query - GROQ-query to perform
|
|
3212
|
+
* @param params - Optional query parameters
|
|
3213
|
+
* @param options - Optional request options
|
|
3214
|
+
*/
|
|
3215
|
+
fetch<
|
|
3216
|
+
R = Any,
|
|
3217
|
+
Q extends QueryWithoutParams | QueryParams = QueryParams,
|
|
3218
|
+
const G extends string = string,
|
|
3219
|
+
>(
|
|
3220
|
+
query: G,
|
|
3221
|
+
params: Q extends QueryWithoutParams ? QueryWithoutParams : Q,
|
|
3222
|
+
options?: FilteredResponseQueryOptions,
|
|
3223
|
+
): Promise<ClientReturn<G, R>>
|
|
3224
|
+
/**
|
|
3225
|
+
* Perform a GROQ-query against the configured dataset.
|
|
3226
|
+
*
|
|
3227
|
+
* @param query - GROQ-query to perform
|
|
3228
|
+
* @param params - Optional query parameters
|
|
3229
|
+
* @param options - Request options
|
|
3230
|
+
*/
|
|
3231
|
+
fetch<
|
|
3232
|
+
R = Any,
|
|
3233
|
+
Q extends QueryWithoutParams | QueryParams = QueryParams,
|
|
3234
|
+
const G extends string = string,
|
|
3235
|
+
>(
|
|
3236
|
+
query: G,
|
|
3237
|
+
params: Q extends QueryWithoutParams ? QueryWithoutParams : Q,
|
|
3238
|
+
options: UnfilteredResponseQueryOptions,
|
|
3239
|
+
): Promise<RawQueryResponse<ClientReturn<G, R>>>
|
|
3240
|
+
/**
|
|
3241
|
+
* Perform a GROQ-query against the configured dataset.
|
|
3242
|
+
*
|
|
3243
|
+
* @param query - GROQ-query to perform
|
|
3244
|
+
* @param params - Optional query parameters
|
|
3245
|
+
* @param options - Request options
|
|
3246
|
+
*/
|
|
3247
|
+
fetch<
|
|
3248
|
+
R = Any,
|
|
3249
|
+
Q extends QueryWithoutParams | QueryParams = QueryParams,
|
|
3250
|
+
const G extends string = string,
|
|
3251
|
+
>(
|
|
3252
|
+
query: G,
|
|
3253
|
+
params: Q extends QueryWithoutParams ? QueryWithoutParams : Q,
|
|
3254
|
+
options: UnfilteredResponseWithoutQuery,
|
|
3255
|
+
): Promise<RawQuerylessQueryResponse<ClientReturn<G, R>>>
|
|
3256
|
+
/**
|
|
3257
|
+
* Fetch a single document with the given ID.
|
|
3258
|
+
*
|
|
3259
|
+
* @param id - Document ID to fetch
|
|
3260
|
+
* @param options - Request options
|
|
3261
|
+
*/
|
|
3262
|
+
getDocument<R extends Record<string, Any> = Record<string, Any>>(
|
|
3263
|
+
id: string,
|
|
3264
|
+
options?: {
|
|
3265
|
+
signal?: AbortSignal
|
|
3266
|
+
tag?: string
|
|
3267
|
+
},
|
|
3268
|
+
): Promise<SanityDocument<R> | undefined>
|
|
3269
|
+
/**
|
|
3270
|
+
* Fetch multiple documents in one request.
|
|
3271
|
+
* Should be used sparingly - performing a query is usually a better option.
|
|
3272
|
+
* The order/position of documents is preserved based on the original array of IDs.
|
|
3273
|
+
* If any of the documents are missing, they will be replaced by a `null` entry in the returned array
|
|
3274
|
+
*
|
|
3275
|
+
* @param ids - Document IDs to fetch
|
|
3276
|
+
* @param options - Request options
|
|
3277
|
+
*/
|
|
3278
|
+
getDocuments<R extends Record<string, Any> = Record<string, Any>>(
|
|
3279
|
+
ids: string[],
|
|
3280
|
+
options?: {
|
|
3281
|
+
signal?: AbortSignal
|
|
3282
|
+
tag?: string
|
|
3283
|
+
},
|
|
3284
|
+
): Promise<(SanityDocument<R> | null)[]>
|
|
3285
|
+
/**
|
|
3286
|
+
* Create a document. Requires a `_type` property. If no `_id` is provided, it will be generated by the database.
|
|
3287
|
+
* Returns a promise that resolves to the created document.
|
|
3288
|
+
*
|
|
3289
|
+
* @param document - Document to create
|
|
3290
|
+
* @param options - Mutation options
|
|
3291
|
+
*/
|
|
3292
|
+
create<R extends Record<string, Any> = Record<string, Any>>(
|
|
3293
|
+
document: SanityDocumentStub<R>,
|
|
3294
|
+
options: FirstDocumentMutationOptions,
|
|
3295
|
+
): Promise<SanityDocument<R>>
|
|
3296
|
+
/**
|
|
3297
|
+
* Create a document. Requires a `_type` property. If no `_id` is provided, it will be generated by the database.
|
|
3298
|
+
* Returns a promise that resolves to an array containing the created document.
|
|
3299
|
+
*
|
|
3300
|
+
* @param document - Document to create
|
|
3301
|
+
* @param options - Mutation options
|
|
3302
|
+
*/
|
|
3303
|
+
create<R extends Record<string, Any> = Record<string, Any>>(
|
|
3304
|
+
document: SanityDocumentStub<R>,
|
|
3305
|
+
options: AllDocumentsMutationOptions,
|
|
3306
|
+
): Promise<SanityDocument<R>[]>
|
|
3307
|
+
/**
|
|
3308
|
+
* Create a document. Requires a `_type` property. If no `_id` is provided, it will be generated by the database.
|
|
3309
|
+
* Returns a promise that resolves to a mutation result object containing the ID of the created document.
|
|
3310
|
+
*
|
|
3311
|
+
* @param document - Document to create
|
|
3312
|
+
* @param options - Mutation options
|
|
3313
|
+
*/
|
|
3314
|
+
create<R extends Record<string, Any> = Record<string, Any>>(
|
|
3315
|
+
document: SanityDocumentStub<R>,
|
|
3316
|
+
options: FirstDocumentIdMutationOptions,
|
|
3317
|
+
): Promise<SingleMutationResult>
|
|
3318
|
+
/**
|
|
3319
|
+
* Create a document. Requires a `_type` property. If no `_id` is provided, it will be generated by the database.
|
|
3320
|
+
* Returns a promise that resolves to a mutation result object containing the ID of the created document.
|
|
3321
|
+
*
|
|
3322
|
+
* @param document - Document to create
|
|
3323
|
+
* @param options - Mutation options
|
|
3324
|
+
*/
|
|
3325
|
+
create<R extends Record<string, Any> = Record<string, Any>>(
|
|
3326
|
+
document: SanityDocumentStub<R>,
|
|
3327
|
+
options: AllDocumentIdsMutationOptions,
|
|
3328
|
+
): Promise<MultipleMutationResult>
|
|
3329
|
+
/**
|
|
3330
|
+
* Create a document. Requires a `_type` property. If no `_id` is provided, it will be generated by the database.
|
|
3331
|
+
* Returns a promise that resolves to the created document.
|
|
3332
|
+
*
|
|
3333
|
+
* @param document - Document to create
|
|
3334
|
+
* @param options - Mutation options
|
|
3335
|
+
*/
|
|
3336
|
+
create<R extends Record<string, Any> = Record<string, Any>>(
|
|
3337
|
+
document: SanityDocumentStub<R>,
|
|
3338
|
+
options?: BaseMutationOptions,
|
|
3339
|
+
): Promise<SanityDocument<R>>
|
|
3340
|
+
/**
|
|
3341
|
+
* Create a document if no document with the same ID already exists.
|
|
3342
|
+
* Returns a promise that resolves to the created document.
|
|
3343
|
+
*
|
|
3344
|
+
* @param document - Document to create
|
|
3345
|
+
* @param options - Mutation options
|
|
3346
|
+
*/
|
|
3347
|
+
createIfNotExists<R extends Record<string, Any> = Record<string, Any>>(
|
|
3348
|
+
document: IdentifiedSanityDocumentStub<R>,
|
|
3349
|
+
options: FirstDocumentMutationOptions,
|
|
3350
|
+
): Promise<SanityDocument<R>>
|
|
3351
|
+
/**
|
|
3352
|
+
* Create a document if no document with the same ID already exists.
|
|
3353
|
+
* Returns a promise that resolves to an array containing the created document.
|
|
3354
|
+
*
|
|
3355
|
+
* @param document - Document to create
|
|
3356
|
+
* @param options - Mutation options
|
|
3357
|
+
*/
|
|
3358
|
+
createIfNotExists<R extends Record<string, Any> = Record<string, Any>>(
|
|
3359
|
+
document: IdentifiedSanityDocumentStub<R>,
|
|
3360
|
+
options: AllDocumentsMutationOptions,
|
|
3361
|
+
): Promise<SanityDocument<R>[]>
|
|
3362
|
+
/**
|
|
3363
|
+
* Create a document if no document with the same ID already exists.
|
|
3364
|
+
* Returns a promise that resolves to a mutation result object containing the ID of the created document.
|
|
3365
|
+
*
|
|
3366
|
+
* @param document - Document to create
|
|
3367
|
+
* @param options - Mutation options
|
|
3368
|
+
*/
|
|
3369
|
+
createIfNotExists<R extends Record<string, Any> = Record<string, Any>>(
|
|
3370
|
+
document: IdentifiedSanityDocumentStub<R>,
|
|
3371
|
+
options: FirstDocumentIdMutationOptions,
|
|
3372
|
+
): Promise<SingleMutationResult>
|
|
3373
|
+
/**
|
|
3374
|
+
* Create a document if no document with the same ID already exists.
|
|
3375
|
+
* Returns a promise that resolves to a mutation result object containing the ID of the created document.
|
|
3376
|
+
*
|
|
3377
|
+
* @param document - Document to create
|
|
3378
|
+
* @param options - Mutation options
|
|
3379
|
+
*/
|
|
3380
|
+
createIfNotExists<R extends Record<string, Any> = Record<string, Any>>(
|
|
3381
|
+
document: IdentifiedSanityDocumentStub<R>,
|
|
3382
|
+
options: AllDocumentIdsMutationOptions,
|
|
3383
|
+
): Promise<MultipleMutationResult>
|
|
3384
|
+
/**
|
|
3385
|
+
* Create a document if no document with the same ID already exists.
|
|
3386
|
+
* Returns a promise that resolves to the created document.
|
|
3387
|
+
*
|
|
3388
|
+
* @param document - Document to create
|
|
3389
|
+
* @param options - Mutation options
|
|
3390
|
+
*/
|
|
3391
|
+
createIfNotExists<R extends Record<string, Any> = Record<string, Any>>(
|
|
3392
|
+
document: IdentifiedSanityDocumentStub<R>,
|
|
3393
|
+
options?: BaseMutationOptions,
|
|
3394
|
+
): Promise<SanityDocument<R>>
|
|
3395
|
+
/**
|
|
3396
|
+
* Create a document if it does not exist, or replace a document with the same document ID
|
|
3397
|
+
* Returns a promise that resolves to the created document.
|
|
3398
|
+
*
|
|
3399
|
+
* @param document - Document to either create or replace
|
|
3400
|
+
* @param options - Mutation options
|
|
3401
|
+
*/
|
|
3402
|
+
createOrReplace<R extends Record<string, Any> = Record<string, Any>>(
|
|
3403
|
+
document: IdentifiedSanityDocumentStub<R>,
|
|
3404
|
+
options: FirstDocumentMutationOptions,
|
|
3405
|
+
): Promise<SanityDocument<R>>
|
|
3406
|
+
/**
|
|
3407
|
+
* Create a document if it does not exist, or replace a document with the same document ID
|
|
3408
|
+
* Returns a promise that resolves to an array containing the created document.
|
|
3409
|
+
*
|
|
3410
|
+
* @param document - Document to either create or replace
|
|
3411
|
+
* @param options - Mutation options
|
|
3412
|
+
*/
|
|
3413
|
+
createOrReplace<R extends Record<string, Any> = Record<string, Any>>(
|
|
3414
|
+
document: IdentifiedSanityDocumentStub<R>,
|
|
3415
|
+
options: AllDocumentsMutationOptions,
|
|
3416
|
+
): Promise<SanityDocument<R>[]>
|
|
3417
|
+
/**
|
|
3418
|
+
* Create a document if it does not exist, or replace a document with the same document ID
|
|
3419
|
+
* Returns a promise that resolves to a mutation result object containing the ID of the created document.
|
|
3420
|
+
*
|
|
3421
|
+
* @param document - Document to either create or replace
|
|
3422
|
+
* @param options - Mutation options
|
|
3423
|
+
*/
|
|
3424
|
+
createOrReplace<R extends Record<string, Any> = Record<string, Any>>(
|
|
3425
|
+
document: IdentifiedSanityDocumentStub<R>,
|
|
3426
|
+
options: FirstDocumentIdMutationOptions,
|
|
3427
|
+
): Promise<SingleMutationResult>
|
|
3428
|
+
/**
|
|
3429
|
+
* Create a document if it does not exist, or replace a document with the same document ID
|
|
3430
|
+
* Returns a promise that resolves to a mutation result object containing the created document ID.
|
|
3431
|
+
*
|
|
3432
|
+
* @param document - Document to either create or replace
|
|
3433
|
+
* @param options - Mutation options
|
|
3434
|
+
*/
|
|
3435
|
+
createOrReplace<R extends Record<string, Any> = Record<string, Any>>(
|
|
3436
|
+
document: IdentifiedSanityDocumentStub<R>,
|
|
3437
|
+
options: AllDocumentIdsMutationOptions,
|
|
3438
|
+
): Promise<MultipleMutationResult>
|
|
3439
|
+
/**
|
|
3440
|
+
* Create a document if it does not exist, or replace a document with the same document ID
|
|
3441
|
+
* Returns a promise that resolves to the created document.
|
|
3442
|
+
*
|
|
3443
|
+
* @param document - Document to either create or replace
|
|
3444
|
+
* @param options - Mutation options
|
|
3445
|
+
*/
|
|
3446
|
+
createOrReplace<R extends Record<string, Any> = Record<string, Any>>(
|
|
3447
|
+
document: IdentifiedSanityDocumentStub<R>,
|
|
3448
|
+
options?: BaseMutationOptions,
|
|
3449
|
+
): Promise<SanityDocument<R>>
|
|
3450
|
+
/**
|
|
3451
|
+
* Deletes a document with the given document ID.
|
|
3452
|
+
* Returns a promise that resolves to the deleted document.
|
|
3453
|
+
*
|
|
3454
|
+
* @param id - Document ID to delete
|
|
3455
|
+
* @param options - Options for the mutation
|
|
3456
|
+
*/
|
|
3457
|
+
delete<R extends Record<string, Any> = Record<string, Any>>(
|
|
3458
|
+
id: string,
|
|
3459
|
+
options: FirstDocumentMutationOptions,
|
|
3460
|
+
): Promise<SanityDocument<R>>
|
|
3461
|
+
/**
|
|
3462
|
+
* Deletes a document with the given document ID.
|
|
3463
|
+
* Returns a promise that resolves to an array containing the deleted document.
|
|
3464
|
+
*
|
|
3465
|
+
* @param id - Document ID to delete
|
|
3466
|
+
* @param options - Options for the mutation
|
|
3467
|
+
*/
|
|
3468
|
+
delete<R extends Record<string, Any> = Record<string, Any>>(
|
|
3469
|
+
id: string,
|
|
3470
|
+
options: AllDocumentsMutationOptions,
|
|
3471
|
+
): Promise<SanityDocument<R>[]>
|
|
3472
|
+
/**
|
|
3473
|
+
* Deletes a document with the given document ID.
|
|
3474
|
+
* Returns a promise that resolves to a mutation result object containing the deleted document ID.
|
|
2244
3475
|
*
|
|
2245
|
-
* @param
|
|
3476
|
+
* @param id - Document ID to delete
|
|
3477
|
+
* @param options - Options for the mutation
|
|
2246
3478
|
*/
|
|
2247
|
-
|
|
3479
|
+
delete(id: string, options: FirstDocumentIdMutationOptions): Promise<SingleMutationResult>
|
|
3480
|
+
/**
|
|
3481
|
+
* Deletes a document with the given document ID.
|
|
3482
|
+
* Returns a promise that resolves to a mutation result object containing the deleted document ID.
|
|
3483
|
+
*
|
|
3484
|
+
* @param id - Document ID to delete
|
|
3485
|
+
* @param options - Options for the mutation
|
|
3486
|
+
*/
|
|
3487
|
+
delete(id: string, options: AllDocumentIdsMutationOptions): Promise<MultipleMutationResult>
|
|
3488
|
+
/**
|
|
3489
|
+
* Deletes a document with the given document ID.
|
|
3490
|
+
* Returns a promise that resolves to the deleted document.
|
|
3491
|
+
*
|
|
3492
|
+
* @param id - Document ID to delete
|
|
3493
|
+
* @param options - Options for the mutation
|
|
3494
|
+
*/
|
|
3495
|
+
delete<R extends Record<string, Any> = Record<string, Any>>(
|
|
3496
|
+
id: string,
|
|
3497
|
+
options?: BaseMutationOptions,
|
|
3498
|
+
): Promise<SanityDocument<R>>
|
|
3499
|
+
/**
|
|
3500
|
+
* Deletes one or more documents matching the given query or document ID.
|
|
3501
|
+
* Returns a promise that resolves to first deleted document.
|
|
3502
|
+
*
|
|
3503
|
+
* @param selection - An object with either an `id` or `query` key defining what to delete
|
|
3504
|
+
* @param options - Options for the mutation
|
|
3505
|
+
*/
|
|
3506
|
+
delete<R extends Record<string, Any> = Record<string, Any>>(
|
|
3507
|
+
selection: MutationSelection,
|
|
3508
|
+
options: FirstDocumentMutationOptions,
|
|
3509
|
+
): Promise<SanityDocument<R>>
|
|
3510
|
+
/**
|
|
3511
|
+
* Deletes one or more documents matching the given query or document ID.
|
|
3512
|
+
* Returns a promise that resolves to an array containing the deleted documents.
|
|
3513
|
+
*
|
|
3514
|
+
* @param selection - An object with either an `id` or `query` key defining what to delete
|
|
3515
|
+
* @param options - Options for the mutation
|
|
3516
|
+
*/
|
|
3517
|
+
delete<R extends Record<string, Any> = Record<string, Any>>(
|
|
3518
|
+
selection: MutationSelection,
|
|
2248
3519
|
options: AllDocumentsMutationOptions,
|
|
2249
3520
|
): Promise<SanityDocument<R>[]>
|
|
2250
3521
|
/**
|
|
2251
|
-
*
|
|
3522
|
+
* Deletes one or more documents matching the given query or document ID.
|
|
3523
|
+
* Returns a promise that resolves to a mutation result object containing the ID of the first deleted document.
|
|
2252
3524
|
*
|
|
2253
|
-
* @param
|
|
3525
|
+
* @param selection - An object with either an `id` or `query` key defining what to delete
|
|
3526
|
+
* @param options - Options for the mutation
|
|
2254
3527
|
*/
|
|
2255
|
-
|
|
3528
|
+
delete(
|
|
3529
|
+
selection: MutationSelection,
|
|
3530
|
+
options: FirstDocumentIdMutationOptions,
|
|
3531
|
+
): Promise<SingleMutationResult>
|
|
2256
3532
|
/**
|
|
2257
|
-
*
|
|
3533
|
+
* Deletes one or more documents matching the given query or document ID.
|
|
3534
|
+
* Returns a promise that resolves to a mutation result object containing the document IDs that were deleted.
|
|
2258
3535
|
*
|
|
2259
|
-
* @param
|
|
3536
|
+
* @param selection - An object with either an `id` or `query` key defining what to delete
|
|
3537
|
+
* @param options - Options for the mutation
|
|
2260
3538
|
*/
|
|
2261
|
-
|
|
3539
|
+
delete(
|
|
3540
|
+
selection: MutationSelection,
|
|
3541
|
+
options: AllDocumentIdsMutationOptions,
|
|
3542
|
+
): Promise<MultipleMutationResult>
|
|
2262
3543
|
/**
|
|
2263
|
-
*
|
|
3544
|
+
* Deletes one or more documents matching the given query or document ID.
|
|
3545
|
+
* Returns a promise that resolves to first deleted document.
|
|
2264
3546
|
*
|
|
2265
|
-
* @param
|
|
3547
|
+
* @param selection - An object with either an `id` or `query` key defining what to delete
|
|
3548
|
+
* @param options - Options for the mutation
|
|
2266
3549
|
*/
|
|
2267
|
-
|
|
3550
|
+
delete<R extends Record<string, Any> = Record<string, Any>>(
|
|
3551
|
+
selection: MutationSelection,
|
|
2268
3552
|
options?: BaseMutationOptions,
|
|
2269
3553
|
): Promise<SanityDocument<R>>
|
|
2270
|
-
}
|
|
2271
|
-
|
|
2272
|
-
/** @public */
|
|
2273
|
-
export declare type PatchBuilder = (patch: Patch) => Patch
|
|
2274
|
-
|
|
2275
|
-
/** @internal */
|
|
2276
|
-
export declare type PatchMutationOperation = PatchOperations & MutationSelection
|
|
2277
|
-
|
|
2278
|
-
/** @internal */
|
|
2279
|
-
export declare interface PatchOperations {
|
|
2280
|
-
set?: {
|
|
2281
|
-
[key: string]: Any
|
|
2282
|
-
}
|
|
2283
|
-
setIfMissing?: {
|
|
2284
|
-
[key: string]: Any
|
|
2285
|
-
}
|
|
2286
|
-
diffMatchPatch?: {
|
|
2287
|
-
[key: string]: Any
|
|
2288
|
-
}
|
|
2289
|
-
unset?: string[]
|
|
2290
|
-
inc?: {
|
|
2291
|
-
[key: string]: number
|
|
2292
|
-
}
|
|
2293
|
-
dec?: {
|
|
2294
|
-
[key: string]: number
|
|
2295
|
-
}
|
|
2296
|
-
insert?: InsertPatch
|
|
2297
|
-
ifRevisionID?: string
|
|
2298
|
-
}
|
|
2299
|
-
|
|
2300
|
-
/** @internal */
|
|
2301
|
-
export declare type PatchSelection = string | string[] | MutationSelection
|
|
2302
|
-
|
|
2303
|
-
/** @public */
|
|
2304
|
-
declare interface ProgressEvent_2 {
|
|
2305
|
-
type: 'progress'
|
|
2306
|
-
stage: 'upload' | 'download'
|
|
2307
|
-
percent: number
|
|
2308
|
-
total?: number
|
|
2309
|
-
loaded?: number
|
|
2310
|
-
lengthComputable: boolean
|
|
2311
|
-
}
|
|
2312
|
-
export {ProgressEvent_2 as ProgressEvent}
|
|
2313
|
-
|
|
2314
|
-
/** @internal */
|
|
2315
|
-
export declare class ProjectsClient {
|
|
2316
|
-
#private
|
|
2317
|
-
constructor(client: SanityClient, httpRequest: HttpRequest)
|
|
2318
3554
|
/**
|
|
2319
|
-
*
|
|
3555
|
+
* Perform mutation operations against the configured dataset
|
|
3556
|
+
* Returns a promise that resolves to the first mutated document.
|
|
2320
3557
|
*
|
|
2321
|
-
* @param
|
|
2322
|
-
* @param options
|
|
3558
|
+
* @param operations - Mutation operations to execute
|
|
3559
|
+
* @param options - Mutation options
|
|
2323
3560
|
*/
|
|
2324
|
-
|
|
2325
|
-
|
|
3561
|
+
mutate<R extends Record<string, Any> = Record<string, Any>>(
|
|
3562
|
+
operations: Mutation<R>[] | Patch | Transaction,
|
|
3563
|
+
options: FirstDocumentMutationOptions,
|
|
3564
|
+
): Promise<SanityDocument<R>>
|
|
2326
3565
|
/**
|
|
2327
|
-
*
|
|
3566
|
+
* Perform mutation operations against the configured dataset.
|
|
3567
|
+
* Returns a promise that resolves to an array of the mutated documents.
|
|
2328
3568
|
*
|
|
2329
|
-
* @param
|
|
3569
|
+
* @param operations - Mutation operations to execute
|
|
3570
|
+
* @param options - Mutation options
|
|
2330
3571
|
*/
|
|
2331
|
-
|
|
2332
|
-
|
|
2333
|
-
|
|
2334
|
-
|
|
2335
|
-
* Publishes a draft document.
|
|
2336
|
-
* If a published version of the document already exists this is replaced by the current draft document.
|
|
2337
|
-
* In either case the draft document is deleted.
|
|
2338
|
-
* The optional revision id parameters can be used for optimistic locking to ensure
|
|
2339
|
-
* that the draft and/or published versions of the document have not been changed by another client.
|
|
2340
|
-
*
|
|
2341
|
-
* @public
|
|
2342
|
-
*/
|
|
2343
|
-
export declare type PublishAction = {
|
|
2344
|
-
actionType: 'sanity.action.document.publish'
|
|
3572
|
+
mutate<R extends Record<string, Any> = Record<string, Any>>(
|
|
3573
|
+
operations: Mutation<R>[] | Patch | Transaction,
|
|
3574
|
+
options: AllDocumentsMutationOptions,
|
|
3575
|
+
): Promise<SanityDocument<R>[]>
|
|
2345
3576
|
/**
|
|
2346
|
-
*
|
|
3577
|
+
* Perform mutation operations against the configured dataset
|
|
3578
|
+
* Returns a promise that resolves to a mutation result object containing the document ID of the first mutated document.
|
|
3579
|
+
*
|
|
3580
|
+
* @param operations - Mutation operations to execute
|
|
3581
|
+
* @param options - Mutation options
|
|
2347
3582
|
*/
|
|
2348
|
-
|
|
3583
|
+
mutate<R extends Record<string, Any> = Record<string, Any>>(
|
|
3584
|
+
operations: Mutation<R>[] | Patch | Transaction,
|
|
3585
|
+
options: FirstDocumentIdMutationOptions,
|
|
3586
|
+
): Promise<SingleMutationResult>
|
|
2349
3587
|
/**
|
|
2350
|
-
*
|
|
3588
|
+
* Perform mutation operations against the configured dataset
|
|
3589
|
+
* Returns a promise that resolves to a mutation result object containing the mutated document IDs.
|
|
3590
|
+
*
|
|
3591
|
+
* @param operations - Mutation operations to execute
|
|
3592
|
+
* @param options - Mutation options
|
|
3593
|
+
*/
|
|
3594
|
+
mutate<R extends Record<string, Any>>(
|
|
3595
|
+
operations: Mutation<R>[] | Patch | Transaction,
|
|
3596
|
+
options: AllDocumentIdsMutationOptions,
|
|
3597
|
+
): Promise<MultipleMutationResult>
|
|
3598
|
+
/**
|
|
3599
|
+
* Perform mutation operations against the configured dataset
|
|
3600
|
+
* Returns a promise that resolves to the first mutated document.
|
|
3601
|
+
*
|
|
3602
|
+
* @param operations - Mutation operations to execute
|
|
3603
|
+
* @param options - Mutation options
|
|
3604
|
+
*/
|
|
3605
|
+
mutate<R extends Record<string, Any> = Record<string, Any>>(
|
|
3606
|
+
operations: Mutation<R>[] | Patch | Transaction,
|
|
3607
|
+
options?: BaseMutationOptions,
|
|
3608
|
+
): Promise<SanityDocument<R>>
|
|
3609
|
+
/**
|
|
3610
|
+
* Create a new buildable patch of operations to perform
|
|
3611
|
+
*
|
|
3612
|
+
* @param documentId - Document ID to patch
|
|
3613
|
+
* @param operations - Optional object of patch operations to initialize the patch instance with
|
|
3614
|
+
* @returns Patch instance - call `.commit()` to perform the operations defined
|
|
3615
|
+
*/
|
|
3616
|
+
patch(documentId: string, operations?: PatchOperations): Patch
|
|
3617
|
+
/**
|
|
3618
|
+
* Create a new buildable patch of operations to perform
|
|
3619
|
+
*
|
|
3620
|
+
* @param documentIds - Array of document IDs to patch
|
|
3621
|
+
* @param operations - Optional object of patch operations to initialize the patch instance with
|
|
3622
|
+
* @returns Patch instance - call `.commit()` to perform the operations defined
|
|
3623
|
+
*/
|
|
3624
|
+
patch(documentIds: string[], operations?: PatchOperations): Patch
|
|
3625
|
+
/**
|
|
3626
|
+
* Create a new buildable patch of operations to perform
|
|
3627
|
+
*
|
|
3628
|
+
* @param selection - An object with `query` and optional `params`, defining which document(s) to patch
|
|
3629
|
+
* @param operations - Optional object of patch operations to initialize the patch instance with
|
|
3630
|
+
* @returns Patch instance - call `.commit()` to perform the operations defined
|
|
3631
|
+
*/
|
|
3632
|
+
patch(selection: MutationSelection, operations?: PatchOperations): Patch
|
|
3633
|
+
/**
|
|
3634
|
+
* Create a new transaction of mutations
|
|
3635
|
+
*
|
|
3636
|
+
* @param operations - Optional array of mutation operations to initialize the transaction instance with
|
|
3637
|
+
*/
|
|
3638
|
+
transaction<R extends Record<string, Any> = Record<string, Any>>(
|
|
3639
|
+
operations?: Mutation<R>[],
|
|
3640
|
+
): Transaction
|
|
3641
|
+
/**
|
|
3642
|
+
* Perform action operations against the configured dataset
|
|
3643
|
+
* Returns a promise that resolves to the transaction result
|
|
3644
|
+
*
|
|
3645
|
+
* @param operations - Action operation(s) to execute
|
|
3646
|
+
* @param options - Action options
|
|
3647
|
+
*/
|
|
3648
|
+
action(
|
|
3649
|
+
operations: Action | Action[],
|
|
3650
|
+
options?: BaseActionOptions,
|
|
3651
|
+
): Promise<SingleActionResult | MultipleActionResult>
|
|
3652
|
+
/**
|
|
3653
|
+
* Perform a request against the Sanity API
|
|
3654
|
+
* NOTE: Only use this for Sanity API endpoints, not for your own APIs!
|
|
3655
|
+
*
|
|
3656
|
+
* @param options - Request options
|
|
3657
|
+
* @returns Promise resolving to the response body
|
|
3658
|
+
*/
|
|
3659
|
+
request<R = Any>(options: RawRequestOptions): Promise<R>
|
|
3660
|
+
/**
|
|
3661
|
+
* Perform an HTTP request a `/data` sub-endpoint
|
|
3662
|
+
* NOTE: Considered internal, thus marked as deprecated. Use `request` instead.
|
|
3663
|
+
*
|
|
3664
|
+
* @deprecated - Use `request()` or your own HTTP library instead
|
|
3665
|
+
* @param endpoint - Endpoint to hit (mutate, query etc)
|
|
3666
|
+
* @param body - Request body
|
|
3667
|
+
* @param options - Request options
|
|
3668
|
+
* @internal
|
|
2351
3669
|
*/
|
|
2352
|
-
|
|
3670
|
+
dataRequest(endpoint: string, body: unknown, options?: BaseMutationOptions): Promise<Any>
|
|
2353
3671
|
/**
|
|
2354
|
-
*
|
|
3672
|
+
* Get a Sanity API URL for the URI provided
|
|
3673
|
+
*
|
|
3674
|
+
* @param uri - URI/path to build URL for
|
|
3675
|
+
* @param canUseCdn - Whether or not to allow using the API CDN for this route
|
|
2355
3676
|
*/
|
|
2356
|
-
|
|
3677
|
+
getUrl(uri: string, canUseCdn?: boolean): string
|
|
2357
3678
|
/**
|
|
2358
|
-
*
|
|
3679
|
+
* Get a Sanity API URL for the data operation and path provided
|
|
3680
|
+
*
|
|
3681
|
+
* @param operation - Data operation (eg `query`, `mutate`, `listen` or similar)
|
|
3682
|
+
* @param path - Path to append after the operation
|
|
2359
3683
|
*/
|
|
2360
|
-
|
|
2361
|
-
}
|
|
2362
|
-
|
|
2363
|
-
/** @public */
|
|
2364
|
-
export declare type QueryOptions =
|
|
2365
|
-
| FilteredResponseQueryOptions
|
|
2366
|
-
| UnfilteredResponseQueryOptions
|
|
2367
|
-
| UnfilteredResponseWithoutQuery
|
|
2368
|
-
|
|
2369
|
-
/** @public */
|
|
2370
|
-
export declare interface QueryParams {
|
|
2371
|
-
[key: string]: any
|
|
2372
|
-
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2373
|
-
body?: never
|
|
2374
|
-
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2375
|
-
cache?: 'next' extends keyof RequestInit ? never : any
|
|
2376
|
-
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2377
|
-
filterResponse?: never
|
|
2378
|
-
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2379
|
-
headers?: never
|
|
2380
|
-
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2381
|
-
method?: never
|
|
2382
|
-
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2383
|
-
next?: 'next' extends keyof RequestInit ? never : any
|
|
2384
|
-
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2385
|
-
perspective?: never
|
|
2386
|
-
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2387
|
-
query?: never
|
|
2388
|
-
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2389
|
-
resultSourceMap?: never
|
|
2390
|
-
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2391
|
-
returnQuery?: never
|
|
2392
|
-
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2393
|
-
signal?: never
|
|
2394
|
-
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2395
|
-
stega?: never
|
|
2396
|
-
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2397
|
-
tag?: never
|
|
2398
|
-
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2399
|
-
timeout?: never
|
|
2400
|
-
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2401
|
-
token?: never
|
|
2402
|
-
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2403
|
-
useCdn?: never
|
|
2404
|
-
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2405
|
-
lastLiveEventId?: never
|
|
2406
|
-
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2407
|
-
cacheMode?: never
|
|
2408
|
-
}
|
|
2409
|
-
|
|
2410
|
-
/**
|
|
2411
|
-
* This type can be used with `client.fetch` to indicate that the query has no GROQ parameters.
|
|
2412
|
-
* @public
|
|
2413
|
-
*/
|
|
2414
|
-
export declare type QueryWithoutParams = Record<string, never> | undefined
|
|
2415
|
-
|
|
2416
|
-
/** @public */
|
|
2417
|
-
export declare type RawQuerylessQueryResponse<R> = Omit<RawQueryResponse<R>, 'query'>
|
|
2418
|
-
|
|
2419
|
-
/** @public */
|
|
2420
|
-
export declare interface RawQueryResponse<R> {
|
|
2421
|
-
query: string
|
|
2422
|
-
ms: number
|
|
2423
|
-
result: R
|
|
2424
|
-
resultSourceMap?: ContentSourceMap
|
|
2425
|
-
/** Requires `apiVersion` to be `2021-03-25` or later. */
|
|
2426
|
-
syncTags?: SyncTag[]
|
|
2427
|
-
}
|
|
2428
|
-
|
|
2429
|
-
/** @internal */
|
|
2430
|
-
export declare interface RawRequestOptions {
|
|
2431
|
-
url?: string
|
|
2432
|
-
uri?: string
|
|
2433
|
-
method?: string
|
|
2434
|
-
token?: string
|
|
2435
|
-
json?: boolean
|
|
2436
|
-
tag?: string
|
|
2437
|
-
useGlobalApi?: boolean
|
|
2438
|
-
withCredentials?: boolean
|
|
2439
|
-
query?: {
|
|
2440
|
-
[key: string]: string | string[]
|
|
2441
|
-
}
|
|
2442
|
-
headers?: {
|
|
2443
|
-
[key: string]: string
|
|
2444
|
-
}
|
|
2445
|
-
timeout?: number
|
|
2446
|
-
proxy?: string
|
|
2447
|
-
body?: Any
|
|
2448
|
-
maxRedirects?: number
|
|
2449
|
-
signal?: AbortSignal
|
|
2450
|
-
}
|
|
2451
|
-
|
|
2452
|
-
/**
|
|
2453
|
-
* The listener has been disconnected, and a reconnect attempt is scheduled.
|
|
2454
|
-
*
|
|
2455
|
-
* @public
|
|
2456
|
-
*/
|
|
2457
|
-
export declare type ReconnectEvent = {
|
|
2458
|
-
type: 'reconnect'
|
|
3684
|
+
getDataUrl(operation: string, path?: string): string
|
|
2459
3685
|
}
|
|
2460
3686
|
|
|
2461
3687
|
/**
|
|
2462
|
-
*
|
|
2463
|
-
*
|
|
2464
|
-
*/
|
|
2465
|
-
export declare type ReleaseId = `r${string}`
|
|
2466
|
-
|
|
2467
|
-
/**
|
|
2468
|
-
* Replaces an existing draft document.
|
|
2469
|
-
* At least one of the draft or published versions of the document must exist.
|
|
2470
|
-
*
|
|
2471
|
-
* @public
|
|
3688
|
+
* Shared base type for the `SanityClient` and `ObservableSanityClient` classes.
|
|
3689
|
+
* TODO: refactor the Promise and Observable differences to use generics so we no longer suffer from all this duplication in TS docs
|
|
2472
3690
|
*/
|
|
2473
|
-
|
|
2474
|
-
|
|
3691
|
+
declare interface SanityClientBase {
|
|
3692
|
+
live: LiveClient
|
|
3693
|
+
listen: typeof _listen
|
|
2475
3694
|
/**
|
|
2476
|
-
*
|
|
3695
|
+
* Get a Sanity API URL for the URI provided
|
|
3696
|
+
*
|
|
3697
|
+
* @param uri - URI/path to build URL for
|
|
3698
|
+
* @param canUseCdn - Whether or not to allow using the API CDN for this route
|
|
2477
3699
|
*/
|
|
2478
|
-
|
|
3700
|
+
getUrl(uri: string, canUseCdn?: boolean): string
|
|
2479
3701
|
/**
|
|
2480
|
-
*
|
|
3702
|
+
* Get a Sanity API URL for the data operation and path provided
|
|
3703
|
+
*
|
|
3704
|
+
* @param operation - Data operation (eg `query`, `mutate`, `listen` or similar)
|
|
3705
|
+
* @param path - Path to append after the operation
|
|
2481
3706
|
*/
|
|
2482
|
-
|
|
3707
|
+
getDataUrl(operation: string, path?: string): string
|
|
2483
3708
|
}
|
|
2484
3709
|
|
|
2485
3710
|
/**
|
|
2486
|
-
*
|
|
3711
|
+
* The interface implemented by the `SanityClient` class.
|
|
3712
|
+
* When writing code that wants to take an instance of `SanityClient` as input it's better to use this type,
|
|
3713
|
+
* as the `SanityClient` class has private properties and thus TypeScrict will consider the type incompatible
|
|
3714
|
+
* in cases where you might have multiple `@sanity/client` instances in your node_modules.
|
|
2487
3715
|
* @public
|
|
2488
3716
|
*/
|
|
2489
|
-
export declare
|
|
2490
|
-
|
|
2491
|
-
/** @internal */
|
|
2492
|
-
export declare interface RequestObservableOptions extends Omit<RequestOptions, 'url'> {
|
|
2493
|
-
url?: string
|
|
2494
|
-
uri?: string
|
|
2495
|
-
canUseCdn?: boolean
|
|
2496
|
-
useCdn?: boolean
|
|
2497
|
-
tag?: string
|
|
2498
|
-
returnQuery?: boolean
|
|
2499
|
-
resultSourceMap?: boolean | 'withKeyArraySelector'
|
|
2500
|
-
perspective?: ClientPerspective
|
|
2501
|
-
lastLiveEventId?: string
|
|
2502
|
-
cacheMode?: 'noStale'
|
|
2503
|
-
}
|
|
2504
|
-
|
|
2505
|
-
/** @public */
|
|
2506
|
-
export declare interface RequestOptions {
|
|
2507
|
-
timeout?: number
|
|
2508
|
-
token?: string
|
|
2509
|
-
tag?: string
|
|
2510
|
-
headers?: Record<string, string>
|
|
2511
|
-
method?: string
|
|
2512
|
-
query?: Any
|
|
2513
|
-
body?: Any
|
|
2514
|
-
signal?: AbortSignal
|
|
2515
|
-
}
|
|
2516
|
-
|
|
2517
|
-
/** @alpha */
|
|
2518
|
-
export declare type ResolveStudioUrl = (
|
|
2519
|
-
sourceDocument: ContentSourceMapDocuments_2[number],
|
|
2520
|
-
) => StudioUrl
|
|
2521
|
-
|
|
2522
|
-
/** @public */
|
|
2523
|
-
export declare interface ResponseEvent<T = unknown> {
|
|
2524
|
-
type: 'response'
|
|
2525
|
-
body: T
|
|
2526
|
-
url: string
|
|
2527
|
-
method: string
|
|
2528
|
-
statusCode: number
|
|
2529
|
-
statusMessage?: string
|
|
2530
|
-
headers: Record<string, string>
|
|
2531
|
-
}
|
|
2532
|
-
|
|
2533
|
-
/** @public */
|
|
2534
|
-
export declare interface ResponseQueryOptions extends RequestOptions {
|
|
2535
|
-
perspective?: ClientPerspective
|
|
2536
|
-
resultSourceMap?: boolean | 'withKeyArraySelector'
|
|
2537
|
-
returnQuery?: boolean
|
|
2538
|
-
useCdn?: boolean
|
|
2539
|
-
stega?: boolean | StegaConfig
|
|
2540
|
-
cache?: 'next' extends keyof RequestInit ? RequestInit['cache'] : never
|
|
2541
|
-
next?: ('next' extends keyof RequestInit ? RequestInit : never)['next']
|
|
2542
|
-
lastLiveEventId?: string | string[] | null
|
|
2543
|
-
/**
|
|
2544
|
-
* When set to `noStale`, APICDN will not return a cached response if the content is stale.
|
|
2545
|
-
* Tradeoff between latency and freshness of content.
|
|
2546
|
-
*
|
|
2547
|
-
* Only to be used with live content queries and when useCdn is true.
|
|
2548
|
-
*/
|
|
2549
|
-
cacheMode?: 'noStale'
|
|
2550
|
-
}
|
|
2551
|
-
|
|
2552
|
-
/** @internal */
|
|
2553
|
-
export declare interface SanityAssetDocument extends SanityDocument {
|
|
2554
|
-
url: string
|
|
2555
|
-
path: string
|
|
2556
|
-
size: number
|
|
2557
|
-
assetId: string
|
|
2558
|
-
mimeType: string
|
|
2559
|
-
sha1hash: string
|
|
2560
|
-
extension: string
|
|
2561
|
-
uploadId?: string
|
|
2562
|
-
originalFilename?: string
|
|
2563
|
-
}
|
|
2564
|
-
|
|
2565
|
-
/** @public */
|
|
2566
|
-
export declare class SanityClient {
|
|
2567
|
-
#private
|
|
3717
|
+
export declare interface SanityClientType extends SanityClientBase {
|
|
2568
3718
|
assets: AssetsClient
|
|
2569
3719
|
datasets: DatasetsClient
|
|
2570
|
-
live: LiveClient
|
|
2571
3720
|
projects: ProjectsClient
|
|
2572
3721
|
users: UsersClient
|
|
2573
3722
|
/**
|
|
2574
3723
|
* Observable version of the Sanity client, with the same configuration as the promise-based one
|
|
2575
3724
|
*/
|
|
2576
|
-
observable:
|
|
2577
|
-
/**
|
|
2578
|
-
* Instance properties
|
|
2579
|
-
*/
|
|
2580
|
-
listen: typeof _listen
|
|
2581
|
-
constructor(httpRequest: HttpRequest, config?: ClientConfig)
|
|
3725
|
+
observable: ObservableSanityClientType
|
|
2582
3726
|
/**
|
|
2583
3727
|
* Clone the client - returns a new instance
|
|
2584
3728
|
*/
|
|
2585
|
-
clone():
|
|
3729
|
+
clone(): SanityClientType
|
|
2586
3730
|
/**
|
|
2587
3731
|
* Returns the current client configuration
|
|
2588
3732
|
*/
|
|
@@ -2590,13 +3734,13 @@ export declare class SanityClient {
|
|
|
2590
3734
|
/**
|
|
2591
3735
|
* Reconfigure the client. Note that this _mutates_ the current client.
|
|
2592
3736
|
*/
|
|
2593
|
-
config(newConfig?: Partial<ClientConfig>):
|
|
3737
|
+
config(newConfig?: Partial<ClientConfig>): SanityClientType
|
|
2594
3738
|
/**
|
|
2595
3739
|
* Clone the client with a new (partial) configuration.
|
|
2596
3740
|
*
|
|
2597
3741
|
* @param newConfig - New client configuration properties, shallowly merged with existing configuration
|
|
2598
3742
|
*/
|
|
2599
|
-
withConfig(newConfig?: Partial<ClientConfig>):
|
|
3743
|
+
withConfig(newConfig?: Partial<ClientConfig>): SanityClientType
|
|
2600
3744
|
/**
|
|
2601
3745
|
* Perform a GROQ-query against the configured dataset.
|
|
2602
3746
|
*
|
|
@@ -2606,7 +3750,10 @@ export declare class SanityClient {
|
|
|
2606
3750
|
R = Any,
|
|
2607
3751
|
Q extends QueryWithoutParams = QueryWithoutParams,
|
|
2608
3752
|
const G extends string = string,
|
|
2609
|
-
>(
|
|
3753
|
+
>(
|
|
3754
|
+
query: G,
|
|
3755
|
+
params?: Q | QueryWithoutParams,
|
|
3756
|
+
): Promise<ClientReturn<G, R>>
|
|
2610
3757
|
/**
|
|
2611
3758
|
* Perform a GROQ-query against the configured dataset.
|
|
2612
3759
|
*
|
|
@@ -3032,6 +4179,14 @@ export declare class SanityClient {
|
|
|
3032
4179
|
* @returns Patch instance - call `.commit()` to perform the operations defined
|
|
3033
4180
|
*/
|
|
3034
4181
|
patch(selection: MutationSelection, operations?: PatchOperations): Patch
|
|
4182
|
+
/**
|
|
4183
|
+
* Create a new buildable patch of operations to perform
|
|
4184
|
+
*
|
|
4185
|
+
* @param selection - Document ID, an array of document IDs, or an object with `query` and optional `params`, defining which document(s) to patch
|
|
4186
|
+
* @param operations - Optional object of patch operations to initialize the patch instance with
|
|
4187
|
+
* @returns Patch instance - call `.commit()` to perform the operations defined
|
|
4188
|
+
*/
|
|
4189
|
+
patch(selection: PatchSelection, operations?: PatchOperations): Patch
|
|
3035
4190
|
/**
|
|
3036
4191
|
* Create a new transaction of mutations
|
|
3037
4192
|
*
|
|
@@ -3070,20 +4225,6 @@ export declare class SanityClient {
|
|
|
3070
4225
|
* @internal
|
|
3071
4226
|
*/
|
|
3072
4227
|
dataRequest(endpoint: string, body: unknown, options?: BaseMutationOptions): Promise<Any>
|
|
3073
|
-
/**
|
|
3074
|
-
* Get a Sanity API URL for the URI provided
|
|
3075
|
-
*
|
|
3076
|
-
* @param uri - URI/path to build URL for
|
|
3077
|
-
* @param canUseCdn - Whether or not to allow using the API CDN for this route
|
|
3078
|
-
*/
|
|
3079
|
-
getUrl(uri: string, canUseCdn?: boolean): string
|
|
3080
|
-
/**
|
|
3081
|
-
* Get a Sanity API URL for the data operation and path provided
|
|
3082
|
-
*
|
|
3083
|
-
* @param operation - Data operation (eg `query`, `mutate`, `listen` or similar)
|
|
3084
|
-
* @param path - Path to append after the operation
|
|
3085
|
-
*/
|
|
3086
|
-
getDataUrl(operation: string, path?: string): string
|
|
3087
4228
|
}
|
|
3088
4229
|
|
|
3089
4230
|
/** @internal */
|