commit db9fa0987d9db2620c1722f17cc265b63c60b2c5
parent 4dc95f397b9ff7e1f8d8003d244cc99d5916f014
Author: Yureka <yuka@yuka.dev>
Date: Mon, 13 Jan 2025 20:49:31 +0100
parent 4dc95f397b9ff7e1f8d8003d244cc99d5916f014
Author: Yureka <yuka@yuka.dev>
Date: Mon, 13 Jan 2025 20:49:31 +0100
db vendo
6 files changed, 116 insertions(+), 9 deletions(-)
M
|
102
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
diff --git a/package-lock.json b/package-lock.json @@ -13,6 +13,7 @@ "buffer": "^6.0.3", "date-fns": "^4.1.0", "date-fns-tz": "^3.2.0", + "db-vendo-client": "https://github.com/yuyuyureka/db-vendo-client#main", "hafas-client": "https://github.com/yu-re-ka/hafas-client#main", "idb": "^8.0.1", "lit-html": "^3.2.1", @@ -1492,6 +1493,55 @@ "date-fns": "^3.0.0 || ^4.0.0" } }, + "node_modules/db-hafas-stations": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/db-hafas-stations/-/db-hafas-stations-1.0.0.tgz", + "integrity": "sha512-F14CaUHz4EZnUTrUGm9EXxeqsbxWnbp8aJIulV/wJ9LnVruYXXmTrRHVsa9DoK5fT9WEInyYSjMLlEspq2wqRw==", + "license": "ISC", + "dependencies": { + "ndjson": "^2.0.0" + }, + "engines": { + "node": ">=14" + } + }, + "node_modules/db-vendo-client": { + "version": "6.3.2", + "resolved": "git+ssh://git@github.com/yuyuyureka/db-vendo-client.git#30af24968a96e653da6512d5941df9dd9723f672", + "license": "ISC", + "dependencies": { + "@derhuerst/round-robin-scheduler": "^1.0.4", + "content-type": "^1.0.4", + "cross-fetch": "^4.0.0", + "db-hafas-stations": "^1.0.0", + "gps-distance": "0.0.4", + "https-proxy-agent": "^7.0.0", + "lodash": "^4.17.5", + "luxon": "^3.1.1", + "qs": "^6.6.0", + "slugg": "^1.2.0", + "uuid": "^11.0.5" + }, + "engines": { + "node": ">=16" + }, + "funding": { + "url": "https://github.com/sponsors/derhuerst" + } + }, + "node_modules/db-vendo-client/node_modules/uuid": { + "version": "11.0.5", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-11.0.5.tgz", + "integrity": "sha512-508e6IcKLrhxKdBbcA2b4KQZlLVp2+J5UwQ6F7Drckkc5N9ZJwFa4TgWtsww9UG8fGHbm6gbV19TdM5pQ4GaIA==", + "funding": [ + "https://github.com/sponsors/broofa", + "https://github.com/sponsors/ctavan" + ], + "license": "MIT", + "bin": { + "uuid": "dist/esm/bin/uuid" + } + }, "node_modules/debug": { "version": "4.4.0", "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.0.tgz", @@ -2879,6 +2929,12 @@ "dev": true, "license": "MIT" }, + "node_modules/json-stringify-safe": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz", + "integrity": "sha512-ZClg6AaYvamvYEE82d3Iyd3vSSIjQ+odgjaTzRuO3s7toCdFKczob2i0zCh7JE8kWn17yvAWhUVxvqGwUalsRA==", + "license": "ISC" + }, "node_modules/kind-of": { "version": "6.0.3", "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.3.tgz", @@ -3097,6 +3153,15 @@ "dev": true, "license": "ISC" }, + "node_modules/minimist": { + "version": "1.2.8", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz", + "integrity": "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==", + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/ms": { "version": "2.1.3", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", @@ -3117,6 +3182,25 @@ "multicast-dns": "cli.js" } }, + "node_modules/ndjson": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ndjson/-/ndjson-2.0.0.tgz", + "integrity": "sha512-nGl7LRGrzugTtaFcJMhLbpzJM6XdivmbkdlaGcrk/LXg2KL/YBC6z1g70xh0/al+oFuVFP8N8kiWRucmeEH/qQ==", + "license": "BSD-3-Clause", + "dependencies": { + "json-stringify-safe": "^5.0.1", + "minimist": "^1.2.5", + "readable-stream": "^3.6.0", + "split2": "^3.0.0", + "through2": "^4.0.0" + }, + "bin": { + "ndjson": "cli.js" + }, + "engines": { + "node": ">=10" + } + }, "node_modules/negotiator": { "version": "0.6.4", "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.4.tgz", @@ -4303,6 +4387,15 @@ "wbuf": "^1.7.3" } }, + "node_modules/split2": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/split2/-/split2-3.2.2.tgz", + "integrity": "sha512-9NThjpgZnifTkJpzTZ7Eue85S49QwpNhZTq6GRJwObb6jnLFNGB7Qm73V5HewTROPyxD0C29xqmaI68bQtV+hg==", + "license": "ISC", + "dependencies": { + "readable-stream": "^3.0.0" + } + }, "node_modules/statuses": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.1.tgz", @@ -4428,6 +4521,15 @@ "tslib": "^2" } }, + "node_modules/through2": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/through2/-/through2-4.0.2.tgz", + "integrity": "sha512-iOqSav00cVxEEICeD7TjLB1sueEL+81Wpzp2bY17uZjZN0pWZPuo4suZ/61VujxmqSGFfgOcNuTZ85QJwNZQpw==", + "license": "MIT", + "dependencies": { + "readable-stream": "3" + } + }, "node_modules/thunky": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/thunky/-/thunky-1.1.0.tgz",
diff --git a/package.json b/package.json @@ -14,6 +14,7 @@ "buffer": "^6.0.3", "date-fns": "^4.1.0", "date-fns-tz": "^3.2.0", + "db-vendo-client": "https://github.com/yuyuyureka/db-vendo-client#main", "hafas-client": "https://github.com/yu-re-ka/hafas-client#main", "idb": "^8.0.1", "lit-html": "^3.2.1",
diff --git a/src/dataStorage.js b/src/dataStorage.js @@ -85,12 +85,11 @@ class IDBStorage { db.createObjectStore('journeysOverview', {keyPath: 'slug'}); db.createObjectStore('journeysHistory', {autoIncrement: true}); case 2: - const tx = await db.transaction(['settings'], 'readwrite'); - const settings = tx.store.get('settings'); + const settings = transaction.objectStore('settings').get('settings'); if (settings.profile === 'vbb') { settings.profile = 'db'; } - tx.store.put(settings, 'settings'); + transaction.objectStore('settings').put(settings, 'settings'); case 3: //... add migrations for 3->4 here }
diff --git a/src/hafas_client.js b/src/hafas_client.js @@ -1,8 +1,10 @@ const clients = {}; export let client; -import { createClient } from "hafas-client"; -import { profile as dbProfile } from "hafas-client/p/db"; +import { createClient as createHafasClient } from "hafas-client"; +import { createClient as createVendoClient } from "db-vendo-client"; + +import { profile as dbnavProfile } from "db-vendo-client/p/dbnav"; import { profile as nahshProfile } from "hafas-client/p/nahsh"; export const getHafasClient = async profileName => { @@ -10,8 +12,9 @@ export const getHafasClient = async profileName => { let profile; switch(profileName) { case "db": - profile = dbProfile; - break; + clients[profileName] = createVendoClient(dbnavProfile, "trainsearch", {enrichStations: false}); + console.info("initialized vendo client"); + return clients[profileName]; case "bvg": const { profile: bvgProfile } = await import('hafas-client/p/bvg'); profile = bvgProfile; @@ -22,7 +25,7 @@ export const getHafasClient = async profileName => { default: throw "Unknown profile name: " + profileName; } - clients[profileName] = createClient(profile, "trainsearch"); + clients[profileName] = createHafasClient(profile, "trainsearch"); } console.info("initialized hafas client with profile " + profileName);
diff --git a/src/shim/db-hafas-stations.js b/src/shim/db-hafas-stations.js @@ -0,0 +1 @@ +export default {};
diff --git a/webpack.config.js b/webpack.config.js @@ -24,12 +24,13 @@ module.exports = { ], }, plugins: [ - new NormalModuleReplacementPlugin(/(node:|https-proxy-agent|cross-fetch)/, (resource) => { + new NormalModuleReplacementPlugin(/(node:|https-proxy-agent|cross-fetch|db-hafas-stations)/, (resource) => { const newRequest = { "node:buffer": "buffer", "node:assert": "assert", "https-proxy-agent": path.resolve(__dirname, "src/shim/https-proxy-agent.js"), "cross-fetch": path.resolve(__dirname, "src/shim/cross-fetch.js"), + "db-hafas-stations": path.resolve(__dirname, "src/shim/db-hafas-stations.js"), }[resource.request]; if (newRequest) { resource.request = newRequest;