Skip to content

Commit 4dd3d8f

Browse files
committed
feat(lsg-api): add schema for notifications
1 parent 8fc2c31 commit 4dd3d8f

3 files changed

Lines changed: 293 additions & 0 deletions

File tree

packages/live-status-gateway-api/api/asyncapi.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ channels:
5151
- $ref: '#/components/messages/adLibs'
5252
- $ref: '#/components/messages/packages'
5353
- $ref: '#/components/messages/buckets'
54+
- $ref: '#/components/messages/notifications'
5455
components:
5556
messages:
5657
ping:
@@ -145,3 +146,9 @@ components:
145146
description: Buckets in Studio
146147
payload:
147148
$ref: './schemas/buckets.yaml#/$defs/buckets'
149+
notifications:
150+
name: notifications
151+
messageId: notificationsUpdate
152+
description: Active notifications in Sofie
153+
payload:
154+
$ref: './schemas/notifications.yaml#/$defs/notifications'
Lines changed: 177 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,177 @@
1+
title: Notifications
2+
description: Active notifications in Sofie
3+
4+
$defs:
5+
notifications:
6+
type: object
7+
title: NotificationsEvent
8+
properties:
9+
event:
10+
type: string
11+
const: notifications
12+
activeNotifications:
13+
description: Active notifications in Sofie
14+
type: array
15+
items:
16+
$ref: '#/$defs/DBNotificationObj'
17+
required: [event, activeNotifications]
18+
additionalProperties: false
19+
examples:
20+
- event: notifications
21+
activeNotifications:
22+
- $ref: '#/$defs/DBNotificationObj/examples/0'
23+
24+
DBNotificationObj:
25+
type: object
26+
title: DBNotificationObj
27+
description: This describes a notification that should be shown to a user. These can come from various sources, and are added and removed dynamically during system usage
28+
required:
29+
- _id
30+
- severity
31+
- message
32+
- relatedTo
33+
- created
34+
properties:
35+
_id:
36+
type: string
37+
description: Unique identifier for the notification
38+
severity:
39+
$ref: '#/$defs/severity'
40+
message:
41+
type: string
42+
description: The message of the notification
43+
relatedTo:
44+
$ref: '#/$defs/DBNotificationTarget'
45+
created:
46+
type: integer
47+
format: int64
48+
description: Unix timestamp of creation
49+
modified:
50+
type: integer
51+
format: int64
52+
description: Unix timestamp of last modification
53+
additionalProperties: false
54+
examples:
55+
- _id: 'notif123'
56+
severity: error
57+
message: 'disk.space.low'
58+
relatedTo:
59+
$ref: '#/$defs/DBNotificationTarget/examples/0'
60+
created: 1694784932
61+
modified: 1694784950
62+
63+
severity:
64+
type: string
65+
title: NotificationSeverity
66+
description: Severity level of the notification.
67+
enum:
68+
- warning
69+
- error
70+
- info
71+
examples:
72+
- info
73+
74+
DBNotificationTarget:
75+
title: DBNotificationTarget
76+
description: Description of what the notification is related to
77+
oneOf:
78+
- $ref: '#/$defs/DBNotificationTargetRundown'
79+
- $ref: '#/$defs/DBNotificationTargetRundownPlaylist'
80+
- $ref: '#/$defs/DBNotificationTargetPartInstance'
81+
- $ref: '#/$defs/DBNotificationTargetPieceInstance'
82+
examples:
83+
- $ref: '#/$defs/DBNotificationTargetRundown/examples/0'
84+
- $ref: '#/$defs/DBNotificationTargetRundownPlaylist/examples/0'
85+
- $ref: '#/$defs/DBNotificationTargetPartInstance/examples/0'
86+
- $ref: '#/$defs/DBNotificationTargetPieceInstance/examples/0'
87+
88+
NotificationTargetType:
89+
type: string
90+
title: NotificationTargetType
91+
description: Possible NotificationTarget types
92+
enum:
93+
- rundown
94+
- playlist
95+
- partInstance
96+
- pieceInstance
97+
98+
DBNotificationTargetRundown:
99+
type: object
100+
title: DBNotificationTargetRundown
101+
required: [type, studioId, rundownId]
102+
properties:
103+
type:
104+
$ref: '#/$defs/NotificationTargetType'
105+
enum: [rundown]
106+
studioId:
107+
type: string
108+
rundownId:
109+
type: string
110+
additionalProperties: false
111+
examples:
112+
- type: rundown
113+
studioId: studio01
114+
rundownId: rd123
115+
116+
DBNotificationTargetRundownPlaylist:
117+
type: object
118+
title: DBNotificationTargetRundownPlaylist
119+
required: [type, studioId, playlistId]
120+
properties:
121+
type:
122+
$ref: '#/$defs/NotificationTargetType'
123+
enum: [playlist]
124+
studioId:
125+
type: string
126+
playlistId:
127+
type: string
128+
additionalProperties: false
129+
examples:
130+
- type: playlist
131+
studioId: studio01
132+
playlistId: pl456
133+
134+
DBNotificationTargetPartInstance:
135+
type: object
136+
title: DBNotificationTargetPartInstance
137+
required: [type, studioId, rundownId, partInstanceId]
138+
properties:
139+
type:
140+
$ref: '#/$defs/NotificationTargetType'
141+
enum: [partInstance]
142+
studioId:
143+
type: string
144+
rundownId:
145+
type: string
146+
partInstanceId:
147+
type: string
148+
additionalProperties: false
149+
examples:
150+
- type: partInstance
151+
studioId: studio01
152+
rundownId: rd123
153+
partInstanceId: pi789
154+
155+
DBNotificationTargetPieceInstance:
156+
type: object
157+
title: DBNotificationTargetPieceInstance
158+
required: [type, studioId, rundownId, partInstanceId, pieceInstanceId]
159+
properties:
160+
type:
161+
$ref: '#/$defs/NotificationTargetType'
162+
enum: [pieceInstance]
163+
studioId:
164+
type: string
165+
rundownId:
166+
type: string
167+
partInstanceId:
168+
type: string
169+
pieceInstanceId:
170+
type: string
171+
additionalProperties: false
172+
examples:
173+
- type: pieceInstance
174+
studioId: studio01
175+
rundownId: rd123
176+
partInstanceId: pi789
177+
pieceInstanceId: pc1011

