perf(workflow): page scope references

This commit is contained in:
2026-07-30 01:30:38 +02:00
parent c45e2b808c
commit a1654e70cf
2 changed files with 17 additions and 3 deletions
@@ -28,6 +28,7 @@ from govoplan_core.core.modules import (
from govoplan_core.core.policy import ( from govoplan_core.core.policy import (
CAPABILITY_POLICY_DEFINITION_GOVERNANCE, CAPABILITY_POLICY_DEFINITION_GOVERNANCE,
) )
from govoplan_core.core.references import CAPABILITY_ACCESS_REFERENCE_OPTIONS
from govoplan_core.core.views import CAPABILITY_VIEWS_RESOLVER from govoplan_core.core.views import CAPABILITY_VIEWS_RESOLVER
from govoplan_core.db.base import Base from govoplan_core.db.base import Base
from govoplan_workflow.backend.db import models as workflow_models from govoplan_workflow.backend.db import models as workflow_models
@@ -139,6 +140,7 @@ manifest = ModuleManifest(
), ),
optional_capabilities=( optional_capabilities=(
CAPABILITY_ACCESS_DIRECTORY, CAPABILITY_ACCESS_DIRECTORY,
CAPABILITY_ACCESS_REFERENCE_OPTIONS,
CAPABILITY_AUTH_PRINCIPAL_RESOLVER, CAPABILITY_AUTH_PRINCIPAL_RESOLVER,
CAPABILITY_AUTH_PERMISSION_EVALUATOR, CAPABILITY_AUTH_PERMISSION_EVALUATOR,
CAPABILITY_DATAFLOW_RUN_LIFECYCLE, CAPABILITY_DATAFLOW_RUN_LIFECYCLE,
@@ -151,6 +153,12 @@ manifest = ModuleManifest(
ModuleInterfaceProvider(name="workflow.definition_catalogue", version="0.1.0"), ModuleInterfaceProvider(name="workflow.definition_catalogue", version="0.1.0"),
), ),
requires_interfaces=( requires_interfaces=(
ModuleInterfaceRequirement(
name=CAPABILITY_ACCESS_REFERENCE_OPTIONS,
version_min="0.1.0",
version_max_exclusive="0.2.0",
optional=True,
),
ModuleInterfaceRequirement( ModuleInterfaceRequirement(
name="dataflow.run_lifecycle", name="dataflow.run_lifecycle",
version_min="0.1.14", version_min="0.1.14",
+9 -3
View File
@@ -10,7 +10,7 @@ from govoplan_core.api.v1.schemas import (
from govoplan_core.audit.logging import audit_event from govoplan_core.audit.logging import audit_event
from govoplan_core.auth import ApiPrincipal, get_api_principal, has_scope from govoplan_core.auth import ApiPrincipal, get_api_principal, has_scope
from govoplan_core.core.references import ( from govoplan_core.core.references import (
access_scope_reference_options, access_scope_reference_page,
access_scope_reference_provider_available, access_scope_reference_provider_available,
validate_access_scope_reference, validate_access_scope_reference,
) )
@@ -225,6 +225,8 @@ def api_scope_targets(
q: str = "", q: str = "",
selected: list[str] = Query(default=[]), selected: list[str] = Query(default=[]),
limit: int = Query(default=50, ge=1, le=200), limit: int = Query(default=50, ge=1, le=200),
cursor: str | None = None,
session: Session = Depends(get_session),
principal: ApiPrincipal = Depends(get_api_principal), principal: ApiPrincipal = Depends(get_api_principal),
) -> ReferenceOptionListResponse: ) -> ReferenceOptionListResponse:
_require_any_scope( _require_any_scope(
@@ -235,14 +237,16 @@ def api_scope_targets(
) )
registry = get_registry() registry = get_registry()
try: try:
options = access_scope_reference_options( page = access_scope_reference_page(
registry, registry,
principal, principal,
scope_type=scope_type, scope_type=scope_type,
query=q, query=q,
selected_values=selected, selected_values=selected,
limit=limit, limit=limit,
cursor=cursor,
administrative=has_scope(principal, ADMIN_SCOPE), administrative=has_scope(principal, ADMIN_SCOPE),
session=session,
) )
except ValueError as exc: except ValueError as exc:
raise HTTPException( raise HTTPException(
@@ -250,8 +254,10 @@ def api_scope_targets(
detail=str(exc), detail=str(exc),
) from exc ) from exc
return ReferenceOptionListResponse( return ReferenceOptionListResponse(
options=[ReferenceOptionResponse(**item.to_dict()) for item in options], options=[ReferenceOptionResponse(**item.to_dict()) for item in page.options],
provider_available=access_scope_reference_provider_available(registry), provider_available=access_scope_reference_provider_available(registry),
next_cursor=page.next_cursor,
has_more=page.has_more,
) )