()
| 477 | } |
| 478 | |
| 479 | public toTS(): string { |
| 480 | const { name } = this.outputType |
| 481 | const { dmmf } = this.context |
| 482 | |
| 483 | const mapping = dmmf.mappingsMap[name] ?? { model: name, plural: `${name}s` } |
| 484 | const modelOrType = dmmf.typeAndModelMap[name] |
| 485 | |
| 486 | const availableActions = getModelActions(dmmf, name) |
| 487 | const nonAggregateActions = this.getNonAggregateActions(availableActions) |
| 488 | const groupByArgsName = getGroupByArgsName(name) |
| 489 | const countArgsName = getModelArgName(name, DMMF.ModelAction.count) |
| 490 | |
| 491 | const genericDelegateParams = [extArgsParam, ts.genericParameter('GlobalOmitOptions').default(ts.objectType())] |
| 492 | |
| 493 | const excludedArgsForCount = ['select', 'include', 'distinct', 'omit'] |
| 494 | if (this.context.isPreviewFeatureOn('relationJoins')) { |
| 495 | excludedArgsForCount.push('relationLoadStrategy') |
| 496 | } |
| 497 | |
| 498 | const excludedArgsForCountType = excludedArgsForCount.map((name) => `'${name}'`).join(' | ') |
| 499 | |
| 500 | return `\ |
| 501 | ${ |
| 502 | availableActions.includes(DMMF.ModelAction.aggregate) |
| 503 | ? `type ${countArgsName}<ExtArgs extends $Extensions.InternalArgs = $Extensions.DefaultArgs> = |
| 504 | Omit<${getModelArgName(name, DMMF.ModelAction.findMany)}, ${excludedArgsForCountType}> & { |
| 505 | select?: ${getCountAggregateInputName(name)} | true |
| 506 | } |
| 507 | ` |
| 508 | : '' |
| 509 | } |
| 510 | export interface ${name}Delegate<${genericDelegateParams.map((param) => ts.stringify(param)).join(', ')}> { |
| 511 | ${indent(`[K: symbol]: { types: Prisma.TypeMap<ExtArgs>['model']['${name}'], meta: { name: '${name}' } }`, TAB_SIZE)} |
| 512 | ${nonAggregateActions |
| 513 | .map((action) => { |
| 514 | const method = buildModelDelegateMethod(name, action, this.context) |
| 515 | return ts.stringify(method, { indentLevel: 1, newLine: 'trailing' }) |
| 516 | }) |
| 517 | .join('\n')} |
| 518 | |
| 519 | ${ |
| 520 | availableActions.includes(DMMF.ModelAction.aggregate) |
| 521 | ? `${indent(getMethodJSDoc(DMMF.ModelAction.count, mapping, modelOrType), TAB_SIZE)} |
| 522 | count<T extends ${countArgsName}>( |
| 523 | args?: Subset<T, ${countArgsName}>, |
| 524 | ): Prisma.PrismaPromise< |
| 525 | T extends $Utils.Record<'select', any> |
| 526 | ? T['select'] extends true |
| 527 | ? number |
| 528 | : GetScalarType<T['select'], ${getCountAggregateOutputName(name)}> |
| 529 | : number |
| 530 | > |
| 531 | ` |
| 532 | : '' |
| 533 | } |
| 534 | ${ |
| 535 | availableActions.includes(DMMF.ModelAction.aggregate) |
| 536 | ? `${indent(getMethodJSDoc(DMMF.ModelAction.aggregate, mapping, modelOrType), TAB_SIZE)} |
nothing calls this directly
no test coverage detected