@paljs/generator
Advanced tools
Comparing version 7.0.1 to 7.0.2
@@ -144,2 +144,3 @@ import { GeneratorOptions, DMMF } from '@paljs/types'; | ||
isModel(modelName: string): boolean; | ||
getParentType(name: string): string; | ||
capital(name: string): string; | ||
@@ -146,0 +147,0 @@ getOutputType(options: DMMF.SchemaField['outputType'] | DMMF.InputTypeRef, input?: boolean): string; |
@@ -41,2 +41,18 @@ "use strict"; | ||
} | ||
getParentType(name) { | ||
if (['Query', 'Mutation'].includes(name)) { | ||
return '{}'; | ||
} | ||
if (name === 'AffectedRowsOutput') { | ||
return 'Client.Prisma.BatchPayload'; | ||
} | ||
if (this.isModel(name)) { | ||
return `Client.${name}`; | ||
} | ||
if (name.startsWith('CreateMany') && name.endsWith('AndReturnOutputType')) { | ||
const innerType = name.replace(/^CreateMany|AndReturnOutputType$/g, ''); | ||
return `ReturnType<Client.Prisma.${innerType}Delegate["createManyAndReturn"]>`; | ||
} | ||
return `Client.Prisma.${name}`; | ||
} | ||
capital(name) { | ||
@@ -53,2 +69,6 @@ return name.charAt(0).toUpperCase() + name.slice(1); | ||
} | ||
if (options.type.startsWith('CreateMany') && options.type.endsWith('AndReturnOutputType')) { | ||
const innerType = options.type.replace(/^CreateMany|AndReturnOutputType$/g, ''); | ||
return `ReturnType<Client.Prisma.${innerType}Delegate["createManyAndReturn"]>`; | ||
} | ||
const type = options.type.toString() === 'AffectedRowsOutput' | ||
@@ -97,9 +117,3 @@ ? 'Prisma.BatchPayload' | ||
type.fields.forEach((field) => { | ||
const parentType = ['Query', 'Mutation'].includes(type.name) | ||
? '{}' | ||
: `Client.${type.name === 'AffectedRowsOutput' | ||
? 'Prisma.BatchPayload' | ||
: !this.isModel(type.name) | ||
? 'Prisma.' + type.name | ||
: type.name}`; | ||
const parentType = this.getParentType(type.name); | ||
const argsType = field.args.length > 0 | ||
@@ -106,0 +120,0 @@ ? `${['Query', 'Mutation'].includes(type.name) ? '' : type.name}${this.capital(field.name)}Args` |
{ | ||
"name": "@paljs/generator", | ||
"version": "7.0.1", | ||
"version": "7.0.2", | ||
"main": "dist/index.js", | ||
@@ -19,5 +19,5 @@ "types": "dist/index.d.ts", | ||
"prettier": "^2.8.8", | ||
"@paljs/types": "7.0.1", | ||
"@paljs/schema": "7.0.1", | ||
"@paljs/utils": "7.0.1" | ||
"@paljs/types": "7.0.2", | ||
"@paljs/utils": "7.0.2", | ||
"@paljs/schema": "7.0.2" | ||
}, | ||
@@ -24,0 +24,0 @@ "devDependencies": { |
Sorry, the diff of this file is not supported yet
170580
2345
+ Added@paljs/display@7.0.2(transitive)
+ Added@paljs/schema@7.0.2(transitive)
+ Added@paljs/types@7.0.2(transitive)
+ Added@paljs/utils@7.0.2(transitive)
- Removed@paljs/display@7.0.1(transitive)
- Removed@paljs/schema@7.0.1(transitive)
- Removed@paljs/types@7.0.1(transitive)
- Removed@paljs/utils@7.0.1(transitive)
Updated@paljs/schema@7.0.2
Updated@paljs/types@7.0.2
Updated@paljs/utils@7.0.2