@@ -16,154 +16,94 @@ class EventBase(BaseModel, ABC):
1616 event : str
1717 """Name of the event used to identify what occurred."""
1818
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
2319
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."""
2825
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."""
3329
3430
35- class ApplicationDidLaunchEvent (EventBase ):
31+ class ApplicationDidLaunch (EventBase ):
3632 event : Literal ["applicationDidLaunch" ]
3733 payload : dict [Literal ["application" ], str ]
3834 """Payload containing the name of the application that triggered the event."""
3935
4036
41- class ApplicationDidTerminateEvent (EventBase ):
37+ class ApplicationDidTerminate (EventBase ):
4238 event : Literal ["applicationDidTerminate" ]
4339 payload : dict [Literal ["application" ], str ]
4440 """Payload containing the name of the application that triggered the event."""
4541
4642
47- class DeviceDidConnectEvent (EventBase ):
43+ class DeviceDidConnect (EventBase , DeviceSpecificEventMixin ):
4844 event : Literal ["deviceDidConnect" ]
49- device : str
50- """Unique identifier of the Stream Deck device that this event is associated with."""
5145 deviceInfo : dict [str , Any ]
5246 """Information about the newly connected device."""
5347
5448
55- class DeviceDidDisconnectEvent (EventBase ):
49+ class DeviceDidDisconnect (EventBase , DeviceSpecificEventMixin ):
5650 event : Literal ["deviceDidDisconnect" ]
57- device : str
58- """Unique identifier of the Stream Deck device that this event is associated with."""
5951
6052
61- class DialDownEvent (EventBase ):
53+ class DialDown (EventBase , ContextualEventMixin , DeviceSpecificEventMixin ):
6254 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"""
6955 payload : dict [str , Any ]
7056
7157
72- class DialRotateEvent (EventBase ):
58+ class DialRotate (EventBase , ContextualEventMixin , DeviceSpecificEventMixin ):
7359 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"""
8060 payload : dict [str , Any ]
8161
8262
83- class DialUpEvent (EventBase ):
63+ class DialUp (EventBase , ContextualEventMixin , DeviceSpecificEventMixin ):
8464 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"""
9165 payload : dict [str , Any ]
9266
9367
94- class DidReceiveDeepLinkEvent (EventBase ):
68+ class DidReceiveDeepLink (EventBase ):
9569 event : Literal ["didReceiveDeepLink" ]
9670 payload : dict [Literal ["url" ], str ]
9771
9872
99- class DidReceiveGlobalSettingsEvent (EventBase ):
73+ class DidReceiveGlobalSettings (EventBase ):
10074 event : Literal ["didReceiveGlobalSettings" ]
10175 payload : dict [Literal ["settings" ], dict [str , Any ]]
10276
10377
104- class DidReceivePropertyInspectorMessageEvent (EventBase ):
78+ class DidReceivePropertyInspectorMessage (EventBase , ContextualEventMixin ):
10579 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"""
11080 payload : dict [str , Any ]
11181
11282
113- class DidReceiveSettingsEvent (EventBase ):
83+ class DidReceiveSettings (EventBase , ContextualEventMixin , DeviceSpecificEventMixin ):
11484 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."""
12185 payload : dict [str , Any ]
12286
12387
124- class KeyDownEvent (EventBase ):
88+ class KeyDown (EventBase , ContextualEventMixin , DeviceSpecificEventMixin ):
12589 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"""
13290 payload : dict [str , Any ]
13391
13492
135- class KeyUpEvent (EventBase ):
93+ class KeyUp (EventBase , ContextualEventMixin , DeviceSpecificEventMixin ):
13694 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"""
14395 payload : dict [str , Any ]
14496
14597
146- class PropertyInspectorDidAppearEvent (EventBase ):
98+ class PropertyInspectorDidAppear (EventBase , ContextualEventMixin , DeviceSpecificEventMixin ):
14799 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"""
154100
155101
156- class PropertyInspectorDidDisappearEvent (EventBase ):
102+ class PropertyInspectorDidDisappear (EventBase , ContextualEventMixin , DeviceSpecificEventMixin ):
157103 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"""
164104
165105
166- class SystemDidWakeUpEvent (EventBase ):
106+ class SystemDidWakeUp (EventBase ):
167107 event : Literal ["systemDidWakeUp" ]
168108
169109
@@ -186,46 +126,25 @@ class TitleParametersDidChangePayload(TypedDict):
186126 titleParameters : TitleParametersDict
187127
188128
189- class TitleParametersDidChangeEvent (EventBase ):
129+ class TitleParametersDidChange (EventBase , DeviceSpecificEventMixin ):
190130 event : Literal ["titleParametersDidChange" ]
191131 context : str
192132 """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]
196133 payload : TitleParametersDidChangePayload
197134
198135
199- class TouchTap (EventBase ):
136+ class TouchTap (EventBase , ContextualEventMixin , DeviceSpecificEventMixin ):
200137 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"""
207138 payload : dict [str , Any ]
208139
209140
210- class WillAppearEvent (EventBase ):
141+ class WillAppear (EventBase , ContextualEventMixin , DeviceSpecificEventMixin ):
211142 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"""
218143 payload : dict [str , Any ]
219144
220145
221- class WillDisappearEvent (EventBase ):
146+ class WillDisappear (EventBase , ContextualEventMixin , DeviceSpecificEventMixin ):
222147 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"""
229148 payload : dict [str , Any ]
230149
231150
@@ -234,26 +153,26 @@ class WillDisappearEvent(EventBase):
234153event_adapter : TypeAdapter [EventBase ] = TypeAdapter (
235154 Annotated [
236155 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 ,
254173 TouchTap ,
255- WillAppearEvent ,
256- WillDisappearEvent ,
174+ WillAppear ,
175+ WillDisappear ,
257176 ],
258177 Field (discriminator = "event" )
259178 ]
0 commit comments