refactor(routes): one supersession seam for REST and MCP; PUT/PATCH notes share a handler; shared mask/not-found/caller helpers (#2829, milestone 296 area 5)
CI & Build / Python lint (push) Successful in 3s
CI & Build / Plugin hooks (push) Successful in 9s
CI & Build / integration (push) Successful in 25s
CI & Build / TypeScript typecheck (push) Successful in 32s
CI & Build / Python tests (push) Failing after 37s
CI & Build / Build & push image (push) Skipped
CI & Build / Python lint (push) Successful in 3s
CI & Build / Plugin hooks (push) Successful in 9s
CI & Build / integration (push) Successful in 25s
CI & Build / TypeScript typecheck (push) Successful in 32s
CI & Build / Python tests (push) Failing after 37s
CI & Build / Build & push image (push) Skipped
Reading the 28 route modules against each other and against the MCP tools: - routes/notes.py carried a PUT and a PATCH handler that were the same function minus the supersedes contract on one of them — one handler now serves both verbs, so both carry it. - The two _attach_supersession copies (REST + MCP) become supersession_svc.attach_relations(uid, note_id, data, hint=) — the seam the two surfaces must agree through; only the agent surface adds the one-sentence reading hint. - Three local _uid() wrappers over g.user.id → scribe.auth.get_current_user_id like every other module; design_systems' private _not_found → routes.utils. not_found; the four "********" literals → settings_svc.SECRET_MASK with the read/write contract written once. - routes/plugin.py: the project_id/repo resolution block and the comma-separated id parse were copied into three endpoints — _project_scope() and _int_list() now. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,33 +1,30 @@
|
||||
"""Trash REST API — list / restore / purge soft-deleted content by batch."""
|
||||
from __future__ import annotations
|
||||
|
||||
from quart import Blueprint, g, jsonify
|
||||
from quart import Blueprint, jsonify
|
||||
|
||||
from scribe.auth import login_required
|
||||
from scribe.auth import get_current_user_id, login_required
|
||||
import scribe.services.trash as trash_svc
|
||||
|
||||
trash_bp = Blueprint("trash", __name__, url_prefix="/api/trash")
|
||||
|
||||
|
||||
def _uid() -> int:
|
||||
return g.user.id
|
||||
|
||||
|
||||
@trash_bp.get("")
|
||||
@login_required
|
||||
async def list_trash():
|
||||
return jsonify({"batches": await trash_svc.list_trash(_uid())})
|
||||
return jsonify({"batches": await trash_svc.list_trash(get_current_user_id())})
|
||||
|
||||
|
||||
@trash_bp.post("/<batch_id>/restore")
|
||||
@login_required
|
||||
async def restore_batch(batch_id: str):
|
||||
n = await trash_svc.restore(_uid(), batch_id)
|
||||
n = await trash_svc.restore(get_current_user_id(), batch_id)
|
||||
return jsonify({"restored": n})
|
||||
|
||||
|
||||
@trash_bp.delete("/<batch_id>")
|
||||
@login_required
|
||||
async def purge_batch(batch_id: str):
|
||||
n = await trash_svc.purge(_uid(), batch_id)
|
||||
n = await trash_svc.purge(get_current_user_id(), batch_id)
|
||||
return jsonify({"purged": n})
|
||||
|
||||
Reference in New Issue
Block a user