@sanity/client 5.1.0 → 5.2.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/README.md +16 -72
- package/dist/index.browser.cjs +49 -11
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.js +49 -11
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +50 -12
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +156 -128
- package/dist/index.js +50 -12
- package/dist/index.js.map +1 -1
- package/package.json +16 -16
- package/src/SanityClient.ts +120 -80
- package/src/assets/AssetsClient.ts +4 -4
- package/src/config.ts +1 -1
- package/src/data/dataMethods.ts +31 -31
- package/src/data/encodeQueryString.ts +3 -3
- package/src/data/listen.ts +11 -11
- package/src/data/patch.ts +18 -18
- package/src/data/transaction.ts +13 -15
- package/src/generateHelpUrl.ts +1 -1
- package/src/http/errors.ts +7 -7
- package/src/http/request.ts +4 -4
- package/src/http/requestOptions.ts +3 -3
- package/src/index.browser.ts +9 -1
- package/src/index.ts +9 -1
- package/src/types.ts +27 -28
- package/src/util/defaults.ts +3 -3
- package/src/util/getSelection.ts +1 -1
- package/src/util/once.ts +4 -4
- package/src/util/pick.ts +3 -3
- package/src/validators.ts +4 -4
- package/src/warnings.ts +8 -4
- package/umd/sanityClient.js +49 -11
- package/umd/sanityClient.min.js +3 -3
- package/src/migrationNotice.ts +0 -9
package/dist/index.d.ts
CHANGED
|
@@ -15,6 +15,12 @@ export declare type AllDocumentsMutationOptions = BaseMutationOptions & {
|
|
|
15
15
|
returnDocuments?: true
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
+
/**
|
|
19
|
+
* Used to tag types that is set to `any` as a temporary measure, but should be replaced with proper typings in the future
|
|
20
|
+
* @internal
|
|
21
|
+
*/
|
|
22
|
+
export declare type Any = any
|
|
23
|
+
|
|
18
24
|
/** @public */
|
|
19
25
|
export declare type AssetMetadataType =
|
|
20
26
|
| 'location'
|
|
@@ -69,7 +75,7 @@ export declare class AssetsClient {
|
|
|
69
75
|
|
|
70
76
|
/** @internal */
|
|
71
77
|
export declare type AttributeSet = {
|
|
72
|
-
[key: string]:
|
|
78
|
+
[key: string]: Any
|
|
73
79
|
}
|
|
74
80
|
|
|
75
81
|
/** @internal */
|
|
@@ -146,21 +152,21 @@ export declare class BasePatch {
|
|
|
146
152
|
* @param selector - JSONPath expression, eg `comments[-1]` or `blocks[_key=="abc123"]`
|
|
147
153
|
* @param items - Array of items to insert/replace
|
|
148
154
|
*/
|
|
149
|
-
insert(at: 'before' | 'after' | 'replace', selector: string, items:
|
|
155
|
+
insert(at: 'before' | 'after' | 'replace', selector: string, items: Any[]): this
|
|
150
156
|
/**
|
|
151
157
|
* Append the given items to the array at the given JSONPath
|
|
152
158
|
*
|
|
153
159
|
* @param selector - Attribute/path to append to, eg `comments` or `person.hobbies`
|
|
154
160
|
* @param items - Array of items to append to the array
|
|
155
161
|
*/
|
|
156
|
-
append(selector: string, items:
|
|
162
|
+
append(selector: string, items: Any[]): this
|
|
157
163
|
/**
|
|
158
164
|
* Prepend the given items to the array at the given JSONPath
|
|
159
165
|
*
|
|
160
166
|
* @param selector - Attribute/path to prepend to, eg `comments` or `person.hobbies`
|
|
161
167
|
* @param items - Array of items to prepend to the array
|
|
162
168
|
*/
|
|
163
|
-
prepend(selector: string, items:
|
|
169
|
+
prepend(selector: string, items: Any[]): this
|
|
164
170
|
/**
|
|
165
171
|
* Change the contents of an array by removing existing elements and/or adding new elements.
|
|
166
172
|
*
|
|
@@ -169,7 +175,7 @@ export declare class BasePatch {
|
|
|
169
175
|
* @param deleteCount - An integer indicating the number of old array elements to remove.
|
|
170
176
|
* @param items - The elements to add to the array, beginning at the start index. If you don't specify any elements, splice() will only remove elements from the array.
|
|
171
177
|
*/
|
|
172
|
-
splice(selector: string, start: number, deleteCount?: number, items?:
|
|
178
|
+
splice(selector: string, start: number, deleteCount?: number, items?: Any[]): this
|
|
173
179
|
/**
|
|
174
180
|
* Adds a revision clause, preventing the document from being patched if the `_rev` property does not match the given value
|
|
175
181
|
*
|
|
@@ -188,8 +194,8 @@ export declare class BasePatch {
|
|
|
188
194
|
* Clears the patch of all operations
|
|
189
195
|
*/
|
|
190
196
|
reset(): this
|
|
191
|
-
protected _assign(op: keyof PatchOperations, props:
|
|
192
|
-
protected _set(op: keyof PatchOperations, props:
|
|
197
|
+
protected _assign(op: keyof PatchOperations, props: Any, merge?: boolean): this
|
|
198
|
+
protected _set(op: keyof PatchOperations, props: Any): this
|
|
193
199
|
}
|
|
194
200
|
|
|
195
201
|
/** @internal */
|
|
@@ -203,14 +209,14 @@ export declare class BaseTransaction {
|
|
|
203
209
|
*
|
|
204
210
|
* @param doc - Document to create. Requires a `_type` property.
|
|
205
211
|
*/
|
|
206
|
-
create<R extends Record<string,
|
|
212
|
+
create<R extends Record<string, Any> = Record<string, Any>>(doc: SanityDocumentStub<R>): this
|
|
207
213
|
/**
|
|
208
214
|
* Creates a new Sanity document. If a document with the same `_id` already exists, the create operation will be ignored.
|
|
209
215
|
* The operation is added to the current transaction, ready to be commited by `commit()`
|
|
210
216
|
*
|
|
211
217
|
* @param doc - Document to create if it does not already exist. Requires `_id` and `_type` properties.
|
|
212
218
|
*/
|
|
213
|
-
createIfNotExists<R extends Record<string,
|
|
219
|
+
createIfNotExists<R extends Record<string, Any> = Record<string, Any>>(
|
|
214
220
|
doc: IdentifiedSanityDocumentStub<R>
|
|
215
221
|
): this
|
|
216
222
|
/**
|
|
@@ -219,7 +225,7 @@ export declare class BaseTransaction {
|
|
|
219
225
|
*
|
|
220
226
|
* @param doc - Document to create or replace. Requires `_id` and `_type` properties.
|
|
221
227
|
*/
|
|
222
|
-
createOrReplace<R extends Record<string,
|
|
228
|
+
createOrReplace<R extends Record<string, Any> = Record<string, Any>>(
|
|
223
229
|
doc: IdentifiedSanityDocumentStub<R>
|
|
224
230
|
): this
|
|
225
231
|
/**
|
|
@@ -230,7 +236,7 @@ export declare class BaseTransaction {
|
|
|
230
236
|
*/
|
|
231
237
|
delete(documentId: string): this
|
|
232
238
|
/**
|
|
233
|
-
* Gets the current transaction ID, if
|
|
239
|
+
* Gets the current transaction ID, if any
|
|
234
240
|
*/
|
|
235
241
|
transactionId(): string | undefined
|
|
236
242
|
/**
|
|
@@ -290,7 +296,7 @@ export declare class ClientError extends Error {
|
|
|
290
296
|
statusCode: ErrorProps['statusCode']
|
|
291
297
|
responseBody: ErrorProps['responseBody']
|
|
292
298
|
details: ErrorProps['details']
|
|
293
|
-
constructor(res:
|
|
299
|
+
constructor(res: Any)
|
|
294
300
|
}
|
|
295
301
|
|
|
296
302
|
/** @public */
|
|
@@ -362,6 +368,13 @@ export declare type DatasetsResponse = {
|
|
|
362
368
|
aclMode: DatasetAclMode
|
|
363
369
|
}[]
|
|
364
370
|
|
|
371
|
+
/**
|
|
372
|
+
* @public
|
|
373
|
+
* @deprecated Use the named export `createClient` instead of the `default` export
|
|
374
|
+
*/
|
|
375
|
+
declare function deprecatedCreateClient(config: ClientConfig): SanityClient
|
|
376
|
+
export default deprecatedCreateClient
|
|
377
|
+
|
|
365
378
|
/** @public */
|
|
366
379
|
export declare type DisconnectEvent = {
|
|
367
380
|
type: 'disconnect'
|
|
@@ -371,10 +384,10 @@ export declare type DisconnectEvent = {
|
|
|
371
384
|
/** @public */
|
|
372
385
|
export declare interface ErrorProps {
|
|
373
386
|
message: string
|
|
374
|
-
response:
|
|
387
|
+
response: Any
|
|
375
388
|
statusCode: number
|
|
376
|
-
responseBody:
|
|
377
|
-
details:
|
|
389
|
+
responseBody: Any
|
|
390
|
+
details: Any
|
|
378
391
|
}
|
|
379
392
|
|
|
380
393
|
/** @internal */
|
|
@@ -394,12 +407,6 @@ export declare type FirstDocumentMutationOptions = BaseMutationOptions & {
|
|
|
394
407
|
returnDocuments?: true
|
|
395
408
|
}
|
|
396
409
|
|
|
397
|
-
/**
|
|
398
|
-
* Used to tag types that is set to `any` as a temporary measure, but should be replaced with proper typings in the future
|
|
399
|
-
* @internal
|
|
400
|
-
*/
|
|
401
|
-
export declare type FIXME = any
|
|
402
|
-
|
|
403
410
|
/** @public */
|
|
404
411
|
export declare type HttpRequest = {
|
|
405
412
|
defaultRequester: Requester
|
|
@@ -411,7 +418,7 @@ export declare type HttpRequestEvent<T = unknown> = ResponseEvent<T> | ProgressE
|
|
|
411
418
|
|
|
412
419
|
/** @public */
|
|
413
420
|
export declare type IdentifiedSanityDocumentStub<
|
|
414
|
-
T extends Record<string,
|
|
421
|
+
T extends Record<string, Any> = Record<string, Any>
|
|
415
422
|
> = {
|
|
416
423
|
[P in keyof T]: T[P]
|
|
417
424
|
} & {
|
|
@@ -442,15 +449,15 @@ export declare interface InitializedClientConfig extends ClientConfig {
|
|
|
442
449
|
export declare type InsertPatch =
|
|
443
450
|
| {
|
|
444
451
|
before: string
|
|
445
|
-
items:
|
|
452
|
+
items: Any[]
|
|
446
453
|
}
|
|
447
454
|
| {
|
|
448
455
|
after: string
|
|
449
|
-
items:
|
|
456
|
+
items: Any[]
|
|
450
457
|
}
|
|
451
458
|
| {
|
|
452
459
|
replace: string
|
|
453
|
-
items:
|
|
460
|
+
items: Any[]
|
|
454
461
|
}
|
|
455
462
|
|
|
456
463
|
/**
|
|
@@ -461,7 +468,7 @@ export declare type InsertPatch =
|
|
|
461
468
|
* @param options - Listener options
|
|
462
469
|
* @internal
|
|
463
470
|
*/
|
|
464
|
-
export declare function _listen<R extends Record<string,
|
|
471
|
+
export declare function _listen<R extends Record<string, Any> = Record<string, Any>>(
|
|
465
472
|
this: SanityClient | ObservableSanityClient,
|
|
466
473
|
query: string,
|
|
467
474
|
params?: QueryParams
|
|
@@ -475,7 +482,7 @@ export declare function _listen<R extends Record<string, FIXME> = Record<string,
|
|
|
475
482
|
* @param options - Listener options
|
|
476
483
|
* @internal
|
|
477
484
|
*/
|
|
478
|
-
export declare function _listen<R extends Record<string,
|
|
485
|
+
export declare function _listen<R extends Record<string, Any> = Record<string, Any>>(
|
|
479
486
|
this: SanityClient | ObservableSanityClient,
|
|
480
487
|
query: string,
|
|
481
488
|
params?: QueryParams,
|
|
@@ -483,7 +490,7 @@ export declare function _listen<R extends Record<string, FIXME> = Record<string,
|
|
|
483
490
|
): Observable<ListenEvent<R>>
|
|
484
491
|
|
|
485
492
|
/** @public */
|
|
486
|
-
export declare type ListenEvent<R extends Record<string,
|
|
493
|
+
export declare type ListenEvent<R extends Record<string, Any>> =
|
|
487
494
|
| MutationEvent_2<R>
|
|
488
495
|
| ChannelErrorEvent
|
|
489
496
|
| DisconnectEvent
|
|
@@ -503,13 +510,6 @@ export declare interface ListenOptions {
|
|
|
503
510
|
tag?: string
|
|
504
511
|
}
|
|
505
512
|
|
|
506
|
-
/**
|
|
507
|
-
* @public
|
|
508
|
-
* @deprecated Use the named export `createClient` instead of the `default` export
|
|
509
|
-
*/
|
|
510
|
-
declare function migrationNotice(): void
|
|
511
|
-
export default migrationNotice
|
|
512
|
-
|
|
513
513
|
/** @internal */
|
|
514
514
|
export declare interface MultipleMutationResult {
|
|
515
515
|
transactionId: string
|
|
@@ -521,7 +521,7 @@ export declare interface MultipleMutationResult {
|
|
|
521
521
|
}
|
|
522
522
|
|
|
523
523
|
/** @public */
|
|
524
|
-
export declare type Mutation<R extends Record<string,
|
|
524
|
+
export declare type Mutation<R extends Record<string, Any> = Record<string, Any>> =
|
|
525
525
|
| {
|
|
526
526
|
create: SanityDocumentStub<R>
|
|
527
527
|
}
|
|
@@ -539,7 +539,7 @@ export declare type Mutation<R extends Record<string, FIXME> = Record<string, FI
|
|
|
539
539
|
}
|
|
540
540
|
|
|
541
541
|
/** @public */
|
|
542
|
-
declare type MutationEvent_2<R extends Record<string,
|
|
542
|
+
declare type MutationEvent_2<R extends Record<string, Any> = Record<string, Any>> = {
|
|
543
543
|
type: 'mutation'
|
|
544
544
|
documentId: string
|
|
545
545
|
eventId: string
|
|
@@ -686,7 +686,7 @@ export declare class ObservablePatch extends BasePatch {
|
|
|
686
686
|
*
|
|
687
687
|
* @param options - Options for the mutation operation
|
|
688
688
|
*/
|
|
689
|
-
commit<R extends Record<string,
|
|
689
|
+
commit<R extends Record<string, Any> = Record<string, Any>>(
|
|
690
690
|
options: FirstDocumentMutationOptions
|
|
691
691
|
): Observable<SanityDocument<R>>
|
|
692
692
|
/**
|
|
@@ -694,7 +694,7 @@ export declare class ObservablePatch extends BasePatch {
|
|
|
694
694
|
*
|
|
695
695
|
* @param options - Options for the mutation operation
|
|
696
696
|
*/
|
|
697
|
-
commit<R extends Record<string,
|
|
697
|
+
commit<R extends Record<string, Any> = Record<string, Any>>(
|
|
698
698
|
options: AllDocumentsMutationOptions
|
|
699
699
|
): Observable<SanityDocument<R>[]>
|
|
700
700
|
/**
|
|
@@ -714,7 +714,7 @@ export declare class ObservablePatch extends BasePatch {
|
|
|
714
714
|
*
|
|
715
715
|
* @param options - Options for the mutation operation
|
|
716
716
|
*/
|
|
717
|
-
commit<R extends Record<string,
|
|
717
|
+
commit<R extends Record<string, Any> = Record<string, Any>>(
|
|
718
718
|
options?: BaseMutationOptions
|
|
719
719
|
): Observable<SanityDocument<R>>
|
|
720
720
|
}
|
|
@@ -773,14 +773,14 @@ export declare class ObservableSanityClient {
|
|
|
773
773
|
*
|
|
774
774
|
* @param query - GROQ-query to perform
|
|
775
775
|
*/
|
|
776
|
-
fetch<R =
|
|
776
|
+
fetch<R = Any>(query: string): Observable<R>
|
|
777
777
|
/**
|
|
778
778
|
* Perform a GROQ-query against the configured dataset.
|
|
779
779
|
*
|
|
780
780
|
* @param query - GROQ-query to perform
|
|
781
781
|
* @param params - Query parameters
|
|
782
782
|
*/
|
|
783
|
-
fetch<R =
|
|
783
|
+
fetch<R = Any, Q = QueryParams>(query: string, params: Q): Observable<R>
|
|
784
784
|
/**
|
|
785
785
|
* Perform a GROQ-query against the configured dataset.
|
|
786
786
|
*
|
|
@@ -788,7 +788,7 @@ export declare class ObservableSanityClient {
|
|
|
788
788
|
* @param params - Query parameters
|
|
789
789
|
* @param options - Request options
|
|
790
790
|
*/
|
|
791
|
-
fetch<R =
|
|
791
|
+
fetch<R = Any, Q = QueryParams>(
|
|
792
792
|
query: string,
|
|
793
793
|
params: Q | undefined,
|
|
794
794
|
options: FilteredResponseQueryOptions
|
|
@@ -800,7 +800,7 @@ export declare class ObservableSanityClient {
|
|
|
800
800
|
* @param params - Query parameters
|
|
801
801
|
* @param options - Request options
|
|
802
802
|
*/
|
|
803
|
-
fetch<R =
|
|
803
|
+
fetch<R = Any, Q = QueryParams>(
|
|
804
804
|
query: string,
|
|
805
805
|
params: Q | undefined,
|
|
806
806
|
options: UnfilteredResponseQueryOptions
|
|
@@ -811,7 +811,7 @@ export declare class ObservableSanityClient {
|
|
|
811
811
|
* @param id - Document ID to fetch
|
|
812
812
|
* @param options - Request options
|
|
813
813
|
*/
|
|
814
|
-
getDocument<R extends Record<string,
|
|
814
|
+
getDocument<R extends Record<string, Any> = Record<string, Any>>(
|
|
815
815
|
id: string,
|
|
816
816
|
options?: {
|
|
817
817
|
tag?: string
|
|
@@ -826,7 +826,7 @@ export declare class ObservableSanityClient {
|
|
|
826
826
|
* @param ids - Document IDs to fetch
|
|
827
827
|
* @param options - Request options
|
|
828
828
|
*/
|
|
829
|
-
getDocuments<R extends Record<string,
|
|
829
|
+
getDocuments<R extends Record<string, Any> = Record<string, Any>>(
|
|
830
830
|
ids: string[],
|
|
831
831
|
options?: {
|
|
832
832
|
tag?: string
|
|
@@ -839,7 +839,7 @@ export declare class ObservableSanityClient {
|
|
|
839
839
|
* @param document - Document to create
|
|
840
840
|
* @param options - Mutation options
|
|
841
841
|
*/
|
|
842
|
-
create<R extends Record<string,
|
|
842
|
+
create<R extends Record<string, Any> = Record<string, Any>>(
|
|
843
843
|
document: SanityDocumentStub<R>,
|
|
844
844
|
options: FirstDocumentMutationOptions
|
|
845
845
|
): Observable<SanityDocument<R>>
|
|
@@ -850,7 +850,7 @@ export declare class ObservableSanityClient {
|
|
|
850
850
|
* @param document - Document to create
|
|
851
851
|
* @param options - Mutation options
|
|
852
852
|
*/
|
|
853
|
-
create<R extends Record<string,
|
|
853
|
+
create<R extends Record<string, Any> = Record<string, Any>>(
|
|
854
854
|
document: SanityDocumentStub<R>,
|
|
855
855
|
options: AllDocumentsMutationOptions
|
|
856
856
|
): Observable<SanityDocument<R>[]>
|
|
@@ -861,7 +861,7 @@ export declare class ObservableSanityClient {
|
|
|
861
861
|
* @param document - Document to create
|
|
862
862
|
* @param options - Mutation options
|
|
863
863
|
*/
|
|
864
|
-
create<R extends Record<string,
|
|
864
|
+
create<R extends Record<string, Any> = Record<string, Any>>(
|
|
865
865
|
document: SanityDocumentStub<R>,
|
|
866
866
|
options: FirstDocumentIdMutationOptions
|
|
867
867
|
): Observable<SingleMutationResult>
|
|
@@ -872,7 +872,7 @@ export declare class ObservableSanityClient {
|
|
|
872
872
|
* @param document - Document to create
|
|
873
873
|
* @param options - Mutation options
|
|
874
874
|
*/
|
|
875
|
-
create<R extends Record<string,
|
|
875
|
+
create<R extends Record<string, Any> = Record<string, Any>>(
|
|
876
876
|
document: SanityDocumentStub<R>,
|
|
877
877
|
options: AllDocumentIdsMutationOptions
|
|
878
878
|
): Observable<MultipleMutationResult>
|
|
@@ -883,7 +883,7 @@ export declare class ObservableSanityClient {
|
|
|
883
883
|
* @param document - Document to create
|
|
884
884
|
* @param options - Mutation options
|
|
885
885
|
*/
|
|
886
|
-
create<R extends Record<string,
|
|
886
|
+
create<R extends Record<string, Any> = Record<string, Any>>(
|
|
887
887
|
document: SanityDocumentStub<R>,
|
|
888
888
|
options?: BaseMutationOptions
|
|
889
889
|
): Observable<SanityDocument<R>>
|
|
@@ -894,7 +894,7 @@ export declare class ObservableSanityClient {
|
|
|
894
894
|
* @param document - Document to create
|
|
895
895
|
* @param options - Mutation options
|
|
896
896
|
*/
|
|
897
|
-
createIfNotExists<R extends Record<string,
|
|
897
|
+
createIfNotExists<R extends Record<string, Any> = Record<string, Any>>(
|
|
898
898
|
document: IdentifiedSanityDocumentStub<R>,
|
|
899
899
|
options: FirstDocumentMutationOptions
|
|
900
900
|
): Observable<SanityDocument<R>>
|
|
@@ -905,7 +905,7 @@ export declare class ObservableSanityClient {
|
|
|
905
905
|
* @param document - Document to create
|
|
906
906
|
* @param options - Mutation options
|
|
907
907
|
*/
|
|
908
|
-
createIfNotExists<R extends Record<string,
|
|
908
|
+
createIfNotExists<R extends Record<string, Any> = Record<string, Any>>(
|
|
909
909
|
document: IdentifiedSanityDocumentStub<R>,
|
|
910
910
|
options: AllDocumentsMutationOptions
|
|
911
911
|
): Observable<SanityDocument<R>[]>
|
|
@@ -916,7 +916,7 @@ export declare class ObservableSanityClient {
|
|
|
916
916
|
* @param document - Document to create
|
|
917
917
|
* @param options - Mutation options
|
|
918
918
|
*/
|
|
919
|
-
createIfNotExists<R extends Record<string,
|
|
919
|
+
createIfNotExists<R extends Record<string, Any> = Record<string, Any>>(
|
|
920
920
|
document: IdentifiedSanityDocumentStub<R>,
|
|
921
921
|
options: FirstDocumentIdMutationOptions
|
|
922
922
|
): Observable<SingleMutationResult>
|
|
@@ -927,7 +927,7 @@ export declare class ObservableSanityClient {
|
|
|
927
927
|
* @param document - Document to create
|
|
928
928
|
* @param options - Mutation options
|
|
929
929
|
*/
|
|
930
|
-
createIfNotExists<R extends Record<string,
|
|
930
|
+
createIfNotExists<R extends Record<string, Any> = Record<string, Any>>(
|
|
931
931
|
document: IdentifiedSanityDocumentStub<R>,
|
|
932
932
|
options: AllDocumentIdsMutationOptions
|
|
933
933
|
): Observable<MultipleMutationResult>
|
|
@@ -938,7 +938,7 @@ export declare class ObservableSanityClient {
|
|
|
938
938
|
* @param document - Document to create
|
|
939
939
|
* @param options - Mutation options
|
|
940
940
|
*/
|
|
941
|
-
createIfNotExists<R extends Record<string,
|
|
941
|
+
createIfNotExists<R extends Record<string, Any> = Record<string, Any>>(
|
|
942
942
|
document: IdentifiedSanityDocumentStub<R>,
|
|
943
943
|
options?: BaseMutationOptions
|
|
944
944
|
): Observable<SanityDocument<R>>
|
|
@@ -949,7 +949,7 @@ export declare class ObservableSanityClient {
|
|
|
949
949
|
* @param document - Document to either create or replace
|
|
950
950
|
* @param options - Mutation options
|
|
951
951
|
*/
|
|
952
|
-
createOrReplace<R extends Record<string,
|
|
952
|
+
createOrReplace<R extends Record<string, Any> = Record<string, Any>>(
|
|
953
953
|
document: IdentifiedSanityDocumentStub<R>,
|
|
954
954
|
options: FirstDocumentMutationOptions
|
|
955
955
|
): Observable<SanityDocument<R>>
|
|
@@ -960,7 +960,7 @@ export declare class ObservableSanityClient {
|
|
|
960
960
|
* @param document - Document to either create or replace
|
|
961
961
|
* @param options - Mutation options
|
|
962
962
|
*/
|
|
963
|
-
createOrReplace<R extends Record<string,
|
|
963
|
+
createOrReplace<R extends Record<string, Any> = Record<string, Any>>(
|
|
964
964
|
document: IdentifiedSanityDocumentStub<R>,
|
|
965
965
|
options: AllDocumentsMutationOptions
|
|
966
966
|
): Observable<SanityDocument<R>[]>
|
|
@@ -971,7 +971,7 @@ export declare class ObservableSanityClient {
|
|
|
971
971
|
* @param document - Document to either create or replace
|
|
972
972
|
* @param options - Mutation options
|
|
973
973
|
*/
|
|
974
|
-
createOrReplace<R extends Record<string,
|
|
974
|
+
createOrReplace<R extends Record<string, Any> = Record<string, Any>>(
|
|
975
975
|
document: IdentifiedSanityDocumentStub<R>,
|
|
976
976
|
options: FirstDocumentIdMutationOptions
|
|
977
977
|
): Observable<SingleMutationResult>
|
|
@@ -982,7 +982,7 @@ export declare class ObservableSanityClient {
|
|
|
982
982
|
* @param document - Document to either create or replace
|
|
983
983
|
* @param options - Mutation options
|
|
984
984
|
*/
|
|
985
|
-
createOrReplace<R extends Record<string,
|
|
985
|
+
createOrReplace<R extends Record<string, Any> = Record<string, Any>>(
|
|
986
986
|
document: IdentifiedSanityDocumentStub<R>,
|
|
987
987
|
options: AllDocumentIdsMutationOptions
|
|
988
988
|
): Observable<MultipleMutationResult>
|
|
@@ -993,7 +993,7 @@ export declare class ObservableSanityClient {
|
|
|
993
993
|
* @param document - Document to either create or replace
|
|
994
994
|
* @param options - Mutation options
|
|
995
995
|
*/
|
|
996
|
-
createOrReplace<R extends Record<string,
|
|
996
|
+
createOrReplace<R extends Record<string, Any> = Record<string, Any>>(
|
|
997
997
|
document: IdentifiedSanityDocumentStub<R>,
|
|
998
998
|
options?: BaseMutationOptions
|
|
999
999
|
): Observable<SanityDocument<R>>
|
|
@@ -1004,7 +1004,7 @@ export declare class ObservableSanityClient {
|
|
|
1004
1004
|
* @param id - Document ID to delete
|
|
1005
1005
|
* @param options - Options for the mutation
|
|
1006
1006
|
*/
|
|
1007
|
-
delete<R extends Record<string,
|
|
1007
|
+
delete<R extends Record<string, Any> = Record<string, Any>>(
|
|
1008
1008
|
id: string,
|
|
1009
1009
|
options: FirstDocumentMutationOptions
|
|
1010
1010
|
): Observable<SanityDocument<R>>
|
|
@@ -1015,7 +1015,7 @@ export declare class ObservableSanityClient {
|
|
|
1015
1015
|
* @param id - Document ID to delete
|
|
1016
1016
|
* @param options - Options for the mutation
|
|
1017
1017
|
*/
|
|
1018
|
-
delete<R extends Record<string,
|
|
1018
|
+
delete<R extends Record<string, Any> = Record<string, Any>>(
|
|
1019
1019
|
id: string,
|
|
1020
1020
|
options: AllDocumentsMutationOptions
|
|
1021
1021
|
): Observable<SanityDocument<R>[]>
|
|
@@ -1042,7 +1042,7 @@ export declare class ObservableSanityClient {
|
|
|
1042
1042
|
* @param id - Document ID to delete
|
|
1043
1043
|
* @param options - Options for the mutation
|
|
1044
1044
|
*/
|
|
1045
|
-
delete<R extends Record<string,
|
|
1045
|
+
delete<R extends Record<string, Any> = Record<string, Any>>(
|
|
1046
1046
|
id: string,
|
|
1047
1047
|
options?: BaseMutationOptions
|
|
1048
1048
|
): Observable<SanityDocument<R>>
|
|
@@ -1053,7 +1053,7 @@ export declare class ObservableSanityClient {
|
|
|
1053
1053
|
* @param selection - An object with either an `id` or `query` key defining what to delete
|
|
1054
1054
|
* @param options - Options for the mutation
|
|
1055
1055
|
*/
|
|
1056
|
-
delete<R extends Record<string,
|
|
1056
|
+
delete<R extends Record<string, Any> = Record<string, Any>>(
|
|
1057
1057
|
selection: MutationSelection,
|
|
1058
1058
|
options: FirstDocumentMutationOptions
|
|
1059
1059
|
): Observable<SanityDocument<R>>
|
|
@@ -1064,7 +1064,7 @@ export declare class ObservableSanityClient {
|
|
|
1064
1064
|
* @param selection - An object with either an `id` or `query` key defining what to delete
|
|
1065
1065
|
* @param options - Options for the mutation
|
|
1066
1066
|
*/
|
|
1067
|
-
delete<R extends Record<string,
|
|
1067
|
+
delete<R extends Record<string, Any> = Record<string, Any>>(
|
|
1068
1068
|
selection: MutationSelection,
|
|
1069
1069
|
options: AllDocumentsMutationOptions
|
|
1070
1070
|
): Observable<SanityDocument<R>[]>
|
|
@@ -1097,7 +1097,7 @@ export declare class ObservableSanityClient {
|
|
|
1097
1097
|
* @param selection - An object with either an `id` or `query` key defining what to delete
|
|
1098
1098
|
* @param options - Options for the mutation
|
|
1099
1099
|
*/
|
|
1100
|
-
delete<R extends Record<string,
|
|
1100
|
+
delete<R extends Record<string, Any> = Record<string, Any>>(
|
|
1101
1101
|
selection: MutationSelection,
|
|
1102
1102
|
options?: BaseMutationOptions
|
|
1103
1103
|
): Observable<SanityDocument<R>>
|
|
@@ -1108,7 +1108,7 @@ export declare class ObservableSanityClient {
|
|
|
1108
1108
|
* @param operations - Mutation operations to execute
|
|
1109
1109
|
* @param options - Mutation options
|
|
1110
1110
|
*/
|
|
1111
|
-
mutate<R extends Record<string,
|
|
1111
|
+
mutate<R extends Record<string, Any> = Record<string, Any>>(
|
|
1112
1112
|
operations: Mutation<R>[] | ObservablePatch | ObservableTransaction,
|
|
1113
1113
|
options: FirstDocumentMutationOptions
|
|
1114
1114
|
): Observable<SanityDocument<R>>
|
|
@@ -1119,7 +1119,7 @@ export declare class ObservableSanityClient {
|
|
|
1119
1119
|
* @param operations - Mutation operations to execute
|
|
1120
1120
|
* @param options - Mutation options
|
|
1121
1121
|
*/
|
|
1122
|
-
mutate<R extends Record<string,
|
|
1122
|
+
mutate<R extends Record<string, Any> = Record<string, Any>>(
|
|
1123
1123
|
operations: Mutation<R>[] | ObservablePatch | ObservableTransaction,
|
|
1124
1124
|
options: AllDocumentsMutationOptions
|
|
1125
1125
|
): Observable<SanityDocument<R>[]>
|
|
@@ -1130,7 +1130,7 @@ export declare class ObservableSanityClient {
|
|
|
1130
1130
|
* @param operations - Mutation operations to execute
|
|
1131
1131
|
* @param options - Mutation options
|
|
1132
1132
|
*/
|
|
1133
|
-
mutate<R extends Record<string,
|
|
1133
|
+
mutate<R extends Record<string, Any> = Record<string, Any>>(
|
|
1134
1134
|
operations: Mutation<R>[] | ObservablePatch | ObservableTransaction,
|
|
1135
1135
|
options: FirstDocumentIdMutationOptions
|
|
1136
1136
|
): Observable<SingleMutationResult>
|
|
@@ -1141,7 +1141,7 @@ export declare class ObservableSanityClient {
|
|
|
1141
1141
|
* @param operations - Mutation operations to execute
|
|
1142
1142
|
* @param options - Mutation options
|
|
1143
1143
|
*/
|
|
1144
|
-
mutate<R extends Record<string,
|
|
1144
|
+
mutate<R extends Record<string, Any> = Record<string, Any>>(
|
|
1145
1145
|
operations: Mutation<R>[] | ObservablePatch | ObservableTransaction,
|
|
1146
1146
|
options: AllDocumentIdsMutationOptions
|
|
1147
1147
|
): Observable<MultipleMutationResult>
|
|
@@ -1152,7 +1152,7 @@ export declare class ObservableSanityClient {
|
|
|
1152
1152
|
* @param operations - Mutation operations to execute
|
|
1153
1153
|
* @param options - Mutation options
|
|
1154
1154
|
*/
|
|
1155
|
-
mutate<R extends Record<string,
|
|
1155
|
+
mutate<R extends Record<string, Any> = Record<string, Any>>(
|
|
1156
1156
|
operations: Mutation<R>[] | ObservablePatch | ObservableTransaction,
|
|
1157
1157
|
options?: BaseMutationOptions
|
|
1158
1158
|
): Observable<SanityDocument<R>>
|
|
@@ -1168,7 +1168,7 @@ export declare class ObservableSanityClient {
|
|
|
1168
1168
|
*
|
|
1169
1169
|
* @param operations - Optional array of mutation operations to initialize the transaction instance with
|
|
1170
1170
|
*/
|
|
1171
|
-
transaction<R extends Record<string,
|
|
1171
|
+
transaction<R extends Record<string, Any> = Record<string, Any>>(
|
|
1172
1172
|
operations?: Mutation<R>[]
|
|
1173
1173
|
): ObservableTransaction
|
|
1174
1174
|
/**
|
|
@@ -1177,7 +1177,21 @@ export declare class ObservableSanityClient {
|
|
|
1177
1177
|
* @deprecated Use your own request library!
|
|
1178
1178
|
* @param options - Request options
|
|
1179
1179
|
*/
|
|
1180
|
-
request<R =
|
|
1180
|
+
request<R = Any>(options: RawRequestOptions): Observable<R>
|
|
1181
|
+
/**
|
|
1182
|
+
* Get a Sanity API URL for the URI provided
|
|
1183
|
+
*
|
|
1184
|
+
* @param uri - URI/path to build URL for
|
|
1185
|
+
* @param canUseCdn - Whether or not to allow using the API CDN for this route
|
|
1186
|
+
*/
|
|
1187
|
+
getUrl(uri: string, canUseCdn?: boolean): string
|
|
1188
|
+
/**
|
|
1189
|
+
* Get a Sanity API URL for the data operation and path provided
|
|
1190
|
+
*
|
|
1191
|
+
* @param operation - Data operation (eg `query`, `mutate`, `listen` or similar)
|
|
1192
|
+
* @param path - Path to append after the operation
|
|
1193
|
+
*/
|
|
1194
|
+
getDataUrl(operation: string, path?: string): string
|
|
1181
1195
|
}
|
|
1182
1196
|
|
|
1183
1197
|
/** @public */
|
|
@@ -1193,7 +1207,7 @@ export declare class ObservableTransaction extends BaseTransaction {
|
|
|
1193
1207
|
*
|
|
1194
1208
|
* @param options - Options for the mutation operation
|
|
1195
1209
|
*/
|
|
1196
|
-
commit<R extends Record<string,
|
|
1210
|
+
commit<R extends Record<string, Any>>(
|
|
1197
1211
|
options: TransactionFirstDocumentMutationOptions
|
|
1198
1212
|
): Observable<SanityDocument<R>>
|
|
1199
1213
|
/**
|
|
@@ -1201,7 +1215,7 @@ export declare class ObservableTransaction extends BaseTransaction {
|
|
|
1201
1215
|
*
|
|
1202
1216
|
* @param options - Options for the mutation operation
|
|
1203
1217
|
*/
|
|
1204
|
-
commit<R extends Record<string,
|
|
1218
|
+
commit<R extends Record<string, Any>>(
|
|
1205
1219
|
options: TransactionAllDocumentsMutationOptions
|
|
1206
1220
|
): Observable<SanityDocument<R>[]>
|
|
1207
1221
|
/**
|
|
@@ -1266,7 +1280,7 @@ export declare class Patch extends BasePatch {
|
|
|
1266
1280
|
*
|
|
1267
1281
|
* @param options - Options for the mutation operation
|
|
1268
1282
|
*/
|
|
1269
|
-
commit<R extends Record<string,
|
|
1283
|
+
commit<R extends Record<string, Any> = Record<string, Any>>(
|
|
1270
1284
|
options: FirstDocumentMutationOptions
|
|
1271
1285
|
): Promise<SanityDocument<R>>
|
|
1272
1286
|
/**
|
|
@@ -1274,7 +1288,7 @@ export declare class Patch extends BasePatch {
|
|
|
1274
1288
|
*
|
|
1275
1289
|
* @param options - Options for the mutation operation
|
|
1276
1290
|
*/
|
|
1277
|
-
commit<R extends Record<string,
|
|
1291
|
+
commit<R extends Record<string, Any> = Record<string, Any>>(
|
|
1278
1292
|
options: AllDocumentsMutationOptions
|
|
1279
1293
|
): Promise<SanityDocument<R>[]>
|
|
1280
1294
|
/**
|
|
@@ -1294,7 +1308,7 @@ export declare class Patch extends BasePatch {
|
|
|
1294
1308
|
*
|
|
1295
1309
|
* @param options - Options for the mutation operation
|
|
1296
1310
|
*/
|
|
1297
|
-
commit<R extends Record<string,
|
|
1311
|
+
commit<R extends Record<string, Any> = Record<string, Any>>(
|
|
1298
1312
|
options?: BaseMutationOptions
|
|
1299
1313
|
): Promise<SanityDocument<R>>
|
|
1300
1314
|
}
|
|
@@ -1308,13 +1322,13 @@ export declare type PatchMutationOperation = PatchOperations & MutationSelection
|
|
|
1308
1322
|
/** @internal */
|
|
1309
1323
|
export declare interface PatchOperations {
|
|
1310
1324
|
set?: {
|
|
1311
|
-
[key: string]:
|
|
1325
|
+
[key: string]: Any
|
|
1312
1326
|
}
|
|
1313
1327
|
setIfMissing?: {
|
|
1314
|
-
[key: string]:
|
|
1328
|
+
[key: string]: Any
|
|
1315
1329
|
}
|
|
1316
1330
|
diffMatchPatch?: {
|
|
1317
|
-
[key: string]:
|
|
1331
|
+
[key: string]: Any
|
|
1318
1332
|
}
|
|
1319
1333
|
unset?: string[]
|
|
1320
1334
|
inc?: {
|
|
@@ -1359,7 +1373,7 @@ export declare class ProjectsClient {
|
|
|
1359
1373
|
|
|
1360
1374
|
/** @public */
|
|
1361
1375
|
export declare type QueryParams = {
|
|
1362
|
-
[key: string]:
|
|
1376
|
+
[key: string]: Any
|
|
1363
1377
|
}
|
|
1364
1378
|
|
|
1365
1379
|
/** @internal */
|
|
@@ -1387,7 +1401,7 @@ export declare interface RawRequestOptions {
|
|
|
1387
1401
|
}
|
|
1388
1402
|
timeout?: number
|
|
1389
1403
|
proxy?: string
|
|
1390
|
-
body?:
|
|
1404
|
+
body?: Any
|
|
1391
1405
|
maxRedirects?: number
|
|
1392
1406
|
}
|
|
1393
1407
|
|
|
@@ -1414,8 +1428,8 @@ export declare interface RequestOptions {
|
|
|
1414
1428
|
tag?: string
|
|
1415
1429
|
headers?: Record<string, string>
|
|
1416
1430
|
method?: string
|
|
1417
|
-
query?:
|
|
1418
|
-
body?:
|
|
1431
|
+
query?: Any
|
|
1432
|
+
body?: Any
|
|
1419
1433
|
signal?: AbortSignal
|
|
1420
1434
|
}
|
|
1421
1435
|
|
|
@@ -1482,14 +1496,14 @@ export declare class SanityClient {
|
|
|
1482
1496
|
*
|
|
1483
1497
|
* @param query - GROQ-query to perform
|
|
1484
1498
|
*/
|
|
1485
|
-
fetch<R =
|
|
1499
|
+
fetch<R = Any>(query: string): Promise<R>
|
|
1486
1500
|
/**
|
|
1487
1501
|
* Perform a GROQ-query against the configured dataset.
|
|
1488
1502
|
*
|
|
1489
1503
|
* @param query - GROQ-query to perform
|
|
1490
1504
|
* @param params - Optional query parameters
|
|
1491
1505
|
*/
|
|
1492
|
-
fetch<R =
|
|
1506
|
+
fetch<R = Any, Q = QueryParams>(query: string, params: Q): Promise<R>
|
|
1493
1507
|
/**
|
|
1494
1508
|
* Perform a GROQ-query against the configured dataset.
|
|
1495
1509
|
*
|
|
@@ -1497,7 +1511,7 @@ export declare class SanityClient {
|
|
|
1497
1511
|
* @param params - Optional query parameters
|
|
1498
1512
|
* @param options - Request options
|
|
1499
1513
|
*/
|
|
1500
|
-
fetch<R =
|
|
1514
|
+
fetch<R = Any, Q = QueryParams>(
|
|
1501
1515
|
query: string,
|
|
1502
1516
|
params: Q | undefined,
|
|
1503
1517
|
options: FilteredResponseQueryOptions
|
|
@@ -1509,7 +1523,7 @@ export declare class SanityClient {
|
|
|
1509
1523
|
* @param params - Optional query parameters
|
|
1510
1524
|
* @param options - Request options
|
|
1511
1525
|
*/
|
|
1512
|
-
fetch<R =
|
|
1526
|
+
fetch<R = Any, Q = QueryParams>(
|
|
1513
1527
|
query: string,
|
|
1514
1528
|
params: Q | undefined,
|
|
1515
1529
|
options: UnfilteredResponseQueryOptions
|
|
@@ -1520,7 +1534,7 @@ export declare class SanityClient {
|
|
|
1520
1534
|
* @param id - Document ID to fetch
|
|
1521
1535
|
* @param options - Request options
|
|
1522
1536
|
*/
|
|
1523
|
-
getDocument<R extends Record<string,
|
|
1537
|
+
getDocument<R extends Record<string, Any> = Record<string, Any>>(
|
|
1524
1538
|
id: string,
|
|
1525
1539
|
options?: {
|
|
1526
1540
|
tag?: string
|
|
@@ -1535,7 +1549,7 @@ export declare class SanityClient {
|
|
|
1535
1549
|
* @param ids - Document IDs to fetch
|
|
1536
1550
|
* @param options - Request options
|
|
1537
1551
|
*/
|
|
1538
|
-
getDocuments<R extends Record<string,
|
|
1552
|
+
getDocuments<R extends Record<string, Any> = Record<string, Any>>(
|
|
1539
1553
|
ids: string[],
|
|
1540
1554
|
options?: {
|
|
1541
1555
|
tag?: string
|
|
@@ -1548,7 +1562,7 @@ export declare class SanityClient {
|
|
|
1548
1562
|
* @param document - Document to create
|
|
1549
1563
|
* @param options - Mutation options
|
|
1550
1564
|
*/
|
|
1551
|
-
create<R extends Record<string,
|
|
1565
|
+
create<R extends Record<string, Any> = Record<string, Any>>(
|
|
1552
1566
|
document: SanityDocumentStub<R>,
|
|
1553
1567
|
options: FirstDocumentMutationOptions
|
|
1554
1568
|
): Promise<SanityDocument<R>>
|
|
@@ -1559,7 +1573,7 @@ export declare class SanityClient {
|
|
|
1559
1573
|
* @param document - Document to create
|
|
1560
1574
|
* @param options - Mutation options
|
|
1561
1575
|
*/
|
|
1562
|
-
create<R extends Record<string,
|
|
1576
|
+
create<R extends Record<string, Any> = Record<string, Any>>(
|
|
1563
1577
|
document: SanityDocumentStub<R>,
|
|
1564
1578
|
options: AllDocumentsMutationOptions
|
|
1565
1579
|
): Promise<SanityDocument<R>[]>
|
|
@@ -1570,7 +1584,7 @@ export declare class SanityClient {
|
|
|
1570
1584
|
* @param document - Document to create
|
|
1571
1585
|
* @param options - Mutation options
|
|
1572
1586
|
*/
|
|
1573
|
-
create<R extends Record<string,
|
|
1587
|
+
create<R extends Record<string, Any> = Record<string, Any>>(
|
|
1574
1588
|
document: SanityDocumentStub<R>,
|
|
1575
1589
|
options: FirstDocumentIdMutationOptions
|
|
1576
1590
|
): Promise<SingleMutationResult>
|
|
@@ -1581,7 +1595,7 @@ export declare class SanityClient {
|
|
|
1581
1595
|
* @param document - Document to create
|
|
1582
1596
|
* @param options - Mutation options
|
|
1583
1597
|
*/
|
|
1584
|
-
create<R extends Record<string,
|
|
1598
|
+
create<R extends Record<string, Any> = Record<string, Any>>(
|
|
1585
1599
|
document: SanityDocumentStub<R>,
|
|
1586
1600
|
options: AllDocumentIdsMutationOptions
|
|
1587
1601
|
): Promise<MultipleMutationResult>
|
|
@@ -1592,7 +1606,7 @@ export declare class SanityClient {
|
|
|
1592
1606
|
* @param document - Document to create
|
|
1593
1607
|
* @param options - Mutation options
|
|
1594
1608
|
*/
|
|
1595
|
-
create<R extends Record<string,
|
|
1609
|
+
create<R extends Record<string, Any> = Record<string, Any>>(
|
|
1596
1610
|
document: SanityDocumentStub<R>,
|
|
1597
1611
|
options?: BaseMutationOptions
|
|
1598
1612
|
): Promise<SanityDocument<R>>
|
|
@@ -1603,7 +1617,7 @@ export declare class SanityClient {
|
|
|
1603
1617
|
* @param document - Document to create
|
|
1604
1618
|
* @param options - Mutation options
|
|
1605
1619
|
*/
|
|
1606
|
-
createIfNotExists<R extends Record<string,
|
|
1620
|
+
createIfNotExists<R extends Record<string, Any> = Record<string, Any>>(
|
|
1607
1621
|
document: IdentifiedSanityDocumentStub<R>,
|
|
1608
1622
|
options: FirstDocumentMutationOptions
|
|
1609
1623
|
): Promise<SanityDocument<R>>
|
|
@@ -1614,7 +1628,7 @@ export declare class SanityClient {
|
|
|
1614
1628
|
* @param document - Document to create
|
|
1615
1629
|
* @param options - Mutation options
|
|
1616
1630
|
*/
|
|
1617
|
-
createIfNotExists<R extends Record<string,
|
|
1631
|
+
createIfNotExists<R extends Record<string, Any> = Record<string, Any>>(
|
|
1618
1632
|
document: IdentifiedSanityDocumentStub<R>,
|
|
1619
1633
|
options: AllDocumentsMutationOptions
|
|
1620
1634
|
): Promise<SanityDocument<R>[]>
|
|
@@ -1625,7 +1639,7 @@ export declare class SanityClient {
|
|
|
1625
1639
|
* @param document - Document to create
|
|
1626
1640
|
* @param options - Mutation options
|
|
1627
1641
|
*/
|
|
1628
|
-
createIfNotExists<R extends Record<string,
|
|
1642
|
+
createIfNotExists<R extends Record<string, Any> = Record<string, Any>>(
|
|
1629
1643
|
document: IdentifiedSanityDocumentStub<R>,
|
|
1630
1644
|
options: FirstDocumentIdMutationOptions
|
|
1631
1645
|
): Promise<SingleMutationResult>
|
|
@@ -1636,7 +1650,7 @@ export declare class SanityClient {
|
|
|
1636
1650
|
* @param document - Document to create
|
|
1637
1651
|
* @param options - Mutation options
|
|
1638
1652
|
*/
|
|
1639
|
-
createIfNotExists<R extends Record<string,
|
|
1653
|
+
createIfNotExists<R extends Record<string, Any> = Record<string, Any>>(
|
|
1640
1654
|
document: IdentifiedSanityDocumentStub<R>,
|
|
1641
1655
|
options: AllDocumentIdsMutationOptions
|
|
1642
1656
|
): Promise<MultipleMutationResult>
|
|
@@ -1647,7 +1661,7 @@ export declare class SanityClient {
|
|
|
1647
1661
|
* @param document - Document to create
|
|
1648
1662
|
* @param options - Mutation options
|
|
1649
1663
|
*/
|
|
1650
|
-
createIfNotExists<R extends Record<string,
|
|
1664
|
+
createIfNotExists<R extends Record<string, Any> = Record<string, Any>>(
|
|
1651
1665
|
document: IdentifiedSanityDocumentStub<R>,
|
|
1652
1666
|
options?: BaseMutationOptions
|
|
1653
1667
|
): Promise<SanityDocument<R>>
|
|
@@ -1658,7 +1672,7 @@ export declare class SanityClient {
|
|
|
1658
1672
|
* @param document - Document to either create or replace
|
|
1659
1673
|
* @param options - Mutation options
|
|
1660
1674
|
*/
|
|
1661
|
-
createOrReplace<R extends Record<string,
|
|
1675
|
+
createOrReplace<R extends Record<string, Any> = Record<string, Any>>(
|
|
1662
1676
|
document: IdentifiedSanityDocumentStub<R>,
|
|
1663
1677
|
options: FirstDocumentMutationOptions
|
|
1664
1678
|
): Promise<SanityDocument<R>>
|
|
@@ -1669,7 +1683,7 @@ export declare class SanityClient {
|
|
|
1669
1683
|
* @param document - Document to either create or replace
|
|
1670
1684
|
* @param options - Mutation options
|
|
1671
1685
|
*/
|
|
1672
|
-
createOrReplace<R extends Record<string,
|
|
1686
|
+
createOrReplace<R extends Record<string, Any> = Record<string, Any>>(
|
|
1673
1687
|
document: IdentifiedSanityDocumentStub<R>,
|
|
1674
1688
|
options: AllDocumentsMutationOptions
|
|
1675
1689
|
): Promise<SanityDocument<R>[]>
|
|
@@ -1680,7 +1694,7 @@ export declare class SanityClient {
|
|
|
1680
1694
|
* @param document - Document to either create or replace
|
|
1681
1695
|
* @param options - Mutation options
|
|
1682
1696
|
*/
|
|
1683
|
-
createOrReplace<R extends Record<string,
|
|
1697
|
+
createOrReplace<R extends Record<string, Any> = Record<string, Any>>(
|
|
1684
1698
|
document: IdentifiedSanityDocumentStub<R>,
|
|
1685
1699
|
options: FirstDocumentIdMutationOptions
|
|
1686
1700
|
): Promise<SingleMutationResult>
|
|
@@ -1691,7 +1705,7 @@ export declare class SanityClient {
|
|
|
1691
1705
|
* @param document - Document to either create or replace
|
|
1692
1706
|
* @param options - Mutation options
|
|
1693
1707
|
*/
|
|
1694
|
-
createOrReplace<R extends Record<string,
|
|
1708
|
+
createOrReplace<R extends Record<string, Any> = Record<string, Any>>(
|
|
1695
1709
|
document: IdentifiedSanityDocumentStub<R>,
|
|
1696
1710
|
options: AllDocumentIdsMutationOptions
|
|
1697
1711
|
): Promise<MultipleMutationResult>
|
|
@@ -1702,7 +1716,7 @@ export declare class SanityClient {
|
|
|
1702
1716
|
* @param document - Document to either create or replace
|
|
1703
1717
|
* @param options - Mutation options
|
|
1704
1718
|
*/
|
|
1705
|
-
createOrReplace<R extends Record<string,
|
|
1719
|
+
createOrReplace<R extends Record<string, Any> = Record<string, Any>>(
|
|
1706
1720
|
document: IdentifiedSanityDocumentStub<R>,
|
|
1707
1721
|
options?: BaseMutationOptions
|
|
1708
1722
|
): Promise<SanityDocument<R>>
|
|
@@ -1713,7 +1727,7 @@ export declare class SanityClient {
|
|
|
1713
1727
|
* @param id - Document ID to delete
|
|
1714
1728
|
* @param options - Options for the mutation
|
|
1715
1729
|
*/
|
|
1716
|
-
delete<R extends Record<string,
|
|
1730
|
+
delete<R extends Record<string, Any> = Record<string, Any>>(
|
|
1717
1731
|
id: string,
|
|
1718
1732
|
options: FirstDocumentMutationOptions
|
|
1719
1733
|
): Promise<SanityDocument<R>>
|
|
@@ -1724,7 +1738,7 @@ export declare class SanityClient {
|
|
|
1724
1738
|
* @param id - Document ID to delete
|
|
1725
1739
|
* @param options - Options for the mutation
|
|
1726
1740
|
*/
|
|
1727
|
-
delete<R extends Record<string,
|
|
1741
|
+
delete<R extends Record<string, Any> = Record<string, Any>>(
|
|
1728
1742
|
id: string,
|
|
1729
1743
|
options: AllDocumentsMutationOptions
|
|
1730
1744
|
): Promise<SanityDocument<R>[]>
|
|
@@ -1751,7 +1765,7 @@ export declare class SanityClient {
|
|
|
1751
1765
|
* @param id - Document ID to delete
|
|
1752
1766
|
* @param options - Options for the mutation
|
|
1753
1767
|
*/
|
|
1754
|
-
delete<R extends Record<string,
|
|
1768
|
+
delete<R extends Record<string, Any> = Record<string, Any>>(
|
|
1755
1769
|
id: string,
|
|
1756
1770
|
options?: BaseMutationOptions
|
|
1757
1771
|
): Promise<SanityDocument<R>>
|
|
@@ -1762,7 +1776,7 @@ export declare class SanityClient {
|
|
|
1762
1776
|
* @param selection - An object with either an `id` or `query` key defining what to delete
|
|
1763
1777
|
* @param options - Options for the mutation
|
|
1764
1778
|
*/
|
|
1765
|
-
delete<R extends Record<string,
|
|
1779
|
+
delete<R extends Record<string, Any> = Record<string, Any>>(
|
|
1766
1780
|
selection: MutationSelection,
|
|
1767
1781
|
options: FirstDocumentMutationOptions
|
|
1768
1782
|
): Promise<SanityDocument<R>>
|
|
@@ -1773,7 +1787,7 @@ export declare class SanityClient {
|
|
|
1773
1787
|
* @param selection - An object with either an `id` or `query` key defining what to delete
|
|
1774
1788
|
* @param options - Options for the mutation
|
|
1775
1789
|
*/
|
|
1776
|
-
delete<R extends Record<string,
|
|
1790
|
+
delete<R extends Record<string, Any> = Record<string, Any>>(
|
|
1777
1791
|
selection: MutationSelection,
|
|
1778
1792
|
options: AllDocumentsMutationOptions
|
|
1779
1793
|
): Promise<SanityDocument<R>[]>
|
|
@@ -1806,7 +1820,7 @@ export declare class SanityClient {
|
|
|
1806
1820
|
* @param selection - An object with either an `id` or `query` key defining what to delete
|
|
1807
1821
|
* @param options - Options for the mutation
|
|
1808
1822
|
*/
|
|
1809
|
-
delete<R extends Record<string,
|
|
1823
|
+
delete<R extends Record<string, Any> = Record<string, Any>>(
|
|
1810
1824
|
selection: MutationSelection,
|
|
1811
1825
|
options?: BaseMutationOptions
|
|
1812
1826
|
): Promise<SanityDocument<R>>
|
|
@@ -1817,7 +1831,7 @@ export declare class SanityClient {
|
|
|
1817
1831
|
* @param operations - Mutation operations to execute
|
|
1818
1832
|
* @param options - Mutation options
|
|
1819
1833
|
*/
|
|
1820
|
-
mutate<R extends Record<string,
|
|
1834
|
+
mutate<R extends Record<string, Any> = Record<string, Any>>(
|
|
1821
1835
|
operations: Mutation<R>[] | Patch | Transaction,
|
|
1822
1836
|
options: FirstDocumentMutationOptions
|
|
1823
1837
|
): Promise<SanityDocument<R>>
|
|
@@ -1828,7 +1842,7 @@ export declare class SanityClient {
|
|
|
1828
1842
|
* @param operations - Mutation operations to execute
|
|
1829
1843
|
* @param options - Mutation options
|
|
1830
1844
|
*/
|
|
1831
|
-
mutate<R extends Record<string,
|
|
1845
|
+
mutate<R extends Record<string, Any> = Record<string, Any>>(
|
|
1832
1846
|
operations: Mutation<R>[] | Patch | Transaction,
|
|
1833
1847
|
options: AllDocumentsMutationOptions
|
|
1834
1848
|
): Promise<SanityDocument<R>[]>
|
|
@@ -1839,7 +1853,7 @@ export declare class SanityClient {
|
|
|
1839
1853
|
* @param operations - Mutation operations to execute
|
|
1840
1854
|
* @param options - Mutation options
|
|
1841
1855
|
*/
|
|
1842
|
-
mutate<R extends Record<string,
|
|
1856
|
+
mutate<R extends Record<string, Any> = Record<string, Any>>(
|
|
1843
1857
|
operations: Mutation<R>[] | Patch | Transaction,
|
|
1844
1858
|
options: FirstDocumentIdMutationOptions
|
|
1845
1859
|
): Promise<SingleMutationResult>
|
|
@@ -1850,7 +1864,7 @@ export declare class SanityClient {
|
|
|
1850
1864
|
* @param operations - Mutation operations to execute
|
|
1851
1865
|
* @param options - Mutation options
|
|
1852
1866
|
*/
|
|
1853
|
-
mutate<R extends Record<string,
|
|
1867
|
+
mutate<R extends Record<string, Any>>(
|
|
1854
1868
|
operations: Mutation<R>[] | Patch | Transaction,
|
|
1855
1869
|
options: AllDocumentIdsMutationOptions
|
|
1856
1870
|
): Promise<MultipleMutationResult>
|
|
@@ -1861,7 +1875,7 @@ export declare class SanityClient {
|
|
|
1861
1875
|
* @param operations - Mutation operations to execute
|
|
1862
1876
|
* @param options - Mutation options
|
|
1863
1877
|
*/
|
|
1864
|
-
mutate<R extends Record<string,
|
|
1878
|
+
mutate<R extends Record<string, Any> = Record<string, Any>>(
|
|
1865
1879
|
operations: Mutation<R>[] | Patch | Transaction,
|
|
1866
1880
|
options?: BaseMutationOptions
|
|
1867
1881
|
): Promise<SanityDocument<R>>
|
|
@@ -1877,7 +1891,7 @@ export declare class SanityClient {
|
|
|
1877
1891
|
*
|
|
1878
1892
|
* @param operations - Optional array of mutation operations to initialize the transaction instance with
|
|
1879
1893
|
*/
|
|
1880
|
-
transaction<R extends Record<string,
|
|
1894
|
+
transaction<R extends Record<string, Any> = Record<string, Any>>(
|
|
1881
1895
|
operations?: Mutation<R>[]
|
|
1882
1896
|
): Transaction
|
|
1883
1897
|
/**
|
|
@@ -1886,7 +1900,7 @@ export declare class SanityClient {
|
|
|
1886
1900
|
* @deprecated Use your own request library!
|
|
1887
1901
|
* @param options - Request options
|
|
1888
1902
|
*/
|
|
1889
|
-
request<R =
|
|
1903
|
+
request<R = Any>(options: RawRequestOptions): Promise<R>
|
|
1890
1904
|
/**
|
|
1891
1905
|
* DEPRECATED: Perform an HTTP request a `/data` sub-endpoint
|
|
1892
1906
|
*
|
|
@@ -1895,11 +1909,25 @@ export declare class SanityClient {
|
|
|
1895
1909
|
* @param body - Request body
|
|
1896
1910
|
* @param options - Request options
|
|
1897
1911
|
*/
|
|
1898
|
-
dataRequest(endpoint: string, body: unknown, options?: BaseMutationOptions): Promise<
|
|
1912
|
+
dataRequest(endpoint: string, body: unknown, options?: BaseMutationOptions): Promise<Any>
|
|
1913
|
+
/**
|
|
1914
|
+
* Get a Sanity API URL for the URI provided
|
|
1915
|
+
*
|
|
1916
|
+
* @param uri - URI/path to build URL for
|
|
1917
|
+
* @param canUseCdn - Whether or not to allow using the API CDN for this route
|
|
1918
|
+
*/
|
|
1919
|
+
getUrl(uri: string, canUseCdn?: boolean): string
|
|
1920
|
+
/**
|
|
1921
|
+
* Get a Sanity API URL for the data operation and path provided
|
|
1922
|
+
*
|
|
1923
|
+
* @param operation - Data operation (eg `query`, `mutate`, `listen` or similar)
|
|
1924
|
+
* @param path - Path to append after the operation
|
|
1925
|
+
*/
|
|
1926
|
+
getDataUrl(operation: string, path?: string): string
|
|
1899
1927
|
}
|
|
1900
1928
|
|
|
1901
1929
|
/** @internal */
|
|
1902
|
-
export declare type SanityDocument<T extends Record<string,
|
|
1930
|
+
export declare type SanityDocument<T extends Record<string, Any> = Record<string, Any>> = {
|
|
1903
1931
|
[P in keyof T]: T[P]
|
|
1904
1932
|
} & {
|
|
1905
1933
|
_id: string
|
|
@@ -1910,7 +1938,7 @@ export declare type SanityDocument<T extends Record<string, FIXME> = Record<stri
|
|
|
1910
1938
|
}
|
|
1911
1939
|
|
|
1912
1940
|
/** @public */
|
|
1913
|
-
export declare type SanityDocumentStub<T extends Record<string,
|
|
1941
|
+
export declare type SanityDocumentStub<T extends Record<string, Any> = Record<string, Any>> = {
|
|
1914
1942
|
[P in keyof T]: T[P]
|
|
1915
1943
|
} & {
|
|
1916
1944
|
_type: string
|
|
@@ -1942,11 +1970,11 @@ export declare interface SanityImageAssetDocument extends SanityAssetDocument {
|
|
|
1942
1970
|
}
|
|
1943
1971
|
image?: {
|
|
1944
1972
|
_type: 'sanity.imageExifTags'
|
|
1945
|
-
[key: string]:
|
|
1973
|
+
[key: string]: Any
|
|
1946
1974
|
}
|
|
1947
1975
|
exif?: {
|
|
1948
1976
|
_type: 'sanity.imageExifMetadata'
|
|
1949
|
-
[key: string]:
|
|
1977
|
+
[key: string]: Any
|
|
1950
1978
|
}
|
|
1951
1979
|
}
|
|
1952
1980
|
}
|
|
@@ -2011,7 +2039,7 @@ export declare class ServerError extends Error {
|
|
|
2011
2039
|
statusCode: ErrorProps['statusCode']
|
|
2012
2040
|
responseBody: ErrorProps['responseBody']
|
|
2013
2041
|
details: ErrorProps['details']
|
|
2014
|
-
constructor(res:
|
|
2042
|
+
constructor(res: Any)
|
|
2015
2043
|
}
|
|
2016
2044
|
|
|
2017
2045
|
/** @internal */
|
|
@@ -2037,7 +2065,7 @@ export declare class Transaction extends BaseTransaction {
|
|
|
2037
2065
|
*
|
|
2038
2066
|
* @param options - Options for the mutation operation
|
|
2039
2067
|
*/
|
|
2040
|
-
commit<R extends Record<string,
|
|
2068
|
+
commit<R extends Record<string, Any>>(
|
|
2041
2069
|
options: TransactionFirstDocumentMutationOptions
|
|
2042
2070
|
): Promise<SanityDocument<R>>
|
|
2043
2071
|
/**
|
|
@@ -2045,7 +2073,7 @@ export declare class Transaction extends BaseTransaction {
|
|
|
2045
2073
|
*
|
|
2046
2074
|
* @param options - Options for the mutation operation
|
|
2047
2075
|
*/
|
|
2048
|
-
commit<R extends Record<string,
|
|
2076
|
+
commit<R extends Record<string, Any>>(
|
|
2049
2077
|
options: TransactionAllDocumentsMutationOptions
|
|
2050
2078
|
): Promise<SanityDocument<R>[]>
|
|
2051
2079
|
/**
|