@sanity/sdk 3.0.0-rc.1 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (128) hide show
  1. package/README.md +12 -0
  2. package/dist/_exports/_internal.d.ts +71 -3
  3. package/dist/_exports/_internal.d.ts.map +1 -1
  4. package/dist/_exports/_internal.js +332 -24
  5. package/dist/_exports/_internal.js.map +1 -1
  6. package/dist/_exports/agent.d.ts +65 -0
  7. package/dist/_exports/agent.d.ts.map +1 -0
  8. package/dist/_exports/agent.js +71 -0
  9. package/dist/_exports/agent.js.map +1 -0
  10. package/dist/_exports/comlink.d.ts +118 -0
  11. package/dist/_exports/comlink.d.ts.map +1 -0
  12. package/dist/_exports/comlink.js +69 -0
  13. package/dist/_exports/comlink.js.map +1 -0
  14. package/dist/authStore-C0o1NOxW.d.ts +3165 -0
  15. package/dist/authStore-C0o1NOxW.d.ts.map +1 -0
  16. package/dist/authStore-CtE9bLHW.js +754 -0
  17. package/dist/authStore-CtE9bLHW.js.map +1 -0
  18. package/dist/clientStore-BtE2-q2i.js +90 -0
  19. package/dist/clientStore-BtE2-q2i.js.map +1 -0
  20. package/dist/createSanityInstance-DUI1bGIg.d.ts +278 -0
  21. package/dist/createSanityInstance-DUI1bGIg.d.ts.map +1 -0
  22. package/dist/createStateSourceAction-BOKtqFNm.js +300 -0
  23. package/dist/createStateSourceAction-BOKtqFNm.js.map +1 -0
  24. package/dist/getEnv-D5RGkQLu.js +8 -0
  25. package/dist/getEnv-D5RGkQLu.js.map +1 -0
  26. package/dist/getNodeState-CR3__B2D.js +67 -0
  27. package/dist/getNodeState-CR3__B2D.js.map +1 -0
  28. package/dist/index.d.ts +3 -2335
  29. package/dist/index.js +4048 -3878
  30. package/dist/index.js.map +1 -1
  31. package/dist/logger-DAtJb5RQ.js +173 -0
  32. package/dist/logger-DAtJb5RQ.js.map +1 -0
  33. package/dist/object-CxXlSVg7.js +83 -0
  34. package/dist/object-CxXlSVg7.js.map +1 -0
  35. package/dist/queryStore-C7yMHPUI.js +1346 -0
  36. package/dist/queryStore-C7yMHPUI.js.map +1 -0
  37. package/dist/rolldown-runtime-vyAXikos.js +9 -0
  38. package/dist/setCleanupTimeout-BiM6q1KF.js +31 -0
  39. package/dist/setCleanupTimeout-BiM6q1KF.js.map +1 -0
  40. package/dist/telemetryManager-UIEiMtC0.js +127 -0
  41. package/dist/telemetryManager-UIEiMtC0.js.map +1 -0
  42. package/dist/version-D8RP_Q59.js +9 -0
  43. package/dist/version-D8RP_Q59.js.map +1 -0
  44. package/package.json +11 -17
  45. package/src/_exports/_internal.ts +1 -0
  46. package/src/_exports/agent.ts +19 -0
  47. package/src/_exports/comlink.ts +16 -0
  48. package/src/_exports/index.ts +45 -90
  49. package/src/applications/applications.test-d.ts +5 -0
  50. package/src/applications/applications.ts +5 -2
  51. package/src/auth/authMode.test.ts +0 -25
  52. package/src/auth/authMode.ts +3 -6
  53. package/src/auth/authStore.test.ts +1 -1
  54. package/src/auth/authStore.ts +0 -1
  55. package/src/comments/addonDatasetStore.test.ts +215 -0
  56. package/src/comments/addonDatasetStore.ts +249 -0
  57. package/src/comments/buildCommentThreads.test.ts +83 -0
  58. package/src/comments/buildCommentThreads.ts +54 -0
  59. package/src/comments/commentActions.test.ts +540 -0
  60. package/src/comments/commentActions.ts +555 -0
  61. package/src/comments/commentFieldPath.test.ts +40 -0
  62. package/src/comments/commentFieldPath.ts +44 -0
  63. package/src/comments/commentsConstants.ts +80 -0
  64. package/src/comments/commentsStore.test.ts +419 -0
  65. package/src/comments/commentsStore.ts +483 -0
  66. package/src/comments/normalizeComment.test.ts +116 -0
  67. package/src/comments/normalizeComment.ts +45 -0
  68. package/src/comments/observeComments.test.ts +193 -0
  69. package/src/comments/observeComments.ts +113 -0
  70. package/src/comments/reducers.test.ts +277 -0
  71. package/src/comments/reducers.ts +316 -0
  72. package/src/comments/types.ts +249 -0
  73. package/src/comments/weakenReferences.test.ts +47 -0
  74. package/src/comments/weakenReferences.ts +29 -0
  75. package/src/config/sanityConfig.ts +3 -75
  76. package/src/datasets/datasets.test.ts +44 -9
  77. package/src/datasets/datasets.ts +24 -23
  78. package/src/document/applyDocumentActions.test.ts +8 -12
  79. package/src/document/documentConstants.ts +17 -0
  80. package/src/document/documentStore.test.ts +173 -19
  81. package/src/document/documentStore.ts +36 -5
  82. package/src/document/patchOperations.test.ts +27 -0
  83. package/src/document/patchOperations.ts +10 -1
  84. package/src/document/permissions.test.ts +3 -1
  85. package/src/document/reducers.test.ts +357 -0
  86. package/src/document/reducers.ts +125 -27
  87. package/src/document/util.test.ts +46 -0
  88. package/src/document/util.ts +37 -1
  89. package/src/favorites/favorites.test.ts +64 -24
  90. package/src/favorites/favorites.ts +73 -22
  91. package/src/installations/installations.test-d.ts +5 -0
  92. package/src/installations/installations.ts +4 -0
  93. package/src/presence/bifurTransport.test.ts +155 -3
  94. package/src/presence/bifurTransport.ts +79 -12
  95. package/src/presence/paths.test.ts +70 -0
  96. package/src/presence/paths.ts +41 -0
  97. package/src/presence/presenceStore.test.ts +822 -2
  98. package/src/presence/presenceStore.ts +518 -102
  99. package/src/presence/types.ts +175 -3
  100. package/src/preview/types.ts +0 -25
  101. package/src/projection/projectionStore.test.ts +0 -8
  102. package/src/projection/types.ts +0 -8
  103. package/src/query/queryStore.ts +7 -6
  104. package/src/store/createActionBinder.test.ts +51 -29
  105. package/src/store/createActionBinder.ts +16 -62
  106. package/src/store/createSanityInstance.test.ts +0 -68
  107. package/src/store/createSanityInstance.ts +0 -63
  108. package/src/store/createStateSourceAction.ts +1 -1
  109. package/src/store/fetcherStore.test.ts +23 -1
  110. package/src/store/fetcherStore.ts +3 -3
  111. package/src/users/reducers.test.ts +0 -3
  112. package/dist/_chunks-dts/createGroqSearchFilter.d.ts +0 -1147
  113. package/dist/_chunks-dts/createGroqSearchFilter.d.ts.map +0 -1
  114. package/dist/_chunks-es/_internal.js +0 -134
  115. package/dist/_chunks-es/_internal.js.map +0 -1
  116. package/dist/_chunks-es/createGroqSearchFilter.js +0 -1864
  117. package/dist/_chunks-es/createGroqSearchFilter.js.map +0 -1
  118. package/dist/_chunks-es/telemetryManager.js +0 -93
  119. package/dist/_chunks-es/telemetryManager.js.map +0 -1
  120. package/dist/index.d.ts.map +0 -1
  121. package/src/applications/userApplications.test.ts +0 -126
  122. package/src/applications/userApplications.ts +0 -261
  123. package/src/preview/getPreviewState.test.ts +0 -137
  124. package/src/preview/getPreviewState.ts +0 -69
  125. package/src/preview/resolvePreview.test.ts +0 -64
  126. package/src/preview/resolvePreview.ts +0 -43
  127. package/src/utils/createFetcherStore.test.ts +0 -171
  128. package/src/utils/createFetcherStore.ts +0 -284
