feat(backend): add publish readiness contract and guarded publish flow
add backend readiness contract for publish prechecks guard publish flow with explicit validation and version-aware checks make publish behavior more predictable for clients and safer against stale state
This commit is contained in:
@@ -18,7 +18,7 @@ from app.repositories.schemes import (
|
||||
rollback_scheme_to_version,
|
||||
unpublish_scheme,
|
||||
)
|
||||
from app.schemas.publish_readiness import SchemePublishActionResponse
|
||||
from app.schemas.publish_readiness import PublishExecutionResponse
|
||||
from app.schemas.scheme_registry import (
|
||||
SchemeCurrentResponse,
|
||||
SchemeDetailResponse,
|
||||
@@ -217,17 +217,18 @@ async def get_publish_validation(scheme_id: str, role: str = Depends(require_api
|
||||
|
||||
@router.post(
|
||||
f"{settings.api_v1_prefix}/schemes/{{scheme_id}}/publish",
|
||||
response_model=SchemePublishActionResponse,
|
||||
response_model=PublishExecutionResponse,
|
||||
)
|
||||
async def publish_scheme_endpoint(
|
||||
scheme_id: str,
|
||||
expected_scheme_version_id: str | None = Query(default=None),
|
||||
role: str = Depends(require_api_key),
|
||||
):
|
||||
return await publish_current_draft_scheme(
|
||||
result = await publish_current_draft_scheme(
|
||||
scheme_id=scheme_id,
|
||||
expected_scheme_version_id=expected_scheme_version_id,
|
||||
)
|
||||
return PublishExecutionResponse(**result)
|
||||
|
||||
|
||||
@router.post(f"{settings.api_v1_prefix}/schemes/{{scheme_id}}/unpublish", response_model=SchemePublishResponse)
|
||||
|
||||
Reference in New Issue
Block a user