-
-
Notifications
You must be signed in to change notification settings - Fork 0
feat: use enhanced prisma to support Polymorphism #28
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
Conversation
📝 WalkthroughWalkthroughBumps 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
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
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. Comment |
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.
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
EnhancementKindtype definition to specify available enhancement types - Modified
loadZenStackModulesto load theenhancefunction from ZenStack runtime or generated output - Updated
getPrismacallback 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.
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
🤖 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).
feat: use enhanced prisma to support Polymorphism (#28)
Summary by CodeRabbit
Chores
New Features