@sanity/client 6.11.3 → 6.11.4-canary.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/README.md +85 -4
- package/dist/_chunks/{browserMiddleware-1MULg59S.cjs → browserMiddleware-Pe3R-Bkh.cjs} +106 -20
- package/dist/_chunks/browserMiddleware-Pe3R-Bkh.cjs.map +1 -0
- package/dist/_chunks/{browserMiddleware-heyg-fDk.js → browserMiddleware-wklv-F5c.js} +108 -22
- package/dist/_chunks/browserMiddleware-wklv-F5c.js.map +1 -0
- package/dist/_chunks/{nodeMiddleware-CHxg1-zH.cjs → nodeMiddleware-7PkLkt-m.cjs} +107 -21
- package/dist/_chunks/nodeMiddleware-7PkLkt-m.cjs.map +1 -0
- package/dist/_chunks/{nodeMiddleware-u_fUUnxa.js → nodeMiddleware-LGORMZpx.js} +109 -23
- package/dist/_chunks/nodeMiddleware-LGORMZpx.js.map +1 -0
- package/dist/_chunks/stegaEncodeSourceMap-2y-qTNKB.cjs +230 -0
- package/dist/_chunks/stegaEncodeSourceMap-2y-qTNKB.cjs.map +1 -0
- package/dist/_chunks/stegaEncodeSourceMap-9L0STMBo.js +475 -0
- package/dist/_chunks/stegaEncodeSourceMap-9L0STMBo.js.map +1 -0
- package/dist/_chunks/stegaEncodeSourceMap-gXzb3LIV.js +226 -0
- package/dist/_chunks/stegaEncodeSourceMap-gXzb3LIV.js.map +1 -0
- package/dist/_chunks/stegaEncodeSourceMap-vNYIaMiu.cjs +479 -0
- package/dist/_chunks/stegaEncodeSourceMap-vNYIaMiu.cjs.map +1 -0
- package/dist/index.browser.cjs +1 -1
- package/dist/index.browser.js +2 -2
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +133 -0
- package/dist/index.js +2 -2
- package/dist/stega.browser.cjs +10 -700
- package/dist/stega.browser.cjs.map +1 -1
- package/dist/stega.browser.js +5 -693
- package/dist/stega.browser.js.map +1 -1
- package/dist/stega.cjs +10 -451
- package/dist/stega.cjs.js +3 -5
- package/dist/stega.cjs.map +1 -1
- package/dist/stega.d.ts +1302 -1455
- package/dist/stega.js +5 -444
- package/dist/stega.js.map +1 -1
- package/package.json +12 -7
- package/src/SanityClient.ts +40 -4
- package/src/config.ts +34 -12
- package/src/data/dataMethods.ts +37 -9
- package/src/stega/index.browser.ts +3 -6
- package/src/stega/index.ts +3 -6
- package/src/stega/shared.ts +1 -13
- package/src/stega/types.ts +11 -18
- package/src/types.ts +24 -0
- package/umd/sanityClient.js +1073 -20
- package/umd/sanityClient.min.js +4 -3
- package/dist/_chunks/browserMiddleware-1MULg59S.cjs.map +0 -1
- package/dist/_chunks/browserMiddleware-heyg-fDk.js.map +0 -1
- package/dist/_chunks/nodeMiddleware-CHxg1-zH.cjs.map +0 -1
- package/dist/_chunks/nodeMiddleware-u_fUUnxa.js.map +0 -1
- package/src/stega/SanityStegaClient.ts +0 -298
- package/src/stega/config.ts +0 -76
package/dist/stega.d.ts
CHANGED
|
@@ -43,7 +43,7 @@ export declare type AssetMetadataType =
|
|
|
43
43
|
/** @internal */
|
|
44
44
|
export declare class AssetsClient {
|
|
45
45
|
#private
|
|
46
|
-
constructor(client:
|
|
46
|
+
constructor(client: SanityClient, httpRequest: HttpRequest)
|
|
47
47
|
/**
|
|
48
48
|
* Uploads a file asset to the configured dataset
|
|
49
49
|
*
|
|
@@ -325,6 +325,10 @@ export declare interface ClientConfig {
|
|
|
325
325
|
*@deprecated set `cache` and `next` options on `client.fetch` instead
|
|
326
326
|
*/
|
|
327
327
|
fetch?: RequestFetchOptions | boolean
|
|
328
|
+
/**
|
|
329
|
+
* Options for how, if enabled, Content Source Maps are encoded into query results using steganography
|
|
330
|
+
*/
|
|
331
|
+
stega?: StegaConfig | boolean
|
|
328
332
|
}
|
|
329
333
|
|
|
330
334
|
/** @public */
|
|
@@ -339,10 +343,11 @@ export declare class ClientError extends Error {
|
|
|
339
343
|
/** @public */
|
|
340
344
|
export declare type ClientPerspective = 'previewDrafts' | 'published' | 'raw'
|
|
341
345
|
|
|
342
|
-
/**
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
+
/**
|
|
347
|
+
* @public
|
|
348
|
+
* @deprecated -- use `ClientConfig` instead
|
|
349
|
+
*/
|
|
350
|
+
export declare interface ClientStegaConfig extends ClientConfig {}
|
|
346
351
|
|
|
347
352
|
/** @public */
|
|
348
353
|
export declare interface ContentSourceMap {
|
|
@@ -445,7 +450,7 @@ export declare interface ContentSourceMapValueMapping {
|
|
|
445
450
|
}
|
|
446
451
|
|
|
447
452
|
/** @public */
|
|
448
|
-
export declare const createClient: (config:
|
|
453
|
+
export declare const createClient: (config: ClientConfig) => SanityClient
|
|
449
454
|
|
|
450
455
|
/** @internal */
|
|
451
456
|
export declare interface CurrentSanityUser {
|
|
@@ -468,7 +473,7 @@ export declare type DatasetResponse = {
|
|
|
468
473
|
/** @internal */
|
|
469
474
|
export declare class DatasetsClient {
|
|
470
475
|
#private
|
|
471
|
-
constructor(client:
|
|
476
|
+
constructor(client: SanityClient, httpRequest: HttpRequest)
|
|
472
477
|
/**
|
|
473
478
|
* Create a new dataset with the given name
|
|
474
479
|
*
|
|
@@ -657,13 +662,18 @@ export declare interface InitializedClientConfig extends ClientConfig {
|
|
|
657
662
|
* @deprecated Internal, don't use
|
|
658
663
|
*/
|
|
659
664
|
cdnUrl: string
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
export declare interface InitializedClientStegaConfig extends InitializedClientConfig {
|
|
665
|
+
/**
|
|
666
|
+
* The fully initialized stega config, can be used to check if stega is enabled
|
|
667
|
+
*/
|
|
664
668
|
stega: InitializedStegaConfig
|
|
665
669
|
}
|
|
666
670
|
|
|
671
|
+
/**
|
|
672
|
+
* @public
|
|
673
|
+
* @deprecated -- use `InitializedClientConfig` instead
|
|
674
|
+
*/
|
|
675
|
+
export declare interface InitializedClientStegaConfig extends InitializedClientConfig {}
|
|
676
|
+
|
|
667
677
|
/** @public */
|
|
668
678
|
export declare type InitializedStegaConfig = Omit<StegaConfig, StegaConfigRequiredKeys> &
|
|
669
679
|
Required<Pick<StegaConfig, StegaConfigRequiredKeys>>
|
|
@@ -683,426 +693,853 @@ export declare type InsertPatch =
|
|
|
683
693
|
items: Any[]
|
|
684
694
|
}
|
|
685
695
|
|
|
696
|
+
/**
|
|
697
|
+
* Set up a listener that will be notified when mutations occur on documents matching the provided query/filter.
|
|
698
|
+
*
|
|
699
|
+
* @param query - GROQ-filter to listen to changes for
|
|
700
|
+
* @param params - Optional query parameters
|
|
701
|
+
* @param options - Optional listener options
|
|
702
|
+
* @public
|
|
703
|
+
*/
|
|
704
|
+
export declare function _listen<R extends Record<string, Any> = Record<string, Any>>(
|
|
705
|
+
this: SanityClient | ObservableSanityClient,
|
|
706
|
+
query: string,
|
|
707
|
+
params?: QueryParams,
|
|
708
|
+
): Observable<MutationEvent_2<R>>
|
|
709
|
+
|
|
710
|
+
/**
|
|
711
|
+
* Set up a listener that will be notified when mutations occur on documents matching the provided query/filter.
|
|
712
|
+
*
|
|
713
|
+
* @param query - GROQ-filter to listen to changes for
|
|
714
|
+
* @param params - Optional query parameters
|
|
715
|
+
* @param options - Optional listener options
|
|
716
|
+
* @public
|
|
717
|
+
*/
|
|
718
|
+
export declare function _listen<R extends Record<string, Any> = Record<string, Any>>(
|
|
719
|
+
this: SanityClient | ObservableSanityClient,
|
|
720
|
+
query: string,
|
|
721
|
+
params?: QueryParams,
|
|
722
|
+
options?: ListenOptions,
|
|
723
|
+
): Observable<ListenEvent<R>>
|
|
724
|
+
|
|
686
725
|
/** @public */
|
|
687
|
-
export declare
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
726
|
+
export declare type ListenEvent<R extends Record<string, Any>> =
|
|
727
|
+
| MutationEvent_2<R>
|
|
728
|
+
| ChannelErrorEvent
|
|
729
|
+
| DisconnectEvent
|
|
730
|
+
| ReconnectEvent
|
|
731
|
+
| WelcomeEvent
|
|
732
|
+
|
|
733
|
+
/** @public */
|
|
734
|
+
export declare type ListenEventName =
|
|
735
|
+
/** A mutation was performed */
|
|
736
|
+
| 'mutation'
|
|
737
|
+
/** The listener has been (re)established */
|
|
738
|
+
| 'welcome'
|
|
739
|
+
/** The listener has been disconnected, and a reconnect attempt is scheduled */
|
|
740
|
+
| 'reconnect'
|
|
741
|
+
|
|
742
|
+
/** @public */
|
|
743
|
+
export declare interface ListenOptions {
|
|
698
744
|
/**
|
|
699
|
-
*
|
|
745
|
+
* Whether or not to include the resulting document in addition to the mutations performed.
|
|
746
|
+
* If you do not need the actual document, set this to `false` to reduce bandwidth usage.
|
|
747
|
+
* The result will be available on the `.result` property of the events.
|
|
748
|
+
* @defaultValue `true`
|
|
700
749
|
*/
|
|
701
|
-
|
|
750
|
+
includeResult?: boolean
|
|
702
751
|
/**
|
|
703
|
-
*
|
|
752
|
+
* Whether or not to include the document as it looked before the mutation event.
|
|
753
|
+
* The previous revision will be available on the `.previous` property of the events,
|
|
754
|
+
* and may be `null` in the case of a new document.
|
|
755
|
+
* @defaultValue `false`
|
|
704
756
|
*/
|
|
705
|
-
|
|
757
|
+
includePreviousRevision?: boolean
|
|
706
758
|
/**
|
|
707
|
-
*
|
|
759
|
+
* Whether events should be sent as soon as a transaction has been committed (`transaction`, default),
|
|
760
|
+
* or only after they are available for queries (query). Note that this is on a best-effort basis,
|
|
761
|
+
* and listeners with `query` may in certain cases (notably with deferred transactions) receive events
|
|
762
|
+
* that are not yet visible to queries.
|
|
763
|
+
*
|
|
764
|
+
* @defaultValue `'transaction'`
|
|
708
765
|
*/
|
|
709
|
-
|
|
766
|
+
visibility?: 'transaction' | 'query'
|
|
710
767
|
/**
|
|
711
|
-
*
|
|
768
|
+
* Array of event names to include in the observable. By default, only mutation events are included.
|
|
712
769
|
*
|
|
713
|
-
* @
|
|
770
|
+
* @defaultValue `['mutation']`
|
|
714
771
|
*/
|
|
715
|
-
|
|
772
|
+
events?: ListenEventName[]
|
|
716
773
|
/**
|
|
717
|
-
*
|
|
774
|
+
* Format of "effects", eg the resulting changes of a mutation.
|
|
775
|
+
* Currently only `mendoza` is supported, and (if set) will include `apply` and `revert` arrays
|
|
776
|
+
* in the mutation events under the `effects` property.
|
|
718
777
|
*
|
|
719
|
-
* @
|
|
778
|
+
* See {@link https://github.com/sanity-io/mendoza | The mendoza docs} for more info
|
|
779
|
+
*
|
|
780
|
+
* @defaultValue `undefined`
|
|
720
781
|
*/
|
|
721
|
-
|
|
782
|
+
effectFormat?: 'mendoza'
|
|
722
783
|
/**
|
|
723
|
-
*
|
|
784
|
+
* Optional request tag for the listener. Use to identify the request in logs.
|
|
724
785
|
*
|
|
725
|
-
* @
|
|
726
|
-
* @param params - Query parameters
|
|
786
|
+
* @defaultValue `undefined`
|
|
727
787
|
*/
|
|
728
|
-
|
|
788
|
+
tag?: string
|
|
789
|
+
}
|
|
790
|
+
|
|
791
|
+
/** @public */
|
|
792
|
+
export declare type Logger =
|
|
793
|
+
| typeof console
|
|
794
|
+
| Partial<
|
|
795
|
+
Pick<typeof console, 'debug' | 'error' | 'groupCollapsed' | 'groupEnd' | 'log' | 'table'>
|
|
796
|
+
>
|
|
797
|
+
|
|
798
|
+
/** @internal */
|
|
799
|
+
export declare interface MultipleMutationResult {
|
|
800
|
+
transactionId: string
|
|
801
|
+
documentIds: string[]
|
|
802
|
+
results: {
|
|
803
|
+
id: string
|
|
804
|
+
operation: MutationOperation
|
|
805
|
+
}[]
|
|
806
|
+
}
|
|
807
|
+
|
|
808
|
+
/** @public */
|
|
809
|
+
export declare type Mutation<R extends Record<string, Any> = Record<string, Any>> =
|
|
810
|
+
| {
|
|
811
|
+
create: SanityDocumentStub<R>
|
|
812
|
+
}
|
|
813
|
+
| {
|
|
814
|
+
createOrReplace: IdentifiedSanityDocumentStub<R>
|
|
815
|
+
}
|
|
816
|
+
| {
|
|
817
|
+
createIfNotExists: IdentifiedSanityDocumentStub<R>
|
|
818
|
+
}
|
|
819
|
+
| {
|
|
820
|
+
delete: MutationSelection
|
|
821
|
+
}
|
|
822
|
+
| {
|
|
823
|
+
patch: PatchMutationOperation
|
|
824
|
+
}
|
|
825
|
+
|
|
826
|
+
/** @internal */
|
|
827
|
+
export declare interface MutationError {
|
|
828
|
+
error: {
|
|
829
|
+
type: 'mutationError'
|
|
830
|
+
description: string
|
|
831
|
+
items?: MutationErrorItem[]
|
|
832
|
+
}
|
|
833
|
+
}
|
|
834
|
+
|
|
835
|
+
/** @internal */
|
|
836
|
+
export declare interface MutationErrorItem {
|
|
837
|
+
error: {
|
|
838
|
+
type: string
|
|
839
|
+
description: string
|
|
840
|
+
value?: unknown
|
|
841
|
+
}
|
|
842
|
+
}
|
|
843
|
+
|
|
844
|
+
/**
|
|
845
|
+
* A mutation was performed. Note that when updating multiple documents in a transaction,
|
|
846
|
+
* each document affected will get a separate mutation event.
|
|
847
|
+
*
|
|
848
|
+
* @public
|
|
849
|
+
*/
|
|
850
|
+
declare type MutationEvent_2<R extends Record<string, Any> = Record<string, Any>> = {
|
|
851
|
+
type: 'mutation'
|
|
729
852
|
/**
|
|
730
|
-
*
|
|
731
|
-
*
|
|
732
|
-
* @param query - GROQ-query to perform
|
|
733
|
-
* @param params - Query parameters
|
|
734
|
-
* @param options - Request options
|
|
853
|
+
* The ID of the document that was affected
|
|
735
854
|
*/
|
|
736
|
-
|
|
737
|
-
query: string,
|
|
738
|
-
params: Q | undefined,
|
|
739
|
-
options: FilteredResponseQueryOptions,
|
|
740
|
-
): Observable<R>
|
|
855
|
+
documentId: string
|
|
741
856
|
/**
|
|
742
|
-
*
|
|
743
|
-
*
|
|
744
|
-
* @param query - GROQ-query to perform
|
|
745
|
-
* @param params - Query parameters
|
|
746
|
-
* @param options - Request options
|
|
857
|
+
* A unique ID for this event
|
|
747
858
|
*/
|
|
748
|
-
|
|
749
|
-
query: string,
|
|
750
|
-
params: Q | undefined,
|
|
751
|
-
options: UnfilteredResponseQueryOptions,
|
|
752
|
-
): Observable<RawQueryResponse<R>>
|
|
859
|
+
eventId: string
|
|
753
860
|
/**
|
|
754
|
-
*
|
|
755
|
-
*
|
|
756
|
-
* @param id - Document ID to fetch
|
|
757
|
-
* @param options - Request options
|
|
861
|
+
* The user ID of the user that performed the mutation
|
|
758
862
|
*/
|
|
759
|
-
|
|
760
|
-
id: string,
|
|
761
|
-
options?: {
|
|
762
|
-
tag?: string
|
|
763
|
-
},
|
|
764
|
-
): Observable<SanityDocument<R> | undefined>
|
|
863
|
+
identity: string
|
|
765
864
|
/**
|
|
766
|
-
*
|
|
767
|
-
*
|
|
768
|
-
* The order/position of documents is preserved based on the original array of IDs.
|
|
769
|
-
* If any of the documents are missing, they will be replaced by a `null` entry in the returned array
|
|
770
|
-
*
|
|
771
|
-
* @param ids - Document IDs to fetch
|
|
772
|
-
* @param options - Request options
|
|
865
|
+
* An array of mutations that were performed. Note that this can differ slightly from the
|
|
866
|
+
* mutations sent to the server, as the server may perform some mutations automatically.
|
|
773
867
|
*/
|
|
774
|
-
|
|
775
|
-
ids: string[],
|
|
776
|
-
options?: {
|
|
777
|
-
tag?: string
|
|
778
|
-
},
|
|
779
|
-
): Observable<(SanityDocument<R> | null)[]>
|
|
868
|
+
mutations: Mutation[]
|
|
780
869
|
/**
|
|
781
|
-
*
|
|
782
|
-
* Returns an observable that resolves to the created document.
|
|
783
|
-
*
|
|
784
|
-
* @param document - Document to create
|
|
785
|
-
* @param options - Mutation options
|
|
870
|
+
* The revision ID of the document before the mutation was performed
|
|
786
871
|
*/
|
|
787
|
-
|
|
788
|
-
document: SanityDocumentStub<R>,
|
|
789
|
-
options: FirstDocumentMutationOptions,
|
|
790
|
-
): Observable<SanityDocument<R>>
|
|
872
|
+
previousRev?: string
|
|
791
873
|
/**
|
|
792
|
-
*
|
|
793
|
-
* Returns an observable that resolves to an array containing the created document.
|
|
794
|
-
*
|
|
795
|
-
* @param document - Document to create
|
|
796
|
-
* @param options - Mutation options
|
|
874
|
+
* The revision ID of the document after the mutation was performed
|
|
797
875
|
*/
|
|
798
|
-
|
|
799
|
-
document: SanityDocumentStub<R>,
|
|
800
|
-
options: AllDocumentsMutationOptions,
|
|
801
|
-
): Observable<SanityDocument<R>[]>
|
|
876
|
+
resultRev?: string
|
|
802
877
|
/**
|
|
803
|
-
*
|
|
804
|
-
*
|
|
878
|
+
* The document as it looked after the mutation was performed. This is only included if
|
|
879
|
+
* the listener was configured with `includeResult: true`.
|
|
880
|
+
*/
|
|
881
|
+
result?: SanityDocument<R>
|
|
882
|
+
/**
|
|
883
|
+
* The document as it looked before the mutation was performed. This is only included if
|
|
884
|
+
* the listener was configured with `includePreviousRevision: true`.
|
|
885
|
+
*/
|
|
886
|
+
previous?: SanityDocument<R> | null
|
|
887
|
+
/**
|
|
888
|
+
* The effects of the mutation, if the listener was configured with `effectFormat: 'mendoza'`.
|
|
889
|
+
* Object with `apply` and `revert` arrays, see {@link https://github.com/sanity-io/mendoza}.
|
|
890
|
+
*/
|
|
891
|
+
effects?: {
|
|
892
|
+
apply: unknown[]
|
|
893
|
+
revert: unknown[]
|
|
894
|
+
}
|
|
895
|
+
/**
|
|
896
|
+
* A timestamp for when the mutation was performed
|
|
897
|
+
*/
|
|
898
|
+
timestamp: string
|
|
899
|
+
/**
|
|
900
|
+
* The transaction ID for the mutation
|
|
901
|
+
*/
|
|
902
|
+
transactionId: string
|
|
903
|
+
/**
|
|
904
|
+
* The type of transition the document went through.
|
|
805
905
|
*
|
|
806
|
-
*
|
|
807
|
-
*
|
|
906
|
+
* - `update` means the document was previously part of the subscribed set of documents,
|
|
907
|
+
* and still is.
|
|
908
|
+
* - `appear` means the document was not previously part of the subscribed set of documents,
|
|
909
|
+
* but is now. This can happen both on create or if updating to a state where it now matches
|
|
910
|
+
* the filter provided to the listener.
|
|
911
|
+
* - `disappear` means the document was previously part of the subscribed set of documents,
|
|
912
|
+
* but is no longer. This can happen both on delete or if updating to a state where it no
|
|
913
|
+
* longer matches the filter provided to the listener.
|
|
808
914
|
*/
|
|
809
|
-
|
|
810
|
-
document: SanityDocumentStub<R>,
|
|
811
|
-
options: FirstDocumentIdMutationOptions,
|
|
812
|
-
): Observable<SingleMutationResult>
|
|
915
|
+
transition: 'update' | 'appear' | 'disappear'
|
|
813
916
|
/**
|
|
814
|
-
*
|
|
815
|
-
*
|
|
917
|
+
* Whether the change that triggered this event is visible to queries (query) or only to
|
|
918
|
+
* subsequent transactions (transaction). The listener client can specify a preferred visibility
|
|
919
|
+
* through the `visibility` parameter on the listener, but this is only on a best-effort basis,
|
|
920
|
+
* and may yet not be accurate.
|
|
921
|
+
*/
|
|
922
|
+
visibility: 'query' | 'transaction'
|
|
923
|
+
/**
|
|
924
|
+
* The total number of events that will be sent for this transaction.
|
|
925
|
+
* Note that this may differ from the amount of _documents_ affected by the transaction, as this
|
|
926
|
+
* number only includes the documents that matches the given filter.
|
|
816
927
|
*
|
|
817
|
-
*
|
|
818
|
-
*
|
|
928
|
+
* This can be useful if you need to perform changes to all matched documents atomically,
|
|
929
|
+
* eg you would wait for `transactionTotalEvents` events with the same `transactionId` before
|
|
930
|
+
* applying the changes locally.
|
|
819
931
|
*/
|
|
820
|
-
|
|
821
|
-
document: SanityDocumentStub<R>,
|
|
822
|
-
options: AllDocumentIdsMutationOptions,
|
|
823
|
-
): Observable<MultipleMutationResult>
|
|
932
|
+
transactionTotalEvents: number
|
|
824
933
|
/**
|
|
825
|
-
*
|
|
826
|
-
*
|
|
934
|
+
* The index of this event within the transaction. Note that events may be delivered out of order,
|
|
935
|
+
* and that the index is zero-based.
|
|
936
|
+
*/
|
|
937
|
+
transactionCurrentEvent: number
|
|
938
|
+
}
|
|
939
|
+
export {MutationEvent_2 as MutationEvent}
|
|
940
|
+
|
|
941
|
+
/** @internal */
|
|
942
|
+
export declare type MutationOperation = 'create' | 'delete' | 'update' | 'none'
|
|
943
|
+
|
|
944
|
+
/** @internal */
|
|
945
|
+
export declare type MutationSelection =
|
|
946
|
+
| {
|
|
947
|
+
query: string
|
|
948
|
+
params?: QueryParams
|
|
949
|
+
}
|
|
950
|
+
| {
|
|
951
|
+
id: string | string[]
|
|
952
|
+
}
|
|
953
|
+
|
|
954
|
+
/** @internal */
|
|
955
|
+
export declare class ObservableAssetsClient {
|
|
956
|
+
#private
|
|
957
|
+
constructor(client: ObservableSanityClient, httpRequest: HttpRequest)
|
|
958
|
+
/**
|
|
959
|
+
* Uploads a file asset to the configured dataset
|
|
827
960
|
*
|
|
828
|
-
* @param
|
|
829
|
-
* @param
|
|
961
|
+
* @param assetType - Asset type (file)
|
|
962
|
+
* @param body - Asset content - can be a browser File instance, a Blob, a Node.js Buffer instance or a Node.js ReadableStream.
|
|
963
|
+
* @param options - Options to use for the upload
|
|
830
964
|
*/
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
965
|
+
upload(
|
|
966
|
+
assetType: 'file',
|
|
967
|
+
body: UploadBody,
|
|
968
|
+
options?: UploadClientConfig,
|
|
969
|
+
): Observable<
|
|
970
|
+
HttpRequestEvent<{
|
|
971
|
+
document: SanityAssetDocument
|
|
972
|
+
}>
|
|
973
|
+
>
|
|
835
974
|
/**
|
|
836
|
-
*
|
|
837
|
-
* Returns an observable that resolves to the created document.
|
|
975
|
+
* Uploads an image asset to the configured dataset
|
|
838
976
|
*
|
|
839
|
-
* @param
|
|
840
|
-
* @param
|
|
977
|
+
* @param assetType - Asset type (image)
|
|
978
|
+
* @param body - Asset content - can be a browser File instance, a Blob, a Node.js Buffer instance or a Node.js ReadableStream.
|
|
979
|
+
* @param options - Options to use for the upload
|
|
841
980
|
*/
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
981
|
+
upload(
|
|
982
|
+
assetType: 'image',
|
|
983
|
+
body: UploadBody,
|
|
984
|
+
options?: UploadClientConfig,
|
|
985
|
+
): Observable<
|
|
986
|
+
HttpRequestEvent<{
|
|
987
|
+
document: SanityImageAssetDocument
|
|
988
|
+
}>
|
|
989
|
+
>
|
|
846
990
|
/**
|
|
847
|
-
*
|
|
848
|
-
* Returns an observable that resolves to an array containing the created document.
|
|
991
|
+
* Uploads a file or an image asset to the configured dataset
|
|
849
992
|
*
|
|
850
|
-
* @param
|
|
851
|
-
* @param
|
|
993
|
+
* @param assetType - Asset type (file/image)
|
|
994
|
+
* @param body - Asset content - can be a browser File instance, a Blob, a Node.js Buffer instance or a Node.js ReadableStream.
|
|
995
|
+
* @param options - Options to use for the upload
|
|
852
996
|
*/
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
997
|
+
upload(
|
|
998
|
+
assetType: 'file' | 'image',
|
|
999
|
+
body: UploadBody,
|
|
1000
|
+
options?: UploadClientConfig,
|
|
1001
|
+
): Observable<
|
|
1002
|
+
HttpRequestEvent<{
|
|
1003
|
+
document: SanityAssetDocument | SanityImageAssetDocument
|
|
1004
|
+
}>
|
|
1005
|
+
>
|
|
1006
|
+
}
|
|
1007
|
+
|
|
1008
|
+
/** @internal */
|
|
1009
|
+
export declare class ObservableDatasetsClient {
|
|
1010
|
+
#private
|
|
1011
|
+
constructor(client: ObservableSanityClient, httpRequest: HttpRequest)
|
|
857
1012
|
/**
|
|
858
|
-
* Create a
|
|
859
|
-
* Returns an observable that resolves to a mutation result object containing the ID of the created document.
|
|
1013
|
+
* Create a new dataset with the given name
|
|
860
1014
|
*
|
|
861
|
-
* @param
|
|
862
|
-
* @param options -
|
|
1015
|
+
* @param name - Name of the dataset to create
|
|
1016
|
+
* @param options - Options for the dataset
|
|
863
1017
|
*/
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
options
|
|
867
|
-
|
|
1018
|
+
create(
|
|
1019
|
+
name: string,
|
|
1020
|
+
options?: {
|
|
1021
|
+
aclMode?: DatasetAclMode
|
|
1022
|
+
},
|
|
1023
|
+
): Observable<DatasetResponse>
|
|
868
1024
|
/**
|
|
869
|
-
*
|
|
870
|
-
* Returns an observable that resolves to a mutation result object containing the ID of the created document.
|
|
1025
|
+
* Edit a dataset with the given name
|
|
871
1026
|
*
|
|
872
|
-
* @param
|
|
873
|
-
* @param options -
|
|
1027
|
+
* @param name - Name of the dataset to edit
|
|
1028
|
+
* @param options - New options for the dataset
|
|
874
1029
|
*/
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
options
|
|
878
|
-
|
|
1030
|
+
edit(
|
|
1031
|
+
name: string,
|
|
1032
|
+
options?: {
|
|
1033
|
+
aclMode?: DatasetAclMode
|
|
1034
|
+
},
|
|
1035
|
+
): Observable<DatasetResponse>
|
|
879
1036
|
/**
|
|
880
|
-
*
|
|
881
|
-
* Returns an observable that resolves to the created document.
|
|
1037
|
+
* Delete a dataset with the given name
|
|
882
1038
|
*
|
|
883
|
-
* @param
|
|
884
|
-
* @param options - Mutation options
|
|
1039
|
+
* @param name - Name of the dataset to delete
|
|
885
1040
|
*/
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
): Observable<SanityDocument<R>>
|
|
1041
|
+
delete(name: string): Observable<{
|
|
1042
|
+
deleted: true
|
|
1043
|
+
}>
|
|
890
1044
|
/**
|
|
891
|
-
*
|
|
892
|
-
|
|
1045
|
+
* Fetch a list of datasets for the configured project
|
|
1046
|
+
*/
|
|
1047
|
+
list(): Observable<DatasetsResponse>
|
|
1048
|
+
}
|
|
1049
|
+
|
|
1050
|
+
/** @public */
|
|
1051
|
+
export declare class ObservablePatch extends BasePatch {
|
|
1052
|
+
#private
|
|
1053
|
+
constructor(
|
|
1054
|
+
selection: PatchSelection,
|
|
1055
|
+
operations?: PatchOperations,
|
|
1056
|
+
client?: ObservableSanityClient,
|
|
1057
|
+
)
|
|
1058
|
+
/**
|
|
1059
|
+
* Clones the patch
|
|
1060
|
+
*/
|
|
1061
|
+
clone(): ObservablePatch
|
|
1062
|
+
/**
|
|
1063
|
+
* Commit the patch, returning an observable that produces the first patched document
|
|
893
1064
|
*
|
|
894
|
-
* @param
|
|
895
|
-
* @param options - Mutation options
|
|
1065
|
+
* @param options - Options for the mutation operation
|
|
896
1066
|
*/
|
|
897
|
-
|
|
898
|
-
document: IdentifiedSanityDocumentStub<R>,
|
|
1067
|
+
commit<R extends Record<string, Any> = Record<string, Any>>(
|
|
899
1068
|
options: FirstDocumentMutationOptions,
|
|
900
1069
|
): Observable<SanityDocument<R>>
|
|
901
1070
|
/**
|
|
902
|
-
*
|
|
903
|
-
* Returns an observable that resolves to an array containing the created document.
|
|
1071
|
+
* Commit the patch, returning an observable that produces an array of the mutated documents
|
|
904
1072
|
*
|
|
905
|
-
* @param
|
|
906
|
-
* @param options - Mutation options
|
|
1073
|
+
* @param options - Options for the mutation operation
|
|
907
1074
|
*/
|
|
908
|
-
|
|
909
|
-
document: IdentifiedSanityDocumentStub<R>,
|
|
1075
|
+
commit<R extends Record<string, Any> = Record<string, Any>>(
|
|
910
1076
|
options: AllDocumentsMutationOptions,
|
|
911
1077
|
): Observable<SanityDocument<R>[]>
|
|
912
1078
|
/**
|
|
913
|
-
*
|
|
914
|
-
* Returns an observable that resolves to a mutation result object containing the ID of the created document.
|
|
1079
|
+
* Commit the patch, returning an observable that produces a mutation result object
|
|
915
1080
|
*
|
|
916
|
-
* @param
|
|
917
|
-
* @param options - Mutation options
|
|
1081
|
+
* @param options - Options for the mutation operation
|
|
918
1082
|
*/
|
|
919
|
-
|
|
920
|
-
document: IdentifiedSanityDocumentStub<R>,
|
|
921
|
-
options: FirstDocumentIdMutationOptions,
|
|
922
|
-
): Observable<SingleMutationResult>
|
|
1083
|
+
commit(options: FirstDocumentIdMutationOptions): Observable<SingleMutationResult>
|
|
923
1084
|
/**
|
|
924
|
-
*
|
|
925
|
-
* Returns an observable that resolves to a mutation result object containing the created document ID.
|
|
1085
|
+
* Commit the patch, returning an observable that produces a mutation result object
|
|
926
1086
|
*
|
|
927
|
-
* @param
|
|
928
|
-
* @param options - Mutation options
|
|
1087
|
+
* @param options - Options for the mutation operation
|
|
929
1088
|
*/
|
|
930
|
-
|
|
931
|
-
document: IdentifiedSanityDocumentStub<R>,
|
|
932
|
-
options: AllDocumentIdsMutationOptions,
|
|
933
|
-
): Observable<MultipleMutationResult>
|
|
1089
|
+
commit(options: AllDocumentIdsMutationOptions): Observable<MultipleMutationResult>
|
|
934
1090
|
/**
|
|
935
|
-
*
|
|
936
|
-
* Returns an observable that resolves to the created document.
|
|
1091
|
+
* Commit the patch, returning an observable that produces the first patched document
|
|
937
1092
|
*
|
|
938
|
-
* @param
|
|
939
|
-
* @param options - Mutation options
|
|
1093
|
+
* @param options - Options for the mutation operation
|
|
940
1094
|
*/
|
|
941
|
-
|
|
942
|
-
document: IdentifiedSanityDocumentStub<R>,
|
|
1095
|
+
commit<R extends Record<string, Any> = Record<string, Any>>(
|
|
943
1096
|
options?: BaseMutationOptions,
|
|
944
1097
|
): Observable<SanityDocument<R>>
|
|
1098
|
+
}
|
|
1099
|
+
|
|
1100
|
+
/** @public */
|
|
1101
|
+
export declare type ObservablePatchBuilder = (patch: ObservablePatch) => ObservablePatch
|
|
1102
|
+
|
|
1103
|
+
/** @internal */
|
|
1104
|
+
export declare class ObservableProjectsClient {
|
|
1105
|
+
#private
|
|
1106
|
+
constructor(client: ObservableSanityClient, httpRequest: HttpRequest)
|
|
945
1107
|
/**
|
|
946
|
-
*
|
|
947
|
-
* Returns an observable that resolves to the deleted document.
|
|
1108
|
+
* Fetch a list of projects the authenticated user has access to.
|
|
948
1109
|
*
|
|
949
|
-
* @param
|
|
950
|
-
* @param options -
|
|
1110
|
+
* @param options - Options for the list request
|
|
1111
|
+
* @param options.includeMembers - Whether to include members in the response (default: true)
|
|
951
1112
|
*/
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
options: FirstDocumentMutationOptions,
|
|
955
|
-
): Observable<SanityDocument<R>>
|
|
1113
|
+
list(options?: {includeMembers?: true}): Observable<SanityProject[]>
|
|
1114
|
+
list(options?: {includeMembers?: false}): Observable<Omit<SanityProject, 'members'>[]>
|
|
956
1115
|
/**
|
|
957
|
-
*
|
|
958
|
-
* Returns an observable that resolves to an array containing the deleted document.
|
|
1116
|
+
* Fetch a project by project ID
|
|
959
1117
|
*
|
|
960
|
-
* @param
|
|
961
|
-
* @param options - Options for the mutation
|
|
1118
|
+
* @param projectId - ID of the project to fetch
|
|
962
1119
|
*/
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
1120
|
+
getById(projectId: string): Observable<SanityProject>
|
|
1121
|
+
}
|
|
1122
|
+
|
|
1123
|
+
/** @public */
|
|
1124
|
+
export declare class ObservableSanityClient {
|
|
1125
|
+
#private
|
|
1126
|
+
assets: ObservableAssetsClient
|
|
1127
|
+
datasets: ObservableDatasetsClient
|
|
1128
|
+
projects: ObservableProjectsClient
|
|
1129
|
+
users: ObservableUsersClient
|
|
967
1130
|
/**
|
|
968
|
-
*
|
|
969
|
-
|
|
1131
|
+
* Instance properties
|
|
1132
|
+
*/
|
|
1133
|
+
listen: typeof _listen
|
|
1134
|
+
constructor(httpRequest: HttpRequest, config?: ClientConfig)
|
|
1135
|
+
/**
|
|
1136
|
+
* Clone the client - returns a new instance
|
|
1137
|
+
*/
|
|
1138
|
+
clone(): ObservableSanityClient
|
|
1139
|
+
/**
|
|
1140
|
+
* Returns the current client configuration
|
|
1141
|
+
*/
|
|
1142
|
+
config(): InitializedClientConfig
|
|
1143
|
+
/**
|
|
1144
|
+
* Reconfigure the client. Note that this _mutates_ the current client.
|
|
1145
|
+
*/
|
|
1146
|
+
config(newConfig?: Partial<ClientConfig>): this
|
|
1147
|
+
/**
|
|
1148
|
+
* Clone the client with a new (partial) configuration.
|
|
970
1149
|
*
|
|
971
|
-
* @param
|
|
972
|
-
* @param options - Options for the mutation
|
|
1150
|
+
* @param newConfig - New client configuration properties, shallowly merged with existing configuration
|
|
973
1151
|
*/
|
|
974
|
-
|
|
1152
|
+
withConfig(newConfig?: Partial<ClientConfig>): ObservableSanityClient
|
|
975
1153
|
/**
|
|
976
|
-
*
|
|
977
|
-
* Returns an observable that resolves to a mutation result object containing the deleted document ID.
|
|
1154
|
+
* Perform a GROQ-query against the configured dataset.
|
|
978
1155
|
*
|
|
979
|
-
* @param
|
|
980
|
-
* @param options - Options for the mutation
|
|
1156
|
+
* @param query - GROQ-query to perform
|
|
981
1157
|
*/
|
|
982
|
-
|
|
1158
|
+
fetch<R = Any>(query: string): Observable<R>
|
|
983
1159
|
/**
|
|
984
|
-
*
|
|
985
|
-
* Returns an observable that resolves to the deleted document.
|
|
1160
|
+
* Perform a GROQ-query against the configured dataset.
|
|
986
1161
|
*
|
|
987
|
-
* @param
|
|
988
|
-
* @param
|
|
1162
|
+
* @param query - GROQ-query to perform
|
|
1163
|
+
* @param params - Query parameters
|
|
989
1164
|
*/
|
|
990
|
-
|
|
1165
|
+
fetch<R = Any, Q = QueryParams>(query: string, params: Q): Observable<R>
|
|
1166
|
+
/**
|
|
1167
|
+
* Perform a GROQ-query against the configured dataset.
|
|
1168
|
+
*
|
|
1169
|
+
* @param query - GROQ-query to perform
|
|
1170
|
+
* @param params - Query parameters
|
|
1171
|
+
* @param options - Request options
|
|
1172
|
+
*/
|
|
1173
|
+
fetch<R = Any, Q = QueryParams>(
|
|
1174
|
+
query: string,
|
|
1175
|
+
params: Q | undefined,
|
|
1176
|
+
options: FilteredResponseQueryOptions,
|
|
1177
|
+
): Observable<R>
|
|
1178
|
+
/**
|
|
1179
|
+
* Perform a GROQ-query against the configured dataset.
|
|
1180
|
+
*
|
|
1181
|
+
* @param query - GROQ-query to perform
|
|
1182
|
+
* @param params - Query parameters
|
|
1183
|
+
* @param options - Request options
|
|
1184
|
+
*/
|
|
1185
|
+
fetch<R = Any, Q = QueryParams>(
|
|
1186
|
+
query: string,
|
|
1187
|
+
params: Q | undefined,
|
|
1188
|
+
options: UnfilteredResponseQueryOptions,
|
|
1189
|
+
): Observable<RawQueryResponse<R>>
|
|
1190
|
+
/**
|
|
1191
|
+
* Fetch a single document with the given ID.
|
|
1192
|
+
*
|
|
1193
|
+
* @param id - Document ID to fetch
|
|
1194
|
+
* @param options - Request options
|
|
1195
|
+
*/
|
|
1196
|
+
getDocument<R extends Record<string, Any> = Record<string, Any>>(
|
|
991
1197
|
id: string,
|
|
992
|
-
options?:
|
|
993
|
-
|
|
1198
|
+
options?: {
|
|
1199
|
+
tag?: string
|
|
1200
|
+
},
|
|
1201
|
+
): Observable<SanityDocument<R> | undefined>
|
|
994
1202
|
/**
|
|
995
|
-
*
|
|
996
|
-
*
|
|
1203
|
+
* Fetch multiple documents in one request.
|
|
1204
|
+
* Should be used sparingly - performing a query is usually a better option.
|
|
1205
|
+
* The order/position of documents is preserved based on the original array of IDs.
|
|
1206
|
+
* If any of the documents are missing, they will be replaced by a `null` entry in the returned array
|
|
997
1207
|
*
|
|
998
|
-
* @param
|
|
999
|
-
* @param options -
|
|
1208
|
+
* @param ids - Document IDs to fetch
|
|
1209
|
+
* @param options - Request options
|
|
1000
1210
|
*/
|
|
1001
|
-
|
|
1002
|
-
|
|
1211
|
+
getDocuments<R extends Record<string, Any> = Record<string, Any>>(
|
|
1212
|
+
ids: string[],
|
|
1213
|
+
options?: {
|
|
1214
|
+
tag?: string
|
|
1215
|
+
},
|
|
1216
|
+
): Observable<(SanityDocument<R> | null)[]>
|
|
1217
|
+
/**
|
|
1218
|
+
* Create a document. Requires a `_type` property. If no `_id` is provided, it will be generated by the database.
|
|
1219
|
+
* Returns an observable that resolves to the created document.
|
|
1220
|
+
*
|
|
1221
|
+
* @param document - Document to create
|
|
1222
|
+
* @param options - Mutation options
|
|
1223
|
+
*/
|
|
1224
|
+
create<R extends Record<string, Any> = Record<string, Any>>(
|
|
1225
|
+
document: SanityDocumentStub<R>,
|
|
1003
1226
|
options: FirstDocumentMutationOptions,
|
|
1004
1227
|
): Observable<SanityDocument<R>>
|
|
1005
1228
|
/**
|
|
1006
|
-
*
|
|
1007
|
-
* Returns an observable that resolves to an array containing the
|
|
1229
|
+
* Create a document. Requires a `_type` property. If no `_id` is provided, it will be generated by the database.
|
|
1230
|
+
* Returns an observable that resolves to an array containing the created document.
|
|
1008
1231
|
*
|
|
1009
|
-
* @param
|
|
1010
|
-
* @param options -
|
|
1232
|
+
* @param document - Document to create
|
|
1233
|
+
* @param options - Mutation options
|
|
1011
1234
|
*/
|
|
1012
|
-
|
|
1013
|
-
|
|
1235
|
+
create<R extends Record<string, Any> = Record<string, Any>>(
|
|
1236
|
+
document: SanityDocumentStub<R>,
|
|
1014
1237
|
options: AllDocumentsMutationOptions,
|
|
1015
1238
|
): Observable<SanityDocument<R>[]>
|
|
1016
1239
|
/**
|
|
1017
|
-
*
|
|
1018
|
-
* Returns an observable that resolves to a mutation result object containing the ID of the
|
|
1240
|
+
* Create a document. Requires a `_type` property. If no `_id` is provided, it will be generated by the database.
|
|
1241
|
+
* Returns an observable that resolves to a mutation result object containing the ID of the created document.
|
|
1019
1242
|
*
|
|
1020
|
-
* @param
|
|
1021
|
-
* @param options -
|
|
1243
|
+
* @param document - Document to create
|
|
1244
|
+
* @param options - Mutation options
|
|
1022
1245
|
*/
|
|
1023
|
-
|
|
1024
|
-
|
|
1246
|
+
create<R extends Record<string, Any> = Record<string, Any>>(
|
|
1247
|
+
document: SanityDocumentStub<R>,
|
|
1025
1248
|
options: FirstDocumentIdMutationOptions,
|
|
1026
1249
|
): Observable<SingleMutationResult>
|
|
1027
1250
|
/**
|
|
1028
|
-
*
|
|
1029
|
-
* Returns an observable that resolves to a mutation result object containing the
|
|
1251
|
+
* Create a document. Requires a `_type` property. If no `_id` is provided, it will be generated by the database.
|
|
1252
|
+
* Returns an observable that resolves to a mutation result object containing the ID of the created document.
|
|
1030
1253
|
*
|
|
1031
|
-
* @param
|
|
1032
|
-
* @param options -
|
|
1254
|
+
* @param document - Document to create
|
|
1255
|
+
* @param options - Mutation options
|
|
1033
1256
|
*/
|
|
1034
|
-
|
|
1035
|
-
|
|
1257
|
+
create<R extends Record<string, Any> = Record<string, Any>>(
|
|
1258
|
+
document: SanityDocumentStub<R>,
|
|
1036
1259
|
options: AllDocumentIdsMutationOptions,
|
|
1037
1260
|
): Observable<MultipleMutationResult>
|
|
1038
1261
|
/**
|
|
1039
|
-
*
|
|
1040
|
-
* Returns an observable that resolves to
|
|
1262
|
+
* Create a document. Requires a `_type` property. If no `_id` is provided, it will be generated by the database.
|
|
1263
|
+
* Returns an observable that resolves to the created document.
|
|
1041
1264
|
*
|
|
1042
|
-
* @param
|
|
1043
|
-
* @param options -
|
|
1265
|
+
* @param document - Document to create
|
|
1266
|
+
* @param options - Mutation options
|
|
1044
1267
|
*/
|
|
1045
|
-
|
|
1046
|
-
|
|
1268
|
+
create<R extends Record<string, Any> = Record<string, Any>>(
|
|
1269
|
+
document: SanityDocumentStub<R>,
|
|
1047
1270
|
options?: BaseMutationOptions,
|
|
1048
1271
|
): Observable<SanityDocument<R>>
|
|
1049
1272
|
/**
|
|
1050
|
-
*
|
|
1051
|
-
* Returns an observable that resolves to the
|
|
1273
|
+
* Create a document if no document with the same ID already exists.
|
|
1274
|
+
* Returns an observable that resolves to the created document.
|
|
1052
1275
|
*
|
|
1053
|
-
* @param
|
|
1276
|
+
* @param document - Document to create
|
|
1054
1277
|
* @param options - Mutation options
|
|
1055
1278
|
*/
|
|
1056
|
-
|
|
1057
|
-
|
|
1279
|
+
createIfNotExists<R extends Record<string, Any> = Record<string, Any>>(
|
|
1280
|
+
document: IdentifiedSanityDocumentStub<R>,
|
|
1058
1281
|
options: FirstDocumentMutationOptions,
|
|
1059
1282
|
): Observable<SanityDocument<R>>
|
|
1060
1283
|
/**
|
|
1061
|
-
*
|
|
1062
|
-
* Returns an observable that resolves to an array
|
|
1284
|
+
* Create a document if no document with the same ID already exists.
|
|
1285
|
+
* Returns an observable that resolves to an array containing the created document.
|
|
1063
1286
|
*
|
|
1064
|
-
* @param
|
|
1287
|
+
* @param document - Document to create
|
|
1065
1288
|
* @param options - Mutation options
|
|
1066
1289
|
*/
|
|
1067
|
-
|
|
1068
|
-
|
|
1290
|
+
createIfNotExists<R extends Record<string, Any> = Record<string, Any>>(
|
|
1291
|
+
document: IdentifiedSanityDocumentStub<R>,
|
|
1069
1292
|
options: AllDocumentsMutationOptions,
|
|
1070
1293
|
): Observable<SanityDocument<R>[]>
|
|
1071
1294
|
/**
|
|
1072
|
-
*
|
|
1073
|
-
* Returns an observable that resolves to a mutation result object containing the
|
|
1295
|
+
* Create a document if no document with the same ID already exists.
|
|
1296
|
+
* Returns an observable that resolves to a mutation result object containing the ID of the created document.
|
|
1074
1297
|
*
|
|
1075
|
-
* @param
|
|
1298
|
+
* @param document - Document to create
|
|
1076
1299
|
* @param options - Mutation options
|
|
1077
1300
|
*/
|
|
1078
|
-
|
|
1079
|
-
|
|
1301
|
+
createIfNotExists<R extends Record<string, Any> = Record<string, Any>>(
|
|
1302
|
+
document: IdentifiedSanityDocumentStub<R>,
|
|
1080
1303
|
options: FirstDocumentIdMutationOptions,
|
|
1081
1304
|
): Observable<SingleMutationResult>
|
|
1082
1305
|
/**
|
|
1083
|
-
*
|
|
1084
|
-
* Returns an observable that resolves to a mutation result object containing the
|
|
1306
|
+
* Create a document if no document with the same ID already exists.
|
|
1307
|
+
* Returns an observable that resolves to a mutation result object containing the ID of the created document.
|
|
1085
1308
|
*
|
|
1086
|
-
* @param
|
|
1309
|
+
* @param document - Document to create
|
|
1087
1310
|
* @param options - Mutation options
|
|
1088
1311
|
*/
|
|
1089
|
-
|
|
1090
|
-
|
|
1312
|
+
createIfNotExists<R extends Record<string, Any> = Record<string, Any>>(
|
|
1313
|
+
document: IdentifiedSanityDocumentStub<R>,
|
|
1091
1314
|
options: AllDocumentIdsMutationOptions,
|
|
1092
1315
|
): Observable<MultipleMutationResult>
|
|
1093
1316
|
/**
|
|
1094
|
-
*
|
|
1095
|
-
* Returns an observable that resolves to the
|
|
1317
|
+
* Create a document if no document with the same ID already exists.
|
|
1318
|
+
* Returns an observable that resolves to the created document.
|
|
1096
1319
|
*
|
|
1097
|
-
* @param
|
|
1320
|
+
* @param document - Document to create
|
|
1098
1321
|
* @param options - Mutation options
|
|
1099
1322
|
*/
|
|
1100
|
-
|
|
1101
|
-
|
|
1323
|
+
createIfNotExists<R extends Record<string, Any> = Record<string, Any>>(
|
|
1324
|
+
document: IdentifiedSanityDocumentStub<R>,
|
|
1102
1325
|
options?: BaseMutationOptions,
|
|
1103
1326
|
): Observable<SanityDocument<R>>
|
|
1104
1327
|
/**
|
|
1105
|
-
* Create a
|
|
1328
|
+
* Create a document if it does not exist, or replace a document with the same document ID
|
|
1329
|
+
* Returns an observable that resolves to the created document.
|
|
1330
|
+
*
|
|
1331
|
+
* @param document - Document to either create or replace
|
|
1332
|
+
* @param options - Mutation options
|
|
1333
|
+
*/
|
|
1334
|
+
createOrReplace<R extends Record<string, Any> = Record<string, Any>>(
|
|
1335
|
+
document: IdentifiedSanityDocumentStub<R>,
|
|
1336
|
+
options: FirstDocumentMutationOptions,
|
|
1337
|
+
): Observable<SanityDocument<R>>
|
|
1338
|
+
/**
|
|
1339
|
+
* Create a document if it does not exist, or replace a document with the same document ID
|
|
1340
|
+
* Returns an observable that resolves to an array containing the created document.
|
|
1341
|
+
*
|
|
1342
|
+
* @param document - Document to either create or replace
|
|
1343
|
+
* @param options - Mutation options
|
|
1344
|
+
*/
|
|
1345
|
+
createOrReplace<R extends Record<string, Any> = Record<string, Any>>(
|
|
1346
|
+
document: IdentifiedSanityDocumentStub<R>,
|
|
1347
|
+
options: AllDocumentsMutationOptions,
|
|
1348
|
+
): Observable<SanityDocument<R>[]>
|
|
1349
|
+
/**
|
|
1350
|
+
* Create a document if it does not exist, or replace a document with the same document ID
|
|
1351
|
+
* Returns an observable that resolves to a mutation result object containing the ID of the created document.
|
|
1352
|
+
*
|
|
1353
|
+
* @param document - Document to either create or replace
|
|
1354
|
+
* @param options - Mutation options
|
|
1355
|
+
*/
|
|
1356
|
+
createOrReplace<R extends Record<string, Any> = Record<string, Any>>(
|
|
1357
|
+
document: IdentifiedSanityDocumentStub<R>,
|
|
1358
|
+
options: FirstDocumentIdMutationOptions,
|
|
1359
|
+
): Observable<SingleMutationResult>
|
|
1360
|
+
/**
|
|
1361
|
+
* Create a document if it does not exist, or replace a document with the same document ID
|
|
1362
|
+
* Returns an observable that resolves to a mutation result object containing the created document ID.
|
|
1363
|
+
*
|
|
1364
|
+
* @param document - Document to either create or replace
|
|
1365
|
+
* @param options - Mutation options
|
|
1366
|
+
*/
|
|
1367
|
+
createOrReplace<R extends Record<string, Any> = Record<string, Any>>(
|
|
1368
|
+
document: IdentifiedSanityDocumentStub<R>,
|
|
1369
|
+
options: AllDocumentIdsMutationOptions,
|
|
1370
|
+
): Observable<MultipleMutationResult>
|
|
1371
|
+
/**
|
|
1372
|
+
* Create a document if it does not exist, or replace a document with the same document ID
|
|
1373
|
+
* Returns an observable that resolves to the created document.
|
|
1374
|
+
*
|
|
1375
|
+
* @param document - Document to either create or replace
|
|
1376
|
+
* @param options - Mutation options
|
|
1377
|
+
*/
|
|
1378
|
+
createOrReplace<R extends Record<string, Any> = Record<string, Any>>(
|
|
1379
|
+
document: IdentifiedSanityDocumentStub<R>,
|
|
1380
|
+
options?: BaseMutationOptions,
|
|
1381
|
+
): Observable<SanityDocument<R>>
|
|
1382
|
+
/**
|
|
1383
|
+
* Deletes a document with the given document ID.
|
|
1384
|
+
* Returns an observable that resolves to the deleted document.
|
|
1385
|
+
*
|
|
1386
|
+
* @param id - Document ID to delete
|
|
1387
|
+
* @param options - Options for the mutation
|
|
1388
|
+
*/
|
|
1389
|
+
delete<R extends Record<string, Any> = Record<string, Any>>(
|
|
1390
|
+
id: string,
|
|
1391
|
+
options: FirstDocumentMutationOptions,
|
|
1392
|
+
): Observable<SanityDocument<R>>
|
|
1393
|
+
/**
|
|
1394
|
+
* Deletes a document with the given document ID.
|
|
1395
|
+
* Returns an observable that resolves to an array containing the deleted document.
|
|
1396
|
+
*
|
|
1397
|
+
* @param id - Document ID to delete
|
|
1398
|
+
* @param options - Options for the mutation
|
|
1399
|
+
*/
|
|
1400
|
+
delete<R extends Record<string, Any> = Record<string, Any>>(
|
|
1401
|
+
id: string,
|
|
1402
|
+
options: AllDocumentsMutationOptions,
|
|
1403
|
+
): Observable<SanityDocument<R>[]>
|
|
1404
|
+
/**
|
|
1405
|
+
* Deletes a document with the given document ID.
|
|
1406
|
+
* Returns an observable that resolves to a mutation result object containing the deleted document ID.
|
|
1407
|
+
*
|
|
1408
|
+
* @param id - Document ID to delete
|
|
1409
|
+
* @param options - Options for the mutation
|
|
1410
|
+
*/
|
|
1411
|
+
delete(id: string, options: FirstDocumentIdMutationOptions): Observable<SingleMutationResult>
|
|
1412
|
+
/**
|
|
1413
|
+
* Deletes a document with the given document ID.
|
|
1414
|
+
* Returns an observable that resolves to a mutation result object containing the deleted document ID.
|
|
1415
|
+
*
|
|
1416
|
+
* @param id - Document ID to delete
|
|
1417
|
+
* @param options - Options for the mutation
|
|
1418
|
+
*/
|
|
1419
|
+
delete(id: string, options: AllDocumentIdsMutationOptions): Observable<MultipleMutationResult>
|
|
1420
|
+
/**
|
|
1421
|
+
* Deletes a document with the given document ID.
|
|
1422
|
+
* Returns an observable that resolves to the deleted document.
|
|
1423
|
+
*
|
|
1424
|
+
* @param id - Document ID to delete
|
|
1425
|
+
* @param options - Options for the mutation
|
|
1426
|
+
*/
|
|
1427
|
+
delete<R extends Record<string, Any> = Record<string, Any>>(
|
|
1428
|
+
id: string,
|
|
1429
|
+
options?: BaseMutationOptions,
|
|
1430
|
+
): Observable<SanityDocument<R>>
|
|
1431
|
+
/**
|
|
1432
|
+
* Deletes one or more documents matching the given query or document ID.
|
|
1433
|
+
* Returns an observable that resolves to first deleted document.
|
|
1434
|
+
*
|
|
1435
|
+
* @param selection - An object with either an `id` or `query` key defining what to delete
|
|
1436
|
+
* @param options - Options for the mutation
|
|
1437
|
+
*/
|
|
1438
|
+
delete<R extends Record<string, Any> = Record<string, Any>>(
|
|
1439
|
+
selection: MutationSelection,
|
|
1440
|
+
options: FirstDocumentMutationOptions,
|
|
1441
|
+
): Observable<SanityDocument<R>>
|
|
1442
|
+
/**
|
|
1443
|
+
* Deletes one or more documents matching the given query or document ID.
|
|
1444
|
+
* Returns an observable that resolves to an array containing the deleted documents.
|
|
1445
|
+
*
|
|
1446
|
+
* @param selection - An object with either an `id` or `query` key defining what to delete
|
|
1447
|
+
* @param options - Options for the mutation
|
|
1448
|
+
*/
|
|
1449
|
+
delete<R extends Record<string, Any> = Record<string, Any>>(
|
|
1450
|
+
selection: MutationSelection,
|
|
1451
|
+
options: AllDocumentsMutationOptions,
|
|
1452
|
+
): Observable<SanityDocument<R>[]>
|
|
1453
|
+
/**
|
|
1454
|
+
* Deletes one or more documents matching the given query or document ID.
|
|
1455
|
+
* Returns an observable that resolves to a mutation result object containing the ID of the first deleted document.
|
|
1456
|
+
*
|
|
1457
|
+
* @param selection - An object with either an `id` or `query` key defining what to delete
|
|
1458
|
+
* @param options - Options for the mutation
|
|
1459
|
+
*/
|
|
1460
|
+
delete(
|
|
1461
|
+
selection: MutationSelection,
|
|
1462
|
+
options: FirstDocumentIdMutationOptions,
|
|
1463
|
+
): Observable<SingleMutationResult>
|
|
1464
|
+
/**
|
|
1465
|
+
* Deletes one or more documents matching the given query or document ID.
|
|
1466
|
+
* Returns an observable that resolves to a mutation result object containing the document IDs that were deleted.
|
|
1467
|
+
*
|
|
1468
|
+
* @param selection - An object with either an `id` or `query` key defining what to delete
|
|
1469
|
+
* @param options - Options for the mutation
|
|
1470
|
+
*/
|
|
1471
|
+
delete(
|
|
1472
|
+
selection: MutationSelection,
|
|
1473
|
+
options: AllDocumentIdsMutationOptions,
|
|
1474
|
+
): Observable<MultipleMutationResult>
|
|
1475
|
+
/**
|
|
1476
|
+
* Deletes one or more documents matching the given query or document ID.
|
|
1477
|
+
* Returns an observable that resolves to first deleted document.
|
|
1478
|
+
*
|
|
1479
|
+
* @param selection - An object with either an `id` or `query` key defining what to delete
|
|
1480
|
+
* @param options - Options for the mutation
|
|
1481
|
+
*/
|
|
1482
|
+
delete<R extends Record<string, Any> = Record<string, Any>>(
|
|
1483
|
+
selection: MutationSelection,
|
|
1484
|
+
options?: BaseMutationOptions,
|
|
1485
|
+
): Observable<SanityDocument<R>>
|
|
1486
|
+
/**
|
|
1487
|
+
* Perform mutation operations against the configured dataset
|
|
1488
|
+
* Returns an observable that resolves to the first mutated document.
|
|
1489
|
+
*
|
|
1490
|
+
* @param operations - Mutation operations to execute
|
|
1491
|
+
* @param options - Mutation options
|
|
1492
|
+
*/
|
|
1493
|
+
mutate<R extends Record<string, Any> = Record<string, Any>>(
|
|
1494
|
+
operations: Mutation<R>[] | ObservablePatch | ObservableTransaction,
|
|
1495
|
+
options: FirstDocumentMutationOptions,
|
|
1496
|
+
): Observable<SanityDocument<R>>
|
|
1497
|
+
/**
|
|
1498
|
+
* Perform mutation operations against the configured dataset.
|
|
1499
|
+
* Returns an observable that resolves to an array of the mutated documents.
|
|
1500
|
+
*
|
|
1501
|
+
* @param operations - Mutation operations to execute
|
|
1502
|
+
* @param options - Mutation options
|
|
1503
|
+
*/
|
|
1504
|
+
mutate<R extends Record<string, Any> = Record<string, Any>>(
|
|
1505
|
+
operations: Mutation<R>[] | ObservablePatch | ObservableTransaction,
|
|
1506
|
+
options: AllDocumentsMutationOptions,
|
|
1507
|
+
): Observable<SanityDocument<R>[]>
|
|
1508
|
+
/**
|
|
1509
|
+
* Perform mutation operations against the configured dataset
|
|
1510
|
+
* Returns an observable that resolves to a mutation result object containing the document ID of the first mutated document.
|
|
1511
|
+
*
|
|
1512
|
+
* @param operations - Mutation operations to execute
|
|
1513
|
+
* @param options - Mutation options
|
|
1514
|
+
*/
|
|
1515
|
+
mutate<R extends Record<string, Any> = Record<string, Any>>(
|
|
1516
|
+
operations: Mutation<R>[] | ObservablePatch | ObservableTransaction,
|
|
1517
|
+
options: FirstDocumentIdMutationOptions,
|
|
1518
|
+
): Observable<SingleMutationResult>
|
|
1519
|
+
/**
|
|
1520
|
+
* Perform mutation operations against the configured dataset
|
|
1521
|
+
* Returns an observable that resolves to a mutation result object containing the mutated document IDs.
|
|
1522
|
+
*
|
|
1523
|
+
* @param operations - Mutation operations to execute
|
|
1524
|
+
* @param options - Mutation options
|
|
1525
|
+
*/
|
|
1526
|
+
mutate<R extends Record<string, Any> = Record<string, Any>>(
|
|
1527
|
+
operations: Mutation<R>[] | ObservablePatch | ObservableTransaction,
|
|
1528
|
+
options: AllDocumentIdsMutationOptions,
|
|
1529
|
+
): Observable<MultipleMutationResult>
|
|
1530
|
+
/**
|
|
1531
|
+
* Perform mutation operations against the configured dataset
|
|
1532
|
+
* Returns an observable that resolves to the first mutated document.
|
|
1533
|
+
*
|
|
1534
|
+
* @param operations - Mutation operations to execute
|
|
1535
|
+
* @param options - Mutation options
|
|
1536
|
+
*/
|
|
1537
|
+
mutate<R extends Record<string, Any> = Record<string, Any>>(
|
|
1538
|
+
operations: Mutation<R>[] | ObservablePatch | ObservableTransaction,
|
|
1539
|
+
options?: BaseMutationOptions,
|
|
1540
|
+
): Observable<SanityDocument<R>>
|
|
1541
|
+
/**
|
|
1542
|
+
* Create a new buildable patch of operations to perform
|
|
1106
1543
|
*
|
|
1107
1544
|
* @param documentId - Document ID to patch
|
|
1108
1545
|
* @param operations - Optional object of patch operations to initialize the patch instance with
|
|
@@ -1156,1305 +1593,793 @@ export declare class INTERNAL_DO_NOT_USE_DIRECTLY_ObservableSanityClient {
|
|
|
1156
1593
|
}
|
|
1157
1594
|
|
|
1158
1595
|
/** @public */
|
|
1159
|
-
export declare class
|
|
1596
|
+
export declare class ObservableTransaction extends BaseTransaction {
|
|
1160
1597
|
#private
|
|
1161
|
-
|
|
1162
|
-
datasets: DatasetsClient
|
|
1163
|
-
projects: ProjectsClient
|
|
1164
|
-
users: UsersClient
|
|
1598
|
+
constructor(operations?: Mutation[], client?: ObservableSanityClient, transactionId?: string)
|
|
1165
1599
|
/**
|
|
1166
|
-
*
|
|
1600
|
+
* Clones the transaction
|
|
1167
1601
|
*/
|
|
1168
|
-
|
|
1602
|
+
clone(): ObservableTransaction
|
|
1169
1603
|
/**
|
|
1170
|
-
*
|
|
1604
|
+
* Commit the transaction, returning an observable that produces the first mutated document
|
|
1605
|
+
*
|
|
1606
|
+
* @param options - Options for the mutation operation
|
|
1171
1607
|
*/
|
|
1172
|
-
|
|
1173
|
-
|
|
1608
|
+
commit<R extends Record<string, Any>>(
|
|
1609
|
+
options: TransactionFirstDocumentMutationOptions,
|
|
1610
|
+
): Observable<SanityDocument<R>>
|
|
1174
1611
|
/**
|
|
1175
|
-
*
|
|
1612
|
+
* Commit the transaction, returning an observable that produces an array of the mutated documents
|
|
1613
|
+
*
|
|
1614
|
+
* @param options - Options for the mutation operation
|
|
1176
1615
|
*/
|
|
1177
|
-
|
|
1616
|
+
commit<R extends Record<string, Any>>(
|
|
1617
|
+
options: TransactionAllDocumentsMutationOptions,
|
|
1618
|
+
): Observable<SanityDocument<R>[]>
|
|
1178
1619
|
/**
|
|
1179
|
-
*
|
|
1620
|
+
* Commit the transaction, returning an observable that produces a mutation result object
|
|
1621
|
+
*
|
|
1622
|
+
* @param options - Options for the mutation operation
|
|
1180
1623
|
*/
|
|
1181
|
-
|
|
1624
|
+
commit(options: TransactionFirstDocumentIdMutationOptions): Observable<SingleMutationResult>
|
|
1182
1625
|
/**
|
|
1183
|
-
*
|
|
1626
|
+
* Commit the transaction, returning an observable that produces a mutation result object
|
|
1627
|
+
*
|
|
1628
|
+
* @param options - Options for the mutation operation
|
|
1184
1629
|
*/
|
|
1185
|
-
|
|
1630
|
+
commit(options: TransactionAllDocumentIdsMutationOptions): Observable<MultipleMutationResult>
|
|
1186
1631
|
/**
|
|
1187
|
-
*
|
|
1632
|
+
* Commit the transaction, returning an observable that produces a mutation result object
|
|
1188
1633
|
*
|
|
1189
|
-
* @param
|
|
1634
|
+
* @param options - Options for the mutation operation
|
|
1190
1635
|
*/
|
|
1191
|
-
|
|
1636
|
+
commit(options?: BaseMutationOptions): Observable<MultipleMutationResult>
|
|
1192
1637
|
/**
|
|
1193
|
-
*
|
|
1194
|
-
*
|
|
1195
|
-
* @param query - GROQ-query to perform
|
|
1196
|
-
*/
|
|
1197
|
-
fetch<R = Any>(query: string): Promise<R>
|
|
1198
|
-
/**
|
|
1199
|
-
* Perform a GROQ-query against the configured dataset.
|
|
1200
|
-
*
|
|
1201
|
-
* @param query - GROQ-query to perform
|
|
1202
|
-
* @param params - Optional query parameters
|
|
1203
|
-
*/
|
|
1204
|
-
fetch<R = Any, Q = QueryParams>(query: string, params: Q): Promise<R>
|
|
1205
|
-
/**
|
|
1206
|
-
* Perform a GROQ-query against the configured dataset.
|
|
1207
|
-
*
|
|
1208
|
-
* @param query - GROQ-query to perform
|
|
1209
|
-
* @param params - Optional query parameters
|
|
1210
|
-
* @param options - Request options
|
|
1211
|
-
*/
|
|
1212
|
-
fetch<R = Any, Q = QueryParams>(
|
|
1213
|
-
query: string,
|
|
1214
|
-
params: Q | undefined,
|
|
1215
|
-
options: FilteredResponseQueryOptions,
|
|
1216
|
-
): Promise<R>
|
|
1217
|
-
/**
|
|
1218
|
-
* Perform a GROQ-query against the configured dataset.
|
|
1219
|
-
*
|
|
1220
|
-
* @param query - GROQ-query to perform
|
|
1221
|
-
* @param params - Optional query parameters
|
|
1222
|
-
* @param options - Request options
|
|
1223
|
-
*/
|
|
1224
|
-
fetch<R = Any, Q = QueryParams>(
|
|
1225
|
-
query: string,
|
|
1226
|
-
params: Q | undefined,
|
|
1227
|
-
options: UnfilteredResponseQueryOptions,
|
|
1228
|
-
): Promise<RawQueryResponse<R>>
|
|
1229
|
-
/**
|
|
1230
|
-
* Fetch a single document with the given ID.
|
|
1231
|
-
*
|
|
1232
|
-
* @param id - Document ID to fetch
|
|
1233
|
-
* @param options - Request options
|
|
1234
|
-
*/
|
|
1235
|
-
getDocument<R extends Record<string, Any> = Record<string, Any>>(
|
|
1236
|
-
id: string,
|
|
1237
|
-
options?: {
|
|
1238
|
-
tag?: string
|
|
1239
|
-
},
|
|
1240
|
-
): Promise<SanityDocument<R> | undefined>
|
|
1241
|
-
/**
|
|
1242
|
-
* Fetch multiple documents in one request.
|
|
1243
|
-
* Should be used sparingly - performing a query is usually a better option.
|
|
1244
|
-
* The order/position of documents is preserved based on the original array of IDs.
|
|
1245
|
-
* If any of the documents are missing, they will be replaced by a `null` entry in the returned array
|
|
1246
|
-
*
|
|
1247
|
-
* @param ids - Document IDs to fetch
|
|
1248
|
-
* @param options - Request options
|
|
1249
|
-
*/
|
|
1250
|
-
getDocuments<R extends Record<string, Any> = Record<string, Any>>(
|
|
1251
|
-
ids: string[],
|
|
1252
|
-
options?: {
|
|
1253
|
-
tag?: string
|
|
1254
|
-
},
|
|
1255
|
-
): Promise<(SanityDocument<R> | null)[]>
|
|
1256
|
-
/**
|
|
1257
|
-
* Create a document. Requires a `_type` property. If no `_id` is provided, it will be generated by the database.
|
|
1258
|
-
* Returns a promise that resolves to the created document.
|
|
1259
|
-
*
|
|
1260
|
-
* @param document - Document to create
|
|
1261
|
-
* @param options - Mutation options
|
|
1262
|
-
*/
|
|
1263
|
-
create<R extends Record<string, Any> = Record<string, Any>>(
|
|
1264
|
-
document: SanityDocumentStub<R>,
|
|
1265
|
-
options: FirstDocumentMutationOptions,
|
|
1266
|
-
): Promise<SanityDocument<R>>
|
|
1267
|
-
/**
|
|
1268
|
-
* Create a document. Requires a `_type` property. If no `_id` is provided, it will be generated by the database.
|
|
1269
|
-
* Returns a promise that resolves to an array containing the created document.
|
|
1638
|
+
* Performs a patch on the given document ID. Can either be a builder function or an object of patch operations.
|
|
1639
|
+
* The operation is added to the current transaction, ready to be commited by `commit()`
|
|
1270
1640
|
*
|
|
1271
|
-
* @param
|
|
1272
|
-
* @param
|
|
1641
|
+
* @param documentId - Document ID to perform the patch operation on
|
|
1642
|
+
* @param patchOps - Operations to perform, or a builder function
|
|
1273
1643
|
*/
|
|
1274
|
-
|
|
1275
|
-
document: SanityDocumentStub<R>,
|
|
1276
|
-
options: AllDocumentsMutationOptions,
|
|
1277
|
-
): Promise<SanityDocument<R>[]>
|
|
1644
|
+
patch(documentId: string, patchOps?: ObservablePatchBuilder | PatchOperations): this
|
|
1278
1645
|
/**
|
|
1279
|
-
*
|
|
1280
|
-
*
|
|
1646
|
+
* Adds the given patch instance to the transaction.
|
|
1647
|
+
* The operation is added to the current transaction, ready to be commited by `commit()`
|
|
1281
1648
|
*
|
|
1282
|
-
* @param
|
|
1283
|
-
* @param options - Mutation options
|
|
1649
|
+
* @param patch - ObservablePatch to execute
|
|
1284
1650
|
*/
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1651
|
+
patch(patch: ObservablePatch): this
|
|
1652
|
+
}
|
|
1653
|
+
|
|
1654
|
+
/** @public */
|
|
1655
|
+
export declare class ObservableUsersClient {
|
|
1656
|
+
#private
|
|
1657
|
+
constructor(client: ObservableSanityClient, httpRequest: HttpRequest)
|
|
1289
1658
|
/**
|
|
1290
|
-
*
|
|
1291
|
-
* Returns a promise that resolves to a mutation result object containing the ID of the created document.
|
|
1659
|
+
* Fetch a user by user ID
|
|
1292
1660
|
*
|
|
1293
|
-
* @param
|
|
1294
|
-
* @param options - Mutation options
|
|
1661
|
+
* @param id - User ID of the user to fetch. If `me` is provided, a minimal response including the users role is returned.
|
|
1295
1662
|
*/
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1663
|
+
getById<T extends 'me' | string>(
|
|
1664
|
+
id: T,
|
|
1665
|
+
): Observable<T extends 'me' ? CurrentSanityUser : SanityUser>
|
|
1666
|
+
}
|
|
1667
|
+
|
|
1668
|
+
/** @public */
|
|
1669
|
+
export declare class Patch extends BasePatch {
|
|
1670
|
+
#private
|
|
1671
|
+
constructor(selection: PatchSelection, operations?: PatchOperations, client?: SanityClient)
|
|
1300
1672
|
/**
|
|
1301
|
-
*
|
|
1302
|
-
* Returns a promise that resolves to the created document.
|
|
1303
|
-
*
|
|
1304
|
-
* @param document - Document to create
|
|
1305
|
-
* @param options - Mutation options
|
|
1673
|
+
* Clones the patch
|
|
1306
1674
|
*/
|
|
1307
|
-
|
|
1308
|
-
document: SanityDocumentStub<R>,
|
|
1309
|
-
options?: BaseMutationOptions,
|
|
1310
|
-
): Promise<SanityDocument<R>>
|
|
1675
|
+
clone(): Patch
|
|
1311
1676
|
/**
|
|
1312
|
-
*
|
|
1313
|
-
* Returns a promise that resolves to the created document.
|
|
1677
|
+
* Commit the patch, returning a promise that resolves to the first patched document
|
|
1314
1678
|
*
|
|
1315
|
-
* @param
|
|
1316
|
-
* @param options - Mutation options
|
|
1679
|
+
* @param options - Options for the mutation operation
|
|
1317
1680
|
*/
|
|
1318
|
-
|
|
1319
|
-
document: IdentifiedSanityDocumentStub<R>,
|
|
1681
|
+
commit<R extends Record<string, Any> = Record<string, Any>>(
|
|
1320
1682
|
options: FirstDocumentMutationOptions,
|
|
1321
1683
|
): Promise<SanityDocument<R>>
|
|
1322
1684
|
/**
|
|
1323
|
-
*
|
|
1324
|
-
* Returns a promise that resolves to an array containing the created document.
|
|
1685
|
+
* Commit the patch, returning a promise that resolves to an array of the mutated documents
|
|
1325
1686
|
*
|
|
1326
|
-
* @param
|
|
1327
|
-
* @param options - Mutation options
|
|
1687
|
+
* @param options - Options for the mutation operation
|
|
1328
1688
|
*/
|
|
1329
|
-
|
|
1330
|
-
document: IdentifiedSanityDocumentStub<R>,
|
|
1689
|
+
commit<R extends Record<string, Any> = Record<string, Any>>(
|
|
1331
1690
|
options: AllDocumentsMutationOptions,
|
|
1332
1691
|
): Promise<SanityDocument<R>[]>
|
|
1333
1692
|
/**
|
|
1334
|
-
*
|
|
1335
|
-
* Returns a promise that resolves to a mutation result object containing the ID of the created document.
|
|
1693
|
+
* Commit the patch, returning a promise that resolves to a mutation result object
|
|
1336
1694
|
*
|
|
1337
|
-
* @param
|
|
1338
|
-
* @param options - Mutation options
|
|
1695
|
+
* @param options - Options for the mutation operation
|
|
1339
1696
|
*/
|
|
1340
|
-
|
|
1341
|
-
document: IdentifiedSanityDocumentStub<R>,
|
|
1342
|
-
options: FirstDocumentIdMutationOptions,
|
|
1343
|
-
): Promise<SingleMutationResult>
|
|
1697
|
+
commit(options: FirstDocumentIdMutationOptions): Promise<SingleMutationResult>
|
|
1344
1698
|
/**
|
|
1345
|
-
*
|
|
1346
|
-
* Returns a promise that resolves to a mutation result object containing the ID of the created document.
|
|
1699
|
+
* Commit the patch, returning a promise that resolves to a mutation result object
|
|
1347
1700
|
*
|
|
1348
|
-
* @param
|
|
1349
|
-
* @param options - Mutation options
|
|
1701
|
+
* @param options - Options for the mutation operation
|
|
1350
1702
|
*/
|
|
1351
|
-
|
|
1352
|
-
document: IdentifiedSanityDocumentStub<R>,
|
|
1353
|
-
options: AllDocumentIdsMutationOptions,
|
|
1354
|
-
): Promise<MultipleMutationResult>
|
|
1703
|
+
commit(options: AllDocumentIdsMutationOptions): Promise<MultipleMutationResult>
|
|
1355
1704
|
/**
|
|
1356
|
-
*
|
|
1357
|
-
* Returns a promise that resolves to the created document.
|
|
1705
|
+
* Commit the patch, returning a promise that resolves to the first patched document
|
|
1358
1706
|
*
|
|
1359
|
-
* @param
|
|
1360
|
-
* @param options - Mutation options
|
|
1707
|
+
* @param options - Options for the mutation operation
|
|
1361
1708
|
*/
|
|
1362
|
-
|
|
1363
|
-
document: IdentifiedSanityDocumentStub<R>,
|
|
1709
|
+
commit<R extends Record<string, Any> = Record<string, Any>>(
|
|
1364
1710
|
options?: BaseMutationOptions,
|
|
1365
1711
|
): Promise<SanityDocument<R>>
|
|
1712
|
+
}
|
|
1713
|
+
|
|
1714
|
+
/** @public */
|
|
1715
|
+
export declare type PatchBuilder = (patch: Patch) => Patch
|
|
1716
|
+
|
|
1717
|
+
/** @internal */
|
|
1718
|
+
export declare type PatchMutationOperation = PatchOperations & MutationSelection
|
|
1719
|
+
|
|
1720
|
+
/** @internal */
|
|
1721
|
+
export declare interface PatchOperations {
|
|
1722
|
+
set?: {
|
|
1723
|
+
[key: string]: Any
|
|
1724
|
+
}
|
|
1725
|
+
setIfMissing?: {
|
|
1726
|
+
[key: string]: Any
|
|
1727
|
+
}
|
|
1728
|
+
diffMatchPatch?: {
|
|
1729
|
+
[key: string]: Any
|
|
1730
|
+
}
|
|
1731
|
+
unset?: string[]
|
|
1732
|
+
inc?: {
|
|
1733
|
+
[key: string]: number
|
|
1734
|
+
}
|
|
1735
|
+
dec?: {
|
|
1736
|
+
[key: string]: number
|
|
1737
|
+
}
|
|
1738
|
+
insert?: InsertPatch
|
|
1739
|
+
ifRevisionID?: string
|
|
1740
|
+
}
|
|
1741
|
+
|
|
1742
|
+
/** @internal */
|
|
1743
|
+
export declare type PatchSelection = string | string[] | MutationSelection
|
|
1744
|
+
|
|
1745
|
+
/** @public */
|
|
1746
|
+
declare interface ProgressEvent_2 {
|
|
1747
|
+
type: 'progress'
|
|
1748
|
+
stage: 'upload' | 'download'
|
|
1749
|
+
percent: number
|
|
1750
|
+
total?: number
|
|
1751
|
+
loaded?: number
|
|
1752
|
+
lengthComputable: boolean
|
|
1753
|
+
}
|
|
1754
|
+
export {ProgressEvent_2 as ProgressEvent}
|
|
1755
|
+
|
|
1756
|
+
/** @internal */
|
|
1757
|
+
export declare class ProjectsClient {
|
|
1758
|
+
#private
|
|
1759
|
+
constructor(client: SanityClient, httpRequest: HttpRequest)
|
|
1366
1760
|
/**
|
|
1367
|
-
*
|
|
1368
|
-
* Returns a promise that resolves to the created document.
|
|
1761
|
+
* Fetch a list of projects the authenticated user has access to.
|
|
1369
1762
|
*
|
|
1370
|
-
* @param
|
|
1371
|
-
* @param options -
|
|
1763
|
+
* @param options - Options for the list request
|
|
1764
|
+
* @param options.includeMembers - Whether to include members in the response (default: true)
|
|
1372
1765
|
*/
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
options: FirstDocumentMutationOptions,
|
|
1376
|
-
): Promise<SanityDocument<R>>
|
|
1766
|
+
list(options?: {includeMembers?: true}): Promise<SanityProject[]>
|
|
1767
|
+
list(options?: {includeMembers?: false}): Promise<Omit<SanityProject, 'members'>[]>
|
|
1377
1768
|
/**
|
|
1378
|
-
*
|
|
1379
|
-
* Returns a promise that resolves to an array containing the created document.
|
|
1769
|
+
* Fetch a project by project ID
|
|
1380
1770
|
*
|
|
1381
|
-
* @param
|
|
1382
|
-
* @param options - Mutation options
|
|
1771
|
+
* @param projectId - ID of the project to fetch
|
|
1383
1772
|
*/
|
|
1384
|
-
|
|
1385
|
-
document: IdentifiedSanityDocumentStub<R>,
|
|
1386
|
-
options: AllDocumentsMutationOptions,
|
|
1387
|
-
): Promise<SanityDocument<R>[]>
|
|
1388
|
-
/**
|
|
1389
|
-
* Create a document if it does not exist, or replace a document with the same document ID
|
|
1390
|
-
* Returns a promise that resolves to a mutation result object containing the ID of the created document.
|
|
1391
|
-
*
|
|
1392
|
-
* @param document - Document to either create or replace
|
|
1393
|
-
* @param options - Mutation options
|
|
1394
|
-
*/
|
|
1395
|
-
createOrReplace<R extends Record<string, Any> = Record<string, Any>>(
|
|
1396
|
-
document: IdentifiedSanityDocumentStub<R>,
|
|
1397
|
-
options: FirstDocumentIdMutationOptions,
|
|
1398
|
-
): Promise<SingleMutationResult>
|
|
1399
|
-
/**
|
|
1400
|
-
* Create a document if it does not exist, or replace a document with the same document ID
|
|
1401
|
-
* Returns a promise that resolves to a mutation result object containing the created document ID.
|
|
1402
|
-
*
|
|
1403
|
-
* @param document - Document to either create or replace
|
|
1404
|
-
* @param options - Mutation options
|
|
1405
|
-
*/
|
|
1406
|
-
createOrReplace<R extends Record<string, Any> = Record<string, Any>>(
|
|
1407
|
-
document: IdentifiedSanityDocumentStub<R>,
|
|
1408
|
-
options: AllDocumentIdsMutationOptions,
|
|
1409
|
-
): Promise<MultipleMutationResult>
|
|
1410
|
-
/**
|
|
1411
|
-
* Create a document if it does not exist, or replace a document with the same document ID
|
|
1412
|
-
* Returns a promise that resolves to the created document.
|
|
1413
|
-
*
|
|
1414
|
-
* @param document - Document to either create or replace
|
|
1415
|
-
* @param options - Mutation options
|
|
1416
|
-
*/
|
|
1417
|
-
createOrReplace<R extends Record<string, Any> = Record<string, Any>>(
|
|
1418
|
-
document: IdentifiedSanityDocumentStub<R>,
|
|
1419
|
-
options?: BaseMutationOptions,
|
|
1420
|
-
): Promise<SanityDocument<R>>
|
|
1421
|
-
/**
|
|
1422
|
-
* Deletes a document with the given document ID.
|
|
1423
|
-
* Returns a promise that resolves to the deleted document.
|
|
1424
|
-
*
|
|
1425
|
-
* @param id - Document ID to delete
|
|
1426
|
-
* @param options - Options for the mutation
|
|
1427
|
-
*/
|
|
1428
|
-
delete<R extends Record<string, Any> = Record<string, Any>>(
|
|
1429
|
-
id: string,
|
|
1430
|
-
options: FirstDocumentMutationOptions,
|
|
1431
|
-
): Promise<SanityDocument<R>>
|
|
1432
|
-
/**
|
|
1433
|
-
* Deletes a document with the given document ID.
|
|
1434
|
-
* Returns a promise that resolves to an array containing the deleted document.
|
|
1435
|
-
*
|
|
1436
|
-
* @param id - Document ID to delete
|
|
1437
|
-
* @param options - Options for the mutation
|
|
1438
|
-
*/
|
|
1439
|
-
delete<R extends Record<string, Any> = Record<string, Any>>(
|
|
1440
|
-
id: string,
|
|
1441
|
-
options: AllDocumentsMutationOptions,
|
|
1442
|
-
): Promise<SanityDocument<R>[]>
|
|
1443
|
-
/**
|
|
1444
|
-
* Deletes a document with the given document ID.
|
|
1445
|
-
* Returns a promise that resolves to a mutation result object containing the deleted document ID.
|
|
1446
|
-
*
|
|
1447
|
-
* @param id - Document ID to delete
|
|
1448
|
-
* @param options - Options for the mutation
|
|
1449
|
-
*/
|
|
1450
|
-
delete(id: string, options: FirstDocumentIdMutationOptions): Promise<SingleMutationResult>
|
|
1451
|
-
/**
|
|
1452
|
-
* Deletes a document with the given document ID.
|
|
1453
|
-
* Returns a promise that resolves to a mutation result object containing the deleted document ID.
|
|
1454
|
-
*
|
|
1455
|
-
* @param id - Document ID to delete
|
|
1456
|
-
* @param options - Options for the mutation
|
|
1457
|
-
*/
|
|
1458
|
-
delete(id: string, options: AllDocumentIdsMutationOptions): Promise<MultipleMutationResult>
|
|
1459
|
-
/**
|
|
1460
|
-
* Deletes a document with the given document ID.
|
|
1461
|
-
* Returns a promise that resolves to the deleted document.
|
|
1462
|
-
*
|
|
1463
|
-
* @param id - Document ID to delete
|
|
1464
|
-
* @param options - Options for the mutation
|
|
1465
|
-
*/
|
|
1466
|
-
delete<R extends Record<string, Any> = Record<string, Any>>(
|
|
1467
|
-
id: string,
|
|
1468
|
-
options?: BaseMutationOptions,
|
|
1469
|
-
): Promise<SanityDocument<R>>
|
|
1470
|
-
/**
|
|
1471
|
-
* Deletes one or more documents matching the given query or document ID.
|
|
1472
|
-
* Returns a promise that resolves to first deleted document.
|
|
1473
|
-
*
|
|
1474
|
-
* @param selection - An object with either an `id` or `query` key defining what to delete
|
|
1475
|
-
* @param options - Options for the mutation
|
|
1476
|
-
*/
|
|
1477
|
-
delete<R extends Record<string, Any> = Record<string, Any>>(
|
|
1478
|
-
selection: MutationSelection,
|
|
1479
|
-
options: FirstDocumentMutationOptions,
|
|
1480
|
-
): Promise<SanityDocument<R>>
|
|
1481
|
-
/**
|
|
1482
|
-
* Deletes one or more documents matching the given query or document ID.
|
|
1483
|
-
* Returns a promise that resolves to an array containing the deleted documents.
|
|
1484
|
-
*
|
|
1485
|
-
* @param selection - An object with either an `id` or `query` key defining what to delete
|
|
1486
|
-
* @param options - Options for the mutation
|
|
1487
|
-
*/
|
|
1488
|
-
delete<R extends Record<string, Any> = Record<string, Any>>(
|
|
1489
|
-
selection: MutationSelection,
|
|
1490
|
-
options: AllDocumentsMutationOptions,
|
|
1491
|
-
): Promise<SanityDocument<R>[]>
|
|
1492
|
-
/**
|
|
1493
|
-
* Deletes one or more documents matching the given query or document ID.
|
|
1494
|
-
* Returns a promise that resolves to a mutation result object containing the ID of the first deleted document.
|
|
1495
|
-
*
|
|
1496
|
-
* @param selection - An object with either an `id` or `query` key defining what to delete
|
|
1497
|
-
* @param options - Options for the mutation
|
|
1498
|
-
*/
|
|
1499
|
-
delete(
|
|
1500
|
-
selection: MutationSelection,
|
|
1501
|
-
options: FirstDocumentIdMutationOptions,
|
|
1502
|
-
): Promise<SingleMutationResult>
|
|
1503
|
-
/**
|
|
1504
|
-
* Deletes one or more documents matching the given query or document ID.
|
|
1505
|
-
* Returns a promise that resolves to a mutation result object containing the document IDs that were deleted.
|
|
1506
|
-
*
|
|
1507
|
-
* @param selection - An object with either an `id` or `query` key defining what to delete
|
|
1508
|
-
* @param options - Options for the mutation
|
|
1509
|
-
*/
|
|
1510
|
-
delete(
|
|
1511
|
-
selection: MutationSelection,
|
|
1512
|
-
options: AllDocumentIdsMutationOptions,
|
|
1513
|
-
): Promise<MultipleMutationResult>
|
|
1514
|
-
/**
|
|
1515
|
-
* Deletes one or more documents matching the given query or document ID.
|
|
1516
|
-
* Returns a promise that resolves to first deleted document.
|
|
1517
|
-
*
|
|
1518
|
-
* @param selection - An object with either an `id` or `query` key defining what to delete
|
|
1519
|
-
* @param options - Options for the mutation
|
|
1520
|
-
*/
|
|
1521
|
-
delete<R extends Record<string, Any> = Record<string, Any>>(
|
|
1522
|
-
selection: MutationSelection,
|
|
1523
|
-
options?: BaseMutationOptions,
|
|
1524
|
-
): Promise<SanityDocument<R>>
|
|
1525
|
-
/**
|
|
1526
|
-
* Perform mutation operations against the configured dataset
|
|
1527
|
-
* Returns a promise that resolves to the first mutated document.
|
|
1528
|
-
*
|
|
1529
|
-
* @param operations - Mutation operations to execute
|
|
1530
|
-
* @param options - Mutation options
|
|
1531
|
-
*/
|
|
1532
|
-
mutate<R extends Record<string, Any> = Record<string, Any>>(
|
|
1533
|
-
operations: Mutation<R>[] | Patch | Transaction,
|
|
1534
|
-
options: FirstDocumentMutationOptions,
|
|
1535
|
-
): Promise<SanityDocument<R>>
|
|
1536
|
-
/**
|
|
1537
|
-
* Perform mutation operations against the configured dataset.
|
|
1538
|
-
* Returns a promise that resolves to an array of the mutated documents.
|
|
1539
|
-
*
|
|
1540
|
-
* @param operations - Mutation operations to execute
|
|
1541
|
-
* @param options - Mutation options
|
|
1542
|
-
*/
|
|
1543
|
-
mutate<R extends Record<string, Any> = Record<string, Any>>(
|
|
1544
|
-
operations: Mutation<R>[] | Patch | Transaction,
|
|
1545
|
-
options: AllDocumentsMutationOptions,
|
|
1546
|
-
): Promise<SanityDocument<R>[]>
|
|
1547
|
-
/**
|
|
1548
|
-
* Perform mutation operations against the configured dataset
|
|
1549
|
-
* Returns a promise that resolves to a mutation result object containing the document ID of the first mutated document.
|
|
1550
|
-
*
|
|
1551
|
-
* @param operations - Mutation operations to execute
|
|
1552
|
-
* @param options - Mutation options
|
|
1553
|
-
*/
|
|
1554
|
-
mutate<R extends Record<string, Any> = Record<string, Any>>(
|
|
1555
|
-
operations: Mutation<R>[] | Patch | Transaction,
|
|
1556
|
-
options: FirstDocumentIdMutationOptions,
|
|
1557
|
-
): Promise<SingleMutationResult>
|
|
1558
|
-
/**
|
|
1559
|
-
* Perform mutation operations against the configured dataset
|
|
1560
|
-
* Returns a promise that resolves to a mutation result object containing the mutated document IDs.
|
|
1561
|
-
*
|
|
1562
|
-
* @param operations - Mutation operations to execute
|
|
1563
|
-
* @param options - Mutation options
|
|
1564
|
-
*/
|
|
1565
|
-
mutate<R extends Record<string, Any>>(
|
|
1566
|
-
operations: Mutation<R>[] | Patch | Transaction,
|
|
1567
|
-
options: AllDocumentIdsMutationOptions,
|
|
1568
|
-
): Promise<MultipleMutationResult>
|
|
1569
|
-
/**
|
|
1570
|
-
* Perform mutation operations against the configured dataset
|
|
1571
|
-
* Returns a promise that resolves to the first mutated document.
|
|
1572
|
-
*
|
|
1573
|
-
* @param operations - Mutation operations to execute
|
|
1574
|
-
* @param options - Mutation options
|
|
1575
|
-
*/
|
|
1576
|
-
mutate<R extends Record<string, Any> = Record<string, Any>>(
|
|
1577
|
-
operations: Mutation<R>[] | Patch | Transaction,
|
|
1578
|
-
options?: BaseMutationOptions,
|
|
1579
|
-
): Promise<SanityDocument<R>>
|
|
1580
|
-
/**
|
|
1581
|
-
* Create a new buildable patch of operations to perform
|
|
1582
|
-
*
|
|
1583
|
-
* @param documentId - Document ID to patch
|
|
1584
|
-
* @param operations - Optional object of patch operations to initialize the patch instance with
|
|
1585
|
-
* @returns Patch instance - call `.commit()` to perform the operations defined
|
|
1586
|
-
*/
|
|
1587
|
-
patch(documentId: string, operations?: PatchOperations): Patch
|
|
1588
|
-
/**
|
|
1589
|
-
* Create a new buildable patch of operations to perform
|
|
1590
|
-
*
|
|
1591
|
-
* @param documentIds - Array of document IDs to patch
|
|
1592
|
-
* @param operations - Optional object of patch operations to initialize the patch instance with
|
|
1593
|
-
* @returns Patch instance - call `.commit()` to perform the operations defined
|
|
1594
|
-
*/
|
|
1595
|
-
patch(documentIds: string[], operations?: PatchOperations): Patch
|
|
1596
|
-
/**
|
|
1597
|
-
* Create a new buildable patch of operations to perform
|
|
1598
|
-
*
|
|
1599
|
-
* @param selection - An object with `query` and optional `params`, defining which document(s) to patch
|
|
1600
|
-
* @param operations - Optional object of patch operations to initialize the patch instance with
|
|
1601
|
-
* @returns Patch instance - call `.commit()` to perform the operations defined
|
|
1602
|
-
*/
|
|
1603
|
-
patch(selection: MutationSelection, operations?: PatchOperations): Patch
|
|
1604
|
-
/**
|
|
1605
|
-
* Create a new transaction of mutations
|
|
1606
|
-
*
|
|
1607
|
-
* @param operations - Optional array of mutation operations to initialize the transaction instance with
|
|
1608
|
-
*/
|
|
1609
|
-
transaction<R extends Record<string, Any> = Record<string, Any>>(
|
|
1610
|
-
operations?: Mutation<R>[],
|
|
1611
|
-
): Transaction
|
|
1612
|
-
/**
|
|
1613
|
-
* Perform a request against the Sanity API
|
|
1614
|
-
* NOTE: Only use this for Sanity API endpoints, not for your own APIs!
|
|
1615
|
-
*
|
|
1616
|
-
* @param options - Request options
|
|
1617
|
-
* @returns Promise resolving to the response body
|
|
1618
|
-
*/
|
|
1619
|
-
request<R = Any>(options: RawRequestOptions): Promise<R>
|
|
1620
|
-
/**
|
|
1621
|
-
* Perform an HTTP request a `/data` sub-endpoint
|
|
1622
|
-
* NOTE: Considered internal, thus marked as deprecated. Use `request` instead.
|
|
1623
|
-
*
|
|
1624
|
-
* @deprecated - Use `request()` or your own HTTP library instead
|
|
1625
|
-
* @param endpoint - Endpoint to hit (mutate, query etc)
|
|
1626
|
-
* @param body - Request body
|
|
1627
|
-
* @param options - Request options
|
|
1628
|
-
* @internal
|
|
1629
|
-
*/
|
|
1630
|
-
dataRequest(endpoint: string, body: unknown, options?: BaseMutationOptions): Promise<Any>
|
|
1631
|
-
/**
|
|
1632
|
-
* Get a Sanity API URL for the URI provided
|
|
1633
|
-
*
|
|
1634
|
-
* @param uri - URI/path to build URL for
|
|
1635
|
-
* @param canUseCdn - Whether or not to allow using the API CDN for this route
|
|
1636
|
-
*/
|
|
1637
|
-
getUrl(uri: string, canUseCdn?: boolean): string
|
|
1638
|
-
/**
|
|
1639
|
-
* Get a Sanity API URL for the data operation and path provided
|
|
1640
|
-
*
|
|
1641
|
-
* @param operation - Data operation (eg `query`, `mutate`, `listen` or similar)
|
|
1642
|
-
* @param path - Path to append after the operation
|
|
1643
|
-
*/
|
|
1644
|
-
getDataUrl(operation: string, path?: string): string
|
|
1773
|
+
getById(projectId: string): Promise<SanityProject>
|
|
1645
1774
|
}
|
|
1646
1775
|
|
|
1647
|
-
/**
|
|
1648
|
-
* Set up a listener that will be notified when mutations occur on documents matching the provided query/filter.
|
|
1649
|
-
*
|
|
1650
|
-
* @param query - GROQ-filter to listen to changes for
|
|
1651
|
-
* @param params - Optional query parameters
|
|
1652
|
-
* @param options - Optional listener options
|
|
1653
|
-
* @public
|
|
1654
|
-
*/
|
|
1655
|
-
export declare function _listen<R extends Record<string, Any> = Record<string, Any>>(
|
|
1656
|
-
this:
|
|
1657
|
-
| INTERNAL_DO_NOT_USE_DIRECTLY_SanityClient
|
|
1658
|
-
| INTERNAL_DO_NOT_USE_DIRECTLY_ObservableSanityClient,
|
|
1659
|
-
query: string,
|
|
1660
|
-
params?: QueryParams,
|
|
1661
|
-
): Observable<MutationEvent_2<R>>
|
|
1662
|
-
|
|
1663
|
-
/**
|
|
1664
|
-
* Set up a listener that will be notified when mutations occur on documents matching the provided query/filter.
|
|
1665
|
-
*
|
|
1666
|
-
* @param query - GROQ-filter to listen to changes for
|
|
1667
|
-
* @param params - Optional query parameters
|
|
1668
|
-
* @param options - Optional listener options
|
|
1669
|
-
* @public
|
|
1670
|
-
*/
|
|
1671
|
-
export declare function _listen<R extends Record<string, Any> = Record<string, Any>>(
|
|
1672
|
-
this:
|
|
1673
|
-
| INTERNAL_DO_NOT_USE_DIRECTLY_SanityClient
|
|
1674
|
-
| INTERNAL_DO_NOT_USE_DIRECTLY_ObservableSanityClient,
|
|
1675
|
-
query: string,
|
|
1676
|
-
params?: QueryParams,
|
|
1677
|
-
options?: ListenOptions,
|
|
1678
|
-
): Observable<ListenEvent<R>>
|
|
1679
|
-
|
|
1680
1776
|
/** @public */
|
|
1681
|
-
export declare type
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
| DisconnectEvent
|
|
1685
|
-
| ReconnectEvent
|
|
1686
|
-
| WelcomeEvent
|
|
1777
|
+
export declare type QueryParams = {
|
|
1778
|
+
[key: string]: Any
|
|
1779
|
+
}
|
|
1687
1780
|
|
|
1688
1781
|
/** @public */
|
|
1689
|
-
export declare
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
| 'reconnect'
|
|
1782
|
+
export declare interface RawQueryResponse<R> {
|
|
1783
|
+
query: string
|
|
1784
|
+
ms: number
|
|
1785
|
+
result: R
|
|
1786
|
+
resultSourceMap?: ContentSourceMap
|
|
1787
|
+
}
|
|
1696
1788
|
|
|
1697
|
-
/** @
|
|
1698
|
-
export declare interface
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
*/
|
|
1705
|
-
includeResult?: boolean
|
|
1706
|
-
/**
|
|
1707
|
-
* Whether or not to include the document as it looked before the mutation event.
|
|
1708
|
-
* The previous revision will be available on the `.previous` property of the events,
|
|
1709
|
-
* and may be `null` in the case of a new document.
|
|
1710
|
-
* @defaultValue `false`
|
|
1711
|
-
*/
|
|
1712
|
-
includePreviousRevision?: boolean
|
|
1713
|
-
/**
|
|
1714
|
-
* Whether events should be sent as soon as a transaction has been committed (`transaction`, default),
|
|
1715
|
-
* or only after they are available for queries (query). Note that this is on a best-effort basis,
|
|
1716
|
-
* and listeners with `query` may in certain cases (notably with deferred transactions) receive events
|
|
1717
|
-
* that are not yet visible to queries.
|
|
1718
|
-
*
|
|
1719
|
-
* @defaultValue `'transaction'`
|
|
1720
|
-
*/
|
|
1721
|
-
visibility?: 'transaction' | 'query'
|
|
1722
|
-
/**
|
|
1723
|
-
* Array of event names to include in the observable. By default, only mutation events are included.
|
|
1724
|
-
*
|
|
1725
|
-
* @defaultValue `['mutation']`
|
|
1726
|
-
*/
|
|
1727
|
-
events?: ListenEventName[]
|
|
1728
|
-
/**
|
|
1729
|
-
* Format of "effects", eg the resulting changes of a mutation.
|
|
1730
|
-
* Currently only `mendoza` is supported, and (if set) will include `apply` and `revert` arrays
|
|
1731
|
-
* in the mutation events under the `effects` property.
|
|
1732
|
-
*
|
|
1733
|
-
* See {@link https://github.com/sanity-io/mendoza | The mendoza docs} for more info
|
|
1734
|
-
*
|
|
1735
|
-
* @defaultValue `undefined`
|
|
1736
|
-
*/
|
|
1737
|
-
effectFormat?: 'mendoza'
|
|
1738
|
-
/**
|
|
1739
|
-
* Optional request tag for the listener. Use to identify the request in logs.
|
|
1740
|
-
*
|
|
1741
|
-
* @defaultValue `undefined`
|
|
1742
|
-
*/
|
|
1789
|
+
/** @internal */
|
|
1790
|
+
export declare interface RawRequestOptions {
|
|
1791
|
+
url?: string
|
|
1792
|
+
uri?: string
|
|
1793
|
+
method?: string
|
|
1794
|
+
token?: string
|
|
1795
|
+
json?: boolean
|
|
1743
1796
|
tag?: string
|
|
1797
|
+
useGlobalApi?: boolean
|
|
1798
|
+
withCredentials?: boolean
|
|
1799
|
+
query?: {
|
|
1800
|
+
[key: string]: string | string[]
|
|
1801
|
+
}
|
|
1802
|
+
headers?: {
|
|
1803
|
+
[key: string]: string
|
|
1804
|
+
}
|
|
1805
|
+
timeout?: number
|
|
1806
|
+
proxy?: string
|
|
1807
|
+
body?: Any
|
|
1808
|
+
maxRedirects?: number
|
|
1809
|
+
}
|
|
1810
|
+
|
|
1811
|
+
/**
|
|
1812
|
+
* The listener has been disconnected, and a reconnect attempt is scheduled.
|
|
1813
|
+
*
|
|
1814
|
+
* @public
|
|
1815
|
+
*/
|
|
1816
|
+
export declare type ReconnectEvent = {
|
|
1817
|
+
type: 'reconnect'
|
|
1744
1818
|
}
|
|
1745
1819
|
|
|
1746
1820
|
/** @public */
|
|
1747
|
-
export declare
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1821
|
+
export declare const requester: Requester
|
|
1822
|
+
|
|
1823
|
+
/**
|
|
1824
|
+
* Options for the native `fetch` feature, used by the Next.js app-router
|
|
1825
|
+
* @public
|
|
1826
|
+
*/
|
|
1827
|
+
export declare interface RequestFetchOptions<T = 'next'> {
|
|
1828
|
+
cache?: RequestInit['cache']
|
|
1829
|
+
next?: T extends keyof RequestInit ? RequestInit[T] : never
|
|
1830
|
+
}
|
|
1752
1831
|
|
|
1753
1832
|
/** @internal */
|
|
1754
|
-
export declare interface
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1833
|
+
export declare interface RequestObservableOptions extends Omit<RequestOptions, 'url'> {
|
|
1834
|
+
url?: string
|
|
1835
|
+
uri?: string
|
|
1836
|
+
canUseCdn?: boolean
|
|
1837
|
+
useCdn?: boolean
|
|
1838
|
+
tag?: string
|
|
1839
|
+
resultSourceMap?: boolean | 'withKeyArraySelector'
|
|
1840
|
+
perspective?: ClientPerspective
|
|
1761
1841
|
}
|
|
1762
1842
|
|
|
1763
1843
|
/** @public */
|
|
1764
|
-
export declare
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
| {
|
|
1775
|
-
delete: MutationSelection
|
|
1776
|
-
}
|
|
1777
|
-
| {
|
|
1778
|
-
patch: PatchMutationOperation
|
|
1779
|
-
}
|
|
1844
|
+
export declare interface RequestOptions {
|
|
1845
|
+
timeout?: number
|
|
1846
|
+
token?: string
|
|
1847
|
+
tag?: string
|
|
1848
|
+
headers?: Record<string, string>
|
|
1849
|
+
method?: string
|
|
1850
|
+
query?: Any
|
|
1851
|
+
body?: Any
|
|
1852
|
+
signal?: AbortSignal
|
|
1853
|
+
}
|
|
1780
1854
|
|
|
1781
|
-
/** @
|
|
1782
|
-
export declare
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1855
|
+
/** @alpha */
|
|
1856
|
+
export declare type ResolveStudioUrl = (
|
|
1857
|
+
sourceDocument: ContentSourceMapDocuments[number],
|
|
1858
|
+
) => StudioUrl
|
|
1859
|
+
|
|
1860
|
+
/** @public */
|
|
1861
|
+
export declare interface ResponseEvent<T = unknown> {
|
|
1862
|
+
type: 'response'
|
|
1863
|
+
body: T
|
|
1864
|
+
url: string
|
|
1865
|
+
method: string
|
|
1866
|
+
statusCode: number
|
|
1867
|
+
statusMessage?: string
|
|
1868
|
+
headers: Record<string, string>
|
|
1869
|
+
}
|
|
1870
|
+
|
|
1871
|
+
/** @public */
|
|
1872
|
+
export declare interface ResponseQueryOptions<T = 'next'> extends RequestOptions {
|
|
1873
|
+
perspective?: ClientPerspective
|
|
1874
|
+
resultSourceMap?: boolean | 'withKeyArraySelector'
|
|
1875
|
+
cache?: RequestInit['cache']
|
|
1876
|
+
next?: T extends keyof RequestInit ? RequestInit[T] : never
|
|
1877
|
+
useCdn?: boolean
|
|
1878
|
+
stega?: boolean | StegaConfig
|
|
1788
1879
|
}
|
|
1789
1880
|
|
|
1790
1881
|
/** @internal */
|
|
1791
|
-
export declare interface
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1882
|
+
export declare interface SanityAssetDocument extends SanityDocument {
|
|
1883
|
+
url: string
|
|
1884
|
+
path: string
|
|
1885
|
+
size: number
|
|
1886
|
+
assetId: string
|
|
1887
|
+
mimeType: string
|
|
1888
|
+
sha1hash: string
|
|
1889
|
+
extension: string
|
|
1890
|
+
uploadId?: string
|
|
1891
|
+
originalFilename?: string
|
|
1797
1892
|
}
|
|
1798
1893
|
|
|
1799
|
-
/**
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
type: 'mutation'
|
|
1807
|
-
/**
|
|
1808
|
-
* The ID of the document that was affected
|
|
1809
|
-
*/
|
|
1810
|
-
documentId: string
|
|
1811
|
-
/**
|
|
1812
|
-
* A unique ID for this event
|
|
1813
|
-
*/
|
|
1814
|
-
eventId: string
|
|
1815
|
-
/**
|
|
1816
|
-
* The user ID of the user that performed the mutation
|
|
1817
|
-
*/
|
|
1818
|
-
identity: string
|
|
1819
|
-
/**
|
|
1820
|
-
* An array of mutations that were performed. Note that this can differ slightly from the
|
|
1821
|
-
* mutations sent to the server, as the server may perform some mutations automatically.
|
|
1822
|
-
*/
|
|
1823
|
-
mutations: Mutation[]
|
|
1824
|
-
/**
|
|
1825
|
-
* The revision ID of the document before the mutation was performed
|
|
1826
|
-
*/
|
|
1827
|
-
previousRev?: string
|
|
1828
|
-
/**
|
|
1829
|
-
* The revision ID of the document after the mutation was performed
|
|
1830
|
-
*/
|
|
1831
|
-
resultRev?: string
|
|
1894
|
+
/** @public */
|
|
1895
|
+
export declare class SanityClient {
|
|
1896
|
+
#private
|
|
1897
|
+
assets: AssetsClient
|
|
1898
|
+
datasets: DatasetsClient
|
|
1899
|
+
projects: ProjectsClient
|
|
1900
|
+
users: UsersClient
|
|
1832
1901
|
/**
|
|
1833
|
-
*
|
|
1834
|
-
* the listener was configured with `includeResult: true`.
|
|
1902
|
+
* Observable version of the Sanity client, with the same configuration as the promise-based one
|
|
1835
1903
|
*/
|
|
1836
|
-
|
|
1904
|
+
observable: ObservableSanityClient
|
|
1837
1905
|
/**
|
|
1838
|
-
*
|
|
1839
|
-
* the listener was configured with `includePreviousRevision: true`.
|
|
1906
|
+
* Instance properties
|
|
1840
1907
|
*/
|
|
1841
|
-
|
|
1908
|
+
listen: typeof _listen
|
|
1909
|
+
constructor(httpRequest: HttpRequest, config?: ClientConfig)
|
|
1842
1910
|
/**
|
|
1843
|
-
*
|
|
1844
|
-
* Object with `apply` and `revert` arrays, see {@link https://github.com/sanity-io/mendoza}.
|
|
1911
|
+
* Clone the client - returns a new instance
|
|
1845
1912
|
*/
|
|
1846
|
-
|
|
1847
|
-
apply: unknown[]
|
|
1848
|
-
revert: unknown[]
|
|
1849
|
-
}
|
|
1913
|
+
clone(): SanityClient
|
|
1850
1914
|
/**
|
|
1851
|
-
*
|
|
1915
|
+
* Returns the current client configuration
|
|
1852
1916
|
*/
|
|
1853
|
-
|
|
1917
|
+
config(): InitializedClientConfig
|
|
1854
1918
|
/**
|
|
1855
|
-
*
|
|
1919
|
+
* Reconfigure the client. Note that this _mutates_ the current client.
|
|
1856
1920
|
*/
|
|
1857
|
-
|
|
1921
|
+
config(newConfig?: Partial<ClientConfig>): this
|
|
1858
1922
|
/**
|
|
1859
|
-
*
|
|
1923
|
+
* Clone the client with a new (partial) configuration.
|
|
1860
1924
|
*
|
|
1861
|
-
*
|
|
1862
|
-
* and still is.
|
|
1863
|
-
* - `appear` means the document was not previously part of the subscribed set of documents,
|
|
1864
|
-
* but is now. This can happen both on create or if updating to a state where it now matches
|
|
1865
|
-
* the filter provided to the listener.
|
|
1866
|
-
* - `disappear` means the document was previously part of the subscribed set of documents,
|
|
1867
|
-
* but is no longer. This can happen both on delete or if updating to a state where it no
|
|
1868
|
-
* longer matches the filter provided to the listener.
|
|
1869
|
-
*/
|
|
1870
|
-
transition: 'update' | 'appear' | 'disappear'
|
|
1871
|
-
/**
|
|
1872
|
-
* Whether the change that triggered this event is visible to queries (query) or only to
|
|
1873
|
-
* subsequent transactions (transaction). The listener client can specify a preferred visibility
|
|
1874
|
-
* through the `visibility` parameter on the listener, but this is only on a best-effort basis,
|
|
1875
|
-
* and may yet not be accurate.
|
|
1925
|
+
* @param newConfig - New client configuration properties, shallowly merged with existing configuration
|
|
1876
1926
|
*/
|
|
1877
|
-
|
|
1927
|
+
withConfig(newConfig?: Partial<ClientConfig>): SanityClient
|
|
1878
1928
|
/**
|
|
1879
|
-
*
|
|
1880
|
-
* Note that this may differ from the amount of _documents_ affected by the transaction, as this
|
|
1881
|
-
* number only includes the documents that matches the given filter.
|
|
1929
|
+
* Perform a GROQ-query against the configured dataset.
|
|
1882
1930
|
*
|
|
1883
|
-
*
|
|
1884
|
-
* eg you would wait for `transactionTotalEvents` events with the same `transactionId` before
|
|
1885
|
-
* applying the changes locally.
|
|
1886
|
-
*/
|
|
1887
|
-
transactionTotalEvents: number
|
|
1888
|
-
/**
|
|
1889
|
-
* The index of this event within the transaction. Note that events may be delivered out of order,
|
|
1890
|
-
* and that the index is zero-based.
|
|
1931
|
+
* @param query - GROQ-query to perform
|
|
1891
1932
|
*/
|
|
1892
|
-
|
|
1893
|
-
}
|
|
1894
|
-
export {MutationEvent_2 as MutationEvent}
|
|
1895
|
-
|
|
1896
|
-
/** @internal */
|
|
1897
|
-
export declare type MutationOperation = 'create' | 'delete' | 'update' | 'none'
|
|
1898
|
-
|
|
1899
|
-
/** @internal */
|
|
1900
|
-
export declare type MutationSelection =
|
|
1901
|
-
| {
|
|
1902
|
-
query: string
|
|
1903
|
-
params?: QueryParams
|
|
1904
|
-
}
|
|
1905
|
-
| {
|
|
1906
|
-
id: string | string[]
|
|
1907
|
-
}
|
|
1908
|
-
|
|
1909
|
-
/** @internal */
|
|
1910
|
-
export declare class ObservableAssetsClient {
|
|
1911
|
-
#private
|
|
1912
|
-
constructor(client: INTERNAL_DO_NOT_USE_DIRECTLY_ObservableSanityClient, httpRequest: HttpRequest)
|
|
1933
|
+
fetch<R = Any>(query: string): Promise<R>
|
|
1913
1934
|
/**
|
|
1914
|
-
*
|
|
1935
|
+
* Perform a GROQ-query against the configured dataset.
|
|
1915
1936
|
*
|
|
1916
|
-
* @param
|
|
1917
|
-
* @param
|
|
1918
|
-
* @param options - Options to use for the upload
|
|
1937
|
+
* @param query - GROQ-query to perform
|
|
1938
|
+
* @param params - Optional query parameters
|
|
1919
1939
|
*/
|
|
1920
|
-
|
|
1921
|
-
assetType: 'file',
|
|
1922
|
-
body: UploadBody,
|
|
1923
|
-
options?: UploadClientConfig,
|
|
1924
|
-
): Observable<
|
|
1925
|
-
HttpRequestEvent<{
|
|
1926
|
-
document: SanityAssetDocument
|
|
1927
|
-
}>
|
|
1928
|
-
>
|
|
1940
|
+
fetch<R = Any, Q = QueryParams>(query: string, params: Q): Promise<R>
|
|
1929
1941
|
/**
|
|
1930
|
-
*
|
|
1942
|
+
* Perform a GROQ-query against the configured dataset.
|
|
1931
1943
|
*
|
|
1932
|
-
* @param
|
|
1933
|
-
* @param
|
|
1934
|
-
* @param options -
|
|
1944
|
+
* @param query - GROQ-query to perform
|
|
1945
|
+
* @param params - Optional query parameters
|
|
1946
|
+
* @param options - Request options
|
|
1935
1947
|
*/
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
options
|
|
1940
|
-
):
|
|
1941
|
-
HttpRequestEvent<{
|
|
1942
|
-
document: SanityImageAssetDocument
|
|
1943
|
-
}>
|
|
1944
|
-
>
|
|
1948
|
+
fetch<R = Any, Q = QueryParams>(
|
|
1949
|
+
query: string,
|
|
1950
|
+
params: Q | undefined,
|
|
1951
|
+
options: FilteredResponseQueryOptions,
|
|
1952
|
+
): Promise<R>
|
|
1945
1953
|
/**
|
|
1946
|
-
*
|
|
1954
|
+
* Perform a GROQ-query against the configured dataset.
|
|
1947
1955
|
*
|
|
1948
|
-
* @param
|
|
1949
|
-
* @param
|
|
1950
|
-
* @param options -
|
|
1956
|
+
* @param query - GROQ-query to perform
|
|
1957
|
+
* @param params - Optional query parameters
|
|
1958
|
+
* @param options - Request options
|
|
1951
1959
|
*/
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
options
|
|
1956
|
-
):
|
|
1957
|
-
HttpRequestEvent<{
|
|
1958
|
-
document: SanityAssetDocument | SanityImageAssetDocument
|
|
1959
|
-
}>
|
|
1960
|
-
>
|
|
1961
|
-
}
|
|
1962
|
-
|
|
1963
|
-
/** @internal */
|
|
1964
|
-
export declare class ObservableDatasetsClient {
|
|
1965
|
-
#private
|
|
1966
|
-
constructor(client: INTERNAL_DO_NOT_USE_DIRECTLY_ObservableSanityClient, httpRequest: HttpRequest)
|
|
1960
|
+
fetch<R = Any, Q = QueryParams>(
|
|
1961
|
+
query: string,
|
|
1962
|
+
params: Q | undefined,
|
|
1963
|
+
options: UnfilteredResponseQueryOptions,
|
|
1964
|
+
): Promise<RawQueryResponse<R>>
|
|
1967
1965
|
/**
|
|
1968
|
-
*
|
|
1966
|
+
* Fetch a single document with the given ID.
|
|
1969
1967
|
*
|
|
1970
|
-
* @param
|
|
1971
|
-
* @param options -
|
|
1968
|
+
* @param id - Document ID to fetch
|
|
1969
|
+
* @param options - Request options
|
|
1972
1970
|
*/
|
|
1973
|
-
|
|
1974
|
-
|
|
1971
|
+
getDocument<R extends Record<string, Any> = Record<string, Any>>(
|
|
1972
|
+
id: string,
|
|
1975
1973
|
options?: {
|
|
1976
|
-
|
|
1974
|
+
tag?: string
|
|
1977
1975
|
},
|
|
1978
|
-
):
|
|
1976
|
+
): Promise<SanityDocument<R> | undefined>
|
|
1979
1977
|
/**
|
|
1980
|
-
*
|
|
1978
|
+
* Fetch multiple documents in one request.
|
|
1979
|
+
* Should be used sparingly - performing a query is usually a better option.
|
|
1980
|
+
* The order/position of documents is preserved based on the original array of IDs.
|
|
1981
|
+
* If any of the documents are missing, they will be replaced by a `null` entry in the returned array
|
|
1981
1982
|
*
|
|
1982
|
-
* @param
|
|
1983
|
-
* @param options -
|
|
1983
|
+
* @param ids - Document IDs to fetch
|
|
1984
|
+
* @param options - Request options
|
|
1984
1985
|
*/
|
|
1985
|
-
|
|
1986
|
-
|
|
1986
|
+
getDocuments<R extends Record<string, Any> = Record<string, Any>>(
|
|
1987
|
+
ids: string[],
|
|
1987
1988
|
options?: {
|
|
1988
|
-
|
|
1989
|
+
tag?: string
|
|
1989
1990
|
},
|
|
1990
|
-
):
|
|
1991
|
+
): Promise<(SanityDocument<R> | null)[]>
|
|
1991
1992
|
/**
|
|
1992
|
-
*
|
|
1993
|
+
* Create a document. Requires a `_type` property. If no `_id` is provided, it will be generated by the database.
|
|
1994
|
+
* Returns a promise that resolves to the created document.
|
|
1993
1995
|
*
|
|
1994
|
-
* @param
|
|
1996
|
+
* @param document - Document to create
|
|
1997
|
+
* @param options - Mutation options
|
|
1995
1998
|
*/
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
+
create<R extends Record<string, Any> = Record<string, Any>>(
|
|
2000
|
+
document: SanityDocumentStub<R>,
|
|
2001
|
+
options: FirstDocumentMutationOptions,
|
|
2002
|
+
): Promise<SanityDocument<R>>
|
|
1999
2003
|
/**
|
|
2000
|
-
*
|
|
2004
|
+
* Create a document. Requires a `_type` property. If no `_id` is provided, it will be generated by the database.
|
|
2005
|
+
* Returns a promise that resolves to an array containing the created document.
|
|
2006
|
+
*
|
|
2007
|
+
* @param document - Document to create
|
|
2008
|
+
* @param options - Mutation options
|
|
2001
2009
|
*/
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
export declare class ObservablePatch extends BasePatch {
|
|
2007
|
-
#private
|
|
2008
|
-
constructor(
|
|
2009
|
-
selection: PatchSelection,
|
|
2010
|
-
operations?: PatchOperations,
|
|
2011
|
-
client?: INTERNAL_DO_NOT_USE_DIRECTLY_ObservableSanityClient,
|
|
2012
|
-
)
|
|
2010
|
+
create<R extends Record<string, Any> = Record<string, Any>>(
|
|
2011
|
+
document: SanityDocumentStub<R>,
|
|
2012
|
+
options: AllDocumentsMutationOptions,
|
|
2013
|
+
): Promise<SanityDocument<R>[]>
|
|
2013
2014
|
/**
|
|
2014
|
-
*
|
|
2015
|
+
* Create a document. Requires a `_type` property. If no `_id` is provided, it will be generated by the database.
|
|
2016
|
+
* Returns a promise that resolves to a mutation result object containing the ID of the created document.
|
|
2017
|
+
*
|
|
2018
|
+
* @param document - Document to create
|
|
2019
|
+
* @param options - Mutation options
|
|
2015
2020
|
*/
|
|
2016
|
-
|
|
2021
|
+
create<R extends Record<string, Any> = Record<string, Any>>(
|
|
2022
|
+
document: SanityDocumentStub<R>,
|
|
2023
|
+
options: FirstDocumentIdMutationOptions,
|
|
2024
|
+
): Promise<SingleMutationResult>
|
|
2017
2025
|
/**
|
|
2018
|
-
*
|
|
2026
|
+
* Create a document. Requires a `_type` property. If no `_id` is provided, it will be generated by the database.
|
|
2027
|
+
* Returns a promise that resolves to a mutation result object containing the ID of the created document.
|
|
2019
2028
|
*
|
|
2020
|
-
* @param
|
|
2029
|
+
* @param document - Document to create
|
|
2030
|
+
* @param options - Mutation options
|
|
2021
2031
|
*/
|
|
2022
|
-
|
|
2032
|
+
create<R extends Record<string, Any> = Record<string, Any>>(
|
|
2033
|
+
document: SanityDocumentStub<R>,
|
|
2034
|
+
options: AllDocumentIdsMutationOptions,
|
|
2035
|
+
): Promise<MultipleMutationResult>
|
|
2036
|
+
/**
|
|
2037
|
+
* Create a document. Requires a `_type` property. If no `_id` is provided, it will be generated by the database.
|
|
2038
|
+
* Returns a promise that resolves to the created document.
|
|
2039
|
+
*
|
|
2040
|
+
* @param document - Document to create
|
|
2041
|
+
* @param options - Mutation options
|
|
2042
|
+
*/
|
|
2043
|
+
create<R extends Record<string, Any> = Record<string, Any>>(
|
|
2044
|
+
document: SanityDocumentStub<R>,
|
|
2045
|
+
options?: BaseMutationOptions,
|
|
2046
|
+
): Promise<SanityDocument<R>>
|
|
2047
|
+
/**
|
|
2048
|
+
* Create a document if no document with the same ID already exists.
|
|
2049
|
+
* Returns a promise that resolves to the created document.
|
|
2050
|
+
*
|
|
2051
|
+
* @param document - Document to create
|
|
2052
|
+
* @param options - Mutation options
|
|
2053
|
+
*/
|
|
2054
|
+
createIfNotExists<R extends Record<string, Any> = Record<string, Any>>(
|
|
2055
|
+
document: IdentifiedSanityDocumentStub<R>,
|
|
2023
2056
|
options: FirstDocumentMutationOptions,
|
|
2024
|
-
):
|
|
2057
|
+
): Promise<SanityDocument<R>>
|
|
2025
2058
|
/**
|
|
2026
|
-
*
|
|
2059
|
+
* Create a document if no document with the same ID already exists.
|
|
2060
|
+
* Returns a promise that resolves to an array containing the created document.
|
|
2027
2061
|
*
|
|
2028
|
-
* @param
|
|
2062
|
+
* @param document - Document to create
|
|
2063
|
+
* @param options - Mutation options
|
|
2029
2064
|
*/
|
|
2030
|
-
|
|
2065
|
+
createIfNotExists<R extends Record<string, Any> = Record<string, Any>>(
|
|
2066
|
+
document: IdentifiedSanityDocumentStub<R>,
|
|
2031
2067
|
options: AllDocumentsMutationOptions,
|
|
2032
|
-
):
|
|
2068
|
+
): Promise<SanityDocument<R>[]>
|
|
2033
2069
|
/**
|
|
2034
|
-
*
|
|
2070
|
+
* Create a document if no document with the same ID already exists.
|
|
2071
|
+
* Returns a promise that resolves to a mutation result object containing the ID of the created document.
|
|
2035
2072
|
*
|
|
2036
|
-
* @param
|
|
2073
|
+
* @param document - Document to create
|
|
2074
|
+
* @param options - Mutation options
|
|
2037
2075
|
*/
|
|
2038
|
-
|
|
2076
|
+
createIfNotExists<R extends Record<string, Any> = Record<string, Any>>(
|
|
2077
|
+
document: IdentifiedSanityDocumentStub<R>,
|
|
2078
|
+
options: FirstDocumentIdMutationOptions,
|
|
2079
|
+
): Promise<SingleMutationResult>
|
|
2039
2080
|
/**
|
|
2040
|
-
*
|
|
2081
|
+
* Create a document if no document with the same ID already exists.
|
|
2082
|
+
* Returns a promise that resolves to a mutation result object containing the ID of the created document.
|
|
2041
2083
|
*
|
|
2042
|
-
* @param
|
|
2084
|
+
* @param document - Document to create
|
|
2085
|
+
* @param options - Mutation options
|
|
2043
2086
|
*/
|
|
2044
|
-
|
|
2087
|
+
createIfNotExists<R extends Record<string, Any> = Record<string, Any>>(
|
|
2088
|
+
document: IdentifiedSanityDocumentStub<R>,
|
|
2089
|
+
options: AllDocumentIdsMutationOptions,
|
|
2090
|
+
): Promise<MultipleMutationResult>
|
|
2045
2091
|
/**
|
|
2046
|
-
*
|
|
2092
|
+
* Create a document if no document with the same ID already exists.
|
|
2093
|
+
* Returns a promise that resolves to the created document.
|
|
2047
2094
|
*
|
|
2048
|
-
* @param
|
|
2095
|
+
* @param document - Document to create
|
|
2096
|
+
* @param options - Mutation options
|
|
2049
2097
|
*/
|
|
2050
|
-
|
|
2098
|
+
createIfNotExists<R extends Record<string, Any> = Record<string, Any>>(
|
|
2099
|
+
document: IdentifiedSanityDocumentStub<R>,
|
|
2051
2100
|
options?: BaseMutationOptions,
|
|
2052
|
-
):
|
|
2053
|
-
}
|
|
2054
|
-
|
|
2055
|
-
/** @public */
|
|
2056
|
-
export declare type ObservablePatchBuilder = (patch: ObservablePatch) => ObservablePatch
|
|
2057
|
-
|
|
2058
|
-
/** @internal */
|
|
2059
|
-
export declare class ObservableProjectsClient {
|
|
2060
|
-
#private
|
|
2061
|
-
constructor(client: INTERNAL_DO_NOT_USE_DIRECTLY_ObservableSanityClient, httpRequest: HttpRequest)
|
|
2101
|
+
): Promise<SanityDocument<R>>
|
|
2062
2102
|
/**
|
|
2063
|
-
*
|
|
2103
|
+
* Create a document if it does not exist, or replace a document with the same document ID
|
|
2104
|
+
* Returns a promise that resolves to the created document.
|
|
2064
2105
|
*
|
|
2065
|
-
* @param
|
|
2066
|
-
* @param options
|
|
2106
|
+
* @param document - Document to either create or replace
|
|
2107
|
+
* @param options - Mutation options
|
|
2067
2108
|
*/
|
|
2068
|
-
|
|
2069
|
-
|
|
2109
|
+
createOrReplace<R extends Record<string, Any> = Record<string, Any>>(
|
|
2110
|
+
document: IdentifiedSanityDocumentStub<R>,
|
|
2111
|
+
options: FirstDocumentMutationOptions,
|
|
2112
|
+
): Promise<SanityDocument<R>>
|
|
2070
2113
|
/**
|
|
2071
|
-
*
|
|
2114
|
+
* Create a document if it does not exist, or replace a document with the same document ID
|
|
2115
|
+
* Returns a promise that resolves to an array containing the created document.
|
|
2072
2116
|
*
|
|
2073
|
-
* @param
|
|
2117
|
+
* @param document - Document to either create or replace
|
|
2118
|
+
* @param options - Mutation options
|
|
2074
2119
|
*/
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
* @deprecated -- Use `import type {ObservableSanityClient} from '@sanity/client'` instead
|
|
2080
|
-
* @public
|
|
2081
|
-
*/
|
|
2082
|
-
export declare type ObservableSanityClient = never
|
|
2083
|
-
|
|
2084
|
-
/** @public */
|
|
2085
|
-
export declare class ObservableSanityStegaClient extends INTERNAL_DO_NOT_USE_DIRECTLY_ObservableSanityClient {
|
|
2086
|
-
#private
|
|
2087
|
-
private stegaConfig
|
|
2088
|
-
constructor(httpRequest: HttpRequest, config?: ClientStegaConfig)
|
|
2120
|
+
createOrReplace<R extends Record<string, Any> = Record<string, Any>>(
|
|
2121
|
+
document: IdentifiedSanityDocumentStub<R>,
|
|
2122
|
+
options: AllDocumentsMutationOptions,
|
|
2123
|
+
): Promise<SanityDocument<R>[]>
|
|
2089
2124
|
/**
|
|
2090
|
-
*
|
|
2125
|
+
* Create a document if it does not exist, or replace a document with the same document ID
|
|
2126
|
+
* Returns a promise that resolves to a mutation result object containing the ID of the created document.
|
|
2127
|
+
*
|
|
2128
|
+
* @param document - Document to either create or replace
|
|
2129
|
+
* @param options - Mutation options
|
|
2130
|
+
*/
|
|
2131
|
+
createOrReplace<R extends Record<string, Any> = Record<string, Any>>(
|
|
2132
|
+
document: IdentifiedSanityDocumentStub<R>,
|
|
2133
|
+
options: FirstDocumentIdMutationOptions,
|
|
2134
|
+
): Promise<SingleMutationResult>
|
|
2135
|
+
/**
|
|
2136
|
+
* Create a document if it does not exist, or replace a document with the same document ID
|
|
2137
|
+
* Returns a promise that resolves to a mutation result object containing the created document ID.
|
|
2138
|
+
*
|
|
2139
|
+
* @param document - Document to either create or replace
|
|
2140
|
+
* @param options - Mutation options
|
|
2091
2141
|
*/
|
|
2092
|
-
|
|
2142
|
+
createOrReplace<R extends Record<string, Any> = Record<string, Any>>(
|
|
2143
|
+
document: IdentifiedSanityDocumentStub<R>,
|
|
2144
|
+
options: AllDocumentIdsMutationOptions,
|
|
2145
|
+
): Promise<MultipleMutationResult>
|
|
2093
2146
|
/**
|
|
2094
|
-
*
|
|
2147
|
+
* Create a document if it does not exist, or replace a document with the same document ID
|
|
2148
|
+
* Returns a promise that resolves to the created document.
|
|
2149
|
+
*
|
|
2150
|
+
* @param document - Document to either create or replace
|
|
2151
|
+
* @param options - Mutation options
|
|
2095
2152
|
*/
|
|
2096
|
-
|
|
2153
|
+
createOrReplace<R extends Record<string, Any> = Record<string, Any>>(
|
|
2154
|
+
document: IdentifiedSanityDocumentStub<R>,
|
|
2155
|
+
options?: BaseMutationOptions,
|
|
2156
|
+
): Promise<SanityDocument<R>>
|
|
2097
2157
|
/**
|
|
2098
|
-
*
|
|
2158
|
+
* Deletes a document with the given document ID.
|
|
2159
|
+
* Returns a promise that resolves to the deleted document.
|
|
2160
|
+
*
|
|
2161
|
+
* @param id - Document ID to delete
|
|
2162
|
+
* @param options - Options for the mutation
|
|
2099
2163
|
*/
|
|
2100
|
-
|
|
2164
|
+
delete<R extends Record<string, Any> = Record<string, Any>>(
|
|
2165
|
+
id: string,
|
|
2166
|
+
options: FirstDocumentMutationOptions,
|
|
2167
|
+
): Promise<SanityDocument<R>>
|
|
2101
2168
|
/**
|
|
2102
|
-
*
|
|
2169
|
+
* Deletes a document with the given document ID.
|
|
2170
|
+
* Returns a promise that resolves to an array containing the deleted document.
|
|
2103
2171
|
*
|
|
2104
|
-
* @param
|
|
2172
|
+
* @param id - Document ID to delete
|
|
2173
|
+
* @param options - Options for the mutation
|
|
2105
2174
|
*/
|
|
2106
|
-
|
|
2175
|
+
delete<R extends Record<string, Any> = Record<string, Any>>(
|
|
2176
|
+
id: string,
|
|
2177
|
+
options: AllDocumentsMutationOptions,
|
|
2178
|
+
): Promise<SanityDocument<R>[]>
|
|
2107
2179
|
/**
|
|
2108
|
-
*
|
|
2180
|
+
* Deletes a document with the given document ID.
|
|
2181
|
+
* Returns a promise that resolves to a mutation result object containing the deleted document ID.
|
|
2109
2182
|
*
|
|
2110
|
-
* @param
|
|
2183
|
+
* @param id - Document ID to delete
|
|
2184
|
+
* @param options - Options for the mutation
|
|
2111
2185
|
*/
|
|
2112
|
-
|
|
2186
|
+
delete(id: string, options: FirstDocumentIdMutationOptions): Promise<SingleMutationResult>
|
|
2113
2187
|
/**
|
|
2114
|
-
*
|
|
2188
|
+
* Deletes a document with the given document ID.
|
|
2189
|
+
* Returns a promise that resolves to a mutation result object containing the deleted document ID.
|
|
2115
2190
|
*
|
|
2116
|
-
* @param
|
|
2117
|
-
* @param
|
|
2191
|
+
* @param id - Document ID to delete
|
|
2192
|
+
* @param options - Options for the mutation
|
|
2118
2193
|
*/
|
|
2119
|
-
|
|
2194
|
+
delete(id: string, options: AllDocumentIdsMutationOptions): Promise<MultipleMutationResult>
|
|
2120
2195
|
/**
|
|
2121
|
-
*
|
|
2196
|
+
* Deletes a document with the given document ID.
|
|
2197
|
+
* Returns a promise that resolves to the deleted document.
|
|
2122
2198
|
*
|
|
2123
|
-
* @param
|
|
2124
|
-
* @param
|
|
2125
|
-
* @param options - Request options
|
|
2199
|
+
* @param id - Document ID to delete
|
|
2200
|
+
* @param options - Options for the mutation
|
|
2126
2201
|
*/
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
|
|
2131
|
-
): Observable<R>
|
|
2202
|
+
delete<R extends Record<string, Any> = Record<string, Any>>(
|
|
2203
|
+
id: string,
|
|
2204
|
+
options?: BaseMutationOptions,
|
|
2205
|
+
): Promise<SanityDocument<R>>
|
|
2132
2206
|
/**
|
|
2133
|
-
*
|
|
2207
|
+
* Deletes one or more documents matching the given query or document ID.
|
|
2208
|
+
* Returns a promise that resolves to first deleted document.
|
|
2134
2209
|
*
|
|
2135
|
-
* @param
|
|
2136
|
-
* @param
|
|
2137
|
-
* @param options - Request options
|
|
2210
|
+
* @param selection - An object with either an `id` or `query` key defining what to delete
|
|
2211
|
+
* @param options - Options for the mutation
|
|
2138
2212
|
*/
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
): Observable<RawQueryResponse<R>>
|
|
2144
|
-
}
|
|
2145
|
-
|
|
2146
|
-
/** @public */
|
|
2147
|
-
export declare class ObservableTransaction extends BaseTransaction {
|
|
2148
|
-
#private
|
|
2149
|
-
constructor(
|
|
2150
|
-
operations?: Mutation[],
|
|
2151
|
-
client?: INTERNAL_DO_NOT_USE_DIRECTLY_ObservableSanityClient,
|
|
2152
|
-
transactionId?: string,
|
|
2153
|
-
)
|
|
2213
|
+
delete<R extends Record<string, Any> = Record<string, Any>>(
|
|
2214
|
+
selection: MutationSelection,
|
|
2215
|
+
options: FirstDocumentMutationOptions,
|
|
2216
|
+
): Promise<SanityDocument<R>>
|
|
2154
2217
|
/**
|
|
2155
|
-
*
|
|
2218
|
+
* Deletes one or more documents matching the given query or document ID.
|
|
2219
|
+
* Returns a promise that resolves to an array containing the deleted documents.
|
|
2220
|
+
*
|
|
2221
|
+
* @param selection - An object with either an `id` or `query` key defining what to delete
|
|
2222
|
+
* @param options - Options for the mutation
|
|
2156
2223
|
*/
|
|
2157
|
-
|
|
2224
|
+
delete<R extends Record<string, Any> = Record<string, Any>>(
|
|
2225
|
+
selection: MutationSelection,
|
|
2226
|
+
options: AllDocumentsMutationOptions,
|
|
2227
|
+
): Promise<SanityDocument<R>[]>
|
|
2158
2228
|
/**
|
|
2159
|
-
*
|
|
2229
|
+
* Deletes one or more documents matching the given query or document ID.
|
|
2230
|
+
* Returns a promise that resolves to a mutation result object containing the ID of the first deleted document.
|
|
2160
2231
|
*
|
|
2161
|
-
* @param
|
|
2232
|
+
* @param selection - An object with either an `id` or `query` key defining what to delete
|
|
2233
|
+
* @param options - Options for the mutation
|
|
2162
2234
|
*/
|
|
2163
|
-
|
|
2164
|
-
|
|
2165
|
-
|
|
2235
|
+
delete(
|
|
2236
|
+
selection: MutationSelection,
|
|
2237
|
+
options: FirstDocumentIdMutationOptions,
|
|
2238
|
+
): Promise<SingleMutationResult>
|
|
2166
2239
|
/**
|
|
2167
|
-
*
|
|
2240
|
+
* Deletes one or more documents matching the given query or document ID.
|
|
2241
|
+
* Returns a promise that resolves to a mutation result object containing the document IDs that were deleted.
|
|
2168
2242
|
*
|
|
2169
|
-
* @param
|
|
2243
|
+
* @param selection - An object with either an `id` or `query` key defining what to delete
|
|
2244
|
+
* @param options - Options for the mutation
|
|
2170
2245
|
*/
|
|
2171
|
-
|
|
2172
|
-
|
|
2173
|
-
|
|
2246
|
+
delete(
|
|
2247
|
+
selection: MutationSelection,
|
|
2248
|
+
options: AllDocumentIdsMutationOptions,
|
|
2249
|
+
): Promise<MultipleMutationResult>
|
|
2174
2250
|
/**
|
|
2175
|
-
*
|
|
2251
|
+
* Deletes one or more documents matching the given query or document ID.
|
|
2252
|
+
* Returns a promise that resolves to first deleted document.
|
|
2176
2253
|
*
|
|
2177
|
-
* @param
|
|
2254
|
+
* @param selection - An object with either an `id` or `query` key defining what to delete
|
|
2255
|
+
* @param options - Options for the mutation
|
|
2178
2256
|
*/
|
|
2179
|
-
|
|
2257
|
+
delete<R extends Record<string, Any> = Record<string, Any>>(
|
|
2258
|
+
selection: MutationSelection,
|
|
2259
|
+
options?: BaseMutationOptions,
|
|
2260
|
+
): Promise<SanityDocument<R>>
|
|
2180
2261
|
/**
|
|
2181
|
-
*
|
|
2262
|
+
* Perform mutation operations against the configured dataset
|
|
2263
|
+
* Returns a promise that resolves to the first mutated document.
|
|
2182
2264
|
*
|
|
2183
|
-
* @param
|
|
2265
|
+
* @param operations - Mutation operations to execute
|
|
2266
|
+
* @param options - Mutation options
|
|
2184
2267
|
*/
|
|
2185
|
-
|
|
2268
|
+
mutate<R extends Record<string, Any> = Record<string, Any>>(
|
|
2269
|
+
operations: Mutation<R>[] | Patch | Transaction,
|
|
2270
|
+
options: FirstDocumentMutationOptions,
|
|
2271
|
+
): Promise<SanityDocument<R>>
|
|
2186
2272
|
/**
|
|
2187
|
-
*
|
|
2273
|
+
* Perform mutation operations against the configured dataset.
|
|
2274
|
+
* Returns a promise that resolves to an array of the mutated documents.
|
|
2188
2275
|
*
|
|
2189
|
-
* @param
|
|
2276
|
+
* @param operations - Mutation operations to execute
|
|
2277
|
+
* @param options - Mutation options
|
|
2190
2278
|
*/
|
|
2191
|
-
|
|
2279
|
+
mutate<R extends Record<string, Any> = Record<string, Any>>(
|
|
2280
|
+
operations: Mutation<R>[] | Patch | Transaction,
|
|
2281
|
+
options: AllDocumentsMutationOptions,
|
|
2282
|
+
): Promise<SanityDocument<R>[]>
|
|
2192
2283
|
/**
|
|
2193
|
-
*
|
|
2194
|
-
*
|
|
2284
|
+
* Perform mutation operations against the configured dataset
|
|
2285
|
+
* Returns a promise that resolves to a mutation result object containing the document ID of the first mutated document.
|
|
2195
2286
|
*
|
|
2196
|
-
* @param
|
|
2197
|
-
* @param
|
|
2287
|
+
* @param operations - Mutation operations to execute
|
|
2288
|
+
* @param options - Mutation options
|
|
2198
2289
|
*/
|
|
2199
|
-
|
|
2290
|
+
mutate<R extends Record<string, Any> = Record<string, Any>>(
|
|
2291
|
+
operations: Mutation<R>[] | Patch | Transaction,
|
|
2292
|
+
options: FirstDocumentIdMutationOptions,
|
|
2293
|
+
): Promise<SingleMutationResult>
|
|
2200
2294
|
/**
|
|
2201
|
-
*
|
|
2202
|
-
*
|
|
2295
|
+
* Perform mutation operations against the configured dataset
|
|
2296
|
+
* Returns a promise that resolves to a mutation result object containing the mutated document IDs.
|
|
2203
2297
|
*
|
|
2204
|
-
* @param
|
|
2298
|
+
* @param operations - Mutation operations to execute
|
|
2299
|
+
* @param options - Mutation options
|
|
2205
2300
|
*/
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
export declare class ObservableUsersClient {
|
|
2211
|
-
#private
|
|
2212
|
-
constructor(client: INTERNAL_DO_NOT_USE_DIRECTLY_ObservableSanityClient, httpRequest: HttpRequest)
|
|
2301
|
+
mutate<R extends Record<string, Any>>(
|
|
2302
|
+
operations: Mutation<R>[] | Patch | Transaction,
|
|
2303
|
+
options: AllDocumentIdsMutationOptions,
|
|
2304
|
+
): Promise<MultipleMutationResult>
|
|
2213
2305
|
/**
|
|
2214
|
-
*
|
|
2306
|
+
* Perform mutation operations against the configured dataset
|
|
2307
|
+
* Returns a promise that resolves to the first mutated document.
|
|
2215
2308
|
*
|
|
2216
|
-
* @param
|
|
2309
|
+
* @param operations - Mutation operations to execute
|
|
2310
|
+
* @param options - Mutation options
|
|
2217
2311
|
*/
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
/** @public */
|
|
2224
|
-
export declare class Patch extends BasePatch {
|
|
2225
|
-
#private
|
|
2226
|
-
constructor(
|
|
2227
|
-
selection: PatchSelection,
|
|
2228
|
-
operations?: PatchOperations,
|
|
2229
|
-
client?: INTERNAL_DO_NOT_USE_DIRECTLY_SanityClient,
|
|
2230
|
-
)
|
|
2312
|
+
mutate<R extends Record<string, Any> = Record<string, Any>>(
|
|
2313
|
+
operations: Mutation<R>[] | Patch | Transaction,
|
|
2314
|
+
options?: BaseMutationOptions,
|
|
2315
|
+
): Promise<SanityDocument<R>>
|
|
2231
2316
|
/**
|
|
2232
|
-
*
|
|
2317
|
+
* Create a new buildable patch of operations to perform
|
|
2318
|
+
*
|
|
2319
|
+
* @param documentId - Document ID to patch
|
|
2320
|
+
* @param operations - Optional object of patch operations to initialize the patch instance with
|
|
2321
|
+
* @returns Patch instance - call `.commit()` to perform the operations defined
|
|
2233
2322
|
*/
|
|
2234
|
-
|
|
2323
|
+
patch(documentId: string, operations?: PatchOperations): Patch
|
|
2235
2324
|
/**
|
|
2236
|
-
*
|
|
2325
|
+
* Create a new buildable patch of operations to perform
|
|
2237
2326
|
*
|
|
2238
|
-
* @param
|
|
2327
|
+
* @param documentIds - Array of document IDs to patch
|
|
2328
|
+
* @param operations - Optional object of patch operations to initialize the patch instance with
|
|
2329
|
+
* @returns Patch instance - call `.commit()` to perform the operations defined
|
|
2239
2330
|
*/
|
|
2240
|
-
|
|
2241
|
-
options: FirstDocumentMutationOptions,
|
|
2242
|
-
): Promise<SanityDocument<R>>
|
|
2331
|
+
patch(documentIds: string[], operations?: PatchOperations): Patch
|
|
2243
2332
|
/**
|
|
2244
|
-
*
|
|
2333
|
+
* Create a new buildable patch of operations to perform
|
|
2245
2334
|
*
|
|
2246
|
-
* @param
|
|
2335
|
+
* @param selection - An object with `query` and optional `params`, defining which document(s) to patch
|
|
2336
|
+
* @param operations - Optional object of patch operations to initialize the patch instance with
|
|
2337
|
+
* @returns Patch instance - call `.commit()` to perform the operations defined
|
|
2247
2338
|
*/
|
|
2248
|
-
|
|
2249
|
-
options: AllDocumentsMutationOptions,
|
|
2250
|
-
): Promise<SanityDocument<R>[]>
|
|
2339
|
+
patch(selection: MutationSelection, operations?: PatchOperations): Patch
|
|
2251
2340
|
/**
|
|
2252
|
-
*
|
|
2341
|
+
* Create a new transaction of mutations
|
|
2253
2342
|
*
|
|
2254
|
-
* @param
|
|
2343
|
+
* @param operations - Optional array of mutation operations to initialize the transaction instance with
|
|
2255
2344
|
*/
|
|
2256
|
-
|
|
2345
|
+
transaction<R extends Record<string, Any> = Record<string, Any>>(
|
|
2346
|
+
operations?: Mutation<R>[],
|
|
2347
|
+
): Transaction
|
|
2257
2348
|
/**
|
|
2258
|
-
*
|
|
2349
|
+
* Perform a request against the Sanity API
|
|
2350
|
+
* NOTE: Only use this for Sanity API endpoints, not for your own APIs!
|
|
2259
2351
|
*
|
|
2260
|
-
* @param options -
|
|
2352
|
+
* @param options - Request options
|
|
2353
|
+
* @returns Promise resolving to the response body
|
|
2261
2354
|
*/
|
|
2262
|
-
|
|
2355
|
+
request<R = Any>(options: RawRequestOptions): Promise<R>
|
|
2263
2356
|
/**
|
|
2264
|
-
*
|
|
2357
|
+
* Perform an HTTP request a `/data` sub-endpoint
|
|
2358
|
+
* NOTE: Considered internal, thus marked as deprecated. Use `request` instead.
|
|
2265
2359
|
*
|
|
2266
|
-
* @
|
|
2360
|
+
* @deprecated - Use `request()` or your own HTTP library instead
|
|
2361
|
+
* @param endpoint - Endpoint to hit (mutate, query etc)
|
|
2362
|
+
* @param body - Request body
|
|
2363
|
+
* @param options - Request options
|
|
2364
|
+
* @internal
|
|
2267
2365
|
*/
|
|
2268
|
-
|
|
2269
|
-
options?: BaseMutationOptions,
|
|
2270
|
-
): Promise<SanityDocument<R>>
|
|
2271
|
-
}
|
|
2272
|
-
|
|
2273
|
-
/** @public */
|
|
2274
|
-
export declare type PatchBuilder = (patch: Patch) => Patch
|
|
2275
|
-
|
|
2276
|
-
/** @internal */
|
|
2277
|
-
export declare type PatchMutationOperation = PatchOperations & MutationSelection
|
|
2278
|
-
|
|
2279
|
-
/** @internal */
|
|
2280
|
-
export declare interface PatchOperations {
|
|
2281
|
-
set?: {
|
|
2282
|
-
[key: string]: Any
|
|
2283
|
-
}
|
|
2284
|
-
setIfMissing?: {
|
|
2285
|
-
[key: string]: Any
|
|
2286
|
-
}
|
|
2287
|
-
diffMatchPatch?: {
|
|
2288
|
-
[key: string]: Any
|
|
2289
|
-
}
|
|
2290
|
-
unset?: string[]
|
|
2291
|
-
inc?: {
|
|
2292
|
-
[key: string]: number
|
|
2293
|
-
}
|
|
2294
|
-
dec?: {
|
|
2295
|
-
[key: string]: number
|
|
2296
|
-
}
|
|
2297
|
-
insert?: InsertPatch
|
|
2298
|
-
ifRevisionID?: string
|
|
2299
|
-
}
|
|
2300
|
-
|
|
2301
|
-
/** @internal */
|
|
2302
|
-
export declare type PatchSelection = string | string[] | MutationSelection
|
|
2303
|
-
|
|
2304
|
-
/** @public */
|
|
2305
|
-
declare interface ProgressEvent_2 {
|
|
2306
|
-
type: 'progress'
|
|
2307
|
-
stage: 'upload' | 'download'
|
|
2308
|
-
percent: number
|
|
2309
|
-
total?: number
|
|
2310
|
-
loaded?: number
|
|
2311
|
-
lengthComputable: boolean
|
|
2312
|
-
}
|
|
2313
|
-
export {ProgressEvent_2 as ProgressEvent}
|
|
2314
|
-
|
|
2315
|
-
/** @internal */
|
|
2316
|
-
export declare class ProjectsClient {
|
|
2317
|
-
#private
|
|
2318
|
-
constructor(client: INTERNAL_DO_NOT_USE_DIRECTLY_SanityClient, httpRequest: HttpRequest)
|
|
2366
|
+
dataRequest(endpoint: string, body: unknown, options?: BaseMutationOptions): Promise<Any>
|
|
2319
2367
|
/**
|
|
2320
|
-
*
|
|
2368
|
+
* Get a Sanity API URL for the URI provided
|
|
2321
2369
|
*
|
|
2322
|
-
* @param
|
|
2323
|
-
* @param
|
|
2370
|
+
* @param uri - URI/path to build URL for
|
|
2371
|
+
* @param canUseCdn - Whether or not to allow using the API CDN for this route
|
|
2324
2372
|
*/
|
|
2325
|
-
|
|
2326
|
-
list(options?: {includeMembers?: false}): Promise<Omit<SanityProject, 'members'>[]>
|
|
2373
|
+
getUrl(uri: string, canUseCdn?: boolean): string
|
|
2327
2374
|
/**
|
|
2328
|
-
*
|
|
2375
|
+
* Get a Sanity API URL for the data operation and path provided
|
|
2329
2376
|
*
|
|
2330
|
-
* @param
|
|
2377
|
+
* @param operation - Data operation (eg `query`, `mutate`, `listen` or similar)
|
|
2378
|
+
* @param path - Path to append after the operation
|
|
2331
2379
|
*/
|
|
2332
|
-
|
|
2333
|
-
}
|
|
2334
|
-
|
|
2335
|
-
/** @public */
|
|
2336
|
-
export declare type QueryParams = {
|
|
2337
|
-
[key: string]: Any
|
|
2338
|
-
}
|
|
2339
|
-
|
|
2340
|
-
/** @public */
|
|
2341
|
-
export declare interface RawQueryResponse<R> {
|
|
2342
|
-
query: string
|
|
2343
|
-
ms: number
|
|
2344
|
-
result: R
|
|
2345
|
-
resultSourceMap?: ContentSourceMap
|
|
2346
|
-
}
|
|
2347
|
-
|
|
2348
|
-
/** @internal */
|
|
2349
|
-
export declare interface RawRequestOptions {
|
|
2350
|
-
url?: string
|
|
2351
|
-
uri?: string
|
|
2352
|
-
method?: string
|
|
2353
|
-
token?: string
|
|
2354
|
-
json?: boolean
|
|
2355
|
-
tag?: string
|
|
2356
|
-
useGlobalApi?: boolean
|
|
2357
|
-
withCredentials?: boolean
|
|
2358
|
-
query?: {
|
|
2359
|
-
[key: string]: string | string[]
|
|
2360
|
-
}
|
|
2361
|
-
headers?: {
|
|
2362
|
-
[key: string]: string
|
|
2363
|
-
}
|
|
2364
|
-
timeout?: number
|
|
2365
|
-
proxy?: string
|
|
2366
|
-
body?: Any
|
|
2367
|
-
maxRedirects?: number
|
|
2368
|
-
}
|
|
2369
|
-
|
|
2370
|
-
/**
|
|
2371
|
-
* The listener has been disconnected, and a reconnect attempt is scheduled.
|
|
2372
|
-
*
|
|
2373
|
-
* @public
|
|
2374
|
-
*/
|
|
2375
|
-
export declare type ReconnectEvent = {
|
|
2376
|
-
type: 'reconnect'
|
|
2377
|
-
}
|
|
2378
|
-
|
|
2379
|
-
/** @public */
|
|
2380
|
-
export declare const requester: Requester
|
|
2381
|
-
|
|
2382
|
-
/**
|
|
2383
|
-
* Options for the native `fetch` feature, used by the Next.js app-router
|
|
2384
|
-
* @public
|
|
2385
|
-
*/
|
|
2386
|
-
export declare interface RequestFetchOptions<T = 'next'> {
|
|
2387
|
-
cache?: RequestInit['cache']
|
|
2388
|
-
next?: T extends keyof RequestInit ? RequestInit[T] : never
|
|
2389
|
-
}
|
|
2390
|
-
|
|
2391
|
-
/** @internal */
|
|
2392
|
-
export declare interface RequestObservableOptions extends Omit<RequestOptions, 'url'> {
|
|
2393
|
-
url?: string
|
|
2394
|
-
uri?: string
|
|
2395
|
-
canUseCdn?: boolean
|
|
2396
|
-
useCdn?: boolean
|
|
2397
|
-
tag?: string
|
|
2398
|
-
resultSourceMap?: boolean | 'withKeyArraySelector'
|
|
2399
|
-
perspective?: ClientPerspective
|
|
2400
|
-
}
|
|
2401
|
-
|
|
2402
|
-
/** @public */
|
|
2403
|
-
export declare interface RequestOptions {
|
|
2404
|
-
timeout?: number
|
|
2405
|
-
token?: string
|
|
2406
|
-
tag?: string
|
|
2407
|
-
headers?: Record<string, string>
|
|
2408
|
-
method?: string
|
|
2409
|
-
query?: Any
|
|
2410
|
-
body?: Any
|
|
2411
|
-
signal?: AbortSignal
|
|
2412
|
-
}
|
|
2413
|
-
|
|
2414
|
-
/** @alpha */
|
|
2415
|
-
export declare type ResolveStudioUrl = (
|
|
2416
|
-
sourceDocument: ContentSourceMapDocuments[number],
|
|
2417
|
-
) => StudioUrl
|
|
2418
|
-
|
|
2419
|
-
/** @public */
|
|
2420
|
-
export declare interface ResponseEvent<T = unknown> {
|
|
2421
|
-
type: 'response'
|
|
2422
|
-
body: T
|
|
2423
|
-
url: string
|
|
2424
|
-
method: string
|
|
2425
|
-
statusCode: number
|
|
2426
|
-
statusMessage?: string
|
|
2427
|
-
headers: Record<string, string>
|
|
2428
|
-
}
|
|
2429
|
-
|
|
2430
|
-
/** @public */
|
|
2431
|
-
export declare interface ResponseQueryOptions<T = 'next'> extends RequestOptions {
|
|
2432
|
-
perspective?: ClientPerspective
|
|
2433
|
-
resultSourceMap?: boolean | 'withKeyArraySelector'
|
|
2434
|
-
cache?: RequestInit['cache']
|
|
2435
|
-
next?: T extends keyof RequestInit ? RequestInit[T] : never
|
|
2436
|
-
useCdn?: boolean
|
|
2437
|
-
}
|
|
2438
|
-
|
|
2439
|
-
/** @internal */
|
|
2440
|
-
export declare interface SanityAssetDocument extends SanityDocument {
|
|
2441
|
-
url: string
|
|
2442
|
-
path: string
|
|
2443
|
-
size: number
|
|
2444
|
-
assetId: string
|
|
2445
|
-
mimeType: string
|
|
2446
|
-
sha1hash: string
|
|
2447
|
-
extension: string
|
|
2448
|
-
uploadId?: string
|
|
2449
|
-
originalFilename?: string
|
|
2380
|
+
getDataUrl(operation: string, path?: string): string
|
|
2450
2381
|
}
|
|
2451
2382
|
|
|
2452
|
-
/**
|
|
2453
|
-
* @deprecated -- Use `import type {SanityClient} from '@sanity/client'` instead
|
|
2454
|
-
* @public
|
|
2455
|
-
*/
|
|
2456
|
-
export declare type SanityClient = never
|
|
2457
|
-
|
|
2458
2383
|
/** @internal */
|
|
2459
2384
|
export declare type SanityDocument<T extends Record<string, Any> = Record<string, Any>> = {
|
|
2460
2385
|
[P in keyof T]: T[P]
|
|
@@ -2552,72 +2477,6 @@ export declare interface SanityReference {
|
|
|
2552
2477
|
_ref: string
|
|
2553
2478
|
}
|
|
2554
2479
|
|
|
2555
|
-
/** @public */
|
|
2556
|
-
export declare class SanityStegaClient extends INTERNAL_DO_NOT_USE_DIRECTLY_SanityClient {
|
|
2557
|
-
#private
|
|
2558
|
-
/**
|
|
2559
|
-
* Observable version of the Sanity client, with the same configuration as the promise-based one
|
|
2560
|
-
*/
|
|
2561
|
-
observable: ObservableSanityStegaClient
|
|
2562
|
-
private stegaConfig
|
|
2563
|
-
constructor(httpRequest: HttpRequest, config?: ClientStegaConfig)
|
|
2564
|
-
/**
|
|
2565
|
-
* Clone the client - returns a new instance
|
|
2566
|
-
*/
|
|
2567
|
-
clone(): SanityStegaClient
|
|
2568
|
-
/**
|
|
2569
|
-
* Returns the current client configuration
|
|
2570
|
-
*/
|
|
2571
|
-
config(): InitializedClientStegaConfig
|
|
2572
|
-
/**
|
|
2573
|
-
* Reconfigure the client. Note that this _mutates_ the current client.
|
|
2574
|
-
*/
|
|
2575
|
-
config(newConfig?: Partial<ClientStegaConfig>): this
|
|
2576
|
-
/**
|
|
2577
|
-
* Clone the client with a new (partial) configuration.
|
|
2578
|
-
*
|
|
2579
|
-
* @param newConfig - New client configuration properties, shallowly merged with existing configuration
|
|
2580
|
-
*/
|
|
2581
|
-
withConfig(newConfig?: Partial<ClientStegaConfig>): SanityStegaClient
|
|
2582
|
-
/**
|
|
2583
|
-
* Perform a GROQ-query against the configured dataset.
|
|
2584
|
-
*
|
|
2585
|
-
* @param query - GROQ-query to perform
|
|
2586
|
-
*/
|
|
2587
|
-
fetch<R = Any>(query: string): Promise<R>
|
|
2588
|
-
/**
|
|
2589
|
-
* Perform a GROQ-query against the configured dataset.
|
|
2590
|
-
*
|
|
2591
|
-
* @param query - GROQ-query to perform
|
|
2592
|
-
* @param params - Optional query parameters
|
|
2593
|
-
*/
|
|
2594
|
-
fetch<R = Any, Q = QueryParams>(query: string, params: Q): Promise<R>
|
|
2595
|
-
/**
|
|
2596
|
-
* Perform a GROQ-query against the configured dataset.
|
|
2597
|
-
*
|
|
2598
|
-
* @param query - GROQ-query to perform
|
|
2599
|
-
* @param params - Optional query parameters
|
|
2600
|
-
* @param options - Request options
|
|
2601
|
-
*/
|
|
2602
|
-
fetch<R = Any, Q = QueryParams>(
|
|
2603
|
-
query: string,
|
|
2604
|
-
params: Q | undefined,
|
|
2605
|
-
options: FilteredResponseQueryOptions,
|
|
2606
|
-
): Promise<R>
|
|
2607
|
-
/**
|
|
2608
|
-
* Perform a GROQ-query against the configured dataset.
|
|
2609
|
-
*
|
|
2610
|
-
* @param query - GROQ-query to perform
|
|
2611
|
-
* @param params - Optional query parameters
|
|
2612
|
-
* @param options - Request options
|
|
2613
|
-
*/
|
|
2614
|
-
fetch<R = Any, Q = QueryParams>(
|
|
2615
|
-
query: string,
|
|
2616
|
-
params: Q | undefined,
|
|
2617
|
-
options: UnfilteredResponseQueryOptions,
|
|
2618
|
-
): Promise<RawQueryResponse<R>>
|
|
2619
|
-
}
|
|
2620
|
-
|
|
2621
2480
|
/** @internal */
|
|
2622
2481
|
export declare interface SanityUser {
|
|
2623
2482
|
id: string
|
|
@@ -2678,7 +2537,7 @@ export declare interface StegaConfig {
|
|
|
2678
2537
|
}
|
|
2679
2538
|
|
|
2680
2539
|
/** @public */
|
|
2681
|
-
export declare type StegaConfigRequiredKeys = Extract<keyof StegaConfig, 'enabled'
|
|
2540
|
+
export declare type StegaConfigRequiredKeys = Extract<keyof StegaConfig, 'enabled'>
|
|
2682
2541
|
|
|
2683
2542
|
/**
|
|
2684
2543
|
* Uses `@vercel/stega` to embed edit info JSON into strings in your query result.
|
|
@@ -2712,11 +2571,7 @@ export declare type StudioUrl = StudioBaseUrl | StudioBaseRoute
|
|
|
2712
2571
|
/** @public */
|
|
2713
2572
|
export declare class Transaction extends BaseTransaction {
|
|
2714
2573
|
#private
|
|
2715
|
-
constructor(
|
|
2716
|
-
operations?: Mutation[],
|
|
2717
|
-
client?: INTERNAL_DO_NOT_USE_DIRECTLY_SanityClient,
|
|
2718
|
-
transactionId?: string,
|
|
2719
|
-
)
|
|
2574
|
+
constructor(operations?: Mutation[], client?: SanityClient, transactionId?: string)
|
|
2720
2575
|
/**
|
|
2721
2576
|
* Clones the transaction
|
|
2722
2577
|
*/
|
|
@@ -2879,7 +2734,7 @@ export declare interface UploadClientConfig {
|
|
|
2879
2734
|
/** @public */
|
|
2880
2735
|
export declare class UsersClient {
|
|
2881
2736
|
#private
|
|
2882
|
-
constructor(client:
|
|
2737
|
+
constructor(client: SanityClient, httpRequest: HttpRequest)
|
|
2883
2738
|
/**
|
|
2884
2739
|
* Fetch a user by user ID
|
|
2885
2740
|
*
|
|
@@ -2906,11 +2761,3 @@ export declare type WelcomeEvent = {
|
|
|
2906
2761
|
}
|
|
2907
2762
|
|
|
2908
2763
|
export {}
|
|
2909
|
-
|
|
2910
|
-
declare module '../types' {
|
|
2911
|
-
/** @public */
|
|
2912
|
-
interface ResponseQueryOptions<T = 'next'> extends RequestOptions {
|
|
2913
|
-
stega?: boolean | StegaConfig
|
|
2914
|
-
}
|
|
2915
|
-
}
|
|
2916
|
-
//# sourceMappingURL=types.d.ts.map
|