diff --git a/.changeset/fluffy-beers-bet.md b/.changeset/fluffy-beers-bet.md new file mode 100644 index 00000000000..d77a139d81e --- /dev/null +++ b/.changeset/fluffy-beers-bet.md @@ -0,0 +1,7 @@ +--- +'@clerk/clerk-js': minor +'@clerk/types': minor +--- + +[Billing Beta]: Update prefix for checkout status +Replaces `awaiting_` with `needs_`. diff --git a/packages/clerk-js/src/core/modules/checkout/__tests__/manager.spec.ts b/packages/clerk-js/src/core/modules/checkout/__tests__/manager.spec.ts index d9b2bd13aa9..d897309b08d 100644 --- a/packages/clerk-js/src/core/modules/checkout/__tests__/manager.spec.ts +++ b/packages/clerk-js/src/core/modules/checkout/__tests__/manager.spec.ts @@ -72,7 +72,7 @@ describe('createCheckoutManager', () => { error: null, checkout: null, fetchStatus: 'idle', - status: 'awaiting_initialization', + status: 'needs_initialization', }); }); @@ -138,7 +138,7 @@ describe('createCheckoutManager', () => { isStarting: false, error: null, fetchStatus: 'idle', - status: 'awaiting_confirmation', + status: 'needs_confirmation', }); expect(listener1).toHaveBeenCalledWith(expectedState); @@ -186,7 +186,7 @@ describe('createCheckoutManager', () => { checkout: mockCheckout, error: null, fetchStatus: 'idle', - status: 'awaiting_confirmation', + status: 'needs_confirmation', }), ); }); @@ -230,7 +230,7 @@ describe('createCheckoutManager', () => { isStarting: false, error: mockError, fetchStatus: 'error', - status: 'awaiting_initialization', + status: 'needs_initialization', }), ); }); @@ -473,7 +473,7 @@ describe('createCheckoutManager', () => { error: null, checkout: null, fetchStatus: 'idle', - status: 'awaiting_initialization', + status: 'needs_initialization', }); // Should notify listeners @@ -515,7 +515,7 @@ describe('createCheckoutManager', () => { manager.clearCheckout(); state = manager.getCacheState(); expect(state.checkout).toBeNull(); - expect(state.status).toBe('awaiting_initialization'); + expect(state.status).toBe('needs_initialization'); }); }); @@ -554,17 +554,17 @@ describe('createCheckoutManager', () => { }); it('should derive status based on checkout state', async () => { - // Initially awaiting initialization - expect(manager.getCacheState().status).toBe('awaiting_initialization'); + // Initially needs initialization + expect(manager.getCacheState().status).toBe('needs_initialization'); - // After starting checkout - awaiting confirmation + // After starting checkout - needs confirmation const pendingCheckout = createMockCheckoutResource({ status: 'pending' }); const startOperation: MockedFunction<() => Promise> = vi .fn() .mockResolvedValue(pendingCheckout); await manager.executeOperation('start', startOperation); - expect(manager.getCacheState().status).toBe('awaiting_confirmation'); + expect(manager.getCacheState().status).toBe('needs_confirmation'); // After completing checkout - completed const completedCheckout = createMockCheckoutResource({ status: 'completed' }); @@ -631,7 +631,7 @@ describe('createCheckoutManager', () => { const state2 = manager2.getCacheState(); expect(state1.checkout?.id).toBe('checkout1'); - expect(state1.status).toBe('awaiting_confirmation'); + expect(state1.status).toBe('needs_confirmation'); expect(state2.checkout?.id).toBe('checkout2'); expect(state2.isStarting).toBe(false); diff --git a/packages/clerk-js/src/core/modules/checkout/manager.ts b/packages/clerk-js/src/core/modules/checkout/manager.ts index c49a504567a..54aeb02814f 100644 --- a/packages/clerk-js/src/core/modules/checkout/manager.ts +++ b/packages/clerk-js/src/core/modules/checkout/manager.ts @@ -36,8 +36,8 @@ const createManagerCache = () => { const managerCache = createManagerCache(); const CHECKOUT_STATUS = { - AWAITING_INITIALIZATION: 'awaiting_initialization', - AWAITING_CONFIRMATION: 'awaiting_confirmation', + NEEDS_INITIALIZATION: 'needs_initialization', + NEEDS_CONFIRMATION: 'needs_confirmation', COMPLETED: 'completed', } as const; @@ -61,8 +61,8 @@ function deriveCheckoutState( const status = (() => { if (baseState.checkout?.status === CHECKOUT_STATUS.COMPLETED) return CHECKOUT_STATUS.COMPLETED; - if (baseState.checkout) return CHECKOUT_STATUS.AWAITING_CONFIRMATION; - return CHECKOUT_STATUS.AWAITING_INITIALIZATION; + if (baseState.checkout) return CHECKOUT_STATUS.NEEDS_CONFIRMATION; + return CHECKOUT_STATUS.NEEDS_INITIALIZATION; })(); return { diff --git a/packages/clerk-js/src/ui/components/Checkout/index.tsx b/packages/clerk-js/src/ui/components/Checkout/index.tsx index 1cd414286e8..32ffbf6f25f 100644 --- a/packages/clerk-js/src/ui/components/Checkout/index.tsx +++ b/packages/clerk-js/src/ui/components/Checkout/index.tsx @@ -23,7 +23,7 @@ export const Checkout = (props: __internal_CheckoutProps) => { - + { - + diff --git a/packages/types/src/clerk.ts b/packages/types/src/clerk.ts index 290d0adaafb..6ea1c7c6c42 100644 --- a/packages/types/src/clerk.ts +++ b/packages/types/src/clerk.ts @@ -60,7 +60,7 @@ import type { UserResource } from './user'; import type { Autocomplete, DeepPartial, DeepSnakeToCamel } from './utils'; import type { WaitlistResource } from './waitlist'; -type __experimental_CheckoutStatus = 'awaiting_initialization' | 'awaiting_confirmation' | 'completed'; +type __experimental_CheckoutStatus = 'needs_initialization' | 'needs_confirmation' | 'completed'; export type __experimental_CheckoutCacheState = Readonly<{ isStarting: boolean;