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

Method toTS

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

Source from the content-addressed store, hash-verified

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