# retoor <retoor@molodetz.nl>

from __future__ import annotations

from typing import Any, Optional

from devplacepy.schemas.base import _Out


class DbTableOut(_Out):
    name: str = ""
    row_count: int = 0
    soft_delete: bool = False


class DbTableListOut(_Out):
    tables: list[DbTableOut] = []
    count: int = 0


class DbColumnOut(_Out):
    name: str = ""
    type: str = ""


class DbSchemaOut(_Out):
    table: str = ""
    columns: list[DbColumnOut] = []
    soft_delete: bool = False
    row_count: int = 0


class DbRowsOut(_Out):
    table: str = ""
    rows: list[dict] = []
    count: int = 0
    next_cursor: Optional[Any] = None


class DbRowOut(_Out):
    table: str = ""
    row: Optional[dict] = None


class DbQueryOut(_Out):
    sql: str = ""
    valid: bool = False
    statement_type: str = ""
    rows: list[dict] = []
    row_count: int = 0
    truncated: bool = False
    suspicious: list[str] = []
    error: Optional[str] = None


class NlQueryOut(_Out):
    question: str = ""
    table: str = ""
    sql: str = ""
    valid: bool = False
    attempts: int = 0
    dialect: str = "sqlite"
    applied_soft_delete: bool = False
    suspicious: list[str] = []
    tables: list[str] = []
    executed: bool = False
    rows: list[dict] = []
    row_count: int = 0
    truncated: bool = False
    error: Optional[str] = None
