@@ -16,154 +16,94 @@ class EventBase(BaseModel, ABC):
16
16
event : str
17
17
"""Name of the event used to identify what occurred."""
18
18
19
- @classmethod
20
- def is_action_specific (cls ) -> bool :
21
- """Check if the event is specific to an action instance (i.e. the event has an "action" field)."""
22
- return "action" in cls .model_fields
23
19
24
- @classmethod
25
- def is_device_specific (cls ) -> bool :
26
- """Check if the event is specific to a device instance (i.e. the event has a "device" field)."""
27
- return "device" in cls .model_fields
20
+ class ContextualEventMixin :
21
+ action : str
22
+ """Unique identifier of the action"""
23
+ context : str
24
+ """Identifies the instance of an action that caused the event, i.e. the specific key or dial."""
28
25
29
- @classmethod
30
- def is_action_instance_specific (cls ) -> bool :
31
- """Check if the event is specific to an action instance (i.e. the event has a "context" field)."""
32
- return "context" in cls .model_fields
26
+ class DeviceSpecificEventMixin :
27
+ device : str
28
+ """Unique identifier of the Stream Deck device that this event is associated with."""
33
29
34
30
35
- class ApplicationDidLaunchEvent (EventBase ):
31
+ class ApplicationDidLaunch (EventBase ):
36
32
event : Literal ["applicationDidLaunch" ]
37
33
payload : dict [Literal ["application" ], str ]
38
34
"""Payload containing the name of the application that triggered the event."""
39
35
40
36
41
- class ApplicationDidTerminateEvent (EventBase ):
37
+ class ApplicationDidTerminate (EventBase ):
42
38
event : Literal ["applicationDidTerminate" ]
43
39
payload : dict [Literal ["application" ], str ]
44
40
"""Payload containing the name of the application that triggered the event."""
45
41
46
42
47
- class DeviceDidConnectEvent (EventBase ):
43
+ class DeviceDidConnect (EventBase , DeviceSpecificEventMixin ):
48
44
event : Literal ["deviceDidConnect" ]
49
- device : str
50
- """Unique identifier of the Stream Deck device that this event is associated with."""
51
45
deviceInfo : dict [str , Any ]
52
46
"""Information about the newly connected device."""
53
47
54
48
55
- class DeviceDidDisconnectEvent (EventBase ):
49
+ class DeviceDidDisconnect (EventBase , DeviceSpecificEventMixin ):
56
50
event : Literal ["deviceDidDisconnect" ]
57
- device : str
58
- """Unique identifier of the Stream Deck device that this event is associated with."""
59
51
60
52
61
- class DialDownEvent (EventBase ):
53
+ class DialDown (EventBase , ContextualEventMixin , DeviceSpecificEventMixin ):
62
54
event : Literal ["dialDown" ]
63
- context : str
64
- """Identifies the instance of an action that caused the event, i.e. the specific key or dial."""
65
- device : str
66
- """Unique identifier of the Stream Deck device that this event is associated with."""
67
- action : str
68
- """Unique identifier of the action"""
69
55
payload : dict [str , Any ]
70
56
71
57
72
- class DialRotateEvent (EventBase ):
58
+ class DialRotate (EventBase , ContextualEventMixin , DeviceSpecificEventMixin ):
73
59
event : Literal ["dialRotate" ]
74
- context : str
75
- """Identifies the instance of an action that caused the event, i.e. the specific key or dial."""
76
- device : str
77
- """Unique identifier of the Stream Deck device that this event is associated with."""
78
- action : str
79
- """Unique identifier of the action"""
80
60
payload : dict [str , Any ]
81
61
82
62
83
- class DialUpEvent (EventBase ):
63
+ class DialUp (EventBase , ContextualEventMixin , DeviceSpecificEventMixin ):
84
64
event : Literal ["dialUp" ]
85
- context : str
86
- """Identifies the instance of an action that caused the event, i.e. the specific key or dial."""
87
- device : str
88
- """Unique identifier of the Stream Deck device that this event is associated with."""
89
- action : str
90
- """Unique identifier of the action"""
91
65
payload : dict [str , Any ]
92
66
93
67
94
- class DidReceiveDeepLinkEvent (EventBase ):
68
+ class DidReceiveDeepLink (EventBase ):
95
69
event : Literal ["didReceiveDeepLink" ]
96
70
payload : dict [Literal ["url" ], str ]
97
71
98
72
99
- class DidReceiveGlobalSettingsEvent (EventBase ):
73
+ class DidReceiveGlobalSettings (EventBase ):
100
74
event : Literal ["didReceiveGlobalSettings" ]
101
75
payload : dict [Literal ["settings" ], dict [str , Any ]]
102
76
103
77
104
- class DidReceivePropertyInspectorMessageEvent (EventBase ):
78
+ class DidReceivePropertyInspectorMessage (EventBase , ContextualEventMixin ):
105
79
event : Literal ["sendToPlugin" ]
106
- context : str
107
- """Identifies the instance of an action that caused the event, i.e. the specific key or dial."""
108
- action : str
109
- """Unique identifier of the action"""
110
80
payload : dict [str , Any ]
111
81
112
82
113
- class DidReceiveSettingsEvent (EventBase ):
83
+ class DidReceiveSettings (EventBase , ContextualEventMixin , DeviceSpecificEventMixin ):
114
84
event : Literal ["didReceiveSettings" ]
115
- context : str
116
- """UUID of the instance of an action that caused the event."""
117
- device : str
118
- """UUID of the Stream Deck device that this event is associated with."""
119
- action : str
120
- """UUID of the action."""
121
85
payload : dict [str , Any ]
122
86
123
87
124
- class KeyDownEvent (EventBase ):
88
+ class KeyDown (EventBase , ContextualEventMixin , DeviceSpecificEventMixin ):
125
89
event : Literal ["keyDown" ]
126
- context : str
127
- """Identifies the instance of an action that caused the event, i.e. the specific key or dial."""
128
- device : str
129
- """Unique identifier of the Stream Deck device that this event is associated with."""
130
- action : str
131
- """Unique identifier of the action"""
132
90
payload : dict [str , Any ]
133
91
134
92
135
- class KeyUpEvent (EventBase ):
93
+ class KeyUp (EventBase , ContextualEventMixin , DeviceSpecificEventMixin ):
136
94
event : Literal ["keyUp" ]
137
- context : str
138
- """Identifies the instance of an action that caused the event, i.e. the specific key or dial."""
139
- device : str
140
- """Unique identifier of the Stream Deck device that this event is associated with."""
141
- action : str
142
- """Unique identifier of the action"""
143
95
payload : dict [str , Any ]
144
96
145
97
146
- class PropertyInspectorDidAppearEvent (EventBase ):
98
+ class PropertyInspectorDidAppear (EventBase , ContextualEventMixin , DeviceSpecificEventMixin ):
147
99
event : Literal ["propertyInspectorDidAppear" ]
148
- context : str
149
- """Identifies the instance of an action that caused the event, i.e. the specific key or dial."""
150
- device : str
151
- """Unique identifier of the Stream Deck device that this event is associated with."""
152
- action : str
153
- """Unique identifier of the action"""
154
100
155
101
156
- class PropertyInspectorDidDisappearEvent (EventBase ):
102
+ class PropertyInspectorDidDisappear (EventBase , ContextualEventMixin , DeviceSpecificEventMixin ):
157
103
event : Literal ["propertyInspectorDidDisappear" ]
158
- context : str
159
- """Identifies the instance of an action that caused the event, i.e. the specific key or dial."""
160
- device : str
161
- """Unique identifier of the Stream Deck device that this event is associated with."""
162
- action : str
163
- """Unique identifier of the action"""
164
104
165
105
166
- class SystemDidWakeUpEvent (EventBase ):
106
+ class SystemDidWakeUp (EventBase ):
167
107
event : Literal ["systemDidWakeUp" ]
168
108
169
109
@@ -186,46 +126,25 @@ class TitleParametersDidChangePayload(TypedDict):
186
126
titleParameters : TitleParametersDict
187
127
188
128
189
- class TitleParametersDidChangeEvent (EventBase ):
129
+ class TitleParametersDidChange (EventBase , DeviceSpecificEventMixin ):
190
130
event : Literal ["titleParametersDidChange" ]
191
131
context : str
192
132
"""Identifies the instance of an action that caused the event, i.e. the specific key or dial."""
193
- device : str
194
- """Unique identifier of the Stream Deck device that this event is associated with."""
195
- # payload: dict[str, Any]
196
133
payload : TitleParametersDidChangePayload
197
134
198
135
199
- class TouchTap (EventBase ):
136
+ class TouchTap (EventBase , ContextualEventMixin , DeviceSpecificEventMixin ):
200
137
event : Literal ["touchTap" ]
201
- context : str
202
- """Identifies the instance of an action that caused the event, i.e. the specific key or dial."""
203
- device : str
204
- """Unique identifier of the Stream Deck device that this event is associated with."""
205
- action : str
206
- """Unique identifier of the action"""
207
138
payload : dict [str , Any ]
208
139
209
140
210
- class WillAppearEvent (EventBase ):
141
+ class WillAppear (EventBase , ContextualEventMixin , DeviceSpecificEventMixin ):
211
142
event : Literal ["willAppear" ]
212
- context : str
213
- """Identifies the instance of an action that caused the event, i.e. the specific key or dial."""
214
- device : str
215
- """Unique identifier of the Stream Deck device that this event is associated with."""
216
- action : str
217
- """Unique identifier of the action"""
218
143
payload : dict [str , Any ]
219
144
220
145
221
- class WillDisappearEvent (EventBase ):
146
+ class WillDisappear (EventBase , ContextualEventMixin , DeviceSpecificEventMixin ):
222
147
event : Literal ["willDisappear" ]
223
- context : str
224
- """Identifies the instance of an action that caused the event, i.e. the specific key or dial."""
225
- device : str
226
- """Unique identifier of the Stream Deck device that this event is associated with."""
227
- action : str
228
- """Unique identifier of the action"""
229
148
payload : dict [str , Any ]
230
149
231
150
@@ -234,26 +153,26 @@ class WillDisappearEvent(EventBase):
234
153
event_adapter : TypeAdapter [EventBase ] = TypeAdapter (
235
154
Annotated [
236
155
Union [ # noqa: UP007
237
- ApplicationDidLaunchEvent ,
238
- ApplicationDidTerminateEvent ,
239
- DeviceDidConnectEvent ,
240
- DeviceDidDisconnectEvent ,
241
- DialDownEvent ,
242
- DialRotateEvent ,
243
- DialUpEvent ,
244
- DidReceiveDeepLinkEvent ,
245
- KeyUpEvent ,
246
- KeyDownEvent ,
247
- DidReceivePropertyInspectorMessageEvent ,
248
- PropertyInspectorDidAppearEvent ,
249
- PropertyInspectorDidDisappearEvent ,
250
- DidReceiveGlobalSettingsEvent ,
251
- DidReceiveSettingsEvent ,
252
- SystemDidWakeUpEvent ,
253
- TitleParametersDidChangeEvent ,
156
+ ApplicationDidLaunch ,
157
+ ApplicationDidTerminate ,
158
+ DeviceDidConnect ,
159
+ DeviceDidDisconnect ,
160
+ DialDown ,
161
+ DialRotate ,
162
+ DialUp ,
163
+ DidReceiveDeepLink ,
164
+ KeyUp ,
165
+ KeyDown ,
166
+ DidReceivePropertyInspectorMessage ,
167
+ PropertyInspectorDidAppear ,
168
+ PropertyInspectorDidDisappear ,
169
+ DidReceiveGlobalSettings ,
170
+ DidReceiveSettings ,
171
+ SystemDidWakeUp ,
172
+ TitleParametersDidChange ,
254
173
TouchTap ,
255
- WillAppearEvent ,
256
- WillDisappearEvent ,
174
+ WillAppear ,
175
+ WillDisappear ,
257
176
],
258
177
Field (discriminator = "event" )
259
178
]
0 commit comments