Skip to content

chore(types,clerk-react,astro,vue): Share Protect component prop type between SDKs #6197

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

Merged
merged 7 commits into from
Jun 26, 2025

Conversation

wobsoriano
Copy link
Member

@wobsoriano wobsoriano commented Jun 25, 2025

Description

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

  • Refactor
    • Centralized and shared internal authorization-related type definitions across multiple SDKs for improved consistency.
    • Streamlined maintenance by reducing duplication of authorization type definitions.
    • No changes to user-facing features or public APIs.

Copy link

changeset-bot bot commented Jun 25, 2025

🦋 Changeset detected

Latest commit: 527a9b4

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

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

Copy link

vercel bot commented Jun 25, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
clerk-js-sandbox ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 26, 2025 5:10pm

@wobsoriano wobsoriano marked this pull request as ready for review June 25, 2025 23:07
Copy link
Contributor

coderabbitai bot commented Jun 25, 2025

📝 Walkthrough
## Walkthrough

This change extracts the internal `ProtectProps` type from multiple SDK packages (`@clerk/astro`, `@clerk/clerk-react`, `@clerk/types`, and `@clerk/vue`) and centralizes it in a shared module within `@clerk/types`. The local definitions of `ProtectProps` in each SDK are removed and replaced with imports from the shared types package. The new shared `ProtectProps` type enforces mutual exclusivity among its authorization-related properties. No changes are made to public or exported entity signatures beyond the internal refactoring of type definitions.

## Possibly related PRs

- clerk/javascript#6188: This PR introduces new `feature` and `plan` variants to the `ProtectProps` type and updates the `<Protect>` component to support these new props. It is related as it extends the type that is now being centralized in the current PR.

## Suggested reviewers

- panteliselef
- anagstef

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 17d7329 and 03e46ef.

📒 Files selected for processing (1)
  • packages/types/src/protect.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/types/src/protect.ts
⏰ Context from checks skipped due to timeout of 90000ms (5)
  • GitHub Check: Build Packages
  • GitHub Check: Formatting | Dedupe | Changeset
  • GitHub Check: semgrep-cloud-platform/scan
  • GitHub Check: semgrep/ci
  • GitHub Check: Analyze (javascript-typescript)

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

pkg-pr-new bot commented Jun 25, 2025

Open in StackBlitz

@clerk/agent-toolkit

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

@clerk/astro

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

@clerk/backend

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

@clerk/chrome-extension

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

@clerk/clerk-js

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

@clerk/dev-cli

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

@clerk/elements

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

@clerk/clerk-expo

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

@clerk/expo-passkeys

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

@clerk/express

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

@clerk/fastify

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

@clerk/localizations

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

@clerk/nextjs

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

@clerk/nuxt

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

@clerk/clerk-react

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

@clerk/react-router

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

@clerk/remix

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

@clerk/shared

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

@clerk/tanstack-react-start

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

@clerk/testing

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

@clerk/themes

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

@clerk/types

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

@clerk/upgrade

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

@clerk/vue

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

commit: 527a9b4

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: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6200c5e and 17d7329.

📒 Files selected for processing (6)
  • .changeset/wet-foxes-attend.md (1 hunks)
  • packages/astro/src/types.ts (1 hunks)
  • packages/react/src/components/controlComponents.tsx (2 hunks)
  • packages/types/src/index.ts (1 hunks)
  • packages/types/src/protect.ts (1 hunks)
  • packages/vue/src/components/controlComponents.ts (2 hunks)
🧰 Additional context used
📓 Path-based instructions (6)
`**/*.{js,ts,tsx,jsx}`: All code must pass ESLint checks with the project's configuration. Use Prettier for consistent code formatting.

