import { ClassType } from 'class-transformer/ClassTransformer'; import { GraphQLResolveInfo } from 'graphql'; import { BaseEntity, FindConditions, FindManyOptions, JoinOptions, ObjectLiteral } from 'typeorm'; import { AbstractCategoryEntity } from '../base'; import { CursoredPageable, PageInfo, PageRequest } from '../core/helpers'; import type { DataLoaderFunction, DefaultRegisteredLoaders, GraphqlContext } from '../dataloader'; import { CategoryInputQuery, CursoredRequestInput, ExclusiveQueryConditionInput, RelationQueryConditionInput, TimeConditionInput } from './input'; interface ResolveFindOptionsType { cls: ClassType; pageRequest?: PageRequest; select?: (keyof Entity)[] | string[]; info?: GraphQLResolveInfo; where?: FindConditions[] | FindConditions | ObjectLiteral | string; join?: JoinOptions; relationPath?: string; selectionPath?: string; relations?: boolean | { relations?: string[]; disableMixedMap?: boolean; }; timeCondition?: TimeConditionInput; cache?: boolean | number | { id: any; milliseconds: number; }; order?: { [P in keyof Entity]?: 'ASC' | 'DESC' | 1 | -1; }; } interface ResolveCategoryOptionsType { categoryRef?: keyof Entity; categoryCls: ClassType; query: CategoryInputQuery; } declare type BaseResolveProperty = { cls: ClassType; instance: Entity; key: keyof Entity; cache?: boolean | number; }; declare type BaseResolvePropertyWithMapper = { cls: ClassType; instance: Entity; key: keyof Entity; cache?: boolean | number; mapper: (item: RelationEntity) => MixedRelationEntity | Promise; }; declare type ResolvePropertyByTarget = { targetCls: ClassType; }; declare type ResolvePropertyByLoader = { loader: DataLoaderFunction; }; export declare class GraphqlHelper { static resolveOrder(cls: ClassType, pageRequest: PageRequest): { [P in keyof Entity]?: 'ASC' | 'DESC' | 1 | -1; }; static handlePagedDefaultQueryRequest({ cls, query, where, ctx, loader, pageRequest, mapper, info, relationPath, }: { cls: ClassType; query: ExclusiveQueryConditionInput; where?: FindConditions[] | FindConditions | ObjectLiteral | string; relationPath?: string; info?: GraphQLResolveInfo; ctx?: GraphqlContext; loader?: (loaders: DataLoaders) => DataLoaderFunction; pageRequest: PageRequest; mapper?: (item: Entity) => Promise; }): Promise; static handleDefaultQueryRequest(opts: { cls: ClassType; categoryCls?: ClassType; query: ExclusiveQueryConditionInput; relationPath?: string; info?: GraphQLResolveInfo; where?: FindConditions[] | FindConditions | ObjectLiteral | string; ctx?: GraphqlContext; pageInfo?: PageInfo; loader?: (loaders: DataLoaders) => DataLoaderFunction; mapper?: (item: Entity) => MixedEntity | Promise; }): Promise; static handleDefaultQueryRequest(opts: { cls: ClassType; categoryCls?: ClassType; query: ExclusiveQueryConditionInput; relationPath?: string; info?: GraphQLResolveInfo; where?: FindConditions[] | FindConditions | ObjectLiteral | string; ctx?: GraphqlContext; pageInfo?: PageInfo; loader?: (loaders: DataLoaders) => DataLoaderFunction; }): Promise; /** * @param cls * @param info * @param select * @param pageRequest * @param where * @param relationPath * @param categoryRef 类型的引用字段,默认为 category * @param categoryCls * @param query * @param timeCondition * @param cache 所有用户敏感的数据都应该关闭 cache,默认 true */ static genericFindOptions(opts: ResolveFindOptionsType): Promise>; static genericFindOptions(opts: ResolveFindOptionsType & ResolveCategoryOptionsType): Promise>; static resolveProperty_DO_NOT_USE(opts: BaseResolveProperty & (ResolvePropertyByLoader | ResolvePropertyByTarget)): Promise; static resolveProperties(opts: BaseResolveProperty & (ResolvePropertyByLoader | ResolvePropertyByTarget)): Promise; static resolveProperties(opts: BaseResolvePropertyWithMapper & (ResolvePropertyByLoader | ResolvePropertyByTarget)): Promise; static pagedResult({ pageRequest, items, total, }: { pageRequest: PageRequest; items: Entity[]; total: number; }): Promise; static pagedResult({ pageRequest, items, total, mapper, }: { pageRequest: PageRequest; items: Entity[]; total: number; mapper: (item: Entity) => MixedEntity | Promise; }): Promise; static resolveMixedRelation({ origin, query, targetCls, where, }: { origin: Entity; query: RelationQueryConditionInput; targetCls: ClassType; where: FindConditions; }): Promise<{ count: number; items: RelationEntity[]; }>; static handleCursoredQueryRequest({ cls, cursoredRequest, where, }: { cls: ClassType; cursoredRequest: CursoredRequestInput; where?: FindConditions[] | FindConditions | ObjectLiteral | string; }): Promise>; } export {};