Files
2026-05-13 12:56:52 +08:00

66 lines
2.1 KiB
Python

"""Abstract scheduled-task persistence API."""
from __future__ import annotations
from abc import ABC, abstractmethod
from datetime import datetime
from typing import Any
class ScheduledTaskStore(ABC):
@abstractmethod
async def get_or_create_scheduler_thread(self, user_id: str, thread_id_factory) -> dict:
raise NotImplementedError
@abstractmethod
async def list_tasks(self, user_id: str) -> list[dict[str, Any]]:
raise NotImplementedError
@abstractmethod
async def get_task(self, task_id: str, user_id: str) -> dict[str, Any] | None:
raise NotImplementedError
@abstractmethod
async def create_task(self, data: dict[str, Any]) -> dict[str, Any]:
raise NotImplementedError
@abstractmethod
async def update_task(self, task_id: str, user_id: str, data: dict[str, Any]) -> dict[str, Any] | None:
raise NotImplementedError
@abstractmethod
async def delete_task(self, task_id: str, user_id: str) -> bool:
raise NotImplementedError
@abstractmethod
async def due_tasks(self, now: datetime, *, limit: int = 20) -> list[dict[str, Any]]:
raise NotImplementedError
@abstractmethod
async def create_run_once(self, data: dict[str, Any]) -> dict[str, Any] | None:
raise NotImplementedError
@abstractmethod
async def update_run(self, run_id: str, data: dict[str, Any]) -> None:
raise NotImplementedError
@abstractmethod
async def list_runs(self, task_id: str, user_id: str, *, limit: int = 50) -> list[dict[str, Any]]:
raise NotImplementedError
@abstractmethod
async def get_run(self, run_id: str, user_id: str) -> dict[str, Any] | None:
raise NotImplementedError
@abstractmethod
async def delete_run(self, run_id: str, user_id: str) -> bool:
raise NotImplementedError
@abstractmethod
async def get_delivery_profile(self, user_id: str) -> dict[str, Any]:
raise NotImplementedError
@abstractmethod
async def update_delivery_profile(self, user_id: str, data: dict[str, Any]) -> dict[str, Any]:
raise NotImplementedError