Skip to content

Conversation

@ymc9
Copy link
Member

@ymc9 ymc9 commented Nov 22, 2025

No description provided.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 22, 2025

Important

Review skipped

Review was skipped due to path filters

⛔ Files ignored due to path filters (3)
  • packages/runtime/package.json is excluded by !**/*.json
  • packages/schema/package.json is excluded by !**/*.json
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml, !**/*.yaml

CodeRabbit blocks several paths by default. You can override this behavior by explicitly including those paths in the path filters. For example, including **/dist/** will override the default block on the dist directory, by removing the pattern from both the lists.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

📝 Walkthrough

Walkthrough

Bumps JetBrains plugin version and pins Prisma in tests; makes DataSource url optional; refactors auth type generation to be Prisma-generator- and TypeDef-aware; adjusts enhancer imports/Prisma-version gating; updates Zod generation and enum handling; and adds related regression and integration tests.

Changes

Cohort / File(s) Summary
Version Update
packages/ide/jetbrains/build.gradle.kts
Bumped project version from 2.21.1 to 2.22.0.
Datasource Validation
packages/schema/src/language-server/validator/datasource-validator.ts
Removed required-url error path; missing url now causes early return (treat url as optional) and added explanatory comment.
Auth Type Generation
packages/schema/src/plugins/enhancer/enhance/auth-type-generator.ts
Added Prisma client–generator awareness and isTypeDef tracking; refactored type metadata flow, introduced findType, iterates by type name, and emits type references conditionally ($TypeDefs vs _P).
Enhancer Index / Generation
packages/schema/src/plugins/enhancer/enhance/index.ts
Version-aware runtime import subpath for Prisma; conditional json-types ($TypeDefs) import when using new Prisma client generator and JSON type defs exist; refined --no-engine flag gating for Prisma versions (<7.0.0).
Zod Generator
packages/schema/src/plugins/zod/generator.ts
Removed output parameter from addPreludeAndImports and updated callers; removed emission of Prisma client enum imports; minor formatting tweak in refine output; enabled literal-enum transformation option.
Zod Utilities
packages/schema/src/plugins/zod/utils/schema-gen.ts
Added handling for enum field references in default-value generation (returns enum name as JSON string when applicable).
TypeScript Expression Transformer
packages/sdk/src/typescript-expression-transformer.ts
Added useLiteralEnum?: boolean option; when true emits enum references as JSON string literals instead of dotted enum access.
Test Dependency Pins
packages/schema/tests/generator/prisma-generator.test.ts, tests/integration/tests/cli/generate.test.ts, tests/integration/tests/cli/plugins.test.ts
Pinned prisma and @prisma/client to 6.19.x in test install/setup commands.
Datasource Validation Tests
packages/schema/tests/schema/validation/datasource-validation.test.ts
Adjusted missing-fields test expectation to only include provider cause (removed expected url error).
Auth Policy Tests
tests/integration/tests/enhancements/with-policy/auth.test.ts
Renamed legacy compile-time test and added a new compile-time test variant for the new Prisma client generator (SQLite) exercising the same policy checks.
Regression Tests
tests/regression/tests/issue-2291.test.ts, tests/regression/tests/issue-2294.test.ts
Added regression tests: enum-default handling with Zod parsing (2291) and an auth-flow test using the new Prisma client generator + SQLite (2294).
CLI Generate Runtime Check
packages/schema/src/cli/actions/generate.ts
Added Prisma version detection and emits a yellow warning if Prisma >= 7.0.0 (runtime-only check).

Sequence Diagram(s)

sequenceDiagram
    participant AuthGen as Auth Type Generator
    participant GenLookup as Prisma Generator Lookup
    participant Out as Generated Types

    AuthGen->>GenLookup: getPrismaClientGenerator(model)
    alt new Prisma client generator
        GenLookup-->>AuthGen: isNewGenerator = true
        AuthGen->>AuthGen: mark types .isTypeDef where relevant
        AuthGen->>Out: emit Partial<$TypeDefs.Type> merges and relation fields
    else legacy generator
        GenLookup-->>AuthGen: isNewGenerator = false
        AuthGen->>Out: emit Partial<_P.Type> merges and relation fields
    end
Loading
sequenceDiagram
    participant Transformer as TS Expression Transformer
    participant EnumRef as Enum Field Reference

    Transformer->>EnumRef: transform(enumReference, useLiteralEnum?)
    alt useLiteralEnum = true
        EnumRef-->>Transformer: return JSON string literal ("VALUE")
    else
        EnumRef-->>Transformer: return dotted access (Container.Name.VALUE)
    end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

  • Focus review on:
    • packages/schema/src/plugins/enhancer/enhance/auth-type-generator.ts (type metadata, isTypeDef handling, emitted type names).
    • packages/schema/src/plugins/enhancer/enhance/index.ts (Prisma-version import path, conditional $TypeDefs import, --no-engine gating).
    • Interaction between Zod generator changes, typescript-expression-transformer (useLiteralEnum), and tests validating enum/default behavior.

Possibly related PRs

Pre-merge checks and finishing touches

❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Description check ⚠️ Warning No description was provided by the author, making it impossible to evaluate whether the description relates to the changeset. Add a pull request description explaining the changes included in this merge, such as the new features, bug fixes, and improvements being released in v2.22.0.
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title 'merge dev to main (v2.22.0)' accurately describes the pull request's primary objective: merging the dev branch into main for version 2.22.0, which aligns with the version bump shown in the changeset.

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.

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 (2)
packages/schema/src/plugins/enhancer/enhance/index.ts (2)

317-338: Version-aware runtime import and $TypeDefs import look aligned; consider deduping version and TypeDef checks

The new runtimeLibraryImportSubPath logic and conditional $TypeDefs import look consistent with supporting both old/new client generators and Prisma ≥7 runtime layout. To keep this maintainable, consider:

  • Caching getPrismaVersion() once on the class (it’s now called in multiple helpers) instead of re-reading package metadata in each method.
  • Reusing the existing hasTypeDef(this.model) helper (or a single shared predicate) instead of re-deriving hasTypeDef here and again elsewhere.

Also, since the exact /runtime/client vs /runtime/library locations and $TypeDefs usage depend on Prisma’s evolving API surface, please double-check these paths and conditions against the Prisma version(s) you officially support in this release.


441-446: Updated --no-engine gating for Prisma ≥7 is sensible; revisit behavior when version is unknown

Bounding --no-engine to >= 5.2.0 && < 7.0.0 matches the intent to avoid passing a removed flag to Prisma 7+. However, the !prismaVersion branch still appends --no-engine even when the installed Prisma CLI might actually be 7+ but its version couldn’t be detected (e.g., only a global prisma is present). That could now cause avoidable failures in such environments.

It’s worth considering:

  • Treating “unknown version” as “don’t add --no-engine” (safer default), or
  • At least logging/warning when prismaVersion is falsy before appending the flag.

Please confirm the current Prisma CLI behavior for --no-engine across your supported versions to ensure this condition matches reality.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between fb0aa0f and bfa40c1.

📒 Files selected for processing (1)
  • packages/schema/src/plugins/enhancer/enhance/index.ts (2 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
packages/schema/src/plugins/enhancer/enhance/index.ts (1)
packages/sdk/src/prisma.ts (1)
  • getPrismaVersion (60-79)
⏰ 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). (4)
  • GitHub Check: build-test (20.x)
  • GitHub Check: dependency-review
  • GitHub Check: build-test (20.x)
  • GitHub Check: build-test (20.x)

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/schema/src/cli/actions/generate.ts (1)

53-56: Tighten Prisma 7+ detection and make the warning more informative

The warning is useful, but you might want to (a) also catch 7.x pre‑releases and (b) be defensive against odd version strings while including the actual version in the message.

A small refinement could look like:

-    const prismaVersion = getPrismaVersion();
-    if (prismaVersion && semver.gte(prismaVersion, '7.0.0')) {
-        console.warn(colors.yellow('Prisma 7 support is untested and not planned. Use with caution.'));
-    }
+    const prismaVersion = getPrismaVersion();
+    const coerced = prismaVersion && semver.coerce(prismaVersion);
+    if (coerced && semver.major(coerced) >= 7) {
+        console.warn(
+            colors.yellow(
+                `Prisma ${prismaVersion} detected. Prisma 7 support is untested and not planned. Use with caution.`
+            )
+        );
+    }

This way:

  • Non‑standard but coercible versions don’t crash semver.
  • Any 7.x (including pre‑releases) triggers the warning.
  • Users see exactly which Prisma version was detected.
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between bfa40c1 and a78f5a7.

📒 Files selected for processing (1)
  • packages/schema/src/cli/actions/generate.ts (2 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
packages/schema/src/cli/actions/generate.ts (1)
packages/sdk/src/prisma.ts (1)
  • getPrismaVersion (60-79)
⏰ 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). (4)
  • GitHub Check: build-test (20.x)
  • GitHub Check: build-test (20.x)
  • GitHub Check: build-test (20.x)
  • GitHub Check: dependency-review
🔇 Additional comments (1)
packages/schema/src/cli/actions/generate.ts (1)

3-6: Imports for Prisma version awareness look good

Bringing in getPrismaVersion and semver at the CLI layer aligns with the new runtime guard and keeps the rest of the flow unchanged. No issues here.

@ymc9 ymc9 merged commit b53b1cb into main Nov 25, 2025
9 of 10 checks passed
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.

3 participants