from abc import ABC, abstractmethod

from ..injections import BaseInjectable
from ..results.base import BaseResult
from ..types import FlowOutput


class BaseTask(ABC):
    @abstractmethod
    def prepare(self) -> None:
        return

    @abstractmethod
    def run(self) -> None:
        return

    @abstractmethod
    def stop(self) -> None:
        return

    @abstractmethod
    def results(self) -> list[BaseResult]:
        return

    @abstractmethod
    def commit_returned(self, returned: FlowOutput) -> None:
        return

    @abstractmethod
    def get_injectables(self) -> list[BaseInjectable]:
        return

    def get_operations(self) -> list[str]:
        return []

    def configure(self, operation: str, **kwargs) -> None:
        return

    def __call__(self) -> list[BaseResult]:
        self.prepare()
        self.run()
        self.stop()
        return self.results()
