| 4 | import { Generable } from class="st">'./Generable' |
| 5 | |
| 6 | export class ModelFieldRefs implements Generable { |
| 7 | constructor(protected outputType: DMMF.OutputType) {} |
| 8 | toTS() { |
| 9 | const { name } = this.outputType |
| 10 | return ` |
| 11 | |
| 12 | /** |
| 13 | * Fields of the ${name} model |
| 14 | */ |
| 15 | interface ${getFieldRefsTypeName(name)} { |
| 16 | ${this.stringifyFields()} |
| 17 | } |
| 18 | ` |
| 19 | } |
| 20 | |
| 21 | private stringifyFields() { |
| 22 | const { name } = this.outputType |
| 23 | return this.outputType.fields |
| 24 | .filter((field) => field.outputType.location !== class="st">'outputObjectTypes') |
| 25 | .map((field) => { |
| 26 | const fieldOutput = field.outputType |
| 27 | const refTypeName = getRefAllowedTypeName(fieldOutput) |
| 28 | return ` readonly ${field.name}: FieldRef<class="st">"${name}", ${refTypeName}>` |
| 29 | }) |
| 30 | .join(class="st">'\n') |
| 31 | } |
| 32 | } |
nothing calls this directly
no outgoing calls
no test coverage detected