perf(dataflow): page scope references

This commit is contained in:
2026-07-30 01:30:27 +02:00
parent 5f3303fb21
commit d61e9d8942
2 changed files with 17 additions and 3 deletions
@@ -35,6 +35,7 @@ from govoplan_core.core.datasources import (
from govoplan_core.core.policy import (
CAPABILITY_POLICY_DEFINITION_GOVERNANCE,
)
from govoplan_core.core.references import CAPABILITY_ACCESS_REFERENCE_OPTIONS
from govoplan_core.core.search import SearchSourceProviderRegistration
from govoplan_core.core.views import ViewSurface
from govoplan_core.db.base import Base
@@ -255,6 +256,7 @@ manifest = ModuleManifest(
),
optional_capabilities=(
CAPABILITY_ACCESS_DIRECTORY,
CAPABILITY_ACCESS_REFERENCE_OPTIONS,
CAPABILITY_DATASOURCE_CATALOGUE,
CAPABILITY_DATASOURCE_LIFECYCLE,
CAPABILITY_DATASOURCE_PUBLICATION,
@@ -272,6 +274,12 @@ manifest = ModuleManifest(
),
),
requires_interfaces=(
ModuleInterfaceRequirement(
name=CAPABILITY_ACCESS_REFERENCE_OPTIONS,
version_min="0.1.0",
version_max_exclusive="0.2.0",
optional=True,
),
ModuleInterfaceRequirement(
name="datasources.catalogue",
version_min="0.1.0",
+9 -3
View File
@@ -26,7 +26,7 @@ from govoplan_core.core.datasources import (
datasource_lifecycle,
)
from govoplan_core.core.references import (
access_scope_reference_options,
access_scope_reference_page,
access_scope_reference_provider_available,
validate_access_scope_reference,
)
@@ -279,19 +279,23 @@ def api_scope_targets(
q: str = "",
selected: list[str] = Query(default=[]),
limit: int = Query(default=50, ge=1, le=200),
cursor: str | None = None,
session: Session = Depends(get_session),
principal: ApiPrincipal = Depends(get_api_principal),
) -> ReferenceOptionListResponse:
_require_any_scope(principal, READ_SCOPE, WRITE_SCOPE, ADMIN_SCOPE)
registry = get_registry()
try:
options = access_scope_reference_options(
page = access_scope_reference_page(
registry,
principal,
scope_type=scope_type,
query=q,
selected_values=selected,
limit=limit,
cursor=cursor,
administrative=has_scope(principal, ADMIN_SCOPE),
session=session,
)
except ValueError as exc:
raise HTTPException(
@@ -299,8 +303,10 @@ def api_scope_targets(
detail=str(exc),
) from exc
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),
next_cursor=page.next_cursor,
has_more=page.has_more,
)