import { Dict, Maybe } from "./utils/util-types"; import { GraphQLInputType, GraphQLOutputType } from "graphql"; import { MappedDataSource } from "./MappedDataSource"; import { AliasHierarchyVisitor } from "./AliasHierarchyVisitor"; import { FieldMapping, ColumnMapping } from "./FieldMapping"; /** * Represents a field that has been mapped from one or more columns in a data source * * Encapsulates the difference between primary and computed fields * * @api-category MapperClass */ export declare class MappedField = any> { dataSource: TSrc; mappedName: string; private mapping; constructor(dataSource: TSrc, mappedName: string, mapping: TFMapping); get dependencies(): MappedField[]; /** * If the field is directly mapped from a column. * * Returns false for computed fields */ get isMappedFromColumn(): boolean; /** * If the field corresponds to a primary key in backing table */ get isPrimary(): boolean | undefined; /** * If this is a computed field */ get isComputed(): boolean; /** * The name of column which this field is mapped from * * Returns undefined for computed fields */ get sourceColumn(): string | undefined; /** * Names of all the columns which this field is derived from. * * For directly mapped column fields, this will always have a singular entry - the name of backing column. * For derived columns it will contain list of dependencies */ get sourceColumns(): string[]; /** * If this field is exposed in the GraphQL API */ get exposed(): boolean; /** * Description of this field - available to clients through the GraphQL API for exposed fields */ get description(): string | undefined; /** * Type specification for field */ get typeSpec(): import("./utils/types").TypeSpec & import("./utils/types").TypeSpec; /** * Human friendly represenation of the path of the field relative to data source - primarily useful for logging and debugging */ get keyPath(): string; /** * Field derivation function - undefined if the field is not a computed field */ get derive(): (Function & ((args: any) => any)) | undefined; /** * Get aliased name for the column, derived from table alias. * * Throws for computed columns */ getColumnAlias(tableAlias: Maybe): string | undefined; getColumnMappingList(aliasHierarchyVisitor: AliasHierarchyVisitor, aliasColumnsToTableScope?: boolean): ColumnMapping[]; /** * GraphQL output type for this field */ get graphQLOutputType(): GraphQLOutputType; /** * GraphQL input type for this field */ get graphQLInputType(): GraphQLInputType; /** * Getter useful to get the static type for this field. * * Useful only in mapped/computed typescript types - will throw if actually invoked. */ get Type(): TFMapping["type"]["Type"]; fromSource(i: any): any; toSource(i: TFMapping["type"]["Type"]): any; /** * Get the value for this field given a source row obtained from the data source */ getValue(sourceRow: Dict): any; /** * Reducer mapping a partial row (from data source) from a partial entity. * * Reduce functions from all fields can be composed to arrive at a data source row from Shallow entity */ updatePartialRow(partialRow: Dict, value: any): Dict; } /** * @api-category PrimaryAPI */ export declare const mapFields: >, TArgs extends {}>(fields: TFieldMapping) => >(dataSource: TSrc) => { [K in keyof TFieldMapping]: MappedField; };