@sanity/sdk 2.0.2 → 2.1.1-canary.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.
package/dist/index.d.ts CHANGED
@@ -1,2647 +1,1960 @@
1
- import {AuthStoreState as AuthStoreState_2} from './authStore'
2
- import {BoundStoreAction} from '../store/createActionBinder'
3
- import {BoundStoreAction as BoundStoreAction_2} from '../../store/createActionBinder'
4
- import {CanvasResource} from '@sanity/message-protocol'
5
- import {ChannelInput} from '@sanity/comlink'
6
- import {ChannelInstance} from '@sanity/comlink'
7
- import {ClientConfig} from '@sanity/client'
8
- import {ClientPerspective} from '@sanity/client'
9
- import {Controller} from '@sanity/comlink'
10
- import {CurrentUser} from '@sanity/types'
11
- import {DatasetsResponse} from '@sanity/client'
12
- import {DocumentPermissionsResult as DocumentPermissionsResult_2} from './permissions'
13
- import {FetcherStoreState as FetcherStoreState_2} from '../_exports'
14
- import {IndexTuple} from '@sanity/types'
15
- import {ListenEvent} from '@sanity/client'
16
- import {MediaResource} from '@sanity/message-protocol'
17
- import {Message} from '@sanity/comlink'
18
- import {Mutation} from '@sanity/types'
19
- import {Node as Node_2} from '@sanity/comlink'
20
- import {NodeInput} from '@sanity/comlink'
21
- import {Observable} from 'rxjs'
22
- import {PatchMutation} from '@sanity/mutate/_unstable_store'
23
- import {PatchOperations} from '@sanity/types'
24
- import {PathSegment} from '@sanity/types'
25
- import {PreviewStoreState as PreviewStoreState_2} from './previewStore'
26
- import {ResponseQueryOptions} from '@sanity/client'
27
- import {Role} from '@sanity/types'
28
- import {SanityClient} from '@sanity/client'
29
- import {SanityDocument} from '@sanity/types'
30
- import {SanityDocument as SanityDocument_2} from 'groq'
31
- import {SanityDocument as SanityDocument_3} from '@sanity/client'
32
- import {SanityDocumentLike} from '@sanity/types'
33
- import {SanityProject as SanityProject_2} from '@sanity/client'
34
- import {SanityProjectionResult} from 'groq'
35
- import {SanityQueryResult} from 'groq'
36
- import {SanityUser as SanityUser_2} from './types'
37
- import {StackablePerspective} from '@sanity/client'
38
- import {StateSource as StateSource_2} from '../_exports'
39
- import {StateSource as StateSource_3} from '../../_exports'
40
- import {Status} from '@sanity/comlink'
41
- import {StudioResource} from '@sanity/message-protocol'
42
- import {Subject} from 'rxjs'
43
- import {ValuePending as ValuePending_2} from './previewStore'
44
-
45
- declare interface AccessAttributeNode extends BaseNode {
46
- type: 'AccessAttribute'
47
- base?: ExprNode
48
- name: string
49
- }
50
-
51
- declare interface AccessElementNode extends BaseNode {
52
- type: 'AccessElement'
53
- base: ExprNode
54
- index: number
55
- }
56
-
1
+ import * as _sanity_client12 from "@sanity/client";
2
+ import { ClientConfig, ClientPerspective, ListenEvent, ResponseQueryOptions, SanityClient, SanityDocument as SanityDocument$1, SanityProject as SanityProject$1, StackablePerspective } from "@sanity/client";
3
+ import { Observable, Subject } from "rxjs";
4
+ import { CurrentUser, CurrentUser as CurrentUser$1, Mutation, PatchOperations, Role, SanityDocument, SanityDocument as SanityDocument$2, SanityDocumentLike } from "@sanity/types";
5
+ import * as _sanity_comlink3 from "@sanity/comlink";
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$3, SanityProjectionResult, SanityQueryResult } from "groq";
9
+ import { CanvasResource, MediaResource, StudioResource } from "@sanity/message-protocol";
10
+ import { getIndexForKey, getPathDepth, joinPaths, jsonMatch, slicePath, stringifyPath } from "@sanity/json-match";
57
11
  /**
58
- * @beta
59
- * Event emitted when a precondition to applying an action fails.
60
- * (For example: when trying to edit a document that no longer exists.)
12
+ * Represents the various states the authentication type can be in.
13
+ *
14
+ * @public
61
15
  */
