import { type ArgumentRef, type CheckAsyncSelection, type FieldKind, type FieldMap, type FieldNullability, type FieldOptionsFromKind, type InferredFieldOptionKeys, type InferredFieldOptionsByKind, type InputFieldMap, type InputFieldsFromShape, type InputShapeFromFields, type InterfaceParam, type ListResolveValue, type MaybeAsyncSelection, type MaybePromise, type Merge, type Normalize, type ObjectRef, type OutputShape, type OutputType, type SchemaTypes, type ShapeFromTypeParam, type ShapeWithNullability, type TypeParam, typeBrandKey } from '@pothos/core'; import type { IndirectInclude, IndirectPathSegment, Mappings, PathSegment } from '@pothos/selection-mapper'; import type { FieldNode, GraphQLResolveInfo } from 'graphql'; import type { PrismaInterfaceRef, PrismaRef } from './interface-ref.js'; export interface PrismaDelegate { findUniqueOrThrow?: (...args: any[]) => Promise; findUnique: (...args: any[]) => Promise; } export declare const prismaModelName: unique symbol; export interface PrismaClient { $connect: () => Promise; } export interface PrismaModelTypes { Name: string; Shape: {}; Include: unknown; Select: unknown; OrderBy: unknown; Where: {}; WhereUnique: {}; Create: {}; Update: {}; ListRelations: string; RelationName: string; Relations: Record; } type ExtractModel = ParentShape extends { [prismaModelName]?: infer Name; } ? Types['PrismaTypes'][Name & keyof Types['PrismaTypes']] extends infer Model ? Model extends PrismaModelTypes ? Model : never : never : never; /** * The model a field's type param names: a prisma ref, the name of a prisma object type (one * registered under its model's name, as `prismaObject` does without `name` or `variant`, and so * a key of `Types['PrismaTypes']`), or a list of either. */ export type ModelForTypeParam = Type extends [infer Item] ? ModelForTypeParam : Type extends PrismaRef ? Model : Type extends keyof Types['PrismaTypes'] ? PrismaModelTypes & Types['PrismaTypes'][Type] : never; /** * The query a relation of `Model` is loaded with: the arguments prisma accepts on a list relation * (the generated `Parent$relationArgs`, which `PrismaModelTypes` does not carry, so the keys are * named here from what it does carry), and the `select` or `include` the planner adds beneath it. * The scalar fields of the model are the keys of its `Shape`, so `omit` and `distinct` are typed * by them. */ export interface PrismaRelationQuery { select?: Model['Select']; include?: Model['Include']; omit?: { [K in keyof Model['Shape']]?: boolean; }; where?: Model['Where']; orderBy?: Model['OrderBy'] | Model['OrderBy'][]; cursor?: Model['WhereUnique']; take?: number; skip?: number; distinct?: (keyof Model['Shape'] & string) | (keyof Model['Shape'] & string)[]; } /** * What `nestedSelection` returns: the relation query for `Model`, keeping the keys of the given * selection as they were given (so a `select` in it still narrows the parent shape). With no * selection, or `true`, it is the relation query itself. A field whose type has no model keeps * the selection it was given. */ export type NestedSelectionResult = [Model] extends [ never ] ? Selection : Selection extends boolean ? PrismaRelationQuery : Normalize, keyof Selection> & Selection>; /** * The selection given to `nestedSelection`: the query itself, or a callback building it from the * field's arguments and the context. A schema with `AsyncSelections: true` may also give a * promise of the query, or an async callback; the result is typed by the query either way, and is * a promise at runtime only when a promise or an async callback was given, or a selection beneath * it is async, and must then be awaited. */ export type NestedSelectionArg = Selection | (true extends Types['AsyncSelections'] ? PromiseLike : never) | ((args: InputShapeFromFields, ctx: Types['Context']) => MaybeAsyncSelection); /** * The callback a field's `select` function plans the selection beneath the field with: `path` * walks a field nested under the field's type, `type` names the type the selection is read as. * The selection is typed by the field's model when it has one, so `select: { title: true }` * keeps its literal `true`. */ export type NestedSelectionFn = ) = true>(selection?: NestedSelectionArg, path?: PathSegment[], type?: string) => NestedSelectionResult; export type PrismaObjectFieldOptions, Nullable extends FieldNullability, Args extends InputFieldMap, Select, ResolveReturnShape, Shape = unknown extends Select ? ParentShape : ParentShape & ShapeFromSelection, { select: Select extends (...args: any[]) => infer S ? Awaited : Select; }>> = PothosSchemaTypes.ObjectFieldOptions & InferredFieldOptionsByKind & { /** * What the field needs from its parent row. With `AsyncSelections: true` the function may be * async, and `nestedSelection` is then a promise when a selection beneath it is async, and * must be awaited. */ select?: Select & CheckAsyncSelection & (ExtractModel['Select'] | ((args: InputShapeFromFields, ctx: Types['Context'], nestedSelection: NestedSelectionFn, Args>) => MaybeAsyncSelection['Select']>)); }; type PrismaObjectFieldsShape = Model['Select'] extends Select ? (t: PothosSchemaTypes.PrismaObjectFieldBuilder) => FieldMap : (t: PrismaSelectionFieldBuilder) => FieldMap; type PrismaSelectionFieldBuilder = PothosSchemaTypes.PrismaObjectFieldBuilder; interface BaseSelection { include?: unknown; select?: unknown; } export type SelectedKeys = { [K in keyof T]-?: {} extends Pick ? never : T[K] extends false | undefined ? never : K; }[keyof T]; /** * An absent select loads all scalar columns. Keep Prisma's model-shape convention for an * unconstrained generated query type, but do not apply it to an explicit empty or partial map. */ type HasNoSelect = unknown extends Select ? true : [NonNullable ? Model['Select'] extends NonNullable