@sanity/sdk 2.20.1 → 2.21.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import { $ as parseQueryKey, Bi as SanityInstance, G as parseUsersKey, Hi as isStudioConfig, I as createGroqSearchFilter, Nr as parseCommentsOptionsKey, W as getUsersKey, Z as getQueryKey, _t as PREVIEW_PROJECTION, a as isProjectUserNotFoundClientError, gt as transformProjectionToPreview, i as getClientErrorApiType, jr as getCommentsOptionsKey, n as getClientErrorApiBody, r as getClientErrorApiDescription, t as ApiErrorBody } from "../utils-BMwA8Kg9.js";
1
+ import { $ as parseQueryKey, G as parseUsersKey, I as createGroqSearchFilter, Mr as getCommentsOptionsKey, Pr as parseCommentsOptionsKey, Ui as isStudioConfig, Vi as SanityInstance, W as getUsersKey, Z as getQueryKey, _t as PREVIEW_PROJECTION, a as isProjectUserNotFoundClientError, gt as transformProjectionToPreview, i as getClientErrorApiType, n as getClientErrorApiBody, r as getClientErrorApiDescription, t as ApiErrorBody } from "../utils-E9GB-6Gs.js";
2
2
  import { SanityClient } from "@sanity/client";
3
3
  /**
4
4
  * Manages telemetry for a single SDK instance.
@@ -95,7 +95,7 @@ function initTelemetry(instance, projectId) {
95
95
  projectId,
96
96
  environment
97
97
  }), Promise.all([
98
- import("../telemetryManager-w-AMXtmz.js").then((n) => n.t),
98
+ import("../telemetryManager-BKcXNRX_.js").then((n) => n.t),
99
99
  import("../clientStore-CMzJ7XhZ.js").then((n) => n.t),
100
100
  import("../authStore-CWTAuieY.js").then((n) => n.n)
101
101
  ]).then(async ([{ createTelemetryManager }, { getClient }, { getTokenState }]) => {
package/dist/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import { $ as parseQueryKey, $i as MediaLibrarySource, $n as UnpublishDocumentAction, $r as CommentTextSelection, $t as OrganizationsOptions, A as CORE_SDK_VERSION, Ai as AgentPromptResult, An as getPermissionsState, Ar as getCommentThreadsState, At as DisconnectEvent, B as getUsersState, Bi as SanityInstance, Bn as CreateReleaseAction, Br as ReplyToCommentOptions, Bt as TransportEvent, C as SanityProject, Ci as OrgVerificationResult, Cn as DocumentTransactionSubmissionResult, Cr as LoggerConfig, Ct as PreviewValue, D as jsonMatch, Di as AgentPatchOptions, Dn as DocumentOptions, Dr as createProjectHandle, Dt as getDocumentPresence, E as joinPaths, Ei as AgentGenerateResult, En as TransactionRevertedEvent, Er as createDocumentTypeHandle, Et as ValidProjection, F as defineIntent, Fi as agentGenerate, Fn as PermissionDeniedReason, Fr as resolveComments, Ft as PresenceSelection, G as parseUsersKey, Gi as DatasetHandle, Gn as EditDocumentAction, Gr as replyToComment, Gt as ResolveUserOptions, H as resolveUser, Hi as isStudioConfig, Hn as DeleteReleaseAction, Hr as UpdateCommentOptions, Ht as GetUserOptions, I as createGroqSearchFilter, Ii as agentPatch, In as JsonMatch, Ir as Selector, It as PresenceSelectionPoint, J as getActiveReleasesState, Ji as DocumentHandle, Jn as PublishDocumentAction, Jr as Comment, Jt as SanityUserResponse, K as getPerspectiveState, Ki as DatasetResource, Kn as EditDocumentOptions, Kr as setCommentStatus, Kt as ResolveUsersOptions, L as FetcherStore, Li as agentPrompt, Ln as Action, Lr as StateSource, Lt as ReportPresenceOptions, M as getCorsErrorProjectId, Mi as AgentTransformResult, Mn as resolvePermissions, Mr as getCommentsState, Mt as DocumentPresenceOptions, N as Intent, Ni as AgentTranslateOptions, Nn as subscribeDocumentEvents, Nt as PresenceLocation, O as slicePath, Oi as AgentPatchResult, On as getDocumentState, Or as CommentsOptions, Ot as getPresence, P as IntentFilter, Pi as AgentTranslateResult, Pn as DocumentPermissionsResult, Pr as resolveCommentThreads, Pt as PresencePerspectiveOptions, Q as getQueryState, Qi as MediaLibraryResource, Qn as UnarchiveReleaseAction, Qr as CommentStatus, Qt as Organizations, R as FetcherStoreState, Ri as agentTransform, Rn as ArchiveReleaseAction, Rr as CreateCommentOptions, Rt as RollCallEvent, S as SanityDocument, Si as observeOrganizationVerificationState, Sn as DocumentRemotePatchesEvent, Sr as Logger, St as PreviewStoreState, T as getPathDepth, Ti as AgentGenerateOptions, Tn as TransactionAcceptedEvent, Tr as createDocumentHandle, Tt as ProjectionValuePending, U as resolveUsers, Ui as CanvasResource, Un as DiscardDocumentAction, Ur as createComment, Ut as GetUsersOptions, V as loadMoreUsers, Vi as createSanityInstance, Vn as DeleteDocumentAction, Vr as SetCommentStatusOptions, Vt as UserPresence, W as getUsersKey, Wi as CanvasSource, Wn as DocumentAction, Wr as removeComment, Wt as Membership, X as QueryOptions, Xi as DocumentSource, Xn as ReleaseAction, Xr as CommentMessage, Xt as UsersGroupState, Y as getAllReleasesState, Yi as DocumentResource, Yn as PublishReleaseAction, Yr as CommentLocalState, Yt as UserProfile, Z as getQueryKey, Zi as DocumentTypeHandle, Zn as ScheduleReleaseAction, Zr as CommentReaction, Zt as UsersStoreState, _ as getTokenState, _i as ClientStoreState, _n as DocumentDeletedEvent, _r as configureLogging, _t as PREVIEW_PROJECTION, a as isProjectUserNotFoundClientError, aa as StudioConfig, ai as getOrCreateNode, an as OrganizationOptions, ar as deleteRelease, at as getProjectionState, b as ReleaseDocument, bi as logout, bn as DocumentEvent, br as LogLevel, bt as PreviewMedia, c as ErrorAuthState, ca as isCanvasSource, ci as destroyController, cn as FavoriteStatusResponse, cr as editRelease, ct as ProjectMember, d as LoggingInAuthState, da as isMediaLibraryResource, di as releaseChannel, dn as getReleaseDocumentId, dr as scheduleRelease, dt as ProjectOptions, ea as PerspectiveHandle, ei as CommentTextSelectionItem, en as getOrganizationsState, er as UnscheduleReleaseAction, et as resolveQuery, f as getAuthState, fa as isMediaLibrarySource, fi as FrameMessage, fn as ActionsResult, fr as unarchiveRelease, ft as getProjectState, g as getLoginUrlState, gi as ClientOptions, gn as DocumentCreatedEvent, gr as resolveDatasets, gt as transformProjectionToPreview, h as getIsInDashboardState, hi as WindowMessage, hn as ActionErrorEvent, hr as getDatasetsState, ht as resolvePreview, i as getClientErrorApiType, ia as SanityConfig, ii as ComlinkNodeState, in as OrganizationMember, ir as deleteDocument, it as resolveProjection, j as isImportError, ji as AgentTransformOptions, jn as resolveDocument, jt as DocumentPresence, k as stringifyPath, ki as AgentPromptOptions, kn as getDocumentSyncStatus, kr as ResolveCommentsOptions, kt as reportPresence, l as LoggedInAuthState, la as isDatasetResource, li as getOrCreateChannel, ln as getFavoritesState, lr as publishDocument, lt as ProjectMemberRole, m as getDashboardOrganizationId, ma as AuthProvider, mi as RequestNewTokenMessage, mn as applyDocumentActions, mr as unscheduleRelease, mt as ResolvePreviewOptions, n as getClientErrorApiBody, na as ReleaseHandle, ni as NodeState, nn as Organization, nr as createDocument, nt as getProjectsState, o as AuthState, oa as TokenSource, oi as releaseNode, on as getOrganizationState, or as discardDocument, ot as Project, p as getCurrentUserState, pa as AuthConfig, pi as NewTokenResponseMessage, pn as ApplyDocumentActionsOptions, pr as unpublishDocument, pt as resolveProject, q as ReleaseState, qi as DatasetSource, qn as EditReleaseAction, qr as updateComment, qt as SanityUser, r as getClientErrorApiDescription, ra as ReleasePerspective, ri as getNodeState, rn as OrganizationBase, rr as createRelease, rt as resolveProjects, s as AuthStoreState, sa as isCanvasResource, si as ComlinkControllerState, sn as resolveOrganization, sr as editDocument, st as ProjectBase, t as ApiErrorBody, ta as ProjectHandle, ti as CommentThread, tn as resolveOrganizations, tr as archiveRelease, tt as ProjectsOptions, u as LoggedOutAuthState, ua as isDatasetSource, ui as getOrCreateController, un as resolveFavoritesState, ur as publishRelease, ut as ProjectMetadata, v as setAuthToken, vi as getClient, vn as DocumentDiscardedEvent, vr as InstanceContext, vt as GetPreviewStateOptions, w as getIndexForKey, wi as AuthStateType, wn as DocumentUnpublishedEvent, wr as createDatasetHandle, wt as ValuePending, x as Role, xi as handleAuthCallback, xn as DocumentPublishedEvent, xr as LogNamespace, xt as PreviewQueryResult, y as CurrentUser, yi as getClientState, yn as DocumentEditedEvent, yr as LogContext, yt as getPreviewState, z as getUserState, zi as agentTranslate, zn as CreateDocumentAction, zr as RemoveCommentOptions, zt as StateEvent } from "./utils-BMwA8Kg9.js";
2
- export { type Action, type ActionErrorEvent, type ActionsResult, type AgentGenerateOptions, type AgentGenerateResult, type AgentPatchOptions, type AgentPatchResult, type AgentPromptOptions, type AgentPromptResult, type AgentTransformOptions, type AgentTransformResult, type AgentTranslateOptions, type AgentTranslateResult, type ApiErrorBody, type ApplyDocumentActionsOptions, type ArchiveReleaseAction, type AuthConfig, type AuthProvider, type AuthState, AuthStateType, type AuthStoreState, CORE_SDK_VERSION, type CanvasResource, type CanvasSource, type ClientOptions, type ClientStoreState as ClientState, type ComlinkControllerState, type ComlinkNodeState, 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 DatasetSource, type DeleteDocumentAction, type DeleteReleaseAction, 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 DocumentSource, type DocumentTransactionSubmissionResult, type DocumentTypeHandle, type DocumentUnpublishedEvent, type EditDocumentAction, type EditDocumentOptions, type EditReleaseAction, type ErrorAuthState, type FavoriteStatusResponse, type FetcherStore, type FetcherStoreState, type FrameMessage, type GetPreviewStateOptions, type GetUserOptions, type GetUsersOptions, type InstanceContext, type Intent, type IntentFilter, type JsonMatch, type LogContext, type LogLevel, type LogNamespace, type LoggedInAuthState, type LoggedOutAuthState, type Logger, type LoggerConfig, type LoggingInAuthState, type MediaLibraryResource, type MediaLibrarySource, type Membership, type NewTokenResponseMessage, type NodeState, type OrgVerificationResult, type Organization, type OrganizationBase, type OrganizationMember, type OrganizationOptions, type Organizations, type OrganizationsOptions, PREVIEW_PROJECTION, type PermissionDeniedReason, type PerspectiveHandle, type PresenceLocation, type PresencePerspectiveOptions, type PresenceSelection, type PresenceSelectionPoint, type PreviewMedia, type PreviewQueryResult, type PreviewStoreState, 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 RequestNewTokenMessage, type ResolveCommentsOptions, type ResolvePreviewOptions, 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 UpdateCommentOptions, type UserPresence, type UserProfile, type UsersGroupState, type UsersStoreState, type ValidProjection, type ValuePending, type WindowMessage, agentGenerate, agentPatch, agentPrompt, agentTransform, agentTranslate, applyDocumentActions, archiveRelease, configureLogging, createComment, createDatasetHandle, createDocument, createDocumentHandle, createDocumentTypeHandle, createGroqSearchFilter, createProjectHandle, createRelease, createSanityInstance, defineIntent, deleteDocument, deleteRelease, destroyController, discardDocument, editDocument, editRelease, getActiveReleasesState, getAllReleasesState, getAuthState, getClient, getClientErrorApiBody, getClientErrorApiDescription, getClientErrorApiType, getClientState, getCommentThreadsState, getCommentsState, getCorsErrorProjectId, getCurrentUserState, getDashboardOrganizationId, getDatasetsState, getDocumentPresence, getDocumentState, getDocumentSyncStatus, getFavoritesState, getIndexForKey, getIsInDashboardState, getLoginUrlState, getNodeState, getOrCreateChannel, getOrCreateController, getOrCreateNode, getOrganizationState, getOrganizationsState, getPathDepth, getPermissionsState, getPerspectiveState, getPresence, getPreviewState, getProjectState, getProjectionState, getProjectsState, getQueryKey, getQueryState, getReleaseDocumentId, getTokenState, getUserState, getUsersKey, getUsersState, handleAuthCallback, isCanvasResource, isCanvasSource, isDatasetResource, isDatasetSource, isImportError, isMediaLibraryResource, isMediaLibrarySource, isProjectUserNotFoundClientError, isStudioConfig, joinPaths, jsonMatch, loadMoreUsers, logout, observeOrganizationVerificationState, parseQueryKey, parseUsersKey, publishDocument, publishRelease, releaseChannel, releaseNode, removeComment, replyToComment, reportPresence, resolveCommentThreads, resolveComments, resolveDatasets, resolveDocument, resolveFavoritesState, resolveOrganization, resolveOrganizations, resolvePermissions, resolvePreview, resolveProject, resolveProjection, resolveProjects, resolveQuery, resolveUser, resolveUsers, scheduleRelease, setAuthToken, setCommentStatus, slicePath, stringifyPath, subscribeDocumentEvents, transformProjectionToPreview, unarchiveRelease, unpublishDocument, unscheduleRelease, updateComment };
1
+ import { $ as parseQueryKey, $i as MediaLibraryResource, $n as UnarchiveReleaseAction, $r as CommentStatus, $t as OrganizationsOptions, A as CORE_SDK_VERSION, Ai as AgentPromptOptions, An as getDocumentSyncStatus, Ar as ResolveCommentsOptions, At as DisconnectEvent, B as getUsersState, Bi as agentTranslate, Bn as CreateDocumentAction, Br as RemoveCommentOptions, Bt as TransportEvent, C as SanityProject, Ci as observeOrganizationVerificationState, Cn as DocumentTransactionSubmissionResult, Cr as Logger, Ct as PreviewValue, D as jsonMatch, Di as AgentGenerateResult, Dn as TransactionSubmissionFailedEvent, Dr as createDocumentTypeHandle, Dt as getDocumentPresence, E as joinPaths, Ei as AgentGenerateOptions, En as TransactionRevertedEvent, Er as createDocumentHandle, Et as ValidProjection, F as defineIntent, Fi as AgentTranslateResult, Fn as DocumentPermissionsResult, Fr as resolveCommentThreads, Ft as PresenceSelection, G as parseUsersKey, Gi as CanvasSource, Gn as DocumentAction, Gr as removeComment, Gt as ResolveUserOptions, H as resolveUser, Hi as createSanityInstance, Hn as DeleteDocumentAction, Hr as SetCommentStatusOptions, Ht as GetUserOptions, I as createGroqSearchFilter, Ii as agentGenerate, In as PermissionDeniedReason, Ir as resolveComments, It as PresenceSelectionPoint, J as getActiveReleasesState, Ji as DatasetSource, Jn as EditReleaseAction, Jr as updateComment, Jt as SanityUserResponse, K as getPerspectiveState, Ki as DatasetHandle, Kn as EditDocumentAction, Kr as replyToComment, Kt as ResolveUsersOptions, L as FetcherStore, Li as agentPatch, Ln as JsonMatch, Lr as Selector, Lt as ReportPresenceOptions, M as getCorsErrorProjectId, Mi as AgentTransformOptions, Mn as resolveDocument, Mt as DocumentPresenceOptions, N as Intent, Ni as AgentTransformResult, Nn as resolvePermissions, Nr as getCommentsState, Nt as PresenceLocation, O as slicePath, Oi as AgentPatchOptions, On as DocumentOptions, Or as createProjectHandle, Ot as getPresence, P as IntentFilter, Pi as AgentTranslateOptions, Pn as subscribeDocumentEvents, Pt as PresencePerspectiveOptions, Q as getQueryState, Qi as DocumentTypeHandle, Qn as ScheduleReleaseAction, Qr as CommentReaction, Qt as Organizations, R as FetcherStoreState, Ri as agentPrompt, Rn as Action, Rr as StateSource, Rt as RollCallEvent, S as SanityDocument, Si as handleAuthCallback, Sn as DocumentRemotePatchesEvent, Sr as LogNamespace, St as PreviewStoreState, T as getPathDepth, Ti as AuthStateType, Tn as TransactionAcceptedEvent, Tr as createDatasetHandle, Tt as ProjectionValuePending, U as resolveUsers, Ui as isStudioConfig, Un as DeleteReleaseAction, Ur as UpdateCommentOptions, Ut as GetUsersOptions, V as loadMoreUsers, Vi as SanityInstance, Vn as CreateReleaseAction, Vr as ReplyToCommentOptions, Vt as UserPresence, W as getUsersKey, Wi as CanvasResource, Wn as DiscardDocumentAction, Wr as createComment, Wt as Membership, X as QueryOptions, Xi as DocumentResource, Xn as PublishReleaseAction, Xr as CommentLocalState, Xt as UsersGroupState, Y as getAllReleasesState, Yi as DocumentHandle, Yn as PublishDocumentAction, Yr as Comment, Yt as UserProfile, Z as getQueryKey, Zi as DocumentSource, Zn as ReleaseAction, Zr as CommentMessage, Zt as UsersStoreState, _ as getTokenState, _i as ClientOptions, _n as DocumentDeletedEvent, _r as resolveDatasets, _t as PREVIEW_PROJECTION, a as isProjectUserNotFoundClientError, aa as SanityConfig, ai as ComlinkNodeState, an as OrganizationOptions, ar as deleteDocument, at as getProjectionState, b as ReleaseDocument, bi as getClientState, bn as DocumentEvent, br as LogContext, bt as PreviewMedia, c as ErrorAuthState, ca as isCanvasResource, ci as ComlinkControllerState, cn as FavoriteStatusResponse, cr as editDocument, ct as ProjectMember, d as LoggingInAuthState, da as isDatasetSource, di as getOrCreateController, dn as getReleaseDocumentId, dr as publishRelease, dt as ProjectOptions, ea as MediaLibrarySource, ei as CommentTextSelection, en as getOrganizationsState, er as UnpublishDocumentAction, et as resolveQuery, f as getAuthState, fa as isMediaLibraryResource, fi as releaseChannel, fn as ActionsResult, fr as scheduleRelease, ft as getProjectState, g as getLoginUrlState, gi as WindowMessage, gn as DocumentCreatedEvent, gr as getDatasetsState, gt as transformProjectionToPreview, h as getIsInDashboardState, ha as AuthProvider, hi as RequestNewTokenMessage, hn as ActionErrorEvent, hr as unscheduleRelease, ht as resolvePreview, i as getClientErrorApiType, ia as ReleasePerspective, ii as getNodeState, in as OrganizationMember, ir as createRelease, it as resolveProjection, j as isImportError, ji as AgentPromptResult, jn as getPermissionsState, jr as getCommentThreadsState, jt as DocumentPresence, k as stringifyPath, ki as AgentPatchResult, kn as getDocumentState, kr as CommentsOptions, kt as reportPresence, l as LoggedInAuthState, la as isCanvasSource, li as destroyController, ln as getFavoritesState, lr as editRelease, lt as ProjectMemberRole, m as getDashboardOrganizationId, ma as AuthConfig, mi as NewTokenResponseMessage, mn as applyDocumentActions, mr as unpublishDocument, mt as ResolvePreviewOptions, n as getClientErrorApiBody, na as ProjectHandle, ni as CommentThread, nn as Organization, nr as archiveRelease, nt as getProjectsState, o as AuthState, oa as StudioConfig, oi as getOrCreateNode, on as getOrganizationState, or as deleteRelease, ot as Project, p as getCurrentUserState, pa as isMediaLibrarySource, pi as FrameMessage, pn as ApplyDocumentActionsOptions, pr as unarchiveRelease, pt as resolveProject, q as ReleaseState, qi as DatasetResource, qn as EditDocumentOptions, qr as setCommentStatus, qt as SanityUser, r as getClientErrorApiDescription, ra as ReleaseHandle, ri as NodeState, rn as OrganizationBase, rr as createDocument, rt as resolveProjects, s as AuthStoreState, sa as TokenSource, si as releaseNode, sn as resolveOrganization, sr as discardDocument, st as ProjectBase, t as ApiErrorBody, ta as PerspectiveHandle, ti as CommentTextSelectionItem, tn as resolveOrganizations, tr as UnscheduleReleaseAction, tt as ProjectsOptions, u as LoggedOutAuthState, ua as isDatasetResource, ui as getOrCreateChannel, un as resolveFavoritesState, ur as publishDocument, ut as ProjectMetadata, v as setAuthToken, vi as ClientStoreState, vn as DocumentDiscardedEvent, vr as configureLogging, vt as GetPreviewStateOptions, w as getIndexForKey, wi as OrgVerificationResult, wn as DocumentUnpublishedEvent, wr as LoggerConfig, wt as ValuePending, x as Role, xi as logout, xn as DocumentPublishedEvent, xr as LogLevel, xt as PreviewQueryResult, y as CurrentUser, yi as getClient, yn as DocumentEditedEvent, yr as InstanceContext, yt as getPreviewState, z as getUserState, zi as agentTransform, zn as ArchiveReleaseAction, zr as CreateCommentOptions, zt as StateEvent } from "./utils-E9GB-6Gs.js";
2
+ export { type Action, type ActionErrorEvent, type ActionsResult, type AgentGenerateOptions, type AgentGenerateResult, type AgentPatchOptions, type AgentPatchResult, type AgentPromptOptions, type AgentPromptResult, type AgentTransformOptions, type AgentTransformResult, type AgentTranslateOptions, type AgentTranslateResult, type ApiErrorBody, type ApplyDocumentActionsOptions, type ArchiveReleaseAction, type AuthConfig, type AuthProvider, type AuthState, AuthStateType, type AuthStoreState, CORE_SDK_VERSION, type CanvasResource, type CanvasSource, type ClientOptions, type ClientStoreState as ClientState, type ComlinkControllerState, type ComlinkNodeState, 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 DatasetSource, type DeleteDocumentAction, type DeleteReleaseAction, 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 DocumentSource, type DocumentTransactionSubmissionResult, type DocumentTypeHandle, type DocumentUnpublishedEvent, type EditDocumentAction, type EditDocumentOptions, type EditReleaseAction, type ErrorAuthState, type FavoriteStatusResponse, type FetcherStore, type FetcherStoreState, type FrameMessage, type GetPreviewStateOptions, type GetUserOptions, type GetUsersOptions, type InstanceContext, type Intent, type IntentFilter, type JsonMatch, type LogContext, type LogLevel, type LogNamespace, type LoggedInAuthState, type LoggedOutAuthState, type Logger, type LoggerConfig, type LoggingInAuthState, type MediaLibraryResource, type MediaLibrarySource, type Membership, type NewTokenResponseMessage, type NodeState, type OrgVerificationResult, type Organization, type OrganizationBase, type OrganizationMember, type OrganizationOptions, type Organizations, type OrganizationsOptions, PREVIEW_PROJECTION, type PermissionDeniedReason, type PerspectiveHandle, type PresenceLocation, type PresencePerspectiveOptions, type PresenceSelection, type PresenceSelectionPoint, type PreviewMedia, type PreviewQueryResult, type PreviewStoreState, 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 RequestNewTokenMessage, type ResolveCommentsOptions, type ResolvePreviewOptions, 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 TransactionSubmissionFailedEvent, type TransportEvent, type UnarchiveReleaseAction, type UnpublishDocumentAction, type UnscheduleReleaseAction, type UpdateCommentOptions, type UserPresence, type UserProfile, type UsersGroupState, type UsersStoreState, type ValidProjection, type ValuePending, type WindowMessage, agentGenerate, agentPatch, agentPrompt, agentTransform, agentTranslate, applyDocumentActions, archiveRelease, configureLogging, createComment, createDatasetHandle, createDocument, createDocumentHandle, createDocumentTypeHandle, createGroqSearchFilter, createProjectHandle, createRelease, createSanityInstance, defineIntent, deleteDocument, deleteRelease, destroyController, discardDocument, editDocument, editRelease, getActiveReleasesState, getAllReleasesState, getAuthState, getClient, getClientErrorApiBody, getClientErrorApiDescription, getClientErrorApiType, getClientState, getCommentThreadsState, getCommentsState, getCorsErrorProjectId, getCurrentUserState, getDashboardOrganizationId, getDatasetsState, getDocumentPresence, getDocumentState, getDocumentSyncStatus, getFavoritesState, getIndexForKey, getIsInDashboardState, getLoginUrlState, getNodeState, getOrCreateChannel, getOrCreateController, getOrCreateNode, getOrganizationState, getOrganizationsState, getPathDepth, getPermissionsState, getPerspectiveState, getPresence, getPreviewState, getProjectState, getProjectionState, getProjectsState, getQueryKey, getQueryState, getReleaseDocumentId, getTokenState, getUserState, getUsersKey, getUsersState, handleAuthCallback, isCanvasResource, isCanvasSource, isDatasetResource, isDatasetSource, isImportError, isMediaLibraryResource, isMediaLibrarySource, isProjectUserNotFoundClientError, isStudioConfig, joinPaths, jsonMatch, loadMoreUsers, logout, observeOrganizationVerificationState, parseQueryKey, parseUsersKey, publishDocument, publishRelease, releaseChannel, releaseNode, removeComment, replyToComment, reportPresence, resolveCommentThreads, resolveComments, resolveDatasets, resolveDocument, resolveFavoritesState, resolveOrganization, resolveOrganizations, resolvePermissions, resolvePreview, resolveProject, resolveProjection, resolveProjects, resolveQuery, resolveUser, resolveUsers, scheduleRelease, setAuthToken, setCommentStatus, slicePath, stringifyPath, subscribeDocumentEvents, transformProjectionToPreview, unarchiveRelease, unpublishDocument, unscheduleRelease, updateComment };
package/dist/index.js CHANGED
@@ -2,7 +2,7 @@ import { A as defineStore, C as REQUEST_TAG_PREFIX, D as bindActionByResource, E
2
2
  import { A as addComment, B as normalizeComment, C as getCommentThreadsState, D as resolveCommentThreads, F as removeCommentById, G as COMMENTS_API_VERSION, H as assertDatasetResource, I as restoreComments, K as setCleanupTimeout, L as rollbackCommentUpdate, M as clearPendingTransaction, N as getCommentsKey, O as resolveComments, P as receiveComment, R as setCommentCreateError, S as commentsStore, T as getCommentsState, U as getAddonDatasetState, V as toCommentFieldPath, W as provisionAddonDataset, _ as setUsersData, a as getQueryState, b as PROJECT_API_VERSION, c as getPerspectiveState, d as addSubscription, f as cancelRequest, g as removeSubscription, h as parseUsersKey, i as getQueryKey, j as applyCommentUpdate, k as toCommentsKeyParts, l as getActiveReleasesState, m as initializeRequest, n as transformProjectionToPreview, o as parseQueryKey, p as getUsersKey, q as insecureRandomId, r as PREVIEW_PROJECTION, s as resolveQuery, t as createGroqSearchFilter, u as getAllReleasesState, v as setUsersError, x as USERS_STATE_CLEAR_DELAY, y as updateLastLoadMoreRequest, z as setPendingTransaction } from "./createGroqSearchFilter-B0NdA-EP.js";
3
3
  import { n as configureLogging$1, r as createLogger } from "./getEnv-76AjZd_f.js";
4
4
  import { i as isDeepEqual, n as getClient, o as omitProperty, r as getClientState, s as pickProperties } from "./clientStore-CMzJ7XhZ.js";
5
- import { t as CORE_SDK_VERSION } from "./version-ByqNiWrK.js";
5
+ import { t as CORE_SDK_VERSION } from "./version-BAVcaHtM.js";
6
6
  import { ClientError, CorsOriginError } from "@sanity/client";
7
7
  import { EMPTY, NEVER, Observable, Subject, Subscription, asapScheduler, auditTime, catchError, combineLatest, concat, concatMap, debounceTime, defer, distinctUntilChanged, filter, first, firstValueFrom, from, fromEvent, groupBy, map, merge, mergeMap, of, pairwise, partition, race, retry, share, shareReplay, skip, startWith, switchMap, take, takeUntil, tap, throttle, throwError, timer, withLatestFrom } from "rxjs";
8
8
  import { isKeySegment, isKeyedObject } from "@sanity/types";
@@ -2755,7 +2755,8 @@ function cleanupOutgoingTransaction(prev) {
2755
2755
  for (let transactionId of outgoing.batchedTransactionIds) for (let documentId of ids) next = removeSubscriptionIdFromDocument(next, documentId, transactionId);
2756
2756
  return {
2757
2757
  ...next,
2758
- outgoing: void 0
2758
+ outgoing: void 0,
2759
+ documentStates: evictOrphanedDocumentStates(next.documentStates)
2759
2760
  };
2760
2761
  }
2761
2762
  function revertOutgoingTransaction(prev) {
@@ -2785,11 +2786,16 @@ function revertOutgoingTransaction(prev) {
2785
2786
  ...base,
2786
2787
  applied: nextApplied,
2787
2788
  outgoing: void 0,
2788
- documentStates: Object.fromEntries(Object.entries(base.documentStates).filter((e) => !!e[1]).map(([documentId, { unverifiedRevisions = {}, local, ...documentState }]) => [documentId, {
2789
- ...documentState,
2790
- local: documentId in working ? working[documentId] : local,
2791
- unverifiedRevisions: prev.outgoing && prev.outgoing.transactionId in unverifiedRevisions ? omitProperty(unverifiedRevisions, prev.outgoing.transactionId) : unverifiedRevisions
2792
- }]))
2789
+ documentStates: evictOrphanedDocumentStates(Object.fromEntries(Object.entries(base.documentStates).filter((e) => !!e[1]).map(([documentId, documentState]) => {
2790
+ let { unverifiedRevisions = {} } = documentState, next = {
2791
+ ...documentState,
2792
+ unverifiedRevisions: prev.outgoing && prev.outgoing.transactionId in unverifiedRevisions ? omitProperty(unverifiedRevisions, prev.outgoing.transactionId) : unverifiedRevisions
2793
+ };
2794
+ return !next.subscriptions.length && isAwaitingOwnEcho(next) ? [documentId, next] : [documentId, {
2795
+ ...next,
2796
+ local: documentId in working ? working[documentId] : next.local
2797
+ }];
2798
+ })))
2793
2799
  };
2794
2800
  }
2795
2801
  /**
@@ -2830,7 +2836,7 @@ function applyRemoteDocument(prev, { document, documentId, previousRev, revision
2830
2836
  let modifiesDocument = (transaction) => transaction.working[documentId]?._rev !== transaction.previousRevs[documentId], local = !prev.applied.some(modifiesDocument) && (!prev.outgoing || prev.outgoing.transactionId === revision || !modifiesDocument(prev.outgoing)) && !isDeepEqual(prevDocState.local, document) ? document : prevDocState.local;
2831
2837
  return {
2832
2838
  ...prev,
2833
- documentStates: {
2839
+ documentStates: evictOrphanedDocumentStates({
2834
2840
  ...prev.documentStates,
2835
2841
  [documentId]: {
2836
2842
  ...prevDocState,
@@ -2839,7 +2845,7 @@ function applyRemoteDocument(prev, { document, documentId, previousRev, revision
2839
2845
  local,
2840
2846
  unverifiedRevisions
2841
2847
  }
2842
- }
2848
+ })
2843
2849
  };
2844
2850
  }
2845
2851
  let working = {
@@ -2874,7 +2880,7 @@ function applyRemoteDocument(prev, { document, documentId, previousRev, revision
2874
2880
  return {
2875
2881
  ...prev,
2876
2882
  applied: nextApplied,
2877
- documentStates: {
2883
+ documentStates: evictOrphanedDocumentStates({
2878
2884
  ...prev.documentStates,
2879
2885
  [documentId]: {
2880
2886
  ...prevDocState,
@@ -2883,7 +2889,7 @@ function applyRemoteDocument(prev, { document, documentId, previousRev, revision
2883
2889
  local,
2884
2890
  unverifiedRevisions
2885
2891
  }
2886
- }
2892
+ })
2887
2893
  };
2888
2894
  }
2889
2895
  function addSubscriptionIdToDocument(prev, documentId, subscriptionId) {
@@ -2901,8 +2907,13 @@ function addSubscriptionIdToDocument(prev, documentId, subscriptionId) {
2901
2907
  };
2902
2908
  }
2903
2909
  function removeSubscriptionIdFromDocument(prev, documentId, subscriptionId) {
2904
- let prevDocState = prev.documentStates?.[documentId], subscriptions = (prevDocState?.subscriptions ?? []).filter((id) => id !== subscriptionId);
2905
- return prevDocState ? subscriptions.length ? {
2910
+ let prevDocState = prev.documentStates?.[documentId];
2911
+ if (!prevDocState) return prev;
2912
+ let subscriptions = prevDocState.subscriptions.filter((id) => id !== subscriptionId);
2913
+ return !subscriptions.length && !isAwaitingOwnEcho(prevDocState) ? {
2914
+ ...prev,
2915
+ documentStates: omitProperty(prev.documentStates, documentId)
2916
+ } : {
2906
2917
  ...prev,
2907
2918
  documentStates: {
2908
2919
  ...prev.documentStates,
@@ -2911,10 +2922,46 @@ function removeSubscriptionIdFromDocument(prev, documentId, subscriptionId) {
2911
2922
  subscriptions
2912
2923
  }
2913
2924
  }
2914
- } : {
2915
- ...prev,
2916
- documentStates: omitProperty(prev.documentStates, documentId)
2917
- } : prev;
2925
+ };
2926
+ }
2927
+ /**
2928
+ * Whether this document still expects the listener echo of one of its own
2929
+ * submitted transactions. That expectation is the only reason a document state
2930
+ * with no subscribers is kept around.
2931
+ *
2932
+ * Revisions stop counting after `UNVERIFIED_REVISION_RETENTION_TIME` because an
2933
+ * echo is not guaranteed to arrive at all: Content Lake records no transaction
2934
+ * when every operation resolves to a no-op (e.g. a keyed path that no longer
2935
+ * exists), while the client bumps `_rev` regardless and so tracks a revision
2936
+ * for it. Without the expiry, such a document (and the listener keyed off its
2937
+ * state) would be pinned for the lifetime of the store.
2938
+ *
2939
+ * `recentOwnTransactionIds` deliberately does not extend the wait: it is capped
2940
+ * rather than drained, so honoring it would keep every edited document alive.
2941
+ */
2942
+ function isAwaitingOwnEcho(documentState) {
2943
+ let expiresAfter = Date.now() - 3e4;
2944
+ return Object.values(documentState.unverifiedRevisions ?? {}).some((revision) => !!revision && new Date(revision.timestamp).getTime() > expiresAfter);
2945
+ }
2946
+ /**
2947
+ * Removes every document state that has no subscribers left and no own
2948
+ * transaction still awaiting its echo.
2949
+ *
2950
+ * This is a sweep rather than a decision made where the last subscriber leaves
2951
+ * because `removeSubscriptionIdFromDocument` defers that eviction while an echo
2952
+ * is in flight, and both halves of the condition can change without a
2953
+ * subscriber going anywhere: the echo can verify, be dropped by a sync, be
2954
+ * discarded by a revert, or simply never arrive. Every reducer that can settle
2955
+ * an in-flight transaction sweeps, so the deferred decision is always re-made.
2956
+ *
2957
+ * Note this can evict the very document whose remote event is being processed,
2958
+ * which synchronously unsubscribes that document's listener from inside its own
2959
+ * emission (see `subscribeToSubscriptionsAndListenToDocuments`).
2960
+ */
2961
+ function evictOrphanedDocumentStates(documentStates) {
2962
+ let next = documentStates;
2963
+ for (let [documentId, documentState] of Object.entries(documentStates)) documentState && (documentState.subscriptions.length || isAwaitingOwnEcho(documentState) || (next = omitProperty(next, documentId)));
2964
+ return next;
2918
2965
  }