packages/live-status-gateway-api/src/generated/schema.ts

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ type Slash =
1818
| AdLibsEvent
1919
| PackagesEvent
2020
| BucketsEvent
21+
| NotificationsEvent
2122

2223
interface PongEvent {
2324
event: 'pong'
@@ -822,6 +823,106 @@ interface BucketAdLibStatus {
822823
additionalProperties?: Record<string, any>
823824
}
824825

826+
interface NotificationsEvent {
827+
event: 'notifications'
828+
/**
829+
* Active notifications in Sofie
830+
*/
831+
activeNotifications: DbNotificationObj[]
832+
}
833+
834+
/**
835+
* This describes a notification that should be shown to a user. These can come from various sources, and are added and removed dynamically during system usage
836+
*/
837+
interface DbNotificationObj {
838+
/**
839+
* Unique identifier for the notification
840+
*/
841+
_id: string
842+
/**
843+
* Severity level of the notification.
844+
*/
845+
severity: NotificationSeverity
846+
/**
847+
* The message of the notification
848+
*/
849+
message: string
850+
/**
851+
* Description of what the notification is related to
852+
*/
853+
relatedTo:
854+
| DbNotificationTargetRundown
855+
| DbNotificationTargetRundownPlaylist
856+
| DbNotificationTargetPartInstance
857+
| DbNotificationTargetPieceInstance
858+
/**
859+
* Unix timestamp of creation
860+
*/
861+
created: number
862+
/**
863+
* Unix timestamp of last modification
864+
*/
865+
modified?: number
866+
}
867+
868+
/**
869+
* Severity level of the notification.
870+
*/
871+
enum NotificationSeverity {
872+
WARNING = 'warning',
873+
ERROR = 'error',
874+
INFO = 'info',
875+
}
876+
877+
interface DbNotificationTargetRundown {
878+
/**
879+
* Possible NotificationTarget types
880+
*/
881+
type: NotificationTargetType
882+
studioId: string
883+
rundownId: string
884+
}
885+
886+
/**
887+
* Possible NotificationTarget types
888+
*/
889+
enum NotificationTargetType {
890+
RUNDOWN = 'rundown',
891+
PLAYLIST = 'playlist',
892+
PART_INSTANCE = 'partInstance',
893+
PIECE_INSTANCE = 'pieceInstance',
894+
}
895+
896+
interface DbNotificationTargetRundownPlaylist {
897+
/**
898+
* Possible NotificationTarget types
899+
*/
900+
type: NotificationTargetType
901+
studioId: string
902+
playlistId: string
903+
}
904+
905+
interface DbNotificationTargetPartInstance {
906+
/**
907+
* Possible NotificationTarget types
908+
*/
909+
type: NotificationTargetType
910+
studioId: string
911+
rundownId: string
912+
partInstanceId: string
913+
}
914+
915+
interface DbNotificationTargetPieceInstance {
916+
/**
917+
* Possible NotificationTarget types
918+
*/
919+
type: NotificationTargetType
920+
studioId: string
921+
rundownId: string
922+
partInstanceId: string
923+
pieceInstanceId: string
924+
}
925+
825926
export {
826927
Slash,
827928
PongEvent,
@@ -866,4 +967,12 @@ export {
866967
BucketsEvent,
867968
BucketStatus,
868969
BucketAdLibStatus,
970+
NotificationsEvent,
971+
DbNotificationObj,
972+
NotificationSeverity,
973+
DbNotificationTargetRundown,
974+
NotificationTargetType,
975+
DbNotificationTargetRundownPlaylist,
976+
DbNotificationTargetPartInstance,
977+
DbNotificationTargetPieceInstance,
869978
}

0 commit comments

Comments
 (0)