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