export interface NotificationLookupArguments { deviceId: string; shuttleId: string; stopId: string; } export interface ScheduledNotification extends NotificationLookupArguments { /** * Value which specifies the ETA of the shuttle for when * the notification should fire. * For example, a secondsThreshold of 180 would mean that the notification * fires when the ETA drops below 3 minutes. */ secondsThreshold: number; } export type Listener = ((event: NotificationEvent) => any); export interface NotificationEvent { notification: ScheduledNotification, event: 'delete' | 'addOrUpdate' } export interface NotificationRepository { getAllNotificationsForShuttleAndStopId(shuttleId: string, stopId: string): Promise; getSecondsThresholdForNotificationIfExists(lookupArguments: NotificationLookupArguments): Promise; isNotificationScheduled(lookupArguments: NotificationLookupArguments): Promise; addOrUpdateNotification(notification: ScheduledNotification): Promise; deleteNotificationIfExists(lookupArguments: NotificationLookupArguments): Promise; subscribeToNotificationChanges(listener: Listener): void; unsubscribeFromNotificationChanges(listener: Listener): void; }