@golemio/pid 2.14.2 → 2.14.3-dev.1364165620
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/migrations/postgresql/20240612135256-fix-delay-in-view-future-stop-times.js +53 -0
- package/db/migrations/postgresql/20240701093122-fix-delay-in-view-v-public-vehiclepositions-past-stop-times.js +53 -0
- package/db/migrations/postgresql/sqls/20240612135256-fix-delay-in-view-future-stop-times-down.sql +82 -0
- package/db/migrations/postgresql/sqls/20240612135256-fix-delay-in-view-future-stop-times-up.sql +93 -0
- package/db/migrations/postgresql/sqls/20240701093122-fix-delay-in-view-v-public-vehiclepositions-past-stop-times-down.sql +31 -0
- package/db/migrations/postgresql/sqls/20240701093122-fix-delay-in-view-v-public-vehiclepositions-past-stop-times-up.sql +38 -0
- package/dist/integration-engine/vehicle-positions/workers/runs/helpers/regional-bus/RegionalBusMessageFilter.d.ts +1 -4
- package/dist/integration-engine/vehicle-positions/workers/runs/helpers/regional-bus/RegionalBusMessageFilter.js +11 -27
- package/dist/integration-engine/vehicle-positions/workers/runs/helpers/regional-bus/RegionalBusMessageFilter.js.map +1 -1
- package/dist/integration-engine/vehicle-positions/workers/vehicle-positions/transformations/MpvMessageTransformation.d.ts +3 -6
- package/dist/integration-engine/vehicle-positions/workers/vehicle-positions/transformations/MpvMessageTransformation.js +8 -19
- package/dist/integration-engine/vehicle-positions/workers/vehicle-positions/transformations/MpvMessageTransformation.js.map +1 -1
- package/dist/output-gateway/public/routers/v1/PublicDeparturesRouter.js +1 -1
- package/dist/output-gateway/public/routers/v1/helpers/CustomStopIdGroupValidator.d.ts +1 -0
- package/dist/output-gateway/public/routers/v1/helpers/CustomStopIdGroupValidator.js +38 -16
- package/dist/output-gateway/public/routers/v1/helpers/CustomStopIdGroupValidator.js.map +1 -1
- package/docs/openapi-output.yaml +4 -2
- package/package.json +2 -2
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var dbm;
|
|
4
|
+
var type;
|
|
5
|
+
var seed;
|
|
6
|
+
var fs = require('fs');
|
|
7
|
+
var path = require('path');
|
|
8
|
+
var Promise;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* We receive the dbmigrate dependency from dbmigrate initially.
|
|
12
|
+
* This enables us to not have to rely on NODE_PATH.
|
|
13
|
+
*/
|
|
14
|
+
exports.setup = function(options, seedLink) {
|
|
15
|
+
dbm = options.dbmigrate;
|
|
16
|
+
type = dbm.dataType;
|
|
17
|
+
seed = seedLink;
|
|
18
|
+
Promise = options.Promise;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
exports.up = function(db) {
|
|
22
|
+
var filePath = path.join(__dirname, 'sqls', '20240612135256-fix-delay-in-view-future-stop-times-up.sql');
|
|
23
|
+
return new Promise( function( resolve, reject ) {
|
|
24
|
+
fs.readFile(filePath, {encoding: 'utf-8'}, function(err,data){
|
|
25
|
+
if (err) return reject(err);
|
|
26
|
+
console.log('received data: ' + data);
|
|
27
|
+
|
|
28
|
+
resolve(data);
|
|
29
|
+
});
|
|
30
|
+
})
|
|
31
|
+
.then(function(data) {
|
|
32
|
+
return db.runSql(data);
|
|
33
|
+
});
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
exports.down = function(db) {
|
|
37
|
+
var filePath = path.join(__dirname, 'sqls', '20240612135256-fix-delay-in-view-future-stop-times-down.sql');
|
|
38
|
+
return new Promise( function( resolve, reject ) {
|
|
39
|
+
fs.readFile(filePath, {encoding: 'utf-8'}, function(err,data){
|
|
40
|
+
if (err) return reject(err);
|
|
41
|
+
console.log('received data: ' + data);
|
|
42
|
+
|
|
43
|
+
resolve(data);
|
|
44
|
+
});
|
|
45
|
+
})
|
|
46
|
+
.then(function(data) {
|
|
47
|
+
return db.runSql(data);
|
|
48
|
+
});
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
exports._meta = {
|
|
52
|
+
"version": 1
|
|
53
|
+
};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var dbm;
|
|
4
|
+
var type;
|
|
5
|
+
var seed;
|
|
6
|
+
var fs = require('fs');
|
|
7
|
+
var path = require('path');
|
|
8
|
+
var Promise;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* We receive the dbmigrate dependency from dbmigrate initially.
|
|
12
|
+
* This enables us to not have to rely on NODE_PATH.
|
|
13
|
+
*/
|
|
14
|
+
exports.setup = function(options, seedLink) {
|
|
15
|
+
dbm = options.dbmigrate;
|
|
16
|
+
type = dbm.dataType;
|
|
17
|
+
seed = seedLink;
|
|
18
|
+
Promise = options.Promise;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
exports.up = function(db) {
|
|
22
|
+
var filePath = path.join(__dirname, 'sqls', '20240701093122-fix-delay-in-view-v-public-vehiclepositions-past-stop-times-up.sql');
|
|
23
|
+
return new Promise( function( resolve, reject ) {
|
|
24
|
+
fs.readFile(filePath, {encoding: 'utf-8'}, function(err,data){
|
|
25
|
+
if (err) return reject(err);
|
|
26
|
+
console.log('received data: ' + data);
|
|
27
|
+
|
|
28
|
+
resolve(data);
|
|
29
|
+
});
|
|
30
|
+
})
|
|
31
|
+
.then(function(data) {
|
|
32
|
+
return db.runSql(data);
|
|
33
|
+
});
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
exports.down = function(db) {
|
|
37
|
+
var filePath = path.join(__dirname, 'sqls', '20240701093122-fix-delay-in-view-v-public-vehiclepositions-past-stop-times-down.sql');
|
|
38
|
+
return new Promise( function( resolve, reject ) {
|
|
39
|
+
fs.readFile(filePath, {encoding: 'utf-8'}, function(err,data){
|
|
40
|
+
if (err) return reject(err);
|
|
41
|
+
console.log('received data: ' + data);
|
|
42
|
+
|
|
43
|
+
resolve(data);
|
|
44
|
+
});
|
|
45
|
+
})
|
|
46
|
+
.then(function(data) {
|
|
47
|
+
return db.runSql(data);
|
|
48
|
+
});
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
exports._meta = {
|
|
52
|
+
"version": 1
|
|
53
|
+
};
|
package/db/migrations/postgresql/sqls/20240612135256-fix-delay-in-view-future-stop-times-down.sql
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
-- v_public_vehiclepositions_future_stop_times source
|
|
2
|
+
CREATE OR REPLACE VIEW v_public_vehiclepositions_future_stop_times AS
|
|
3
|
+
WITH RECURSIVE stop_times AS (
|
|
4
|
+
SELECT
|
|
5
|
+
rst.trip_id,
|
|
6
|
+
vt.id AS trips_id,
|
|
7
|
+
vt.provider_source_type,
|
|
8
|
+
vp.delay,
|
|
9
|
+
COALESCE(vp.last_stop_sequence, 1) AS initial_stop_sequence,
|
|
10
|
+
vp.state_position,
|
|
11
|
+
rst.stop_id,
|
|
12
|
+
rst.stop_sequence,
|
|
13
|
+
rst.computed_dwell_time_seconds,
|
|
14
|
+
CASE WHEN vp.last_stop_sequence IS NULL THEN
|
|
15
|
+
vp.delay
|
|
16
|
+
ELSE
|
|
17
|
+
vp.delay_stop_arrival
|
|
18
|
+
END AS arrival_delay_seconds,
|
|
19
|
+
CASE WHEN vp.last_stop_sequence IS NULL THEN
|
|
20
|
+
predict_delay_seconds(vp.delay, rst.computed_dwell_time_seconds, vt.provider_source_type)
|
|
21
|
+
WHEN vp.state_position::text = 'at_stop'::text THEN
|
|
22
|
+
CASE WHEN vt.provider_source_type::text = '1'::text THEN
|
|
23
|
+
GREATEST(0, vp.delay)
|
|
24
|
+
ELSE
|
|
25
|
+
vp.delay
|
|
26
|
+
END
|
|
27
|
+
ELSE
|
|
28
|
+
vp.delay_stop_departure
|
|
29
|
+
END AS departure_delay_seconds
|
|
30
|
+
FROM
|
|
31
|
+
ropidgtfs_stop_times rst
|
|
32
|
+
JOIN vehiclepositions_trips vt ON vt.gtfs_trip_id::text = rst.trip_id::text
|
|
33
|
+
JOIN vehiclepositions_positions vp ON vp.id = vt.last_position_id
|
|
34
|
+
AND (vp.valid_to IS NULL
|
|
35
|
+
OR vp.valid_to >= now())
|
|
36
|
+
AND (vp.state_position::text = ANY (ARRAY['on_track'::character varying::text,
|
|
37
|
+
'at_stop'::character varying::text,
|
|
38
|
+
'before_track'::character varying::text,
|
|
39
|
+
'before_track_delayed'::character varying::text]))
|
|
40
|
+
WHERE
|
|
41
|
+
vt.gtfs_trip_id IS NOT NULL
|
|
42
|
+
AND rst.stop_sequence = COALESCE(vp.last_stop_sequence, 1)
|
|
43
|
+
UNION ALL
|
|
44
|
+
SELECT
|
|
45
|
+
rst.trip_id,
|
|
46
|
+
previous_row.trips_id,
|
|
47
|
+
previous_row.provider_source_type,
|
|
48
|
+
previous_row.delay,
|
|
49
|
+
previous_row.initial_stop_sequence,
|
|
50
|
+
previous_row.state_position,
|
|
51
|
+
rst.stop_id,
|
|
52
|
+
rst.stop_sequence,
|
|
53
|
+
rst.computed_dwell_time_seconds,
|
|
54
|
+
CASE WHEN (rst.stop_sequence - previous_row.initial_stop_sequence) = 1
|
|
55
|
+
AND previous_row.state_position::text <> 'at_stop'::text THEN
|
|
56
|
+
previous_row.delay
|
|
57
|
+
ELSE
|
|
58
|
+
previous_row.departure_delay_seconds
|
|
59
|
+
END AS arrival_delay_seconds,
|
|
60
|
+
predict_delay_seconds(
|
|
61
|
+
CASE WHEN (rst.stop_sequence - previous_row.initial_stop_sequence) = 1
|
|
62
|
+
AND previous_row.state_position::text <> 'at_stop'::text THEN
|
|
63
|
+
previous_row.delay
|
|
64
|
+
ELSE
|
|
65
|
+
previous_row.departure_delay_seconds
|
|
66
|
+
END, rst.computed_dwell_time_seconds, previous_row.provider_source_type) AS departure_delay_seconds
|
|
67
|
+
FROM
|
|
68
|
+
stop_times previous_row
|
|
69
|
+
JOIN ropidgtfs_stop_times rst ON rst.trip_id::text = previous_row.trip_id::text
|
|
70
|
+
AND rst.stop_sequence =(previous_row.stop_sequence + 1))
|
|
71
|
+
SELECT
|
|
72
|
+
stop_times.trips_id AS rt_trip_id,
|
|
73
|
+
stop_times.stop_sequence,
|
|
74
|
+
COALESCE(stop_times.arrival_delay_seconds, 0) AS stop_arr_delay,
|
|
75
|
+
COALESCE(stop_times.departure_delay_seconds, 0) AS stop_dep_delay,
|
|
76
|
+
stop_times.stop_id
|
|
77
|
+
FROM
|
|
78
|
+
stop_times
|
|
79
|
+
ORDER BY
|
|
80
|
+
stop_times.trip_id,
|
|
81
|
+
stop_times.stop_sequence;
|
|
82
|
+
|
package/db/migrations/postgresql/sqls/20240612135256-fix-delay-in-view-future-stop-times-up.sql
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
CREATE OR REPLACE VIEW v_public_vehiclepositions_future_stop_times AS
|
|
2
|
+
WITH RECURSIVE stop_times AS (
|
|
3
|
+
SELECT
|
|
4
|
+
rst.trip_id,
|
|
5
|
+
vt.id AS trips_id,
|
|
6
|
+
vt.provider_source_type,
|
|
7
|
+
coalesce(vp.delay, 0) AS delay,
|
|
8
|
+
coalesce(vp.last_stop_sequence, 1) AS initial_stop_sequence,
|
|
9
|
+
vp.state_position,
|
|
10
|
+
rst.stop_id,
|
|
11
|
+
rst.stop_sequence,
|
|
12
|
+
rst.computed_dwell_time_seconds,
|
|
13
|
+
rst.arrival_time,
|
|
14
|
+
rst.departure_time,
|
|
15
|
+
CASE WHEN vp.last_stop_sequence IS NULL THEN
|
|
16
|
+
coalesce(vp.delay, 0)
|
|
17
|
+
ELSE
|
|
18
|
+
coalesce(vp.delay_stop_arrival, 0)
|
|
19
|
+
END AS arrival_delay_seconds,
|
|
20
|
+
CASE WHEN vp.last_stop_sequence IS NULL THEN
|
|
21
|
+
predict_delay_seconds(vp.delay, rst.computed_dwell_time_seconds, vt.provider_source_type)
|
|
22
|
+
WHEN vp.state_position::text = 'at_stop'::text THEN
|
|
23
|
+
CASE WHEN vt.provider_source_type::text = '1'::text THEN
|
|
24
|
+
greatest(0, vp.delay)
|
|
25
|
+
ELSE
|
|
26
|
+
vp.delay
|
|
27
|
+
END
|
|
28
|
+
ELSE
|
|
29
|
+
vp.delay_stop_departure
|
|
30
|
+
END AS departure_delay_seconds
|
|
31
|
+
FROM
|
|
32
|
+
ropidgtfs_stop_times rst
|
|
33
|
+
JOIN vehiclepositions_trips vt ON vt.gtfs_trip_id::text = rst.trip_id::text
|
|
34
|
+
JOIN vehiclepositions_positions vp ON vp.id = vt.last_position_id
|
|
35
|
+
AND (vp.valid_to IS NULL
|
|
36
|
+
OR vp.valid_to >= now())
|
|
37
|
+
AND (vp.state_position::text = ANY (ARRAY['on_track'::character varying::text,
|
|
38
|
+
'at_stop'::character varying::text,
|
|
39
|
+
'before_track'::character varying::text,
|
|
40
|
+
'before_track_delayed'::character varying::text]))
|
|
41
|
+
WHERE
|
|
42
|
+
vt.gtfs_trip_id IS NOT NULL
|
|
43
|
+
AND rst.stop_sequence = coalesce(vp.last_stop_sequence, 1)
|
|
44
|
+
UNION ALL
|
|
45
|
+
SELECT
|
|
46
|
+
rst.trip_id,
|
|
47
|
+
previous_row.trips_id,
|
|
48
|
+
previous_row.provider_source_type,
|
|
49
|
+
previous_row.delay,
|
|
50
|
+
previous_row.initial_stop_sequence,
|
|
51
|
+
previous_row.state_position,
|
|
52
|
+
rst.stop_id,
|
|
53
|
+
rst.stop_sequence,
|
|
54
|
+
rst.computed_dwell_time_seconds,
|
|
55
|
+
rst.arrival_time,
|
|
56
|
+
rst.departure_time,
|
|
57
|
+
CASE WHEN (rst.stop_sequence - previous_row.initial_stop_sequence) = 1
|
|
58
|
+
AND previous_row.state_position::text <> 'at_stop'::text THEN
|
|
59
|
+
CASE WHEN (rst.arrival_time::time +(interval '1 second' * previous_row.delay) < previous_row.departure_time::time +(interval '1 second' *(previous_row.departure_delay_seconds))) THEN
|
|
60
|
+
NULL
|
|
61
|
+
ELSE
|
|
62
|
+
previous_row.delay
|
|
63
|
+
END
|
|
64
|
+
ELSE
|
|
65
|
+
previous_row.departure_delay_seconds
|
|
66
|
+
END AS arrival_delay_seconds,
|
|
67
|
+
predict_delay_seconds(
|
|
68
|
+
CASE WHEN (rst.stop_sequence - previous_row.initial_stop_sequence) = 1
|
|
69
|
+
AND previous_row.state_position::text <> 'at_stop'::text THEN
|
|
70
|
+
previous_row.delay
|
|
71
|
+
ELSE
|
|
72
|
+
previous_row.departure_delay_seconds
|
|
73
|
+
END, rst.computed_dwell_time_seconds, previous_row.provider_source_type) AS departure_delay_seconds
|
|
74
|
+
FROM
|
|
75
|
+
stop_times previous_row
|
|
76
|
+
JOIN ropidgtfs_stop_times rst ON rst.trip_id::text = previous_row.trip_id::text
|
|
77
|
+
AND rst.stop_sequence =(previous_row.stop_sequence + 1))
|
|
78
|
+
SELECT
|
|
79
|
+
stop_times.trips_id AS rt_trip_id,
|
|
80
|
+
stop_times.stop_sequence,
|
|
81
|
+
stop_times.arrival_delay_seconds AS stop_arr_delay,
|
|
82
|
+
CASE WHEN (stop_times.arrival_time::time +(interval '1 second' * coalesce(stop_times.arrival_delay_seconds, 0))) >(stop_times.departure_time::time +(interval '1 second' * coalesce(stop_times.departure_delay_seconds, 0))) THEN
|
|
83
|
+
NULL
|
|
84
|
+
ELSE
|
|
85
|
+
stop_times.departure_delay_seconds
|
|
86
|
+
END AS stop_dep_delay,
|
|
87
|
+
stop_times.stop_id
|
|
88
|
+
FROM
|
|
89
|
+
stop_times
|
|
90
|
+
ORDER BY
|
|
91
|
+
stop_times.trip_id,
|
|
92
|
+
stop_times.stop_sequence;
|
|
93
|
+
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
CREATE OR REPLACE VIEW v_public_vehiclepositions_past_stop_times AS
|
|
2
|
+
SELECT
|
|
3
|
+
sub.trips_id AS rt_trip_id,
|
|
4
|
+
sub.last_stop_sequence AS stop_sequence,
|
|
5
|
+
sub.stop_arr_delay,
|
|
6
|
+
sub.stop_dep_delay,
|
|
7
|
+
sub.last_stop_id AS stop_id
|
|
8
|
+
FROM (
|
|
9
|
+
SELECT
|
|
10
|
+
rt_position.trips_id,
|
|
11
|
+
rt_position.last_stop_id,
|
|
12
|
+
rt_position.last_stop_sequence,
|
|
13
|
+
rt_position.delay_stop_arrival,
|
|
14
|
+
rt_position.delay_stop_departure,
|
|
15
|
+
max(rt_position.delay_stop_arrival) AS stop_arr_delay,
|
|
16
|
+
min(rt_position.delay_stop_departure) AS stop_dep_delay
|
|
17
|
+
FROM
|
|
18
|
+
vehiclepositions_positions rt_position
|
|
19
|
+
WHERE (rt_position.delay_stop_arrival IS NOT NULL
|
|
20
|
+
OR rt_position.delay_stop_departure IS NOT NULL)
|
|
21
|
+
AND (rt_position.state_position::text = ANY (ARRAY['on_track'::character varying::text, 'at_stop'::character varying::text, 'after_track'::character varying::text]))
|
|
22
|
+
GROUP BY
|
|
23
|
+
rt_position.trips_id,
|
|
24
|
+
rt_position.last_stop_id,
|
|
25
|
+
rt_position.last_stop_sequence,
|
|
26
|
+
rt_position.delay_stop_arrival,
|
|
27
|
+
rt_position.delay_stop_departure) sub
|
|
28
|
+
ORDER BY
|
|
29
|
+
sub.trips_id,
|
|
30
|
+
sub.last_stop_sequence;
|
|
31
|
+
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
CREATE OR REPLACE VIEW v_public_vehiclepositions_past_stop_times AS
|
|
2
|
+
SELECT
|
|
3
|
+
sub.trips_id AS rt_trip_id,
|
|
4
|
+
sub.last_stop_sequence AS stop_sequence,
|
|
5
|
+
sub.stop_arr_delay,
|
|
6
|
+
sub.stop_dep_delay,
|
|
7
|
+
sub.last_stop_id AS stop_id
|
|
8
|
+
FROM (
|
|
9
|
+
SELECT
|
|
10
|
+
rt_position.trips_id,
|
|
11
|
+
rt_position.last_stop_id,
|
|
12
|
+
rt_position.last_stop_sequence,
|
|
13
|
+
CASE WHEN (rt_position.last_stop_departure_time::time +(interval '1 second' * min(rt_position.delay_stop_departure)) > rt_position.next_stop_arrival_time::time +(interval '1 second' * max(rt_position.delay_stop_arrival))) THEN
|
|
14
|
+
NULL
|
|
15
|
+
ELSE
|
|
16
|
+
max(rt_position.delay_stop_arrival)
|
|
17
|
+
END AS stop_arr_delay,
|
|
18
|
+
CASE WHEN (rt_position.last_stop_arrival_time::time +(interval '1 second' * max(rt_position.delay_stop_arrival)) > rt_position.last_stop_departure_time::time +(interval '1 second' * min(rt_position.delay_stop_departure))) THEN
|
|
19
|
+
NULL
|
|
20
|
+
ELSE
|
|
21
|
+
min(rt_position.delay_stop_departure)
|
|
22
|
+
END AS stop_dep_delay
|
|
23
|
+
FROM
|
|
24
|
+
vehiclepositions_positions rt_position
|
|
25
|
+
WHERE (rt_position.delay_stop_arrival IS NOT NULL
|
|
26
|
+
OR rt_position.delay_stop_departure IS NOT NULL)
|
|
27
|
+
AND (rt_position.state_position::text = ANY (ARRAY['on_track'::character varying::text, 'at_stop'::character varying::text, 'after_track'::character varying::text]))
|
|
28
|
+
GROUP BY
|
|
29
|
+
rt_position.trips_id,
|
|
30
|
+
rt_position.last_stop_id,
|
|
31
|
+
rt_position.last_stop_sequence,
|
|
32
|
+
rt_position.last_stop_arrival_time,
|
|
33
|
+
rt_position.last_stop_departure_time,
|
|
34
|
+
rt_position.next_stop_arrival_time) sub
|
|
35
|
+
ORDER BY
|
|
36
|
+
sub.trips_id,
|
|
37
|
+
sub.last_stop_sequence;
|
|
38
|
+
|
|
@@ -1,16 +1,13 @@
|
|
|
1
1
|
import { IRegionalBusRunsMessagesModel } from "../../../../../../schema-definitions/vehicle-positions/models/interfaces/IRegionalBusRunsMessagesModel";
|
|
2
|
-
import { ISimpleConfig } from "@golemio/core/dist/helpers/configuration/ISimpleConfig";
|
|
3
2
|
import { ILogger } from "@golemio/core/dist/helpers/logger";
|
|
4
3
|
import { IRegionalBusMessageFilter } from "./interfaces/IRegionalBusMessageFilter";
|
|
5
4
|
import { TimestampValidator } from "../TimestampValidator";
|
|
6
5
|
export declare class RegionalBusMessageFilter implements IRegionalBusMessageFilter {
|
|
7
|
-
private config;
|
|
8
6
|
private logger;
|
|
9
7
|
private timestampValidator;
|
|
10
|
-
constructor(
|
|
8
|
+
constructor(logger: ILogger, timestampValidator: TimestampValidator);
|
|
11
9
|
/**
|
|
12
10
|
* Get messages that are valid for processing
|
|
13
11
|
*/
|
|
14
12
|
getFilteredMessages(messages: IRegionalBusRunsMessagesModel[], timestamp: number): IRegionalBusRunsMessagesModel[];
|
|
15
|
-
private get regNumberWhitelist();
|
|
16
13
|
}
|
|
@@ -19,8 +19,7 @@ const VPContainerToken_1 = require("../../../../ioc/VPContainerToken");
|
|
|
19
19
|
const TimestampValidator_1 = require("../TimestampValidator");
|
|
20
20
|
const golemio_errors_1 = require("@golemio/core/dist/shared/golemio-errors");
|
|
21
21
|
let RegionalBusMessageFilter = exports.RegionalBusMessageFilter = class RegionalBusMessageFilter {
|
|
22
|
-
constructor(
|
|
23
|
-
this.config = config;
|
|
22
|
+
constructor(logger, timestampValidator) {
|
|
24
23
|
this.logger = logger;
|
|
25
24
|
this.timestampValidator = timestampValidator;
|
|
26
25
|
}
|
|
@@ -30,18 +29,13 @@ let RegionalBusMessageFilter = exports.RegionalBusMessageFilter = class Regional
|
|
|
30
29
|
getFilteredMessages(messages, timestamp) {
|
|
31
30
|
let filteredMessages = [];
|
|
32
31
|
for (const message of messages) {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
if (!this.timestampValidator.isTimestampValid(timestamp, message.timestamp)) {
|
|
41
|
-
this.logger.error(new golemio_errors_1.GeneralError(`Message timestamp 'tm' of value ${message.timestamp} is not valid ` +
|
|
42
|
-
`(line ${message.cis_line_id}, trip id ${message.cis_trip_number})`, this.constructor.name, undefined, undefined, "pid"));
|
|
43
|
-
continue;
|
|
44
|
-
}
|
|
32
|
+
const isValidMessage = message.cis_line_id && message.cis_trip_number && message.registration_number && message.events !== "";
|
|
33
|
+
if (!this.timestampValidator.isTimestampValid(timestamp, message.timestamp)) {
|
|
34
|
+
this.logger.error(new golemio_errors_1.GeneralError(`Message timestamp 'tm' of value ${message.timestamp} is not valid ` +
|
|
35
|
+
`(line ${message.cis_line_id}, trip id ${message.cis_trip_number})`, this.constructor.name, undefined, undefined, "pid"));
|
|
36
|
+
continue;
|
|
37
|
+
}
|
|
38
|
+
if (isValidMessage) {
|
|
45
39
|
filteredMessages.push(message);
|
|
46
40
|
}
|
|
47
41
|
}
|
|
@@ -50,21 +44,11 @@ let RegionalBusMessageFilter = exports.RegionalBusMessageFilter = class Regional
|
|
|
50
44
|
}
|
|
51
45
|
return filteredMessages;
|
|
52
46
|
}
|
|
53
|
-
get regNumberWhitelist() {
|
|
54
|
-
const valuePath = "old.datasources.pid.vehicle-positions.regNumberWhitelist.regionalBus";
|
|
55
|
-
const whitelistDict = this.config.getValue(valuePath, {});
|
|
56
|
-
const whitelist = Object.values(whitelistDict);
|
|
57
|
-
if (whitelist[0] !== "*") {
|
|
58
|
-
return whitelist;
|
|
59
|
-
}
|
|
60
|
-
return null;
|
|
61
|
-
}
|
|
62
47
|
};
|
|
63
48
|
exports.RegionalBusMessageFilter = RegionalBusMessageFilter = __decorate([
|
|
64
49
|
(0, tsyringe_1.injectable)(),
|
|
65
|
-
__param(0, (0, tsyringe_1.inject)(CoreToken_1.CoreToken.
|
|
66
|
-
__param(1, (0, tsyringe_1.inject)(
|
|
67
|
-
|
|
68
|
-
__metadata("design:paramtypes", [Object, Object, TimestampValidator_1.TimestampValidator])
|
|
50
|
+
__param(0, (0, tsyringe_1.inject)(CoreToken_1.CoreToken.Logger)),
|
|
51
|
+
__param(1, (0, tsyringe_1.inject)(VPContainerToken_1.VPContainerToken.TimestampValidator)),
|
|
52
|
+
__metadata("design:paramtypes", [Object, TimestampValidator_1.TimestampValidator])
|
|
69
53
|
], RegionalBusMessageFilter);
|
|
70
54
|
//# sourceMappingURL=RegionalBusMessageFilter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RegionalBusMessageFilter.js","sourceRoot":"","sources":["../../../../../../../src/integration-engine/vehicle-positions/workers/runs/helpers/regional-bus/RegionalBusMessageFilter.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"RegionalBusMessageFilter.js","sourceRoot":"","sources":["../../../../../../../src/integration-engine/vehicle-positions/workers/runs/helpers/regional-bus/RegionalBusMessageFilter.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AACA,wEAAqE;AAErE,iEAAwE;AAExE,uEAA8E;AAC9E,8DAA2D;AAC3D,6EAAwE;AAGjE,IAAM,wBAAwB,sCAA9B,MAAM,wBAAwB;IACjC,YACsC,MAAe,EACI,kBAAsC;QADzD,WAAM,GAAN,MAAM,CAAS;QACI,uBAAkB,GAAlB,kBAAkB,CAAoB;IAC5F,CAAC;IAEJ;;OAEG;IACI,mBAAmB,CAAC,QAAyC,EAAE,SAAiB;QACnF,IAAI,gBAAgB,GAAoC,EAAE,CAAC;QAC3D,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE;YAC5B,MAAM,cAAc,GAChB,OAAO,CAAC,WAAW,IAAI,OAAO,CAAC,eAAe,IAAI,OAAO,CAAC,mBAAmB,IAAI,OAAO,CAAC,MAAM,KAAK,EAAE,CAAC;YAC3G,IAAI,CAAC,IAAI,CAAC,kBAAkB,CAAC,gBAAgB,CAAC,SAAS,EAAE,OAAO,CAAC,SAAU,CAAC,EAAE;gBAC1E,IAAI,CAAC,MAAM,CAAC,KAAK,CACb,IAAI,6BAAY,CACZ,mCAAmC,OAAO,CAAC,SAAS,gBAAgB;oBAChE,SAAS,OAAO,CAAC,WAAW,aAAa,OAAO,CAAC,eAAe,GAAG,EACvE,IAAI,CAAC,WAAW,CAAC,IAAI,EACrB,SAAS,EACT,SAAS,EACT,KAAK,CACR,CACJ,CAAC;gBACF,SAAS;aACZ;YAED,IAAI,cAAc,EAAE;gBAChB,gBAAgB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;aAClC;SACJ;QAED,IAAI,gBAAgB,CAAC,MAAM,KAAK,CAAC,EAAE;YAC/B,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,uDAAuD,CAAC,CAAC;SAChF;QAED,OAAO,gBAAgB,CAAC;IAC5B,CAAC;CACJ,CAAA;mCAvCY,wBAAwB;IADpC,IAAA,qBAAU,GAAE;IAGJ,WAAA,IAAA,iBAAM,EAAC,qBAAS,CAAC,MAAM,CAAC,CAAA;IACxB,WAAA,IAAA,iBAAM,EAAC,mCAAgB,CAAC,kBAAkB,CAAC,CAAA;6CAA6B,uCAAkB;GAHtF,wBAAwB,CAuCpC"}
|
|
@@ -3,9 +3,10 @@ import { Moment } from "@golemio/core/dist/shared/moment-timezone";
|
|
|
3
3
|
import { IMpvPositionContent } from "../../../../../schema-definitions/vehicle-positions/interfaces/IMpvMessageInterfaces";
|
|
4
4
|
import { ITransformationElement, ITransformationResult } from "../interfaces/TransformationInterfaces";
|
|
5
5
|
export declare class MpvMessageTransformation extends BaseTransformation implements ITransformation {
|
|
6
|
+
private static ORIGIN_TIME_FORMAT;
|
|
6
7
|
name: string;
|
|
7
8
|
private config;
|
|
8
|
-
private
|
|
9
|
+
private skipAgencyNames;
|
|
9
10
|
constructor();
|
|
10
11
|
/**
|
|
11
12
|
* Overrides BaseTransformation::transform
|
|
@@ -31,6 +32,7 @@ export declare class MpvMessageTransformation extends BaseTransformation impleme
|
|
|
31
32
|
* @returns {number}
|
|
32
33
|
*/
|
|
33
34
|
private checkMidnight;
|
|
35
|
+
private isBlacklistedAgency;
|
|
34
36
|
/**
|
|
35
37
|
* Fix source negative bearing value due to overflow by adding 256
|
|
36
38
|
*
|
|
@@ -45,9 +47,4 @@ export declare class MpvMessageTransformation extends BaseTransformation impleme
|
|
|
45
47
|
* @returns {stringList}
|
|
46
48
|
*/
|
|
47
49
|
private formatASWStopId;
|
|
48
|
-
/**
|
|
49
|
-
* Returns list of vehicle reg numbers that should be excluded from MPVNet processing
|
|
50
|
-
* (already processed from another source)
|
|
51
|
-
*/
|
|
52
|
-
private get regionalBusRegNumberBlacklist();
|
|
53
50
|
}
|
|
@@ -31,6 +31,7 @@ var PositionTrackingEnum;
|
|
|
31
31
|
class MpvMessageTransformation extends transformations_1.BaseTransformation {
|
|
32
32
|
constructor() {
|
|
33
33
|
super();
|
|
34
|
+
this.skipAgencyNames = [DPPUtils_1.default.DPP_AGENCY_NAME];
|
|
34
35
|
/**
|
|
35
36
|
* Overrides BaseTransformation::transform
|
|
36
37
|
*/
|
|
@@ -61,14 +62,9 @@ class MpvMessageTransformation extends transformations_1.BaseTransformation {
|
|
|
61
62
|
this.transformElement = (element) => __awaiter(this, void 0, void 0, function* () {
|
|
62
63
|
var _a, _b;
|
|
63
64
|
const attributes = element.$;
|
|
64
|
-
// DPP and regional bus trips to be excluded in HTTP ingress
|
|
65
|
-
const isDPPTrip = attributes.dopr === DPPUtils_1.default.DPP_AGENCY_NAME;
|
|
66
|
-
const isRegionalBusTrip = !!attributes.vuzevc &&
|
|
67
|
-
this.regionalBusRegNumberBlacklist &&
|
|
68
|
-
this.regionalBusRegNumberBlacklist.includes(attributes.vuzevc);
|
|
69
65
|
// Trips with null cpoz (origin time) and falsy or "false" zrus (cancellation) attributes are excluded
|
|
70
66
|
const hasInvalidAttributes = !attributes.cpoz && (!attributes.zrus || attributes.zrus === "false");
|
|
71
|
-
if (
|
|
67
|
+
if (this.isBlacklistedAgency(attributes.dopr) || hasInvalidAttributes) {
|
|
72
68
|
return null;
|
|
73
69
|
}
|
|
74
70
|
attributes.lin = attributes.lin || "none";
|
|
@@ -233,6 +229,12 @@ class MpvMessageTransformation extends transformations_1.BaseTransformation {
|
|
|
233
229
|
};
|
|
234
230
|
this.name = vehicle_positions_1.VehiclePositions.name;
|
|
235
231
|
this.config = Di_1.IntegrationEngineContainer.resolve(CoreToken_1.CoreToken.SimpleConfig);
|
|
232
|
+
this.skipAgencyNames = this.skipAgencyNames.concat(this.config
|
|
233
|
+
.getValue("module.pid.vehicle-positions.mpvIntegration.skipAgencyNames", "ARRIVA CITY,ARRIVA CITY (Neratovice)")
|
|
234
|
+
.split(","));
|
|
235
|
+
}
|
|
236
|
+
isBlacklistedAgency(agency) {
|
|
237
|
+
return agency && this.skipAgencyNames.includes(agency);
|
|
236
238
|
}
|
|
237
239
|
/**
|
|
238
240
|
* Fix source negative bearing value due to overflow by adding 256
|
|
@@ -255,19 +257,6 @@ class MpvMessageTransformation extends transformations_1.BaseTransformation {
|
|
|
255
257
|
const aswParsedStopPostId = parseInt(stopId, 10) - aswParsedStopNodeId * fixedRightPadFactor;
|
|
256
258
|
return aswParsedStopNodeId + "/" + aswParsedStopPostId;
|
|
257
259
|
}
|
|
258
|
-
/**
|
|
259
|
-
* Returns list of vehicle reg numbers that should be excluded from MPVNet processing
|
|
260
|
-
* (already processed from another source)
|
|
261
|
-
*/
|
|
262
|
-
get regionalBusRegNumberBlacklist() {
|
|
263
|
-
const valuePath = "old.datasources.pid.vehicle-positions.regNumberWhitelist.regionalBus";
|
|
264
|
-
const blacklistDict = this.config.getValue(valuePath, {});
|
|
265
|
-
const blacklist = Object.values(blacklistDict);
|
|
266
|
-
if (blacklist.length > 0 && blacklist[0] !== "*") {
|
|
267
|
-
return blacklist;
|
|
268
|
-
}
|
|
269
|
-
return null;
|
|
270
|
-
}
|
|
271
260
|
}
|
|
272
261
|
exports.MpvMessageTransformation = MpvMessageTransformation;
|
|
273
262
|
MpvMessageTransformation.ORIGIN_TIME_FORMAT = "HH:mm:ss";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MpvMessageTransformation.js","sourceRoot":"","sources":["../../../../../../src/integration-engine/vehicle-positions/workers/vehicle-positions/transformations/MpvMessageTransformation.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2FAA0D;AAG1D,wEAAqE;AACrE,qEAA0F;AAC1F,2FAA4G;AAC5G,gGAA2E;AAC3E,gDAAgE;AAChE,mEAA2C;AAC3C,8EAA2E;AAC3E,oEAAiE;AAGjE,0EAA4D;AAE5D,IAAK,oBAGJ;AAHD,WAAK,oBAAoB;IACrB,0CAAkB,CAAA;IAClB,sCAAc,CAAA;AAClB,CAAC,EAHI,oBAAoB,KAApB,oBAAoB,QAGxB;AAED,MAAa,wBAAyB,SAAQ,oCAAkB;
|
|
1
|
+
{"version":3,"file":"MpvMessageTransformation.js","sourceRoot":"","sources":["../../../../../../src/integration-engine/vehicle-positions/workers/vehicle-positions/transformations/MpvMessageTransformation.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2FAA0D;AAG1D,wEAAqE;AACrE,qEAA0F;AAC1F,2FAA4G;AAC5G,gGAA2E;AAC3E,gDAAgE;AAChE,mEAA2C;AAC3C,8EAA2E;AAC3E,oEAAiE;AAGjE,0EAA4D;AAE5D,IAAK,oBAGJ;AAHD,WAAK,oBAAoB;IACrB,0CAAkB,CAAA;IAClB,sCAAc,CAAA;AAClB,CAAC,EAHI,oBAAoB,KAApB,oBAAoB,QAGxB;AAED,MAAa,wBAAyB,SAAQ,oCAAkB;IAO5D;QACI,KAAK,EAAE,CAAC;QAHJ,oBAAe,GAAG,CAAC,kBAAQ,CAAC,eAAe,CAAC,CAAC;QAgBrD;;WAEG;QACI,cAAS,GAAG,CAAO,IAAiD,EAAkC,EAAE;YAC3G,IAAI,KAAK,GAAG,IAAI,GAAG,EAAqC,CAAC;YACzD,IAAI,KAAK,GAAG,IAAI,GAAG,EAAuB,CAAC;YAC3C,IAAI,GAAG,GAA0B;gBAC7B,SAAS,EAAE,EAAE;gBACb,KAAK,EAAE,EAAE;gBACT,KAAK,EAAE,EAAE;aACZ,CAAC;YAEF,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC;gBAAE,IAAI,GAAG,CAAC,IAAI,CAAC,CAAC;YACxC,KAAK,MAAM,OAAO,IAAI,IAAI,EAAE;gBACxB,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC;gBACrD,IAAI,OAAO,EAAE;oBACT,GAAG,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,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,IAAI,IAAI,CAAC,eAAe,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IAC3D,CAAC;IAED;;;;;OAKG;IACK,wBAAwB,CAAC,OAAe;QAC5C,OAAO,OAAO,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,GAAG,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC;IACjD,CAAC;IAED;;;;;OAKG;IACK,eAAe,CAAC,MAAc;QAClC,MAAM,mBAAmB,GAAG,KAAK,CAAC;QAClC,MAAM,mBAAmB,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,EAAE,EAAE,CAAC,GAAG,mBAAmB,CAAC,CAAC;QACnF,MAAM,mBAAmB,GAAG,QAAQ,CAAC,MAAM,EAAE,EAAE,CAAC,GAAG,mBAAmB,GAAG,mBAAmB,CAAC;QAC7F,OAAO,mBAAmB,GAAG,GAAG,GAAG,mBAAmB,CAAC;IAC3D,CAAC;;AA7QL,4DA8QC;AA7QkB,2CAAkB,GAAG,UAAU,AAAb,CAAc"}
|
|
@@ -18,7 +18,7 @@ class PublicDeparturesRouter {
|
|
|
18
18
|
initRoutes() {
|
|
19
19
|
this.router.get("/", [
|
|
20
20
|
(0, express_validator_1.query)("stopIds").exists().custom(CustomStopIdGroupValidator_1.CustomStopIdGroupValidator.validate),
|
|
21
|
-
(0, express_validator_1.query)("limit").optional().isInt({ min: 1, max:
|
|
21
|
+
(0, express_validator_1.query)("limit").optional().isInt({ min: 1, max: 30 }).not().isArray(),
|
|
22
22
|
(0, express_validator_1.query)("routeShortNames").optional().not().isEmpty({ ignore_whitespace: true }),
|
|
23
23
|
(0, express_validator_1.query)("minutesAfter").optional().isInt({ min: 1, max: 360 }).not().isArray(),
|
|
24
24
|
], Validation_1.checkErrors,
|
|
@@ -2,41 +2,63 @@
|
|
|
2
2
|
var _a;
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.CustomStopIdGroupValidator = void 0;
|
|
5
|
+
const MAX_STOP_GROUPS = 50;
|
|
6
|
+
const MAX_STOPS_IN_GROUP = 50;
|
|
7
|
+
const MAX_STOPS_TOTAL = 50;
|
|
5
8
|
class CustomStopIdGroupValidator {
|
|
6
|
-
static isStopIdGroupValid(
|
|
9
|
+
static isStopIdGroupValid(stopIds) {
|
|
7
10
|
try {
|
|
8
|
-
const parsed = JSON.parse(value);
|
|
9
|
-
const keys = Object.keys(parsed);
|
|
10
|
-
if (keys.length !== 1) {
|
|
11
|
-
return false;
|
|
12
|
-
}
|
|
13
|
-
const priority = Number.parseInt(keys[0]);
|
|
14
|
-
if (Number.isNaN(priority)) {
|
|
15
|
-
return false;
|
|
16
|
-
}
|
|
17
|
-
const stopIds = parsed[priority];
|
|
18
11
|
if (!Array.isArray(stopIds) ||
|
|
19
12
|
stopIds.length === 0 ||
|
|
20
|
-
stopIds.length >
|
|
13
|
+
stopIds.length > MAX_STOPS_IN_GROUP ||
|
|
21
14
|
stopIds.some((stopId) => typeof stopId !== "string" || stopId.length === 0 || stopId.length > 30)) {
|
|
22
15
|
return false;
|
|
23
16
|
}
|
|
24
17
|
return true;
|
|
25
18
|
}
|
|
26
|
-
catch (
|
|
19
|
+
catch (_b) {
|
|
27
20
|
return false;
|
|
28
21
|
}
|
|
29
22
|
}
|
|
23
|
+
static parseStopIdsFromGroup(value) {
|
|
24
|
+
try {
|
|
25
|
+
const parsed = JSON.parse(value);
|
|
26
|
+
const keys = Object.keys(parsed);
|
|
27
|
+
if (keys.length !== 1) {
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
const priority = Number.parseInt(keys[0]);
|
|
31
|
+
if (Number.isNaN(priority)) {
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
return parsed[priority];
|
|
35
|
+
}
|
|
36
|
+
catch (_b) {
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
30
40
|
}
|
|
31
41
|
exports.CustomStopIdGroupValidator = CustomStopIdGroupValidator;
|
|
32
42
|
_a = CustomStopIdGroupValidator;
|
|
33
43
|
CustomStopIdGroupValidator.validate = (value, _) => {
|
|
34
44
|
if (value instanceof Array) {
|
|
35
|
-
if (value.length === 0 || value.length >
|
|
45
|
+
if (value.length === 0 || value.length > MAX_STOP_GROUPS) {
|
|
36
46
|
return false;
|
|
37
47
|
}
|
|
38
|
-
|
|
48
|
+
let stopsTotal = 0;
|
|
49
|
+
for (const stopIdGroup of value) {
|
|
50
|
+
const stopIds = _a.parseStopIdsFromGroup(stopIdGroup);
|
|
51
|
+
if (!_a.isStopIdGroupValid(stopIds)) {
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
stopsTotal += stopIds.length;
|
|
55
|
+
if (stopsTotal > MAX_STOPS_TOTAL) {
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return true;
|
|
39
60
|
}
|
|
40
|
-
|
|
61
|
+
const stopIds = _a.parseStopIdsFromGroup(value);
|
|
62
|
+
return _a.isStopIdGroupValid(stopIds);
|
|
41
63
|
};
|
|
42
64
|
//# sourceMappingURL=CustomStopIdGroupValidator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CustomStopIdGroupValidator.js","sourceRoot":"","sources":["../../../../../../src/output-gateway/public/routers/v1/helpers/CustomStopIdGroupValidator.ts"],"names":[],"mappings":";;;;AAEA,
|
|
1
|
+
{"version":3,"file":"CustomStopIdGroupValidator.js","sourceRoot":"","sources":["../../../../../../src/output-gateway/public/routers/v1/helpers/CustomStopIdGroupValidator.ts"],"names":[],"mappings":";;;;AAEA,MAAM,eAAe,GAAG,EAAE,CAAC;AAC3B,MAAM,kBAAkB,GAAG,EAAE,CAAC;AAC9B,MAAM,eAAe,GAAG,EAAE,CAAC;AAE3B,MAAa,0BAA0B;IA4B3B,MAAM,CAAC,kBAAkB,CAAC,OAAwB;QACtD,IAAI;YACA,IACI,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC;gBAC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qBAAqB,CAAC,WAAW,CAAC,CAAC;YAExD,IAAI,CAAC,EAAI,CAAC,kBAAkB,CAAC,OAAO,CAAC,EAAE;gBACnC,OAAO,KAAK,CAAC;aAChB;YAED,UAAU,IAAI,OAAO,CAAC,MAAM,CAAC;YAC7B,IAAI,UAAU,GAAG,eAAe,EAAE;gBAC9B,OAAO,KAAK,CAAC;aAChB;SACJ;QAED,OAAO,IAAI,CAAC;KACf;IAED,MAAM,OAAO,GAAG,EAAI,CAAC,qBAAqB,CAAC,KAAK,CAAC,CAAC;IAClD,OAAO,EAAI,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC;AAC5C,CAAC,AAzBqB,CAyBpB"}
|
package/docs/openapi-output.yaml
CHANGED
|
@@ -1305,13 +1305,15 @@ paths:
|
|
|
1305
1305
|
items:
|
|
1306
1306
|
type: string
|
|
1307
1307
|
example: ["{\"0\": [\"U717Z5P\"]}", "{\"1\": [\"U718Z5P\", \"U719Z5P\"]}"]
|
|
1308
|
-
description:
|
|
1308
|
+
description: |
|
|
1309
|
+
Groups of stop IDs formatted as JSON (index/priority -> stop IDs). For example ?stopIds[]={\"0\": [\"U717Z5P\"]}&stopIds[]={\"1\": [\"U718Z5P\", \"U719Z5P\"]}.
|
|
1310
|
+
The maximum number of groups is 50. The maximum number of stops in one group is 50. The maximum number of stops combined is 50.
|
|
1309
1311
|
- in: query
|
|
1310
1312
|
name: limit
|
|
1311
1313
|
required: false
|
|
1312
1314
|
schema:
|
|
1313
1315
|
type: integer
|
|
1314
|
-
description: Limit for each group of departures. Default is 5. Maximum is
|
|
1316
|
+
description: Limit for each group of departures. Default is 5. Maximum is 30.
|
|
1315
1317
|
example: 5
|
|
1316
1318
|
- in: query
|
|
1317
1319
|
name: routeShortNames
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@golemio/pid",
|
|
3
|
-
"version": "2.14.
|
|
3
|
+
"version": "2.14.3-dev.1364165620",
|
|
4
4
|
"description": "Golemio PID Module",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -76,7 +76,7 @@
|
|
|
76
76
|
"@golemio/core": ">=1.9.16"
|
|
77
77
|
},
|
|
78
78
|
"dependencies": {
|
|
79
|
-
"@golemio/ovapi-gtfs-realtime-bindings": "1.2.
|
|
79
|
+
"@golemio/ovapi-gtfs-realtime-bindings": "1.2.4-dev.1288219308",
|
|
80
80
|
"@turf/turf": "^6.5.0",
|
|
81
81
|
"cheap-ruler": "^3.0.2",
|
|
82
82
|
"csv-parser": "^3.0.0",
|