import * as t from "io-ts"; import { MappedAssociation } from "./MappedAssociation"; import { MappedDataSource } from "./MappedDataSource"; import { MappedSingleSourceOperation } from "./MappedSingleSourceOperation"; import { MappedSingleSourceQueryOperation } from "./MappedSingleSourceQueryOperation"; import { SingleSourceQueryOperationResolver } from "./SingleSourceQueryOperationResolver"; import { PaginationConfig } from "./PaginationConfig"; import { JoinBuilder } from "./utils/JoinBuilder"; import { PartialDeep } from "./utils/util-types"; import { SourceAwareResolverContext } from "./SourceAwareResolverContext"; /** * In a composite multi-step operations, we can resolve operations over associations as mapped foreign operation in another data source * * Internally there is not much difference between a directly exposed data source and an operation which happens as a part of another multi-step composite operation * * MappedForeignOperation couples an operation as well as the arguments needed to invoke that operation. * * @api-category ConfigType */ export interface MappedForeignOperation> { operation: M; args: M["ArgsType"]; } /** * Runtime type representing union of constants representing different join types * * @api-category ConfigType */ export declare const JoinRT: t.UnionC<[t.LiteralC<"innerJoin">, t.LiteralC<"leftJoin">, t.LiteralC<"leftOuterJoin">, t.LiteralC<"rightOuterJoin">, t.LiteralC<"rightJoin">, t.LiteralC<"outerJoin">, t.LiteralC<"fullOuterJoin">, t.LiteralC<"crossJoin">]>; /** * @api-category ConfigType */ export declare type JoinTypeId = t.TypeOf; /** * @api-category ConfigType */ export declare const AssociationJoinConfigRT: t.TypeC<{ join: t.UnionC<[t.UnionC<[t.LiteralC<"innerJoin">, t.LiteralC<"leftJoin">, t.LiteralC<"leftOuterJoin">, t.LiteralC<"rightOuterJoin">, t.LiteralC<"rightJoin">, t.LiteralC<"outerJoin">, t.LiteralC<"fullOuterJoin">, t.LiteralC<"crossJoin">]>, t.FunctionC]>; }>; /** * @api-category ConfigType */ export interface AssociationJoinConfig extends t.TypeOf { join: JoinTypeId | ((joinBuilder: JoinBuilder) => JoinBuilder); } /** * @api-category ConfigType */ export declare const AssociationPreFetchConfigRT: t.IntersectionC<[t.TypeC<{ preFetch: t.FunctionC; }>, t.PartialC<{ associateResultsWithParents: t.FunctionC; }>]>; /** * @api-category ConfigType */ export interface AssociationPreFetchConfig extends t.TypeOf { preFetch: , TRootSrc extends MappedDataSource, TMappedOperation extends MappedSingleSourceQueryOperation, TGQLArgs extends {}, TGQLSource = any, TGQLContext = any, TResolved = any>(this: MappedAssociation, operation: SingleSourceQueryOperationResolver) => MappedForeignOperation>; associateResultsWithParents?: (this: MappedAssociation, parents: PartialDeep[], results: PartialDeep[]) => void; } /** * @api-category ConfigType */ export declare const AssociationPostFetchConfigRT: t.IntersectionC<[t.TypeC<{ postFetch: t.FunctionC; }>, t.PartialC<{ associateResultsWithParents: t.FunctionC; }>]>; /** * @api-category ConfigType */ export interface AssociationPostFetchConfig extends t.TypeOf { postFetch: , TRootSrc extends MappedDataSource, TMappedOperation extends MappedSingleSourceQueryOperation, TGQLArgs extends {}, TGQLSource = any, TGQLContext = any, TResolved = any>(this: MappedAssociation, operation: SingleSourceQueryOperationResolver, parents: PartialDeep[]) => MappedForeignOperation>; associateResultsWithParents?: (this: MappedAssociation, parents: PartialDeep[], results: PartialDeep[]) => void; } /** * @api-category ConfigType */ export declare const AssociationFetchConfigRT: t.IntersectionC<[t.UnionC<[t.IntersectionC<[t.TypeC<{ preFetch: t.FunctionC; }>, t.PartialC<{ associateResultsWithParents: t.FunctionC; }>]>, t.IntersectionC<[t.TypeC<{ postFetch: t.FunctionC; }>, t.PartialC<{ associateResultsWithParents: t.FunctionC; }>]>, t.TypeC<{ join: t.UnionC<[t.UnionC<[t.LiteralC<"innerJoin">, t.LiteralC<"leftJoin">, t.LiteralC<"leftOuterJoin">, t.LiteralC<"rightOuterJoin">, t.LiteralC<"rightJoin">, t.LiteralC<"outerJoin">, t.LiteralC<"fullOuterJoin">, t.LiteralC<"crossJoin">]>, t.FunctionC]>; }>]>, t.PartialC<{ useIf: t.FunctionC; }>]>; /** * @api-category ConfigType */ export declare type AssociationFetchConfig = (AssociationJoinConfig | AssociationPreFetchConfig | AssociationPostFetchConfig) & { useIf?: , TRootSrc extends MappedDataSource, TMappedOperation extends MappedSingleSourceQueryOperation, TGQLArgs extends {}, TGQLSource = any, TGQLContext = any, TResolved = any>(this: MappedAssociation, operation: SingleSourceQueryOperationResolver) => boolean; }; export declare function isPreFetchConfig(config: any): config is AssociationPreFetchConfig; export declare function isPostFetchConfig(config: any): config is AssociationPostFetchConfig; export declare function isJoinConfig(config: any): config is AssociationJoinConfig; /** * @api-category ConfigType */ export declare const AssociationMappingRT: t.IntersectionC<[t.TypeC<{ target: t.FunctionC; fetchThrough: t.ArrayC, t.PartialC<{ associateResultsWithParents: t.FunctionC; }>]>, t.IntersectionC<[t.TypeC<{ postFetch: t.FunctionC; }>, t.PartialC<{ associateResultsWithParents: t.FunctionC; }>]>, t.TypeC<{ join: t.UnionC<[t.UnionC<[t.LiteralC<"innerJoin">, t.LiteralC<"leftJoin">, t.LiteralC<"leftOuterJoin">, t.LiteralC<"rightOuterJoin">, t.LiteralC<"rightJoin">, t.LiteralC<"outerJoin">, t.LiteralC<"fullOuterJoin">, t.LiteralC<"crossJoin">]>, t.FunctionC]>; }>]>, t.PartialC<{ useIf: t.FunctionC; }>]>>; }>, t.PartialC<{ description: t.StringC; singular: t.BooleanC; exposed: t.BooleanC; associatorColumns: t.TypeC<{ inSource: t.StringC; inRelated: t.StringC; }>; paginate: t.UnionC<[t.IntersectionC<[t.TypeC<{ cursorColumn: t.StringC; }>, t.PartialC<{ pageSize: t.UnionC<[t.NumberC, t.PartialC<{ max: t.NumberC; default: t.NumberC; }>]>; }>]>, t.IntersectionC<[t.PartialC<{ pageSize: t.UnionC<[t.NumberC, t.PartialC<{ max: t.NumberC; default: t.NumberC; }>]>; }>, t.TypeC<{ interceptQuery: t.FunctionC; getNextCursor: t.FunctionC; getPrevCursor: t.FunctionC; getTotalCount: t.FunctionC; }>]>]>; }>]>; /** * Configuration used to map an association. * * 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. * * @api-category ConfigType */ export interface AssociationMapping extends t.TypeOf { target: (this: MappedAssociation) => TTgt; description?: string; singular?: boolean; associatorColumns?: { inSource: string; inRelated: string; }; fetchThrough: AssociationFetchConfig[]; paginate?: PaginationConfig; }