Module 02 Slice 3: per-doctor document sharing#17
Merged
Conversation
Adds an isolated describeWithDb block exercising the three new sub-paths under /documents/:id/shares — list, grant, revoke — plus auth/role guards. Fixtures cover two patients (ownership boundary), two doctors (GET shares result shape), and two seed documents. 17 new tests; all currently fail with 404 because the routes do not exist yet. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Backend
- Repository: findDocumentById, isUserDoctor, listDoctorAccessForDocument
(left join doctors → document_shares so every doctor appears with a
hasAccess flag), grantDocumentShare (ON CONFLICT DO NOTHING for
idempotency), revokeDocumentShare.
- Use cases: getSharingState, grantAccess, revokeAccess. Each loads the
doc and verifies ownership before any mutation; mutations also verify
the target user is a doctor (404 DOCTOR_NOT_FOUND otherwise).
- Routes: GET /documents/:id/shares, PUT and DELETE
/documents/:id/shares/:doctorId, all behind inline requireAuth +
requireRole(['patient']) since the parent /documents .use() does not
match sub-paths.
- Contracts: ts-rest entries for the three endpoints with UUID-validated
path params and proper error response shapes.
Web
- useDocumentShares + useGrantAccess + useRevokeAccess hooks: query keys
are scoped per document, mutations invalidate the matching key on
success so the panel reflects live state immediately.
- SharingPanel component: per-doctor toggle buttons. Button is disabled
while a mutation for that doctor is in flight; visual state mirrors
hasAccess.
- DocumentList: per-row "Manage sharing" toggle that expands to render
<SharingPanel documentId={...} />.
Closes #11. All 85 tests pass; pnpm verify clean.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
8 tasks
|
Claude finished @mGasiorek998's task in 2m 52s —— View job PR Review — Module 02 Slice 3 (per-doctor document sharing)Verdict: ✅ APPROVE Solid vertical slice. All AC from issue #11 are covered by code and tests, layering follows Spec compliance (issue #11)
Architecture
Security
Test quality
Suggestions (non-blocking)
· branch |
8 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #11
Summary
/documents/:id/shares(GET list, PUT grant, DELETE revoke), all behindrequireAuth()+requireRole(['patient'])inline (parent.use('/documents', ...)middleware does not match sub-paths in Hono).Test plan
pnpm verify— typecheck + 85 tests + lint all green./patient/documents: log in as a seeded patient, upload a doc, expand "Manage sharing", grant + revoke a doctor, verify the toggle reflects state.🤖 Generated with Claude Code