import { ExposeOptions, TypeHelpOptions, TypeOptions } from 'class-transformer'; import { AutoMapperBase } from './base'; import { Configuration, Constructable, CreateMapFluentFunctions, MapActionOptions, MappingProfile } from './types'; /** * Combined Expose and Type from class-transformer * * @param {(type?: TypeHelpOptions) => Function} typeFn * @param {ExposeOptions} exposeOptions * @param {TypeOptions} typeOptions */ export declare const ExposedType: (typeFn: (type?: TypeHelpOptions | undefined) => Function, exposeOptions?: ExposeOptions | undefined, typeOptions?: TypeOptions | undefined) => PropertyDecorator; export declare class AutoMapper extends AutoMapperBase { private static _instance; private readonly _profiles; /** * @static - Get the Mapper instance */ static getInstance(): AutoMapper; constructor(); /** * Initialize Mapper * * @example * * * ```ts * Mapper.initialize(config => { * config.addProfile(new Profile()); * config.createMap(Source, Destination); * }) * ``` * * @param {(config: Configuration) => void} configFn - Config function callback * */ initialize(configFn: (config: Configuration) => void): void; /** * Map from Source to Destination * * @example * * * ```ts * const user = new User(); * user.firstName = 'John'; * user.lastName = 'Doe'; * * const userVm = Mapper.map(user, UserVm); * ``` * * @param {TSource} sourceObj - the sourceObj that are going to be mapped * @param {Constructable} destination - the Destination model to receive the * mapped values * @param {MapActionOptions} option - Optional mapping option */ map(sourceObj: TSource, destination: Constructable, option?: MapActionOptions): TDestination; /** * Map from Source to Destination Async. Mapping operation will be run as a micro task. * * @example * * * ```ts * const user = new User(); * user.firstName = 'John'; * user.lastName = 'Doe'; * * const userVm = await Mapper.mapAsync(user, UserVm); * ``` * * @param {TSource} sourceObj - the sourceObj that are going to be mapped * @param {Constructable} destination - the Destination model to receive the * mapped values * * @param {MapActionOptions} option - Optional mapping option * @returns {Promise} Promise that resolves TDestination */ mapAsync(sourceObj: TSource, destination: Constructable, option?: MapActionOptions): Promise; /** * Map from a list of Source to a list of Destination * * @example * * * ```ts * const addresses = []; * addresses.push(new Address(), new Address()); * * const addressesVm = Mapper.mapArray(addresses, AddressVm); * ``` * * @param {TSource} sourceObj - the sourceObj that are going to be mapped * @param {Constructable} destination - the Destination model to receive the * mapped values * @param {MapActionOptions} option - Optional mapping option */ mapArray(sourceObj: TSource[], destination: Constructable, option?: MapActionOptions): TDestination[]; /** * Map from a list of Source to a list of Destination async. Mapping operation will be run * as a micro task. * * @example * * * ```ts * const addresses = []; * addresses.push(new Address(), new Address()); * * const addressesVm = await Mapper.mapArrayAsync(addresses, AddressVm); * ``` * * @param {TSource} sourceObj - the sourceObj that are going to be mapped * @param {Constructable} destination - the Destination model to receive the * mapped values * @param {MapActionOptions} option - Optional mapping option * @returns {Promise>} Promise that resolves a TDestination[] */ mapArrayAsync(sourceObj: TSource[], destination: Constructable, option?: MapActionOptions): Promise; /** * Add MappingProfile to the current instance of AutoMapper * * @param {MappingProfile} profile - Profile being added */ addProfile(profile: MappingProfile): AutoMapper; /** * Create a mapping between Source and Destination without initializing the Mapper * * @param {Constructable} source - the Source model * @param {Constructable} destination - the Destination model */ createMap(source: Constructable, destination: Constructable): CreateMapFluentFunctions; /** * Dispose Mappings and Profiles created on the Mapper singleton */ dispose(): void; private _createMappingFluentFunctions; private _createMapForMember; private _createReverseMap; private _createMapForPath; } /** * @instance AutoMapper singleton */ export declare const Mapper: AutoMapper;