diff --git a/.changeset/cuddly-cougars-check.md b/.changeset/cuddly-cougars-check.md new file mode 100644 index 0000000000..eac077ac2a --- /dev/null +++ b/.changeset/cuddly-cougars-check.md @@ -0,0 +1,13 @@ +--- +'@clerk/shared': major +'@clerk/clerk-react': major +--- + +Drop deprecations. Migration steps: +- use `EmailLinkError` instead of `MagicLinkError` +- use `isEmailLinkError` instead of `isMagicLinkError` +- use `EmailLinkErrorCode` instead of `MagicLinkErrorCode` +- use `useEmailLink` instead of `useMagicLink` +- use `buildRequestUrl` from `@clerk/backend` instead of `getRequestUrl` from `@clerk/shared` +- use `OrganizationProvider` instead of `OrganizationContext` +- use `userMemberships` instead of `organizationList` from `useOrganizationList` \ No newline at end of file diff --git a/packages/clerk-js/src/ui/hooks/__tests__/useCoreOrganizationList.test.tsx b/packages/clerk-js/src/ui/hooks/__tests__/useCoreOrganizationList.test.tsx index 381fb568e6..c69d7e72d2 100644 --- a/packages/clerk-js/src/ui/hooks/__tests__/useCoreOrganizationList.test.tsx +++ b/packages/clerk-js/src/ui/hooks/__tests__/useCoreOrganizationList.test.tsx @@ -38,15 +38,6 @@ describe('useOrganizationList', () => { expect(result.current.isLoaded).toBe(true); expect(result.current.setActive).toBeDefined(); expect(result.current.createOrganization).toBeDefined(); - expect(result.current.organizationList).toEqual( - expect.arrayContaining([ - expect.objectContaining({ - membership: expect.objectContaining({ - role: 'basic_member', - }), - }), - ]), - ); expect(result.current.userInvitations).toEqual( expect.objectContaining({ diff --git a/packages/react/src/contexts/OrganizationContext.tsx b/packages/react/src/contexts/OrganizationContext.tsx index f6f820acfa..099dc09105 100644 --- a/packages/react/src/contexts/OrganizationContext.tsx +++ b/packages/react/src/contexts/OrganizationContext.tsx @@ -1 +1 @@ -export { OrganizationProvider, OrganizationContext, useOrganizationContext } from '@clerk/shared/react'; +export { OrganizationProvider, useOrganizationContext } from '@clerk/shared/react'; diff --git a/packages/shared/src/error.ts b/packages/shared/src/error.ts index 4822117503..8f35f232a6 100644 --- a/packages/shared/src/error.ts +++ b/packages/shared/src/error.ts @@ -1,7 +1,5 @@ import type { ClerkAPIError, ClerkAPIErrorJSON } from '@clerk/types'; -import { deprecated } from './deprecated'; - export function isUnauthorizedError(e: any): boolean { const status = e?.status; const code = e?.errors?.[0]?.code; @@ -169,20 +167,6 @@ export class ClerkRuntimeError extends Error { }; } -/** - * @deprecated Use `EmailLinkError` instead. - */ -export class MagicLinkError extends Error { - code: string; - - constructor(code: string) { - super(code); - this.code = code; - Object.setPrototypeOf(this, MagicLinkError.prototype); - deprecated('MagicLinkError', 'Use `EmailLinkError` instead.'); - } -} - export class EmailLinkError extends Error { code: string; @@ -193,34 +177,10 @@ export class EmailLinkError extends Error { } } -/** - * Check if the error is a MagicLinkError. - * @deprecated Use `isEmailLinkError` instead. - */ -export function isMagicLinkError(err: Error): err is MagicLinkError { - deprecated('isMagicLinkError', 'Use `isEmailLinkError` instead.'); - return err instanceof MagicLinkError; -} - export function isEmailLinkError(err: Error): err is EmailLinkError { return err instanceof EmailLinkError; } -const _MagicLinkErrorCode = { - Expired: 'expired', - Failed: 'failed', -}; - -/** - * @deprecated Use `EmailLinkErrorCode` instead. - */ -export const MagicLinkErrorCode = new Proxy(_MagicLinkErrorCode, { - get(target, prop, receiver) { - deprecated('MagicLinkErrorCode', 'Use `EmailLinkErrorCode` instead.'); - return Reflect.get(target, prop, receiver); - }, -}); - export const EmailLinkErrorCode = { Expired: 'expired', Failed: 'failed', diff --git a/packages/shared/src/proxy.ts b/packages/shared/src/proxy.ts index 6d877d9bbd..4ca38b9e3d 100644 --- a/packages/shared/src/proxy.ts +++ b/packages/shared/src/proxy.ts @@ -1,5 +1,3 @@ -import { deprecated } from './deprecated'; - export function isValidProxyUrl(key: string | undefined) { if (!key) { return true; @@ -22,20 +20,3 @@ export function proxyUrlToAbsoluteURL(url: string | undefined): string { } return isProxyUrlRelative(url) ? new URL(url, window.location.origin).toString() : url; } - -/** - * @deprecated Use `buildRequestUrl` from @clerk/backend - */ -export function getRequestUrl({ request, relativePath }: { request: Request; relativePath?: string }): URL { - deprecated('getRequestUrl', 'Use `buildRequestUrl` from @clerk/backend instead.'); - const { headers, url: initialUrl } = request; - const url = new URL(initialUrl); - const host = headers.get('X-Forwarded-Host') ?? headers.get('host') ?? (headers as any)['host'] ?? url.host; - - // X-Forwarded-Proto could be 'https, http' - let protocol = - (headers.get('X-Forwarded-Proto') ?? (headers as any)['X-Forwarded-Proto'])?.split(',')[0] ?? url.protocol; - protocol = protocol.replace(/[:/]/, ''); - - return new URL(relativePath || url.pathname, `${protocol}://${host}`); -} diff --git a/packages/shared/src/react/contexts.tsx b/packages/shared/src/react/contexts.tsx index 6a50243766..de372140a8 100644 --- a/packages/shared/src/react/contexts.tsx +++ b/packages/shared/src/react/contexts.tsx @@ -4,15 +4,12 @@ import type { ActiveSessionResource, ClientResource, LoadedClerk, - OrganizationInvitationResource, - OrganizationMembershipResource, OrganizationResource, UserResource, } from '@clerk/types'; import type { PropsWithChildren } from 'react'; import React from 'react'; -import { deprecated } from '../deprecated'; import { SWRConfig } from './clerk-swr'; import { createContextAndHook } from './hooks/createContextAndHook'; @@ -53,14 +50,6 @@ const OrganizationProvider = ({ ); }; -/** - * @deprecated use OrganizationProvider instead - */ -export const OrganizationContext = (...args: Parameters) => { - deprecated('OrganizationContext', 'Use `OrganizationProvider` instead'); - return OrganizationProvider(...args); -}; - export { ClientContext, useClientContext, diff --git a/packages/shared/src/react/hooks/useOrganizationList.tsx b/packages/shared/src/react/hooks/useOrganizationList.tsx index e78148d9a5..80dc52e0af 100644 --- a/packages/shared/src/react/hooks/useOrganizationList.tsx +++ b/packages/shared/src/react/hooks/useOrganizationList.tsx @@ -11,7 +11,6 @@ import type { UserOrganizationInvitationResource, } from '@clerk/types'; -import { deprecatedObjectProperty } from '../../deprecated'; import { useClerkInstanceContext, useUserContext } from '../contexts'; import type { PaginatedResources, PaginatedResourcesWithDefault } from '../types'; import { usePagesOrInfinite, useWithSafeValues } from './usePagesOrInfinite'; @@ -37,7 +36,6 @@ type UseOrganizationListParams = { }); }; -type OrganizationList = ReturnType; const undefinedPaginatedResource = { data: undefined, count: undefined, @@ -60,10 +58,6 @@ type UseOrganizationList = ( ) => | { isLoaded: false; - /** - * @deprecated Use userMemberships instead - */ - organizationList: undefined; createOrganization: undefined; setActive: undefined; userMemberships: PaginatedResourcesWithDefault; @@ -72,10 +66,6 @@ type UseOrganizationList = ( } | { isLoaded: boolean; - /** - * @deprecated Use userMemberships instead - */ - organizationList: OrganizationList; createOrganization: (params: CreateOrganizationParams) => Promise; setActive: SetActive; userMemberships: PaginatedResources< @@ -208,7 +198,6 @@ export const useOrganizationList: UseOrganizationList = params => { if (!isClerkLoaded) { return { isLoaded: false, - organizationList: undefined, createOrganization: undefined, setActive: undefined, userMemberships: undefinedPaginatedResource, @@ -217,23 +206,12 @@ export const useOrganizationList: UseOrganizationList = params => { }; } - const result = { + return { isLoaded: isClerkLoaded, - organizationList: createOrganizationList(user.organizationMemberships), setActive: clerk.setActive, createOrganization: clerk.createOrganization, userMemberships: memberships, userInvitations: invitations, userSuggestions: suggestions, }; - deprecatedObjectProperty(result, 'organizationList', 'Use `userMemberships` instead.'); - - return result; }; - -function createOrganizationList(organizationMemberships: OrganizationMembershipResource[]) { - return organizationMemberships.map(organizationMembership => ({ - membership: organizationMembership, - organization: organizationMembership.organization, - })); -} diff --git a/packages/shared/src/react/index.ts b/packages/shared/src/react/index.ts index f1c1afd549..1a4c596806 100644 --- a/packages/shared/src/react/index.ts +++ b/packages/shared/src/react/index.ts @@ -3,7 +3,6 @@ export * from './hooks'; export { ClerkInstanceContext, ClientContext, - OrganizationContext, OrganizationProvider, SessionContext, useClerkInstanceContext,