@sanity/client 3.4.0-beta.esm.3 → 3.4.1

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/sanityClient.d.ts CHANGED
@@ -35,7 +35,7 @@ export interface ProgressEvent {
35
35
 
36
36
  type AttributeSet = {[key: string]: any}
37
37
  type QueryParams = {[key: string]: any}
38
- type MutationSelection = {query: string} | {id: string}
38
+ type MutationSelection = {query: string; params?: QueryParams} | {id: string}
39
39
  type SanityReference = {_ref: string}
40
40
 
41
41
  interface RawRequestOptions {
@@ -205,7 +205,7 @@ export type PatchBuilder = (patch: Patch) => Patch
205
205
 
206
206
  export type PatchMutationOperation = PatchOperations & MutationSelection
207
207
 
208
- export type Mutation<R = any> =
208
+ export type Mutation<R extends Record<string, any> = Record<string, any>> =
209
209
  | {create: SanityDocumentStub<R>}
210
210
  | {createOrReplace: IdentifiedSanityDocumentStub<R>}
211
211
  | {createIfNotExists: IdentifiedSanityDocumentStub<R>}
@@ -224,14 +224,7 @@ export interface MultipleMutationResult {
224
224
  results: {id: string; operation: MutationOperation}[]
225
225
  }
226
226
 
227
- export class Patch {
228
- constructor(documentId: string, operations?: PatchOperations, client?: SanityClient)
229
-
230
- /**
231
- * Clones the patch
232
- */
233
- clone(): Patch
234
-
227
+ export abstract class BasePatch {
235
228
  /**
236
229
  * DEPRECATED: Don't use.
237
230
  * The operation is added to the current patch, ready to be commited by `commit()`
@@ -339,19 +332,37 @@ export class Patch {
339
332
  */
340
333
  toJSON(): PatchMutationOperation
341
334
 
335
+ /**
336
+ * Clears the patch of all operations
337
+ */
338
+ reset(): this
339
+ }
340
+
341
+ export class Patch extends BasePatch {
342
+ constructor(documentId: string, operations?: PatchOperations, client?: SanityClient)
343
+
344
+ /**
345
+ * Clones the patch
346
+ */
347
+ clone(): Patch
348
+
342
349
  /**
343
350
  * Commit the patch, returning a promise that resolves to the first patched document
344
351
  *
345
352
  * @param options Options for the mutation operation
346
353
  */
347
- commit<R = any>(options: FirstDocumentMutationOptions): Promise<SanityDocument<R>>
354
+ commit<R extends Record<string, any> = Record<string, any>>(
355
+ options: FirstDocumentMutationOptions
356
+ ): Promise<SanityDocument<R>>
348
357
 
349
358
  /**
350
359
  * Commit the patch, returning a promise that resolves to an array of the mutated documents
351
360
  *
352
361
  * @param options Options for the mutation operation
353
362
  */
354
- commit<R = any>(options: AllDocumentsMutationOptions): Promise<SanityDocument<R>[]>
363
+ commit<R extends Record<string, any> = Record<string, any>>(
364
+ options: AllDocumentsMutationOptions
365
+ ): Promise<SanityDocument<R>[]>
355
366
 
356
367
  /**
357
368
  * Commit the patch, returning a promise that resolves to a mutation result object
@@ -372,25 +383,69 @@ export class Patch {
372
383
  *
373
384
  * @param options Options for the mutation operation
374
385
  */
375
- commit<R = any>(options?: BaseMutationOptions): Promise<SanityDocument<R>>
386
+ commit<R extends Record<string, any> = Record<string, any>>(
387
+ options?: BaseMutationOptions
388
+ ): Promise<SanityDocument<R>>
389
+ }
390
+
391
+ export class ObservablePatch extends BasePatch {
392
+ constructor(documentId: string, operations?: PatchOperations, client?: ObservableSanityClient)
376
393
 
377
394
  /**
378
- * Clears the patch of all operations
395
+ * Clones the patch
379
396
  */
380
- reset(): this
381
- }
397
+ clone(): ObservablePatch
382
398
 
383
- export class Transaction {
384
- constructor(operations?: Mutation[], client?: SanityClient, transactionId?: string)
385
- clone(): Transaction
399
+ /**
400
+ * Commit the patch, returning an observable that produces the first patched document
401
+ *
402
+ * @param options Options for the mutation operation
403
+ */
404
+ commit<R extends Record<string, any> = Record<string, any>>(
405
+ options: FirstDocumentMutationOptions
406
+ ): Observable<SanityDocument<R>>
386
407
 
408
+ /**
409
+ * Commit the patch, returning an observable that produces an array of the mutated documents
410
+ *
411
+ * @param options Options for the mutation operation
412
+ */
413
+ commit<R extends Record<string, any> = Record<string, any>>(
414
+ options: AllDocumentsMutationOptions
415
+ ): Observable<SanityDocument<R>[]>
416
+
417
+ /**
418
+ * Commit the patch, returning an observable that produces a mutation result object
419
+ *
420
+ * @param options Options for the mutation operation
421
+ */
422
+ commit(options: FirstDocumentIdMutationOptions): Observable<SingleMutationResult>
423
+
424
+ /**
425
+ * Commit the patch, returning an observable that produces a mutation result object
426
+ *
427
+ * @param options Options for the mutation operation
428
+ */
429
+ commit(options: AllDocumentIdsMutationOptions): Observable<MultipleMutationResult>
430
+
431
+ /**
432
+ * Commit the patch, returning an observable that produces the first patched document
433
+ *
434
+ * @param options Options for the mutation operation
435
+ */
436
+ commit<R extends Record<string, any> = Record<string, any>>(
437
+ options?: BaseMutationOptions
438
+ ): Observable<SanityDocument<R>>
439
+ }
440
+
441
+ export abstract class BaseTransaction {
387
442
  /**
388
443
  * 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.
389
444
  * The operation is added to the current transaction, ready to be commited by `commit()`
390
445
  *
391
446
  * @param doc Document to create. Requires a `_type` property.
392
447
  */
393
- create<R = any>(doc: SanityDocumentStub<R>): this
448
+ create<R extends Record<string, any> = Record<string, any>>(doc: SanityDocumentStub<R>): this
394
449
 
395
450
  /**
396
451
  * Creates a new Sanity document. If a document with the same `_id` already exists, the create operation will be ignored.
@@ -398,7 +453,9 @@ export class Transaction {
398
453
  *
399
454
  * @param doc Document to create if it does not already exist. Requires `_id` and `_type` properties.
400
455
  */
401
- createIfNotExists<R = any>(doc: IdentifiedSanityDocumentStub<R>): this
456
+ createIfNotExists<R extends Record<string, any> = Record<string, any>>(
457
+ doc: IdentifiedSanityDocumentStub<R>
458
+ ): this
402
459
 
403
460
  /**
404
461
  * Creates a new Sanity document, or replaces an existing one if the same `_id` is already used.
@@ -406,7 +463,9 @@ export class Transaction {
406
463
  *
407
464
  * @param doc Document to create or replace. Requires `_id` and `_type` properties.
408
465
  */
409
- createOrReplace<R = any>(doc: IdentifiedSanityDocumentStub<R>): this
466
+ createOrReplace<R extends Record<string, any> = Record<string, any>>(
467
+ doc: IdentifiedSanityDocumentStub<R>
468
+ ): this
410
469
 
411
470
  /**
412
471
  * Deletes the document with the given document ID
@@ -452,19 +511,37 @@ export class Transaction {
452
511
  */
453
512
  toJSON(): Mutation[]
454
513
 
514
+ /**
515
+ * Clears the transaction of all operations
516
+ */
517
+ reset(): this
518
+ }
519
+
520
+ export class Transaction extends BaseTransaction {
521
+ constructor(operations?: Mutation[], client?: SanityClient, transactionId?: string)
522
+
523
+ /**
524
+ * Clones the transaction
525
+ */
526
+ clone(): Transaction
527
+
455
528
  /**
456
529
  * Commit the transaction, returning a promise that resolves to the first mutated document
457
530
  *
458
531
  * @param options Options for the mutation operation
459
532
  */
460
- commit<R>(options: TransactionFirstDocumentMutationOptions): Promise<SanityDocument<R>>
533
+ commit<R extends Record<string, any>>(
534
+ options: TransactionFirstDocumentMutationOptions
535
+ ): Promise<SanityDocument<R>>
461
536
 
462
537
  /**
463
538
  * Commit the transaction, returning a promise that resolves to an array of the mutated documents
464
539
  *
465
540
  * @param options Options for the mutation operation
466
541
  */
467
- commit<R>(options: TransactionAllDocumentsMutationOptions): Promise<SanityDocument<R>[]>
542
+ commit<R extends Record<string, any>>(
543
+ options: TransactionAllDocumentsMutationOptions
544
+ ): Promise<SanityDocument<R>[]>
468
545
 
469
546
  /**
470
547
  * Commit the transaction, returning a promise that resolves to a mutation result object
@@ -486,11 +563,54 @@ export class Transaction {
486
563
  * @param options Options for the mutation operation
487
564
  */
488
565
  commit(options?: BaseMutationOptions): Promise<MultipleMutationResult>
566
+ }
567
+
568
+ export class ObservableTransaction extends BaseTransaction {
569
+ constructor(operations?: Mutation[], client?: ObservableSanityClient, transactionId?: string)
489
570
 
490
571
  /**
491
- * Clears the transaction of all operations
572
+ * Clones the transaction
492
573
  */
493
- reset(): this
574
+ clone(): ObservableTransaction
575
+
576
+ /**
577
+ * Commit the transaction, returning an observable that produces the first mutated document
578
+ *
579
+ * @param options Options for the mutation operation
580
+ */
581
+ commit<R extends Record<string, any>>(
582
+ options: TransactionFirstDocumentMutationOptions
583
+ ): Observable<SanityDocument<R>>
584
+
585
+ /**
586
+ * Commit the transaction, returning an observable that produces an array of the mutated documents
587
+ *
588
+ * @param options Options for the mutation operation
589
+ */
590
+ commit<R extends Record<string, any>>(
591
+ options: TransactionAllDocumentsMutationOptions
592
+ ): Observable<SanityDocument<R>[]>
593
+
594
+ /**
595
+ * Commit the transaction, returning an observable that produces a mutation result object
596
+ *
597
+ * @param options Options for the mutation operation
598
+ */
599
+ commit(options: TransactionFirstDocumentIdMutationOptions): Observable<SingleMutationResult>
600
+
601
+ /**
602
+ * Commit the transaction, returning an observable that produces a mutation result object
603
+ *
604
+ * @param options Options for the mutation operation
605
+ */
606
+ commit(options: TransactionAllDocumentIdsMutationOptions): Observable<MultipleMutationResult>
607
+
608
+ /**
609
+ * Commit the transaction, returning an observable that produces a mutation result object
610
+ *
611
+ * @param options Options for the mutation operation
612
+ */
613
+ commit(options?: BaseMutationOptions): Observable<MultipleMutationResult>
494
614
  }
495
615
 
496
616
  export interface ClientConfig {
@@ -504,6 +624,7 @@ export interface ClientConfig {
504
624
  requestTagPrefix?: string
505
625
  ignoreBrowserTokenWarning?: boolean
506
626
  withCredentials?: boolean
627
+ allowReconfigure?: boolean
507
628
  timeout?: number
508
629
 
509
630
  /**
@@ -546,7 +667,7 @@ type BaseMutationOptions = RequestOptions & {
546
667
  skipCrossDatasetReferenceValidation?: boolean
547
668
  }
548
669
 
549
- export type MutationEvent<R = any> = {
670
+ export type MutationEvent<R extends Record<string, any> = Record<string, any>> = {
550
671
  type: 'mutation'
551
672
  documentId: string
552
673
  eventId: string
@@ -581,7 +702,7 @@ export type WelcomeEvent = {
581
702
  type: 'welcome'
582
703
  }
583
704
 
584
- export type ListenEvent<R> =
705
+ export type ListenEvent<R extends Record<string, any>> =
585
706
  | MutationEvent<R>
586
707
  | ChannelErrorEvent
587
708
  | DisconnectEvent
@@ -1015,7 +1136,7 @@ export class ObservableSanityClient {
1015
1136
  * @param id Document ID to fetch
1016
1137
  * @param options Request options
1017
1138
  */
1018
- getDocument<R = any>(
1139
+ getDocument<R extends Record<string, any> = Record<string, any>>(
1019
1140
  id: string,
1020
1141
  options?: {tag?: string}
1021
1142
  ): Observable<SanityDocument<R> | undefined>
@@ -1029,7 +1150,7 @@ export class ObservableSanityClient {
1029
1150
  * @param ids Document IDs to fetch
1030
1151
  * @param options Request options
1031
1152
  */
1032
- getDocuments<R = any>(
1153
+ getDocuments<R extends Record<string, any> = Record<string, any>>(
1033
1154
  ids: string[],
1034
1155
  options?: {tag?: string}
1035
1156
  ): Observable<(SanityDocument<R> | null)[]>
@@ -1041,7 +1162,7 @@ export class ObservableSanityClient {
1041
1162
  * @param document Document to create
1042
1163
  * @param options Mutation options
1043
1164
  */
1044
- create<R = any>(
1165
+ create<R extends Record<string, any> = Record<string, any>>(
1045
1166
  document: SanityDocumentStub<R>,
1046
1167
  options: FirstDocumentMutationOptions
1047
1168
  ): Observable<SanityDocument<R>>
@@ -1053,7 +1174,7 @@ export class ObservableSanityClient {
1053
1174
  * @param document Document to create
1054
1175
  * @param options Mutation options
1055
1176
  */
1056
- create<R = any>(
1177
+ create<R extends Record<string, any> = Record<string, any>>(
1057
1178
  document: SanityDocumentStub<R>,
1058
1179
  options: AllDocumentsMutationOptions
1059
1180
  ): Observable<SanityDocument<R>[]>
@@ -1065,7 +1186,7 @@ export class ObservableSanityClient {
1065
1186
  * @param document Document to create
1066
1187
  * @param options Mutation options
1067
1188
  */
1068
- create<R = any>(
1189
+ create<R extends Record<string, any> = Record<string, any>>(
1069
1190
  document: SanityDocumentStub<R>,
1070
1191
  options: FirstDocumentIdMutationOptions
1071
1192
  ): Observable<SingleMutationResult>
@@ -1077,7 +1198,7 @@ export class ObservableSanityClient {
1077
1198
  * @param document Document to create
1078
1199
  * @param options Mutation options
1079
1200
  */
1080
- create<R = any>(
1201
+ create<R extends Record<string, any> = Record<string, any>>(
1081
1202
  document: SanityDocumentStub<R>,
1082
1203
  options: AllDocumentIdsMutationOptions
1083
1204
  ): Observable<MultipleMutationResult>
@@ -1089,7 +1210,7 @@ export class ObservableSanityClient {
1089
1210
  * @param document Document to create
1090
1211
  * @param options Mutation options
1091
1212
  */
1092
- create<R = any>(
1213
+ create<R extends Record<string, any> = Record<string, any>>(
1093
1214
  document: SanityDocumentStub<R>,
1094
1215
  options?: BaseMutationOptions
1095
1216
  ): Observable<SanityDocument<R>>
@@ -1101,7 +1222,7 @@ export class ObservableSanityClient {
1101
1222
  * @param document Document to create
1102
1223
  * @param options Mutation options
1103
1224
  */
1104
- createIfNotExists<R = any>(
1225
+ createIfNotExists<R extends Record<string, any> = Record<string, any>>(
1105
1226
  document: IdentifiedSanityDocumentStub<R>,
1106
1227
  options: FirstDocumentMutationOptions
1107
1228
  ): Observable<SanityDocument<R>>
@@ -1113,7 +1234,7 @@ export class ObservableSanityClient {
1113
1234
  * @param document Document to create
1114
1235
  * @param options Mutation options
1115
1236
  */
1116
- createIfNotExists<R = any>(
1237
+ createIfNotExists<R extends Record<string, any> = Record<string, any>>(
1117
1238
  document: IdentifiedSanityDocumentStub<R>,
1118
1239
  options: AllDocumentsMutationOptions
1119
1240
  ): Observable<SanityDocument<R>[]>
@@ -1125,7 +1246,7 @@ export class ObservableSanityClient {
1125
1246
  * @param document Document to create
1126
1247
  * @param options Mutation options
1127
1248
  */
1128
- createIfNotExists<R = any>(
1249
+ createIfNotExists<R extends Record<string, any> = Record<string, any>>(
1129
1250
  document: IdentifiedSanityDocumentStub<R>,
1130
1251
  options: FirstDocumentIdMutationOptions
1131
1252
  ): Observable<SingleMutationResult>
@@ -1137,7 +1258,7 @@ export class ObservableSanityClient {
1137
1258
  * @param document Document to create
1138
1259
  * @param options Mutation options
1139
1260
  */
1140
- createIfNotExists<R = any>(
1261
+ createIfNotExists<R extends Record<string, any> = Record<string, any>>(
1141
1262
  document: IdentifiedSanityDocumentStub<R>,
1142
1263
  options: AllDocumentIdsMutationOptions
1143
1264
  ): Observable<MultipleMutationResult>
@@ -1149,7 +1270,7 @@ export class ObservableSanityClient {
1149
1270
  * @param document Document to create
1150
1271
  * @param options Mutation options
1151
1272
  */
1152
- createIfNotExists<R = any>(
1273
+ createIfNotExists<R extends Record<string, any> = Record<string, any>>(
1153
1274
  document: IdentifiedSanityDocumentStub<R>,
1154
1275
  options?: BaseMutationOptions
1155
1276
  ): Observable<SanityDocument<R>>
@@ -1161,7 +1282,7 @@ export class ObservableSanityClient {
1161
1282
  * @param document Document to either create or replace
1162
1283
  * @param options Mutation options
1163
1284
  */
1164
- createOrReplace<R = any>(
1285
+ createOrReplace<R extends Record<string, any> = Record<string, any>>(
1165
1286
  document: IdentifiedSanityDocumentStub<R>,
1166
1287
  options: FirstDocumentMutationOptions
1167
1288
  ): Observable<SanityDocument<R>>
@@ -1173,7 +1294,7 @@ export class ObservableSanityClient {
1173
1294
  * @param document Document to either create or replace
1174
1295
  * @param options Mutation options
1175
1296
  */
1176
- createOrReplace<R = any>(
1297
+ createOrReplace<R extends Record<string, any> = Record<string, any>>(
1177
1298
  document: IdentifiedSanityDocumentStub<R>,
1178
1299
  options: AllDocumentsMutationOptions
1179
1300
  ): Observable<SanityDocument<R>[]>
@@ -1185,7 +1306,7 @@ export class ObservableSanityClient {
1185
1306
  * @param document Document to either create or replace
1186
1307
  * @param options Mutation options
1187
1308
  */
1188
- createOrReplace<R = any>(
1309
+ createOrReplace<R extends Record<string, any> = Record<string, any>>(
1189
1310
  document: IdentifiedSanityDocumentStub<R>,
1190
1311
  options: FirstDocumentIdMutationOptions
1191
1312
  ): Observable<SingleMutationResult>
@@ -1197,7 +1318,7 @@ export class ObservableSanityClient {
1197
1318
  * @param document Document to either create or replace
1198
1319
  * @param options Mutation options
1199
1320
  */
1200
- createOrReplace<R = any>(
1321
+ createOrReplace<R extends Record<string, any> = Record<string, any>>(
1201
1322
  document: IdentifiedSanityDocumentStub<R>,
1202
1323
  options: AllDocumentIdsMutationOptions
1203
1324
  ): Observable<MultipleMutationResult>
@@ -1209,7 +1330,7 @@ export class ObservableSanityClient {
1209
1330
  * @param document Document to either create or replace
1210
1331
  * @param options Mutation options
1211
1332
  */
1212
- createOrReplace<R = any>(
1333
+ createOrReplace<R extends Record<string, any> = Record<string, any>>(
1213
1334
  document: IdentifiedSanityDocumentStub<R>,
1214
1335
  options?: BaseMutationOptions
1215
1336
  ): Observable<SanityDocument<R>>
@@ -1221,7 +1342,10 @@ export class ObservableSanityClient {
1221
1342
  * @param id Document ID to delete
1222
1343
  * @param options Options for the mutation
1223
1344
  */
1224
- delete<R = any>(id: string, options: FirstDocumentMutationOptions): Observable<SanityDocument<R>>
1345
+ delete<R extends Record<string, any> = Record<string, any>>(
1346
+ id: string,
1347
+ options: FirstDocumentMutationOptions
1348
+ ): Observable<SanityDocument<R>>
1225
1349
 
1226
1350
  /**
1227
1351
  * Deletes a document with the given document ID.
@@ -1230,7 +1354,10 @@ export class ObservableSanityClient {
1230
1354
  * @param id Document ID to delete
1231
1355
  * @param options Options for the mutation
1232
1356
  */
1233
- delete<R = any>(id: string, options: AllDocumentsMutationOptions): Observable<SanityDocument<R>[]>
1357
+ delete<R extends Record<string, any> = Record<string, any>>(
1358
+ id: string,
1359
+ options: AllDocumentsMutationOptions
1360
+ ): Observable<SanityDocument<R>[]>
1234
1361
 
1235
1362
  /**
1236
1363
  * Deletes a document with the given document ID.
@@ -1257,7 +1384,10 @@ export class ObservableSanityClient {
1257
1384
  * @param id Document ID to delete
1258
1385
  * @param options Options for the mutation
1259
1386
  */
1260
- delete<R = any>(id: string, options?: BaseMutationOptions): Observable<SanityDocument<R>>
1387
+ delete<R extends Record<string, any> = Record<string, any>>(
1388
+ id: string,
1389
+ options?: BaseMutationOptions
1390
+ ): Observable<SanityDocument<R>>
1261
1391
 
1262
1392
  /**
1263
1393
  * Deletes one or more documents matching the given query or document ID.
@@ -1266,7 +1396,7 @@ export class ObservableSanityClient {
1266
1396
  * @param selection An object with either an `id` or `query` key defining what to delete
1267
1397
  * @param options Options for the mutation
1268
1398
  */
1269
- delete<R = any>(
1399
+ delete<R extends Record<string, any> = Record<string, any>>(
1270
1400
  selection: MutationSelection,
1271
1401
  options: FirstDocumentMutationOptions
1272
1402
  ): Observable<SanityDocument<R>>
@@ -1278,7 +1408,7 @@ export class ObservableSanityClient {
1278
1408
  * @param selection An object with either an `id` or `query` key defining what to delete
1279
1409
  * @param options Options for the mutation
1280
1410
  */
1281
- delete<R = any>(
1411
+ delete<R extends Record<string, any> = Record<string, any>>(
1282
1412
  selection: MutationSelection,
1283
1413
  options: AllDocumentsMutationOptions
1284
1414
  ): Observable<SanityDocument<R>[]>
@@ -1314,7 +1444,7 @@ export class ObservableSanityClient {
1314
1444
  * @param selection An object with either an `id` or `query` key defining what to delete
1315
1445
  * @param options Options for the mutation
1316
1446
  */
1317
- delete<R = any>(
1447
+ delete<R extends Record<string, any> = Record<string, any>>(
1318
1448
  selection: MutationSelection,
1319
1449
  options?: BaseMutationOptions
1320
1450
  ): Observable<SanityDocument<R>>
@@ -1326,7 +1456,7 @@ export class ObservableSanityClient {
1326
1456
  * @param operations Mutation operations to execute
1327
1457
  * @param options Mutation options
1328
1458
  */
1329
- mutate<R = any>(
1459
+ mutate<R extends Record<string, any> = Record<string, any>>(
1330
1460
  operations: Mutation<R>[] | Patch | Transaction,
1331
1461
  options: FirstDocumentMutationOptions
1332
1462
  ): Observable<SanityDocument<R>>
@@ -1338,7 +1468,7 @@ export class ObservableSanityClient {
1338
1468
  * @param operations Mutation operations to execute
1339
1469
  * @param options Mutation options
1340
1470
  */
1341
- mutate<R = any>(
1471
+ mutate<R extends Record<string, any> = Record<string, any>>(
1342
1472
  operations: Mutation<R>[] | Patch | Transaction,
1343
1473
  options: AllDocumentsMutationOptions
1344
1474
  ): Observable<SanityDocument<R>[]>
@@ -1350,7 +1480,7 @@ export class ObservableSanityClient {
1350
1480
  * @param operations Mutation operations to execute
1351
1481
  * @param options Mutation options
1352
1482
  */
1353
- mutate<R = any>(
1483
+ mutate<R extends Record<string, any> = Record<string, any>>(
1354
1484
  operations: Mutation<R>[] | Patch | Transaction,
1355
1485
  options: FirstDocumentIdMutationOptions
1356
1486
  ): Observable<SingleMutationResult>
@@ -1362,7 +1492,7 @@ export class ObservableSanityClient {
1362
1492
  * @param operations Mutation operations to execute
1363
1493
  * @param options Mutation options
1364
1494
  */
1365
- mutate<R = any>(
1495
+ mutate<R extends Record<string, any> = Record<string, any>>(
1366
1496
  operations: Mutation<R>[] | Patch | Transaction,
1367
1497
  options: AllDocumentIdsMutationOptions
1368
1498
  ): Observable<MultipleMutationResult>
@@ -1374,7 +1504,7 @@ export class ObservableSanityClient {
1374
1504
  * @param operations Mutation operations to execute
1375
1505
  * @param options Mutation options
1376
1506
  */
1377
- mutate<R = any>(
1507
+ mutate<R extends Record<string, any> = Record<string, any>>(
1378
1508
  operations: Mutation<R>[] | Patch | Transaction,
1379
1509
  options?: BaseMutationOptions
1380
1510
  ): Observable<SanityDocument<R>>
@@ -1385,14 +1515,16 @@ export class ObservableSanityClient {
1385
1515
  * @param documentId Document ID to patch
1386
1516
  * @param operations Optional object of patch operations to initialize the patch instance with
1387
1517
  */
1388
- patch(documentId: string | MutationSelection, operations?: PatchOperations): Patch
1518
+ patch(documentId: string | MutationSelection, operations?: PatchOperations): ObservablePatch
1389
1519
 
1390
1520
  /**
1391
1521
  * Create a new transaction of mutations
1392
1522
  *
1393
1523
  * @param operations Optional array of mutation operations to initialize the transaction instance with
1394
1524
  */
1395
- transaction<R = any>(operations?: Mutation<R>[]): Transaction
1525
+ transaction<R extends Record<string, any> = Record<string, any>>(
1526
+ operations?: Mutation<R>[]
1527
+ ): ObservableTransaction
1396
1528
 
1397
1529
  // "Internals", should generally not be used externally
1398
1530
  /**
@@ -1609,7 +1741,10 @@ export interface SanityClient {
1609
1741
  * @param params Optional query parameters
1610
1742
  * @param options Listener options
1611
1743
  */
1612
- listen<R = any>(query: string, params?: QueryParams): Observable<MutationEvent<R>>
1744
+ listen<R extends Record<string, any> = Record<string, any>>(
1745
+ query: string,
1746
+ params?: QueryParams
1747
+ ): Observable<MutationEvent<R>>
1613
1748
 
1614
1749
  /**
1615
1750
  * Set up a listener that will be notified when mutations occur on documents matching the provided query/filter.
@@ -1618,7 +1753,7 @@ export interface SanityClient {
1618
1753
  * @param params Optional query parameters
1619
1754
  * @param options Listener options
1620
1755
  */
1621
- listen<R = any>(
1756
+ listen<R extends Record<string, any> = Record<string, any>>(
1622
1757
  query: string,
1623
1758
  params?: QueryParams,
1624
1759
  options?: ListenOptions
@@ -1671,7 +1806,10 @@ export interface SanityClient {
1671
1806
  * @param id Document ID to fetch
1672
1807
  * @param options Request options
1673
1808
  */
1674
- getDocument<R = any>(id: string, options?: {tag?: string}): Promise<SanityDocument<R> | undefined>
1809
+ getDocument<R extends Record<string, any> = Record<string, any>>(
1810
+ id: string,
1811
+ options?: {tag?: string}
1812
+ ): Promise<SanityDocument<R> | undefined>
1675
1813
 
1676
1814
  /**
1677
1815
  * Fetch multiple documents in one request.
@@ -1682,7 +1820,7 @@ export interface SanityClient {
1682
1820
  * @param ids Document IDs to fetch
1683
1821
  * @param options Request options
1684
1822
  */
1685
- getDocuments<R = any>(
1823
+ getDocuments<R extends Record<string, any> = Record<string, any>>(
1686
1824
  ids: string[],
1687
1825
  options?: {tag?: string}
1688
1826
  ): Promise<(SanityDocument<R> | null)[]>
@@ -1694,7 +1832,7 @@ export interface SanityClient {
1694
1832
  * @param document Document to create
1695
1833
  * @param options Mutation options
1696
1834
  */
1697
- create<R = any>(
1835
+ create<R extends Record<string, any> = Record<string, any>>(
1698
1836
  document: SanityDocumentStub<R>,
1699
1837
  options: FirstDocumentMutationOptions
1700
1838
  ): Promise<SanityDocument<R>>
@@ -1706,7 +1844,7 @@ export interface SanityClient {
1706
1844
  * @param document Document to create
1707
1845
  * @param options Mutation options
1708
1846
  */
1709
- create<R = any>(
1847
+ create<R extends Record<string, any> = Record<string, any>>(
1710
1848
  document: SanityDocumentStub<R>,
1711
1849
  options: AllDocumentsMutationOptions
1712
1850
  ): Promise<SanityDocument<R>[]>
@@ -1718,7 +1856,7 @@ export interface SanityClient {
1718
1856
  * @param document Document to create
1719
1857
  * @param options Mutation options
1720
1858
  */
1721
- create<R = any>(
1859
+ create<R extends Record<string, any> = Record<string, any>>(
1722
1860
  document: SanityDocumentStub<R>,
1723
1861
  options: FirstDocumentIdMutationOptions
1724
1862
  ): Promise<SingleMutationResult>
@@ -1730,7 +1868,7 @@ export interface SanityClient {
1730
1868
  * @param document Document to create
1731
1869
  * @param options Mutation options
1732
1870
  */
1733
- create<R = any>(
1871
+ create<R extends Record<string, any> = Record<string, any>>(
1734
1872
  document: SanityDocumentStub<R>,
1735
1873
  options: AllDocumentIdsMutationOptions
1736
1874
  ): Promise<MultipleMutationResult>
@@ -1742,7 +1880,7 @@ export interface SanityClient {
1742
1880
  * @param document Document to create
1743
1881
  * @param options Mutation options
1744
1882
  */
1745
- create<R = any>(
1883
+ create<R extends Record<string, any> = Record<string, any>>(
1746
1884
  document: SanityDocumentStub<R>,
1747
1885
  options?: BaseMutationOptions
1748
1886
  ): Promise<SanityDocument<R>>
@@ -1754,7 +1892,7 @@ export interface SanityClient {
1754
1892
  * @param document Document to create
1755
1893
  * @param options Mutation options
1756
1894
  */
1757
- createIfNotExists<R = any>(
1895
+ createIfNotExists<R extends Record<string, any> = Record<string, any>>(
1758
1896
  document: IdentifiedSanityDocumentStub<R>,
1759
1897
  options: FirstDocumentMutationOptions
1760
1898
  ): Promise<SanityDocument<R>>
@@ -1766,7 +1904,7 @@ export interface SanityClient {
1766
1904
  * @param document Document to create
1767
1905
  * @param options Mutation options
1768
1906
  */
1769
- createIfNotExists<R = any>(
1907
+ createIfNotExists<R extends Record<string, any> = Record<string, any>>(
1770
1908
  document: IdentifiedSanityDocumentStub<R>,
1771
1909
  options: AllDocumentsMutationOptions
1772
1910
  ): Promise<SanityDocument<R>[]>
@@ -1778,7 +1916,7 @@ export interface SanityClient {
1778
1916
  * @param document Document to create
1779
1917
  * @param options Mutation options
1780
1918
  */
1781
- createIfNotExists<R = any>(
1919
+ createIfNotExists<R extends Record<string, any> = Record<string, any>>(
1782
1920
  document: IdentifiedSanityDocumentStub<R>,
1783
1921
  options: FirstDocumentIdMutationOptions
1784
1922
  ): Promise<SingleMutationResult>
@@ -1790,7 +1928,7 @@ export interface SanityClient {
1790
1928
  * @param document Document to create
1791
1929
  * @param options Mutation options
1792
1930
  */
1793
- createIfNotExists<R = any>(
1931
+ createIfNotExists<R extends Record<string, any> = Record<string, any>>(
1794
1932
  document: IdentifiedSanityDocumentStub<R>,
1795
1933
  options: AllDocumentIdsMutationOptions
1796
1934
  ): Promise<MultipleMutationResult>
@@ -1802,7 +1940,7 @@ export interface SanityClient {
1802
1940
  * @param document Document to create
1803
1941
  * @param options Mutation options
1804
1942
  */
1805
- createIfNotExists<R = any>(
1943
+ createIfNotExists<R extends Record<string, any> = Record<string, any>>(
1806
1944
  document: IdentifiedSanityDocumentStub<R>,
1807
1945
  options?: BaseMutationOptions
1808
1946
  ): Promise<SanityDocument<R>>
@@ -1814,7 +1952,7 @@ export interface SanityClient {
1814
1952
  * @param document Document to either create or replace
1815
1953
  * @param options Mutation options
1816
1954
  */
1817
- createOrReplace<R = any>(
1955
+ createOrReplace<R extends Record<string, any> = Record<string, any>>(
1818
1956
  document: IdentifiedSanityDocumentStub<R>,
1819
1957
  options: FirstDocumentMutationOptions
1820
1958
  ): Promise<SanityDocument<R>>
@@ -1826,7 +1964,7 @@ export interface SanityClient {
1826
1964
  * @param document Document to either create or replace
1827
1965
  * @param options Mutation options
1828
1966
  */
1829
- createOrReplace<R = any>(
1967
+ createOrReplace<R extends Record<string, any> = Record<string, any>>(
1830
1968
  document: IdentifiedSanityDocumentStub<R>,
1831
1969
  options: AllDocumentsMutationOptions
1832
1970
  ): Promise<SanityDocument<R>[]>
@@ -1838,7 +1976,7 @@ export interface SanityClient {
1838
1976
  * @param document Document to either create or replace
1839
1977
  * @param options Mutation options
1840
1978
  */
1841
- createOrReplace<R = any>(
1979
+ createOrReplace<R extends Record<string, any> = Record<string, any>>(
1842
1980
  document: IdentifiedSanityDocumentStub<R>,
1843
1981
  options: FirstDocumentIdMutationOptions
1844
1982
  ): Promise<SingleMutationResult>
@@ -1850,7 +1988,7 @@ export interface SanityClient {
1850
1988
  * @param document Document to either create or replace
1851
1989
  * @param options Mutation options
1852
1990
  */
1853
- createOrReplace<R = any>(
1991
+ createOrReplace<R extends Record<string, any> = Record<string, any>>(
1854
1992
  document: IdentifiedSanityDocumentStub<R>,
1855
1993
  options: AllDocumentIdsMutationOptions
1856
1994
  ): Promise<MultipleMutationResult>
@@ -1862,7 +2000,7 @@ export interface SanityClient {
1862
2000
  * @param document Document to either create or replace
1863
2001
  * @param options Mutation options
1864
2002
  */
1865
- createOrReplace<R = any>(
2003
+ createOrReplace<R extends Record<string, any> = Record<string, any>>(
1866
2004
  document: IdentifiedSanityDocumentStub<R>,
1867
2005
  options?: BaseMutationOptions
1868
2006
  ): Promise<SanityDocument<R>>
@@ -1874,7 +2012,10 @@ export interface SanityClient {
1874
2012
  * @param id Document ID to delete
1875
2013
  * @param options Options for the mutation
1876
2014
  */
1877
- delete<R = any>(id: string, options: FirstDocumentMutationOptions): Promise<SanityDocument<R>>
2015
+ delete<R extends Record<string, any> = Record<string, any>>(
2016
+ id: string,
2017
+ options: FirstDocumentMutationOptions
2018
+ ): Promise<SanityDocument<R>>
1878
2019
 
1879
2020
  /**
1880
2021
  * Deletes a document with the given document ID.
@@ -1883,7 +2024,10 @@ export interface SanityClient {
1883
2024
  * @param id Document ID to delete
1884
2025
  * @param options Options for the mutation
1885
2026
  */
1886
- delete<R = any>(id: string, options: AllDocumentsMutationOptions): Promise<SanityDocument<R>[]>
2027
+ delete<R extends Record<string, any> = Record<string, any>>(
2028
+ id: string,
2029
+ options: AllDocumentsMutationOptions
2030
+ ): Promise<SanityDocument<R>[]>
1887
2031
 
1888
2032
  /**
1889
2033
  * Deletes a document with the given document ID.
@@ -1910,7 +2054,10 @@ export interface SanityClient {
1910
2054
  * @param id Document ID to delete
1911
2055
  * @param options Options for the mutation
1912
2056
  */
1913
- delete<R = any>(id: string, options?: BaseMutationOptions): Promise<SanityDocument<R>>
2057
+ delete<R extends Record<string, any> = Record<string, any>>(
2058
+ id: string,
2059
+ options?: BaseMutationOptions
2060
+ ): Promise<SanityDocument<R>>
1914
2061
 
1915
2062
  /**
1916
2063
  * Deletes one or more documents matching the given query or document ID.
@@ -1919,7 +2066,7 @@ export interface SanityClient {
1919
2066
  * @param selection An object with either an `id` or `query` key defining what to delete
1920
2067
  * @param options Options for the mutation
1921
2068
  */
1922
- delete<R = any>(
2069
+ delete<R extends Record<string, any> = Record<string, any>>(
1923
2070
  selection: MutationSelection,
1924
2071
  options: FirstDocumentMutationOptions
1925
2072
  ): Promise<SanityDocument<R>>
@@ -1931,7 +2078,7 @@ export interface SanityClient {
1931
2078
  * @param selection An object with either an `id` or `query` key defining what to delete
1932
2079
  * @param options Options for the mutation
1933
2080
  */
1934
- delete<R = any>(
2081
+ delete<R extends Record<string, any> = Record<string, any>>(
1935
2082
  selection: MutationSelection,
1936
2083
  options: AllDocumentsMutationOptions
1937
2084
  ): Promise<SanityDocument<R>[]>
@@ -1967,7 +2114,7 @@ export interface SanityClient {
1967
2114
  * @param selection An object with either an `id` or `query` key defining what to delete
1968
2115
  * @param options Options for the mutation
1969
2116
  */
1970
- delete<R = any>(
2117
+ delete<R extends Record<string, any> = Record<string, any>>(
1971
2118
  selection: MutationSelection,
1972
2119
  options?: BaseMutationOptions
1973
2120
  ): Promise<SanityDocument<R>>
@@ -1979,7 +2126,7 @@ export interface SanityClient {
1979
2126
  * @param operations Mutation operations to execute
1980
2127
  * @param options Mutation options
1981
2128
  */
1982
- mutate<R = any>(
2129
+ mutate<R extends Record<string, any> = Record<string, any>>(
1983
2130
  operations: Mutation<R>[] | Patch | Transaction,
1984
2131
  options: FirstDocumentMutationOptions
1985
2132
  ): Promise<SanityDocument<R>>
@@ -1991,7 +2138,7 @@ export interface SanityClient {
1991
2138
  * @param operations Mutation operations to execute
1992
2139
  * @param options Mutation options
1993
2140
  */
1994
- mutate<R = any>(
2141
+ mutate<R extends Record<string, any> = Record<string, any>>(
1995
2142
  operations: Mutation<R>[] | Patch | Transaction,
1996
2143
  options: AllDocumentsMutationOptions
1997
2144
  ): Promise<SanityDocument<R>[]>
@@ -2003,7 +2150,7 @@ export interface SanityClient {
2003
2150
  * @param operations Mutation operations to execute
2004
2151
  * @param options Mutation options
2005
2152
  */
2006
- mutate<R = any>(
2153
+ mutate<R extends Record<string, any> = Record<string, any>>(
2007
2154
  operations: Mutation<R>[] | Patch | Transaction,
2008
2155
  options: FirstDocumentIdMutationOptions
2009
2156
  ): Promise<SingleMutationResult>
@@ -2015,7 +2162,7 @@ export interface SanityClient {
2015
2162
  * @param operations Mutation operations to execute
2016
2163
  * @param options Mutation options
2017
2164
  */
2018
- mutate<R>(
2165
+ mutate<R extends Record<string, any>>(
2019
2166
  operations: Mutation<R>[] | Patch | Transaction,
2020
2167
  options: AllDocumentIdsMutationOptions
2021
2168
  ): Promise<MultipleMutationResult>
@@ -2027,7 +2174,7 @@ export interface SanityClient {
2027
2174
  * @param operations Mutation operations to execute
2028
2175
  * @param options Mutation options
2029
2176
  */
2030
- mutate<R = any>(
2177
+ mutate<R extends Record<string, any> = Record<string, any>>(
2031
2178
  operations: Mutation<R>[] | Patch | Transaction,
2032
2179
  options?: BaseMutationOptions
2033
2180
  ): Promise<SanityDocument<R>>
@@ -2045,7 +2192,9 @@ export interface SanityClient {
2045
2192
  *
2046
2193
  * @param operations Optional array of mutation operations to initialize the transaction instance with
2047
2194
  */
2048
- transaction<R = any>(operations?: Mutation<R>[]): Transaction
2195
+ transaction<R extends Record<string, any> = Record<string, any>>(
2196
+ operations?: Mutation<R>[]
2197
+ ): Transaction
2049
2198
 
2050
2199
  // "Internals", should generally not be used externally
2051
2200
  /**