import type { AnnotationValue, OperationKind, ValidAnnotations, } from '@prisma-next/framework-components/runtime'; import type { Expression, ExpressionBuilder, FieldProxy, Functions, OrderByOptions, OrderByScope, } from '../expression'; import type { GatedMethod, QueryContext, Scope, ScopeField, Subquery } from '../scope'; import type { GroupedQuery } from './grouped-query'; import type { WithAlias, WithBuild, WithDistinct, WithPagination, WithSelect } from './shared'; export interface SelectQuery< QC extends QueryContext, AvailableScope extends Scope, RowType extends Record, > extends Subquery, WithSelect, 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> ): SelectQuery; where(expr: ExpressionBuilder): SelectQuery; orderBy( field: (keyof RowType | keyof AvailableScope['topLevel']) & string, options?: OrderByOptions, ): SelectQuery; orderBy( expr: ( fields: FieldProxy>, fns: Functions, ) => Expression, options?: OrderByOptions, ): SelectQuery; groupBy( ...fields: ((keyof RowType | keyof AvailableScope['topLevel']) & string)[] ): GroupedQuery; groupBy( expr: ( fields: FieldProxy>, fns: Functions, ) => Expression, ): GroupedQuery; distinctOn: GatedMethod< QC['capabilities'], { postgres: { distinctOn: true } }, { ( ...fields: ((keyof RowType | keyof AvailableScope['topLevel']) & string)[] ): SelectQuery; ( expr: ( fields: FieldProxy>, fns: Functions, ) => Expression, ): SelectQuery; } >; }