import { Constructor } from './types/Constructor'; import { IMappingKey } from './types/MappingKey'; import { IMappingProfile } from './profile/interfaces/IMappingProfile'; /** * Central mapping registry supporting keyed & type-based mappings. * * @public */ export declare class MappingService { private readonly _keyRegistry; private readonly _typeRegistry; private readonly _registeredProfiles; private readonly _logger; /** * Constructs a new instance of the `{@link MappingService}` class. * * @public */ constructor(); /** * Registers a mapping function for a specific key. * * @public * @param key - The unique key for the mapping. * @param fn - The mapping function. * @returns void */ register(key: string, fn: (source: TSource) => TDestination): void; /** * Registers a mapping function for a specific source and destination type. * * @public * @param source - The constructor of the source type. * @param destination - The constructor of the destination type. * @param fn - The mapping function. * @returns void */ registerMap(source: Constructor, destination: Constructor, fn: (source: TSource) => TDestination): void; /** * Maps a source object to a destination type using a type-safe mapping key. * The key encodes both input and output types, ensuring compile-time type safety. * * @public * @param key - The type-safe mapping key. * @param source - The source object to map. * @returns The mapped destination object. * * @example * ```typescript * const response = this._mappingService.map(PRODUCT_MAPPING_KEY, productInput); * // response is automatically typed as ProductResponse * ``` */ map(key: IMappingKey, source: TInput): TOutput; /** * Attempts to map returning undefined instead of throwing when mapping is absent. * * @public * @param key - The type-safe mapping key. * @param source - The source object to map. * @returns The mapped destination object or undefined if no mapping exists. */ tryMap(key: IMappingKey, source: TInput): TOutput | undefined; /** * Maps a source object to a destination type using a registered mapping function. * * @public * @param source - The source object to map. * @param destination - The constructor of the destination type. * @returns The mapped destination object. */ mapTypes(source: TSource, destination: Constructor): TDestination; /** * Safe variant of {@link mapTypes} that returns undefined if not registered. */ tryMapTypes(source: TSource, destination: Constructor): TDestination | undefined; /** * Maps an array of source objects to an array of destination types using a registered mapping function. * * @public * @param sources - The array of source objects to map. * @param destination - The constructor of the destination type. * @returns The array of mapped destination objects. */ mapTypesArray(sources: TSource[], destination: Constructor): TDestination[]; /** * Registers a mapping profile containing multiple mappings. * * @public * @param profile - The mapping profile to register. * @returns void */ registerProfile(profile: IMappingProfile): void; /** * Generates a unique key for a mapping between two types. * * @private * @param a - The constructor of the source type. * @param b - The constructor of the destination type. * @returns A unique key representing the mapping. */ private typeKey; }