UNPKG

@golemio/pid

Version:
65 lines 3.08 kB
"use strict"; var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; var __metadata = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; var __param = (this && this.__param) || function (paramIndex, decorator) { return function (target, key) { decorator(target, key, paramIndex); } }; Object.defineProperty(exports, "__esModule", { value: true }); exports.StopFacade = void 0; const OgPidToken_1 = require("../../ioc/OgPidToken"); const CisStopGroupRepository_1 = require("../../../ropid-gtfs/data-access/CisStopGroupRepository"); const models_1 = require("../../../ropid-gtfs/models"); const golemio_errors_1 = require("@golemio/core/dist/shared/golemio-errors"); const tsyringe_1 = require("@golemio/core/dist/shared/tsyringe"); let StopFacade = exports.StopFacade = class StopFacade { constructor(cisStopGroupsRepository) { this.cisStopGroupsRepository = cisStopGroupsRepository; } /** * Retrieves ASW node ID for given CIS ID and then returns GTFS stop IDs for this ASW node */ async getStopIdsForTransferBoards(cisId) { //#region CIS stop node let aswNode; try { const cisStopNode = await this.cisStopGroupsRepository.getNodeByCisId(cisId); if (cisStopNode === null) { return []; } aswNode = cisStopNode; } catch (error) { if (error instanceof golemio_errors_1.AbstractGolemioError) { throw error; } throw new golemio_errors_1.GeneralError("Failed to retrieve CIS stop node", this.constructor.name, error, 500); } //#endregion //#region GTFS stop IDs let stopIds = []; try { stopIds = await models_1.models.GTFSStopModel.getMultipleIdsByAswNode(aswNode); } catch (error) { if (error instanceof golemio_errors_1.AbstractGolemioError) { throw error; } throw new golemio_errors_1.GeneralError("Failed to retrieve GTFS stops", this.constructor.name, error, 500); } //#endregion return stopIds; } }; exports.StopFacade = StopFacade = __decorate([ (0, tsyringe_1.injectable)(), __param(0, (0, tsyringe_1.inject)(OgPidToken_1.OgPidToken.CisStopGroupRepository)), __metadata("design:paramtypes", [CisStopGroupRepository_1.CisStopGroupRepository]) ], StopFacade); //# sourceMappingURL=StopFacade.js.map