@opentripplanner/core-utils 9.0.0-alpha.35 → 9.0.0-alpha.37
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/esm/itinerary.js +6 -2
- package/esm/itinerary.js.map +1 -1
- package/esm/query-gen.js +8 -1
- package/esm/query-gen.js.map +1 -1
- package/lib/itinerary.d.ts +2 -2
- package/lib/itinerary.d.ts.map +1 -1
- package/lib/itinerary.js +4 -2
- package/lib/itinerary.js.map +1 -1
- package/lib/query-gen.d.ts +6 -0
- package/lib/query-gen.d.ts.map +1 -1
- package/lib/query-gen.js +8 -1
- package/lib/query-gen.js.map +1 -1
- package/package.json +1 -1
- package/src/__tests__/itinerary.js +34 -34
- package/src/itinerary.ts +12 -10
- package/src/otpSchema.json +598 -2720
- package/src/planQuery.graphql +11 -11
- package/src/query-gen.ts +6 -0
- package/tsconfig.tsbuildinfo +1 -1
package/src/itinerary.ts
CHANGED
|
@@ -570,7 +570,7 @@ export function getLegCost(
|
|
|
570
570
|
leg: Leg,
|
|
571
571
|
mediumId: string,
|
|
572
572
|
riderCategoryId: string
|
|
573
|
-
): { price
|
|
573
|
+
): { price?: Money; transferAmount?: Money | undefined } {
|
|
574
574
|
if (!leg.fareProducts) return { price: undefined };
|
|
575
575
|
const relevantFareProducts = leg.fareProducts.filter(({ product }) => {
|
|
576
576
|
return (
|
|
@@ -602,17 +602,19 @@ export function getItineraryCost(
|
|
|
602
602
|
legs: Leg[],
|
|
603
603
|
mediumId: string,
|
|
604
604
|
riderCategoryId: string
|
|
605
|
-
): Money {
|
|
606
|
-
|
|
605
|
+
): Money | undefined {
|
|
606
|
+
const legCosts = legs
|
|
607
607
|
.filter(leg => leg.fareProducts?.length > 0)
|
|
608
608
|
.map(leg => getLegCost(leg, mediumId, riderCategoryId).price)
|
|
609
|
-
.
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
)
|
|
609
|
+
.filter(cost => cost !== undefined);
|
|
610
|
+
if (legCosts.length === 0) return undefined;
|
|
611
|
+
return legCosts.reduce<Money>(
|
|
612
|
+
(prev, cur) => ({
|
|
613
|
+
amount: prev.amount + cur?.amount || 0,
|
|
614
|
+
currency: prev.currency ?? cur?.currency
|
|
615
|
+
}),
|
|
616
|
+
{ amount: 0, currency: null }
|
|
617
|
+
);
|
|
616
618
|
}
|
|
617
619
|
|
|
618
620
|
const pickupDropoffTypeToOtp1 = otp2Type => {
|