-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver_packets.py
More file actions
80 lines (52 loc) · 1.95 KB
/
Copy pathserver_packets.py
File metadata and controls
80 lines (52 loc) · 1.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
from typing import TypedDict, List, Literal, NotRequired
"""
Types used for communication between the client and server
This is based on the frontend's `networking/packetTypes.ts` interfaces.
"""
# Incoming Request Types
class RoutingStartRequest(TypedDict):
endpoint: Literal["routingStart"]
project: str # Project serialized as JSON, TODO: Define a proper Project type, subset of values relevant to the backend
class RoutingProgressRequest(TypedDict):
endpoint: Literal["routingProgress"]
jobId: str
class PCBArtifactRequest(TypedDict):
endpoint: Literal["pcbArtifact"]
jobId: str
uploadToFabHouse: NotRequired[bool]
# Outgoing Response Types
class RoutingStartResponseResult(TypedDict):
jobId: str
class RoutingStartResponseError(TypedDict):
message: str
# response
class RoutingStartResponse(TypedDict):
endpoint: Literal["routingStart"]
error: NotRequired[RoutingStartResponseError]
result: NotRequired[RoutingStartResponseResult]
class RoutingProgressResponseError(TypedDict):
message: str
failedModuleIds: List[str]
succeededModuleIds: NotRequired[List[str]]
class RoutingProgressResponseResult(TypedDict):
progress: float
routingImage: NotRequired[str] # Base64 encoded image
busWidthLeft: NotRequired[float]
busWidthRight: NotRequired[float]
completed: NotRequired[bool]
# response
class RoutingProgressResponse(TypedDict):
endpoint: Literal["routingProgress"]
error: NotRequired[RoutingProgressResponseError]
result: NotRequired[RoutingProgressResponseResult]
issues: NotRequired[List[str]]
class PCBArtifactResponseResult(TypedDict):
zipFile: str # Base64 encoded zip file
fabricationUrl: NotRequired[str]
class PCBArtifactResponseError(TypedDict):
message: str
# response
class PCBArtifactResponse(TypedDict):
endpoint: Literal["pcbArtifact"]
error: NotRequired[PCBArtifactResponseError]
result: NotRequired[PCBArtifactResponseResult]