@sanity/sdk 0.0.0-rc.6 → 0.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/README.md +7 -15
  2. package/dist/index.d.ts +562 -234
  3. package/dist/index.js +515 -256
  4. package/dist/index.js.map +1 -1
  5. package/package.json +12 -10
  6. package/src/_exports/index.ts +17 -2
  7. package/src/auth/dashboardUtils.test.ts +41 -0
  8. package/src/auth/dashboardUtils.ts +12 -0
  9. package/src/auth/getOrganizationVerificationState.test.ts +197 -0
  10. package/src/auth/getOrganizationVerificationState.ts +73 -0
  11. package/src/auth/handleAuthCallback.test.ts +2 -0
  12. package/src/auth/handleAuthCallback.ts +1 -0
  13. package/src/auth/logout.test.ts +1 -0
  14. package/src/auth/logout.ts +1 -0
  15. package/src/auth/refreshStampedToken.ts +1 -0
  16. package/src/auth/studioModeAuth.test.ts +1 -1
  17. package/src/auth/studioModeAuth.ts +1 -0
  18. package/src/auth/subscribeToStateAndFetchCurrentUser.test.ts +2 -0
  19. package/src/auth/subscribeToStateAndFetchCurrentUser.ts +1 -0
  20. package/src/client/clientStore.ts +22 -18
  21. package/src/comlink/node/actions/releaseNode.ts +16 -14
  22. package/src/config/__tests__/handles.test.ts +30 -0
  23. package/src/config/handles.ts +67 -0
  24. package/src/config/sanityConfig.ts +44 -16
  25. package/src/document/actions.ts +188 -60
  26. package/src/document/applyDocumentActions.ts +12 -5
  27. package/src/document/documentStore.test.ts +70 -121
  28. package/src/document/documentStore.ts +57 -27
  29. package/src/document/patchOperations.test.ts +1 -1
  30. package/src/document/patchOperations.ts +39 -39
  31. package/src/document/sharedListener.ts +3 -1
  32. package/src/favorites/favorites.test.ts +237 -0
  33. package/src/favorites/favorites.ts +122 -0
  34. package/src/preview/resolvePreview.test.ts +3 -4
  35. package/src/preview/subscribeToStateAndFetchBatches.test.ts +1 -1
  36. package/src/preview/subscribeToStateAndFetchBatches.ts +4 -2
  37. package/src/project/organizationVerification.test.ts +35 -0
  38. package/src/project/organizationVerification.ts +26 -0
  39. package/src/projection/getProjectionState.ts +36 -11
  40. package/src/projection/resolveProjection.test.ts +3 -4
  41. package/src/projection/resolveProjection.ts +35 -9
  42. package/src/projection/subscribeToStateAndFetchBatches.test.ts +1 -1
  43. package/src/projection/subscribeToStateAndFetchBatches.ts +4 -2
  44. package/src/query/queryStore.test.ts +12 -12
  45. package/src/query/queryStore.ts +71 -42
  46. package/src/releases/getPerspectiveState.test.ts +192 -0
  47. package/src/releases/getPerspectiveState.ts +93 -0
  48. package/src/releases/releasesStore.test.ts +170 -0
  49. package/src/releases/releasesStore.ts +89 -0
  50. package/src/releases/utils/sortReleases.test.ts +336 -0
  51. package/src/releases/utils/sortReleases.ts +48 -0
  52. package/src/utils/listenQuery.test.ts +302 -0
  53. package/src/utils/listenQuery.ts +128 -0
package/dist/index.d.ts CHANGED
@@ -1,9 +1,11 @@
1
1
  import {AuthStoreState as AuthStoreState_2} from './authStore'
2
2
  import {BoundStoreAction} from '../store/createActionBinder'
3
3
  import {BoundStoreAction as BoundStoreAction_2} from '../../store/createActionBinder'
4
+ import {CanvasResource} from '@sanity/message-protocol'
4
5
  import {ChannelInput} from '@sanity/comlink'
5
6
  import {ChannelInstance} from '@sanity/comlink'
6
7
  import {ClientConfig} from '@sanity/client'
8
+ import {ClientPerspective} from '@sanity/client'
7
9
  import {Controller} from '@sanity/comlink'
8
10
  import {CurrentUser} from '@sanity/types'
9
11
  import {DatasetsResponse} from '@sanity/client'
@@ -11,6 +13,7 @@ import {DocumentPermissionsResult as DocumentPermissionsResult_2} from './permis
11
13
  import {FetcherStoreState as FetcherStoreState_2} from '../_exports'
12
14
  import {IndexTuple} from '@sanity/types'
13
15
  import {ListenEvent} from '@sanity/client'
16
+ import {MediaResource} from '@sanity/message-protocol'
14
17
  import {Message} from '@sanity/comlink'
15
18
  import {Mutation} from '@sanity/types'
16
19
  import {Node as Node_2} from '@sanity/comlink'
@@ -20,17 +23,20 @@ import {PatchMutation} from '@sanity/mutate/_unstable_store'
20
23
  import {PatchOperations} from '@sanity/types'
21
24
  import {PathSegment} from '@sanity/types'
22
25
  import {PreviewStoreState as PreviewStoreState_2} from './previewStore'
23
- import {ProjectionStoreState} from './types'
24
- import {ProjectionValuePending as ProjectionValuePending_2} from './types'
25
26
  import {ResponseQueryOptions} from '@sanity/client'
26
27
  import {Role} from '@sanity/types'
27
28
  import {SanityClient} from '@sanity/client'
28
29
  import {SanityDocument} from '@sanity/types'
29
30
  import {SanityDocument as SanityDocument_2} from '@sanity/client'
30
31
  import {SanityDocumentLike} from '@sanity/types'
32
+ import {SanityDocumentResult} from 'groq'
31
33
  import {SanityProject as SanityProject_2} from '@sanity/client'
34
+ import {SanityProjectionResult} from 'groq'
35
+ import {SanityQueryResult} from 'groq'
32
36
  import {SanityUser as SanityUser_2} from './types'
37
+ import {StackablePerspective} from '@sanity/client'
33
38
  import {StateSource as StateSource_2} from '../_exports'
39
+ import {StudioResource} from '@sanity/message-protocol'
34
40
  import {Subject} from 'rxjs'
35
41
  import {ValuePending as ValuePending_2} from './previewStore'
36
42
 
@@ -69,7 +75,9 @@ declare type ActionMap = {
69
75
  }
70
76
 
71
77
  /** @beta */
