@sanity/sdk 2.10.0 → 2.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/dist/_chunks-dts/utils.d.ts +200 -28
  2. package/dist/_chunks-es/_internal.js +3 -14
  3. package/dist/_chunks-es/_internal.js.map +1 -1
  4. package/dist/_chunks-es/createGroqSearchFilter.js +7 -14
  5. package/dist/_chunks-es/createGroqSearchFilter.js.map +1 -1
  6. package/dist/_chunks-es/version.js +1 -1
  7. package/dist/_exports/_internal.d.ts +16 -2
  8. package/dist/_exports/_internal.js +3 -1
  9. package/dist/index.d.ts +2 -2
  10. package/dist/index.js +168 -88
  11. package/dist/index.js.map +1 -1
  12. package/package.json +7 -9
  13. package/src/_exports/_internal.ts +1 -0
  14. package/src/_exports/index.ts +25 -2
  15. package/src/agent/agentActions.ts +21 -25
  16. package/src/client/clientStore.test.ts +10 -46
  17. package/src/client/clientStore.ts +7 -14
  18. package/src/comlink/node/actions/getOrCreateNode.test.ts +5 -2
  19. package/src/comlink/node/actions/releaseNode.test.ts +3 -3
  20. package/src/config/sanityConfig.ts +0 -1
  21. package/src/document/documentStore.ts +2 -7
  22. package/src/document/sharedListener.ts +3 -5
  23. package/src/organization/organization.test-d.ts +102 -0
  24. package/src/organization/organization.test.ts +138 -0
  25. package/src/organization/organization.ts +166 -0
  26. package/src/organizations/organizations.test-d.ts +77 -0
  27. package/src/organizations/organizations.test.ts +150 -0
  28. package/src/organizations/organizations.ts +132 -0
  29. package/src/presence/presenceStore.test.ts +5 -5
  30. package/src/preview/previewProjectionUtils.ts +2 -3
  31. package/src/project/project.test-d.ts +93 -0
  32. package/src/project/project.test.ts +108 -10
  33. package/src/project/project.ts +152 -26
  34. package/src/projection/subscribeToStateAndFetchBatches.ts +4 -9
  35. package/src/projects/projects.test-d.ts +38 -0
  36. package/src/projects/projects.test.ts +104 -38
  37. package/src/projects/projects.ts +74 -14
  38. package/src/query/queryStore.ts +2 -3
  39. package/src/releases/releasesStore.test.ts +1 -1
  40. package/src/releases/releasesStore.ts +2 -2
  41. package/src/store/createSanityInstance.ts +3 -3
  42. package/src/telemetry/devMode.test.ts +8 -0
  43. package/src/telemetry/devMode.ts +10 -9
  44. package/src/telemetry/initTelemetry.test.ts +0 -17
  45. package/src/telemetry/initTelemetry.ts +2 -12
@@ -1,5 +1,5 @@
1
1
  import { getEnv } from "./createGroqSearchFilter.js";
2
- var version = "2.10.0";
2
+ var version = "2.11.0";
3
3
  const CORE_SDK_VERSION = getEnv("PKG_VERSION") || `${version}-development`;
4
4
  export {
5
5
  CORE_SDK_VERSION
@@ -1,4 +1,4 @@
1
- import { F as createGroqSearchFilter, Sr as isStudioConfig, U as getUsersKey, W as parseUsersKey, Y as getQueryKey, Z as parseQueryKey, a as isProjectUserNotFoundClientError, br as SanityInstance, ct as PREVIEW_PROJECTION, i as getClientErrorApiType, n as getClientErrorApiBody, r as getClientErrorApiDescription, st as transformProjectionToPreview, t as ApiErrorBody } from "../_chunks-dts/utils.js";
1
+ import { F as createGroqSearchFilter, Lr as SanityInstance, U as getUsersKey, W as parseUsersKey, Y as getQueryKey, Z as parseQueryKey, a as isProjectUserNotFoundClientError, ht as PREVIEW_PROJECTION, i as getClientErrorApiType, mt as transformProjectionToPreview, n as getClientErrorApiBody, r as getClientErrorApiDescription, t as ApiErrorBody, zr as isStudioConfig } from "../_chunks-dts/utils.js";
2
2
  import { SanityClient } from "@sanity/client";
3
3
  /**
4
4
  * Manages dev-mode telemetry for a single SDK instance.
@@ -61,4 +61,18 @@ declare function getTelemetryManager(instance: SanityInstance): TelemetryManager
61
61
  * @internal
62
62
  */
63
63
  declare function trackHookMounted(instance: SanityInstance, hookName: string): void;
64
- export { type ApiErrorBody, PREVIEW_PROJECTION, createGroqSearchFilter, getClientErrorApiBody, getClientErrorApiDescription, getClientErrorApiType, getQueryKey, getTelemetryManager, getUsersKey, initTelemetry, isProjectUserNotFoundClientError, isStudioConfig, parseQueryKey, parseUsersKey, trackHookMounted, transformProjectionToPreview };
64
+ /**
65
+ * Creates a shallow copy containing only the provided properties.
66
+ *
67
+ * @internal
68
+ */
69
+ declare function pickProperties<T extends object, K extends keyof T>(value: T, keys: readonly K[]): Pick<T, K>;
70
+ /**
71
+ * Compares values deeply across the plain object, array, map, and set shapes used by the SDK.
72
+ * This helper is intended for acyclic SDK data structures and does not guard against circular
73
+ * references.
74
+ *
75
+ * @internal
76
+ */
77
+ declare function isDeepEqual<T>(left: T, right: T): boolean;
78
+ export { type ApiErrorBody, PREVIEW_PROJECTION, createGroqSearchFilter, getClientErrorApiBody, getClientErrorApiDescription, getClientErrorApiType, getQueryKey, getTelemetryManager, getUsersKey, initTelemetry, isDeepEqual, isProjectUserNotFoundClientError, isStudioConfig, parseQueryKey, parseUsersKey, pickProperties, trackHookMounted, transformProjectionToPreview };
@@ -1,4 +1,4 @@
1
- import { PREVIEW_PROJECTION, createGroqSearchFilter, getClientErrorApiBody, getClientErrorApiDescription, getClientErrorApiType, getQueryKey, getUsersKey, isProjectUserNotFoundClientError, isStudioConfig, parseQueryKey, parseUsersKey, transformProjectionToPreview } from "../_chunks-es/createGroqSearchFilter.js";
1
+ import { PREVIEW_PROJECTION, createGroqSearchFilter, getClientErrorApiBody, getClientErrorApiDescription, getClientErrorApiType, getQueryKey, getUsersKey, isDeepEqual, isProjectUserNotFoundClientError, isStudioConfig, parseQueryKey, parseUsersKey, pickProperties, transformProjectionToPreview } from "../_chunks-es/createGroqSearchFilter.js";
2
2
  import { getTelemetryManager, initTelemetry, trackHookMounted } from "../_chunks-es/_internal.js";
3
3
  export {
4
4
  PREVIEW_PROJECTION,
@@ -10,10 +10,12 @@ export {
10
10
  getTelemetryManager,
11
11
  getUsersKey,
12
12
  initTelemetry,
13
+ isDeepEqual,
13
14
  isProjectUserNotFoundClientError,
14
15
  isStudioConfig,
15
16
  parseQueryKey,
16
17
  parseUsersKey,
18
+ pickProperties,
17
19
  trackHookMounted,
18
20
  transformProjectionToPreview
19
21
  };
package/dist/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import { $ as getProjectsState, $n as getClientState, $t as getDocumentState, A as isImportError, An as Logger, Ar as DocumentSource, At as SanityUser, B as loadMoreUsers, Bn as releaseNode, Br as isCanvasResource, Bt as applyDocumentActions, C as getIndexForKey, Cn as getDatasetsState, Cr as CanvasResource, Ct as TransportEvent, D as slicePath, Dn as LogContext, Dr as DatasetSource, Dt as Membership, E as jsonMatch, En as InstanceContext, Er as DatasetResource, Et as GetUsersOptions, F as createGroqSearchFilter, Fn as createProjectHandle, Fr as ProjectHandle, Ft as FavoriteStatusResponse, G as getPerspectiveState, Gn as releaseChannel, Gr as isMediaLibrarySource, Gt as DocumentEditedEvent, H as resolveUsers, Hn as destroyController, Hr as isDatasetResource, Ht as DocumentCreatedEvent, I as FetcherStore, In as NodeState, Ir as ReleasePerspective, It as getFavoritesState, J as QueryOptions, Jn as RequestNewTokenMessage, Jt as DocumentTransactionSubmissionResult, K as ReleaseDocument, Kn as FrameMessage, Kr as AuthConfig, Kt as DocumentEvent, L as FetcherStoreState, Ln as getNodeState, Lr as SanityConfig, Lt as resolveFavoritesState, M as Intent, Mn as createDatasetHandle, Mr as MediaLibraryResource, Mt as UserProfile, N as IntentFilter, Nn as createDocumentHandle, Nr as MediaLibrarySource, Nt as UsersGroupState, O as stringifyPath, On as LogLevel, Or as DocumentHandle, Ot as ResolveUserOptions, P as defineIntent, Pn as createDocumentTypeHandle, Pr as PerspectiveHandle, Pt as UsersStoreState, Q as resolveQuery, Qn as getClient, Qt as DocumentOptions, R as getUserState, Rn as ComlinkNodeState, Rr as StudioConfig, Rt as ActionsResult, S as SanityProject, Sn as unpublishDocument, Sr as isStudioConfig, St as StateEvent, T as joinPaths, Tn as configureLogging, Tr as DatasetHandle, Tt as GetUserOptions, U as getUsersKey, Un as getOrCreateChannel, Ur as isDatasetSource, Ut as DocumentDeletedEvent, V as resolveUser, Vn as ComlinkControllerState, Vr as isCanvasSource, Vt as ActionErrorEvent, W as parseUsersKey, Wn as getOrCreateController, Wr as isMediaLibraryResource, Wt as DocumentDiscardedEvent, X as getQueryState, Xn as ClientOptions, Xt as TransactionAcceptedEvent, Y as getQueryKey, Yn as WindowMessage, Yt as DocumentUnpublishedEvent, Z as parseQueryKey, Zn as ClientStoreState, Zt as TransactionRevertedEvent, _ as getTokenState, _n as createDocument, _r as agentPrompt, _t as ValidProjection, a as isProjectUserNotFoundClientError, an as DocumentPermissionsResult, ar as AgentGenerateOptions, at as ResolvePreviewOptions, b as Role, bn as editDocument, br as SanityInstance, bt as PresenceLocation, c as ErrorAuthState, cn as Selector, cr as AgentPatchResult, ct as PREVIEW_PROJECTION, d as LoggingInAuthState, dn as DeleteDocumentAction, dr as AgentTransformOptions, dt as PreviewMedia, en as getDocumentSyncStatus, er as logout, et as resolveProjects, f as getAuthState, fn as DiscardDocumentAction, fr as AgentTransformResult, ft as PreviewQueryResult, g as getLoginUrlState, gn as UnpublishDocumentAction, gr as agentPatch, gt as ProjectionValuePending, h as getIsInDashboardState, hn as PublishDocumentAction, hr as agentGenerate, ht as ValuePending, i as getClientErrorApiType, in as subscribeDocumentEvents, ir as AuthStateType, it as resolveProject, j as getCorsErrorProjectId, jn as LoggerConfig, jr as DocumentTypeHandle, jt as SanityUserResponse, k as CORE_SDK_VERSION, kn as LogNamespace, kr as DocumentResource, kt as ResolveUsersOptions, l as LoggedInAuthState, ln as StateSource, lr as AgentPromptOptions, lt as GetPreviewStateOptions, m as getDashboardOrganizationId, mn as EditDocumentAction, mr as AgentTranslateResult, mt as PreviewValue, n as getClientErrorApiBody, nn as resolveDocument, nr as observeOrganizationVerificationState, nt as getProjectionState, o as AuthState, on as PermissionDeniedReason, or as AgentGenerateResult, ot as resolvePreview, p as getCurrentUserState, pn as DocumentAction, pr as AgentTranslateOptions, pt as PreviewStoreState, q as getActiveReleasesState, qn as NewTokenResponseMessage, qr as AuthProvider, qt as DocumentPublishedEvent, r as getClientErrorApiDescription, rn as resolvePermissions, rr as OrgVerificationResult, rt as getProjectState, s as AuthStoreState, sn as JsonMatch, sr as AgentPatchOptions, st as transformProjectionToPreview, t as ApiErrorBody, tn as getPermissionsState, tr as handleAuthCallback, tt as resolveProjection, u as LoggedOutAuthState, un as CreateDocumentAction, ur as AgentPromptResult, ut as getPreviewState, v as setAuthToken, vn as deleteDocument, vr as agentTransform, vt as getPresence, w as getPathDepth, wn as resolveDatasets, wr as CanvasSource, wt as UserPresence, x as SanityDocument, xn as publishDocument, xr as createSanityInstance, xt as RollCallEvent, y as CurrentUser, yn as discardDocument, yr as agentTranslate, yt as DisconnectEvent, z as getUsersState, zn as getOrCreateNode, zr as TokenSource, zt as ApplyDocumentActionsOptions } from "./_chunks-dts/utils.js";
2
- export { ActionErrorEvent, ActionsResult, AgentGenerateOptions, AgentGenerateResult, AgentPatchOptions, AgentPatchResult, AgentPromptOptions, AgentPromptResult, AgentTransformOptions, AgentTransformResult, AgentTranslateOptions, AgentTranslateResult, ApiErrorBody, ApplyDocumentActionsOptions, AuthConfig, AuthProvider, AuthState, AuthStateType, AuthStoreState, CORE_SDK_VERSION, CanvasResource, CanvasSource, ClientOptions, ClientStoreState as ClientState, ComlinkControllerState, ComlinkNodeState, CreateDocumentAction, CurrentUser, DatasetHandle, DatasetResource, DatasetSource, DeleteDocumentAction, DiscardDocumentAction, DisconnectEvent, DocumentAction, DocumentCreatedEvent, DocumentDeletedEvent, DocumentDiscardedEvent, DocumentEditedEvent, DocumentEvent, DocumentHandle, DocumentOptions, DocumentPermissionsResult, DocumentPublishedEvent, DocumentResource, DocumentSource, DocumentTransactionSubmissionResult, DocumentTypeHandle, DocumentUnpublishedEvent, EditDocumentAction, ErrorAuthState, FavoriteStatusResponse, FetcherStore, FetcherStoreState, FrameMessage, GetPreviewStateOptions, GetUserOptions, GetUsersOptions, InstanceContext, Intent, IntentFilter, JsonMatch, LogContext, LogLevel, LogNamespace, LoggedInAuthState, LoggedOutAuthState, Logger, LoggerConfig, LoggingInAuthState, MediaLibraryResource, MediaLibrarySource, Membership, NewTokenResponseMessage, NodeState, OrgVerificationResult, PREVIEW_PROJECTION, PermissionDeniedReason, PerspectiveHandle, PresenceLocation, PreviewMedia, PreviewQueryResult, PreviewStoreState, PreviewValue, ProjectHandle, ProjectionValuePending, PublishDocumentAction, QueryOptions, ReleaseDocument, ReleasePerspective, RequestNewTokenMessage, ResolvePreviewOptions, ResolveUserOptions, ResolveUsersOptions, Role, RollCallEvent, SanityConfig, SanityDocument, SanityInstance, SanityProject, SanityUser, SanityUserResponse, Selector, StateEvent, StateSource, StudioConfig, TokenSource, TransactionAcceptedEvent, TransactionRevertedEvent, TransportEvent, UnpublishDocumentAction, UserPresence, UserProfile, UsersGroupState, UsersStoreState, ValidProjection, ValuePending, WindowMessage, agentGenerate, agentPatch, agentPrompt, agentTransform, agentTranslate, applyDocumentActions, configureLogging, createDatasetHandle, createDocument, createDocumentHandle, createDocumentTypeHandle, createGroqSearchFilter, createProjectHandle, 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, getPreviewState, getProjectState, getProjectionState, getProjectsState, getQueryKey, getQueryState, getTokenState, getUserState, getUsersKey, getUsersState, handleAuthCallback, isCanvasResource, isCanvasSource, isDatasetResource, isDatasetSource, isImportError, isMediaLibraryResource, isMediaLibrarySource, isProjectUserNotFoundClientError, isStudioConfig, joinPaths, jsonMatch, loadMoreUsers, logout, observeOrganizationVerificationState, parseQueryKey, parseUsersKey, publishDocument, releaseChannel, releaseNode, resolveDatasets, resolveDocument, resolveFavoritesState, resolvePermissions, resolvePreview, resolveProject, resolveProjection, resolveProjects, resolveQuery, resolveUser, resolveUsers, setAuthToken, slicePath, stringifyPath, subscribeDocumentEvents, transformProjectionToPreview, unpublishDocument };
1
+ import { $ as ProjectsOptions, $n as NodeState, $r as ReleasePerspective, $t as getFavoritesState, A as isImportError, An as DocumentAction, Ar as AgentTranslateOptions, At as TransportEvent, B as loadMoreUsers, Bn as getDatasetsState, Br as CanvasResource, Bt as UsersGroupState, C as getIndexForKey, Cn as PermissionDeniedReason, Cr as AgentGenerateResult, Ct as ProjectionValuePending, D as slicePath, Dn as CreateDocumentAction, Dr as AgentPromptResult, Dt as PresenceLocation, E as jsonMatch, En as StateSource, Er as AgentPromptOptions, Et as DisconnectEvent, F as createGroqSearchFilter, Fn as deleteDocument, Fr as agentTransform, Ft as ResolveUserOptions, G as getPerspectiveState, Gn as LogLevel, Gr as DocumentHandle, Gt as resolveOrganizations, H as resolveUsers, Hn as configureLogging, Hr as DatasetHandle, Ht as Organizations, I as FetcherStore, In as discardDocument, Ir as agentTranslate, It as ResolveUsersOptions, J as QueryOptions, Jn as LoggerConfig, Jr as DocumentTypeHandle, Jt as OrganizationMember, K as ReleaseDocument, Kn as LogNamespace, Kr as DocumentResource, Kt as Organization, L as FetcherStoreState, Ln as editDocument, Lr as SanityInstance, Lt as SanityUser, M as Intent, Mn as PublishDocumentAction, Mr as agentGenerate, Mt as GetUserOptions, N as IntentFilter, Nn as UnpublishDocumentAction, Nr as agentPatch, Nt as GetUsersOptions, O as stringifyPath, On as DeleteDocumentAction, Or as AgentTransformOptions, Ot as RollCallEvent, P as defineIntent, Pn as createDocument, Pr as agentPrompt, Pt as Membership, Q as resolveQuery, Qn as createProjectHandle, Qr as ProjectHandle, Qt as FavoriteStatusResponse, R as getUserState, Rn as publishDocument, Rr as createSanityInstance, Rt as SanityUserResponse, S as SanityProject, Sn as DocumentPermissionsResult, Sr as AgentGenerateOptions, St as ValuePending, T as joinPaths, Tn as Selector, Tr as AgentPatchResult, Tt as getPresence, U as getUsersKey, Un as InstanceContext, Ur as DatasetResource, Ut as OrganizationsOptions, V as resolveUser, Vn as resolveDatasets, Vr as CanvasSource, Vt as UsersStoreState, W as parseUsersKey, Wn as LogContext, Wr as DatasetSource, Wt as getOrganizationsState, X as getQueryState, Xn as createDocumentHandle, Xr as MediaLibrarySource, Xt as getOrganizationState, Y as getQueryKey, Yn as createDatasetHandle, Yr as MediaLibraryResource, Yt as OrganizationOptions, Z as parseQueryKey, Zn as createDocumentTypeHandle, Zr as PerspectiveHandle, Zt as resolveOrganization, _ as getTokenState, _n as getDocumentSyncStatus, _r as logout, _t as getPreviewState, a as isProjectUserNotFoundClientError, ai as isDatasetResource, an as DocumentCreatedEvent, ar as destroyController, at as ProjectBase, b as Role, bn as resolvePermissions, br as OrgVerificationResult, bt as PreviewStoreState, c as ErrorAuthState, ci as isMediaLibrarySource, cn as DocumentEditedEvent, cr as releaseChannel, ct as ProjectMetadata, d as LoggingInAuthState, dn as DocumentTransactionSubmissionResult, dr as RequestNewTokenMessage, dt as resolveProject, ei as SanityConfig, en as resolveFavoritesState, er as getNodeState, et as getProjectsState, f as getAuthState, fn as DocumentUnpublishedEvent, fr as WindowMessage, ft as ResolvePreviewOptions, g as getLoginUrlState, gn as getDocumentState, gr as getClientState, gt as GetPreviewStateOptions, h as getIsInDashboardState, hn as DocumentOptions, hr as getClient, ht as PREVIEW_PROJECTION, i as getClientErrorApiType, ii as isCanvasSource, in as ActionErrorEvent, ir as ComlinkControllerState, it as Project, j as getCorsErrorProjectId, jn as EditDocumentAction, jr as AgentTranslateResult, jt as UserPresence, k as CORE_SDK_VERSION, kn as DiscardDocumentAction, kr as AgentTransformResult, kt as StateEvent, l as LoggedInAuthState, li as AuthConfig, ln as DocumentEvent, lr as FrameMessage, lt as ProjectOptions, m as getDashboardOrganizationId, mn as TransactionRevertedEvent, mr as ClientStoreState, mt as transformProjectionToPreview, n as getClientErrorApiBody, ni as TokenSource, nn as ApplyDocumentActionsOptions, nr as getOrCreateNode, nt as resolveProjection, o as AuthState, oi as isDatasetSource, on as DocumentDeletedEvent, or as getOrCreateChannel, ot as ProjectMember, p as getCurrentUserState, pn as TransactionAcceptedEvent, pr as ClientOptions, pt as resolvePreview, q as getActiveReleasesState, qn as Logger, qr as DocumentSource, qt as OrganizationBase, r as getClientErrorApiDescription, ri as isCanvasResource, rn as applyDocumentActions, rr as releaseNode, rt as getProjectionState, s as AuthStoreState, si as isMediaLibraryResource, sn as DocumentDiscardedEvent, sr as getOrCreateController, st as ProjectMemberRole, t as ApiErrorBody, ti as StudioConfig, tn as ActionsResult, tr as ComlinkNodeState, tt as resolveProjects, u as LoggedOutAuthState, ui as AuthProvider, un as DocumentPublishedEvent, ur as NewTokenResponseMessage, ut as getProjectState, v as setAuthToken, vn as getPermissionsState, vr as handleAuthCallback, vt as PreviewMedia, w as getPathDepth, wn as JsonMatch, wr as AgentPatchOptions, wt as ValidProjection, x as SanityDocument, xn as subscribeDocumentEvents, xr as AuthStateType, xt as PreviewValue, y as CurrentUser, yn as resolveDocument, yr as observeOrganizationVerificationState, yt as PreviewQueryResult, z as getUsersState, zn as unpublishDocument, zr as isStudioConfig, zt as UserProfile } from "./_chunks-dts/utils.js";
2
+ export { ActionErrorEvent, ActionsResult, AgentGenerateOptions, AgentGenerateResult, AgentPatchOptions, AgentPatchResult, AgentPromptOptions, AgentPromptResult, AgentTransformOptions, AgentTransformResult, AgentTranslateOptions, AgentTranslateResult, ApiErrorBody, ApplyDocumentActionsOptions, AuthConfig, AuthProvider, AuthState, AuthStateType, AuthStoreState, CORE_SDK_VERSION, CanvasResource, CanvasSource, ClientOptions, ClientStoreState as ClientState, ComlinkControllerState, ComlinkNodeState, CreateDocumentAction, CurrentUser, DatasetHandle, DatasetResource, DatasetSource, DeleteDocumentAction, DiscardDocumentAction, DisconnectEvent, DocumentAction, DocumentCreatedEvent, DocumentDeletedEvent, DocumentDiscardedEvent, DocumentEditedEvent, DocumentEvent, DocumentHandle, DocumentOptions, DocumentPermissionsResult, DocumentPublishedEvent, DocumentResource, DocumentSource, DocumentTransactionSubmissionResult, DocumentTypeHandle, DocumentUnpublishedEvent, EditDocumentAction, ErrorAuthState, FavoriteStatusResponse, FetcherStore, FetcherStoreState, FrameMessage, GetPreviewStateOptions, GetUserOptions, GetUsersOptions, InstanceContext, Intent, IntentFilter, JsonMatch, LogContext, LogLevel, LogNamespace, LoggedInAuthState, LoggedOutAuthState, Logger, LoggerConfig, LoggingInAuthState, MediaLibraryResource, MediaLibrarySource, Membership, NewTokenResponseMessage, NodeState, OrgVerificationResult, Organization, OrganizationBase, OrganizationMember, OrganizationOptions, Organizations, OrganizationsOptions, PREVIEW_PROJECTION, PermissionDeniedReason, PerspectiveHandle, PresenceLocation, PreviewMedia, PreviewQueryResult, PreviewStoreState, PreviewValue, Project, ProjectBase, ProjectHandle, ProjectMember, ProjectMemberRole, ProjectMetadata, ProjectOptions, ProjectionValuePending, ProjectsOptions, PublishDocumentAction, QueryOptions, ReleaseDocument, ReleasePerspective, RequestNewTokenMessage, ResolvePreviewOptions, ResolveUserOptions, ResolveUsersOptions, Role, RollCallEvent, SanityConfig, SanityDocument, SanityInstance, SanityProject, SanityUser, SanityUserResponse, Selector, StateEvent, StateSource, StudioConfig, TokenSource, TransactionAcceptedEvent, TransactionRevertedEvent, TransportEvent, UnpublishDocumentAction, UserPresence, UserProfile, UsersGroupState, UsersStoreState, ValidProjection, ValuePending, WindowMessage, agentGenerate, agentPatch, agentPrompt, agentTransform, agentTranslate, applyDocumentActions, configureLogging, createDatasetHandle, createDocument, createDocumentHandle, createDocumentTypeHandle, createGroqSearchFilter, createProjectHandle, 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, getOrganizationState, getOrganizationsState, getPathDepth, getPermissionsState, getPerspectiveState, getPresence, getPreviewState, getProjectState, getProjectionState, getProjectsState, getQueryKey, getQueryState, getTokenState, getUserState, getUsersKey, getUsersState, handleAuthCallback, isCanvasResource, isCanvasSource, isDatasetResource, isDatasetSource, isImportError, isMediaLibraryResource, isMediaLibrarySource, isProjectUserNotFoundClientError, isStudioConfig, joinPaths, jsonMatch, loadMoreUsers, logout, observeOrganizationVerificationState, parseQueryKey, parseUsersKey, publishDocument, releaseChannel, releaseNode, resolveDatasets, resolveDocument, resolveFavoritesState, resolveOrganization, resolveOrganizations, resolvePermissions, resolvePreview, resolveProject, resolveProjection, resolveProjects, resolveQuery, resolveUser, resolveUsers, setAuthToken, slicePath, stringifyPath, subscribeDocumentEvents, transformProjectionToPreview, unpublishDocument };
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { switchMap, from, firstValueFrom, EMPTY, asapScheduler, distinctUntilChanged, map as map$1, combineLatest, of, concatMap, withLatestFrom, filter as filter$1, concat, timer, throwError, first as first$1, Subject, takeUntil, share, partition, merge, shareReplay, tap as tap$1, catchError as catchError$1, startWith as startWith$1, pairwise as pairwise$1, groupBy as groupBy$1, mergeMap as mergeMap$1, throttle, race, skip, Observable, NEVER, fromEvent, Subscription, debounceTime, defer } from "rxjs";
2
- import { createLogger, pickProperties, insecureRandomId, getClientState, bindActionGlobally, createStateSourceAction, setCleanupTimeout, omitProperty, defineStore, authStore, AuthStateType, getCleanedUrl, getTokenFromLocation, createLoggedInAuthState, getAuthCode, REQUEST_TAG_PREFIX, DEFAULT_API_VERSION, getDefaultLocation, isDeepEqual, configureLogging as configureLogging$1, isReleasePerspective, isDatasetResource, bindActionByResource, isMediaLibraryResource, isCanvasResource, getUsersKey, addSubscription, parseUsersKey, getClient, PROJECT_API_VERSION, setUsersError, setUsersData, API_VERSION as API_VERSION$6, getDashboardOrganizationId as getDashboardOrganizationId$1, USERS_STATE_CLEAR_DELAY, removeSubscription, updateLastLoadMoreRequest, cancelRequest, initializeRequest, getTokenState, getQueryState, resolveQuery, bindActionByResourceAndPerspective, PREVIEW_PROJECTION, transformProjectionToPreview } from "./_chunks-es/createGroqSearchFilter.js";
2
+ import { createLogger, pickProperties, insecureRandomId, getClientState, bindActionGlobally, createStateSourceAction, setCleanupTimeout, omitProperty, defineStore, authStore, AuthStateType, getCleanedUrl, getTokenFromLocation, createLoggedInAuthState, getAuthCode, REQUEST_TAG_PREFIX, DEFAULT_API_VERSION, getDefaultLocation, isDeepEqual, configureLogging as configureLogging$1, isReleasePerspective, bindActionByResource, isDatasetResource, isMediaLibraryResource, isCanvasResource, getUsersKey, addSubscription, parseUsersKey, getClient, PROJECT_API_VERSION, setUsersError, setUsersData, API_VERSION as API_VERSION$8, getDashboardOrganizationId as getDashboardOrganizationId$1, USERS_STATE_CLEAR_DELAY, removeSubscription, updateLastLoadMoreRequest, cancelRequest, initializeRequest, getTokenState, getQueryState, resolveQuery, bindActionByResourceAndPerspective, PREVIEW_PROJECTION, transformProjectionToPreview } from "./_chunks-es/createGroqSearchFilter.js";
3
3
  import { createGroqSearchFilter, getActiveReleasesState, getAuthState, getClientErrorApiBody, getClientErrorApiDescription, getClientErrorApiType, getCurrentUserState, getIsInDashboardState, getLoginUrlState, getPerspectiveState, getQueryKey, isCanvasSource, isDatasetSource, isMediaLibrarySource, isProjectUserNotFoundClientError, isStudioConfig, parseQueryKey, setAuthToken } from "./_chunks-es/createGroqSearchFilter.js";
4
4
  import { first, switchMap as switchMap$1, groupBy, mergeMap, startWith, pairwise, filter, map, delay, tap, catchError, scan, share as share$1 } from "rxjs/operators";
5
5
  import { createController, createNode } from "@sanity/comlink";
@@ -91,41 +91,31 @@ function createSanityInstance(config = {}) {
91
91
  };
92
92
  return instance;
93
93
  }
94
- const API_VERSION$5 = "vX";
95
- function agentGenerate(instance, options) {
96
- return getClientState(instance, {
97
- apiVersion: API_VERSION$5,
98
- projectId: instance.config.projectId,
99
- dataset: instance.config.dataset
100
- }).observable.pipe(switchMap((client) => client.observable.agent.action.generate(options)));
94
+ const API_VERSION$7 = "vX";
95
+ function agentGenerate(instance, options, resource) {
96
+ return getClientState(instance, { apiVersion: API_VERSION$7, resource }).observable.pipe(
97
+ switchMap((client) => client.observable.agent.action.generate(options))
98
+ );
101
99
  }
102
- function agentTransform(instance, options) {
103
- return getClientState(instance, {
104
- apiVersion: API_VERSION$5,
105
- projectId: instance.config.projectId,
106
- dataset: instance.config.dataset
107
- }).observable.pipe(switchMap((client) => client.observable.agent.action.transform(options)));
100
+ function agentTransform(instance, options, resource) {
101
+ return getClientState(instance, { apiVersion: API_VERSION$7, resource }).observable.pipe(
102
+ switchMap((client) => client.observable.agent.action.transform(options))
103
+ );
108
104
  }
109
- function agentTranslate(instance, options) {
110
- return getClientState(instance, {
111
- apiVersion: API_VERSION$5,
112
- projectId: instance.config.projectId,
113
- dataset: instance.config.dataset
114
- }).observable.pipe(switchMap((client) => client.observable.agent.action.translate(options)));
105
+ function agentTranslate(instance, options, resource) {
106
+ return getClientState(instance, { apiVersion: API_VERSION$7, resource }).observable.pipe(
107
+ switchMap((client) => client.observable.agent.action.translate(options))
108
+ );
115
109
  }
116
- function agentPrompt(instance, options) {
117
- return getClientState(instance, {
118
- apiVersion: API_VERSION$5,
119
- projectId: instance.config.projectId,
120
- dataset: instance.config.dataset
121
- }).observable.pipe(switchMap((client) => from(client.agent.action.prompt(options))));
110
+ function agentPrompt(instance, options, resource) {
111
+ return getClientState(instance, { apiVersion: API_VERSION$7, resource }).observable.pipe(
112
+ switchMap((client) => from(client.agent.action.prompt(options)))
113
+ );
122
114
  }
123
- function agentPatch(instance, options) {
124
- return getClientState(instance, {
125
- apiVersion: API_VERSION$5,
126
- projectId: instance.config.projectId,
127
- dataset: instance.config.dataset
128
- }).observable.pipe(switchMap((client) => from(client.agent.action.patch(options))));
115
+ function agentPatch(instance, options, resource) {
116
+ return getClientState(instance, { apiVersion: API_VERSION$7, resource }).observable.pipe(
117
+ switchMap((client) => from(client.agent.action.patch(options)))
118
+ );
129
119
  }
130
120
  function compareProjectOrganization(projectId, projectOrganizationId, currentDashboardOrgId) {
131
121
  return projectOrganizationId !== currentDashboardOrgId ? {
@@ -265,27 +255,42 @@ function createFetcherStore({
265
255
  );
266
256
  return { getState, resolveState };
267
257
  }
268
- const API_VERSION$4 = "v2025-02-19", project = createFetcherStore({
258
+ const API_VERSION$6 = "v2025-02-19";
259
+ function normalizeProjectOptions(options) {
260
+ return {
261
+ includeMembers: options?.includeMembers ?? !0,
262
+ includeFeatures: options?.includeFeatures ?? !0
263
+ };
264
+ }
265
+ function resolveProjectId(instance, options) {
266
+ const projectId = options?.projectId ?? instance.config.projectId;
267
+ if (!projectId)
268
+ throw new Error("A projectId is required to use the project API.");
269
+ return projectId;
270
+ }
271
+ function getProjectCacheKey(instance, options) {
272
+ const projectId = resolveProjectId(instance, options), { includeMembers, includeFeatures } = normalizeProjectOptions(options);
273
+ return `project:${projectId}${includeMembers ? ":members" : ""}${includeFeatures ? ":features" : ""}`;
274
+ }
275
+ const project = createFetcherStore({
269
276
  name: "Project",
270
- getKey: (instance, options) => {
271
- const projectId = options?.projectId ?? instance.config.projectId;
272
- if (!projectId)
273
- throw new Error("A projectId is required to use the project API.");
274
- return projectId;
275
- },
276
- fetcher: (instance) => (options = {}) => {
277
- const projectId = options.projectId ?? instance.config.projectId;
277
+ getKey: getProjectCacheKey,
278
+ fetcher: (instance) => (options) => {
279
+ const projectId = resolveProjectId(instance, options);
278
280
  return getClientState(instance, {
279
- apiVersion: API_VERSION$4,
280
- scope: "global",
281
- projectId
281
+ apiVersion: API_VERSION$6,
282
+ scope: "global"
282
283
  }).observable.pipe(
283
- switchMap(
284
- (client) => client.observable.projects.getById(
285
- // non-null assertion is fine with the above throwing
286
- projectId ?? instance.config.projectId
287
- )
288
- )
284
+ switchMap((client) => {
285
+ const normalized = normalizeProjectOptions(options), query = Object.fromEntries(
286
+ Object.entries(normalized).filter(([, value]) => value !== void 0).map(([key, value]) => [key, String(value)])
287
+ );
288
+ return client.observable.request({
289
+ uri: `/projects/${projectId}`,
290
+ query,
291
+ tag: "project.get"
292
+ });
293
+ })
289
294
  );
290
295
  }
291
296
  }), getProjectState = project.getState, resolveProject = project.resolveState, getDashboardOrganizationId = bindActionGlobally(
@@ -553,7 +558,7 @@ function configureLogging(config) {
553
558
  source: "programmatic"
554
559
  });
555
560
  }
556
- const API_VERSION$3 = "v2025-02-19", datasets = createFetcherStore({
561
+ const API_VERSION$5 = "v2025-02-19", datasets = createFetcherStore({
557
562
  name: "Datasets",
558
563
  getKey: (instance, options) => {
559
564
  const projectId = options?.projectId ?? instance.config.projectId;
@@ -562,7 +567,7 @@ const API_VERSION$3 = "v2025-02-19", datasets = createFetcherStore({
562
567
  return projectId;
563
568
  },
564
569
  fetcher: (instance) => (options) => getClientState(instance, {
565
- apiVersion: API_VERSION$3,
570
+ apiVersion: API_VERSION$5,
566
571
  // non-null assertion is fine because we check above
567
572
  projectId: options?.projectId ?? instance.config.projectId,
568
573
  useProjectHostname: !0
@@ -637,7 +642,7 @@ function discardDocument(doc) {
637
642
  documentId: effectiveDocumentId
638
643
  };
639
644
  }
640
- const DOCUMENT_STATE_CLEAR_DELAY = 1e3, INITIAL_OUTGOING_THROTTLE_TIME = 1e3, API_VERSION$2 = "v2025-05-06";
645
+ const DOCUMENT_STATE_CLEAR_DELAY = 1e3, INITIAL_OUTGOING_THROTTLE_TIME = 1e3, API_VERSION$4 = "v2025-05-06";
641
646
  function generateArrayKey(length = 12) {
642
647
  const numBytes = Math.ceil(length / 2), bytes = crypto.getRandomValues(new Uint8Array(numBytes));
643
648
  return Array.from(bytes, (byte) => byte.toString(16).padStart(2, "0")).join("").slice(0, length);
@@ -1977,12 +1982,11 @@ function getDocumentEvents(outgoing) {
1977
1982
  )
1978
1983
  );
1979
1984
  }
1980
- const API_VERSION$1 = "v2025-05-06";
1985
+ const API_VERSION$3 = "v2025-05-06";
1981
1986
  function createSharedListener(instance, resource) {
1982
1987
  const dispose$ = new Subject(), events$ = getClientState(instance, {
1983
- apiVersion: API_VERSION$1,
1984
- // TODO: remove in v3 when we're ready for everything to be queried via resource
1985
- resource: resource && !isDatasetResource(resource) ? resource : void 0
1988
+ apiVersion: API_VERSION$3,
1989
+ resource
1986
1990
  }).observable.pipe(
1987
1991
  switchMap(
1988
1992
  (client) => (
@@ -2019,9 +2023,8 @@ function createSharedListener(instance, resource) {
2019
2023
  function createFetchDocument(instance, resource) {
2020
2024
  return function(documentId) {
2021
2025
  return getClientState(instance, {
2022
- apiVersion: API_VERSION$1,
2023
- // TODO: remove in v3 when we're ready for everything to be queried via resource
2024
- resource: resource && !isDatasetResource(resource) ? resource : void 0
2026
+ apiVersion: API_VERSION$3,
2027
+ resource
2025
2028
  }).observable.pipe(
2026
2029
  switchMap((client) => createDocumentLoaderFromClient(client)(documentId)),
2027
2030
  map$1((result) => {
@@ -2185,9 +2188,8 @@ const _resolveDocument = bindActionByResource(
2185
2188
  distinctUntilChanged(),
2186
2189
  withLatestFrom(
2187
2190
  getClientState(instance, {
2188
- apiVersion: API_VERSION$2,
2189
- // TODO: remove in v3 when we're ready for everything to be queried via resource
2190
- resource: resource && !isDatasetResource(resource) ? resource : void 0
2191
+ apiVersion: API_VERSION$4,
2192
+ resource
2191
2193
  }).observable
2192
2194
  ),
2193
2195
  concatMap(([outgoing, client]) => {
@@ -2263,8 +2265,7 @@ const _resolveDocument = bindActionByResource(
2263
2265
  state,
2264
2266
  key: { resource }
2265
2267
  }) => {
2266
- const clientOptions = { apiVersion: API_VERSION$2 };
2267
- resource && !isDatasetResource(resource) && (clientOptions.resource = resource);
2268
+ const clientOptions = { apiVersion: API_VERSION$4, resource };
2268
2269
  let uri;
2269
2270
  if (resource && isDatasetResource(resource))
2270
2271
  uri = `/projects/${resource.projectId}/datasets/${resource.dataset}/acl`;
@@ -2385,7 +2386,75 @@ const favorites = createFetcherStore({
2385
2386
  })
2386
2387
  );
2387
2388
  }
2388
- }), getFavoritesState = favorites.getState, resolveFavoritesState = favorites.resolveState, usersStore = defineStore({
2389
+ }), getFavoritesState = favorites.getState, resolveFavoritesState = favorites.resolveState, API_VERSION$2 = "v2025-02-19";
2390
+ function resolveOrganizationId(options) {
2391
+ const organizationId = options?.organizationId;
2392
+ if (!organizationId)
2393
+ throw new Error("An organizationId is required to use the organization API.");
2394
+ return organizationId;
2395
+ }
2396
+ function normalizeOrganizationOptions$1(options) {
2397
+ return {
2398
+ includeMembers: options?.includeMembers ?? !1,
2399
+ includeFeatures: options?.includeFeatures ?? !1
2400
+ };
2401
+ }
2402
+ function getOrganizationCacheKey(_instance, options) {
2403
+ const organizationId = resolveOrganizationId(options), { includeMembers, includeFeatures } = normalizeOrganizationOptions$1(options);
2404
+ return `organization:${organizationId}${includeMembers ? ":members" : ""}${includeFeatures ? ":features" : ""}`;
2405
+ }
2406
+ const organization = createFetcherStore({
2407
+ name: "Organization",
2408
+ getKey: getOrganizationCacheKey,
2409
+ fetcher: (instance) => (options) => {
2410
+ const organizationId = resolveOrganizationId(options);
2411
+ return getClientState(instance, {
2412
+ apiVersion: API_VERSION$2,
2413
+ scope: "global"
2414
+ }).observable.pipe(
2415
+ switchMap((client) => {
2416
+ const normalized = normalizeOrganizationOptions$1(options), query = Object.fromEntries(
2417
+ Object.entries(normalized).filter(([, value]) => value !== void 0).map(([key, value]) => [key, String(value)])
2418
+ );
2419
+ return client.observable.request({
2420
+ uri: `/organizations/${organizationId}`,
2421
+ query,
2422
+ tag: "organization.get"
2423
+ });
2424
+ })
2425
+ );
2426
+ }
2427
+ }), getOrganizationState = organization.getState, resolveOrganization = organization.resolveState, API_VERSION$1 = "v2025-02-19";
2428
+ function normalizeOrganizationOptions(options) {
2429
+ return {
2430
+ includeImplicitMemberships: options?.includeImplicitMemberships ?? !1,
2431
+ includeMembers: options?.includeMembers ?? !1,
2432
+ includeFeatures: options?.includeFeatures ?? !1
2433
+ };
2434
+ }
2435
+ function getOrganizationsCacheKey(_instance, options) {
2436
+ const { includeMembers, includeFeatures, includeImplicitMemberships } = normalizeOrganizationOptions(options);
2437
+ return `organizations${includeMembers ? ":members" : ""}${includeFeatures ? ":features" : ""}${includeImplicitMemberships ? ":implicit" : ""}`;
2438
+ }
2439
+ const organizations = createFetcherStore({
2440
+ name: "Organizations",
2441
+ getKey: getOrganizationsCacheKey,
2442
+ fetcher: (instance) => (options) => getClientState(instance, {
2443
+ apiVersion: API_VERSION$1,
2444
+ scope: "global"
2445
+ }).observable.pipe(
2446
+ switchMap((client) => {
2447
+ const normalized = normalizeOrganizationOptions(options), query = Object.fromEntries(
2448
+ Object.entries(normalized).filter(([, value]) => value !== void 0).map(([key, value]) => [key, String(value)])
2449
+ );
2450
+ return client.observable.request({
2451
+ uri: "/organizations",
2452
+ query,
2453
+ tag: "organizations.get"
2454
+ });
2455
+ })
2456
+ )
2457
+ }), getOrganizationsState = organizations.getState, resolveOrganizations = organizations.resolveState, usersStore = defineStore({
2389
2458
  name: "UsersStore",
2390
2459
  getInitialState: () => ({ users: {} }),
2391
2460
  initialize: (context) => {
@@ -2451,7 +2520,7 @@ const favorites = createFetcherStore({
2451
2520
  );
2452
2521
  const scope = userId.startsWith("g") ? "global" : void 0, client = getClient(instance, {
2453
2522
  scope,
2454
- apiVersion: API_VERSION$6
2523
+ apiVersion: API_VERSION$8
2455
2524
  }), resourceType2 = options.resourceType || "project", resourceId = resourceType2 === "organization" ? options.organizationId : options.projectId;
2456
2525
  return resourceId ? client.observable.request({
2457
2526
  method: "GET",
@@ -2471,7 +2540,7 @@ const favorites = createFetcherStore({
2471
2540
  filter$1((i) => typeof i == "string")
2472
2541
  ), resource$ = resourceType === "project" ? projectId ? of({ type: "project", id: projectId }) : throwError(() => new Error("Project ID required for this API.")) : organizationId$.pipe(map$1((id) => ({ type: "organization", id }))), client$ = getClientState(instance, {
2473
2542
  scope: "global",
2474
- apiVersion: API_VERSION$6
2543
+ apiVersion: API_VERSION$8
2475
2544
  }).observable, loadMore$ = state.observable.pipe(
2476
2545
  map$1((s) => s.users[group$.key]?.lastLoadMoreRequest),
2477
2546
  distinctUntilChanged()
@@ -2876,8 +2945,7 @@ const BATCH_DEBOUNCE_TIME = 50, isSetEqual = (a, b) => a.size === b.size && Arra
2876
2945
  params,
2877
2946
  tag: PROJECTION_TAG,
2878
2947
  perspective,
2879
- // temporary guard here until we're ready for everything to be queried via global API
2880
- ...resource && !isDatasetResource(resource) ? { resource } : {}
2948
+ resource
2881
2949
  }), subscription = defer(() => getCurrent() === void 0 ? from(
2882
2950
  resolveQuery(instance, {
2883
2951
  query,
@@ -2885,8 +2953,7 @@ const BATCH_DEBOUNCE_TIME = 50, isSetEqual = (a, b) => a.size === b.size && Arra
2885
2953
  tag: PROJECTION_TAG,
2886
2954
  signal: controller.signal,
2887
2955
  perspective,
2888
- // temporary guard here until we're ready for everything to be queried via global API in v3
2889
- ...resource && !isDatasetResource(resource) ? { resource } : {}
2956
+ resource
2890
2957
  })
2891
2958
  ).pipe(switchMap(() => observable)) : observable).pipe(filter$1((result) => result !== void 0)).subscribe(observer);
2892
2959
  return () => {
@@ -2898,8 +2965,7 @@ const BATCH_DEBOUNCE_TIME = 50, isSetEqual = (a, b) => a.size === b.size && Arra
2898
2965
  params: statusParams,
2899
2966
  tag: PROJECTION_TAG,
2900
2967
  perspective: "raw",
2901
- // temporary guard here until we're ready for everything to be queried via global API
2902
- ...resource && !isDatasetResource(resource) ? { resource } : {}
2968
+ resource
2903
2969
  }), subscription = defer(() => getCurrent() === void 0 ? from(
2904
2970
  resolveQuery(instance, {
2905
2971
  query: statusQuery,
@@ -2907,8 +2973,7 @@ const BATCH_DEBOUNCE_TIME = 50, isSetEqual = (a, b) => a.size === b.size && Arra
2907
2973
  tag: PROJECTION_TAG,
2908
2974
  signal: controller.signal,
2909
2975
  perspective: "raw",
2910
- // temporary guard here until we're ready for everything to be queried via global API
2911
- ...resource && !isDatasetResource(resource) ? { resource } : {}
2976
+ resource
2912
2977
  })
2913
2978
  ).pipe(switchMap(() => observable)) : observable).pipe(filter$1((result) => result !== void 0)).subscribe(observer);
2914
2979
  return () => {
@@ -3074,23 +3139,34 @@ async function resolvePreview(instance, options) {
3074
3139
  isPending: projectionResult.isPending
3075
3140
  } : { data: null, isPending: projectionResult.isPending };
3076
3141
  }
3077
- const API_VERSION = "v2025-02-19", projects = createFetcherStore({
3142
+ const API_VERSION = "v2025-02-19";
3143
+ function normalizeProjectsOptions(options) {
3144
+ return {
3145
+ organizationId: options?.organizationId,
3146
+ includeMembers: options?.includeMembers ?? !1,
3147
+ includeFeatures: options?.includeFeatures ?? !0,
3148
+ onlyExplicitMembership: options?.onlyExplicitMembership ?? !1
3149
+ };
3150
+ }
3151
+ function getProjectsCacheKey(_instance, options) {
3152
+ const { organizationId, includeMembers, includeFeatures, onlyExplicitMembership } = normalizeProjectsOptions(options);
3153
+ return `projects${organizationId ? `:org:${organizationId}` : ""}${includeMembers ? ":members" : ""}${includeFeatures ? ":features" : ""}${onlyExplicitMembership ? ":explicit" : ""}`;
3154
+ }
3155
+ const projects = createFetcherStore({
3078
3156
  name: "Projects",
3079
- getKey: (_instance, options) => {
3080
- const orgKey = options?.organizationId ? `:org:${options.organizationId}` : "", membersKey = options?.includeMembers === !1 ? ":no-members" : "";
3081
- return `projects${orgKey}${membersKey}`;
3082
- },
3157
+ getKey: getProjectsCacheKey,
3083
3158
  fetcher: (instance) => (options) => getClientState(instance, {
3084
3159
  apiVersion: API_VERSION,
3085
- scope: "global",
3086
- requestTagPrefix: "sanity.sdk.projects"
3160
+ scope: "global"
3087
3161
  }).observable.pipe(
3088
3162
  switchMap((client) => {
3089
- const organizationId = options?.organizationId;
3090
- return client.observable.projects.list({
3091
- // client method has a type that expects false | undefined
3092
- includeMembers: options?.includeMembers ? void 0 : !1,
3093
- organizationId
3163
+ const normalized = normalizeProjectsOptions(options), query = Object.fromEntries(
3164
+ Object.entries(normalized).filter(([, value]) => value !== void 0).map(([key, value]) => [key, String(value)])
3165
+ );
3166
+ return client.observable.request({
3167
+ uri: "/projects",
3168
+ query,
3169
+ tag: "projects.get"
3094
3170
  });
3095
3171
  })
3096
3172
  )
@@ -3203,6 +3279,8 @@ export {
3203
3279
  getOrCreateChannel,
3204
3280
  getOrCreateController,
3205
3281
  getOrCreateNode,
3282
+ getOrganizationState,
3283
+ getOrganizationsState,
3206
3284
  getPathDepth,
3207
3285
  getPermissionsState,
3208
3286
  getPerspectiveState,
@@ -3240,6 +3318,8 @@ export {
3240
3318
  resolveDatasets,
3241
3319
  resolveDocument,
3242
3320
  resolveFavoritesState,
3321
+ resolveOrganization,
3322
+ resolveOrganizations,
3243
3323
  resolvePermissions,
3244
3324
  resolvePreview,
3245
3325
  resolveProject,