entity-models-new

Declares entity model namespaces and mappers for Angular domain libraries.

1|Updated Jan 14, 2024
One-click install
npx skills add https://github.com/Eyhenij/rt-tools --skill entity-models-new-eyhenij
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: entity-models-new
Source: https://github.com/Eyhenij/rt-tools/tree/main/.claude/skills/entity-models-new
Command: npx skills add https://github.com/Eyhenij/rt-tools --skill entity-models-new-eyhenij

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? When adding a new admin entity or editing an existing one, developers must follow a strict convention for declaring entity models and their mappers; this Skill encodes that pattern so the model, mapper, and proto regeneration steps are done consistently. ## Core Features & Use Cases - Entity Model Namespace Pattern: Defines the ready-made I<Entity> namespace with Api, State, and Draft types, plus short and full levels, capped at two levels of nesting. - Mapper Convention: Provides a BaseMapper heir per level using typeCast helpers, with no state and no DI, and explicit handling of finite string sets. - Proto Workflow: Covers what to do after editing .proto contracts, including buf lint, proto generation, and reserved field marking. - Use Case: When creating a new admin entity like a promo code, use this Skill to scaffold the model namespace, the short and full mappers, and regenerate the contract types correctly. ## Quick Start Declare a new entity model and its mapper for the promo code domain following the entity-models pattern.

Frequently Asked Questions about entity-models-new

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I declare a new entity model in an Angular domain library?

Create an I<Entity> namespace in the domain's util models file containing Api, State, and Draft types, with a nested Short namespace for list-level data. Keep nesting to two levels maximum and place domain enums outside the namespace in the same file.

How to write a model mapper with BaseMapper and typeCast?

Extend BaseMapper<State> and override mapFrom to convert the Api type using typeCast helpers like getAsString and getAsNumber. Create one mapper class per level, keep it stateless with no DI, and instantiate it directly with new.

What should I do after editing a .proto contract file?

Run npx buf lint in the proto library, then run the proto:generate npm script to regenerate types. Neither buf lint nor buf breaking runs in CI, so they must be executed by hand, and removed fields must be marked reserved with their number and name.

Why should mappers avoid null and undefined in State interfaces?

The convention expresses empty values as empty strings or zero instead of null or undefined, with a comment explaining the meaning of zero. Using ?? instead of typeCast misses default values returned by the contract, and as Type casts are forbidden.

When should an entity have a separate short level model?

Add a short level when the entity appears in list views needing only a subset of fields, declared as a nested Short namespace with its own Api alias and State interface. Each level gets its own mapper class, such as PromoCodeShortModelMapper and PromoCodeModelMapper.