import { AutoMapper } from './automapper'; export declare type Unpacked = T extends (infer U)[] ? U : T extends (...args: any[]) => infer U ? U : T extends Promise ? U : T; export declare enum TransformationType { /** * when `opts.ignore()` is used on `forMember()` */ Ignore = 0, /** * when `opts.mapFrom()` is used on `forMember()` */ MapFrom = 1, /** * when `opts.condition()` is used on `forMember()` */ Condition = 2, /** * when `opts.fromValue()` is used on `forMember()` */ FromValue = 3, /** * when `opts.mapWith()` is used on `forMember()` */ MapWith = 4, /** * when `opts.convertUsing()` is used on `forMember()` */ ConvertUsing = 5 } /** * A new-able type */ export declare type Constructable = new (...args: any[]) => T; export declare type MapActionOptions = { beforeMap?: BeforeAfterMapAction; afterMap?: BeforeAfterMapAction; }; export declare type BeforeAfterMapAction = (source: TSource, destination: TDestination, mapping?: Mapping) => void; export interface Converter { convert(source: TSource): TDestination; } export interface Resolver { resolve(source: TSource, destination: TDestination, transformation: MappingTransformation): TDestination[K]; } /** * Value Selector from a source type * * @example * * ```ts * source => source.foo.bar * ``` */ export declare type ValueSelector = (source: TSource) => TDestination[K]; export declare type MapFromCallback = ValueSelector | Resolver; /** * Condition Predicate from a source */ export declare type ConditionPredicate = (source: TSource) => boolean; /** * Options for mapWith */ export declare type MapWithOptions = { destination: Constructable>; value: ValueSelector; }; export declare type ConvertUsingOptions = { converter: Converter; value?: (source: TSource) => TSource[keyof TSource]; }; export interface DestinationMemberConfigOptions { mapFrom(cb: MapFromCallback): void; mapWith(destination: Constructable>, value: ValueSelector): void; condition(predicate: ConditionPredicate): void; fromValue(value: TDestination[K]): void; ignore(): void; convertUsing(converter: Converter, value?: (source: TSource) => TConvertSource): void; } export interface ForMemberExpression { (opts: DestinationMemberConfigOptions): void; } export declare type ForPathDestinationFn = (destination: TDestination) => TDestination[keyof TDestination]; export interface CreateReverseMapFluentFunctions { forPath(destination: ForPathDestinationFn, forPathFn: ForMemberExpression): CreateReverseMapFluentFunctions; } export interface CreateMapFluentFunctions { forMember(key: K, expression: ForMemberExpression): CreateMapFluentFunctions; beforeMap(action: BeforeAfterMapAction): CreateMapFluentFunctions; afterMap(action: BeforeAfterMapAction): CreateMapFluentFunctions; reverseMap(): CreateReverseMapFluentFunctions; setSourceNamingConvention(namingConvention: NamingConvention): CreateMapFluentFunctions; setDestinationNamingConvention(namingConvention: NamingConvention): CreateMapFluentFunctions; } export interface Configuration { addProfile(profile: MappingProfile): void; createMap(source: Constructable, destination: Constructable): CreateMapFluentFunctions; } export interface MappingTransformation { transformationType: TransformationType; mapFrom: MapFromCallback; mapWith: MapWithOptions; condition: ConditionPredicate; fromValue: TDestination[keyof TDestination]; convertUsing: ConvertUsingOptions; } export interface MappingProperty { destinationKey: keyof TDestination; transformation: MappingTransformation; } export interface Mapping { source: Constructable; destination: Constructable; sourceKey: string; destinationKey: string; properties: Map>; sourceMemberNamingConvention: NamingConvention; destinationMemberNamingConvention: NamingConvention; beforeMapAction?: BeforeAfterMapAction; afterMapAction?: BeforeAfterMapAction; } export interface MappingProfile { profileName: string; configure: (mapper: AutoMapper) => void; } export declare type NamingConvention = { splittingExpression: RegExp; separatorCharacter: string; transformPropertyName: (sourcePropNameParts: string[]) => string; };