diff --git a/src/repository.ts b/src/repository.ts new file mode 100644 index 0000000..8cc3210 --- /dev/null +++ b/src/repository.ts @@ -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; + 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; + + getEtasForShuttleId(shuttleId: string): Promise; + getEtasForStopId(stopId: string): Promise; + getEtaForShuttleAndStopId(shuttleId: string, stopId: string): Promise; + + getOrderedStopByRouteAndStopId(routeId: string, stopId: string): Promise; + getOrderedStopsByStopId(stopId: string): Promise; + getOrderedStopsByRouteId(routeId: string): Promise; + getNextOrderedStopFromOrderedStopId(stopId: string): Promise; + getPreviousOrderedStopFromOrderedStopId(stopId: string): Promise; + + // Setter methods + addOrUpdateSystem(system: ISystem): Promise; + addOrUpdateRoute(route: IRoute): Promise; + addOrUpdateShuttle(shuttle: IShuttle): Promise; + addOrUpdateStop(stop: IStop): Promise; + addOrUpdateOrderedStop(orderedStop: IStop): Promise; + addOrUpdateEta(eta: IEta): Promise; +} \ No newline at end of file