Исходный код core.interfaces

from __future__ import annotations

"""Common interfaces (Protocols) for dependency injection.
These allow GoalManager to depend on abstractions rather than concrete
Google-Sheets or OpenAI implementations.
"""

from typing import Protocol, Any, Dict, List, Optional, Tuple

from core.models import Goal, GoalPriority, GoalStatistics, GoalStatus, Task


[документация] class StorageInterface(Protocol): """Storage interface for goals and tasks with multi-goal support.""" # Spreadsheet management
[документация] def create_spreadsheet(self, user_id: int) -> None: """Create a new spreadsheet for user.""" ...
[документация] def delete_spreadsheet(self, user_id: int) -> None: """Delete user's spreadsheet.""" ...
# Goal management
[документация] def get_all_goals(self, user_id: int) -> List[Goal]: """Get all goals for a user.""" ...
[документация] def get_goal_by_id(self, user_id: int, goal_id: int) -> Optional[Goal]: """Get a specific goal by ID.""" ...
[документация] def get_active_goals(self, user_id: int) -> List[Goal]: """Get only active goals.""" ...
[документация] def get_active_goals_count(self, user_id: int) -> int: """Count active goals.""" ...
[документация] def get_next_goal_id(self, user_id: int) -> int: """Get next available goal ID.""" ...
[документация] def save_goal_info(self, user_id: int, goal: Goal) -> str: """Save or update goal information.""" ...
[документация] def update_goal_status( self, user_id: int, goal_id: int, status: GoalStatus ) -> None: """Update goal status.""" ...
[документация] def update_goal_progress(self, user_id: int, goal_id: int, progress: int) -> None: """Update goal progress percentage.""" ...
[документация] def update_goal_priority( self, user_id: int, goal_id: int, priority: GoalPriority ) -> None: """Update goal priority.""" ...
[документация] def archive_goal(self, user_id: int, goal_id: int) -> None: """Archive a goal.""" ...
[документация] def delete_goal(self, user_id: int, goal_id: int) -> None: """Delete a goal completely.""" ...
# Plan management
[документация] def save_plan(self, user_id: int, goal_id: int, plan: List[Dict[str, Any]]) -> None: """Save plan for a goal.""" ...
[документация] def get_plan_for_goal(self, user_id: int, goal_id: int) -> List[Task]: """Get plan for a specific goal.""" ...
# Task management
[документация] def get_task_for_date( self, user_id: int, goal_id: int, date: str ) -> Optional[Task]: """Get task for specific goal and date.""" ...
[документация] def get_all_tasks_for_date(self, user_id: int, date: str) -> List[Task]: """Get all tasks for a specific date.""" ...
[документация] def update_task_status( self, user_id: int, goal_id: int, date: str, status: str ) -> None: """Update task status.""" ...
[документация] def batch_update_task_statuses( self, user_id: int, updates: Dict[Tuple[int, str], str] ) -> None: """Batch update multiple task statuses.""" ...
# Statistics
[документация] def get_goal_statistics(self, user_id: int, goal_id: int) -> GoalStatistics: """Get statistics for a specific goal.""" ...
[документация] def get_overall_statistics(self, user_id: int) -> Dict[str, Any]: """Get overall statistics for all goals.""" ...
# Legacy methods (to be deprecated)
[документация] def get_goal_info(self, user_id: int) -> Dict[str, str]: """Get goal info (legacy, single goal).""" ...
[документация] def save_goal_and_plan( self, user_id: int, goal_data: Dict[str, str], plan: List[Dict[str, Any]] ) -> str: """Save goal and plan (legacy, single goal).""" ...
[документация] def get_status_message(self, user_id: int) -> str: """Get status message (legacy, single goal).""" ...
[документация] class AsyncStorageInterface(Protocol): """Async storage interface for goals and tasks with multi-goal support.""" # Spreadsheet management
[документация] async def create_spreadsheet(self, user_id: int) -> None: """Create a new spreadsheet for user.""" ...
[документация] async def delete_spreadsheet(self, user_id: int) -> None: """Delete user's spreadsheet.""" ...
# Goal management
[документация] async def get_all_goals(self, user_id: int) -> List[Goal]: """Get all goals for a user.""" ...
[документация] async def get_goal_by_id(self, user_id: int, goal_id: int) -> Optional[Goal]: """Get a specific goal by ID.""" ...
[документация] async def get_active_goals(self, user_id: int) -> List[Goal]: """Get only active goals.""" ...
[документация] async def get_active_goals_count(self, user_id: int) -> int: """Count active goals.""" ...
[документация] async def get_next_goal_id(self, user_id: int) -> int: """Get next available goal ID.""" ...
[документация] async def save_goal_info(self, user_id: int, goal: Goal) -> str: """Save or update goal information.""" ...
[документация] async def update_goal_status( self, user_id: int, goal_id: int, status: GoalStatus ) -> None: """Update goal status.""" ...
[документация] async def update_goal_progress( self, user_id: int, goal_id: int, progress: int ) -> None: """Update goal progress percentage.""" ...
[документация] async def update_goal_priority( self, user_id: int, goal_id: int, priority: GoalPriority ) -> None: """Update goal priority.""" ...
[документация] async def archive_goal(self, user_id: int, goal_id: int) -> None: """Archive a goal.""" ...
[документация] async def delete_goal(self, user_id: int, goal_id: int) -> None: """Delete a goal completely.""" ...
# Plan management
[документация] async def save_plan( self, user_id: int, goal_id: int, plan: List[Dict[str, Any]] ) -> None: """Save plan for a goal.""" ...
[документация] async def get_plan_for_goal(self, user_id: int, goal_id: int) -> List[Task]: """Get plan for a specific goal.""" ...
# Task management
[документация] async def get_task_for_date( self, user_id: int, goal_id: int, date: str ) -> Optional[Task]: """Get task for specific goal and date.""" ...
[документация] async def get_all_tasks_for_date(self, user_id: int, date: str) -> List[Task]: """Get all tasks for a specific date.""" ...
[документация] async def update_task_status( self, user_id: int, goal_id: int, date: str, status: str ) -> None: """Update task status.""" ...
[документация] async def batch_update_task_statuses( self, user_id: int, updates: Dict[Tuple[int, str], str] ) -> None: """Batch update multiple task statuses.""" ...
# Statistics
[документация] async def get_goal_statistics(self, user_id: int, goal_id: int) -> GoalStatistics: """Get statistics for a specific goal.""" ...
[документация] async def get_overall_statistics(self, user_id: int) -> Dict[str, Any]: """Get overall statistics for all goals.""" ...
# Legacy methods (to be deprecated)
[документация] async def get_goal_info(self, user_id: int) -> Dict[str, str]: """Get goal info (legacy, single goal).""" ...
[документация] async def save_goal_and_plan( self, user_id: int, goal_data: Dict[str, str], plan: List[Dict[str, Any]] ) -> str: """Save goal and plan (legacy, single goal).""" ...
[документация] async def get_status_message(self, user_id: int) -> str: """Get status message (legacy, single goal).""" ...
[документация] async def get_task_for_today(self, user_id: int) -> Dict[str, Any] | None: """Get today's task (legacy, single goal).""" ...
[документация] async def update_task_status_old( self, user_id: int, date: str, status: str ) -> None: """Update task status (legacy, single goal).""" ...
[документация] async def get_extended_statistics( self, user_id: int, count: int = 7 ) -> Dict[str, Any]: """Get extended statistics (legacy method).""" ...
[документация] class LLMInterface(Protocol): """Interface for LLM interactions."""
[документация] def generate_plan( self, goal_text: str, deadline_str: str, available_time_str: str ) -> List[Dict[str, Any]]: """Generate a plan for achieving a goal.""" ...
[документация] def generate_motivation(self, goal_info: str, progress_summary: str) -> str: """Generate motivational message based on goal and progress.""" ...
[документация] class AsyncLLMInterface(Protocol): """Async interface for LLM interactions."""
[документация] async def generate_plan( self, goal_text: str, deadline_str: str, available_time_str: str ) -> List[Dict[str, Any]]: """Generate a plan for achieving a goal.""" ...
[документация] async def generate_motivation(self, goal_info: str, progress_summary: str) -> str: """Generate motivational message based on goal and progress.""" ...