@sanity/client 6.15.6 → 6.15.8

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