-
-
Notifications
You must be signed in to change notification settings - Fork 102
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
Update Zod Generator - Fix Enum Imports #2069
Conversation
Enum exports from `models` are just types. Accordinlgy, enum imports must also be types only. This fixed issues for generated models with pnpm monorepo.
📝 WalkthroughWalkthroughThe PR updates the Changes
Possibly related PRs
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🔇 Additional comments (1)
✨ Finishing Touches
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. 🪧 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 using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
Hi @adnanalbeda , thank you for making this PR! Coincidentally, a related issue was filed for the same issue as well #2065. I think the problem is that enums need to be reexported from ".zenstack/models" as values too (instead of just as types), otherwise at runtime, accessing enum values will still fail even if typescript compilation succeeds. I've made a separate PR to let ".zenstack/models" reexport all values from the original PrismaClient model (while keeping "models.d.ts" reexport ZenStack-modified Prisma types). I think it should be more robust than fixing the enum imports. |
Great, I tested your changes and it's working better than mine. |
Thanks for confirming it! I'll merge and make a patch release today. |
#2070 fixed the issue by supporting referencing |
Since zod generated
models
file are all just types. Soenum
exports frommodels
are also types only.Accordinlgy, enum imports must also be types only.
This fixed issues for generated models when working with
workspaces
of pnpm monorepo andNextJS
.