// If types match closely, we can use TypeScript "casting" // to convert from data repo to GraphQL schema export interface IEntityWithId { id: string; } export interface ISystem extends IEntityWithId { name: string; } export interface ICoordinates { latitude: number; longitude: number; } export interface IRoute extends IEntityWithId { name: string; color: string; polylineCoordinates: ICoordinates[]; systemId: string; } export interface IStop extends IEntityWithId { name: string; systemId: string; coordinates: ICoordinates; } export interface IShuttle extends IEntityWithId { coordinates: ICoordinates; name: string; routeId: string; systemId: string; } export interface IEta { secondsRemaining: number; shuttleId: string; stopId: string; } export interface IOrderedStop { nextStop?: IOrderedStop; previousStop?: IOrderedStop; routeId: string; stopId: string; position: number; } /** * Repository interface for data derived from Passio API. * The repository is not designed to have write locks in place. * Objects passed from/to the repository should be treated * as disposable. */ export interface Repository { // Getter methods getSystems(): Promise; getSystemById(systemId: string): Promise; getStopsBySystemId(systemId: string): Promise; getStopById(stopId: string): Promise; getRoutesBySystemId(systemId: string): Promise; getRouteById(routeId: string): Promise; getShuttlesBySystemId(systemId: string): Promise; getShuttleById(shuttleId: string): Promise; getShuttlesByRouteId(routeId: string): Promise; getEtasForShuttleId(shuttleId: string): Promise; getEtasForStopId(stopId: string): Promise; getEtaForShuttleAndStopId(shuttleId: string, stopId: string): Promise; getOrderedStopByRouteAndStopId(routeId: string, stopId: string): Promise; /** * Get ordered stops with the given stop ID. * Returns an empty array if no ordered stops found. * @param stopId */ getOrderedStopsByStopId(stopId: string): Promise; /** * Get ordered stops with the given route ID. * Returns an empty array if no ordered stops found. * @param routeId */ getOrderedStopsByRouteId(routeId: string): Promise; // Setter methods addOrUpdateSystem(system: ISystem): Promise; addOrUpdateRoute(route: IRoute): Promise; addOrUpdateShuttle(shuttle: IShuttle): Promise; addOrUpdateStop(stop: IStop): Promise; addOrUpdateOrderedStop(orderedStop: IOrderedStop): Promise; addOrUpdateEta(eta: IEta): Promise; }