feat(backend): add draft validation endpoint with stale version guard
add backend endpoint for draft validation protect validation requests against stale version state keep draft checks version-aware and consistent with mutation flows
This commit is contained in:
@@ -56,6 +56,7 @@ from app.services.editor_validation import (
|
|||||||
validate_single_seat_patch_references,
|
validate_single_seat_patch_references,
|
||||||
validate_single_seat_patch_uniqueness,
|
validate_single_seat_patch_uniqueness,
|
||||||
)
|
)
|
||||||
|
from app.services.scheme_validation import build_scheme_validation_report
|
||||||
from app.services.structure_diff import build_structure_diff
|
from app.services.structure_diff import build_structure_diff
|
||||||
from app.services.structure_sync import repair_structure_references
|
from app.services.structure_sync import repair_structure_references
|
||||||
|
|
||||||
@@ -131,6 +132,28 @@ async def get_draft_structure(
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@router.get(f"{settings.api_v1_prefix}/schemes/{{scheme_id}}/draft/validation")
|
||||||
|
async def get_draft_validation(
|
||||||
|
scheme_id: str,
|
||||||
|
expected_scheme_version_id: str | None = Query(default=None),
|
||||||
|
role: str = Depends(require_api_key),
|
||||||
|
):
|
||||||
|
scheme, version = await get_current_draft_context(
|
||||||
|
scheme_id,
|
||||||
|
expected_scheme_version_id=expected_scheme_version_id,
|
||||||
|
)
|
||||||
|
report = await build_scheme_validation_report(
|
||||||
|
scheme_id=scheme.scheme_id,
|
||||||
|
scheme_version_id=version.scheme_version_id,
|
||||||
|
)
|
||||||
|
return {
|
||||||
|
"scheme_id": scheme.scheme_id,
|
||||||
|
"scheme_version_id": version.scheme_version_id,
|
||||||
|
"status": version.status,
|
||||||
|
"report": report,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@router.get(f"{settings.api_v1_prefix}/schemes/{{scheme_id}}/draft/compare-preview", response_model=StructureDiffResponse)
|
@router.get(f"{settings.api_v1_prefix}/schemes/{{scheme_id}}/draft/compare-preview", response_model=StructureDiffResponse)
|
||||||
async def get_draft_compare_preview(
|
async def get_draft_compare_preview(
|
||||||
scheme_id: str,
|
scheme_id: str,
|
||||||
|
|||||||
Reference in New Issue
Block a user