@golemio/pid 6.4.0 → 6.4.1-dev.3054859807
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/db/example/00_clear_test_data.sql +1 -0
- package/db/example/24_jis_delayed_segments.sql +142 -0
- package/db/migrations/postgresql/20261027100000-jis-delayed-segments.js +16 -0
- package/db/migrations/postgresql/sqls/20250127134438-departure-additional-indexes-down.sql +20 -2
- package/db/migrations/postgresql/sqls/20261027100000-jis-delayed-segments-down.sql +17 -0
- package/db/migrations/postgresql/sqls/20261027100000-jis-delayed-segments-up.sql +42 -0
- package/dist/integration-engine/jis/datasources/JISDelayedSegmentsDataSourceFactory.d.ts +9 -0
- package/dist/integration-engine/jis/datasources/JISDelayedSegmentsDataSourceFactory.js +54 -0
- package/dist/integration-engine/jis/datasources/JISDelayedSegmentsDataSourceFactory.js.map +1 -0
- package/dist/integration-engine/jis/ioc/Di.js +10 -0
- package/dist/integration-engine/jis/ioc/Di.js.map +1 -1
- package/dist/integration-engine/jis/ioc/JISContainerToken.d.ts +5 -0
- package/dist/integration-engine/jis/ioc/JISContainerToken.js +5 -0
- package/dist/integration-engine/jis/ioc/JISContainerToken.js.map +1 -1
- package/dist/integration-engine/jis/repositories/JISDelayedSegmentEnrichmentRepository.d.ts +14 -0
- package/dist/integration-engine/jis/repositories/JISDelayedSegmentEnrichmentRepository.js +69 -0
- package/dist/integration-engine/jis/repositories/JISDelayedSegmentEnrichmentRepository.js.map +1 -0
- package/dist/integration-engine/jis/repositories/JISDelayedSegmentsRepository.d.ts +23 -0
- package/dist/integration-engine/jis/repositories/JISDelayedSegmentsRepository.js +73 -0
- package/dist/integration-engine/jis/repositories/JISDelayedSegmentsRepository.js.map +1 -0
- package/dist/integration-engine/jis/repositories/helpers/JISDelayedSegmentEnrichmentQuery.d.ts +13 -0
- package/dist/integration-engine/jis/repositories/helpers/JISDelayedSegmentEnrichmentQuery.js +266 -0
- package/dist/integration-engine/jis/repositories/helpers/JISDelayedSegmentEnrichmentQuery.js.map +1 -0
- package/dist/integration-engine/jis/repositories/interfaces/IJISDelayedSegmentEnrichmentParams.d.ts +23 -0
- package/dist/integration-engine/jis/repositories/interfaces/IJISDelayedSegmentEnrichmentParams.js +2 -0
- package/dist/integration-engine/jis/repositories/interfaces/IJISDelayedSegmentEnrichmentParams.js.map +1 -0
- package/dist/integration-engine/jis/services/JISDelayedSegmentsDataService.d.ts +38 -0
- package/dist/integration-engine/jis/services/JISDelayedSegmentsDataService.js +174 -0
- package/dist/integration-engine/jis/services/JISDelayedSegmentsDataService.js.map +1 -0
- package/dist/integration-engine/jis/workers/JISWorker.js +1 -0
- package/dist/integration-engine/jis/workers/JISWorker.js.map +1 -1
- package/dist/integration-engine/jis/workers/tasks/RefreshDelayedSegmentsTask.d.ts +15 -0
- package/dist/integration-engine/jis/workers/tasks/RefreshDelayedSegmentsTask.js +55 -0
- package/dist/integration-engine/jis/workers/tasks/RefreshDelayedSegmentsTask.js.map +1 -0
- package/dist/integration-engine/vehicle-positions/workers/runs/helpers/TramMessageFilter.d.ts +2 -0
- package/dist/integration-engine/vehicle-positions/workers/runs/helpers/TramMessageFilter.js +16 -0
- package/dist/integration-engine/vehicle-positions/workers/runs/helpers/TramMessageFilter.js.map +1 -1
- package/dist/output-gateway/jis/controllers/v1/V1DelayedSegmentsController.d.ts +9 -0
- package/dist/output-gateway/jis/controllers/v1/V1DelayedSegmentsController.js +54 -0
- package/dist/output-gateway/jis/controllers/v1/V1DelayedSegmentsController.js.map +1 -0
- package/dist/output-gateway/jis/data-access/JISDelayedSegmentsRepository.d.ts +14 -0
- package/dist/output-gateway/jis/data-access/JISDelayedSegmentsRepository.js +56 -0
- package/dist/output-gateway/jis/data-access/JISDelayedSegmentsRepository.js.map +1 -0
- package/dist/output-gateway/jis/domain/IJISDelayedSegmentDto.d.ts +12 -0
- package/dist/output-gateway/jis/domain/IJISDelayedSegmentDto.js +2 -0
- package/dist/output-gateway/jis/domain/IJISDelayedSegmentDto.js.map +1 -0
- package/dist/output-gateway/jis/dto/interfaces/IDelayedSegmentsQueryDto.d.ts +5 -0
- package/dist/output-gateway/jis/dto/interfaces/IDelayedSegmentsQueryDto.js +2 -0
- package/dist/output-gateway/jis/dto/interfaces/IDelayedSegmentsQueryDto.js.map +1 -0
- package/dist/output-gateway/jis/helpers/JISDelayedSegmentInfoPanelStopsFilter.d.ts +8 -0
- package/dist/output-gateway/jis/helpers/JISDelayedSegmentInfoPanelStopsFilter.js +13 -0
- package/dist/output-gateway/jis/helpers/JISDelayedSegmentInfoPanelStopsFilter.js.map +1 -0
- package/dist/output-gateway/jis/ioc/Di.js +6 -0
- package/dist/output-gateway/jis/ioc/Di.js.map +1 -1
- package/dist/output-gateway/jis/ioc/OgJisToken.d.ts +3 -0
- package/dist/output-gateway/jis/ioc/OgJisToken.js +3 -0
- package/dist/output-gateway/jis/ioc/OgJisToken.js.map +1 -1
- package/dist/output-gateway/jis/routers/v1/V1JISRouter.d.ts +2 -0
- package/dist/output-gateway/jis/routers/v1/V1JISRouter.js +9 -0
- package/dist/output-gateway/jis/routers/v1/V1JISRouter.js.map +1 -1
- package/dist/output-gateway/jis/transformations/JISDelayedSegmentsTransformation.d.ts +7 -0
- package/dist/output-gateway/jis/transformations/JISDelayedSegmentsTransformation.js +32 -0
- package/dist/output-gateway/jis/transformations/JISDelayedSegmentsTransformation.js.map +1 -0
- package/dist/schema-definitions/jis/datasources/MapaPidDelayShapesJsonSchema.d.ts +3 -0
- package/dist/schema-definitions/jis/datasources/MapaPidDelayShapesJsonSchema.js +16 -0
- package/dist/schema-definitions/jis/datasources/MapaPidDelayShapesJsonSchema.js.map +1 -0
- package/dist/schema-definitions/jis/datasources/interfaces/IMapaPidDelayShape.d.ts +10 -0
- package/dist/schema-definitions/jis/datasources/interfaces/IMapaPidDelayShape.js +2 -0
- package/dist/schema-definitions/jis/datasources/interfaces/IMapaPidDelayShape.js.map +1 -0
- package/dist/schema-definitions/jis/datasources/interfaces/index.d.ts +1 -0
- package/dist/schema-definitions/jis/datasources/interfaces/index.js +1 -0
- package/dist/schema-definitions/jis/datasources/interfaces/index.js.map +1 -1
- package/dist/schema-definitions/jis/models/JISDelayedSegmentsModel.d.ts +24 -0
- package/dist/schema-definitions/jis/models/JISDelayedSegmentsModel.js +138 -0
- package/dist/schema-definitions/jis/models/JISDelayedSegmentsModel.js.map +1 -0
- package/dist/schema-definitions/jis/models/interfaces/IJISDelayedSegment.d.ts +44 -0
- package/dist/schema-definitions/jis/models/interfaces/IJISDelayedSegment.js +2 -0
- package/dist/schema-definitions/jis/models/interfaces/IJISDelayedSegment.js.map +1 -0
- package/dist/schema-definitions/jis/models/interfaces/index.d.ts +1 -0
- package/dist/schema-definitions/jis/models/interfaces/index.js +1 -0
- package/dist/schema-definitions/jis/models/interfaces/index.js.map +1 -1
- package/docs/assets/pid_jis_erd.png +0 -0
- package/docs/asyncapi.yaml +15 -0
- package/docs/implementation_documentation.md +56 -0
- package/docs/index.md +1 -0
- package/docs/jis/delayed-segments.md +241 -0
- package/docs/jis/index.md +9 -0
- package/docs/openapi-output.yaml +176 -0
- package/package.json +2 -2
|
@@ -17,6 +17,7 @@ export class JISWorker extends AbstractWorker {
|
|
|
17
17
|
this.registerTask(JISContainer.resolve(JISContainerToken.RefreshJISInfotextsTask));
|
|
18
18
|
this.registerTask(JISContainer.resolve(JISContainerToken.RefreshJISInfotextsCacheTask));
|
|
19
19
|
this.registerTask(JISContainer.resolve(JISContainerToken.UpdateEventWebhookTask));
|
|
20
|
+
this.registerTask(JISContainer.resolve(JISContainerToken.RefreshDelayedSegmentsTask));
|
|
20
21
|
}
|
|
21
22
|
}
|
|
22
23
|
//# sourceMappingURL=JISWorker.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"JISWorker.js","sourceRoot":"","sources":["../../../../src/integration-engine/jis/workers/JISWorker.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,wDAAwD,CAAC;AA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AC;QACtH,IAAI,CAAC,YAAY,CAAC,YAAY,CAAC,OAAO,CAAyB,iBAAiB,CAAC,sBAAsB,CAAC,CAAC,CAAC;QAC1G,IAAI,CAAC,YAAY,CAAC,YAAY,CAAC,OAAO,CAA6B,iBAAiB,CAAC,0BAA0B,CAAC,CAAC,CAAC;IACtH,CAAC;CAMJ"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { JISDelayedSegmentsDataSourceFactory } from "#ie/jis/datasources/JISDelayedSegmentsDataSourceFactory";
|
|
2
|
+
import { JISDelayedSegmentsDataService } from "#ie/jis/services/JISDelayedSegmentsDataService";
|
|
3
|
+
import { AbstractEmptyTask } from "@golemio/core/dist/integration-engine/index.js";
|
|
4
|
+
/**
|
|
5
|
+
* Fetches delayed segments detected by Mapa PID and replaces the stored ones with them, enriched with GTFS data.
|
|
6
|
+
* On failure, stored segments are kept untouched and expire for consumers by their last detection time.
|
|
7
|
+
*/
|
|
8
|
+
export declare class RefreshDelayedSegmentsTask extends AbstractEmptyTask {
|
|
9
|
+
private dataSourceFactory;
|
|
10
|
+
private dataService;
|
|
11
|
+
readonly queueName = "refreshDelayedSegments";
|
|
12
|
+
readonly queueTtl: number;
|
|
13
|
+
constructor(dataSourceFactory: JISDelayedSegmentsDataSourceFactory, dataService: JISDelayedSegmentsDataService);
|
|
14
|
+
protected execute(): Promise<void>;
|
|
15
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
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;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
11
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
12
|
+
};
|
|
13
|
+
import { JISDelayedSegmentsDataSourceFactory } from "#ie/jis/datasources/JISDelayedSegmentsDataSourceFactory";
|
|
14
|
+
import { JISContainerToken } from "#ie/jis/ioc/JISContainerToken";
|
|
15
|
+
import { JISDelayedSegmentsDataService } from "#ie/jis/services/JISDelayedSegmentsDataService";
|
|
16
|
+
import { AbstractEmptyTask } from "@golemio/core/dist/integration-engine/index.js";
|
|
17
|
+
import GolemioErrorsCore from "@golemio/core/dist/shared/golemio-errors.js";
|
|
18
|
+
const { AbstractGolemioError, GeneralError } = GolemioErrorsCore;
|
|
19
|
+
import { inject, injectable } from "@golemio/core/dist/shared/tsyringe.js";
|
|
20
|
+
import { JIS_WORKER_NAME } from "../constants.js";
|
|
21
|
+
/**
|
|
22
|
+
* Fetches delayed segments detected by Mapa PID and replaces the stored ones with them, enriched with GTFS data.
|
|
23
|
+
* On failure, stored segments are kept untouched and expire for consumers by their last detection time.
|
|
24
|
+
*/
|
|
25
|
+
let RefreshDelayedSegmentsTask = class RefreshDelayedSegmentsTask extends AbstractEmptyTask {
|
|
26
|
+
constructor(dataSourceFactory, dataService) {
|
|
27
|
+
super(JIS_WORKER_NAME.toLowerCase());
|
|
28
|
+
this.dataSourceFactory = dataSourceFactory;
|
|
29
|
+
this.dataService = dataService;
|
|
30
|
+
this.queueName = "refreshDelayedSegments";
|
|
31
|
+
this.queueTtl = 4 * 60 * 1000;
|
|
32
|
+
}
|
|
33
|
+
async execute() {
|
|
34
|
+
try {
|
|
35
|
+
const detectedAt = new Date();
|
|
36
|
+
const delayShapes = await this.dataSourceFactory.getDataSource().getAll();
|
|
37
|
+
await this.dataService.refreshDelayedSegments(delayShapes, detectedAt);
|
|
38
|
+
}
|
|
39
|
+
catch (err) {
|
|
40
|
+
if (err instanceof AbstractGolemioError) {
|
|
41
|
+
throw err;
|
|
42
|
+
}
|
|
43
|
+
throw new GeneralError("Error while refreshing delayed segments", this.constructor.name, err);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
RefreshDelayedSegmentsTask = __decorate([
|
|
48
|
+
injectable(),
|
|
49
|
+
__param(0, inject(JISContainerToken.JISDelayedSegmentsDataSourceFactory)),
|
|
50
|
+
__param(1, inject(JISContainerToken.JISDelayedSegmentsDataService)),
|
|
51
|
+
__metadata("design:paramtypes", [JISDelayedSegmentsDataSourceFactory,
|
|
52
|
+
JISDelayedSegmentsDataService])
|
|
53
|
+
], RefreshDelayedSegmentsTask);
|
|
54
|
+
export { RefreshDelayedSegmentsTask };
|
|
55
|
+
//# sourceMappingURL=RefreshDelayedSegmentsTask.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RefreshDelayedSegmentsTask.js","sourceRoot":"","sources":["../../../../../src/integration-engine/jis/workers/tasks/RefreshDelayedSegmentsTask.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,mCAAmC,EAAE,MAAM,yDAAyD,CAAC;AAC9G,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAClE,OAAO,EAAE,6BAA6B,EAAE,MAAM,gDAAgD,CAAC;AAC/F,OAAO,EAAE,iBAAiB,EAAE,MAAM,gDAAgD,CAAC;AACnF,OAAO,iBAAiB,MAAM,6CAA6C,CAAC;AAC5E,MAAM,EAAE,oBAAoB,EAAE,YAAY,EAAE,GAAG,iBAAiB,CAAC;AACjE,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,uCAAuC,CAAC;AAC3E,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAElD;;;GAGG;AAEI,IAAM,0BAA0B,GAAhC,MAAM,0BAA2B,SAAQ,iBAAiB;IAI7D,YAEI,iBAA8D,EAE9D,WAAkD;QAElD,KAAK,CAAC,eAAe,CAAC,WAAW,EAAE,CAAC,CAAC;QAJ7B,sBAAiB,GAAjB,iBAAiB,CAAqC;QAEtD,gBAAW,GAAX,WAAW,CAA+B;QAPtC,cAAS,GAAG,wBAAwB,CAAC;QACrC,aAAQ,GAAG,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC;IASzC,CAAC;IAES,KAAK,CAAC,OAAO;QACnB,IAAI,CAAC;YACD,MAAM,UAAU,GAAG,IAAI,IAAI,EAAE,CAAC;YAC9B,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,iBAAiB,CAAC,aAAa,EAAE,CAAC,MAAM,EAAE,CAAC;YAC1E,MAAM,IAAI,CAAC,WAAW,CAAC,sBAAsB,CAAC,WAAW,EAAE,UAAU,CAAC,CAAC;QAC3E,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACX,IAAI,GAAG,YAAY,oBAAoB,EAAE,CAAC;gBACtC,MAAM,GAAG,CAAC;YACd,CAAC;YACD,MAAM,IAAI,YAAY,CAAC,yCAAyC,EAAE,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;QAClG,CAAC;IACL,CAAC;CACJ,CAAA;AAzBY,0BAA0B;IADtC,UAAU,EAAE;IAMJ,WAAA,MAAM,CAAC,iBAAiB,CAAC,mCAAmC,CAAC,CAAA;IAE7D,WAAA,MAAM,CAAC,iBAAiB,CAAC,6BAA6B,CAAC,CAAA;qCAD7B,mCAAmC;QAEzC,6BAA6B;GAR7C,0BAA0B,CAyBtC"}
|
package/dist/integration-engine/vehicle-positions/workers/runs/helpers/TramMessageFilter.d.ts
CHANGED
|
@@ -14,10 +14,12 @@ export declare class TramMessageFilter implements ICommonMessageFilter {
|
|
|
14
14
|
* - run number is less than 80
|
|
15
15
|
* - OR registration number is in not-public vehicles whitelist (e.g., mazačka maintenance trams)
|
|
16
16
|
* - timestamp is in acceptable range
|
|
17
|
+
* - scheduled timestamp 'tjr' is not more than 120 minutes ahead of 'tm' (negative delay over 120 minutes)
|
|
17
18
|
*
|
|
18
19
|
* Sets isNotPublic flag on messages to avoid duplicate whitelist checks in processor
|
|
19
20
|
*/
|
|
20
21
|
yieldFilteredMessages(messages: ICommonRunWithMessageDto[], timestamp: number): AsyncGenerator<ICommonRunWithMessageDto>;
|
|
22
|
+
private isNegativeDelayExceeded;
|
|
21
23
|
private isRouteIdValid;
|
|
22
24
|
private isRunNumberValid;
|
|
23
25
|
}
|
|
@@ -20,6 +20,7 @@ const { GeneralError } = GolemioErrorsCore;
|
|
|
20
20
|
const TRAM_SERVICING_ROUTE_ID_MIN = 50;
|
|
21
21
|
const TRAM_SERVICING_ROUTE_ID_MAX = 89;
|
|
22
22
|
const TRAM_UNUSUAL_RUN_NUMBER_MIN = 80;
|
|
23
|
+
const MAX_NEGATIVE_DELAY_IN_MS = 120 * 60 * 1000;
|
|
23
24
|
let TramMessageFilter = class TramMessageFilter {
|
|
24
25
|
constructor(logger, timestampValidator, notPublicVehiclesRepository) {
|
|
25
26
|
this.logger = logger;
|
|
@@ -32,6 +33,7 @@ let TramMessageFilter = class TramMessageFilter {
|
|
|
32
33
|
* - run number is less than 80
|
|
33
34
|
* - OR registration number is in not-public vehicles whitelist (e.g., mazačka maintenance trams)
|
|
34
35
|
* - timestamp is in acceptable range
|
|
36
|
+
* - scheduled timestamp 'tjr' is not more than 120 minutes ahead of 'tm' (negative delay over 120 minutes)
|
|
35
37
|
*
|
|
36
38
|
* Sets isNotPublic flag on messages to avoid duplicate whitelist checks in processor
|
|
37
39
|
*/
|
|
@@ -48,6 +50,13 @@ let TramMessageFilter = class TramMessageFilter {
|
|
|
48
50
|
` is not valid for line ${message.run.line_short_name}, run ${message.run.run_number}`, this.constructor.name, undefined, undefined, "pid"));
|
|
49
51
|
continue;
|
|
50
52
|
}
|
|
53
|
+
if (this.isNegativeDelayExceeded(message)) {
|
|
54
|
+
this.logger.warn(`${this.constructor.name}: message timestamp 'tjr' of value` +
|
|
55
|
+
` '${message.run_message.actual_stop_timestamp_scheduled?.toISOString()}' is more than 120 minutes` +
|
|
56
|
+
` ahead of 'tm' of value '${message.run_message.actual_stop_timestamp_real.toISOString()}'` +
|
|
57
|
+
` (line ${line_short_name}, run ${run_number}, vehicle ${registration_number}), message is skipped.`);
|
|
58
|
+
continue;
|
|
59
|
+
}
|
|
51
60
|
// Check if this is a not-public vehicle
|
|
52
61
|
// - Whitelisted registration number (e.g., mazačka maintenance tram)
|
|
53
62
|
// - Whitelisted route name (e.g., ad-hoc routes like X1, X2, NAD)
|
|
@@ -67,6 +76,13 @@ let TramMessageFilter = class TramMessageFilter {
|
|
|
67
76
|
}
|
|
68
77
|
}
|
|
69
78
|
}
|
|
79
|
+
isNegativeDelayExceeded(message) {
|
|
80
|
+
const { actual_stop_timestamp_scheduled: scheduledTimestamp, actual_stop_timestamp_real: realTimestamp } = message.run_message;
|
|
81
|
+
if (!scheduledTimestamp) {
|
|
82
|
+
return false;
|
|
83
|
+
}
|
|
84
|
+
return scheduledTimestamp.getTime() - realTimestamp.getTime() > MAX_NEGATIVE_DELAY_IN_MS;
|
|
85
|
+
}
|
|
70
86
|
isRouteIdValid(routeId) {
|
|
71
87
|
const parsedRouteId = Number.parseInt(routeId);
|
|
72
88
|
return (!Number.isNaN(parsedRouteId) &&
|
package/dist/integration-engine/vehicle-positions/workers/runs/helpers/TramMessageFilter.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TramMessageFilter.js","sourceRoot":"","sources":["../../../../../../src/integration-engine/vehicle-positions/workers/runs/helpers/TramMessageFilter.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,OAAO,EAAE,gCAAgC,EAAE,MAAM,mEAAmE,CAAC;AACrH,OAAO,EAAE,SAAS,EAAE,MAAM,6CAA6C,CAAC;AAExE,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,uCAAuC,CAAC;AAE3E,OAAO,EAAE,gBAAgB,EAAE,MAAM,4CAA4C,CAAC;AAC9E,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,iBAAiB,MAAM,6CAA6C,CAAC;AAC5E,MAAM,EAAE,YAAY,EAAE,GAAG,iBAAiB,CAAC;AAE3C,MAAM,2BAA2B,GAAG,EAAE,CAAC;AACvC,MAAM,2BAA2B,GAAG,EAAE,CAAC;AACvC,MAAM,2BAA2B,GAAG,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"TramMessageFilter.js","sourceRoot":"","sources":["../../../../../../src/integration-engine/vehicle-positions/workers/runs/helpers/TramMessageFilter.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,OAAO,EAAE,gCAAgC,EAAE,MAAM,mEAAmE,CAAC;AACrH,OAAO,EAAE,SAAS,EAAE,MAAM,6CAA6C,CAAC;AAExE,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,uCAAuC,CAAC;AAE3E,OAAO,EAAE,gBAAgB,EAAE,MAAM,4CAA4C,CAAC;AAC9E,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,iBAAiB,MAAM,6CAA6C,CAAC;AAC5E,MAAM,EAAE,YAAY,EAAE,GAAG,iBAAiB,CAAC;AAE3C,MAAM,2BAA2B,GAAG,EAAE,CAAC;AACvC,MAAM,2BAA2B,GAAG,EAAE,CAAC;AACvC,MAAM,2BAA2B,GAAG,EAAE,CAAC;AACvC,MAAM,wBAAwB,GAAG,GAAG,GAAG,EAAE,GAAG,IAAI,CAAC;AAG1C,IAAM,iBAAiB,GAAvB,MAAM,iBAAiB;IAC1B,YACsC,MAAe,EACI,kBAAsC,EAEnF,2BAA6D;QAHnC,WAAM,GAAN,MAAM,CAAS;QACI,uBAAkB,GAAlB,kBAAkB,CAAoB;QAEnF,gCAA2B,GAA3B,2B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,CAAC,OAAe;QAClC,MAAM,aAAa,GAAG,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;QAC/C,OAAO,CACH,CAAC,MAAM,CAAC,KAAK,CAAC,aAAa,CAAC;YAC5B,CAAC,aAAa,GAAG,2BAA2B,IAAI,aAAa,GAAG,2BAA2B,CAAC,CAC/F,CAAC;IACN,CAAC;IAEO,gBAAgB,CAAC,SAAiB;QACtC,OAAO,SAAS,GAAG,2BAA2B,CAAC;IACnD,CAAC;CACJ,CAAA;AAnGY,iBAAiB;IAD7B,UAAU,EAAE;IAGJ,WAAA,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,CAAA;IACxB,WAAA,MAAM,CAAC,gBAAgB,CAAC,kBAAkB,CAAC,CAAA;IAC3C,WAAA,MAAM,CAAC,gBAAgB,CAAC,gCAAgC,CAAC,CAAA;6CADe,kBAAkB;QAEtD,gCAAgC;GALhE,iBAAiB,CAmG7B"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { JISDelayedSegmentsTransformation } from "#og/jis/transformations/JISDelayedSegmentsTransformation";
|
|
2
|
+
import type { RequestHandler } from "@golemio/core/dist/shared/express.js";
|
|
3
|
+
import { JISDelayedSegmentsRepository } from "../../data-access/JISDelayedSegmentsRepository.js";
|
|
4
|
+
export declare class V1DelayedSegmentsController {
|
|
5
|
+
private delayedSegmentsRepository;
|
|
6
|
+
private delayedSegmentsTransformation;
|
|
7
|
+
constructor(delayedSegmentsRepository: JISDelayedSegmentsRepository, delayedSegmentsTransformation: JISDelayedSegmentsTransformation);
|
|
8
|
+
getAllDelayedSegments: RequestHandler;
|
|
9
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
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;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
11
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
12
|
+
};
|
|
13
|
+
import { JISDelayedSegmentInfoPanelStopsFilter } from "#og/jis/helpers/JISDelayedSegmentInfoPanelStopsFilter";
|
|
14
|
+
import { OgJisToken } from "#og/jis/ioc/OgJisToken";
|
|
15
|
+
import { JISDelayedSegmentsTransformation } from "#og/jis/transformations/JISDelayedSegmentsTransformation";
|
|
16
|
+
import { createChildSpan } from "@golemio/core/dist/monitoring/index.js";
|
|
17
|
+
import ExpressValidatorCore from "@golemio/core/dist/shared/express-validator.js";
|
|
18
|
+
const { matchedData } = ExpressValidatorCore;
|
|
19
|
+
import { inject, injectable } from "@golemio/core/dist/shared/tsyringe.js";
|
|
20
|
+
import { JISDelayedSegmentsRepository } from "../../data-access/JISDelayedSegmentsRepository.js";
|
|
21
|
+
let V1DelayedSegmentsController = class V1DelayedSegmentsController {
|
|
22
|
+
constructor(delayedSegmentsRepository, delayedSegmentsTransformation) {
|
|
23
|
+
this.delayedSegmentsRepository = delayedSegmentsRepository;
|
|
24
|
+
this.delayedSegmentsTransformation = delayedSegmentsTransformation;
|
|
25
|
+
this.getAllDelayedSegments = async (req, res, next) => {
|
|
26
|
+
const span = createChildSpan("V1DelayedSegmentsController.getAllDelayedSegments");
|
|
27
|
+
try {
|
|
28
|
+
const { minDelaySeconds, minDistanceStops, maxDistanceStops } = matchedData(req);
|
|
29
|
+
const delayedSegments = await this.delayedSegmentsRepository.getAll(minDelaySeconds);
|
|
30
|
+
const transformedSegments = this.delayedSegmentsTransformation.transformArray(delayedSegments).map((segment) => ({
|
|
31
|
+
...segment,
|
|
32
|
+
info_panel_stops: JISDelayedSegmentInfoPanelStopsFilter.filterByDistance(segment.info_panel_stops, minDistanceStops, maxDistanceStops),
|
|
33
|
+
}));
|
|
34
|
+
return res.status(200).json(transformedSegments);
|
|
35
|
+
}
|
|
36
|
+
catch (err) {
|
|
37
|
+
span?.recordException(err);
|
|
38
|
+
next(err);
|
|
39
|
+
}
|
|
40
|
+
finally {
|
|
41
|
+
span?.end();
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
V1DelayedSegmentsController = __decorate([
|
|
47
|
+
injectable(),
|
|
48
|
+
__param(0, inject(OgJisToken.JISDelayedSegmentsRepository)),
|
|
49
|
+
__param(1, inject(OgJisToken.JISDelayedSegmentsTransformation)),
|
|
50
|
+
__metadata("design:paramtypes", [JISDelayedSegmentsRepository,
|
|
51
|
+
JISDelayedSegmentsTransformation])
|
|
52
|
+
], V1DelayedSegmentsController);
|
|
53
|
+
export { V1DelayedSegmentsController };
|
|
54
|
+
//# sourceMappingURL=V1DelayedSegmentsController.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"V1DelayedSegmentsController.js","sourceRoot":"","sources":["../../../../../src/output-gateway/jis/controllers/v1/V1DelayedSegmentsController.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,OAAO,EAAE,qCAAqC,EAAE,MAAM,uDAAuD,CAAC;AAC9G,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,gCAAgC,EAAE,MAAM,0DAA0D,CAAC;AAC5G,OAAO,EAAE,eAAe,EAAE,MAAM,wCAAwC,CAAC;AAEzE,OAAO,oBAAoB,MAAM,gDAAgD,CAAC;AAClF,MAAM,EAAE,WAAW,EAAE,GA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BP,CAAA;AA5BY,2BAA2B;IADvC,UAAU,EAAE;IAGJ,WAAA,MAAM,CAAC,UAAU,CAAC,4BAA4B,CAAC,CAAA;IAC/C,WAAA,MAAM,CAAC,UAAU,CAAC,gCAAgC,CAAC,CAAA;qCADgC,4BAA4B;QAEzE,gCAAgC;GAJlE,2BAA2B,CA4BvC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { JISDelayedSegmentsModel } from "#sch/jis/models/JISDelayedSegmentsModel";
|
|
2
|
+
import { type ILogger } from "@golemio/core/dist/helpers/index.js";
|
|
3
|
+
import { type IDatabaseConnector } from "@golemio/core/dist/helpers/data-access/postgres/IDatabaseConnector.js";
|
|
4
|
+
import { AbstractValidatableRepository } from "@golemio/core/dist/helpers/data-access/postgres/repositories/AbstractValidatableRepository.js";
|
|
5
|
+
import type { JSONSchemaValidator as TJSONSchemaValidator } from "@golemio/core/dist/shared/golemio-validator.js";
|
|
6
|
+
import type { ModelStatic } from "@golemio/core/dist/shared/sequelize.js";
|
|
7
|
+
export declare class JISDelayedSegmentsRepository extends AbstractValidatableRepository {
|
|
8
|
+
validator: TJSONSchemaValidator;
|
|
9
|
+
schema: string;
|
|
10
|
+
tableName: string;
|
|
11
|
+
sequelizeModel: ModelStatic<JISDelayedSegmentsModel>;
|
|
12
|
+
constructor(connector: IDatabaseConnector, logger: ILogger);
|
|
13
|
+
getAll(minDelaySeconds?: number): Promise<JISDelayedSegmentsModel[]>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
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;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
11
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
12
|
+
};
|
|
13
|
+
import { PG_SCHEMA } from "#sch/const";
|
|
14
|
+
import { JISDelayedSegmentsModel } from "#sch/jis/models/JISDelayedSegmentsModel";
|
|
15
|
+
import { AbstractValidatableRepository } from "@golemio/core/dist/helpers/data-access/postgres/repositories/AbstractValidatableRepository.js";
|
|
16
|
+
import { CoreToken } from "@golemio/core/dist/helpers/ioc/CoreToken.js";
|
|
17
|
+
import GolemioErrorsCore from "@golemio/core/dist/shared/golemio-errors.js";
|
|
18
|
+
const { GeneralError } = GolemioErrorsCore;
|
|
19
|
+
import GolemioValidatorCore from "@golemio/core/dist/shared/golemio-validator.js";
|
|
20
|
+
const { JSONSchemaValidator } = GolemioValidatorCore;
|
|
21
|
+
import SequelizeCore from "@golemio/core/dist/shared/sequelize.js";
|
|
22
|
+
const { Op } = SequelizeCore;
|
|
23
|
+
import { inject, injectable } from "@golemio/core/dist/shared/tsyringe.js";
|
|
24
|
+
let JISDelayedSegmentsRepository = class JISDelayedSegmentsRepository extends AbstractValidatableRepository {
|
|
25
|
+
constructor(connector, logger) {
|
|
26
|
+
super(connector, logger);
|
|
27
|
+
this.schema = PG_SCHEMA;
|
|
28
|
+
this.tableName = JISDelayedSegmentsModel.tableName;
|
|
29
|
+
this.validator = new JSONSchemaValidator("JISDelayedSegmentsRepository", JISDelayedSegmentsModel.jsonSchema);
|
|
30
|
+
this.sequelizeModel = connector
|
|
31
|
+
.getConnection()
|
|
32
|
+
.define(this.tableName, JISDelayedSegmentsModel.attributeModel, { schema: this.schema });
|
|
33
|
+
}
|
|
34
|
+
async getAll(minDelaySeconds = 0) {
|
|
35
|
+
try {
|
|
36
|
+
return await this.sequelizeModel.findAll({
|
|
37
|
+
where: { expected_delay_seconds: { [Op.gte]: minDelaySeconds } },
|
|
38
|
+
order: [
|
|
39
|
+
["expected_delay_seconds", "DESC"],
|
|
40
|
+
["id", "ASC"],
|
|
41
|
+
],
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
catch (err) {
|
|
45
|
+
throw new GeneralError("Error while getting delayed segments", this.constructor.name, err, 500);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
JISDelayedSegmentsRepository = __decorate([
|
|
50
|
+
injectable(),
|
|
51
|
+
__param(0, inject(CoreToken.PostgresConnector)),
|
|
52
|
+
__param(1, inject(CoreToken.Logger)),
|
|
53
|
+
__metadata("design:paramtypes", [Object, Object])
|
|
54
|
+
], JISDelayedSegmentsRepository);
|
|
55
|
+
export { JISDelayedSegmentsRepository };
|
|
56
|
+
//# sourceMappingURL=JISDelayedSegmentsRepository.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"JISDelayedSegmentsRepository.js","sourceRoot":"","sources":["../../../../src/output-gateway/jis/data-access/JISDelayedSegmentsRepository.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,uBAAuB,EAAE,MAAM,yCAAyC,CAAC;AAGlF,OAAO,EAAE,6BAA6B,EAAE,MAAM,+FAA+F,CAAC;AAC9I,OAAO,EAAE,SAAS,EAAE,MAAM,6CAA6C,CAAC;AACxE,OAAO,iBAAiB,MAAM,6CAA6C,CAAC;AAC5E,MAAM,EAAE,YAAY,EAAE,GAAG,iBAAiB,CAAC;AAE3C,OAAO,oBAAoB,MAAM,gDAAgD,CAAC;AAClF,MAAM,EAAE,mBAAmB,EAAE,GAAG,oBAAoB,CAAC;AAErD,O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AAS,CAAC,iBAAiB,CAAC,CAAA;IAAiC,WAAA,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,CAAA;;GANhG,4BAA4B,CA2BxC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type IJISDelayedSegmentInfoPanelStop, type IJISDelayedSegmentRoute, type IJISDelayedSegmentStop } from "#sch/jis/models/interfaces/index";
|
|
2
|
+
export interface IJISDelayedSegmentDto {
|
|
3
|
+
id: string;
|
|
4
|
+
from_stop: IJISDelayedSegmentStop;
|
|
5
|
+
to_stop: IJISDelayedSegmentStop;
|
|
6
|
+
expected_delay_seconds: number;
|
|
7
|
+
first_detected_at: string;
|
|
8
|
+
last_detected_at: string;
|
|
9
|
+
stops: IJISDelayedSegmentStop[];
|
|
10
|
+
routes: IJISDelayedSegmentRoute[];
|
|
11
|
+
info_panel_stops: IJISDelayedSegmentInfoPanelStop[];
|
|
12
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IJISDelayedSegmentDto.js","sourceRoot":"","sources":["../../../../src/output-gateway/jis/domain/IJISDelayedSegmentDto.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IDelayedSegmentsQueryDto.js","sourceRoot":"","sources":["../../../../../src/output-gateway/jis/dto/interfaces/IDelayedSegmentsQueryDto.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type IJISDelayedSegmentInfoPanelStop } from "#sch/jis/models/interfaces/index";
|
|
2
|
+
/**
|
|
3
|
+
* Keeps only the routes of info panel stops whose signed distance from the segment lies within the inclusive range,
|
|
4
|
+
* so that consumers get only the panels they inform; stops left without a route are left out
|
|
5
|
+
*/
|
|
6
|
+
export declare class JISDelayedSegmentInfoPanelStopsFilter {
|
|
7
|
+
static filterByDistance(infoPanelStops: IJISDelayedSegmentInfoPanelStop[], minDistanceStops?: number, maxDistanceStops?: number): IJISDelayedSegmentInfoPanelStop[];
|
|
8
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Keeps only the routes of info panel stops whose signed distance from the segment lies within the inclusive range,
|
|
3
|
+
* so that consumers get only the panels they inform; stops left without a route are left out
|
|
4
|
+
*/
|
|
5
|
+
export class JISDelayedSegmentInfoPanelStopsFilter {
|
|
6
|
+
static filterByDistance(infoPanelStops, minDistanceStops = -Infinity, maxDistanceStops = Infinity) {
|
|
7
|
+
return infoPanelStops.flatMap((infoPanelStop) => {
|
|
8
|
+
const routes = infoPanelStop.routes.filter((route) => route.distance_stops >= minDistanceStops && route.distance_stops <= maxDistanceStops);
|
|
9
|
+
return routes.length > 0 ? [{ ...infoPanelStop, routes }] : [];
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=JISDelayedSegmentInfoPanelStopsFilter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"JISDelayedSegmentInfoPanelStopsFilter.js","sourceRoot":"","sources":["../../../../src/output-gateway/jis/helpers/JISDelayedSegmentInfoPanelStopsFilter.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,MAAM,OAAO,qCAAqC;IACvC,MAAM,CAAC,gBAAgB,CAC1B,cAAiD,EACjD,gBAAgB,GAAG,CAAC,QAAQ,EAC5B,gBAAgB,GAAG,QAAQ;QAE3B,OAAO,cAAc,CAAC,OAAO,CAAC,CAAC,aAAa,EAAE,EAAE;YAC5C,MAAM,MAAM,GAAG,aAAa,CAAC,MAAM,CAAC,MAAM,CACtC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,cAAc,IAAI,gBAAgB,IAAI,KAAK,CAAC,cAAc,IAAI,gBAAgB,CAClG,CAAC;YACF,OAAO,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,GAAG,aAAa,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QACnE,CAAC,CAAC,CAAC;IACP,CAAC;CACJ"}
|
|
@@ -1,21 +1,27 @@
|
|
|
1
1
|
import { OutputGatewayContainer } from "@golemio/core/dist/output-gateway/ioc/index.js";
|
|
2
|
+
import { V1DelayedSegmentsController } from "../controllers/v1/V1DelayedSegmentsController.js";
|
|
2
3
|
import { V1EventsController } from "../controllers/v1/V1EventsController.js";
|
|
4
|
+
import { JISDelayedSegmentsRepository } from "../data-access/JISDelayedSegmentsRepository.js";
|
|
3
5
|
import { JISEventsRepository } from "../data-access/JISEventsRepository.js";
|
|
4
6
|
import { JISEventsRopidGTFSRoutesRepository } from "../data-access/JISEventsRopidGTFSRoutesRepository.js";
|
|
5
7
|
import { RopidGTFSRoutesRepository } from "../data-access/RopidGTFSRoutesRepository.js";
|
|
8
|
+
import { JISDelayedSegmentsTransformation } from "../transformations/JISDelayedSegmentsTransformation.js";
|
|
6
9
|
import { JISEventsCustomFormatTransformation } from "../transformations/JISEventsCustomFormatTransformation.js";
|
|
7
10
|
import { OgJisToken } from "./OgJisToken.js";
|
|
8
11
|
const ogJisContainer = OutputGatewayContainer.createChildContainer();
|
|
9
12
|
//#region Controllers
|
|
10
13
|
ogJisContainer.registerSingleton(OgJisToken.V1EventsController, V1EventsController);
|
|
14
|
+
ogJisContainer.registerSingleton(OgJisToken.V1DelayedSegmentsController, V1DelayedSegmentsController);
|
|
11
15
|
//#endregion
|
|
12
16
|
//#region Repositories
|
|
13
17
|
ogJisContainer.registerSingleton(OgJisToken.JISEventsRepository, JISEventsRepository);
|
|
14
18
|
ogJisContainer.registerSingleton(OgJisToken.JISEventsRopidGTFSRoutesRepository, JISEventsRopidGTFSRoutesRepository);
|
|
15
19
|
ogJisContainer.registerSingleton(OgJisToken.RopidGTFSRoutesRepository, RopidGTFSRoutesRepository);
|
|
20
|
+
ogJisContainer.registerSingleton(OgJisToken.JISDelayedSegmentsRepository, JISDelayedSegmentsRepository);
|
|
16
21
|
//#endregion
|
|
17
22
|
//#region Transformations
|
|
18
23
|
ogJisContainer.registerSingleton(OgJisToken.JISEventsCustomFormatTransformation, JISEventsCustomFormatTransformation);
|
|
24
|
+
ogJisContainer.registerSingleton(OgJisToken.JISDelayedSegmentsTransformation, JISDelayedSegmentsTransformation);
|
|
19
25
|
//#endregion
|
|
20
26
|
export { ogJisContainer as OgJisContainer };
|
|
21
27
|
//# sourceMappingURL=Di.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Di.js","sourceRoot":"","sources":["../../../../src/output-gateway/jis/ioc/Di.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,gDAAgD,CAAC;AAExF,OAAO,EAAE,kBAAkB,EAAE,MAAM,yCAAyC,CAAC;AAC7E,OAAO,EAAE,mBAAmB,EAAE,MAAM,uCAAuC,CAAC;AAC5E,OAAO,EAAE,kCAAkC,EAAE,MAAM,sDAAsD,CAAC;AAC1G,OAAO,EAAE,yBAAyB,EAAE,MAAM,6CAA6C,CAAC;AACxF,OAAO,EAAE,mCAAmC,EAAE,MAAM,2DAA2D,CAAC;AAChH,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE7C,MAAM,cAAc,GAAwB,sBAAsB,CAAC,oBAAoB,EAAE,CAAC;AAE1F,qBAAqB;AACrB,cAAc,CAAC,iBAAiB,CAAC,UAAU,CAAC,kBAAkB,EAAE,kBAAkB,CAAC,CAAC;AACpF,YAAY;AAEZ,sBAAsB;AACtB,cAAc,CAAC,iBAAiB,CAAC,UAAU,CAAC,mBAAmB,EAAE,mBAAmB,CAAC,CAAC;AACtF,cAAc,CAAC,iBAAiB,CAAC,UAAU,CAAC,kCAAkC,EAAE,kCAAkC,CAAC,CAAC;AACpH,cAAc,CAAC,iBAAiB,CAAC,UAAU,CAAC,yBAAyB,EAAE,yBAAyB,CAAC,CAAC;AAClG,YAAY;AAEZ,yBAAyB;AACzB,cAAc,CAAC,iBAAiB,CAAC,UAAU,CAA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,cAAc,CAAC,iBAAiB,CAAC,UAAU,CAAC,4BAA4B,EAAE,4BAA4B,CAAC,CAAC;AACxG,YAAY;AAEZ,yBAAyB;AACzB,cAAc,CAAC,iBAAiB,CAAC,UAAU,CAAC,mCAAmC,EAAE,mCAAmC,CAAC,CAAC;AACtH,cAAc,CAAC,iBAAiB,CAAC,UAAU,CAAC,gCAAgC,EAAE,gCAAgC,CAAC,CAAC;AAChH,YAAY;AAEZ,OAAO,EAAE,cAAc,IAAI,cAAc,EAAE,CAAC"}
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
export declare const OgJisToken: {
|
|
2
2
|
V1EventsController: symbol;
|
|
3
|
+
V1DelayedSegmentsController: symbol;
|
|
3
4
|
JISEventsRepository: symbol;
|
|
4
5
|
JISEventsRopidGTFSRoutesRepository: symbol;
|
|
5
6
|
JISInfotextsRedisRepository: symbol;
|
|
6
7
|
RopidGTFSRoutesRepository: symbol;
|
|
8
|
+
JISDelayedSegmentsRepository: symbol;
|
|
7
9
|
JISEventsCustomFormatTransformation: symbol;
|
|
10
|
+
JISDelayedSegmentsTransformation: symbol;
|
|
8
11
|
VPSubscriber: symbol;
|
|
9
12
|
};
|
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
export const OgJisToken = {
|
|
2
2
|
//#region Controllers
|
|
3
3
|
V1EventsController: Symbol("V1EventsController"),
|
|
4
|
+
V1DelayedSegmentsController: Symbol("V1DelayedSegmentsController"),
|
|
4
5
|
//#endregion
|
|
5
6
|
//#region Repositories
|
|
6
7
|
JISEventsRepository: Symbol("JISEventsRepository"),
|
|
7
8
|
JISEventsRopidGTFSRoutesRepository: Symbol("JISEventsRopidGTFSRoutesRepository"),
|
|
8
9
|
JISInfotextsRedisRepository: Symbol("JISInfotextsRedisRepository"),
|
|
9
10
|
RopidGTFSRoutesRepository: Symbol("RopidGTFSRoutesRepository"),
|
|
11
|
+
JISDelayedSegmentsRepository: Symbol("JISDelayedSegmentsRepository"),
|
|
10
12
|
//#endregion
|
|
11
13
|
//#region Transformations
|
|
12
14
|
JISEventsCustomFormatTransformation: Symbol("JISEventsCustomFormatTransformation"),
|
|
15
|
+
JISDelayedSegmentsTransformation: Symbol("JISDelayedSegmentsTransformation"),
|
|
13
16
|
//#endregion
|
|
14
17
|
//#region Helpers
|
|
15
18
|
VPSubscriber: Symbol("VPSubscriber"),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OgJisToken.js","sourceRoot":"","sources":["../../../../src/output-gateway/jis/ioc/OgJisToken.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,UAAU,GAAG;IACtB,qBAAqB;IACrB,kBAAkB,EAAE,MAAM,CAAC,oBAAoB,CAAC;IAChD,YAAY;IAEZ,sBAAsB;IACtB,mBAAmB,EAAE,MAAM,CAAC,qBAAqB,CAAC;IAClD,kCAAkC,EAAE,MAAM,CAAC,oCAAoC,CAAC;IAChF,2BAA2B,EAAE,MAAM,CAAC,6BAA6B,CAAC;IAClE,yBAAyB,EAAE,MAAM,CAAC,2BAA2B,CAAC;IAC9D,YAAY;IAEZ,yBAAyB;IACzB,mCAAmC,EAAE,MAAM,CAAC,qCAAqC,CAAC;IAClF,YAAY;IAEZ,iBAAiB;IACjB,YAAY,EAAE,MAAM,CAAC,cAAc,CAAC;IACpC,YAAY;CACf,CAAC"}
|
|
1
|
+
{"version":3,"file":"OgJisToken.js","sourceRoot":"","sources":["../../../../src/output-gateway/jis/ioc/OgJisToken.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,UAAU,GAAG;IACtB,qBAAqB;IACrB,kBAAkB,EAAE,MAAM,CAAC,oBAAoB,CAAC;IAChD,2BAA2B,EAAE,MAAM,CAAC,6BAA6B,CAAC;IAClE,YAAY;IAEZ,sBAAsB;IACtB,mBAAmB,EAAE,MAAM,CAAC,qBAAqB,CAAC;IAClD,kCAAkC,EAAE,MAAM,CAAC,oCAAoC,CAAC;IAChF,2BAA2B,EAAE,MAAM,CAAC,6BAA6B,CAAC;IAClE,yBAAyB,EAAE,MAAM,CAAC,2BAA2B,CAAC;IAC9D,4BAA4B,EAAE,MAAM,CAAC,8BAA8B,CAAC;IACpE,YAAY;IAEZ,yBAAyB;IACzB,mCAAmC,EAAE,MAAM,CAAC,qCAAqC,CAAC;IAClF,gCAAgC,EAAE,MAAM,CAAC,kCAAkC,CAAC;IAC5E,YAAY;IAEZ,iBAAiB;IACjB,YAAY,EAAE,MAAM,CAAC,cAAc,CAAC;IACpC,YAAY;CACf,CAAC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { V1DelayedSegmentsController } from "#og/jis/controllers/v1/V1DelayedSegmentsController";
|
|
1
2
|
import { V1EventsController } from "#og/jis/controllers/v1/V1EventsController";
|
|
2
3
|
import { AbstractRouter } from "@golemio/core/dist/helpers/routing/AbstractRouter.js";
|
|
3
4
|
import { CacheHeaderMiddleware } from "@golemio/core/dist/output-gateway/CacheHeaderMiddleware.js";
|
|
@@ -6,6 +7,7 @@ export declare class V1JISRouter extends AbstractRouter {
|
|
|
6
7
|
readonly router: TRouter;
|
|
7
8
|
readonly cacheHeaderMiddleware: CacheHeaderMiddleware;
|
|
8
9
|
readonly eventsController: V1EventsController;
|
|
10
|
+
readonly delayedSegmentsController: V1DelayedSegmentsController;
|
|
9
11
|
constructor();
|
|
10
12
|
protected initRoutes: () => void;
|
|
11
13
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { OgJisContainer } from "#og/jis/ioc/Di";
|
|
2
2
|
import { OgJisToken } from "#og/jis/ioc/OgJisToken";
|
|
3
3
|
import { RouteVersion } from "#og/shared/constants/index";
|
|
4
|
+
import { PG_INT_MAX, PG_INT_MIN } from "../../../../const.js";
|
|
4
5
|
import { jisEventType } from "#sch/jis/constants/jisEventType";
|
|
5
6
|
import { AbstractRouter } from "@golemio/core/dist/helpers/routing/AbstractRouter.js";
|
|
6
7
|
import { ContainerToken } from "@golemio/core/dist/output-gateway/ioc/index.js";
|
|
@@ -22,8 +23,16 @@ export class V1JISRouter extends AbstractRouter {
|
|
|
22
23
|
], checkErrors,
|
|
23
24
|
// // max-age 5 seconds, stale-while-revalidate 5 seconds
|
|
24
25
|
this.cacheHeaderMiddleware.getMiddleware(5, 5), this.eventsController.getAllEventsInCustomFormat);
|
|
26
|
+
this.router.get("/delayed-segments", [
|
|
27
|
+
query("minDelaySeconds").optional().isInt({ min: 0, max: PG_INT_MAX }).not().isArray().toInt(),
|
|
28
|
+
query("minDistanceStops").optional().isInt({ min: PG_INT_MIN, max: PG_INT_MAX }).not().isArray().toInt(),
|
|
29
|
+
query("maxDistanceStops").optional().isInt({ min: PG_INT_MIN, max: PG_INT_MAX }).not().isArray().toInt(),
|
|
30
|
+
], checkErrors,
|
|
31
|
+
// max-age 5 seconds, stale-while-revalidate 5 seconds
|
|
32
|
+
this.cacheHeaderMiddleware.getMiddleware(5, 5), this.delayedSegmentsController.getAllDelayedSegments);
|
|
25
33
|
};
|
|
26
34
|
this.eventsController = OgJisContainer.resolve(OgJisToken.V1EventsController);
|
|
35
|
+
this.delayedSegmentsController = OgJisContainer.resolve(OgJisToken.V1DelayedSegmentsController);
|
|
27
36
|
this.cacheHeaderMiddleware = OgJisContainer.resolve(ContainerToken.CacheHeaderMiddleware);
|
|
28
37
|
this.initRoutes();
|
|
29
38
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"V1JISRouter.js","sourceRoot":"","sources":["../../../../../src/output-gateway/jis/routers/v1/V1JISRouter.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"V1JISRouter.js","sourceRoot":"","sources":["../../../../../src/output-gateway/jis/routers/v1/V1JISRouter.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,UAAU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,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,UAAU,EAAE,CAAC,CAAC,GAAG,EAAE,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE;gBAC9F,KAAK,CAAC,kBAAkB,CAAC,CAAC,QAAQ,EAAE,CAAC,KAAK,CAAC,EAAE,GAAG,EAAE,UAAU,EAAE,GAAG,EAAE,UAAU,EAAE,CAAC,CAAC,GAAG,EAAE,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE;gBACxG,KAAK,CAAC,kBAAkB,CAAC,CAAC,QAAQ,EAAE,CAAC,KAAK,CAAC,EAAE,GAAG,EAAE,UAAU,EAAE,GAAG,EAAE,UAAU,EAAE,CAAC,CAAC,GAAG,EAAE,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE;aAC3G,EACD,WAAW;YACX,sDAAsD;YACtD,IAAI,CAAC,qBAAqB,CAAC,aAAa,CAAC,CAAC,EAAE,CAAC,CAAC,EAC9C,IAAI,CAAC,yBAAyB,CAAC,qBAAqB,CACvD,CAAC;QACN,CAAC,CAAC;QAjCE,IAAI,CAAC,gBAAgB,GAAG,cAAc,CAAC,OAAO,CAAqB,UAAU,CAAC,kBAAkB,CAAC,CAAC;QAClG,IAAI,CAAC,yBAAyB,GAAG,cAAc,CAAC,OAAO,CACnD,UAAU,CAAC,2BAA2B,CACzC,CAAC;QACF,IAAI,CAAC,qBAAqB,GAAG,cAAc,CAAC,OAAO,CAAwB,cAAc,CAAC,qBAAqB,CAAC,CAAC;QACjH,IAAI,CAAC,UAAU,EAAE,CAAC;IACtB,CAAC;CA4BJ;AAED,MAAM,WAAW,GAAmB,IAAI,WAAW,EAAE,CAAC;AAEtD,OAAO,EAAE,WAAW,EAAE,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { JISDelayedSegmentsModel } from "#sch/jis/models/JISDelayedSegmentsModel";
|
|
2
|
+
import { AbstractTransformation } from "@golemio/core/dist/helpers/transformation/AbstractTransformation.js";
|
|
3
|
+
import { type IJISDelayedSegmentDto } from "../domain/IJISDelayedSegmentDto.js";
|
|
4
|
+
export declare class JISDelayedSegmentsTransformation extends AbstractTransformation<JISDelayedSegmentsModel, IJISDelayedSegmentDto> {
|
|
5
|
+
name: string;
|
|
6
|
+
protected transformInternal: (segment: JISDelayedSegmentsModel) => IJISDelayedSegmentDto;
|
|
7
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
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;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { AbstractTransformation } from "@golemio/core/dist/helpers/transformation/AbstractTransformation.js";
|
|
8
|
+
import { injectable } from "@golemio/core/dist/shared/tsyringe.js";
|
|
9
|
+
let JISDelayedSegmentsTransformation = class JISDelayedSegmentsTransformation extends AbstractTransformation {
|
|
10
|
+
constructor() {
|
|
11
|
+
super(...arguments);
|
|
12
|
+
this.name = "JISDelayedSegmentsTransformation";
|
|
13
|
+
this.transformInternal = (segment) => {
|
|
14
|
+
return {
|
|
15
|
+
id: segment.id,
|
|
16
|
+
from_stop: { id: segment.from_stop_id, name: segment.from_stop_name },
|
|
17
|
+
to_stop: { id: segment.to_stop_id, name: segment.to_stop_name },
|
|
18
|
+
expected_delay_seconds: segment.expected_delay_seconds,
|
|
19
|
+
first_detected_at: segment.created_at.toISOString(),
|
|
20
|
+
last_detected_at: segment.updated_at.toISOString(),
|
|
21
|
+
stops: segment.stops,
|
|
22
|
+
routes: segment.routes,
|
|
23
|
+
info_panel_stops: segment.info_panel_stops,
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
JISDelayedSegmentsTransformation = __decorate([
|
|
29
|
+
injectable()
|
|
30
|
+
], JISDelayedSegmentsTransformation);
|
|
31
|
+
export { JISDelayedSegmentsTransformation };
|
|
32
|
+
//# sourceMappingURL=JISDelayedSegmentsTransformation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"JISDelayedSegmentsTransformation.js","sourceRoot":"","sources":["../../../../src/output-gateway/jis/transformations/JISDelayedSegmentsTransformation.ts"],"names":[],"mappings":";;;;;;AACA,OAAO,EAAE,sBAAsB,EAAE,MAAM,qEAAqE,CAAC;AAC7G,OAAO,EAAE,UAAU,EAAE,MAAM,uCAAuC,CAAC;AAI5D,IAAM,gCAAgC,GAAtC,MAAM,gCAAiC,SAAQ,sBAAsE;IAArH;;QACI,SAAI,GAAG,kCAAkC,CAAC;QAEvC,sBAAiB,GAAG,CAAC,OAAgC,EAAyB,EAAE;YACtF,OAAO;gBACH,EAAE,EAAE,OAAO,CAAC,EAAE;gBACd,SAAS,EAAE,EAAE,EAAE,EAAE,OAAO,CAAC,YAAY,EAAE,IAAI,EAAE,OAAO,CAAC,cAAc,EAAE;gBACrE,OAAO,EAAE,EAAE,EAAE,EAAE,OAAO,CAAC,UAAU,EAAE,IAAI,EAAE,OAAO,CAAC,YAAY,EAAE;gBAC/D,sBAAsB,EAAE,OAAO,CAAC,sBAAsB;gBACtD,iBAAiB,EAAE,OAAO,CAAC,UAAU,CAAC,WAAW,EAAE;gBACnD,gBAAgB,EAAE,OAAO,CAAC,UAAU,CAAC,WAAW,EAAE;gBAClD,KAAK,EAAE,OAAO,CAAC,KAAK;gBACpB,MAAM,EAAE,OAAO,CAAC,MAAM;gBACtB,gBAAgB,EAAE,OAAO,CAAC,gBAAgB;aAC7C,CAAC;QACN,CAAC,CAAC;IACN,CAAC;CAAA,CAAA;AAhBY,gCAAgC;IAD5C,UAAU,EAAE;GACA,gCAAgC,CAgB5C"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// Additional properties are allowed, as the endpoint serves the Mapa PID web map and its response contains more fields
|
|
2
|
+
export const mapaPidDelayShapesJsonSchema = {
|
|
3
|
+
type: "array",
|
|
4
|
+
items: {
|
|
5
|
+
type: "object",
|
|
6
|
+
properties: {
|
|
7
|
+
from_stop_id: { type: "string" },
|
|
8
|
+
to_stop_id: { type: "string" },
|
|
9
|
+
from_stop_name: { oneOf: [{ type: "string" }, { type: "null", nullable: true }] },
|
|
10
|
+
to_stop_name: { oneOf: [{ type: "string" }, { type: "null", nullable: true }] },
|
|
11
|
+
expected_delay: { type: "integer" },
|
|
12
|
+
},
|
|
13
|
+
required: ["from_stop_id", "to_stop_id", "from_stop_name", "to_stop_name", "expected_delay"],
|
|
14
|
+
},
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=MapaPidDelayShapesJsonSchema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MapaPidDelayShapesJsonSchema.js","sourceRoot":"","sources":["../../../../src/schema-definitions/jis/datasources/MapaPidDelayShapesJsonSchema.ts"],"names":[],"mappings":"AAGA,uHAAuH;AACvH,MAAM,CAAC,MAAM,4BAA4B,GAAyC;IAC9E,IAAI,EAAE,OAAO;IACb,KAAK,EAAE;QACH,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACR,YAAY,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;YAChC,UAAU,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;YAC9B,cAAc,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,EAAE;YACjF,YAAY,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,EAAE;YAC/E,cAAc,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE;SACtC;QACD,QAAQ,EAAE,CAAC,cAAc,EAAE,YAAY,EAAE,gBAAgB,EAAE,cAAc,EAAE,gBAAgB,CAAC;KAC/F;CACJ,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Delayed segment (merged chain of delayed stop-to-stop sections) as reported by Mapa PID
|
|
3
|
+
*/
|
|
4
|
+
export interface IMapaPidDelayShape {
|
|
5
|
+
from_stop_id: string;
|
|
6
|
+
to_stop_id: string;
|
|
7
|
+
from_stop_name: string | null;
|
|
8
|
+
to_stop_name: string | null;
|
|
9
|
+
expected_delay: number;
|
|
10
|
+
}
|