TonyGravagno / mysql-zod

Fork of erwinstone Generate Zod interfaces from MySQL database
MIT License
0 stars 0 forks source link

Improve prefix and suffix options #11

Open TonyGravagno opened 1 year ago

TonyGravagno commented 1 year ago

The 'suffix' option only applies to the filename. The new 'modify' option applies to both the filename and the schema const.

Enhance this to be more specific : A third array value in modify can specify how the modifications are applied :

- Add an enum with modification types : file, schema, type
- The third array value will be an array with any of those values. Examples:


["/address/", "_Address", [ 'schema' , 'type' ] ]
export const userAddress // undescore removed in camelCasing
export type userAddressType
filename remains useraddress.ts

["^log(.$)", "schema_$1_log", [ 'file' ] ]
export const logaudits
export type logauditsType
filename schema_audits_log.ts

["/address/", "_Address", [ 'schema' , 'type' ] ]
["^", "schema_", [ 'file' ] ]
["$", "Schema", [ 'schema' ] ]
["$", "ZodType", [ 'type' ] ]
export const userAddressSchema
export type userAddressZodType
filename schema_useraddress.ts // preference, don't capitalize for Linux

Going forward this can be used as an alternative/replacement for the suffix option. It also eliminates the hardcoded `${typeName}Type`.