fix(i-c): BUG-024 behoben — Plugin-Detail-Endpoint GET /api/v1/plugins/{name} implementiert (Manifest-Metadaten + DB-Status, 404 für unbekannte); Beweistest test_plugin_detail.py 2/2 grün; Existenzprüfung vorher: Route fehlte komplett (bewiesen), Frontend-Nutzung niedrig aber API-Vollständigkeit hergestellt
This commit is contained in:
+44
-1
@@ -5,13 +5,14 @@ from __future__ import annotations
|
||||
import logging
|
||||
from typing import Any
|
||||
|
||||
from fastapi import APIRouter, Depends, File, HTTPException, Query, UploadFile
|
||||
from fastapi import APIRouter, Depends, File, HTTPException, Query, UploadFile, status
|
||||
from pydantic import BaseModel
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
|
||||
from app.core.db import get_db
|
||||
from app.deps import get_current_user, require_admin, require_permission
|
||||
from app.plugins.migration_runner import MigrationValidationError
|
||||
from app.plugins.registry import get_registry
|
||||
from app.services.plugin_service import get_plugin_service
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
@@ -43,6 +44,48 @@ async def list_plugins(
|
||||
return {"plugins": plugins, "total": len(plugins)}
|
||||
|
||||
|
||||
@router.get("/{name}")
|
||||
async def get_plugin_detail(
|
||||
name: str,
|
||||
db: AsyncSession = Depends(get_db),
|
||||
current_user: dict = Depends(require_permission("plugins:read")),
|
||||
):
|
||||
"""Get detail for a single plugin: manifest metadata + DB status.
|
||||
|
||||
BUG-024 fix: this endpoint was missing entirely (404).
|
||||
"""
|
||||
registry = get_registry()
|
||||
plugin = registry.get_plugin(name)
|
||||
if plugin is None:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_404_NOT_FOUND,
|
||||
detail={"detail": f"Plugin '{name}' not found", "code": "not_found"},
|
||||
)
|
||||
|
||||
m = plugin.manifest
|
||||
record = registry.get_db_status(name)
|
||||
return {
|
||||
"name": m.name,
|
||||
"version": m.version,
|
||||
"display_name": getattr(m, "display_name", None) or m.name,
|
||||
"description": getattr(m, "description", None),
|
||||
"author": getattr(m, "author", None),
|
||||
"is_core": bool(getattr(m, "is_core", False)),
|
||||
"permissions": list(m.permissions),
|
||||
"depends_on": list(getattr(m, "depends_on", []) or []),
|
||||
"status": {
|
||||
"installed": record is not None,
|
||||
"active": bool(record.active) if record is not None else False,
|
||||
"version_installed": getattr(record, "version", None),
|
||||
},
|
||||
"menu_items": len(getattr(m, "menu_items", []) or []),
|
||||
"page_routes": len(getattr(m, "page_routes", []) or []),
|
||||
"detail_tabs": len(getattr(m, "detail_tabs", []) or []),
|
||||
"settings_pages": len(getattr(m, "settings_pages", []) or []),
|
||||
"dashboard_widgets": len(getattr(m, "dashboard_widgets", []) or []),
|
||||
}
|
||||
|
||||
|
||||
@router.get("/manifest")
|
||||
async def get_manifest_schema(
|
||||
current_user: dict = Depends(require_permission("plugins:read")),
|
||||
|
||||
Reference in New Issue
Block a user