@golemio/pid 5.9.3-dev.2487758126 → 5.9.3-dev.2497470687
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/dist/output-gateway/pid/controllers/v2/V2DepartureBoardsController.d.ts +4 -0
- package/dist/output-gateway/pid/controllers/v2/V2DepartureBoardsController.js +69 -37
- package/dist/output-gateway/pid/controllers/v2/V2DepartureBoardsController.js.map +1 -1
- package/dist/output-gateway/pid/helpers/MpvnetTransportTypeMapper.d.ts +8 -0
- package/dist/output-gateway/pid/helpers/MpvnetTransportTypeMapper.js +45 -0
- package/dist/output-gateway/pid/helpers/MpvnetTransportTypeMapper.js.map +1 -0
- package/dist/output-gateway/pid/helpers/MpvnetXmlSerializer.d.ts +16 -0
- package/dist/output-gateway/pid/helpers/MpvnetXmlSerializer.js +137 -0
- package/dist/output-gateway/pid/helpers/MpvnetXmlSerializer.js.map +1 -0
- package/dist/output-gateway/pid/routers/v2/V2PIDRouter.js +3 -0
- package/dist/output-gateway/pid/routers/v2/V2PIDRouter.js.map +1 -1
- package/docs/openapi-output.yaml +256 -137
- package/package.json +2 -9
|
@@ -5,54 +5,42 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.V2DepartureBoardsController = void 0;
|
|
7
7
|
const dto_1 = require("../../dto");
|
|
8
|
+
const MpvnetXmlSerializer_1 = require("../../helpers/MpvnetXmlSerializer");
|
|
8
9
|
const PIDDepartureBoardsModel_1 = require("../../models/PIDDepartureBoardsModel");
|
|
9
10
|
const shared_1 = require("../../../shared");
|
|
10
11
|
const trace_provider_1 = require("@golemio/core/dist/monitoring/opentelemetry/trace-provider");
|
|
11
12
|
const express_validator_1 = require("@golemio/core/dist/shared/express-validator");
|
|
13
|
+
const golemio_errors_1 = require("@golemio/core/dist/shared/golemio-errors");
|
|
12
14
|
const moment_timezone_1 = __importDefault(require("@golemio/core/dist/shared/moment-timezone"));
|
|
13
15
|
class V2DepartureBoardsController {
|
|
14
16
|
constructor() {
|
|
15
17
|
this.getDepartureBoard = async (req, res, next) => {
|
|
16
|
-
const
|
|
17
|
-
const query = shared_1.RopidRouterUtils.mapObjectToDTOInstance(dto_1.DepartureBoardsQueryDTO, queryData);
|
|
18
|
-
const preferredTimezone = shared_1.RopidRouterUtils.getPreferredTimezone(query.preferredTimezone);
|
|
18
|
+
const { query, preferredTimezone } = this.parseQuery(req);
|
|
19
19
|
res.setHeader("X-Golemio-Preset-Metadata", `airConditionPossible=${query.airCondition ? 1 : 0}`);
|
|
20
|
-
|
|
21
|
-
// it matches:
|
|
22
|
-
// 2020-10-10T10:00:00Z
|
|
23
|
-
// 2020-10-10 10:00:00.00Z
|
|
24
|
-
// 2020-10-10T10:00:00+02
|
|
25
|
-
// 2020-10-10T10:00:00+02:00
|
|
26
|
-
const timezoneDefinedRegexp = /[T ][\d:.]+([zZ]|([+-])([01]\d|2[0-3]):?([0-5]\d)?)/;
|
|
27
|
-
// use timezone from ?preferredTimezone if not set in ?timeFrom
|
|
28
|
-
const timeFrom = query.timeFrom
|
|
29
|
-
? query.timeFrom.match(timezoneDefinedRegexp)
|
|
30
|
-
? (0, moment_timezone_1.default)(query.timeFrom)
|
|
31
|
-
: moment_timezone_1.default.tz(query.timeFrom, preferredTimezone)
|
|
32
|
-
: undefined;
|
|
20
|
+
const timeFrom = this.computeTimeFrom(query, preferredTimezone);
|
|
33
21
|
const span = (0, trace_provider_1.createChildSpan)("V2DepartureBoardsController.getDepartureBoard");
|
|
34
22
|
try {
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
res.status(200).send(
|
|
23
|
+
const dto = await this.fetchBoard(query, preferredTimezone, timeFrom);
|
|
24
|
+
res.status(200).send(dto);
|
|
25
|
+
}
|
|
26
|
+
catch (err) {
|
|
27
|
+
next(err);
|
|
28
|
+
}
|
|
29
|
+
finally {
|
|
30
|
+
span?.end();
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
this.getDepartureBoardXml = async (req, res, next) => {
|
|
34
|
+
const { query, preferredTimezone } = this.parseQuery(req);
|
|
35
|
+
if (query.mode !== undefined && query.mode !== "departures") {
|
|
36
|
+
next(new golemio_errors_1.GeneralError("Only mode=departures is supported for the XML endpoint.", "V2DepartureBoardsController", undefined, 400));
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
const timeFrom = this.computeTimeFrom(query, preferredTimezone);
|
|
40
|
+
const span = (0, trace_provider_1.createChildSpan)("V2DepartureBoardsController.getDepartureBoardXml");
|
|
41
|
+
try {
|
|
42
|
+
const dto = await this.fetchBoard(query, preferredTimezone, timeFrom);
|
|
43
|
+
res.set("Content-Type", "text/xml; charset=utf-8").status(200).send(MpvnetXmlSerializer_1.MpvnetXmlSerializer.serialize(dto));
|
|
56
44
|
}
|
|
57
45
|
catch (err) {
|
|
58
46
|
next(err);
|
|
@@ -63,6 +51,50 @@ class V2DepartureBoardsController {
|
|
|
63
51
|
};
|
|
64
52
|
this.departureBoardsModel = new PIDDepartureBoardsModel_1.PIDDepartureBoardsModel();
|
|
65
53
|
}
|
|
54
|
+
parseQuery(req) {
|
|
55
|
+
const queryData = (0, express_validator_1.matchedData)(req);
|
|
56
|
+
const query = shared_1.RopidRouterUtils.mapObjectToDTOInstance(dto_1.DepartureBoardsQueryDTO, queryData);
|
|
57
|
+
const preferredTimezone = shared_1.RopidRouterUtils.getPreferredTimezone(query.preferredTimezone);
|
|
58
|
+
return { query, preferredTimezone };
|
|
59
|
+
}
|
|
60
|
+
computeTimeFrom(query, preferredTimezone) {
|
|
61
|
+
// datetime is valid ISO 8601 (by express validator)
|
|
62
|
+
// it matches:
|
|
63
|
+
// 2020-10-10T10:00:00Z
|
|
64
|
+
// 2020-10-10 10:00:00.00Z
|
|
65
|
+
// 2020-10-10T10:00:00+02
|
|
66
|
+
// 2020-10-10T10:00:00+02:00
|
|
67
|
+
const timezoneDefinedRegexp = /[T ][\d:.]+([zZ]|([+-])([01]\d|2[0-3]):?([0-5]\d)?)/;
|
|
68
|
+
// use timezone from ?preferredTimezone if not set in ?timeFrom
|
|
69
|
+
return query.timeFrom
|
|
70
|
+
? query.timeFrom.match(timezoneDefinedRegexp)
|
|
71
|
+
? (0, moment_timezone_1.default)(query.timeFrom)
|
|
72
|
+
: moment_timezone_1.default.tz(query.timeFrom, preferredTimezone)
|
|
73
|
+
: undefined;
|
|
74
|
+
}
|
|
75
|
+
async fetchBoard(query, preferredTimezone, timeFrom) {
|
|
76
|
+
const data = await this.departureBoardsModel.getAll({
|
|
77
|
+
aswIds: query.aswIds,
|
|
78
|
+
cisIds: query.cisIds,
|
|
79
|
+
gtfsIds: query.ids,
|
|
80
|
+
names: query.names,
|
|
81
|
+
minutesAfter: query.minutesAfter,
|
|
82
|
+
minutesBefore: query.minutesBefore,
|
|
83
|
+
timeFrom,
|
|
84
|
+
mode: query.mode,
|
|
85
|
+
order: query.order,
|
|
86
|
+
filter: query.filter,
|
|
87
|
+
skip: query.skip,
|
|
88
|
+
limit: query.limit,
|
|
89
|
+
offset: query.offset,
|
|
90
|
+
total: query.total ?? query.limit,
|
|
91
|
+
timezone: preferredTimezone,
|
|
92
|
+
includeMetroTrains: query.includeMetroTrains,
|
|
93
|
+
airCondition: query.airCondition,
|
|
94
|
+
appendHeadsignsLimit: query.appendHeadsignsLimit,
|
|
95
|
+
});
|
|
96
|
+
return shared_1.RopidRouterUtils.mapObjectToDTOInstance(dto_1.DepartureBoardsResponseDTO, data);
|
|
97
|
+
}
|
|
66
98
|
}
|
|
67
99
|
exports.V2DepartureBoardsController = V2DepartureBoardsController;
|
|
68
100
|
//# sourceMappingURL=V2DepartureBoardsController.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"V2DepartureBoardsController.js","sourceRoot":"","sources":["../../../../../src/output-gateway/pid/controllers/v2/V2DepartureBoardsController.ts"],"names":[],"mappings":";;;;;;AAAA,mCAAkF;AAClF,kFAAiF;AACjF,4CAA8C;AAC9C,+FAA6F;AAE7F,mFAA0E;AAC1E,gGAA2E;AAE3E,MAAa,2BAA2B;IAGpC;QAIO,sBAAiB,GAAmB,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE;YAChE,MAAM,SAAS,GAAG,IAAA
|
|
1
|
+
{"version":3,"file":"V2DepartureBoardsController.js","sourceRoot":"","sources":["../../../../../src/output-gateway/pid/controllers/v2/V2DepartureBoardsController.ts"],"names":[],"mappings":";;;;;;AAAA,mCAAkF;AAClF,2EAA0E;AAC1E,kFAAiF;AACjF,4CAA8C;AAC9C,+FAA6F;AAE7F,mFAA0E;AAC1E,6EAAwE;AACxE,gGAA2E;AAE3E,MAAa,2BAA2B;IAGpC;QAIO,sBAAiB,GAAmB,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE;YAChE,MAAM,EAAE,KAAK,EAAE,iBAAiB,EAAE,GAAG,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;YAC1D,GAAG,CAAC,SAAS,CAAC,2BAA2B,EAAE,wBAAwB,KAAK,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;YACjG,MAAM,QAAQ,GAAG,IAAI,CAAC,eAAe,CAAC,KAAK,EAAE,iBAAiB,CAAC,CAAC;YAEhE,MAAM,IAAI,GAAG,IAAA,gCAAe,EAAC,+CAA+C,CAAC,CAAC;YAC9E,IAAI,CAAC;gBACD,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,iBAAiB,E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,aAAa;YAClC,QAAQ;YACR,IAAI,EAAE,KAAK,CAAC,IAAI;YAChB,KAAK,EAAE,KAAK,CAAC,KAAK;YAClB,MAAM,EAAE,KAAK,CAAC,MAAM;YACpB,IAAI,EAAE,KAAK,CAAC,IAAI;YAChB,KAAK,EAAE,KAAK,CAAC,KAAK;YAClB,MAAM,EAAE,KAAK,CAAC,MAAM;YACpB,KAAK,EAAE,KAAK,CAAC,KAAK,IAAI,KAAK,CAAC,KAAK;YACjC,QAAQ,EAAE,iBAAiB;YAC3B,kBAAkB,EAAE,KAAK,CAAC,kBAAkB;YAC5C,YAAY,EAAE,KAAK,CAAC,YAAY;YAChC,oBAAoB,EAAE,KAAK,CAAC,oBAAoB;SACnD,CAAC,CAAC;QACH,OAAO,yBAAgB,CAAC,sBAAsB,CAAC,gCAA0B,EAAE,IAAI,CAAC,CAAC;IACrF,CAAC;CACJ;AArGD,kEAqGC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { MPVRouteTypesEnum } from "../../../helpers/RouteTypeEnums";
|
|
2
|
+
export interface ITransportTypeInput {
|
|
3
|
+
type: number | null;
|
|
4
|
+
is_night: boolean;
|
|
5
|
+
is_regional: boolean;
|
|
6
|
+
is_substitute_transport: boolean;
|
|
7
|
+
}
|
|
8
|
+
export declare function mapTransportType(route: ITransportTypeInput): MPVRouteTypesEnum;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.mapTransportType = mapTransportType;
|
|
4
|
+
const RouteTypeEnums_1 = require("../../../helpers/RouteTypeEnums");
|
|
5
|
+
const SIMPLE_TYPE_MAP = {
|
|
6
|
+
[RouteTypeEnums_1.GTFSRouteTypeEnum.METRO]: RouteTypeEnums_1.MPVRouteTypesEnum.METRO,
|
|
7
|
+
[RouteTypeEnums_1.GTFSRouteTypeEnum.TRAIN]: RouteTypeEnums_1.MPVRouteTypesEnum.TRAIN,
|
|
8
|
+
[RouteTypeEnums_1.GTFSRouteTypeEnum.TROLLEYBUS]: RouteTypeEnums_1.MPVRouteTypesEnum.TROLLEYBUS,
|
|
9
|
+
[RouteTypeEnums_1.GTFSRouteTypeEnum.FERRY]: RouteTypeEnums_1.MPVRouteTypesEnum.FERRY,
|
|
10
|
+
[RouteTypeEnums_1.GTFSRouteTypeEnum.FUNICULAR]: RouteTypeEnums_1.MPVRouteTypesEnum.FUNICULAR,
|
|
11
|
+
};
|
|
12
|
+
function mapTransportType(route) {
|
|
13
|
+
if (route.type === RouteTypeEnums_1.GTFSRouteTypeEnum.TRAM) {
|
|
14
|
+
return mapTram(route);
|
|
15
|
+
}
|
|
16
|
+
if (route.type === RouteTypeEnums_1.GTFSRouteTypeEnum.BUS) {
|
|
17
|
+
return mapBus(route);
|
|
18
|
+
}
|
|
19
|
+
return SIMPLE_TYPE_MAP[route.type] ?? RouteTypeEnums_1.MPVRouteTypesEnum.OTHER;
|
|
20
|
+
}
|
|
21
|
+
function mapTram(route) {
|
|
22
|
+
if (route.is_substitute_transport) {
|
|
23
|
+
return RouteTypeEnums_1.MPVRouteTypesEnum.TRAM_SUBSTITUTE;
|
|
24
|
+
}
|
|
25
|
+
if (route.is_night) {
|
|
26
|
+
return RouteTypeEnums_1.MPVRouteTypesEnum.TRAM_NIGHT;
|
|
27
|
+
}
|
|
28
|
+
return RouteTypeEnums_1.MPVRouteTypesEnum.TRAM;
|
|
29
|
+
}
|
|
30
|
+
function mapBus(route) {
|
|
31
|
+
if (route.is_substitute_transport) {
|
|
32
|
+
return RouteTypeEnums_1.MPVRouteTypesEnum.BUS_SUBSTITUTE;
|
|
33
|
+
}
|
|
34
|
+
if (route.is_regional && route.is_night) {
|
|
35
|
+
return RouteTypeEnums_1.MPVRouteTypesEnum.BUS_NIGHT_REGIONAL;
|
|
36
|
+
}
|
|
37
|
+
if (route.is_regional) {
|
|
38
|
+
return RouteTypeEnums_1.MPVRouteTypesEnum.BUS_REGIONAL;
|
|
39
|
+
}
|
|
40
|
+
if (route.is_night) {
|
|
41
|
+
return RouteTypeEnums_1.MPVRouteTypesEnum.BUS_NIGHT;
|
|
42
|
+
}
|
|
43
|
+
return RouteTypeEnums_1.MPVRouteTypesEnum.BUS_CITY;
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=MpvnetTransportTypeMapper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MpvnetTransportTypeMapper.js","sourceRoot":"","sources":["../../../../src/output-gateway/pid/helpers/MpvnetTransportTypeMapper.ts"],"names":[],"mappings":";;AAiBA,4CAUC;AA3BD,oEAA+E;AAS/E,MAAM,eAAe,GAA0D;IAC3E,CAAC,kCAAiB,CAAC,KAAK,CAAC,EAAE,kCAAiB,CAAC,KAAK;IAClD,CAAC,kCAAiB,CAAC,KAAK,CAAC,EAAE,kCAAiB,CAAC,KAAK;IAClD,CAAC,kCAAiB,CAAC,UAAU,CAAC,EAAE,kCAAiB,CAAC,UAAU;IAC5D,CAAC,kCAAiB,CAAC,KAAK,CAAC,EAAE,kCAAiB,CAAC,KAAK;IAClD,CAAC,kCAAiB,CAAC,SAAS,CAAC,EAAE,kCAAiB,CAAC,SAAS;CAC7D,CAAC;AAEF,SAAgB,gBAAgB,CAAC,KAA0B;IACvD,IAAI,KAAK,CAAC,IAAI,KAAK,kCAAiB,CAAC,IAAI,EAAE,CAAC;QACxC,OAAO,OAAO,CAAC,KAAK,CAAC,CAAC;IAC1B,CAAC;IAED,IAAI,KAAK,CAAC,IAAI,KAAK,kCAAiB,CAAC,GAAG,EAAE,CAAC;QACvC,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;IACzB,CAAC;IAED,OAAO,eAAe,CAAC,KAAK,CAAC,IAAyB,CAAC,IAAI,kCAAiB,CAAC,KAAK,CAAC;AACvF,CAAC;AAED,SAAS,OAAO,CAAC,KAA0B;IACvC,IAAI,KAAK,CAAC,uBAAuB,EAAE,CAAC;QAChC,OAAO,kCAAiB,CAAC,eAAe,CAAC;IAC7C,CAAC;IAED,IAAI,KAAK,CAAC,QAAQ,EAAE,CAAC;QACjB,OAAO,kCAAiB,CAAC,UAAU,CAAC;IACxC,CAAC;IAED,OAAO,kCAAiB,CAAC,IAAI,CAAC;AAClC,CAAC;AAED,SAAS,MAAM,CAAC,KAA0B;IACtC,IAAI,KAAK,CAAC,uBAAuB,EAAE,CAAC;QAChC,OAAO,kCAAiB,CAAC,cAAc,CAAC;IAC5C,CAAC;IAED,IAAI,KAAK,CAAC,WAAW,IAAI,KAAK,CAAC,QAAQ,EAAE,CAAC;QACtC,OAAO,kCAAiB,CAAC,kBAAkB,CAAC;IAChD,CAAC;IAED,IAAI,KAAK,CAAC,WAAW,EAAE,CAAC;QACpB,OAAO,kCAAiB,CAAC,YAAY,CAAC;IAC1C,CAAC;IAED,IAAI,KAAK,CAAC,QAAQ,EAAE,CAAC;QACjB,OAAO,kCAAiB,CAAC,SAAS,CAAC;IACvC,CAAC;IAED,OAAO,kCAAiB,CAAC,QAAQ,CAAC;AACtC,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { DepartureBoardsResponseDTO } from "../dto/DepartureBoardsDTO";
|
|
2
|
+
export declare class MpvnetXmlSerializer {
|
|
3
|
+
private static readonly builder;
|
|
4
|
+
static serialize(dto: DepartureBoardsResponseDTO): string;
|
|
5
|
+
private static buildStopNode;
|
|
6
|
+
private static buildDeparture;
|
|
7
|
+
private static buildInfotext;
|
|
8
|
+
private static formatTblCas;
|
|
9
|
+
private static formatScheduledOffset;
|
|
10
|
+
private static formatHeadsign;
|
|
11
|
+
private static extractTrainNumber;
|
|
12
|
+
private static formatPlatformListCsv;
|
|
13
|
+
private static formatPlatformListTab;
|
|
14
|
+
private static collectPlatformCodes;
|
|
15
|
+
private static formatStopIds;
|
|
16
|
+
}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.MpvnetXmlSerializer = void 0;
|
|
7
|
+
const fast_xml_builder_1 = __importDefault(require("fast-xml-builder"));
|
|
8
|
+
const moment_timezone_1 = __importDefault(require("@golemio/core/dist/shared/moment-timezone"));
|
|
9
|
+
const InfotextDisplayTypeEnum_1 = require("../domain/InfotextDisplayTypeEnum");
|
|
10
|
+
const HeadsignFormatter_1 = require("../service/helpers/HeadsignFormatter");
|
|
11
|
+
const MpvnetTransportTypeMapper_1 = require("./MpvnetTransportTypeMapper");
|
|
12
|
+
const PRAGUE_TIMEZONE = "Europe/Prague";
|
|
13
|
+
const ARROW_UNICODE = /→/g;
|
|
14
|
+
const ARROW_ASCII = "->";
|
|
15
|
+
const ISO_LOCAL_FORMAT = "YYYY-MM-DDTHH:mm:ss";
|
|
16
|
+
const ISO_LOCAL_OFFSET_FORMAT = "YYYY-MM-DDTHH:mm:ssZ";
|
|
17
|
+
// Omit > from escapes so the literal "->" arrow (mapped from unicode →) survives in the smer attribute.
|
|
18
|
+
const XML_ENTITIES_KEEP_GT = [
|
|
19
|
+
{ regex: /&/g, val: "&" },
|
|
20
|
+
{ regex: /</g, val: "<" },
|
|
21
|
+
{ regex: /'/g, val: "'" },
|
|
22
|
+
{ regex: /"/g, val: """ },
|
|
23
|
+
];
|
|
24
|
+
class MpvnetXmlSerializer {
|
|
25
|
+
static serialize(dto) {
|
|
26
|
+
const tree = {
|
|
27
|
+
TBL: {
|
|
28
|
+
"@_cas": MpvnetXmlSerializer.formatTblCas(new Date()),
|
|
29
|
+
"@_text": "Odjezdy poskytuje Golemio",
|
|
30
|
+
t: MpvnetXmlSerializer.buildStopNode(dto),
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
return MpvnetXmlSerializer.builder.build(tree);
|
|
34
|
+
}
|
|
35
|
+
static buildStopNode(dto) {
|
|
36
|
+
const node = {
|
|
37
|
+
"@_id": MpvnetXmlSerializer.formatStopIds(dto.stops),
|
|
38
|
+
"@_zast": dto.stops[0]?.stop_name ?? "",
|
|
39
|
+
"@_zobraz_stan": "True",
|
|
40
|
+
"@_stan": MpvnetXmlSerializer.formatPlatformListCsv(dto.stops),
|
|
41
|
+
};
|
|
42
|
+
if (dto.departures.length > 0) {
|
|
43
|
+
node.o = dto.departures.map((d) => MpvnetXmlSerializer.buildDeparture(d));
|
|
44
|
+
}
|
|
45
|
+
if (dto.infotexts.length > 0) {
|
|
46
|
+
node.i = dto.infotexts.map((info) => MpvnetXmlSerializer.buildInfotext(info, dto.stops));
|
|
47
|
+
}
|
|
48
|
+
return node;
|
|
49
|
+
}
|
|
50
|
+
static buildDeparture(departure) {
|
|
51
|
+
const lin = departure.route.short_name ?? "";
|
|
52
|
+
const dd = String((0, MpvnetTransportTypeMapper_1.mapTransportType)({
|
|
53
|
+
type: departure.route.type,
|
|
54
|
+
is_night: departure.route.is_night,
|
|
55
|
+
is_regional: departure.route.is_regional,
|
|
56
|
+
is_substitute_transport: departure.route.is_substitute_transport,
|
|
57
|
+
}));
|
|
58
|
+
const out = {};
|
|
59
|
+
if (departure.stop.platform_code) {
|
|
60
|
+
out["@_stan"] = departure.stop.platform_code;
|
|
61
|
+
}
|
|
62
|
+
out["@_lin"] = lin;
|
|
63
|
+
out["@_alias"] = lin;
|
|
64
|
+
out["@_spoj"] = MpvnetXmlSerializer.extractTrainNumber(departure.trip.short_name);
|
|
65
|
+
out["@_smer"] = MpvnetXmlSerializer.formatHeadsign(departure.trip.headsign);
|
|
66
|
+
out["@_odj"] = MpvnetXmlSerializer.formatScheduledOffset(departure.departure_timestamp.scheduled);
|
|
67
|
+
out["@_sled"] = String(departure.delay.is_available);
|
|
68
|
+
out["@_zpoz"] = String(departure.delay.minutes ?? 0);
|
|
69
|
+
out["@_np"] = String(departure.trip.is_wheelchair_accessible ?? false);
|
|
70
|
+
out["@_nad"] = String(departure.route.is_substitute_transport);
|
|
71
|
+
if (departure.trip.is_canceled) {
|
|
72
|
+
out["@_info"] = "nejede";
|
|
73
|
+
}
|
|
74
|
+
if (departure.trip.is_at_stop) {
|
|
75
|
+
out["@_blik"] = "true";
|
|
76
|
+
}
|
|
77
|
+
if (departure.last_stop.name) {
|
|
78
|
+
out["@_pz"] = departure.last_stop.name;
|
|
79
|
+
}
|
|
80
|
+
out["@_dd"] = dd;
|
|
81
|
+
return out;
|
|
82
|
+
}
|
|
83
|
+
static buildInfotext(infotext, stops) {
|
|
84
|
+
const stan = MpvnetXmlSerializer.formatPlatformListTab(stops);
|
|
85
|
+
if (infotext.display_type === InfotextDisplayTypeEnum_1.InfotextDisplayType.General) {
|
|
86
|
+
return { "@_stan": stan, "@_global": "true", "@_ds": "GLOBAL_STATIC", "#text": infotext.text };
|
|
87
|
+
}
|
|
88
|
+
return { "@_stan": stan, "#text": infotext.text };
|
|
89
|
+
}
|
|
90
|
+
static formatTblCas(date) {
|
|
91
|
+
return moment_timezone_1.default.tz(date, PRAGUE_TIMEZONE).format(ISO_LOCAL_FORMAT);
|
|
92
|
+
}
|
|
93
|
+
static formatScheduledOffset(isoString) {
|
|
94
|
+
if (!isoString) {
|
|
95
|
+
return "";
|
|
96
|
+
}
|
|
97
|
+
return moment_timezone_1.default.tz(isoString, PRAGUE_TIMEZONE).format(ISO_LOCAL_OFFSET_FORMAT);
|
|
98
|
+
}
|
|
99
|
+
// Strip the airport pictogram (HeadsignFormatter) and replace the unicode arrow with ASCII for legacy MPVnet panels.
|
|
100
|
+
static formatHeadsign(headsign) {
|
|
101
|
+
return HeadsignFormatter_1.HeadsignFormatter.format(headsign).replace(ARROW_UNICODE, ARROW_ASCII);
|
|
102
|
+
}
|
|
103
|
+
// Trip number is the last numeric run of trip.short_name (e.g. "S9 1234" -> "1234", "1234" -> "1234").
|
|
104
|
+
static extractTrainNumber(shortName) {
|
|
105
|
+
return shortName?.match(/\d+/g)?.pop() ?? "";
|
|
106
|
+
}
|
|
107
|
+
static formatPlatformListCsv(stops) {
|
|
108
|
+
return MpvnetXmlSerializer.collectPlatformCodes(stops).join(",");
|
|
109
|
+
}
|
|
110
|
+
static formatPlatformListTab(stops) {
|
|
111
|
+
return MpvnetXmlSerializer.collectPlatformCodes(stops).join("\t");
|
|
112
|
+
}
|
|
113
|
+
static collectPlatformCodes(stops) {
|
|
114
|
+
const codes = stops.map((s) => s.platform_code ?? "").filter((c) => c.length > 0);
|
|
115
|
+
return [...new Set(codes)].sort();
|
|
116
|
+
}
|
|
117
|
+
static formatStopIds(stops) {
|
|
118
|
+
const ids = stops.map((s) => {
|
|
119
|
+
if (s.asw_id && s.asw_id.node != null && s.asw_id.stop != null) {
|
|
120
|
+
return `${s.asw_id.node}/${s.asw_id.stop}`;
|
|
121
|
+
}
|
|
122
|
+
return s.stop_id;
|
|
123
|
+
});
|
|
124
|
+
return [...new Set(ids)].sort().join(",");
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
exports.MpvnetXmlSerializer = MpvnetXmlSerializer;
|
|
128
|
+
MpvnetXmlSerializer.builder = new fast_xml_builder_1.default({
|
|
129
|
+
ignoreAttributes: false,
|
|
130
|
+
attributeNamePrefix: "@_",
|
|
131
|
+
suppressEmptyNode: true,
|
|
132
|
+
suppressBooleanAttributes: false,
|
|
133
|
+
format: false,
|
|
134
|
+
processEntities: true,
|
|
135
|
+
entities: XML_ENTITIES_KEEP_GT,
|
|
136
|
+
});
|
|
137
|
+
//# sourceMappingURL=MpvnetXmlSerializer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MpvnetXmlSerializer.js","sourceRoot":"","sources":["../../../../src/output-gateway/pid/helpers/MpvnetXmlSerializer.ts"],"names":[],"mappings":";;;;;;AAAA,wEAAiE;AACjE,gGAA+D;AAK/D,+EAA6E;AAC7E,4EAA8E;AAC9E,2EAA+D;AAE/D,MAAM,eAAe,GAAG,eAAe,CAAC;AACxC,MAAM,aAAa,GAAG,IAAI,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KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,aAAa,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;QAClF,OAAO,CAAC,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;IACtC,CAAC;IAEO,MAAM,CAAC,aAAa,CAAC,KAA8B;QACvD,MAAM,GAAG,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE;YACxB,IAAI,CAAC,CAAC,MAAM,IAAI,CAAC,CAAC,MAAM,CAAC,IAAI,IAAI,IAAI,IAAI,CAAC,CAAC,MAAM,CAAC,IAAI,IAAI,IAAI,EAAE,CAAC;gBAC7D,OAAO,GAAG,CAAC,CAAC,MAAM,CAAC,IAAI,IAAI,CAAC,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;YAC/C,CAAC;YACD,OAAO,CAAC,CAAC,OAAO,CAAC;QACrB,CAAC,CAAC,CAAC;QACH,OAAO,CAAC,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC9C,CAAC;;AA3IL,kDA4IC;AA3I2B,2BAAO,GAAG,IAAI,0BAAU,CAAC;IAC7C,gBAAgB,EAAE,KAAK;IACvB,mBAAmB,EAAE,IAAI;IACzB,iBAAiB,EAAE,IAAI;IACvB,yBAAyB,EAAE,KAAK;IAChC,MAAM,EAAE,KAAK;IACb,eAAe,EAAE,IAAI;IACrB,QAAQ,EAAE,oBAAoB;CACZ,CAAC,CAAC"}
|
|
@@ -64,6 +64,9 @@ class V2PIDRouter extends AbstractRouter_1.AbstractRouter {
|
|
|
64
64
|
this.router.get("/departureboards", validation, ...this.commonMiddleware("PIDDepartureBoards"), Validation_1.checkErrors,
|
|
65
65
|
// max-age 5 seconds, stale-while-revalidate 5 seconds
|
|
66
66
|
this.cacheHeaderMiddleware.getMiddleware(5, 5), this.departureBoardsController.getDepartureBoard);
|
|
67
|
+
this.router.get("/departureboards/xml", validation, ...this.commonMiddleware("PIDDepartureBoardsXml"), Validation_1.checkErrors,
|
|
68
|
+
// max-age 5 seconds, stale-while-revalidate 5 seconds
|
|
69
|
+
this.cacheHeaderMiddleware.getMiddleware(5, 5), this.departureBoardsController.getDepartureBoardXml);
|
|
67
70
|
};
|
|
68
71
|
this.commonMiddleware = (name) => [(0, Validation_1.paginationLimitMiddleware)(name)];
|
|
69
72
|
this.cacheHeaderMiddleware = ioc_1.OutputGatewayContainer.resolve(ioc_1.ContainerToken.CacheHeaderMiddleware);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"V2PIDRouter.js","sourceRoot":"","sources":["../../../../../src/output-gateway/pid/routers/v2/V2PIDRouter.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kGAAiG;AACjG,+EAA8E;AAC9E,yDAAsE;AACtE,sFAAmF;AAEnF,6EAAsG;AACtG,+DAA+F;AAC/F,+DAA2D;AAC3D,mFAA2E;AAC3E,6CAA8G;AAE9G,MAAa,WAAY,SAAQ,+BAAc;IAK3C;QACI,KAAK,CAAC,wBAAY,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC;QALlB,WAAM,GAAW,IAAA,gBAAM,GAAE,CAAC;QAWhC,eAAU,GAAG,GAAS,EAAE;YAC9B,IAAI,CAAC,6BAA6B,EAAE,CAAC;QACzC,CAAC,CAAC;QAEM,kCAA6B,GAAG,GAAG,EAAE;YACzC,MAAM,EACF,iBAAiB,EACjB,eAAe,EAAE,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,GAC1D,GAAG,4BAAgB,CAAC;YACrB,MAAM,UAAU,GAAG;gBACf,IAAA,yBAAK,EAAC,QAAQ,CAAC,CAAC,QAAQ,EAAE;gBAC1B,IAAA,y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,4BAAsB,CAAC,OAAO,CAAwB,oBAAc,CAAC,qBAAqB,CAAC,CAAC;QACzH,IAAI,CAAC,yBAAyB,GAAG,IAAI,yDAA2B,EAAE,CAAC;QACnE,IAAI,CAAC,UAAU,EAAE,CAAC;IACtB,CAAC;CA0EJ;AApFD,kCAoFC;AAED,MAAM,WAAW,GAAmB,IAAI,WAAW,EAAE,CAAC;AAC7C,kCAAW"}
|
package/docs/openapi-output.yaml
CHANGED
|
@@ -887,77 +887,16 @@ paths:
|
|
|
887
887
|
tags:
|
|
888
888
|
- 🚏 PID Departure Boards (v2)
|
|
889
889
|
parameters:
|
|
890
|
-
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
required: false
|
|
901
|
-
schema:
|
|
902
|
-
type: string
|
|
903
|
-
example: "458_101"
|
|
904
|
-
- name: cisIds
|
|
905
|
-
in: query
|
|
906
|
-
description: Get result by CIS ID. A list of CIS IDs can be found in [Prague Open data](https://opendata.praha.eu/datasets/https%3A%2F%2Fapi.opendata.praha.eu%2Flod%2Fcatalog%2F6ac8381f-ea19-4ea9-8949-92076809dc5a).
|
|
907
|
-
required: false
|
|
908
|
-
schema:
|
|
909
|
-
type: number
|
|
910
|
-
example: 28004
|
|
911
|
-
- name: names
|
|
912
|
-
in: query
|
|
913
|
-
description: Get results by exact name of stop (case and whitespace sensitive). May return stops of the same name from different towns. Using `names` in combination with other identifiers will return an intersection of stops with `names` and stops of ASW, CIS or GTFS identifiers in the same node. Use this feature to filter out a subset of stops of the same name while guaranteeing them to be from the desired node only.
|
|
914
|
-
required: false
|
|
915
|
-
schema:
|
|
916
|
-
type: string
|
|
917
|
-
example: "Smíchovské nádraží"
|
|
918
|
-
- name: minutesBefore
|
|
919
|
-
in: query
|
|
920
|
-
description: Set the start of interval from which to retrieve departures. Positive numbers are set in past relative to the time of request or `timeFrom` timestamp, negative numbers set the start in the future. Use to compensate for walking distance to a stop. Default is set to 0. Maximum value is 30 because of implemented data retention. Minimum value is -4320 (0 - 3 days GTFS calendar maximum).
|
|
921
|
-
required: false
|
|
922
|
-
schema:
|
|
923
|
-
type: number
|
|
924
|
-
example: 10
|
|
925
|
-
- name: minutesAfter
|
|
926
|
-
in: query
|
|
927
|
-
description: Set the end of interval from which to retrieve departures. Positive numbers are set in future relative to the time of request or `timeFrom` timestamp, negative are in the past. The sum of minutesBefore and minutesAfter must be larger than zero. Default is set to 180. Maximum value is 4320 (GTFS calendar maximum). Minimum value is -4350 (0 - 3 days GTFS calendar maximum - 30 minutes data retention).
|
|
928
|
-
required: false
|
|
929
|
-
schema:
|
|
930
|
-
type: number
|
|
931
|
-
example: 60
|
|
932
|
-
- name: timeFrom
|
|
933
|
-
in: query
|
|
934
|
-
description: Set initial timestamp for time interval given by `minutesBefore` and `minutesAfter`. Use to simulate query time different from now. Use ISO 8601 time format and URL encoded symbols - `%3A` for `:`, `%2B` for `.`, `%2F` for `+`. Time zone is set according to the `preferredTimezone` parameter. Applicable range is -6 hours +2 days from now.
|
|
935
|
-
required: false
|
|
936
|
-
schema:
|
|
937
|
-
type: string
|
|
938
|
-
example: "2021-01-21T06:00:00"
|
|
939
|
-
- name: includeMetroTrains
|
|
940
|
-
in: query
|
|
941
|
-
description: "When selecting a node by `name`, when `true`, will include metro and/or train stops that are a member of the same node. I.e. when querying _Na Knížecí_, setting this to `true` will add the metro station _Anděl_ to results as well because both have the same ASW node number 1040. ⚠️ Note: combination with `aswIds` is currently not supported, see [issue pid#222](https://gitlab.com/operator-ict/golemio/code/modules/pid/-/issues/222)."
|
|
942
|
-
required: false
|
|
943
|
-
schema:
|
|
944
|
-
type: boolean
|
|
945
|
-
example: true
|
|
946
|
-
- name: airCondition
|
|
947
|
-
in: query
|
|
948
|
-
description: Enrich departures with vehicle air condition information. Setting to `false` will force all items to be `null`. Useful for disabling the indication of air condition during cold season.
|
|
949
|
-
required: false
|
|
950
|
-
schema:
|
|
951
|
-
type: boolean
|
|
952
|
-
example: true
|
|
953
|
-
default: true
|
|
954
|
-
- name: preferredTimezone
|
|
955
|
-
in: query
|
|
956
|
-
description: Preferred timezone offset as defined in the IANA Time zone database in the form of Country/City (use an URL encoded slash sign `%2F` or use an underscore _ symbol), default is Europe/Prague
|
|
957
|
-
required: false
|
|
958
|
-
schema:
|
|
959
|
-
type: string
|
|
960
|
-
example: "Europe_Prague"
|
|
890
|
+
- $ref: "#/components/parameters/DepartureBoardsIds"
|
|
891
|
+
- $ref: "#/components/parameters/DepartureBoardsAswIds"
|
|
892
|
+
- $ref: "#/components/parameters/DepartureBoardsCisIds"
|
|
893
|
+
- $ref: "#/components/parameters/DepartureBoardsNames"
|
|
894
|
+
- $ref: "#/components/parameters/DepartureBoardsMinutesBefore"
|
|
895
|
+
- $ref: "#/components/parameters/DepartureBoardsMinutesAfter"
|
|
896
|
+
- $ref: "#/components/parameters/DepartureBoardsTimeFrom"
|
|
897
|
+
- $ref: "#/components/parameters/DepartureBoardsIncludeMetroTrains"
|
|
898
|
+
- $ref: "#/components/parameters/DepartureBoardsAirCondition"
|
|
899
|
+
- $ref: "#/components/parameters/DepartureBoardsPreferredTimezone"
|
|
961
900
|
- name: mode
|
|
962
901
|
in: query
|
|
963
902
|
description: >-
|
|
@@ -966,72 +905,13 @@ paths:
|
|
|
966
905
|
schema:
|
|
967
906
|
type: string
|
|
968
907
|
example: "departures"
|
|
969
|
-
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
example: "real"
|
|
977
|
-
- name: filter
|
|
978
|
-
in: query
|
|
979
|
-
description: >-
|
|
980
|
-
Valid entries: `none` (default), `routeOnce`, `routeOnceFill`, `routeHeadingOnce`, `routeHeadingOnceFill`, `routeHeadingOnceNoGap`, `routeHeadingOnceNoGapFill`. Defines how should be the list of departures returned. `none` returns all departures within the time and item limit. `routeOnce` returns exactly one occurence of departure for each `route_id`. Works best when querying a single stop. `routeHeadingOnce` returns one entry for each pair of `route_id` and `trip_headsign`, i.e. returns departures for routes that have multiple end stops. Works well when quering one or more stops in a node. `...NoGap` will ensure that departures with a distinct trip headsign will not be displayed if they should arrive too far in the future. `...Fill` attributes will behave the same as their namesakes but afterwards will fill the rest of request up to `total/limit` with further departures. Use to have every line/destination represented and have the display filled with departures at the same time.
|
|
981
|
-
required: false
|
|
982
|
-
schema:
|
|
983
|
-
type: string
|
|
984
|
-
example: "routeOnce"
|
|
985
|
-
- name: skip
|
|
986
|
-
in: query
|
|
987
|
-
description: |
|
|
988
|
-
Filters out trips matching the given states.
|
|
989
|
-
Multiple filters can be applied using array syntax, e.g., `&skip[]=canceled&skip[]=atStop`.
|
|
990
|
-
Using both `untracked` and `missing` will exclude all untracked vehicles, as missing vehicles are a subset of untracked vehicles.
|
|
991
|
-
We recommend using `missing` instead of `untracked`, as skipping all untracked vehicles may result in departures not appearing in the API response until the last few minutes before departure, especially for departure boards near the starting station/stop.
|
|
992
|
-
required: false
|
|
993
|
-
schema:
|
|
994
|
-
type: string
|
|
995
|
-
example: "canceled"
|
|
996
|
-
enum:
|
|
997
|
-
- canceled
|
|
998
|
-
- atStop
|
|
999
|
-
- untracked
|
|
1000
|
-
- missing
|
|
1001
|
-
- name: limit
|
|
1002
|
-
in: query
|
|
1003
|
-
description: Limits the number of items in response. The maximum is 1000 (default value is 20).
|
|
1004
|
-
required: false
|
|
1005
|
-
schema:
|
|
1006
|
-
type: number
|
|
1007
|
-
format: int64
|
|
1008
|
-
example: 0
|
|
1009
|
-
- name: total
|
|
1010
|
-
in: query
|
|
1011
|
-
description: Sets the number of items that will be queried. Use in conjunction with `offset`. Up to `total - offset`, but not more than `limit` items will be then returned. If unset, is same as `limit`. The maximum is 1000 (default value is 20).
|
|
1012
|
-
required: false
|
|
1013
|
-
schema:
|
|
1014
|
-
type: number
|
|
1015
|
-
format: int64
|
|
1016
|
-
example: 0
|
|
1017
|
-
- name: offset
|
|
1018
|
-
in: query
|
|
1019
|
-
description: Number of the initial departures that are skipped. Useful for multi-page displays.
|
|
1020
|
-
required: false
|
|
1021
|
-
schema:
|
|
1022
|
-
type: number
|
|
1023
|
-
format: int64
|
|
1024
|
-
example: 0
|
|
1025
|
-
- name: appendHeadsignsLimit
|
|
1026
|
-
in: query
|
|
1027
|
-
description: >-
|
|
1028
|
-
Number of stops before route switch at which headsign is enriched with continuation info.
|
|
1029
|
-
When set and a departure has route-switch data, headsign becomes `<headsign> → <next_route> <next_headsign>`.
|
|
1030
|
-
required: false
|
|
1031
|
-
schema:
|
|
1032
|
-
type: integer
|
|
1033
|
-
minimum: 0
|
|
1034
|
-
example: 3
|
|
908
|
+
- $ref: "#/components/parameters/DepartureBoardsOrder"
|
|
909
|
+
- $ref: "#/components/parameters/DepartureBoardsFilter"
|
|
910
|
+
- $ref: "#/components/parameters/DepartureBoardsSkip"
|
|
911
|
+
- $ref: "#/components/parameters/DepartureBoardsLimit"
|
|
912
|
+
- $ref: "#/components/parameters/DepartureBoardsTotal"
|
|
913
|
+
- $ref: "#/components/parameters/DepartureBoardsOffset"
|
|
914
|
+
- $ref: "#/components/parameters/DepartureBoardsAppendHeadsignsLimit"
|
|
1035
915
|
|
|
1036
916
|
responses:
|
|
1037
917
|
"200":
|
|
@@ -1056,6 +936,89 @@ paths:
|
|
|
1056
936
|
"404":
|
|
1057
937
|
description: Not found
|
|
1058
938
|
|
|
939
|
+
/v2/pid/departureboards/xml:
|
|
940
|
+
get:
|
|
941
|
+
summary: "[DEPRECATED] GET Departure Boards (legacy MPVnet XML)"
|
|
942
|
+
description: |
|
|
943
|
+
**DEPRECATED.** Legacy MPVnet XML for ROPID information panels that cannot consume JSON.
|
|
944
|
+
For new integrations use `/v2/pid/departureboards` (JSON).
|
|
945
|
+
|
|
946
|
+
UTF-8, no `<?xml ...?>` prologue. Only `mode=departures` is supported (others return 400).
|
|
947
|
+
Same query parameters and identifier rules as the JSON endpoint
|
|
948
|
+
(`ids` / `cisIds` / `aswIds` / `names`, at least one required, max 100 stops).
|
|
949
|
+
|
|
950
|
+
See the example response below for the exact attribute set.
|
|
951
|
+
deprecated: true
|
|
952
|
+
tags:
|
|
953
|
+
- 🚏 PID Departure Boards (v2)
|
|
954
|
+
parameters:
|
|
955
|
+
- $ref: "#/components/parameters/DepartureBoardsIds"
|
|
956
|
+
- $ref: "#/components/parameters/DepartureBoardsAswIds"
|
|
957
|
+
- $ref: "#/components/parameters/DepartureBoardsCisIds"
|
|
958
|
+
- $ref: "#/components/parameters/DepartureBoardsNames"
|
|
959
|
+
- $ref: "#/components/parameters/DepartureBoardsMinutesBefore"
|
|
960
|
+
- $ref: "#/components/parameters/DepartureBoardsMinutesAfter"
|
|
961
|
+
- $ref: "#/components/parameters/DepartureBoardsTimeFrom"
|
|
962
|
+
- $ref: "#/components/parameters/DepartureBoardsIncludeMetroTrains"
|
|
963
|
+
- $ref: "#/components/parameters/DepartureBoardsAirCondition"
|
|
964
|
+
- $ref: "#/components/parameters/DepartureBoardsPreferredTimezone"
|
|
965
|
+
- name: mode
|
|
966
|
+
in: query
|
|
967
|
+
description: >-
|
|
968
|
+
Only `departures` is supported for this XML endpoint; other values return 400.
|
|
969
|
+
Valid entries: `departures` (default), `arrivals`, `mixed`.
|
|
970
|
+
required: false
|
|
971
|
+
schema:
|
|
972
|
+
type: string
|
|
973
|
+
example: "departures"
|
|
974
|
+
- $ref: "#/components/parameters/DepartureBoardsOrder"
|
|
975
|
+
- $ref: "#/components/parameters/DepartureBoardsFilter"
|
|
976
|
+
- $ref: "#/components/parameters/DepartureBoardsSkip"
|
|
977
|
+
- $ref: "#/components/parameters/DepartureBoardsLimit"
|
|
978
|
+
- $ref: "#/components/parameters/DepartureBoardsTotal"
|
|
979
|
+
- $ref: "#/components/parameters/DepartureBoardsOffset"
|
|
980
|
+
- $ref: "#/components/parameters/DepartureBoardsAppendHeadsignsLimit"
|
|
981
|
+
|
|
982
|
+
responses:
|
|
983
|
+
"200":
|
|
984
|
+
description: |
|
|
985
|
+
Single-line MPVnet XML response. Example body
|
|
986
|
+
|
|
987
|
+
```xml
|
|
988
|
+
<TBL cas="2026-03-20T15:30:00" text="Odjezdy poskytuje Golemio">
|
|
989
|
+
<t id="458/1,458/2" zast="Smíchovské nádraží" zobraz_stan="True" stan="A,B">
|
|
990
|
+
<o stan="A" lin="129" alias="129" spoj="" smer="Baně"
|
|
991
|
+
odj="2026-03-20T15:31:00+01:00" sled="true" zpoz="0" np="true" nad="false" dd="3"/>
|
|
992
|
+
<o stan="A" lin="5" alias="5" spoj="" smer="Slivenec"
|
|
993
|
+
odj="2026-03-20T15:31:00+01:00" sled="true" zpoz="2" np="false" nad="false"
|
|
994
|
+
pz="Plzeňka" dd="2"/>
|
|
995
|
+
<o stan="B" lin="B" alias="B" spoj="" smer="Černý Most"
|
|
996
|
+
odj="2026-03-20T15:32:00+01:00" sled="true" zpoz="1" np="true" nad="false"
|
|
997
|
+
pz="Radlická" dd="1"/>
|
|
998
|
+
<o stan="A" lin="X22" alias="X22" spoj="" smer="Nádraží Hostivař"
|
|
999
|
+
odj="2026-03-20T15:33:00+01:00" sled="false" zpoz="0" np="false" nad="true"
|
|
1000
|
+
info="nejede" dd="7"/>
|
|
1001
|
+
<i stan="A">Výluka tramvají na Smíchově.</i>
|
|
1002
|
+
</t>
|
|
1003
|
+
</TBL>
|
|
1004
|
+
```
|
|
1005
|
+
headers:
|
|
1006
|
+
Cache-Control:
|
|
1007
|
+
description: Cache control directive for caching proxies
|
|
1008
|
+
schema:
|
|
1009
|
+
type: string
|
|
1010
|
+
example: public, s-maxage=5, stale-while-revalidate=5
|
|
1011
|
+
content:
|
|
1012
|
+
text/xml; charset=utf-8:
|
|
1013
|
+
schema:
|
|
1014
|
+
type: string
|
|
1015
|
+
"400":
|
|
1016
|
+
$ref: "#/components/responses/BadRequestError"
|
|
1017
|
+
"401":
|
|
1018
|
+
$ref: "#/components/responses/UnauthorizedError"
|
|
1019
|
+
"404":
|
|
1020
|
+
description: Not found
|
|
1021
|
+
|
|
1059
1022
|
/v3/pid/transferboards:
|
|
1060
1023
|
get:
|
|
1061
1024
|
tags:
|
|
@@ -2071,6 +2034,162 @@ components:
|
|
|
2071
2034
|
- error_status
|
|
2072
2035
|
|
|
2073
2036
|
|
|
2037
|
+
parameters:
|
|
2038
|
+
DepartureBoardsIds:
|
|
2039
|
+
name: ids
|
|
2040
|
+
in: query
|
|
2041
|
+
description: Get result by GTFS stop_id. Can be used to retrive individual stops and to separate departures of Prague and intercity routes, even if they depart from the same physical stop. A list of GTFS stops can be found in `stops.txt` file of the [GTFS feed](https://opendata.praha.eu/datasets/https%3A%2F%2Fapi.opendata.praha.eu%2Flod%2Fcatalog%2F9a6a1d8e-45b9-41de-b9ae-0bcec7126876).
|
|
2042
|
+
required: false
|
|
2043
|
+
schema:
|
|
2044
|
+
type: string
|
|
2045
|
+
example: "U458Z101P"
|
|
2046
|
+
DepartureBoardsAswIds:
|
|
2047
|
+
name: aswIds
|
|
2048
|
+
in: query
|
|
2049
|
+
description: "Get result by ASW ID. First part of the number represents the whole node. Usually it groups the stops of the same name or all stops associated with a metro station. Also returns related train stations in the node. The second part of the number is optional and represents individual stops in the node. Use `_` instead of `/` as a separator or encode the slash sign with `%2F`. A list of ASW IDs can be found in [Prague Open data](https://opendata.praha.eu/datasets/https%3A%2F%2Fapi.opendata.praha.eu%2Flod%2Fcatalog%2F6ac8381f-ea19-4ea9-8949-92076809dc5a). ⚠️ Note: combination with `includeMetroTrains` is currently not supported, see [issue pid#222](https://gitlab.com/operator-ict/golemio/code/modules/pid/-/issues/222)."
|
|
2050
|
+
required: false
|
|
2051
|
+
schema:
|
|
2052
|
+
type: string
|
|
2053
|
+
example: "458_101"
|
|
2054
|
+
DepartureBoardsCisIds:
|
|
2055
|
+
name: cisIds
|
|
2056
|
+
in: query
|
|
2057
|
+
description: Get result by CIS ID. A list of CIS IDs can be found in [Prague Open data](https://opendata.praha.eu/datasets/https%3A%2F%2Fapi.opendata.praha.eu%2Flod%2Fcatalog%2F6ac8381f-ea19-4ea9-8949-92076809dc5a).
|
|
2058
|
+
required: false
|
|
2059
|
+
schema:
|
|
2060
|
+
type: number
|
|
2061
|
+
example: 28004
|
|
2062
|
+
DepartureBoardsNames:
|
|
2063
|
+
name: names
|
|
2064
|
+
in: query
|
|
2065
|
+
description: Get results by exact name of stop (case and whitespace sensitive). May return stops of the same name from different towns. Using `names` in combination with other identifiers will return an intersection of stops with `names` and stops of ASW, CIS or GTFS identifiers in the same node. Use this feature to filter out a subset of stops of the same name while guaranteeing them to be from the desired node only.
|
|
2066
|
+
required: false
|
|
2067
|
+
schema:
|
|
2068
|
+
type: string
|
|
2069
|
+
example: "Smíchovské nádraží"
|
|
2070
|
+
DepartureBoardsMinutesBefore:
|
|
2071
|
+
name: minutesBefore
|
|
2072
|
+
in: query
|
|
2073
|
+
description: Set the start of interval from which to retrieve departures. Positive numbers are set in past relative to the time of request or `timeFrom` timestamp, negative numbers set the start in the future. Use to compensate for walking distance to a stop. Default is set to 0. Maximum value is 30 because of implemented data retention. Minimum value is -4320 (0 - 3 days GTFS calendar maximum).
|
|
2074
|
+
required: false
|
|
2075
|
+
schema:
|
|
2076
|
+
type: number
|
|
2077
|
+
example: 10
|
|
2078
|
+
DepartureBoardsMinutesAfter:
|
|
2079
|
+
name: minutesAfter
|
|
2080
|
+
in: query
|
|
2081
|
+
description: Set the end of interval from which to retrieve departures. Positive numbers are set in future relative to the time of request or `timeFrom` timestamp, negative are in the past. The sum of minutesBefore and minutesAfter must be larger than zero. Default is set to 180. Maximum value is 4320 (GTFS calendar maximum). Minimum value is -4350 (0 - 3 days GTFS calendar maximum - 30 minutes data retention).
|
|
2082
|
+
required: false
|
|
2083
|
+
schema:
|
|
2084
|
+
type: number
|
|
2085
|
+
example: 60
|
|
2086
|
+
DepartureBoardsTimeFrom:
|
|
2087
|
+
name: timeFrom
|
|
2088
|
+
in: query
|
|
2089
|
+
description: Set initial timestamp for time interval given by `minutesBefore` and `minutesAfter`. Use to simulate query time different from now. Use ISO 8601 time format and URL encoded symbols - `%3A` for `:`, `%2B` for `.`, `%2F` for `+`. Time zone is set according to the `preferredTimezone` parameter. Applicable range is -6 hours +2 days from now.
|
|
2090
|
+
required: false
|
|
2091
|
+
schema:
|
|
2092
|
+
type: string
|
|
2093
|
+
example: "2021-01-21T06:00:00"
|
|
2094
|
+
DepartureBoardsIncludeMetroTrains:
|
|
2095
|
+
name: includeMetroTrains
|
|
2096
|
+
in: query
|
|
2097
|
+
description: "When selecting a node by `name`, when `true`, will include metro and/or train stops that are a member of the same node. I.e. when querying _Na Knížecí_, setting this to `true` will add the metro station _Anděl_ to results as well because both have the same ASW node number 1040. ⚠️ Note: combination with `aswIds` is currently not supported, see [issue pid#222](https://gitlab.com/operator-ict/golemio/code/modules/pid/-/issues/222)."
|
|
2098
|
+
required: false
|
|
2099
|
+
schema:
|
|
2100
|
+
type: boolean
|
|
2101
|
+
example: true
|
|
2102
|
+
DepartureBoardsAirCondition:
|
|
2103
|
+
name: airCondition
|
|
2104
|
+
in: query
|
|
2105
|
+
description: Enrich departures with vehicle air condition information. Setting to `false` will force all items to be `null`. Useful for disabling the indication of air condition during cold season.
|
|
2106
|
+
required: false
|
|
2107
|
+
schema:
|
|
2108
|
+
type: boolean
|
|
2109
|
+
example: true
|
|
2110
|
+
default: true
|
|
2111
|
+
DepartureBoardsPreferredTimezone:
|
|
2112
|
+
name: preferredTimezone
|
|
2113
|
+
in: query
|
|
2114
|
+
description: Preferred timezone offset as defined in the IANA Time zone database in the form of Country/City (use an URL encoded slash sign `%2F` or use an underscore _ symbol), default is Europe/Prague
|
|
2115
|
+
required: false
|
|
2116
|
+
schema:
|
|
2117
|
+
type: string
|
|
2118
|
+
example: "Europe_Prague"
|
|
2119
|
+
DepartureBoardsOrder:
|
|
2120
|
+
name: order
|
|
2121
|
+
in: query
|
|
2122
|
+
description: >-
|
|
2123
|
+
Valid entries: `real` (default), `timetable`. Order results by predicted time including trip delay or by timetable time.
|
|
2124
|
+
required: false
|
|
2125
|
+
schema:
|
|
2126
|
+
type: string
|
|
2127
|
+
example: "real"
|
|
2128
|
+
DepartureBoardsFilter:
|
|
2129
|
+
name: filter
|
|
2130
|
+
in: query
|
|
2131
|
+
description: >-
|
|
2132
|
+
Valid entries: `none` (default), `routeOnce`, `routeOnceFill`, `routeHeadingOnce`, `routeHeadingOnceFill`, `routeHeadingOnceNoGap`, `routeHeadingOnceNoGapFill`. Defines how should be the list of departures returned. `none` returns all departures within the time and item limit. `routeOnce` returns exactly one occurence of departure for each `route_id`. Works best when querying a single stop. `routeHeadingOnce` returns one entry for each pair of `route_id` and `trip_headsign`, i.e. returns departures for routes that have multiple end stops. Works well when quering one or more stops in a node. `...NoGap` will ensure that departures with a distinct trip headsign will not be displayed if they should arrive too far in the future. `...Fill` attributes will behave the same as their namesakes but afterwards will fill the rest of request up to `total/limit` with further departures. Use to have every line/destination represented and have the display filled with departures at the same time.
|
|
2133
|
+
required: false
|
|
2134
|
+
schema:
|
|
2135
|
+
type: string
|
|
2136
|
+
example: "routeOnce"
|
|
2137
|
+
DepartureBoardsSkip:
|
|
2138
|
+
name: skip
|
|
2139
|
+
in: query
|
|
2140
|
+
description: |
|
|
2141
|
+
Filters out trips matching the given states.
|
|
2142
|
+
Multiple filters can be applied using array syntax, e.g., `&skip[]=canceled&skip[]=atStop`.
|
|
2143
|
+
Using both `untracked` and `missing` will exclude all untracked vehicles, as missing vehicles are a subset of untracked vehicles.
|
|
2144
|
+
We recommend using `missing` instead of `untracked`, as skipping all untracked vehicles may result in departures not appearing in the API response until the last few minutes before departure, especially for departure boards near the starting station/stop.
|
|
2145
|
+
required: false
|
|
2146
|
+
schema:
|
|
2147
|
+
type: string
|
|
2148
|
+
example: "canceled"
|
|
2149
|
+
enum:
|
|
2150
|
+
- canceled
|
|
2151
|
+
- atStop
|
|
2152
|
+
- untracked
|
|
2153
|
+
- missing
|
|
2154
|
+
DepartureBoardsLimit:
|
|
2155
|
+
name: limit
|
|
2156
|
+
in: query
|
|
2157
|
+
description: Limits the number of items in response. The maximum is 1000 (default value is 20).
|
|
2158
|
+
required: false
|
|
2159
|
+
schema:
|
|
2160
|
+
type: number
|
|
2161
|
+
format: int64
|
|
2162
|
+
example: 0
|
|
2163
|
+
DepartureBoardsTotal:
|
|
2164
|
+
name: total
|
|
2165
|
+
in: query
|
|
2166
|
+
description: Sets the number of items that will be queried. Use in conjunction with `offset`. Up to `total - offset`, but not more than `limit` items will be then returned. If unset, is same as `limit`. The maximum is 1000 (default value is 20).
|
|
2167
|
+
required: false
|
|
2168
|
+
schema:
|
|
2169
|
+
type: number
|
|
2170
|
+
format: int64
|
|
2171
|
+
example: 0
|
|
2172
|
+
DepartureBoardsOffset:
|
|
2173
|
+
name: offset
|
|
2174
|
+
in: query
|
|
2175
|
+
description: Number of the initial departures that are skipped. Useful for multi-page displays.
|
|
2176
|
+
required: false
|
|
2177
|
+
schema:
|
|
2178
|
+
type: number
|
|
2179
|
+
format: int64
|
|
2180
|
+
example: 0
|
|
2181
|
+
DepartureBoardsAppendHeadsignsLimit:
|
|
2182
|
+
name: appendHeadsignsLimit
|
|
2183
|
+
in: query
|
|
2184
|
+
description: >-
|
|
2185
|
+
Number of stops before route switch at which headsign is enriched with continuation info.
|
|
2186
|
+
When set and a departure has route-switch data, headsign becomes `<headsign> → <next_route> <next_headsign>`.
|
|
2187
|
+
required: false
|
|
2188
|
+
schema:
|
|
2189
|
+
type: integer
|
|
2190
|
+
minimum: 0
|
|
2191
|
+
example: 3
|
|
2192
|
+
|
|
2074
2193
|
schemas:
|
|
2075
2194
|
RepeatOnlyTimes:
|
|
2076
2195
|
title: Repeat Only Times
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@golemio/pid",
|
|
3
|
-
"version": "5.9.3-dev.
|
|
3
|
+
"version": "5.9.3-dev.2497470687",
|
|
4
4
|
"description": "Golemio PID Module",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -80,20 +80,13 @@
|
|
|
80
80
|
"peerDependencies": {
|
|
81
81
|
"@golemio/core": "^3.0.7-dev.2 || ^3.0.0"
|
|
82
82
|
},
|
|
83
|
-
"overrides": {
|
|
84
|
-
"@google-cloud/storage": {
|
|
85
|
-
"fast-xml-parser": "^5.3.4"
|
|
86
|
-
},
|
|
87
|
-
"@azure/core-xml": {
|
|
88
|
-
"fast-xml-parser": "^5.3.4"
|
|
89
|
-
}
|
|
90
|
-
},
|
|
91
83
|
"dependencies": {
|
|
92
84
|
"@golemio/ovapi-gtfs-realtime-bindings": "1.4.0",
|
|
93
85
|
"@turf/turf": "^6.5.0",
|
|
94
86
|
"cheap-ruler": "^3.0.2",
|
|
95
87
|
"csv-parser": "^3.0.0",
|
|
96
88
|
"csv-stringify": "^5.6.2",
|
|
89
|
+
"fast-xml-builder": "^1.1.5",
|
|
97
90
|
"html-entities": "^2.6.0",
|
|
98
91
|
"pg-copy-streams": "^7.0.0"
|
|
99
92
|
}
|