You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As a homeowner, I want to add notes and checklist subtasks to work items so that I can track detailed progress and record important information for each construction task.
1. POST /api/work-items/:workItemId/notes creates a new note on a work item and returns 201. Required field: content (text, non-empty). The createdBy field is automatically set to the authenticated user. Returns 404 NOT_FOUND if the work item does not exist.
2. GET /api/work-items/:workItemId/notes returns all notes for a work item (200 OK), sorted by created_at descending (newest first). Each note includes id, content, createdBy (user summary: { id, displayName }), createdAt, updatedAt.
3. PATCH /api/work-items/:workItemId/notes/:noteId updates a note's content (200 OK). Only the note's author or an admin can edit a note. Returns 403 FORBIDDEN if a non-admin user tries to edit another user's note. Returns 404 NOT_FOUND if the note or work item does not exist.
4. DELETE /api/work-items/:workItemId/notes/:noteId deletes a note (204 No Content). Only the note's author or an admin can delete a note. Returns 403 FORBIDDEN if unauthorized. Returns 404 NOT_FOUND if the note or work item does not exist.
Subtasks
5. POST /api/work-items/:workItemId/subtasks creates a new subtask and returns 201. Required field: title (text, non-empty). Optional field: sortOrder (integer). If sortOrder is not provided, the subtask is appended to the end (max sort_order + 1). Returns 404 NOT_FOUND if the work item does not exist.
6. GET /api/work-items/:workItemId/subtasks returns all subtasks for a work item (200 OK), sorted by sort_order ascending.
7. PATCH /api/work-items/:workItemId/subtasks/:subtaskId updates a subtask's title, completion status (isCompleted), and/or sort order (200 OK). Returns 404 NOT_FOUND if the subtask or work item does not exist.
8. DELETE /api/work-items/:workItemId/subtasks/:subtaskId deletes a subtask (204 No Content). Returns 404 NOT_FOUND if the subtask or work item does not exist.
9. PATCH /api/work-items/:workItemId/subtasks/reorder accepts an ordered array of subtask IDs and updates the sort_order of each subtask to match the array order (200 OK). Returns 400 VALIDATION_ERROR if any subtask ID does not belong to the specified work item.
Cross-cutting
10. All endpoints require authentication (401 UNAUTHORIZED without valid session). Both admin and member roles can manage notes and subtasks.
As a homeowner, I want to add notes and checklist subtasks to work items so that I can track detailed progress and record important information for each construction task.
Parent Epic: #3
Priority: Must Have
Acceptance Criteria
Notes
POST /api/work-items/:workItemId/notescreates a new note on a work item and returns 201. Required field:content(text, non-empty). ThecreatedByfield is automatically set to the authenticated user. Returns 404NOT_FOUNDif the work item does not exist.GET /api/work-items/:workItemId/notesreturns all notes for a work item (200 OK), sorted bycreated_atdescending (newest first). Each note includesid,content,createdBy(user summary:{ id, displayName }),createdAt,updatedAt.PATCH /api/work-items/:workItemId/notes/:noteIdupdates a note's content (200 OK). Only the note's author or an admin can edit a note. Returns 403FORBIDDENif a non-admin user tries to edit another user's note. Returns 404NOT_FOUNDif the note or work item does not exist.DELETE /api/work-items/:workItemId/notes/:noteIddeletes a note (204 No Content). Only the note's author or an admin can delete a note. Returns 403FORBIDDENif unauthorized. Returns 404NOT_FOUNDif the note or work item does not exist.Subtasks
POST /api/work-items/:workItemId/subtaskscreates a new subtask and returns 201. Required field:title(text, non-empty). Optional field:sortOrder(integer). IfsortOrderis not provided, the subtask is appended to the end (max sort_order + 1). Returns 404NOT_FOUNDif the work item does not exist.GET /api/work-items/:workItemId/subtasksreturns all subtasks for a work item (200 OK), sorted bysort_orderascending.PATCH /api/work-items/:workItemId/subtasks/:subtaskIdupdates a subtask's title, completion status (isCompleted), and/or sort order (200 OK). Returns 404NOT_FOUNDif the subtask or work item does not exist.DELETE /api/work-items/:workItemId/subtasks/:subtaskIddeletes a subtask (204 No Content). Returns 404NOT_FOUNDif the subtask or work item does not exist.PATCH /api/work-items/:workItemId/subtasks/reorderaccepts an ordered array of subtask IDs and updates thesort_orderof each subtask to match the array order (200 OK). Returns 400VALIDATION_ERRORif any subtask ID does not belong to the specified work item.Cross-cutting
UNAUTHORIZEDwithout valid session). Both admin and member roles can manage notes and subtasks.VALIDATION_ERRORfor: empty content/title, non-integer sort_order.Notes
createdByFK uses SET NULL on delete so that notes remain even if the creating user is removed.