Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 6, 2025

Infrastructure files in recent-food were exporting internal helper functions alongside their factories, violating encapsulation.

Changes

recentFoodRepository.ts

  • Removed export from 5 helper functions: fetchByUserTypeAndReferenceId, fetchUserRecentFoodsAsTemplates, insert, update, deleteByReference
  • Functions now file-local, accessible only through createRecentFoodRepository() factory

Other files (supabaseRecentFoodGateway.ts, supabaseRecentFoodMapper.ts, recentFoodCacheStore.ts, realtime.ts)

  • Already compliant — only factories/objects exported

Before/After

// Before: Helper functions exposed
import { fetchByUserTypeAndReferenceId, createRecentFoodRepository } from './recentFoodRepository'

// After: Only factory exposed
import { createRecentFoodRepository } from './recentFoodRepository'
const repo = createRecentFoodRepository()
repo.fetchByUserTypeAndReferenceId(...)

Application layer already uses factories correctly — no call-site changes needed.

Part of #1403

Original prompt

This section details on the original issue you should resolve

<issue_title>recent-food: Encapsulate infra exports — export only factories</issue_title>
<issue_description>## Summary

Refactor the recent-food module infrastructure to encapsulate implementation details: export only factory functions and keep helper functions file-local.

Part of #1403

Scope / Representative files

  • src/modules/recent-food/infrastructure/recentFoodRepository.ts
  • src/modules/recent-food/infrastructure/supabase/supabaseRecentFoodGateway.ts
  • src/modules/recent-food/infrastructure/supabase/supabaseRecentFoodMapper.ts
  • src/modules/recent-food/infrastructure/signals/recentFoodCacheStore.ts
  • src/modules/recent-food/infrastructure/supabase/realtime.ts

Deliverables

  • Implementation files export only factories (e.g., createRecentFoodRepository, createSupabaseRecentFoodGateway).
  • Internal helper functions removed from exports.
  • All call-sites import factories and use repository/gateway instances.
  • TypeScript/lint/tests pass for the module.

Acceptance Criteria

  • No named exports for internal helpers remain in the module infra files.
  • Call sites updated and compile cleanly.
    </issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@vercel
Copy link

vercel bot commented Dec 6, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
macroflows Ready Ready Preview Comment Dec 6, 2025 6:44pm

…Repository

Co-authored-by: marcuscastelo <27441558+marcuscastelo@users.noreply.github.com>
Copilot AI changed the title [WIP] Encapsulate infra exports in recent-food module refactor(recent-food): Encapsulate infrastructure — export only factories Dec 6, 2025
Copilot AI requested a review from marcuscastelo December 6, 2025 18:44
@marcuscastelo marcuscastelo marked this pull request as ready for review December 6, 2025 19:02
Copilot AI review requested due to automatic review settings December 6, 2025 19:02
@marcuscastelo marcuscastelo merged commit 3376451 into marcuscastelo/issue1447-remove-shims Dec 6, 2025
10 checks passed
@marcuscastelo marcuscastelo deleted the copilot/refactor-recent-food-infra-exports branch December 6, 2025 19:03
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors the recent-food infrastructure layer to enforce proper encapsulation by removing export keywords from internal helper functions in recentFoodRepository.ts. The five helper functions (fetchByUserTypeAndReferenceId, fetchUserRecentFoodsAsTemplates, insert, update, deleteByReference) are now file-local and accessible only through the createRecentFoodRepository() factory, which returns an object implementing the RecentFoodRepository interface.

Key changes:

  • Removed export from 5 helper functions in recentFoodRepository.ts, making them file-local
  • Maintained factory pattern where createRecentFoodRepository() is the only public export
  • No breaking changes—application layer already uses the factory correctly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants