@sanity/sdk-react 2.11.0 → 2.12.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.
package/dist/index.d.ts CHANGED
@@ -824,6 +824,18 @@ declare type Updater<TValue> = TValue | ((currentValue: TValue) => TValue)
824
824
  /**
825
825
  * @public
826
826
  * @function
827
+ *
828
+ * Returns the active releases for the current project,
829
+ * represented as a list of release documents.
830
+ *
831
+ * @returns The active releases for the current project.
832
+ * @category Releases
833
+ * @example
834
+ * ```tsx
835
+ * import {useActiveReleases} from '@sanity/sdk-react'
836
+ *
837
+ * const activeReleases = useActiveReleases()
838
+ * ```
827
839
  */
828
840
  export declare function useActiveReleases(
829
841
  options?: WithResourceNameSupport<SanityConfig> | undefined,
@@ -1352,6 +1364,35 @@ export declare function useAgentTranslate(
1352
1364
  resourceHandle?: ResourceHandle,
1353
1365
  ): (options: AgentTranslateOptions) => Subscribable<unknown>
1354
1366
 
1367
+ /**
1368
+ * @public
1369
+ * @function
1370
+ *
1371
+ * Returns every release the dataset has — including `archived`, `published`,
1372
+ * and mid-transition states (`archiving`, `unarchiving`, `publishing`,
1373
+ * `scheduling`).
1374
+ *
1375
+ * Use this hook when you're building a release-management UI (listing
1376
+ * releases, surfacing lifecycle controls, etc.) so a release stays visible
1377
+ * across its full lifecycle — including after it's been published or
1378
+ * archived. For perspective / content queries, prefer
1379
+ * {@link useActiveReleases}, which filters to releases that still affect
1380
+ * what's queryable.
1381
+ *
1382
+ * @returns Every release for the current project, sorted to match the order
1383
+ * used by {@link useActiveReleases}.
1384
+ * @category Releases
1385
+ * @example
1386
+ * ```tsx
1387
+ * import {useAllReleases} from '@sanity/sdk-react'
1388
+ *
1389
+ * const releases = useAllReleases()
1390
+ * ```
1391
+ */
1392
+ export declare function useAllReleases(
1393
+ options?: WithResourceNameSupport<SanityConfig> | undefined,
1394
+ ): ReleaseDocument[]
1395
+
1355
1396
  /**
1356
1397
  * @public
1357
1398
  */
package/dist/index.js CHANGED
@@ -1,10 +1,10 @@
1
1
  import { jsx, jsxs, Fragment } from "react/jsx-runtime";
2
2
  import { c } from "react-compiler-runtime";
3
3
  import { ClientError, CorsOriginError } from "@sanity/client";
4
- import { getAuthState, getNodeState, getIsInDashboardState, isStudioConfig, setAuthToken, AuthStateType, getLoginUrlState, observeOrganizationVerificationState, handleAuthCallback, logout, isProjectUserNotFoundClientError, getClientErrorApiDescription, getClientErrorApiBody, isImportError, getCorsErrorProjectId, createSanityInstance, isDatasetResource, agentGenerate, agentPatch, agentPrompt, agentTransform, agentTranslate, getTokenState, getCurrentUserState, getDashboardOrganizationId, getClientState, getOrCreateController, getOrCreateChannel, releaseChannel, isMediaLibraryResource, isCanvasResource, getFavoritesState, resolveFavoritesState, resolveDatasets, getDatasetsState, applyDocumentActions, resolveDocument, getDocumentState, subscribeDocumentEvents, getPermissionsState, getDocumentSyncStatus, editDocument, getQueryKey, parseQueryKey, getQueryState, resolveQuery, createGroqSearchFilter, resolveOrganization, getOrganizationState, resolveOrganizations, getOrganizationsState, getPresence, getProjectionState, resolveProjection, transformProjectionToPreview, PREVIEW_PROJECTION, resolveProject, getProjectState, resolveProjects, getProjectsState, getActiveReleasesState, getPerspectiveState, getUsersKey, parseUsersKey, getUsersState, resolveUsers, loadMoreUsers } from "@sanity/sdk";
4
+ import { getAuthState, getNodeState, getIsInDashboardState, isStudioConfig, setAuthToken, AuthStateType, getLoginUrlState, observeOrganizationVerificationState, handleAuthCallback, logout, isProjectUserNotFoundClientError, getClientErrorApiDescription, getClientErrorApiBody, isImportError, getCorsErrorProjectId, createSanityInstance, isDatasetResource, agentGenerate, agentPatch, agentPrompt, agentTransform, agentTranslate, getTokenState, getCurrentUserState, getDashboardOrganizationId, getClientState, getOrCreateController, getOrCreateChannel, releaseChannel, isMediaLibraryResource, isCanvasResource, getFavoritesState, resolveFavoritesState, resolveDatasets, getDatasetsState, applyDocumentActions, resolveDocument, getDocumentState, subscribeDocumentEvents, getPermissionsState, getDocumentSyncStatus, editDocument, getQueryKey, parseQueryKey, getQueryState, resolveQuery, createGroqSearchFilter, resolveOrganization, getOrganizationState, resolveOrganizations, getOrganizationsState, getPresence, getProjectionState, resolveProjection, transformProjectionToPreview, PREVIEW_PROJECTION, resolveProject, getProjectState, resolveProjects, getProjectsState, getActiveReleasesState, getAllReleasesState, getPerspectiveState, getUsersKey, parseUsersKey, getUsersState, resolveUsers, loadMoreUsers } from "@sanity/sdk";
5
5
  export * from "@sanity/sdk";
6
6
  import { createContext, useContext, useSyncExternalStore, useRef, useEffect, useState, Suspense, StrictMode, useCallback, useMemo, useInsertionEffect, useTransition } from "react";
7
- import { ErrorBoundary } from "react-error-boundary";
7
+ import { getErrorMessage, ErrorBoundary } from "react-error-boundary";
8
8
  import { SDK_CHANNEL_NAME, SDK_NODE_NAME } from "@sanity/message-protocol";
9
9
  import { firstValueFrom, filter, identity, Observable, startWith, distinctUntilChanged, switchMap, EMPTY } from "rxjs";
10
10
  import { initTelemetry, isDeepEqual, trackHookMounted, pickProperties } from "@sanity/sdk/_internal";
@@ -288,7 +288,7 @@ function CorsErrorComponent(t0) {
288
288
  t1 = t3;
289
289
  const corsUrl = t1;
290
290
  let t4;
291
- return $[2] !== corsUrl || $[3] !== error?.message || $[4] !== projectId ? (t4 = /* @__PURE__ */ jsx(Error$1, { heading: "Before you continue\u2026", ...projectId ? {
291
+ return $[2] !== corsUrl || $[3] !== error || $[4] !== projectId ? (t4 = /* @__PURE__ */ jsx(Error$1, { heading: "Before you continue\u2026", ...projectId ? {
292
292
  description: "To access your content, you need to <strong>add the following URL as a CORS origin</strong> to your Sanity project.",
293
293
  code: origin,
294
294
  cta: {
@@ -296,8 +296,8 @@ function CorsErrorComponent(t0) {
296
296
  href: corsUrl
297
297
  }
298
298
  } : {
299
- description: error?.message
300
- } }), $[2] = corsUrl, $[3] = error?.message, $[4] = projectId, $[5] = t4) : t4 = $[5], t4;
299
+ description: getErrorMessage(error)
300
+ } }), $[2] = corsUrl, $[3] = error, $[4] = projectId, $[5] = t4) : t4 = $[5], t4;
301
301
  }
302
302
  function isInIframe() {
303
303
  return typeof window < "u" && window.self !== window.top;
@@ -1735,6 +1735,18 @@ function useActiveReleases(options) {
1735
1735
  const normalizedOptions = useNormalizedResourceOptions(t0);
1736
1736
  return useActiveReleasesValue(normalizedOptions);
1737
1737
  }
1738
+ const useAllReleasesValue = createStateSourceHook({
1739
+ getState: getAllReleasesState,
1740
+ shouldSuspend: (instance, options) => getAllReleasesState(instance, options ?? {}).getCurrent() === void 0,
1741
+ suspender: (instance, options) => firstValueFrom(getAllReleasesState(instance, options ?? {}).observable.pipe(filter(Boolean)))
1742
+ });
1743
+ function useAllReleases(options) {
1744
+ const $ = c(2);
1745
+ let t0;
1746
+ $[0] !== options ? (t0 = options ?? {}, $[0] = options, $[1] = t0) : t0 = $[1];
1747
+ const normalizedOptions = useNormalizedResourceOptions(t0);
1748
+ return useAllReleasesValue(normalizedOptions);
1749
+ }
1738
1750
  const usePerspectiveValue = createStateSourceHook({
1739
1751
  getState: getPerspectiveState,
1740
1752
  shouldSuspend: (instance, options) => getPerspectiveState(instance, options).getCurrent() === void 0,
@@ -1801,7 +1813,7 @@ function useUsers(options) {
1801
1813
  loadMore
1802
1814
  };
1803
1815
  }
1804
- var version = "2.11.0";
1816
+ var version = "2.12.0";
1805
1817
  function getEnv(key) {
1806
1818
  if (typeof import.meta < "u" && import.meta.env)
1807
1819
  return import.meta.env[key];
@@ -1828,6 +1840,7 @@ export {
1828
1840
  useAgentResourceContext,
1829
1841
  useAgentTransform,
1830
1842
  useAgentTranslate,
1843
+ useAllReleases,
1831
1844
  useApplyDocumentActions,
1832
1845
  useAuthState,
1833
1846
  useAuthToken,