diff --git a/src/govoplan_workflow/backend/manifest.py b/src/govoplan_workflow/backend/manifest.py index db0df35..8402aa7 100644 --- a/src/govoplan_workflow/backend/manifest.py +++ b/src/govoplan_workflow/backend/manifest.py @@ -28,6 +28,7 @@ from govoplan_core.core.modules 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.views import CAPABILITY_VIEWS_RESOLVER from govoplan_core.db.base import Base from govoplan_workflow.backend.db import models as workflow_models @@ -139,6 +140,7 @@ manifest = ModuleManifest( ), optional_capabilities=( CAPABILITY_ACCESS_DIRECTORY, + CAPABILITY_ACCESS_REFERENCE_OPTIONS, CAPABILITY_AUTH_PRINCIPAL_RESOLVER, CAPABILITY_AUTH_PERMISSION_EVALUATOR, CAPABILITY_DATAFLOW_RUN_LIFECYCLE, @@ -151,6 +153,12 @@ manifest = ModuleManifest( ModuleInterfaceProvider(name="workflow.definition_catalogue", version="0.1.0"), ), requires_interfaces=( + ModuleInterfaceRequirement( + name=CAPABILITY_ACCESS_REFERENCE_OPTIONS, + version_min="0.1.0", + version_max_exclusive="0.2.0", + optional=True, + ), ModuleInterfaceRequirement( name="dataflow.run_lifecycle", version_min="0.1.14", diff --git a/src/govoplan_workflow/backend/router.py b/src/govoplan_workflow/backend/router.py index 13ecfa7..20674b7 100644 --- a/src/govoplan_workflow/backend/router.py +++ b/src/govoplan_workflow/backend/router.py @@ -10,7 +10,7 @@ from govoplan_core.api.v1.schemas import ( from govoplan_core.audit.logging import audit_event from govoplan_core.auth import ApiPrincipal, get_api_principal, has_scope from govoplan_core.core.references import ( - access_scope_reference_options, + access_scope_reference_page, access_scope_reference_provider_available, validate_access_scope_reference, ) @@ -225,6 +225,8 @@ 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( @@ -235,14 +237,16 @@ def api_scope_targets( ) 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( @@ -250,8 +254,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, )