@tiducto/spider-sdk-typescript 0.1.1 → 1.0.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 (109) hide show
  1. package/README.md +1 -1
  2. package/dist/client.d.ts +14 -0
  3. package/dist/client.d.ts.map +1 -1
  4. package/dist/client.js +19 -0
  5. package/dist/client.js.map +1 -1
  6. package/dist/contract/routing/Leg.d.ts +1 -0
  7. package/dist/contract/routing/Leg.d.ts.map +1 -1
  8. package/dist/contract/routing/PlanConnectionStreamData.d.ts +5 -0
  9. package/dist/contract/routing/PlanConnectionStreamData.d.ts.map +1 -0
  10. package/dist/contract/routing/PlanConnectionStreamData.js +2 -0
  11. package/dist/contract/routing/PlanConnectionStreamData.js.map +1 -0
  12. package/dist/contract/routing/PlanConnectionStreamResponse.d.ts +7 -0
  13. package/dist/contract/routing/PlanConnectionStreamResponse.d.ts.map +1 -0
  14. package/dist/contract/routing/PlanConnectionStreamResponse.js +2 -0
  15. package/dist/contract/routing/PlanConnectionStreamResponse.js.map +1 -0
  16. package/dist/contract/routing/PlanConnectionStreamVariables.d.ts +18 -0
  17. package/dist/contract/routing/PlanConnectionStreamVariables.d.ts.map +1 -0
  18. package/dist/contract/routing/PlanConnectionStreamVariables.js +2 -0
  19. package/dist/contract/routing/PlanConnectionStreamVariables.js.map +1 -0
  20. package/dist/contract/routing/Route.d.ts +3 -0
  21. package/dist/contract/routing/Route.d.ts.map +1 -1
  22. package/dist/contract/routing/Stop.d.ts +2 -0
  23. package/dist/contract/routing/Stop.d.ts.map +1 -1
  24. package/dist/contract/routing/StopDeparturesData.d.ts +3 -3
  25. package/dist/contract/routing/StopDeparturesData.d.ts.map +1 -1
  26. package/dist/contract/routing/StopDeparturesRoute.d.ts +3 -0
  27. package/dist/contract/routing/StopDeparturesRoute.d.ts.map +1 -1
  28. package/dist/contract/routing/StopDeparturesStop.d.ts +1 -5
  29. package/dist/contract/routing/StopDeparturesStop.d.ts.map +1 -1
  30. package/dist/contract/routing/StopDeparturesStop2.d.ts +9 -0
  31. package/dist/contract/routing/StopDeparturesStop2.d.ts.map +1 -0
  32. package/dist/contract/routing/StopDeparturesStop2.js +2 -0
  33. package/dist/contract/routing/StopDeparturesStop2.js.map +1 -0
  34. package/dist/contract/routing/StopDeparturesStoptime.d.ts +14 -0
  35. package/dist/contract/routing/StopDeparturesStoptime.d.ts.map +1 -0
  36. package/dist/contract/routing/StopDeparturesStoptime.js +2 -0
  37. package/dist/contract/routing/StopDeparturesStoptime.js.map +1 -0
  38. package/dist/contract/routing/StopDeparturesTrip.d.ts +2 -0
  39. package/dist/contract/routing/StopDeparturesTrip.d.ts.map +1 -1
  40. package/dist/contract/routing/StopDeparturesVariables.d.ts +2 -2
  41. package/dist/contract/routing/StopDeparturesVariables.d.ts.map +1 -1
  42. package/dist/contract/routing/Stoptime.d.ts +4 -3
  43. package/dist/contract/routing/Stoptime.d.ts.map +1 -1
  44. package/dist/contract/routing/TripRoute.d.ts +3 -0
  45. package/dist/contract/routing/TripRoute.d.ts.map +1 -1
  46. package/dist/contract/routing/TripStop.d.ts +2 -0
  47. package/dist/contract/routing/TripStop.d.ts.map +1 -1
  48. package/dist/contract/routing/TripTrip.d.ts +4 -2
  49. package/dist/contract/routing/TripTrip.d.ts.map +1 -1
  50. package/dist/contract/routing/index.d.ts +5 -1
  51. package/dist/contract/routing/index.d.ts.map +1 -1
  52. package/dist/contract.d.ts +0 -1
  53. package/dist/contract.d.ts.map +1 -1
  54. package/dist/contract.js +0 -12
  55. package/dist/contract.js.map +1 -1
  56. package/dist/contractVersion.d.ts +1 -1
  57. package/dist/contractVersion.js +1 -1
  58. package/dist/enums.d.ts +11 -4
  59. package/dist/enums.d.ts.map +1 -1
  60. package/dist/enums.js +43 -24
  61. package/dist/enums.js.map +1 -1
  62. package/dist/errors.d.ts +30 -10
  63. package/dist/errors.d.ts.map +1 -1
  64. package/dist/errors.js +55 -18
  65. package/dist/errors.js.map +1 -1
  66. package/dist/http.d.ts +39 -1
  67. package/dist/http.d.ts.map +1 -1
  68. package/dist/http.js +78 -32
  69. package/dist/http.js.map +1 -1
  70. package/dist/index.d.ts +4 -5
  71. package/dist/index.d.ts.map +1 -1
  72. package/dist/index.js +1 -2
  73. package/dist/index.js.map +1 -1
  74. package/dist/location.d.ts +4 -0
  75. package/dist/location.d.ts.map +1 -1
  76. package/dist/location.js +4 -0
  77. package/dist/location.js.map +1 -1
  78. package/dist/persistedQueries.d.ts +1 -0
  79. package/dist/persistedQueries.d.ts.map +1 -1
  80. package/dist/persistedQueries.js +4 -3
  81. package/dist/persistedQueries.js.map +1 -1
  82. package/dist/polling.d.ts +2 -1
  83. package/dist/polling.d.ts.map +1 -1
  84. package/dist/polling.js +5 -2
  85. package/dist/polling.js.map +1 -1
  86. package/dist/realtime.d.ts +23 -2
  87. package/dist/realtime.d.ts.map +1 -1
  88. package/dist/realtime.js +42 -21
  89. package/dist/realtime.js.map +1 -1
  90. package/dist/routing.d.ts +133 -32
  91. package/dist/routing.d.ts.map +1 -1
  92. package/dist/routing.js +309 -86
  93. package/dist/routing.js.map +1 -1
  94. package/dist/sdk.d.ts +1 -1
  95. package/dist/sdkVersion.d.ts +1 -1
  96. package/dist/sdkVersion.js +1 -1
  97. package/dist/serviceDate.d.ts +6 -0
  98. package/dist/serviceDate.d.ts.map +1 -0
  99. package/dist/serviceDate.js +17 -0
  100. package/dist/serviceDate.js.map +1 -0
  101. package/dist/stops.d.ts +12 -1
  102. package/dist/stops.d.ts.map +1 -1
  103. package/dist/stops.js +15 -6
  104. package/dist/stops.js.map +1 -1
  105. package/package.json +1 -1
  106. package/dist/contract/routing/TripStoptime.d.ts +0 -13
  107. package/dist/contract/routing/TripStoptime.d.ts.map +0 -1
  108. package/dist/contract/routing/TripStoptime.js +0 -2
  109. package/dist/contract/routing/TripStoptime.js.map +0 -1
