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

Method toTS

packages/client-generator-ts/src/TSClient/Model.ts:371–478  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

369 }
370
371 public toTS(): string {
372 const { model } = this
373 const isComposite = this.dmmf.isComposite(model.name)
374
375 const omitType = ts.stringify(
376 buildOmitType({ modelName: this.model.name, context: this.context, fields: this.type.fields }),
377 {
378 newLine: 'leading',
379 },
380 )
381
382 const hasRelationField = model.fields.some((f) => f.kind === 'object')
383 const includeType = hasRelationField
384 ? ts.stringify(
385 buildIncludeType({ modelName: this.model.name, context: this.context, fields: this.type.fields }),
386 {
387 newLine: 'leading',
388 },
389 )
390 : ''
391
392 const createManyAndReturnIncludeType =
393 hasRelationField && this.createManyAndReturnType
394 ? ts.stringify(
395 buildIncludeType({
396 typeName: getIncludeCreateManyAndReturnName(this.model.name),
397 modelName: this.model.name,
398 context: this.context,
399 fields: this.createManyAndReturnType.fields,
400 }),
401 {
402 newLine: 'leading',
403 },
404 )
405 : ''
406
407 const updateManyAndReturnIncludeType =
408 hasRelationField && this.updateManyAndReturnType
409 ? ts.stringify(
410 buildIncludeType({
411 typeName: getIncludeUpdateManyAndReturnName(this.model.name),
412 modelName: this.model.name,
413 context: this.context,
414 fields: this.updateManyAndReturnType.fields,
415 }),
416 {
417 newLine: 'leading',
418 },
419 )
420 : ''
421
422 return `
423${this.getModelExport()}
424
425${!isComposite ? this.getAggregationTypes() : ''}
426
427${!isComposite ? this.getGroupByTypes() : ''}
428

Callers

nothing calls this directly

Calls 15

getModelExportMethod · 0.95
getAggregationTypesMethod · 0.95
getGroupByTypesMethod · 0.95
getDeepInputTypesMethod · 0.95
getCountTypesMethod · 0.95
buildOmitTypeFunction · 0.90
buildIncludeTypeFunction · 0.90
buildSelectTypeFunction · 0.90

Tested by

no test coverage detected