@sanity/sdk 2.8.0 → 3.0.0-rc.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 (99) hide show
  1. package/dist/index.d.ts +228 -239
  2. package/dist/index.js +287 -454
  3. package/dist/index.js.map +1 -1
  4. package/package.json +4 -4
  5. package/src/_exports/index.ts +16 -17
  6. package/src/agent/agentActions.test.ts +60 -16
  7. package/src/agent/agentActions.ts +29 -20
  8. package/src/auth/authMode.test.ts +0 -25
  9. package/src/auth/authMode.ts +3 -6
  10. package/src/auth/authStore.test.ts +129 -66
  11. package/src/auth/authStore.ts +9 -11
  12. package/src/auth/dashboardAuth.ts +2 -2
  13. package/src/auth/getOrganizationVerificationState.test.ts +10 -11
  14. package/src/auth/handleAuthCallback.test.ts +0 -12
  15. package/src/auth/handleAuthCallback.ts +9 -3
  16. package/src/auth/logout.test.ts +0 -6
  17. package/src/auth/refreshStampedToken.test.ts +121 -17
  18. package/src/auth/standaloneAuth.ts +9 -3
  19. package/src/auth/studioAuth.ts +35 -8
  20. package/src/auth/subscribeToStateAndFetchCurrentUser.test.ts +9 -3
  21. package/src/auth/subscribeToStateAndFetchCurrentUser.ts +1 -1
  22. package/src/auth/subscribeToStorageEventsAndSetToken.test.ts +0 -2
  23. package/src/auth/subscribeToStorageEventsAndSetToken.ts +2 -2
  24. package/src/auth/utils.ts +33 -0
  25. package/src/client/clientStore.test.ts +14 -61
  26. package/src/client/clientStore.ts +52 -28
  27. package/src/comlink/controller/actions/destroyController.test.ts +1 -4
  28. package/src/comlink/controller/actions/getOrCreateChannel.test.ts +1 -4
  29. package/src/comlink/controller/actions/getOrCreateController.test.ts +1 -4
  30. package/src/comlink/controller/actions/releaseChannel.test.ts +1 -1
  31. package/src/comlink/controller/comlinkControllerStore.test.ts +1 -4
  32. package/src/comlink/node/actions/getOrCreateNode.test.ts +1 -4
  33. package/src/comlink/node/actions/releaseNode.test.ts +1 -4
  34. package/src/comlink/node/comlinkNodeStore.test.ts +2 -2
  35. package/src/comlink/node/getNodeState.test.ts +1 -1
  36. package/src/config/__tests__/handles.test.ts +12 -18
  37. package/src/config/handles.ts +7 -25
  38. package/src/config/sanityConfig.ts +99 -52
  39. package/src/datasets/datasets.test.ts +2 -2
  40. package/src/datasets/datasets.ts +4 -10
  41. package/src/document/actions.test.ts +33 -4
  42. package/src/document/actions.ts +3 -10
  43. package/src/document/applyDocumentActions.test.ts +17 -18
  44. package/src/document/applyDocumentActions.ts +9 -12
  45. package/src/document/documentStore.test.ts +303 -133
  46. package/src/document/documentStore.ts +70 -61
  47. package/src/document/permissions.test.ts +44 -8
  48. package/src/document/processActions.test.ts +77 -7
  49. package/src/document/reducers.test.ts +35 -3
  50. package/src/document/sharedListener.test.ts +13 -13
  51. package/src/document/sharedListener.ts +8 -3
  52. package/src/favorites/favorites.test.ts +10 -2
  53. package/src/presence/presenceStore.test.ts +34 -9
  54. package/src/presence/presenceStore.ts +29 -13
  55. package/src/preview/previewProjectionUtils.test.ts +192 -0
  56. package/src/preview/previewProjectionUtils.ts +88 -0
  57. package/src/preview/{previewStore.ts → types.ts} +6 -25
  58. package/src/project/project.test.ts +1 -1
  59. package/src/project/project.ts +14 -20
  60. package/src/projection/getProjectionState.test.ts +4 -2
  61. package/src/projection/getProjectionState.ts +2 -21
  62. package/src/projection/projectionQuery.ts +2 -3
  63. package/src/projection/projectionStore.test.ts +3 -3
  64. package/src/projection/resolveProjection.test.ts +2 -1
  65. package/src/projection/resolveProjection.ts +2 -18
  66. package/src/projection/subscribeToStateAndFetchBatches.test.ts +2 -2
  67. package/src/projection/subscribeToStateAndFetchBatches.ts +23 -36
  68. package/src/projection/types.ts +1 -9
  69. package/src/projects/projects.test.ts +1 -1
  70. package/src/query/queryStore.test.ts +86 -28
  71. package/src/query/queryStore.ts +23 -38
  72. package/src/releases/getPerspectiveState.test.ts +14 -13
  73. package/src/releases/getPerspectiveState.ts +6 -6
  74. package/src/releases/releasesStore.test.ts +21 -6
  75. package/src/releases/releasesStore.ts +18 -8
  76. package/src/store/createActionBinder.test.ts +114 -111
  77. package/src/store/createActionBinder.ts +52 -101
  78. package/src/store/createSanityInstance.test.ts +13 -83
  79. package/src/store/createSanityInstance.ts +2 -78
  80. package/src/store/createStateSourceAction.test.ts +2 -2
  81. package/src/store/createStateSourceAction.ts +5 -5
  82. package/src/store/createStoreInstance.test.ts +2 -4
  83. package/src/users/reducers.test.ts +1 -6
  84. package/src/users/reducers.ts +2 -2
  85. package/src/users/types.ts +4 -4
  86. package/src/users/usersStore.test.ts +12 -15
  87. package/src/utils/createFetcherStore.test.ts +1 -1
  88. package/src/utils/logger.test.ts +0 -12
  89. package/src/utils/logger.ts +3 -8
  90. package/src/preview/getPreviewState.test.ts +0 -120
  91. package/src/preview/getPreviewState.ts +0 -91
  92. package/src/preview/previewQuery.test.ts +0 -236
  93. package/src/preview/previewQuery.ts +0 -153
  94. package/src/preview/previewStore.test.ts +0 -36
  95. package/src/preview/resolvePreview.test.ts +0 -47
  96. package/src/preview/resolvePreview.ts +0 -20
  97. package/src/preview/subscribeToStateAndFetchBatches.test.ts +0 -221
  98. package/src/preview/subscribeToStateAndFetchBatches.ts +0 -112
  99. package/src/preview/util.ts +0 -13
package/dist/index.d.ts CHANGED
@@ -2,12 +2,11 @@ import * as _sanity_client12 from "@sanity/client";
2
2
  import { ClientConfig, ClientError, ClientPerspective, ListenEvent, ResponseQueryOptions, SanityClient, SanityDocument as SanityDocument$1, SanityProject as SanityProject$1, StackablePerspective } from "@sanity/client";
3
3
  import { Observable, Subject } from "rxjs";
4
4
  import { CurrentUser, CurrentUser as CurrentUser$1, Mutation, PatchOperations, Role, SanityDocument, SanityDocument as SanityDocument$2, SanityDocumentLike } from "@sanity/types";
5
- import * as _sanity_comlink3 from "@sanity/comlink";
5
+ import * as _sanity_comlink5 from "@sanity/comlink";
6
6
  import { ChannelInput, ChannelInstance, Controller, Message, Node, NodeInput, Status } from "@sanity/comlink";
7
7
  import { PatchMutation } from "@sanity/mutate/_unstable_store";
8
- import { SanityDocument as SanityDocument$3, SanityProjectionResult, SanityQueryResult } from "groq";
9
8
  import { ExprNode } from "groq-js";
10
- import { CanvasResource, MediaResource, StudioResource } from "@sanity/message-protocol";
9
+ import { CanvasResource as CanvasResource$1, MediaResource, StudioResource } from "@sanity/message-protocol";
11
10
  import { getIndexForKey, getPathDepth, joinPaths, jsonMatch, slicePath, stringifyPath } from "@sanity/json-match";
