diff options
feat: initial commit
Diffstat (limited to 'src/lib/motis-types.ts')
-rw-r--r-- | src/lib/motis-types.ts | 496 |
1 files changed, 496 insertions, 0 deletions
diff --git a/src/lib/motis-types.ts b/src/lib/motis-types.ts new file mode 100644 index 0000000..2f05229 --- /dev/null +++ b/src/lib/motis-types.ts @@ -0,0 +1,496 @@ +export type Area = { + /** Name of the area */ + name: string; + /** {@link https://wiki.openstreetmap.org/wiki/Key:admin_level OpenStreetMap `admin_level`} of the area */ + adminLevel: number; + /** Whether this area was matched by the input text */ + matched: boolean; + /** Set for the first area after the `default` area that distinguishes areas if the match is ambiguous regarding (`default` area + place name / street [+ house number]). */ + unique: boolean; + /** Whether this area should be displayed as default area (area with admin level closest 7) */ + default: boolean; +}; +export type Match = { + /** location type */ + type: 'ADDRESS' | 'PLACE' | 'STOP'; + /** list of non-overlapping tokens that were matched */ + tokens: number[][]; + /** name of the location (transit stop / PoI / address) */ + name: string; + /** unique id of the location */ + id: string; + /** latitude */ + lat: number; + /** longitude */ + lon: number; + /** level according to OpenStreetMap (at the moment only for public transport) */ + level?: number; + /** street name */ + street?: string; + /** house number */ + houseNumber?: string; + /** zip code */ + zip?: string; + /** list of areas */ + areas: Area[]; +}; +export enum Mode { + // street // + Walk = 'WALK', + Bike = 'BIKE', + /** Experimental. Expect unannounced breaking changes (without version bumps) for all parameters and returned structs. */ + Rental = 'RENTAL', + Car = 'CAR', + /** Experimental. Expect unannounced breaking changes (without version bumps) for all parameters and returned structs. */ + CarParking = 'CAR_PARKING', + /** Experimental. Expect unannounced breaking changes (without version bumps) for all parameters and returned structs. */ + CarDropoff = 'CAR_DROPOFF', + /** on-demand taxis from the Prima+ÖV Project */ + ODM = 'ODM', + /** flexible transports */ + Flex = 'FLEX', + + // transit // + + /** translates to `RAIL,TRAM,BUS,FERRY,AIRPLANE,COACH,CABLE_CAR,FUNICULAR,AREAL_LIFT,OTHER` */ + Transit = 'TRANSIT', + /** trams */ + Tram = 'TRAM', + /** subway trains */ + Subway = 'SUBWAY', + /** ferries */ + Ferry = 'FERRY', + /** airline flights */ + Airplane = 'AIRPLANE', + /** metro trains */ + Metro = 'METRO', + /** short distance buses (does not include `COACH`) */ + Bus = 'BUS', + /** long distance buses (does not include `BUS`) */ + Coach = 'COACH', + /** translates to `HIGHSPEED_RAIL,LONG_DISTANCE,NIGHT_RAIL,REGIONAL_RAIL,REGIONAL_FAST_RAIL,METRO,SUBWAY` */ + Rail = 'RAIL', + /** long distance high speed trains (e.g. TGV, ICE) */ + HighspeedRail = 'HIGHSPEED_RAIL', + /** long distance inter city trains */ + LongDistanceRail = 'LONG_DISTANCE', + /** long distance night trains */ + NightRail = 'NIGHT_RAIL', + /** regional express routes that skip low traffic stops to be faster */ + RegionalFastRail = 'REGIONAL_FAST_RAIL', + /** regional train */ + RegionalRail = 'REGIONAL_RAIL', + /** Cable tram. Used for street-level rail cars where the cable runs beneath the vehicle (e.g., cable car in San Francisco). */ + CableTram = 'CABLE_CAR', + /** Funicular. Any rail system designed for steep inclines. */ + Funicular = 'FUNICULAR', + /** Aerial lift, suspended cable car (e.g., gondola lift, aerial tramway). Cable transport where cabins, cars, gondolas or open chairs are suspended by means of one or more cables. */ + AerialLift = 'AREAL_LIFT', + Other = 'OTHER', +} + +/** + * - `NORMAL` - latitude / longitude coordinate or address + * - `BIKESHARE` - bike sharing station + * - `TRANSIT` - transit stop + */ +export type VertexType = 'NORMAL' | 'BIKESHARE' | 'TRANSIT'; +/** + * - `NORMAL` - entry/exit is possible normally + * - `NOT_ALLOWED` - entry/exit is not allowed + */ +export type PickupDropoffType = 'NORMAL' | 'NOT_ALLOWED'; + +/** Cause of this alert. */ +export type AlertCause = + | 'UNKNOWN_CAUSE' + | 'OTHER_CAUSE' + | 'TECHNICAL_PROBLEM' + | 'STRIKE' + | 'DEMONSTRATION' + | 'ACCIDENT' + | 'HOLIDAY' + | 'WEATHER' + | 'MAINTENANCE' + | 'CONSTRUCTION' + | 'POLICE_ACTIVITY' + | 'MEDICAL_EMERGENCY'; +/** The effect of this problem on the affected entity. */ +export type AlertEffect = + | 'NO_SERVICE' + | 'REDUCED_SERVICE' + | 'SIGNIFICANT_DELAYS' + | 'DETOUR' + | 'ADDITIONAL_SERVICE' + | 'MODIFIED_SERVICE' + | 'OTHER_EFFECT' + | 'UNKNOWN_EFFECT' + | 'STOP_MOVED' + | 'NO_EFFECT' + | 'ACCESSIBILITY_ISSUE'; +/** The severity of the alert. */ +export type AlertSeverityLevel = + | 'UNKNOWN_SEVERITY' + | 'INFO' + | 'WARNING' + | 'SEVERE'; +/** + * A time interval. + * The interval is considered active at time t if t is greater than or equal to the start time and less than the end time. + */ +export type TimeRange = { + /** + * If missing, the interval starts at minus infinity. + * If a TimeRange is provided, either start or end must be provided - both fields cannot be empty. + */ + start?: string; + /** + * If missing, the interval ends at plus infinity. + * If a TimeRange is provided, either start or end must be provided - both fields cannot be empty. + */ + end?: string; +}; +/** + * An alert, indicating some sort of incident in the public transit network. + */ +export type Alert = { + /** + * Time when the alert should be shown to the user. + * If missing, the alert will be shown as long as it appears in the feed. + * If multiple ranges are given, the alert will be shown during all of them. + */ + communicationPeriod?: Array<TimeRange>; + + /** + * Time when the services are affected by the disruption mentioned in the alert. + */ + impactPeriod?: Array<TimeRange>; + + cause?: AlertCause; + + /** + * * Description of the cause of the alert that allows for agency-specific language; + * more specific than the Cause. + * + */ + causeDetail?: string; + + effect?: AlertEffect; + + /** + * * Description of the effect of the alert that allows for agency-specific language; + * more specific than the Effect. + * + */ + effectDetail?: string; + + /** + * * The URL which provides additional information about the alert. + */ + url?: string; + + /** + * * Header for the alert. This plain-text string will be highlighted, for example in boldface. + * + */ + headerText: string; + + /** + * * Description for the alert. + * This plain-text string will be formatted as the body of the alert (or shown on an explicit "expand" request by the user). + * The information in the description should add to the information of the header. + * + */ + descriptionText: string; + + /** + * * Text containing the alert's header to be used for text-to-speech implementations. + * This field is the text-to-speech version of header_text. + * It should contain the same information as headerText but formatted such that it can read as text-to-speech + * (for example, abbreviations removed, numbers spelled out, etc.) + * + */ + ttsHeaderText?: string; + + /** + * * Text containing a description for the alert to be used for text-to-speech implementations. + * This field is the text-to-speech version of description_text. + * It should contain the same information as description_text but formatted such that it can be read as text-to-speech + * (for example, abbreviations removed, numbers spelled out, etc.) + * + */ + ttsDescriptionText?: string; + + /** + * * Severity of the alert. + */ + severityLevel?: AlertSeverityLevel; + + /** + * * String containing an URL linking to an image. + */ + imageUrl?: string; + + /** + * * IANA media type as to specify the type of image to be displayed. The type must start with "image/" + * + */ + imageMediaType?: string; + + /** + * * Text describing the appearance of the linked image in the image field + * (e.g., in case the image can't be displayed or the user can't see the image for accessibility reasons). + * See the HTML spec for alt image text. + * + */ + imageAlternativeText?: string; +}; + +export type Place = { + /** + * name of the transit stop / PoI / address + */ + name: string; + + /** + * The ID of the stop. This is often something that users don't care about. + */ + stopId?: string; + + /** + * latitude + */ + lat: number; + + /** + * longitude + */ + lon: number; + + /** + * level according to OpenStreetMap + */ + level: number; + + /** + * arrival time + */ + arrival?: string; + + /** + * departure time + */ + departure?: string; + + /** + * scheduled arrival time + */ + scheduledArrival?: string; + + /** + * scheduled departure time + */ + scheduledDeparture?: string; + + /** + * scheduled track from the static schedule timetable dataset + */ + scheduledTrack?: string; + + /** + * The current track/platform information, updated with real-time updates if available. + * Can be missing if neither real-time updates nor the schedule timetable contains track information. + * + */ + track?: string; + + /** + * description of the location that provides more detailed information + */ + description?: string; + + vertexType?: VertexType; + + /** + * Type of pickup. It could be disallowed due to schedule, skipped stops or cancellations. + */ + pickupType?: PickupDropoffType; + + /** + * Type of dropoff. It could be disallowed due to schedule, skipped stops or cancellations. + */ + dropoffType?: PickupDropoffType; + + /** + * Whether this stop is cancelled due to the realtime situation. + */ + cancelled?: boolean; + + /** + * Alerts for this stop. + */ + alerts?: Array<Alert>; + + /** + * for `FLEX` transports, the flex location area or location group name + */ + flex?: string; + + /** + * for `FLEX` transports, the flex location area ID or location group ID + */ + flexId?: string; + + /** + * Time that on-demand service becomes available + */ + flexStartPickupDropOffWindow?: string; + + /** + * Time that on-demand service ends + */ + flexEndPickupDropOffWindow?: string; +}; +/** + * departure or arrival event at a stop + */ +export type StopTime = { + /** + * information about the stop place and time + */ + place: Place; + /** + * Transport mode for this leg + */ + mode: Mode; + /** + * Whether there is real-time data about this leg + */ + realTime: boolean; + /** + * For transit legs, the headsign of the bus or train being used. + * For non-transit legs, null + * + */ + headsign: string; + agencyId: string; + agencyName: string; + agencyUrl: string; + routeColor?: string; + routeTextColor?: string; + tripId: string; + routeShortName: string; + /** + * Type of pickup (for departures) or dropoff (for arrivals), may be disallowed either due to schedule, skipped stops or cancellations + */ + pickupDropoffType: PickupDropoffType; + /** + * Whether the departure/arrival is cancelled due to the realtime situation (either because the stop is skipped or because the entire trip is cancelled). + */ + cancelled: boolean; + /** + * Whether the entire trip is cancelled due to the realtime situation. + */ + tripCancelled: boolean; + /** + * Filename and line number where this trip is from + */ + source: string; +}; +export type StoptimesResponse = { + /** + * list of stop times + */ + stopTimes: Array<StopTime>; + /** + * metadata of the requested stop + */ + place: Place; + /** + * Use the cursor to get the previous page of results. Insert the cursor into the request and post it to get the previous page. + * The previous page is a set of stop times BEFORE the first stop time in the result. + * + */ + previousPageCursor: string; + /** + * Use the cursor to get the next page of results. Insert the cursor into the request and post it to get the next page. + * The next page is a set of stop times AFTER the last stop time in this result. + * + */ + nextPageCursor: string; +}; +// export type StoptimesData = { +// query: { +// /** +// * Optional. Default is `false`. +// * +// * - `arriveBy=true`: the parameters `date` and `time` refer to the arrival time +// * - `arriveBy=false`: the parameters `date` and `time` refer to the departure time +// * +// */ +// arriveBy?: boolean; +// /** +// * This parameter will be ignored in case `pageCursor` is set. +// * +// * Optional. Default is +// * - `LATER` for `arriveBy=false` +// * - `EARLIER` for `arriveBy=true` +// * +// * The response will contain the next `n` arrivals / departures +// * in case `EARLIER` is selected and the previous `n` +// * arrivals / departures if `LATER` is selected. +// * +// */ +// direction?: 'EARLIER' | 'LATER'; +// /** +// * Optional. Default is `false`. +// * +// * If set to `true`, only stations that are phyiscally in the radius are considered. +// * If set to `false`, additionally to the stations in the radius, equivalences with the same name and children are considered. +// * +// */ +// exactRadius?: boolean; +// /** +// * Optional. Default is all transit modes. +// * +// * Only return arrivals/departures of the given modes. +// * +// */ +// mode?: Array<Mode>; +// /** +// * the number of events +// */ +// n: number; +// /** +// * Use the cursor to go to the next "page" of stop times. +// * Copy the cursor from the last response and keep the original request as is. +// * This will enable you to search for stop times in the next or previous time-window. +// * +// */ +// pageCursor?: string; +// /** +// * Optional. Radius in meters. +// * +// * Default is that only stop times of the parent of the stop itself +// * and all stops with the same name (+ their child stops) are returned. +// * +// * If set, all stops at parent stations and their child stops in the specified radius +// * are returned. +// * +// */ +// radius?: number; +// /** +// * stop id of the stop to retrieve departures/arrivals for +// */ +// stopId: string; +// /** +// * Optional. Defaults to the current time. +// * +// */ +// time?: string; +// /** +// * Optional. Include stoptimes where passengers can not alight/board according to schedule. +// */ +// withScheduledSkippedStops?: boolean; +// }; +// }; |