bengaluru-transit 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (123) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +507 -0
  3. package/dist/api/info.d.ts +77 -0
  4. package/dist/api/info.d.ts.map +1 -0
  5. package/dist/api/info.js +197 -0
  6. package/dist/api/info.js.map +1 -0
  7. package/dist/api/locations.d.ts +26 -0
  8. package/dist/api/locations.d.ts.map +1 -0
  9. package/dist/api/locations.js +57 -0
  10. package/dist/api/locations.js.map +1 -0
  11. package/dist/api/routes.d.ts +341 -0
  12. package/dist/api/routes.d.ts.map +1 -0
  13. package/dist/api/routes.js +1133 -0
  14. package/dist/api/routes.js.map +1 -0
  15. package/dist/api/stops.d.ts +92 -0
  16. package/dist/api/stops.d.ts.map +1 -0
  17. package/dist/api/stops.js +237 -0
  18. package/dist/api/stops.js.map +1 -0
  19. package/dist/api/vehicles.d.ts +49 -0
  20. package/dist/api/vehicles.d.ts.map +1 -0
  21. package/dist/api/vehicles.js +154 -0
  22. package/dist/api/vehicles.js.map +1 -0
  23. package/dist/client/base-client.d.ts +52 -0
  24. package/dist/client/base-client.d.ts.map +1 -0
  25. package/dist/client/base-client.js +76 -0
  26. package/dist/client/base-client.js.map +1 -0
  27. package/dist/client/transit-client.d.ts +91 -0
  28. package/dist/client/transit-client.d.ts.map +1 -0
  29. package/dist/client/transit-client.js +98 -0
  30. package/dist/client/transit-client.js.map +1 -0
  31. package/dist/constants/api.d.ts +16 -0
  32. package/dist/constants/api.d.ts.map +1 -0
  33. package/dist/constants/api.js +16 -0
  34. package/dist/constants/api.js.map +1 -0
  35. package/dist/constants/routes.d.ts +16 -0
  36. package/dist/constants/routes.d.ts.map +1 -0
  37. package/dist/constants/routes.js +16 -0
  38. package/dist/constants/routes.js.map +1 -0
  39. package/dist/index.d.ts +11 -0
  40. package/dist/index.d.ts.map +1 -0
  41. package/dist/index.js +10 -0
  42. package/dist/index.js.map +1 -0
  43. package/dist/schemas/common.d.ts +34 -0
  44. package/dist/schemas/common.d.ts.map +1 -0
  45. package/dist/schemas/common.js +20 -0
  46. package/dist/schemas/common.js.map +1 -0
  47. package/dist/schemas/index.d.ts +7 -0
  48. package/dist/schemas/index.d.ts.map +1 -0
  49. package/dist/schemas/index.js +7 -0
  50. package/dist/schemas/index.js.map +1 -0
  51. package/dist/schemas/info.d.ts +390 -0
  52. package/dist/schemas/info.d.ts.map +1 -0
  53. package/dist/schemas/info.js +110 -0
  54. package/dist/schemas/info.js.map +1 -0
  55. package/dist/schemas/locations.d.ts +84 -0
  56. package/dist/schemas/locations.d.ts.map +1 -0
  57. package/dist/schemas/locations.js +31 -0
  58. package/dist/schemas/locations.js.map +1 -0
  59. package/dist/schemas/routes.d.ts +3967 -0
  60. package/dist/schemas/routes.d.ts.map +1 -0
  61. package/dist/schemas/routes.js +532 -0
  62. package/dist/schemas/routes.js.map +1 -0
  63. package/dist/schemas/stops.d.ts +543 -0
  64. package/dist/schemas/stops.d.ts.map +1 -0
  65. package/dist/schemas/stops.js +129 -0
  66. package/dist/schemas/stops.js.map +1 -0
  67. package/dist/schemas/vehicles.d.ts +602 -0
  68. package/dist/schemas/vehicles.d.ts.map +1 -0
  69. package/dist/schemas/vehicles.js +116 -0
  70. package/dist/schemas/vehicles.js.map +1 -0
  71. package/dist/types/api.d.ts +9 -0
  72. package/dist/types/api.d.ts.map +1 -0
  73. package/dist/types/api.js +5 -0
  74. package/dist/types/api.js.map +1 -0
  75. package/dist/types/coordinates.d.ts +7 -0
  76. package/dist/types/coordinates.d.ts.map +1 -0
  77. package/dist/types/coordinates.js +2 -0
  78. package/dist/types/coordinates.js.map +1 -0
  79. package/dist/types/geojson.d.ts +84 -0
  80. package/dist/types/geojson.d.ts.map +1 -0
  81. package/dist/types/geojson.js +2 -0
  82. package/dist/types/geojson.js.map +1 -0
  83. package/dist/types/index.d.ts +16 -0
  84. package/dist/types/index.d.ts.map +1 -0
  85. package/dist/types/index.js +12 -0
  86. package/dist/types/index.js.map +1 -0
  87. package/dist/types/info.d.ts +133 -0
  88. package/dist/types/info.d.ts.map +1 -0
  89. package/dist/types/info.js +5 -0
  90. package/dist/types/info.js.map +1 -0
  91. package/dist/types/locations.d.ts +59 -0
  92. package/dist/types/locations.d.ts.map +1 -0
  93. package/dist/types/locations.js +5 -0
  94. package/dist/types/locations.js.map +1 -0
  95. package/dist/types/routes.d.ts +1137 -0
  96. package/dist/types/routes.d.ts.map +1 -0
  97. package/dist/types/routes.js +14 -0
  98. package/dist/types/routes.js.map +1 -0
  99. package/dist/types/stops.d.ts +286 -0
  100. package/dist/types/stops.d.ts.map +1 -0
  101. package/dist/types/stops.js +26 -0
  102. package/dist/types/stops.js.map +1 -0
  103. package/dist/types/vehicles.d.ts +138 -0
  104. package/dist/types/vehicles.d.ts.map +1 -0
  105. package/dist/types/vehicles.js +5 -0
  106. package/dist/types/vehicles.js.map +1 -0
  107. package/dist/utils/date.d.ts +35 -0
  108. package/dist/utils/date.d.ts.map +1 -0
  109. package/dist/utils/date.js +49 -0
  110. package/dist/utils/date.js.map +1 -0
  111. package/dist/utils/errors.d.ts +34 -0
  112. package/dist/utils/errors.d.ts.map +1 -0
  113. package/dist/utils/errors.js +41 -0
  114. package/dist/utils/errors.js.map +1 -0
  115. package/dist/utils/geojson.d.ts +36 -0
  116. package/dist/utils/geojson.d.ts.map +1 -0
  117. package/dist/utils/geojson.js +115 -0
  118. package/dist/utils/geojson.js.map +1 -0
  119. package/dist/utils/validation.d.ts +40 -0
  120. package/dist/utils/validation.d.ts.map +1 -0
  121. package/dist/utils/validation.js +62 -0
  122. package/dist/utils/validation.js.map +1 -0
  123. package/package.json +77 -0
