Skip to content

Commit 41770fe

Browse files
committed
feat(lsg-api): add schema for notifications
1 parent 69c0465 commit 41770fe

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
@@ -50,6 +50,7 @@ channels:
5050
- $ref: '#/components/messages/adLibs'
5151
- $ref: '#/components/messages/packages'
5252
- $ref: '#/components/messages/buckets'
53+
- $ref: '#/components/messages/notifications'
5354
components:
5455
messages:
5556
ping:
@@ -137,3 +138,9 @@ components:
137138
description: Buckets in Studio
138139
payload:
139140
$ref: './schemas/buckets.yaml#/$defs/buckets'
141+
notifications:
142+
name: notifications
143+
messageId: notificationsUpdate
144+
description: Active notifications in Sofie
145+
payload:
146+
$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
@@ -17,6 +17,7 @@ type Slash =
1717
| AdLibsEvent
1818
| PackagesEvent
1919
| BucketsEvent
20+
| NotificationsEvent
2021

2122
interface PongEvent {
2223
event: 'pong'
@@ -726,6 +727,106 @@ interface BucketAdLibStatus {
726727
additionalProperties?: Record<string, any>
727728
}
728729

730+
interface NotificationsEvent {
731+
event: 'notifications'
732+
/**
733+
* Active notifications in Sofie
734+
*/
735+
activeNotifications: DbNotificationObj[]
736+
}
737+
738+
/**
739+
* 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
740+
*/
741+
interface DbNotificationObj {
742+
/**
743+
* Unique identifier for the notification
744+
*/
745+
_id: string
746+
/**
747+
* Severity level of the notification.
748+
*/
749+
severity: NotificationSeverity
750+
/**
751+
* The message of the notification
752+
*/
753+
message: string
754+
/**
755+
* Description of what the notification is related to
756+
*/
757+
relatedTo:
758+
| DbNotificationTargetRundown
759+
| DbNotificationTargetRundownPlaylist
760+
| DbNotificationTargetPartInstance
761+
| DbNotificationTargetPieceInstance
762+
/**
763+
* Unix timestamp of creation
764+
*/
765+
created: number
766+
/**
767+
* Unix timestamp of last modification
768+
*/
769+
modified?: number
770+
}
771+
772+
/**
773+
* Severity level of the notification.
774+
*/
775+
enum NotificationSeverity {
776+
WARNING = 'warning',
777+
ERROR = 'error',
778+
INFO = 'info',
779+
}
780+
781+
interface DbNotificationTargetRundown {
782+
/**
783+
* Possible NotificationTarget types
784+
*/
785+
type: NotificationTargetType
786+
studioId: string
787+
rundownId: string
788+
}
789+
790+
/**
791+
* Possible NotificationTarget types
792+
*/
793+
enum NotificationTargetType {
794+
RUNDOWN = 'rundown',
795+
PLAYLIST = 'playlist',
796+
PART_INSTANCE = 'partInstance',
797+
PIECE_INSTANCE = 'pieceInstance',
798+
}
799+
800+
interface DbNotificationTargetRundownPlaylist {
801+
/**
802+
* Possible NotificationTarget types
803+
*/
804+
type: NotificationTargetType
805+
studioId: string
806+
playlistId: string
807+
}
808+
809+
interface DbNotificationTargetPartInstance {
810+
/**
811+
* Possible NotificationTarget types
812+
*/
813+
type: NotificationTargetType
814+
studioId: string
815+
rundownId: string
816+
partInstanceId: string
817+
}
818+
819+
interface DbNotificationTargetPieceInstance {
820+
/**
821+
* Possible NotificationTarget types
822+
*/
823+
type: NotificationTargetType
824+
studioId: string
825+
rundownId: string
826+
partInstanceId: string
827+
pieceInstanceId: string
828+
}
829+
729830
export {
730831
Slash,
731832
PongEvent,
@@ -767,4 +868,12 @@ export {
767868
BucketsEvent,
768869
BucketStatus,
769870
BucketAdLibStatus,
871+
NotificationsEvent,
872+
DbNotificationObj,
873+
NotificationSeverity,
874+
DbNotificationTargetRundown,
875+
NotificationTargetType,
876+
DbNotificationTargetRundownPlaylist,
877+
DbNotificationTargetPartInstance,
878+
DbNotificationTargetPieceInstance,
770879
}

0 commit comments

Comments
 (0)