2919
2966
  function manageSubscriberIds({ state }, handles) {
2920
2967
  let documentIds = getDocumentIdsFromHandleLikes(handles), subscriptionId = insecureRandomId();
@@ -3106,6 +3153,40 @@ function createFetchDocument(instance, resource) {
3106
3153
  }), first());
3107
3154
  };
3108
3155
  }
3156
+ const REJECTED_TRANSACTION_STATUS_CODES = /* @__PURE__ */ new Set([
3157
+ 400,
3158
+ 402,
3159
+ 403,
3160
+ 404,
3161
+ 409,
3162
+ 410,
3163
+ 412,
3164
+ 413,
3165
+ 422
3166
+ ]);
3167
+ function getErrorType(error) {
3168
+ let details = error.details;
3169
+ if (details && typeof details == "object" && "type" in details) return details.type;
3170
+ }
3171
+ /**
3172
+ * Classifies a failed transaction submission. Unknown failures (network
3173
+ * errors, timeouts, 5xx and 429 responses, and anything that is not a
3174
+ * `ClientError`) default to `retry`: wrongly retrying a rejected transaction
3175
+ * leaves the document visibly unsynced with the edits still on screen, while
3176
+ * wrongly reverting a transient failure silently discards the user's work.
3177
+ *
3178
+ * @internal
3179
+ */
3180
+ function classifySubmissionError(error) {
3181
+ if (error instanceof CorsOriginError) return "revert";
3182
+ if (!(error instanceof ClientError)) return "retry";
3183
+ if (error.statusCode === 409) {
3184
+ let errorType = getErrorType(error);
3185
+ if (errorType === "transactionAlreadyExistsError") return "accepted";
3186
+ if (errorType === "transactionConflictError") return "retry";
3187
+ }
3188
+ return REJECTED_TRANSACTION_STATUS_CODES.has(error.statusCode) ? "revert" : "retry";
3189
+ }
3109
3190
  const documentStore = defineStore({
3110
3191
  name: "Document",
3111
3192
  getInitialState: (instance, { resource }) => ({
@@ -3196,41 +3277,52 @@ const _resolveDocument = bindActionByResource(documentStore, ({ instance }, docH
3196
3277
  }), caught;
3197
3278
  throw error;
3198
3279
  })).subscribe({ error: (error) => state.set("setError", { error }) });
3199
- }, subscribeToAppliedAndSubmitNextTransaction = ({ state, instance, key: { resource } }) => {
3200
- let { events } = state.get();
3280
+ }, getErrorMessage = (error) => error instanceof Error ? error.message : "Request failed", submitOutgoingTransaction = (client, outgoing) => outgoing.actions.some((action) => !isReleaseAction(action) && action.liveEdit) ? client.observable.mutate(outgoing.outgoingMutations, {
3281
+ transactionId: outgoing.transactionId,
3282
+ visibility: "async",
3283
+ returnDocuments: !1,
3284
+ returnFirst: !1,
3285
+ tag: "document.mutate",
3286
+ skipCrossDatasetReferenceValidation: !0
3287
+ }) : client.observable.action(outgoing.outgoingActions, {
3288
+ transactionId: outgoing.transactionId,
3289
+ skipCrossDatasetReferenceValidation: !0,
3290
+ tag: "document.action"
3291
+ }), subscribeToAppliedAndSubmitNextTransaction = ({ state, instance, key: { resource } }) => {
3292
+ let { events } = state.get(), clients$ = getClientState(instance, {
3293
+ apiVersion: API_VERSION$4,
3294
+ resource
3295
+ }).observable;
3201
3296
  return state.observable.pipe(throttle((s) => s.outgoing ? state.observable.pipe(first(({ outgoing }) => !outgoing)) : timer(1e3), {
3202
3297
  leading: !1,
3203
3298
  trailing: !0
3204
- }), map(transitionAppliedTransactionsToOutgoing), distinctUntilChanged((a, b) => a.outgoing?.transactionId === b.outgoing?.transactionId), tap((next) => state.set("transitionAppliedTransactionsToOutgoing", next)), map((s) => s.outgoing), distinctUntilChanged(), withLatestFrom(getClientState(instance, {
3205
- apiVersion: API_VERSION$4,
3206
- resource
3207
- }).observable), concatMap(([outgoing, client]) => {
3299
+ }), map(transitionAppliedTransactionsToOutgoing), distinctUntilChanged((a, b) => a.outgoing?.transactionId === b.outgoing?.transactionId), tap((next) => state.set("transitionAppliedTransactionsToOutgoing", next)), map((s) => s.outgoing), distinctUntilChanged(), withLatestFrom(clients$), concatMap(([outgoing, initialClient]) => {
3208
3300
  if (!outgoing) return EMPTY;
3209
- let revertOnError = catchError((error) => {
3210
- state.set("revertOutgoingTransaction", revertOutgoingTransaction);
3211
- let message = error instanceof Error ? error.message : "Request failed";
3212
- return events.next({
3213
- type: "reverted",
3214
- message,
3301
+ let attemptClient;
3302
+ return defer(() => attemptClient ? clients$.pipe(first()) : of(initialClient)).pipe(concatMap((client) => (attemptClient = client, submitOutgoingTransaction(client, outgoing))), retry({ delay: (error, retryCount) => {
3303
+ if (classifySubmissionError(error) !== "retry") return throwError(() => error);
3304
+ events.next({
3305
+ type: "submission-failed",
3306
+ message: getErrorMessage(error),
3307
+ error,
3215
3308
  outgoing,
3216
- error
3217
- }), EMPTY;
3218
- }), toResult = map((result) => ({
3309
+ attempt: retryCount
3310
+ });
3311
+ let backoff = Math.min(1e3 * 2 ** (retryCount - 1), 1e4);
3312
+ return race(timer(backoff), clients$.pipe(first((client) => client !== attemptClient)));
3313
+ } }), catchError((error) => classifySubmissionError(error) === "accepted" ? of({
3314
+ transactionId: outgoing.transactionId,
3315
+ documentIds: [],
3316
+ results: []
3317
+ }) : (state.set("revertOutgoingTransaction", revertOutgoingTransaction), events.next({
3318
+ type: "reverted",
3319
+ message: getErrorMessage(error),
3320
+ outgoing,
3321
+ error
3322
+ }), EMPTY)), map((result) => ({
3219
3323
  result,
3220
3324
  outgoing
3221
- }));
3222
- return outgoing.actions.some((action) => !isReleaseAction(action) && action.liveEdit) ? client.observable.mutate(outgoing.outgoingMutations, {
3223
- transactionId: outgoing.transactionId,
3224
- visibility: "async",
3225
- returnDocuments: !1,
3226
- returnFirst: !1,
3227
- tag: "document.mutate",
3228
- skipCrossDatasetReferenceValidation: !0
3229
- }).pipe(revertOnError, toResult) : client.observable.action(outgoing.outgoingActions, {
3230
- transactionId: outgoing.transactionId,
3231
- skipCrossDatasetReferenceValidation: !0,
3232
- tag: "document.action"
3233
- }).pipe(revertOnError, toResult);
3325
+ })));
3234
3326
  }), tap(({ outgoing, result }) => {
3235
3327
  state.set("cleanupOutgoingTransaction", cleanupOutgoingTransaction);
3236
3328
  for (let e of getDocumentEvents(outgoing)) events.next(e);