Unify the new ETA functionality across all shuttle repositories

This commit is contained in:
2025-11-10 20:20:39 -08:00
parent e6793572bf
commit 20c97de94d
4 changed files with 197 additions and 23 deletions

View File

@@ -22,6 +22,22 @@ export type ShuttleRepositoryEventListener<T extends ShuttleRepositoryEventName>
payload: ShuttleRepositoryEventPayloads[T],
) => void;
export interface ShuttleStopArrival {
stopId: string;
timestamp: Date;
}
export interface ShuttleTravelTimeDataIdentifier {
routeId: string;
fromStopId: string;
toStopId: string;
}
export interface ShuttleTravelTimeDateFilterArguments {
from: Date;
to: Date;
}
/**
* Shuttle getter repository to be linked to a system.
*/
@@ -61,4 +77,19 @@ export interface ShuttleGetterRepository extends EventEmitter {
* @param routeId
*/
getOrderedStopsByRouteId(routeId: string): Promise<IOrderedStop[]>;
/**
* Get the last stop arrival for a shuttle.
* Returns undefined if no last stop arrival has been recorded.
* @param shuttleId
*/
getShuttleLastStopArrival(shuttleId: string): Promise<ShuttleStopArrival | undefined>;
/**
* Check if a shuttle has arrived at a stop within the given delta.
* Returns the stop if the shuttle is at a stop, otherwise undefined.
* @param shuttle
* @param delta - The coordinate delta tolerance (default 0.001)
*/
getArrivedStopIfExists(shuttle: IShuttle, delta?: number): Promise<IStop | undefined>;
}