-
Notifications
You must be signed in to change notification settings - Fork 403
fix(clerk-js, types): Remove orgId from BillingPayerMethods interface
#7087
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
fix(clerk-js, types): Remove orgId from BillingPayerMethods interface
#7087
Conversation
🦋 Changeset detectedLatest commit: 706eac3 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 GitHub.
|
WalkthroughBilling methods were changed to surface or handle Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant BillingModule as payment-source-methods
participant API
Client->>BillingModule: initializePaymentMethod(params{..., orgId?})
Note right of BillingModule: extract orgId if present<br/>build path including orgId<br/>send request body without orgId
BillingModule->>API: POST /billing/{orgId?}/payment-methods (body: params w/o orgId)
API-->>BillingModule: 200 OK
BillingModule-->>Client: response
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Disabled knowledge base sources:
📒 Files selected for processing (1)
🧰 Additional context used📓 Path-based instructions (1).changeset/**📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)
Files:
⏰ 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)
🔇 Additional comments (1)
Comment |
| type WithOptionalOrgType<T> = T & { | ||
| orgId?: string; | ||
| }; |
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.
This is an internal concern, and should not affect the public API
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: 2
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
packages/clerk-js/src/core/modules/billing/payment-source-methods.ts (2)
20-30: Remove or justify theas anycast.Line 26 uses
as anywhich bypasses TypeScript's type checking. After destructuringorgId,restshould matchInitializePaymentMethodParams(i.e.,{ gateway: PaymentGateway }). The cast appears unnecessary and violates the coding guideline againstanytypes.Apply this diff:
export const initializePaymentMethod = async (params: WithOptionalOrgType<InitializePaymentMethodParams>) => { const { orgId, ...rest } = params; const json = ( await BaseResource._fetch({ path: Billing.path(`${PAYMENT_METHODS_PATH}/initialize`, { orgId }), method: 'POST', - body: rest as any, + body: rest, }) )?.response as unknown as BillingInitializedPaymentMethodJSON; return new BillingInitializedPaymentMethod(json); };
32-43: Remove or justify theas anycast.Line 39 uses
as anywhich bypasses TypeScript's type checking. After destructuringorgId,restshould matchAddPaymentMethodParams(i.e.,{ gateway: PaymentGateway; paymentToken: string }). The cast appears unnecessary and violates the coding guideline againstanytypes.Apply this diff:
export const addPaymentMethod = async (params: WithOptionalOrgType<AddPaymentMethodParams>) => { const { orgId, ...rest } = params; const json = ( await BaseResource._fetch({ path: Billing.path(PAYMENT_METHODS_PATH, { orgId }), method: 'POST', - body: rest as any, + body: rest, }) )?.response as unknown as BillingPaymentMethodJSON; return new BillingPaymentMethod(json); };
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Disabled knowledge base sources:
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (3)
.changeset/great-bees-fix.md(1 hunks)packages/clerk-js/src/core/modules/billing/payment-source-methods.ts(3 hunks)packages/types/src/billing.ts(3 hunks)
🧰 Additional context used
📓 Path-based instructions (7)
.changeset/**
📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)
Automated releases must use Changesets.
Files:
.changeset/great-bees-fix.md
**/*.{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/types/src/billing.tspackages/clerk-js/src/core/modules/billing/payment-source-methods.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/types/src/billing.tspackages/clerk-js/src/core/modules/billing/payment-source-methods.ts
packages/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
TypeScript is required for all packages
Files:
packages/types/src/billing.tspackages/clerk-js/src/core/modules/billing/payment-source-methods.ts
packages/**/*.{ts,tsx,d.ts}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
Packages should export TypeScript types alongside runtime code
Files:
packages/types/src/billing.tspackages/clerk-js/src/core/modules/billing/payment-source-methods.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
Avoidanytype - preferunknownwhen type is uncertain, then narrow with type guards
Useinterfacefor object shapes that might be extended
Usetypefor unions, primitives, and computed types
Preferreadonlyproperties for immutable data structures
Useprivatefor internal implementation details
Useprotectedfor inheritance hierarchies
Usepublicexplicitly for clarity in public APIs
Preferreadonlyfor 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 assertionsfor literal types:as const
Usesatisfiesoperator 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 ...
Noanytypes without justification
Proper error handling with typed errors
Consistent use ofreadonlyfor 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/types/src/billing.tspackages/clerk-js/src/core/modules/billing/payment-source-methods.ts
**/*.{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/types/src/billing.tspackages/clerk-js/src/core/modules/billing/payment-source-methods.ts
🧬 Code graph analysis (2)
packages/types/src/billing.ts (1)
packages/types/src/pagination.ts (1)
ClerkPaginationParams(36-47)
packages/clerk-js/src/core/modules/billing/payment-source-methods.ts (1)
packages/types/src/billing.ts (3)
InitializePaymentMethodParams(239-244)AddPaymentMethodParams(249-258)GetPaymentMethodsParams(227-227)
⏰ 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). (1)
- GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (6)
packages/types/src/billing.ts (5)
92-102: LGTM! Clean interface simplification.The removal of
Exclude<..., 'orgId'>wrappers and direct use of parameter types is a good simplification. MakinggetPaymentMethodsparams optional also improves the API ergonomics.
227-227: LGTM! Consistent with orgId removal.Simplifying from
WithOptionalOrgType<ClerkPaginationParams>toClerkPaginationParamsaligns with the PR's goal.
239-244: LGTM! Parameter type simplified correctly.The removal of
WithOptionalOrgTypewrapper fromInitializePaymentMethodParamsis consistent with the PR's objective.
249-258: LGTM! Parameter type simplified correctly.The removal of
WithOptionalOrgTypewrapper fromAddPaymentMethodParamsis consistent with the PR's objective.
234-234: PayPal support was never implemented — removal is acceptable.The search found zero references to 'paypal' in the entire codebase, confirming it was only a planned but never-implemented feature. Since
PaymentGatewayis marked@experimentalin a public beta API that explicitly states "the API is subject to change," removing the unused type option is legitimate code cleanup rather than a problematic breaking change.packages/clerk-js/src/core/modules/billing/payment-source-methods.ts (1)
45-59: LGTM! Clean implementation with proper optional parameter handling.The use of
params ?? {}provides a clean default, and the orgId extraction pattern is consistent with the other methods. No type safety issues here.
@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
Passing
orgIdshould not be part of the public signature.Checklist
pnpm testruns as expected.pnpm buildruns as expected.Type of change
Summary by CodeRabbit
New Features
Behavior Changes
Breaking Changes