@sanity/client 6.9.1 → 6.9.2

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