mirror of
https://github.com/brendan-ch/project-inter-server.git
synced 2026-04-17 07:50:31 +00:00
move getter methods to GetterRepository
This commit is contained in:
37
src/repositories/GetterRepository.ts
Normal file
37
src/repositories/GetterRepository.ts
Normal file
@@ -0,0 +1,37 @@
|
||||
import { IEta, IOrderedStop, IRoute, IShuttle, IStop, ISystem } from "./GetterSetterRepository";
|
||||
|
||||
export interface GetterRepository {
|
||||
getSystems(): Promise<ISystem[]>;
|
||||
getSystemById(systemId: string): Promise<ISystem | null>;
|
||||
|
||||
getStopsBySystemId(systemId: string): Promise<IStop[]>;
|
||||
getStopById(stopId: string): Promise<IStop | null>;
|
||||
|
||||
getRoutesBySystemId(systemId: string): Promise<IRoute[]>;
|
||||
getRouteById(routeId: string): Promise<IRoute | null>;
|
||||
|
||||
getShuttlesBySystemId(systemId: string): Promise<IShuttle[]>;
|
||||
getShuttleById(shuttleId: string): Promise<IShuttle | null>;
|
||||
getShuttlesByRouteId(routeId: string): Promise<IShuttle[]>;
|
||||
|
||||
getEtasForShuttleId(shuttleId: string): Promise<IEta[]>;
|
||||
getEtasForStopId(stopId: string): Promise<IEta[]>;
|
||||
|
||||
getEtaForShuttleAndStopId(shuttleId: string, stopId: string): Promise<IEta | null>;
|
||||
|
||||
getOrderedStopByRouteAndStopId(routeId: string, stopId: string): Promise<IOrderedStop | null>;
|
||||
|
||||
/**
|
||||
* Get ordered stops with the given stop ID.
|
||||
* Returns an empty array if no ordered stops found.
|
||||
* @param stopId
|
||||
*/
|
||||
getOrderedStopsByStopId(stopId: string): Promise<IOrderedStop[]>;
|
||||
|
||||
/**
|
||||
* Get ordered stops with the given route ID.
|
||||
* Returns an empty array if no ordered stops found.
|
||||
* @param routeId
|
||||
*/
|
||||
getOrderedStopsByRouteId(routeId: string): Promise<IOrderedStop[]>;
|
||||
}
|
||||
@@ -1,6 +1,8 @@
|
||||
// If types match closely, we can use TypeScript "casting"
|
||||
// to convert from data repo to GraphQL schema
|
||||
|
||||
import { GetterRepository } from "./GetterRepository";
|
||||
|
||||
export interface IEntityWithId {
|
||||
id: string;
|
||||
}
|
||||
@@ -54,43 +56,7 @@ export interface IOrderedStop {
|
||||
* Objects passed from/to the repository should be treated
|
||||
* as disposable.
|
||||
*/
|
||||
export interface GetterSetterRepository {
|
||||
// Getter methods
|
||||
|
||||
getSystems(): Promise<ISystem[]>;
|
||||
getSystemById(systemId: string): Promise<ISystem | null>;
|
||||
|
||||
getStopsBySystemId(systemId: string): Promise<IStop[]>;
|
||||
getStopById(stopId: string): Promise<IStop | null>;
|
||||
|
||||
getRoutesBySystemId(systemId: string): Promise<IRoute[]>;
|
||||
getRouteById(routeId: string): Promise<IRoute | null>;
|
||||
|
||||
getShuttlesBySystemId(systemId: string): Promise<IShuttle[]>;
|
||||
getShuttleById(shuttleId: string): Promise<IShuttle | null>;
|
||||
getShuttlesByRouteId(routeId: string): Promise<IShuttle[]>;
|
||||
|
||||
getEtasForShuttleId(shuttleId: string): Promise<IEta[]>;
|
||||
getEtasForStopId(stopId: string): Promise<IEta[]>;
|
||||
|
||||
getEtaForShuttleAndStopId(shuttleId: string, stopId: string): Promise<IEta | null>;
|
||||
|
||||
getOrderedStopByRouteAndStopId(routeId: string, stopId: string): Promise<IOrderedStop | null>;
|
||||
|
||||
/**
|
||||
* Get ordered stops with the given stop ID.
|
||||
* Returns an empty array if no ordered stops found.
|
||||
* @param stopId
|
||||
*/
|
||||
getOrderedStopsByStopId(stopId: string): Promise<IOrderedStop[]>;
|
||||
|
||||
/**
|
||||
* Get ordered stops with the given route ID.
|
||||
* Returns an empty array if no ordered stops found.
|
||||
* @param routeId
|
||||
*/
|
||||
getOrderedStopsByRouteId(routeId: string): Promise<IOrderedStop[]>;
|
||||
|
||||
export interface GetterSetterRepository extends GetterRepository {
|
||||
// Setter methods
|
||||
addOrUpdateSystem(system: ISystem): Promise<void>;
|
||||
addOrUpdateRoute(route: IRoute): Promise<void>;
|
||||
|
||||
Reference in New Issue
Block a user