feat: type stateless draft results

This commit is contained in:
lda
2026-08-01 08:27:47 +07:00 Verified
parent 3891a62138
commit fbcd3a61a5
12 changed files with 338 additions and 63 deletions
+4 -4
View File
@@ -4,8 +4,6 @@ Return annotations stay eagerly evaluated because fastapi-jsonrpc captures them
while registering nested handlers for response validation and OpenRPC output.
"""
from typing import Any
import fastapi_jsonrpc as jsonrpc
from wf_api.models import (
@@ -15,6 +13,8 @@ from wf_api.models import (
DeleteDraftWorkspaceResult,
DraftWorkspaceResult,
ListDraftWorkspacesResult,
PatchDraftResult,
ValidateDraftResult,
)
from wf_api.surface import RouteSource
from wf_server import WorkflowServer
@@ -77,7 +77,7 @@ def register_methods(
@entrypoint.method(name="workflow.drafts.patch", errors=[WorkflowRpcError])
async def workflow_drafts_patch(
params: PatchDraftParams = RpcParams(),
) -> dict[str, Any]:
) -> PatchDraftResult:
try:
return await server.api.patch_draft(draft=params.draft, patch=params.patch)
except (ValueError, KeyError, LookupError, FileNotFoundError) as exc:
@@ -86,7 +86,7 @@ def register_methods(
@entrypoint.method(name="workflow.drafts.validate", errors=[WorkflowRpcError])
async def workflow_drafts_validate(
params: ValidateDraftParams = RpcParams(),
) -> dict[str, Any]:
) -> ValidateDraftResult:
try:
return await server.api.validate_draft(draft=params.draft)
except (ValueError, KeyError, LookupError, FileNotFoundError) as exc: