From a7cb71c87044fac168022097382cbf919ba394ad Mon Sep 17 00:00:00 2001 From: Jannis R Date: Tue, 26 Oct 2021 14:15:17 +0200 Subject: [PATCH] add todos & comments --- format/stop-req.js | 1 + index.js | 4 +++- lib/default-profile.js | 2 ++ lib/errors.js | 1 + p/db/index.js | 11 +++++++++++ parse/hint.js | 1 + parse/trip.js | 1 + test/e2e/saarfahrplan.js | 6 +++--- 8 files changed, 23 insertions(+), 4 deletions(-) diff --git a/format/stop-req.js b/format/stop-req.js index e44ab593..4769c562 100644 --- a/format/stop-req.js +++ b/format/stop-req.js @@ -2,6 +2,7 @@ const formatStopReq = (ctx, stopRef) => { return { + // todo: there's also `StationDetails`, are there differences? meth: 'LocDetails', req: { locL: [stopRef] diff --git a/index.js b/index.js index be27cef3..e0373a84 100644 --- a/index.js +++ b/index.js @@ -342,7 +342,7 @@ const createClient = (profile, userAgent, opt = {}) => { const query = { // https://github.com/marudor/BahnhofsAbfahrten/blob/49ebf8b36576547112e61a6273bee770f0769660/packages/types/HAFAS/SearchOnTrip.ts#L16-L30 - // todo: support search by `journey.refreshToken` (a.k.a. `ctxRecon`)? + // todo: support search by `journey.refreshToken` (a.k.a. `ctxRecon`) via `sotMode: RC`? sotMode: 'JI', // seach by trip ID (a.k.a. "JID") jid: fromTripId, locData: { // when & where the trip has been entered @@ -465,6 +465,7 @@ const createClient = (profile, userAgent, opt = {}) => { .then(({common, res}) => { if (!Array.isArray(res.locL)) return [] + // todo: parse `.dur` – walking duration? const ctx = {profile, opt, common, res} const results = res.locL.map(loc => profile.parseNearby(ctx, loc)) return Number.isInteger(opt.results) ? results.slice(0, opt.results) : results @@ -569,6 +570,7 @@ const createClient = (profile, userAgent, opt = {}) => { meth: 'JourneyMatch', req, }) + // todo [breaking]: catch `NO_MATCH` errors, return [] .then(({res, common}) => { const ctx = {profile, opt, common, res} return res.jnyL.map(t => profile.parseTrip(ctx, t)) diff --git a/lib/default-profile.js b/lib/default-profile.js index cc3ba885..36d0c10b 100644 --- a/lib/default-profile.js +++ b/lib/default-profile.js @@ -103,6 +103,7 @@ const defaultProfile = { filters, journeysOutFrwd: true, // `journeys()` method: support for `outFrwd` field? + // todo: https://github.com/KDE/kpublictransport/commit/c7c54304160d8f22eab0c91812a107aca82304b7 departuresGetPasslist: true, // `departures()` method: support for `getPasslist` field? departuresStbFltrEquiv: true, // `departures()` method: support for `stbFltrEquiv` field? trip: false, @@ -112,6 +113,7 @@ const defaultProfile = { refreshJourneyUseOutReconL: false, tripsByName: true, remarks: true, + // `remarks()` method: support for `getPolyline` field? remarksGetPolyline: true, // `remarks()` method: support for `getPolyline` field? lines: true, } diff --git a/lib/errors.js b/lib/errors.js index f838c739..59490ea1 100644 --- a/lib/errors.js +++ b/lib/errors.js @@ -8,6 +8,7 @@ const SERVER_ERROR = 'SERVER_ERROR' // https://gist.github.com/derhuerst/79d49c0f04c1c192a5d15756e5af575f/edit // todo: // `code: 'METHOD_NA', message: 'HCI Service: service method disabled'` +// "err": "PARAMETER", "errTxt": "HCI Service: parameter invalid" const byErrorCode = Object.assign(Object.create(null), { H_UNKNOWN: { isServer: false, diff --git a/p/db/index.js b/p/db/index.js index 43459f4c..d136cf0b 100644 --- a/p/db/index.js +++ b/p/db/index.js @@ -169,6 +169,17 @@ const transformJourneysQuery = ({opt}, query) => { return query } +// todo: fix this +// line: { +// type: 'line', +// id: '5-vbbbvb-x9', +// fahrtNr: '52496', +// name: 'X9', +// public: true, +// mode: 'bus', +// product: 'bus', +// operator: {type: 'operator', id: 'nahreisezug', name: 'Nahreisezug'} +// } const parseLineWithAdditionalName = ({parsed}, l) => { if (l.nameS && ['bus', 'tram', 'ferry'].includes(l.product)) { parsed.name = l.nameS diff --git a/parse/hint.js b/parse/hint.js index 332bc033..f2667991 100644 --- a/parse/hint.js +++ b/parse/hint.js @@ -25,6 +25,7 @@ const linkTypesByCode = Object.assign(Object.create(null), { // ] // todo: https://github.com/public-transport/hafas-client/issues/5 // todo: expose h.type somehow +// todo: https://github.com/KDE/kpublictransport/blob/39ac8f9586b9300fa8a9ba0dec010e96fab9ab08/src/lib/backends/hafasmgateparser.cpp#L56-L72 const parseHint = (ctx, h) => { // todo: C diff --git a/parse/trip.js b/parse/trip.js index b000f90a..45ad030a 100644 --- a/parse/trip.js +++ b/parse/trip.js @@ -27,6 +27,7 @@ const parseTrip = (ctx, t) => { // t = raw trip const trip = profile.parseJourneyLeg(ctx, fakeLeg, date) trip.id = trip.tripId delete trip.tripId + // todo [breaking]: delete trip.reachable return trip } diff --git a/test/e2e/saarfahrplan.js b/test/e2e/saarfahrplan.js index f75d5358..91b8ac60 100644 --- a/test/e2e/saarfahrplan.js +++ b/test/e2e/saarfahrplan.js @@ -123,9 +123,9 @@ tap.test('Saarbrücken Hbf to Schlossberghöhlen', async (t) => { tap.skip('journeys: via works – with detour', async (t) => { // Going from Stephansplatz to Schottenring via Donauinsel without detour // is currently impossible. We check if the routing engine computes a detour. - const stephansplatz = '1390167' - const schottenring = '1390163' - const donauinsel = '1392277' + const stephansplatz = '1390167' // todo: does not exist anymore? + const schottenring = '1390163' // todo: does not exist anymore? + const donauinsel = '1392277' // todo: does not exist anymore? const donauinselPassed = '922001' const res = await client.journeys(stephansplatz, schottenring, { via: donauinsel,