@sanity/client 6.11.3 → 6.11.4-canary.1

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