-
-
Notifications
You must be signed in to change notification settings - Fork 126
feat(nestjs): Add prop as optional parameter of getEnhancedPrisma #1537 #1538
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
WalkthroughWalkthroughThe recent updates to the Changes
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
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 as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
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: 0
Outside diff range and nitpick comments (1)
packages/server/src/nestjs/zenstack.module.ts (1)
Line range hint
53-98: Consider refactoring to avoid static-only class structure.The static analysis tool has flagged the
ZenStackModuleas a class that only contains static members, which is generally discouraged as it can limit testing and flexibility.Consider converting the static methods to top-level functions if feasible, or introducing instance methods or properties to justify the use of a class structure.
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (2)
- packages/server/src/nestjs/zenstack.module.ts (2 hunks)
- packages/server/tests/adapter/nestjs.test.ts (1 hunks)
Files skipped from review due to trivial changes (1)
- packages/server/tests/adapter/nestjs.test.ts
Additional context used
Biome
packages/server/src/nestjs/zenstack.module.ts
[error] 53-98: Avoid classes that contain only static members.
Prefer using simple functions instead of classes with only static members.
(lint/complexity/noStaticOnlyClass)
Additional comments not posted (2)
packages/server/src/nestjs/zenstack.module.ts (2)
15-15: Update toZenStackModuleOptionsinterface approved.The addition of the optional parameter
proptogetEnhancedPrismamethod aligns with the PR objectives and enhances flexibility in the usage of the method.
82-82: Correct implementation of dynamic property handling ingetEnhancedPrisma.The implementation correctly uses the
propparameter to enhance the Prisma client dynamically. This should allow for more flexible and powerful usage scenarios.
|
Hmm, I'm not sure why those regressions are failing. I didn't touch anything related to the generated enhance file. |
| * A callback for getting an enhanced `PrismaClient`. | ||
| */ | ||
| getEnhancedPrisma: () => unknown; | ||
| getEnhancedPrisma: (prop?: string | symbol) => unknown; |
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.
Shall we rename prop to model instead so it's meaning is clearer? Also, I think in this case it's always typed as string. Maybe remove the | symbol part so the user can have a simpler callback signature?
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.
Sounds good, I'll update this in this tomorrow and push it.
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.
Thank you!
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.
So it looks like not including symbol causes a type error.
Error: packages/server build: src/nestjs/zenstack.module.ts(82,83): error TS2345: Argument of type 'string | symbol' is not assignable to parameter of type 'string | undefined'.
https://github.com/zenstackhq/zenstack/actions/runs/9877836393/job/27280399900?pr=1538
This is likely because the prop from Proxy is typed as string | symbol, which is why I think I had set that earlier. I'll revert that change for now.
|
Hi @jasonmacdonald , thanks for implementing this FR. The change looks good to me, and I've left a comment about the callback signature. Could you take a look? I think the test failure is due to the current test scaffolding not pinning Prisma dependencies to their minor versions. Prisma 5.16 introduced a breaking change. I've made a fix to the dev branch. Could you merge it to your branch and push again? The errors should go awai then. |
|
@ymc9 I pushed the requested update. Sorry for the delay. |
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: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (1)
- packages/server/src/nestjs/zenstack.module.ts (2 hunks)
Additional comments not posted (2)
packages/server/src/nestjs/zenstack.module.ts (2)
15-15: LGTM! The optional parameter addition is well-implemented.This update makes the
modelparameter optional, providing flexibility while maintaining backward compatibility.
82-82: LGTM! The optional parameter is correctly integrated.The
getEnhancedPrismamethod is called with thepropargument, ensuring the optional parameter is passed correctly.
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: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (1)
- packages/server/src/nestjs/zenstack.module.ts (2 hunks)
Files skipped from review as they are similar to previous changes (1)
- packages/server/src/nestjs/zenstack.module.ts
Support for receiving the property used to trigger getEnhancedPrisma for the NestJS module. This is in relation to feature request #1537