import { BaseContext as ApolloBaseContext, ApolloServerPlugin } from '@apollo/server'; import { Span, Tracer } from '@opentelemetry/api'; import { GraphQLResolveInfo, GraphQLScalarType, Source } from 'graphql'; import { ResolveTree } from 'graphql-parse-resolve-info'; import { ComplexityEstimator } from 'graphql-query-complexity'; import { CellFormatOptions, DetailPanelInputComponent, DetailPanelInputComponentOption } from './decorators'; import { EntityMetadata } from './metadata'; export type { Instrumentation } from '@opentelemetry/instrumentation'; export type { GraphQLResolveInfo } from 'graphql'; export type { FieldsByTypeName, ResolveTree } from 'graphql-parse-resolve-info'; export type BaseContext = object; export declare const ID: GraphQLScalarType; export interface TraceOptions { span: Span; tracer: Tracer; } export declare enum Sort { ASC = "ASC", DESC = "DESC" } export type OrderByOptions = Record; export type PaginationOptions = { orderBy: OrderByOptions; offset: number; limit: number; }; export type BaseOperator = 'ne' | 'notnull' | 'null'; export type ArrayOperator = 'in' | 'nin'; export type StringOperator = 'like' | 'ilike'; export type NumericOperator = 'gt' | 'gte' | 'lt' | 'lte'; export type FilterWithOperators = { [K in keyof G as G[K] extends string ? `${K & string}_${BaseOperator | ArrayOperator | StringOperator}` : G[K] extends number | bigint | Date ? `${K & string}_${BaseOperator | ArrayOperator | NumericOperator}` : `${K & string}_${BaseOperator | ArrayOperator}`]?: FilterValue; }; export type FilterValue = T | T[]; export type FilterEntity = { [K in keyof G]?: G[K] extends (...args: any[]) => Promise ? Filter : G[K] extends Promise ? Filter : Partial; }; export type FilterTopLevelProperties = { _and?: Filter[]; _or?: Filter[]; _not?: Filter[]; }; export declare const isTopLevelFilterProperty: (key: string) => boolean; export type Filter = FilterEntity & FilterTopLevelProperties & FilterWithOperators; export interface GraphQLArgs { items?: Partial[]; filter?: Filter; pagination?: PaginationOptions; } export declare enum AggregationType { COUNT = "COUNT" } export interface AggregationResult { count?: number; } export interface BackendProvider { readonly backendId: string; readonly backendDisplayName?: string; entityType?: new () => D; find(filter: Filter, pagination?: PaginationOptions, entityMetadata?: EntityMetadata): Promise; findOne(filter: Filter, entityMetadata?: EntityMetadata): Promise; findByRelatedId(entity: { new (): D; }, relatedField: string, relatedIds: readonly string[], filter?: Filter): Promise; updateOne(id: string | number, updateArgs: Partial): Promise; updateMany(entities: Partial[]): Promise; createOne(entity: Partial): Promise; createMany(entities: Partial[]): Promise; createTraces?(entities: Partial[]): Promise; createOrUpdateMany(entities: Partial[]): Promise; deleteOne(filter: Filter): Promise; deleteMany?(filter: Filter): Promise; withTransaction?: (callback: () => Promise) => Promise; foreignKeyForRelationshipField?(field: FieldMetadata, dataEntity: D): string | number; readonly maxDataLoaderBatchSize?: number; aggregate?(filter: Filter | undefined, requestedAggregations: Set): Promise; backendProviderConfig?: BackendProviderConfig; /** * @deprecated The method should not be used and will be removed in the future. Use `apolloPluginManager.addPlugin` instead. */ apolloPlugins?: ApolloServerPlugin[]; } export interface HookParams { context: TContext; transactional: boolean; fields?: ResolveTree; entities?: (G | null)[]; deleted?: boolean; } export interface CreateOrUpdateHookParams extends HookParams { args: { items: Partial[]; }; } export interface ReadHookParams extends HookParams { args: { filter?: Filter; pagination?: PaginationOptions; }; isAggregate?: boolean; } export interface DeleteHookParams extends HookParams { args: { filter: Filter; }; } export interface DeleteManyHookParams extends HookParams { args: { filter: Filter; }; } export declare enum AdminUIFilterType { DATE_TIME_RANGE = "DATE_TIME_RANGE", DATE_RANGE = "DATE_RANGE", ENUM = "ENUM", /** Default for numbers - shows simple numeric input */ NUMERIC = "NUMERIC", /** Shows a range to filter by a range from and to a number. */ NUMERIC_RANGE = "NUMERIC_RANGE", RELATIONSHIP = "RELATIONSHIP", TEXT = "TEXT", BOOLEAN = "BOOLEAN", DROP_DOWN_TEXT = "DROP_DOWN_TEXT" } export type AdminUIEntitySettings = { defaultFilter?: Filter; hideFromDisplay?: boolean; hideFromFilterBar?: boolean; }; export type AdminUISettingsType = { fields?: { [x: string]: { hideFromDisplay?: boolean; hideFromFilterBar?: boolean; }; }; entity?: AdminUIEntitySettings; }; export declare enum RelationshipType { MANY_TO_ONE = "MANY_TO_ONE", MANY_TO_MANY = "MANY_TO_MANY", ONE_TO_MANY = "ONE_TO_MANY" } export interface BackendProviderConfig { filter?: boolean; pagination?: boolean; orderBy?: boolean; supportedAggregationTypes?: Set; idListLoadingMethod?: 'find' | 'findOne'; supportsPseudoCursorPagination?: boolean; } export type Constructor = new (...arguments_: Arguments) => T; export type ClassType = Constructor & { prototype: T; }; export type TypeValue = ClassType | GraphQLScalarType | Function | object | symbol; export type GetTypeFunction = (type?: void) => TypeValue; export type Complexity = ComplexityEstimator | number; export interface FieldMetadata { adminUIOptions?: { hideInTable?: boolean; hideInFilterBar?: boolean; hideInDetailForm?: boolean; readonly?: boolean; fieldForDetailPanelNavigationId?: boolean; filterType?: AdminUIFilterType; filterOptions?: Record; detailPanelInputComponent?: DetailPanelInputComponentOption | DetailPanelInputComponent; format?: CellFormatOptions; relationshipBehaviour?: 'load' | 'count'; }; apiOptions?: { requiredForCreate?: boolean; requiredForUpdate?: boolean; excludeFromBuiltInWriteOperations?: boolean; }; target: { new (...args: any[]): G; }; name: string; getType: GetTypeFunction; relationshipInfo?: { relatedField?: string; id?: string | bigint | ((dataEntity: D) => string | number | bigint | undefined); }; description?: string; deprecationReason?: string; complexity?: Complexity; defaultValue?: any; readonly?: boolean; nullable?: boolean | 'items' | 'itemsAndList'; excludeFromFilterType?: boolean; additionalInformation?: Record; directives?: Record; } export type AuthChecker = (context: TContextType, roles: TRoleType[]) => boolean | Promise; export type ResolverOptions = { source: TSource; args: TArgs; context: TContext; fields: ResolveTree; info: GraphQLResolveInfo; trace?: TraceOptions; }; export type Resolver = ({ args, context, fields, trace, }: ResolverOptions) => Promise; export declare enum GraphweaverRequestEvent { OnRequest = "ON_REQUEST" } export type GraphweaverPluginNextFunction = (event: GraphweaverRequestEvent, next: GraphweaverPluginNextFunction) => Promise; export type GraphweaverPlugin = { name: string; event: GraphweaverRequestEvent; next: GraphweaverPluginNextFunction; };