-
Notifications
You must be signed in to change notification settings - Fork 152
feat(client): add JS client methods #2991
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
📝 WalkthroughWalkthroughThe changes introduce new methods and classes to the API client, enhancing support for customer access retrieval, event listing with improved filtering, plan addon management, and subscription deletion. Method signatures are updated for clarity and consistency, and a new Changes
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 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: 0
🧹 Nitpick comments (6)
api/client/javascript/src/client/customers.ts (1)
131-136: JSDoc param description is outdatedThe JSDoc block still refers to
@param signal, but the actual parameter isoptions. Update the comment to avoid confusion.- * @param options - Optional request options + * @param options - Optional request optionsapi/client/javascript/src/client/subscriptions.ts (2)
173-179: Align JSDoc parameter name with implementationThe JSDoc tag says
@param subscriptionId, yet the method argument is calledsubscriptionId. That’s correct, but the preceding comment* Delete subscriptionmentions “Only scheduled subscriptions can be deleted.”
Consider clarifying that restriction in the tag, and explicitly documenting that the method returns the deleted subscription (orvoid) once the backend is consistent.
180-195: Method namedeletemay clash with built-in operator
deleteis allowed as a method name, but it can be visually confusing with the JSdeleteoperator and makes stack-traces harder to grep. If you have the freedom to change the public surface, consider renaming toremoveordestroyfor clarity.No functional bug, only readability.
api/client/javascript/src/client/events.ts (1)
53-70: Duplicated request-building logic – extract a helper
listandlistV2are identical except for the path. Consider a small private helper to DRY the code and keep later maintenance cheaper.private async _list(path: string, params?: Record<string, unknown>, options?: RequestOptions) { const resp = await this.client.GET(path, { params: params ? { query: params } : undefined, ...options, }) return transformResponse(resp) }Then
listandlistV2become one-liners.api/client/javascript/src/client/plans.ts (2)
16-20: Exposeaddonsasreadonly
addonsis an accessor to a utility object – callers shouldn’t replace it. Marking itreadonlysignals intent and prevents accidental reassignment:- public addons: PlanAddons + public readonly addons: PlanAddons
238-254: High duplication across CRUD methods
create,get,update,deleteall follow the same request/response pattern differing only by HTTP verb & path. Extracting a private helper (similar to the earlier Events suggestion) would centralise error handling and keep signatures succinct.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
api/client/javascript/src/client/customers.ts(1 hunks)api/client/javascript/src/client/events.ts(1 hunks)api/client/javascript/src/client/plans.ts(6 hunks)api/client/javascript/src/client/subscriptions.ts(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (11)
- GitHub Check: CI
- GitHub Check: Quickstart
- GitHub Check: E2E
- GitHub Check: Commit hooks
- GitHub Check: Developer environment
- GitHub Check: Lint
- GitHub Check: Test
- GitHub Check: Migration Checks
- GitHub Check: Build
- GitHub Check: Analyze (javascript)
- GitHub Check: Analyze (go)
🔇 Additional comments (2)
api/client/javascript/src/client/events.ts (1)
35-52: Passingundefinedquery paramsWhen
paramsisundefined, the call builds{ query: undefined }. Depending on the fetch-client implementation this might serialise as?undefinedor omit the query string. Defensive guard keeps the wire clean:- params: { query: params }, + params: params ? { query: params } : undefined,api/client/javascript/src/client/plans.ts (1)
168-182: Guard against undefined query params in listingSame as with the Events client: if
paramsis not provided we risk emitting?undefined. Consider:- params: { - path: { planId }, - query: params, - }, + params: params + ? { path: { planId }, query: params } + : { path: { planId } },
Summary by CodeRabbit
New Features
Improvements