chrishoermann / zod-prisma-types

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

Export types along with schemas in inputTypeSchemas/index.ts barrel file #249

Open canadaduane opened 1 month ago

canadaduane commented 1 month ago

Is your feature request related to a problem? Please describe.

The barrel file that exports input type schemas does not also export types. For example:

// ...
export { PlanSchema } from './PlanSchema';
export { GradeLevelSchema } from './GradeLevelSchema';
export { InputTypeSchema } from './InputTypeSchema';
export { InputRoleSchema } from './InputRoleSchema';
// ...

Describe the solution you'd like Currently, each inputTypeSchema file also exports its type, e.g.

import { z } from 'zod';

export const PlanSchema = z.enum(['FREE','PRO']);

export type PlanType = `${z.infer<typeof PlanSchema>}`

export default PlanSchema;

I'd like the barrel file to additionally export the type that corresponds with the schema, e.g.

// ...
export { PlanSchema, type PlanType } from './PlanSchema';
export { GradeLevelSchema, type GradeLevelType } from './GradeLevelSchema';
export { InputTypeSchema, type InputTypeType } from './InputTypeSchema';
export { InputRoleSchema, type InputRoleType } from './InputRoleSchema';
// ...

Describe alternatives you've considered

I could also mention each generated file in the package.json file that exports these schemas, but then I would need to autogenerate the package.json file as well.

Additional context Our polyrepo contains many packages, one of which is the "database" package that exports the prisma client and these additional zod-prisma-types generated schemas and types.