chrishoermann / zod-prisma-types

Generator creates zod types for your prisma models with advanced validation
Other
579 stars 43 forks source link

Enums are stored in inputTypeSchemas even if generation of input types is disabled #164

Closed CyanoFresh closed 8 months ago

CyanoFresh commented 11 months ago

Hi! I have such prisma config:

generator zod {
  provider                 = "zod-prisma-types"
  output                   = "../schema/src/prisma-generated"
  useMultipleFiles         = true
  writeBarrelFiels         = false
  createInputTypes         = false
  addIncludeType           = false
  addSelectType            = false
  writeNullishInModelTypes = true
}

but enums are generated inside inputTypeSchemas folder anyway:

import { z } from 'zod';

export const AssignmentTypeSchema = z.enum(['GROUPS','TEAMS','LOB','OTHER']);

export type AssignmentTypeType = `${z.infer<typeof AssignmentTypeSchema>}`

export default AssignmentTypeSchema;

Can we add an option to generate "in-place" enums and other types that are stored now in inputTypeSchemas folder?

chrishoermann commented 8 months ago

@CyanoFresh thanks for reaching out. I located the enums in the inputTypeFolder because otherwise in useMultipleFile mode imports would have been a real pain to get working - this would also be the case with in-place enums. So sadly this is not an option I'm currently considering.