@sanity/client 6.29.1 → 7.0.1-canary.0

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