import { MappedDataSource } from "./MappedDataSource"; import { SingleSourceQueryOperationResolver } from "./SingleSourceQueryOperationResolver"; import { MappedSingleSourceOperation } from "./MappedSingleSourceOperation"; import * as Knex from "knex"; import { Dict, PartialDeep } from "./utils/util-types"; import { AliasHierarchyVisitor } from "./AliasHierarchyVisitor"; import { AssociationMapping, AssociationPreFetchConfig, MappedForeignOperation, AssociationPostFetchConfig, AssociationJoinConfig } from "./AssociationMapping"; import { MappedSingleSourceQueryOperation } from "./MappedSingleSourceQueryOperation"; import { SourceAwareResolverContext } from "./SourceAwareResolverContext"; /** * A mapped association represents an association among multiple data sources and encapsulates the knowledge of how to fetch a connected * data source while resolving an operation in another data source. * * @api-category MapperClass */ export declare class MappedAssociation { dataSource: TSrc; mappedName: string; private mapping; constructor(dataSource: TSrc, mappedName: string, mapping: AssociationMapping); /** * If the association will resolve to at most one associated entity */ get singular(): boolean; /** * If the association will be exposed through GraphQL API */ get exposed(): boolean; /** * Linked data source */ get target(): TTgt; /** * Association description made available through the GraphQL API */ get description(): string | undefined; /** * If the association supports paginated response */ get isPaginated(): boolean; /** * For a given operation, identify one of the (potentially) many many fetch configurations specified * using the fetchThrough mapping property. */ getFetchConfig, TRootSrc extends MappedDataSource, TMappedOperation extends MappedSingleSourceQueryOperation, TGQLArgs extends {}, TGQLSource = any, TGQLContext = any, TResolved = any>(operation: SingleSourceQueryOperationResolver): (AssociationJoinConfig & { useIf?: (, TRootSrc_1 extends MappedDataSource, TMappedOperation_1 extends MappedSingleSourceQueryOperation, TGQLArgs_1 extends {}, TGQLSource_1 = any, TGQLContext_1 = any, TResolved_1 = any>(this: MappedAssociation, operation: SingleSourceQueryOperationResolver) => boolean) | undefined; }) | (AssociationPreFetchConfig & { useIf?: (, TRootSrc_1 extends MappedDataSource, TMappedOperation_1 extends MappedSingleSourceQueryOperation, TGQLArgs_1 extends {}, TGQLSource_1 = any, TGQLContext_1 = any, TResolved_1 = any>(this: MappedAssociation, operation: SingleSourceQueryOperationResolver) => boolean) | undefined; }) | (AssociationPostFetchConfig & { useIf?: (, TRootSrc_1 extends MappedDataSource, TMappedOperation_1 extends MappedSingleSourceQueryOperation, TGQLArgs_1 extends {}, TGQLSource_1 = any, TGQLContext_1 = any, TResolved_1 = any>(this: MappedAssociation, operation: SingleSourceQueryOperationResolver) => boolean) | undefined; }) | null; /** * Start Side loading associated entities before the parent entity has been fetched */ preFetch, TRootSrc extends MappedDataSource, TMappedOperation extends MappedSingleSourceQueryOperation, TGQLArgs extends {}, TGQLSource = any, TGQLContext = any, TResolved = any>(preFetchConfig: AssociationPreFetchConfig, operation: SingleSourceQueryOperationResolver): MappedForeignOperation>; /** * Side-load associated entities after parent entity has been fetched */ postFetch, TRootSrc extends MappedDataSource, TMappedOperation extends MappedSingleSourceQueryOperation, TGQLArgs extends {}, TGQLSource = any, TGQLContext = any, TResolved = any>(postFetchConfig: AssociationPostFetchConfig, operation: SingleSourceQueryOperationResolver, parents: PartialDeep[]): MappedForeignOperation>; join(joinConfig: AssociationJoinConfig, queryBuilder: Knex.QueryBuilder, aliasHierarchyVisitor: AliasHierarchyVisitor): AliasHierarchyVisitor; isAutoJoinable(joinConfig: AssociationJoinConfig): boolean; /** * Associates side loaded entities with parent entity. */ associateResultsWithParents(fetchConfig: AssociationPreFetchConfig | AssociationPostFetchConfig): (parents: PartialDeep[], results: PartialDeep[]) => void; /** * Columns used to link the data sources at the persistence layer */ get associatorColumns(): { inSource: string; inRelated: string; } | undefined; /** * Getter to obtain the type of source DataSource. * * This is expected to be used only in mapped typescript types. Invoking the getter directly * at runtime will throw. */ get DataSourceType(): TSrc; /** * Getter to obtain the type of associated DataSource. * * This is expected to be used only in mapped typescript types. Invoking the getter directly * at runtime will throw. */ get AssociatedDataSourceType(): TTgt; /** * Getter to obtain the type of entity from source DataSource. * * This is expected to be used only in mapped typescript types. Invoking the getter directly * at runtime will throw. */ get SourceEntityType(): TSrc["EntityType"]; /** * Getter to obtain the type of entity from associated DataSource. * * This is expected to be used only in mapped typescript types. Invoking the getter directly * at runtime will throw. */ get AssociatedEntityType(): TTgt["EntityType"]; } declare type AssociationMappingResult>, TSrc extends MappedDataSource> = { [K in keyof TMapping]: MappedAssociation>; }; /** * Used to define an association between two data sources. * * Make sure you have gone through the [Association Mapping](guide:mapping-associations) guide first which elaborates on * the concepts behind association mapping. * * Association mapping determines how two data sources can be linked (through joins, or auxiliary queries) so * that operations can be performed over multiple data sources. * * Accepts an [AssociationMapping](api:AssociationMapping) configuration. * * @api-category PrimaryAPI * @param associations */ export declare const mapAssociations: >>>(associations: TMapping) => >(dataSource: TSrc) => AssociationMappingResult; export {};