"""Ports used by account application services.""" from collections.abc import Sequence from datetime import datetime from typing import Protocol from services.entities.account_access_entities import ( AccountSessionRevocation, AccountSessionSnapshot, AccountWorkspaceSnapshot, ) from services.entities.account_entities import ( AccountCredentials, AccountDeletionChallenge, AccountEmailResetResult, AccountInitialization, AccountInitializationResult, AccountIntegrationSnapshot, AccountPasswordDigest, AccountProfileChanges, AccountSnapshot, ) class AccountSnapshotQuery(Protocol): def get(self, account_id: str) -> AccountSnapshot | None: ... class AccountRepository(Protocol): def get(self, account_id: str) -> AccountSnapshot | None: ... def find_by_email(self, email: str) -> AccountSnapshot | None: ... def activate_pending(self, account_id: str, *, initialized_at: datetime) -> None: ... def get_credentials(self, account_id: str) -> AccountCredentials | None: ... def update_profile(self, account_id: str, changes: AccountProfileChanges) -> AccountSnapshot | None: ... def update_password(self, account_id: str, password: AccountPasswordDigest) -> AccountSnapshot | None: ... def initialize( self, account_id: str, initialization: AccountInitialization, *, invitation_code: str | None, workspace_id: str | None, ) -> AccountInitializationResult: ... def email_exists(self, email: str) -> bool: ... def reset_email(self, account_id: str, *, expected_old_email: str, new_email: str) -> AccountEmailResetResult: ... class AccountIntegrationRepository(Protocol): def find_account_id(self, *, provider: str, open_id: str) -> str | None: ... def list_for_account(self, account_id: str) -> list[AccountIntegrationSnapshot]: ... def link(self, account_id: str, *, provider: str, open_id: str) -> None: ... class AccountWorkspaceMembershipQuery(Protocol): def list_ids_for_account(self, account_id: str) -> Sequence[str]: ... def has_active_membership(self, account_id: str) -> bool: ... class AccountWorkspaceSnapshotQuery(Protocol): def list_account_access_workspaces(self, account_id: str) -> Sequence[AccountWorkspaceSnapshot]: ... class AccountSessionRepository(Protocol): def list_active( self, *, account_id: str, active_at: datetime, offset: int, limit: int, ) -> tuple[int, Sequence[AccountSessionSnapshot]]: ... def revoke( self, *, account_id: str, token_id: str, revoked_at: datetime, ) -> AccountSessionRevocation: ... class AccountTokenCacheInvalidator(Protocol): def __call__(self, token_hash: str) -> None: ... class AccountAvatarFileGateway(Protocol): def get_owned_signed_url(self, *, account_id: str, upload_file_id: str) -> str | None: ... class AccountPasswordHasher(Protocol): def verify(self, password: str, *, password_hash: str, password_salt: str) -> bool: ... def hash(self, password: str) -> AccountPasswordDigest: ... class AccountDeletionVerificationGateway(Protocol): def create(self, *, account_id: str, email: str) -> AccountDeletionChallenge: ... def verify(self, *, account_id: str, token: str, code: str) -> bool: ... class AccountDeletionVerificationNotifier(Protocol): def send(self, *, email: str, code: str) -> None: ... class AccountDeletionSyncGateway(Protocol): def sync(self, *, account_id: str, workspace_ids: Sequence[str]) -> bool: ... class AccountDeletionScheduler(Protocol): def schedule(self, account_id: str) -> None: ...