@sanity/client 5.0.0-esm.3 → 5.0.0-esm.4

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.
@@ -2,7 +2,7 @@ import {lastValueFrom, Observable} from 'rxjs'
2
2
 
3
3
  import {AssetsClient, ObservableAssetsClient} from './assets/AssetsClient'
4
4
  import {AuthClient, ObservableAuthClient} from './auth/AuthClient'
5
- import {initConfig} from './config'
5
+ import {defaultConfig, initConfig} from './config'
6
6
  import * as dataMethods from './data/dataMethods'
7
7
  import {_listen} from './data/listen'
8
8
  import {ObservablePatch, Patch} from './data/patch'
@@ -24,6 +24,7 @@ import type {
24
24
  Mutation,
25
25
  MutationSelection,
26
26
  PatchOperations,
27
+ PatchSelection,
27
28
  QueryParams,
28
29
  RawQueryResponse,
29
30
  RawRequestOptions,
@@ -48,6 +49,7 @@ export type {
48
49
  UsersClient,
49
50
  }
50
51
 
52
+ /** @public */
51
53
  export class ObservableSanityClient {
52
54
  assets: ObservableAssetsClient
53
55
  auth: ObservableAuthClient
@@ -61,7 +63,7 @@ export class ObservableSanityClient {
61
63
  #clientConfig: InitializedClientConfig
62
64
  #httpRequest: HttpRequest
63
65
 
64
- constructor(httpRequest: HttpRequest, config: ClientConfig) {
66
+ constructor(httpRequest: HttpRequest, config: ClientConfig = defaultConfig) {
65
67
  this.config(config)
66
68
 
67
69
  this.#httpRequest = httpRequest
@@ -106,7 +108,7 @@ export class ObservableSanityClient {
106
108
  /**
107
109
  * Clone the client with a new (partial) configuration.
108
110
  *
109
- * @param newConfig New client configuration properties, shallowly merged with existing configuration
111
+ * @param newConfig - New client configuration properties, shallowly merged with existing configuration
110
112
  */
111
113
  withConfig(newConfig?: Partial<ClientConfig>): ObservableSanityClient {
112
114
  return new ObservableSanityClient(this.#httpRequest, {...this.config(), ...newConfig})
@@ -115,22 +117,22 @@ export class ObservableSanityClient {
115
117
  /**
116
118
  * Perform a GROQ-query against the configured dataset.
117
119
  *
118
- * @param query GROQ-query to perform
120
+ * @param query - GROQ-query to perform
119
121
  */
120
122
  fetch<R = any>(query: string): Observable<R>
121
123
  /**
122
124
  * Perform a GROQ-query against the configured dataset.
123
125
  *
124
- * @param query GROQ-query to perform
125
- * @param params Query parameters
126
+ * @param query - GROQ-query to perform
127
+ * @param params - Query parameters
126
128
  */
127
129
  fetch<R = any>(query: string, params: QueryParams): Observable<R>
128
130
  /**
129
131
  * Perform a GROQ-query against the configured dataset.
130
132
  *
131
- * @param query GROQ-query to perform
132
- * @param params Query parameters
133
- * @param options Request options
133
+ * @param query - GROQ-query to perform
134
+ * @param params - Query parameters
135
+ * @param options - Request options
134
136
  */
135
137
  fetch<R = any>(
136
138
  query: string,
@@ -140,9 +142,9 @@ export class ObservableSanityClient {
140
142
  /**
141
143
  * Perform a GROQ-query against the configured dataset.
142
144
  *
143
- * @param query GROQ-query to perform
144
- * @param params Query parameters
145
- * @param options Request options
145
+ * @param query - GROQ-query to perform
146
+ * @param params - Query parameters
147
+ * @param options - Request options
146
148
  */
147
149
  fetch<R = any>(
148
150
  query: string,
@@ -160,8 +162,8 @@ export class ObservableSanityClient {
160
162
  /**
161
163
  * Fetch a single document with the given ID.
162
164
  *
163
- * @param id Document ID to fetch
164
- * @param options Request options
165
+ * @param id - Document ID to fetch
166
+ * @param options - Request options
165
167
  */
166
168
  getDocument<R extends Record<string, any> = Record<string, any>>(
167
169
  id: string,
@@ -176,8 +178,8 @@ export class ObservableSanityClient {
176
178
  * The order/position of documents is preserved based on the original array of IDs.
177
179
  * If a any of the documents are missing, they will be replaced by a `null` entry in the returned array
178
180
  *
179
- * @param ids Document IDs to fetch
180
- * @param options Request options
181
+ * @param ids - Document IDs to fetch
182
+ * @param options - Request options
181
183
  */
182
184
  getDocuments<R extends Record<string, any> = Record<string, any>>(
183
185
  ids: string[],
@@ -190,8 +192,8 @@ export class ObservableSanityClient {
190
192
  * Create a document. Requires a `_type` property. If no `_id` is provided, it will be generated by the database.
191
193
  * Returns an observable that resolves to the created document.
192
194
  *
193
- * @param document Document to create
194
- * @param options Mutation options
195
+ * @param document - Document to create
196
+ * @param options - Mutation options
195
197
  */
196
198
  create<R extends Record<string, any> = Record<string, any>>(
197
199
  document: SanityDocumentStub<R>,
@@ -201,8 +203,8 @@ export class ObservableSanityClient {
201
203
  * Create a document. Requires a `_type` property. If no `_id` is provided, it will be generated by the database.
202
204
  * Returns an observable that resolves to an array containing the created document.
203
205
  *
204
- * @param document Document to create
205
- * @param options Mutation options
206
+ * @param document - Document to create
207
+ * @param options - Mutation options
206
208
  */
207
209
  create<R extends Record<string, any> = Record<string, any>>(
208
210
  document: SanityDocumentStub<R>,
@@ -212,8 +214,8 @@ export class ObservableSanityClient {
212
214
  * Create a document. Requires a `_type` property. If no `_id` is provided, it will be generated by the database.
213
215
  * Returns an observable that resolves to a mutation result object containing the ID of the created document.
214
216
  *
215
- * @param document Document to create
216
- * @param options Mutation options
217
+ * @param document - Document to create
218
+ * @param options - Mutation options
217
219
  */
218
220
  create<R extends Record<string, any> = Record<string, any>>(
219
221
  document: SanityDocumentStub<R>,
@@ -223,8 +225,8 @@ export class ObservableSanityClient {
223
225
  * Create a document. Requires a `_type` property. If no `_id` is provided, it will be generated by the database.
224
226
  * Returns an observable that resolves to a mutation result object containing the ID of the created document.
225
227
  *
226
- * @param document Document to create
227
- * @param options Mutation options
228
+ * @param document - Document to create
229
+ * @param options - Mutation options
228
230
  */
229
231
  create<R extends Record<string, any> = Record<string, any>>(
230
232
  document: SanityDocumentStub<R>,
@@ -234,8 +236,8 @@ export class ObservableSanityClient {
234
236
  * Create a document. Requires a `_type` property. If no `_id` is provided, it will be generated by the database.
235
237
  * Returns an observable that resolves to the created document.
236
238
  *
237
- * @param document Document to create
238
- * @param options Mutation options
239
+ * @param document - Document to create
240
+ * @param options - Mutation options
239
241
  */
240
242
  create<R extends Record<string, any> = Record<string, any>>(
241
243
  document: SanityDocumentStub<R>,
@@ -259,8 +261,8 @@ export class ObservableSanityClient {
259
261
  * Create a document if no document with the same ID already exists.
260
262
  * Returns an observable that resolves to the created document.
261
263
  *
262
- * @param document Document to create
263
- * @param options Mutation options
264
+ * @param document - Document to create
265
+ * @param options - Mutation options
264
266
  */
265
267
  createIfNotExists<R extends Record<string, any> = Record<string, any>>(
266
268
  document: IdentifiedSanityDocumentStub<R>,
@@ -270,8 +272,8 @@ export class ObservableSanityClient {
270
272
  * Create a document if no document with the same ID already exists.
271
273
  * Returns an observable that resolves to an array containing the created document.
272
274
  *
273
- * @param document Document to create
274
- * @param options Mutation options
275
+ * @param document - Document to create
276
+ * @param options - Mutation options
275
277
  */
276
278
  createIfNotExists<R extends Record<string, any> = Record<string, any>>(
277
279
  document: IdentifiedSanityDocumentStub<R>,
@@ -281,8 +283,8 @@ export class ObservableSanityClient {
281
283
  * Create a document if no document with the same ID already exists.
282
284
  * Returns an observable that resolves to a mutation result object containing the ID of the created document.
283
285
  *
284
- * @param document Document to create
285
- * @param options Mutation options
286
+ * @param document - Document to create
287
+ * @param options - Mutation options
286
288
  */
287
289
  createIfNotExists<R extends Record<string, any> = Record<string, any>>(
288
290
  document: IdentifiedSanityDocumentStub<R>,
@@ -292,8 +294,8 @@ export class ObservableSanityClient {
292
294
  * Create a document if no document with the same ID already exists.
293
295
  * Returns an observable that resolves to a mutation result object containing the ID of the created document.
294
296
  *
295
- * @param document Document to create
296
- * @param options Mutation options
297
+ * @param document - Document to create
298
+ * @param options - Mutation options
297
299
  */
298
300
  createIfNotExists<R extends Record<string, any> = Record<string, any>>(
299
301
  document: IdentifiedSanityDocumentStub<R>,
@@ -303,8 +305,8 @@ export class ObservableSanityClient {
303
305
  * Create a document if no document with the same ID already exists.
304
306
  * Returns an observable that resolves to the created document.
305
307
  *
306
- * @param document Document to create
307
- * @param options Mutation options
308
+ * @param document - Document to create
309
+ * @param options - Mutation options
308
310
  */
309
311
  createIfNotExists<R extends Record<string, any> = Record<string, any>>(
310
312
  document: IdentifiedSanityDocumentStub<R>,
@@ -328,8 +330,8 @@ export class ObservableSanityClient {
328
330
  * Create a document if it does not exist, or replace a document with the same document ID
329
331
  * Returns an observable that resolves to the created document.
330
332
  *
331
- * @param document Document to either create or replace
332
- * @param options Mutation options
333
+ * @param document - Document to either create or replace
334
+ * @param options - Mutation options
333
335
  */
334
336
  createOrReplace<R extends Record<string, any> = Record<string, any>>(
335
337
  document: IdentifiedSanityDocumentStub<R>,
@@ -339,8 +341,8 @@ export class ObservableSanityClient {
339
341
  * Create a document if it does not exist, or replace a document with the same document ID
340
342
  * Returns an observable that resolves to an array containing the created document.
341
343
  *
342
- * @param document Document to either create or replace
343
- * @param options Mutation options
344
+ * @param document - Document to either create or replace
345
+ * @param options - Mutation options
344
346
  */
345
347
  createOrReplace<R extends Record<string, any> = Record<string, any>>(
346
348
  document: IdentifiedSanityDocumentStub<R>,
@@ -350,8 +352,8 @@ export class ObservableSanityClient {
350
352
  * Create a document if it does not exist, or replace a document with the same document ID
351
353
  * Returns an observable that resolves to a mutation result object containing the ID of the created document.
352
354
  *
353
- * @param document Document to either create or replace
354
- * @param options Mutation options
355
+ * @param document - Document to either create or replace
356
+ * @param options - Mutation options
355
357
  */
356
358
  createOrReplace<R extends Record<string, any> = Record<string, any>>(
357
359
  document: IdentifiedSanityDocumentStub<R>,
@@ -361,8 +363,8 @@ export class ObservableSanityClient {
361
363
  * Create a document if it does not exist, or replace a document with the same document ID
362
364
  * Returns an observable that resolves to a mutation result object containing the created document ID.
363
365
  *
364
- * @param document Document to either create or replace
365
- * @param options Mutation options
366
+ * @param document - Document to either create or replace
367
+ * @param options - Mutation options
366
368
  */
367
369
  createOrReplace<R extends Record<string, any> = Record<string, any>>(
368
370
  document: IdentifiedSanityDocumentStub<R>,
@@ -372,8 +374,8 @@ export class ObservableSanityClient {
372
374
  * Create a document if it does not exist, or replace a document with the same document ID
373
375
  * Returns an observable that resolves to the created document.
374
376
  *
375
- * @param document Document to either create or replace
376
- * @param options Mutation options
377
+ * @param document - Document to either create or replace
378
+ * @param options - Mutation options
377
379
  */
378
380
  createOrReplace<R extends Record<string, any> = Record<string, any>>(
379
381
  document: IdentifiedSanityDocumentStub<R>,
@@ -397,8 +399,8 @@ export class ObservableSanityClient {
397
399
  * Deletes a document with the given document ID.
398
400
  * Returns an observable that resolves to the deleted document.
399
401
  *
400
- * @param id Document ID to delete
401
- * @param options Options for the mutation
402
+ * @param id - Document ID to delete
403
+ * @param options - Options for the mutation
402
404
  */
403
405
  delete<R extends Record<string, any> = Record<string, any>>(
404
406
  id: string,
@@ -408,8 +410,8 @@ export class ObservableSanityClient {
408
410
  * Deletes a document with the given document ID.
409
411
  * Returns an observable that resolves to an array containing the deleted document.
410
412
  *
411
- * @param id Document ID to delete
412
- * @param options Options for the mutation
413
+ * @param id - Document ID to delete
414
+ * @param options - Options for the mutation
413
415
  */
414
416
  delete<R extends Record<string, any> = Record<string, any>>(
415
417
  id: string,
@@ -419,24 +421,24 @@ export class ObservableSanityClient {
419
421
  * Deletes a document with the given document ID.
420
422
  * Returns an observable that resolves to a mutation result object containing the deleted document ID.
421
423
  *
422
- * @param id Document ID to delete
423
- * @param options Options for the mutation
424
+ * @param id - Document ID to delete
425
+ * @param options - Options for the mutation
424
426
  */
425
427
  delete(id: string, options: FirstDocumentIdMutationOptions): Observable<SingleMutationResult>
426
428
  /**
427
429
  * Deletes a document with the given document ID.
428
430
  * Returns an observable that resolves to a mutation result object containing the deleted document ID.
429
431
  *
430
- * @param id Document ID to delete
431
- * @param options Options for the mutation
432
+ * @param id - Document ID to delete
433
+ * @param options - Options for the mutation
432
434
  */
433
435
  delete(id: string, options: AllDocumentIdsMutationOptions): Observable<MultipleMutationResult>
434
436
  /**
435
437
  * Deletes a document with the given document ID.
436
438
  * Returns an observable that resolves to the deleted document.
437
439
  *
438
- * @param id Document ID to delete
439
- * @param options Options for the mutation
440
+ * @param id - Document ID to delete
441
+ * @param options - Options for the mutation
440
442
  */
441
443
  delete<R extends Record<string, any> = Record<string, any>>(
442
444
  id: string,
@@ -446,8 +448,8 @@ export class ObservableSanityClient {
446
448
  * Deletes one or more documents matching the given query or document ID.
447
449
  * Returns an observable that resolves to first deleted document.
448
450
  *
449
- * @param selection An object with either an `id` or `query` key defining what to delete
450
- * @param options Options for the mutation
451
+ * @param selection - An object with either an `id` or `query` key defining what to delete
452
+ * @param options - Options for the mutation
451
453
  */
452
454
  delete<R extends Record<string, any> = Record<string, any>>(
453
455
  selection: MutationSelection,
@@ -457,8 +459,8 @@ export class ObservableSanityClient {
457
459
  * Deletes one or more documents matching the given query or document ID.
458
460
  * Returns an observable that resolves to an array containing the deleted documents.
459
461
  *
460
- * @param selection An object with either an `id` or `query` key defining what to delete
461
- * @param options Options for the mutation
462
+ * @param selection - An object with either an `id` or `query` key defining what to delete
463
+ * @param options - Options for the mutation
462
464
  */
463
465
  delete<R extends Record<string, any> = Record<string, any>>(
464
466
  selection: MutationSelection,
@@ -468,8 +470,8 @@ export class ObservableSanityClient {
468
470
  * Deletes one or more documents matching the given query or document ID.
469
471
  * Returns an observable that resolves to a mutation result object containing the ID of the first deleted document.
470
472
  *
471
- * @param selection An object with either an `id` or `query` key defining what to delete
472
- * @param options Options for the mutation
473
+ * @param selection - An object with either an `id` or `query` key defining what to delete
474
+ * @param options - Options for the mutation
473
475
  */
474
476
  delete(
475
477
  selection: MutationSelection,
@@ -479,8 +481,8 @@ export class ObservableSanityClient {
479
481
  * Deletes one or more documents matching the given query or document ID.
480
482
  * Returns an observable that resolves to a mutation result object containing the document IDs that were deleted.
481
483
  *
482
- * @param selection An object with either an `id` or `query` key defining what to delete
483
- * @param options Options for the mutation
484
+ * @param selection - An object with either an `id` or `query` key defining what to delete
485
+ * @param options - Options for the mutation
484
486
  */
485
487
  delete(
486
488
  selection: MutationSelection,
@@ -490,8 +492,8 @@ export class ObservableSanityClient {
490
492
  * Deletes one or more documents matching the given query or document ID.
491
493
  * Returns an observable that resolves to first deleted document.
492
494
  *
493
- * @param selection An object with either an `id` or `query` key defining what to delete
494
- * @param options Options for the mutation
495
+ * @param selection - An object with either an `id` or `query` key defining what to delete
496
+ * @param options - Options for the mutation
495
497
  */
496
498
  delete<R extends Record<string, any> = Record<string, any>>(
497
499
  selection: MutationSelection,
@@ -515,8 +517,8 @@ export class ObservableSanityClient {
515
517
  * Perform mutation operations against the configured dataset
516
518
  * Returns an observable that resolves to the first mutated document.
517
519
  *
518
- * @param operations Mutation operations to execute
519
- * @param options Mutation options
520
+ * @param operations - Mutation operations to execute
521
+ * @param options - Mutation options
520
522
  */
521
523
  mutate<R extends Record<string, any> = Record<string, any>>(
522
524
  operations: Mutation<R>[] | ObservablePatch | ObservableTransaction,
@@ -526,8 +528,8 @@ export class ObservableSanityClient {
526
528
  * Perform mutation operations against the configured dataset.
527
529
  * Returns an observable that resolves to an array of the mutated documents.
528
530
  *
529
- * @param operations Mutation operations to execute
530
- * @param options Mutation options
531
+ * @param operations - Mutation operations to execute
532
+ * @param options - Mutation options
531
533
  */
532
534
  mutate<R extends Record<string, any> = Record<string, any>>(
533
535
  operations: Mutation<R>[] | ObservablePatch | ObservableTransaction,
@@ -537,8 +539,8 @@ export class ObservableSanityClient {
537
539
  * Perform mutation operations against the configured dataset
538
540
  * Returns an observable that resolves to a mutation result object containing the document ID of the first mutated document.
539
541
  *
540
- * @param operations Mutation operations to execute
541
- * @param options Mutation options
542
+ * @param operations - Mutation operations to execute
543
+ * @param options - Mutation options
542
544
  */
543
545
  mutate<R extends Record<string, any> = Record<string, any>>(
544
546
  operations: Mutation<R>[] | ObservablePatch | ObservableTransaction,
@@ -548,8 +550,8 @@ export class ObservableSanityClient {
548
550
  * Perform mutation operations against the configured dataset
549
551
  * Returns an observable that resolves to a mutation result object containing the mutated document IDs.
550
552
  *
551
- * @param operations Mutation operations to execute
552
- * @param options Mutation options
553
+ * @param operations - Mutation operations to execute
554
+ * @param options - Mutation options
553
555
  */
554
556
  mutate<R extends Record<string, any> = Record<string, any>>(
555
557
  operations: Mutation<R>[] | ObservablePatch | ObservableTransaction,
@@ -559,8 +561,8 @@ export class ObservableSanityClient {
559
561
  * Perform mutation operations against the configured dataset
560
562
  * Returns an observable that resolves to the first mutated document.
561
563
  *
562
- * @param operations Mutation operations to execute
563
- * @param options Mutation options
564
+ * @param operations - Mutation operations to execute
565
+ * @param options - Mutation options
564
566
  */
565
567
  mutate<R extends Record<string, any> = Record<string, any>>(
566
568
  operations: Mutation<R>[] | ObservablePatch | ObservableTransaction,
@@ -583,17 +585,17 @@ export class ObservableSanityClient {
583
585
  /**
584
586
  * Create a new buildable patch of operations to perform
585
587
  *
586
- * @param documentId Document ID to patch
587
- * @param operations Optional object of patch operations to initialize the patch instance with
588
+ * @param documentId - Document ID(s) to patch
589
+ * @param operations - Optional object of patch operations to initialize the patch instance with
588
590
  */
589
- patch(documentId: string | MutationSelection, operations?: PatchOperations): ObservablePatch {
591
+ patch(documentId: PatchSelection, operations?: PatchOperations): ObservablePatch {
590
592
  return new ObservablePatch(documentId, operations, this)
591
593
  }
592
594
 
593
595
  /**
594
596
  * Create a new transaction of mutations
595
597
  *
596
- * @param operations Optional array of mutation operations to initialize the transaction instance with
598
+ * @param operations - Optional array of mutation operations to initialize the transaction instance with
597
599
  */
598
600
  transaction<R extends Record<string, any> = Record<string, any>>(
599
601
  operations?: Mutation<R>[]
@@ -605,13 +607,14 @@ export class ObservableSanityClient {
605
607
  * DEPRECATED: Perform an HTTP request against the Sanity API
606
608
  *
607
609
  * @deprecated Use your own request library!
608
- * @param options Request options
610
+ * @param options - Request options
609
611
  */
610
612
  request<R = any>(options: RawRequestOptions): Observable<R> {
611
613
  return dataMethods._request(this, this.#httpRequest, options)
612
614
  }
613
615
  }
614
616
 
617
+ /** @public */
615
618
  export class SanityClient {
616
619
  assets: AssetsClient
617
620
  auth: AuthClient
@@ -635,9 +638,7 @@ export class SanityClient {
635
638
  */
636
639
  listen = _listen
637
640
 
638
- constructor(httpRequest: HttpRequest, config: ClientConfig) {
639
- this.observable = new ObservableSanityClient(httpRequest, config)
640
-
641
+ constructor(httpRequest: HttpRequest, config: ClientConfig = defaultConfig) {
641
642
  this.config(config)
642
643
 
643
644
  this.#httpRequest = httpRequest
@@ -647,6 +648,8 @@ export class SanityClient {
647
648
  this.datasets = new DatasetsClient(this, this.#httpRequest)
648
649
  this.projects = new ProjectsClient(this, this.#httpRequest)
649
650
  this.users = new UsersClient(this, this.#httpRequest)
651
+
652
+ this.observable = new ObservableSanityClient(httpRequest, config)
650
653
  }
651
654
 
652
655
  /**
@@ -675,7 +678,9 @@ export class SanityClient {
675
678
  )
676
679
  }
677
680
 
678
- this.observable.config(newConfig)
681
+ if (this.observable) {
682
+ this.observable.config(newConfig)
683
+ }
679
684
 
680
685
  this.#clientConfig = initConfig(newConfig, this.#clientConfig || {})
681
686
  return this
@@ -684,7 +689,7 @@ export class SanityClient {
684
689
  /**
685
690
  * Clone the client with a new (partial) configuration.
686
691
  *
687
- * @param newConfig New client configuration properties, shallowly merged with existing configuration
692
+ * @param newConfig - New client configuration properties, shallowly merged with existing configuration
688
693
  */
689
694
  withConfig(newConfig?: Partial<ClientConfig>): SanityClient {
690
695
  return new SanityClient(this.#httpRequest, {...this.config(), ...newConfig})
@@ -693,22 +698,22 @@ export class SanityClient {
693
698
  /**
694
699
  * Perform a GROQ-query against the configured dataset.
695
700
  *
696
- * @param query GROQ-query to perform
701
+ * @param query - GROQ-query to perform
697
702
  */
698
703
  fetch<R = any>(query: string): Promise<R>
699
704
  /**
700
705
  * Perform a GROQ-query against the configured dataset.
701
706
  *
702
- * @param query GROQ-query to perform
703
- * @param params Optional query parameters
707
+ * @param query - GROQ-query to perform
708
+ * @param params - Optional query parameters
704
709
  */
705
710
  fetch<R = any>(query: string, params: QueryParams): Promise<R>
706
711
  /**
707
712
  * Perform a GROQ-query against the configured dataset.
708
713
  *
709
- * @param query GROQ-query to perform
710
- * @param params Optional query parameters
711
- * @param options Request options
714
+ * @param query - GROQ-query to perform
715
+ * @param params - Optional query parameters
716
+ * @param options - Request options
712
717
  */
713
718
  fetch<R = any>(
714
719
  query: string,
@@ -718,9 +723,9 @@ export class SanityClient {
718
723
  /**
719
724
  * Perform a GROQ-query against the configured dataset.
720
725
  *
721
- * @param query GROQ-query to perform
722
- * @param params Optional query parameters
723
- * @param options Request options
726
+ * @param query - GROQ-query to perform
727
+ * @param params - Optional query parameters
728
+ * @param options - Request options
724
729
  */
725
730
  fetch<R = any>(
726
731
  query: string,
@@ -738,8 +743,8 @@ export class SanityClient {
738
743
  /**
739
744
  * Fetch a single document with the given ID.
740
745
  *
741
- * @param id Document ID to fetch
742
- * @param options Request options
746
+ * @param id - Document ID to fetch
747
+ * @param options - Request options
743
748
  */
744
749
  getDocument<R extends Record<string, any> = Record<string, any>>(
745
750
  id: string,
@@ -754,8 +759,8 @@ export class SanityClient {
754
759
  * The order/position of documents is preserved based on the original array of IDs.
755
760
  * If a any of the documents are missing, they will be replaced by a `null` entry in the returned array
756
761
  *
757
- * @param ids Document IDs to fetch
758
- * @param options Request options
762
+ * @param ids - Document IDs to fetch
763
+ * @param options - Request options
759
764
  */
760
765
  getDocuments<R extends Record<string, any> = Record<string, any>>(
761
766
  ids: string[],
@@ -768,8 +773,8 @@ export class SanityClient {
768
773
  * Create a document. Requires a `_type` property. If no `_id` is provided, it will be generated by the database.
769
774
  * Returns a promise that resolves to the created document.
770
775
  *
771
- * @param document Document to create
772
- * @param options Mutation options
776
+ * @param document - Document to create
777
+ * @param options - Mutation options
773
778
  */
774
779
  create<R extends Record<string, any> = Record<string, any>>(
775
780
  document: SanityDocumentStub<R>,
@@ -779,8 +784,8 @@ export class SanityClient {
779
784
  * Create a document. Requires a `_type` property. If no `_id` is provided, it will be generated by the database.
780
785
  * Returns a promise that resolves to an array containing the created document.
781
786
  *
782
- * @param document Document to create
783
- * @param options Mutation options
787
+ * @param document - Document to create
788
+ * @param options - Mutation options
784
789
  */
785
790
  create<R extends Record<string, any> = Record<string, any>>(
786
791
  document: SanityDocumentStub<R>,
@@ -790,8 +795,8 @@ export class SanityClient {
790
795
  * Create a document. Requires a `_type` property. If no `_id` is provided, it will be generated by the database.
791
796
  * Returns a promise that resolves to a mutation result object containing the ID of the created document.
792
797
  *
793
- * @param document Document to create
794
- * @param options Mutation options
798
+ * @param document - Document to create
799
+ * @param options - Mutation options
795
800
  */
796
801
  create<R extends Record<string, any> = Record<string, any>>(
797
802
  document: SanityDocumentStub<R>,
@@ -801,8 +806,8 @@ export class SanityClient {
801
806
  * Create a document. Requires a `_type` property. If no `_id` is provided, it will be generated by the database.
802
807
  * Returns a promise that resolves to a mutation result object containing the ID of the created document.
803
808
  *
804
- * @param document Document to create
805
- * @param options Mutation options
809
+ * @param document - Document to create
810
+ * @param options - Mutation options
806
811
  */
807
812
  create<R extends Record<string, any> = Record<string, any>>(
808
813
  document: SanityDocumentStub<R>,
@@ -812,8 +817,8 @@ export class SanityClient {
812
817
  * Create a document. Requires a `_type` property. If no `_id` is provided, it will be generated by the database.
813
818
  * Returns a promise that resolves to the created document.
814
819
  *
815
- * @param document Document to create
816
- * @param options Mutation options
820
+ * @param document - Document to create
821
+ * @param options - Mutation options
817
822
  */
818
823
  create<R extends Record<string, any> = Record<string, any>>(
819
824
  document: SanityDocumentStub<R>,
@@ -839,8 +844,8 @@ export class SanityClient {
839
844
  * Create a document if no document with the same ID already exists.
840
845
  * Returns a promise that resolves to the created document.
841
846
  *
842
- * @param document Document to create
843
- * @param options Mutation options
847
+ * @param document - Document to create
848
+ * @param options - Mutation options
844
849
  */
845
850
  createIfNotExists<R extends Record<string, any> = Record<string, any>>(
846
851
  document: IdentifiedSanityDocumentStub<R>,
@@ -850,8 +855,8 @@ export class SanityClient {
850
855
  * Create a document if no document with the same ID already exists.
851
856
  * Returns a promise that resolves to an array containing the created document.
852
857
  *
853
- * @param document Document to create
854
- * @param options Mutation options
858
+ * @param document - Document to create
859
+ * @param options - Mutation options
855
860
  */
856
861
  createIfNotExists<R extends Record<string, any> = Record<string, any>>(
857
862
  document: IdentifiedSanityDocumentStub<R>,
@@ -861,8 +866,8 @@ export class SanityClient {
861
866
  * Create a document if no document with the same ID already exists.
862
867
  * Returns a promise that resolves to a mutation result object containing the ID of the created document.
863
868
  *
864
- * @param document Document to create
865
- * @param options Mutation options
869
+ * @param document - Document to create
870
+ * @param options - Mutation options
866
871
  */
867
872
  createIfNotExists<R extends Record<string, any> = Record<string, any>>(
868
873
  document: IdentifiedSanityDocumentStub<R>,
@@ -872,8 +877,8 @@ export class SanityClient {
872
877
  * Create a document if no document with the same ID already exists.
873
878
  * Returns a promise that resolves to a mutation result object containing the ID of the created document.
874
879
  *
875
- * @param document Document to create
876
- * @param options Mutation options
880
+ * @param document - Document to create
881
+ * @param options - Mutation options
877
882
  */
878
883
  createIfNotExists<R extends Record<string, any> = Record<string, any>>(
879
884
  document: IdentifiedSanityDocumentStub<R>,
@@ -883,8 +888,8 @@ export class SanityClient {
883
888
  * Create a document if no document with the same ID already exists.
884
889
  * Returns a promise that resolves to the created document.
885
890
  *
886
- * @param document Document to create
887
- * @param options Mutation options
891
+ * @param document - Document to create
892
+ * @param options - Mutation options
888
893
  */
889
894
  createIfNotExists<R extends Record<string, any> = Record<string, any>>(
890
895
  document: IdentifiedSanityDocumentStub<R>,
@@ -910,8 +915,8 @@ export class SanityClient {
910
915
  * Create a document if it does not exist, or replace a document with the same document ID
911
916
  * Returns a promise that resolves to the created document.
912
917
  *
913
- * @param document Document to either create or replace
914
- * @param options Mutation options
918
+ * @param document - Document to either create or replace
919
+ * @param options - Mutation options
915
920
  */
916
921
  createOrReplace<R extends Record<string, any> = Record<string, any>>(
917
922
  document: IdentifiedSanityDocumentStub<R>,
@@ -921,8 +926,8 @@ export class SanityClient {
921
926
  * Create a document if it does not exist, or replace a document with the same document ID
922
927
  * Returns a promise that resolves to an array containing the created document.
923
928
  *
924
- * @param document Document to either create or replace
925
- * @param options Mutation options
929
+ * @param document - Document to either create or replace
930
+ * @param options - Mutation options
926
931
  */
927
932
  createOrReplace<R extends Record<string, any> = Record<string, any>>(
928
933
  document: IdentifiedSanityDocumentStub<R>,
@@ -932,8 +937,8 @@ export class SanityClient {
932
937
  * Create a document if it does not exist, or replace a document with the same document ID
933
938
  * Returns a promise that resolves to a mutation result object containing the ID of the created document.
934
939
  *
935
- * @param document Document to either create or replace
936
- * @param options Mutation options
940
+ * @param document - Document to either create or replace
941
+ * @param options - Mutation options
937
942
  */
938
943
  createOrReplace<R extends Record<string, any> = Record<string, any>>(
939
944
  document: IdentifiedSanityDocumentStub<R>,
@@ -943,8 +948,8 @@ export class SanityClient {
943
948
  * Create a document if it does not exist, or replace a document with the same document ID
944
949
  * Returns a promise that resolves to a mutation result object containing the created document ID.
945
950
  *
946
- * @param document Document to either create or replace
947
- * @param options Mutation options
951
+ * @param document - Document to either create or replace
952
+ * @param options - Mutation options
948
953
  */
949
954
  createOrReplace<R extends Record<string, any> = Record<string, any>>(
950
955
  document: IdentifiedSanityDocumentStub<R>,
@@ -954,8 +959,8 @@ export class SanityClient {
954
959
  * Create a document if it does not exist, or replace a document with the same document ID
955
960
  * Returns a promise that resolves to the created document.
956
961
  *
957
- * @param document Document to either create or replace
958
- * @param options Mutation options
962
+ * @param document - Document to either create or replace
963
+ * @param options - Mutation options
959
964
  */
960
965
  createOrReplace<R extends Record<string, any> = Record<string, any>>(
961
966
  document: IdentifiedSanityDocumentStub<R>,
@@ -981,8 +986,8 @@ export class SanityClient {
981
986
  * Deletes a document with the given document ID.
982
987
  * Returns a promise that resolves to the deleted document.
983
988
  *
984
- * @param id Document ID to delete
985
- * @param options Options for the mutation
989
+ * @param id - Document ID to delete
990
+ * @param options - Options for the mutation
986
991
  */
987
992
  delete<R extends Record<string, any> = Record<string, any>>(
988
993
  id: string,
@@ -992,8 +997,8 @@ export class SanityClient {
992
997
  * Deletes a document with the given document ID.
993
998
  * Returns a promise that resolves to an array containing the deleted document.
994
999
  *
995
- * @param id Document ID to delete
996
- * @param options Options for the mutation
1000
+ * @param id - Document ID to delete
1001
+ * @param options - Options for the mutation
997
1002
  */
998
1003
  delete<R extends Record<string, any> = Record<string, any>>(
999
1004
  id: string,
@@ -1003,24 +1008,24 @@ export class SanityClient {
1003
1008
  * Deletes a document with the given document ID.
1004
1009
  * Returns a promise that resolves to a mutation result object containing the deleted document ID.
1005
1010
  *
1006
- * @param id Document ID to delete
1007
- * @param options Options for the mutation
1011
+ * @param id - Document ID to delete
1012
+ * @param options - Options for the mutation
1008
1013
  */
1009
1014
  delete(id: string, options: FirstDocumentIdMutationOptions): Promise<SingleMutationResult>
1010
1015
  /**
1011
1016
  * Deletes a document with the given document ID.
1012
1017
  * Returns a promise that resolves to a mutation result object containing the deleted document ID.
1013
1018
  *
1014
- * @param id Document ID to delete
1015
- * @param options Options for the mutation
1019
+ * @param id - Document ID to delete
1020
+ * @param options - Options for the mutation
1016
1021
  */
1017
1022
  delete(id: string, options: AllDocumentIdsMutationOptions): Promise<MultipleMutationResult>
1018
1023
  /**
1019
1024
  * Deletes a document with the given document ID.
1020
1025
  * Returns a promise that resolves to the deleted document.
1021
1026
  *
1022
- * @param id Document ID to delete
1023
- * @param options Options for the mutation
1027
+ * @param id - Document ID to delete
1028
+ * @param options - Options for the mutation
1024
1029
  */
1025
1030
  delete<R extends Record<string, any> = Record<string, any>>(
1026
1031
  id: string,
@@ -1030,8 +1035,8 @@ export class SanityClient {
1030
1035
  * Deletes one or more documents matching the given query or document ID.
1031
1036
  * Returns a promise that resolves to first deleted document.
1032
1037
  *
1033
- * @param selection An object with either an `id` or `query` key defining what to delete
1034
- * @param options Options for the mutation
1038
+ * @param selection - An object with either an `id` or `query` key defining what to delete
1039
+ * @param options - Options for the mutation
1035
1040
  */
1036
1041
  delete<R extends Record<string, any> = Record<string, any>>(
1037
1042
  selection: MutationSelection,
@@ -1041,8 +1046,8 @@ export class SanityClient {
1041
1046
  * Deletes one or more documents matching the given query or document ID.
1042
1047
  * Returns a promise that resolves to an array containing the deleted documents.
1043
1048
  *
1044
- * @param selection An object with either an `id` or `query` key defining what to delete
1045
- * @param options Options for the mutation
1049
+ * @param selection - An object with either an `id` or `query` key defining what to delete
1050
+ * @param options - Options for the mutation
1046
1051
  */
1047
1052
  delete<R extends Record<string, any> = Record<string, any>>(
1048
1053
  selection: MutationSelection,
@@ -1052,8 +1057,8 @@ export class SanityClient {
1052
1057
  * Deletes one or more documents matching the given query or document ID.
1053
1058
  * Returns a promise that resolves to a mutation result object containing the ID of the first deleted document.
1054
1059
  *
1055
- * @param selection An object with either an `id` or `query` key defining what to delete
1056
- * @param options Options for the mutation
1060
+ * @param selection - An object with either an `id` or `query` key defining what to delete
1061
+ * @param options - Options for the mutation
1057
1062
  */
1058
1063
  delete(
1059
1064
  selection: MutationSelection,
@@ -1063,8 +1068,8 @@ export class SanityClient {
1063
1068
  * Deletes one or more documents matching the given query or document ID.
1064
1069
  * Returns a promise that resolves to a mutation result object containing the document IDs that were deleted.
1065
1070
  *
1066
- * @param selection An object with either an `id` or `query` key defining what to delete
1067
- * @param options Options for the mutation
1071
+ * @param selection - An object with either an `id` or `query` key defining what to delete
1072
+ * @param options - Options for the mutation
1068
1073
  */
1069
1074
  delete(
1070
1075
  selection: MutationSelection,
@@ -1074,8 +1079,8 @@ export class SanityClient {
1074
1079
  * Deletes one or more documents matching the given query or document ID.
1075
1080
  * Returns a promise that resolves to first deleted document.
1076
1081
  *
1077
- * @param selection An object with either an `id` or `query` key defining what to delete
1078
- * @param options Options for the mutation
1082
+ * @param selection - An object with either an `id` or `query` key defining what to delete
1083
+ * @param options - Options for the mutation
1079
1084
  */
1080
1085
  delete<R extends Record<string, any> = Record<string, any>>(
1081
1086
  selection: MutationSelection,
@@ -1099,8 +1104,8 @@ export class SanityClient {
1099
1104
  * Perform mutation operations against the configured dataset
1100
1105
  * Returns a promise that resolves to the first mutated document.
1101
1106
  *
1102
- * @param operations Mutation operations to execute
1103
- * @param options Mutation options
1107
+ * @param operations - Mutation operations to execute
1108
+ * @param options - Mutation options
1104
1109
  */
1105
1110
  mutate<R extends Record<string, any> = Record<string, any>>(
1106
1111
  operations: Mutation<R>[] | Patch | Transaction,
@@ -1110,8 +1115,8 @@ export class SanityClient {
1110
1115
  * Perform mutation operations against the configured dataset.
1111
1116
  * Returns a promise that resolves to an array of the mutated documents.
1112
1117
  *
1113
- * @param operations Mutation operations to execute
1114
- * @param options Mutation options
1118
+ * @param operations - Mutation operations to execute
1119
+ * @param options - Mutation options
1115
1120
  */
1116
1121
  mutate<R extends Record<string, any> = Record<string, any>>(
1117
1122
  operations: Mutation<R>[] | Patch | Transaction,
@@ -1121,8 +1126,8 @@ export class SanityClient {
1121
1126
  * Perform mutation operations against the configured dataset
1122
1127
  * Returns a promise that resolves to a mutation result object containing the document ID of the first mutated document.
1123
1128
  *
1124
- * @param operations Mutation operations to execute
1125
- * @param options Mutation options
1129
+ * @param operations - Mutation operations to execute
1130
+ * @param options - Mutation options
1126
1131
  */
1127
1132
  mutate<R extends Record<string, any> = Record<string, any>>(
1128
1133
  operations: Mutation<R>[] | Patch | Transaction,
@@ -1132,8 +1137,8 @@ export class SanityClient {
1132
1137
  * Perform mutation operations against the configured dataset
1133
1138
  * Returns a promise that resolves to a mutation result object containing the mutated document IDs.
1134
1139
  *
1135
- * @param operations Mutation operations to execute
1136
- * @param options Mutation options
1140
+ * @param operations - Mutation operations to execute
1141
+ * @param options - Mutation options
1137
1142
  */
1138
1143
  mutate<R extends Record<string, any>>(
1139
1144
  operations: Mutation<R>[] | Patch | Transaction,
@@ -1143,8 +1148,8 @@ export class SanityClient {
1143
1148
  * Perform mutation operations against the configured dataset
1144
1149
  * Returns a promise that resolves to the first mutated document.
1145
1150
  *
1146
- * @param operations Mutation operations to execute
1147
- * @param options Mutation options
1151
+ * @param operations - Mutation operations to execute
1152
+ * @param options - Mutation options
1148
1153
  */
1149
1154
  mutate<R extends Record<string, any> = Record<string, any>>(
1150
1155
  operations: Mutation<R>[] | Patch | Transaction,
@@ -1167,17 +1172,17 @@ export class SanityClient {
1167
1172
  /**
1168
1173
  * Create a new buildable patch of operations to perform
1169
1174
  *
1170
- * @param documentId Document ID to patch
1171
- * @param operations Optional object of patch operations to initialize the patch instance with
1175
+ * @param documentId - Document ID(s)to patch
1176
+ * @param operations - Optional object of patch operations to initialize the patch instance with
1172
1177
  */
1173
- patch(documentId: string | MutationSelection, operations?: PatchOperations): Patch {
1178
+ patch(documentId: PatchSelection, operations?: PatchOperations): Patch {
1174
1179
  return new Patch(documentId, operations, this)
1175
1180
  }
1176
1181
 
1177
1182
  /**
1178
1183
  * Create a new transaction of mutations
1179
1184
  *
1180
- * @param operations Optional array of mutation operations to initialize the transaction instance with
1185
+ * @param operations - Optional array of mutation operations to initialize the transaction instance with
1181
1186
  */
1182
1187
  transaction<R extends Record<string, any> = Record<string, any>>(
1183
1188
  operations?: Mutation<R>[]
@@ -1189,7 +1194,7 @@ export class SanityClient {
1189
1194
  * DEPRECATED: Perform an HTTP request against the Sanity API
1190
1195
  *
1191
1196
  * @deprecated Use your own request library!
1192
- * @param options Request options
1197
+ * @param options - Request options
1193
1198
  */
1194
1199
  request<R = any>(options: RawRequestOptions): Promise<R> {
1195
1200
  return lastValueFrom(dataMethods._request<R>(this, this.#httpRequest, options))
@@ -1199,9 +1204,9 @@ export class SanityClient {
1199
1204
  * DEPRECATED: Perform an HTTP request a `/data` sub-endpoint
1200
1205
  *
1201
1206
  * @deprecated Use your own request library!
1202
- * @param endpoint Endpoint to hit (mutate, query etc)
1203
- * @param body Request body
1204
- * @param options Request options
1207
+ * @param endpoint - Endpoint to hit (mutate, query etc)
1208
+ * @param body - Request body
1209
+ * @param options - Request options
1205
1210
  */
1206
1211
  dataRequest(endpoint: string, body: unknown, options?: BaseMutationOptions): Promise<any> {
1207
1212
  return lastValueFrom(dataMethods._dataRequest(this, this.#httpRequest, endpoint, body, options))