prisma-typebox-generator
prisma-typebox-generator copied to clipboard
Configuration for type suffixes and prettier config + other breaking changes
Type suffix is now configurable, but omitted by default
This fixes #11 by omitting the typeSuffix in outputted code by default which is a breaking change.
If a type suffix is still desired it can now be configured in the schema.prisma file as follows:
generator typebox {
provider = "prisma-typebox-generator"
typeSuffix = "Type"
}
Customize code style of outputted code by specifying a prettier config
This PR adds a configuration option letting you link to a prettier config as follows:
generator typebox {
provider = "prisma-typebox-generator"
prettierConfig = "<path-to-config-file>"
}
This allows users to more easily make the generated code match the code style of their codebase. Under the hood this feature uses c12, which allows us to support json, typescript, and javascript configuration files. (The c12 library was created by the nuxtjs and unjs team so I think it's safe to add it as a dependency as it's very likely to remain well maintained.)
Automatically add the $id property to generated models.
Given the following prisma schema
model User {
id String @id @default(uuid())
name String
}
The generator will now output
export const User = Type.Object(
{
id: Type.String(),
name: Type.String(),
},
{ $id: 'User' } // note this line
)
I'm on the fence as to whether this should be the default behavior or whether this is something that should be toggleable through the configuration in the schema.prisma. I guess regardless it would be good to have it be configurable somehow. If we do add another configuration field I wonder what we should call it...
Dependency Updates and Other Changes
- replace yarn with pnpm
- remove deprecated
@prisma/sdkdependency and replace it with@prisma/internals - update
@prisma/generator-helperto v5.2.0 - update
core-jsto v3.32.1 - update
prettierto v3.0.3 - add
c12as a dependency to supportjson,ts, andjsprettier config files - update all dev dependencies
@adeyahya I know there's alot here so lemme know if anything needs to be reverted or changed.
For example I imagine the yarn > pnpm change might break some CI stuff along with potentially the @semantic-release updates