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