Skip to content

refactor: extract 'prisma-client-js' into PRISMA_CLIENT_JS_PROVIDER constant - #29317

Merged
jacek-prisma merged 5 commits into
prisma:mainfrom
Felipeness:refactor/extract-prisma-client-js-constant
Mar 17, 2026
Merged

jacek-prisma merged 5 commits into
prisma:mainfrom
Felipeness:refactor/extract-prisma-client-js-constant

Conversation

@Felipeness

@Felipeness Felipeness commented Mar 7, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Closes #29316

Extracts the hardcoded 'prisma-client-js' string literal into a shared PRISMA_CLIENT_JS_PROVIDER constant defined in @prisma/internals, replacing all occurrences across the codebase.

Changes

  • New: packages/internals/src/prisma-client-js-provider.ts — single source of truth for the constant
  • Modified (8 files across 4 packages):
    • packages/internals/src/index.ts — export the constant
    • packages/internals/src/cli/getGeneratorSuccessMessage.ts — use constant
    • packages/internals/src/utils/extractPreviewFeatures.ts — use constant
    • packages/cli/src/Generate.ts — use constant (2 occurrences)
    • packages/cli/src/utils/checkpoint.ts — use constant
    • packages/client-generator-js/src/generator.ts — use constant
    • packages/client-generator-js/src/utils/types/dmmfToTypes.ts — use constant (2 occurrences)
    • packages/client/src/utils/getTestClient.ts — use constant

Motivation

This was identified during the review of #29315 by @coderabbitai. Having a single constant:

  • Eliminates risk of typos in the provider string
  • Makes it easy to find all usages via "Find References"
  • Provides a single place to update if the value ever changes

Test plan

  • pnpm build passes (43 tasks)
  • getGenerators tests pass (40/40, 33 snapshots)
  • No behavioral changes — pure mechanical refactor

Summary by CodeRabbit

  • Refactor
    • Standardized provider identifiers across internal modules using a centralized constant.
    • No changes to behavior or public APIs; end-user experience remains unchanged.
    • Improved internal consistency and reliability of provider detection and generator selection logic.

@coderabbitai

coderabbitai Bot commented Mar 7, 2026 •

Copy link
Copy Markdown
Contributor

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 768dd7a2-a4a6-4d3d-b910-276dfd847751

📥 Commits

Reviewing files that changed from the base of the PR and between d32eb75 and fd02429.

📒 Files selected for processing (9)
  • packages/cli/src/Generate.ts
  • packages/cli/src/utils/checkpoint.ts
  • packages/client-generator-js/src/generator.ts
  • packages/client-generator-js/src/utils/types/dmmfToTypes.ts
  • packages/client/src/utils/getTestClient.ts
  • packages/internals/src/built-in-provider.ts
  • packages/internals/src/cli/getGeneratorSuccessMessage.ts
  • packages/internals/src/index.ts
  • packages/internals/src/utils/extractPreviewFeatures.ts

Walkthrough

A new exported constant BuiltInProvider was added to packages/internals, and occurrences of the provider string literal 'prisma-client-js' (and related provider identifiers) were replaced across packages with references to BuiltInProvider members.

Changes

Cohort / File(s) Summary
Internals: definition & export
packages/internals/src/built-in-provider.ts, packages/internals/src/index.ts
Added and exported BuiltInProvider with PrismaClientJs = 'prisma-client-js' and PrismaClientTs = 'prisma-client'.
CLI & checkpoint utilities
packages/cli/src/Generate.ts, packages/cli/src/utils/checkpoint.ts
Replaced string-literal provider checks/arrays with BuiltInProvider values for provider detection/selection and preview-feature handling.
Client generator (js) code
packages/client-generator-js/src/generator.ts, packages/client-generator-js/src/utils/types/dmmfToTypes.ts
Replaced literal 'prisma-client-js' assignments with BuiltInProvider.PrismaClientJs for generator name and provider fields.
Client & internals helpers
packages/client/src/utils/getTestClient.ts, packages/internals/src/cli/getGeneratorSuccessMessage.ts, packages/internals/src/utils/extractPreviewFeatures.ts
Replaced provider identity comparisons using the 'prisma-client-js' literal with BuiltInProvider.PrismaClientJs.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 60.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main refactoring objective—extracting the repeated 'prisma-client-js' string literal into a centralized constant, which is exactly what the PR implements.
Linked Issues check ✅ Passed The PR fully addresses issue #29316 by extracting 'prisma-client-js' into a BuiltInProvider constant, replacing all hardcoded occurrences across the specified files, and introducing 'prisma-client' as BuiltInProvider.PrismaClientTs as an additional improvement.
Out of Scope Changes check ✅ Passed All changes are directly aligned with the refactoring objective; the addition of BuiltInProvider.PrismaClientTs in checkpoint.ts is a natural extension of the provider consolidation goal and does not introduce unrelated functionality.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
📝 Coding Plan
  • Generate coding plan for human review comments

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@coderabbitai coderabbitai Bot 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


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 6d41f57b-41e0-4f71-b864-384b371d4c45

