- Implemented SvelteKit frontend with authentication callback handling. - Created demo routes and paraglide localization functionality. - Added health check and entrypoint scripts for backend services. - Established PostgreSQL and Keycloak initialization scripts with health checks. - Introduced models for database schema using SQLAlchemy. - Configured Vite and SvelteKit for development and testing environments. - Added health check script to verify service statuses and resource usage. - Created Docker entrypoint scripts for seamless service startup.
98 lines
3.2 KiB
Python
98 lines
3.2 KiB
Python
"""
|
|
DTOs (Data Transfer Objects) para módulo de tenants
|
|
Reemplaza schemas.py siguiendo enfoque DDD y estilo NestJS
|
|
"""
|
|
from pydantic import BaseModel, Field, EmailStr
|
|
from typing import Optional
|
|
from datetime import datetime
|
|
from enum import Enum
|
|
|
|
|
|
class TenantTypeDTO(str, Enum):
|
|
"""Tipo de tenant"""
|
|
SHARED = "shared"
|
|
DEDICATED = "dedicated"
|
|
|
|
|
|
class TenantCreateDTO(BaseModel):
|
|
"""DTO para crear un nuevo tenant"""
|
|
name: str = Field(..., min_length=3, max_length=255, description="Nombre del tenant")
|
|
slug: str = Field(..., min_length=3, max_length=100, description="Identificador único del tenant")
|
|
keycloak_realm: str = Field(..., min_length=3, max_length=255, description="Nombre del realm en Keycloak")
|
|
type: TenantTypeDTO = Field(default=TenantTypeDTO.SHARED, description="Tipo de tenant")
|
|
|
|
contact_name: Optional[str] = Field(None, max_length=255, description="Nombre de contacto")
|
|
contact_email: Optional[EmailStr] = Field(None, description="Email de contacto")
|
|
contact_phone: Optional[str] = Field(None, max_length=50, description="Teléfono de contacto")
|
|
|
|
class Config:
|
|
json_schema_extra = {
|
|
"example": {
|
|
"name": "Empresa ABC S.A. de C.V.",
|
|
"slug": "empresa-abc",
|
|
"keycloak_realm": "empresa-abc-realm",
|
|
"type": "shared",
|
|
"contact_name": "Juan Pérez",
|
|
"contact_email": "juan.perez@empresa-abc.com",
|
|
"contact_phone": "+52 55 1234 5678"
|
|
}
|
|
}
|
|
|
|
|
|
class TenantUpdateDTO(BaseModel):
|
|
"""DTO para actualizar un tenant"""
|
|
name: Optional[str] = Field(None, min_length=3, max_length=255)
|
|
contact_name: Optional[str] = Field(None, max_length=255)
|
|
contact_email: Optional[EmailStr] = None
|
|
contact_phone: Optional[str] = Field(None, max_length=50)
|
|
is_active: Optional[bool] = None
|
|
|
|
class Config:
|
|
json_schema_extra = {
|
|
"example": {
|
|
"name": "Empresa ABC S.A. de C.V. - Actualizado",
|
|
"contact_email": "nuevo@empresa-abc.com"
|
|
}
|
|
}
|
|
|
|
|
|
class TenantResponseDTO(BaseModel):
|
|
"""DTO para respuesta de tenant"""
|
|
id: int
|
|
name: str
|
|
slug: str
|
|
type: TenantTypeDTO
|
|
keycloak_realm: str
|
|
contact_name: Optional[str]
|
|
contact_email: Optional[str]
|
|
contact_phone: Optional[str]
|
|
is_active: bool
|
|
created_at: datetime
|
|
updated_at: datetime
|
|
|
|
class Config:
|
|
from_attributes = True
|
|
json_schema_extra = {
|
|
"example": {
|
|
"id": 1,
|
|
"name": "Empresa ABC S.A. de C.V.",
|
|
"slug": "empresa-abc",
|
|
"type": "shared",
|
|
"keycloak_realm": "empresa-abc-realm",
|
|
"contact_name": "Juan Pérez",
|
|
"contact_email": "juan.perez@empresa-abc.com",
|
|
"contact_phone": "+52 55 1234 5678",
|
|
"is_active": True,
|
|
"created_at": "2025-01-15T10:30:00Z",
|
|
"updated_at": "2025-01-15T10:30:00Z"
|
|
}
|
|
}
|
|
|
|
|
|
class TenantListResponseDTO(BaseModel):
|
|
"""DTO para lista de tenants"""
|
|
tenants: list[TenantResponseDTO]
|
|
total: int
|
|
page: int
|
|
page_size: int
|