mirror of
https://github.com/public-transport/db-vendo-client.git
synced 2025-04-20 23:23:56 +03:00
Compare commits
No commits in common. "main" and "v6.8.0" have entirely different histories.
13 changed files with 12 additions and 2377 deletions
|
@ -627,8 +627,6 @@
|
||||||
"Intervalle",
|
"Intervalle",
|
||||||
"tagesbest",
|
"tagesbest",
|
||||||
"dbbahnhof",
|
"dbbahnhof",
|
||||||
"Deutschlandticket",
|
|
||||||
"fahrverguenstigungen",
|
|
||||||
"cancelation"
|
"cancelation"
|
||||||
],
|
],
|
||||||
"ignorePaths": [
|
"ignorePaths": [
|
||||||
|
|
4
index.js
4
index.js
|
@ -181,8 +181,6 @@ const createClient = (profile, userAgent, opt = {}) => {
|
||||||
scheduledDays: false, // parse & expose dates each journey is valid on?
|
scheduledDays: false, // parse & expose dates each journey is valid on?
|
||||||
notOnlyFastRoutes: false, // if true, also show routes that are mathematically non-optimal
|
notOnlyFastRoutes: false, // if true, also show routes that are mathematically non-optimal
|
||||||
bestprice: false, // search for lowest prices across the entire day
|
bestprice: false, // search for lowest prices across the entire day
|
||||||
deutschlandTicketDiscount: false,
|
|
||||||
deutschlandTicketConnectionsOnly: false,
|
|
||||||
}, opt);
|
}, opt);
|
||||||
|
|
||||||
if (opt.when !== undefined) {
|
if (opt.when !== undefined) {
|
||||||
|
@ -241,8 +239,6 @@ const createClient = (profile, userAgent, opt = {}) => {
|
||||||
entrances: true, // parse & expose entrances of stops/stations?
|
entrances: true, // parse & expose entrances of stops/stations?
|
||||||
remarks: true, // parse & expose hints & warnings?
|
remarks: true, // parse & expose hints & warnings?
|
||||||
scheduledDays: false, // parse & expose dates the journey is valid on?
|
scheduledDays: false, // parse & expose dates the journey is valid on?
|
||||||
deutschlandTicketDiscount: false,
|
|
||||||
deutschlandTicketConnectionsOnly: false,
|
|
||||||
}, opt);
|
}, opt);
|
||||||
|
|
||||||
const req = profile.formatRefreshJourneyReq({profile, opt}, refreshToken);
|
const req = profile.formatRefreshJourneyReq({profile, opt}, refreshToken);
|
||||||
|
|
|
@ -76,18 +76,6 @@ const mapRouteParsers = (route, parsers) => {
|
||||||
default: false,
|
default: false,
|
||||||
parse: parseBoolean,
|
parse: parseBoolean,
|
||||||
},
|
},
|
||||||
deutschlandTicketDiscount: {
|
|
||||||
description: 'Calculate ticket prices assuming Deutschlandticket is present',
|
|
||||||
type: 'boolean',
|
|
||||||
default: false,
|
|
||||||
parse: parseBoolean,
|
|
||||||
},
|
|
||||||
deutschlandTicketConnectionsOnly: {
|
|
||||||
description: 'Only return journeys that can be used with the Deutschlandticket',
|
|
||||||
type: 'boolean',
|
|
||||||
default: false,
|
|
||||||
parse: parseBoolean,
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
if (route.includes('departures') || route.includes('arrivals')) {
|
if (route.includes('departures') || route.includes('arrivals')) {
|
||||||
|
|
|
@ -105,6 +105,7 @@ const request = async (ctx, userAgent, reqData) => {
|
||||||
if (reqOptions.query) {
|
if (reqOptions.query) {
|
||||||
url += '?' + stringify(reqOptions.query, {arrayFormat: 'brackets', encodeValuesOnly: true});
|
url += '?' + stringify(reqOptions.query, {arrayFormat: 'brackets', encodeValuesOnly: true});
|
||||||
}
|
}
|
||||||
|
console.log(url);
|
||||||
const reqId = randomBytesHexString(6);
|
const reqId = randomBytesHexString(6);
|
||||||
const fetchReq = new Request(url, reqOptions);
|
const fetchReq = new Request(url, reqOptions);
|
||||||
profile.logRequest(ctx, fetchReq, reqId);
|
profile.logRequest(ctx, fetchReq, reqId);
|
||||||
|
@ -121,7 +122,6 @@ const request = async (ctx, userAgent, reqData) => {
|
||||||
|
|
||||||
if (!res.ok) {
|
if (!res.ok) {
|
||||||
// todo [breaking]: make this a FetchError or a HafasClientError?
|
// todo [breaking]: make this a FetchError or a HafasClientError?
|
||||||
console.log(JSON.stringify(res), await res.text());
|
|
||||||
const err = new Error(res.statusText);
|
const err = new Error(res.statusText);
|
||||||
Object.assign(err, errProps);
|
Object.assign(err, errProps);
|
||||||
throw err;
|
throw err;
|
||||||
|
|
|
@ -9,10 +9,6 @@ const formatBaseJourneysReq = (ctx) => {
|
||||||
einstiegsTypList: [
|
einstiegsTypList: [
|
||||||
'STANDARD',
|
'STANDARD',
|
||||||
],
|
],
|
||||||
fahrverguenstigungen: {
|
|
||||||
deutschlandTicketVorhanden: ctx.opt.deutschlandTicketDiscount,
|
|
||||||
nurDeutschlandTicketVerbindungen: ctx.opt.deutschlandTicketConnectionsOnly,
|
|
||||||
},
|
|
||||||
klasse: travellers.klasse,
|
klasse: travellers.klasse,
|
||||||
reisendenProfil: {
|
reisendenProfil: {
|
||||||
reisende: travellers.reisende.map(t => {
|
reisende: travellers.reisende.map(t => {
|
||||||
|
|
|
@ -10,8 +10,8 @@ const formatJourneysReq = (ctx, from, to, when, outFrwd, journeysRef) => {
|
||||||
let query = {
|
let query = {
|
||||||
maxUmstiege: transfers,
|
maxUmstiege: transfers,
|
||||||
minUmstiegszeit: opt.transferTime,
|
minUmstiegszeit: opt.transferTime,
|
||||||
deutschlandTicketVorhanden: opt.deutschlandTicketDiscount,
|
deutschlandTicketVorhanden: false,
|
||||||
nurDeutschlandTicketVerbindungen: opt.deutschlandTicketConnectionsOnly,
|
nurDeutschlandTicketVerbindungen: false,
|
||||||
reservierungsKontingenteVorhanden: false,
|
reservierungsKontingenteVorhanden: false,
|
||||||
schnelleVerbindungen: !opt.notOnlyFastRoutes,
|
schnelleVerbindungen: !opt.notOnlyFastRoutes,
|
||||||
sitzplatzOnly: false,
|
sitzplatzOnly: false,
|
||||||
|
|
4
package-lock.json
generated
4
package-lock.json
generated
|
@ -1,12 +1,12 @@
|
||||||
{
|
{
|
||||||
"name": "db-vendo-client",
|
"name": "db-vendo-client",
|
||||||
"version": "6.8.2",
|
"version": "6.8.0",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "db-vendo-client",
|
"name": "db-vendo-client",
|
||||||
"version": "6.8.2",
|
"version": "6.8.0",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"content-type": "^1.0.5",
|
"content-type": "^1.0.5",
|
||||||
|
|
|
@ -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.8.2",
|
"version": "6.8.0",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"files": [
|
"files": [
|
||||||
|
|
|
@ -127,7 +127,7 @@ if (!process.env.VCR_OFF) {
|
||||||
});
|
});
|
||||||
|
|
||||||
tap.test('refreshJourney – valid tickets', async (t) => {
|
tap.test('refreshJourney – valid tickets', async (t) => {
|
||||||
const T_MOCK = 1758279600 * 1000;
|
const T_MOCK = 1710831600 * 1000; // 2024-03-19T08:00:00+01:00
|
||||||
const when = createWhen(dbProfile.timezone, dbProfile.locale, T_MOCK);
|
const when = createWhen(dbProfile.timezone, dbProfile.locale, T_MOCK);
|
||||||
|
|
||||||
const journeysRes = await client.journeys(berlinHbf, münchenHbf, {
|
const journeysRes = await client.journeys(berlinHbf, münchenHbf, {
|
||||||
|
@ -261,7 +261,7 @@ if (!process.env.VCR_MODE) {
|
||||||
}
|
}
|
||||||
|
|
||||||
tap.test('refreshJourney', async (t) => {
|
tap.test('refreshJourney', async (t) => {
|
||||||
const T_MOCK = 1763542800 * 1000;
|
const T_MOCK = 1710831600 * 1000; // 2024-03-19T08:00:00+01:00
|
||||||
const when = createWhen(dbProfile.timezone, dbProfile.locale, T_MOCK);
|
const when = createWhen(dbProfile.timezone, dbProfile.locale, T_MOCK);
|
||||||
const validate = createValidate({...cfg, when});
|
const validate = createValidate({...cfg, when});
|
||||||
|
|
||||||
|
|
|
@ -126,7 +126,7 @@ tap.test('journeys – Berlin Schwedter Str. to München Hbf', async (t) => {
|
||||||
});
|
});
|
||||||
|
|
||||||
tap.test('refreshJourney – valid tickets', async (t) => {
|
tap.test('refreshJourney – valid tickets', async (t) => {
|
||||||
const T_MOCK = 1758279600 * 1000;
|
const T_MOCK = 1710831600 * 1000; // 2024-03-19T08:00:00+01:00
|
||||||
const when = createWhen(dbProfile.timezone, dbProfile.locale, T_MOCK);
|
const when = createWhen(dbProfile.timezone, dbProfile.locale, T_MOCK);
|
||||||
|
|
||||||
const journeysRes = await client.journeys(berlinHbf, münchenHbf, {
|
const journeysRes = await client.journeys(berlinHbf, münchenHbf, {
|
||||||
|
@ -261,7 +261,7 @@ if (!process.env.VCR_OFF) {
|
||||||
}
|
}
|
||||||
|
|
||||||
tap.test('refreshJourney', async (t) => {
|
tap.test('refreshJourney', async (t) => {
|
||||||
const T_MOCK = 1763542800 * 1000;
|
const T_MOCK = 1710831600 * 1000; // 2024-03-19T08:00:00+01:00
|
||||||
const when = createWhen(dbProfile.timezone, dbProfile.locale, T_MOCK);
|
const when = createWhen(dbProfile.timezone, dbProfile.locale, T_MOCK);
|
||||||
const validate = createValidate({...cfg, when});
|
const validate = createValidate({...cfg, when});
|
||||||
|
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -41,10 +41,6 @@ const berlinWienQuery0 = Object.freeze(
|
||||||
einstiegsTypList: [
|
einstiegsTypList: [
|
||||||
'STANDARD',
|
'STANDARD',
|
||||||
],
|
],
|
||||||
fahrverguenstigungen: {
|
|
||||||
deutschlandTicketVorhanden: undefined,
|
|
||||||
nurDeutschlandTicketVerbindungen: undefined,
|
|
||||||
},
|
|
||||||
klasse: 'KLASSE_2',
|
klasse: 'KLASSE_2',
|
||||||
reiseHin: {
|
reiseHin: {
|
||||||
wunsch: {
|
wunsch: {
|
||||||
|
|
|
@ -57,8 +57,8 @@ const berlinWienQuery0 = Object.freeze(
|
||||||
sitzplatzOnly: false,
|
sitzplatzOnly: false,
|
||||||
bikeCarriage: false,
|
bikeCarriage: false,
|
||||||
reservierungsKontingenteVorhanden: false,
|
reservierungsKontingenteVorhanden: false,
|
||||||
nurDeutschlandTicketVerbindungen: undefined,
|
nurDeutschlandTicketVerbindungen: false,
|
||||||
deutschlandTicketVorhanden: undefined,
|
deutschlandTicketVorhanden: false,
|
||||||
maxUmstiege: null,
|
maxUmstiege: null,
|
||||||
zwischenhalte: null,
|
zwischenhalte: null,
|
||||||
minUmstiegszeit: 0,
|
minUmstiegszeit: 0,
|
||||||
|
|
Loading…
Add table
Reference in a new issue