-
Notifications
You must be signed in to change notification settings - Fork 393
chore(clerk-js,types,backend): Add enterprise_connection_id
to SamlAccount
& EnterpriseAccount
#6961
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
🦋 Changeset detectedLatest commit: bed5e7f The changes in this PR will be included in the next version bump. This PR includes changesets to release 22 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
The latest updates on your projects. Learn more about Vercel for GitHub.
|
WalkthroughAdds an optional field Changes
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
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Comment |
enterprise_connection_id
to SamlAccount
and EnterpriseAccount
resources enterprise_connection_id
to SamlAccount
and EnterpriseAccount
resources
enterprise_connection_id
to SamlAccount
and EnterpriseAccount
resourcesenterprise_connection_id
to SamlAccount
and EnterpriseAccount
enterprise_connection_id
to SamlAccount
and EnterpriseAccount
enterprise_connection_id
to SamlAccount
& EnterpriseAccount
7606a72
to
9ca31c9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
packages/clerk-js/src/core/resources/EnterpriseAccount.ts (1)
95-95
: Usenull
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 inSamlAccount.ts
(line 27), the default should benull
.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.
📒 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
Avoidany
type - preferunknown
when type is uncertain, then narrow with type guards
Useinterface
for object shapes that might be extended
Usetype
for unions, primitives, and computed types
Preferreadonly
properties for immutable data structures
Useprivate
for internal implementation details
Useprotected
for inheritance hierarchies
Usepublic
explicitly for clarity in public APIs
Preferreadonly
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
Useconst assertions
for literal types:as const
Usesatisfies
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 ...
Noany
types without justification
Proper error handling with typed errors
Consistent use ofreadonly
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 ofSamlAccount
andEnterpriseAccount
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 theSamlAccountJSON
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 bothEnterpriseAccountConnectionJSON
andSamlAccountJSON
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 thefromJSON
method correctly maps theenterprise_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
withnull
as the default value (appropriate forstring | null
)- Maps
enterprise_connection_id
from JSON to the class property infromJSON
- Serializes back to
enterprise_connection_id
in the snapshotThis follows the established pattern for nullable fields in the codebase.
Also applies to: 48-48, 75-75
!snapshot |
Hey @LauraBeatris - the snapshot version command generated the following package versions:
Tip: Use the snippet copy button below to quickly install the required packages. npm i @clerk/agent-toolkit@0.1.39-snapshot.v20251010205949 --save-exact
npm i @clerk/astro@2.13.7-snapshot.v20251010205949 --save-exact
npm i @clerk/backend@2.18.0-snapshot.v20251010205949 --save-exact
npm i @clerk/chrome-extension@2.7.4-snapshot.v20251010205949 --save-exact
npm i @clerk/clerk-js@5.100.0-snapshot.v20251010205949 --save-exact
npm i @clerk/elements@0.23.70-snapshot.v20251010205949 --save-exact
npm i @clerk/clerk-expo@2.16.2-snapshot.v20251010205949 --save-exact
npm i @clerk/expo-passkeys@0.4.7-snapshot.v20251010205949 --save-exact
npm i @clerk/express@1.7.38-snapshot.v20251010205949 --save-exact
npm i @clerk/fastify@2.4.38-snapshot.v20251010205949 --save-exact
npm i @clerk/localizations@3.26.0-snapshot.v20251010205949 --save-exact
npm i @clerk/nextjs@6.33.4-snapshot.v20251010205949 --save-exact
npm i @clerk/nuxt@1.10.1-snapshot.v20251010205949 --save-exact
npm i @clerk/clerk-react@5.52.0-snapshot.v20251010205949 --save-exact
npm i @clerk/react-router@2.1.1-snapshot.v20251010205949 --save-exact
npm i @clerk/remix@4.13.4-snapshot.v20251010205949 --save-exact
npm i @clerk/shared@3.27.4-snapshot.v20251010205949 --save-exact
npm i @clerk/tanstack-react-start@0.26.0-snapshot.v20251010205949 --save-exact
npm i @clerk/testing@1.13.4-snapshot.v20251010205949 --save-exact
npm i @clerk/themes@2.4.26-snapshot.v20251010205949 --save-exact
npm i @clerk/types@4.93.0-snapshot.v20251010205949 --save-exact
npm i @clerk/vue@1.14.4-snapshot.v20251010205949 --save-exact |
@clerk/agent-toolkit
@clerk/astro
@clerk/backend
@clerk/chrome-extension
@clerk/clerk-js
@clerk/dev-cli
@clerk/elements
@clerk/clerk-expo
@clerk/expo-passkeys
@clerk/express
@clerk/fastify
@clerk/localizations
@clerk/nextjs
@clerk/nuxt
@clerk/clerk-react
@clerk/react-router
@clerk/remix
@clerk/shared
@clerk/tanstack-react-start
@clerk/testing
@clerk/themes
@clerk/types
@clerk/upgrade
@clerk/vue
commit: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 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.
📒 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
Avoidany
type - preferunknown
when type is uncertain, then narrow with type guards
Useinterface
for object shapes that might be extended
Usetype
for unions, primitives, and computed types
Preferreadonly
properties for immutable data structures
Useprivate
for internal implementation details
Useprotected
for inheritance hierarchies
Usepublic
explicitly for clarity in public APIs
Preferreadonly
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
Useconst assertions
for literal types:as const
Usesatisfies
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 ...
Noany
types without justification
Proper error handling with typed errors
Consistent use ofreadonly
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 onenterprise_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 toEnterpriseAccountJSON
with appropriate nullable type and snake_case naming convention.
272-272
: LGTM!The
enterprise_connection_id
field is correctly added toEnterpriseAccountConnectionJSON
with appropriate nullable type and snake_case naming convention.
286-286
: LGTM!The
enterprise_connection_id
field is correctly added toSamlAccountJSON
with appropriate nullable type and snake_case naming convention.
syncUserAttributes!: boolean; | ||
createdAt!: Date; | ||
updatedAt!: Date; | ||
enterpriseConnectionId: string | null = ''; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ 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 tonull
) - 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.
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.
!snapshot |
Description
This PR introduces a
enterprise_connection_id
property to theSamlAccount
andEnterpriseAccount
resourcesChecklist
pnpm test
runs as expected.pnpm build
runs as expected.Type of change
Summary by CodeRabbit
New Features
Chores