-
Notifications
You must be signed in to change notification settings - Fork 386
chore(shared,clerk-js): Align for
payer type across billing APIs
#6423
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
🦋 Changeset detectedLatest commit: 01fc05c The changes in this PR will be included in the next version bump. This PR includes changesets to release 22 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
📝 WalkthroughWalkthroughThis change updates the terminology and type system for payer types across multiple packages. The string literal Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20–25 minutes Suggested labels
Suggested reviewers
Note ⚡️ Unit Test Generation is now available in beta!Learn more here, or try it out under "Finishing Touches" below. 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (33)
💤 Files with no reviewable changes (1)
✅ Files skipped from review due to trivial changes (2)
🚧 Files skipped from review as they are similar to previous changes (30)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (28)
.changeset/some-parents-begin.md
(1 hunks)packages/clerk-js/src/core/modules/commerce/CommerceBilling.ts
(1 hunks)packages/clerk-js/src/core/resources/CommercePlan.ts
(2 hunks)packages/clerk-js/src/ui/components/Checkout/CheckoutForm.tsx
(2 hunks)packages/clerk-js/src/ui/components/Checkout/CheckoutPage.tsx
(1 hunks)packages/clerk-js/src/ui/components/Checkout/index.tsx
(1 hunks)packages/clerk-js/src/ui/components/OrganizationProfile/OrganizationBillingPage.tsx
(1 hunks)packages/clerk-js/src/ui/components/OrganizationProfile/OrganizationPaymentAttemptPage.tsx
(1 hunks)packages/clerk-js/src/ui/components/OrganizationProfile/OrganizationPlansPage.tsx
(1 hunks)packages/clerk-js/src/ui/components/OrganizationProfile/OrganizationStatementPage.tsx
(1 hunks)packages/clerk-js/src/ui/components/PaymentSources/PaymentSources.tsx
(4 hunks)packages/clerk-js/src/ui/components/Plans/PlanDetails.tsx
(1 hunks)packages/clerk-js/src/ui/components/SubscriptionDetails/index.tsx
(3 hunks)packages/clerk-js/src/ui/components/Subscriptions/SubscriptionsList.tsx
(1 hunks)packages/clerk-js/src/ui/contexts/ClerkUIComponentsContext.tsx
(1 hunks)packages/clerk-js/src/ui/contexts/components/Checkout.ts
(0 hunks)packages/clerk-js/src/ui/contexts/components/Plans.tsx
(6 hunks)packages/clerk-js/src/ui/contexts/components/SubscriberType.ts
(1 hunks)packages/clerk-js/src/ui/lazyModules/MountedCheckoutDrawer.tsx
(1 hunks)packages/shared/src/react/commerce.tsx
(6 hunks)packages/shared/src/react/contexts.tsx
(2 hunks)packages/shared/src/react/hooks/createCommerceHook.tsx
(3 hunks)packages/shared/src/react/hooks/useCheckout.ts
(2 hunks)packages/shared/src/react/hooks/usePlans.tsx
(1 hunks)packages/shared/src/react/hooks/useSubscription.tsx
(2 hunks)packages/types/src/clerk.ts
(6 hunks)packages/types/src/commerce.ts
(3 hunks)packages/types/src/json.ts
(2 hunks)
💤 Files with no reviewable changes (1)
- packages/clerk-js/src/ui/contexts/components/Checkout.ts
🧰 Additional context used
📓 Path-based instructions (11)
packages/clerk-js/src/ui/**/*.{ts,tsx}
📄 CodeRabbit Inference Engine (.cursor/rules/clerk-js-ui.mdc)
packages/clerk-js/src/ui/**/*.{ts,tsx}
: Element descriptors should always be camelCase
Use element descriptors in UI components to enable consistent theming and styling via appearance.elements
Element descriptors should generate unique, stable CSS classes for theming
Element descriptors should handle state classes (e.g., cl-loading, cl-active, cl-error, cl-open) automatically based on component state
Do not render hard-coded values; all user-facing strings must be localized using provided localization methods
Use the useLocalizations hook and localizationKeys utility for all text and error messages
Use the styled system (sx prop, theme tokens, responsive values) for custom component styling
Use useCardState for card-level state, useFormState for form-level state, and useLoadingStatus for loading states
Always use handleError utility for API errors and use translateError for localized error messages
Use useFormControl for form field state, implement proper validation, and handle loading and error states in forms
Use localization keys for all form labels and placeholders
Use element descriptors for consistent styling and follow the theme token system
Use the Card and FormContainer patterns for consistent UI structure
Files:
packages/clerk-js/src/ui/components/OrganizationProfile/OrganizationStatementPage.tsx
packages/clerk-js/src/ui/components/Checkout/index.tsx
packages/clerk-js/src/ui/components/OrganizationProfile/OrganizationPlansPage.tsx
packages/clerk-js/src/ui/components/OrganizationProfile/OrganizationPaymentAttemptPage.tsx
packages/clerk-js/src/ui/components/OrganizationProfile/OrganizationBillingPage.tsx
packages/clerk-js/src/ui/components/SubscriptionDetails/index.tsx
packages/clerk-js/src/ui/lazyModules/MountedCheckoutDrawer.tsx
packages/clerk-js/src/ui/contexts/ClerkUIComponentsContext.tsx
packages/clerk-js/src/ui/components/Plans/PlanDetails.tsx
packages/clerk-js/src/ui/components/Checkout/CheckoutForm.tsx
packages/clerk-js/src/ui/components/Subscriptions/SubscriptionsList.tsx
packages/clerk-js/src/ui/components/Checkout/CheckoutPage.tsx
packages/clerk-js/src/ui/contexts/components/Plans.tsx
packages/clerk-js/src/ui/components/PaymentSources/PaymentSources.tsx
packages/clerk-js/src/ui/contexts/components/SubscriberType.ts
**/*.{js,jsx,ts,tsx}
📄 CodeRabbit Inference Engine (.cursor/rules/development.mdc)
**/*.{js,jsx,ts,tsx}
: All code must pass ESLint checks with the project's configuration
Follow established naming conventions (PascalCase for components, camelCase for variables)
Maintain comprehensive JSDoc comments for public APIs
Use dynamic imports for optional features
All public APIs must be documented with JSDoc
Provide meaningful error messages to developers
Include error recovery suggestions where applicable
Log errors appropriately for debugging
Lazy load components and features when possible
Implement proper caching strategies
Use efficient data structures and algorithms
Profile and optimize critical paths
Validate all inputs and sanitize outputs
Implement proper logging with different levels
Files:
packages/clerk-js/src/ui/components/OrganizationProfile/OrganizationStatementPage.tsx
packages/clerk-js/src/ui/components/Checkout/index.tsx
packages/clerk-js/src/ui/components/OrganizationProfile/OrganizationPlansPage.tsx
packages/clerk-js/src/ui/components/OrganizationProfile/OrganizationPaymentAttemptPage.tsx
packages/clerk-js/src/ui/components/OrganizationProfile/OrganizationBillingPage.tsx
packages/clerk-js/src/ui/components/SubscriptionDetails/index.tsx
packages/shared/src/react/contexts.tsx
packages/clerk-js/src/core/modules/commerce/CommerceBilling.ts
packages/clerk-js/src/ui/lazyModules/MountedCheckoutDrawer.tsx
packages/clerk-js/src/core/resources/CommercePlan.ts
packages/types/src/json.ts
packages/clerk-js/src/ui/contexts/ClerkUIComponentsContext.tsx
packages/clerk-js/src/ui/components/Plans/PlanDetails.tsx
packages/shared/src/react/hooks/useSubscription.tsx
packages/clerk-js/src/ui/components/Checkout/CheckoutForm.tsx
packages/shared/src/react/hooks/usePlans.tsx
packages/clerk-js/src/ui/components/Subscriptions/SubscriptionsList.tsx
packages/clerk-js/src/ui/components/Checkout/CheckoutPage.tsx
packages/clerk-js/src/ui/contexts/components/Plans.tsx
packages/clerk-js/src/ui/components/PaymentSources/PaymentSources.tsx
packages/shared/src/react/hooks/useCheckout.ts
packages/shared/src/react/hooks/createCommerceHook.tsx
packages/types/src/commerce.ts
packages/clerk-js/src/ui/contexts/components/SubscriberType.ts
packages/shared/src/react/commerce.tsx
packages/types/src/clerk.ts
**/*.{js,jsx,ts,tsx,json,css,scss,md,yaml,yml}
📄 CodeRabbit Inference Engine (.cursor/rules/development.mdc)
Use Prettier for consistent code formatting
Files:
packages/clerk-js/src/ui/components/OrganizationProfile/OrganizationStatementPage.tsx
packages/clerk-js/src/ui/components/Checkout/index.tsx
packages/clerk-js/src/ui/components/OrganizationProfile/OrganizationPlansPage.tsx
packages/clerk-js/src/ui/components/OrganizationProfile/OrganizationPaymentAttemptPage.tsx
packages/clerk-js/src/ui/components/OrganizationProfile/OrganizationBillingPage.tsx
packages/clerk-js/src/ui/components/SubscriptionDetails/index.tsx
packages/shared/src/react/contexts.tsx
packages/clerk-js/src/core/modules/commerce/CommerceBilling.ts
packages/clerk-js/src/ui/lazyModules/MountedCheckoutDrawer.tsx
packages/clerk-js/src/core/resources/CommercePlan.ts
packages/types/src/json.ts
packages/clerk-js/src/ui/contexts/ClerkUIComponentsContext.tsx
packages/clerk-js/src/ui/components/Plans/PlanDetails.tsx
packages/shared/src/react/hooks/useSubscription.tsx
packages/clerk-js/src/ui/components/Checkout/CheckoutForm.tsx
packages/shared/src/react/hooks/usePlans.tsx
packages/clerk-js/src/ui/components/Subscriptions/SubscriptionsList.tsx
packages/clerk-js/src/ui/components/Checkout/CheckoutPage.tsx
packages/clerk-js/src/ui/contexts/components/Plans.tsx
packages/clerk-js/src/ui/components/PaymentSources/PaymentSources.tsx
packages/shared/src/react/hooks/useCheckout.ts
packages/shared/src/react/hooks/createCommerceHook.tsx
packages/types/src/commerce.ts
packages/clerk-js/src/ui/contexts/components/SubscriberType.ts
packages/shared/src/react/commerce.tsx
packages/types/src/clerk.ts
packages/**/*.{ts,tsx}
📄 CodeRabbit Inference Engine (.cursor/rules/development.mdc)
TypeScript is required for all packages
Files:
packages/clerk-js/src/ui/components/OrganizationProfile/OrganizationStatementPage.tsx
packages/clerk-js/src/ui/components/Checkout/index.tsx
packages/clerk-js/src/ui/components/OrganizationProfile/OrganizationPlansPage.tsx
packages/clerk-js/src/ui/components/OrganizationProfile/OrganizationPaymentAttemptPage.tsx
packages/clerk-js/src/ui/components/OrganizationProfile/OrganizationBillingPage.tsx
packages/clerk-js/src/ui/components/SubscriptionDetails/index.tsx
packages/shared/src/react/contexts.tsx
packages/clerk-js/src/core/modules/commerce/CommerceBilling.ts
packages/clerk-js/src/ui/lazyModules/MountedCheckoutDrawer.tsx
packages/clerk-js/src/core/resources/CommercePlan.ts
packages/types/src/json.ts
packages/clerk-js/src/ui/contexts/ClerkUIComponentsContext.tsx
packages/clerk-js/src/ui/components/Plans/PlanDetails.tsx
packages/shared/src/react/hooks/useSubscription.tsx
packages/clerk-js/src/ui/components/Checkout/CheckoutForm.tsx
packages/shared/src/react/hooks/usePlans.tsx
packages/clerk-js/src/ui/components/Subscriptions/SubscriptionsList.tsx
packages/clerk-js/src/ui/components/Checkout/CheckoutPage.tsx
packages/clerk-js/src/ui/contexts/components/Plans.tsx
packages/clerk-js/src/ui/components/PaymentSources/PaymentSources.tsx
packages/shared/src/react/hooks/useCheckout.ts
packages/shared/src/react/hooks/createCommerceHook.tsx
packages/types/src/commerce.ts
packages/clerk-js/src/ui/contexts/components/SubscriberType.ts
packages/shared/src/react/commerce.tsx
packages/types/src/clerk.ts
packages/**/*.{ts,tsx,d.ts}
📄 CodeRabbit Inference Engine (.cursor/rules/development.mdc)
Packages should export TypeScript types alongside runtime code
Files:
packages/clerk-js/src/ui/components/OrganizationProfile/OrganizationStatementPage.tsx
packages/clerk-js/src/ui/components/Checkout/index.tsx
packages/clerk-js/src/ui/components/OrganizationProfile/OrganizationPlansPage.tsx
packages/clerk-js/src/ui/components/OrganizationProfile/OrganizationPaymentAttemptPage.tsx
packages/clerk-js/src/ui/components/OrganizationProfile/OrganizationBillingPage.tsx
packages/clerk-js/src/ui/components/SubscriptionDetails/index.tsx
packages/shared/src/react/contexts.tsx
packages/clerk-js/src/core/modules/commerce/CommerceBilling.ts
packages/clerk-js/src/ui/lazyModules/MountedCheckoutDrawer.tsx
packages/clerk-js/src/core/resources/CommercePlan.ts
packages/types/src/json.ts
packages/clerk-js/src/ui/contexts/ClerkUIComponentsContext.tsx
packages/clerk-js/src/ui/components/Plans/PlanDetails.tsx
packages/shared/src/react/hooks/useSubscription.tsx
packages/clerk-js/src/ui/components/Checkout/CheckoutForm.tsx
packages/shared/src/react/hooks/usePlans.tsx
packages/clerk-js/src/ui/components/Subscriptions/SubscriptionsList.tsx
packages/clerk-js/src/ui/components/Checkout/CheckoutPage.tsx
packages/clerk-js/src/ui/contexts/components/Plans.tsx
packages/clerk-js/src/ui/components/PaymentSources/PaymentSources.tsx
packages/shared/src/react/hooks/useCheckout.ts
packages/shared/src/react/hooks/createCommerceHook.tsx
packages/types/src/commerce.ts
packages/clerk-js/src/ui/contexts/components/SubscriberType.ts
packages/shared/src/react/commerce.tsx
packages/types/src/clerk.ts
**/*.{ts,tsx}
📄 CodeRabbit Inference Engine (.cursor/rules/development.mdc)
Use proper TypeScript error types
**/*.{ts,tsx}
: Always define explicit return types for functions, especially public APIs
Use proper type annotations for variables and parameters where inference isn't clear
Avoidany
type - preferunknown
when type is uncertain, then narrow with type guards
Useinterface
for object shapes that might be extended
Usetype
for unions, primitives, and computed types
Preferreadonly
properties for immutable data structures
Useprivate
for internal implementation details
Useprotected
for inheritance hierarchies
Usepublic
explicitly for clarity in public APIs
Preferreadonly
for properties that shouldn't change after construction
Prefer composition and interfaces over deep inheritance chains
Use mixins for shared behavior across unrelated classes
Implement dependency injection for loose coupling
Let TypeScript infer when types are obvious
Useconst assertions
for literal types:as const
Usesatisfies
operator for type checking without widening
Use mapped types for transforming object types
Use conditional types for type-level logic
Leverage template literal types for string manipulation
Use ES6 imports/exports consistently
Use default exports sparingly, prefer named exports
Use type-only imports:import type { ... } from ...
Noany
types without justification
Proper error handling with typed errors
Consistent use ofreadonly
for immutable data
Proper generic constraints
No unused type parameters
Proper use of utility types instead of manual type construction
Type-only imports where possible
Proper tree-shaking friendly exports
No circular dependencies
Efficient type computations (avoid deep recursion)
Files:
packages/clerk-js/src/ui/components/OrganizationProfile/OrganizationStatementPage.tsx
packages/clerk-js/src/ui/components/Checkout/index.tsx
packages/clerk-js/src/ui/components/OrganizationProfile/OrganizationPlansPage.tsx
packages/clerk-js/src/ui/components/OrganizationProfile/OrganizationPaymentAttemptPage.tsx
packages/clerk-js/src/ui/components/OrganizationProfile/OrganizationBillingPage.tsx
packages/clerk-js/src/ui/components/SubscriptionDetails/index.tsx
packages/shared/src/react/contexts.tsx
packages/clerk-js/src/core/modules/commerce/CommerceBilling.ts
packages/clerk-js/src/ui/lazyModules/MountedCheckoutDrawer.tsx
packages/clerk-js/src/core/resources/CommercePlan.ts
packages/types/src/json.ts
packages/clerk-js/src/ui/contexts/ClerkUIComponentsContext.tsx
packages/clerk-js/src/ui/components/Plans/PlanDetails.tsx
packages/shared/src/react/hooks/useSubscription.tsx
packages/clerk-js/src/ui/components/Checkout/CheckoutForm.tsx
packages/shared/src/react/hooks/usePlans.tsx
packages/clerk-js/src/ui/components/Subscriptions/SubscriptionsList.tsx
packages/clerk-js/src/ui/components/Checkout/CheckoutPage.tsx
packages/clerk-js/src/ui/contexts/components/Plans.tsx
packages/clerk-js/src/ui/components/PaymentSources/PaymentSources.tsx
packages/shared/src/react/hooks/useCheckout.ts
packages/shared/src/react/hooks/createCommerceHook.tsx
packages/types/src/commerce.ts
packages/clerk-js/src/ui/contexts/components/SubscriberType.ts
packages/shared/src/react/commerce.tsx
packages/types/src/clerk.ts
**/*.{jsx,tsx}
📄 CodeRabbit Inference Engine (.cursor/rules/development.mdc)
**/*.{jsx,tsx}
: Use error boundaries in React components
Minimize re-renders in React components
**/*.{jsx,tsx}
: Always use functional components with hooks instead of class components
Follow PascalCase naming for components:UserProfile
,NavigationMenu
Keep components focused on a single responsibility - split large components
Limit component size to 150-200 lines; extract logic into custom hooks
Use composition over inheritance - prefer smaller, composable components
Export components as named exports for better tree-shaking
One component per file with matching filename and component name
Use useState for simple state management
Use useReducer for complex state logic
Implement proper state initialization
Use proper state updates with callbacks
Implement proper state cleanup
Use Context API for theme/authentication
Implement proper state selectors
Use proper state normalization
Implement proper state persistence
Use React.memo for expensive components
Implement proper useCallback for handlers
Use proper useMemo for expensive computations
Implement proper virtualization for lists
Use proper code splitting with React.lazy
Implement proper cleanup in useEffect
Use proper refs for DOM access
Implement proper event listener cleanup
Use proper abort controllers for fetch
Implement proper subscription cleanup
Use proper HTML elements
Implement proper ARIA attributes
Use proper heading hierarchy
Implement proper form labels
Use proper button types
Implement proper focus management
Use proper keyboard shortcuts
Implement proper tab order
Use proper skip links
Implement proper focus traps
Implement proper error boundaries
Use proper error logging
Implement proper error recovery
Use proper error messages
Implement proper error fallbacks
Use proper form validation
Implement proper error states
Use proper error messages
Implement proper form submission
Use proper form reset
Use proper component naming
Implement proper file naming
Use proper prop naming
Implement proper...
Files:
packages/clerk-js/src/ui/components/OrganizationProfile/OrganizationStatementPage.tsx
packages/clerk-js/src/ui/components/Checkout/index.tsx
packages/clerk-js/src/ui/components/OrganizationProfile/OrganizationPlansPage.tsx
packages/clerk-js/src/ui/components/OrganizationProfile/OrganizationPaymentAttemptPage.tsx
packages/clerk-js/src/ui/components/OrganizationProfile/OrganizationBillingPage.tsx
packages/clerk-js/src/ui/components/SubscriptionDetails/index.tsx
packages/shared/src/react/contexts.tsx
packages/clerk-js/src/ui/lazyModules/MountedCheckoutDrawer.tsx
packages/clerk-js/src/ui/contexts/ClerkUIComponentsContext.tsx
packages/clerk-js/src/ui/components/Plans/PlanDetails.tsx
packages/shared/src/react/hooks/useSubscription.tsx
packages/clerk-js/src/ui/components/Checkout/CheckoutForm.tsx
packages/shared/src/react/hooks/usePlans.tsx
packages/clerk-js/src/ui/components/Subscriptions/SubscriptionsList.tsx
packages/clerk-js/src/ui/components/Checkout/CheckoutPage.tsx
packages/clerk-js/src/ui/contexts/components/Plans.tsx
packages/clerk-js/src/ui/components/PaymentSources/PaymentSources.tsx
packages/shared/src/react/hooks/createCommerceHook.tsx
packages/shared/src/react/commerce.tsx
**/*.{js,ts,tsx,jsx}
📄 CodeRabbit Inference Engine (.cursor/rules/monorepo.mdc)
Support multiple Clerk environment variables (CLERK_, NEXT_PUBLIC_CLERK_, etc.) for configuration.
Files:
packages/clerk-js/src/ui/components/OrganizationProfile/OrganizationStatementPage.tsx
packages/clerk-js/src/ui/components/Checkout/index.tsx
packages/clerk-js/src/ui/components/OrganizationProfile/OrganizationPlansPage.tsx
packages/clerk-js/src/ui/components/OrganizationProfile/OrganizationPaymentAttemptPage.tsx
packages/clerk-js/src/ui/components/OrganizationProfile/OrganizationBillingPage.tsx
packages/clerk-js/src/ui/components/SubscriptionDetails/index.tsx
packages/shared/src/react/contexts.tsx
packages/clerk-js/src/core/modules/commerce/CommerceBilling.ts
packages/clerk-js/src/ui/lazyModules/MountedCheckoutDrawer.tsx
packages/clerk-js/src/core/resources/CommercePlan.ts
packages/types/src/json.ts
packages/clerk-js/src/ui/contexts/ClerkUIComponentsContext.tsx
packages/clerk-js/src/ui/components/Plans/PlanDetails.tsx
packages/shared/src/react/hooks/useSubscription.tsx
packages/clerk-js/src/ui/components/Checkout/CheckoutForm.tsx
packages/shared/src/react/hooks/usePlans.tsx
packages/clerk-js/src/ui/components/Subscriptions/SubscriptionsList.tsx
packages/clerk-js/src/ui/components/Checkout/CheckoutPage.tsx
packages/clerk-js/src/ui/contexts/components/Plans.tsx
packages/clerk-js/src/ui/components/PaymentSources/PaymentSources.tsx
packages/shared/src/react/hooks/useCheckout.ts
packages/shared/src/react/hooks/createCommerceHook.tsx
packages/types/src/commerce.ts
packages/clerk-js/src/ui/contexts/components/SubscriberType.ts
packages/shared/src/react/commerce.tsx
packages/types/src/clerk.ts
**/*.tsx
📄 CodeRabbit Inference Engine (.cursor/rules/react.mdc)
**/*.tsx
: Use proper type definitions for props and state
Leverage TypeScript's type inference where possible
Use proper event types for handlers
Implement proper generic types for reusable components
Use proper type guards for conditional rendering
Files:
packages/clerk-js/src/ui/components/OrganizationProfile/OrganizationStatementPage.tsx
packages/clerk-js/src/ui/components/Checkout/index.tsx
packages/clerk-js/src/ui/components/OrganizationProfile/OrganizationPlansPage.tsx
packages/clerk-js/src/ui/components/OrganizationProfile/OrganizationPaymentAttemptPage.tsx
packages/clerk-js/src/ui/components/OrganizationProfile/OrganizationBillingPage.tsx
packages/clerk-js/src/ui/components/SubscriptionDetails/index.tsx
packages/shared/src/react/contexts.tsx
packages/clerk-js/src/ui/lazyModules/MountedCheckoutDrawer.tsx
packages/clerk-js/src/ui/contexts/ClerkUIComponentsContext.tsx
packages/clerk-js/src/ui/components/Plans/PlanDetails.tsx
packages/shared/src/react/hooks/useSubscription.tsx
packages/clerk-js/src/ui/components/Checkout/CheckoutForm.tsx
packages/shared/src/react/hooks/usePlans.tsx
packages/clerk-js/src/ui/components/Subscriptions/SubscriptionsList.tsx
packages/clerk-js/src/ui/components/Checkout/CheckoutPage.tsx
packages/clerk-js/src/ui/contexts/components/Plans.tsx
packages/clerk-js/src/ui/components/PaymentSources/PaymentSources.tsx
packages/shared/src/react/hooks/createCommerceHook.tsx
packages/shared/src/react/commerce.tsx
**/*
⚙️ CodeRabbit Configuration File
**/*
: If there are no tests added or modified as part of the PR, please suggest that tests be added to cover the changes.Whenever reviewing a pull request, if there are any changes that could impact security, always tag
@clerk/security
in the PR.Security-impacting changes include, but are not limited to:
- Changes to authentication logic or mechanisms (e.g. login, session handling, token issuance)
- Any modification to access control, authorization checks, or role-based permissions
- Introduction or modification of hashing algorithms, signature verification, or cryptographic primitives
- Handling of sensitive data (e.g. passwords, tokens, secrets, PII)
- Integration with external identity providers (e.g. SSO, OAuth, OpenID Connect)
- Modifications to security headers, cookie flags, CORS policies, or CSRF protections
- Bypass mechanisms (e.g. feature flags, testing overrides) that could weaken protections
- Changes to rate limiting, abuse prevention, or input validation
If you're unsure whether a change is security-relevant, err on the side of caution and tag
@clerk/security
.Any time that you tag
@clerk/security
, please do so explicitly in a code comment, rather than within a collapsed section in a coderabbit comment, such as the "recent review details" section. If you do use the team name in any thinking or non-direct-code-comment content, it can be referred to as "clerk security team" to avoid accidentally printing the tag which sends a notification to the team.
Files:
packages/clerk-js/src/ui/components/OrganizationProfile/OrganizationStatementPage.tsx
packages/clerk-js/src/ui/components/Checkout/index.tsx
packages/clerk-js/src/ui/components/OrganizationProfile/OrganizationPlansPage.tsx
packages/clerk-js/src/ui/components/OrganizationProfile/OrganizationPaymentAttemptPage.tsx
packages/clerk-js/src/ui/components/OrganizationProfile/OrganizationBillingPage.tsx
packages/clerk-js/src/ui/components/SubscriptionDetails/index.tsx
packages/shared/src/react/contexts.tsx
packages/clerk-js/src/core/modules/commerce/CommerceBilling.ts
packages/clerk-js/src/ui/lazyModules/MountedCheckoutDrawer.tsx
packages/clerk-js/src/core/resources/CommercePlan.ts
packages/types/src/json.ts
packages/clerk-js/src/ui/contexts/ClerkUIComponentsContext.tsx
packages/clerk-js/src/ui/components/Plans/PlanDetails.tsx
packages/shared/src/react/hooks/useSubscription.tsx
packages/clerk-js/src/ui/components/Checkout/CheckoutForm.tsx
packages/shared/src/react/hooks/usePlans.tsx
packages/clerk-js/src/ui/components/Subscriptions/SubscriptionsList.tsx
packages/clerk-js/src/ui/components/Checkout/CheckoutPage.tsx
packages/clerk-js/src/ui/contexts/components/Plans.tsx
packages/clerk-js/src/ui/components/PaymentSources/PaymentSources.tsx
packages/shared/src/react/hooks/useCheckout.ts
packages/shared/src/react/hooks/createCommerceHook.tsx
packages/types/src/commerce.ts
packages/clerk-js/src/ui/contexts/components/SubscriberType.ts
packages/shared/src/react/commerce.tsx
packages/types/src/clerk.ts
.changeset/**
📄 CodeRabbit Inference Engine (.cursor/rules/monorepo.mdc)
Automated releases must use Changesets.
Files:
.changeset/some-parents-begin.md
🧬 Code Graph Analysis (18)
packages/clerk-js/src/ui/components/OrganizationProfile/OrganizationStatementPage.tsx (1)
packages/clerk-js/src/ui/contexts/components/SubscriberType.ts (1)
SubscriberTypeContext
(5-5)
packages/clerk-js/src/ui/components/Checkout/index.tsx (1)
packages/clerk-js/src/ui/contexts/components/SubscriberType.ts (1)
SubscriberTypeContext
(5-5)
packages/clerk-js/src/ui/components/OrganizationProfile/OrganizationPlansPage.tsx (1)
packages/clerk-js/src/ui/contexts/components/SubscriberType.ts (1)
SubscriberTypeContext
(5-5)
packages/clerk-js/src/ui/components/OrganizationProfile/OrganizationPaymentAttemptPage.tsx (1)
packages/clerk-js/src/ui/contexts/components/SubscriberType.ts (1)
SubscriberTypeContext
(5-5)
packages/clerk-js/src/ui/components/OrganizationProfile/OrganizationBillingPage.tsx (1)
packages/clerk-js/src/ui/contexts/components/SubscriberType.ts (1)
SubscriberTypeContext
(5-5)
packages/clerk-js/src/ui/components/SubscriptionDetails/index.tsx (1)
packages/react/src/isomorphicClerk.ts (1)
organization
(680-686)
packages/shared/src/react/contexts.tsx (1)
packages/types/src/commerce.ts (1)
ForPayerType
(111-111)
packages/clerk-js/src/core/resources/CommercePlan.ts (1)
packages/types/src/commerce.ts (1)
CommercePayerResourceType
(101-101)
packages/types/src/json.ts (1)
packages/types/src/commerce.ts (1)
CommercePayerResourceType
(101-101)
packages/clerk-js/src/ui/contexts/ClerkUIComponentsContext.tsx (2)
packages/clerk-js/src/ui/contexts/components/SubscriberType.ts (1)
SubscriberTypeContext
(5-5)packages/types/src/clerk.ts (1)
PricingTableProps
(1781-1781)
packages/clerk-js/src/ui/components/Plans/PlanDetails.tsx (1)
packages/clerk-js/src/ui/contexts/components/SubscriberType.ts (1)
SubscriberTypeContext
(5-5)
packages/shared/src/react/hooks/useSubscription.tsx (1)
packages/types/src/commerce.ts (1)
ForPayerType
(111-111)
packages/clerk-js/src/ui/components/PaymentSources/PaymentSources.tsx (1)
packages/react/src/isomorphicClerk.ts (1)
organization
(680-686)
packages/shared/src/react/hooks/useCheckout.ts (1)
packages/shared/src/react/contexts.tsx (1)
__experimental_CheckoutProvider
(119-119)
packages/shared/src/react/hooks/createCommerceHook.tsx (3)
packages/types/src/commerce.ts (1)
ForPayerType
(111-111)packages/types/src/pagination.ts (1)
ClerkPaginatedResponse
(21-30)packages/shared/src/react/types.ts (1)
PaginatedResources
(14-80)
packages/clerk-js/src/ui/contexts/components/SubscriberType.ts (1)
packages/types/src/commerce.ts (1)
ForPayerType
(111-111)
packages/shared/src/react/commerce.tsx (3)
packages/types/src/commerce.ts (1)
ForPayerType
(111-111)packages/shared/src/react/hooks/index.ts (2)
useOrganization
(2-2)useUser
(7-7)packages/react/src/isomorphicClerk.ts (2)
organization
(680-686)user
(672-678)
packages/types/src/clerk.ts (1)
packages/types/src/commerce.ts (1)
ForPayerType
(111-111)
🪛 ESLint
packages/clerk-js/src/ui/components/Checkout/CheckoutForm.tsx
[error] 134-134: Unexpected constant truthiness on the left-hand side of a ||
expression.
(no-constant-binary-expression)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
- GitHub Check: semgrep-cloud-platform/scan
- GitHub Check: Formatting | Dedupe | Changeset
- GitHub Check: Build Packages
- GitHub Check: semgrep/ci
- GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (47)
packages/clerk-js/src/ui/components/OrganizationProfile/OrganizationStatementPage.tsx (1)
6-6
: LGTM: Consistent terminology updateThe change from
'org'
to'organization'
aligns with the broader refactor to standardize payer type terminology across billing APIs. The component structure remains clean and follows React best practices.packages/clerk-js/src/ui/components/OrganizationProfile/OrganizationPaymentAttemptPage.tsx (1)
6-6
: LGTM: Consistent with refactor patternThe terminology update from
'org'
to'organization'
is consistent with the standardization effort across all organization profile components.packages/clerk-js/src/ui/components/OrganizationProfile/OrganizationBillingPage.tsx (1)
86-86
: LGTM: Terminology standardization maintainedThe change from
'org'
to'organization'
is consistent with the refactor objectives. The component maintains its well-structured architecture with proper element descriptors, localization, and permission-based access control.packages/clerk-js/src/ui/components/OrganizationProfile/OrganizationPlansPage.tsx (1)
56-56
: LGTM: Consistent refactor implementationThe terminology update maintains consistency with the other organization profile components. The component structure demonstrates good practices with proper permission checking and context management.
.changeset/some-parents-begin.md (1)
1-10
: Approve: No remaining'org'
references found in billing codeI ran a targeted search across all billing-related files in
packages/clerk-js
and confirmed there are no lingering'org'
strings.• Changeset correctly documents replacing
org
→organization
and lists all affected packages.
• Minor version bump is appropriate; the exception for Frontend API resource classes is clearly noted.Next steps (non-blocking):
- Add or update tests to cover the new
organization
terminology in your billing APIs.- Tag
@clerk/security
for a quick review of any payment/billing implications.packages/clerk-js/src/ui/contexts/ClerkUIComponentsContext.tsx (1)
95-95
: All SubscriberTypeContext consumers inclerk-js
now use “organization”I’ve verified across
packages/clerk-js/src/ui
that there are no remaining=== 'org'
or!= 'org'
checks—every consumer now handles the'organization'
value correctly. No further changes are needed in this package.packages/clerk-js/src/ui/components/Checkout/index.tsx (1)
16-16
: LGTM! Proper prop name alignment and fallback handling.The change correctly updates the prop name from
subscriberType
tofor
and provides a sensible fallback to'user'
. This aligns with the broader refactor to standardize payer type naming and ensures the context always receives a validForPayerType
value.packages/shared/src/react/contexts.tsx (1)
7-7
: LGTM! Improved type safety with ForPayerType.The change from a hardcoded string literal
'organization'
to theForPayerType
type alias improves type safety and consistency with the broader refactor. This ensures that only valid payer type values ('organization' | 'user'
) can be used in checkout options.Also applies to: 29-29
packages/clerk-js/src/ui/lazyModules/MountedCheckoutDrawer.tsx (1)
43-43
: LGTM! Prop name standardization aligned with refactor.The change from
subscriberType
tofor
correctly aligns with the broader refactor to standardize prop naming across the checkout components. This maintains the same functionality while using the updated prop interface.packages/clerk-js/src/ui/components/Plans/PlanDetails.tsx (1)
61-61
: LGTM! Proper mapping from resource to UI context values.The conditional mapping correctly translates the resource's
'org'
value to the UI context's standardized'organization'
value, while providing a sensible fallback to'user'
. This approach maintains backward compatibility with existing resource data while ensuring the UI context uses the standardized payer type naming.packages/types/src/json.ts (1)
7-7
: LGTM! Type import and usage properly aligned with the refactor.The changes correctly update the import from
CommercePayerType
toCommercePayerResourceType
and apply it consistently to thefor_payer_type
property. This maintains the same string literal values ('org' | 'user'
) while using the new semantic type name that distinguishes resource-level types from external API types.Also applies to: 647-647
packages/clerk-js/src/core/resources/CommercePlan.ts (1)
1-6
: LGTM! Resource class correctly uses the resource-level type.The changes properly update the import and property type from
CommercePayerType
toCommercePayerResourceType
. This is appropriate for a resource class that represents data from the Frontend API, maintaining the original'org' | 'user'
string literals while using the semantically correct type name.Also applies to: 25-25
packages/shared/src/react/hooks/useSubscription.tsx (1)
1-1
: LGTM! Type consolidation improves consistency.The changes correctly replace the inline string literal union
'organization' | 'user'
with the centralizedForPayerType
type. This improves type safety and maintains consistency across the codebase while preserving the same string literal values.Also applies to: 16-16
packages/clerk-js/src/core/modules/commerce/CommerceBilling.ts (1)
36-37
: LGTM! Proper mapping between external and internal payer types.The changes correctly implement the mapping from the external-facing
'organization'
parameter to the internal API's'org'
value, while defaulting to'user'
. This maintains backward compatibility with the existing backend API while supporting the new standardized terminology in the UI layer.packages/clerk-js/src/ui/components/SubscriptionDetails/index.tsx (2)
192-192
: LGTM! Condition updated to use standardized payer type.The change correctly updates the condition from
subscriberType === 'org'
tosubscriberType === 'organization'
, aligning with the new standardized payer type naming convention throughout the codebase.
384-384
: LGTM! Parameter naming aligned with API conventions.The changes correctly update the parameter name from
subscriberType
tofor
when callingopenCheckout
, which aligns with the standardized parameter naming convention established across the billing APIs and components.Also applies to: 406-406
packages/clerk-js/src/ui/components/Subscriptions/SubscriptionsList.tsx (1)
200-200
: LGTM: Consistent payer type alignmentThe change from
'org'
to'organization'
correctly aligns with the PR objective to standardize payer type naming across billing APIs.packages/shared/src/react/hooks/usePlans.tsx (1)
14-17
: LGTM: Simplified parameter handlingGood refactoring that:
- Explicitly excludes
orgId
from forwarded parameters- Removes conditional mapping logic, delegating conversion to the API layer
- Directly passes the
_for
value, simplifying the implementationpackages/clerk-js/src/ui/components/Checkout/CheckoutForm.tsx (1)
118-118
: LGTM: Variable naming alignmentThe renaming from
subscriberType
tofor: _for
correctly aligns with the standardized parameter naming across the codebase.packages/clerk-js/src/ui/components/Checkout/CheckoutPage.tsx (2)
13-13
: Consider error handling for checkout.start()Removing error handling from
checkout.start().catch(() => null)
tovoid checkout.start()
means errors will no longer be caught. This could lead to unhandled promise rejections.Consider if error handling is needed or if errors are handled elsewhere in the checkout flow.
20-20
: LGTM: Simplified context usageThe changes correctly:
- Rename
subscriberType
tofor: _for
for consistency- Pass
_for
directly instead of using conditional logicAlso applies to: 24-24
packages/clerk-js/src/ui/contexts/components/SubscriberType.ts (1)
1-1
: LGTM: Type system alignmentThe type changes from
CommercePayerType
toForPayerType
correctly align with the codebase refactor. The newForPayerType
supports'organization' | 'user'
values as seen in the type definition, maintaining the same functionality while standardizing naming.Also applies to: 5-5, 7-7
packages/clerk-js/src/ui/contexts/components/Plans.tsx (2)
28-28
: LGTM! Simplified parameter passing.The removal of conditional mapping logic in favor of direct pass-through of
subscriberType
as thefor
parameter is a good simplification. This aligns with the broader refactor where the subscriber type context now directly provides the appropriate values ('organization'
or'user'
) that can be passed directly to the billing hooks.Also applies to: 38-38, 48-48, 59-59, 77-77
306-306
: LGTM! Consistent parameter naming.The property name change from
subscriberType
tofor
maintains consistency with the updated billing API parameter naming conventions throughout the codebase.packages/shared/src/react/hooks/useCheckout.ts (2)
9-9
: LGTM! Improved type alignment.Importing the
__experimental_CheckoutProvider
type instead ofCommerceSubscriptionPlanPeriod
allows the hook to derive its parameter type directly from the context provider, ensuring better type consistency.
48-50
: LGTM! Type consistency improvement.Using
Parameters<typeof __experimental_CheckoutProvider>[0]
to derive theParams
type ensures that theuseCheckout
hook's parameters stay in sync with the__experimental_CheckoutProvider
context. This is a robust approach that prevents type mismatches.packages/clerk-js/src/ui/components/PaymentSources/PaymentSources.tsx (1)
28-28
: LGTM! Consistent string literal updates.All subscriber type checks have been consistently updated from
'org'
to'organization'
, aligning with the newForPayerType
values. The conditional logic remains functionally identical while using the standardized terminology.Also applies to: 75-75, 111-111, 212-212
packages/types/src/commerce.ts (4)
101-101
: LGTM! Clear type rename.Renaming
CommercePayerType
toCommercePayerResourceType
clearly indicates this type is used for resource representations that come from the Frontend API, maintaining the original'org' | 'user'
values.
103-111
: LGTM! Well-documented new type.The new
ForPayerType
with'organization' | 'user'
values is properly documented and serves as the external-facing type for billing API parameters. The experimental annotation and documentation are consistent with the existing codebase standards.
240-240
: LGTM! Correct type usage for external API.Using
ForPayerType
for theGetPlansParams.for
property is appropriate since this is an external-facing API parameter that should accept'organization'
rather than the internal'org'
representation.
383-383
: LGTM! Appropriate type usage for resource property.Using
CommercePayerResourceType
for theCommercePlanResource.forPayerType
property is correct since this represents data from the Frontend API that uses the'org'
representation internally.packages/shared/src/react/commerce.tsx (6)
2-2
: LGTM: Import addition is correct.The addition of
ForPayerType
to the import statement follows TypeScript best practices and is necessary for the type standardization changes throughout the file.
66-69
: LGTM: Hook parameter and logic updates are correct.The changes improve type safety by:
- Using
ForPayerType
instead of inline string union type- Providing a sensible default value of
'user'
- Updating the comparison logic to use
'organization'
instead of'org'
The conditional resource selection logic remains clear and correct.
141-146
: LGTM: Well-documented prop with clear defaults.The JSDoc documentation clearly explains the
for
prop's purpose and default behavior. The type annotation usingForPayerType
is consistent with the broader refactoring effort.
236-236
: LGTM: Appropriate variable renaming to avoid shadowing.Renaming the destructured
for
prop to_for
is a good practice to avoid potential shadowing issues with thefor
keyword while maintaining clear variable naming.
249-249
: LGTM: String literal updated for consistency.The comparison logic correctly uses
'organization'
instead of'org'
, aligning with the newForPayerType
definition and maintaining consistency across the codebase.
259-259
: LGTM: Dependency array properly updated.The useMemo dependency array correctly references the renamed
_for
variable, ensuring proper memoization behavior.packages/shared/src/react/hooks/createCommerceHook.tsx (4)
1-1
: LGTM: Import addition is necessary and correct.The
ForPayerType
import is properly added to support the type standardization throughout the hook factory.
20-20
: LGTM: Type consistency improvement.Using
ForPayerType
instead of an inline union type improves maintainability and ensures consistency with the centralized type definition.
48-48
: LGTM: Type property updated consistently.The
for
property type update toForPayerType
maintains consistency with the other type changes in the hook factory.
52-54
: LGTM: API improvement with optional parameters and sensible defaults.Making the parameters optional while providing a sensible default value (
{ for: 'user' }
) improves the developer experience and maintains backward compatibility. The destructuring pattern properly handles both provided and default values.packages/types/src/clerk.ts (6)
30-30
: LGTM: Import updated for type standardization.The import change from
CommercePayerType
toForPayerType
is consistent with the broader refactoring effort to standardize payer type naming.
75-75
: LGTM: Type property updated consistently.The
for
property type update toForPayerType
maintains the optional nature while using the standardized type definition.
1839-1839
: LGTM: Checkout props type updated consistently.The
for
property type update toForPayerType
in__internal_CheckoutProps
maintains consistency with the standardized type system.
1864-1864
: LGTM: Checkout button props type updated consistently.The
for
property type update toForPayerType
in__experimental_CheckoutButtonProps
aligns with the broader type standardization effort.
1932-1935
: LGTM: Documentation and type updates are consistent.The JSDoc comment correctly uses "organization" instead of "org" to match the new string literal values, and the type update to
ForPayerType
maintains consistency with the standardization effort.
1955-1958
: LGTM: Consistent documentation and type updates.The documentation and type changes mirror the pattern established in the previous subscription details props, maintaining consistency across the codebase.
0b5dfd6
to
1b5a997
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
♻️ Duplicate comments (1)
packages/clerk-js/src/ui/components/Checkout/CheckoutForm.tsx (1)
133-135
: Critical: Remove hardcoded organization IDThe hardcoded organization ID
'org_30Xtae0Ptea60PvylFEIJi5LvXm'
will always be used instead of the actualorganization?.id
due to JavaScript's truthy evaluation. This is a critical bug that will cause checkout to use the wrong organization.- // TODO(@COMMERCE): Come back to this, this should not be needed - ...(_for === 'organization' ? { orgId: 'org_30Xtae0Ptea60PvylFEIJi5LvXm' || organization?.id } : {}), + ...(_for === 'organization' ? { orgId: organization?.id } : {}),The TODO comment suggests this shouldn't be needed - consider investigating if the
orgId
parameter is actually required.
🧹 Nitpick comments (2)
packages/react/src/components/CheckoutButton.tsx (1)
34-45
: Update JSDoc examples to reflect new API.The documentation examples still reference the old
subscriberType="org"
prop, which should be updated tofor="organization"
to match the new API.- subscriberType="org" + for="organization"- * @throws {Error} When `subscriberType="org"` is used without an active organization context + * @throws {Error} When `for="organization"` is used without an active organization contextpackages/react/src/components/SubscriptionDetailsButton.tsx (1)
29-39
: Update JSDoc examples to reflect new API.The documentation examples still reference
for="org"
which should be updated tofor="organization"
to match the new API.- for="org" + for="organization"- * @throws {Error} When `for="org"` is used without an active organization context + * @throws {Error} When `for="organization"` is used without an active organization context
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (33)
.changeset/some-parents-begin.md
(1 hunks)packages/clerk-js/src/core/modules/commerce/CommerceBilling.ts
(1 hunks)packages/clerk-js/src/core/resources/CommercePlan.ts
(2 hunks)packages/clerk-js/src/ui/components/Checkout/CheckoutForm.tsx
(2 hunks)packages/clerk-js/src/ui/components/Checkout/CheckoutPage.tsx
(1 hunks)packages/clerk-js/src/ui/components/Checkout/index.tsx
(1 hunks)packages/clerk-js/src/ui/components/OrganizationProfile/OrganizationBillingPage.tsx
(1 hunks)packages/clerk-js/src/ui/components/OrganizationProfile/OrganizationPaymentAttemptPage.tsx
(1 hunks)packages/clerk-js/src/ui/components/OrganizationProfile/OrganizationPlansPage.tsx
(1 hunks)packages/clerk-js/src/ui/components/OrganizationProfile/OrganizationStatementPage.tsx
(1 hunks)packages/clerk-js/src/ui/components/PaymentSources/PaymentSources.tsx
(4 hunks)packages/clerk-js/src/ui/components/Plans/PlanDetails.tsx
(1 hunks)packages/clerk-js/src/ui/components/SubscriptionDetails/index.tsx
(3 hunks)packages/clerk-js/src/ui/components/Subscriptions/SubscriptionsList.tsx
(1 hunks)packages/clerk-js/src/ui/contexts/ClerkUIComponentsContext.tsx
(1 hunks)packages/clerk-js/src/ui/contexts/components/Checkout.ts
(0 hunks)packages/clerk-js/src/ui/contexts/components/Plans.tsx
(6 hunks)packages/clerk-js/src/ui/contexts/components/SubscriberType.ts
(1 hunks)packages/clerk-js/src/ui/lazyModules/MountedCheckoutDrawer.tsx
(1 hunks)packages/react/src/components/CheckoutButton.tsx
(3 hunks)packages/react/src/components/SubscriptionDetailsButton.tsx
(3 hunks)packages/react/src/components/__tests__/CheckoutButton.test.tsx
(2 hunks)packages/react/src/components/__tests__/PlanDetailsButton.test.tsx
(2 hunks)packages/react/src/components/__tests__/SubscriptionDetailsButton.test.tsx
(2 hunks)packages/shared/src/react/commerce.tsx
(6 hunks)packages/shared/src/react/contexts.tsx
(2 hunks)packages/shared/src/react/hooks/createCommerceHook.tsx
(3 hunks)packages/shared/src/react/hooks/useCheckout.ts
(2 hunks)packages/shared/src/react/hooks/usePlans.tsx
(1 hunks)packages/shared/src/react/hooks/useSubscription.tsx
(2 hunks)packages/types/src/clerk.ts
(6 hunks)packages/types/src/commerce.ts
(3 hunks)packages/types/src/json.ts
(2 hunks)
💤 Files with no reviewable changes (1)
- packages/clerk-js/src/ui/contexts/components/Checkout.ts
✅ Files skipped from review due to trivial changes (3)
- packages/types/src/json.ts
- packages/react/src/components/tests/SubscriptionDetailsButton.test.tsx
- packages/react/src/components/tests/PlanDetailsButton.test.tsx
🚧 Files skipped from review as they are similar to previous changes (25)
- packages/clerk-js/src/ui/components/OrganizationProfile/OrganizationBillingPage.tsx
- packages/clerk-js/src/ui/components/OrganizationProfile/OrganizationPlansPage.tsx
- packages/clerk-js/src/ui/contexts/ClerkUIComponentsContext.tsx
- packages/clerk-js/src/ui/components/OrganizationProfile/OrganizationStatementPage.tsx
- packages/clerk-js/src/ui/components/OrganizationProfile/OrganizationPaymentAttemptPage.tsx
- .changeset/some-parents-begin.md
- packages/clerk-js/src/ui/lazyModules/MountedCheckoutDrawer.tsx
- packages/shared/src/react/contexts.tsx
- packages/clerk-js/src/ui/components/Subscriptions/SubscriptionsList.tsx
- packages/clerk-js/src/ui/components/Plans/PlanDetails.tsx
- packages/clerk-js/src/ui/components/Checkout/CheckoutPage.tsx
- packages/shared/src/react/hooks/useSubscription.tsx
- packages/clerk-js/src/ui/contexts/components/SubscriberType.ts
- packages/clerk-js/src/ui/components/Checkout/index.tsx
- packages/clerk-js/src/core/resources/CommercePlan.ts
- packages/types/src/commerce.ts
- packages/clerk-js/src/core/modules/commerce/CommerceBilling.ts
- packages/clerk-js/src/ui/components/SubscriptionDetails/index.tsx
- packages/shared/src/react/hooks/useCheckout.ts
- packages/shared/src/react/hooks/usePlans.tsx
- packages/clerk-js/src/ui/contexts/components/Plans.tsx
- packages/shared/src/react/commerce.tsx
- packages/clerk-js/src/ui/components/PaymentSources/PaymentSources.tsx
- packages/shared/src/react/hooks/createCommerceHook.tsx
- packages/types/src/clerk.ts
🧰 Additional context used
📓 Path-based instructions (13)
**/*.{js,jsx,ts,tsx}
📄 CodeRabbit Inference Engine (.cursor/rules/development.mdc)
**/*.{js,jsx,ts,tsx}
: All code must pass ESLint checks with the project's configuration
Follow established naming conventions (PascalCase for components, camelCase for variables)
Maintain comprehensive JSDoc comments for public APIs
Use dynamic imports for optional features
All public APIs must be documented with JSDoc
Provide meaningful error messages to developers
Include error recovery suggestions where applicable
Log errors appropriately for debugging
Lazy load components and features when possible
Implement proper caching strategies
Use efficient data structures and algorithms
Profile and optimize critical paths
Validate all inputs and sanitize outputs
Implement proper logging with different levels
Files:
packages/react/src/components/SubscriptionDetailsButton.tsx
packages/react/src/components/__tests__/CheckoutButton.test.tsx
packages/react/src/components/CheckoutButton.tsx
packages/clerk-js/src/ui/components/Checkout/CheckoutForm.tsx
**/*.{js,jsx,ts,tsx,json,css,scss,md,yaml,yml}
📄 CodeRabbit Inference Engine (.cursor/rules/development.mdc)
Use Prettier for consistent code formatting
Files:
packages/react/src/components/SubscriptionDetailsButton.tsx
packages/react/src/components/__tests__/CheckoutButton.test.tsx
packages/react/src/components/CheckoutButton.tsx
packages/clerk-js/src/ui/components/Checkout/CheckoutForm.tsx
packages/**/*.{ts,tsx}
📄 CodeRabbit Inference Engine (.cursor/rules/development.mdc)
TypeScript is required for all packages
Files:
packages/react/src/components/SubscriptionDetailsButton.tsx
packages/react/src/components/__tests__/CheckoutButton.test.tsx
packages/react/src/components/CheckoutButton.tsx
packages/clerk-js/src/ui/components/Checkout/CheckoutForm.tsx
packages/**/*.{ts,tsx,d.ts}
📄 CodeRabbit Inference Engine (.cursor/rules/development.mdc)
Packages should export TypeScript types alongside runtime code
Files:
packages/react/src/components/SubscriptionDetailsButton.tsx
packages/react/src/components/__tests__/CheckoutButton.test.tsx
packages/react/src/components/CheckoutButton.tsx
packages/clerk-js/src/ui/components/Checkout/CheckoutForm.tsx
**/*.{ts,tsx}
📄 CodeRabbit Inference Engine (.cursor/rules/development.mdc)
Use proper TypeScript error types
**/*.{ts,tsx}
: Always define explicit return types for functions, especially public APIs
Use proper type annotations for variables and parameters where inference isn't clear
Avoidany
type - preferunknown
when type is uncertain, then narrow with type guards
Useinterface
for object shapes that might be extended
Usetype
for unions, primitives, and computed types
Preferreadonly
properties for immutable data structures
Useprivate
for internal implementation details
Useprotected
for inheritance hierarchies
Usepublic
explicitly for clarity in public APIs
Preferreadonly
for properties that shouldn't change after construction
Prefer composition and interfaces over deep inheritance chains
Use mixins for shared behavior across unrelated classes
Implement dependency injection for loose coupling
Let TypeScript infer when types are obvious
Useconst assertions
for literal types:as const
Usesatisfies
operator for type checking without widening
Use mapped types for transforming object types
Use conditional types for type-level logic
Leverage template literal types for string manipulation
Use ES6 imports/exports consistently
Use default exports sparingly, prefer named exports
Use type-only imports:import type { ... } from ...
Noany
types without justification
Proper error handling with typed errors
Consistent use ofreadonly
for immutable data
Proper generic constraints
No unused type parameters
Proper use of utility types instead of manual type construction
Type-only imports where possible
Proper tree-shaking friendly exports
No circular dependencies
Efficient type computations (avoid deep recursion)
Files:
packages/react/src/components/SubscriptionDetailsButton.tsx
packages/react/src/components/__tests__/CheckoutButton.test.tsx
packages/react/src/components/CheckoutButton.tsx
packages/clerk-js/src/ui/components/Checkout/CheckoutForm.tsx
**/*.{jsx,tsx}
📄 CodeRabbit Inference Engine (.cursor/rules/development.mdc)
**/*.{jsx,tsx}
: Use error boundaries in React components
Minimize re-renders in React components
**/*.{jsx,tsx}
: Always use functional components with hooks instead of class components
Follow PascalCase naming for components:UserProfile
,NavigationMenu
Keep components focused on a single responsibility - split large components
Limit component size to 150-200 lines; extract logic into custom hooks
Use composition over inheritance - prefer smaller, composable components
Export components as named exports for better tree-shaking
One component per file with matching filename and component name
Use useState for simple state management
Use useReducer for complex state logic
Implement proper state initialization
Use proper state updates with callbacks
Implement proper state cleanup
Use Context API for theme/authentication
Implement proper state selectors
Use proper state normalization
Implement proper state persistence
Use React.memo for expensive components
Implement proper useCallback for handlers
Use proper useMemo for expensive computations
Implement proper virtualization for lists
Use proper code splitting with React.lazy
Implement proper cleanup in useEffect
Use proper refs for DOM access
Implement proper event listener cleanup
Use proper abort controllers for fetch
Implement proper subscription cleanup
Use proper HTML elements
Implement proper ARIA attributes
Use proper heading hierarchy
Implement proper form labels
Use proper button types
Implement proper focus management
Use proper keyboard shortcuts
Implement proper tab order
Use proper skip links
Implement proper focus traps
Implement proper error boundaries
Use proper error logging
Implement proper error recovery
Use proper error messages
Implement proper error fallbacks
Use proper form validation
Implement proper error states
Use proper error messages
Implement proper form submission
Use proper form reset
Use proper component naming
Implement proper file naming
Use proper prop naming
Implement proper...
Files:
packages/react/src/components/SubscriptionDetailsButton.tsx
packages/react/src/components/__tests__/CheckoutButton.test.tsx
packages/react/src/components/CheckoutButton.tsx
packages/clerk-js/src/ui/components/Checkout/CheckoutForm.tsx
**/*.{js,ts,tsx,jsx}
📄 CodeRabbit Inference Engine (.cursor/rules/monorepo.mdc)
Support multiple Clerk environment variables (CLERK_, NEXT_PUBLIC_CLERK_, etc.) for configuration.
Files:
packages/react/src/components/SubscriptionDetailsButton.tsx
packages/react/src/components/__tests__/CheckoutButton.test.tsx
packages/react/src/components/CheckoutButton.tsx
packages/clerk-js/src/ui/components/Checkout/CheckoutForm.tsx
**/*.tsx
📄 CodeRabbit Inference Engine (.cursor/rules/react.mdc)
**/*.tsx
: Use proper type definitions for props and state
Leverage TypeScript's type inference where possible
Use proper event types for handlers
Implement proper generic types for reusable components
Use proper type guards for conditional rendering
Files:
packages/react/src/components/SubscriptionDetailsButton.tsx
packages/react/src/components/__tests__/CheckoutButton.test.tsx
packages/react/src/components/CheckoutButton.tsx
packages/clerk-js/src/ui/components/Checkout/CheckoutForm.tsx
**/*
⚙️ CodeRabbit Configuration File
**/*
: If there are no tests added or modified as part of the PR, please suggest that tests be added to cover the changes.Whenever reviewing a pull request, if there are any changes that could impact security, always tag
@clerk/security
in the PR.Security-impacting changes include, but are not limited to:
- Changes to authentication logic or mechanisms (e.g. login, session handling, token issuance)
- Any modification to access control, authorization checks, or role-based permissions
- Introduction or modification of hashing algorithms, signature verification, or cryptographic primitives
- Handling of sensitive data (e.g. passwords, tokens, secrets, PII)
- Integration with external identity providers (e.g. SSO, OAuth, OpenID Connect)
- Modifications to security headers, cookie flags, CORS policies, or CSRF protections
- Bypass mechanisms (e.g. feature flags, testing overrides) that could weaken protections
- Changes to rate limiting, abuse prevention, or input validation
If you're unsure whether a change is security-relevant, err on the side of caution and tag
@clerk/security
.Any time that you tag
@clerk/security
, please do so explicitly in a code comment, rather than within a collapsed section in a coderabbit comment, such as the "recent review details" section. If you do use the team name in any thinking or non-direct-code-comment content, it can be referred to as "clerk security team" to avoid accidentally printing the tag which sends a notification to the team.
Files:
packages/react/src/components/SubscriptionDetailsButton.tsx
packages/react/src/components/__tests__/CheckoutButton.test.tsx
packages/react/src/components/CheckoutButton.tsx
packages/clerk-js/src/ui/components/Checkout/CheckoutForm.tsx
packages/**/*.{test,spec}.{js,jsx,ts,tsx}
📄 CodeRabbit Inference Engine (.cursor/rules/monorepo.mdc)
Unit tests should use Jest or Vitest as the test runner.
Files:
packages/react/src/components/__tests__/CheckoutButton.test.tsx
**/*.test.{jsx,tsx}
📄 CodeRabbit Inference Engine (.cursor/rules/react.mdc)
**/*.test.{jsx,tsx}
: Use React Testing Library
Test component behavior, not implementation
Use proper test queries
Implement proper test isolation
Use proper test coverage
Test component interactions
Use proper test data
Implement proper test setup
Use proper test cleanup
Implement proper test assertions
Use proper test structure
Files:
packages/react/src/components/__tests__/CheckoutButton.test.tsx
**/__tests__/**/*.{ts,tsx}
📄 CodeRabbit Inference Engine (.cursor/rules/typescript.mdc)
**/__tests__/**/*.{ts,tsx}
: Create type-safe test builders/factories
Use branded types for test isolation
Implement proper mock types that match interfaces
Files:
packages/react/src/components/__tests__/CheckoutButton.test.tsx
packages/clerk-js/src/ui/**/*.{ts,tsx}
📄 CodeRabbit Inference Engine (.cursor/rules/clerk-js-ui.mdc)
packages/clerk-js/src/ui/**/*.{ts,tsx}
: Element descriptors should always be camelCase
Use element descriptors in UI components to enable consistent theming and styling via appearance.elements
Element descriptors should generate unique, stable CSS classes for theming
Element descriptors should handle state classes (e.g., cl-loading, cl-active, cl-error, cl-open) automatically based on component state
Do not render hard-coded values; all user-facing strings must be localized using provided localization methods
Use the useLocalizations hook and localizationKeys utility for all text and error messages
Use the styled system (sx prop, theme tokens, responsive values) for custom component styling
Use useCardState for card-level state, useFormState for form-level state, and useLoadingStatus for loading states
Always use handleError utility for API errors and use translateError for localized error messages
Use useFormControl for form field state, implement proper validation, and handle loading and error states in forms
Use localization keys for all form labels and placeholders
Use element descriptors for consistent styling and follow the theme token system
Use the Card and FormContainer patterns for consistent UI structure
Files:
packages/clerk-js/src/ui/components/Checkout/CheckoutForm.tsx
🧬 Code Graph Analysis (1)
packages/react/src/components/__tests__/CheckoutButton.test.tsx (1)
packages/react/src/components/CheckoutButton.tsx (1)
CheckoutButton
(47-98)
🪛 ESLint
packages/clerk-js/src/ui/components/Checkout/CheckoutForm.tsx
[error] 134-134: Unexpected constant truthiness on the left-hand side of a ||
expression.
(no-constant-binary-expression)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
- GitHub Check: semgrep-cloud-platform/scan
- GitHub Check: Formatting | Dedupe | Changeset
- GitHub Check: Build Packages
- GitHub Check: semgrep/ci
- GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (9)
packages/react/src/components/__tests__/CheckoutButton.test.tsx (2)
57-67
: LGTM! Test updates align with API changes.The test correctly updates the prop name from
subscriberType
tofor
and the value from'org'
to'organization'
, matching the component API changes. The error message assertion is also properly updated.
84-86
: LGTM! Consistent test coverage for organization subscription.The test properly validates that the component renders successfully when both
userId
andorgId
are present, using the updatedfor='organization'
prop.packages/react/src/components/CheckoutButton.tsx (3)
52-52
: LGTM! Proper prop destructuring with alias.Using
for: _for
correctly avoids the reserved keywordfor
while maintaining clear intent.
65-67
: LGTM! Conditional logic updated correctly.The check now properly validates organization context when
_for === 'organization'
, and the error message reflects the new API.
80-80
: LGTM! API call updated correctly.The clerk function call now receives the correct
for
parameter with the aliased value.packages/clerk-js/src/ui/components/Checkout/CheckoutForm.tsx (1)
118-118
: LGTM! Context destructuring updated correctly.The prop is now correctly destructured as
for: _for
to align with the API changes.packages/react/src/components/SubscriptionDetailsButton.tsx (3)
49-49
: LGTM! Prop destructuring updated correctly.The destructuring now uses
for: _for
alias consistently with other components in this refactor.
59-63
: LGTM! Organization validation updated correctly.The conditional check and error message now properly reference the new
'organization'
value and updated prop name.
71-71
: LGTM! API call updated correctly.The clerk function now receives the correct
for
parameter.
1b5a997
to
4f125ce
Compare
@clerk/agent-toolkit
@clerk/astro
@clerk/backend
@clerk/chrome-extension
@clerk/clerk-js
@clerk/dev-cli
@clerk/elements
@clerk/clerk-expo
@clerk/expo-passkeys
@clerk/express
@clerk/fastify
@clerk/localizations
@clerk/nextjs
@clerk/nuxt
@clerk/clerk-react
@clerk/react-router
@clerk/remix
@clerk/shared
@clerk/tanstack-react-start
@clerk/testing
@clerk/themes
@clerk/types
@clerk/upgrade
@clerk/vue
commit: |
Description
Checklist
pnpm test
runs as expected.pnpm build
runs as expected.Type of change
Summary by CodeRabbit