mirror of
https://github.com/brendan-ch/project-inter-server.git
synced 2026-04-19 08:50:29 +00:00
Add SHUTTLE_ARRIVED_AT_STOP event and remove ETA-related methods for ShuttleGetterRepository
This commit is contained in:
@@ -4,6 +4,7 @@ import type EventEmitter from "node:events";
|
|||||||
export const ShuttleRepositoryEvent = {
|
export const ShuttleRepositoryEvent = {
|
||||||
SHUTTLE_UPDATED: "shuttleUpdated",
|
SHUTTLE_UPDATED: "shuttleUpdated",
|
||||||
SHUTTLE_REMOVED: "shuttleRemoved",
|
SHUTTLE_REMOVED: "shuttleRemoved",
|
||||||
|
SHUTTLE_ARRIVED_AT_STOP: "shuttleArrivedAtStop",
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
export type ShuttleRepositoryEventName = typeof ShuttleRepositoryEvent[keyof typeof ShuttleRepositoryEvent];
|
export type ShuttleRepositoryEventName = typeof ShuttleRepositoryEvent[keyof typeof ShuttleRepositoryEvent];
|
||||||
@@ -14,6 +15,7 @@ export type EtaDataClearedEventPayload = IEta[];
|
|||||||
export interface ShuttleRepositoryEventPayloads {
|
export interface ShuttleRepositoryEventPayloads {
|
||||||
[ShuttleRepositoryEvent.SHUTTLE_UPDATED]: IShuttle,
|
[ShuttleRepositoryEvent.SHUTTLE_UPDATED]: IShuttle,
|
||||||
[ShuttleRepositoryEvent.SHUTTLE_REMOVED]: IShuttle,
|
[ShuttleRepositoryEvent.SHUTTLE_REMOVED]: IShuttle,
|
||||||
|
[ShuttleRepositoryEvent.SHUTTLE_ARRIVED_AT_STOP]: ShuttleStopArrival,
|
||||||
}
|
}
|
||||||
|
|
||||||
export type ShuttleRepositoryEventListener<T extends ShuttleRepositoryEventName> = (
|
export type ShuttleRepositoryEventListener<T extends ShuttleRepositoryEventName> = (
|
||||||
@@ -21,6 +23,7 @@ export type ShuttleRepositoryEventListener<T extends ShuttleRepositoryEventName>
|
|||||||
) => void;
|
) => void;
|
||||||
|
|
||||||
export interface ShuttleStopArrival {
|
export interface ShuttleStopArrival {
|
||||||
|
shuttleId: string;
|
||||||
stopId: string;
|
stopId: string;
|
||||||
timestamp: Date;
|
timestamp: Date;
|
||||||
}
|
}
|
||||||
@@ -50,10 +53,6 @@ export interface ShuttleGetterRepository extends EventEmitter {
|
|||||||
getShuttleById(shuttleId: string): Promise<IShuttle | null>;
|
getShuttleById(shuttleId: string): Promise<IShuttle | null>;
|
||||||
getShuttlesByRouteId(routeId: string): Promise<IShuttle[]>;
|
getShuttlesByRouteId(routeId: string): Promise<IShuttle[]>;
|
||||||
|
|
||||||
getEtasForShuttleId(shuttleId: string): Promise<IEta[]>;
|
|
||||||
getEtasForStopId(stopId: string): Promise<IEta[]>;
|
|
||||||
getEtaForShuttleAndStopId(shuttleId: string, stopId: string): Promise<IEta | null>;
|
|
||||||
|
|
||||||
on<T extends ShuttleRepositoryEventName>(event: T, listener: ShuttleRepositoryEventListener<T>): this;
|
on<T extends ShuttleRepositoryEventName>(event: T, listener: ShuttleRepositoryEventListener<T>): this;
|
||||||
once<T extends ShuttleRepositoryEventName>(event: T, listener: ShuttleRepositoryEventListener<T>): this;
|
once<T extends ShuttleRepositoryEventName>(event: T, listener: ShuttleRepositoryEventListener<T>): this;
|
||||||
off<T extends ShuttleRepositoryEventName>(event: T, listener: ShuttleRepositoryEventListener<T>): this;
|
off<T extends ShuttleRepositoryEventName>(event: T, listener: ShuttleRepositoryEventListener<T>): this;
|
||||||
|
|||||||
Reference in New Issue
Block a user