perf(dataflow): page scope references
This commit is contained in:
@@ -35,6 +35,7 @@ from govoplan_core.core.datasources 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.search import SearchSourceProviderRegistration
|
from govoplan_core.core.search import SearchSourceProviderRegistration
|
||||||
from govoplan_core.core.views import ViewSurface
|
from govoplan_core.core.views import ViewSurface
|
||||||
from govoplan_core.db.base import Base
|
from govoplan_core.db.base import Base
|
||||||
@@ -255,6 +256,7 @@ manifest = ModuleManifest(
|
|||||||
),
|
),
|
||||||
optional_capabilities=(
|
optional_capabilities=(
|
||||||
CAPABILITY_ACCESS_DIRECTORY,
|
CAPABILITY_ACCESS_DIRECTORY,
|
||||||
|
CAPABILITY_ACCESS_REFERENCE_OPTIONS,
|
||||||
CAPABILITY_DATASOURCE_CATALOGUE,
|
CAPABILITY_DATASOURCE_CATALOGUE,
|
||||||
CAPABILITY_DATASOURCE_LIFECYCLE,
|
CAPABILITY_DATASOURCE_LIFECYCLE,
|
||||||
CAPABILITY_DATASOURCE_PUBLICATION,
|
CAPABILITY_DATASOURCE_PUBLICATION,
|
||||||
@@ -272,6 +274,12 @@ manifest = ModuleManifest(
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
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="datasources.catalogue",
|
name="datasources.catalogue",
|
||||||
version_min="0.1.0",
|
version_min="0.1.0",
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ from govoplan_core.core.datasources import (
|
|||||||
datasource_lifecycle,
|
datasource_lifecycle,
|
||||||
)
|
)
|
||||||
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,
|
||||||
)
|
)
|
||||||
@@ -279,19 +279,23 @@ 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(principal, READ_SCOPE, WRITE_SCOPE, ADMIN_SCOPE)
|
_require_any_scope(principal, READ_SCOPE, WRITE_SCOPE, ADMIN_SCOPE)
|
||||||
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(
|
||||||
@@ -299,8 +303,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,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user