@sanity/sdk 2.12.0 → 2.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/dist/_chunks-dts/createGroqSearchFilter.d.ts +925 -0
  2. package/dist/_chunks-dts/createGroqSearchFilter.d.ts.map +1 -0
  3. package/dist/_chunks-es/createGroqSearchFilter.js +261 -225
  4. package/dist/_chunks-es/createGroqSearchFilter.js.map +1 -1
  5. package/dist/_chunks-es/version.js +1 -1
  6. package/dist/_exports/_internal.d.ts +3 -2
  7. package/dist/_exports/_internal.d.ts.map +1 -0
  8. package/dist/index.d.ts +1856 -2
  9. package/dist/index.d.ts.map +1 -0
  10. package/dist/index.js +207 -133
  11. package/dist/index.js.map +1 -1
  12. package/package.json +11 -11
  13. package/src/auth/authLogger.ts +30 -0
  14. package/src/auth/authStore.test.ts +96 -1
  15. package/src/auth/authStore.ts +55 -24
  16. package/src/auth/handleAuthCallback.test.ts +23 -1
  17. package/src/auth/handleAuthCallback.ts +25 -6
  18. package/src/auth/logout.test.ts +68 -1
  19. package/src/auth/logout.ts +22 -3
  20. package/src/auth/refreshStampedToken.test.ts +15 -0
  21. package/src/auth/refreshStampedToken.ts +12 -1
  22. package/src/auth/subscribeToStateAndFetchCurrentUser.test.ts +17 -2
  23. package/src/auth/subscribeToStateAndFetchCurrentUser.ts +9 -0
  24. package/src/document/applyDocumentActions.test.ts +24 -0
  25. package/src/document/applyDocumentActions.ts +13 -2
  26. package/src/document/documentConstants.ts +7 -0
  27. package/src/document/documentStore.test.ts +69 -0
  28. package/src/document/documentStore.ts +36 -5
  29. package/src/document/listen.ts +1 -1
  30. package/src/document/permissions.test.ts +79 -0
  31. package/src/document/permissions.ts +8 -7
  32. package/src/document/processActions/create.ts +7 -4
  33. package/src/document/processActions/delete.ts +4 -4
  34. package/src/document/processActions/discard.ts +2 -2
  35. package/src/document/processActions/edit.ts +4 -3
  36. package/src/document/processActions/processActions.ts +9 -0
  37. package/src/document/processActions/publish.ts +4 -4
  38. package/src/document/processActions/releaseArchive.ts +4 -4
  39. package/src/document/processActions/releaseCreate.ts +2 -2
  40. package/src/document/processActions/releaseDelete.ts +2 -2
  41. package/src/document/processActions/releaseEdit.ts +2 -1
  42. package/src/document/processActions/releasePublish.ts +2 -2
  43. package/src/document/processActions/releaseSchedule.ts +4 -4
  44. package/src/document/processActions/shared.ts +15 -3
  45. package/src/document/processActions/unpublish.ts +3 -3
  46. package/src/document/reducers.ts +4 -3
  47. package/src/document/resourceRules.test.ts +178 -0
  48. package/src/document/resourceRules.ts +117 -0
  49. package/dist/_chunks-dts/utils.d.ts +0 -2774
