@sanity/client 6.7.1 → 6.8.0-pink-lizard.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. package/README.md +79 -2
  2. package/dist/_chunks/browserMiddleware-Oa7zKwEN.js +1862 -0
  3. package/dist/_chunks/browserMiddleware-Oa7zKwEN.js.map +1 -0
  4. package/dist/_chunks/browserMiddleware-zle5A-pb.cjs +1877 -0
  5. package/dist/_chunks/browserMiddleware-zle5A-pb.cjs.map +1 -0
  6. package/dist/_chunks/createEditLink-FiifjNgi.cjs +222 -0
  7. package/dist/_chunks/createEditLink-FiifjNgi.cjs.map +1 -0
  8. package/dist/_chunks/createEditLink-f3l2nngi.js +212 -0
  9. package/dist/_chunks/createEditLink-f3l2nngi.js.map +1 -0
  10. package/dist/_chunks/nodeMiddleware-S6QZVGmT.cjs +1897 -0
  11. package/dist/_chunks/nodeMiddleware-S6QZVGmT.cjs.map +1 -0
  12. package/dist/_chunks/nodeMiddleware-XodpBhbR.js +1882 -0
  13. package/dist/_chunks/nodeMiddleware-XodpBhbR.js.map +1 -0
  14. package/dist/csm.cjs +71 -0
  15. package/dist/csm.cjs.map +1 -0
  16. package/dist/csm.d.ts +248 -0
  17. package/dist/csm.js +58 -0
  18. package/dist/csm.js.map +1 -0
  19. package/dist/index.browser.cjs +13 -1868
  20. package/dist/index.browser.cjs.map +1 -1
  21. package/dist/index.browser.js +3 -1858
  22. package/dist/index.browser.js.map +1 -1
  23. package/dist/index.cjs +13 -1888
  24. package/dist/index.cjs.js +2 -2
  25. package/dist/index.cjs.map +1 -1
  26. package/dist/index.js +3 -1878
  27. package/dist/index.js.map +1 -1
  28. package/dist/stega.browser.cjs +629 -0
  29. package/dist/stega.browser.cjs.map +1 -0
  30. package/dist/stega.browser.js +598 -0
  31. package/dist/stega.browser.js.map +1 -0
  32. package/dist/stega.cjs +424 -0
  33. package/dist/stega.cjs.js +21 -0
  34. package/dist/stega.cjs.map +1 -0
  35. package/dist/stega.d.ts +2872 -0
  36. package/dist/stega.js +393 -0
  37. package/dist/stega.js.map +1 -0
  38. package/package.json +42 -2
  39. package/src/config.ts +6 -0
  40. package/src/csm/applySourceDocuments.test.ts +820 -0
  41. package/src/csm/applySourceDocuments.ts +87 -0
  42. package/src/csm/createEditLink.ts +75 -0
  43. package/src/csm/getPublishedId.ts +12 -0
  44. package/src/csm/index.ts +9 -0
  45. package/src/csm/isArray.ts +3 -0
  46. package/src/csm/isRecord.ts +3 -0
  47. package/src/csm/jsonpath.test.ts +33 -0
  48. package/src/csm/jsonpath.ts +93 -0
  49. package/src/csm/resolveMapping.ts +41 -0
  50. package/src/csm/resolvedKeyedSourcePath.ts +23 -0
  51. package/src/csm/simplifyPath.ts +20 -0
  52. package/src/csm/types.ts +72 -0
  53. package/src/csm/walkMap.ts +30 -0
  54. package/src/stega/SanityStegaClient.ts +244 -0
  55. package/src/stega/config.ts +56 -0
  56. package/src/stega/encodeIntoResult.test.ts +268 -0
  57. package/src/stega/encodeIntoResult.ts +59 -0
  58. package/src/stega/filterDefault.ts +49 -0
  59. package/src/stega/index.browser.ts +19 -0
  60. package/src/stega/index.ts +19 -0
  61. package/src/stega/shared.ts +4 -0
  62. package/src/stega/stegaEncodeSourceMap.ts +128 -0
  63. package/src/stega/types.ts +139 -0
  64. package/umd/sanityClient.js +5 -1
  65. package/umd/sanityClient.min.js +1 -1
