init
This commit is contained in:
1
src/application/abstractions/__init__.py
Normal file
1
src/application/abstractions/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from src.application.abstractions.i_unit_of_work import IUnitOfWork
|
||||
43
src/application/abstractions/i_unit_of_work.py
Normal file
43
src/application/abstractions/i_unit_of_work.py
Normal file
@@ -0,0 +1,43 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Protocol, runtime_checkable
|
||||
|
||||
from src.application.abstractions.repositories import (
|
||||
IAdminSessionRepository,
|
||||
IAdminUserRepository,
|
||||
ILegalEntityRepository,
|
||||
IOrganizationDocumentRepository,
|
||||
IOrganizationWalletRepository,
|
||||
IPurchaseRequestRepository,
|
||||
IUserRepository,
|
||||
)
|
||||
|
||||
|
||||
@runtime_checkable
|
||||
class IUnitOfWork(Protocol):
|
||||
async def __aenter__(self) -> 'IUnitOfWork': ...
|
||||
async def __aexit__(self, exc_type, exc_val, exc_tb) -> None: ...
|
||||
|
||||
async def commit(self) -> None: ...
|
||||
async def rollback(self) -> None: ...
|
||||
|
||||
@property
|
||||
def user_repository(self) -> IUserRepository: ...
|
||||
|
||||
@property
|
||||
def admin_user_repository(self) -> IAdminUserRepository: ...
|
||||
|
||||
@property
|
||||
def admin_session_repository(self) -> IAdminSessionRepository: ...
|
||||
|
||||
@property
|
||||
def legal_entity_repository(self) -> ILegalEntityRepository: ...
|
||||
|
||||
@property
|
||||
def organization_wallet_repository(self) -> IOrganizationWalletRepository: ...
|
||||
|
||||
@property
|
||||
def organization_document_repository(self) -> IOrganizationDocumentRepository: ...
|
||||
|
||||
@property
|
||||
def purchase_request_repository(self) -> IPurchaseRequestRepository: ...
|
||||
7
src/application/abstractions/repositories/__init__.py
Normal file
7
src/application/abstractions/repositories/__init__.py
Normal file
@@ -0,0 +1,7 @@
|
||||
from src.application.abstractions.repositories.i_user_repository import IUserRepository
|
||||
from src.application.abstractions.repositories.i_admin_user_repository import IAdminUserRepository
|
||||
from src.application.abstractions.repositories.i_admin_session_repository import IAdminSessionRepository
|
||||
from src.application.abstractions.repositories.i_legal_entity_repository import ILegalEntityRepository
|
||||
from src.application.abstractions.repositories.i_organization_wallet_repository import IOrganizationWalletRepository
|
||||
from src.application.abstractions.repositories.i_organization_document_repository import IOrganizationDocumentRepository
|
||||
from src.application.abstractions.repositories.i_purchase_request_repository import IPurchaseRequestRepository
|
||||
@@ -0,0 +1,44 @@
|
||||
from abc import ABC, abstractmethod
|
||||
from datetime import datetime
|
||||
from typing import Optional
|
||||
|
||||
from src.application.domain.entities.admin_session import AdminSessionEntity
|
||||
|
||||
|
||||
class IAdminSessionRepository(ABC):
|
||||
@abstractmethod
|
||||
async def get_by_sid(self, sid: str) -> Optional[AdminSessionEntity]:
|
||||
raise NotImplementedError
|
||||
|
||||
@abstractmethod
|
||||
async def upsert_by_device(
|
||||
self,
|
||||
*,
|
||||
admin_user_id: str,
|
||||
device_id: str,
|
||||
sid: str,
|
||||
refresh_jti_hash: str,
|
||||
refresh_expires_at: datetime,
|
||||
user_agent: str | None,
|
||||
ip: str | None,
|
||||
now: datetime,
|
||||
) -> AdminSessionEntity:
|
||||
raise NotImplementedError
|
||||
|
||||
@abstractmethod
|
||||
async def revoke_by_sid(self, sid: str, now: datetime) -> None:
|
||||
raise NotImplementedError
|
||||
|
||||
@abstractmethod
|
||||
async def rotate_refresh_if_match(
|
||||
self,
|
||||
*,
|
||||
sid: str,
|
||||
old_jti_hash: str,
|
||||
new_jti_hash: str,
|
||||
new_refresh_expires_at: datetime,
|
||||
now: datetime,
|
||||
ip: str | None,
|
||||
user_agent: str | None,
|
||||
) -> bool:
|
||||
raise NotImplementedError
|
||||
@@ -0,0 +1,17 @@
|
||||
from abc import ABC, abstractmethod
|
||||
|
||||
from src.application.domain.entities.admin_user import AdminUserEntity
|
||||
|
||||
|
||||
class IAdminUserRepository(ABC):
|
||||
@abstractmethod
|
||||
async def get_by_email(self, email: str) -> AdminUserEntity:
|
||||
raise NotImplementedError
|
||||
|
||||
@abstractmethod
|
||||
async def get_by_id(self, admin_user_id: str) -> AdminUserEntity:
|
||||
raise NotImplementedError
|
||||
|
||||
@abstractmethod
|
||||
async def update_last_login(self, admin_user_id: str, *, last_login_at) -> None:
|
||||
raise NotImplementedError
|
||||
@@ -0,0 +1,53 @@
|
||||
from abc import ABC, abstractmethod
|
||||
from typing import Any
|
||||
|
||||
from src.application.domain.entities.organization import LegalEntityEntity
|
||||
|
||||
|
||||
class ILegalEntityRepository(ABC):
|
||||
@abstractmethod
|
||||
async def create(
|
||||
self,
|
||||
*,
|
||||
user_id: str,
|
||||
name: str,
|
||||
short_name: str | None,
|
||||
inn: str,
|
||||
ogrn: str | None,
|
||||
kpp: str | None,
|
||||
legal_address: str | None,
|
||||
actual_address: str | None,
|
||||
bank_details: dict[str, Any] | None,
|
||||
contact_person: str | None,
|
||||
contact_phone: str | None,
|
||||
status: str,
|
||||
kyc_verified: bool,
|
||||
kyc_verified_at,
|
||||
created_by: str | None,
|
||||
) -> LegalEntityEntity:
|
||||
raise NotImplementedError
|
||||
|
||||
@abstractmethod
|
||||
async def get_by_id(self, organization_id: str) -> LegalEntityEntity:
|
||||
raise NotImplementedError
|
||||
|
||||
@abstractmethod
|
||||
async def list_all(self, *, limit: int, offset: int) -> list[LegalEntityEntity]:
|
||||
raise NotImplementedError
|
||||
|
||||
@abstractmethod
|
||||
async def update(
|
||||
self,
|
||||
organization_id: str,
|
||||
*,
|
||||
values: dict[str, Any],
|
||||
) -> LegalEntityEntity:
|
||||
raise NotImplementedError
|
||||
|
||||
@abstractmethod
|
||||
async def set_encrypted_mnemonic(self, organization_id: str, encrypted_mnemonic: str) -> None:
|
||||
raise NotImplementedError
|
||||
|
||||
@abstractmethod
|
||||
async def count_all(self) -> int:
|
||||
raise NotImplementedError
|
||||
@@ -0,0 +1,17 @@
|
||||
from abc import ABC, abstractmethod
|
||||
|
||||
from src.application.domain.entities.organization import OrganizationDocumentEntity
|
||||
|
||||
|
||||
class IOrganizationDocumentRepository(ABC):
|
||||
@abstractmethod
|
||||
async def create(self, document: OrganizationDocumentEntity) -> OrganizationDocumentEntity:
|
||||
raise NotImplementedError
|
||||
|
||||
@abstractmethod
|
||||
async def get_by_id(self, document_id: str) -> OrganizationDocumentEntity:
|
||||
raise NotImplementedError
|
||||
|
||||
@abstractmethod
|
||||
async def list_by_organization(self, organization_id: str) -> list[OrganizationDocumentEntity]:
|
||||
raise NotImplementedError
|
||||
@@ -0,0 +1,17 @@
|
||||
from abc import ABC, abstractmethod
|
||||
|
||||
from src.application.domain.entities.organization import OrganizationWalletEntity
|
||||
|
||||
|
||||
class IOrganizationWalletRepository(ABC):
|
||||
@abstractmethod
|
||||
async def create_many(self, wallets: list[OrganizationWalletEntity]) -> list[OrganizationWalletEntity]:
|
||||
raise NotImplementedError
|
||||
|
||||
@abstractmethod
|
||||
async def list_by_organization(self, organization_id: str) -> list[OrganizationWalletEntity]:
|
||||
raise NotImplementedError
|
||||
|
||||
@abstractmethod
|
||||
async def exists_for_organization(self, organization_id: str) -> bool:
|
||||
raise NotImplementedError
|
||||
@@ -0,0 +1,29 @@
|
||||
from abc import ABC, abstractmethod
|
||||
from typing import Any
|
||||
|
||||
from src.application.domain.entities.organization import PurchaseRequestEntity
|
||||
|
||||
|
||||
class IPurchaseRequestRepository(ABC):
|
||||
@abstractmethod
|
||||
async def get_by_id(self, request_id: str) -> PurchaseRequestEntity:
|
||||
raise NotImplementedError
|
||||
|
||||
@abstractmethod
|
||||
async def list_all(
|
||||
self,
|
||||
*,
|
||||
status: str | None,
|
||||
organization_id: str | None,
|
||||
limit: int,
|
||||
offset: int,
|
||||
) -> list[PurchaseRequestEntity]:
|
||||
raise NotImplementedError
|
||||
|
||||
@abstractmethod
|
||||
async def update(self, request_id: str, *, values: dict[str, Any]) -> PurchaseRequestEntity:
|
||||
raise NotImplementedError
|
||||
|
||||
@abstractmethod
|
||||
async def count_all(self, *, status: str | None, organization_id: str | None) -> int:
|
||||
raise NotImplementedError
|
||||
@@ -0,0 +1,27 @@
|
||||
from abc import ABC, abstractmethod
|
||||
from datetime import datetime
|
||||
|
||||
from src.application.domain.entities import UserEntity
|
||||
|
||||
|
||||
class IUserRepository(ABC):
|
||||
@abstractmethod
|
||||
async def create_legal_entity_user(
|
||||
self,
|
||||
*,
|
||||
email: str,
|
||||
password_hash: str,
|
||||
provisioned_by: str,
|
||||
provisioned_at: datetime,
|
||||
kyc_verified: bool,
|
||||
kyc_verified_at: datetime,
|
||||
) -> UserEntity:
|
||||
raise NotImplementedError
|
||||
|
||||
@abstractmethod
|
||||
async def get_user_by_email(self, email: str) -> UserEntity:
|
||||
raise NotImplementedError
|
||||
|
||||
@abstractmethod
|
||||
async def exists_by_email(self, email: str) -> bool:
|
||||
raise NotImplementedError
|
||||
Reference in New Issue
Block a user