|
| 1 | +import type { NoteSeverity } from '@sofie-automation/blueprints-integration' |
| 2 | +import type { NotificationId, PartInstanceId, PieceInstanceId, RundownId, RundownPlaylistId, StudioId } from './Ids' |
| 3 | +import type { ITranslatableMessage } from '../TranslatableMessage' |
| 4 | + |
| 5 | +/** |
| 6 | + * This describes a notification that should be shown to a user |
| 7 | + * These can come from various sources, and are added and removed dynamically during system usage |
| 8 | + */ |
| 9 | +export interface DBNotificationObj { |
| 10 | + _id: NotificationId |
| 11 | + |
| 12 | + /** |
| 13 | + * Used to group a certain group of notifications |
| 14 | + * Each source of these notifications should use its own value, so that it can find and cleanup after itself when appropriate |
| 15 | + * Typically, a method will clear all previous notifications for a category when it is called, and then possibly add new ones |
| 16 | + * This is a technical value, not intended to be conusmed outside of the generation/update logic |
| 17 | + */ |
| 18 | + category: string |
| 19 | + |
| 20 | + /** |
| 21 | + * Unique id for this notification within the category |
| 22 | + */ |
| 23 | + localId: string |
| 24 | + |
| 25 | + severity: NoteSeverity |
| 26 | + message: ITranslatableMessage |
| 27 | + // type: 'event' | 'persistent' |
| 28 | + |
| 29 | + /** Description of what the notification is related to */ |
| 30 | + relatedTo: DBNotificationTarget |
| 31 | + |
| 32 | + created: number // unix timestamp |
| 33 | + modified: number // unix timestamp |
| 34 | + |
| 35 | + // /** |
| 36 | + // * When set, the notification will be automatically dismissed after this time |
| 37 | + // * For events, this is typically set to less than a minute |
| 38 | + // * For persistent notifications, this is never set |
| 39 | + // */ |
| 40 | + // autoTimeout?: number // unix timestamp |
| 41 | +} |
| 42 | + |
| 43 | +export type DBNotificationTarget = |
| 44 | + // | DBNotificationTargetEverywhere |
| 45 | + // | DBNotificationTargetStudio |
| 46 | + | DBNotificationTargetRundown |
| 47 | + // | DBNotificationTargetSegment |
| 48 | + // | DBNotificationTargetPart |
| 49 | + // | DBNotificationTargetPiece |
| 50 | + | DBNotificationTargetRundownPlaylist |
| 51 | + | DBNotificationTargetPartInstance |
| 52 | + | DBNotificationTargetPieceInstance |
| 53 | + |
| 54 | +export enum DBNotificationTargetType { |
| 55 | + // EVERYWHERE = 'everywhere', |
| 56 | + // STUDIO = 'studio', |
| 57 | + RUNDOWN = 'rundown', |
| 58 | + // SEGMENT = 'segment', |
| 59 | + // PART = 'part', |
| 60 | + // PIECE = 'piece', |
| 61 | + PLAYLIST = 'playlist', |
| 62 | + PARTINSTANCE = 'partInstance', |
| 63 | + PIECEINSTANCE = 'pieceInstance', |
| 64 | +} |
| 65 | + |
| 66 | +// export interface DBNotificationTargetEverywhere { |
| 67 | +// type: DBNotificationTargetType.EVERYWHERE |
| 68 | +// } |
| 69 | + |
| 70 | +// export interface DBNotificationTargetStudio { |
| 71 | +// type: DBNotificationTargetType.STUDIO |
| 72 | +// studioId: StudioId |
| 73 | +// } |
| 74 | + |
| 75 | +export interface DBNotificationTargetRundown { |
| 76 | + type: DBNotificationTargetType.RUNDOWN |
| 77 | + studioId: StudioId |
| 78 | + rundownId: RundownId |
| 79 | +} |
| 80 | + |
| 81 | +// export interface DBNotificationTargetSegment { |
| 82 | +// type: DBNotificationTargetType.SEGMENT |
| 83 | +// studioId: StudioId |
| 84 | +// rundownId: RundownId |
| 85 | +// segmentId: SegmentId |
| 86 | +// } |
| 87 | + |
| 88 | +// export interface DBNotificationTargetPart { |
| 89 | +// type: DBNotificationTargetType.PART |
| 90 | +// studioId: StudioId |
| 91 | +// rundownId: RundownId |
| 92 | +// // segmentId: SegmentId |
| 93 | +// partId: PartId |
| 94 | +// } |
| 95 | + |
| 96 | +// export interface DBNotificationTargetPiece { |
| 97 | +// type: DBNotificationTargetType.PIECE |
| 98 | +// studioId: StudioId |
| 99 | +// rundownId: RundownId |
| 100 | +// // segmentId: SegmentId |
| 101 | +// partId: PartId |
| 102 | +// pieceId: PieceId |
| 103 | +// } |
| 104 | + |
| 105 | +export interface DBNotificationTargetRundownPlaylist { |
| 106 | + type: DBNotificationTargetType.PLAYLIST |
| 107 | + studioId: StudioId |
| 108 | + playlistId: RundownPlaylistId |
| 109 | +} |
| 110 | + |
| 111 | +export interface DBNotificationTargetPartInstance { |
| 112 | + type: DBNotificationTargetType.PARTINSTANCE |
| 113 | + studioId: StudioId |
| 114 | + rundownId: RundownId |
| 115 | + partInstanceId: PartInstanceId |
| 116 | +} |
| 117 | + |
| 118 | +export interface DBNotificationTargetPieceInstance { |
| 119 | + type: DBNotificationTargetType.PIECEINSTANCE |
| 120 | + studioId: StudioId |
| 121 | + rundownId: RundownId |
| 122 | + partInstanceId: PartInstanceId |
| 123 | + pieceInstanceId: PieceInstanceId |
| 124 | +} |
0 commit comments