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