mirror of
https://github.com/brendan-ch/project-inter-server.git
synced 2026-04-17 07:50:31 +00:00
add repository interface
This commit is contained in:
86
src/repository.ts
Normal file
86
src/repository.ts
Normal file
@@ -0,0 +1,86 @@
|
||||
// If types match closely, we can use TypeScript "casting"
|
||||
// to convert from data repo to GraphQL schema
|
||||
|
||||
export interface ISystem {
|
||||
id: string;
|
||||
name: string;
|
||||
}
|
||||
|
||||
export interface ICoordinates {
|
||||
latitude: number;
|
||||
longitude: number;
|
||||
}
|
||||
|
||||
export interface IRoute {
|
||||
id: string;
|
||||
name: string;
|
||||
color: string;
|
||||
polylineCoordinates: ICoordinates[];
|
||||
systemId: string;
|
||||
}
|
||||
|
||||
export interface IStop {
|
||||
id: string;
|
||||
name: string;
|
||||
systemId: string;
|
||||
coordinates: ICoordinates;
|
||||
}
|
||||
|
||||
export interface IShuttle {
|
||||
coordinates: ICoordinates;
|
||||
id: string;
|
||||
name: string;
|
||||
routeId: string;
|
||||
systemId: string;
|
||||
}
|
||||
|
||||
export interface IEta {
|
||||
secondsRemaining: number;
|
||||
shuttleId: string;
|
||||
stopId: string;
|
||||
}
|
||||
|
||||
export interface IOrderedStop {
|
||||
nextStopId: string;
|
||||
previousStopId: string;
|
||||
routeId: string;
|
||||
stopId: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Repository interface for data derived from Passio API.
|
||||
* The repository is not designed to have write locks in place.
|
||||
*/
|
||||
export interface Repository {
|
||||
// Getter methods
|
||||
|
||||
getSystems(): Promise<ISystem[]>;
|
||||
getSystemById(systemId: string): Promise<ISystem>;
|
||||
|
||||
getStopsBySystemId(systemId: string): Promise<IStop[]>;
|
||||
getStopById(stopId: string): Promise<IStop[]>;
|
||||
|
||||
getRoutesBySystemId(systemId: string): Promise<IRoute[]>;
|
||||
getRouteById(routeId: string): Promise<IRoute>;
|
||||
|
||||
getShuttlesBySystemId(systemId: string): Promise<IShuttle[]>;
|
||||
getShuttleById(shuttleId: string): Promise<IShuttle[]>;
|
||||
|
||||
getEtasForShuttleId(shuttleId: string): Promise<IEta[]>;
|
||||
getEtasForStopId(stopId: string): Promise<IEta[]>;
|
||||
getEtaForShuttleAndStopId(shuttleId: string, stopId: string): Promise<IEta[]>;
|
||||
|
||||
getOrderedStopByRouteAndStopId(routeId: string, stopId: string): Promise<IOrderedStop[]>;
|
||||
getOrderedStopsByStopId(stopId: string): Promise<IOrderedStop[]>;
|
||||
getOrderedStopsByRouteId(routeId: string): Promise<IOrderedStop[]>;
|
||||
getNextOrderedStopFromOrderedStopId(stopId: string): Promise<IOrderedStop | null>;
|
||||
getPreviousOrderedStopFromOrderedStopId(stopId: string): Promise<IOrderedStop | null>;
|
||||
|
||||
// Setter methods
|
||||
addOrUpdateSystem(system: ISystem): Promise<void>;
|
||||
addOrUpdateRoute(route: IRoute): Promise<void>;
|
||||
addOrUpdateShuttle(shuttle: IShuttle): Promise<void>;
|
||||
addOrUpdateStop(stop: IStop): Promise<void>;
|
||||
addOrUpdateOrderedStop(orderedStop: IStop): Promise<void>;
|
||||
addOrUpdateEta(eta: IEta): Promise<void>;
|
||||
}
|
||||
Reference in New Issue
Block a user