diff --git a/ROADMAP.md b/ROADMAP.md index d748a53..967eae7 100644 --- a/ROADMAP.md +++ b/ROADMAP.md @@ -73,7 +73,7 @@ ## Future - [ ] Font selection (visual comparison of candidates) -- [ ] Application-owned map preview asset (replace URL with static file) +- [x] Application-owned map preview asset (replace URL with static file) - [ ] Miniature rendered invitation preview in admin config editor - [ ] Enhanced admin features (edit/delete RSVP, attendance status, guest count) - [ ] CSV import diff --git a/backend/app/config.py b/backend/app/config.py index ad39270..69b5a13 100644 --- a/backend/app/config.py +++ b/backend/app/config.py @@ -1,3 +1,5 @@ +from pathlib import Path + from pydantic_settings import BaseSettings, SettingsConfigDict @@ -7,8 +9,18 @@ class Settings(BaseSettings): BASE_PATH: str = "/birthday" APP_PORT: int = 8000 DATABASE_URL: str = "sqlite:///./data/bdinvite.db" + DATA_DIR: str = "./data" model_config = SettingsConfigDict(env_file=".env", extra="ignore") + @property + def data_path(self) -> Path: + return Path(self.DATA_DIR).resolve() + + @property + def map_preview_file(self) -> Path: + return self.data_path / "map_preview.png" + settings = Settings() + diff --git a/backend/app/main.py b/backend/app/main.py index 7b2bbbd..f694f27 100644 --- a/backend/app/main.py +++ b/backend/app/main.py @@ -8,6 +8,7 @@ from fastapi.middleware.cors import CORSMiddleware from fastapi.responses import FileResponse, JSONResponse, RedirectResponse from fastapi.staticfiles import StaticFiles +from .config import settings from .database import Base, SessionLocal, engine from .routes import admin, config, rsvp from .services.config import seed_default_config @@ -92,6 +93,25 @@ app.include_router(config.router, prefix="/birthday/api") app.include_router(admin.router, prefix="/birthday/api/admin") +@app.get( + "/birthday/api/map-preview.png", + tags=["Config"], + summary="Obtener imagen de vista previa del mapa generada", + description="Retorna el archivo PNG de vista previa del mapa generado centrado en la ubicación.", +) +async def get_map_preview(): + if settings.map_preview_file.exists(): + return FileResponse( + settings.map_preview_file, + media_type="image/png", + headers={"Cache-Control": "public, max-age=300"}, + ) + return RedirectResponse( + url="https://tile.openstreetmap.org/15/8802/13443.png", + status_code=status.HTTP_307_TEMPORARY_REDIRECT, + ) + + # Static files and SPA serving STATIC_DIR = os.path.join(os.path.dirname(__file__), "..", "static") ASSETS_DIR = os.path.join(STATIC_DIR, "assets") diff --git a/backend/app/routes/admin.py b/backend/app/routes/admin.py index b5ee94c..d50725c 100644 --- a/backend/app/routes/admin.py +++ b/backend/app/routes/admin.py @@ -1,17 +1,22 @@ import csv import io +from datetime import UTC, datetime from typing import Annotated -from fastapi import APIRouter, Depends, Header, HTTPException, Query, Response +from fastapi import APIRouter, Depends, Header, HTTPException, Query, Response, status from sqlalchemy.orm import Session +from ..config import settings from ..database import get_db from ..schemas import ( + GenerateMapPreviewRequest, + GenerateMapPreviewResponse, InvitationConfigResponse, InvitationConfigUpdate, RSVPListResponse, ) from ..services.config import get_config, seed_default_config, update_config +from ..services.map_preview import generate_map_preview_image, resolve_google_maps_coordinates from ..services.rsvp import get_rsvps router = APIRouter(tags=["Admin"]) @@ -140,6 +145,7 @@ def get_admin_config( summary="Actualizar configuración de la invitación", description=( "Reemplaza los valores de la configuración singleton del evento. " + "Si la URL de Google Maps cambió, valida y regenera automáticamente la vista previa del mapa. " "Aplica validación de fecha ISO, hora en formato militar 24h y zona horaria válida IANA. " "Los cambios toman efecto de inmediato sin requerir recarga del contenedor." ), @@ -148,10 +154,82 @@ def get_admin_config( **ADMIN_401, }, ) -def update_admin_config( +async def update_admin_config( update_in: InvitationConfigUpdate, admin: AdminDep, db: DbDep, ): + current = get_config(db) + if not current: + current = seed_default_config(db) + + # Condition: Trigger generation ONLY if map_url was changed + if current.map_url != update_in.map_url: + try: + lat, lng, _ = await resolve_google_maps_coordinates(update_in.map_url) + await generate_map_preview_image(lat, lng) + update_in.map_preview_url = f"{settings.BASE_PATH}/api/map-preview.png" + except ValueError as err: + raise HTTPException( + status_code=status.HTTP_422_UNPROCESSABLE_ENTITY, + detail=str(err), + ) from err + except Exception as err: + raise HTTPException( + status_code=status.HTTP_500_INTERNAL_SERVER_ERROR, + detail=f"Error al generar la vista previa del mapa: {err}", + ) from err + updated = update_config(db, update_in) return updated + + +@router.post( + "/map-preview/generate", + response_model=GenerateMapPreviewResponse, + summary="Regenerar la vista previa del mapa", + description=( + "Genera o regenera la imagen del mapa en disco para la URL provista o la configurada actualmente, " + "sin realizar escrituras innecesarias a la base de datos." + ), + responses={ + 200: {"model": GenerateMapPreviewResponse, "description": "Vista previa generada exitosamente."}, + **ADMIN_401, + }, +) +async def regenerate_map_preview_endpoint( + admin: AdminDep, + db: DbDep, + payload: GenerateMapPreviewRequest | None = None, +): + target_url = payload.map_url.strip() if (payload and payload.map_url) else None + if not target_url: + current = get_config(db) + if not current or not current.map_url: + raise HTTPException( + status_code=status.HTTP_400_BAD_REQUEST, + detail="No se proporcionó una URL de Google Maps ni existe una guardada en la configuración.", + ) + target_url = current.map_url + + try: + lat, lng, _ = await resolve_google_maps_coordinates(target_url) + await generate_map_preview_image(lat, lng) + timestamp = int(datetime.now(UTC).timestamp()) + return GenerateMapPreviewResponse( + map_preview_url=f"{settings.BASE_PATH}/api/map-preview.png?t={timestamp}", + lat=lat, + lng=lng, + message="Vista previa del mapa generada exitosamente.", + ) + except ValueError as err: + raise HTTPException( + status_code=status.HTTP_422_UNPROCESSABLE_ENTITY, + detail=str(err), + ) from err + except Exception as err: + raise HTTPException( + status_code=status.HTTP_500_INTERNAL_SERVER_ERROR, + detail=f"Error al generar la vista previa del mapa: {err}", + ) from err + diff --git a/backend/app/schemas.py b/backend/app/schemas.py index ac3cdb0..f2e7aa8 100644 --- a/backend/app/schemas.py +++ b/backend/app/schemas.py @@ -275,6 +275,15 @@ class InvitationConfigBase(BaseModel): raise ValueError(f"Zona horaria IANA desconocida: {clean}") return clean + @field_validator("map_url") + @classmethod + def validate_map_url(cls, v: str) -> str: + from .services.map_preview import validate_google_maps_url_format + + clean = v.strip() + validate_google_maps_url_format(clean) + return clean + class InvitationConfigUpdate(InvitationConfigBase): pass @@ -285,3 +294,18 @@ class InvitationConfigResponse(InvitationConfigBase): updated_at: datetime | None = Field(default=None, description="Última modificación en UTC") model_config = ConfigDict(from_attributes=True) + + +class GenerateMapPreviewRequest(BaseModel): + map_url: str | None = Field( + default=None, + description="URL de Google Maps a procesar. Si se omite, se usa la configurada actualmente.", + examples=["https://maps.app.goo.gl/abcd1234efgh5678"], + ) + + +class GenerateMapPreviewResponse(BaseModel): + map_preview_url: str = Field(description="URL para acceder a la imagen de vista previa generada") + lat: float = Field(description="Latitud resuelta") + lng: float = Field(description="Longitud resuelta") + message: str = Field(default="Vista previa generada con éxito") diff --git a/backend/app/services/map_preview.py b/backend/app/services/map_preview.py new file mode 100644 index 0000000..794f477 --- /dev/null +++ b/backend/app/services/map_preview.py @@ -0,0 +1,230 @@ +import io +import math +import re +from pathlib import Path +from urllib.parse import parse_qs, unquote, urlparse + +import httpx +from PIL import Image, ImageDraw + +from ..config import settings + +USER_AGENT = "bdinvite-map-preview/1.0 (contact: admin@roadtotech.me)" + +GOOGLE_MAPS_DOMAINS = ( + "maps.app.goo.gl", + "goo.gl", + "google.com", + "www.google.com", + "maps.google.com", +) + + +def is_google_maps_host(host: str) -> bool: + """Check if the hostname belongs to Google Maps or Goo.gl shortlinks.""" + clean_host = host.lower().strip() + if clean_host in ("maps.app.goo.gl", "goo.gl"): + return True + if clean_host.startswith("maps.google."): + return True + if clean_host == "google.com" or clean_host.endswith(".google.com"): + return True + # Regional domains like google.es, google.co, google.com.co + if re.match(r"^(?:www\.)?google\.[a-z.]+$", clean_host): + return True + return False + + +def validate_google_maps_url_format(url: str) -> None: + """Validate that the given string is a structurally sound Google Maps URL.""" + clean = url.strip() + if not clean: + raise ValueError("La URL de Google Maps no puede estar vacía.") + + parsed = urlparse(clean) + if parsed.scheme not in ("http", "https"): + raise ValueError("La URL debe comenzar con http:// o https://") + + if not parsed.netloc or not is_google_maps_host(parsed.netloc): + raise ValueError( + "La URL debe ser un enlace de Google Maps válido (ej. maps.app.goo.gl/... o google.com/maps/...)" + ) + + +def extract_coordinates_from_text(text: str) -> tuple[float, float] | None: + """Extract latitude and longitude from URL fragments, paths, or query strings.""" + # Pattern 1: @, (e.g. /@34.143245,-118.255132,17z) + match_at = re.search(r"@(-?\d+(?:\.\d+)?),(-?\d+(?:\.\d+)?)", text) + if match_at: + lat = float(match_at.group(1)) + lng = float(match_at.group(2)) + if -90.0 <= lat <= 90.0 and -180.0 <= lng <= 180.0: + return lat, lng + + # Pattern 2: !3d!4d (Google Maps protobuf data parameter) + match_data = re.search(r"!3d(-?\d+(?:\.\d+)?)(?:!4d|.*?!4d)(-?\d+(?:\.\d+)?)", text) + if match_data: + lat = float(match_data.group(1)) + lng = float(match_data.group(2)) + if -90.0 <= lat <= 90.0 and -180.0 <= lng <= 180.0: + return lat, lng + + # Pattern 3: Query parameters (q=lat,lng, ll=lat,lng, destination=lat,lng) + parsed = urlparse(text) + if parsed.query: + qs = parse_qs(parsed.query) + for param in ("q", "ll", "destination"): + if param in qs and qs[param]: + val = qs[param][0].strip() + m = re.match(r"^(-?\d+(?:\.\d+)?),\s*(-?\d+(?:\.\d+)?)$", val) + if m: + lat = float(m.group(1)) + lng = float(m.group(2)) + if -90.0 <= lat <= 90.0 and -180.0 <= lng <= 180.0: + return lat, lng + + return None + + +async def resolve_google_maps_coordinates(map_url: str) -> tuple[float, float, str]: + """ + Validate and resolve a Google Maps URL, following redirects if necessary, + and return (latitude, longitude, resolved_url). + """ + validate_google_maps_url_format(map_url) + clean_url = map_url.strip() + + # Try direct extraction before making any network requests + direct_coords = extract_coordinates_from_text(clean_url) + if direct_coords: + return direct_coords[0], direct_coords[1], clean_url + + # Follow HTTP redirects to resolve short links (maps.app.goo.gl, etc.) + resolved_url = clean_url + async with httpx.AsyncClient( + follow_redirects=True, + timeout=10.0, + headers={"User-Agent": USER_AGENT}, + ) as client: + try: + response = await client.get(clean_url) + resolved_url = str(response.url) + # Check redirect history URLs in case coordinates were in an intermediate hop + for hop in response.history: + hop_coords = extract_coordinates_from_text(str(hop.url)) + if hop_coords: + return hop_coords[0], hop_coords[1], resolved_url + except httpx.RequestError as exc: + raise ValueError(f"No se pudo resolver el enlace de Google Maps: {exc}") from exc + + # Try extraction on the final resolved destination URL + final_coords = extract_coordinates_from_text(resolved_url) + if final_coords: + return final_coords[0], final_coords[1], resolved_url + + # Fallback: check if there is a place search query in the URL or query string + parsed = urlparse(resolved_url) + qs = parse_qs(parsed.query) + query_text = None + if "q" in qs and qs["q"]: + query_text = qs["q"][0] + elif "/place/" in parsed.path: + # e.g. /maps/place/Fresco+Ristorante/... + place_part = parsed.path.split("/place/")[1].split("/")[0] + query_text = unquote(place_part.replace("+", " ")) + + if query_text: + # Attempt open geocoding with OpenStreetMap Nominatim + async with httpx.AsyncClient(timeout=8.0, headers={"User-Agent": USER_AGENT}) as client: + try: + nom_res = await client.get( + "https://nominatim.openstreetmap.org/search", + params={"q": query_text, "format": "json", "limit": 1}, + ) + if nom_res.status_code == 200: + results = nom_res.json() + if results and isinstance(results, list) and len(results) > 0: + lat = float(results[0]["lat"]) + lng = float(results[0]["lon"]) + if -90.0 <= lat <= 90.0 and -180.0 <= lng <= 180.0: + return lat, lng, resolved_url + except Exception: + pass + + raise ValueError( + "No se pudieron extraer las coordenadas de la URL de Google Maps. " + "Asegúrate de que el enlace dirija a un lugar o coordenadas específicas." + ) + + +def deg2num(lat_deg: float, lon_deg: float, zoom: int) -> tuple[float, float]: + """Convert latitude and longitude to floating-point Slippy tile coordinates.""" + lat_rad = math.radians(lat_deg) + n = 2.0**zoom + xtile = (lon_deg + 180.0) / 360.0 * n + ytile = (1.0 - math.asinh(math.tan(lat_rad)) / math.pi) / 2.0 * n + return xtile, ytile + + +async def generate_map_preview_image( + lat: float, + lng: float, + zoom: int = 16, + output_path: Path | None = None, +) -> Path: + """ + Download OpenStreetMap tiles surrounding (lat, lng), stitch them into a canvas, + crop a 400x400 square centered on the location, render a golden marker pin, + and save the resulting PNG to output_path (defaulting to settings.map_preview_file). + """ + dest_path = output_path or settings.map_preview_file + dest_path.parent.mkdir(parents=True, exist_ok=True) + + xtile, ytile = deg2num(lat, lng, zoom) + x_int, y_int = int(xtile), int(ytile) + dx = xtile - x_int + dy = ytile - y_int + + # Canvas of 3x3 tiles = 768x768 pixels + canvas = Image.new("RGB", (768, 768), color=(229, 227, 223)) + + async with httpx.AsyncClient(timeout=10.0, headers={"User-Agent": USER_AGENT}) as client: + for r_idx, y in enumerate(range(y_int - 1, y_int + 2)): + for c_idx, x in enumerate(range(x_int - 1, x_int + 2)): + tile_url = f"https://tile.openstreetmap.org/{zoom}/{x}/{y}.png" + try: + res = await client.get(tile_url) + if res.status_code == 200: + tile = Image.open(io.BytesIO(res.content)).convert("RGB") + canvas.paste(tile, (c_idx * 256, r_idx * 256)) + except Exception: + # Keep neutral background tile if individual tile fails + pass + + # Exact target location within the 768x768 canvas + cx = 256 + int(dx * 256) + cy = 256 + int(dy * 256) + + # 400x400 crop centered on target coordinates + box = (cx - 200, cy - 200, cx + 200, cy + 200) + cropped = canvas.crop(box) + + # Draw marker pin centered at (200, 200) + # The pin tip touches (200, 200) + draw = ImageDraw.Draw(cropped, "RGBA") + + # Ground shadow underneath the pin tip + draw.ellipse((192, 198, 208, 204), fill=(40, 40, 40, 140)) + + # Golden pin pointer (inverted triangle) + draw.polygon([(188, 184), (212, 184), (200, 200)], fill="#d4a843", outline="#1a1a1a") + + # Golden pin circular head + draw.ellipse((188, 170, 212, 194), fill="#d4a843", outline="#1a1a1a", width=2) + + # Dark center eye + draw.ellipse((197, 179, 203, 185), fill="#1a1a1a") + + # Save to disk as PNG + cropped.save(dest_path, "PNG", optimize=True) + return dest_path diff --git a/backend/pyproject.toml b/backend/pyproject.toml index 11db20c..5da6415 100644 --- a/backend/pyproject.toml +++ b/backend/pyproject.toml @@ -9,6 +9,8 @@ dependencies = [ "sqlalchemy>=2.0.0", "pydantic>=2.0.0", "pydantic-settings>=2.0.0", + "pillow>=10.0.0", + "httpx>=0.27.0", ] [dependency-groups] diff --git a/backend/tests/test_map_preview.py b/backend/tests/test_map_preview.py new file mode 100644 index 0000000..fbc437e --- /dev/null +++ b/backend/tests/test_map_preview.py @@ -0,0 +1,150 @@ +from unittest.mock import patch + +import pytest + +from app.config import settings +from app.services.map_preview import ( + deg2num, + extract_coordinates_from_text, + is_google_maps_host, + validate_google_maps_url_format, +) + +ADMIN_HEADERS = {"Remote-User": "kiskaadee"} + + +def test_is_google_maps_host(): + assert is_google_maps_host("maps.app.goo.gl") + assert is_google_maps_host("goo.gl") + assert is_google_maps_host("maps.google.com") + assert is_google_maps_host("google.com") + assert is_google_maps_host("www.google.com") + assert is_google_maps_host("google.es") + assert is_google_maps_host("maps.google.co.uk") + + assert not is_google_maps_host("example.com") + assert not is_google_maps_host("bing.com") + assert not is_google_maps_host("evilgoogle.com") + + +def test_validate_google_maps_url_format(): + validate_google_maps_url_format("https://maps.app.goo.gl/354784424357732") + validate_google_maps_url_format("https://www.google.com/maps/place/Fresco/@34.1,-118.2,17z") + validate_google_maps_url_format("https://maps.google.com/?q=34.1,-118.2") + + with pytest.raises(ValueError, match="no puede estar vacía"): + validate_google_maps_url_format("") + + with pytest.raises(ValueError, match="comenzar con http"): + validate_google_maps_url_format("ftp://maps.google.com") + + with pytest.raises(ValueError, match="enlace de Google Maps válido"): + validate_google_maps_url_format("https://apple.com/maps") + + +def test_extract_coordinates_from_text(): + # 1. @lat,lng + coords = extract_coordinates_from_text("https://google.com/maps/place/Venue/@34.143245,-118.255132,17z") + assert coords == (34.143245, -118.255132) + + # 2. !3dlat!4dlng + coords = extract_coordinates_from_text("https://google.com/maps/data=!4m6!3m5!1s0x0!8m2!3d4.6534!4d-74.0564") + assert coords == (4.6534, -74.0564) + + # 3. Query params: q=lat,lng + coords = extract_coordinates_from_text("https://maps.google.com/?q=34.1432,-118.2551") + assert coords == (34.1432, -118.2551) + + # 4. Query params: ll=lat,lng + coords = extract_coordinates_from_text("https://maps.google.com/maps?ll=34.1432,-118.2551&z=16") + assert coords == (34.1432, -118.2551) + + # 5. Non-coordinate text + assert extract_coordinates_from_text("https://maps.google.com/?q=Eiffel+Tower") is None + + +def test_deg2num(): + xtile, ytile = deg2num(34.1432, -118.2551, 16) + assert int(xtile) == 11240 + assert int(ytile) == 26148 + + +@patch("app.routes.admin.resolve_google_maps_coordinates") +@patch("app.routes.admin.generate_map_preview_image") +def test_admin_generate_map_preview_endpoint(mock_generate, mock_resolve, client, tmp_path): + mock_resolve.return_value = (34.1432, -118.2551, "https://resolved.url") + mock_generate.return_value = tmp_path / "map_preview.png" + + # Test without auth -> 401 + resp = client.post("/birthday/api/admin/map-preview/generate", json={"map_url": "https://maps.google.com/?q=34.1,-118.2"}) + assert resp.status_code == 401 + + # Test with auth -> 200 + resp = client.post( + "/birthday/api/admin/map-preview/generate", + headers=ADMIN_HEADERS, + json={"map_url": "https://maps.google.com/?q=34.1,-118.2"}, + ) + assert resp.status_code == 200 + data = resp.json() + assert "/birthday/api/map-preview.png" in data["map_preview_url"] + assert data["lat"] == 34.1432 + assert data["lng"] == -118.2551 + mock_resolve.assert_called_once_with("https://maps.google.com/?q=34.1,-118.2") + mock_generate.assert_called_once_with(34.1432, -118.2551) + + +@patch("app.routes.admin.resolve_google_maps_coordinates") +@patch("app.routes.admin.generate_map_preview_image") +def test_config_update_triggers_generator_only_when_map_url_changes(mock_generate, mock_resolve, client, tmp_path): + mock_resolve.return_value = (34.1432, -118.2551, "https://resolved.url") + mock_generate.return_value = tmp_path / "map_preview.png" + + # Get current config + current = client.get("/birthday/api/admin/config", headers=ADMIN_HEADERS).json() + orig_map_url = current["map_url"] + assert orig_map_url == "https://maps.google.com/?q=Fresco+Ristorante+Glendale+CA" + + # 1. Update config WITHOUT changing map_url -> generator NOT called + update_payload = {**current} + update_payload["honoree_name"] = "Updated Honoree" + resp = client.put("/birthday/api/admin/config", headers=ADMIN_HEADERS, json=update_payload) + assert resp.status_code == 200 + assert resp.json()["honoree_name"] == "Updated Honoree" + mock_resolve.assert_not_called() + mock_generate.assert_not_called() + + # 2. Update config WITH new map_url -> generator CALLED + update_payload["map_url"] = "https://maps.google.com/?q=34.1432,-118.2551" + resp = client.put("/birthday/api/admin/config", headers=ADMIN_HEADERS, json=update_payload) + assert resp.status_code == 200 + assert resp.json()["map_url"] == "https://maps.google.com/?q=34.1432,-118.2551" + assert resp.json()["map_preview_url"] == "/birthday/api/map-preview.png" + mock_resolve.assert_called_once_with("https://maps.google.com/?q=34.1432,-118.2551") + mock_generate.assert_called_once_with(34.1432, -118.2551) + + +def test_config_update_rejects_invalid_map_url(client): + current = client.get("/birthday/api/admin/config", headers=ADMIN_HEADERS).json() + bad_payload = {**current, "map_url": "https://invalid-non-google-url.com/something"} + + resp = client.put("/birthday/api/admin/config", headers=ADMIN_HEADERS, json=bad_payload) + assert resp.status_code == 422 + + +def test_get_map_preview_serving(client, tmp_path, monkeypatch): + # Case 1: file exists + test_img = tmp_path / "map_preview.png" + test_img.write_bytes(b"\x89PNG\r\n\x1a\nfakeimagebytes") + monkeypatch.setattr(settings, "DATA_DIR", str(tmp_path)) + + resp = client.get("/birthday/api/map-preview.png") + assert resp.status_code == 200 + assert resp.headers["content-type"] == "image/png" + assert resp.content == b"\x89PNG\r\n\x1a\nfakeimagebytes" + + # Case 2: file does not exist -> redirects to fallback + test_img.unlink() + resp_fallback = client.get("/birthday/api/map-preview.png", follow_redirects=False) + assert resp_fallback.status_code == 307 + assert "tile.openstreetmap.org" in resp_fallback.headers["location"] diff --git a/backend/uv.lock b/backend/uv.lock index 42b9f0b..22c442d 100644 --- a/backend/uv.lock +++ b/backend/uv.lock @@ -53,6 +53,8 @@ version = "0.1.0" source = { virtual = "." } dependencies = [ { name = "fastapi", extra = ["standard"] }, + { name = "httpx" }, + { name = "pillow" }, { name = "pydantic" }, { name = "pydantic-settings" }, { name = "sqlalchemy" }, @@ -70,6 +72,8 @@ dev = [ [package.metadata] requires-dist = [ { name = "fastapi", extras = ["standard"], specifier = ">=0.115.0" }, + { name = "httpx", specifier = ">=0.27.0" }, + { name = "pillow", specifier = ">=10.0.0" }, { name = "pydantic", specifier = ">=2.0.0" }, { name = "pydantic-settings", specifier = ">=2.0.0" }, { name = "sqlalchemy", specifier = ">=2.0.0" }, @@ -694,6 +698,91 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/63/34/ba1c580383c9eada3711951fef0795c80b829a078d72188184bcab9dd527/packaging-26.3-py3-none-any.whl", hash = "sha256:d7193f7c8e4e93f444fde0262bf90af30e16fa0ad0ad44cb553c87339b23cd1c", size = 129956, upload-time = "2026-08-04T18:15:27.159Z" }, ] +[[package]] +name = "pillow" +version = "12.3.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/1c/3d/bb7fca845737cf9d7dbde16ed1843984665ff2e0a518f5db43e77ec540b9/pillow-12.3.0.tar.gz", hash = "sha256:3b8182a766685eaa002637e28b4ec8d6b18819a0c71f579bf0dbaa5830297cce", size = 47025035, upload-time = "2026-07-01T11:56:38.965Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/fb/c8/0a78b0e02d7ac54bc03e5321c9220da52f0c2ea83b21f7c40e7f3169c502/pillow-12.3.0-cp311-cp311-macosx_10_10_x86_64.whl", hash = "sha256:00808c5e14ef63ac5161091d242999076604ff74b883423a11e5d7bbb38bf756", size = 5392415, upload-time = "2026-07-01T11:53:47.162Z" }, + { url = "https://files.pythonhosted.org/packages/b2/5b/a02d30018abd97ced9f5a6c63d28597694a00d066516b9c1c6de45859fc9/pillow-12.3.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:37d6d0a00072fd2948eb22bce7e1475f34569d90c87c59f7a2ec59541b77f7a6", size = 4785266, upload-time = "2026-07-01T11:53:49.079Z" }, + { url = "https://files.pythonhosted.org/packages/c8/98/766667a4be768150a202836acd9fad19c06824ca86c4286d3cf6b274964e/pillow-12.3.0-cp311-cp311-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:bcb46e2f9feff8d06323983bd83ed00c201fdcab3d74973e7072a889b3979fcd", size = 6263814, upload-time = "2026-07-01T11:53:51.32Z" }, + { url = "https://files.pythonhosted.org/packages/3b/2d/ede717bc1144f63886c21fd349bb95860b0d1a21149ff16f2bb362b612b6/pillow-12.3.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:23d27a3e0307ec2244cc51e7287b919aa68d097504ebe19df4e76a98a3eea5bd", size = 6934408, upload-time = "2026-07-01T11:53:53.487Z" }, + { url = "https://files.pythonhosted.org/packages/a3/48/9c58b685e69d49c31af6c8eb9012055fab7e665785165c84796e2c73ce72/pillow-12.3.0-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:4f883547d4b7f0495ebe7056b0cc2aea76094e7a4abc8e933540f3271df27d9c", size = 6337160, upload-time = "2026-07-01T11:53:55.457Z" }, + { url = "https://files.pythonhosted.org/packages/ff/fa/dc2a5c0ba6df93f67c31d34b808b7ce440b40cdbf96f0b81cde1d1e6fa93/pillow-12.3.0-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:236ff70b9312fb68943c703aa842ca6a758abfa45ac187a5e7c1452e96ef72b5", size = 7045172, upload-time = "2026-07-01T11:53:57.736Z" }, + { url = "https://files.pythonhosted.org/packages/86/a5/444817a4d4c4c2417df00513086ca196f388d8f9ef40c2e4ccd1ad1af54b/pillow-12.3.0-cp311-cp311-win32.whl", hash = "sha256:10e41f0fbf1eec8cfd234b8fe17a4caac7c9d0db4c204d3c173a8f9f6ef3232b", size = 6472232, upload-time = "2026-07-01T11:53:59.767Z" }, + { url = "https://files.pythonhosted.org/packages/63/c6/4bad1b18d132a50b27e1365e1ab163616f7a5bb56d330f66f9d1d9d4f9d4/pillow-12.3.0-cp311-cp311-win_amd64.whl", hash = "sha256:8e95e1385e4998ae9694eeaa4730ba5457ff61185b3a55e2e7bea0880aef452a", size = 7233653, upload-time = "2026-07-01T11:54:02.066Z" }, + { url = "https://files.pythonhosted.org/packages/fd/16/00f91ab7760dc842f5aad55217e80fc4a7067a0604535249bc8a2d6d9870/pillow-12.3.0-cp311-cp311-win_arm64.whl", hash = "sha256:ebaea975e03d3141d9d3a507df75c9b3ec90fa9d2ffd07567b3a978d9d790b26", size = 2568195, upload-time = "2026-07-01T11:54:04.622Z" }, + { url = "https://files.pythonhosted.org/packages/37/bf/fb3ebff8ddcb76aac5a01389251bbbb9519922a9b520d8247c1ca864a25d/pillow-12.3.0-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:ba09209fbe443b4acccebe845d8a138b89a8f4fbaeedd44953490b5315d5e965", size = 5345969, upload-time = "2026-07-01T11:54:06.397Z" }, + { url = "https://files.pythonhosted.org/packages/d8/66/9a386a92561f402389a4fc70c18838bf6d35eb5eb5c6850b4b2dc64f5048/pillow-12.3.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:ffd0c5368496f41b0944be820fcb7a838aa6e623d250b01acf2643939c3f99d7", size = 4780323, upload-time = "2026-07-01T11:54:09.351Z" }, + { url = "https://files.pythonhosted.org/packages/25/27/ac8f99618ffd3dde21db0f4d4b1d2ab00c0880595bfd17df103f7f39fd0c/pillow-12.3.0-cp312-cp312-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:d9c7f76c0673154f044e9d78c8655fb4213f6ca31a836df48b40fe5d187717b9", size = 6266838, upload-time = "2026-07-01T11:54:11.71Z" }, + { url = "https://files.pythonhosted.org/packages/84/21/a35af28dcc61f37ed850a2d64c65c701321dfbf25085e469d5559360cbbf/pillow-12.3.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:78cb2c6865a35ab8ff8b75fd122f6033b92a62c82801110e48ddd6c936a45d91", size = 6940830, upload-time = "2026-07-01T11:54:13.732Z" }, + { url = "https://files.pythonhosted.org/packages/eb/51/8b08617af3ad95e33ce6d7dd2c99ed6c8298f7fb131636303956be022e25/pillow-12.3.0-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:e491916b378fba47242221bb9ead245211b70d504f495d105d17b14a24b4907c", size = 6344383, upload-time = "2026-07-01T11:54:15.756Z" }, + { url = "https://files.pythonhosted.org/packages/1d/72/cf78ac9780bb93c28328f408973845a309d4d145041665f734572ced1b52/pillow-12.3.0-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:0dd2064cbc55aaec028ef5fbb60fa47bb6c3e7918e07ff17935284b227a9d2df", size = 7052934, upload-time = "2026-07-01T11:54:17.721Z" }, + { url = "https://files.pythonhosted.org/packages/20/20/25e0f4dc178a6bc0696793720055519a0de89e7661dae886992decbd2f81/pillow-12.3.0-cp312-cp312-win32.whl", hash = "sha256:dbce0b29841537a2fa4a214c2bbf14de3587c9680caa9b4e217568472490b28f", size = 6472684, upload-time = "2026-07-01T11:54:19.839Z" }, + { url = "https://files.pythonhosted.org/packages/45/89/da2f7971a317f83d807fdd4065c0af40208e59e692cc43d315a71a0e96d1/pillow-12.3.0-cp312-cp312-win_amd64.whl", hash = "sha256:a2b55dd6b2a4c4b7d87ffa56bdb33fdc5fdb9a462173861a7bc097f17d91cb09", size = 7227137, upload-time = "2026-07-01T11:54:22.025Z" }, + { url = "https://files.pythonhosted.org/packages/de/47/4845a0a6c0dbf1db8456bd9fc791f13c5ced7ced20606d08a0aacfd25b49/pillow-12.3.0-cp312-cp312-win_arm64.whl", hash = "sha256:331b624368d4f1d069149002f25f44bc61c8919ce8ddb3c45bdad8f6e2d89510", size = 2568267, upload-time = "2026-07-01T11:54:24.051Z" }, + { url = "https://files.pythonhosted.org/packages/9d/ac/31fb64e1e7efb5a4b50cd3d92049ba89ac6e4d8d3bb6a74e15048ca3353e/pillow-12.3.0-cp313-cp313-ios_13_0_arm64_iphoneos.whl", hash = "sha256:21900ce7ba264168cd50defae43cd75d25c833ad4ad6e73ffc5596d12e25ac89", size = 4161684, upload-time = "2026-07-01T11:54:25.934Z" }, + { url = "https://files.pythonhosted.org/packages/87/b4/9805e23d2b4d77842b468513841fda254ee42f0289d25088340e4ff46e2d/pillow-12.3.0-cp313-cp313-ios_13_0_arm64_iphonesimulator.whl", hash = "sha256:4e8c2a84d977f50b9daed6eeaf3baef67d00d5d74d932288f02cb94518ee3ace", size = 4255487, upload-time = "2026-07-01T11:54:27.935Z" }, + { url = "https://files.pythonhosted.org/packages/df/39/ecf519435a200c693fe053a6ee4d835b41cf963a4dfc2551c4e637cb2a71/pillow-12.3.0-cp313-cp313-ios_13_0_x86_64_iphonesimulator.whl", hash = "sha256:ae26d61dfa7a47befdc7572b521024e8745f3d809bd95ca9505a7bba9ef849ec", size = 3696433, upload-time = "2026-07-01T11:54:29.813Z" }, + { url = "https://files.pythonhosted.org/packages/42/92/2fc3ffad878ae8dd5469ec1bc8eb83b71f48e13efdf68f02709003982a32/pillow-12.3.0-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:7a743ff716f746fc19a9557f60dab1600d4613255f8a7aeb3cdde4db7eb15a66", size = 5345889, upload-time = "2026-07-01T11:54:31.97Z" }, + { url = "https://files.pythonhosted.org/packages/10/76/8803c13605b763d33d156c4678fc77f8443389c0c51c8aef707bb02015f4/pillow-12.3.0-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:d69141514cc30b774ceea5e3ed3a6635c8d8a96edf664689b890f4089111fb35", size = 4780109, upload-time = "2026-07-01T11:54:34.026Z" }, + { url = "https://files.pythonhosted.org/packages/1f/01/e18aff37cb0b4aac47ac90f016d347a49aca667ef97f190b06ac2aabc928/pillow-12.3.0-cp313-cp313-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:f7401aebd7f581d7f83a439d87d474999317ee099218e5ad25d125290990ba65", size = 6263736, upload-time = "2026-07-01T11:54:36.131Z" }, + { url = "https://files.pythonhosted.org/packages/f7/62/de5bdd77d935331f4f802edc11e4d82950f642caad6cb2f949837b8560e2/pillow-12.3.0-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:0847a763afefb695bc912d7c131e7e0632d4edc1d8698f58ddabec8e46b8b6d3", size = 6937129, upload-time = "2026-07-01T11:54:38.216Z" }, + { url = "https://files.pythonhosted.org/packages/70/4d/105627a13300c5e0df1d174230b32fd1273062c96f7745fd552b945d1e1d/pillow-12.3.0-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:571b9fcb07b97ef3a492028fb3d2dc0993ca23a06138b0315286566d29ef718a", size = 6339562, upload-time = "2026-07-01T11:54:40.354Z" }, + { url = "https://files.pythonhosted.org/packages/6b/1d/f13de01a553988ab895ba1c722e06cf3144d4f57656fd5b81b6d881f1179/pillow-12.3.0-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:756c768d0c9c2955feb7a56c37ea24aea2e369f8d36a88da270b6a9f19e62b5e", size = 7049439, upload-time = "2026-07-01T11:54:42.489Z" }, + { url = "https://files.pythonhosted.org/packages/c9/f9/066794cca041b969964f779ee5fa66a9498bbf34248ac39c5d7954e4198f/pillow-12.3.0-cp313-cp313-win32.whl", hash = "sha256:a876864214e136f0eb367788dbd7df045f4806801518e2cfe9e13229cfe06d8f", size = 6473287, upload-time = "2026-07-01T11:54:44.9Z" }, + { url = "https://files.pythonhosted.org/packages/a6/9b/7a58e61d62be561da3a356fe2384d4059a6345fc130e23ef1c36a5b81d24/pillow-12.3.0-cp313-cp313-win_amd64.whl", hash = "sha256:1cca606cd25738df4ed873d5ad46bbdb3d83b5cbca291f6b4ff13a4df6b0bbe8", size = 7239691, upload-time = "2026-07-01T11:54:47.141Z" }, + { url = "https://files.pythonhosted.org/packages/aa/b0/c4ed4f0ef8f8fa5ee8351537db6650bb8189f7e118842978dd6589065692/pillow-12.3.0-cp313-cp313-win_arm64.whl", hash = "sha256:b629de27fda84b42cde7edef0d85f13b958b47f6e9bbcbba9b673c562a89bd8b", size = 2568185, upload-time = "2026-07-01T11:54:49.137Z" }, + { url = "https://files.pythonhosted.org/packages/dc/01/001f65b68192f0228cc1dbbc8d2530ab5d58b61037ba0587f946fea607cd/pillow-12.3.0-cp314-cp314-ios_13_0_arm64_iphoneos.whl", hash = "sha256:9cf95fe4d0f84c82d282745d9bb08ad9f926efa00be4697e767b814ce40d4330", size = 4161736, upload-time = "2026-07-01T11:54:51.156Z" }, + { url = "https://files.pythonhosted.org/packages/1a/d2/0219746d0fd16fc8a84498e79452375be3797d3ce4044596ce565164b84f/pillow-12.3.0-cp314-cp314-ios_13_0_arm64_iphonesimulator.whl", hash = "sha256:8728f216dcdb6e6d555cf971cb34076139ad74b31fc2c14da4fafc741c5f6217", size = 4255435, upload-time = "2026-07-01T11:54:53.414Z" }, + { url = "https://files.pythonhosted.org/packages/c8/02/8d0bc62ef0302318c46ff2a512822d2610e81c7aa46c9b3abe6cbaca5ad0/pillow-12.3.0-cp314-cp314-ios_13_0_x86_64_iphonesimulator.whl", hash = "sha256:a45650e8ce7fafffd731db8550230db6b0d306d181a90b67d3e6bca2f1990930", size = 3696262, upload-time = "2026-07-01T11:54:55.739Z" }, + { url = "https://files.pythonhosted.org/packages/85/e2/73c77d218410b14f5f2d565e8a998d5317b7b9c75368d29985139f7a46f0/pillow-12.3.0-cp314-cp314-macosx_10_15_x86_64.whl", hash = "sha256:ba54cfebe86920a559a7c4d6b9050791c20513650a1952ebe3368c7dc70306f8", size = 5350344, upload-time = "2026-07-01T11:54:57.657Z" }, + { url = "https://files.pythonhosted.org/packages/c7/da/32c752228ae345f489e3a42499d817b6c3996da7e8a3bc7a04fc806b243b/pillow-12.3.0-cp314-cp314-macosx_11_0_arm64.whl", hash = "sha256:e158cb00350dc278f3b91551101aa7d12415a66ebf2c91d8d5ac14e56ddd3ad0", size = 4780131, upload-time = "2026-07-01T11:54:59.713Z" }, + { url = "https://files.pythonhosted.org/packages/b1/9d/8b2c807dbef61a5197c047afe99823787eb66f63daf9fb2432f91d6f0462/pillow-12.3.0-cp314-cp314-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:e9aeb04d6aef139de265b29683e119b638208f88cf73cdd1658aa07221165321", size = 6263757, upload-time = "2026-07-01T11:55:01.778Z" }, + { url = "https://files.pythonhosted.org/packages/5c/44/c85361f65dbe00eea8576ee467c768d25129989efb76e94f205e9ca9bb46/pillow-12.3.0-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:251bf95b67017e27b13d82f5b326234ca62d70f9cf4c2b9032de2358a3b12c7b", size = 6936962, upload-time = "2026-07-01T11:55:03.93Z" }, + { url = "https://files.pythonhosted.org/packages/18/7e/e483414b35800b86b6f08dbbc7803fb5cd52c4d6f897f47d53ea2c7e6f65/pillow-12.3.0-cp314-cp314-musllinux_1_2_aarch64.whl", hash = "sha256:fe3cca2e4e8a592be0f269a1ca4835c25199d9f3ce815c8491048f785b0a0198", size = 6339171, upload-time = "2026-07-01T11:55:05.989Z" }, + { url = "https://files.pythonhosted.org/packages/f0/f4/68c491844841ede6bed70189546b3ee9731cf9f2cbad396faff5e1ccba45/pillow-12.3.0-cp314-cp314-musllinux_1_2_x86_64.whl", hash = "sha256:23aceaa007d6172b02c277f0cd359c79492bbb14f7072b4ede9fbcaf20648130", size = 7048116, upload-time = "2026-07-01T11:55:08.131Z" }, + { url = "https://files.pythonhosted.org/packages/a3/34/77f3f793fed8efc7d243f21b33c5a3f0d1c97ee70346d3db855587e155ff/pillow-12.3.0-cp314-cp314-win32.whl", hash = "sha256:af8d94b0db561cf68b88a267c5c44b49e134f525d0dc2cb7ed413a66bc23559a", size = 6467209, upload-time = "2026-07-01T11:55:10.408Z" }, + { url = "https://files.pythonhosted.org/packages/f1/e0/492879f69d94f91f60fc8cd05ba03650e9520afebb2fb7aa12777d7c7f38/pillow-12.3.0-cp314-cp314-win_amd64.whl", hash = "sha256:fdafc9cce40277e0f7a0feabce0ee50dd2fa1800f3b38015e51296b5e814048d", size = 7237707, upload-time = "2026-07-01T11:55:12.745Z" }, + { url = "https://files.pythonhosted.org/packages/c9/ac/6b11f2875f1c2ac040d84e1bbf9cf22a88038f901ca1037898b280b38365/pillow-12.3.0-cp314-cp314-win_arm64.whl", hash = "sha256:e91206ee562682b51b98ef4b26a6ef48fd84e15fd4c4bc5ec768eb641d206838", size = 2565995, upload-time = "2026-07-01T11:55:14.736Z" }, + { url = "https://files.pythonhosted.org/packages/52/69/c2208e56af9bfc1913afb24020297a691eb1d4ef688474c8a04913f65e04/pillow-12.3.0-cp314-cp314t-macosx_10_15_x86_64.whl", hash = "sha256:164b31cd1a0490ab6efae01aa5df49da7061be0af1b30e035b6e9a1bfe34ee6e", size = 5352503, upload-time = "2026-07-01T11:55:17.076Z" }, + { url = "https://files.pythonhosted.org/packages/07/70/e5686d753e898a45d778ff1718dba8516ead6ab6b95d85fc8c4b70650cf2/pillow-12.3.0-cp314-cp314t-macosx_11_0_arm64.whl", hash = "sha256:5afb51d599ea772b8365ae807ae557f18bccfe46ab261fd1c2a9ed700fc6eb17", size = 4782956, upload-time = "2026-07-01T11:55:19.448Z" }, + { url = "https://files.pythonhosted.org/packages/d5/37/25c6692f06927ee973ff18c8d9ee98ad0b4d84ee67a09610c2dd1447958e/pillow-12.3.0-cp314-cp314t-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:3edce1d53195db527e0191f84b71d02022de0540bf43a16ed734ed7537b07385", size = 6322855, upload-time = "2026-07-01T11:55:21.613Z" }, + { url = "https://files.pythonhosted.org/packages/cc/91/420637fcb8f1bc11029e403b4538e6694744428d8246118e45719f944556/pillow-12.3.0-cp314-cp314t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:bf16ba1b4d0b6b7c8e534936632270cf70eb00dbe09005bc345b2677b726855c", size = 6989642, upload-time = "2026-07-01T11:55:24.006Z" }, + { url = "https://files.pythonhosted.org/packages/10/08/b94d7811281ccf0d143a1cf768d1c49e1e54af63e7b708ab2ee3eb87face/pillow-12.3.0-cp314-cp314t-musllinux_1_2_aarch64.whl", hash = "sha256:24870b09b224f7ae3c39ed07d10e819d06f8720bc551847b1d623832b5b0e28d", size = 6391281, upload-time = "2026-07-01T11:55:26.252Z" }, + { url = "https://files.pythonhosted.org/packages/d2/87/24233f785f55474dc02ce3e739c5528a77e3a862e9333d1dd7a25cc31f70/pillow-12.3.0-cp314-cp314t-musllinux_1_2_x86_64.whl", hash = "sha256:30f2aa603c41533cc25c05acd0da21636e84a315768feb631c937177db558931", size = 7096716, upload-time = "2026-07-01T11:55:28.318Z" }, + { url = "https://files.pythonhosted.org/packages/23/26/fcb2f6e37175b04f53570b59937867e2b80ee1685e744023153028fc14f9/pillow-12.3.0-cp314-cp314t-win32.whl", hash = "sha256:4b0a7fe987b14c31ebda6083f74f22b561fd3739bc0ac51e019622e3d72668c7", size = 6474125, upload-time = "2026-07-01T11:55:30.956Z" }, + { url = "https://files.pythonhosted.org/packages/90/de/3634abee5f1c9e13c56787b7d5517b0ba8d6de51700b95578cf338349c9f/pillow-12.3.0-cp314-cp314t-win_amd64.whl", hash = "sha256:962864dc93511324d51ddbb5b9f8731bf71675b93ca612a07441896f4688fb8c", size = 7242939, upload-time = "2026-07-01T11:55:34.044Z" }, + { url = "https://files.pythonhosted.org/packages/ce/2a/fd13f8eb24de5714a6eb444a3d67e2842c6c576e159a43793adf23051351/pillow-12.3.0-cp314-cp314t-win_arm64.whl", hash = "sha256:0740a512dc522224c77d9aa5a8d70d8b7d73fb91f2c21125d8d025d3b8990e45", size = 2567506, upload-time = "2026-07-01T11:55:35.988Z" }, + { url = "https://files.pythonhosted.org/packages/5d/dc/8fdce34ec725a33c81c6ba122b904d6b9024e50ea9ac7bede62fab54506c/pillow-12.3.0-cp315-cp315-ios_13_0_arm64_iphoneos.whl", hash = "sha256:0feb2e9d6ad6c9e3c06effe9d00f3f1e618a6643273576b016f591e9315a7139", size = 4162063, upload-time = "2026-07-01T11:55:37.941Z" }, + { url = "https://files.pythonhosted.org/packages/76/66/2044b9a63d3b84ff048228dfcb7cd9bf0df983e8470971bf7d4c57b693de/pillow-12.3.0-cp315-cp315-ios_13_0_arm64_iphonesimulator.whl", hash = "sha256:9e881fca225083806662a5c43d627d215f258ff43c890f831966c7d7ba9c7402", size = 4255549, upload-time = "2026-07-01T11:55:40.022Z" }, + { url = "https://files.pythonhosted.org/packages/52/7e/1f67e6f4ece6b582ee4b539decbcc9f848dc245a93ed8cd7338bafef72f1/pillow-12.3.0-cp315-cp315-ios_13_0_x86_64_iphonesimulator.whl", hash = "sha256:4998562bf62a445225f22e07c896bb04b35b1b1f2eb6d760584c9c51d7a5f78c", size = 3696331, upload-time = "2026-07-01T11:55:41.98Z" }, + { url = "https://files.pythonhosted.org/packages/12/40/d306fc2c8e4d45d7f175c77edca7063be7b86fe7fe6e68f4353bf71d808c/pillow-12.3.0-cp315-cp315-macosx_10_15_x86_64.whl", hash = "sha256:dc624f6bc473dacdf7ef7eb8678d0d08edf15cd94fad6ae5c7d6cc67a4e4902f", size = 5350370, upload-time = "2026-07-01T11:55:44.028Z" }, + { url = "https://files.pythonhosted.org/packages/dd/44/668fb1437e8ce420f62d6106eb66e44a5971602a4d794615bdf79315d82d/pillow-12.3.0-cp315-cp315-macosx_11_0_arm64.whl", hash = "sha256:71d6097b330eea8fd15097780c8e89cb1a8ce7838669f48c5bacd6f663dd4701", size = 4780147, upload-time = "2026-07-01T11:55:46.073Z" }, + { url = "https://files.pythonhosted.org/packages/0c/08/93fa2e70e30a2d81547e481b6ee2bb9522117221fb1e0ce4b5df70967677/pillow-12.3.0-cp315-cp315-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:28ce87c5ab450a9dd970b52e5aca5fe63ed432d18a2eaddd1979a00a1ba24ace", size = 6273659, upload-time = "2026-07-01T11:55:48.264Z" }, + { url = "https://files.pythonhosted.org/packages/f8/6d/043e96ff814fc31a33077e4cba86082167db520c93632afdf2042febbb0c/pillow-12.3.0-cp315-cp315-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:6b02afb9b97f65fbca5f31db6a2a3ba21aa93030225f150fa3f249717e938fb4", size = 6947439, upload-time = "2026-07-01T11:55:50.503Z" }, + { url = "https://files.pythonhosted.org/packages/af/92/ba71d2ee2ac0edf3fa33bd9d5ee9ee080da70b1766f3ca3934f9938ddac9/pillow-12.3.0-cp315-cp315-musllinux_1_2_aarch64.whl", hash = "sha256:1182d52bc2d5e5d7d0949503aa7e36d12f42205dc287e4883f407b1988820d39", size = 6353577, upload-time = "2026-07-01T11:55:52.697Z" }, + { url = "https://files.pythonhosted.org/packages/0f/ce/e63064e2122923ff687c8ad792d0d736a7b3920a56a46982e81a7fdd25d6/pillow-12.3.0-cp315-cp315-musllinux_1_2_x86_64.whl", hash = "sha256:e795b7eb908249c4e43c7c99fac7c2c75dab0c43566e37db472a355f63693d71", size = 7060394, upload-time = "2026-07-01T11:55:55.149Z" }, + { url = "https://files.pythonhosted.org/packages/54/76/a09cc3ccc8d773a7283d34c38bec1708f9e3cc932093cbc4c5e71ac4060b/pillow-12.3.0-cp315-cp315-win32.whl", hash = "sha256:57b3d78c95ba9059768b10e28b813002261d3f3dfc55cc48b0c988f625175827", size = 6467375, upload-time = "2026-07-01T11:55:57.769Z" }, + { url = "https://files.pythonhosted.org/packages/3e/03/1846c49ba3b1d5550392a4bbd06d6fb4578e1cd91a803198b5c90f5f7d53/pillow-12.3.0-cp315-cp315-win_amd64.whl", hash = "sha256:fa4ecea169a355be7a3ade2c783e2ed12f0e40d2c5621cda8b3297faf7fbb9f5", size = 7237048, upload-time = "2026-07-01T11:55:59.975Z" }, + { url = "https://files.pythonhosted.org/packages/fb/bb/89f35dcc79610423f9f195504d7def7f0d1416a711541b42867e25fe3412/pillow-12.3.0-cp315-cp315-win_arm64.whl", hash = "sha256:877c3f311ff35410f690861c4409e7ccbf0cd2f878e50628a28e5a0bb689e658", size = 2566006, upload-time = "2026-07-01T11:56:02.143Z" }, + { url = "https://files.pythonhosted.org/packages/30/88/707027ba09942dfa2c28759b5c222d769290a41c6d20ea60ec250801941f/pillow-12.3.0-cp315-cp315t-macosx_10_15_x86_64.whl", hash = "sha256:e9871b1ffbfa9656b60aeee92ed5136a5742696006fa322b29ea3d8da0ecc9cf", size = 5352509, upload-time = "2026-07-01T11:56:04.2Z" }, + { url = "https://files.pythonhosted.org/packages/b0/6d/00352fa25332c2569cd387851f568cc5a4b75a9adbfb37ac4fbce4c02eec/pillow-12.3.0-cp315-cp315t-macosx_11_0_arm64.whl", hash = "sha256:53aa02d20d10c3d814d536aa4e5ac9b84ca0ff5a88377963b085ad6822f93e64", size = 4783167, upload-time = "2026-07-01T11:56:06.631Z" }, + { url = "https://files.pythonhosted.org/packages/13/4f/9e049dfa21af7c22427275720e2490267ba8138120add5c4c574deb69782/pillow-12.3.0-cp315-cp315t-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:446c34dcc4324b084a53b705127dc15717b22c5e140ae0a3c38349d4efec071e", size = 6329237, upload-time = "2026-07-01T11:56:08.868Z" }, + { url = "https://files.pythonhosted.org/packages/36/16/cf6eeaae8d0fce8dd390a33437cf68c5d5bd73834a2bc6e2f14efda0ab45/pillow-12.3.0-cp315-cp315t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:cf1845d02ad822a369a49f2bb9345b1614744267682e7a03527dc3bf6eea1777", size = 6997047, upload-time = "2026-07-01T11:56:11.379Z" }, + { url = "https://files.pythonhosted.org/packages/1e/69/dbf769bdd55f48bf5733cac28edc6364ffaa072ec9ba336266e4fe66be55/pillow-12.3.0-cp315-cp315t-musllinux_1_2_aarch64.whl", hash = "sha256:186941b6aef820ad110fb01fb06eb925374dc3a21b17e37ec9a53b250c6fe2d1", size = 6400440, upload-time = "2026-07-01T11:56:13.908Z" }, + { url = "https://files.pythonhosted.org/packages/a0/e1/ffc9cfc2eea0d178da8018e18e959301ad9d6bc9f3edb7181e748a474b97/pillow-12.3.0-cp315-cp315t-musllinux_1_2_x86_64.whl", hash = "sha256:f13c32a3abd6079a66d9526e18dad9b6d280384d49d7c54040cd57b6424041d9", size = 7105895, upload-time = "2026-07-01T11:56:16.575Z" }, + { url = "https://files.pythonhosted.org/packages/18/f0/a5595c1e8c3ae44b9828cb2f0fa8155e5095ef04d6327b8f61cf44a3df85/pillow-12.3.0-cp315-cp315t-win32.whl", hash = "sha256:1657923d2d45afb66526e5b933e5b3052e6bdea196c90d3abb2424e18c77dae8", size = 6474384, upload-time = "2026-07-01T11:56:18.855Z" }, + { url = "https://files.pythonhosted.org/packages/e4/04/62bcd9f844984c5938d3b05264a61d797a29d3e0812341a8204af70bbdee/pillow-12.3.0-cp315-cp315t-win_amd64.whl", hash = "sha256:8cd2f7bdda092d99c9fc2fb7391354f306d01443d22785d0cbfafa2e2c8bb418", size = 7243537, upload-time = "2026-07-01T11:56:21.214Z" }, + { url = "https://files.pythonhosted.org/packages/3d/68/1f3066acedf37673694a7141381d8f811ae97f30d34413d236abe7d489f1/pillow-12.3.0-cp315-cp315t-win_arm64.whl", hash = "sha256:06ff022112bc9cbf83b60f8e028d94ad87b60621706487e65f673de61610ab59", size = 2567491, upload-time = "2026-07-01T11:56:23.506Z" }, + { url = "https://files.pythonhosted.org/packages/75/18/2e8b40223153ccbc60df07f9e8928dc0c76202aa4e55ae9f53962b6510d6/pillow-12.3.0-pp311-pypy311_pp73-macosx_10_15_x86_64.whl", hash = "sha256:b3c777e849237620b022f7f297dd67705f9f5cf1685f09f02e46f93e92725468", size = 5302510, upload-time = "2026-07-01T11:56:25.736Z" }, + { url = "https://files.pythonhosted.org/packages/46/3e/51fabf59d5ab801ceab709453d3ab6b180083496579549de4c45ced6528a/pillow-12.3.0-pp311-pypy311_pp73-macosx_11_0_arm64.whl", hash = "sha256:b343699e8308bdc51978310e1c959c584e7869cc8c40780058c87da7781a1e94", size = 4736058, upload-time = "2026-07-01T11:56:28.041Z" }, + { url = "https://files.pythonhosted.org/packages/bf/20/22fe9384b7949e25fb1293bcfc84fb82590ff4ea6b37c95b24d26d793d86/pillow-12.3.0-pp311-pypy311_pp73-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:fbd139c8447d25dd750ab79ee274cc5e1fe80fc56340ab10b18a195e1b6eca3e", size = 5237776, upload-time = "2026-07-01T11:56:30.263Z" }, + { url = "https://files.pythonhosted.org/packages/08/14/f6ba68107680ffa74b39985f3f30884e41318fbc4250caa423c79b4788bb/pillow-12.3.0-pp311-pypy311_pp73-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:e7e480451b9fa137494bccd3a7d69adbe8ac65a87d97be61e11f1b1050a5bac3", size = 5860358, upload-time = "2026-07-01T11:56:32.68Z" }, + { url = "https://files.pythonhosted.org/packages/36/54/0169bc772ec491108b62f644f8ecf1fe5d8ae5ebafde2ee2142210166903/pillow-12.3.0-pp311-pypy311_pp73-win_amd64.whl", hash = "sha256:04f01d28a6aaff387bf842a13be313df23ba0597a44f1a976c9feb3c6ff4711a", size = 7231786, upload-time = "2026-07-01T11:56:35.046Z" }, +] + [[package]] name = "pluggy" version = "1.6.0" diff --git a/frontend/src/admin/ConfigEditor.tsx b/frontend/src/admin/ConfigEditor.tsx index 6a4c99f..8e5d88b 100644 --- a/frontend/src/admin/ConfigEditor.tsx +++ b/frontend/src/admin/ConfigEditor.tsx @@ -1,5 +1,5 @@ import { type FormEvent, useEffect, useState } from "react"; -import { fetchAdminConfig, updateAdminConfig } from "../api/client"; +import { fetchAdminConfig, regenerateMapPreview, updateAdminConfig } from "../api/client"; import { Button } from "../components/Button"; import { Field } from "../components/Field"; import { Spinner } from "../components/Spinner"; @@ -9,6 +9,11 @@ export function ConfigEditor() { const [formData, setFormData] = useState(null); const [loading, setLoading] = useState(true); const [saving, setSaving] = useState(false); + const [regeneratingMap, setRegeneratingMap] = useState(false); + const [mapNotice, setMapNotice] = useState<{ + type: "success" | "error"; + msg: string; + } | null>(null); const [feedback, setFeedback] = useState<{ type: "success" | "error"; msg: string; @@ -58,6 +63,28 @@ export function ConfigEditor() { } } + async function handleRegenerateMap() { + if (!formData?.map_url || regeneratingMap) return; + setRegeneratingMap(true); + setMapNotice(null); + + try { + const res = await regenerateMapPreview(formData.map_url); + setFormData({ ...formData, map_preview_url: res.map_preview_url }); + setMapNotice({ + type: "success", + msg: `¡Vista previa regenerada con éxito! (Coordenadas: ${res.lat.toFixed(4)}, ${res.lng.toFixed(4)})`, + }); + } catch (err) { + setMapNotice({ + type: "error", + msg: err instanceof Error ? err.message : "Error al regenerar el mapa.", + }); + } finally { + setRegeneratingMap(false); + } + } + if (loading) { return (
@@ -226,12 +253,116 @@ export function ConfigEditor() { />
- handleChange("map_preview_url", e.target.value)} - required - /> +
+ {/* Visual circular thumbnail preview */} +
+ {formData.map_preview_url ? ( + Vista previa mapa + ) : ( +
+ Sin mapa +
+ )} +
+ +
+ handleChange("map_preview_url", e.target.value)} + required + /> +
+ + + Genera la imagen en disco sin guardar aún en la BD. + +
+ {mapNotice && ( +
+ {mapNotice.msg} +
+ )} +
+
{ + const res = await fetch(`${BASE_API}/admin/map-preview/generate`, { + method: "POST", + headers: { + "Content-Type": "application/json", + Accept: "application/json", + }, + body: JSON.stringify({ map_url: mapUrl }), + }); + + if (!res.ok) { + const errorJson = await res.json().catch(() => null); + const msg = + errorJson?.detail || + (errorJson?.errors + ? Object.values(errorJson.errors).join(", ") + : `HTTP ${res.status}`); + throw new Error(msg || "Error al regenerar vista previa del mapa."); + } + return res.json(); +} diff --git a/specs/backend.md b/specs/backend.md index 8ecb485..210eff7 100644 --- a/specs/backend.md +++ b/specs/backend.md @@ -131,12 +131,14 @@ flowchart LR subgraph Public A["GET /birthday/api/config"] B["POST /birthday/api/rsvp"] + G["GET /birthday/api/map-preview.png"] end subgraph Admin["Admin (Remote-User required)"] C["GET /birthday/api/admin/rsvps"] D["GET /birthday/api/admin/export"] E["GET /birthday/api/admin/config"] F["PUT /birthday/api/admin/config"] + H["POST /birthday/api/admin/map-preview/generate"] end ``` @@ -150,6 +152,14 @@ Serves the invitation configuration to the guest frontend. - **Response `200`:** Full `InvitationConfig` object — all fields from the config table. - **Response `500`:** `{"result": "ERROR"}` (if no config row exists — should not happen after seeding) +#### `GET /birthday/api/map-preview.png` + +Serves the locally generated OpenStreetMap static crop image centered on the event venue. + +- **Auth:** None (public) +- **Response `200`:** `image/png` static file with caching headers (`Cache-Control: public, max-age=300`). +- **Fallback:** 307 Redirect to default OSM tile if the image file has not yet been generated. + #### `POST /birthday/api/rsvp` Submit an RSVP. @@ -245,8 +255,28 @@ Update configuration (full object replacement). - `event_date` is a valid ISO 8601 date - `event_time` is a valid `HH:MM` (24-hour) string - `event_timezone` is a valid IANA timezone identifier - - URL fields are valid URLs + - `map_url` is a valid Google Maps URL format (`maps.app.goo.gl`, `goo.gl`, or `google.com/maps`) - Text fields are non-empty where required +- **Conditional Map Regeneration:** + - If `map_url` changed compared to the stored singleton, the backend automatically resolves destination coordinates, generates a fresh OpenStreetMap stitched preview PNG on disk, and points `map_preview_url` to `/birthday/api/map-preview.png`. + - If `map_url` did not change, no external network calls or image generation occur. + +#### `POST /birthday/api/admin/map-preview/generate` + +Regenerates the venue map preview image on disk without requiring full configuration updates or database writes. + +- **Request body:** Optional JSON `{"map_url": "..."}`. If omitted, uses the currently persisted `map_url`. +- **Response `200`:** + ```json + { + "map_preview_url": "/birthday/api/map-preview.png?t=1759338600", + "lat": 34.1432, + "lng": -118.2551, + "message": "Vista previa del mapa generada con éxito." + } + ``` +- **Error `422`:** If the provided URL cannot be parsed into valid geographic coordinates. +- **Side Effect:** Writes `data/map_preview.png` directly to disk, cache-busting via the returned timestamp. ---