import type { AnnotationValue, OperationKind, ValidAnnotations, } from '@prisma-next/framework-components/runtime'; import type { AggregateFunctions, BooleanCodecType, Expression, FieldProxy, Functions, OrderByOptions, OrderByScope, } from '../expression'; import type { GatedMethod, QueryContext, Scope, ScopeField, Subquery } from '../scope'; import type { WithAlias, WithBuild, WithDistinct, WithPagination } from './shared'; export interface GroupedQuery< QC extends QueryContext, AvailableScope extends Scope, RowType extends Record, > extends Subquery, WithPagination, WithDistinct, WithAlias, WithBuild { /** * Attach one or more read-typed annotations to this query plan. * Annotations declare `applicableTo: ['read']` (or `['read', 'write']`) * via `defineAnnotation`; write-only annotations fail to compile here. * Annotations are merged into `plan.meta.annotations` at `.build()` time. * Chainable in any position; multiple calls compose with last-write-wins * on duplicate namespaces. */ annotate[]>( ...annotations: As & ValidAnnotations<'read', As> ): GroupedQuery; groupBy( ...fields: ((keyof RowType | keyof AvailableScope['topLevel']) & string)[] ): GroupedQuery; groupBy( expr: ( fields: FieldProxy>, fns: Functions, ) => Expression, ): GroupedQuery; having( expr: ( fields: FieldProxy>, fns: AggregateFunctions, ) => Expression, ): GroupedQuery; orderBy( field: (keyof RowType | keyof AvailableScope['topLevel']) & string, options?: OrderByOptions, ): GroupedQuery; orderBy( expr: ( fields: FieldProxy>, fns: AggregateFunctions, ) => Expression, options?: OrderByOptions, ): GroupedQuery; distinctOn: GatedMethod< QC['capabilities'], { postgres: { distinctOn: true } }, { ( ...fields: ((keyof RowType | keyof AvailableScope['topLevel']) & string)[] ): GroupedQuery; ( expr: ( fields: FieldProxy>, fns: Functions, ) => Expression, ): GroupedQuery; } >; }