import * as Knex from "knex"; import { AliasHierarchyVisitor } from "./AliasHierarchyVisitor"; import { PrimaryRowMapper } from "./SingleSourceQueryOperationResolver"; import { Dict, Maybe } from "./utils/util-types"; import { MappedDataSource } from "./MappedDataSource"; import { MappedSourceAwareOperation } from "./MappedSourceAwareOperation"; import { SourceAwareResolverContext } from "./SourceAwareResolverContext"; import { BaseResolver } from "./BaseResolver"; export interface BaseStoreParams { queryBuilder: Knex.QueryBuilder; } /** * Base class for operation resolvers that need to interact with one or more mapped data sources * * @api-category CRUDResolvers */ export declare class SourceAwareOperationResolver, TSrc, TArgs>, TSrc extends MappedDataSource, TArgs extends {}, TResolved> extends BaseResolver { resolverContext: TCtx; isDelegated: boolean | undefined; protected _activeTransaction?: Maybe; constructor(resolverContext: TCtx); /** * Can be overriden to return a collection of resolver instances that we are delegating to. * * This is required for sharing the same transactions across the root resolver and all the * delegated resolvers */ get delegatedResolvers(): SourceAwareOperationResolver[]; /** * Currently active Knex transaction instance */ get activeTransaction(): Maybe; /** * Set a transaction as currently active */ set activeTransaction(transaction: Maybe); /** * Get AliasHeirarchyVisitor for specified data source */ getAliasHierarchyVisitorFor(dataSource: TCtx["DataSourceType"]): AliasHierarchyVisitor; /** * Use associated operation's primary data source to construct the root query builder * and wrap it in active transaction. * * Currently this can be used only if the operation is a single source operation, and throws otherwise. */ createRootQueryBuilder(dataSource: TCtx["DataSourceType"], shouldAlias?: boolean): Knex.QueryBuilder; /** * Check if all the involved data sources support SQL returning statement */ get supportsReturning(): boolean; /** * Use columnAlias mappings to reverse map retrieved rows to fields of entities */ protected extractPrimaryKeyValues(primaryMappers: PrimaryRowMapper[], rows: Dict[]): Dict[]; /** * Given a set of primary key + value combinations, compose a knex query to match any of these * values */ protected queryByPrimaryKeyValues(queryBuilder: Knex.QueryBuilder, primaryKeyValues: Dict[]): Knex.QueryBuilder; /** * Wrap database operations in a transaction * * Creates a new transaction only if the operation is not delegated from some other operation. Reuses * parent operation transaction for delegated transactions. */ protected wrapInTransaction(cb: () => Promise): Promise; }