mirror of
https://github.com/kennethnym/aris.git
synced 2026-02-02 13:11:17 +00:00
refactor: migrate aris-data-source-tfl to aris-source-tfl
Migrates TFL package from old DataSource interface to new FeedSource interface for use with FeedEngine. Changes: - Rename package from @aris/data-source-tfl to @aris/source-tfl - Replace TflDataSource class with TflSource implementing FeedSource - Add dependency on @aris/source-location for LocationKey - Use normalized priority values (0-1) instead of arbitrary numbers - Update tests for FeedSource interface - Update README.md with new package name Co-authored-by: Ona <no-reply@ona.com>
This commit is contained in:
35
packages/aris-source-tfl/scripts/fetch-fixtures.ts
Normal file
35
packages/aris-source-tfl/scripts/fetch-fixtures.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
// Fetches real TfL API responses and saves them as test fixtures
|
||||
|
||||
const TEST_LINES = ["northern", "central", "elizabeth"]
|
||||
const BASE_URL = "https://api.tfl.gov.uk"
|
||||
|
||||
async function fetchFixtures() {
|
||||
console.log("Fetching line statuses...")
|
||||
const statusRes = await fetch(`${BASE_URL}/Line/${TEST_LINES.join(",")}/Status`)
|
||||
const lineStatuses = await statusRes.json()
|
||||
|
||||
console.log("Fetching stop points...")
|
||||
const stopPoints: Record<string, unknown> = {}
|
||||
for (const lineId of TEST_LINES) {
|
||||
console.log(` Fetching ${lineId}...`)
|
||||
const res = await fetch(`${BASE_URL}/Line/${lineId}/StopPoints`)
|
||||
stopPoints[lineId] = await res.json()
|
||||
}
|
||||
|
||||
const fixtures = {
|
||||
fetchedAt: new Date().toISOString(),
|
||||
lineStatuses,
|
||||
stopPoints,
|
||||
}
|
||||
|
||||
const path = new URL("../fixtures/tfl-responses.json", import.meta.url)
|
||||
await Bun.write(path, JSON.stringify(fixtures))
|
||||
|
||||
console.log(`\nFixtures saved to fixtures/tfl-responses.json`)
|
||||
console.log(` Line statuses: ${(lineStatuses as unknown[]).length} lines`)
|
||||
for (const [lineId, stops] of Object.entries(stopPoints)) {
|
||||
console.log(` ${lineId} stops: ${(stops as unknown[]).length}`)
|
||||
}
|
||||
}
|
||||
|
||||
fetchFixtures().catch(console.error)
|
||||
Reference in New Issue
Block a user