@golemio/pid 4.0.2-dev.1982507419 → 4.0.2-rc.1988899397
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/helpers/GtfsStopParser.d.ts +0 -2
- package/dist/helpers/GtfsStopParser.js +8 -11
- package/dist/helpers/GtfsStopParser.js.map +1 -1
- package/dist/input-gateway/jis/controllers/JISEventsController.js +2 -1
- package/dist/input-gateway/jis/controllers/JISEventsController.js.map +1 -1
- package/dist/input-gateway/jis/controllers/JISInfotextsController.js +2 -1
- package/dist/input-gateway/jis/controllers/JISInfotextsController.js.map +1 -1
- package/dist/input-gateway/vehicle-positions/VehiclePositionsController.js +1 -0
- package/dist/input-gateway/vehicle-positions/VehiclePositionsController.js.map +1 -1
- package/dist/integration-engine/jis/ioc/Di.js +0 -10
- package/dist/integration-engine/jis/ioc/Di.js.map +1 -1
- package/dist/integration-engine/jis/ioc/JISContainerToken.d.ts +0 -4
- package/dist/integration-engine/jis/ioc/JISContainerToken.js +0 -5
- package/dist/integration-engine/jis/ioc/JISContainerToken.js.map +1 -1
- package/dist/integration-engine/jis/repositories/JISInfotextsRepository.d.ts +1 -6
- package/dist/integration-engine/jis/repositories/JISInfotextsRepository.js +2 -50
- package/dist/integration-engine/jis/repositories/JISInfotextsRepository.js.map +1 -1
- package/dist/integration-engine/jis/workers/JISWorker.js +0 -1
- package/dist/integration-engine/jis/workers/JISWorker.js.map +1 -1
- package/dist/integration-engine/jis/workers/tasks/RefreshJISInfotextsTask.d.ts +2 -1
- package/dist/integration-engine/jis/workers/tasks/RefreshJISInfotextsTask.js +4 -5
- package/dist/integration-engine/jis/workers/tasks/RefreshJISInfotextsTask.js.map +1 -1
- package/dist/integration-engine/ropid-gtfs/RopidGTFSStopsModel.d.ts +1 -5
- package/dist/integration-engine/ropid-gtfs/RopidGTFSStopsModel.js +0 -24
- package/dist/integration-engine/ropid-gtfs/RopidGTFSStopsModel.js.map +1 -1
- package/dist/integration-engine/ropid-gtfs/data-access/cache/DelayComputationRedisRepository.js.map +1 -1
- package/dist/integration-engine/ropid-gtfs/index.d.ts +0 -1
- package/dist/integration-engine/ropid-gtfs/index.js +0 -1
- package/dist/integration-engine/ropid-gtfs/index.js.map +1 -1
- package/dist/integration-engine/ropid-gtfs/ioc/Di.js +0 -8
- package/dist/integration-engine/ropid-gtfs/ioc/Di.js.map +1 -1
- package/dist/integration-engine/ropid-gtfs/ioc/RopidGtfsContainerToken.d.ts +0 -3
- package/dist/integration-engine/ropid-gtfs/ioc/RopidGtfsContainerToken.js +0 -3
- package/dist/integration-engine/ropid-gtfs/ioc/RopidGtfsContainerToken.js.map +1 -1
- package/dist/integration-engine/ropid-gtfs/transformations/RopidDeparturesPresetsTransformation.js +1 -1
- package/dist/integration-engine/ropid-gtfs/transformations/RopidDeparturesPresetsTransformation.js.map +1 -1
- package/dist/integration-engine/ropid-gtfs/workers/timetables/TimetableWorker.js +0 -1
- package/dist/integration-engine/ropid-gtfs/workers/timetables/TimetableWorker.js.map +1 -1
- package/dist/integration-engine/ropid-gtfs/workers/timetables/tasks/CheckSavedRowsAndReplaceTablesTask.js +5 -8
- package/dist/integration-engine/ropid-gtfs/workers/timetables/tasks/CheckSavedRowsAndReplaceTablesTask.js.map +1 -1
- package/dist/integration-engine/vehicle-positions/workers/vehicle-positions/data-access/TripsRepository.js +0 -1
- package/dist/integration-engine/vehicle-positions/workers/vehicle-positions/data-access/TripsRepository.js.map +1 -1
- package/dist/integration-engine/vehicle-positions/workers/vehicle-positions/data-access/interfaces/TripRepositoryInterfaces.d.ts +1 -2
- package/dist/integration-engine/vehicle-positions/workers/vehicle-positions/tasks/PropagateTrainDelayTask.js.map +1 -1
- package/dist/integration-engine/vehicle-positions/workers/vehicle-positions/tasks/RefreshPublicStopTimeCacheTask.js +0 -1
- package/dist/integration-engine/vehicle-positions/workers/vehicle-positions/tasks/RefreshPublicStopTimeCacheTask.js.map +1 -1
- package/dist/integration-engine/vehicle-positions/workers/vehicle-positions/transformations/PublicApiTripTransformation.js +0 -2
- package/dist/integration-engine/vehicle-positions/workers/vehicle-positions/transformations/PublicApiTripTransformation.js.map +1 -1
- package/dist/output-gateway/index.js +0 -1
- package/dist/output-gateway/index.js.map +1 -1
- package/dist/output-gateway/jis/ioc/Di.js +2 -2
- package/dist/output-gateway/jis/ioc/Di.js.map +1 -1
- package/dist/output-gateway/jis/ioc/OgJisToken.d.ts +0 -2
- package/dist/output-gateway/jis/ioc/OgJisToken.js +0 -2
- package/dist/output-gateway/jis/ioc/OgJisToken.js.map +1 -1
- package/dist/output-gateway/pid/controllers/v3/V3TransferBoardsController.js.map +1 -1
- package/dist/output-gateway/pid/domain/InfotextInterfaces.d.ts +0 -5
- package/dist/output-gateway/pid/helpers/JISInfotextStopSuppressionFilter.d.ts +1 -4
- package/dist/output-gateway/pid/helpers/JISInfotextStopSuppressionFilter.js +1 -7
- package/dist/output-gateway/pid/helpers/JISInfotextStopSuppressionFilter.js.map +1 -1
- package/dist/output-gateway/pid/index.d.ts +0 -50
- package/dist/output-gateway/pid/index.js.map +1 -1
- package/dist/output-gateway/pid/ioc/Di.js +6 -62
- package/dist/output-gateway/pid/ioc/Di.js.map +1 -1
- package/dist/output-gateway/pid/ioc/OgPidToken.d.ts +0 -11
- package/dist/output-gateway/pid/ioc/OgPidToken.js +0 -11
- package/dist/output-gateway/pid/ioc/OgPidToken.js.map +1 -1
- package/dist/output-gateway/pid/routers/index.d.ts +0 -1
- package/dist/output-gateway/pid/routers/index.js +1 -3
- package/dist/output-gateway/pid/routers/index.js.map +1 -1
- package/dist/output-gateway/pid/service/facade/InfotextFacade.d.ts +2 -7
- package/dist/output-gateway/pid/service/facade/InfotextFacade.js +4 -29
- package/dist/output-gateway/pid/service/facade/InfotextFacade.js.map +1 -1
- package/dist/output-gateway/pid/service/facade/StopFacade.d.ts +3 -12
- package/dist/output-gateway/pid/service/facade/StopFacade.js +7 -43
- package/dist/output-gateway/pid/service/facade/StopFacade.js.map +1 -1
- package/dist/output-gateway/pid/service/facade/TransferFacade.d.ts +9 -11
- package/dist/output-gateway/pid/service/facade/TransferFacade.js +14 -117
- package/dist/output-gateway/pid/service/facade/TransferFacade.js.map +1 -1
- package/dist/output-gateway/pid/service/helpers/PlatformCodeResolver.d.ts +1 -7
- package/dist/output-gateway/pid/service/helpers/PlatformCodeResolver.js +0 -12
- package/dist/output-gateway/pid/service/helpers/PlatformCodeResolver.js.map +1 -1
- package/dist/output-gateway/public/data-access/redis/PublicGtfsDepartureRepository.d.ts +1 -1
- package/dist/output-gateway/public/data-access/redis/PublicGtfsDepartureRepository.js +4 -4
- package/dist/output-gateway/public/data-access/redis/PublicGtfsDepartureRepository.js.map +1 -1
- package/dist/output-gateway/public/ioc/Di.js +1 -1
- package/dist/output-gateway/public/ioc/Di.js.map +1 -1
- package/dist/output-gateway/{shared → public}/service/VPSubscriber.d.ts +2 -4
- package/dist/output-gateway/{shared → public}/service/VPSubscriber.js +1 -1
- package/dist/output-gateway/public/service/VPSubscriber.js.map +1 -0
- package/dist/output-gateway/shared/constants/route-version.d.ts +1 -2
- package/dist/output-gateway/shared/constants/route-version.js +0 -1
- package/dist/output-gateway/shared/constants/route-version.js.map +1 -1
- package/dist/schema-definitions/jis/redis/const.d.ts +0 -1
- package/dist/schema-definitions/jis/redis/const.js +1 -2
- package/dist/schema-definitions/jis/redis/const.js.map +1 -1
- package/dist/schema-definitions/ropid-departures-presets/index.d.ts +0 -1
- package/dist/schema-definitions/ropid-departures-presets/index.js +0 -3
- package/dist/schema-definitions/ropid-departures-presets/index.js.map +1 -1
- package/dist/schema-definitions/ropid-gtfs/interfaces/IStopDto.d.ts +0 -1
- package/dist/schema-definitions/ropid-gtfs/redis/const.d.ts +0 -1
- package/dist/schema-definitions/ropid-gtfs/redis/const.js +1 -2
- package/dist/schema-definitions/ropid-gtfs/redis/const.js.map +1 -1
- package/dist/schema-definitions/vehicle-positions/models/views/PublicStopTimeModel.d.ts +2 -3
- package/dist/schema-definitions/vehicle-positions/models/views/PublicStopTimeModel.js +0 -4
- package/dist/schema-definitions/vehicle-positions/models/views/PublicStopTimeModel.js.map +1 -1
- package/dist/schema-definitions/vehicle-positions/models/views/interfaces/IPublicStopTimeDto.d.ts +0 -1
- package/dist/schema-definitions/vehicle-positions/redis/interfaces/IPublicApiCacheDto.d.ts +0 -2
- package/dist/schema-definitions/vehicle-positions/redis/interfaces/IPublicStopTimeCacheDto.d.ts +0 -1
- package/dist/schema-definitions/vehicle-positions/redis/schemas/PublicApiCacheDtoSchema.js +0 -8
- package/dist/schema-definitions/vehicle-positions/redis/schemas/PublicApiCacheDtoSchema.js.map +1 -1
- package/dist/schema-definitions/vehicle-positions/redis/schemas/PublicStopTimeCacheDtoSchema.js +1 -4
- package/dist/schema-definitions/vehicle-positions/redis/schemas/PublicStopTimeCacheDtoSchema.js.map +1 -1
- package/docs/asyncapi.yaml +0 -45
- package/docs/cache/types/redis.md +2 -82
- package/docs/jis/index.md +5 -15
- package/docs/openapi-input.yaml +2 -13
- package/docs/openapi-output.yaml +4 -326
- package/package.json +2 -2
- package/db/example/redis/gtfsStopsCacheMock.json +0 -8
- package/db/example/redis/jisCacheMock.json +0 -31
- package/db/migrations/postgresql/20250716143052-add-stop-name-to-combined-stop-times.js +0 -53
- package/db/migrations/postgresql/sqls/20250716143052-add-stop-name-to-combined-stop-times-down.sql +0 -47
- package/db/migrations/postgresql/sqls/20250716143052-add-stop-name-to-combined-stop-times-up.sql +0 -47
- package/dist/helpers/jis/JISInfotextSeverityLevelPriority.d.ts +0 -6
- package/dist/helpers/jis/JISInfotextSeverityLevelPriority.js +0 -11
- package/dist/helpers/jis/JISInfotextSeverityLevelPriority.js.map +0 -1
- package/dist/integration-engine/jis/repositories/JISInfotextsRedisRepository.d.ts +0 -9
- package/dist/integration-engine/jis/repositories/JISInfotextsRedisRepository.js +0 -86
- package/dist/integration-engine/jis/repositories/JISInfotextsRedisRepository.js.map +0 -1
- package/dist/integration-engine/jis/transformations/JISInfotextCacheTranformation.d.ts +0 -7
- package/dist/integration-engine/jis/transformations/JISInfotextCacheTranformation.js +0 -37
- package/dist/integration-engine/jis/transformations/JISInfotextCacheTranformation.js.map +0 -1
- package/dist/integration-engine/jis/workers/tasks/RefreshJISInfotextsCacheTask.d.ts +0 -13
- package/dist/integration-engine/jis/workers/tasks/RefreshJISInfotextsCacheTask.js +0 -47
- package/dist/integration-engine/jis/workers/tasks/RefreshJISInfotextsCacheTask.js.map +0 -1
- package/dist/integration-engine/ropid-gtfs/RopidGTFSCisStopsModel.d.ts +0 -18
- package/dist/integration-engine/ropid-gtfs/RopidGTFSCisStopsModel.js +0 -44
- package/dist/integration-engine/ropid-gtfs/RopidGTFSCisStopsModel.js.map +0 -1
- package/dist/integration-engine/ropid-gtfs/workers/timetables/tasks/RefreshGtfsStopsCacheTask.d.ts +0 -12
- package/dist/integration-engine/ropid-gtfs/workers/timetables/tasks/RefreshGtfsStopsCacheTask.js +0 -44
- package/dist/integration-engine/ropid-gtfs/workers/timetables/tasks/RefreshGtfsStopsCacheTask.js.map +0 -1
- package/dist/integration-engine/ropid-gtfs/workers/timetables/tasks/data-access/cache/GtfsStopsRedisRepository.d.ts +0 -12
- package/dist/integration-engine/ropid-gtfs/workers/timetables/tasks/data-access/cache/GtfsStopsRedisRepository.js +0 -87
- package/dist/integration-engine/ropid-gtfs/workers/timetables/tasks/data-access/cache/GtfsStopsRedisRepository.js.map +0 -1
- package/dist/output-gateway/jis/data-access/cache/JISInfotextsRedisRepository.d.ts +0 -17
- package/dist/output-gateway/jis/data-access/cache/JISInfotextsRedisRepository.js +0 -113
- package/dist/output-gateway/jis/data-access/cache/JISInfotextsRedisRepository.js.map +0 -1
- package/dist/output-gateway/pid/controllers/v4/V4TransferBoardsController.d.ts +0 -17
- package/dist/output-gateway/pid/controllers/v4/V4TransferBoardsController.js +0 -154
- package/dist/output-gateway/pid/controllers/v4/V4TransferBoardsController.js.map +0 -1
- package/dist/output-gateway/pid/controllers/v4/interfaces/ITransferBoardsParams.d.ts +0 -14
- package/dist/output-gateway/pid/controllers/v4/interfaces/ITransferBoardsParams.js +0 -3
- package/dist/output-gateway/pid/controllers/v4/interfaces/ITransferBoardsParams.js.map +0 -1
- package/dist/output-gateway/pid/helpers/TransferBoardFilter.d.ts +0 -5
- package/dist/output-gateway/pid/helpers/TransferBoardFilter.js +0 -33
- package/dist/output-gateway/pid/helpers/TransferBoardFilter.js.map +0 -1
- package/dist/output-gateway/pid/helpers/TransferBoardSorter.d.ts +0 -6
- package/dist/output-gateway/pid/helpers/TransferBoardSorter.js +0 -61
- package/dist/output-gateway/pid/helpers/TransferBoardSorter.js.map +0 -1
- package/dist/output-gateway/pid/routers/v4/V4PIDRouter.d.ts +0 -16
- package/dist/output-gateway/pid/routers/v4/V4PIDRouter.js +0 -67
- package/dist/output-gateway/pid/routers/v4/V4PIDRouter.js.map +0 -1
- package/dist/output-gateway/pid/service/transformations/JISInfotextCacheTransferTransformation.d.ts +0 -13
- package/dist/output-gateway/pid/service/transformations/JISInfotextCacheTransferTransformation.js +0 -31
- package/dist/output-gateway/pid/service/transformations/JISInfotextCacheTransferTransformation.js.map +0 -1
- package/dist/output-gateway/pid/service/transformations/TransferDepartureCacheTransformation.d.ts +0 -27
- package/dist/output-gateway/pid/service/transformations/TransferDepartureCacheTransformation.js +0 -78
- package/dist/output-gateway/pid/service/transformations/TransferDepartureCacheTransformation.js.map +0 -1
- package/dist/output-gateway/ropid-gtfs/data-access/redis/GtfsStopsRedisRepository.d.ts +0 -13
- package/dist/output-gateway/ropid-gtfs/data-access/redis/GtfsStopsRedisRepository.js +0 -83
- package/dist/output-gateway/ropid-gtfs/data-access/redis/GtfsStopsRedisRepository.js.map +0 -1
- package/dist/output-gateway/shared/service/VPSubscriber.js.map +0 -1
- package/dist/schema-definitions/jis/redis/interfaces/IJISInfotextDto.d.ts +0 -17
- package/dist/schema-definitions/jis/redis/interfaces/IJISInfotextDto.js +0 -3
- package/dist/schema-definitions/jis/redis/interfaces/IJISInfotextDto.js.map +0 -1
- package/dist/schema-definitions/jis/redis/schemas/JISInfotextDtoSchema.d.ts +0 -3
- package/dist/schema-definitions/jis/redis/schemas/JISInfotextDtoSchema.js +0 -59
- package/dist/schema-definitions/jis/redis/schemas/JISInfotextDtoSchema.js.map +0 -1
- package/dist/schema-definitions/ropid-gtfs/interfaces/IStopCisDto.d.ts +0 -16
- package/dist/schema-definitions/ropid-gtfs/interfaces/IStopCisDto.js +0 -3
- package/dist/schema-definitions/ropid-gtfs/interfaces/IStopCisDto.js.map +0 -1
- package/dist/schema-definitions/ropid-gtfs/models/StopCisDto.d.ts +0 -58
- package/dist/schema-definitions/ropid-gtfs/models/StopCisDto.js +0 -69
- package/dist/schema-definitions/ropid-gtfs/models/StopCisDto.js.map +0 -1
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
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;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
-
};
|
|
11
|
-
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
-
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
-
};
|
|
14
|
-
var GtfsStopsRedisRepository_1;
|
|
15
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
-
exports.GtfsStopsRedisRepository = void 0;
|
|
17
|
-
const GtfsStopParser_1 = require("../../../../../../../helpers/GtfsStopParser");
|
|
18
|
-
const RopidGtfsContainerToken_1 = require("../../../../../ioc/RopidGtfsContainerToken");
|
|
19
|
-
const const_1 = require("../../../../../../../schema-definitions/ropid-gtfs/redis/const");
|
|
20
|
-
const integration_engine_1 = require("@golemio/core/dist/integration-engine");
|
|
21
|
-
const golemio_errors_1 = require("@golemio/core/dist/shared/golemio-errors");
|
|
22
|
-
const tsyringe_1 = require("@golemio/core/dist/shared/tsyringe");
|
|
23
|
-
const node_crypto_1 = require("node:crypto");
|
|
24
|
-
const TTL_SECONDS_BEFORE_DELETE = 60;
|
|
25
|
-
let GtfsStopsRedisRepository = exports.GtfsStopsRedisRepository = GtfsStopsRedisRepository_1 = class GtfsStopsRedisRepository extends integration_engine_1.RedisModel {
|
|
26
|
-
constructor(gtfsStopParser) {
|
|
27
|
-
super("GtfsStopsRedisRepository", {
|
|
28
|
-
isKeyConstructedFromData: false,
|
|
29
|
-
prefix: GtfsStopsRedisRepository_1.NAMESPACE_PREFIX,
|
|
30
|
-
});
|
|
31
|
-
this.gtfsStopParser = gtfsStopParser;
|
|
32
|
-
}
|
|
33
|
-
async refreshData(cisStops, gtfsStops) {
|
|
34
|
-
try {
|
|
35
|
-
const oldSetName = (await this.connection.get(`${this.prefix}:activeSetName`)) ?? "";
|
|
36
|
-
await this.createNewCache(cisStops, gtfsStops);
|
|
37
|
-
await this.deleteOldCache(oldSetName);
|
|
38
|
-
}
|
|
39
|
-
catch (err) {
|
|
40
|
-
throw new golemio_errors_1.GeneralError("refreshData failed", this.constructor.name, err);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
async createNewCache(cisStops, gtfsStops) {
|
|
44
|
-
try {
|
|
45
|
-
const cisToAswNode = new Map();
|
|
46
|
-
for (const stop of cisStops) {
|
|
47
|
-
cisToAswNode.set(stop.cis, this.gtfsStopParser.getAswNodeFromId(stop.id));
|
|
48
|
-
}
|
|
49
|
-
const aswNodeToGtfsStops = new Map();
|
|
50
|
-
for (const stop of gtfsStops) {
|
|
51
|
-
const nodeStopIds = aswNodeToGtfsStops.get(stop.asw_node_id) ?? [];
|
|
52
|
-
if (nodeStopIds.length === 0) {
|
|
53
|
-
aswNodeToGtfsStops.set(stop.asw_node_id, nodeStopIds);
|
|
54
|
-
}
|
|
55
|
-
nodeStopIds.push(stop.stop_id);
|
|
56
|
-
}
|
|
57
|
-
const setName = (0, node_crypto_1.randomBytes)(4).toString("hex");
|
|
58
|
-
const pipeline = this.connection.pipeline();
|
|
59
|
-
pipeline.hset(`${this.prefix}:${setName}:aswNodeToGtfsStops`, aswNodeToGtfsStops);
|
|
60
|
-
pipeline.hset(`${this.prefix}:${setName}:cisToAswNode`, cisToAswNode);
|
|
61
|
-
pipeline.publish(`${this.prefix}`, `${this.prefix}:${setName}`);
|
|
62
|
-
pipeline.set(`${this.prefix}:activeSetName`, `${this.prefix}:${setName}`);
|
|
63
|
-
await pipeline.exec();
|
|
64
|
-
}
|
|
65
|
-
catch (err) {
|
|
66
|
-
throw new golemio_errors_1.GeneralError("createNewCache failed", this.constructor.name, err);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
async deleteOldCache(setName) {
|
|
70
|
-
try {
|
|
71
|
-
const pipeline = this.connection.pipeline();
|
|
72
|
-
pipeline.expire(`${setName}:aswNodeToGtfsStops`, TTL_SECONDS_BEFORE_DELETE);
|
|
73
|
-
pipeline.expire(`${setName}:cisToAswNode`, TTL_SECONDS_BEFORE_DELETE);
|
|
74
|
-
await pipeline.exec();
|
|
75
|
-
}
|
|
76
|
-
catch (err) {
|
|
77
|
-
throw new golemio_errors_1.GeneralError("deleteOldCache failed", this.constructor.name, err);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
};
|
|
81
|
-
GtfsStopsRedisRepository.NAMESPACE_PREFIX = const_1.GTFS_STOPS_NAMESPACE_PREFIX;
|
|
82
|
-
exports.GtfsStopsRedisRepository = GtfsStopsRedisRepository = GtfsStopsRedisRepository_1 = __decorate([
|
|
83
|
-
(0, tsyringe_1.injectable)(),
|
|
84
|
-
__param(0, (0, tsyringe_1.inject)(RopidGtfsContainerToken_1.RopidGtfsContainerToken.GtfsStopParser)),
|
|
85
|
-
__metadata("design:paramtypes", [GtfsStopParser_1.GtfsStopParser])
|
|
86
|
-
], GtfsStopsRedisRepository);
|
|
87
|
-
//# sourceMappingURL=GtfsStopsRedisRepository.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"GtfsStopsRedisRepository.js","sourceRoot":"","sources":["../../../../../../../../src/integration-engine/ropid-gtfs/workers/timetables/tasks/data-access/cache/GtfsStopsRedisRepository.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,gFAAyD;AACzD,wFAAqF;AAGrF,0FAA0E;AAC1E,8EAAmE;AACnE,6EAAwE;AACxE,iEAAwE;AACxE,6CAA0C;AAE1C,MAAM,yBAAyB,GAAG,EAAE,CAAC;AAG9B,IAAM,wBAAwB,mEAA9B,MAAM,wBAAyB,SAAQ,+BAAU;IAGpD,YAAoE,cAA8B;QAC9F,KAAK,CAAC,0BAA0B,EAAE;YAC9B,wBAAwB,EAAE,KAAK;YAC/B,MAAM,EAAE,0BAAwB,CAAC,gBAAgB;SACpD,CAAC,CAAC;QAJ6D,mBAAc,GAAd,cAAc,CAAgB;IAKlG,CAAC;IAEM,KAAK,CAAC,WAAW,CACpB,QAAgD,EAChD,SAAoC;QAEpC,IAAI;YACA,MAAM,UAAU,GAAG,CAAC,MAAM,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,MAAM,gBAAgB,CAAC,CAAC,IAAI,EAAE,CAAC;YACrF,MAAM,IAAI,CAAC,cAAc,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;YAC/C,MAAM,IAAI,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC;SACzC;QAAC,OAAO,GAAG,EAAE;YACV,MAAM,IAAI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AM,IAAI,OAAO,EAAE,CAAC,CAAC;YAChE,QAAQ,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,MAAM,gBAAgB,EAAE,GAAG,IAAI,CAAC,MAAM,IAAI,OAAO,EAAE,CAAC,CAAC;YAC1E,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;SACzB;QAAC,OAAO,GAAG,EAAE;YACV,MAAM,IAAI,6BAAY,CAAC,uBAAuB,EAAE,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;SAC/E;IACL,CAAC;IAEO,KAAK,CAAC,cAAc,CAAC,OAAe;QACxC,IAAI;YACA,MAAM,QAAQ,GAAG,IAAI,CAAC,UAAU,CAAC,QAAQ,EAAE,CAAC;YAC5C,QAAQ,CAAC,MAAM,CAAC,GAAG,OAAO,qBAAqB,EAAE,yBAAyB,CAAC,CAAC;YAC5E,QAAQ,CAAC,MAAM,CAAC,GAAG,OAAO,eAAe,EAAE,yBAAyB,CAAC,CAAC;YACtE,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;SACzB;QAAC,OAAO,GAAG,EAAE;YACV,MAAM,IAAI,6BAAY,CAAC,uBAAuB,EAAE,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;SAC/E;IACL,CAAC;;AA9Da,yCAAgB,GAAG,mCAA2B,AAA9B,CAA+B;mCADpD,wBAAwB;IADpC,IAAA,qBAAU,GAAE;IAII,WAAA,IAAA,iBAAM,EAAC,iDAAuB,CAAC,cAAc,CAAC,CAAA;qCAAyB,+BAAc;GAHzF,wBAAwB,CAgEpC"}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { RepositoryWithSubscriber } from "../../../shared/service/VPSubscriber";
|
|
2
|
-
import { IJISInfotextDto } from "../../../../schema-definitions/jis/redis/interfaces/IJISInfotextDto";
|
|
3
|
-
import { IoRedisConnector } from "@golemio/core/dist/helpers/data-access/redis/IoRedisConnector";
|
|
4
|
-
import { ILogger } from "@golemio/core/dist/helpers/logger/LoggerProvider";
|
|
5
|
-
export declare class JISInfotextsRedisRepository implements RepositoryWithSubscriber {
|
|
6
|
-
private redisConnector;
|
|
7
|
-
private log;
|
|
8
|
-
private setName;
|
|
9
|
-
constructor(redisConnector: IoRedisConnector, log: ILogger);
|
|
10
|
-
private checkSetNameAndConnection;
|
|
11
|
-
setCurrentSetName(name: string): void;
|
|
12
|
-
getActiveStopsInfotexts(stopIds: string[], timeFrom?: Date): Promise<IJISInfotextDto[]>;
|
|
13
|
-
private getStopsInfotexts;
|
|
14
|
-
private getStopsInfotextIds;
|
|
15
|
-
private getInfotextsByIds;
|
|
16
|
-
private sortAndFilter;
|
|
17
|
-
}
|
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
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;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
-
};
|
|
11
|
-
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
-
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
-
};
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.JISInfotextsRedisRepository = void 0;
|
|
16
|
-
const JISInfotextSeverityLevelPriority_1 = require("../../../../helpers/jis/JISInfotextSeverityLevelPriority");
|
|
17
|
-
const const_1 = require("../../../../schema-definitions/jis/redis/const");
|
|
18
|
-
const IoRedisConnector_1 = require("@golemio/core/dist/helpers/data-access/redis/IoRedisConnector");
|
|
19
|
-
const CoreToken_1 = require("@golemio/core/dist/helpers/ioc/CoreToken");
|
|
20
|
-
const ioc_1 = require("@golemio/core/dist/output-gateway/ioc");
|
|
21
|
-
const golemio_errors_1 = require("@golemio/core/dist/shared/golemio-errors");
|
|
22
|
-
const tsyringe_1 = require("@golemio/core/dist/shared/tsyringe");
|
|
23
|
-
let JISInfotextsRedisRepository = exports.JISInfotextsRedisRepository = class JISInfotextsRedisRepository {
|
|
24
|
-
constructor(redisConnector, log) {
|
|
25
|
-
this.redisConnector = redisConnector;
|
|
26
|
-
this.log = log;
|
|
27
|
-
this.setName = undefined; // loaded via pub sub or loaded from redis
|
|
28
|
-
}
|
|
29
|
-
async checkSetNameAndConnection() {
|
|
30
|
-
if (!this.redisConnector.isConnected()) {
|
|
31
|
-
await this.redisConnector.connect();
|
|
32
|
-
}
|
|
33
|
-
const connection = this.redisConnector.getConnection();
|
|
34
|
-
if (!this.setName) {
|
|
35
|
-
const loadedSetName = await connection.get(`${const_1.JIS_NAMESPACE_PREFIX}:activeSetName`);
|
|
36
|
-
if (!loadedSetName) {
|
|
37
|
-
this.log.debug(`Empty setName for ${const_1.JIS_NAMESPACE_PREFIX}`);
|
|
38
|
-
return null;
|
|
39
|
-
}
|
|
40
|
-
else {
|
|
41
|
-
this.setName = loadedSetName;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
return connection;
|
|
45
|
-
}
|
|
46
|
-
setCurrentSetName(name) {
|
|
47
|
-
this.setName = name;
|
|
48
|
-
}
|
|
49
|
-
async getActiveStopsInfotexts(stopIds, timeFrom = new Date()) {
|
|
50
|
-
const infotexts = await this.getStopsInfotexts(stopIds);
|
|
51
|
-
return this.sortAndFilter(infotexts, timeFrom);
|
|
52
|
-
}
|
|
53
|
-
async getStopsInfotexts(stopIds) {
|
|
54
|
-
try {
|
|
55
|
-
const connection = await this.checkSetNameAndConnection();
|
|
56
|
-
if (!connection) {
|
|
57
|
-
return [];
|
|
58
|
-
}
|
|
59
|
-
const infotextIds = await this.getStopsInfotextIds(stopIds, connection);
|
|
60
|
-
if (infotextIds.size === 0)
|
|
61
|
-
return [];
|
|
62
|
-
return this.getInfotextsByIds(infotextIds, connection);
|
|
63
|
-
}
|
|
64
|
-
catch (error) {
|
|
65
|
-
throw new golemio_errors_1.GeneralError("Cannot get stop infotexts from cache", this.constructor.name, error);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
async getStopsInfotextIds(stopIds, connection) {
|
|
69
|
-
const stopsInfotexts = await connection.hmget(`${this.setName}:stops-infotexts`, ...stopIds);
|
|
70
|
-
const infotextIds = new Set();
|
|
71
|
-
for (const infotextIdsRaw of stopsInfotexts) {
|
|
72
|
-
for (const infotextId of infotextIdsRaw?.split(",") ?? []) {
|
|
73
|
-
infotextIds.add(infotextId);
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
return infotextIds;
|
|
77
|
-
}
|
|
78
|
-
async getInfotextsByIds(infotextIds, connection) {
|
|
79
|
-
const infotextsRaw = await connection.hmget(`${this.setName}:infotexts`, ...infotextIds);
|
|
80
|
-
const infotexts = [];
|
|
81
|
-
for (const infotext of infotextsRaw) {
|
|
82
|
-
if (infotext === null)
|
|
83
|
-
continue;
|
|
84
|
-
infotexts.push(JSON.parse(infotext));
|
|
85
|
-
}
|
|
86
|
-
return infotexts;
|
|
87
|
-
}
|
|
88
|
-
sortAndFilter(infotexts, timeFrom) {
|
|
89
|
-
const activeInfotexts = infotexts.filter((infotext) => new Date(infotext.active_period_start) <= timeFrom &&
|
|
90
|
-
(!infotext.active_period_end || new Date(infotext.active_period_end) >= timeFrom));
|
|
91
|
-
return activeInfotexts.sort((a, b) => {
|
|
92
|
-
// First sort by severity_level DESC
|
|
93
|
-
if (a.severity_level !== b.severity_level) {
|
|
94
|
-
return JISInfotextSeverityLevelPriority_1.JISInfotextSeverityLevelPriority[b.severity_level] - JISInfotextSeverityLevelPriority_1.JISInfotextSeverityLevelPriority[a.severity_level];
|
|
95
|
-
}
|
|
96
|
-
// Then sort by created_timestamp DESC
|
|
97
|
-
const createdA = a.created_timestamp;
|
|
98
|
-
const createdB = b.created_timestamp;
|
|
99
|
-
if (createdA < createdB)
|
|
100
|
-
return -1;
|
|
101
|
-
if (createdA > createdB)
|
|
102
|
-
return 1;
|
|
103
|
-
return 0;
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
|
-
};
|
|
107
|
-
exports.JISInfotextsRedisRepository = JISInfotextsRedisRepository = __decorate([
|
|
108
|
-
(0, tsyringe_1.injectable)(),
|
|
109
|
-
__param(0, (0, tsyringe_1.inject)(ioc_1.ContainerToken.RedisConnector)),
|
|
110
|
-
__param(1, (0, tsyringe_1.inject)(CoreToken_1.CoreToken.Logger)),
|
|
111
|
-
__metadata("design:paramtypes", [IoRedisConnector_1.IoRedisConnector, Object])
|
|
112
|
-
], JISInfotextsRedisRepository);
|
|
113
|
-
//# sourceMappingURL=JISInfotextsRedisRepository.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"JISInfotextsRedisRepository.js","sourceRoot":"","sources":["../../../../../src/output-gateway/jis/data-access/cache/JISInfotextsRedisRepository.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,+GAAiG;AAEjG,0EAA4D;AAE5D,oGAAiG;AACjG,wEAAqE;AAErE,+DAAuE;AACvE,6EAAwE;AACxE,iEAAwE;AAKjE,IAAM,2BAA2B,yCAAjC,MAAM,2BAA2B;IAGpC,YAC2C,cAAwC,EACrD,GAAoB;QADC,mBAAc,GAAd,cAAc,CAAkB;QAC7C,QAAG,GAAH,GAAG,CAAS;QAJ1C,YAAO,GAAuB,SAAS,CAAC,CAAC,0CAA0C;IAKxF,CAAC;IAEI,KAAK,CAAC,yBAAyB;QACnC,IAAI,CAAC,IAAI,CAAC,cAAc,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AAC,QAAQ,CAAC,iBAAiB,CAAC,IAAI,QAAQ,CAAC,CACxF,CAAC;QACF,OAAO,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;YACjC,oCAAoC;YACpC,IAAI,CAAC,CAAC,cAAc,KAAK,CAAC,CAAC,cAAc,EAAE;gBACvC,OAAO,mEAAgC,CAAC,CAAC,CAAC,cAAc,CAAC,GAAG,mEAAgC,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC;aAClH;YACD,sCAAsC;YACtC,MAAM,QAAQ,GAAG,CAAC,CAAC,iBAAiB,CAAC;YACrC,MAAM,QAAQ,GAAG,CAAC,CAAC,iBAAiB,CAAC;YACrC,IAAI,QAAQ,GAAG,QAAQ;gBAAE,OAAO,CAAC,CAAC,CAAC;YACnC,IAAI,QAAQ,GAAG,QAAQ;gBAAE,OAAO,CAAC,CAAC;YAClC,OAAO,CAAC,CAAC;QACb,CAAC,CAAC,CAAC;IACP,CAAC;CACJ,CAAA;sCAzFY,2BAA2B;IADvC,IAAA,qBAAU,GAAE;IAKJ,WAAA,IAAA,iBAAM,EAAC,oBAAc,CAAC,cAAc,CAAC,CAAA;IACrC,WAAA,IAAA,iBAAM,EAAC,qBAAS,CAAC,MAAM,CAAC,CAAA;qCADsC,mCAAgB;GAJ1E,2BAA2B,CAyFvC"}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/// <reference types="express" />
|
|
2
|
-
import { InfotextFacade } from "../../service/facade/InfotextFacade";
|
|
3
|
-
import { StopFacade } from "../../service/facade/StopFacade";
|
|
4
|
-
import { TransferFacade } from "../../service/facade/TransferFacade";
|
|
5
|
-
import { RequestHandler } from "@golemio/core/dist/shared/express";
|
|
6
|
-
import { TransferDepartureCacheTransformation } from "../../service/transformations/TransferDepartureCacheTransformation";
|
|
7
|
-
export declare class V4TransferBoardsController {
|
|
8
|
-
private stopFacade;
|
|
9
|
-
private infotextFacade;
|
|
10
|
-
private transferFacade;
|
|
11
|
-
private transformation;
|
|
12
|
-
private readonly defaultTransferBoardsLimit;
|
|
13
|
-
constructor(stopFacade: StopFacade, infotextFacade: InfotextFacade, transferFacade: TransferFacade, transformation: TransferDepartureCacheTransformation);
|
|
14
|
-
getTransferBoardData: RequestHandler;
|
|
15
|
-
private parseTransferBoardsParams;
|
|
16
|
-
private getTimeFrom;
|
|
17
|
-
}
|
|
@@ -1,154 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
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;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
-
};
|
|
11
|
-
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
-
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
-
};
|
|
14
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
15
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
16
|
-
};
|
|
17
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.V4TransferBoardsController = void 0;
|
|
19
|
-
const TransferBoardFilter_1 = require("../../helpers/TransferBoardFilter");
|
|
20
|
-
const TransferBoardSorter_1 = require("../../helpers/TransferBoardSorter");
|
|
21
|
-
const OgPidToken_1 = require("../../ioc/OgPidToken");
|
|
22
|
-
const InfotextFacade_1 = require("../../service/facade/InfotextFacade");
|
|
23
|
-
const StopFacade_1 = require("../../service/facade/StopFacade");
|
|
24
|
-
const TransferFacade_1 = require("../../service/facade/TransferFacade");
|
|
25
|
-
const shared_1 = require("../../../shared");
|
|
26
|
-
const trace_provider_1 = require("@golemio/core/dist/monitoring/opentelemetry/trace-provider");
|
|
27
|
-
const moment_timezone_1 = __importDefault(require("@golemio/core/dist/shared/moment-timezone"));
|
|
28
|
-
const tsyringe_1 = require("@golemio/core/dist/shared/tsyringe");
|
|
29
|
-
const TransferDepartureCacheTransformation_1 = require("../../service/transformations/TransferDepartureCacheTransformation");
|
|
30
|
-
const DepartureCalculator_1 = require("../../../shared/DepartureCalculator");
|
|
31
|
-
const DEFAULT_TRANSFER_BOARDS_LIMIT = 8;
|
|
32
|
-
let V4TransferBoardsController = exports.V4TransferBoardsController = class V4TransferBoardsController {
|
|
33
|
-
constructor(stopFacade, infotextFacade, transferFacade, transformation) {
|
|
34
|
-
this.stopFacade = stopFacade;
|
|
35
|
-
this.infotextFacade = infotextFacade;
|
|
36
|
-
this.transferFacade = transferFacade;
|
|
37
|
-
this.transformation = transformation;
|
|
38
|
-
this.defaultTransferBoardsLimit = DEFAULT_TRANSFER_BOARDS_LIMIT;
|
|
39
|
-
this.getTransferBoardData = async (req, res, next) => {
|
|
40
|
-
const span = (0, trace_provider_1.createChildSpan)("V4TransferBoardsController.getTransferBoardData");
|
|
41
|
-
try {
|
|
42
|
-
const params = this.parseTransferBoardsParams(req.query);
|
|
43
|
-
span?.setAttributes(Object.fromEntries(Object.entries(params).filter(([_, value]) => value !== null)));
|
|
44
|
-
const now = new Date();
|
|
45
|
-
let timeFrom = null;
|
|
46
|
-
if (params.timeFrom !== null) {
|
|
47
|
-
timeFrom = moment_timezone_1.default.tz(params.timeFrom, shared_1.RopidRouterUtils.TIMEZONE).toDate();
|
|
48
|
-
}
|
|
49
|
-
//#region GTFS stops
|
|
50
|
-
let stopIds = [];
|
|
51
|
-
let transferCacheDto = undefined;
|
|
52
|
-
let infotextsToInclude = [];
|
|
53
|
-
try {
|
|
54
|
-
if ("aswId" in params && typeof params.aswId === "string") {
|
|
55
|
-
stopIds = await this.stopFacade.getStopIdsForTransferBoardsByAswId(params.aswId);
|
|
56
|
-
//#region Transfer departures and infotexts
|
|
57
|
-
if (stopIds.length === 0) {
|
|
58
|
-
return res.status(404).json({
|
|
59
|
-
departures: [],
|
|
60
|
-
infotexts: [],
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
try {
|
|
64
|
-
const [transferCache, infotexts] = await Promise.all([
|
|
65
|
-
this.transferFacade.getTransferCache(stopIds, parseInt(params.vehicleRegistrationNumber ?? "0", 10), params.routeType),
|
|
66
|
-
this.infotextFacade.getInfotextsCache(stopIds, now, timeFrom),
|
|
67
|
-
]);
|
|
68
|
-
infotextsToInclude = infotexts;
|
|
69
|
-
transferCacheDto = transferCache;
|
|
70
|
-
}
|
|
71
|
-
catch (error) {
|
|
72
|
-
span?.recordException(error);
|
|
73
|
-
throw error;
|
|
74
|
-
}
|
|
75
|
-
//#endregion
|
|
76
|
-
}
|
|
77
|
-
else if ("cisId" in params && typeof params.cisId === "number") {
|
|
78
|
-
// TODO: add support for trains
|
|
79
|
-
// stopIds = await this.stopFacade.getStopIdsForTransferBoardsByCisId(`${params.cisId!}`);
|
|
80
|
-
return res.status(501).json({ message: "EP is not ready for cisId+tripNumber yet" });
|
|
81
|
-
}
|
|
82
|
-
else {
|
|
83
|
-
return res.status(400).json({
|
|
84
|
-
message: "Either an aswId (and no cisId), or a cisId (and no aswId) must be provided",
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
catch (error) {
|
|
89
|
-
span?.recordException(error);
|
|
90
|
-
throw error;
|
|
91
|
-
}
|
|
92
|
-
//#endregion
|
|
93
|
-
// add predictedDeparture to transfers
|
|
94
|
-
transferCacheDto.transfers = transferCacheDto.transfers.map((t) => {
|
|
95
|
-
t.departure.predictedDepartureDate = DepartureCalculator_1.DepartureCalculator.getPredictedDepartureTime(new Date(t.departure.departure_datetime), t.departure.arrival_datetime ? new Date(t.departure.arrival_datetime) : null, t.position?.delay ?? null);
|
|
96
|
-
t.departure.predictedDepartureTimestamp = t.departure.predictedDepartureDate.getTime();
|
|
97
|
-
return t;
|
|
98
|
-
});
|
|
99
|
-
TransferBoardSorter_1.TransferBoardSorter.sortDepartures(transferCacheDto.transfers);
|
|
100
|
-
const transformedData = this.transformation.transformArray(transferCacheDto.transfers);
|
|
101
|
-
const flitredData = TransferBoardFilter_1.TransferBoardFilter.filterDepartures(transformedData, this.defaultTransferBoardsLimit, this.getTimeFrom(transferCacheDto.currentTrip));
|
|
102
|
-
const output = {
|
|
103
|
-
platform_code: transferCacheDto.currentTrip.stopTime?.platform_code ??
|
|
104
|
-
transferCacheDto.currentTrip.stopTime?.cis_stop_platform_code,
|
|
105
|
-
stop_name: transferCacheDto.currentTrip.stopTime?.stop_name,
|
|
106
|
-
departures: flitredData,
|
|
107
|
-
infotexts: infotextsToInclude,
|
|
108
|
-
icons: [],
|
|
109
|
-
};
|
|
110
|
-
return res.status(200).json(output);
|
|
111
|
-
}
|
|
112
|
-
catch (err) {
|
|
113
|
-
next(err);
|
|
114
|
-
}
|
|
115
|
-
finally {
|
|
116
|
-
span?.end();
|
|
117
|
-
}
|
|
118
|
-
};
|
|
119
|
-
}
|
|
120
|
-
parseTransferBoardsParams(query) {
|
|
121
|
-
return {
|
|
122
|
-
aswId: (query.aswId ?? null),
|
|
123
|
-
cisId: (query.cisId ?? null),
|
|
124
|
-
tripNumber: (query.tripNumber ?? null),
|
|
125
|
-
vehicleRegistrationNumber: (query.vehicleRegistrationNumber ?? null),
|
|
126
|
-
routeType: query.routeType,
|
|
127
|
-
timeFrom: (query.timeFrom ?? null),
|
|
128
|
-
limit: (query.limit ?? this.defaultTransferBoardsLimit),
|
|
129
|
-
};
|
|
130
|
-
}
|
|
131
|
-
getTimeFrom({ departure, position }) {
|
|
132
|
-
if (!departure?.arrival_datetime || !position) {
|
|
133
|
-
return new Date().getTime();
|
|
134
|
-
}
|
|
135
|
-
const arrivalDate = new Date(departure.arrival_datetime);
|
|
136
|
-
if (!position.delay) {
|
|
137
|
-
return arrivalDate.getTime();
|
|
138
|
-
}
|
|
139
|
-
arrivalDate.setSeconds(arrivalDate.getSeconds() + position.delay);
|
|
140
|
-
return arrivalDate.getTime();
|
|
141
|
-
}
|
|
142
|
-
};
|
|
143
|
-
exports.V4TransferBoardsController = V4TransferBoardsController = __decorate([
|
|
144
|
-
(0, tsyringe_1.injectable)(),
|
|
145
|
-
__param(0, (0, tsyringe_1.inject)(OgPidToken_1.OgPidToken.StopFacade)),
|
|
146
|
-
__param(1, (0, tsyringe_1.inject)(OgPidToken_1.OgPidToken.InfotextFacade)),
|
|
147
|
-
__param(2, (0, tsyringe_1.inject)(OgPidToken_1.OgPidToken.TransferFacade)),
|
|
148
|
-
__param(3, (0, tsyringe_1.inject)(OgPidToken_1.OgPidToken.TransferDepartureCacheTransformation)),
|
|
149
|
-
__metadata("design:paramtypes", [StopFacade_1.StopFacade,
|
|
150
|
-
InfotextFacade_1.InfotextFacade,
|
|
151
|
-
TransferFacade_1.TransferFacade,
|
|
152
|
-
TransferDepartureCacheTransformation_1.TransferDepartureCacheTransformation])
|
|
153
|
-
], V4TransferBoardsController);
|
|
154
|
-
//# sourceMappingURL=V4TransferBoardsController.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"V4TransferBoardsController.js","sourceRoot":"","sources":["../../../../../src/output-gateway/pid/controllers/v4/V4TransferBoardsController.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAEA,2EAA0E;AAC1E,2EAA0E;AAC1E,qDAAoD;AACpD,wEAAuE;AACvE,gEAA+D;AAC/D,wEAAuE;AACvE,4CAA8C;AAC9C,+FAA6F;AAE7F,gGAA+D;AAE/D,iEAAwE;AAExE,6HAA4H;AAC5H,6EAAqE;AAErE,MAAM,6BAA6B,GAAG,CAAC,CAAC;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AO,WAAW,CAAC,OAAO,EAAE,CAAC;IACjC,CAAC;CACJ,CAAA;qCAjIY,0BAA0B;IADtC,IAAA,qBAAU,GAAE;IAKJ,WAAA,IAAA,iBAAM,EAAC,uBAAU,CAAC,UAAU,CAAC,CAAA;IAC7B,WAAA,IAAA,iBAAM,EAAC,uBAAU,CAAC,cAAc,CAAC,CAAA;IACjC,WAAA,IAAA,iBAAM,EAAC,uBAAU,CAAC,cAAc,CAAC,CAAA;IACjC,WAAA,IAAA,iBAAM,EAAC,uBAAU,CAAC,oCAAoC,CAAC,CAAA;qCAHL,uBAAU;QACF,+BAAc;QACd,+BAAc;QACQ,2EAAoC;GAPhH,0BAA0B,CAiItC"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export interface ITransferBoardsBasic {
|
|
2
|
-
timeFrom: string | null;
|
|
3
|
-
limit: number;
|
|
4
|
-
}
|
|
5
|
-
export interface ITransferBoardsAswIdBased extends ITransferBoardsBasic {
|
|
6
|
-
aswId: string | null;
|
|
7
|
-
vehicleRegistrationNumber: string | null;
|
|
8
|
-
routeType: number;
|
|
9
|
-
}
|
|
10
|
-
export interface ITransferBoardsCisIdBased extends ITransferBoardsBasic {
|
|
11
|
-
cisId: number | null;
|
|
12
|
-
tripNumber: number | null;
|
|
13
|
-
}
|
|
14
|
-
export type ITransferBoardsParams = ITransferBoardsAswIdBased | ITransferBoardsCisIdBased;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ITransferBoardsParams.js","sourceRoot":"","sources":["../../../../../../src/output-gateway/pid/controllers/v4/interfaces/ITransferBoardsParams.ts"],"names":[],"mappings":""}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TransferBoardFilter = void 0;
|
|
4
|
-
class TransferBoardFilter {
|
|
5
|
-
static filterDepartures(transfers, limit, timeFrom) {
|
|
6
|
-
const filteredDepartures = [];
|
|
7
|
-
for (const transfer of transfers) {
|
|
8
|
-
if (filteredDepartures.length === limit) {
|
|
9
|
-
break;
|
|
10
|
-
}
|
|
11
|
-
if (!this.isInRange(transfer, timeFrom)) {
|
|
12
|
-
continue;
|
|
13
|
-
}
|
|
14
|
-
filteredDepartures.push(transfer);
|
|
15
|
-
}
|
|
16
|
-
// Departures are already sorted so that metro ones are first
|
|
17
|
-
return filteredDepartures;
|
|
18
|
-
}
|
|
19
|
-
static isInRange(departure, timeFrom) {
|
|
20
|
-
const timeRangeStart = timeFrom;
|
|
21
|
-
// add one hour
|
|
22
|
-
const timeRangeEnd = timeFrom + 60 * 60 * 1000;
|
|
23
|
-
const departureMinutes = departure.departure_timestamp.minutes[0] === "<1" ? 1 : Number(departure.departure_timestamp.minutes[0]);
|
|
24
|
-
if (isNaN(departureMinutes))
|
|
25
|
-
return false;
|
|
26
|
-
// Calculate the departure time
|
|
27
|
-
const departureTime = timeRangeStart + departureMinutes * 60 * 1000;
|
|
28
|
-
// Check if departureTime is within the range
|
|
29
|
-
return departureTime >= timeRangeStart && departureTime <= timeRangeEnd;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
exports.TransferBoardFilter = TransferBoardFilter;
|
|
33
|
-
//# sourceMappingURL=TransferBoardFilter.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"TransferBoardFilter.js","sourceRoot":"","sources":["../../../../src/output-gateway/pid/helpers/TransferBoardFilter.ts"],"names":[],"mappings":";;;AAEA,MAAa,mBAAmB;IACrB,MAAM,CAAC,gBAAgB,CAC1B,SAA0C,EAC1C,KAAa,EACb,QAAgB;QAEhB,MAAM,kBAAkB,GAAoC,EAAE,CAAC;QAE/D,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE;YAC9B,IAAI,kBAAkB,CAAC,MAAM,KAAK,KAAK,EAAE;gBACrC,MAAM;aACT;YACD,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,QAAQ,CAAC,EAAE;gBACrC,SAAS;aACZ;YACD,kBAAkB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;SACrC;QAED,6DAA6D;QAC7D,OAAO,kBAAkB,CAAC;IAC9B,CAAC;IACO,MAAM,CAAC,SAAS,CAAC,SAAwC,EAAE,QAAgB;QAC/E,MAAM,cAAc,GAAG,QAAQ,CAAC;QAChC,eAAe;QACf,MAAM,YAAY,GAAG,QAAQ,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;QAE/C,MAAM,gBAAgB,GAClB,SAAS,CAAC,mBAAmB,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,mBAAmB,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;QAC7G,IAAI,KAAK,CAAC,gBAAgB,CAAC;YAAE,OAAO,KAAK,CAAC;QAE1C,+BAA+B;QAC/B,MAAM,aAAa,GAAG,cAAc,GAAG,gBAAgB,GAAG,EAAE,GAAG,IAAI,CAAC;QAEpE,6CAA6C;QAC7C,OAAO,aAAa,IAAI,cAAc,IAAI,aAAa,IAAI,YAAY,CAAC;IAC5E,CAAC;CACJ;AApCD,kDAoCC"}
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var _a;
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.TransferBoardSorter = void 0;
|
|
5
|
-
const RouteTypeEnums_1 = require("../../../helpers/RouteTypeEnums");
|
|
6
|
-
class TransferBoardSorter {
|
|
7
|
-
static sortDepartures(departures) {
|
|
8
|
-
departures.sort((a, b) => {
|
|
9
|
-
for (const compareFn of this.compareFnPipeline) {
|
|
10
|
-
const res = compareFn(a, b);
|
|
11
|
-
if (res !== 0)
|
|
12
|
-
return res;
|
|
13
|
-
}
|
|
14
|
-
return 0;
|
|
15
|
-
});
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
exports.TransferBoardSorter = TransferBoardSorter;
|
|
19
|
-
_a = TransferBoardSorter;
|
|
20
|
-
TransferBoardSorter.compareFns = {
|
|
21
|
-
metroFirst: (a, b) => {
|
|
22
|
-
const aIsMetro = a.departure.route_type === RouteTypeEnums_1.GTFSRouteTypeEnum.METRO;
|
|
23
|
-
const bIsMetro = b.departure.route_type === RouteTypeEnums_1.GTFSRouteTypeEnum.METRO;
|
|
24
|
-
if (aIsMetro !== bIsMetro)
|
|
25
|
-
return aIsMetro ? -1 : 1;
|
|
26
|
-
return 0;
|
|
27
|
-
},
|
|
28
|
-
metroNameAsc: (a, b) => {
|
|
29
|
-
const aIsMetro = a.departure.route_type === RouteTypeEnums_1.GTFSRouteTypeEnum.METRO;
|
|
30
|
-
const bIsMetro = b.departure.route_type === RouteTypeEnums_1.GTFSRouteTypeEnum.METRO;
|
|
31
|
-
if (aIsMetro && bIsMetro && a.departure.route_short_name !== null && b.departure.route_short_name !== null)
|
|
32
|
-
return a.departure.route_short_name.localeCompare(b.departure.route_short_name);
|
|
33
|
-
return 0;
|
|
34
|
-
},
|
|
35
|
-
departureTimeAsc: (a, b) => {
|
|
36
|
-
const aTimestamp = a.departure.predictedDepartureTimestamp;
|
|
37
|
-
const bTimestamp = b.departure.predictedDepartureTimestamp;
|
|
38
|
-
if (aTimestamp && bTimestamp) {
|
|
39
|
-
return aTimestamp - bTimestamp;
|
|
40
|
-
}
|
|
41
|
-
if (!aTimestamp && !bTimestamp)
|
|
42
|
-
return 0;
|
|
43
|
-
if (!bTimestamp)
|
|
44
|
-
return -1;
|
|
45
|
-
return 1;
|
|
46
|
-
},
|
|
47
|
-
directionIdAsc: (a, b) => {
|
|
48
|
-
const aDirectionId = a.position?.detailed_info.direction_id;
|
|
49
|
-
const bDirectionId = b.position?.detailed_info.direction_id;
|
|
50
|
-
if (aDirectionId !== bDirectionId)
|
|
51
|
-
return aDirectionId ? -1 : 1;
|
|
52
|
-
return 0;
|
|
53
|
-
},
|
|
54
|
-
};
|
|
55
|
-
TransferBoardSorter.compareFnPipeline = [
|
|
56
|
-
_a.compareFns.metroFirst,
|
|
57
|
-
_a.compareFns.metroNameAsc,
|
|
58
|
-
_a.compareFns.departureTimeAsc,
|
|
59
|
-
_a.compareFns.directionIdAsc,
|
|
60
|
-
];
|
|
61
|
-
//# sourceMappingURL=TransferBoardSorter.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"TransferBoardSorter.js","sourceRoot":"","sources":["../../../../src/output-gateway/pid/helpers/TransferBoardSorter.ts"],"names":[],"mappings":";;;;AAAA,oEAA4D;AAG5D,MAAa,mBAAmB;IACrB,MAAM,CAAC,cAAc,CAAC,UAAoC;QAC7D,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;YACrB,KAAK,MAAM,SAAS,IAAI,IAAI,CAAC,iBAAiB,EAAE;gBAC5C,MAAM,GAAG,GAAG,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;gBAC5B,IAAI,GAAG,KAAK,CAAC;oBAAE,OAAO,GAAG,CAAC;aAC7B;YACD,OAAO,CAAC,CAAC;QACb,CAAC,CAAC,CAAC;IACP,CAAC;;AATL,kDAiDC;;AAtC2B,8BAAU,GAAqF;IACnH,UAAU,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;QACjB,MAAM,QAAQ,GAAG,CAAC,CAAC,SAAS,CAAC,UAAU,KAAK,kCAAiB,CAAC,KAAK,CAAC;QACpE,MAAM,QAAQ,GAAG,CAAC,CAAC,SAAS,CAAC,UAAU,KAAK,kCAAiB,CAAC,KAAK,CAAC;QACpE,IAAI,QAAQ,KAAK,QAAQ;YAAE,OAAO,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACpD,OAAO,CAAC,CAAC;IACb,CAAC;IACD,YAAY,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,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C,CA8BhC;AAEsB,qCAAiB,GAAG;IACxC,EAAI,CAAC,UAAU,CAAC,UAAU;IAC1B,EAAI,CAAC,UAAU,CAAC,YAAY;IAC5B,EAAI,CAAC,UAAU,CAAC,gBAAgB;IAChC,EAAI,CAAC,UAAU,CAAC,cAAc;CACjC,AALwC,CAKvC"}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/// <reference types="express" />
|
|
2
|
-
import { AbstractRouter } from "@golemio/core/dist/helpers/routing/AbstractRouter";
|
|
3
|
-
import { Router } from "@golemio/core/dist/shared/express";
|
|
4
|
-
export declare class V4PIDRouter extends AbstractRouter {
|
|
5
|
-
readonly router: Router;
|
|
6
|
-
private readonly cacheHeaderMiddleware;
|
|
7
|
-
private readonly transferBoardsController;
|
|
8
|
-
private readonly GtfsStopsSubscriber;
|
|
9
|
-
private readonly VPSubscriber;
|
|
10
|
-
private readonly JisInotextsSubscriber;
|
|
11
|
-
constructor();
|
|
12
|
-
protected initRoutes: () => void;
|
|
13
|
-
private registerTransferBoardsRoutes;
|
|
14
|
-
}
|
|
15
|
-
declare const v4PidRouter: AbstractRouter;
|
|
16
|
-
export { v4PidRouter };
|