@breadstone/archipel-platform-mapping
v0.0.41
Published
Type-safe object mapping infrastructure for NestJS with keyed and type-based mapping registries, profiles, and compile-time safety.
Maintainers
Readme
@breadstone/archipel-platform-mapping
Type-safe object-to-object mapping framework for NestJS with a fluent builder API and profile-based configuration.
Features
- Type-safe mapping keys — Compile-time safety for source → destination pairs
- Profile-based configuration — Group related mappings in reusable profile classes
- Fluent builder API —
createMap,forMemberfor declarative field mapping - NestJS integration — Injectable
MappingServicewith dynamic module registration
Quick Start
import { MappingModule, MappingService, MappingProfileBase, MappingKey } from '@breadstone/archipel-platform-mapping';
const USER_TO_RESPONSE = new MappingKey<UserEntity, UserResponse>('UserToResponse');
class UserMappingProfile extends MappingProfileBase {
public configure(builder: IMappingBuilder): void {
builder
.createMap<UserEntity, UserResponse>(USER_TO_RESPONSE, UserResponse)
.forMember('displayName', (src) => `${src.firstName} ${src.lastName}`);
}
}
@Module({
imports: [
MappingModule.register({
profiles: [UserMappingProfile],
}),
],
})
export class AppModule {}Error Handling
| Error Class | When Thrown |
| ------------------------------- | -------------------------------------------- |
| MappingNotRegisteredError | No mapping registered for the given key |
| TypeMappingNotRegisteredError | No type mapping registered for the given key |
Peer Dependencies
| Package | Required | Notes |
| ---------------- | -------- | ----------- |
| @nestjs/common | Yes | NestJS core |
Documentation
📖 Package Docs: .docs/packages/platform-mapping/index.md
Development
# Build
yarn nx build platform-mapping
# Test
yarn nx test platform-mapping
# Lint
yarn nx lint platform-mappingLint
yarn nx lint platform-mapping
