Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/tiny-bobcats-train.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@clerk/backend': minor
---

Add backend query to GET organization settings for an instance.
7 changes: 7 additions & 0 deletions packages/backend/src/api/endpoints/InstanceApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,13 @@ export class InstanceAPI extends AbstractAPI {
});
}

public async getOrganizationSettings() {
return this.request<OrganizationSettings>({
method: 'GET',
path: joinPaths(basePath, 'organization_settings'),
});
}
Comment on lines +94 to +99
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

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.

⚠️ Potential issue | 🟠 Major

🧩 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.ts

Repository: 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 -40

Repository: clerk/javascript

Length of output: 1421


🏁 Script executed:

fd -t f AbstractAPI.ts -o -t f AbstractAPI.tsx

Repository: clerk/javascript

Length of output: 176


🏁 Script executed:

rg -t ts 'class AbstractAPI' -l

Repository: clerk/javascript

Length of output: 109


🏁 Script executed:

cat packages/backend/src/api/endpoints/AbstractApi.ts

Repository: clerk/javascript

Length of output: 323


🏁 Script executed:

cat packages/backend/src/api/request.ts

Repository: 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.

Suggested change
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.


public async updateOrganizationSettings(params: UpdateOrganizationSettingsParams) {
return this.request<OrganizationSettings>({
method: 'PATCH',
Expand Down
Loading