@sanity/sdk-react 0.0.0-alpha.15 → 0.0.0-alpha.17

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 (49) hide show
  1. package/dist/_chunks-es/context.js +9 -1
  2. package/dist/_chunks-es/context.js.map +1 -1
  3. package/dist/_chunks-es/useLogOut.js +28 -15
  4. package/dist/_chunks-es/useLogOut.js.map +1 -1
  5. package/dist/components.d.ts +37 -9
  6. package/dist/components.js +171 -96
  7. package/dist/components.js.map +1 -1
  8. package/dist/hooks.d.ts +417 -145
  9. package/dist/hooks.js +470 -226
  10. package/dist/hooks.js.map +1 -1
  11. package/dist/index.d.ts +2 -2
  12. package/dist/index.js +10 -2
  13. package/dist/index.js.map +1 -1
  14. package/package.json +7 -4
  15. package/src/_exports/hooks.ts +15 -6
  16. package/src/_exports/index.ts +1 -10
  17. package/src/components/SDKProvider.test.tsx +3 -3
  18. package/src/components/SDKProvider.tsx +18 -7
  19. package/src/components/SanityApp.test.tsx +5 -5
  20. package/src/components/SanityApp.tsx +38 -24
  21. package/src/hooks/_synchronous-groq-js.mjs +4 -0
  22. package/src/hooks/client/useClient.ts +4 -1
  23. package/src/hooks/context/useSanityInstance.ts +1 -1
  24. package/src/hooks/datasets/useDatasets.ts +26 -1
  25. package/src/hooks/document/useApplyActions.test.ts +5 -4
  26. package/src/hooks/document/useApplyActions.ts +10 -4
  27. package/src/hooks/document/useDocument.ts +3 -3
  28. package/src/hooks/document/useDocumentEvent.ts +2 -0
  29. package/src/hooks/document/useDocumentSyncStatus.ts +2 -1
  30. package/src/hooks/document/useEditDocument.ts +31 -33
  31. package/src/hooks/helpers/createCallbackHook.tsx +3 -2
  32. package/src/hooks/helpers/createStateSourceHook.tsx +6 -10
  33. package/src/hooks/infiniteList/useInfiniteList.test.tsx +152 -0
  34. package/src/hooks/infiniteList/useInfiniteList.ts +174 -0
  35. package/src/hooks/paginatedList/usePaginatedList.test.tsx +259 -0
  36. package/src/hooks/paginatedList/usePaginatedList.ts +290 -0
  37. package/src/hooks/projection/useProjection.ts +3 -3
  38. package/src/hooks/projects/useProject.ts +25 -1
  39. package/src/hooks/projects/useProjects.ts +33 -11
  40. package/src/hooks/query/useQuery.test.tsx +188 -0
  41. package/src/hooks/query/useQuery.ts +103 -0
  42. package/src/hooks/users/useUsers.ts +2 -2
  43. package/src/utils/getEnv.ts +21 -0
  44. package/src/version.ts +8 -0
  45. package/src/hooks/documentCollection/types.ts +0 -19
  46. package/src/hooks/documentCollection/useDocuments.test.ts +0 -130
  47. package/src/hooks/documentCollection/useDocuments.ts +0 -126
  48. package/src/hooks/documentCollection/useSearch.test.ts +0 -100
  49. package/src/hooks/documentCollection/useSearch.ts +0 -75
package/dist/hooks.d.ts CHANGED
@@ -7,18 +7,21 @@ import {CurrentUser} from '@sanity/sdk'
7
7
  import {DocumentAction} from '@sanity/sdk'
8
8
  import {DocumentEvent} from '@sanity/sdk'
9
9
  import {DocumentHandle} from '@sanity/sdk'
10
- import {DocumentListOptions} from '@sanity/sdk'
11
10
  import {FrameMessage} from '@sanity/sdk'
12
11
  import {JsonMatch} from '@sanity/sdk'
13
12
  import {JsonMatchPath} from '@sanity/sdk'
14
13
  import {Observable} from 'rxjs'
15
14
  import {PermissionsResult} from '@sanity/sdk'
16
15
  import {PreviewValue} from '@sanity/sdk'
16
+ import {QueryOptions} from '@sanity/sdk'
17
17
  import {Requester} from 'get-it'
18
+ import {ResourceId} from '@sanity/sdk'
18
19
  import {ResourceType} from '@sanity/sdk'
19
20
  import {SanityDocument} from '@sanity/types'
20
21
  import {SanityInstance} from '@sanity/sdk'
