@sanity/client 3.3.4 → 3.3.7

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.
Files changed (2) hide show
  1. package/package.json +2 -9
  2. package/sanityClient.d.ts +144 -86
package/package.json CHANGED
@@ -1,18 +1,11 @@
1
1
  {
2
2
  "name": "@sanity/client",
3
- "version": "3.3.4",
3
+ "version": "3.3.7",
4
4
  "description": "Client for retrieving, creating and patching data from Sanity.io",
5
5
  "main": "lib/sanityClient.js",
6
6
  "umd": "umd/sanityClient.min.js",
7
7
  "unpkg": "umd/sanityClient.min.js",
8
8
  "types": "./sanityClient.d.ts",
9
- "exports": {
10
- ".": {
11
- "source": "./src/sanityClient.js",
12
- "browser": "./dist/sanityClient.browser.mjs",
13
- "default": "./lib/sanityClient.js"
14
- }
15
- },
16
9
  "files": [
17
10
  "dist",
18
11
  "lib",
@@ -32,7 +25,7 @@
32
25
  "minify": "terser -c -m -- umd/sanityClient.js > umd/sanityClient.min.js",
33
26
  "prepublishOnly": "npm run clean && npm run build",
34
27
  "test": "NODE_ENV=test tape test/*.test.js",
35
- "posttest": "npm run lint && npm run typecheck"
28
+ "posttest": "npm run lint && npm run typecheck --strict"
36
29
  },
37
30
  "browser": {
38
31
  "./src/http/nodeMiddleware.js": "./src/http/browserMiddleware.js",
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>}
@@ -351,14 +351,18 @@ export class Patch extends BasePatch {
351
351
  *
352
352
  * @param options Options for the mutation operation
353
353
  */
354
- 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>>
355
357
 
356
358
  /**
357
359
  * Commit the patch, returning a promise that resolves to an array of the mutated documents
358
360
  *
359
361
  * @param options Options for the mutation operation
360
362
  */
361
- 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>[]>
362
366
 
363
367
  /**
364
368
  * Commit the patch, returning a promise that resolves to a mutation result object
@@ -379,7 +383,9 @@ export class Patch extends BasePatch {
379
383
  *
380
384
  * @param options Options for the mutation operation
381
385
  */
382
- 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>>
383
389
  }
384
390
 
385
391
  export class ObservablePatch extends BasePatch {
@@ -395,14 +401,18 @@ export class ObservablePatch extends BasePatch {
395
401
  *
396
402
  * @param options Options for the mutation operation
397
403
  */
398
- commit<R = any>(options: FirstDocumentMutationOptions): Observable<SanityDocument<R>>
404
+ commit<R extends Record<string, any> = Record<string, any>>(
405
+ options: FirstDocumentMutationOptions
406
+ ): Observable<SanityDocument<R>>
399
407
 
400
408
  /**
401
409
  * Commit the patch, returning an observable that produces an array of the mutated documents
402
410
  *
403
411
  * @param options Options for the mutation operation
404
412
  */
405
- commit<R = any>(options: AllDocumentsMutationOptions): Observable<SanityDocument<R>[]>
413
+ commit<R extends Record<string, any> = Record<string, any>>(
414
+ options: AllDocumentsMutationOptions
415
+ ): Observable<SanityDocument<R>[]>
406
416
 
407
417
  /**
408
418
  * Commit the patch, returning an observable that produces a mutation result object
@@ -423,7 +433,9 @@ export class ObservablePatch extends BasePatch {
423
433
  *
424
434
  * @param options Options for the mutation operation
425
435
  */
426
- commit<R = any>(options?: BaseMutationOptions): Observable<SanityDocument<R>>
436
+ commit<R extends Record<string, any> = Record<string, any>>(
437
+ options?: BaseMutationOptions
438
+ ): Observable<SanityDocument<R>>
427
439
  }
428
440
 
429
441
  export abstract class BaseTransaction {
@@ -433,7 +445,7 @@ export abstract class BaseTransaction {
433
445
  *
434
446
  * @param doc Document to create. Requires a `_type` property.
435
447
  */
436
- create<R = any>(doc: SanityDocumentStub<R>): this
448
+ create<R extends Record<string, any> = Record<string, any>>(doc: SanityDocumentStub<R>): this
437
449
 
438
450
  /**
439
451
  * Creates a new Sanity document. If a document with the same `_id` already exists, the create operation will be ignored.
@@ -441,7 +453,9 @@ export abstract class BaseTransaction {
441
453
  *
442
454
  * @param doc Document to create if it does not already exist. Requires `_id` and `_type` properties.
443
455
  */
444
- createIfNotExists<R = any>(doc: IdentifiedSanityDocumentStub<R>): this
456
+ createIfNotExists<R extends Record<string, any> = Record<string, any>>(
457
+ doc: IdentifiedSanityDocumentStub<R>
458
+ ): this
445
459
 
446
460
  /**
447
461
  * Creates a new Sanity document, or replaces an existing one if the same `_id` is already used.
@@ -449,7 +463,9 @@ export abstract class BaseTransaction {
449
463
  *
450
464
  * @param doc Document to create or replace. Requires `_id` and `_type` properties.
451
465
  */
452
- createOrReplace<R = any>(doc: IdentifiedSanityDocumentStub<R>): this
466
+ createOrReplace<R extends Record<string, any> = Record<string, any>>(
467
+ doc: IdentifiedSanityDocumentStub<R>
468
+ ): this
453
469
 
454
470
  /**
455
471
  * Deletes the document with the given document ID
@@ -514,14 +530,18 @@ export class Transaction extends BaseTransaction {
514
530
  *
515
531
  * @param options Options for the mutation operation
516
532
  */
517
- commit<R>(options: TransactionFirstDocumentMutationOptions): Promise<SanityDocument<R>>
533
+ commit<R extends Record<string, any>>(
534
+ options: TransactionFirstDocumentMutationOptions
535
+ ): Promise<SanityDocument<R>>
518
536
 
519
537
  /**
520
538
  * Commit the transaction, returning a promise that resolves to an array of the mutated documents
521
539
  *
522
540
  * @param options Options for the mutation operation
523
541
  */
524
- commit<R>(options: TransactionAllDocumentsMutationOptions): Promise<SanityDocument<R>[]>
542
+ commit<R extends Record<string, any>>(
543
+ options: TransactionAllDocumentsMutationOptions
544
+ ): Promise<SanityDocument<R>[]>
525
545
 
526
546
  /**
527
547
  * Commit the transaction, returning a promise that resolves to a mutation result object
@@ -545,7 +565,7 @@ export class Transaction extends BaseTransaction {
545
565
  commit(options?: BaseMutationOptions): Promise<MultipleMutationResult>
546
566
  }
547
567
 
548
- export class ObservableTransaction {
568
+ export class ObservableTransaction extends BaseTransaction {
549
569
  constructor(operations?: Mutation[], client?: ObservableSanityClient, transactionId?: string)
550
570
 
551
571
  /**
@@ -558,14 +578,18 @@ export class ObservableTransaction {
558
578
  *
559
579
  * @param options Options for the mutation operation
560
580
  */
561
- commit<R>(options: TransactionFirstDocumentMutationOptions): Observable<SanityDocument<R>>
581
+ commit<R extends Record<string, any>>(
582
+ options: TransactionFirstDocumentMutationOptions
583
+ ): Observable<SanityDocument<R>>
562
584
 
563
585
  /**
564
586
  * Commit the transaction, returning an observable that produces an array of the mutated documents
565
587
  *
566
588
  * @param options Options for the mutation operation
567
589
  */
568
- commit<R>(options: TransactionAllDocumentsMutationOptions): Observable<SanityDocument<R>[]>
590
+ commit<R extends Record<string, any>>(
591
+ options: TransactionAllDocumentsMutationOptions
592
+ ): Observable<SanityDocument<R>[]>
569
593
 
570
594
  /**
571
595
  * Commit the transaction, returning an observable that produces a mutation result object
@@ -642,7 +666,7 @@ type BaseMutationOptions = RequestOptions & {
642
666
  skipCrossDatasetReferenceValidation?: boolean
643
667
  }
644
668
 
645
- export type MutationEvent<R = any> = {
669
+ export type MutationEvent<R extends Record<string, any> = Record<string, any>> = {
646
670
  type: 'mutation'
647
671
  documentId: string
648
672
  eventId: string
@@ -677,7 +701,7 @@ export type WelcomeEvent = {
677
701
  type: 'welcome'
678
702
  }
679
703
 
680
- export type ListenEvent<R> =
704
+ export type ListenEvent<R extends Record<string, any>> =
681
705
  | MutationEvent<R>
682
706
  | ChannelErrorEvent
683
707
  | DisconnectEvent
@@ -1069,7 +1093,7 @@ export class ObservableSanityClient {
1069
1093
  *
1070
1094
  * @param query GROQ-query to perform
1071
1095
  */
1072
- fetch<R = any>(query: string): Observable<R>
1096
+ fetch<R extends Record<string, any> = Record<string, any>>(query: string): Observable<R>
1073
1097
 
1074
1098
  /**
1075
1099
  * Perform a GROQ-query against the configured dataset.
@@ -1077,7 +1101,10 @@ export class ObservableSanityClient {
1077
1101
  * @param query GROQ-query to perform
1078
1102
  * @param params Query parameters
1079
1103
  */
1080
- fetch<R = any>(query: string, params: QueryParams): Observable<R>
1104
+ fetch<R extends Record<string, any> = Record<string, any>>(
1105
+ query: string,
1106
+ params: QueryParams
1107
+ ): Observable<R>
1081
1108
 
1082
1109
  /**
1083
1110
  * Perform a GROQ-query against the configured dataset.
@@ -1086,7 +1113,7 @@ export class ObservableSanityClient {
1086
1113
  * @param params Query parameters
1087
1114
  * @param options Request options
1088
1115
  */
1089
- fetch<R = any>(
1116
+ fetch<R extends Record<string, any> = Record<string, any>>(
1090
1117
  query: string,
1091
1118
  params: QueryParams | undefined,
1092
1119
  options: FilteredResponseQueryOptions
@@ -1099,7 +1126,7 @@ export class ObservableSanityClient {
1099
1126
  * @param params Query parameters
1100
1127
  * @param options Request options
1101
1128
  */
1102
- fetch<R = any>(
1129
+ fetch<R extends Record<string, any> = Record<string, any>>(
1103
1130
  query: string,
1104
1131
  params: QueryParams | undefined,
1105
1132
  options: UnfilteredResponseQueryOptions
@@ -1111,7 +1138,7 @@ export class ObservableSanityClient {
1111
1138
  * @param id Document ID to fetch
1112
1139
  * @param options Request options
1113
1140
  */
1114
- getDocument<R = any>(
1141
+ getDocument<R extends Record<string, any> = Record<string, any>>(
1115
1142
  id: string,
1116
1143
  options?: {tag?: string}
1117
1144
  ): Observable<SanityDocument<R> | undefined>
@@ -1125,7 +1152,7 @@ export class ObservableSanityClient {
1125
1152
  * @param ids Document IDs to fetch
1126
1153
  * @param options Request options
1127
1154
  */
1128
- getDocuments<R = any>(
1155
+ getDocuments<R extends Record<string, any> = Record<string, any>>(
1129
1156
  ids: string[],
1130
1157
  options?: {tag?: string}
1131
1158
  ): Observable<(SanityDocument<R> | null)[]>
@@ -1137,7 +1164,7 @@ export class ObservableSanityClient {
1137
1164
  * @param document Document to create
1138
1165
  * @param options Mutation options
1139
1166
  */
1140
- create<R = any>(
1167
+ create<R extends Record<string, any> = Record<string, any>>(
1141
1168
  document: SanityDocumentStub<R>,
1142
1169
  options: FirstDocumentMutationOptions
1143
1170
  ): Observable<SanityDocument<R>>
@@ -1149,7 +1176,7 @@ export class ObservableSanityClient {
1149
1176
  * @param document Document to create
1150
1177
  * @param options Mutation options
1151
1178
  */
1152
- create<R = any>(
1179
+ create<R extends Record<string, any> = Record<string, any>>(
1153
1180
  document: SanityDocumentStub<R>,
1154
1181
  options: AllDocumentsMutationOptions
1155
1182
  ): Observable<SanityDocument<R>[]>
@@ -1161,7 +1188,7 @@ export class ObservableSanityClient {
1161
1188
  * @param document Document to create
1162
1189
  * @param options Mutation options
1163
1190
  */
1164
- create<R = any>(
1191
+ create<R extends Record<string, any> = Record<string, any>>(
1165
1192
  document: SanityDocumentStub<R>,
1166
1193
  options: FirstDocumentIdMutationOptions
1167
1194
  ): Observable<SingleMutationResult>
@@ -1173,7 +1200,7 @@ export class ObservableSanityClient {
1173
1200
  * @param document Document to create
1174
1201
  * @param options Mutation options
1175
1202
  */
1176
- create<R = any>(
1203
+ create<R extends Record<string, any> = Record<string, any>>(
1177
1204
  document: SanityDocumentStub<R>,
1178
1205
  options: AllDocumentIdsMutationOptions
1179
1206
  ): Observable<MultipleMutationResult>
@@ -1185,7 +1212,7 @@ export class ObservableSanityClient {
1185
1212
  * @param document Document to create
1186
1213
  * @param options Mutation options
1187
1214
  */
1188
- create<R = any>(
1215
+ create<R extends Record<string, any> = Record<string, any>>(
1189
1216
  document: SanityDocumentStub<R>,
1190
1217
  options?: BaseMutationOptions
1191
1218
  ): Observable<SanityDocument<R>>
@@ -1197,7 +1224,7 @@ export class ObservableSanityClient {
1197
1224
  * @param document Document to create
1198
1225
  * @param options Mutation options
1199
1226
  */
1200
- createIfNotExists<R = any>(
1227
+ createIfNotExists<R extends Record<string, any> = Record<string, any>>(
1201
1228
  document: IdentifiedSanityDocumentStub<R>,
1202
1229
  options: FirstDocumentMutationOptions
1203
1230
  ): Observable<SanityDocument<R>>
@@ -1209,7 +1236,7 @@ export class ObservableSanityClient {
1209
1236
  * @param document Document to create
1210
1237
  * @param options Mutation options
1211
1238
  */
1212
- createIfNotExists<R = any>(
1239
+ createIfNotExists<R extends Record<string, any> = Record<string, any>>(
1213
1240
  document: IdentifiedSanityDocumentStub<R>,
1214
1241
  options: AllDocumentsMutationOptions
1215
1242
  ): Observable<SanityDocument<R>[]>
@@ -1221,7 +1248,7 @@ export class ObservableSanityClient {
1221
1248
  * @param document Document to create
1222
1249
  * @param options Mutation options
1223
1250
  */
1224
- createIfNotExists<R = any>(
1251
+ createIfNotExists<R extends Record<string, any> = Record<string, any>>(
1225
1252
  document: IdentifiedSanityDocumentStub<R>,
1226
1253
  options: FirstDocumentIdMutationOptions
1227
1254
  ): Observable<SingleMutationResult>
@@ -1233,7 +1260,7 @@ export class ObservableSanityClient {
1233
1260
  * @param document Document to create
1234
1261
  * @param options Mutation options
1235
1262
  */
1236
- createIfNotExists<R = any>(
1263
+ createIfNotExists<R extends Record<string, any> = Record<string, any>>(
1237
1264
  document: IdentifiedSanityDocumentStub<R>,
1238
1265
  options: AllDocumentIdsMutationOptions
1239
1266
  ): Observable<MultipleMutationResult>
@@ -1245,7 +1272,7 @@ export class ObservableSanityClient {
1245
1272
  * @param document Document to create
1246
1273
  * @param options Mutation options
1247
1274
  */
1248
- createIfNotExists<R = any>(
1275
+ createIfNotExists<R extends Record<string, any> = Record<string, any>>(
1249
1276
  document: IdentifiedSanityDocumentStub<R>,
1250
1277
  options?: BaseMutationOptions
1251
1278
  ): Observable<SanityDocument<R>>
@@ -1257,7 +1284,7 @@ export class ObservableSanityClient {
1257
1284
  * @param document Document to either create or replace
1258
1285
  * @param options Mutation options
1259
1286
  */
1260
- createOrReplace<R = any>(
1287
+ createOrReplace<R extends Record<string, any> = Record<string, any>>(
1261
1288
  document: IdentifiedSanityDocumentStub<R>,
1262
1289
  options: FirstDocumentMutationOptions
1263
1290
  ): Observable<SanityDocument<R>>
@@ -1269,7 +1296,7 @@ export class ObservableSanityClient {
1269
1296
  * @param document Document to either create or replace
1270
1297
  * @param options Mutation options
1271
1298
  */
1272
- createOrReplace<R = any>(
1299
+ createOrReplace<R extends Record<string, any> = Record<string, any>>(
1273
1300
  document: IdentifiedSanityDocumentStub<R>,
1274
1301
  options: AllDocumentsMutationOptions
1275
1302
  ): Observable<SanityDocument<R>[]>
@@ -1281,7 +1308,7 @@ export class ObservableSanityClient {
1281
1308
  * @param document Document to either create or replace
1282
1309
  * @param options Mutation options
1283
1310
  */
1284
- createOrReplace<R = any>(
1311
+ createOrReplace<R extends Record<string, any> = Record<string, any>>(
1285
1312
  document: IdentifiedSanityDocumentStub<R>,
1286
1313
  options: FirstDocumentIdMutationOptions
1287
1314
  ): Observable<SingleMutationResult>
@@ -1293,7 +1320,7 @@ export class ObservableSanityClient {
1293
1320
  * @param document Document to either create or replace
1294
1321
  * @param options Mutation options
1295
1322
  */
1296
- createOrReplace<R = any>(
1323
+ createOrReplace<R extends Record<string, any> = Record<string, any>>(
1297
1324
  document: IdentifiedSanityDocumentStub<R>,
1298
1325
  options: AllDocumentIdsMutationOptions
1299
1326
  ): Observable<MultipleMutationResult>
@@ -1305,7 +1332,7 @@ export class ObservableSanityClient {
1305
1332
  * @param document Document to either create or replace
1306
1333
  * @param options Mutation options
1307
1334
  */
1308
- createOrReplace<R = any>(
1335
+ createOrReplace<R extends Record<string, any> = Record<string, any>>(
1309
1336
  document: IdentifiedSanityDocumentStub<R>,
1310
1337
  options?: BaseMutationOptions
1311
1338
  ): Observable<SanityDocument<R>>
@@ -1317,7 +1344,10 @@ export class ObservableSanityClient {
1317
1344
  * @param id Document ID to delete
1318
1345
  * @param options Options for the mutation
1319
1346
  */
1320
- delete<R = any>(id: string, options: FirstDocumentMutationOptions): Observable<SanityDocument<R>>
1347
+ delete<R extends Record<string, any> = Record<string, any>>(
1348
+ id: string,
1349
+ options: FirstDocumentMutationOptions
1350
+ ): Observable<SanityDocument<R>>
1321
1351
 
1322
1352
  /**
1323
1353
  * Deletes a document with the given document ID.
@@ -1326,7 +1356,10 @@ export class ObservableSanityClient {
1326
1356
  * @param id Document ID to delete
1327
1357
  * @param options Options for the mutation
1328
1358
  */
1329
- delete<R = any>(id: string, options: AllDocumentsMutationOptions): Observable<SanityDocument<R>[]>
1359
+ delete<R extends Record<string, any> = Record<string, any>>(
1360
+ id: string,
1361
+ options: AllDocumentsMutationOptions
1362
+ ): Observable<SanityDocument<R>[]>
1330
1363
 
1331
1364
  /**
1332
1365
  * Deletes a document with the given document ID.
@@ -1353,7 +1386,10 @@ export class ObservableSanityClient {
1353
1386
  * @param id Document ID to delete
1354
1387
  * @param options Options for the mutation
1355
1388
  */
1356
- delete<R = any>(id: string, options?: BaseMutationOptions): Observable<SanityDocument<R>>
1389
+ delete<R extends Record<string, any> = Record<string, any>>(
1390
+ id: string,
1391
+ options?: BaseMutationOptions
1392
+ ): Observable<SanityDocument<R>>
1357
1393
 
1358
1394
  /**
1359
1395
  * Deletes one or more documents matching the given query or document ID.
@@ -1362,7 +1398,7 @@ export class ObservableSanityClient {
1362
1398
  * @param selection An object with either an `id` or `query` key defining what to delete
1363
1399
  * @param options Options for the mutation
1364
1400
  */
1365
- delete<R = any>(
1401
+ delete<R extends Record<string, any> = Record<string, any>>(
1366
1402
  selection: MutationSelection,
1367
1403
  options: FirstDocumentMutationOptions
1368
1404
  ): Observable<SanityDocument<R>>
@@ -1374,7 +1410,7 @@ export class ObservableSanityClient {
1374
1410
  * @param selection An object with either an `id` or `query` key defining what to delete
1375
1411
  * @param options Options for the mutation
1376
1412
  */
1377
- delete<R = any>(
1413
+ delete<R extends Record<string, any> = Record<string, any>>(
1378
1414
  selection: MutationSelection,
1379
1415
  options: AllDocumentsMutationOptions
1380
1416
  ): Observable<SanityDocument<R>[]>
@@ -1410,7 +1446,7 @@ export class ObservableSanityClient {
1410
1446
  * @param selection An object with either an `id` or `query` key defining what to delete
1411
1447
  * @param options Options for the mutation
1412
1448
  */
1413
- delete<R = any>(
1449
+ delete<R extends Record<string, any> = Record<string, any>>(
1414
1450
  selection: MutationSelection,
1415
1451
  options?: BaseMutationOptions
1416
1452
  ): Observable<SanityDocument<R>>
@@ -1422,7 +1458,7 @@ export class ObservableSanityClient {
1422
1458
  * @param operations Mutation operations to execute
1423
1459
  * @param options Mutation options
1424
1460
  */
1425
- mutate<R = any>(
1461
+ mutate<R extends Record<string, any> = Record<string, any>>(
1426
1462
  operations: Mutation<R>[] | Patch | Transaction,
1427
1463
  options: FirstDocumentMutationOptions
1428
1464
  ): Observable<SanityDocument<R>>
@@ -1434,7 +1470,7 @@ export class ObservableSanityClient {
1434
1470
  * @param operations Mutation operations to execute
1435
1471
  * @param options Mutation options
1436
1472
  */
1437
- mutate<R = any>(
1473
+ mutate<R extends Record<string, any> = Record<string, any>>(
1438
1474
  operations: Mutation<R>[] | Patch | Transaction,
1439
1475
  options: AllDocumentsMutationOptions
1440
1476
  ): Observable<SanityDocument<R>[]>
@@ -1446,7 +1482,7 @@ export class ObservableSanityClient {
1446
1482
  * @param operations Mutation operations to execute
1447
1483
  * @param options Mutation options
1448
1484
  */
1449
- mutate<R = any>(
1485
+ mutate<R extends Record<string, any> = Record<string, any>>(
1450
1486
  operations: Mutation<R>[] | Patch | Transaction,
1451
1487
  options: FirstDocumentIdMutationOptions
1452
1488
  ): Observable<SingleMutationResult>
@@ -1458,7 +1494,7 @@ export class ObservableSanityClient {
1458
1494
  * @param operations Mutation operations to execute
1459
1495
  * @param options Mutation options
1460
1496
  */
1461
- mutate<R = any>(
1497
+ mutate<R extends Record<string, any> = Record<string, any>>(
1462
1498
  operations: Mutation<R>[] | Patch | Transaction,
1463
1499
  options: AllDocumentIdsMutationOptions
1464
1500
  ): Observable<MultipleMutationResult>
@@ -1470,7 +1506,7 @@ export class ObservableSanityClient {
1470
1506
  * @param operations Mutation operations to execute
1471
1507
  * @param options Mutation options
1472
1508
  */
1473
- mutate<R = any>(
1509
+ mutate<R extends Record<string, any> = Record<string, any>>(
1474
1510
  operations: Mutation<R>[] | Patch | Transaction,
1475
1511
  options?: BaseMutationOptions
1476
1512
  ): Observable<SanityDocument<R>>
@@ -1488,7 +1524,9 @@ export class ObservableSanityClient {
1488
1524
  *
1489
1525
  * @param operations Optional array of mutation operations to initialize the transaction instance with
1490
1526
  */
1491
- transaction<R = any>(operations?: Mutation<R>[]): ObservableTransaction
1527
+ transaction<R extends Record<string, any> = Record<string, any>>(
1528
+ operations?: Mutation<R>[]
1529
+ ): ObservableTransaction
1492
1530
 
1493
1531
  // "Internals", should generally not be used externally
1494
1532
  /**
@@ -1705,7 +1743,10 @@ export interface SanityClient {
1705
1743
  * @param params Optional query parameters
1706
1744
  * @param options Listener options
1707
1745
  */
1708
- listen<R = any>(query: string, params?: QueryParams): Observable<MutationEvent<R>>
1746
+ listen<R extends Record<string, any> = Record<string, any>>(
1747
+ query: string,
1748
+ params?: QueryParams
1749
+ ): Observable<MutationEvent<R>>
1709
1750
 
1710
1751
  /**
1711
1752
  * Set up a listener that will be notified when mutations occur on documents matching the provided query/filter.
@@ -1714,7 +1755,7 @@ export interface SanityClient {
1714
1755
  * @param params Optional query parameters
1715
1756
  * @param options Listener options
1716
1757
  */
1717
- listen<R = any>(
1758
+ listen<R extends Record<string, any> = Record<string, any>>(
1718
1759
  query: string,
1719
1760
  params?: QueryParams,
1720
1761
  options?: ListenOptions
@@ -1725,7 +1766,7 @@ export interface SanityClient {
1725
1766
  *
1726
1767
  * @param query GROQ-query to perform
1727
1768
  */
1728
- fetch<R = any>(query: string): Promise<R>
1769
+ fetch<R extends Record<string, any> = Record<string, any>>(query: string): Promise<R>
1729
1770
 
1730
1771
  /**
1731
1772
  * Perform a GROQ-query against the configured dataset.
@@ -1733,7 +1774,10 @@ export interface SanityClient {
1733
1774
  * @param query GROQ-query to perform
1734
1775
  * @param params Optional query parameters
1735
1776
  */
1736
- fetch<R = any>(query: string, params: QueryParams): Promise<R>
1777
+ fetch<R extends Record<string, any> = Record<string, any>>(
1778
+ query: string,
1779
+ params: QueryParams
1780
+ ): Promise<R>
1737
1781
 
1738
1782
  /**
1739
1783
  * Perform a GROQ-query against the configured dataset.
@@ -1742,7 +1786,7 @@ export interface SanityClient {
1742
1786
  * @param params Optional query parameters
1743
1787
  * @param options Request options
1744
1788
  */
1745
- fetch<R = any>(
1789
+ fetch<R extends Record<string, any> = Record<string, any>>(
1746
1790
  query: string,
1747
1791
  params: QueryParams | undefined,
1748
1792
  options: FilteredResponseQueryOptions
@@ -1755,7 +1799,7 @@ export interface SanityClient {
1755
1799
  * @param params Optional query parameters
1756
1800
  * @param options Request options
1757
1801
  */
1758
- fetch<R = any>(
1802
+ fetch<R extends Record<string, any> = Record<string, any>>(
1759
1803
  query: string,
1760
1804
  params: QueryParams | undefined,
1761
1805
  options: UnfilteredResponseQueryOptions
@@ -1767,7 +1811,10 @@ export interface SanityClient {
1767
1811
  * @param id Document ID to fetch
1768
1812
  * @param options Request options
1769
1813
  */
1770
- getDocument<R = any>(id: string, options?: {tag?: string}): Promise<SanityDocument<R> | undefined>
1814
+ getDocument<R extends Record<string, any> = Record<string, any>>(
1815
+ id: string,
1816
+ options?: {tag?: string}
1817
+ ): Promise<SanityDocument<R> | undefined>
1771
1818
 
1772
1819
  /**
1773
1820
  * Fetch multiple documents in one request.
@@ -1778,7 +1825,7 @@ export interface SanityClient {
1778
1825
  * @param ids Document IDs to fetch
1779
1826
  * @param options Request options
1780
1827
  */
1781
- getDocuments<R = any>(
1828
+ getDocuments<R extends Record<string, any> = Record<string, any>>(
1782
1829
  ids: string[],
1783
1830
  options?: {tag?: string}
1784
1831
  ): Promise<(SanityDocument<R> | null)[]>
@@ -1790,7 +1837,7 @@ export interface SanityClient {
1790
1837
  * @param document Document to create
1791
1838
  * @param options Mutation options
1792
1839
  */
1793
- create<R = any>(
1840
+ create<R extends Record<string, any> = Record<string, any>>(
1794
1841
  document: SanityDocumentStub<R>,
1795
1842
  options: FirstDocumentMutationOptions
1796
1843
  ): Promise<SanityDocument<R>>
@@ -1802,7 +1849,7 @@ export interface SanityClient {
1802
1849
  * @param document Document to create
1803
1850
  * @param options Mutation options
1804
1851
  */
1805
- create<R = any>(
1852
+ create<R extends Record<string, any> = Record<string, any>>(
1806
1853
  document: SanityDocumentStub<R>,
1807
1854
  options: AllDocumentsMutationOptions
1808
1855
  ): Promise<SanityDocument<R>[]>
@@ -1814,7 +1861,7 @@ export interface SanityClient {
1814
1861
  * @param document Document to create
1815
1862
  * @param options Mutation options
1816
1863
  */
1817
- create<R = any>(
1864
+ create<R extends Record<string, any> = Record<string, any>>(
1818
1865
  document: SanityDocumentStub<R>,
1819
1866
  options: FirstDocumentIdMutationOptions
1820
1867
  ): Promise<SingleMutationResult>
@@ -1826,7 +1873,7 @@ export interface SanityClient {
1826
1873
  * @param document Document to create
1827
1874
  * @param options Mutation options
1828
1875
  */
1829
- create<R = any>(
1876
+ create<R extends Record<string, any> = Record<string, any>>(
1830
1877
  document: SanityDocumentStub<R>,
1831
1878
  options: AllDocumentIdsMutationOptions
1832
1879
  ): Promise<MultipleMutationResult>
@@ -1838,7 +1885,7 @@ export interface SanityClient {
1838
1885
  * @param document Document to create
1839
1886
  * @param options Mutation options
1840
1887
  */
1841
- create<R = any>(
1888
+ create<R extends Record<string, any> = Record<string, any>>(
1842
1889
  document: SanityDocumentStub<R>,
1843
1890
  options?: BaseMutationOptions
1844
1891
  ): Promise<SanityDocument<R>>
@@ -1850,7 +1897,7 @@ export interface SanityClient {
1850
1897
  * @param document Document to create
1851
1898
  * @param options Mutation options
1852
1899
  */
1853
- createIfNotExists<R = any>(
1900
+ createIfNotExists<R extends Record<string, any> = Record<string, any>>(
1854
1901
  document: IdentifiedSanityDocumentStub<R>,
1855
1902
  options: FirstDocumentMutationOptions
1856
1903
  ): Promise<SanityDocument<R>>
@@ -1862,7 +1909,7 @@ export interface SanityClient {
1862
1909
  * @param document Document to create
1863
1910
  * @param options Mutation options
1864
1911
  */
1865
- createIfNotExists<R = any>(
1912
+ createIfNotExists<R extends Record<string, any> = Record<string, any>>(
1866
1913
  document: IdentifiedSanityDocumentStub<R>,
1867
1914
  options: AllDocumentsMutationOptions
1868
1915
  ): Promise<SanityDocument<R>[]>
@@ -1874,7 +1921,7 @@ export interface SanityClient {
1874
1921
  * @param document Document to create
1875
1922
  * @param options Mutation options
1876
1923
  */
1877
- createIfNotExists<R = any>(
1924
+ createIfNotExists<R extends Record<string, any> = Record<string, any>>(
1878
1925
  document: IdentifiedSanityDocumentStub<R>,
1879
1926
  options: FirstDocumentIdMutationOptions
1880
1927
  ): Promise<SingleMutationResult>
@@ -1886,7 +1933,7 @@ export interface SanityClient {
1886
1933
  * @param document Document to create
1887
1934
  * @param options Mutation options
1888
1935
  */
1889
- createIfNotExists<R = any>(
1936
+ createIfNotExists<R extends Record<string, any> = Record<string, any>>(
1890
1937
  document: IdentifiedSanityDocumentStub<R>,
1891
1938
  options: AllDocumentIdsMutationOptions
1892
1939
  ): Promise<MultipleMutationResult>
@@ -1898,7 +1945,7 @@ export interface SanityClient {
1898
1945
  * @param document Document to create
1899
1946
  * @param options Mutation options
1900
1947
  */
1901
- createIfNotExists<R = any>(
1948
+ createIfNotExists<R extends Record<string, any> = Record<string, any>>(
1902
1949
  document: IdentifiedSanityDocumentStub<R>,
1903
1950
  options?: BaseMutationOptions
1904
1951
  ): Promise<SanityDocument<R>>
@@ -1910,7 +1957,7 @@ export interface SanityClient {
1910
1957
  * @param document Document to either create or replace
1911
1958
  * @param options Mutation options
1912
1959
  */
1913
- createOrReplace<R = any>(
1960
+ createOrReplace<R extends Record<string, any> = Record<string, any>>(
1914
1961
  document: IdentifiedSanityDocumentStub<R>,
1915
1962
  options: FirstDocumentMutationOptions
1916
1963
  ): Promise<SanityDocument<R>>
@@ -1922,7 +1969,7 @@ export interface SanityClient {
1922
1969
  * @param document Document to either create or replace
1923
1970
  * @param options Mutation options
1924
1971
  */
1925
- createOrReplace<R = any>(
1972
+ createOrReplace<R extends Record<string, any> = Record<string, any>>(
1926
1973
  document: IdentifiedSanityDocumentStub<R>,
1927
1974
  options: AllDocumentsMutationOptions
1928
1975
  ): Promise<SanityDocument<R>[]>
@@ -1934,7 +1981,7 @@ export interface SanityClient {
1934
1981
  * @param document Document to either create or replace
1935
1982
  * @param options Mutation options
1936
1983
  */
1937
- createOrReplace<R = any>(
1984
+ createOrReplace<R extends Record<string, any> = Record<string, any>>(
1938
1985
  document: IdentifiedSanityDocumentStub<R>,
1939
1986
  options: FirstDocumentIdMutationOptions
1940
1987
  ): Promise<SingleMutationResult>
@@ -1946,7 +1993,7 @@ export interface SanityClient {
1946
1993
  * @param document Document to either create or replace
1947
1994
  * @param options Mutation options
1948
1995
  */
1949
- createOrReplace<R = any>(
1996
+ createOrReplace<R extends Record<string, any> = Record<string, any>>(
1950
1997
  document: IdentifiedSanityDocumentStub<R>,
1951
1998
  options: AllDocumentIdsMutationOptions
1952
1999
  ): Promise<MultipleMutationResult>
@@ -1958,7 +2005,7 @@ export interface SanityClient {
1958
2005
  * @param document Document to either create or replace
1959
2006
  * @param options Mutation options
1960
2007
  */
1961
- createOrReplace<R = any>(
2008
+ createOrReplace<R extends Record<string, any> = Record<string, any>>(
1962
2009
  document: IdentifiedSanityDocumentStub<R>,
1963
2010
  options?: BaseMutationOptions
1964
2011
  ): Promise<SanityDocument<R>>
@@ -1970,7 +2017,10 @@ export interface SanityClient {
1970
2017
  * @param id Document ID to delete
1971
2018
  * @param options Options for the mutation
1972
2019
  */
1973
- delete<R = any>(id: string, options: FirstDocumentMutationOptions): Promise<SanityDocument<R>>
2020
+ delete<R extends Record<string, any> = Record<string, any>>(
2021
+ id: string,
2022
+ options: FirstDocumentMutationOptions
2023
+ ): Promise<SanityDocument<R>>
1974
2024
 
1975
2025
  /**
1976
2026
  * Deletes a document with the given document ID.
@@ -1979,7 +2029,10 @@ export interface SanityClient {
1979
2029
  * @param id Document ID to delete
1980
2030
  * @param options Options for the mutation
1981
2031
  */
1982
- delete<R = any>(id: string, options: AllDocumentsMutationOptions): Promise<SanityDocument<R>[]>
2032
+ delete<R extends Record<string, any> = Record<string, any>>(
2033
+ id: string,
2034
+ options: AllDocumentsMutationOptions
2035
+ ): Promise<SanityDocument<R>[]>
1983
2036
 
1984
2037
  /**
1985
2038
  * Deletes a document with the given document ID.
@@ -2006,7 +2059,10 @@ export interface SanityClient {
2006
2059
  * @param id Document ID to delete
2007
2060
  * @param options Options for the mutation
2008
2061
  */
2009
- delete<R = any>(id: string, options?: BaseMutationOptions): Promise<SanityDocument<R>>
2062
+ delete<R extends Record<string, any> = Record<string, any>>(
2063
+ id: string,
2064
+ options?: BaseMutationOptions
2065
+ ): Promise<SanityDocument<R>>
2010
2066
 
2011
2067
  /**
2012
2068
  * Deletes one or more documents matching the given query or document ID.
@@ -2015,7 +2071,7 @@ export interface SanityClient {
2015
2071
  * @param selection An object with either an `id` or `query` key defining what to delete
2016
2072
  * @param options Options for the mutation
2017
2073
  */
2018
- delete<R = any>(
2074
+ delete<R extends Record<string, any> = Record<string, any>>(
2019
2075
  selection: MutationSelection,
2020
2076
  options: FirstDocumentMutationOptions
2021
2077
  ): Promise<SanityDocument<R>>
@@ -2027,7 +2083,7 @@ export interface SanityClient {
2027
2083
  * @param selection An object with either an `id` or `query` key defining what to delete
2028
2084
  * @param options Options for the mutation
2029
2085
  */
2030
- delete<R = any>(
2086
+ delete<R extends Record<string, any> = Record<string, any>>(
2031
2087
  selection: MutationSelection,
2032
2088
  options: AllDocumentsMutationOptions
2033
2089
  ): Promise<SanityDocument<R>[]>
@@ -2063,7 +2119,7 @@ export interface SanityClient {
2063
2119
  * @param selection An object with either an `id` or `query` key defining what to delete
2064
2120
  * @param options Options for the mutation
2065
2121
  */
2066
- delete<R = any>(
2122
+ delete<R extends Record<string, any> = Record<string, any>>(
2067
2123
  selection: MutationSelection,
2068
2124
  options?: BaseMutationOptions
2069
2125
  ): Promise<SanityDocument<R>>
@@ -2075,7 +2131,7 @@ export interface SanityClient {
2075
2131
  * @param operations Mutation operations to execute
2076
2132
  * @param options Mutation options
2077
2133
  */
2078
- mutate<R = any>(
2134
+ mutate<R extends Record<string, any> = Record<string, any>>(
2079
2135
  operations: Mutation<R>[] | Patch | Transaction,
2080
2136
  options: FirstDocumentMutationOptions
2081
2137
  ): Promise<SanityDocument<R>>
@@ -2087,7 +2143,7 @@ export interface SanityClient {
2087
2143
  * @param operations Mutation operations to execute
2088
2144
  * @param options Mutation options
2089
2145
  */
2090
- mutate<R = any>(
2146
+ mutate<R extends Record<string, any> = Record<string, any>>(
2091
2147
  operations: Mutation<R>[] | Patch | Transaction,
2092
2148
  options: AllDocumentsMutationOptions
2093
2149
  ): Promise<SanityDocument<R>[]>
@@ -2099,7 +2155,7 @@ export interface SanityClient {
2099
2155
  * @param operations Mutation operations to execute
2100
2156
  * @param options Mutation options
2101
2157
  */
2102
- mutate<R = any>(
2158
+ mutate<R extends Record<string, any> = Record<string, any>>(
2103
2159
  operations: Mutation<R>[] | Patch | Transaction,
2104
2160
  options: FirstDocumentIdMutationOptions
2105
2161
  ): Promise<SingleMutationResult>
@@ -2111,7 +2167,7 @@ export interface SanityClient {
2111
2167
  * @param operations Mutation operations to execute
2112
2168
  * @param options Mutation options
2113
2169
  */
2114
- mutate<R>(
2170
+ mutate<R extends Record<string, any>>(
2115
2171
  operations: Mutation<R>[] | Patch | Transaction,
2116
2172
  options: AllDocumentIdsMutationOptions
2117
2173
  ): Promise<MultipleMutationResult>
@@ -2123,7 +2179,7 @@ export interface SanityClient {
2123
2179
  * @param operations Mutation operations to execute
2124
2180
  * @param options Mutation options
2125
2181
  */
2126
- mutate<R = any>(
2182
+ mutate<R extends Record<string, any> = Record<string, any>>(
2127
2183
  operations: Mutation<R>[] | Patch | Transaction,
2128
2184
  options?: BaseMutationOptions
2129
2185
  ): Promise<SanityDocument<R>>
@@ -2141,7 +2197,9 @@ export interface SanityClient {
2141
2197
  *
2142
2198
  * @param operations Optional array of mutation operations to initialize the transaction instance with
2143
2199
  */
2144
- transaction<R = any>(operations?: Mutation<R>[]): Transaction
2200
+ transaction<R extends Record<string, any> = Record<string, any>>(
2201
+ operations?: Mutation<R>[]
2202
+ ): Transaction
2145
2203
 
2146
2204
  // "Internals", should generally not be used externally
2147
2205
  /**