@jersmart/automapper-core
v0.0.0
Published
AutoMapper TypeScript Core
Maintainers
Readme
@jersmart/automapper-core
This is the core package that will handle mapping configurations and mapping operations.
Installation
npm i @jersmart/automapper-coreor with yarn
yarn add @jersmart/automapper-coreUsage
@jersmart/automapper-core exposes createMapper() method to create a Mapper object with a accompany MappingStrategy (read more
about Strategies)
createMapper accepts a CreateMapperOptions object with the following shape:
export interface CreateMapperOptions {
strategyInitializer: MappingStrategyInitializer<MetadataIdentifier>;
errorHandler?: ErrorHandler;
namingConventions?: NamingConventionInput;
}Read more about usage on documentation site
Strategies
A given Mapper is accompanied by a Strategy by providing strategyInitializer when using createMapper().
A Strategy will be responsible for:
- Discover metadata (eg:
classesuses@AutoMap()decorator to discover the metadata of the properties on the Classes) - Retrieve metadata: how the metadata should be retrieved from the discovery phase (eg:
classesdiscovers and stores the metadata toReflect, retrieve metadata simply gets them fromReflect) - Apply metadata: how the metadata is applied to the Model
@automapper provides the following official strategies:
@jersmart/automapper-classes: Work with TS/ES6 classes.@jersmart/automapper-pojos: Work with Interfaces/Types along with POJOs. In projects that do not make use of Class,pojoscan be used instead.@jersmart/automapper-mikro: Work together with TS/ES6 classes along with MikroORM@jersmart/automapper-sequelize: Work together with TS/ES6 classes along with Sequelize
