Skip to content

feat(diet): extract shared artifacts for phase 2 - src/modules/diet/shared #1442

@marcuscastelo

Description

@marcuscastelo

reportedBy: github-copilot.v1/refine-github-issue

feat(diet): extract shared artifacts for phase 2 - src/modules/diet/shared

Objective

Create reusable artifacts (types, converters, and mappers) used by recent-food, template and the api/food routes without changing infrastructure layers (repositories/gateways). The artifacts must be forward-compatible with Phase 3.

Reference: docs/unify-phases-2-3.md

Scope / Proposed Implementation

  • Add a src/modules/diet/shared folder containing explicit, named exports only (no barrel index.ts files).
    • src/modules/diet/shared/types/templateTypes.ts — shared TypeScript types such as Template, TemplateItem and minimal runtime guards/validations (JSDoc required).
    • src/modules/diet/shared/converters/templateToItem.tstemplateToItem(template): Item converter (named export).
    • src/modules/diet/shared/mappers/recentFoodMapper.ts — reusable DB↔domain mappers (used by Supabase gateway).

Concrete tasks

  1. Create the shared files with JSDoc and named exports. Do not create barrel index.ts files.
  2. Update consumers in src/modules/diet/recent-food and src/modules/diet/template to import from the new shared paths.
  3. Update unit tests that reference moved types/mappers to point to the new paths and adjust imports.
  4. Run the full test suite and fix regressions.
  5. Document the new artifact locations in the diet module README and in docs/unify-phases-2-3.md (link back).

Priority symbols/files to migrate (examples)

  • src/modules/diet/template/domain/template.ts — migrate Template type and guards to shared/types.
  • src/modules/diet/template/application/templateToItem.ts — move or re-export the converter from shared/converters.
  • src/modules/diet/recent-food/infrastructure/supabase/supabaseRecentFoodMapper.ts — extract or re-use mappers in shared/mappers.
  • Optional: shared constants (e.g., src/modules/diet/recent-food/infrastructure/supabase/constants.ts) if truly shared.

Acceptance criteria

  • Full test suite passes (or regressions are documented and justified).
  • Consumers (recent-food, template, src/routes/api/food) import from src/modules/diet/shared.
  • No barrel index.ts files added; all imports are explicit.
  • PR contains a checklist and CI links.

PR checklist

  • Created shared files with JSDoc and named exports.
  • Updated imports across consumers.
  • Tests updated and passing locally.
  • CI green.
  • PR description includes rollback instructions (codemod revert if applicable).

Notes

See the planning document: docs/unify-phases-2-3.md for the full Phase 2 & Phase 3 plan and file inventory. The Phase 2 work is estimated at 3–7 days for a senior developer; risk: low–moderate.

Metadata

Metadata

Assignees

No one assigned

    Labels

    complexity-mediumMedium implementation complexitydomainDomain logic or business rulesfeatureRequest or implement a new feature

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions