@sanity/sdk 3.0.0-rc.1 → 3.0.0-rc.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +12 -0
- package/dist/_exports/_internal.d.ts +71 -3
- package/dist/_exports/_internal.d.ts.map +1 -1
- package/dist/_exports/_internal.js +332 -24
- package/dist/_exports/_internal.js.map +1 -1
- package/dist/_exports/agent.d.ts +65 -0
- package/dist/_exports/agent.d.ts.map +1 -0
- package/dist/_exports/agent.js +71 -0
- package/dist/_exports/agent.js.map +1 -0
- package/dist/_exports/comlink.d.ts +118 -0
- package/dist/_exports/comlink.d.ts.map +1 -0
- package/dist/_exports/comlink.js +69 -0
- package/dist/_exports/comlink.js.map +1 -0
- package/dist/authStore-CtE9bLHW.js +754 -0
- package/dist/authStore-CtE9bLHW.js.map +1 -0
- package/dist/authStore-DKFX8fn7.d.ts +3179 -0
- package/dist/authStore-DKFX8fn7.d.ts.map +1 -0
- package/dist/clientStore-BtE2-q2i.js +90 -0
- package/dist/clientStore-BtE2-q2i.js.map +1 -0
- package/dist/createSanityInstance-DUI1bGIg.d.ts +278 -0
- package/dist/createSanityInstance-DUI1bGIg.d.ts.map +1 -0
- package/dist/createStateSourceAction-BOKtqFNm.js +300 -0
- package/dist/createStateSourceAction-BOKtqFNm.js.map +1 -0
- package/dist/getEnv-D5RGkQLu.js +8 -0
- package/dist/getEnv-D5RGkQLu.js.map +1 -0
- package/dist/getNodeState-CR3__B2D.js +67 -0
- package/dist/getNodeState-CR3__B2D.js.map +1 -0
- package/dist/index.d.ts +3 -2335
- package/dist/index.js +4048 -3874
- package/dist/index.js.map +1 -1
- package/dist/logger-DAtJb5RQ.js +173 -0
- package/dist/logger-DAtJb5RQ.js.map +1 -0
- package/dist/object-CxXlSVg7.js +83 -0
- package/dist/object-CxXlSVg7.js.map +1 -0
- package/dist/queryStore-DPf9sN3V.js +1346 -0
- package/dist/queryStore-DPf9sN3V.js.map +1 -0
- package/dist/rolldown-runtime-vyAXikos.js +9 -0
- package/dist/setCleanupTimeout-BiM6q1KF.js +31 -0
- package/dist/setCleanupTimeout-BiM6q1KF.js.map +1 -0
- package/dist/telemetryManager-Dq_qCkeI.js +127 -0
- package/dist/telemetryManager-Dq_qCkeI.js.map +1 -0
- package/dist/version-BChjsi4u.js +9 -0
- package/dist/version-BChjsi4u.js.map +1 -0
- package/package.json +13 -19
- package/src/_exports/_internal.ts +1 -0
- package/src/_exports/agent.ts +19 -0
- package/src/_exports/comlink.ts +16 -0
- package/src/_exports/index.ts +38 -86
- package/src/applications/applications.test-d.ts +5 -0
- package/src/applications/applications.ts +5 -2
- package/src/auth/authMode.test.ts +0 -25
- package/src/auth/authMode.ts +3 -6
- package/src/auth/authStore.test.ts +1 -1
- package/src/auth/authStore.ts +0 -1
- package/src/comments/addonDatasetStore.test.ts +215 -0
- package/src/comments/addonDatasetStore.ts +249 -0
- package/src/comments/buildCommentThreads.test.ts +83 -0
- package/src/comments/buildCommentThreads.ts +54 -0
- package/src/comments/commentActions.test.ts +540 -0
- package/src/comments/commentActions.ts +555 -0
- package/src/comments/commentFieldPath.test.ts +40 -0
- package/src/comments/commentFieldPath.ts +44 -0
- package/src/comments/commentsConstants.ts +80 -0
- package/src/comments/commentsStore.test.ts +419 -0
- package/src/comments/commentsStore.ts +483 -0
- package/src/comments/normalizeComment.test.ts +116 -0
- package/src/comments/normalizeComment.ts +45 -0
- package/src/comments/observeComments.test.ts +193 -0
- package/src/comments/observeComments.ts +113 -0
- package/src/comments/reducers.test.ts +277 -0
- package/src/comments/reducers.ts +316 -0
- package/src/comments/types.ts +249 -0
- package/src/comments/weakenReferences.test.ts +47 -0
- package/src/comments/weakenReferences.ts +29 -0
- package/src/config/sanityConfig.ts +3 -75
- package/src/document/applyDocumentActions.test.ts +8 -12
- package/src/document/documentConstants.ts +8 -0
- package/src/document/documentStore.test.ts +104 -19
- package/src/document/documentStore.ts +36 -5
- package/src/document/patchOperations.test.ts +27 -0
- package/src/document/patchOperations.ts +10 -1
- package/src/document/permissions.test.ts +3 -1
- package/src/document/reducers.test.ts +133 -0
- package/src/document/reducers.ts +18 -3
- package/src/document/util.test.ts +46 -0
- package/src/document/util.ts +37 -1
- package/src/installations/installations.test-d.ts +5 -0
- package/src/installations/installations.ts +4 -0
- package/src/presence/bifurTransport.test.ts +155 -3
- package/src/presence/bifurTransport.ts +79 -12
- package/src/presence/paths.test.ts +70 -0
- package/src/presence/paths.ts +41 -0
- package/src/presence/presenceStore.test.ts +822 -2
- package/src/presence/presenceStore.ts +518 -102
- package/src/presence/types.ts +175 -3
- package/src/preview/types.ts +0 -25
- package/src/projection/projectionStore.test.ts +0 -8
- package/src/projection/types.ts +0 -8
- package/src/query/queryStore.ts +7 -6
- package/src/store/createActionBinder.test.ts +51 -29
- package/src/store/createActionBinder.ts +16 -62
- package/src/store/createSanityInstance.test.ts +0 -68
- package/src/store/createSanityInstance.ts +0 -63
- package/src/store/createStateSourceAction.ts +1 -1
- package/src/users/reducers.test.ts +0 -3
- package/dist/_chunks-dts/createGroqSearchFilter.d.ts +0 -1147
- package/dist/_chunks-dts/createGroqSearchFilter.d.ts.map +0 -1
- package/dist/_chunks-es/_internal.js +0 -134
- package/dist/_chunks-es/_internal.js.map +0 -1
- package/dist/_chunks-es/createGroqSearchFilter.js +0 -1864
- package/dist/_chunks-es/createGroqSearchFilter.js.map +0 -1
- package/dist/_chunks-es/telemetryManager.js +0 -93
- package/dist/_chunks-es/telemetryManager.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/src/applications/userApplications.test.ts +0 -126
- package/src/applications/userApplications.ts +0 -261
- package/src/preview/getPreviewState.test.ts +0 -137
- package/src/preview/getPreviewState.ts +0 -69
- package/src/preview/resolvePreview.test.ts +0 -64
- package/src/preview/resolvePreview.ts +0 -43
|
@@ -0,0 +1,3179 @@
|
|
|
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, 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
|
+
/** @public */
|
|
1368
|
+
declare const getDatasetsState: BoundStoreAction<FetcherStoreState<[options?: ProjectHandle<string> | undefined], import("@sanity/client").DatasetsResponse>, [options?: ProjectHandle<string> | undefined], StateSource<import("@sanity/client").DatasetsResponse | undefined>>;
|
|
1369
|
+
/** @public */
|
|
1370
|
+
declare const resolveDatasets: BoundStoreAction<FetcherStoreState<[options?: ProjectHandle<string> | undefined], import("@sanity/client").DatasetsResponse>, [options?: ProjectHandle<string> | undefined], Promise<import("@sanity/client").DatasetsResponse>>;
|
|
1371
|
+
/**
|
|
1372
|
+
* Represents an action to create a new document.
|
|
1373
|
+
* Specifies the document type and optionally a document ID (which will be treated as the published ID).
|
|
1374
|
+
* @beta
|
|
1375
|
+
*/
|
|
1376
|
+
interface CreateDocumentAction<TDocumentType extends string = string, TDataset extends string = string, TProjectId extends string = string> extends DocumentTypeHandle<TDocumentType, TDataset, TProjectId> {
|
|
1377
|
+
type: 'document.create';
|
|
1378
|
+
/**
|
|
1379
|
+
* Optional initial field values for the document.
|
|
1380
|
+
* These values will be set when the document is created.
|
|
1381
|
+
* System fields (_id, _type, _rev, _createdAt, _updatedAt) are omitted as they are set automatically.
|
|
1382
|
+
*/
|
|
1383
|
+
initialValue?: Partial<Omit<SanityDocument$2<TDocumentType, `${TProjectId}.${TDataset}`>, '_id' | '_type' | '_rev' | '_createdAt' | '_updatedAt'>>;
|
|
1384
|
+
}
|
|
1385
|
+
/**
|
|
1386
|
+
* Represents an action to delete an existing document.
|
|
1387
|
+
* Requires the full document handle including the document ID.
|
|
1388
|
+
* @beta
|
|
1389
|
+
*/
|
|
1390
|
+
interface DeleteDocumentAction<TDocumentType extends string = string, TDataset extends string = string, TProjectId extends string = string> extends DocumentHandle<TDocumentType, TDataset, TProjectId> {
|
|
1391
|
+
type: 'document.delete';
|
|
1392
|
+
}
|
|
1393
|
+
/**
|
|
1394
|
+
* Represents an action to edit an existing document using patches.
|
|
1395
|
+
* Requires the full document handle and an array of patch operations.
|
|
1396
|
+
* @beta
|
|
1397
|
+
*/
|
|
1398
|
+
interface EditDocumentAction<TDocumentType extends string = string, TDataset extends string = string, TProjectId extends string = string> extends DocumentHandle<TDocumentType, TDataset, TProjectId> {
|
|
1399
|
+
type: 'document.edit';
|
|
1400
|
+
patches?: PatchOperations[];
|
|
1401
|
+
/**
|
|
1402
|
+
* When `true`, the given `patches` are forwarded verbatim to the server and
|
|
1403
|
+
* applied as-is locally, instead of being re-derived by diffing document
|
|
1404
|
+
* snapshots. This preserves the operational intent of the patches (e.g.
|
|
1405
|
+
* keyed array inserts/unsets), which lets concurrent edits from other
|
|
1406
|
+
* clients interleave coherently instead of being overwritten by
|
|
1407
|
+
* position-based patches computed from a stale snapshot.
|
|
1408
|
+
*
|
|
1409
|
+
* Use this when the patches were produced by an editor that tracks its own
|
|
1410
|
+
* operations (e.g. a collaborative text editor). During a rebase onto a
|
|
1411
|
+
* changed remote document, preserved patches are re-applied operationally;
|
|
1412
|
+
* if a patch can no longer apply, the transaction is skipped and reported
|
|
1413
|
+
* as a `rebase-error` document event.
|
|
1414
|
+
*/
|
|
1415
|
+
preserveOperations?: boolean;
|
|
1416
|
+
}
|
|
1417
|
+
/**
|
|
1418
|
+
* Represents an action to publish the draft version of a document.
|
|
1419
|
+
* Requires the full document handle.
|
|
1420
|
+
* @beta
|
|
1421
|
+
*/
|
|
1422
|
+
interface PublishDocumentAction<TDocumentType extends string = string, TDataset extends string = string, TProjectId extends string = string> extends DocumentHandle<TDocumentType, TDataset, TProjectId> {
|
|
1423
|
+
type: 'document.publish';
|
|
1424
|
+
}
|
|
1425
|
+
/**
|
|
1426
|
+
* Represents an action to unpublish a document, moving its published content to a draft.
|
|
1427
|
+
* Requires the full document handle.
|
|
1428
|
+
* @beta
|
|
1429
|
+
*/
|
|
1430
|
+
interface UnpublishDocumentAction<TDocumentType extends string = string, TDataset extends string = string, TProjectId extends string = string> extends DocumentHandle<TDocumentType, TDataset, TProjectId> {
|
|
1431
|
+
type: 'document.unpublish';
|
|
1432
|
+
}
|
|
1433
|
+
/**
|
|
1434
|
+
* Represents an action to discard the draft changes of a document.
|
|
1435
|
+
* Requires the full document handle.
|
|
1436
|
+
* @beta
|
|
1437
|
+
*/
|
|
1438
|
+
interface DiscardDocumentAction<TDocumentType extends string = string, TDataset extends string = string, TProjectId extends string = string> extends DocumentHandle<TDocumentType, TDataset, TProjectId> {
|
|
1439
|
+
type: 'document.discard';
|
|
1440
|
+
}
|
|
1441
|
+
/**
|
|
1442
|
+
* Union type representing all possible document actions within the SDK.
|
|
1443
|
+
* @beta
|
|
1444
|
+
*/
|
|
1445
|
+
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>;
|
|
1446
|
+
/**
|
|
1447
|
+
* Union of every action accepted by `applyDocumentActions` — both document-
|
|
1448
|
+
* level actions and release-lifecycle actions.
|
|
1449
|
+
* @beta
|
|
1450
|
+
*/
|
|
1451
|
+
type Action<TDocumentType extends string = string, TDataset extends string = string, TProjectId extends string = string> = DocumentAction<TDocumentType, TDataset, TProjectId> | ReleaseAction;
|
|
1452
|
+
/**
|
|
1453
|
+
* Creates a `CreateDocumentAction` object.
|
|
1454
|
+
* @param doc - A handle identifying the document type, dataset, and project. An optional `documentId` can be provided.
|
|
1455
|
+
* @param initialValue - Optional initial field values for the document. (System fields are omitted as they are set automatically.)
|
|
1456
|
+
* @returns A `CreateDocumentAction` object ready for dispatch.
|
|
1457
|
+
* @beta
|
|
1458
|
+
*/
|
|
1459
|
+
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>;
|
|
1460
|
+
/**
|
|
1461
|
+
* Creates a `DeleteDocumentAction` object.
|
|
1462
|
+
* @param doc - A handle uniquely identifying the document to be deleted.
|
|
1463
|
+
* @returns A `DeleteDocumentAction` object ready for dispatch.
|
|
1464
|
+
* @beta
|
|
1465
|
+
*/
|
|
1466
|
+
declare function deleteDocument<TDocumentType extends string = string, TDataset extends string = string, TProjectId extends string = string>(doc: DocumentHandle<TDocumentType, TDataset, TProjectId>): DeleteDocumentAction<TDocumentType, TDataset, TProjectId>;
|
|
1467
|
+
/**
|
|
1468
|
+
* Options for creating an `EditDocumentAction`.
|
|
1469
|
+
* @beta
|
|
1470
|
+
*/
|
|
1471
|
+
interface EditDocumentOptions {
|
|
1472
|
+
/**
|
|
1473
|
+
* Forward the given patches verbatim instead of re-deriving them by
|
|
1474
|
+
* diffing document snapshots. See {@link EditDocumentAction.preserveOperations}.
|
|
1475
|
+
*/
|
|
1476
|
+
preserveOperations?: boolean;
|
|
1477
|
+
}
|
|
1478
|
+
/**
|
|
1479
|
+
* Creates an `EditDocumentAction` object with patches for modifying a document.
|
|
1480
|
+
* Accepts patches in either the standard `PatchOperations` format or as a `SanityMutatePatchMutation` from `@sanity/mutate`.
|
|
1481
|
+
*
|
|
1482
|
+
* @param doc - A handle uniquely identifying the document to be edited.
|
|
1483
|
+
* @param sanityMutatePatch - A patch mutation object from `@sanity/mutate`.
|
|
1484
|
+
* @param options - Options controlling how the patches are processed.
|
|
1485
|
+
* @returns An `EditDocumentAction` object ready for dispatch.
|
|
1486
|
+
* @beta
|
|
1487
|
+
*/
|
|
1488
|
+
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>;
|
|
1489
|
+
/**
|
|
1490
|
+
* Creates an `EditDocumentAction` object with patches for modifying a document.
|
|
1491
|
+
*
|
|
1492
|
+
* @param doc - A handle uniquely identifying the document to be edited.
|
|
1493
|
+
* @param patches - A single patch operation or an array of patch operations.
|
|
1494
|
+
* @param options - Options controlling how the patches are processed.
|
|
1495
|
+
* @returns An `EditDocumentAction` object ready for dispatch.
|
|
1496
|
+
* @beta
|
|
1497
|
+
*/
|
|
1498
|
+
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>;
|
|
1499
|
+
/**
|
|
1500
|
+
* Creates a `PublishDocumentAction` object.
|
|
1501
|
+
* @param doc - A handle uniquely identifying the document to be published.
|
|
1502
|
+
* @returns A `PublishDocumentAction` object ready for dispatch.
|
|
1503
|
+
* @beta
|
|
1504
|
+
*/
|
|
1505
|
+
declare function publishDocument<TDocumentType extends string = string, TDataset extends string = string, TProjectId extends string = string>(doc: DocumentHandle<TDocumentType, TDataset, TProjectId>): PublishDocumentAction<TDocumentType, TDataset, TProjectId>;
|
|
1506
|
+
/**
|
|
1507
|
+
* Creates an `UnpublishDocumentAction` object.
|
|
1508
|
+
* @param doc - A handle uniquely identifying the document to be unpublished.
|
|
1509
|
+
* @returns An `UnpublishDocumentAction` object ready for dispatch.
|
|
1510
|
+
* @beta
|
|
1511
|
+
*/
|
|
1512
|
+
declare function unpublishDocument<TDocumentType extends string = string, TDataset extends string = string, TProjectId extends string = string>(doc: DocumentHandle<TDocumentType, TDataset, TProjectId>): UnpublishDocumentAction<TDocumentType, TDataset, TProjectId>;
|
|
1513
|
+
/**
|
|
1514
|
+
* Creates a `DiscardDocumentAction` object.
|
|
1515
|
+
* @param doc - A handle uniquely identifying the document whose draft changes are to be discarded.
|
|
1516
|
+
* @returns A `DiscardDocumentAction` object ready for dispatch.
|
|
1517
|
+
* @beta
|
|
1518
|
+
*/
|
|
1519
|
+
declare function discardDocument<TDocumentType extends string = string, TDataset extends string = string, TProjectId extends string = string>(doc: DocumentHandle<TDocumentType, TDataset, TProjectId>): DiscardDocumentAction<TDocumentType, TDataset, TProjectId>;
|
|
1520
|
+
/**
|
|
1521
|
+
* Creates a new release. The `releaseId` must be unique within the current
|
|
1522
|
+
* retention period.
|
|
1523
|
+
* @beta
|
|
1524
|
+
*/
|
|
1525
|
+
interface CreateReleaseAction extends ReleaseHandle {
|
|
1526
|
+
type: 'release.create';
|
|
1527
|
+
metadata: ReleaseDocument['metadata'];
|
|
1528
|
+
}
|
|
1529
|
+
/**
|
|
1530
|
+
* Patches the metadata of an existing release.
|
|
1531
|
+
* @beta
|
|
1532
|
+
*/
|
|
1533
|
+
interface EditReleaseAction extends ReleaseHandle {
|
|
1534
|
+
type: 'release.edit';
|
|
1535
|
+
patch: PatchOperations;
|
|
1536
|
+
}
|
|
1537
|
+
/**
|
|
1538
|
+
* Publishes all version documents in a release.
|
|
1539
|
+
* @beta
|
|
1540
|
+
*/
|
|
1541
|
+
interface PublishReleaseAction extends ReleaseHandle {
|
|
1542
|
+
type: 'release.publish';
|
|
1543
|
+
}
|
|
1544
|
+
/**
|
|
1545
|
+
* Schedules a release to be published at the given UTC time. Locks the
|
|
1546
|
+
* version documents server-side until the release is unscheduled or published.
|
|
1547
|
+
* @beta
|
|
1548
|
+
*/
|
|
1549
|
+
interface ScheduleReleaseAction extends ReleaseHandle {
|
|
1550
|
+
type: 'release.schedule';
|
|
1551
|
+
publishAt: string;
|
|
1552
|
+
}
|
|
1553
|
+
/**
|
|
1554
|
+
* Unschedules a release that was previously scheduled, returning it to the
|
|
1555
|
+
* active editable state.
|
|
1556
|
+
* @beta
|
|
1557
|
+
*/
|
|
1558
|
+
interface UnscheduleReleaseAction extends ReleaseHandle {
|
|
1559
|
+
type: 'release.unschedule';
|
|
1560
|
+
}
|
|
1561
|
+
/**
|
|
1562
|
+
* Archives an active release. Version documents within the release are
|
|
1563
|
+
* removed and no longer queryable, though still recoverable through history
|
|
1564
|
+
* during the retention period.
|
|
1565
|
+
* @beta
|
|
1566
|
+
*/
|
|
1567
|
+
interface ArchiveReleaseAction extends ReleaseHandle {
|
|
1568
|
+
type: 'release.archive';
|
|
1569
|
+
}
|
|
1570
|
+
/**
|
|
1571
|
+
* Restores an archived release. Only possible during the retention period.
|
|
1572
|
+
* @beta
|
|
1573
|
+
*/
|
|
1574
|
+
interface UnarchiveReleaseAction extends ReleaseHandle {
|
|
1575
|
+
type: 'release.unarchive';
|
|
1576
|
+
}
|
|
1577
|
+
/**
|
|
1578
|
+
* Permanently deletes an archived or published release. To remove an active
|
|
1579
|
+
* release, use the archive action first.
|
|
1580
|
+
* @beta
|
|
1581
|
+
*/
|
|
1582
|
+
interface DeleteReleaseAction extends ReleaseHandle {
|
|
1583
|
+
type: 'release.delete';
|
|
1584
|
+
}
|
|
1585
|
+
/**
|
|
1586
|
+
* Union of all release actions that can be dispatched alongside document
|
|
1587
|
+
* actions through `applyDocumentActions`.
|
|
1588
|
+
* @beta
|
|
1589
|
+
*/
|
|
1590
|
+
type ReleaseAction = CreateReleaseAction | EditReleaseAction | PublishReleaseAction | ScheduleReleaseAction | UnscheduleReleaseAction | ArchiveReleaseAction | UnarchiveReleaseAction | DeleteReleaseAction;
|
|
1591
|
+
/** @beta */
|
|
1592
|
+
declare function createRelease(handle: ReleaseHandle, metadata?: ReleaseDocument['metadata']): CreateReleaseAction;
|
|
1593
|
+
/** @beta */
|
|
1594
|
+
declare function editRelease(handle: ReleaseHandle, patch: PatchOperations): EditReleaseAction;
|
|
1595
|
+
/** @beta */
|
|
1596
|
+
declare function publishRelease(handle: ReleaseHandle): PublishReleaseAction;
|
|
1597
|
+
/** @beta */
|
|
1598
|
+
declare function scheduleRelease(handle: ReleaseHandle, publishAt: string): ScheduleReleaseAction;
|
|
1599
|
+
/** @beta */
|
|
1600
|
+
declare function unscheduleRelease(handle: ReleaseHandle): UnscheduleReleaseAction;
|
|
1601
|
+
/** @beta */
|
|
1602
|
+
declare function archiveRelease(handle: ReleaseHandle): ArchiveReleaseAction;
|
|
1603
|
+
/** @beta */
|
|
1604
|
+
declare function unarchiveRelease(handle: ReleaseHandle): UnarchiveReleaseAction;
|
|
1605
|
+
/** @beta */
|
|
1606
|
+
declare function deleteRelease(handle: ReleaseHandle): DeleteReleaseAction;
|
|
1607
|
+
/**
|
|
1608
|
+
* Split the entire path string on dots "outside" of any brackets.
|
|
1609
|
+
*
|
|
1610
|
+
* For example:
|
|
1611
|
+
* ```
|
|
1612
|
+
* "friends[0].name"
|
|
1613
|
+
* ```
|
|
1614
|
+
*
|
|
1615
|
+
* becomes:
|
|
1616
|
+
*
|
|
1617
|
+
* ```
|
|
1618
|
+
* [...ParseSegment<"friends[0]">, ...ParseSegment<"name">]
|
|
1619
|
+
* ```
|
|
1620
|
+
*
|
|
1621
|
+
* (We use a simple recursion that splits on the first dot.)
|
|
1622
|
+
*/
|
|
1623
|
+
type PathParts<TPath extends string> = TPath extends `${infer Head}.${infer Tail}` ? [Head, ...PathParts<Tail>] : TPath extends '' ? [] : [TPath];
|
|
1624
|
+
/**
|
|
1625
|
+
* Given a type T and an array of "access keys" Parts, recursively index into T.
|
|
1626
|
+
*
|
|
1627
|
+
* If a part is a key, it looks up that property.
|
|
1628
|
+
* If T is an array and the part is a number, it "indexes" into the element type.
|
|
1629
|
+
*/
|
|
1630
|
+
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
|
|
1631
|
+
, TTail extends readonly (string | number)[] ? TTail : []> : never;
|
|
1632
|
+
/**
|
|
1633
|
+
* Given a document type TDocument and a JSON Match path string TPath,
|
|
1634
|
+
* compute the type found at that path.
|
|
1635
|
+
* @beta
|
|
1636
|
+
*/
|
|
1637
|
+
type JsonMatch<TDocument, TPath extends string> = DeepGet<TDocument, PathParts<TPath>>;
|
|
1638
|
+
/**
|
|
1639
|
+
* Represents a set of document that will go into `applyMutations`. Before
|
|
1640
|
+
* applying a mutation, it's expected that all relevant documents that the
|
|
1641
|
+
* mutations affect are included, including those that do not exist yet.
|
|
1642
|
+
* Documents that don't exist have a `null` value.
|
|
1643
|
+
*/
|
|
1644
|
+
type DocumentSet<TDocument extends SanityDocument$1 = SanityDocument$1> = { [TDocumentId in string]?: TDocument | null; };
|
|
1645
|
+
type Grant = 'read' | 'update' | 'create' | 'history';
|
|
1646
|
+
/** @beta */
|
|
1647
|
+
interface PermissionDeniedReason {
|
|
1648
|
+
type: 'precondition' | 'access';
|
|
1649
|
+
message: string;
|
|
1650
|
+
documentId?: string;
|
|
1651
|
+
}
|
|
1652
|
+
/** @beta */
|
|
1653
|
+
type DocumentPermissionsResult = {
|
|
1654
|
+
allowed: false;
|
|
1655
|
+
message: string;
|
|
1656
|
+
reasons: PermissionDeniedReason[];
|
|
1657
|
+
} | {
|
|
1658
|
+
allowed: true;
|
|
1659
|
+
message?: undefined;
|
|
1660
|
+
reasons?: undefined;
|
|
1661
|
+
};
|
|
1662
|
+
interface SharedListener {
|
|
1663
|
+
events: Observable<ListenEvent<SanityDocument>>;
|
|
1664
|
+
dispose: () => void;
|
|
1665
|
+
}
|
|
1666
|
+
interface DocumentStoreState {
|
|
1667
|
+
documentStates: { [TDocumentId in string]?: DocumentState; };
|
|
1668
|
+
queued: QueuedTransaction[];
|
|
1669
|
+
applied: AppliedTransaction[];
|
|
1670
|
+
outgoing?: OutgoingTransaction;
|
|
1671
|
+
grants?: Record<Grant, ExprNode>;
|
|
1672
|
+
/**
|
|
1673
|
+
* The current user's identity (their user ID).
|
|
1674
|
+
*/
|
|
1675
|
+
identity?: string;
|
|
1676
|
+
error?: unknown;
|
|
1677
|
+
sharedListener: SharedListener;
|
|
1678
|
+
fetchDocument: (documentId: string) => Observable<SanityDocument$2 | null>;
|
|
1679
|
+
events: Subject<DocumentEvent>;
|
|
1680
|
+
}
|
|
1681
|
+
interface DocumentState {
|
|
1682
|
+
id: string;
|
|
1683
|
+
/**
|
|
1684
|
+
* the "remote" local copy that matches the server. represents the last known
|
|
1685
|
+
* server state. this gets updated every time we confirm remote patches
|
|
1686
|
+
*/
|
|
1687
|
+
remote?: SanityDocument$2 | null;
|
|
1688
|
+
/**
|
|
1689
|
+
* the current ephemeral working copy that includes local optimistic changes
|
|
1690
|
+
* that have not yet been confirmed by the server
|
|
1691
|
+
*/
|
|
1692
|
+
local?: SanityDocument$2 | null;
|
|
1693
|
+
/**
|
|
1694
|
+
* the revision that our remote document is at
|
|
1695
|
+
*/
|
|
1696
|
+
remoteRev?: string | null;
|
|
1697
|
+
/**
|
|
1698
|
+
* Array of subscription IDs. This document state will be deleted if there are
|
|
1699
|
+
* no subscribers.
|
|
1700
|
+
*/
|
|
1701
|
+
subscriptions: string[];
|
|
1702
|
+
/**
|
|
1703
|
+
* An object keyed by transaction ID of revisions sent out but that have not
|
|
1704
|
+
* yet been verified yet. When an applied transaction is transitioned to an
|
|
1705
|
+
* outgoing transaction, it also adds unverified revisions for each document
|
|
1706
|
+
* that is part of that outgoing transaction. Transactions are submitted to
|
|
1707
|
+
* the server with a locally generated transaction ID. This way we can observe
|
|
1708
|
+
* when our transaction comes back through the shared listener. Each listener
|
|
1709
|
+
* event that comes back contains a `previousRev`. If we see our own
|
|
1710
|
+
* transaction with a different `previousRev` than expected, we can rebase our
|
|
1711
|
+
* local transactions on top of this new remote.
|
|
1712
|
+
*/
|
|
1713
|
+
unverifiedRevisions?: { [TTransactionId in string]?: UnverifiedDocumentRevision; };
|
|
1714
|
+
/**
|
|
1715
|
+
* transaction IDs recently submitted by this client for this document,
|
|
1716
|
+
* newest last. used to label `remote-patches` events with the correct
|
|
1717
|
+
* `origin` even after the corresponding `unverifiedRevisions` entry has
|
|
1718
|
+
* been pruned (e.g. by a sync event that raced the listener echo). capped
|
|
1719
|
+
* to the most recent entries.
|
|
1720
|
+
*/
|
|
1721
|
+
recentOwnTransactionIds?: string[];
|
|
1722
|
+
}
|
|
1723
|
+
/**
|
|
1724
|
+
* @beta
|
|
1725
|
+
* Options for specifying a document and optionally a path within it.
|
|
1726
|
+
*/
|
|
1727
|
+
interface DocumentOptions<TPath extends string | undefined = undefined, TDocumentType extends string = string, TDataset extends string = string, TProjectId extends string = string> extends DocumentHandle<TDocumentType, TDataset, TProjectId> {
|
|
1728
|
+
path?: TPath;
|
|
1729
|
+
}
|
|
1730
|
+
/** @beta */
|
|
1731
|
+
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>;
|
|
1732
|
+
/** @beta */
|
|
1733
|
+
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>;
|
|
1734
|
+
/** @beta */
|
|
1735
|
+
declare function getDocumentState<TData>(instance: SanityInstance, options: DocumentOptions<string | undefined>): StateSource<TData | undefined | null>;
|
|
1736
|
+
/** @beta */
|
|
1737
|
+
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>;
|
|
1738
|
+
/** @beta */
|
|
1739
|
+
declare function resolveDocument<TData extends SanityDocument$2>(instance: SanityInstance, docHandle: DocumentHandle<string, string, string>): Promise<TData | null>;
|
|
1740
|
+
/** @beta */
|
|
1741
|
+
declare const getDocumentSyncStatus: BoundStoreAction<DocumentStoreState, [doc: DocumentHandle<string, string, string>], StateSource<boolean | undefined>>;
|
|
1742
|
+
type PermissionsStateOptions = {
|
|
1743
|
+
resource?: DocumentResource;
|
|
1744
|
+
actions: DocumentAction[];
|
|
1745
|
+
};
|
|
1746
|
+
/** @beta */
|
|
1747
|
+
declare const getPermissionsState: BoundStoreAction<DocumentStoreState, [PermissionsStateOptions], StateSource<DocumentPermissionsResult>>;
|
|
1748
|
+
/** @beta */
|
|
1749
|
+
declare const resolvePermissions: BoundStoreAction<DocumentStoreState, [options: PermissionsStateOptions], Promise<DocumentPermissionsResult>>;
|
|
1750
|
+
/** @beta */
|
|
1751
|
+
declare const subscribeDocumentEvents: BoundStoreAction<DocumentStoreState, [options: {
|
|
1752
|
+
resource?: DocumentResource;
|
|
1753
|
+
eventHandler: (e: DocumentEvent) => void;
|
|
1754
|
+
}], () => void>;
|
|
1755
|
+
type ActionMap = {
|
|
1756
|
+
create: 'sanity.action.document.version.create';
|
|
1757
|
+
discard: 'sanity.action.document.version.discard';
|
|
1758
|
+
unpublish: 'sanity.action.document.unpublish';
|
|
1759
|
+
delete: 'sanity.action.document.delete';
|
|
1760
|
+
edit: 'sanity.action.document.edit';
|
|
1761
|
+
publish: 'sanity.action.document.publish';
|
|
1762
|
+
releaseCreate: 'sanity.action.release.create';
|
|
1763
|
+
releaseEdit: 'sanity.action.release.edit';
|
|
1764
|
+
releasePublish: 'sanity.action.release.publish';
|
|
1765
|
+
releaseSchedule: 'sanity.action.release.schedule';
|
|
1766
|
+
releaseUnschedule: 'sanity.action.release.unschedule';
|
|
1767
|
+
releaseArchive: 'sanity.action.release.archive';
|
|
1768
|
+
releaseUnarchive: 'sanity.action.release.unarchive';
|
|
1769
|
+
releaseDelete: 'sanity.action.release.delete';
|
|
1770
|
+
};
|
|
1771
|
+
type OptimisticLock = {
|
|
1772
|
+
ifDraftRevisionId?: string;
|
|
1773
|
+
ifPublishedRevisionId?: string;
|
|
1774
|
+
};
|
|
1775
|
+
interface ReleaseMetadataPayload {
|
|
1776
|
+
title?: string;
|
|
1777
|
+
description?: string;
|
|
1778
|
+
intendedPublishAt?: string;
|
|
1779
|
+
releaseType?: 'asap' | 'scheduled' | 'undecided';
|
|
1780
|
+
cardinality?: 'one' | 'many';
|
|
1781
|
+
}
|
|
1782
|
+
type HttpAction = {
|
|
1783
|
+
actionType: ActionMap['create'];
|
|
1784
|
+
publishedId: string;
|
|
1785
|
+
attributes: SanityDocumentLike;
|
|
1786
|
+
} | {
|
|
1787
|
+
actionType: ActionMap['discard'];
|
|
1788
|
+
versionId: string;
|
|
1789
|
+
purge?: boolean;
|
|
1790
|
+
} | {
|
|
1791
|
+
actionType: ActionMap['unpublish'];
|
|
1792
|
+
draftId: string;
|
|
1793
|
+
publishedId: string;
|
|
1794
|
+
} | {
|
|
1795
|
+
actionType: ActionMap['delete'];
|
|
1796
|
+
publishedId: string;
|
|
1797
|
+
includeDrafts?: string[];
|
|
1798
|
+
} | {
|
|
1799
|
+
actionType: ActionMap['edit'];
|
|
1800
|
+
draftId: string;
|
|
1801
|
+
publishedId: string;
|
|
1802
|
+
patch: PatchOperations;
|
|
1803
|
+
} | ({
|
|
1804
|
+
actionType: ActionMap['publish'];
|
|
1805
|
+
draftId: string;
|
|
1806
|
+
publishedId: string;
|
|
1807
|
+
} & OptimisticLock) | {
|
|
1808
|
+
actionType: ActionMap['releaseCreate'];
|
|
1809
|
+
releaseId: string;
|
|
1810
|
+
metadata?: ReleaseMetadataPayload;
|
|
1811
|
+
} | {
|
|
1812
|
+
actionType: ActionMap['releaseEdit'];
|
|
1813
|
+
releaseId: string;
|
|
1814
|
+
patch: PatchOperations;
|
|
1815
|
+
} | {
|
|
1816
|
+
actionType: ActionMap['releasePublish'];
|
|
1817
|
+
releaseId: string;
|
|
1818
|
+
} | {
|
|
1819
|
+
actionType: ActionMap['releaseSchedule'];
|
|
1820
|
+
releaseId: string;
|
|
1821
|
+
publishAt: string;
|
|
1822
|
+
} | {
|
|
1823
|
+
actionType: ActionMap['releaseUnschedule'];
|
|
1824
|
+
releaseId: string;
|
|
1825
|
+
} | {
|
|
1826
|
+
actionType: ActionMap['releaseArchive'];
|
|
1827
|
+
releaseId: string;
|
|
1828
|
+
} | {
|
|
1829
|
+
actionType: ActionMap['releaseUnarchive'];
|
|
1830
|
+
releaseId: string;
|
|
1831
|
+
} | {
|
|
1832
|
+
actionType: ActionMap['releaseDelete'];
|
|
1833
|
+
releaseId: string;
|
|
1834
|
+
};
|
|
1835
|
+
/**
|
|
1836
|
+
* Represents a transaction that is queued to be applied but has not yet been
|
|
1837
|
+
* applied. A transaction will remain in a queued state until all required
|
|
1838
|
+
* documents for the transactions are available locally.
|
|
1839
|
+
*/
|
|
1840
|
+
interface QueuedTransaction {
|
|
1841
|
+
/**
|
|
1842
|
+
* the ID of this transaction. this is generated client-side.
|
|
1843
|
+
*/
|
|
1844
|
+
transactionId: string;
|
|
1845
|
+
/**
|
|
1846
|
+
* the high-level actions associated with this transaction. note that these
|
|
1847
|
+
* actions don't mention draft IDs and is meant to abstract away the draft
|
|
1848
|
+
* model from users.
|
|
1849
|
+
*/
|
|
1850
|
+
actions: Action[];
|
|
1851
|
+
/**
|
|
1852
|
+
* An optional flag set to disable this transaction from being batched with
|
|
1853
|
+
* other transactions.
|
|
1854
|
+
*/
|
|
1855
|
+
disableBatching?: boolean;
|
|
1856
|
+
}
|
|
1857
|
+
/**
|
|
1858
|
+
* Represents a transaction that has been applied locally but has not been
|
|
1859
|
+
* committed/transitioned-to-outgoing. These transactions are visible to the
|
|
1860
|
+
* user but may be rebased upon a new working document set. Applied transactions
|
|
1861
|
+
* also contain the resulting `outgoingActions` that will be submitted to
|
|
1862
|
+
* Content Lake. These `outgoingActions` depend on the state of the working
|
|
1863
|
+
* documents so they are recomputed on rebase and are only relevant to applied
|
|
1864
|
+
* actions (we cannot compute `outgoingActions` for queued transactions because
|
|
1865
|
+
* we haven't resolved the set of documents the actions are dependent on yet).
|
|
1866
|
+
*
|
|
1867
|
+
* In order to support better conflict resolution, the original `previous` set
|
|
1868
|
+
* is saved as the `base` set.
|
|
1869
|
+
*/
|
|
1870
|
+
interface AppliedTransaction extends QueuedTransaction {
|
|
1871
|
+
/**
|
|
1872
|
+
* the resulting set of documents after the actions have been applied
|
|
1873
|
+
*/
|
|
1874
|
+
working: DocumentSet;
|
|
1875
|
+
/**
|
|
1876
|
+
* the previous set of documents before the action was applied
|
|
1877
|
+
*/
|
|
1878
|
+
previous: DocumentSet;
|
|
1879
|
+
/**
|
|
1880
|
+
* the original `previous` document set captured when this action was
|
|
1881
|
+
* originally applied. this is used as a reference point to do a 3-way merge
|
|
1882
|
+
* if this applied transaction ever needs to be reapplied on a different
|
|
1883
|
+
* set of documents.
|
|
1884
|
+
*/
|
|
1885
|
+
base: DocumentSet;
|
|
1886
|
+
/**
|
|
1887
|
+
* the `_rev`s from `previous` document set
|
|
1888
|
+
*/
|
|
1889
|
+
previousRevs: { [TDocumentId in string]?: string; };
|
|
1890
|
+
/**
|
|
1891
|
+
* a timestamp for when this transaction was applied locally
|
|
1892
|
+
*/
|
|
1893
|
+
timestamp: string;
|
|
1894
|
+
/**
|
|
1895
|
+
* the resulting HTTP actions derived from the state of the `working` document
|
|
1896
|
+
* set. these are sent to Content Lake as-is when this transaction is batched
|
|
1897
|
+
* and transitioned into an outgoing transaction.
|
|
1898
|
+
*/
|
|
1899
|
+
outgoingActions: HttpAction[];
|
|
1900
|
+
/**
|
|
1901
|
+
* similar to `outgoingActions` but comprised of mutations instead of actions.
|
|
1902
|
+
* Useful for debugging, and is also used by liveEdit documents to send mutations,
|
|
1903
|
+
* since they can't use the Actions API which is pretty dependent on the draft model.
|
|
1904
|
+
*/
|
|
1905
|
+
outgoingMutations: Mutation[];
|
|
1906
|
+
}
|
|
1907
|
+
/**
|
|
1908
|
+
* Represents a set of applied transactions batched into a single outgoing
|
|
1909
|
+
* transaction. An outgoing transaction is the result of batching many applied
|
|
1910
|
+
* actions. An outgoing transaction may be reverted locally if the server
|
|
1911
|
+
* does not accept it.
|
|
1912
|
+
*/
|
|
1913
|
+
interface OutgoingTransaction extends AppliedTransaction {
|
|
1914
|
+
disableBatching: boolean;
|
|
1915
|
+
batchedTransactionIds: string[];
|
|
1916
|
+
}
|
|
1917
|
+
interface UnverifiedDocumentRevision {
|
|
1918
|
+
transactionId: string;
|
|
1919
|
+
documentId: string;
|
|
1920
|
+
previousRev: string | undefined;
|
|
1921
|
+
timestamp: string;
|
|
1922
|
+
}
|
|
1923
|
+
/** @beta Response body from submitting an outgoing transaction (actions or mutations API). */
|
|
1924
|
+
type DocumentTransactionSubmissionResult = Awaited<ReturnType<SanityClient['action']>> | MultipleMutationResult;
|
|
1925
|
+
/** @beta */
|
|
1926
|
+
type DocumentEvent = ActionErrorEvent | TransactionRevertedEvent | TransactionAcceptedEvent | DocumentRebaseErrorEvent | DocumentEditedEvent | DocumentCreatedEvent | DocumentDeletedEvent | DocumentPublishedEvent | DocumentUnpublishedEvent | DocumentDiscardedEvent | DocumentRemotePatchesEvent;
|
|
1927
|
+
/**
|
|
1928
|
+
* @beta
|
|
1929
|
+
* Event emitted when a precondition to applying an action fails.
|
|
1930
|
+
* (For example: when trying to edit a document that no longer exists.)
|
|
1931
|
+
*/
|
|
1932
|
+
interface ActionErrorEvent {
|
|
1933
|
+
type: 'error';
|
|
1934
|
+
documentId: string;
|
|
1935
|
+
transactionId: string;
|
|
1936
|
+
message: string;
|
|
1937
|
+
error: unknown;
|
|
1938
|
+
}
|
|
1939
|
+
/**
|
|
1940
|
+
* @beta
|
|
1941
|
+
* Event emitted when a transaction is accepted.
|
|
1942
|
+
*/
|
|
1943
|
+
interface TransactionAcceptedEvent {
|
|
1944
|
+
type: 'accepted';
|
|
1945
|
+
outgoing: OutgoingTransaction;
|
|
1946
|
+
result: DocumentTransactionSubmissionResult;
|
|
1947
|
+
}
|
|
1948
|
+
/**
|
|
1949
|
+
* @beta
|
|
1950
|
+
* Event emitted when a transaction is reverted.
|
|
1951
|
+
*/
|
|
1952
|
+
interface TransactionRevertedEvent {
|
|
1953
|
+
type: 'reverted';
|
|
1954
|
+
message: string;
|
|
1955
|
+
error: unknown;
|
|
1956
|
+
outgoing: OutgoingTransaction;
|
|
1957
|
+
}
|
|
1958
|
+
/**
|
|
1959
|
+
* @beta
|
|
1960
|
+
* Event emitted when an attempt to apply local changes to a modified remote document fails.
|
|
1961
|
+
*/
|
|
1962
|
+
interface DocumentRebaseErrorEvent {
|
|
1963
|
+
type: 'rebase-error';
|
|
1964
|
+
documentId: string;
|
|
1965
|
+
transactionId: string;
|
|
1966
|
+
message: string;
|
|
1967
|
+
error: unknown;
|
|
1968
|
+
}
|
|
1969
|
+
/**
|
|
1970
|
+
* @beta
|
|
1971
|
+
* Event emitted when a document is edited.
|
|
1972
|
+
*/
|
|
1973
|
+
interface DocumentEditedEvent {
|
|
1974
|
+
type: 'edited';
|
|
1975
|
+
documentId: string;
|
|
1976
|
+
outgoing: OutgoingTransaction;
|
|
1977
|
+
}
|
|
1978
|
+
/**
|
|
1979
|
+
* @beta
|
|
1980
|
+
* Event emitted when a document is created.
|
|
1981
|
+
*/
|
|
1982
|
+
interface DocumentCreatedEvent {
|
|
1983
|
+
type: 'created';
|
|
1984
|
+
documentId: string;
|
|
1985
|
+
outgoing: OutgoingTransaction;
|
|
1986
|
+
}
|
|
1987
|
+
/**
|
|
1988
|
+
* @beta
|
|
1989
|
+
* Event emitted when a document is deleted.
|
|
1990
|
+
*/
|
|
1991
|
+
interface DocumentDeletedEvent {
|
|
1992
|
+
type: 'deleted';
|
|
1993
|
+
documentId: string;
|
|
1994
|
+
outgoing: OutgoingTransaction;
|
|
1995
|
+
}
|
|
1996
|
+
/**
|
|
1997
|
+
* @beta
|
|
1998
|
+
* Event emitted when a document is published.
|
|
1999
|
+
*/
|
|
2000
|
+
interface DocumentPublishedEvent {
|
|
2001
|
+
type: 'published';
|
|
2002
|
+
documentId: string;
|
|
2003
|
+
outgoing: OutgoingTransaction;
|
|
2004
|
+
}
|
|
2005
|
+
/**
|
|
2006
|
+
* @beta
|
|
2007
|
+
* Event emitted when a document is unpublished.
|
|
2008
|
+
*/
|
|
2009
|
+
interface DocumentUnpublishedEvent {
|
|
2010
|
+
type: 'unpublished';
|
|
2011
|
+
documentId: string;
|
|
2012
|
+
outgoing: OutgoingTransaction;
|
|
2013
|
+
}
|
|
2014
|
+
/**
|
|
2015
|
+
* @beta
|
|
2016
|
+
* Event emitted when a document version is discarded.
|
|
2017
|
+
*/
|
|
2018
|
+
interface DocumentDiscardedEvent {
|
|
2019
|
+
type: 'discarded';
|
|
2020
|
+
documentId: string;
|
|
2021
|
+
outgoing: OutgoingTransaction;
|
|
2022
|
+
}
|
|
2023
|
+
/**
|
|
2024
|
+
* @beta
|
|
2025
|
+
* Event emitted when patches for a document are observed through the listener.
|
|
2026
|
+
*
|
|
2027
|
+
* Unlike the whole-document snapshots the store keeps, these are the raw patch
|
|
2028
|
+
* operations from the transaction that produced the change, preserving the
|
|
2029
|
+
* operational intent of the edit (e.g. keyed array inserts/unsets). Consumers
|
|
2030
|
+
* that maintain their own local state, like collaborative text editors, can
|
|
2031
|
+
* apply these directly instead of diffing document snapshots.
|
|
2032
|
+
*
|
|
2033
|
+
* `origin` is `'local'` when the transaction was submitted by this document
|
|
2034
|
+
* store instance (an own edit observed back through the listener) and
|
|
2035
|
+
* `'remote'` when it came from another client.
|
|
2036
|
+
*/
|
|
2037
|
+
interface DocumentRemotePatchesEvent {
|
|
2038
|
+
type: 'remote-patches';
|
|
2039
|
+
/** The ID of the document version the patches apply to (e.g. a draft ID). */
|
|
2040
|
+
documentId: string;
|
|
2041
|
+
/** The transaction ID that carried these patches. */
|
|
2042
|
+
transactionId: string;
|
|
2043
|
+
/** The revision the document was at before this transaction. */
|
|
2044
|
+
previousRev?: string;
|
|
2045
|
+
/** The timestamp of the transaction. */
|
|
2046
|
+
timestamp: string;
|
|
2047
|
+
/** The patch operations, rooted at the document. */
|
|
2048
|
+
patches: PatchOperations[];
|
|
2049
|
+
/** Whether the transaction originated from this client or another one. */
|
|
2050
|
+
origin: 'local' | 'remote';
|
|
2051
|
+
}
|
|
2052
|
+
/** @beta */
|
|
2053
|
+
interface ActionsResult<TDocument extends SanityDocument$2 = SanityDocument$2> {
|
|
2054
|
+
transactionId: string;
|
|
2055
|
+
documents: DocumentSet<TDocument>;
|
|
2056
|
+
previous: DocumentSet<TDocument>;
|
|
2057
|
+
previousRevs: {
|
|
2058
|
+
[documentId: string]: string | undefined;
|
|
2059
|
+
};
|
|
2060
|
+
appeared: string[];
|
|
2061
|
+
updated: string[];
|
|
2062
|
+
disappeared: string[];
|
|
2063
|
+
submitted: () => Promise<DocumentTransactionSubmissionResult>;
|
|
2064
|
+
}
|
|
2065
|
+
/** @beta */
|
|
2066
|
+
interface ApplyDocumentActionsOptions {
|
|
2067
|
+
/**
|
|
2068
|
+
* List of actions to apply. Accepts both document actions and release
|
|
2069
|
+
* lifecycle actions because they share the same transaction pipeline.
|
|
2070
|
+
*/
|
|
2071
|
+
actions: Action[];
|
|
2072
|
+
/**
|
|
2073
|
+
* The resource to which the documents being acted on belong.
|
|
2074
|
+
*/
|
|
2075
|
+
resource?: DocumentResource;
|
|
2076
|
+
/**
|
|
2077
|
+
* Optionally provide an ID to be used as this transaction ID
|
|
2078
|
+
*/
|
|
2079
|
+
transactionId?: string;
|
|
2080
|
+
/**
|
|
2081
|
+
* Set this to true to prevent this action from being batched with others.
|
|
2082
|
+
*/
|
|
2083
|
+
disableBatching?: boolean;
|
|
2084
|
+
}
|
|
2085
|
+
/** @beta */
|
|
2086
|
+
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}`>>>;
|
|
2087
|
+
/** @beta */
|
|
2088
|
+
declare function applyDocumentActions(instance: SanityInstance, options: ApplyDocumentActionsOptions): Promise<ActionsResult>;
|
|
2089
|
+
/**
|
|
2090
|
+
* Returns the full release document ID for the given release name.
|
|
2091
|
+
* e.g. `getReleaseDocumentId('my-release') === '_.releases.my-release'`
|
|
2092
|
+
* @beta
|
|
2093
|
+
*/
|
|
2094
|
+
declare function getReleaseDocumentId(releaseId: string): string;
|
|
2095
|
+
/**
|
|
2096
|
+
* @public
|
|
2097
|
+
*/
|
|
2098
|
+
interface FavoriteStatusResponse {
|
|
2099
|
+
isFavorited: boolean;
|
|
2100
|
+
}
|
|
2101
|
+
/**
|
|
2102
|
+
* @public
|
|
2103
|
+
*/
|
|
2104
|
+
interface FavoriteDocumentContext extends DocumentHandle {
|
|
2105
|
+
resourceId: string;
|
|
2106
|
+
resourceType: StudioResource['type'] | MediaResource['type'] | CanvasResource['type'];
|
|
2107
|
+
schemaName?: string;
|
|
2108
|
+
}
|
|
2109
|
+
/**
|
|
2110
|
+
* Gets a StateSource for the favorite status of a document.
|
|
2111
|
+
* @param instance - The Sanity instance.
|
|
2112
|
+
* @param context - The document context including ID, type, and resource information.
|
|
2113
|
+
* @returns A StateSource emitting `{ isFavorited: boolean }`.
|
|
2114
|
+
* @public
|
|
2115
|
+
*/
|
|
2116
|
+
declare const getFavoritesState: BoundStoreAction<FetcherStoreState<[FavoriteDocumentContext], FavoriteStatusResponse>, [FavoriteDocumentContext], StateSource<FavoriteStatusResponse | undefined>>;
|
|
2117
|
+
/**
|
|
2118
|
+
* Resolves the favorite status for a document.
|
|
2119
|
+
* @param instance - The Sanity instance.
|
|
2120
|
+
* @param context - The document context including ID, type, and resource information.
|
|
2121
|
+
* @returns A Promise resolving to `{ isFavorited: boolean }`.
|
|
2122
|
+
* @public
|
|
2123
|
+
*/
|
|
2124
|
+
declare const resolveFavoritesState: BoundStoreAction<FetcherStoreState<[FavoriteDocumentContext], FavoriteStatusResponse>, [FavoriteDocumentContext], Promise<FavoriteStatusResponse>>;
|
|
2125
|
+
/**
|
|
2126
|
+
* Related data the Installations API can embed in a response. Each token adds
|
|
2127
|
+
* a top-level field to the {@link Installation} item.
|
|
2128
|
+
*
|
|
2129
|
+
* @see https://www.sanity.io/docs/http-reference/applications-api
|
|
2130
|
+
* @public
|
|
2131
|
+
*/
|
|
2132
|
+
type InstallationInclude = 'activeConfig' | 'access' | 'interfaces';
|
|
2133
|
+
/**
|
|
2134
|
+
* A resource an installation accesses, embedded when `access` is included.
|
|
2135
|
+
*
|
|
2136
|
+
* @see https://www.sanity.io/docs/http-reference/applications-api
|
|
2137
|
+
* @public
|
|
2138
|
+
*/
|
|
2139
|
+
interface InstallationAccess {
|
|
2140
|
+
id: string;
|
|
2141
|
+
resourceType: 'datasets' | 'canvases' | 'dashboards' | 'media-libraries';
|
|
2142
|
+
resourceId: string;
|
|
2143
|
+
}
|
|
2144
|
+
/**
|
|
2145
|
+
* An interface exposed by an installation, embedded when `interfaces` is
|
|
2146
|
+
* included.
|
|
2147
|
+
*
|
|
2148
|
+
* @see https://www.sanity.io/docs/http-reference/applications-api
|
|
2149
|
+
* @public
|
|
2150
|
+
*/
|
|
2151
|
+
interface InstallationInterface {
|
|
2152
|
+
id: string;
|
|
2153
|
+
type: 'app' | 'worker' | 'asset_source' | 'panel';
|
|
2154
|
+
name: string;
|
|
2155
|
+
title: string;
|
|
2156
|
+
version: string;
|
|
2157
|
+
/** Module federation module ID; resolved from the host mf-manifest at runtime */
|
|
2158
|
+
moduleId: string;
|
|
2159
|
+
metadata: {
|
|
2160
|
+
group?: string;
|
|
2161
|
+
priority?: number;
|
|
2162
|
+
} | null;
|
|
2163
|
+
}
|
|
2164
|
+
/**
|
|
2165
|
+
* The active config of an installation, embedded when `activeConfig` is
|
|
2166
|
+
* included. `null` when nothing is deployed.
|
|
2167
|
+
*
|
|
2168
|
+
* @see https://www.sanity.io/docs/http-reference/applications-api
|
|
2169
|
+
* @public
|
|
2170
|
+
*/
|
|
2171
|
+
interface InstallationActiveConfig {
|
|
2172
|
+
id: string;
|
|
2173
|
+
installationId: string;
|
|
2174
|
+
deployedBy: string | null;
|
|
2175
|
+
version: string;
|
|
2176
|
+
isActive: boolean;
|
|
2177
|
+
createdAt: string;
|
|
2178
|
+
}
|
|
2179
|
+
/**
|
|
2180
|
+
* The always-present fields of an active singleton installation returned by the
|
|
2181
|
+
* Installations API (`/installations`), before any {@link InstallationInclude}.
|
|
2182
|
+
*
|
|
2183
|
+
* @see https://www.sanity.io/docs/http-reference/applications-api
|
|
2184
|
+
* @public
|
|
2185
|
+
*/
|
|
2186
|
+
interface InstallationBase {
|
|
2187
|
+
id: string;
|
|
2188
|
+
applicationId: string;
|
|
2189
|
+
organizationId: string;
|
|
2190
|
+
installedBy: string | null;
|
|
2191
|
+
createdAt: string;
|
|
2192
|
+
updatedAt: string;
|
|
2193
|
+
application: {
|
|
2194
|
+
title: string;
|
|
2195
|
+
/** Stable, immutable identity of the installed singleton, distinct from `slug`. */
|
|
2196
|
+
name: string;
|
|
2197
|
+
/** Qualified, globally-unique handle of the installed singleton (e.g. `sanity/<name>`). */
|
|
2198
|
+
reference: string;
|
|
2199
|
+
slug: string | null;
|
|
2200
|
+
};
|
|
2201
|
+
}
|
|
2202
|
+
/**
|
|
2203
|
+
* An active singleton installation as returned by the Installations API
|
|
2204
|
+
* (`/installations`). `activeConfig`, `access` and `interfaces` are top-level
|
|
2205
|
+
* fields, each present only when the matching {@link InstallationInclude} token
|
|
2206
|
+
* was requested.
|
|
2207
|
+
*
|
|
2208
|
+
* @see https://www.sanity.io/docs/http-reference/applications-api
|
|
2209
|
+
* @public
|
|
2210
|
+
*/
|
|
2211
|
+
type Installation<Include extends InstallationInclude = never> = InstallationBase & Included<InstallationInclude, 'activeConfig', Include, {
|
|
2212
|
+
activeConfig: InstallationActiveConfig | null;
|
|
2213
|
+
}> & Included<InstallationInclude, 'access', Include, {
|
|
2214
|
+
access: InstallationAccess[];
|
|
2215
|
+
}> & Included<InstallationInclude, 'interfaces', Include, {
|
|
2216
|
+
interfaces: InstallationInterface[];
|
|
2217
|
+
}>;
|
|
2218
|
+
/**
|
|
2219
|
+
* Options for listing an organization's installations.
|
|
2220
|
+
*
|
|
2221
|
+
* @see https://www.sanity.io/docs/http-reference/applications-api
|
|
2222
|
+
* @public
|
|
2223
|
+
*/
|
|
2224
|
+
interface InstallationsOptions<Include extends InstallationInclude = InstallationInclude> {
|
|
2225
|
+
organizationId: string;
|
|
2226
|
+
include?: Include[];
|
|
2227
|
+
/** Page size (1-100, default 50), or `'none'` to disable pagination */
|
|
2228
|
+
limit?: number | 'none';
|
|
2229
|
+
/** Cursor from a previous response's `nextCursor` */
|
|
2230
|
+
cursor?: string;
|
|
2231
|
+
}
|
|
2232
|
+
/**
|
|
2233
|
+
* The cursor-paginated envelope returned by `GET /installations`.
|
|
2234
|
+
*
|
|
2235
|
+
* @see https://www.sanity.io/docs/http-reference/applications-api
|
|
2236
|
+
* @public
|
|
2237
|
+
*/
|
|
2238
|
+
interface InstallationsResponse<Include extends InstallationInclude = never> {
|
|
2239
|
+
nextCursor: string | null;
|
|
2240
|
+
data: Installation<Include>[];
|
|
2241
|
+
}
|
|
2242
|
+
/**
|
|
2243
|
+
* Fetcher for an organization's installations (`GET /installations`), on the
|
|
2244
|
+
* shared fetcher cache.
|
|
2245
|
+
*
|
|
2246
|
+
* @see https://www.sanity.io/docs/http-reference/applications-api
|
|
2247
|
+
* @internal
|
|
2248
|
+
*/
|
|
2249
|
+
declare const installations: Fetcher<[options: InstallationsOptions<InstallationInclude>], InstallationsResponse<InstallationInclude>>;
|
|
2250
|
+
/**
|
|
2251
|
+
* Fetcher for a single installation (`GET /installations/:id`), on the shared
|
|
2252
|
+
* fetcher cache. No pre-seeding from {@link installations}: its list keys
|
|
2253
|
+
* include the organization, which this fetcher's params can't reconstruct.
|
|
2254
|
+
*
|
|
2255
|
+
* @see https://www.sanity.io/docs/http-reference/applications-api
|
|
2256
|
+
* @internal
|
|
2257
|
+
*/
|
|
2258
|
+
declare const installation: Fetcher<[installationId: string, options?: {
|
|
2259
|
+
include?: InstallationInclude[];
|
|
2260
|
+
} | undefined], Installation<InstallationInclude>>;
|
|
2261
|
+
/** @public */
|
|
2262
|
+
interface OrganizationMember {
|
|
2263
|
+
sanityUserId: string;
|
|
2264
|
+
isCurrentUser: boolean;
|
|
2265
|
+
user: {
|
|
2266
|
+
id: string;
|
|
2267
|
+
displayName: string;
|
|
2268
|
+
familyName: string;
|
|
2269
|
+
givenName: string;
|
|
2270
|
+
middleName: string | null;
|
|
2271
|
+
imageUrl: string | null;
|
|
2272
|
+
email: string;
|
|
2273
|
+
loginProvider: string;
|
|
2274
|
+
};
|
|
2275
|
+
roles: Array<{
|
|
2276
|
+
name: string;
|
|
2277
|
+
title: string;
|
|
2278
|
+
description?: string;
|
|
2279
|
+
}>;
|
|
2280
|
+
}
|
|
2281
|
+
/**
|
|
2282
|
+
* The base fields returned from `/organizations/<id>` for every organization.
|
|
2283
|
+
* @public
|
|
2284
|
+
*/
|
|
2285
|
+
interface OrganizationBase {
|
|
2286
|
+
id: string;
|
|
2287
|
+
name: string;
|
|
2288
|
+
slug: string | null;
|
|
2289
|
+
createdAt: string;
|
|
2290
|
+
createdByUserId: string;
|
|
2291
|
+
updatedAt: string;
|
|
2292
|
+
deletedAt: string | null;
|
|
2293
|
+
dashboardStatus: 'enabled' | 'disabled';
|
|
2294
|
+
aiFeaturesStatus: 'enabled' | 'disabled';
|
|
2295
|
+
mediaLibraryStatus: 'enabled' | 'disabled';
|
|
2296
|
+
requestAccessStatus: 'allowed' | 'disabled';
|
|
2297
|
+
telemetryConsentStatus: 'allowed' | 'msa_denied' | 'customer_denied';
|
|
2298
|
+
oauthAppsStatus: 'allowed' | 'blocked';
|
|
2299
|
+
defaultRoleName: string;
|
|
2300
|
+
domains: string[] | null;
|
|
2301
|
+
}
|
|
2302
|
+
/** @public */
|
|
2303
|
+
interface OrganizationOptions<IncludeMembers extends boolean = false, IncludeFeatures extends boolean = false> {
|
|
2304
|
+
includeMembers?: IncludeMembers;
|
|
2305
|
+
includeFeatures?: IncludeFeatures;
|
|
2306
|
+
organizationId: string;
|
|
2307
|
+
}
|
|
2308
|
+
/**
|
|
2309
|
+
* An `Organization` with `members` and/or `features` conditionally included
|
|
2310
|
+
* based on the query options used to fetch it.
|
|
2311
|
+
* @public
|
|
2312
|
+
*/
|
|
2313
|
+
type Organization<IncludeMembers extends boolean = false, IncludeFeatures extends boolean = false> = OrganizationBase & (boolean extends IncludeMembers ? {
|
|
2314
|
+
members?: OrganizationMember[];
|
|
2315
|
+
} : IncludeMembers extends true ? {
|
|
2316
|
+
members: OrganizationMember[];
|
|
2317
|
+
} : unknown) & (boolean extends IncludeFeatures ? {
|
|
2318
|
+
features?: string[];
|
|
2319
|
+
} : IncludeFeatures extends true ? {
|
|
2320
|
+
features: string[];
|
|
2321
|
+
} : unknown);
|
|
2322
|
+
/**
|
|
2323
|
+
* Fetcher for a single organization (`GET /organizations/:id`), on the shared
|
|
2324
|
+
* fetcher cache. No pre-seeding from the organizations list: it returns a
|
|
2325
|
+
* subset of the detail fields, and a partial seed would serve as fresh for
|
|
2326
|
+
* the whole stale window.
|
|
2327
|
+
*
|
|
2328
|
+
* @internal
|
|
2329
|
+
*/
|
|
2330
|
+
declare const organization: Fetcher<[options?: OrganizationOptions<boolean, boolean> | undefined], Organization<boolean, boolean>>;
|
|
2331
|
+
/**
|
|
2332
|
+
* The list shape returned from `/organizations`, with `members` and/or
|
|
2333
|
+
* `features` conditionally included based on the query options used.
|
|
2334
|
+
* @public
|
|
2335
|
+
*/
|
|
2336
|
+
type Organizations<IncludeMembers extends boolean = false, IncludeFeatures extends boolean = false> = (Pick<OrganizationBase, 'id' | 'name' | 'slug' | 'createdAt' | 'updatedAt' | 'defaultRoleName' | 'dashboardStatus' | 'aiFeaturesStatus'> & (boolean extends IncludeMembers ? {
|
|
2337
|
+
members?: OrganizationMember[];
|
|
2338
|
+
} : IncludeMembers extends true ? {
|
|
2339
|
+
members: OrganizationMember[];
|
|
2340
|
+
} : unknown) & (boolean extends IncludeFeatures ? {
|
|
2341
|
+
features?: string[];
|
|
2342
|
+
} : IncludeFeatures extends true ? {
|
|
2343
|
+
features: string[];
|
|
2344
|
+
} : unknown))[];
|
|
2345
|
+
/** @public */
|
|
2346
|
+
interface OrganizationsOptions<IncludeMembers extends boolean = false, IncludeFeatures extends boolean = false> extends Omit<OrganizationOptions<IncludeMembers, IncludeFeatures>, 'organizationId'> {
|
|
2347
|
+
/**
|
|
2348
|
+
* When `true`, includes organisations the user has access to via
|
|
2349
|
+
* project-level grants, not just direct organisation memberships.
|
|
2350
|
+
*/
|
|
2351
|
+
includeImplicitMemberships?: boolean;
|
|
2352
|
+
}
|
|
2353
|
+
/**
|
|
2354
|
+
* Fetcher for the current user's organizations (`GET /organizations`), on the
|
|
2355
|
+
* shared fetcher cache.
|
|
2356
|
+
*
|
|
2357
|
+
* @internal
|
|
2358
|
+
*/
|
|
2359
|
+
declare const organizations: Fetcher<[options?: OrganizationsOptions<boolean, boolean> | undefined], Organizations<boolean, boolean>>;
|
|
2360
|
+
/**
|
|
2361
|
+
* @public
|
|
2362
|
+
*/
|
|
2363
|
+
interface SanityUser {
|
|
2364
|
+
sanityUserId: string;
|
|
2365
|
+
profile: UserProfile;
|
|
2366
|
+
memberships: Membership[];
|
|
2367
|
+
}
|
|
2368
|
+
/**
|
|
2369
|
+
* @public
|
|
2370
|
+
*/
|
|
2371
|
+
interface Membership {
|
|
2372
|
+
addedAt?: string;
|
|
2373
|
+
resourceType: string;
|
|
2374
|
+
resourceId: string;
|
|
2375
|
+
roleNames: Array<string>;
|
|
2376
|
+
lastSeenAt?: string | null;
|
|
2377
|
+
}
|
|
2378
|
+
/**
|
|
2379
|
+
* @public
|
|
2380
|
+
*/
|
|
2381
|
+
interface UserProfile {
|
|
2382
|
+
id: string;
|
|
2383
|
+
displayName: string;
|
|
2384
|
+
email: string;
|
|
2385
|
+
familyName?: string;
|
|
2386
|
+
givenName?: string;
|
|
2387
|
+
middleName?: string | null;
|
|
2388
|
+
imageUrl?: string;
|
|
2389
|
+
provider: string;
|
|
2390
|
+
tosAcceptedAt?: string;
|
|
2391
|
+
createdAt: string;
|
|
2392
|
+
updatedAt?: string;
|
|
2393
|
+
isCurrentUser?: boolean;
|
|
2394
|
+
providerId?: string;
|
|
2395
|
+
}
|
|
2396
|
+
/**
|
|
2397
|
+
* @public
|
|
2398
|
+
*/
|
|
2399
|
+
interface GetUsersOptions extends ProjectHandle {
|
|
2400
|
+
resourceType?: 'organization' | 'project';
|
|
2401
|
+
batchSize?: number;
|
|
2402
|
+
organizationId?: string;
|
|
2403
|
+
userId?: string;
|
|
2404
|
+
}
|
|
2405
|
+
/**
|
|
2406
|
+
* @public
|
|
2407
|
+
*/
|
|
2408
|
+
interface UsersGroupState {
|
|
2409
|
+
subscriptions: string[];
|
|
2410
|
+
totalCount?: number;
|
|
2411
|
+
nextCursor?: string | null;
|
|
2412
|
+
lastLoadMoreRequest?: string;
|
|
2413
|
+
users?: SanityUser[];
|
|
2414
|
+
error?: unknown;
|
|
2415
|
+
}
|
|
2416
|
+
/**
|
|
2417
|
+
* @public
|
|
2418
|
+
*/
|
|
2419
|
+
interface SanityUserResponse {
|
|
2420
|
+
data: SanityUser[];
|
|
2421
|
+
totalCount: number;
|
|
2422
|
+
nextCursor: string | null;
|
|
2423
|
+
}
|
|
2424
|
+
/**
|
|
2425
|
+
* @public
|
|
2426
|
+
*/
|
|
2427
|
+
interface UsersStoreState {
|
|
2428
|
+
users: { [TUsersKey in string]?: UsersGroupState; };
|
|
2429
|
+
error?: unknown;
|
|
2430
|
+
}
|
|
2431
|
+
/**
|
|
2432
|
+
* @public
|
|
2433
|
+
*/
|
|
2434
|
+
interface ResolveUsersOptions extends GetUsersOptions {
|
|
2435
|
+
signal?: AbortSignal;
|
|
2436
|
+
}
|
|
2437
|
+
/**
|
|
2438
|
+
* @public
|
|
2439
|
+
*/
|
|
2440
|
+
interface GetUserOptions extends ProjectHandle {
|
|
2441
|
+
userId: string;
|
|
2442
|
+
resourceType?: 'organization' | 'project';
|
|
2443
|
+
organizationId?: string;
|
|
2444
|
+
}
|
|
2445
|
+
/**
|
|
2446
|
+
* @public
|
|
2447
|
+
*/
|
|
2448
|
+
interface ResolveUserOptions extends GetUserOptions {
|
|
2449
|
+
signal?: AbortSignal;
|
|
2450
|
+
}
|
|
2451
|
+
/**
|
|
2452
|
+
* One end of a text selection: a Portable Text path plus a character offset
|
|
2453
|
+
* within the span it addresses.
|
|
2454
|
+
* @public
|
|
2455
|
+
*/
|
|
2456
|
+
interface PresenceSelectionPoint {
|
|
2457
|
+
path: Path;
|
|
2458
|
+
offset: number;
|
|
2459
|
+
}
|
|
2460
|
+
/**
|
|
2461
|
+
* A Portable Text caret or selected range, as exchanged with the Studio.
|
|
2462
|
+
*
|
|
2463
|
+
* Structurally identical to `EditorSelection` from `@portabletext/editor`, and
|
|
2464
|
+
* declared separately so that `@sanity/sdk` stays free of React dependencies. A
|
|
2465
|
+
* value from the editor can be passed straight through, and vice versa.
|
|
2466
|
+
*
|
|
2467
|
+
* `offset` is a character offset within the span that `path` addresses.
|
|
2468
|
+
* @public
|
|
2469
|
+
*/
|
|
2470
|
+
type PresenceSelection = {
|
|
2471
|
+
anchor: PresenceSelectionPoint;
|
|
2472
|
+
focus: PresenceSelectionPoint;
|
|
2473
|
+
backward?: boolean;
|
|
2474
|
+
} | null;
|
|
2475
|
+
/**
|
|
2476
|
+
* Somewhere a participant is, as it arrives over the wire.
|
|
2477
|
+
*
|
|
2478
|
+
* Prefer {@link DocumentPresence} from `getDocumentPresence`, which is scoped to one
|
|
2479
|
+
* document, flattened for rendering, and types `path` accurately.
|
|
2480
|
+
* @public
|
|
2481
|
+
*/
|
|
2482
|
+
interface PresenceLocation {
|
|
2483
|
+
type: 'document';
|
|
2484
|
+
/**
|
|
2485
|
+
* The specific document the participant is in, so a draft, published, or version
|
|
2486
|
+
* id rather than a bare document id.
|
|
2487
|
+
*/
|
|
2488
|
+
documentId: string;
|
|
2489
|
+
/**
|
|
2490
|
+
* The focused field path, empty when they are in the document but not a field.
|
|
2491
|
+
*
|
|
2492
|
+
* Declared as `string[]`, but segments can also be numbers or `{_key: string}`
|
|
2493
|
+
* objects when the focus is inside an array or a Portable Text field, because
|
|
2494
|
+
* that is what other clients send. Guard for those rather than assuming strings.
|
|
2495
|
+
* Widening the declared type is a breaking change, so it waits for the next major;
|
|
2496
|
+
* {@link DocumentPresence.path} is typed correctly today.
|
|
2497
|
+
*/
|
|
2498
|
+
path: string[];
|
|
2499
|
+
/**
|
|
2500
|
+
* When the participant said they were last active, on *their* clock.
|
|
2501
|
+
*
|
|
2502
|
+
* Fine for display, unreliable for deciding whether someone is still here: it is
|
|
2503
|
+
* subject to clock skew between machines. Presence already drops participants that
|
|
2504
|
+
* stop announcing, so a session appearing here is one the SDK still considers
|
|
2505
|
+
* live.
|
|
2506
|
+
*/
|
|
2507
|
+
lastActiveAt: string;
|
|
2508
|
+
/** A Portable Text caret, when the focused field is a Portable Text field. */
|
|
2509
|
+
selection?: PresenceSelection;
|
|
2510
|
+
}
|
|
2511
|
+
/**
|
|
2512
|
+
* Which specific document a presence id resolves to.
|
|
2513
|
+
*
|
|
2514
|
+
* Presence compares exact document ids, so a client in a draft and a client in the
|
|
2515
|
+
* published document are in different places even for the same `documentId`. Pass
|
|
2516
|
+
* the perspective you are editing under and the SDK resolves it; the React hooks
|
|
2517
|
+
* take it from `ResourceProvider` when you do not pass one.
|
|
2518
|
+
* @public
|
|
2519
|
+
*/
|
|
2520
|
+
interface PresencePerspectiveOptions extends PerspectiveHandle {
|
|
2521
|
+
/** Live-edit documents have no draft, so presence resolves to the published id. */
|
|
2522
|
+
liveEdit?: boolean;
|
|
2523
|
+
}
|
|
2524
|
+
/**
|
|
2525
|
+
* What an app reports about where the current user is.
|
|
2526
|
+
*
|
|
2527
|
+
* Omit `path` for document-level presence, or pass one for field-level presence.
|
|
2528
|
+
* @public
|
|
2529
|
+
*/
|
|
2530
|
+
interface ReportPresenceOptions extends PresencePerspectiveOptions {
|
|
2531
|
+
/**
|
|
2532
|
+
* The document the user is in.
|
|
2533
|
+
*
|
|
2534
|
+
* Pass the plain document id; the perspective decides which specific document that
|
|
2535
|
+
* resolves to. An already-specific id is accepted and re-resolved, so passing
|
|
2536
|
+
* `drafts.abc` while the perspective is `published` reports the published document.
|
|
2537
|
+
*/
|
|
2538
|
+
documentId: string;
|
|
2539
|
+
/**
|
|
2540
|
+
* The focused field path. Supports keyed and numeric segments, so array items
|
|
2541
|
+
* and Portable Text spans can be addressed.
|
|
2542
|
+
*/
|
|
2543
|
+
path?: Path;
|
|
2544
|
+
/** A Portable Text caret, when the focused field is a Portable Text field. */
|
|
2545
|
+
selection?: PresenceSelection;
|
|
2546
|
+
}
|
|
2547
|
+
/**
|
|
2548
|
+
* One participant's session and everywhere it currently is.
|
|
2549
|
+
*
|
|
2550
|
+
* Keyed by session, not by user: the same person in two tabs is two entries with
|
|
2551
|
+
* the same `user`.
|
|
2552
|
+
* @public
|
|
2553
|
+
*/
|
|
2554
|
+
interface UserPresence {
|
|
2555
|
+
user: SanityUser;
|
|
2556
|
+
locations: PresenceLocation[];
|
|
2557
|
+
/** Identifies one tab. Stable while that tab is open, and not reused. */
|
|
2558
|
+
sessionId: string;
|
|
2559
|
+
}
|
|
2560
|
+
/**
|
|
2561
|
+
* One participant at one location within a single document, flattened so it can
|
|
2562
|
+
* be rendered directly against a field.
|
|
2563
|
+
*
|
|
2564
|
+
* Unlike {@link PresenceLocation.path}, `path` here is typed as a full `Path`, so
|
|
2565
|
+
* keyed and numeric segments are described rather than cast away.
|
|
2566
|
+
* @beta
|
|
2567
|
+
*/
|
|
2568
|
+
interface DocumentPresence {
|
|
2569
|
+
user: SanityUser;
|
|
2570
|
+
/** Identifies one tab, so the same person in two tabs appears twice. */
|
|
2571
|
+
sessionId: string;
|
|
2572
|
+
/**
|
|
2573
|
+
* The specific document id this participant is in: a draft, published, or
|
|
2574
|
+
* version id, depending on which perspective they are editing.
|
|
2575
|
+
*/
|
|
2576
|
+
documentId: string;
|
|
2577
|
+
/** The focused field path. Empty when they are in the document but no field. */
|
|
2578
|
+
path: Path;
|
|
2579
|
+
/**
|
|
2580
|
+
* When they said they were last active, on *their* clock. Fine for display,
|
|
2581
|
+
* unreliable for liveness. See {@link PresenceLocation.lastActiveAt}.
|
|
2582
|
+
*/
|
|
2583
|
+
lastActiveAt: string;
|
|
2584
|
+
/** The Portable Text caret, when they are focused in a Portable Text field. */
|
|
2585
|
+
selection?: PresenceSelection;
|
|
2586
|
+
}
|
|
2587
|
+
/** @beta */
|
|
2588
|
+
interface DocumentPresenceOptions extends PresencePerspectiveOptions {
|
|
2589
|
+
/**
|
|
2590
|
+
* The document to look at. Resolved through the perspective exactly as
|
|
2591
|
+
* {@link ReportPresenceOptions.documentId} is, so reads match writes.
|
|
2592
|
+
*/
|
|
2593
|
+
documentId: string;
|
|
2594
|
+
/**
|
|
2595
|
+
* Narrows to participants at or below this field path. Omit it for everyone in
|
|
2596
|
+
* the document.
|
|
2597
|
+
*/
|
|
2598
|
+
path?: Path;
|
|
2599
|
+
/**
|
|
2600
|
+
* By default a draft, its published version, and any release versions are
|
|
2601
|
+
* treated as the same document, which is what document lists want. Set this to
|
|
2602
|
+
* compare ids exactly, which is what field-level indicators want so that a
|
|
2603
|
+
* draft and a release version do not bleed into each other.
|
|
2604
|
+
*/
|
|
2605
|
+
excludeVersions?: boolean;
|
|
2606
|
+
}
|
|
2607
|
+
/** @public */
|
|
2608
|
+
type TransportEvent = RollCallEvent | StateEvent | DisconnectEvent;
|
|
2609
|
+
/** @public */
|
|
2610
|
+
interface RollCallEvent {
|
|
2611
|
+
type: 'rollCall';
|
|
2612
|
+
userId: string;
|
|
2613
|
+
sessionId: string;
|
|
2614
|
+
}
|
|
2615
|
+
/** @public */
|
|
2616
|
+
interface StateEvent {
|
|
2617
|
+
type: 'state';
|
|
2618
|
+
userId: string;
|
|
2619
|
+
sessionId: string;
|
|
2620
|
+
timestamp: string;
|
|
2621
|
+
locations: PresenceLocation[];
|
|
2622
|
+
}
|
|
2623
|
+
/** @public */
|
|
2624
|
+
interface DisconnectEvent {
|
|
2625
|
+
type: 'disconnect';
|
|
2626
|
+
userId: string;
|
|
2627
|
+
sessionId: string;
|
|
2628
|
+
timestamp: string;
|
|
2629
|
+
}
|
|
2630
|
+
/** @beta */
|
|
2631
|
+
declare function getPresence(instance: SanityInstance, params?: {
|
|
2632
|
+
resource?: DocumentResource;
|
|
2633
|
+
}): StateSource<UserPresence[]>;
|
|
2634
|
+
/**
|
|
2635
|
+
* Presence within a single document, flattened to one entry per participant per
|
|
2636
|
+
* location so it can be rendered directly against a field.
|
|
2637
|
+
*
|
|
2638
|
+
* Reading presence never announces anything. Use `reportPresence` to make the
|
|
2639
|
+
* current user visible to others.
|
|
2640
|
+
*
|
|
2641
|
+
* @param instance - the Sanity instance
|
|
2642
|
+
* @param params - the document to look at, its perspective, an optional `path` to
|
|
2643
|
+
* narrow to a field subtree, and `excludeVersions` to compare document ids exactly
|
|
2644
|
+
*
|
|
2645
|
+
* @beta
|
|
2646
|
+
*/
|
|
2647
|
+
declare function getDocumentPresence(instance: SanityInstance, params: {
|
|
2648
|
+
resource?: DocumentResource;
|
|
2649
|
+
} & DocumentPresenceOptions): StateSource<DocumentPresence[]>;
|
|
2650
|
+
/**
|
|
2651
|
+
* Announces where the current user is, so other clients in the same project and
|
|
2652
|
+
* dataset can show them. Reading presence never announces anything, so this is
|
|
2653
|
+
* the only way an app becomes visible to others.
|
|
2654
|
+
*
|
|
2655
|
+
* Call it again whenever the user moves. Announcements are collapsed over a short
|
|
2656
|
+
* window and then repeated every 30 seconds while idle, which is what tells peers
|
|
2657
|
+
* the session is still alive.
|
|
2658
|
+
*
|
|
2659
|
+
* Which specific document each location resolves to depends on its perspective, and
|
|
2660
|
+
* that matters for interoperability: other clients, the Studio included, compare
|
|
2661
|
+
* exact document ids for field-level presence. Pass the perspective you are editing
|
|
2662
|
+
* under rather than building a draft or version id yourself.
|
|
2663
|
+
*
|
|
2664
|
+
* @param instance - the Sanity instance
|
|
2665
|
+
* @param params - the resource to announce on, plus the locations to report.
|
|
2666
|
+
* Pass one location with a `documentId` for document-level presence, add a
|
|
2667
|
+
* `path` for field-level presence, and pass an empty array to appear present
|
|
2668
|
+
* without being in any document.
|
|
2669
|
+
*
|
|
2670
|
+
* @beta
|
|
2671
|
+
*/
|
|
2672
|
+
declare function reportPresence(instance: SanityInstance, params: {
|
|
2673
|
+
resource?: DocumentResource;
|
|
2674
|
+
locations: ReportPresenceOptions[];
|
|
2675
|
+
}): void;
|
|
2676
|
+
/**
|
|
2677
|
+
* @public
|
|
2678
|
+
* The result of a projection query
|
|
2679
|
+
*/
|
|
2680
|
+
interface ProjectionValuePending<TValue extends object> {
|
|
2681
|
+
data: TValue | null;
|
|
2682
|
+
isPending: boolean;
|
|
2683
|
+
}
|
|
2684
|
+
interface DocumentStatus {
|
|
2685
|
+
lastEditedDraftAt?: string;
|
|
2686
|
+
lastEditedPublishedAt?: string;
|
|
2687
|
+
lastEditedVersionAt?: string;
|
|
2688
|
+
}
|
|
2689
|
+
/**
|
|
2690
|
+
*
|
|
2691
|
+
* @internal
|
|
2692
|
+
*/
|
|
2693
|
+
interface PreviewQueryResult {
|
|
2694
|
+
_id: string;
|
|
2695
|
+
_type: string;
|
|
2696
|
+
_updatedAt: string;
|
|
2697
|
+
titleCandidates: Record<string, unknown>;
|
|
2698
|
+
subtitleCandidates: Record<string, unknown>;
|
|
2699
|
+
media?: PreviewMedia | null;
|
|
2700
|
+
_status?: DocumentStatus;
|
|
2701
|
+
}
|
|
2702
|
+
/**
|
|
2703
|
+
* Represents a media asset in a preview.
|
|
2704
|
+
*
|
|
2705
|
+
* @public
|
|
2706
|
+
*/
|
|
2707
|
+
interface PreviewMedia {
|
|
2708
|
+
type: 'image-asset';
|
|
2709
|
+
_ref: string;
|
|
2710
|
+
url: string;
|
|
2711
|
+
}
|
|
2712
|
+
/**
|
|
2713
|
+
* Represents the set of values displayed as a preview for a given Sanity document.
|
|
2714
|
+
* This includes a primary title, a secondary subtitle, an optional piece of media associated
|
|
2715
|
+
* with the document, and the document's status.
|
|
2716
|
+
*
|
|
2717
|
+
* @public
|
|
2718
|
+
*/
|
|
2719
|
+
interface PreviewValue {
|
|
2720
|
+
/**
|
|
2721
|
+
* The primary text displayed for the document preview.
|
|
2722
|
+
*/
|
|
2723
|
+
title: string;
|
|
2724
|
+
/**
|
|
2725
|
+
* A secondary line of text providing additional context about the document.
|
|
2726
|
+
*/
|
|
2727
|
+
subtitle?: string;
|
|
2728
|
+
/**
|
|
2729
|
+
* An optional piece of media representing the document within its preview.
|
|
2730
|
+
* Currently, only image assets are available.
|
|
2731
|
+
*/
|
|
2732
|
+
media?: PreviewMedia | null;
|
|
2733
|
+
/**
|
|
2734
|
+
* The status of the document.
|
|
2735
|
+
*/
|
|
2736
|
+
_status?: {
|
|
2737
|
+
/** The date of the last published edit */
|
|
2738
|
+
lastEditedPublishedAt?: string;
|
|
2739
|
+
/** The date of the last draft edit */
|
|
2740
|
+
lastEditedDraftAt?: string;
|
|
2741
|
+
};
|
|
2742
|
+
}
|
|
2743
|
+
/** @public */
|
|
2744
|
+
interface ProjectMemberRole {
|
|
2745
|
+
name: string;
|
|
2746
|
+
title: string;
|
|
2747
|
+
description: string;
|
|
2748
|
+
}
|
|
2749
|
+
/** @public */
|
|
2750
|
+
interface ProjectMember {
|
|
2751
|
+
id: string;
|
|
2752
|
+
createdAt: string;
|
|
2753
|
+
updatedAt: string;
|
|
2754
|
+
isCurrentUser: boolean;
|
|
2755
|
+
isRobot: boolean;
|
|
2756
|
+
roles: ProjectMemberRole[];
|
|
2757
|
+
}
|
|
2758
|
+
/** @public */
|
|
2759
|
+
interface ProjectMetadata {
|
|
2760
|
+
color?: string;
|
|
2761
|
+
externalStudioHost?: string;
|
|
2762
|
+
initialTemplate?: string;
|
|
2763
|
+
cliInitializedAt?: string;
|
|
2764
|
+
integration: 'manage' | 'cli';
|
|
2765
|
+
}
|
|
2766
|
+
/**
|
|
2767
|
+
* The base fields returned from `/projects` for every project.
|
|
2768
|
+
* @public
|
|
2769
|
+
*/
|
|
2770
|
+
interface ProjectBase {
|
|
2771
|
+
id: string;
|
|
2772
|
+
displayName: string;
|
|
2773
|
+
studioHost: string | null;
|
|
2774
|
+
organizationId: string;
|
|
2775
|
+
metadata: ProjectMetadata;
|
|
2776
|
+
isBlocked: boolean;
|
|
2777
|
+
isDisabled: boolean;
|
|
2778
|
+
isDisabledByUser: boolean;
|
|
2779
|
+
activityFeedEnabled: boolean;
|
|
2780
|
+
createdAt: string;
|
|
2781
|
+
updatedAt: string;
|
|
2782
|
+
}
|
|
2783
|
+
/**
|
|
2784
|
+
* A `Project` with `members` and/or `features` conditionally included
|
|
2785
|
+
* based on the query options used to fetch it.
|
|
2786
|
+
* @public
|
|
2787
|
+
*/
|
|
2788
|
+
type Project<IncludeMembers extends boolean = true, IncludeFeatures extends boolean = true> = ProjectBase & (boolean extends IncludeMembers ? {
|
|
2789
|
+
members?: ProjectMember[];
|
|
2790
|
+
} : IncludeMembers extends true ? {
|
|
2791
|
+
members: ProjectMember[];
|
|
2792
|
+
} : unknown) & (boolean extends IncludeFeatures ? {
|
|
2793
|
+
features?: string[];
|
|
2794
|
+
} : IncludeFeatures extends true ? {
|
|
2795
|
+
features: string[];
|
|
2796
|
+
} : unknown);
|
|
2797
|
+
/** @public */
|
|
2798
|
+
interface ProjectOptions<IncludeMembers extends boolean = true, IncludeFeatures extends boolean = true> extends ProjectHandle {
|
|
2799
|
+
includeMembers?: IncludeMembers;
|
|
2800
|
+
includeFeatures?: IncludeFeatures;
|
|
2801
|
+
}
|
|
2802
|
+
/**
|
|
2803
|
+
* Fetcher for a single project (`GET /projects/:id`), on the shared fetcher
|
|
2804
|
+
* cache. Pre-seeds from the default {@link projects} list entry when it can
|
|
2805
|
+
* satisfy the read — the default list carries features but not members, so
|
|
2806
|
+
* only `includeMembers: false` reads seed.
|
|
2807
|
+
*
|
|
2808
|
+
* @internal
|
|
2809
|
+
*/
|
|
2810
|
+
declare const project: Fetcher<[options?: ProjectOptions<boolean, boolean> | undefined], Project<boolean, boolean>>;
|
|
2811
|
+
interface ProjectionOptions<TProjection extends string = string, TDocumentType extends string = string, TDataset extends string = string, TProjectId extends string = string> extends DocumentHandle<TDocumentType, TDataset, TProjectId> {
|
|
2812
|
+
projection: TProjection;
|
|
2813
|
+
}
|
|
2814
|
+
/**
|
|
2815
|
+
* @beta
|
|
2816
|
+
*/
|
|
2817
|
+
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>;
|
|
2818
|
+
/**
|
|
2819
|
+
* @beta
|
|
2820
|
+
*/
|
|
2821
|
+
declare function getProjectionState<TData extends object>(instance: SanityInstance, options: ProjectionOptions): StateSource<ProjectionValuePending<TData> | undefined>;
|
|
2822
|
+
/**
|
|
2823
|
+
* @beta
|
|
2824
|
+
*/
|
|
2825
|
+
declare function getProjectionState(instance: SanityInstance, options: ProjectionOptions): StateSource<ProjectionValuePending<Record<string, unknown>> | undefined>;
|
|
2826
|
+
/** @beta */
|
|
2827
|
+
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}`>>>;
|
|
2828
|
+
/** @beta */
|
|
2829
|
+
declare function resolveProjection<TData extends object>(instance: SanityInstance, options: ProjectionOptions): Promise<ProjectionValuePending<TData>>;
|
|
2830
|
+
/** @public */
|
|
2831
|
+
interface ProjectsOptions<IncludeMembers extends boolean = false, IncludeFeatures extends boolean = true> {
|
|
2832
|
+
organizationId?: string;
|
|
2833
|
+
includeMembers?: IncludeMembers;
|
|
2834
|
+
includeFeatures?: IncludeFeatures;
|
|
2835
|
+
onlyExplicitMembership?: boolean;
|
|
2836
|
+
}
|
|
2837
|
+
/**
|
|
2838
|
+
* Fetcher for the current user's projects (`GET /projects`), on the shared
|
|
2839
|
+
* fetcher cache.
|
|
2840
|
+
*
|
|
2841
|
+
* @internal
|
|
2842
|
+
*/
|
|
2843
|
+
declare const projects: Fetcher<[options?: ProjectsOptions<boolean, boolean> | undefined], Project<boolean, boolean>[]>;
|
|
2844
|
+
/**
|
|
2845
|
+
* @beta
|
|
2846
|
+
*/
|
|
2847
|
+
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> {
|
|
2848
|
+
query: TQuery;
|
|
2849
|
+
params?: Record<string, unknown>;
|
|
2850
|
+
}
|
|
2851
|
+
/**
|
|
2852
|
+
* @beta
|
|
2853
|
+
*/
|
|
2854
|
+
interface ResolveQueryOptions<TQuery extends string = string, TDataset extends string = string, TProjectId extends string = string> extends QueryOptions<TQuery, TDataset, TProjectId> {
|
|
2855
|
+
signal?: AbortSignal;
|
|
2856
|
+
}
|
|
2857
|
+
/** @internal */
|
|
2858
|
+
declare const getQueryKey: (instance: SanityInstance, options: QueryOptions) => string;
|
|
2859
|
+
/** @internal */
|
|
2860
|
+
declare const parseQueryKey: (key: string) => QueryOptions;
|
|
2861
|
+
/**
|
|
2862
|
+
* Returns the state source for a query.
|
|
2863
|
+
*
|
|
2864
|
+
* This function returns a state source that represents the current result of a GROQ query.
|
|
2865
|
+
* Subscribing to the state source will instruct the SDK to fetch the query (if not already fetched)
|
|
2866
|
+
* and will keep the query live using the Live content API (considering sync tags) to provide up-to-date results.
|
|
2867
|
+
* When the last subscriber is removed, the query state is automatically cleaned up from the store.
|
|
2868
|
+
*
|
|
2869
|
+
* Note: This functionality is for advanced users who want to build their own framework integrations.
|
|
2870
|
+
* Our SDK also provides a React integration (useQuery hook) for convenient usage.
|
|
2871
|
+
*
|
|
2872
|
+
* Note: Automatic cleanup can interfere with React Suspense because if a component suspends while being the only subscriber,
|
|
2873
|
+
* cleanup might occur unexpectedly. In such cases, consider using `resolveQuery` instead.
|
|
2874
|
+
*
|
|
2875
|
+
* @beta
|
|
2876
|
+
*/
|
|
2877
|
+
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>;
|
|
2878
|
+
/** @beta */
|
|
2879
|
+
declare function getQueryState<TData>(instance: SanityInstance, queryOptions: QueryOptions): StateSource<TData | undefined>;
|
|
2880
|
+
/** @beta */
|
|
2881
|
+
declare function getQueryState(instance: SanityInstance, queryOptions: QueryOptions): StateSource<unknown>;
|
|
2882
|
+
/**
|
|
2883
|
+
* Resolves the result of a query without registering a lasting subscriber.
|
|
2884
|
+
*
|
|
2885
|
+
* This function fetches the result of a GROQ query and returns a promise that resolves with the query result.
|
|
2886
|
+
* It registers a temporary subscriber for the lifetime of the resolution (released shortly after the promise
|
|
2887
|
+
* settles), so the query state participates in normal cleanup even when no lasting subscriber ever attaches —
|
|
2888
|
+
* e.g. when a suspended component errors before committing. This makes it ideal for use with React Suspense,
|
|
2889
|
+
* where the returned promise is thrown to delay rendering until the query result becomes available.
|
|
2890
|
+
* Once the promise resolves, it is expected that a real subscriber will be added via `getQueryState` to manage ongoing updates.
|
|
2891
|
+
*
|
|
2892
|
+
* Additionally, an optional AbortSignal can be provided to cancel the query and immediately clear the associated state
|
|
2893
|
+
* if there are no other active subscribers.
|
|
2894
|
+
*
|
|
2895
|
+
* @beta
|
|
2896
|
+
*/
|
|
2897
|
+
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}`>>;
|
|
2898
|
+
/** @beta */
|
|
2899
|
+
declare function resolveQuery<TData>(instance: SanityInstance, queryOptions: ResolveQueryOptions): Promise<TData>;
|
|
2900
|
+
/**
|
|
2901
|
+
* Lifecycle states a release document can be in. Mirrors the server's
|
|
2902
|
+
* `ReleaseState`.
|
|
2903
|
+
* @beta
|
|
2904
|
+
*/
|
|
2905
|
+
type ReleaseState = 'active' | 'archiving' | 'unarchiving' | 'archived' | 'published' | 'publishing' | 'scheduled' | 'scheduling';
|
|
2906
|
+
interface ReleasesStoreState {
|
|
2907
|
+
activeReleases?: ReleaseDocument[];
|
|
2908
|
+
allReleases?: ReleaseDocument[];
|
|
2909
|
+
error?: unknown;
|
|
2910
|
+
}
|
|
2911
|
+
/**
|
|
2912
|
+
* Get the active releases from the store.
|
|
2913
|
+
* @internal
|
|
2914
|
+
*/
|
|
2915
|
+
declare const getActiveReleasesState: (instance: SanityInstance, options?: {
|
|
2916
|
+
resource?: DocumentResource;
|
|
2917
|
+
}) => StateSource<ReleaseDocument[] | undefined>;
|
|
2918
|
+
/**
|
|
2919
|
+
* Get every release in the store, including archived and published.
|
|
2920
|
+
* @internal
|
|
2921
|
+
*/
|
|
2922
|
+
declare const getAllReleasesState: (instance: SanityInstance, options?: {
|
|
2923
|
+
resource?: DocumentResource;
|
|
2924
|
+
}) => StateSource<ReleaseDocument[] | undefined>;
|
|
2925
|
+
declare const _getPerspectiveStateSelector: StoreAction<ReleasesStoreState, [_?: (PerspectiveHandle & {
|
|
2926
|
+
projectId?: string;
|
|
2927
|
+
dataset?: string;
|
|
2928
|
+
resource?: DocumentResource;
|
|
2929
|
+
}) | undefined], StateSource<string[] | "previewDrafts" | "published" | "drafts" | "raw" | undefined>, unknown>;
|
|
2930
|
+
type OmitFirst<T extends unknown[]> = T extends [unknown, ...infer R] ? R : never;
|
|
2931
|
+
type SelectorParams = OmitFirst<Parameters<typeof _getPerspectiveStateSelector>>;
|
|
2932
|
+
type BoundGetPerspectiveState = BoundStoreAction<ReleasesStoreState, SelectorParams, ReturnType<typeof _getPerspectiveStateSelector>>;
|
|
2933
|
+
/**
|
|
2934
|
+
* Provides a subscribable state source for a "perspective" for the Sanity client,
|
|
2935
|
+
* which is used to fetch documents as though certain Content Releases are active.
|
|
2936
|
+
*
|
|
2937
|
+
* @param instance - The Sanity instance to get the perspective for
|
|
2938
|
+
* @param options - The options for the perspective -- usually a release name
|
|
2939
|
+
*
|
|
2940
|
+
* @returns A subscribable perspective value, usually a list of applicable release names,
|
|
2941
|
+
* or a single release name / default perspective (such as 'drafts').
|
|
2942
|
+
*
|
|
2943
|
+
* @public
|
|
2944
|
+
*/
|
|
2945
|
+
declare const getPerspectiveState: BoundGetPerspectiveState;
|
|
2946
|
+
/**
|
|
2947
|
+
* Returns the state source for users associated with a specific resource.
|
|
2948
|
+
*
|
|
2949
|
+
* This function returns a state source that represents the current list of users for a given
|
|
2950
|
+
* resource. Subscribing to the state source will instruct the SDK to fetch the users (if not
|
|
2951
|
+
* already fetched) and will load more from this state source as well. When the last subscriber is
|
|
2952
|
+
* removed, the users state is automatically cleaned up from the store after a delay.
|
|
2953
|
+
*
|
|
2954
|
+
* Note: This functionality is for advanced users who want to build their own framework
|
|
2955
|
+
* integrations. Our SDK also provides a React integration for convenient usage.
|
|
2956
|
+
*
|
|
2957
|
+
* @beta
|
|
2958
|
+
*/
|
|
2959
|
+
declare const getUsersState: BoundStoreAction<UsersStoreState, [options?: GetUsersOptions | undefined], StateSource<{
|
|
2960
|
+
data: SanityUser[];
|
|
2961
|
+
totalCount: number;
|
|
2962
|
+
hasMore: boolean;
|
|
2963
|
+
} | undefined>>;
|
|
2964
|
+
/**
|
|
2965
|
+
* Resolves the users for a specific resource without registering a lasting subscriber.
|
|
2966
|
+
*
|
|
2967
|
+
* This function fetches the users for a given resource and returns a promise that resolves with
|
|
2968
|
+
* the users result. Unlike `getUsersState`, which registers subscribers to keep the data live and
|
|
2969
|
+
* performs automatic cleanup, `resolveUsers` does not track subscribers. This makes it ideal for
|
|
2970
|
+
* use with React Suspense, where the returned promise is thrown to delay rendering until the users
|
|
2971
|
+
* result becomes available. Once the promise resolves, it is expected that a real subscriber will
|
|
2972
|
+
* be added via `getUsersState` to manage ongoing updates.
|
|
2973
|
+
*
|
|
2974
|
+
* Additionally, an optional AbortSignal can be provided to cancel the request and immediately
|
|
2975
|
+
* clear the associated state if there are no active subscribers.
|
|
2976
|
+
*
|
|
2977
|
+
* @beta
|
|
2978
|
+
*/
|
|
2979
|
+
declare const resolveUsers: BoundStoreAction<UsersStoreState, [ResolveUsersOptions], Promise<{
|
|
2980
|
+
data: SanityUser[];
|
|
2981
|
+
totalCount: number;
|
|
2982
|
+
hasMore: boolean;
|
|
2983
|
+
}>>;
|
|
2984
|
+
/**
|
|
2985
|
+
* Loads more users for a specific resource.
|
|
2986
|
+
*
|
|
2987
|
+
* This function triggers a request to fetch the next page of users for a given resource. It
|
|
2988
|
+
* requires that users have already been loaded for the resource (via `resolveUsers` or
|
|
2989
|
+
* `getUsersState`), and that there are more users available to load (as indicated by the `hasMore`
|
|
2990
|
+
* property).
|
|
2991
|
+
*
|
|
2992
|
+
* The function returns a promise that resolves when the next page of users has been loaded.
|
|
2993
|
+
*
|
|
2994
|
+
* @beta
|
|
2995
|
+
*/
|
|
2996
|
+
declare const loadMoreUsers: BoundStoreAction<UsersStoreState, [options?: GetUsersOptions | undefined], Promise<{
|
|
2997
|
+
data: SanityUser[];
|
|
2998
|
+
totalCount: number;
|
|
2999
|
+
hasMore: boolean;
|
|
3000
|
+
}>>;
|
|
3001
|
+
/**
|
|
3002
|
+
* @beta
|
|
3003
|
+
*/
|
|
3004
|
+
declare const getUserState: BoundStoreAction<UsersStoreState, [GetUserOptions], Observable<SanityUser | undefined>>;
|
|
3005
|
+
/**
|
|
3006
|
+
* @beta
|
|
3007
|
+
*/
|
|
3008
|
+
declare const resolveUser: BoundStoreAction<UsersStoreState, [ResolveUserOptions], Promise<SanityUser>>;
|
|
3009
|
+
interface StoreEntry<TParams extends unknown[], TData> {
|
|
3010
|
+
params: TParams;
|
|
3011
|
+
instance: SanityInstance;
|
|
3012
|
+
key: string;
|
|
3013
|
+
data?: TData;
|
|
3014
|
+
error?: unknown;
|
|
3015
|
+
subscriptions: string[];
|
|
3016
|
+
lastFetchInitiatedAt?: string;
|
|
3017
|
+
}
|
|
3018
|
+
/**
|
|
3019
|
+
* Internal helper type
|
|
3020
|
+
* @public
|
|
3021
|
+
*/
|
|
3022
|
+
interface FetcherStoreState<TParams extends unknown[], TData> {
|
|
3023
|
+
stateByParams: { [TSerializedKey in string]?: StoreEntry<TParams, TData>; };
|
|
3024
|
+
error?: unknown;
|
|
3025
|
+
}
|
|
3026
|
+
/**
|
|
3027
|
+
* Internal helper type
|
|
3028
|
+
* @public
|
|
3029
|
+
*/
|
|
3030
|
+
interface FetcherStore<TParams extends unknown[], TData> {
|
|
3031
|
+
getState: BoundStoreAction<FetcherStoreState<TParams, TData>, TParams, StateSource<TData | undefined>>;
|
|
3032
|
+
resolveState: BoundStoreAction<FetcherStoreState<TParams, TData>, TParams, Promise<TData>>;
|
|
3033
|
+
}
|
|
3034
|
+
/**
|
|
3035
|
+
* @public
|
|
3036
|
+
* Extracts the project ID from a CorsOriginError message.
|
|
3037
|
+
* @param error - The error to extract the project ID from.
|
|
3038
|
+
* @returns The project ID or null if the error is not a CorsOriginError.
|
|
3039
|
+
*/
|
|
3040
|
+
declare function getCorsErrorProjectId(error: Error): string | null;
|
|
3041
|
+
/**
|
|
3042
|
+
* Returns true when the given error looks like a dynamic-import or
|
|
3043
|
+
* code-split chunk-loading failure.
|
|
3044
|
+
*
|
|
3045
|
+
* These errors typically surface when a user has a tab open against a
|
|
3046
|
+
* previously-deployed version of an app and the JavaScript or CSS chunk
|
|
3047
|
+
* filenames have since changed: a fresh deployment removes the hashed assets
|
|
3048
|
+
* the open tab still references. Detecting them lets the SDK trigger an
|
|
3049
|
+
* automatic reload so the user gets the new build without manual intervention.
|
|
3050
|
+
*
|
|
3051
|
+
* Recognized shapes (webpack ChunkLoadError, Vite "Failed to fetch
|
|
3052
|
+
* dynamically imported module", Firefox "error loading dynamically imported
|
|
3053
|
+
* module", Safari "Importing a module script failed", and Vite "Unable to
|
|
3054
|
+
* preload CSS").
|
|
3055
|
+
*
|
|
3056
|
+
* @param error - The value to inspect. Anything that is not an Error
|
|
3057
|
+
* instance returns false.
|
|
3058
|
+
* @returns True if the error matches a known import/chunk-load failure.
|
|
3059
|
+
*
|
|
3060
|
+
* @public
|
|
3061
|
+
*/
|
|
3062
|
+
declare function isImportError(error: unknown): boolean;
|
|
3063
|
+
/**
|
|
3064
|
+
* This version is provided by pkg-utils at build time
|
|
3065
|
+
* @internal
|
|
3066
|
+
*/
|
|
3067
|
+
declare const CORE_SDK_VERSION: {};
|
|
3068
|
+
/**
|
|
3069
|
+
* @public
|
|
3070
|
+
*/
|
|
3071
|
+
type SanityProject$1 = SanityProject;
|
|
3072
|
+
/**
|
|
3073
|
+
* Represents the various states the authentication can be in.
|
|
3074
|
+
*
|
|
3075
|
+
* @public
|
|
3076
|
+
*/
|
|
3077
|
+
type AuthState = LoggedInAuthState | LoggedOutAuthState | LoggingInAuthState | ErrorAuthState;
|
|
3078
|
+
/**
|
|
3079
|
+
* Logged-in state from the auth state.
|
|
3080
|
+
* @public
|
|
3081
|
+
*/
|
|
3082
|
+
type LoggedInAuthState = {
|
|
3083
|
+
type: AuthStateType.LOGGED_IN;
|
|
3084
|
+
token: string;
|
|
3085
|
+
currentUser: CurrentUser | null;
|
|
3086
|
+
lastTokenRefresh?: number;
|
|
3087
|
+
};
|
|
3088
|
+
/**
|
|
3089
|
+
* Logged-out state from the auth state.
|
|
3090
|
+
* @public
|
|
3091
|
+
*/
|
|
3092
|
+
type LoggedOutAuthState = {
|
|
3093
|
+
type: AuthStateType.LOGGED_OUT;
|
|
3094
|
+
isDestroyingSession: boolean;
|
|
3095
|
+
};
|
|
3096
|
+
/**
|
|
3097
|
+
* Logging-in state from the auth state.
|
|
3098
|
+
* @public
|
|
3099
|
+
*/
|
|
3100
|
+
type LoggingInAuthState = {
|
|
3101
|
+
type: AuthStateType.LOGGING_IN;
|
|
3102
|
+
isExchangingToken: boolean;
|
|
3103
|
+
};
|
|
3104
|
+
/**
|
|
3105
|
+
* Error state from the auth state.
|
|
3106
|
+
* @public
|
|
3107
|
+
*/
|
|
3108
|
+
type ErrorAuthState = {
|
|
3109
|
+
type: AuthStateType.ERROR;
|
|
3110
|
+
error: unknown;
|
|
3111
|
+
};
|
|
3112
|
+
/**
|
|
3113
|
+
* Represents the various states the authentication can be in.
|
|
3114
|
+
*
|
|
3115
|
+
* @public
|
|
3116
|
+
*/
|
|
3117
|
+
interface DashboardContext {
|
|
3118
|
+
mode?: string;
|
|
3119
|
+
env?: string;
|
|
3120
|
+
orgId?: string;
|
|
3121
|
+
}
|
|
3122
|
+
/**
|
|
3123
|
+
* The method of authentication used.
|
|
3124
|
+
* @internal
|
|
3125
|
+
*/
|
|
3126
|
+
type AuthMethodOptions = 'localstorage' | 'cookie' | undefined;
|
|
3127
|
+
/**
|
|
3128
|
+
* @public
|
|
3129
|
+
*/
|
|
3130
|
+
interface AuthStoreState {
|
|
3131
|
+
authState: AuthState;
|
|
3132
|
+
providers?: AuthProvider[];
|
|
3133
|
+
options: {
|
|
3134
|
+
initialLocationHref: string;
|
|
3135
|
+
clientFactory: (config: ClientConfig) => SanityClient;
|
|
3136
|
+
customProviders: AuthConfig['providers'];
|
|
3137
|
+
storageKey: string;
|
|
3138
|
+
storageArea: Storage | undefined;
|
|
3139
|
+
apiHost: string | undefined;
|
|
3140
|
+
loginUrl: string;
|
|
3141
|
+
callbackUrl: string | undefined;
|
|
3142
|
+
providedToken: string | undefined;
|
|
3143
|
+
authMethod: AuthMethodOptions;
|
|
3144
|
+
};
|
|
3145
|
+
dashboardContext?: DashboardContext;
|
|
3146
|
+
}
|
|
3147
|
+
/**
|
|
3148
|
+
* @public
|
|
3149
|
+
*/
|
|
3150
|
+
declare const getCurrentUserState: BoundStoreAction<AuthStoreState, [], StateSource<CurrentUser | null>>;
|
|
3151
|
+
/**
|
|
3152
|
+
* @public
|
|
3153
|
+
*/
|
|
3154
|
+
declare const getTokenState: BoundStoreAction<AuthStoreState, [], StateSource<string | null>>;
|
|
3155
|
+
/**
|
|
3156
|
+
* @public
|
|
3157
|
+
*/
|
|
3158
|
+
declare const getLoginUrlState: BoundStoreAction<AuthStoreState, [], StateSource<string>>;
|
|
3159
|
+
/**
|
|
3160
|
+
* @public
|
|
3161
|
+
*/
|
|
3162
|
+
declare const getAuthState: BoundStoreAction<AuthStoreState, [], StateSource<AuthState>>;
|
|
3163
|
+
/**
|
|
3164
|
+
* @public
|
|
3165
|
+
*/
|
|
3166
|
+
declare const getDashboardOrganizationId: BoundStoreAction<AuthStoreState, [], StateSource<string | undefined>>;
|
|
3167
|
+
/**
|
|
3168
|
+
* Returns a state source indicating if the SDK is running within a dashboard context.
|
|
3169
|
+
* @public
|
|
3170
|
+
*/
|
|
3171
|
+
declare const getIsInDashboardState: BoundStoreAction<AuthStoreState, [], StateSource<boolean>>;
|
|
3172
|
+
/**
|
|
3173
|
+
* Action to explicitly set the authentication token.
|
|
3174
|
+
* Used internally by the Comlink token refresh.
|
|
3175
|
+
* @internal
|
|
3176
|
+
*/
|
|
3177
|
+
declare const setAuthToken: BoundStoreAction<AuthStoreState, [token: string | null], void>;
|
|
3178
|
+
export { ProjectOptions as $, unpublishDocument as $n, ApplicationInclude as $r, ApplyDocumentActionsOptions as $t, getUserState as A, DocumentAction as An, setCommentStatus as Ar, Organizations as At, getQueryKey as B, UnscheduleReleaseAction as Bn, ClientOptions as Br, InstallationActiveConfig as Bt, slicePath$1 as C, defineMutation as Ci, Action as Cn, RemoveCommentOptions as Cr, ResolveUserOptions as Ct, getCorsErrorProjectId as D, DeleteDocumentAction as Dn, createComment as Dr, UserProfile as Dt, isImportError as E, BoundStoreAction as Ei, CreateReleaseAction as En, UpdateCommentOptions as Er, SanityUserResponse as Et, getPerspectiveState as F, PublishReleaseAction as Fn, CommentReaction as Fr, OrganizationMember as Ft, projects as G, deleteRelease as Gn, handleAuthCallback as Gr, InstallationsResponse as Gt, parseQueryKey as H, createDocument as Hn, getClient as Hr, InstallationInclude as Ht, ReleaseState as I, ReleaseAction as In, CommentStatus as Ir, OrganizationOptions as It, Project as J, editRelease as Jn, AuthStateType as Jr, FavoriteStatusResponse as Jt, resolveProjection as K, discardDocument as Kn, observeOrganizationVerificationState as Kr, installation as Kt, getActiveReleasesState as L, ScheduleReleaseAction as Ln, CommentTextSelection as Lr, organization as Lt, loadMoreUsers as M, EditDocumentOptions as Mn, Comment as Mr, organizations as Mt, resolveUser as N, EditReleaseAction as Nn, CommentLocalState as Nr, Organization as Nt, FetcherStore as O, DeleteReleaseAction as On, removeComment as Or, UsersGroupState as Ot, resolveUsers as P, PublishDocumentAction as Pn, CommentMessage as Pr, OrganizationBase as Pt, ProjectMetadata as Q, unarchiveRelease as Qn, ApplicationDeployment as Qr, ActionsResult as Qt, getAllReleasesState as R, UnarchiveReleaseAction as Rn, CommentTextSelectionItem as Rr, Installation as Rt, jsonMatch$1 as S, defineFetcher as Si, JsonMatch as Sn, CreateCommentOptions as Sr, Membership as St, CORE_SDK_VERSION as T, StateSource as Ti, CreateDocumentAction as Tn, SetCommentStatusOptions as Tr, SanityUser as Tt, resolveQuery as U, createRelease as Un, getClientState as Ur, InstallationInterface as Ut, getQueryState as V, archiveRelease as Vn, ClientStoreState as Vr, InstallationBase as Vt, ProjectsOptions as W, deleteDocument as Wn, logout as Wr, InstallationsOptions as Wt, ProjectMember as X, publishRelease as Xn, ApplicationAccess as Xr, resolveFavoritesState as Xt, ProjectBase as Y, publishDocument as Yn, Application as Yr, getFavoritesState as Yt, ProjectMemberRole as Z, scheduleRelease as Zn, ApplicationBase as Zr, getReleaseDocumentId as Zt, SanityDocument$3 as _, Fetcher as _i, resolveDocument as _n, getCommentsOptionsKey as _r, StateEvent as _t, LoggedOutAuthState as a, ApplicationsResponse as ai, DocumentEditedEvent as an, LogContext as ar, getDocumentPresence as at, getPathDepth as b, MutationDefinition as bi, DocumentPermissionsResult as bn, resolveCommentThreads as br, GetUserOptions as bt, getCurrentUserState as c, UpdateApplicationInput as ci, DocumentRemotePatchesEvent as cn, Logger as cr, DisconnectEvent as ct, getLoginUrlState as d, deleteApplication as di, TransactionAcceptedEvent as dn, createDocumentHandle as dr, PresenceLocation as dt, ApplicationInterface as ei, applyDocumentActions as en, unscheduleRelease as er, project as et, getTokenState as f, updateApplication as fi, TransactionRevertedEvent as fn, createDocumentTypeHandle as fr, PresencePerspectiveOptions as ft, Role as g, CacheWriter as gi, getPermissionsState as gn, getCommentThreadsState as gr, RollCallEvent as gt, ReleaseDocument$1 as h, CacheTag as hi, getDocumentSyncStatus as hn, ResolveCommentsOptions as hr, ReportPresenceOptions as ht, LoggedInAuthState as i, ApplicationsOptions as ii, DocumentDiscardedEvent as in, InstanceContext as ir, ProjectionValuePending as it, getUsersState as j, EditDocumentAction as jn, updateComment as jr, OrganizationsOptions as jt, FetcherStoreState as k, DiscardDocumentAction as kn, replyToComment as kr, UsersStoreState as kt, getDashboardOrganizationId as l, application as li, DocumentTransactionSubmissionResult as ln, LoggerConfig as lr, DocumentPresence as lt, CurrentUser$1 as m, checkPermissions as mi, getDocumentState as mn, CommentsOptions as mr, PresenceSelectionPoint as mt, AuthStoreState as n, ApplicationVisibility as ni, DocumentCreatedEvent as nn, resolveDatasets as nr, PreviewQueryResult as nt, LoggingInAuthState as o, DeleteApplicationInput as oi, DocumentEvent as on, LogLevel as or, getPresence as ot, setAuthToken as p, AccessResourceType as pi, DocumentOptions as pn, createProjectHandle as pr, PresenceSelection as pt, getProjectionState as q, editDocument as qn, OrgVerificationResult as qr, installations as qt, ErrorAuthState as r, ApplicationWorkspace as ri, DocumentDeletedEvent as rn, configureLogging as rr, PreviewValue as rt, getAuthState as s, DeletedResult as si, DocumentPublishedEvent as sn, LogNamespace as sr, reportPresence as st, AuthState as t, ApplicationStudioConfig as ti, ActionErrorEvent as tn, getDatasetsState as tr, PreviewMedia as tt, getIsInDashboardState as u, applications as ui, DocumentUnpublishedEvent as un, createDatasetHandle as ur, DocumentPresenceOptions as ut, SanityProject$1 as v, FetcherDefinition as vi, resolvePermissions as vn, getCommentsState as vr, TransportEvent as vt, stringifyPath$1 as w, Selector as wi, ArchiveReleaseAction as wn, ReplyToCommentOptions as wr, ResolveUsersOptions as wt, joinPaths as x, MutationResult as xi, PermissionDeniedReason as xn, resolveComments as xr, GetUsersOptions as xt, getIndexForKey$1 as y, FetcherSnapshot as yi, subscribeDocumentEvents as yn, parseCommentsOptionsKey as yr, UserPresence as yt, QueryOptions as z, UnpublishDocumentAction as zn, CommentThread as zr, InstallationAccess as zt };
|
|
3179
|
+
//# sourceMappingURL=authStore-DKFX8fn7.d.ts.map
|