@@ -0,0 +1,3165 @@
1
+ import { b as AuthConfig, c as DocumentTypeHandle, d as ProjectHandle, f as ReleaseHandle, i as DatasetHandle, o as DocumentHandle, s as DocumentResource, t as SanityInstance, u as PerspectiveHandle, x as AuthProvider } from "./createSanityInstance-DUI1bGIg.js";
2
+ import { ClientConfig, ClientPerspective, DatasetsResponse, ListenEvent, MultipleMutationResult, ReleaseDocument, ReleaseDocument as ReleaseDocument$1, ResponseQueryOptions, SanityClient, SanityDocument, SanityProject } from "@sanity/client";
3
+ import { Observable, Subject } from "rxjs";
4
+ import { CurrentUser, CurrentUser as CurrentUser$1, Mutation, PatchOperations, Path, PortableTextBlock, Role, SanityDocument as SanityDocument$1, SanityDocument as SanityDocument$3, SanityDocumentLike } from "@sanity/types";
5
+ import "zustand/middleware";
6
+ import { getIndexForKey as getIndexForKey$1, getPathDepth, joinPaths, jsonMatch as jsonMatch$1, slicePath as slicePath$1, stringifyPath as stringifyPath$1 } from "@sanity/json-match";
7
+ import { PatchMutation } from "@sanity/mutate/_unstable_store";
8
+ import { SanityDocument as SanityDocument$2, SanityProjectionResult, SanityQueryResult } from "groq";
9
+ import { ExprNode } from "groq-js";
10
+ import { CanvasResource, MediaResource, StudioResource } from "@sanity/message-protocol";
11
+ /**
12
+ * Represents a reactive store state container with multiple access patterns
13
+ */
14
+ interface StoreState<TState> {
15
+ /**
16
+ * Gets the current state value
17
+ *
18
+ * @remarks
19
+ * This is a direct synchronous accessor that doesn't trigger subscriptions
20
+ */
21
+ get: () => TState;
22
+ /**
23
+ * Updates the store state
24
+ * @param name - Action name for devtools tracking
25
+ * @param updatedState - New state value or updater function
26
+ *
27
+ * @remarks
28
+ * When providing a partial object, previous top-level keys not included in
29
+ * the update will be preserved.
30
+ */
31
+ set: (name: string, updatedState: Partial<TState> | ((s: TState) => Partial<TState>)) => void;
32
+ /**
33
+ * Observable stream of state changes
34
+ * @remarks
35
+ * - Emits immediately with current state on subscription
36
+ * - Shares underlying subscription between observers
37
+ * - Only emits when state reference changes
38
+ * - Completes when store is disposed
39
+ */
40
+ observable: Observable<TState>;
41
+ }
42
+ /**
43
+ * Context object provided to store initialization functions
44
+ */
45
+ interface StoreContext<TState, TKey = unknown> {
46
+ /**
47
+ * Sanity instance associated with this store
48
+ *
49
+ * @remarks
50
+ * Provides access to the Sanity configuration and instance lifecycle methods
51
+ */
52
+ instance: SanityInstance;
53
+ /**
54
+ * Reactive store state management utilities
55
+ *
56
+ * @remarks
57
+ * Contains methods for getting/setting state and observing changes
58
+ */
59
+ state: StoreState<TState>;
60
+ /**
61
+ * The key used to instantiate the store.
62
+ */
63
+ key: TKey;
64
+ }
65
+ /**
66
+ * Defines a store action that operates on a specific state type
67
+ */
68
+ type StoreAction<TState, TParams extends unknown[], TReturn, TKey = unknown> = (context: StoreContext<TState, TKey>, ...params: TParams) => TReturn;
69
+ /**
70
+ * Represents a store action that has been bound to a specific store instance
71
+ */
72
+ type BoundStoreAction<_TState, TParams extends unknown[], TReturn> = (instance: SanityInstance, ...params: TParams) => TReturn;
73
+ /**
74
+ * Represents a reactive state source that provides synchronized access to store data
75
+ *
76
+ * @remarks
77
+ * Designed to work with React's useSyncExternalStore hook. Provides three ways to access data:
78
+ * 1. `getCurrent()` for synchronous current value access
79
+ * 2. `subscribe()` for imperative change notifications
80
+ * 3. `observable` for reactive stream access
81
+ *
82
+ * @public
83
+ */
84
+ interface StateSource<T> {
85
+ /**
86
+ * Subscribes to state changes with optional callback
87
+ * @param onStoreChanged - Called whenever relevant state changes occur
88
+ * @returns Unsubscribe function to clean up the subscription
89
+ */
90
+ subscribe: (onStoreChanged?: () => void) => () => void;
91
+ /**
92
+ * Gets the current derived state value
93
+ *
94
+ * @remarks
95
+ * Safe to call without subscription. Will always return the latest value
96
+ * based on the current store state and selector parameters.
97
+ */
98
+ getCurrent: () => T;
99
+ /**
100
+ * Observable stream of state values
101
+ *
102
+ * @remarks
103
+ * Shares a single underlying subscription between all observers. Emits:
104
+ * - Immediately with current value on subscription
105
+ * - On every relevant state change
106
+ * - Errors if selector throws
107
+ */
108
+ observable: Observable<T>;
109
+ }
110
+ /**
111
+ * Context passed to selectors when deriving state
112
+ *
113
+ * @remarks
114
+ * Provides access to both the current state value and the Sanity instance,
115
+ * allowing selectors to use configuration values when computing derived state.
116
+ * The context is memoized for each state object and instance combination
117
+ * to optimize performance and prevent unnecessary recalculations.
118
+ *
119
+ * @example
120
+ * ```ts
121
+ * // Using both state and instance in a selector (psuedo example)
122
+ * const getUserByProjectId = createStateSourceAction(
123
+ * ({ state, instance }: SelectorContext<UsersState>, options?: ProjectHandle) => {
124
+ * const allUsers = state.users
125
+ * const projectId = options?.projectId ?? instance.config.projectId
126
+ * return allUsers.filter(user => user.projectId === projectId)
127
+ * }
128
+ * )
129
+ * ```
130
+ */
131
+ interface SelectorContext<TState> {
132
+ /**
133
+ * The current state object from the store
134
+ */
135
+ state: TState;
136
+ /**
137
+ * The Sanity instance associated with this state
138
+ */
139
+ instance: SanityInstance;
140
+ }
141
+ /**
142
+ * Function type for selecting derived state from store state and parameters
143
+ * @public
144
+ */
145
+ type Selector<TState, TParams extends unknown[], TReturn> = (context: SelectorContext<TState>, ...params: TParams) => TReturn;
146
+ /**
147
+ * Identifies cached data for invalidation, matched across the whole store.
148
+ * A fetcher declares the tags each of its entries carries (via
149
+ * {@link FetcherDefinition.tags}); a mutation declares the tags it invalidates
150
+ * (via {@link MutationDefinition.invalidates}).
151
+ *
152
+ * When invalidating,`{type: 'organization'}` matches every entry carrying any `organization` tag;
153
+ * `{type: 'organization', id: 'abc'}` matches only entries carrying that exact pair.
154
+ * List entries carry a `{type, id: 'LIST'}` sentinel plus one tag per item, so a
155
+ * "create" mutation can refetch lists without touching unrelated detail entries.
156
+ *
157
+ * @internal
158
+ */
159
+ interface CacheTag {
160
+ type: string;
161
+ /** Specific id, or the `'LIST'` sentinel for list entries */
162
+ id?: string | number;
163
+ }
164
+ /**
165
+ * The reactive value of one cache entry, as exposed by
166
+ * {@link Fetcher.getState}. React hooks consume this envelope directly.
167
+ * Discriminated on `status`, so narrowing gives correctly-typed `data`:
168
+ * `'success'` is the only arm carrying data, and a background failure while
169
+ * data still renders surfaces on the `'success'` arm's `error`.
170
+ *
171
+ * `isFetching` is common to all arms: a fetch for this entry is in flight
172
+ * (initial load, revalidation, or poll).
173
+ *
174
+ * @internal
175
+ */
176
+ type FetcherSnapshot<TData> = {
177
+ /** No data yet — initial fetch in flight or not started */
178
+ status: 'pending';
179
+ data: undefined;
180
+ error: undefined;
181
+ isFetching: boolean;
182
+ dataUpdatedAt: undefined;
183
+ } | {
184
+ /** Data available — possibly stale, possibly revalidating */
185
+ status: 'success';
186
+ data: TData;
187
+ /** Most recent background-fetch failure, cleared by the next successful fetch */
188
+ error: unknown;
189
+ isFetching: boolean;
190
+ /** Epoch ms of the fetch that produced `data` */
191
+ dataUpdatedAt: number;
192
+ } | {
193
+ /** The last fetch failed and no data exists to serve */
194
+ status: 'error';
195
+ data: undefined;
196
+ error: unknown;
197
+ isFetching: boolean;
198
+ dataUpdatedAt: undefined;
199
+ };
200
+ /**
201
+ * A typed description of one cached, parameterised read of an API response —
202
+ * here is a single cache per {@link SanityInstance}; every definition registers
203
+ * into it and its `name` namespaces its keys. A list and a detail read are two
204
+ * definitions over the one cache, not two caches.
205
+ *
206
+ * Entry lifecycle: fresh → stale → collected. Fresh entries are served from
207
+ * cache with no fetch; stale entries are served immediately and revalidated in
208
+ * the background (stale-while-revalidate); collected entries are removed once
209
+ * their `gcTime` elapses after the last unsubscribe, so the next subscriber
210
+ * suspends.
211
+ *
212
+ * @internal
213
+ */
214
+ interface FetcherDefinition<TParams extends unknown[], TData> {
215
+ /** Namespaces this fetcher's keys in the shared cache; used for devtools and request-tag derivation */
216
+ name: string;
217
+ /**
218
+ * Fetches the data once. Return an observable that emits the result and
219
+ * completes.
220
+ */
221
+ fetch: (instance: SanityInstance) => (...params: TParams) => Observable<TData>;
222
+ /** Converts params into the cache key that identifies an entry (unique within `name`) */
223
+ getKey: (instance: SanityInstance, ...params: TParams) => string;
224
+ /**
225
+ * Cache tags each entry carries, for cache-wide invalidation. A static array,
226
+ * or a function of the fetched data when tags depend on the response (e.g. one
227
+ * tag per list item).
228
+ */
229
+ tags?: CacheTag[] | ((data: TData, ...params: TParams) => CacheTag[]);
230
+ /**
231
+ * How long fetched data is fresh, in ms. Fresh entries never refetch;
232
+ * stale entries serve cached data and revalidate in the background.
233
+ * @defaultValue 30_000
234
+ */
235
+ staleTime?: number;
236
+ /**
237
+ * How long an entry survives after its last unsubscribe before it is garbage
238
+ * collected, in ms. The clock starts at the last unsubscribe — entries with
239
+ * active subscribers are never collected.
240
+ * @defaultValue 300_000
241
+ */
242
+ gcTime?: number;
243
+ /**
244
+ * Refetch on this interval (ms) while the entry has at least one subscriber,
245
+ * independent of staleness. Ticks are skipped while `document.hidden`. Off by default.
246
+ */
247
+ refetchInterval?: number;
248
+ /**
249
+ * Consulted once, when an entry is being created and no cached data exists for
250
+ * it. Return data pulled from another fetcher in the same cache — read via its
251
+ * ordinary `getState(instance, ...).getCurrent()`, e.g. a detail entry pulling
252
+ * its item out of the cached list — to skip or soften the initial fetch.
253
+ * `dataUpdatedAt` must be when the source data was fetched, not "now": staleness
254
+ * is measured from it. Return `undefined` to fetch as normal.
255
+ */
256
+ initialData?: (instance: SanityInstance, ...params: TParams) => {
257
+ data: TData;
258
+ dataUpdatedAt: number;
259
+ } | undefined;
260
+ }
261
+ /**
262
+ * A typed handle over the shared fetcher cache, returned by
263
+ * {@link defineFetcher}. It is a view onto the entries under its definition's
264
+ * `name`, not a cache of its own.
265
+ *
266
+ * @internal
267
+ */
268
+ interface Fetcher<TParams extends unknown[], TData> {
269
+ /** Reactive envelope for one entry. Subscribing triggers fetching per staleness rules. */
270
+ getState: (instance: SanityInstance, ...params: TParams) => StateSource<FetcherSnapshot<TData>>;
271
+ /**
272
+ * Resolves with the entry's first available data — the promise a suspending
273
+ * component throws. Rejects if the initial fetch fails.
274
+ */
275
+ resolveState: (instance: SanityInstance, ...params: TParams) => Promise<TData>;
276
+ /**
277
+ * Marks the entry stale. If it has active subscribers it refetches immediately;
278
+ * otherwise it refetches on next subscribe.
279
+ */
280
+ invalidate: (instance: SanityInstance, ...params: TParams) => void;
281
+ /** {@link Fetcher.invalidate} for every entry under this fetcher's `name`. */
282
+ invalidateAll: (instance: SanityInstance) => void;
283
+ /**
284
+ * Imperative fetch, bypassing staleness. Dedupes against an in-flight fetch.
285
+ * Resolves with the entry's data as held by the cache once the fetch settles.
286
+ */
287
+ refetch: (instance: SanityInstance, ...params: TParams) => Promise<TData>;
288
+ /**
289
+ * Writes an entry's data directly. Returns an undo handle — inside a
290
+ * mutation's `onMutate` these writes are recorded and rolled back automatically
291
+ * on failure.
292
+ */
293
+ setData: (instance: SanityInstance, params: TParams, updater: TData | ((current: TData | undefined) => TData)) => {
294
+ undo: () => void;
295
+ };
296
+ }
297
+ /**
298
+ * Writes an entry's data in any fetcher. Passed to {@link MutationDefinition}
299
+ * callbacks — mutations are the only holders of arbitrary write access; read
300
+ * fetchers pull their data (see {@link FetcherDefinition.initialData}). Inside
301
+ * `onMutate`, every write is recorded and undone automatically if the mutation
302
+ * fails.
303
+ *
304
+ * @internal
305
+ */
306
+ type CacheWriter = <TParams extends unknown[], TData>(fetcher: Fetcher<TParams, TData>, params: TParams, updater: TData | ((current: TData | undefined) => TData)) => void;
307
+ /**
308
+ * Resolves when the mutation settles on the server. `invalidated` tracks the
309
+ * background reconciliation — the refetches triggered by
310
+ * {@link MutationDefinition.invalidates} — for the rare caller that must wait for
311
+ * full reconvergence rather than server settlement.
312
+ *
313
+ * @internal
314
+ */
315
+ interface MutationResult<TResult> {
316
+ /** The server response */
317
+ data: TResult;
318
+ /** Settles when the refetches of matched active entries complete */
319
+ invalidated: Promise<void>;
320
+ }
321
+ /**
322
+ * Defines a mutation with optimistic cache updates. Lifecycle:
323
+ *
324
+ * 1. `onMutate` applies optimistic writes synchronously — the UI updates before
325
+ * the request leaves. Each entry carries a version counter that increments on
326
+ * every write. An optimistic write bumps the counter, so a revalidation already
327
+ * in flight lands "out of date" and is discarded rather than clobbering the
328
+ * optimistic write.
329
+ * 2. The request runs. On failure, recorded writes are rolled back automatically
330
+ * — the cache is restored exactly, so failure ends the lifecycle here.
331
+ * 3. On success, `onSuccess` may write the server response into the cache directly.
332
+ * 4. On success, `invalidates` tags mark matching entries across the cache
333
+ * stale (active entries refetch), so the cache reconverges on server truth
334
+ * even if the optimistic shape was wrong.
335
+ *
336
+ * @internal
337
+ */
338
+ interface MutationDefinition<TInput, TResult> {
339
+ /** Unique mutation name, used for devtools and request-tag derivation */
340
+ name: string;
341
+ /** Creates the observable that performs the server mutation */
342
+ mutationFn: (instance: SanityInstance) => (input: TInput) => Observable<TResult>;
343
+ /** Optimistic cache writes, applied synchronously before the request */
344
+ onMutate?: (write: CacheWriter, input: TInput) => void;
345
+ /** Reconcile the cache with the server response, avoiding a refetch round-trip */
346
+ onSuccess?: (write: CacheWriter, result: TResult, input: TInput) => void;
347
+ /**
348
+ * Cache tags to invalidate on success. Failure invalidates nothing: recorded
349
+ * optimistic writes roll back to the exact pre-mutation cache, and any
350
+ * server-side ambiguity (e.g. timeout after commit) heals via `staleTime`.
351
+ * A static array, or a function of the result/input.
352
+ */
353
+ invalidates?: CacheTag[] | ((result: TResult, input: TInput) => CacheTag[]);
354
+ }
355
+ /**
356
+ * Registers a fetcher definition against the shared cache and returns its typed
357
+ * handle.
358
+ *
359
+ * @internal
360
+ */
361
+ declare function defineFetcher<TParams extends unknown[], TData>(definition: FetcherDefinition<TParams, TData>): Fetcher<TParams, TData>;
362
+ /**
363
+ * Creates a bound mutation from its definition. The returned action resolves at
364
+ * server settlement — not after invalidation refetches, which run as background
365
+ * reconciliation (see {@link MutationResult.invalidated}).
366
+ *
367
+ * @internal
368
+ */
369
+ declare function defineMutation<TInput, TResult>(definition: MutationDefinition<TInput, TResult>): (instance: SanityInstance, input: TInput) => Promise<MutationResult<TResult>>;
370
+ /**
371
+ * The resource types the Access API can scope a permission check to.
372
+ *
373
+ * @see https://www.sanity.io/docs/http-reference/access-api
374
+ * @public
375
+ */
376
+ type AccessResourceType = 'organization' | 'project' | 'media-library' | 'canvas' | 'dashboard' | 'view';
377
+ /**
378
+ * Fetcher checking whether the current user holds the given permissions on a
379
+ * resource (`GET /access/:resourceType/:resourceId/user-permissions/me/check`),
380
+ * on the shared fetcher cache. Resolves to a map of each requested permission
381
+ * to whether the user has it. The key sorts the permission list, so permission
382
+ * order doesn't create distinct cache entries.
383
+ *
384
+ * @see https://www.sanity.io/docs/http-reference/access-api
385
+ * @internal
386
+ */
387
+ declare const checkPermissions: Fetcher<[resourceType: AccessResourceType, resourceId: string, permissions: string[]], Record<string, boolean>>;
388
+ /**
389
+ * A response field that the API embeds only when its `include` token was
390
+ * requested. Given the full set of tokens `All`, the token `Key` this field
391
+ * maps to, and the tokens actually `Requested`, it resolves to:
392
+ *
393
+ * - `unknown` (field absent) when nothing — or nothing matching `Key` — was requested
394
+ * - `Field` (present, as declared) when a literal request list contains `Key`
395
+ * - `Partial<Field>` (optional) when `Requested` is the wide `All` union, i.e.
396
+ * an `include` array whose members aren't known at the type level
397
+ *
398
+ * Absent arms return `unknown` so they vanish under intersection. Mirrors the
399
+ * `boolean extends Flag` trick the organization/project types use, but for an
400
+ * include-token union rather than a boolean flag.
401
+ *
402
+ * @internal
403
+ */
404
+ type Included<All extends string, Key extends All, Requested extends All, Field> = [All] extends [Requested] ? Partial<Field> : [Key] extends [Requested] ? Field : unknown;
405
+ /**
406
+ * Whether the requested include tokens intersect a given set — used to decide
407
+ * whether a parent field (e.g. an application's `activeDeployment`) is present,
408
+ * when requesting any of several tokens forces it in.
409
+ *
410
+ * @internal
411
+ */
412
+ type IncludesAny<Requested extends string, Set extends string> = [Requested & Set] extends [never] ? false : true;
413
+ /**
414
+ * Related data the Applications API can embed in a response. `interfaces`,
415
+ * `workspaces` and `access` are children of the active deployment and are
416
+ * embedded under {@link Application.activeDeployment}; `config.studio` and
417
+ * `config.mfManifest` are embedded under {@link Application.config}.
418
+ *
419
+ * @see https://www.sanity.io/docs/http-reference/applications-api
420
+ * @public
421
+ */
422
+ type ApplicationInclude = 'interfaces' | 'workspaces' | 'access' | 'config.studio' | 'config.mfManifest' | 'activeDeployment';
423
+ /**
424
+ * An interface exposed by a deployment, embedded when `interfaces` is included.
425
+ *
426
+ * @see https://www.sanity.io/docs/http-reference/applications-api
427
+ * @public
428
+ */
429
+ interface ApplicationInterface {
430
+ id: string;
431
+ type: 'app' | 'worker' | 'asset_source' | 'panel';
432
+ name: string;
433
+ title: string;
434
+ version: string;
435
+ /** Module federation module ID; resolved from the host mf-manifest at runtime */
436
+ moduleId: string;
437
+ metadata: {
438
+ group?: string;
439
+ priority?: number;
440
+ } | null;
441
+ }
442
+ /**
443
+ * A studio workspace of a deployment, embedded when `workspaces` is included.
444
+ * Studio applications only.
445
+ *
446
+ * @see https://www.sanity.io/docs/http-reference/applications-api
447
+ * @public
448
+ */
449
+ interface ApplicationWorkspace {
450
+ id: string;
451
+ name: string;
452
+ title: string | null;
453
+ subtitle: string | null;
454
+ projectId: string;
455
+ dataset: string;
456
+ schemaDescriptorId: string | null;
457
+ basePath: string | null;
458
+ /** Sanitized SVG icon markup */
459
+ icon: string | null;
460
+ }
461
+ /**
462
+ * A resource an application accesses, embedded when `access` is included.
463
+ *
464
+ * @see https://www.sanity.io/docs/http-reference/applications-api
465
+ * @public
466
+ */
467
+ interface ApplicationAccess {
468
+ id: string;
469
+ resourceType: 'datasets' | 'canvases' | 'dashboards' | 'media-libraries';
470
+ resourceId: string;
471
+ }
472
+ /**
473
+ * Studio configuration, embedded under `config` when `config.studio` is included.
474
+ *
475
+ * @see https://www.sanity.io/docs/http-reference/applications-api
476
+ * @public
477
+ */
478
+ interface ApplicationStudioConfig {
479
+ projectId: string;
480
+ /** Release channel (`next`, `stable`, `latest`) or a pinned semver; null if unset */
481
+ autoUpdatingVersion: string | null;
482
+ }
483
+ /**
484
+ * The active deployment as embedded under {@link Application.activeDeployment}.
485
+ * Its `interfaces`, `workspaces` and `access` children are each present only
486
+ * when the matching {@link ApplicationInclude} token was requested. `workspaces`
487
+ * is omitted (not `null`) for non-studio applications even when requested.
488
+ *
489
+ * @see https://www.sanity.io/docs/http-reference/applications-api
490
+ * @public
491
+ */
492
+ type ApplicationDeployment<Include extends ApplicationInclude = never> = {
493
+ id: string;
494
+ applicationId: string;
495
+ size: number | null;
496
+ version: string | null;
497
+ isAutoUpdating: boolean | null;
498
+ isActiveDeployment: boolean;
499
+ deployedBy: string | null;
500
+ createdAt: string;
501
+ updatedAt: string;
502
+ } & Included<ApplicationInclude, 'interfaces', Include, {
503
+ interfaces: ApplicationInterface[];
504
+ }> & Included<ApplicationInclude, 'workspaces', Include, {
505
+ workspaces?: ApplicationWorkspace[];
506
+ }> & Included<ApplicationInclude, 'access', Include, {
507
+ access: ApplicationAccess[];
508
+ }>;
509
+ /**
510
+ * The always-present fields of an org-owned application returned by the
511
+ * Applications API (`/applications`), before any {@link ApplicationInclude}.
512
+ *
513
+ * @see https://www.sanity.io/docs/http-reference/applications-api
514
+ * @public
515
+ */
516
+ interface ApplicationBase {
517
+ id: string;
518
+ type: 'studio' | 'coreApp';
519
+ title: string;
520
+ /** Stable, immutable identity, distinct from the mutable `slug` address. */
521
+ name: string;
522
+ /** Qualified, globally-unique handle: `sanity/<name>` for singletons, `<organizationId>/<name>` otherwise. */
523
+ reference: string;
524
+ icon: string | null;
525
+ isSingleton: boolean;
526
+ visibility: 'default' | 'unlisted' | 'disabled';
527
+ slug: string | null;
528
+ externalUrl: string | null;
529
+ organizationId: string;
530
+ createdAt: string;
531
+ updatedAt: string;
532
+ }
533
+ type DeploymentToken = 'activeDeployment' | 'interfaces' | 'workspaces' | 'access';
534
+ type ApplicationConfigShape<Include extends ApplicationInclude> = Included<ApplicationInclude, 'config.studio', Include, {
535
+ config: {
536
+ studio: ApplicationStudioConfig;
537
+ };
538
+ }> & Included<ApplicationInclude, 'config.mfManifest', Include, {
539
+ config: {
540
+ mfManifest: unknown;
541
+ };
542
+ }>;
543
+ type ApplicationDeploymentShape<Include extends ApplicationInclude> = [ApplicationInclude] extends [Include] ? {
544
+ activeDeployment?: ApplicationDeployment<Include> | null;
545
+ } : IncludesAny<Include, DeploymentToken> extends true ? {
546
+ activeDeployment: ApplicationDeployment<Include> | null;
547
+ } : unknown;
548
+ /**
549
+ * An org-owned application as returned by the Applications API
550
+ * (`/applications`). `config` and `activeDeployment` (with its
551
+ * `interfaces`/`workspaces`/`access` children) are present only when the
552
+ * corresponding {@link ApplicationInclude} tokens were requested.
553
+ *
554
+ * @see https://www.sanity.io/docs/http-reference/applications-api
555
+ * @public
556
+ */
557
+ type Application<Include extends ApplicationInclude = never> = ApplicationBase & ApplicationConfigShape<Include> & ApplicationDeploymentShape<Include>;
558
+ /**
559
+ * Options for listing an organization's applications.
560
+ *
561
+ * @see https://www.sanity.io/docs/http-reference/applications-api
562
+ * @public
563
+ */
564
+ interface ApplicationsOptions<Include extends ApplicationInclude = ApplicationInclude> {
565
+ organizationId: string;
566
+ /** Filter by application type */
567
+ type?: string;
568
+ include?: Include[];
569
+ /** Page size (1-100, default 50), or `'none'` to disable pagination */
570
+ limit?: number | 'none';
571
+ /** Cursor from a previous response's `nextCursor` */
572
+ cursor?: string;
573
+ }
574
+ /**
575
+ * The cursor-paginated envelope returned by `GET /applications`.
576
+ *
577
+ * @see https://www.sanity.io/docs/http-reference/applications-api
578
+ * @public
579
+ */
580
+ interface ApplicationsResponse<Include extends ApplicationInclude = never> {
581
+ nextCursor: string | null;
582
+ data: Application<Include>[];
583
+ }
584
+ /**
585
+ * Fetcher for an organization's applications (`GET /applications`), on the
586
+ * shared fetcher cache.
587
+ *
588
+ * @see https://www.sanity.io/docs/http-reference/applications-api
589
+ * @internal
590
+ */
591
+ declare const applications: Fetcher<[options: ApplicationsOptions<ApplicationInclude>], ApplicationsResponse<ApplicationInclude>>;
592
+ /**
593
+ * Fetcher for a single application (`GET /applications/:id`), on the shared
594
+ * fetcher cache. No pre-seeding from {@link applications}: its list keys
595
+ * include the organization, which this fetcher's params can't reconstruct.
596
+ *
597
+ * @see https://www.sanity.io/docs/http-reference/applications-api
598
+ * @internal
599
+ */
600
+ declare const application: Fetcher<[applicationId: string, options?: {
601
+ include?: ApplicationInclude[];
602
+ } | undefined], Application<ApplicationInclude>>;
603
+ /**
604
+ * Confirmation returned by the API's soft-delete endpoints.
605
+ *
606
+ * @see https://www.sanity.io/docs/http-reference/applications-api
607
+ * @internal
608
+ */
609
+ interface DeletedResult {
610
+ deleted: boolean;
611
+ }
612
+ /**
613
+ * Dashboard visibility for an application.
614
+ *
615
+ * @see https://www.sanity.io/docs/http-reference/applications-api
616
+ * @internal
617
+ */
618
+ type ApplicationVisibility = ApplicationBase['visibility'];
619
+ /**
620
+ * Mutable properties of an application (`PATCH /applications/:id`) — the
621
+ * writable subset of {@link ApplicationBase}, each optional, keyed by id.
622
+ *
623
+ * @see https://www.sanity.io/docs/http-reference/applications-api
624
+ * @internal
625
+ */
626
+ type UpdateApplicationInput = {
627
+ applicationId: string;
628
+ } & Partial<Pick<ApplicationBase, 'title' | 'icon' | 'visibility'>>;
629
+ /**
630
+ * Mutation to update an application (`PATCH /applications/:id`). Invalidates the
631
+ * updated application and the list so active entries reconverge on server truth.
632
+ *
633
+ * @see https://www.sanity.io/docs/http-reference/applications-api
634
+ * @internal
635
+ */
636
+ declare const updateApplication: (instance: SanityInstance, input: UpdateApplicationInput) => Promise<MutationResult<ApplicationBase>>;
637
+ /**
638
+ * Input for {@link deleteApplication}.
639
+ *
640
+ * @internal
641
+ */
642
+ interface DeleteApplicationInput {
643
+ applicationId: string;
644
+ }
645
+ /**
646
+ * Mutation to soft-delete an application (`DELETE /applications/:id`).
647
+ * Invalidates the deleted application and the list.
648
+ *
649
+ * @see https://www.sanity.io/docs/http-reference/applications-api
650
+ * @internal
651
+ */
652
+ declare const deleteApplication: (instance: SanityInstance, input: DeleteApplicationInput) => Promise<MutationResult<DeletedResult>>;
653
+ /**
654
+ * Represents the various states the authentication type can be in.
655
+ *
656
+ * @public
657
+ */
658
+ declare enum AuthStateType {
659
+ LOGGED_IN = "logged-in",
660
+ LOGGING_IN = "logging-in",
661
+ ERROR = "error",
662
+ LOGGED_OUT = "logged-out"
663
+ }
664
+ /**
665
+ * Error message returned by the organization verification
666
+ * @public
667
+ */
668
+ interface OrgVerificationResult {
669
+ error: string | null;
670
+ }
671
+ /**
672
+ * Creates an observable that emits the organization verification state for a given instance.
673
+ * It combines the dashboard organization ID (from auth context) with the
674
+ * project's actual organization ID (fetched via the project fetcher) and compares them.
675
+ * @public
676
+ */
677
+ declare function observeOrganizationVerificationState(instance: SanityInstance, projectIds: string[]): Observable<OrgVerificationResult>;
678
+ /**
679
+ * @public
680
+ */
681
+ declare const handleAuthCallback: BoundStoreAction<AuthStoreState, [locationHref?: string | undefined], Promise<string | false>>;
682
+ /**
683
+ * @public
684
+ */
685
+ declare const logout: BoundStoreAction<AuthStoreState, [], Promise<void>>;
686
+ type AllowedClientConfigKey = 'useCdn' | 'token' | 'perspective' | 'apiHost' | 'proxy' | 'withCredentials' | 'timeout' | 'maxRetries' | 'dataset' | 'projectId' | 'requestTagPrefix' | 'useProjectHostname';
687
+ /**
688
+ * States tracked by the client store
689
+ * @public
690
+ */
691
+ interface ClientStoreState {
692
+ token: string | null;
693
+ clients: { [TKey in string]?: SanityClient; };
694
+ authMethod?: 'localstorage' | 'cookie';
695
+ }
696
+ /**
697
+ * Options used when retrieving a client instance from the client store.
698
+ *
699
+ * This interface extends the base {@link ClientConfig} and adds:
700
+ *
701
+ * - **apiVersion:** A required string indicating the API version for the client.
702
+ * - **scope:** An optional flag to choose between the project-specific client
703
+ * ('project') and the global client ('global'). When set to `'global'`, the
704
+ * global client is used.
705
+ *
706
+ * These options are utilized by `getClient` and `getClientState` to configure and
707
+ * return appropriate client instances that automatically handle authentication
708
+ * updates and configuration changes.
709
+ *
710
+ * @public
711
+ */
712
+ interface ClientOptions extends Pick<ClientConfig, AllowedClientConfigKey> {
713
+ /**
714
+ * An optional flag to choose between the default client (typically project-level)
715
+ * and the global client ('global'). When set to `'global'`, the global client
716
+ * is used.
717
+ */
718
+ scope?: 'default' | 'global';
719
+ /**
720
+ * A required string indicating the API version for the client.
721
+ */
722
+ apiVersion: string;
723
+ /**
724
+ * @internal
725
+ * The SDK resource to use for the client -- this will get transformed into a ClientConfig resource.
726
+ */
727
+ resource?: DocumentResource;
728
+ }
729
+ /**
730
+ * Retrieves a Sanity client instance configured with the provided options.
731
+ *
732
+ * This function returns a client instance configured for the project or as a
733
+ * global client based on the options provided. It ensures efficient reuse of
734
+ * client instances by returning the same instance for the same options.
735
+ * For automatic handling of authentication token updates, consider using
736
+ * `getClientState`.
737
+ *
738
+ * @public
739
+ */
740
+ declare const getClient: BoundStoreAction<ClientStoreState, [options: ClientOptions], SanityClient>;
741
+ /**
742
+ * Returns a state source for the Sanity client instance.
743
+ *
744
+ * This function provides a subscribable state source that emits updated client
745
+ * instances whenever relevant configurations change (such as authentication tokens).
746
+ * Use this when you need to react to client configuration changes in your application.
747
+ *
748
+ * @public
749
+ */
750
+ declare const getClientState: BoundStoreAction<ClientStoreState, [options: ClientOptions], StateSource<SanityClient>>;
751
+ /**
752
+ * Whether a thread is still being discussed or has been closed out.
753
+ * @beta
754
+ */
755
+ type CommentStatus = 'open' | 'resolved';
756
+ /**
757
+ * The body of a comment, as Portable Text.
758
+ *
759
+ * Mentions appear here as inline objects of type `mention` carrying a `userId`.
760
+ * The SDK stores and returns them untouched, so a mention written in the Studio
761
+ * survives a round trip, but there is no API for composing one yet.
762
+ * @beta
763
+ */
764
+ type CommentMessage = PortableTextBlock[] | null;
765
+ /**
766
+ * One block touched by a text selection, and that block's text with the
767
+ * selection boundaries marked.
768
+ *
769
+ * `text` is the block's *entire* plain text with two private-use sentinel
770
+ * characters (U+F000 and U+F001) inserted where the selection starts and ends.
771
+ * Storing marked-up text rather than character offsets is what lets a highlight
772
+ * survive edits elsewhere in the same block.
773
+ * @beta
774
+ */
775
+ interface CommentTextSelectionItem {
776
+ _key: string;
777
+ text: string;
778
+ }
779
+ /**
780
+ * A comment anchored to a run of text inside a Portable Text field.
781
+ *
782
+ * The SDK passes this through untouched. Resolving it back to a position in a
783
+ * live editor needs the editor's current value, so that lives in
784
+ * `@portabletext/plugin-sdk-value` rather than here.
785
+ * @beta
786
+ */
787
+ interface CommentTextSelection {
788
+ type: 'text';
789
+ value: CommentTextSelectionItem[];
790
+ }
791
+ /**
792
+ * An emoji reaction on a comment.
793
+ *
794
+ * Read only for now: a reaction added in the Studio shows up here, but there is
795
+ * no action for adding or removing one.
796
+ * @beta
797
+ */
798
+ interface CommentReaction {
799
+ shortName: string;
800
+ userId: string;
801
+ addedAt: string;
802
+ }
803
+ /**
804
+ * Why a comment is not yet on the server.
805
+ *
806
+ * Local only, never written. Present on a comment whose create request failed,
807
+ * so an app can offer a retry.
808
+ * @beta
809
+ */
810
+ type CommentLocalState = {
811
+ type: 'createError';
812
+ error: Error;
813
+ } | {
814
+ type: 'createRetrying';
815
+ };
816
+ /**
817
+ * A single comment.
818
+ *
819
+ * Deliberately not the stored document. Comments are moving from per-dataset
820
+ * addon datasets to an organization-level store, and the two disagree on the
821
+ * document type, on how the commented document is referenced, and on where the
822
+ * author is recorded. Everything here reads the same on both sides, so an app
823
+ * written against this survives the move.
824
+ *
825
+ * Threads are flat: every comment in a thread shares a `threadId`, the thread's
826
+ * first comment has no `parentCommentId`, and replies carry that first comment's
827
+ * `id`. Use {@link CommentThread} to work with them grouped.
828
+ *
829
+ * @beta
830
+ */
831
+ interface Comment {
832
+ id: string;
833
+ createdAt: string;
834
+ /**
835
+ * Who wrote it.
836
+ *
837
+ * Absent when the server carries the author instead of the document. The
838
+ * Studio's comments dataset stores it on the document, so it is present on
839
+ * everything written today, but an agent-authored comment records
840
+ * attribution elsewhere. Render a fallback rather than assuming a user id.
841
+ */
842
+ authorId?: string;
843
+ message: CommentMessage;
844
+ threadId: string;
845
+ /** Absent on the comment that starts a thread. */
846
+ parentCommentId?: string;
847
+ status: CommentStatus;
848
+ /** Set once the message has been rewritten. */
849
+ lastEditedAt?: string;
850
+ /** The document the thread hangs on, always the published id. */
851
+ documentId: string;
852
+ documentType: string;
853
+ /** The field the thread hangs off, for example `title`. */
854
+ fieldPath: string;
855
+ /** Set when the comment is anchored to a run of text in a Portable Text field. */
856
+ selection?: CommentTextSelection;
857
+ /** A copy of the content the comment was written about. */
858
+ contentSnapshot?: unknown;
859
+ reactions: CommentReaction[];
860
+ /** Local only. Present while a create is failing or being retried. */
861
+ state?: CommentLocalState;
862
+ }
863
+ /**
864
+ * A thread: one comment plus its replies.
865
+ *
866
+ * Unlike the Studio, the SDK returns every thread it finds. The Studio hides
867
+ * threads whose field is gone from the schema or hidden by a conditional, which
868
+ * it can do because it has the schema. Check `fieldPath` yourself if your app
869
+ * needs the same behaviour.
870
+ * @beta
871
+ */
872
+ interface CommentThread {
873
+ threadId: string;
874
+ /** The field the thread hangs off, taken from its first comment. */
875
+ fieldPath: string;
876
+ parentComment: Comment;
877
+ /** Oldest first. */
878
+ replies: Comment[];
879
+ /** The parent plus its replies. */
880
+ commentsCount: number;
881
+ /** Taken from the parent comment; replies follow it. */
882
+ status: CommentStatus;
883
+ /** `createdAt` of the most recent comment in the thread. */
884
+ lastActivityAt: string;
885
+ }
886
+ /** @beta */
887
+ interface CreateCommentOptions extends DocumentHandle {
888
+ message: CommentMessage;
889
+ /**
890
+ * Which field the thread hangs off, for example `title` or
891
+ * `body[_key=="intro"].content`.
892
+ *
893
+ * Required, and it has to resolve to a real path. There is no such thing as a
894
+ * comment on a document as a whole: the Studio only ever creates field
895
+ * comments, and its comment inspector throws on an empty path rather than
896
+ * ignoring it, so a pathless comment takes the inspector down for everyone
897
+ * looking at that document.
898
+ */
899
+ fieldPath: string | Path;
900
+ /**
901
+ * Anchors the comment to a run of text inside a Portable Text field. Building
902
+ * one needs a live editor, so this comes from
903
+ * `@portabletext/plugin-sdk-value` rather than being constructed by hand.
904
+ */
905
+ selection?: CommentTextSelection;
906
+ /** Reuse the id of a failed comment to retry it. Defaults to a new id. */
907
+ commentId?: string;
908
+ /** Defaults to a new id, which starts a new thread. */
909
+ threadId?: string;
910
+ /** @defaultValue `'open'` */
911
+ status?: CommentStatus;
912
+ /**
913
+ * The `_rev` of the document when the comment was written.
914
+ *
915
+ * Not filled in automatically: the SDK's local document revision is replaced
916
+ * by a transaction id while an edit is in flight, so it can name a revision
917
+ * that never reached the server. Nothing in the Studio reads this today.
918
+ */
919
+ documentRevisionId?: string;
920
+ /**
921
+ * Ambient information stored alongside the comment, merged over the defaults.
922
+ *
923
+ * The Studio writes `tool`, `payload`, `intent`, and `notification` here for
924
+ * its notification backend. The SDK has no source for any of them, so
925
+ * mentions in comments created this way do not send email unless you supply
926
+ * `notification` yourself. Deliberately loose: the organization-level store
927
+ * treats this as free-form, so no shape is worth promising.
928
+ */
929
+ context?: Record<string, unknown>;
930
+ /** A copy of the content being discussed. References in it are weakened. */
931
+ contentSnapshot?: unknown;
932
+ }
933
+ /** @beta */
934
+ interface ReplyToCommentOptions extends DocumentHandle {
935
+ /** The comment being replied to. Replies to a reply join the same thread. */
936
+ parentCommentId: string;
937
+ message: CommentMessage;
938
+ commentId?: string;
939
+ /** Only needed when the parent is not loaded, such as following a deep link. */
940
+ threadId?: string;
941
+ /** Only needed when the parent is not loaded. */
942
+ fieldPath?: string | Path;
943
+ /** Required when the parent is not loaded. */
944
+ status?: CommentStatus;
945
+ }
946
+ /** @beta */
947
+ interface UpdateCommentOptions extends DatasetHandle {
948
+ commentId: string;
949
+ message: CommentMessage;
950
+ }
951
+ /** @beta */
952
+ interface SetCommentStatusOptions extends DatasetHandle {
953
+ /** The thread's first comment. Replies follow their parent. */
954
+ commentId: string;
955
+ status: CommentStatus;
956
+ }
957
+ /** @beta */
958
+ interface RemoveCommentOptions extends DatasetHandle {
959
+ commentId: string;
960
+ }
961
+ /**
962
+ * Starts a thread on a document, or on one of its fields.
963
+ *
964
+ * Creates the project's comments dataset if this is the first comment anywhere
965
+ * in it. The comment appears locally before the server confirms it; if the
966
+ * write fails it stays, carrying `_state.createError`, and retrying with the
967
+ * same `commentId` replaces it.
968
+ *
969
+ * @beta
970
+ */
971
+ declare const createComment: (instance: SanityInstance, options: CreateCommentOptions) => Promise<Comment>;
972
+ /**
973
+ * Adds a reply to an existing thread.
974
+ *
975
+ * The thread and field are taken from the parent comment, so a reply always
976
+ * matches the same list as the comment it answers. Supply them only when the
977
+ * parent is not loaded.
978
+ *
979
+ * @beta
980
+ */
981
+ declare const replyToComment: (instance: SanityInstance, options: ReplyToCommentOptions) => Promise<Comment>;
982
+ /**
983
+ * Rewrites a comment's message and stamps `lastEditedAt`.
984
+ * @beta
985
+ */
986
+ declare const updateComment: (instance: SanityInstance, options: UpdateCommentOptions) => Promise<void>;
987
+ /**
988
+ * Resolves or reopens a thread.
989
+ *
990
+ * Pass the thread's first comment: replies follow it, patched server-side in
991
+ * one query so a reply created by someone else at the same moment is caught
992
+ * too.
993
+ *
994
+ * @beta
995
+ */
996
+ declare const setCommentStatus: (instance: SanityInstance, options: SetCommentStatusOptions) => Promise<void>;
997
+ /**
998
+ * Deletes a comment, and its replies when it starts a thread.
999
+ * @beta
1000
+ */
1001
+ declare const removeComment: (instance: SanityInstance, options: RemoveCommentOptions) => Promise<void>;
1002
+ /**
1003
+ * Which comments to read.
1004
+ * @beta
1005
+ */
1006
+ interface CommentsOptions extends DocumentHandle {
1007
+ /**
1008
+ * Narrow to one field. Omit to get every comment on the document.
1009
+ */
1010
+ fieldPath?: string | Path;
1011
+ /** Narrow to open or resolved threads. Omit for both. */
1012
+ status?: CommentStatus;
1013
+ }
1014
+ /** @beta */
1015
+ interface ResolveCommentsOptions extends CommentsOptions {
1016
+ signal?: AbortSignal;
1017
+ }
1018
+ /**
1019
+ * A stable string standing for one set of read options.
1020
+ *
1021
+ * Only React needs this: it holds one state source steady across renders and
1022
+ * defers swapping to a new one while the previous list is still on screen.
1023
+ * `fieldPath` is normalised on the way in, so a path array and the equivalent
1024
+ * string address the same list.
1025
+ *
1026
+ * @internal
1027
+ */
1028
+ declare function getCommentsOptionsKey(options: CommentsOptions): string;
1029
+ /** @internal */
1030
+ declare function parseCommentsOptionsKey(key: string): CommentsOptions;
1031
+ /**
1032
+ * Every comment on a document, newest first.
1033
+ *
1034
+ * `undefined` until the first snapshot arrives. Replies are included; use
1035
+ * {@link getCommentThreadsState} to read them grouped.
1036
+ *
1037
+ * @beta
1038
+ */
1039
+ declare const getCommentsState: (instance: SanityInstance, options: CommentsOptions) => StateSource<Comment[] | undefined>;
1040
+ /**
1041
+ * Threads on a document, newest thread first, each with its replies oldest first.
1042
+ *
1043
+ * A thread's `status` and `fieldPath` come from its first comment, so filtering
1044
+ * by either selects whole threads rather than individual replies.
1045
+ *
1046
+ * @beta
1047
+ */
1048
+ declare const getCommentThreadsState: (instance: SanityInstance, options: CommentsOptions) => StateSource<CommentThread[] | undefined>;
1049
+ /**
1050
+ * Waits for a document's comments to load.
1051
+ *
1052
+ * Holds a subscriber only while resolving, so a component that suspends on this
1053
+ * and then errors before mounting does not strand the list. Throw the promise
1054
+ * for Suspense, then read through {@link getCommentsState}.
1055
+ *
1056
+ * @beta
1057
+ */
1058
+ declare const resolveComments: (instance: SanityInstance, options: ResolveCommentsOptions) => Promise<Comment[]>;
1059
+ /**
1060
+ * Waits for a document's comments to load, grouped into threads.
1061
+ * @beta
1062
+ */
1063
+ declare const resolveCommentThreads: (instance: SanityInstance, options: ResolveCommentsOptions) => Promise<CommentThread[]>;
1064
+ /**
1065
+ * Creates or validates a `DocumentHandle` object.
1066
+ * Ensures the provided object conforms to the `DocumentHandle` interface.
1067
+ * @param handle - The object containing document identification properties.
1068
+ * @returns The validated `DocumentHandle` object.
1069
+ * @public
1070
+ */
1071
+ declare function createDocumentHandle<TDocumentType extends string = string, TDataset extends string = string, TProjectId extends string = string>(handle: DocumentHandle<TDocumentType, TDataset, TProjectId>): DocumentHandle<TDocumentType, TDataset, TProjectId>;
1072
+ /**
1073
+ * Creates or validates a `DocumentTypeHandle` object.
1074
+ * Ensures the provided object conforms to the `DocumentTypeHandle` interface.
1075
+ * @param handle - The object containing document type identification properties.
1076
+ * @returns The validated `DocumentTypeHandle` object.
1077
+ * @public
1078
+ */
1079
+ declare function createDocumentTypeHandle<TDocumentType extends string = string, TDataset extends string = string, TProjectId extends string = string>(handle: DocumentTypeHandle<TDocumentType, TDataset, TProjectId>): DocumentTypeHandle<TDocumentType, TDataset, TProjectId>;
1080
+ /**
1081
+ * Creates or validates a `ProjectHandle` object.
1082
+ * Ensures the provided object conforms to the `ProjectHandle` interface.
1083
+ * @param handle - The object containing project identification properties.
1084
+ * @returns The validated `ProjectHandle` object.
1085
+ * @public
1086
+ */
1087
+ declare function createProjectHandle<TProjectId extends string = string>(handle: ProjectHandle<TProjectId>): ProjectHandle<TProjectId>;
1088
+ /**
1089
+ * Creates or validates a `DatasetHandle` object.
1090
+ * Ensures the provided object conforms to the `DatasetHandle` interface.
1091
+ * @param handle - The object containing dataset identification properties.
1092
+ * @returns The validated `DatasetHandle` object.
1093
+ * @public
1094
+ */
1095
+ declare function createDatasetHandle<TDataset extends string = string, TProjectId extends string = string>(handle: DatasetHandle<TDataset, TProjectId>): DatasetHandle<TDataset, TProjectId>;
1096
+ /**
1097
+ * Logging infrastructure for the Sanity SDK
1098
+ *
1099
+ * Provides multi-level, namespace-based logging for both SDK users and maintainers.
1100
+ * In production builds, all logging can be stripped via tree-shaking.
1101
+ *
1102
+ * @example SDK User
1103
+ * ```ts
1104
+ * import {configureLogging} from '@sanity/sdk'
1105
+ *
1106
+ * configureLogging({
1107
+ * level: 'info',
1108
+ * namespaces: ['auth', 'document']
1109
+ * })
1110
+ * ```
1111
+ *
1112
+ * @example SDK Maintainer
1113
+ * ```ts
1114
+ * configureLogging({
1115
+ * level: 'trace',
1116
+ * namespaces: ['*'],
1117
+ * internal: true
1118
+ * })
1119
+ * ```
1120
+ */
1121
+ /**
1122
+ * Log levels in order of verbosity (least to most)
1123
+ * - error: Critical failures that prevent operation
1124
+ * - warn: Issues that may cause problems but don't stop execution
1125
+ * - info: High-level informational messages (SDK user level)
1126
+ * - debug: Detailed debugging information (maintainer level)
1127
+ * - trace: Very detailed tracing (maintainer level, includes RxJS streams)
1128
+ * @public
1129
+ */
1130
+ type LogLevel = 'error' | 'warn' | 'info' | 'debug' | 'trace';
1131
+ /**
1132
+ * Log namespaces organize logs by functional domain
1133
+ *
1134
+ * @remarks
1135
+ * This is an extensible string type. As logging is added to more modules,
1136
+ * additional namespaces will be recognized. Currently implemented namespaces
1137
+ * will be documented as they are added.
1138
+ * @internal
1139
+ */
1140
+ type LogNamespace = string;
1141
+ /**
1142
+ * Configuration for the logging system
1143
+ * @public
1144
+ */
1145
+ interface LoggerConfig {
1146
+ /**
1147
+ * Minimum log level to output
1148
+ * @defaultValue 'warn'
1149
+ */
1150
+ level?: LogLevel;
1151
+ /**
1152
+ * Namespaces to enable. Use ['*'] for all namespaces
1153
+ * @defaultValue []
1154
+ * @remarks
1155
+ * Available namespaces depend on which modules have logging integrated.
1156
+ * Check the SDK documentation for the current list of instrumented modules.
1157
+ * @example ['auth', 'document']
1158
+ */
1159
+ namespaces?: string[];
1160
+ /**
1161
+ * Enable internal/maintainer-level logging
1162
+ * Shows RxJS streams, store internals, etc.
1163
+ * @defaultValue false
1164
+ */
1165
+ internal?: boolean;
1166
+ /**
1167
+ * Custom log handler (for testing or custom output)
1168
+ * @defaultValue console methods
1169
+ */
1170
+ handler?: LogHandler;
1171
+ /**
1172
+ * Enable timestamps in log output
1173
+ * @defaultValue true
1174
+ */
1175
+ timestamps?: boolean;
1176
+ /**
1177
+ * Enable in production builds
1178
+ * @defaultValue false
1179
+ */
1180
+ enableInProduction?: boolean;
1181
+ }
1182
+ /**
1183
+ * Custom log handler interface
1184
+ *
1185
+ * @internal
1186
+ */
1187
+ interface LogHandler {
1188
+ error: (message: string, context?: LogContext) => void;
1189
+ warn: (message: string, context?: LogContext) => void;
1190
+ info: (message: string, context?: LogContext) => void;
1191
+ debug: (message: string, context?: LogContext) => void;
1192
+ trace: (message: string, context?: LogContext) => void;
1193
+ }
1194
+ /**
1195
+ * Context object attached to log messages
1196
+ *
1197
+ * This interface allows you to attach arbitrary contextual data to log messages.
1198
+ * The index signature `[key: string]: unknown` enables you to add any custom
1199
+ * properties relevant to your log entry (e.g., `userId`, `documentId`, `action`, etc.).
1200
+ *
1201
+ * **Sensitive data sanitization:**
1202
+ * Top-level keys containing sensitive names (`token`, `password`, `secret`, `apiKey`,
1203
+ * `authorization`) are automatically redacted to `[REDACTED]` in log output.
1204
+ *
1205
+ * @example
1206
+ * ```ts
1207
+ * logger.info('User logged in', {
1208
+ * userId: '123', // Custom context
1209
+ * action: 'login', // Custom context
1210
+ * token: 'secret' // Will be redacted to [REDACTED]
1211
+ * })
1212
+ * ```
1213
+ *
1214
+ * @internal
1215
+ */
1216
+ interface LogContext {
1217
+ /**
1218
+ * Custom context properties that provide additional information about the log entry.
1219
+ * Any key-value pairs can be added here (e.g., userId, documentId, requestId, etc.).
1220
+ * Keys with sensitive names (token, password, secret, apiKey, authorization) are
1221
+ * automatically sanitized.
1222
+ */
1223
+ [key: string]: unknown;
1224
+ /** Error object if logging an error */
1225
+ error?: Error | unknown;
1226
+ /** Duration in milliseconds for timed operations */
1227
+ duration?: number;
1228
+ /** Stack trace for debugging */
1229
+ stack?: string;
1230
+ /** Instance context (automatically added when available) */
1231
+ instanceContext?: InstanceContext;
1232
+ }
1233
+ /**
1234
+ * Instance context information automatically added to logs
1235
+ * @internal
1236
+ */
1237
+ interface InstanceContext {
1238
+ /** Unique instance ID */
1239
+ instanceId?: string;
1240
+ /** Project ID */
1241
+ projectId?: string;
1242
+ /** Dataset name */
1243
+ dataset?: string;
1244
+ }
1245
+ /**
1246
+ * Logger instance for a specific namespace
1247
+ * @internal
1248
+ */
1249
+ interface Logger {
1250
+ readonly namespace: string;
1251
+ error: (message: string, context?: LogContext) => void;
1252
+ warn: (message: string, context?: LogContext) => void;
1253
+ info: (message: string, context?: LogContext) => void;
1254
+ debug: (message: string, context?: LogContext) => void;
1255
+ trace: (message: string, context?: LogContext) => void;
1256
+ /** Check if a log level is enabled (for performance-sensitive code) */
1257
+ isLevelEnabled: (level: LogLevel) => boolean;
1258
+ /** Create a child logger with extended context */
1259
+ child: (context: LogContext) => Logger;
1260
+ /** Get the instance context if available */
1261
+ getInstanceContext: () => InstanceContext | undefined;
1262
+ }
1263
+ /**
1264
+ * Configure logging for the Sanity SDK
1265
+ *
1266
+ * This function allows you to control what logs are output by the SDK,
1267
+ * making it easier to debug issues in development or production.
1268
+ *
1269
+ * @remarks
1270
+ * **Zero-Config via Environment Variable (Recommended):**
1271
+ *
1272
+ * The SDK automatically reads the `DEBUG` environment variable, making it
1273
+ * easy to enable logging without code changes:
1274
+ *
1275
+ * ```bash
1276
+ * # Enable all SDK logging at debug level
1277
+ * DEBUG=sanity:* npm start
1278
+ *
1279
+ * # Enable specific namespaces
1280
+ * DEBUG=sanity:auth,sanity:document npm start
1281
+ *
1282
+ * # Enable trace level for all namespaces
1283
+ * DEBUG=sanity:trace:* npm start
1284
+ *
1285
+ * # Enable internal/maintainer logs
1286
+ * DEBUG=sanity:*:internal npm start
1287
+ * ```
1288
+ *
1289
+ * This matches the pattern used by Sanity CLI and Studio, making it familiar
1290
+ * and easy for support teams to help troubleshoot issues.
1291
+ *
1292
+ * **Programmatic Configuration (Advanced):**
1293
+ *
1294
+ * For more control (custom handlers, dynamic configuration), call this function
1295
+ * explicitly. Programmatic configuration overrides environment variables.
1296
+ *
1297
+ * **For Application Developers:**
1298
+ * Use `info`, `warn`, or `error` levels to see high-level SDK activity
1299
+ * without being overwhelmed by internal details.
1300
+ *
1301
+ * **For SDK Maintainers:**
1302
+ * Use `debug` or `trace` levels with `internal: true` to see detailed
1303
+ * information about store operations, RxJS streams, and state transitions.
1304
+ *
1305
+ * **Instance Context:**
1306
+ * Logs automatically include instance information (projectId, dataset, instanceId)
1307
+ * when available, making it easier to debug multi-instance scenarios:
1308
+ * ```
1309
+ * [INFO] [auth] [project:abc] [dataset:production] User logged in
1310
+ * ```
1311
+ *
1312
+ * **Available Namespaces:**
1313
+ * - `sdk` - SDK initialization, configuration, and lifecycle
1314
+ * - `auth` - Authentication and authorization (when instrumented in the future)
1315
+ * - And more as logging is added to modules
1316
+ *
1317
+ * @example Zero-config via environment variable (recommended for debugging)
1318
+ * ```bash
1319
+ * # Just set DEBUG and run your app - no code changes needed!
1320
+ * DEBUG=sanity:* npm start
1321
+ * ```
1322
+ *
1323
+ * @example Programmatic configuration (application developer)
1324
+ * ```ts
1325
+ * import {configureLogging} from '@sanity/sdk'
1326
+ *
1327
+ * // Log warnings and errors for auth and document operations
1328
+ * configureLogging({
1329
+ * level: 'warn',
1330
+ * namespaces: ['auth', 'document']
1331
+ * })
1332
+ * ```
1333
+ *
1334
+ * @example Programmatic configuration (SDK maintainer)
1335
+ * ```ts
1336
+ * import {configureLogging} from '@sanity/sdk'
1337
+ *
1338
+ * // Enable all logs including internal traces
1339
+ * configureLogging({
1340
+ * level: 'trace',
1341
+ * namespaces: ['*'],
1342
+ * internal: true
1343
+ * })
1344
+ * ```
1345
+ *
1346
+ * @example Custom handler (for testing)
1347
+ * ```ts
1348
+ * import {configureLogging} from '@sanity/sdk'
1349
+ *
1350
+ * const logs: string[] = []
1351
+ * configureLogging({
1352
+ * level: 'info',
1353
+ * namespaces: ['*'],
1354
+ * handler: {
1355
+ * error: (msg) => logs.push(msg),
1356
+ * warn: (msg) => logs.push(msg),
1357
+ * info: (msg) => logs.push(msg),
1358
+ * debug: (msg) => logs.push(msg),
1359
+ * trace: (msg) => logs.push(msg),
1360
+ * }
1361
+ * })
1362
+ * ```
1363
+ *
1364
+ * @public
1365
+ */
1366
+ declare function configureLogging(config: LoggerConfig): void;
1367
+ /**
1368
+ * Fetcher for a project's datasets (`GET /datasets`), on the shared fetcher
1369
+ * cache.
1370
+ *
1371
+ * @internal
1372
+ */
1373
+ declare const datasets: Fetcher<[options?: ProjectHandle<string> | undefined], DatasetsResponse>;
1374
+ /**
1375
+ * Represents an action to create a new document.
1376
+ * Specifies the document type and optionally a document ID (which will be treated as the published ID).
1377
+ * @beta
1378
+ */
1379
+ interface CreateDocumentAction<TDocumentType extends string = string, TDataset extends string = string, TProjectId extends string = string> extends DocumentTypeHandle<TDocumentType, TDataset, TProjectId> {
1380
+ type: 'document.create';
1381
+ /**
1382
+ * Optional initial field values for the document.
1383
+ * These values will be set when the document is created.
1384
+ * System fields (_id, _type, _rev, _createdAt, _updatedAt) are omitted as they are set automatically.
1385
+ */
1386
+ initialValue?: Partial<Omit<SanityDocument$2<TDocumentType, `${TProjectId}.${TDataset}`>, '_id' | '_type' | '_rev' | '_createdAt' | '_updatedAt'>>;
1387
+ }
1388
+ /**
1389
+ * Represents an action to delete an existing document.
1390
+ * Requires the full document handle including the document ID.
1391
+ * @beta
1392
+ */
1393
+ interface DeleteDocumentAction<TDocumentType extends string = string, TDataset extends string = string, TProjectId extends string = string> extends DocumentHandle<TDocumentType, TDataset, TProjectId> {
1394
+ type: 'document.delete';
1395
+ }
1396
+ /**
1397
+ * Represents an action to edit an existing document using patches.
1398
+ * Requires the full document handle and an array of patch operations.
1399
+ * @beta
1400
+ */
1401
+ interface EditDocumentAction<TDocumentType extends string = string, TDataset extends string = string, TProjectId extends string = string> extends DocumentHandle<TDocumentType, TDataset, TProjectId> {
1402
+ type: 'document.edit';
1403
+ patches?: PatchOperations[];
1404
+ /**
1405
+ * When `true`, the given `patches` are forwarded verbatim to the server and
1406
+ * applied as-is locally, instead of being re-derived by diffing document
1407
+ * snapshots. This preserves the operational intent of the patches (e.g.
1408
+ * keyed array inserts/unsets), which lets concurrent edits from other
1409
+ * clients interleave coherently instead of being overwritten by
1410
+ * position-based patches computed from a stale snapshot.
1411
+ *
1412
+ * Use this when the patches were produced by an editor that tracks its own
1413
+ * operations (e.g. a collaborative text editor). During a rebase onto a
1414
+ * changed remote document, preserved patches are re-applied operationally;
1415
+ * if a patch can no longer apply, the transaction is skipped and reported
1416
+ * as a `rebase-error` document event.
1417
+ */
1418
+ preserveOperations?: boolean;
1419
+ }
1420
+ /**
1421
+ * Represents an action to publish the draft version of a document.
1422
+ * Requires the full document handle.
1423
+ * @beta
1424
+ */
1425
+ interface PublishDocumentAction<TDocumentType extends string = string, TDataset extends string = string, TProjectId extends string = string> extends DocumentHandle<TDocumentType, TDataset, TProjectId> {
1426
+ type: 'document.publish';
1427
+ }
1428
+ /**
1429
+ * Represents an action to unpublish a document, moving its published content to a draft.
1430
+ * Requires the full document handle.
1431
+ * @beta
1432
+ */
1433
+ interface UnpublishDocumentAction<TDocumentType extends string = string, TDataset extends string = string, TProjectId extends string = string> extends DocumentHandle<TDocumentType, TDataset, TProjectId> {
1434
+ type: 'document.unpublish';
1435
+ }
1436
+ /**
1437
+ * Represents an action to discard the draft changes of a document.
1438
+ * Requires the full document handle.
1439
+ * @beta
1440
+ */
1441
+ interface DiscardDocumentAction<TDocumentType extends string = string, TDataset extends string = string, TProjectId extends string = string> extends DocumentHandle<TDocumentType, TDataset, TProjectId> {
1442
+ type: 'document.discard';
1443
+ }
1444
+ /**
1445
+ * Union type representing all possible document actions within the SDK.
1446
+ * @beta
1447
+ */
1448
+ 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>;
1449
+ /**
1450
+ * Union of every action accepted by `applyDocumentActions` — both document-
1451
+ * level actions and release-lifecycle actions.
1452
+ * @beta
1453
+ */
1454
+ type Action<TDocumentType extends string = string, TDataset extends string = string, TProjectId extends string = string> = DocumentAction<TDocumentType, TDataset, TProjectId> | ReleaseAction;
1455
+ /**
1456
+ * Creates a `CreateDocumentAction` object.
1457
+ * @param doc - A handle identifying the document type, dataset, and project. An optional `documentId` can be provided.
1458
+ * @param initialValue - Optional initial field values for the document. (System fields are omitted as they are set automatically.)
1459
+ * @returns A `CreateDocumentAction` object ready for dispatch.
1460
+ * @beta
1461
+ */
1462
+ declare function createDocument<TDocumentType extends string = string, TDataset extends string = string, TProjectId extends string = string>(doc: DocumentTypeHandle<TDocumentType, TDataset, TProjectId>, initialValue?: Partial<Omit<SanityDocument$2<TDocumentType, `${TProjectId}.${TDataset}`>, '_id' | '_type' | '_rev' | '_createdAt' | '_updatedAt'>>): CreateDocumentAction<TDocumentType, TDataset, TProjectId>;
1463
+ /**
1464
+ * Creates a `DeleteDocumentAction` object.
1465
+ * @param doc - A handle uniquely identifying the document to be deleted.
1466
+ * @returns A `DeleteDocumentAction` object ready for dispatch.
1467
+ * @beta
1468
+ */
1469
+ declare function deleteDocument<TDocumentType extends string = string, TDataset extends string = string, TProjectId extends string = string>(doc: DocumentHandle<TDocumentType, TDataset, TProjectId>): DeleteDocumentAction<TDocumentType, TDataset, TProjectId>;
1470
+ /**
1471
+ * Options for creating an `EditDocumentAction`.
1472
+ * @beta
1473
+ */
1474
+ interface EditDocumentOptions {
1475
+ /**
1476
+ * Forward the given patches verbatim instead of re-deriving them by
1477
+ * diffing document snapshots. See {@link EditDocumentAction.preserveOperations}.
1478
+ */
1479
+ preserveOperations?: boolean;
1480
+ }
1481
+ /**
1482
+ * Creates an `EditDocumentAction` object with patches for modifying a document.
1483
+ * Accepts patches in either the standard `PatchOperations` format or as a `SanityMutatePatchMutation` from `@sanity/mutate`.
1484
+ *
1485
+ * @param doc - A handle uniquely identifying the document to be edited.
1486
+ * @param sanityMutatePatch - A patch mutation object from `@sanity/mutate`.
1487
+ * @param options - Options controlling how the patches are processed.
1488
+ * @returns An `EditDocumentAction` object ready for dispatch.
1489
+ * @beta
1490
+ */
1491
+ declare function editDocument<TDocumentType extends string = string, TDataset extends string = string, TProjectId extends string = string>(doc: DocumentHandle<TDocumentType, TDataset, TProjectId>, sanityMutatePatch: PatchMutation, options?: EditDocumentOptions): EditDocumentAction<TDocumentType, TDataset, TProjectId>;
1492
+ /**
1493
+ * Creates an `EditDocumentAction` object with patches for modifying a document.
1494
+ *
1495
+ * @param doc - A handle uniquely identifying the document to be edited.
1496
+ * @param patches - A single patch operation or an array of patch operations.
1497
+ * @param options - Options controlling how the patches are processed.
1498
+ * @returns An `EditDocumentAction` object ready for dispatch.
1499
+ * @beta
1500
+ */
1501
+ declare function editDocument<TDocumentType extends string = string, TDataset extends string = string, TProjectId extends string = string>(doc: DocumentHandle<TDocumentType, TDataset, TProjectId>, patches?: PatchOperations | PatchOperations[], options?: EditDocumentOptions): EditDocumentAction<TDocumentType, TDataset, TProjectId>;
1502
+ /**
1503
+ * Creates a `PublishDocumentAction` object.
1504
+ * @param doc - A handle uniquely identifying the document to be published.
1505
+ * @returns A `PublishDocumentAction` object ready for dispatch.
1506
+ * @beta
1507
+ */
1508
+ declare function publishDocument<TDocumentType extends string = string, TDataset extends string = string, TProjectId extends string = string>(doc: DocumentHandle<TDocumentType, TDataset, TProjectId>): PublishDocumentAction<TDocumentType, TDataset, TProjectId>;
1509
+ /**
1510
+ * Creates an `UnpublishDocumentAction` object.
1511
+ * @param doc - A handle uniquely identifying the document to be unpublished.
1512
+ * @returns An `UnpublishDocumentAction` object ready for dispatch.
1513
+ * @beta
1514
+ */
1515
+ declare function unpublishDocument<TDocumentType extends string = string, TDataset extends string = string, TProjectId extends string = string>(doc: DocumentHandle<TDocumentType, TDataset, TProjectId>): UnpublishDocumentAction<TDocumentType, TDataset, TProjectId>;
1516
+ /**
1517
+ * Creates a `DiscardDocumentAction` object.
1518
+ * @param doc - A handle uniquely identifying the document whose draft changes are to be discarded.
1519
+ * @returns A `DiscardDocumentAction` object ready for dispatch.
1520
+ * @beta
1521
+ */
1522
+ declare function discardDocument<TDocumentType extends string = string, TDataset extends string = string, TProjectId extends string = string>(doc: DocumentHandle<TDocumentType, TDataset, TProjectId>): DiscardDocumentAction<TDocumentType, TDataset, TProjectId>;
1523
+ /**
1524
+ * Creates a new release. The `releaseId` must be unique within the current
1525
+ * retention period.
1526
+ * @beta
1527
+ */
1528
+ interface CreateReleaseAction extends ReleaseHandle {
1529
+ type: 'release.create';
1530
+ metadata: ReleaseDocument['metadata'];
1531
+ }
1532
+ /**
1533
+ * Patches the metadata of an existing release.
1534
+ * @beta
1535
+ */
1536
+ interface EditReleaseAction extends ReleaseHandle {
1537
+ type: 'release.edit';
1538
+ patch: PatchOperations;
1539
+ }
1540
+ /**
1541
+ * Publishes all version documents in a release.
1542
+ * @beta
1543
+ */
1544
+ interface PublishReleaseAction extends ReleaseHandle {
1545
+ type: 'release.publish';
1546
+ }
1547
+ /**
1548
+ * Schedules a release to be published at the given UTC time. Locks the
1549
+ * version documents server-side until the release is unscheduled or published.
1550
+ * @beta
1551
+ */
1552
+ interface ScheduleReleaseAction extends ReleaseHandle {
1553
+ type: 'release.schedule';
1554
+ publishAt: string;
1555
+ }
1556
+ /**
1557
+ * Unschedules a release that was previously scheduled, returning it to the
1558
+ * active editable state.
1559
+ * @beta
1560
+ */
1561
+ interface UnscheduleReleaseAction extends ReleaseHandle {
1562
+ type: 'release.unschedule';
1563
+ }
1564
+ /**
1565
+ * Archives an active release. Version documents within the release are
1566
+ * removed and no longer queryable, though still recoverable through history
1567
+ * during the retention period.
1568
+ * @beta
1569
+ */
1570
+ interface ArchiveReleaseAction extends ReleaseHandle {
1571
+ type: 'release.archive';
1572
+ }
1573
+ /**
1574
+ * Restores an archived release. Only possible during the retention period.
1575
+ * @beta
1576
+ */
1577
+ interface UnarchiveReleaseAction extends ReleaseHandle {
1578
+ type: 'release.unarchive';
1579
+ }
1580
+ /**
1581
+ * Permanently deletes an archived or published release. To remove an active
1582
+ * release, use the archive action first.
1583
+ * @beta
1584
+ */
1585
+ interface DeleteReleaseAction extends ReleaseHandle {
1586
+ type: 'release.delete';
1587
+ }
1588
+ /**
1589
+ * Union of all release actions that can be dispatched alongside document
1590
+ * actions through `applyDocumentActions`.
1591
+ * @beta
1592
+ */
1593
+ type ReleaseAction = CreateReleaseAction | EditReleaseAction | PublishReleaseAction | ScheduleReleaseAction | UnscheduleReleaseAction | ArchiveReleaseAction | UnarchiveReleaseAction | DeleteReleaseAction;
1594
+ /** @beta */
1595
+ declare function createRelease(handle: ReleaseHandle, metadata?: ReleaseDocument['metadata']): CreateReleaseAction;
1596
+ /** @beta */
1597
+ declare function editRelease(handle: ReleaseHandle, patch: PatchOperations): EditReleaseAction;
1598
+ /** @beta */
1599
+ declare function publishRelease(handle: ReleaseHandle): PublishReleaseAction;
1600
+ /** @beta */
1601
+ declare function scheduleRelease(handle: ReleaseHandle, publishAt: string): ScheduleReleaseAction;
1602
+ /** @beta */
1603
+ declare function unscheduleRelease(handle: ReleaseHandle): UnscheduleReleaseAction;
1604
+ /** @beta */
1605
+ declare function archiveRelease(handle: ReleaseHandle): ArchiveReleaseAction;
1606
+ /** @beta */
1607
+ declare function unarchiveRelease(handle: ReleaseHandle): UnarchiveReleaseAction;
1608
+ /** @beta */
1609
+ declare function deleteRelease(handle: ReleaseHandle): DeleteReleaseAction;
1610
+ /**
1611
+ * Split the entire path string on dots "outside" of any brackets.
1612
+ *
1613
+ * For example:
1614
+ * ```
1615
+ * "friends[0].name"
1616
+ * ```
1617
+ *
1618
+ * becomes:
1619
+ *
1620
+ * ```
1621
+ * [...ParseSegment<"friends[0]">, ...ParseSegment<"name">]
1622
+ * ```
1623
+ *
1624
+ * (We use a simple recursion that splits on the first dot.)
1625
+ */
1626
+ type PathParts<TPath extends string> = TPath extends `${infer Head}.${infer Tail}` ? [Head, ...PathParts<Tail>] : TPath extends '' ? [] : [TPath];
1627
+ /**
1628
+ * Given a type T and an array of "access keys" Parts, recursively index into T.
1629
+ *
1630
+ * If a part is a key, it looks up that property.
1631
+ * If T is an array and the part is a number, it "indexes" into the element type.
1632
+ */
1633
+ 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 // Key/index doesn't exist
1634
+ , TTail extends readonly (string | number)[] ? TTail : []> : never;
1635
+ /**
1636
+ * Given a document type TDocument and a JSON Match path string TPath,
1637
+ * compute the type found at that path.
1638
+ * @beta
1639
+ */
1640
+ type JsonMatch<TDocument, TPath extends string> = DeepGet<TDocument, PathParts<TPath>>;
1641
+ /**
1642
+ * Represents a set of document that will go into `applyMutations`. Before
1643
+ * applying a mutation, it's expected that all relevant documents that the
1644
+ * mutations affect are included, including those that do not exist yet.
1645
+ * Documents that don't exist have a `null` value.
1646
+ */
1647
+ type DocumentSet<TDocument extends SanityDocument$1 = SanityDocument$1> = { [TDocumentId in string]?: TDocument | null; };
1648
+ type Grant = 'read' | 'update' | 'create' | 'history';
1649
+ /** @beta */
1650
+ interface PermissionDeniedReason {
1651
+ type: 'precondition' | 'access';
1652
+ message: string;
1653
+ documentId?: string;
1654
+ }
1655
+ /** @beta */
1656
+ type DocumentPermissionsResult = {
1657
+ allowed: false;
1658
+ message: string;
1659
+ reasons: PermissionDeniedReason[];
1660
+ } | {
1661
+ allowed: true;
1662
+ message?: undefined;
1663
+ reasons?: undefined;
1664
+ };
1665
+ interface SharedListener {
1666
+ events: Observable<ListenEvent<SanityDocument>>;
1667
+ dispose: () => void;
1668
+ }
1669
+ interface DocumentStoreState {
1670
+ documentStates: { [TDocumentId in string]?: DocumentState; };
1671
+ queued: QueuedTransaction[];
1672
+ applied: AppliedTransaction[];
1673
+ outgoing?: OutgoingTransaction;
1674
+ grants?: Record<Grant, ExprNode>;
1675
+ /**
1676
+ * The current user's identity (their user ID).
1677
+ */
1678
+ identity?: string;
1679
+ error?: unknown;
1680
+ sharedListener: SharedListener;
1681
+ fetchDocument: (documentId: string) => Observable<SanityDocument$2 | null>;
1682
+ events: Subject<DocumentEvent>;
1683
+ }
1684
+ interface DocumentState {
1685
+ id: string;
1686
+ /**
1687
+ * the "remote" local copy that matches the server. represents the last known
1688
+ * server state. this gets updated every time we confirm remote patches
1689
+ */
1690
+ remote?: SanityDocument$2 | null;
1691
+ /**
1692
+ * the current ephemeral working copy that includes local optimistic changes
1693
+ * that have not yet been confirmed by the server
1694
+ */
1695
+ local?: SanityDocument$2 | null;
1696
+ /**
1697
+ * the revision that our remote document is at
1698
+ */
1699
+ remoteRev?: string | null;
1700
+ /**
1701
+ * Array of subscription IDs. This document state will be deleted if there are
1702
+ * no subscribers.
1703
+ */
1704
+ subscriptions: string[];
1705
+ /**
1706
+ * An object keyed by transaction ID of revisions sent out but that have not
1707
+ * yet been verified yet. When an applied transaction is transitioned to an
1708
+ * outgoing transaction, it also adds unverified revisions for each document
1709
+ * that is part of that outgoing transaction. Transactions are submitted to
1710
+ * the server with a locally generated transaction ID. This way we can observe
1711
+ * when our transaction comes back through the shared listener. Each listener
1712
+ * event that comes back contains a `previousRev`. If we see our own
1713
+ * transaction with a different `previousRev` than expected, we can rebase our
1714
+ * local transactions on top of this new remote.
1715
+ */
1716
+ unverifiedRevisions?: { [TTransactionId in string]?: UnverifiedDocumentRevision; };
1717
+ /**
1718
+ * transaction IDs recently submitted by this client for this document,
1719
+ * newest last. used to label `remote-patches` events with the correct
1720
+ * `origin` even after the corresponding `unverifiedRevisions` entry has
1721
+ * been pruned (e.g. by a sync event that raced the listener echo). capped
1722
+ * to the most recent entries.
1723
+ */
1724
+ recentOwnTransactionIds?: string[];
1725
+ }
1726
+ /**
1727
+ * @beta
1728
+ * Options for specifying a document and optionally a path within it.
1729
+ */
1730
+ interface DocumentOptions<TPath extends string | undefined = undefined, TDocumentType extends string = string, TDataset extends string = string, TProjectId extends string = string> extends DocumentHandle<TDocumentType, TDataset, TProjectId> {
1731
+ path?: TPath;
1732
+ }
1733
+ /** @beta */
1734
+ declare function getDocumentState<TDocumentType extends string = string, TDataset extends string = string, TProjectId extends string = string>(instance: SanityInstance, options: DocumentOptions<undefined, TDocumentType, TDataset, TProjectId>): StateSource<SanityDocument$2<TDocumentType, `${TProjectId}.${TDataset}`> | undefined | null>;
1735
+ /** @beta */
1736
+ declare function getDocumentState<TPath extends string = string, TDocumentType extends string = string, TDataset extends string = string, TProjectId extends string = string>(instance: SanityInstance, options: DocumentOptions<TPath, TDocumentType, TDataset, TProjectId>): StateSource<JsonMatch<SanityDocument$2<TDocumentType, `${TProjectId}.${TDataset}`>, TPath> | undefined>;
1737
+ /** @beta */
1738
+ declare function getDocumentState<TData>(instance: SanityInstance, options: DocumentOptions<string | undefined>): StateSource<TData | undefined | null>;
1739
+ /** @beta */
1740
+ declare function resolveDocument<TDocumentType extends string = string, TDataset extends string = string, TProjectId extends string = string>(instance: SanityInstance, docHandle: DocumentHandle<TDocumentType, TDataset, TProjectId>): Promise<SanityDocument$2<TDocumentType, `${TProjectId}.${TDataset}`> | null>;
1741
+ /** @beta */
1742
+ declare function resolveDocument<TData extends SanityDocument$2>(instance: SanityInstance, docHandle: DocumentHandle<string, string, string>): Promise<TData | null>;
1743
+ /** @beta */
1744
+ declare const getDocumentSyncStatus: BoundStoreAction<DocumentStoreState, [doc: DocumentHandle<string, string, string>], StateSource<boolean | undefined>>;
1745
+ type PermissionsStateOptions = {
1746
+ resource?: DocumentResource;
1747
+ actions: DocumentAction[];
1748
+ };
1749
+ /** @beta */
1750
+ declare const getPermissionsState: BoundStoreAction<DocumentStoreState, [PermissionsStateOptions], StateSource<DocumentPermissionsResult>>;
1751
+ /** @beta */
1752
+ declare const resolvePermissions: BoundStoreAction<DocumentStoreState, [options: PermissionsStateOptions], Promise<DocumentPermissionsResult>>;
1753
+ /** @beta */
1754
+ declare const subscribeDocumentEvents: BoundStoreAction<DocumentStoreState, [options: {
1755
+ resource?: DocumentResource;
1756
+ eventHandler: (e: DocumentEvent) => void;
1757
+ }], () => void>;
1758
+ type ActionMap = {
1759
+ create: 'sanity.action.document.version.create';
1760
+ discard: 'sanity.action.document.version.discard';
1761
+ unpublish: 'sanity.action.document.unpublish';
1762
+ delete: 'sanity.action.document.delete';
1763
+ edit: 'sanity.action.document.edit';
1764
+ publish: 'sanity.action.document.publish';
1765
+ releaseCreate: 'sanity.action.release.create';
1766
+ releaseEdit: 'sanity.action.release.edit';
1767
+ releasePublish: 'sanity.action.release.publish';
1768
+ releaseSchedule: 'sanity.action.release.schedule';
1769
+ releaseUnschedule: 'sanity.action.release.unschedule';
1770
+ releaseArchive: 'sanity.action.release.archive';
1771
+ releaseUnarchive: 'sanity.action.release.unarchive';
1772
+ releaseDelete: 'sanity.action.release.delete';
1773
+ };
1774
+ type OptimisticLock = {
1775
+ ifDraftRevisionId?: string;
1776
+ ifPublishedRevisionId?: string;
1777
+ };
1778
+ interface ReleaseMetadataPayload {
1779
+ title?: string;
1780
+ description?: string;
1781
+ intendedPublishAt?: string;
1782
+ releaseType?: 'asap' | 'scheduled' | 'undecided';
1783
+ cardinality?: 'one' | 'many';
1784
+ }
1785
+ type HttpAction = {
1786
+ actionType: ActionMap['create'];
1787
+ publishedId: string;
1788
+ attributes: SanityDocumentLike;
1789
+ } | {
1790
+ actionType: ActionMap['discard'];
1791
+ versionId: string;
1792
+ purge?: boolean;
1793
+ } | {
1794
+ actionType: ActionMap['unpublish'];
1795
+ draftId: string;
1796
+ publishedId: string;
1797
+ } | {
1798
+ actionType: ActionMap['delete'];
1799
+ publishedId: string;
1800
+ includeDrafts?: string[];
1801
+ } | {
1802
+ actionType: ActionMap['edit'];
1803
+ draftId: string;
1804
+ publishedId: string;
1805
+ patch: PatchOperations;
1806
+ } | ({
1807
+ actionType: ActionMap['publish'];
1808
+ draftId: string;
1809
+ publishedId: string;
1810
+ } & OptimisticLock) | {
1811
+ actionType: ActionMap['releaseCreate'];
1812
+ releaseId: string;
1813
+ metadata?: ReleaseMetadataPayload;
1814
+ } | {
1815
+ actionType: ActionMap['releaseEdit'];
1816
+ releaseId: string;
1817
+ patch: PatchOperations;
1818
+ } | {
1819
+ actionType: ActionMap['releasePublish'];
1820
+ releaseId: string;
1821
+ } | {
1822
+ actionType: ActionMap['releaseSchedule'];
1823
+ releaseId: string;
1824
+ publishAt: string;
1825
+ } | {
1826
+ actionType: ActionMap['releaseUnschedule'];
1827
+ releaseId: string;
1828
+ } | {
1829
+ actionType: ActionMap['releaseArchive'];
1830
+ releaseId: string;
1831
+ } | {
1832
+ actionType: ActionMap['releaseUnarchive'];
1833
+ releaseId: string;
1834
+ } | {
1835
+ actionType: ActionMap['releaseDelete'];
1836
+ releaseId: string;
1837
+ };
1838
+ /**
1839
+ * Represents a transaction that is queued to be applied but has not yet been
1840
+ * applied. A transaction will remain in a queued state until all required
1841
+ * documents for the transactions are available locally.
1842
+ */
1843
+ interface QueuedTransaction {
1844
+ /**
1845
+ * the ID of this transaction. this is generated client-side.
1846
+ */
1847
+ transactionId: string;
1848
+ /**
1849
+ * the high-level actions associated with this transaction. note that these
1850
+ * actions don't mention draft IDs and is meant to abstract away the draft
1851
+ * model from users.
1852
+ */
1853
+ actions: Action[];
1854
+ /**
1855
+ * An optional flag set to disable this transaction from being batched with
1856
+ * other transactions.
1857
+ */
1858
+ disableBatching?: boolean;
1859
+ }
1860
+ /**
1861
+ * Represents a transaction that has been applied locally but has not been
1862
+ * committed/transitioned-to-outgoing. These transactions are visible to the
1863
+ * user but may be rebased upon a new working document set. Applied transactions
1864
+ * also contain the resulting `outgoingActions` that will be submitted to
1865
+ * Content Lake. These `outgoingActions` depend on the state of the working
1866
+ * documents so they are recomputed on rebase and are only relevant to applied
1867
+ * actions (we cannot compute `outgoingActions` for queued transactions because
1868
+ * we haven't resolved the set of documents the actions are dependent on yet).
1869
+ *
1870
+ * In order to support better conflict resolution, the original `previous` set
1871
+ * is saved as the `base` set.
1872
+ */
1873
+ interface AppliedTransaction extends QueuedTransaction {
1874
+ /**
1875
+ * the resulting set of documents after the actions have been applied
1876
+ */
1877
+ working: DocumentSet;
1878
+ /**
1879
+ * the previous set of documents before the action was applied
1880
+ */
1881
+ previous: DocumentSet;
1882
+ /**
1883
+ * the original `previous` document set captured when this action was
1884
+ * originally applied. this is used as a reference point to do a 3-way merge
1885
+ * if this applied transaction ever needs to be reapplied on a different
1886
+ * set of documents.
1887
+ */
1888
+ base: DocumentSet;
1889
+ /**
1890
+ * the `_rev`s from `previous` document set
1891
+ */
1892
+ previousRevs: { [TDocumentId in string]?: string; };
1893
+ /**
1894
+ * a timestamp for when this transaction was applied locally
1895
+ */
1896
+ timestamp: string;
1897
+ /**
1898
+ * the resulting HTTP actions derived from the state of the `working` document
1899
+ * set. these are sent to Content Lake as-is when this transaction is batched
1900
+ * and transitioned into an outgoing transaction.
1901
+ */
1902
+ outgoingActions: HttpAction[];
1903
+ /**
1904
+ * similar to `outgoingActions` but comprised of mutations instead of actions.
1905
+ * Useful for debugging, and is also used by liveEdit documents to send mutations,
1906
+ * since they can't use the Actions API which is pretty dependent on the draft model.
1907
+ */
1908
+ outgoingMutations: Mutation[];
1909
+ }
1910
+ /**
1911
+ * Represents a set of applied transactions batched into a single outgoing
1912
+ * transaction. An outgoing transaction is the result of batching many applied
1913
+ * actions. An outgoing transaction may be reverted locally if the server
1914
+ * does not accept it.
1915
+ */
1916
+ interface OutgoingTransaction extends AppliedTransaction {
1917
+ disableBatching: boolean;
1918
+ batchedTransactionIds: string[];
1919
+ }
1920
+ interface UnverifiedDocumentRevision {
1921
+ transactionId: string;
1922
+ documentId: string;
1923
+ previousRev: string | undefined;
1924
+ timestamp: string;
1925
+ }
1926
+ /** @beta Response body from submitting an outgoing transaction (actions or mutations API). */
1927
+ type DocumentTransactionSubmissionResult = Awaited<ReturnType<SanityClient['action']>> | MultipleMutationResult;
1928
+ /** @beta */
1929
+ type DocumentEvent = ActionErrorEvent | TransactionRevertedEvent | TransactionAcceptedEvent | DocumentRebaseErrorEvent | DocumentEditedEvent | DocumentCreatedEvent | DocumentDeletedEvent | DocumentPublishedEvent | DocumentUnpublishedEvent | DocumentDiscardedEvent | DocumentRemotePatchesEvent;
1930
+ /**
1931
+ * @beta
1932
+ * Event emitted when a precondition to applying an action fails.
1933
+ * (For example: when trying to edit a document that no longer exists.)
1934
+ */
1935
+ interface ActionErrorEvent {
1936
+ type: 'error';
1937
+ documentId: string;
1938
+ transactionId: string;
1939
+ message: string;
1940
+ error: unknown;
1941
+ }
1942
+ /**
1943
+ * @beta
1944
+ * Event emitted when a transaction is accepted.
1945
+ */
1946
+ interface TransactionAcceptedEvent {
1947
+ type: 'accepted';
1948
+ outgoing: OutgoingTransaction;
1949
+ result: DocumentTransactionSubmissionResult;
1950
+ }
1951
+ /**
1952
+ * @beta
1953
+ * Event emitted when a transaction is reverted.
1954
+ */
1955
+ interface TransactionRevertedEvent {
1956
+ type: 'reverted';
1957
+ message: string;
1958
+ error: unknown;
1959
+ outgoing: OutgoingTransaction;
1960
+ }
1961
+ /**
1962
+ * @beta
1963
+ * Event emitted when an attempt to apply local changes to a modified remote document fails.
1964
+ */
1965
+ interface DocumentRebaseErrorEvent {
1966
+ type: 'rebase-error';
1967
+ documentId: string;
1968
+ transactionId: string;
1969
+ message: string;
1970
+ error: unknown;
1971
+ }
1972
+ /**
1973
+ * @beta
1974
+ * Event emitted when a document is edited.
1975
+ */
1976
+ interface DocumentEditedEvent {
1977
+ type: 'edited';
1978
+ documentId: string;
1979
+ outgoing: OutgoingTransaction;
1980
+ }
1981
+ /**
1982
+ * @beta
1983
+ * Event emitted when a document is created.
1984
+ */
1985
+ interface DocumentCreatedEvent {
1986
+ type: 'created';
1987
+ documentId: string;
1988
+ outgoing: OutgoingTransaction;
1989
+ }
1990
+ /**
1991
+ * @beta
1992
+ * Event emitted when a document is deleted.
1993
+ */
1994
+ interface DocumentDeletedEvent {
1995
+ type: 'deleted';
1996
+ documentId: string;
1997
+ outgoing: OutgoingTransaction;
1998
+ }
1999
+ /**
2000
+ * @beta
2001
+ * Event emitted when a document is published.
2002
+ */
2003
+ interface DocumentPublishedEvent {
2004
+ type: 'published';
2005
+ documentId: string;
2006
+ outgoing: OutgoingTransaction;
2007
+ }
2008
+ /**
2009
+ * @beta
2010
+ * Event emitted when a document is unpublished.
2011
+ */
2012
+ interface DocumentUnpublishedEvent {
2013
+ type: 'unpublished';
2014
+ documentId: string;
2015
+ outgoing: OutgoingTransaction;
2016
+ }
2017
+ /**
2018
+ * @beta
2019
+ * Event emitted when a document version is discarded.
2020
+ */
2021
+ interface DocumentDiscardedEvent {
2022
+ type: 'discarded';
2023
+ documentId: string;
2024
+ outgoing: OutgoingTransaction;
2025
+ }
2026
+ /**
2027
+ * @beta
2028
+ * Event emitted when patches for a document are observed through the listener.
2029
+ *
2030
+ * Unlike the whole-document snapshots the store keeps, these are the raw patch
2031
+ * operations from the transaction that produced the change, preserving the
2032
+ * operational intent of the edit (e.g. keyed array inserts/unsets). Consumers
2033
+ * that maintain their own local state, like collaborative text editors, can
2034
+ * apply these directly instead of diffing document snapshots.
2035
+ *
2036
+ * `origin` is `'local'` when the transaction was submitted by this document
2037
+ * store instance (an own edit observed back through the listener) and
2038
+ * `'remote'` when it came from another client.
2039
+ */
2040
+ interface DocumentRemotePatchesEvent {
2041
+ type: 'remote-patches';
2042
+ /** The ID of the document version the patches apply to (e.g. a draft ID). */
2043
+ documentId: string;
2044
+ /** The transaction ID that carried these patches. */
2045
+ transactionId: string;
2046
+ /** The revision the document was at before this transaction. */
2047
+ previousRev?: string;
2048
+ /** The timestamp of the transaction. */
2049
+ timestamp: string;
2050
+ /** The patch operations, rooted at the document. */
2051
+ patches: PatchOperations[];
2052
+ /** Whether the transaction originated from this client or another one. */
2053
+ origin: 'local' | 'remote';
2054
+ }
2055
+ /** @beta */
2056
+ interface ActionsResult<TDocument extends SanityDocument$2 = SanityDocument$2> {
2057
+ transactionId: string;
2058
+ documents: DocumentSet<TDocument>;
2059
+ previous: DocumentSet<TDocument>;
2060
+ previousRevs: {
2061
+ [documentId: string]: string | undefined;
2062
+ };
2063
+ appeared: string[];
2064
+ updated: string[];
2065
+ disappeared: string[];
2066
+ submitted: () => Promise<DocumentTransactionSubmissionResult>;
2067
+ }
2068
+ /** @beta */
2069
+ interface ApplyDocumentActionsOptions {
2070
+ /**
2071
+ * List of actions to apply. Accepts both document actions and release
2072
+ * lifecycle actions because they share the same transaction pipeline.
2073
+ */
2074
+ actions: Action[];
2075
+ /**
2076
+ * The resource to which the documents being acted on belong.
2077
+ */
2078
+ resource?: DocumentResource;
2079
+ /**
2080
+ * Optionally provide an ID to be used as this transaction ID
2081
+ */
2082
+ transactionId?: string;
2083
+ /**
2084
+ * Set this to true to prevent this action from being batched with others.
2085
+ */
2086
+ disableBatching?: boolean;
2087
+ }
2088
+ /** @beta */
2089
+ declare function applyDocumentActions<TDocumentType extends string = string, TDataset extends string = string, TProjectId extends string = string>(instance: SanityInstance, options: ApplyDocumentActionsOptions): Promise<ActionsResult<SanityDocument$2<TDocumentType, `${TProjectId}.${TDataset}`>>>;
2090
+ /** @beta */
2091
+ declare function applyDocumentActions(instance: SanityInstance, options: ApplyDocumentActionsOptions): Promise<ActionsResult>;
2092
+ /**
2093
+ * Returns the full release document ID for the given release name.
2094
+ * e.g. `getReleaseDocumentId('my-release') === '_.releases.my-release'`
2095
+ * @beta
2096
+ */
2097
+ declare function getReleaseDocumentId(releaseId: string): string;
2098
+ /**
2099
+ * @public
2100
+ */
2101
+ interface FavoriteStatusResponse {
2102
+ isFavorited: boolean;
2103
+ }
2104
+ /**
2105
+ * @public
2106
+ */
2107
+ interface FavoriteDocumentContext extends DocumentHandle {
2108
+ resourceId: string;
2109
+ resourceType: StudioResource['type'] | MediaResource['type'] | CanvasResource['type'];
2110
+ schemaName?: string;
2111
+ }
2112
+ /**
2113
+ * Fetcher for a document's favorite status, read from the dashboard over
2114
+ * comlink, on the shared fetcher cache.
2115
+ *
2116
+ * @internal
2117
+ */
2118
+ declare const favorites: Fetcher<[context: FavoriteDocumentContext], FavoriteStatusResponse>;
2119
+ /**
2120
+ * Input for {@link setFavorite}: the document context plus the desired state.
2121
+ *
2122
+ * @public
2123
+ */
2124
+ type SetFavoriteInput = FavoriteDocumentContext & {
2125
+ /** The favorite state to move to: `true` to favorite, `false` to unfavorite. */
2126
+ isFavorited: boolean;
2127
+ };
2128
+ /**
2129
+ * Sets a document's favorite state over comlink, then invalidates the cached
2130
+ * {@link favorites} status for that document so active readers reconverge on
2131
+ * server truth. The write-side counterpart to {@link favorites}.
2132
+ *
2133
+ * @internal
2134
+ */
2135
+ declare const setFavorite: (instance: SanityInstance, input: SetFavoriteInput) => Promise<MutationResult<FavoriteStatusResponse>>;
2136
+ /**
2137
+ * Related data the Installations API can embed in a response. Each token adds
2138
+ * a top-level field to the {@link Installation} item.
2139
+ *
2140
+ * @see https://www.sanity.io/docs/http-reference/applications-api
2141
+ * @public
2142
+ */
2143
+ type InstallationInclude = 'activeConfig' | 'access' | 'interfaces';
2144
+ /**
2145
+ * A resource an installation accesses, embedded when `access` is included.
2146
+ *
2147
+ * @see https://www.sanity.io/docs/http-reference/applications-api
2148
+ * @public
2149
+ */
2150
+ interface InstallationAccess {
2151
+ id: string;
2152
+ resourceType: 'datasets' | 'canvases' | 'dashboards' | 'media-libraries';
2153
+ resourceId: string;
2154
+ }
2155
+ /**
2156
+ * An interface exposed by an installation, embedded when `interfaces` is
2157
+ * included.
2158
+ *
2159
+ * @see https://www.sanity.io/docs/http-reference/applications-api
2160
+ * @public
2161
+ */
2162
+ interface InstallationInterface {
2163
+ id: string;
2164
+ type: 'app' | 'worker' | 'asset_source' | 'panel';
2165
+ name: string;
2166
+ title: string;
2167
+ version: string;
2168
+ /** Module federation module ID; resolved from the host mf-manifest at runtime */
2169
+ moduleId: string;
2170
+ metadata: {
2171
+ group?: string;
2172
+ priority?: number;
2173
+ } | null;
2174
+ }
2175
+ /**
2176
+ * The active config of an installation, embedded when `activeConfig` is
2177
+ * included. `null` when nothing is deployed.
2178
+ *
2179
+ * @see https://www.sanity.io/docs/http-reference/applications-api
2180
+ * @public
2181
+ */
2182
+ interface InstallationActiveConfig {
2183
+ id: string;
2184
+ installationId: string;
2185
+ deployedBy: string | null;
2186
+ version: string;
2187
+ isActive: boolean;
2188
+ createdAt: string;
2189
+ }
2190
+ /**
2191
+ * The always-present fields of an active singleton installation returned by the
2192
+ * Installations API (`/installations`), before any {@link InstallationInclude}.
2193
+ *
2194
+ * @see https://www.sanity.io/docs/http-reference/applications-api
2195
+ * @public
2196
+ */
2197
+ interface InstallationBase {
2198
+ id: string;
2199
+ applicationId: string;
2200
+ organizationId: string;
2201
+ installedBy: string | null;
2202
+ createdAt: string;
2203
+ updatedAt: string;
2204
+ application: {
2205
+ title: string;
2206
+ /** Stable, immutable identity of the installed singleton, distinct from `slug`. */
2207
+ name: string;
2208
+ /** Qualified, globally-unique handle of the installed singleton (e.g. `sanity/<name>`). */
2209
+ reference: string;
2210
+ slug: string | null;
2211
+ };
2212
+ }
2213
+ /**
2214
+ * An active singleton installation as returned by the Installations API
2215
+ * (`/installations`). `activeConfig`, `access` and `interfaces` are top-level
2216
+ * fields, each present only when the matching {@link InstallationInclude} token
2217
+ * was requested.
2218
+ *
2219
+ * @see https://www.sanity.io/docs/http-reference/applications-api
2220
+ * @public
2221
+ */
2222
+ type Installation<Include extends InstallationInclude = never> = InstallationBase & Included<InstallationInclude, 'activeConfig', Include, {
2223
+ activeConfig: InstallationActiveConfig | null;
2224
+ }> & Included<InstallationInclude, 'access', Include, {
2225
+ access: InstallationAccess[];
2226
+ }> & Included<InstallationInclude, 'interfaces', Include, {
2227
+ interfaces: InstallationInterface[];
2228
+ }>;
2229
+ /**
2230
+ * Options for listing an organization's installations.
2231
+ *
2232
+ * @see https://www.sanity.io/docs/http-reference/applications-api
2233
+ * @public
2234
+ */
2235
+ interface InstallationsOptions<Include extends InstallationInclude = InstallationInclude> {
2236
+ organizationId: string;
2237
+ include?: Include[];
2238
+ /** Page size (1-100, default 50), or `'none'` to disable pagination */
2239
+ limit?: number | 'none';
2240
+ /** Cursor from a previous response's `nextCursor` */
2241
+ cursor?: string;
2242
+ }
2243
+ /**
2244
+ * The cursor-paginated envelope returned by `GET /installations`.
2245
+ *
2246
+ * @see https://www.sanity.io/docs/http-reference/applications-api
2247
+ * @public
2248
+ */
2249
+ interface InstallationsResponse<Include extends InstallationInclude = never> {
2250
+ nextCursor: string | null;
2251
+ data: Installation<Include>[];
2252
+ }
2253
+ /**
2254
+ * Fetcher for an organization's installations (`GET /installations`), on the
2255
+ * shared fetcher cache.
2256
+ *
2257
+ * @see https://www.sanity.io/docs/http-reference/applications-api
2258
+ * @internal
2259
+ */
2260
+ declare const installations: Fetcher<[options: InstallationsOptions<InstallationInclude>], InstallationsResponse<InstallationInclude>>;
2261
+ /**
2262
+ * Fetcher for a single installation (`GET /installations/:id`), on the shared
2263
+ * fetcher cache. No pre-seeding from {@link installations}: its list keys
2264
+ * include the organization, which this fetcher's params can't reconstruct.
2265
+ *
2266
+ * @see https://www.sanity.io/docs/http-reference/applications-api
2267
+ * @internal
2268
+ */
2269
+ declare const installation: Fetcher<[installationId: string, options?: {
2270
+ include?: InstallationInclude[];
2271
+ } | undefined], Installation<InstallationInclude>>;
2272
+ /** @public */
2273
+ interface OrganizationMember {
2274
+ sanityUserId: string;
2275
+ isCurrentUser: boolean;
2276
+ user: {
2277
+ id: string;
2278
+ displayName: string;
2279
+ familyName: string;
2280
+ givenName: string;
2281
+ middleName: string | null;
2282
+ imageUrl: string | null;
2283
+ email: string;
2284
+ loginProvider: string;
2285
+ };
2286
+ roles: Array<{
2287
+ name: string;
2288
+ title: string;
2289
+ description?: string;
2290
+ }>;
2291
+ }
2292
+ /**
2293
+ * The base fields returned from `/organizations/<id>` for every organization.
2294
+ * @public
2295
+ */
2296
+ interface OrganizationBase {
2297
+ id: string;
2298
+ name: string;
2299
+ slug: string | null;
2300
+ createdAt: string;
2301
+ createdByUserId: string;
2302
+ updatedAt: string;
2303
+ deletedAt: string | null;
2304
+ dashboardStatus: 'enabled' | 'disabled';
2305
+ aiFeaturesStatus: 'enabled' | 'disabled';
2306
+ mediaLibraryStatus: 'enabled' | 'disabled';
2307
+ requestAccessStatus: 'allowed' | 'disabled';
2308
+ telemetryConsentStatus: 'allowed' | 'msa_denied' | 'customer_denied';
2309
+ oauthAppsStatus: 'allowed' | 'blocked';
2310
+ defaultRoleName: string;
2311
+ domains: string[] | null;
2312
+ }
2313
+ /** @public */
2314
+ interface OrganizationOptions<IncludeMembers extends boolean = false, IncludeFeatures extends boolean = false> {
2315
+ includeMembers?: IncludeMembers;
2316
+ includeFeatures?: IncludeFeatures;
2317
+ organizationId: string;
2318
+ }
2319
+ /**
2320
+ * An `Organization` with `members` and/or `features` conditionally included
2321
+ * based on the query options used to fetch it.
2322
+ * @public
2323
+ */
2324
+ type Organization<IncludeMembers extends boolean = false, IncludeFeatures extends boolean = false> = OrganizationBase & (boolean extends IncludeMembers ? {
2325
+ members?: OrganizationMember[];
2326
+ } : IncludeMembers extends true ? {
2327
+ members: OrganizationMember[];
2328
+ } : unknown) & (boolean extends IncludeFeatures ? {
2329
+ features?: string[];
2330
+ } : IncludeFeatures extends true ? {
2331
+ features: string[];
2332
+ } : unknown);
2333
+ /**
2334
+ * Fetcher for a single organization (`GET /organizations/:id`), on the shared
2335
+ * fetcher cache. No pre-seeding from the organizations list: it returns a
2336
+ * subset of the detail fields, and a partial seed would serve as fresh for
2337
+ * the whole stale window.
2338
+ *
2339
+ * @internal
2340
+ */
2341
+ declare const organization: Fetcher<[options?: OrganizationOptions<boolean, boolean> | undefined], Organization<boolean, boolean>>;
2342
+ /**
2343
+ * The list shape returned from `/organizations`, with `members` and/or
2344
+ * `features` conditionally included based on the query options used.
2345
+ * @public
2346
+ */
2347
+ type Organizations<IncludeMembers extends boolean = false, IncludeFeatures extends boolean = false> = (Pick<OrganizationBase, 'id' | 'name' | 'slug' | 'createdAt' | 'updatedAt' | 'defaultRoleName' | 'dashboardStatus' | 'aiFeaturesStatus'> & (boolean extends IncludeMembers ? {
2348
+ members?: OrganizationMember[];
2349
+ } : IncludeMembers extends true ? {
2350
+ members: OrganizationMember[];
2351
+ } : unknown) & (boolean extends IncludeFeatures ? {
2352
+ features?: string[];
2353
+ } : IncludeFeatures extends true ? {
2354
+ features: string[];
2355
+ } : unknown))[];
2356
+ /** @public */
2357
+ interface OrganizationsOptions<IncludeMembers extends boolean = false, IncludeFeatures extends boolean = false> extends Omit<OrganizationOptions<IncludeMembers, IncludeFeatures>, 'organizationId'> {
2358
+ /**
2359
+ * When `true`, includes organisations the user has access to via
2360
+ * project-level grants, not just direct organisation memberships.
2361
+ */
2362
+ includeImplicitMemberships?: boolean;
2363
+ }
2364
+ /**
2365
+ * Fetcher for the current user's organizations (`GET /organizations`), on the
2366
+ * shared fetcher cache.
2367
+ *
2368
+ * @internal
2369
+ */
2370
+ declare const organizations: Fetcher<[options?: OrganizationsOptions<boolean, boolean> | undefined], Organizations<boolean, boolean>>;
2371
+ /**
2372
+ * @public
2373
+ */
2374
+ interface SanityUser {
2375
+ sanityUserId: string;
2376
+ profile: UserProfile;
2377
+ memberships: Membership[];
2378
+ }
2379
+ /**
2380
+ * @public
2381
+ */
2382
+ interface Membership {
2383
+ addedAt?: string;
2384
+ resourceType: string;
2385
+ resourceId: string;
2386
+ roleNames: Array<string>;
2387
+ lastSeenAt?: string | null;
2388
+ }
2389
+ /**
2390
+ * @public
2391
+ */
2392
+ interface UserProfile {
2393
+ id: string;
2394
+ displayName: string;
2395
+ email: string;
2396
+ familyName?: string;
2397
+ givenName?: string;
2398
+ middleName?: string | null;
2399
+ imageUrl?: string;
2400
+ provider: string;
2401
+ tosAcceptedAt?: string;
2402
+ createdAt: string;
2403
+ updatedAt?: string;
2404
+ isCurrentUser?: boolean;
2405
+ providerId?: string;
2406
+ }
2407
+ /**
2408
+ * @public
2409
+ */
2410
+ interface GetUsersOptions extends ProjectHandle {
2411
+ resourceType?: 'organization' | 'project';
2412
+ batchSize?: number;
2413
+ organizationId?: string;
2414
+ userId?: string;
2415
+ }
2416
+ /**
2417
+ * @public
2418
+ */
2419
+ interface UsersGroupState {
2420
+ subscriptions: string[];
2421
+ totalCount?: number;
2422
+ nextCursor?: string | null;
2423
+ lastLoadMoreRequest?: string;
2424
+ users?: SanityUser[];
2425
+ error?: unknown;
2426
+ }
2427
+ /**
2428
+ * @public
2429
+ */
2430
+ interface SanityUserResponse {
2431
+ data: SanityUser[];
2432
+ totalCount: number;
2433
+ nextCursor: string | null;
2434
+ }
2435
+ /**
2436
+ * @public
2437
+ */
2438
+ interface UsersStoreState {
2439
+ users: { [TUsersKey in string]?: UsersGroupState; };
2440
+ error?: unknown;
2441
+ }
2442
+ /**
2443
+ * @public
2444
+ */
2445
+ interface ResolveUsersOptions extends GetUsersOptions {
2446
+ signal?: AbortSignal;
2447
+ }
2448
+ /**
2449
+ * @public
2450
+ */
2451
+ interface GetUserOptions extends ProjectHandle {
2452
+ userId: string;
2453
+ resourceType?: 'organization' | 'project';
2454
+ organizationId?: string;
2455
+ }
2456
+ /**
2457
+ * @public
2458
+ */
2459
+ interface ResolveUserOptions extends GetUserOptions {
2460
+ signal?: AbortSignal;
2461
+ }
2462
+ /**
2463
+ * One end of a text selection: a Portable Text path plus a character offset
2464
+ * within the span it addresses.
2465
+ * @public
2466
+ */
2467
+ interface PresenceSelectionPoint {
2468
+ path: Path;
2469
+ offset: number;
2470
+ }
2471
+ /**
2472
+ * A Portable Text caret or selected range, as exchanged with the Studio.
2473
+ *
2474
+ * Structurally identical to `EditorSelection` from `@portabletext/editor`, and
2475
+ * declared separately so that `@sanity/sdk` stays free of React dependencies. A
2476
+ * value from the editor can be passed straight through, and vice versa.
2477
+ *
2478
+ * `offset` is a character offset within the span that `path` addresses.
2479
+ * @public
2480
+ */
2481
+ type PresenceSelection = {
2482
+ anchor: PresenceSelectionPoint;
2483
+ focus: PresenceSelectionPoint;
2484
+ backward?: boolean;
2485
+ } | null;
2486
+ /**
2487
+ * Somewhere a participant is, as it arrives over the wire.
2488
+ *
2489
+ * Prefer {@link DocumentPresence} from `getDocumentPresence`, which is scoped to one
2490
+ * document, flattened for rendering, and types `path` accurately.
2491
+ * @public
2492
+ */
2493
+ interface PresenceLocation {
2494
+ type: 'document';
2495
+ /**
2496
+ * The specific document the participant is in, so a draft, published, or version
2497
+ * id rather than a bare document id.
2498
+ */
2499
+ documentId: string;
2500
+ /**
2501
+ * The focused field path, empty when they are in the document but not a field.
2502
+ *
2503
+ * Declared as `string[]`, but segments can also be numbers or `{_key: string}`
2504
+ * objects when the focus is inside an array or a Portable Text field, because
2505
+ * that is what other clients send. Guard for those rather than assuming strings.
2506
+ * Widening the declared type is a breaking change, so it waits for the next major;
2507
+ * {@link DocumentPresence.path} is typed correctly today.
2508
+ */
2509
+ path: string[];
2510
+ /**
2511
+ * When the participant said they were last active, on *their* clock.
2512
+ *
2513
+ * Fine for display, unreliable for deciding whether someone is still here: it is
2514
+ * subject to clock skew between machines. Presence already drops participants that
2515
+ * stop announcing, so a session appearing here is one the SDK still considers
2516
+ * live.
2517
+ */
2518
+ lastActiveAt: string;
2519
+ /** A Portable Text caret, when the focused field is a Portable Text field. */
2520
+ selection?: PresenceSelection;
2521
+ }
2522
+ /**
2523
+ * Which specific document a presence id resolves to.
2524
+ *
2525
+ * Presence compares exact document ids, so a client in a draft and a client in the
2526
+ * published document are in different places even for the same `documentId`. Pass
2527
+ * the perspective you are editing under and the SDK resolves it; the React hooks
2528
+ * take it from `ResourceProvider` when you do not pass one.
2529
+ * @public
2530
+ */
2531
+ interface PresencePerspectiveOptions extends PerspectiveHandle {
2532
+ /** Live-edit documents have no draft, so presence resolves to the published id. */
2533
+ liveEdit?: boolean;
2534
+ }
2535
+ /**
2536
+ * What an app reports about where the current user is.
2537
+ *
2538
+ * Omit `path` for document-level presence, or pass one for field-level presence.
2539
+ * @public
2540
+ */
2541
+ interface ReportPresenceOptions extends PresencePerspectiveOptions {
2542
+ /**
2543
+ * The document the user is in.
2544
+ *
2545
+ * Pass the plain document id; the perspective decides which specific document that
2546
+ * resolves to. An already-specific id is accepted and re-resolved, so passing
2547
+ * `drafts.abc` while the perspective is `published` reports the published document.
2548
+ */
2549
+ documentId: string;
2550
+ /**
2551
+ * The focused field path. Supports keyed and numeric segments, so array items
2552
+ * and Portable Text spans can be addressed.
2553
+ */
2554
+ path?: Path;
2555
+ /** A Portable Text caret, when the focused field is a Portable Text field. */
2556
+ selection?: PresenceSelection;
2557
+ }
2558
+ /**
2559
+ * One participant's session and everywhere it currently is.
2560
+ *
2561
+ * Keyed by session, not by user: the same person in two tabs is two entries with
2562
+ * the same `user`.
2563
+ * @public
2564
+ */
2565
+ interface UserPresence {
2566
+ user: SanityUser;
2567
+ locations: PresenceLocation[];
2568
+ /** Identifies one tab. Stable while that tab is open, and not reused. */
2569
+ sessionId: string;
2570
+ }
2571
+ /**
2572
+ * One participant at one location within a single document, flattened so it can
2573
+ * be rendered directly against a field.
2574
+ *
2575
+ * Unlike {@link PresenceLocation.path}, `path` here is typed as a full `Path`, so
2576
+ * keyed and numeric segments are described rather than cast away.
2577
+ * @beta
2578
+ */
2579
+ interface DocumentPresence {
2580
+ user: SanityUser;
2581
+ /** Identifies one tab, so the same person in two tabs appears twice. */
2582
+ sessionId: string;
2583
+ /**
2584
+ * The specific document id this participant is in: a draft, published, or
2585
+ * version id, depending on which perspective they are editing.
2586
+ */
2587
+ documentId: string;
2588
+ /** The focused field path. Empty when they are in the document but no field. */
2589
+ path: Path;
2590
+ /**
2591
+ * When they said they were last active, on *their* clock. Fine for display,
2592
+ * unreliable for liveness. See {@link PresenceLocation.lastActiveAt}.
2593
+ */
2594
+ lastActiveAt: string;
2595
+ /** The Portable Text caret, when they are focused in a Portable Text field. */
2596
+ selection?: PresenceSelection;
2597
+ }
2598
+ /** @beta */
2599
+ interface DocumentPresenceOptions extends PresencePerspectiveOptions {
2600
+ /**
2601
+ * The document to look at. Resolved through the perspective exactly as
2602
+ * {@link ReportPresenceOptions.documentId} is, so reads match writes.
2603
+ */
2604
+ documentId: string;
2605
+ /**
2606
+ * Narrows to participants at or below this field path. Omit it for everyone in
2607
+ * the document.
2608
+ */
2609
+ path?: Path;
2610
+ /**
2611
+ * By default a draft, its published version, and any release versions are
2612
+ * treated as the same document, which is what document lists want. Set this to
2613
+ * compare ids exactly, which is what field-level indicators want so that a
2614
+ * draft and a release version do not bleed into each other.
2615
+ */
2616
+ excludeVersions?: boolean;
2617
+ }
2618
+ /** @public */
2619
+ type TransportEvent = RollCallEvent | StateEvent | DisconnectEvent;
2620
+ /** @public */
2621
+ interface RollCallEvent {
2622
+ type: 'rollCall';
2623
+ userId: string;
2624
+ sessionId: string;
2625
+ }
2626
+ /** @public */
2627
+ interface StateEvent {
2628
+ type: 'state';
2629
+ userId: string;
2630
+ sessionId: string;
2631
+ timestamp: string;
2632
+ locations: PresenceLocation[];
2633
+ }
2634
+ /** @public */
2635
+ interface DisconnectEvent {
2636
+ type: 'disconnect';
2637
+ userId: string;
2638
+ sessionId: string;
2639
+ timestamp: string;
2640
+ }
2641
+ /** @beta */
2642
+ declare function getPresence(instance: SanityInstance, params?: {
2643
+ resource?: DocumentResource;
2644
+ }): StateSource<UserPresence[]>;
2645
+ /**
2646
+ * Presence within a single document, flattened to one entry per participant per
2647
+ * location so it can be rendered directly against a field.
2648
+ *
2649
+ * Reading presence never announces anything. Use `reportPresence` to make the
2650
+ * current user visible to others.
2651
+ *
2652
+ * @param instance - the Sanity instance
2653
+ * @param params - the document to look at, its perspective, an optional `path` to
2654
+ * narrow to a field subtree, and `excludeVersions` to compare document ids exactly
2655
+ *
2656
+ * @beta
2657
+ */
2658
+ declare function getDocumentPresence(instance: SanityInstance, params: {
2659
+ resource?: DocumentResource;
2660
+ } & DocumentPresenceOptions): StateSource<DocumentPresence[]>;
2661
+ /**
2662
+ * Announces where the current user is, so other clients in the same project and
2663
+ * dataset can show them. Reading presence never announces anything, so this is
2664
+ * the only way an app becomes visible to others.
2665
+ *
2666
+ * Call it again whenever the user moves. Announcements are collapsed over a short
2667
+ * window and then repeated every 30 seconds while idle, which is what tells peers
2668
+ * the session is still alive.
2669
+ *
2670
+ * Which specific document each location resolves to depends on its perspective, and
2671
+ * that matters for interoperability: other clients, the Studio included, compare
2672
+ * exact document ids for field-level presence. Pass the perspective you are editing
2673
+ * under rather than building a draft or version id yourself.
2674
+ *
2675
+ * @param instance - the Sanity instance
2676
+ * @param params - the resource to announce on, plus the locations to report.
2677
+ * Pass one location with a `documentId` for document-level presence, add a
2678
+ * `path` for field-level presence, and pass an empty array to appear present
2679
+ * without being in any document.
2680
+ *
2681
+ * @beta
2682
+ */
2683
+ declare function reportPresence(instance: SanityInstance, params: {
2684
+ resource?: DocumentResource;
2685
+ locations: ReportPresenceOptions[];
2686
+ }): void;
2687
+ /**
2688
+ * @public
2689
+ * The result of a projection query
2690
+ */
2691
+ interface ProjectionValuePending<TValue extends object> {
2692
+ data: TValue | null;
2693
+ isPending: boolean;
2694
+ }
2695
+ interface DocumentStatus {
2696
+ lastEditedDraftAt?: string;
2697
+ lastEditedPublishedAt?: string;
2698
+ lastEditedVersionAt?: string;
2699
+ }
2700
+ /**
2701
+ *
2702
+ * @internal
2703
+ */
2704
+ interface PreviewQueryResult {
2705
+ _id: string;
2706
+ _type: string;
2707
+ _updatedAt: string;
2708
+ titleCandidates: Record<string, unknown>;
2709
+ subtitleCandidates: Record<string, unknown>;
2710
+ media?: PreviewMedia | null;
2711
+ _status?: DocumentStatus;
2712
+ }
2713
+ /**
2714
+ * Represents a media asset in a preview.
2715
+ *
2716
+ * @public
2717
+ */
2718
+ interface PreviewMedia {
2719
+ type: 'image-asset';
2720
+ _ref: string;
2721
+ url: string;
2722
+ }
2723
+ /**
2724
+ * Represents the set of values displayed as a preview for a given Sanity document.
2725
+ * This includes a primary title, a secondary subtitle, an optional piece of media associated
2726
+ * with the document, and the document's status.
2727
+ *
2728
+ * @public
2729
+ */
2730
+ interface PreviewValue {
2731
+ /**
2732
+ * The primary text displayed for the document preview.
2733
+ */
2734
+ title: string;
2735
+ /**
2736
+ * A secondary line of text providing additional context about the document.
2737
+ */
2738
+ subtitle?: string;
2739
+ /**
2740
+ * An optional piece of media representing the document within its preview.
2741
+ * Currently, only image assets are available.
2742
+ */
2743
+ media?: PreviewMedia | null;
2744
+ /**
2745
+ * The status of the document.
2746
+ */
2747
+ _status?: {
2748
+ /** The date of the last published edit */
2749
+ lastEditedPublishedAt?: string;
2750
+ /** The date of the last draft edit */
2751
+ lastEditedDraftAt?: string;
2752
+ };
2753
+ }
2754
+ /** @public */
2755
+ interface ProjectMemberRole {
2756
+ name: string;
2757
+ title: string;
2758
+ description: string;
2759
+ }
2760
+ /** @public */
2761
+ interface ProjectMember {
2762
+ id: string;
2763
+ createdAt: string;
2764
+ updatedAt: string;
2765
+ isCurrentUser: boolean;
2766
+ isRobot: boolean;
2767
+ roles: ProjectMemberRole[];
2768
+ }
2769
+ /** @public */
2770
+ interface ProjectMetadata {
2771
+ color?: string;
2772
+ externalStudioHost?: string;
2773
+ initialTemplate?: string;
2774
+ cliInitializedAt?: string;
2775
+ integration: 'manage' | 'cli';
2776
+ }
2777
+ /**
2778
+ * The base fields returned from `/projects` for every project.
2779
+ * @public
2780
+ */
2781
+ interface ProjectBase {
2782
+ id: string;
2783
+ displayName: string;
2784
+ studioHost: string | null;
2785
+ organizationId: string;
2786
+ metadata: ProjectMetadata;
2787
+ isBlocked: boolean;
2788
+ isDisabled: boolean;
2789
+ isDisabledByUser: boolean;
2790
+ activityFeedEnabled: boolean;
2791
+ createdAt: string;
2792
+ updatedAt: string;
2793
+ }
2794
+ /**
2795
+ * A `Project` with `members` and/or `features` conditionally included
2796
+ * based on the query options used to fetch it.
2797
+ * @public
2798
+ */
2799
+ type Project<IncludeMembers extends boolean = true, IncludeFeatures extends boolean = true> = ProjectBase & (boolean extends IncludeMembers ? {
2800
+ members?: ProjectMember[];
2801
+ } : IncludeMembers extends true ? {
2802
+ members: ProjectMember[];
2803
+ } : unknown) & (boolean extends IncludeFeatures ? {
2804
+ features?: string[];
2805
+ } : IncludeFeatures extends true ? {
2806
+ features: string[];
2807
+ } : unknown);
2808
+ /** @public */
2809
+ interface ProjectOptions<IncludeMembers extends boolean = true, IncludeFeatures extends boolean = true> extends ProjectHandle {
2810
+ includeMembers?: IncludeMembers;
2811
+ includeFeatures?: IncludeFeatures;
2812
+ }
2813
+ /**
2814
+ * Fetcher for a single project (`GET /projects/:id`), on the shared fetcher
2815
+ * cache. Pre-seeds from the default {@link projects} list entry when it can
2816
+ * satisfy the read — the default list carries features but not members, so
2817
+ * only `includeMembers: false` reads seed.
2818
+ *
2819
+ * @internal
2820
+ */
2821
+ declare const project: Fetcher<[options?: ProjectOptions<boolean, boolean> | undefined], Project<boolean, boolean>>;
2822
+ interface ProjectionOptions<TProjection extends string = string, TDocumentType extends string = string, TDataset extends string = string, TProjectId extends string = string> extends DocumentHandle<TDocumentType, TDataset, TProjectId> {
2823
+ projection: TProjection;
2824
+ }
2825
+ /**
2826
+ * @beta
2827
+ */
2828
+ declare function getProjectionState<TProjection extends string = string, TDocumentType extends string = string, TDataset extends string = string, TProjectId extends string = string>(instance: SanityInstance, options: ProjectionOptions<TProjection, TDocumentType, TDataset, TProjectId>): StateSource<ProjectionValuePending<SanityProjectionResult<TProjection, TDocumentType, `${TProjectId}.${TDataset}`>> | undefined>;
2829
+ /**
2830
+ * @beta
2831
+ */
2832
+ declare function getProjectionState<TData extends object>(instance: SanityInstance, options: ProjectionOptions): StateSource<ProjectionValuePending<TData> | undefined>;
2833
+ /**
2834
+ * @beta
2835
+ */
2836
+ declare function getProjectionState(instance: SanityInstance, options: ProjectionOptions): StateSource<ProjectionValuePending<Record<string, unknown>> | undefined>;
2837
+ /** @beta */
2838
+ declare function resolveProjection<TProjection extends string = string, TDocumentType extends string = string, TDataset extends string = string, TProjectId extends string = string>(instance: SanityInstance, options: ProjectionOptions<TProjection, TDocumentType, TDataset, TProjectId>): Promise<ProjectionValuePending<SanityProjectionResult<TProjection, TDocumentType, `${TProjectId}.${TDataset}`>>>;
2839
+ /** @beta */
2840
+ declare function resolveProjection<TData extends object>(instance: SanityInstance, options: ProjectionOptions): Promise<ProjectionValuePending<TData>>;
2841
+ /** @public */
2842
+ interface ProjectsOptions<IncludeMembers extends boolean = false, IncludeFeatures extends boolean = true> {
2843
+ organizationId?: string;
2844
+ includeMembers?: IncludeMembers;
2845
+ includeFeatures?: IncludeFeatures;
2846
+ onlyExplicitMembership?: boolean;
2847
+ }
2848
+ /**
2849
+ * Fetcher for the current user's projects (`GET /projects`), on the shared
2850
+ * fetcher cache.
2851
+ *
2852
+ * @internal
2853
+ */
2854
+ declare const projects: Fetcher<[options?: ProjectsOptions<boolean, boolean> | undefined], Project<boolean, boolean>[]>;
2855
+ /**
2856
+ * @beta
2857
+ */
2858
+ 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> {
2859
+ query: TQuery;
2860
+ params?: Record<string, unknown>;
2861
+ }
2862
+ /**
2863
+ * @beta
2864
+ */
2865
+ interface ResolveQueryOptions<TQuery extends string = string, TDataset extends string = string, TProjectId extends string = string> extends QueryOptions<TQuery, TDataset, TProjectId> {
2866
+ signal?: AbortSignal;
2867
+ }
2868
+ /** @internal */
2869
+ declare const getQueryKey: (instance: SanityInstance, options: QueryOptions) => string;
2870
+ /** @internal */
2871
+ declare const parseQueryKey: (key: string) => QueryOptions;
2872
+ /**
2873
+ * Returns the state source for a query.
2874
+ *
2875
+ * This function returns a state source that represents the current result of a GROQ query.
2876
+ * Subscribing to the state source will instruct the SDK to fetch the query (if not already fetched)
2877
+ * and will keep the query live using the Live content API (considering sync tags) to provide up-to-date results.
2878
+ * When the last subscriber is removed, the query state is automatically cleaned up from the store.
2879
+ *
2880
+ * Note: This functionality is for advanced users who want to build their own framework integrations.
2881
+ * Our SDK also provides a React integration (useQuery hook) for convenient usage.
2882
+ *
2883
+ * Note: Automatic cleanup can interfere with React Suspense because if a component suspends while being the only subscriber,
2884
+ * cleanup might occur unexpectedly. In such cases, consider using `resolveQuery` instead.
2885
+ *
2886
+ * @beta
2887
+ */
2888
+ 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>;
2889
+ /** @beta */
2890
+ declare function getQueryState<TData>(instance: SanityInstance, queryOptions: QueryOptions): StateSource<TData | undefined>;
2891
+ /** @beta */
2892
+ declare function getQueryState(instance: SanityInstance, queryOptions: QueryOptions): StateSource<unknown>;
2893
+ /**
2894
+ * Resolves the result of a query without registering a lasting subscriber.
2895
+ *
2896
+ * This function fetches the result of a GROQ query and returns a promise that resolves with the query result.
2897
+ * It registers a temporary subscriber for the lifetime of the resolution (released shortly after the promise
2898
+ * settles), so the query state participates in normal cleanup even when no lasting subscriber ever attaches —
2899
+ * e.g. when a suspended component errors before committing. This makes it ideal for use with React Suspense,
2900
+ * where the returned promise is thrown to delay rendering until the query result becomes available.
2901
+ * Once the promise resolves, it is expected that a real subscriber will be added via `getQueryState` to manage ongoing updates.
2902
+ *
2903
+ * Additionally, an optional AbortSignal can be provided to cancel the query and immediately clear the associated state
2904
+ * if there are no other active subscribers.
2905
+ *
2906
+ * @beta
2907
+ */
2908
+ 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}`>>;
2909
+ /** @beta */
2910
+ declare function resolveQuery<TData>(instance: SanityInstance, queryOptions: ResolveQueryOptions): Promise<TData>;
2911
+ /**
2912
+ * Lifecycle states a release document can be in. Mirrors the server's
2913
+ * `ReleaseState`.
2914
+ * @beta
2915
+ */
2916
+ type ReleaseState = 'active' | 'archiving' | 'unarchiving' | 'archived' | 'published' | 'publishing' | 'scheduled' | 'scheduling';
2917
+ interface ReleasesStoreState {
2918
+ activeReleases?: ReleaseDocument[];
2919
+ allReleases?: ReleaseDocument[];
2920
+ error?: unknown;
2921
+ }
2922
+ /**
2923
+ * Get the active releases from the store.
2924
+ * @internal
2925
+ */
2926
+ declare const getActiveReleasesState: (instance: SanityInstance, options?: {
2927
+ resource?: DocumentResource;
2928
+ }) => StateSource<ReleaseDocument[] | undefined>;
2929
+ /**
2930
+ * Get every release in the store, including archived and published.
2931
+ * @internal
2932
+ */
2933
+ declare const getAllReleasesState: (instance: SanityInstance, options?: {
2934
+ resource?: DocumentResource;
2935
+ }) => StateSource<ReleaseDocument[] | undefined>;
2936
+ declare const _getPerspectiveStateSelector: StoreAction<ReleasesStoreState, [_?: (PerspectiveHandle & {
2937
+ projectId?: string;
2938
+ dataset?: string;
2939
+ resource?: DocumentResource;
2940
+ }) | undefined], StateSource<string[] | "previewDrafts" | "published" | "drafts" | "raw" | undefined>, unknown>;
2941
+ type OmitFirst<T extends unknown[]> = T extends [unknown, ...infer R] ? R : never;
2942
+ type SelectorParams = OmitFirst<Parameters<typeof _getPerspectiveStateSelector>>;
2943
+ type BoundGetPerspectiveState = BoundStoreAction<ReleasesStoreState, SelectorParams, ReturnType<typeof _getPerspectiveStateSelector>>;
2944
+ /**
2945
+ * Provides a subscribable state source for a "perspective" for the Sanity client,
2946
+ * which is used to fetch documents as though certain Content Releases are active.
2947
+ *
2948
+ * @param instance - The Sanity instance to get the perspective for
2949
+ * @param options - The options for the perspective -- usually a release name
2950
+ *
2951
+ * @returns A subscribable perspective value, usually a list of applicable release names,
2952
+ * or a single release name / default perspective (such as 'drafts').
2953
+ *
2954
+ * @public
2955
+ */
2956
+ declare const getPerspectiveState: BoundGetPerspectiveState;
2957
+ /**
2958
+ * Returns the state source for users associated with a specific resource.
2959
+ *
2960
+ * This function returns a state source that represents the current list of users for a given
2961
+ * resource. Subscribing to the state source will instruct the SDK to fetch the users (if not
2962
+ * already fetched) and will load more from this state source as well. When the last subscriber is
2963
+ * removed, the users state is automatically cleaned up from the store after a delay.
2964
+ *
2965
+ * Note: This functionality is for advanced users who want to build their own framework
2966
+ * integrations. Our SDK also provides a React integration for convenient usage.
2967
+ *
2968
+ * @beta
2969
+ */
2970
+ declare const getUsersState: BoundStoreAction<UsersStoreState, [options?: GetUsersOptions | undefined], StateSource<{
2971
+ data: SanityUser[];
2972
+ totalCount: number;
2973
+ hasMore: boolean;
2974
+ } | undefined>>;
2975
+ /**
2976
+ * Resolves the users for a specific resource without registering a lasting subscriber.
2977
+ *
2978
+ * This function fetches the users for a given resource and returns a promise that resolves with
2979
+ * the users result. Unlike `getUsersState`, which registers subscribers to keep the data live and
2980
+ * performs automatic cleanup, `resolveUsers` does not track subscribers. This makes it ideal for
2981
+ * use with React Suspense, where the returned promise is thrown to delay rendering until the users
2982
+ * result becomes available. Once the promise resolves, it is expected that a real subscriber will
2983
+ * be added via `getUsersState` to manage ongoing updates.
2984
+ *
2985
+ * Additionally, an optional AbortSignal can be provided to cancel the request and immediately
2986
+ * clear the associated state if there are no active subscribers.
2987
+ *
2988
+ * @beta
2989
+ */
2990
+ declare const resolveUsers: BoundStoreAction<UsersStoreState, [ResolveUsersOptions], Promise<{
2991
+ data: SanityUser[];
2992
+ totalCount: number;
2993
+ hasMore: boolean;
2994
+ }>>;
2995
+ /**
2996
+ * Loads more users for a specific resource.
2997
+ *
2998
+ * This function triggers a request to fetch the next page of users for a given resource. It
2999
+ * requires that users have already been loaded for the resource (via `resolveUsers` or
3000
+ * `getUsersState`), and that there are more users available to load (as indicated by the `hasMore`
3001
+ * property).
3002
+ *
3003
+ * The function returns a promise that resolves when the next page of users has been loaded.
3004
+ *
3005
+ * @beta
3006
+ */
3007
+ declare const loadMoreUsers: BoundStoreAction<UsersStoreState, [options?: GetUsersOptions | undefined], Promise<{
3008
+ data: SanityUser[];
3009
+ totalCount: number;
3010
+ hasMore: boolean;
3011
+ }>>;
3012
+ /**
3013
+ * @beta
3014
+ */
3015
+ declare const getUserState: BoundStoreAction<UsersStoreState, [GetUserOptions], Observable<SanityUser | undefined>>;
3016
+ /**
3017
+ * @beta
3018
+ */
3019
+ declare const resolveUser: BoundStoreAction<UsersStoreState, [ResolveUserOptions], Promise<SanityUser>>;
3020
+ /**
3021
+ * @public
3022
+ * Extracts the project ID from a CorsOriginError message.
3023
+ * @param error - The error to extract the project ID from.
3024
+ * @returns The project ID or null if the error is not a CorsOriginError.
3025
+ */
3026
+ declare function getCorsErrorProjectId(error: Error): string | null;
3027
+ /**
3028
+ * Returns true when the given error looks like a dynamic-import or
3029
+ * code-split chunk-loading failure.
3030
+ *
3031
+ * These errors typically surface when a user has a tab open against a
3032
+ * previously-deployed version of an app and the JavaScript or CSS chunk
3033
+ * filenames have since changed: a fresh deployment removes the hashed assets
3034
+ * the open tab still references. Detecting them lets the SDK trigger an
3035
+ * automatic reload so the user gets the new build without manual intervention.
3036
+ *
3037
+ * Recognized shapes (webpack ChunkLoadError, Vite "Failed to fetch
3038
+ * dynamically imported module", Firefox "error loading dynamically imported
3039
+ * module", Safari "Importing a module script failed", and Vite "Unable to
3040
+ * preload CSS").
3041
+ *
3042
+ * @param error - The value to inspect. Anything that is not an Error
3043
+ * instance returns false.
3044
+ * @returns True if the error matches a known import/chunk-load failure.
3045
+ *
3046
+ * @public
3047
+ */
3048
+ declare function isImportError(error: unknown): boolean;
3049
+ /**
3050
+ * This version is provided by pkg-utils at build time
3051
+ * @internal
3052
+ */
3053
+ declare const CORE_SDK_VERSION: {};
3054
+ /**
3055
+ * @public
3056
+ */
3057
+ type SanityProject$1 = SanityProject;
3058
+ /**
3059
+ * Represents the various states the authentication can be in.
3060
+ *
3061
+ * @public
3062
+ */
3063
+ type AuthState = LoggedInAuthState | LoggedOutAuthState | LoggingInAuthState | ErrorAuthState;
3064
+ /**
3065
+ * Logged-in state from the auth state.
3066
+ * @public
3067
+ */
3068
+ type LoggedInAuthState = {
3069
+ type: AuthStateType.LOGGED_IN;
3070
+ token: string;
3071
+ currentUser: CurrentUser | null;
3072
+ lastTokenRefresh?: number;
3073
+ };
3074
+ /**
3075
+ * Logged-out state from the auth state.
3076
+ * @public
3077
+ */
3078
+ type LoggedOutAuthState = {
3079
+ type: AuthStateType.LOGGED_OUT;
3080
+ isDestroyingSession: boolean;
3081
+ };
3082
+ /**
3083
+ * Logging-in state from the auth state.
3084
+ * @public
3085
+ */
3086
+ type LoggingInAuthState = {
3087
+ type: AuthStateType.LOGGING_IN;
3088
+ isExchangingToken: boolean;
3089
+ };
3090
+ /**
3091
+ * Error state from the auth state.
3092
+ * @public
3093
+ */
3094
+ type ErrorAuthState = {
3095
+ type: AuthStateType.ERROR;
3096
+ error: unknown;
3097
+ };
3098
+ /**
3099
+ * Represents the various states the authentication can be in.
3100
+ *
3101
+ * @public
3102
+ */
3103
+ interface DashboardContext {
3104
+ mode?: string;
3105
+ env?: string;
3106
+ orgId?: string;
3107
+ }
3108
+ /**
3109
+ * The method of authentication used.
3110
+ * @internal
3111
+ */
3112
+ type AuthMethodOptions = 'localstorage' | 'cookie' | undefined;
3113
+ /**
3114
+ * @public
3115
+ */
3116
+ interface AuthStoreState {
3117
+ authState: AuthState;
3118
+ providers?: AuthProvider[];
3119
+ options: {
3120
+ initialLocationHref: string;
3121
+ clientFactory: (config: ClientConfig) => SanityClient;
3122
+ customProviders: AuthConfig['providers'];
3123
+ storageKey: string;
3124
+ storageArea: Storage | undefined;
3125
+ apiHost: string | undefined;
3126
+ loginUrl: string;
3127
+ callbackUrl: string | undefined;
3128
+ providedToken: string | undefined;
3129
+ authMethod: AuthMethodOptions;
3130
+ };
3131
+ dashboardContext?: DashboardContext;
3132
+ }
3133
+ /**
3134
+ * @public
3135
+ */
3136
+ declare const getCurrentUserState: BoundStoreAction<AuthStoreState, [], StateSource<CurrentUser | null>>;
3137
+ /**
3138
+ * @public
3139
+ */
3140
+ declare const getTokenState: BoundStoreAction<AuthStoreState, [], StateSource<string | null>>;
3141
+ /**
3142
+ * @public
3143
+ */
3144
+ declare const getLoginUrlState: BoundStoreAction<AuthStoreState, [], StateSource<string>>;
3145
+ /**
3146
+ * @public
3147
+ */
3148
+ declare const getAuthState: BoundStoreAction<AuthStoreState, [], StateSource<AuthState>>;
3149
+ /**
3150
+ * @public
3151
+ */
3152
+ declare const getDashboardOrganizationId: BoundStoreAction<AuthStoreState, [], StateSource<string | undefined>>;
3153
+ /**
3154
+ * Returns a state source indicating if the SDK is running within a dashboard context.
3155
+ * @public
3156
+ */
3157
+ declare const getIsInDashboardState: BoundStoreAction<AuthStoreState, [], StateSource<boolean>>;
3158
+ /**
3159
+ * Action to explicitly set the authentication token.
3160
+ * Used internally by the Comlink token refresh.
3161
+ * @internal
3162
+ */
3163
+ declare const setAuthToken: BoundStoreAction<AuthStoreState, [token: string | null], void>;
3164
+ export { PreviewMedia as $, unpublishDocument as $n, ApplicationInterface as $r, ApplyDocumentActionsOptions as $t, loadMoreUsers as A, DocumentAction as An, updateComment as Ar, organizations as At, parseQueryKey as B, UnscheduleReleaseAction as Bn, ClientStoreState as Br, InstallationInclude as Bt, slicePath$1 as C, Selector as Ci, Action as Cn, ReplyToCommentOptions as Cr, SanityUser as Ct, getCorsErrorProjectId as D, DeleteDocumentAction as Dn, removeComment as Dr, UsersStoreState as Dt, isImportError as E, CreateReleaseAction as En, createComment as Er, UsersGroupState as Et, getActiveReleasesState as F, PublishReleaseAction as Fn, CommentStatus as Fr, organization as Ft, getProjectionState as G, deleteRelease as Gn, observeOrganizationVerificationState as Gr, installations as Gt, ProjectsOptions as H, createDocument as Hn, getClientState as Hr, InstallationsOptions as Ht, getAllReleasesState as I, ReleaseAction as In, CommentTextSelection as Ir, Installation as It, ProjectMember as J, editRelease as Jn, Application as Jr, SetFavoriteInput as Jt, Project as K, discardDocument as Kn, OrgVerificationResult as Kr, FavoriteDocumentContext as Kt, QueryOptions as L, ScheduleReleaseAction as Ln, CommentTextSelectionItem as Lr, InstallationAccess as Lt, resolveUsers as M, EditDocumentOptions as Mn, CommentLocalState as Mr, OrganizationBase as Mt, getPerspectiveState as N, EditReleaseAction as Nn, CommentMessage as Nr, OrganizationMember as Nt, getUserState as O, DeleteReleaseAction as On, replyToComment as Or, Organizations as Ot, ReleaseState as P, PublishDocumentAction as Pn, CommentReaction as Pr, OrganizationOptions as Pt, project as Q, unarchiveRelease as Qn, ApplicationInclude as Qr, ActionsResult as Qt, getQueryKey as R, UnarchiveReleaseAction as Rn, CommentThread as Rr, InstallationActiveConfig as Rt, jsonMatch$1 as S, defineMutation as Si, JsonMatch as Sn, RemoveCommentOptions as Sr, ResolveUsersOptions as St, CORE_SDK_VERSION as T, BoundStoreAction as Ti, CreateDocumentAction as Tn, UpdateCommentOptions as Tr, UserProfile as Tt, projects as U, createRelease as Un, logout as Ur, InstallationsResponse as Ut, resolveQuery as V, archiveRelease as Vn, getClient as Vr, InstallationInterface as Vt, resolveProjection as W, deleteDocument as Wn, handleAuthCallback as Wr, installation as Wt, ProjectMetadata as X, publishRelease as Xn, ApplicationBase as Xr, setFavorite as Xt, ProjectMemberRole as Y, publishDocument as Yn, ApplicationAccess as Yr, favorites as Yt, ProjectOptions as Z, scheduleRelease as Zn, ApplicationDeployment as Zr, getReleaseDocumentId as Zt, SanityDocument$3 as _, FetcherDefinition as _i, resolveDocument as _n, getCommentsState as _r, UserPresence as _t, LoggedOutAuthState as a, DeleteApplicationInput as ai, DocumentEditedEvent as an, LogLevel as ar, reportPresence as at, getPathDepth as b, MutationResult as bi, DocumentPermissionsResult as bn, resolveComments as br, Membership as bt, getCurrentUserState as c, application as ci, DocumentRemotePatchesEvent as cn, LoggerConfig as cr, DocumentPresenceOptions as ct, getLoginUrlState as d, updateApplication as di, TransactionAcceptedEvent as dn, createDocumentTypeHandle as dr, PresenceSelection as dt, ApplicationStudioConfig as ei, applyDocumentActions as en, unscheduleRelease as er, PreviewQueryResult as et, getTokenState as f, AccessResourceType as fi, TransactionRevertedEvent as fn, createProjectHandle as fr, PresenceSelectionPoint as ft, Role as g, Fetcher as gi, getPermissionsState as gn, getCommentsOptionsKey as gr, TransportEvent as gt, ReleaseDocument$1 as h, CacheWriter as hi, getDocumentSyncStatus as hn, getCommentThreadsState as hr, StateEvent as ht, LoggedInAuthState as i, ApplicationsResponse as ii, DocumentDiscardedEvent as in, LogContext as ir, getPresence as it, resolveUser as j, EditDocumentAction as jn, Comment as jr, Organization as jt, getUsersState as k, DiscardDocumentAction as kn, setCommentStatus as kr, OrganizationsOptions as kt, getDashboardOrganizationId as l, applications as li, DocumentTransactionSubmissionResult as ln, createDatasetHandle as lr, PresenceLocation as lt, CurrentUser$1 as m, CacheTag as mi, getDocumentState as mn, ResolveCommentsOptions as mr, RollCallEvent as mt, AuthStoreState as n, ApplicationWorkspace as ni, DocumentCreatedEvent as nn, configureLogging as nr, ProjectionValuePending as nt, LoggingInAuthState as o, DeletedResult as oi, DocumentEvent as on, LogNamespace as or, DisconnectEvent as ot, setAuthToken as p, checkPermissions as pi, DocumentOptions as pn, CommentsOptions as pr, ReportPresenceOptions as pt, ProjectBase as q, editDocument as qn, AuthStateType as qr, FavoriteStatusResponse as qt, ErrorAuthState as r, ApplicationsOptions as ri, DocumentDeletedEvent as rn, InstanceContext as rr, getDocumentPresence as rt, getAuthState as s, UpdateApplicationInput as si, DocumentPublishedEvent as sn, Logger as sr, DocumentPresence as st, AuthState as t, ApplicationVisibility as ti, ActionErrorEvent as tn, datasets as tr, PreviewValue as tt, getIsInDashboardState as u, deleteApplication as ui, DocumentUnpublishedEvent as un, createDocumentHandle as ur, PresencePerspectiveOptions as ut, SanityProject$1 as v, FetcherSnapshot as vi, resolvePermissions as vn, parseCommentsOptionsKey as vr, GetUserOptions as vt, stringifyPath$1 as w, StateSource as wi, ArchiveReleaseAction as wn, SetCommentStatusOptions as wr, SanityUserResponse as wt, joinPaths as x, defineFetcher as xi, PermissionDeniedReason as xn, CreateCommentOptions as xr, ResolveUserOptions as xt, getIndexForKey$1 as y, MutationDefinition as yi, subscribeDocumentEvents as yn, resolveCommentThreads as yr, GetUsersOptions as yt, getQueryState as z, UnpublishDocumentAction as zn, ClientOptions as zr, InstallationBase as zt };
3165
+ //# sourceMappingURL=authStore-C0o1NOxW.d.ts.map