Skip to content

Conversation

LauraBeatris
Copy link
Member

@LauraBeatris LauraBeatris commented Oct 10, 2025

Description

This PR introduces a enterprise_connection_id property to the SamlAccount and EnterpriseAccount resources

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

    • SAML and Enterprise account objects now include an enterprise_connection_id field.
    • Enterprise account objects also expose a lastAuthenticatedAt field.
    • New fields are available in client and backend APIs and included in serialized JSON responses.
  • Chores

    • Added a changeset to prepare patch releases for related packages.

Copy link

changeset-bot bot commented Oct 10, 2025

🦋 Changeset detected

Latest commit: bed5e7f

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

This PR includes changesets to release 22 packages
Name Type
@clerk/clerk-js Patch
@clerk/backend Patch
@clerk/types Patch
@clerk/chrome-extension Patch
@clerk/clerk-expo Patch
@clerk/agent-toolkit Patch
@clerk/astro Patch
@clerk/express Patch
@clerk/fastify Patch
@clerk/nextjs Patch
@clerk/nuxt Patch
@clerk/react-router Patch
@clerk/remix Patch
@clerk/tanstack-react-start Patch
@clerk/testing Patch
@clerk/elements Patch
@clerk/expo-passkeys Patch
@clerk/localizations Patch
@clerk/clerk-react Patch
@clerk/shared Patch
@clerk/themes Patch
@clerk/vue Patch

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 LauraBeatris self-assigned this Oct 10, 2025
Copy link

vercel bot commented Oct 10, 2025

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

Project Deployment Preview Comments Updated (UTC)
clerk-js-sandbox Ready Ready Preview Comment Oct 10, 2025 9:37pm

Copy link
Contributor

coderabbitai bot commented Oct 10, 2025

Walkthrough

Adds an optional field enterprise_connection_id (string | null) to public JSON/types for SamlAccount and EnterpriseAccount, maps it through backend JSON and SamlAccount class, surfaces it on clerk-js resource classes (EnterpriseAccount, EnterpriseAccountConnection, SamlAccount) and includes it in snapshot serialization; adds a changeset for patch bumps.

Changes