22
+ import {SanityProject as SanityProject_2} from '@sanity/sdk'
21
23
  import {SanityUser as SanityUser_2} from '@sanity/sdk'
24
+ import {SortOrderingItem} from '@sanity/types'
22
25
  import {ValidProjection} from '@sanity/sdk'
23
26
  import {WindowMessage} from '@sanity/sdk'
24
27
 
@@ -306,14 +309,14 @@ declare interface ClientConfig {
306
309
  /**
307
310
  * What perspective to use for the client. See {@link https://www.sanity.io/docs/perspectives|perspective documentation}
308
311
  * @remarks
309
- * As of API version `v2025-02-19`, the default perspective has changed from `raw` to `published`. {@link https://www.sanity.io/changelog/e93a2d5a-9cee-4801-829e-8d3394bfed85|Changelog}
312
+ * As of API version `v2025-02-19`, the default perspective has changed from `raw` to `published`. {@link https://www.sanity.io/changelog/676aaa9d-2da6-44fb-abe5-580f28047c10|Changelog}
310
313
  * @defaultValue 'published'
311
314
  */
312
315
  perspective?: ClientPerspective
313
316
  apiHost?: string
314
317
  /**
315
318
  @remarks
316
- * As of API version `v2025-02-19`, the default perspective has changed from `raw` to `published`. {@link https://www.sanity.io/changelog/e93a2d5a-9cee-4801-829e-8d3394bfed85|Changelog}
319
+ * As of API version `v2025-02-19`, the default perspective has changed from `raw` to `published`. {@link https://www.sanity.io/changelog/676aaa9d-2da6-44fb-abe5-580f28047c10|Changelog}
317
320
  */
318
321
  apiVersion?: string
319
322
  proxy?: string
@@ -582,7 +585,7 @@ declare class DatasetsClient {
582
585
  }
583
586
 
584
587
  /** @public */
585
- declare type DatasetsResponse = {
588
+ export declare type DatasetsResponse = {
586
589
  name: string
587
590
  aclMode: DatasetAclMode
588
591
  createdAt: string
@@ -655,24 +658,6 @@ declare type DisconnectEvent = {
655
658
 
656
659
  export {DocumentHandle}
657
660
 
658
- /**
659
- * @public
660
- * A live collection of {@link DocumentHandle}s, along with metadata about the collection and a function for loading more of them.
661
- * @category Types
662
- */
663
- export declare interface DocumentHandleCollection {
664
- /** Retrieve more documents matching the provided options */
665
- loadMore: () => void
666
- /** The retrieved document handles of the documents matching the provided options */
667
- results: DocumentHandle[]
668
- /** Whether a retrieval of documents is in flight */
669
- isPending: boolean
670
- /** Whether more documents exist that match the provided options than have been retrieved */
671
- hasMore: boolean
672
- /** The total number of documents in the collection */
673
- count: number
674
- }
675
-
676
661
  /**
677
662
  * Modifies an existing draft document.
678
663
  * It applies the given patch to the document referenced by draftId.
@@ -803,6 +788,60 @@ declare type IdentifiedSanityDocumentStub<T extends Record<string, Any> = Record
803
788
  _id: string
804
789
  } & SanityDocumentStub
805
790
 
791
+ /**
792
+ * Return value from the useInfiniteList hook
793
+ *
794
+ * @beta
795
+ * @category Types
796
+ */
797
+ export declare interface InfiniteList {
798
+ /**
799
+ * Array of document handles for the current batch
800
+ */
801
+ data: DocumentHandle[]
802
+ /**
803
+ * Whether there are more items available to load
804
+ */
805
+ hasMore: boolean
806
+ /**
807
+ * Total count of items matching the query
808
+ */
809
+ count: number
810
+ /**
811
+ * Whether a query is currently in progress
812
+ */
813
+ isPending: boolean
814
+ /**
815
+ * Function to load the next batch of results
816
+ */
817
+ loadMore: () => void
818
+ }
819
+
820
+ /**
821
+ * Configuration options for the useInfiniteList hook
822
+ *
823
+ * @beta
824
+ * @category Types
825
+ */
826
+ export declare interface InfiniteListOptions extends QueryOptions {
827
+ /**
828
+ * GROQ filter expression to apply to the query
829
+ */
830
+ filter?: string
831
+ /**
832
+ * Number of items to load per batch (defaults to 25)
833
+ */
834
+ batchSize?: number
835
+ /**
836
+ * Sorting configuration for the results
837
+ */
838
+ orderings?: SortOrderingItem[]
839
+ /**
840
+ * Text search query to filter results
841
+ */
842
+ search?: string
843
+ }
844
+
806
845
  /** @public */
807
846
  declare interface InitializedClientConfig extends ClientConfig {
808
847
  apiHost: string
@@ -917,7 +956,7 @@ declare interface ListenOptions {
917
956
  includePreviousRevision?: boolean
918
957
  /**
919
958
  * Whether to include events for drafts and versions. As of API Version >= v2025-02-19, only events
920
- * for published documents will be included by default (see {@link https://www.sanity.io/changelog/e93a2d5a-9cee-4801-829e-8d3394bfed85|Changelog})
959
+ * for published documents will be included by default (see {@link https://www.sanity.io/changelog/676aaa9d-2da6-44fb-abe5-580f28047c10|Changelog})
921
960
  * If you need events from drafts and versions, set this to `true`.
922
961
  * Note: Keep in mind that additional document variants may be introduced in the future, so it's
923
962
  * recommended to respond to events in a way that's tolerant of potential future variants, e.g. by
@@ -1928,6 +1967,109 @@ declare type OpenEvent = {
1928
1967
  type: 'open'
1929
1968
  }
1930
1969
 
1970
+ /**
1971
+ * Return value from the usePaginatedList hook
1972
+ *
1973
+ * @beta
1974
+ * @category Types
1975
+ */
1976
+ export declare interface PaginatedList {
1977
+ /**
1978
+ * Array of document handles for the current page
1979
+ */
1980
+ data: DocumentHandle[]
1981
+ /**
1982
+ * Whether a query is currently in progress
1983
+ */
1984
+ isPending: boolean
1985
+ /**
1986
+ * Number of items displayed per page
1987
+ */
1988
+ pageSize: number
1989
+ /**
1990
+ * Current page number (1-indexed)
1991
+ */
1992
+ currentPage: number
1993
+ /**
1994
+ * Total number of pages available
1995
+ */
1996
+ totalPages: number
1997
+ /**
1998
+ * Starting index of the current page (0-indexed)
1999
+ */
2000
+ startIndex: number
2001
+ /**
2002
+ * Ending index of the current page (exclusive, 0-indexed)
2003
+ */
2004
+ endIndex: number
2005
+ /**
2006
+ * Total count of items matching the query
2007
+ */
2008
+ count: number
2009
+ /**
2010
+ * Navigate to the first page
2011
+ */
2012
+ firstPage: () => void
2013
+ /**
2014
+ * Whether there is a first page available to navigate to
2015
+ */
2016
+ hasFirstPage: boolean
2017
+ /**
2018
+ * Navigate to the previous page
2019
+ */
2020
+ previousPage: () => void
2021
+ /**
2022
+ * Whether there is a previous page available to navigate to
2023
+ */
2024
+ hasPreviousPage: boolean
2025
+ /**
2026
+ * Navigate to the next page
2027
+ */
2028
+ nextPage: () => void
2029
+ /**
2030
+ * Whether there is a next page available to navigate to
2031
+ */
2032
+ hasNextPage: boolean
2033
+ /**
2034
+ * Navigate to the last page
2035
+ */
2036
+ lastPage: () => void
2037
+ /**
2038
+ * Whether there is a last page available to navigate to
2039
+ */
2040
+ hasLastPage: boolean
2041
+ /**
2042
+ * Navigate to a specific page number
2043
+ * @param pageNumber - The page number to navigate to (1-indexed)
2044
+ */
2045
+ goToPage: (pageNumber: number) => void
2046
+ }
2047
+
2048
+ /**
2049
+ * Configuration options for the usePaginatedList hook
2050
+ *
2051
+ * @beta
2052
+ * @category Types
2053
+ */
2054
+ export declare interface PaginatedListOptions extends QueryOptions {
2055
+ /**
2056
+ * GROQ filter expression to apply to the query
2057
+ */
2058
+ filter?: string
2059
+ /**
2060
+ * Number of items to display per page (defaults to 25)
2061
+ */
2062
+ pageSize?: number
2063
+ /**
2064
+ * Sorting configuration for the results
2065
+ */
2066
+ orderings?: SortOrderingItem[]
2067
+ /**
2068
+ * Text search query to filter results
2069
+ */
2070
+ search?: string
2071
+ }
2072
+
1931
2073
  /** @public */
1932
2074
  declare class Patch extends BasePatch {
1933
2075
  #private
@@ -2035,6 +2177,12 @@ declare class ProjectsClient {
2035
2177
  getById(projectId: string): Promise<SanityProject>
2036
2178
  }
2037
2179
 
2180
+ /**
2181
+ * @public
2182
+ * @category Types
2183
+ */
2184
+ export declare type ProjectWithoutMembers = Omit<SanityProject, 'members'>
2185
+
2038
2186
  /**
2039
2187
  * Publishes a draft document.
2040
2188
  * If a published version of the document already exists this is replaced by the current draft document.
@@ -2824,7 +2972,7 @@ declare interface SanityImagePalette {
2824
2972
  }
2825
2973
 
2826
2974
  /** @public */
2827
- declare interface SanityProject {
2975
+ export declare interface SanityProject {
2828
2976
  id: string
2829
2977
  displayName: string
2830
2978
  /**
@@ -2852,7 +3000,7 @@ declare interface SanityProject {
2852
3000
  }
2853
3001
 
2854
3002
  /** @public */
2855
- declare interface SanityProjectMember {
3003
+ export declare interface SanityProjectMember {
2856
3004
  id: string
2857
3005
  role: string
2858
3006
  isRobot: boolean
@@ -2876,10 +3024,6 @@ declare interface SanityUser {
2876
3024
  isCurrentUser: boolean
2877
3025
  }
2878
3026
 
2879
- declare interface SearchOptions extends DocumentListOptions {
2880
- query?: string
2881
- }
2882
-
2883
3027
  /** @internal */
2884
3028
  declare interface SingleActionResult {
2885
3029
  transactionId: string
@@ -2895,6 +3039,8 @@ declare interface SingleMutationResult {
2895
3039
  }[]
2896
3040
  }
2897
3041
 
3042
+ export {SortOrderingItem}
3043
+
2898
3044
  /** @public */
2899
3045
  declare type StackablePerspective = ('published' | 'drafts' | string) & {}
2900
3046
 
@@ -3156,6 +3302,7 @@ declare interface UploadClientConfig {
3156
3302
  * Provides a callback for applying one or more actions to a document.
3157
3303
  *
3158
3304
  * @category Documents
3305
+ * @param resourceId - The resource ID of the document to apply actions to. If not provided, the document will use the default resource.
3159
3306
  * @returns A function that takes one more more {@link DocumentAction}s and returns a promise that resolves to an {@link ActionsResult}.
3160
3307
  * @example Publish or unpublish a document
3161
3308
  * ```
@@ -3193,7 +3340,9 @@ declare interface UploadClientConfig {
3193
3340
  * )
3194
3341
  * ```
3195
3342
  */
3196
- export declare function useApplyActions(): <TDocument extends SanityDocument>(
3343
+ export declare function useApplyActions(
3344
+ resourceId?: ResourceId,
3345
+ ): <TDocument extends SanityDocument>(
3197
3346
  action: DocumentAction<TDocument> | DocumentAction<TDocument>[],
3198
3347
  options?: ApplyActionsOptions,
3199
3348
  ) => Promise<ActionsResult<TDocument>>
@@ -3254,7 +3403,7 @@ export declare const useAuthToken: () => string | null
3254
3403
  *
3255
3404
  * @public
3256
3405
  */
3257
- export declare const useClient: (options: ClientOptions) => SanityClient
3406
+ export declare const useClient: (e: ClientOptions) => SanityClient
3258
3407
 
3259
3408
  declare type UseCurrentUser = {
3260
3409
  /**
@@ -3286,8 +3435,33 @@ declare type UseCurrentUser = {
3286
3435
  */
3287
3436
  export declare const useCurrentUser: UseCurrentUser
3288
3437
 
3438
+ declare type UseDatasets = {
3439
+ /**
3440
+ *
3441
+ * Returns metadata for each dataset in your organization.
3442
+ *
3443
+ * @category Datasets
3444
+ * @returns The metadata for your organization's datasets
3445
+ *
3446
+ * @example
3447
+ * ```tsx
3448
+ * const datasets = useDatasets()
3449
+ *
3450
+ * return (
3451
+ * <select>
3452
+ * {datasets.map((dataset) => (
3453
+ * <option key={dataset.name}>{dataset.name}</option>
3454
+ * ))}
3455
+ * </select>
3456
+ * )
3457
+ * ```
3458
+ *
3459
+ */
3460
+ (): DatasetsResponse
3461
+ }
3462
+
3289
3463
  /** @public */
3290
- export declare const useDatasets: () => DatasetsResponse
3464
+ export declare const useDatasets: UseDatasets
3291
3465
 
3292
3466
  /**
3293
3467
  * @beta
@@ -3295,7 +3469,8 @@ export declare const useDatasets: () => DatasetsResponse
3295
3469
  * ## useDocument(doc, path)
3296
3470
  * Read and subscribe to nested values in a document
3297
3471
  * @category Documents
3298
- * @param doc - The document to read state from
3472
+ * @param doc - The document to read state from. If you pass a `DocumentHandle` with a `resourceId` in the DocumentResourceId format (`document:projectId.dataset:documentId`)
3473
+ * the document will be read from the specified Sanity project and dataset that is included in the handle. If no `resourceId` is provided, the default project and dataset from your `SanityApp` configuration will be used.
3299
3474
  * @param path - The path to the nested value to read from
3300
3475
  * @returns The value at the specified path
3301
3476
  * @example
@@ -3366,6 +3541,8 @@ export declare function useDocument<TDocument extends SanityDocument>(
3366
3541
  *
3367
3542
  * @category Documents
3368
3543
  * @param handler - The event handler to register.
3544
+ * @param doc - The document to subscribe to events for. If you pass a `DocumentHandle` with a `resourceId` (in the format of `document:projectId.dataset:documentId`)
3545
+ * the document will be read from the specified Sanity project and dataset that is included in the handle. If no `resourceId` is provided, the default project and dataset from your `SanityApp` configuration will be used.
3369
3546
  * @example
3370
3547
  * ```
3371
3548
  * import {useDocumentEvent} from '@sanity/sdk-react'
@@ -3385,71 +3562,13 @@ export declare function useDocumentEvent(
3385
3562
  doc: DocumentHandle,
3386
3563
  ): void
3387
3564
 
3388
- /**
3389
- * @public
3390
- *
3391
- * Retrieves and provides access to a live collection of {@link DocumentHandle}s, with an optional filter and sort applied.
3392
- * The returned document handles are canonical — that is, they refer to the document in its current state, whether draft, published, or within a release or perspective.
3393
- * Because the returned document handle collection is live, the results will update in real time until the component invoking the hook is unmounted.
3394
- *
3395
- * @remarks
3396
- * {@link DocumentHandle}s are used by many other hooks (such as {@link usePreview}, {@link useDocument}, and {@link useEditDocument})
3397
- * to work with documents in various ways without the entire document needing to be fetched upfront.
3398
- *
3399
- * @category Documents
3400
- * @param options - Options for narrowing and sorting the document collection
3401
- * @returns The collection of document handles matching the provided options (if any), as well as properties describing the collection and a function to load more.
3402
- *
3403
- * @example Retrieving document handles for all documents of type 'movie'
3404
- * ```
3405
- * const { results, isPending } = useDocuments({ filter: '_type == "movie"' })
3406
- *
3407
- * return (
3408
- * <div>
3409
- * <h1>Movies</h1>
3410
- * {results && (
3411
- * <ul>
3412
- * {results.map(movie => (<li key={movie._id}>…</li>))}
3413
- * </ul>
3414
- * )}
3415
- * {isPending && <div>Loading movies…</div>}
3416
- * </div>
3417
- * )
3418
- * ```
3419
- *
3420
- * @example Retrieving document handles for all movies released since 1980, sorted by director’s last name
3421
- * ```
3422
- * const { results } = useDocuments({
3423
- * filter: '_type == "movie" && releaseDate >= "1980-01-01"',
3424
- * sort: [
3425
- * {
3426
- * // Expand the `director` reference field with the dereferencing operator `->`
3427
- * field: 'director->lastName',
3428
- * sort: 'asc',
3429
- * },
3430
- * ],
3431
- * })
3432
- *
3433
- * return (
3434
- * <div>
3435
- * <h1>Movies released since 1980</h1>
3436
- * {results && (
3437
- * <ol>
3438
- * {results.map(movie => (<li key={movie._id}>…</li>))}
3439
- * </ol>
3440
- * )}
3441
- * </div>
3442
- * )
3443
- * ```
3444
- */
3445
- export declare function useDocuments(options?: DocumentListOptions): DocumentHandleCollection
3446
-
3447
3565
  declare type UseDocumentSyncStatus = {
3448
3566
  /**
3449
3567
  * Exposes the document’s sync status between local and remote document states.
3450
3568
  *
3451
3569
  * @category Documents
3452
- * @param doc - The document handle to get sync status for
3570
+ * @param doc - The document handle to get sync status for. If you pass a `DocumentHandle` with a `resourceId` (in the format of `document:projectId.dataset:documentId`)
3571
+ * the document will be read from the specified Sanity project and dataset that is included in the handle. If no `resourceId` is provided, the default project and dataset from your `SanityApp` configuration will be used.
3453
3572
  * @returns `true` if local changes are synced with remote, `false` if the changes are not synced, and `undefined` if the document is not found
3454
3573
  * @example Disable a Save button when there are no changes to sync
3455
3574
  * ```
@@ -3529,7 +3648,8 @@ export declare function useEditDocument<
3529
3648
  *
3530
3649
  * ## useEditDocument(doc)
3531
3650
  * Edit an entire document
3532
- * @param doc - The document to be edited; either as a document handle or the document’s ID a string
3651
+ * @param doc - The document to be edited; either as a document handle or the document’s ID a string. If you pass a `DocumentHandle` with a `resourceId` (in the format of `document:projectId.dataset:documentId`)
3652
+ * the document will be read from the specified Sanity project and dataset that is included in the handle. If no `resourceId` is provided, the default project and dataset from your `SanityApp` configuration will be used.
3533
3653
  * @returns A function to update the document state. Accepts either a new document state, or an updater function that exposes the previous document state and returns the new document state.
3534
3654
  * @example
3535
3655
  * ```
@@ -3661,6 +3781,49 @@ export declare const useHandleCallback: () => (
3661
3781
  locationHref?: string | undefined,
3662
3782
  ) => Promise<string | false>
3663
3783
 
3784
+ /**
3785
+ * Retrieves batches of {@link DocumentHandle}s, narrowed by optional filters, text searches, and custom ordering,
3786
+ * with infinite scrolling support. The number of document handles returned per batch is customizable,
3787
+ * and additional batches can be loaded using the supplied `loadMore` function.
3788
+ *
3789
+ * @beta
3790
+ * @category Documents
3791
+ * @param options - Configuration options for the infinite list
3792
+ * @returns An object containing the list of document handles, the loading state, the total count of retrived document handles, and a function to load more
3793
+ * @example
3794
+ * ```tsx
3795
+ * const {data, hasMore, isPending, loadMore} = useInfiniteList({
3796
+ * filter: '_type == "post"',
3797
+ * search: searchTerm,
3798
+ * batchSize: 10,
3799
+ * orderings: [{field: '_createdAt', direction: 'desc'}]
3800
+ * })
3801
+ *
3802
+ * return (
3803
+ * <div>
3804
+ * Total documents: {count}
3805
+ * <ol>
3806
+ * {data.map((doc) => (
3807
+ * <li key={doc._id}>
3808
+ * <MyDocumentComponent doc={doc} />
3809
+ * </li>
3810
+ * ))}
3811
+ * </ol>
3812
+ * {hasMore && <button onClick={loadMore}>Load More</button>}
3813
+ * </div>
3814
+ * )
3815
+ * ```
3816
+ *
3817
+ */
3818
+ export declare function useInfiniteList({
3819
+ batchSize,
3820
+ params,
3821
+ search,
3822
+ filter,
3823
+ orderings,
3824
+ ...options
3825
+ }: InfiniteListOptions): InfiniteList
3826
+
3664
3827
  /**
3665
3828
  * @internal
3666
3829
  * A React hook that retrieves the available authentication provider URLs for login.
@@ -3709,6 +3872,59 @@ export declare function useLoginUrls(): AuthProvider[]
3709
3872
  */
3710
3873
  export declare const useLogOut: () => () => Promise<void>
3711
3874
 
3875
+ /**
3876
+ * Retrieves pages of {@link DocumentHandle}s, narrowed by optional filters, text searches, and custom ordering,
3877
+ * with support for traditional paginated interfaces. The number of document handles returned per page is customizable,
3878
+ * while page navigation is handled via the included navigation functions.
3879
+ *
3880
+ * @beta
3881
+ * @category Documents
3882
+ * @param options - Configuration options for the paginated list
3883
+ * @returns An object containing the current page of document handles, the loading and pagination state, and navigation functions
3884
+ * @example
3885
+ * ```tsx
3886
+ * const {
3887
+ * data,
3888
+ * isPending,
3889
+ * currentPage,
3890
+ * totalPages,
3891
+ * nextPage,
3892
+ * previousPage,
3893
+ * hasNextPage,
3894
+ * hasPreviousPage
3895
+ * } = usePaginatedList({
3896
+ * filter: '_type == "post"',
3897
+ * search: searchTerm,
3898
+ * pageSize: 10,
3899
+ * orderings: [{field: '_createdAt', direction: 'desc'}]
3900
+ * })
3901
+ *
3902
+ * return (
3903
+ * <>
3904
+ * <table>
3905
+ * {data.map(doc => (
3906
+ * <MyTableRowComponent key={doc._id} doc={doc} />
3907
+ * ))}
3908
+ * </table>
3909
+ * <>
3910
+ * {hasPreviousPage && <button onClick={previousPage}>Previous</button>}
3911
+ * {currentPage} / {totalPages}
3912
+ * {hasNextPage && <button onClick={nextPage}>Next</button>}
3913
+ * </>
3914
+ * </>
3915
+ * )
3916
+ * ```
3917
+ *
3918
+ */
3919
+ export declare function usePaginatedList({
3920
+ filter,
3921
+ pageSize,
3922
+ params,
3923
+ orderings,
3924
+ search,
3925
+ ...options
3926
+ }?: PaginatedListOptions): PaginatedList
3927
+
3712
3928
  /**
3713
3929
  *
3714
3930
  * @beta
@@ -3820,8 +4036,32 @@ export declare interface UsePreviewResults {
3820
4036
  isPending: boolean
3821
4037
  }
3822
4038
 
4039
+ declare type UseProject = {
4040
+ /**
4041
+ *
4042
+ * Returns metadata for a given project
4043
+ *
4044
+ * @category Projects
4045
+ * @param projectId - The ID of the project to retrieve metadata for
4046
+ * @returns The metadata for the project
4047
+ * @example
4048
+ * ```tsx
4049
+ * function ProjectMetadata({ projectId }: { projectId: string }) {
4050
+ * const project = useProject(projectId)
4051
+ *
4052
+ * return (
4053
+ * <figure style={{ backgroundColor: project.metadata.color || 'lavender'}}>
4054
+ * <h1>{project.displayName}</h1>
4055
+ * </figure>
4056
+ * )
4057
+ * }
4058
+ * ```
4059
+ */
4060
+ (projectId: string): SanityProject_2
4061
+ }
4062
+
3823
4063
  /** @public */
3824
- export declare const useProject: (projectId: string) => SanityProject
4064
+ export declare const useProject: UseProject
3825
4065
 
3826
4066
  /**
3827
4067
  * @beta
@@ -3856,15 +4096,15 @@ export declare const useProject: (projectId: string) => SanityProject
3856
4096
  * }
3857
4097
  * ```
3858
4098
  *
3859
- * @example Combining with useDocuments to render a collection with specific fields
4099
+ * @example Combining with useInfiniteList to render a collection with specific fields
3860
4100
  * ```
3861
4101
  * // DocumentList.jsx
3862
- * const { results, isPending } = useDocuments({ filter: '_type == "article"' })
4102
+ * const { data } = useInfiniteList({ filter: '_type == "article"' })
3863
4103
  * return (
3864
4104
  * <div>
3865
4105
  * <h1>Articles</h1>
3866
4106
  * <ul>
3867
- * {isPending ? 'Loading…' : results.map(article => (
4107
+ * {data.map(article => (
3868
4108
  * <li key={article._id}>
3869
4109
  * <Suspense fallback='Loading…'>
3870
4110
  * <ProjectionComponent
@@ -3895,8 +4135,83 @@ declare interface UseProjectionResults<TResult extends object> {
3895
4135
  isPending: boolean
3896
4136
  }
3897
4137
 
4138
+ declare type UseProjects = {
4139
+ /**
4140
+ *
4141
+ * Returns metadata for each project in your organization.
4142
+ *
4143
+ * @category Projects
4144
+ * @returns An array of metadata (minus the projects’ members) for each project in your organization
4145
+ * @example
4146
+ * ```tsx
4147
+ * const projects = useProjects()
4148
+ *
4149
+ * return (
4150
+ * <select>
4151
+ * {projects.map((project) => (
4152
+ * <option key={project.id}>{project.displayName}</option>
4153
+ * ))}
4154
+ * </select>
4155
+ * )
4156
+ * ```
4157
+ */
4158
+ (): ProjectWithoutMembers[]
4159
+ }
4160
+
3898
4161
  /** @public */
3899
- export declare const useProjects: () => Omit<SanityProject, 'members'>[]
4162
+ export declare const useProjects: UseProjects
4163
+
4164
+ /**
4165
+ * Executes GROQ queries against a Sanity dataset.
4166
+ *
4167
+ * This hook provides a convenient way to fetch and subscribe to real-time updates
4168
+ * for your Sanity content. Changes made to the dataset’s content will trigger
4169
+ * automatic updates.
4170
+ *
4171
+ * @remarks
4172
+ * The returned `isPending` flag indicates when a React transition is in progress,
4173
+ * which can be used to show loading states for query changes.
4174
+ *
4175
+ * @beta
4176
+ * @category GROQ
4177
+ * @param query - GROQ query string to execute
4178
+ * @param options - Optional configuration for the query
4179
+ * @returns Object containing the query result and a pending state flag
4180
+ *
4181
+ * @example Basic usage
4182
+ * ```tsx
4183
+ * const {data, isPending} = useQuery<Movie[]>('*[_type == "movie"]')
4184
+ * ```
4185
+ *
4186
+ * @example Using parameters
4187
+ * ```tsx
4188
+ * // With parameters
4189
+ * const {data} = useQuery<Movie>('*[_type == "movie" && _id == $id][0]', {
4190
+ * params: { id: 'movie-123' }
4191
+ * })
4192
+ * ```
4193
+ *
4194
+ * @example With a loading state for transitions
4195
+ * ```tsx
4196
+ * const {data, isPending} = useQuery<Movie[]>('*[_type == "movie"]')
4197
+ * return (
4198
+ * <div>
4199
+ * {isPending && <div>Updating...</div>}
4200
+ * <ul>
4201
+ * {data.map(movie => <li key={movie._id}>{movie.title}</li>)}
4202
+ * </ul>
4203
+ * </div>
4204
+ * )
4205
+ * ```
4206
+ *
4207
+ */
4208
+ export declare function useQuery<T>(
4209
+ query: string,
4210
+ options?: QueryOptions,
4211
+ ): {
4212
+ data: T
4213
+ isPending: boolean
4214
+ }
3900
4215
 
3901
4216
  /** @public */
3902
4217
  declare class UsersClient {
@@ -3919,54 +4234,11 @@ declare class UsersClient {
3919
4234
  * @returns The current Sanity instance
3920
4235
  * @example
3921
4236
  * ```tsx
3922
- * const instance = useSanityInstance('abc123:production')
4237
+ * const instance = useSanityInstance('abc123.production')
3923
4238
  * ```
3924
4239
  */
3925
4240
  export declare const useSanityInstance: (resourceId?: string) => SanityInstance
3926
4241
 
3927
- /**
3928
- * @public
3929
- * Hook for searching documents using full-text search.
3930
- *
3931
- * @param options - The options for the search.
3932
- * @example
3933
- * ```tsx
3934
- * function SearchResults() {
3935
- * const [query, setQuery] = useState('')
3936
- * const {results, isPending} = useSearch({
3937
- * filter: '_type == "book"',
3938
- * query,
3939
- * sort: [{field: '_createdAt', direction: 'desc'}]
3940
- * })
3941
- *
3942
- * return (
3943
- * <div>
3944
- * <input
3945
- * type="search"
3946
- * value={query}
3947
- * onChange={(e) => setQuery(e.target.value)}
3948
- * placeholder="Search books..."
3949
- * />
3950
- * {isPending ? (
3951
- * <div>Searching...</div>
3952
- * ) : (
3953
- * <ul>
3954
- * {results.map((doc) => (
3955
- * <li key={doc._id}>{doc._id}</li>
3956
- * ))}
3957
- * </ul>
3958
- * )}
3959
- * </div>
3960
- * )
3961
- * }
3962
- * ```
3963
- */
3964
- export declare function useSearch({
3965
- query,
3966
- filter: additionalFilter,
3967
- ...options
3968
- }?: SearchOptions): DocumentHandleCollection
3969
-
3970
4242
  /**
3971
4243
  *
3972
4244
  * @public
@@ -4003,7 +4275,7 @@ export declare function useUsers(params: UseUsersParams): UseUsersResult
4003
4275
 
4004
4276
  /**
4005
4277
  * @public
4006
- * @category Users
4278
+ * @category Types
4007
4279
  */
4008
4280
  export declare interface UseUsersParams {
4009
4281
  /**
@@ -4022,7 +4294,7 @@ export declare interface UseUsersParams {
4022
4294
 
4023
4295
  /**
4024
4296
  * @public
4025
- * @category Users
4297
+ * @category Types
4026
4298
  */
4027
4299
  export declare interface UseUsersResult {
4028
4300
  /**