feat(user) Expose embedded users as CompactUserDto in comments, ratings, tags and meal plan shares (spec 003) #32
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "003-compact-user-in-embedded-dtos"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Spec 003: docs/features/003-compact-user-in-embedded-dtos.md (recipe-platform#22). Contract PR: recipe-platform#46.
Plan: docs/plans/003-compact-user-in-embedded-dtos.md
CommentDto.createdByUser,RatingDto.createdByUser,EnrichedTagDto.createdByUserandMealPlanShareDto.sharedWithUserare now built asCompactUserDto(id, user name, first and last name, avatar). Email and role of the embedded user no longer leave the API in these responses, also when that user is the caller or the caller is an admin. Besides email and role, the embedded user'screatedAt,updatedAt,versionandcreatedByare gone, and a name that is not set is an absent key instead ofnull.What was implemented
contract.ref→0f2e4006995362d60686ce328c1edbb292188ed3CommentDtoEntityMapper,RatingDtoEntityMapper,EnrichedTagMapper,MealPlanShareDtoEntityMappertakeCompactUserMapperinstead ofUserDtoEntityMapper; JSDoc and inline comments updated. Mapping logic and guards unchangedComment,Rating,Tag,MealPlan,Recipe,AiRecipeGeneration) build and pass aCompactUserMappertoEqualon the exact compact object, plus explicit"email" in/"role" inchecks.RecipeDtoEntityMapper.test.tsandMealPlanDtoEntityMapper.test.tscover the embedded case (comment and rating inside a recipe, share inside a meal plan). 9 new testsTagApplicationService, the two entities and three bullets ofdocs/architecture.mdNo route, repository query, handler or Bruno file changed.
UserDtoEntityMapperand everything behind/user/me, login, passkey login and admin user management are untouched; their tests are unedited and green.Deviations from the plan
One, recorded in the plan's Deviations section, decided in the implementation:
RecipeRepository.findById()reworded. The plan puts repositories out of scope, but its own check (grepfor "full user object" insrcreturns nothing) finds this JSDoc line. It is reworded like the others. Comment only, no change to the query.Judgment calls
EXPECTED_COMPACT_USERconstant instead of repeating the literal in every assertion.EnrichedTagMapperonly;CommentDtoEntityMapper's constructor got a one-line@paramJSDoc as well, since the class was being documented anyway.Verification
../recipe-platformon0f2e400npm run buildnpm testtsc; checked with a temporary tsconfig)grepof step 3:UserDtoEntityMapperoutside testsCompactUserMapper.ts,AuthHandler.ts,AuthHandlerFactory.ts,PasskeyApplicationService.ts,PasskeyServiceFactory.ts,UserApplicationService.ts,UserServiceFactory.ts(and its own file)grepof step 5npm run test:integrationNot verified: the responses of a running server were not called; the evidence is the mapper tests.
The
contract_pincheck stays red until the contract PR (recipe-platform#46) is merged; it has to be re-run then.🤖 Generated with Claude Code
WIP: feat(user) Expose embedded users as CompactUserDto in comments, ratings, tags and meal plan shares (spec 003)to feat(user) Expose embedded users as CompactUserDto in comments, ratings, tags and meal plan shares (spec 003)