@@ -0,0 +1,1137 @@
1
+ /**
2
+ * Types for route-related API endpoints
3
+ */
4
+ import type { z } from "zod";
5
+ /**
6
+ * Route direction type - lowercase normalized values
7
+ */
8
+ export type RouteDirection = "up" | "down";
9
+ import type { rawRoutePointsResponseSchema, rawRouteSearchResponseSchema, rawAllRoutesResponseSchema, rawTimetableResponseSchema, rawRouteDetailsResponseSchema, rawRoutesBetweenStationsResponseSchema, rawFareDataResponseSchema, rawTripPlannerResponseSchema, rawPathDetailsResponseSchema, rawTimetableByStationResponseSchema } from "../schemas/routes";
10
+ import type { RouteFeatureCollection, LocationFeatureCollection, StopProperties } from "./geojson";
11
+ import type { Feature, FeatureCollection, Point } from "geojson";
12
+ import type { Coordinate } from "./coordinates";
13
+ /**
14
+ * Raw route point data item from BMTC API
15
+ */
16
+ export interface RawRoutePointItem {
17
+ latitude: string;
18
+ longitude: string;
19
+ responsecode: number;
20
+ }
21
+ /**
22
+ * Raw route points API response from BMTC API (for validation)
23
+ * Uses Zod inferred type to match schema exactly
24
+ */
25
+ export type RawRoutePointsResponse = z.infer<typeof rawRoutePointsResponseSchema>;
26
+ /**
27
+ * Clean, normalized route points response
28
+ */
29
+ export interface RoutePointsResponse {
30
+ /**
31
+ * Route path as GeoJSON FeatureCollection (LineString feature)
32
+ */
33
+ routePath: RouteFeatureCollection;
34
+ }
35
+ /**
36
+ * Parameters for getting route points
37
+ */
38
+ export interface RoutePointsParams {
39
+ /**
40
+ * Route ID (obtained from getVehicleTrip, always string for consistency)
41
+ */
42
+ routeId: string;
43
+ }
44
+ /**
45
+ * Raw route search result item from BMTC API
46
+ */
47
+ export interface RawRouteSearchItem {
48
+ union_rowno: number;
49
+ row: number;
50
+ routeno: string;
51
+ responsecode: number;
52
+ routeparentid: number;
53
+ }
54
+ /**
55
+ * Raw route search API response from BMTC API (for validation)
56
+ * Uses Zod inferred type to match schema exactly
57
+ */
58
+ export type RawRouteSearchResponse = z.infer<typeof rawRouteSearchResponseSchema>;
59
+ /**
60
+ * Clean, normalized route search result item
61
+ */
62
+ export interface RouteSearchItem {
63
+ /**
64
+ * Union row number (grouping identifier)
65
+ */
66
+ unionRowNo: number;
67
+ /**
68
+ * Row number within the union group
69
+ */
70
+ row: number;
71
+ /**
72
+ * Route number/name (e.g., "80-A", "80-A D31G-KBS")
73
+ */
74
+ routeNo: string;
75
+ /**
76
+ * Parent route ID (groups multiple subroutes, used for endpoints like getRoutePoints, always string for consistency)
77
+ */
78
+ parentRouteId: string;
79
+ }
80
+ /**
81
+ * Clean, normalized route search response
82
+ */
83
+ export interface RouteSearchResponse {
84
+ items: RouteSearchItem[];
85
+ }
86
+ /**
87
+ * Parameters for searching routes
88
+ */
89
+ export interface RouteSearchParams {
90
+ /**
91
+ * Search query for routes (partial match supported)
92
+ * e.g., "80-a" will match "80-A", "180-A", "280-A", etc.
93
+ */
94
+ query: string;
95
+ }
96
+ /**
97
+ * Raw route list item from GetAllRouteList API
98
+ */
99
+ export interface RawRouteListItem {
100
+ routeid: number;
101
+ routeno: string;
102
+ routename: string;
103
+ fromstationid: number;
104
+ fromstation: string;
105
+ tostationid: number;
106
+ tostation: string;
107
+ responsecode: number;
108
+ }
109
+ /**
110
+ * Raw all routes API response from BMTC API (for validation)
111
+ * Uses Zod inferred type to match schema exactly
112
+ */
113
+ export type RawAllRoutesResponse = z.infer<typeof rawAllRoutesResponseSchema>;
114
+ /**
115
+ * Clean, normalized route list item
116
+ */
117
+ export interface RouteListItem {
118
+ /**
119
+ * Subroute ID (specific directional variant, e.g., "89-C UP" or "89-C DOWN", always string for consistency)
120
+ */
121
+ subrouteId: string;
122
+ /**
123
+ * Route number (e.g., "89-C UP", "89-C DOWN")
124
+ */
125
+ routeNo: string;
126
+ /**
127
+ * Route name (e.g., "KBS-CVN", "CVN-KBS")
128
+ */
129
+ routeName: string;
130
+ /**
131
+ * From stop ID (always string for consistency)
132
+ * Note: "stop" refers to any bus stop. Use "station" only for major bus stations with facilities.
133
+ */
134
+ fromStopId: string;
135
+ /**
136
+ * From stop name
137
+ */
138
+ fromStop: string;
139
+ /**
140
+ * To stop ID (always string for consistency)
141
+ * Note: "stop" refers to any bus stop. Use "station" only for major bus stations with facilities.
142
+ */
143
+ toStopId: string;
144
+ /**
145
+ * To stop name
146
+ */
147
+ toStop: string;
148
+ }
149
+ /**
150
+ * Clean, normalized all routes response
151
+ */
152
+ export interface AllRoutesResponse {
153
+ items: RouteListItem[];
154
+ }
155
+ /**
156
+ * Raw trip detail item from timetable API
157
+ */
158
+ export interface RawTripDetailItem {
159
+ starttime: string;
160
+ endtime: string;
161
+ }
162
+ /**
163
+ * Raw timetable data item from BMTC API
164
+ */
165
+ export interface RawTimetableItem {
166
+ fromstationname: string;
167
+ tostationname: string;
168
+ fromstationid: string;
169
+ tostationid: string;
170
+ apptime: string;
171
+ distance: string;
172
+ platformname: string;
173
+ platformnumber: string;
174
+ baynumber: string;
175
+ tripdetails: RawTripDetailItem[];
176
+ }
177
+ /**
178
+ * Raw timetable API response from BMTC API (for validation)
179
+ * Uses Zod inferred type to match schema exactly
180
+ */
181
+ export type RawTimetableResponse = z.infer<typeof rawTimetableResponseSchema>;
182
+ /**
183
+ * Clean, normalized trip detail item
184
+ */
185
+ export interface TripDetailItem {
186
+ /**
187
+ * Start time in format "HH:mm"
188
+ */
189
+ startTime: string;
190
+ /**
191
+ * End time in format "HH:mm"
192
+ */
193
+ endTime: string;
194
+ }
195
+ /**
196
+ * Clean, normalized timetable item
197
+ */
198
+ export interface TimetableItem {
199
+ /**
200
+ * From stop name
201
+ */
202
+ fromStopName: string;
203
+ /**
204
+ * To stop name
205
+ */
206
+ toStopName: string;
207
+ /**
208
+ * From stop ID (string as returned by API)
209
+ */
210
+ fromStopId: string;
211
+ /**
212
+ * To stop ID (string as returned by API)
213
+ */
214
+ toStopId: string;
215
+ /**
216
+ * Approximate travel time in format "HH:mm:ss"
217
+ */
218
+ approximateTime: string;
219
+ /**
220
+ * Distance in kilometers
221
+ */
222
+ distance: number;
223
+ /**
224
+ * Platform name
225
+ */
226
+ platformName: string;
227
+ /**
228
+ * Platform number
229
+ */
230
+ platformNumber: string;
231
+ /**
232
+ * Bay number
233
+ */
234
+ bayNumber: string;
235
+ /**
236
+ * List of trip details with start and end times
237
+ */
238
+ tripDetails: TripDetailItem[];
239
+ }
240
+ /**
241
+ * Clean, normalized timetable response
242
+ */
243
+ export interface TimetableResponse {
244
+ items: TimetableItem[];
245
+ }
246
+ /**
247
+ * Base parameters for getting timetable by route ID
248
+ */
249
+ interface TimetableByRouteBaseParams {
250
+ /**
251
+ * Route ID (always string for consistency)
252
+ */
253
+ routeId: string;
254
+ /**
255
+ * Start time (optional - defaults to current time)
256
+ * The wrapper converts this to "YYYY-MM-DD HH:mm" format
257
+ */
258
+ startTime?: Date;
259
+ /**
260
+ * End time (optional - defaults to "23:59" of startTime date)
261
+ * The wrapper converts this to "YYYY-MM-DD HH:mm" format
262
+ */
263
+ endTime?: Date;
264
+ }
265
+ /**
266
+ * Parameters for getting timetable with specific stops
267
+ */
268
+ export interface TimetableByRouteParamsWithStops extends TimetableByRouteBaseParams {
269
+ /**
270
+ * From stop ID (required with toStopId, string as returned by API)
271
+ */
272
+ fromStopId: string;
273
+ /**
274
+ * To stop ID (required with fromStopId, string as returned by API)
275
+ */
276
+ toStopId: string;
277
+ }
278
+ /**
279
+ * Parameters for getting timetable without specific stops (uses route start/end)
280
+ */
281
+ export interface TimetableByRouteParamsWithoutStops extends TimetableByRouteBaseParams {
282
+ /**
283
+ * From stop ID must not be provided
284
+ */
285
+ fromStopId?: never;
286
+ /**
287
+ * To stop ID must not be provided
288
+ */
289
+ toStopId?: never;
290
+ }
291
+ /**
292
+ * Parameters for getting timetable by route ID
293
+ * Type-safe: either both fromStopId and toStopId are provided, or neither
294
+ */
295
+ export type TimetableByRouteParams = TimetableByRouteParamsWithStops | TimetableByRouteParamsWithoutStops;
296
+ /**
297
+ * Raw vehicle detail item from SearchByRouteDetails_v4 API
298
+ */
299
+ export interface RawRouteDetailVehicleItem {
300
+ vehicleid: number;
301
+ vehiclenumber: string;
302
+ servicetypeid: number;
303
+ servicetype: string;
304
+ centerlat: number;
305
+ centerlong: number;
306
+ eta: string;
307
+ sch_arrivaltime: string;
308
+ sch_departuretime: string;
309
+ actual_arrivaltime: string;
310
+ actual_departuretime: string;
311
+ sch_tripstarttime: string;
312
+ sch_tripendtime: string;
313
+ lastlocationid: number;
314
+ currentlocationid: number;
315
+ nextlocationid: number;
316
+ currentstop: string | null;
317
+ nextstop: string | null;
318
+ laststop: string | null;
319
+ stopCoveredStatus: number;
320
+ heading: number;
321
+ lastrefreshon: string;
322
+ lastreceiveddatetimeflag: number;
323
+ tripposition: number;
324
+ }
325
+ /**
326
+ * Raw station data item from SearchByRouteDetails_v4 API
327
+ */
328
+ export interface RawRouteDetailStationItem {
329
+ routeid: number;
330
+ stationid: number;
331
+ stationname: string;
332
+ from: string;
333
+ to: string;
334
+ routeno: string;
335
+ distance_on_station: number;
336
+ centerlat: number;
337
+ centerlong: number;
338
+ responsecode: number;
339
+ isnotify: number;
340
+ vehicleDetails: RawRouteDetailVehicleItem[];
341
+ }
342
+ /**
343
+ * Raw direction data (up or down) from SearchByRouteDetails_v4 API
344
+ */
345
+ export interface RawRouteDetailDirectionData {
346
+ data: RawRouteDetailStationItem[];
347
+ mapData: RawRouteDetailVehicleItem[];
348
+ }
349
+ /**
350
+ * Raw SearchByRouteDetails_v4 API response from BMTC API (for validation)
351
+ * Uses Zod inferred type to match schema exactly
352
+ */
353
+ export type RawRouteDetailsResponse = z.infer<typeof rawRouteDetailsResponseSchema>;
354
+ /**
355
+ * Clean, normalized vehicle detail item (for station vehicles)
356
+ * Note: This is used as properties in GeoJSON features, excluding centerLat/centerLong
357
+ */
358
+ export interface RouteDetailVehicleProperties {
359
+ vehicleId: string;
360
+ vehicleNumber: string;
361
+ serviceTypeId: string;
362
+ serviceType: string;
363
+ /**
364
+ * Station ID where this vehicle is at/near
365
+ */
366
+ stationId?: string;
367
+ eta: string;
368
+ scheduledArrivalTime: string;
369
+ scheduledDepartureTime: string;
370
+ actualArrivalTime: string;
371
+ actualDepartureTime: string;
372
+ scheduledTripStartTime: string;
373
+ scheduledTripEndTime: string;
374
+ lastLocationId: string;
375
+ currentLocationId: string;
376
+ nextLocationId: string;
377
+ currentStop: string | null;
378
+ nextStop: string | null;
379
+ lastStop: string | null;
380
+ stopCoveredStatus: number;
381
+ heading: number;
382
+ lastRefreshOn: string;
383
+ lastReceivedDateTimeFlag: number;
384
+ tripPosition: number;
385
+ }
386
+ /**
387
+ * Clean, normalized vehicle detail item (deprecated - use RouteDetailVehicleProperties in GeoJSON)
388
+ * @deprecated Use RouteDetailVehicleProperties instead
389
+ */
390
+ export interface RouteDetailVehicleItem extends RouteDetailVehicleProperties {
391
+ centerLat: number;
392
+ centerLong: number;
393
+ }
394
+ /**
395
+ * Properties for a route detail station feature
396
+ * Extends StopProperties with route-specific fields
397
+ */
398
+ export interface RouteDetailStationProperties extends StopProperties {
399
+ /**
400
+ * Subroute ID (specific directional variant from the parent route)
401
+ * This is the subroute ID for the specific direction (UP or DOWN)
402
+ */
403
+ subrouteId: string;
404
+ from: string;
405
+ to: string;
406
+ routeNo: string;
407
+ distanceOnStation: number;
408
+ isNotify: number;
409
+ }
410
+ /**
411
+ * A route detail station represented as a GeoJSON Point Feature
412
+ */
413
+ export type RouteDetailStationFeature = Feature<Point, RouteDetailStationProperties>;
414
+ /**
415
+ * Clean, normalized direction data (up or down)
416
+ * All spatial data is returned as GeoJSON FeatureCollections
417
+ */
418
+ export interface RouteDetailDirectionData {
419
+ /**
420
+ * Bus stops/stations along the route as GeoJSON FeatureCollection (Point features)
421
+ */
422
+ stops: FeatureCollection<Point, RouteDetailStationProperties>;
423
+ /**
424
+ * Vehicles at/near stations as GeoJSON FeatureCollection (Point features)
425
+ * These are vehicles that are currently at or near specific stops
426
+ */
427
+ stationVehicles: FeatureCollection<Point, RouteDetailVehicleProperties>;
428
+ /**
429
+ * Live vehicles currently on the route for map display as GeoJSON FeatureCollection (Point features)
430
+ */
431
+ liveVehicles: LocationFeatureCollection;
432
+ }
433
+ /**
434
+ * Clean, normalized route details response
435
+ */
436
+ export interface RouteDetailsResponse {
437
+ up: RouteDetailDirectionData;
438
+ down: RouteDetailDirectionData;
439
+ }
440
+ /**
441
+ * Parameters for searching route details
442
+ */
443
+ export interface RouteDetailsParams {
444
+ /**
445
+ * Parent route ID (from searchRoutes().parentRouteId, always string for consistency)
446
+ * This is the parent route that groups multiple subroutes (UP/DOWN directions)
447
+ */
448
+ parentRouteId: string;
449
+ /**
450
+ * Service type ID (optional - from GetAllServiceTypes)
451
+ */
452
+ serviceTypeId?: string;
453
+ }
454
+ /**
455
+ * Raw route between stations item from GetFareRoutes API
456
+ */
457
+ export interface RawRouteBetweenStationsItem {
458
+ id: number;
459
+ fromstationid: number;
460
+ source_code: string;
461
+ from_displayname: string;
462
+ tostationid: number;
463
+ destination_code: string;
464
+ to_displayname: string;
465
+ fromdistance: number;
466
+ todistance: number;
467
+ routeid: number;
468
+ routeno: string;
469
+ routename: string;
470
+ route_direction: string;
471
+ fromstationname: string;
472
+ tostationname: string;
473
+ }
474
+ /**
475
+ * Raw routes between stations API response from BMTC API
476
+ * Uses Zod inferred type to match schema exactly
477
+ */
478
+ export type RawRoutesBetweenStationsResponse = z.infer<typeof rawRoutesBetweenStationsResponseSchema>;
479
+ /**
480
+ * Clean, normalized route between stops item
481
+ */
482
+ export interface RouteBetweenStopsItem {
483
+ id: string;
484
+ fromStopId: string;
485
+ sourceCode: string;
486
+ fromDisplayName: string;
487
+ toStopId: string;
488
+ destinationCode: string;
489
+ toDisplayName: string;
490
+ fromDistance: number;
491
+ toDistance: number;
492
+ /**
493
+ * Subroute ID (specific to direction/variant as indicated by routeDirection)
494
+ * Can be used with searchByRouteDetails() endpoint
495
+ * Note: This differs from parentRouteId returned by searchRoutes()
496
+ */
497
+ subrouteId: string;
498
+ routeNo: string;
499
+ routeName: string;
500
+ /**
501
+ * Route direction ("up" or "down" - lowercase normalized)
502
+ * Indicates this is a directional subroute
503
+ */
504
+ routeDirection: RouteDirection;
505
+ fromStopName: string;
506
+ toStopName: string;
507
+ }
508
+ /**
509
+ * Clean, normalized routes between stops response
510
+ */
511
+ export interface RoutesBetweenStopsResponse {
512
+ items: RouteBetweenStopsItem[];
513
+ }
514
+ /**
515
+ * Parameters for getting routes between stops
516
+ */
517
+ export interface RoutesBetweenStopsParams {
518
+ /**
519
+ * From stop ID (always string for consistency)
520
+ */
521
+ fromStopId: string;
522
+ /**
523
+ * To stop ID (always string for consistency)
524
+ */
525
+ toStopId: string;
526
+ }
527
+ /**
528
+ * Raw fare data item from GetMobileFareData_v2 API
529
+ */
530
+ export interface RawFareDataItem {
531
+ servicetype: string;
532
+ fare: string;
533
+ }
534
+ /**
535
+ * Raw fare data response from GetMobileFareData_v2 API
536
+ * Uses Zod inferred type to match schema exactly
537
+ */
538
+ export type RawFareDataResponse = z.infer<typeof rawFareDataResponseSchema>;
539
+ /**
540
+ * Clean, normalized fare data item
541
+ */
542
+ export interface FareDataItem {
543
+ /**
544
+ * Service type name (e.g., "Vajra", "Volvo Electric")
545
+ */
546
+ serviceType: string;
547
+ /**
548
+ * Fare amount as string (always string for consistency, even if numeric)
549
+ */
550
+ fare: string;
551
+ }
552
+ /**
553
+ * Clean, normalized fare data response
554
+ */
555
+ export interface FareDataResponse {
556
+ items: FareDataItem[];
557
+ }
558
+ /**
559
+ * Parameters for getting fare data
560
+ * These parameters match the response from getRoutesBetweenStations()
561
+ */
562
+ export interface FareDataParams {
563
+ /**
564
+ * Route number (from RouteBetweenStationsItem.routeNo)
565
+ */
566
+ routeNo: string;
567
+ /**
568
+ * Subroute ID (from RouteBetweenStationsItem.subrouteId)
569
+ * This is the subroute ID for the specific direction
570
+ */
571
+ subrouteId: string;
572
+ /**
573
+ * Route direction ("up" or "down" - lowercase normalized) from RouteBetweenStationsItem.routeDirection
574
+ */
575
+ routeDirection: RouteDirection;
576
+ /**
577
+ * Source code (from RouteBetweenStationsItem.sourceCode)
578
+ */
579
+ sourceCode: string;
580
+ /**
581
+ * Destination code (from RouteBetweenStationsItem.destinationCode)
582
+ */
583
+ destinationCode: string;
584
+ }
585
+ /**
586
+ * Filter option for trip planner
587
+ * Human-readable values that map to API numeric codes
588
+ */
589
+ export type TripPlannerFilter = "minimum-transfers" | "shortest-time";
590
+ /**
591
+ * Map human-readable filter option to API numeric value
592
+ */
593
+ export declare function tripPlannerFilterToNumber(filter: TripPlannerFilter): 1 | 2;
594
+ /**
595
+ * Base parameters for trip planner (common fields)
596
+ */
597
+ type TripPlannerParamsBase = {
598
+ /**
599
+ * Service type ID (from getAllServiceTypes)
600
+ * Optional - if not provided, searches all service types
601
+ */
602
+ serviceTypeId?: string;
603
+ /**
604
+ * Start date/time for the trip (must be in the future)
605
+ * The wrapper converts this to "YYYY-MM-DD HH:mm" format
606
+ * Optional - if not provided, uses current time
607
+ */
608
+ fromDateTime?: Date;
609
+ /**
610
+ * Filter option for route selection
611
+ * - "minimum-transfers": Prioritize fewer transfers
612
+ * - "shortest-time": Prioritize faster routes
613
+ * Optional - if not provided, API uses default sorting
614
+ */
615
+ filterBy?: TripPlannerFilter;
616
+ };
617
+ /**
618
+ * Stop to Stop trip parameters
619
+ */
620
+ type TripPlannerStopToStop = TripPlannerParamsBase & {
621
+ /**
622
+ * From stop ID (always string for consistency)
623
+ */
624
+ fromStopId: string;
625
+ /**
626
+ * To stop ID (always string for consistency)
627
+ */
628
+ toStopId: string;
629
+ /**
630
+ * From coordinates are not used for stop-to-stop trips
631
+ */
632
+ fromCoordinates?: never;
633
+ /**
634
+ * To coordinates are not used for stop-to-stop trips
635
+ */
636
+ toCoordinates?: never;
637
+ };
638
+ /**
639
+ * Stop to Location trip parameters
640
+ */
641
+ type TripPlannerStopToLocation = TripPlannerParamsBase & {
642
+ /**
643
+ * From stop ID (always string for consistency)
644
+ */
645
+ fromStopId: string;
646
+ /**
647
+ * To coordinates [latitude, longitude]
648
+ */
649
+ toCoordinates: Coordinate;
650
+ /**
651
+ * To stop ID is not used for stop-to-location trips
652
+ */
653
+ toStopId?: never;
654
+ /**
655
+ * From coordinates are not used for stop-to-location trips
656
+ */
657
+ fromCoordinates?: never;
658
+ };
659
+ /**
660
+ * Location to Stop trip parameters
661
+ */
662
+ type TripPlannerLocationToStop = TripPlannerParamsBase & {
663
+ /**
664
+ * From coordinates [latitude, longitude]
665
+ */
666
+ fromCoordinates: Coordinate;
667
+ /**
668
+ * To stop ID (always string for consistency)
669
+ */
670
+ toStopId: string;
671
+ /**
672
+ * From stop ID is not used for location-to-stop trips
673
+ */
674
+ fromStopId?: never;
675
+ /**
676
+ * To coordinates are not used for location-to-stop trips
677
+ */
678
+ toCoordinates?: never;
679
+ };
680
+ /**
681
+ * Location to Location trip parameters
682
+ */
683
+ type TripPlannerLocationToLocation = TripPlannerParamsBase & {
684
+ /**
685
+ * From coordinates [latitude, longitude]
686
+ */
687
+ fromCoordinates: Coordinate;
688
+ /**
689
+ * To coordinates [latitude, longitude]
690
+ */
691
+ toCoordinates: Coordinate;
692
+ /**
693
+ * Stop IDs are not used for location-to-location trips
694
+ */
695
+ fromStopId?: never;
696
+ toStopId?: never;
697
+ };
698
+ /**
699
+ * Parameters for trip planner
700
+ * Supports 4 combinations: Stop-Stop, Stop-Location, Location-Stop, Location-Location
701
+ */
702
+ export type TripPlannerParams = TripPlannerStopToStop | TripPlannerStopToLocation | TripPlannerLocationToStop | TripPlannerLocationToLocation;
703
+ /**
704
+ * Raw trip planner path leg item from TripPlannerMSMD API
705
+ */
706
+ export interface RawTripPlannerPathLeg {
707
+ pathSrno: number;
708
+ transferSrNo: number;
709
+ tripId: number;
710
+ routeid: number;
711
+ routeno: string;
712
+ schNo: string | null;
713
+ vehicleId: number;
714
+ busNo: string | null;
715
+ distance: number;
716
+ duration: string;
717
+ fromStationId: number;
718
+ fromStationName: string;
719
+ toStationId: number;
720
+ toStationName: string;
721
+ etaFromStation: string | null;
722
+ etaToStation: string | null;
723
+ serviceTypeId: number;
724
+ fromLatitude: number;
725
+ fromLongitude: number;
726
+ toLatitude: number;
727
+ toLongitude: number;
728
+ routeParentId: number;
729
+ totalDuration: string;
730
+ waitingDuration: string | null;
731
+ platformnumber: string;
732
+ baynumber: number;
733
+ devicestatusnameflag: string;
734
+ devicestatusflag: number;
735
+ srno: number;
736
+ approx_fare: number;
737
+ fromstagenumber: number;
738
+ tostagenumber: number;
739
+ minsrno: number;
740
+ maxsrno: number;
741
+ tollfees: number;
742
+ totalStages: number | null;
743
+ }
744
+ /**
745
+ * Raw trip planner response from TripPlannerMSMD API
746
+ * Uses Zod inferred type to match schema exactly
747
+ */
748
+ export type RawTripPlannerResponse = z.infer<typeof rawTripPlannerResponseSchema>;
749
+ /**
750
+ * Clean, normalized trip planner path leg
751
+ */
752
+ export interface TripPlannerPathLeg {
753
+ /**
754
+ * Path sequence number
755
+ */
756
+ pathSrNo: number;
757
+ /**
758
+ * Transfer sequence number (0 for direct routes, increments for transfers)
759
+ */
760
+ transferSrNo: number;
761
+ /**
762
+ * Trip ID (0 for walking segments)
763
+ */
764
+ tripId: string;
765
+ /**
766
+ * Subroute ID (specific directional variant, 0 for walking segments)
767
+ * This is the subroute ID for the specific direction/variant
768
+ */
769
+ subrouteId: string;
770
+ /**
771
+ * Route number (e.g., "285-M", "walk_source")
772
+ */
773
+ routeNo: string;
774
+ /**
775
+ * Schedule number (null for walking segments)
776
+ */
777
+ scheduleNo: string | null;
778
+ /**
779
+ * Vehicle ID (0 for walking segments)
780
+ */
781
+ vehicleId: string;
782
+ /**
783
+ * Bus registration number (null for walking segments)
784
+ */
785
+ busNo: string | null;
786
+ /**
787
+ * Distance in kilometers
788
+ */
789
+ distance: number;
790
+ /**
791
+ * Duration (format: "HH:mm:ss")
792
+ */
793
+ duration: string;
794
+ /**
795
+ * Duration in seconds (computed from duration string for easier comparisons)
796
+ */
797
+ durationSeconds: number;
798
+ /**
799
+ * From stop ID (0 for "Your Location")
800
+ */
801
+ fromStopId: string;
802
+ /**
803
+ * From stop name
804
+ */
805
+ fromStopName: string;
806
+ /**
807
+ * To stop ID (0 for "Your Location")
808
+ */
809
+ toStopId: string;
810
+ /**
811
+ * To stop name
812
+ */
813
+ toStopName: string;
814
+ /**
815
+ * ETA at from stop (null for walking segments)
816
+ */
817
+ etaFromStop: string | null;
818
+ /**
819
+ * ETA at to stop (null for walking segments)
820
+ */
821
+ etaToStop: string | null;
822
+ /**
823
+ * Service type ID (0 for walking segments)
824
+ */
825
+ serviceTypeId: string;
826
+ /**
827
+ * From latitude
828
+ */
829
+ fromLatitude: number;
830
+ /**
831
+ * From longitude
832
+ */
833
+ fromLongitude: number;
834
+ /**
835
+ * To latitude
836
+ */
837
+ toLatitude: number;
838
+ /**
839
+ * To longitude
840
+ */
841
+ toLongitude: number;
842
+ /**
843
+ * Route parent ID (0 for walking segments)
844
+ */
845
+ routeParentId: string;
846
+ /**
847
+ * Total duration for this leg (format: "HH:mm:ss")
848
+ */
849
+ totalDuration: string;
850
+ /**
851
+ * Total duration for this leg in seconds (computed from totalDuration string)
852
+ */
853
+ totalDurationSeconds: number;
854
+ /**
855
+ * Waiting duration before next leg (null if not applicable)
856
+ */
857
+ waitingDuration: string | null;
858
+ /**
859
+ * Platform number
860
+ */
861
+ platformNumber: string;
862
+ /**
863
+ * Bay number
864
+ */
865
+ bayNumber: number;
866
+ /**
867
+ * Device status name (e.g., "Running", "Tracking device is not installed")
868
+ */
869
+ deviceStatusName: string;
870
+ /**
871
+ * Device status flag
872
+ * - 1: Tracking device is installed
873
+ * - 3: Tracking device is not installed
874
+ * - 4: Running
875
+ */
876
+ deviceStatusFlag: number;
877
+ /**
878
+ * Sequence number
879
+ */
880
+ srNo: number;
881
+ /**
882
+ * Approximate fare (0 for walking segments)
883
+ */
884
+ approxFare: number;
885
+ /**
886
+ * From stage number
887
+ */
888
+ fromStageNumber: number;
889
+ /**
890
+ * To stage number
891
+ */
892
+ toStageNumber: number;
893
+ /**
894
+ * Minimum sequence number
895
+ */
896
+ minSrNo: number;
897
+ /**
898
+ * Maximum sequence number
899
+ */
900
+ maxSrNo: number;
901
+ /**
902
+ * Toll fees
903
+ */
904
+ tollFees: number;
905
+ /**
906
+ * Total stages (null if not applicable)
907
+ */
908
+ totalStages: number | null;
909
+ }
910
+ /**
911
+ * Trip planner route with computed totals
912
+ * Represents a complete route path (array of legs) with aggregated statistics
913
+ */
914
+ export interface TripPlannerRoute {
915
+ /**
916
+ * Route legs (ordered sequence of path segments)
917
+ */
918
+ legs: TripPlannerPathLeg[];
919
+ /**
920
+ * Total duration across all legs (format: "HH:mm:ss")
921
+ * Sum of all leg durations plus waiting times
922
+ */
923
+ totalDuration: string;
924
+ /**
925
+ * Total duration in seconds (computed from totalDuration for easier comparisons)
926
+ */
927
+ totalDurationSeconds: number;
928
+ /**
929
+ * Total fare in rupees (sum of all leg fares)
930
+ * Walking segments have 0 fare
931
+ */
932
+ totalFare: number;
933
+ /**
934
+ * Total distance in kilometers (sum of all leg distances)
935
+ */
936
+ totalDistance: number;
937
+ /**
938
+ * Number of transfers (number of bus segments minus 1, or 0 for direct routes)
939
+ */
940
+ transferCount: number;
941
+ /**
942
+ * Whether this route includes walking segments
943
+ */
944
+ hasWalking: boolean;
945
+ }
946
+ /**
947
+ * Clean, normalized trip planner response
948
+ */
949
+ export interface TripPlannerResponse {
950
+ /**
951
+ * All available routes (merged from directRoutes and transferRoutes)
952
+ * Each route includes computed totals for easy comparison
953
+ * Filter by `transferCount === 0` to identify direct routes (no transfers)
954
+ */
955
+ routes: TripPlannerRoute[];
956
+ }
957
+ /**
958
+ * Path detail request item - represents a trip leg segment
959
+ * Used to get detailed stop-by-stop information for a specific trip segment
960
+ * Typically derived from TripPlannerPathLeg (tripId, fromStopId, toStopId)
961
+ * All IDs are strings (converted to numbers internally for API call)
962
+ */
963
+ export interface PathDetailRequestItem {
964
+ /** Trip ID for the bus journey (always string) */
965
+ tripId: string;
966
+ /** Starting stop ID (always string) */
967
+ fromStopId: string;
968
+ /** Ending stop ID (always string) */
969
+ toStopId: string;
970
+ }
971
+ /**
972
+ * Path detail request parameters
973
+ */
974
+ export interface PathDetailsParams {
975
+ /** Array of trip leg segments to get stops for */
976
+ trips: PathDetailRequestItem[];
977
+ }
978
+ /**
979
+ * Single path detail item from GetPathDetails API
980
+ * Represents a single station in a trip's path
981
+ */
982
+ export interface PathDetailItem {
983
+ /** Trip ID for the bus journey */
984
+ tripId: string;
985
+ /** Subroute ID (specific directional variant) */
986
+ subrouteId: string;
987
+ /** Route number (e.g., "285-M", "25-A") */
988
+ routeNo: string;
989
+ /** Stop ID */
990
+ stopId: string;
991
+ /** Stop name */
992
+ stopName: string;
993
+ /** Station latitude */
994
+ latitude: number;
995
+ /** Station longitude */
996
+ longitude: number;
997
+ /** Estimated time of arrival (may be empty string) */
998
+ eta: string | null;
999
+ /** Scheduled arrival time (format: "MM/DD/YYYY HH:mm:ss") */
1000
+ scheduledArrivalTime: string | null;
1001
+ /** Scheduled departure time (format: "MM/DD/YYYY HH:mm:ss") */
1002
+ scheduledDepartureTime: string | null;
1003
+ /** Actual arrival time (may be empty string) */
1004
+ actualArrivalTime: string | null;
1005
+ /** Actual departure time (may be empty string) */
1006
+ actualDepartureTime: string | null;
1007
+ /** Distance from previous station (in km) */
1008
+ distance: number;
1009
+ /** Duration (may be null) */
1010
+ duration: string | null;
1011
+ /** Whether this is a transfer point */
1012
+ isTransfer: boolean;
1013
+ }
1014
+ /**
1015
+ * Raw path details response from GetPathDetails API
1016
+ */
1017
+ export type RawPathDetailsResponse = z.infer<typeof rawPathDetailsResponseSchema>;
1018
+ /**
1019
+ * Path details response from GetPathDetails API
1020
+ * Returns GeoJSON FeatureCollection of Point features (bus stops)
1021
+ */
1022
+ export type PathDetailsResponse = FeatureCollection;
1023
+ /**
1024
+ * Waypoints request parameters for getWaypoints_v1 API
1025
+ * The first point is the origin, the last point is the destination.
1026
+ */
1027
+ export interface WaypointsParams {
1028
+ /** Bus stops along the route path.
1029
+ * Can be either:
1030
+ * - Array of Coordinate [latitude, longitude] tuples
1031
+ * - GeoJSON FeatureCollection with Point features (coordinates will be extracted, properties ignored)
1032
+ * Must have at least 2 points (origin and destination).
1033
+ */
1034
+ viaPoints: Array<Coordinate> | FeatureCollection;
1035
+ }
1036
+ /**
1037
+ * Raw waypoints response from getWaypoints_v1 API
1038
+ */
1039
+ export type RawWaypointsResponse = string[];
1040
+ /**
1041
+ * Trip path response from getWaypoints_v1 API
1042
+ * Returns GeoJSON FeatureCollection with LineString features (route path segments)
1043
+ */
1044
+ export type TripPathResponse = FeatureCollection;
1045
+ /**
1046
+ * Raw timetable by station item from GetTimetableByStation_v4 API
1047
+ */
1048
+ export interface RawTimetableByStationItem {
1049
+ routeid: number;
1050
+ id: number;
1051
+ fromstationid: number;
1052
+ tostationid: number;
1053
+ f: number;
1054
+ t: number;
1055
+ routeno: string;
1056
+ routename: string;
1057
+ fromstationname: string;
1058
+ tostationname: string;
1059
+ traveltime: string;
1060
+ distance: number;
1061
+ apptime: string;
1062
+ apptimesecs: string;
1063
+ starttime: string;
1064
+ platformname: string | null;
1065
+ platformnumber: string | null;
1066
+ baynumber: string | null;
1067
+ }
1068
+ /**
1069
+ * Raw timetable by station API response from BMTC API (for validation)
1070
+ */
1071
+ export type RawTimetableByStationResponse = z.infer<typeof rawTimetableByStationResponseSchema>;
1072
+ /**
1073
+ * Route that passes through both stations (in sequence) with schedule information
1074
+ * Note: This is NOT a full timetable - it contains one startTime per route, not multiple scheduled trips.
1075
+ * The route may start before fromStation and/or continue after toStation.
1076
+ */
1077
+ export interface TimetableByStationItem {
1078
+ /** Route ID */
1079
+ routeId: string;
1080
+ /** Internal ID */
1081
+ id: number;
1082
+ /** From stop ID */
1083
+ fromStopId: string;
1084
+ /** To stop ID */
1085
+ toStopId: string;
1086
+ /** Distance from route start (first stop) to fromStop (km) - cumulative distance along route */
1087
+ fromStopOffset: number;
1088
+ /** Total distance from route start (first stop) to toStop (km) - cumulative distance along route */
1089
+ toStopOffset: number;
1090
+ /** Route number */
1091
+ routeNo: string;
1092
+ /** Route name */
1093
+ routeName: string;
1094
+ /** From stop name */
1095
+ fromStopName: string;
1096
+ /** To stop name */
1097
+ toStopName: string;
1098
+ /** Travel time in format "HH:mm:ss" - actual/scheduled travel time between stops */
1099
+ travelTime: string;
1100
+ /** Distance from fromStop to toStop (km) - distance along the route path between stops (calculated as toStopOffset - fromStopOffset) */
1101
+ distance: number;
1102
+ /** Approximate time in format "HH:mm:ss" - approximate travel time (always <= travelTime) */
1103
+ approximateTime: string;
1104
+ /** Approximate time in seconds - approximate travel time in seconds (always <= travelTime) */
1105
+ approximateTimeSeconds: number;
1106
+ /** Start time in format "HH:mm:ss" */
1107
+ startTime: string;
1108
+ /** Platform name (may be null) */
1109
+ platformName: string | null;
1110
+ /** Platform number (may be null) */
1111
+ platformNumber: string | null;
1112
+ /** Bay number (may be null) */
1113
+ bayNumber: string | null;
1114
+ }
1115
+ /**
1116
+ * Routes that pass through both stops (in sequence) with schedule information
1117
+ * Note: This is NOT a full timetable - each route has one startTime, not multiple scheduled trips.
1118
+ * Routes may start before fromStop and/or continue after toStop.
1119
+ */
1120
+ export interface TimetableByStationResponse {
1121
+ items: TimetableByStationItem[];
1122
+ }
1123
+ /**
1124
+ * Parameters for getting route options between stops
1125
+ */
1126
+ export interface TimetableByStationParams {
1127
+ /** From stop ID (always string for consistency) */
1128
+ fromStopId: string;
1129
+ /** To stop ID (always string for consistency) */
1130
+ toStopId: string;
1131
+ /** Optional: Filter by specific route ID */
1132
+ routeId?: string;
1133
+ /** Optional: Date for timetable (defaults to current date) */
1134
+ date?: Date;
1135
+ }
1136
+ export {};
1137
+ //# sourceMappingURL=routes.d.ts.map