2024-02-06 22:58:49 +01:00
|
|
|
import {request} from '../lib/request.js';
|
2024-12-21 15:26:49 +00:00
|
|
|
import {products} from '../lib/products.js';
|
|
|
|
import {ageGroup, ageGroupFromAge, ageGroupLabel} from './age-group.js';
|
2017-11-12 14:52:04 +01:00
|
|
|
|
2024-02-06 22:58:49 +01:00
|
|
|
import {formatStationBoardReq} from '../format/station-board-req.js';
|
|
|
|
import {formatStopReq} from '../format/stop-req.js';
|
|
|
|
import {formatTripReq} from '../format/trip-req.js';
|
2024-12-07 18:29:16 +00:00
|
|
|
import {formatNearbyReq} from '../format/nearby-req.js';
|
2019-10-31 18:48:11 +01:00
|
|
|
|
2024-02-06 22:58:49 +01:00
|
|
|
import {parseDateTime} from '../parse/date-time.js';
|
|
|
|
import {parsePlatform} from '../parse/platform.js';
|
2024-12-21 15:26:49 +00:00
|
|
|
import {parseProducts} from '../parse/products.js';
|
2024-02-06 22:58:49 +01:00
|
|
|
import {parseWhen} from '../parse/when.js';
|
|
|
|
import {parseDeparture} from '../parse/departure.js';
|
|
|
|
import {parseArrival} from '../parse/arrival.js';
|
|
|
|
import {parseTrip} from '../parse/trip.js';
|
|
|
|
import {parseJourneyLeg} from '../parse/journey-leg.js';
|
|
|
|
import {parseJourney} from '../parse/journey.js';
|
|
|
|
import {parseLine} from '../parse/line.js';
|
|
|
|
import {parseLocation} from '../parse/location.js';
|
|
|
|
import {parsePolyline} from '../parse/polyline.js';
|
|
|
|
import {parseOperator} from '../parse/operator.js';
|
2025-01-02 14:00:45 +00:00
|
|
|
import {parseRemarks, parseCancelled} from '../parse/remarks.js';
|
2024-02-06 22:58:49 +01:00
|
|
|
import {parseStopover} from '../parse/stopover.js';
|
2024-12-21 15:26:49 +00:00
|
|
|
import {parseLoadFactor, parseArrOrDepWithLoadFactor} from '../parse/load-factor.js';
|
|
|
|
import {parseHintByCode} from '../parse/hints-by-code.js';
|
2019-10-31 20:08:56 +01:00
|
|
|
|
2024-02-06 22:58:49 +01:00
|
|
|
import {formatAddress} from '../format/address.js';
|
|
|
|
import {formatCoord} from '../format/coord.js';
|
|
|
|
import {formatDate} from '../format/date.js';
|
|
|
|
import {formatProductsFilter} from '../format/products-filter.js';
|
|
|
|
import {formatPoi} from '../format/poi.js';
|
|
|
|
import {formatStation} from '../format/station.js';
|
2025-01-02 14:00:45 +00:00
|
|
|
import {formatTime, formatTimeOfDay} from '../format/time.js';
|
2024-02-06 22:58:49 +01:00
|
|
|
import {formatLocation} from '../format/location.js';
|
2024-12-21 15:26:49 +00:00
|
|
|
import {formatLoyaltyCard} from '../format/loyalty-cards.js';
|
2017-11-12 14:52:04 +01:00
|
|
|
|
2024-02-06 22:58:49 +01:00
|
|
|
const DEBUG = (/(^|,)hafas-client(,|$)/).test(process.env.DEBUG || '');
|
2022-10-06 14:22:46 +02:00
|
|
|
const logRequest = DEBUG
|
2024-02-06 22:58:49 +01:00
|
|
|
? (_, req, reqId) => console.error(String(req.body))
|
2024-12-21 15:26:49 +00:00
|
|
|
: () => { };
|
2022-10-06 14:22:46 +02:00
|
|
|
const logResponse = DEBUG
|
2022-10-07 01:29:36 +02:00
|
|
|
? (_, res, body, reqId) => console.error(body)
|
2024-12-21 15:26:49 +00:00
|
|
|
: () => { };
|
2022-10-06 14:22:46 +02:00
|
|
|
|
2024-12-21 15:26:49 +00:00
|
|
|
const id = (_ctx, x) => x;
|
|
|
|
const notImplemented = (_ctx, _x) => {
|
|
|
|
throw new Error('NotImplemented');
|
|
|
|
};
|
2017-11-12 14:52:04 +01:00
|
|
|
|
|
|
|
const defaultProfile = {
|
2019-10-31 18:48:11 +01:00
|
|
|
request,
|
2024-12-21 15:26:49 +00:00
|
|
|
products,
|
|
|
|
ageGroup, ageGroupFromAge, ageGroupLabel,
|
2019-10-31 18:48:11 +01:00
|
|
|
transformReqBody: id,
|
|
|
|
transformReq: id,
|
2025-01-02 14:00:45 +00:00
|
|
|
randomizeUserAgent: false,
|
2022-10-06 14:22:46 +02:00
|
|
|
logRequest,
|
|
|
|
logResponse,
|
2018-01-15 00:45:05 +01:00
|
|
|
|
2019-10-31 20:08:56 +01:00
|
|
|
formatStationBoardReq,
|
2024-12-21 15:26:49 +00:00
|
|
|
formatLocationsReq: notImplemented,
|
2019-10-31 20:08:56 +01:00
|
|
|
formatStopReq,
|
|
|
|
formatTripReq,
|
2024-12-07 18:29:16 +00:00
|
|
|
formatNearbyReq,
|
2024-12-21 15:26:49 +00:00
|
|
|
formatJourneysReq: notImplemented,
|
|
|
|
formatRefreshJourneyReq: notImplemented,
|
2017-11-12 20:02:32 +01:00
|
|
|
transformJourneysQuery: id,
|
|
|
|
|
2017-11-12 14:52:04 +01:00
|
|
|
parseDateTime,
|
2019-08-30 19:19:31 +02:00
|
|
|
parsePlatform,
|
2024-12-21 15:26:49 +00:00
|
|
|
parseProducts,
|
2019-08-30 19:19:31 +02:00
|
|
|
parseWhen,
|
2017-11-12 14:52:04 +01:00
|
|
|
parseDeparture,
|
2018-06-26 15:49:50 +02:00
|
|
|
parseArrival,
|
2020-06-11 15:33:45 +02:00
|
|
|
parseTrip,
|
2017-12-28 16:56:27 +01:00
|
|
|
parseJourneyLeg,
|
2017-11-12 14:52:04 +01:00
|
|
|
parseJourney,
|
|
|
|
parseLine,
|
2024-12-21 15:26:49 +00:00
|
|
|
parseStationName: id,
|
2017-11-12 14:52:04 +01:00
|
|
|
parseLocation,
|
2018-05-16 21:07:05 +02:00
|
|
|
parsePolyline,
|
2017-11-12 14:52:04 +01:00
|
|
|
parseOperator,
|
2024-12-07 16:16:31 +00:00
|
|
|
parseRemarks,
|
2025-01-02 14:00:45 +00:00
|
|
|
parseCancelled,
|
2017-11-12 14:52:04 +01:00
|
|
|
parseStopover,
|
2024-12-21 15:26:49 +00:00
|
|
|
parseLoadFactor,
|
|
|
|
parseArrOrDepWithLoadFactor,
|
|
|
|
parseHintByCode,
|
|
|
|
parsePrice: notImplemented,
|
|
|
|
parseTickets: notImplemented,
|
2017-11-12 14:52:04 +01:00
|
|
|
|
|
|
|
formatAddress,
|
|
|
|
formatCoord,
|
|
|
|
formatDate,
|
2024-12-21 15:26:49 +00:00
|
|
|
formatLocation,
|
|
|
|
formatLocationFilter: notImplemented,
|
|
|
|
formatLoyaltyCard,
|
2017-11-12 14:52:04 +01:00
|
|
|
formatPoi,
|
2024-12-21 15:26:49 +00:00
|
|
|
formatProductsFilter,
|
2017-11-12 14:52:04 +01:00
|
|
|
formatStation,
|
2017-11-12 19:15:13 +01:00
|
|
|
formatTime,
|
2025-01-02 14:00:45 +00:00
|
|
|
formatTimeOfDay,
|
2024-12-21 15:26:49 +00:00
|
|
|
formatTravellers: notImplemented,
|
|
|
|
formatRectangle: id,
|
2021-12-29 18:06:46 +01:00
|
|
|
|
2024-12-21 15:26:49 +00:00
|
|
|
journeysOutFrwd: true,
|
2021-12-29 18:06:46 +01:00
|
|
|
departuresGetPasslist: false,
|
|
|
|
departuresStbFltrEquiv: false,
|
2024-12-21 15:26:49 +00:00
|
|
|
trip: true,
|
2018-07-24 18:28:33 +02:00
|
|
|
radar: false,
|
2019-12-17 14:12:35 +01:00
|
|
|
refreshJourney: true,
|
2024-12-21 16:30:11 +00:00
|
|
|
journeysFromTrip: false,
|
2021-01-10 20:45:37 +01:00
|
|
|
refreshJourneyUseOutReconL: false,
|
2024-12-07 16:16:31 +00:00
|
|
|
tripsByName: false,
|
|
|
|
remarks: false,
|
2024-12-21 15:26:49 +00:00
|
|
|
remarksGetPolyline: false,
|
2024-12-21 16:30:11 +00:00
|
|
|
reachableFrom: false,
|
2024-12-07 16:16:31 +00:00
|
|
|
lines: false,
|
2024-02-06 22:58:49 +01:00
|
|
|
};
|
2017-11-12 14:52:04 +01:00
|
|
|
|
2022-05-07 16:17:37 +02:00
|
|
|
export {
|
|
|
|
defaultProfile,
|
2024-02-06 22:58:49 +01:00
|
|
|
};
|