@opentripplanner/core-utils 16.0.4 → 16.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opentripplanner/core-utils",
3
- "version": "16.0.4",
3
+ "version": "16.1.0",
4
4
  "description": "Core functionality that is shared among numerous UI components",
5
5
  "engines": {
6
6
  "node": ">=13"
@@ -25,13 +25,14 @@
25
25
  "graphql": "^16.6.0",
26
26
  "lodash.clonedeep": "^4.5.0",
27
27
  "qs": "^6.9.1",
28
- "@opentripplanner/geocoder": "^3.1.1"
28
+ "@opentripplanner/geocoder": "^3.1.2"
29
29
  },
30
30
  "gitHead": "0af1b7cda60bd4252b219dcf893e01c2acb2ed5d",
31
31
  "devDependencies": {
32
32
  "@types/chroma-js": "^3.1.2",
33
33
  "@types/mapbox__polyline": "^1.0.5",
34
- "@opentripplanner/types": "^8.4.0"
34
+ "@types/node": "^25.6.0",
35
+ "@opentripplanner/types": "^8.5.0"
35
36
  },
36
37
  "scripts": {
37
38
  "tsc": "tsc"
@@ -263,6 +263,10 @@ exports[`query parseLocationString should return location with coordinates as na
263
263
 
264
264
  exports[`query parseLocationString should return null for null input 1`] = `null`;
265
265
 
266
+ exports[`query parseLocationString should return null with name as name with no coords (but with commas) for input 1`] = `null`;
267
+
268
+ exports[`query parseLocationString should return null with name as name with no coords for input 1`] = `null`;
269
+
266
270
  exports[`query planParamsToQuery should parse a depart at query 1`] = `
267
271
  {
268
272
  "bannedRoutes": "897ABC",
@@ -218,6 +218,13 @@ describe("query", () => {
218
218
  parseLocationString("33.983929829,-87.3892387982")
219
219
  ).toMatchSnapshot();
220
220
  });
221
+
222
+ it("should return null with name as name with no coords for input", () => {
223
+ expect(parseLocationString("1 cool street")).toMatchSnapshot();
224
+ });
225
+ it("should return null with name as name with no coords (but with commas) for input", () => {
226
+ expect(parseLocationString("148, se street")).toMatchSnapshot();
227
+ });
221
228
  });
222
229
 
223
230
  describe("planParamsToQuery", () => {
@@ -7,6 +7,7 @@ query Plan(
7
7
  $fromPlace: String!
8
8
  $modes: [TransportMode]
9
9
  $numItineraries: Int
10
+ $omitCanceled: Boolean
10
11
  $time: String
11
12
  $toPlace: String!
12
13
  $unpreferred: InputUnpreferred
@@ -24,6 +25,7 @@ query Plan(
24
25
  # Currently only supporting EN locale, used for times and text
25
26
  locale: "en"
26
27
  numItineraries: $numItineraries
28
+ omitCanceled: $omitCanceled
27
29
  time: $time
28
30
  toPlace: $toPlace
29
31
  transportModes: $modes
package/src/query-gen.ts CHANGED
@@ -24,15 +24,16 @@ type InputPreferred = {
24
24
 
25
25
  type OTPQueryParams = {
26
26
  arriveBy: boolean;
27
+ banned?: InputBanned;
27
28
  date?: string;
28
29
  from: LonLatOutput & { name?: string };
29
30
  modes: TransportMode[];
30
31
  modeSettings: ModeSetting[];
31
- time?: string;
32
32
  numItineraries?: number;
33
- to: LonLatOutput & { name?: string };
34
- banned?: InputBanned;
33
+ omitCanceled?: boolean;
35
34
  preferred?: InputPreferred;
35
+ time?: string;
36
+ to: LonLatOutput & { name?: string };
36
37
  unpreferred?: InputPreferred;
37
38
  };
38
39
 
package/src/query.js CHANGED
@@ -247,7 +247,7 @@ async function getFirstGeocodeResult(
247
247
  if (firstResult) {
248
248
  return geocoder.getLocationFromGeocodedFeature(firstResult);
249
249
  }
250
- return null;
250
+ return { name: `(Geocoder failure) ${text}` };
251
251
  });
252
252
  }
253
253
 
@@ -265,7 +265,7 @@ export function parseLocationString(value) {
265
265
  ? stringToCoords(parts[1])
266
266
  : stringToCoords(parts[0]);
267
267
  const name = parts[1] ? parts[0] : coordsToString(coordinates);
268
- return coordinates.length === 2
268
+ return coordinates.length === 2 && coordinates.every(c => !!c)
269
269
  ? {
270
270
  name: name || null,
271
271
  lat: coordinates[0] || null,