Conversation
We recently added this BAPI endpoint because agents expect it to exist; they want to GET organization settings before doing a PATCH. Add support to the Javascript SDK as well. I didn't bother with unit tests here because it would just be a thin mock.
🦋 Changeset detectedLatest commit: 718b3b8 The changes in this PR will be included in the next version bump. This PR includes changesets to release 10 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.
|
@clerk/astro
@clerk/backend
@clerk/chrome-extension
@clerk/clerk-js
@clerk/dev-cli
@clerk/expo
@clerk/expo-passkeys
@clerk/express
@clerk/fastify
@clerk/hono
@clerk/localizations
@clerk/nextjs
@clerk/nuxt
@clerk/react
@clerk/react-router
@clerk/shared
@clerk/tanstack-react-start
@clerk/testing
@clerk/ui
@clerk/upgrade
@clerk/vue
commit: |
📝 WalkthroughWalkthroughThis pull request introduces a new method to the Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@packages/backend/src/api/endpoints/InstanceApi.ts`:
- Around line 94-99: Add a unit test that exercises
InstanceApi.getOrganizationSettings(); specifically assert that it calls
this.request with method 'GET' and path equal to joinPaths(basePath,
'organization_settings') (or the resolved string) and that the generic return
type OrganizationSettings is expected; mock or spy on InstanceApi.request (or
the HTTP layer) to verify the method/path wiring and a mocked response is
returned, and add the test alongside other InstanceApi tests so the new endpoint
is covered before merge.
- Around line 94-99: The public method getOrganizationSettings in the
InstanceApi class lacks an explicit return type; update its signature to declare
the return type as Promise<OrganizationSettings> (matching the generic used in
this.request<OrganizationSettings>) so the method becomes explicitly typed and
conforms to the public API typing guidelines.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository YAML (base), Organization UI (inherited)
Review profile: CHILL
Plan: Pro
Run ID: 65ffb5ed-9495-42d1-8926-63a5fc5996bf
📒 Files selected for processing (2)
.changeset/tiny-bobcats-train.mdpackages/backend/src/api/endpoints/InstanceApi.ts
| public async getOrganizationSettings() { | ||
| return this.request<OrganizationSettings>({ | ||
| method: 'GET', | ||
| path: joinPaths(basePath, 'organization_settings'), | ||
| }); | ||
| } |
There was a problem hiding this comment.
Add tests for the new endpoint wrapper before merge.
Line 94 adds a new backend call path, but this PR has no test changes. Please add at least one test asserting method/path wiring for getOrganizationSettings().
As per coding guidelines: "**/*: If there are no tests added or modified as part of the PR, please suggest that tests be added to cover the changes."
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@packages/backend/src/api/endpoints/InstanceApi.ts` around lines 94 - 99, Add
a unit test that exercises InstanceApi.getOrganizationSettings(); specifically
assert that it calls this.request with method 'GET' and path equal to
joinPaths(basePath, 'organization_settings') (or the resolved string) and that
the generic return type OrganizationSettings is expected; mock or spy on
InstanceApi.request (or the HTTP layer) to verify the method/path wiring and a
mocked response is returned, and add the test alongside other InstanceApi tests
so the new endpoint is covered before merge.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Verify public async methods missing explicit return types in this file
rg -nP --type=ts '^\s*public\s+async\s+\w+\([^)]*\)\s*\{' packages/backend/src/api/endpoints/InstanceApi.tsRepository: clerk/javascript
Length of output: 343
🏁 Script executed:
cat -n packages/backend/src/api/endpoints/InstanceApi.ts | sed -n '85,110p'Repository: clerk/javascript
Length of output: 895
🏁 Script executed:
cat -n packages/backend/src/api/endpoints/InstanceApi.ts | sed -n '1,95p' | tail -40Repository: clerk/javascript
Length of output: 1421
🏁 Script executed:
fd -t f AbstractAPI.ts -o -t f AbstractAPI.tsxRepository: clerk/javascript
Length of output: 176
🏁 Script executed:
rg -t ts 'class AbstractAPI' -lRepository: clerk/javascript
Length of output: 109
🏁 Script executed:
cat packages/backend/src/api/endpoints/AbstractApi.tsRepository: clerk/javascript
Length of output: 323
🏁 Script executed:
cat packages/backend/src/api/request.tsRepository: clerk/javascript
Length of output: 8919
Add explicit return type to this public API method.
The getOrganizationSettings() method at line 94 is missing an explicit return type annotation. Per the coding guidelines, all public APIs must have explicit return types.
Proposed fix
- public async getOrganizationSettings() {
+ public async getOrganizationSettings(): Promise<OrganizationSettings> {
return this.request<OrganizationSettings>({
method: 'GET',
path: joinPaths(basePath, 'organization_settings'),
});
}📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| public async getOrganizationSettings() { | |
| return this.request<OrganizationSettings>({ | |
| method: 'GET', | |
| path: joinPaths(basePath, 'organization_settings'), | |
| }); | |
| } | |
| public async getOrganizationSettings(): Promise<OrganizationSettings> { | |
| return this.request<OrganizationSettings>({ | |
| method: 'GET', | |
| path: joinPaths(basePath, 'organization_settings'), | |
| }); | |
| } |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@packages/backend/src/api/endpoints/InstanceApi.ts` around lines 94 - 99, The
public method getOrganizationSettings in the InstanceApi class lacks an explicit
return type; update its signature to declare the return type as
Promise<OrganizationSettings> (matching the generic used in
this.request<OrganizationSettings>) so the method becomes explicitly typed and
conforms to the public API typing guidelines.
Description
We recently added this BAPI endpoint because agents expect it to exist; they want to GET organization settings before doing a PATCH. In this PR we add support to the Javascript SDK as well.
I didn't bother with unit tests here because it would just be a thin mock.
Checklist
pnpm testruns as expected.pnpm buildruns as expected.Type of change