@@ -26,7 +26,11 @@ export async function generate(model: Model, options: PluginOptions, dmmf: DMMF.
26
26
const outputObjectTypes = prismaClientDmmf . schema . outputObjectTypes . prisma ;
27
27
const models : DMMF . Model [ ] = prismaClientDmmf . datamodel . models ;
28
28
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
+ ) ;
30
34
31
35
const dataSource = model . declarations . find ( ( d ) : d is DataSource => isDataSource ( d ) ) ;
32
36
@@ -43,8 +47,8 @@ export async function generate(model: Model, options: PluginOptions, dmmf: DMMF.
43
47
44
48
const aggregateOperationSupport = resolveAggregateOperationSupport ( inputObjectTypes ) ;
45
49
46
- await generateObjectSchemas ( inputObjectTypes , output ) ;
47
- await generateModelSchemas ( models , modelOperations , aggregateOperationSupport ) ;
50
+ await generateObjectSchemas ( inputObjectTypes , output , model ) ;
51
+ await generateModelSchemas ( models , modelOperations , aggregateOperationSupport , model ) ;
48
52
}
49
53
50
54
async function handleGeneratorOutputValue ( output : string ) {
@@ -56,22 +60,27 @@ async function handleGeneratorOutputValue(output: string) {
56
60
Transformer . setOutputPath ( output ) ;
57
61
}
58
62
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
+ ) {
60
68
const enumTypes = [ ...prismaSchemaEnum , ...modelSchemaEnum ] ;
61
69
const enumNames = enumTypes . map ( ( enumItem ) => enumItem . name ) ;
62
70
Transformer . enumNames = enumNames ?? [ ] ;
63
71
const transformer = new Transformer ( {
64
72
enumTypes,
73
+ zmodel,
65
74
} ) ;
66
75
await transformer . generateEnumSchemas ( ) ;
67
76
}
68
77
69
- async function generateObjectSchemas ( inputObjectTypes : DMMF . InputType [ ] , output : string ) {
78
+ async function generateObjectSchemas ( inputObjectTypes : DMMF . InputType [ ] , output : string , zmodel : Model ) {
70
79
const moduleNames : string [ ] = [ ] ;
71
80
for ( let i = 0 ; i < inputObjectTypes . length ; i += 1 ) {
72
81
const fields = inputObjectTypes [ i ] ?. fields ;
73
82
const name = inputObjectTypes [ i ] ?. name ;
74
- const transformer = new Transformer ( { name, fields } ) ;
83
+ const transformer = new Transformer ( { name, fields, zmodel } ) ;
75
84
const moduleName = await transformer . generateObjectSchema ( ) ;
76
85
moduleNames . push ( moduleName ) ;
77
86
}
@@ -84,12 +93,14 @@ async function generateObjectSchemas(inputObjectTypes: DMMF.InputType[], output:
84
93
async function generateModelSchemas (
85
94
models : DMMF . Model [ ] ,
86
95
modelOperations : DMMF . ModelMapping [ ] ,
87
- aggregateOperationSupport : AggregateOperationSupport
96
+ aggregateOperationSupport : AggregateOperationSupport ,
97
+ zmodel : Model
88
98
) {
89
99
const transformer = new Transformer ( {
90
100
models,
91
101
modelOperations,
92
102
aggregateOperationSupport,
103
+ zmodel,
93
104
} ) ;
94
105
await transformer . generateModelSchemas ( ) ;
95
106
}
0 commit comments