from pydantic import BaseModel, Field
from typing import Any, Type
import hashlib
import os

class WhereFilter(BaseModel):
    field: str | Any = ""
    value: str | Any = ""

class ExactFilter(BaseModel):
    modeldata: object

class TableModel(BaseModel): pass

class Table(BaseModel):
    name: str
    model: Any | Type[TableModel]

class BaseRequest(BaseModel):
    rid: str = Field(default_factory=lambda: hashlib.md5(os.urandom(32)).hexdigest())

class Insert(BaseRequest):
    table: Table
    data: Any | Type[TableModel]
    where: list[WhereFilter] = []
    exclude: list[WhereFilter] = []

class Update(BaseRequest):
    table: Table
    data: Any | Type[TableModel]
    where: list[WhereFilter]

class Delete(BaseRequest):
    table: Table
    where: list[WhereFilter]

class Select(BaseRequest):
    table: Table
    where: list[WhereFilter] = []
    exclude: list[WhereFilter] = []

class Create(BaseRequest):
    table: Table