2026-01-20 22:26:39 -03:00
|
|
|
from typing import Generic, TypeVar
|
|
|
|
|
from ...mapping.database import NotionDatabase as _NotionDatabase
|
|
|
|
|
from ..pages import _Pages as _Pages
|
|
|
|
|
from .CreateDatabasePage import CreateDatabasePage as _CreateDatabasePage
|
|
|
|
|
from .SearchPage import SearchPage as _SearchPage
|
|
|
|
|
from .SearchPageProperty import SearchPageProperty as _SearchPageProperty
|
|
|
|
|
|
|
|
|
|
TDB = TypeVar('TDB', bound = _NotionDatabase)
|
|
|
|
|
|
2026-01-21 22:15:36 -03:00
|
|
|
class DatabaseClient(Generic[TDB]):
|
|
|
|
|
|
2026-01-20 22:26:39 -03:00
|
|
|
def __init__(self,
|
|
|
|
|
database_id : str,
|
|
|
|
|
generic_response : bool = False
|
|
|
|
|
) -> None:
|
|
|
|
|
|
|
|
|
|
self._database_id = database_id
|
|
|
|
|
self._generic_response = generic_response
|
|
|
|
|
|
|
|
|
|
@property
|
|
|
|
|
def CreateDatabasePage(self) -> _CreateDatabasePage[TDB]:
|
|
|
|
|
return _CreateDatabasePage(
|
|
|
|
|
database_id = self._database_id,
|
|
|
|
|
generic_response = self._generic_response
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
@property
|
|
|
|
|
def SearchPage(self) -> _SearchPage[TDB]:
|
|
|
|
|
return _SearchPage(
|
|
|
|
|
database_id = self._database_id,
|
|
|
|
|
generic_response = self._generic_response
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
@property
|
|
|
|
|
def SearchPageProperty(self) -> _SearchPageProperty:
|
|
|
|
|
return _SearchPageProperty(
|
|
|
|
|
database_id = self._database_id
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
@property
|
|
|
|
|
def page(self) -> _Pages[TDB]:
|
|
|
|
|
return _Pages(
|
|
|
|
|
database_id = self._database_id,
|
|
|
|
|
generic_response = self._generic_response
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
@staticmethod
|
2026-01-21 22:15:36 -03:00
|
|
|
def generic(database_id : str) -> 'DatabaseClient[_NotionDatabase]':
|
2026-01-20 22:26:39 -03:00
|
|
|
|
|
|
|
|
"Acessa database sem schema definido"
|
|
|
|
|
|
2026-01-21 22:15:36 -03:00
|
|
|
return DatabaseClient(
|
2026-01-20 22:26:39 -03:00
|
|
|
database_id = database_id,
|
|
|
|
|
generic_response = True
|
|
|
|
|
)
|
|
|
|
|
|
2026-01-21 22:15:36 -03:00
|
|
|
__all__ = ["DatabaseClient"]
|