You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
enum FooType {
Bar
Baz
}
// Add JSON type field so a logical prisma client is generated.
// Polymorphic models also trigger this bug
type Meta {
test String?
}
model Foo {
id String @id @db.Uuid @default(uuid())
type FooType
meta Meta @json
@@validate(type == Bar, "FooType must be Bar")
}
Screenshots
The generated Zod Schema file for Foo then contains an invalid import. .zenstack/models is a .d.ts file and contains no value exports.
Environment (please complete the following information):
ZenStack version: 2.13.0
Prisma version: 6.5.0
Database type: Postgresql
Additional context
This bug doesn't occur when a logical client isn't generated. I believe the issue lies somewhere in this code, It doesn't really make sense to me that prismaClientPath is being mapped to a definitions file?
The text was updated successfully, but these errors were encountered:
diesal11
changed the title
Zod Schemas contain invalid import to logical Prisma Client, when @@validate rule references an enum
Zod Schema contains invalid import to logical Prisma Client, when @@validate rule references an enum
Apr 3, 2025
Hey @diesal11 , I had a look into it, you're right the problem is "./zenstack/models" currently only exports types. However, to import enums, values should be exported there as well.
I think a simple fix would be to generate a "models.js" file which reexports the original prisma client module. The "/models" will behave in a "strange" way that its types correspond to logical schema, however values come from the original schema. But that's how it should work ...
Description and expected behavior
Schema:
Screenshots
The generated Zod Schema file for
Foo
then contains an invalid import..zenstack/models
is a.d.ts
file and contains no value exports.Environment (please complete the following information):
Additional context
This bug doesn't occur when a logical client isn't generated. I believe the issue lies somewhere in this code, It doesn't really make sense to me that
prismaClientPath
is being mapped to a definitions file?zenstack/packages/schema/src/plugins/enhancer/index.ts
Lines 29 to 45 in 8a62f63
The text was updated successfully, but these errors were encountered: