MCPcopy
hub / github.com/prisma/prisma / toTS

Method toTS

packages/client-generator-js/src/TSClient/Count.ts:38–76  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

36 return argsTypes
37 }
38 public toTS(): string {
39 const { type } = this
40 const { name } = type
41 const outputType = buildOutputType(type)
42
43 return `
44/**
45 * Count Type ${name}
46 */
47
48${ts.stringify(outputType)}
49
50export type ${getSelectName(name)}<ExtArgs extends $Extensions.InternalArgs = $Extensions.DefaultArgs> = {
51${indent(
52 type.fields
53 .map((field) => {
54 const types = ['boolean']
55 if (field.outputType.location === 'outputObjectTypes') {
56 types.push(getFieldArgName(field, this.type.name))
57 }
58
59 // TODO: what should happen if both args and output types are present?
60 // Right new, they both will be part of the union, but is it correct?
61
62 if (field.args.length > 0) {
63 types.push(getCountArgsType(name, field.name))
64 }
65
66 return `${field.name}?: ${types.join(' | ')}`
67 })
68 .join('\n'),
69 TAB_SIZE,
70)}
71}
72
73// Custom InputTypes
74${this.argsTypes.map((typeExport) => ts.stringify(typeExport)).join('\n\n')}
75`
76 }
77}
78
79function getCountArgsType(typeName: string, fieldName: string) {

Callers

nothing calls this directly

Calls 5

buildOutputTypeFunction · 0.90
getSelectNameFunction · 0.90
getFieldArgNameFunction · 0.90
getCountArgsTypeFunction · 0.70
pushMethod · 0.45

Tested by

no test coverage detected