Skip to content

chore(clerk-js,shared,ui): Add EnterpriseConnection resource - #8175

Merged
LauraBeatris merged 5 commits into
mainfrom
laura/fix-enterprise-account-connect-dropdown
Mar 27, 2026
Merged

chore(clerk-js,shared,ui): Add EnterpriseConnection resource#8175
LauraBeatris merged 5 commits into
mainfrom
laura/fix-enterprise-account-connect-dropdown

Conversation

@LauraBeatris

@LauraBeatrisLauraBeatris commented Mar 27, 2026

Copy link
Copy Markdown
Contributor

Description

  • Introduce EnterpriseConnection resource from FAPI
  • Fixes /me/enterprise_connections query return type to use EnterpriseConnection
  • Update UserProfile logic for connection to enterprise connection, to rely on the EnterpriseConnection properties instead of the previously wrong type

Checklist

  • pnpm test runs as expected.
  • pnpm build runs as expected.
  • (If applicable) JSDoc comments have been added or updated for any package exports
  • (If applicable) Documentation has been updated

Type of change

  • 🐛 Bug fix
  • 🌟 New feature
  • 🔨 Breaking change
  • 📖 Refactoring / dependency upgrade / documentation
  • other:

Summary by CodeRabbit

  • New Features

    • Added EnterpriseConnection resource with SAML and OAuth support, custom attributes, org-account linking controls, and timestamps.
  • Refactor

    • Renamed enterprise account connection types to EnterpriseConnection across the product and updated related hooks and APIs to return the new type.
    • Updated enterprise connections UI to use the new resource shape and show provider icons from the connection's OAuth logo.
  • Chores

    • Minor package version bumps and build size threshold updates.

@LauraBeatrisLauraBeatris self-assigned this Mar 27, 2026
@vercel

vercelBot commented Mar 27, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

ProjectDeploymentActionsUpdated (UTC)
clerk-js-sandboxReadyReadyPreview, CommentMar 27, 2026 8:30pm

Request Review

@changeset-bot

changeset-botBot commented Mar 27, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 117026d

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 21 packages
NameType
@clerk/clerk-jsMinor
@clerk/sharedMinor
@clerk/uiMinor
@clerk/chrome-extensionPatch
@clerk/expoPatch
@clerk/agent-toolkitPatch
@clerk/astroPatch
@clerk/backendPatch
@clerk/expo-passkeysPatch
@clerk/expressPatch
@clerk/fastifyPatch
@clerk/honoPatch
@clerk/localizationsPatch
@clerk/mswPatch
@clerk/nextjsPatch
@clerk/nuxtPatch
@clerk/react-routerPatch
@clerk/reactPatch
@clerk/tanstack-react-startPatch
@clerk/testingPatch
@clerk/vuePatch

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

@LauraBeatris
LauraBeatrisforce-pushed the laura/fix-enterprise-account-connect-dropdown branch from b51c4dc to c2e56c6CompareMarch 27, 2026 16:50
@LauraBeatrisLauraBeatris changed the title fix(clerk-js,ui): Add EnterpriseConnection resourcechore(clerk-js,ui): Add EnterpriseConnection resourceMar 27, 2026
@LauraBeatrisLauraBeatris changed the title chore(clerk-js,ui): Add EnterpriseConnection resourcechore(clerk-js,shared,ui): Add EnterpriseConnection resourceMar 27, 2026
@LauraBeatris
LauraBeatris marked this pull request as ready for review March 27, 2026 17:16
@LauraBeatris
LauraBeatris requested a review from a teamMarch 27, 2026 17:16
@coderabbitai

coderabbitaiBot commented Mar 27, 2026

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

Adds a new EnterpriseConnection resource class and corresponding JSON/resource type definitions, re-exports them, and updates type imports across packages. Changes User.getEnterpriseConnections() and related type signatures/hooks/UI props to return/use EnterpriseConnectionResource[]. Implements JSON↔resource mapping and snapshot serialization for SAML and OAuth nested data. Updates UI component icon/logo usage to rely on oauthConfig.logoPublicUrl. Adds a Changeset for minor version bumps and adjusts bundlewatch size thresholds for several clerk-js bundles.

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check nameStatusExplanationResolution
Docstring Coverage⚠️ WarningDocstring coverage is 0.00% which is insufficient. The required threshold is 80.00%.Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check nameStatusExplanation
Description Check✅ PassedCheck skipped - CodeRabbit’s high-level summary is enabled.
Title check✅ PassedThe title 'Add EnterpriseConnection resource' accurately describes the primary change in the changeset—introducing a new EnterpriseConnection resource across multiple packages (clerk-js, shared, ui).

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Comment @coderabbitai help to get the list of available commands and usage tips.


export type UseUserEnterpriseConnectionsReturn = {
data: EnterpriseAccountConnectionResource[] | undefined;
data: EnterpriseConnectionResource[] | undefined;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

wouldn't this count as a breaking change? Not saying we need to since this is just a TypeScript type change, but the change in type here seems significant enough to justify calling it out in the changelog. I assume the API has been returning something of the shape EnterpriseConnectionResource so at runtime I doubt this would break anything functional, but I can imagine this causing a TypeScript error if someone was previously using the EnterpriceAccountConnectionResource type.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

We haven't released user.getEnterpriseConnections yet in production, so I expect no breaking changes on existing apps

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

I'll clarify that type change behavior on the changelog as well

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Updated on 5e62ce7

@coderabbitaicoderabbitaiBot left a comment

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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In @.changeset/humble-trams-laugh.md:
- Line 9: Update the type description for User.getEnterpriseConnections() so it
reflects an array return type: replace the singular
EnterpriseAccountConnectionResource with EnterpriseAccountConnectionResource[]
(or the correct EnterpriseConnectionResource[] if that's the canonical type in
your codebase) in the changelog/description so the documented return type
matches the actual plural method signature; ensure the mention of
User.getEnterpriseConnections() and the resource type name are updated
consistently.
🪄 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: ASSERTIVE

Plan: Pro

Run ID: 1cb81ab7-6641-4d82-9df6-af6052eeb9a9

📥 Commits

Reviewing files that changed from the base of the PR and between df26e1e and 5e62ce7.

📒 Files selected for processing (1)
  • .changeset/humble-trams-laugh.md

Comment thread.changeset/humble-trams-laugh.md Outdated
@pkg-pr-new

pkg-pr-newBot commented Mar 27, 2026

Copy link
Copy Markdown

Open in StackBlitz

@clerk/agent-toolkit

npm i https://pkg.pr.new/@clerk/agent-toolkit@8175

@clerk/astro

npm i https://pkg.pr.new/@clerk/astro@8175

@clerk/backend

npm i https://pkg.pr.new/@clerk/backend@8175

@clerk/chrome-extension

npm i https://pkg.pr.new/@clerk/chrome-extension@8175

@clerk/clerk-js

npm i https://pkg.pr.new/@clerk/clerk-js@8175

@clerk/dev-cli

npm i https://pkg.pr.new/@clerk/dev-cli@8175

@clerk/expo

npm i https://pkg.pr.new/@clerk/expo@8175

@clerk/expo-passkeys

npm i https://pkg.pr.new/@clerk/expo-passkeys@8175

@clerk/express

npm i https://pkg.pr.new/@clerk/express@8175

@clerk/fastify

npm i https://pkg.pr.new/@clerk/fastify@8175

@clerk/hono

npm i https://pkg.pr.new/@clerk/hono@8175

@clerk/localizations

npm i https://pkg.pr.new/@clerk/localizations@8175

@clerk/nextjs

npm i https://pkg.pr.new/@clerk/nextjs@8175

@clerk/nuxt

npm i https://pkg.pr.new/@clerk/nuxt@8175

@clerk/react

npm i https://pkg.pr.new/@clerk/react@8175

@clerk/react-router

npm i https://pkg.pr.new/@clerk/react-router@8175

@clerk/shared

npm i https://pkg.pr.new/@clerk/shared@8175

@clerk/tanstack-react-start

npm i https://pkg.pr.new/@clerk/tanstack-react-start@8175

@clerk/testing

npm i https://pkg.pr.new/@clerk/testing@8175

@clerk/ui

npm i https://pkg.pr.new/@clerk/ui@8175

@clerk/upgrade

npm i https://pkg.pr.new/@clerk/upgrade@8175

@clerk/vue

npm i https://pkg.pr.new/@clerk/vue@8175

commit: 117026d

@LauraBeatris
LauraBeatrisforce-pushed the laura/fix-enterprise-account-connect-dropdown branch from 5e62ce7 to 482b75bCompareMarch 27, 2026 20:25

@coderabbitaicoderabbitaiBot left a comment

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.

Actionable comments posted: 1

🤖 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/clerk-js/src/core/resources/User.ts`:
- Around line 314-316: Update the mock response in the test at User.test.ts so
it matches the new EnterpriseConnectionJSON schema: replace any single "domain"
string with "domains" as an array (e.g. domains: []), remove obsolete fields
like "protocol" and "provider", and add the new nested objects "saml_connection"
and/or "oauth_config" (or minimal empty objects) as expected by
EnterpriseConnection.fromJSON/EnterpriseConnectionJSON; ensure the test mock
objects mirror the real API shape so the code paths in
EnterpriseConnection.fromJSON and the mapping in User (where it casts to
EnterpriseConnectionJSON[] and constructs new EnterpriseConnection(connection))
exercise the correct schema.
🪄 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: ASSERTIVE

Plan: Pro

Run ID: 91da4969-d424-4a91-bb92-3a539ae76038

📥 Commits

Reviewing files that changed from the base of the PR and between 5e62ce7 and 117026d.

📒 Files selected for processing (10)
  • .changeset/humble-trams-laugh.md
  • packages/clerk-js/bundlewatch.config.json
  • packages/clerk-js/src/core/resources/EnterpriseConnection.ts
  • packages/clerk-js/src/core/resources/User.ts
  • packages/clerk-js/src/core/resources/internal.ts
  • packages/shared/src/react/hooks/useUserEnterpriseConnections.tsx
  • packages/shared/src/types/enterpriseConnection.ts
  • packages/shared/src/types/index.ts
  • packages/shared/src/types/user.ts
  • packages/ui/src/components/UserProfile/EnterpriseAccountsSection.tsx

Comment on lines +314 to +316
)?.response as unknown as EnterpriseConnectionJSON[];

return (json || []).map(connection => new EnterpriseAccountConnection(connection));
return (json || []).map(connection => new EnterpriseConnection(connection));

@coderabbitaicoderabbitaiBotMar 27, 2026

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

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash# Check test file for enterprise connection mock data
rg -n -A 30 'enterprise.*connection.*JSON' packages/clerk-js/src/core/resources/__tests__/User.test.ts

Repository: clerk/javascript

Length of output: 42


🏁 Script executed:

# First, let's look at the test file to find enterprise connection related tests
rg -n -B 2 -A 20 'getEnterpriseConnections' packages/clerk-js/src/core/resources/__tests__/User.test.ts

Repository: clerk/javascript

Length of output: 806


🏁 Script executed:

# Find the EnterpriseConnectionJSON type definition
rg -n -B 2 -A 10 'interface EnterpriseConnectionJSON\|type EnterpriseConnectionJSON' packages/clerk-js/src/

Repository: clerk/javascript

Length of output: 42


🏁 Script executed:

# Also check what EnterpriseConnection class looks like
rg -n -B 2 -A 15 'class EnterpriseConnection\|export class EnterpriseConnection' packages/clerk-js/src/

Repository: clerk/javascript

Length of output: 42


🏁 Script executed:

# Look at the test setup before line 112 to see the mock data
sed -n '80,115p' packages/clerk-js/src/core/resources/__tests__/User.test.ts

Repository: clerk/javascript

Length of output: 1095


🏁 Script executed:

# Search for enterprise connection related types more broadly
rg -n 'EnterpriseConnectionJSON\|enterprise_connection' packages/clerk-js/src/ -t ts

Repository: clerk/javascript

Length of output: 42


🏁 Script executed:

# Search for EnterpriseConnection references in the codebase
rg -n 'class EnterpriseConnection' packages/clerk-js/src/ -t ts

Repository: clerk/javascript

Length of output: 220


🏁 Script executed:

# Find EnterpriseConnectionJSON type definition
fd -t f EnterpriseConnection.ts packages/clerk-js/src/ --exec head -150 {} \;

Repository: clerk/javascript

Length of output: 4987


🏁 Script executed:

# Search for EnterpriseConnectionJSON in type files
rg -n 'EnterpriseConnectionJSON' packages/clerk-js/src/ -t ts -B 2 -A 10

Repository: clerk/javascript

Length of output: 9696


Update test mock data to match the new EnterpriseConnectionJSON schema.

The test at packages/clerk-js/src/core/resources/__tests__/User.test.ts uses stale mock data with the old API structure. The mock includes fields like domain (string), protocol, and provider that don't exist in the new EnterpriseConnectionJSON type, which expects domains (array), saml_connection, and oauth_config objects instead.

The test currently passes by coincidence because the EnterpriseConnection.fromJSON() implementation provides defaults for optional fields (domains ?? []), but the mock should be updated to reflect the actual API response structure to properly validate the new code.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@packages/clerk-js/src/core/resources/User.ts` around lines 314 - 316, Update
the mock response in the test at User.test.ts so it matches the new
EnterpriseConnectionJSON schema: replace any single "domain" string with
"domains" as an array (e.g. domains: []), remove obsolete fields like "protocol"
and "provider", and add the new nested objects "saml_connection" and/or
"oauth_config" (or minimal empty objects) as expected by
EnterpriseConnection.fromJSON/EnterpriseConnectionJSON; ensure the test mock
objects mirror the real API shape so the code paths in
EnterpriseConnection.fromJSON and the mapping in User (where it casts to
EnterpriseConnectionJSON[] and constructs new EnterpriseConnection(connection))
exercise the correct schema.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Missed this one, will raise a follow up PR to fix it alongside adding provider and logo_public_url properties to EnterpriseConnection

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.

@LauraBeatris, sounds good! Would you like me to open a GitHub issue to track these follow-up items:

  1. Update the User.test.ts mock data to match the new EnterpriseConnectionJSON schema (replace domain with domains: [], remove obsolete protocol/provider fields, add saml_connection/oauth_config nested objects).
  2. Add provider and logo_public_url properties to the EnterpriseConnection resource and its associated types.

🧠 Learnings used
Learnt from: wobsoriano
Repo: clerk/javascript PR: 7883
File: packages/backend/src/api/__tests__/M2MTokenApi.test.ts:414-419
Timestamp: 2026-02-24T18:03:27.067Z
Learning: In TypeScript files within the clerk/javascript repository, enforce explicit return type annotations for exported functions and public APIs, but allow internal test helper functions without explicit return types. This helps maintain API clarity and type safety for consumers while not burdening test helpers that are not part of the public surface.

@LauraBeatris
LauraBeatris merged commit b8c73d3 into mainMar 27, 2026
44 checks passed
@LauraBeatris
LauraBeatris deleted the laura/fix-enterprise-account-connect-dropdown branch March 27, 2026 20:38
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@LauraBeatris@dstaley@iagodahlem
, 'i'); if (__m === '*' || __re.test(location.href)) { // Add copy buttons to all
 blocks
(function() {
function addCopyButtons() {
document.querySelectorAll('pre code').forEach(function(codeBlock) {
if (codeBlock.parentElement.hasAttribute('data-copy-added')) return;
codeBlock.parentElement.setAttribute('data-copy-added', 'true');
var btn = document.createElement('button');
btn.textContent = 'Copy';
btn.style.cssText = 'position:absolute;top:4px;right:4px;padding:2px 8px;font-size:11px;background:#4ecdc4;border:none;border-radius:4px;color:#1a1a2e;cursor:pointer;opacity:0.7;transition:opacity 0.2s;';
btn.onmouseover = function() { this.style.opacity = '1'; };
btn.onmouseout = function() { this.style.opacity = '0.7'; };
btn.onclick = function() {
navigator.clipboard.writeText(codeBlock.textContent).then(function() {
btn.textContent = 'Copied!';
setTimeout(function() { btn.textContent = 'Copy'; }, 1500);
});
};
codeBlock.parentElement.style.position = 'relative';
codeBlock.parentElement.appendChild(btn);
});
}
addCopyButtons();
// Re-run on dynamic content
var observer = new MutationObserver(addCopyButtons);
observer.observe(document.body, { childList: true, subtree: true });
})();
}
} catch(__e) { console.warn('[Userscript:Add Copy Buttons to Code Blocks]', __e); }
})();
(function(){
try {
var __m = "github.com";
var __re = new RegExp('^' + "github\\.com" + '
chore(clerk-js,shared,ui): Add `EnterpriseConnection` resource by LauraBeatris · Pull Request #8175 · clerk/javascript · GitHub
Skip to content

chore(clerk-js,shared,ui): Add EnterpriseConnection resource - #8175

Merged
LauraBeatris merged 5 commits into
mainfrom
laura/fix-enterprise-account-connect-dropdown
Mar 27, 2026
Merged

chore(clerk-js,shared,ui): Add EnterpriseConnection resource#8175
LauraBeatris merged 5 commits into
mainfrom
laura/fix-enterprise-account-connect-dropdown

Conversation

@LauraBeatris

@LauraBeatrisLauraBeatris commented Mar 27, 2026

Copy link
Copy Markdown
Contributor

Description

  • Introduce EnterpriseConnection resource from FAPI
  • Fixes /me/enterprise_connections query return type to use EnterpriseConnection
  • Update UserProfile logic for connection to enterprise connection, to rely on the EnterpriseConnection properties instead of the previously wrong type

Checklist

  • pnpm test runs as expected.
  • pnpm build runs as expected.
  • (If applicable) JSDoc comments have been added or updated for any package exports
  • (If applicable) Documentation has been updated

Type of change

  • 🐛 Bug fix
  • 🌟 New feature
  • 🔨 Breaking change
  • 📖 Refactoring / dependency upgrade / documentation
  • other:

Summary by CodeRabbit

  • New Features

    • Added EnterpriseConnection resource with SAML and OAuth support, custom attributes, org-account linking controls, and timestamps.
  • Refactor

    • Renamed enterprise account connection types to EnterpriseConnection across the product and updated related hooks and APIs to return the new type.
    • Updated enterprise connections UI to use the new resource shape and show provider icons from the connection's OAuth logo.
  • Chores

    • Minor package version bumps and build size threshold updates.

@LauraBeatrisLauraBeatris self-assigned this Mar 27, 2026
@vercel

vercelBot commented Mar 27, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

ProjectDeploymentActionsUpdated (UTC)
clerk-js-sandboxReadyReadyPreview, CommentMar 27, 2026 8:30pm

Request Review

@changeset-bot

changeset-botBot commented Mar 27, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 117026d

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 21 packages
NameType
@clerk/clerk-jsMinor
@clerk/sharedMinor
@clerk/uiMinor
@clerk/chrome-extensionPatch
@clerk/expoPatch
@clerk/agent-toolkitPatch
@clerk/astroPatch
@clerk/backendPatch
@clerk/expo-passkeysPatch
@clerk/expressPatch
@clerk/fastifyPatch
@clerk/honoPatch
@clerk/localizationsPatch
@clerk/mswPatch
@clerk/nextjsPatch
@clerk/nuxtPatch
@clerk/react-routerPatch
@clerk/reactPatch
@clerk/tanstack-react-startPatch
@clerk/testingPatch
@clerk/vuePatch

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

@LauraBeatris
LauraBeatrisforce-pushed the laura/fix-enterprise-account-connect-dropdown branch from b51c4dc to c2e56c6CompareMarch 27, 2026 16:50
@LauraBeatrisLauraBeatris changed the title fix(clerk-js,ui): Add EnterpriseConnection resourcechore(clerk-js,ui): Add EnterpriseConnection resourceMar 27, 2026
@LauraBeatrisLauraBeatris changed the title chore(clerk-js,ui): Add EnterpriseConnection resourcechore(clerk-js,shared,ui): Add EnterpriseConnection resourceMar 27, 2026
@LauraBeatris
LauraBeatris marked this pull request as ready for review March 27, 2026 17:16
@LauraBeatris
LauraBeatris requested a review from a teamMarch 27, 2026 17:16
@coderabbitai

coderabbitaiBot commented Mar 27, 2026

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

Adds a new EnterpriseConnection resource class and corresponding JSON/resource type definitions, re-exports them, and updates type imports across packages. Changes User.getEnterpriseConnections() and related type signatures/hooks/UI props to return/use EnterpriseConnectionResource[]. Implements JSON↔resource mapping and snapshot serialization for SAML and OAuth nested data. Updates UI component icon/logo usage to rely on oauthConfig.logoPublicUrl. Adds a Changeset for minor version bumps and adjusts bundlewatch size thresholds for several clerk-js bundles.

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check nameStatusExplanationResolution
Docstring Coverage⚠️ WarningDocstring coverage is 0.00% which is insufficient. The required threshold is 80.00%.Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check nameStatusExplanation
Description Check✅ PassedCheck skipped - CodeRabbit’s high-level summary is enabled.
Title check✅ PassedThe title 'Add EnterpriseConnection resource' accurately describes the primary change in the changeset—introducing a new EnterpriseConnection resource across multiple packages (clerk-js, shared, ui).

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Comment @coderabbitai help to get the list of available commands and usage tips.


export type UseUserEnterpriseConnectionsReturn = {
data: EnterpriseAccountConnectionResource[] | undefined;
data: EnterpriseConnectionResource[] | undefined;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

wouldn't this count as a breaking change? Not saying we need to since this is just a TypeScript type change, but the change in type here seems significant enough to justify calling it out in the changelog. I assume the API has been returning something of the shape EnterpriseConnectionResource so at runtime I doubt this would break anything functional, but I can imagine this causing a TypeScript error if someone was previously using the EnterpriceAccountConnectionResource type.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

We haven't released user.getEnterpriseConnections yet in production, so I expect no breaking changes on existing apps

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

I'll clarify that type change behavior on the changelog as well

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Updated on 5e62ce7

@coderabbitaicoderabbitaiBot left a comment

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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In @.changeset/humble-trams-laugh.md:
- Line 9: Update the type description for User.getEnterpriseConnections() so it
reflects an array return type: replace the singular
EnterpriseAccountConnectionResource with EnterpriseAccountConnectionResource[]
(or the correct EnterpriseConnectionResource[] if that's the canonical type in
your codebase) in the changelog/description so the documented return type
matches the actual plural method signature; ensure the mention of
User.getEnterpriseConnections() and the resource type name are updated
consistently.
🪄 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: ASSERTIVE

Plan: Pro

Run ID: 1cb81ab7-6641-4d82-9df6-af6052eeb9a9

📥 Commits

Reviewing files that changed from the base of the PR and between df26e1e and 5e62ce7.

📒 Files selected for processing (1)
  • .changeset/humble-trams-laugh.md

Comment thread.changeset/humble-trams-laugh.md Outdated
@pkg-pr-new

pkg-pr-newBot commented Mar 27, 2026

Copy link
Copy Markdown

Open in StackBlitz

@clerk/agent-toolkit

npm i https://pkg.pr.new/@clerk/agent-toolkit@8175

@clerk/astro

npm i https://pkg.pr.new/@clerk/astro@8175

@clerk/backend

npm i https://pkg.pr.new/@clerk/backend@8175

@clerk/chrome-extension

npm i https://pkg.pr.new/@clerk/chrome-extension@8175

@clerk/clerk-js

npm i https://pkg.pr.new/@clerk/clerk-js@8175

@clerk/dev-cli

npm i https://pkg.pr.new/@clerk/dev-cli@8175

@clerk/expo

npm i https://pkg.pr.new/@clerk/expo@8175

@clerk/expo-passkeys

npm i https://pkg.pr.new/@clerk/expo-passkeys@8175

@clerk/express

npm i https://pkg.pr.new/@clerk/express@8175

@clerk/fastify

npm i https://pkg.pr.new/@clerk/fastify@8175

@clerk/hono

npm i https://pkg.pr.new/@clerk/hono@8175

@clerk/localizations

npm i https://pkg.pr.new/@clerk/localizations@8175

@clerk/nextjs

npm i https://pkg.pr.new/@clerk/nextjs@8175

@clerk/nuxt

npm i https://pkg.pr.new/@clerk/nuxt@8175

@clerk/react

npm i https://pkg.pr.new/@clerk/react@8175

@clerk/react-router

npm i https://pkg.pr.new/@clerk/react-router@8175

@clerk/shared

npm i https://pkg.pr.new/@clerk/shared@8175

@clerk/tanstack-react-start

npm i https://pkg.pr.new/@clerk/tanstack-react-start@8175

@clerk/testing

npm i https://pkg.pr.new/@clerk/testing@8175

@clerk/ui

npm i https://pkg.pr.new/@clerk/ui@8175

@clerk/upgrade

npm i https://pkg.pr.new/@clerk/upgrade@8175

@clerk/vue

npm i https://pkg.pr.new/@clerk/vue@8175

commit: 117026d

@LauraBeatris
LauraBeatrisforce-pushed the laura/fix-enterprise-account-connect-dropdown branch from 5e62ce7 to 482b75bCompareMarch 27, 2026 20:25

@coderabbitaicoderabbitaiBot left a comment

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.

Actionable comments posted: 1

🤖 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/clerk-js/src/core/resources/User.ts`:
- Around line 314-316: Update the mock response in the test at User.test.ts so
it matches the new EnterpriseConnectionJSON schema: replace any single "domain"
string with "domains" as an array (e.g. domains: []), remove obsolete fields
like "protocol" and "provider", and add the new nested objects "saml_connection"
and/or "oauth_config" (or minimal empty objects) as expected by
EnterpriseConnection.fromJSON/EnterpriseConnectionJSON; ensure the test mock
objects mirror the real API shape so the code paths in
EnterpriseConnection.fromJSON and the mapping in User (where it casts to
EnterpriseConnectionJSON[] and constructs new EnterpriseConnection(connection))
exercise the correct schema.
🪄 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: ASSERTIVE

Plan: Pro

Run ID: 91da4969-d424-4a91-bb92-3a539ae76038

📥 Commits

Reviewing files that changed from the base of the PR and between 5e62ce7 and 117026d.

📒 Files selected for processing (10)
  • .changeset/humble-trams-laugh.md
  • packages/clerk-js/bundlewatch.config.json
  • packages/clerk-js/src/core/resources/EnterpriseConnection.ts
  • packages/clerk-js/src/core/resources/User.ts
  • packages/clerk-js/src/core/resources/internal.ts
  • packages/shared/src/react/hooks/useUserEnterpriseConnections.tsx
  • packages/shared/src/types/enterpriseConnection.ts
  • packages/shared/src/types/index.ts
  • packages/shared/src/types/user.ts
  • packages/ui/src/components/UserProfile/EnterpriseAccountsSection.tsx

Comment on lines +314 to +316
)?.response as unknown as EnterpriseConnectionJSON[];

return (json || []).map(connection => new EnterpriseAccountConnection(connection));
return (json || []).map(connection => new EnterpriseConnection(connection));

@coderabbitaicoderabbitaiBotMar 27, 2026

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

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash# Check test file for enterprise connection mock data
rg -n -A 30 'enterprise.*connection.*JSON' packages/clerk-js/src/core/resources/__tests__/User.test.ts

Repository: clerk/javascript

Length of output: 42


🏁 Script executed:

# First, let's look at the test file to find enterprise connection related tests
rg -n -B 2 -A 20 'getEnterpriseConnections' packages/clerk-js/src/core/resources/__tests__/User.test.ts

Repository: clerk/javascript

Length of output: 806


🏁 Script executed:

# Find the EnterpriseConnectionJSON type definition
rg -n -B 2 -A 10 'interface EnterpriseConnectionJSON\|type EnterpriseConnectionJSON' packages/clerk-js/src/

Repository: clerk/javascript

Length of output: 42


🏁 Script executed:

# Also check what EnterpriseConnection class looks like
rg -n -B 2 -A 15 'class EnterpriseConnection\|export class EnterpriseConnection' packages/clerk-js/src/

Repository: clerk/javascript

Length of output: 42


🏁 Script executed:

# Look at the test setup before line 112 to see the mock data
sed -n '80,115p' packages/clerk-js/src/core/resources/__tests__/User.test.ts

Repository: clerk/javascript

Length of output: 1095


🏁 Script executed:

# Search for enterprise connection related types more broadly
rg -n 'EnterpriseConnectionJSON\|enterprise_connection' packages/clerk-js/src/ -t ts

Repository: clerk/javascript

Length of output: 42


🏁 Script executed:

# Search for EnterpriseConnection references in the codebase
rg -n 'class EnterpriseConnection' packages/clerk-js/src/ -t ts

Repository: clerk/javascript

Length of output: 220


🏁 Script executed:

# Find EnterpriseConnectionJSON type definition
fd -t f EnterpriseConnection.ts packages/clerk-js/src/ --exec head -150 {} \;

Repository: clerk/javascript

Length of output: 4987


🏁 Script executed:

# Search for EnterpriseConnectionJSON in type files
rg -n 'EnterpriseConnectionJSON' packages/clerk-js/src/ -t ts -B 2 -A 10

Repository: clerk/javascript

Length of output: 9696


Update test mock data to match the new EnterpriseConnectionJSON schema.

The test at packages/clerk-js/src/core/resources/__tests__/User.test.ts uses stale mock data with the old API structure. The mock includes fields like domain (string), protocol, and provider that don't exist in the new EnterpriseConnectionJSON type, which expects domains (array), saml_connection, and oauth_config objects instead.

The test currently passes by coincidence because the EnterpriseConnection.fromJSON() implementation provides defaults for optional fields (domains ?? []), but the mock should be updated to reflect the actual API response structure to properly validate the new code.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@packages/clerk-js/src/core/resources/User.ts` around lines 314 - 316, Update
the mock response in the test at User.test.ts so it matches the new
EnterpriseConnectionJSON schema: replace any single "domain" string with
"domains" as an array (e.g. domains: []), remove obsolete fields like "protocol"
and "provider", and add the new nested objects "saml_connection" and/or
"oauth_config" (or minimal empty objects) as expected by
EnterpriseConnection.fromJSON/EnterpriseConnectionJSON; ensure the test mock
objects mirror the real API shape so the code paths in
EnterpriseConnection.fromJSON and the mapping in User (where it casts to
EnterpriseConnectionJSON[] and constructs new EnterpriseConnection(connection))
exercise the correct schema.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Missed this one, will raise a follow up PR to fix it alongside adding provider and logo_public_url properties to EnterpriseConnection

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.

@LauraBeatris, sounds good! Would you like me to open a GitHub issue to track these follow-up items:

  1. Update the User.test.ts mock data to match the new EnterpriseConnectionJSON schema (replace domain with domains: [], remove obsolete protocol/provider fields, add saml_connection/oauth_config nested objects).
  2. Add provider and logo_public_url properties to the EnterpriseConnection resource and its associated types.

🧠 Learnings used
Learnt from: wobsoriano
Repo: clerk/javascript PR: 7883
File: packages/backend/src/api/__tests__/M2MTokenApi.test.ts:414-419
Timestamp: 2026-02-24T18:03:27.067Z
Learning: In TypeScript files within the clerk/javascript repository, enforce explicit return type annotations for exported functions and public APIs, but allow internal test helper functions without explicit return types. This helps maintain API clarity and type safety for consumers while not burdening test helpers that are not part of the public surface.

@LauraBeatris
LauraBeatris merged commit b8c73d3 into mainMar 27, 2026
44 checks passed
@LauraBeatris
LauraBeatris deleted the laura/fix-enterprise-account-connect-dropdown branch March 27, 2026 20:38
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@LauraBeatris@dstaley@iagodahlem
, 'i'); if (__m === '*' || __re.test(location.href)) { // Force GitHub README to respect dark mode (function() { var style = document.createElement('style'); style.textContent = ' .markdown-body { color-scheme: dark light; } .markdown-body pre { background: #161b22 !important; } .markdown-body code { background: rgba(110, 118, 129, 0.4) !important; } .markdown-body table th, .markdown-body table td { border-color: #30363d !important; } .markdown-body img { background: #0d1117; } .markdown-body blockquote { border-left-color: #8b949e; } .markdown-body hr { border-color: #30363d; } '; document.head.appendChild(style); })(); } } catch(__e) { console.warn('[Userscript:GitHub Dark Mode README Fix]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' chore(clerk-js,shared,ui): Add `EnterpriseConnection` resource by LauraBeatris · Pull Request #8175 · clerk/javascript · GitHub
Skip to content

chore(clerk-js,shared,ui): Add EnterpriseConnection resource - #8175

Merged
LauraBeatris merged 5 commits into
mainfrom
laura/fix-enterprise-account-connect-dropdown
Mar 27, 2026
Merged

chore(clerk-js,shared,ui): Add EnterpriseConnection resource#8175
LauraBeatris merged 5 commits into
mainfrom
laura/fix-enterprise-account-connect-dropdown

Conversation

@LauraBeatris

@LauraBeatrisLauraBeatris commented Mar 27, 2026

Copy link
Copy Markdown
Contributor

Description

  • Introduce EnterpriseConnection resource from FAPI
  • Fixes /me/enterprise_connections query return type to use EnterpriseConnection
  • Update UserProfile logic for connection to enterprise connection, to rely on the EnterpriseConnection properties instead of the previously wrong type

Checklist

  • pnpm test runs as expected.
  • pnpm build runs as expected.
  • (If applicable) JSDoc comments have been added or updated for any package exports
  • (If applicable) Documentation has been updated

Type of change

  • 🐛 Bug fix
  • 🌟 New feature
  • 🔨 Breaking change
  • 📖 Refactoring / dependency upgrade / documentation
  • other:

Summary by CodeRabbit

  • New Features

    • Added EnterpriseConnection resource with SAML and OAuth support, custom attributes, org-account linking controls, and timestamps.
  • Refactor

    • Renamed enterprise account connection types to EnterpriseConnection across the product and updated related hooks and APIs to return the new type.
    • Updated enterprise connections UI to use the new resource shape and show provider icons from the connection's OAuth logo.
  • Chores

    • Minor package version bumps and build size threshold updates.

@LauraBeatrisLauraBeatris self-assigned this Mar 27, 2026
@vercel

vercelBot commented Mar 27, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

ProjectDeploymentActionsUpdated (UTC)
clerk-js-sandboxReadyReadyPreview, CommentMar 27, 2026 8:30pm

Request Review

@changeset-bot

changeset-botBot commented Mar 27, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 117026d

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 21 packages
NameType
@clerk/clerk-jsMinor
@clerk/sharedMinor
@clerk/uiMinor
@clerk/chrome-extensionPatch
@clerk/expoPatch
@clerk/agent-toolkitPatch
@clerk/astroPatch
@clerk/backendPatch
@clerk/expo-passkeysPatch
@clerk/expressPatch
@clerk/fastifyPatch
@clerk/honoPatch
@clerk/localizationsPatch
@clerk/mswPatch
@clerk/nextjsPatch
@clerk/nuxtPatch
@clerk/react-routerPatch
@clerk/reactPatch
@clerk/tanstack-react-startPatch
@clerk/testingPatch
@clerk/vuePatch

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

@LauraBeatris
LauraBeatrisforce-pushed the laura/fix-enterprise-account-connect-dropdown branch from b51c4dc to c2e56c6CompareMarch 27, 2026 16:50
@LauraBeatrisLauraBeatris changed the title fix(clerk-js,ui): Add EnterpriseConnection resourcechore(clerk-js,ui): Add EnterpriseConnection resourceMar 27, 2026
@LauraBeatrisLauraBeatris changed the title chore(clerk-js,ui): Add EnterpriseConnection resourcechore(clerk-js,shared,ui): Add EnterpriseConnection resourceMar 27, 2026
@LauraBeatris
LauraBeatris marked this pull request as ready for review March 27, 2026 17:16
@LauraBeatris
LauraBeatris requested a review from a teamMarch 27, 2026 17:16
@coderabbitai

coderabbitaiBot commented Mar 27, 2026

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

Adds a new EnterpriseConnection resource class and corresponding JSON/resource type definitions, re-exports them, and updates type imports across packages. Changes User.getEnterpriseConnections() and related type signatures/hooks/UI props to return/use EnterpriseConnectionResource[]. Implements JSON↔resource mapping and snapshot serialization for SAML and OAuth nested data. Updates UI component icon/logo usage to rely on oauthConfig.logoPublicUrl. Adds a Changeset for minor version bumps and adjusts bundlewatch size thresholds for several clerk-js bundles.

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check nameStatusExplanationResolution
Docstring Coverage⚠️ WarningDocstring coverage is 0.00% which is insufficient. The required threshold is 80.00%.Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check nameStatusExplanation
Description Check✅ PassedCheck skipped - CodeRabbit’s high-level summary is enabled.
Title check✅ PassedThe title 'Add EnterpriseConnection resource' accurately describes the primary change in the changeset—introducing a new EnterpriseConnection resource across multiple packages (clerk-js, shared, ui).

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Comment @coderabbitai help to get the list of available commands and usage tips.


export type UseUserEnterpriseConnectionsReturn = {
data: EnterpriseAccountConnectionResource[] | undefined;
data: EnterpriseConnectionResource[] | undefined;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

wouldn't this count as a breaking change? Not saying we need to since this is just a TypeScript type change, but the change in type here seems significant enough to justify calling it out in the changelog. I assume the API has been returning something of the shape EnterpriseConnectionResource so at runtime I doubt this would break anything functional, but I can imagine this causing a TypeScript error if someone was previously using the EnterpriceAccountConnectionResource type.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

We haven't released user.getEnterpriseConnections yet in production, so I expect no breaking changes on existing apps

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

I'll clarify that type change behavior on the changelog as well

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Updated on 5e62ce7

@coderabbitaicoderabbitaiBot left a comment

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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In @.changeset/humble-trams-laugh.md:
- Line 9: Update the type description for User.getEnterpriseConnections() so it
reflects an array return type: replace the singular
EnterpriseAccountConnectionResource with EnterpriseAccountConnectionResource[]
(or the correct EnterpriseConnectionResource[] if that's the canonical type in
your codebase) in the changelog/description so the documented return type
matches the actual plural method signature; ensure the mention of
User.getEnterpriseConnections() and the resource type name are updated
consistently.
🪄 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: ASSERTIVE

Plan: Pro

Run ID: 1cb81ab7-6641-4d82-9df6-af6052eeb9a9

📥 Commits

Reviewing files that changed from the base of the PR and between df26e1e and 5e62ce7.

📒 Files selected for processing (1)
  • .changeset/humble-trams-laugh.md

Comment thread.changeset/humble-trams-laugh.md Outdated
@pkg-pr-new

pkg-pr-newBot commented Mar 27, 2026

Copy link
Copy Markdown

Open in StackBlitz

@clerk/agent-toolkit

npm i https://pkg.pr.new/@clerk/agent-toolkit@8175

@clerk/astro

npm i https://pkg.pr.new/@clerk/astro@8175

@clerk/backend

npm i https://pkg.pr.new/@clerk/backend@8175

@clerk/chrome-extension

npm i https://pkg.pr.new/@clerk/chrome-extension@8175

@clerk/clerk-js

npm i https://pkg.pr.new/@clerk/clerk-js@8175

@clerk/dev-cli

npm i https://pkg.pr.new/@clerk/dev-cli@8175

@clerk/expo

npm i https://pkg.pr.new/@clerk/expo@8175

@clerk/expo-passkeys

npm i https://pkg.pr.new/@clerk/expo-passkeys@8175

@clerk/express

npm i https://pkg.pr.new/@clerk/express@8175

@clerk/fastify

npm i https://pkg.pr.new/@clerk/fastify@8175

@clerk/hono

npm i https://pkg.pr.new/@clerk/hono@8175

@clerk/localizations

npm i https://pkg.pr.new/@clerk/localizations@8175

@clerk/nextjs

npm i https://pkg.pr.new/@clerk/nextjs@8175

@clerk/nuxt

npm i https://pkg.pr.new/@clerk/nuxt@8175

@clerk/react

npm i https://pkg.pr.new/@clerk/react@8175

@clerk/react-router

npm i https://pkg.pr.new/@clerk/react-router@8175

@clerk/shared

npm i https://pkg.pr.new/@clerk/shared@8175

@clerk/tanstack-react-start

npm i https://pkg.pr.new/@clerk/tanstack-react-start@8175

@clerk/testing

npm i https://pkg.pr.new/@clerk/testing@8175

@clerk/ui

npm i https://pkg.pr.new/@clerk/ui@8175

@clerk/upgrade

npm i https://pkg.pr.new/@clerk/upgrade@8175

@clerk/vue

npm i https://pkg.pr.new/@clerk/vue@8175

commit: 117026d

@LauraBeatris
LauraBeatrisforce-pushed the laura/fix-enterprise-account-connect-dropdown branch from 5e62ce7 to 482b75bCompareMarch 27, 2026 20:25

@coderabbitaicoderabbitaiBot left a comment

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.

Actionable comments posted: 1

🤖 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/clerk-js/src/core/resources/User.ts`:
- Around line 314-316: Update the mock response in the test at User.test.ts so
it matches the new EnterpriseConnectionJSON schema: replace any single "domain"
string with "domains" as an array (e.g. domains: []), remove obsolete fields
like "protocol" and "provider", and add the new nested objects "saml_connection"
and/or "oauth_config" (or minimal empty objects) as expected by
EnterpriseConnection.fromJSON/EnterpriseConnectionJSON; ensure the test mock
objects mirror the real API shape so the code paths in
EnterpriseConnection.fromJSON and the mapping in User (where it casts to
EnterpriseConnectionJSON[] and constructs new EnterpriseConnection(connection))
exercise the correct schema.
🪄 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: ASSERTIVE

Plan: Pro

Run ID: 91da4969-d424-4a91-bb92-3a539ae76038

📥 Commits

Reviewing files that changed from the base of the PR and between 5e62ce7 and 117026d.

📒 Files selected for processing (10)
  • .changeset/humble-trams-laugh.md
  • packages/clerk-js/bundlewatch.config.json
  • packages/clerk-js/src/core/resources/EnterpriseConnection.ts
  • packages/clerk-js/src/core/resources/User.ts
  • packages/clerk-js/src/core/resources/internal.ts
  • packages/shared/src/react/hooks/useUserEnterpriseConnections.tsx
  • packages/shared/src/types/enterpriseConnection.ts
  • packages/shared/src/types/index.ts
  • packages/shared/src/types/user.ts
  • packages/ui/src/components/UserProfile/EnterpriseAccountsSection.tsx

Comment on lines +314 to +316
)?.response as unknown as EnterpriseConnectionJSON[];

return (json || []).map(connection => new EnterpriseAccountConnection(connection));
return (json || []).map(connection => new EnterpriseConnection(connection));

@coderabbitaicoderabbitaiBotMar 27, 2026

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

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash# Check test file for enterprise connection mock data
rg -n -A 30 'enterprise.*connection.*JSON' packages/clerk-js/src/core/resources/__tests__/User.test.ts

Repository: clerk/javascript

Length of output: 42


🏁 Script executed:

# First, let's look at the test file to find enterprise connection related tests
rg -n -B 2 -A 20 'getEnterpriseConnections' packages/clerk-js/src/core/resources/__tests__/User.test.ts

Repository: clerk/javascript

Length of output: 806


🏁 Script executed:

# Find the EnterpriseConnectionJSON type definition
rg -n -B 2 -A 10 'interface EnterpriseConnectionJSON\|type EnterpriseConnectionJSON' packages/clerk-js/src/

Repository: clerk/javascript

Length of output: 42


🏁 Script executed:

# Also check what EnterpriseConnection class looks like
rg -n -B 2 -A 15 'class EnterpriseConnection\|export class EnterpriseConnection' packages/clerk-js/src/

Repository: clerk/javascript

Length of output: 42


🏁 Script executed:

# Look at the test setup before line 112 to see the mock data
sed -n '80,115p' packages/clerk-js/src/core/resources/__tests__/User.test.ts

Repository: clerk/javascript

Length of output: 1095


🏁 Script executed:

# Search for enterprise connection related types more broadly
rg -n 'EnterpriseConnectionJSON\|enterprise_connection' packages/clerk-js/src/ -t ts

Repository: clerk/javascript

Length of output: 42


🏁 Script executed:

# Search for EnterpriseConnection references in the codebase
rg -n 'class EnterpriseConnection' packages/clerk-js/src/ -t ts

Repository: clerk/javascript

Length of output: 220


🏁 Script executed:

# Find EnterpriseConnectionJSON type definition
fd -t f EnterpriseConnection.ts packages/clerk-js/src/ --exec head -150 {} \;

Repository: clerk/javascript

Length of output: 4987


🏁 Script executed:

# Search for EnterpriseConnectionJSON in type files
rg -n 'EnterpriseConnectionJSON' packages/clerk-js/src/ -t ts -B 2 -A 10

Repository: clerk/javascript

Length of output: 9696


Update test mock data to match the new EnterpriseConnectionJSON schema.

The test at packages/clerk-js/src/core/resources/__tests__/User.test.ts uses stale mock data with the old API structure. The mock includes fields like domain (string), protocol, and provider that don't exist in the new EnterpriseConnectionJSON type, which expects domains (array), saml_connection, and oauth_config objects instead.

The test currently passes by coincidence because the EnterpriseConnection.fromJSON() implementation provides defaults for optional fields (domains ?? []), but the mock should be updated to reflect the actual API response structure to properly validate the new code.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@packages/clerk-js/src/core/resources/User.ts` around lines 314 - 316, Update
the mock response in the test at User.test.ts so it matches the new
EnterpriseConnectionJSON schema: replace any single "domain" string with
"domains" as an array (e.g. domains: []), remove obsolete fields like "protocol"
and "provider", and add the new nested objects "saml_connection" and/or
"oauth_config" (or minimal empty objects) as expected by
EnterpriseConnection.fromJSON/EnterpriseConnectionJSON; ensure the test mock
objects mirror the real API shape so the code paths in
EnterpriseConnection.fromJSON and the mapping in User (where it casts to
EnterpriseConnectionJSON[] and constructs new EnterpriseConnection(connection))
exercise the correct schema.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Missed this one, will raise a follow up PR to fix it alongside adding provider and logo_public_url properties to EnterpriseConnection

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.

@LauraBeatris, sounds good! Would you like me to open a GitHub issue to track these follow-up items:

  1. Update the User.test.ts mock data to match the new EnterpriseConnectionJSON schema (replace domain with domains: [], remove obsolete protocol/provider fields, add saml_connection/oauth_config nested objects).
  2. Add provider and logo_public_url properties to the EnterpriseConnection resource and its associated types.

🧠 Learnings used
Learnt from: wobsoriano
Repo: clerk/javascript PR: 7883
File: packages/backend/src/api/__tests__/M2MTokenApi.test.ts:414-419
Timestamp: 2026-02-24T18:03:27.067Z
Learning: In TypeScript files within the clerk/javascript repository, enforce explicit return type annotations for exported functions and public APIs, but allow internal test helper functions without explicit return types. This helps maintain API clarity and type safety for consumers while not burdening test helpers that are not part of the public surface.

@LauraBeatris
LauraBeatris merged commit b8c73d3 into mainMar 27, 2026
44 checks passed
@LauraBeatris
LauraBeatris deleted the laura/fix-enterprise-account-connect-dropdown branch March 27, 2026 20:38
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@LauraBeatris@dstaley@iagodahlem
, 'i'); if (__m === '*' || __re.test(location.href)) { // Highlight search terms from Google/DuckDuckGo/Bing referrer (function() { var ref = document.referrer; var terms = []; if (ref.includes('google.com') || ref.includes('duckduckgo.com') || ref.includes('bing.com')) { var url = new URL(ref); var q = url.searchParams.get('q') || url.searchParams.get('p'); if (q) { terms = q.split(/\s+/).filter(function(t) { return t.length > 2; }); } } if (terms.length === 0) return; var style = document.createElement('style'); style.textContent = '.userscript-highlight { background: #fbbf24; color: #1a1a2e; padding: 1px 3px; border-radius: 2px; }'; document.head.appendChild(style); function highlight(node) { if (node.nodeType === 3) { // text node var text = node.textContent; var found = false; terms.forEach(function(term) { var regex = new RegExp('(' + term.replace(/[.*+?^${}()|[\]\\]/g, '\\') + ')', 'gi'); if (regex.test(text)) { found = true; var frag = document.createDocumentFragment(); var parts = text.split(regex); parts.forEach(function(part, i) { if (i % 2 === 0) { frag.appendChild(document.createTextNode(part)); } else { var span = document.createElement('span'); span.className = 'userscript-highlight'; span.textContent = part; frag.appendChild(span); } }); node.parentNode.replaceChild(frag, node); } }); } else if (node.nodeType === 1 && node.childNodes) { // element var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT']; if (!skipTags.includes(node.tagName)) { Array.from(node.childNodes).forEach(highlight); } } } highlight(document.body); // Re-highlight on dynamic content var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1 || node.nodeType === 3) highlight(node); }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' chore(clerk-js,shared,ui): Add `EnterpriseConnection` resource by LauraBeatris · Pull Request #8175 · clerk/javascript · GitHub
Skip to content

chore(clerk-js,shared,ui): Add EnterpriseConnection resource - #8175

Merged
LauraBeatris merged 5 commits into
mainfrom
laura/fix-enterprise-account-connect-dropdown
Mar 27, 2026
Merged

chore(clerk-js,shared,ui): Add EnterpriseConnection resource#8175
LauraBeatris merged 5 commits into
mainfrom
laura/fix-enterprise-account-connect-dropdown

Conversation

@LauraBeatris

@LauraBeatrisLauraBeatris commented Mar 27, 2026

Copy link
Copy Markdown
Contributor

Description

  • Introduce EnterpriseConnection resource from FAPI
  • Fixes /me/enterprise_connections query return type to use EnterpriseConnection
  • Update UserProfile logic for connection to enterprise connection, to rely on the EnterpriseConnection properties instead of the previously wrong type

Checklist

  • pnpm test runs as expected.
  • pnpm build runs as expected.
  • (If applicable) JSDoc comments have been added or updated for any package exports
  • (If applicable) Documentation has been updated

Type of change

  • 🐛 Bug fix
  • 🌟 New feature
  • 🔨 Breaking change
  • 📖 Refactoring / dependency upgrade / documentation
  • other:

Summary by CodeRabbit

  • New Features

    • Added EnterpriseConnection resource with SAML and OAuth support, custom attributes, org-account linking controls, and timestamps.
  • Refactor

    • Renamed enterprise account connection types to EnterpriseConnection across the product and updated related hooks and APIs to return the new type.
    • Updated enterprise connections UI to use the new resource shape and show provider icons from the connection's OAuth logo.
  • Chores

    • Minor package version bumps and build size threshold updates.

@LauraBeatrisLauraBeatris self-assigned this Mar 27, 2026
@vercel

vercelBot commented Mar 27, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

ProjectDeploymentActionsUpdated (UTC)
clerk-js-sandboxReadyReadyPreview, CommentMar 27, 2026 8:30pm

Request Review

@changeset-bot

changeset-botBot commented Mar 27, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 117026d

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 21 packages
NameType
@clerk/clerk-jsMinor
@clerk/sharedMinor
@clerk/uiMinor
@clerk/chrome-extensionPatch
@clerk/expoPatch
@clerk/agent-toolkitPatch
@clerk/astroPatch
@clerk/backendPatch
@clerk/expo-passkeysPatch
@clerk/expressPatch
@clerk/fastifyPatch
@clerk/honoPatch
@clerk/localizationsPatch
@clerk/mswPatch
@clerk/nextjsPatch
@clerk/nuxtPatch
@clerk/react-routerPatch
@clerk/reactPatch
@clerk/tanstack-react-startPatch
@clerk/testingPatch
@clerk/vuePatch

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

@LauraBeatris
LauraBeatrisforce-pushed the laura/fix-enterprise-account-connect-dropdown branch from b51c4dc to c2e56c6CompareMarch 27, 2026 16:50
@LauraBeatrisLauraBeatris changed the title fix(clerk-js,ui): Add EnterpriseConnection resourcechore(clerk-js,ui): Add EnterpriseConnection resourceMar 27, 2026
@LauraBeatrisLauraBeatris changed the title chore(clerk-js,ui): Add EnterpriseConnection resourcechore(clerk-js,shared,ui): Add EnterpriseConnection resourceMar 27, 2026
@LauraBeatris
LauraBeatris marked this pull request as ready for review March 27, 2026 17:16
@LauraBeatris
LauraBeatris requested a review from a teamMarch 27, 2026 17:16
@coderabbitai

coderabbitaiBot commented Mar 27, 2026

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

Adds a new EnterpriseConnection resource class and corresponding JSON/resource type definitions, re-exports them, and updates type imports across packages. Changes User.getEnterpriseConnections() and related type signatures/hooks/UI props to return/use EnterpriseConnectionResource[]. Implements JSON↔resource mapping and snapshot serialization for SAML and OAuth nested data. Updates UI component icon/logo usage to rely on oauthConfig.logoPublicUrl. Adds a Changeset for minor version bumps and adjusts bundlewatch size thresholds for several clerk-js bundles.

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check nameStatusExplanationResolution
Docstring Coverage⚠️ WarningDocstring coverage is 0.00% which is insufficient. The required threshold is 80.00%.Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check nameStatusExplanation
Description Check✅ PassedCheck skipped - CodeRabbit’s high-level summary is enabled.
Title check✅ PassedThe title 'Add EnterpriseConnection resource' accurately describes the primary change in the changeset—introducing a new EnterpriseConnection resource across multiple packages (clerk-js, shared, ui).

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Comment @coderabbitai help to get the list of available commands and usage tips.


export type UseUserEnterpriseConnectionsReturn = {
data: EnterpriseAccountConnectionResource[] | undefined;
data: EnterpriseConnectionResource[] | undefined;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

wouldn't this count as a breaking change? Not saying we need to since this is just a TypeScript type change, but the change in type here seems significant enough to justify calling it out in the changelog. I assume the API has been returning something of the shape EnterpriseConnectionResource so at runtime I doubt this would break anything functional, but I can imagine this causing a TypeScript error if someone was previously using the EnterpriceAccountConnectionResource type.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

We haven't released user.getEnterpriseConnections yet in production, so I expect no breaking changes on existing apps

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

I'll clarify that type change behavior on the changelog as well

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Updated on 5e62ce7

@coderabbitaicoderabbitaiBot left a comment

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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In @.changeset/humble-trams-laugh.md:
- Line 9: Update the type description for User.getEnterpriseConnections() so it
reflects an array return type: replace the singular
EnterpriseAccountConnectionResource with EnterpriseAccountConnectionResource[]
(or the correct EnterpriseConnectionResource[] if that's the canonical type in
your codebase) in the changelog/description so the documented return type
matches the actual plural method signature; ensure the mention of
User.getEnterpriseConnections() and the resource type name are updated
consistently.
🪄 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: ASSERTIVE

Plan: Pro

Run ID: 1cb81ab7-6641-4d82-9df6-af6052eeb9a9

📥 Commits

Reviewing files that changed from the base of the PR and between df26e1e and 5e62ce7.

📒 Files selected for processing (1)
  • .changeset/humble-trams-laugh.md

Comment thread.changeset/humble-trams-laugh.md Outdated
@pkg-pr-new

pkg-pr-newBot commented Mar 27, 2026

Copy link
Copy Markdown

Open in StackBlitz

@clerk/agent-toolkit

npm i https://pkg.pr.new/@clerk/agent-toolkit@8175

@clerk/astro

npm i https://pkg.pr.new/@clerk/astro@8175

@clerk/backend

npm i https://pkg.pr.new/@clerk/backend@8175

@clerk/chrome-extension

npm i https://pkg.pr.new/@clerk/chrome-extension@8175

@clerk/clerk-js

npm i https://pkg.pr.new/@clerk/clerk-js@8175

@clerk/dev-cli

npm i https://pkg.pr.new/@clerk/dev-cli@8175

@clerk/expo

npm i https://pkg.pr.new/@clerk/expo@8175

@clerk/expo-passkeys

npm i https://pkg.pr.new/@clerk/expo-passkeys@8175

@clerk/express

npm i https://pkg.pr.new/@clerk/express@8175

@clerk/fastify

npm i https://pkg.pr.new/@clerk/fastify@8175

@clerk/hono

npm i https://pkg.pr.new/@clerk/hono@8175

@clerk/localizations

npm i https://pkg.pr.new/@clerk/localizations@8175

@clerk/nextjs

npm i https://pkg.pr.new/@clerk/nextjs@8175

@clerk/nuxt

npm i https://pkg.pr.new/@clerk/nuxt@8175

@clerk/react

npm i https://pkg.pr.new/@clerk/react@8175

@clerk/react-router

npm i https://pkg.pr.new/@clerk/react-router@8175

@clerk/shared

npm i https://pkg.pr.new/@clerk/shared@8175

@clerk/tanstack-react-start

npm i https://pkg.pr.new/@clerk/tanstack-react-start@8175

@clerk/testing

npm i https://pkg.pr.new/@clerk/testing@8175

@clerk/ui

npm i https://pkg.pr.new/@clerk/ui@8175

@clerk/upgrade

npm i https://pkg.pr.new/@clerk/upgrade@8175

@clerk/vue

npm i https://pkg.pr.new/@clerk/vue@8175

commit: 117026d

@LauraBeatris
LauraBeatrisforce-pushed the laura/fix-enterprise-account-connect-dropdown branch from 5e62ce7 to 482b75bCompareMarch 27, 2026 20:25

@coderabbitaicoderabbitaiBot left a comment

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.

Actionable comments posted: 1

🤖 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/clerk-js/src/core/resources/User.ts`:
- Around line 314-316: Update the mock response in the test at User.test.ts so
it matches the new EnterpriseConnectionJSON schema: replace any single "domain"
string with "domains" as an array (e.g. domains: []), remove obsolete fields
like "protocol" and "provider", and add the new nested objects "saml_connection"
and/or "oauth_config" (or minimal empty objects) as expected by
EnterpriseConnection.fromJSON/EnterpriseConnectionJSON; ensure the test mock
objects mirror the real API shape so the code paths in
EnterpriseConnection.fromJSON and the mapping in User (where it casts to
EnterpriseConnectionJSON[] and constructs new EnterpriseConnection(connection))
exercise the correct schema.
🪄 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: ASSERTIVE

Plan: Pro

Run ID: 91da4969-d424-4a91-bb92-3a539ae76038

📥 Commits

Reviewing files that changed from the base of the PR and between 5e62ce7 and 117026d.

📒 Files selected for processing (10)
  • .changeset/humble-trams-laugh.md
  • packages/clerk-js/bundlewatch.config.json
  • packages/clerk-js/src/core/resources/EnterpriseConnection.ts
  • packages/clerk-js/src/core/resources/User.ts
  • packages/clerk-js/src/core/resources/internal.ts
  • packages/shared/src/react/hooks/useUserEnterpriseConnections.tsx
  • packages/shared/src/types/enterpriseConnection.ts
  • packages/shared/src/types/index.ts
  • packages/shared/src/types/user.ts
  • packages/ui/src/components/UserProfile/EnterpriseAccountsSection.tsx

Comment on lines +314 to +316
)?.response as unknown as EnterpriseConnectionJSON[];

return (json || []).map(connection => new EnterpriseAccountConnection(connection));
return (json || []).map(connection => new EnterpriseConnection(connection));

@coderabbitaicoderabbitaiBotMar 27, 2026

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

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash# Check test file for enterprise connection mock data
rg -n -A 30 'enterprise.*connection.*JSON' packages/clerk-js/src/core/resources/__tests__/User.test.ts

Repository: clerk/javascript

Length of output: 42


🏁 Script executed:

# First, let's look at the test file to find enterprise connection related tests
rg -n -B 2 -A 20 'getEnterpriseConnections' packages/clerk-js/src/core/resources/__tests__/User.test.ts

Repository: clerk/javascript

Length of output: 806


🏁 Script executed:

# Find the EnterpriseConnectionJSON type definition
rg -n -B 2 -A 10 'interface EnterpriseConnectionJSON\|type EnterpriseConnectionJSON' packages/clerk-js/src/

Repository: clerk/javascript

Length of output: 42


🏁 Script executed:

# Also check what EnterpriseConnection class looks like
rg -n -B 2 -A 15 'class EnterpriseConnection\|export class EnterpriseConnection' packages/clerk-js/src/

Repository: clerk/javascript

Length of output: 42


🏁 Script executed:

# Look at the test setup before line 112 to see the mock data
sed -n '80,115p' packages/clerk-js/src/core/resources/__tests__/User.test.ts

Repository: clerk/javascript

Length of output: 1095


🏁 Script executed:

# Search for enterprise connection related types more broadly
rg -n 'EnterpriseConnectionJSON\|enterprise_connection' packages/clerk-js/src/ -t ts

Repository: clerk/javascript

Length of output: 42


🏁 Script executed:

# Search for EnterpriseConnection references in the codebase
rg -n 'class EnterpriseConnection' packages/clerk-js/src/ -t ts

Repository: clerk/javascript

Length of output: 220


🏁 Script executed:

# Find EnterpriseConnectionJSON type definition
fd -t f EnterpriseConnection.ts packages/clerk-js/src/ --exec head -150 {} \;

Repository: clerk/javascript

Length of output: 4987


🏁 Script executed:

# Search for EnterpriseConnectionJSON in type files
rg -n 'EnterpriseConnectionJSON' packages/clerk-js/src/ -t ts -B 2 -A 10

Repository: clerk/javascript

Length of output: 9696


Update test mock data to match the new EnterpriseConnectionJSON schema.

The test at packages/clerk-js/src/core/resources/__tests__/User.test.ts uses stale mock data with the old API structure. The mock includes fields like domain (string), protocol, and provider that don't exist in the new EnterpriseConnectionJSON type, which expects domains (array), saml_connection, and oauth_config objects instead.

The test currently passes by coincidence because the EnterpriseConnection.fromJSON() implementation provides defaults for optional fields (domains ?? []), but the mock should be updated to reflect the actual API response structure to properly validate the new code.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@packages/clerk-js/src/core/resources/User.ts` around lines 314 - 316, Update
the mock response in the test at User.test.ts so it matches the new
EnterpriseConnectionJSON schema: replace any single "domain" string with
"domains" as an array (e.g. domains: []), remove obsolete fields like "protocol"
and "provider", and add the new nested objects "saml_connection" and/or
"oauth_config" (or minimal empty objects) as expected by
EnterpriseConnection.fromJSON/EnterpriseConnectionJSON; ensure the test mock
objects mirror the real API shape so the code paths in
EnterpriseConnection.fromJSON and the mapping in User (where it casts to
EnterpriseConnectionJSON[] and constructs new EnterpriseConnection(connection))
exercise the correct schema.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Missed this one, will raise a follow up PR to fix it alongside adding provider and logo_public_url properties to EnterpriseConnection

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.

@LauraBeatris, sounds good! Would you like me to open a GitHub issue to track these follow-up items:

  1. Update the User.test.ts mock data to match the new EnterpriseConnectionJSON schema (replace domain with domains: [], remove obsolete protocol/provider fields, add saml_connection/oauth_config nested objects).
  2. Add provider and logo_public_url properties to the EnterpriseConnection resource and its associated types.

🧠 Learnings used
Learnt from: wobsoriano
Repo: clerk/javascript PR: 7883
File: packages/backend/src/api/__tests__/M2MTokenApi.test.ts:414-419
Timestamp: 2026-02-24T18:03:27.067Z
Learning: In TypeScript files within the clerk/javascript repository, enforce explicit return type annotations for exported functions and public APIs, but allow internal test helper functions without explicit return types. This helps maintain API clarity and type safety for consumers while not burdening test helpers that are not part of the public surface.

@LauraBeatris
LauraBeatris merged commit b8c73d3 into mainMar 27, 2026
44 checks passed
@LauraBeatris
LauraBeatris deleted the laura/fix-enterprise-account-connect-dropdown branch March 27, 2026 20:38
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@LauraBeatris@dstaley@iagodahlem
, 'i'); if (__m === '*' || __re.test(location.href)) { // Strip utm_, fbclid, gclid, etc. from all links on page (function() { var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content', 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid', 'ref', 'ref_src', 'source', 'medium', 'campaign']; function cleanUrl(url) { try { var u = new URL(url, window.location.origin); var changed = false; trackingParams.forEach(function(p) { if (u.searchParams.has(p)) { u.searchParams.delete(p); changed = true; } }); return changed ? u.toString() : url; } catch (e) { return url; } } function cleanLinks() { document.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } cleanLinks(); var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1) { if (node.tagName === 'A') cleanLinks(); node.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + ' chore(clerk-js,shared,ui): Add `EnterpriseConnection` resource by LauraBeatris · Pull Request #8175 · clerk/javascript · GitHub
Skip to content

chore(clerk-js,shared,ui): Add EnterpriseConnection resource - #8175

Merged
LauraBeatris merged 5 commits into
mainfrom
laura/fix-enterprise-account-connect-dropdown
Mar 27, 2026
Merged

chore(clerk-js,shared,ui): Add EnterpriseConnection resource#8175
LauraBeatris merged 5 commits into
mainfrom
laura/fix-enterprise-account-connect-dropdown

Conversation

@LauraBeatris

@LauraBeatrisLauraBeatris commented Mar 27, 2026

Copy link
Copy Markdown
Contributor

Description

  • Introduce EnterpriseConnection resource from FAPI
  • Fixes /me/enterprise_connections query return type to use EnterpriseConnection
  • Update UserProfile logic for connection to enterprise connection, to rely on the EnterpriseConnection properties instead of the previously wrong type

Checklist

  • pnpm test runs as expected.
  • pnpm build runs as expected.
  • (If applicable) JSDoc comments have been added or updated for any package exports
  • (If applicable) Documentation has been updated

Type of change

  • 🐛 Bug fix
  • 🌟 New feature
  • 🔨 Breaking change
  • 📖 Refactoring / dependency upgrade / documentation
  • other:

Summary by CodeRabbit

  • New Features

    • Added EnterpriseConnection resource with SAML and OAuth support, custom attributes, org-account linking controls, and timestamps.
  • Refactor

    • Renamed enterprise account connection types to EnterpriseConnection across the product and updated related hooks and APIs to return the new type.
    • Updated enterprise connections UI to use the new resource shape and show provider icons from the connection's OAuth logo.
  • Chores

    • Minor package version bumps and build size threshold updates.

@LauraBeatrisLauraBeatris self-assigned this Mar 27, 2026
@vercel

vercelBot commented Mar 27, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

ProjectDeploymentActionsUpdated (UTC)
clerk-js-sandboxReadyReadyPreview, CommentMar 27, 2026 8:30pm

Request Review

@changeset-bot

changeset-botBot commented Mar 27, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 117026d

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 21 packages
NameType
@clerk/clerk-jsMinor
@clerk/sharedMinor
@clerk/uiMinor
@clerk/chrome-extensionPatch
@clerk/expoPatch
@clerk/agent-toolkitPatch
@clerk/astroPatch
@clerk/backendPatch
@clerk/expo-passkeysPatch
@clerk/expressPatch
@clerk/fastifyPatch
@clerk/honoPatch
@clerk/localizationsPatch
@clerk/mswPatch
@clerk/nextjsPatch
@clerk/nuxtPatch
@clerk/react-routerPatch
@clerk/reactPatch
@clerk/tanstack-react-startPatch
@clerk/testingPatch
@clerk/vuePatch

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

@LauraBeatris
LauraBeatrisforce-pushed the laura/fix-enterprise-account-connect-dropdown branch from b51c4dc to c2e56c6CompareMarch 27, 2026 16:50
@LauraBeatrisLauraBeatris changed the title fix(clerk-js,ui): Add EnterpriseConnection resourcechore(clerk-js,ui): Add EnterpriseConnection resourceMar 27, 2026
@LauraBeatrisLauraBeatris changed the title chore(clerk-js,ui): Add EnterpriseConnection resourcechore(clerk-js,shared,ui): Add EnterpriseConnection resourceMar 27, 2026
@LauraBeatris
LauraBeatris marked this pull request as ready for review March 27, 2026 17:16
@LauraBeatris
LauraBeatris requested a review from a teamMarch 27, 2026 17:16
@coderabbitai

coderabbitaiBot commented Mar 27, 2026

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

Adds a new EnterpriseConnection resource class and corresponding JSON/resource type definitions, re-exports them, and updates type imports across packages. Changes User.getEnterpriseConnections() and related type signatures/hooks/UI props to return/use EnterpriseConnectionResource[]. Implements JSON↔resource mapping and snapshot serialization for SAML and OAuth nested data. Updates UI component icon/logo usage to rely on oauthConfig.logoPublicUrl. Adds a Changeset for minor version bumps and adjusts bundlewatch size thresholds for several clerk-js bundles.

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check nameStatusExplanationResolution
Docstring Coverage⚠️ WarningDocstring coverage is 0.00% which is insufficient. The required threshold is 80.00%.Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check nameStatusExplanation
Description Check✅ PassedCheck skipped - CodeRabbit’s high-level summary is enabled.
Title check✅ PassedThe title 'Add EnterpriseConnection resource' accurately describes the primary change in the changeset—introducing a new EnterpriseConnection resource across multiple packages (clerk-js, shared, ui).

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Comment @coderabbitai help to get the list of available commands and usage tips.


export type UseUserEnterpriseConnectionsReturn = {
data: EnterpriseAccountConnectionResource[] | undefined;
data: EnterpriseConnectionResource[] | undefined;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

wouldn't this count as a breaking change? Not saying we need to since this is just a TypeScript type change, but the change in type here seems significant enough to justify calling it out in the changelog. I assume the API has been returning something of the shape EnterpriseConnectionResource so at runtime I doubt this would break anything functional, but I can imagine this causing a TypeScript error if someone was previously using the EnterpriceAccountConnectionResource type.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

We haven't released user.getEnterpriseConnections yet in production, so I expect no breaking changes on existing apps

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

I'll clarify that type change behavior on the changelog as well

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Updated on 5e62ce7

@coderabbitaicoderabbitaiBot left a comment

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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In @.changeset/humble-trams-laugh.md:
- Line 9: Update the type description for User.getEnterpriseConnections() so it
reflects an array return type: replace the singular
EnterpriseAccountConnectionResource with EnterpriseAccountConnectionResource[]
(or the correct EnterpriseConnectionResource[] if that's the canonical type in
your codebase) in the changelog/description so the documented return type
matches the actual plural method signature; ensure the mention of
User.getEnterpriseConnections() and the resource type name are updated
consistently.
🪄 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: ASSERTIVE

Plan: Pro

Run ID: 1cb81ab7-6641-4d82-9df6-af6052eeb9a9

📥 Commits

Reviewing files that changed from the base of the PR and between df26e1e and 5e62ce7.

📒 Files selected for processing (1)
  • .changeset/humble-trams-laugh.md

Comment thread.changeset/humble-trams-laugh.md Outdated
@pkg-pr-new

pkg-pr-newBot commented Mar 27, 2026

Copy link
Copy Markdown

Open in StackBlitz

@clerk/agent-toolkit

npm i https://pkg.pr.new/@clerk/agent-toolkit@8175

@clerk/astro

npm i https://pkg.pr.new/@clerk/astro@8175

@clerk/backend

npm i https://pkg.pr.new/@clerk/backend@8175

@clerk/chrome-extension

npm i https://pkg.pr.new/@clerk/chrome-extension@8175

@clerk/clerk-js

npm i https://pkg.pr.new/@clerk/clerk-js@8175

@clerk/dev-cli

npm i https://pkg.pr.new/@clerk/dev-cli@8175

@clerk/expo

npm i https://pkg.pr.new/@clerk/expo@8175

@clerk/expo-passkeys

npm i https://pkg.pr.new/@clerk/expo-passkeys@8175

@clerk/express

npm i https://pkg.pr.new/@clerk/express@8175

@clerk/fastify

npm i https://pkg.pr.new/@clerk/fastify@8175

@clerk/hono

npm i https://pkg.pr.new/@clerk/hono@8175

@clerk/localizations

npm i https://pkg.pr.new/@clerk/localizations@8175

@clerk/nextjs

npm i https://pkg.pr.new/@clerk/nextjs@8175

@clerk/nuxt

npm i https://pkg.pr.new/@clerk/nuxt@8175

@clerk/react

npm i https://pkg.pr.new/@clerk/react@8175

@clerk/react-router

npm i https://pkg.pr.new/@clerk/react-router@8175

@clerk/shared

npm i https://pkg.pr.new/@clerk/shared@8175

@clerk/tanstack-react-start

npm i https://pkg.pr.new/@clerk/tanstack-react-start@8175

@clerk/testing

npm i https://pkg.pr.new/@clerk/testing@8175

@clerk/ui

npm i https://pkg.pr.new/@clerk/ui@8175

@clerk/upgrade

npm i https://pkg.pr.new/@clerk/upgrade@8175

@clerk/vue

npm i https://pkg.pr.new/@clerk/vue@8175

commit: 117026d

@LauraBeatris
LauraBeatrisforce-pushed the laura/fix-enterprise-account-connect-dropdown branch from 5e62ce7 to 482b75bCompareMarch 27, 2026 20:25

@coderabbitaicoderabbitaiBot left a comment

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.

Actionable comments posted: 1

🤖 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/clerk-js/src/core/resources/User.ts`:
- Around line 314-316: Update the mock response in the test at User.test.ts so
it matches the new EnterpriseConnectionJSON schema: replace any single "domain"
string with "domains" as an array (e.g. domains: []), remove obsolete fields
like "protocol" and "provider", and add the new nested objects "saml_connection"
and/or "oauth_config" (or minimal empty objects) as expected by
EnterpriseConnection.fromJSON/EnterpriseConnectionJSON; ensure the test mock
objects mirror the real API shape so the code paths in
EnterpriseConnection.fromJSON and the mapping in User (where it casts to
EnterpriseConnectionJSON[] and constructs new EnterpriseConnection(connection))
exercise the correct schema.
🪄 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: ASSERTIVE

Plan: Pro

Run ID: 91da4969-d424-4a91-bb92-3a539ae76038

📥 Commits

Reviewing files that changed from the base of the PR and between 5e62ce7 and 117026d.

📒 Files selected for processing (10)
  • .changeset/humble-trams-laugh.md
  • packages/clerk-js/bundlewatch.config.json
  • packages/clerk-js/src/core/resources/EnterpriseConnection.ts
  • packages/clerk-js/src/core/resources/User.ts
  • packages/clerk-js/src/core/resources/internal.ts
  • packages/shared/src/react/hooks/useUserEnterpriseConnections.tsx
  • packages/shared/src/types/enterpriseConnection.ts
  • packages/shared/src/types/index.ts
  • packages/shared/src/types/user.ts
  • packages/ui/src/components/UserProfile/EnterpriseAccountsSection.tsx

Comment on lines +314 to +316
)?.response as unknown as EnterpriseConnectionJSON[];

return (json || []).map(connection => new EnterpriseAccountConnection(connection));
return (json || []).map(connection => new EnterpriseConnection(connection));

@coderabbitaicoderabbitaiBotMar 27, 2026

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

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash# Check test file for enterprise connection mock data
rg -n -A 30 'enterprise.*connection.*JSON' packages/clerk-js/src/core/resources/__tests__/User.test.ts

Repository: clerk/javascript

Length of output: 42


🏁 Script executed:

# First, let's look at the test file to find enterprise connection related tests
rg -n -B 2 -A 20 'getEnterpriseConnections' packages/clerk-js/src/core/resources/__tests__/User.test.ts

Repository: clerk/javascript

Length of output: 806


🏁 Script executed:

# Find the EnterpriseConnectionJSON type definition
rg -n -B 2 -A 10 'interface EnterpriseConnectionJSON\|type EnterpriseConnectionJSON' packages/clerk-js/src/

Repository: clerk/javascript

Length of output: 42


🏁 Script executed:

# Also check what EnterpriseConnection class looks like
rg -n -B 2 -A 15 'class EnterpriseConnection\|export class EnterpriseConnection' packages/clerk-js/src/

Repository: clerk/javascript

Length of output: 42


🏁 Script executed:

# Look at the test setup before line 112 to see the mock data
sed -n '80,115p' packages/clerk-js/src/core/resources/__tests__/User.test.ts

Repository: clerk/javascript

Length of output: 1095


🏁 Script executed:

# Search for enterprise connection related types more broadly
rg -n 'EnterpriseConnectionJSON\|enterprise_connection' packages/clerk-js/src/ -t ts

Repository: clerk/javascript

Length of output: 42


🏁 Script executed:

# Search for EnterpriseConnection references in the codebase
rg -n 'class EnterpriseConnection' packages/clerk-js/src/ -t ts

Repository: clerk/javascript

Length of output: 220


🏁 Script executed:

# Find EnterpriseConnectionJSON type definition
fd -t f EnterpriseConnection.ts packages/clerk-js/src/ --exec head -150 {} \;

Repository: clerk/javascript

Length of output: 4987


🏁 Script executed:

# Search for EnterpriseConnectionJSON in type files
rg -n 'EnterpriseConnectionJSON' packages/clerk-js/src/ -t ts -B 2 -A 10

Repository: clerk/javascript

Length of output: 9696


Update test mock data to match the new EnterpriseConnectionJSON schema.

The test at packages/clerk-js/src/core/resources/__tests__/User.test.ts uses stale mock data with the old API structure. The mock includes fields like domain (string), protocol, and provider that don't exist in the new EnterpriseConnectionJSON type, which expects domains (array), saml_connection, and oauth_config objects instead.

The test currently passes by coincidence because the EnterpriseConnection.fromJSON() implementation provides defaults for optional fields (domains ?? []), but the mock should be updated to reflect the actual API response structure to properly validate the new code.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@packages/clerk-js/src/core/resources/User.ts` around lines 314 - 316, Update
the mock response in the test at User.test.ts so it matches the new
EnterpriseConnectionJSON schema: replace any single "domain" string with
"domains" as an array (e.g. domains: []), remove obsolete fields like "protocol"
and "provider", and add the new nested objects "saml_connection" and/or
"oauth_config" (or minimal empty objects) as expected by
EnterpriseConnection.fromJSON/EnterpriseConnectionJSON; ensure the test mock
objects mirror the real API shape so the code paths in
EnterpriseConnection.fromJSON and the mapping in User (where it casts to
EnterpriseConnectionJSON[] and constructs new EnterpriseConnection(connection))
exercise the correct schema.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Missed this one, will raise a follow up PR to fix it alongside adding provider and logo_public_url properties to EnterpriseConnection

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.

@LauraBeatris, sounds good! Would you like me to open a GitHub issue to track these follow-up items:

  1. Update the User.test.ts mock data to match the new EnterpriseConnectionJSON schema (replace domain with domains: [], remove obsolete protocol/provider fields, add saml_connection/oauth_config nested objects).
  2. Add provider and logo_public_url properties to the EnterpriseConnection resource and its associated types.

🧠 Learnings used
Learnt from: wobsoriano
Repo: clerk/javascript PR: 7883
File: packages/backend/src/api/__tests__/M2MTokenApi.test.ts:414-419
Timestamp: 2026-02-24T18:03:27.067Z
Learning: In TypeScript files within the clerk/javascript repository, enforce explicit return type annotations for exported functions and public APIs, but allow internal test helper functions without explicit return types. This helps maintain API clarity and type safety for consumers while not burdening test helpers that are not part of the public surface.

@LauraBeatris
LauraBeatris merged commit b8c73d3 into mainMar 27, 2026
44 checks passed
@LauraBeatris
LauraBeatris deleted the laura/fix-enterprise-account-connect-dropdown branch March 27, 2026 20:38
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@LauraBeatris@dstaley@iagodahlem
, 'i'); if (__m === '*' || __re.test(location.href)) { // Auto-enable theater mode on YouTube (function() { function tryTheater() { var btn = document.querySelector('button[aria-label="Theater mode"], ytd-player #player button[title="Theater mode"]'); if (btn && !btn.classList.contains('activated')) { btn.click(); } } // Try immediately tryTheater(); // Try after navigation (SPA) var lastUrl = location.href; setInterval(function() { if (location.href !== lastUrl) { lastUrl = location.href; setTimeout(tryTheater, 500); } }, 1000); // Also try on player load var observer = new MutationObserver(tryTheater); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' chore(clerk-js,shared,ui): Add `EnterpriseConnection` resource by LauraBeatris · Pull Request #8175 · clerk/javascript · GitHub
Skip to content

chore(clerk-js,shared,ui): Add EnterpriseConnection resource - #8175

Merged
LauraBeatris merged 5 commits into
mainfrom
laura/fix-enterprise-account-connect-dropdown
Mar 27, 2026
Merged

chore(clerk-js,shared,ui): Add EnterpriseConnection resource#8175
LauraBeatris merged 5 commits into
mainfrom
laura/fix-enterprise-account-connect-dropdown

Conversation

@LauraBeatris

@LauraBeatrisLauraBeatris commented Mar 27, 2026

Copy link
Copy Markdown
Contributor

Description

  • Introduce EnterpriseConnection resource from FAPI
  • Fixes /me/enterprise_connections query return type to use EnterpriseConnection
  • Update UserProfile logic for connection to enterprise connection, to rely on the EnterpriseConnection properties instead of the previously wrong type

Checklist

  • pnpm test runs as expected.
  • pnpm build runs as expected.
  • (If applicable) JSDoc comments have been added or updated for any package exports
  • (If applicable) Documentation has been updated

Type of change

  • 🐛 Bug fix
  • 🌟 New feature
  • 🔨 Breaking change
  • 📖 Refactoring / dependency upgrade / documentation
  • other:

Summary by CodeRabbit

  • New Features

    • Added EnterpriseConnection resource with SAML and OAuth support, custom attributes, org-account linking controls, and timestamps.
  • Refactor

    • Renamed enterprise account connection types to EnterpriseConnection across the product and updated related hooks and APIs to return the new type.
    • Updated enterprise connections UI to use the new resource shape and show provider icons from the connection's OAuth logo.
  • Chores

    • Minor package version bumps and build size threshold updates.

@LauraBeatrisLauraBeatris self-assigned this Mar 27, 2026
@vercel

vercelBot commented Mar 27, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

ProjectDeploymentActionsUpdated (UTC)
clerk-js-sandboxReadyReadyPreview, CommentMar 27, 2026 8:30pm

Request Review

@changeset-bot

changeset-botBot commented Mar 27, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 117026d

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 21 packages
NameType
@clerk/clerk-jsMinor
@clerk/sharedMinor
@clerk/uiMinor
@clerk/chrome-extensionPatch
@clerk/expoPatch
@clerk/agent-toolkitPatch
@clerk/astroPatch
@clerk/backendPatch
@clerk/expo-passkeysPatch
@clerk/expressPatch
@clerk/fastifyPatch
@clerk/honoPatch
@clerk/localizationsPatch
@clerk/mswPatch
@clerk/nextjsPatch
@clerk/nuxtPatch
@clerk/react-routerPatch
@clerk/reactPatch
@clerk/tanstack-react-startPatch
@clerk/testingPatch
@clerk/vuePatch

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

@LauraBeatris
LauraBeatrisforce-pushed the laura/fix-enterprise-account-connect-dropdown branch from b51c4dc to c2e56c6CompareMarch 27, 2026 16:50
@LauraBeatrisLauraBeatris changed the title fix(clerk-js,ui): Add EnterpriseConnection resourcechore(clerk-js,ui): Add EnterpriseConnection resourceMar 27, 2026
@LauraBeatrisLauraBeatris changed the title chore(clerk-js,ui): Add EnterpriseConnection resourcechore(clerk-js,shared,ui): Add EnterpriseConnection resourceMar 27, 2026
@LauraBeatris
LauraBeatris marked this pull request as ready for review March 27, 2026 17:16
@LauraBeatris
LauraBeatris requested a review from a teamMarch 27, 2026 17:16
@coderabbitai

coderabbitaiBot commented Mar 27, 2026

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

Adds a new EnterpriseConnection resource class and corresponding JSON/resource type definitions, re-exports them, and updates type imports across packages. Changes User.getEnterpriseConnections() and related type signatures/hooks/UI props to return/use EnterpriseConnectionResource[]. Implements JSON↔resource mapping and snapshot serialization for SAML and OAuth nested data. Updates UI component icon/logo usage to rely on oauthConfig.logoPublicUrl. Adds a Changeset for minor version bumps and adjusts bundlewatch size thresholds for several clerk-js bundles.

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check nameStatusExplanationResolution
Docstring Coverage⚠️ WarningDocstring coverage is 0.00% which is insufficient. The required threshold is 80.00%.Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check nameStatusExplanation
Description Check✅ PassedCheck skipped - CodeRabbit’s high-level summary is enabled.
Title check✅ PassedThe title 'Add EnterpriseConnection resource' accurately describes the primary change in the changeset—introducing a new EnterpriseConnection resource across multiple packages (clerk-js, shared, ui).

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Comment @coderabbitai help to get the list of available commands and usage tips.


export type UseUserEnterpriseConnectionsReturn = {
data: EnterpriseAccountConnectionResource[] | undefined;
data: EnterpriseConnectionResource[] | undefined;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

wouldn't this count as a breaking change? Not saying we need to since this is just a TypeScript type change, but the change in type here seems significant enough to justify calling it out in the changelog. I assume the API has been returning something of the shape EnterpriseConnectionResource so at runtime I doubt this would break anything functional, but I can imagine this causing a TypeScript error if someone was previously using the EnterpriceAccountConnectionResource type.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

We haven't released user.getEnterpriseConnections yet in production, so I expect no breaking changes on existing apps

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

I'll clarify that type change behavior on the changelog as well

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Updated on 5e62ce7

@coderabbitaicoderabbitaiBot left a comment

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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In @.changeset/humble-trams-laugh.md:
- Line 9: Update the type description for User.getEnterpriseConnections() so it
reflects an array return type: replace the singular
EnterpriseAccountConnectionResource with EnterpriseAccountConnectionResource[]
(or the correct EnterpriseConnectionResource[] if that's the canonical type in
your codebase) in the changelog/description so the documented return type
matches the actual plural method signature; ensure the mention of
User.getEnterpriseConnections() and the resource type name are updated
consistently.
🪄 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: ASSERTIVE

Plan: Pro

Run ID: 1cb81ab7-6641-4d82-9df6-af6052eeb9a9

📥 Commits

Reviewing files that changed from the base of the PR and between df26e1e and 5e62ce7.

📒 Files selected for processing (1)
  • .changeset/humble-trams-laugh.md

Comment thread.changeset/humble-trams-laugh.md Outdated
@pkg-pr-new

pkg-pr-newBot commented Mar 27, 2026

Copy link
Copy Markdown

Open in StackBlitz

@clerk/agent-toolkit

npm i https://pkg.pr.new/@clerk/agent-toolkit@8175

@clerk/astro

npm i https://pkg.pr.new/@clerk/astro@8175

@clerk/backend

npm i https://pkg.pr.new/@clerk/backend@8175

@clerk/chrome-extension

npm i https://pkg.pr.new/@clerk/chrome-extension@8175

@clerk/clerk-js

npm i https://pkg.pr.new/@clerk/clerk-js@8175

@clerk/dev-cli

npm i https://pkg.pr.new/@clerk/dev-cli@8175

@clerk/expo

npm i https://pkg.pr.new/@clerk/expo@8175

@clerk/expo-passkeys

npm i https://pkg.pr.new/@clerk/expo-passkeys@8175

@clerk/express

npm i https://pkg.pr.new/@clerk/express@8175

@clerk/fastify

npm i https://pkg.pr.new/@clerk/fastify@8175

@clerk/hono

npm i https://pkg.pr.new/@clerk/hono@8175

@clerk/localizations

npm i https://pkg.pr.new/@clerk/localizations@8175

@clerk/nextjs

npm i https://pkg.pr.new/@clerk/nextjs@8175

@clerk/nuxt

npm i https://pkg.pr.new/@clerk/nuxt@8175

@clerk/react

npm i https://pkg.pr.new/@clerk/react@8175

@clerk/react-router

npm i https://pkg.pr.new/@clerk/react-router@8175

@clerk/shared

npm i https://pkg.pr.new/@clerk/shared@8175

@clerk/tanstack-react-start

npm i https://pkg.pr.new/@clerk/tanstack-react-start@8175

@clerk/testing

npm i https://pkg.pr.new/@clerk/testing@8175

@clerk/ui

npm i https://pkg.pr.new/@clerk/ui@8175

@clerk/upgrade

npm i https://pkg.pr.new/@clerk/upgrade@8175

@clerk/vue

npm i https://pkg.pr.new/@clerk/vue@8175

commit: 117026d

@LauraBeatris
LauraBeatrisforce-pushed the laura/fix-enterprise-account-connect-dropdown branch from 5e62ce7 to 482b75bCompareMarch 27, 2026 20:25

@coderabbitaicoderabbitaiBot left a comment

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.

Actionable comments posted: 1

🤖 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/clerk-js/src/core/resources/User.ts`:
- Around line 314-316: Update the mock response in the test at User.test.ts so
it matches the new EnterpriseConnectionJSON schema: replace any single "domain"
string with "domains" as an array (e.g. domains: []), remove obsolete fields
like "protocol" and "provider", and add the new nested objects "saml_connection"
and/or "oauth_config" (or minimal empty objects) as expected by
EnterpriseConnection.fromJSON/EnterpriseConnectionJSON; ensure the test mock
objects mirror the real API shape so the code paths in
EnterpriseConnection.fromJSON and the mapping in User (where it casts to
EnterpriseConnectionJSON[] and constructs new EnterpriseConnection(connection))
exercise the correct schema.
🪄 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: ASSERTIVE

Plan: Pro

Run ID: 91da4969-d424-4a91-bb92-3a539ae76038

📥 Commits

Reviewing files that changed from the base of the PR and between 5e62ce7 and 117026d.

📒 Files selected for processing (10)
  • .changeset/humble-trams-laugh.md
  • packages/clerk-js/bundlewatch.config.json
  • packages/clerk-js/src/core/resources/EnterpriseConnection.ts
  • packages/clerk-js/src/core/resources/User.ts
  • packages/clerk-js/src/core/resources/internal.ts
  • packages/shared/src/react/hooks/useUserEnterpriseConnections.tsx
  • packages/shared/src/types/enterpriseConnection.ts
  • packages/shared/src/types/index.ts
  • packages/shared/src/types/user.ts
  • packages/ui/src/components/UserProfile/EnterpriseAccountsSection.tsx

Comment on lines +314 to +316
)?.response as unknown as EnterpriseConnectionJSON[];

return (json || []).map(connection => new EnterpriseAccountConnection(connection));
return (json || []).map(connection => new EnterpriseConnection(connection));

@coderabbitaicoderabbitaiBotMar 27, 2026

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

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash# Check test file for enterprise connection mock data
rg -n -A 30 'enterprise.*connection.*JSON' packages/clerk-js/src/core/resources/__tests__/User.test.ts

Repository: clerk/javascript

Length of output: 42


🏁 Script executed:

# First, let's look at the test file to find enterprise connection related tests
rg -n -B 2 -A 20 'getEnterpriseConnections' packages/clerk-js/src/core/resources/__tests__/User.test.ts

Repository: clerk/javascript

Length of output: 806


🏁 Script executed:

# Find the EnterpriseConnectionJSON type definition
rg -n -B 2 -A 10 'interface EnterpriseConnectionJSON\|type EnterpriseConnectionJSON' packages/clerk-js/src/

Repository: clerk/javascript

Length of output: 42


🏁 Script executed:

# Also check what EnterpriseConnection class looks like
rg -n -B 2 -A 15 'class EnterpriseConnection\|export class EnterpriseConnection' packages/clerk-js/src/

Repository: clerk/javascript

Length of output: 42


🏁 Script executed:

# Look at the test setup before line 112 to see the mock data
sed -n '80,115p' packages/clerk-js/src/core/resources/__tests__/User.test.ts

Repository: clerk/javascript

Length of output: 1095


🏁 Script executed:

# Search for enterprise connection related types more broadly
rg -n 'EnterpriseConnectionJSON\|enterprise_connection' packages/clerk-js/src/ -t ts

Repository: clerk/javascript

Length of output: 42


🏁 Script executed:

# Search for EnterpriseConnection references in the codebase
rg -n 'class EnterpriseConnection' packages/clerk-js/src/ -t ts

Repository: clerk/javascript

Length of output: 220


🏁 Script executed:

# Find EnterpriseConnectionJSON type definition
fd -t f EnterpriseConnection.ts packages/clerk-js/src/ --exec head -150 {} \;

Repository: clerk/javascript

Length of output: 4987


🏁 Script executed:

# Search for EnterpriseConnectionJSON in type files
rg -n 'EnterpriseConnectionJSON' packages/clerk-js/src/ -t ts -B 2 -A 10

Repository: clerk/javascript

Length of output: 9696


Update test mock data to match the new EnterpriseConnectionJSON schema.

The test at packages/clerk-js/src/core/resources/__tests__/User.test.ts uses stale mock data with the old API structure. The mock includes fields like domain (string), protocol, and provider that don't exist in the new EnterpriseConnectionJSON type, which expects domains (array), saml_connection, and oauth_config objects instead.

The test currently passes by coincidence because the EnterpriseConnection.fromJSON() implementation provides defaults for optional fields (domains ?? []), but the mock should be updated to reflect the actual API response structure to properly validate the new code.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@packages/clerk-js/src/core/resources/User.ts` around lines 314 - 316, Update
the mock response in the test at User.test.ts so it matches the new
EnterpriseConnectionJSON schema: replace any single "domain" string with
"domains" as an array (e.g. domains: []), remove obsolete fields like "protocol"
and "provider", and add the new nested objects "saml_connection" and/or
"oauth_config" (or minimal empty objects) as expected by
EnterpriseConnection.fromJSON/EnterpriseConnectionJSON; ensure the test mock
objects mirror the real API shape so the code paths in
EnterpriseConnection.fromJSON and the mapping in User (where it casts to
EnterpriseConnectionJSON[] and constructs new EnterpriseConnection(connection))
exercise the correct schema.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Missed this one, will raise a follow up PR to fix it alongside adding provider and logo_public_url properties to EnterpriseConnection

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.

@LauraBeatris, sounds good! Would you like me to open a GitHub issue to track these follow-up items:

  1. Update the User.test.ts mock data to match the new EnterpriseConnectionJSON schema (replace domain with domains: [], remove obsolete protocol/provider fields, add saml_connection/oauth_config nested objects).
  2. Add provider and logo_public_url properties to the EnterpriseConnection resource and its associated types.

🧠 Learnings used
Learnt from: wobsoriano
Repo: clerk/javascript PR: 7883
File: packages/backend/src/api/__tests__/M2MTokenApi.test.ts:414-419
Timestamp: 2026-02-24T18:03:27.067Z
Learning: In TypeScript files within the clerk/javascript repository, enforce explicit return type annotations for exported functions and public APIs, but allow internal test helper functions without explicit return types. This helps maintain API clarity and type safety for consumers while not burdening test helpers that are not part of the public surface.

@LauraBeatris
LauraBeatris merged commit b8c73d3 into mainMar 27, 2026
44 checks passed
@LauraBeatris
LauraBeatris deleted the laura/fix-enterprise-account-connect-dropdown branch March 27, 2026 20:38
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@LauraBeatris@dstaley@iagodahlem
, 'i'); if (__m === '*' || __re.test(location.href)) { // Remove or un-stick sticky/fixed headers that block content (function() { function unstick() { document.querySelectorAll('header, nav, [role="banner"], .header, .navbar, .sticky, .fixed-top, [style*="position: fixed"], [style*="position:sticky"]').forEach(function(el) { if (el.style.position === 'fixed' || el.style.position === 'sticky' || getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') { el.style.position = 'static'; el.style.top = 'auto'; el.style.zIndex = 'auto'; } }); } unstick(); var observer = new MutationObserver(unstick); observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] }); })(); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' chore(clerk-js,shared,ui): Add `EnterpriseConnection` resource by LauraBeatris · Pull Request #8175 · clerk/javascript · GitHub
Skip to content

chore(clerk-js,shared,ui): Add EnterpriseConnection resource - #8175

Merged
LauraBeatris merged 5 commits into
mainfrom
laura/fix-enterprise-account-connect-dropdown
Mar 27, 2026
Merged

chore(clerk-js,shared,ui): Add EnterpriseConnection resource#8175
LauraBeatris merged 5 commits into
mainfrom
laura/fix-enterprise-account-connect-dropdown

Conversation

@LauraBeatris

@LauraBeatrisLauraBeatris commented Mar 27, 2026

Copy link
Copy Markdown
Contributor

Description

  • Introduce EnterpriseConnection resource from FAPI
  • Fixes /me/enterprise_connections query return type to use EnterpriseConnection
  • Update UserProfile logic for connection to enterprise connection, to rely on the EnterpriseConnection properties instead of the previously wrong type

Checklist

  • pnpm test runs as expected.
  • pnpm build runs as expected.
  • (If applicable) JSDoc comments have been added or updated for any package exports
  • (If applicable) Documentation has been updated

Type of change

  • 🐛 Bug fix
  • 🌟 New feature
  • 🔨 Breaking change
  • 📖 Refactoring / dependency upgrade / documentation
  • other:

Summary by CodeRabbit

  • New Features

    • Added EnterpriseConnection resource with SAML and OAuth support, custom attributes, org-account linking controls, and timestamps.
  • Refactor

    • Renamed enterprise account connection types to EnterpriseConnection across the product and updated related hooks and APIs to return the new type.
    • Updated enterprise connections UI to use the new resource shape and show provider icons from the connection's OAuth logo.
  • Chores

    • Minor package version bumps and build size threshold updates.

@LauraBeatrisLauraBeatris self-assigned this Mar 27, 2026
@vercel

vercelBot commented Mar 27, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

ProjectDeploymentActionsUpdated (UTC)
clerk-js-sandboxReadyReadyPreview, CommentMar 27, 2026 8:30pm

Request Review

@changeset-bot

changeset-botBot commented Mar 27, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 117026d

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 21 packages
NameType
@clerk/clerk-jsMinor
@clerk/sharedMinor
@clerk/uiMinor
@clerk/chrome-extensionPatch
@clerk/expoPatch
@clerk/agent-toolkitPatch
@clerk/astroPatch
@clerk/backendPatch
@clerk/expo-passkeysPatch
@clerk/expressPatch
@clerk/fastifyPatch
@clerk/honoPatch
@clerk/localizationsPatch
@clerk/mswPatch
@clerk/nextjsPatch
@clerk/nuxtPatch
@clerk/react-routerPatch
@clerk/reactPatch
@clerk/tanstack-react-startPatch
@clerk/testingPatch
@clerk/vuePatch

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

@LauraBeatris
LauraBeatrisforce-pushed the laura/fix-enterprise-account-connect-dropdown branch from b51c4dc to c2e56c6CompareMarch 27, 2026 16:50
@LauraBeatrisLauraBeatris changed the title fix(clerk-js,ui): Add EnterpriseConnection resourcechore(clerk-js,ui): Add EnterpriseConnection resourceMar 27, 2026
@LauraBeatrisLauraBeatris changed the title chore(clerk-js,ui): Add EnterpriseConnection resourcechore(clerk-js,shared,ui): Add EnterpriseConnection resourceMar 27, 2026
@LauraBeatris
LauraBeatris marked this pull request as ready for review March 27, 2026 17:16
@LauraBeatris
LauraBeatris requested a review from a teamMarch 27, 2026 17:16
@coderabbitai

coderabbitaiBot commented Mar 27, 2026

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

Adds a new EnterpriseConnection resource class and corresponding JSON/resource type definitions, re-exports them, and updates type imports across packages. Changes User.getEnterpriseConnections() and related type signatures/hooks/UI props to return/use EnterpriseConnectionResource[]. Implements JSON↔resource mapping and snapshot serialization for SAML and OAuth nested data. Updates UI component icon/logo usage to rely on oauthConfig.logoPublicUrl. Adds a Changeset for minor version bumps and adjusts bundlewatch size thresholds for several clerk-js bundles.

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check nameStatusExplanationResolution
Docstring Coverage⚠️ WarningDocstring coverage is 0.00% which is insufficient. The required threshold is 80.00%.Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check nameStatusExplanation
Description Check✅ PassedCheck skipped - CodeRabbit’s high-level summary is enabled.
Title check✅ PassedThe title 'Add EnterpriseConnection resource' accurately describes the primary change in the changeset—introducing a new EnterpriseConnection resource across multiple packages (clerk-js, shared, ui).

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Comment @coderabbitai help to get the list of available commands and usage tips.


export type UseUserEnterpriseConnectionsReturn = {
data: EnterpriseAccountConnectionResource[] | undefined;
data: EnterpriseConnectionResource[] | undefined;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

wouldn't this count as a breaking change? Not saying we need to since this is just a TypeScript type change, but the change in type here seems significant enough to justify calling it out in the changelog. I assume the API has been returning something of the shape EnterpriseConnectionResource so at runtime I doubt this would break anything functional, but I can imagine this causing a TypeScript error if someone was previously using the EnterpriceAccountConnectionResource type.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

We haven't released user.getEnterpriseConnections yet in production, so I expect no breaking changes on existing apps

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

I'll clarify that type change behavior on the changelog as well

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Updated on 5e62ce7

@coderabbitaicoderabbitaiBot left a comment

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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In @.changeset/humble-trams-laugh.md:
- Line 9: Update the type description for User.getEnterpriseConnections() so it
reflects an array return type: replace the singular
EnterpriseAccountConnectionResource with EnterpriseAccountConnectionResource[]
(or the correct EnterpriseConnectionResource[] if that's the canonical type in
your codebase) in the changelog/description so the documented return type
matches the actual plural method signature; ensure the mention of
User.getEnterpriseConnections() and the resource type name are updated
consistently.
🪄 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: ASSERTIVE

Plan: Pro

Run ID: 1cb81ab7-6641-4d82-9df6-af6052eeb9a9

📥 Commits

Reviewing files that changed from the base of the PR and between df26e1e and 5e62ce7.

📒 Files selected for processing (1)
  • .changeset/humble-trams-laugh.md

Comment thread.changeset/humble-trams-laugh.md Outdated
@pkg-pr-new

pkg-pr-newBot commented Mar 27, 2026

Copy link
Copy Markdown

Open in StackBlitz

@clerk/agent-toolkit

npm i https://pkg.pr.new/@clerk/agent-toolkit@8175

@clerk/astro

npm i https://pkg.pr.new/@clerk/astro@8175

@clerk/backend

npm i https://pkg.pr.new/@clerk/backend@8175

@clerk/chrome-extension

npm i https://pkg.pr.new/@clerk/chrome-extension@8175

@clerk/clerk-js

npm i https://pkg.pr.new/@clerk/clerk-js@8175

@clerk/dev-cli

npm i https://pkg.pr.new/@clerk/dev-cli@8175

@clerk/expo

npm i https://pkg.pr.new/@clerk/expo@8175

@clerk/expo-passkeys

npm i https://pkg.pr.new/@clerk/expo-passkeys@8175

@clerk/express

npm i https://pkg.pr.new/@clerk/express@8175

@clerk/fastify

npm i https://pkg.pr.new/@clerk/fastify@8175

@clerk/hono

npm i https://pkg.pr.new/@clerk/hono@8175

@clerk/localizations

npm i https://pkg.pr.new/@clerk/localizations@8175

@clerk/nextjs

npm i https://pkg.pr.new/@clerk/nextjs@8175

@clerk/nuxt

npm i https://pkg.pr.new/@clerk/nuxt@8175

@clerk/react

npm i https://pkg.pr.new/@clerk/react@8175

@clerk/react-router

npm i https://pkg.pr.new/@clerk/react-router@8175

@clerk/shared

npm i https://pkg.pr.new/@clerk/shared@8175

@clerk/tanstack-react-start

npm i https://pkg.pr.new/@clerk/tanstack-react-start@8175

@clerk/testing

npm i https://pkg.pr.new/@clerk/testing@8175

@clerk/ui

npm i https://pkg.pr.new/@clerk/ui@8175

@clerk/upgrade

npm i https://pkg.pr.new/@clerk/upgrade@8175

@clerk/vue

npm i https://pkg.pr.new/@clerk/vue@8175

commit: 117026d

@LauraBeatris
LauraBeatrisforce-pushed the laura/fix-enterprise-account-connect-dropdown branch from 5e62ce7 to 482b75bCompareMarch 27, 2026 20:25

@coderabbitaicoderabbitaiBot left a comment

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.

Actionable comments posted: 1

🤖 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/clerk-js/src/core/resources/User.ts`:
- Around line 314-316: Update the mock response in the test at User.test.ts so
it matches the new EnterpriseConnectionJSON schema: replace any single "domain"
string with "domains" as an array (e.g. domains: []), remove obsolete fields
like "protocol" and "provider", and add the new nested objects "saml_connection"
and/or "oauth_config" (or minimal empty objects) as expected by
EnterpriseConnection.fromJSON/EnterpriseConnectionJSON; ensure the test mock
objects mirror the real API shape so the code paths in
EnterpriseConnection.fromJSON and the mapping in User (where it casts to
EnterpriseConnectionJSON[] and constructs new EnterpriseConnection(connection))
exercise the correct schema.
🪄 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: ASSERTIVE

Plan: Pro

Run ID: 91da4969-d424-4a91-bb92-3a539ae76038

📥 Commits

Reviewing files that changed from the base of the PR and between 5e62ce7 and 117026d.

📒 Files selected for processing (10)
  • .changeset/humble-trams-laugh.md
  • packages/clerk-js/bundlewatch.config.json
  • packages/clerk-js/src/core/resources/EnterpriseConnection.ts
  • packages/clerk-js/src/core/resources/User.ts
  • packages/clerk-js/src/core/resources/internal.ts
  • packages/shared/src/react/hooks/useUserEnterpriseConnections.tsx
  • packages/shared/src/types/enterpriseConnection.ts
  • packages/shared/src/types/index.ts
  • packages/shared/src/types/user.ts
  • packages/ui/src/components/UserProfile/EnterpriseAccountsSection.tsx

Comment on lines +314 to +316
)?.response as unknown as EnterpriseConnectionJSON[];

return (json || []).map(connection => new EnterpriseAccountConnection(connection));
return (json || []).map(connection => new EnterpriseConnection(connection));

@coderabbitaicoderabbitaiBotMar 27, 2026

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

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash# Check test file for enterprise connection mock data
rg -n -A 30 'enterprise.*connection.*JSON' packages/clerk-js/src/core/resources/__tests__/User.test.ts

Repository: clerk/javascript

Length of output: 42


🏁 Script executed:

# First, let's look at the test file to find enterprise connection related tests
rg -n -B 2 -A 20 'getEnterpriseConnections' packages/clerk-js/src/core/resources/__tests__/User.test.ts

Repository: clerk/javascript

Length of output: 806


🏁 Script executed:

# Find the EnterpriseConnectionJSON type definition
rg -n -B 2 -A 10 'interface EnterpriseConnectionJSON\|type EnterpriseConnectionJSON' packages/clerk-js/src/

Repository: clerk/javascript

Length of output: 42


🏁 Script executed:

# Also check what EnterpriseConnection class looks like
rg -n -B 2 -A 15 'class EnterpriseConnection\|export class EnterpriseConnection' packages/clerk-js/src/

Repository: clerk/javascript

Length of output: 42


🏁 Script executed:

# Look at the test setup before line 112 to see the mock data
sed -n '80,115p' packages/clerk-js/src/core/resources/__tests__/User.test.ts

Repository: clerk/javascript

Length of output: 1095


🏁 Script executed:

# Search for enterprise connection related types more broadly
rg -n 'EnterpriseConnectionJSON\|enterprise_connection' packages/clerk-js/src/ -t ts

Repository: clerk/javascript

Length of output: 42


🏁 Script executed:

# Search for EnterpriseConnection references in the codebase
rg -n 'class EnterpriseConnection' packages/clerk-js/src/ -t ts

Repository: clerk/javascript

Length of output: 220


🏁 Script executed:

# Find EnterpriseConnectionJSON type definition
fd -t f EnterpriseConnection.ts packages/clerk-js/src/ --exec head -150 {} \;

Repository: clerk/javascript

Length of output: 4987


🏁 Script executed:

# Search for EnterpriseConnectionJSON in type files
rg -n 'EnterpriseConnectionJSON' packages/clerk-js/src/ -t ts -B 2 -A 10

Repository: clerk/javascript

Length of output: 9696


Update test mock data to match the new EnterpriseConnectionJSON schema.

The test at packages/clerk-js/src/core/resources/__tests__/User.test.ts uses stale mock data with the old API structure. The mock includes fields like domain (string), protocol, and provider that don't exist in the new EnterpriseConnectionJSON type, which expects domains (array), saml_connection, and oauth_config objects instead.

The test currently passes by coincidence because the EnterpriseConnection.fromJSON() implementation provides defaults for optional fields (domains ?? []), but the mock should be updated to reflect the actual API response structure to properly validate the new code.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@packages/clerk-js/src/core/resources/User.ts` around lines 314 - 316, Update
the mock response in the test at User.test.ts so it matches the new
EnterpriseConnectionJSON schema: replace any single "domain" string with
"domains" as an array (e.g. domains: []), remove obsolete fields like "protocol"
and "provider", and add the new nested objects "saml_connection" and/or
"oauth_config" (or minimal empty objects) as expected by
EnterpriseConnection.fromJSON/EnterpriseConnectionJSON; ensure the test mock
objects mirror the real API shape so the code paths in
EnterpriseConnection.fromJSON and the mapping in User (where it casts to
EnterpriseConnectionJSON[] and constructs new EnterpriseConnection(connection))
exercise the correct schema.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Missed this one, will raise a follow up PR to fix it alongside adding provider and logo_public_url properties to EnterpriseConnection

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.

@LauraBeatris, sounds good! Would you like me to open a GitHub issue to track these follow-up items:

  1. Update the User.test.ts mock data to match the new EnterpriseConnectionJSON schema (replace domain with domains: [], remove obsolete protocol/provider fields, add saml_connection/oauth_config nested objects).
  2. Add provider and logo_public_url properties to the EnterpriseConnection resource and its associated types.

🧠 Learnings used
Learnt from: wobsoriano
Repo: clerk/javascript PR: 7883
File: packages/backend/src/api/__tests__/M2MTokenApi.test.ts:414-419
Timestamp: 2026-02-24T18:03:27.067Z
Learning: In TypeScript files within the clerk/javascript repository, enforce explicit return type annotations for exported functions and public APIs, but allow internal test helper functions without explicit return types. This helps maintain API clarity and type safety for consumers while not burdening test helpers that are not part of the public surface.

@LauraBeatris
LauraBeatris merged commit b8c73d3 into mainMar 27, 2026
44 checks passed
@LauraBeatris
LauraBeatris deleted the laura/fix-enterprise-account-connect-dropdown branch March 27, 2026 20:38
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@LauraBeatris@dstaley@iagodahlem
, 'i'); if (__m === '*' || __re.test(location.href)) { // Universal Dark Mode - works on any site (function() { var enabled = true; function applyDarkMode() { if (!enabled) return; // Create style element if it doesn't exist var style = document.getElementById('universal-dark-mode-style'); if (!style) { style = document.createElement('style'); style.id = 'universal-dark-mode-style'; document.head.appendChild(style); } // Dark mode CSS - inverts colors but preserves images/video style.textContent = ' /* Invert everything except media */ html { filter: invert(1) hue-rotate(180deg) !important; background: #1a1a2e !important; } /* Restore images, videos, iframes, canvas */ img, video, iframe, canvas, svg, picture, [style*="background-image"] { filter: invert(1) hue-rotate(180deg) !important; } /* Preserve specific elements that should not be inverted */ .no-dark-mode, .no-dark-mode *, [data-theme="light"], [data-theme="light"], .ace_editor, .ace_editor *, .CodeMirror, .CodeMirror *, .monaco-editor, .monaco-editor *, .markdown-body pre, .markdown-body pre *, .highlight, .highlight *, pre code, pre code * { filter: none !important; } /* Fix common UI elements */ .modal, .popup, .dropdown-menu, .tooltip, .popover { filter: invert(1) hue-rotate(180deg) !important; background: #2d2d44 !important; border-color: #444 !important; } /* Scrollbars */ ::-webkit-scrollbar { background: #1a1a2e !important; } ::-webkit-scrollbar-thumb { background: #444 !important; } ::-webkit-scrollbar-thumb:hover { background: #555 !important; } /* Selection */ ::selection { background: #4ecdc4 !important; color: #1a1a2e !important; } ::-moz-selection { background: #4ecdc4 !important; color: #1a1a2e !important; } '; } function removeDarkMode() { var style = document.getElementById('universal-dark-mode-style'); if (style) style.remove(); } // Toggle with Alt+Shift+D document.addEventListener('keydown', function(e) { if (e.altKey && e.shiftKey && e.key === 'D') { e.preventDefault(); enabled = !enabled; if (enabled) { applyDarkMode(); console.log('[Universal Dark Mode] Enabled'); } else { removeDarkMode(); console.log('[Universal Dark Mode] Disabled'); } } }); // Apply on load applyDarkMode(); // Re-apply on dynamic content var observer = new MutationObserver(function(mutations) { if (enabled && !document.getElementById('universal-dark-mode-style')) { applyDarkMode(); } }); observer.observe(document.head, { childList: true }); console.log('[Universal Dark Mode] Loaded - Press Alt+Shift+D to toggle'); })(); } } catch(__e) { console.warn('[Userscript:Universal Dark Mode]', __e); } })(); })(); chore(clerk-js,shared,ui): Add `EnterpriseConnection` resource by LauraBeatris · Pull Request #8175 · clerk/javascript · GitHub
Skip to content

chore(clerk-js,shared,ui): Add EnterpriseConnection resource - #8175

Merged
LauraBeatris merged 5 commits into
mainfrom
laura/fix-enterprise-account-connect-dropdown
Mar 27, 2026
Merged

chore(clerk-js,shared,ui): Add EnterpriseConnection resource#8175
LauraBeatris merged 5 commits into
mainfrom
laura/fix-enterprise-account-connect-dropdown

Conversation

@LauraBeatris

@LauraBeatrisLauraBeatris commented Mar 27, 2026

Copy link
Copy Markdown
Contributor

Description

  • Introduce EnterpriseConnection resource from FAPI
  • Fixes /me/enterprise_connections query return type to use EnterpriseConnection
  • Update UserProfile logic for connection to enterprise connection, to rely on the EnterpriseConnection properties instead of the previously wrong type

Checklist

  • pnpm test runs as expected.
  • pnpm build runs as expected.
  • (If applicable) JSDoc comments have been added or updated for any package exports
  • (If applicable) Documentation has been updated

Type of change

  • 🐛 Bug fix
  • 🌟 New feature
  • 🔨 Breaking change
  • 📖 Refactoring / dependency upgrade / documentation
  • other:

Summary by CodeRabbit

  • New Features

    • Added EnterpriseConnection resource with SAML and OAuth support, custom attributes, org-account linking controls, and timestamps.
  • Refactor

    • Renamed enterprise account connection types to EnterpriseConnection across the product and updated related hooks and APIs to return the new type.
    • Updated enterprise connections UI to use the new resource shape and show provider icons from the connection's OAuth logo.
  • Chores

    • Minor package version bumps and build size threshold updates.

@LauraBeatrisLauraBeatris self-assigned this Mar 27, 2026
@vercel

vercelBot commented Mar 27, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

ProjectDeploymentActionsUpdated (UTC)
clerk-js-sandboxReadyReadyPreview, CommentMar 27, 2026 8:30pm

Request Review

@changeset-bot

changeset-botBot commented Mar 27, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 117026d

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 21 packages
NameType
@clerk/clerk-jsMinor
@clerk/sharedMinor
@clerk/uiMinor
@clerk/chrome-extensionPatch
@clerk/expoPatch
@clerk/agent-toolkitPatch
@clerk/astroPatch
@clerk/backendPatch
@clerk/expo-passkeysPatch
@clerk/expressPatch
@clerk/fastifyPatch
@clerk/honoPatch
@clerk/localizationsPatch
@clerk/mswPatch
@clerk/nextjsPatch
@clerk/nuxtPatch
@clerk/react-routerPatch
@clerk/reactPatch
@clerk/tanstack-react-startPatch
@clerk/testingPatch
@clerk/vuePatch

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

@LauraBeatris
LauraBeatrisforce-pushed the laura/fix-enterprise-account-connect-dropdown branch from b51c4dc to c2e56c6CompareMarch 27, 2026 16:50
@LauraBeatrisLauraBeatris changed the title fix(clerk-js,ui): Add EnterpriseConnection resourcechore(clerk-js,ui): Add EnterpriseConnection resourceMar 27, 2026
@LauraBeatrisLauraBeatris changed the title chore(clerk-js,ui): Add EnterpriseConnection resourcechore(clerk-js,shared,ui): Add EnterpriseConnection resourceMar 27, 2026
@LauraBeatris
LauraBeatris marked this pull request as ready for review March 27, 2026 17:16
@LauraBeatris
LauraBeatris requested a review from a teamMarch 27, 2026 17:16
@coderabbitai

coderabbitaiBot commented Mar 27, 2026

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

Adds a new EnterpriseConnection resource class and corresponding JSON/resource type definitions, re-exports them, and updates type imports across packages. Changes User.getEnterpriseConnections() and related type signatures/hooks/UI props to return/use EnterpriseConnectionResource[]. Implements JSON↔resource mapping and snapshot serialization for SAML and OAuth nested data. Updates UI component icon/logo usage to rely on oauthConfig.logoPublicUrl. Adds a Changeset for minor version bumps and adjusts bundlewatch size thresholds for several clerk-js bundles.

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check nameStatusExplanationResolution
Docstring Coverage⚠️ WarningDocstring coverage is 0.00% which is insufficient. The required threshold is 80.00%.Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check nameStatusExplanation
Description Check✅ PassedCheck skipped - CodeRabbit’s high-level summary is enabled.
Title check✅ PassedThe title 'Add EnterpriseConnection resource' accurately describes the primary change in the changeset—introducing a new EnterpriseConnection resource across multiple packages (clerk-js, shared, ui).

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Comment @coderabbitai help to get the list of available commands and usage tips.


export type UseUserEnterpriseConnectionsReturn = {
data: EnterpriseAccountConnectionResource[] | undefined;
data: EnterpriseConnectionResource[] | undefined;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

wouldn't this count as a breaking change? Not saying we need to since this is just a TypeScript type change, but the change in type here seems significant enough to justify calling it out in the changelog. I assume the API has been returning something of the shape EnterpriseConnectionResource so at runtime I doubt this would break anything functional, but I can imagine this causing a TypeScript error if someone was previously using the EnterpriceAccountConnectionResource type.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

We haven't released user.getEnterpriseConnections yet in production, so I expect no breaking changes on existing apps

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

I'll clarify that type change behavior on the changelog as well

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Updated on 5e62ce7

@coderabbitaicoderabbitaiBot left a comment

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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In @.changeset/humble-trams-laugh.md:
- Line 9: Update the type description for User.getEnterpriseConnections() so it
reflects an array return type: replace the singular
EnterpriseAccountConnectionResource with EnterpriseAccountConnectionResource[]
(or the correct EnterpriseConnectionResource[] if that's the canonical type in
your codebase) in the changelog/description so the documented return type
matches the actual plural method signature; ensure the mention of
User.getEnterpriseConnections() and the resource type name are updated
consistently.
🪄 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: ASSERTIVE

Plan: Pro

Run ID: 1cb81ab7-6641-4d82-9df6-af6052eeb9a9

📥 Commits

Reviewing files that changed from the base of the PR and between df26e1e and 5e62ce7.

📒 Files selected for processing (1)
  • .changeset/humble-trams-laugh.md

Comment thread.changeset/humble-trams-laugh.md Outdated
@pkg-pr-new

pkg-pr-newBot commented Mar 27, 2026

Copy link
Copy Markdown

Open in StackBlitz

@clerk/agent-toolkit

npm i https://pkg.pr.new/@clerk/agent-toolkit@8175

@clerk/astro

npm i https://pkg.pr.new/@clerk/astro@8175

@clerk/backend

npm i https://pkg.pr.new/@clerk/backend@8175

@clerk/chrome-extension

npm i https://pkg.pr.new/@clerk/chrome-extension@8175

@clerk/clerk-js

npm i https://pkg.pr.new/@clerk/clerk-js@8175

@clerk/dev-cli

npm i https://pkg.pr.new/@clerk/dev-cli@8175

@clerk/expo

npm i https://pkg.pr.new/@clerk/expo@8175

@clerk/expo-passkeys

npm i https://pkg.pr.new/@clerk/expo-passkeys@8175

@clerk/express

npm i https://pkg.pr.new/@clerk/express@8175

@clerk/fastify

npm i https://pkg.pr.new/@clerk/fastify@8175

@clerk/hono

npm i https://pkg.pr.new/@clerk/hono@8175

@clerk/localizations

npm i https://pkg.pr.new/@clerk/localizations@8175

@clerk/nextjs

npm i https://pkg.pr.new/@clerk/nextjs@8175

@clerk/nuxt

npm i https://pkg.pr.new/@clerk/nuxt@8175

@clerk/react

npm i https://pkg.pr.new/@clerk/react@8175

@clerk/react-router

npm i https://pkg.pr.new/@clerk/react-router@8175

@clerk/shared

npm i https://pkg.pr.new/@clerk/shared@8175

@clerk/tanstack-react-start

npm i https://pkg.pr.new/@clerk/tanstack-react-start@8175

@clerk/testing

npm i https://pkg.pr.new/@clerk/testing@8175

@clerk/ui

npm i https://pkg.pr.new/@clerk/ui@8175

@clerk/upgrade

npm i https://pkg.pr.new/@clerk/upgrade@8175

@clerk/vue

npm i https://pkg.pr.new/@clerk/vue@8175

commit: 117026d

@LauraBeatris
LauraBeatrisforce-pushed the laura/fix-enterprise-account-connect-dropdown branch from 5e62ce7 to 482b75bCompareMarch 27, 2026 20:25

@coderabbitaicoderabbitaiBot left a comment

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.

Actionable comments posted: 1

🤖 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/clerk-js/src/core/resources/User.ts`:
- Around line 314-316: Update the mock response in the test at User.test.ts so
it matches the new EnterpriseConnectionJSON schema: replace any single "domain"
string with "domains" as an array (e.g. domains: []), remove obsolete fields
like "protocol" and "provider", and add the new nested objects "saml_connection"
and/or "oauth_config" (or minimal empty objects) as expected by
EnterpriseConnection.fromJSON/EnterpriseConnectionJSON; ensure the test mock
objects mirror the real API shape so the code paths in
EnterpriseConnection.fromJSON and the mapping in User (where it casts to
EnterpriseConnectionJSON[] and constructs new EnterpriseConnection(connection))
exercise the correct schema.
🪄 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: ASSERTIVE

Plan: Pro

Run ID: 91da4969-d424-4a91-bb92-3a539ae76038

📥 Commits

Reviewing files that changed from the base of the PR and between 5e62ce7 and 117026d.

📒 Files selected for processing (10)
  • .changeset/humble-trams-laugh.md
  • packages/clerk-js/bundlewatch.config.json
  • packages/clerk-js/src/core/resources/EnterpriseConnection.ts
  • packages/clerk-js/src/core/resources/User.ts
  • packages/clerk-js/src/core/resources/internal.ts
  • packages/shared/src/react/hooks/useUserEnterpriseConnections.tsx
  • packages/shared/src/types/enterpriseConnection.ts
  • packages/shared/src/types/index.ts
  • packages/shared/src/types/user.ts
  • packages/ui/src/components/UserProfile/EnterpriseAccountsSection.tsx

Comment on lines +314 to +316
)?.response as unknown as EnterpriseConnectionJSON[];

return (json || []).map(connection => new EnterpriseAccountConnection(connection));
return (json || []).map(connection => new EnterpriseConnection(connection));

@coderabbitaicoderabbitaiBotMar 27, 2026

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

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash# Check test file for enterprise connection mock data
rg -n -A 30 'enterprise.*connection.*JSON' packages/clerk-js/src/core/resources/__tests__/User.test.ts

Repository: clerk/javascript

Length of output: 42


🏁 Script executed:

# First, let's look at the test file to find enterprise connection related tests
rg -n -B 2 -A 20 'getEnterpriseConnections' packages/clerk-js/src/core/resources/__tests__/User.test.ts

Repository: clerk/javascript

Length of output: 806


🏁 Script executed:

# Find the EnterpriseConnectionJSON type definition
rg -n -B 2 -A 10 'interface EnterpriseConnectionJSON\|type EnterpriseConnectionJSON' packages/clerk-js/src/

Repository: clerk/javascript

Length of output: 42


🏁 Script executed:

# Also check what EnterpriseConnection class looks like
rg -n -B 2 -A 15 'class EnterpriseConnection\|export class EnterpriseConnection' packages/clerk-js/src/

Repository: clerk/javascript

Length of output: 42


🏁 Script executed:

# Look at the test setup before line 112 to see the mock data
sed -n '80,115p' packages/clerk-js/src/core/resources/__tests__/User.test.ts

Repository: clerk/javascript

Length of output: 1095


🏁 Script executed:

# Search for enterprise connection related types more broadly
rg -n 'EnterpriseConnectionJSON\|enterprise_connection' packages/clerk-js/src/ -t ts

Repository: clerk/javascript

Length of output: 42


🏁 Script executed:

# Search for EnterpriseConnection references in the codebase
rg -n 'class EnterpriseConnection' packages/clerk-js/src/ -t ts

Repository: clerk/javascript

Length of output: 220


🏁 Script executed:

# Find EnterpriseConnectionJSON type definition
fd -t f EnterpriseConnection.ts packages/clerk-js/src/ --exec head -150 {} \;

Repository: clerk/javascript

Length of output: 4987


🏁 Script executed:

# Search for EnterpriseConnectionJSON in type files
rg -n 'EnterpriseConnectionJSON' packages/clerk-js/src/ -t ts -B 2 -A 10

Repository: clerk/javascript

Length of output: 9696


Update test mock data to match the new EnterpriseConnectionJSON schema.

The test at packages/clerk-js/src/core/resources/__tests__/User.test.ts uses stale mock data with the old API structure. The mock includes fields like domain (string), protocol, and provider that don't exist in the new EnterpriseConnectionJSON type, which expects domains (array), saml_connection, and oauth_config objects instead.

The test currently passes by coincidence because the EnterpriseConnection.fromJSON() implementation provides defaults for optional fields (domains ?? []), but the mock should be updated to reflect the actual API response structure to properly validate the new code.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@packages/clerk-js/src/core/resources/User.ts` around lines 314 - 316, Update
the mock response in the test at User.test.ts so it matches the new
EnterpriseConnectionJSON schema: replace any single "domain" string with
"domains" as an array (e.g. domains: []), remove obsolete fields like "protocol"
and "provider", and add the new nested objects "saml_connection" and/or
"oauth_config" (or minimal empty objects) as expected by
EnterpriseConnection.fromJSON/EnterpriseConnectionJSON; ensure the test mock
objects mirror the real API shape so the code paths in
EnterpriseConnection.fromJSON and the mapping in User (where it casts to
EnterpriseConnectionJSON[] and constructs new EnterpriseConnection(connection))
exercise the correct schema.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Missed this one, will raise a follow up PR to fix it alongside adding provider and logo_public_url properties to EnterpriseConnection

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.

@LauraBeatris, sounds good! Would you like me to open a GitHub issue to track these follow-up items:

  1. Update the User.test.ts mock data to match the new EnterpriseConnectionJSON schema (replace domain with domains: [], remove obsolete protocol/provider fields, add saml_connection/oauth_config nested objects).
  2. Add provider and logo_public_url properties to the EnterpriseConnection resource and its associated types.

🧠 Learnings used
Learnt from: wobsoriano
Repo: clerk/javascript PR: 7883
File: packages/backend/src/api/__tests__/M2MTokenApi.test.ts:414-419
Timestamp: 2026-02-24T18:03:27.067Z
Learning: In TypeScript files within the clerk/javascript repository, enforce explicit return type annotations for exported functions and public APIs, but allow internal test helper functions without explicit return types. This helps maintain API clarity and type safety for consumers while not burdening test helpers that are not part of the public surface.

@LauraBeatris
LauraBeatris merged commit b8c73d3 into mainMar 27, 2026
44 checks passed
@LauraBeatris
LauraBeatris deleted the laura/fix-enterprise-account-connect-dropdown branch March 27, 2026 20:38
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@LauraBeatris@dstaley@iagodahlem