-
-
Notifications
You must be signed in to change notification settings - Fork 127
Closed
Labels
Description
Description and expected behavior
Generate Zod with default value Enum uses @prisma/client import instead of local enums file.
For instance, if we'll try to npx zenstack generate the following schema.zmodel:
// This is a sample model to get you started.
/// A sample data source using local sqlite db.
datasource db {
provider = 'sqlite'
url = 'file:./dev.db'
}
generator client {
provider = "prisma-client-js"
}
plugin zod {
provider = '@core/zod'
output = './generated/zenstack/zod'
modelOnly = true
compile = false
}
enum SomeEnum {
Ex1
Ex2
}
/// Post model
model Post {
id String @id @default(cuid())
e SomeEnum @default(Ex1)
}it would create the following file generated/zenstack/zod/models/Post.schema.ts
and inside there would be:
import { z } from 'zod/v3';
import { SomeEnum } from '@prisma/client';
import { SomeEnumSchema } from '../enums/SomeEnum.schema';As you can see, it uses @prisma/client (sometimes also zenstackhq import) instead of reuse local files, or even not using it at all because SomeEnum is actually never used, so no need to import it.
Another big issue is that because I export this generated file to a different repo as part of my micro services implementation i don't have prisma/client.
config:
"devDependencies": {
"prisma": "6.18.x",
"typescript": "^5.9.3",
"zenstack": "2.21.0"
},
"dependencies": {
"@prisma/client": "6.18.x",
"@zenstackhq/runtime": "2.21.0",
"@zenstackhq/tanstack-query": "^2.21.0",
"zod": "^4.1.12"
}