72
- export declare interface ActionsResult<TDocument extends SanityDocument = SanityDocument> {
78
+ export declare interface ActionsResult<
79
+ TDocument extends SanityDocumentResult = SanityDocumentResult,
80
+ > {
73
81
  transactionId: string
74
82
  documents: DocumentSet<TDocument>
75
83
  previous: DocumentSet<TDocument>
@@ -166,11 +174,17 @@ declare interface AppliedTransaction extends QueuedTransaction {
166
174
  }
167
175
 
168
176
  /** @beta */
169
- export declare function applyDocumentActions<TDocument extends SanityDocument>(
177
+ export declare function applyDocumentActions<
178
+ TDocumentType extends string = string,
179
+ TDataset extends string = string,
180
+ TProjectId extends string = string,
181
+ >(
170
182
  instance: SanityInstance,
171
- action: DocumentAction<TDocument> | DocumentAction<TDocument>[],
183
+ action:
184
+ | DocumentAction<TDocumentType, TDataset, TProjectId>
185
+ | DocumentAction<TDocumentType, TDataset, TProjectId>[],
172
186
  options?: ApplyDocumentActionsOptions,
173
- ): Promise<ActionsResult<TDocument>>
187
+ ): Promise<ActionsResult<SanityDocumentResult<TDocumentType, TDataset, TProjectId>>>
174
188
 
175
189
  /** @beta */
176
190
  export declare function applyDocumentActions(
@@ -370,19 +384,21 @@ declare interface ChannelEntry {
370
384
  *
371
385
  * @public
372
386
  */
373
- export declare interface ClientOptions
374
- extends Pick<ClientConfig, AllowedClientConfigKey>,
375
- DatasetHandle {
387
+ export declare interface ClientOptions extends Pick<ClientConfig, AllowedClientConfigKey> {
376
388
  /**
377
389
  * An optional flag to choose between the default client (typically project-level)
378
390
  * and the global client ('global'). When set to `'global'`, the global client
379
391
  * is used.
380
392
  */
381
- scope?: 'default' | 'global'
393
+ 'scope'?: 'default' | 'global'
382
394
  /**
383
395
  * A required string indicating the API version for the client.
384
396
  */
385
- apiVersion: string
397
+ 'apiVersion': string
398
+ /**
399
+ * @internal
400
+ */
401
+ '~experimental_resource'?: ClientConfig['~experimental_resource']
386
402
  }
387
403
 
388
404
  /**
@@ -438,18 +454,75 @@ declare interface ContextNode extends BaseNode {
438
454
  */
439
455
  export declare const CORE_SDK_VERSION: {}
440
456
 
441
- /** @beta */
442
- export declare function createDocument<TDocument extends SanityDocumentLike>(
443
- doc: DocumentTypeHandle<TDocument>,
444
- ): CreateDocumentAction<TDocument>
457
+ /**
458
+ * Creates or validates a `DatasetHandle` object.
459
+ * Ensures the provided object conforms to the `DatasetHandle` interface.
460
+ * @param handle - The object containing dataset identification properties.
461
+ * @returns The validated `DatasetHandle` object.
462
+ * @public
463
+ */
464
+ export declare function createDatasetHandle<
465
+ TDataset extends string = string,
466
+ TProjectId extends string = string,
467
+ >(handle: DatasetHandle<TDataset, TProjectId>): DatasetHandle<TDataset, TProjectId>
445
468
 
446
- /** @beta */
469
+ /**
470
+ * Creates a `CreateDocumentAction` object.
471
+ * @param doc - A handle identifying the document type, dataset, and project. An optional `documentId` can be provided.
472
+ * @returns A `CreateDocumentAction` object ready for dispatch.
473
+ * @beta
474
+ */
475
+ export declare function createDocument<
476
+ TDocumentType extends string = string,
477
+ TDataset extends string = string,
478
+ TProjectId extends string = string,
479
+ >(
480
+ doc: DocumentTypeHandle<TDocumentType, TDataset, TProjectId>,
481
+ ): CreateDocumentAction<TDocumentType, TDataset, TProjectId>
482
+
483
+ /**
484
+ * Represents an action to create a new document.
485
+ * Specifies the document type and optionally a document ID (which will be treated as the published ID).
486
+ * @beta
487
+ */
447
488
  export declare interface CreateDocumentAction<
448
- TDocument extends SanityDocumentLike = SanityDocumentLike,
449
- > extends DocumentTypeHandle<TDocument> {
489
+ TDocumentType extends string = string,
490
+ TDataset extends string = string,
491
+ TProjectId extends string = string,
492
+ > extends DocumentTypeHandle<TDocumentType, TDataset, TProjectId> {
450
493
  type: 'document.create'
451
494
  }
452
495
 
496
+ /**
497
+ * Creates or validates a `DocumentHandle` object.
498
+ * Ensures the provided object conforms to the `DocumentHandle` interface.
499
+ * @param handle - The object containing document identification properties.
500
+ * @returns The validated `DocumentHandle` object.
501
+ * @public
502
+ */
503
+ export declare function createDocumentHandle<
504
+ TDocumentType extends string = string,
505
+ TDataset extends string = string,
506
+ TProjectId extends string = string,
507
+ >(
508
+ handle: DocumentHandle<TDocumentType, TDataset, TProjectId>,
509
+ ): DocumentHandle<TDocumentType, TDataset, TProjectId>
510
+
511
+ /**
512
+ * Creates or validates a `DocumentTypeHandle` object.
513
+ * Ensures the provided object conforms to the `DocumentTypeHandle` interface.
514
+ * @param handle - The object containing document type identification properties.
515
+ * @returns The validated `DocumentTypeHandle` object.
516
+ * @public
517
+ */
518
+ export declare function createDocumentTypeHandle<
519
+ TDocumentType extends string = string,
520
+ TDataset extends string = string,
521
+ TProjectId extends string = string,
522
+ >(
523
+ handle: DocumentTypeHandle<TDocumentType, TDataset, TProjectId>,
524
+ ): DocumentTypeHandle<TDocumentType, TDataset, TProjectId>
525
+
453
526
  /**
454
527
  * Creates a GROQ search filter string (`[@] match text::query("...")`)
455
528
  * from a raw search query string.
@@ -465,6 +538,17 @@ export declare interface CreateDocumentAction<
465
538
  */
466
539
  export declare function createGroqSearchFilter(query: string): string
467
540
 
541
+ /**
542
+ * Creates or validates a `ProjectHandle` object.
543
+ * Ensures the provided object conforms to the `ProjectHandle` interface.
544
+ * @param handle - The object containing project identification properties.
545
+ * @returns The validated `ProjectHandle` object.
546
+ * @public
547
+ */
548
+ export declare function createProjectHandle<TProjectId extends string = string>(
549
+ handle: ProjectHandle<TProjectId>,
550
+ ): ProjectHandle<TProjectId>
551
+
468
552
  /**
469
553
  * Creates a new Sanity resource instance
470
554
  * @param config - Configuration for the instance (optional)
@@ -491,8 +575,12 @@ declare interface DashboardContext {
491
575
  /**
492
576
  * @public
493
577
  */
494
- export declare interface DatasetHandle extends ProjectHandle {
495
- dataset?: string | undefined
578
+ export declare interface DatasetHandle<
579
+ TDataset extends string = string,
580
+ TProjectId extends string = string,
581
+ > extends ProjectHandle<TProjectId>,
582
+ PerspectiveHandle {
583
+ dataset?: TDataset
496
584
  }
497
585
 
498
586
  declare class DateTime {
@@ -510,33 +598,52 @@ declare class DateTime {
510
598
  declare type DateTimeValue = StaticValue<DateTime, 'datetime'>
511
599
 
512
600
  /**
513
- * Given a type T and an array of access keys Parts, recursively index into T.
601
+ * Given a type T and an array of "access keys" Parts, recursively index into T.
514
602
  *
515
603
  * If a part is a key, it looks up that property.
516
- * If T is an array and the part is a number, it indexes into the element type.
517
- */
518
- declare type DeepGet<T, TParts extends readonly unknown[]> = TParts extends [
519
- infer Head,
520
- ...infer Tail,
521
- ]
522
- ? Head extends keyof T
523
- ? DeepGet<T[Head], Tail>
524
- : T extends Array<infer U>
525
- ? Head extends number
526
- ? DeepGet<U, Tail>
527
- : never
528
- : never
529
- : T
530
-
531
- /** @beta */
532
- export declare function deleteDocument<TDocument extends SanityDocumentLike>(
533
- doc: DocumentHandle<TDocument>,
534
- ): DeleteDocumentAction<TDocument>
604
+ * If T is an array and the part is a number, it "indexes" into the element type.
605
+ */
606
+ declare type DeepGet<TValue, TPath extends readonly (string | number)[]> = TPath extends []
607
+ ? TValue
608
+ : TPath extends readonly [infer THead, ...infer TTail]
609
+ ? DeepGet<
610
+ TValue extends undefined | null
611
+ ? undefined
612
+ : THead extends keyof TValue
613
+ ? TValue[THead]
614
+ : THead extends number
615
+ ? TValue extends readonly (infer TElement)[]
616
+ ? TElement | undefined
617
+ : undefined
618
+ : undefined, // Key/index doesn't exist
619
+ TTail extends readonly (string | number)[] ? TTail : []
620
+ >
621
+ : never
622
+
623
+ /**
624
+ * Creates a `DeleteDocumentAction` object.
625
+ * @param doc - A handle uniquely identifying the document to be deleted.
626
+ * @returns A `DeleteDocumentAction` object ready for dispatch.
627
+ * @beta
628
+ */
629
+ export declare function deleteDocument<
630
+ TDocumentType extends string = string,
631
+ TDataset extends string = string,
632
+ TProjectId extends string = string,
633
+ >(
634
+ doc: DocumentHandle<TDocumentType, TDataset, TProjectId>,
635
+ ): DeleteDocumentAction<TDocumentType, TDataset, TProjectId>
535
636
 
536
- /** @beta */
637
+ /**
638
+ * Represents an action to delete an existing document.
639
+ * Requires the full document handle including the document ID.
640
+ * @beta
641
+ */
537
642
  export declare interface DeleteDocumentAction<
538
- TDocument extends SanityDocumentLike = SanityDocumentLike,
539
- > extends DocumentHandle<TDocument> {
643
+ TDocumentType extends string = string,
644
+ TDataset extends string = string,
645
+ TProjectId extends string = string,
646
+ > extends DocumentHandle<TDocumentType, TDataset, TProjectId> {
540
647
  type: 'document.delete'
541
648
  }
542
649
 
@@ -560,15 +667,30 @@ declare interface DescNode extends BaseNode {
560
667
  */
561
668
  export declare const destroyController: BoundStoreAction_2<ComlinkControllerState, [], void>
562
669
 
563
- /** @beta */
564
- export declare function discardDocument<TDocument extends SanityDocumentLike>(
565
- doc: DocumentHandle<TDocument>,
566
- ): DiscardDocumentAction<TDocument>
670
+ /**
671
+ * Creates a `DiscardDocumentAction` object.
672
+ * @param doc - A handle uniquely identifying the document whose draft changes are to be discarded.
673
+ * @returns A `DiscardDocumentAction` object ready for dispatch.
674
+ * @beta
675
+ */
676
+ export declare function discardDocument<
677
+ TDocumentType extends string = string,
678
+ TDataset extends string = string,
679
+ TProjectId extends string = string,
680
+ >(
681
+ doc: DocumentHandle<TDocumentType, TDataset, TProjectId>,
682
+ ): DiscardDocumentAction<TDocumentType, TDataset, TProjectId>
567
683
 
568
- /** @beta */
684
+ /**
685
+ * Represents an action to discard the draft changes of a document.
686
+ * Requires the full document handle.
687
+ * @beta
688
+ */
569
689
  export declare interface DiscardDocumentAction<
570
- TDocument extends SanityDocumentLike = SanityDocumentLike,
571
- > extends DocumentHandle<TDocument> {
690
+ TDocumentType extends string = string,
691
+ TDataset extends string = string,
692
+ TProjectId extends string = string,
693
+ > extends DocumentHandle<TDocumentType, TDataset, TProjectId> {
572
694
  type: 'document.discard'
573
695
  }
574
696
 
@@ -578,14 +700,21 @@ declare type Document_2 = {
578
700
  [T: string]: unknown
579
701
  }
580
702
 
581
- /** @beta */
582
- export declare type DocumentAction<TDocument extends SanityDocumentLike = SanityDocumentLike> =
583
- | CreateDocumentAction<TDocument>
584
- | DeleteDocumentAction<TDocument>
585
- | EditDocumentAction<TDocument>
586
- | PublishDocumentAction<TDocument>
587
- | UnpublishDocumentAction<TDocument>
588
- | DiscardDocumentAction<TDocument>
703
+ /**
704
+ * Union type representing all possible document actions within the SDK.
705
+ * @beta
706
+ */
707
+ export declare type DocumentAction<
708
+ TDocumentType extends string = string,
709
+ TDataset extends string = string,
710
+ TProjectId extends string = string,
711
+ > =
712
+ | CreateDocumentAction<TDocumentType, TDataset, TProjectId>
713
+ | DeleteDocumentAction<TDocumentType, TDataset, TProjectId>
714
+ | EditDocumentAction<TDocumentType, TDataset, TProjectId>
715
+ | PublishDocumentAction<TDocumentType, TDataset, TProjectId>
716
+ | UnpublishDocumentAction<TDocumentType, TDataset, TProjectId>
717
+ | DiscardDocumentAction<TDocumentType, TDataset, TProjectId>
589
718
 
590
719
  /**
591
720
  * @beta
@@ -641,17 +770,32 @@ export declare type DocumentEvent =
641
770
  | DocumentDiscardedEvent
642
771
 
643
772
  /**
773
+ * Uniquely identifies a specific document within a Sanity dataset and project.
774
+ * Includes `projectId`, `dataset`, `documentType`, and the required `documentId`.
775
+ * Commonly used by document-related hooks and components to reference a document without fetching its full content initially.
644
776
  * @public
645
- * A minimal set of metadata for a given document, comprising the document's ID and type.
646
- * Used by most document-related hooks (such as {@link usePreview}, {@link useDocument}, and {@link useEditDocument})
647
- * to reference a particular document without fetching the entire document upfront.
648
- * @category Types
649
777
  */
650
- export declare interface DocumentHandle<TDocument extends SanityDocumentLike = SanityDocumentLike>
651
- extends DocumentTypeHandle<TDocument> {
778
+ export declare interface DocumentHandle<
779
+ TDocumentType extends string = string,
780
+ TDataset extends string = string,
781
+ TProjectId extends string = string,
782
+ > extends DocumentTypeHandle<TDocumentType, TDataset, TProjectId> {
652
783
  documentId: string
653
784
  }
654
785
 
786
+ /**
787
+ * @beta
788
+ * Options for specifying a document and optionally a path within it.
789
+ */
790
+ export declare interface DocumentOptions<
791
+ TPath extends string | undefined = undefined,
792
+ TDocumentType extends string = string,
793
+ TDataset extends string = string,
794
+ TProjectId extends string = string,
795
+ > extends DocumentHandle<TDocumentType, TDataset, TProjectId> {
796
+ path?: TPath
797
+ }
798
+
655
799
  /** @beta */
656
800
  export declare type DocumentPermissionsResult =
657
801
  | {
@@ -748,12 +892,19 @@ declare interface DocumentStoreState {
748
892
  events: Subject<DocumentEvent>
749
893
  }
750
894
 
751
- /** @public */
895
+ /**
896
+ * Identifies a specific document type within a Sanity dataset and project.
897
+ * Includes `projectId`, `dataset`, and `documentType`.
898
+ * Optionally includes a `documentId`, useful for referencing a specific document type context, potentially without a specific document ID.
899
+ * @public
900
+ */
752
901
  export declare interface DocumentTypeHandle<
753
- TDocument extends SanityDocumentLike = SanityDocumentLike,
754
- > extends DatasetHandle {
902
+ TDocumentType extends string = string,
903
+ TDataset extends string = string,
904
+ TProjectId extends string = string,
905
+ > extends DatasetHandle<TDataset, TProjectId> {
755
906
  documentId?: string
756
- documentType: TDocument['_type']
907
+ documentType: TDocumentType
757
908
  }
758
909
 
759
910
  /**
@@ -766,22 +917,51 @@ export declare interface DocumentUnpublishedEvent {
766
917
  outgoing: OutgoingTransaction
767
918
  }
768
919
 
769
- /** @beta */
770
- export declare function editDocument<TDocument extends SanityDocumentLike>(
771
- doc: DocumentHandle<TDocument>,
920
+ /**
921
+ * Creates an `EditDocumentAction` object with patches for modifying a document.
922
+ * Accepts patches in either the standard `PatchOperations` format or as a `SanityMutatePatchMutation` from `@sanity/mutate`.
923
+ *
924
+ * @param doc - A handle uniquely identifying the document to be edited.
925
+ * @param sanityMutatePatch - A patch mutation object from `@sanity/mutate`.
926
+ * @returns An `EditDocumentAction` object ready for dispatch.
927
+ * @beta
928
+ */
929
+ export declare function editDocument<
930
+ TDocumentType extends string = string,
931
+ TDataset extends string = string,
932
+ TProjectId extends string = string,
933
+ >(
934
+ doc: DocumentHandle<TDocumentType, TDataset, TProjectId>,
772
935
  sanityMutatePatch: PatchMutation,
773
- ): EditDocumentAction<TDocument>
936
+ ): EditDocumentAction<TDocumentType, TDataset, TProjectId>
774
937
 
775
- /** @beta */
776
- export declare function editDocument<TDocument extends SanityDocumentLike>(
777
- doc: DocumentHandle<TDocument>,
938
+ /**
939
+ * Creates an `EditDocumentAction` object with patches for modifying a document.
940
+ *
941
+ * @param doc - A handle uniquely identifying the document to be edited.
942
+ * @param patches - A single patch operation or an array of patch operations.
943
+ * @returns An `EditDocumentAction` object ready for dispatch.
944
+ * @beta
945
+ */
946
+ export declare function editDocument<
947
+ TDocumentType extends string = string,
948
+ TDataset extends string = string,
949
+ TProjectId extends string = string,
950
+ >(
951
+ doc: DocumentHandle<TDocumentType, TDataset, TProjectId>,
778
952
  patches?: PatchOperations | PatchOperations[],
779
- ): EditDocumentAction<TDocument>
953
+ ): EditDocumentAction<TDocumentType, TDataset, TProjectId>
780
954
 
781
- /** @beta */
955
+ /**
956
+ * Represents an action to edit an existing document using patches.
957
+ * Requires the full document handle and an array of patch operations.
958
+ * @beta
959
+ */
782
960
  export declare interface EditDocumentAction<
783
- TDocument extends SanityDocumentLike = SanityDocumentLike,
784
- > extends DocumentHandle<TDocument> {
961
+ TDocumentType extends string = string,
962
+ TDataset extends string = string,
963
+ TProjectId extends string = string,
964
+ > extends DocumentHandle<TDocumentType, TDataset, TProjectId> {
785
965
  type: 'document.edit'
786
966
  patches?: PatchOperations[]
787
967
  }
@@ -839,6 +1019,22 @@ declare type ExprNode =
839
1019
  | TupleNode
840
1020
  | ValueNode
841
1021
 
1022
+ /**
1023
+ * @public
1024
+ */
1025
+ declare interface FavoriteDocumentContext extends DocumentHandle {
1026
+ resourceId: string
1027
+ resourceType: StudioResource['type'] | MediaResource['type'] | CanvasResource['type']
1028
+ schemaName?: string
1029
+ }
1030
+
1031
+ /**
1032
+ * @public
1033
+ */
1034
+ export declare interface FavoriteStatusResponse {
1035
+ isFavorited: boolean
1036
+ }
1037
+
842
1038
  /**
843
1039
  * Internal helper type
844
1040
  * @public
@@ -889,6 +1085,16 @@ declare interface FuncCallNode extends BaseNode {
889
1085
  args: ExprNode[]
890
1086
  }
891
1087
 
1088
+ /**
1089
+ * Get the active releases from the store.
1090
+ * @internal
1091
+ */
1092
+ export declare const getActiveReleasesState: BoundStoreAction<
1093
+ ReleasesStoreState,
1094
+ [],
1095
+ StateSource_2<ReleaseDocument[] | undefined>
1096
+ >
1097
+
892
1098
  /**
893
1099
  * @public
894
1100
  */
@@ -946,41 +1152,60 @@ export declare const getDashboardOrganizationId: BoundStoreAction<
946
1152
 
947
1153
  /** @public */
948
1154
  export declare const getDatasetsState: BoundStoreAction<
949
- FetcherStoreState_2<[options?: ProjectHandle | undefined], DatasetsResponse>,
950
- [options?: ProjectHandle | undefined],
1155
+ FetcherStoreState_2<[options?: ProjectHandle<string> | undefined], DatasetsResponse>,
1156
+ [options?: ProjectHandle<string> | undefined],
951
1157
  StateSource_2<DatasetsResponse | undefined>
952
1158
  >
953
1159
 
954
1160
  /** @beta */
955
1161
  export declare function getDocumentState<
956
- TDocument extends SanityDocument,
957
- TPath extends JsonMatchPath<TDocument>,
1162
+ TDocumentType extends string = string,
1163
+ TDataset extends string = string,
1164
+ TProjectId extends string = string,
958
1165
  >(
959
1166
  instance: SanityInstance,
960
- doc: string | DocumentHandle<TDocument>,
961
- path: TPath,
962
- ): StateSource<JsonMatch<TDocument, TPath> | undefined>
1167
+ options: DocumentOptions<undefined, TDocumentType, TDataset, TProjectId>,
1168
+ ): StateSource<SanityDocumentResult<TDocumentType, TDataset, TProjectId> | undefined | null>
963
1169
 
964
1170
  /** @beta */
965
- export declare function getDocumentState<TDocument extends SanityDocument>(
1171
+ export declare function getDocumentState<
1172
+ TPath extends string = string,
1173
+ TDocumentType extends string = string,
1174
+ TDataset extends string = string,
1175
+ TProjectId extends string = string,
1176
+ >(
966
1177
  instance: SanityInstance,
967
- doc: string | DocumentHandle<TDocument>,
968
- ): StateSource<TDocument | null>
1178
+ options: DocumentOptions<TPath, TDocumentType, TDataset, TProjectId>,
1179
+ ): StateSource<
1180
+ JsonMatch<SanityDocumentResult<TDocumentType, TDataset, TProjectId>, TPath> | undefined
1181
+ >
969
1182
 
970
1183
  /** @beta */
971
- export declare function getDocumentState(
1184
+ export declare function getDocumentState<TData>(
972
1185
  instance: SanityInstance,
973
- doc: string | DocumentHandle,
974
- path?: string,
975
- ): StateSource<unknown>
1186
+ options: DocumentOptions<string | undefined>,
1187
+ ): StateSource<TData | undefined | null>
976
1188
 
977
1189
  /** @beta */
978
1190
  export declare const getDocumentSyncStatus: BoundStoreAction<
979
1191
  DocumentStoreState,
980
- [doc: DocumentHandle<SanityDocumentLike>],
1192
+ [doc: DocumentHandle<string, string, string>],
981
1193
  StateSource<boolean | undefined>
982
1194
  >
983
1195
 
1196
+ /**
1197
+ * Gets a StateSource for the favorite status of a document.
1198
+ * @param instance - The Sanity instance.
1199
+ * @param context - The document context including ID, type, and resource information.
1200
+ * @returns A StateSource emitting `{ isFavorited: boolean }`.
1201
+ * @public
1202
+ */
1203
+ export declare const getFavoritesState: BoundStoreAction<
1204
+ FetcherStoreState_2<[FavoriteDocumentContext], FavoriteStatusResponse>,
1205
+ [FavoriteDocumentContext],
1206
+ StateSource_2<FavoriteStatusResponse | undefined>
1207
+ >
1208
+
984
1209
  /**
985
1210
  * @public
986
1211
  */
@@ -1027,6 +1252,24 @@ export declare const getPermissionsState: BoundStoreAction<
1027
1252
  StateSource<DocumentPermissionsResult_2 | undefined>
1028
1253
  >
1029
1254
 
1255
+ /**
1256
+ * Provides a subscribable state source for a "perspective" for the Sanity client,
1257
+ * which is used to fetch documents as though certain Content Releases are active.
1258
+ *
1259
+ * @param instance - The Sanity instance to get the perspective for
1260
+ * @param options - The options for the perspective -- usually a release name
1261
+ *
1262
+ * @returns A subscribable perspective value, usually a list of applicable release names,
1263
+ * or a single release name / default perspective (such as 'drafts').
1264
+ *
1265
+ * @public
1266
+ */
1267
+ export declare const getPerspectiveState: BoundStoreAction<
1268
+ ReleasesStoreState,
1269
+ [options?: PerspectiveHandle | undefined],
1270
+ StateSource_2<string[] | 'published' | 'drafts' | 'previewDrafts' | 'raw' | undefined>
1271
+ >
1272
+
1030
1273
  /**
1031
1274
  * @beta
1032
1275
  */
@@ -1051,22 +1294,34 @@ export declare type GetPreviewStateOptions = DocumentHandle
1051
1294
  /**
1052
1295
  * @beta
1053
1296
  */
1054
- export declare function getProjectionState<TResult extends object>(
1297
+ export declare function getProjectionState<
1298
+ TProjection extends ValidProjection = ValidProjection,
1299
+ TDocumentType extends string = string,
1300
+ TDataset extends string = string,
1301
+ TProjectId extends string = string,
1302
+ >(
1055
1303
  instance: SanityInstance,
1056
- options: GetProjectionStateOptions,
1057
- ): StateSource<ProjectionValuePending<TResult>>
1304
+ options: ProjectionOptions<TProjection, TDocumentType, TDataset, TProjectId>,
1305
+ ): StateSource<
1306
+ | ProjectionValuePending<SanityProjectionResult<TProjection, TDocumentType, TDataset, TProjectId>>
1307
+ | undefined
1308
+ >
1058
1309
 
1059
1310
  /**
1060
1311
  * @beta
1061
1312
  */
1062
- export declare function getProjectionState(
1313
+ export declare function getProjectionState<TData extends object>(
1063
1314
  instance: SanityInstance,
1064
- options: GetProjectionStateOptions,
1065
- ): StateSource<ProjectionValuePending<Record<string, unknown>>>
1315
+ options: ProjectionOptions,
1316
+ ): StateSource<ProjectionValuePending<TData> | undefined>
1066
1317
 
1067
- declare interface GetProjectionStateOptions extends DocumentHandle {
1068
- projection: ValidProjection
1069
- }
1318
+ /**
1319
+ * @beta
1320
+ */
1321
+ export declare function getProjectionState(
1322
+ instance: SanityInstance,
1323
+ options: ProjectionOptions,
1324
+ ): StateSource<ProjectionValuePending<Record<string, unknown>> | undefined>
1070
1325
 
1071
1326
  /** @public */
1072
1327
  export declare const getProjectsState: BoundStoreAction<
@@ -1077,13 +1332,13 @@ export declare const getProjectsState: BoundStoreAction<
1077
1332
 
1078
1333
  /** @public */
1079
1334
  export declare const getProjectState: BoundStoreAction<
1080
- FetcherStoreState_2<[options?: ProjectHandle | undefined], SanityProject_2>,
1081
- [options?: ProjectHandle | undefined],
1335
+ FetcherStoreState_2<[options?: ProjectHandle<string> | undefined], SanityProject_2>,
1336
+ [options?: ProjectHandle<string> | undefined],
1082
1337
  StateSource_2<SanityProject_2 | undefined>
1083
1338
  >
1084
1339
 
1085
1340
  /** @beta */
1086
- export declare const getQueryKey: (query: string, options?: QueryOptions) => string
1341
+ export declare const getQueryKey: (options: QueryOptions) => string
1087
1342
 
1088
1343
  /**
1089
1344
  * Returns the state source for a query.
@@ -1101,17 +1356,25 @@ export declare const getQueryKey: (query: string, options?: QueryOptions) => str
1101
1356
  *
1102
1357
  * @beta
1103
1358
  */
1104
- export declare function getQueryState<T>(
1359
+ export declare function getQueryState<
1360
+ TQuery extends string = string,
1361
+ TDataset extends string = string,
1362
+ TProjectId extends string = string,
1363
+ >(
1105
1364
  instance: SanityInstance,
1106
- query: string,
1107
- options?: QueryOptions,
1108
- ): StateSource<T | undefined>
1365
+ queryOptions: QueryOptions<TQuery, TDataset, TProjectId>,
1366
+ ): StateSource<SanityQueryResult<TQuery, TDataset, TProjectId> | undefined>
1367
+
1368
+ /** @beta */
1369
+ export declare function getQueryState<TData>(
1370
+ instance: SanityInstance,
1371
+ queryOptions: QueryOptions,
1372
+ ): StateSource<TData | undefined>
1109
1373
 
1110
1374
  /** @beta */
1111
1375
  export declare function getQueryState(
1112
1376
  instance: SanityInstance,
1113
- query: string,
1114
- options?: QueryOptions,
1377
+ queryOptions: QueryOptions,
1115
1378
  ): StateSource<unknown>
1116
1379
 
1117
1380
  /**
@@ -1256,7 +1519,7 @@ declare interface InRangeNode extends BaseNode {
1256
1519
  * compute the type found at that path.
1257
1520
  * @beta
1258
1521
  */
1259
- export declare type JsonMatch<TDocument extends SanityDocumentLike, TPath extends string> = DeepGet<
1522
+ export declare type JsonMatch<TDocument, TPath extends string> = DeepGet<
1260
1523
  TDocument,
1261
1524
  PathParts<TPath>
1262
1525
  >
@@ -1274,21 +1537,14 @@ export declare type JsonMatch<TDocument extends SanityDocumentLike, TPath extend
1274
1537
  *
1275
1538
  * @beta
1276
1539
  */
1277
- export declare function jsonMatch<
1278
- TDocument extends SanityDocumentLike,
1279
- TPath extends JsonMatchPath<TDocument>,
1280
- >(input: TDocument, path: TPath): MatchEntry<JsonMatch<TDocument, TPath>>[]
1540
+ export declare function jsonMatch<TDocument, TPath extends string>(
1541
+ input: TDocument,
1542
+ path: TPath,
1543
+ ): MatchEntry<JsonMatch<TDocument, TPath>>[]
1281
1544
 
1282
1545
  /** @beta */
1283
1546
  export declare function jsonMatch<TValue>(input: unknown, path: string): MatchEntry<TValue>[]
1284
1547
 
1285
- /**
1286
- * Computing the full possible paths may be possible but is hard to compute
1287
- * within the type system for complex document types so we use string.
1288
- * @beta
1289
- */
1290
- export declare type JsonMatchPath<_TDocument extends SanityDocumentLike> = string
1291
-
1292
1548
  /**
1293
1549
  * Loads more users for a specific resource.
1294
1550
  *
@@ -1419,6 +1675,17 @@ declare interface ObjectSplatNode extends BaseNode {
1419
1675
 
1420
1676
  declare type ObjectValue = StaticValue<Record<string, unknown>, 'object'>
1421
1677
 
1678
+ /**
1679
+ * Creates an observable that emits the organization verification state for a given instance.
1680
+ * It combines the dashboard organization ID (from auth context) with the
1681
+ * project's actual organization ID (fetched via getProjectState) and compares them.
1682
+ * @public
1683
+ */
1684
+ export declare function observeOrganizationVerificationState(
1685
+ instance: SanityInstance,
1686
+ projectIds: string[],
1687
+ ): Observable<OrgVerificationResult>
1688
+
1422
1689
  declare type OpCall =
1423
1690
  | '=='
1424
1691
  | '!='
@@ -1447,6 +1714,14 @@ declare type OptimisticLock = {
1447
1714
  ifPublishedRevisionId?: string
1448
1715
  }
1449
1716
 
1717
+ /**
1718
+ * Error message returned by the organization verification
1719
+ * @public
1720
+ */
1721
+ export declare interface OrgVerificationResult {
1722
+ error: string | null
1723
+ }
1724
+
1450
1725
  declare interface OrNode extends BaseNode {
1451
1726
  type: 'Or'
1452
1727
  left: ExprNode
@@ -1474,55 +1749,8 @@ declare interface ParentNode_2 extends BaseNode {
1474
1749
  n: number
1475
1750
  }
1476
1751
 
1477
- /**
1478
- * Parse one or more bracketed parts from a segment.
1479
- *
1480
- * It recursively “peels off” a bracketed part and then continues.
1481
- *
1482
- * For example, given the string:
1483
- *
1484
- * ```
1485
- * "[0][foo]"
1486
- * ```
1487
- *
1488
- * it produces:
1489
- *
1490
- * ```
1491
- * [ToNumber<"0">, "foo"]
1492
- * ```
1493
- */
1494
- declare type ParseBracket<TInput extends string> = TInput extends `[${infer TPart}]${infer TRest}`
1495
- ? [ToNumber<TPart>, ...ParseSegment<TRest>]
1496
- : []
1497
-
1498
1752
  /** @beta */
1499
- export declare const parseQueryKey: (key: string) => {
1500
- query: string
1501
- options: QueryOptions
1502
- }
1503
-
1504
- /**
1505
- * Parse a single “segment” that may include bracket parts.
1506
- *
1507
- * For example, the literal
1508
- *
1509
- * ```
1510
- * "friends[0][1]"
1511
- * ```
1512
- *
1513
- * is parsed as:
1514
- *
1515
- * ```
1516
- * ["friends", 0, 1]
1517
- * ```
1518
- */
1519
- declare type ParseSegment<TInput extends string> = TInput extends `${infer TProp}[${infer TRest}`
1520
- ? TProp extends ''
1521
- ? [...ParseBracket<`[${TRest}`>]
1522
- : [TProp, ...ParseBracket<`[${TRest}`>]
1523
- : TInput extends ''
1524
- ? []
1525
- : [TInput]
1753
+ export declare const parseQueryKey: (key: string) => QueryOptions
1526
1754
 
1527
1755
  /** @internal */
1528
1756
  export declare const parseUsersKey: (key: string) => {
@@ -1541,7 +1769,7 @@ declare class Path {
1541
1769
  }
1542
1770
 
1543
1771
  /**
1544
- * Split the entire path string on dots outside of any brackets.
1772
+ * Split the entire path string on dots "outside" of any brackets.
1545
1773
  *
1546
1774
  * For example:
1547
1775
  * ```
@@ -1556,9 +1784,11 @@ declare class Path {
1556
1784
  *
1557
1785
  * (We use a simple recursion that splits on the first dot.)
1558
1786
  */
1559
- declare type PathParts<TPath extends string> = TPath extends `${infer TLeft}.${infer TRight}`
1560
- ? [...ParseSegment<TLeft>, ...PathParts<TRight>]
1561
- : ParseSegment<TPath>
1787
+ declare type PathParts<TPath extends string> = TPath extends `${infer Head}.${infer Tail}`
1788
+ ? [Head, ...PathParts<Tail>]
1789
+ : TPath extends ''
1790
+ ? []
1791
+ : [TPath]
1562
1792
 
1563
1793
  declare type PathValue = StaticValue<Path, 'path'>
1564
1794
 
@@ -1569,6 +1799,13 @@ export declare interface PermissionDeniedReason {
1569
1799
  documentId?: string
1570
1800
  }
1571
1801
 
1802
+ /**
1803
+ * @public
1804
+ */
1805
+ export declare interface PerspectiveHandle {
1806
+ perspective?: ClientPerspective | ReleasePerspective
1807
+ }
1808
+
1572
1809
  declare interface PipeFuncCallNode extends BaseNode {
1573
1810
  type: 'PipeFuncCall'
1574
1811
  func: GroqPipeFunction
@@ -1640,10 +1877,11 @@ export declare interface PreviewValue {
1640
1877
  }
1641
1878
 
1642
1879
  /**
1880
+ * Represents the minimal configuration required to identify a Sanity project.
1643
1881
  * @public
1644
1882
  */
1645
- export declare interface ProjectHandle {
1646
- projectId?: string | undefined
1883
+ export declare interface ProjectHandle<TProjectId extends string = string> {
1884
+ projectId?: TProjectId
1647
1885
  }
1648
1886
 
1649
1887
  declare interface ProjectionNode extends BaseNode {
@@ -1652,6 +1890,15 @@ declare interface ProjectionNode extends BaseNode {
1652
1890
  expr: ExprNode
1653
1891
  }
1654
1892
 
1893
+ declare interface ProjectionOptions<
1894
+ TProjection extends ValidProjection = ValidProjection,
1895
+ TDocumentType extends string = string,
1896
+ TDataset extends string = string,
1897
+ TProjectId extends string = string,
1898
+ > extends DocumentHandle<TDocumentType, TDataset, TProjectId> {
1899
+ projection: TProjection
1900
+ }
1901
+
1655
1902
  /**
1656
1903
  * @public
1657
1904
  * The result of a projection query
@@ -1661,27 +1908,43 @@ export declare interface ProjectionValuePending<TValue extends object> {
1661
1908
  isPending: boolean
1662
1909
  }
1663
1910
 
1664
- /** @beta */
1665
- export declare function publishDocument<TDocument extends SanityDocumentLike>(
1666
- doc: DocumentHandle<TDocument>,
1667
- ): PublishDocumentAction<TDocument>
1911
+ /**
1912
+ * Creates a `PublishDocumentAction` object.
1913
+ * @param doc - A handle uniquely identifying the document to be published.
1914
+ * @returns A `PublishDocumentAction` object ready for dispatch.
1915
+ * @beta
1916
+ */
1917
+ export declare function publishDocument<
1918
+ TDocumentType extends string = string,
1919
+ TDataset extends string = string,
1920
+ TProjectId extends string = string,
1921
+ >(
1922
+ doc: DocumentHandle<TDocumentType, TDataset, TProjectId>,
1923
+ ): PublishDocumentAction<TDocumentType, TDataset, TProjectId>
1668
1924
 
1669
- /** @beta */
1925
+ /**
1926
+ * Represents an action to publish the draft version of a document.
1927
+ * Requires the full document handle.
1928
+ * @beta
1929
+ */
1670
1930
  export declare interface PublishDocumentAction<
1671
- TDocument extends SanityDocumentLike = SanityDocumentLike,
1672
- > extends DocumentHandle<TDocument> {
1931
+ TDocumentType extends string = string,
1932
+ TDataset extends string = string,
1933
+ TProjectId extends string = string,
1934
+ > extends DocumentHandle<TDocumentType, TDataset, TProjectId> {
1673
1935
  type: 'document.publish'
1674
1936
  }
1675
1937
 
1676
1938
  /**
1677
1939
  * @beta
1678
1940
  */
1679
- export declare interface QueryOptions
1680
- extends Pick<
1681
- ResponseQueryOptions,
1682
- 'perspective' | 'useCdn' | 'cache' | 'next' | 'cacheMode' | 'tag'
1683
- >,
1684
- DatasetHandle {
1941
+ export declare interface QueryOptions<
1942
+ TQuery extends string = string,
1943
+ TDataset extends string = string,
1944
+ TProjectId extends string = string,
1945
+ > extends Pick<ResponseQueryOptions, 'useCdn' | 'cache' | 'next' | 'cacheMode' | 'tag'>,
1946
+ DatasetHandle<TDataset, TProjectId> {
1947
+ query: TQuery
1685
1948
  params?: Record<string, unknown>
1686
1949
  }
1687
1950
 
@@ -1718,30 +1981,74 @@ export declare const releaseChannel: BoundStoreAction_2<
1718
1981
  void
1719
1982
  >
1720
1983
 
1984
+ /**
1985
+ * Represents a document in a Sanity dataset that represents release options.
1986
+ * @internal
1987
+ */
1988
+ export declare type ReleaseDocument = SanityDocument & {
1989
+ name: string
1990
+ publishAt?: string
1991
+ metadata: {
1992
+ title: string
1993
+ releaseType: 'asap' | 'scheduled' | 'undecided'
1994
+ intendedPublishAt?: string
1995
+ }
1996
+ }
1997
+
1721
1998
  /**
1722
1999
  * Signals to the store that the consumer has stopped using the node
1723
2000
  * @public
1724
2001
  */
1725
2002
  export declare const releaseNode: BoundStoreAction_2<ComlinkNodeState, [name: string], void>
1726
2003
 
2004
+ /**
2005
+ * @public
2006
+ */
2007
+ declare type ReleasePerspective = {
2008
+ releaseName: string
2009
+ excludedPerspectives?: StackablePerspective[]
2010
+ }
2011
+
2012
+ declare interface ReleasesStoreState {
2013
+ activeReleases?: ReleaseDocument[]
2014
+ error?: unknown
2015
+ }
2016
+
1727
2017
  /** @public */
1728
2018
  export declare const resolveDatasets: BoundStoreAction<
1729
- FetcherStoreState_2<[options?: ProjectHandle | undefined], DatasetsResponse>,
1730
- [options?: ProjectHandle | undefined],
2019
+ FetcherStoreState_2<[options?: ProjectHandle<string> | undefined], DatasetsResponse>,
2020
+ [options?: ProjectHandle<string> | undefined],
1731
2021
  Promise<DatasetsResponse>
1732
2022
  >
1733
2023
 
1734
2024
  /** @beta */
1735
- export declare function resolveDocument<TDocument extends SanityDocument>(
2025
+ export declare function resolveDocument<
2026
+ TDocumentType extends string = string,
2027
+ TDataset extends string = string,
2028
+ TProjectId extends string = string,
2029
+ >(
1736
2030
  instance: SanityInstance,
1737
- doc: string | DocumentHandle<TDocument>,
1738
- ): Promise<TDocument | null>
2031
+ docHandle: DocumentHandle<TDocumentType, TDataset, TProjectId>,
2032
+ ): Promise<SanityDocumentResult<TDocumentType, TDataset, TProjectId> | null>
1739
2033
 
1740
2034
  /** @beta */
1741
- export declare function resolveDocument(
2035
+ export declare function resolveDocument<TData extends SanityDocument>(
1742
2036
  instance: SanityInstance,
1743
- doc: string | DocumentHandle,
1744
- ): Promise<SanityDocument | null>
2037
+ docHandle: DocumentHandle<string, string, string>,
2038
+ ): Promise<TData | null>
2039
+
2040
+ /**
2041
+ * Resolves the favorite status for a document.
2042
+ * @param instance - The Sanity instance.
2043
+ * @param context - The document context including ID, type, and resource information.
2044
+ * @returns A Promise resolving to `{ isFavorited: boolean }`.
2045
+ * @public
2046
+ */
2047
+ export declare const resolveFavoritesState: BoundStoreAction<
2048
+ FetcherStoreState_2<[FavoriteDocumentContext], FavoriteStatusResponse>,
2049
+ [FavoriteDocumentContext],
2050
+ Promise<FavoriteStatusResponse>
2051
+ >
1745
2052
 
1746
2053
  /** @beta */
1747
2054
  export declare const resolvePermissions: BoundStoreAction<
@@ -1766,23 +2073,29 @@ export declare type ResolvePreviewOptions = DocumentHandle
1766
2073
 
1767
2074
  /** @public */
1768
2075
  export declare const resolveProject: BoundStoreAction<
1769
- FetcherStoreState_2<[options?: ProjectHandle | undefined], SanityProject_2>,
1770
- [options?: ProjectHandle | undefined],
2076
+ FetcherStoreState_2<[options?: ProjectHandle<string> | undefined], SanityProject_2>,
2077
+ [options?: ProjectHandle<string> | undefined],
1771
2078
  Promise<SanityProject_2>
1772
2079
  >
1773
2080
 
1774
- /**
1775
- * @beta
1776
- */
1777
- export declare const resolveProjection: BoundStoreAction<
1778
- ProjectionStoreState<object>,
1779
- [ResolveProjectionOptions],
1780
- Promise<ProjectionValuePending_2<object>>
2081
+ /** @beta */
2082
+ export declare function resolveProjection<
2083
+ TProjection extends ValidProjection = ValidProjection,
2084
+ TDocumentType extends string = string,
2085
+ TDataset extends string = string,
2086
+ TProjectId extends string = string,
2087
+ >(
2088
+ instance: SanityInstance,
2089
+ options: ProjectionOptions<TProjection, TDocumentType, TDataset, TProjectId>,
2090
+ ): Promise<
2091
+ ProjectionValuePending<SanityProjectionResult<TProjection, TDocumentType, TDataset, TProjectId>>
1781
2092
  >
1782
2093
 
1783
- declare interface ResolveProjectionOptions extends DocumentHandle {
1784
- projection: ValidProjection
1785
- }
2094
+ /** @beta */
2095
+ export declare function resolveProjection<TData extends object>(
2096
+ instance: SanityInstance,
2097
+ options: ProjectionOptions,
2098
+ ): Promise<ProjectionValuePending<TData>>
1786
2099
 
1787
2100
  /** @public */
1788
2101
  export declare const resolveProjects: BoundStoreAction<
@@ -1805,23 +2118,29 @@ export declare const resolveProjects: BoundStoreAction<
1805
2118
  *
1806
2119
  * @beta
1807
2120
  */
1808
- export declare function resolveQuery<T>(
2121
+ export declare function resolveQuery<
2122
+ TQuery extends string = string,
2123
+ TDataset extends string = string,
2124
+ TProjectId extends string = string,
2125
+ >(
1809
2126
  instance: SanityInstance,
1810
- query: string,
1811
- options?: ResolveQueryOptions,
1812
- ): Promise<T>
2127
+ queryOptions: ResolveQueryOptions<TQuery, TDataset, TProjectId>,
2128
+ ): Promise<SanityQueryResult<TQuery, TDataset, TProjectId>>
1813
2129
 
1814
2130
  /** @beta */
1815
- export declare function resolveQuery(
2131
+ export declare function resolveQuery<TData>(
1816
2132
  instance: SanityInstance,
1817
- query: string,
1818
- options?: ResolveQueryOptions,
1819
- ): Promise<unknown>
2133
+ queryOptions: ResolveQueryOptions,
2134
+ ): Promise<TData>
1820
2135
 
1821
2136
  /**
1822
2137
  * @beta
1823
2138
  */
1824
- declare interface ResolveQueryOptions extends QueryOptions {
2139
+ declare interface ResolveQueryOptions<
2140
+ TQuery extends string = string,
2141
+ TDataset extends string = string,
2142
+ TProjectId extends string = string,
2143
+ > extends QueryOptions<TQuery, TDataset, TProjectId> {
1825
2144
  signal?: AbortSignal
1826
2145
  }
1827
2146
 
@@ -1863,7 +2182,7 @@ export {Role}
1863
2182
  * Represents the complete configuration for a Sanity SDK instance
1864
2183
  * @public
1865
2184
  */
1866
- export declare interface SanityConfig extends DatasetHandle {
2185
+ export declare interface SanityConfig extends DatasetHandle, PerspectiveHandle {
1867
2186
  /**
1868
2187
  * Authentication configuration for the instance
1869
2188
  * @remarks Merged with parent configurations when using createChild
@@ -1880,8 +2199,6 @@ export declare interface SanityConfig extends DatasetHandle {
1880
2199
 
1881
2200
  export {SanityDocument}
1882
2201
 
1883
- export {SanityDocumentLike}
1884
-
1885
2202
  /**
1886
2203
  * Represents a Sanity.io resource instance with its own configuration and lifecycle
1887
2204
  * @remarks Instances form a hierarchy through parent/child relationships
@@ -2122,10 +2439,6 @@ declare interface ThisNode extends BaseNode {
2122
2439
  type: 'This'
2123
2440
  }
2124
2441
 
2125
- declare type ToNumber<TInput extends string> = TInput extends `${infer TNumber extends number}`
2126
- ? TNumber
2127
- : TInput
2128
-
2129
2442
  /**
2130
2443
  * @beta
2131
2444
  * Event emitted when a transaction is accepted.
@@ -2152,15 +2465,30 @@ declare interface TupleNode extends BaseNode {
2152
2465
  members: Array<ExprNode>
2153
2466
  }
2154
2467
 
2155
- /** @beta */
2156
- export declare function unpublishDocument<TDocument extends SanityDocumentLike>(
2157
- doc: DocumentHandle<TDocument>,
2158
- ): UnpublishDocumentAction<TDocument>
2468
+ /**
2469
+ * Creates an `UnpublishDocumentAction` object.
2470
+ * @param doc - A handle uniquely identifying the document to be unpublished.
2471
+ * @returns An `UnpublishDocumentAction` object ready for dispatch.
2472
+ * @beta
2473
+ */
2474
+ export declare function unpublishDocument<
2475
+ TDocumentType extends string = string,
2476
+ TDataset extends string = string,
2477
+ TProjectId extends string = string,
2478
+ >(
2479
+ doc: DocumentHandle<TDocumentType, TDataset, TProjectId>,
2480
+ ): UnpublishDocumentAction<TDocumentType, TDataset, TProjectId>
2159
2481
 
2160
- /** @beta */
2482
+ /**
2483
+ * Represents an action to unpublish a document, moving its published content to a draft.
2484
+ * Requires the full document handle.
2485
+ * @beta
2486
+ */
2161
2487
  export declare interface UnpublishDocumentAction<
2162
- TDocument extends SanityDocumentLike = SanityDocumentLike,
2163
- > extends DocumentHandle<TDocument> {
2488
+ TDocumentType extends string = string,
2489
+ TDataset extends string = string,
2490
+ TProjectId extends string = string,
2491
+ > extends DocumentHandle<TDocumentType, TDataset, TProjectId> {
2164
2492
  type: 'document.unpublish'
2165
2493
  }
2166
2494