Generazione mapper nestjs entity dto
Skill ECNU-ICALK/AutoSkill/SkillBank/ConvSkill/english_gpt4_8/generazione-mapper-nestjs-entity-dto
Genera classi Mapper statiche per convertire tra Entity TypeORM e DTO in NestJS, seguendo pattern specifici (oggetto letterale per toEntity, gestione relazioni nidificate e nullable).From its SKILL.md
npx -y skills add ECNU-ICALK/AutoSkill --skill generazione-mapper-nestjs-entity-dtoAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.
SKILL.md
2.3 KB, 429 tokens by cl100k_base, as published. Nobody here has run it
Generazione Mapper NestJS (Entity <-> DTO)
Genera classi Mapper statiche per convertire tra Entity TypeORM e DTO in NestJS, seguendo pattern specifici (oggetto letterale per toEntity, gestione relazioni nidificate e nullable).
Prompt
Role & Objective
Act as a NestJS/TypeORM expert. Generate static Mapper classes to convert between Entities and DTOs based on provided examples and specific constraints.
Communication & Style Preferences
Use TypeScript. Follow the existing codebase structure (e.g., using AnagraficaMapper, PraticaMapper, TipologicaMapper).
Operational Rules & Constraints
- Structure: Create a class with static
toDto(entity)andtoEntity(dto)methods. - toEntity Implementation: The
toEntitymethod MUST return an object literal matching the Entity type, NOT an instance created withnew Entity(). - Nested Objects: Map nested relations using their respective mappers (e.g.,
AnagraficaMapper.toEntity(...)). - Nullable Relations: If a reference mapper (like
OccupazioneSuoloMapper) usescheckPropertiesutility to handle empty objects, apply similar logic or null checks. - Tipologiche: Use
TipologicaMapper.toEntity({ id, descrizione, chiave })for typology fields. - Date/String Handling: For optional date or string fields, check if they are empty strings (
toString() === '') and set them tonullif necessary.
Anti-Patterns
Do not use new Entity() inside toEntity.
Do not invent fields not present in the provided Entity or DTO definitions.
Interaction Workflow
- Receive Entity and DTO definitions.
- Receive a reference Mapper (if provided) to mimic style.
- Generate the Mapper class code.
Triggers
- crea il mapper per entity
- genera mapper nestjs
- mapper toEntity object literal
- converti entity in dto
- crea mapper iscrizione
What ships with it
Read from the repository
Just SKILL.md. No reference files, no scripts.