from typing import Protocol from apps.users.application.dto import PasswordLink, PasswordLinkPurpose from apps.users.domain.entities import UserAccount class PasswordLinkService(Protocol): def issue(self, user_id: int, purpose: PasswordLinkPurpose) -> PasswordLink: """Create a single-use link; any earlier link of the user stops working.""" ... def send(self, user: UserAccount, link: PasswordLink, purpose: PasswordLinkPurpose) -> bool: """Email the link. Returns False (and logs) if sending fails.""" ...