Tighten provider normalization contract and fallback semantics
This commit is contained in:
109
apps/providers/contracts.py
Normal file
109
apps/providers/contracts.py
Normal file
@ -0,0 +1,109 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import NotRequired, TypedDict
|
||||
|
||||
|
||||
class NationalityPayload(TypedDict):
|
||||
name: str
|
||||
iso2_code: str
|
||||
iso3_code: NotRequired[str | None]
|
||||
|
||||
|
||||
class PositionPayload(TypedDict):
|
||||
code: str
|
||||
name: str
|
||||
|
||||
|
||||
class RolePayload(TypedDict):
|
||||
code: str
|
||||
name: str
|
||||
|
||||
|
||||
class PlayerPayload(TypedDict):
|
||||
external_id: str
|
||||
first_name: str
|
||||
last_name: str
|
||||
full_name: str
|
||||
birth_date: str | None
|
||||
nationality: NationalityPayload | None
|
||||
nominal_position: PositionPayload | None
|
||||
inferred_role: RolePayload | None
|
||||
height_cm: int | None
|
||||
weight_kg: int | None
|
||||
dominant_hand: str
|
||||
is_active: bool
|
||||
aliases: list[str]
|
||||
|
||||
|
||||
class CompetitionPayload(TypedDict):
|
||||
external_id: str
|
||||
name: str
|
||||
slug: str
|
||||
competition_type: str
|
||||
gender: str
|
||||
level: int
|
||||
country: NationalityPayload | None
|
||||
is_active: bool
|
||||
|
||||
|
||||
class TeamPayload(TypedDict):
|
||||
external_id: str
|
||||
name: str
|
||||
short_name: str
|
||||
slug: str
|
||||
country: NationalityPayload | None
|
||||
is_national_team: bool
|
||||
|
||||
|
||||
class SeasonPayload(TypedDict):
|
||||
external_id: str
|
||||
label: str
|
||||
start_date: str
|
||||
end_date: str
|
||||
is_current: bool
|
||||
|
||||
|
||||
class PlayerStatsPayload(TypedDict):
|
||||
external_id: str
|
||||
player_external_id: str
|
||||
team_external_id: str | None
|
||||
competition_external_id: str | None
|
||||
season_external_id: str
|
||||
games_played: int
|
||||
games_started: int
|
||||
minutes_played: int
|
||||
points: float
|
||||
rebounds: float
|
||||
assists: float
|
||||
steals: float
|
||||
blocks: float
|
||||
turnovers: float
|
||||
fg_pct: float | None
|
||||
three_pct: float | None
|
||||
ft_pct: float | None
|
||||
usage_rate: float | None
|
||||
true_shooting_pct: float | None
|
||||
player_efficiency_rating: float | None
|
||||
|
||||
|
||||
class PlayerCareerPayload(TypedDict):
|
||||
external_id: str
|
||||
player_external_id: str
|
||||
team_external_id: str | None
|
||||
competition_external_id: str | None
|
||||
season_external_id: str | None
|
||||
role_code: str
|
||||
shirt_number: int | None
|
||||
start_date: str | None
|
||||
end_date: str | None
|
||||
notes: str
|
||||
|
||||
|
||||
class NormalizedSyncPayload(TypedDict):
|
||||
players: list[PlayerPayload]
|
||||
competitions: list[CompetitionPayload]
|
||||
teams: list[TeamPayload]
|
||||
seasons: list[SeasonPayload]
|
||||
player_stats: list[PlayerStatsPayload]
|
||||
player_careers: list[PlayerCareerPayload]
|
||||
cursor: str | None
|
||||
Reference in New Issue
Block a user