@sanity/client 6.15.6 → 6.15.7

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