@sanity/client 6.24.2 → 6.24.3

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