@sanity/sdk 2.13.0 → 2.14.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2778 +0,0 @@
1
- import * as _sanity_client4 from "@sanity/client";
2
- import { ClientConfig, ClientError, ClientPerspective, ListenEvent, MultipleMutationResult, ReleaseDocument, ReleaseDocument as ReleaseDocument$1, ResponseQueryOptions, SanityClient, SanityDocument, SanityProject, StackablePerspective } from "@sanity/client";
3
- import { CurrentUser, CurrentUser as CurrentUser$1, Mutation, PatchOperations, Role, SanityDocument as SanityDocument$1, SanityDocument as SanityDocument$3, SanityDocumentLike } from "@sanity/types";
4
- import { Observable, Subject } from "rxjs";
5
- import * as _sanity_comlink3 from "@sanity/comlink";
6
- import { ChannelInput, ChannelInstance, Controller, Message, Node, NodeInput, Status } from "@sanity/comlink";
7
- import { PatchMutation } from "@sanity/mutate/_unstable_store";
8
- import { SanityDocument as SanityDocument$2, SanityProjectionResult, SanityQueryResult } from "groq";
9
- import { ExprNode } from "groq-js";
10
- import { CanvasResource, MediaResource, StudioResource } from "@sanity/message-protocol";
11
- import { getIndexForKey, getPathDepth, joinPaths, jsonMatch, slicePath, stringifyPath } from "@sanity/json-match";
12
- /**
13
- * Configuration for an authentication provider
14
- * @public
15
- */
16
- interface AuthProvider {
17
- /**
18
- * Unique identifier for the auth provider (e.g., 'google', 'github')
19
- */
20
- name: string;
21
- /**
22
- * Display name for the auth provider in the UI
23
- */
24
- title: string;
25
- /**
26
- * Complete authentication URL including callback and token parameters
27
- */
28
- url: string;
29
- /**
30
- * Optional URL for direct sign-up flow
31
- */
32
- signUpUrl?: string;
33
- }
34
- /**
35
- * Configuration options for creating an auth store.
36
- *
37
- * @public
38
- */
39
- interface AuthConfig {
40
- /**
41
- * The initial location href to use when handling auth callbacks.
42
- * Defaults to the current window location if available.
43
- */
44
- initialLocationHref?: string;
45
- /**
46
- * Factory function to create a SanityClient instance.
47
- * Defaults to the standard Sanity client factory if not provided.
48
- */
49
- clientFactory?: (config: ClientConfig) => SanityClient;
50
- /**
51
- * Custom authentication providers to use instead of or in addition to the default ones.
52
- * Can be an array of providers or a function that takes the default providers and returns
53
- * a modified array or a Promise resolving to one.
54
- */
55
- providers?: AuthProvider[] | ((prev: AuthProvider[]) => AuthProvider[] | Promise<AuthProvider[]>);
56
- /**
57
- * The API hostname for requests. Usually leave this undefined, but it can be set
58
- * if using a custom domain or CNAME for the API endpoint.
59
- */
60
- apiHost?: string;
61
- /**
62
- * Storage implementation to persist authentication state.
63
- * Defaults to `localStorage` if available.
64
- */
65
- storageArea?: Storage;
66
- /**
67
- * A callback URL for your application.
68
- * If none is provided, the auth API will redirect back to the current location (`location.href`).
69
- * When handling callbacks, this URL's pathname is checked to ensure it matches the callback.
70
- */
71
- callbackUrl?: string;
72
- /**
73
- * A static authentication token to use instead of handling the OAuth flow.
74
- * When provided, the auth store will remain in a logged-in state with this token,
75
- * ignoring any storage or callback handling.
76
- */
77
- token?: string;
78
- }
79
- /**
80
- * A minimal Observable-compatible interface for subscribing to token changes.
81
- * Any object with a `subscribe` method that follows this contract will work,
82
- * including RxJS Observables. This avoids coupling the SDK to a specific
83
- * reactive library.
84
- *
85
- * @public
86
- */
87
- interface TokenSource {
88
- /** Subscribe to token emissions. Emits `null` when logged out. */
89
- subscribe(observer: {
90
- next: (token: string | null) => void;
91
- }): {
92
- unsubscribe(): void;
93
- };
94
- }
95
- /**
96
- * Studio-specific configuration for the SDK.
97
- * When present, the SDK operates in studio mode and derives auth from the
98
- * provided token source instead of discovering tokens independently.
99
- *
100
- * @public
101
- */
102
- interface StudioConfig {
103
- /**
104
- * Whether the Studio has already determined the user is authenticated.
105
- * When `true` and the token source emits `null`, the SDK infers
106
- * cookie-based auth is in use rather than transitioning to logged-out.
107
- */
108
- authenticated?: boolean;
109
- /** Reactive auth token source from the Studio's auth store. */
110
- auth?: {
111
- /**
112
- * A reactive token source. The SDK subscribes and stays in sync — the
113
- * Studio is the single authority for auth and handles token refresh.
114
- *
115
- * Optional because older Studios may not expose it. When absent, the
116
- * SDK falls back to localStorage/cookie discovery.
117
- */
118
- token?: TokenSource;
119
- };
120
- }
121
- /**
122
- * Represents the minimal configuration required to identify a Sanity project.
123
- * @public
124
- */
125
- interface ProjectHandle<TProjectId extends string = string> {
126
- projectId?: TProjectId;
127
- }
128
- /**
129
- * @public
130
- */
131
- type ReleasePerspective = {
132
- releaseName: string;
133
- excludedPerspectives?: StackablePerspective[];
134
- };
135
- /**
136
- * @public
137
- */
138
- interface PerspectiveHandle {
139
- perspective?: ClientPerspective | ReleasePerspective;
140
- }
141
- /**
142
- * @public
143
- */
144
- interface DatasetHandle<TDataset extends string = string, TProjectId extends string = string> extends ProjectHandle<TProjectId>, PerspectiveHandle {
145
- dataset?: TDataset;
146
- /**
147
- * @beta
148
- * Explicit resource object to use for this operation.
149
- */
150
- resource?: DocumentResource;
151
- /**
152
- * @deprecated Use `resource` instead.
153
- * @beta
154
- */
155
- source?: DocumentResource;
156
- }
157
- /**
158
- * Identifies a specific document type within a Sanity dataset and project.
159
- * Includes `projectId`, `dataset`, and `documentType`.
160
- * Optionally includes a `documentId` and `liveEdit` flag.
161
- * @public
162
- */
163
- interface DocumentTypeHandle<TDocumentType extends string = string, TDataset extends string = string, TProjectId extends string = string> extends DatasetHandle<TDataset, TProjectId> {
164
- documentId?: string;
165
- documentType: TDocumentType;
166
- /**
167
- * Indicates whether this document uses liveEdit mode.
168
- * When `true`, the document does not use the draft/published model and edits are applied directly to the document.
169
- * @see https://www.sanity.io/docs/content-lake/drafts#ca0663a8f002
170
- */
171
- liveEdit?: boolean;
172
- }
173
- /**
174
- * Uniquely identifies a specific document within a Sanity dataset and project.
175
- * Includes `projectId`, `dataset`, `documentType`, and the required `documentId`.
176
- * Commonly used by document-related hooks and components to reference a document without fetching its full content initially.
177
- * @public
178
- */
179
- interface DocumentHandle<TDocumentType extends string = string, TDataset extends string = string, TProjectId extends string = string> extends DocumentTypeHandle<TDocumentType, TDataset, TProjectId> {
180
- documentId: string;
181
- }
182
- /**
183
- * Identifies a release within a Sanity dataset and project. `releaseId` is the
184
- * `name` parameter on the release document (e.g. `{name: 'r41035a4'}`).
185
- * The underlying release document ID is `_.releases.<releaseId>`.
186
- * It's also the `id` parameter sent to the Actions API.
187
- * (This type doesn't need to have ProjectId / Dataset generics since it's always the same shape)
188
- * @beta
189
- */
190
- interface ReleaseHandle extends DatasetHandle {
191
- releaseId: string;
192
- }
193
- /**
194
- * Represents the complete configuration for a Sanity SDK instance
195
- * @public
196
- */
197
- interface SanityConfig extends DatasetHandle, PerspectiveHandle {
198
- /**
199
- * Authentication configuration for the instance
200
- */
201
- auth?: AuthConfig;
202
- /**
203
- * Studio configuration provided by a Sanity Studio workspace.
204
- * When present, the SDK operates in studio mode and derives auth from the
205
- * workspace's reactive token source — no manual configuration needed.
206
- *
207
- * @remarks Typically set automatically by `SanityApp` when it detects an
208
- * `SDKStudioContext` provider. Can also be set explicitly for programmatic use.
209
- */
210
- studio?: StudioConfig;
211
- /**
212
- * Studio mode configuration for use of the SDK in a Sanity Studio.
213
- * @remarks Controls whether studio mode features are enabled.
214
- * @deprecated Use `studio` instead, which provides richer integration
215
- * with the Studio's workspace (auth token sync, etc.).
216
- */
217
- studioMode?: {
218
- enabled: boolean;
219
- };
220
- /**
221
- * @beta
222
- * A list of named resources to use for this instance.
223
- */
224
- resources?: Record<string, DocumentResource>;
225
- /**
226
- * @deprecated Use `resources` instead.
227
- * @beta
228
- */
229
- sources?: Record<string, DocumentResource>;
230
- }
231
- /**
232
- * A document resource can be used for querying.
233
- * This will soon be the default way to identify where you are querying from.
234
- *
235
- * @beta
236
- */
237
- type DocumentResource = DatasetResource | MediaLibraryResource | CanvasResource$1;
238
- /**
239
- * @beta
240
- */
241
- type DatasetResource = {
242
- projectId: string;
243
- dataset: string;
244
- };
245
- /**
246
- * @beta
247
- */
248
- type MediaLibraryResource = {
249
- mediaLibraryId: string;
250
- };
251
- /**
252
- * @beta
253
- */
254
- type CanvasResource$1 = {
255
- canvasId: string;
256
- };
257
- /**
258
- * @beta
259
- */
260
- declare function isDatasetResource(resource: DocumentResource): resource is DatasetResource;
261
- /**
262
- * @beta
263
- */
264
- declare function isMediaLibraryResource(resource: DocumentResource): resource is MediaLibraryResource;
265
- /**
266
- * @beta
267
- */
268
- declare function isCanvasResource(resource: DocumentResource): resource is CanvasResource$1;
269
- /**
270
- * @deprecated Use `DocumentResource` instead.
271
- * @beta
272
- */
273
- type DocumentSource = DocumentResource;
274
- /**
275
- * @deprecated Use `DatasetResource` instead.
276
- * @beta
277
- */
278
- type DatasetSource = DatasetResource;
279
- /**
280
- * @deprecated Use `MediaLibraryResource` instead.
281
- * @beta
282
- */
283
- type MediaLibrarySource = MediaLibraryResource;
284
- /**
285
- * @deprecated Use `CanvasResource` instead.
286
- * @beta
287
- */
288
- type CanvasSource = CanvasResource$1;
289
- /**
290
- * @deprecated Use `isDatasetResource` instead.
291
- * @beta
292
- */
293
- declare function isDatasetSource(source: DocumentSource): source is DatasetSource;
294
- /**
295
- * @deprecated Use `isMediaLibraryResource` instead.
296
- * @beta
297
- */
298
- declare function isMediaLibrarySource(source: DocumentSource): source is MediaLibrarySource;
299
- /**
300
- * @deprecated Use `isCanvasResource` instead.
301
- * @beta
302
- */
303
- declare function isCanvasSource(source: DocumentSource): source is CanvasSource;
304
- /**
305
- * Returns `true` when the config indicates the SDK is running inside a Studio.
306
- * Checks the new `studio` field first, then falls back to the deprecated
307
- * `studioMode.enabled` for backwards compatibility.
308
- *
309
- * @internal
310
- */
311
- declare function isStudioConfig(config: SanityConfig): boolean;
312
- /**
313
- * Represents a Sanity.io resource instance with its own configuration and lifecycle
314
- *
315
- * @public
316
- */
317
- interface SanityInstance {
318
- /**
319
- * Unique identifier for this instance
320
- * @remarks Generated using crypto.randomUUID()
321
- */
322
- readonly instanceId: string;
323
- /**
324
- * Resolved configuration for this instance
325
- */
326
- readonly config: SanityConfig;
327
- /**
328
- * Checks if the instance has been disposed
329
- * @returns true if dispose() has been called
330
- */
331
- isDisposed(): boolean;
332
- /**
333
- * Disposes the instance and cleans up associated resources
334
- * @remarks Triggers all registered onDispose callbacks
335
- */
336
- dispose(): void;
337
- /**
338
- * Registers a callback to be invoked when the instance is disposed
339
- * @param cb - Callback to execute on disposal
340
- * @returns Function to unsubscribe the callback
341
- */
342
- onDispose(cb: () => void): () => void;
343
- /**
344
- * Gets the parent instance in the hierarchy
345
- * @returns Parent instance or undefined if this is the root
346
- * @deprecated The parent/child instance hierarchy is deprecated. Use a single SanityInstance instead.
347
- */
348
- getParent(): SanityInstance | undefined;
349
- /**
350
- * Creates a child instance with merged configuration
351
- * @param config - Configuration to merge with parent values
352
- * @deprecated The parent/child instance hierarchy is deprecated. Use a single SanityInstance instead.
353
- */
354
- createChild(config: SanityConfig): SanityInstance;
355
- /**
356
- * Traverses the instance hierarchy to find the first instance whose configuration
357
- * matches the given target config using a shallow comparison.
358
- * @param targetConfig - A partial configuration object containing key-value pairs to match.
359
- * @returns The first matching instance or undefined if no match is found.
360
- * @deprecated The parent/child instance hierarchy is deprecated. Use a single SanityInstance instead.
361
- */
362
- match(targetConfig: Partial<SanityConfig>): SanityInstance | undefined;
363
- }
364
- /**
365
- * Creates a new Sanity resource instance
366
- * @param config - Configuration for the instance (optional)
367
- * @returns A configured SanityInstance
368
- * @remarks When creating child instances, configurations are merged with parent values
369
- *
370
- * @public
371
- */
372
- declare function createSanityInstance(config?: SanityConfig): SanityInstance;
373
- /**
374
- * Represents a reactive store state container with multiple access patterns
375
- */
376
- interface StoreState<TState> {
377
- /**
378
- * Gets the current state value
379
- *
380
- * @remarks
381
- * This is a direct synchronous accessor that doesn't trigger subscriptions
382
- */
383
- get: () => TState;
384
- /**
385
- * Updates the store state
386
- * @param name - Action name for devtools tracking
387
- * @param updatedState - New state value or updater function
388
- *
389
- * @remarks
390
- * When providing a partial object, previous top-level keys not included in
391
- * the update will be preserved.
392
- */
393
- set: (name: string, updatedState: Partial<TState> | ((s: TState) => Partial<TState>)) => void;
394
- /**
395
- * Observable stream of state changes
396
- * @remarks
397
- * - Emits immediately with current state on subscription
398
- * - Shares underlying subscription between observers
399
- * - Only emits when state reference changes
400
- * - Completes when store is disposed
401
- */
402
- observable: Observable<TState>;
403
- }
404
- /**
405
- * Context object provided to store initialization functions
406
- */
407
- interface StoreContext<TState, TKey = unknown> {
408
- /**
409
- * Sanity instance associated with this store
410
- *
411
- * @remarks
412
- * Provides access to the Sanity configuration and instance lifecycle methods
413
- */
414
- instance: SanityInstance;
415
- /**
416
- * Reactive store state management utilities
417
- *
418
- * @remarks
419
- * Contains methods for getting/setting state and observing changes
420
- */
421
- state: StoreState<TState>;
422
- /**
423
- * The key used to instantiate the store.
424
- */
425
- key: TKey;
426
- }
427
- /** @alpha */
428
- type AgentGenerateOptions = Parameters<SanityClient['observable']['agent']['action']['generate']>[0];
429
- /** @alpha */
430
- type AgentTransformOptions = Parameters<SanityClient['observable']['agent']['action']['transform']>[0];
431
- /** @alpha */
432
- type AgentTranslateOptions = Parameters<SanityClient['observable']['agent']['action']['translate']>[0];
433
- /** @alpha */
434
- type AgentPromptOptions = Parameters<SanityClient['agent']['action']['prompt']>[0];
435
- /** @alpha */
436
- type AgentPatchOptions = Parameters<SanityClient['agent']['action']['patch']>[0];
437
- /** @alpha */
438
- type AgentGenerateResult = Awaited<ReturnType<SanityClient['observable']['agent']['action']['generate']>>;
439
- /** @alpha */
440
- type AgentTransformResult = Awaited<ReturnType<SanityClient['observable']['agent']['action']['transform']>>;
441
- /** @alpha */
442
- type AgentTranslateResult = Awaited<ReturnType<SanityClient['observable']['agent']['action']['translate']>>;
443
- /** @alpha */
444
- type AgentPromptResult = Awaited<ReturnType<SanityClient['agent']['action']['prompt']>>;
445
- /** @alpha */
446
- type AgentPatchResult = Awaited<ReturnType<SanityClient['agent']['action']['patch']>>;
447
- /**
448
- * Generates a new document using the agent.
449
- * @param instance - The Sanity instance.
450
- * @param options - The options for the agent generate action. See the [Agent Actions API](https://www.sanity.io/docs/agent-actions/introduction) for more details.
451
- * @returns An Observable emitting the result of the agent generate action.
452
- * @alpha
453
- */
454
- declare function agentGenerate(instance: SanityInstance, options: AgentGenerateOptions, resource?: DocumentResource): AgentGenerateResult;
455
- /**
456
- * Transforms a document using the agent.
457
- * @param instance - The Sanity instance.
458
- * @param options - The options for the agent transform action. See the [Agent Actions API](https://www.sanity.io/docs/agent-actions/introduction) for more details.
459
- * @returns An Observable emitting the result of the agent transform action.
460
- * @alpha
461
- */
462
- declare function agentTransform(instance: SanityInstance, options: AgentTransformOptions, resource?: DocumentResource): AgentTransformResult;
463
- /**
464
- * Translates a document using the agent.
465
- * @param instance - The Sanity instance.
466
- * @param options - The options for the agent translate action. See the [Agent Actions API](https://www.sanity.io/docs/agent-actions/introduction) for more details.
467
- * @returns An Observable emitting the result of the agent translate action.
468
- * @alpha
469
- */
470
- declare function agentTranslate(instance: SanityInstance, options: AgentTranslateOptions, resource?: DocumentResource): AgentTranslateResult;
471
- /**
472
- * Prompts the agent using the same instruction template format as the other actions, but returns text or json instead of acting on a document.
473
- * @param instance - The Sanity instance.
474
- * @param options - The options for the agent prompt action. See the [Agent Actions API](https://www.sanity.io/docs/agent-actions/introduction) for more details.
475
- * @returns An Observable emitting the result of the agent prompt action.
476
- * @alpha
477
- */
478
- declare function agentPrompt(instance: SanityInstance, options: AgentPromptOptions, resource?: DocumentResource): Observable<AgentPromptResult>;
479
- /**
480
- * Patches a document using the agent.
481
- * @param instance - The Sanity instance.
482
- * @param options - The options for the agent patch action. See the [Agent Actions API](https://www.sanity.io/docs/agent-actions/introduction) for more details.
483
- * @returns An Observable emitting the result of the agent patch action.
484
- * @alpha
485
- */
486
- declare function agentPatch(instance: SanityInstance, options: AgentPatchOptions, resource?: DocumentResource): Observable<AgentPatchResult>;
487
- /**
488
- * Represents the various states the authentication type can be in.
489
- *
490
- * @public
491
- */
492
- declare enum AuthStateType {
493
- LOGGED_IN = "logged-in",
494
- LOGGING_IN = "logging-in",
495
- ERROR = "error",
496
- LOGGED_OUT = "logged-out",
497
- }
498
- /**
499
- * Error message returned by the organization verification
500
- * @public
501
- */
502
- interface OrgVerificationResult {
503
- error: string | null;
504
- }
505
- /**
506
- * Creates an observable that emits the organization verification state for a given instance.
507
- * It combines the dashboard organization ID (from auth context) with the
508
- * project's actual organization ID (fetched via getProjectState) and compares them.
509
- * @public
510
- */
511
- declare function observeOrganizationVerificationState(instance: SanityInstance, projectIds: string[]): Observable<OrgVerificationResult>;
512
- /**
513
- * Defines a store action that operates on a specific state type
514
- */
515
- type StoreAction<TState, TParams extends unknown[], TReturn, TKey = unknown> = (context: StoreContext<TState, TKey>, ...params: TParams) => TReturn;
516
- /**
517
- * Represents a store action that has been bound to a specific store instance
518
- */
519
- type BoundStoreAction<_TState, TParams extends unknown[], TReturn> = (instance: SanityInstance, ...params: TParams) => TReturn;
520
- /**
521
- * @public
522
- */
523
- declare const handleAuthCallback: BoundStoreAction<AuthStoreState, [locationHref?: string | undefined], Promise<string | false>>;
524
- /**
525
- * @public
526
- */
527
- declare const logout: BoundStoreAction<AuthStoreState, [], Promise<void>>;
528
- type AllowedClientConfigKey = 'useCdn' | 'token' | 'perspective' | 'apiHost' | 'proxy' | 'withCredentials' | 'timeout' | 'maxRetries' | 'dataset' | 'projectId' | 'requestTagPrefix' | 'useProjectHostname';
529
- /**
530
- * States tracked by the client store
531
- * @public
532
- */
533
- interface ClientStoreState {
534
- token: string | null;
535
- clients: { [TKey in string]?: SanityClient };
536
- authMethod?: 'localstorage' | 'cookie';
537
- }
538
- /**
539
- * Options used when retrieving a client instance from the client store.
540
- *
541
- * This interface extends the base {@link ClientConfig} and adds:
542
- *
543
- * - **apiVersion:** A required string indicating the API version for the client.
544
- * - **scope:** An optional flag to choose between the project-specific client
545
- * ('project') and the global client ('global'). When set to `'global'`, the
546
- * global client is used.
547
- *
548
- * These options are utilized by `getClient` and `getClientState` to configure and
549
- * return appropriate client instances that automatically handle authentication
550
- * updates and configuration changes.
551
- *
552
- * @public
553
- */
554
- interface ClientOptions extends Pick<ClientConfig, AllowedClientConfigKey> {
555
- /**
556
- * An optional flag to choose between the default client (typically project-level)
557
- * and the global client ('global'). When set to `'global'`, the global client
558
- * is used.
559
- */
560
- scope?: 'default' | 'global';
561
- /**
562
- * A required string indicating the API version for the client.
563
- */
564
- apiVersion: string;
565
- /**
566
- * @internal
567
- * The SDK resource to use for the client -- this will get transformed into a ClientConfig resource.
568
- */
569
- resource?: DocumentResource;
570
- }
571
- /**
572
- * Retrieves a Sanity client instance configured with the provided options.
573
- *
574
- * This function returns a client instance configured for the project or as a
575
- * global client based on the options provided. It ensures efficient reuse of
576
- * client instances by returning the same instance for the same options.
577
- * For automatic handling of authentication token updates, consider using
578
- * `getClientState`.
579
- *
580
- * @public
581
- */
582
- declare const getClient: BoundStoreAction<ClientStoreState, [options: ClientOptions], SanityClient>;
583
- /**
584
- * Returns a state source for the Sanity client instance.
585
- *
586
- * This function provides a subscribable state source that emits updated client
587
- * instances whenever relevant configurations change (such as authentication tokens).
588
- * Use this when you need to react to client configuration changes in your application.
589
- *
590
- * @public
591
- */
592
- declare const getClientState: BoundStoreAction<ClientStoreState, [options: ClientOptions], StateSource<SanityClient>>;
593
- /**
594
- * Message sent from a containing app to an iframe
595
- * @public
596
- */
597
- type FrameMessage = Message;
598
- /**
599
- * Message sent from an iframe to a containing app
600
- * @public
601
- */
602
- type WindowMessage = Message;
603
- /**
604
- * Message from SDK (iframe) to Parent (dashboard) to request a new token
605
- * @internal
606
- */
607
- type RequestNewTokenMessage = {
608
- type: 'dashboard/v1/auth/tokens/create';
609
- payload?: undefined;
610
- };
611
- /**
612
- * Message from Parent (dashboard) to SDK (iframe) with the new token
613
- * @internal
614
- */
615
- type NewTokenResponseMessage = {
616
- type: 'dashboard/v1/auth/tokens/create';
617
- payload: {
618
- token: string | null;
619
- error?: string;
620
- };
621
- };
622
- /**
623
- * Individual channel with its relevant options
624
- * @public
625
- */
626
- interface ChannelEntry {
627
- channel: ChannelInstance<FrameMessage, WindowMessage>;
628
- options: ChannelInput;
629
- refCount: number;
630
- }
631
- /**
632
- * Internal state tracking comlink connections
633
- * @public
634
- */
635
- interface ComlinkControllerState {
636
- controller: Controller | null;
637
- controllerOrigin: string | null;
638
- channels: Map<string, ChannelEntry>;
639
- }
640
- /**
641
- * Calls the destroy method on the controller and resets the controller state.
642
- * @public
643
- */
644
- declare const destroyController: BoundStoreAction<ComlinkControllerState, [], void>;
645
- /**
646
- * Retrieve or create a channel to be used for communication between
647
- * an application and the controller.
648
- * @public
649
- */
650
- declare const getOrCreateChannel: BoundStoreAction<ComlinkControllerState, [options: ChannelInput], ChannelInstance<_sanity_comlink3.Message, _sanity_comlink3.Message>>;
651
- /**
652
- * Initializes or fetches a controller to handle communication
653
- * between an application and iframes.
654
- * @public
655
- */
656
- declare const getOrCreateController: BoundStoreAction<ComlinkControllerState, [targetOrigin: string], Controller>;
657
- /**
658
- * Signals to the store that the consumer has stopped using the channel
659
- * @public
660
- */
661
- declare const releaseChannel: BoundStoreAction<ComlinkControllerState, [name: string], void>;
662
- /**
663
- * Individual node with its relevant options
664
- * @public
665
- */
666
- interface NodeEntry {
667
- node: Node<WindowMessage, FrameMessage>;
668
- options: NodeInput;
669
- status: Status;
670
- statusUnsub?: () => void;
671
- }
672
- /**
673
- * Internal state tracking comlink connections
674
- * @public
675
- */
676
- interface ComlinkNodeState {
677
- nodes: Map<string, NodeEntry>;
678
- subscriptions: Map<string, Set<symbol>>;
679
- }
680
- /**
681
- * Signals to the store that the consumer has stopped using the node
682
- * @public
683
- */
684
- declare const releaseNode: BoundStoreAction<ComlinkNodeState, [name: string], void>;
685
- /**
686
- * Retrieve or create a node to be used for communication between
687
- * an application and the controller -- specifically, a node should
688
- * be created within a frame / window to communicate with the controller.
689
- * @public
690
- */
691
- declare const getOrCreateNode: BoundStoreAction<ComlinkNodeState, [options: NodeInput], Node<_sanity_comlink3.Message, _sanity_comlink3.Message>>;
692
- /**
693
- * @public
694
- */
695
- interface NodeState {
696
- node: Node<WindowMessage, FrameMessage>;
697
- status: Status | undefined;
698
- }
699
- /**
700
- * Provides a subscribable state source for a node by name
701
- * @param instance - The Sanity instance to get the node state for
702
- * @param nodeInput - The configuration for the node to get the state for
703
-
704
- * @returns A subscribable state source for the node
705
- * @public
706
- */
707
- declare const getNodeState: BoundStoreAction<ComlinkNodeState, [NodeInput], StateSource<NodeState | undefined>>;
708
- /**
709
- * Creates or validates a `DocumentHandle` object.
710
- * Ensures the provided object conforms to the `DocumentHandle` interface.
711
- * @param handle - The object containing document identification properties.
712
- * @returns The validated `DocumentHandle` object.
713
- * @public
714
- */
715
- declare function createDocumentHandle<TDocumentType extends string = string, TDataset extends string = string, TProjectId extends string = string>(handle: DocumentHandle<TDocumentType, TDataset, TProjectId>): DocumentHandle<TDocumentType, TDataset, TProjectId>;
716
- /**
717
- * Creates or validates a `DocumentTypeHandle` object.
718
- * Ensures the provided object conforms to the `DocumentTypeHandle` interface.
719
- * @param handle - The object containing document type identification properties.
720
- * @returns The validated `DocumentTypeHandle` object.
721
- * @public
722
- */
723
- declare function createDocumentTypeHandle<TDocumentType extends string = string, TDataset extends string = string, TProjectId extends string = string>(handle: DocumentTypeHandle<TDocumentType, TDataset, TProjectId>): DocumentTypeHandle<TDocumentType, TDataset, TProjectId>;
724
- /**
725
- * Creates or validates a `ProjectHandle` object.
726
- * Ensures the provided object conforms to the `ProjectHandle` interface.
727
- * @param handle - The object containing project identification properties.
728
- * @returns The validated `ProjectHandle` object.
729
- * @public
730
- */
731
- declare function createProjectHandle<TProjectId extends string = string>(handle: ProjectHandle<TProjectId>): ProjectHandle<TProjectId>;
732
- /**
733
- * Creates or validates a `DatasetHandle` object.
734
- * Ensures the provided object conforms to the `DatasetHandle` interface.
735
- * @param handle - The object containing dataset identification properties.
736
- * @returns The validated `DatasetHandle` object.
737
- * @public
738
- */
739
- declare function createDatasetHandle<TDataset extends string = string, TProjectId extends string = string>(handle: DatasetHandle<TDataset, TProjectId>): DatasetHandle<TDataset, TProjectId>;
740
- /**
741
- * Logging infrastructure for the Sanity SDK
742
- *
743
- * Provides multi-level, namespace-based logging for both SDK users and maintainers.
744
- * In production builds, all logging can be stripped via tree-shaking.
745
- *
746
- * @example SDK User
747
- * ```ts
748
- * import {configureLogging} from '@sanity/sdk'
749
- *
750
- * configureLogging({
751
- * level: 'info',
752
- * namespaces: ['auth', 'document']
753
- * })
754
- * ```
755
- *
756
- * @example SDK Maintainer
757
- * ```ts
758
- * configureLogging({
759
- * level: 'trace',
760
- * namespaces: ['*'],
761
- * internal: true
762
- * })
763
- * ```
764
- */
765
- /**
766
- * Log levels in order of verbosity (least to most)
767
- * - error: Critical failures that prevent operation
768
- * - warn: Issues that may cause problems but don't stop execution
769
- * - info: High-level informational messages (SDK user level)
770
- * - debug: Detailed debugging information (maintainer level)
771
- * - trace: Very detailed tracing (maintainer level, includes RxJS streams)
772
- * @public
773
- */
774
- type LogLevel = 'error' | 'warn' | 'info' | 'debug' | 'trace';
775
- /**
776
- * Log namespaces organize logs by functional domain
777
- *
778
- * @remarks
779
- * This is an extensible string type. As logging is added to more modules,
780
- * additional namespaces will be recognized. Currently implemented namespaces
781
- * will be documented as they are added.
782
- * @internal
783
- */
784
- type LogNamespace = string;
785
- /**
786
- * Configuration for the logging system
787
- * @public
788
- */
789
- interface LoggerConfig {
790
- /**
791
- * Minimum log level to output
792
- * @defaultValue 'warn'
793
- */
794
- level?: LogLevel;
795
- /**
796
- * Namespaces to enable. Use ['*'] for all namespaces
797
- * @defaultValue []
798
- * @remarks
799
- * Available namespaces depend on which modules have logging integrated.
800
- * Check the SDK documentation for the current list of instrumented modules.
801
- * @example ['auth', 'document']
802
- */
803
- namespaces?: string[];
804
- /**
805
- * Enable internal/maintainer-level logging
806
- * Shows RxJS streams, store internals, etc.
807
- * @defaultValue false
808
- */
809
- internal?: boolean;
810
- /**
811
- * Custom log handler (for testing or custom output)
812
- * @defaultValue console methods
813
- */
814
- handler?: LogHandler;
815
- /**
816
- * Enable timestamps in log output
817
- * @defaultValue true
818
- */
819
- timestamps?: boolean;
820
- /**
821
- * Enable in production builds
822
- * @defaultValue false
823
- */
824
- enableInProduction?: boolean;
825
- }
826
- /**
827
- * Custom log handler interface
828
- *
829
- * @internal
830
- */
831
- interface LogHandler {
832
- error: (message: string, context?: LogContext) => void;
833
- warn: (message: string, context?: LogContext) => void;
834
- info: (message: string, context?: LogContext) => void;
835
- debug: (message: string, context?: LogContext) => void;
836
- trace: (message: string, context?: LogContext) => void;
837
- }
838
- /**
839
- * Context object attached to log messages
840
- *
841
- * This interface allows you to attach arbitrary contextual data to log messages.
842
- * The index signature `[key: string]: unknown` enables you to add any custom
843
- * properties relevant to your log entry (e.g., `userId`, `documentId`, `action`, etc.).
844
- *
845
- * **Sensitive data sanitization:**
846
- * Top-level keys containing sensitive names (`token`, `password`, `secret`, `apiKey`,
847
- * `authorization`) are automatically redacted to `[REDACTED]` in log output.
848
- *
849
- * @example
850
- * ```ts
851
- * logger.info('User logged in', {
852
- * userId: '123', // Custom context
853
- * action: 'login', // Custom context
854
- * token: 'secret' // Will be redacted to [REDACTED]
855
- * })
856
- * ```
857
- *
858
- * @internal
859
- */
860
- interface LogContext {
861
- /**
862
- * Custom context properties that provide additional information about the log entry.
863
- * Any key-value pairs can be added here (e.g., userId, documentId, requestId, etc.).
864
- * Keys with sensitive names (token, password, secret, apiKey, authorization) are
865
- * automatically sanitized.
866
- */
867
- [key: string]: unknown;
868
- /** Error object if logging an error */
869
- error?: Error | unknown;
870
- /** Duration in milliseconds for timed operations */
871
- duration?: number;
872
- /** Stack trace for debugging */
873
- stack?: string;
874
- /** Instance context (automatically added when available) */
875
- instanceContext?: InstanceContext;
876
- }
877
- /**
878
- * Instance context information automatically added to logs
879
- * @internal
880
- */
881
- interface InstanceContext {
882
- /** Unique instance ID */
883
- instanceId?: string;
884
- /** Project ID */
885
- projectId?: string;
886
- /** Dataset name */
887
- dataset?: string;
888
- }
889
- /**
890
- * Logger instance for a specific namespace
891
- * @internal
892
- */
893
- interface Logger {
894
- readonly namespace: string;
895
- error: (message: string, context?: LogContext) => void;
896
- warn: (message: string, context?: LogContext) => void;
897
- info: (message: string, context?: LogContext) => void;
898
- debug: (message: string, context?: LogContext) => void;
899
- trace: (message: string, context?: LogContext) => void;
900
- /** Check if a log level is enabled (for performance-sensitive code) */
901
- isLevelEnabled: (level: LogLevel) => boolean;
902
- /** Create a child logger with extended context */
903
- child: (context: LogContext) => Logger;
904
- /** Get the instance context if available */
905
- getInstanceContext: () => InstanceContext | undefined;
906
- }
907
- /**
908
- * Configure logging for the Sanity SDK
909
- *
910
- * This function allows you to control what logs are output by the SDK,
911
- * making it easier to debug issues in development or production.
912
- *
913
- * @remarks
914
- * **Zero-Config via Environment Variable (Recommended):**
915
- *
916
- * The SDK automatically reads the `DEBUG` environment variable, making it
917
- * easy to enable logging without code changes:
918
- *
919
- * ```bash
920
- * # Enable all SDK logging at debug level
921
- * DEBUG=sanity:* npm start
922
- *
923
- * # Enable specific namespaces
924
- * DEBUG=sanity:auth,sanity:document npm start
925
- *
926
- * # Enable trace level for all namespaces
927
- * DEBUG=sanity:trace:* npm start
928
- *
929
- * # Enable internal/maintainer logs
930
- * DEBUG=sanity:*:internal npm start
931
- * ```
932
- *
933
- * This matches the pattern used by Sanity CLI and Studio, making it familiar
934
- * and easy for support teams to help troubleshoot issues.
935
- *
936
- * **Programmatic Configuration (Advanced):**
937
- *
938
- * For more control (custom handlers, dynamic configuration), call this function
939
- * explicitly. Programmatic configuration overrides environment variables.
940
- *
941
- * **For Application Developers:**
942
- * Use `info`, `warn`, or `error` levels to see high-level SDK activity
943
- * without being overwhelmed by internal details.
944
- *
945
- * **For SDK Maintainers:**
946
- * Use `debug` or `trace` levels with `internal: true` to see detailed
947
- * information about store operations, RxJS streams, and state transitions.
948
- *
949
- * **Instance Context:**
950
- * Logs automatically include instance information (projectId, dataset, instanceId)
951
- * when available, making it easier to debug multi-instance scenarios:
952
- * ```
953
- * [INFO] [auth] [project:abc] [dataset:production] User logged in
954
- * ```
955
- *
956
- * **Available Namespaces:**
957
- * - `sdk` - SDK initialization, configuration, and lifecycle
958
- * - `auth` - Authentication and authorization (when instrumented in the future)
959
- * - And more as logging is added to modules
960
- *
961
- * @example Zero-config via environment variable (recommended for debugging)
962
- * ```bash
963
- * # Just set DEBUG and run your app - no code changes needed!
964
- * DEBUG=sanity:* npm start
965
- * ```
966
- *
967
- * @example Programmatic configuration (application developer)
968
- * ```ts
969
- * import {configureLogging} from '@sanity/sdk'
970
- *
971
- * // Log warnings and errors for auth and document operations
972
- * configureLogging({
973
- * level: 'warn',
974
- * namespaces: ['auth', 'document']
975
- * })
976
- * ```
977
- *
978
- * @example Programmatic configuration (SDK maintainer)
979
- * ```ts
980
- * import {configureLogging} from '@sanity/sdk'
981
- *
982
- * // Enable all logs including internal traces
983
- * configureLogging({
984
- * level: 'trace',
985
- * namespaces: ['*'],
986
- * internal: true
987
- * })
988
- * ```
989
- *
990
- * @example Custom handler (for testing)
991
- * ```ts
992
- * import {configureLogging} from '@sanity/sdk'
993
- *
994
- * const logs: string[] = []
995
- * configureLogging({
996
- * level: 'info',
997
- * namespaces: ['*'],
998
- * handler: {
999
- * error: (msg) => logs.push(msg),
1000
- * warn: (msg) => logs.push(msg),
1001
- * info: (msg) => logs.push(msg),
1002
- * debug: (msg) => logs.push(msg),
1003
- * trace: (msg) => logs.push(msg),
1004
- * }
1005
- * })
1006
- * ```
1007
- *
1008
- * @public
1009
- */
1010
- declare function configureLogging(config: LoggerConfig): void;
1011
- /** @public */
1012
- declare const getDatasetsState: BoundStoreAction<FetcherStoreState<[options?: ProjectHandle<string> | undefined], _sanity_client4.DatasetsResponse>, [options?: ProjectHandle<string> | undefined], StateSource<_sanity_client4.DatasetsResponse | undefined>>;
1013
- /** @public */
1014
- declare const resolveDatasets: BoundStoreAction<FetcherStoreState<[options?: ProjectHandle<string> | undefined], _sanity_client4.DatasetsResponse>, [options?: ProjectHandle<string> | undefined], Promise<_sanity_client4.DatasetsResponse>>;
1015
- /**
1016
- * Represents an action to create a new document.
1017
- * Specifies the document type and optionally a document ID (which will be treated as the published ID).
1018
- * @beta
1019
- */
1020
- interface CreateDocumentAction<TDocumentType extends string = string, TDataset extends string = string, TProjectId extends string = string> extends DocumentTypeHandle<TDocumentType, TDataset, TProjectId> {
1021
- type: 'document.create';
1022
- /**
1023
- * Optional initial field values for the document.
1024
- * These values will be set when the document is created.
1025
- * System fields (_id, _type, _rev, _createdAt, _updatedAt) are omitted as they are set automatically.
1026
- */
1027
- initialValue?: Partial<Omit<SanityDocument$2<TDocumentType, `${TProjectId}.${TDataset}`>, '_id' | '_type' | '_rev' | '_createdAt' | '_updatedAt'>>;
1028
- }
1029
- /**
1030
- * Represents an action to delete an existing document.
1031
- * Requires the full document handle including the document ID.
1032
- * @beta
1033
- */
1034
- interface DeleteDocumentAction<TDocumentType extends string = string, TDataset extends string = string, TProjectId extends string = string> extends DocumentHandle<TDocumentType, TDataset, TProjectId> {
1035
- type: 'document.delete';
1036
- }
1037
- /**
1038
- * Represents an action to edit an existing document using patches.
1039
- * Requires the full document handle and an array of patch operations.
1040
- * @beta
1041
- */
1042
- interface EditDocumentAction<TDocumentType extends string = string, TDataset extends string = string, TProjectId extends string = string> extends DocumentHandle<TDocumentType, TDataset, TProjectId> {
1043
- type: 'document.edit';
1044
- patches?: PatchOperations[];
1045
- }
1046
- /**
1047
- * Represents an action to publish the draft version of a document.
1048
- * Requires the full document handle.
1049
- * @beta
1050
- */
1051
- interface PublishDocumentAction<TDocumentType extends string = string, TDataset extends string = string, TProjectId extends string = string> extends DocumentHandle<TDocumentType, TDataset, TProjectId> {
1052
- type: 'document.publish';
1053
- }
1054
- /**
1055
- * Represents an action to unpublish a document, moving its published content to a draft.
1056
- * Requires the full document handle.
1057
- * @beta
1058
- */
1059
- interface UnpublishDocumentAction<TDocumentType extends string = string, TDataset extends string = string, TProjectId extends string = string> extends DocumentHandle<TDocumentType, TDataset, TProjectId> {
1060
- type: 'document.unpublish';
1061
- }
1062
- /**
1063
- * Represents an action to discard the draft changes of a document.
1064
- * Requires the full document handle.
1065
- * @beta
1066
- */
1067
- interface DiscardDocumentAction<TDocumentType extends string = string, TDataset extends string = string, TProjectId extends string = string> extends DocumentHandle<TDocumentType, TDataset, TProjectId> {
1068
- type: 'document.discard';
1069
- }
1070
- /**
1071
- * Union type representing all possible document actions within the SDK.
1072
- * @beta
1073
- */
1074
- type DocumentAction<TDocumentType extends string = string, TDataset extends string = string, TProjectId extends string = string> = CreateDocumentAction<TDocumentType, TDataset, TProjectId> | DeleteDocumentAction<TDocumentType, TDataset, TProjectId> | EditDocumentAction<TDocumentType, TDataset, TProjectId> | PublishDocumentAction<TDocumentType, TDataset, TProjectId> | UnpublishDocumentAction<TDocumentType, TDataset, TProjectId> | DiscardDocumentAction<TDocumentType, TDataset, TProjectId>;
1075
- /**
1076
- * Union of every action accepted by `applyDocumentActions` — both document-
1077
- * level actions and release-lifecycle actions.
1078
- * @beta
1079
- */
1080
- type Action<TDocumentType extends string = string, TDataset extends string = string, TProjectId extends string = string> = DocumentAction<TDocumentType, TDataset, TProjectId> | ReleaseAction;
1081
- /**
1082
- * Creates a `CreateDocumentAction` object.
1083
- * @param doc - A handle identifying the document type, dataset, and project. An optional `documentId` can be provided.
1084
- * @param initialValue - Optional initial field values for the document. (System fields are omitted as they are set automatically.)
1085
- * @returns A `CreateDocumentAction` object ready for dispatch.
1086
- * @beta
1087
- */
1088
- 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<TDocumentType, `${TProjectId}.${TDataset}`>, '_id' | '_type' | '_rev' | '_createdAt' | '_updatedAt'>>): CreateDocumentAction<TDocumentType, TDataset, TProjectId>;
1089
- /**
1090
- * Creates a `DeleteDocumentAction` object.
1091
- * @param doc - A handle uniquely identifying the document to be deleted.
1092
- * @returns A `DeleteDocumentAction` object ready for dispatch.
1093
- * @beta
1094
- */
1095
- declare function deleteDocument<TDocumentType extends string = string, TDataset extends string = string, TProjectId extends string = string>(doc: DocumentHandle<TDocumentType, TDataset, TProjectId>): DeleteDocumentAction<TDocumentType, TDataset, TProjectId>;
1096
- /**
1097
- * Creates an `EditDocumentAction` object with patches for modifying a document.
1098
- * Accepts patches in either the standard `PatchOperations` format or as a `SanityMutatePatchMutation` from `@sanity/mutate`.
1099
- *
1100
- * @param doc - A handle uniquely identifying the document to be edited.
1101
- * @param sanityMutatePatch - A patch mutation object from `@sanity/mutate`.
1102
- * @returns An `EditDocumentAction` object ready for dispatch.
1103
- * @beta
1104
- */
1105
- declare function editDocument<TDocumentType extends string = string, TDataset extends string = string, TProjectId extends string = string>(doc: DocumentHandle<TDocumentType, TDataset, TProjectId>, sanityMutatePatch: PatchMutation): EditDocumentAction<TDocumentType, TDataset, TProjectId>;
1106
- /**
1107
- * Creates an `EditDocumentAction` object with patches for modifying a document.
1108
- *
1109
- * @param doc - A handle uniquely identifying the document to be edited.
1110
- * @param patches - A single patch operation or an array of patch operations.
1111
- * @returns An `EditDocumentAction` object ready for dispatch.
1112
- * @beta
1113
- */
1114
- declare function editDocument<TDocumentType extends string = string, TDataset extends string = string, TProjectId extends string = string>(doc: DocumentHandle<TDocumentType, TDataset, TProjectId>, patches?: PatchOperations | PatchOperations[]): EditDocumentAction<TDocumentType, TDataset, TProjectId>;
1115
- /**
1116
- * Creates a `PublishDocumentAction` object.
1117
- * @param doc - A handle uniquely identifying the document to be published.
1118
- * @returns A `PublishDocumentAction` object ready for dispatch.
1119
- * @beta
1120
- */
1121
- declare function publishDocument<TDocumentType extends string = string, TDataset extends string = string, TProjectId extends string = string>(doc: DocumentHandle<TDocumentType, TDataset, TProjectId>): PublishDocumentAction<TDocumentType, TDataset, TProjectId>;
1122
- /**
1123
- * Creates an `UnpublishDocumentAction` object.
1124
- * @param doc - A handle uniquely identifying the document to be unpublished.
1125
- * @returns An `UnpublishDocumentAction` object ready for dispatch.
1126
- * @beta
1127
- */
1128
- declare function unpublishDocument<TDocumentType extends string = string, TDataset extends string = string, TProjectId extends string = string>(doc: DocumentHandle<TDocumentType, TDataset, TProjectId>): UnpublishDocumentAction<TDocumentType, TDataset, TProjectId>;
1129
- /**
1130
- * Creates a `DiscardDocumentAction` object.
1131
- * @param doc - A handle uniquely identifying the document whose draft changes are to be discarded.
1132
- * @returns A `DiscardDocumentAction` object ready for dispatch.
1133
- * @beta
1134
- */
1135
- declare function discardDocument<TDocumentType extends string = string, TDataset extends string = string, TProjectId extends string = string>(doc: DocumentHandle<TDocumentType, TDataset, TProjectId>): DiscardDocumentAction<TDocumentType, TDataset, TProjectId>;
1136
- /**
1137
- * Creates a new release. The `releaseId` must be unique within the current
1138
- * retention period.
1139
- * @beta
1140
- */
1141
- interface CreateReleaseAction extends ReleaseHandle {
1142
- type: 'release.create';
1143
- metadata: ReleaseDocument['metadata'];
1144
- }
1145
- /**
1146
- * Patches the metadata of an existing release.
1147
- * @beta
1148
- */
1149
- interface EditReleaseAction extends ReleaseHandle {
1150
- type: 'release.edit';
1151
- patch: PatchOperations;
1152
- }
1153
- /**
1154
- * Publishes all version documents in a release.
1155
- * @beta
1156
- */
1157
- interface PublishReleaseAction extends ReleaseHandle {
1158
- type: 'release.publish';
1159
- }
1160
- /**
1161
- * Schedules a release to be published at the given UTC time. Locks the
1162
- * version documents server-side until the release is unscheduled or published.
1163
- * @beta
1164
- */
1165
- interface ScheduleReleaseAction extends ReleaseHandle {
1166
- type: 'release.schedule';
1167
- publishAt: string;
1168
- }
1169
- /**
1170
- * Unschedules a release that was previously scheduled, returning it to the
1171
- * active editable state.
1172
- * @beta
1173
- */
1174
- interface UnscheduleReleaseAction extends ReleaseHandle {
1175
- type: 'release.unschedule';
1176
- }
1177
- /**
1178
- * Archives an active release. Version documents within the release are
1179
- * removed and no longer queryable, though still recoverable through history
1180
- * during the retention period.
1181
- * @beta
1182
- */
1183
- interface ArchiveReleaseAction extends ReleaseHandle {
1184
- type: 'release.archive';
1185
- }
1186
- /**
1187
- * Restores an archived release. Only possible during the retention period.
1188
- * @beta
1189
- */
1190
- interface UnarchiveReleaseAction extends ReleaseHandle {
1191
- type: 'release.unarchive';
1192
- }
1193
- /**
1194
- * Permanently deletes an archived or published release. To remove an active
1195
- * release, use the archive action first.
1196
- * @beta
1197
- */
1198
- interface DeleteReleaseAction extends ReleaseHandle {
1199
- type: 'release.delete';
1200
- }
1201
- /**
1202
- * Union of all release actions that can be dispatched alongside document
1203
- * actions through `applyDocumentActions`.
1204
- * @beta
1205
- */
1206
- type ReleaseAction = CreateReleaseAction | EditReleaseAction | PublishReleaseAction | ScheduleReleaseAction | UnscheduleReleaseAction | ArchiveReleaseAction | UnarchiveReleaseAction | DeleteReleaseAction;
1207
- /** @beta */
1208
- declare function createRelease(handle: ReleaseHandle, metadata?: ReleaseDocument['metadata']): CreateReleaseAction;
1209
- /** @beta */
1210
- declare function editRelease(handle: ReleaseHandle, patch: PatchOperations): EditReleaseAction;
1211
- /** @beta */
1212
- declare function publishRelease(handle: ReleaseHandle): PublishReleaseAction;
1213
- /** @beta */
1214
- declare function scheduleRelease(handle: ReleaseHandle, publishAt: string): ScheduleReleaseAction;
1215
- /** @beta */
1216
- declare function unscheduleRelease(handle: ReleaseHandle): UnscheduleReleaseAction;
1217
- /** @beta */
1218
- declare function archiveRelease(handle: ReleaseHandle): ArchiveReleaseAction;
1219
- /** @beta */
1220
- declare function unarchiveRelease(handle: ReleaseHandle): UnarchiveReleaseAction;
1221
- /** @beta */
1222
- declare function deleteRelease(handle: ReleaseHandle): DeleteReleaseAction;
1223
- /**
1224
- * Represents a reactive state source that provides synchronized access to store data
1225
- *
1226
- * @remarks
1227
- * Designed to work with React's useSyncExternalStore hook. Provides three ways to access data:
1228
- * 1. `getCurrent()` for synchronous current value access
1229
- * 2. `subscribe()` for imperative change notifications
1230
- * 3. `observable` for reactive stream access
1231
- *
1232
- * @public
1233
- */
1234
- interface StateSource<T> {
1235
- /**
1236
- * Subscribes to state changes with optional callback
1237
- * @param onStoreChanged - Called whenever relevant state changes occur
1238
- * @returns Unsubscribe function to clean up the subscription
1239
- */
1240
- subscribe: (onStoreChanged?: () => void) => () => void;
1241
- /**
1242
- * Gets the current derived state value
1243
- *
1244
- * @remarks
1245
- * Safe to call without subscription. Will always return the latest value
1246
- * based on the current store state and selector parameters.
1247
- */
1248
- getCurrent: () => T;
1249
- /**
1250
- * Observable stream of state values
1251
- *
1252
- * @remarks
1253
- * Shares a single underlying subscription between all observers. Emits:
1254
- * - Immediately with current value on subscription
1255
- * - On every relevant state change
1256
- * - Errors if selector throws
1257
- */
1258
- observable: Observable<T>;
1259
- }
1260
- /**
1261
- * Context passed to selectors when deriving state
1262
- *
1263
- * @remarks
1264
- * Provides access to both the current state value and the Sanity instance,
1265
- * allowing selectors to use configuration values when computing derived state.
1266
- * The context is memoized for each state object and instance combination
1267
- * to optimize performance and prevent unnecessary recalculations.
1268
- *
1269
- * @example
1270
- * ```ts
1271
- * // Using both state and instance in a selector (psuedo example)
1272
- * const getUserByProjectId = createStateSourceAction(
1273
- * ({ state, instance }: SelectorContext<UsersState>, options?: ProjectHandle) => {
1274
- * const allUsers = state.users
1275
- * const projectId = options?.projectId ?? instance.config.projectId
1276
- * return allUsers.filter(user => user.projectId === projectId)
1277
- * }
1278
- * )
1279
- * ```
1280
- */
1281
- interface SelectorContext<TState> {
1282
- /**
1283
- * The current state object from the store
1284
- */
1285
- state: TState;
1286
- /**
1287
- * The Sanity instance associated with this state
1288
- */
1289
- instance: SanityInstance;
1290
- }
1291
- /**
1292
- * Function type for selecting derived state from store state and parameters
1293
- * @public
1294
- */
1295
- type Selector<TState, TParams extends unknown[], TReturn> = (context: SelectorContext<TState>, ...params: TParams) => TReturn;
1296
- /**
1297
- * Split the entire path string on dots "outside" of any brackets.
1298
- *
1299
- * For example:
1300
- * ```
1301
- * "friends[0].name"
1302
- * ```
1303
- *
1304
- * becomes:
1305
- *
1306
- * ```
1307
- * [...ParseSegment<"friends[0]">, ...ParseSegment<"name">]
1308
- * ```
1309
- *
1310
- * (We use a simple recursion that splits on the first dot.)
1311
- */
1312
- type PathParts<TPath extends string> = TPath extends `${infer Head}.${infer Tail}` ? [Head, ...PathParts<Tail>] : TPath extends '' ? [] : [TPath];
1313
- /**
1314
- * Given a type T and an array of "access keys" Parts, recursively index into T.
1315
- *
1316
- * If a part is a key, it looks up that property.
1317
- * If T is an array and the part is a number, it "indexes" into the element type.
1318
- */
1319
- 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,
1320
- // Key/index doesn't exist
1321
- TTail extends readonly (string | number)[] ? TTail : []> : never;
1322
- /**
1323
- * Given a document type TDocument and a JSON Match path string TPath,
1324
- * compute the type found at that path.
1325
- * @beta
1326
- */
1327
- type JsonMatch<TDocument, TPath extends string> = DeepGet<TDocument, PathParts<TPath>>;
1328
- /**
1329
- * Represents a set of document that will go into `applyMutations`. Before
1330
- * applying a mutation, it's expected that all relevant documents that the
1331
- * mutations affect are included, including those that do not exist yet.
1332
- * Documents that don't exist have a `null` value.
1333
- */
1334
- type DocumentSet<TDocument extends SanityDocument$1 = SanityDocument$1> = { [TDocumentId in string]?: TDocument | null };
1335
- type Grant = 'read' | 'update' | 'create' | 'history';
1336
- /** @beta */
1337
- interface PermissionDeniedReason {
1338
- type: 'precondition' | 'access';
1339
- message: string;
1340
- documentId?: string;
1341
- }
1342
- /** @beta */
1343
- type DocumentPermissionsResult = {
1344
- allowed: false;
1345
- message: string;
1346
- reasons: PermissionDeniedReason[];
1347
- } | {
1348
- allowed: true;
1349
- message?: undefined;
1350
- reasons?: undefined;
1351
- };
1352
- interface SharedListener {
1353
- events: Observable<ListenEvent<SanityDocument>>;
1354
- dispose: () => void;
1355
- }
1356
- interface DocumentStoreState {
1357
- documentStates: { [TDocumentId in string]?: DocumentState };
1358
- queued: QueuedTransaction[];
1359
- applied: AppliedTransaction[];
1360
- outgoing?: OutgoingTransaction;
1361
- grants?: Record<Grant, ExprNode>;
1362
- /**
1363
- * The current user's identity (their user ID).
1364
- */
1365
- identity?: string;
1366
- error?: unknown;
1367
- sharedListener: SharedListener;
1368
- fetchDocument: (documentId: string) => Observable<SanityDocument$2 | null>;
1369
- events: Subject<DocumentEvent>;
1370
- }
1371
- interface DocumentState {
1372
- id: string;
1373
- /**
1374
- * the "remote" local copy that matches the server. represents the last known
1375
- * server state. this gets updated every time we confirm remote patches
1376
- */
1377
- remote?: SanityDocument$2 | null;
1378
- /**
1379
- * the current ephemeral working copy that includes local optimistic changes
1380
- * that have not yet been confirmed by the server
1381
- */
1382
- local?: SanityDocument$2 | null;
1383
- /**
1384
- * the revision that our remote document is at
1385
- */
1386
- remoteRev?: string | null;
1387
- /**
1388
- * Array of subscription IDs. This document state will be deleted if there are
1389
- * no subscribers.
1390
- */
1391
- subscriptions: string[];
1392
- /**
1393
- * An object keyed by transaction ID of revisions sent out but that have not
1394
- * yet been verified yet. When an applied transaction is transitioned to an
1395
- * outgoing transaction, it also adds unverified revisions for each document
1396
- * that is part of that outgoing transaction. Transactions are submitted to
1397
- * the server with a locally generated transaction ID. This way we can observe
1398
- * when our transaction comes back through the shared listener. Each listener
1399
- * event that comes back contains a `previousRev`. If we see our own
1400
- * transaction with a different `previousRev` than expected, we can rebase our
1401
- * local transactions on top of this new remote.
1402
- */
1403
- unverifiedRevisions?: { [TTransactionId in string]?: UnverifiedDocumentRevision };
1404
- }
1405
- /**
1406
- * @beta
1407
- * Options for specifying a document and optionally a path within it.
1408
- */
1409
- interface DocumentOptions<TPath extends string | undefined = undefined, TDocumentType extends string = string, TDataset extends string = string, TProjectId extends string = string> extends DocumentHandle<TDocumentType, TDataset, TProjectId> {
1410
- path?: TPath;
1411
- }
1412
- /** @beta */
1413
- 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$2<TDocumentType, `${TProjectId}.${TDataset}`> | undefined | null>;
1414
- /** @beta */
1415
- 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$2<TDocumentType, `${TProjectId}.${TDataset}`>, TPath> | undefined>;
1416
- /** @beta */
1417
- declare function getDocumentState<TData>(instance: SanityInstance, options: DocumentOptions<string | undefined>): StateSource<TData | undefined | null>;
1418
- /** @beta */
1419
- declare function resolveDocument<TDocumentType extends string = string, TDataset extends string = string, TProjectId extends string = string>(instance: SanityInstance, docHandle: DocumentHandle<TDocumentType, TDataset, TProjectId>): Promise<SanityDocument$2<TDocumentType, `${TProjectId}.${TDataset}`> | null>;
1420
- /** @beta */
1421
- declare function resolveDocument<TData extends SanityDocument$2>(instance: SanityInstance, docHandle: DocumentHandle<string, string, string>): Promise<TData | null>;
1422
- /** @beta */
1423
- declare const getDocumentSyncStatus: BoundStoreAction<DocumentStoreState, [doc: DocumentHandle<string, string, string>], StateSource<boolean | undefined>>;
1424
- type PermissionsStateOptions = {
1425
- resource?: DocumentResource;
1426
- actions: DocumentAction[];
1427
- };
1428
- /** @beta */
1429
- declare const getPermissionsState: BoundStoreAction<DocumentStoreState, [PermissionsStateOptions], StateSource<DocumentPermissionsResult>>;
1430
- /** @beta */
1431
- declare const resolvePermissions: BoundStoreAction<DocumentStoreState, [options: PermissionsStateOptions], Promise<DocumentPermissionsResult>>;
1432
- /** @beta */
1433
- declare const subscribeDocumentEvents: BoundStoreAction<DocumentStoreState, [options: {
1434
- resource?: DocumentResource;
1435
- eventHandler: (e: DocumentEvent) => void;
1436
- }], () => void>;
1437
- type ActionMap = {
1438
- create: 'sanity.action.document.version.create';
1439
- discard: 'sanity.action.document.version.discard';
1440
- unpublish: 'sanity.action.document.unpublish';
1441
- delete: 'sanity.action.document.delete';
1442
- edit: 'sanity.action.document.edit';
1443
- publish: 'sanity.action.document.publish';
1444
- releaseCreate: 'sanity.action.release.create';
1445
- releaseEdit: 'sanity.action.release.edit';
1446
- releasePublish: 'sanity.action.release.publish';
1447
- releaseSchedule: 'sanity.action.release.schedule';
1448
- releaseUnschedule: 'sanity.action.release.unschedule';
1449
- releaseArchive: 'sanity.action.release.archive';
1450
- releaseUnarchive: 'sanity.action.release.unarchive';
1451
- releaseDelete: 'sanity.action.release.delete';
1452
- };
1453
- type OptimisticLock = {
1454
- ifDraftRevisionId?: string;
1455
- ifPublishedRevisionId?: string;
1456
- };
1457
- interface ReleaseMetadataPayload {
1458
- title?: string;
1459
- description?: string;
1460
- intendedPublishAt?: string;
1461
- releaseType?: 'asap' | 'scheduled' | 'undecided';
1462
- cardinality?: 'one' | 'many';
1463
- }
1464
- type HttpAction = {
1465
- actionType: ActionMap['create'];
1466
- publishedId: string;
1467
- attributes: SanityDocumentLike;
1468
- } | {
1469
- actionType: ActionMap['discard'];
1470
- versionId: string;
1471
- purge?: boolean;
1472
- } | {
1473
- actionType: ActionMap['unpublish'];
1474
- draftId: string;
1475
- publishedId: string;
1476
- } | {
1477
- actionType: ActionMap['delete'];
1478
- publishedId: string;
1479
- includeDrafts?: string[];
1480
- } | {
1481
- actionType: ActionMap['edit'];
1482
- draftId: string;
1483
- publishedId: string;
1484
- patch: PatchOperations;
1485
- } | ({
1486
- actionType: ActionMap['publish'];
1487
- draftId: string;
1488
- publishedId: string;
1489
- } & OptimisticLock) | {
1490
- actionType: ActionMap['releaseCreate'];
1491
- releaseId: string;
1492
- metadata?: ReleaseMetadataPayload;
1493
- } | {
1494
- actionType: ActionMap['releaseEdit'];
1495
- releaseId: string;
1496
- patch: PatchOperations;
1497
- } | {
1498
- actionType: ActionMap['releasePublish'];
1499
- releaseId: string;
1500
- } | {
1501
- actionType: ActionMap['releaseSchedule'];
1502
- releaseId: string;
1503
- publishAt: string;
1504
- } | {
1505
- actionType: ActionMap['releaseUnschedule'];
1506
- releaseId: string;
1507
- } | {
1508
- actionType: ActionMap['releaseArchive'];
1509
- releaseId: string;
1510
- } | {
1511
- actionType: ActionMap['releaseUnarchive'];
1512
- releaseId: string;
1513
- } | {
1514
- actionType: ActionMap['releaseDelete'];
1515
- releaseId: string;
1516
- };
1517
- /**
1518
- * Represents a transaction that is queued to be applied but has not yet been
1519
- * applied. A transaction will remain in a queued state until all required
1520
- * documents for the transactions are available locally.
1521
- */
1522
- interface QueuedTransaction {
1523
- /**
1524
- * the ID of this transaction. this is generated client-side.
1525
- */
1526
- transactionId: string;
1527
- /**
1528
- * the high-level actions associated with this transaction. note that these
1529
- * actions don't mention draft IDs and is meant to abstract away the draft
1530
- * model from users.
1531
- */
1532
- actions: Action[];
1533
- /**
1534
- * An optional flag set to disable this transaction from being batched with
1535
- * other transactions.
1536
- */
1537
- disableBatching?: boolean;
1538
- }
1539
- /**
1540
- * Represents a transaction that has been applied locally but has not been
1541
- * committed/transitioned-to-outgoing. These transactions are visible to the
1542
- * user but may be rebased upon a new working document set. Applied transactions
1543
- * also contain the resulting `outgoingActions` that will be submitted to
1544
- * Content Lake. These `outgoingActions` depend on the state of the working
1545
- * documents so they are recomputed on rebase and are only relevant to applied
1546
- * actions (we cannot compute `outgoingActions` for queued transactions because
1547
- * we haven't resolved the set of documents the actions are dependent on yet).
1548
- *
1549
- * In order to support better conflict resolution, the original `previous` set
1550
- * is saved as the `base` set.
1551
- */
1552
- interface AppliedTransaction extends QueuedTransaction {
1553
- /**
1554
- * the resulting set of documents after the actions have been applied
1555
- */
1556
- working: DocumentSet;
1557
- /**
1558
- * the previous set of documents before the action was applied
1559
- */
1560
- previous: DocumentSet;
1561
- /**
1562
- * the original `previous` document set captured when this action was
1563
- * originally applied. this is used as a reference point to do a 3-way merge
1564
- * if this applied transaction ever needs to be reapplied on a different
1565
- * set of documents.
1566
- */
1567
- base: DocumentSet;
1568
- /**
1569
- * the `_rev`s from `previous` document set
1570
- */
1571
- previousRevs: { [TDocumentId in string]?: string };
1572
- /**
1573
- * a timestamp for when this transaction was applied locally
1574
- */
1575
- timestamp: string;
1576
- /**
1577
- * the resulting HTTP actions derived from the state of the `working` document
1578
- * set. these are sent to Content Lake as-is when this transaction is batched
1579
- * and transitioned into an outgoing transaction.
1580
- */
1581
- outgoingActions: HttpAction[];
1582
- /**
1583
- * similar to `outgoingActions` but comprised of mutations instead of actions.
1584
- * Useful for debugging, and is also used by liveEdit documents to send mutations,
1585
- * since they can't use the Actions API which is pretty dependent on the draft model.
1586
- */
1587
- outgoingMutations: Mutation[];
1588
- }
1589
- /**
1590
- * Represents a set of applied transactions batched into a single outgoing
1591
- * transaction. An outgoing transaction is the result of batching many applied
1592
- * actions. An outgoing transaction may be reverted locally if the server
1593
- * does not accept it.
1594
- */
1595
- interface OutgoingTransaction extends AppliedTransaction {
1596
- disableBatching: boolean;
1597
- batchedTransactionIds: string[];
1598
- }
1599
- interface UnverifiedDocumentRevision {
1600
- transactionId: string;
1601
- documentId: string;
1602
- previousRev: string | undefined;
1603
- timestamp: string;
1604
- }
1605
- /** @beta Response body from submitting an outgoing transaction (actions or mutations API). */
1606
- type DocumentTransactionSubmissionResult = Awaited<ReturnType<SanityClient['action']>> | MultipleMutationResult;
1607
- /** @beta */
1608
- type DocumentEvent = ActionErrorEvent | TransactionRevertedEvent | TransactionAcceptedEvent | DocumentRebaseErrorEvent | DocumentEditedEvent | DocumentCreatedEvent | DocumentDeletedEvent | DocumentPublishedEvent | DocumentUnpublishedEvent | DocumentDiscardedEvent;
1609
- /**
1610
- * @beta
1611
- * Event emitted when a precondition to applying an action fails.
1612
- * (For example: when trying to edit a document that no longer exists.)
1613
- */
1614
- interface ActionErrorEvent {
1615
- type: 'error';
1616
- documentId: string;
1617
- transactionId: string;
1618
- message: string;
1619
- error: unknown;
1620
- }
1621
- /**
1622
- * @beta
1623
- * Event emitted when a transaction is accepted.
1624
- */
1625
- interface TransactionAcceptedEvent {
1626
- type: 'accepted';
1627
- outgoing: OutgoingTransaction;
1628
- result: DocumentTransactionSubmissionResult;
1629
- }
1630
- /**
1631
- * @beta
1632
- * Event emitted when a transaction is reverted.
1633
- */
1634
- interface TransactionRevertedEvent {
1635
- type: 'reverted';
1636
- message: string;
1637
- error: unknown;
1638
- outgoing: OutgoingTransaction;
1639
- }
1640
- /**
1641
- * @beta
1642
- * Event emitted when an attempt to apply local changes to a modified remote document fails.
1643
- */
1644
- interface DocumentRebaseErrorEvent {
1645
- type: 'rebase-error';
1646
- documentId: string;
1647
- transactionId: string;
1648
- message: string;
1649
- error: unknown;
1650
- }
1651
- /**
1652
- * @beta
1653
- * Event emitted when a document is edited.
1654
- */
1655
- interface DocumentEditedEvent {
1656
- type: 'edited';
1657
- documentId: string;
1658
- outgoing: OutgoingTransaction;
1659
- }
1660
- /**
1661
- * @beta
1662
- * Event emitted when a document is created.
1663
- */
1664
- interface DocumentCreatedEvent {
1665
- type: 'created';
1666
- documentId: string;
1667
- outgoing: OutgoingTransaction;
1668
- }
1669
- /**
1670
- * @beta
1671
- * Event emitted when a document is deleted.
1672
- */
1673
- interface DocumentDeletedEvent {
1674
- type: 'deleted';
1675
- documentId: string;
1676
- outgoing: OutgoingTransaction;
1677
- }
1678
- /**
1679
- * @beta
1680
- * Event emitted when a document is published.
1681
- */
1682
- interface DocumentPublishedEvent {
1683
- type: 'published';
1684
- documentId: string;
1685
- outgoing: OutgoingTransaction;
1686
- }
1687
- /**
1688
- * @beta
1689
- * Event emitted when a document is unpublished.
1690
- */
1691
- interface DocumentUnpublishedEvent {
1692
- type: 'unpublished';
1693
- documentId: string;
1694
- outgoing: OutgoingTransaction;
1695
- }
1696
- /**
1697
- * @beta
1698
- * Event emitted when a document version is discarded.
1699
- */
1700
- interface DocumentDiscardedEvent {
1701
- type: 'discarded';
1702
- documentId: string;
1703
- outgoing: OutgoingTransaction;
1704
- }
1705
- /** @beta */
1706
- interface ActionsResult<TDocument extends SanityDocument$2 = SanityDocument$2> {
1707
- transactionId: string;
1708
- documents: DocumentSet<TDocument>;
1709
- previous: DocumentSet<TDocument>;
1710
- previousRevs: {
1711
- [documentId: string]: string | undefined;
1712
- };
1713
- appeared: string[];
1714
- updated: string[];
1715
- disappeared: string[];
1716
- submitted: () => Promise<DocumentTransactionSubmissionResult>;
1717
- }
1718
- /** @beta */
1719
- interface ApplyDocumentActionsOptions {
1720
- /**
1721
- * List of actions to apply. Accepts both document actions and release
1722
- * lifecycle actions because they share the same transaction pipeline.
1723
- */
1724
- actions: Action[];
1725
- /**
1726
- * The resource to which the documents being acted on belong.
1727
- */
1728
- resource?: DocumentResource;
1729
- /**
1730
- * Optionally provide an ID to be used as this transaction ID
1731
- */
1732
- transactionId?: string;
1733
- /**
1734
- * Set this to true to prevent this action from being batched with others.
1735
- */
1736
- disableBatching?: boolean;
1737
- }
1738
- /** @beta */
1739
- declare function applyDocumentActions<TDocumentType extends string = string, TDataset extends string = string, TProjectId extends string = string>(instance: SanityInstance, options: ApplyDocumentActionsOptions): Promise<ActionsResult<SanityDocument$2<TDocumentType, `${TProjectId}.${TDataset}`>>>;
1740
- /** @beta */
1741
- declare function applyDocumentActions(instance: SanityInstance, options: ApplyDocumentActionsOptions): Promise<ActionsResult>;
1742
- /**
1743
- * Returns the full release document ID for the given release name.
1744
- * e.g. `getReleaseDocumentId('my-release') === '_.releases.my-release'`
1745
- * @beta
1746
- */
1747
- declare function getReleaseDocumentId(releaseId: string): string;
1748
- /**
1749
- * @public
1750
- */
1751
- interface FavoriteStatusResponse {
1752
- isFavorited: boolean;
1753
- }
1754
- /**
1755
- * @public
1756
- */
1757
- interface FavoriteDocumentContext extends DocumentHandle {
1758
- resourceId: string;
1759
- resourceType: StudioResource['type'] | MediaResource['type'] | CanvasResource['type'];
1760
- schemaName?: string;
1761
- }
1762
- /**
1763
- * Gets a StateSource for the favorite status of a document.
1764
- * @param instance - The Sanity instance.
1765
- * @param context - The document context including ID, type, and resource information.
1766
- * @returns A StateSource emitting `{ isFavorited: boolean }`.
1767
- * @public
1768
- */
1769
- declare const getFavoritesState: BoundStoreAction<FetcherStoreState<[FavoriteDocumentContext], FavoriteStatusResponse>, [FavoriteDocumentContext], StateSource<FavoriteStatusResponse | undefined>>;
1770
- /**
1771
- * Resolves the favorite status for a document.
1772
- * @param instance - The Sanity instance.
1773
- * @param context - The document context including ID, type, and resource information.
1774
- * @returns A Promise resolving to `{ isFavorited: boolean }`.
1775
- * @public
1776
- */
1777
- declare const resolveFavoritesState: BoundStoreAction<FetcherStoreState<[FavoriteDocumentContext], FavoriteStatusResponse>, [FavoriteDocumentContext], Promise<FavoriteStatusResponse>>;
1778
- /** @public */
1779
- interface OrganizationMember {
1780
- sanityUserId: string;
1781
- isCurrentUser: boolean;
1782
- user: {
1783
- id: string;
1784
- displayName: string;
1785
- familyName: string;
1786
- givenName: string;
1787
- middleName: string | null;
1788
- imageUrl: string | null;
1789
- email: string;
1790
- loginProvider: string;
1791
- };
1792
- roles: Array<{
1793
- name: string;
1794
- title: string;
1795
- description?: string;
1796
- }>;
1797
- }
1798
- /**
1799
- * The base fields returned from `/organizations/<id>` for every organization.
1800
- * @public
1801
- */
1802
- interface OrganizationBase {
1803
- id: string;
1804
- name: string;
1805
- slug: string | null;
1806
- createdAt: string;
1807
- createdByUserId: string;
1808
- updatedAt: string;
1809
- deletedAt: string | null;
1810
- dashboardStatus: 'enabled' | 'disabled';
1811
- aiFeaturesStatus: 'enabled' | 'disabled';
1812
- mediaLibraryStatus: 'enabled' | 'disabled';
1813
- requestAccessStatus: 'allowed' | 'disabled';
1814
- telemetryConsentStatus: 'allowed' | 'msa_denied' | 'customer_denied';
1815
- oauthAppsStatus: 'allowed' | 'blocked';
1816
- defaultRoleName: string;
1817
- domains: string[] | null;
1818
- }
1819
- /** @public */
1820
- interface OrganizationOptions<IncludeMembers extends boolean = false, IncludeFeatures extends boolean = false> {
1821
- includeMembers?: IncludeMembers;
1822
- includeFeatures?: IncludeFeatures;
1823
- organizationId: string;
1824
- }
1825
- /**
1826
- * An `Organization` with `members` and/or `features` conditionally included
1827
- * based on the query options used to fetch it.
1828
- * @public
1829
- */
1830
- type Organization<IncludeMembers extends boolean = false, IncludeFeatures extends boolean = false> = OrganizationBase & (boolean extends IncludeMembers ? {
1831
- members?: OrganizationMember[];
1832
- } : IncludeMembers extends true ? {
1833
- members: OrganizationMember[];
1834
- } : unknown) & (boolean extends IncludeFeatures ? {
1835
- features?: string[];
1836
- } : IncludeFeatures extends true ? {
1837
- features: string[];
1838
- } : unknown);
1839
- /**
1840
- * Public signature for the organization state source. The conditional generics
1841
- * cannot flow through `BoundStoreAction`, so we declare the signature here
1842
- * and assign the (already-correct) runtime function to it.
1843
- */
1844
- type GetOrganizationState = <IncludeMembers extends boolean = false, IncludeFeatures extends boolean = false>(instance: SanityInstance, options: OrganizationOptions<IncludeMembers, IncludeFeatures>) => StateSource<Organization<IncludeMembers, IncludeFeatures> | undefined>;
1845
- type ResolveOrganization = <IncludeMembers extends boolean = false, IncludeFeatures extends boolean = false>(instance: SanityInstance, options: OrganizationOptions<IncludeMembers, IncludeFeatures>) => Promise<Organization<IncludeMembers, IncludeFeatures>>;
1846
- /** @public */
1847
- declare const getOrganizationState: GetOrganizationState;
1848
- /** @public */
1849
- declare const resolveOrganization: ResolveOrganization;
1850
- /**
1851
- * The list shape returned from `/organizations`, with `members` and/or
1852
- * `features` conditionally included based on the query options used.
1853
- * @public
1854
- */
1855
- type Organizations<IncludeMembers extends boolean = false, IncludeFeatures extends boolean = false> = (Pick<OrganizationBase, 'id' | 'name' | 'slug' | 'createdAt' | 'updatedAt' | 'defaultRoleName' | 'dashboardStatus' | 'aiFeaturesStatus'> & (boolean extends IncludeMembers ? {
1856
- members?: OrganizationMember[];
1857
- } : IncludeMembers extends true ? {
1858
- members: OrganizationMember[];
1859
- } : unknown) & (boolean extends IncludeFeatures ? {
1860
- features?: string[];
1861
- } : IncludeFeatures extends true ? {
1862
- features: string[];
1863
- } : unknown))[];
1864
- /** @public */
1865
- interface OrganizationsOptions<IncludeMembers extends boolean = false, IncludeFeatures extends boolean = false> extends Omit<OrganizationOptions<IncludeMembers, IncludeFeatures>, 'organizationId'> {
1866
- /**
1867
- * When `true`, includes organisations the user has access to via
1868
- * project-level grants, not just direct organisation memberships.
1869
- */
1870
- includeImplicitMemberships?: boolean;
1871
- }
1872
- /**
1873
- * Public signature for the organization state source. The conditional generics
1874
- * cannot flow through `BoundStoreAction`, so we declare the signature here
1875
- * and assign the (already-correct) runtime function to it.
1876
- */
1877
- type GetOrganizationsState = <IncludeMembers extends boolean = false, IncludeFeatures extends boolean = false>(instance: SanityInstance, options?: OrganizationsOptions<IncludeMembers, IncludeFeatures>) => StateSource<Organizations<IncludeMembers, IncludeFeatures> | undefined>;
1878
- type ResolveOrganizations = <IncludeMembers extends boolean = false, IncludeFeatures extends boolean = false>(instance: SanityInstance, options?: OrganizationsOptions<IncludeMembers, IncludeFeatures>) => Promise<Organizations<IncludeMembers, IncludeFeatures>>;
1879
- /** @public */
1880
- declare const getOrganizationsState: GetOrganizationsState;
1881
- /** @public */
1882
- declare const resolveOrganizations: ResolveOrganizations;
1883
- /**
1884
- * @public
1885
- */
1886
- interface SanityUser {
1887
- sanityUserId: string;
1888
- profile: UserProfile;
1889
- memberships: Membership[];
1890
- }
1891
- /**
1892
- * @public
1893
- */
1894
- interface Membership {
1895
- addedAt?: string;
1896
- resourceType: string;
1897
- resourceId: string;
1898
- roleNames: Array<string>;
1899
- lastSeenAt?: string | null;
1900
- }
1901
- /**
1902
- * @public
1903
- */
1904
- interface UserProfile {
1905
- id: string;
1906
- displayName: string;
1907
- email: string;
1908
- familyName?: string;
1909
- givenName?: string;
1910
- middleName?: string | null;
1911
- imageUrl?: string;
1912
- provider: string;
1913
- tosAcceptedAt?: string;
1914
- createdAt: string;
1915
- updatedAt?: string;
1916
- isCurrentUser?: boolean;
1917
- providerId?: string;
1918
- }
1919
- /**
1920
- * @public
1921
- */
1922
- interface GetUsersOptions extends ProjectHandle {
1923
- resourceType?: 'organization' | 'project';
1924
- batchSize?: number;
1925
- organizationId?: string;
1926
- userId?: string;
1927
- }
1928
- /**
1929
- * @public
1930
- */
1931
- interface UsersGroupState {
1932
- subscriptions: string[];
1933
- totalCount?: number;
1934
- nextCursor?: string | null;
1935
- lastLoadMoreRequest?: string;
1936
- users?: SanityUser[];
1937
- error?: unknown;
1938
- }
1939
- /**
1940
- * @public
1941
- */
1942
- interface SanityUserResponse {
1943
- data: SanityUser[];
1944
- totalCount: number;
1945
- nextCursor: string | null;
1946
- }
1947
- /**
1948
- * @public
1949
- */
1950
- interface UsersStoreState {
1951
- users: { [TUsersKey in string]?: UsersGroupState };
1952
- error?: unknown;
1953
- }
1954
- /**
1955
- * @public
1956
- */
1957
- interface ResolveUsersOptions extends GetUsersOptions {
1958
- signal?: AbortSignal;
1959
- }
1960
- /**
1961
- * @public
1962
- */
1963
- interface GetUserOptions extends ProjectHandle {
1964
- userId: string;
1965
- resourceType?: 'organization' | 'project';
1966
- organizationId?: string;
1967
- }
1968
- /**
1969
- * @public
1970
- */
1971
- interface ResolveUserOptions extends GetUserOptions {
1972
- signal?: AbortSignal;
1973
- }
1974
- /** @public */
1975
- interface PresenceLocation {
1976
- type: 'document';
1977
- documentId: string;
1978
- path: string[];
1979
- lastActiveAt: string;
1980
- }
1981
- /** @public */
1982
- interface UserPresence {
1983
- user: SanityUser;
1984
- locations: PresenceLocation[];
1985
- sessionId: string;
1986
- }
1987
- /** @public */
1988
- type TransportEvent = RollCallEvent | StateEvent | DisconnectEvent;
1989
- /** @public */
1990
- interface RollCallEvent {
1991
- type: 'rollCall';
1992
- userId: string;
1993
- sessionId: string;
1994
- }
1995
- /** @public */
1996
- interface StateEvent {
1997
- type: 'state';
1998
- userId: string;
1999
- sessionId: string;
2000
- timestamp: string;
2001
- locations: PresenceLocation[];
2002
- }
2003
- /** @public */
2004
- interface DisconnectEvent {
2005
- type: 'disconnect';
2006
- userId: string;
2007
- sessionId: string;
2008
- timestamp: string;
2009
- }
2010
- /** @beta */
2011
- declare function getPresence(instance: SanityInstance, params?: {
2012
- resource?: DocumentResource;
2013
- }): StateSource<UserPresence[]>;
2014
- /**
2015
- * @public
2016
- * The result of a projection query
2017
- */
2018
- interface ProjectionValuePending<TValue extends object> {
2019
- data: TValue | null;
2020
- isPending: boolean;
2021
- }
2022
- /**
2023
- * @public
2024
- * @deprecated
2025
- * Template literals are a bit too limited, so this type is deprecated.
2026
- * Use `string` instead. Projection strings are validated at runtime.
2027
- */
2028
- type ValidProjection = string;
2029
- interface DocumentStatus {
2030
- lastEditedDraftAt?: string;
2031
- lastEditedPublishedAt?: string;
2032
- lastEditedVersionAt?: string;
2033
- }
2034
- /**
2035
- *
2036
- * @internal
2037
- */
2038
- interface PreviewQueryResult {
2039
- _id: string;
2040
- _type: string;
2041
- _updatedAt: string;
2042
- titleCandidates: Record<string, unknown>;
2043
- subtitleCandidates: Record<string, unknown>;
2044
- media?: PreviewMedia | null;
2045
- _status?: DocumentStatus;
2046
- }
2047
- /**
2048
- * Represents a media asset in a preview.
2049
- *
2050
- * @public
2051
- */
2052
- interface PreviewMedia {
2053
- type: 'image-asset';
2054
- _ref: string;
2055
- url: string;
2056
- }
2057
- /**
2058
- * Represents the set of values displayed as a preview for a given Sanity document.
2059
- * This includes a primary title, a secondary subtitle, an optional piece of media associated
2060
- * with the document, and the document's status.
2061
- *
2062
- * @public
2063
- */
2064
- interface PreviewValue {
2065
- /**
2066
- * The primary text displayed for the document preview.
2067
- */
2068
- title: string;
2069
- /**
2070
- * A secondary line of text providing additional context about the document.
2071
- */
2072
- subtitle?: string;
2073
- /**
2074
- * An optional piece of media representing the document within its preview.
2075
- * Currently, only image assets are available.
2076
- */
2077
- media?: PreviewMedia | null;
2078
- /**
2079
- * The status of the document.
2080
- */
2081
- _status?: {
2082
- /** The date of the last published edit */
2083
- lastEditedPublishedAt?: string;
2084
- /** The date of the last draft edit */
2085
- lastEditedDraftAt?: string;
2086
- };
2087
- }
2088
- /**
2089
- * Represents the current state of a preview value along with a flag indicating whether
2090
- * the preview data is still being fetched or is fully resolved.
2091
- *
2092
- * The tuple contains a preview value or null, and a boolean indicating if the data is
2093
- * pending. A `true` value means a fetch is ongoing; `false` indicates that the
2094
- * currently provided preview value is up-to-date.
2095
- *
2096
- * @public
2097
- */
2098
- type ValuePending<T> = {
2099
- data: T | null;
2100
- isPending: boolean;
2101
- };
2102
- /**
2103
- * @public
2104
- * @deprecated This interface is kept for backwards compatibility but is no longer used internally.
2105
- * Preview state is now stored in the projection store.
2106
- */
2107
- interface PreviewStoreState {
2108
- values: { [TDocumentId in string]?: ValuePending<PreviewValue> };
2109
- subscriptions: { [TDocumentId in string]?: { [TSubscriptionId in string]?: true } };
2110
- }
2111
- /**
2112
- * @beta
2113
- * @deprecated This type is deprecated and will be removed in a future release.
2114
- */
2115
- type GetPreviewStateOptions = DocumentHandle;
2116
- /**
2117
- * @beta
2118
- * @deprecated This function is deprecated and will be removed in a future release.
2119
- */
2120
- declare function getPreviewState<TResult extends object>(instance: SanityInstance, options: GetPreviewStateOptions): StateSource<ValuePending<TResult>>;
2121
- /**
2122
- * @beta
2123
- * @deprecated This function is deprecated and will be removed in a future release.
2124
- */
2125
- declare function getPreviewState(instance: SanityInstance, options: GetPreviewStateOptions): StateSource<ValuePending<PreviewValue>>;
2126
- /**
2127
- * Generates a GROQ projection for preview data without requiring a schema.
2128
- * Uses common field names to make educated guesses about which fields to use.
2129
- *
2130
- * @internal
2131
- */
2132
- declare const PREVIEW_PROJECTION: string;
2133
- /**
2134
- * Transforms a projection result (with titleCandidates, subtitleCandidates, media)
2135
- * into a PreviewValue (with title, subtitle, media).
2136
- *
2137
- * @param projectionResult - The raw projection result from GROQ
2138
- * @param instance - The Sanity instance to use for client configuration
2139
- * @param resource - Data resource for the preview
2140
- * @internal
2141
- */
2142
- declare function transformProjectionToPreview(instance: SanityInstance, projectionResult: PreviewQueryResult, resource?: DocumentResource): PreviewValue;
2143
- /**
2144
- * @beta
2145
- * @deprecated This type is deprecated and will be removed in a future release.
2146
- */
2147
- type ResolvePreviewOptions = DocumentHandle;
2148
- /**
2149
- * @beta
2150
- * @deprecated This function is deprecated and will be removed in a future release.
2151
- */
2152
- declare function resolvePreview(instance: SanityInstance, options: ResolvePreviewOptions): Promise<ValuePending<PreviewValue>>;
2153
- /** @public */
2154
- interface ProjectMemberRole {
2155
- name: string;
2156
- title: string;
2157
- description: string;
2158
- }
2159
- /** @public */
2160
- interface ProjectMember {
2161
- id: string;
2162
- createdAt: string;
2163
- updatedAt: string;
2164
- isCurrentUser: boolean;
2165
- isRobot: boolean;
2166
- roles: ProjectMemberRole[];
2167
- }
2168
- /** @public */
2169
- interface ProjectMetadata {
2170
- color?: string;
2171
- externalStudioHost?: string;
2172
- initialTemplate?: string;
2173
- cliInitializedAt?: string;
2174
- integration: 'manage' | 'cli';
2175
- }
2176
- /**
2177
- * The base fields returned from `/projects` for every project.
2178
- * @public
2179
- */
2180
- interface ProjectBase {
2181
- id: string;
2182
- displayName: string;
2183
- studioHost: string | null;
2184
- organizationId: string;
2185
- metadata: ProjectMetadata;
2186
- isBlocked: boolean;
2187
- isDisabled: boolean;
2188
- isDisabledByUser: boolean;
2189
- activityFeedEnabled: boolean;
2190
- createdAt: string;
2191
- updatedAt: string;
2192
- }
2193
- /**
2194
- * A `Project` with `members` and/or `features` conditionally included
2195
- * based on the query options used to fetch it.
2196
- * @public
2197
- */
2198
- type Project<IncludeMembers extends boolean = true, IncludeFeatures extends boolean = true> = ProjectBase & (boolean extends IncludeMembers ? {
2199
- members?: ProjectMember[];
2200
- } : IncludeMembers extends true ? {
2201
- members: ProjectMember[];
2202
- } : unknown) & (boolean extends IncludeFeatures ? {
2203
- features?: string[];
2204
- } : IncludeFeatures extends true ? {
2205
- features: string[];
2206
- } : unknown);
2207
- /** @public */
2208
- interface ProjectOptions<IncludeMembers extends boolean = true, IncludeFeatures extends boolean = true> extends ProjectHandle {
2209
- includeMembers?: IncludeMembers;
2210
- includeFeatures?: IncludeFeatures;
2211
- }
2212
- /**
2213
- * Public signature for the project state source. The conditional generics
2214
- * cannot flow through `BoundStoreAction`, so we declare the signature here
2215
- * and assign the (already-correct) runtime function to it.
2216
- */
2217
- type GetProjectState = <IncludeMembers extends boolean = true, IncludeFeatures extends boolean = true>(instance: SanityInstance, options?: ProjectOptions<IncludeMembers, IncludeFeatures>) => StateSource<Project<IncludeMembers, IncludeFeatures> | undefined>;
2218
- type ResolveProject = <IncludeMembers extends boolean = true, IncludeFeatures extends boolean = true>(instance: SanityInstance, options?: ProjectOptions<IncludeMembers, IncludeFeatures>) => Promise<Project<IncludeMembers, IncludeFeatures>>;
2219
- /** @public */
2220
- declare const getProjectState: GetProjectState;
2221
- /** @public */
2222
- declare const resolveProject: ResolveProject;
2223
- interface ProjectionOptions<TProjection extends string = string, TDocumentType extends string = string, TDataset extends string = string, TProjectId extends string = string> extends DocumentHandle<TDocumentType, TDataset, TProjectId> {
2224
- projection: TProjection;
2225
- }
2226
- /**
2227
- * @beta
2228
- */
2229
- 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>;
2230
- /**
2231
- * @beta
2232
- */
2233
- declare function getProjectionState<TData extends object>(instance: SanityInstance, options: ProjectionOptions): StateSource<ProjectionValuePending<TData> | undefined>;
2234
- /**
2235
- * @beta
2236
- */
2237
- declare function getProjectionState(instance: SanityInstance, options: ProjectionOptions): StateSource<ProjectionValuePending<Record<string, unknown>> | undefined>;
2238
- /** @beta */
2239
- 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}`>>>;
2240
- /** @beta */
2241
- declare function resolveProjection<TData extends object>(instance: SanityInstance, options: ProjectionOptions): Promise<ProjectionValuePending<TData>>;
2242
- /** @public */
2243
- interface ProjectsOptions<IncludeMembers extends boolean = false, IncludeFeatures extends boolean = true> {
2244
- organizationId?: string;
2245
- includeMembers?: IncludeMembers;
2246
- includeFeatures?: IncludeFeatures;
2247
- onlyExplicitMembership?: boolean;
2248
- }
2249
- /**
2250
- * Public signature for the projects state source. The conditional generics
2251
- * cannot flow through `BoundStoreAction`, so we declare the signature here
2252
- * and assign the (already-correct) runtime function to it.
2253
- */
2254
- type GetProjectsState = <IncludeMembers extends boolean = false, IncludeFeatures extends boolean = true>(instance: SanityInstance, options?: ProjectsOptions<IncludeMembers, IncludeFeatures>) => StateSource<Project<IncludeMembers, IncludeFeatures>[] | undefined>;
2255
- type ResolveProjects = <IncludeMembers extends boolean = false, IncludeFeatures extends boolean = true>(instance: SanityInstance, options?: ProjectsOptions<IncludeMembers, IncludeFeatures>) => Promise<Project<IncludeMembers, IncludeFeatures>[]>;
2256
- /** @public */
2257
- declare const getProjectsState: GetProjectsState;
2258
- /** @public */
2259
- declare const resolveProjects: ResolveProjects;
2260
- /**
2261
- * @beta
2262
- */
2263
- 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> {
2264
- query: TQuery;
2265
- params?: Record<string, unknown>;
2266
- }
2267
- /**
2268
- * @beta
2269
- */
2270
- interface ResolveQueryOptions<TQuery extends string = string, TDataset extends string = string, TProjectId extends string = string> extends QueryOptions<TQuery, TDataset, TProjectId> {
2271
- signal?: AbortSignal;
2272
- }
2273
- /** @beta */
2274
- declare const getQueryKey: (options: QueryOptions) => string;
2275
- /** @beta */
2276
- declare const parseQueryKey: (key: string) => QueryOptions;
2277
- /**
2278
- * Returns the state source for a query.
2279
- *
2280
- * This function returns a state source that represents the current result of a GROQ query.
2281
- * Subscribing to the state source will instruct the SDK to fetch the query (if not already fetched)
2282
- * and will keep the query live using the Live content API (considering sync tags) to provide up-to-date results.
2283
- * When the last subscriber is removed, the query state is automatically cleaned up from the store.
2284
- *
2285
- * Note: This functionality is for advanced users who want to build their own framework integrations.
2286
- * Our SDK also provides a React integration (useQuery hook) for convenient usage.
2287
- *
2288
- * Note: Automatic cleanup can interfere with React Suspense because if a component suspends while being the only subscriber,
2289
- * cleanup might occur unexpectedly. In such cases, consider using `resolveQuery` instead.
2290
- *
2291
- * @beta
2292
- */
2293
- 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>;
2294
- /** @beta */
2295
- declare function getQueryState<TData>(instance: SanityInstance, queryOptions: QueryOptions): StateSource<TData | undefined>;
2296
- /** @beta */
2297
- declare function getQueryState(instance: SanityInstance, queryOptions: QueryOptions): StateSource<unknown>;
2298
- /**
2299
- * Resolves the result of a query without registering a lasting subscriber.
2300
- *
2301
- * This function fetches the result of a GROQ query and returns a promise that resolves with the query result.
2302
- * Unlike `getQueryState`, which registers subscribers to keep the query live and performs automatic cleanup,
2303
- * `resolveQuery` does not track subscribers. This makes it ideal for use with React Suspense, where the returned
2304
- * promise is thrown to delay rendering until the query result becomes available.
2305
- * Once the promise resolves, it is expected that a real subscriber will be added via `getQueryState` to manage ongoing updates.
2306
- *
2307
- * Additionally, an optional AbortSignal can be provided to cancel the query and immediately clear the associated state
2308
- * if there are no active subscribers.
2309
- *
2310
- * @beta
2311
- */
2312
- 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}`>>;
2313
- /** @beta */
2314
- declare function resolveQuery<TData>(instance: SanityInstance, queryOptions: ResolveQueryOptions): Promise<TData>;
2315
- /**
2316
- * Lifecycle states a release document can be in. Mirrors the server's
2317
- * `ReleaseState`.
2318
- * @beta
2319
- */
2320
- type ReleaseState = 'active' | 'archiving' | 'unarchiving' | 'archived' | 'published' | 'publishing' | 'scheduled' | 'scheduling';
2321
- interface ReleasesStoreState {
2322
- activeReleases?: ReleaseDocument[];
2323
- allReleases?: ReleaseDocument[];
2324
- error?: unknown;
2325
- }
2326
- /**
2327
- * Get the active releases from the store.
2328
- * @internal
2329
- */
2330
- declare const getActiveReleasesState: (instance: SanityInstance, options?: {
2331
- resource?: DocumentResource;
2332
- }) => StateSource<ReleaseDocument[] | undefined>;
2333
- /**
2334
- * Get every release in the store, including archived and published.
2335
- * @internal
2336
- */
2337
- declare const getAllReleasesState: (instance: SanityInstance, options?: {
2338
- resource?: DocumentResource;
2339
- }) => StateSource<ReleaseDocument[] | undefined>;
2340
- declare const _getPerspectiveStateSelector: StoreAction<ReleasesStoreState, [_?: (PerspectiveHandle & {
2341
- projectId?: string;
2342
- dataset?: string;
2343
- resource?: DocumentResource;
2344
- }) | undefined], StateSource<string[] | "previewDrafts" | "published" | "drafts" | "raw" | undefined>, unknown>;
2345
- type OmitFirst<T extends unknown[]> = T extends [unknown, ...infer R] ? R : never;
2346
- type SelectorParams = OmitFirst<Parameters<typeof _getPerspectiveStateSelector>>;
2347
- type BoundGetPerspectiveState = BoundStoreAction<ReleasesStoreState, SelectorParams, ReturnType<typeof _getPerspectiveStateSelector>>;
2348
- /**
2349
- * Provides a subscribable state source for a "perspective" for the Sanity client,
2350
- * which is used to fetch documents as though certain Content Releases are active.
2351
- *
2352
- * @param instance - The Sanity instance to get the perspective for
2353
- * @param options - The options for the perspective -- usually a release name
2354
- *
2355
- * @returns A subscribable perspective value, usually a list of applicable release names,
2356
- * or a single release name / default perspective (such as 'drafts').
2357
- *
2358
- * @public
2359
- */
2360
- declare const getPerspectiveState: BoundGetPerspectiveState;
2361
- /** @internal */
2362
- declare const getUsersKey: (instance: SanityInstance, {
2363
- resourceType,
2364
- organizationId,
2365
- batchSize,
2366
- projectId,
2367
- userId
2368
- }?: GetUsersOptions) => string;
2369
- /** @internal */
2370
- declare const parseUsersKey: (key: string) => {
2371
- batchSize: number;
2372
- resourceType?: "organization" | "project";
2373
- projectId?: string;
2374
- organizationId?: string;
2375
- userId?: string;
2376
- };
2377
- /**
2378
- * Returns the state source for users associated with a specific resource.
2379
- *
2380
- * This function returns a state source that represents the current list of users for a given
2381
- * resource. Subscribing to the state source will instruct the SDK to fetch the users (if not
2382
- * already fetched) and will load more from this state source as well. When the last subscriber is
2383
- * removed, the users state is automatically cleaned up from the store after a delay.
2384
- *
2385
- * Note: This functionality is for advanced users who want to build their own framework
2386
- * integrations. Our SDK also provides a React integration for convenient usage.
2387
- *
2388
- * @beta
2389
- */
2390
- declare const getUsersState: BoundStoreAction<UsersStoreState, [options?: GetUsersOptions | undefined], StateSource<{
2391
- data: SanityUser[];
2392
- totalCount: number;
2393
- hasMore: boolean;
2394
- } | undefined>>;
2395
- /**
2396
- * Resolves the users for a specific resource without registering a lasting subscriber.
2397
- *
2398
- * This function fetches the users for a given resource and returns a promise that resolves with
2399
- * the users result. Unlike `getUsersState`, which registers subscribers to keep the data live and
2400
- * performs automatic cleanup, `resolveUsers` does not track subscribers. This makes it ideal for
2401
- * use with React Suspense, where the returned promise is thrown to delay rendering until the users
2402
- * result becomes available. Once the promise resolves, it is expected that a real subscriber will
2403
- * be added via `getUsersState` to manage ongoing updates.
2404
- *
2405
- * Additionally, an optional AbortSignal can be provided to cancel the request and immediately
2406
- * clear the associated state if there are no active subscribers.
2407
- *
2408
- * @beta
2409
- */
2410
- declare const resolveUsers: BoundStoreAction<UsersStoreState, [ResolveUsersOptions], Promise<{
2411
- data: SanityUser[];
2412
- totalCount: number;
2413
- hasMore: boolean;
2414
- }>>;
2415
- /**
2416
- * Loads more users for a specific resource.
2417
- *
2418
- * This function triggers a request to fetch the next page of users for a given resource. It
2419
- * requires that users have already been loaded for the resource (via `resolveUsers` or
2420
- * `getUsersState`), and that there are more users available to load (as indicated by the `hasMore`
2421
- * property).
2422
- *
2423
- * The function returns a promise that resolves when the next page of users has been loaded.
2424
- *
2425
- * @beta
2426
- */
2427
- declare const loadMoreUsers: BoundStoreAction<UsersStoreState, [options?: GetUsersOptions | undefined], Promise<{
2428
- data: SanityUser[];
2429
- totalCount: number;
2430
- hasMore: boolean;
2431
- }>>;
2432
- /**
2433
- * @beta
2434
- */
2435
- declare const getUserState: BoundStoreAction<UsersStoreState, [GetUserOptions], Observable<SanityUser | undefined>>;
2436
- /**
2437
- * @beta
2438
- */
2439
- declare const resolveUser: BoundStoreAction<UsersStoreState, [ResolveUserOptions], Promise<SanityUser>>;
2440
- interface StoreEntry<TParams extends unknown[], TData> {
2441
- params: TParams;
2442
- instance: SanityInstance;
2443
- key: string;
2444
- data?: TData;
2445
- error?: unknown;
2446
- subscriptions: string[];
2447
- lastFetchInitiatedAt?: string;
2448
- }
2449
- /**
2450
- * Internal helper type
2451
- * @public
2452
- */
2453
- interface FetcherStoreState<TParams extends unknown[], TData> {
2454
- stateByParams: { [TSerializedKey in string]?: StoreEntry<TParams, TData> };
2455
- error?: unknown;
2456
- }
2457
- /**
2458
- * Internal helper type
2459
- * @public
2460
- */
2461
- interface FetcherStore<TParams extends unknown[], TData> {
2462
- getState: BoundStoreAction<FetcherStoreState<TParams, TData>, TParams, StateSource<TData | undefined>>;
2463
- resolveState: BoundStoreAction<FetcherStoreState<TParams, TData>, TParams, Promise<TData>>;
2464
- }
2465
- /**
2466
- * Creates a GROQ search filter string (`[@] match text::query("...")`)
2467
- * from a raw search query string.
2468
- *
2469
- * It applies wildcard ('*') logic to the last eligible token and escapes
2470
- * double quotes within the search term.
2471
- *
2472
- * If the input query is empty or only whitespace, it returns an empty string.
2473
- *
2474
- * @param query - The raw input search string.
2475
- * @returns The GROQ search filter string, or an empty string.
2476
- * @internal
2477
- */
2478
- declare function createGroqSearchFilter(query: string): string;
2479
- /**
2480
- * Filter criteria for intent matching. Can be combined to create more specific intents.
2481
- *
2482
- * @example
2483
- * ```typescript
2484
- * // matches only geopoints in the travel-project project, production dataset
2485
- * const filter: IntentFilter = {
2486
- * projectId: 'travel-project',
2487
- * dataset: 'production',
2488
- * types: ['geopoint']
2489
- * }
2490
- *
2491
- * // matches all documents in the travel-project project
2492
- * const filter: IntentFilter = {
2493
- * projectId: 'travel-project',
2494
- * types: ['*']
2495
- * }
2496
- *
2497
- * // matches geopoints in the travel-project production dataset and map pins in all projects in the org
2498
- * const filters: IntentFilter[] = [
2499
- * {
2500
- * projectId: 'travel-project',
2501
- * dataset: 'production',
2502
- * types: ['geopoint']
2503
- * },
2504
- * {
2505
- * types: ['map-pin']
2506
- * }
2507
- * ]
2508
- * ```
2509
- * @public
2510
- */
2511
- interface IntentFilter {
2512
- /**
2513
- * Project ID to match against
2514
- * @remarks When specified, the intent will only match for the specified project.
2515
- */
2516
- projectId?: string;
2517
- /**
2518
- * Dataset to match against
2519
- * @remarks When specified, the intent will only match for the specified dataset. Requires projectId to be specified.
2520
- */
2521
- dataset?: string;
2522
- /**
2523
- * Document types that this intent can handle
2524
- * @remarks This is required for all filters. Use ['*'] to match all document types.
2525
- */
2526
- types: string[];
2527
- }
2528
- /**
2529
- * Intent definition structure for registering user intents
2530
- * @public
2531
- */
2532
- interface Intent {
2533
- /**
2534
- * Unique identifier for this intent
2535
- * @remarks Should be unique across all registered intents in an org for proper matching
2536
- */
2537
- id: string;
2538
- /**
2539
- * The action that this intent performs
2540
- * @remarks Examples: "view", "edit", "create", "delete"
2541
- */
2542
- action: 'view' | 'edit' | 'create' | 'delete';
2543
- /**
2544
- * Human-readable title for this intent
2545
- * @remarks Used for display purposes in UI or logs
2546
- */
2547
- title: string;
2548
- /**
2549
- * Detailed description of what this intent does
2550
- * @remarks Helps users understand the purpose and behavior of the intent
2551
- */
2552
- description?: string;
2553
- /**
2554
- * Array of filter criteria for intent matching
2555
- * @remarks At least one filter is required. Use `{types: ['*']}` to match everything
2556
- */
2557
- filters: IntentFilter[];
2558
- }
2559
- /**
2560
- * Creates a properly typed intent definition for registration with the backend.
2561
- *
2562
- * This utility function provides TypeScript support and validation for intent declarations.
2563
- * It is also used in the CLI if intents are declared as bare objects in an intents file.
2564
- *
2565
- * @param intent - The intent definition object
2566
- * @returns The same intent object with proper typing
2567
- *
2568
- * @example
2569
- * ```typescript
2570
- * // Specific filter for a document type
2571
- * const viewGeopointInMapApp = defineIntent({
2572
- * id: 'viewGeopointInMapApp',
2573
- * action: 'view',
2574
- * title: 'View a geopoint in the map app',
2575
- * description: 'This lets you view a geopoint in the map app',
2576
- * filters: [
2577
- * {
2578
- * projectId: 'travel-project',
2579
- * dataset: 'production',
2580
- * types: ['geopoint']
2581
- * }
2582
- * ]
2583
- * })
2584
- *
2585
- * export default viewGeopointInMapApp
2586
- * ```
2587
- *
2588
- * If your intent is asynchronous, resolve the promise before defining / returning the intent
2589
- * ```typescript
2590
- * async function createAsyncIntent() {
2591
- * const currentProject = await asyncProjectFunction()
2592
- * const currentDataset = await asyncDatasetFunction()
2593
- *
2594
- * return defineIntent({
2595
- * id: 'dynamicIntent',
2596
- * action: 'view',
2597
- * title: 'Dynamic Intent',
2598
- * description: 'Intent with dynamically resolved values',
2599
- * filters: [
2600
- * {
2601
- * projectId: currentProject, // Resolved value
2602
- * dataset: currentDataset, // Resolved value
2603
- * types: ['document']
2604
- * }
2605
- * ]
2606
- * })
2607
- * }
2608
- *
2609
- * const intent = await createAsyncIntent()
2610
- * export default intent
2611
- * ```
2612
- *
2613
- * @public
2614
- */
2615
- declare function defineIntent(intent: Intent): Intent;
2616
- /**
2617
- * @public
2618
- * Extracts the project ID from a CorsOriginError message.
2619
- * @param error - The error to extract the project ID from.
2620
- * @returns The project ID or null if the error is not a CorsOriginError.
2621
- */
2622
- declare function getCorsErrorProjectId(error: Error): string | null;
2623
- /**
2624
- * Returns true when the given error looks like a dynamic-import or
2625
- * code-split chunk-loading failure.
2626
- *
2627
- * These errors typically surface when a user has a tab open against a
2628
- * previously-deployed version of an app and the JavaScript or CSS chunk
2629
- * filenames have since changed: a fresh deployment removes the hashed assets
2630
- * the open tab still references. Detecting them lets the SDK trigger an
2631
- * automatic reload so the user gets the new build without manual intervention.
2632
- *
2633
- * Recognized shapes (webpack ChunkLoadError, Vite "Failed to fetch
2634
- * dynamically imported module", Firefox "error loading dynamically imported
2635
- * module", Safari "Importing a module script failed", and Vite "Unable to
2636
- * preload CSS").
2637
- *
2638
- * @param error - The value to inspect. Anything that is not an Error
2639
- * instance returns false.
2640
- * @returns True if the error matches a known import/chunk-load failure.
2641
- *
2642
- * @public
2643
- */
2644
- declare function isImportError(error: unknown): boolean;
2645
- /**
2646
- * This version is provided by pkg-utils at build time
2647
- * @internal
2648
- */
2649
- declare const CORE_SDK_VERSION: {};
2650
- /**
2651
- * @public
2652
- */
2653
- type SanityProject$1 = SanityProject;
2654
- /**
2655
- * Represents the various states the authentication can be in.
2656
- *
2657
- * @public
2658
- */
2659
- type AuthState = LoggedInAuthState | LoggedOutAuthState | LoggingInAuthState | ErrorAuthState;
2660
- /**
2661
- * Logged-in state from the auth state.
2662
- * @public
2663
- */
2664
- type LoggedInAuthState = {
2665
- type: AuthStateType.LOGGED_IN;
2666
- token: string;
2667
- currentUser: CurrentUser | null;
2668
- lastTokenRefresh?: number;
2669
- };
2670
- /**
2671
- * Logged-out state from the auth state.
2672
- * @public
2673
- */
2674
- type LoggedOutAuthState = {
2675
- type: AuthStateType.LOGGED_OUT;
2676
- isDestroyingSession: boolean;
2677
- };
2678
- /**
2679
- * Logging-in state from the auth state.
2680
- * @public
2681
- */
2682
- type LoggingInAuthState = {
2683
- type: AuthStateType.LOGGING_IN;
2684
- isExchangingToken: boolean;
2685
- };
2686
- /**
2687
- * Error state from the auth state.
2688
- * @public
2689
- */
2690
- type ErrorAuthState = {
2691
- type: AuthStateType.ERROR;
2692
- error: unknown;
2693
- };
2694
- /**
2695
- * Represents the various states the authentication can be in.
2696
- *
2697
- * @public
2698
- */
2699
- interface DashboardContext {
2700
- mode?: string;
2701
- env?: string;
2702
- orgId?: string;
2703
- }
2704
- /**
2705
- * The method of authentication used.
2706
- * @internal
2707
- */
2708
- type AuthMethodOptions = 'localstorage' | 'cookie' | undefined;
2709
- /**
2710
- * @public
2711
- */
2712
- interface AuthStoreState {
2713
- authState: AuthState;
2714
- providers?: AuthProvider[];
2715
- options: {
2716
- initialLocationHref: string;
2717
- clientFactory: (config: ClientConfig) => SanityClient;
2718
- customProviders: AuthConfig['providers'];
2719
- storageKey: string;
2720
- storageArea: Storage | undefined;
2721
- apiHost: string | undefined;
2722
- loginUrl: string;
2723
- callbackUrl: string | undefined;
2724
- providedToken: string | undefined;
2725
- authMethod: AuthMethodOptions;
2726
- };
2727
- dashboardContext?: DashboardContext;
2728
- }
2729
- /**
2730
- * @public
2731
- */
2732
- declare const getCurrentUserState: BoundStoreAction<AuthStoreState, [], StateSource<CurrentUser | null>>;
2733
- /**
2734
- * @public
2735
- */
2736
- declare const getTokenState: BoundStoreAction<AuthStoreState, [], StateSource<string | null>>;
2737
- /**
2738
- * @public
2739
- */
2740
- declare const getLoginUrlState: BoundStoreAction<AuthStoreState, [], StateSource<string>>;
2741
- /**
2742
- * @public
2743
- */
2744
- declare const getAuthState: BoundStoreAction<AuthStoreState, [], StateSource<AuthState>>;
2745
- /**
2746
- * @public
2747
- */
2748
- declare const getDashboardOrganizationId: BoundStoreAction<AuthStoreState, [], StateSource<string | undefined>>;
2749
- /**
2750
- * Returns a state source indicating if the SDK is running within a dashboard context.
2751
- * @public
2752
- */
2753
- declare const getIsInDashboardState: BoundStoreAction<AuthStoreState, [], StateSource<boolean>>;
2754
- /**
2755
- * Action to explicitly set the authentication token.
2756
- * Used internally by the Comlink token refresh.
2757
- * @internal
2758
- */
2759
- declare const setAuthToken: BoundStoreAction<AuthStoreState, [token: string | null], void>;
2760
- /** @internal */
2761
- type ApiErrorBody = {
2762
- error?: {
2763
- type?: string;
2764
- description?: string;
2765
- };
2766
- type?: string;
2767
- description?: string;
2768
- message?: string;
2769
- };
2770
- /** @internal Extracts the structured API error body from a ClientError, if present. */
2771
- declare function getClientErrorApiBody(error: ClientError): ApiErrorBody | undefined;
2772
- /** @internal Returns the error type string from an API error body, if available. */
2773
- declare function getClientErrorApiType(error: ClientError): string | undefined;
2774
- /** @internal Returns the error description string from an API error body, if available. */
2775
- declare function getClientErrorApiDescription(error: ClientError): string | undefined;
2776
- /** @internal True if the error represents a projectUserNotFoundError. */
2777
- declare function isProjectUserNotFoundClientError(error: ClientError): boolean;
2778
- export { parseQueryKey as $, editDocument as $n, agentGenerate as $r, resolveOrganization as $t, CORE_SDK_VERSION as A, isMediaLibrarySource as Ai, Action as An, FrameMessage as Ar, RollCallEvent as At, getUsersState as B, PublishDocumentAction as Bn, observeOrganizationVerificationState as Br, SanityUserResponse as Bt, SanityProject$1 as C, StudioConfig as Ci, resolvePermissions as Cn, getOrCreateNode as Cr, PreviewValue as Ct, jsonMatch as D, isDatasetResource as Di, JsonMatch as Dn, getOrCreateChannel as Dr, getPresence as Dt, joinPaths as E, isCanvasSource as Ei, PermissionDeniedReason as En, destroyController as Er, ValidProjection as Et, defineIntent as F, DeleteReleaseAction as Fn, ClientStoreState as Fr, GetUsersOptions as Ft, parseUsersKey as G, UnpublishDocumentAction as Gn, AgentPatchOptions as Gr, OrganizationsOptions as Gt, resolveUser as H, ReleaseAction as Hn, AuthStateType as Hr, UsersGroupState as Ht, createGroqSearchFilter as I, DiscardDocumentAction as In, getClient as Ir, Membership as It, getActiveReleasesState as J, createDocument as Jn, AgentPromptResult as Jr, Organization as Jt, getPerspectiveState as K, UnscheduleReleaseAction as Kn, AgentPatchResult as Kr, getOrganizationsState as Kt, FetcherStore as L, DocumentAction as Ln, getClientState as Lr, ResolveUserOptions as Lt, getCorsErrorProjectId as M, AuthProvider as Mi, CreateDocumentAction as Mn, RequestNewTokenMessage as Mr, TransportEvent as Mt, Intent as N, CreateReleaseAction as Nn, WindowMessage as Nr, UserPresence as Nt, slicePath as O, isDatasetSource as Oi, Selector as On, getOrCreateController as Or, DisconnectEvent as Ot, IntentFilter as P, DeleteDocumentAction as Pn, ClientOptions as Pr, GetUserOptions as Pt, getQueryState as Q, discardDocument as Qn, AgentTranslateResult as Qr, getOrganizationState as Qt, FetcherStoreState as R, EditDocumentAction as Rn, logout as Rr, ResolveUsersOptions as Rt, SanityDocument$3 as S, SanityConfig as Si, resolveDocument as Sn, ComlinkNodeState as Sr, PreviewStoreState as St, getPathDepth as T, isCanvasResource as Ti, DocumentPermissionsResult as Tn, ComlinkControllerState as Tr, ProjectionValuePending as Tt, resolveUsers as U, ScheduleReleaseAction as Un, AgentGenerateOptions as Ur, UsersStoreState as Ut, loadMoreUsers as V, PublishReleaseAction as Vn, OrgVerificationResult as Vr, UserProfile as Vt, getUsersKey as W, UnarchiveReleaseAction as Wn, AgentGenerateResult as Wr, Organizations as Wt, QueryOptions as X, deleteDocument as Xn, AgentTransformResult as Xr, OrganizationMember as Xt, getAllReleasesState as Y, createRelease as Yn, AgentTransformOptions as Yr, OrganizationBase as Yt, getQueryKey as Z, deleteRelease as Zn, AgentTranslateOptions as Zr, OrganizationOptions as Zt, getTokenState as _, MediaLibrarySource as _i, TransactionRevertedEvent as _n, createDocumentHandle as _r, PREVIEW_PROJECTION as _t, isProjectUserNotFoundClientError as a, createSanityInstance as ai, ApplyDocumentActionsOptions as an, unpublishDocument as ar, getProjectionState as at, ReleaseDocument$1 as b, ReleaseHandle as bi, getDocumentSyncStatus as bn, NodeState as br, PreviewMedia as bt, ErrorAuthState as c, CanvasSource as ci, DocumentCreatedEvent as cn, resolveDatasets as cr, ProjectMember as ct, LoggingInAuthState as d, DatasetSource as di, DocumentEditedEvent as dn, LogContext as dr, ProjectOptions as dt, agentPatch as ei, FavoriteStatusResponse as en, editRelease as er, resolveQuery as et, getAuthState as f, DocumentHandle as fi, DocumentEvent as fn, LogLevel as fr, getProjectState as ft, getLoginUrlState as g, MediaLibraryResource as gi, TransactionAcceptedEvent as gn, createDatasetHandle as gr, transformProjectionToPreview as gt, getIsInDashboardState as h, DocumentTypeHandle as hi, DocumentUnpublishedEvent as hn, LoggerConfig as hr, resolvePreview as ht, getClientErrorApiType as i, SanityInstance as ii, ActionsResult as in, unarchiveRelease as ir, resolveProjection as it, isImportError as j, AuthConfig as ji, ArchiveReleaseAction as jn, NewTokenResponseMessage as jr, StateEvent as jt, stringifyPath as k, isMediaLibraryResource as ki, StateSource as kn, releaseChannel as kr, PresenceLocation as kt, LoggedInAuthState as l, DatasetHandle as li, DocumentDeletedEvent as ln, configureLogging as lr, ProjectMemberRole as lt, getDashboardOrganizationId as m, DocumentSource as mi, DocumentTransactionSubmissionResult as mn, Logger as mr, ResolvePreviewOptions as mt, getClientErrorApiBody as n, agentTransform as ni, resolveFavoritesState as nn, publishRelease as nr, getProjectsState as nt, AuthState as o, isStudioConfig as oi, applyDocumentActions as on, unscheduleRelease as or, Project as ot, getCurrentUserState as p, DocumentResource as pi, DocumentPublishedEvent as pn, LogNamespace as pr, resolveProject as pt, ReleaseState as q, archiveRelease as qn, AgentPromptOptions as qr, resolveOrganizations as qt, getClientErrorApiDescription as r, agentTranslate as ri, getReleaseDocumentId as rn, scheduleRelease as rr, resolveProjects as rt, AuthStoreState as s, CanvasResource$1 as si, ActionErrorEvent as sn, getDatasetsState as sr, ProjectBase as st, ApiErrorBody as t, agentPrompt as ti, getFavoritesState as tn, publishDocument as tr, ProjectsOptions as tt, LoggedOutAuthState as u, DatasetResource as ui, DocumentDiscardedEvent as un, InstanceContext as ur, ProjectMetadata as ut, setAuthToken as v, PerspectiveHandle as vi, DocumentOptions as vn, createDocumentTypeHandle as vr, GetPreviewStateOptions as vt, getIndexForKey as w, TokenSource as wi, subscribeDocumentEvents as wn, releaseNode as wr, ValuePending as wt, Role as x, ReleasePerspective as xi, getPermissionsState as xn, getNodeState as xr, PreviewQueryResult as xt, CurrentUser$1 as y, ProjectHandle as yi, getDocumentState as yn, createProjectHandle as yr, getPreviewState as yt, getUserState as z, EditReleaseAction as zn, handleAuthCallback as zr, SanityUser as zt };