From 9d9f989287f0f36740c86f6a52b5d28334e2e6af Mon Sep 17 00:00:00 2001 From: Ryan Bonial Date: Wed, 30 Apr 2025 16:53:17 -0600 Subject: [PATCH 01/17] feat: add new token fetching via comlink --- packages/core/src/_exports/index.ts | 9 +- packages/core/src/auth/authStore.ts | 45 +++++ packages/core/src/client/clientStore.ts | 18 +- packages/core/src/comlink/types.ts | 15 ++ .../react/src/context/ComlinkTokenRefresh.tsx | 186 ++++++++++++++++++ 5 files changed, 266 insertions(+), 7 deletions(-) create mode 100644 packages/react/src/context/ComlinkTokenRefresh.tsx diff --git a/packages/core/src/_exports/index.ts b/packages/core/src/_exports/index.ts index 89fde067..774f120f 100644 --- a/packages/core/src/_exports/index.ts +++ b/packages/core/src/_exports/index.ts @@ -13,11 +13,13 @@ export { getAuthState, getCurrentUserState, getDashboardOrganizationId, + getIsInDashboardState, getLoginUrlState, getTokenState, type LoggedInAuthState, type LoggedOutAuthState, type LoggingInAuthState, + setAuthToken, } from '../auth/authStore' export {observeOrganizationVerificationState} from '../auth/getOrganizationVerificationState' export {handleAuthCallback} from '../auth/handleAuthCallback' @@ -33,7 +35,12 @@ export { } from '../comlink/controller/comlinkControllerStore' export type {ComlinkNodeState} from '../comlink/node/comlinkNodeStore' export {getOrCreateNode, releaseNode} from '../comlink/node/comlinkNodeStore' -export {type FrameMessage, type WindowMessage} from '../comlink/types' +export { + type FrameMessage, + type NewTokenResponseMessage, + type RequestNewTokenMessage, + type WindowMessage, +} from '../comlink/types' export {type AuthConfig, type AuthProvider} from '../config/authConfig' export { createDatasetHandle, diff --git a/packages/core/src/auth/authStore.ts b/packages/core/src/auth/authStore.ts index ca0080a4..aa140d3a 100644 --- a/packages/core/src/auth/authStore.ts +++ b/packages/core/src/auth/authStore.ts @@ -280,3 +280,48 @@ export const getDashboardOrganizationId = bindActionGlobally( authStore, createStateSourceAction(({state: {dashboardContext}}) => dashboardContext?.orgId), ) + +/** + * Returns a state source indicating if the SDK is running within a dashboard context. + * @public + */ +export const getIsInDashboardState = bindActionGlobally( + authStore, + createStateSourceAction( + ({state: {dashboardContext}}) => + // Check if dashboardContext exists and is not empty + !!dashboardContext && Object.keys(dashboardContext).length > 0, + ), +) + +/** + * Action to explicitly set the authentication token. + * Used internally by the Comlink token refresh. + * @internal + */ +export const setAuthToken = bindActionGlobally(authStore, ({state}, token: string | null) => { + const currentAuthState = state.get().authState + if (token) { + // Update state only if the new token is different or currently logged out + if (currentAuthState.type !== AuthStateType.LOGGED_IN || currentAuthState.token !== token) { + // This state update structure should trigger listeners in clientStore + state.set('setToken', { + authState: { + type: AuthStateType.LOGGED_IN, + token: token, + // Keep existing user or set to null? Setting to null forces refetch. + // Keep existing user to avoid unnecessary refetches if user data is still valid. + currentUser: + currentAuthState.type === AuthStateType.LOGGED_IN ? currentAuthState.currentUser : null, + }, + }) + } + } else { + // Handle setting token to null (logging out) + if (currentAuthState.type !== AuthStateType.LOGGED_OUT) { + state.set('setToken', { + authState: {type: AuthStateType.LOGGED_OUT, isDestroyingSession: false}, + }) + } + } +}) diff --git a/packages/core/src/client/clientStore.ts b/packages/core/src/client/clientStore.ts index 468e23a1..f9ade94f 100644 --- a/packages/core/src/client/clientStore.ts +++ b/packages/core/src/client/clientStore.ts @@ -38,7 +38,10 @@ const allowedKeys = Object.keys({ apiVersion: null, requestTagPrefix: null, useProjectHostname: null, -} satisfies Record) as (keyof ClientOptions)[] +} satisfies Record, null>) as (keyof Omit< + ClientOptions, + 'middleware' +>)[] const DEFAULT_CLIENT_CONFIG: ClientConfig = { apiVersion: DEFAULT_API_VERSION, @@ -136,8 +139,8 @@ const getClientConfigKey = (options: ClientOptions) => JSON.stringify(pick(optio */ export const getClient = bindActionGlobally( clientStore, - ({state, instance}, options: ClientOptions) => { - // Check for disallowed keys + ({state, instance}, options: ClientOptions, middleware?: unknown[]) => { + // Check for disallowed keys (excluding middleware) const providedKeys = Object.keys(options) as (keyof ClientOptions)[] const disallowedKeys = providedKeys.filter((key) => !allowedKeys.includes(key)) @@ -155,7 +158,7 @@ export const getClient = bindActionGlobally( const dataset = options.dataset ?? instance.config.dataset const apiHost = options.apiHost ?? instance.config.auth?.apiHost - const effectiveOptions: ClientOptions = { + const effectiveOptions: ClientConfig = { ...DEFAULT_CLIENT_CONFIG, ...((options.scope === 'global' || !projectId) && {useProjectHostname: false}), token: authMethod === 'cookie' ? undefined : (tokenFromState ?? undefined), @@ -163,6 +166,8 @@ export const getClient = bindActionGlobally( ...(projectId && {projectId}), ...(dataset && {dataset}), ...(apiHost && {apiHost}), + // eslint-disable-next-line @typescript-eslint/no-explicit-any + ...(middleware && {middleware: middleware as any}), } if (effectiveOptions.token === null || typeof effectiveOptions.token === 'undefined') { @@ -174,11 +179,12 @@ export const getClient = bindActionGlobally( delete effectiveOptions.withCredentials } - const key = getClientConfigKey(effectiveOptions) + // Key generation uses only standard options passed to getClient + const key = getClientConfigKey(options) // Use original options for key if (clients[key]) return clients[key] - const client = createClient(effectiveOptions) + const client = createClient(effectiveOptions) // Pass options including middleware here state.set('addClient', (prev) => ({clients: {...prev.clients, [key]: client}})) return client diff --git a/packages/core/src/comlink/types.ts b/packages/core/src/comlink/types.ts index be50a389..dc667af2 100644 --- a/packages/core/src/comlink/types.ts +++ b/packages/core/src/comlink/types.ts @@ -11,3 +11,18 @@ export type FrameMessage = Message * @public */ export type WindowMessage = Message + +/** + * @internal + */ +/** Message from SDK (iframe) to Parent (dashboard) to request a new token */ +export type RequestNewTokenMessage = { + type: 'dashboard/v1/auth/tokens/create' + payload?: undefined +} + +/** Message from Parent (dashboard) to SDK (iframe) with the new token */ +export type NewTokenResponseMessage = { + type: 'dashboard/v1/auth/tokens/create' + payload: {token: string | null; error?: string} +} diff --git a/packages/react/src/context/ComlinkTokenRefresh.tsx b/packages/react/src/context/ComlinkTokenRefresh.tsx new file mode 100644 index 00000000..f83ef270 --- /dev/null +++ b/packages/react/src/context/ComlinkTokenRefresh.tsx @@ -0,0 +1,186 @@ +import {type Status as ComlinkStatus} from '@sanity/comlink' // Import Status as ComlinkStatus +import { + type FrameMessage, + getIsInDashboardState, // <-- Import the new selector + type NewTokenResponseMessage, + type RequestNewTokenMessage, + setAuthToken, + type WindowMessage, +} from '@sanity/sdk' +import React, { + createContext, + type PropsWithChildren, + useCallback, + useContext, + useEffect, + useMemo, + useRef, + useState, +} from 'react' + +import {useWindowConnection} from '../hooks/comlink/useWindowConnection' // <-- Correct path to useWindowConnection +import {useSanityInstance} from '../hooks/context/useSanityInstance' // Import the instance hook + +// Define specific message types extending the base types for clarity +type SdkParentComlinkMessage = NewTokenResponseMessage | WindowMessage // Messages received by SDK +type SdkChildComlinkMessage = RequestNewTokenMessage | FrameMessage // Messages sent by SDK + +export type ComlinkTokenRefreshConfig = { + /** Enable the Comlink token refresh feature. Defaults to false */ + enabled?: boolean + /** Unique name for this SDK iframe instance's Comlink endpoint. Defaults to 'sanity-sdk-iframe' */ + comlinkName?: string + /** The name of the parent window's Comlink endpoint to connect to. Defaults to 'sanity-dashboard-parent' */ + parentName?: string + /** Timeout in ms for waiting for a token response from the parent. Defaults to 15000ms */ + responseTimeout?: number +} + +interface ComlinkTokenRefreshContextValue { + requestNewToken: () => void + isTokenRefreshInProgress: React.MutableRefObject + comlinkStatus: ComlinkStatus + isEnabled: boolean +} + +const ComlinkTokenRefreshContext = createContext(null) + +const DEFAULT_COMLINK_NAME = 'sanity-sdk-iframe' +const DEFAULT_PARENT_NAME = 'sanity-dashboard-parent' +const DEFAULT_RESPONSE_TIMEOUT = 15000 // 15 seconds + +export const ComlinkTokenRefreshProvider: React.FC< + PropsWithChildren +> = ({ + children, + enabled = false, // Default to disabled + comlinkName = DEFAULT_COMLINK_NAME, + parentName = DEFAULT_PARENT_NAME, + responseTimeout = DEFAULT_RESPONSE_TIMEOUT, +}) => { + const instance = useSanityInstance() // Get the instance + const [comlinkStatus, setComlinkStatus] = useState('idle') + const isTokenRefreshInProgress = useRef(false) + const timeoutRef = useRef(null) + + // Get the dashboard status value once + const isInDashboard = useMemo(() => getIsInDashboardState(instance).getCurrent(), [instance]) + + // Determine if the feature should be active + const isDashboardComlinkEnabled = enabled && isInDashboard + + const clearRefreshTimeout = useCallback(() => { + if (timeoutRef.current) { + clearTimeout(timeoutRef.current) + timeoutRef.current = null + } + }, []) + + // Conditionally connect only if operational + const connectionOptions = useMemo( + () => + isDashboardComlinkEnabled + ? { + name: comlinkName, + connectTo: parentName, + onStatus: setComlinkStatus, + onMessage: { + 'dashboard/v1/auth/tokens/create': (data: NewTokenResponseMessage['payload']) => { + clearRefreshTimeout() + // Re-check isDashboardComlinkEnabled in case props/context changed + if (!isDashboardComlinkEnabled) return + + if (data.token) { + setAuthToken(instance, data.token) + } + isTokenRefreshInProgress.current = false + }, + }, + } + : undefined, + // Add isDashboardComlinkEnabled to dependency array + [ + isDashboardComlinkEnabled, + comlinkName, + parentName, + setComlinkStatus, + clearRefreshTimeout, + instance, + ], + ) + + const {sendMessage} = useWindowConnection( + // eslint-disable-next-line @typescript-eslint/no-explicit-any + connectionOptions as any, + ) + + const requestNewToken = useCallback(() => { + // Check if operational before proceeding + if (!isDashboardComlinkEnabled) { + return + } + if (comlinkStatus !== 'connected') { + return + } + if (isTokenRefreshInProgress.current) { + return + } + + isTokenRefreshInProgress.current = true + clearRefreshTimeout() + + timeoutRef.current = setTimeout(() => { + if (isTokenRefreshInProgress.current) { + isTokenRefreshInProgress.current = false + } + timeoutRef.current = null + }, responseTimeout) + + try { + const messageType = 'dashboard/v1/auth/tokens/create' as const + sendMessage(messageType) + } catch { + isTokenRefreshInProgress.current = false + clearRefreshTimeout() + } + }, [isDashboardComlinkEnabled, sendMessage, comlinkStatus, responseTimeout, clearRefreshTimeout]) + + const contextValue = useMemo( + () => ({ + requestNewToken, + isTokenRefreshInProgress, + comlinkStatus, + // Expose isDashboardComlinkEnabled instead of isEnabled? + // Let's stick to isEnabled prop for clarity, checks happen internally. + isEnabled: enabled, + }), + [requestNewToken, isTokenRefreshInProgress, comlinkStatus, enabled], + ) + + useEffect(() => { + return () => { + clearRefreshTimeout() + } + }, [clearRefreshTimeout]) + + return ( + + {children} + + ) +} + +export const useComlinkTokenRefresh = (): ComlinkTokenRefreshContextValue => { + const context = useContext(ComlinkTokenRefreshContext) + if (!context) { + return { + requestNewToken: () => { + /* console.warn(...) */ + }, + isTokenRefreshInProgress: {current: false}, + comlinkStatus: 'idle', + isEnabled: false, + } + } + return context +} From b05ebdd9653db5a749863b02fb1fea6684da8ff3 Mon Sep 17 00:00:00 2001 From: Ryan Bonial Date: Fri, 30 May 2025 12:46:58 -0600 Subject: [PATCH 02/17] chore: update changelog --- packages/react/CHANGELOG.md | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/packages/react/CHANGELOG.md b/packages/react/CHANGELOG.md index 6cefd04e..8aef967e 100644 --- a/packages/react/CHANGELOG.md +++ b/packages/react/CHANGELOG.md @@ -2,39 +2,34 @@ ## [2.0.0](https://github.com/sanity-io/sdk/compare/sdk-react-v1.0.0...sdk-react-v2.0.0) (2025-05-23) - ### ⚠ BREAKING CHANGES -* change `status` to `_status` in projection and preview ([#527](https://github.com/sanity-io/sdk/issues/527)) +- change `status` to `_status` in projection and preview ([#527](https://github.com/sanity-io/sdk/issues/527)) ### Features -* **react:** add navigate function ([#529](https://github.com/sanity-io/sdk/issues/529)) ([8a5bcfc](https://github.com/sanity-io/sdk/commit/8a5bcfc570cf59c73579d3be16f5bef5abc65da7)) - +- **react:** add navigate function ([#529](https://github.com/sanity-io/sdk/issues/529)) ([8a5bcfc](https://github.com/sanity-io/sdk/commit/8a5bcfc570cf59c73579d3be16f5bef5abc65da7)) ### Bug Fixes -* change `status` to `_status` in projection and preview ([#527](https://github.com/sanity-io/sdk/issues/527)) ([79f6df6](https://github.com/sanity-io/sdk/commit/79f6df6fcf5479bb144447c246e093551ed8c865)) -* **deps:** update dependency @sanity/client to ^7.2.1 ([#526](https://github.com/sanity-io/sdk/issues/526)) ([34b4f26](https://github.com/sanity-io/sdk/commit/34b4f260c1d639414908dd2f1dd8f375e7d1b73e)) -* **deps:** update dependency @sanity/comlink to ^3.0.4 ([#543](https://github.com/sanity-io/sdk/issues/543)) ([e9672a8](https://github.com/sanity-io/sdk/commit/e9672a8747db70715e9547da50791b6135264046)) -* **docs:** use correct hook in TS doc ([#523](https://github.com/sanity-io/sdk/issues/523)) ([fe25a11](https://github.com/sanity-io/sdk/commit/fe25a1109a5a4c6a271645ce5cd978572a09b685)) - +- change `status` to `_status` in projection and preview ([#527](https://github.com/sanity-io/sdk/issues/527)) ([79f6df6](https://github.com/sanity-io/sdk/commit/79f6df6fcf5479bb144447c246e093551ed8c865)) +- **deps:** update dependency @sanity/client to ^7.2.1 ([#526](https://github.com/sanity-io/sdk/issues/526)) ([34b4f26](https://github.com/sanity-io/sdk/commit/34b4f260c1d639414908dd2f1dd8f375e7d1b73e)) +- **deps:** update dependency @sanity/comlink to ^3.0.4 ([#543](https://github.com/sanity-io/sdk/issues/543)) ([e9672a8](https://github.com/sanity-io/sdk/commit/e9672a8747db70715e9547da50791b6135264046)) +- **docs:** use correct hook in TS doc ([#523](https://github.com/sanity-io/sdk/issues/523)) ([fe25a11](https://github.com/sanity-io/sdk/commit/fe25a1109a5a4c6a271645ce5cd978572a09b685)) ### Documentation -* **react:** fix isConnected mentions in comink hook docs ([#521](https://github.com/sanity-io/sdk/issues/521)) ([2cc1bf1](https://github.com/sanity-io/sdk/commit/2cc1bf141cecba6ee6757e472ed65a73ad590cce)) - +- **react:** fix isConnected mentions in comink hook docs ([#521](https://github.com/sanity-io/sdk/issues/521)) ([2cc1bf1](https://github.com/sanity-io/sdk/commit/2cc1bf141cecba6ee6757e472ed65a73ad590cce)) ### Miscellaneous -* release 2.0.0 ([#544](https://github.com/sanity-io/sdk/issues/544)) ([048cb50](https://github.com/sanity-io/sdk/commit/048cb503ea2e7852c984c376e48ff74d2a7023be)) - +- release 2.0.0 ([#544](https://github.com/sanity-io/sdk/issues/544)) ([048cb50](https://github.com/sanity-io/sdk/commit/048cb503ea2e7852c984c376e48ff74d2a7023be)) ### Dependencies -* The following workspace dependencies were updated - * dependencies - * @sanity/sdk bumped to 2.0.0 +- The following workspace dependencies were updated + - dependencies + - @sanity/sdk bumped to 2.0.0 ## [1.0.0](https://github.com/sanity-io/sdk/compare/sdk-react-v1.0.0...sdk-react-v1.0.0) (2025-05-07) From ca35948511195f98f908cf5e2d3b4d99f809de5b Mon Sep 17 00:00:00 2001 From: Ryan Bonial Date: Fri, 30 May 2025 12:47:58 -0600 Subject: [PATCH 03/17] chore: update changelog --- packages/react/CHANGELOG.md | 692 ++++++++++++++++++++---------------- 1 file changed, 382 insertions(+), 310 deletions(-) diff --git a/packages/react/CHANGELOG.md b/packages/react/CHANGELOG.md index 8aef967e..9ba16a95 100644 --- a/packages/react/CHANGELOG.md +++ b/packages/react/CHANGELOG.md @@ -2,630 +2,702 @@ ## [2.0.0](https://github.com/sanity-io/sdk/compare/sdk-react-v1.0.0...sdk-react-v2.0.0) (2025-05-23) + ### ⚠ BREAKING CHANGES -- change `status` to `_status` in projection and preview ([#527](https://github.com/sanity-io/sdk/issues/527)) +* change `status` to `_status` in projection and preview ([#527](https://github.com/sanity-io/sdk/issues/527)) ### Features -- **react:** add navigate function ([#529](https://github.com/sanity-io/sdk/issues/529)) ([8a5bcfc](https://github.com/sanity-io/sdk/commit/8a5bcfc570cf59c73579d3be16f5bef5abc65da7)) +* **react:** add navigate function ([#529](https://github.com/sanity-io/sdk/issues/529)) ([8a5bcfc](https://github.com/sanity-io/sdk/commit/8a5bcfc570cf59c73579d3be16f5bef5abc65da7)) + ### Bug Fixes -- change `status` to `_status` in projection and preview ([#527](https://github.com/sanity-io/sdk/issues/527)) ([79f6df6](https://github.com/sanity-io/sdk/commit/79f6df6fcf5479bb144447c246e093551ed8c865)) -- **deps:** update dependency @sanity/client to ^7.2.1 ([#526](https://github.com/sanity-io/sdk/issues/526)) ([34b4f26](https://github.com/sanity-io/sdk/commit/34b4f260c1d639414908dd2f1dd8f375e7d1b73e)) -- **deps:** update dependency @sanity/comlink to ^3.0.4 ([#543](https://github.com/sanity-io/sdk/issues/543)) ([e9672a8](https://github.com/sanity-io/sdk/commit/e9672a8747db70715e9547da50791b6135264046)) -- **docs:** use correct hook in TS doc ([#523](https://github.com/sanity-io/sdk/issues/523)) ([fe25a11](https://github.com/sanity-io/sdk/commit/fe25a1109a5a4c6a271645ce5cd978572a09b685)) +* change `status` to `_status` in projection and preview ([#527](https://github.com/sanity-io/sdk/issues/527)) ([79f6df6](https://github.com/sanity-io/sdk/commit/79f6df6fcf5479bb144447c246e093551ed8c865)) +* **deps:** update dependency @sanity/client to ^7.2.1 ([#526](https://github.com/sanity-io/sdk/issues/526)) ([34b4f26](https://github.com/sanity-io/sdk/commit/34b4f260c1d639414908dd2f1dd8f375e7d1b73e)) +* **deps:** update dependency @sanity/comlink to ^3.0.4 ([#543](https://github.com/sanity-io/sdk/issues/543)) ([e9672a8](https://github.com/sanity-io/sdk/commit/e9672a8747db70715e9547da50791b6135264046)) +* **docs:** use correct hook in TS doc ([#523](https://github.com/sanity-io/sdk/issues/523)) ([fe25a11](https://github.com/sanity-io/sdk/commit/fe25a1109a5a4c6a271645ce5cd978572a09b685)) + ### Documentation -- **react:** fix isConnected mentions in comink hook docs ([#521](https://github.com/sanity-io/sdk/issues/521)) ([2cc1bf1](https://github.com/sanity-io/sdk/commit/2cc1bf141cecba6ee6757e472ed65a73ad590cce)) +* **react:** fix isConnected mentions in comink hook docs ([#521](https://github.com/sanity-io/sdk/issues/521)) ([2cc1bf1](https://github.com/sanity-io/sdk/commit/2cc1bf141cecba6ee6757e472ed65a73ad590cce)) + ### Miscellaneous -- release 2.0.0 ([#544](https://github.com/sanity-io/sdk/issues/544)) ([048cb50](https://github.com/sanity-io/sdk/commit/048cb503ea2e7852c984c376e48ff74d2a7023be)) +* release 2.0.0 ([#544](https://github.com/sanity-io/sdk/issues/544)) ([048cb50](https://github.com/sanity-io/sdk/commit/048cb503ea2e7852c984c376e48ff74d2a7023be)) + ### Dependencies -- The following workspace dependencies were updated - - dependencies - - @sanity/sdk bumped to 2.0.0 +* The following workspace dependencies were updated + * dependencies + * @sanity/sdk bumped to 2.0.0 ## [1.0.0](https://github.com/sanity-io/sdk/compare/sdk-react-v1.0.0...sdk-react-v1.0.0) (2025-05-07) + ### Miscellaneous -- release 1.0.0 ([#517](https://github.com/sanity-io/sdk/issues/517)) ([52c00a1](https://github.com/sanity-io/sdk/commit/52c00a1eb99a6a34681bba363207ebcf4a9b5371)) +* release 1.0.0 ([#517](https://github.com/sanity-io/sdk/issues/517)) ([52c00a1](https://github.com/sanity-io/sdk/commit/52c00a1eb99a6a34681bba363207ebcf4a9b5371)) + ### Dependencies -- The following workspace dependencies were updated - - dependencies - - @sanity/sdk bumped to 1.0.0 +* The following workspace dependencies were updated + * dependencies + * @sanity/sdk bumped to 1.0.0 ## [0.0.3](https://github.com/sanity-io/sdk/compare/sdk-react-v0.0.2...sdk-react-v0.0.3) (2025-05-07) + ### ⚠ BREAKING CHANGES -- bump versions ([#516](https://github.com/sanity-io/sdk/issues/516)) -- remove redundant guides: ([#511](https://github.com/sanity-io/sdk/issues/511)) -- rename useProjection to useDocumentProjection & rename usePreview to useDocumentPreview ([#508](https://github.com/sanity-io/sdk/issues/508)) +* bump versions ([#516](https://github.com/sanity-io/sdk/issues/516)) +* remove redundant guides: ([#511](https://github.com/sanity-io/sdk/issues/511)) +* rename useProjection to useDocumentProjection & rename usePreview to useDocumentPreview ([#508](https://github.com/sanity-io/sdk/issues/508)) ### Bug Fixes -- bump versions ([#516](https://github.com/sanity-io/sdk/issues/516)) ([3601ade](https://github.com/sanity-io/sdk/commit/3601adeebe986af4102f639500a754d585694d9e)) +* bump versions ([#516](https://github.com/sanity-io/sdk/issues/516)) ([3601ade](https://github.com/sanity-io/sdk/commit/3601adeebe986af4102f639500a754d585694d9e)) + ### Documentation -- remove redundant guides: ([#511](https://github.com/sanity-io/sdk/issues/511)) ([c7be7ac](https://github.com/sanity-io/sdk/commit/c7be7ac1170727496fdb725265bd3d51e02101f3)) -- update package readmes ([#513](https://github.com/sanity-io/sdk/issues/513)) ([aa79bc7](https://github.com/sanity-io/sdk/commit/aa79bc74e904cfcac119be415d871fc71fe17277)) +* remove redundant guides: ([#511](https://github.com/sanity-io/sdk/issues/511)) ([c7be7ac](https://github.com/sanity-io/sdk/commit/c7be7ac1170727496fdb725265bd3d51e02101f3)) +* update package readmes ([#513](https://github.com/sanity-io/sdk/issues/513)) ([aa79bc7](https://github.com/sanity-io/sdk/commit/aa79bc74e904cfcac119be415d871fc71fe17277)) + ### Miscellaneous -- rename useProjection to useDocumentProjection & rename usePreview to useDocumentPreview ([#508](https://github.com/sanity-io/sdk/issues/508)) ([324aec7](https://github.com/sanity-io/sdk/commit/324aec74f69b42bfca3b44934130eeb91f013528)) +* rename useProjection to useDocumentProjection & rename usePreview to useDocumentPreview ([#508](https://github.com/sanity-io/sdk/issues/508)) ([324aec7](https://github.com/sanity-io/sdk/commit/324aec74f69b42bfca3b44934130eeb91f013528)) + ### Dependencies -- The following workspace dependencies were updated - - dependencies - - @sanity/sdk bumped to 0.0.3 +* The following workspace dependencies were updated + * dependencies + * @sanity/sdk bumped to 0.0.3 ## [0.0.2](https://github.com/sanity-io/sdk/compare/sdk-react-v0.0.1...sdk-react-v0.0.2) (2025-05-06) + ### ⚠ BREAKING CHANGES -- make all comlink hooks suspend ([#504](https://github.com/sanity-io/sdk/issues/504)) +* make all comlink hooks suspend ([#504](https://github.com/sanity-io/sdk/issues/504)) ### Features -- make all comlink hooks suspend ([#504](https://github.com/sanity-io/sdk/issues/504)) ([d49bf0e](https://github.com/sanity-io/sdk/commit/d49bf0e4be9268d68dbec186ed3ba6afc075bedb)) +* make all comlink hooks suspend ([#504](https://github.com/sanity-io/sdk/issues/504)) ([d49bf0e](https://github.com/sanity-io/sdk/commit/d49bf0e4be9268d68dbec186ed3ba6afc075bedb)) + ### Bug Fixes -- **deps:** move react compiler to RC ([#505](https://github.com/sanity-io/sdk/issues/505)) ([217e0a2](https://github.com/sanity-io/sdk/commit/217e0a2fb31731c4f485a2d8eba9f7ebacedcba5)) +* **deps:** move react compiler to RC ([#505](https://github.com/sanity-io/sdk/issues/505)) ([217e0a2](https://github.com/sanity-io/sdk/commit/217e0a2fb31731c4f485a2d8eba9f7ebacedcba5)) + ### Dependencies -- The following workspace dependencies were updated - - dependencies - - @sanity/sdk bumped to 0.0.2 +* The following workspace dependencies were updated + * dependencies + * @sanity/sdk bumped to 0.0.2 ## [0.0.1](https://github.com/sanity-io/sdk/compare/sdk-react-v0.0.0...sdk-react-v0.0.1) (2025-05-02) + ### Bug Fixes -- **docs:** remove custom docs entrypoint names ([#498](https://github.com/sanity-io/sdk/issues/498)) ([4499e85](https://github.com/sanity-io/sdk/commit/4499e85a3a30a5086bceb164c19cb18c71376471)) +* **docs:** remove custom docs entrypoint names ([#498](https://github.com/sanity-io/sdk/issues/498)) ([4499e85](https://github.com/sanity-io/sdk/commit/4499e85a3a30a5086bceb164c19cb18c71376471)) + ### Dependencies -- The following workspace dependencies were updated - - dependencies - - @sanity/sdk bumped to 0.0.1 +* The following workspace dependencies were updated + * dependencies + * @sanity/sdk bumped to 0.0.1 ## 0.0.0 (2025-05-02) + ### ⚠ BREAKING CHANGES -- remove reference to SDKProvider and ResourceProvider in migration guide ([#493](https://github.com/sanity-io/sdk/issues/493)) +* remove reference to SDKProvider and ResourceProvider in migration guide ([#493](https://github.com/sanity-io/sdk/issues/493)) ### Bug Fixes -- **deps:** update dependency @sanity/message-protocol to ^0.12.0 ([#484](https://github.com/sanity-io/sdk/issues/484)) ([f3beb42](https://github.com/sanity-io/sdk/commit/f3beb42ddad7ad9bf7826783602d57be006c15ee)) +* **deps:** update dependency @sanity/message-protocol to ^0.12.0 ([#484](https://github.com/sanity-io/sdk/issues/484)) ([f3beb42](https://github.com/sanity-io/sdk/commit/f3beb42ddad7ad9bf7826783602d57be006c15ee)) + ### Documentation -- correct categories for new hooks ([#494](https://github.com/sanity-io/sdk/issues/494)) ([96da771](https://github.com/sanity-io/sdk/commit/96da771e061df6fef1570907275c6c7d1d760269)) -- remove reference to SDKProvider and ResourceProvider in migration guide ([#493](https://github.com/sanity-io/sdk/issues/493)) ([0c1bb0e](https://github.com/sanity-io/sdk/commit/0c1bb0e385f177ced9350c927617b0e37d8743fe)) +* correct categories for new hooks ([#494](https://github.com/sanity-io/sdk/issues/494)) ([96da771](https://github.com/sanity-io/sdk/commit/96da771e061df6fef1570907275c6c7d1d760269)) +* remove reference to SDKProvider and ResourceProvider in migration guide ([#493](https://github.com/sanity-io/sdk/issues/493)) ([0c1bb0e](https://github.com/sanity-io/sdk/commit/0c1bb0e385f177ced9350c927617b0e37d8743fe)) + ### Miscellaneous -- release 0.0.0 ([08c9acc](https://github.com/sanity-io/sdk/commit/08c9acc0a34954cd611a53753fac2b788b61da9b)) +* release 0.0.0 ([08c9acc](https://github.com/sanity-io/sdk/commit/08c9acc0a34954cd611a53753fac2b788b61da9b)) + ### Dependencies -- The following workspace dependencies were updated - - dependencies - - @sanity/sdk bumped to 0.0.0 +* The following workspace dependencies were updated + * dependencies + * @sanity/sdk bumped to 0.0.0 ## [0.0.0-alpha.31](https://github.com/sanity-io/sdk/compare/sdk-react-v0.0.0-alpha.30...sdk-react-v0.0.0-alpha.31) (2025-05-01) + ### Miscellaneous -- **sdk-react:** Synchronize sdk versions +* **sdk-react:** Synchronize sdk versions + ### Dependencies -- The following workspace dependencies were updated - - dependencies - - @sanity/sdk bumped to 0.0.0-alpha.31 +* The following workspace dependencies were updated + * dependencies + * @sanity/sdk bumped to 0.0.0-alpha.31 ## [0.0.0-alpha.30](https://github.com/sanity-io/sdk/compare/sdk-react-v0.0.0-alpha.29...sdk-react-v0.0.0-alpha.30) (2025-05-01) + ### ⚠ BREAKING CHANGES -- fetch favorites from dashboard ([#437](https://github.com/sanity-io/sdk/issues/437)) +* fetch favorites from dashboard ([#437](https://github.com/sanity-io/sdk/issues/437)) ### Features -- add releases store ([#420](https://github.com/sanity-io/sdk/issues/420)) ([b5a376c](https://github.com/sanity-io/sdk/commit/b5a376c86e700031fe1700fb55b7f0d1236aaea3)) -- fetch favorites from dashboard ([#437](https://github.com/sanity-io/sdk/issues/437)) ([1a8ecb8](https://github.com/sanity-io/sdk/commit/1a8ecb89217b05c6ed90699c7ee162592cedb896)) -- integrate typegen ([#452](https://github.com/sanity-io/sdk/issues/452)) ([8416864](https://github.com/sanity-io/sdk/commit/8416864533f0f14851e8e71c15be4a1596711b52)) -- verify projects match current org for dashboard apps ([#464](https://github.com/sanity-io/sdk/issues/464)) ([52c8c76](https://github.com/sanity-io/sdk/commit/52c8c7668f09b119d6ca618381e1a44d134612a3)) +* add releases store ([#420](https://github.com/sanity-io/sdk/issues/420)) ([b5a376c](https://github.com/sanity-io/sdk/commit/b5a376c86e700031fe1700fb55b7f0d1236aaea3)) +* fetch favorites from dashboard ([#437](https://github.com/sanity-io/sdk/issues/437)) ([1a8ecb8](https://github.com/sanity-io/sdk/commit/1a8ecb89217b05c6ed90699c7ee162592cedb896)) +* integrate typegen ([#452](https://github.com/sanity-io/sdk/issues/452)) ([8416864](https://github.com/sanity-io/sdk/commit/8416864533f0f14851e8e71c15be4a1596711b52)) +* verify projects match current org for dashboard apps ([#464](https://github.com/sanity-io/sdk/issues/464)) ([52c8c76](https://github.com/sanity-io/sdk/commit/52c8c7668f09b119d6ca618381e1a44d134612a3)) + ### Bug Fixes -- **deps:** update dependency @sanity/client to ^6.29.1 ([#466](https://github.com/sanity-io/sdk/issues/466)) ([f25ba2b](https://github.com/sanity-io/sdk/commit/f25ba2b2aa32e3c010a6adf5658367c6fa3e149e)) -- **deps:** update dependency @sanity/client to v7 ([#478](https://github.com/sanity-io/sdk/issues/478)) ([e5ed504](https://github.com/sanity-io/sdk/commit/e5ed5047c84c3864cdbebd2c158184d57dfdaff9)) -- fix useProjection example (results -> data) ([#460](https://github.com/sanity-io/sdk/issues/460)) ([46d7d51](https://github.com/sanity-io/sdk/commit/46d7d513cedaada7bd19df6f5e813e28f5976c8a)) +* **deps:** update dependency @sanity/client to ^6.29.1 ([#466](https://github.com/sanity-io/sdk/issues/466)) ([f25ba2b](https://github.com/sanity-io/sdk/commit/f25ba2b2aa32e3c010a6adf5658367c6fa3e149e)) +* **deps:** update dependency @sanity/client to v7 ([#478](https://github.com/sanity-io/sdk/issues/478)) ([e5ed504](https://github.com/sanity-io/sdk/commit/e5ed5047c84c3864cdbebd2c158184d57dfdaff9)) +* fix useProjection example (results -> data) ([#460](https://github.com/sanity-io/sdk/issues/460)) ([46d7d51](https://github.com/sanity-io/sdk/commit/46d7d513cedaada7bd19df6f5e813e28f5976c8a)) + ### Documentation -- cleanup for Apr 30 ([#479](https://github.com/sanity-io/sdk/issues/479)) ([8793c1e](https://github.com/sanity-io/sdk/commit/8793c1e0d93bc9184d9a65f6e11d35dc148e4ac5)) -- update readmes ([#474](https://github.com/sanity-io/sdk/issues/474)) ([042a853](https://github.com/sanity-io/sdk/commit/042a85316c8179b8a135abbae4d66a4e467f5ee0)) +* cleanup for Apr 30 ([#479](https://github.com/sanity-io/sdk/issues/479)) ([8793c1e](https://github.com/sanity-io/sdk/commit/8793c1e0d93bc9184d9a65f6e11d35dc148e4ac5)) +* update readmes ([#474](https://github.com/sanity-io/sdk/issues/474)) ([042a853](https://github.com/sanity-io/sdk/commit/042a85316c8179b8a135abbae4d66a4e467f5ee0)) + ### Dependencies -- The following workspace dependencies were updated - - dependencies - - @sanity/sdk bumped to 0.0.0-alpha.30 +* The following workspace dependencies were updated + * dependencies + * @sanity/sdk bumped to 0.0.0-alpha.30 ## [0.0.0-alpha.29](https://github.com/sanity-io/sdk/compare/sdk-react-v0.0.0-alpha.28...sdk-react-v0.0.0-alpha.29) (2025-04-23) + ### Bug Fixes -- **build:** fixes build to not include node libraries ([#456](https://github.com/sanity-io/sdk/issues/456)) ([11a8d8a](https://github.com/sanity-io/sdk/commit/11a8d8a6c35dcfd0eeba3f5ca926b5e263aa56e8)) +* **build:** fixes build to not include node libraries ([#456](https://github.com/sanity-io/sdk/issues/456)) ([11a8d8a](https://github.com/sanity-io/sdk/commit/11a8d8a6c35dcfd0eeba3f5ca926b5e263aa56e8)) + ### Documentation -- mark useDocumentPermissions as public ([#449](https://github.com/sanity-io/sdk/issues/449)) ([089798b](https://github.com/sanity-io/sdk/commit/089798bc5f714279ba6148ed8eb5f9ee116b6af4)) -- mark useProjection as public ([#447](https://github.com/sanity-io/sdk/issues/447)) ([ae0661b](https://github.com/sanity-io/sdk/commit/ae0661b1ae4d04d1dac3044e730c36066cc06094)) +* mark useDocumentPermissions as public ([#449](https://github.com/sanity-io/sdk/issues/449)) ([089798b](https://github.com/sanity-io/sdk/commit/089798bc5f714279ba6148ed8eb5f9ee116b6af4)) +* mark useProjection as public ([#447](https://github.com/sanity-io/sdk/issues/447)) ([ae0661b](https://github.com/sanity-io/sdk/commit/ae0661b1ae4d04d1dac3044e730c36066cc06094)) + ### Dependencies -- The following workspace dependencies were updated - - dependencies - - @sanity/sdk bumped to 0.0.0-alpha.29 +* The following workspace dependencies were updated + * dependencies + * @sanity/sdk bumped to 0.0.0-alpha.29 ## [0.0.0-alpha.28](https://github.com/sanity-io/sdk/compare/sdk-react-v0.0.0-alpha.27...sdk-react-v0.0.0-alpha.28) (2025-04-22) + ### Bug Fixes -- **core:** refactor calculatePermissions to fix initialization error ([#443](https://github.com/sanity-io/sdk/issues/443)) ([e59d6e5](https://github.com/sanity-io/sdk/commit/e59d6e54b1da22194446ffffc747ddbf0711f134)) -- update useNavigateToStudioDocument for new dashboard context ([#436](https://github.com/sanity-io/sdk/issues/436)) ([7d7bbd4](https://github.com/sanity-io/sdk/commit/7d7bbd401942aa2839479f5698be53c0af178017)) +* **core:** refactor calculatePermissions to fix initialization error ([#443](https://github.com/sanity-io/sdk/issues/443)) ([e59d6e5](https://github.com/sanity-io/sdk/commit/e59d6e54b1da22194446ffffc747ddbf0711f134)) +* update useNavigateToStudioDocument for new dashboard context ([#436](https://github.com/sanity-io/sdk/issues/436)) ([7d7bbd4](https://github.com/sanity-io/sdk/commit/7d7bbd401942aa2839479f5698be53c0af178017)) + ### Dependencies -- The following workspace dependencies were updated - - dependencies - - @sanity/sdk bumped to 0.0.0-alpha.28 +* The following workspace dependencies were updated + * dependencies + * @sanity/sdk bumped to 0.0.0-alpha.28 ## [0.0.0-alpha.27](https://github.com/sanity-io/sdk/compare/sdk-react-v0.0.0-alpha.26...sdk-react-v0.0.0-alpha.27) (2025-04-22) + ### Bug Fixes -- **react:** allow sdk-react to work in react 18 ([#389](https://github.com/sanity-io/sdk/issues/389)) ([783b2f9](https://github.com/sanity-io/sdk/commit/783b2f9bce5bf2731e2518bf6a21ccdd3a4a6749)) +* **react:** allow sdk-react to work in react 18 ([#389](https://github.com/sanity-io/sdk/issues/389)) ([783b2f9](https://github.com/sanity-io/sdk/commit/783b2f9bce5bf2731e2518bf6a21ccdd3a4a6749)) + ### Dependencies -- The following workspace dependencies were updated - - dependencies - - @sanity/sdk bumped to 0.0.0-alpha.27 +* The following workspace dependencies were updated + * dependencies + * @sanity/sdk bumped to 0.0.0-alpha.27 ## [0.0.0-alpha.26](https://github.com/sanity-io/sdk/compare/sdk-react-v0.0.0-alpha.25...sdk-react-v0.0.0-alpha.26) (2025-04-21) + ### Bug Fixes -- **auth:** ensure initial url does not contain an sid and improve error handling ([#418](https://github.com/sanity-io/sdk/issues/418)) ([4d76bfc](https://github.com/sanity-io/sdk/commit/4d76bfc52542896128efd7cbd6d5342f1c275cd5)) -- **deps:** update dependency @sanity/types to ^3.83.0 ([#412](https://github.com/sanity-io/sdk/issues/412)) ([b40b289](https://github.com/sanity-io/sdk/commit/b40b289ea67026e7f0a0b7a2f95486e7a27a71c1)) -- **deps:** update dependency rxjs to ^7.8.2 ([#427](https://github.com/sanity-io/sdk/issues/427)) ([cbbf964](https://github.com/sanity-io/sdk/commit/cbbf9645eb2b4d43746d6283e237fbdfd5068080)) -- **docs:** fix navigateToStudioDocument doc & type ([#417](https://github.com/sanity-io/sdk/issues/417)) ([e49e799](https://github.com/sanity-io/sdk/commit/e49e799632f0d569a126ed9f7986d6b51f829da3)) -- prevent bridge script addition if already loaded ([#428](https://github.com/sanity-io/sdk/issues/428)) ([7425a97](https://github.com/sanity-io/sdk/commit/7425a9794d357074ff433b051871dd9eaf454572)) +* **auth:** ensure initial url does not contain an sid and improve error handling ([#418](https://github.com/sanity-io/sdk/issues/418)) ([4d76bfc](https://github.com/sanity-io/sdk/commit/4d76bfc52542896128efd7cbd6d5342f1c275cd5)) +* **deps:** update dependency @sanity/types to ^3.83.0 ([#412](https://github.com/sanity-io/sdk/issues/412)) ([b40b289](https://github.com/sanity-io/sdk/commit/b40b289ea67026e7f0a0b7a2f95486e7a27a71c1)) +* **deps:** update dependency rxjs to ^7.8.2 ([#427](https://github.com/sanity-io/sdk/issues/427)) ([cbbf964](https://github.com/sanity-io/sdk/commit/cbbf9645eb2b4d43746d6283e237fbdfd5068080)) +* **docs:** fix navigateToStudioDocument doc & type ([#417](https://github.com/sanity-io/sdk/issues/417)) ([e49e799](https://github.com/sanity-io/sdk/commit/e49e799632f0d569a126ed9f7986d6b51f829da3)) +* prevent bridge script addition if already loaded ([#428](https://github.com/sanity-io/sdk/issues/428)) ([7425a97](https://github.com/sanity-io/sdk/commit/7425a9794d357074ff433b051871dd9eaf454572)) + ### Documentation -- fix duplication/entrypoints; add SDK Core note ([#430](https://github.com/sanity-io/sdk/issues/430)) ([f1046fa](https://github.com/sanity-io/sdk/commit/f1046faec1c70d3690ddc9b4d4f92d7c433178a2)) +* fix duplication/entrypoints; add SDK Core note ([#430](https://github.com/sanity-io/sdk/issues/430)) ([f1046fa](https://github.com/sanity-io/sdk/commit/f1046faec1c70d3690ddc9b4d4f92d7c433178a2)) + ### Dependencies -- The following workspace dependencies were updated - - dependencies - - @sanity/sdk bumped to 0.0.0-alpha.26 +* The following workspace dependencies were updated + * dependencies + * @sanity/sdk bumped to 0.0.0-alpha.26 ## [0.0.0-alpha.25](https://github.com/sanity-io/sdk/compare/v0.0.0-alpha.24...v0.0.0-alpha.25) (2025-04-09) + ### Features -- **core, react:** introduce createGroqSearchFilter utility for search ([#407](https://github.com/sanity-io/sdk/issues/407)) ([77766bb](https://github.com/sanity-io/sdk/commit/77766bbf3fdc7efef4cd8a24f0ca206bef3179ec)) +* **core, react:** introduce createGroqSearchFilter utility for search ([#407](https://github.com/sanity-io/sdk/issues/407)) ([77766bb](https://github.com/sanity-io/sdk/commit/77766bbf3fdc7efef4cd8a24f0ca206bef3179ec)) + ### Dependencies -- The following workspace dependencies were updated - - dependencies - - @sanity/sdk bumped to 0.0.0-alpha.25 +* The following workspace dependencies were updated + * dependencies + * @sanity/sdk bumped to 0.0.0-alpha.25 ## [0.0.0-alpha.24](https://github.com/sanity-io/sdk/compare/v0.0.0-alpha.23...v0.0.0-alpha.24) (2025-04-09) + ### ⚠ BREAKING CHANGES -- use hosted login for standalone apps ([#386](https://github.com/sanity-io/sdk/issues/386)) -- replace `sanityConfigs` prop with `config` prop in `` and `` -- replace `resourceId` concept with explicit `projectId` and `dataset` fields in handles -- rename `_type` to `documentType` in DocumentHandle interface and related usages -- rename `_id` to `documentId` in DocumentHandle interface and related usages -- update document hooks and actions to expect `DocumentHandle` props -- update project and dataset hooks to use `ProjectHandle` or `DatasetHandle` -- remove ``, introduce `` for configuration -- update `useManageFavorite` signature ([#360](https://github.com/sanity-io/sdk/issues/360)) -- rename usePermissions → useDocumentPermissions ([#365](https://github.com/sanity-io/sdk/issues/365)) -- rename useInfiniteList → useDocuments ([#363](https://github.com/sanity-io/sdk/issues/363)) -- rename usePaginatedList → usePaginatedDocuments ([#364](https://github.com/sanity-io/sdk/issues/364)) -- rename useActions → useDocumentActions and useActions → useDocumentActions ([#362](https://github.com/sanity-io/sdk/issues/362)) -- rename useHandleCallback → useHandleAuthCallback and HandleCallback → HandleAuthCallback ([#358](https://github.com/sanity-io/sdk/issues/358)) -- rename `results` to `data` for useProjection hook ([#335](https://github.com/sanity-io/sdk/issues/335)) -- rename `result` to `data` for usePreview hook ([#325](https://github.com/sanity-io/sdk/issues/325)) -- **react:** flatten sdk-react imports ([#319](https://github.com/sanity-io/sdk/issues/319)) -- remove `schema` from sanity config -- remove schema state and schema manager -- remove `useDocuments` and `useSearch` hooks -- allow multiple resources via instances ([#271](https://github.com/sanity-io/sdk/issues/271)) -- renames `org` auth scope to `global` ([#187](https://github.com/sanity-io/sdk/issues/187)) +* use hosted login for standalone apps ([#386](https://github.com/sanity-io/sdk/issues/386)) +* replace `sanityConfigs` prop with `config` prop in `` and `` +* replace `resourceId` concept with explicit `projectId` and `dataset` fields in handles +* rename `_type` to `documentType` in DocumentHandle interface and related usages +* rename `_id` to `documentId` in DocumentHandle interface and related usages +* update document hooks and actions to expect `DocumentHandle` props +* update project and dataset hooks to use `ProjectHandle` or `DatasetHandle` +* remove ``, introduce `` for configuration +* update `useManageFavorite` signature ([#360](https://github.com/sanity-io/sdk/issues/360)) +* rename usePermissions → useDocumentPermissions ([#365](https://github.com/sanity-io/sdk/issues/365)) +* rename useInfiniteList → useDocuments ([#363](https://github.com/sanity-io/sdk/issues/363)) +* rename usePaginatedList → usePaginatedDocuments ([#364](https://github.com/sanity-io/sdk/issues/364)) +* rename useActions → useDocumentActions and useActions → useDocumentActions ([#362](https://github.com/sanity-io/sdk/issues/362)) +* rename useHandleCallback → useHandleAuthCallback and HandleCallback → HandleAuthCallback ([#358](https://github.com/sanity-io/sdk/issues/358)) +* rename `results` to `data` for useProjection hook ([#335](https://github.com/sanity-io/sdk/issues/335)) +* rename `result` to `data` for usePreview hook ([#325](https://github.com/sanity-io/sdk/issues/325)) +* **react:** flatten sdk-react imports ([#319](https://github.com/sanity-io/sdk/issues/319)) +* remove `schema` from sanity config +* remove schema state and schema manager +* remove `useDocuments` and `useSearch` hooks +* allow multiple resources via instances ([#271](https://github.com/sanity-io/sdk/issues/271)) +* renames `org` auth scope to `global` ([#187](https://github.com/sanity-io/sdk/issues/187)) ### Features -- `useProjects`, `useProject`, `useDatasets` ([#235](https://github.com/sanity-io/sdk/issues/235)) ([cc95dfd](https://github.com/sanity-io/sdk/commit/cc95dfd45a82171fa7ccf05a8ca331e8de97fbee)) -- add `useQuery`, `useInfiniteList`, `usePaginatedList` hooks ([1a3f4ad](https://github.com/sanity-io/sdk/commit/1a3f4ad98abf2ab68c552fea20d60639462f3aac)) -- add authorization ([#52](https://github.com/sanity-io/sdk/issues/52)) ([59501f1](https://github.com/sanity-io/sdk/commit/59501f1525e271e8d724c4eb69a27f01726bb64e)) -- add hooks for AuthStore ([#91](https://github.com/sanity-io/sdk/issues/91)) ([4367719](https://github.com/sanity-io/sdk/commit/43677193fccc08fcf7074f906edf2acdfc440e1c)) -- add initial SanityInstance provider ([#63](https://github.com/sanity-io/sdk/issues/63)) ([2e816b9](https://github.com/sanity-io/sdk/commit/2e816b94c6a706de7792907e7e593970d1570256)) -- add preview store ([#62](https://github.com/sanity-io/sdk/issues/62)) ([c343f1e](https://github.com/sanity-io/sdk/commit/c343f1e15f30afd66dbd4c0309b9152600ceb1be)) -- add React and Vitest ([#3](https://github.com/sanity-io/sdk/issues/3)) ([e55dc32](https://github.com/sanity-io/sdk/commit/e55dc32f080ffaa7470bdcb2ed97f992cfcbe584)) -- add sdk-react-internal package and remove @sanity/ui package ([#193](https://github.com/sanity-io/sdk/issues/193)) ([7fa201e](https://github.com/sanity-io/sdk/commit/7fa201ee49b75bbc71a741503ed0336f94785201)) -- add session hooks and store ([#59](https://github.com/sanity-io/sdk/issues/59)) ([65ac911](https://github.com/sanity-io/sdk/commit/65ac9111d79211aee621f7bfed47bb5cfcf565e1)) -- add storybook and dev affordances ([#6](https://github.com/sanity-io/sdk/issues/6)) ([15b45e8](https://github.com/sanity-io/sdk/commit/15b45e8d7821ec7abc1852998143e19553c06f1e)) -- add suspense boundary to prevent recreating instances ([d92e38d](https://github.com/sanity-io/sdk/commit/d92e38d64dfe5c0a35d8de35faa7ecbe5425f023)) -- add turborepo ([#2](https://github.com/sanity-io/sdk/issues/2)) ([19c53e1](https://github.com/sanity-io/sdk/commit/19c53e1408edacbda4105c75c6fa5c4fe0a6b744)) -- add TypeDoc ([#43](https://github.com/sanity-io/sdk/issues/43)) ([2274873](https://github.com/sanity-io/sdk/commit/227487372c1d04799f7c2ed06839dae06113887c)) -- add useClient hook ([#96](https://github.com/sanity-io/sdk/issues/96)) ([c50883b](https://github.com/sanity-io/sdk/commit/c50883bbf3eed32977a1033615582690234154fc)) -- add useDashboardOrganizationId hook ([#339](https://github.com/sanity-io/sdk/issues/339)) ([401468e](https://github.com/sanity-io/sdk/commit/401468e07b8c74deb02d4b7df78af808bddd9242)) -- add useProjection hook ([#257](https://github.com/sanity-io/sdk/issues/257)) ([fbaafe0](https://github.com/sanity-io/sdk/commit/fbaafe031e235f61b9d60bf5938f18a4683aafe5)) -- add useUsers hook ([#239](https://github.com/sanity-io/sdk/issues/239)) ([b89bcf0](https://github.com/sanity-io/sdk/commit/b89bcf00bc4a849409ae80f45b1917cb1e51c66e)) -- add versions information to all packages ([#275](https://github.com/sanity-io/sdk/issues/275)) ([afb2fec](https://github.com/sanity-io/sdk/commit/afb2fec63ea3bae53cab9d8f05081daf2f3c2733)) -- allow multiple resources via instances ([#271](https://github.com/sanity-io/sdk/issues/271)) ([6f4d541](https://github.com/sanity-io/sdk/commit/6f4d5410671e8b75759e33380464656a8c961ad6)) -- allow useEditDocument to take an updater function ([#218](https://github.com/sanity-io/sdk/issues/218)) ([85b3440](https://github.com/sanity-io/sdk/commit/85b344007df3fd66ce7dae94df8f6b8a81f54574)) -- **auth:** fetch current user when token is present ([#92](https://github.com/sanity-io/sdk/issues/92)) ([f38008c](https://github.com/sanity-io/sdk/commit/f38008c71d55bb3b54bbf5318045a52a918084c2)) -- **auth:** refresh stamped tokens ([#225](https://github.com/sanity-io/sdk/issues/225)) ([10b2745](https://github.com/sanity-io/sdk/commit/10b2745c62f9169b8cd1c66d7fb641d7fda37429)) -- **components:** add initial presentational components ([#44](https://github.com/sanity-io/sdk/issues/44)) ([9d7cf51](https://github.com/sanity-io/sdk/commit/9d7cf517186ee274fe3bd9ea32b36b590ddb7150)) -- **components:** DocumentList & Storybook upgrades ([#54](https://github.com/sanity-io/sdk/issues/54)) ([71e8eca](https://github.com/sanity-io/sdk/commit/71e8eca3da0995f3a8dd4f6eb5b606fdfa139b6c)) -- **components:** swap Sanity UI w/ CSS (doc collection) ([#114](https://github.com/sanity-io/sdk/issues/114)) ([36dcd35](https://github.com/sanity-io/sdk/commit/36dcd3595bd09eba3cd5e6bac57d9dfcd4fee035)) -- **components:** update DocumentList & DocumentPreview ([#61](https://github.com/sanity-io/sdk/issues/61)) ([c00b292](https://github.com/sanity-io/sdk/commit/c00b292dd99bdc6c5b4ee1615b0f3e49106d09c5)) -- **core:** add README and npm keywords ([#115](https://github.com/sanity-io/sdk/issues/115)) ([8a3c492](https://github.com/sanity-io/sdk/commit/8a3c4928647f6e8c4a8fe3f43da9cb8e904af522)) -- **core:** create client store ([#38](https://github.com/sanity-io/sdk/issues/38)) ([8545333](https://github.com/sanity-io/sdk/commit/8545333c02c5691674e90be19951458ab3abbd6a)) -- **core:** use separate client for auth and refresh client store with token ([#64](https://github.com/sanity-io/sdk/issues/64)) ([9d18fbf](https://github.com/sanity-io/sdk/commit/9d18fbfd2fc2708e0f9505617343720c5d7fafb0)) -- **docs:** add a migration guide ([#357](https://github.com/sanity-io/sdk/issues/357)) ([47ef529](https://github.com/sanity-io/sdk/commit/47ef529e7d4c9f4453451ac6141d28a81a1dfbfe)) -- **document hooks:** update the documentation for the Document hook s an optional resourceId ([#280](https://github.com/sanity-io/sdk/issues/280)) ([eb65378](https://github.com/sanity-io/sdk/commit/eb65378c884f3aaf9b2c0dbc95dd86075c76f9e0)) -- document permissions ([#226](https://github.com/sanity-io/sdk/issues/226)) ([107f434](https://github.com/sanity-io/sdk/commit/107f4349d7defab04d1282ee1ab20766d157eab7)) -- document store ([#197](https://github.com/sanity-io/sdk/issues/197)) ([497bb26](https://github.com/sanity-io/sdk/commit/497bb2641d5766128dfca4db8247f2f9555b83b1)) -- export useClient ([#213](https://github.com/sanity-io/sdk/issues/213)) ([0e79002](https://github.com/sanity-io/sdk/commit/0e790020ee0f688e6f07243c5605b5cbffe4b1c5)) -- introduce consistent Handle pattern (`ProjectHandle`, `DatasetHandle`, `DocumentHandle`) across the SDK ([969d70e](https://github.com/sanity-io/sdk/commit/969d70e41f6987234323f99753f5cf937469532b)) -- **kitchen-sink:** add routing to kitchen-sink ([#99](https://github.com/sanity-io/sdk/issues/99)) ([50483ea](https://github.com/sanity-io/sdk/commit/50483ea66073bfccdc28e51f7606673eb213bebe)) -- make packages public ([#320](https://github.com/sanity-io/sdk/issues/320)) ([8c94c29](https://github.com/sanity-io/sdk/commit/8c94c29b0aadd86273db59da1b0577aad682d6e9)) -- **react:** add AuthBoundary ([#102](https://github.com/sanity-io/sdk/issues/102)) ([bd657a0](https://github.com/sanity-io/sdk/commit/bd657a058c4ae0989018503fe2fafa319fcdbc7d)) -- **react:** add comlink fetch hook ([#338](https://github.com/sanity-io/sdk/issues/338)) ([1a78882](https://github.com/sanity-io/sdk/commit/1a788824a2c83126c1b39318aa05f8c3964cad8e)) -- **react:** add interaction history and favorite hooks ([#236](https://github.com/sanity-io/sdk/issues/236)) ([b7cdbd6](https://github.com/sanity-io/sdk/commit/b7cdbd648b81dc46054de0e4c1b864471f2daa30)) -- **react:** add react compiler to the build process ([#298](https://github.com/sanity-io/sdk/issues/298)) ([bfb74eb](https://github.com/sanity-io/sdk/commit/bfb74ebe538b1218a980b03493890b70dc1311d2)) -- **react:** add sanity os bridge script to AuthBoundary ([#196](https://github.com/sanity-io/sdk/issues/196)) ([1fb064d](https://github.com/sanity-io/sdk/commit/1fb064d111541bf93c8933920d7bce00a9c454ef)) -- **react:** add SDKProvider app to use SDK without core ([#263](https://github.com/sanity-io/sdk/issues/263)) ([51e84fc](https://github.com/sanity-io/sdk/commit/51e84fcd7b64558bc108f00d3fb5a98aade25d29)) -- **react:** add useDocuments hook ([#98](https://github.com/sanity-io/sdk/issues/98)) ([d0f0c1a](https://github.com/sanity-io/sdk/commit/d0f0c1ad753b56b7e7cc6ff0830682d4fc6be0d1)) -- **react:** add useNavigateToStudioDocument hook ([#352](https://github.com/sanity-io/sdk/issues/352)) ([a00b9fa](https://github.com/sanity-io/sdk/commit/a00b9fa381bd89f42da4ef95d01f6e5e7c5f0511)) -- **react:** add useSearch hook ([#258](https://github.com/sanity-io/sdk/issues/258)) ([488317a](https://github.com/sanity-io/sdk/commit/488317a72987daf88385f757a60ffdc191333218)) -- **react:** create React hooks for comlink store ([#153](https://github.com/sanity-io/sdk/issues/153)) ([7055347](https://github.com/sanity-io/sdk/commit/7055347160f7d3734c361d182b686e2f835e1846)) -- **react:** create useStudioWorkspaceById hook ([#343](https://github.com/sanity-io/sdk/issues/343)) ([83feb21](https://github.com/sanity-io/sdk/commit/83feb216e13b903a312a5cffd63f793b29570b30)) -- **react:** flatten sdk-react imports ([#319](https://github.com/sanity-io/sdk/issues/319)) ([3922025](https://github.com/sanity-io/sdk/commit/3922025569abfa4cd824e81222495913875246d7)) -- **react:** re-export core sdk and update kitchensink ([#393](https://github.com/sanity-io/sdk/issues/393)) ([a27b850](https://github.com/sanity-io/sdk/commit/a27b850e4ea2779360868009f7646445e36c092f)) -- **react:** use refs for nodes and channels ([#341](https://github.com/sanity-io/sdk/issues/341)) ([4a0b763](https://github.com/sanity-io/sdk/commit/4a0b7637463e8808180a2abe091795e1c3bcef1d)) -- redirect to core if app opened without core ([#268](https://github.com/sanity-io/sdk/issues/268)) ([3f6bb83](https://github.com/sanity-io/sdk/commit/3f6bb8344cee6d582aaee0d7ba64b9cb3035469f)) -- refactor to internal auth store ([#95](https://github.com/sanity-io/sdk/issues/95)) ([5807a2b](https://github.com/sanity-io/sdk/commit/5807a2b0b823f9187c25ab82233ad6d30df664f1)) -- remove ``, introduce `` for configuration ([969d70e](https://github.com/sanity-io/sdk/commit/969d70e41f6987234323f99753f5cf937469532b)) -- remove `schema` from sanity config ([6257fe3](https://github.com/sanity-io/sdk/commit/6257fe39b4521ace71db54f1d0d173a6019db38d)) -- remove `useDocuments` and `useSearch` hooks ([9f37daf](https://github.com/sanity-io/sdk/commit/9f37daf1243ee0fda558ffd7259c45da9e4ba259)) -- remove schema state and schema manager ([6257fe3](https://github.com/sanity-io/sdk/commit/6257fe39b4521ace71db54f1d0d173a6019db38d)) -- rename `_id` to `documentId` in DocumentHandle interface and related usages ([969d70e](https://github.com/sanity-io/sdk/commit/969d70e41f6987234323f99753f5cf937469532b)) -- rename `_type` to `documentType` in DocumentHandle interface and related usages ([969d70e](https://github.com/sanity-io/sdk/commit/969d70e41f6987234323f99753f5cf937469532b)) -- rename `result` to `data` for usePreview hook ([#325](https://github.com/sanity-io/sdk/issues/325)) ([1e5813e](https://github.com/sanity-io/sdk/commit/1e5813e2e26a72c463cafa8c5502043176930a5b)) -- rename `results` to `data` for useProjection hook ([#335](https://github.com/sanity-io/sdk/issues/335)) ([026dd26](https://github.com/sanity-io/sdk/commit/026dd26bffb9fc2a03801ef05a8d075a2968c725)) -- rename useActions → useDocumentActions and useActions → useDocumentActions ([#362](https://github.com/sanity-io/sdk/issues/362)) ([c753897](https://github.com/sanity-io/sdk/commit/c75389759a57c6da5ad306dbac46c6d58b4f8dda)) -- rename useInfiniteList → useDocuments ([#363](https://github.com/sanity-io/sdk/issues/363)) ([8e51dcc](https://github.com/sanity-io/sdk/commit/8e51dcc99bfcb84f59dd43f3b7d877daba158fa3)) -- rename usePaginatedList → usePaginatedDocuments ([#364](https://github.com/sanity-io/sdk/issues/364)) ([544019d](https://github.com/sanity-io/sdk/commit/544019d5c85d2c695848dcb6ea089cc84b7fbbcd)) -- rename usePermissions → useDocumentPermissions ([#365](https://github.com/sanity-io/sdk/issues/365)) ([6ca2ada](https://github.com/sanity-io/sdk/commit/6ca2ada0b0d9a0633d46ccf8c0170c1712a3afb4)) -- render AuthProvider components w/ Sanity UI ([#189](https://github.com/sanity-io/sdk/issues/189)) ([a4ab4c3](https://github.com/sanity-io/sdk/commit/a4ab4c35519417bdd92c75f935479fb834f9af18)) -- replace `resourceId` concept with explicit `projectId` and `dataset` fields in handles ([969d70e](https://github.com/sanity-io/sdk/commit/969d70e41f6987234323f99753f5cf937469532b)) -- replace `sanityConfigs` prop with `config` prop in `` and `` ([969d70e](https://github.com/sanity-io/sdk/commit/969d70e41f6987234323f99753f5cf937469532b)) -- replace jsdoc with tsdoc ([#75](https://github.com/sanity-io/sdk/issues/75)) ([7074a38](https://github.com/sanity-io/sdk/commit/7074a383b58de66fe2a9badc7122d0345e354b2a)) -- resolve preview projections ([#130](https://github.com/sanity-io/sdk/issues/130)) ([d30997e](https://github.com/sanity-io/sdk/commit/d30997e4a3d40c0edd1b3f31f48934bf846ab56a)) -- update `useManageFavorite` signature ([#360](https://github.com/sanity-io/sdk/issues/360)) ([f1617da](https://github.com/sanity-io/sdk/commit/f1617da31ddcb2d0595877f402a6a1ec82c1d0ab)) -- update document hooks and actions to expect `DocumentHandle` props ([969d70e](https://github.com/sanity-io/sdk/commit/969d70e41f6987234323f99753f5cf937469532b)) -- update project and dataset hooks to use `ProjectHandle` or `DatasetHandle` ([969d70e](https://github.com/sanity-io/sdk/commit/969d70e41f6987234323f99753f5cf937469532b)) -- update query and list hooks to accept optional `DatasetHandle` for configuration ([969d70e](https://github.com/sanity-io/sdk/commit/969d70e41f6987234323f99753f5cf937469532b)) -- use hosted login for standalone apps ([#386](https://github.com/sanity-io/sdk/issues/386)) ([9c1ad58](https://github.com/sanity-io/sdk/commit/9c1ad58bc0b302073c90dd6e584f566eba3d0d17)) -- use projection for previews and remove schema usage ([6257fe3](https://github.com/sanity-io/sdk/commit/6257fe39b4521ace71db54f1d0d173a6019db38d)) +* `useProjects`, `useProject`, `useDatasets` ([#235](https://github.com/sanity-io/sdk/issues/235)) ([cc95dfd](https://github.com/sanity-io/sdk/commit/cc95dfd45a82171fa7ccf05a8ca331e8de97fbee)) +* add `useQuery`, `useInfiniteList`, `usePaginatedList` hooks ([1a3f4ad](https://github.com/sanity-io/sdk/commit/1a3f4ad98abf2ab68c552fea20d60639462f3aac)) +* add authorization ([#52](https://github.com/sanity-io/sdk/issues/52)) ([59501f1](https://github.com/sanity-io/sdk/commit/59501f1525e271e8d724c4eb69a27f01726bb64e)) +* add hooks for AuthStore ([#91](https://github.com/sanity-io/sdk/issues/91)) ([4367719](https://github.com/sanity-io/sdk/commit/43677193fccc08fcf7074f906edf2acdfc440e1c)) +* add initial SanityInstance provider ([#63](https://github.com/sanity-io/sdk/issues/63)) ([2e816b9](https://github.com/sanity-io/sdk/commit/2e816b94c6a706de7792907e7e593970d1570256)) +* add preview store ([#62](https://github.com/sanity-io/sdk/issues/62)) ([c343f1e](https://github.com/sanity-io/sdk/commit/c343f1e15f30afd66dbd4c0309b9152600ceb1be)) +* add React and Vitest ([#3](https://github.com/sanity-io/sdk/issues/3)) ([e55dc32](https://github.com/sanity-io/sdk/commit/e55dc32f080ffaa7470bdcb2ed97f992cfcbe584)) +* add sdk-react-internal package and remove @sanity/ui package ([#193](https://github.com/sanity-io/sdk/issues/193)) ([7fa201e](https://github.com/sanity-io/sdk/commit/7fa201ee49b75bbc71a741503ed0336f94785201)) +* add session hooks and store ([#59](https://github.com/sanity-io/sdk/issues/59)) ([65ac911](https://github.com/sanity-io/sdk/commit/65ac9111d79211aee621f7bfed47bb5cfcf565e1)) +* add storybook and dev affordances ([#6](https://github.com/sanity-io/sdk/issues/6)) ([15b45e8](https://github.com/sanity-io/sdk/commit/15b45e8d7821ec7abc1852998143e19553c06f1e)) +* add suspense boundary to prevent recreating instances ([d92e38d](https://github.com/sanity-io/sdk/commit/d92e38d64dfe5c0a35d8de35faa7ecbe5425f023)) +* add turborepo ([#2](https://github.com/sanity-io/sdk/issues/2)) ([19c53e1](https://github.com/sanity-io/sdk/commit/19c53e1408edacbda4105c75c6fa5c4fe0a6b744)) +* add TypeDoc ([#43](https://github.com/sanity-io/sdk/issues/43)) ([2274873](https://github.com/sanity-io/sdk/commit/227487372c1d04799f7c2ed06839dae06113887c)) +* add useClient hook ([#96](https://github.com/sanity-io/sdk/issues/96)) ([c50883b](https://github.com/sanity-io/sdk/commit/c50883bbf3eed32977a1033615582690234154fc)) +* add useDashboardOrganizationId hook ([#339](https://github.com/sanity-io/sdk/issues/339)) ([401468e](https://github.com/sanity-io/sdk/commit/401468e07b8c74deb02d4b7df78af808bddd9242)) +* add useProjection hook ([#257](https://github.com/sanity-io/sdk/issues/257)) ([fbaafe0](https://github.com/sanity-io/sdk/commit/fbaafe031e235f61b9d60bf5938f18a4683aafe5)) +* add useUsers hook ([#239](https://github.com/sanity-io/sdk/issues/239)) ([b89bcf0](https://github.com/sanity-io/sdk/commit/b89bcf00bc4a849409ae80f45b1917cb1e51c66e)) +* add versions information to all packages ([#275](https://github.com/sanity-io/sdk/issues/275)) ([afb2fec](https://github.com/sanity-io/sdk/commit/afb2fec63ea3bae53cab9d8f05081daf2f3c2733)) +* allow multiple resources via instances ([#271](https://github.com/sanity-io/sdk/issues/271)) ([6f4d541](https://github.com/sanity-io/sdk/commit/6f4d5410671e8b75759e33380464656a8c961ad6)) +* allow useEditDocument to take an updater function ([#218](https://github.com/sanity-io/sdk/issues/218)) ([85b3440](https://github.com/sanity-io/sdk/commit/85b344007df3fd66ce7dae94df8f6b8a81f54574)) +* **auth:** fetch current user when token is present ([#92](https://github.com/sanity-io/sdk/issues/92)) ([f38008c](https://github.com/sanity-io/sdk/commit/f38008c71d55bb3b54bbf5318045a52a918084c2)) +* **auth:** refresh stamped tokens ([#225](https://github.com/sanity-io/sdk/issues/225)) ([10b2745](https://github.com/sanity-io/sdk/commit/10b2745c62f9169b8cd1c66d7fb641d7fda37429)) +* **components:** add initial presentational components ([#44](https://github.com/sanity-io/sdk/issues/44)) ([9d7cf51](https://github.com/sanity-io/sdk/commit/9d7cf517186ee274fe3bd9ea32b36b590ddb7150)) +* **components:** DocumentList & Storybook upgrades ([#54](https://github.com/sanity-io/sdk/issues/54)) ([71e8eca](https://github.com/sanity-io/sdk/commit/71e8eca3da0995f3a8dd4f6eb5b606fdfa139b6c)) +* **components:** swap Sanity UI w/ CSS (doc collection) ([#114](https://github.com/sanity-io/sdk/issues/114)) ([36dcd35](https://github.com/sanity-io/sdk/commit/36dcd3595bd09eba3cd5e6bac57d9dfcd4fee035)) +* **components:** update DocumentList & DocumentPreview ([#61](https://github.com/sanity-io/sdk/issues/61)) ([c00b292](https://github.com/sanity-io/sdk/commit/c00b292dd99bdc6c5b4ee1615b0f3e49106d09c5)) +* **core:** add README and npm keywords ([#115](https://github.com/sanity-io/sdk/issues/115)) ([8a3c492](https://github.com/sanity-io/sdk/commit/8a3c4928647f6e8c4a8fe3f43da9cb8e904af522)) +* **core:** create client store ([#38](https://github.com/sanity-io/sdk/issues/38)) ([8545333](https://github.com/sanity-io/sdk/commit/8545333c02c5691674e90be19951458ab3abbd6a)) +* **core:** use separate client for auth and refresh client store with token ([#64](https://github.com/sanity-io/sdk/issues/64)) ([9d18fbf](https://github.com/sanity-io/sdk/commit/9d18fbfd2fc2708e0f9505617343720c5d7fafb0)) +* **docs:** add a migration guide ([#357](https://github.com/sanity-io/sdk/issues/357)) ([47ef529](https://github.com/sanity-io/sdk/commit/47ef529e7d4c9f4453451ac6141d28a81a1dfbfe)) +* **document hooks:** update the documentation for the Document hook s an optional resourceId ([#280](https://github.com/sanity-io/sdk/issues/280)) ([eb65378](https://github.com/sanity-io/sdk/commit/eb65378c884f3aaf9b2c0dbc95dd86075c76f9e0)) +* document permissions ([#226](https://github.com/sanity-io/sdk/issues/226)) ([107f434](https://github.com/sanity-io/sdk/commit/107f4349d7defab04d1282ee1ab20766d157eab7)) +* document store ([#197](https://github.com/sanity-io/sdk/issues/197)) ([497bb26](https://github.com/sanity-io/sdk/commit/497bb2641d5766128dfca4db8247f2f9555b83b1)) +* export useClient ([#213](https://github.com/sanity-io/sdk/issues/213)) ([0e79002](https://github.com/sanity-io/sdk/commit/0e790020ee0f688e6f07243c5605b5cbffe4b1c5)) +* introduce consistent Handle pattern (`ProjectHandle`, `DatasetHandle`, `DocumentHandle`) across the SDK ([969d70e](https://github.com/sanity-io/sdk/commit/969d70e41f6987234323f99753f5cf937469532b)) +* **kitchen-sink:** add routing to kitchen-sink ([#99](https://github.com/sanity-io/sdk/issues/99)) ([50483ea](https://github.com/sanity-io/sdk/commit/50483ea66073bfccdc28e51f7606673eb213bebe)) +* make packages public ([#320](https://github.com/sanity-io/sdk/issues/320)) ([8c94c29](https://github.com/sanity-io/sdk/commit/8c94c29b0aadd86273db59da1b0577aad682d6e9)) +* **react:** add AuthBoundary ([#102](https://github.com/sanity-io/sdk/issues/102)) ([bd657a0](https://github.com/sanity-io/sdk/commit/bd657a058c4ae0989018503fe2fafa319fcdbc7d)) +* **react:** add comlink fetch hook ([#338](https://github.com/sanity-io/sdk/issues/338)) ([1a78882](https://github.com/sanity-io/sdk/commit/1a788824a2c83126c1b39318aa05f8c3964cad8e)) +* **react:** add interaction history and favorite hooks ([#236](https://github.com/sanity-io/sdk/issues/236)) ([b7cdbd6](https://github.com/sanity-io/sdk/commit/b7cdbd648b81dc46054de0e4c1b864471f2daa30)) +* **react:** add react compiler to the build process ([#298](https://github.com/sanity-io/sdk/issues/298)) ([bfb74eb](https://github.com/sanity-io/sdk/commit/bfb74ebe538b1218a980b03493890b70dc1311d2)) +* **react:** add sanity os bridge script to AuthBoundary ([#196](https://github.com/sanity-io/sdk/issues/196)) ([1fb064d](https://github.com/sanity-io/sdk/commit/1fb064d111541bf93c8933920d7bce00a9c454ef)) +* **react:** add SDKProvider app to use SDK without core ([#263](https://github.com/sanity-io/sdk/issues/263)) ([51e84fc](https://github.com/sanity-io/sdk/commit/51e84fcd7b64558bc108f00d3fb5a98aade25d29)) +* **react:** add useDocuments hook ([#98](https://github.com/sanity-io/sdk/issues/98)) ([d0f0c1a](https://github.com/sanity-io/sdk/commit/d0f0c1ad753b56b7e7cc6ff0830682d4fc6be0d1)) +* **react:** add useNavigateToStudioDocument hook ([#352](https://github.com/sanity-io/sdk/issues/352)) ([a00b9fa](https://github.com/sanity-io/sdk/commit/a00b9fa381bd89f42da4ef95d01f6e5e7c5f0511)) +* **react:** add useSearch hook ([#258](https://github.com/sanity-io/sdk/issues/258)) ([488317a](https://github.com/sanity-io/sdk/commit/488317a72987daf88385f757a60ffdc191333218)) +* **react:** create React hooks for comlink store ([#153](https://github.com/sanity-io/sdk/issues/153)) ([7055347](https://github.com/sanity-io/sdk/commit/7055347160f7d3734c361d182b686e2f835e1846)) +* **react:** create useStudioWorkspaceById hook ([#343](https://github.com/sanity-io/sdk/issues/343)) ([83feb21](https://github.com/sanity-io/sdk/commit/83feb216e13b903a312a5cffd63f793b29570b30)) +* **react:** flatten sdk-react imports ([#319](https://github.com/sanity-io/sdk/issues/319)) ([3922025](https://github.com/sanity-io/sdk/commit/3922025569abfa4cd824e81222495913875246d7)) +* **react:** re-export core sdk and update kitchensink ([#393](https://github.com/sanity-io/sdk/issues/393)) ([a27b850](https://github.com/sanity-io/sdk/commit/a27b850e4ea2779360868009f7646445e36c092f)) +* **react:** use refs for nodes and channels ([#341](https://github.com/sanity-io/sdk/issues/341)) ([4a0b763](https://github.com/sanity-io/sdk/commit/4a0b7637463e8808180a2abe091795e1c3bcef1d)) +* redirect to core if app opened without core ([#268](https://github.com/sanity-io/sdk/issues/268)) ([3f6bb83](https://github.com/sanity-io/sdk/commit/3f6bb8344cee6d582aaee0d7ba64b9cb3035469f)) +* refactor to internal auth store ([#95](https://github.com/sanity-io/sdk/issues/95)) ([5807a2b](https://github.com/sanity-io/sdk/commit/5807a2b0b823f9187c25ab82233ad6d30df664f1)) +* remove ``, introduce `` for configuration ([969d70e](https://github.com/sanity-io/sdk/commit/969d70e41f6987234323f99753f5cf937469532b)) +* remove `schema` from sanity config ([6257fe3](https://github.com/sanity-io/sdk/commit/6257fe39b4521ace71db54f1d0d173a6019db38d)) +* remove `useDocuments` and `useSearch` hooks ([9f37daf](https://github.com/sanity-io/sdk/commit/9f37daf1243ee0fda558ffd7259c45da9e4ba259)) +* remove schema state and schema manager ([6257fe3](https://github.com/sanity-io/sdk/commit/6257fe39b4521ace71db54f1d0d173a6019db38d)) +* rename `_id` to `documentId` in DocumentHandle interface and related usages ([969d70e](https://github.com/sanity-io/sdk/commit/969d70e41f6987234323f99753f5cf937469532b)) +* rename `_type` to `documentType` in DocumentHandle interface and related usages ([969d70e](https://github.com/sanity-io/sdk/commit/969d70e41f6987234323f99753f5cf937469532b)) +* rename `result` to `data` for usePreview hook ([#325](https://github.com/sanity-io/sdk/issues/325)) ([1e5813e](https://github.com/sanity-io/sdk/commit/1e5813e2e26a72c463cafa8c5502043176930a5b)) +* rename `results` to `data` for useProjection hook ([#335](https://github.com/sanity-io/sdk/issues/335)) ([026dd26](https://github.com/sanity-io/sdk/commit/026dd26bffb9fc2a03801ef05a8d075a2968c725)) +* rename useActions → useDocumentActions and useActions → useDocumentActions ([#362](https://github.com/sanity-io/sdk/issues/362)) ([c753897](https://github.com/sanity-io/sdk/commit/c75389759a57c6da5ad306dbac46c6d58b4f8dda)) +* rename useInfiniteList → useDocuments ([#363](https://github.com/sanity-io/sdk/issues/363)) ([8e51dcc](https://github.com/sanity-io/sdk/commit/8e51dcc99bfcb84f59dd43f3b7d877daba158fa3)) +* rename usePaginatedList → usePaginatedDocuments ([#364](https://github.com/sanity-io/sdk/issues/364)) ([544019d](https://github.com/sanity-io/sdk/commit/544019d5c85d2c695848dcb6ea089cc84b7fbbcd)) +* rename usePermissions → useDocumentPermissions ([#365](https://github.com/sanity-io/sdk/issues/365)) ([6ca2ada](https://github.com/sanity-io/sdk/commit/6ca2ada0b0d9a0633d46ccf8c0170c1712a3afb4)) +* render AuthProvider components w/ Sanity UI ([#189](https://github.com/sanity-io/sdk/issues/189)) ([a4ab4c3](https://github.com/sanity-io/sdk/commit/a4ab4c35519417bdd92c75f935479fb834f9af18)) +* replace `resourceId` concept with explicit `projectId` and `dataset` fields in handles ([969d70e](https://github.com/sanity-io/sdk/commit/969d70e41f6987234323f99753f5cf937469532b)) +* replace `sanityConfigs` prop with `config` prop in `` and `` ([969d70e](https://github.com/sanity-io/sdk/commit/969d70e41f6987234323f99753f5cf937469532b)) +* replace jsdoc with tsdoc ([#75](https://github.com/sanity-io/sdk/issues/75)) ([7074a38](https://github.com/sanity-io/sdk/commit/7074a383b58de66fe2a9badc7122d0345e354b2a)) +* resolve preview projections ([#130](https://github.com/sanity-io/sdk/issues/130)) ([d30997e](https://github.com/sanity-io/sdk/commit/d30997e4a3d40c0edd1b3f31f48934bf846ab56a)) +* update `useManageFavorite` signature ([#360](https://github.com/sanity-io/sdk/issues/360)) ([f1617da](https://github.com/sanity-io/sdk/commit/f1617da31ddcb2d0595877f402a6a1ec82c1d0ab)) +* update document hooks and actions to expect `DocumentHandle` props ([969d70e](https://github.com/sanity-io/sdk/commit/969d70e41f6987234323f99753f5cf937469532b)) +* update project and dataset hooks to use `ProjectHandle` or `DatasetHandle` ([969d70e](https://github.com/sanity-io/sdk/commit/969d70e41f6987234323f99753f5cf937469532b)) +* update query and list hooks to accept optional `DatasetHandle` for configuration ([969d70e](https://github.com/sanity-io/sdk/commit/969d70e41f6987234323f99753f5cf937469532b)) +* use hosted login for standalone apps ([#386](https://github.com/sanity-io/sdk/issues/386)) ([9c1ad58](https://github.com/sanity-io/sdk/commit/9c1ad58bc0b302073c90dd6e584f566eba3d0d17)) +* use projection for previews and remove schema usage ([6257fe3](https://github.com/sanity-io/sdk/commit/6257fe39b4521ace71db54f1d0d173a6019db38d)) + ### Bug Fixes -- add access api types inside the SDK ([#261](https://github.com/sanity-io/sdk/issues/261)) ([ff53123](https://github.com/sanity-io/sdk/commit/ff53123f2e01a242c22df22b9dc109d2cbc3b1d4)) -- add lint to turbo.json and run prettier ([909f0d3](https://github.com/sanity-io/sdk/commit/909f0d34339c9c8ff8c013dfa13e5d607a2012fc)) -- adjust incorrect release back to alpha.6 ([#212](https://github.com/sanity-io/sdk/issues/212)) ([a946853](https://github.com/sanity-io/sdk/commit/a9468530e16ee056d972d913e4f046ceb0610134)) -- **auth:** do not perform multiple sid token exchanges ([#308](https://github.com/sanity-io/sdk/issues/308)) ([18461c6](https://github.com/sanity-io/sdk/commit/18461c6837bf532fb7a303efe3f2a279e8fce26f)) -- **comlink:** expose statuses and destroy unused resources ([#233](https://github.com/sanity-io/sdk/issues/233)) ([8b8a40c](https://github.com/sanity-io/sdk/commit/8b8a40c5ac0b5ba76cda043ffc9bc3b740bce5bd)) -- correct the React SDK quickstart ([#317](https://github.com/sanity-io/sdk/issues/317)) ([df5474f](https://github.com/sanity-io/sdk/commit/df5474f478ca6bbde8b471d1beea34f5916470a5)) -- **deps:** update dependency @sanity/comlink to v3 ([#296](https://github.com/sanity-io/sdk/issues/296)) ([14fbe1b](https://github.com/sanity-io/sdk/commit/14fbe1b89a79d2532e8735a58abbe4a5cff6d635)) -- **deps:** update dependency react-error-boundary to v5 ([#334](https://github.com/sanity-io/sdk/issues/334)) ([a128d7c](https://github.com/sanity-io/sdk/commit/a128d7c7a64f0e724028e0a6f0e0e2f17a399f82)) -- **deps:** Update eslint-tooling ([#69](https://github.com/sanity-io/sdk/issues/69)) ([d9d8e09](https://github.com/sanity-io/sdk/commit/d9d8e099e4711bb6ae90e926ce804715f56ef5d3)) -- **deps:** update message-protocol to 0.7.0 ([#379](https://github.com/sanity-io/sdk/issues/379)) ([553b2f5](https://github.com/sanity-io/sdk/commit/553b2f5249432773c8b0d05b6704a9f17b26137c)) -- **deps:** update pkg-utils to v7 ([#384](https://github.com/sanity-io/sdk/issues/384)) ([ce9a952](https://github.com/sanity-io/sdk/commit/ce9a952a295a32ec86c12cbf9b967128ba5eaf4f)) -- **deps:** Update sanity monorepo to ^3.78.1 ([#297](https://github.com/sanity-io/sdk/issues/297)) ([835b594](https://github.com/sanity-io/sdk/commit/835b5942d3870a92e0fd1387ab9baa5e555a3ee5)) -- **deps:** upgrade `@sanity/client`, do not use `withCredentials` ([#368](https://github.com/sanity-io/sdk/issues/368)) ([8e1cbd9](https://github.com/sanity-io/sdk/commit/8e1cbd92501892bf116c3a3473ae693062518f89)) -- **docs:** rename infiniteList pageSize -> batchSize, update reference docs ([#303](https://github.com/sanity-io/sdk/issues/303)) ([953d111](https://github.com/sanity-io/sdk/commit/953d1117d680acf5fc2e4f74350fb8f9fd8a9b1d)) -- ensure usePreview and useProjection hooks subscribe if no ref is passed ([#366](https://github.com/sanity-io/sdk/issues/366)) ([6da3fd1](https://github.com/sanity-io/sdk/commit/6da3fd158de23956b5f1aa732e31be7a6f312c64)) -- fix typedoc annotations for hooks ([#361](https://github.com/sanity-io/sdk/issues/361)) ([778a63a](https://github.com/sanity-io/sdk/commit/778a63ac5cb52ed6c1e28b1ff22605caad54db33)) -- handle env variable for react and react-internal ([#294](https://github.com/sanity-io/sdk/issues/294)) ([0b733ff](https://github.com/sanity-io/sdk/commit/0b733ffbe00bbcb8c29fbee6628ba53c704e1c11)) -- mark packages as private for now ([#11](https://github.com/sanity-io/sdk/issues/11)) ([a103825](https://github.com/sanity-io/sdk/commit/a1038257192e2c493132b96233d461bdd9a31744)) -- package access and version ([#89](https://github.com/sanity-io/sdk/issues/89)) ([c4eb26d](https://github.com/sanity-io/sdk/commit/c4eb26dac12ec56c5a569c8edc895ffcd46a63a7)) -- **react:** remove react compiler runtime package ([#311](https://github.com/sanity-io/sdk/issues/311)) ([08046b5](https://github.com/sanity-io/sdk/commit/08046b565b187cad00f45f8790940e5735a77d5a)) -- **react:** update app redirect url to new dashboard ([#377](https://github.com/sanity-io/sdk/issues/377)) ([86ec07e](https://github.com/sanity-io/sdk/commit/86ec07e86c194a38f59f2f0f6ee80c0b0b0d0356)) -- **react:** update bridge script import for AuthBoundary ([#234](https://github.com/sanity-io/sdk/issues/234)) ([fe69106](https://github.com/sanity-io/sdk/commit/fe69106d35f5e1dee9f901ec21424042d7f9dc18)) -- route Document edit actions to correct resource instance ([#300](https://github.com/sanity-io/sdk/issues/300)) ([9e8f2ac](https://github.com/sanity-io/sdk/commit/9e8f2ac7de3fa1ec6f9af3cc79e3ec9ab45b3e59)) -- styled is not a function in Remix apps ([#169](https://github.com/sanity-io/sdk/issues/169)) ([7a8cfbf](https://github.com/sanity-io/sdk/commit/7a8cfbfedb60c5877cc4edae0caf92dfb6adf388)) -- trigger release ([#210](https://github.com/sanity-io/sdk/issues/210)) ([2b36c98](https://github.com/sanity-io/sdk/commit/2b36c985a91d44be95a9e6c8446e9a11ffa59d61)) -- update the react README to use the updated app template ([#354](https://github.com/sanity-io/sdk/issues/354)) ([a2a41d0](https://github.com/sanity-io/sdk/commit/a2a41d0bee9128317a0ee4de59008c75988daa74)) -- update typedoc to use package mode ([#117](https://github.com/sanity-io/sdk/issues/117)) ([7f4e0e1](https://github.com/sanity-io/sdk/commit/7f4e0e1f08610fb3861e5dc8eb67fb1556b4d965)) +* add access api types inside the SDK ([#261](https://github.com/sanity-io/sdk/issues/261)) ([ff53123](https://github.com/sanity-io/sdk/commit/ff53123f2e01a242c22df22b9dc109d2cbc3b1d4)) +* add lint to turbo.json and run prettier ([909f0d3](https://github.com/sanity-io/sdk/commit/909f0d34339c9c8ff8c013dfa13e5d607a2012fc)) +* adjust incorrect release back to alpha.6 ([#212](https://github.com/sanity-io/sdk/issues/212)) ([a946853](https://github.com/sanity-io/sdk/commit/a9468530e16ee056d972d913e4f046ceb0610134)) +* **auth:** do not perform multiple sid token exchanges ([#308](https://github.com/sanity-io/sdk/issues/308)) ([18461c6](https://github.com/sanity-io/sdk/commit/18461c6837bf532fb7a303efe3f2a279e8fce26f)) +* **comlink:** expose statuses and destroy unused resources ([#233](https://github.com/sanity-io/sdk/issues/233)) ([8b8a40c](https://github.com/sanity-io/sdk/commit/8b8a40c5ac0b5ba76cda043ffc9bc3b740bce5bd)) +* correct the React SDK quickstart ([#317](https://github.com/sanity-io/sdk/issues/317)) ([df5474f](https://github.com/sanity-io/sdk/commit/df5474f478ca6bbde8b471d1beea34f5916470a5)) +* **deps:** update dependency @sanity/comlink to v3 ([#296](https://github.com/sanity-io/sdk/issues/296)) ([14fbe1b](https://github.com/sanity-io/sdk/commit/14fbe1b89a79d2532e8735a58abbe4a5cff6d635)) +* **deps:** update dependency react-error-boundary to v5 ([#334](https://github.com/sanity-io/sdk/issues/334)) ([a128d7c](https://github.com/sanity-io/sdk/commit/a128d7c7a64f0e724028e0a6f0e0e2f17a399f82)) +* **deps:** Update eslint-tooling ([#69](https://github.com/sanity-io/sdk/issues/69)) ([d9d8e09](https://github.com/sanity-io/sdk/commit/d9d8e099e4711bb6ae90e926ce804715f56ef5d3)) +* **deps:** update message-protocol to 0.7.0 ([#379](https://github.com/sanity-io/sdk/issues/379)) ([553b2f5](https://github.com/sanity-io/sdk/commit/553b2f5249432773c8b0d05b6704a9f17b26137c)) +* **deps:** update pkg-utils to v7 ([#384](https://github.com/sanity-io/sdk/issues/384)) ([ce9a952](https://github.com/sanity-io/sdk/commit/ce9a952a295a32ec86c12cbf9b967128ba5eaf4f)) +* **deps:** Update sanity monorepo to ^3.78.1 ([#297](https://github.com/sanity-io/sdk/issues/297)) ([835b594](https://github.com/sanity-io/sdk/commit/835b5942d3870a92e0fd1387ab9baa5e555a3ee5)) +* **deps:** upgrade `@sanity/client`, do not use `withCredentials` ([#368](https://github.com/sanity-io/sdk/issues/368)) ([8e1cbd9](https://github.com/sanity-io/sdk/commit/8e1cbd92501892bf116c3a3473ae693062518f89)) +* **docs:** rename infiniteList pageSize -> batchSize, update reference docs ([#303](https://github.com/sanity-io/sdk/issues/303)) ([953d111](https://github.com/sanity-io/sdk/commit/953d1117d680acf5fc2e4f74350fb8f9fd8a9b1d)) +* ensure usePreview and useProjection hooks subscribe if no ref is passed ([#366](https://github.com/sanity-io/sdk/issues/366)) ([6da3fd1](https://github.com/sanity-io/sdk/commit/6da3fd158de23956b5f1aa732e31be7a6f312c64)) +* fix typedoc annotations for hooks ([#361](https://github.com/sanity-io/sdk/issues/361)) ([778a63a](https://github.com/sanity-io/sdk/commit/778a63ac5cb52ed6c1e28b1ff22605caad54db33)) +* handle env variable for react and react-internal ([#294](https://github.com/sanity-io/sdk/issues/294)) ([0b733ff](https://github.com/sanity-io/sdk/commit/0b733ffbe00bbcb8c29fbee6628ba53c704e1c11)) +* mark packages as private for now ([#11](https://github.com/sanity-io/sdk/issues/11)) ([a103825](https://github.com/sanity-io/sdk/commit/a1038257192e2c493132b96233d461bdd9a31744)) +* package access and version ([#89](https://github.com/sanity-io/sdk/issues/89)) ([c4eb26d](https://github.com/sanity-io/sdk/commit/c4eb26dac12ec56c5a569c8edc895ffcd46a63a7)) +* **react:** remove react compiler runtime package ([#311](https://github.com/sanity-io/sdk/issues/311)) ([08046b5](https://github.com/sanity-io/sdk/commit/08046b565b187cad00f45f8790940e5735a77d5a)) +* **react:** update app redirect url to new dashboard ([#377](https://github.com/sanity-io/sdk/issues/377)) ([86ec07e](https://github.com/sanity-io/sdk/commit/86ec07e86c194a38f59f2f0f6ee80c0b0b0d0356)) +* **react:** update bridge script import for AuthBoundary ([#234](https://github.com/sanity-io/sdk/issues/234)) ([fe69106](https://github.com/sanity-io/sdk/commit/fe69106d35f5e1dee9f901ec21424042d7f9dc18)) +* route Document edit actions to correct resource instance ([#300](https://github.com/sanity-io/sdk/issues/300)) ([9e8f2ac](https://github.com/sanity-io/sdk/commit/9e8f2ac7de3fa1ec6f9af3cc79e3ec9ab45b3e59)) +* styled is not a function in Remix apps ([#169](https://github.com/sanity-io/sdk/issues/169)) ([7a8cfbf](https://github.com/sanity-io/sdk/commit/7a8cfbfedb60c5877cc4edae0caf92dfb6adf388)) +* trigger release ([#210](https://github.com/sanity-io/sdk/issues/210)) ([2b36c98](https://github.com/sanity-io/sdk/commit/2b36c985a91d44be95a9e6c8446e9a11ffa59d61)) +* update the react README to use the updated app template ([#354](https://github.com/sanity-io/sdk/issues/354)) ([a2a41d0](https://github.com/sanity-io/sdk/commit/a2a41d0bee9128317a0ee4de59008c75988daa74)) +* update typedoc to use package mode ([#117](https://github.com/sanity-io/sdk/issues/117)) ([7f4e0e1](https://github.com/sanity-io/sdk/commit/7f4e0e1f08610fb3861e5dc8eb67fb1556b4d965)) + ### Miscellaneous Chores -- renames `org` auth scope to `global` ([#187](https://github.com/sanity-io/sdk/issues/187)) ([3220d57](https://github.com/sanity-io/sdk/commit/3220d5729c8012ffc47bfa2d75bfca1f2642df76)) +* renames `org` auth scope to `global` ([#187](https://github.com/sanity-io/sdk/issues/187)) ([3220d57](https://github.com/sanity-io/sdk/commit/3220d5729c8012ffc47bfa2d75bfca1f2642df76)) + ### Code Refactoring -- rename useHandleCallback → useHandleAuthCallback and HandleCallback → HandleAuthCallback ([#358](https://github.com/sanity-io/sdk/issues/358)) ([014dc69](https://github.com/sanity-io/sdk/commit/014dc695320273b4e166d946753e851c9701d159)) +* rename useHandleCallback → useHandleAuthCallback and HandleCallback → HandleAuthCallback ([#358](https://github.com/sanity-io/sdk/issues/358)) ([014dc69](https://github.com/sanity-io/sdk/commit/014dc695320273b4e166d946753e851c9701d159)) + ### Dependencies -- The following workspace dependencies were updated - - dependencies - - @sanity/sdk bumped to 0.0.0-alpha.24 +* The following workspace dependencies were updated + * dependencies + * @sanity/sdk bumped to 0.0.0-alpha.24 ## [0.0.0-alpha.23](https://github.com/sanity-io/sdk/compare/sdk-react-v0.0.0-alpha.22...sdk-react-v0.0.0-alpha.23) (2025-04-03) + ### ⚠ BREAKING CHANGES -- use hosted login for standalone apps ([#386](https://github.com/sanity-io/sdk/issues/386)) -- replace `sanityConfigs` prop with `config` prop in `` and `` -- replace `resourceId` concept with explicit `projectId` and `dataset` fields in handles -- rename `_type` to `documentType` in DocumentHandle interface and related usages -- rename `_id` to `documentId` in DocumentHandle interface and related usages -- update document hooks and actions to expect `DocumentHandle` props -- update project and dataset hooks to use `ProjectHandle` or `DatasetHandle` -- remove ``, introduce `` for configuration +* use hosted login for standalone apps ([#386](https://github.com/sanity-io/sdk/issues/386)) +* replace `sanityConfigs` prop with `config` prop in `` and `` +* replace `resourceId` concept with explicit `projectId` and `dataset` fields in handles +* rename `_type` to `documentType` in DocumentHandle interface and related usages +* rename `_id` to `documentId` in DocumentHandle interface and related usages +* update document hooks and actions to expect `DocumentHandle` props +* update project and dataset hooks to use `ProjectHandle` or `DatasetHandle` +* remove ``, introduce `` for configuration ### Features -- introduce consistent Handle pattern (`ProjectHandle`, `DatasetHandle`, `DocumentHandle`) across the SDK ([969d70e](https://github.com/sanity-io/sdk/commit/969d70e41f6987234323f99753f5cf937469532b)) -- remove ``, introduce `` for configuration ([969d70e](https://github.com/sanity-io/sdk/commit/969d70e41f6987234323f99753f5cf937469532b)) -- rename `_id` to `documentId` in DocumentHandle interface and related usages ([969d70e](https://github.com/sanity-io/sdk/commit/969d70e41f6987234323f99753f5cf937469532b)) -- rename `_type` to `documentType` in DocumentHandle interface and related usages ([969d70e](https://github.com/sanity-io/sdk/commit/969d70e41f6987234323f99753f5cf937469532b)) -- replace `resourceId` concept with explicit `projectId` and `dataset` fields in handles ([969d70e](https://github.com/sanity-io/sdk/commit/969d70e41f6987234323f99753f5cf937469532b)) -- replace `sanityConfigs` prop with `config` prop in `` and `` ([969d70e](https://github.com/sanity-io/sdk/commit/969d70e41f6987234323f99753f5cf937469532b)) -- update document hooks and actions to expect `DocumentHandle` props ([969d70e](https://github.com/sanity-io/sdk/commit/969d70e41f6987234323f99753f5cf937469532b)) -- update project and dataset hooks to use `ProjectHandle` or `DatasetHandle` ([969d70e](https://github.com/sanity-io/sdk/commit/969d70e41f6987234323f99753f5cf937469532b)) -- update query and list hooks to accept optional `DatasetHandle` for configuration ([969d70e](https://github.com/sanity-io/sdk/commit/969d70e41f6987234323f99753f5cf937469532b)) -- use hosted login for standalone apps ([#386](https://github.com/sanity-io/sdk/issues/386)) ([9c1ad58](https://github.com/sanity-io/sdk/commit/9c1ad58bc0b302073c90dd6e584f566eba3d0d17)) +* introduce consistent Handle pattern (`ProjectHandle`, `DatasetHandle`, `DocumentHandle`) across the SDK ([969d70e](https://github.com/sanity-io/sdk/commit/969d70e41f6987234323f99753f5cf937469532b)) +* remove ``, introduce `` for configuration ([969d70e](https://github.com/sanity-io/sdk/commit/969d70e41f6987234323f99753f5cf937469532b)) +* rename `_id` to `documentId` in DocumentHandle interface and related usages ([969d70e](https://github.com/sanity-io/sdk/commit/969d70e41f6987234323f99753f5cf937469532b)) +* rename `_type` to `documentType` in DocumentHandle interface and related usages ([969d70e](https://github.com/sanity-io/sdk/commit/969d70e41f6987234323f99753f5cf937469532b)) +* replace `resourceId` concept with explicit `projectId` and `dataset` fields in handles ([969d70e](https://github.com/sanity-io/sdk/commit/969d70e41f6987234323f99753f5cf937469532b)) +* replace `sanityConfigs` prop with `config` prop in `` and `` ([969d70e](https://github.com/sanity-io/sdk/commit/969d70e41f6987234323f99753f5cf937469532b)) +* update document hooks and actions to expect `DocumentHandle` props ([969d70e](https://github.com/sanity-io/sdk/commit/969d70e41f6987234323f99753f5cf937469532b)) +* update project and dataset hooks to use `ProjectHandle` or `DatasetHandle` ([969d70e](https://github.com/sanity-io/sdk/commit/969d70e41f6987234323f99753f5cf937469532b)) +* update query and list hooks to accept optional `DatasetHandle` for configuration ([969d70e](https://github.com/sanity-io/sdk/commit/969d70e41f6987234323f99753f5cf937469532b)) +* use hosted login for standalone apps ([#386](https://github.com/sanity-io/sdk/issues/386)) ([9c1ad58](https://github.com/sanity-io/sdk/commit/9c1ad58bc0b302073c90dd6e584f566eba3d0d17)) + ### Bug Fixes -- **deps:** update message-protocol to 0.7.0 ([#379](https://github.com/sanity-io/sdk/issues/379)) ([553b2f5](https://github.com/sanity-io/sdk/commit/553b2f5249432773c8b0d05b6704a9f17b26137c)) -- **deps:** update pkg-utils to v7 ([#384](https://github.com/sanity-io/sdk/issues/384)) ([ce9a952](https://github.com/sanity-io/sdk/commit/ce9a952a295a32ec86c12cbf9b967128ba5eaf4f)) -- ensure usePreview and useProjection hooks subscribe if no ref is passed ([#366](https://github.com/sanity-io/sdk/issues/366)) ([6da3fd1](https://github.com/sanity-io/sdk/commit/6da3fd158de23956b5f1aa732e31be7a6f312c64)) -- **react:** update app redirect url to new dashboard ([#377](https://github.com/sanity-io/sdk/issues/377)) ([86ec07e](https://github.com/sanity-io/sdk/commit/86ec07e86c194a38f59f2f0f6ee80c0b0b0d0356)) +* **deps:** update message-protocol to 0.7.0 ([#379](https://github.com/sanity-io/sdk/issues/379)) ([553b2f5](https://github.com/sanity-io/sdk/commit/553b2f5249432773c8b0d05b6704a9f17b26137c)) +* **deps:** update pkg-utils to v7 ([#384](https://github.com/sanity-io/sdk/issues/384)) ([ce9a952](https://github.com/sanity-io/sdk/commit/ce9a952a295a32ec86c12cbf9b967128ba5eaf4f)) +* ensure usePreview and useProjection hooks subscribe if no ref is passed ([#366](https://github.com/sanity-io/sdk/issues/366)) ([6da3fd1](https://github.com/sanity-io/sdk/commit/6da3fd158de23956b5f1aa732e31be7a6f312c64)) +* **react:** update app redirect url to new dashboard ([#377](https://github.com/sanity-io/sdk/issues/377)) ([86ec07e](https://github.com/sanity-io/sdk/commit/86ec07e86c194a38f59f2f0f6ee80c0b0b0d0356)) ## [0.0.0-alpha.22](https://github.com/sanity-io/sdk/compare/sdk-react-v0.0.0-alpha.21...sdk-react-v0.0.0-alpha.22) (2025-03-27) + ### Bug Fixes -- **deps:** upgrade `@sanity/client`, do not use `withCredentials` ([#368](https://github.com/sanity-io/sdk/issues/368)) ([8e1cbd9](https://github.com/sanity-io/sdk/commit/8e1cbd92501892bf116c3a3473ae693062518f89)) +* **deps:** upgrade `@sanity/client`, do not use `withCredentials` ([#368](https://github.com/sanity-io/sdk/issues/368)) ([8e1cbd9](https://github.com/sanity-io/sdk/commit/8e1cbd92501892bf116c3a3473ae693062518f89)) ## [0.0.0-alpha.21](https://github.com/sanity-io/sdk/compare/sdk-react-v0.0.0-alpha.20...sdk-react-v0.0.0-alpha.21) (2025-03-25) + ### ⚠ BREAKING CHANGES -- update `useManageFavorite` signature ([#360](https://github.com/sanity-io/sdk/issues/360)) -- rename usePermissions → useDocumentPermissions ([#365](https://github.com/sanity-io/sdk/issues/365)) -- rename useInfiniteList → useDocuments ([#363](https://github.com/sanity-io/sdk/issues/363)) -- rename usePaginatedList → usePaginatedDocuments ([#364](https://github.com/sanity-io/sdk/issues/364)) -- rename useActions → useDocumentActions and useActions → useDocumentActions ([#362](https://github.com/sanity-io/sdk/issues/362)) -- rename useHandleCallback → useHandleAuthCallback and HandleCallback → HandleAuthCallback ([#358](https://github.com/sanity-io/sdk/issues/358)) +* update `useManageFavorite` signature ([#360](https://github.com/sanity-io/sdk/issues/360)) +* rename usePermissions → useDocumentPermissions ([#365](https://github.com/sanity-io/sdk/issues/365)) +* rename useInfiniteList → useDocuments ([#363](https://github.com/sanity-io/sdk/issues/363)) +* rename usePaginatedList → usePaginatedDocuments ([#364](https://github.com/sanity-io/sdk/issues/364)) +* rename useActions → useDocumentActions and useActions → useDocumentActions ([#362](https://github.com/sanity-io/sdk/issues/362)) +* rename useHandleCallback → useHandleAuthCallback and HandleCallback → HandleAuthCallback ([#358](https://github.com/sanity-io/sdk/issues/358)) ### Features -- **docs:** add a migration guide ([#357](https://github.com/sanity-io/sdk/issues/357)) ([47ef529](https://github.com/sanity-io/sdk/commit/47ef529e7d4c9f4453451ac6141d28a81a1dfbfe)) -- rename useActions → useDocumentActions and useActions → useDocumentActions ([#362](https://github.com/sanity-io/sdk/issues/362)) ([c753897](https://github.com/sanity-io/sdk/commit/c75389759a57c6da5ad306dbac46c6d58b4f8dda)) -- rename useInfiniteList → useDocuments ([#363](https://github.com/sanity-io/sdk/issues/363)) ([8e51dcc](https://github.com/sanity-io/sdk/commit/8e51dcc99bfcb84f59dd43f3b7d877daba158fa3)) -- rename usePaginatedList → usePaginatedDocuments ([#364](https://github.com/sanity-io/sdk/issues/364)) ([544019d](https://github.com/sanity-io/sdk/commit/544019d5c85d2c695848dcb6ea089cc84b7fbbcd)) -- rename usePermissions → useDocumentPermissions ([#365](https://github.com/sanity-io/sdk/issues/365)) ([6ca2ada](https://github.com/sanity-io/sdk/commit/6ca2ada0b0d9a0633d46ccf8c0170c1712a3afb4)) -- update `useManageFavorite` signature ([#360](https://github.com/sanity-io/sdk/issues/360)) ([f1617da](https://github.com/sanity-io/sdk/commit/f1617da31ddcb2d0595877f402a6a1ec82c1d0ab)) +* **docs:** add a migration guide ([#357](https://github.com/sanity-io/sdk/issues/357)) ([47ef529](https://github.com/sanity-io/sdk/commit/47ef529e7d4c9f4453451ac6141d28a81a1dfbfe)) +* rename useActions → useDocumentActions and useActions → useDocumentActions ([#362](https://github.com/sanity-io/sdk/issues/362)) ([c753897](https://github.com/sanity-io/sdk/commit/c75389759a57c6da5ad306dbac46c6d58b4f8dda)) +* rename useInfiniteList → useDocuments ([#363](https://github.com/sanity-io/sdk/issues/363)) ([8e51dcc](https://github.com/sanity-io/sdk/commit/8e51dcc99bfcb84f59dd43f3b7d877daba158fa3)) +* rename usePaginatedList → usePaginatedDocuments ([#364](https://github.com/sanity-io/sdk/issues/364)) ([544019d](https://github.com/sanity-io/sdk/commit/544019d5c85d2c695848dcb6ea089cc84b7fbbcd)) +* rename usePermissions → useDocumentPermissions ([#365](https://github.com/sanity-io/sdk/issues/365)) ([6ca2ada](https://github.com/sanity-io/sdk/commit/6ca2ada0b0d9a0633d46ccf8c0170c1712a3afb4)) +* update `useManageFavorite` signature ([#360](https://github.com/sanity-io/sdk/issues/360)) ([f1617da](https://github.com/sanity-io/sdk/commit/f1617da31ddcb2d0595877f402a6a1ec82c1d0ab)) + ### Bug Fixes -- fix typedoc annotations for hooks ([#361](https://github.com/sanity-io/sdk/issues/361)) ([778a63a](https://github.com/sanity-io/sdk/commit/778a63ac5cb52ed6c1e28b1ff22605caad54db33)) +* fix typedoc annotations for hooks ([#361](https://github.com/sanity-io/sdk/issues/361)) ([778a63a](https://github.com/sanity-io/sdk/commit/778a63ac5cb52ed6c1e28b1ff22605caad54db33)) + ### Code Refactoring -- rename useHandleCallback → useHandleAuthCallback and HandleCallback → HandleAuthCallback ([#358](https://github.com/sanity-io/sdk/issues/358)) ([014dc69](https://github.com/sanity-io/sdk/commit/014dc695320273b4e166d946753e851c9701d159)) +* rename useHandleCallback → useHandleAuthCallback and HandleCallback → HandleAuthCallback ([#358](https://github.com/sanity-io/sdk/issues/358)) ([014dc69](https://github.com/sanity-io/sdk/commit/014dc695320273b4e166d946753e851c9701d159)) ## [0.0.0-alpha.20](https://github.com/sanity-io/sdk/compare/sdk-react-v0.0.0-alpha.19...sdk-react-v0.0.0-alpha.20) (2025-03-21) + ### ⚠ BREAKING CHANGES -- rename `results` to `data` for useProjection hook ([#335](https://github.com/sanity-io/sdk/issues/335)) -- rename `result` to `data` for usePreview hook ([#325](https://github.com/sanity-io/sdk/issues/325)) +* rename `results` to `data` for useProjection hook ([#335](https://github.com/sanity-io/sdk/issues/335)) +* rename `result` to `data` for usePreview hook ([#325](https://github.com/sanity-io/sdk/issues/325)) ### Features -- add useDashboardOrganizationId hook ([#339](https://github.com/sanity-io/sdk/issues/339)) ([401468e](https://github.com/sanity-io/sdk/commit/401468e07b8c74deb02d4b7df78af808bddd9242)) -- make packages public ([#320](https://github.com/sanity-io/sdk/issues/320)) ([8c94c29](https://github.com/sanity-io/sdk/commit/8c94c29b0aadd86273db59da1b0577aad682d6e9)) -- **react:** add comlink fetch hook ([#338](https://github.com/sanity-io/sdk/issues/338)) ([1a78882](https://github.com/sanity-io/sdk/commit/1a788824a2c83126c1b39318aa05f8c3964cad8e)) -- **react:** add useNavigateToStudioDocument hook ([#352](https://github.com/sanity-io/sdk/issues/352)) ([a00b9fa](https://github.com/sanity-io/sdk/commit/a00b9fa381bd89f42da4ef95d01f6e5e7c5f0511)) -- **react:** create useStudioWorkspaceById hook ([#343](https://github.com/sanity-io/sdk/issues/343)) ([83feb21](https://github.com/sanity-io/sdk/commit/83feb216e13b903a312a5cffd63f793b29570b30)) -- **react:** use refs for nodes and channels ([#341](https://github.com/sanity-io/sdk/issues/341)) ([4a0b763](https://github.com/sanity-io/sdk/commit/4a0b7637463e8808180a2abe091795e1c3bcef1d)) -- rename `result` to `data` for usePreview hook ([#325](https://github.com/sanity-io/sdk/issues/325)) ([1e5813e](https://github.com/sanity-io/sdk/commit/1e5813e2e26a72c463cafa8c5502043176930a5b)) -- rename `results` to `data` for useProjection hook ([#335](https://github.com/sanity-io/sdk/issues/335)) ([026dd26](https://github.com/sanity-io/sdk/commit/026dd26bffb9fc2a03801ef05a8d075a2968c725)) +* add useDashboardOrganizationId hook ([#339](https://github.com/sanity-io/sdk/issues/339)) ([401468e](https://github.com/sanity-io/sdk/commit/401468e07b8c74deb02d4b7df78af808bddd9242)) +* make packages public ([#320](https://github.com/sanity-io/sdk/issues/320)) ([8c94c29](https://github.com/sanity-io/sdk/commit/8c94c29b0aadd86273db59da1b0577aad682d6e9)) +* **react:** add comlink fetch hook ([#338](https://github.com/sanity-io/sdk/issues/338)) ([1a78882](https://github.com/sanity-io/sdk/commit/1a788824a2c83126c1b39318aa05f8c3964cad8e)) +* **react:** add useNavigateToStudioDocument hook ([#352](https://github.com/sanity-io/sdk/issues/352)) ([a00b9fa](https://github.com/sanity-io/sdk/commit/a00b9fa381bd89f42da4ef95d01f6e5e7c5f0511)) +* **react:** create useStudioWorkspaceById hook ([#343](https://github.com/sanity-io/sdk/issues/343)) ([83feb21](https://github.com/sanity-io/sdk/commit/83feb216e13b903a312a5cffd63f793b29570b30)) +* **react:** use refs for nodes and channels ([#341](https://github.com/sanity-io/sdk/issues/341)) ([4a0b763](https://github.com/sanity-io/sdk/commit/4a0b7637463e8808180a2abe091795e1c3bcef1d)) +* rename `result` to `data` for usePreview hook ([#325](https://github.com/sanity-io/sdk/issues/325)) ([1e5813e](https://github.com/sanity-io/sdk/commit/1e5813e2e26a72c463cafa8c5502043176930a5b)) +* rename `results` to `data` for useProjection hook ([#335](https://github.com/sanity-io/sdk/issues/335)) ([026dd26](https://github.com/sanity-io/sdk/commit/026dd26bffb9fc2a03801ef05a8d075a2968c725)) + ### Bug Fixes -- **deps:** update dependency react-error-boundary to v5 ([#334](https://github.com/sanity-io/sdk/issues/334)) ([a128d7c](https://github.com/sanity-io/sdk/commit/a128d7c7a64f0e724028e0a6f0e0e2f17a399f82)) -- update the react README to use the updated app template ([#354](https://github.com/sanity-io/sdk/issues/354)) ([a2a41d0](https://github.com/sanity-io/sdk/commit/a2a41d0bee9128317a0ee4de59008c75988daa74)) +* **deps:** update dependency react-error-boundary to v5 ([#334](https://github.com/sanity-io/sdk/issues/334)) ([a128d7c](https://github.com/sanity-io/sdk/commit/a128d7c7a64f0e724028e0a6f0e0e2f17a399f82)) +* update the react README to use the updated app template ([#354](https://github.com/sanity-io/sdk/issues/354)) ([a2a41d0](https://github.com/sanity-io/sdk/commit/a2a41d0bee9128317a0ee4de59008c75988daa74)) ## [0.0.0-alpha.19](https://github.com/sanity-io/sdk/compare/sdk-react-v0.0.0-alpha.18...sdk-react-v0.0.0-alpha.19) (2025-03-14) + ### ⚠ BREAKING CHANGES -- **react:** flatten sdk-react imports ([#319](https://github.com/sanity-io/sdk/issues/319)) +* **react:** flatten sdk-react imports ([#319](https://github.com/sanity-io/sdk/issues/319)) ### Features -- **react:** flatten sdk-react imports ([#319](https://github.com/sanity-io/sdk/issues/319)) ([3922025](https://github.com/sanity-io/sdk/commit/3922025569abfa4cd824e81222495913875246d7)) +* **react:** flatten sdk-react imports ([#319](https://github.com/sanity-io/sdk/issues/319)) ([3922025](https://github.com/sanity-io/sdk/commit/3922025569abfa4cd824e81222495913875246d7)) + ### Bug Fixes -- correct the React SDK quickstart ([#317](https://github.com/sanity-io/sdk/issues/317)) ([df5474f](https://github.com/sanity-io/sdk/commit/df5474f478ca6bbde8b471d1beea34f5916470a5)) +* correct the React SDK quickstart ([#317](https://github.com/sanity-io/sdk/issues/317)) ([df5474f](https://github.com/sanity-io/sdk/commit/df5474f478ca6bbde8b471d1beea34f5916470a5)) ## [0.0.0-alpha.18](https://github.com/sanity-io/sdk/compare/sdk-react-v0.0.0-alpha.17...sdk-react-v0.0.0-alpha.18) (2025-03-14) + ### ⚠ BREAKING CHANGES -- remove `schema` from sanity config -- remove schema state and schema manager +* remove `schema` from sanity config +* remove schema state and schema manager ### Features -- **react:** add interaction history and favorite hooks ([#236](https://github.com/sanity-io/sdk/issues/236)) ([b7cdbd6](https://github.com/sanity-io/sdk/commit/b7cdbd648b81dc46054de0e4c1b864471f2daa30)) -- remove `schema` from sanity config ([6257fe3](https://github.com/sanity-io/sdk/commit/6257fe39b4521ace71db54f1d0d173a6019db38d)) -- remove schema state and schema manager ([6257fe3](https://github.com/sanity-io/sdk/commit/6257fe39b4521ace71db54f1d0d173a6019db38d)) -- use projection for previews and remove schema usage ([6257fe3](https://github.com/sanity-io/sdk/commit/6257fe39b4521ace71db54f1d0d173a6019db38d)) +* **react:** add interaction history and favorite hooks ([#236](https://github.com/sanity-io/sdk/issues/236)) ([b7cdbd6](https://github.com/sanity-io/sdk/commit/b7cdbd648b81dc46054de0e4c1b864471f2daa30)) +* remove `schema` from sanity config ([6257fe3](https://github.com/sanity-io/sdk/commit/6257fe39b4521ace71db54f1d0d173a6019db38d)) +* remove schema state and schema manager ([6257fe3](https://github.com/sanity-io/sdk/commit/6257fe39b4521ace71db54f1d0d173a6019db38d)) +* use projection for previews and remove schema usage ([6257fe3](https://github.com/sanity-io/sdk/commit/6257fe39b4521ace71db54f1d0d173a6019db38d)) + ### Bug Fixes -- **react:** remove react compiler runtime package ([#311](https://github.com/sanity-io/sdk/issues/311)) ([08046b5](https://github.com/sanity-io/sdk/commit/08046b565b187cad00f45f8790940e5735a77d5a)) +* **react:** remove react compiler runtime package ([#311](https://github.com/sanity-io/sdk/issues/311)) ([08046b5](https://github.com/sanity-io/sdk/commit/08046b565b187cad00f45f8790940e5735a77d5a)) ## [0.0.0-alpha.17](https://github.com/sanity-io/sdk/compare/sdk-react-v0.0.0-alpha.16...sdk-react-v0.0.0-alpha.17) (2025-03-12) + ### Features -- **react:** add react compiler to the build process ([#298](https://github.com/sanity-io/sdk/issues/298)) ([bfb74eb](https://github.com/sanity-io/sdk/commit/bfb74ebe538b1218a980b03493890b70dc1311d2)) +* **react:** add react compiler to the build process ([#298](https://github.com/sanity-io/sdk/issues/298)) ([bfb74eb](https://github.com/sanity-io/sdk/commit/bfb74ebe538b1218a980b03493890b70dc1311d2)) + ### Bug Fixes -- **auth:** do not perform multiple sid token exchanges ([#308](https://github.com/sanity-io/sdk/issues/308)) ([18461c6](https://github.com/sanity-io/sdk/commit/18461c6837bf532fb7a303efe3f2a279e8fce26f)) -- **docs:** rename infiniteList pageSize -> batchSize, update reference docs ([#303](https://github.com/sanity-io/sdk/issues/303)) ([953d111](https://github.com/sanity-io/sdk/commit/953d1117d680acf5fc2e4f74350fb8f9fd8a9b1d)) -- route Document edit actions to correct resource instance ([#300](https://github.com/sanity-io/sdk/issues/300)) ([9e8f2ac](https://github.com/sanity-io/sdk/commit/9e8f2ac7de3fa1ec6f9af3cc79e3ec9ab45b3e59)) +* **auth:** do not perform multiple sid token exchanges ([#308](https://github.com/sanity-io/sdk/issues/308)) ([18461c6](https://github.com/sanity-io/sdk/commit/18461c6837bf532fb7a303efe3f2a279e8fce26f)) +* **docs:** rename infiniteList pageSize -> batchSize, update reference docs ([#303](https://github.com/sanity-io/sdk/issues/303)) ([953d111](https://github.com/sanity-io/sdk/commit/953d1117d680acf5fc2e4f74350fb8f9fd8a9b1d)) +* route Document edit actions to correct resource instance ([#300](https://github.com/sanity-io/sdk/issues/300)) ([9e8f2ac](https://github.com/sanity-io/sdk/commit/9e8f2ac7de3fa1ec6f9af3cc79e3ec9ab45b3e59)) ## [0.0.0-alpha.16](https://github.com/sanity-io/sdk/compare/sdk-react-v0.0.0-alpha.15...sdk-react-v0.0.0-alpha.16) (2025-03-10) + ### ⚠ BREAKING CHANGES -- remove `useDocuments` and `useSearch` hooks +* remove `useDocuments` and `useSearch` hooks ### Features -- add `useQuery`, `useInfiniteList`, `usePaginatedList` hooks ([1a3f4ad](https://github.com/sanity-io/sdk/commit/1a3f4ad98abf2ab68c552fea20d60639462f3aac)) -- add suspense boundary to prevent recreating instances ([d92e38d](https://github.com/sanity-io/sdk/commit/d92e38d64dfe5c0a35d8de35faa7ecbe5425f023)) -- add versions information to all packages ([#275](https://github.com/sanity-io/sdk/issues/275)) ([afb2fec](https://github.com/sanity-io/sdk/commit/afb2fec63ea3bae53cab9d8f05081daf2f3c2733)) -- **document hooks:** update the documentation for the Document hook s an optional resourceId ([#280](https://github.com/sanity-io/sdk/issues/280)) ([eb65378](https://github.com/sanity-io/sdk/commit/eb65378c884f3aaf9b2c0dbc95dd86075c76f9e0)) -- remove `useDocuments` and `useSearch` hooks ([9f37daf](https://github.com/sanity-io/sdk/commit/9f37daf1243ee0fda558ffd7259c45da9e4ba259)) +* add `useQuery`, `useInfiniteList`, `usePaginatedList` hooks ([1a3f4ad](https://github.com/sanity-io/sdk/commit/1a3f4ad98abf2ab68c552fea20d60639462f3aac)) +* add suspense boundary to prevent recreating instances ([d92e38d](https://github.com/sanity-io/sdk/commit/d92e38d64dfe5c0a35d8de35faa7ecbe5425f023)) +* add versions information to all packages ([#275](https://github.com/sanity-io/sdk/issues/275)) ([afb2fec](https://github.com/sanity-io/sdk/commit/afb2fec63ea3bae53cab9d8f05081daf2f3c2733)) +* **document hooks:** update the documentation for the Document hook s an optional resourceId ([#280](https://github.com/sanity-io/sdk/issues/280)) ([eb65378](https://github.com/sanity-io/sdk/commit/eb65378c884f3aaf9b2c0dbc95dd86075c76f9e0)) +* remove `useDocuments` and `useSearch` hooks ([9f37daf](https://github.com/sanity-io/sdk/commit/9f37daf1243ee0fda558ffd7259c45da9e4ba259)) + ### Bug Fixes -- **deps:** update dependency @sanity/comlink to v3 ([#296](https://github.com/sanity-io/sdk/issues/296)) ([14fbe1b](https://github.com/sanity-io/sdk/commit/14fbe1b89a79d2532e8735a58abbe4a5cff6d635)) -- **deps:** Update sanity monorepo to ^3.78.1 ([#297](https://github.com/sanity-io/sdk/issues/297)) ([835b594](https://github.com/sanity-io/sdk/commit/835b5942d3870a92e0fd1387ab9baa5e555a3ee5)) -- handle env variable for react and react-internal ([#294](https://github.com/sanity-io/sdk/issues/294)) ([0b733ff](https://github.com/sanity-io/sdk/commit/0b733ffbe00bbcb8c29fbee6628ba53c704e1c11)) +* **deps:** update dependency @sanity/comlink to v3 ([#296](https://github.com/sanity-io/sdk/issues/296)) ([14fbe1b](https://github.com/sanity-io/sdk/commit/14fbe1b89a79d2532e8735a58abbe4a5cff6d635)) +* **deps:** Update sanity monorepo to ^3.78.1 ([#297](https://github.com/sanity-io/sdk/issues/297)) ([835b594](https://github.com/sanity-io/sdk/commit/835b5942d3870a92e0fd1387ab9baa5e555a3ee5)) +* handle env variable for react and react-internal ([#294](https://github.com/sanity-io/sdk/issues/294)) ([0b733ff](https://github.com/sanity-io/sdk/commit/0b733ffbe00bbcb8c29fbee6628ba53c704e1c11)) ## [0.0.0-alpha.15](https://github.com/sanity-io/sdk/compare/sdk-react-v0.0.0-alpha.14...sdk-react-v0.0.0-alpha.15) (2025-03-07) + ### ⚠ BREAKING CHANGES -- allow multiple resources via instances ([#271](https://github.com/sanity-io/sdk/issues/271)) +* allow multiple resources via instances ([#271](https://github.com/sanity-io/sdk/issues/271)) ### Features -- add useProjection hook ([#257](https://github.com/sanity-io/sdk/issues/257)) ([fbaafe0](https://github.com/sanity-io/sdk/commit/fbaafe031e235f61b9d60bf5938f18a4683aafe5)) -- allow multiple resources via instances ([#271](https://github.com/sanity-io/sdk/issues/271)) ([6f4d541](https://github.com/sanity-io/sdk/commit/6f4d5410671e8b75759e33380464656a8c961ad6)) -- redirect to core if app opened without core ([#268](https://github.com/sanity-io/sdk/issues/268)) ([3f6bb83](https://github.com/sanity-io/sdk/commit/3f6bb8344cee6d582aaee0d7ba64b9cb3035469f)) +* add useProjection hook ([#257](https://github.com/sanity-io/sdk/issues/257)) ([fbaafe0](https://github.com/sanity-io/sdk/commit/fbaafe031e235f61b9d60bf5938f18a4683aafe5)) +* allow multiple resources via instances ([#271](https://github.com/sanity-io/sdk/issues/271)) ([6f4d541](https://github.com/sanity-io/sdk/commit/6f4d5410671e8b75759e33380464656a8c961ad6)) +* redirect to core if app opened without core ([#268](https://github.com/sanity-io/sdk/issues/268)) ([3f6bb83](https://github.com/sanity-io/sdk/commit/3f6bb8344cee6d582aaee0d7ba64b9cb3035469f)) ## [0.0.0-alpha.14](https://github.com/sanity-io/sdk/compare/sdk-react-v0.0.0-alpha.13...sdk-react-v0.0.0-alpha.14) (2025-03-05) + ### Features -- `useProjects`, `useProject`, `useDatasets` ([#235](https://github.com/sanity-io/sdk/issues/235)) ([cc95dfd](https://github.com/sanity-io/sdk/commit/cc95dfd45a82171fa7ccf05a8ca331e8de97fbee)) -- **react:** add SDKProvider app to use SDK without core ([#263](https://github.com/sanity-io/sdk/issues/263)) ([51e84fc](https://github.com/sanity-io/sdk/commit/51e84fcd7b64558bc108f00d3fb5a98aade25d29)) -- **react:** add useSearch hook ([#258](https://github.com/sanity-io/sdk/issues/258)) ([488317a](https://github.com/sanity-io/sdk/commit/488317a72987daf88385f757a60ffdc191333218)) +* `useProjects`, `useProject`, `useDatasets` ([#235](https://github.com/sanity-io/sdk/issues/235)) ([cc95dfd](https://github.com/sanity-io/sdk/commit/cc95dfd45a82171fa7ccf05a8ca331e8de97fbee)) +* **react:** add SDKProvider app to use SDK without core ([#263](https://github.com/sanity-io/sdk/issues/263)) ([51e84fc](https://github.com/sanity-io/sdk/commit/51e84fcd7b64558bc108f00d3fb5a98aade25d29)) +* **react:** add useSearch hook ([#258](https://github.com/sanity-io/sdk/issues/258)) ([488317a](https://github.com/sanity-io/sdk/commit/488317a72987daf88385f757a60ffdc191333218)) + ### Bug Fixes -- add access api types inside the SDK ([#261](https://github.com/sanity-io/sdk/issues/261)) ([ff53123](https://github.com/sanity-io/sdk/commit/ff53123f2e01a242c22df22b9dc109d2cbc3b1d4)) +* add access api types inside the SDK ([#261](https://github.com/sanity-io/sdk/issues/261)) ([ff53123](https://github.com/sanity-io/sdk/commit/ff53123f2e01a242c22df22b9dc109d2cbc3b1d4)) ## [0.0.0-alpha.13](https://github.com/sanity-io/sdk/compare/sdk-react-v0.0.0-alpha.12...sdk-react-v0.0.0-alpha.13) (2025-02-28) + ### Features -- add useUsers hook ([#239](https://github.com/sanity-io/sdk/issues/239)) ([b89bcf0](https://github.com/sanity-io/sdk/commit/b89bcf00bc4a849409ae80f45b1917cb1e51c66e)) +* add useUsers hook ([#239](https://github.com/sanity-io/sdk/issues/239)) ([b89bcf0](https://github.com/sanity-io/sdk/commit/b89bcf00bc4a849409ae80f45b1917cb1e51c66e)) + ### Bug Fixes -- **react:** update bridge script import for AuthBoundary ([#234](https://github.com/sanity-io/sdk/issues/234)) ([fe69106](https://github.com/sanity-io/sdk/commit/fe69106d35f5e1dee9f901ec21424042d7f9dc18)) +* **react:** update bridge script import for AuthBoundary ([#234](https://github.com/sanity-io/sdk/issues/234)) ([fe69106](https://github.com/sanity-io/sdk/commit/fe69106d35f5e1dee9f901ec21424042d7f9dc18)) ## [0.0.0-alpha.12](https://github.com/sanity-io/sdk/compare/sdk-react-v0.0.0-alpha.11...sdk-react-v0.0.0-alpha.12) (2025-02-28) + ### Features -- **auth:** refresh stamped tokens ([#225](https://github.com/sanity-io/sdk/issues/225)) ([10b2745](https://github.com/sanity-io/sdk/commit/10b2745c62f9169b8cd1c66d7fb641d7fda37429)) -- document permissions ([#226](https://github.com/sanity-io/sdk/issues/226)) ([107f434](https://github.com/sanity-io/sdk/commit/107f4349d7defab04d1282ee1ab20766d157eab7)) +* **auth:** refresh stamped tokens ([#225](https://github.com/sanity-io/sdk/issues/225)) ([10b2745](https://github.com/sanity-io/sdk/commit/10b2745c62f9169b8cd1c66d7fb641d7fda37429)) +* document permissions ([#226](https://github.com/sanity-io/sdk/issues/226)) ([107f434](https://github.com/sanity-io/sdk/commit/107f4349d7defab04d1282ee1ab20766d157eab7)) + ### Bug Fixes -- **comlink:** expose statuses and destroy unused resources ([#233](https://github.com/sanity-io/sdk/issues/233)) ([8b8a40c](https://github.com/sanity-io/sdk/commit/8b8a40c5ac0b5ba76cda043ffc9bc3b740bce5bd)) +* **comlink:** expose statuses and destroy unused resources ([#233](https://github.com/sanity-io/sdk/issues/233)) ([8b8a40c](https://github.com/sanity-io/sdk/commit/8b8a40c5ac0b5ba76cda043ffc9bc3b740bce5bd)) ## [0.0.0-alpha.11](https://github.com/sanity-io/sdk/compare/sdk-react-v0.0.0-alpha.10...sdk-react-v0.0.0-alpha.11) (2025-02-13) + ### Features -- add sdk-react-internal package and remove @sanity/ui package ([#193](https://github.com/sanity-io/sdk/issues/193)) ([7fa201e](https://github.com/sanity-io/sdk/commit/7fa201ee49b75bbc71a741503ed0336f94785201)) +* add sdk-react-internal package and remove @sanity/ui package ([#193](https://github.com/sanity-io/sdk/issues/193)) ([7fa201e](https://github.com/sanity-io/sdk/commit/7fa201ee49b75bbc71a741503ed0336f94785201)) ## [0.0.0-alpha.10](https://github.com/sanity-io/sdk/compare/sdk-react-v0.0.0-alpha.9...sdk-react-v0.0.0-alpha.10) (2025-02-12) + ### Features -- allow useEditDocument to take an updater function ([#218](https://github.com/sanity-io/sdk/issues/218)) ([85b3440](https://github.com/sanity-io/sdk/commit/85b344007df3fd66ce7dae94df8f6b8a81f54574)) +* allow useEditDocument to take an updater function ([#218](https://github.com/sanity-io/sdk/issues/218)) ([85b3440](https://github.com/sanity-io/sdk/commit/85b344007df3fd66ce7dae94df8f6b8a81f54574)) ## [0.0.0-alpha.9](https://github.com/sanity-io/sdk/compare/sdk-react-v0.0.0-alpha.8...sdk-react-v0.0.0-alpha.9) (2025-02-11) + ### Features -- document store ([#197](https://github.com/sanity-io/sdk/issues/197)) ([497bb26](https://github.com/sanity-io/sdk/commit/497bb2641d5766128dfca4db8247f2f9555b83b1)) +* document store ([#197](https://github.com/sanity-io/sdk/issues/197)) ([497bb26](https://github.com/sanity-io/sdk/commit/497bb2641d5766128dfca4db8247f2f9555b83b1)) ## [0.0.0-alpha.8](https://github.com/sanity-io/sdk/compare/sdk-react-v0.0.0-alpha.7...sdk-react-v0.0.0-alpha.8) (2025-02-06) + ### Features -- export useClient ([#213](https://github.com/sanity-io/sdk/issues/213)) ([0e79002](https://github.com/sanity-io/sdk/commit/0e790020ee0f688e6f07243c5605b5cbffe4b1c5)) +* export useClient ([#213](https://github.com/sanity-io/sdk/issues/213)) ([0e79002](https://github.com/sanity-io/sdk/commit/0e790020ee0f688e6f07243c5605b5cbffe4b1c5)) ## [0.0.0-alpha.7](https://github.com/sanity-io/sdk/compare/sdk-react-v0.0.0-alpha.6...sdk-react-v0.0.0-alpha.7) (2025-02-05) + ### Features -- **react:** add sanity os bridge script to AuthBoundary ([#196](https://github.com/sanity-io/sdk/issues/196)) ([1fb064d](https://github.com/sanity-io/sdk/commit/1fb064d111541bf93c8933920d7bce00a9c454ef)) +* **react:** add sanity os bridge script to AuthBoundary ([#196](https://github.com/sanity-io/sdk/issues/196)) ([1fb064d](https://github.com/sanity-io/sdk/commit/1fb064d111541bf93c8933920d7bce00a9c454ef)) + ### Bug Fixes -- adjust incorrect release back to alpha.6 ([#212](https://github.com/sanity-io/sdk/issues/212)) ([a946853](https://github.com/sanity-io/sdk/commit/a9468530e16ee056d972d913e4f046ceb0610134)) -- trigger release ([#210](https://github.com/sanity-io/sdk/issues/210)) ([2b36c98](https://github.com/sanity-io/sdk/commit/2b36c985a91d44be95a9e6c8446e9a11ffa59d61)) +* adjust incorrect release back to alpha.6 ([#212](https://github.com/sanity-io/sdk/issues/212)) ([a946853](https://github.com/sanity-io/sdk/commit/a9468530e16ee056d972d913e4f046ceb0610134)) +* trigger release ([#210](https://github.com/sanity-io/sdk/issues/210)) ([2b36c98](https://github.com/sanity-io/sdk/commit/2b36c985a91d44be95a9e6c8446e9a11ffa59d61)) ## [0.0.0-alpha.6](https://github.com/sanity-io/sdk/compare/sdk-react-v0.0.0-alpha.5...sdk-react-v0.0.0-alpha.6) (2025-01-30) From b6cadfb66518c7bc3291799319f00b0c7583317e Mon Sep 17 00:00:00 2001 From: Ryan Bonial Date: Fri, 30 May 2025 15:17:24 -0600 Subject: [PATCH 04/17] refactor: handle 401 in comlink token refresh --- packages/core/src/comlink/types.ts | 7 ++- .../src/components/auth/AuthBoundary.tsx | 2 + .../react/src/context/ComlinkTokenRefresh.tsx | 54 +++++++++++++++---- 3 files changed, 50 insertions(+), 13 deletions(-) diff --git a/packages/core/src/comlink/types.ts b/packages/core/src/comlink/types.ts index dc667af2..47d4db0e 100644 --- a/packages/core/src/comlink/types.ts +++ b/packages/core/src/comlink/types.ts @@ -13,15 +13,18 @@ export type FrameMessage = Message export type WindowMessage = Message /** + * Message from SDK (iframe) to Parent (dashboard) to request a new token * @internal */ -/** Message from SDK (iframe) to Parent (dashboard) to request a new token */ export type RequestNewTokenMessage = { type: 'dashboard/v1/auth/tokens/create' payload?: undefined } -/** Message from Parent (dashboard) to SDK (iframe) with the new token */ +/** + * Message from Parent (dashboard) to SDK (iframe) with the new token + * @internal + */ export type NewTokenResponseMessage = { type: 'dashboard/v1/auth/tokens/create' payload: {token: string | null; error?: string} diff --git a/packages/react/src/components/auth/AuthBoundary.tsx b/packages/react/src/components/auth/AuthBoundary.tsx index d439e28b..43906f9d 100644 --- a/packages/react/src/components/auth/AuthBoundary.tsx +++ b/packages/react/src/components/auth/AuthBoundary.tsx @@ -2,6 +2,7 @@ import {AuthStateType} from '@sanity/sdk' import {useEffect, useMemo} from 'react' import {ErrorBoundary, type FallbackProps} from 'react-error-boundary' +import {useComlinkTokenRefresh} from '../../context/ComlinkTokenRefresh' import {useAuthState} from '../../hooks/auth/useAuthState' import {useLoginUrl} from '../../hooks/auth/useLoginUrl' import {useVerifyOrgProjects} from '../../hooks/auth/useVerifyOrgProjects' @@ -145,6 +146,7 @@ function AuthSwitch({ const isLoggedOut = authState.type === AuthStateType.LOGGED_OUT && !authState.isDestroyingSession const loginUrl = useLoginUrl() + useComlinkTokenRefresh() // Initialize the comlink token refresh context for Dashboard Comlink useEffect(() => { if (isLoggedOut && !isInIframe()) { diff --git a/packages/react/src/context/ComlinkTokenRefresh.tsx b/packages/react/src/context/ComlinkTokenRefresh.tsx index f83ef270..0905f8ee 100644 --- a/packages/react/src/context/ComlinkTokenRefresh.tsx +++ b/packages/react/src/context/ComlinkTokenRefresh.tsx @@ -1,7 +1,9 @@ -import {type Status as ComlinkStatus} from '@sanity/comlink' // Import Status as ComlinkStatus +import {type ClientError} from '@sanity/client' +import {type Status as ComlinkStatus} from '@sanity/comlink' import { + AuthStateType, type FrameMessage, - getIsInDashboardState, // <-- Import the new selector + getIsInDashboardState, type NewTokenResponseMessage, type RequestNewTokenMessage, setAuthToken, @@ -18,8 +20,9 @@ import React, { useState, } from 'react' -import {useWindowConnection} from '../hooks/comlink/useWindowConnection' // <-- Correct path to useWindowConnection -import {useSanityInstance} from '../hooks/context/useSanityInstance' // Import the instance hook +import {useAuthState} from '../hooks/auth/useAuthState' +import {useWindowConnection} from '../hooks/comlink/useWindowConnection' +import {useSanityInstance} from '../hooks/context/useSanityInstance' // Define specific message types extending the base types for clarity type SdkParentComlinkMessage = NewTokenResponseMessage | WindowMessage // Messages received by SDK @@ -58,15 +61,15 @@ export const ComlinkTokenRefreshProvider: React.FC< parentName = DEFAULT_PARENT_NAME, responseTimeout = DEFAULT_RESPONSE_TIMEOUT, }) => { - const instance = useSanityInstance() // Get the instance + const instance = useSanityInstance() const [comlinkStatus, setComlinkStatus] = useState('idle') const isTokenRefreshInProgress = useRef(false) const timeoutRef = useRef(null) + const processed401ErrorRef = useRef(null) // Ref to track processed 401 error - // Get the dashboard status value once - const isInDashboard = useMemo(() => getIsInDashboardState(instance).getCurrent(), [instance]) + const authState = useAuthState() - // Determine if the feature should be active + const isInDashboard = useMemo(() => getIsInDashboardState(instance).getCurrent(), [instance]) const isDashboardComlinkEnabled = enabled && isInDashboard const clearRefreshTimeout = useCallback(() => { @@ -76,7 +79,6 @@ export const ComlinkTokenRefreshProvider: React.FC< } }, []) - // Conditionally connect only if operational const connectionOptions = useMemo( () => isDashboardComlinkEnabled @@ -115,7 +117,6 @@ export const ComlinkTokenRefreshProvider: React.FC< ) const requestNewToken = useCallback(() => { - // Check if operational before proceeding if (!isDashboardComlinkEnabled) { return } @@ -163,6 +164,34 @@ export const ComlinkTokenRefreshProvider: React.FC< } }, [clearRefreshTimeout]) + // Effect to automatically request a new token on 401 error if enabled + useEffect(() => { + if ( + isDashboardComlinkEnabled && + authState.type === AuthStateType.ERROR && + authState.error && + (authState.error as ClientError)?.statusCode === 401 && + !isTokenRefreshInProgress.current && + processed401ErrorRef.current !== authState.error // Check if this specific error instance has been processed + ) { + // Mark this error instance as processed before requesting token + processed401ErrorRef.current = authState.error + requestNewToken() + } else if ( + authState.type !== AuthStateType.ERROR || + processed401ErrorRef.current !== authState.error + ) { + // Reset if the error is no longer a 401 or a different error occurs + processed401ErrorRef.current = null + } + }, [ + authState, + isDashboardComlinkEnabled, + requestNewToken, + // Dependency: isTokenRefreshInProgress.current won't trigger effect, use the ref itself + isTokenRefreshInProgress, + ]) + return ( {children} @@ -175,7 +204,10 @@ export const useComlinkTokenRefresh = (): ComlinkTokenRefreshContextValue => { if (!context) { return { requestNewToken: () => { - /* console.warn(...) */ + // eslint-disable-next-line no-console + console.warn( + 'useComlinkTokenRefresh must be used within a ComlinkTokenRefreshProvider with the feature enabled.', + ) }, isTokenRefreshInProgress: {current: false}, comlinkStatus: 'idle', From 1ae3c79ae53cf60328d0665d1cab3d5c96ab32aa Mon Sep 17 00:00:00 2001 From: Ryan Bonial Date: Fri, 30 May 2025 15:44:27 -0600 Subject: [PATCH 05/17] chore: add exports --- packages/react/src/_exports/sdk-react.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/react/src/_exports/sdk-react.ts b/packages/react/src/_exports/sdk-react.ts index 0fa82995..5a83e3b8 100644 --- a/packages/react/src/_exports/sdk-react.ts +++ b/packages/react/src/_exports/sdk-react.ts @@ -4,6 +4,11 @@ export {AuthBoundary, type AuthBoundaryProps} from '../components/auth/AuthBoundary' export {SanityApp, type SanityAppProps} from '../components/SanityApp' export {SDKProvider, type SDKProviderProps} from '../components/SDKProvider' +export { + type ComlinkTokenRefreshConfig, + ComlinkTokenRefreshProvider, + useComlinkTokenRefresh, +} from '../context/ComlinkTokenRefresh' export {ResourceProvider, type ResourceProviderProps} from '../context/ResourceProvider' export {useAuthState} from '../hooks/auth/useAuthState' export {useAuthToken} from '../hooks/auth/useAuthToken' From 43b7f2e2f5457f6352dd837641ed61e043826f4d Mon Sep 17 00:00:00 2001 From: Ryan Bonial Date: Fri, 30 May 2025 15:52:34 -0600 Subject: [PATCH 06/17] chore: add tsdoc --- .../react/src/context/ComlinkTokenRefresh.tsx | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/packages/react/src/context/ComlinkTokenRefresh.tsx b/packages/react/src/context/ComlinkTokenRefresh.tsx index 0905f8ee..d4bad387 100644 --- a/packages/react/src/context/ComlinkTokenRefresh.tsx +++ b/packages/react/src/context/ComlinkTokenRefresh.tsx @@ -28,6 +28,11 @@ import {useSanityInstance} from '../hooks/context/useSanityInstance' type SdkParentComlinkMessage = NewTokenResponseMessage | WindowMessage // Messages received by SDK type SdkChildComlinkMessage = RequestNewTokenMessage | FrameMessage // Messages sent by SDK +/** + * This config is used to configure the Comlink token refresh feature. + * It is used to automatically request a new token on 401 error if enabled. + * @public + */ export type ComlinkTokenRefreshConfig = { /** Enable the Comlink token refresh feature. Defaults to false */ enabled?: boolean @@ -52,6 +57,11 @@ const DEFAULT_COMLINK_NAME = 'sanity-sdk-iframe' const DEFAULT_PARENT_NAME = 'sanity-dashboard-parent' const DEFAULT_RESPONSE_TIMEOUT = 15000 // 15 seconds +/** + * This provider is used to provide the Comlink token refresh feature. + * It is used to automatically request a new token on 401 error if enabled. + * @public + */ export const ComlinkTokenRefreshProvider: React.FC< PropsWithChildren > = ({ @@ -199,6 +209,11 @@ export const ComlinkTokenRefreshProvider: React.FC< ) } +/** + * This hook is used to request a new token from the parent window. + * It is used to automatically request a new token on 401 error if enabled. + * @public + */ export const useComlinkTokenRefresh = (): ComlinkTokenRefreshContextValue => { const context = useContext(ComlinkTokenRefreshContext) if (!context) { From efd34928c58279eb3ce38f64ba5cd16d99bc383c Mon Sep 17 00:00:00 2001 From: Ryan Bonial Date: Fri, 30 May 2025 16:42:08 -0600 Subject: [PATCH 07/17] chore: add tests --- .../src/context/ComlinkTokenRefresh.test.tsx | 550 ++++++++++++++++++ .../react/src/context/ComlinkTokenRefresh.tsx | 19 +- 2 files changed, 554 insertions(+), 15 deletions(-) create mode 100644 packages/react/src/context/ComlinkTokenRefresh.test.tsx diff --git a/packages/react/src/context/ComlinkTokenRefresh.test.tsx b/packages/react/src/context/ComlinkTokenRefresh.test.tsx new file mode 100644 index 00000000..41172986 --- /dev/null +++ b/packages/react/src/context/ComlinkTokenRefresh.test.tsx @@ -0,0 +1,550 @@ +import {AuthStateType, getIsInDashboardState, setAuthToken} from '@sanity/sdk' +import {act, render, waitFor} from '@testing-library/react' +import React from 'react' +import {afterEach, beforeEach, describe, expect, it, type Mock, vi} from 'vitest' + +import {useAuthState} from '../hooks/auth/useAuthState' +import {useWindowConnection} from '../hooks/comlink/useWindowConnection' +import {useSanityInstance} from '../hooks/context/useSanityInstance' +import { + type ComlinkTokenRefreshConfig, + ComlinkTokenRefreshProvider, + useComlinkTokenRefresh, +} from './ComlinkTokenRefresh' + +// Mocks +vi.mock('@sanity/sdk', async () => { + const actual = await vi.importActual('@sanity/sdk') + return { + ...actual, + getIsInDashboardState: vi.fn(() => ({getCurrent: vi.fn()})), + setAuthToken: vi.fn(), + } +}) + +vi.mock('../hooks/auth/useAuthState') +vi.mock('../hooks/comlink/useWindowConnection') +vi.mock('../hooks/context/useSanityInstance') + +// Use simpler mock typings +const mockGetIsInDashboardState = getIsInDashboardState as Mock +const mockSetAuthToken = setAuthToken as Mock +const mockUseAuthState = useAuthState as Mock +const mockUseWindowConnection = useWindowConnection as Mock +const mockUseSanityInstance = useSanityInstance as Mock + +const mockSendMessage = vi.fn() +// eslint-disable-next-line @typescript-eslint/no-explicit-any +const mockSanityInstance: any = {projectId: 'test', dataset: 'test'} + +// Variable to capture the hook's current value for direct assertions +let currentHookValue: ReturnType + +describe('ComlinkTokenRefresh', () => { + beforeEach(() => { + vi.useFakeTimers() + mockGetIsInDashboardState.mockReturnValue({getCurrent: vi.fn(() => false)}) + mockUseAuthState.mockReturnValue({type: AuthStateType.LOGGED_IN}) + mockUseWindowConnection.mockReturnValue({sendMessage: mockSendMessage, connection: undefined}) + mockUseSanityInstance.mockReturnValue(mockSanityInstance) + vi.spyOn(console, 'warn').mockImplementation(() => {}) // Mock console.warn + // Initialize currentHookValue with default structure + currentHookValue = { + requestNewToken: () => {}, + isTokenRefreshInProgress: {current: false}, + comlinkStatus: 'idle', + isEnabled: false, + } + }) + + afterEach(() => { + vi.clearAllMocks() + vi.useRealTimers() + }) + + interface TestComponentProps { + onHookUpdate?: (value: ReturnType) => void + } + + const TestComponent: React.FC = ({onHookUpdate}) => { + const hookValue = useComlinkTokenRefresh() + React.useEffect(() => { + onHookUpdate?.(hookValue) + }, [hookValue, onHookUpdate]) // Update when hookValue or callback changes + + return ( +
+ {String(hookValue.isEnabled)} + {hookValue.comlinkStatus} + + {String(hookValue.isTokenRefreshInProgress.current)} + + +
+ ) + } + + const renderWithProvider = ( + props?: ComlinkTokenRefreshConfig, + testComponentProps?: TestComponentProps, + children?: React.ReactNode, // Allow custom children as before + ) => { + const onHookUpdateCallback = + testComponentProps?.onHookUpdate || + ((value) => { + currentHookValue = value + }) + return render( + + {children || } + , + ) + } + + describe('useComlinkTokenRefresh without Provider', () => { + it('should return default values and warn on requestNewToken', () => { + // Render TestComponent directly without ComlinkTokenRefreshProvider + const {getByText, getByTestId} = render( + (currentHookValue = value)} />, + ) + + expect(currentHookValue.isEnabled).toBe(false) + expect(currentHookValue.comlinkStatus).toBe('idle') + expect(currentHookValue.isTokenRefreshInProgress.current).toBe(false) + + expect(getByTestId('is-enabled').textContent).toBe('false') + expect(getByTestId('comlink-status').textContent).toBe('idle') + expect(getByTestId('is-in-progress').textContent).toBe('false') + + act(() => { + getByText('Request Token').click() + }) + + // eslint-disable-next-line no-console + expect(console.warn).toHaveBeenCalledWith( + 'useComlinkTokenRefresh must be used within a ComlinkTokenRefreshProvider with the feature enabled.', + ) + expect(mockSendMessage).not.toHaveBeenCalled() + }) + }) + + describe('ComlinkTokenRefreshProvider', () => { + it('should provide default context values when disabled', () => { + renderWithProvider({enabled: false}) + expect(currentHookValue.isEnabled).toBe(false) + expect(currentHookValue.comlinkStatus).toBe('idle') + expect(currentHookValue.isTokenRefreshInProgress.current).toBe(false) + }) + + it('requestNewToken should do nothing and not warn if disabled', () => { + const {getByText} = renderWithProvider({enabled: false}) + act(() => { + getByText('Request Token').click() + }) + expect(mockSendMessage).not.toHaveBeenCalled() + // eslint-disable-next-line no-console + expect(console.warn).not.toHaveBeenCalled() + expect(currentHookValue.isTokenRefreshInProgress.current).toBe(false) + }) + + it('should provide enabled as true from context when enabled prop is true', () => { + renderWithProvider({enabled: true}) + expect(currentHookValue.isEnabled).toBe(true) + }) + + describe('when enabled and not in dashboard', () => { + beforeEach(() => { + mockGetIsInDashboardState.mockReturnValue({getCurrent: () => false}) + }) + + it('should have comlinkStatus idle and requestNewToken should do nothing', () => { + const {getByText} = renderWithProvider({enabled: true}) + expect(currentHookValue.isEnabled).toBe(true) + expect(currentHookValue.comlinkStatus).toBe('idle') + + act(() => { + getByText('Request Token').click() + }) + expect(mockSendMessage).not.toHaveBeenCalled() + expect(currentHookValue.isTokenRefreshInProgress.current).toBe(false) + }) + }) + + describe('when enabled and in dashboard', () => { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const comlinkCallbacks: any = {} + + beforeEach(() => { + mockGetIsInDashboardState.mockReturnValue({getCurrent: () => true}) + // Capture the onMessage and onStatus callbacks + // eslint-disable-next-line @typescript-eslint/no-explicit-any + mockUseWindowConnection.mockImplementation((options: any) => { + // Fix: Safely access options properties + if (options && options.onMessage) comlinkCallbacks.onMessage = options.onMessage + if (options && options.onStatus) comlinkCallbacks.onStatus = options.onStatus + return {sendMessage: mockSendMessage, connection: undefined} + }) + }) + + it('should initialize useWindowConnection with correct parameters and allow comlink status update', () => { + renderWithProvider({ + enabled: true, + comlinkName: 'test-sdk', + parentName: 'test-parent', + }) + + expect(mockUseWindowConnection).toHaveBeenCalledWith( + expect.objectContaining({ + name: 'test-sdk', + connectTo: 'test-parent', + }), + ) + + act(() => { + comlinkCallbacks.onStatus?.('connected') + }) + expect(currentHookValue.comlinkStatus).toBe('connected') + }) + + it('requestNewToken should do nothing if comlinkStatus is not "connected"', () => { + renderWithProvider({enabled: true}) + act(() => { + comlinkCallbacks.onStatus?.('connecting') + }) + expect(currentHookValue.comlinkStatus).toBe('connecting') + + act(() => { + currentHookValue.requestNewToken() // Call directly for this check + }) + expect(mockSendMessage).not.toHaveBeenCalled() + expect(currentHookValue.isTokenRefreshInProgress.current).toBe(false) + }) + + it('requestNewToken should do nothing if token refresh is already in progress', () => { + const {getByText} = renderWithProvider({enabled: true}) + act(() => { + comlinkCallbacks.onStatus?.('connected') + }) + expect(currentHookValue.comlinkStatus).toBe('connected') + + // Start a request + act(() => { + getByText('Request Token').click() + }) + expect(mockSendMessage).toHaveBeenCalledTimes(1) + expect(currentHookValue.isTokenRefreshInProgress.current).toBe(true) + + // Try to start another one + act(() => { + getByText('Request Token').click() + }) + expect(mockSendMessage).toHaveBeenCalledTimes(1) // Still 1 + expect(currentHookValue.isTokenRefreshInProgress.current).toBe(true) + + act(() => { + vi.advanceTimersByTime(15000) // Default timeout + }) + expect(currentHookValue.isTokenRefreshInProgress.current).toBe(false) + }) + + it('requestNewToken should send message and set inProgress, then timeout', async () => { + const responseTimeout = 5000 + const {getByText} = renderWithProvider({enabled: true, responseTimeout}) + act(() => { + comlinkCallbacks.onStatus?.('connected') + }) + + act(() => { + getByText('Request Token').click() + }) + + expect(mockSendMessage).toHaveBeenCalledWith('dashboard/v1/auth/tokens/create') + expect(currentHookValue.isTokenRefreshInProgress.current).toBe(true) + + act(() => { + vi.advanceTimersByTime(responseTimeout - 1) + }) + expect(currentHookValue.isTokenRefreshInProgress.current).toBe(true) + + act(() => { + vi.advanceTimersByTime(1) + }) + expect(currentHookValue.isTokenRefreshInProgress.current).toBe(false) + }) + + it('should handle received token and reset inProgress', () => { + const {getByText} = renderWithProvider({enabled: true}) + act(() => { + comlinkCallbacks.onStatus?.('connected') + }) + + act(() => { + getByText('Request Token').click() + }) + expect(currentHookValue.isTokenRefreshInProgress.current).toBe(true) + expect(mockSendMessage).toHaveBeenCalledTimes(1) + + act(() => { + comlinkCallbacks.onMessage['dashboard/v1/auth/tokens/create']({token: 'new-token'}) + }) + + expect(mockSetAuthToken).toHaveBeenCalledWith(mockSanityInstance, 'new-token') + expect(currentHookValue.isTokenRefreshInProgress.current).toBe(false) + // Ensure timeout was cleared (check by advancing time - progress should still be false) + act(() => { + vi.advanceTimersByTime(15000) // Default timeout + }) + expect(currentHookValue.isTokenRefreshInProgress.current).toBe(false) + }) + + it('should not set auth token if received token is null', () => { + renderWithProvider({enabled: true}) + act(() => { + comlinkCallbacks.onStatus?.('connected') + }) + act(() => { + currentHookValue.requestNewToken() + }) + act(() => { + comlinkCallbacks.onMessage['dashboard/v1/auth/tokens/create']({token: null}) + }) + expect(mockSetAuthToken).not.toHaveBeenCalled() + expect(currentHookValue.isTokenRefreshInProgress.current).toBe(false) + }) + + it('should reset inProgress if sendMessage throws', () => { + mockSendMessage.mockImplementationOnce(() => { + throw new Error('Send failed') + }) + renderWithProvider({enabled: true}) + act(() => { + comlinkCallbacks.onStatus?.('connected') + }) + act(() => { + currentHookValue.requestNewToken() + }) + expect(currentHookValue.isTokenRefreshInProgress.current).toBe(false) + expect(mockSendMessage).toHaveBeenCalledTimes(1) + }) + + describe('Automatic token refresh on 401', () => { + const createError401 = () => ({statusCode: 401, message: 'Unauthorized'}) + + it.skip('should request new token on 401 error if not already in progress', async () => { + mockUseAuthState.mockReturnValue({type: AuthStateType.LOGGED_IN}) + const {rerender} = renderWithProvider({enabled: true}) + + act(() => { + comlinkCallbacks.onStatus?.('connected') + }) + expect(currentHookValue.comlinkStatus).toBe('connected') + + currentHookValue.isTokenRefreshInProgress.current = false + act(() => { + rerender( + + + , + ) + }) + expect(currentHookValue.isTokenRefreshInProgress.current).toBe(false) + + mockUseAuthState.mockReturnValue({type: AuthStateType.ERROR, error: createError401()}) + act(() => { + rerender( + + + , + ) + }) + + await waitFor( + () => { + expect(mockSendMessage).toHaveBeenCalledWith('dashboard/v1/auth/tokens/create') + }, + {timeout: 10000}, + ) + expect(currentHookValue.isTokenRefreshInProgress.current).toBe(true) + }, 10000) + + it('should not request new token on 401 if refresh is already in progress', async () => { + mockUseAuthState.mockReturnValue({type: AuthStateType.LOGGED_IN}) + const {rerender, getByText} = renderWithProvider({enabled: true}) + act(() => { + comlinkCallbacks.onStatus?.('connected') + }) + + act(() => { + getByText('Request Token').click() + }) + expect(currentHookValue.isTokenRefreshInProgress.current).toBe(true) + mockSendMessage.mockClear() + + mockUseAuthState.mockReturnValue({type: AuthStateType.ERROR, error: createError401()}) + act(() => { + rerender( + + + , + ) + }) + + await act(async () => { + await vi.advanceTimersByTimeAsync(100) + }) + expect(mockSendMessage).not.toHaveBeenCalled() + expect(currentHookValue.isTokenRefreshInProgress.current).toBe(true) + }, 10000) + + it('should not request new token on 401 if not in dashboard', async () => { + mockGetIsInDashboardState.mockReturnValue({getCurrent: () => false}) + mockUseAuthState.mockReturnValue({type: AuthStateType.LOGGED_IN}) + const {rerender} = renderWithProvider({enabled: true}) + + mockUseAuthState.mockReturnValue({type: AuthStateType.ERROR, error: createError401()}) + act(() => { + rerender( + + + , + ) + }) + + await act(async () => { + await vi.advanceTimersByTimeAsync(100) + }) + expect(mockSendMessage).not.toHaveBeenCalled() + expect(currentHookValue.isTokenRefreshInProgress.current).toBe(false) + }, 10000) + + it('should not request new token for non-401 errors', async () => { + const error500 = {statusCode: 500, message: 'Server Error'} + mockUseAuthState.mockReturnValue({type: AuthStateType.LOGGED_IN}) + const {rerender} = renderWithProvider({enabled: true}) + act(() => { + comlinkCallbacks.onStatus?.('connected') + }) + + mockUseAuthState.mockReturnValue({type: AuthStateType.ERROR, error: error500}) + act(() => { + rerender( + + + , + ) + }) + + await act(async () => { + await vi.advanceTimersByTimeAsync(100) + }) + expect(mockSendMessage).not.toHaveBeenCalled() + expect(currentHookValue.isTokenRefreshInProgress.current).toBe(false) + }, 10000) + + it.skip('should not process the same 401 error instance multiple times', async () => { + mockUseAuthState.mockReturnValue({type: AuthStateType.LOGGED_IN}) + const {rerender} = renderWithProvider({enabled: true}) + act(() => { + comlinkCallbacks.onStatus?.('connected') + }) + + const firstErrorInstance = createError401() + mockUseAuthState.mockReturnValue({type: AuthStateType.ERROR, error: firstErrorInstance}) + act(() => { + rerender( + + + , + ) + }) + await waitFor(() => expect(mockSendMessage).toHaveBeenCalledTimes(1), {timeout: 10000}) + expect(currentHookValue.isTokenRefreshInProgress.current).toBe(true) + + mockUseAuthState.mockReturnValue({type: AuthStateType.ERROR, error: firstErrorInstance}) + act(() => { + rerender( + + + , + ) + }) + await act(async () => { + await vi.advanceTimersByTimeAsync(100) + }) + expect(mockSendMessage).toHaveBeenCalledTimes(1) + + act(() => { + vi.advanceTimersByTime(15000) + }) + await waitFor( + () => expect(currentHookValue.isTokenRefreshInProgress.current).toBe(false), + {timeout: 10000}, + ) + mockSendMessage.mockClear() + + const newErrorInstance = createError401() + mockUseAuthState.mockReturnValue({type: AuthStateType.ERROR, error: newErrorInstance}) + act(() => { + rerender( + + + , + ) + }) + await waitFor(() => expect(mockSendMessage).toHaveBeenCalledTimes(1), {timeout: 10000}) + expect(currentHookValue.isTokenRefreshInProgress.current).toBe(true) + }, 20000) + + it.skip('should reset processed error ref if auth state changes to non-error or different error', async () => { + mockUseAuthState.mockReturnValue({type: AuthStateType.LOGGED_IN}) + const {rerender} = renderWithProvider({enabled: true}) + act(() => { + comlinkCallbacks.onStatus?.('connected') + }) + + const firstError = createError401() + mockUseAuthState.mockReturnValue({type: AuthStateType.ERROR, error: firstError}) + act(() => { + rerender( + + + , + ) + }) + await waitFor(() => expect(mockSendMessage).toHaveBeenCalledTimes(1), {timeout: 10000}) + act(() => { + vi.advanceTimersByTime(15000) + }) + await waitFor( + () => expect(currentHookValue.isTokenRefreshInProgress.current).toBe(false), + {timeout: 10000}, + ) + mockSendMessage.mockClear() + + mockUseAuthState.mockReturnValue({type: AuthStateType.LOGGED_IN}) + act(() => { + rerender( + + + , + ) + }) + await act(async () => { + await vi.advanceTimersByTimeAsync(100) + }) + + mockUseAuthState.mockReturnValue({type: AuthStateType.ERROR, error: createError401()}) + act(() => { + rerender( + + + , + ) + }) + await waitFor(() => expect(mockSendMessage).toHaveBeenCalledTimes(1), {timeout: 10000}) + expect(currentHookValue.isTokenRefreshInProgress.current).toBe(true) + }, 25000) + }) + }) + }) +}) diff --git a/packages/react/src/context/ComlinkTokenRefresh.tsx b/packages/react/src/context/ComlinkTokenRefresh.tsx index d4bad387..9ec8ab16 100644 --- a/packages/react/src/context/ComlinkTokenRefresh.tsx +++ b/packages/react/src/context/ComlinkTokenRefresh.tsx @@ -99,7 +99,6 @@ export const ComlinkTokenRefreshProvider: React.FC< onMessage: { 'dashboard/v1/auth/tokens/create': (data: NewTokenResponseMessage['payload']) => { clearRefreshTimeout() - // Re-check isDashboardComlinkEnabled in case props/context changed if (!isDashboardComlinkEnabled) return if (data.token) { @@ -110,7 +109,6 @@ export const ComlinkTokenRefreshProvider: React.FC< }, } : undefined, - // Add isDashboardComlinkEnabled to dependency array [ isDashboardComlinkEnabled, comlinkName, @@ -161,8 +159,6 @@ export const ComlinkTokenRefreshProvider: React.FC< requestNewToken, isTokenRefreshInProgress, comlinkStatus, - // Expose isDashboardComlinkEnabled instead of isEnabled? - // Let's stick to isEnabled prop for clarity, checks happen internally. isEnabled: enabled, }), [requestNewToken, isTokenRefreshInProgress, comlinkStatus, enabled], @@ -182,25 +178,18 @@ export const ComlinkTokenRefreshProvider: React.FC< authState.error && (authState.error as ClientError)?.statusCode === 401 && !isTokenRefreshInProgress.current && - processed401ErrorRef.current !== authState.error // Check if this specific error instance has been processed + processed401ErrorRef.current !== authState.error ) { - // Mark this error instance as processed before requesting token processed401ErrorRef.current = authState.error requestNewToken() } else if ( authState.type !== AuthStateType.ERROR || - processed401ErrorRef.current !== authState.error + processed401ErrorRef.current !== + (authState.type === AuthStateType.ERROR ? authState.error : undefined) ) { - // Reset if the error is no longer a 401 or a different error occurs processed401ErrorRef.current = null } - }, [ - authState, - isDashboardComlinkEnabled, - requestNewToken, - // Dependency: isTokenRefreshInProgress.current won't trigger effect, use the ref itself - isTokenRefreshInProgress, - ]) + }, [authState, isDashboardComlinkEnabled, requestNewToken]) return ( From a45a767676b61f53d6995a90093ac76eaaaac842 Mon Sep 17 00:00:00 2001 From: Ryan Bonial Date: Wed, 11 Jun 2025 16:43:19 -0600 Subject: [PATCH 08/17] fix: comlink token refresh message path --- .../src/components/auth/AuthBoundary.tsx | 13 ++- .../react/src/context/ComlinkTokenRefresh.tsx | 91 +++++++++++++------ 2 files changed, 73 insertions(+), 31 deletions(-) diff --git a/packages/react/src/components/auth/AuthBoundary.tsx b/packages/react/src/components/auth/AuthBoundary.tsx index 43906f9d..347a07c3 100644 --- a/packages/react/src/components/auth/AuthBoundary.tsx +++ b/packages/react/src/components/auth/AuthBoundary.tsx @@ -2,7 +2,10 @@ import {AuthStateType} from '@sanity/sdk' import {useEffect, useMemo} from 'react' import {ErrorBoundary, type FallbackProps} from 'react-error-boundary' -import {useComlinkTokenRefresh} from '../../context/ComlinkTokenRefresh' +import { + ComlinkTokenRefreshProvider, + useComlinkTokenRefresh, +} from '../../context/ComlinkTokenRefresh' import {useAuthState} from '../../hooks/auth/useAuthState' import {useLoginUrl} from '../../hooks/auth/useLoginUrl' import {useVerifyOrgProjects} from '../../hooks/auth/useVerifyOrgProjects' @@ -112,9 +115,11 @@ export function AuthBoundary({ }, [LoginErrorComponent]) return ( - - - + + + + + ) } diff --git a/packages/react/src/context/ComlinkTokenRefresh.tsx b/packages/react/src/context/ComlinkTokenRefresh.tsx index 9ec8ab16..ad460f94 100644 --- a/packages/react/src/context/ComlinkTokenRefresh.tsx +++ b/packages/react/src/context/ComlinkTokenRefresh.tsx @@ -53,9 +53,9 @@ interface ComlinkTokenRefreshContextValue { const ComlinkTokenRefreshContext = createContext(null) -const DEFAULT_COMLINK_NAME = 'sanity-sdk-iframe' -const DEFAULT_PARENT_NAME = 'sanity-dashboard-parent' -const DEFAULT_RESPONSE_TIMEOUT = 15000 // 15 seconds +export const DEFAULT_COMLINK_NAME = 'dashboard/nodes/sdk' +export const DEFAULT_PARENT_NAME = 'dashboard/channels/sdk' +const DEFAULT_RESPONSE_TIMEOUT = 10000 // 10 seconds /** * This provider is used to provide the Comlink token refresh feature. @@ -66,11 +66,12 @@ export const ComlinkTokenRefreshProvider: React.FC< PropsWithChildren > = ({ children, - enabled = false, // Default to disabled + enabled = true, // Default to enabled comlinkName = DEFAULT_COMLINK_NAME, parentName = DEFAULT_PARENT_NAME, responseTimeout = DEFAULT_RESPONSE_TIMEOUT, }) => { + // console.log('ComlinkTokenRefreshProvider', {enabled, comlinkName, parentName, responseTimeout}) const instance = useSanityInstance() const [comlinkStatus, setComlinkStatus] = useState('idle') const isTokenRefreshInProgress = useRef(false) @@ -80,7 +81,9 @@ export const ComlinkTokenRefreshProvider: React.FC< const authState = useAuthState() const isInDashboard = useMemo(() => getIsInDashboardState(instance).getCurrent(), [instance]) - const isDashboardComlinkEnabled = enabled && isInDashboard + // const isDashboardComlinkEnabled = enabled && isInDashboard + const isDashboardComlinkEnabled = enabled || isInDashboard + // console.log('isDashboardComlinkEnabled:', isDashboardComlinkEnabled) const clearRefreshTimeout = useCallback(() => { if (timeoutRef.current) { @@ -90,25 +93,25 @@ export const ComlinkTokenRefreshProvider: React.FC< }, []) const connectionOptions = useMemo( - () => - isDashboardComlinkEnabled + () => ({ + name: comlinkName, + connectTo: parentName, + onStatus: setComlinkStatus, + onMessage: isDashboardComlinkEnabled ? { - name: comlinkName, - connectTo: parentName, - onStatus: setComlinkStatus, - onMessage: { - 'dashboard/v1/auth/tokens/create': (data: NewTokenResponseMessage['payload']) => { - clearRefreshTimeout() - if (!isDashboardComlinkEnabled) return - - if (data.token) { - setAuthToken(instance, data.token) - } - isTokenRefreshInProgress.current = false - }, + 'dashboard/v1/auth/tokens/create': (data: NewTokenResponseMessage['payload']) => { + clearRefreshTimeout() + if (!isDashboardComlinkEnabled) return + + if (data.token) { + // console.log('Received new token via comlink') + setAuthToken(instance, data.token) + } + isTokenRefreshInProgress.current = false }, } - : undefined, + : {}, + }), [ isDashboardComlinkEnabled, comlinkName, @@ -119,22 +122,45 @@ export const ComlinkTokenRefreshProvider: React.FC< ], ) - const {sendMessage} = useWindowConnection( + const windowConnection = useWindowConnection( // eslint-disable-next-line @typescript-eslint/no-explicit-any connectionOptions as any, ) + const sendMessage = useMemo(() => { + if (isDashboardComlinkEnabled && windowConnection?.sendMessage) { + return (messageType: string) => { + // console.log('Sending comlink message:', messageType) + // eslint-disable-next-line @typescript-eslint/no-explicit-any + windowConnection.sendMessage(messageType as any) + } + } + return () => { + // console.log('sendMessage called but comlink is not available') + } + }, [isDashboardComlinkEnabled, windowConnection]) + const requestNewToken = useCallback(() => { + // console.log('[++++] requestNewToken', { + // isDashboardComlinkEnabled, + // comlinkStatus, + // isTokenRefreshInProgress, + // }) if (!isDashboardComlinkEnabled) { return } - if (comlinkStatus !== 'connected') { + // console.log('[++++] requestNewToken: comlinkStatus', comlinkStatus) + if (comlinkStatus !== 'idle') { return } + // console.log( + // '[++++] requestNewToken: isTokenRefreshInProgress', + // isTokenRefreshInProgress.current, + // ) if (isTokenRefreshInProgress.current) { return } - + // console.log('[++++] requestNewToken: setting isTokenRefreshInProgress to true') isTokenRefreshInProgress.current = true clearRefreshTimeout() @@ -172,15 +198,26 @@ export const ComlinkTokenRefreshProvider: React.FC< // Effect to automatically request a new token on 401 error if enabled useEffect(() => { - if ( + // console.log('[++++] authState', authState) + const has401Error = isDashboardComlinkEnabled && authState.type === AuthStateType.ERROR && authState.error && (authState.error as ClientError)?.statusCode === 401 && !isTokenRefreshInProgress.current && processed401ErrorRef.current !== authState.error - ) { - processed401ErrorRef.current = authState.error + + const isLoggedOut = + isDashboardComlinkEnabled && + authState.type === AuthStateType.LOGGED_OUT && + !isTokenRefreshInProgress.current + + // console.log('[++++] has401Error', has401Error) + // console.log('[++++] isLoggedOut', isLoggedOut) + + if (has401Error || isLoggedOut) { + processed401ErrorRef.current = + authState.type === AuthStateType.ERROR ? authState.error : undefined requestNewToken() } else if ( authState.type !== AuthStateType.ERROR || From 9eac1e8b5a6f5e402de998e9cd34f186267a24ed Mon Sep 17 00:00:00 2001 From: Ryan Bonial Date: Thu, 12 Jun 2025 15:06:17 -0600 Subject: [PATCH 09/17] fix: use fetch instead of sendMessage for comlink --- .../react/src/components/auth/LoginError.tsx | 21 +++- .../react/src/context/ComlinkTokenRefresh.tsx | 102 +++++------------- 2 files changed, 41 insertions(+), 82 deletions(-) diff --git a/packages/react/src/components/auth/LoginError.tsx b/packages/react/src/components/auth/LoginError.tsx index 255d5160..26234d9a 100644 --- a/packages/react/src/components/auth/LoginError.tsx +++ b/packages/react/src/components/auth/LoginError.tsx @@ -19,7 +19,15 @@ export type LoginErrorProps = FallbackProps * @alpha */ export function LoginError({error, resetErrorBoundary}: LoginErrorProps): React.ReactNode { - if (!(error instanceof AuthError || error instanceof ConfigurationError)) throw error + if ( + !( + error instanceof AuthError || + error instanceof ConfigurationError || + error instanceof ClientError + ) + ) + throw error + const logout = useLogOut() const authState = useAuthState() @@ -33,11 +41,14 @@ export function LoginError({error, resetErrorBoundary}: LoginErrorProps): React. }, [logout, resetErrorBoundary]) useEffect(() => { - if (authState.type === AuthStateType.ERROR && authState.error instanceof ClientError) { - if (authState.error.statusCode === 401) { + if ( + // (authState.type === AuthStateType.ERROR || authState.type === AuthStateType.LOGGED_IN) && + error instanceof ClientError + ) { + if (error.statusCode === 401) { handleRetry() - } else if (authState.error.statusCode === 404) { - const errorMessage = authState.error.response.body.message || '' + } else if (error.statusCode === 404) { + const errorMessage = error.response.body.message || '' if (errorMessage.startsWith('Session with sid') && errorMessage.endsWith('not found')) { setAuthErrorMessage('The session ID is invalid or expired.') } else { diff --git a/packages/react/src/context/ComlinkTokenRefresh.tsx b/packages/react/src/context/ComlinkTokenRefresh.tsx index ad460f94..544a9fd9 100644 --- a/packages/react/src/context/ComlinkTokenRefresh.tsx +++ b/packages/react/src/context/ComlinkTokenRefresh.tsx @@ -1,5 +1,5 @@ import {type ClientError} from '@sanity/client' -import {type Status as ComlinkStatus} from '@sanity/comlink' +import {SDK_CHANNEL_NAME, SDK_NODE_NAME} from '@sanity/message-protocol' import { AuthStateType, type FrameMessage, @@ -17,7 +17,6 @@ import React, { useEffect, useMemo, useRef, - useState, } from 'react' import {useAuthState} from '../hooks/auth/useAuthState' @@ -36,25 +35,16 @@ type SdkChildComlinkMessage = RequestNewTokenMessage | FrameMessage // Messages export type ComlinkTokenRefreshConfig = { /** Enable the Comlink token refresh feature. Defaults to false */ enabled?: boolean - /** Unique name for this SDK iframe instance's Comlink endpoint. Defaults to 'sanity-sdk-iframe' */ - comlinkName?: string - /** The name of the parent window's Comlink endpoint to connect to. Defaults to 'sanity-dashboard-parent' */ - parentName?: string - /** Timeout in ms for waiting for a token response from the parent. Defaults to 15000ms */ - responseTimeout?: number } interface ComlinkTokenRefreshContextValue { requestNewToken: () => void isTokenRefreshInProgress: React.MutableRefObject - comlinkStatus: ComlinkStatus isEnabled: boolean } const ComlinkTokenRefreshContext = createContext(null) -export const DEFAULT_COMLINK_NAME = 'dashboard/nodes/sdk' -export const DEFAULT_PARENT_NAME = 'dashboard/channels/sdk' const DEFAULT_RESPONSE_TIMEOUT = 10000 // 10 seconds /** @@ -67,22 +57,19 @@ export const ComlinkTokenRefreshProvider: React.FC< > = ({ children, enabled = true, // Default to enabled - comlinkName = DEFAULT_COMLINK_NAME, - parentName = DEFAULT_PARENT_NAME, - responseTimeout = DEFAULT_RESPONSE_TIMEOUT, }) => { // console.log('ComlinkTokenRefreshProvider', {enabled, comlinkName, parentName, responseTimeout}) const instance = useSanityInstance() - const [comlinkStatus, setComlinkStatus] = useState('idle') const isTokenRefreshInProgress = useRef(false) const timeoutRef = useRef(null) const processed401ErrorRef = useRef(null) // Ref to track processed 401 error const authState = useAuthState() + // console.log('[++++] authState type', authState.type) const isInDashboard = useMemo(() => getIsInDashboardState(instance).getCurrent(), [instance]) - // const isDashboardComlinkEnabled = enabled && isInDashboard - const isDashboardComlinkEnabled = enabled || isInDashboard + const isDashboardComlinkEnabled = enabled && isInDashboard + // const isDashboardComlinkEnabled = enabled // console.log('isDashboardComlinkEnabled:', isDashboardComlinkEnabled) const clearRefreshTimeout = useCallback(() => { @@ -92,55 +79,12 @@ export const ComlinkTokenRefreshProvider: React.FC< } }, []) - const connectionOptions = useMemo( - () => ({ - name: comlinkName, - connectTo: parentName, - onStatus: setComlinkStatus, - onMessage: isDashboardComlinkEnabled - ? { - 'dashboard/v1/auth/tokens/create': (data: NewTokenResponseMessage['payload']) => { - clearRefreshTimeout() - if (!isDashboardComlinkEnabled) return + const windowConnection = useWindowConnection({ + name: SDK_NODE_NAME, + connectTo: SDK_CHANNEL_NAME, + }) - if (data.token) { - // console.log('Received new token via comlink') - setAuthToken(instance, data.token) - } - isTokenRefreshInProgress.current = false - }, - } - : {}, - }), - [ - isDashboardComlinkEnabled, - comlinkName, - parentName, - setComlinkStatus, - clearRefreshTimeout, - instance, - ], - ) - - const windowConnection = useWindowConnection( - // eslint-disable-next-line @typescript-eslint/no-explicit-any - connectionOptions as any, - ) - - const sendMessage = useMemo(() => { - if (isDashboardComlinkEnabled && windowConnection?.sendMessage) { - return (messageType: string) => { - // console.log('Sending comlink message:', messageType) - // eslint-disable-next-line @typescript-eslint/no-explicit-any - windowConnection.sendMessage(messageType as any) - } - } - return () => { - // console.log('sendMessage called but comlink is not available') - } - }, [isDashboardComlinkEnabled, windowConnection]) - - const requestNewToken = useCallback(() => { + const requestNewToken = useCallback(async () => { // console.log('[++++] requestNewToken', { // isDashboardComlinkEnabled, // comlinkStatus, @@ -149,10 +93,6 @@ export const ComlinkTokenRefreshProvider: React.FC< if (!isDashboardComlinkEnabled) { return } - // console.log('[++++] requestNewToken: comlinkStatus', comlinkStatus) - if (comlinkStatus !== 'idle') { - return - } // console.log( // '[++++] requestNewToken: isTokenRefreshInProgress', // isTokenRefreshInProgress.current, @@ -169,25 +109,34 @@ export const ComlinkTokenRefreshProvider: React.FC< isTokenRefreshInProgress.current = false } timeoutRef.current = null - }, responseTimeout) + }, DEFAULT_RESPONSE_TIMEOUT) try { - const messageType = 'dashboard/v1/auth/tokens/create' as const - sendMessage(messageType) + // const messageType = 'dashboard/v1/auth/tokens/create' as const + const res = await windowConnection.fetch<{token: string | null; error?: string}>( + 'dashboard/v1/auth/tokens/create', + ) + // console.log('[&&&&++++] requestNewToken: res', res) + clearRefreshTimeout() + + if (res.token) { + // console.log('Received new token via comlink', res.token) + setAuthToken(instance, res.token) + } + isTokenRefreshInProgress.current = false } catch { isTokenRefreshInProgress.current = false clearRefreshTimeout() } - }, [isDashboardComlinkEnabled, sendMessage, comlinkStatus, responseTimeout, clearRefreshTimeout]) + }, [isDashboardComlinkEnabled, windowConnection, clearRefreshTimeout, instance]) const contextValue = useMemo( () => ({ requestNewToken, isTokenRefreshInProgress, - comlinkStatus, isEnabled: enabled, }), - [requestNewToken, isTokenRefreshInProgress, comlinkStatus, enabled], + [requestNewToken, isTokenRefreshInProgress, enabled], ) useEffect(() => { @@ -198,7 +147,7 @@ export const ComlinkTokenRefreshProvider: React.FC< // Effect to automatically request a new token on 401 error if enabled useEffect(() => { - // console.log('[++++] authState', authState) + // console.log('[-----++++] authState', authState) const has401Error = isDashboardComlinkEnabled && authState.type === AuthStateType.ERROR && @@ -251,7 +200,6 @@ export const useComlinkTokenRefresh = (): ComlinkTokenRefreshContextValue => { ) }, isTokenRefreshInProgress: {current: false}, - comlinkStatus: 'idle', isEnabled: false, } } From 8776c9529b32143e64fb9f8a8086f772ad172953 Mon Sep 17 00:00:00 2001 From: Ryan Bonial Date: Mon, 16 Jun 2025 13:08:15 -0600 Subject: [PATCH 10/17] fix: allow standalone token refresh --- .../react/src/context/ComlinkTokenRefresh.tsx | 107 ++++++++---------- 1 file changed, 45 insertions(+), 62 deletions(-) diff --git a/packages/react/src/context/ComlinkTokenRefresh.tsx b/packages/react/src/context/ComlinkTokenRefresh.tsx index 544a9fd9..4b6fe19e 100644 --- a/packages/react/src/context/ComlinkTokenRefresh.tsx +++ b/packages/react/src/context/ComlinkTokenRefresh.tsx @@ -27,20 +27,9 @@ import {useSanityInstance} from '../hooks/context/useSanityInstance' type SdkParentComlinkMessage = NewTokenResponseMessage | WindowMessage // Messages received by SDK type SdkChildComlinkMessage = RequestNewTokenMessage | FrameMessage // Messages sent by SDK -/** - * This config is used to configure the Comlink token refresh feature. - * It is used to automatically request a new token on 401 error if enabled. - * @public - */ -export type ComlinkTokenRefreshConfig = { - /** Enable the Comlink token refresh feature. Defaults to false */ - enabled?: boolean -} - interface ComlinkTokenRefreshContextValue { requestNewToken: () => void isTokenRefreshInProgress: React.MutableRefObject - isEnabled: boolean } const ComlinkTokenRefreshContext = createContext(null) @@ -48,29 +37,14 @@ const ComlinkTokenRefreshContext = createContext -> = ({ - children, - enabled = true, // Default to enabled -}) => { - // console.log('ComlinkTokenRefreshProvider', {enabled, comlinkName, parentName, responseTimeout}) +function DashboardTokenRefresh({children}: PropsWithChildren) { const instance = useSanityInstance() const isTokenRefreshInProgress = useRef(false) const timeoutRef = useRef(null) - const processed401ErrorRef = useRef(null) // Ref to track processed 401 error - + const processed401ErrorRef = useRef(null) const authState = useAuthState() - // console.log('[++++] authState type', authState.type) - - const isInDashboard = useMemo(() => getIsInDashboardState(instance).getCurrent(), [instance]) - const isDashboardComlinkEnabled = enabled && isInDashboard - // const isDashboardComlinkEnabled = enabled - // console.log('isDashboardComlinkEnabled:', isDashboardComlinkEnabled) const clearRefreshTimeout = useCallback(() => { if (timeoutRef.current) { @@ -85,22 +59,10 @@ export const ComlinkTokenRefreshProvider: React.FC< }) const requestNewToken = useCallback(async () => { - // console.log('[++++] requestNewToken', { - // isDashboardComlinkEnabled, - // comlinkStatus, - // isTokenRefreshInProgress, - // }) - if (!isDashboardComlinkEnabled) { - return - } - // console.log( - // '[++++] requestNewToken: isTokenRefreshInProgress', - // isTokenRefreshInProgress.current, - // ) if (isTokenRefreshInProgress.current) { return } - // console.log('[++++] requestNewToken: setting isTokenRefreshInProgress to true') + isTokenRefreshInProgress.current = true clearRefreshTimeout() @@ -112,15 +74,12 @@ export const ComlinkTokenRefreshProvider: React.FC< }, DEFAULT_RESPONSE_TIMEOUT) try { - // const messageType = 'dashboard/v1/auth/tokens/create' as const const res = await windowConnection.fetch<{token: string | null; error?: string}>( 'dashboard/v1/auth/tokens/create', ) - // console.log('[&&&&++++] requestNewToken: res', res) clearRefreshTimeout() if (res.token) { - // console.log('Received new token via comlink', res.token) setAuthToken(instance, res.token) } isTokenRefreshInProgress.current = false @@ -128,15 +87,14 @@ export const ComlinkTokenRefreshProvider: React.FC< isTokenRefreshInProgress.current = false clearRefreshTimeout() } - }, [isDashboardComlinkEnabled, windowConnection, clearRefreshTimeout, instance]) + }, [windowConnection, clearRefreshTimeout, instance]) const contextValue = useMemo( () => ({ requestNewToken, isTokenRefreshInProgress, - isEnabled: enabled, }), - [requestNewToken, isTokenRefreshInProgress, enabled], + [requestNewToken], ) useEffect(() => { @@ -145,11 +103,8 @@ export const ComlinkTokenRefreshProvider: React.FC< } }, [clearRefreshTimeout]) - // Effect to automatically request a new token on 401 error if enabled useEffect(() => { - // console.log('[-----++++] authState', authState) const has401Error = - isDashboardComlinkEnabled && authState.type === AuthStateType.ERROR && authState.error && (authState.error as ClientError)?.statusCode === 401 && @@ -157,12 +112,7 @@ export const ComlinkTokenRefreshProvider: React.FC< processed401ErrorRef.current !== authState.error const isLoggedOut = - isDashboardComlinkEnabled && - authState.type === AuthStateType.LOGGED_OUT && - !isTokenRefreshInProgress.current - - // console.log('[++++] has401Error', has401Error) - // console.log('[++++] isLoggedOut', isLoggedOut) + authState.type === AuthStateType.LOGGED_OUT && !isTokenRefreshInProgress.current if (has401Error || isLoggedOut) { processed401ErrorRef.current = @@ -175,7 +125,7 @@ export const ComlinkTokenRefreshProvider: React.FC< ) { processed401ErrorRef.current = null } - }, [authState, isDashboardComlinkEnabled, requestNewToken]) + }, [authState, requestNewToken]) return ( @@ -184,6 +134,42 @@ export const ComlinkTokenRefreshProvider: React.FC< ) } +/** + * Component that provides a no-op token refresh outside of dashboard + */ +function NoOpTokenRefresh({children}: PropsWithChildren) { + const contextValue = useMemo( + () => ({ + requestNewToken: () => {}, + isTokenRefreshInProgress: {current: false}, + }), + [], + ) + + return ( + + {children} + + ) +} + +/** + * This provider is used to provide the Comlink token refresh feature. + * It is used to automatically request a new token on 401 error if enabled. + * @public + */ +export const ComlinkTokenRefreshProvider: React.FC = ({children}) => { + const instance = useSanityInstance() + const isInDashboard = useMemo(() => getIsInDashboardState(instance).getCurrent(), [instance]) + + if (isInDashboard) { + return {children} + } + + // If we're not in the dashboard, we don't need to do anything + return {children} +} + /** * This hook is used to request a new token from the parent window. * It is used to automatically request a new token on 401 error if enabled. @@ -195,12 +181,9 @@ export const useComlinkTokenRefresh = (): ComlinkTokenRefreshContextValue => { return { requestNewToken: () => { // eslint-disable-next-line no-console - console.warn( - 'useComlinkTokenRefresh must be used within a ComlinkTokenRefreshProvider with the feature enabled.', - ) + console.warn('useComlinkTokenRefresh must be used within a ComlinkTokenRefreshProvider.') }, isTokenRefreshInProgress: {current: false}, - isEnabled: false, } } return context From 4f566a173c92503fa951490a85c30559f2a2085c Mon Sep 17 00:00:00 2001 From: Ryan Bonial Date: Mon, 16 Jun 2025 13:26:50 -0600 Subject: [PATCH 11/17] chore: update tests --- .../src/components/auth/AuthBoundary.test.tsx | 49 ++- .../src/context/ComlinkTokenRefresh.test.tsx | 391 +++++------------- 2 files changed, 122 insertions(+), 318 deletions(-) diff --git a/packages/react/src/components/auth/AuthBoundary.test.tsx b/packages/react/src/components/auth/AuthBoundary.test.tsx index 86bb883d..d4e88df9 100644 --- a/packages/react/src/components/auth/AuthBoundary.test.tsx +++ b/packages/react/src/components/auth/AuthBoundary.test.tsx @@ -1,4 +1,4 @@ -import {AuthStateType} from '@sanity/sdk' +import {AuthStateType, type SanityConfig} from '@sanity/sdk' import {render, screen, waitFor} from '@testing-library/react' import React from 'react' import {type FallbackProps} from 'react-error-boundary' @@ -8,6 +8,7 @@ import {ResourceProvider} from '../../context/ResourceProvider' import {useAuthState} from '../../hooks/auth/useAuthState' import {useLoginUrl} from '../../hooks/auth/useLoginUrl' import {useVerifyOrgProjects} from '../../hooks/auth/useVerifyOrgProjects' +import {useSanityInstance} from '../../hooks/context/useSanityInstance' import {AuthBoundary} from './AuthBoundary' // Mock hooks @@ -22,6 +23,9 @@ vi.mock('../../hooks/auth/useHandleAuthCallback', () => ({ vi.mock('../../hooks/auth/useLogOut', () => ({ useLogOut: vi.fn(() => async () => {}), })) +vi.mock('../../hooks/context/useSanityInstance', () => ({ + useSanityInstance: vi.fn(), +})) // Mock AuthError throwing scenario vi.mock('./AuthError', async (importOriginal) => { @@ -105,8 +109,27 @@ describe('AuthBoundary', () => { const mockUseAuthState = vi.mocked(useAuthState) const mockUseLoginUrl = vi.mocked(useLoginUrl) const mockUseVerifyOrgProjects = vi.mocked(useVerifyOrgProjects) + const mockUseSanityInstance = vi.mocked(useSanityInstance) const testProjectIds = ['proj-test'] // Example project ID for tests + // Mock Sanity instance + const mockSanityInstance = { + instanceId: 'test-instance-id', + config: { + projectId: 'test-project', + dataset: 'test-dataset', + }, + isDisposed: () => false, + dispose: () => {}, + onDispose: () => () => {}, + getParent: () => undefined, + createChild: (config: SanityConfig) => ({ + ...mockSanityInstance, + config: {...mockSanityInstance.config, ...config}, + }), + match: () => undefined, + } + beforeEach(() => { vi.clearAllMocks() consoleErrorSpy = vi.spyOn(console, 'error').mockImplementation(() => {}) @@ -116,6 +139,8 @@ describe('AuthBoundary', () => { mockUseLoginUrl.mockReturnValue('http://example.com/login') // Default mock for useVerifyOrgProjects - returns null (no error) mockUseVerifyOrgProjects.mockImplementation(() => null) + // Mock useSanityInstance to return our mock instance + mockUseSanityInstance.mockReturnValue(mockSanityInstance) }) afterEach(() => { @@ -145,9 +170,7 @@ describe('AuthBoundary', () => { isExchangingToken: false, }) const {container} = render( - - Protected Content - , + Protected Content, ) // The callback screen renders null check that it renders nothing @@ -161,11 +184,7 @@ describe('AuthBoundary', () => { currentUser: null, token: 'exampleToken', }) - render( - - Protected Content - , - ) + render(Protected Content) expect(screen.getByText('Protected Content')).toBeInTheDocument() }) @@ -175,11 +194,7 @@ describe('AuthBoundary', () => { type: AuthStateType.ERROR, error: new Error('test error'), }) - render( - - Protected Content - , - ) + render(Protected Content) // The AuthBoundary should throw an AuthError internally // and then display the LoginError component as the fallback. @@ -192,11 +207,7 @@ describe('AuthBoundary', () => { }) it('renders children when logged in and org verification passes', () => { - render( - - Protected Content - , - ) + render(Protected Content) expect(screen.getByText('Protected Content')).toBeInTheDocument() }) diff --git a/packages/react/src/context/ComlinkTokenRefresh.test.tsx b/packages/react/src/context/ComlinkTokenRefresh.test.tsx index 41172986..b003ab40 100644 --- a/packages/react/src/context/ComlinkTokenRefresh.test.tsx +++ b/packages/react/src/context/ComlinkTokenRefresh.test.tsx @@ -1,16 +1,15 @@ +import {SDK_CHANNEL_NAME, SDK_NODE_NAME} from '@sanity/message-protocol' import {AuthStateType, getIsInDashboardState, setAuthToken} from '@sanity/sdk' -import {act, render, waitFor} from '@testing-library/react' +import {act, render} from '@testing-library/react' import React from 'react' import {afterEach, beforeEach, describe, expect, it, type Mock, vi} from 'vitest' import {useAuthState} from '../hooks/auth/useAuthState' import {useWindowConnection} from '../hooks/comlink/useWindowConnection' import {useSanityInstance} from '../hooks/context/useSanityInstance' -import { - type ComlinkTokenRefreshConfig, - ComlinkTokenRefreshProvider, - useComlinkTokenRefresh, -} from './ComlinkTokenRefresh' +import {ComlinkTokenRefreshProvider, useComlinkTokenRefresh} from './ComlinkTokenRefresh' + +const DEFAULT_RESPONSE_TIMEOUT = 10000 // 10 seconds // Mocks vi.mock('@sanity/sdk', async () => { @@ -22,9 +21,17 @@ vi.mock('@sanity/sdk', async () => { } }) -vi.mock('../hooks/auth/useAuthState') -vi.mock('../hooks/comlink/useWindowConnection') -vi.mock('../hooks/context/useSanityInstance') +vi.mock('../hooks/auth/useAuthState', () => ({ + useAuthState: vi.fn(), +})) + +vi.mock('../hooks/comlink/useWindowConnection', () => ({ + useWindowConnection: vi.fn(), +})) + +vi.mock('../hooks/context/useSanityInstance', () => ({ + useSanityInstance: vi.fn(), +})) // Use simpler mock typings const mockGetIsInDashboardState = getIsInDashboardState as Mock @@ -33,7 +40,7 @@ const mockUseAuthState = useAuthState as Mock const mockUseWindowConnection = useWindowConnection as Mock const mockUseSanityInstance = useSanityInstance as Mock -const mockSendMessage = vi.fn() +const mockFetch = vi.fn() // eslint-disable-next-line @typescript-eslint/no-explicit-any const mockSanityInstance: any = {projectId: 'test', dataset: 'test'} @@ -45,15 +52,13 @@ describe('ComlinkTokenRefresh', () => { vi.useFakeTimers() mockGetIsInDashboardState.mockReturnValue({getCurrent: vi.fn(() => false)}) mockUseAuthState.mockReturnValue({type: AuthStateType.LOGGED_IN}) - mockUseWindowConnection.mockReturnValue({sendMessage: mockSendMessage, connection: undefined}) + mockUseWindowConnection.mockReturnValue({fetch: mockFetch}) mockUseSanityInstance.mockReturnValue(mockSanityInstance) vi.spyOn(console, 'warn').mockImplementation(() => {}) // Mock console.warn // Initialize currentHookValue with default structure currentHookValue = { requestNewToken: () => {}, isTokenRefreshInProgress: {current: false}, - comlinkStatus: 'idle', - isEnabled: false, } }) @@ -74,8 +79,6 @@ describe('ComlinkTokenRefresh', () => { return (
- {String(hookValue.isEnabled)} - {hookValue.comlinkStatus} {String(hookValue.isTokenRefreshInProgress.current)} @@ -85,9 +88,8 @@ describe('ComlinkTokenRefresh', () => { } const renderWithProvider = ( - props?: ComlinkTokenRefreshConfig, testComponentProps?: TestComponentProps, - children?: React.ReactNode, // Allow custom children as before + children?: React.ReactNode, ) => { const onHookUpdateCallback = testComponentProps?.onHookUpdate || @@ -95,7 +97,7 @@ describe('ComlinkTokenRefresh', () => { currentHookValue = value }) return render( - + {children || } , ) @@ -103,166 +105,96 @@ describe('ComlinkTokenRefresh', () => { describe('useComlinkTokenRefresh without Provider', () => { it('should return default values and warn on requestNewToken', () => { - // Render TestComponent directly without ComlinkTokenRefreshProvider - const {getByText, getByTestId} = render( + const {getByText} = render( (currentHookValue = value)} />, ) - expect(currentHookValue.isEnabled).toBe(false) - expect(currentHookValue.comlinkStatus).toBe('idle') expect(currentHookValue.isTokenRefreshInProgress.current).toBe(false) - expect(getByTestId('is-enabled').textContent).toBe('false') - expect(getByTestId('comlink-status').textContent).toBe('idle') - expect(getByTestId('is-in-progress').textContent).toBe('false') - act(() => { getByText('Request Token').click() }) + // Verify warning was shown // eslint-disable-next-line no-console expect(console.warn).toHaveBeenCalledWith( - 'useComlinkTokenRefresh must be used within a ComlinkTokenRefreshProvider with the feature enabled.', + 'useComlinkTokenRefresh must be used within a ComlinkTokenRefreshProvider.', ) - expect(mockSendMessage).not.toHaveBeenCalled() + expect(mockFetch).not.toHaveBeenCalled() }) }) describe('ComlinkTokenRefreshProvider', () => { - it('should provide default context values when disabled', () => { - renderWithProvider({enabled: false}) - expect(currentHookValue.isEnabled).toBe(false) - expect(currentHookValue.comlinkStatus).toBe('idle') - expect(currentHookValue.isTokenRefreshInProgress.current).toBe(false) - }) - - it('requestNewToken should do nothing and not warn if disabled', () => { - const {getByText} = renderWithProvider({enabled: false}) - act(() => { - getByText('Request Token').click() - }) - expect(mockSendMessage).not.toHaveBeenCalled() - // eslint-disable-next-line no-console - expect(console.warn).not.toHaveBeenCalled() - expect(currentHookValue.isTokenRefreshInProgress.current).toBe(false) - }) - - it('should provide enabled as true from context when enabled prop is true', () => { - renderWithProvider({enabled: true}) - expect(currentHookValue.isEnabled).toBe(true) - }) - - describe('when enabled and not in dashboard', () => { + describe('when not in dashboard', () => { beforeEach(() => { mockGetIsInDashboardState.mockReturnValue({getCurrent: () => false}) }) - it('should have comlinkStatus idle and requestNewToken should do nothing', () => { - const {getByText} = renderWithProvider({enabled: true}) - expect(currentHookValue.isEnabled).toBe(true) - expect(currentHookValue.comlinkStatus).toBe('idle') + it('should have requestNewToken do nothing', () => { + const {getByText} = renderWithProvider() act(() => { getByText('Request Token').click() }) - expect(mockSendMessage).not.toHaveBeenCalled() + expect(mockFetch).not.toHaveBeenCalled() expect(currentHookValue.isTokenRefreshInProgress.current).toBe(false) }) }) - describe('when enabled and in dashboard', () => { - // eslint-disable-next-line @typescript-eslint/no-explicit-any - const comlinkCallbacks: any = {} - + describe('when in dashboard', () => { beforeEach(() => { mockGetIsInDashboardState.mockReturnValue({getCurrent: () => true}) - // Capture the onMessage and onStatus callbacks - // eslint-disable-next-line @typescript-eslint/no-explicit-any - mockUseWindowConnection.mockImplementation((options: any) => { - // Fix: Safely access options properties - if (options && options.onMessage) comlinkCallbacks.onMessage = options.onMessage - if (options && options.onStatus) comlinkCallbacks.onStatus = options.onStatus - return {sendMessage: mockSendMessage, connection: undefined} - }) }) - it('should initialize useWindowConnection with correct parameters and allow comlink status update', () => { - renderWithProvider({ - enabled: true, - comlinkName: 'test-sdk', - parentName: 'test-parent', - }) + it('should initialize useWindowConnection with correct parameters', () => { + renderWithProvider() expect(mockUseWindowConnection).toHaveBeenCalledWith( expect.objectContaining({ - name: 'test-sdk', - connectTo: 'test-parent', + name: SDK_NODE_NAME, + connectTo: SDK_CHANNEL_NAME, }), ) - - act(() => { - comlinkCallbacks.onStatus?.('connected') - }) - expect(currentHookValue.comlinkStatus).toBe('connected') - }) - - it('requestNewToken should do nothing if comlinkStatus is not "connected"', () => { - renderWithProvider({enabled: true}) - act(() => { - comlinkCallbacks.onStatus?.('connecting') - }) - expect(currentHookValue.comlinkStatus).toBe('connecting') - - act(() => { - currentHookValue.requestNewToken() // Call directly for this check - }) - expect(mockSendMessage).not.toHaveBeenCalled() - expect(currentHookValue.isTokenRefreshInProgress.current).toBe(false) }) - it('requestNewToken should do nothing if token refresh is already in progress', () => { - const {getByText} = renderWithProvider({enabled: true}) - act(() => { - comlinkCallbacks.onStatus?.('connected') - }) - expect(currentHookValue.comlinkStatus).toBe('connected') + it('requestNewToken should do nothing if token refresh is already in progress', async () => { + // Use a promise that never resolves to keep the refresh in progress + mockFetch.mockImplementationOnce(() => new Promise(() => {})) + const {getByText} = renderWithProvider() // Start a request - act(() => { + await act(async () => { getByText('Request Token').click() }) - expect(mockSendMessage).toHaveBeenCalledTimes(1) + expect(mockFetch).toHaveBeenCalledTimes(1) expect(currentHookValue.isTokenRefreshInProgress.current).toBe(true) // Try to start another one - act(() => { + await act(async () => { getByText('Request Token').click() }) - expect(mockSendMessage).toHaveBeenCalledTimes(1) // Still 1 + expect(mockFetch).toHaveBeenCalledTimes(1) // Still 1 expect(currentHookValue.isTokenRefreshInProgress.current).toBe(true) act(() => { - vi.advanceTimersByTime(15000) // Default timeout + vi.advanceTimersByTime(DEFAULT_RESPONSE_TIMEOUT + 1000) }) expect(currentHookValue.isTokenRefreshInProgress.current).toBe(false) }) - it('requestNewToken should send message and set inProgress, then timeout', async () => { - const responseTimeout = 5000 - const {getByText} = renderWithProvider({enabled: true, responseTimeout}) - act(() => { - comlinkCallbacks.onStatus?.('connected') - }) + it('requestNewToken should fetch token and set inProgress, then timeout if no response', async () => { + mockFetch.mockImplementationOnce(() => new Promise(() => {})) // Never resolves + const {getByText} = renderWithProvider() - act(() => { + await act(async () => { getByText('Request Token').click() }) - expect(mockSendMessage).toHaveBeenCalledWith('dashboard/v1/auth/tokens/create') + expect(mockFetch).toHaveBeenCalledWith('dashboard/v1/auth/tokens/create') expect(currentHookValue.isTokenRefreshInProgress.current).toBe(true) act(() => { - vi.advanceTimersByTime(responseTimeout - 1) + vi.advanceTimersByTime(DEFAULT_RESPONSE_TIMEOUT - 1) }) expect(currentHookValue.isTokenRefreshInProgress.current).toBe(true) @@ -272,118 +204,67 @@ describe('ComlinkTokenRefresh', () => { expect(currentHookValue.isTokenRefreshInProgress.current).toBe(false) }) - it('should handle received token and reset inProgress', () => { - const {getByText} = renderWithProvider({enabled: true}) - act(() => { - comlinkCallbacks.onStatus?.('connected') - }) + it('should handle received token and reset inProgress', async () => { + mockFetch.mockResolvedValueOnce({token: 'new-token'}) + const {getByText} = renderWithProvider() - act(() => { + await act(async () => { getByText('Request Token').click() }) - expect(currentHookValue.isTokenRefreshInProgress.current).toBe(true) - expect(mockSendMessage).toHaveBeenCalledTimes(1) - - act(() => { - comlinkCallbacks.onMessage['dashboard/v1/auth/tokens/create']({token: 'new-token'}) - }) - expect(mockSetAuthToken).toHaveBeenCalledWith(mockSanityInstance, 'new-token') expect(currentHookValue.isTokenRefreshInProgress.current).toBe(false) + expect(mockSetAuthToken).toHaveBeenCalledWith(mockSanityInstance, 'new-token') + expect(mockFetch).toHaveBeenCalledTimes(1) + // Ensure timeout was cleared (check by advancing time - progress should still be false) act(() => { - vi.advanceTimersByTime(15000) // Default timeout + vi.advanceTimersByTime(DEFAULT_RESPONSE_TIMEOUT + 1000) }) expect(currentHookValue.isTokenRefreshInProgress.current).toBe(false) }) - it('should not set auth token if received token is null', () => { - renderWithProvider({enabled: true}) - act(() => { - comlinkCallbacks.onStatus?.('connected') - }) - act(() => { + it('should not set auth token if received token is null', async () => { + mockFetch.mockResolvedValueOnce({token: null}) + renderWithProvider() + + await act(async () => { currentHookValue.requestNewToken() }) - act(() => { - comlinkCallbacks.onMessage['dashboard/v1/auth/tokens/create']({token: null}) - }) + expect(mockSetAuthToken).not.toHaveBeenCalled() expect(currentHookValue.isTokenRefreshInProgress.current).toBe(false) }) - it('should reset inProgress if sendMessage throws', () => { - mockSendMessage.mockImplementationOnce(() => { - throw new Error('Send failed') - }) - renderWithProvider({enabled: true}) - act(() => { - comlinkCallbacks.onStatus?.('connected') - }) - act(() => { + it('should reset inProgress if fetch throws', async () => { + mockFetch.mockRejectedValueOnce(new Error('Fetch failed')) + renderWithProvider() + + await act(async () => { currentHookValue.requestNewToken() }) + expect(currentHookValue.isTokenRefreshInProgress.current).toBe(false) - expect(mockSendMessage).toHaveBeenCalledTimes(1) + expect(mockFetch).toHaveBeenCalledTimes(1) }) describe('Automatic token refresh on 401', () => { const createError401 = () => ({statusCode: 401, message: 'Unauthorized'}) - it.skip('should request new token on 401 error if not already in progress', async () => { - mockUseAuthState.mockReturnValue({type: AuthStateType.LOGGED_IN}) - const {rerender} = renderWithProvider({enabled: true}) - - act(() => { - comlinkCallbacks.onStatus?.('connected') - }) - expect(currentHookValue.comlinkStatus).toBe('connected') - - currentHookValue.isTokenRefreshInProgress.current = false - act(() => { - rerender( - - - , - ) - }) - expect(currentHookValue.isTokenRefreshInProgress.current).toBe(false) - - mockUseAuthState.mockReturnValue({type: AuthStateType.ERROR, error: createError401()}) - act(() => { - rerender( - - - , - ) - }) - - await waitFor( - () => { - expect(mockSendMessage).toHaveBeenCalledWith('dashboard/v1/auth/tokens/create') - }, - {timeout: 10000}, - ) - expect(currentHookValue.isTokenRefreshInProgress.current).toBe(true) - }, 10000) - it('should not request new token on 401 if refresh is already in progress', async () => { + mockFetch.mockImplementationOnce(() => new Promise(() => {})) // Never resolves mockUseAuthState.mockReturnValue({type: AuthStateType.LOGGED_IN}) - const {rerender, getByText} = renderWithProvider({enabled: true}) - act(() => { - comlinkCallbacks.onStatus?.('connected') - }) + const {rerender, getByText} = renderWithProvider() - act(() => { + await act(async () => { getByText('Request Token').click() }) expect(currentHookValue.isTokenRefreshInProgress.current).toBe(true) - mockSendMessage.mockClear() + mockFetch.mockClear() mockUseAuthState.mockReturnValue({type: AuthStateType.ERROR, error: createError401()}) act(() => { rerender( - + , ) @@ -392,19 +273,19 @@ describe('ComlinkTokenRefresh', () => { await act(async () => { await vi.advanceTimersByTimeAsync(100) }) - expect(mockSendMessage).not.toHaveBeenCalled() + expect(mockFetch).not.toHaveBeenCalled() expect(currentHookValue.isTokenRefreshInProgress.current).toBe(true) - }, 10000) + }) it('should not request new token on 401 if not in dashboard', async () => { mockGetIsInDashboardState.mockReturnValue({getCurrent: () => false}) mockUseAuthState.mockReturnValue({type: AuthStateType.LOGGED_IN}) - const {rerender} = renderWithProvider({enabled: true}) + const {rerender} = renderWithProvider() mockUseAuthState.mockReturnValue({type: AuthStateType.ERROR, error: createError401()}) act(() => { rerender( - + , ) @@ -413,22 +294,19 @@ describe('ComlinkTokenRefresh', () => { await act(async () => { await vi.advanceTimersByTimeAsync(100) }) - expect(mockSendMessage).not.toHaveBeenCalled() + expect(mockFetch).not.toHaveBeenCalled() expect(currentHookValue.isTokenRefreshInProgress.current).toBe(false) - }, 10000) + }) it('should not request new token for non-401 errors', async () => { const error500 = {statusCode: 500, message: 'Server Error'} mockUseAuthState.mockReturnValue({type: AuthStateType.LOGGED_IN}) - const {rerender} = renderWithProvider({enabled: true}) - act(() => { - comlinkCallbacks.onStatus?.('connected') - }) + const {rerender} = renderWithProvider() mockUseAuthState.mockReturnValue({type: AuthStateType.ERROR, error: error500}) act(() => { rerender( - + , ) @@ -437,113 +315,28 @@ describe('ComlinkTokenRefresh', () => { await act(async () => { await vi.advanceTimersByTimeAsync(100) }) - expect(mockSendMessage).not.toHaveBeenCalled() + expect(mockFetch).not.toHaveBeenCalled() expect(currentHookValue.isTokenRefreshInProgress.current).toBe(false) - }, 10000) - - it.skip('should not process the same 401 error instance multiple times', async () => { - mockUseAuthState.mockReturnValue({type: AuthStateType.LOGGED_IN}) - const {rerender} = renderWithProvider({enabled: true}) - act(() => { - comlinkCallbacks.onStatus?.('connected') - }) - - const firstErrorInstance = createError401() - mockUseAuthState.mockReturnValue({type: AuthStateType.ERROR, error: firstErrorInstance}) - act(() => { - rerender( - - - , - ) - }) - await waitFor(() => expect(mockSendMessage).toHaveBeenCalledTimes(1), {timeout: 10000}) - expect(currentHookValue.isTokenRefreshInProgress.current).toBe(true) - - mockUseAuthState.mockReturnValue({type: AuthStateType.ERROR, error: firstErrorInstance}) - act(() => { - rerender( - - - , - ) - }) - await act(async () => { - await vi.advanceTimersByTimeAsync(100) - }) - expect(mockSendMessage).toHaveBeenCalledTimes(1) - - act(() => { - vi.advanceTimersByTime(15000) - }) - await waitFor( - () => expect(currentHookValue.isTokenRefreshInProgress.current).toBe(false), - {timeout: 10000}, - ) - mockSendMessage.mockClear() - - const newErrorInstance = createError401() - mockUseAuthState.mockReturnValue({type: AuthStateType.ERROR, error: newErrorInstance}) - act(() => { - rerender( - - - , - ) - }) - await waitFor(() => expect(mockSendMessage).toHaveBeenCalledTimes(1), {timeout: 10000}) - expect(currentHookValue.isTokenRefreshInProgress.current).toBe(true) - }, 20000) + }) - it.skip('should reset processed error ref if auth state changes to non-error or different error', async () => { + it('should request new token on LOGGED_OUT state', async () => { + // Use a promise that never resolves to keep the refresh in progress + mockFetch.mockImplementationOnce(() => new Promise(() => {})) mockUseAuthState.mockReturnValue({type: AuthStateType.LOGGED_IN}) - const {rerender} = renderWithProvider({enabled: true}) - act(() => { - comlinkCallbacks.onStatus?.('connected') - }) - - const firstError = createError401() - mockUseAuthState.mockReturnValue({type: AuthStateType.ERROR, error: firstError}) - act(() => { - rerender( - - - , - ) - }) - await waitFor(() => expect(mockSendMessage).toHaveBeenCalledTimes(1), {timeout: 10000}) - act(() => { - vi.advanceTimersByTime(15000) - }) - await waitFor( - () => expect(currentHookValue.isTokenRefreshInProgress.current).toBe(false), - {timeout: 10000}, - ) - mockSendMessage.mockClear() + const {rerender} = renderWithProvider() - mockUseAuthState.mockReturnValue({type: AuthStateType.LOGGED_IN}) + mockUseAuthState.mockReturnValue({type: AuthStateType.LOGGED_OUT}) act(() => { rerender( - + , ) }) - await act(async () => { - await vi.advanceTimersByTimeAsync(100) - }) - mockUseAuthState.mockReturnValue({type: AuthStateType.ERROR, error: createError401()}) - act(() => { - rerender( - - - , - ) - }) - await waitFor(() => expect(mockSendMessage).toHaveBeenCalledTimes(1), {timeout: 10000}) + expect(mockFetch).toHaveBeenCalledWith('dashboard/v1/auth/tokens/create') expect(currentHookValue.isTokenRefreshInProgress.current).toBe(true) - }, 25000) + }) }) }) }) From 2ada833d0cd7f3b2d9ff0bcf442962900e89981f Mon Sep 17 00:00:00 2001 From: Ryan Bonial Date: Mon, 16 Jun 2025 15:10:46 -0600 Subject: [PATCH 12/17] fix: invalid export --- packages/react/src/_exports/sdk-react.ts | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/packages/react/src/_exports/sdk-react.ts b/packages/react/src/_exports/sdk-react.ts index 5a83e3b8..79eb2247 100644 --- a/packages/react/src/_exports/sdk-react.ts +++ b/packages/react/src/_exports/sdk-react.ts @@ -4,11 +4,7 @@ export {AuthBoundary, type AuthBoundaryProps} from '../components/auth/AuthBoundary' export {SanityApp, type SanityAppProps} from '../components/SanityApp' export {SDKProvider, type SDKProviderProps} from '../components/SDKProvider' -export { - type ComlinkTokenRefreshConfig, - ComlinkTokenRefreshProvider, - useComlinkTokenRefresh, -} from '../context/ComlinkTokenRefresh' +export {ComlinkTokenRefreshProvider, useComlinkTokenRefresh} from '../context/ComlinkTokenRefresh' export {ResourceProvider, type ResourceProviderProps} from '../context/ResourceProvider' export {useAuthState} from '../hooks/auth/useAuthState' export {useAuthToken} from '../hooks/auth/useAuthToken' From 74f32f06bdc20c911d06bd67d45f4dfad06d9497 Mon Sep 17 00:00:00 2001 From: Ryan Bonial Date: Mon, 16 Jun 2025 15:15:06 -0600 Subject: [PATCH 13/17] chore: remove unused middleware option --- packages/core/src/client/clientStore.ts | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/packages/core/src/client/clientStore.ts b/packages/core/src/client/clientStore.ts index d8ee2edc..c83b266e 100644 --- a/packages/core/src/client/clientStore.ts +++ b/packages/core/src/client/clientStore.ts @@ -141,8 +141,8 @@ const getClientConfigKey = (options: ClientOptions) => JSON.stringify(pick(optio */ export const getClient = bindActionGlobally( clientStore, - ({state, instance}, options: ClientOptions, middleware?: unknown[]) => { - // Check for disallowed keys (excluding middleware) + ({state, instance}, options: ClientOptions) => { + // Check for disallowed keys const providedKeys = Object.keys(options) as (keyof ClientOptions)[] const disallowedKeys = providedKeys.filter((key) => !allowedKeys.includes(key)) @@ -160,7 +160,7 @@ export const getClient = bindActionGlobally( const dataset = options.dataset ?? instance.config.dataset const apiHost = options.apiHost ?? instance.config.auth?.apiHost - const effectiveOptions: ClientConfig = { + const effectiveOptions: ClientOptions = { ...DEFAULT_CLIENT_CONFIG, ...((options.scope === 'global' || !projectId) && {useProjectHostname: false}), token: authMethod === 'cookie' ? undefined : (tokenFromState ?? undefined), @@ -168,8 +168,6 @@ export const getClient = bindActionGlobally( ...(projectId && {projectId}), ...(dataset && {dataset}), ...(apiHost && {apiHost}), - // eslint-disable-next-line @typescript-eslint/no-explicit-any - ...(middleware && {middleware: middleware as any}), } if (effectiveOptions.token === null || typeof effectiveOptions.token === 'undefined') { @@ -181,12 +179,11 @@ export const getClient = bindActionGlobally( delete effectiveOptions.withCredentials } - // Key generation uses only standard options passed to getClient - const key = getClientConfigKey(options) // Use original options for key + const key = getClientConfigKey(effectiveOptions) if (clients[key]) return clients[key] - const client = createClient(effectiveOptions) // Pass options including middleware here + const client = createClient(effectiveOptions) state.set('addClient', (prev) => ({clients: {...prev.clients, [key]: client}})) return client From cf972296fb30c1957d9e6216afbe382fb4b8c0e0 Mon Sep 17 00:00:00 2001 From: Ryan Bonial Date: Mon, 16 Jun 2025 15:16:43 -0600 Subject: [PATCH 14/17] chore: fix unintentional changelog changes --- packages/core/CHANGELOG.md | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/packages/core/CHANGELOG.md b/packages/core/CHANGELOG.md index 5bd9c3b4..c9fa6859 100644 --- a/packages/core/CHANGELOG.md +++ b/packages/core/CHANGELOG.md @@ -2,23 +2,21 @@ ## [2.0.0](https://github.com/sanity-io/sdk/compare/sdk-v1.0.0...sdk-v2.0.0) (2025-05-23) - ### ⚠ BREAKING CHANGES -* change `status` to `_status` in projection and preview ([#527](https://github.com/sanity-io/sdk/issues/527)) +- change `status` to `_status` in projection and preview ([#527](https://github.com/sanity-io/sdk/issues/527)) ### Bug Fixes -* change `status` to `_status` in projection and preview ([#527](https://github.com/sanity-io/sdk/issues/527)) ([79f6df6](https://github.com/sanity-io/sdk/commit/79f6df6fcf5479bb144447c246e093551ed8c865)) -* **core:** align release order with studio release order ([#534](https://github.com/sanity-io/sdk/issues/534)) ([afd4b2c](https://github.com/sanity-io/sdk/commit/afd4b2cd9242763403d30796afd8ad73a45dd075)) -* **deps:** update dependency @sanity/client to ^7.2.1 ([#526](https://github.com/sanity-io/sdk/issues/526)) ([34b4f26](https://github.com/sanity-io/sdk/commit/34b4f260c1d639414908dd2f1dd8f375e7d1b73e)) -* **deps:** update dependency @sanity/comlink to ^3.0.3 ([#525](https://github.com/sanity-io/sdk/issues/525)) ([e0599ea](https://github.com/sanity-io/sdk/commit/e0599ea7965555b16a4ae4e9b45a91a91ae94b13)) -* **deps:** update dependency @sanity/comlink to ^3.0.4 ([#542](https://github.com/sanity-io/sdk/issues/542)) ([7365c97](https://github.com/sanity-io/sdk/commit/7365c97f2100367cbdc9eaa7adebdeee9f596733)) - +- change `status` to `_status` in projection and preview ([#527](https://github.com/sanity-io/sdk/issues/527)) ([79f6df6](https://github.com/sanity-io/sdk/commit/79f6df6fcf5479bb144447c246e093551ed8c865)) +- **core:** align release order with studio release order ([#534](https://github.com/sanity-io/sdk/issues/534)) ([afd4b2c](https://github.com/sanity-io/sdk/commit/afd4b2cd9242763403d30796afd8ad73a45dd075)) +- **deps:** update dependency @sanity/client to ^7.2.1 ([#526](https://github.com/sanity-io/sdk/issues/526)) ([34b4f26](https://github.com/sanity-io/sdk/commit/34b4f260c1d639414908dd2f1dd8f375e7d1b73e)) +- **deps:** update dependency @sanity/comlink to ^3.0.3 ([#525](https://github.com/sanity-io/sdk/issues/525)) ([e0599ea](https://github.com/sanity-io/sdk/commit/e0599ea7965555b16a4ae4e9b45a91a91ae94b13)) +- **deps:** update dependency @sanity/comlink to ^3.0.4 ([#542](https://github.com/sanity-io/sdk/issues/542)) ([7365c97](https://github.com/sanity-io/sdk/commit/7365c97f2100367cbdc9eaa7adebdeee9f596733)) ### Miscellaneous -* release 2.0.0 ([#544](https://github.com/sanity-io/sdk/issues/544)) ([048cb50](https://github.com/sanity-io/sdk/commit/048cb503ea2e7852c984c376e48ff74d2a7023be)) +- release 2.0.0 ([#544](https://github.com/sanity-io/sdk/issues/544)) ([048cb50](https://github.com/sanity-io/sdk/commit/048cb503ea2e7852c984c376e48ff74d2a7023be)) ## [1.0.0](https://github.com/sanity-io/sdk/compare/sdk-v1.0.0...sdk-v1.0.0) (2025-05-07) From 267f20362192841ab40d7712d70e728d7aecef4d Mon Sep 17 00:00:00 2001 From: Ryan Bonial Date: Mon, 16 Jun 2025 15:17:29 -0600 Subject: [PATCH 15/17] fix: changelog --- packages/core/CHANGELOG.md | 518 ++++++++++++++++++++----------------- 1 file changed, 286 insertions(+), 232 deletions(-) diff --git a/packages/core/CHANGELOG.md b/packages/core/CHANGELOG.md index c9fa6859..03595f0e 100644 --- a/packages/core/CHANGELOG.md +++ b/packages/core/CHANGELOG.md @@ -2,500 +2,554 @@ ## [2.0.0](https://github.com/sanity-io/sdk/compare/sdk-v1.0.0...sdk-v2.0.0) (2025-05-23) + ### ⚠ BREAKING CHANGES -- change `status` to `_status` in projection and preview ([#527](https://github.com/sanity-io/sdk/issues/527)) +* change `status` to `_status` in projection and preview ([#527](https://github.com/sanity-io/sdk/issues/527)) ### Bug Fixes -- change `status` to `_status` in projection and preview ([#527](https://github.com/sanity-io/sdk/issues/527)) ([79f6df6](https://github.com/sanity-io/sdk/commit/79f6df6fcf5479bb144447c246e093551ed8c865)) -- **core:** align release order with studio release order ([#534](https://github.com/sanity-io/sdk/issues/534)) ([afd4b2c](https://github.com/sanity-io/sdk/commit/afd4b2cd9242763403d30796afd8ad73a45dd075)) -- **deps:** update dependency @sanity/client to ^7.2.1 ([#526](https://github.com/sanity-io/sdk/issues/526)) ([34b4f26](https://github.com/sanity-io/sdk/commit/34b4f260c1d639414908dd2f1dd8f375e7d1b73e)) -- **deps:** update dependency @sanity/comlink to ^3.0.3 ([#525](https://github.com/sanity-io/sdk/issues/525)) ([e0599ea](https://github.com/sanity-io/sdk/commit/e0599ea7965555b16a4ae4e9b45a91a91ae94b13)) -- **deps:** update dependency @sanity/comlink to ^3.0.4 ([#542](https://github.com/sanity-io/sdk/issues/542)) ([7365c97](https://github.com/sanity-io/sdk/commit/7365c97f2100367cbdc9eaa7adebdeee9f596733)) +* change `status` to `_status` in projection and preview ([#527](https://github.com/sanity-io/sdk/issues/527)) ([79f6df6](https://github.com/sanity-io/sdk/commit/79f6df6fcf5479bb144447c246e093551ed8c865)) +* **core:** align release order with studio release order ([#534](https://github.com/sanity-io/sdk/issues/534)) ([afd4b2c](https://github.com/sanity-io/sdk/commit/afd4b2cd9242763403d30796afd8ad73a45dd075)) +* **deps:** update dependency @sanity/client to ^7.2.1 ([#526](https://github.com/sanity-io/sdk/issues/526)) ([34b4f26](https://github.com/sanity-io/sdk/commit/34b4f260c1d639414908dd2f1dd8f375e7d1b73e)) +* **deps:** update dependency @sanity/comlink to ^3.0.3 ([#525](https://github.com/sanity-io/sdk/issues/525)) ([e0599ea](https://github.com/sanity-io/sdk/commit/e0599ea7965555b16a4ae4e9b45a91a91ae94b13)) +* **deps:** update dependency @sanity/comlink to ^3.0.4 ([#542](https://github.com/sanity-io/sdk/issues/542)) ([7365c97](https://github.com/sanity-io/sdk/commit/7365c97f2100367cbdc9eaa7adebdeee9f596733)) + ### Miscellaneous -- release 2.0.0 ([#544](https://github.com/sanity-io/sdk/issues/544)) ([048cb50](https://github.com/sanity-io/sdk/commit/048cb503ea2e7852c984c376e48ff74d2a7023be)) +* release 2.0.0 ([#544](https://github.com/sanity-io/sdk/issues/544)) ([048cb50](https://github.com/sanity-io/sdk/commit/048cb503ea2e7852c984c376e48ff74d2a7023be)) ## [1.0.0](https://github.com/sanity-io/sdk/compare/sdk-v1.0.0...sdk-v1.0.0) (2025-05-07) + ### Miscellaneous -- release 1.0.0 ([#517](https://github.com/sanity-io/sdk/issues/517)) ([52c00a1](https://github.com/sanity-io/sdk/commit/52c00a1eb99a6a34681bba363207ebcf4a9b5371)) +* release 1.0.0 ([#517](https://github.com/sanity-io/sdk/issues/517)) ([52c00a1](https://github.com/sanity-io/sdk/commit/52c00a1eb99a6a34681bba363207ebcf4a9b5371)) ## [0.0.3](https://github.com/sanity-io/sdk/compare/sdk-v0.0.2...sdk-v0.0.3) (2025-05-07) + ### ⚠ BREAKING CHANGES -- bump versions ([#516](https://github.com/sanity-io/sdk/issues/516)) +* bump versions ([#516](https://github.com/sanity-io/sdk/issues/516)) ### Bug Fixes -- bump versions ([#516](https://github.com/sanity-io/sdk/issues/516)) ([3601ade](https://github.com/sanity-io/sdk/commit/3601adeebe986af4102f639500a754d585694d9e)) -- **core:** use raw perspective for functions that coalesce drafts and published ([#503](https://github.com/sanity-io/sdk/issues/503)) ([0bf6c57](https://github.com/sanity-io/sdk/commit/0bf6c577183fd0796fa9c00347af258cbb9b607c)) +* bump versions ([#516](https://github.com/sanity-io/sdk/issues/516)) ([3601ade](https://github.com/sanity-io/sdk/commit/3601adeebe986af4102f639500a754d585694d9e)) +* **core:** use raw perspective for functions that coalesce drafts and published ([#503](https://github.com/sanity-io/sdk/issues/503)) ([0bf6c57](https://github.com/sanity-io/sdk/commit/0bf6c577183fd0796fa9c00347af258cbb9b607c)) + ### Documentation -- update package readmes ([#513](https://github.com/sanity-io/sdk/issues/513)) ([aa79bc7](https://github.com/sanity-io/sdk/commit/aa79bc74e904cfcac119be415d871fc71fe17277)) +* update package readmes ([#513](https://github.com/sanity-io/sdk/issues/513)) ([aa79bc7](https://github.com/sanity-io/sdk/commit/aa79bc74e904cfcac119be415d871fc71fe17277)) ## [0.0.2](https://github.com/sanity-io/sdk/compare/sdk-v0.0.1...sdk-v0.0.2) (2025-05-06) + ### ⚠ BREAKING CHANGES -- make all comlink hooks suspend ([#504](https://github.com/sanity-io/sdk/issues/504)) +* make all comlink hooks suspend ([#504](https://github.com/sanity-io/sdk/issues/504)) ### Features -- make all comlink hooks suspend ([#504](https://github.com/sanity-io/sdk/issues/504)) ([d49bf0e](https://github.com/sanity-io/sdk/commit/d49bf0e4be9268d68dbec186ed3ba6afc075bedb)) +* make all comlink hooks suspend ([#504](https://github.com/sanity-io/sdk/issues/504)) ([d49bf0e](https://github.com/sanity-io/sdk/commit/d49bf0e4be9268d68dbec186ed3ba6afc075bedb)) + ### Bug Fixes -- **core:** bump default api versions ([#507](https://github.com/sanity-io/sdk/issues/507)) ([dc4f6f6](https://github.com/sanity-io/sdk/commit/dc4f6f67a1c86e0a30cb69ebc23c11ca06ff4ac2)) -- **deps:** update dependency zustand to ^5.0.4 ([#500](https://github.com/sanity-io/sdk/issues/500)) ([0847430](https://github.com/sanity-io/sdk/commit/0847430c57d170ccbecd853f0e9621ccc74664d7)) +* **core:** bump default api versions ([#507](https://github.com/sanity-io/sdk/issues/507)) ([dc4f6f6](https://github.com/sanity-io/sdk/commit/dc4f6f67a1c86e0a30cb69ebc23c11ca06ff4ac2)) +* **deps:** update dependency zustand to ^5.0.4 ([#500](https://github.com/sanity-io/sdk/issues/500)) ([0847430](https://github.com/sanity-io/sdk/commit/0847430c57d170ccbecd853f0e9621ccc74664d7)) ## [0.0.1](https://github.com/sanity-io/sdk/compare/sdk-v0.0.0...sdk-v0.0.1) (2025-05-02) + ### Bug Fixes -- **docs:** remove custom docs entrypoint names ([#498](https://github.com/sanity-io/sdk/issues/498)) ([4499e85](https://github.com/sanity-io/sdk/commit/4499e85a3a30a5086bceb164c19cb18c71376471)) +* **docs:** remove custom docs entrypoint names ([#498](https://github.com/sanity-io/sdk/issues/498)) ([4499e85](https://github.com/sanity-io/sdk/commit/4499e85a3a30a5086bceb164c19cb18c71376471)) ## 0.0.0 (2025-05-02) + ### Features -- allow ~experimental_resource client option ([08b4582](https://github.com/sanity-io/sdk/commit/08b4582840ddbd39e1343b07704dfb758a4e988d)) +* allow ~experimental_resource client option ([08b4582](https://github.com/sanity-io/sdk/commit/08b4582840ddbd39e1343b07704dfb758a4e988d)) + ### Bug Fixes -- **deps:** update dependency @sanity/message-protocol to ^0.12.0 ([#484](https://github.com/sanity-io/sdk/issues/484)) ([f3beb42](https://github.com/sanity-io/sdk/commit/f3beb42ddad7ad9bf7826783602d57be006c15ee)) +* **deps:** update dependency @sanity/message-protocol to ^0.12.0 ([#484](https://github.com/sanity-io/sdk/issues/484)) ([f3beb42](https://github.com/sanity-io/sdk/commit/f3beb42ddad7ad9bf7826783602d57be006c15ee)) + ### Miscellaneous -- release 0.0.0 ([08c9acc](https://github.com/sanity-io/sdk/commit/08c9acc0a34954cd611a53753fac2b788b61da9b)) +* release 0.0.0 ([08c9acc](https://github.com/sanity-io/sdk/commit/08c9acc0a34954cd611a53753fac2b788b61da9b)) ## [0.0.0-alpha.31](https://github.com/sanity-io/sdk/compare/sdk-v0.0.0-alpha.30...sdk-v0.0.0-alpha.31) (2025-05-01) + ### Bug Fixes -- **deps:** update dependency @sanity/comlink to ^3.0.2 ([#482](https://github.com/sanity-io/sdk/issues/482)) ([f9b3eca](https://github.com/sanity-io/sdk/commit/f9b3eca4a0a21a456ebda46b42b836efd9f7718f)) +* **deps:** update dependency @sanity/comlink to ^3.0.2 ([#482](https://github.com/sanity-io/sdk/issues/482)) ([f9b3eca](https://github.com/sanity-io/sdk/commit/f9b3eca4a0a21a456ebda46b42b836efd9f7718f)) ## [0.0.0-alpha.30](https://github.com/sanity-io/sdk/compare/sdk-v0.0.0-alpha.29...sdk-v0.0.0-alpha.30) (2025-05-01) + ### ⚠ BREAKING CHANGES -- fetch favorites from dashboard ([#437](https://github.com/sanity-io/sdk/issues/437)) +* fetch favorites from dashboard ([#437](https://github.com/sanity-io/sdk/issues/437)) ### Features -- add releases store ([#420](https://github.com/sanity-io/sdk/issues/420)) ([b5a376c](https://github.com/sanity-io/sdk/commit/b5a376c86e700031fe1700fb55b7f0d1236aaea3)) -- **auth:** add studio mode ([#429](https://github.com/sanity-io/sdk/issues/429)) ([cef0f72](https://github.com/sanity-io/sdk/commit/cef0f7229d519709b4f069b982110c32a4d23217)) -- fetch favorites from dashboard ([#437](https://github.com/sanity-io/sdk/issues/437)) ([1a8ecb8](https://github.com/sanity-io/sdk/commit/1a8ecb89217b05c6ed90699c7ee162592cedb896)) -- integrate typegen ([#452](https://github.com/sanity-io/sdk/issues/452)) ([8416864](https://github.com/sanity-io/sdk/commit/8416864533f0f14851e8e71c15be4a1596711b52)) -- verify projects match current org for dashboard apps ([#464](https://github.com/sanity-io/sdk/issues/464)) ([52c8c76](https://github.com/sanity-io/sdk/commit/52c8c7668f09b119d6ca618381e1a44d134612a3)) +* add releases store ([#420](https://github.com/sanity-io/sdk/issues/420)) ([b5a376c](https://github.com/sanity-io/sdk/commit/b5a376c86e700031fe1700fb55b7f0d1236aaea3)) +* **auth:** add studio mode ([#429](https://github.com/sanity-io/sdk/issues/429)) ([cef0f72](https://github.com/sanity-io/sdk/commit/cef0f7229d519709b4f069b982110c32a4d23217)) +* fetch favorites from dashboard ([#437](https://github.com/sanity-io/sdk/issues/437)) ([1a8ecb8](https://github.com/sanity-io/sdk/commit/1a8ecb89217b05c6ed90699c7ee162592cedb896)) +* integrate typegen ([#452](https://github.com/sanity-io/sdk/issues/452)) ([8416864](https://github.com/sanity-io/sdk/commit/8416864533f0f14851e8e71c15be4a1596711b52)) +* verify projects match current org for dashboard apps ([#464](https://github.com/sanity-io/sdk/issues/464)) ([52c8c76](https://github.com/sanity-io/sdk/commit/52c8c7668f09b119d6ca618381e1a44d134612a3)) + ### Bug Fixes -- **deps:** update dependency @sanity/client to ^6.29.1 ([#466](https://github.com/sanity-io/sdk/issues/466)) ([f25ba2b](https://github.com/sanity-io/sdk/commit/f25ba2b2aa32e3c010a6adf5658367c6fa3e149e)) -- **deps:** update dependency @sanity/client to v7 ([#478](https://github.com/sanity-io/sdk/issues/478)) ([e5ed504](https://github.com/sanity-io/sdk/commit/e5ed5047c84c3864cdbebd2c158184d57dfdaff9)) +* **deps:** update dependency @sanity/client to ^6.29.1 ([#466](https://github.com/sanity-io/sdk/issues/466)) ([f25ba2b](https://github.com/sanity-io/sdk/commit/f25ba2b2aa32e3c010a6adf5658367c6fa3e149e)) +* **deps:** update dependency @sanity/client to v7 ([#478](https://github.com/sanity-io/sdk/issues/478)) ([e5ed504](https://github.com/sanity-io/sdk/commit/e5ed5047c84c3864cdbebd2c158184d57dfdaff9)) + ### Documentation -- cleanup for Apr 30 ([#479](https://github.com/sanity-io/sdk/issues/479)) ([8793c1e](https://github.com/sanity-io/sdk/commit/8793c1e0d93bc9184d9a65f6e11d35dc148e4ac5)) -- update readmes ([#474](https://github.com/sanity-io/sdk/issues/474)) ([042a853](https://github.com/sanity-io/sdk/commit/042a85316c8179b8a135abbae4d66a4e467f5ee0)) +* cleanup for Apr 30 ([#479](https://github.com/sanity-io/sdk/issues/479)) ([8793c1e](https://github.com/sanity-io/sdk/commit/8793c1e0d93bc9184d9a65f6e11d35dc148e4ac5)) +* update readmes ([#474](https://github.com/sanity-io/sdk/issues/474)) ([042a853](https://github.com/sanity-io/sdk/commit/042a85316c8179b8a135abbae4d66a4e467f5ee0)) ## [0.0.0-alpha.29](https://github.com/sanity-io/sdk/compare/sdk-v0.0.0-alpha.28...sdk-v0.0.0-alpha.29) (2025-04-23) + ### Features -- **auth:** check for a token being passed into the url hash from the dashboard ([#451](https://github.com/sanity-io/sdk/issues/451)) ([59893e2](https://github.com/sanity-io/sdk/commit/59893e2216acdf01f5187617cd42b2bc3760a068)) +* **auth:** check for a token being passed into the url hash from the dashboard ([#451](https://github.com/sanity-io/sdk/issues/451)) ([59893e2](https://github.com/sanity-io/sdk/commit/59893e2216acdf01f5187617cd42b2bc3760a068)) + ### Bug Fixes -- **build:** fixes build to not include node libraries ([#456](https://github.com/sanity-io/sdk/issues/456)) ([11a8d8a](https://github.com/sanity-io/sdk/commit/11a8d8a6c35dcfd0eeba3f5ca926b5e263aa56e8)) +* **build:** fixes build to not include node libraries ([#456](https://github.com/sanity-io/sdk/issues/456)) ([11a8d8a](https://github.com/sanity-io/sdk/commit/11a8d8a6c35dcfd0eeba3f5ca926b5e263aa56e8)) ## [0.0.0-alpha.28](https://github.com/sanity-io/sdk/compare/sdk-v0.0.0-alpha.27...sdk-v0.0.0-alpha.28) (2025-04-22) + ### Bug Fixes -- **core:** refactor calculatePermissions to fix initialization error ([#443](https://github.com/sanity-io/sdk/issues/443)) ([e59d6e5](https://github.com/sanity-io/sdk/commit/e59d6e54b1da22194446ffffc747ddbf0711f134)) +* **core:** refactor calculatePermissions to fix initialization error ([#443](https://github.com/sanity-io/sdk/issues/443)) ([e59d6e5](https://github.com/sanity-io/sdk/commit/e59d6e54b1da22194446ffffc747ddbf0711f134)) ## [0.0.0-alpha.27](https://github.com/sanity-io/sdk/compare/sdk-v0.0.0-alpha.26...sdk-v0.0.0-alpha.27) (2025-04-22) + ### Miscellaneous -- **sdk:** Synchronize sdk versions +* **sdk:** Synchronize sdk versions ## [0.0.0-alpha.26](https://github.com/sanity-io/sdk/compare/sdk-v0.0.0-alpha.25...sdk-v0.0.0-alpha.26) (2025-04-21) + ### Features -- **auth:** don't store tokens in localstorage if running in dashboard ([#409](https://github.com/sanity-io/sdk/issues/409)) ([637f17c](https://github.com/sanity-io/sdk/commit/637f17cc3d38037a0fbc3020173ef619c24acbc1)) +* **auth:** don't store tokens in localstorage if running in dashboard ([#409](https://github.com/sanity-io/sdk/issues/409)) ([637f17c](https://github.com/sanity-io/sdk/commit/637f17cc3d38037a0fbc3020173ef619c24acbc1)) + ### Bug Fixes -- **auth:** ensure initial url does not contain an sid and improve error handling ([#418](https://github.com/sanity-io/sdk/issues/418)) ([4d76bfc](https://github.com/sanity-io/sdk/commit/4d76bfc52542896128efd7cbd6d5342f1c275cd5)) -- **authentication:** use web lock to ensure only one token refresh process runs over multiple tabs ([#398](https://github.com/sanity-io/sdk/issues/398)) ([64aa9fa](https://github.com/sanity-io/sdk/commit/64aa9fa0ecd4efeda8dd6ff7277a272d7e0945a8)) -- **auth:** fix bug with incorrect refreshing with newly acquired tokens ([#422](https://github.com/sanity-io/sdk/issues/422)) ([1218361](https://github.com/sanity-io/sdk/commit/121836143486c7c40d770ed5748d9c09b4911e9f)) -- **core:** allow multiple projections per doc ([#403](https://github.com/sanity-io/sdk/issues/403)) ([d30c5ae](https://github.com/sanity-io/sdk/commit/d30c5ae58de5710cd6ed6bbcaa83fb02c29b7e6c)) -- **deps:** update dependency @sanity/client to ^6.29.0 ([#435](https://github.com/sanity-io/sdk/issues/435)) ([c6c7b35](https://github.com/sanity-io/sdk/commit/c6c7b35f0e71c5e40747866704b7b16ebf10e4fb)) -- **deps:** update dependency @sanity/types to ^3.83.0 ([#412](https://github.com/sanity-io/sdk/issues/412)) ([b40b289](https://github.com/sanity-io/sdk/commit/b40b289ea67026e7f0a0b7a2f95486e7a27a71c1)) -- **deps:** update dependency rxjs to ^7.8.2 ([#427](https://github.com/sanity-io/sdk/issues/427)) ([cbbf964](https://github.com/sanity-io/sdk/commit/cbbf9645eb2b4d43746d6283e237fbdfd5068080)) +* **auth:** ensure initial url does not contain an sid and improve error handling ([#418](https://github.com/sanity-io/sdk/issues/418)) ([4d76bfc](https://github.com/sanity-io/sdk/commit/4d76bfc52542896128efd7cbd6d5342f1c275cd5)) +* **authentication:** use web lock to ensure only one token refresh process runs over multiple tabs ([#398](https://github.com/sanity-io/sdk/issues/398)) ([64aa9fa](https://github.com/sanity-io/sdk/commit/64aa9fa0ecd4efeda8dd6ff7277a272d7e0945a8)) +* **auth:** fix bug with incorrect refreshing with newly acquired tokens ([#422](https://github.com/sanity-io/sdk/issues/422)) ([1218361](https://github.com/sanity-io/sdk/commit/121836143486c7c40d770ed5748d9c09b4911e9f)) +* **core:** allow multiple projections per doc ([#403](https://github.com/sanity-io/sdk/issues/403)) ([d30c5ae](https://github.com/sanity-io/sdk/commit/d30c5ae58de5710cd6ed6bbcaa83fb02c29b7e6c)) +* **deps:** update dependency @sanity/client to ^6.29.0 ([#435](https://github.com/sanity-io/sdk/issues/435)) ([c6c7b35](https://github.com/sanity-io/sdk/commit/c6c7b35f0e71c5e40747866704b7b16ebf10e4fb)) +* **deps:** update dependency @sanity/types to ^3.83.0 ([#412](https://github.com/sanity-io/sdk/issues/412)) ([b40b289](https://github.com/sanity-io/sdk/commit/b40b289ea67026e7f0a0b7a2f95486e7a27a71c1)) +* **deps:** update dependency rxjs to ^7.8.2 ([#427](https://github.com/sanity-io/sdk/issues/427)) ([cbbf964](https://github.com/sanity-io/sdk/commit/cbbf9645eb2b4d43746d6283e237fbdfd5068080)) + ### Documentation -- fix duplication/entrypoints; add SDK Core note ([#430](https://github.com/sanity-io/sdk/issues/430)) ([f1046fa](https://github.com/sanity-io/sdk/commit/f1046faec1c70d3690ddc9b4d4f92d7c433178a2)) +* fix duplication/entrypoints; add SDK Core note ([#430](https://github.com/sanity-io/sdk/issues/430)) ([f1046fa](https://github.com/sanity-io/sdk/commit/f1046faec1c70d3690ddc9b4d4f92d7c433178a2)) ## [0.0.0-alpha.25](https://github.com/sanity-io/sdk/compare/v0.0.0-alpha.24...v0.0.0-alpha.25) (2025-04-09) + ### Features -- **core, react:** introduce createGroqSearchFilter utility for search ([#407](https://github.com/sanity-io/sdk/issues/407)) ([77766bb](https://github.com/sanity-io/sdk/commit/77766bbf3fdc7efef4cd8a24f0ca206bef3179ec)) +* **core, react:** introduce createGroqSearchFilter utility for search ([#407](https://github.com/sanity-io/sdk/issues/407)) ([77766bb](https://github.com/sanity-io/sdk/commit/77766bbf3fdc7efef4cd8a24f0ca206bef3179ec)) + ### Bug Fixes -- **deps:** update dependency zustand to ^5.0.3 ([#404](https://github.com/sanity-io/sdk/issues/404)) ([a1ff448](https://github.com/sanity-io/sdk/commit/a1ff448d4fd5370d9d868e5da19348247fc30ddc)) +* **deps:** update dependency zustand to ^5.0.3 ([#404](https://github.com/sanity-io/sdk/issues/404)) ([a1ff448](https://github.com/sanity-io/sdk/commit/a1ff448d4fd5370d9d868e5da19348247fc30ddc)) ## [0.0.0-alpha.24](https://github.com/sanity-io/sdk/compare/v0.0.0-alpha.23...v0.0.0-alpha.24) (2025-04-09) + ### ⚠ BREAKING CHANGES -- use hosted login for standalone apps ([#386](https://github.com/sanity-io/sdk/issues/386)) -- replace `sanityConfigs` prop with `config` prop in `` and `` -- replace `resourceId` concept with explicit `projectId` and `dataset` fields in handles -- rename `_type` to `documentType` in DocumentHandle interface and related usages -- rename `_id` to `documentId` in DocumentHandle interface and related usages -- update document hooks and actions to expect `DocumentHandle` props -- update project and dataset hooks to use `ProjectHandle` or `DatasetHandle` -- remove ``, introduce `` for configuration -- rename usePermissions → useDocumentPermissions ([#365](https://github.com/sanity-io/sdk/issues/365)) -- rename useActions → useDocumentActions and useActions → useDocumentActions ([#362](https://github.com/sanity-io/sdk/issues/362)) -- rename useHandleCallback → useHandleAuthCallback and HandleCallback → HandleAuthCallback ([#358](https://github.com/sanity-io/sdk/issues/358)) -- rename `results` to `data` for useProjection hook ([#335](https://github.com/sanity-io/sdk/issues/335)) -- rename `result` to `data` for usePreview hook ([#325](https://github.com/sanity-io/sdk/issues/325)) -- **react:** flatten sdk-react imports ([#319](https://github.com/sanity-io/sdk/issues/319)) -- remove `schema` from sanity config -- remove schema state and schema manager -- remove `useDocuments` and `useSearch` hooks -- allow multiple resources via instances ([#271](https://github.com/sanity-io/sdk/issues/271)) -- renames `org` auth scope to `global` ([#187](https://github.com/sanity-io/sdk/issues/187)) +* use hosted login for standalone apps ([#386](https://github.com/sanity-io/sdk/issues/386)) +* replace `sanityConfigs` prop with `config` prop in `` and `` +* replace `resourceId` concept with explicit `projectId` and `dataset` fields in handles +* rename `_type` to `documentType` in DocumentHandle interface and related usages +* rename `_id` to `documentId` in DocumentHandle interface and related usages +* update document hooks and actions to expect `DocumentHandle` props +* update project and dataset hooks to use `ProjectHandle` or `DatasetHandle` +* remove ``, introduce `` for configuration +* rename usePermissions → useDocumentPermissions ([#365](https://github.com/sanity-io/sdk/issues/365)) +* rename useActions → useDocumentActions and useActions → useDocumentActions ([#362](https://github.com/sanity-io/sdk/issues/362)) +* rename useHandleCallback → useHandleAuthCallback and HandleCallback → HandleAuthCallback ([#358](https://github.com/sanity-io/sdk/issues/358)) +* rename `results` to `data` for useProjection hook ([#335](https://github.com/sanity-io/sdk/issues/335)) +* rename `result` to `data` for usePreview hook ([#325](https://github.com/sanity-io/sdk/issues/325)) +* **react:** flatten sdk-react imports ([#319](https://github.com/sanity-io/sdk/issues/319)) +* remove `schema` from sanity config +* remove schema state and schema manager +* remove `useDocuments` and `useSearch` hooks +* allow multiple resources via instances ([#271](https://github.com/sanity-io/sdk/issues/271)) +* renames `org` auth scope to `global` ([#187](https://github.com/sanity-io/sdk/issues/187)) ### Features -- `createStore` prototype ([#46](https://github.com/sanity-io/sdk/issues/46)) ([d3d69f8](https://github.com/sanity-io/sdk/commit/d3d69f8164ed406c77a3586a8a29987fd5aa1b2e)) -- `useProjects`, `useProject`, `useDatasets` ([#235](https://github.com/sanity-io/sdk/issues/235)) ([cc95dfd](https://github.com/sanity-io/sdk/commit/cc95dfd45a82171fa7ccf05a8ca331e8de97fbee)) -- add `useQuery`, `useInfiniteList`, `usePaginatedList` hooks ([1a3f4ad](https://github.com/sanity-io/sdk/commit/1a3f4ad98abf2ab68c552fea20d60639462f3aac)) -- add authorization ([#52](https://github.com/sanity-io/sdk/issues/52)) ([59501f1](https://github.com/sanity-io/sdk/commit/59501f1525e271e8d724c4eb69a27f01726bb64e)) -- add document list store ([#58](https://github.com/sanity-io/sdk/issues/58)) ([b66ea04](https://github.com/sanity-io/sdk/commit/b66ea04a386207704512a4b5cd1c5e77e0a48eb6)) -- add hooks for AuthStore ([#91](https://github.com/sanity-io/sdk/issues/91)) ([4367719](https://github.com/sanity-io/sdk/commit/43677193fccc08fcf7074f906edf2acdfc440e1c)) -- add preview store ([#62](https://github.com/sanity-io/sdk/issues/62)) ([c343f1e](https://github.com/sanity-io/sdk/commit/c343f1e15f30afd66dbd4c0309b9152600ceb1be)) -- add React and Vitest ([#3](https://github.com/sanity-io/sdk/issues/3)) ([e55dc32](https://github.com/sanity-io/sdk/commit/e55dc32f080ffaa7470bdcb2ed97f992cfcbe584)) -- add session hooks and store ([#59](https://github.com/sanity-io/sdk/issues/59)) ([65ac911](https://github.com/sanity-io/sdk/commit/65ac9111d79211aee621f7bfed47bb5cfcf565e1)) -- add storybook and dev affordances ([#6](https://github.com/sanity-io/sdk/issues/6)) ([15b45e8](https://github.com/sanity-io/sdk/commit/15b45e8d7821ec7abc1852998143e19553c06f1e)) -- add turborepo ([#2](https://github.com/sanity-io/sdk/issues/2)) ([19c53e1](https://github.com/sanity-io/sdk/commit/19c53e1408edacbda4105c75c6fa5c4fe0a6b744)) -- add TypeDoc ([#43](https://github.com/sanity-io/sdk/issues/43)) ([2274873](https://github.com/sanity-io/sdk/commit/227487372c1d04799f7c2ed06839dae06113887c)) -- add useClient hook ([#96](https://github.com/sanity-io/sdk/issues/96)) ([c50883b](https://github.com/sanity-io/sdk/commit/c50883bbf3eed32977a1033615582690234154fc)) -- add useDashboardOrganizationId hook ([#339](https://github.com/sanity-io/sdk/issues/339)) ([401468e](https://github.com/sanity-io/sdk/commit/401468e07b8c74deb02d4b7df78af808bddd9242)) -- add useProjection hook ([#257](https://github.com/sanity-io/sdk/issues/257)) ([fbaafe0](https://github.com/sanity-io/sdk/commit/fbaafe031e235f61b9d60bf5938f18a4683aafe5)) -- add useUsers hook ([#239](https://github.com/sanity-io/sdk/issues/239)) ([b89bcf0](https://github.com/sanity-io/sdk/commit/b89bcf00bc4a849409ae80f45b1917cb1e51c66e)) -- add versions information to all packages ([#275](https://github.com/sanity-io/sdk/issues/275)) ([afb2fec](https://github.com/sanity-io/sdk/commit/afb2fec63ea3bae53cab9d8f05081daf2f3c2733)) -- allow multiple resources via instances ([#271](https://github.com/sanity-io/sdk/issues/271)) ([6f4d541](https://github.com/sanity-io/sdk/commit/6f4d5410671e8b75759e33380464656a8c961ad6)) -- **auth:** fetch current user when token is present ([#92](https://github.com/sanity-io/sdk/issues/92)) ([f38008c](https://github.com/sanity-io/sdk/commit/f38008c71d55bb3b54bbf5318045a52a918084c2)) -- **auth:** refresh stamped tokens ([#225](https://github.com/sanity-io/sdk/issues/225)) ([10b2745](https://github.com/sanity-io/sdk/commit/10b2745c62f9169b8cd1c66d7fb641d7fda37429)) -- AuthStore ([#79](https://github.com/sanity-io/sdk/issues/79)) ([f52e68e](https://github.com/sanity-io/sdk/commit/f52e68e43d5552b061415aba6c2758bcd6243c7c)) -- **client:** add a global api client ([#209](https://github.com/sanity-io/sdk/issues/209)) ([5898b1d](https://github.com/sanity-io/sdk/commit/5898b1d82fc07d12f736d1361e48287e41ae0608)) -- **core:** add comlink controller and channel store ([#141](https://github.com/sanity-io/sdk/issues/141)) ([cf1e5d5](https://github.com/sanity-io/sdk/commit/cf1e5d5a8cbcb27beacba2362b462176071200e4)) -- **core:** add comlink node store ([#156](https://github.com/sanity-io/sdk/issues/156)) ([a080357](https://github.com/sanity-io/sdk/commit/a0803574dacbe86455fc60b1b9f3775ea33e7a89)) -- **core:** add README and npm keywords ([#115](https://github.com/sanity-io/sdk/issues/115)) ([8a3c492](https://github.com/sanity-io/sdk/commit/8a3c4928647f6e8c4a8fe3f43da9cb8e904af522)) -- **core:** create client store ([#38](https://github.com/sanity-io/sdk/issues/38)) ([8545333](https://github.com/sanity-io/sdk/commit/8545333c02c5691674e90be19951458ab3abbd6a)) -- **core:** update client store to subscribe to changes in auth ([#85](https://github.com/sanity-io/sdk/issues/85)) ([a42d58d](https://github.com/sanity-io/sdk/commit/a42d58d3227e7d884a5449192f176e66bf404144)) -- **core:** use separate client for auth and refresh client store with token ([#64](https://github.com/sanity-io/sdk/issues/64)) ([9d18fbf](https://github.com/sanity-io/sdk/commit/9d18fbfd2fc2708e0f9505617343720c5d7fafb0)) -- create sanity instance and store map ([#40](https://github.com/sanity-io/sdk/issues/40)) ([a7bf3e1](https://github.com/sanity-io/sdk/commit/a7bf3e12ea0f36ee63e42b4ba9088a9413b0742b)) -- **document hooks:** update the documentation for the Document hook s an optional resourceId ([#280](https://github.com/sanity-io/sdk/issues/280)) ([eb65378](https://github.com/sanity-io/sdk/commit/eb65378c884f3aaf9b2c0dbc95dd86075c76f9e0)) -- document permissions ([#226](https://github.com/sanity-io/sdk/issues/226)) ([107f434](https://github.com/sanity-io/sdk/commit/107f4349d7defab04d1282ee1ab20766d157eab7)) -- document store ([#197](https://github.com/sanity-io/sdk/issues/197)) ([497bb26](https://github.com/sanity-io/sdk/commit/497bb2641d5766128dfca4db8247f2f9555b83b1)) -- export the SanityDocument type ([#221](https://github.com/sanity-io/sdk/issues/221)) ([dc6dbc8](https://github.com/sanity-io/sdk/commit/dc6dbc85fe6d80c6e3b08de76e666da340aa62f6)) -- introduce consistent Handle pattern (`ProjectHandle`, `DatasetHandle`, `DocumentHandle`) across the SDK ([969d70e](https://github.com/sanity-io/sdk/commit/969d70e41f6987234323f99753f5cf937469532b)) -- **kitchen-sink:** add routing to kitchen-sink ([#99](https://github.com/sanity-io/sdk/issues/99)) ([50483ea](https://github.com/sanity-io/sdk/commit/50483ea66073bfccdc28e51f7606673eb213bebe)) -- make packages public ([#320](https://github.com/sanity-io/sdk/issues/320)) ([8c94c29](https://github.com/sanity-io/sdk/commit/8c94c29b0aadd86273db59da1b0577aad682d6e9)) -- **react:** add AuthBoundary ([#102](https://github.com/sanity-io/sdk/issues/102)) ([bd657a0](https://github.com/sanity-io/sdk/commit/bd657a058c4ae0989018503fe2fafa319fcdbc7d)) -- **react:** add react compiler to the build process ([#298](https://github.com/sanity-io/sdk/issues/298)) ([bfb74eb](https://github.com/sanity-io/sdk/commit/bfb74ebe538b1218a980b03493890b70dc1311d2)) -- **react:** add useDocuments hook ([#98](https://github.com/sanity-io/sdk/issues/98)) ([d0f0c1a](https://github.com/sanity-io/sdk/commit/d0f0c1ad753b56b7e7cc6ff0830682d4fc6be0d1)) -- **react:** flatten sdk-react imports ([#319](https://github.com/sanity-io/sdk/issues/319)) ([3922025](https://github.com/sanity-io/sdk/commit/3922025569abfa4cd824e81222495913875246d7)) -- refactor to internal auth store ([#95](https://github.com/sanity-io/sdk/issues/95)) ([5807a2b](https://github.com/sanity-io/sdk/commit/5807a2b0b823f9187c25ab82233ad6d30df664f1)) -- remove ``, introduce `` for configuration ([969d70e](https://github.com/sanity-io/sdk/commit/969d70e41f6987234323f99753f5cf937469532b)) -- remove `schema` from sanity config ([6257fe3](https://github.com/sanity-io/sdk/commit/6257fe39b4521ace71db54f1d0d173a6019db38d)) -- remove `useDocuments` and `useSearch` hooks ([9f37daf](https://github.com/sanity-io/sdk/commit/9f37daf1243ee0fda558ffd7259c45da9e4ba259)) -- remove schema state and schema manager ([6257fe3](https://github.com/sanity-io/sdk/commit/6257fe39b4521ace71db54f1d0d173a6019db38d)) -- rename `_id` to `documentId` in DocumentHandle interface and related usages ([969d70e](https://github.com/sanity-io/sdk/commit/969d70e41f6987234323f99753f5cf937469532b)) -- rename `_type` to `documentType` in DocumentHandle interface and related usages ([969d70e](https://github.com/sanity-io/sdk/commit/969d70e41f6987234323f99753f5cf937469532b)) -- rename `result` to `data` for usePreview hook ([#325](https://github.com/sanity-io/sdk/issues/325)) ([1e5813e](https://github.com/sanity-io/sdk/commit/1e5813e2e26a72c463cafa8c5502043176930a5b)) -- rename `results` to `data` for useProjection hook ([#335](https://github.com/sanity-io/sdk/issues/335)) ([026dd26](https://github.com/sanity-io/sdk/commit/026dd26bffb9fc2a03801ef05a8d075a2968c725)) -- rename useActions → useDocumentActions and useActions → useDocumentActions ([#362](https://github.com/sanity-io/sdk/issues/362)) ([c753897](https://github.com/sanity-io/sdk/commit/c75389759a57c6da5ad306dbac46c6d58b4f8dda)) -- rename usePermissions → useDocumentPermissions ([#365](https://github.com/sanity-io/sdk/issues/365)) ([6ca2ada](https://github.com/sanity-io/sdk/commit/6ca2ada0b0d9a0633d46ccf8c0170c1712a3afb4)) -- replace `resourceId` concept with explicit `projectId` and `dataset` fields in handles ([969d70e](https://github.com/sanity-io/sdk/commit/969d70e41f6987234323f99753f5cf937469532b)) -- replace `sanityConfigs` prop with `config` prop in `` and `` ([969d70e](https://github.com/sanity-io/sdk/commit/969d70e41f6987234323f99753f5cf937469532b)) -- replace jsdoc with tsdoc ([#75](https://github.com/sanity-io/sdk/issues/75)) ([7074a38](https://github.com/sanity-io/sdk/commit/7074a383b58de66fe2a9badc7122d0345e354b2a)) -- resolve preview projections ([#130](https://github.com/sanity-io/sdk/issues/130)) ([d30997e](https://github.com/sanity-io/sdk/commit/d30997e4a3d40c0edd1b3f31f48934bf846ab56a)) -- store Dashboard context ([#307](https://github.com/sanity-io/sdk/issues/307)) ([a6c454e](https://github.com/sanity-io/sdk/commit/a6c454e33acea6d33d004751615b226bd60c49b3)) -- update document hooks and actions to expect `DocumentHandle` props ([969d70e](https://github.com/sanity-io/sdk/commit/969d70e41f6987234323f99753f5cf937469532b)) -- update project and dataset hooks to use `ProjectHandle` or `DatasetHandle` ([969d70e](https://github.com/sanity-io/sdk/commit/969d70e41f6987234323f99753f5cf937469532b)) -- update query and list hooks to accept optional `DatasetHandle` for configuration ([969d70e](https://github.com/sanity-io/sdk/commit/969d70e41f6987234323f99753f5cf937469532b)) -- use hosted login for standalone apps ([#386](https://github.com/sanity-io/sdk/issues/386)) ([9c1ad58](https://github.com/sanity-io/sdk/commit/9c1ad58bc0b302073c90dd6e584f566eba3d0d17)) -- use projection for previews and remove schema usage ([6257fe3](https://github.com/sanity-io/sdk/commit/6257fe39b4521ace71db54f1d0d173a6019db38d)) +* `createStore` prototype ([#46](https://github.com/sanity-io/sdk/issues/46)) ([d3d69f8](https://github.com/sanity-io/sdk/commit/d3d69f8164ed406c77a3586a8a29987fd5aa1b2e)) +* `useProjects`, `useProject`, `useDatasets` ([#235](https://github.com/sanity-io/sdk/issues/235)) ([cc95dfd](https://github.com/sanity-io/sdk/commit/cc95dfd45a82171fa7ccf05a8ca331e8de97fbee)) +* add `useQuery`, `useInfiniteList`, `usePaginatedList` hooks ([1a3f4ad](https://github.com/sanity-io/sdk/commit/1a3f4ad98abf2ab68c552fea20d60639462f3aac)) +* add authorization ([#52](https://github.com/sanity-io/sdk/issues/52)) ([59501f1](https://github.com/sanity-io/sdk/commit/59501f1525e271e8d724c4eb69a27f01726bb64e)) +* add document list store ([#58](https://github.com/sanity-io/sdk/issues/58)) ([b66ea04](https://github.com/sanity-io/sdk/commit/b66ea04a386207704512a4b5cd1c5e77e0a48eb6)) +* add hooks for AuthStore ([#91](https://github.com/sanity-io/sdk/issues/91)) ([4367719](https://github.com/sanity-io/sdk/commit/43677193fccc08fcf7074f906edf2acdfc440e1c)) +* add preview store ([#62](https://github.com/sanity-io/sdk/issues/62)) ([c343f1e](https://github.com/sanity-io/sdk/commit/c343f1e15f30afd66dbd4c0309b9152600ceb1be)) +* add React and Vitest ([#3](https://github.com/sanity-io/sdk/issues/3)) ([e55dc32](https://github.com/sanity-io/sdk/commit/e55dc32f080ffaa7470bdcb2ed97f992cfcbe584)) +* add session hooks and store ([#59](https://github.com/sanity-io/sdk/issues/59)) ([65ac911](https://github.com/sanity-io/sdk/commit/65ac9111d79211aee621f7bfed47bb5cfcf565e1)) +* add storybook and dev affordances ([#6](https://github.com/sanity-io/sdk/issues/6)) ([15b45e8](https://github.com/sanity-io/sdk/commit/15b45e8d7821ec7abc1852998143e19553c06f1e)) +* add turborepo ([#2](https://github.com/sanity-io/sdk/issues/2)) ([19c53e1](https://github.com/sanity-io/sdk/commit/19c53e1408edacbda4105c75c6fa5c4fe0a6b744)) +* add TypeDoc ([#43](https://github.com/sanity-io/sdk/issues/43)) ([2274873](https://github.com/sanity-io/sdk/commit/227487372c1d04799f7c2ed06839dae06113887c)) +* add useClient hook ([#96](https://github.com/sanity-io/sdk/issues/96)) ([c50883b](https://github.com/sanity-io/sdk/commit/c50883bbf3eed32977a1033615582690234154fc)) +* add useDashboardOrganizationId hook ([#339](https://github.com/sanity-io/sdk/issues/339)) ([401468e](https://github.com/sanity-io/sdk/commit/401468e07b8c74deb02d4b7df78af808bddd9242)) +* add useProjection hook ([#257](https://github.com/sanity-io/sdk/issues/257)) ([fbaafe0](https://github.com/sanity-io/sdk/commit/fbaafe031e235f61b9d60bf5938f18a4683aafe5)) +* add useUsers hook ([#239](https://github.com/sanity-io/sdk/issues/239)) ([b89bcf0](https://github.com/sanity-io/sdk/commit/b89bcf00bc4a849409ae80f45b1917cb1e51c66e)) +* add versions information to all packages ([#275](https://github.com/sanity-io/sdk/issues/275)) ([afb2fec](https://github.com/sanity-io/sdk/commit/afb2fec63ea3bae53cab9d8f05081daf2f3c2733)) +* allow multiple resources via instances ([#271](https://github.com/sanity-io/sdk/issues/271)) ([6f4d541](https://github.com/sanity-io/sdk/commit/6f4d5410671e8b75759e33380464656a8c961ad6)) +* **auth:** fetch current user when token is present ([#92](https://github.com/sanity-io/sdk/issues/92)) ([f38008c](https://github.com/sanity-io/sdk/commit/f38008c71d55bb3b54bbf5318045a52a918084c2)) +* **auth:** refresh stamped tokens ([#225](https://github.com/sanity-io/sdk/issues/225)) ([10b2745](https://github.com/sanity-io/sdk/commit/10b2745c62f9169b8cd1c66d7fb641d7fda37429)) +* AuthStore ([#79](https://github.com/sanity-io/sdk/issues/79)) ([f52e68e](https://github.com/sanity-io/sdk/commit/f52e68e43d5552b061415aba6c2758bcd6243c7c)) +* **client:** add a global api client ([#209](https://github.com/sanity-io/sdk/issues/209)) ([5898b1d](https://github.com/sanity-io/sdk/commit/5898b1d82fc07d12f736d1361e48287e41ae0608)) +* **core:** add comlink controller and channel store ([#141](https://github.com/sanity-io/sdk/issues/141)) ([cf1e5d5](https://github.com/sanity-io/sdk/commit/cf1e5d5a8cbcb27beacba2362b462176071200e4)) +* **core:** add comlink node store ([#156](https://github.com/sanity-io/sdk/issues/156)) ([a080357](https://github.com/sanity-io/sdk/commit/a0803574dacbe86455fc60b1b9f3775ea33e7a89)) +* **core:** add README and npm keywords ([#115](https://github.com/sanity-io/sdk/issues/115)) ([8a3c492](https://github.com/sanity-io/sdk/commit/8a3c4928647f6e8c4a8fe3f43da9cb8e904af522)) +* **core:** create client store ([#38](https://github.com/sanity-io/sdk/issues/38)) ([8545333](https://github.com/sanity-io/sdk/commit/8545333c02c5691674e90be19951458ab3abbd6a)) +* **core:** update client store to subscribe to changes in auth ([#85](https://github.com/sanity-io/sdk/issues/85)) ([a42d58d](https://github.com/sanity-io/sdk/commit/a42d58d3227e7d884a5449192f176e66bf404144)) +* **core:** use separate client for auth and refresh client store with token ([#64](https://github.com/sanity-io/sdk/issues/64)) ([9d18fbf](https://github.com/sanity-io/sdk/commit/9d18fbfd2fc2708e0f9505617343720c5d7fafb0)) +* create sanity instance and store map ([#40](https://github.com/sanity-io/sdk/issues/40)) ([a7bf3e1](https://github.com/sanity-io/sdk/commit/a7bf3e12ea0f36ee63e42b4ba9088a9413b0742b)) +* **document hooks:** update the documentation for the Document hook s an optional resourceId ([#280](https://github.com/sanity-io/sdk/issues/280)) ([eb65378](https://github.com/sanity-io/sdk/commit/eb65378c884f3aaf9b2c0dbc95dd86075c76f9e0)) +* document permissions ([#226](https://github.com/sanity-io/sdk/issues/226)) ([107f434](https://github.com/sanity-io/sdk/commit/107f4349d7defab04d1282ee1ab20766d157eab7)) +* document store ([#197](https://github.com/sanity-io/sdk/issues/197)) ([497bb26](https://github.com/sanity-io/sdk/commit/497bb2641d5766128dfca4db8247f2f9555b83b1)) +* export the SanityDocument type ([#221](https://github.com/sanity-io/sdk/issues/221)) ([dc6dbc8](https://github.com/sanity-io/sdk/commit/dc6dbc85fe6d80c6e3b08de76e666da340aa62f6)) +* introduce consistent Handle pattern (`ProjectHandle`, `DatasetHandle`, `DocumentHandle`) across the SDK ([969d70e](https://github.com/sanity-io/sdk/commit/969d70e41f6987234323f99753f5cf937469532b)) +* **kitchen-sink:** add routing to kitchen-sink ([#99](https://github.com/sanity-io/sdk/issues/99)) ([50483ea](https://github.com/sanity-io/sdk/commit/50483ea66073bfccdc28e51f7606673eb213bebe)) +* make packages public ([#320](https://github.com/sanity-io/sdk/issues/320)) ([8c94c29](https://github.com/sanity-io/sdk/commit/8c94c29b0aadd86273db59da1b0577aad682d6e9)) +* **react:** add AuthBoundary ([#102](https://github.com/sanity-io/sdk/issues/102)) ([bd657a0](https://github.com/sanity-io/sdk/commit/bd657a058c4ae0989018503fe2fafa319fcdbc7d)) +* **react:** add react compiler to the build process ([#298](https://github.com/sanity-io/sdk/issues/298)) ([bfb74eb](https://github.com/sanity-io/sdk/commit/bfb74ebe538b1218a980b03493890b70dc1311d2)) +* **react:** add useDocuments hook ([#98](https://github.com/sanity-io/sdk/issues/98)) ([d0f0c1a](https://github.com/sanity-io/sdk/commit/d0f0c1ad753b56b7e7cc6ff0830682d4fc6be0d1)) +* **react:** flatten sdk-react imports ([#319](https://github.com/sanity-io/sdk/issues/319)) ([3922025](https://github.com/sanity-io/sdk/commit/3922025569abfa4cd824e81222495913875246d7)) +* refactor to internal auth store ([#95](https://github.com/sanity-io/sdk/issues/95)) ([5807a2b](https://github.com/sanity-io/sdk/commit/5807a2b0b823f9187c25ab82233ad6d30df664f1)) +* remove ``, introduce `` for configuration ([969d70e](https://github.com/sanity-io/sdk/commit/969d70e41f6987234323f99753f5cf937469532b)) +* remove `schema` from sanity config ([6257fe3](https://github.com/sanity-io/sdk/commit/6257fe39b4521ace71db54f1d0d173a6019db38d)) +* remove `useDocuments` and `useSearch` hooks ([9f37daf](https://github.com/sanity-io/sdk/commit/9f37daf1243ee0fda558ffd7259c45da9e4ba259)) +* remove schema state and schema manager ([6257fe3](https://github.com/sanity-io/sdk/commit/6257fe39b4521ace71db54f1d0d173a6019db38d)) +* rename `_id` to `documentId` in DocumentHandle interface and related usages ([969d70e](https://github.com/sanity-io/sdk/commit/969d70e41f6987234323f99753f5cf937469532b)) +* rename `_type` to `documentType` in DocumentHandle interface and related usages ([969d70e](https://github.com/sanity-io/sdk/commit/969d70e41f6987234323f99753f5cf937469532b)) +* rename `result` to `data` for usePreview hook ([#325](https://github.com/sanity-io/sdk/issues/325)) ([1e5813e](https://github.com/sanity-io/sdk/commit/1e5813e2e26a72c463cafa8c5502043176930a5b)) +* rename `results` to `data` for useProjection hook ([#335](https://github.com/sanity-io/sdk/issues/335)) ([026dd26](https://github.com/sanity-io/sdk/commit/026dd26bffb9fc2a03801ef05a8d075a2968c725)) +* rename useActions → useDocumentActions and useActions → useDocumentActions ([#362](https://github.com/sanity-io/sdk/issues/362)) ([c753897](https://github.com/sanity-io/sdk/commit/c75389759a57c6da5ad306dbac46c6d58b4f8dda)) +* rename usePermissions → useDocumentPermissions ([#365](https://github.com/sanity-io/sdk/issues/365)) ([6ca2ada](https://github.com/sanity-io/sdk/commit/6ca2ada0b0d9a0633d46ccf8c0170c1712a3afb4)) +* replace `resourceId` concept with explicit `projectId` and `dataset` fields in handles ([969d70e](https://github.com/sanity-io/sdk/commit/969d70e41f6987234323f99753f5cf937469532b)) +* replace `sanityConfigs` prop with `config` prop in `` and `` ([969d70e](https://github.com/sanity-io/sdk/commit/969d70e41f6987234323f99753f5cf937469532b)) +* replace jsdoc with tsdoc ([#75](https://github.com/sanity-io/sdk/issues/75)) ([7074a38](https://github.com/sanity-io/sdk/commit/7074a383b58de66fe2a9badc7122d0345e354b2a)) +* resolve preview projections ([#130](https://github.com/sanity-io/sdk/issues/130)) ([d30997e](https://github.com/sanity-io/sdk/commit/d30997e4a3d40c0edd1b3f31f48934bf846ab56a)) +* store Dashboard context ([#307](https://github.com/sanity-io/sdk/issues/307)) ([a6c454e](https://github.com/sanity-io/sdk/commit/a6c454e33acea6d33d004751615b226bd60c49b3)) +* update document hooks and actions to expect `DocumentHandle` props ([969d70e](https://github.com/sanity-io/sdk/commit/969d70e41f6987234323f99753f5cf937469532b)) +* update project and dataset hooks to use `ProjectHandle` or `DatasetHandle` ([969d70e](https://github.com/sanity-io/sdk/commit/969d70e41f6987234323f99753f5cf937469532b)) +* update query and list hooks to accept optional `DatasetHandle` for configuration ([969d70e](https://github.com/sanity-io/sdk/commit/969d70e41f6987234323f99753f5cf937469532b)) +* use hosted login for standalone apps ([#386](https://github.com/sanity-io/sdk/issues/386)) ([9c1ad58](https://github.com/sanity-io/sdk/commit/9c1ad58bc0b302073c90dd6e584f566eba3d0d17)) +* use projection for previews and remove schema usage ([6257fe3](https://github.com/sanity-io/sdk/commit/6257fe39b4521ace71db54f1d0d173a6019db38d)) + ### Bug Fixes -- add access api types inside the SDK ([#261](https://github.com/sanity-io/sdk/issues/261)) ([ff53123](https://github.com/sanity-io/sdk/commit/ff53123f2e01a242c22df22b9dc109d2cbc3b1d4)) -- add lint to turbo.json and run prettier ([909f0d3](https://github.com/sanity-io/sdk/commit/909f0d34339c9c8ff8c013dfa13e5d607a2012fc)) -- all client requests are properly tagged ([#274](https://github.com/sanity-io/sdk/issues/274)) ([6df8938](https://github.com/sanity-io/sdk/commit/6df893891e7b12eff122de5147ab03b65b51bcbe)) -- **auth:** ensure that authStore is a true shared resource store ([#371](https://github.com/sanity-io/sdk/issues/371)) ([1709d95](https://github.com/sanity-io/sdk/commit/1709d95dd62082b5e46ae909e2531448ff979074)) -- **auth:** only attempt to refresh stamped tokens ([#304](https://github.com/sanity-io/sdk/issues/304)) ([b08a319](https://github.com/sanity-io/sdk/commit/b08a3194a061031400e2ded654269adf71130ea5)) -- **build:** fixes build warning ([#252](https://github.com/sanity-io/sdk/issues/252)) ([bed82f8](https://github.com/sanity-io/sdk/commit/bed82f8d87521dd0cc9d827af5a7f908749ad711)) -- **comlink:** expose statuses and destroy unused resources ([#233](https://github.com/sanity-io/sdk/issues/233)) ([8b8a40c](https://github.com/sanity-io/sdk/commit/8b8a40c5ac0b5ba76cda043ffc9bc3b740bce5bd)) -- **core:** add correct perspective to useProjection ([#295](https://github.com/sanity-io/sdk/issues/295)) ([8792e00](https://github.com/sanity-io/sdk/commit/8792e00db7f5f5926e5c311e5cf0bf74bc78f041)) -- **core:** add raw perspective to client ([#237](https://github.com/sanity-io/sdk/issues/237)) ([202c4ba](https://github.com/sanity-io/sdk/commit/202c4ba7bb9fdbc7f635ac8691ba840717cafc69)) -- **core:** determine env for version ([#293](https://github.com/sanity-io/sdk/issues/293)) ([643eac4](https://github.com/sanity-io/sdk/commit/643eac4c69c117c7b08866afb1f92b32010c9a83)) -- **core:** emit current token state on subscribe ([#139](https://github.com/sanity-io/sdk/issues/139)) ([7ec0d98](https://github.com/sanity-io/sdk/commit/7ec0d984f2c7f2da519206165cb7a2c1e2213c79)) -- **core:** fixes apiVersion in usersStore ([#262](https://github.com/sanity-io/sdk/issues/262)) ([248eb19](https://github.com/sanity-io/sdk/commit/248eb192dc331ce64c05721172f2855a44dad0ca)) -- **core:** use drafts instead of previewDrafts ([#279](https://github.com/sanity-io/sdk/issues/279)) ([45305ad](https://github.com/sanity-io/sdk/commit/45305ad0ecc72d60ca1ccba15703bb8a0a6a53f5)) -- correct auth state subscription ([#101](https://github.com/sanity-io/sdk/issues/101)) ([9ba03d0](https://github.com/sanity-io/sdk/commit/9ba03d03f00df6d6aac29036cdca6a880fb3c52d)) -- **deps:** update dependency @sanity/client to ^6.28.3 ([#287](https://github.com/sanity-io/sdk/issues/287)) ([fc5c5a1](https://github.com/sanity-io/sdk/commit/fc5c5a1fd54bca5b7b7138e4cab49113449eebe2)) -- **deps:** update dependency @sanity/comlink to v3 ([#296](https://github.com/sanity-io/sdk/issues/296)) ([14fbe1b](https://github.com/sanity-io/sdk/commit/14fbe1b89a79d2532e8735a58abbe4a5cff6d635)) -- **deps:** update dependency @sanity/mutate to ^0.12.4 ([#395](https://github.com/sanity-io/sdk/issues/395)) ([6cbb54a](https://github.com/sanity-io/sdk/commit/6cbb54a343b81fb0da0bd4852b1bdf36ae29de42)) -- **deps:** Update eslint-tooling ([#69](https://github.com/sanity-io/sdk/issues/69)) ([d9d8e09](https://github.com/sanity-io/sdk/commit/d9d8e099e4711bb6ae90e926ce804715f56ef5d3)) -- **deps:** update pkg-utils to v7 ([#384](https://github.com/sanity-io/sdk/issues/384)) ([ce9a952](https://github.com/sanity-io/sdk/commit/ce9a952a295a32ec86c12cbf9b967128ba5eaf4f)) -- **deps:** Update sanity monorepo to ^3.78.1 ([#297](https://github.com/sanity-io/sdk/issues/297)) ([835b594](https://github.com/sanity-io/sdk/commit/835b5942d3870a92e0fd1387ab9baa5e555a3ee5)) -- **deps:** upgrade `@sanity/client`, do not use `withCredentials` ([#368](https://github.com/sanity-io/sdk/issues/368)) ([8e1cbd9](https://github.com/sanity-io/sdk/commit/8e1cbd92501892bf116c3a3473ae693062518f89)) -- environment variable access for Remix ([#168](https://github.com/sanity-io/sdk/issues/168)) ([4ad3587](https://github.com/sanity-io/sdk/commit/4ad3587fd0ea262b09c3add20c2ba2bd8d5d15c2)) -- fix typedoc annotations for hooks ([#361](https://github.com/sanity-io/sdk/issues/361)) ([778a63a](https://github.com/sanity-io/sdk/commit/778a63ac5cb52ed6c1e28b1ff22605caad54db33)) -- initialize client with configured apiHost ([#186](https://github.com/sanity-io/sdk/issues/186)) ([13c72cb](https://github.com/sanity-io/sdk/commit/13c72cbb0dc9aa2fe1b4c0384f1cf28eb7f40d2e)) -- make apiVersion required in getClient ([#230](https://github.com/sanity-io/sdk/issues/230)) ([91458d3](https://github.com/sanity-io/sdk/commit/91458d35251be6cf02592f0d4391f58838921ff8)) -- mark packages as private for now ([#11](https://github.com/sanity-io/sdk/issues/11)) ([a103825](https://github.com/sanity-io/sdk/commit/a1038257192e2c493132b96233d461bdd9a31744)) -- package access and version ([#89](https://github.com/sanity-io/sdk/issues/89)) ([c4eb26d](https://github.com/sanity-io/sdk/commit/c4eb26dac12ec56c5a569c8edc895ffcd46a63a7)) -- trigger release ([#210](https://github.com/sanity-io/sdk/issues/210)) ([2b36c98](https://github.com/sanity-io/sdk/commit/2b36c985a91d44be95a9e6c8446e9a11ffa59d61)) -- update typedoc to use package mode ([#117](https://github.com/sanity-io/sdk/issues/117)) ([7f4e0e1](https://github.com/sanity-io/sdk/commit/7f4e0e1f08610fb3861e5dc8eb67fb1556b4d965)) +* add access api types inside the SDK ([#261](https://github.com/sanity-io/sdk/issues/261)) ([ff53123](https://github.com/sanity-io/sdk/commit/ff53123f2e01a242c22df22b9dc109d2cbc3b1d4)) +* add lint to turbo.json and run prettier ([909f0d3](https://github.com/sanity-io/sdk/commit/909f0d34339c9c8ff8c013dfa13e5d607a2012fc)) +* all client requests are properly tagged ([#274](https://github.com/sanity-io/sdk/issues/274)) ([6df8938](https://github.com/sanity-io/sdk/commit/6df893891e7b12eff122de5147ab03b65b51bcbe)) +* **auth:** ensure that authStore is a true shared resource store ([#371](https://github.com/sanity-io/sdk/issues/371)) ([1709d95](https://github.com/sanity-io/sdk/commit/1709d95dd62082b5e46ae909e2531448ff979074)) +* **auth:** only attempt to refresh stamped tokens ([#304](https://github.com/sanity-io/sdk/issues/304)) ([b08a319](https://github.com/sanity-io/sdk/commit/b08a3194a061031400e2ded654269adf71130ea5)) +* **build:** fixes build warning ([#252](https://github.com/sanity-io/sdk/issues/252)) ([bed82f8](https://github.com/sanity-io/sdk/commit/bed82f8d87521dd0cc9d827af5a7f908749ad711)) +* **comlink:** expose statuses and destroy unused resources ([#233](https://github.com/sanity-io/sdk/issues/233)) ([8b8a40c](https://github.com/sanity-io/sdk/commit/8b8a40c5ac0b5ba76cda043ffc9bc3b740bce5bd)) +* **core:** add correct perspective to useProjection ([#295](https://github.com/sanity-io/sdk/issues/295)) ([8792e00](https://github.com/sanity-io/sdk/commit/8792e00db7f5f5926e5c311e5cf0bf74bc78f041)) +* **core:** add raw perspective to client ([#237](https://github.com/sanity-io/sdk/issues/237)) ([202c4ba](https://github.com/sanity-io/sdk/commit/202c4ba7bb9fdbc7f635ac8691ba840717cafc69)) +* **core:** determine env for version ([#293](https://github.com/sanity-io/sdk/issues/293)) ([643eac4](https://github.com/sanity-io/sdk/commit/643eac4c69c117c7b08866afb1f92b32010c9a83)) +* **core:** emit current token state on subscribe ([#139](https://github.com/sanity-io/sdk/issues/139)) ([7ec0d98](https://github.com/sanity-io/sdk/commit/7ec0d984f2c7f2da519206165cb7a2c1e2213c79)) +* **core:** fixes apiVersion in usersStore ([#262](https://github.com/sanity-io/sdk/issues/262)) ([248eb19](https://github.com/sanity-io/sdk/commit/248eb192dc331ce64c05721172f2855a44dad0ca)) +* **core:** use drafts instead of previewDrafts ([#279](https://github.com/sanity-io/sdk/issues/279)) ([45305ad](https://github.com/sanity-io/sdk/commit/45305ad0ecc72d60ca1ccba15703bb8a0a6a53f5)) +* correct auth state subscription ([#101](https://github.com/sanity-io/sdk/issues/101)) ([9ba03d0](https://github.com/sanity-io/sdk/commit/9ba03d03f00df6d6aac29036cdca6a880fb3c52d)) +* **deps:** update dependency @sanity/client to ^6.28.3 ([#287](https://github.com/sanity-io/sdk/issues/287)) ([fc5c5a1](https://github.com/sanity-io/sdk/commit/fc5c5a1fd54bca5b7b7138e4cab49113449eebe2)) +* **deps:** update dependency @sanity/comlink to v3 ([#296](https://github.com/sanity-io/sdk/issues/296)) ([14fbe1b](https://github.com/sanity-io/sdk/commit/14fbe1b89a79d2532e8735a58abbe4a5cff6d635)) +* **deps:** update dependency @sanity/mutate to ^0.12.4 ([#395](https://github.com/sanity-io/sdk/issues/395)) ([6cbb54a](https://github.com/sanity-io/sdk/commit/6cbb54a343b81fb0da0bd4852b1bdf36ae29de42)) +* **deps:** Update eslint-tooling ([#69](https://github.com/sanity-io/sdk/issues/69)) ([d9d8e09](https://github.com/sanity-io/sdk/commit/d9d8e099e4711bb6ae90e926ce804715f56ef5d3)) +* **deps:** update pkg-utils to v7 ([#384](https://github.com/sanity-io/sdk/issues/384)) ([ce9a952](https://github.com/sanity-io/sdk/commit/ce9a952a295a32ec86c12cbf9b967128ba5eaf4f)) +* **deps:** Update sanity monorepo to ^3.78.1 ([#297](https://github.com/sanity-io/sdk/issues/297)) ([835b594](https://github.com/sanity-io/sdk/commit/835b5942d3870a92e0fd1387ab9baa5e555a3ee5)) +* **deps:** upgrade `@sanity/client`, do not use `withCredentials` ([#368](https://github.com/sanity-io/sdk/issues/368)) ([8e1cbd9](https://github.com/sanity-io/sdk/commit/8e1cbd92501892bf116c3a3473ae693062518f89)) +* environment variable access for Remix ([#168](https://github.com/sanity-io/sdk/issues/168)) ([4ad3587](https://github.com/sanity-io/sdk/commit/4ad3587fd0ea262b09c3add20c2ba2bd8d5d15c2)) +* fix typedoc annotations for hooks ([#361](https://github.com/sanity-io/sdk/issues/361)) ([778a63a](https://github.com/sanity-io/sdk/commit/778a63ac5cb52ed6c1e28b1ff22605caad54db33)) +* initialize client with configured apiHost ([#186](https://github.com/sanity-io/sdk/issues/186)) ([13c72cb](https://github.com/sanity-io/sdk/commit/13c72cbb0dc9aa2fe1b4c0384f1cf28eb7f40d2e)) +* make apiVersion required in getClient ([#230](https://github.com/sanity-io/sdk/issues/230)) ([91458d3](https://github.com/sanity-io/sdk/commit/91458d35251be6cf02592f0d4391f58838921ff8)) +* mark packages as private for now ([#11](https://github.com/sanity-io/sdk/issues/11)) ([a103825](https://github.com/sanity-io/sdk/commit/a1038257192e2c493132b96233d461bdd9a31744)) +* package access and version ([#89](https://github.com/sanity-io/sdk/issues/89)) ([c4eb26d](https://github.com/sanity-io/sdk/commit/c4eb26dac12ec56c5a569c8edc895ffcd46a63a7)) +* trigger release ([#210](https://github.com/sanity-io/sdk/issues/210)) ([2b36c98](https://github.com/sanity-io/sdk/commit/2b36c985a91d44be95a9e6c8446e9a11ffa59d61)) +* update typedoc to use package mode ([#117](https://github.com/sanity-io/sdk/issues/117)) ([7f4e0e1](https://github.com/sanity-io/sdk/commit/7f4e0e1f08610fb3861e5dc8eb67fb1556b4d965)) + ### Miscellaneous Chores -- renames `org` auth scope to `global` ([#187](https://github.com/sanity-io/sdk/issues/187)) ([3220d57](https://github.com/sanity-io/sdk/commit/3220d5729c8012ffc47bfa2d75bfca1f2642df76)) +* renames `org` auth scope to `global` ([#187](https://github.com/sanity-io/sdk/issues/187)) ([3220d57](https://github.com/sanity-io/sdk/commit/3220d5729c8012ffc47bfa2d75bfca1f2642df76)) + ### Code Refactoring -- rename useHandleCallback → useHandleAuthCallback and HandleCallback → HandleAuthCallback ([#358](https://github.com/sanity-io/sdk/issues/358)) ([014dc69](https://github.com/sanity-io/sdk/commit/014dc695320273b4e166d946753e851c9701d159)) +* rename useHandleCallback → useHandleAuthCallback and HandleCallback → HandleAuthCallback ([#358](https://github.com/sanity-io/sdk/issues/358)) ([014dc69](https://github.com/sanity-io/sdk/commit/014dc695320273b4e166d946753e851c9701d159)) ## [0.0.0-alpha.23](https://github.com/sanity-io/sdk/compare/sdk-v0.0.0-alpha.22...sdk-v0.0.0-alpha.23) (2025-04-03) + ### ⚠ BREAKING CHANGES -- use hosted login for standalone apps ([#386](https://github.com/sanity-io/sdk/issues/386)) -- replace `sanityConfigs` prop with `config` prop in `` and `` -- replace `resourceId` concept with explicit `projectId` and `dataset` fields in handles -- rename `_type` to `documentType` in DocumentHandle interface and related usages -- rename `_id` to `documentId` in DocumentHandle interface and related usages -- update document hooks and actions to expect `DocumentHandle` props -- update project and dataset hooks to use `ProjectHandle` or `DatasetHandle` -- remove ``, introduce `` for configuration +* use hosted login for standalone apps ([#386](https://github.com/sanity-io/sdk/issues/386)) +* replace `sanityConfigs` prop with `config` prop in `` and `` +* replace `resourceId` concept with explicit `projectId` and `dataset` fields in handles +* rename `_type` to `documentType` in DocumentHandle interface and related usages +* rename `_id` to `documentId` in DocumentHandle interface and related usages +* update document hooks and actions to expect `DocumentHandle` props +* update project and dataset hooks to use `ProjectHandle` or `DatasetHandle` +* remove ``, introduce `` for configuration ### Features -- introduce consistent Handle pattern (`ProjectHandle`, `DatasetHandle`, `DocumentHandle`) across the SDK ([969d70e](https://github.com/sanity-io/sdk/commit/969d70e41f6987234323f99753f5cf937469532b)) -- remove ``, introduce `` for configuration ([969d70e](https://github.com/sanity-io/sdk/commit/969d70e41f6987234323f99753f5cf937469532b)) -- rename `_id` to `documentId` in DocumentHandle interface and related usages ([969d70e](https://github.com/sanity-io/sdk/commit/969d70e41f6987234323f99753f5cf937469532b)) -- rename `_type` to `documentType` in DocumentHandle interface and related usages ([969d70e](https://github.com/sanity-io/sdk/commit/969d70e41f6987234323f99753f5cf937469532b)) -- replace `resourceId` concept with explicit `projectId` and `dataset` fields in handles ([969d70e](https://github.com/sanity-io/sdk/commit/969d70e41f6987234323f99753f5cf937469532b)) -- replace `sanityConfigs` prop with `config` prop in `` and `` ([969d70e](https://github.com/sanity-io/sdk/commit/969d70e41f6987234323f99753f5cf937469532b)) -- update document hooks and actions to expect `DocumentHandle` props ([969d70e](https://github.com/sanity-io/sdk/commit/969d70e41f6987234323f99753f5cf937469532b)) -- update project and dataset hooks to use `ProjectHandle` or `DatasetHandle` ([969d70e](https://github.com/sanity-io/sdk/commit/969d70e41f6987234323f99753f5cf937469532b)) -- update query and list hooks to accept optional `DatasetHandle` for configuration ([969d70e](https://github.com/sanity-io/sdk/commit/969d70e41f6987234323f99753f5cf937469532b)) -- use hosted login for standalone apps ([#386](https://github.com/sanity-io/sdk/issues/386)) ([9c1ad58](https://github.com/sanity-io/sdk/commit/9c1ad58bc0b302073c90dd6e584f566eba3d0d17)) +* introduce consistent Handle pattern (`ProjectHandle`, `DatasetHandle`, `DocumentHandle`) across the SDK ([969d70e](https://github.com/sanity-io/sdk/commit/969d70e41f6987234323f99753f5cf937469532b)) +* remove ``, introduce `` for configuration ([969d70e](https://github.com/sanity-io/sdk/commit/969d70e41f6987234323f99753f5cf937469532b)) +* rename `_id` to `documentId` in DocumentHandle interface and related usages ([969d70e](https://github.com/sanity-io/sdk/commit/969d70e41f6987234323f99753f5cf937469532b)) +* rename `_type` to `documentType` in DocumentHandle interface and related usages ([969d70e](https://github.com/sanity-io/sdk/commit/969d70e41f6987234323f99753f5cf937469532b)) +* replace `resourceId` concept with explicit `projectId` and `dataset` fields in handles ([969d70e](https://github.com/sanity-io/sdk/commit/969d70e41f6987234323f99753f5cf937469532b)) +* replace `sanityConfigs` prop with `config` prop in `` and `` ([969d70e](https://github.com/sanity-io/sdk/commit/969d70e41f6987234323f99753f5cf937469532b)) +* update document hooks and actions to expect `DocumentHandle` props ([969d70e](https://github.com/sanity-io/sdk/commit/969d70e41f6987234323f99753f5cf937469532b)) +* update project and dataset hooks to use `ProjectHandle` or `DatasetHandle` ([969d70e](https://github.com/sanity-io/sdk/commit/969d70e41f6987234323f99753f5cf937469532b)) +* update query and list hooks to accept optional `DatasetHandle` for configuration ([969d70e](https://github.com/sanity-io/sdk/commit/969d70e41f6987234323f99753f5cf937469532b)) +* use hosted login for standalone apps ([#386](https://github.com/sanity-io/sdk/issues/386)) ([9c1ad58](https://github.com/sanity-io/sdk/commit/9c1ad58bc0b302073c90dd6e584f566eba3d0d17)) + ### Bug Fixes -- **deps:** update pkg-utils to v7 ([#384](https://github.com/sanity-io/sdk/issues/384)) ([ce9a952](https://github.com/sanity-io/sdk/commit/ce9a952a295a32ec86c12cbf9b967128ba5eaf4f)) +* **deps:** update pkg-utils to v7 ([#384](https://github.com/sanity-io/sdk/issues/384)) ([ce9a952](https://github.com/sanity-io/sdk/commit/ce9a952a295a32ec86c12cbf9b967128ba5eaf4f)) ## [0.0.0-alpha.22](https://github.com/sanity-io/sdk/compare/sdk-v0.0.0-alpha.21...sdk-v0.0.0-alpha.22) (2025-03-28) + ### Bug Fixes -- **auth:** ensure that authStore is a true shared resource store ([#371](https://github.com/sanity-io/sdk/issues/371)) ([1709d95](https://github.com/sanity-io/sdk/commit/1709d95dd62082b5e46ae909e2531448ff979074)) +* **auth:** ensure that authStore is a true shared resource store ([#371](https://github.com/sanity-io/sdk/issues/371)) ([1709d95](https://github.com/sanity-io/sdk/commit/1709d95dd62082b5e46ae909e2531448ff979074)) ## [0.0.0-alpha.21](https://github.com/sanity-io/sdk/compare/sdk-v0.0.0-alpha.20...sdk-v0.0.0-alpha.21) (2025-03-27) + ### Bug Fixes -- **deps:** upgrade `@sanity/client`, do not use `withCredentials` ([#368](https://github.com/sanity-io/sdk/issues/368)) ([8e1cbd9](https://github.com/sanity-io/sdk/commit/8e1cbd92501892bf116c3a3473ae693062518f89)) +* **deps:** upgrade `@sanity/client`, do not use `withCredentials` ([#368](https://github.com/sanity-io/sdk/issues/368)) ([8e1cbd9](https://github.com/sanity-io/sdk/commit/8e1cbd92501892bf116c3a3473ae693062518f89)) ## [0.0.0-alpha.20](https://github.com/sanity-io/sdk/compare/sdk-v0.0.0-alpha.19...sdk-v0.0.0-alpha.20) (2025-03-25) + ### ⚠ BREAKING CHANGES -- rename usePermissions → useDocumentPermissions ([#365](https://github.com/sanity-io/sdk/issues/365)) -- rename useActions → useDocumentActions and useActions → useDocumentActions ([#362](https://github.com/sanity-io/sdk/issues/362)) -- rename useHandleCallback → useHandleAuthCallback and HandleCallback → HandleAuthCallback ([#358](https://github.com/sanity-io/sdk/issues/358)) +* rename usePermissions → useDocumentPermissions ([#365](https://github.com/sanity-io/sdk/issues/365)) +* rename useActions → useDocumentActions and useActions → useDocumentActions ([#362](https://github.com/sanity-io/sdk/issues/362)) +* rename useHandleCallback → useHandleAuthCallback and HandleCallback → HandleAuthCallback ([#358](https://github.com/sanity-io/sdk/issues/358)) ### Features -- rename useActions → useDocumentActions and useActions → useDocumentActions ([#362](https://github.com/sanity-io/sdk/issues/362)) ([c753897](https://github.com/sanity-io/sdk/commit/c75389759a57c6da5ad306dbac46c6d58b4f8dda)) -- rename usePermissions → useDocumentPermissions ([#365](https://github.com/sanity-io/sdk/issues/365)) ([6ca2ada](https://github.com/sanity-io/sdk/commit/6ca2ada0b0d9a0633d46ccf8c0170c1712a3afb4)) +* rename useActions → useDocumentActions and useActions → useDocumentActions ([#362](https://github.com/sanity-io/sdk/issues/362)) ([c753897](https://github.com/sanity-io/sdk/commit/c75389759a57c6da5ad306dbac46c6d58b4f8dda)) +* rename usePermissions → useDocumentPermissions ([#365](https://github.com/sanity-io/sdk/issues/365)) ([6ca2ada](https://github.com/sanity-io/sdk/commit/6ca2ada0b0d9a0633d46ccf8c0170c1712a3afb4)) + ### Bug Fixes -- fix typedoc annotations for hooks ([#361](https://github.com/sanity-io/sdk/issues/361)) ([778a63a](https://github.com/sanity-io/sdk/commit/778a63ac5cb52ed6c1e28b1ff22605caad54db33)) +* fix typedoc annotations for hooks ([#361](https://github.com/sanity-io/sdk/issues/361)) ([778a63a](https://github.com/sanity-io/sdk/commit/778a63ac5cb52ed6c1e28b1ff22605caad54db33)) + ### Code Refactoring -- rename useHandleCallback → useHandleAuthCallback and HandleCallback → HandleAuthCallback ([#358](https://github.com/sanity-io/sdk/issues/358)) ([014dc69](https://github.com/sanity-io/sdk/commit/014dc695320273b4e166d946753e851c9701d159)) +* rename useHandleCallback → useHandleAuthCallback and HandleCallback → HandleAuthCallback ([#358](https://github.com/sanity-io/sdk/issues/358)) ([014dc69](https://github.com/sanity-io/sdk/commit/014dc695320273b4e166d946753e851c9701d159)) ## [0.0.0-alpha.19](https://github.com/sanity-io/sdk/compare/sdk-v0.0.0-alpha.18...sdk-v0.0.0-alpha.19) (2025-03-21) + ### ⚠ BREAKING CHANGES -- rename `results` to `data` for useProjection hook ([#335](https://github.com/sanity-io/sdk/issues/335)) -- rename `result` to `data` for usePreview hook ([#325](https://github.com/sanity-io/sdk/issues/325)) +* rename `results` to `data` for useProjection hook ([#335](https://github.com/sanity-io/sdk/issues/335)) +* rename `result` to `data` for usePreview hook ([#325](https://github.com/sanity-io/sdk/issues/325)) ### Features -- add useDashboardOrganizationId hook ([#339](https://github.com/sanity-io/sdk/issues/339)) ([401468e](https://github.com/sanity-io/sdk/commit/401468e07b8c74deb02d4b7df78af808bddd9242)) -- make packages public ([#320](https://github.com/sanity-io/sdk/issues/320)) ([8c94c29](https://github.com/sanity-io/sdk/commit/8c94c29b0aadd86273db59da1b0577aad682d6e9)) -- rename `result` to `data` for usePreview hook ([#325](https://github.com/sanity-io/sdk/issues/325)) ([1e5813e](https://github.com/sanity-io/sdk/commit/1e5813e2e26a72c463cafa8c5502043176930a5b)) -- rename `results` to `data` for useProjection hook ([#335](https://github.com/sanity-io/sdk/issues/335)) ([026dd26](https://github.com/sanity-io/sdk/commit/026dd26bffb9fc2a03801ef05a8d075a2968c725)) +* add useDashboardOrganizationId hook ([#339](https://github.com/sanity-io/sdk/issues/339)) ([401468e](https://github.com/sanity-io/sdk/commit/401468e07b8c74deb02d4b7df78af808bddd9242)) +* make packages public ([#320](https://github.com/sanity-io/sdk/issues/320)) ([8c94c29](https://github.com/sanity-io/sdk/commit/8c94c29b0aadd86273db59da1b0577aad682d6e9)) +* rename `result` to `data` for usePreview hook ([#325](https://github.com/sanity-io/sdk/issues/325)) ([1e5813e](https://github.com/sanity-io/sdk/commit/1e5813e2e26a72c463cafa8c5502043176930a5b)) +* rename `results` to `data` for useProjection hook ([#335](https://github.com/sanity-io/sdk/issues/335)) ([026dd26](https://github.com/sanity-io/sdk/commit/026dd26bffb9fc2a03801ef05a8d075a2968c725)) ## [0.0.0-alpha.18](https://github.com/sanity-io/sdk/compare/sdk-v0.0.0-alpha.17...sdk-v0.0.0-alpha.18) (2025-03-14) + ### ⚠ BREAKING CHANGES -- **react:** flatten sdk-react imports ([#319](https://github.com/sanity-io/sdk/issues/319)) +* **react:** flatten sdk-react imports ([#319](https://github.com/sanity-io/sdk/issues/319)) ### Features -- **react:** flatten sdk-react imports ([#319](https://github.com/sanity-io/sdk/issues/319)) ([3922025](https://github.com/sanity-io/sdk/commit/3922025569abfa4cd824e81222495913875246d7)) +* **react:** flatten sdk-react imports ([#319](https://github.com/sanity-io/sdk/issues/319)) ([3922025](https://github.com/sanity-io/sdk/commit/3922025569abfa4cd824e81222495913875246d7)) ## [0.0.0-alpha.17](https://github.com/sanity-io/sdk/compare/sdk-v0.0.0-alpha.16...sdk-v0.0.0-alpha.17) (2025-03-14) + ### ⚠ BREAKING CHANGES -- remove `schema` from sanity config -- remove schema state and schema manager +* remove `schema` from sanity config +* remove schema state and schema manager ### Features -- remove `schema` from sanity config ([6257fe3](https://github.com/sanity-io/sdk/commit/6257fe39b4521ace71db54f1d0d173a6019db38d)) -- remove schema state and schema manager ([6257fe3](https://github.com/sanity-io/sdk/commit/6257fe39b4521ace71db54f1d0d173a6019db38d)) -- store Dashboard context ([#307](https://github.com/sanity-io/sdk/issues/307)) ([a6c454e](https://github.com/sanity-io/sdk/commit/a6c454e33acea6d33d004751615b226bd60c49b3)) -- use projection for previews and remove schema usage ([6257fe3](https://github.com/sanity-io/sdk/commit/6257fe39b4521ace71db54f1d0d173a6019db38d)) +* remove `schema` from sanity config ([6257fe3](https://github.com/sanity-io/sdk/commit/6257fe39b4521ace71db54f1d0d173a6019db38d)) +* remove schema state and schema manager ([6257fe3](https://github.com/sanity-io/sdk/commit/6257fe39b4521ace71db54f1d0d173a6019db38d)) +* store Dashboard context ([#307](https://github.com/sanity-io/sdk/issues/307)) ([a6c454e](https://github.com/sanity-io/sdk/commit/a6c454e33acea6d33d004751615b226bd60c49b3)) +* use projection for previews and remove schema usage ([6257fe3](https://github.com/sanity-io/sdk/commit/6257fe39b4521ace71db54f1d0d173a6019db38d)) ## [0.0.0-alpha.16](https://github.com/sanity-io/sdk/compare/sdk-v0.0.0-alpha.15...sdk-v0.0.0-alpha.16) (2025-03-12) + ### Features -- **react:** add react compiler to the build process ([#298](https://github.com/sanity-io/sdk/issues/298)) ([bfb74eb](https://github.com/sanity-io/sdk/commit/bfb74ebe538b1218a980b03493890b70dc1311d2)) +* **react:** add react compiler to the build process ([#298](https://github.com/sanity-io/sdk/issues/298)) ([bfb74eb](https://github.com/sanity-io/sdk/commit/bfb74ebe538b1218a980b03493890b70dc1311d2)) + ### Bug Fixes -- all client requests are properly tagged ([#274](https://github.com/sanity-io/sdk/issues/274)) ([6df8938](https://github.com/sanity-io/sdk/commit/6df893891e7b12eff122de5147ab03b65b51bcbe)) -- **auth:** only attempt to refresh stamped tokens ([#304](https://github.com/sanity-io/sdk/issues/304)) ([b08a319](https://github.com/sanity-io/sdk/commit/b08a3194a061031400e2ded654269adf71130ea5)) +* all client requests are properly tagged ([#274](https://github.com/sanity-io/sdk/issues/274)) ([6df8938](https://github.com/sanity-io/sdk/commit/6df893891e7b12eff122de5147ab03b65b51bcbe)) +* **auth:** only attempt to refresh stamped tokens ([#304](https://github.com/sanity-io/sdk/issues/304)) ([b08a319](https://github.com/sanity-io/sdk/commit/b08a3194a061031400e2ded654269adf71130ea5)) ## [0.0.0-alpha.15](https://github.com/sanity-io/sdk/compare/sdk-v0.0.0-alpha.14...sdk-v0.0.0-alpha.15) (2025-03-10) + ### ⚠ BREAKING CHANGES -- remove `useDocuments` and `useSearch` hooks +* remove `useDocuments` and `useSearch` hooks ### Features -- add `useQuery`, `useInfiniteList`, `usePaginatedList` hooks ([1a3f4ad](https://github.com/sanity-io/sdk/commit/1a3f4ad98abf2ab68c552fea20d60639462f3aac)) -- add versions information to all packages ([#275](https://github.com/sanity-io/sdk/issues/275)) ([afb2fec](https://github.com/sanity-io/sdk/commit/afb2fec63ea3bae53cab9d8f05081daf2f3c2733)) -- **document hooks:** update the documentation for the Document hook s an optional resourceId ([#280](https://github.com/sanity-io/sdk/issues/280)) ([eb65378](https://github.com/sanity-io/sdk/commit/eb65378c884f3aaf9b2c0dbc95dd86075c76f9e0)) -- remove `useDocuments` and `useSearch` hooks ([9f37daf](https://github.com/sanity-io/sdk/commit/9f37daf1243ee0fda558ffd7259c45da9e4ba259)) +* add `useQuery`, `useInfiniteList`, `usePaginatedList` hooks ([1a3f4ad](https://github.com/sanity-io/sdk/commit/1a3f4ad98abf2ab68c552fea20d60639462f3aac)) +* add versions information to all packages ([#275](https://github.com/sanity-io/sdk/issues/275)) ([afb2fec](https://github.com/sanity-io/sdk/commit/afb2fec63ea3bae53cab9d8f05081daf2f3c2733)) +* **document hooks:** update the documentation for the Document hook s an optional resourceId ([#280](https://github.com/sanity-io/sdk/issues/280)) ([eb65378](https://github.com/sanity-io/sdk/commit/eb65378c884f3aaf9b2c0dbc95dd86075c76f9e0)) +* remove `useDocuments` and `useSearch` hooks ([9f37daf](https://github.com/sanity-io/sdk/commit/9f37daf1243ee0fda558ffd7259c45da9e4ba259)) + ### Bug Fixes -- **core:** add correct perspective to useProjection ([#295](https://github.com/sanity-io/sdk/issues/295)) ([8792e00](https://github.com/sanity-io/sdk/commit/8792e00db7f5f5926e5c311e5cf0bf74bc78f041)) -- **core:** determine env for version ([#293](https://github.com/sanity-io/sdk/issues/293)) ([643eac4](https://github.com/sanity-io/sdk/commit/643eac4c69c117c7b08866afb1f92b32010c9a83)) -- **deps:** update dependency @sanity/client to ^6.28.3 ([#287](https://github.com/sanity-io/sdk/issues/287)) ([fc5c5a1](https://github.com/sanity-io/sdk/commit/fc5c5a1fd54bca5b7b7138e4cab49113449eebe2)) -- **deps:** update dependency @sanity/comlink to v3 ([#296](https://github.com/sanity-io/sdk/issues/296)) ([14fbe1b](https://github.com/sanity-io/sdk/commit/14fbe1b89a79d2532e8735a58abbe4a5cff6d635)) -- **deps:** Update sanity monorepo to ^3.78.1 ([#297](https://github.com/sanity-io/sdk/issues/297)) ([835b594](https://github.com/sanity-io/sdk/commit/835b5942d3870a92e0fd1387ab9baa5e555a3ee5)) +* **core:** add correct perspective to useProjection ([#295](https://github.com/sanity-io/sdk/issues/295)) ([8792e00](https://github.com/sanity-io/sdk/commit/8792e00db7f5f5926e5c311e5cf0bf74bc78f041)) +* **core:** determine env for version ([#293](https://github.com/sanity-io/sdk/issues/293)) ([643eac4](https://github.com/sanity-io/sdk/commit/643eac4c69c117c7b08866afb1f92b32010c9a83)) +* **deps:** update dependency @sanity/client to ^6.28.3 ([#287](https://github.com/sanity-io/sdk/issues/287)) ([fc5c5a1](https://github.com/sanity-io/sdk/commit/fc5c5a1fd54bca5b7b7138e4cab49113449eebe2)) +* **deps:** update dependency @sanity/comlink to v3 ([#296](https://github.com/sanity-io/sdk/issues/296)) ([14fbe1b](https://github.com/sanity-io/sdk/commit/14fbe1b89a79d2532e8735a58abbe4a5cff6d635)) +* **deps:** Update sanity monorepo to ^3.78.1 ([#297](https://github.com/sanity-io/sdk/issues/297)) ([835b594](https://github.com/sanity-io/sdk/commit/835b5942d3870a92e0fd1387ab9baa5e555a3ee5)) ## [0.0.0-alpha.14](https://github.com/sanity-io/sdk/compare/sdk-v0.0.0-alpha.13...sdk-v0.0.0-alpha.14) (2025-03-07) + ### ⚠ BREAKING CHANGES -- allow multiple resources via instances ([#271](https://github.com/sanity-io/sdk/issues/271)) +* allow multiple resources via instances ([#271](https://github.com/sanity-io/sdk/issues/271)) ### Features -- add useProjection hook ([#257](https://github.com/sanity-io/sdk/issues/257)) ([fbaafe0](https://github.com/sanity-io/sdk/commit/fbaafe031e235f61b9d60bf5938f18a4683aafe5)) -- allow multiple resources via instances ([#271](https://github.com/sanity-io/sdk/issues/271)) ([6f4d541](https://github.com/sanity-io/sdk/commit/6f4d5410671e8b75759e33380464656a8c961ad6)) +* add useProjection hook ([#257](https://github.com/sanity-io/sdk/issues/257)) ([fbaafe0](https://github.com/sanity-io/sdk/commit/fbaafe031e235f61b9d60bf5938f18a4683aafe5)) +* allow multiple resources via instances ([#271](https://github.com/sanity-io/sdk/issues/271)) ([6f4d541](https://github.com/sanity-io/sdk/commit/6f4d5410671e8b75759e33380464656a8c961ad6)) + ### Bug Fixes -- **core:** use drafts instead of previewDrafts ([#279](https://github.com/sanity-io/sdk/issues/279)) ([45305ad](https://github.com/sanity-io/sdk/commit/45305ad0ecc72d60ca1ccba15703bb8a0a6a53f5)) +* **core:** use drafts instead of previewDrafts ([#279](https://github.com/sanity-io/sdk/issues/279)) ([45305ad](https://github.com/sanity-io/sdk/commit/45305ad0ecc72d60ca1ccba15703bb8a0a6a53f5)) ## [0.0.0-alpha.13](https://github.com/sanity-io/sdk/compare/sdk-v0.0.0-alpha.12...sdk-v0.0.0-alpha.13) (2025-03-05) + ### Features -- `useProjects`, `useProject`, `useDatasets` ([#235](https://github.com/sanity-io/sdk/issues/235)) ([cc95dfd](https://github.com/sanity-io/sdk/commit/cc95dfd45a82171fa7ccf05a8ca331e8de97fbee)) +* `useProjects`, `useProject`, `useDatasets` ([#235](https://github.com/sanity-io/sdk/issues/235)) ([cc95dfd](https://github.com/sanity-io/sdk/commit/cc95dfd45a82171fa7ccf05a8ca331e8de97fbee)) + ### Bug Fixes -- add access api types inside the SDK ([#261](https://github.com/sanity-io/sdk/issues/261)) ([ff53123](https://github.com/sanity-io/sdk/commit/ff53123f2e01a242c22df22b9dc109d2cbc3b1d4)) -- **build:** fixes build warning ([#252](https://github.com/sanity-io/sdk/issues/252)) ([bed82f8](https://github.com/sanity-io/sdk/commit/bed82f8d87521dd0cc9d827af5a7f908749ad711)) -- **core:** fixes apiVersion in usersStore ([#262](https://github.com/sanity-io/sdk/issues/262)) ([248eb19](https://github.com/sanity-io/sdk/commit/248eb192dc331ce64c05721172f2855a44dad0ca)) +* add access api types inside the SDK ([#261](https://github.com/sanity-io/sdk/issues/261)) ([ff53123](https://github.com/sanity-io/sdk/commit/ff53123f2e01a242c22df22b9dc109d2cbc3b1d4)) +* **build:** fixes build warning ([#252](https://github.com/sanity-io/sdk/issues/252)) ([bed82f8](https://github.com/sanity-io/sdk/commit/bed82f8d87521dd0cc9d827af5a7f908749ad711)) +* **core:** fixes apiVersion in usersStore ([#262](https://github.com/sanity-io/sdk/issues/262)) ([248eb19](https://github.com/sanity-io/sdk/commit/248eb192dc331ce64c05721172f2855a44dad0ca)) ## [0.0.0-alpha.12](https://github.com/sanity-io/sdk/compare/sdk-v0.0.0-alpha.11...sdk-v0.0.0-alpha.12) (2025-02-28) + ### Features -- add useUsers hook ([#239](https://github.com/sanity-io/sdk/issues/239)) ([b89bcf0](https://github.com/sanity-io/sdk/commit/b89bcf00bc4a849409ae80f45b1917cb1e51c66e)) +* add useUsers hook ([#239](https://github.com/sanity-io/sdk/issues/239)) ([b89bcf0](https://github.com/sanity-io/sdk/commit/b89bcf00bc4a849409ae80f45b1917cb1e51c66e)) ## [0.0.0-alpha.11](https://github.com/sanity-io/sdk/compare/sdk-v0.0.0-alpha.10...sdk-v0.0.0-alpha.11) (2025-02-28) + ### Features -- **auth:** refresh stamped tokens ([#225](https://github.com/sanity-io/sdk/issues/225)) ([10b2745](https://github.com/sanity-io/sdk/commit/10b2745c62f9169b8cd1c66d7fb641d7fda37429)) -- document permissions ([#226](https://github.com/sanity-io/sdk/issues/226)) ([107f434](https://github.com/sanity-io/sdk/commit/107f4349d7defab04d1282ee1ab20766d157eab7)) +* **auth:** refresh stamped tokens ([#225](https://github.com/sanity-io/sdk/issues/225)) ([10b2745](https://github.com/sanity-io/sdk/commit/10b2745c62f9169b8cd1c66d7fb641d7fda37429)) +* document permissions ([#226](https://github.com/sanity-io/sdk/issues/226)) ([107f434](https://github.com/sanity-io/sdk/commit/107f4349d7defab04d1282ee1ab20766d157eab7)) + ### Bug Fixes -- **comlink:** expose statuses and destroy unused resources ([#233](https://github.com/sanity-io/sdk/issues/233)) ([8b8a40c](https://github.com/sanity-io/sdk/commit/8b8a40c5ac0b5ba76cda043ffc9bc3b740bce5bd)) -- **core:** add raw perspective to client ([#237](https://github.com/sanity-io/sdk/issues/237)) ([202c4ba](https://github.com/sanity-io/sdk/commit/202c4ba7bb9fdbc7f635ac8691ba840717cafc69)) -- make apiVersion required in getClient ([#230](https://github.com/sanity-io/sdk/issues/230)) ([91458d3](https://github.com/sanity-io/sdk/commit/91458d35251be6cf02592f0d4391f58838921ff8)) +* **comlink:** expose statuses and destroy unused resources ([#233](https://github.com/sanity-io/sdk/issues/233)) ([8b8a40c](https://github.com/sanity-io/sdk/commit/8b8a40c5ac0b5ba76cda043ffc9bc3b740bce5bd)) +* **core:** add raw perspective to client ([#237](https://github.com/sanity-io/sdk/issues/237)) ([202c4ba](https://github.com/sanity-io/sdk/commit/202c4ba7bb9fdbc7f635ac8691ba840717cafc69)) +* make apiVersion required in getClient ([#230](https://github.com/sanity-io/sdk/issues/230)) ([91458d3](https://github.com/sanity-io/sdk/commit/91458d35251be6cf02592f0d4391f58838921ff8)) ## [0.0.0-alpha.10](https://github.com/sanity-io/sdk/compare/sdk-v0.0.0-alpha.9...sdk-v0.0.0-alpha.10) (2025-02-13) + ### Features -- export the SanityDocument type ([#221](https://github.com/sanity-io/sdk/issues/221)) ([dc6dbc8](https://github.com/sanity-io/sdk/commit/dc6dbc85fe6d80c6e3b08de76e666da340aa62f6)) +* export the SanityDocument type ([#221](https://github.com/sanity-io/sdk/issues/221)) ([dc6dbc8](https://github.com/sanity-io/sdk/commit/dc6dbc85fe6d80c6e3b08de76e666da340aa62f6)) ## [0.0.0-alpha.9](https://github.com/sanity-io/sdk/compare/sdk-v0.0.0-alpha.8...sdk-v0.0.0-alpha.9) (2025-02-11) + ### Features -- document store ([#197](https://github.com/sanity-io/sdk/issues/197)) ([497bb26](https://github.com/sanity-io/sdk/commit/497bb2641d5766128dfca4db8247f2f9555b83b1)) +* document store ([#197](https://github.com/sanity-io/sdk/issues/197)) ([497bb26](https://github.com/sanity-io/sdk/commit/497bb2641d5766128dfca4db8247f2f9555b83b1)) ## [0.0.0-alpha.8](https://github.com/sanity-io/sdk/compare/sdk-v0.0.0-alpha.7...sdk-v0.0.0-alpha.8) (2025-02-06) + ### Features -- **client:** add a global api client ([#209](https://github.com/sanity-io/sdk/issues/209)) ([5898b1d](https://github.com/sanity-io/sdk/commit/5898b1d82fc07d12f736d1361e48287e41ae0608)) +* **client:** add a global api client ([#209](https://github.com/sanity-io/sdk/issues/209)) ([5898b1d](https://github.com/sanity-io/sdk/commit/5898b1d82fc07d12f736d1361e48287e41ae0608)) ## [0.0.0-alpha.7](https://github.com/sanity-io/sdk/compare/sdk-v0.0.0-alpha.6...sdk-v0.0.0-alpha.7) (2025-02-05) + ### Bug Fixes -- trigger release ([#210](https://github.com/sanity-io/sdk/issues/210)) ([2b36c98](https://github.com/sanity-io/sdk/commit/2b36c985a91d44be95a9e6c8446e9a11ffa59d61)) +* trigger release ([#210](https://github.com/sanity-io/sdk/issues/210)) ([2b36c98](https://github.com/sanity-io/sdk/commit/2b36c985a91d44be95a9e6c8446e9a11ffa59d61)) ## [0.0.0-alpha.6](https://github.com/sanity-io/sdk/compare/sdk-v0.0.0-alpha.5...sdk-v0.0.0-alpha.6) (2025-01-30) + ### ⚠ BREAKING CHANGES -- renames `org` auth scope to `global` ([#187](https://github.com/sanity-io/sdk/issues/187)) +* renames `org` auth scope to `global` ([#187](https://github.com/sanity-io/sdk/issues/187)) ### Miscellaneous Chores -- renames `org` auth scope to `global` ([#187](https://github.com/sanity-io/sdk/issues/187)) ([3220d57](https://github.com/sanity-io/sdk/commit/3220d5729c8012ffc47bfa2d75bfca1f2642df76)) +* renames `org` auth scope to `global` ([#187](https://github.com/sanity-io/sdk/issues/187)) ([3220d57](https://github.com/sanity-io/sdk/commit/3220d5729c8012ffc47bfa2d75bfca1f2642df76)) ## [0.0.0-alpha.5](https://github.com/sanity-io/sdk/compare/sdk-v0.0.0-alpha.4...sdk-v0.0.0-alpha.5) (2025-01-28) From 5d48db1c7cef49c4d8bcfe8c9f0e82061d306869 Mon Sep 17 00:00:00 2001 From: Ryan Bonial Date: Fri, 20 Jun 2025 12:58:03 -0600 Subject: [PATCH 16/17] chore: remove unneeded hook --- packages/react/src/_exports/sdk-react.ts | 2 +- .../src/components/auth/AuthBoundary.tsx | 6 +- .../src/context/ComlinkTokenRefresh.test.tsx | 278 +++++------------- .../react/src/context/ComlinkTokenRefresh.tsx | 20 -- 4 files changed, 80 insertions(+), 226 deletions(-) diff --git a/packages/react/src/_exports/sdk-react.ts b/packages/react/src/_exports/sdk-react.ts index 79eb2247..e9a490fc 100644 --- a/packages/react/src/_exports/sdk-react.ts +++ b/packages/react/src/_exports/sdk-react.ts @@ -4,7 +4,7 @@ export {AuthBoundary, type AuthBoundaryProps} from '../components/auth/AuthBoundary' export {SanityApp, type SanityAppProps} from '../components/SanityApp' export {SDKProvider, type SDKProviderProps} from '../components/SDKProvider' -export {ComlinkTokenRefreshProvider, useComlinkTokenRefresh} from '../context/ComlinkTokenRefresh' +export {ComlinkTokenRefreshProvider} from '../context/ComlinkTokenRefresh' export {ResourceProvider, type ResourceProviderProps} from '../context/ResourceProvider' export {useAuthState} from '../hooks/auth/useAuthState' export {useAuthToken} from '../hooks/auth/useAuthToken' diff --git a/packages/react/src/components/auth/AuthBoundary.tsx b/packages/react/src/components/auth/AuthBoundary.tsx index 347a07c3..7924fdc6 100644 --- a/packages/react/src/components/auth/AuthBoundary.tsx +++ b/packages/react/src/components/auth/AuthBoundary.tsx @@ -2,10 +2,7 @@ import {AuthStateType} from '@sanity/sdk' import {useEffect, useMemo} from 'react' import {ErrorBoundary, type FallbackProps} from 'react-error-boundary' -import { - ComlinkTokenRefreshProvider, - useComlinkTokenRefresh, -} from '../../context/ComlinkTokenRefresh' +import {ComlinkTokenRefreshProvider} from '../../context/ComlinkTokenRefresh' import {useAuthState} from '../../hooks/auth/useAuthState' import {useLoginUrl} from '../../hooks/auth/useLoginUrl' import {useVerifyOrgProjects} from '../../hooks/auth/useVerifyOrgProjects' @@ -151,7 +148,6 @@ function AuthSwitch({ const isLoggedOut = authState.type === AuthStateType.LOGGED_OUT && !authState.isDestroyingSession const loginUrl = useLoginUrl() - useComlinkTokenRefresh() // Initialize the comlink token refresh context for Dashboard Comlink useEffect(() => { if (isLoggedOut && !isInIframe()) { diff --git a/packages/react/src/context/ComlinkTokenRefresh.test.tsx b/packages/react/src/context/ComlinkTokenRefresh.test.tsx index b003ab40..e6e1316b 100644 --- a/packages/react/src/context/ComlinkTokenRefresh.test.tsx +++ b/packages/react/src/context/ComlinkTokenRefresh.test.tsx @@ -1,15 +1,12 @@ import {SDK_CHANNEL_NAME, SDK_NODE_NAME} from '@sanity/message-protocol' import {AuthStateType, getIsInDashboardState, setAuthToken} from '@sanity/sdk' import {act, render} from '@testing-library/react' -import React from 'react' import {afterEach, beforeEach, describe, expect, it, type Mock, vi} from 'vitest' import {useAuthState} from '../hooks/auth/useAuthState' import {useWindowConnection} from '../hooks/comlink/useWindowConnection' import {useSanityInstance} from '../hooks/context/useSanityInstance' -import {ComlinkTokenRefreshProvider, useComlinkTokenRefresh} from './ComlinkTokenRefresh' - -const DEFAULT_RESPONSE_TIMEOUT = 10000 // 10 seconds +import {ComlinkTokenRefreshProvider} from './ComlinkTokenRefresh' // Mocks vi.mock('@sanity/sdk', async () => { @@ -44,9 +41,6 @@ const mockFetch = vi.fn() // eslint-disable-next-line @typescript-eslint/no-explicit-any const mockSanityInstance: any = {projectId: 'test', dataset: 'test'} -// Variable to capture the hook's current value for direct assertions -let currentHookValue: ReturnType - describe('ComlinkTokenRefresh', () => { beforeEach(() => { vi.useFakeTimers() @@ -54,12 +48,6 @@ describe('ComlinkTokenRefresh', () => { mockUseAuthState.mockReturnValue({type: AuthStateType.LOGGED_IN}) mockUseWindowConnection.mockReturnValue({fetch: mockFetch}) mockUseSanityInstance.mockReturnValue(mockSanityInstance) - vi.spyOn(console, 'warn').mockImplementation(() => {}) // Mock console.warn - // Initialize currentHookValue with default structure - currentHookValue = { - requestNewToken: () => {}, - isTokenRefreshInProgress: {current: false}, - } }) afterEach(() => { @@ -67,77 +55,36 @@ describe('ComlinkTokenRefresh', () => { vi.useRealTimers() }) - interface TestComponentProps { - onHookUpdate?: (value: ReturnType) => void - } - - const TestComponent: React.FC = ({onHookUpdate}) => { - const hookValue = useComlinkTokenRefresh() - React.useEffect(() => { - onHookUpdate?.(hookValue) - }, [hookValue, onHookUpdate]) // Update when hookValue or callback changes - - return ( -
- - {String(hookValue.isTokenRefreshInProgress.current)} - - -
- ) - } - - const renderWithProvider = ( - testComponentProps?: TestComponentProps, - children?: React.ReactNode, - ) => { - const onHookUpdateCallback = - testComponentProps?.onHookUpdate || - ((value) => { - currentHookValue = value - }) - return render( - - {children || } - , - ) - } - - describe('useComlinkTokenRefresh without Provider', () => { - it('should return default values and warn on requestNewToken', () => { - const {getByText} = render( - (currentHookValue = value)} />, - ) - - expect(currentHookValue.isTokenRefreshInProgress.current).toBe(false) - - act(() => { - getByText('Request Token').click() - }) - - // Verify warning was shown - // eslint-disable-next-line no-console - expect(console.warn).toHaveBeenCalledWith( - 'useComlinkTokenRefresh must be used within a ComlinkTokenRefreshProvider.', - ) - expect(mockFetch).not.toHaveBeenCalled() - }) - }) - describe('ComlinkTokenRefreshProvider', () => { describe('when not in dashboard', () => { beforeEach(() => { mockGetIsInDashboardState.mockReturnValue({getCurrent: () => false}) }) - it('should have requestNewToken do nothing', () => { - const {getByText} = renderWithProvider() + it('should not request new token on 401 if not in dashboard', async () => { + mockUseAuthState.mockReturnValue({type: AuthStateType.LOGGED_IN}) + const {rerender} = render( + +
Test
+
, + ) + mockUseAuthState.mockReturnValue({ + type: AuthStateType.ERROR, + error: {statusCode: 401, message: 'Unauthorized'}, + }) act(() => { - getByText('Request Token').click() + rerender( + +
Test
+
, + ) + }) + + await act(async () => { + await vi.advanceTimersByTimeAsync(100) }) expect(mockFetch).not.toHaveBeenCalled() - expect(currentHookValue.isTokenRefreshInProgress.current).toBe(false) }) }) @@ -147,7 +94,11 @@ describe('ComlinkTokenRefresh', () => { }) it('should initialize useWindowConnection with correct parameters', () => { - renderWithProvider() + render( + +
Test
+
, + ) expect(mockUseWindowConnection).toHaveBeenCalledWith( expect.objectContaining({ @@ -157,157 +108,84 @@ describe('ComlinkTokenRefresh', () => { ) }) - it('requestNewToken should do nothing if token refresh is already in progress', async () => { - // Use a promise that never resolves to keep the refresh in progress - mockFetch.mockImplementationOnce(() => new Promise(() => {})) - const {getByText} = renderWithProvider() - - // Start a request - await act(async () => { - getByText('Request Token').click() - }) - expect(mockFetch).toHaveBeenCalledTimes(1) - expect(currentHookValue.isTokenRefreshInProgress.current).toBe(true) - - // Try to start another one - await act(async () => { - getByText('Request Token').click() - }) - expect(mockFetch).toHaveBeenCalledTimes(1) // Still 1 - expect(currentHookValue.isTokenRefreshInProgress.current).toBe(true) - - act(() => { - vi.advanceTimersByTime(DEFAULT_RESPONSE_TIMEOUT + 1000) - }) - expect(currentHookValue.isTokenRefreshInProgress.current).toBe(false) - }) - - it('requestNewToken should fetch token and set inProgress, then timeout if no response', async () => { - mockFetch.mockImplementationOnce(() => new Promise(() => {})) // Never resolves - const {getByText} = renderWithProvider() - - await act(async () => { - getByText('Request Token').click() - }) - - expect(mockFetch).toHaveBeenCalledWith('dashboard/v1/auth/tokens/create') - expect(currentHookValue.isTokenRefreshInProgress.current).toBe(true) - - act(() => { - vi.advanceTimersByTime(DEFAULT_RESPONSE_TIMEOUT - 1) + it('should handle received token', async () => { + mockUseAuthState.mockReturnValue({ + type: AuthStateType.ERROR, + error: {statusCode: 401, message: 'Unauthorized'}, }) - expect(currentHookValue.isTokenRefreshInProgress.current).toBe(true) - - act(() => { - vi.advanceTimersByTime(1) - }) - expect(currentHookValue.isTokenRefreshInProgress.current).toBe(false) - }) - - it('should handle received token and reset inProgress', async () => { mockFetch.mockResolvedValueOnce({token: 'new-token'}) - const {getByText} = renderWithProvider() + + render( + +
Test
+
, + ) await act(async () => { - getByText('Request Token').click() + await vi.advanceTimersByTimeAsync(100) }) - expect(currentHookValue.isTokenRefreshInProgress.current).toBe(false) expect(mockSetAuthToken).toHaveBeenCalledWith(mockSanityInstance, 'new-token') expect(mockFetch).toHaveBeenCalledTimes(1) - - // Ensure timeout was cleared (check by advancing time - progress should still be false) - act(() => { - vi.advanceTimersByTime(DEFAULT_RESPONSE_TIMEOUT + 1000) - }) - expect(currentHookValue.isTokenRefreshInProgress.current).toBe(false) }) it('should not set auth token if received token is null', async () => { + mockUseAuthState.mockReturnValue({ + type: AuthStateType.ERROR, + error: {statusCode: 401, message: 'Unauthorized'}, + }) mockFetch.mockResolvedValueOnce({token: null}) - renderWithProvider() + + render( + +
Test
+
, + ) await act(async () => { - currentHookValue.requestNewToken() + await vi.advanceTimersByTimeAsync(100) }) expect(mockSetAuthToken).not.toHaveBeenCalled() - expect(currentHookValue.isTokenRefreshInProgress.current).toBe(false) }) - it('should reset inProgress if fetch throws', async () => { + it('should handle fetch errors gracefully', async () => { + mockUseAuthState.mockReturnValue({ + type: AuthStateType.ERROR, + error: {statusCode: 401, message: 'Unauthorized'}, + }) mockFetch.mockRejectedValueOnce(new Error('Fetch failed')) - renderWithProvider() + + render( + +
Test
+
, + ) await act(async () => { - currentHookValue.requestNewToken() + await vi.advanceTimersByTimeAsync(100) }) - expect(currentHookValue.isTokenRefreshInProgress.current).toBe(false) expect(mockFetch).toHaveBeenCalledTimes(1) }) - describe('Automatic token refresh on 401', () => { - const createError401 = () => ({statusCode: 401, message: 'Unauthorized'}) - - it('should not request new token on 401 if refresh is already in progress', async () => { - mockFetch.mockImplementationOnce(() => new Promise(() => {})) // Never resolves - mockUseAuthState.mockReturnValue({type: AuthStateType.LOGGED_IN}) - const {rerender, getByText} = renderWithProvider() - - await act(async () => { - getByText('Request Token').click() - }) - expect(currentHookValue.isTokenRefreshInProgress.current).toBe(true) - mockFetch.mockClear() - - mockUseAuthState.mockReturnValue({type: AuthStateType.ERROR, error: createError401()}) - act(() => { - rerender( - - - , - ) - }) - - await act(async () => { - await vi.advanceTimersByTimeAsync(100) - }) - expect(mockFetch).not.toHaveBeenCalled() - expect(currentHookValue.isTokenRefreshInProgress.current).toBe(true) - }) - - it('should not request new token on 401 if not in dashboard', async () => { - mockGetIsInDashboardState.mockReturnValue({getCurrent: () => false}) - mockUseAuthState.mockReturnValue({type: AuthStateType.LOGGED_IN}) - const {rerender} = renderWithProvider() - - mockUseAuthState.mockReturnValue({type: AuthStateType.ERROR, error: createError401()}) - act(() => { - rerender( - - - , - ) - }) - - await act(async () => { - await vi.advanceTimersByTimeAsync(100) - }) - expect(mockFetch).not.toHaveBeenCalled() - expect(currentHookValue.isTokenRefreshInProgress.current).toBe(false) - }) - + describe('Automatic token refresh', () => { it('should not request new token for non-401 errors', async () => { - const error500 = {statusCode: 500, message: 'Server Error'} mockUseAuthState.mockReturnValue({type: AuthStateType.LOGGED_IN}) - const {rerender} = renderWithProvider() - - mockUseAuthState.mockReturnValue({type: AuthStateType.ERROR, error: error500}) + const {rerender} = render( + +
Test
+
, + ) + + mockUseAuthState.mockReturnValue({ + type: AuthStateType.ERROR, + error: {statusCode: 500, message: 'Server Error'}, + }) act(() => { rerender( - +
Test
, ) }) @@ -316,26 +194,26 @@ describe('ComlinkTokenRefresh', () => { await vi.advanceTimersByTimeAsync(100) }) expect(mockFetch).not.toHaveBeenCalled() - expect(currentHookValue.isTokenRefreshInProgress.current).toBe(false) }) it('should request new token on LOGGED_OUT state', async () => { - // Use a promise that never resolves to keep the refresh in progress - mockFetch.mockImplementationOnce(() => new Promise(() => {})) mockUseAuthState.mockReturnValue({type: AuthStateType.LOGGED_IN}) - const {rerender} = renderWithProvider() + const {rerender} = render( + +
Test
+
, + ) mockUseAuthState.mockReturnValue({type: AuthStateType.LOGGED_OUT}) act(() => { rerender( - +
Test
, ) }) expect(mockFetch).toHaveBeenCalledWith('dashboard/v1/auth/tokens/create') - expect(currentHookValue.isTokenRefreshInProgress.current).toBe(true) }) }) }) diff --git a/packages/react/src/context/ComlinkTokenRefresh.tsx b/packages/react/src/context/ComlinkTokenRefresh.tsx index 4b6fe19e..5efeefc7 100644 --- a/packages/react/src/context/ComlinkTokenRefresh.tsx +++ b/packages/react/src/context/ComlinkTokenRefresh.tsx @@ -13,7 +13,6 @@ import React, { createContext, type PropsWithChildren, useCallback, - useContext, useEffect, useMemo, useRef, @@ -169,22 +168,3 @@ export const ComlinkTokenRefreshProvider: React.FC = ({childr // If we're not in the dashboard, we don't need to do anything return {children} } - -/** - * This hook is used to request a new token from the parent window. - * It is used to automatically request a new token on 401 error if enabled. - * @public - */ -export const useComlinkTokenRefresh = (): ComlinkTokenRefreshContextValue => { - const context = useContext(ComlinkTokenRefreshContext) - if (!context) { - return { - requestNewToken: () => { - // eslint-disable-next-line no-console - console.warn('useComlinkTokenRefresh must be used within a ComlinkTokenRefreshProvider.') - }, - isTokenRefreshInProgress: {current: false}, - } - } - return context -} From 3032ef7636878b8a2e654f3095622b142e8dfd44 Mon Sep 17 00:00:00 2001 From: Ryan Bonial Date: Fri, 20 Jun 2025 13:02:15 -0600 Subject: [PATCH 17/17] chore: review feedback --- .../react/src/components/auth/LoginError.tsx | 5 +- .../react/src/context/ComlinkTokenRefresh.tsx | 51 ++----------------- 2 files changed, 4 insertions(+), 52 deletions(-) diff --git a/packages/react/src/components/auth/LoginError.tsx b/packages/react/src/components/auth/LoginError.tsx index 26234d9a..3213dd8b 100644 --- a/packages/react/src/components/auth/LoginError.tsx +++ b/packages/react/src/components/auth/LoginError.tsx @@ -41,10 +41,7 @@ export function LoginError({error, resetErrorBoundary}: LoginErrorProps): React. }, [logout, resetErrorBoundary]) useEffect(() => { - if ( - // (authState.type === AuthStateType.ERROR || authState.type === AuthStateType.LOGGED_IN) && - error instanceof ClientError - ) { + if (error instanceof ClientError) { if (error.statusCode === 401) { handleRetry() } else if (error.statusCode === 404) { diff --git a/packages/react/src/context/ComlinkTokenRefresh.tsx b/packages/react/src/context/ComlinkTokenRefresh.tsx index 5efeefc7..9646b718 100644 --- a/packages/react/src/context/ComlinkTokenRefresh.tsx +++ b/packages/react/src/context/ComlinkTokenRefresh.tsx @@ -9,14 +9,7 @@ import { setAuthToken, type WindowMessage, } from '@sanity/sdk' -import React, { - createContext, - type PropsWithChildren, - useCallback, - useEffect, - useMemo, - useRef, -} from 'react' +import React, {type PropsWithChildren, useCallback, useEffect, useMemo, useRef} from 'react' import {useAuthState} from '../hooks/auth/useAuthState' import {useWindowConnection} from '../hooks/comlink/useWindowConnection' @@ -26,13 +19,6 @@ import {useSanityInstance} from '../hooks/context/useSanityInstance' type SdkParentComlinkMessage = NewTokenResponseMessage | WindowMessage // Messages received by SDK type SdkChildComlinkMessage = RequestNewTokenMessage | FrameMessage // Messages sent by SDK -interface ComlinkTokenRefreshContextValue { - requestNewToken: () => void - isTokenRefreshInProgress: React.MutableRefObject -} - -const ComlinkTokenRefreshContext = createContext(null) - const DEFAULT_RESPONSE_TIMEOUT = 10000 // 10 seconds /** @@ -88,14 +74,6 @@ function DashboardTokenRefresh({children}: PropsWithChildren) { } }, [windowConnection, clearRefreshTimeout, instance]) - const contextValue = useMemo( - () => ({ - requestNewToken, - isTokenRefreshInProgress, - }), - [requestNewToken], - ) - useEffect(() => { return () => { clearRefreshTimeout() @@ -126,30 +104,7 @@ function DashboardTokenRefresh({children}: PropsWithChildren) { } }, [authState, requestNewToken]) - return ( - - {children} - - ) -} - -/** - * Component that provides a no-op token refresh outside of dashboard - */ -function NoOpTokenRefresh({children}: PropsWithChildren) { - const contextValue = useMemo( - () => ({ - requestNewToken: () => {}, - isTokenRefreshInProgress: {current: false}, - }), - [], - ) - - return ( - - {children} - - ) + return children } /** @@ -166,5 +121,5 @@ export const ComlinkTokenRefreshProvider: React.FC = ({childr } // If we're not in the dashboard, we don't need to do anything - return {children} + return children }