from enum import StrEnum
from pathlib import Path

from pydantic import BaseModel, Field


class Environment(StrEnum):
    DEV = "DEV"
    PROD = "PROD"


class Settings(BaseModel):
    environment: Environment = Field(default=Environment.PROD)
    run_migrations: bool = Field(default=True)
    secret_key: str = Field(..., min_length=8)

    @staticmethod
    def get_db_url() -> str:
        return f"sqlite:///{Path('./vdash.db').resolve()}"

    @property
    def db_url(self) -> str:
        return self.get_db_url()

    @property
    def checkpoint_db_path(self) -> str:
        return f"{Path('./vdash_checkpoint.db').resolve()}"