12
11
  /**
13
12
  * Configuration for an authentication provider
@@ -100,6 +99,12 @@ interface TokenSource {
100
99
  * @public
101
100
  */
102
101
  interface StudioConfig {
102
+ /**
103
+ * Whether the Studio has already determined the user is authenticated.
104
+ * When `true` and the token source emits `null`, the SDK infers
105
+ * cookie-based auth is in use rather than transitioning to logged-out.
106
+ */
107
+ authenticated?: boolean;
103
108
  /** Reactive auth token source from the Studio's auth store. */
104
109
  auth?: {
105
110
  /**
@@ -111,13 +116,12 @@ interface StudioConfig {
111
116
  */
112
117
  token?: TokenSource;
113
118
  };
114
- }
115
- /**
116
- * Represents the minimal configuration required to identify a Sanity project.
117
- * @public
118
- */
119
- interface ProjectHandle<TProjectId extends string = string> {
120
- projectId?: TProjectId;
119
+ /**
120
+ * The project ID for this Studio workspace.
121
+ * Used to derive the localStorage key for studio auth token discovery
122
+ * (`__studio_auth_token_<projectId>`) and for project-specific API hostname requests.
123
+ */
124
+ projectId?: string;
121
125
  }
122
126
  /**
123
127
  * @public
@@ -130,18 +134,23 @@ type ReleasePerspective = {
130
134
  * @public
131
135
  */
132
136
  interface PerspectiveHandle {
133
- perspective?: ClientPerspective | ReleasePerspective;
137
+ /**
138
+ * The perspective to use for this operation.
139
+ * Note that the SDK stacks perspectives for you when querying.
140
+ * The SDK automatically fetches all of your content releases, and orders them the way the Sanity Studio does: usually by scheduled date, with ASAP releases coming first.
141
+ * @public
142
+ */
143
+ perspective?: Exclude<ClientPerspective, readonly unknown[]> | ReleasePerspective;
134
144
  }
135
145
  /**
136
146
  * @public
137
147
  */
