UNPKG

trade360-nodejs-sdk

Version:
72 lines (71 loc) 3.25 kB
import { BaseEntity, Constructor, PackageCredentials } from '../../entities/core-entities/index.js'; import { IMapper } from './interfaces'; /** * Mapper class for mapping between different types * of objects in the application using the mapping * configurations provided in the application. * The Mapper class provides functionality similar * to AutoMapper with the ability to map between * different types of objects in the application * using the mapping configurations provided in the * application. * @param packageCredentials The package credentials * for the API to use in the mapping configurations * for the application. The package credentials are * used to authenticate the API requests in the * mapping configurations for the application. * @implements IMapper interface for mapping between * different types of objects in the application * using the mapping configurations provided in the * application. */ export declare class Mapper implements IMapper { private mappingConfigs; private readonly desiredDateFormat; constructor(packageCredentials?: PackageCredentials); map<S extends BaseEntity, D extends BaseEntity>(source: S, destinationType: Constructor<D>): D; /** * Initializes all mapping configurations for the * application using the package credentials provided in * the constructor of the mapping service to authenticate * the API requests in the mapping configurations for the * application. * @param packageCredentials The package credentials for * the API to use in the mapping configurations for the * application. * @returns void to indicate that the mapping * configurations have been initialized successfully in * the application using the package credentials provided * in the constructor of the mapping service. */ private initializeMappings; /** * Registers a new mapping configuration between two types * of objects in the application using a mapping function * to transform the source object to the destination object * type specified in the mapping configuration. * @param sourceType The constructor of the source type * @param destinationType The constructor of the destination * type to map to the source type using the mapping function * provided in the configuration profile for the mapping * between the two types of objects * @param mappingFn The function that performs the mapping * from source to destination type objects in the application * using the mapping function provided in the configuration * profile for the mapping between the two types of objects * in the application using the mapping function provided in * the configuration profile for the mapping. * @returns void to indicate that the mapping configuration * has been registered successfully in the application. */ private registerMapping; /** * Formats a date to MM/DD/YYYY string format * @param fieldName The name of the date field * to format. * @param date The date to format to MM/DD/YYYY string * format. * @returns Formatted date string in MM/DD/YYYY format */ private formatDate; }