|
@@ -2,7 +2,7 @@ from __future__ import annotations
|
|
|
|
|
|
from collections import defaultdict
|
|
|
from datetime import datetime, timedelta
|
|
|
-from typing import Any, Iterable, List, MutableMapping, Sequence
|
|
|
+from typing import Any, Dict, Iterable, List, MutableMapping, Optional, Sequence, cast
|
|
|
|
|
|
import sentry_sdk
|
|
|
from django.db import connection
|
|
@@ -437,6 +437,17 @@ class ProjectWithOrganizationSerializer(ProjectSerializer):
|
|
|
return data
|
|
|
|
|
|
|
|
|
+class TeamResponseDict(TypedDict):
|
|
|
+ id: str
|
|
|
+ name: str
|
|
|
+ slug: str
|
|
|
+
|
|
|
+
|
|
|
+class ProjectWithTeamResponseDict(ProjectSerializerResponse):
|
|
|
+ team: TeamResponseDict
|
|
|
+ teams: List[TeamResponseDict]
|
|
|
+
|
|
|
+
|
|
|
class ProjectWithTeamSerializer(ProjectSerializer):
|
|
|
def get_attrs(
|
|
|
self, item_list: Sequence[Project], user: User, **kwargs: Any
|
|
@@ -464,8 +475,8 @@ class ProjectWithTeamSerializer(ProjectSerializer):
|
|
|
attrs[item]["teams"] = teams_by_project_id[item.id]
|
|
|
return attrs
|
|
|
|
|
|
- def serialize(self, obj, attrs, user):
|
|
|
- data = super().serialize(obj, attrs, user)
|
|
|
+ def serialize(self, obj, attrs, user) -> ProjectWithTeamResponseDict:
|
|
|
+ data = cast(ProjectWithTeamResponseDict, super().serialize(obj, attrs, user))
|
|
|
# TODO(jess): remove this when this is deprecated
|
|
|
try:
|
|
|
data["team"] = attrs["teams"][0]
|
|
@@ -475,6 +486,43 @@ class ProjectWithTeamSerializer(ProjectSerializer):
|
|
|
return data
|
|
|
|
|
|
|
|
|
+class EventProcessingDict(TypedDict):
|
|
|
+ symbolicationDegraded: bool
|
|
|
+
|
|
|
+
|
|
|
+class LatestReleaseDict(TypedDict):
|
|
|
+ version: str
|
|
|
+
|
|
|
+
|
|
|
+class _OrganizationProjectResponseDictOptional(TypedDict, total=False):
|
|
|
+ latestDeploys: Optional[Dict[str, Dict[str, str]]]
|
|
|
+ stats: Any
|
|
|
+ transactionStats: Any
|
|
|
+ sessionStats: Any
|
|
|
+
|
|
|
+
|
|
|
+class OrganizationProjectResponseDict(_OrganizationProjectResponseDictOptional):
|
|
|
+ team: Optional[TeamResponseDict]
|
|
|
+ teams: List[TeamResponseDict]
|
|
|
+ id: str
|
|
|
+ name: str
|
|
|
+ slug: str
|
|
|
+ isBookmarked: bool
|
|
|
+ isMember: bool
|
|
|
+ hasAccess: bool
|
|
|
+ dateCreated: str
|
|
|
+ eventProcessing: EventProcessingDict
|
|
|
+ features: List[str]
|
|
|
+ firstTransactionEvent: bool
|
|
|
+ hasSessions: bool
|
|
|
+ platform: Optional[str]
|
|
|
+ platforms: List[str]
|
|
|
+ hasUserReports: bool
|
|
|
+ firstEvent: Optional[str]
|
|
|
+ environments: List[str]
|
|
|
+ latestRelease: Optional[LatestReleaseDict]
|
|
|
+
|
|
|
+
|
|
|
class ProjectSummarySerializer(ProjectWithTeamSerializer):
|
|
|
def get_deploys_by_project(self, item_list):
|
|
|
cursor = connection.cursor()
|
|
@@ -572,8 +620,8 @@ class ProjectSummarySerializer(ProjectWithTeamSerializer):
|
|
|
|
|
|
return attrs
|
|
|
|
|
|
- def serialize(self, obj, attrs, user):
|
|
|
- context = {
|
|
|
+ def serialize(self, obj, attrs, user) -> OrganizationProjectResponseDict: # type: ignore
|
|
|
+ context: OrganizationProjectResponseDict = {
|
|
|
"team": attrs["teams"][0] if attrs["teams"] else None,
|
|
|
"teams": attrs["teams"],
|
|
|
"id": str(obj.id),
|