138
- interface DatasetHandle<TDataset extends string = string, TProjectId extends string = string> extends ProjectHandle<TProjectId>, PerspectiveHandle {
139
- dataset?: TDataset;
148
+ interface ResourceHandle<TProjectId extends string = string, TDataset extends string = string> extends PerspectiveHandle {
140
149
  /**
141
- * @beta
142
- * Explicit source object to use for this operation.
150
+ * Explicit resource object to use for this operation.
151
+ * @public
143
152
  */
144
- source?: DocumentSource;
153
+ resource: DocumentResource<TProjectId, TDataset>;
145
154
  }
146
155
  /**
147
156
  * Identifies a specific document type within a Sanity dataset and project.
@@ -149,7 +158,7 @@ interface DatasetHandle<TDataset extends string = string, TProjectId extends str
149
158
  * Optionally includes a `documentId` and `liveEdit` flag.
150
159
  * @public
151
160
  */
152
- interface DocumentTypeHandle<TDocumentType extends string = string, TDataset extends string = string, TProjectId extends string = string> extends DatasetHandle<TDataset, TProjectId> {
161
+ interface DocumentTypeHandle<TDocumentType extends string = string, TDataset extends string = string, TProjectId extends string = string> extends ResourceHandle<TDataset, TProjectId> {
153
162
  documentId?: string;
154
163
  documentType: TDocumentType;
155
164
  /**
@@ -169,13 +178,43 @@ interface DocumentHandle<TDocumentType extends string = string, TDataset extends
169
178
  documentId: string;
170
179
  }
171
180
  /**
172
- * Represents the complete configuration for a Sanity SDK instance
181
+ * The key used to identify the default resource in a resources map.
182
+ * When no `resource` or `resourceName` is specified, the SDK resolves
183
+ * the resource registered under this name.
184
+ *
185
+ * @public
186
+ */
187
+ declare const DEFAULT_RESOURCE_NAME = "default";
188
+ /**
189
+ * Represents the complete configuration for a Sanity SDK instance.
190
+ *
191
+ * Most apps configure resources via the `resources` prop on `SanityApp`:
192
+ *
193
+ * @example Typical React usage
194
+ * ```tsx
195
+ * <SanityApp
196
+ * resources={{ default: { projectId: 'abc123', dataset: 'production' } }}
197
+ * fallback={<Loading />}
198
+ * >
199
+ * <App />
200
+ * </SanityApp>
201
+ * ```
202
+ *
203
+ * The `defaultResource` field is set automatically by the React layer from
204
+ * `resources['default']`. It can also be set directly when using the core
205
+ * SDK without React (e.g. in a Node.js script):
206
+ *
207
+ * @example Direct core usage (without React)
208
+ * ```ts
209
+ * const instance = createSanityInstance({
210
+ * defaultResource: { projectId: 'abc123', dataset: 'production' },
211
+ * })
212
+ * ```
173
213
  * @public
174
214
  */
175
- interface SanityConfig extends DatasetHandle, PerspectiveHandle {
215
+ interface SanityConfig extends PerspectiveHandle {
176
216
  /**
177
217
  * Authentication configuration for the instance
178
- * @remarks Merged with parent configurations when using createChild
179
218
  */
180
219
  auth?: AuthConfig;
181
220
  /**
@@ -188,61 +227,59 @@ interface SanityConfig extends DatasetHandle, PerspectiveHandle {
188
227
  */
189
228
  studio?: StudioConfig;
190
229
  /**
191
- * Studio mode configuration for use of the SDK in a Sanity Studio.
192
- * @remarks Controls whether studio mode features are enabled.
193
- * @deprecated Use `studio` instead, which provides richer integration
194
- * with the Studio's workspace (auth token sync, etc.).
195
- */
196
- studioMode?: {
197
- enabled: boolean;
198
- };
199
- /**
200
- * @beta
201
- * A list of named sources to use for this instance.
230
+ * The default document resource for this instance. Used by bound actions
231
+ * when no explicit resource is provided.
232
+ *
233
+ * @public
202
234
  */
203
- sources?: Record<string, DocumentSource>;
235
+ defaultResource?: DocumentResource;
204
236
  }
205
237
  /**
206
- * A document source can be used for querying.
207
- * This will soon be the default way to identify where you are querying from.
238
+ * A document resource identifies where data is stored and queried from.
239
+ * Can be a dataset (project + dataset pair), a media library, or a canvas.
208
240
  *
209
- * @beta
241
+ * @public
210
242
  */
211
- type DocumentSource = DatasetSource | MediaLibrarySource | CanvasSource;
243
+ type DocumentResource<TProjectId extends string = string, TDataset extends string = string> = DatasetResource<TProjectId, TDataset> | MediaLibraryResource | CanvasResource;
212
244
  /**
213
- * @beta
245
+ * A resource that targets a specific project and dataset.
246
+ * @public
214
247
  */
215
- type DatasetSource = {
216
- projectId: string;
217
- dataset: string;
248
+ type DatasetResource<TProjectId extends string = string, TDataset extends string = string> = {
249
+ projectId: TProjectId;
250
+ dataset: TDataset;
218
251
  };
219
252
  /**
220
- * @beta
253
+ * A resource that targets a media library.
254
+ * @public
221
255
  */
222
- type MediaLibrarySource = {
256
+ type MediaLibraryResource = {
223
257
  mediaLibraryId: string;
224
258
  };
225
259
  /**
226
- * @beta
260
+ * A resource that targets a canvas.
261
+ * @public
227
262
  */
228
- type CanvasSource = {
263
+ type CanvasResource = {
229
264
  canvasId: string;
230
265
  };
231
266
  /**
232
- * @beta
267
+ * Type guard that checks whether a {@link DocumentResource} is a {@link DatasetResource}.
268
+ * @public
233
269
  */
234
- declare function isDatasetSource(source: DocumentSource): source is DatasetSource;
270
+ declare function isDatasetResource(resource: DocumentResource): resource is DatasetResource;
235
271
  /**
236
- * @beta
272
+ * Type guard that checks whether a {@link DocumentResource} is a {@link MediaLibraryResource}.
273
+ * @public
237
274
  */
238
- declare function isMediaLibrarySource(source: DocumentSource): source is MediaLibrarySource;
275
+ declare function isMediaLibraryResource(resource: DocumentResource): resource is MediaLibraryResource;
239
276
  /**
240
- * @beta
277
+ * Type guard that checks whether a {@link DocumentResource} is a {@link CanvasResource}.
278
+ * @public
241
279
  */
242
- declare function isCanvasSource(source: DocumentSource): source is CanvasSource;
280
+ declare function isCanvasResource(resource: DocumentResource): resource is CanvasResource;
243
281
  /**
244
- * Represents a Sanity.io resource instance with its own configuration and lifecycle
245
- * @remarks Instances form a hierarchy through parent/child relationships
282
+ * Represents a Sanity.io resource instance with its own configuration and lifecycle.
246
283
  *
247
284
  * @public
248
285
  */
@@ -252,10 +289,7 @@ interface SanityInstance {
252
289
  * @remarks Generated using crypto.randomUUID()
253
290
  */
254
291
  readonly instanceId: string;
255
- /**
256
- * Resolved configuration for this instance
257
- * @remarks Merges values from parent instances where appropriate
258
- */
292
+ /** Resolved configuration for this instance */
259
293
  readonly config: SanityConfig;
260
294
  /**
261
295
  * Checks if the instance has been disposed
@@ -273,34 +307,22 @@ interface SanityInstance {
273
307
  * @returns Function to unsubscribe the callback
274
308
  */
275
309
  onDispose(cb: () => void): () => void;
276
- /**
277
- * Gets the parent instance in the hierarchy
278
- * @returns Parent instance or undefined if this is the root
279
- */
280
- getParent(): SanityInstance | undefined;
281
- /**
282
- * Creates a child instance with merged configuration
283
- * @param config - Configuration to merge with parent values
284
- * @remarks Child instances inherit parent configuration but can override values
285
- */
286
- createChild(config: SanityConfig): SanityInstance;
287
- /**
288
- * Traverses the instance hierarchy to find the first instance whose configuration
289
- * matches the given target config using a shallow comparison.
290
- * @param targetConfig - A partial configuration object containing key-value pairs to match.
291
- * @returns The first matching instance or undefined if no match is found.
292
- */
293
- match(targetConfig: Partial<SanityConfig>): SanityInstance | undefined;
294
310
  }
295
311
  /**
296
312
  * Creates a new Sanity resource instance
297
313
  * @param config - Configuration for the instance (optional)
298
314
  * @returns A configured SanityInstance
299
- * @remarks When creating child instances, configurations are merged with parent values
300
315
  *
301
316
  * @public
302
317
  */
303
318
  declare function createSanityInstance(config?: SanityConfig): SanityInstance;
319
+ /**
320
+ * Options that all agent actions accept for targeting a specific resource.
321
+ * @alpha
322
+ */
323
+ interface AgentResourceOptions {
324
+ resource: DocumentResource;
325
+ }
304
326
  /** @alpha */
305
327
  type AgentGenerateOptions = Parameters<SanityClient['observable']['agent']['action']['generate']>[0];
306
328
  /** @alpha */
@@ -328,7 +350,7 @@ type AgentPatchResult = Awaited<ReturnType<SanityClient['agent']['action']['patc
328
350
  * @returns An Observable emitting the result of the agent generate action.
329
351
  * @alpha
330
352
  */
331
- declare function agentGenerate(instance: SanityInstance, options: AgentGenerateOptions): AgentGenerateResult;
353
+ declare function agentGenerate(instance: SanityInstance, options: AgentGenerateOptions & AgentResourceOptions): AgentGenerateResult;
332
354
  /**
333
355
  * Transforms a document using the agent.
334
356
  * @param instance - The Sanity instance.
@@ -336,7 +358,7 @@ declare function agentGenerate(instance: SanityInstance, options: AgentGenerateO
336
358
  * @returns An Observable emitting the result of the agent transform action.
337
359
  * @alpha
338
360
  */
339
- declare function agentTransform(instance: SanityInstance, options: AgentTransformOptions): AgentTransformResult;
361
+ declare function agentTransform(instance: SanityInstance, options: AgentTransformOptions & AgentResourceOptions): AgentTransformResult;
340
362
  /**
341
363
  * Translates a document using the agent.
342
364
  * @param instance - The Sanity instance.
@@ -344,7 +366,7 @@ declare function agentTransform(instance: SanityInstance, options: AgentTransfor
344
366
  * @returns An Observable emitting the result of the agent translate action.
345
367
  * @alpha
346
368
  */
347
- declare function agentTranslate(instance: SanityInstance, options: AgentTranslateOptions): AgentTranslateResult;
369
+ declare function agentTranslate(instance: SanityInstance, options: AgentTranslateOptions & AgentResourceOptions): AgentTranslateResult;
348
370
  /**
349
371
  * Prompts the agent using the same instruction template format as the other actions, but returns text or json instead of acting on a document.
350
372
  * @param instance - The Sanity instance.
@@ -352,7 +374,7 @@ declare function agentTranslate(instance: SanityInstance, options: AgentTranslat
352
374
  * @returns An Observable emitting the result of the agent prompt action.
353
375
  * @alpha
354
376
  */
355
- declare function agentPrompt(instance: SanityInstance, options: AgentPromptOptions): Observable<AgentPromptResult>;
377
+ declare function agentPrompt(instance: SanityInstance, options: AgentPromptOptions & AgentResourceOptions): Observable<AgentPromptResult>;
356
378
  /**
357
379
  * Patches a document using the agent.
358
380
  * @param instance - The Sanity instance.
@@ -360,11 +382,9 @@ declare function agentPrompt(instance: SanityInstance, options: AgentPromptOptio
360
382
  * @returns An Observable emitting the result of the agent patch action.
361
383
  * @alpha
362
384
  */
363
- declare function agentPatch(instance: SanityInstance, options: AgentPatchOptions): Observable<AgentPatchResult>;
385
+ declare function agentPatch(instance: SanityInstance, options: AgentPatchOptions & AgentResourceOptions): Observable<AgentPatchResult>;
364
386
  /**
365
387
  * Returns `true` when the config indicates the SDK is running inside a Studio.
366
- * Checks the new `studio` field first, then falls back to the deprecated
367
- * `studioMode.enabled` for backwards compatibility.
368
388
  *
369
389
  * @internal
370
390
  */
@@ -614,7 +634,12 @@ interface ClientStoreState {
614
634
  *
615
635
  * @public
616
636
  */
617
- interface ClientOptions extends Pick<ClientConfig, AllowedClientConfigKey> {
637
+ interface ClientOptions extends Omit<Pick<ClientConfig, AllowedClientConfigKey>, 'resource'> {
638
+ /**
639
+ * Narrows the inherited `perspective` to exclude stackable perspectives,
640
+ * which are not supported by the SDK.
641
+ */
642
+ 'perspective'?: Exclude<ClientPerspective, readonly unknown[]>;
618
643
  /**
619
644
  * An optional flag to choose between the default client (typically project-level)
620
645
  * and the global client ('global'). When set to `'global'`, the global client
@@ -632,7 +657,7 @@ interface ClientOptions extends Pick<ClientConfig, AllowedClientConfigKey> {
632
657
  /**
633
658
  * @internal
634
659
  */
635
- 'source'?: DocumentSource;
660
+ 'resource'?: DocumentResource;
636
661
  }
637
662
  /**
638
663
  * Retrieves a Sanity client instance configured with the provided options.
@@ -713,7 +738,7 @@ declare const destroyController: BoundStoreAction<ComlinkControllerState, [], vo
713
738
  * an application and the controller.
714
739
  * @public
715
740
  */
716
- declare const getOrCreateChannel: BoundStoreAction<ComlinkControllerState, [options: ChannelInput], ChannelInstance<_sanity_comlink3.Message, _sanity_comlink3.Message>>;
741
+ declare const getOrCreateChannel: BoundStoreAction<ComlinkControllerState, [options: ChannelInput], ChannelInstance<_sanity_comlink5.Message, _sanity_comlink5.Message>>;
717
742
  /**
718
743
  * Initializes or fetches a controller to handle communication
719
744
  * between an application and iframes.
@@ -754,7 +779,7 @@ declare const releaseNode: BoundStoreAction<ComlinkNodeState, [name: string], vo
754
779
  * be created within a frame / window to communicate with the controller.
755
780
  * @public
756
781
  */
757
- declare const getOrCreateNode: BoundStoreAction<ComlinkNodeState, [options: NodeInput], Node<_sanity_comlink3.Message, _sanity_comlink3.Message>>;
782
+ declare const getOrCreateNode: BoundStoreAction<ComlinkNodeState, [options: NodeInput], Node<_sanity_comlink5.Message, _sanity_comlink5.Message>>;
758
783
  /**
759
784
  * @public
760
785
  */
@@ -788,21 +813,13 @@ declare function createDocumentHandle<TDocumentType extends string = string, TDa
788
813
  */
789
814
  declare function createDocumentTypeHandle<TDocumentType extends string = string, TDataset extends string = string, TProjectId extends string = string>(handle: DocumentTypeHandle<TDocumentType, TDataset, TProjectId>): DocumentTypeHandle<TDocumentType, TDataset, TProjectId>;
790
815
  /**
791
- * Creates or validates a `ProjectHandle` object.
792
- * Ensures the provided object conforms to the `ProjectHandle` interface.
793
- * @param handle - The object containing project identification properties.
794
- * @returns The validated `ProjectHandle` object.
795
- * @public
796
- */
797
- declare function createProjectHandle<TProjectId extends string = string>(handle: ProjectHandle<TProjectId>): ProjectHandle<TProjectId>;
798
- /**
799
- * Creates or validates a `DatasetHandle` object.
800
- * Ensures the provided object conforms to the `DatasetHandle` interface.
801
- * @param handle - The object containing dataset identification properties.
802
- * @returns The validated `DatasetHandle` object.
816
+ * Creates or validates a `ResourceHandle` object.
817
+ * Ensures the provided object conforms to the `ResourceHandle` interface.
818
+ * @param handle - The object containing resource identification properties.
819
+ * @returns The validated `ResourceHandle` object.
803
820
  * @public
804
821
  */
805
- declare function createDatasetHandle<TDataset extends string = string, TProjectId extends string = string>(handle: DatasetHandle<TDataset, TProjectId>): DatasetHandle<TDataset, TProjectId>;
822
+ declare function createResourceHandle<TDataset extends string = string, TProjectId extends string = string>(handle: ResourceHandle<TProjectId, TDataset>): ResourceHandle<TProjectId, TDataset>;
806
823
  /**
807
824
  * Logging infrastructure for the Sanity SDK
808
825
  *
@@ -947,9 +964,9 @@ interface LogContext {
947
964
  interface InstanceContext {
948
965
  /** Unique instance ID */
949
966
  instanceId?: string;
950
- /** Project ID */
967
+ /** Project ID (derived from default resource) */
951
968
  projectId?: string;
952
- /** Dataset name */
969
+ /** Dataset name (derived from default resource) */
953
970
  dataset?: string;
954
971
  }
955
972
  /**
@@ -1075,9 +1092,17 @@ interface Logger {
1075
1092
  */
1076
1093
  declare function configureLogging(config: LoggerConfig): void;
1077
1094
  /** @public */
1078
- declare const getDatasetsState: BoundStoreAction<FetcherStoreState<[options?: ProjectHandle<string> | undefined], _sanity_client12.DatasetsResponse>, [options?: ProjectHandle<string> | undefined], StateSource<_sanity_client12.DatasetsResponse | undefined>>;
1095
+ declare const getDatasetsState: BoundStoreAction<FetcherStoreState<[options: {
1096
+ projectId: string;
1097
+ }], _sanity_client12.DatasetsResponse>, [options: {
1098
+ projectId: string;
1099
+ }], StateSource<_sanity_client12.DatasetsResponse | undefined>>;
1079
1100
  /** @public */
1080
- declare const resolveDatasets: BoundStoreAction<FetcherStoreState<[options?: ProjectHandle<string> | undefined], _sanity_client12.DatasetsResponse>, [options?: ProjectHandle<string> | undefined], Promise<_sanity_client12.DatasetsResponse>>;
1101
+ declare const resolveDatasets: BoundStoreAction<FetcherStoreState<[options: {
1102
+ projectId: string;
1103
+ }], _sanity_client12.DatasetsResponse>, [options: {
1104
+ projectId: string;
1105
+ }], Promise<_sanity_client12.DatasetsResponse>>;
1081
1106
  /**
1082
1107
  * Represents an action to create a new document.
1083
1108
  * Specifies the document type and optionally a document ID (which will be treated as the published ID).
@@ -1090,7 +1115,7 @@ interface CreateDocumentAction<TDocumentType extends string = string, TDataset e
1090
1115
  * These values will be set when the document is created.
1091
1116
  * System fields (_id, _type, _rev, _createdAt, _updatedAt) are omitted as they are set automatically.
1092
1117
  */
1093
- initialValue?: Partial<Omit<SanityDocument$3<TDocumentType, `${TProjectId}.${TDataset}`>, '_id' | '_type' | '_rev' | '_createdAt' | '_updatedAt'>>;
1118
+ initialValue?: Partial<Omit<SanityDocument$2, '_id' | '_type' | '_rev' | '_createdAt' | '_updatedAt'>>;
1094
1119
  }
1095
1120
  /**
1096
1121
  * Represents an action to delete an existing document.
@@ -1145,7 +1170,7 @@ type DocumentAction<TDocumentType extends string = string, TDataset extends stri
1145
1170
  * @returns A `CreateDocumentAction` object ready for dispatch.
1146
1171
  * @beta
1147
1172
  */
1148
- declare function createDocument<TDocumentType extends string = string, TDataset extends string = string, TProjectId extends string = string>(doc: DocumentTypeHandle<TDocumentType, TDataset, TProjectId>, initialValue?: Partial<Omit<SanityDocument$3<TDocumentType, `${TProjectId}.${TDataset}`>, '_id' | '_type' | '_rev' | '_createdAt' | '_updatedAt'>>): CreateDocumentAction<TDocumentType, TDataset, TProjectId>;
1173
+ declare function createDocument<TDocumentType extends string = string, TDataset extends string = string, TProjectId extends string = string>(doc: DocumentTypeHandle<TDocumentType, TDataset, TProjectId>, initialValue?: Partial<Omit<SanityDocument$2, '_id' | '_type' | '_rev' | '_createdAt' | '_updatedAt'>>): CreateDocumentAction<TDocumentType, TDataset, TProjectId>;
1149
1174
  /**
1150
1175
  * Creates a `DeleteDocumentAction` object.
1151
1176
  * @param doc - A handle uniquely identifying the document to be deleted.
@@ -1201,7 +1226,7 @@ declare function discardDocument<TDocumentType extends string = string, TDataset
1201
1226
  */
1202
1227
  type DocumentSet<TDocument extends SanityDocument$2 = SanityDocument$2> = { [TDocumentId in string]?: TDocument | null };
1203
1228
  /** @beta */
1204
- interface ActionsResult<TDocument extends SanityDocument$3 = SanityDocument$3> {
1229
+ interface ActionsResult<TDocument extends SanityDocument$2 = SanityDocument$2> {
1205
1230
  transactionId: string;
1206
1231
  documents: DocumentSet<TDocument>;
1207
1232
  previous: DocumentSet<TDocument>;
@@ -1219,6 +1244,10 @@ interface ApplyDocumentActionsOptions {
1219
1244
  * List of actions to apply.
1220
1245
  */
1221
1246
  actions: DocumentAction[];
1247
+ /**
1248
+ * The resource to which the documents being acted on belong.
1249
+ */
1250
+ resource: DocumentResource;
1222
1251
  /**
1223
1252
  * Optionally provide an ID to be used as this transaction ID
1224
1253
  */
@@ -1229,8 +1258,6 @@ interface ApplyDocumentActionsOptions {
1229
1258
  disableBatching?: boolean;
1230
1259
  }
1231
1260
  /** @beta */
1232
- declare function applyDocumentActions<TDocumentType extends string = string, TDataset extends string = string, TProjectId extends string = string>(instance: SanityInstance, options: ApplyDocumentActionsOptions): Promise<ActionsResult<SanityDocument$3<TDocumentType, `${TProjectId}.${TDataset}`>>>;
1233
- /** @beta */
1234
1261
  declare function applyDocumentActions(instance: SanityInstance, options: ApplyDocumentActionsOptions): Promise<ActionsResult>;
1235
1262
  /**
1236
1263
  * Represents a reactive state source that provides synchronized access to store data
@@ -1282,9 +1309,9 @@ interface StateSource<T> {
1282
1309
  * ```ts
1283
1310
  * // Using both state and instance in a selector (psuedo example)
1284
1311
  * const getUserByProjectId = createStateSourceAction(
1285
- * ({ state, instance }: SelectorContext<UsersState>, options?: ProjectHandle) => {
1312
+ * ({ state, instance }: SelectorContext<UsersState>, options?: ResourceHandle) => {
1286
1313
  * const allUsers = state.users
1287
- * const projectId = options?.projectId ?? instance.config.projectId
1314
+ * const projectId = options?.projectId ?? instance.config.defaultResource?.projectId
1288
1315
  * return allUsers.filter(user => user.projectId === projectId)
1289
1316
  * }
1290
1317
  * )
@@ -1436,23 +1463,6 @@ interface UnverifiedDocumentRevision {
1436
1463
  previousRev: string | undefined;
1437
1464
  timestamp: string;
1438
1465
  }
1439
- type Grant = 'read' | 'update' | 'create' | 'history';
1440
- /** @beta */
1441
- interface PermissionDeniedReason {
1442
- type: 'precondition' | 'access';
1443
- message: string;
1444
- documentId?: string;
1445
- }
1446
- /** @beta */
1447
- type DocumentPermissionsResult = {
1448
- allowed: false;
1449
- message: string;
1450
- reasons: PermissionDeniedReason[];
1451
- } | {
1452
- allowed: true;
1453
- message?: undefined;
1454
- reasons?: undefined;
1455
- };
1456
1466
  /** @beta */
1457
1467
  type DocumentEvent = ActionErrorEvent | TransactionRevertedEvent | TransactionAcceptedEvent | DocumentRebaseErrorEvent | DocumentEditedEvent | DocumentCreatedEvent | DocumentDeletedEvent | DocumentPublishedEvent | DocumentUnpublishedEvent | DocumentDiscardedEvent;
1458
1468
  /**
@@ -1551,38 +1561,23 @@ interface DocumentDiscardedEvent {
1551
1561
  documentId: string;
1552
1562
  outgoing: OutgoingTransaction;
1553
1563
  }
1554
- /**
1555
- * Split the entire path string on dots "outside" of any brackets.
1556
- *
1557
- * For example:
1558
- * ```
1559
- * "friends[0].name"
1560
- * ```
1561
- *
1562
- * becomes:
1563
- *
1564
- * ```
1565
- * [...ParseSegment<"friends[0]">, ...ParseSegment<"name">]
1566
- * ```
1567
- *
1568
- * (We use a simple recursion that splits on the first dot.)
1569
- */
1570
- type PathParts<TPath extends string> = TPath extends `${infer Head}.${infer Tail}` ? [Head, ...PathParts<Tail>] : TPath extends '' ? [] : [TPath];
1571
- /**
1572
- * Given a type T and an array of "access keys" Parts, recursively index into T.
1573
- *
1574
- * If a part is a key, it looks up that property.
1575
- * If T is an array and the part is a number, it "indexes" into the element type.
1576
- */
1577
- type DeepGet<TValue, TPath extends readonly (string | number)[]> = TPath extends [] ? TValue : TPath extends readonly [infer THead, ...infer TTail] ? DeepGet<TValue extends undefined | null ? undefined : THead extends keyof TValue ? TValue[THead] : THead extends number ? TValue extends readonly (infer TElement)[] ? TElement | undefined : undefined : undefined,
1578
- // Key/index doesn't exist
1579
- TTail extends readonly (string | number)[] ? TTail : []> : never;
1580
- /**
1581
- * Given a document type TDocument and a JSON Match path string TPath,
1582
- * compute the type found at that path.
1583
- * @beta
1584
- */
1585
- type JsonMatch<TDocument, TPath extends string> = DeepGet<TDocument, PathParts<TPath>>;
1564
+ type Grant = 'read' | 'update' | 'create' | 'history';
1565
+ /** @beta */
1566
+ interface PermissionDeniedReason {
1567
+ type: 'precondition' | 'access';
1568
+ message: string;
1569
+ documentId?: string;
1570
+ }
1571
+ /** @beta */
1572
+ type DocumentPermissionsResult = {
1573
+ allowed: false;
1574
+ message: string;
1575
+ reasons: PermissionDeniedReason[];
1576
+ } | {
1577
+ allowed: true;
1578
+ message?: undefined;
1579
+ reasons?: undefined;
1580
+ };
1586
1581
  interface SharedListener {
1587
1582
  events: Observable<ListenEvent<SanityDocument$1>>;
1588
1583
  dispose: () => void;
@@ -1595,7 +1590,7 @@ interface DocumentStoreState {
1595
1590
  grants?: Record<Grant, ExprNode>;
1596
1591
  error?: unknown;
1597
1592
  sharedListener: SharedListener;
1598
- fetchDocument: (documentId: string) => Observable<SanityDocument$3 | null>;
1593
+ fetchDocument: (documentId: string) => Observable<SanityDocument$2 | null>;
1599
1594
  events: Subject<DocumentEvent>;
1600
1595
  }
1601
1596
  interface DocumentState {
@@ -1604,12 +1599,12 @@ interface DocumentState {
1604
1599
  * the "remote" local copy that matches the server. represents the last known
1605
1600
  * server state. this gets updated every time we confirm remote patches
1606
1601
  */
1607
- remote?: SanityDocument$3 | null;
1602
+ remote?: SanityDocument$2 | null;
1608
1603
  /**
1609
1604
  * the current ephemeral working copy that includes local optimistic changes
1610
1605
  * that have not yet been confirmed by the server
1611
1606
  */
1612
- local?: SanityDocument$3 | null;
1607
+ local?: SanityDocument$2 | null;
1613
1608
  /**
1614
1609
  * the revision that our remote document is at
1615
1610
  */
@@ -1640,26 +1635,26 @@ interface DocumentOptions<TPath extends string | undefined = undefined, TDocumen
1640
1635
  path?: TPath;
1641
1636
  }
1642
1637
  /** @beta */
1643
- declare function getDocumentState<TDocumentType extends string = string, TDataset extends string = string, TProjectId extends string = string>(instance: SanityInstance, options: DocumentOptions<undefined, TDocumentType, TDataset, TProjectId>): StateSource<SanityDocument$3<TDocumentType, `${TProjectId}.${TDataset}`> | undefined | null>;
1644
- /** @beta */
1645
- declare function getDocumentState<TPath extends string = string, TDocumentType extends string = string, TDataset extends string = string, TProjectId extends string = string>(instance: SanityInstance, options: DocumentOptions<TPath, TDocumentType, TDataset, TProjectId>): StateSource<JsonMatch<SanityDocument$3<TDocumentType, `${TProjectId}.${TDataset}`>, TPath> | undefined>;
1646
- /** @beta */
1647
1638
  declare function getDocumentState<TData>(instance: SanityInstance, options: DocumentOptions<string | undefined>): StateSource<TData | undefined | null>;
1648
1639
  /** @beta */
1649
- declare function resolveDocument<TDocumentType extends string = string, TDataset extends string = string, TProjectId extends string = string>(instance: SanityInstance, docHandle: DocumentHandle<TDocumentType, TDataset, TProjectId>): Promise<SanityDocument$3<TDocumentType, `${TProjectId}.${TDataset}`> | null>;
1640
+ declare function resolveDocument<TData extends SanityDocument$2>(instance: SanityInstance, docHandle: DocumentHandle): Promise<TData | null>;
1650
1641
  /** @beta */
1651
- declare function resolveDocument<TData extends SanityDocument$3>(instance: SanityInstance, docHandle: DocumentHandle<string, string, string>): Promise<TData | null>;
1642
+ declare function resolveDocument(instance: SanityInstance, docHandle: DocumentHandle): Promise<SanityDocument$2 | null>;
1652
1643
  /** @beta */
1653
1644
  declare const getDocumentSyncStatus: BoundStoreAction<DocumentStoreState, [doc: DocumentHandle<string, string, string>], StateSource<boolean | undefined>>;
1654
1645
  type PermissionsStateOptions = {
1646
+ resource: DocumentResource;
1655
1647
  actions: DocumentAction[];
1656
1648
  };
1657
1649
  /** @beta */
1658
- declare const getPermissionsState: BoundStoreAction<DocumentStoreState, [PermissionsStateOptions], StateSource<DocumentPermissionsResult | undefined>>;
1650
+ declare const getPermissionsState: BoundStoreAction<DocumentStoreState, [PermissionsStateOptions], StateSource<DocumentPermissionsResult>>;
1659
1651
  /** @beta */
1660
1652
  declare const resolvePermissions: BoundStoreAction<DocumentStoreState, [options: PermissionsStateOptions], Promise<DocumentPermissionsResult>>;
1661
1653
  /** @beta */
1662
- declare const subscribeDocumentEvents: BoundStoreAction<DocumentStoreState, [eventHandler: (e: DocumentEvent) => void], () => void>;
1654
+ declare const subscribeDocumentEvents: BoundStoreAction<DocumentStoreState, [options: {
1655
+ resource: DocumentResource;
1656
+ eventHandler: (e: DocumentEvent) => void;
1657
+ }], () => void>;
1663
1658
  /**
1664
1659
  * @public
1665
1660
  */
@@ -1671,7 +1666,7 @@ interface FavoriteStatusResponse {
1671
1666
  */
1672
1667
  interface FavoriteDocumentContext extends DocumentHandle {
1673
1668
  resourceId: string;
1674
- resourceType: StudioResource['type'] | MediaResource['type'] | CanvasResource['type'];
1669
+ resourceType: StudioResource['type'] | MediaResource['type'] | CanvasResource$1['type'];
1675
1670
  schemaName?: string;
1676
1671
  }
1677
1672
  /**
@@ -1729,7 +1724,8 @@ interface UserProfile {
1729
1724
  /**
1730
1725
  * @public
1731
1726
  */
1732
- interface GetUsersOptions extends ProjectHandle {
1727
+ interface GetUsersOptions {
1728
+ projectId?: string;
1733
1729
  resourceType?: 'organization' | 'project';
1734
1730
  batchSize?: number;
1735
1731
  organizationId?: string;
@@ -1770,7 +1766,8 @@ interface ResolveUsersOptions extends GetUsersOptions {
1770
1766
  /**
1771
1767
  * @public
1772
1768
  */
1773
- interface GetUserOptions extends ProjectHandle {
1769
+ interface GetUserOptions {
1770
+ projectId?: string;
1774
1771
  userId: string;
1775
1772
  resourceType?: 'organization' | 'project';
1776
1773
  organizationId?: string;
@@ -1826,11 +1823,43 @@ type PresenceStoreState = {
1826
1823
  };
1827
1824
  /** @public */
1828
1825
 
1829
- /** @public */
1830
- declare const getPresence: BoundStoreAction<PresenceStoreState, [((object & {
1831
- projectId?: string;
1832
- dataset?: string;
1833
- }) | undefined)?, ...unknown[]], StateSource<UserPresence[]>>;
1826
+ /** @beta */
1827
+ declare const getPresence: BoundStoreAction<PresenceStoreState, [{
1828
+ resource?: DocumentResource;
1829
+ }, ...unknown[]], StateSource<UserPresence[]>>;
1830
+ /**
1831
+ * Generates a GROQ projection for preview data without requiring a schema.
1832
+ * Uses common field names to make educated guesses about which fields to use.
1833
+ *
1834
+ * @internal
1835
+ */
1836
+ declare const PREVIEW_PROJECTION: string;
1837
+ /**
1838
+ * @public
1839
+ * The result of a projection query
1840
+ */
1841
+ interface ProjectionValuePending<TValue extends object> {
1842
+ data: TValue | null;
1843
+ isPending: boolean;
1844
+ }
1845
+ interface DocumentStatus {
1846
+ lastEditedDraftAt?: string;
1847
+ lastEditedPublishedAt?: string;
1848
+ lastEditedVersionAt?: string;
1849
+ }
1850
+ /**
1851
+ *
1852
+ * @internal
1853
+ */
1854
+ interface PreviewQueryResult {
1855
+ _id: string;
1856
+ _type: string;
1857
+ _updatedAt: string;
1858
+ titleCandidates: Record<string, unknown>;
1859
+ subtitleCandidates: Record<string, unknown>;
1860
+ media?: PreviewMedia | null;
1861
+ _status?: DocumentStatus;
1862
+ }
1834
1863
  /**
1835
1864
  * Represents a media asset in a preview.
1836
1865
  *
@@ -1887,58 +1916,26 @@ type ValuePending<T> = {
1887
1916
  isPending: boolean;
1888
1917
  };
1889
1918
  /**
1890
- * @public
1891
- */
1892
- interface PreviewStoreState {
1893
- values: { [TDocumentId in string]?: ValuePending<PreviewValue> };
1894
- subscriptions: { [TDocumentId in string]?: { [TSubscriptionId in string]?: true } };
1895
- }
1896
- /**
1897
- * @beta
1898
- */
1899
- type GetPreviewStateOptions = DocumentHandle;
1900
- /**
1901
- * @beta
1902
- */
1903
- declare function getPreviewState<TResult extends object>(instance: SanityInstance, options: GetPreviewStateOptions): StateSource<ValuePending<TResult>>;
1904
- /**
1905
- * @beta
1906
- */
1907
- declare function getPreviewState(instance: SanityInstance, options: GetPreviewStateOptions): StateSource<ValuePending<PreviewValue>>;
1908
- /**
1909
- * @beta
1910
- */
1911
- type ResolvePreviewOptions = DocumentHandle;
1912
- /**
1913
- * @beta
1919
+ * Transforms a projection result (with titleCandidates, subtitleCandidates, media)
1920
+ * into a PreviewValue (with title, subtitle, media).
1921
+ *
1922
+ * @param projectionResult - The raw projection result from GROQ
1923
+ * @param instance - The Sanity instance to use for client configuration
1924
+ * @param resource - Data resource for the preview
1925
+ * @internal
1914
1926
  */
1915
- declare const resolvePreview: BoundStoreAction<PreviewStoreState, [docHandle: ResolvePreviewOptions], Promise<ValuePending<object>>>;
1927
+ declare function transformProjectionToPreview(instance: SanityInstance, resource: DocumentResource, projectionResult: PreviewQueryResult): PreviewValue;
1928
+ /** @public */
1929
+ type ProjectHandle = {
1930
+ projectId: string;
1931
+ };
1916
1932
  /** @public */
1917
- declare const getProjectState: BoundStoreAction<FetcherStoreState<[options?: ProjectHandle<string> | undefined], _sanity_client12.SanityProject>, [options?: ProjectHandle<string> | undefined], StateSource<_sanity_client12.SanityProject | undefined>>;
1933
+ declare const getProjectState: BoundStoreAction<FetcherStoreState<[options: ProjectHandle], _sanity_client12.SanityProject>, [options: ProjectHandle], StateSource<_sanity_client12.SanityProject | undefined>>;
1918
1934
  /** @public */
1919
- declare const resolveProject: BoundStoreAction<FetcherStoreState<[options?: ProjectHandle<string> | undefined], _sanity_client12.SanityProject>, [options?: ProjectHandle<string> | undefined], Promise<_sanity_client12.SanityProject>>;
1920
- /**
1921
- * @public
1922
- * The result of a projection query
1923
- */
1924
- interface ProjectionValuePending<TValue extends object> {
1925
- data: TValue | null;
1926
- isPending: boolean;
1927
- }
1928
- /**
1929
- * @public
1930
- * @deprecated
1931
- * Template literals are a bit too limited, so this type is deprecated.
1932
- * Use `string` instead. Projection strings are validated at runtime.
1933
- */
1934
- type ValidProjection = string;
1935
+ declare const resolveProject: BoundStoreAction<FetcherStoreState<[options: ProjectHandle], _sanity_client12.SanityProject>, [options: ProjectHandle], Promise<_sanity_client12.SanityProject>>;
1935
1936
  interface ProjectionOptions<TProjection extends string = string, TDocumentType extends string = string, TDataset extends string = string, TProjectId extends string = string> extends DocumentHandle<TDocumentType, TDataset, TProjectId> {
1936
1937
  projection: TProjection;
1937
1938
  }
1938
- /**
1939
- * @beta
1940
- */
1941
- declare function getProjectionState<TProjection extends string = string, TDocumentType extends string = string, TDataset extends string = string, TProjectId extends string = string>(instance: SanityInstance, options: ProjectionOptions<TProjection, TDocumentType, TDataset, TProjectId>): StateSource<ProjectionValuePending<SanityProjectionResult<TProjection, TDocumentType, `${TProjectId}.${TDataset}`>> | undefined>;
1942
1939
  /**
1943
1940
  * @beta
1944
1941
  */
@@ -1948,8 +1945,6 @@ declare function getProjectionState<TData extends object>(instance: SanityInstan
1948
1945
  */
1949
1946
  declare function getProjectionState(instance: SanityInstance, options: ProjectionOptions): StateSource<ProjectionValuePending<Record<string, unknown>> | undefined>;
1950
1947
  /** @beta */
1951
- declare function resolveProjection<TProjection extends string = string, TDocumentType extends string = string, TDataset extends string = string, TProjectId extends string = string>(instance: SanityInstance, options: ProjectionOptions<TProjection, TDocumentType, TDataset, TProjectId>): Promise<ProjectionValuePending<SanityProjectionResult<TProjection, TDocumentType, `${TProjectId}.${TDataset}`>>>;
1952
- /** @beta */
1953
1948
  declare function resolveProjection<TData extends object>(instance: SanityInstance, options: ProjectionOptions): Promise<ProjectionValuePending<TData>>;
1954
1949
  /** @public */
1955
1950
  declare const getProjectsState: BoundStoreAction<FetcherStoreState<[options?: {
@@ -1970,7 +1965,7 @@ declare const resolveProjects: BoundStoreAction<FetcherStoreState<[options?: {
1970
1965
  /**
1971
1966
  * @beta
1972
1967
  */
1973
- interface QueryOptions<TQuery extends string = string, TDataset extends string = string, TProjectId extends string = string> extends Pick<ResponseQueryOptions, 'useCdn' | 'cache' | 'next' | 'cacheMode' | 'tag'>, DatasetHandle<TDataset, TProjectId> {
1968
+ interface QueryOptions<TQuery extends string = string, TDataset extends string = string, TProjectId extends string = string> extends Pick<ResponseQueryOptions, 'useCdn' | 'cache' | 'next' | 'cacheMode' | 'tag'>, ResourceHandle<TDataset, TProjectId> {
1974
1969
  query: TQuery;
1975
1970
  params?: Record<string, unknown>;
1976
1971
  }
@@ -2000,8 +1995,6 @@ declare const parseQueryKey: (key: string) => QueryOptions;
2000
1995
  *
2001
1996
  * @beta
2002
1997
  */
2003
- declare function getQueryState<TQuery extends string = string, TDataset extends string = string, TProjectId extends string = string>(instance: SanityInstance, queryOptions: QueryOptions<TQuery, TDataset, TProjectId>): StateSource<SanityQueryResult<TQuery, `${TProjectId}.${TDataset}`> | undefined>;
2004
- /** @beta */
2005
1998
  declare function getQueryState<TData>(instance: SanityInstance, queryOptions: QueryOptions): StateSource<TData | undefined>;
2006
1999
  /** @beta */
2007
2000
  declare function getQueryState(instance: SanityInstance, queryOptions: QueryOptions): StateSource<unknown>;
@@ -2019,8 +2012,6 @@ declare function getQueryState(instance: SanityInstance, queryOptions: QueryOpti
2019
2012
  *
2020
2013
  * @beta
2021
2014
  */
2022
- declare function resolveQuery<TQuery extends string = string, TDataset extends string = string, TProjectId extends string = string>(instance: SanityInstance, queryOptions: ResolveQueryOptions<TQuery, TDataset, TProjectId>): Promise<SanityQueryResult<TQuery, `${TProjectId}.${TDataset}`>>;
2023
- /** @beta */
2024
2015
  declare function resolveQuery<TData>(instance: SanityInstance, queryOptions: ResolveQueryOptions): Promise<TData>;
2025
2016
  /**
2026
2017
  * Represents a document in a Sanity dataset that represents release options.
@@ -2045,13 +2036,11 @@ interface ReleasesStoreState {
2045
2036
  * Get the active releases from the store.
2046
2037
  * @internal
2047
2038
  */
2048
- declare const getActiveReleasesState: BoundStoreAction<ReleasesStoreState, [((object & {
2049
- projectId?: string;
2050
- dataset?: string;
2051
- }) | undefined)?, ...unknown[]], StateSource<ReleaseDocument[] | undefined>>;
2039
+ declare const getActiveReleasesState: (instance: SanityInstance, options: {
2040
+ resource: DocumentResource;
2041
+ }) => StateSource<ReleaseDocument[] | undefined>;
2052
2042
  declare const _getPerspectiveStateSelector: StoreAction<ReleasesStoreState, [_?: (PerspectiveHandle & {
2053
- projectId?: string;
2054
- dataset?: string;
2043
+ resource?: DocumentResource;
2055
2044
  }) | undefined], StateSource<string[] | "previewDrafts" | "published" | "drafts" | "raw" | undefined>, unknown>;
2056
2045
  type OmitFirst<T extends unknown[]> = T extends [unknown, ...infer R] ? R : never;
2057
2046
  type SelectorParams = OmitFirst<Parameters<typeof _getPerspectiveStateSelector>>;
@@ -2070,7 +2059,7 @@ type BoundGetPerspectiveState = BoundStoreAction<ReleasesStoreState, SelectorPar
2070
2059
  */
2071
2060
  declare const getPerspectiveState: BoundGetPerspectiveState;
2072
2061
  /** @internal */
2073
- declare const getUsersKey: (instance: SanityInstance, {
2062
+ declare const getUsersKey: (_instance: SanityInstance, {
2074
2063
  resourceType,
2075
2064
  organizationId,
2076
2065
  batchSize,
@@ -2340,4 +2329,4 @@ declare const CORE_SDK_VERSION: {};
2340
2329
  * @public
2341
2330
  */
2342
2331
  type SanityProject = SanityProject$1;
2343
- export { type ActionErrorEvent, type ActionsResult, type AgentGenerateOptions, type AgentGenerateResult, type AgentPatchOptions, type AgentPatchResult, type AgentPromptOptions, type AgentPromptResult, type AgentTransformOptions, type AgentTransformResult, type AgentTranslateOptions, type AgentTranslateResult, type ApiErrorBody, type ApplyDocumentActionsOptions, type AuthConfig, type AuthProvider, type AuthState, AuthStateType, type AuthStoreState, CORE_SDK_VERSION, type CanvasSource, type ClientOptions, type ClientStoreState as ClientState, type ComlinkControllerState, type ComlinkNodeState, type CreateDocumentAction, type CurrentUser, type DatasetHandle, type DatasetSource, type DeleteDocumentAction, type DiscardDocumentAction, type DisconnectEvent, type DocumentAction, type DocumentCreatedEvent, type DocumentDeletedEvent, type DocumentDiscardedEvent, type DocumentEditedEvent, type DocumentEvent, type DocumentHandle, type DocumentOptions, type DocumentPermissionsResult, type DocumentPublishedEvent, type DocumentSource, type DocumentTypeHandle, type DocumentUnpublishedEvent, type EditDocumentAction, type ErrorAuthState, type FavoriteStatusResponse, type FetcherStore, type FetcherStoreState, type FrameMessage, type GetPreviewStateOptions, type GetUserOptions, type GetUsersOptions, type InstanceContext, type Intent, type IntentFilter, type JsonMatch, type LogContext, type LogLevel, type LogNamespace, type LoggedInAuthState, type LoggedOutAuthState, type Logger, type LoggerConfig, type LoggingInAuthState, type MediaLibrarySource, type Membership, type NewTokenResponseMessage, type NodeState, type OrgVerificationResult, type PermissionDeniedReason, type PerspectiveHandle, type PresenceLocation, type PreviewStoreState, type PreviewValue, type ProjectHandle, type ProjectionValuePending, type PublishDocumentAction, type QueryOptions, type ReleaseDocument, type ReleasePerspective, type RequestNewTokenMessage, type ResolvePreviewOptions, type ResolveUserOptions, type ResolveUsersOptions, type Role, type RollCallEvent, type SanityConfig, type SanityDocument, type SanityInstance, SanityProject, type SanityUser, type SanityUserResponse, type Selector, type StateEvent, type StateSource, type StudioConfig, type TokenSource, type TransactionAcceptedEvent, type TransactionRevertedEvent, type TransportEvent, type UnpublishDocumentAction, type UserPresence, type UserProfile, type UsersGroupState, type UsersStoreState, type ValidProjection, type ValuePending, type WindowMessage, agentGenerate, agentPatch, agentPrompt, agentTransform, agentTranslate, applyDocumentActions, configureLogging, createDatasetHandle, createDocument, createDocumentHandle, createDocumentTypeHandle, createGroqSearchFilter, createProjectHandle, createSanityInstance, defineIntent, deleteDocument, destroyController, discardDocument, editDocument, getActiveReleasesState, getAuthState, getClient, getClientErrorApiBody, getClientErrorApiDescription, getClientErrorApiType, getClientState, getCorsErrorProjectId, getCurrentUserState, getDashboardOrganizationId, getDatasetsState, getDocumentState, getDocumentSyncStatus, getFavoritesState, getIndexForKey, getIsInDashboardState, getLoginUrlState, getNodeState, getOrCreateChannel, getOrCreateController, getOrCreateNode, getPathDepth, getPermissionsState, getPerspectiveState, getPresence, getPreviewState, getProjectState, getProjectionState, getProjectsState, getQueryKey, getQueryState, getTokenState, getUserState, getUsersKey, getUsersState, handleAuthCallback, isCanvasSource, isDatasetSource, isMediaLibrarySource, isProjectUserNotFoundClientError, isStudioConfig, joinPaths, jsonMatch, loadMoreUsers, logout, observeOrganizationVerificationState, parseQueryKey, parseUsersKey, publishDocument, releaseChannel, releaseNode, resolveDatasets, resolveDocument, resolveFavoritesState, resolvePermissions, resolvePreview, resolveProject, resolveProjection, resolveProjects, resolveQuery, resolveUser, resolveUsers, setAuthToken, slicePath, stringifyPath, subscribeDocumentEvents, unpublishDocument };
2332
+ export { type ActionErrorEvent, type ActionsResult, type AgentGenerateOptions, type AgentGenerateResult, type AgentPatchOptions, type AgentPatchResult, type AgentPromptOptions, type AgentPromptResult, type AgentResourceOptions, type AgentTransformOptions, type AgentTransformResult, type AgentTranslateOptions, type AgentTranslateResult, type ApiErrorBody, type ApplyDocumentActionsOptions, type AuthConfig, type AuthProvider, type AuthState, AuthStateType, type AuthStoreState, CORE_SDK_VERSION, type CanvasResource, type ClientOptions, type ClientStoreState as ClientState, type ComlinkControllerState, type ComlinkNodeState, type CreateDocumentAction, type CurrentUser, DEFAULT_RESOURCE_NAME, type DatasetResource, type DeleteDocumentAction, type DiscardDocumentAction, type DisconnectEvent, type DocumentAction, type DocumentCreatedEvent, type DocumentDeletedEvent, type DocumentDiscardedEvent, type DocumentEditedEvent, type DocumentEvent, type DocumentHandle, type DocumentOptions, type DocumentPermissionsResult, type DocumentPublishedEvent, type DocumentResource, type DocumentTypeHandle, type DocumentUnpublishedEvent, type EditDocumentAction, type ErrorAuthState, type FavoriteStatusResponse, type FetcherStore, type FetcherStoreState, type FrameMessage, type GetUserOptions, type GetUsersOptions, type InstanceContext, type Intent, type IntentFilter, type LogContext, type LogLevel, type LogNamespace, type LoggedInAuthState, type LoggedOutAuthState, type Logger, type LoggerConfig, type LoggingInAuthState, type MediaLibraryResource, type Membership, type NewTokenResponseMessage, type NodeState, type OrgVerificationResult, PREVIEW_PROJECTION, type PermissionDeniedReason, type PerspectiveHandle, type PresenceLocation, type PreviewMedia, type PreviewQueryResult, type PreviewValue, type ProjectHandle, type ProjectionValuePending, type PublishDocumentAction, type QueryOptions, type ReleaseDocument, type ReleasePerspective, type RequestNewTokenMessage, type ResolveUserOptions, type ResolveUsersOptions, type ResourceHandle, type Role, type RollCallEvent, type SanityConfig, type SanityDocument, type SanityInstance, SanityProject, type SanityUser, type SanityUserResponse, type Selector, type StateEvent, type StateSource, type StudioConfig, type TokenSource, type TransactionAcceptedEvent, type TransactionRevertedEvent, type TransportEvent, type UnpublishDocumentAction, type UserPresence, type UserProfile, type UsersGroupState, type UsersStoreState, type ValuePending, type WindowMessage, agentGenerate, agentPatch, agentPrompt, agentTransform, agentTranslate, applyDocumentActions, configureLogging, createDocument, createDocumentHandle, createDocumentTypeHandle, createGroqSearchFilter, createResourceHandle, createSanityInstance, defineIntent, deleteDocument, destroyController, discardDocument, editDocument, getActiveReleasesState, getAuthState, getClient, getClientErrorApiBody, getClientErrorApiDescription, getClientErrorApiType, getClientState, getCorsErrorProjectId, getCurrentUserState, getDashboardOrganizationId, getDatasetsState, getDocumentState, getDocumentSyncStatus, getFavoritesState, getIndexForKey, getIsInDashboardState, getLoginUrlState, getNodeState, getOrCreateChannel, getOrCreateController, getOrCreateNode, getPathDepth, getPermissionsState, getPerspectiveState, getPresence, getProjectState, getProjectionState, getProjectsState, getQueryKey, getQueryState, getTokenState, getUserState, getUsersKey, getUsersState, handleAuthCallback, isCanvasResource, isDatasetResource, isMediaLibraryResource, isProjectUserNotFoundClientError, isStudioConfig, joinPaths, jsonMatch, loadMoreUsers, logout, observeOrganizationVerificationState, parseQueryKey, parseUsersKey, publishDocument, releaseChannel, releaseNode, resolveDatasets, resolveDocument, resolveFavoritesState, resolvePermissions, resolveProject, resolveProjection, resolveProjects, resolveQuery, resolveUser, resolveUsers, setAuthToken, slicePath, stringifyPath, subscribeDocumentEvents, transformProjectionToPreview, unpublishDocument };