@@ -26,7 +26,11 @@ export async function generate(model: Model, options: PluginOptions, dmmf: DMMF.
2626    const  outputObjectTypes  =  prismaClientDmmf . schema . outputObjectTypes . prisma ; 
2727    const  models : DMMF . Model [ ]  =  prismaClientDmmf . datamodel . models ; 
2828
29-     await  generateEnumSchemas ( prismaClientDmmf . schema . enumTypes . prisma ,  prismaClientDmmf . schema . enumTypes . model  ??  [ ] ) ; 
29+     await  generateEnumSchemas ( 
30+         prismaClientDmmf . schema . enumTypes . prisma , 
31+         prismaClientDmmf . schema . enumTypes . model  ??  [ ] , 
32+         model 
33+     ) ; 
3034
3135    const  dataSource  =  model . declarations . find ( ( d ) : d  is DataSource  =>  isDataSource ( d ) ) ; 
3236
@@ -43,8 +47,8 @@ export async function generate(model: Model, options: PluginOptions, dmmf: DMMF.
4347
4448    const  aggregateOperationSupport  =  resolveAggregateOperationSupport ( inputObjectTypes ) ; 
4549
46-     await  generateObjectSchemas ( inputObjectTypes ,  output ) ; 
47-     await  generateModelSchemas ( models ,  modelOperations ,  aggregateOperationSupport ) ; 
50+     await  generateObjectSchemas ( inputObjectTypes ,  output ,   model ) ; 
51+     await  generateModelSchemas ( models ,  modelOperations ,  aggregateOperationSupport ,   model ) ; 
4852} 
4953
5054async  function  handleGeneratorOutputValue ( output : string )  { 
@@ -56,22 +60,27 @@ async function handleGeneratorOutputValue(output: string) {
5660    Transformer . setOutputPath ( output ) ; 
5761} 
5862
59- async  function  generateEnumSchemas ( prismaSchemaEnum : DMMF . SchemaEnum [ ] ,  modelSchemaEnum : DMMF . SchemaEnum [ ] )  { 
63+ async  function  generateEnumSchemas ( 
64+     prismaSchemaEnum : DMMF . SchemaEnum [ ] , 
65+     modelSchemaEnum : DMMF . SchemaEnum [ ] , 
66+     zmodel : Model 
67+ )  { 
6068    const  enumTypes  =  [ ...prismaSchemaEnum ,  ...modelSchemaEnum ] ; 
6169    const  enumNames  =  enumTypes . map ( ( enumItem )  =>  enumItem . name ) ; 
6270    Transformer . enumNames  =  enumNames  ??  [ ] ; 
6371    const  transformer  =  new  Transformer ( { 
6472        enumTypes, 
73+         zmodel, 
6574    } ) ; 
6675    await  transformer . generateEnumSchemas ( ) ; 
6776} 
6877
69- async  function  generateObjectSchemas ( inputObjectTypes : DMMF . InputType [ ] ,  output : string )  { 
78+ async  function  generateObjectSchemas ( inputObjectTypes : DMMF . InputType [ ] ,  output : string ,   zmodel :  Model )  { 
7079    const  moduleNames : string [ ]  =  [ ] ; 
7180    for  ( let  i  =  0 ;  i  <  inputObjectTypes . length ;  i  +=  1 )  { 
7281        const  fields  =  inputObjectTypes [ i ] ?. fields ; 
7382        const  name  =  inputObjectTypes [ i ] ?. name ; 
74-         const  transformer  =  new  Transformer ( {  name,  fields } ) ; 
83+         const  transformer  =  new  Transformer ( {  name,  fields,  zmodel  } ) ; 
7584        const  moduleName  =  await  transformer . generateObjectSchema ( ) ; 
7685        moduleNames . push ( moduleName ) ; 
7786    } 
@@ -84,12 +93,14 @@ async function generateObjectSchemas(inputObjectTypes: DMMF.InputType[], output:
8493async  function  generateModelSchemas ( 
8594    models : DMMF . Model [ ] , 
8695    modelOperations : DMMF . ModelMapping [ ] , 
87-     aggregateOperationSupport : AggregateOperationSupport 
96+     aggregateOperationSupport : AggregateOperationSupport , 
97+     zmodel : Model 
8898)  { 
8999    const  transformer  =  new  Transformer ( { 
90100        models, 
91101        modelOperations, 
92102        aggregateOperationSupport, 
103+         zmodel, 
93104    } ) ; 
94105    await  transformer . generateModelSchemas ( ) ; 
95106} 
0 commit comments