**/*.{js,ts,tsx,jsx}: All code must pass ESLint checks with the project's configuration.
Use Prettier for consistent code formatting.

📄 Source: CodeRabbit Inference Engine (.cursor/rules/development.mdc)

List of files the instruction was applied to:

  • packages/types/src/index.ts
  • packages/vue/src/components/controlComponents.ts
  • packages/astro/src/types.ts
  • packages/react/src/components/controlComponents.tsx
  • packages/types/src/protect.ts
`**/*.{ts,tsx}`: Maintain comprehensive JSDoc comments for public APIs.

**/*.{ts,tsx}: Maintain comprehensive JSDoc comments for public APIs.

📄 Source: CodeRabbit Inference Engine (.cursor/rules/development.mdc)

List of files the instruction was applied to:

  • packages/types/src/index.ts
  • packages/vue/src/components/controlComponents.ts
  • packages/astro/src/types.ts
  • packages/react/src/components/controlComponents.tsx
  • packages/types/src/protect.ts
`packages/**`: All publishable packages under the @clerk namespace must be located in the packages/ directory.

packages/**: All publishable packages under the @clerk namespace must be located in the packages/ directory.

📄 Source: CodeRabbit Inference Engine (.cursor/rules/global.mdc)

List of files the instruction was applied to:

  • packages/types/src/index.ts
  • packages/vue/src/components/controlComponents.ts
  • packages/astro/src/types.ts
  • packages/react/src/components/controlComponents.tsx
  • packages/types/src/protect.ts
`**/index.ts`: Use index.ts files for clean imports but avoid deep barrel exports.

**/index.ts: Use index.ts files for clean imports but avoid deep barrel exports.

📄 Source: CodeRabbit Inference Engine (.cursor/rules/react.mdc)

List of files the instruction was applied to:

  • packages/types/src/index.ts
`**/*.ts`: Always define explicit return types for functions, especially public ...

**/*.ts: 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, protected for inheritance, and public explicitly for clarity in public APIs.
Prefer composition and interfaces over deep inheritance chains; use mixins for shared behavior.
Use ES6 imports/exports consistently; avoid barrel files (index.ts re-exports) to prevent circular dependencies.
Use type-only imports (import type { ... }) where possible.
Use as const for literal types and the satisfies operator for type checking without widening.
Enable --incremental and --tsBuildInfoFile for faster builds.
Use ESLint with @typescript-eslint/recommended rules and Prettier for formatting.
Use lint-staged and Husky for pre-commit checks.
Use type-coverage to measure type safety.

📄 Source: CodeRabbit Inference Engine (.cursor/rules/typescript.mdc)

List of files the instruction was applied to:

  • packages/types/src/index.ts
  • packages/vue/src/components/controlComponents.ts
  • packages/astro/src/types.ts
  • packages/types/src/protect.ts
`**/*.{jsx,tsx}`: Always use functional components with hooks instead of class c...

**/*.{jsx,tsx}: Always use functional components with hooks instead of class components.
Follow PascalCase naming for components; the filename and component name should match.
Limit component size to 150-200 lines; extract logic into custom hooks.
Export components as named exports for better tree-shaking.
One component per file with matching filename and component name.
Co-locate related files (component, test, stories) in the same directory.

📄 Source: CodeRabbit Inference Engine (.cursor/rules/react.mdc)

List of files the instruction was applied to:

  • packages/react/src/components/controlComponents.tsx
🧬 Code Graph Analysis (2)
packages/vue/src/components/controlComponents.ts (4)
packages/types/src/protect.ts (1)
  • ProtectProps (5-47)
packages/react/src/components/controlComponents.tsx (1)
  • ProtectProps (72-76)
packages/astro/src/react/controlComponents.tsx (1)
  • ProtectProps (72-74)
packages/types/src/session.ts (1)
  • PendingSessionOptions (34-40)
packages/types/src/protect.ts (3)
packages/types/src/organizationMembership.ts (2)
  • OrganizationCustomRoleKey (77-81)
  • OrganizationCustomPermissionKey (64-68)
packages/types/src/session.ts (1)
  • CheckAuthorizationWithCustomPermissions (50-51)
packages/types/src/utils.ts (1)
  • Autocomplete (100-100)
⏰ Context from checks skipped due to timeout of 90000ms (23)
  • GitHub Check: Integration Tests (nextjs, chrome, 15)
  • GitHub Check: Integration Tests (nextjs, chrome, 13)
  • GitHub Check: Integration Tests (astro, chrome)
  • GitHub Check: Integration Tests (react-router, chrome)
  • GitHub Check: Integration Tests (nuxt, chrome)
  • GitHub Check: Integration Tests (localhost, chrome)
  • GitHub Check: Integration Tests (nextjs, chrome, 14)
  • GitHub Check: Integration Tests (expo-web, chrome)
  • GitHub Check: Integration Tests (billing, chrome)
  • GitHub Check: Integration Tests (tanstack-react-router, chrome)
  • GitHub Check: Integration Tests (vue, chrome)
  • GitHub Check: Integration Tests (ap-flows, chrome)
  • GitHub Check: Integration Tests (tanstack-react-start, chrome)
  • GitHub Check: Integration Tests (sessions, chrome)
  • GitHub Check: Integration Tests (elements, chrome)
  • GitHub Check: Integration Tests (generic, chrome)
  • GitHub Check: Integration Tests (quickstart, chrome)
  • GitHub Check: Integration Tests (express, chrome)
  • GitHub Check: Unit Tests (18, --filter=@clerk/astro --filter=@clerk/backend --filter=@clerk/express --filter=@c...
  • GitHub Check: Unit Tests (22, **)
  • GitHub Check: Publish with pkg-pr-new
  • GitHub Check: Static analysis
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (10)
packages/types/src/index.ts (1)

40-40: LGTM - Clean addition of shared type export.

The export statement follows the established alphabetical ordering pattern and correctly exposes the new shared ProtectProps type.

.changeset/wet-foxes-attend.md (1)

1-9: LGTM - Well-documented changeset.

The changeset appropriately uses patch level for all affected packages and clearly describes the internal refactoring without breaking changes.

packages/vue/src/components/controlComponents.ts (2)

5-5: LGTM - Proper import with alias to avoid naming conflicts.

The type-only import with alias follows TypeScript best practices and integrates cleanly with the shared types.


107-107: LGTM - Correct type definition for Vue's slot-based architecture.

The intersection with PendingSessionOptions is appropriate, and the absence of a fallback prop is correct since Vue uses slots for fallback content (as seen in the component implementation).

packages/astro/src/types.ts (2)

6-6: LGTM - Clean import of shared ProtectProps type.

Direct import of the shared type eliminates duplication and maintains consistency across SDKs.


48-48: LGTM - Appropriate re-export of shared type.

Re-exporting the ProtectProps type maintains the public API while leveraging the shared type definition.

packages/react/src/components/controlComponents.tsx (2)

2-2: LGTM - Proper type-only import with alias.

The import statement correctly brings in the shared ProtectProps type with an alias to avoid naming conflicts, following TypeScript best practices.


72-76: LGTM - Correct React-specific type extension.

The intersection type properly extends the shared _ProtectProps with React-specific requirements: PropsWithChildren for children support, fallback for React's prop-based fallback pattern, and PendingSessionOptions for authentication state handling.

packages/types/src/protect.ts (2)

1-3: LGTM: Clean type-only imports

The imports follow TypeScript best practices by using type-only imports and importing from the appropriate modules within the types package.


31-31: Consistent template literal type usage looks good

The feature and plan properties correctly use the Autocomplete utility type with template literal types to enforce the user: or org: prefix pattern while maintaining autocomplete functionality.

Also applies to: 39-39

@wobsoriano wobsoriano changed the title chore(types,react,astro,vue): Share Protect component prop type between SDKs chore(types,clerk-react,astro,vue): Share Protect component prop type between SDKs Jun 25, 2025
@wobsoriano wobsoriano merged commit edc0bfd into main Jun 26, 2025
61 of 62 checks passed
@wobsoriano wobsoriano deleted the rob/shared-protect-props branch June 26, 2025 18:33
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.

3 participants