Cohort / File(s) Summary
Changeset
.changeset/flat-teams-trade.md
New changeset entry declaring patch bumps for @clerk/clerk-js, @clerk/backend, and @clerk/types; notes addition of enterprise_connection_id.
Types: public JSON & resources
packages/types/src/json.ts, packages/types/src/enterpriseAccount.ts
Added `enterprise_connection_id: string
Backend: JSON shape & SamlAccount class
packages/backend/src/api/resources/JSON.ts, packages/backend/src/api/resources/SamlAccount.ts
Extended SamlAccountJSON with `enterprise_connection_id: string
clerk-js: resource classes & snapshots
packages/clerk-js/src/core/resources/EnterpriseAccount.ts, packages/clerk-js/src/core/resources/SamlAccount.ts
Added `enterpriseConnectionId: string

Sequence Diagram(s)

sequenceDiagram
  participant API as Upstream API JSON
  participant BackendJSON as Backend SamlAccountJSON
  participant BackendRes as Backend SamlAccount
  participant ClerkJS as clerk-js Resource
  rect rgb(230, 255, 230)
    note left of API: New field\n`enterprise_connection_id`
  end
  API->>BackendJSON: receive JSON including enterprise_connection_id
  BackendJSON->>BackendRes: SamlAccount.fromJSON(data)\nmap enterprise_connection_id → enterpriseConnectionId
  BackendRes->>ClerkJS: expose serialized snapshot\n(include enterprise_connection_id)
  ClerkJS->>ClerkJS: fromJSON maps enterprise_connection_id → enterpriseConnectionId
  note right of ClerkJS: Snapshots now contain\n`enterprise_connection_id` for clients
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

I’m a rabbit who hops through code and logs,
Nudging IDs into JSON like tiny cogs. 🐇
From backend fields to snapshots so neat,
Enterprise links now take a small seat.
Patch bumps hop onward—soft, swift, and fleet.

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title accurately summarizes the main change by stating that the enterprise_connection_id field was added to SamlAccount and EnterpriseAccount across the specified packages, and it follows the conventional commit style with clear scopes and concise wording.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch laura/add-enterprise-connection-id

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

@LauraBeatris LauraBeatris changed the title chore(clerk-js,types,backend): Add enterprise_connection_id to SamlAccount and EnterpriseAccount resources chore(clerk-js,types,backend): Add enterprise_connection_id to SamlAccount and EnterpriseAccount resources Oct 10, 2025
@LauraBeatris LauraBeatris changed the title chore(clerk-js,types,backend): Add enterprise_connection_id to SamlAccount and EnterpriseAccount resources chore(clerk-js,types,backend): Add enterprise_connection_id to SamlAccount and EnterpriseAccount Oct 10, 2025
@LauraBeatris LauraBeatris changed the title chore(clerk-js,types,backend): Add enterprise_connection_id to SamlAccount and EnterpriseAccount chore(clerk-js,types,backend): Add enterprise_connection_id to SamlAccount & EnterpriseAccount Oct 10, 2025
@LauraBeatris LauraBeatris force-pushed the laura/add-enterprise-connection-id branch from 7606a72 to 9ca31c9 Compare October 10, 2025 20:23
@LauraBeatris LauraBeatris marked this pull request as ready for review October 10, 2025 20:26
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
packages/clerk-js/src/core/resources/EnterpriseAccount.ts (1)

95-95: Use null as the default value for consistency.

The field type is string | null, but the default value is an empty string ''. For consistency with the type annotation and with the similar field in SamlAccount.ts (line 27), the default should be null.

Apply this diff:

-  enterpriseConnectionId: string | null = '';
+  enterpriseConnectionId: string | null = null;
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 0835ee7 and 9ca31c9.

📒 Files selected for processing (6)
  • .changeset/flat-teams-trade.md (1 hunks)
  • packages/backend/src/api/resources/JSON.ts (1 hunks)
  • packages/backend/src/api/resources/SamlAccount.ts (2 hunks)
  • packages/clerk-js/src/core/resources/EnterpriseAccount.ts (3 hunks)
  • packages/clerk-js/src/core/resources/SamlAccount.ts (3 hunks)
  • packages/types/src/json.ts (2 hunks)
🧰 Additional context used
📓 Path-based instructions (7)
**/*.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

**/*.{js,jsx,ts,tsx}: All code must pass ESLint checks with the project's configuration
Follow established naming conventions (PascalCase for components, camelCase for variables)
Maintain comprehensive JSDoc comments for public APIs
Use dynamic imports for optional features
All public APIs must be documented with JSDoc
Provide meaningful error messages to developers
Include error recovery suggestions where applicable
Log errors appropriately for debugging
Lazy load components and features when possible
Implement proper caching strategies
Use efficient data structures and algorithms
Profile and optimize critical paths
Validate all inputs and sanitize outputs
Implement proper logging with different levels

Files:

  • packages/backend/src/api/resources/SamlAccount.ts
  • packages/types/src/json.ts
  • packages/backend/src/api/resources/JSON.ts
  • packages/clerk-js/src/core/resources/EnterpriseAccount.ts
  • packages/clerk-js/src/core/resources/SamlAccount.ts
**/*.{js,jsx,ts,tsx,json,css,scss,md,yaml,yml}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Use Prettier for consistent code formatting

Files:

  • packages/backend/src/api/resources/SamlAccount.ts
  • packages/types/src/json.ts
  • packages/backend/src/api/resources/JSON.ts
  • packages/clerk-js/src/core/resources/EnterpriseAccount.ts
  • packages/clerk-js/src/core/resources/SamlAccount.ts
packages/**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

TypeScript is required for all packages

Files:

  • packages/backend/src/api/resources/SamlAccount.ts
  • packages/types/src/json.ts
  • packages/backend/src/api/resources/JSON.ts
  • packages/clerk-js/src/core/resources/EnterpriseAccount.ts
  • packages/clerk-js/src/core/resources/SamlAccount.ts
packages/**/*.{ts,tsx,d.ts}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Packages should export TypeScript types alongside runtime code

Files:

  • packages/backend/src/api/resources/SamlAccount.ts
  • packages/types/src/json.ts
  • packages/backend/src/api/resources/JSON.ts
  • packages/clerk-js/src/core/resources/EnterpriseAccount.ts
  • packages/clerk-js/src/core/resources/SamlAccount.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Use proper TypeScript error types

**/*.{ts,tsx}: Always define explicit return types for functions, especially public APIs
Use proper type annotations for variables and parameters where inference isn't clear
Avoid any type - prefer unknown when type is uncertain, then narrow with type guards
Use interface for object shapes that might be extended
Use type for unions, primitives, and computed types
Prefer readonly properties for immutable data structures
Use private for internal implementation details
Use protected for inheritance hierarchies
Use public explicitly for clarity in public APIs
Prefer readonly for properties that shouldn't change after construction
Prefer composition and interfaces over deep inheritance chains
Use mixins for shared behavior across unrelated classes
Implement dependency injection for loose coupling
Let TypeScript infer when types are obvious
Use const assertions for literal types: as const
Use satisfies operator for type checking without widening
Use mapped types for transforming object types
Use conditional types for type-level logic
Leverage template literal types for string manipulation
Use ES6 imports/exports consistently
Use default exports sparingly, prefer named exports
Use type-only imports: import type { ... } from ...
No any types without justification
Proper error handling with typed errors
Consistent use of readonly for immutable data
Proper generic constraints
No unused type parameters
Proper use of utility types instead of manual type construction
Type-only imports where possible
Proper tree-shaking friendly exports
No circular dependencies
Efficient type computations (avoid deep recursion)

Files:

  • packages/backend/src/api/resources/SamlAccount.ts
  • packages/types/src/json.ts
  • packages/backend/src/api/resources/JSON.ts
  • packages/clerk-js/src/core/resources/EnterpriseAccount.ts
  • packages/clerk-js/src/core/resources/SamlAccount.ts
**/*.{js,ts,tsx,jsx}

📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)

Support multiple Clerk environment variables (CLERK_, NEXT_PUBLIC_CLERK_, etc.) for configuration.

Files:

  • packages/backend/src/api/resources/SamlAccount.ts
  • packages/types/src/json.ts
  • packages/backend/src/api/resources/JSON.ts
  • packages/clerk-js/src/core/resources/EnterpriseAccount.ts
  • packages/clerk-js/src/core/resources/SamlAccount.ts
.changeset/**

📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)

Automated releases must use Changesets.

Files:

  • .changeset/flat-teams-trade.md
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: semgrep-cloud-platform/scan
🔇 Additional comments (6)
.changeset/flat-teams-trade.md (1)

1-7: LGTM!

The changeset correctly documents the addition of enterprise_connection_id to the public APIs of SamlAccount and EnterpriseAccount resources. The patch-level versioning is appropriate for this additive change.

packages/backend/src/api/resources/JSON.ts (1)

250-250: LGTM!

The addition of enterprise_connection_id: string | null to the SamlAccountJSON interface follows the established conventions for optional ID fields in JSON representations.

packages/clerk-js/src/core/resources/EnterpriseAccount.ts (1)

116-116: LGTM!

The mapping from JSON (enterprise_connection_id) to the class property (enterpriseConnectionId) and serialization back to JSON are both implemented correctly.

Also applies to: 136-136

packages/types/src/json.ts (1)

271-271: LGTM!

The addition of enterprise_connection_id: string | null to both EnterpriseAccountConnectionJSON and SamlAccountJSON is consistent and follows the established type definition patterns.

Also applies to: 285-285

packages/backend/src/api/resources/SamlAccount.ts (1)

50-53: LGTM!

The JSDoc documentation clearly describes the new enterpriseConnectionId parameter, and the fromJSON method correctly maps the enterprise_connection_id field from the JSON data.

Also applies to: 68-68

packages/clerk-js/src/core/resources/SamlAccount.ts (1)

27-27: LGTM!

The implementation correctly:

  • Declares enterpriseConnectionId with null as the default value (appropriate for string | null)
  • Maps enterprise_connection_id from JSON to the class property in fromJSON
  • Serializes back to enterprise_connection_id in the snapshot

This follows the established pattern for nullable fields in the codebase.

Also applies to: 48-48, 75-75

@LauraBeatris
Copy link
Member Author

!snapshot

@clerk-cookie
Copy link
Collaborator

Hey @LauraBeatris - the snapshot version command generated the following package versions:

Package Version
@clerk/agent-toolkit 0.1.39-snapshot.v20251010205949
@clerk/astro 2.13.7-snapshot.v20251010205949
@clerk/backend 2.18.0-snapshot.v20251010205949
@clerk/chrome-extension 2.7.4-snapshot.v20251010205949
@clerk/clerk-js 5.100.0-snapshot.v20251010205949
@clerk/elements 0.23.70-snapshot.v20251010205949
@clerk/clerk-expo 2.16.2-snapshot.v20251010205949
@clerk/expo-passkeys 0.4.7-snapshot.v20251010205949
@clerk/express 1.7.38-snapshot.v20251010205949
@clerk/fastify 2.4.38-snapshot.v20251010205949
@clerk/localizations 3.26.0-snapshot.v20251010205949
@clerk/nextjs 6.33.4-snapshot.v20251010205949
@clerk/nuxt 1.10.1-snapshot.v20251010205949
@clerk/clerk-react 5.52.0-snapshot.v20251010205949
@clerk/react-router 2.1.1-snapshot.v20251010205949
@clerk/remix 4.13.4-snapshot.v20251010205949
@clerk/shared 3.27.4-snapshot.v20251010205949
@clerk/tanstack-react-start 0.26.0-snapshot.v20251010205949
@clerk/testing 1.13.4-snapshot.v20251010205949
@clerk/themes 2.4.26-snapshot.v20251010205949
@clerk/types 4.93.0-snapshot.v20251010205949
@clerk/vue 1.14.4-snapshot.v20251010205949

Tip: Use the snippet copy button below to quickly install the required packages.
@clerk/agent-toolkit

npm i @clerk/agent-toolkit@0.1.39-snapshot.v20251010205949 --save-exact

@clerk/astro

npm i @clerk/astro@2.13.7-snapshot.v20251010205949 --save-exact

@clerk/backend

npm i @clerk/backend@2.18.0-snapshot.v20251010205949 --save-exact

@clerk/chrome-extension

npm i @clerk/chrome-extension@2.7.4-snapshot.v20251010205949 --save-exact

@clerk/clerk-js

npm i @clerk/clerk-js@5.100.0-snapshot.v20251010205949 --save-exact

@clerk/elements

npm i @clerk/elements@0.23.70-snapshot.v20251010205949 --save-exact

@clerk/clerk-expo

npm i @clerk/clerk-expo@2.16.2-snapshot.v20251010205949 --save-exact

@clerk/expo-passkeys

npm i @clerk/expo-passkeys@0.4.7-snapshot.v20251010205949 --save-exact

@clerk/express

npm i @clerk/express@1.7.38-snapshot.v20251010205949 --save-exact

@clerk/fastify

npm i @clerk/fastify@2.4.38-snapshot.v20251010205949 --save-exact

@clerk/localizations

npm i @clerk/localizations@3.26.0-snapshot.v20251010205949 --save-exact

@clerk/nextjs

npm i @clerk/nextjs@6.33.4-snapshot.v20251010205949 --save-exact

@clerk/nuxt

npm i @clerk/nuxt@1.10.1-snapshot.v20251010205949 --save-exact

@clerk/clerk-react

npm i @clerk/clerk-react@5.52.0-snapshot.v20251010205949 --save-exact

@clerk/react-router

npm i @clerk/react-router@2.1.1-snapshot.v20251010205949 --save-exact

@clerk/remix

npm i @clerk/remix@4.13.4-snapshot.v20251010205949 --save-exact

@clerk/shared

npm i @clerk/shared@3.27.4-snapshot.v20251010205949 --save-exact

@clerk/tanstack-react-start

npm i @clerk/tanstack-react-start@0.26.0-snapshot.v20251010205949 --save-exact

@clerk/testing

npm i @clerk/testing@1.13.4-snapshot.v20251010205949 --save-exact

@clerk/themes

npm i @clerk/themes@2.4.26-snapshot.v20251010205949 --save-exact

@clerk/types

npm i @clerk/types@4.93.0-snapshot.v20251010205949 --save-exact

@clerk/vue

npm i @clerk/vue@1.14.4-snapshot.v20251010205949 --save-exact

Copy link

pkg-pr-new bot commented Oct 10, 2025

Open in StackBlitz

@clerk/agent-toolkit

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

@clerk/astro

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

@clerk/backend

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

@clerk/chrome-extension

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

@clerk/clerk-js

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

@clerk/dev-cli

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

@clerk/elements

npm i https://pkg.pr.new/@clerk/elements@6961

@clerk/clerk-expo

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

@clerk/expo-passkeys

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

@clerk/express

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

@clerk/fastify

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

@clerk/localizations

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

@clerk/nextjs

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

@clerk/nuxt

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

@clerk/clerk-react

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

@clerk/react-router

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

@clerk/remix

npm i https://pkg.pr.new/@clerk/remix@6961

@clerk/shared

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

@clerk/tanstack-react-start

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

@clerk/testing

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

@clerk/themes

npm i https://pkg.pr.new/@clerk/themes@6961

@clerk/types

npm i https://pkg.pr.new/@clerk/types@6961

@clerk/upgrade

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

@clerk/vue

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

commit: bed5e7f

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 9ca31c9 and bed5e7f.

📒 Files selected for processing (3)
  • packages/clerk-js/src/core/resources/EnterpriseAccount.ts (6 hunks)
  • packages/types/src/enterpriseAccount.ts (1 hunks)
  • packages/types/src/json.ts (3 hunks)
🧰 Additional context used
📓 Path-based instructions (6)
**/*.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

**/*.{js,jsx,ts,tsx}: All code must pass ESLint checks with the project's configuration
Follow established naming conventions (PascalCase for components, camelCase for variables)
Maintain comprehensive JSDoc comments for public APIs
Use dynamic imports for optional features
All public APIs must be documented with JSDoc
Provide meaningful error messages to developers
Include error recovery suggestions where applicable
Log errors appropriately for debugging
Lazy load components and features when possible
Implement proper caching strategies
Use efficient data structures and algorithms
Profile and optimize critical paths
Validate all inputs and sanitize outputs
Implement proper logging with different levels

Files:

  • packages/types/src/json.ts
  • packages/types/src/enterpriseAccount.ts
  • packages/clerk-js/src/core/resources/EnterpriseAccount.ts
**/*.{js,jsx,ts,tsx,json,css,scss,md,yaml,yml}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Use Prettier for consistent code formatting

Files:

  • packages/types/src/json.ts
  • packages/types/src/enterpriseAccount.ts
  • packages/clerk-js/src/core/resources/EnterpriseAccount.ts
packages/**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

TypeScript is required for all packages

Files:

  • packages/types/src/json.ts
  • packages/types/src/enterpriseAccount.ts
  • packages/clerk-js/src/core/resources/EnterpriseAccount.ts
packages/**/*.{ts,tsx,d.ts}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Packages should export TypeScript types alongside runtime code

Files:

  • packages/types/src/json.ts
  • packages/types/src/enterpriseAccount.ts
  • packages/clerk-js/src/core/resources/EnterpriseAccount.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Use proper TypeScript error types

**/*.{ts,tsx}: Always define explicit return types for functions, especially public APIs
Use proper type annotations for variables and parameters where inference isn't clear
Avoid any type - prefer unknown when type is uncertain, then narrow with type guards
Use interface for object shapes that might be extended
Use type for unions, primitives, and computed types
Prefer readonly properties for immutable data structures
Use private for internal implementation details
Use protected for inheritance hierarchies
Use public explicitly for clarity in public APIs
Prefer readonly for properties that shouldn't change after construction
Prefer composition and interfaces over deep inheritance chains
Use mixins for shared behavior across unrelated classes
Implement dependency injection for loose coupling
Let TypeScript infer when types are obvious
Use const assertions for literal types: as const
Use satisfies operator for type checking without widening
Use mapped types for transforming object types
Use conditional types for type-level logic
Leverage template literal types for string manipulation
Use ES6 imports/exports consistently
Use default exports sparingly, prefer named exports
Use type-only imports: import type { ... } from ...
No any types without justification
Proper error handling with typed errors
Consistent use of readonly for immutable data
Proper generic constraints
No unused type parameters
Proper use of utility types instead of manual type construction
Type-only imports where possible
Proper tree-shaking friendly exports
No circular dependencies
Efficient type computations (avoid deep recursion)

Files:

  • packages/types/src/json.ts
  • packages/types/src/enterpriseAccount.ts
  • packages/clerk-js/src/core/resources/EnterpriseAccount.ts
**/*.{js,ts,tsx,jsx}

📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)

Support multiple Clerk environment variables (CLERK_, NEXT_PUBLIC_CLERK_, etc.) for configuration.

Files:

  • packages/types/src/json.ts
  • packages/types/src/enterpriseAccount.ts
  • packages/clerk-js/src/core/resources/EnterpriseAccount.ts
🧬 Code graph analysis (1)
packages/types/src/enterpriseAccount.ts (1)
packages/types/src/verification.ts (1)
  • VerificationResource (7-20)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
  • GitHub Check: Formatting | Dedupe | Changeset
  • GitHub Check: Build Packages
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: semgrep-cloud-platform/scan
  • GitHub Check: semgrep-cloud-platform/scan
🔇 Additional comments (7)
packages/types/src/enterpriseAccount.ts (2)

15-15: LGTM!

The addition of enterpriseConnectionId is correctly typed and follows the established naming conventions.


23-23: Verify scope: lastAuthenticatedAt not mentioned in PR summary.

The addition of lastAuthenticatedAt is not mentioned in the PR title or summary, which focuses solely on enterprise_connection_id. Confirm this addition is intentional and part of the same feature.

packages/clerk-js/src/core/resources/EnterpriseAccount.ts (2)

28-28: LGTM!

The enterpriseConnectionId field is correctly:

  • Declared with appropriate type (string | null)
  • Initialized to null
  • Mapped from JSON (data.enterprise_connection_id)
  • Serialized to snapshot (enterprise_connection_id)

Also applies to: 52-52, 79-79


119-119: LGTM!

The enterpriseConnectionId field is correctly mapped from JSON and serialized to snapshot with proper snake_case/camelCase conversion.

Also applies to: 139-139

packages/types/src/json.ts (3)

256-256: LGTM!

The enterprise_connection_id field is correctly added to EnterpriseAccountJSON with appropriate nullable type and snake_case naming convention.


272-272: LGTM!

The enterprise_connection_id field is correctly added to EnterpriseAccountConnectionJSON with appropriate nullable type and snake_case naming convention.


286-286: LGTM!

The enterprise_connection_id field is correctly added to SamlAccountJSON with appropriate nullable type and snake_case naming convention.

syncUserAttributes!: boolean;
createdAt!: Date;
updatedAt!: Date;
enterpriseConnectionId: string | null = '';
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion | 🟠 Major

Initialize enterpriseConnectionId to null instead of empty string.

The field is initialized to '' (empty string) but should be null for consistency with:

  • The type declaration (string | null)
  • The same field in EnterpriseAccount class (line 28, initialized to null)
  • Semantic clarity: null better represents the absence of an ID

While logoPublicUrl on line 91 also uses '', for a new ID field, null is the more appropriate default.

Apply this diff:

-  enterpriseConnectionId: string | null = '';
+  enterpriseConnectionId: string | null = null;
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
enterpriseConnectionId: string | null = '';
enterpriseConnectionId: string | null = null;
🤖 Prompt for AI Agents
In packages/clerk-js/src/core/resources/EnterpriseAccount.ts around line 98, the
property enterpriseConnectionId is initialized to an empty string but its type
is string | null and should match the class's other initialization; change the
initialization from '' to null so the field defaults to null (absence of an ID)
and remains type-consistent.

@NicolasLopes7
Copy link
Contributor

!snapshot

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants