๐ฅ An Object-Object AutoMapper for TypeScript ๐ฅ
MIT License
Bot releases are visible (Hide)
@automapper/classes
A before
transformer plugin that runs before the compilation step in order to keep track of the classes' metadata a different way. Read more about it on documentations
One of the requests I've got is to map any object as-is instead of going through the usual mapping pipeline. Internally, @automapper/core
looks at source
value and will determine to proceed with Mapping Nested Object if it encounters an object type. Previously, there's no way to customize this behavior from the auto-configured standpoint (you can still customize this with a forMember
). v3.x will allow to use null
for metadata that will affect the auto-configured process during initialization.
classes
class Foo {
@AutoMap(() => null)
arbitraryObject: Record<string, unknown>;
}
pojos
interface Foo {
arbitraryObject: Record<string, unknown>;
}
createMetadataMap<Foo>("Foo", {
arbitraryObject: null
})
Previously, a Date property will be instantiated with a new Date instance when the source
value is undefined
. This has been changed to instantiate a Date property with undefined
when source
value is undefined
instead. If your code and tests depend on the old behavior, please adjust accordingly
null
in createMetadataMap
As mentioned above, null
now means something else when used with createMetadataMap
. Previously, null
is to skip a property when we use the extend syntax of createMetadataMap
. Now, to skip a property, use false
value instead.
// previously
createMetadataMap("AnotherFoo", "Foo", {
bar: null // AnotherFoo has everything Foo has but it does not have "bar", so we skip it
})
// now
createMetadataMap("AnotherFoo", "Foo", {
bar: false
})