Skip to content

Conversation

@jiashengguo
Copy link
Member

@jiashengguo jiashengguo commented Feb 2, 2026

Summary by CodeRabbit

  • Chores

    • Version updated to 0.3.0
  • New Features

    • Runtime module loading improved to support a broader set of enhancement types and dynamic loading paths.
    • Server middleware now applies configurable data-enhancements (e.g., password/encryption/validation-related behaviors) to the runtime database client, improving runtime capabilities and error messaging.

Copilot AI review requested due to automatic review settings February 2, 2026 09:16
@coderabbitai
Copy link

coderabbitai bot commented Feb 2, 2026

📝 Walkthrough

Walkthrough

Bumps package version to 0.3.0 and refactors server loading to add EnhancementKind and an enhanceFunc, dynamically loading enhancement logic from ZenStack runtime or path and applying enhancements when returning Prisma clients.

Changes

Cohort / File(s) Summary
Version Bump
package.json
Package version updated from 0.2.7 to 0.3.0. No other manifest or dependency changes.
Server enhancement integration
src/server.ts
Adds EnhancementKind and Enhancements list; introduces enhanceFunc and loads it from ZenStack runtime or provided path; loadZenStackModules now returns enhanceFunc; startServer and ZenStackMiddleware use enhanceFunc to return an enhanced Prisma client; updates error messages and logging for loading paths.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 I found a function, tucked neat in a stack,
I hopped it on Prisma and gave it a snack.
Enhancements assembled — a crunchy delight,
Version bumped onward into the night. ✨

🚥 Pre-merge checks | ✅ 3
✅ 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 clearly and specifically describes the main change: introducing enhanced Prisma client support for Polymorphism functionality, which aligns with the core modifications in src/server.ts.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

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

✨ 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 jiasheng-dev

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

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds support for Prisma polymorphism by integrating ZenStack's enhance function to apply various enhancements (password, omit, validation, delegate, encryption) to the Prisma client. The version is bumped from 0.2.7 to 0.3.0 to reflect this new feature.

Changes:

  • Added EnhancementKind type definition to specify available enhancement types
  • Modified loadZenStackModules to load the enhance function from ZenStack runtime or generated output
  • Updated getPrisma callback in ZenStackMiddleware to apply enhancements (excluding policy) to the Prisma client on each request
  • Version bumped to 0.3.0 reflecting the feature addition

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.

File Description
package.json Version bump from 0.2.7 to 0.3.0 for the new polymorphism feature
src/server.ts Added EnhancementKind type, loaded enhance function, and applied enhancements to Prisma client in middleware

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link

@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

🤖 Fix all issues with AI agents
In `@src/server.ts`:
- Around line 182-195: The try/catch should report failures for both model meta
and enhance module loading and validate the enhance export is a function: update
the error message in the catch around the require calls (symbols:
zenstackAbsPath, modelMeta, enhanceFunc, path.join, require, CliError) to
mention both model-meta and enhance loading, and after assigning enhanceFunc
(for both the zenstackAbsPath and fallback branches) add a runtime check that
typeof enhanceFunc === 'function' and throw a CliError with a clear message if
not; apply the same validation for the second occurrence referenced (enhanceFunc
usage near the later block).

@jiashengguo jiashengguo merged commit de8e516 into dev Feb 3, 2026
3 checks passed
@jiashengguo jiashengguo deleted the jiasheng-dev branch February 3, 2026 00:27
jiashengguo added a commit that referenced this pull request Feb 3, 2026
feat: use enhanced prisma to support Polymorphism (#28)
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.

2 participants