@@ -0,0 +1,2872 @@
1
+ /// <reference types="node" />
2
+
3
+ import {Observable} from 'rxjs'
4
+ import {Requester} from 'get-it'
5
+ import {adapter as unstable__adapter} from 'get-it'
6
+ import {environment as unstable__environment} from 'get-it'
7
+
8
+ /** @internal */
9
+ export declare type AllDocumentIdsMutationOptions = BaseMutationOptions & {
10
+ returnFirst: false
11
+ returnDocuments: false
12
+ }
13
+
14
+ /** @internal */
15
+ export declare type AllDocumentsMutationOptions = BaseMutationOptions & {
16
+ returnFirst: false
17
+ returnDocuments?: true
18
+ }
19
+
20
+ /**
21
+ * Used to tag types that is set to `any` as a temporary measure, but should be replaced with proper typings in the future
22
+ * @internal
23
+ */
24
+ export declare type Any = any
25
+
26
+ /** @internal */
27
+ export declare interface ApiError {
28
+ error: string
29
+ message: string
30
+ statusCode: number
31
+ }
32
+
33
+ /** @public */
34
+ export declare type AssetMetadataType =
35
+ | 'location'
36
+ | 'exif'
37
+ | 'image'
38
+ | 'palette'
39
+ | 'lqip'
40
+ | 'blurhash'
41
+ | 'none'
42
+
43
+ /** @internal */
44
+ export declare class AssetsClient {
45
+ #private
46
+ constructor(client: SanityClient, httpRequest: HttpRequest)
47
+ /**
48
+ * Uploads a file asset to the configured dataset
49
+ *
50
+ * @param assetType - Asset type (file)
51
+ * @param body - Asset content - can be a browser File instance, a Blob, a Node.js Buffer instance or a Node.js ReadableStream.
52
+ * @param options - Options to use for the upload
53
+ */
54
+ upload(
55
+ assetType: 'file',
56
+ body: UploadBody,
57
+ options?: UploadClientConfig,
58
+ ): Promise<SanityAssetDocument>
59
+ /**
60
+ * Uploads an image asset to the configured dataset
61
+ *
62
+ * @param assetType - Asset type (image)
63
+ * @param body - Asset content - can be a browser File instance, a Blob, a Node.js Buffer instance or a Node.js ReadableStream.
64
+ * @param options - Options to use for the upload
65
+ */
66
+ upload(
67
+ assetType: 'image',
68
+ body: UploadBody,
69
+ options?: UploadClientConfig,
70
+ ): Promise<SanityImageAssetDocument>
71
+ /**
72
+ * Uploads a file or an image asset to the configured dataset
73
+ *
74
+ * @param assetType - Asset type (file/image)
75
+ * @param body - Asset content - can be a browser File instance, a Blob, a Node.js Buffer instance or a Node.js ReadableStream.
76
+ * @param options - Options to use for the upload
77
+ */
78
+ upload(
79
+ assetType: 'file' | 'image',
80
+ body: UploadBody,
81
+ options?: UploadClientConfig,
82
+ ): Promise<SanityAssetDocument | SanityImageAssetDocument>
83
+ }
84
+
85
+ /** @internal */
86
+ export declare type AttributeSet = {
87
+ [key: string]: Any
88
+ }
89
+
90
+ /** @internal */
91
+ export declare interface AuthProvider {
92
+ name: string
93
+ title: string
94
+ url: string
95
+ }
96
+
97
+ /** @internal */
98
+ export declare type AuthProviderResponse = {
99
+ providers: AuthProvider[]
100
+ }
101
+
102
+ /** @internal */
103
+ export declare type BaseMutationOptions = RequestOptions & {
104
+ visibility?: 'sync' | 'async' | 'deferred'
105
+ returnDocuments?: boolean
106
+ returnFirst?: boolean
107
+ dryRun?: boolean
108
+ autoGenerateArrayKeys?: boolean
109
+ skipCrossDatasetReferenceValidation?: boolean
110
+ transactionId?: string
111
+ }
112
+
113
+ /** @internal */
114
+ export declare class BasePatch {
115
+ protected selection: PatchSelection
116
+ protected operations: PatchOperations
117
+ constructor(selection: PatchSelection, operations?: PatchOperations)
118
+ /**
119
+ * Sets the given attributes to the document. Does NOT merge objects.
120
+ * The operation is added to the current patch, ready to be commited by `commit()`
121
+ *
122
+ * @param attrs - Attributes to set. To set a deep attribute, use JSONMatch, eg: \{"nested.prop": "value"\}
123
+ */
124
+ set(attrs: AttributeSet): this
125
+ /**
126
+ * Sets the given attributes to the document if they are not currently set. Does NOT merge objects.
127
+ * The operation is added to the current patch, ready to be commited by `commit()`
128
+ *
129
+ * @param attrs - Attributes to set. To set a deep attribute, use JSONMatch, eg: \{"nested.prop": "value"\}
130
+ */
131
+ setIfMissing(attrs: AttributeSet): this
132
+ /**
133
+ * Performs a "diff-match-patch" operation on the string attributes provided.
134
+ * The operation is added to the current patch, ready to be commited by `commit()`
135
+ *
136
+ * @param attrs - Attributes to perform operation on. To set a deep attribute, use JSONMatch, eg: \{"nested.prop": "dmp"\}
137
+ */
138
+ diffMatchPatch(attrs: AttributeSet): this
139
+ /**
140
+ * Unsets the attribute paths provided.
141
+ * The operation is added to the current patch, ready to be commited by `commit()`
142
+ *
143
+ * @param attrs - Attribute paths to unset.
144
+ */
145
+ unset(attrs: string[]): this
146
+ /**
147
+ * Increment a numeric value. Each entry in the argument is either an attribute or a JSON path. The value may be a positive or negative integer or floating-point value. The operation will fail if target value is not a numeric value, or doesn't exist.
148
+ *
149
+ * @param attrs - Object of attribute paths to increment, values representing the number to increment by.
150
+ */
151
+ inc(attrs: {[key: string]: number}): this
152
+ /**
153
+ * Decrement a numeric value. Each entry in the argument is either an attribute or a JSON path. The value may be a positive or negative integer or floating-point value. The operation will fail if target value is not a numeric value, or doesn't exist.
154
+ *
155
+ * @param attrs - Object of attribute paths to decrement, values representing the number to decrement by.
156
+ */
157
+ dec(attrs: {[key: string]: number}): this
158
+ /**
159
+ * Provides methods for modifying arrays, by inserting, appending and replacing elements via a JSONPath expression.
160
+ *
161
+ * @param at - Location to insert at, relative to the given selector, or 'replace' the matched path
162
+ * @param selector - JSONPath expression, eg `comments[-1]` or `blocks[_key=="abc123"]`
163
+ * @param items - Array of items to insert/replace
164
+ */
165
+ insert(at: 'before' | 'after' | 'replace', selector: string, items: Any[]): this
166
+ /**
167
+ * Append the given items to the array at the given JSONPath
168
+ *
169
+ * @param selector - Attribute/path to append to, eg `comments` or `person.hobbies`
170
+ * @param items - Array of items to append to the array
171
+ */
172
+ append(selector: string, items: Any[]): this
173
+ /**
174
+ * Prepend the given items to the array at the given JSONPath
175
+ *
176
+ * @param selector - Attribute/path to prepend to, eg `comments` or `person.hobbies`
177
+ * @param items - Array of items to prepend to the array
178
+ */
179
+ prepend(selector: string, items: Any[]): this
180
+ /**
181
+ * Change the contents of an array by removing existing elements and/or adding new elements.
182
+ *
183
+ * @param selector - Attribute or JSONPath expression for array
184
+ * @param start - Index at which to start changing the array (with origin 0). If greater than the length of the array, actual starting index will be set to the length of the array. If negative, will begin that many elements from the end of the array (with origin -1) and will be set to 0 if absolute value is greater than the length of the array.x
185
+ * @param deleteCount - An integer indicating the number of old array elements to remove.
186
+ * @param items - The elements to add to the array, beginning at the start index. If you don't specify any elements, splice() will only remove elements from the array.
187
+ */
188
+ splice(selector: string, start: number, deleteCount?: number, items?: Any[]): this
189
+ /**
190
+ * Adds a revision clause, preventing the document from being patched if the `_rev` property does not match the given value
191
+ *
192
+ * @param rev - Revision to lock the patch to
193
+ */
194
+ ifRevisionId(rev: string): this
195
+ /**
196
+ * Return a plain JSON representation of the patch
197
+ */
198
+ serialize(): PatchMutationOperation
199
+ /**
200
+ * Return a plain JSON representation of the patch
201
+ */
202
+ toJSON(): PatchMutationOperation
203
+ /**
204
+ * Clears the patch of all operations
205
+ */
206
+ reset(): this
207
+ protected _assign(op: keyof PatchOperations, props: Any, merge?: boolean): this
208
+ protected _set(op: keyof PatchOperations, props: Any): this
209
+ }
210
+
211
+ /** @internal */
212
+ export declare class BaseTransaction {
213
+ protected operations: Mutation[]
214
+ protected trxId?: string
215
+ constructor(operations?: Mutation[], transactionId?: string)
216
+ /**
217
+ * Creates a new Sanity document. If `_id` is provided and already exists, the mutation will fail. If no `_id` is given, one will automatically be generated by the database.
218
+ * The operation is added to the current transaction, ready to be commited by `commit()`
219
+ *
220
+ * @param doc - Document to create. Requires a `_type` property.
221
+ */
222
+ create<R extends Record<string, Any> = Record<string, Any>>(doc: SanityDocumentStub<R>): this
223
+ /**
224
+ * Creates a new Sanity document. If a document with the same `_id` already exists, the create operation will be ignored.
225
+ * The operation is added to the current transaction, ready to be commited by `commit()`
226
+ *
227
+ * @param doc - Document to create if it does not already exist. Requires `_id` and `_type` properties.
228
+ */
229
+ createIfNotExists<R extends Record<string, Any> = Record<string, Any>>(
230
+ doc: IdentifiedSanityDocumentStub<R>,
231
+ ): this
232
+ /**
233
+ * Creates a new Sanity document, or replaces an existing one if the same `_id` is already used.
234
+ * The operation is added to the current transaction, ready to be commited by `commit()`
235
+ *
236
+ * @param doc - Document to create or replace. Requires `_id` and `_type` properties.
237
+ */
238
+ createOrReplace<R extends Record<string, Any> = Record<string, Any>>(
239
+ doc: IdentifiedSanityDocumentStub<R>,
240
+ ): this
241
+ /**
242
+ * Deletes the document with the given document ID
243
+ * The operation is added to the current transaction, ready to be commited by `commit()`
244
+ *
245
+ * @param documentId - Document ID to delete
246
+ */
247
+ delete(documentId: string): this
248
+ /**
249
+ * Gets the current transaction ID, if any
250
+ */
251
+ transactionId(): string | undefined
252
+ /**
253
+ * Set the ID of this transaction.
254
+ *
255
+ * @param id - Transaction ID
256
+ */
257
+ transactionId(id: string): this
258
+ /**
259
+ * Return a plain JSON representation of the transaction
260
+ */
261
+ serialize(): Mutation[]
262
+ /**
263
+ * Return a plain JSON representation of the transaction
264
+ */
265
+ toJSON(): Mutation[]
266
+ /**
267
+ * Clears the transaction of all operations
268
+ */
269
+ reset(): this
270
+ protected _add(mut: Mutation): this
271
+ }
272
+
273
+ /**
274
+ * An error occurred. This is different from a network-level error (which will be emitted as 'error').
275
+ * Possible causes are things such as malformed filters, non-existant datasets or similar.
276
+ *
277
+ * @public
278
+ */
279
+ export declare type ChannelErrorEvent = {
280
+ type: 'channelError'
281
+ message: string
282
+ }
283
+
284
+ /** @public */
285
+ export declare interface ClientConfig {
286
+ projectId?: string
287
+ dataset?: string
288
+ /** @defaultValue true */
289
+ useCdn?: boolean
290
+ token?: string
291
+ /** @defaultValue 'raw' */
292
+ perspective?: ClientPerspective
293
+ apiHost?: string
294
+ apiVersion?: string
295
+ proxy?: string
296
+ requestTagPrefix?: string
297
+ ignoreBrowserTokenWarning?: boolean
298
+ withCredentials?: boolean
299
+ allowReconfigure?: boolean
300
+ timeout?: number
301
+ /** Number of retries for requests. Defaults to 5. */
302
+ maxRetries?: number
303
+ /**
304
+ * The amount of time, in milliseconds, to wait before retrying, given an attemptNumber (starting at 0).
305
+ *
306
+ * Defaults to exponential back-off, starting at 100ms, doubling for each attempt, together with random
307
+ * jitter between 0 and 100 milliseconds. More specifically the following algorithm is used:
308
+ *
309
+ * Delay = 100 * 2^attemptNumber + randomNumberBetween0and100
310
+ */
311
+ retryDelay?: (attemptNumber: number) => number
312
+ /**
313
+ * @deprecated Don't use
314
+ */
315
+ useProjectHostname?: boolean
316
+ /**
317
+ * @deprecated Don't use
318
+ */
319
+ requester?: Requester
320
+ /**
321
+ * Adds a `resultSourceMap` key to the API response, with the type `ContentSourceMap`
322
+ */
323
+ resultSourceMap?: boolean | 'withKeyArraySelector'
324
+ /**
325
+ *@deprecated set `cache` and `next` options on `client.fetch` instead
326
+ */
327
+ fetch?: RequestFetchOptions | boolean
328
+ }
329
+
330
+ /** @public */
331
+ export declare class ClientError extends Error {
332
+ response: ErrorProps['response']
333
+ statusCode: ErrorProps['statusCode']
334
+ responseBody: ErrorProps['responseBody']
335
+ details: ErrorProps['details']
336
+ constructor(res: Any)
337
+ }
338
+
339
+ /** @public */
340
+ export declare type ClientPerspective = 'previewDrafts' | 'published' | 'raw'
341
+
342
+ /** @public */
343
+ export declare interface ClientStegaConfig extends ClientConfig {
344
+ stega?: StegaConfig
345
+ }
346
+
347
+ /** @public */
348
+ export declare interface ContentSourceMap {
349
+ mappings: ContentSourceMapMappings
350
+ documents: ContentSourceMapDocuments
351
+ paths: ContentSourceMapPaths
352
+ }
353
+
354
+ /** @public */
355
+ export declare interface ContentSourceMapDocument extends ContentSourceMapDocumentBase {
356
+ _projectId?: undefined
357
+ _dataset?: undefined
358
+ }
359
+
360
+ /** @public */
361
+ export declare interface ContentSourceMapDocumentBase {
362
+ _id: string
363
+ _type: string
364
+ }
365
+
366
+ /** @public */
367
+ export declare type ContentSourceMapDocuments = (
368
+ | ContentSourceMapDocument
369
+ | ContentSourceMapRemoteDocument
370
+ )[]
371
+
372
+ /**
373
+ * DocumentValueSource is a path to a value within a document
374
+ * @public
375
+ */
376
+ export declare interface ContentSourceMapDocumentValueSource {
377
+ type: 'documentValue'
378
+ document: number
379
+ path: number
380
+ }
381
+
382
+ /**
383
+ * When a value is not from a source, its a literal
384
+ * @public
385
+ */
386
+ export declare interface ContentSourceMapLiteralSource {
387
+ type: 'literal'
388
+ }
389
+
390
+ /** @public */
391
+ export declare type ContentSourceMapMapping = ContentSourceMapValueMapping
392
+
393
+ /** @public */
394
+ export declare type ContentSourceMapMappings = Record<string, ContentSourceMapMapping>
395
+
396
+ /** @public */
397
+ export declare type ContentSourceMapPaths = string[]
398
+
399
+ /** @public */
400
+ export declare type ContentSourceMapQueryResponse =
401
+ | RawQueryResponse<unknown>
402
+ | Pick<RawQueryResponse<unknown>, 'result' | 'resultSourceMap'>
403
+
404
+ /** @public */
405
+ export declare interface ContentSourceMapRemoteDocument extends ContentSourceMapDocumentBase {
406
+ _projectId: string
407
+ _dataset: string
408
+ }
409
+
410
+ /** @public */
411
+ export declare type ContentSourceMapSource =
412
+ | ContentSourceMapDocumentValueSource
413
+ | ContentSourceMapLiteralSource
414
+ | ContentSourceMapUnknownSource
415
+
416
+ /**
417
+ * When a field source is unknown
418
+ * @public
419
+ */
420
+ export declare interface ContentSourceMapUnknownSource {
421
+ type: 'unknown'
422
+ }
423
+
424
+ /**
425
+ * ValueMapping is a mapping when for value that is from a single source value
426
+ * It may refer to a field within a document or a literal value
427
+ * @public
428
+ */
429
+ export declare interface ContentSourceMapValueMapping {
430
+ type: 'value'
431
+ source: ContentSourceMapSource
432
+ }
433
+
434
+ /** @public */
435
+ export declare const createClient: (config: ClientStegaConfig) => SanityStegaClient
436
+
437
+ /** @internal */
438
+ export declare interface CurrentSanityUser {
439
+ id: string
440
+ name: string
441
+ email: string
442
+ profileImage: string | null
443
+ role: string
444
+ }
445
+
446
+ /** @internal */
447
+ export declare type DatasetAclMode = 'public' | 'private' | 'custom'
448
+
449
+ /** @internal */
450
+ export declare type DatasetResponse = {
451
+ datasetName: string
452
+ aclMode: DatasetAclMode
453
+ }
454
+
455
+ /** @internal */
456
+ export declare class DatasetsClient {
457
+ #private
458
+ constructor(client: SanityClient, httpRequest: HttpRequest)
459
+ /**
460
+ * Create a new dataset with the given name
461
+ *
462
+ * @param name - Name of the dataset to create
463
+ * @param options - Options for the dataset
464
+ */
465
+ create(
466
+ name: string,
467
+ options?: {
468
+ aclMode?: DatasetAclMode
469
+ },
470
+ ): Promise<DatasetResponse>
471
+ /**
472
+ * Edit a dataset with the given name
473
+ *
474
+ * @param name - Name of the dataset to edit
475
+ * @param options - New options for the dataset
476
+ */
477
+ edit(
478
+ name: string,
479
+ options?: {
480
+ aclMode?: DatasetAclMode
481
+ },
482
+ ): Promise<DatasetResponse>
483
+ /**
484
+ * Delete a dataset with the given name
485
+ *
486
+ * @param name - Name of the dataset to delete
487
+ */
488
+ delete(name: string): Promise<{
489
+ deleted: true
490
+ }>
491
+ /**
492
+ * Fetch a list of datasets for the configured project
493
+ */
494
+ list(): Promise<DatasetsResponse>
495
+ }
496
+
497
+ /** @internal */
498
+ export declare type DatasetsResponse = {
499
+ name: string
500
+ aclMode: DatasetAclMode
501
+ }[]
502
+
503
+ /**
504
+ * The listener has been told to explicitly disconnect and not reconnect.
505
+ * This is a rare situation, but may occur if the API knows reconnect attempts will fail,
506
+ * eg in the case of a deleted dataset, a blocked project or similar events.
507
+ *
508
+ * Note that this is not treated as an error on the observable, but will complete the observable.
509
+ *
510
+ * @public
511
+ */
512
+ export declare type DisconnectEvent = {
513
+ type: 'disconnect'
514
+ reason: string
515
+ }
516
+
517
+ /**
518
+ * @internal
519
+ */
520
+ export declare function encodeIntoResult<Result>(
521
+ result: Result,
522
+ csm: ContentSourceMap,
523
+ encoder: Encoder,
524
+ options?: {
525
+ keyArraySelectors: boolean
526
+ },
527
+ ): Result
528
+
529
+ /**
530
+ * @internal
531
+ */
532
+ export declare type Encoder = (context: {
533
+ sourcePath: Path
534
+ sourceDocument: ContentSourceMapDocuments[number]
535
+ resultPath: Path
536
+ value: string
537
+ }) => string
538
+
539
+ /** @public */
540
+ export declare interface ErrorProps {
541
+ message: string
542
+ response: Any
543
+ statusCode: number
544
+ responseBody: Any
545
+ details: Any
546
+ }
547
+
548
+ /** @public */
549
+ export declare type FilterDefault = (props: {
550
+ /**
551
+ * The path to the value in the source document, for example if you queried for a document like this:
552
+ * `*[_type == "author"][0]{"slug": slug.current}`
553
+ * Then the `sourcePath` for `result.slug` would be `['slug', 'current']`.
554
+ *
555
+ */
556
+ sourcePath: Path
557
+ /**
558
+ * If `sourcePath` alone isn't enough to tell you if it's safe to contain stega strings, then you can use `sourceDocument`
559
+ * for additional metadata.
560
+ * It'll always have a `_type` property, which can be used to trace it to the Studio Schema that were used initially.
561
+ * It also has `_id` to help you debug and look at the whole document when troubleshooting.
562
+ * Finally, if the document origins in a Cross Dataset Reference you'll also have `_projectId` and `_dataset` properties to help you trace it.
563
+ */
564
+ sourceDocument: ContentSourceMapDocuments[number]
565
+ /**
566
+ * If you don't colocate your Studio Schemas with your GROQ queries it might be hard to make sense of `sourcePath`,
567
+ * as it operates on the original shape of a document.
568
+ * In that case `resultPath` can be used, as it mirrors the path to the value in the result.
569
+ * For example in a query like this:
570
+ * `*[_type == "author"][0]{"slug": slug.current}`
571
+ * The `resultPath` for `result.slug` would be `['slug']`, while `sourcePath` will be `['slug', 'current']`.
572
+ */
573
+ resultPath: Path
574
+ /**
575
+ * You can also use your own string validation logic to determine if it's safe.
576
+ */
577
+ value: string
578
+ /**
579
+ * If you want to keep the default filtering behavior, but only override it for a specific path, you can use `filterDefault` to do that.
580
+ * For example, here all "icon" documents in a Page Builder skips encoding:
581
+ * ```ts
582
+ {
583
+ filter: (props) => {
584
+ switch (props.sourceDocument._type) {
585
+ case 'icon':
586
+ return false
587
+ default:
588
+ return props.filterDefault(props)
589
+ }
590
+ }
591
+ }
592
+ * ```
593
+ */
594
+ filterDefault: FilterDefault
595
+ }) => boolean
596
+
597
+ /** @public */
598
+ export declare type FilteredResponseQueryOptions = ResponseQueryOptions & {
599
+ filterResponse?: true
600
+ }
601
+
602
+ /** @internal */
603
+ export declare type FirstDocumentIdMutationOptions = BaseMutationOptions & {
604
+ returnFirst?: true
605
+ returnDocuments: false
606
+ }
607
+
608
+ /** @internal */
609
+ export declare type FirstDocumentMutationOptions = BaseMutationOptions & {
610
+ returnFirst?: true
611
+ returnDocuments?: true
612
+ }
613
+
614
+ /** @public */
615
+ export declare type HttpRequest = {
616
+ defaultRequester: Requester
617
+ (options: RequestOptions, requester: Requester): ReturnType<Requester>
618
+ }
619
+
620
+ /** @public */
621
+ export declare type HttpRequestEvent<T = unknown> = ResponseEvent<T> | ProgressEvent_2
622
+
623
+ /** @public */
624
+ export declare type IdentifiedSanityDocumentStub<
625
+ T extends Record<string, Any> = Record<string, Any>,
626
+ > = {
627
+ [P in keyof T]: T[P]
628
+ } & {
629
+ _id: string
630
+ } & SanityDocumentStub
631
+
632
+ /** @public */
633
+ export declare interface InitializedClientConfig extends ClientConfig {
634
+ apiHost: string
635
+ apiVersion: string
636
+ useProjectHostname: boolean
637
+ useCdn: boolean
638
+ /**
639
+ * @deprecated Internal, don't use
640
+ */
641
+ isDefaultApi: boolean
642
+ /**
643
+ * @deprecated Internal, don't use
644
+ */
645
+ url: string
646
+ /**
647
+ * @deprecated Internal, don't use
648
+ */
649
+ cdnUrl: string
650
+ }
651
+
652
+ /** @public */
653
+ export declare interface InitializedClientStegaConfig extends InitializedClientConfig {
654
+ stega: InitializedStegaConfig
655
+ }
656
+
657
+ /** @public */
658
+ export declare type InitializedStegaConfig = Omit<StegaConfig, StegaConfigRequiredKeys> &
659
+ Required<Pick<StegaConfig, StegaConfigRequiredKeys>>
660
+
661
+ /** @internal */
662
+ export declare type InsertPatch =
663
+ | {
664
+ before: string
665
+ items: Any[]
666
+ }
667
+ | {
668
+ after: string
669
+ items: Any[]
670
+ }
671
+ | {
672
+ replace: string
673
+ items: Any[]
674
+ }
675
+
676
+ /** @public */
677
+ export declare type KeyedSegment = {
678
+ key: string
679
+ index: number
680
+ }
681
+
682
+ /**
683
+ * Set up a listener that will be notified when mutations occur on documents matching the provided query/filter.
684
+ *
685
+ * @param query - GROQ-filter to listen to changes for
686
+ * @param params - Optional query parameters
687
+ * @param options - Optional listener options
688
+ * @public
689
+ */
690
+ export declare function _listen<R extends Record<string, Any> = Record<string, Any>>(
691
+ this: SanityClient | ObservableSanityClient,
692
+ query: string,
693
+ params?: QueryParams,
694
+ ): Observable<MutationEvent_2<R>>
695
+
696
+ /**
697
+ * Set up a listener that will be notified when mutations occur on documents matching the provided query/filter.
698
+ *
699
+ * @param query - GROQ-filter to listen to changes for
700
+ * @param params - Optional query parameters
701
+ * @param options - Optional listener options
702
+ * @public
703
+ */
704
+ export declare function _listen<R extends Record<string, Any> = Record<string, Any>>(
705
+ this: SanityClient | ObservableSanityClient,
706
+ query: string,
707
+ params?: QueryParams,
708
+ options?: ListenOptions,
709
+ ): Observable<ListenEvent<R>>
710
+
711
+ /** @public */
712
+ export declare type ListenEvent<R extends Record<string, Any>> =
713
+ | MutationEvent_2<R>
714
+ | ChannelErrorEvent
715
+ | DisconnectEvent
716
+ | ReconnectEvent
717
+ | WelcomeEvent
718
+
719
+ /** @public */
720
+ export declare type ListenEventName =
721
+ /** A mutation was performed */
722
+ | 'mutation'
723
+ /** The listener has been (re)established */
724
+ | 'welcome'
725
+ /** The listener has been disconnected, and a reconnect attempt is scheduled */
726
+ | 'reconnect'
727
+
728
+ /** @public */
729
+ export declare interface ListenOptions {
730
+ /**
731
+ * Whether or not to include the resulting document in addition to the mutations performed.
732
+ * If you do not need the actual document, set this to `false` to reduce bandwidth usage.
733
+ * The result will be available on the `.result` property of the events.
734
+ * @defaultValue `true`
735
+ */
736
+ includeResult?: boolean
737
+ /**
738
+ * Whether or not to include the document as it looked before the mutation event.
739
+ * The previous revision will be available on the `.previous` property of the events,
740
+ * and may be `null` in the case of a new document.
741
+ * @defaultValue `false`
742
+ */
743
+ includePreviousRevision?: boolean
744
+ /**
745
+ * Whether events should be sent as soon as a transaction has been committed (`transaction`, default),
746
+ * or only after they are available for queries (query). Note that this is on a best-effort basis,
747
+ * and listeners with `query` may in certain cases (notably with deferred transactions) receive events
748
+ * that are not yet visible to queries.
749
+ *
750
+ * @defaultValue `'transaction'`
751
+ */
752
+ visibility?: 'transaction' | 'query'
753
+ /**
754
+ * Array of event names to include in the observable. By default, only mutation events are included.
755
+ *
756
+ * @defaultValue `['mutation']`
757
+ */
758
+ events?: ListenEventName[]
759
+ /**
760
+ * Format of "effects", eg the resulting changes of a mutation.
761
+ * Currently only `mendoza` is supported, and (if set) will include `apply` and `revert` arrays
762
+ * in the mutation events under the `effects` property.
763
+ *
764
+ * See {@link https://github.com/sanity-io/mendoza | The mendoza docs} for more info
765
+ *
766
+ * @defaultValue `undefined`
767
+ */
768
+ effectFormat?: 'mendoza'
769
+ /**
770
+ * Optional request tag for the listener. Use to identify the request in logs.
771
+ *
772
+ * @defaultValue `undefined`
773
+ */
774
+ tag?: string
775
+ }
776
+
777
+ /** @public */
778
+ export declare type Logger =
779
+ | typeof console
780
+ | Partial<
781
+ Pick<typeof console, 'debug' | 'error' | 'groupCollapsed' | 'groupEnd' | 'log' | 'table'>
782
+ >
783
+
784
+ /** @internal */
785
+ export declare interface MultipleMutationResult {
786
+ transactionId: string
787
+ documentIds: string[]
788
+ results: {
789
+ id: string
790
+ operation: MutationOperation
791
+ }[]
792
+ }
793
+
794
+ /** @public */
795
+ export declare type Mutation<R extends Record<string, Any> = Record<string, Any>> =
796
+ | {
797
+ create: SanityDocumentStub<R>
798
+ }
799
+ | {
800
+ createOrReplace: IdentifiedSanityDocumentStub<R>
801
+ }
802
+ | {
803
+ createIfNotExists: IdentifiedSanityDocumentStub<R>
804
+ }
805
+ | {
806
+ delete: MutationSelection
807
+ }
808
+ | {
809
+ patch: PatchMutationOperation
810
+ }
811
+
812
+ /** @internal */
813
+ export declare interface MutationError {
814
+ error: {
815
+ type: 'mutationError'
816
+ description: string
817
+ items?: MutationErrorItem[]
818
+ }
819
+ }
820
+
821
+ /** @internal */
822
+ export declare interface MutationErrorItem {
823
+ error: {
824
+ type: string
825
+ description: string
826
+ value?: unknown
827
+ }
828
+ }
829
+
830
+ /**
831
+ * A mutation was performed. Note that when updating multiple documents in a transaction,
832
+ * each document affected will get a separate mutation event.
833
+ *
834
+ * @public
835
+ */
836
+ declare type MutationEvent_2<R extends Record<string, Any> = Record<string, Any>> = {
837
+ type: 'mutation'
838
+ /**
839
+ * The ID of the document that was affected
840
+ */
841
+ documentId: string
842
+ /**
843
+ * A unique ID for this event
844
+ */
845
+ eventId: string
846
+ /**
847
+ * The user ID of the user that performed the mutation
848
+ */
849
+ identity: string
850
+ /**
851
+ * An array of mutations that were performed. Note that this can differ slightly from the
852
+ * mutations sent to the server, as the server may perform some mutations automatically.
853
+ */
854
+ mutations: Mutation[]
855
+ /**
856
+ * The revision ID of the document before the mutation was performed
857
+ */
858
+ previousRev?: string
859
+ /**
860
+ * The revision ID of the document after the mutation was performed
861
+ */
862
+ resultRev?: string
863
+ /**
864
+ * The document as it looked after the mutation was performed. This is only included if
865
+ * the listener was configured with `includeResult: true`.
866
+ */
867
+ result?: SanityDocument<R>
868
+ /**
869
+ * The document as it looked before the mutation was performed. This is only included if
870
+ * the listener was configured with `includePreviousRevision: true`.
871
+ */
872
+ previous?: SanityDocument<R> | null
873
+ /**
874
+ * The effects of the mutation, if the listener was configured with `effectFormat: 'mendoza'`.
875
+ * Object with `apply` and `revert` arrays, see {@link https://github.com/sanity-io/mendoza}.
876
+ */
877
+ effects?: {
878
+ apply: unknown[]
879
+ revert: unknown[]
880
+ }
881
+ /**
882
+ * A timestamp for when the mutation was performed
883
+ */
884
+ timestamp: string
885
+ /**
886
+ * The transaction ID for the mutation
887
+ */
888
+ transactionId: string
889
+ /**
890
+ * The type of transition the document went through.
891
+ *
892
+ * - `update` means the document was previously part of the subscribed set of documents,
893
+ * and still is.
894
+ * - `appear` means the document was not previously part of the subscribed set of documents,
895
+ * but is now. This can happen both on create or if updating to a state where it now matches
896
+ * the filter provided to the listener.
897
+ * - `disappear` means the document was previously part of the subscribed set of documents,
898
+ * but is no longer. This can happen both on delete or if updating to a state where it no
899
+ * longer matches the filter provided to the listener.
900
+ */
901
+ transition: 'update' | 'appear' | 'disappear'
902
+ /**
903
+ * Whether the change that triggered this event is visible to queries (query) or only to
904
+ * subsequent transactions (transaction). The listener client can specify a preferred visibility
905
+ * through the `visibility` parameter on the listener, but this is only on a best-effort basis,
906
+ * and may yet not be accurate.
907
+ */
908
+ visibility: 'query' | 'transaction'
909
+ /**
910
+ * The total number of events that will be sent for this transaction.
911
+ * Note that this may differ from the amount of _documents_ affected by the transaction, as this
912
+ * number only includes the documents that matches the given filter.
913
+ *
914
+ * This can be useful if you need to perform changes to all matched documents atomically,
915
+ * eg you would wait for `transactionTotalEvents` events with the same `transactionId` before
916
+ * applying the changes locally.
917
+ */
918
+ transactionTotalEvents: number
919
+ /**
920
+ * The index of this event within the transaction. Note that events may be delivered out of order,
921
+ * and that the index is zero-based.
922
+ */
923
+ transactionCurrentEvent: number
924
+ }
925
+ export {MutationEvent_2 as MutationEvent}
926
+
927
+ /** @internal */
928
+ export declare type MutationOperation = 'create' | 'delete' | 'update' | 'none'
929
+
930
+ /** @internal */
931
+ export declare type MutationSelection =
932
+ | {
933
+ query: string
934
+ params?: QueryParams
935
+ }
936
+ | {
937
+ id: string | string[]
938
+ }
939
+
940
+ /** @internal */
941
+ export declare class ObservableAssetsClient {
942
+ #private
943
+ constructor(client: ObservableSanityClient, httpRequest: HttpRequest)
944
+ /**
945
+ * Uploads a file asset to the configured dataset
946
+ *
947
+ * @param assetType - Asset type (file)
948
+ * @param body - Asset content - can be a browser File instance, a Blob, a Node.js Buffer instance or a Node.js ReadableStream.
949
+ * @param options - Options to use for the upload
950
+ */
951
+ upload(
952
+ assetType: 'file',
953
+ body: UploadBody,
954
+ options?: UploadClientConfig,
955
+ ): Observable<
956
+ HttpRequestEvent<{
957
+ document: SanityAssetDocument
958
+ }>
959
+ >
960
+ /**
961
+ * Uploads an image asset to the configured dataset
962
+ *
963
+ * @param assetType - Asset type (image)
964
+ * @param body - Asset content - can be a browser File instance, a Blob, a Node.js Buffer instance or a Node.js ReadableStream.
965
+ * @param options - Options to use for the upload
966
+ */
967
+ upload(
968
+ assetType: 'image',
969
+ body: UploadBody,
970
+ options?: UploadClientConfig,
971
+ ): Observable<
972
+ HttpRequestEvent<{
973
+ document: SanityImageAssetDocument
974
+ }>
975
+ >
976
+ /**
977
+ * Uploads a file or an image asset to the configured dataset
978
+ *
979
+ * @param assetType - Asset type (file/image)
980
+ * @param body - Asset content - can be a browser File instance, a Blob, a Node.js Buffer instance or a Node.js ReadableStream.
981
+ * @param options - Options to use for the upload
982
+ */
983
+ upload(
984
+ assetType: 'file' | 'image',
985
+ body: UploadBody,
986
+ options?: UploadClientConfig,
987
+ ): Observable<
988
+ HttpRequestEvent<{
989
+ document: SanityAssetDocument | SanityImageAssetDocument
990
+ }>
991
+ >
992
+ }
993
+
994
+ /** @internal */
995
+ export declare class ObservableDatasetsClient {
996
+ #private
997
+ constructor(client: ObservableSanityClient, httpRequest: HttpRequest)
998
+ /**
999
+ * Create a new dataset with the given name
1000
+ *
1001
+ * @param name - Name of the dataset to create
1002
+ * @param options - Options for the dataset
1003
+ */
1004
+ create(
1005
+ name: string,
1006
+ options?: {
1007
+ aclMode?: DatasetAclMode
1008
+ },
1009
+ ): Observable<DatasetResponse>
1010
+ /**
1011
+ * Edit a dataset with the given name
1012
+ *
1013
+ * @param name - Name of the dataset to edit
1014
+ * @param options - New options for the dataset
1015
+ */
1016
+ edit(
1017
+ name: string,
1018
+ options?: {
1019
+ aclMode?: DatasetAclMode
1020
+ },
1021
+ ): Observable<DatasetResponse>
1022
+ /**
1023
+ * Delete a dataset with the given name
1024
+ *
1025
+ * @param name - Name of the dataset to delete
1026
+ */
1027
+ delete(name: string): Observable<{
1028
+ deleted: true
1029
+ }>
1030
+ /**
1031
+ * Fetch a list of datasets for the configured project
1032
+ */
1033
+ list(): Observable<DatasetsResponse>
1034
+ }
1035
+
1036
+ /** @public */
1037
+ export declare class ObservablePatch extends BasePatch {
1038
+ #private
1039
+ constructor(
1040
+ selection: PatchSelection,
1041
+ operations?: PatchOperations,
1042
+ client?: ObservableSanityClient,
1043
+ )
1044
+ /**
1045
+ * Clones the patch
1046
+ */
1047
+ clone(): ObservablePatch
1048
+ /**
1049
+ * Commit the patch, returning an observable that produces the first patched document
1050
+ *
1051
+ * @param options - Options for the mutation operation
1052
+ */
1053
+ commit<R extends Record<string, Any> = Record<string, Any>>(
1054
+ options: FirstDocumentMutationOptions,
1055
+ ): Observable<SanityDocument<R>>
1056
+ /**
1057
+ * Commit the patch, returning an observable that produces an array of the mutated documents
1058
+ *
1059
+ * @param options - Options for the mutation operation
1060
+ */
1061
+ commit<R extends Record<string, Any> = Record<string, Any>>(
1062
+ options: AllDocumentsMutationOptions,
1063
+ ): Observable<SanityDocument<R>[]>
1064
+ /**
1065
+ * Commit the patch, returning an observable that produces a mutation result object
1066
+ *
1067
+ * @param options - Options for the mutation operation
1068
+ */
1069
+ commit(options: FirstDocumentIdMutationOptions): Observable<SingleMutationResult>
1070
+ /**
1071
+ * Commit the patch, returning an observable that produces a mutation result object
1072
+ *
1073
+ * @param options - Options for the mutation operation
1074
+ */
1075
+ commit(options: AllDocumentIdsMutationOptions): Observable<MultipleMutationResult>
1076
+ /**
1077
+ * Commit the patch, returning an observable that produces the first patched document
1078
+ *
1079
+ * @param options - Options for the mutation operation
1080
+ */
1081
+ commit<R extends Record<string, Any> = Record<string, Any>>(
1082
+ options?: BaseMutationOptions,
1083
+ ): Observable<SanityDocument<R>>
1084
+ }
1085
+
1086
+ /** @public */
1087
+ export declare type ObservablePatchBuilder = (patch: ObservablePatch) => ObservablePatch
1088
+
1089
+ /** @internal */
1090
+ export declare class ObservableProjectsClient {
1091
+ #private
1092
+ constructor(client: ObservableSanityClient, httpRequest: HttpRequest)
1093
+ /**
1094
+ * Fetch a list of projects the authenticated user has access to.
1095
+ *
1096
+ * @param options - Options for the list request
1097
+ * @param options.includeMembers - Whether to include members in the response (default: true)
1098
+ */
1099
+ list(options?: {includeMembers?: true}): Observable<SanityProject[]>
1100
+ list(options?: {includeMembers?: false}): Observable<Omit<SanityProject, 'members'>[]>
1101
+ /**
1102
+ * Fetch a project by project ID
1103
+ *
1104
+ * @param projectId - ID of the project to fetch
1105
+ */
1106
+ getById(projectId: string): Observable<SanityProject>
1107
+ }
1108
+
1109
+ /** @public */
1110
+ export declare class ObservableSanityClient {
1111
+ #private
1112
+ assets: ObservableAssetsClient
1113
+ datasets: ObservableDatasetsClient
1114
+ projects: ObservableProjectsClient
1115
+ users: ObservableUsersClient
1116
+ /**
1117
+ * Instance properties
1118
+ */
1119
+ listen: typeof _listen
1120
+ constructor(httpRequest: HttpRequest, config?: ClientConfig)
1121
+ /**
1122
+ * Clone the client - returns a new instance
1123
+ */
1124
+ clone(): ObservableSanityClient
1125
+ /**
1126
+ * Returns the current client configuration
1127
+ */
1128
+ config(): InitializedClientConfig
1129
+ /**
1130
+ * Reconfigure the client. Note that this _mutates_ the current client.
1131
+ */
1132
+ config(newConfig?: Partial<ClientConfig>): this
1133
+ /**
1134
+ * Clone the client with a new (partial) configuration.
1135
+ *
1136
+ * @param newConfig - New client configuration properties, shallowly merged with existing configuration
1137
+ */
1138
+ withConfig(newConfig?: Partial<ClientConfig>): ObservableSanityClient
1139
+ /**
1140
+ * Perform a GROQ-query against the configured dataset.
1141
+ *
1142
+ * @param query - GROQ-query to perform
1143
+ */
1144
+ fetch<R = Any>(query: string): Observable<R>
1145
+ /**
1146
+ * Perform a GROQ-query against the configured dataset.
1147
+ *
1148
+ * @param query - GROQ-query to perform
1149
+ * @param params - Query parameters
1150
+ */
1151
+ fetch<R = Any, Q = QueryParams>(query: string, params: Q): Observable<R>
1152
+ /**
1153
+ * Perform a GROQ-query against the configured dataset.
1154
+ *
1155
+ * @param query - GROQ-query to perform
1156
+ * @param params - Query parameters
1157
+ * @param options - Request options
1158
+ */
1159
+ fetch<R = Any, Q = QueryParams>(
1160
+ query: string,
1161
+ params: Q | undefined,
1162
+ options: FilteredResponseQueryOptions,
1163
+ ): Observable<R>
1164
+ /**
1165
+ * Perform a GROQ-query against the configured dataset.
1166
+ *
1167
+ * @param query - GROQ-query to perform
1168
+ * @param params - Query parameters
1169
+ * @param options - Request options
1170
+ */
1171
+ fetch<R = Any, Q = QueryParams>(
1172
+ query: string,
1173
+ params: Q | undefined,
1174
+ options: UnfilteredResponseQueryOptions,
1175
+ ): Observable<RawQueryResponse<R>>
1176
+ /**
1177
+ * Fetch a single document with the given ID.
1178
+ *
1179
+ * @param id - Document ID to fetch
1180
+ * @param options - Request options
1181
+ */
1182
+ getDocument<R extends Record<string, Any> = Record<string, Any>>(
1183
+ id: string,
1184
+ options?: {
1185
+ tag?: string
1186
+ },
1187
+ ): Observable<SanityDocument<R> | undefined>
1188
+ /**
1189
+ * Fetch multiple documents in one request.
1190
+ * Should be used sparingly - performing a query is usually a better option.
1191
+ * The order/position of documents is preserved based on the original array of IDs.
1192
+ * If any of the documents are missing, they will be replaced by a `null` entry in the returned array
1193
+ *
1194
+ * @param ids - Document IDs to fetch
1195
+ * @param options - Request options
1196
+ */
1197
+ getDocuments<R extends Record<string, Any> = Record<string, Any>>(
1198
+ ids: string[],
1199
+ options?: {
1200
+ tag?: string
1201
+ },
1202
+ ): Observable<(SanityDocument<R> | null)[]>
1203
+ /**
1204
+ * Create a document. Requires a `_type` property. If no `_id` is provided, it will be generated by the database.
1205
+ * Returns an observable that resolves to the created document.
1206
+ *
1207
+ * @param document - Document to create
1208
+ * @param options - Mutation options
1209
+ */
1210
+ create<R extends Record<string, Any> = Record<string, Any>>(
1211
+ document: SanityDocumentStub<R>,
1212
+ options: FirstDocumentMutationOptions,
1213
+ ): Observable<SanityDocument<R>>
1214
+ /**
1215
+ * Create a document. Requires a `_type` property. If no `_id` is provided, it will be generated by the database.
1216
+ * Returns an observable that resolves to an array containing the created document.
1217
+ *
1218
+ * @param document - Document to create
1219
+ * @param options - Mutation options
1220
+ */
1221
+ create<R extends Record<string, Any> = Record<string, Any>>(
1222
+ document: SanityDocumentStub<R>,
1223
+ options: AllDocumentsMutationOptions,
1224
+ ): Observable<SanityDocument<R>[]>
1225
+ /**
1226
+ * Create a document. Requires a `_type` property. If no `_id` is provided, it will be generated by the database.
1227
+ * Returns an observable that resolves to a mutation result object containing the ID of the created document.
1228
+ *
1229
+ * @param document - Document to create
1230
+ * @param options - Mutation options
1231
+ */
1232
+ create<R extends Record<string, Any> = Record<string, Any>>(
1233
+ document: SanityDocumentStub<R>,
1234
+ options: FirstDocumentIdMutationOptions,
1235
+ ): Observable<SingleMutationResult>
1236
+ /**
1237
+ * Create a document. Requires a `_type` property. If no `_id` is provided, it will be generated by the database.
1238
+ * Returns an observable that resolves to a mutation result object containing the ID of the created document.
1239
+ *
1240
+ * @param document - Document to create
1241
+ * @param options - Mutation options
1242
+ */
1243
+ create<R extends Record<string, Any> = Record<string, Any>>(
1244
+ document: SanityDocumentStub<R>,
1245
+ options: AllDocumentIdsMutationOptions,
1246
+ ): Observable<MultipleMutationResult>
1247
+ /**
1248
+ * Create a document. Requires a `_type` property. If no `_id` is provided, it will be generated by the database.
1249
+ * Returns an observable that resolves to the created document.
1250
+ *
1251
+ * @param document - Document to create
1252
+ * @param options - Mutation options
1253
+ */
1254
+ create<R extends Record<string, Any> = Record<string, Any>>(
1255
+ document: SanityDocumentStub<R>,
1256
+ options?: BaseMutationOptions,
1257
+ ): Observable<SanityDocument<R>>
1258
+ /**
1259
+ * Create a document if no document with the same ID already exists.
1260
+ * Returns an observable that resolves to the created document.
1261
+ *
1262
+ * @param document - Document to create
1263
+ * @param options - Mutation options
1264
+ */
1265
+ createIfNotExists<R extends Record<string, Any> = Record<string, Any>>(
1266
+ document: IdentifiedSanityDocumentStub<R>,
1267
+ options: FirstDocumentMutationOptions,
1268
+ ): Observable<SanityDocument<R>>
1269
+ /**
1270
+ * Create a document if no document with the same ID already exists.
1271
+ * Returns an observable that resolves to an array containing the created document.
1272
+ *
1273
+ * @param document - Document to create
1274
+ * @param options - Mutation options
1275
+ */
1276
+ createIfNotExists<R extends Record<string, Any> = Record<string, Any>>(
1277
+ document: IdentifiedSanityDocumentStub<R>,
1278
+ options: AllDocumentsMutationOptions,
1279
+ ): Observable<SanityDocument<R>[]>
1280
+ /**
1281
+ * Create a document if no document with the same ID already exists.
1282
+ * Returns an observable that resolves to a mutation result object containing the ID of the created document.
1283
+ *
1284
+ * @param document - Document to create
1285
+ * @param options - Mutation options
1286
+ */
1287
+ createIfNotExists<R extends Record<string, Any> = Record<string, Any>>(
1288
+ document: IdentifiedSanityDocumentStub<R>,
1289
+ options: FirstDocumentIdMutationOptions,
1290
+ ): Observable<SingleMutationResult>
1291
+ /**
1292
+ * Create a document if no document with the same ID already exists.
1293
+ * Returns an observable that resolves to a mutation result object containing the ID of the created document.
1294
+ *
1295
+ * @param document - Document to create
1296
+ * @param options - Mutation options
1297
+ */
1298
+ createIfNotExists<R extends Record<string, Any> = Record<string, Any>>(
1299
+ document: IdentifiedSanityDocumentStub<R>,
1300
+ options: AllDocumentIdsMutationOptions,
1301
+ ): Observable<MultipleMutationResult>
1302
+ /**
1303
+ * Create a document if no document with the same ID already exists.
1304
+ * Returns an observable that resolves to the created document.
1305
+ *
1306
+ * @param document - Document to create
1307
+ * @param options - Mutation options
1308
+ */
1309
+ createIfNotExists<R extends Record<string, Any> = Record<string, Any>>(
1310
+ document: IdentifiedSanityDocumentStub<R>,
1311
+ options?: BaseMutationOptions,
1312
+ ): Observable<SanityDocument<R>>
1313
+ /**
1314
+ * Create a document if it does not exist, or replace a document with the same document ID
1315
+ * Returns an observable that resolves to the created document.
1316
+ *
1317
+ * @param document - Document to either create or replace
1318
+ * @param options - Mutation options
1319
+ */
1320
+ createOrReplace<R extends Record<string, Any> = Record<string, Any>>(
1321
+ document: IdentifiedSanityDocumentStub<R>,
1322
+ options: FirstDocumentMutationOptions,
1323
+ ): Observable<SanityDocument<R>>
1324
+ /**
1325
+ * Create a document if it does not exist, or replace a document with the same document ID
1326
+ * Returns an observable that resolves to an array containing the created document.
1327
+ *
1328
+ * @param document - Document to either create or replace
1329
+ * @param options - Mutation options
1330
+ */
1331
+ createOrReplace<R extends Record<string, Any> = Record<string, Any>>(
1332
+ document: IdentifiedSanityDocumentStub<R>,
1333
+ options: AllDocumentsMutationOptions,
1334
+ ): Observable<SanityDocument<R>[]>
1335
+ /**
1336
+ * Create a document if it does not exist, or replace a document with the same document ID
1337
+ * Returns an observable that resolves to a mutation result object containing the ID of the created document.
1338
+ *
1339
+ * @param document - Document to either create or replace
1340
+ * @param options - Mutation options
1341
+ */
1342
+ createOrReplace<R extends Record<string, Any> = Record<string, Any>>(
1343
+ document: IdentifiedSanityDocumentStub<R>,
1344
+ options: FirstDocumentIdMutationOptions,
1345
+ ): Observable<SingleMutationResult>
1346
+ /**
1347
+ * Create a document if it does not exist, or replace a document with the same document ID
1348
+ * Returns an observable that resolves to a mutation result object containing the created document ID.
1349
+ *
1350
+ * @param document - Document to either create or replace
1351
+ * @param options - Mutation options
1352
+ */
1353
+ createOrReplace<R extends Record<string, Any> = Record<string, Any>>(
1354
+ document: IdentifiedSanityDocumentStub<R>,
1355
+ options: AllDocumentIdsMutationOptions,
1356
+ ): Observable<MultipleMutationResult>
1357
+ /**
1358
+ * Create a document if it does not exist, or replace a document with the same document ID
1359
+ * Returns an observable that resolves to the created document.
1360
+ *
1361
+ * @param document - Document to either create or replace
1362
+ * @param options - Mutation options
1363
+ */
1364
+ createOrReplace<R extends Record<string, Any> = Record<string, Any>>(
1365
+ document: IdentifiedSanityDocumentStub<R>,
1366
+ options?: BaseMutationOptions,
1367
+ ): Observable<SanityDocument<R>>
1368
+ /**
1369
+ * Deletes a document with the given document ID.
1370
+ * Returns an observable that resolves to the deleted document.
1371
+ *
1372
+ * @param id - Document ID to delete
1373
+ * @param options - Options for the mutation
1374
+ */
1375
+ delete<R extends Record<string, Any> = Record<string, Any>>(
1376
+ id: string,
1377
+ options: FirstDocumentMutationOptions,
1378
+ ): Observable<SanityDocument<R>>
1379
+ /**
1380
+ * Deletes a document with the given document ID.
1381
+ * Returns an observable that resolves to an array containing the deleted document.
1382
+ *
1383
+ * @param id - Document ID to delete
1384
+ * @param options - Options for the mutation
1385
+ */
1386
+ delete<R extends Record<string, Any> = Record<string, Any>>(
1387
+ id: string,
1388
+ options: AllDocumentsMutationOptions,
1389
+ ): Observable<SanityDocument<R>[]>
1390
+ /**
1391
+ * Deletes a document with the given document ID.
1392
+ * Returns an observable that resolves to a mutation result object containing the deleted document ID.
1393
+ *
1394
+ * @param id - Document ID to delete
1395
+ * @param options - Options for the mutation
1396
+ */
1397
+ delete(id: string, options: FirstDocumentIdMutationOptions): Observable<SingleMutationResult>
1398
+ /**
1399
+ * Deletes a document with the given document ID.
1400
+ * Returns an observable that resolves to a mutation result object containing the deleted document ID.
1401
+ *
1402
+ * @param id - Document ID to delete
1403
+ * @param options - Options for the mutation
1404
+ */
1405
+ delete(id: string, options: AllDocumentIdsMutationOptions): Observable<MultipleMutationResult>
1406
+ /**
1407
+ * Deletes a document with the given document ID.
1408
+ * Returns an observable that resolves to the deleted document.
1409
+ *
1410
+ * @param id - Document ID to delete
1411
+ * @param options - Options for the mutation
1412
+ */
1413
+ delete<R extends Record<string, Any> = Record<string, Any>>(
1414
+ id: string,
1415
+ options?: BaseMutationOptions,
1416
+ ): Observable<SanityDocument<R>>
1417
+ /**
1418
+ * Deletes one or more documents matching the given query or document ID.
1419
+ * Returns an observable that resolves to first deleted document.
1420
+ *
1421
+ * @param selection - An object with either an `id` or `query` key defining what to delete
1422
+ * @param options - Options for the mutation
1423
+ */
1424
+ delete<R extends Record<string, Any> = Record<string, Any>>(
1425
+ selection: MutationSelection,
1426
+ options: FirstDocumentMutationOptions,
1427
+ ): Observable<SanityDocument<R>>
1428
+ /**
1429
+ * Deletes one or more documents matching the given query or document ID.
1430
+ * Returns an observable that resolves to an array containing the deleted documents.
1431
+ *
1432
+ * @param selection - An object with either an `id` or `query` key defining what to delete
1433
+ * @param options - Options for the mutation
1434
+ */
1435
+ delete<R extends Record<string, Any> = Record<string, Any>>(
1436
+ selection: MutationSelection,
1437
+ options: AllDocumentsMutationOptions,
1438
+ ): Observable<SanityDocument<R>[]>
1439
+ /**
1440
+ * Deletes one or more documents matching the given query or document ID.
1441
+ * Returns an observable that resolves to a mutation result object containing the ID of the first deleted document.
1442
+ *
1443
+ * @param selection - An object with either an `id` or `query` key defining what to delete
1444
+ * @param options - Options for the mutation
1445
+ */
1446
+ delete(
1447
+ selection: MutationSelection,
1448
+ options: FirstDocumentIdMutationOptions,
1449
+ ): Observable<SingleMutationResult>
1450
+ /**
1451
+ * Deletes one or more documents matching the given query or document ID.
1452
+ * Returns an observable that resolves to a mutation result object containing the document IDs that were deleted.
1453
+ *
1454
+ * @param selection - An object with either an `id` or `query` key defining what to delete
1455
+ * @param options - Options for the mutation
1456
+ */
1457
+ delete(
1458
+ selection: MutationSelection,
1459
+ options: AllDocumentIdsMutationOptions,
1460
+ ): Observable<MultipleMutationResult>
1461
+ /**
1462
+ * Deletes one or more documents matching the given query or document ID.
1463
+ * Returns an observable that resolves to first deleted document.
1464
+ *
1465
+ * @param selection - An object with either an `id` or `query` key defining what to delete
1466
+ * @param options - Options for the mutation
1467
+ */
1468
+ delete<R extends Record<string, Any> = Record<string, Any>>(
1469
+ selection: MutationSelection,
1470
+ options?: BaseMutationOptions,
1471
+ ): Observable<SanityDocument<R>>
1472
+ /**
1473
+ * Perform mutation operations against the configured dataset
1474
+ * Returns an observable that resolves to the first mutated document.
1475
+ *
1476
+ * @param operations - Mutation operations to execute
1477
+ * @param options - Mutation options
1478
+ */
1479
+ mutate<R extends Record<string, Any> = Record<string, Any>>(
1480
+ operations: Mutation<R>[] | ObservablePatch | ObservableTransaction,
1481
+ options: FirstDocumentMutationOptions,
1482
+ ): Observable<SanityDocument<R>>
1483
+ /**
1484
+ * Perform mutation operations against the configured dataset.
1485
+ * Returns an observable that resolves to an array of the mutated documents.
1486
+ *
1487
+ * @param operations - Mutation operations to execute
1488
+ * @param options - Mutation options
1489
+ */
1490
+ mutate<R extends Record<string, Any> = Record<string, Any>>(
1491
+ operations: Mutation<R>[] | ObservablePatch | ObservableTransaction,
1492
+ options: AllDocumentsMutationOptions,
1493
+ ): Observable<SanityDocument<R>[]>
1494
+ /**
1495
+ * Perform mutation operations against the configured dataset
1496
+ * Returns an observable that resolves to a mutation result object containing the document ID of the first mutated document.
1497
+ *
1498
+ * @param operations - Mutation operations to execute
1499
+ * @param options - Mutation options
1500
+ */
1501
+ mutate<R extends Record<string, Any> = Record<string, Any>>(
1502
+ operations: Mutation<R>[] | ObservablePatch | ObservableTransaction,
1503
+ options: FirstDocumentIdMutationOptions,
1504
+ ): Observable<SingleMutationResult>
1505
+ /**
1506
+ * Perform mutation operations against the configured dataset
1507
+ * Returns an observable that resolves to a mutation result object containing the mutated document IDs.
1508
+ *
1509
+ * @param operations - Mutation operations to execute
1510
+ * @param options - Mutation options
1511
+ */
1512
+ mutate<R extends Record<string, Any> = Record<string, Any>>(
1513
+ operations: Mutation<R>[] | ObservablePatch | ObservableTransaction,
1514
+ options: AllDocumentIdsMutationOptions,
1515
+ ): Observable<MultipleMutationResult>
1516
+ /**
1517
+ * Perform mutation operations against the configured dataset
1518
+ * Returns an observable that resolves to the first mutated document.
1519
+ *
1520
+ * @param operations - Mutation operations to execute
1521
+ * @param options - Mutation options
1522
+ */
1523
+ mutate<R extends Record<string, Any> = Record<string, Any>>(
1524
+ operations: Mutation<R>[] | ObservablePatch | ObservableTransaction,
1525
+ options?: BaseMutationOptions,
1526
+ ): Observable<SanityDocument<R>>
1527
+ /**
1528
+ * Create a new buildable patch of operations to perform
1529
+ *
1530
+ * @param documentId - Document ID to patch
1531
+ * @param operations - Optional object of patch operations to initialize the patch instance with
1532
+ * @returns Patch instance - call `.commit()` to perform the operations defined
1533
+ */
1534
+ patch(documentId: string, operations?: PatchOperations): ObservablePatch
1535
+ /**
1536
+ * Create a new buildable patch of operations to perform
1537
+ *
1538
+ * @param documentIds - Array of document IDs to patch
1539
+ * @param operations - Optional object of patch operations to initialize the patch instance with
1540
+ * @returns Patch instance - call `.commit()` to perform the operations defined
1541
+ */
1542
+ patch(documentIds: string[], operations?: PatchOperations): ObservablePatch
1543
+ /**
1544
+ * Create a new buildable patch of operations to perform
1545
+ *
1546
+ * @param selection - An object with `query` and optional `params`, defining which document(s) to patch
1547
+ * @param operations - Optional object of patch operations to initialize the patch instance with
1548
+ * @returns Patch instance - call `.commit()` to perform the operations defined
1549
+ */
1550
+ patch(selection: MutationSelection, operations?: PatchOperations): ObservablePatch
1551
+ /**
1552
+ * Create a new transaction of mutations
1553
+ *
1554
+ * @param operations - Optional array of mutation operations to initialize the transaction instance with
1555
+ */
1556
+ transaction<R extends Record<string, Any> = Record<string, Any>>(
1557
+ operations?: Mutation<R>[],
1558
+ ): ObservableTransaction
1559
+ /**
1560
+ * Perform an HTTP request against the Sanity API
1561
+ *
1562
+ * @param options - Request options
1563
+ */
1564
+ request<R = Any>(options: RawRequestOptions): Observable<R>
1565
+ /**
1566
+ * Get a Sanity API URL for the URI provided
1567
+ *
1568
+ * @param uri - URI/path to build URL for
1569
+ * @param canUseCdn - Whether or not to allow using the API CDN for this route
1570
+ */
1571
+ getUrl(uri: string, canUseCdn?: boolean): string
1572
+ /**
1573
+ * Get a Sanity API URL for the data operation and path provided
1574
+ *
1575
+ * @param operation - Data operation (eg `query`, `mutate`, `listen` or similar)
1576
+ * @param path - Path to append after the operation
1577
+ */
1578
+ getDataUrl(operation: string, path?: string): string
1579
+ }
1580
+
1581
+ /** @public */
1582
+ export declare class ObservableSanityStegaClient extends ObservableSanityClient {
1583
+ #private
1584
+ private stegaConfig
1585
+ constructor(httpRequest: HttpRequest, config?: ClientStegaConfig)
1586
+ /**
1587
+ * Clone the client - returns a new instance
1588
+ */
1589
+ clone(): ObservableSanityStegaClient
1590
+ /**
1591
+ * Returns the current client configuration
1592
+ */
1593
+ config(): InitializedClientStegaConfig
1594
+ /**
1595
+ * Reconfigure the client. Note that this _mutates_ the current client.
1596
+ */
1597
+ config(newConfig?: Partial<ClientStegaConfig>): this
1598
+ /**
1599
+ * Clone the client with a new (partial) configuration.
1600
+ *
1601
+ * @param newConfig - New client configuration properties, shallowly merged with existing configuration
1602
+ */
1603
+ withConfig(newConfig?: Partial<ClientConfig>): ObservableSanityStegaClient
1604
+ /**
1605
+ * Perform a GROQ-query against the configured dataset.
1606
+ *
1607
+ * @param query - GROQ-query to perform
1608
+ */
1609
+ fetch<R = Any>(query: string): Observable<R>
1610
+ /**
1611
+ * Perform a GROQ-query against the configured dataset.
1612
+ *
1613
+ * @param query - GROQ-query to perform
1614
+ * @param params - Query parameters
1615
+ */
1616
+ fetch<R = Any, Q = QueryParams>(query: string, params: Q): Observable<R>
1617
+ /**
1618
+ * Perform a GROQ-query against the configured dataset.
1619
+ *
1620
+ * @param query - GROQ-query to perform
1621
+ * @param params - Query parameters
1622
+ * @param options - Request options
1623
+ */
1624
+ fetch<R = Any, Q = QueryParams>(
1625
+ query: string,
1626
+ params: Q | undefined,
1627
+ options: FilteredResponseQueryOptions,
1628
+ ): Observable<R>
1629
+ /**
1630
+ * Perform a GROQ-query against the configured dataset.
1631
+ *
1632
+ * @param query - GROQ-query to perform
1633
+ * @param params - Query parameters
1634
+ * @param options - Request options
1635
+ */
1636
+ fetch<R = Any, Q = QueryParams>(
1637
+ query: string,
1638
+ params: Q | undefined,
1639
+ options: UnfilteredResponseQueryOptions,
1640
+ ): Observable<RawQueryResponse<R>>
1641
+ }
1642
+
1643
+ /** @public */
1644
+ export declare class ObservableTransaction extends BaseTransaction {
1645
+ #private
1646
+ constructor(operations?: Mutation[], client?: ObservableSanityClient, transactionId?: string)
1647
+ /**
1648
+ * Clones the transaction
1649
+ */
1650
+ clone(): ObservableTransaction
1651
+ /**
1652
+ * Commit the transaction, returning an observable that produces the first mutated document
1653
+ *
1654
+ * @param options - Options for the mutation operation
1655
+ */
1656
+ commit<R extends Record<string, Any>>(
1657
+ options: TransactionFirstDocumentMutationOptions,
1658
+ ): Observable<SanityDocument<R>>
1659
+ /**
1660
+ * Commit the transaction, returning an observable that produces an array of the mutated documents
1661
+ *
1662
+ * @param options - Options for the mutation operation
1663
+ */
1664
+ commit<R extends Record<string, Any>>(
1665
+ options: TransactionAllDocumentsMutationOptions,
1666
+ ): Observable<SanityDocument<R>[]>
1667
+ /**
1668
+ * Commit the transaction, returning an observable that produces a mutation result object
1669
+ *
1670
+ * @param options - Options for the mutation operation
1671
+ */
1672
+ commit(options: TransactionFirstDocumentIdMutationOptions): Observable<SingleMutationResult>
1673
+ /**
1674
+ * Commit the transaction, returning an observable that produces a mutation result object
1675
+ *
1676
+ * @param options - Options for the mutation operation
1677
+ */
1678
+ commit(options: TransactionAllDocumentIdsMutationOptions): Observable<MultipleMutationResult>
1679
+ /**
1680
+ * Commit the transaction, returning an observable that produces a mutation result object
1681
+ *
1682
+ * @param options - Options for the mutation operation
1683
+ */
1684
+ commit(options?: BaseMutationOptions): Observable<MultipleMutationResult>
1685
+ /**
1686
+ * Performs a patch on the given document ID. Can either be a builder function or an object of patch operations.
1687
+ * The operation is added to the current transaction, ready to be commited by `commit()`
1688
+ *
1689
+ * @param documentId - Document ID to perform the patch operation on
1690
+ * @param patchOps - Operations to perform, or a builder function
1691
+ */
1692
+ patch(documentId: string, patchOps?: ObservablePatchBuilder | PatchOperations): this
1693
+ /**
1694
+ * Adds the given patch instance to the transaction.
1695
+ * The operation is added to the current transaction, ready to be commited by `commit()`
1696
+ *
1697
+ * @param patch - ObservablePatch to execute
1698
+ */
1699
+ patch(patch: ObservablePatch): this
1700
+ }
1701
+
1702
+ /** @public */
1703
+ export declare class ObservableUsersClient {
1704
+ #private
1705
+ constructor(client: ObservableSanityClient, httpRequest: HttpRequest)
1706
+ /**
1707
+ * Fetch a user by user ID
1708
+ *
1709
+ * @param id - User ID of the user to fetch. If `me` is provided, a minimal response including the users role is returned.
1710
+ */
1711
+ getById<T extends 'me' | string>(
1712
+ id: T,
1713
+ ): Observable<T extends 'me' ? CurrentSanityUser : SanityUser>
1714
+ }
1715
+
1716
+ /** @public */
1717
+ export declare class Patch extends BasePatch {
1718
+ #private
1719
+ constructor(selection: PatchSelection, operations?: PatchOperations, client?: SanityClient)
1720
+ /**
1721
+ * Clones the patch
1722
+ */
1723
+ clone(): Patch
1724
+ /**
1725
+ * Commit the patch, returning a promise that resolves to the first patched document
1726
+ *
1727
+ * @param options - Options for the mutation operation
1728
+ */
1729
+ commit<R extends Record<string, Any> = Record<string, Any>>(
1730
+ options: FirstDocumentMutationOptions,
1731
+ ): Promise<SanityDocument<R>>
1732
+ /**
1733
+ * Commit the patch, returning a promise that resolves to an array of the mutated documents
1734
+ *
1735
+ * @param options - Options for the mutation operation
1736
+ */
1737
+ commit<R extends Record<string, Any> = Record<string, Any>>(
1738
+ options: AllDocumentsMutationOptions,
1739
+ ): Promise<SanityDocument<R>[]>
1740
+ /**
1741
+ * Commit the patch, returning a promise that resolves to a mutation result object
1742
+ *
1743
+ * @param options - Options for the mutation operation
1744
+ */
1745
+ commit(options: FirstDocumentIdMutationOptions): Promise<SingleMutationResult>
1746
+ /**
1747
+ * Commit the patch, returning a promise that resolves to a mutation result object
1748
+ *
1749
+ * @param options - Options for the mutation operation
1750
+ */
1751
+ commit(options: AllDocumentIdsMutationOptions): Promise<MultipleMutationResult>
1752
+ /**
1753
+ * Commit the patch, returning a promise that resolves to the first patched document
1754
+ *
1755
+ * @param options - Options for the mutation operation
1756
+ */
1757
+ commit<R extends Record<string, Any> = Record<string, Any>>(
1758
+ options?: BaseMutationOptions,
1759
+ ): Promise<SanityDocument<R>>
1760
+ }
1761
+
1762
+ /** @public */
1763
+ export declare type PatchBuilder = (patch: Patch) => Patch
1764
+
1765
+ /** @internal */
1766
+ export declare type PatchMutationOperation = PatchOperations & MutationSelection
1767
+
1768
+ /** @internal */
1769
+ export declare interface PatchOperations {
1770
+ set?: {
1771
+ [key: string]: Any
1772
+ }
1773
+ setIfMissing?: {
1774
+ [key: string]: Any
1775
+ }
1776
+ diffMatchPatch?: {
1777
+ [key: string]: Any
1778
+ }
1779
+ unset?: string[]
1780
+ inc?: {
1781
+ [key: string]: number
1782
+ }
1783
+ dec?: {
1784
+ [key: string]: number
1785
+ }
1786
+ insert?: InsertPatch
1787
+ ifRevisionID?: string
1788
+ }
1789
+
1790
+ /** @internal */
1791
+ export declare type PatchSelection = string | string[] | MutationSelection
1792
+
1793
+ /** @public */
1794
+ export declare type Path = PathSegment[]
1795
+
1796
+ /** @public */
1797
+ export declare type PathSegment = string | number | KeyedSegment
1798
+
1799
+ /** @public */
1800
+ declare interface ProgressEvent_2 {
1801
+ type: 'progress'
1802
+ stage: 'upload' | 'download'
1803
+ percent: number
1804
+ total?: number
1805
+ loaded?: number
1806
+ lengthComputable: boolean
1807
+ }
1808
+ export {ProgressEvent_2 as ProgressEvent}
1809
+
1810
+ /** @internal */
1811
+ export declare class ProjectsClient {
1812
+ #private
1813
+ constructor(client: SanityClient, httpRequest: HttpRequest)
1814
+ /**
1815
+ * Fetch a list of projects the authenticated user has access to.
1816
+ *
1817
+ * @param options - Options for the list request
1818
+ * @param options.includeMembers - Whether to include members in the response (default: true)
1819
+ */
1820
+ list(options?: {includeMembers?: true}): Promise<SanityProject[]>
1821
+ list(options?: {includeMembers?: false}): Promise<Omit<SanityProject, 'members'>[]>
1822
+ /**
1823
+ * Fetch a project by project ID
1824
+ *
1825
+ * @param projectId - ID of the project to fetch
1826
+ */
1827
+ getById(projectId: string): Promise<SanityProject>
1828
+ }
1829
+
1830
+ /** @public */
1831
+ export declare type QueryParams = {
1832
+ [key: string]: Any
1833
+ }
1834
+
1835
+ /** @public */
1836
+ export declare interface RawQueryResponse<R> {
1837
+ query: string
1838
+ ms: number
1839
+ result: R
1840
+ resultSourceMap?: ContentSourceMap
1841
+ }
1842
+
1843
+ /** @internal */
1844
+ export declare interface RawRequestOptions {
1845
+ url?: string
1846
+ uri?: string
1847
+ method?: string
1848
+ token?: string
1849
+ json?: boolean
1850
+ tag?: string
1851
+ useGlobalApi?: boolean
1852
+ withCredentials?: boolean
1853
+ query?: {
1854
+ [key: string]: string | string[]
1855
+ }
1856
+ headers?: {
1857
+ [key: string]: string
1858
+ }
1859
+ timeout?: number
1860
+ proxy?: string
1861
+ body?: Any
1862
+ maxRedirects?: number
1863
+ }
1864
+
1865
+ /**
1866
+ * The listener has been disconnected, and a reconnect attempt is scheduled.
1867
+ *
1868
+ * @public
1869
+ */
1870
+ export declare type ReconnectEvent = {
1871
+ type: 'reconnect'
1872
+ }
1873
+
1874
+ /** @public */
1875
+ export declare const requester: Requester
1876
+
1877
+ /**
1878
+ * Options for the native `fetch` feature, used by the Next.js app-router
1879
+ * @public
1880
+ */
1881
+ export declare interface RequestFetchOptions<T = 'next'> {
1882
+ cache?: RequestInit['cache']
1883
+ next?: T extends keyof RequestInit ? RequestInit[T] : never
1884
+ }
1885
+
1886
+ /** @internal */
1887
+ export declare interface RequestObservableOptions extends Omit<RequestOptions, 'url'> {
1888
+ url?: string
1889
+ uri?: string
1890
+ canUseCdn?: boolean
1891
+ tag?: string
1892
+ resultSourceMap?: boolean
1893
+ perspective?: ClientPerspective
1894
+ }
1895
+
1896
+ /** @public */
1897
+ export declare interface RequestOptions {
1898
+ timeout?: number
1899
+ token?: string
1900
+ tag?: string
1901
+ headers?: Record<string, string>
1902
+ method?: string
1903
+ query?: Any
1904
+ body?: Any
1905
+ signal?: AbortSignal
1906
+ }
1907
+
1908
+ /** @public */
1909
+ export declare type ResolveStudioUrl = (
1910
+ sourceDocument: ContentSourceMapDocuments[number],
1911
+ sourcePath: Path,
1912
+ ) => StudioUrl
1913
+
1914
+ /** @public */
1915
+ export declare interface ResponseEvent<T = unknown> {
1916
+ type: 'response'
1917
+ body: T
1918
+ url: string
1919
+ method: string
1920
+ statusCode: number
1921
+ statusMessage?: string
1922
+ headers: Record<string, string>
1923
+ }
1924
+
1925
+ /** @public */
1926
+ export declare type ResponseQueryOptions<T = 'next'> = RequestOptions & {
1927
+ perspective?: ClientPerspective
1928
+ resultSourceMap?: boolean
1929
+ cache?: RequestInit['cache']
1930
+ next?: T extends keyof RequestInit ? RequestInit[T] : never
1931
+ }
1932
+
1933
+ /** @internal */
1934
+ export declare interface SanityAssetDocument extends SanityDocument {
1935
+ url: string
1936
+ path: string
1937
+ size: number
1938
+ assetId: string
1939
+ mimeType: string
1940
+ sha1hash: string
1941
+ extension: string
1942
+ uploadId?: string
1943
+ originalFilename?: string
1944
+ }
1945
+
1946
+ /** @public */
1947
+ export declare class SanityClient {
1948
+ #private
1949
+ assets: AssetsClient
1950
+ datasets: DatasetsClient
1951
+ projects: ProjectsClient
1952
+ users: UsersClient
1953
+ /**
1954
+ * Observable version of the Sanity client, with the same configuration as the promise-based one
1955
+ */
1956
+ observable: ObservableSanityClient
1957
+ /**
1958
+ * Instance properties
1959
+ */
1960
+ listen: typeof _listen
1961
+ constructor(httpRequest: HttpRequest, config?: ClientConfig)
1962
+ /**
1963
+ * Clone the client - returns a new instance
1964
+ */
1965
+ clone(): SanityClient
1966
+ /**
1967
+ * Returns the current client configuration
1968
+ */
1969
+ config(): InitializedClientConfig
1970
+ /**
1971
+ * Reconfigure the client. Note that this _mutates_ the current client.
1972
+ */
1973
+ config(newConfig?: Partial<ClientConfig>): this
1974
+ /**
1975
+ * Clone the client with a new (partial) configuration.
1976
+ *
1977
+ * @param newConfig - New client configuration properties, shallowly merged with existing configuration
1978
+ */
1979
+ withConfig(newConfig?: Partial<ClientConfig>): SanityClient
1980
+ /**
1981
+ * Perform a GROQ-query against the configured dataset.
1982
+ *
1983
+ * @param query - GROQ-query to perform
1984
+ */
1985
+ fetch<R = Any>(query: string): Promise<R>
1986
+ /**
1987
+ * Perform a GROQ-query against the configured dataset.
1988
+ *
1989
+ * @param query - GROQ-query to perform
1990
+ * @param params - Optional query parameters
1991
+ */
1992
+ fetch<R = Any, Q = QueryParams>(query: string, params: Q): Promise<R>
1993
+ /**
1994
+ * Perform a GROQ-query against the configured dataset.
1995
+ *
1996
+ * @param query - GROQ-query to perform
1997
+ * @param params - Optional query parameters
1998
+ * @param options - Request options
1999
+ */
2000
+ fetch<R = Any, Q = QueryParams>(
2001
+ query: string,
2002
+ params: Q | undefined,
2003
+ options: FilteredResponseQueryOptions,
2004
+ ): Promise<R>
2005
+ /**
2006
+ * Perform a GROQ-query against the configured dataset.
2007
+ *
2008
+ * @param query - GROQ-query to perform
2009
+ * @param params - Optional query parameters
2010
+ * @param options - Request options
2011
+ */
2012
+ fetch<R = Any, Q = QueryParams>(
2013
+ query: string,
2014
+ params: Q | undefined,
2015
+ options: UnfilteredResponseQueryOptions,
2016
+ ): Promise<RawQueryResponse<R>>
2017
+ /**
2018
+ * Fetch a single document with the given ID.
2019
+ *
2020
+ * @param id - Document ID to fetch
2021
+ * @param options - Request options
2022
+ */
2023
+ getDocument<R extends Record<string, Any> = Record<string, Any>>(
2024
+ id: string,
2025
+ options?: {
2026
+ tag?: string
2027
+ },
2028
+ ): Promise<SanityDocument<R> | undefined>
2029
+ /**
2030
+ * Fetch multiple documents in one request.
2031
+ * Should be used sparingly - performing a query is usually a better option.
2032
+ * The order/position of documents is preserved based on the original array of IDs.
2033
+ * If any of the documents are missing, they will be replaced by a `null` entry in the returned array
2034
+ *
2035
+ * @param ids - Document IDs to fetch
2036
+ * @param options - Request options
2037
+ */
2038
+ getDocuments<R extends Record<string, Any> = Record<string, Any>>(
2039
+ ids: string[],
2040
+ options?: {
2041
+ tag?: string
2042
+ },
2043
+ ): Promise<(SanityDocument<R> | null)[]>
2044
+ /**
2045
+ * Create a document. Requires a `_type` property. If no `_id` is provided, it will be generated by the database.
2046
+ * Returns a promise that resolves to the created document.
2047
+ *
2048
+ * @param document - Document to create
2049
+ * @param options - Mutation options
2050
+ */
2051
+ create<R extends Record<string, Any> = Record<string, Any>>(
2052
+ document: SanityDocumentStub<R>,
2053
+ options: FirstDocumentMutationOptions,
2054
+ ): Promise<SanityDocument<R>>
2055
+ /**
2056
+ * Create a document. Requires a `_type` property. If no `_id` is provided, it will be generated by the database.
2057
+ * Returns a promise that resolves to an array containing the created document.
2058
+ *
2059
+ * @param document - Document to create
2060
+ * @param options - Mutation options
2061
+ */
2062
+ create<R extends Record<string, Any> = Record<string, Any>>(
2063
+ document: SanityDocumentStub<R>,
2064
+ options: AllDocumentsMutationOptions,
2065
+ ): Promise<SanityDocument<R>[]>
2066
+ /**
2067
+ * Create a document. Requires a `_type` property. If no `_id` is provided, it will be generated by the database.
2068
+ * Returns a promise that resolves to a mutation result object containing the ID of the created document.
2069
+ *
2070
+ * @param document - Document to create
2071
+ * @param options - Mutation options
2072
+ */
2073
+ create<R extends Record<string, Any> = Record<string, Any>>(
2074
+ document: SanityDocumentStub<R>,
2075
+ options: FirstDocumentIdMutationOptions,
2076
+ ): Promise<SingleMutationResult>
2077
+ /**
2078
+ * Create a document. Requires a `_type` property. If no `_id` is provided, it will be generated by the database.
2079
+ * Returns a promise that resolves to a mutation result object containing the ID of the created document.
2080
+ *
2081
+ * @param document - Document to create
2082
+ * @param options - Mutation options
2083
+ */
2084
+ create<R extends Record<string, Any> = Record<string, Any>>(
2085
+ document: SanityDocumentStub<R>,
2086
+ options: AllDocumentIdsMutationOptions,
2087
+ ): Promise<MultipleMutationResult>
2088
+ /**
2089
+ * Create a document. Requires a `_type` property. If no `_id` is provided, it will be generated by the database.
2090
+ * Returns a promise that resolves to the created document.
2091
+ *
2092
+ * @param document - Document to create
2093
+ * @param options - Mutation options
2094
+ */
2095
+ create<R extends Record<string, Any> = Record<string, Any>>(
2096
+ document: SanityDocumentStub<R>,
2097
+ options?: BaseMutationOptions,
2098
+ ): Promise<SanityDocument<R>>
2099
+ /**
2100
+ * Create a document if no document with the same ID already exists.
2101
+ * Returns a promise that resolves to the created document.
2102
+ *
2103
+ * @param document - Document to create
2104
+ * @param options - Mutation options
2105
+ */
2106
+ createIfNotExists<R extends Record<string, Any> = Record<string, Any>>(
2107
+ document: IdentifiedSanityDocumentStub<R>,
2108
+ options: FirstDocumentMutationOptions,
2109
+ ): Promise<SanityDocument<R>>
2110
+ /**
2111
+ * Create a document if no document with the same ID already exists.
2112
+ * Returns a promise that resolves to an array containing the created document.
2113
+ *
2114
+ * @param document - Document to create
2115
+ * @param options - Mutation options
2116
+ */
2117
+ createIfNotExists<R extends Record<string, Any> = Record<string, Any>>(
2118
+ document: IdentifiedSanityDocumentStub<R>,
2119
+ options: AllDocumentsMutationOptions,
2120
+ ): Promise<SanityDocument<R>[]>
2121
+ /**
2122
+ * Create a document if no document with the same ID already exists.
2123
+ * Returns a promise that resolves to a mutation result object containing the ID of the created document.
2124
+ *
2125
+ * @param document - Document to create
2126
+ * @param options - Mutation options
2127
+ */
2128
+ createIfNotExists<R extends Record<string, Any> = Record<string, Any>>(
2129
+ document: IdentifiedSanityDocumentStub<R>,
2130
+ options: FirstDocumentIdMutationOptions,
2131
+ ): Promise<SingleMutationResult>
2132
+ /**
2133
+ * Create a document if no document with the same ID already exists.
2134
+ * Returns a promise that resolves to a mutation result object containing the ID of the created document.
2135
+ *
2136
+ * @param document - Document to create
2137
+ * @param options - Mutation options
2138
+ */
2139
+ createIfNotExists<R extends Record<string, Any> = Record<string, Any>>(
2140
+ document: IdentifiedSanityDocumentStub<R>,
2141
+ options: AllDocumentIdsMutationOptions,
2142
+ ): Promise<MultipleMutationResult>
2143
+ /**
2144
+ * Create a document if no document with the same ID already exists.
2145
+ * Returns a promise that resolves to the created document.
2146
+ *
2147
+ * @param document - Document to create
2148
+ * @param options - Mutation options
2149
+ */
2150
+ createIfNotExists<R extends Record<string, Any> = Record<string, Any>>(
2151
+ document: IdentifiedSanityDocumentStub<R>,
2152
+ options?: BaseMutationOptions,
2153
+ ): Promise<SanityDocument<R>>
2154
+ /**
2155
+ * Create a document if it does not exist, or replace a document with the same document ID
2156
+ * Returns a promise that resolves to the created document.
2157
+ *
2158
+ * @param document - Document to either create or replace
2159
+ * @param options - Mutation options
2160
+ */
2161
+ createOrReplace<R extends Record<string, Any> = Record<string, Any>>(
2162
+ document: IdentifiedSanityDocumentStub<R>,
2163
+ options: FirstDocumentMutationOptions,
2164
+ ): Promise<SanityDocument<R>>
2165
+ /**
2166
+ * Create a document if it does not exist, or replace a document with the same document ID
2167
+ * Returns a promise that resolves to an array containing the created document.
2168
+ *
2169
+ * @param document - Document to either create or replace
2170
+ * @param options - Mutation options
2171
+ */
2172
+ createOrReplace<R extends Record<string, Any> = Record<string, Any>>(
2173
+ document: IdentifiedSanityDocumentStub<R>,
2174
+ options: AllDocumentsMutationOptions,
2175
+ ): Promise<SanityDocument<R>[]>
2176
+ /**
2177
+ * Create a document if it does not exist, or replace a document with the same document ID
2178
+ * Returns a promise that resolves to a mutation result object containing the ID of the created document.
2179
+ *
2180
+ * @param document - Document to either create or replace
2181
+ * @param options - Mutation options
2182
+ */
2183
+ createOrReplace<R extends Record<string, Any> = Record<string, Any>>(
2184
+ document: IdentifiedSanityDocumentStub<R>,
2185
+ options: FirstDocumentIdMutationOptions,
2186
+ ): Promise<SingleMutationResult>
2187
+ /**
2188
+ * Create a document if it does not exist, or replace a document with the same document ID
2189
+ * Returns a promise that resolves to a mutation result object containing the created document ID.
2190
+ *
2191
+ * @param document - Document to either create or replace
2192
+ * @param options - Mutation options
2193
+ */
2194
+ createOrReplace<R extends Record<string, Any> = Record<string, Any>>(
2195
+ document: IdentifiedSanityDocumentStub<R>,
2196
+ options: AllDocumentIdsMutationOptions,
2197
+ ): Promise<MultipleMutationResult>
2198
+ /**
2199
+ * Create a document if it does not exist, or replace a document with the same document ID
2200
+ * Returns a promise that resolves to the created document.
2201
+ *
2202
+ * @param document - Document to either create or replace
2203
+ * @param options - Mutation options
2204
+ */
2205
+ createOrReplace<R extends Record<string, Any> = Record<string, Any>>(
2206
+ document: IdentifiedSanityDocumentStub<R>,
2207
+ options?: BaseMutationOptions,
2208
+ ): Promise<SanityDocument<R>>
2209
+ /**
2210
+ * Deletes a document with the given document ID.
2211
+ * Returns a promise that resolves to the deleted document.
2212
+ *
2213
+ * @param id - Document ID to delete
2214
+ * @param options - Options for the mutation
2215
+ */
2216
+ delete<R extends Record<string, Any> = Record<string, Any>>(
2217
+ id: string,
2218
+ options: FirstDocumentMutationOptions,
2219
+ ): Promise<SanityDocument<R>>
2220
+ /**
2221
+ * Deletes a document with the given document ID.
2222
+ * Returns a promise that resolves to an array containing the deleted document.
2223
+ *
2224
+ * @param id - Document ID to delete
2225
+ * @param options - Options for the mutation
2226
+ */
2227
+ delete<R extends Record<string, Any> = Record<string, Any>>(
2228
+ id: string,
2229
+ options: AllDocumentsMutationOptions,
2230
+ ): Promise<SanityDocument<R>[]>
2231
+ /**
2232
+ * Deletes a document with the given document ID.
2233
+ * Returns a promise that resolves to a mutation result object containing the deleted document ID.
2234
+ *
2235
+ * @param id - Document ID to delete
2236
+ * @param options - Options for the mutation
2237
+ */
2238
+ delete(id: string, options: FirstDocumentIdMutationOptions): Promise<SingleMutationResult>
2239
+ /**
2240
+ * Deletes a document with the given document ID.
2241
+ * Returns a promise that resolves to a mutation result object containing the deleted document ID.
2242
+ *
2243
+ * @param id - Document ID to delete
2244
+ * @param options - Options for the mutation
2245
+ */
2246
+ delete(id: string, options: AllDocumentIdsMutationOptions): Promise<MultipleMutationResult>
2247
+ /**
2248
+ * Deletes a document with the given document ID.
2249
+ * Returns a promise that resolves to the deleted document.
2250
+ *
2251
+ * @param id - Document ID to delete
2252
+ * @param options - Options for the mutation
2253
+ */
2254
+ delete<R extends Record<string, Any> = Record<string, Any>>(
2255
+ id: string,
2256
+ options?: BaseMutationOptions,
2257
+ ): Promise<SanityDocument<R>>
2258
+ /**
2259
+ * Deletes one or more documents matching the given query or document ID.
2260
+ * Returns a promise that resolves to first deleted document.
2261
+ *
2262
+ * @param selection - An object with either an `id` or `query` key defining what to delete
2263
+ * @param options - Options for the mutation
2264
+ */
2265
+ delete<R extends Record<string, Any> = Record<string, Any>>(
2266
+ selection: MutationSelection,
2267
+ options: FirstDocumentMutationOptions,
2268
+ ): Promise<SanityDocument<R>>
2269
+ /**
2270
+ * Deletes one or more documents matching the given query or document ID.
2271
+ * Returns a promise that resolves to an array containing the deleted documents.
2272
+ *
2273
+ * @param selection - An object with either an `id` or `query` key defining what to delete
2274
+ * @param options - Options for the mutation
2275
+ */
2276
+ delete<R extends Record<string, Any> = Record<string, Any>>(
2277
+ selection: MutationSelection,
2278
+ options: AllDocumentsMutationOptions,
2279
+ ): Promise<SanityDocument<R>[]>
2280
+ /**
2281
+ * Deletes one or more documents matching the given query or document ID.
2282
+ * Returns a promise that resolves to a mutation result object containing the ID of the first deleted document.
2283
+ *
2284
+ * @param selection - An object with either an `id` or `query` key defining what to delete
2285
+ * @param options - Options for the mutation
2286
+ */
2287
+ delete(
2288
+ selection: MutationSelection,
2289
+ options: FirstDocumentIdMutationOptions,
2290
+ ): Promise<SingleMutationResult>
2291
+ /**
2292
+ * Deletes one or more documents matching the given query or document ID.
2293
+ * Returns a promise that resolves to a mutation result object containing the document IDs that were deleted.
2294
+ *
2295
+ * @param selection - An object with either an `id` or `query` key defining what to delete
2296
+ * @param options - Options for the mutation
2297
+ */
2298
+ delete(
2299
+ selection: MutationSelection,
2300
+ options: AllDocumentIdsMutationOptions,
2301
+ ): Promise<MultipleMutationResult>
2302
+ /**
2303
+ * Deletes one or more documents matching the given query or document ID.
2304
+ * Returns a promise that resolves to first deleted document.
2305
+ *
2306
+ * @param selection - An object with either an `id` or `query` key defining what to delete
2307
+ * @param options - Options for the mutation
2308
+ */
2309
+ delete<R extends Record<string, Any> = Record<string, Any>>(
2310
+ selection: MutationSelection,
2311
+ options?: BaseMutationOptions,
2312
+ ): Promise<SanityDocument<R>>
2313
+ /**
2314
+ * Perform mutation operations against the configured dataset
2315
+ * Returns a promise that resolves to the first mutated document.
2316
+ *
2317
+ * @param operations - Mutation operations to execute
2318
+ * @param options - Mutation options
2319
+ */
2320
+ mutate<R extends Record<string, Any> = Record<string, Any>>(
2321
+ operations: Mutation<R>[] | Patch | Transaction,
2322
+ options: FirstDocumentMutationOptions,
2323
+ ): Promise<SanityDocument<R>>
2324
+ /**
2325
+ * Perform mutation operations against the configured dataset.
2326
+ * Returns a promise that resolves to an array of the mutated documents.
2327
+ *
2328
+ * @param operations - Mutation operations to execute
2329
+ * @param options - Mutation options
2330
+ */
2331
+ mutate<R extends Record<string, Any> = Record<string, Any>>(
2332
+ operations: Mutation<R>[] | Patch | Transaction,
2333
+ options: AllDocumentsMutationOptions,
2334
+ ): Promise<SanityDocument<R>[]>
2335
+ /**
2336
+ * Perform mutation operations against the configured dataset
2337
+ * Returns a promise that resolves to a mutation result object containing the document ID of the first mutated document.
2338
+ *
2339
+ * @param operations - Mutation operations to execute
2340
+ * @param options - Mutation options
2341
+ */
2342
+ mutate<R extends Record<string, Any> = Record<string, Any>>(
2343
+ operations: Mutation<R>[] | Patch | Transaction,
2344
+ options: FirstDocumentIdMutationOptions,
2345
+ ): Promise<SingleMutationResult>
2346
+ /**
2347
+ * Perform mutation operations against the configured dataset
2348
+ * Returns a promise that resolves to a mutation result object containing the mutated document IDs.
2349
+ *
2350
+ * @param operations - Mutation operations to execute
2351
+ * @param options - Mutation options
2352
+ */
2353
+ mutate<R extends Record<string, Any>>(
2354
+ operations: Mutation<R>[] | Patch | Transaction,
2355
+ options: AllDocumentIdsMutationOptions,
2356
+ ): Promise<MultipleMutationResult>
2357
+ /**
2358
+ * Perform mutation operations against the configured dataset
2359
+ * Returns a promise that resolves to the first mutated document.
2360
+ *
2361
+ * @param operations - Mutation operations to execute
2362
+ * @param options - Mutation options
2363
+ */
2364
+ mutate<R extends Record<string, Any> = Record<string, Any>>(
2365
+ operations: Mutation<R>[] | Patch | Transaction,
2366
+ options?: BaseMutationOptions,
2367
+ ): Promise<SanityDocument<R>>
2368
+ /**
2369
+ * Create a new buildable patch of operations to perform
2370
+ *
2371
+ * @param documentId - Document ID to patch
2372
+ * @param operations - Optional object of patch operations to initialize the patch instance with
2373
+ * @returns Patch instance - call `.commit()` to perform the operations defined
2374
+ */
2375
+ patch(documentId: string, operations?: PatchOperations): Patch
2376
+ /**
2377
+ * Create a new buildable patch of operations to perform
2378
+ *
2379
+ * @param documentIds - Array of document IDs to patch
2380
+ * @param operations - Optional object of patch operations to initialize the patch instance with
2381
+ * @returns Patch instance - call `.commit()` to perform the operations defined
2382
+ */
2383
+ patch(documentIds: string[], operations?: PatchOperations): Patch
2384
+ /**
2385
+ * Create a new buildable patch of operations to perform
2386
+ *
2387
+ * @param selection - An object with `query` and optional `params`, defining which document(s) to patch
2388
+ * @param operations - Optional object of patch operations to initialize the patch instance with
2389
+ * @returns Patch instance - call `.commit()` to perform the operations defined
2390
+ */
2391
+ patch(selection: MutationSelection, operations?: PatchOperations): Patch
2392
+ /**
2393
+ * Create a new transaction of mutations
2394
+ *
2395
+ * @param operations - Optional array of mutation operations to initialize the transaction instance with
2396
+ */
2397
+ transaction<R extends Record<string, Any> = Record<string, Any>>(
2398
+ operations?: Mutation<R>[],
2399
+ ): Transaction
2400
+ /**
2401
+ * Perform a request against the Sanity API
2402
+ * NOTE: Only use this for Sanity API endpoints, not for your own APIs!
2403
+ *
2404
+ * @param options - Request options
2405
+ * @returns Promise resolving to the response body
2406
+ */
2407
+ request<R = Any>(options: RawRequestOptions): Promise<R>
2408
+ /**
2409
+ * Perform an HTTP request a `/data` sub-endpoint
2410
+ * NOTE: Considered internal, thus marked as deprecated. Use `request` instead.
2411
+ *
2412
+ * @deprecated - Use `request()` or your own HTTP library instead
2413
+ * @param endpoint - Endpoint to hit (mutate, query etc)
2414
+ * @param body - Request body
2415
+ * @param options - Request options
2416
+ * @internal
2417
+ */
2418
+ dataRequest(endpoint: string, body: unknown, options?: BaseMutationOptions): Promise<Any>
2419
+ /**
2420
+ * Get a Sanity API URL for the URI provided
2421
+ *
2422
+ * @param uri - URI/path to build URL for
2423
+ * @param canUseCdn - Whether or not to allow using the API CDN for this route
2424
+ */
2425
+ getUrl(uri: string, canUseCdn?: boolean): string
2426
+ /**
2427
+ * Get a Sanity API URL for the data operation and path provided
2428
+ *
2429
+ * @param operation - Data operation (eg `query`, `mutate`, `listen` or similar)
2430
+ * @param path - Path to append after the operation
2431
+ */
2432
+ getDataUrl(operation: string, path?: string): string
2433
+ }
2434
+
2435
+ /** @internal */
2436
+ export declare type SanityDocument<T extends Record<string, Any> = Record<string, Any>> = {
2437
+ [P in keyof T]: T[P]
2438
+ } & {
2439
+ _id: string
2440
+ _rev: string
2441
+ _type: string
2442
+ _createdAt: string
2443
+ _updatedAt: string
2444
+ /**
2445
+ * Present when `perspective` is set to `previewDrafts`
2446
+ */
2447
+ _originalId?: string
2448
+ }
2449
+
2450
+ /** @public */
2451
+ export declare type SanityDocumentStub<T extends Record<string, Any> = Record<string, Any>> = {
2452
+ [P in keyof T]: T[P]
2453
+ } & {
2454
+ _type: string
2455
+ }
2456
+
2457
+ /** @internal */
2458
+ export declare interface SanityImageAssetDocument extends SanityAssetDocument {
2459
+ metadata: {
2460
+ _type: 'sanity.imageMetadata'
2461
+ hasAlpha: boolean
2462
+ isOpaque: boolean
2463
+ lqip?: string
2464
+ blurHash?: string
2465
+ dimensions: {
2466
+ _type: 'sanity.imageDimensions'
2467
+ aspectRatio: number
2468
+ height: number
2469
+ width: number
2470
+ }
2471
+ palette?: {
2472
+ _type: 'sanity.imagePalette'
2473
+ darkMuted?: SanityImagePalette
2474
+ darkVibrant?: SanityImagePalette
2475
+ dominant?: SanityImagePalette
2476
+ lightMuted?: SanityImagePalette
2477
+ lightVibrant?: SanityImagePalette
2478
+ muted?: SanityImagePalette
2479
+ vibrant?: SanityImagePalette
2480
+ }
2481
+ image?: {
2482
+ _type: 'sanity.imageExifTags'
2483
+ [key: string]: Any
2484
+ }
2485
+ exif?: {
2486
+ _type: 'sanity.imageExifMetadata'
2487
+ [key: string]: Any
2488
+ }
2489
+ }
2490
+ }
2491
+
2492
+ /** @internal */
2493
+ export declare interface SanityImagePalette {
2494
+ background: string
2495
+ foreground: string
2496
+ population: number
2497
+ title: string
2498
+ }
2499
+
2500
+ /** @internal */
2501
+ export declare interface SanityProject {
2502
+ id: string
2503
+ displayName: string
2504
+ studioHost: string | null
2505
+ organizationId: string | null
2506
+ isBlocked: boolean
2507
+ isDisabled: boolean
2508
+ isDisabledByUser: boolean
2509
+ createdAt: string
2510
+ pendingInvites?: number
2511
+ maxRetentionDays?: number
2512
+ members: SanityProjectMember[]
2513
+ metadata: {
2514
+ color?: string
2515
+ externalStudioHost?: string
2516
+ }
2517
+ }
2518
+
2519
+ /** @internal */
2520
+ export declare interface SanityProjectMember {
2521
+ id: string
2522
+ role: string
2523
+ isRobot: boolean
2524
+ isCurrentUser: boolean
2525
+ }
2526
+
2527
+ /** @internal */
2528
+ export declare interface SanityReference {
2529
+ _ref: string
2530
+ }
2531
+
2532
+ /** @public */
2533
+ export declare class SanityStegaClient extends SanityClient {
2534
+ #private
2535
+ /**
2536
+ * Observable version of the Sanity client, with the same configuration as the promise-based one
2537
+ */
2538
+ observable: ObservableSanityStegaClient
2539
+ private stegaConfig
2540
+ constructor(httpRequest: HttpRequest, config?: ClientStegaConfig)
2541
+ /**
2542
+ * Clone the client - returns a new instance
2543
+ */
2544
+ clone(): SanityStegaClient
2545
+ /**
2546
+ * Returns the current client configuration
2547
+ */
2548
+ config(): InitializedClientStegaConfig
2549
+ /**
2550
+ * Reconfigure the client. Note that this _mutates_ the current client.
2551
+ */
2552
+ config(newConfig?: Partial<ClientStegaConfig>): this
2553
+ /**
2554
+ * Clone the client with a new (partial) configuration.
2555
+ *
2556
+ * @param newConfig - New client configuration properties, shallowly merged with existing configuration
2557
+ */
2558
+ withConfig(newConfig?: Partial<ClientStegaConfig>): SanityStegaClient
2559
+ /**
2560
+ * Perform a GROQ-query against the configured dataset.
2561
+ *
2562
+ * @param query - GROQ-query to perform
2563
+ */
2564
+ fetch<R = Any>(query: string): Promise<R>
2565
+ /**
2566
+ * Perform a GROQ-query against the configured dataset.
2567
+ *
2568
+ * @param query - GROQ-query to perform
2569
+ * @param params - Optional query parameters
2570
+ */
2571
+ fetch<R = Any, Q = QueryParams>(query: string, params: Q): Promise<R>
2572
+ /**
2573
+ * Perform a GROQ-query against the configured dataset.
2574
+ *
2575
+ * @param query - GROQ-query to perform
2576
+ * @param params - Optional query parameters
2577
+ * @param options - Request options
2578
+ */
2579
+ fetch<R = Any, Q = QueryParams>(
2580
+ query: string,
2581
+ params: Q | undefined,
2582
+ options: FilteredResponseQueryOptions,
2583
+ ): Promise<R>
2584
+ /**
2585
+ * Perform a GROQ-query against the configured dataset.
2586
+ *
2587
+ * @param query - GROQ-query to perform
2588
+ * @param params - Optional query parameters
2589
+ * @param options - Request options
2590
+ */
2591
+ fetch<R = Any, Q = QueryParams>(
2592
+ query: string,
2593
+ params: Q | undefined,
2594
+ options: UnfilteredResponseQueryOptions,
2595
+ ): Promise<RawQueryResponse<R>>
2596
+ }
2597
+
2598
+ /** @internal */
2599
+ export declare interface SanityUser {
2600
+ id: string
2601
+ projectId: string
2602
+ displayName: string
2603
+ familyName: string | null
2604
+ givenName: string | null
2605
+ middleName: string | null
2606
+ imageUrl: string | null
2607
+ createdAt: string
2608
+ updatedAt: string
2609
+ isCurrentUser: boolean
2610
+ }
2611
+
2612
+ /** @public */
2613
+ export declare class ServerError extends Error {
2614
+ response: ErrorProps['response']
2615
+ statusCode: ErrorProps['statusCode']
2616
+ responseBody: ErrorProps['responseBody']
2617
+ details: ErrorProps['details']
2618
+ constructor(res: Any)
2619
+ }
2620
+
2621
+ /** @internal */
2622
+ export declare interface SingleMutationResult {
2623
+ transactionId: string
2624
+ documentId: string
2625
+ results: {
2626
+ id: string
2627
+ operation: MutationOperation
2628
+ }[]
2629
+ }
2630
+
2631
+ /** @public */
2632
+ export declare interface StegaConfig {
2633
+ /**
2634
+ * Enable or disable stega encoded strings in query results
2635
+ * ```ts
2636
+ {
2637
+ enabled: process.env.VERCEL_ENV !== 'production'
2638
+ }
2639
+ * ```
2640
+ * @defaultValue `false`
2641
+ */
2642
+ enabled?: boolean
2643
+ /**
2644
+ * Where the Studio is hosted.
2645
+ * If it's embedded in the app, use the base path for example `/studio`.
2646
+ * Otherwise provide the full URL to where the Studio is hosted, for example: `https://blog.sanity.studio`.
2647
+ *
2648
+ */
2649
+ studioUrl?: StudioUrl | ResolveStudioUrl
2650
+ filter?: FilterDefault
2651
+ /**
2652
+ * Specify a `console.log` compatible logger to see debug logs, which keys are encoded and which are not.
2653
+ */
2654
+ logger?: Logger
2655
+ /**
2656
+ * Override the `skip` parameter in `vercelStegaCombine`
2657
+ * @defaultValue `'auto'`
2658
+ */
2659
+ vercelStegaCombineSkip?: 'auto' | boolean
2660
+ }
2661
+
2662
+ /** @public */
2663
+ export declare type StegaConfigRequiredKeys = Extract<
2664
+ keyof StegaConfig,
2665
+ 'enabled' | 'filter' | 'vercelStegaCombineSkip'
2666
+ >
2667
+
2668
+ /**
2669
+ * Uses `@vercel/stega` to embed edit info JSON into strings in your query result.
2670
+ * The JSON payloads are added using invisible characters so they don't show up visually.
2671
+ * The edit info is generated from the Content Source Map (CSM) that is returned from Sanity for the query.
2672
+ * @public
2673
+ */
2674
+ export declare function stegaEncodeSourceMap<Result = unknown>(
2675
+ result: Result,
2676
+ resultSourceMap: ContentSourceMap | undefined,
2677
+ config: InitializedStegaConfig,
2678
+ ): Result
2679
+
2680
+ /** @public */
2681
+ export declare type StudioUrl =
2682
+ | `/${string}`
2683
+ | `${string}.sanity.studio`
2684
+ | `https://${string}`
2685
+ | string
2686
+
2687
+ /** @public */
2688
+ export declare class Transaction extends BaseTransaction {
2689
+ #private
2690
+ constructor(operations?: Mutation[], client?: SanityClient, transactionId?: string)
2691
+ /**
2692
+ * Clones the transaction
2693
+ */
2694
+ clone(): Transaction
2695
+ /**
2696
+ * Commit the transaction, returning a promise that resolves to the first mutated document
2697
+ *
2698
+ * @param options - Options for the mutation operation
2699
+ */
2700
+ commit<R extends Record<string, Any>>(
2701
+ options: TransactionFirstDocumentMutationOptions,
2702
+ ): Promise<SanityDocument<R>>
2703
+ /**
2704
+ * Commit the transaction, returning a promise that resolves to an array of the mutated documents
2705
+ *
2706
+ * @param options - Options for the mutation operation
2707
+ */
2708
+ commit<R extends Record<string, Any>>(
2709
+ options: TransactionAllDocumentsMutationOptions,
2710
+ ): Promise<SanityDocument<R>[]>
2711
+ /**
2712
+ * Commit the transaction, returning a promise that resolves to a mutation result object
2713
+ *
2714
+ * @param options - Options for the mutation operation
2715
+ */
2716
+ commit(options: TransactionFirstDocumentIdMutationOptions): Promise<SingleMutationResult>
2717
+ /**
2718
+ * Commit the transaction, returning a promise that resolves to a mutation result object
2719
+ *
2720
+ * @param options - Options for the mutation operation
2721
+ */
2722
+ commit(options: TransactionAllDocumentIdsMutationOptions): Promise<MultipleMutationResult>
2723
+ /**
2724
+ * Commit the transaction, returning a promise that resolves to a mutation result object
2725
+ *
2726
+ * @param options - Options for the mutation operation
2727
+ */
2728
+ commit(options?: BaseMutationOptions): Promise<MultipleMutationResult>
2729
+ /**
2730
+ * Performs a patch on the given document ID. Can either be a builder function or an object of patch operations.
2731
+ * The operation is added to the current transaction, ready to be commited by `commit()`
2732
+ *
2733
+ * @param documentId - Document ID to perform the patch operation on
2734
+ * @param patchOps - Operations to perform, or a builder function
2735
+ */
2736
+ patch(documentId: string, patchOps?: PatchBuilder | PatchOperations): this
2737
+ /**
2738
+ * Adds the given patch instance to the transaction.
2739
+ * The operation is added to the current transaction, ready to be commited by `commit()`
2740
+ *
2741
+ * @param patch - Patch to execute
2742
+ */
2743
+ patch(patch: Patch): this
2744
+ }
2745
+
2746
+ /** @internal */
2747
+ export declare type TransactionAllDocumentIdsMutationOptions = BaseMutationOptions & {
2748
+ returnFirst?: false
2749
+ returnDocuments?: false
2750
+ }
2751
+
2752
+ /** @internal */
2753
+ export declare type TransactionAllDocumentsMutationOptions = BaseMutationOptions & {
2754
+ returnFirst?: false
2755
+ returnDocuments: true
2756
+ }
2757
+
2758
+ /** @internal */
2759
+ export declare type TransactionFirstDocumentIdMutationOptions = BaseMutationOptions & {
2760
+ returnFirst: true
2761
+ returnDocuments?: false
2762
+ }
2763
+
2764
+ /** @internal */
2765
+ export declare type TransactionFirstDocumentMutationOptions = BaseMutationOptions & {
2766
+ returnFirst: true
2767
+ returnDocuments: true
2768
+ }
2769
+
2770
+ /** @internal */
2771
+ export declare type TransactionMutationOptions =
2772
+ | TransactionFirstDocumentMutationOptions
2773
+ | TransactionFirstDocumentIdMutationOptions
2774
+ | TransactionAllDocumentsMutationOptions
2775
+ | TransactionAllDocumentIdsMutationOptions
2776
+
2777
+ /** @public */
2778
+ export declare type UnfilteredResponseQueryOptions = ResponseQueryOptions & {
2779
+ filterResponse: false
2780
+ }
2781
+
2782
+ export {unstable__adapter}
2783
+
2784
+ export {unstable__environment}
2785
+
2786
+ /** @public */
2787
+ export declare type UploadBody = File | Blob | Buffer | NodeJS.ReadableStream
2788
+
2789
+ /** @public */
2790
+ export declare interface UploadClientConfig {
2791
+ /**
2792
+ * Optional request tag for the upload
2793
+ */
2794
+ tag?: string
2795
+ /**
2796
+ * Whether or not to preserve the original filename (default: true)
2797
+ */
2798
+ preserveFilename?: boolean
2799
+ /**
2800
+ * Filename for this file (optional)
2801
+ */
2802
+ filename?: string
2803
+ /**
2804
+ * Milliseconds to wait before timing the request out
2805
+ */
2806
+ timeout?: number
2807
+ /**
2808
+ * Mime type of the file
2809
+ */
2810
+ contentType?: string
2811
+ /**
2812
+ * Array of metadata parts to extract from asset
2813
+ */
2814
+ extract?: AssetMetadataType[]
2815
+ /**
2816
+ * Optional freeform label for the asset. Generally not used.
2817
+ */
2818
+ label?: string
2819
+ /**
2820
+ * Optional title for the asset
2821
+ */
2822
+ title?: string
2823
+ /**
2824
+ * Optional description for the asset
2825
+ */
2826
+ description?: string
2827
+ /**
2828
+ * The credit to person(s) and/or organization(s) required by the supplier of the asset to be used when published
2829
+ */
2830
+ creditLine?: string
2831
+ /**
2832
+ * Source data (when the asset is from an external service)
2833
+ */
2834
+ source?: {
2835
+ /**
2836
+ * The (u)id of the asset within the source, i.e. 'i-f323r1E'
2837
+ */
2838
+ id: string
2839
+ /**
2840
+ * The name of the source, i.e. 'unsplash'
2841
+ */
2842
+ name: string
2843
+ /**
2844
+ * A url to where to find the asset, or get more info about it in the source
2845
+ */
2846
+ url?: string
2847
+ }
2848
+ }
2849
+
2850
+ /** @public */
2851
+ export declare class UsersClient {
2852
+ #private
2853
+ constructor(client: SanityClient, httpRequest: HttpRequest)
2854
+ /**
2855
+ * Fetch a user by user ID
2856
+ *
2857
+ * @param id - User ID of the user to fetch. If `me` is provided, a minimal response including the users role is returned.
2858
+ */
2859
+ getById<T extends 'me' | string>(id: T): Promise<T extends 'me' ? CurrentSanityUser : SanityUser>
2860
+ }
2861
+
2862
+ /**
2863
+ * The listener has been established, and will start receiving events.
2864
+ * Note that this is also emitted upon _reconnection_.
2865
+ *
2866
+ * @public
2867
+ */
2868
+ export declare type WelcomeEvent = {
2869
+ type: 'welcome'
2870
+ }
2871
+
2872
+ export {}