62
- export declare interface ActionErrorEvent {
63
- type: 'error'
64
- documentId: string
65
- transactionId: string
66
- message: string
67
- error: unknown
68
- }
69
-
70
- declare type ActionMap = {
71
- create: 'sanity.action.document.version.create'
72
- discard: 'sanity.action.document.version.discard'
73
- unpublish: 'sanity.action.document.unpublish'
74
- delete: 'sanity.action.document.delete'
75
- edit: 'sanity.action.document.edit'
76
- publish: 'sanity.action.document.publish'
77
- }
78
-
79
- /** @beta */
80
- export declare interface ActionsResult<TDocument extends SanityDocument_2 = SanityDocument_2> {
81
- transactionId: string
82
- documents: DocumentSet<TDocument>
83
- previous: DocumentSet<TDocument>
84
- previousRevs: {
85
- [documentId: string]: string | undefined
86
- }
87
- appeared: string[]
88
- updated: string[]
89
- disappeared: string[]
90
- submitted: () => ReturnType<SanityClient['action']>
91
- }
92
-
93
- declare type AllowedClientConfigKey =
94
- | 'useCdn'
95
- | 'token'
96
- | 'perspective'
97
- | 'apiHost'
98
- | 'proxy'
99
- | 'withCredentials'
100
- | 'timeout'
101
- | 'maxRetries'
102
- | 'dataset'
103
- | 'projectId'
104
- | 'requestTagPrefix'
105
- | 'useProjectHostname'
106
-
107
- declare interface AndNode extends BaseNode {
108
- type: 'And'
109
- left: ExprNode
110
- right: ExprNode
16
+ declare enum AuthStateType {
17
+ LOGGED_IN = "logged-in",
18
+ LOGGING_IN = "logging-in",
19
+ ERROR = "error",
20
+ LOGGED_OUT = "logged-out",
111
21
  }
112
-
113
- declare type AnyStaticValue =
114
- | StringValue
115
- | NumberValue
116
- | NullValue
117
- | BooleanValue
118
- | DateTimeValue
119
- | ObjectValue
120
- | ArrayValue
121
- | PathValue
122
-
123
22
  /**
124
- * Represents a transaction that has been applied locally but has not been
125
- * committed/transitioned-to-outgoing. These transactions are visible to the
126
- * user but may be rebased upon a new working document set. Applied transactions
127
- * also contain the resulting `outgoingActions` that will be submitted to
128
- * Content Lake. These `outgoingActions` depend on the state of the working
129
- * documents so they are recomputed on rebase and are only relevant to applied
130
- * actions (we cannot compute `outgoingActions` for queued transactions because
131
- * we haven't resolved the set of documents the actions are dependent on yet).
132
- *
133
- * In order to support better conflict resolution, the original `previous` set
134
- * is saved as the `base` set.
23
+ * Configuration for an authentication provider
24
+ * @public
135
25
  */
136
- declare interface AppliedTransaction extends QueuedTransaction {
137
- /**
138
- * the resulting set of documents after the actions have been applied
139
- */
140
- working: DocumentSet
141
- /**
142
- * the previous set of documents before the action was applied
143
- */
144
- previous: DocumentSet
145
- /**
146
- * the original `previous` document set captured when this action was
147
- * originally applied. this is used as a reference point to do a 3-way merge
148
- * if this applied transaction ever needs to be reapplied on a different
149
- * set of documents.
150
- */
151
- base: DocumentSet
152
- /**
153
- * the `_rev`s from `previous` document set
154
- */
155
- previousRevs: {
156
- [TDocumentId in string]?: string
157
- }
158
- /**
159
- * a timestamp for when this transaction was applied locally
160
- */
161
- timestamp: string
26
+ interface AuthProvider {
162
27
  /**
163
- * the resulting HTTP actions derived from the state of the `working` document
164
- * set. these are sent to Content Lake as-is when this transaction is batched
165
- * and transitioned into an outgoing transaction.
28
+ * Unique identifier for the auth provider (e.g., 'google', 'github')
166
29
  */
167
- outgoingActions: HttpAction[]
30
+ name: string;
168
31
  /**
169
- * similar to `outgoingActions` but comprised of mutations instead of action.
170
- * this left here for debugging purposes but could be used to send mutations
171
- * to Content Lake instead of actions.
32
+ * Display name for the auth provider in the UI
172
33
  */
173
- outgoingMutations: Mutation[]
174
- }
175
-
176
- /** @beta */
177
- export declare function applyDocumentActions<
178
- TDocumentType extends string = string,
179
- TDataset extends string = string,
180
- TProjectId extends string = string,
181
- >(
182
- instance: SanityInstance,
183
- action:
184
- | DocumentAction<TDocumentType, TDataset, TProjectId>
185
- | DocumentAction<TDocumentType, TDataset, TProjectId>[],
186
- options?: ApplyDocumentActionsOptions,
187
- ): Promise<ActionsResult<SanityDocument_2<TDocumentType, `${TProjectId}.${TDataset}`>>>
188
-
189
- /** @beta */
190
- export declare function applyDocumentActions(
191
- instance: SanityInstance,
192
- action: DocumentAction | DocumentAction[],
193
- options?: ApplyDocumentActionsOptions,
194
- ): Promise<ActionsResult>
195
-
196
- /** @beta */
197
- export declare interface ApplyDocumentActionsOptions {
34
+ title: string;
198
35
  /**
199
- * Optionally provide an ID to be used as this transaction ID
36
+ * Complete authentication URL including callback and token parameters
200
37
  */
201
- transactionId?: string
38
+ url: string;
202
39
  /**
203
- * Set this to true to prevent this action from being batched with others.
40
+ * Optional URL for direct sign-up flow
204
41
  */
205
- disableBatching?: boolean
206
- }
207
-
208
- declare interface ArrayCoerceNode extends BaseNode {
209
- type: 'ArrayCoerce'
210
- base: ExprNode
211
- }
212
-
213
- declare interface ArrayElementNode extends BaseNode {
214
- type: 'ArrayElement'
215
- value: ExprNode
216
- isSplat: boolean
217
- }
218
-
219
- declare interface ArrayNode extends BaseNode {
220
- type: 'Array'
221
- elements: ArrayElementNode[]
222
- }
223
-
224
- declare type ArrayValue = StaticValue<unknown[], 'array'>
225
-
226
- declare interface AscNode extends BaseNode {
227
- type: 'Asc'
228
- base: ExprNode
42
+ signUpUrl?: string;
229
43
  }
230
-
231
44
  /**
232
45
  * Configuration options for creating an auth store.
233
46
  *
234
47
  * @public
235
48
  */
236
- export declare interface AuthConfig {
49
+ interface AuthConfig {
237
50
  /**
238
51
  * The initial location href to use when handling auth callbacks.
239
52
  * Defaults to the current window location if available.
240
53
  */
241
- initialLocationHref?: string
54
+ initialLocationHref?: string;
242
55
  /**
243
56
  * Factory function to create a SanityClient instance.
244
57
  * Defaults to the standard Sanity client factory if not provided.
245
58
  */
246
- clientFactory?: (config: ClientConfig) => SanityClient
59
+ clientFactory?: (config: ClientConfig) => SanityClient;
247
60
  /**
248
61
  * Custom authentication providers to use instead of or in addition to the default ones.
249
62
  * Can be an array of providers or a function that takes the default providers and returns
250
63
  * a modified array or a Promise resolving to one.
251
64
  */
252
- providers?: AuthProvider[] | ((prev: AuthProvider[]) => AuthProvider[] | Promise<AuthProvider[]>)
65
+ providers?: AuthProvider[] | ((prev: AuthProvider[]) => AuthProvider[] | Promise<AuthProvider[]>);
253
66
  /**
254
67
  * The API hostname for requests. Usually leave this undefined, but it can be set
255
68
  * if using a custom domain or CNAME for the API endpoint.
256
69
  */
257
- apiHost?: string
70
+ apiHost?: string;
258
71
  /**
259
72
  * Storage implementation to persist authentication state.
260
73
  * Defaults to `localStorage` if available.
261
74
  */
262
- storageArea?: Storage
75
+ storageArea?: Storage;
263
76
  /**
264
77
  * A callback URL for your application.
265
78
  * If none is provided, the auth API will redirect back to the current location (`location.href`).
266
79
  * When handling callbacks, this URL's pathname is checked to ensure it matches the callback.
267
80
  */
268
- callbackUrl?: string
81
+ callbackUrl?: string;
269
82
  /**
270
83
  * A static authentication token to use instead of handling the OAuth flow.
271
84
  * When provided, the auth store will remain in a logged-in state with this token,
272
85
  * ignoring any storage or callback handling.
273
86
  */
274
- token?: string
87
+ token?: string;
275
88
  }
276
-
277
- declare type AuthMethodOptions = 'localstorage' | 'cookie' | undefined
278
-
279
89
  /**
280
- * Configuration for an authentication provider
90
+ * Represents the minimal configuration required to identify a Sanity project.
281
91
  * @public
282
92
  */
283
- export declare interface AuthProvider {
284
- /**
285
- * Unique identifier for the auth provider (e.g., 'google', 'github')
286
- */
287
- name: string
288
- /**
289
- * Display name for the auth provider in the UI
290
- */
291
- title: string
292
- /**
293
- * Complete authentication URL including callback and token parameters
294
- */
295
- url: string
296
- /**
297
- * Optional URL for direct sign-up flow
298
- */
299
- signUpUrl?: string
93
+ interface ProjectHandle<TProjectId extends string = string> {
94
+ projectId?: TProjectId;
300
95
  }
301
-
302
96
  /**
303
- * Represents the various states the authentication can be in.
304
- *
305
97
  * @public
306
98
  */
307
- export declare type AuthState =
308
- | LoggedInAuthState
309
- | LoggedOutAuthState
310
- | LoggingInAuthState
311
- | ErrorAuthState
312
-
99
+ type ReleasePerspective = {
100
+ releaseName: string;
101
+ excludedPerspectives?: StackablePerspective[];
102
+ };
313
103
  /**
314
- * Represents the various states the authentication type can be in.
315
- *
316
104
  * @public
317
105
  */
318
- export declare enum AuthStateType {
319
- LOGGED_IN = 'logged-in',
320
- LOGGING_IN = 'logging-in',
321
- ERROR = 'error',
322
- LOGGED_OUT = 'logged-out',
106
+ interface PerspectiveHandle {
107
+ perspective?: ClientPerspective | ReleasePerspective;
323
108
  }
324
-
325
109
  /**
326
110
  * @public
327
111
  */
328
- export declare interface AuthStoreState {
329
- authState: AuthState
330
- providers?: AuthProvider[]
331
- options: {
332
- initialLocationHref: string
333
- clientFactory: (config: ClientConfig) => SanityClient
334
- customProviders: AuthConfig['providers']
335
- storageKey: string
336
- storageArea: Storage | undefined
337
- apiHost: string | undefined
338
- loginUrl: string
339
- callbackUrl: string | undefined
340
- providedToken: string | undefined
341
- authMethod: AuthMethodOptions
342
- }
343
- dashboardContext?: DashboardContext
112
+ interface DatasetHandle<TDataset extends string = string, TProjectId extends string = string> extends ProjectHandle<TProjectId>, PerspectiveHandle {
113
+ dataset?: TDataset;
344
114
  }
345
-
346
- /** The base interface for SyntaxNode. */
347
- declare interface BaseNode {
348
- type: string
115
+ /**
116
+ * Identifies a specific document type within a Sanity dataset and project.
117
+ * Includes `projectId`, `dataset`, and `documentType`.
118
+ * Optionally includes a `documentId`, useful for referencing a specific document type context, potentially without a specific document ID.
119
+ * @public
120
+ */
121
+ interface DocumentTypeHandle<TDocumentType extends string = string, TDataset extends string = string, TProjectId extends string = string> extends DatasetHandle<TDataset, TProjectId> {
122
+ documentId?: string;
123
+ documentType: TDocumentType;
349
124
  }
350
-
351
- declare type BooleanValue = StaticValue<boolean, 'boolean'>
352
-
353
125
  /**
354
- * Represents a store action that has been bound to a specific store instance
126
+ * Uniquely identifies a specific document within a Sanity dataset and project.
127
+ * Includes `projectId`, `dataset`, `documentType`, and the required `documentId`.
128
+ * Commonly used by document-related hooks and components to reference a document without fetching its full content initially.
129
+ * @public
355
130
  */
356
- declare type BoundStoreAction_3<_TState, TParams extends unknown[], TReturn> = (
357
- instance: SanityInstance,
358
- ...params: TParams
359
- ) => TReturn
360
-
131
+ interface DocumentHandle<TDocumentType extends string = string, TDataset extends string = string, TProjectId extends string = string> extends DocumentTypeHandle<TDocumentType, TDataset, TProjectId> {
132
+ documentId: string;
133
+ }
361
134
  /**
362
- * Individual channel with its relevant options
135
+ * Represents the complete configuration for a Sanity SDK instance
363
136
  * @public
364
137
  */
365
- declare interface ChannelEntry {
366
- channel: ChannelInstance<FrameMessage, WindowMessage>
367
- options: ChannelInput
368
- refCount: number
138
+ interface SanityConfig extends DatasetHandle, PerspectiveHandle {
139
+ /**
140
+ * Authentication configuration for the instance
141
+ * @remarks Merged with parent configurations when using createChild
142
+ */
143
+ auth?: AuthConfig;
144
+ /**
145
+ * Studio mode configuration for use of the SDK in a Sanity Studio
146
+ * @remarks Controls whether studio mode features are enabled
147
+ */
148
+ studioMode?: {
149
+ enabled: boolean;
150
+ };
369
151
  }
370
-
371
152
  /**
372
- * Options used when retrieving a client instance from the client store.
373
- *
374
- * This interface extends the base {@link ClientConfig} and adds:
375
- *
376
- * - **apiVersion:** A required string indicating the API version for the client.
377
- * - **scope:** An optional flag to choose between the project-specific client
378
- * ('project') and the global client ('global'). When set to `'global'`, the
379
- * global client is used.
380
- *
381
- * These options are utilized by `getClient` and `getClientState` to configure and
382
- * return appropriate client instances that automatically handle authentication
383
- * updates and configuration changes.
153
+ * Represents a Sanity.io resource instance with its own configuration and lifecycle
154
+ * @remarks Instances form a hierarchy through parent/child relationships
384
155
  *
385
156
  * @public
386
157
  */
387
- export declare interface ClientOptions extends Pick<ClientConfig, AllowedClientConfigKey> {
158
+ interface SanityInstance {
388
159
  /**
389
- * An optional flag to choose between the default client (typically project-level)
390
- * and the global client ('global'). When set to `'global'`, the global client
391
- * is used.
160
+ * Unique identifier for this instance
161
+ * @remarks Generated using crypto.randomUUID()
392
162
  */
393
- 'scope'?: 'default' | 'global'
163
+ readonly instanceId: string;
394
164
  /**
395
- * A required string indicating the API version for the client.
165
+ * Resolved configuration for this instance
166
+ * @remarks Merges values from parent instances where appropriate
396
167
  */
397
- 'apiVersion': string
168
+ readonly config: SanityConfig;
398
169
  /**
399
- * @internal
170
+ * Checks if the instance has been disposed
171
+ * @returns true if dispose() has been called
172
+ */
173
+ isDisposed(): boolean;
174
+ /**
175
+ * Disposes the instance and cleans up associated resources
176
+ * @remarks Triggers all registered onDispose callbacks
177
+ */
178
+ dispose(): void;
179
+ /**
180
+ * Registers a callback to be invoked when the instance is disposed
181
+ * @param cb - Callback to execute on disposal
182
+ * @returns Function to unsubscribe the callback
183
+ */
184
+ onDispose(cb: () => void): () => void;
185
+ /**
186
+ * Gets the parent instance in the hierarchy
187
+ * @returns Parent instance or undefined if this is the root
188
+ */
189
+ getParent(): SanityInstance | undefined;
190
+ /**
191
+ * Creates a child instance with merged configuration
192
+ * @param config - Configuration to merge with parent values
193
+ * @remarks Child instances inherit parent configuration but can override values
194
+ */
195
+ createChild(config: SanityConfig): SanityInstance;
196
+ /**
197
+ * Traverses the instance hierarchy to find the first instance whose configuration
198
+ * matches the given target config using a shallow comparison.
199
+ * @param targetConfig - A partial configuration object containing key-value pairs to match.
200
+ * @returns The first matching instance or undefined if no match is found.
400
201
  */
401
- '~experimental_resource'?: ClientConfig['~experimental_resource']
202
+ match(targetConfig: Partial<SanityConfig>): SanityInstance | undefined;
402
203
  }
403
-
404
204
  /**
405
- * States tracked by the client store
205
+ * Creates a new Sanity resource instance
206
+ * @param config - Configuration for the instance (optional)
207
+ * @returns A configured SanityInstance
208
+ * @remarks When creating child instances, configurations are merged with parent values
209
+ *
406
210
  * @public
407
211
  */
408
- export declare interface ClientState {
409
- token: string | null
410
- clients: {
411
- [TKey in string]?: SanityClient
412
- }
413
- authMethod?: 'localstorage' | 'cookie'
414
- }
415
-
212
+ declare function createSanityInstance(config?: SanityConfig): SanityInstance;
416
213
  /**
417
- * Internal state tracking comlink connections
214
+ * Represents a store action that has been bound to a specific store instance
215
+ */
216
+ type BoundStoreAction<_TState, TParams extends unknown[], TReturn> = (instance: SanityInstance, ...params: TParams) => TReturn;
217
+ /**
218
+ * Creates an action binder function that uses the provided key function
219
+ * to determine how store instances are shared between Sanity instances
220
+ *
221
+ * @param keyFn - Function that generates a key from a Sanity config
222
+ * @returns A function that binds store actions to Sanity instances
223
+ *
224
+ * @remarks
225
+ * Action binders determine how store instances are shared across multiple
226
+ * Sanity instances. The key function determines which instances share state.
227
+ *
228
+ * @example
229
+ * ```ts
230
+ * // Create a custom binder that uses a tenant ID for isolation
231
+ * const bindActionByTenant = createActionBinder(config => config.tenantId || 'default')
232
+ *
233
+ * // Use the custom binder with a store definition
234
+ * const getTenantUsers = bindActionByTenant(
235
+ * userStore,
236
+ * ({state}) => state.get().users
237
+ * )
238
+ * ```
239
+ */
240
+ /**
241
+ * Represents the various states the authentication can be in.
242
+ *
418
243
  * @public
419
244
  */
420
- export declare interface ComlinkControllerState {
421
- controller: Controller | null
422
- controllerOrigin: string | null
423
- channels: Map<string, ChannelEntry>
424
- }
425
-
245
+ type AuthState = LoggedInAuthState | LoggedOutAuthState | LoggingInAuthState | ErrorAuthState;
426
246
  /**
427
- * Internal state tracking comlink connections
247
+ * Logged-in state from the auth state.
428
248
  * @public
429
249
  */
430
- export declare interface ComlinkNodeState {
431
- nodes: Map<string, NodeEntry>
432
- subscriptions: Map<string, Set<symbol>>
433
- }
434
-
435
- declare interface Context {
436
- timestamp: Date
437
- identity: string
438
- before: Value | null
439
- after: Value | null
440
- sanity?: {
441
- projectId: string
442
- dataset: string
443
- }
444
- dereference?: DereferenceFunction
445
- }
446
-
447
- declare interface ContextNode extends BaseNode {
448
- type: 'Context'
449
- key: string
450
- }
451
-
250
+ type LoggedInAuthState = {
251
+ type: AuthStateType.LOGGED_IN;
252
+ token: string;
253
+ currentUser: CurrentUser$1 | null;
254
+ };
452
255
  /**
453
- * This version is provided by pkg-utils at build time
454
- * @internal
256
+ * Logged-out state from the auth state.
257
+ * @public
455
258
  */
456
- export declare const CORE_SDK_VERSION: {}
457
-
259
+ type LoggedOutAuthState = {
260
+ type: AuthStateType.LOGGED_OUT;
261
+ isDestroyingSession: boolean;
262
+ };
458
263
  /**
459
- * Creates or validates a `DatasetHandle` object.
460
- * Ensures the provided object conforms to the `DatasetHandle` interface.
461
- * @param handle - The object containing dataset identification properties.
462
- * @returns The validated `DatasetHandle` object.
264
+ * Logging-in state from the auth state.
463
265
  * @public
464
266
  */
465
- export declare function createDatasetHandle<
466
- TDataset extends string = string,
467
- TProjectId extends string = string,
468
- >(handle: DatasetHandle<TDataset, TProjectId>): DatasetHandle<TDataset, TProjectId>
469
-
267
+ type LoggingInAuthState = {
268
+ type: AuthStateType.LOGGING_IN;
269
+ isExchangingToken: boolean;
270
+ };
470
271
  /**
471
- * Creates a `CreateDocumentAction` object.
472
- * @param doc - A handle identifying the document type, dataset, and project. An optional `documentId` can be provided.
473
- * @returns A `CreateDocumentAction` object ready for dispatch.
474
- * @beta
272
+ * Error state from the auth state.
273
+ * @public
475
274
  */
476
- export declare function createDocument<
477
- TDocumentType extends string = string,
478
- TDataset extends string = string,
479
- TProjectId extends string = string,
480
- >(
481
- doc: DocumentTypeHandle<TDocumentType, TDataset, TProjectId>,
482
- ): CreateDocumentAction<TDocumentType, TDataset, TProjectId>
483
-
275
+ type ErrorAuthState = {
276
+ type: AuthStateType.ERROR;
277
+ error: unknown;
278
+ };
484
279
  /**
485
- * Represents an action to create a new document.
486
- * Specifies the document type and optionally a document ID (which will be treated as the published ID).
487
- * @beta
280
+ * Represents the various states the authentication can be in.
281
+ *
282
+ * @public
488
283
  */
489
- export declare interface CreateDocumentAction<
490
- TDocumentType extends string = string,
491
- TDataset extends string = string,
492
- TProjectId extends string = string,
493
- > extends DocumentTypeHandle<TDocumentType, TDataset, TProjectId> {
494
- type: 'document.create'
284
+ interface DashboardContext {
285
+ mode?: string;
286
+ env?: string;
287
+ orgId?: string;
495
288
  }
496
-
289
+ type AuthMethodOptions = 'localstorage' | 'cookie' | undefined;
497
290
  /**
498
- * Creates or validates a `DocumentHandle` object.
499
- * Ensures the provided object conforms to the `DocumentHandle` interface.
500
- * @param handle - The object containing document identification properties.
501
- * @returns The validated `DocumentHandle` object.
502
291
  * @public
503
292
  */
504
- export declare function createDocumentHandle<
505
- TDocumentType extends string = string,
506
- TDataset extends string = string,
507
- TProjectId extends string = string,
508
- >(
509
- handle: DocumentHandle<TDocumentType, TDataset, TProjectId>,
510
- ): DocumentHandle<TDocumentType, TDataset, TProjectId>
511
-
293
+ interface AuthStoreState {
294
+ authState: AuthState;
295
+ providers?: AuthProvider[];
296
+ options: {
297
+ initialLocationHref: string;
298
+ clientFactory: (config: ClientConfig) => SanityClient;
299
+ customProviders: AuthConfig['providers'];
300
+ storageKey: string;
301
+ storageArea: Storage | undefined;
302
+ apiHost: string | undefined;
303
+ loginUrl: string;
304
+ callbackUrl: string | undefined;
305
+ providedToken: string | undefined;
306
+ authMethod: AuthMethodOptions;
307
+ };
308
+ dashboardContext?: DashboardContext;
309
+ }
512
310
  /**
513
- * Creates or validates a `DocumentTypeHandle` object.
514
- * Ensures the provided object conforms to the `DocumentTypeHandle` interface.
515
- * @param handle - The object containing document type identification properties.
516
- * @returns The validated `DocumentTypeHandle` object.
517
311
  * @public
518
312
  */
519
- export declare function createDocumentTypeHandle<
520
- TDocumentType extends string = string,
521
- TDataset extends string = string,
522
- TProjectId extends string = string,
523
- >(
524
- handle: DocumentTypeHandle<TDocumentType, TDataset, TProjectId>,
525
- ): DocumentTypeHandle<TDocumentType, TDataset, TProjectId>
526
-
313
+ declare const getCurrentUserState: BoundStoreAction<AuthStoreState, [], StateSource<CurrentUser$1 | null>>;
314
+ /**
315
+ * @public
316
+ */
317
+ declare const getTokenState: BoundStoreAction<AuthStoreState, [], StateSource<string | null>>;
527
318
  /**
528
- * Creates a GROQ search filter string (`[@] match text::query("...")`)
529
- * from a raw search query string.
530
- *
531
- * It applies wildcard ('*') logic to the last eligible token and escapes
532
- * double quotes within the search term.
533
- *
534
- * If the input query is empty or only whitespace, it returns an empty string.
535
- *
536
- * @param query - The raw input search string.
537
- * @returns The GROQ search filter string, or an empty string.
538
319
  * @internal
539
320
  */
540
- export declare function createGroqSearchFilter(query: string): string
541
321
 
542
322
  /**
543
- * Creates or validates a `ProjectHandle` object.
544
- * Ensures the provided object conforms to the `ProjectHandle` interface.
545
- * @param handle - The object containing project identification properties.
546
- * @returns The validated `ProjectHandle` object.
547
323
  * @public
548
324
  */
549
- export declare function createProjectHandle<TProjectId extends string = string>(
550
- handle: ProjectHandle<TProjectId>,
551
- ): ProjectHandle<TProjectId>
552
-
325
+ declare const getLoginUrlState: BoundStoreAction<AuthStoreState, [], StateSource<string>>;
553
326
  /**
554
- * Creates a new Sanity resource instance
555
- * @param config - Configuration for the instance (optional)
556
- * @returns A configured SanityInstance
557
- * @remarks When creating child instances, configurations are merged with parent values
558
- *
559
327
  * @public
560
328
  */
561
- export declare function createSanityInstance(config?: SanityConfig): SanityInstance
562
-
563
- export {CurrentUser}
564
-
329
+ declare const getAuthState: BoundStoreAction<AuthStoreState, [], StateSource<AuthState>>;
565
330
  /**
566
- * Represents the various states the authentication can be in.
567
- *
568
331
  * @public
569
332
  */
570
- declare interface DashboardContext {
571
- mode?: string
572
- env?: string
573
- orgId?: string
574
- }
575
-
333
+ declare const getDashboardOrganizationId: BoundStoreAction<AuthStoreState, [], StateSource<string | undefined>>;
576
334
  /**
335
+ * Returns a state source indicating if the SDK is running within a dashboard context.
577
336
  * @public
578
337
  */
579
- export declare interface DatasetHandle<
580
- TDataset extends string = string,
581
- TProjectId extends string = string,
582
- > extends ProjectHandle<TProjectId>,
583
- PerspectiveHandle {
584
- dataset?: TDataset
585
- }
586
-
587
- declare class DateTime {
588
- date: Date
589
- constructor(date: Date)
590
- static parseToValue(str: string): Value
591
- equals(other: DateTime): boolean
592
- add(secs: number): DateTime
593
- difference(other: DateTime): number
594
- compareTo(other: DateTime): number
595
- toString(): string
596
- toJSON(): string
338
+ declare const getIsInDashboardState: BoundStoreAction<AuthStoreState, [], StateSource<boolean>>;
339
+ /**
340
+ * Action to explicitly set the authentication token.
341
+ * Used internally by the Comlink token refresh.
342
+ * @internal
343
+ */
344
+ declare const setAuthToken: BoundStoreAction<AuthStoreState, [token: string | null], void>;
345
+ /**
346
+ * Error message returned by the organization verification
347
+ * @public
348
+ */
349
+ interface OrgVerificationResult {
350
+ error: string | null;
597
351
  }
598
-
599
- declare type DateTimeValue = StaticValue<DateTime, 'datetime'>
600
-
601
352
  /**
602
- * Given a type T and an array of "access keys" Parts, recursively index into T.
603
- *
604
- * If a part is a key, it looks up that property.
605
- * If T is an array and the part is a number, it "indexes" into the element type.
353
+ * Compares a project's actual organization ID with the expected organization ID.
354
+ * @public
606
355
  */
607
- declare type DeepGet<TValue, TPath extends readonly (string | number)[]> = TPath extends []
608
- ? TValue
609
- : TPath extends readonly [infer THead, ...infer TTail]
610
- ? DeepGet<
611
- TValue extends undefined | null
612
- ? undefined
613
- : THead extends keyof TValue
614
- ? TValue[THead]
615
- : THead extends number
616
- ? TValue extends readonly (infer TElement)[]
617
- ? TElement | undefined
618
- : undefined
619
- : undefined, // Key/index doesn't exist
620
- TTail extends readonly (string | number)[] ? TTail : []
621
- >
622
- : never
623
-
624
356
  /**
625
- * Creates a `DeleteDocumentAction` object.
626
- * @param doc - A handle uniquely identifying the document to be deleted.
627
- * @returns A `DeleteDocumentAction` object ready for dispatch.
628
- * @beta
357
+ * Creates an observable that emits the organization verification state for a given instance.
358
+ * It combines the dashboard organization ID (from auth context) with the
359
+ * project's actual organization ID (fetched via getProjectState) and compares them.
360
+ * @public
629
361
  */
630
- export declare function deleteDocument<
631
- TDocumentType extends string = string,
632
- TDataset extends string = string,
633
- TProjectId extends string = string,
634
- >(
635
- doc: DocumentHandle<TDocumentType, TDataset, TProjectId>,
636
- ): DeleteDocumentAction<TDocumentType, TDataset, TProjectId>
637
-
362
+ declare function observeOrganizationVerificationState(instance: SanityInstance, projectIds: string[]): Observable<OrgVerificationResult>;
638
363
  /**
639
- * Represents an action to delete an existing document.
640
- * Requires the full document handle including the document ID.
641
- * @beta
364
+ * @public
642
365
  */
643
- export declare interface DeleteDocumentAction<
644
- TDocumentType extends string = string,
645
- TDataset extends string = string,
646
- TProjectId extends string = string,
647
- > extends DocumentHandle<TDocumentType, TDataset, TProjectId> {
648
- type: 'document.delete'
649
- }
650
-
651
- declare type DereferenceFunction = (obj: {
652
- _ref: string
653
- }) => PromiseLike<Document_2 | null | undefined>
654
-
655
- declare interface DerefNode extends BaseNode {
656
- type: 'Deref'
657
- base: ExprNode
366
+ declare const handleAuthCallback: BoundStoreAction<AuthStoreState, [locationHref?: string | undefined], Promise<string | false>>;
367
+ /**
368
+ * @public
369
+ */
370
+ declare const logout: BoundStoreAction<AuthStoreState, [], Promise<void>>;
371
+ type AllowedClientConfigKey = 'useCdn' | 'token' | 'perspective' | 'apiHost' | 'proxy' | 'withCredentials' | 'timeout' | 'maxRetries' | 'dataset' | 'projectId' | 'requestTagPrefix' | 'useProjectHostname';
372
+ /**
373
+ * States tracked by the client store
374
+ * @public
375
+ */
376
+ interface ClientStoreState {
377
+ token: string | null;
378
+ clients: { [TKey in string]?: SanityClient };
379
+ authMethod?: 'localstorage' | 'cookie';
658
380
  }
659
-
660
- declare interface DescNode extends BaseNode {
661
- type: 'Desc'
662
- base: ExprNode
381
+ /**
382
+ * Options used when retrieving a client instance from the client store.
383
+ *
384
+ * This interface extends the base {@link ClientConfig} and adds:
385
+ *
386
+ * - **apiVersion:** A required string indicating the API version for the client.
387
+ * - **scope:** An optional flag to choose between the project-specific client
388
+ * ('project') and the global client ('global'). When set to `'global'`, the
389
+ * global client is used.
390
+ *
391
+ * These options are utilized by `getClient` and `getClientState` to configure and
392
+ * return appropriate client instances that automatically handle authentication
393
+ * updates and configuration changes.
394
+ *
395
+ * @public
396
+ */
397
+ interface ClientOptions extends Pick<ClientConfig, AllowedClientConfigKey> {
398
+ /**
399
+ * An optional flag to choose between the default client (typically project-level)
400
+ * and the global client ('global'). When set to `'global'`, the global client
401
+ * is used.
402
+ */
403
+ 'scope'?: 'default' | 'global';
404
+ /**
405
+ * A required string indicating the API version for the client.
406
+ */
407
+ 'apiVersion': string;
408
+ /**
409
+ * @internal
410
+ */
411
+ '~experimental_resource'?: ClientConfig['~experimental_resource'];
663
412
  }
664
-
665
413
  /**
666
- * Calls the destroy method on the controller and resets the controller state.
414
+ * Retrieves a Sanity client instance configured with the provided options.
415
+ *
416
+ * This function returns a client instance configured for the project or as a
417
+ * global client based on the options provided. It ensures efficient reuse of
418
+ * client instances by returning the same instance for the same options.
419
+ * For automatic handling of authentication token updates, consider using
420
+ * `getClientState`.
421
+ *
667
422
  * @public
668
423
  */
669
- export declare const destroyController: BoundStoreAction_2<ComlinkControllerState, [], void>
670
-
424
+ declare const getClient: BoundStoreAction<ClientStoreState, [options: ClientOptions], SanityClient>;
671
425
  /**
672
- * Creates a `DiscardDocumentAction` object.
673
- * @param doc - A handle uniquely identifying the document whose draft changes are to be discarded.
674
- * @returns A `DiscardDocumentAction` object ready for dispatch.
675
- * @beta
426
+ * Returns a state source for the Sanity client instance.
427
+ *
428
+ * This function provides a subscribable state source that emits updated client
429
+ * instances whenever relevant configurations change (such as authentication tokens).
430
+ * Use this when you need to react to client configuration changes in your application.
431
+ *
432
+ * @public
676
433
  */
677
- export declare function discardDocument<
678
- TDocumentType extends string = string,
679
- TDataset extends string = string,
680
- TProjectId extends string = string,
681
- >(
682
- doc: DocumentHandle<TDocumentType, TDataset, TProjectId>,
683
- ): DiscardDocumentAction<TDocumentType, TDataset, TProjectId>
684
-
434
+ declare const getClientState: BoundStoreAction<ClientStoreState, [options: ClientOptions], StateSource<SanityClient>>;
685
435
  /**
686
- * Represents an action to discard the draft changes of a document.
687
- * Requires the full document handle.
688
- * @beta
436
+ * Message sent from a containing app to an iframe
437
+ * @public
689
438
  */
690
- export declare interface DiscardDocumentAction<
691
- TDocumentType extends string = string,
692
- TDataset extends string = string,
693
- TProjectId extends string = string,
694
- > extends DocumentHandle<TDocumentType, TDataset, TProjectId> {
695
- type: 'document.discard'
696
- }
697
-
698
- declare type Document_2 = {
699
- _id?: string
700
- _type?: string
701
- [T: string]: unknown
702
- }
703
-
439
+ type FrameMessage = Message;
704
440
  /**
705
- * Union type representing all possible document actions within the SDK.
706
- * @beta
441
+ * Message sent from an iframe to a containing app
442
+ * @public
707
443
  */
708
- export declare type DocumentAction<
709
- TDocumentType extends string = string,
710
- TDataset extends string = string,
711
- TProjectId extends string = string,
712
- > =
713
- | CreateDocumentAction<TDocumentType, TDataset, TProjectId>
714
- | DeleteDocumentAction<TDocumentType, TDataset, TProjectId>
715
- | EditDocumentAction<TDocumentType, TDataset, TProjectId>
716
- | PublishDocumentAction<TDocumentType, TDataset, TProjectId>
717
- | UnpublishDocumentAction<TDocumentType, TDataset, TProjectId>
718
- | DiscardDocumentAction<TDocumentType, TDataset, TProjectId>
719
-
444
+ type WindowMessage = Message;
720
445
  /**
721
- * @beta
722
- * Event emitted when a document is created.
446
+ * Message from SDK (iframe) to Parent (dashboard) to request a new token
447
+ * @internal
723
448
  */
724
- export declare interface DocumentCreatedEvent {
725
- type: 'created'
726
- documentId: string
727
- outgoing: OutgoingTransaction
728
- }
729
-
449
+ type RequestNewTokenMessage = {
450
+ type: 'dashboard/v1/auth/tokens/create';
451
+ payload?: undefined;
452
+ };
730
453
  /**
731
- * @beta
732
- * Event emitted when a document is deleted.
454
+ * Message from Parent (dashboard) to SDK (iframe) with the new token
455
+ * @internal
733
456
  */
734
- export declare interface DocumentDeletedEvent {
735
- type: 'deleted'
736
- documentId: string
737
- outgoing: OutgoingTransaction
738
- }
739
-
457
+ type NewTokenResponseMessage = {
458
+ type: 'dashboard/v1/auth/tokens/create';
459
+ payload: {
460
+ token: string | null;
461
+ error?: string;
462
+ };
463
+ };
740
464
  /**
741
- * @beta
742
- * Event emitted when a document version is discarded.
465
+ * Individual channel with its relevant options
466
+ * @public
743
467
  */
744
- export declare interface DocumentDiscardedEvent {
745
- type: 'discarded'
746
- documentId: string
747
- outgoing: OutgoingTransaction
468
+ interface ChannelEntry {
469
+ channel: ChannelInstance<FrameMessage, WindowMessage>;
470
+ options: ChannelInput;
471
+ refCount: number;
748
472
  }
749
-
750
473
  /**
751
- * @beta
752
- * Event emitted when a document is edited.
474
+ * Internal state tracking comlink connections
475
+ * @public
753
476
  */
754
- export declare interface DocumentEditedEvent {
755
- type: 'edited'
756
- documentId: string
757
- outgoing: OutgoingTransaction
477
+ interface ComlinkControllerState {
478
+ controller: Controller | null;
479
+ controllerOrigin: string | null;
480
+ channels: Map<string, ChannelEntry>;
758
481
  }
759
-
760
- /** @beta */
761
- export declare type DocumentEvent =
762
- | ActionErrorEvent
763
- | TransactionRevertedEvent
764
- | TransactionAcceptedEvent
765
- | DocumentRebaseErrorEvent
766
- | DocumentEditedEvent
767
- | DocumentCreatedEvent
768
- | DocumentDeletedEvent
769
- | DocumentPublishedEvent
770
- | DocumentUnpublishedEvent
771
- | DocumentDiscardedEvent
772
-
773
482
  /**
774
- * Uniquely identifies a specific document within a Sanity dataset and project.
775
- * Includes `projectId`, `dataset`, `documentType`, and the required `documentId`.
776
- * Commonly used by document-related hooks and components to reference a document without fetching its full content initially.
483
+ * Calls the destroy method on the controller and resets the controller state.
777
484
  * @public
778
485
  */
779
- export declare interface DocumentHandle<
780
- TDocumentType extends string = string,
781
- TDataset extends string = string,
782
- TProjectId extends string = string,
783
- > extends DocumentTypeHandle<TDocumentType, TDataset, TProjectId> {
784
- documentId: string
785
- }
786
-
486
+ declare const destroyController: BoundStoreAction<ComlinkControllerState, [], void>;
787
487
  /**
788
- * @beta
789
- * Options for specifying a document and optionally a path within it.
488
+ * Retrieve or create a channel to be used for communication between
489
+ * an application and the controller.
490
+ * @public
790
491
  */
791
- export declare interface DocumentOptions<
792
- TPath extends string | undefined = undefined,
793
- TDocumentType extends string = string,
794
- TDataset extends string = string,
795
- TProjectId extends string = string,
796
- > extends DocumentHandle<TDocumentType, TDataset, TProjectId> {
797
- path?: TPath
798
- }
799
-
800
- /** @beta */
801
- export declare type DocumentPermissionsResult =
802
- | {
803
- allowed: false
804
- message: string
805
- reasons: PermissionDeniedReason[]
806
- }
807
- | {
808
- allowed: true
809
- message?: undefined
810
- reasons?: undefined
811
- }
812
-
492
+ declare const getOrCreateChannel: BoundStoreAction<ComlinkControllerState, [options: ChannelInput], ChannelInstance<_sanity_comlink3.Message, _sanity_comlink3.Message>>;
813
493
  /**
814
- * @beta
815
- * Event emitted when a document is published.
494
+ * Initializes or fetches a controller to handle communication
495
+ * between an application and iframes.
496
+ * @public
816
497
  */
817
- export declare interface DocumentPublishedEvent {
818
- type: 'published'
819
- documentId: string
820
- outgoing: OutgoingTransaction
821
- }
822
-
498
+ declare const getOrCreateController: BoundStoreAction<ComlinkControllerState, [targetOrigin: string], Controller>;
823
499
  /**
824
- * @beta
825
- * Event emitted when an attempt to apply local changes to a modified remote document fails.
500
+ * Signals to the store that the consumer has stopped using the channel
501
+ * @public
826
502
  */
827
- declare interface DocumentRebaseErrorEvent {
828
- type: 'rebase-error'
829
- documentId: string
830
- transactionId: string
831
- message: string
832
- error: unknown
833
- }
834
-
503
+ declare const releaseChannel: BoundStoreAction<ComlinkControllerState, [name: string], void>;
835
504
  /**
836
- * Represents a set of document that will go into `applyMutations`. Before
837
- * applying a mutation, it's expected that all relevant documents that the
838
- * mutations affect are included, including those that do not exist yet.
839
- * Documents that don't exist have a `null` value.
505
+ * Individual node with its relevant options
506
+ * @public
840
507
  */
841
- declare type DocumentSet<TDocument extends SanityDocument = SanityDocument> = {
842
- [TDocumentId in string]?: TDocument | null
843
- }
844
-
845
- declare interface DocumentState {
846
- id: string
847
- /**
848
- * the "remote" local copy that matches the server. represents the last known
849
- * server state. this gets updated every time we confirm remote patches
850
- */
851
- remote?: SanityDocument_2 | null
852
- /**
853
- * the current ephemeral working copy that includes local optimistic changes
854
- * that have not yet been confirmed by the server
855
- */
856
- local?: SanityDocument_2 | null
857
- /**
858
- * the revision that our remote document is at
859
- */
860
- remoteRev?: string | null
861
- /**
862
- * Array of subscription IDs. This document state will be deleted if there are
863
- * no subscribers.
864
- */
865
- subscriptions: string[]
866
- /**
867
- * An object keyed by transaction ID of revisions sent out but that have not
868
- * yet been verified yet. When an applied transaction is transitioned to an
869
- * outgoing transaction, it also adds unverified revisions for each document
870
- * that is part of that outgoing transaction. Transactions are submitted to
871
- * the server with a locally generated transaction ID. This way we can observe
872
- * when our transaction comes back through the shared listener. Each listener
873
- * event that comes back contains a `previousRev`. If we see our own
874
- * transaction with a different `previousRev` than expected, we can rebase our
875
- * local transactions on top of this new remote.
876
- */
877
- unverifiedRevisions?: {
878
- [TTransactionId in string]?: UnverifiedDocumentRevision
879
- }
880
- }
881
-
882
- declare interface DocumentStoreState {
883
- documentStates: {
884
- [TDocumentId in string]?: DocumentState
885
- }
886
- queued: QueuedTransaction[]
887
- applied: AppliedTransaction[]
888
- outgoing?: OutgoingTransaction
889
- grants?: Record<Grant, ExprNode>
890
- error?: unknown
891
- sharedListener: SharedListener
892
- fetchDocument: (documentId: string) => Observable<SanityDocument_2 | null>
893
- events: Subject<DocumentEvent>
508
+ interface NodeEntry {
509
+ node: Node<WindowMessage, FrameMessage>;
510
+ options: NodeInput;
511
+ status: Status;
512
+ statusUnsub?: () => void;
894
513
  }
895
-
896
514
  /**
897
- * Identifies a specific document type within a Sanity dataset and project.
898
- * Includes `projectId`, `dataset`, and `documentType`.
899
- * Optionally includes a `documentId`, useful for referencing a specific document type context, potentially without a specific document ID.
515
+ * Internal state tracking comlink connections
900
516
  * @public
901
517
  */
902
- export declare interface DocumentTypeHandle<
903
- TDocumentType extends string = string,
904
- TDataset extends string = string,
905
- TProjectId extends string = string,
906
- > extends DatasetHandle<TDataset, TProjectId> {
907
- documentId?: string
908
- documentType: TDocumentType
518
+ interface ComlinkNodeState {
519
+ nodes: Map<string, NodeEntry>;
520
+ subscriptions: Map<string, Set<symbol>>;
909
521
  }
910
-
911
522
  /**
912
- * @beta
913
- * Event emitted when a document is unpublished.
523
+ * Signals to the store that the consumer has stopped using the node
524
+ * @public
914
525
  */
915
- export declare interface DocumentUnpublishedEvent {
916
- type: 'unpublished'
917
- documentId: string
918
- outgoing: OutgoingTransaction
919
- }
920
-
921
- /**
922
- * Creates an `EditDocumentAction` object with patches for modifying a document.
923
- * Accepts patches in either the standard `PatchOperations` format or as a `SanityMutatePatchMutation` from `@sanity/mutate`.
924
- *
925
- * @param doc - A handle uniquely identifying the document to be edited.
926
- * @param sanityMutatePatch - A patch mutation object from `@sanity/mutate`.
927
- * @returns An `EditDocumentAction` object ready for dispatch.
928
- * @beta
929
- */
930
- export declare function editDocument<
931
- TDocumentType extends string = string,
932
- TDataset extends string = string,
933
- TProjectId extends string = string,
934
- >(
935
- doc: DocumentHandle<TDocumentType, TDataset, TProjectId>,
936
- sanityMutatePatch: PatchMutation,
937
- ): EditDocumentAction<TDocumentType, TDataset, TProjectId>
938
-
939
- /**
940
- * Creates an `EditDocumentAction` object with patches for modifying a document.
941
- *
942
- * @param doc - A handle uniquely identifying the document to be edited.
943
- * @param patches - A single patch operation or an array of patch operations.
944
- * @returns An `EditDocumentAction` object ready for dispatch.
945
- * @beta
946
- */
947
- export declare function editDocument<
948
- TDocumentType extends string = string,
949
- TDataset extends string = string,
950
- TProjectId extends string = string,
951
- >(
952
- doc: DocumentHandle<TDocumentType, TDataset, TProjectId>,
953
- patches?: PatchOperations | PatchOperations[],
954
- ): EditDocumentAction<TDocumentType, TDataset, TProjectId>
955
-
956
- /**
957
- * Represents an action to edit an existing document using patches.
958
- * Requires the full document handle and an array of patch operations.
959
- * @beta
960
- */
961
- export declare interface EditDocumentAction<
962
- TDocumentType extends string = string,
963
- TDataset extends string = string,
964
- TProjectId extends string = string,
965
- > extends DocumentHandle<TDocumentType, TDataset, TProjectId> {
966
- type: 'document.edit'
967
- patches?: PatchOperations[]
968
- }
969
-
970
- /**
971
- * Error state from the auth state.
972
- * @public
973
- */
974
- export declare type ErrorAuthState = {
975
- type: AuthStateType.ERROR
976
- error: unknown
977
- }
978
-
979
- declare interface EverythingNode extends BaseNode {
980
- type: 'Everything'
981
- }
982
-
983
- declare type Executor<N = ExprNode> = (node: N, scope: Scope) => Value | PromiseLike<Value>
984
-
985
- /**
986
- * A node which can be evaluated into a value.
987
- * @public
988
- */
989
- declare type ExprNode =
990
- | AccessAttributeNode
991
- | AccessElementNode
992
- | AndNode
993
- | ArrayNode
994
- | ArrayCoerceNode
995
- | AscNode
996
- | ContextNode
997
- | DerefNode
998
- | DescNode
999
- | EverythingNode
1000
- | FilterNode
1001
- | FlatMapNode
1002
- | FuncCallNode
1003
- | GroupNode
1004
- | InRangeNode
1005
- | MapNode
1006
- | NegNode
1007
- | NotNode
1008
- | ObjectNode
1009
- | OpCallNode
1010
- | OrNode
1011
- | ParameterNode
1012
- | ParentNode_2
1013
- | PipeFuncCallNode
1014
- | PosNode
1015
- | ProjectionNode
1016
- | SelectNode
1017
- | SelectorNode
1018
- | SliceNode
1019
- | ThisNode
1020
- | TupleNode
1021
- | ValueNode
1022
-
526
+ declare const releaseNode: BoundStoreAction<ComlinkNodeState, [name: string], void>;
1023
527
  /**
528
+ * Retrieve or create a node to be used for communication between
529
+ * an application and the controller -- specifically, a node should
530
+ * be created within a frame / window to communicate with the controller.
1024
531
  * @public
1025
532
  */
1026
- declare interface FavoriteDocumentContext extends DocumentHandle {
1027
- resourceId: string
1028
- resourceType: StudioResource['type'] | MediaResource['type'] | CanvasResource['type']
1029
- schemaName?: string
1030
- }
1031
-
533
+ declare const getOrCreateNode: BoundStoreAction<ComlinkNodeState, [options: NodeInput], Node<_sanity_comlink3.Message, _sanity_comlink3.Message>>;
1032
534
  /**
1033
535
  * @public
1034
536
  */
1035
- export declare interface FavoriteStatusResponse {
1036
- isFavorited: boolean
537
+ interface NodeState {
538
+ node: Node<WindowMessage, FrameMessage>;
539
+ status: Status | undefined;
1037
540
  }
1038
-
1039
541
  /**
1040
- * Internal helper type
1041
- * @public
1042
- */
1043
- export declare interface FetcherStore<TParams extends unknown[], TData> {
1044
- getState: BoundStoreAction_3<
1045
- FetcherStoreState<TParams, TData>,
1046
- TParams,
1047
- StateSource<TData | undefined>
1048
- >
1049
- resolveState: BoundStoreAction_3<FetcherStoreState<TParams, TData>, TParams, Promise<TData>>
1050
- }
542
+ * Provides a subscribable state source for a node by name
543
+ * @param instance - The Sanity instance to get the node state for
544
+ * @param nodeInput - The configuration for the node to get the state for
1051
545
 
1052
- /**
1053
- * Internal helper type
546
+ * @returns A subscribable state source for the node
1054
547
  * @public
1055
548
  */
1056
- export declare interface FetcherStoreState<TParams extends unknown[], TData> {
1057
- stateByParams: {
1058
- [TSerializedKey in string]?: StoreEntry<TParams, TData>
1059
- }
1060
- error?: unknown
1061
- }
1062
-
1063
- declare interface FilterNode extends BaseNode {
1064
- type: 'Filter'
1065
- base: ExprNode
1066
- expr: ExprNode
1067
- }
1068
-
1069
- declare interface FlatMapNode extends BaseNode {
1070
- type: 'FlatMap'
1071
- base: ExprNode
1072
- expr: ExprNode
1073
- }
1074
-
549
+ declare const getNodeState: BoundStoreAction<ComlinkNodeState, [NodeInput], StateSource<NodeState | undefined>>;
1075
550
  /**
1076
- * Message sent from a containing app to an iframe
551
+ * Creates or validates a `DocumentHandle` object.
552
+ * Ensures the provided object conforms to the `DocumentHandle` interface.
553
+ * @param handle - The object containing document identification properties.
554
+ * @returns The validated `DocumentHandle` object.
1077
555
  * @public
1078
556
  */
1079
- export declare type FrameMessage = Message
1080
-
1081
- declare interface FuncCallNode extends BaseNode {
1082
- type: 'FuncCall'
1083
- func: GroqFunction
1084
- namespace: string
1085
- name: string
1086
- args: ExprNode[]
1087
- }
1088
-
1089
- /**
1090
- * Get the active releases from the store.
1091
- * @internal
1092
- */
1093
- export declare const getActiveReleasesState: BoundStoreAction<
1094
- ReleasesStoreState,
1095
- [],
1096
- StateSource_2<ReleaseDocument[] | undefined>
1097
- >
1098
-
557
+ declare function createDocumentHandle<TDocumentType extends string = string, TDataset extends string = string, TProjectId extends string = string>(handle: DocumentHandle<TDocumentType, TDataset, TProjectId>): DocumentHandle<TDocumentType, TDataset, TProjectId>;
1099
558
  /**
559
+ * Creates or validates a `DocumentTypeHandle` object.
560
+ * Ensures the provided object conforms to the `DocumentTypeHandle` interface.
561
+ * @param handle - The object containing document type identification properties.
562
+ * @returns The validated `DocumentTypeHandle` object.
1100
563
  * @public
1101
564
  */
1102
- export declare const getAuthState: BoundStoreAction<AuthStoreState, [], StateSource_2<AuthState>>
1103
-
565
+ declare function createDocumentTypeHandle<TDocumentType extends string = string, TDataset extends string = string, TProjectId extends string = string>(handle: DocumentTypeHandle<TDocumentType, TDataset, TProjectId>): DocumentTypeHandle<TDocumentType, TDataset, TProjectId>;
1104
566
  /**
1105
- * Retrieves a Sanity client instance configured with the provided options.
1106
- *
1107
- * This function returns a client instance configured for the project or as a
1108
- * global client based on the options provided. It ensures efficient reuse of
1109
- * client instances by returning the same instance for the same options.
1110
- * For automatic handling of authentication token updates, consider using
1111
- * `getClientState`.
1112
- *
567
+ * Creates or validates a `ProjectHandle` object.
568
+ * Ensures the provided object conforms to the `ProjectHandle` interface.
569
+ * @param handle - The object containing project identification properties.
570
+ * @returns The validated `ProjectHandle` object.
1113
571
  * @public
1114
572
  */
1115
- export declare const getClient: BoundStoreAction<
1116
- ClientState,
1117
- [options: ClientOptions],
1118
- SanityClient
1119
- >
1120
-
573
+ declare function createProjectHandle<TProjectId extends string = string>(handle: ProjectHandle<TProjectId>): ProjectHandle<TProjectId>;
1121
574
  /**
1122
- * Returns a state source for the Sanity client instance.
1123
- *
1124
- * This function provides a subscribable state source that emits updated client
1125
- * instances whenever relevant configurations change (such as authentication tokens).
1126
- * Use this when you need to react to client configuration changes in your application.
1127
- *
575
+ * Creates or validates a `DatasetHandle` object.
576
+ * Ensures the provided object conforms to the `DatasetHandle` interface.
577
+ * @param handle - The object containing dataset identification properties.
578
+ * @returns The validated `DatasetHandle` object.
1128
579
  * @public
1129
580
  */
1130
- export declare const getClientState: BoundStoreAction<
1131
- ClientState,
1132
- [options: ClientOptions],
1133
- StateSource_2<SanityClient>
1134
- >
1135
-
581
+ declare function createDatasetHandle<TDataset extends string = string, TProjectId extends string = string>(handle: DatasetHandle<TDataset, TProjectId>): DatasetHandle<TDataset, TProjectId>;
582
+ /** @public */
583
+ declare const getDatasetsState: BoundStoreAction<FetcherStoreState<[options?: ProjectHandle<string> | undefined], _sanity_client12.DatasetsResponse>, [options?: ProjectHandle<string> | undefined], StateSource<_sanity_client12.DatasetsResponse | undefined>>;
584
+ /** @public */
585
+ declare const resolveDatasets: BoundStoreAction<FetcherStoreState<[options?: ProjectHandle<string> | undefined], _sanity_client12.DatasetsResponse>, [options?: ProjectHandle<string> | undefined], Promise<_sanity_client12.DatasetsResponse>>;
1136
586
  /**
1137
- * @public
587
+ * Represents an action to create a new document.
588
+ * Specifies the document type and optionally a document ID (which will be treated as the published ID).
589
+ * @beta
1138
590
  */
1139
- export declare const getCurrentUserState: BoundStoreAction<
1140
- AuthStoreState,
1141
- [],
1142
- StateSource_2<CurrentUser | null>
1143
- >
1144
-
591
+ interface CreateDocumentAction<TDocumentType extends string = string, TDataset extends string = string, TProjectId extends string = string> extends DocumentTypeHandle<TDocumentType, TDataset, TProjectId> {
592
+ type: 'document.create';
593
+ }
1145
594
  /**
1146
- * @public
595
+ * Represents an action to delete an existing document.
596
+ * Requires the full document handle including the document ID.
597
+ * @beta
1147
598
  */
1148
- export declare const getDashboardOrganizationId: BoundStoreAction<
1149
- AuthStoreState,
1150
- [],
1151
- StateSource_2<string | undefined>
1152
- >
1153
-
1154
- /** @public */
1155
- export declare const getDatasetsState: BoundStoreAction<
1156
- FetcherStoreState_2<[options?: ProjectHandle<string> | undefined], DatasetsResponse>,
1157
- [options?: ProjectHandle<string> | undefined],
1158
- StateSource_2<DatasetsResponse | undefined>
1159
- >
1160
-
1161
- /** @beta */
1162
- export declare function getDocumentState<
1163
- TDocumentType extends string = string,
1164
- TDataset extends string = string,
1165
- TProjectId extends string = string,
1166
- >(
1167
- instance: SanityInstance,
1168
- options: DocumentOptions<undefined, TDocumentType, TDataset, TProjectId>,
1169
- ): StateSource<SanityDocument_2<TDocumentType, `${TProjectId}.${TDataset}`> | undefined | null>
1170
-
1171
- /** @beta */
1172
- export declare function getDocumentState<
1173
- TPath extends string = string,
1174
- TDocumentType extends string = string,
1175
- TDataset extends string = string,
1176
- TProjectId extends string = string,
1177
- >(
1178
- instance: SanityInstance,
1179
- options: DocumentOptions<TPath, TDocumentType, TDataset, TProjectId>,
1180
- ): StateSource<
1181
- JsonMatch<SanityDocument_2<TDocumentType, `${TProjectId}.${TDataset}`>, TPath> | undefined
1182
- >
1183
-
1184
- /** @beta */
1185
- export declare function getDocumentState<TData>(
1186
- instance: SanityInstance,
1187
- options: DocumentOptions<string | undefined>,
1188
- ): StateSource<TData | undefined | null>
1189
-
1190
- /** @beta */
1191
- export declare const getDocumentSyncStatus: BoundStoreAction<
1192
- DocumentStoreState,
1193
- [doc: DocumentHandle<string, string, string>],
1194
- StateSource<boolean | undefined>
1195
- >
1196
-
599
+ interface DeleteDocumentAction<TDocumentType extends string = string, TDataset extends string = string, TProjectId extends string = string> extends DocumentHandle<TDocumentType, TDataset, TProjectId> {
600
+ type: 'document.delete';
601
+ }
1197
602
  /**
1198
- * Gets a StateSource for the favorite status of a document.
1199
- * @param instance - The Sanity instance.
1200
- * @param context - The document context including ID, type, and resource information.
1201
- * @returns A StateSource emitting `{ isFavorited: boolean }`.
1202
- * @public
603
+ * Represents an action to edit an existing document using patches.
604
+ * Requires the full document handle and an array of patch operations.
605
+ * @beta
1203
606
  */
1204
- export declare const getFavoritesState: BoundStoreAction<
1205
- FetcherStoreState_2<[FavoriteDocumentContext], FavoriteStatusResponse>,
1206
- [FavoriteDocumentContext],
1207
- StateSource_2<FavoriteStatusResponse | undefined>
1208
- >
1209
-
607
+ interface EditDocumentAction<TDocumentType extends string = string, TDataset extends string = string, TProjectId extends string = string> extends DocumentHandle<TDocumentType, TDataset, TProjectId> {
608
+ type: 'document.edit';
609
+ patches?: PatchOperations[];
610
+ }
1210
611
  /**
1211
- * Returns a state source indicating if the SDK is running within a dashboard context.
1212
- * @public
612
+ * Represents an action to publish the draft version of a document.
613
+ * Requires the full document handle.
614
+ * @beta
1213
615
  */
1214
- export declare const getIsInDashboardState: BoundStoreAction<
1215
- AuthStoreState,
1216
- [],
1217
- StateSource_2<boolean>
1218
- >
1219
-
616
+ interface PublishDocumentAction<TDocumentType extends string = string, TDataset extends string = string, TProjectId extends string = string> extends DocumentHandle<TDocumentType, TDataset, TProjectId> {
617
+ type: 'document.publish';
618
+ }
1220
619
  /**
1221
- * @public
620
+ * Represents an action to unpublish a document, moving its published content to a draft.
621
+ * Requires the full document handle.
622
+ * @beta
1222
623
  */
1223
- export declare const getLoginUrlState: BoundStoreAction<AuthStoreState, [], StateSource_2<string>>
1224
-
624
+ interface UnpublishDocumentAction<TDocumentType extends string = string, TDataset extends string = string, TProjectId extends string = string> extends DocumentHandle<TDocumentType, TDataset, TProjectId> {
625
+ type: 'document.unpublish';
626
+ }
1225
627
  /**
1226
- * Provides a subscribable state source for a node by name
1227
- * @param instance - The Sanity instance to get the node state for
1228
- * @param nodeInput - The configuration for the node to get the state for
1229
-
1230
- * @returns A subscribable state source for the node
1231
- * @public
628
+ * Represents an action to discard the draft changes of a document.
629
+ * Requires the full document handle.
630
+ * @beta
1232
631
  */
1233
- export declare const getNodeState: BoundStoreAction_2<
1234
- ComlinkNodeState,
1235
- [NodeInput],
1236
- StateSource_3<NodeState | undefined>
1237
- >
1238
-
632
+ interface DiscardDocumentAction<TDocumentType extends string = string, TDataset extends string = string, TProjectId extends string = string> extends DocumentHandle<TDocumentType, TDataset, TProjectId> {
633
+ type: 'document.discard';
634
+ }
1239
635
  /**
1240
- * Retrieve or create a channel to be used for communication between
1241
- * an application and the controller.
1242
- * @public
636
+ * Union type representing all possible document actions within the SDK.
637
+ * @beta
1243
638
  */
1244
- export declare const getOrCreateChannel: BoundStoreAction_2<
1245
- ComlinkControllerState,
1246
- [options: ChannelInput],
1247
- ChannelInstance<Message, Message>
1248
- >
1249
-
639
+ 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>;
1250
640
  /**
1251
- * Initializes or fetches a controller to handle communication
1252
- * between an application and iframes.
1253
- * @public
641
+ * Creates a `CreateDocumentAction` object.
642
+ * @param doc - A handle identifying the document type, dataset, and project. An optional `documentId` can be provided.
643
+ * @returns A `CreateDocumentAction` object ready for dispatch.
644
+ * @beta
1254
645
  */
1255
- export declare const getOrCreateController: BoundStoreAction_2<
1256
- ComlinkControllerState,
1257
- [targetOrigin: string],
1258
- Controller
1259
- >
1260
-
646
+ declare function createDocument<TDocumentType extends string = string, TDataset extends string = string, TProjectId extends string = string>(doc: DocumentTypeHandle<TDocumentType, TDataset, TProjectId>): CreateDocumentAction<TDocumentType, TDataset, TProjectId>;
1261
647
  /**
1262
- * Retrieve or create a node to be used for communication between
1263
- * an application and the controller -- specifically, a node should
1264
- * be created within a frame / window to communicate with the controller.
1265
- * @public
648
+ * Creates a `DeleteDocumentAction` object.
649
+ * @param doc - A handle uniquely identifying the document to be deleted.
650
+ * @returns A `DeleteDocumentAction` object ready for dispatch.
651
+ * @beta
1266
652
  */
1267
- export declare const getOrCreateNode: BoundStoreAction_2<
1268
- ComlinkNodeState,
1269
- [options: NodeInput],
1270
- Node_2<Message, Message>
1271
- >
1272
-
1273
- /** @beta */
1274
- export declare const getPermissionsState: BoundStoreAction<
1275
- DocumentStoreState,
1276
- [DocumentAction | DocumentAction[]],
1277
- StateSource<DocumentPermissionsResult_2 | undefined>
1278
- >
1279
-
653
+ declare function deleteDocument<TDocumentType extends string = string, TDataset extends string = string, TProjectId extends string = string>(doc: DocumentHandle<TDocumentType, TDataset, TProjectId>): DeleteDocumentAction<TDocumentType, TDataset, TProjectId>;
1280
654
  /**
1281
- * Provides a subscribable state source for a "perspective" for the Sanity client,
1282
- * which is used to fetch documents as though certain Content Releases are active.
1283
- *
1284
- * @param instance - The Sanity instance to get the perspective for
1285
- * @param options - The options for the perspective -- usually a release name
1286
- *
1287
- * @returns A subscribable perspective value, usually a list of applicable release names,
1288
- * or a single release name / default perspective (such as 'drafts').
655
+ * Creates an `EditDocumentAction` object with patches for modifying a document.
656
+ * Accepts patches in either the standard `PatchOperations` format or as a `SanityMutatePatchMutation` from `@sanity/mutate`.
1289
657
  *
1290
- * @public
1291
- */
1292
- export declare const getPerspectiveState: BoundStoreAction<
1293
- ReleasesStoreState,
1294
- [options?: PerspectiveHandle | undefined],
1295
- StateSource_2<string[] | 'published' | 'drafts' | 'previewDrafts' | 'raw' | undefined>
1296
- >
1297
-
1298
- /**
658
+ * @param doc - A handle uniquely identifying the document to be edited.
659
+ * @param sanityMutatePatch - A patch mutation object from `@sanity/mutate`.
660
+ * @returns An `EditDocumentAction` object ready for dispatch.
1299
661
  * @beta
1300
662
  */
1301
- export declare function getPreviewState<TResult extends object>(
1302
- instance: SanityInstance,
1303
- options: GetPreviewStateOptions,
1304
- ): StateSource<ValuePending<TResult>>
1305
-
663
+ 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>;
1306
664
  /**
665
+ * Creates an `EditDocumentAction` object with patches for modifying a document.
666
+ *
667
+ * @param doc - A handle uniquely identifying the document to be edited.
668
+ * @param patches - A single patch operation or an array of patch operations.
669
+ * @returns An `EditDocumentAction` object ready for dispatch.
1307
670
  * @beta
1308
671
  */
1309
- export declare function getPreviewState(
1310
- instance: SanityInstance,
1311
- options: GetPreviewStateOptions,
1312
- ): StateSource<ValuePending<PreviewValue>>
1313
-
672
+ 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>;
1314
673
  /**
674
+ * Creates a `PublishDocumentAction` object.
675
+ * @param doc - A handle uniquely identifying the document to be published.
676
+ * @returns A `PublishDocumentAction` object ready for dispatch.
1315
677
  * @beta
1316
678
  */
1317
- export declare type GetPreviewStateOptions = DocumentHandle
1318
-
679
+ declare function publishDocument<TDocumentType extends string = string, TDataset extends string = string, TProjectId extends string = string>(doc: DocumentHandle<TDocumentType, TDataset, TProjectId>): PublishDocumentAction<TDocumentType, TDataset, TProjectId>;
1319
680
  /**
681
+ * Creates an `UnpublishDocumentAction` object.
682
+ * @param doc - A handle uniquely identifying the document to be unpublished.
683
+ * @returns An `UnpublishDocumentAction` object ready for dispatch.
1320
684
  * @beta
1321
685
  */
1322
- export declare function getProjectionState<
1323
- TProjection extends ValidProjection = ValidProjection,
1324
- TDocumentType extends string = string,
1325
- TDataset extends string = string,
1326
- TProjectId extends string = string,
1327
- >(
1328
- instance: SanityInstance,
1329
- options: ProjectionOptions<TProjection, TDocumentType, TDataset, TProjectId>,
1330
- ): StateSource<
1331
- | ProjectionValuePending<
1332
- SanityProjectionResult<TProjection, TDocumentType, `${TProjectId}.${TDataset}`>
1333
- >
1334
- | undefined
1335
- >
1336
-
686
+ declare function unpublishDocument<TDocumentType extends string = string, TDataset extends string = string, TProjectId extends string = string>(doc: DocumentHandle<TDocumentType, TDataset, TProjectId>): UnpublishDocumentAction<TDocumentType, TDataset, TProjectId>;
1337
687
  /**
688
+ * Creates a `DiscardDocumentAction` object.
689
+ * @param doc - A handle uniquely identifying the document whose draft changes are to be discarded.
690
+ * @returns A `DiscardDocumentAction` object ready for dispatch.
1338
691
  * @beta
1339
692
  */
1340
- export declare function getProjectionState<TData extends object>(
1341
- instance: SanityInstance,
1342
- options: ProjectionOptions,
1343
- ): StateSource<ProjectionValuePending<TData> | undefined>
1344
-
693
+ declare function discardDocument<TDocumentType extends string = string, TDataset extends string = string, TProjectId extends string = string>(doc: DocumentHandle<TDocumentType, TDataset, TProjectId>): DiscardDocumentAction<TDocumentType, TDataset, TProjectId>;
1345
694
  /**
1346
- * @beta
695
+ * Represents a set of document that will go into `applyMutations`. Before
696
+ * applying a mutation, it's expected that all relevant documents that the
697
+ * mutations affect are included, including those that do not exist yet.
698
+ * Documents that don't exist have a `null` value.
1347
699
  */
1348
- export declare function getProjectionState(
1349
- instance: SanityInstance,
1350
- options: ProjectionOptions,
1351
- ): StateSource<ProjectionValuePending<Record<string, unknown>> | undefined>
1352
-
1353
- /** @public */
1354
- export declare const getProjectsState: BoundStoreAction<
1355
- FetcherStoreState_2<[], Omit<SanityProject_2, 'members'>[]>,
1356
- [],
1357
- StateSource_2<Omit<SanityProject_2, 'members'>[] | undefined>
1358
- >
1359
-
1360
- /** @public */
1361
- export declare const getProjectState: BoundStoreAction<
1362
- FetcherStoreState_2<[options?: ProjectHandle<string> | undefined], SanityProject_2>,
1363
- [options?: ProjectHandle<string> | undefined],
1364
- StateSource_2<SanityProject_2 | undefined>
1365
- >
1366
-
1367
- /** @beta */
1368
- export declare const getQueryKey: (options: QueryOptions) => string
1369
-
700
+ type DocumentSet<TDocument extends SanityDocument$2 = SanityDocument$2> = { [TDocumentId in string]?: TDocument | null };
1370
701
  /**
1371
- * Returns the state source for a query.
702
+ * Implements ID generation:
1372
703
  *
1373
- * This function returns a state source that represents the current result of a GROQ query.
1374
- * Subscribing to the state source will instruct the SDK to fetch the query (if not already fetched)
1375
- * and will keep the query live using the Live content API (considering sync tags) to provide up-to-date results.
1376
- * When the last subscriber is removed, the query state is automatically cleaned up from the store.
704
+ * A create mutation creates a new document. It takes the literal document
705
+ * content as its argument. The rules for the new document's identifier are as
706
+ * follows:
1377
707
  *
1378
- * Note: This functionality is for advanced users who want to build their own framework integrations.
1379
- * Our SDK also provides a React integration (useQuery hook) for convenient usage.
1380
- *
1381
- * Note: Automatic cleanup can interfere with React Suspense because if a component suspends while being the only subscriber,
1382
- * cleanup might occur unexpectedly. In such cases, consider using `resolveQuery` instead.
708
+ * - If the `_id` attribute is missing, then a new, random, unique ID is
709
+ * generated.
710
+ * - If the `_id` attribute is present but ends with `.`, then it is used as a
711
+ * prefix for a new, random, unique ID.
712
+ * - If the _id attribute is present, it is used as-is.
1383
713
  *
1384
- * @beta
714
+ * [- source](https://www.sanity.io/docs/http-mutations#c732f27330a4)
1385
715
  */
1386
- export declare function getQueryState<
1387
- TQuery extends string = string,
1388
- TDataset extends string = string,
1389
- TProjectId extends string = string,
1390
- >(
1391
- instance: SanityInstance,
1392
- queryOptions: QueryOptions<TQuery, TDataset, TProjectId>,
1393
- ): StateSource<SanityQueryResult<TQuery, `${TProjectId}.${TDataset}`> | undefined>
1394
-
1395
716
  /** @beta */
1396
- export declare function getQueryState<TData>(
1397
- instance: SanityInstance,
1398
- queryOptions: QueryOptions,
1399
- ): StateSource<TData | undefined>
1400
-
717
+ interface ActionsResult<TDocument extends SanityDocument$3 = SanityDocument$3> {
718
+ transactionId: string;
719
+ documents: DocumentSet<TDocument>;
720
+ previous: DocumentSet<TDocument>;
721
+ previousRevs: {
722
+ [documentId: string]: string | undefined;
723
+ };
724
+ appeared: string[];
725
+ updated: string[];
726
+ disappeared: string[];
727
+ submitted: () => ReturnType<SanityClient['action']>;
728
+ }
1401
729
  /** @beta */
1402
- export declare function getQueryState(
1403
- instance: SanityInstance,
1404
- queryOptions: QueryOptions,
1405
- ): StateSource<unknown>
1406
-
1407
- /**
1408
- * @public
1409
- */
1410
- export declare const getTokenState: BoundStoreAction<
1411
- AuthStoreState,
1412
- [],
1413
- StateSource_2<string | null>
1414
- >
1415
-
1416
- /** @internal */
1417
- export declare const getUsersKey: (
1418
- instance: SanityInstance,
1419
- {resourceType, organizationId, batchSize, projectId}?: GetUsersOptions,
1420
- ) => string
1421
-
1422
- /**
1423
- * @public
1424
- */
1425
- export declare interface GetUsersOptions extends ProjectHandle {
1426
- resourceType?: 'organization' | 'project'
1427
- batchSize?: number
1428
- organizationId?: string
730
+ interface ApplyDocumentActionsOptions {
731
+ /**
732
+ * Optionally provide an ID to be used as this transaction ID
733
+ */
734
+ transactionId?: string;
735
+ /**
736
+ * Set this to true to prevent this action from being batched with others.
737
+ */
738
+ disableBatching?: boolean;
1429
739
  }
1430
-
1431
- /**
1432
- * Returns the state source for users associated with a specific resource.
1433
- *
1434
- * This function returns a state source that represents the current list of users for a given
1435
- * resource. Subscribing to the state source will instruct the SDK to fetch the users (if not
1436
- * already fetched) and will load more from this state source as well. When the last subscriber is
1437
- * removed, the users state is automatically cleaned up from the store after a delay.
1438
- *
1439
- * Note: This functionality is for advanced users who want to build their own framework
1440
- * integrations. Our SDK also provides a React integration for convenient usage.
1441
- *
1442
- * @beta
1443
- */
1444
- export declare const getUsersState: BoundStoreAction<
1445
- UsersStoreState,
1446
- [options?: GetUsersOptions | undefined],
1447
- StateSource_2<
1448
- | {
1449
- data: SanityUser_2[]
1450
- totalCount: number
1451
- hasMore: boolean
1452
- }
1453
- | undefined
1454
- >
1455
- >
1456
-
1457
- declare type Grant = 'read' | 'update' | 'create' | 'history'
1458
-
1459
- /** @public */
1460
- declare type GroqFunction = (
1461
- args: GroqFunctionArg[],
1462
- scope: Scope,
1463
- execute: Executor,
1464
- ) => PromiseLike<Value>
1465
-
1466
- /** @public */
1467
- declare type GroqFunctionArg = ExprNode
1468
-
1469
- declare type GroqPipeFunction = (
1470
- base: Value,
1471
- args: ExprNode[],
1472
- scope: Scope,
1473
- execute: Executor,
1474
- ) => PromiseLike<Value>
1475
-
1476
- /**
1477
- * A type of a value in GROQ.
1478
- */
1479
- declare type GroqType =
1480
- | 'null'
1481
- | 'boolean'
1482
- | 'number'
1483
- | 'string'
1484
- | 'array'
1485
- | 'object'
1486
- | 'path'
1487
- | 'datetime'
1488
-
1489
- declare interface GroupNode extends BaseNode {
1490
- type: 'Group'
1491
- base: ExprNode
740
+ /** @beta */
741
+ declare function applyDocumentActions<TDocumentType extends string = string, TDataset extends string = string, TProjectId extends string = string>(instance: SanityInstance, action: DocumentAction<TDocumentType, TDataset, TProjectId> | DocumentAction<TDocumentType, TDataset, TProjectId>[], options?: ApplyDocumentActionsOptions): Promise<ActionsResult<SanityDocument$3<TDocumentType, `${TProjectId}.${TDataset}`>>>;
742
+ /** @beta */
743
+ declare function applyDocumentActions(instance: SanityInstance, action: DocumentAction | DocumentAction[], options?: ApplyDocumentActionsOptions): Promise<ActionsResult>;
744
+ declare interface AccessAttributeNode extends BaseNode {
745
+ type: 'AccessAttribute';
746
+ base?: ExprNode;
747
+ name: string;
748
+ }
749
+ declare interface AccessElementNode extends BaseNode {
750
+ type: 'AccessElement';
751
+ base: ExprNode;
752
+ index: number;
753
+ }
754
+ declare interface AndNode extends BaseNode {
755
+ type: 'And';
756
+ left: ExprNode;
757
+ right: ExprNode;
758
+ }
759
+ declare type AnyStaticValue = StringValue | NumberValue | NullValue | BooleanValue | DateTimeValue | ObjectValue | ArrayValue | PathValue;
760
+ declare interface ArrayCoerceNode extends BaseNode {
761
+ type: 'ArrayCoerce';
762
+ base: ExprNode;
763
+ }
764
+ declare interface ArrayElementNode extends BaseNode {
765
+ type: 'ArrayElement';
766
+ value: ExprNode;
767
+ isSplat: boolean;
768
+ }
769
+ declare interface ArrayNode extends BaseNode {
770
+ type: 'Array';
771
+ elements: ArrayElementNode[];
1492
772
  }
1493
773
 
1494
- /**
1495
- * @public
1496
- */
1497
- export declare const handleAuthCallback: BoundStoreAction<
1498
- AuthStoreState,
1499
- [locationHref?: string | undefined],
1500
- Promise<string | false>
1501
- >
1502
-
1503
- declare type HttpAction =
1504
- | {
1505
- actionType: ActionMap['create']
1506
- publishedId: string
1507
- attributes: SanityDocumentLike
1508
- }
1509
- | {
1510
- actionType: ActionMap['discard']
1511
- versionId: string
1512
- purge?: boolean
1513
- }
1514
- | {
1515
- actionType: ActionMap['unpublish']
1516
- draftId: string
1517
- publishedId: string
1518
- }
1519
- | {
1520
- actionType: ActionMap['delete']
1521
- publishedId: string
1522
- includeDrafts?: string[]
1523
- }
1524
- | {
1525
- actionType: ActionMap['edit']
1526
- draftId: string
1527
- publishedId: string
1528
- patch: PatchOperations
1529
- }
1530
- | ({
1531
- actionType: ActionMap['publish']
1532
- draftId: string
1533
- publishedId: string
1534
- } & OptimisticLock)
774
+ /** Describes a type node for array values. */
1535
775
 
1536
- declare interface InRangeNode extends BaseNode {
1537
- type: 'InRange'
1538
- base: ExprNode
1539
- left: ExprNode
1540
- right: ExprNode
1541
- isInclusive: boolean
776
+ declare type ArrayValue = StaticValue<unknown[], 'array'>;
777
+ declare interface AscNode extends BaseNode {
778
+ type: 'Asc';
779
+ base: ExprNode;
1542
780
  }
1543
781
 
1544
- /**
1545
- * Given a document type TDocument and a JSON Match path string TPath,
1546
- * compute the type found at that path.
1547
- * @beta
1548
- */
1549
- export declare type JsonMatch<TDocument, TPath extends string> = DeepGet<
1550
- TDocument,
1551
- PathParts<TPath>
1552
- >
782
+ /** The base interface for SyntaxNode. */
783
+ declare interface BaseNode {
784
+ type: string;
785
+ }
1553
786
 
1554
- /**
1555
- * A very simplified implementation of [JSONMatch][0] that only supports:
1556
- * - descent e.g. `friend.name`
1557
- * - array index e.g. `items[-1]`
1558
- * - array matching with `_key` e.g. `items[_key=="dd9efe09"]`
1559
- * - array matching with a range e.g. `items[4:]`
1560
- *
1561
- * E.g. `friends[_key=="dd9efe09"].address.zip`
1562
- *
1563
- * [0]: https://www.sanity.io/docs/json-match
1564
- *
1565
- * @beta
1566
- */
1567
- export declare function jsonMatch<TDocument, TPath extends string>(
1568
- input: TDocument,
1569
- path: TPath,
1570
- ): MatchEntry<JsonMatch<TDocument, TPath>>[]
787
+ /** Describes a type node for boolean values, optionally including a value. If a value is provided it will always be the given boolean value. */
1571
788
 
1572
- /** @beta */
1573
- export declare function jsonMatch<TValue>(input: unknown, path: string): MatchEntry<TValue>[]
789
+ declare type BooleanValue = StaticValue<boolean, 'boolean'>;
790
+ declare interface Context {
791
+ timestamp: Date;
792
+ identity: string;
793
+ before: Value | null;
794
+ after: Value | null;
795
+ sanity?: {
796
+ projectId: string;
797
+ dataset: string;
798
+ };
799
+ dereference?: DereferenceFunction;
800
+ }
801
+ declare interface ContextNode extends BaseNode {
802
+ type: 'Context';
803
+ key: string;
804
+ }
1574
805
 
1575
806
  /**
1576
- * Loads more users for a specific resource.
1577
- *
1578
- * This function triggers a request to fetch the next page of users for a given resource. It
1579
- * requires that users have already been loaded for the resource (via `resolveUsers` or
1580
- * `getUsersState`), and that there are more users available to load (as indicated by the `hasMore`
1581
- * property).
1582
- *
1583
- * The function returns a promise that resolves when the next page of users has been loaded.
1584
- *
1585
- * @beta
807
+ * createReferenceTypeNode creates a ObjectTypeNode representing a reference type
808
+ * it adds required attributes for a reference type.
809
+ * @param name - The name of the reference type
810
+ * @param inArray - Whether the reference is in an array
811
+ * @returns A ObjectTypeNode representing a reference type
812
+ * @internal
1586
813
  */
1587
- export declare const loadMoreUsers: BoundStoreAction<
1588
- UsersStoreState,
1589
- [options?: GetUsersOptions | undefined],
1590
- Promise<{
1591
- data: SanityUser_2[]
1592
- totalCount: number
1593
- hasMore: boolean
1594
- }>
1595
- >
1596
814
 
1597
- /**
1598
- * Logged-in state from the auth state.
1599
- * @public
1600
- */
1601
- export declare type LoggedInAuthState = {
1602
- type: AuthStateType.LOGGED_IN
1603
- token: string
1604
- currentUser: CurrentUser | null
815
+ declare class DateTime {
816
+ date: Date;
817
+ constructor(date: Date);
818
+ static parseToValue(str: string): Value;
819
+ equals(other: DateTime): boolean;
820
+ add(secs: number): DateTime;
821
+ difference(other: DateTime): number;
822
+ compareTo(other: DateTime): number;
823
+ toString(): string;
824
+ toJSON(): string;
825
+ }
826
+ declare type DateTimeValue = StaticValue<DateTime, 'datetime'>;
827
+ declare type DereferenceFunction = (obj: {
828
+ _ref: string;
829
+ }) => PromiseLike<Document_2 | null | undefined>;
830
+ declare interface DerefNode extends BaseNode {
831
+ type: 'Deref';
832
+ base: ExprNode;
1605
833
  }
1606
-
1607
- /**
1608
- * Logged-out state from the auth state.
1609
- * @public
1610
- */
1611
- export declare type LoggedOutAuthState = {
1612
- type: AuthStateType.LOGGED_OUT
1613
- isDestroyingSession: boolean
834
+ declare interface DescNode extends BaseNode {
835
+ type: 'Desc';
836
+ base: ExprNode;
1614
837
  }
1615
-
1616
- /**
1617
- * Logging-in state from the auth state.
1618
- * @public
1619
- */
1620
- export declare type LoggingInAuthState = {
1621
- type: AuthStateType.LOGGING_IN
1622
- isExchangingToken: boolean
838
+ declare type Document_2 = {
839
+ _id?: string;
840
+ _type?: string;
841
+ [T: string]: unknown;
842
+ };
843
+ declare interface EverythingNode extends BaseNode {
844
+ type: 'Everything';
1623
845
  }
846
+ declare type Executor<N = ExprNode> = (node: N, scope: Scope) => Value | PromiseLike<Value>;
1624
847
 
1625
848
  /**
849
+ * A node which can be evaluated into a value.
1626
850
  * @public
1627
851
  */
1628
- export declare const logout: BoundStoreAction<AuthStoreState_2, [], Promise<void>>
1629
-
1630
- declare interface MapNode extends BaseNode {
1631
- type: 'Map'
1632
- base: ExprNode
1633
- expr: ExprNode
852
+ declare type ExprNode = AccessAttributeNode | AccessElementNode | AndNode | ArrayNode | ArrayCoerceNode | AscNode | ContextNode | DerefNode | DescNode | EverythingNode | FilterNode | FlatMapNode | FuncCallNode | GroupNode | InRangeNode | MapNode | NegNode | NotNode | ObjectNode | OpCallNode | OrNode | ParameterNode | ParentNode_2 | PipeFuncCallNode | PosNode | ProjectionNode | SelectNode | SelectorNode | SliceNode | ThisNode | TupleNode | ValueNode;
853
+ declare interface FilterNode extends BaseNode {
854
+ type: 'Filter';
855
+ base: ExprNode;
856
+ expr: ExprNode;
1634
857
  }
1635
-
1636
- declare type MatchEntry<T = unknown> = {
1637
- value: T
1638
- path: SingleValuePath
858
+ declare interface FlatMapNode extends BaseNode {
859
+ type: 'FlatMap';
860
+ base: ExprNode;
861
+ expr: ExprNode;
1639
862
  }
1640
-
1641
- /**
1642
- * @public
1643
- */
1644
- export declare interface Membership {
1645
- addedAt?: string
1646
- resourceType: string
1647
- resourceId: string
1648
- roleNames: Array<string>
1649
- lastSeenAt?: string | null
863
+ declare interface FuncCallNode extends BaseNode {
864
+ type: 'FuncCall';
865
+ func: GroqFunction;
866
+ namespace: string;
867
+ name: string;
868
+ args: ExprNode[];
1650
869
  }
1651
870
 
1652
- declare interface NegNode extends BaseNode {
1653
- type: 'Neg'
1654
- base: ExprNode
1655
- }
871
+ /** @public */
872
+ declare type GroqFunction = (args: GroqFunctionArg[], scope: Scope, execute: Executor) => PromiseLike<Value>;
1656
873
 
1657
- /**
1658
- * Message from Parent (dashboard) to SDK (iframe) with the new token
1659
- * @internal
1660
- */
1661
- export declare type NewTokenResponseMessage = {
1662
- type: 'dashboard/v1/auth/tokens/create'
1663
- payload: {
1664
- token: string | null
1665
- error?: string
1666
- }
1667
- }
874
+ /** @public */
875
+ declare type GroqFunctionArg = ExprNode;
876
+ declare type GroqPipeFunction = (base: Value, args: ExprNode[], scope: Scope, execute: Executor) => PromiseLike<Value>;
1668
877
 
1669
878
  /**
1670
- * Individual node with its relevant options
1671
- * @public
879
+ * A type of a value in GROQ.
1672
880
  */
1673
- declare interface NodeEntry {
1674
- node: Node_2<WindowMessage, FrameMessage>
1675
- options: NodeInput
1676
- status: Status
1677
- statusUnsub?: () => void
881
+ declare type GroqType = 'null' | 'boolean' | 'number' | 'string' | 'array' | 'object' | 'path' | 'datetime';
882
+ declare interface GroupNode extends BaseNode {
883
+ type: 'Group';
884
+ base: ExprNode;
1678
885
  }
1679
886
 
1680
- /**
1681
- * @public
1682
- */
1683
- export declare interface NodeState {
1684
- node: Node_2<WindowMessage, FrameMessage>
1685
- status: Status | undefined
1686
- }
887
+ /** Describes a type node for inline values, including a name that references another type. */
1687
888
 
889
+ declare interface InRangeNode extends BaseNode {
890
+ type: 'InRange';
891
+ base: ExprNode;
892
+ left: ExprNode;
893
+ right: ExprNode;
894
+ isInclusive: boolean;
895
+ }
896
+ declare interface MapNode extends BaseNode {
897
+ type: 'Map';
898
+ base: ExprNode;
899
+ expr: ExprNode;
900
+ }
901
+ declare interface NegNode extends BaseNode {
902
+ type: 'Neg';
903
+ base: ExprNode;
904
+ }
1688
905
  declare interface NotNode extends BaseNode {
1689
- type: 'Not'
1690
- base: ExprNode
906
+ type: 'Not';
907
+ base: ExprNode;
1691
908
  }
1692
909
 
1693
- declare type NullValue = StaticValue<null, 'null'>
910
+ /** Describes a type node for null values, always being the null value. */
911
+
912
+ declare type NullValue = StaticValue<null, 'null'>;
1694
913
 
1695
- declare type NumberValue = StaticValue<number, 'number'>
914
+ /** Describes a type node for number values, optionally including a value. If a value is provided it will always be the given numeric value.*/
1696
915
 
1697
- declare type ObjectAttributeNode =
1698
- | ObjectAttributeValueNode
1699
- | ObjectConditionalSplatNode
1700
- | ObjectSplatNode
916
+ declare type NumberValue = StaticValue<number, 'number'>;
1701
917
 
918
+ /** Describes a type node for object attributes, including a type and an optional flag for being optional. */
919
+
920
+ declare type ObjectAttributeNode = ObjectAttributeValueNode | ObjectConditionalSplatNode | ObjectSplatNode;
1702
921
  declare interface ObjectAttributeValueNode extends BaseNode {
1703
- type: 'ObjectAttributeValue'
1704
- name: string
1705
- value: ExprNode
922
+ type: 'ObjectAttributeValue';
923
+ name: string;
924
+ value: ExprNode;
1706
925
  }
1707
-
1708
926
  declare interface ObjectConditionalSplatNode extends BaseNode {
1709
- type: 'ObjectConditionalSplat'
1710
- condition: ExprNode
1711
- value: ExprNode
927
+ type: 'ObjectConditionalSplat';
928
+ condition: ExprNode;
929
+ value: ExprNode;
1712
930
  }
1713
-
1714
931
  declare interface ObjectNode extends BaseNode {
1715
- type: 'Object'
1716
- attributes: ObjectAttributeNode[]
932
+ type: 'Object';
933
+ attributes: ObjectAttributeNode[];
1717
934
  }
1718
-
1719
935
  declare interface ObjectSplatNode extends BaseNode {
1720
- type: 'ObjectSplat'
1721
- value: ExprNode
936
+ type: 'ObjectSplat';
937
+ value: ExprNode;
1722
938
  }
1723
939
 
1724
- declare type ObjectValue = StaticValue<Record<string, unknown>, 'object'>
1725
-
1726
940
  /**
1727
- * Creates an observable that emits the organization verification state for a given instance.
1728
- * It combines the dashboard organization ID (from auth context) with the
1729
- * project's actual organization ID (fetched via getProjectState) and compares them.
1730
- * @public
941
+ * Describes a type node for object values, including a collection of attributes and an optional rest value.
942
+ * The rest value can be another ObjectTypeNode, an UnknownTypeNode, or an InlineTypeNode.
943
+ * If the rest value is an ObjectTypeNode, it means that the object can have additional attributes.
944
+ * If the rest value is an UnknownTypeNode, the entire object is unknown.
945
+ * If the rest value is an InlineTypeNode, it means that the object has additional attributes from the referenced type.
1731
946
  */
1732
- export declare function observeOrganizationVerificationState(
1733
- instance: SanityInstance,
1734
- projectIds: string[],
1735
- ): Observable<OrgVerificationResult>
1736
-
1737
- declare type OpCall =
1738
- | '=='
1739
- | '!='
1740
- | '>'
1741
- | '>='
1742
- | '<'
1743
- | '<='
1744
- | '+'
1745
- | '-'
1746
- | '*'
1747
- | '/'
1748
- | '%'
1749
- | '**'
1750
- | 'in'
1751
- | 'match'
1752
947
 
948
+ declare type ObjectValue = StaticValue<Record<string, unknown>, 'object'>;
949
+ declare type OpCall = '==' | '!=' | '>' | '>=' | '<' | '<=' | '+' | '-' | '*' | '/' | '%' | '**' | 'in' | 'match';
1753
950
  declare interface OpCallNode extends BaseNode {
1754
- type: 'OpCall'
1755
- op: OpCall
1756
- left: ExprNode
1757
- right: ExprNode
1758
- }
1759
-
1760
- declare type OptimisticLock = {
1761
- ifDraftRevisionId?: string
1762
- ifPublishedRevisionId?: string
1763
- }
1764
-
1765
- /**
1766
- * Error message returned by the organization verification
1767
- * @public
1768
- */
1769
- export declare interface OrgVerificationResult {
1770
- error: string | null
951
+ type: 'OpCall';
952
+ op: OpCall;
953
+ left: ExprNode;
954
+ right: ExprNode;
1771
955
  }
1772
-
1773
956
  declare interface OrNode extends BaseNode {
1774
- type: 'Or'
1775
- left: ExprNode
1776
- right: ExprNode
1777
- }
1778
-
1779
- /**
1780
- * Represents a set of applied transactions batched into a single outgoing
1781
- * transaction. An outgoing transaction is the result of batching many applied
1782
- * actions. An outgoing transaction may be reverted locally if the server
1783
- * does not accept it.
1784
- */
1785
- declare interface OutgoingTransaction extends AppliedTransaction {
1786
- disableBatching: boolean
1787
- batchedTransactionIds: string[]
957
+ type: 'Or';
958
+ left: ExprNode;
959
+ right: ExprNode;
1788
960
  }
1789
-
1790
961
  declare interface ParameterNode extends BaseNode {
1791
- type: 'Parameter'
1792
- name: string
962
+ type: 'Parameter';
963
+ name: string;
1793
964
  }
1794
-
1795
965
  declare interface ParentNode_2 extends BaseNode {
1796
- type: 'Parent'
1797
- n: number
966
+ type: 'Parent';
967
+ n: number;
968
+ }
969
+ declare class Path {
970
+ private pattern;
971
+ private patternRe;
972
+ constructor(pattern: string);
973
+ matches(str: string): boolean;
974
+ toJSON(): string;
975
+ }
976
+ declare type PathValue = StaticValue<Path, 'path'>;
977
+ declare interface PipeFuncCallNode extends BaseNode {
978
+ type: 'PipeFuncCall';
979
+ func: GroqPipeFunction;
980
+ base: ExprNode;
981
+ name: string;
982
+ args: ExprNode[];
983
+ }
984
+ declare interface PosNode extends BaseNode {
985
+ type: 'Pos';
986
+ base: ExprNode;
1798
987
  }
1799
988
 
1800
- /** @beta */
1801
- export declare const parseQueryKey: (key: string) => QueryOptions
989
+ /** Union of any primitive type nodes. */
1802
990
 
1803
- /** @internal */
1804
- export declare const parseUsersKey: (key: string) => {
1805
- batchSize: number
1806
- resourceType?: 'organization' | 'project'
1807
- projectId?: string
1808
- organizationId?: string
991
+ declare interface ProjectionNode extends BaseNode {
992
+ type: 'Projection';
993
+ base: ExprNode;
994
+ expr: ExprNode;
1809
995
  }
1810
996
 
1811
- declare class Path {
1812
- private pattern
1813
- private patternRe
1814
- constructor(pattern: string)
1815
- matches(str: string): boolean
1816
- toJSON(): string
1817
- }
997
+ /** A schema consisting of a list of Document or TypeDeclaration items, allowing for complex type definitions. */
1818
998
 
1819
- /**
1820
- * Split the entire path string on dots "outside" of any brackets.
1821
- *
1822
- * For example:
1823
- * ```
1824
- * "friends[0].name"
1825
- * ```
1826
- *
1827
- * becomes:
1828
- *
1829
- * ```
1830
- * [...ParseSegment<"friends[0]">, ...ParseSegment<"name">]
1831
- * ```
1832
- *
1833
- * (We use a simple recursion that splits on the first dot.)
1834
- */
1835
- declare type PathParts<TPath extends string> = TPath extends `${infer Head}.${infer Tail}`
1836
- ? [Head, ...PathParts<Tail>]
1837
- : TPath extends ''
1838
- ? []
1839
- : [TPath]
999
+ declare class Scope {
1000
+ params: Record<string, unknown>;
1001
+ source: Value;
1002
+ value: Value;
1003
+ parent: Scope | null;
1004
+ context: Context;
1005
+ isHidden: boolean;
1006
+ constructor(params: Record<string, unknown>, source: Value, value: Value, context: Context, parent: Scope | null);
1007
+ createNested(value: Value): Scope;
1008
+ createHidden(value: Value): Scope;
1009
+ }
1010
+ declare interface SelectAlternativeNode extends BaseNode {
1011
+ type: 'SelectAlternative';
1012
+ condition: ExprNode;
1013
+ value: ExprNode;
1014
+ }
1015
+ declare interface SelectNode extends BaseNode {
1016
+ type: 'Select';
1017
+ alternatives: SelectAlternativeNode[];
1018
+ fallback?: ExprNode;
1019
+ }
1020
+ declare interface SelectorNode extends BaseNode {
1021
+ type: 'Selector';
1022
+ }
1023
+ declare interface SliceNode extends BaseNode {
1024
+ type: 'Slice';
1025
+ base: ExprNode;
1026
+ left: number;
1027
+ right: number;
1028
+ isInclusive: boolean;
1029
+ }
1030
+ declare class StaticValue<P, T extends GroqType> {
1031
+ data: P;
1032
+ type: T;
1033
+ constructor(data: P, type: T);
1034
+ isArray(): boolean;
1035
+ get(): Promise<any>;
1036
+ [Symbol.asyncIterator](): Generator<Value, void, unknown>;
1037
+ }
1038
+ declare class StreamValue {
1039
+ type: 'stream';
1040
+ private generator;
1041
+ private ticker;
1042
+ private isDone;
1043
+ private data;
1044
+ constructor(generator: () => AsyncGenerator<Value, void, unknown>);
1045
+ isArray(): boolean;
1046
+ get(): Promise<any>;
1047
+ [Symbol.asyncIterator](): AsyncGenerator<Value, void, unknown>;
1048
+ _nextTick(): Promise<void>;
1049
+ }
1840
1050
 
1841
- declare type PathValue = StaticValue<Path, 'path'>
1051
+ /** Describes a type node for string values, optionally including a value. If a value is provided it will always be the given string value. */
1842
1052
 
1843
- /** @beta */
1844
- export declare interface PermissionDeniedReason {
1845
- type: 'precondition' | 'access'
1846
- message: string
1847
- documentId?: string
1848
- }
1053
+ declare type StringValue = StaticValue<string, 'string'>;
1849
1054
 
1850
- /**
1851
- * @public
1852
- */
1853
- export declare interface PerspectiveHandle {
1854
- perspective?: ClientPerspective | ReleasePerspective
1855
- }
1055
+ /** Any sort of node which appears as syntax */
1856
1056
 
1857
- declare interface PipeFuncCallNode extends BaseNode {
1858
- type: 'PipeFuncCall'
1859
- func: GroqPipeFunction
1860
- base: ExprNode
1861
- name: string
1862
- args: ExprNode[]
1057
+ declare interface ThisNode extends BaseNode {
1058
+ type: 'This';
1863
1059
  }
1864
-
1865
- declare interface PosNode extends BaseNode {
1866
- type: 'Pos'
1867
- base: ExprNode
1060
+ declare interface TupleNode extends BaseNode {
1061
+ type: 'Tuple';
1062
+ members: Array<ExprNode>;
1868
1063
  }
1869
1064
 
1870
- /**
1871
- * Represents a media asset in a preview.
1872
- *
1873
- * @public
1874
- */
1875
- declare interface PreviewMedia {
1876
- type: 'image-asset'
1877
- _ref: string
1878
- url: string
1879
- }
1065
+ /** Defines a type declaration with a specific name and a value that describes the structure of the type using a TypeNode. */
1880
1066
 
1881
1067
  /**
1882
- * @public
1068
+ * The result of an expression.
1883
1069
  */
1884
- export declare interface PreviewStoreState {
1885
- values: {
1886
- [TDocumentId in string]?: ValuePending<PreviewValue>
1887
- }
1888
- subscriptions: {
1889
- [TDocumentId in string]?: {
1890
- [TSubscriptionId in string]?: true
1891
- }
1892
- }
1070
+ declare type Value = AnyStaticValue | StreamValue;
1071
+ declare interface ValueNode<P = any> {
1072
+ type: 'Value';
1073
+ value: P;
1893
1074
  }
1894
-
1895
1075
  /**
1896
- * Represents the set of values displayed as a preview for a given Sanity document.
1897
- * This includes a primary title, a secondary subtitle, an optional piece of media associated
1898
- * with the document, and the document's status.
1076
+ * Represents a reactive state source that provides synchronized access to store data
1077
+ *
1078
+ * @remarks
1079
+ * Designed to work with React's useSyncExternalStore hook. Provides three ways to access data:
1080
+ * 1. `getCurrent()` for synchronous current value access
1081
+ * 2. `subscribe()` for imperative change notifications
1082
+ * 3. `observable` for reactive stream access
1899
1083
  *
1900
1084
  * @public
1901
1085
  */
1902
- export declare interface PreviewValue {
1903
- /**
1904
- * The primary text displayed for the document preview.
1905
- */
1906
- title: string
1086
+ interface StateSource<T> {
1907
1087
  /**
1908
- * A secondary line of text providing additional context about the document.
1088
+ * Subscribes to state changes with optional callback
1089
+ * @param onStoreChanged - Called whenever relevant state changes occur
1090
+ * @returns Unsubscribe function to clean up the subscription
1909
1091
  */
1910
- subtitle?: string
1092
+ subscribe: (onStoreChanged?: () => void) => () => void;
1911
1093
  /**
1912
- * An optional piece of media representing the document within its preview.
1913
- * Currently, only image assets are available.
1094
+ * Gets the current derived state value
1095
+ *
1096
+ * @remarks
1097
+ * Safe to call without subscription. Will always return the latest value
1098
+ * based on the current store state and selector parameters.
1914
1099
  */
1915
- media?: PreviewMedia | null
1100
+ getCurrent: () => T;
1916
1101
  /**
1917
- * The status of the document.
1102
+ * Observable stream of state values
1103
+ *
1104
+ * @remarks
1105
+ * Shares a single underlying subscription between all observers. Emits:
1106
+ * - Immediately with current value on subscription
1107
+ * - On every relevant state change
1108
+ * - Errors if selector throws
1918
1109
  */
1919
- _status?: {
1920
- /** The date of the last published edit */
1921
- lastEditedPublishedAt?: string
1922
- /** The date of the last draft edit */
1923
- lastEditedDraftAt?: string
1924
- }
1110
+ observable: Observable<T>;
1925
1111
  }
1926
-
1927
1112
  /**
1928
- * Represents the minimal configuration required to identify a Sanity project.
1929
- * @public
1113
+ * Context passed to selectors when deriving state
1114
+ *
1115
+ * @remarks
1116
+ * Provides access to both the current state value and the Sanity instance,
1117
+ * allowing selectors to use configuration values when computing derived state.
1118
+ * The context is memoized for each state object and instance combination
1119
+ * to optimize performance and prevent unnecessary recalculations.
1120
+ *
1121
+ * @example
1122
+ * ```ts
1123
+ * // Using both state and instance in a selector (psuedo example)
1124
+ * const getUserByProjectId = createStateSourceAction(
1125
+ * ({ state, instance }: SelectorContext<UsersState>, options?: ProjectHandle) => {
1126
+ * const allUsers = state.users
1127
+ * const projectId = options?.projectId ?? instance.config.projectId
1128
+ * return allUsers.filter(user => user.projectId === projectId)
1129
+ * }
1130
+ * )
1131
+ * ```
1930
1132
  */
1931
- export declare interface ProjectHandle<TProjectId extends string = string> {
1932
- projectId?: TProjectId
1933
- }
1934
-
1935
- declare interface ProjectionNode extends BaseNode {
1936
- type: 'Projection'
1937
- base: ExprNode
1938
- expr: ExprNode
1939
- }
1940
-
1941
- declare interface ProjectionOptions<
1942
- TProjection extends ValidProjection = ValidProjection,
1943
- TDocumentType extends string = string,
1944
- TDataset extends string = string,
1945
- TProjectId extends string = string,
1946
- > extends DocumentHandle<TDocumentType, TDataset, TProjectId> {
1947
- projection: TProjection
1133
+ interface SelectorContext<TState> {
1134
+ /**
1135
+ * The current state object from the store
1136
+ */
1137
+ state: TState;
1138
+ /**
1139
+ * The Sanity instance associated with this state
1140
+ */
1141
+ instance: SanityInstance;
1948
1142
  }
1949
-
1950
1143
  /**
1144
+ * Function type for selecting derived state from store state and parameters
1951
1145
  * @public
1952
- * The result of a projection query
1953
- */
1954
- export declare interface ProjectionValuePending<TValue extends object> {
1955
- data: TValue | null
1956
- isPending: boolean
1957
- }
1958
-
1959
- /**
1960
- * Creates a `PublishDocumentAction` object.
1961
- * @param doc - A handle uniquely identifying the document to be published.
1962
- * @returns A `PublishDocumentAction` object ready for dispatch.
1963
- * @beta
1964
- */
1965
- export declare function publishDocument<
1966
- TDocumentType extends string = string,
1967
- TDataset extends string = string,
1968
- TProjectId extends string = string,
1969
- >(
1970
- doc: DocumentHandle<TDocumentType, TDataset, TProjectId>,
1971
- ): PublishDocumentAction<TDocumentType, TDataset, TProjectId>
1972
-
1973
- /**
1974
- * Represents an action to publish the draft version of a document.
1975
- * Requires the full document handle.
1976
- * @beta
1977
- */
1978
- export declare interface PublishDocumentAction<
1979
- TDocumentType extends string = string,
1980
- TDataset extends string = string,
1981
- TProjectId extends string = string,
1982
- > extends DocumentHandle<TDocumentType, TDataset, TProjectId> {
1983
- type: 'document.publish'
1984
- }
1985
-
1986
- /**
1987
- * @beta
1988
1146
  */
1989
- export declare interface QueryOptions<
1990
- TQuery extends string = string,
1991
- TDataset extends string = string,
1992
- TProjectId extends string = string,
1993
- > extends Pick<ResponseQueryOptions, 'useCdn' | 'cache' | 'next' | 'cacheMode' | 'tag'>,
1994
- DatasetHandle<TDataset, TProjectId> {
1995
- query: TQuery
1996
- params?: Record<string, unknown>
1997
- }
1998
-
1147
+ type Selector<TState, TParams extends unknown[], TReturn> = (context: SelectorContext<TState>, ...params: TParams) => TReturn;
1148
+ /**
1149
+ * Configuration options for creating a state source action
1150
+ */
1151
+ type ActionMap = {
1152
+ create: 'sanity.action.document.version.create';
1153
+ discard: 'sanity.action.document.version.discard';
1154
+ unpublish: 'sanity.action.document.unpublish';
1155
+ delete: 'sanity.action.document.delete';
1156
+ edit: 'sanity.action.document.edit';
1157
+ publish: 'sanity.action.document.publish';
1158
+ };
1159
+ type OptimisticLock = {
1160
+ ifDraftRevisionId?: string;
1161
+ ifPublishedRevisionId?: string;
1162
+ };
1163
+ type HttpAction = {
1164
+ actionType: ActionMap['create'];
1165
+ publishedId: string;
1166
+ attributes: SanityDocumentLike;
1167
+ } | {
1168
+ actionType: ActionMap['discard'];
1169
+ versionId: string;
1170
+ purge?: boolean;
1171
+ } | {
1172
+ actionType: ActionMap['unpublish'];
1173
+ draftId: string;
1174
+ publishedId: string;
1175
+ } | {
1176
+ actionType: ActionMap['delete'];
1177
+ publishedId: string;
1178
+ includeDrafts?: string[];
1179
+ } | {
1180
+ actionType: ActionMap['edit'];
1181
+ draftId: string;
1182
+ publishedId: string;
1183
+ patch: PatchOperations;
1184
+ } | ({
1185
+ actionType: ActionMap['publish'];
1186
+ draftId: string;
1187
+ publishedId: string;
1188
+ } & OptimisticLock);
1999
1189
  /**
2000
1190
  * Represents a transaction that is queued to be applied but has not yet been
2001
1191
  * applied. A transaction will remain in a queued state until all required
2002
1192
  * documents for the transactions are available locally.
2003
1193
  */
2004
- declare interface QueuedTransaction {
1194
+ interface QueuedTransaction {
2005
1195
  /**
2006
1196
  * the ID of this transaction. this is generated client-side.
2007
1197
  */
2008
- transactionId: string
1198
+ transactionId: string;
2009
1199
  /**
2010
1200
  * the high-level actions associated with this transaction. note that these
2011
1201
  * actions don't mention draft IDs and is meant to abstract away the draft
2012
1202
  * model from users.
2013
1203
  */
2014
- actions: DocumentAction[]
1204
+ actions: DocumentAction[];
2015
1205
  /**
2016
1206
  * An optional flag set to disable this transaction from being batched with
2017
1207
  * other transactions.
2018
1208
  */
2019
- disableBatching?: boolean
1209
+ disableBatching?: boolean;
2020
1210
  }
2021
-
2022
1211
  /**
2023
- * Signals to the store that the consumer has stopped using the channel
2024
- * @public
1212
+ * Represents a transaction that has been applied locally but has not been
1213
+ * committed/transitioned-to-outgoing. These transactions are visible to the
1214
+ * user but may be rebased upon a new working document set. Applied transactions
1215
+ * also contain the resulting `outgoingActions` that will be submitted to
1216
+ * Content Lake. These `outgoingActions` depend on the state of the working
1217
+ * documents so they are recomputed on rebase and are only relevant to applied
1218
+ * actions (we cannot compute `outgoingActions` for queued transactions because
1219
+ * we haven't resolved the set of documents the actions are dependent on yet).
1220
+ *
1221
+ * In order to support better conflict resolution, the original `previous` set
1222
+ * is saved as the `base` set.
2025
1223
  */
2026
- export declare const releaseChannel: BoundStoreAction_2<
2027
- ComlinkControllerState,
2028
- [name: string],
2029
- void
2030
- >
2031
-
1224
+ interface AppliedTransaction extends QueuedTransaction {
1225
+ /**
1226
+ * the resulting set of documents after the actions have been applied
1227
+ */
1228
+ working: DocumentSet;
1229
+ /**
1230
+ * the previous set of documents before the action was applied
1231
+ */
1232
+ previous: DocumentSet;
1233
+ /**
1234
+ * the original `previous` document set captured when this action was
1235
+ * originally applied. this is used as a reference point to do a 3-way merge
1236
+ * if this applied transaction ever needs to be reapplied on a different
1237
+ * set of documents.
1238
+ */
1239
+ base: DocumentSet;
1240
+ /**
1241
+ * the `_rev`s from `previous` document set
1242
+ */
1243
+ previousRevs: { [TDocumentId in string]?: string };
1244
+ /**
1245
+ * a timestamp for when this transaction was applied locally
1246
+ */
1247
+ timestamp: string;
1248
+ /**
1249
+ * the resulting HTTP actions derived from the state of the `working` document
1250
+ * set. these are sent to Content Lake as-is when this transaction is batched
1251
+ * and transitioned into an outgoing transaction.
1252
+ */
1253
+ outgoingActions: HttpAction[];
1254
+ /**
1255
+ * similar to `outgoingActions` but comprised of mutations instead of action.
1256
+ * this left here for debugging purposes but could be used to send mutations
1257
+ * to Content Lake instead of actions.
1258
+ */
1259
+ outgoingMutations: Mutation[];
1260
+ }
2032
1261
  /**
2033
- * Represents a document in a Sanity dataset that represents release options.
2034
- * @internal
1262
+ * Represents a set of applied transactions batched into a single outgoing
1263
+ * transaction. An outgoing transaction is the result of batching many applied
1264
+ * actions. An outgoing transaction may be reverted locally if the server
1265
+ * does not accept it.
2035
1266
  */
2036
- export declare type ReleaseDocument = SanityDocument & {
2037
- name: string
2038
- publishAt?: string
2039
- state: 'active' | 'scheduled'
2040
- metadata: {
2041
- title: string
2042
- releaseType: 'asap' | 'scheduled' | 'undecided'
2043
- intendedPublishAt?: string
2044
- description?: string
2045
- }
1267
+ interface OutgoingTransaction extends AppliedTransaction {
1268
+ disableBatching: boolean;
1269
+ batchedTransactionIds: string[];
2046
1270
  }
2047
-
1271
+ interface UnverifiedDocumentRevision {
1272
+ transactionId: string;
1273
+ documentId: string;
1274
+ previousRev: string | undefined;
1275
+ timestamp: string;
1276
+ }
1277
+ type Grant = 'read' | 'update' | 'create' | 'history';
1278
+ /** @beta */
1279
+ interface PermissionDeniedReason {
1280
+ type: 'precondition' | 'access';
1281
+ message: string;
1282
+ documentId?: string;
1283
+ }
1284
+ /** @beta */
1285
+ type DocumentPermissionsResult = {
1286
+ allowed: false;
1287
+ message: string;
1288
+ reasons: PermissionDeniedReason[];
1289
+ } | {
1290
+ allowed: true;
1291
+ message?: undefined;
1292
+ reasons?: undefined;
1293
+ };
1294
+ /** @beta */
1295
+ type DocumentEvent = ActionErrorEvent | TransactionRevertedEvent | TransactionAcceptedEvent | DocumentRebaseErrorEvent | DocumentEditedEvent | DocumentCreatedEvent | DocumentDeletedEvent | DocumentPublishedEvent | DocumentUnpublishedEvent | DocumentDiscardedEvent;
2048
1296
  /**
2049
- * Signals to the store that the consumer has stopped using the node
2050
- * @public
1297
+ * @beta
1298
+ * Event emitted when a precondition to applying an action fails.
1299
+ * (For example: when trying to edit a document that no longer exists.)
2051
1300
  */
2052
- export declare const releaseNode: BoundStoreAction_2<ComlinkNodeState, [name: string], void>
2053
-
1301
+ interface ActionErrorEvent {
1302
+ type: 'error';
1303
+ documentId: string;
1304
+ transactionId: string;
1305
+ message: string;
1306
+ error: unknown;
1307
+ }
2054
1308
  /**
2055
- * @public
1309
+ * @beta
1310
+ * Event emitted when a transaction is accepted.
2056
1311
  */
2057
- export declare type ReleasePerspective = {
2058
- releaseName: string
2059
- excludedPerspectives?: StackablePerspective[]
1312
+ interface TransactionAcceptedEvent {
1313
+ type: 'accepted';
1314
+ outgoing: OutgoingTransaction;
1315
+ result: Awaited<ReturnType<SanityClient['action']>>;
2060
1316
  }
2061
-
2062
- declare interface ReleasesStoreState {
2063
- activeReleases?: ReleaseDocument[]
2064
- error?: unknown
1317
+ /**
1318
+ * @beta
1319
+ * Event emitted when a transaction is reverted.
1320
+ */
1321
+ interface TransactionRevertedEvent {
1322
+ type: 'reverted';
1323
+ message: string;
1324
+ error: unknown;
1325
+ outgoing: OutgoingTransaction;
2065
1326
  }
2066
-
2067
1327
  /**
2068
- * Message from SDK (iframe) to Parent (dashboard) to request a new token
2069
- * @internal
1328
+ * @beta
1329
+ * Event emitted when an attempt to apply local changes to a modified remote document fails.
2070
1330
  */
2071
- export declare type RequestNewTokenMessage = {
2072
- type: 'dashboard/v1/auth/tokens/create'
2073
- payload?: undefined
1331
+ interface DocumentRebaseErrorEvent {
1332
+ type: 'rebase-error';
1333
+ documentId: string;
1334
+ transactionId: string;
1335
+ message: string;
1336
+ error: unknown;
2074
1337
  }
2075
-
2076
- /** @public */
2077
- export declare const resolveDatasets: BoundStoreAction<
2078
- FetcherStoreState_2<[options?: ProjectHandle<string> | undefined], DatasetsResponse>,
2079
- [options?: ProjectHandle<string> | undefined],
2080
- Promise<DatasetsResponse>
2081
- >
2082
-
2083
- /** @beta */
2084
- export declare function resolveDocument<
2085
- TDocumentType extends string = string,
2086
- TDataset extends string = string,
2087
- TProjectId extends string = string,
2088
- >(
2089
- instance: SanityInstance,
2090
- docHandle: DocumentHandle<TDocumentType, TDataset, TProjectId>,
2091
- ): Promise<SanityDocument_2<TDocumentType, `${TProjectId}.${TDataset}`> | null>
2092
-
2093
- /** @beta */
2094
- export declare function resolveDocument<TData extends SanityDocument_2>(
2095
- instance: SanityInstance,
2096
- docHandle: DocumentHandle<string, string, string>,
2097
- ): Promise<TData | null>
2098
-
2099
1338
  /**
2100
- * Resolves the favorite status for a document.
2101
- * @param instance - The Sanity instance.
2102
- * @param context - The document context including ID, type, and resource information.
2103
- * @returns A Promise resolving to `{ isFavorited: boolean }`.
2104
- * @public
1339
+ * @beta
1340
+ * Event emitted when a document is edited.
2105
1341
  */
2106
- export declare const resolveFavoritesState: BoundStoreAction<
2107
- FetcherStoreState_2<[FavoriteDocumentContext], FavoriteStatusResponse>,
2108
- [FavoriteDocumentContext],
2109
- Promise<FavoriteStatusResponse>
2110
- >
2111
-
2112
- /** @beta */
2113
- export declare const resolvePermissions: BoundStoreAction<
2114
- DocumentStoreState,
2115
- [actions: DocumentAction | DocumentAction[]],
2116
- Promise<DocumentPermissionsResult_2>
2117
- >
2118
-
1342
+ interface DocumentEditedEvent {
1343
+ type: 'edited';
1344
+ documentId: string;
1345
+ outgoing: OutgoingTransaction;
1346
+ }
2119
1347
  /**
2120
1348
  * @beta
1349
+ * Event emitted when a document is created.
2121
1350
  */
2122
- export declare const resolvePreview: BoundStoreAction<
2123
- PreviewStoreState_2,
2124
- [docHandle: ResolvePreviewOptions],
2125
- Promise<ValuePending_2<object>>
2126
- >
2127
-
1351
+ interface DocumentCreatedEvent {
1352
+ type: 'created';
1353
+ documentId: string;
1354
+ outgoing: OutgoingTransaction;
1355
+ }
2128
1356
  /**
2129
1357
  * @beta
1358
+ * Event emitted when a document is deleted.
2130
1359
  */
2131
- export declare type ResolvePreviewOptions = DocumentHandle
2132
-
2133
- /** @public */
2134
- export declare const resolveProject: BoundStoreAction<
2135
- FetcherStoreState_2<[options?: ProjectHandle<string> | undefined], SanityProject_2>,
2136
- [options?: ProjectHandle<string> | undefined],
2137
- Promise<SanityProject_2>
2138
- >
2139
-
2140
- /** @beta */
2141
- export declare function resolveProjection<
2142
- TProjection extends ValidProjection = ValidProjection,
2143
- TDocumentType extends string = string,
2144
- TDataset extends string = string,
2145
- TProjectId extends string = string,
2146
- >(
2147
- instance: SanityInstance,
2148
- options: ProjectionOptions<TProjection, TDocumentType, TDataset, TProjectId>,
2149
- ): Promise<
2150
- ProjectionValuePending<
2151
- SanityProjectionResult<TProjection, TDocumentType, `${TProjectId}.${TDataset}`>
2152
- >
2153
- >
2154
-
2155
- /** @beta */
2156
- export declare function resolveProjection<TData extends object>(
2157
- instance: SanityInstance,
2158
- options: ProjectionOptions,
2159
- ): Promise<ProjectionValuePending<TData>>
2160
-
2161
- /** @public */
2162
- export declare const resolveProjects: BoundStoreAction<
2163
- FetcherStoreState_2<[], Omit<SanityProject_2, 'members'>[]>,
2164
- [],
2165
- Promise<Omit<SanityProject_2, 'members'>[]>
2166
- >
2167
-
1360
+ interface DocumentDeletedEvent {
1361
+ type: 'deleted';
1362
+ documentId: string;
1363
+ outgoing: OutgoingTransaction;
1364
+ }
2168
1365
  /**
2169
- * Resolves the result of a query without registering a lasting subscriber.
2170
- *
2171
- * This function fetches the result of a GROQ query and returns a promise that resolves with the query result.
2172
- * Unlike `getQueryState`, which registers subscribers to keep the query live and performs automatic cleanup,
2173
- * `resolveQuery` does not track subscribers. This makes it ideal for use with React Suspense, where the returned
2174
- * promise is thrown to delay rendering until the query result becomes available.
2175
- * Once the promise resolves, it is expected that a real subscriber will be added via `getQueryState` to manage ongoing updates.
2176
- *
2177
- * Additionally, an optional AbortSignal can be provided to cancel the query and immediately clear the associated state
2178
- * if there are no active subscribers.
2179
- *
2180
1366
  * @beta
1367
+ * Event emitted when a document is published.
2181
1368
  */
2182
- export declare function resolveQuery<
2183
- TQuery extends string = string,
2184
- TDataset extends string = string,
2185
- TProjectId extends string = string,
2186
- >(
2187
- instance: SanityInstance,
2188
- queryOptions: ResolveQueryOptions<TQuery, TDataset, TProjectId>,
2189
- ): Promise<SanityQueryResult<TQuery, `${TProjectId}.${TDataset}`>>
2190
-
2191
- /** @beta */
2192
- export declare function resolveQuery<TData>(
2193
- instance: SanityInstance,
2194
- queryOptions: ResolveQueryOptions,
2195
- ): Promise<TData>
2196
-
1369
+ interface DocumentPublishedEvent {
1370
+ type: 'published';
1371
+ documentId: string;
1372
+ outgoing: OutgoingTransaction;
1373
+ }
2197
1374
  /**
2198
1375
  * @beta
1376
+ * Event emitted when a document is unpublished.
2199
1377
  */
2200
- declare interface ResolveQueryOptions<
2201
- TQuery extends string = string,
2202
- TDataset extends string = string,
2203
- TProjectId extends string = string,
2204
- > extends QueryOptions<TQuery, TDataset, TProjectId> {
2205
- signal?: AbortSignal
1378
+ interface DocumentUnpublishedEvent {
1379
+ type: 'unpublished';
1380
+ documentId: string;
1381
+ outgoing: OutgoingTransaction;
2206
1382
  }
2207
-
2208
1383
  /**
2209
- * Resolves the users for a specific resource without registering a lasting subscriber.
1384
+ * @beta
1385
+ * Event emitted when a document version is discarded.
1386
+ */
1387
+ interface DocumentDiscardedEvent {
1388
+ type: 'discarded';
1389
+ documentId: string;
1390
+ outgoing: OutgoingTransaction;
1391
+ }
1392
+ /**
1393
+ * Split the entire path string on dots "outside" of any brackets.
2210
1394
  *
2211
- * This function fetches the users for a given resource and returns a promise that resolves with
2212
- * the users result. Unlike `getUsersState`, which registers subscribers to keep the data live and
2213
- * performs automatic cleanup, `resolveUsers` does not track subscribers. This makes it ideal for
2214
- * use with React Suspense, where the returned promise is thrown to delay rendering until the users
2215
- * result becomes available. Once the promise resolves, it is expected that a real subscriber will
2216
- * be added via `getUsersState` to manage ongoing updates.
1395
+ * For example:
1396
+ * ```
1397
+ * "friends[0].name"
1398
+ * ```
2217
1399
  *
2218
- * Additionally, an optional AbortSignal can be provided to cancel the request and immediately
2219
- * clear the associated state if there are no active subscribers.
1400
+ * becomes:
2220
1401
  *
2221
- * @beta
1402
+ * ```
1403
+ * [...ParseSegment<"friends[0]">, ...ParseSegment<"name">]
1404
+ * ```
1405
+ *
1406
+ * (We use a simple recursion that splits on the first dot.)
2222
1407
  */
2223
- export declare const resolveUsers: BoundStoreAction<
2224
- UsersStoreState,
2225
- [ResolveUsersOptions],
2226
- Promise<{
2227
- data: SanityUser_2[]
2228
- totalCount: number
2229
- hasMore: boolean
2230
- }>
2231
- >
2232
-
1408
+ type PathParts<TPath extends string> = TPath extends `${infer Head}.${infer Tail}` ? [Head, ...PathParts<Tail>] : TPath extends '' ? [] : [TPath];
2233
1409
  /**
2234
- * @public
1410
+ * Given a type T and an array of "access keys" Parts, recursively index into T.
1411
+ *
1412
+ * If a part is a key, it looks up that property.
1413
+ * If T is an array and the part is a number, it "indexes" into the element type.
2235
1414
  */
2236
- export declare interface ResolveUsersOptions extends GetUsersOptions {
2237
- signal?: AbortSignal
2238
- }
2239
-
2240
- export {Role}
2241
-
1415
+ 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,
1416
+ // Key/index doesn't exist
1417
+ TTail extends readonly (string | number)[] ? TTail : []> : never;
2242
1418
  /**
2243
- * Represents the complete configuration for a Sanity SDK instance
2244
- * @public
1419
+ * Given a document type TDocument and a JSON Match path string TPath,
1420
+ * compute the type found at that path.
1421
+ * @beta
2245
1422
  */
2246
- export declare interface SanityConfig extends DatasetHandle, PerspectiveHandle {
1423
+ type JsonMatch<TDocument, TPath extends string> = DeepGet<TDocument, PathParts<TPath>>;
1424
+ /**
1425
+ * Recursively traverse a value. When an array is encountered, ensure that
1426
+ * each object item has a _key property. Memoized such that sub-objects that
1427
+ * have not changed aren't re-computed.
1428
+ */
1429
+ interface SharedListener {
1430
+ events: Observable<ListenEvent<SanityDocument$1>>;
1431
+ dispose: () => void;
1432
+ }
1433
+ interface DocumentStoreState {
1434
+ documentStates: { [TDocumentId in string]?: DocumentState };
1435
+ queued: QueuedTransaction[];
1436
+ applied: AppliedTransaction[];
1437
+ outgoing?: OutgoingTransaction;
1438
+ grants?: Record<Grant, ExprNode>;
1439
+ error?: unknown;
1440
+ sharedListener: SharedListener;
1441
+ fetchDocument: (documentId: string) => Observable<SanityDocument$3 | null>;
1442
+ events: Subject<DocumentEvent>;
1443
+ }
1444
+ interface DocumentState {
1445
+ id: string;
2247
1446
  /**
2248
- * Authentication configuration for the instance
2249
- * @remarks Merged with parent configurations when using createChild
1447
+ * the "remote" local copy that matches the server. represents the last known
1448
+ * server state. this gets updated every time we confirm remote patches
2250
1449
  */
2251
- auth?: AuthConfig
1450
+ remote?: SanityDocument$3 | null;
2252
1451
  /**
2253
- * Studio mode configuration for use of the SDK in a Sanity Studio
2254
- * @remarks Controls whether studio mode features are enabled
1452
+ * the current ephemeral working copy that includes local optimistic changes
1453
+ * that have not yet been confirmed by the server
2255
1454
  */
2256
- studioMode?: {
2257
- enabled: boolean
2258
- }
2259
- }
2260
-
2261
- export {SanityDocument}
2262
-
2263
- /**
2264
- * Represents a Sanity.io resource instance with its own configuration and lifecycle
2265
- * @remarks Instances form a hierarchy through parent/child relationships
2266
- *
2267
- * @public
2268
- */
2269
- export declare interface SanityInstance {
1455
+ local?: SanityDocument$3 | null;
2270
1456
  /**
2271
- * Unique identifier for this instance
2272
- * @remarks Generated using crypto.randomUUID()
2273
- */
2274
- readonly instanceId: string
2275
- /**
2276
- * Resolved configuration for this instance
2277
- * @remarks Merges values from parent instances where appropriate
2278
- */
2279
- readonly config: SanityConfig
2280
- /**
2281
- * Checks if the instance has been disposed
2282
- * @returns true if dispose() has been called
2283
- */
2284
- isDisposed(): boolean
2285
- /**
2286
- * Disposes the instance and cleans up associated resources
2287
- * @remarks Triggers all registered onDispose callbacks
2288
- */
2289
- dispose(): void
2290
- /**
2291
- * Registers a callback to be invoked when the instance is disposed
2292
- * @param cb - Callback to execute on disposal
2293
- * @returns Function to unsubscribe the callback
2294
- */
2295
- onDispose(cb: () => void): () => void
2296
- /**
2297
- * Gets the parent instance in the hierarchy
2298
- * @returns Parent instance or undefined if this is the root
1457
+ * the revision that our remote document is at
2299
1458
  */
2300
- getParent(): SanityInstance | undefined
1459
+ remoteRev?: string | null;
2301
1460
  /**
2302
- * Creates a child instance with merged configuration
2303
- * @param config - Configuration to merge with parent values
2304
- * @remarks Child instances inherit parent configuration but can override values
1461
+ * Array of subscription IDs. This document state will be deleted if there are
1462
+ * no subscribers.
2305
1463
  */
2306
- createChild(config: SanityConfig): SanityInstance
1464
+ subscriptions: string[];
2307
1465
  /**
2308
- * Traverses the instance hierarchy to find the first instance whose configuration
2309
- * matches the given target config using a shallow comparison.
2310
- * @param targetConfig - A partial configuration object containing key-value pairs to match.
2311
- * @returns The first matching instance or undefined if no match is found.
1466
+ * An object keyed by transaction ID of revisions sent out but that have not
1467
+ * yet been verified yet. When an applied transaction is transitioned to an
1468
+ * outgoing transaction, it also adds unverified revisions for each document
1469
+ * that is part of that outgoing transaction. Transactions are submitted to
1470
+ * the server with a locally generated transaction ID. This way we can observe
1471
+ * when our transaction comes back through the shared listener. Each listener
1472
+ * event that comes back contains a `previousRev`. If we see our own
1473
+ * transaction with a different `previousRev` than expected, we can rebase our
1474
+ * local transactions on top of this new remote.
2312
1475
  */
2313
- match(targetConfig: Partial<SanityConfig>): SanityInstance | undefined
1476
+ unverifiedRevisions?: { [TTransactionId in string]?: UnverifiedDocumentRevision };
2314
1477
  }
2315
-
2316
1478
  /**
2317
- * @public
1479
+ * @beta
1480
+ * Options for specifying a document and optionally a path within it.
2318
1481
  */
2319
- export declare type SanityProject = SanityProject_2
2320
-
1482
+ interface DocumentOptions<TPath extends string | undefined = undefined, TDocumentType extends string = string, TDataset extends string = string, TProjectId extends string = string> extends DocumentHandle<TDocumentType, TDataset, TProjectId> {
1483
+ path?: TPath;
1484
+ }
1485
+ /** @beta */
1486
+ declare function getDocumentState<TDocumentType extends string = string, TDataset extends string = string, TProjectId extends string = string>(instance: SanityInstance, options: DocumentOptions<undefined, TDocumentType, TDataset, TProjectId>): StateSource<SanityDocument$3<TDocumentType, `${TProjectId}.${TDataset}`> | undefined | null>;
1487
+ /** @beta */
1488
+ declare function getDocumentState<TPath extends string = string, TDocumentType extends string = string, TDataset extends string = string, TProjectId extends string = string>(instance: SanityInstance, options: DocumentOptions<TPath, TDocumentType, TDataset, TProjectId>): StateSource<JsonMatch<SanityDocument$3<TDocumentType, `${TProjectId}.${TDataset}`>, TPath> | undefined>;
1489
+ /** @beta */
1490
+ declare function getDocumentState<TData>(instance: SanityInstance, options: DocumentOptions<string | undefined>): StateSource<TData | undefined | null>;
1491
+ /** @beta */
1492
+ declare function resolveDocument<TDocumentType extends string = string, TDataset extends string = string, TProjectId extends string = string>(instance: SanityInstance, docHandle: DocumentHandle<TDocumentType, TDataset, TProjectId>): Promise<SanityDocument$3<TDocumentType, `${TProjectId}.${TDataset}`> | null>;
1493
+ /** @beta */
1494
+ declare function resolveDocument<TData extends SanityDocument$3>(instance: SanityInstance, docHandle: DocumentHandle<string, string, string>): Promise<TData | null>;
1495
+ /** @beta */
1496
+ declare const getDocumentSyncStatus: BoundStoreAction<DocumentStoreState, [doc: DocumentHandle<string, string, string>], StateSource<boolean | undefined>>;
1497
+ /** @beta */
1498
+ declare const getPermissionsState: BoundStoreAction<DocumentStoreState, [DocumentAction | DocumentAction[]], StateSource<DocumentPermissionsResult | undefined>>;
1499
+ /** @beta */
1500
+ declare const resolvePermissions: BoundStoreAction<DocumentStoreState, [actions: DocumentAction | DocumentAction[]], Promise<DocumentPermissionsResult>>;
1501
+ /** @beta */
1502
+ declare const subscribeDocumentEvents: BoundStoreAction<DocumentStoreState, [eventHandler: (e: DocumentEvent) => void], () => void>;
2321
1503
  /**
2322
1504
  * @public
2323
1505
  */
2324
- export declare interface SanityUser {
2325
- sanityUserId: string
2326
- profile: UserProfile
2327
- memberships: Membership[]
2328
- }
2329
-
2330
- declare class Scope {
2331
- params: Record<string, unknown>
2332
- source: Value
2333
- value: Value
2334
- parent: Scope | null
2335
- context: Context
2336
- isHidden: boolean
2337
- constructor(
2338
- params: Record<string, unknown>,
2339
- source: Value,
2340
- value: Value,
2341
- context: Context,
2342
- parent: Scope | null,
2343
- )
2344
- createNested(value: Value): Scope
2345
- createHidden(value: Value): Scope
2346
- }
2347
-
2348
- declare interface SelectAlternativeNode extends BaseNode {
2349
- type: 'SelectAlternative'
2350
- condition: ExprNode
2351
- value: ExprNode
1506
+ interface FavoriteStatusResponse {
1507
+ isFavorited: boolean;
2352
1508
  }
2353
-
2354
- declare interface SelectNode extends BaseNode {
2355
- type: 'Select'
2356
- alternatives: SelectAlternativeNode[]
2357
- fallback?: ExprNode
1509
+ /**
1510
+ * @public
1511
+ */
1512
+ interface FavoriteDocumentContext extends DocumentHandle {
1513
+ resourceId: string;
1514
+ resourceType: StudioResource['type'] | MediaResource['type'] | CanvasResource['type'];
1515
+ schemaName?: string;
2358
1516
  }
2359
-
2360
1517
  /**
2361
- * Function type for selecting derived state from store state and parameters
1518
+ * Gets a StateSource for the favorite status of a document.
1519
+ * @param instance - The Sanity instance.
1520
+ * @param context - The document context including ID, type, and resource information.
1521
+ * @returns A StateSource emitting `{ isFavorited: boolean }`.
2362
1522
  * @public
2363
1523
  */
2364
- export declare type Selector<TState, TParams extends unknown[], TReturn> = (
2365
- context: SelectorContext<TState>,
2366
- ...params: TParams
2367
- ) => TReturn
2368
-
1524
+ declare const getFavoritesState: BoundStoreAction<FetcherStoreState<[FavoriteDocumentContext], FavoriteStatusResponse>, [FavoriteDocumentContext], StateSource<FavoriteStatusResponse | undefined>>;
2369
1525
  /**
2370
- * Context passed to selectors when deriving state
2371
- *
2372
- * @remarks
2373
- * Provides access to both the current state value and the Sanity instance,
2374
- * allowing selectors to use configuration values when computing derived state.
2375
- * The context is memoized for each state object and instance combination
2376
- * to optimize performance and prevent unnecessary recalculations.
2377
- *
2378
- * @example
2379
- * ```ts
2380
- * // Using both state and instance in a selector (psuedo example)
2381
- * const getUserByProjectId = createStateSourceAction(
2382
- * ({ state, instance }: SelectorContext<UsersState>, options?: ProjectHandle) => {
2383
- * const allUsers = state.users
2384
- * const projectId = options?.projectId ?? instance.config.projectId
2385
- * return allUsers.filter(user => user.projectId === projectId)
2386
- * }
2387
- * )
2388
- * ```
1526
+ * Resolves the favorite status for a document.
1527
+ * @param instance - The Sanity instance.
1528
+ * @param context - The document context including ID, type, and resource information.
1529
+ * @returns A Promise resolving to `{ isFavorited: boolean }`.
1530
+ * @public
2389
1531
  */
2390
- declare interface SelectorContext<TState> {
2391
- /**
2392
- * The current state object from the store
2393
- */
2394
- state: TState
2395
- /**
2396
- * The Sanity instance associated with this state
2397
- */
2398
- instance: SanityInstance
2399
- }
2400
-
2401
- declare interface SelectorNode extends BaseNode {
2402
- type: 'Selector'
2403
- }
2404
-
1532
+ declare const resolveFavoritesState: BoundStoreAction<FetcherStoreState<[FavoriteDocumentContext], FavoriteStatusResponse>, [FavoriteDocumentContext], Promise<FavoriteStatusResponse>>;
2405
1533
  /**
2406
- * Action to explicitly set the authentication token.
2407
- * Used internally by the Comlink token refresh.
2408
- * @internal
1534
+ * Represents a media asset in a preview.
1535
+ *
1536
+ * @public
2409
1537
  */
2410
- export declare const setAuthToken: BoundStoreAction<AuthStoreState, [token: string | null], void>
2411
-
2412
- declare interface SharedListener {
2413
- events: Observable<ListenEvent<SanityDocument_3>>
2414
- dispose: () => void
2415
- }
2416
-
2417
- declare type SingleValuePath = Exclude<PathSegment, IndexTuple>[]
2418
-
2419
- declare interface SliceNode extends BaseNode {
2420
- type: 'Slice'
2421
- base: ExprNode
2422
- left: number
2423
- right: number
2424
- isInclusive: boolean
1538
+ interface PreviewMedia {
1539
+ type: 'image-asset';
1540
+ _ref: string;
1541
+ url: string;
2425
1542
  }
2426
-
2427
1543
  /**
2428
- * Represents a reactive state source that provides synchronized access to store data
2429
- *
2430
- * @remarks
2431
- * Designed to work with React's useSyncExternalStore hook. Provides three ways to access data:
2432
- * 1. `getCurrent()` for synchronous current value access
2433
- * 2. `subscribe()` for imperative change notifications
2434
- * 3. `observable` for reactive stream access
1544
+ * Represents the set of values displayed as a preview for a given Sanity document.
1545
+ * This includes a primary title, a secondary subtitle, an optional piece of media associated
1546
+ * with the document, and the document's status.
2435
1547
  *
2436
1548
  * @public
2437
1549
  */
2438
- export declare interface StateSource<T> {
1550
+ interface PreviewValue {
2439
1551
  /**
2440
- * Subscribes to state changes with optional callback
2441
- * @param onStoreChanged - Called whenever relevant state changes occur
2442
- * @returns Unsubscribe function to clean up the subscription
1552
+ * The primary text displayed for the document preview.
2443
1553
  */
2444
- subscribe: (onStoreChanged?: () => void) => () => void
1554
+ title: string;
2445
1555
  /**
2446
- * Gets the current derived state value
2447
- *
2448
- * @remarks
2449
- * Safe to call without subscription. Will always return the latest value
2450
- * based on the current store state and selector parameters.
1556
+ * A secondary line of text providing additional context about the document.
2451
1557
  */
2452
- getCurrent: () => T
1558
+ subtitle?: string;
2453
1559
  /**
2454
- * Observable stream of state values
2455
- *
2456
- * @remarks
2457
- * Shares a single underlying subscription between all observers. Emits:
2458
- * - Immediately with current value on subscription
2459
- * - On every relevant state change
2460
- * - Errors if selector throws
1560
+ * An optional piece of media representing the document within its preview.
1561
+ * Currently, only image assets are available.
1562
+ */
1563
+ media?: PreviewMedia | null;
1564
+ /**
1565
+ * The status of the document.
2461
1566
  */
2462
- observable: Observable<T>
1567
+ _status?: {
1568
+ /** The date of the last published edit */
1569
+ lastEditedPublishedAt?: string;
1570
+ /** The date of the last draft edit */
1571
+ lastEditedDraftAt?: string;
1572
+ };
2463
1573
  }
2464
-
2465
- declare class StaticValue<P, T extends GroqType> {
2466
- data: P
2467
- type: T
2468
- constructor(data: P, type: T)
2469
- isArray(): boolean
2470
- get(): Promise<any>
2471
- [Symbol.asyncIterator](): Generator<Value, void, unknown>
1574
+ /**
1575
+ * Represents the current state of a preview value along with a flag indicating whether
1576
+ * the preview data is still being fetched or is fully resolved.
1577
+ *
1578
+ * The tuple contains a preview value or null, and a boolean indicating if the data is
1579
+ * pending. A `true` value means a fetch is ongoing; `false` indicates that the
1580
+ * currently provided preview value is up-to-date.
1581
+ *
1582
+ * @public
1583
+ */
1584
+ type ValuePending<T> = {
1585
+ data: T | null;
1586
+ isPending: boolean;
1587
+ };
1588
+ /**
1589
+ * @public
1590
+ */
1591
+ interface PreviewStoreState {
1592
+ values: { [TDocumentId in string]?: ValuePending<PreviewValue> };
1593
+ subscriptions: { [TDocumentId in string]?: { [TSubscriptionId in string]?: true } };
2472
1594
  }
2473
-
2474
- declare interface StoreEntry<TParams extends unknown[], TData> {
2475
- params: TParams
2476
- instance: SanityInstance
2477
- key: string
2478
- data?: TData
2479
- error?: unknown
2480
- subscriptions: string[]
2481
- lastFetchInitiatedAt?: string
1595
+ /**
1596
+ * @beta
1597
+ */
1598
+ type GetPreviewStateOptions = DocumentHandle;
1599
+ /**
1600
+ * @beta
1601
+ */
1602
+ declare function getPreviewState<TResult extends object>(instance: SanityInstance, options: GetPreviewStateOptions): StateSource<ValuePending<TResult>>;
1603
+ /**
1604
+ * @beta
1605
+ */
1606
+ declare function getPreviewState(instance: SanityInstance, options: GetPreviewStateOptions): StateSource<ValuePending<PreviewValue>>;
1607
+ /**
1608
+ * @beta
1609
+ */
1610
+ /**
1611
+ * @beta
1612
+ */
1613
+ type ResolvePreviewOptions = DocumentHandle;
1614
+ /**
1615
+ * @beta
1616
+ */
1617
+ declare const resolvePreview: BoundStoreAction<PreviewStoreState, [docHandle: ResolvePreviewOptions], Promise<ValuePending<object>>>;
1618
+ /** @public */
1619
+ declare const getProjectState: BoundStoreAction<FetcherStoreState<[options?: ProjectHandle<string> | undefined], _sanity_client12.SanityProject>, [options?: ProjectHandle<string> | undefined], StateSource<_sanity_client12.SanityProject | undefined>>;
1620
+ /** @public */
1621
+ declare const resolveProject: BoundStoreAction<FetcherStoreState<[options?: ProjectHandle<string> | undefined], _sanity_client12.SanityProject>, [options?: ProjectHandle<string> | undefined], Promise<_sanity_client12.SanityProject>>;
1622
+ /**
1623
+ * @public
1624
+ */
1625
+ type ValidProjection = `{${string}}`;
1626
+ /**
1627
+ * @public
1628
+ * The result of a projection query
1629
+ */
1630
+ interface ProjectionValuePending<TValue extends object> {
1631
+ data: TValue | null;
1632
+ isPending: boolean;
2482
1633
  }
2483
-
2484
- declare class StreamValue {
2485
- type: 'stream'
2486
- private generator
2487
- private ticker
2488
- private isDone
2489
- private data
2490
- constructor(generator: () => AsyncGenerator<Value, void, unknown>)
2491
- isArray(): boolean
2492
- get(): Promise<any>
2493
- [Symbol.asyncIterator](): AsyncGenerator<Value, void, unknown>
2494
- _nextTick(): Promise<void>
1634
+ interface ProjectionOptions<TProjection extends ValidProjection = ValidProjection, TDocumentType extends string = string, TDataset extends string = string, TProjectId extends string = string> extends DocumentHandle<TDocumentType, TDataset, TProjectId> {
1635
+ projection: TProjection;
2495
1636
  }
2496
-
2497
- declare type StringValue = StaticValue<string, 'string'>
2498
-
1637
+ /**
1638
+ * @beta
1639
+ */
1640
+ declare function getProjectionState<TProjection extends ValidProjection = ValidProjection, 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>;
1641
+ /**
1642
+ * @beta
1643
+ */
1644
+ declare function getProjectionState<TData extends object>(instance: SanityInstance, options: ProjectionOptions): StateSource<ProjectionValuePending<TData> | undefined>;
1645
+ /**
1646
+ * @beta
1647
+ */
1648
+ declare function getProjectionState(instance: SanityInstance, options: ProjectionOptions): StateSource<ProjectionValuePending<Record<string, unknown>> | undefined>;
1649
+ /**
1650
+ * @beta
1651
+ */
2499
1652
  /** @beta */
2500
- export declare const subscribeDocumentEvents: BoundStoreAction<
2501
- DocumentStoreState,
2502
- [eventHandler: (e: DocumentEvent) => void],
2503
- () => void
2504
- >
2505
-
2506
- declare interface ThisNode extends BaseNode {
2507
- type: 'This'
2508
- }
2509
-
1653
+ declare function resolveProjection<TProjection extends ValidProjection = ValidProjection, 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}`>>>;
1654
+ /** @beta */
1655
+ declare function resolveProjection<TData extends object>(instance: SanityInstance, options: ProjectionOptions): Promise<ProjectionValuePending<TData>>;
1656
+ /** @public */
1657
+ declare const getProjectsState: BoundStoreAction<FetcherStoreState<[], Omit<_sanity_client12.SanityProject, "members">[]>, [], StateSource<Omit<_sanity_client12.SanityProject, "members">[] | undefined>>;
1658
+ /** @public */
1659
+ declare const resolveProjects: BoundStoreAction<FetcherStoreState<[], Omit<_sanity_client12.SanityProject, "members">[]>, [], Promise<Omit<_sanity_client12.SanityProject, "members">[]>>;
2510
1660
  /**
2511
1661
  * @beta
2512
- * Event emitted when a transaction is accepted.
2513
1662
  */
2514
- export declare interface TransactionAcceptedEvent {
2515
- type: 'accepted'
2516
- outgoing: OutgoingTransaction
2517
- result: Awaited<ReturnType<SanityClient['action']>>
1663
+ 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> {
1664
+ query: TQuery;
1665
+ params?: Record<string, unknown>;
2518
1666
  }
2519
-
2520
1667
  /**
2521
1668
  * @beta
2522
- * Event emitted when a transaction is reverted.
2523
1669
  */
2524
- export declare interface TransactionRevertedEvent {
2525
- type: 'reverted'
2526
- message: string
2527
- error: unknown
2528
- outgoing: OutgoingTransaction
2529
- }
2530
-
2531
- declare interface TupleNode extends BaseNode {
2532
- type: 'Tuple'
2533
- members: Array<ExprNode>
1670
+ interface ResolveQueryOptions<TQuery extends string = string, TDataset extends string = string, TProjectId extends string = string> extends QueryOptions<TQuery, TDataset, TProjectId> {
1671
+ signal?: AbortSignal;
2534
1672
  }
2535
-
1673
+ /** @beta */
1674
+ declare const getQueryKey: (options: QueryOptions) => string;
1675
+ /** @beta */
1676
+ declare const parseQueryKey: (key: string) => QueryOptions;
2536
1677
  /**
2537
- * Creates an `UnpublishDocumentAction` object.
2538
- * @param doc - A handle uniquely identifying the document to be unpublished.
2539
- * @returns An `UnpublishDocumentAction` object ready for dispatch.
1678
+ * Returns the state source for a query.
1679
+ *
1680
+ * This function returns a state source that represents the current result of a GROQ query.
1681
+ * Subscribing to the state source will instruct the SDK to fetch the query (if not already fetched)
1682
+ * and will keep the query live using the Live content API (considering sync tags) to provide up-to-date results.
1683
+ * When the last subscriber is removed, the query state is automatically cleaned up from the store.
1684
+ *
1685
+ * Note: This functionality is for advanced users who want to build their own framework integrations.
1686
+ * Our SDK also provides a React integration (useQuery hook) for convenient usage.
1687
+ *
1688
+ * Note: Automatic cleanup can interfere with React Suspense because if a component suspends while being the only subscriber,
1689
+ * cleanup might occur unexpectedly. In such cases, consider using `resolveQuery` instead.
1690
+ *
2540
1691
  * @beta
2541
1692
  */
2542
- export declare function unpublishDocument<
2543
- TDocumentType extends string = string,
2544
- TDataset extends string = string,
2545
- TProjectId extends string = string,
2546
- >(
2547
- doc: DocumentHandle<TDocumentType, TDataset, TProjectId>,
2548
- ): UnpublishDocumentAction<TDocumentType, TDataset, TProjectId>
2549
-
1693
+ 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>;
1694
+ /** @beta */
1695
+ declare function getQueryState<TData>(instance: SanityInstance, queryOptions: QueryOptions): StateSource<TData | undefined>;
1696
+ /** @beta */
1697
+ declare function getQueryState(instance: SanityInstance, queryOptions: QueryOptions): StateSource<unknown>;
2550
1698
  /**
2551
- * Represents an action to unpublish a document, moving its published content to a draft.
2552
- * Requires the full document handle.
1699
+ * Resolves the result of a query without registering a lasting subscriber.
1700
+ *
1701
+ * This function fetches the result of a GROQ query and returns a promise that resolves with the query result.
1702
+ * Unlike `getQueryState`, which registers subscribers to keep the query live and performs automatic cleanup,
1703
+ * `resolveQuery` does not track subscribers. This makes it ideal for use with React Suspense, where the returned
1704
+ * promise is thrown to delay rendering until the query result becomes available.
1705
+ * Once the promise resolves, it is expected that a real subscriber will be added via `getQueryState` to manage ongoing updates.
1706
+ *
1707
+ * Additionally, an optional AbortSignal can be provided to cancel the query and immediately clear the associated state
1708
+ * if there are no active subscribers.
1709
+ *
2553
1710
  * @beta
2554
1711
  */
2555
- export declare interface UnpublishDocumentAction<
2556
- TDocumentType extends string = string,
2557
- TDataset extends string = string,
2558
- TProjectId extends string = string,
2559
- > extends DocumentHandle<TDocumentType, TDataset, TProjectId> {
2560
- type: 'document.unpublish'
1712
+ 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}`>>;
1713
+ /** @beta */
1714
+ declare function resolveQuery<TData>(instance: SanityInstance, queryOptions: ResolveQueryOptions): Promise<TData>;
1715
+ /**
1716
+ * Represents a document in a Sanity dataset that represents release options.
1717
+ * @internal
1718
+ */
1719
+ type ReleaseDocument = SanityDocument$2 & {
1720
+ name: string;
1721
+ publishAt?: string;
1722
+ state: 'active' | 'scheduled';
1723
+ metadata: {
1724
+ title: string;
1725
+ releaseType: 'asap' | 'scheduled' | 'undecided';
1726
+ intendedPublishAt?: string;
1727
+ description?: string;
1728
+ };
1729
+ };
1730
+ interface ReleasesStoreState {
1731
+ activeReleases?: ReleaseDocument[];
1732
+ error?: unknown;
2561
1733
  }
2562
-
2563
- declare interface UnverifiedDocumentRevision {
2564
- transactionId: string
2565
- documentId: string
2566
- previousRev: string | undefined
2567
- timestamp: string
1734
+ /**
1735
+ * Get the active releases from the store.
1736
+ * @internal
1737
+ */
1738
+ declare const getActiveReleasesState: BoundStoreAction<ReleasesStoreState, [], StateSource<ReleaseDocument[] | undefined>>;
1739
+ /**
1740
+ * Provides a subscribable state source for a "perspective" for the Sanity client,
1741
+ * which is used to fetch documents as though certain Content Releases are active.
1742
+ *
1743
+ * @param instance - The Sanity instance to get the perspective for
1744
+ * @param options - The options for the perspective -- usually a release name
1745
+ *
1746
+ * @returns A subscribable perspective value, usually a list of applicable release names,
1747
+ * or a single release name / default perspective (such as 'drafts').
1748
+ *
1749
+ * @public
1750
+ */
1751
+ declare const getPerspectiveState: BoundStoreAction<ReleasesStoreState, [options?: PerspectiveHandle | undefined], StateSource<string[] | "previewDrafts" | "published" | "drafts" | "raw" | undefined>>;
1752
+ /**
1753
+ * @public
1754
+ */
1755
+ interface SanityUser {
1756
+ sanityUserId: string;
1757
+ profile: UserProfile;
1758
+ memberships: Membership[];
2568
1759
  }
2569
-
2570
1760
  /**
2571
1761
  * @public
2572
1762
  */
2573
- export declare interface UserProfile {
2574
- id: string
2575
- displayName: string
2576
- email: string
2577
- familyName?: string
2578
- givenName?: string
2579
- middleName?: string | null
2580
- imageUrl?: string
2581
- provider: string
2582
- tosAcceptedAt?: string
2583
- createdAt: string
2584
- updatedAt?: string
2585
- isCurrentUser?: boolean
2586
- providerId?: string
1763
+ interface Membership {
1764
+ addedAt?: string;
1765
+ resourceType: string;
1766
+ resourceId: string;
1767
+ roleNames: Array<string>;
1768
+ lastSeenAt?: string | null;
2587
1769
  }
2588
-
2589
1770
  /**
2590
1771
  * @public
2591
1772
  */
2592
- declare interface UsersGroupState {
2593
- subscriptions: string[]
2594
- totalCount?: number
2595
- nextCursor?: string | null
2596
- lastLoadMoreRequest?: string
2597
- users?: SanityUser[]
2598
- error?: unknown
1773
+ interface UserProfile {
1774
+ id: string;
1775
+ displayName: string;
1776
+ email: string;
1777
+ familyName?: string;
1778
+ givenName?: string;
1779
+ middleName?: string | null;
1780
+ imageUrl?: string;
1781
+ provider: string;
1782
+ tosAcceptedAt?: string;
1783
+ createdAt: string;
1784
+ updatedAt?: string;
1785
+ isCurrentUser?: boolean;
1786
+ providerId?: string;
2599
1787
  }
2600
-
2601
1788
  /**
2602
1789
  * @public
2603
1790
  */
2604
- declare interface UsersStoreState {
2605
- users: {
2606
- [TUsersKey in string]?: UsersGroupState
2607
- }
2608
- error?: unknown
1791
+ interface GetUsersOptions extends ProjectHandle {
1792
+ resourceType?: 'organization' | 'project';
1793
+ batchSize?: number;
1794
+ organizationId?: string;
2609
1795
  }
2610
-
2611
1796
  /**
2612
1797
  * @public
2613
1798
  */
2614
- export declare type ValidProjection = `{${string}}`
2615
-
1799
+ interface UsersGroupState {
1800
+ subscriptions: string[];
1801
+ totalCount?: number;
1802
+ nextCursor?: string | null;
1803
+ lastLoadMoreRequest?: string;
1804
+ users?: SanityUser[];
1805
+ error?: unknown;
1806
+ }
2616
1807
  /**
2617
- * The result of an expression.
1808
+ * @public
2618
1809
  */
2619
- declare type Value = AnyStaticValue | StreamValue
2620
1810
 
2621
- declare interface ValueNode<P = any> {
2622
- type: 'Value'
2623
- value: P
1811
+ /**
1812
+ * @public
1813
+ */
1814
+ interface UsersStoreState {
1815
+ users: { [TUsersKey in string]?: UsersGroupState };
1816
+ error?: unknown;
2624
1817
  }
2625
-
2626
1818
  /**
2627
- * Represents the current state of a preview value along with a flag indicating whether
2628
- * the preview data is still being fetched or is fully resolved.
1819
+ * @public
1820
+ */
1821
+ interface ResolveUsersOptions extends GetUsersOptions {
1822
+ signal?: AbortSignal;
1823
+ }
1824
+ /** @internal */
1825
+ declare const getUsersKey: (instance: SanityInstance, {
1826
+ resourceType,
1827
+ organizationId,
1828
+ batchSize,
1829
+ projectId
1830
+ }?: GetUsersOptions) => string;
1831
+ /** @internal */
1832
+ declare const parseUsersKey: (key: string) => {
1833
+ batchSize: number;
1834
+ resourceType?: "organization" | "project";
1835
+ projectId?: string;
1836
+ organizationId?: string;
1837
+ };
1838
+ /**
1839
+ * Returns the state source for users associated with a specific resource.
2629
1840
  *
2630
- * The tuple contains a preview value or null, and a boolean indicating if the data is
2631
- * pending. A `true` value means a fetch is ongoing; `false` indicates that the
2632
- * currently provided preview value is up-to-date.
1841
+ * This function returns a state source that represents the current list of users for a given
1842
+ * resource. Subscribing to the state source will instruct the SDK to fetch the users (if not
1843
+ * already fetched) and will load more from this state source as well. When the last subscriber is
1844
+ * removed, the users state is automatically cleaned up from the store after a delay.
1845
+ *
1846
+ * Note: This functionality is for advanced users who want to build their own framework
1847
+ * integrations. Our SDK also provides a React integration for convenient usage.
1848
+ *
1849
+ * @beta
1850
+ */
1851
+ declare const getUsersState: BoundStoreAction<UsersStoreState, [options?: GetUsersOptions], StateSource<{
1852
+ data: SanityUser[];
1853
+ totalCount: number;
1854
+ hasMore: boolean;
1855
+ } | undefined>>;
1856
+ /**
1857
+ * Resolves the users for a specific resource without registering a lasting subscriber.
1858
+ *
1859
+ * This function fetches the users for a given resource and returns a promise that resolves with
1860
+ * the users result. Unlike `getUsersState`, which registers subscribers to keep the data live and
1861
+ * performs automatic cleanup, `resolveUsers` does not track subscribers. This makes it ideal for
1862
+ * use with React Suspense, where the returned promise is thrown to delay rendering until the users
1863
+ * result becomes available. Once the promise resolves, it is expected that a real subscriber will
1864
+ * be added via `getUsersState` to manage ongoing updates.
1865
+ *
1866
+ * Additionally, an optional AbortSignal can be provided to cancel the request and immediately
1867
+ * clear the associated state if there are no active subscribers.
1868
+ *
1869
+ * @beta
1870
+ */
1871
+ declare const resolveUsers: BoundStoreAction<UsersStoreState, [ResolveUsersOptions], Promise<{
1872
+ data: SanityUser[];
1873
+ totalCount: number;
1874
+ hasMore: boolean;
1875
+ }>>;
1876
+ /**
1877
+ * Loads more users for a specific resource.
1878
+ *
1879
+ * This function triggers a request to fetch the next page of users for a given resource. It
1880
+ * requires that users have already been loaded for the resource (via `resolveUsers` or
1881
+ * `getUsersState`), and that there are more users available to load (as indicated by the `hasMore`
1882
+ * property).
1883
+ *
1884
+ * The function returns a promise that resolves when the next page of users has been loaded.
2633
1885
  *
1886
+ * @beta
1887
+ */
1888
+ declare const loadMoreUsers: BoundStoreAction<UsersStoreState, [options?: GetUsersOptions | undefined], Promise<{
1889
+ data: SanityUser[];
1890
+ totalCount: number;
1891
+ hasMore: boolean;
1892
+ }>>;
1893
+ interface StoreEntry<TParams extends unknown[], TData> {
1894
+ params: TParams;
1895
+ instance: SanityInstance;
1896
+ key: string;
1897
+ data?: TData;
1898
+ error?: unknown;
1899
+ subscriptions: string[];
1900
+ lastFetchInitiatedAt?: string;
1901
+ }
1902
+ /**
1903
+ * Internal helper type
2634
1904
  * @public
2635
1905
  */
2636
- export declare type ValuePending<T> = {
2637
- data: T | null
2638
- isPending: boolean
1906
+ interface FetcherStoreState<TParams extends unknown[], TData> {
1907
+ stateByParams: { [TSerializedKey in string]?: StoreEntry<TParams, TData> };
1908
+ error?: unknown;
2639
1909
  }
2640
-
2641
1910
  /**
2642
- * Message sent from an iframe to a containing app
1911
+ * Internal helper type
2643
1912
  * @public
2644
1913
  */
2645
- export declare type WindowMessage = Message
2646
-
2647
- export {}
1914
+ interface FetcherStore<TParams extends unknown[], TData> {
1915
+ getState: BoundStoreAction<FetcherStoreState<TParams, TData>, TParams, StateSource<TData | undefined>>;
1916
+ resolveState: BoundStoreAction<FetcherStoreState<TParams, TData>, TParams, Promise<TData>>;
1917
+ }
1918
+ /**
1919
+ * Creates a store from a function that returns an observable that fetches data
1920
+ * that supports parameterized state caching.
1921
+ *
1922
+ * This function creates a resource store keyed by parameter values (using the
1923
+ * provided `getKey` function) and returns a state source (via `getState`)
1924
+ * that components can subscribe to. When a new subscription is added, and if
1925
+ * enough time has passed since the last fetch (controlled by
1926
+ * `fetchThrottleInternal`), it invokes the observable factory (via
1927
+ * `getObservable`) to fetch fresh data. The data is stored in state and can be
1928
+ * accessed reactively.
1929
+ *
1930
+ * Additionally, the store provides a `resolveState` function that returns a
1931
+ * Promise resolving with the next non-undefined value from the state source.
1932
+ *
1933
+ * State expiration is implemented: after the last subscription for a key is
1934
+ * removed, its state is cleared after `stateExpirationDelay` ms, causing
1935
+ * components to suspend until fresh data is fetched.
1936
+ */
1937
+ /**
1938
+ * Creates a GROQ search filter string (`[@] match text::query("...")`)
1939
+ * from a raw search query string.
1940
+ *
1941
+ * It applies wildcard ('*') logic to the last eligible token and escapes
1942
+ * double quotes within the search term.
1943
+ *
1944
+ * If the input query is empty or only whitespace, it returns an empty string.
1945
+ *
1946
+ * @param query - The raw input search string.
1947
+ * @returns The GROQ search filter string, or an empty string.
1948
+ * @internal
1949
+ */
1950
+ declare function createGroqSearchFilter(query: string): string;
1951
+ /**
1952
+ * This version is provided by pkg-utils at build time
1953
+ * @internal
1954
+ */
1955
+ declare const CORE_SDK_VERSION: {};
1956
+ /**
1957
+ * @public
1958
+ */
1959
+ type SanityProject = SanityProject$1;
1960
+ export { type ActionErrorEvent, type ActionsResult, type ApplyDocumentActionsOptions, type AuthConfig, type AuthProvider, type AuthState, AuthStateType, type AuthStoreState, CORE_SDK_VERSION, type ClientOptions, type ClientStoreState as ClientState, type ComlinkControllerState, type ComlinkNodeState, type CreateDocumentAction, type CurrentUser, type DatasetHandle, type DeleteDocumentAction, type DiscardDocumentAction, type DocumentAction, type DocumentCreatedEvent, type DocumentDeletedEvent, type DocumentDiscardedEvent, type DocumentEditedEvent, type DocumentEvent, type DocumentHandle, type DocumentOptions, type DocumentPermissionsResult, type DocumentPublishedEvent, type DocumentTypeHandle, type DocumentUnpublishedEvent, type EditDocumentAction, type ErrorAuthState, type FavoriteStatusResponse, type FetcherStore, type FetcherStoreState, type FrameMessage, type GetPreviewStateOptions, type GetUsersOptions, type JsonMatch, type LoggedInAuthState, type LoggedOutAuthState, type LoggingInAuthState, type Membership, type NewTokenResponseMessage, type NodeState, type OrgVerificationResult, type PermissionDeniedReason, type PerspectiveHandle, type PreviewStoreState, type PreviewValue, type ProjectHandle, type ProjectionValuePending, type PublishDocumentAction, type QueryOptions, type ReleaseDocument, type ReleasePerspective, type RequestNewTokenMessage, type ResolvePreviewOptions, type ResolveUsersOptions, type Role, type SanityConfig, type SanityDocument, type SanityInstance, SanityProject, type SanityUser, type Selector, type StateSource, type TransactionAcceptedEvent, type TransactionRevertedEvent, type UnpublishDocumentAction, type UserProfile, type ValidProjection, type ValuePending, type WindowMessage, applyDocumentActions, createDatasetHandle, createDocument, createDocumentHandle, createDocumentTypeHandle, createGroqSearchFilter, createProjectHandle, createSanityInstance, deleteDocument, destroyController, discardDocument, editDocument, getActiveReleasesState, getAuthState, getClient, getClientState, getCurrentUserState, getDashboardOrganizationId, getDatasetsState, getDocumentState, getDocumentSyncStatus, getFavoritesState, getIndexForKey, getIsInDashboardState, getLoginUrlState, getNodeState, getOrCreateChannel, getOrCreateController, getOrCreateNode, getPathDepth, getPermissionsState, getPerspectiveState, getPreviewState, getProjectState, getProjectionState, getProjectsState, getQueryKey, getQueryState, getTokenState, getUsersKey, getUsersState, handleAuthCallback, joinPaths, jsonMatch, loadMoreUsers, logout, observeOrganizationVerificationState, parseQueryKey, parseUsersKey, publishDocument, releaseChannel, releaseNode, resolveDatasets, resolveDocument, resolveFavoritesState, resolvePermissions, resolvePreview, resolveProject, resolveProjection, resolveProjects, resolveQuery, resolveUsers, setAuthToken, slicePath, stringifyPath, subscribeDocumentEvents, unpublishDocument };