@@ -1,2774 +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
- error?: unknown;
1363
- sharedListener: SharedListener;
1364
- fetchDocument: (documentId: string) => Observable<SanityDocument$2 | null>;
1365
- events: Subject<DocumentEvent>;
1366
- }
1367
- interface DocumentState {
1368
- id: string;
1369
- /**
1370
- * the "remote" local copy that matches the server. represents the last known
1371
- * server state. this gets updated every time we confirm remote patches
1372
- */
1373
- remote?: SanityDocument$2 | null;
1374
- /**
1375
- * the current ephemeral working copy that includes local optimistic changes
1376
- * that have not yet been confirmed by the server
1377
- */
1378
- local?: SanityDocument$2 | null;
1379
- /**
1380
- * the revision that our remote document is at
1381
- */
1382
- remoteRev?: string | null;
1383
- /**
1384
- * Array of subscription IDs. This document state will be deleted if there are
1385
- * no subscribers.
1386
- */
1387
- subscriptions: string[];
1388
- /**
1389
- * An object keyed by transaction ID of revisions sent out but that have not
1390
- * yet been verified yet. When an applied transaction is transitioned to an
1391
- * outgoing transaction, it also adds unverified revisions for each document
1392
- * that is part of that outgoing transaction. Transactions are submitted to
1393
- * the server with a locally generated transaction ID. This way we can observe
1394
- * when our transaction comes back through the shared listener. Each listener
1395
- * event that comes back contains a `previousRev`. If we see our own
1396
- * transaction with a different `previousRev` than expected, we can rebase our
1397
- * local transactions on top of this new remote.
1398
- */
1399
- unverifiedRevisions?: { [TTransactionId in string]?: UnverifiedDocumentRevision };
1400
- }
1401
- /**
1402
- * @beta
1403
- * Options for specifying a document and optionally a path within it.
1404
- */
1405
- interface DocumentOptions<TPath extends string | undefined = undefined, TDocumentType extends string = string, TDataset extends string = string, TProjectId extends string = string> extends DocumentHandle<TDocumentType, TDataset, TProjectId> {
1406
- path?: TPath;
1407
- }
1408
- /** @beta */
1409
- 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>;
1410
- /** @beta */
1411
- 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>;
1412
- /** @beta */
1413
- declare function getDocumentState<TData>(instance: SanityInstance, options: DocumentOptions<string | undefined>): StateSource<TData | undefined | null>;
1414
- /** @beta */
1415
- 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>;
1416
- /** @beta */
1417
- declare function resolveDocument<TData extends SanityDocument$2>(instance: SanityInstance, docHandle: DocumentHandle<string, string, string>): Promise<TData | null>;
1418
- /** @beta */
1419
- declare const getDocumentSyncStatus: BoundStoreAction<DocumentStoreState, [doc: DocumentHandle<string, string, string>], StateSource<boolean | undefined>>;
1420
- type PermissionsStateOptions = {
1421
- resource?: DocumentResource;
1422
- actions: DocumentAction[];
1423
- };
1424
- /** @beta */
1425
- declare const getPermissionsState: BoundStoreAction<DocumentStoreState, [PermissionsStateOptions], StateSource<DocumentPermissionsResult>>;
1426
- /** @beta */
1427
- declare const resolvePermissions: BoundStoreAction<DocumentStoreState, [options: PermissionsStateOptions], Promise<DocumentPermissionsResult>>;
1428
- /** @beta */
1429
- declare const subscribeDocumentEvents: BoundStoreAction<DocumentStoreState, [options: {
1430
- resource?: DocumentResource;
1431
- eventHandler: (e: DocumentEvent) => void;
1432
- }], () => void>;
1433
- type ActionMap = {
1434
- create: 'sanity.action.document.version.create';
1435
- discard: 'sanity.action.document.version.discard';
1436
- unpublish: 'sanity.action.document.unpublish';
1437
- delete: 'sanity.action.document.delete';
1438
- edit: 'sanity.action.document.edit';
1439
- publish: 'sanity.action.document.publish';
1440
- releaseCreate: 'sanity.action.release.create';
1441
- releaseEdit: 'sanity.action.release.edit';
1442
- releasePublish: 'sanity.action.release.publish';
1443
- releaseSchedule: 'sanity.action.release.schedule';
1444
- releaseUnschedule: 'sanity.action.release.unschedule';
1445
- releaseArchive: 'sanity.action.release.archive';
1446
- releaseUnarchive: 'sanity.action.release.unarchive';
1447
- releaseDelete: 'sanity.action.release.delete';
1448
- };
1449
- type OptimisticLock = {
1450
- ifDraftRevisionId?: string;
1451
- ifPublishedRevisionId?: string;
1452
- };
1453
- interface ReleaseMetadataPayload {
1454
- title?: string;
1455
- description?: string;
1456
- intendedPublishAt?: string;
1457
- releaseType?: 'asap' | 'scheduled' | 'undecided';
1458
- cardinality?: 'one' | 'many';
1459
- }
1460
- type HttpAction = {
1461
- actionType: ActionMap['create'];
1462
- publishedId: string;
1463
- attributes: SanityDocumentLike;
1464
- } | {
1465
- actionType: ActionMap['discard'];
1466
- versionId: string;
1467
- purge?: boolean;
1468
- } | {
1469
- actionType: ActionMap['unpublish'];
1470
- draftId: string;
1471
- publishedId: string;
1472
- } | {
1473
- actionType: ActionMap['delete'];
1474
- publishedId: string;
1475
- includeDrafts?: string[];
1476
- } | {
1477
- actionType: ActionMap['edit'];
1478
- draftId: string;
1479
- publishedId: string;
1480
- patch: PatchOperations;
1481
- } | ({
1482
- actionType: ActionMap['publish'];
1483
- draftId: string;
1484
- publishedId: string;
1485
- } & OptimisticLock) | {
1486
- actionType: ActionMap['releaseCreate'];
1487
- releaseId: string;
1488
- metadata?: ReleaseMetadataPayload;
1489
- } | {
1490
- actionType: ActionMap['releaseEdit'];
1491
- releaseId: string;
1492
- patch: PatchOperations;
1493
- } | {
1494
- actionType: ActionMap['releasePublish'];
1495
- releaseId: string;
1496
- } | {
1497
- actionType: ActionMap['releaseSchedule'];
1498
- releaseId: string;
1499
- publishAt: string;
1500
- } | {
1501
- actionType: ActionMap['releaseUnschedule'];
1502
- releaseId: string;
1503
- } | {
1504
- actionType: ActionMap['releaseArchive'];
1505
- releaseId: string;
1506
- } | {
1507
- actionType: ActionMap['releaseUnarchive'];
1508
- releaseId: string;
1509
- } | {
1510
- actionType: ActionMap['releaseDelete'];
1511
- releaseId: string;
1512
- };
1513
- /**
1514
- * Represents a transaction that is queued to be applied but has not yet been
1515
- * applied. A transaction will remain in a queued state until all required
1516
- * documents for the transactions are available locally.
1517
- */
1518
- interface QueuedTransaction {
1519
- /**
1520
- * the ID of this transaction. this is generated client-side.
1521
- */
1522
- transactionId: string;
1523
- /**
1524
- * the high-level actions associated with this transaction. note that these
1525
- * actions don't mention draft IDs and is meant to abstract away the draft
1526
- * model from users.
1527
- */
1528
- actions: Action[];
1529
- /**
1530
- * An optional flag set to disable this transaction from being batched with
1531
- * other transactions.
1532
- */
1533
- disableBatching?: boolean;
1534
- }
1535
- /**
1536
- * Represents a transaction that has been applied locally but has not been
1537
- * committed/transitioned-to-outgoing. These transactions are visible to the
1538
- * user but may be rebased upon a new working document set. Applied transactions
1539
- * also contain the resulting `outgoingActions` that will be submitted to
1540
- * Content Lake. These `outgoingActions` depend on the state of the working
1541
- * documents so they are recomputed on rebase and are only relevant to applied
1542
- * actions (we cannot compute `outgoingActions` for queued transactions because
1543
- * we haven't resolved the set of documents the actions are dependent on yet).
1544
- *
1545
- * In order to support better conflict resolution, the original `previous` set
1546
- * is saved as the `base` set.
1547
- */
1548
- interface AppliedTransaction extends QueuedTransaction {
1549
- /**
1550
- * the resulting set of documents after the actions have been applied
1551
- */
1552
- working: DocumentSet;
1553
- /**
1554
- * the previous set of documents before the action was applied
1555
- */
1556
- previous: DocumentSet;
1557
- /**
1558
- * the original `previous` document set captured when this action was
1559
- * originally applied. this is used as a reference point to do a 3-way merge
1560
- * if this applied transaction ever needs to be reapplied on a different
1561
- * set of documents.
1562
- */
1563
- base: DocumentSet;
1564
- /**
1565
- * the `_rev`s from `previous` document set
1566
- */
1567
- previousRevs: { [TDocumentId in string]?: string };
1568
- /**
1569
- * a timestamp for when this transaction was applied locally
1570
- */
1571
- timestamp: string;
1572
- /**
1573
- * the resulting HTTP actions derived from the state of the `working` document
1574
- * set. these are sent to Content Lake as-is when this transaction is batched
1575
- * and transitioned into an outgoing transaction.
1576
- */
1577
- outgoingActions: HttpAction[];
1578
- /**
1579
- * similar to `outgoingActions` but comprised of mutations instead of actions.
1580
- * Useful for debugging, and is also used by liveEdit documents to send mutations,
1581
- * since they can't use the Actions API which is pretty dependent on the draft model.
1582
- */
1583
- outgoingMutations: Mutation[];
1584
- }
1585
- /**
1586
- * Represents a set of applied transactions batched into a single outgoing
1587
- * transaction. An outgoing transaction is the result of batching many applied
1588
- * actions. An outgoing transaction may be reverted locally if the server
1589
- * does not accept it.
1590
- */
1591
- interface OutgoingTransaction extends AppliedTransaction {
1592
- disableBatching: boolean;
1593
- batchedTransactionIds: string[];
1594
- }
1595
- interface UnverifiedDocumentRevision {
1596
- transactionId: string;
1597
- documentId: string;
1598
- previousRev: string | undefined;
1599
- timestamp: string;
1600
- }
1601
- /** @beta Response body from submitting an outgoing transaction (actions or mutations API). */
1602
- type DocumentTransactionSubmissionResult = Awaited<ReturnType<SanityClient['action']>> | MultipleMutationResult;
1603
- /** @beta */
1604
- type DocumentEvent = ActionErrorEvent | TransactionRevertedEvent | TransactionAcceptedEvent | DocumentRebaseErrorEvent | DocumentEditedEvent | DocumentCreatedEvent | DocumentDeletedEvent | DocumentPublishedEvent | DocumentUnpublishedEvent | DocumentDiscardedEvent;
1605
- /**
1606
- * @beta
1607
- * Event emitted when a precondition to applying an action fails.
1608
- * (For example: when trying to edit a document that no longer exists.)
1609
- */
1610
- interface ActionErrorEvent {
1611
- type: 'error';
1612
- documentId: string;
1613
- transactionId: string;
1614
- message: string;
1615
- error: unknown;
1616
- }
1617
- /**
1618
- * @beta
1619
- * Event emitted when a transaction is accepted.
1620
- */
1621
- interface TransactionAcceptedEvent {
1622
- type: 'accepted';
1623
- outgoing: OutgoingTransaction;
1624
- result: DocumentTransactionSubmissionResult;
1625
- }
1626
- /**
1627
- * @beta
1628
- * Event emitted when a transaction is reverted.
1629
- */
1630
- interface TransactionRevertedEvent {
1631
- type: 'reverted';
1632
- message: string;
1633
- error: unknown;
1634
- outgoing: OutgoingTransaction;
1635
- }
1636
- /**
1637
- * @beta
1638
- * Event emitted when an attempt to apply local changes to a modified remote document fails.
1639
- */
1640
- interface DocumentRebaseErrorEvent {
1641
- type: 'rebase-error';
1642
- documentId: string;
1643
- transactionId: string;
1644
- message: string;
1645
- error: unknown;
1646
- }
1647
- /**
1648
- * @beta
1649
- * Event emitted when a document is edited.
1650
- */
1651
- interface DocumentEditedEvent {
1652
- type: 'edited';
1653
- documentId: string;
1654
- outgoing: OutgoingTransaction;
1655
- }
1656
- /**
1657
- * @beta
1658
- * Event emitted when a document is created.
1659
- */
1660
- interface DocumentCreatedEvent {
1661
- type: 'created';
1662
- documentId: string;
1663
- outgoing: OutgoingTransaction;
1664
- }
1665
- /**
1666
- * @beta
1667
- * Event emitted when a document is deleted.
1668
- */
1669
- interface DocumentDeletedEvent {
1670
- type: 'deleted';
1671
- documentId: string;
1672
- outgoing: OutgoingTransaction;
1673
- }
1674
- /**
1675
- * @beta
1676
- * Event emitted when a document is published.
1677
- */
1678
- interface DocumentPublishedEvent {
1679
- type: 'published';
1680
- documentId: string;
1681
- outgoing: OutgoingTransaction;
1682
- }
1683
- /**
1684
- * @beta
1685
- * Event emitted when a document is unpublished.
1686
- */
1687
- interface DocumentUnpublishedEvent {
1688
- type: 'unpublished';
1689
- documentId: string;
1690
- outgoing: OutgoingTransaction;
1691
- }
1692
- /**
1693
- * @beta
1694
- * Event emitted when a document version is discarded.
1695
- */
1696
- interface DocumentDiscardedEvent {
1697
- type: 'discarded';
1698
- documentId: string;
1699
- outgoing: OutgoingTransaction;
1700
- }
1701
- /** @beta */
1702
- interface ActionsResult<TDocument extends SanityDocument$2 = SanityDocument$2> {
1703
- transactionId: string;
1704
- documents: DocumentSet<TDocument>;
1705
- previous: DocumentSet<TDocument>;
1706
- previousRevs: {
1707
- [documentId: string]: string | undefined;
1708
- };
1709
- appeared: string[];
1710
- updated: string[];
1711
- disappeared: string[];
1712
- submitted: () => Promise<DocumentTransactionSubmissionResult>;
1713
- }
1714
- /** @beta */
1715
- interface ApplyDocumentActionsOptions {
1716
- /**
1717
- * List of actions to apply. Accepts both document actions and release
1718
- * lifecycle actions because they share the same transaction pipeline.
1719
- */
1720
- actions: Action[];
1721
- /**
1722
- * The resource to which the documents being acted on belong.
1723
- */
1724
- resource?: DocumentResource;
1725
- /**
1726
- * Optionally provide an ID to be used as this transaction ID
1727
- */
1728
- transactionId?: string;
1729
- /**
1730
- * Set this to true to prevent this action from being batched with others.
1731
- */
1732
- disableBatching?: boolean;
1733
- }
1734
- /** @beta */
1735
- 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}`>>>;
1736
- /** @beta */
1737
- declare function applyDocumentActions(instance: SanityInstance, options: ApplyDocumentActionsOptions): Promise<ActionsResult>;
1738
- /**
1739
- * Returns the full release document ID for the given release name.
1740
- * e.g. `getReleaseDocumentId('my-release') === '_.releases.my-release'`
1741
- * @beta
1742
- */
1743
- declare function getReleaseDocumentId(releaseId: string): string;
1744
- /**
1745
- * @public
1746
- */
1747
- interface FavoriteStatusResponse {
1748
- isFavorited: boolean;
1749
- }
1750
- /**
1751
- * @public
1752
- */
1753
- interface FavoriteDocumentContext extends DocumentHandle {
1754
- resourceId: string;
1755
- resourceType: StudioResource['type'] | MediaResource['type'] | CanvasResource['type'];
1756
- schemaName?: string;
1757
- }
1758
- /**
1759
- * Gets a StateSource for the favorite status of a document.
1760
- * @param instance - The Sanity instance.
1761
- * @param context - The document context including ID, type, and resource information.
1762
- * @returns A StateSource emitting `{ isFavorited: boolean }`.
1763
- * @public
1764
- */
1765
- declare const getFavoritesState: BoundStoreAction<FetcherStoreState<[FavoriteDocumentContext], FavoriteStatusResponse>, [FavoriteDocumentContext], StateSource<FavoriteStatusResponse | undefined>>;
1766
- /**
1767
- * Resolves the favorite status for a document.
1768
- * @param instance - The Sanity instance.
1769
- * @param context - The document context including ID, type, and resource information.
1770
- * @returns A Promise resolving to `{ isFavorited: boolean }`.
1771
- * @public
1772
- */
1773
- declare const resolveFavoritesState: BoundStoreAction<FetcherStoreState<[FavoriteDocumentContext], FavoriteStatusResponse>, [FavoriteDocumentContext], Promise<FavoriteStatusResponse>>;
1774
- /** @public */
1775
- interface OrganizationMember {
1776
- sanityUserId: string;
1777
- isCurrentUser: boolean;
1778
- user: {
1779
- id: string;
1780
- displayName: string;
1781
- familyName: string;
1782
- givenName: string;
1783
- middleName: string | null;
1784
- imageUrl: string | null;
1785
- email: string;
1786
- loginProvider: string;
1787
- };
1788
- roles: Array<{
1789
- name: string;
1790
- title: string;
1791
- description?: string;
1792
- }>;
1793
- }
1794
- /**
1795
- * The base fields returned from `/organizations/<id>` for every organization.
1796
- * @public
1797
- */
1798
- interface OrganizationBase {
1799
- id: string;
1800
- name: string;
1801
- slug: string | null;
1802
- createdAt: string;
1803
- createdByUserId: string;
1804
- updatedAt: string;
1805
- deletedAt: string | null;
1806
- dashboardStatus: 'enabled' | 'disabled';
1807
- aiFeaturesStatus: 'enabled' | 'disabled';
1808
- mediaLibraryStatus: 'enabled' | 'disabled';
1809
- requestAccessStatus: 'allowed' | 'disabled';
1810
- telemetryConsentStatus: 'allowed' | 'msa_denied' | 'customer_denied';
1811
- oauthAppsStatus: 'allowed' | 'blocked';
1812
- defaultRoleName: string;
1813
- domains: string[] | null;
1814
- }
1815
- /** @public */
1816
- interface OrganizationOptions<IncludeMembers extends boolean = false, IncludeFeatures extends boolean = false> {
1817
- includeMembers?: IncludeMembers;
1818
- includeFeatures?: IncludeFeatures;
1819
- organizationId: string;
1820
- }
1821
- /**
1822
- * An `Organization` with `members` and/or `features` conditionally included
1823
- * based on the query options used to fetch it.
1824
- * @public
1825
- */
1826
- type Organization<IncludeMembers extends boolean = false, IncludeFeatures extends boolean = false> = OrganizationBase & (boolean extends IncludeMembers ? {
1827
- members?: OrganizationMember[];
1828
- } : IncludeMembers extends true ? {
1829
- members: OrganizationMember[];
1830
- } : unknown) & (boolean extends IncludeFeatures ? {
1831
- features?: string[];
1832
- } : IncludeFeatures extends true ? {
1833
- features: string[];
1834
- } : unknown);
1835
- /**
1836
- * Public signature for the organization state source. The conditional generics
1837
- * cannot flow through `BoundStoreAction`, so we declare the signature here
1838
- * and assign the (already-correct) runtime function to it.
1839
- */
1840
- type GetOrganizationState = <IncludeMembers extends boolean = false, IncludeFeatures extends boolean = false>(instance: SanityInstance, options: OrganizationOptions<IncludeMembers, IncludeFeatures>) => StateSource<Organization<IncludeMembers, IncludeFeatures> | undefined>;
1841
- type ResolveOrganization = <IncludeMembers extends boolean = false, IncludeFeatures extends boolean = false>(instance: SanityInstance, options: OrganizationOptions<IncludeMembers, IncludeFeatures>) => Promise<Organization<IncludeMembers, IncludeFeatures>>;
1842
- /** @public */
1843
- declare const getOrganizationState: GetOrganizationState;
1844
- /** @public */
1845
- declare const resolveOrganization: ResolveOrganization;
1846
- /**
1847
- * The list shape returned from `/organizations`, with `members` and/or
1848
- * `features` conditionally included based on the query options used.
1849
- * @public
1850
- */
1851
- type Organizations<IncludeMembers extends boolean = false, IncludeFeatures extends boolean = false> = (Pick<OrganizationBase, 'id' | 'name' | 'slug' | 'createdAt' | 'updatedAt' | 'defaultRoleName' | 'dashboardStatus' | 'aiFeaturesStatus'> & (boolean extends IncludeMembers ? {
1852
- members?: OrganizationMember[];
1853
- } : IncludeMembers extends true ? {
1854
- members: OrganizationMember[];
1855
- } : unknown) & (boolean extends IncludeFeatures ? {
1856
- features?: string[];
1857
- } : IncludeFeatures extends true ? {
1858
- features: string[];
1859
- } : unknown))[];
1860
- /** @public */
1861
- interface OrganizationsOptions<IncludeMembers extends boolean = false, IncludeFeatures extends boolean = false> extends Omit<OrganizationOptions<IncludeMembers, IncludeFeatures>, 'organizationId'> {
1862
- /**
1863
- * When `true`, includes organisations the user has access to via
1864
- * project-level grants, not just direct organisation memberships.
1865
- */
1866
- includeImplicitMemberships?: boolean;
1867
- }
1868
- /**
1869
- * Public signature for the organization state source. The conditional generics
1870
- * cannot flow through `BoundStoreAction`, so we declare the signature here
1871
- * and assign the (already-correct) runtime function to it.
1872
- */
1873
- type GetOrganizationsState = <IncludeMembers extends boolean = false, IncludeFeatures extends boolean = false>(instance: SanityInstance, options?: OrganizationsOptions<IncludeMembers, IncludeFeatures>) => StateSource<Organizations<IncludeMembers, IncludeFeatures> | undefined>;
1874
- type ResolveOrganizations = <IncludeMembers extends boolean = false, IncludeFeatures extends boolean = false>(instance: SanityInstance, options?: OrganizationsOptions<IncludeMembers, IncludeFeatures>) => Promise<Organizations<IncludeMembers, IncludeFeatures>>;
1875
- /** @public */
1876
- declare const getOrganizationsState: GetOrganizationsState;
1877
- /** @public */
1878
- declare const resolveOrganizations: ResolveOrganizations;
1879
- /**
1880
- * @public
1881
- */
1882
- interface SanityUser {
1883
- sanityUserId: string;
1884
- profile: UserProfile;
1885
- memberships: Membership[];
1886
- }
1887
- /**
1888
- * @public
1889
- */
1890
- interface Membership {
1891
- addedAt?: string;
1892
- resourceType: string;
1893
- resourceId: string;
1894
- roleNames: Array<string>;
1895
- lastSeenAt?: string | null;
1896
- }
1897
- /**
1898
- * @public
1899
- */
1900
- interface UserProfile {
1901
- id: string;
1902
- displayName: string;
1903
- email: string;
1904
- familyName?: string;
1905
- givenName?: string;
1906
- middleName?: string | null;
1907
- imageUrl?: string;
1908
- provider: string;
1909
- tosAcceptedAt?: string;
1910
- createdAt: string;
1911
- updatedAt?: string;
1912
- isCurrentUser?: boolean;
1913
- providerId?: string;
1914
- }
1915
- /**
1916
- * @public
1917
- */
1918
- interface GetUsersOptions extends ProjectHandle {
1919
- resourceType?: 'organization' | 'project';
1920
- batchSize?: number;
1921
- organizationId?: string;
1922
- userId?: string;
1923
- }
1924
- /**
1925
- * @public
1926
- */
1927
- interface UsersGroupState {
1928
- subscriptions: string[];
1929
- totalCount?: number;
1930
- nextCursor?: string | null;
1931
- lastLoadMoreRequest?: string;
1932
- users?: SanityUser[];
1933
- error?: unknown;
1934
- }
1935
- /**
1936
- * @public
1937
- */
1938
- interface SanityUserResponse {
1939
- data: SanityUser[];
1940
- totalCount: number;
1941
- nextCursor: string | null;
1942
- }
1943
- /**
1944
- * @public
1945
- */
1946
- interface UsersStoreState {
1947
- users: { [TUsersKey in string]?: UsersGroupState };
1948
- error?: unknown;
1949
- }
1950
- /**
1951
- * @public
1952
- */
1953
- interface ResolveUsersOptions extends GetUsersOptions {
1954
- signal?: AbortSignal;
1955
- }
1956
- /**
1957
- * @public
1958
- */
1959
- interface GetUserOptions extends ProjectHandle {
1960
- userId: string;
1961
- resourceType?: 'organization' | 'project';
1962
- organizationId?: string;
1963
- }
1964
- /**
1965
- * @public
1966
- */
1967
- interface ResolveUserOptions extends GetUserOptions {
1968
- signal?: AbortSignal;
1969
- }
1970
- /** @public */
1971
- interface PresenceLocation {
1972
- type: 'document';
1973
- documentId: string;
1974
- path: string[];
1975
- lastActiveAt: string;
1976
- }
1977
- /** @public */
1978
- interface UserPresence {
1979
- user: SanityUser;
1980
- locations: PresenceLocation[];
1981
- sessionId: string;
1982
- }
1983
- /** @public */
1984
- type TransportEvent = RollCallEvent | StateEvent | DisconnectEvent;
1985
- /** @public */
1986
- interface RollCallEvent {
1987
- type: 'rollCall';
1988
- userId: string;
1989
- sessionId: string;
1990
- }
1991
- /** @public */
1992
- interface StateEvent {
1993
- type: 'state';
1994
- userId: string;
1995
- sessionId: string;
1996
- timestamp: string;
1997
- locations: PresenceLocation[];
1998
- }
1999
- /** @public */
2000
- interface DisconnectEvent {
2001
- type: 'disconnect';
2002
- userId: string;
2003
- sessionId: string;
2004
- timestamp: string;
2005
- }
2006
- /** @beta */
2007
- declare function getPresence(instance: SanityInstance, params?: {
2008
- resource?: DocumentResource;
2009
- }): StateSource<UserPresence[]>;
2010
- /**
2011
- * @public
2012
- * The result of a projection query
2013
- */
2014
- interface ProjectionValuePending<TValue extends object> {
2015
- data: TValue | null;
2016
- isPending: boolean;
2017
- }
2018
- /**
2019
- * @public
2020
- * @deprecated
2021
- * Template literals are a bit too limited, so this type is deprecated.
2022
- * Use `string` instead. Projection strings are validated at runtime.
2023
- */
2024
- type ValidProjection = string;
2025
- interface DocumentStatus {
2026
- lastEditedDraftAt?: string;
2027
- lastEditedPublishedAt?: string;
2028
- lastEditedVersionAt?: string;
2029
- }
2030
- /**
2031
- *
2032
- * @internal
2033
- */
2034
- interface PreviewQueryResult {
2035
- _id: string;
2036
- _type: string;
2037
- _updatedAt: string;
2038
- titleCandidates: Record<string, unknown>;
2039
- subtitleCandidates: Record<string, unknown>;
2040
- media?: PreviewMedia | null;
2041
- _status?: DocumentStatus;
2042
- }
2043
- /**
2044
- * Represents a media asset in a preview.
2045
- *
2046
- * @public
2047
- */
2048
- interface PreviewMedia {
2049
- type: 'image-asset';
2050
- _ref: string;
2051
- url: string;
2052
- }
2053
- /**
2054
- * Represents the set of values displayed as a preview for a given Sanity document.
2055
- * This includes a primary title, a secondary subtitle, an optional piece of media associated
2056
- * with the document, and the document's status.
2057
- *
2058
- * @public
2059
- */
2060
- interface PreviewValue {
2061
- /**
2062
- * The primary text displayed for the document preview.
2063
- */
2064
- title: string;
2065
- /**
2066
- * A secondary line of text providing additional context about the document.
2067
- */
2068
- subtitle?: string;
2069
- /**
2070
- * An optional piece of media representing the document within its preview.
2071
- * Currently, only image assets are available.
2072
- */
2073
- media?: PreviewMedia | null;
2074
- /**
2075
- * The status of the document.
2076
- */
2077
- _status?: {
2078
- /** The date of the last published edit */
2079
- lastEditedPublishedAt?: string;
2080
- /** The date of the last draft edit */
2081
- lastEditedDraftAt?: string;
2082
- };
2083
- }
2084
- /**
2085
- * Represents the current state of a preview value along with a flag indicating whether
2086
- * the preview data is still being fetched or is fully resolved.
2087
- *
2088
- * The tuple contains a preview value or null, and a boolean indicating if the data is
2089
- * pending. A `true` value means a fetch is ongoing; `false` indicates that the
2090
- * currently provided preview value is up-to-date.
2091
- *
2092
- * @public
2093
- */
2094
- type ValuePending<T> = {
2095
- data: T | null;
2096
- isPending: boolean;
2097
- };
2098
- /**
2099
- * @public
2100
- * @deprecated This interface is kept for backwards compatibility but is no longer used internally.
2101
- * Preview state is now stored in the projection store.
2102
- */
2103
- interface PreviewStoreState {
2104
- values: { [TDocumentId in string]?: ValuePending<PreviewValue> };
2105
- subscriptions: { [TDocumentId in string]?: { [TSubscriptionId in string]?: true } };
2106
- }
2107
- /**
2108
- * @beta
2109
- * @deprecated This type is deprecated and will be removed in a future release.
2110
- */
2111
- type GetPreviewStateOptions = DocumentHandle;
2112
- /**
2113
- * @beta
2114
- * @deprecated This function is deprecated and will be removed in a future release.
2115
- */
2116
- declare function getPreviewState<TResult extends object>(instance: SanityInstance, options: GetPreviewStateOptions): StateSource<ValuePending<TResult>>;
2117
- /**
2118
- * @beta
2119
- * @deprecated This function is deprecated and will be removed in a future release.
2120
- */
2121
- declare function getPreviewState(instance: SanityInstance, options: GetPreviewStateOptions): StateSource<ValuePending<PreviewValue>>;
2122
- /**
2123
- * Generates a GROQ projection for preview data without requiring a schema.
2124
- * Uses common field names to make educated guesses about which fields to use.
2125
- *
2126
- * @internal
2127
- */
2128
- declare const PREVIEW_PROJECTION: string;
2129
- /**
2130
- * Transforms a projection result (with titleCandidates, subtitleCandidates, media)
2131
- * into a PreviewValue (with title, subtitle, media).
2132
- *
2133
- * @param projectionResult - The raw projection result from GROQ
2134
- * @param instance - The Sanity instance to use for client configuration
2135
- * @param resource - Data resource for the preview
2136
- * @internal
2137
- */
2138
- declare function transformProjectionToPreview(instance: SanityInstance, projectionResult: PreviewQueryResult, resource?: DocumentResource): PreviewValue;
2139
- /**
2140
- * @beta
2141
- * @deprecated This type is deprecated and will be removed in a future release.
2142
- */
2143
- type ResolvePreviewOptions = DocumentHandle;
2144
- /**
2145
- * @beta
2146
- * @deprecated This function is deprecated and will be removed in a future release.
2147
- */
2148
- declare function resolvePreview(instance: SanityInstance, options: ResolvePreviewOptions): Promise<ValuePending<PreviewValue>>;
2149
- /** @public */
2150
- interface ProjectMemberRole {
2151
- name: string;
2152
- title: string;
2153
- description: string;
2154
- }
2155
- /** @public */
2156
- interface ProjectMember {
2157
- id: string;
2158
- createdAt: string;
2159
- updatedAt: string;
2160
- isCurrentUser: boolean;
2161
- isRobot: boolean;
2162
- roles: ProjectMemberRole[];
2163
- }
2164
- /** @public */
2165
- interface ProjectMetadata {
2166
- color?: string;
2167
- externalStudioHost?: string;
2168
- initialTemplate?: string;
2169
- cliInitializedAt?: string;
2170
- integration: 'manage' | 'cli';
2171
- }
2172
- /**
2173
- * The base fields returned from `/projects` for every project.
2174
- * @public
2175
- */
2176
- interface ProjectBase {
2177
- id: string;
2178
- displayName: string;
2179
- studioHost: string | null;
2180
- organizationId: string;
2181
- metadata: ProjectMetadata;
2182
- isBlocked: boolean;
2183
- isDisabled: boolean;
2184
- isDisabledByUser: boolean;
2185
- activityFeedEnabled: boolean;
2186
- createdAt: string;
2187
- updatedAt: string;
2188
- }
2189
- /**
2190
- * A `Project` with `members` and/or `features` conditionally included
2191
- * based on the query options used to fetch it.
2192
- * @public
2193
- */
2194
- type Project<IncludeMembers extends boolean = true, IncludeFeatures extends boolean = true> = ProjectBase & (boolean extends IncludeMembers ? {
2195
- members?: ProjectMember[];
2196
- } : IncludeMembers extends true ? {
2197
- members: ProjectMember[];
2198
- } : unknown) & (boolean extends IncludeFeatures ? {
2199
- features?: string[];
2200
- } : IncludeFeatures extends true ? {
2201
- features: string[];
2202
- } : unknown);
2203
- /** @public */
2204
- interface ProjectOptions<IncludeMembers extends boolean = true, IncludeFeatures extends boolean = true> extends ProjectHandle {
2205
- includeMembers?: IncludeMembers;
2206
- includeFeatures?: IncludeFeatures;
2207
- }
2208
- /**
2209
- * Public signature for the project state source. The conditional generics
2210
- * cannot flow through `BoundStoreAction`, so we declare the signature here
2211
- * and assign the (already-correct) runtime function to it.
2212
- */
2213
- type GetProjectState = <IncludeMembers extends boolean = true, IncludeFeatures extends boolean = true>(instance: SanityInstance, options?: ProjectOptions<IncludeMembers, IncludeFeatures>) => StateSource<Project<IncludeMembers, IncludeFeatures> | undefined>;
2214
- type ResolveProject = <IncludeMembers extends boolean = true, IncludeFeatures extends boolean = true>(instance: SanityInstance, options?: ProjectOptions<IncludeMembers, IncludeFeatures>) => Promise<Project<IncludeMembers, IncludeFeatures>>;
2215
- /** @public */
2216
- declare const getProjectState: GetProjectState;
2217
- /** @public */
2218
- declare const resolveProject: ResolveProject;
2219
- interface ProjectionOptions<TProjection extends string = string, TDocumentType extends string = string, TDataset extends string = string, TProjectId extends string = string> extends DocumentHandle<TDocumentType, TDataset, TProjectId> {
2220
- projection: TProjection;
2221
- }
2222
- /**
2223
- * @beta
2224
- */
2225
- 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>;
2226
- /**
2227
- * @beta
2228
- */
2229
- declare function getProjectionState<TData extends object>(instance: SanityInstance, options: ProjectionOptions): StateSource<ProjectionValuePending<TData> | undefined>;
2230
- /**
2231
- * @beta
2232
- */
2233
- declare function getProjectionState(instance: SanityInstance, options: ProjectionOptions): StateSource<ProjectionValuePending<Record<string, unknown>> | undefined>;
2234
- /** @beta */
2235
- 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}`>>>;
2236
- /** @beta */
2237
- declare function resolveProjection<TData extends object>(instance: SanityInstance, options: ProjectionOptions): Promise<ProjectionValuePending<TData>>;
2238
- /** @public */
2239
- interface ProjectsOptions<IncludeMembers extends boolean = false, IncludeFeatures extends boolean = true> {
2240
- organizationId?: string;
2241
- includeMembers?: IncludeMembers;
2242
- includeFeatures?: IncludeFeatures;
2243
- onlyExplicitMembership?: boolean;
2244
- }
2245
- /**
2246
- * Public signature for the projects state source. The conditional generics
2247
- * cannot flow through `BoundStoreAction`, so we declare the signature here
2248
- * and assign the (already-correct) runtime function to it.
2249
- */
2250
- type GetProjectsState = <IncludeMembers extends boolean = false, IncludeFeatures extends boolean = true>(instance: SanityInstance, options?: ProjectsOptions<IncludeMembers, IncludeFeatures>) => StateSource<Project<IncludeMembers, IncludeFeatures>[] | undefined>;
2251
- type ResolveProjects = <IncludeMembers extends boolean = false, IncludeFeatures extends boolean = true>(instance: SanityInstance, options?: ProjectsOptions<IncludeMembers, IncludeFeatures>) => Promise<Project<IncludeMembers, IncludeFeatures>[]>;
2252
- /** @public */
2253
- declare const getProjectsState: GetProjectsState;
2254
- /** @public */
2255
- declare const resolveProjects: ResolveProjects;
2256
- /**
2257
- * @beta
2258
- */
2259
- 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> {
2260
- query: TQuery;
2261
- params?: Record<string, unknown>;
2262
- }
2263
- /**
2264
- * @beta
2265
- */
2266
- interface ResolveQueryOptions<TQuery extends string = string, TDataset extends string = string, TProjectId extends string = string> extends QueryOptions<TQuery, TDataset, TProjectId> {
2267
- signal?: AbortSignal;
2268
- }
2269
- /** @beta */
2270
- declare const getQueryKey: (options: QueryOptions) => string;
2271
- /** @beta */
2272
- declare const parseQueryKey: (key: string) => QueryOptions;
2273
- /**
2274
- * Returns the state source for a query.
2275
- *
2276
- * This function returns a state source that represents the current result of a GROQ query.
2277
- * Subscribing to the state source will instruct the SDK to fetch the query (if not already fetched)
2278
- * and will keep the query live using the Live content API (considering sync tags) to provide up-to-date results.
2279
- * When the last subscriber is removed, the query state is automatically cleaned up from the store.
2280
- *
2281
- * Note: This functionality is for advanced users who want to build their own framework integrations.
2282
- * Our SDK also provides a React integration (useQuery hook) for convenient usage.
2283
- *
2284
- * Note: Automatic cleanup can interfere with React Suspense because if a component suspends while being the only subscriber,
2285
- * cleanup might occur unexpectedly. In such cases, consider using `resolveQuery` instead.
2286
- *
2287
- * @beta
2288
- */
2289
- 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>;
2290
- /** @beta */
2291
- declare function getQueryState<TData>(instance: SanityInstance, queryOptions: QueryOptions): StateSource<TData | undefined>;
2292
- /** @beta */
2293
- declare function getQueryState(instance: SanityInstance, queryOptions: QueryOptions): StateSource<unknown>;
2294
- /**
2295
- * Resolves the result of a query without registering a lasting subscriber.
2296
- *
2297
- * This function fetches the result of a GROQ query and returns a promise that resolves with the query result.
2298
- * Unlike `getQueryState`, which registers subscribers to keep the query live and performs automatic cleanup,
2299
- * `resolveQuery` does not track subscribers. This makes it ideal for use with React Suspense, where the returned
2300
- * promise is thrown to delay rendering until the query result becomes available.
2301
- * Once the promise resolves, it is expected that a real subscriber will be added via `getQueryState` to manage ongoing updates.
2302
- *
2303
- * Additionally, an optional AbortSignal can be provided to cancel the query and immediately clear the associated state
2304
- * if there are no active subscribers.
2305
- *
2306
- * @beta
2307
- */
2308
- 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}`>>;
2309
- /** @beta */
2310
- declare function resolveQuery<TData>(instance: SanityInstance, queryOptions: ResolveQueryOptions): Promise<TData>;
2311
- /**
2312
- * Lifecycle states a release document can be in. Mirrors the server's
2313
- * `ReleaseState`.
2314
- * @beta
2315
- */
2316
- type ReleaseState = 'active' | 'archiving' | 'unarchiving' | 'archived' | 'published' | 'publishing' | 'scheduled' | 'scheduling';
2317
- interface ReleasesStoreState {
2318
- activeReleases?: ReleaseDocument[];
2319
- allReleases?: ReleaseDocument[];
2320
- error?: unknown;
2321
- }
2322
- /**
2323
- * Get the active releases from the store.
2324
- * @internal
2325
- */
2326
- declare const getActiveReleasesState: (instance: SanityInstance, options?: {
2327
- resource?: DocumentResource;
2328
- }) => StateSource<ReleaseDocument[] | undefined>;
2329
- /**
2330
- * Get every release in the store, including archived and published.
2331
- * @internal
2332
- */
2333
- declare const getAllReleasesState: (instance: SanityInstance, options?: {
2334
- resource?: DocumentResource;
2335
- }) => StateSource<ReleaseDocument[] | undefined>;
2336
- declare const _getPerspectiveStateSelector: StoreAction<ReleasesStoreState, [_?: (PerspectiveHandle & {
2337
- projectId?: string;
2338
- dataset?: string;
2339
- resource?: DocumentResource;
2340
- }) | undefined], StateSource<string[] | "previewDrafts" | "published" | "drafts" | "raw" | undefined>, unknown>;
2341
- type OmitFirst<T extends unknown[]> = T extends [unknown, ...infer R] ? R : never;
2342
- type SelectorParams = OmitFirst<Parameters<typeof _getPerspectiveStateSelector>>;
2343
- type BoundGetPerspectiveState = BoundStoreAction<ReleasesStoreState, SelectorParams, ReturnType<typeof _getPerspectiveStateSelector>>;
2344
- /**
2345
- * Provides a subscribable state source for a "perspective" for the Sanity client,
2346
- * which is used to fetch documents as though certain Content Releases are active.
2347
- *
2348
- * @param instance - The Sanity instance to get the perspective for
2349
- * @param options - The options for the perspective -- usually a release name
2350
- *
2351
- * @returns A subscribable perspective value, usually a list of applicable release names,
2352
- * or a single release name / default perspective (such as 'drafts').
2353
- *
2354
- * @public
2355
- */
2356
- declare const getPerspectiveState: BoundGetPerspectiveState;
2357
- /** @internal */
2358
- declare const getUsersKey: (instance: SanityInstance, {
2359
- resourceType,
2360
- organizationId,
2361
- batchSize,
2362
- projectId,
2363
- userId
2364
- }?: GetUsersOptions) => string;
2365
- /** @internal */
2366
- declare const parseUsersKey: (key: string) => {
2367
- batchSize: number;
2368
- resourceType?: "organization" | "project";
2369
- projectId?: string;
2370
- organizationId?: string;
2371
- userId?: string;
2372
- };
2373
- /**
2374
- * Returns the state source for users associated with a specific resource.
2375
- *
2376
- * This function returns a state source that represents the current list of users for a given
2377
- * resource. Subscribing to the state source will instruct the SDK to fetch the users (if not
2378
- * already fetched) and will load more from this state source as well. When the last subscriber is
2379
- * removed, the users state is automatically cleaned up from the store after a delay.
2380
- *
2381
- * Note: This functionality is for advanced users who want to build their own framework
2382
- * integrations. Our SDK also provides a React integration for convenient usage.
2383
- *
2384
- * @beta
2385
- */
2386
- declare const getUsersState: BoundStoreAction<UsersStoreState, [options?: GetUsersOptions | undefined], StateSource<{
2387
- data: SanityUser[];
2388
- totalCount: number;
2389
- hasMore: boolean;
2390
- } | undefined>>;
2391
- /**
2392
- * Resolves the users for a specific resource without registering a lasting subscriber.
2393
- *
2394
- * This function fetches the users for a given resource and returns a promise that resolves with
2395
- * the users result. Unlike `getUsersState`, which registers subscribers to keep the data live and
2396
- * performs automatic cleanup, `resolveUsers` does not track subscribers. This makes it ideal for
2397
- * use with React Suspense, where the returned promise is thrown to delay rendering until the users
2398
- * result becomes available. Once the promise resolves, it is expected that a real subscriber will
2399
- * be added via `getUsersState` to manage ongoing updates.
2400
- *
2401
- * Additionally, an optional AbortSignal can be provided to cancel the request and immediately
2402
- * clear the associated state if there are no active subscribers.
2403
- *
2404
- * @beta
2405
- */
2406
- declare const resolveUsers: BoundStoreAction<UsersStoreState, [ResolveUsersOptions], Promise<{
2407
- data: SanityUser[];
2408
- totalCount: number;
2409
- hasMore: boolean;
2410
- }>>;
2411
- /**
2412
- * Loads more users for a specific resource.
2413
- *
2414
- * This function triggers a request to fetch the next page of users for a given resource. It
2415
- * requires that users have already been loaded for the resource (via `resolveUsers` or
2416
- * `getUsersState`), and that there are more users available to load (as indicated by the `hasMore`
2417
- * property).
2418
- *
2419
- * The function returns a promise that resolves when the next page of users has been loaded.
2420
- *
2421
- * @beta
2422
- */
2423
- declare const loadMoreUsers: BoundStoreAction<UsersStoreState, [options?: GetUsersOptions | undefined], Promise<{
2424
- data: SanityUser[];
2425
- totalCount: number;
2426
- hasMore: boolean;
2427
- }>>;
2428
- /**
2429
- * @beta
2430
- */
2431
- declare const getUserState: BoundStoreAction<UsersStoreState, [GetUserOptions], Observable<SanityUser | undefined>>;
2432
- /**
2433
- * @beta
2434
- */
2435
- declare const resolveUser: BoundStoreAction<UsersStoreState, [ResolveUserOptions], Promise<SanityUser>>;
2436
- interface StoreEntry<TParams extends unknown[], TData> {
2437
- params: TParams;
2438
- instance: SanityInstance;
2439
- key: string;
2440
- data?: TData;
2441
- error?: unknown;
2442
- subscriptions: string[];
2443
- lastFetchInitiatedAt?: string;
2444
- }
2445
- /**
2446
- * Internal helper type
2447
- * @public
2448
- */
2449
- interface FetcherStoreState<TParams extends unknown[], TData> {
2450
- stateByParams: { [TSerializedKey in string]?: StoreEntry<TParams, TData> };
2451
- error?: unknown;
2452
- }
2453
- /**
2454
- * Internal helper type
2455
- * @public
2456
- */
2457
- interface FetcherStore<TParams extends unknown[], TData> {
2458
- getState: BoundStoreAction<FetcherStoreState<TParams, TData>, TParams, StateSource<TData | undefined>>;
2459
- resolveState: BoundStoreAction<FetcherStoreState<TParams, TData>, TParams, Promise<TData>>;
2460
- }
2461
- /**
2462
- * Creates a GROQ search filter string (`[@] match text::query("...")`)
2463
- * from a raw search query string.
2464
- *
2465
- * It applies wildcard ('*') logic to the last eligible token and escapes
2466
- * double quotes within the search term.
2467
- *
2468
- * If the input query is empty or only whitespace, it returns an empty string.
2469
- *
2470
- * @param query - The raw input search string.
2471
- * @returns The GROQ search filter string, or an empty string.
2472
- * @internal
2473
- */
2474
- declare function createGroqSearchFilter(query: string): string;
2475
- /**
2476
- * Filter criteria for intent matching. Can be combined to create more specific intents.
2477
- *
2478
- * @example
2479
- * ```typescript
2480
- * // matches only geopoints in the travel-project project, production dataset
2481
- * const filter: IntentFilter = {
2482
- * projectId: 'travel-project',
2483
- * dataset: 'production',
2484
- * types: ['geopoint']
2485
- * }
2486
- *
2487
- * // matches all documents in the travel-project project
2488
- * const filter: IntentFilter = {
2489
- * projectId: 'travel-project',
2490
- * types: ['*']
2491
- * }
2492
- *
2493
- * // matches geopoints in the travel-project production dataset and map pins in all projects in the org
2494
- * const filters: IntentFilter[] = [
2495
- * {
2496
- * projectId: 'travel-project',
2497
- * dataset: 'production',
2498
- * types: ['geopoint']
2499
- * },
2500
- * {
2501
- * types: ['map-pin']
2502
- * }
2503
- * ]
2504
- * ```
2505
- * @public
2506
- */
2507
- interface IntentFilter {
2508
- /**
2509
- * Project ID to match against
2510
- * @remarks When specified, the intent will only match for the specified project.
2511
- */
2512
- projectId?: string;
2513
- /**
2514
- * Dataset to match against
2515
- * @remarks When specified, the intent will only match for the specified dataset. Requires projectId to be specified.
2516
- */
2517
- dataset?: string;
2518
- /**
2519
- * Document types that this intent can handle
2520
- * @remarks This is required for all filters. Use ['*'] to match all document types.
2521
- */
2522
- types: string[];
2523
- }
2524
- /**
2525
- * Intent definition structure for registering user intents
2526
- * @public
2527
- */
2528
- interface Intent {
2529
- /**
2530
- * Unique identifier for this intent
2531
- * @remarks Should be unique across all registered intents in an org for proper matching
2532
- */
2533
- id: string;
2534
- /**
2535
- * The action that this intent performs
2536
- * @remarks Examples: "view", "edit", "create", "delete"
2537
- */
2538
- action: 'view' | 'edit' | 'create' | 'delete';
2539
- /**
2540
- * Human-readable title for this intent
2541
- * @remarks Used for display purposes in UI or logs
2542
- */
2543
- title: string;
2544
- /**
2545
- * Detailed description of what this intent does
2546
- * @remarks Helps users understand the purpose and behavior of the intent
2547
- */
2548
- description?: string;
2549
- /**
2550
- * Array of filter criteria for intent matching
2551
- * @remarks At least one filter is required. Use `{types: ['*']}` to match everything
2552
- */
2553
- filters: IntentFilter[];
2554
- }
2555
- /**
2556
- * Creates a properly typed intent definition for registration with the backend.
2557
- *
2558
- * This utility function provides TypeScript support and validation for intent declarations.
2559
- * It is also used in the CLI if intents are declared as bare objects in an intents file.
2560
- *
2561
- * @param intent - The intent definition object
2562
- * @returns The same intent object with proper typing
2563
- *
2564
- * @example
2565
- * ```typescript
2566
- * // Specific filter for a document type
2567
- * const viewGeopointInMapApp = defineIntent({
2568
- * id: 'viewGeopointInMapApp',
2569
- * action: 'view',
2570
- * title: 'View a geopoint in the map app',
2571
- * description: 'This lets you view a geopoint in the map app',
2572
- * filters: [
2573
- * {
2574
- * projectId: 'travel-project',
2575
- * dataset: 'production',
2576
- * types: ['geopoint']
2577
- * }
2578
- * ]
2579
- * })
2580
- *
2581
- * export default viewGeopointInMapApp
2582
- * ```
2583
- *
2584
- * If your intent is asynchronous, resolve the promise before defining / returning the intent
2585
- * ```typescript
2586
- * async function createAsyncIntent() {
2587
- * const currentProject = await asyncProjectFunction()
2588
- * const currentDataset = await asyncDatasetFunction()
2589
- *
2590
- * return defineIntent({
2591
- * id: 'dynamicIntent',
2592
- * action: 'view',
2593
- * title: 'Dynamic Intent',
2594
- * description: 'Intent with dynamically resolved values',
2595
- * filters: [
2596
- * {
2597
- * projectId: currentProject, // Resolved value
2598
- * dataset: currentDataset, // Resolved value
2599
- * types: ['document']
2600
- * }
2601
- * ]
2602
- * })
2603
- * }
2604
- *
2605
- * const intent = await createAsyncIntent()
2606
- * export default intent
2607
- * ```
2608
- *
2609
- * @public
2610
- */
2611
- declare function defineIntent(intent: Intent): Intent;
2612
- /**
2613
- * @public
2614
- * Extracts the project ID from a CorsOriginError message.
2615
- * @param error - The error to extract the project ID from.
2616
- * @returns The project ID or null if the error is not a CorsOriginError.
2617
- */
2618
- declare function getCorsErrorProjectId(error: Error): string | null;
2619
- /**
2620
- * Returns true when the given error looks like a dynamic-import or
2621
- * code-split chunk-loading failure.
2622
- *
2623
- * These errors typically surface when a user has a tab open against a
2624
- * previously-deployed version of an app and the JavaScript or CSS chunk
2625
- * filenames have since changed: a fresh deployment removes the hashed assets
2626
- * the open tab still references. Detecting them lets the SDK trigger an
2627
- * automatic reload so the user gets the new build without manual intervention.
2628
- *
2629
- * Recognized shapes (webpack ChunkLoadError, Vite "Failed to fetch
2630
- * dynamically imported module", Firefox "error loading dynamically imported
2631
- * module", Safari "Importing a module script failed", and Vite "Unable to
2632
- * preload CSS").
2633
- *
2634
- * @param error - The value to inspect. Anything that is not an Error
2635
- * instance returns false.
2636
- * @returns True if the error matches a known import/chunk-load failure.
2637
- *
2638
- * @public
2639
- */
2640
- declare function isImportError(error: unknown): boolean;
2641
- /**
2642
- * This version is provided by pkg-utils at build time
2643
- * @internal
2644
- */
2645
- declare const CORE_SDK_VERSION: {};
2646
- /**
2647
- * @public
2648
- */
2649
- type SanityProject$1 = SanityProject;
2650
- /**
2651
- * Represents the various states the authentication can be in.
2652
- *
2653
- * @public
2654
- */
2655
- type AuthState = LoggedInAuthState | LoggedOutAuthState | LoggingInAuthState | ErrorAuthState;
2656
- /**
2657
- * Logged-in state from the auth state.
2658
- * @public
2659
- */
2660
- type LoggedInAuthState = {
2661
- type: AuthStateType.LOGGED_IN;
2662
- token: string;
2663
- currentUser: CurrentUser | null;
2664
- lastTokenRefresh?: number;
2665
- };
2666
- /**
2667
- * Logged-out state from the auth state.
2668
- * @public
2669
- */
2670
- type LoggedOutAuthState = {
2671
- type: AuthStateType.LOGGED_OUT;
2672
- isDestroyingSession: boolean;
2673
- };
2674
- /**
2675
- * Logging-in state from the auth state.
2676
- * @public
2677
- */
2678
- type LoggingInAuthState = {
2679
- type: AuthStateType.LOGGING_IN;
2680
- isExchangingToken: boolean;
2681
- };
2682
- /**
2683
- * Error state from the auth state.
2684
- * @public
2685
- */
2686
- type ErrorAuthState = {
2687
- type: AuthStateType.ERROR;
2688
- error: unknown;
2689
- };
2690
- /**
2691
- * Represents the various states the authentication can be in.
2692
- *
2693
- * @public
2694
- */
2695
- interface DashboardContext {
2696
- mode?: string;
2697
- env?: string;
2698
- orgId?: string;
2699
- }
2700
- /**
2701
- * The method of authentication used.
2702
- * @internal
2703
- */
2704
- type AuthMethodOptions = 'localstorage' | 'cookie' | undefined;
2705
- /**
2706
- * @public
2707
- */
2708
- interface AuthStoreState {
2709
- authState: AuthState;
2710
- providers?: AuthProvider[];
2711
- options: {
2712
- initialLocationHref: string;
2713
- clientFactory: (config: ClientConfig) => SanityClient;
2714
- customProviders: AuthConfig['providers'];
2715
- storageKey: string;
2716
- storageArea: Storage | undefined;
2717
- apiHost: string | undefined;
2718
- loginUrl: string;
2719
- callbackUrl: string | undefined;
2720
- providedToken: string | undefined;
2721
- authMethod: AuthMethodOptions;
2722
- };
2723
- dashboardContext?: DashboardContext;
2724
- }
2725
- /**
2726
- * @public
2727
- */
2728
- declare const getCurrentUserState: BoundStoreAction<AuthStoreState, [], StateSource<CurrentUser | null>>;
2729
- /**
2730
- * @public
2731
- */
2732
- declare const getTokenState: BoundStoreAction<AuthStoreState, [], StateSource<string | null>>;
2733
- /**
2734
- * @public
2735
- */
2736
- declare const getLoginUrlState: BoundStoreAction<AuthStoreState, [], StateSource<string>>;
2737
- /**
2738
- * @public
2739
- */
2740
- declare const getAuthState: BoundStoreAction<AuthStoreState, [], StateSource<AuthState>>;
2741
- /**
2742
- * @public
2743
- */
2744
- declare const getDashboardOrganizationId: BoundStoreAction<AuthStoreState, [], StateSource<string | undefined>>;
2745
- /**
2746
- * Returns a state source indicating if the SDK is running within a dashboard context.
2747
- * @public
2748
- */
2749
- declare const getIsInDashboardState: BoundStoreAction<AuthStoreState, [], StateSource<boolean>>;
2750
- /**
2751
- * Action to explicitly set the authentication token.
2752
- * Used internally by the Comlink token refresh.
2753
- * @internal
2754
- */
2755
- declare const setAuthToken: BoundStoreAction<AuthStoreState, [token: string | null], void>;
2756
- /** @internal */
2757
- type ApiErrorBody = {
2758
- error?: {
2759
- type?: string;
2760
- description?: string;
2761
- };
2762
- type?: string;
2763
- description?: string;
2764
- message?: string;
2765
- };
2766
- /** @internal Extracts the structured API error body from a ClientError, if present. */
2767
- declare function getClientErrorApiBody(error: ClientError): ApiErrorBody | undefined;
2768
- /** @internal Returns the error type string from an API error body, if available. */
2769
- declare function getClientErrorApiType(error: ClientError): string | undefined;
2770
- /** @internal Returns the error description string from an API error body, if available. */
2771
- declare function getClientErrorApiDescription(error: ClientError): string | undefined;
2772
- /** @internal True if the error represents a projectUserNotFoundError. */
2773
- declare function isProjectUserNotFoundClientError(error: ClientError): boolean;
2774
- 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 };