mirror of
				https://github.com/public-transport/db-vendo-client.git
				synced 2025-11-04 01:56:33 +02:00 
			
		
		
		
	add todos & comments
This commit is contained in:
		
							parent
							
								
									dd5e436892
								
							
						
					
					
						commit
						a7cb71c870
					
				
					 8 changed files with 23 additions and 4 deletions
				
			
		| 
						 | 
					@ -2,6 +2,7 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const formatStopReq = (ctx, stopRef) => {
 | 
					const formatStopReq = (ctx, stopRef) => {
 | 
				
			||||||
	return {
 | 
						return {
 | 
				
			||||||
 | 
							// todo: there's also `StationDetails`, are there differences?
 | 
				
			||||||
		meth: 'LocDetails',
 | 
							meth: 'LocDetails',
 | 
				
			||||||
		req: {
 | 
							req: {
 | 
				
			||||||
			locL: [stopRef]
 | 
								locL: [stopRef]
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										4
									
								
								index.js
									
										
									
									
									
								
							
							
						
						
									
										4
									
								
								index.js
									
										
									
									
									
								
							| 
						 | 
					@ -342,7 +342,7 @@ const createClient = (profile, userAgent, opt = {}) => {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		const query = {
 | 
							const query = {
 | 
				
			||||||
			// https://github.com/marudor/BahnhofsAbfahrten/blob/49ebf8b36576547112e61a6273bee770f0769660/packages/types/HAFAS/SearchOnTrip.ts#L16-L30
 | 
								// 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")
 | 
								sotMode: 'JI', // seach by trip ID (a.k.a. "JID")
 | 
				
			||||||
			jid: fromTripId,
 | 
								jid: fromTripId,
 | 
				
			||||||
			locData: { // when & where the trip has been entered
 | 
								locData: { // when & where the trip has been entered
 | 
				
			||||||
| 
						 | 
					@ -465,6 +465,7 @@ const createClient = (profile, userAgent, opt = {}) => {
 | 
				
			||||||
		.then(({common, res}) => {
 | 
							.then(({common, res}) => {
 | 
				
			||||||
			if (!Array.isArray(res.locL)) return []
 | 
								if (!Array.isArray(res.locL)) return []
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								// todo: parse `.dur` – walking duration?
 | 
				
			||||||
			const ctx = {profile, opt, common, res}
 | 
								const ctx = {profile, opt, common, res}
 | 
				
			||||||
			const results = res.locL.map(loc => profile.parseNearby(ctx, loc))
 | 
								const results = res.locL.map(loc => profile.parseNearby(ctx, loc))
 | 
				
			||||||
			return Number.isInteger(opt.results) ? results.slice(0, opt.results) : results
 | 
								return Number.isInteger(opt.results) ? results.slice(0, opt.results) : results
 | 
				
			||||||
| 
						 | 
					@ -569,6 +570,7 @@ const createClient = (profile, userAgent, opt = {}) => {
 | 
				
			||||||
			meth: 'JourneyMatch',
 | 
								meth: 'JourneyMatch',
 | 
				
			||||||
			req,
 | 
								req,
 | 
				
			||||||
		})
 | 
							})
 | 
				
			||||||
 | 
							// todo [breaking]: catch `NO_MATCH` errors, return []
 | 
				
			||||||
		.then(({res, common}) => {
 | 
							.then(({res, common}) => {
 | 
				
			||||||
			const ctx = {profile, opt, common, res}
 | 
								const ctx = {profile, opt, common, res}
 | 
				
			||||||
			return res.jnyL.map(t => profile.parseTrip(ctx, t))
 | 
								return res.jnyL.map(t => profile.parseTrip(ctx, t))
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -103,6 +103,7 @@ const defaultProfile = {
 | 
				
			||||||
	filters,
 | 
						filters,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	journeysOutFrwd: true,  // `journeys()` method: support for `outFrwd` field?
 | 
						journeysOutFrwd: true,  // `journeys()` method: support for `outFrwd` field?
 | 
				
			||||||
 | 
						// todo: https://github.com/KDE/kpublictransport/commit/c7c54304160d8f22eab0c91812a107aca82304b7
 | 
				
			||||||
	departuresGetPasslist: true, // `departures()` method: support for `getPasslist` field?
 | 
						departuresGetPasslist: true, // `departures()` method: support for `getPasslist` field?
 | 
				
			||||||
	departuresStbFltrEquiv: true, // `departures()` method: support for `stbFltrEquiv` field?
 | 
						departuresStbFltrEquiv: true, // `departures()` method: support for `stbFltrEquiv` field?
 | 
				
			||||||
	trip: false,
 | 
						trip: false,
 | 
				
			||||||
| 
						 | 
					@ -112,6 +113,7 @@ const defaultProfile = {
 | 
				
			||||||
	refreshJourneyUseOutReconL: false,
 | 
						refreshJourneyUseOutReconL: false,
 | 
				
			||||||
	tripsByName: true,
 | 
						tripsByName: true,
 | 
				
			||||||
	remarks: true,
 | 
						remarks: true,
 | 
				
			||||||
 | 
						// `remarks()` method: support for `getPolyline` field?
 | 
				
			||||||
	remarksGetPolyline: true, // `remarks()` method: support for `getPolyline` field?
 | 
						remarksGetPolyline: true, // `remarks()` method: support for `getPolyline` field?
 | 
				
			||||||
	lines: true,
 | 
						lines: true,
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -8,6 +8,7 @@ const SERVER_ERROR = 'SERVER_ERROR'
 | 
				
			||||||
// https://gist.github.com/derhuerst/79d49c0f04c1c192a5d15756e5af575f/edit
 | 
					// https://gist.github.com/derhuerst/79d49c0f04c1c192a5d15756e5af575f/edit
 | 
				
			||||||
// todo:
 | 
					// todo:
 | 
				
			||||||
// `code: 'METHOD_NA', message: 'HCI Service: service method disabled'`
 | 
					// `code: 'METHOD_NA', message: 'HCI Service: service method disabled'`
 | 
				
			||||||
 | 
					// "err": "PARAMETER", "errTxt": "HCI Service: parameter invalid"
 | 
				
			||||||
const byErrorCode = Object.assign(Object.create(null), {
 | 
					const byErrorCode = Object.assign(Object.create(null), {
 | 
				
			||||||
	H_UNKNOWN: {
 | 
						H_UNKNOWN: {
 | 
				
			||||||
		isServer: false,
 | 
							isServer: false,
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -169,6 +169,17 @@ const transformJourneysQuery = ({opt}, query) => {
 | 
				
			||||||
	return 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) => {
 | 
					const parseLineWithAdditionalName = ({parsed}, l) => {
 | 
				
			||||||
	if (l.nameS && ['bus', 'tram', 'ferry'].includes(l.product)) {
 | 
						if (l.nameS && ['bus', 'tram', 'ferry'].includes(l.product)) {
 | 
				
			||||||
		parsed.name = l.nameS
 | 
							parsed.name = l.nameS
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -25,6 +25,7 @@ const linkTypesByCode = Object.assign(Object.create(null), {
 | 
				
			||||||
// ]
 | 
					// ]
 | 
				
			||||||
// todo: https://github.com/public-transport/hafas-client/issues/5
 | 
					// todo: https://github.com/public-transport/hafas-client/issues/5
 | 
				
			||||||
// todo: expose h.type somehow
 | 
					// todo: expose h.type somehow
 | 
				
			||||||
 | 
					// todo: https://github.com/KDE/kpublictransport/blob/39ac8f9586b9300fa8a9ba0dec010e96fab9ab08/src/lib/backends/hafasmgateparser.cpp#L56-L72
 | 
				
			||||||
const parseHint = (ctx, h) => {
 | 
					const parseHint = (ctx, h) => {
 | 
				
			||||||
	// todo: C
 | 
						// todo: C
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -27,6 +27,7 @@ const parseTrip = (ctx, t) => { // t = raw trip
 | 
				
			||||||
	const trip = profile.parseJourneyLeg(ctx, fakeLeg, date)
 | 
						const trip = profile.parseJourneyLeg(ctx, fakeLeg, date)
 | 
				
			||||||
	trip.id = trip.tripId
 | 
						trip.id = trip.tripId
 | 
				
			||||||
	delete trip.tripId
 | 
						delete trip.tripId
 | 
				
			||||||
 | 
						// todo [breaking]: delete trip.reachable
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return trip
 | 
						return trip
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -123,9 +123,9 @@ tap.test('Saarbrücken Hbf to Schlossberghöhlen', async (t) => {
 | 
				
			||||||
tap.skip('journeys: via works – with detour', async (t) => {
 | 
					tap.skip('journeys: via works – with detour', async (t) => {
 | 
				
			||||||
	// Going from Stephansplatz to Schottenring via Donauinsel without detour
 | 
						// Going from Stephansplatz to Schottenring via Donauinsel without detour
 | 
				
			||||||
	// is currently impossible. We check if the routing engine computes a detour.
 | 
						// is currently impossible. We check if the routing engine computes a detour.
 | 
				
			||||||
	const stephansplatz = '1390167'
 | 
						const stephansplatz = '1390167' // todo: does not exist anymore?
 | 
				
			||||||
	const schottenring = '1390163'
 | 
						const schottenring = '1390163' // todo: does not exist anymore?
 | 
				
			||||||
	const donauinsel = '1392277'
 | 
						const donauinsel = '1392277' // todo: does not exist anymore?
 | 
				
			||||||
	const donauinselPassed = '922001'
 | 
						const donauinselPassed = '922001'
 | 
				
			||||||
	const res = await client.journeys(stephansplatz, schottenring, {
 | 
						const res = await client.journeys(stephansplatz, schottenring, {
 | 
				
			||||||
		via: donauinsel,
 | 
							via: donauinsel,
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		
		Reference in a new issue