@sanity/client 6.2.0-fetch.6 → 6.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.browser.cjs +13 -19
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.js +13 -19
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +14 -20
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +105 -97
- package/dist/index.js +14 -20
- package/dist/index.js.map +1 -1
- package/package.json +23 -19
- package/src/SanityClient.ts +83 -83
- package/src/assets/AssetsClient.ts +13 -13
- package/src/config.ts +3 -4
- package/src/data/dataMethods.ts +20 -21
- package/src/data/listen.ts +3 -3
- package/src/data/patch.ts +11 -11
- package/src/data/transaction.ts +13 -13
- package/src/datasets/DatasetsClient.ts +4 -4
- package/src/http/request.ts +1 -1
- package/src/http/requestOptions.ts +1 -1
- package/src/index.browser.ts +1 -1
- package/src/index.ts +1 -1
- package/src/projects/ProjectsClient.ts +21 -9
- package/src/users/UsersClient.ts +4 -4
- package/src/validators.ts +2 -2
- package/src/warnings.ts +1 -1
- package/umd/sanityClient.js +57 -30
- package/umd/sanityClient.min.js +3 -3
package/src/SanityClient.ts
CHANGED
|
@@ -98,7 +98,7 @@ export class ObservableSanityClient {
|
|
|
98
98
|
|
|
99
99
|
if (this.#clientConfig && this.#clientConfig.allowReconfigure === false) {
|
|
100
100
|
throw new Error(
|
|
101
|
-
'Existing client instance cannot be reconfigured - use `withConfig(newConfig)` to return a new client'
|
|
101
|
+
'Existing client instance cannot be reconfigured - use `withConfig(newConfig)` to return a new client',
|
|
102
102
|
)
|
|
103
103
|
}
|
|
104
104
|
|
|
@@ -138,7 +138,7 @@ export class ObservableSanityClient {
|
|
|
138
138
|
fetch<R = Any, Q = QueryParams>(
|
|
139
139
|
query: string,
|
|
140
140
|
params: Q | undefined,
|
|
141
|
-
options: FilteredResponseQueryOptions
|
|
141
|
+
options: FilteredResponseQueryOptions,
|
|
142
142
|
): Observable<R>
|
|
143
143
|
/**
|
|
144
144
|
* Perform a GROQ-query against the configured dataset.
|
|
@@ -150,12 +150,12 @@ export class ObservableSanityClient {
|
|
|
150
150
|
fetch<R = Any, Q = QueryParams>(
|
|
151
151
|
query: string,
|
|
152
152
|
params: Q | undefined,
|
|
153
|
-
options: UnfilteredResponseQueryOptions
|
|
153
|
+
options: UnfilteredResponseQueryOptions,
|
|
154
154
|
): Observable<RawQueryResponse<R>>
|
|
155
155
|
fetch<R, Q extends QueryParams>(
|
|
156
156
|
query: string,
|
|
157
157
|
params?: Q,
|
|
158
|
-
options: FilteredResponseQueryOptions | UnfilteredResponseQueryOptions = {}
|
|
158
|
+
options: FilteredResponseQueryOptions | UnfilteredResponseQueryOptions = {},
|
|
159
159
|
): Observable<RawQueryResponse<R> | R> {
|
|
160
160
|
return dataMethods._fetch<R, Q>(this, this.#httpRequest, query, params, options)
|
|
161
161
|
}
|
|
@@ -168,7 +168,7 @@ export class ObservableSanityClient {
|
|
|
168
168
|
*/
|
|
169
169
|
getDocument<R extends Record<string, Any> = Record<string, Any>>(
|
|
170
170
|
id: string,
|
|
171
|
-
options?: {tag?: string}
|
|
171
|
+
options?: {tag?: string},
|
|
172
172
|
): Observable<SanityDocument<R> | undefined> {
|
|
173
173
|
return dataMethods._getDocument<R>(this, this.#httpRequest, id, options)
|
|
174
174
|
}
|
|
@@ -184,7 +184,7 @@ export class ObservableSanityClient {
|
|
|
184
184
|
*/
|
|
185
185
|
getDocuments<R extends Record<string, Any> = Record<string, Any>>(
|
|
186
186
|
ids: string[],
|
|
187
|
-
options?: {tag?: string}
|
|
187
|
+
options?: {tag?: string},
|
|
188
188
|
): Observable<(SanityDocument<R> | null)[]> {
|
|
189
189
|
return dataMethods._getDocuments<R>(this, this.#httpRequest, ids, options)
|
|
190
190
|
}
|
|
@@ -198,7 +198,7 @@ export class ObservableSanityClient {
|
|
|
198
198
|
*/
|
|
199
199
|
create<R extends Record<string, Any> = Record<string, Any>>(
|
|
200
200
|
document: SanityDocumentStub<R>,
|
|
201
|
-
options: FirstDocumentMutationOptions
|
|
201
|
+
options: FirstDocumentMutationOptions,
|
|
202
202
|
): Observable<SanityDocument<R>>
|
|
203
203
|
/**
|
|
204
204
|
* Create a document. Requires a `_type` property. If no `_id` is provided, it will be generated by the database.
|
|
@@ -209,7 +209,7 @@ export class ObservableSanityClient {
|
|
|
209
209
|
*/
|
|
210
210
|
create<R extends Record<string, Any> = Record<string, Any>>(
|
|
211
211
|
document: SanityDocumentStub<R>,
|
|
212
|
-
options: AllDocumentsMutationOptions
|
|
212
|
+
options: AllDocumentsMutationOptions,
|
|
213
213
|
): Observable<SanityDocument<R>[]>
|
|
214
214
|
/**
|
|
215
215
|
* Create a document. Requires a `_type` property. If no `_id` is provided, it will be generated by the database.
|
|
@@ -220,7 +220,7 @@ export class ObservableSanityClient {
|
|
|
220
220
|
*/
|
|
221
221
|
create<R extends Record<string, Any> = Record<string, Any>>(
|
|
222
222
|
document: SanityDocumentStub<R>,
|
|
223
|
-
options: FirstDocumentIdMutationOptions
|
|
223
|
+
options: FirstDocumentIdMutationOptions,
|
|
224
224
|
): Observable<SingleMutationResult>
|
|
225
225
|
/**
|
|
226
226
|
* Create a document. Requires a `_type` property. If no `_id` is provided, it will be generated by the database.
|
|
@@ -231,7 +231,7 @@ export class ObservableSanityClient {
|
|
|
231
231
|
*/
|
|
232
232
|
create<R extends Record<string, Any> = Record<string, Any>>(
|
|
233
233
|
document: SanityDocumentStub<R>,
|
|
234
|
-
options: AllDocumentIdsMutationOptions
|
|
234
|
+
options: AllDocumentIdsMutationOptions,
|
|
235
235
|
): Observable<MultipleMutationResult>
|
|
236
236
|
/**
|
|
237
237
|
* Create a document. Requires a `_type` property. If no `_id` is provided, it will be generated by the database.
|
|
@@ -242,7 +242,7 @@ export class ObservableSanityClient {
|
|
|
242
242
|
*/
|
|
243
243
|
create<R extends Record<string, Any> = Record<string, Any>>(
|
|
244
244
|
document: SanityDocumentStub<R>,
|
|
245
|
-
options?: BaseMutationOptions
|
|
245
|
+
options?: BaseMutationOptions,
|
|
246
246
|
): Observable<SanityDocument<R>>
|
|
247
247
|
create<R extends Record<string, Any> = Record<string, Any>>(
|
|
248
248
|
document: SanityDocumentStub<R>,
|
|
@@ -251,7 +251,7 @@ export class ObservableSanityClient {
|
|
|
251
251
|
| AllDocumentsMutationOptions
|
|
252
252
|
| BaseMutationOptions
|
|
253
253
|
| FirstDocumentIdMutationOptions
|
|
254
|
-
| FirstDocumentMutationOptions
|
|
254
|
+
| FirstDocumentMutationOptions,
|
|
255
255
|
): Observable<
|
|
256
256
|
SanityDocument<R> | SanityDocument<R>[] | SingleMutationResult | MultipleMutationResult
|
|
257
257
|
> {
|
|
@@ -267,7 +267,7 @@ export class ObservableSanityClient {
|
|
|
267
267
|
*/
|
|
268
268
|
createIfNotExists<R extends Record<string, Any> = Record<string, Any>>(
|
|
269
269
|
document: IdentifiedSanityDocumentStub<R>,
|
|
270
|
-
options: FirstDocumentMutationOptions
|
|
270
|
+
options: FirstDocumentMutationOptions,
|
|
271
271
|
): Observable<SanityDocument<R>>
|
|
272
272
|
/**
|
|
273
273
|
* Create a document if no document with the same ID already exists.
|
|
@@ -278,7 +278,7 @@ export class ObservableSanityClient {
|
|
|
278
278
|
*/
|
|
279
279
|
createIfNotExists<R extends Record<string, Any> = Record<string, Any>>(
|
|
280
280
|
document: IdentifiedSanityDocumentStub<R>,
|
|
281
|
-
options: AllDocumentsMutationOptions
|
|
281
|
+
options: AllDocumentsMutationOptions,
|
|
282
282
|
): Observable<SanityDocument<R>[]>
|
|
283
283
|
/**
|
|
284
284
|
* Create a document if no document with the same ID already exists.
|
|
@@ -289,7 +289,7 @@ export class ObservableSanityClient {
|
|
|
289
289
|
*/
|
|
290
290
|
createIfNotExists<R extends Record<string, Any> = Record<string, Any>>(
|
|
291
291
|
document: IdentifiedSanityDocumentStub<R>,
|
|
292
|
-
options: FirstDocumentIdMutationOptions
|
|
292
|
+
options: FirstDocumentIdMutationOptions,
|
|
293
293
|
): Observable<SingleMutationResult>
|
|
294
294
|
/**
|
|
295
295
|
* Create a document if no document with the same ID already exists.
|
|
@@ -300,7 +300,7 @@ export class ObservableSanityClient {
|
|
|
300
300
|
*/
|
|
301
301
|
createIfNotExists<R extends Record<string, Any> = Record<string, Any>>(
|
|
302
302
|
document: IdentifiedSanityDocumentStub<R>,
|
|
303
|
-
options: AllDocumentIdsMutationOptions
|
|
303
|
+
options: AllDocumentIdsMutationOptions,
|
|
304
304
|
): Observable<MultipleMutationResult>
|
|
305
305
|
/**
|
|
306
306
|
* Create a document if no document with the same ID already exists.
|
|
@@ -311,7 +311,7 @@ export class ObservableSanityClient {
|
|
|
311
311
|
*/
|
|
312
312
|
createIfNotExists<R extends Record<string, Any> = Record<string, Any>>(
|
|
313
313
|
document: IdentifiedSanityDocumentStub<R>,
|
|
314
|
-
options?: BaseMutationOptions
|
|
314
|
+
options?: BaseMutationOptions,
|
|
315
315
|
): Observable<SanityDocument<R>>
|
|
316
316
|
createIfNotExists<R extends Record<string, Any> = Record<string, Any>>(
|
|
317
317
|
document: IdentifiedSanityDocumentStub<R>,
|
|
@@ -320,7 +320,7 @@ export class ObservableSanityClient {
|
|
|
320
320
|
| AllDocumentsMutationOptions
|
|
321
321
|
| BaseMutationOptions
|
|
322
322
|
| FirstDocumentIdMutationOptions
|
|
323
|
-
| FirstDocumentMutationOptions
|
|
323
|
+
| FirstDocumentMutationOptions,
|
|
324
324
|
): Observable<
|
|
325
325
|
SanityDocument<R> | SanityDocument<R>[] | SingleMutationResult | MultipleMutationResult
|
|
326
326
|
> {
|
|
@@ -336,7 +336,7 @@ export class ObservableSanityClient {
|
|
|
336
336
|
*/
|
|
337
337
|
createOrReplace<R extends Record<string, Any> = Record<string, Any>>(
|
|
338
338
|
document: IdentifiedSanityDocumentStub<R>,
|
|
339
|
-
options: FirstDocumentMutationOptions
|
|
339
|
+
options: FirstDocumentMutationOptions,
|
|
340
340
|
): Observable<SanityDocument<R>>
|
|
341
341
|
/**
|
|
342
342
|
* Create a document if it does not exist, or replace a document with the same document ID
|
|
@@ -347,7 +347,7 @@ export class ObservableSanityClient {
|
|
|
347
347
|
*/
|
|
348
348
|
createOrReplace<R extends Record<string, Any> = Record<string, Any>>(
|
|
349
349
|
document: IdentifiedSanityDocumentStub<R>,
|
|
350
|
-
options: AllDocumentsMutationOptions
|
|
350
|
+
options: AllDocumentsMutationOptions,
|
|
351
351
|
): Observable<SanityDocument<R>[]>
|
|
352
352
|
/**
|
|
353
353
|
* Create a document if it does not exist, or replace a document with the same document ID
|
|
@@ -358,7 +358,7 @@ export class ObservableSanityClient {
|
|
|
358
358
|
*/
|
|
359
359
|
createOrReplace<R extends Record<string, Any> = Record<string, Any>>(
|
|
360
360
|
document: IdentifiedSanityDocumentStub<R>,
|
|
361
|
-
options: FirstDocumentIdMutationOptions
|
|
361
|
+
options: FirstDocumentIdMutationOptions,
|
|
362
362
|
): Observable<SingleMutationResult>
|
|
363
363
|
/**
|
|
364
364
|
* Create a document if it does not exist, or replace a document with the same document ID
|
|
@@ -369,7 +369,7 @@ export class ObservableSanityClient {
|
|
|
369
369
|
*/
|
|
370
370
|
createOrReplace<R extends Record<string, Any> = Record<string, Any>>(
|
|
371
371
|
document: IdentifiedSanityDocumentStub<R>,
|
|
372
|
-
options: AllDocumentIdsMutationOptions
|
|
372
|
+
options: AllDocumentIdsMutationOptions,
|
|
373
373
|
): Observable<MultipleMutationResult>
|
|
374
374
|
/**
|
|
375
375
|
* Create a document if it does not exist, or replace a document with the same document ID
|
|
@@ -380,7 +380,7 @@ export class ObservableSanityClient {
|
|
|
380
380
|
*/
|
|
381
381
|
createOrReplace<R extends Record<string, Any> = Record<string, Any>>(
|
|
382
382
|
document: IdentifiedSanityDocumentStub<R>,
|
|
383
|
-
options?: BaseMutationOptions
|
|
383
|
+
options?: BaseMutationOptions,
|
|
384
384
|
): Observable<SanityDocument<R>>
|
|
385
385
|
createOrReplace<R extends Record<string, Any> = Record<string, Any>>(
|
|
386
386
|
document: IdentifiedSanityDocumentStub<R>,
|
|
@@ -389,7 +389,7 @@ export class ObservableSanityClient {
|
|
|
389
389
|
| AllDocumentsMutationOptions
|
|
390
390
|
| BaseMutationOptions
|
|
391
391
|
| FirstDocumentIdMutationOptions
|
|
392
|
-
| FirstDocumentMutationOptions
|
|
392
|
+
| FirstDocumentMutationOptions,
|
|
393
393
|
): Observable<
|
|
394
394
|
SanityDocument<R> | SanityDocument<R>[] | SingleMutationResult | MultipleMutationResult
|
|
395
395
|
> {
|
|
@@ -405,7 +405,7 @@ export class ObservableSanityClient {
|
|
|
405
405
|
*/
|
|
406
406
|
delete<R extends Record<string, Any> = Record<string, Any>>(
|
|
407
407
|
id: string,
|
|
408
|
-
options: FirstDocumentMutationOptions
|
|
408
|
+
options: FirstDocumentMutationOptions,
|
|
409
409
|
): Observable<SanityDocument<R>>
|
|
410
410
|
/**
|
|
411
411
|
* Deletes a document with the given document ID.
|
|
@@ -416,7 +416,7 @@ export class ObservableSanityClient {
|
|
|
416
416
|
*/
|
|
417
417
|
delete<R extends Record<string, Any> = Record<string, Any>>(
|
|
418
418
|
id: string,
|
|
419
|
-
options: AllDocumentsMutationOptions
|
|
419
|
+
options: AllDocumentsMutationOptions,
|
|
420
420
|
): Observable<SanityDocument<R>[]>
|
|
421
421
|
/**
|
|
422
422
|
* Deletes a document with the given document ID.
|
|
@@ -443,7 +443,7 @@ export class ObservableSanityClient {
|
|
|
443
443
|
*/
|
|
444
444
|
delete<R extends Record<string, Any> = Record<string, Any>>(
|
|
445
445
|
id: string,
|
|
446
|
-
options?: BaseMutationOptions
|
|
446
|
+
options?: BaseMutationOptions,
|
|
447
447
|
): Observable<SanityDocument<R>>
|
|
448
448
|
/**
|
|
449
449
|
* Deletes one or more documents matching the given query or document ID.
|
|
@@ -454,7 +454,7 @@ export class ObservableSanityClient {
|
|
|
454
454
|
*/
|
|
455
455
|
delete<R extends Record<string, Any> = Record<string, Any>>(
|
|
456
456
|
selection: MutationSelection,
|
|
457
|
-
options: FirstDocumentMutationOptions
|
|
457
|
+
options: FirstDocumentMutationOptions,
|
|
458
458
|
): Observable<SanityDocument<R>>
|
|
459
459
|
/**
|
|
460
460
|
* Deletes one or more documents matching the given query or document ID.
|
|
@@ -465,7 +465,7 @@ export class ObservableSanityClient {
|
|
|
465
465
|
*/
|
|
466
466
|
delete<R extends Record<string, Any> = Record<string, Any>>(
|
|
467
467
|
selection: MutationSelection,
|
|
468
|
-
options: AllDocumentsMutationOptions
|
|
468
|
+
options: AllDocumentsMutationOptions,
|
|
469
469
|
): Observable<SanityDocument<R>[]>
|
|
470
470
|
/**
|
|
471
471
|
* Deletes one or more documents matching the given query or document ID.
|
|
@@ -476,7 +476,7 @@ export class ObservableSanityClient {
|
|
|
476
476
|
*/
|
|
477
477
|
delete(
|
|
478
478
|
selection: MutationSelection,
|
|
479
|
-
options: FirstDocumentIdMutationOptions
|
|
479
|
+
options: FirstDocumentIdMutationOptions,
|
|
480
480
|
): Observable<SingleMutationResult>
|
|
481
481
|
/**
|
|
482
482
|
* Deletes one or more documents matching the given query or document ID.
|
|
@@ -487,7 +487,7 @@ export class ObservableSanityClient {
|
|
|
487
487
|
*/
|
|
488
488
|
delete(
|
|
489
489
|
selection: MutationSelection,
|
|
490
|
-
options: AllDocumentIdsMutationOptions
|
|
490
|
+
options: AllDocumentIdsMutationOptions,
|
|
491
491
|
): Observable<MultipleMutationResult>
|
|
492
492
|
/**
|
|
493
493
|
* Deletes one or more documents matching the given query or document ID.
|
|
@@ -498,7 +498,7 @@ export class ObservableSanityClient {
|
|
|
498
498
|
*/
|
|
499
499
|
delete<R extends Record<string, Any> = Record<string, Any>>(
|
|
500
500
|
selection: MutationSelection,
|
|
501
|
-
options?: BaseMutationOptions
|
|
501
|
+
options?: BaseMutationOptions,
|
|
502
502
|
): Observable<SanityDocument<R>>
|
|
503
503
|
delete<R extends Record<string, Any> = Record<string, Any>>(
|
|
504
504
|
selection: string | MutationSelection,
|
|
@@ -507,7 +507,7 @@ export class ObservableSanityClient {
|
|
|
507
507
|
| AllDocumentsMutationOptions
|
|
508
508
|
| BaseMutationOptions
|
|
509
509
|
| FirstDocumentIdMutationOptions
|
|
510
|
-
| FirstDocumentMutationOptions
|
|
510
|
+
| FirstDocumentMutationOptions,
|
|
511
511
|
): Observable<
|
|
512
512
|
SanityDocument<R> | SanityDocument<R>[] | SingleMutationResult | MultipleMutationResult
|
|
513
513
|
> {
|
|
@@ -523,7 +523,7 @@ export class ObservableSanityClient {
|
|
|
523
523
|
*/
|
|
524
524
|
mutate<R extends Record<string, Any> = Record<string, Any>>(
|
|
525
525
|
operations: Mutation<R>[] | ObservablePatch | ObservableTransaction,
|
|
526
|
-
options: FirstDocumentMutationOptions
|
|
526
|
+
options: FirstDocumentMutationOptions,
|
|
527
527
|
): Observable<SanityDocument<R>>
|
|
528
528
|
/**
|
|
529
529
|
* Perform mutation operations against the configured dataset.
|
|
@@ -534,7 +534,7 @@ export class ObservableSanityClient {
|
|
|
534
534
|
*/
|
|
535
535
|
mutate<R extends Record<string, Any> = Record<string, Any>>(
|
|
536
536
|
operations: Mutation<R>[] | ObservablePatch | ObservableTransaction,
|
|
537
|
-
options: AllDocumentsMutationOptions
|
|
537
|
+
options: AllDocumentsMutationOptions,
|
|
538
538
|
): Observable<SanityDocument<R>[]>
|
|
539
539
|
/**
|
|
540
540
|
* Perform mutation operations against the configured dataset
|
|
@@ -545,7 +545,7 @@ export class ObservableSanityClient {
|
|
|
545
545
|
*/
|
|
546
546
|
mutate<R extends Record<string, Any> = Record<string, Any>>(
|
|
547
547
|
operations: Mutation<R>[] | ObservablePatch | ObservableTransaction,
|
|
548
|
-
options: FirstDocumentIdMutationOptions
|
|
548
|
+
options: FirstDocumentIdMutationOptions,
|
|
549
549
|
): Observable<SingleMutationResult>
|
|
550
550
|
/**
|
|
551
551
|
* Perform mutation operations against the configured dataset
|
|
@@ -556,7 +556,7 @@ export class ObservableSanityClient {
|
|
|
556
556
|
*/
|
|
557
557
|
mutate<R extends Record<string, Any> = Record<string, Any>>(
|
|
558
558
|
operations: Mutation<R>[] | ObservablePatch | ObservableTransaction,
|
|
559
|
-
options: AllDocumentIdsMutationOptions
|
|
559
|
+
options: AllDocumentIdsMutationOptions,
|
|
560
560
|
): Observable<MultipleMutationResult>
|
|
561
561
|
/**
|
|
562
562
|
* Perform mutation operations against the configured dataset
|
|
@@ -567,7 +567,7 @@ export class ObservableSanityClient {
|
|
|
567
567
|
*/
|
|
568
568
|
mutate<R extends Record<string, Any> = Record<string, Any>>(
|
|
569
569
|
operations: Mutation<R>[] | ObservablePatch | ObservableTransaction,
|
|
570
|
-
options?: BaseMutationOptions
|
|
570
|
+
options?: BaseMutationOptions,
|
|
571
571
|
): Observable<SanityDocument<R>>
|
|
572
572
|
mutate<R extends Record<string, Any> = Record<string, Any>>(
|
|
573
573
|
operations: Mutation<R>[] | ObservablePatch | ObservableTransaction,
|
|
@@ -576,7 +576,7 @@ export class ObservableSanityClient {
|
|
|
576
576
|
| AllDocumentsMutationOptions
|
|
577
577
|
| FirstDocumentIdMutationOptions
|
|
578
578
|
| AllDocumentIdsMutationOptions
|
|
579
|
-
| BaseMutationOptions
|
|
579
|
+
| BaseMutationOptions,
|
|
580
580
|
): Observable<
|
|
581
581
|
SanityDocument<R> | SanityDocument<R>[] | SingleMutationResult | MultipleMutationResult
|
|
582
582
|
> {
|
|
@@ -599,7 +599,7 @@ export class ObservableSanityClient {
|
|
|
599
599
|
* @param operations - Optional array of mutation operations to initialize the transaction instance with
|
|
600
600
|
*/
|
|
601
601
|
transaction<R extends Record<string, Any> = Record<string, Any>>(
|
|
602
|
-
operations?: Mutation<R>[]
|
|
602
|
+
operations?: Mutation<R>[],
|
|
603
603
|
): ObservableTransaction {
|
|
604
604
|
return new ObservableTransaction(operations, this)
|
|
605
605
|
}
|
|
@@ -693,7 +693,7 @@ export class SanityClient {
|
|
|
693
693
|
|
|
694
694
|
if (this.#clientConfig && this.#clientConfig.allowReconfigure === false) {
|
|
695
695
|
throw new Error(
|
|
696
|
-
'Existing client instance cannot be reconfigured - use `withConfig(newConfig)` to return a new client'
|
|
696
|
+
'Existing client instance cannot be reconfigured - use `withConfig(newConfig)` to return a new client',
|
|
697
697
|
)
|
|
698
698
|
}
|
|
699
699
|
|
|
@@ -737,7 +737,7 @@ export class SanityClient {
|
|
|
737
737
|
fetch<R = Any, Q = QueryParams>(
|
|
738
738
|
query: string,
|
|
739
739
|
params: Q | undefined,
|
|
740
|
-
options: FilteredResponseQueryOptions
|
|
740
|
+
options: FilteredResponseQueryOptions,
|
|
741
741
|
): Promise<R>
|
|
742
742
|
/**
|
|
743
743
|
* Perform a GROQ-query against the configured dataset.
|
|
@@ -749,12 +749,12 @@ export class SanityClient {
|
|
|
749
749
|
fetch<R = Any, Q = QueryParams>(
|
|
750
750
|
query: string,
|
|
751
751
|
params: Q | undefined,
|
|
752
|
-
options: UnfilteredResponseQueryOptions
|
|
752
|
+
options: UnfilteredResponseQueryOptions,
|
|
753
753
|
): Promise<RawQueryResponse<R>>
|
|
754
754
|
fetch<R, Q extends QueryParams>(
|
|
755
755
|
query: string,
|
|
756
756
|
params?: Q,
|
|
757
|
-
options: FilteredResponseQueryOptions | UnfilteredResponseQueryOptions = {}
|
|
757
|
+
options: FilteredResponseQueryOptions | UnfilteredResponseQueryOptions = {},
|
|
758
758
|
): Promise<RawQueryResponse<R> | R> {
|
|
759
759
|
return lastValueFrom(dataMethods._fetch<R, Q>(this, this.#httpRequest, query, params, options))
|
|
760
760
|
}
|
|
@@ -767,7 +767,7 @@ export class SanityClient {
|
|
|
767
767
|
*/
|
|
768
768
|
getDocument<R extends Record<string, Any> = Record<string, Any>>(
|
|
769
769
|
id: string,
|
|
770
|
-
options?: {tag?: string}
|
|
770
|
+
options?: {tag?: string},
|
|
771
771
|
): Promise<SanityDocument<R> | undefined> {
|
|
772
772
|
return lastValueFrom(dataMethods._getDocument<R>(this, this.#httpRequest, id, options))
|
|
773
773
|
}
|
|
@@ -783,7 +783,7 @@ export class SanityClient {
|
|
|
783
783
|
*/
|
|
784
784
|
getDocuments<R extends Record<string, Any> = Record<string, Any>>(
|
|
785
785
|
ids: string[],
|
|
786
|
-
options?: {tag?: string}
|
|
786
|
+
options?: {tag?: string},
|
|
787
787
|
): Promise<(SanityDocument<R> | null)[]> {
|
|
788
788
|
return lastValueFrom(dataMethods._getDocuments<R>(this, this.#httpRequest, ids, options))
|
|
789
789
|
}
|
|
@@ -797,7 +797,7 @@ export class SanityClient {
|
|
|
797
797
|
*/
|
|
798
798
|
create<R extends Record<string, Any> = Record<string, Any>>(
|
|
799
799
|
document: SanityDocumentStub<R>,
|
|
800
|
-
options: FirstDocumentMutationOptions
|
|
800
|
+
options: FirstDocumentMutationOptions,
|
|
801
801
|
): Promise<SanityDocument<R>>
|
|
802
802
|
/**
|
|
803
803
|
* Create a document. Requires a `_type` property. If no `_id` is provided, it will be generated by the database.
|
|
@@ -808,7 +808,7 @@ export class SanityClient {
|
|
|
808
808
|
*/
|
|
809
809
|
create<R extends Record<string, Any> = Record<string, Any>>(
|
|
810
810
|
document: SanityDocumentStub<R>,
|
|
811
|
-
options: AllDocumentsMutationOptions
|
|
811
|
+
options: AllDocumentsMutationOptions,
|
|
812
812
|
): Promise<SanityDocument<R>[]>
|
|
813
813
|
/**
|
|
814
814
|
* Create a document. Requires a `_type` property. If no `_id` is provided, it will be generated by the database.
|
|
@@ -819,7 +819,7 @@ export class SanityClient {
|
|
|
819
819
|
*/
|
|
820
820
|
create<R extends Record<string, Any> = Record<string, Any>>(
|
|
821
821
|
document: SanityDocumentStub<R>,
|
|
822
|
-
options: FirstDocumentIdMutationOptions
|
|
822
|
+
options: FirstDocumentIdMutationOptions,
|
|
823
823
|
): Promise<SingleMutationResult>
|
|
824
824
|
/**
|
|
825
825
|
* Create a document. Requires a `_type` property. If no `_id` is provided, it will be generated by the database.
|
|
@@ -830,7 +830,7 @@ export class SanityClient {
|
|
|
830
830
|
*/
|
|
831
831
|
create<R extends Record<string, Any> = Record<string, Any>>(
|
|
832
832
|
document: SanityDocumentStub<R>,
|
|
833
|
-
options: AllDocumentIdsMutationOptions
|
|
833
|
+
options: AllDocumentIdsMutationOptions,
|
|
834
834
|
): Promise<MultipleMutationResult>
|
|
835
835
|
/**
|
|
836
836
|
* Create a document. Requires a `_type` property. If no `_id` is provided, it will be generated by the database.
|
|
@@ -841,7 +841,7 @@ export class SanityClient {
|
|
|
841
841
|
*/
|
|
842
842
|
create<R extends Record<string, Any> = Record<string, Any>>(
|
|
843
843
|
document: SanityDocumentStub<R>,
|
|
844
|
-
options?: BaseMutationOptions
|
|
844
|
+
options?: BaseMutationOptions,
|
|
845
845
|
): Promise<SanityDocument<R>>
|
|
846
846
|
create<R extends Record<string, Any> = Record<string, Any>>(
|
|
847
847
|
document: SanityDocumentStub<R>,
|
|
@@ -850,12 +850,12 @@ export class SanityClient {
|
|
|
850
850
|
| AllDocumentsMutationOptions
|
|
851
851
|
| BaseMutationOptions
|
|
852
852
|
| FirstDocumentIdMutationOptions
|
|
853
|
-
| FirstDocumentMutationOptions
|
|
853
|
+
| FirstDocumentMutationOptions,
|
|
854
854
|
): Promise<
|
|
855
855
|
SanityDocument<R> | SanityDocument<R>[] | SingleMutationResult | MultipleMutationResult
|
|
856
856
|
> {
|
|
857
857
|
return lastValueFrom(
|
|
858
|
-
dataMethods._create<R>(this, this.#httpRequest, document, 'create', options)
|
|
858
|
+
dataMethods._create<R>(this, this.#httpRequest, document, 'create', options),
|
|
859
859
|
)
|
|
860
860
|
}
|
|
861
861
|
|
|
@@ -868,7 +868,7 @@ export class SanityClient {
|
|
|
868
868
|
*/
|
|
869
869
|
createIfNotExists<R extends Record<string, Any> = Record<string, Any>>(
|
|
870
870
|
document: IdentifiedSanityDocumentStub<R>,
|
|
871
|
-
options: FirstDocumentMutationOptions
|
|
871
|
+
options: FirstDocumentMutationOptions,
|
|
872
872
|
): Promise<SanityDocument<R>>
|
|
873
873
|
/**
|
|
874
874
|
* Create a document if no document with the same ID already exists.
|
|
@@ -879,7 +879,7 @@ export class SanityClient {
|
|
|
879
879
|
*/
|
|
880
880
|
createIfNotExists<R extends Record<string, Any> = Record<string, Any>>(
|
|
881
881
|
document: IdentifiedSanityDocumentStub<R>,
|
|
882
|
-
options: AllDocumentsMutationOptions
|
|
882
|
+
options: AllDocumentsMutationOptions,
|
|
883
883
|
): Promise<SanityDocument<R>[]>
|
|
884
884
|
/**
|
|
885
885
|
* Create a document if no document with the same ID already exists.
|
|
@@ -890,7 +890,7 @@ export class SanityClient {
|
|
|
890
890
|
*/
|
|
891
891
|
createIfNotExists<R extends Record<string, Any> = Record<string, Any>>(
|
|
892
892
|
document: IdentifiedSanityDocumentStub<R>,
|
|
893
|
-
options: FirstDocumentIdMutationOptions
|
|
893
|
+
options: FirstDocumentIdMutationOptions,
|
|
894
894
|
): Promise<SingleMutationResult>
|
|
895
895
|
/**
|
|
896
896
|
* Create a document if no document with the same ID already exists.
|
|
@@ -901,7 +901,7 @@ export class SanityClient {
|
|
|
901
901
|
*/
|
|
902
902
|
createIfNotExists<R extends Record<string, Any> = Record<string, Any>>(
|
|
903
903
|
document: IdentifiedSanityDocumentStub<R>,
|
|
904
|
-
options: AllDocumentIdsMutationOptions
|
|
904
|
+
options: AllDocumentIdsMutationOptions,
|
|
905
905
|
): Promise<MultipleMutationResult>
|
|
906
906
|
/**
|
|
907
907
|
* Create a document if no document with the same ID already exists.
|
|
@@ -912,7 +912,7 @@ export class SanityClient {
|
|
|
912
912
|
*/
|
|
913
913
|
createIfNotExists<R extends Record<string, Any> = Record<string, Any>>(
|
|
914
914
|
document: IdentifiedSanityDocumentStub<R>,
|
|
915
|
-
options?: BaseMutationOptions
|
|
915
|
+
options?: BaseMutationOptions,
|
|
916
916
|
): Promise<SanityDocument<R>>
|
|
917
917
|
createIfNotExists<R extends Record<string, Any> = Record<string, Any>>(
|
|
918
918
|
document: IdentifiedSanityDocumentStub<R>,
|
|
@@ -921,12 +921,12 @@ export class SanityClient {
|
|
|
921
921
|
| AllDocumentsMutationOptions
|
|
922
922
|
| BaseMutationOptions
|
|
923
923
|
| FirstDocumentIdMutationOptions
|
|
924
|
-
| FirstDocumentMutationOptions
|
|
924
|
+
| FirstDocumentMutationOptions,
|
|
925
925
|
): Promise<
|
|
926
926
|
SanityDocument<R> | SanityDocument<R>[] | SingleMutationResult | MultipleMutationResult
|
|
927
927
|
> {
|
|
928
928
|
return lastValueFrom(
|
|
929
|
-
dataMethods._createIfNotExists<R>(this, this.#httpRequest, document, options)
|
|
929
|
+
dataMethods._createIfNotExists<R>(this, this.#httpRequest, document, options),
|
|
930
930
|
)
|
|
931
931
|
}
|
|
932
932
|
|
|
@@ -939,7 +939,7 @@ export class SanityClient {
|
|
|
939
939
|
*/
|
|
940
940
|
createOrReplace<R extends Record<string, Any> = Record<string, Any>>(
|
|
941
941
|
document: IdentifiedSanityDocumentStub<R>,
|
|
942
|
-
options: FirstDocumentMutationOptions
|
|
942
|
+
options: FirstDocumentMutationOptions,
|
|
943
943
|
): Promise<SanityDocument<R>>
|
|
944
944
|
/**
|
|
945
945
|
* Create a document if it does not exist, or replace a document with the same document ID
|
|
@@ -950,7 +950,7 @@ export class SanityClient {
|
|
|
950
950
|
*/
|
|
951
951
|
createOrReplace<R extends Record<string, Any> = Record<string, Any>>(
|
|
952
952
|
document: IdentifiedSanityDocumentStub<R>,
|
|
953
|
-
options: AllDocumentsMutationOptions
|
|
953
|
+
options: AllDocumentsMutationOptions,
|
|
954
954
|
): Promise<SanityDocument<R>[]>
|
|
955
955
|
/**
|
|
956
956
|
* Create a document if it does not exist, or replace a document with the same document ID
|
|
@@ -961,7 +961,7 @@ export class SanityClient {
|
|
|
961
961
|
*/
|
|
962
962
|
createOrReplace<R extends Record<string, Any> = Record<string, Any>>(
|
|
963
963
|
document: IdentifiedSanityDocumentStub<R>,
|
|
964
|
-
options: FirstDocumentIdMutationOptions
|
|
964
|
+
options: FirstDocumentIdMutationOptions,
|
|
965
965
|
): Promise<SingleMutationResult>
|
|
966
966
|
/**
|
|
967
967
|
* Create a document if it does not exist, or replace a document with the same document ID
|
|
@@ -972,7 +972,7 @@ export class SanityClient {
|
|
|
972
972
|
*/
|
|
973
973
|
createOrReplace<R extends Record<string, Any> = Record<string, Any>>(
|
|
974
974
|
document: IdentifiedSanityDocumentStub<R>,
|
|
975
|
-
options: AllDocumentIdsMutationOptions
|
|
975
|
+
options: AllDocumentIdsMutationOptions,
|
|
976
976
|
): Promise<MultipleMutationResult>
|
|
977
977
|
/**
|
|
978
978
|
* Create a document if it does not exist, or replace a document with the same document ID
|
|
@@ -983,7 +983,7 @@ export class SanityClient {
|
|
|
983
983
|
*/
|
|
984
984
|
createOrReplace<R extends Record<string, Any> = Record<string, Any>>(
|
|
985
985
|
document: IdentifiedSanityDocumentStub<R>,
|
|
986
|
-
options?: BaseMutationOptions
|
|
986
|
+
options?: BaseMutationOptions,
|
|
987
987
|
): Promise<SanityDocument<R>>
|
|
988
988
|
createOrReplace<R extends Record<string, Any> = Record<string, Any>>(
|
|
989
989
|
document: IdentifiedSanityDocumentStub<R>,
|
|
@@ -992,12 +992,12 @@ export class SanityClient {
|
|
|
992
992
|
| AllDocumentsMutationOptions
|
|
993
993
|
| BaseMutationOptions
|
|
994
994
|
| FirstDocumentIdMutationOptions
|
|
995
|
-
| FirstDocumentMutationOptions
|
|
995
|
+
| FirstDocumentMutationOptions,
|
|
996
996
|
): Promise<
|
|
997
997
|
SanityDocument<R> | SanityDocument<R>[] | SingleMutationResult | MultipleMutationResult
|
|
998
998
|
> {
|
|
999
999
|
return lastValueFrom(
|
|
1000
|
-
dataMethods._createOrReplace<R>(this, this.#httpRequest, document, options)
|
|
1000
|
+
dataMethods._createOrReplace<R>(this, this.#httpRequest, document, options),
|
|
1001
1001
|
)
|
|
1002
1002
|
}
|
|
1003
1003
|
|
|
@@ -1010,7 +1010,7 @@ export class SanityClient {
|
|
|
1010
1010
|
*/
|
|
1011
1011
|
delete<R extends Record<string, Any> = Record<string, Any>>(
|
|
1012
1012
|
id: string,
|
|
1013
|
-
options: FirstDocumentMutationOptions
|
|
1013
|
+
options: FirstDocumentMutationOptions,
|
|
1014
1014
|
): Promise<SanityDocument<R>>
|
|
1015
1015
|
/**
|
|
1016
1016
|
* Deletes a document with the given document ID.
|
|
@@ -1021,7 +1021,7 @@ export class SanityClient {
|
|
|
1021
1021
|
*/
|
|
1022
1022
|
delete<R extends Record<string, Any> = Record<string, Any>>(
|
|
1023
1023
|
id: string,
|
|
1024
|
-
options: AllDocumentsMutationOptions
|
|
1024
|
+
options: AllDocumentsMutationOptions,
|
|
1025
1025
|
): Promise<SanityDocument<R>[]>
|
|
1026
1026
|
/**
|
|
1027
1027
|
* Deletes a document with the given document ID.
|
|
@@ -1048,7 +1048,7 @@ export class SanityClient {
|
|
|
1048
1048
|
*/
|
|
1049
1049
|
delete<R extends Record<string, Any> = Record<string, Any>>(
|
|
1050
1050
|
id: string,
|
|
1051
|
-
options?: BaseMutationOptions
|
|
1051
|
+
options?: BaseMutationOptions,
|
|
1052
1052
|
): Promise<SanityDocument<R>>
|
|
1053
1053
|
/**
|
|
1054
1054
|
* Deletes one or more documents matching the given query or document ID.
|
|
@@ -1059,7 +1059,7 @@ export class SanityClient {
|
|
|
1059
1059
|
*/
|
|
1060
1060
|
delete<R extends Record<string, Any> = Record<string, Any>>(
|
|
1061
1061
|
selection: MutationSelection,
|
|
1062
|
-
options: FirstDocumentMutationOptions
|
|
1062
|
+
options: FirstDocumentMutationOptions,
|
|
1063
1063
|
): Promise<SanityDocument<R>>
|
|
1064
1064
|
/**
|
|
1065
1065
|
* Deletes one or more documents matching the given query or document ID.
|
|
@@ -1070,7 +1070,7 @@ export class SanityClient {
|
|
|
1070
1070
|
*/
|
|
1071
1071
|
delete<R extends Record<string, Any> = Record<string, Any>>(
|
|
1072
1072
|
selection: MutationSelection,
|
|
1073
|
-
options: AllDocumentsMutationOptions
|
|
1073
|
+
options: AllDocumentsMutationOptions,
|
|
1074
1074
|
): Promise<SanityDocument<R>[]>
|
|
1075
1075
|
/**
|
|
1076
1076
|
* Deletes one or more documents matching the given query or document ID.
|
|
@@ -1081,7 +1081,7 @@ export class SanityClient {
|
|
|
1081
1081
|
*/
|
|
1082
1082
|
delete(
|
|
1083
1083
|
selection: MutationSelection,
|
|
1084
|
-
options: FirstDocumentIdMutationOptions
|
|
1084
|
+
options: FirstDocumentIdMutationOptions,
|
|
1085
1085
|
): Promise<SingleMutationResult>
|
|
1086
1086
|
/**
|
|
1087
1087
|
* Deletes one or more documents matching the given query or document ID.
|
|
@@ -1092,7 +1092,7 @@ export class SanityClient {
|
|
|
1092
1092
|
*/
|
|
1093
1093
|
delete(
|
|
1094
1094
|
selection: MutationSelection,
|
|
1095
|
-
options: AllDocumentIdsMutationOptions
|
|
1095
|
+
options: AllDocumentIdsMutationOptions,
|
|
1096
1096
|
): Promise<MultipleMutationResult>
|
|
1097
1097
|
/**
|
|
1098
1098
|
* Deletes one or more documents matching the given query or document ID.
|
|
@@ -1103,7 +1103,7 @@ export class SanityClient {
|
|
|
1103
1103
|
*/
|
|
1104
1104
|
delete<R extends Record<string, Any> = Record<string, Any>>(
|
|
1105
1105
|
selection: MutationSelection,
|
|
1106
|
-
options?: BaseMutationOptions
|
|
1106
|
+
options?: BaseMutationOptions,
|
|
1107
1107
|
): Promise<SanityDocument<R>>
|
|
1108
1108
|
delete<R extends Record<string, Any> = Record<string, Any>>(
|
|
1109
1109
|
selection: string | MutationSelection,
|
|
@@ -1112,7 +1112,7 @@ export class SanityClient {
|
|
|
1112
1112
|
| AllDocumentsMutationOptions
|
|
1113
1113
|
| BaseMutationOptions
|
|
1114
1114
|
| FirstDocumentIdMutationOptions
|
|
1115
|
-
| FirstDocumentMutationOptions
|
|
1115
|
+
| FirstDocumentMutationOptions,
|
|
1116
1116
|
): Promise<
|
|
1117
1117
|
SanityDocument<R> | SanityDocument<R>[] | SingleMutationResult | MultipleMutationResult
|
|
1118
1118
|
> {
|
|
@@ -1128,7 +1128,7 @@ export class SanityClient {
|
|
|
1128
1128
|
*/
|
|
1129
1129
|
mutate<R extends Record<string, Any> = Record<string, Any>>(
|
|
1130
1130
|
operations: Mutation<R>[] | Patch | Transaction,
|
|
1131
|
-
options: FirstDocumentMutationOptions
|
|
1131
|
+
options: FirstDocumentMutationOptions,
|
|
1132
1132
|
): Promise<SanityDocument<R>>
|
|
1133
1133
|
/**
|
|
1134
1134
|
* Perform mutation operations against the configured dataset.
|
|
@@ -1139,7 +1139,7 @@ export class SanityClient {
|
|
|
1139
1139
|
*/
|
|
1140
1140
|
mutate<R extends Record<string, Any> = Record<string, Any>>(
|
|
1141
1141
|
operations: Mutation<R>[] | Patch | Transaction,
|
|
1142
|
-
options: AllDocumentsMutationOptions
|
|
1142
|
+
options: AllDocumentsMutationOptions,
|
|
1143
1143
|
): Promise<SanityDocument<R>[]>
|
|
1144
1144
|
/**
|
|
1145
1145
|
* Perform mutation operations against the configured dataset
|
|
@@ -1150,7 +1150,7 @@ export class SanityClient {
|
|
|
1150
1150
|
*/
|
|
1151
1151
|
mutate<R extends Record<string, Any> = Record<string, Any>>(
|
|
1152
1152
|
operations: Mutation<R>[] | Patch | Transaction,
|
|
1153
|
-
options: FirstDocumentIdMutationOptions
|
|
1153
|
+
options: FirstDocumentIdMutationOptions,
|
|
1154
1154
|
): Promise<SingleMutationResult>
|
|
1155
1155
|
/**
|
|
1156
1156
|
* Perform mutation operations against the configured dataset
|
|
@@ -1161,7 +1161,7 @@ export class SanityClient {
|
|
|
1161
1161
|
*/
|
|
1162
1162
|
mutate<R extends Record<string, Any>>(
|
|
1163
1163
|
operations: Mutation<R>[] | Patch | Transaction,
|
|
1164
|
-
options: AllDocumentIdsMutationOptions
|
|
1164
|
+
options: AllDocumentIdsMutationOptions,
|
|
1165
1165
|
): Promise<MultipleMutationResult>
|
|
1166
1166
|
/**
|
|
1167
1167
|
* Perform mutation operations against the configured dataset
|
|
@@ -1172,7 +1172,7 @@ export class SanityClient {
|
|
|
1172
1172
|
*/
|
|
1173
1173
|
mutate<R extends Record<string, Any> = Record<string, Any>>(
|
|
1174
1174
|
operations: Mutation<R>[] | Patch | Transaction,
|
|
1175
|
-
options?: BaseMutationOptions
|
|
1175
|
+
options?: BaseMutationOptions,
|
|
1176
1176
|
): Promise<SanityDocument<R>>
|
|
1177
1177
|
mutate<R extends Record<string, Any> = Record<string, Any>>(
|
|
1178
1178
|
operations: Mutation<R>[] | Patch | Transaction,
|
|
@@ -1181,7 +1181,7 @@ export class SanityClient {
|
|
|
1181
1181
|
| AllDocumentsMutationOptions
|
|
1182
1182
|
| FirstDocumentIdMutationOptions
|
|
1183
1183
|
| AllDocumentIdsMutationOptions
|
|
1184
|
-
| BaseMutationOptions
|
|
1184
|
+
| BaseMutationOptions,
|
|
1185
1185
|
): Promise<
|
|
1186
1186
|
SanityDocument<R> | SanityDocument<R>[] | SingleMutationResult | MultipleMutationResult
|
|
1187
1187
|
> {
|
|
@@ -1204,7 +1204,7 @@ export class SanityClient {
|
|
|
1204
1204
|
* @param operations - Optional array of mutation operations to initialize the transaction instance with
|
|
1205
1205
|
*/
|
|
1206
1206
|
transaction<R extends Record<string, Any> = Record<string, Any>>(
|
|
1207
|
-
operations?: Mutation<R>[]
|
|
1207
|
+
operations?: Mutation<R>[],
|
|
1208
1208
|
): Transaction {
|
|
1209
1209
|
return new Transaction(operations, this)
|
|
1210
1210
|
}
|