update db-hafas-stations
Some checks failed
test / lint-and-spellcheck (push) Has been cancelled
test / unit-tests (18.x) (push) Has been cancelled
test / unit-tests (20.x) (push) Has been cancelled
test / unit-tests (22.x) (push) Has been cancelled
test / integration-tests (18.x) (push) Has been cancelled
test / integration-tests (20.x) (push) Has been cancelled
test / integration-tests (22.x) (push) Has been cancelled
test / e2e-tests (18.x) (push) Has been cancelled

This commit is contained in:
Traines 2025-03-19 00:39:01 +00:00
parent 2ea47f7792
commit b3e0e764e2
4 changed files with 31 additions and 29 deletions

View file

@ -27,25 +27,18 @@ const validateLocation = (loc, name = 'location') => {
} }
}; };
const loadEnrichedStationData = (profile) => new Promise((resolve, reject) => { const loadEnrichedStationData = async (profile) => {
import('db-hafas-stations').then(m => { const dbHafasStations = await import('db-hafas-stations');
const items = {}; const items = {};
m.default.full() for await (const station of dbHafasStations.readFullStations()) {
.on('data', (station) => { items[station.id] = station;
items[station.id] = station; items[station.name] = station;
items[station.name] = station; }
}) if (profile.DEBUG) {
.once('end', () => { console.log('Loaded station index.');
if (profile.DEBUG) { }
console.log('Loaded station index.'); return items;
} };
resolve(items);
})
.once('error', (err) => {
reject(err);
});
});
});
const applyEnrichedStationData = async (ctx, shouldLoadEnrichedStationData) => { const applyEnrichedStationData = async (ctx, shouldLoadEnrichedStationData) => {
const {profile, common} = ctx; const {profile, common} = ctx;

17
package-lock.json generated
View file

@ -1,17 +1,17 @@
{ {
"name": "db-vendo-client", "name": "db-vendo-client",
"version": "6.6.2", "version": "6.7.0",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "db-vendo-client", "name": "db-vendo-client",
"version": "6.6.2", "version": "6.7.0",
"license": "ISC", "license": "ISC",
"dependencies": { "dependencies": {
"content-type": "^1.0.5", "content-type": "^1.0.5",
"cross-fetch": "^4.1.0", "cross-fetch": "^4.1.0",
"db-hafas-stations": "^1.1.0", "db-hafas-stations": "2.0.0",
"gps-distance": "0.0.4", "gps-distance": "0.0.4",
"https-proxy-agent": "^7.0.6", "https-proxy-agent": "^7.0.6",
"luxon": "^3.5.0", "luxon": "^3.5.0",
@ -3447,14 +3447,15 @@
} }
}, },
"node_modules/db-hafas-stations": { "node_modules/db-hafas-stations": {
"version": "1.1.0", "version": "2.0.0",
"resolved": "https://registry.npmjs.org/db-hafas-stations/-/db-hafas-stations-1.1.0.tgz", "resolved": "https://registry.npmjs.org/db-hafas-stations/-/db-hafas-stations-2.0.0.tgz",
"integrity": "sha512-o6NhX3YExhdxd8IA1cfWf1px5nJTym/2hXcnnINgXjSCBmD4ujv/pCUcXZcj8ucozhk5koR2SBgdKhWJpM39pw==", "integrity": "sha512-GjcqpZhs+HeOvc2dnAJs2Uy3/b8zRNlvTfLCvqFe9J2JYOlQVyuYCjjdsPBTOmJol42sPToPs71wr03kTMVJDw==",
"dependencies": { "dependencies": {
"ndjson": "^2.0.0" "ndjson": "^2.0.0",
"qs": "^6.14.0"
}, },
"engines": { "engines": {
"node": ">=14" "node": ">=18"
} }
}, },
"node_modules/db-rest": { "node_modules/db-rest": {

View file

@ -1,7 +1,7 @@
{ {
"name": "db-vendo-client", "name": "db-vendo-client",
"description": "Client for bahn.de public transport APIs.", "description": "Client for bahn.de public transport APIs.",
"version": "6.6.2", "version": "6.7.0",
"type": "module", "type": "module",
"main": "index.js", "main": "index.js",
"files": [ "files": [
@ -60,7 +60,7 @@
"dependencies": { "dependencies": {
"content-type": "^1.0.5", "content-type": "^1.0.5",
"cross-fetch": "^4.1.0", "cross-fetch": "^4.1.0",
"db-hafas-stations": "^1.1.0", "db-hafas-stations": "2.0.0",
"gps-distance": "0.0.4", "gps-distance": "0.0.4",
"https-proxy-agent": "^7.0.6", "https-proxy-agent": "^7.0.6",
"luxon": "^3.5.0", "luxon": "^3.5.0",

View file

@ -78,6 +78,14 @@ const enrichStation = (ctx, stop, locations) => {
...stop, ...stop,
}; };
delete stop.lines; delete stop.lines;
delete stop.facilities;
delete stop.reisezentrumOpeningHours;
if (stop.station) {
stop.station = {...stop.station};
delete stop.station.lines;
delete stop.station.facilities;
delete stop.station.reisezentrumOpeningHours;
}
} }
return stop; return stop;
}; };