- simple-icons als kompakter Index im Repository (3.459 Marken, 2 MB gzip),
erzeugt von scripts/vendor_simple_icons.py bzw. `make vendor-icons`
- logo.dev und Brandfetch als optionale Adapter, ohne Schlüssel übersprungen
- Favicon-Fallback und generierter Buchstaben-Avatar als Garantie
- Bei eindeutigem Offline-Treffer unterbleiben Anfragen nach außen komplett
- Cache im Dateisystem nach SHA-256, Auslieferung nur über /api/logos/{id}
mit immutable-Header und ETag
- Markenfarbe aus SVG-Fills bzw. per k-Means (k=4) über 64x64 Pixel, dazu eine
aufgehellte Variante mit mindestens 4,5:1 Kontrast auf dunklem Grund
- Kandidatensuche mit Vorauswahl, Auswahl, Upload und Zurücksetzen
- Bildtyp wird nur noch am Inhalt bestimmt, nicht an der gemeldeten Kopfzeile
- 60 neue Tests, insgesamt 208 grün
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014e7t8UpmoVNMtWivY5LiSH
75 lines
2.2 KiB
Python
75 lines
2.2 KiB
Python
"""Schemata für Firmen und Zahlungsempfänger."""
|
|
|
|
from datetime import datetime
|
|
|
|
from pydantic import Field
|
|
|
|
from app.models.enums import LogoSource, LogoStatus
|
|
from app.schemas.common import ApiModel, HexColor, InputModel
|
|
|
|
|
|
class MerchantCreate(InputModel):
|
|
name: str = Field(min_length=1, max_length=160, examples=["Netflix"])
|
|
domain: str | None = Field(
|
|
default=None,
|
|
max_length=255,
|
|
examples=["netflix.com"],
|
|
description="Verbessert die Trefferquote der Logosuche erheblich.",
|
|
)
|
|
aliases: list[str] = Field(
|
|
default_factory=list, description="Weitere Schreibweisen, etwa aus Kontoauszügen."
|
|
)
|
|
brand_color: HexColor | None = None
|
|
brand_color_dark: HexColor | None = None
|
|
|
|
|
|
class MerchantUpdate(InputModel):
|
|
name: str | None = Field(default=None, min_length=1, max_length=160)
|
|
domain: str | None = Field(default=None, max_length=255)
|
|
aliases: list[str] | None = None
|
|
brand_color: HexColor | None = None
|
|
brand_color_dark: HexColor | None = None
|
|
|
|
|
|
class MerchantOut(ApiModel):
|
|
id: int
|
|
name: str
|
|
normalized_name: str
|
|
domain: str | None
|
|
aliases: list[str]
|
|
logo_asset_id: int | None = Field(
|
|
description="Wenn gesetzt, ist das Logo unter /api/logos/{id} abrufbar."
|
|
)
|
|
brand_color: str | None
|
|
brand_color_dark: str | None
|
|
logo_source: LogoSource | None
|
|
logo_status: LogoStatus
|
|
created_at: datetime
|
|
|
|
|
|
class LogoCandidateOut(ApiModel):
|
|
"""Ein zur Auswahl stehendes Logo. Die Datei liegt bereits im lokalen Cache."""
|
|
|
|
candidate_id: int = Field(description="ID für /api/logos/{id} und für die Auswahl.")
|
|
source: LogoSource
|
|
title: str
|
|
score: float = Field(
|
|
ge=0, le=1, description="Trefferwahrscheinlichkeit; der höchste Wert ist vorausgewählt."
|
|
)
|
|
mime: str
|
|
width: int | None = None
|
|
height: int | None = None
|
|
brand_color: str | None = None
|
|
is_preselected: bool = Field(description="Genau ein Kandidat ist vorausgewählt.")
|
|
|
|
|
|
class LogoSearchOut(ApiModel):
|
|
"""Ergebnis der Logosuche."""
|
|
|
|
merchant_id: int
|
|
candidates: list[LogoCandidateOut]
|
|
|
|
|
|
class LogoSelectRequest(InputModel):
|
|
candidate_id: int = Field(description="ID aus der Kandidatenliste.")
|