File tree Expand file tree Collapse file tree 2 files changed +16
-4
lines changed
Expand file tree Collapse file tree 2 files changed +16
-4
lines changed Original file line number Diff line number Diff line change @@ -66,7 +66,9 @@ const configSchema = Type.Object(
6666 *
6767 * E.g. Date will be of Type String when enabled.
6868 */
69- useJsonTypes : Type . Boolean ( { default : false } ) ,
69+ useJsonTypes : Type . Union ( [ Type . Boolean ( ) , Type . Literal ( "transformer" ) ] , {
70+ default : false ,
71+ } ) ,
7072 /**
7173 * What file extension, if any, to add to src file imports. Set to ".js" to support nodenext module resolution
7274 */
@@ -76,7 +78,7 @@ const configSchema = Type.Object(
7678 */
7779 exportedTypePrefix : Type . String ( { default : "" } ) ,
7880 } ,
79- { additionalProperties : false } ,
81+ { additionalProperties : false }
8082) ;
8183
8284// biome-ignore lint/suspicious/noExplicitAny: we want to set the default value
Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ const PrimitiveFields = [
1515export type PrimitivePrismaFieldType = ( typeof PrimitiveFields ) [ number ] ;
1616
1717export function isPrimitivePrismaFieldType (
18- str : string ,
18+ str : string
1919) : str is PrimitivePrismaFieldType {
2020 // biome-ignore lint/suspicious/noExplicitAny: we want to check if the string is a valid primitive field
2121 return PrimitiveFields . includes ( str as any ) ;
@@ -42,10 +42,20 @@ export function stringifyPrimitiveType({
4242
4343 if ( [ "DateTime" ] . includes ( fieldType ) ) {
4444 const config = getConfig ( ) ;
45- if ( config . useJsonTypes ) {
45+ if ( config . useJsonTypes === "transformer" ) {
4646 return `${ getConfig ( ) . transformDateName } (${ options } )` ;
4747 }
4848
49+ if ( config . useJsonTypes ) {
50+ let opts = options ;
51+ if ( opts . includes ( "{" ) && opts . includes ( "}" ) ) {
52+ opts = opts . replace ( "{" , "{ format: 'date-time', " ) ;
53+ } else {
54+ opts = `{ format: 'date-time' }` ;
55+ }
56+ return `${ config . typeboxImportVariableName } .String(${ opts } )` ;
57+ }
58+
4959 return `${ getConfig ( ) . typeboxImportVariableName } .Date(${ options } )` ;
5060 }
5161
You can’t perform that action at this time.
0 commit comments