package/dist/index.js CHANGED
@@ -1,8 +1,7 @@
1
1
  export { SpiderClient } from "./client.js";
2
- export { SpiderContractMismatchError } from "./errors.js";
3
2
  export { Location, ViaLocation } from "./location.js";
4
3
  export { SpiderRouting } from "./routing.js";
5
4
  export { SpiderStops } from "./stops.js";
6
- export { SpiderRealtime } from "./realtime.js";
5
+ export { SpiderRealtime, delayFor } from "./realtime.js";
7
6
  export { pollVehicles, pollVehicleForTrip, pollDelays, pollAlerts } from "./polling.js";
8
7
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAI3C,OAAO,EAAE,2BAA2B,EAAE,MAAM,aAAa,CAAC;AAC1D,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAEtD,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAiB7C,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAEzC,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAc/C,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAI3C,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAUtD,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAiB7C,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAEzC,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAezD,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC"}
@@ -18,6 +18,10 @@ export type ViaLocation = {
18
18
  readonly location: Location;
19
19
  readonly minimumWaitSeconds: number;
20
20
  };
21
+ /**
22
+ * A point the itinerary must pass. How many a request may carry is an environment setting; each pass-through takes
23
+ * 1 to 10 stop ids and a visit waits 0 to 86400 seconds, else the request fails as `bad_request` on `via`.
24
+ */
21
25
  export declare const ViaLocation: {
22
26
  readonly passThrough: (...stopIds: string[]) => ViaLocation;
23
27
  readonly visit: (location: Location, minimumWaitSeconds?: number) => ViaLocation;
@@ -1 +1 @@
1
- {"version":3,"file":"location.d.ts","sourceRoot":"","sources":["../src/location.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,QAAQ,GAChB;IAAE,QAAQ,CAAC,IAAI,EAAE,YAAY,CAAC;IAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;CAAE,GACtF;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;CAAE,CAAC;AAEnD,eAAO,MAAM,QAAQ;oCACE,MAAM,aAAa,MAAM,KAAG,QAAQ;wBAGhD,MAAM,KAAG,QAAQ;CAGlB,CAAC;AAEX,MAAM,MAAM,WAAW,GACnB;IAAE,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAA;CAAE,GACrE;IAAE,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAAC,QAAQ,CAAC,kBAAkB,EAAE,MAAM,CAAA;CAAE,CAAC;AAEjG,eAAO,MAAM,WAAW;uCACE,MAAM,EAAE,KAAG,WAAW;+BAG9B,QAAQ,kCAA2B,WAAW;CAGtD,CAAC"}
1
+ {"version":3,"file":"location.d.ts","sourceRoot":"","sources":["../src/location.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,QAAQ,GAChB;IAAE,QAAQ,CAAC,IAAI,EAAE,YAAY,CAAC;IAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;CAAE,GACtF;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;CAAE,CAAC;AAEnD,eAAO,MAAM,QAAQ;oCACE,MAAM,aAAa,MAAM,KAAG,QAAQ;wBAGhD,MAAM,KAAG,QAAQ;CAGlB,CAAC;AAEX,MAAM,MAAM,WAAW,GACnB;IAAE,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAA;CAAE,GACrE;IAAE,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAAC,QAAQ,CAAC,kBAAkB,EAAE,MAAM,CAAA;CAAE,CAAC;AAEjG;;;GAGG;AACH,eAAO,MAAM,WAAW;uCACE,MAAM,EAAE,KAAG,WAAW;+BAG9B,QAAQ,kCAA2B,WAAW;CAGtD,CAAC"}
package/dist/location.js CHANGED
@@ -6,6 +6,10 @@ export const Location = {
6
6
  return { kind: 'stop', id };
7
7
  },
8
8
  };
9
+ /**
10
+ * A point the itinerary must pass. How many a request may carry is an environment setting; each pass-through takes
11
+ * 1 to 10 stop ids and a visit waits 0 to 86400 seconds, else the request fails as `bad_request` on `via`.
12
+ */
9
13
  export const ViaLocation = {
10
14
  passThrough(...stopIds) {
11
15
  return { kind: 'passThrough', stopIds };
@@ -1 +1 @@
1
- {"version":3,"file":"location.js","sourceRoot":"","sources":["../src/location.ts"],"names":[],"mappings":"AAIA,MAAM,CAAC,MAAM,QAAQ,GAAG;IACtB,UAAU,CAAC,QAAgB,EAAE,SAAiB;QAC5C,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC;IACrD,CAAC;IACD,IAAI,CAAC,EAAU;QACb,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC;IAC9B,CAAC;CACO,CAAC;AAMX,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,WAAW,CAAC,GAAG,OAAiB;QAC9B,OAAO,EAAE,IAAI,EAAE,aAAa,EAAE,OAAO,EAAE,CAAC;IAC1C,CAAC;IACD,KAAK,CAAC,QAAkB,EAAE,kBAAkB,GAAG,CAAC;QAC9C,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,kBAAkB,EAAE,CAAC;IACzD,CAAC;CACO,CAAC"}
1
+ {"version":3,"file":"location.js","sourceRoot":"","sources":["../src/location.ts"],"names":[],"mappings":"AAIA,MAAM,CAAC,MAAM,QAAQ,GAAG;IACtB,UAAU,CAAC,QAAgB,EAAE,SAAiB;QAC5C,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC;IACrD,CAAC;IACD,IAAI,CAAC,EAAU;QACb,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC;IAC9B,CAAC;CACO,CAAC;AAMX;;;GAGG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,WAAW,CAAC,GAAG,OAAiB;QAC9B,OAAO,EAAE,IAAI,EAAE,aAAa,EAAE,OAAO,EAAE,CAAC;IAC1C,CAAC;IACD,KAAK,CAAC,QAAkB,EAAE,kBAAkB,GAAG,CAAC;QAC9C,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,kBAAkB,EAAE,CAAC;IACzD,CAAC;CACO,CAAC"}
@@ -4,5 +4,6 @@ export interface PersistedOp {
4
4
  }
5
5
  export declare const DEPARTURES: PersistedOp;
6
6
  export declare const PLAN: PersistedOp;
7
+ export declare const PLAN_STREAM: PersistedOp;
7
8
  export declare const TRIP: PersistedOp;
8
9
  //# sourceMappingURL=persistedQueries.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"persistedQueries.d.ts","sourceRoot":"","sources":["../src/persistedQueries.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAED,eAAO,MAAM,UAAU,EAAE,WAA4G,CAAC;AACtI,eAAO,MAAM,IAAI,EAAE,WAAsG,CAAC;AAC1H,eAAO,MAAM,IAAI,EAAE,WAAsG,CAAC"}
1
+ {"version":3,"file":"persistedQueries.d.ts","sourceRoot":"","sources":["../src/persistedQueries.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAED,eAAO,MAAM,UAAU,EAAE,WAA4G,CAAC;AACtI,eAAO,MAAM,IAAI,EAAE,WAAsG,CAAC;AAC1H,eAAO,MAAM,WAAW,EAAE,WAA6G,CAAC;AACxI,eAAO,MAAM,IAAI,EAAE,WAAsG,CAAC"}
@@ -1,4 +1,5 @@
1
- export const DEPARTURES = { id: '70a644fe3c6b2cbf5b2d70cef8230c1428bea6357ae1766772162d86469563d0', path: 'departures' };
2
- export const PLAN = { id: 'dad4f190af803a8cb50ec99c5852544297e94db8edc0d94220c8f79d98f065a7', path: 'plan' };
3
- export const TRIP = { id: 'e8959a8d47a8e8437ee3ec740cd9c3e28bd401efdd236dde0502559daea53920', path: 'trip' };
1
+ export const DEPARTURES = { id: 'e4ae3f49e06982173b38e945c3c02ef113be05e12564145faeade7758295f536', path: 'departures' };
2
+ export const PLAN = { id: '679549e87f9653ff7a5a021c0b329a2c9658d4701c836139e63712dd9b77981f', path: 'plan' };
3
+ export const PLAN_STREAM = { id: '40380fc4cf10397a4c20d039cc9428b73757c7fce0de2072ae1685a43efbfc15', path: 'plan-stream' };
4
+ export const TRIP = { id: '4a10717f45697a241a0843902808cd696eb8ffd102e93238bf753f865d939a3f', path: 'trip' };
4
5
  //# sourceMappingURL=persistedQueries.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"persistedQueries.js","sourceRoot":"","sources":["../src/persistedQueries.ts"],"names":[],"mappings":"AAKA,MAAM,CAAC,MAAM,UAAU,GAAgB,EAAE,EAAE,EAAE,kEAAkE,EAAE,IAAI,EAAE,YAAY,EAAE,CAAC;AACtI,MAAM,CAAC,MAAM,IAAI,GAAgB,EAAE,EAAE,EAAE,kEAAkE,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;AAC1H,MAAM,CAAC,MAAM,IAAI,GAAgB,EAAE,EAAE,EAAE,kEAAkE,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC"}
1
+ {"version":3,"file":"persistedQueries.js","sourceRoot":"","sources":["../src/persistedQueries.ts"],"names":[],"mappings":"AAKA,MAAM,CAAC,MAAM,UAAU,GAAgB,EAAE,EAAE,EAAE,kEAAkE,EAAE,IAAI,EAAE,YAAY,EAAE,CAAC;AACtI,MAAM,CAAC,MAAM,IAAI,GAAgB,EAAE,EAAE,EAAE,kEAAkE,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;AAC1H,MAAM,CAAC,MAAM,WAAW,GAAgB,EAAE,EAAE,EAAE,kEAAkE,EAAE,IAAI,EAAE,aAAa,EAAE,CAAC;AACxI,MAAM,CAAC,MAAM,IAAI,GAAgB,EAAE,EAAE,EAAE,kEAAkE,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC"}
package/dist/polling.d.ts CHANGED
@@ -6,6 +6,7 @@ export interface PollOptions {
6
6
  }
7
7
  export declare function pollVehicles(realtime: SpiderRealtime, tripIds: readonly string[], options?: PollOptions): AsyncGenerator<SpiderResult<VehiclePositions>>;
8
8
  export declare function pollVehicleForTrip(realtime: SpiderRealtime, tripId: string, options?: PollOptions): AsyncGenerator<SpiderResult<LiveVehicleUpdate>>;
9
- export declare function pollDelays(realtime: SpiderRealtime, tripIds: readonly string[], options?: PollOptions): AsyncGenerator<SpiderResult<TripDelays>>;
9
+ export declare function pollDelays(realtime: SpiderRealtime, byServiceDate: Readonly<Record<string, readonly string[]>>, options?: PollOptions): AsyncGenerator<SpiderResult<TripDelays>>;
10
+ export declare function pollDelays(realtime: SpiderRealtime, tripIds: readonly string[], serviceDate: string, options?: PollOptions): AsyncGenerator<SpiderResult<TripDelays>>;
10
11
  export declare function pollAlerts(realtime: SpiderRealtime, options?: PollOptions): AsyncGenerator<SpiderResult<ServiceAlerts>>;
11
12
  //# sourceMappingURL=polling.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"polling.d.ts","sourceRoot":"","sources":["../src/polling.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AACpH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhD,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC;CAC/B;AAED,wBAAgB,YAAY,CAC1B,QAAQ,EAAE,cAAc,EACxB,OAAO,EAAE,SAAS,MAAM,EAAE,EAC1B,OAAO,CAAC,EAAE,WAAW,GACpB,cAAc,CAAC,YAAY,CAAC,gBAAgB,CAAC,CAAC,CAEhD;AAED,wBAAgB,kBAAkB,CAChC,QAAQ,EAAE,cAAc,EACxB,MAAM,EAAE,MAAM,EACd,OAAO,CAAC,EAAE,WAAW,GACpB,cAAc,CAAC,YAAY,CAAC,iBAAiB,CAAC,CAAC,CAEjD;AAED,wBAAgB,UAAU,CACxB,QAAQ,EAAE,cAAc,EACxB,OAAO,EAAE,SAAS,MAAM,EAAE,EAC1B,OAAO,CAAC,EAAE,WAAW,GACpB,cAAc,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC,CAE1C;AAED,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,wBAAgB,UAAU,CACxB,QAAQ,EAAE,cAAc,EACxB,OAAO,CAAC,EAAE,WAAW,GACpB,cAAc,CAAC,YAAY,CAAC,aAAa,CAAC,CAAC,CAE7C"}
package/dist/polling.js CHANGED
@@ -4,8 +4,11 @@ export function pollVehicles(realtime, tripIds, options) {
4
4
  export function pollVehicleForTrip(realtime, tripId, options) {
5
5
  return poll(options, () => realtime.vehicleForTrip(tripId));
6
6
  }
7
- export function pollDelays(realtime, tripIds, options) {
8
- return poll(options, () => realtime.delays(tripIds));
7
+ export function pollDelays(realtime, arg, serviceDateOrOptions, options) {
8
+ if (typeof serviceDateOrOptions === 'string') {
9
+ return poll(options, () => realtime.delays(arg, serviceDateOrOptions));
10
+ }
11
+ return poll(serviceDateOrOptions, () => realtime.delays(arg));
9
12
  }
10
13
  export function pollAlerts(realtime, options) {
11
14
  return poll(options, () => realtime.alerts());
@@ -1 +1 @@
1
- {"version":3,"file":"polling.js","sourceRoot":"","sources":["../src/polling.ts"],"names":[],"mappings":"AAQA,MAAM,UAAU,YAAY,CAC1B,QAAwB,EACxB,OAA0B,EAC1B,OAAqB;IAErB,OAAO,IAAI,CAAC,OAAO,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC;AACzD,CAAC;AAED,MAAM,UAAU,kBAAkB,CAChC,QAAwB,EACxB,MAAc,EACd,OAAqB;IAErB,OAAO,IAAI,CAAC,OAAO,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,CAAC;AAC9D,CAAC;AAED,MAAM,UAAU,UAAU,CACxB,QAAwB,EACxB,OAA0B,EAC1B,OAAqB;IAErB,OAAO,IAAI,CAAC,OAAO,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC;AACvD,CAAC;AAED,MAAM,UAAU,UAAU,CACxB,QAAwB,EACxB,OAAqB;IAErB,OAAO,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@@ -5,6 +5,7 @@ export interface FeedFreshness {
5
5
  readonly feedTimestampEpochMs: number | null;
6
6
  readonly staleSeconds: number | null;
7
7
  }
8
+ /** A vehicle's live position. `tripId`, `routeId`, `stopId` and `vehicleId` are feed-prefixed (`<feedId>:<id>`). */
8
9
  export interface LiveVehicle {
9
10
  readonly tripId: string | null;
10
11
  readonly routeId: string | null;
@@ -42,11 +43,22 @@ export interface TripDelay {
42
43
  readonly scheduleRelationship: string | null;
43
44
  readonly stopTimeUpdates: readonly StopTimeUpdate[];
44
45
  }
45
- export interface TripDelays {
46
+ /** Delays for one GTFS service date: those the feed reported, and the `missing` trip ids it didn't. */
47
+ export interface ServiceDateDelays {
48
+ readonly serviceDate: string;
46
49
  readonly delays: readonly TripDelay[];
47
50
  readonly missing: readonly string[];
51
+ }
52
+ /**
53
+ * Result of {@link SpiderRealtime.delays}: delays grouped by service date (the same `tripId` on two dates is
54
+ * two distinct instances), plus feed freshness. Look up a single instance with {@link delayFor}.
55
+ */
56
+ export interface TripDelays {
57
+ readonly groups: readonly ServiceDateDelays[];
48
58
  readonly freshness: FeedFreshness;
49
59
  }
60
+ /** The delay for the (`tripId`, `serviceDate`) instance, if the feed reported one; otherwise null. */
61
+ export declare function delayFor(delays: TripDelays, tripId: string, serviceDate: string): TripDelay | null;
50
62
  export interface AlertActivePeriod {
51
63
  readonly startEpochMs: number | null;
52
64
  readonly endEpochMs: number | null;
@@ -75,9 +87,18 @@ export interface ServiceAlerts {
75
87
  export declare class SpiderRealtime {
76
88
  private readonly transport;
77
89
  constructor(transport: Transport);
90
+ /** Live positions for up to 50 trips. Empty input skips the call; more than 50 fails as `bad_request` without a request. */
78
91
  vehicles(tripIds: readonly string[]): Promise<SpiderResult<VehiclePositions>>;
79
92
  vehicleForTrip(tripId: string): Promise<SpiderResult<LiveVehicleUpdate>>;
80
- delays(tripIds: readonly string[]): Promise<SpiderResult<TripDelays>>;
93
+ /**
94
+ * Live delays, resolved per `(tripId, serviceDate)` instance: group trip ids by the GTFS service date
95
+ * (ISO `YYYY-MM-DD`) they run on — pass each plan leg's or departure's `serviceDate` through. Up to 50 trip ids
96
+ * in total across all dates. Empty input skips the call; a malformed date or more than 50 ids fails as
97
+ * `bad_request` without a request.
98
+ */
99
+ delays(byServiceDate: Readonly<Record<string, readonly string[]>>): Promise<SpiderResult<TripDelays>>;
100
+ /** Live delays for `tripIds` all on one `serviceDate` (ISO `YYYY-MM-DD`) — the common single-day case. */
101
+ delays(tripIds: readonly string[], serviceDate: string): Promise<SpiderResult<TripDelays>>;
81
102
  alerts(): Promise<SpiderResult<ServiceAlerts>>;
82
103
  }
83
104
  //# sourceMappingURL=realtime.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"realtime.d.ts","sourceRoot":"","sources":["../src/realtime.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAE3C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAGhD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAGlD,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,oBAAoB,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7C,QAAQ,CAAC,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;CACtC;AAED,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACjC,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IA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,QAAQ,CAAC,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;IACxC,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,QAAQ,CAAC,aAAa,EAAE,SAAS,iBAAiB,EAAE,CAAC;IACrD,QAAQ,CAAC,gBAAgB,EAAE,SAAS,mBAAmB,EAAE,CAAC;CAC3D;AAED,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,MAAM,EAAE,SAAS,YAAY,EAAE,CAAC;IACzC,QAAQ,CAAC,SAAS,EAAE,aAAa,CAAC;CACnC;AAOD,qBAAa,cAAc;IACzB,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAY;gBAE1B,SAAS,EAAE,SAAS;IAIhC,4HAA4H;IACtH,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,GAAG,OAAO,CAAC,YAAY,CAAC,gBAAgB,CAAC,CAAC;IAiB7E,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC,iBAAiB,CAAC,CAAC;IAsB9E;;;;;OAKG;IACG,MAAM,CAAC,aAAa,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC,CAAC,GAAG,OAAO,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC;IAC3G,0GAA0G;IACpG,MAAM,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC;IA4B1F,MAAM,IAAI,OAAO,CAAC,YAAY,CAAC,aAAa,CAAC,CAAC;CAWrD"}
package/dist/realtime.js CHANGED
@@ -1,18 +1,28 @@
1
1
  import { parseJson } from "./http.js";
2
2
  import { failure, success } from "./result.js";
3
- import { SpiderContractMismatchError, TransportError, toSpiderError } from "./errors.js";
3
+ import { badRequest, httpFailure, limitRefusal, toSpiderError } from "./errors.js";
4
+ import { invalidServiceDate } from "./serviceDate.js";
4
5
  import { occupancyFromWire } from "./enums.js";
6
+ /** The delay for the (`tripId`, `serviceDate`) instance, if the feed reported one; otherwise null. */
7
+ export function delayFor(delays, tripId, serviceDate) {
8
+ const group = delays.groups.find((g) => g.serviceDate === serviceDate);
9
+ return group?.delays.find((d) => d.tripId === tripId) ?? null;
10
+ }
5
11
  const EMPTY_FRESHNESS = { feedTimestampEpochMs: null, staleSeconds: null };
6
12
  const EMPTY_POSITIONS = { vehicles: [], missing: [], freshness: EMPTY_FRESHNESS };
7
- const EMPTY_DELAYS = { delays: [], missing: [], freshness: EMPTY_FRESHNESS };
13
+ const EMPTY_DELAYS = { groups: [], freshness: EMPTY_FRESHNESS };
14
+ const MAX_TRIP_IDS = 50;
8
15
  export class SpiderRealtime {
9
16
  transport;
10
17
  constructor(transport) {
11
18
  this.transport = transport;
12
19
  }
20
+ /** Live positions for up to 50 trips. Empty input skips the call; more than 50 fails as `bad_request` without a request. */
13
21
  async vehicles(tripIds) {
14
22
  if (tripIds.length === 0)
15
23
  return success(EMPTY_POSITIONS);
24
+ if (tripIds.length > MAX_TRIP_IDS)
25
+ return failure(badRequest('tripIds'));
16
26
  try {
17
27
  const dto = await this.transport.getJson('/realtime/vehicles', {
18
28
  tripIds: tripIds.join(','),
@@ -24,8 +34,6 @@ export class SpiderRealtime {
24
34
  });
25
35
  }
26
36
  catch (e) {
27
- if (e instanceof SpiderContractMismatchError)
28
- throw e;
29
37
  return failure(toSpiderError(e));
30
38
  }
31
39
  }
@@ -33,11 +41,13 @@ export class SpiderRealtime {
33
41
  const path = `/realtime/vehicles/by-trip/${encodeURIComponent(tripId)}`;
34
42
  try {
35
43
  const raw = await this.transport.getRaw(path);
36
- if (raw.status === 404) {
37
- return success({ vehicle: null, freshness: EMPTY_FRESHNESS });
38
- }
39
44
  if (!raw.ok) {
40
- throw new TransportError('http', `GET ${path} -> ${raw.status}: ${raw.text.slice(0, 300)}`, raw.status);
45
+ const error = httpFailure(`GET ${path}`, raw.status, raw.text);
46
+ // A 404 is "no vehicle" unless its body names a plan limit.
47
+ if (raw.status === 404 && limitRefusal(error) == null) {
48
+ return success({ vehicle: null, freshness: EMPTY_FRESHNESS });
49
+ }
50
+ throw error;
41
51
  }
42
52
  const dto = parseJson(raw.text, path);
43
53
  return success({
@@ -46,27 +56,33 @@ export class SpiderRealtime {
46
56
  });
47
57
  }
48
58
  catch (e) {
49
- if (e instanceof SpiderContractMismatchError)
50
- throw e;
51
59
  return failure(toSpiderError(e));
52
60
  }
53
61
  }
54
- async delays(tripIds) {
55
- if (tripIds.length === 0)
62
+ async delays(arg, serviceDate) {
63
+ const byServiceDate = serviceDate !== undefined
64
+ ? { [serviceDate]: arg }
65
+ : arg;
66
+ const queries = Object.entries(byServiceDate).map(([date, tripIds]) => ({ serviceDate: date, tripIds: [...tripIds] }));
67
+ for (const q of queries) {
68
+ const invalid = invalidServiceDate(q.serviceDate);
69
+ if (invalid != null)
70
+ return failure(invalid);
71
+ }
72
+ const total = queries.reduce((n, q) => n + q.tripIds.length, 0);
73
+ if (total === 0)
56
74
  return success(EMPTY_DELAYS);
75
+ if (total > MAX_TRIP_IDS)
76
+ return failure(badRequest('tripIds'));
57
77
  try {
58
- const dto = await this.transport.getJson('/realtime/delays', {
59
- tripIds: tripIds.join(','),
60
- });
78
+ const request = { queries };
79
+ const dto = await this.transport.postJson('/realtime/delays', request);
61
80
  return success({
62
- delays: (dto.delays ?? []).map(mapDelay),
63
- missing: dto.missing ?? [],
81
+ groups: (dto.results ?? []).map(mapGroupResult),
64
82
  freshness: mapFreshness(dto),
65
83
  });
66
84
  }
67
85
  catch (e) {
68
- if (e instanceof SpiderContractMismatchError)
69
- throw e;
70
86
  return failure(toSpiderError(e));
71
87
  }
72
88
  }
@@ -79,8 +95,6 @@ export class SpiderRealtime {
79
95
  });
80
96
  }
81
97
  catch (e) {
82
- if (e instanceof SpiderContractMismatchError)
83
- throw e;
84
98
  return failure(toSpiderError(e));
85
99
  }
86
100
  }
@@ -107,6 +121,13 @@ function mapVehicle(v) {
107
121
  timestampEpochMs: secondsToMs(v.timestamp),
108
122
  };
109
123
  }
124
+ function mapGroupResult(g) {
125
+ return {
126
+ serviceDate: g.serviceDate,
127
+ delays: (g.delays ?? []).map(mapDelay),
128
+ missing: g.missing ?? [],
129
+ };
130
+ }
110
131
  function mapDelay(d) {
111
132
  return {
112
133
  tripId: d.tripId ?? null,
@@ -1 +1 @@
1
- {"version":3,"file":"realtime.js","sourceRoot":"","sources":["../src/realtime.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEtC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,2BAA2B,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAEzF,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAoF/C,MAAM,eAAe,GAAkB,EAAE,oBAAoB,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC;AAC1F,MAAM,eAAe,GAAqB,EAAE,QAAQ,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,SAAS,EAAE,eAAe,EAAE,CAAC;AACpG,MAAM,YAAY,GAAe,EAAE,MAAM,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,SAAS,EAAE,eAAe,EAAE,CAAC;AAEzF,MAAM,OAAO,cAAc;IACR,SAAS,CAAY;IAEtC,YAAY,SAAoB;QAC9B,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC7B,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,OAA0B;QACvC,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,OAAO,CAAC,eAAe,CAAC,CAAC;QAC1D,IAAI,CAAC;YACH,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,OAAO,CAAuB,oBAAoB,EAAE;gBACnF,OAAO,EAAE,OA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C,UAAU,EAAE,CAAC,CAAC,UAAU,IAAI,IAAI;QAChC,eAAe,EAAE,CAAC,CAAC,eAAe,IAAI,IAAI;QAC1C,GAAG,EAAE,CAAC,CAAC,GAAG,IAAI,IAAI;QAClB,aAAa,EAAE,CAAC,CAAC,CAAC,aAAa,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;YACjD,YAAY,EAAE,WAAW,CAAC,CAAC,CAAC,KAAK,CAAC;YAClC,UAAU,EAAE,WAAW,CAAC,CAAC,CAAC,GAAG,CAAC;SAC/B,CAAC,CAAC;QACH,gBAAgB,EAAE,CAAC,CAAC,CAAC,gBAAgB,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;YACvD,QAAQ,EAAE,CAAC,CAAC,QAAQ,IAAI,IAAI;YAC5B,OAAO,EAAE,CAAC,CAAC,OAAO,IAAI,IAAI;YAC1B,MAAM,EAAE,CAAC,CAAC,MAAM,IAAI,IAAI;YACxB,MAAM,EAAE,CAAC,CAAC,MAAM,IAAI,IAAI;SACzB,CAAC,CAAC;KACJ,CAAC;AACJ,CAAC"}
package/dist/routing.d.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  import type { Transport } from './http.ts';
2
2
  import type { SpiderResult } from './result.ts';
3
- import type { BikesAllowed, TransitMode, WheelchairBoarding } from './enums.ts';
3
+ import type { SpiderError } from './errors.ts';
4
+ import type { BikesAllowed, InputField, RealtimeState, RoutingErrorCode, TransitMode, WheelchairBoarding } from './enums.ts';
4
5
  import type { Location, ViaLocation } from './location.ts';
5
- import type { RoutingErrorCode, InputField, RealtimeState } from './contract/routing/index.ts';
6
6
  export interface LatLon {
7
7
  readonly lat: number;
8
8
  readonly lon: number;
@@ -11,10 +11,34 @@ export interface Leg {
11
11
  readonly mode: TransitMode | null;
12
12
  readonly startScheduled: string;
13
13
  readonly endScheduled: string;
14
+ /** Estimated (realtime-adjusted) departure ISO time, when the feed reported one; otherwise null. */
15
+ readonly startEstimated: string | null;
16
+ /** Estimated (realtime-adjusted) arrival ISO time, when the feed reported one; otherwise null. */
17
+ readonly endEstimated: string | null;
18
+ /** Departure schedule deviation in seconds (positive = late), when known; otherwise null. */
19
+ readonly startDelaySeconds: number | null;
20
+ /** Arrival schedule deviation in seconds (positive = late), when known; otherwise null. */
21
+ readonly endDelaySeconds: number | null;
22
+ readonly isRealtime: boolean;
23
+ readonly realtimeState: RealtimeState | null;
24
+ /** GTFS service date this leg's trip runs on (ISO `YYYY-MM-DD`) — pass to realtime `delays` lookups. */
25
+ readonly serviceDate: string | null;
14
26
  readonly fromName: string | null;
15
27
  readonly toName: string | null;
28
+ /** Stop ids of the leg's endpoints; null for a coordinate endpoint. */
29
+ readonly fromGtfsId: string | null;
30
+ readonly toGtfsId: string | null;
31
+ readonly fromPlatformCode: string | null;
32
+ readonly toPlatformCode: string | null;
33
+ readonly fromZoneId: string | null;
34
+ readonly toZoneId: string | null;
35
+ readonly routeGtfsId: string | null;
16
36
  readonly routeShortName: string | null;
17
37
  readonly routeLongName: string | null;
38
+ /** Route colour as the feed gives it: GTFS hex without `#`, e.g. `FF0000`. */
39
+ readonly routeColor: string | null;
40
+ /** Route text colour as the feed gives it: GTFS hex without `#`, e.g. `FFFFFF`. */
41
+ readonly routeTextColor: string | null;
18
42
  readonly headsign: string | null;
19
43
  readonly distanceMeters: number | null;
20
44
  readonly durationSeconds: number | null;
@@ -48,6 +72,10 @@ export interface RoutePageInfo {
48
72
  export interface RoutingError {
49
73
  readonly code: RoutingErrorCode;
50
74
  readonly description: string;
75
+ /**
76
+ * The input the error is about, when there is one. A `LOCATION_NOT_FOUND` names `FROM` (origin), `TO`
77
+ * (destination) or `VIA` (a via stop id the environment doesn't know).
78
+ */
51
79
  readonly inputField: InputField | null;
52
80
  }
53
81
  export interface Route {
@@ -56,6 +84,28 @@ export interface Route {
56
84
  readonly routingErrors: readonly RoutingError[];
57
85
  readonly searchDateTime: string | null;
58
86
  }
87
+ /**
88
+ * One event from {@link SpiderRouting.planStream}. The router sweeps the search window forward and pushes
89
+ * finalized itineraries as `result`s; a terminal `done` carries the continuation {@link RoutePageInfo}. A
90
+ * `failure` is terminal and takes the place of the rest.
91
+ */
92
+ export type PlanStreamEvent = {
93
+ /** A batch of finalized itineraries as the search frontier advances (with realtime delays on their legs). */
94
+ readonly type: 'result';
95
+ readonly itineraries: readonly Itinerary[];
96
+ } | {
97
+ /** Terminal: the continuation cursors, mirroring {@link Route.pageInfo}. Continue with
98
+ * {@link SpiderRouting.planStreamNext} (`endCursor`) or {@link SpiderRouting.planStreamPrevious}
99
+ * (`startCursor`), gated on `hasNextPage` / `hasPreviousPage`. */
100
+ readonly type: 'done';
101
+ readonly pageInfo: RoutePageInfo;
102
+ /** Why the sweep found nothing, mirroring {@link Route.routingErrors}; empty when there is nothing to report. */
103
+ readonly routingErrors: readonly RoutingError[];
104
+ } | {
105
+ /** Terminal failure — a transport/HTTP problem, a decoding error, or a server `error` event (`bad_request` for malformed input). */
106
+ readonly type: 'failure';
107
+ readonly error: SpiderError;
108
+ };
59
109
  export interface Departure {
60
110
  readonly scheduledTimeEpochMs: number;
61
111
  readonly realtimeTimeEpochMs: number | null;
@@ -63,9 +113,20 @@ export interface Departure {
63
113
  readonly realtimeState: RealtimeState | null;
64
114
  readonly headsign: string | null;
65
115
  readonly tripGtfsId: string | null;
116
+ /** GTFS service date the trip runs on (ISO `YYYY-MM-DD`) — pass it to {@link SpiderRouting.trip} and realtime `delays`. */
117
+ readonly serviceDate: string;
118
+ readonly routeGtfsId: string | null;
66
119
  readonly routeShortName: string | null;
67
120
  readonly routeLongName: string | null;
121
+ /** Route colour as the feed gives it: GTFS hex without `#`, e.g. `FF0000`. */
122
+ readonly routeColor: string | null;
123
+ /** Route text colour as the feed gives it: GTFS hex without `#`, e.g. `FFFFFF`. */
124
+ readonly routeTextColor: string | null;
68
125
  readonly mode: TransitMode | null;
126
+ /** The stop this departure leaves from: the board's own stop, or one of a station's platforms. */
127
+ readonly stopGtfsId: string | null;
128
+ readonly platformCode: string | null;
129
+ readonly wheelchairAccessible: WheelchairBoarding | null;
69
130
  }
70
131
  export interface TripStop {
71
132
  readonly gtfsId: string;
@@ -78,15 +139,25 @@ export interface TripStop {
78
139
  readonly realtimeDepartureEpochMs: number | null;
79
140
  readonly isRealtime: boolean;
80
141
  readonly wheelchairBoarding: WheelchairBoarding | null;
142
+ readonly platformCode: string | null;
143
+ readonly zoneId: string | null;
81
144
  }
82
145
  export interface TripDetails {
83
146
  readonly gtfsId: string;
147
+ /** GTFS service date of this trip instance (ISO `YYYY-MM-DD`); null when the trip has no stop times on it. */
148
+ readonly serviceDate: string | null;
149
+ readonly routeGtfsId: string | null;
84
150
  readonly routeShortName: string | null;
85
151
  readonly routeLongName: string | null;
152
+ /** Route colour as the feed gives it: GTFS hex without `#`, e.g. `FF0000`. */
153
+ readonly routeColor: string | null;
154
+ /** Route text colour as the feed gives it: GTFS hex without `#`, e.g. `FFFFFF`. */
155
+ readonly routeTextColor: string | null;
86
156
  readonly mode: TransitMode | null;
87
157
  readonly headsign: string | null;
88
158
  readonly directionId: string | null;
89
159
  readonly bikesAllowed: BikesAllowed | null;
160
+ readonly wheelchairAccessible: WheelchairBoarding | null;
90
161
  readonly stops: readonly TripStop[];
91
162
  readonly geometry: readonly LatLon[];
92
163
  }
@@ -98,59 +169,89 @@ export interface PlanOptions {
98
169
  readonly via?: readonly ViaLocation[];
99
170
  /** Restrict routing to these transit modes. Undefined/empty = no filter (all modes); WALK/UNKNOWN drop out. */
100
171
  readonly allowedTransitModes?: readonly TransitMode[];
101
- /** Absolute cap on transfers in any returned itinerary. Undefined = OTP default. */
172
+ /** Most transfers in any itinerary (0 = direct only), up to the environment's limit. Undefined = that limit. */
102
173
  readonly maxTransfers?: number;
103
174
  /**
104
- * Search window in minutes (default 60). Always sent, deliberately not OTP's dynamic route-dependent
105
- * window — predictable cost + paging. Widen for sparse/intercity routes.
175
+ * Search window in minutes (default 60), up to the environment's limit. Always sent, deliberately not a
176
+ * dynamic route-dependent window — predictable cost + paging. Widen for sparse/intercity routes.
106
177
  */
107
178
  readonly searchWindowMinutes?: number;
108
179
  /** Prefer wheelchair-accessible routing. */
109
180
  readonly wheelchairAccessible?: boolean;
110
181
  }
111
- /** Options for the streaming `planUntil` — the plan filters plus the walk's bounds. `searchWindowMinutes` is the step. */
112
- export interface PlanStreamOptions extends PlanOptions {
113
- /** Stop once ~this many itineraries have been collected (soft — the window that reaches it is yielded whole). */
114
- readonly targetResults?: number;
115
- /** Stop after stepping through this much total time (default 360 = 6h). `searchWindowMinutes` is the step size. */
116
- readonly maxTraversalMinutes?: number;
117
- }
118
- /** Bounds for the streaming continuations `planNextUntil` / `planPreviousUntil` (the step is fixed from `prev`). */
119
- export interface PlanStreamPageOptions {
120
- readonly targetResults?: number;
121
- readonly maxTraversalMinutes?: number;
182
+ /**
183
+ * Options for {@link SpiderRouting.planStream} and its continuations — the server-push SSE stream that opens one
184
+ * long-lived Server-Sent Events request and pushes itineraries (with realtime delays) as the router sweeps the
185
+ * window forward. The continuation methods take these same options plus a raw cursor string.
186
+ */
187
+ export interface PlanStreamRequestOptions {
188
+ readonly origin: Location;
189
+ readonly destination: Location;
190
+ readonly departAt?: number | Date;
191
+ readonly arriveBy?: number | Date;
192
+ readonly via?: readonly ViaLocation[];
193
+ readonly allowedTransitModes?: readonly TransitMode[];
194
+ readonly maxTransfers?: number;
195
+ readonly wheelchairAccessible?: boolean;
196
+ /**
197
+ * Soft floor: the sweep keeps going until at least this many itineraries are found. From 1 up to the
198
+ * environment's result count.
199
+ */
200
+ readonly targetResults: number;
201
+ /**
202
+ * How far the sweep may search, in minutes: at least 120 (2 h), up to the environment's search-window limit.
203
+ * A smaller value fails as `bad_request` on `maxWindow` before any request.
204
+ */
205
+ readonly maxWindowMinutes: number;
122
206
  }
123
207
  export interface DeparturesOptions {
208
+ /** Departures from this time on (default now). */
124
209
  readonly startTime?: number | Date;
210
+ /** How far ahead to look, in seconds: above 0, up to 86400 (24 h, the default). */
125
211
  readonly timeRangeSeconds?: number;
126
212
  }
127
213
  export declare class SpiderRouting {
128
214
  private readonly transport;
129
215
  constructor(transport: Transport);
130
216
  plan(options: PlanOptions): Promise<SpiderResult<Route>>;
217
+ /**
218
+ * Streams itineraries over Server-Sent Events as the router sweeps the search window forward, emitting them
219
+ * as they finalize instead of one batched page. Lazy and cancellable: iteration opens the request, and
220
+ * `break`ing out of the `for await` cancels the underlying stream. Each `result` event carries itineraries
221
+ * with realtime delays already on their legs; a terminal `done` event then carries the continuation
222
+ * {@link RoutePageInfo} and any `routingErrors` (or a terminal `failure`). Never throws — transport, HTTP and
223
+ * request errors surface as a `failure` event.
224
+ *
225
+ * `targetResults` (a soft floor the sweep aims to reach) and `maxWindowMinutes` (how far it may search, at
226
+ * least 2 h) are required. This opens a fresh stream; to continue, call {@link planStreamNext} with
227
+ * `done.pageInfo.endCursor` (when `hasNextPage`) or {@link planStreamPrevious} with `done.pageInfo.startCursor`
228
+ * (when `hasPreviousPage`). For a single batched page instead, use {@link plan}.
229
+ */
230
+ planStream(options: PlanStreamRequestOptions): AsyncGenerator<PlanStreamEvent>;
231
+ /**
232
+ * Continues a stream forward from a prior `done` event's `endCursor`. Takes the same options as
233
+ * {@link planStream} (so `targetResults` / `maxWindowMinutes` can vary per continuation) plus the raw cursor.
234
+ * Call only when the prior `done.pageInfo.hasNextPage` was true.
235
+ */
236
+ planStreamNext(options: PlanStreamRequestOptions, after: string): AsyncGenerator<PlanStreamEvent>;
237
+ /**
238
+ * Continues a stream backward from a prior `done` event's `startCursor`. Takes the same options as
239
+ * {@link planStream} plus the raw cursor. Call only when the prior `done.pageInfo.hasPreviousPage` was true.
240
+ */
241
+ planStreamPrevious(options: PlanStreamRequestOptions, before: string): AsyncGenerator<PlanStreamEvent>;
242
+ private streamVariables;
243
+ private openPlanStream;
131
244
  planNext(route: Route): Promise<SpiderResult<Route> | null>;
132
245
  planPrevious(route: Route): Promise<SpiderResult<Route> | null>;
133
246
  /**
134
- * Streams itineraries by stepping the search forward one search window at a time, until `targetResults`
135
- * itineraries have been collected or `maxTraversalMinutes` of time has been traversed. Each step pulls a
136
- * whole window in one search, so a busy window yields more — `targetResults` is a soft floor, the window
137
- * that reaches it is yielded whole. Lazy: `for await ... break` stops stepping and skips the remaining OTP
138
- * searches. Each yield is one step's `SpiderResult` (a terminal error ends the stream), matching the
139
- * non-throwing poll helpers.
140
- *
141
- * The step is `searchWindowMinutes` and it is fixed for the whole walk — OTP locks the window into the
142
- * paging cursor after the first search and ignores it thereafter, so a wider step means a wider
143
- * `searchWindowMinutes` here, not on a continuation.
247
+ * Upcoming departures from a stop or station: `numberOfDepartures` (default 30, up to the environment's
248
+ * limit) within `options.timeRangeSeconds` (default 24 h) from `options.startTime` (default now).
144
249
  */
145
- planUntil(options: PlanStreamOptions): AsyncGenerator<SpiderResult<Route>>;
146
- /** Streaming form of `planNext`: steps forward from `prev`, one (fixed) search window per step. */
147
- planNextUntil(prev: Route, options?: PlanStreamPageOptions): AsyncGenerator<SpiderResult<Route>>;
148
- /** Streaming form of `planPrevious`: steps backward from `prev`, one (fixed) search window per step. */
149
- planPreviousUntil(prev: Route, options?: PlanStreamPageOptions): AsyncGenerator<SpiderResult<Route>>;
150
- private stepFrom;
151
250
  departures(stopId: string, numberOfDepartures?: number, options?: DeparturesOptions): Promise<SpiderResult<Departure[]>>;
251
+ /** One trip on one service date (ISO `YYYY-MM-DD`, e.g. a {@link Departure.serviceDate}); undefined = today. */
152
252
  trip(tripId: string, serviceDate?: string): Promise<SpiderResult<TripDetails>>;
153
253
  private page;
154
254
  private fetchPlan;
155
255
  }
256
+ export declare function parsePlanStreamRecord(event: string, data: string): PlanStreamEvent | null;
156
257
  //# sourceMappingURL=routing.d.ts.map