feat: add uncached option to data structures and update use cases for cache invalidation#1775
Conversation
… cache invalidation
📝 WalkthroughWalkthroughThis PR adds an optional ChangesUncached Metadata Cache Flag
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 6✅ Passed checks (6 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
ESLint skipped: no ESLint configuration detected in root package.json. To enable, add Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Pull request overview
This PR adds an opt-in _uncached query parameter to several table row endpoints, allowing API consumers to invalidate the DAO's metadata cache before reading or mutating rows. The flag is propagated from the controller through new optional uncached fields on the use case data structures, and the controller strips the reserved query param so it isn't mistaken for a primary-key column value (the underscore prefix further reduces the chance of column-name collisions).
Changes:
- Add
uncached?: booleanto theGetRowByPrimaryKeyDs,UpdateRowInTableDs, andDeleteRowFromTableDsdata structures, and invalidate the DAO metadata cache in the corresponding use cases when the flag is set. - In
TableController, rename the query parameter to_uncached, document it via@ApiQuery, wire it through thegetPrimaryKeys, update, delete, and get-by-primary-key flows, and invalidate the DAO cache ingetPrimaryKeyswhen requested. - Introduce
stripReservedQueryParamsto remove_uncachedfrom the query map before it is used for primary-key lookup or downstream filtering.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| backend/src/entities/table/application/data-structures/get-row-by-primary-key.ds.ts | Adds optional uncached flag to the DS. |
| backend/src/entities/table/application/data-structures/update-row-in-table.ds.ts | Adds optional uncached flag to the DS. |
| backend/src/entities/table/application/data-structures/delete-row-from-table.ds.ts | Adds optional uncached flag to the DS. |
| backend/src/entities/table/use-cases/get-row-by-primary-key.use.case.ts | Invalidates DAO metadata cache when uncached is set. |
| backend/src/entities/table/use-cases/update-row-in-table.use.case.ts | Invalidates DAO metadata cache when uncached is set. |
| backend/src/entities/table/use-cases/delete-row-from-table.use.case.ts | Invalidates DAO metadata cache when uncached is set. |
| backend/src/entities/table/table.controller.ts | Renames query param to _uncached, strips it from query maps, and threads the flag into use cases and getPrimaryKeys. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
🧹 Nitpick comments (1)
backend/src/entities/table/application/data-structures/delete-row-from-table.ds.ts (1)
10-16: Consider extendinguncachedsupport to bulk operations.The single-row
DeleteRowFromTableDsnow supportsuncached, butDeleteRowsFromTableDs(used for bulk deletes) does not. Similarly, bulk update operations lack this flag. If users need fresh metadata during bulk operations, they currently have no mechanism to invalidate the cache.Consider whether bulk delete/update endpoints should also accept the
_uncachedquery parameter for consistency and to support cache invalidation in batch scenarios.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@backend/src/entities/table/application/data-structures/delete-row-from-table.ds.ts` around lines 10 - 16, DeleteRowsFromTableDs currently lacks the uncached flag used by single-row deletes, so bulk delete endpoints can't request fresh metadata; add an optional boolean property named `_uncached?: boolean` (or `uncached?: boolean` to match existing naming) to the DeleteRowsFromTableDs class to mirror DeleteRowFromTableDs, update any related bulk-update DTO/classes (e.g., the bulk update data-structure) to include the same optional flag, and ensure request handling code reads this field to respect the `_uncached` query param for cache invalidation during bulk operations.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In
`@backend/src/entities/table/application/data-structures/delete-row-from-table.ds.ts`:
- Around line 10-16: DeleteRowsFromTableDs currently lacks the uncached flag
used by single-row deletes, so bulk delete endpoints can't request fresh
metadata; add an optional boolean property named `_uncached?: boolean` (or
`uncached?: boolean` to match existing naming) to the DeleteRowsFromTableDs
class to mirror DeleteRowFromTableDs, update any related bulk-update DTO/classes
(e.g., the bulk update data-structure) to include the same optional flag, and
ensure request handling code reads this field to respect the `_uncached` query
param for cache invalidation during bulk operations.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 2e02d806-8d60-42c1-a2f2-dfb06501539b
📒 Files selected for processing (7)
backend/src/entities/table/application/data-structures/delete-row-from-table.ds.tsbackend/src/entities/table/application/data-structures/get-row-by-primary-key.ds.tsbackend/src/entities/table/application/data-structures/update-row-in-table.ds.tsbackend/src/entities/table/table.controller.tsbackend/src/entities/table/use-cases/delete-row-from-table.use.case.tsbackend/src/entities/table/use-cases/get-row-by-primary-key.use.case.tsbackend/src/entities/table/use-cases/update-row-in-table.use.case.ts
Summary by CodeRabbit
New Features
_uncachedquery parameter support for row operations (delete, update, fetch by primary key, and find all rows) to provide control over metadata cache behavior.Chores