📥 Commits

Reviewing files that changed from the base of the PR and between 9fa295d and f308cb5.

📒 Files selected for processing (9)
  • packages/cli/src/Generate.ts
  • packages/cli/src/utils/checkpoint.ts
  • packages/client-generator-js/src/generator.ts
  • packages/client-generator-js/src/utils/types/dmmfToTypes.ts
  • packages/client/src/utils/getTestClient.ts
  • packages/internals/src/cli/getGeneratorSuccessMessage.ts
  • packages/internals/src/index.ts
  • packages/internals/src/prisma-client-js-provider.ts
  • packages/internals/src/utils/extractPreviewFeatures.ts

Comment thread packages/cli/src/utils/checkpoint.ts Resolved
@Felipeness

Copy link
Copy Markdown
Contributor Author

Hey! Just a heads-up that the "Milestone Check" is blocking this PR because no milestone has been assigned yet — and as an external contributor I can't set it myself. Would a maintainer be able to set the right milestone here (I'm guessing 7.5.0)? Thank you!

@jacek-prisma jacek-prisma 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.

Suggested 1 change

@coderabbitai coderabbitai Bot 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


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 53321e7c-8438-4b17-a906-325cd2bc767d

📥 Commits

Reviewing files that changed from the base of the PR and between f308cb5 and 5e819eb.

📒 Files selected for processing (9)
  • packages/cli/src/Generate.ts
  • packages/cli/src/utils/checkpoint.ts
  • packages/client-generator-js/src/generator.ts
  • packages/client-generator-js/src/utils/types/dmmfToTypes.ts
  • packages/client/src/utils/getTestClient.ts
  • packages/internals/src/cli/getGeneratorSuccessMessage.ts
  • packages/internals/src/index.ts
  • packages/internals/src/prisma-client-js-provider.ts
  • packages/internals/src/utils/extractPreviewFeatures.ts

@Felipeness

Copy link
Copy Markdown
Contributor Author

Hey Jacek! Applied both suggestions — grouped the providers into a BuiltInProvider const enum and renamed the file to built-in-provider.ts. Also took the opportunity to replace the hardcoded 'prisma-client' in checkpoint.ts with BuiltInProvider.PrismaClientTs. Let me know if it looks good!

Create PRISMA_CLIENT_JS_PROVIDER constant in @prisma/internals and
replace all hardcoded 'prisma-client-js' string literals across
cli, client, client-generator-js, and internals packages.
Group built-in provider strings into a single const enum as suggested
in code review, also replacing the hardcoded 'prisma-client' literal.
@Felipeness
Felipeness force-pushed the refactor/extract-prisma-client-js-constant branch from d32eb75 to fd02429 Compare March 17, 2026 13:13
@Felipeness

Copy link
Copy Markdown
Contributor Author

Hey @jacek-prisma! Quick update on the latest changes:

Fixed the CI failures — the const enum approach didn't work because the project uses isolatedModules: true in tsconfig.build.regular.json. Cross-package const enum access fails with TS2748. Switched to the as const object (your second suggestion), which works identically but is compatible with isolatedModules.

Changes in the latest push:

  • Rebased on latest main
  • const enum → as const object (fixes all 216 CI failures)
  • Added string[] type annotation in checkpoint.ts (needed because as const creates literal types that are stricter with .includes())
  • Added JSDoc comment on BuiltInProvider

Still need maintainer action:

  • Set milestone (guessing 7.5.0?)
  • Approve the CI workflows
  • Re-review when you get a chance

Thanks!

@coderabbitai coderabbitai Bot 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.

♻️ Duplicate comments (1)
packages/internals/src/built-in-provider.ts (1)

1-4: 🧹 Nitpick | 🔵 Trivial

Add a documentation comment for the exported BuiltInProvider constant.

The exported constant is missing a documentation comment. As per coding guidelines: "Write documentation comments for exported items."

📝 Proposed documentation
+/**
+ * Built-in generator provider identifiers used across Prisma packages.
+ */
 export const BuiltInProvider = {
   PrismaClientJs: 'prisma-client-js',
   PrismaClientTs: 'prisma-client',
 } as const

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 9ce5f11b-8344-4747-a621-b4b1dc43bd0c

📥 Commits

Reviewing files that changed from the base of the PR and between 4973261 and d32eb75.

📒 Files selected for processing (2)
  • packages/cli/src/utils/checkpoint.ts
  • packages/internals/src/built-in-provider.ts

@jacek-prisma
jacek-prisma merged commit 309b4bc into prisma:main Mar 17, 2026
250 of 251 checks passed
thomasjahoda pushed a commit to thomasjahoda/prisma that referenced this pull request Mar 22, 2026
thomasjahoda pushed a commit to thomasjahoda/prisma that referenced this pull request Mar 22, 2026
thomasjahoda pushed a commit to thomasjahoda/prisma that referenced this pull request Apr 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

refactor: extract 'prisma-client-js' string literal into a shared constant

2 participants