PROJ-238, 237, 374, 234: wiki folders, delete semantics, attachments MCP parity, comments authz fix#127
Merged
Merged
Conversation
The ForbiddenError guard already shipped in 5f95e62 but had no test covering it and the ticket was never closed.
- Move all attachments business logic + raw SQL out of routes/files.ts into services/files.ts + schemas/files.ts, per the service-layer contract. R2 object I/O (streaming put/get/delete) stays in the route. - Add two typed errors (PayloadTooLargeError, UnsupportedMediaTypeError) so the 413/415 REST responses still come from the service layer via the standard error-adapter pattern. - Add mcp/files.ts: list_attachments, get_attachment, create_link_attachment, delete_attachment. Binary upload/download remain REST-only (documented as a deliberate parity exception in AGENTS.md); delete_attachment also cleans up the R2 object so the MCP path doesn't orphan storage. - Wire into routes/mcp.ts + mcp/catalog.ts, regenerate the tool catalog. - Add MCP round-trip tests and extend files.test.ts; all existing REST behavior/status codes preserved (30/30 files.test.ts, 820/825 full API suite).
Adds a Move button to the page header that opens a parent-page picker and PUTs the new parentId. Backend already enforces cycle/scope validation on PUT /api/wiki/:slug.
wiki_pages.parent_id has no FK constraint, so deleting a page left children pointing at a row that no longer existed. Default behavior now promotes children to the deleted page's parent; an explicit cascade=true (REST query param, MCP tool arg) deletes the whole subtree instead, using inChunks to stay under D1's bound-parameter limit. Regenerated the MCP tool catalog for the schema change.
Fixes an Opus-review finding: opening Move then clicking Edit (or Create) left both forms mounted since only navigateTo reset move state.
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.
Summary
routes/files.ts's business logic intoservices/files.ts; addsPayloadTooLargeError/UnsupportedMediaTypeErrortyped errors (413/415); gives attachments MCP parity (list_attachments,get_attachment,create_link_attachment,delete_attachment) with R2 cleanup on delete.parentId. Tree nav, create-under, and breadcrumbs were already implemented in prior work.parent_idbug on wiki page delete (no FK constraint exists). Default now promotes children to the deleted page's parent;cascade=true(REST query param / MCP arg) deletes the whole subtree, chunked to respect D1's bound-parameter limit.An Opus-model review pass was run over the full batched diff before merge — no blocking issues found. Two non-blocking findings were filed as follow-up tickets: PROJ-425 (attachments have no viewer/write authz gate, now reachable via the new MCP tools) and PROJ-426 (wiki page delete orphans R2 blobs for file attachments).
Test plan
pnpm --filter @projektor/api test— 824/824 passed (5 pre-existing todo)pnpm --filter @projektor/web test— 379/379 passedpnpm turbo type-check— clean across all packagespnpm --filter @projektor/web build— succeedsrtk proxy pnpm lint(biome) — clean🤖 Generated with Claude Code