@odynn/awayz-flights 0.10.17 → 0.10.20

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.
@@ -0,0 +1,5 @@
1
+ var T = /* @__PURE__ */ ((_) => (_.TOKEN = "token", _.REFRESH_TOKEN = "refreshToken", _.CLIENT_ID = "clientId", _.AUTH_FLOW = "authFlow", _.OVERRIDE_TOKEN_EXCHANGE_ENDPOINT = "overrideExchangeTokenEndpoint", _.OVERRIDE_PAC_ENDPOINT = "overridePACEndpoint", _))(T || {}), d = /* @__PURE__ */ ((_) => (_.ISO = "dates:iso", _.DISPLAY_SHORT = "dates:displayShort", _.DISPLAY_MEDIUM = "dates:displayMedium", _.DISPLAY_LONG = "dates:displayLong", _.DISPLAY_FULL = "dates:displayFull", _.DISPLAY_SHORT_WITH_YEAR = "dates:displayShortWithYear", _.DISPLAY_MEDIUM_WITH_YEAR = "dates:displayMediumWithYear", _.DISPLAY_LONG_WITH_YEAR = "dates:displayLongWithYear", _.DISPLAY_FULL_WITH_YEAR = "dates:displayFullWithYear", _.DATE_TIME_SHORT = "dates:dateTimeShort", _.DATE_TIME_MEDIUM = "dates:dateTimeMedium", _.DATE_TIME_LONG = "dates:dateTimeLong", _.DATE_TIME_FULL = "dates:dateTimeFull", _.DATE_TIME_SHORT_WITH_YEAR = "dates:dateTimeShortWithYear", _.DATE_TIME_MEDIUM_WITH_YEAR = "dates:dateTimeMediumWithYear", _.DATE_TIME_LONG_WITH_YEAR = "dates:dateTimeLongWithYear", _.DATE_TIME_FULL_WITH_YEAR = "dates:dateTimeFullWithYear", _.TIME_ONLY = "dates:timeOnly", _.TIME_WITH_SECONDS = "dates:timeWithSeconds", _))(d || {});
2
+ export {
3
+ d as E,
4
+ T as a
5
+ };
@@ -40,6 +40,7 @@ export interface ISearchFlightArgs {
40
40
  passengers?: {
41
41
  adults: number;
42
42
  children: number;
43
+ infants: number;
43
44
  };
44
45
  /**
45
46
  * Optional Payment Type
@@ -4,7 +4,8 @@ import { IAirlineProgram } from '../services/wallet/WalletService.types';
4
4
  import { ECabinClass } from '../types/ECabinClass';
5
5
  declare enum EPassengerType {
6
6
  ADULT = "adult",
7
- CHILD = "child"
7
+ CHILD = "child",
8
+ INFANT = "infant"
8
9
  }
9
10
  /**
10
11
  * @description - maps flight details into the flight result format, which is the expected format for Flight Components throughout the Awayz Application
@@ -35,12 +36,14 @@ export declare const getOperatedBy: (segment: ISegment) => string;
35
36
  * @param {EFlightPaymentType} params.paymentType - The type of payment (e.g., cash, points).
36
37
  * @returns {string} The constructed flight search query URL.
37
38
  */
38
- export declare const buildFlightSearchQuery: ({ originCode, destinationCode, dates, cabinClass, passengerCount, paymentType }: {
39
+ export declare const buildFlightSearchQuery: ({ originCode, destinationCode, dates, cabinClass, adults, children, infants, paymentType }: {
39
40
  originCode: string;
40
41
  destinationCode: string;
41
42
  dates: string[];
42
43
  cabinClass: ECabinClass;
43
- passengerCount: number;
44
+ adults: number;
45
+ children: number;
46
+ infants: number;
44
47
  paymentType: string[];
45
48
  }) => string;
46
49
  /**
@@ -95,12 +98,14 @@ export declare const getAirlineProgram: (airlineProgramName: string) => Promise<
95
98
  export declare const buildPassengerArray: (config: {
96
99
  adults: number;
97
100
  children: number;
101
+ infants: number;
98
102
  }) => {
99
103
  type: EPassengerType;
100
104
  }[];
101
105
  interface IPassengers {
102
106
  adults: number;
103
107
  children: number;
108
+ infants: number;
104
109
  }
105
110
  export declare const passengerValues: (passengers?: IPassengers) => {
106
111
  passengerCount: number;
package/dist/main.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { useFlightSearch as Y } from "./hooks/useFlightSearch/useFlightSearch.js";
2
2
  import { useAirportSearch as p } from "./hooks/useAirportSearch/useAirportSearch.js";
3
3
  import { EBaggage as l } from "./hooks/useFlightSearch/useFlightSearch.types.js";
4
- import { F as h, g as f } from "./FlightItinerary-BMRY5V0b.js";
4
+ import { F as h, g as f } from "./FlightItinerary-BAARVZkD.js";
5
5
  import { FlightItineraryDropdown as S } from "./components/FlightItineraryDropdown/FlightItineraryDropdown.js";
6
6
  import "react/jsx-runtime";
7
7
  import "react";
@@ -1,27 +1,27 @@
1
- import { defaultAwayzConfig as Y, awayzClient as Q } from "@odynn/awayz-core";
1
+ import { defaultAwayzConfig as H, awayzClient as Y } from "@odynn/awayz-core";
2
2
  import "react/jsx-runtime";
3
- import { d as q } from "../dateUtils-Cb9VQiIL.js";
3
+ import { d as j } from "../dateUtils-Cb9VQiIL.js";
4
4
  import "../arrayExtensions-Ce8YopTP.js";
5
5
  import "react";
6
6
  import { h as y } from "../moment-BGjjqtLQ.js";
7
- import { EFlightEndpoint as V } from "../constants/endpoints.js";
8
- import { mapBaggageType as W } from "../hooks/useFlightSearch/useFlightSearch.types.js";
9
- import { WalletService as f } from "../services/wallet/WalletService.js";
7
+ import { EFlightEndpoint as Q } from "../constants/endpoints.js";
8
+ import { mapBaggageType as V } from "../hooks/useFlightSearch/useFlightSearch.types.js";
9
+ import { WalletService as W } from "../services/wallet/WalletService.js";
10
10
  import { ERewardProgramCategories as J } from "../services/wallet/WalletService.types.js";
11
11
  const X = "https://assets.duffel.com/img/airlines/for-light-background/full-color-lockup/", ye = (s) => s == null ? void 0 : s.map((e) => {
12
- var l, n, c, a, t, u, d, r, o, p, m, C, g, b, F, A, L, T, w, D, P, I, k, O, R, _, v, E, M, N, $, z, G, Z, S, U;
13
- const i = ae(e);
12
+ var m, r, l, a, i, n, d, o, c, p, u, g, C, b, F, A, L, T, w, D, P, I, k, O, R, _, v, E, $, M, N, z, G, Z, S, U;
13
+ const t = ae(e);
14
14
  return {
15
15
  id: e.id,
16
16
  points: (e == null ? void 0 : e.points) >= 0 ? e.points : -1,
17
17
  partial: e == null ? void 0 : e.partial,
18
18
  origin: {
19
- city: ((l = e.slices[0].segments[0].origin) == null ? void 0 : l.cityName) || ((c = (n = e.slices[0].segments[0].origin) == null ? void 0 : n.city) == null ? void 0 : c.name) || "",
20
- country: ((a = e.slices[0].segments[0].origin) == null ? void 0 : a.iataCountryCode) || ((u = (t = e.slices[0].segments[0].origin) == null ? void 0 : t.city) == null ? void 0 : u.iataCountryCode) || "",
21
- airportCode: ((d = e.slices[0].segments[0].origin) == null ? void 0 : d.iataCode) || ((o = (r = e.slices[0].segments[0].origin) == null ? void 0 : r.city) == null ? void 0 : o.iataCode) || "",
19
+ city: ((m = e.slices[0].segments[0].origin) == null ? void 0 : m.cityName) || ((l = (r = e.slices[0].segments[0].origin) == null ? void 0 : r.city) == null ? void 0 : l.name) || "",
20
+ country: ((a = e.slices[0].segments[0].origin) == null ? void 0 : a.iataCountryCode) || ((n = (i = e.slices[0].segments[0].origin) == null ? void 0 : i.city) == null ? void 0 : n.iataCountryCode) || "",
21
+ airportCode: ((d = e.slices[0].segments[0].origin) == null ? void 0 : d.iataCode) || ((c = (o = e.slices[0].segments[0].origin) == null ? void 0 : o.city) == null ? void 0 : c.iataCode) || "",
22
22
  coordinates: {
23
- latitude: ((m = (p = e.slices[0].segments[0].origin) == null ? void 0 : p.city) == null ? void 0 : m.latitude) || 0,
24
- longitude: ((g = (C = e.slices[0].segments[0].origin) == null ? void 0 : C.city) == null ? void 0 : g.longitude) || 0
23
+ latitude: ((u = (p = e.slices[0].segments[0].origin) == null ? void 0 : p.city) == null ? void 0 : u.latitude) || 0,
24
+ longitude: ((C = (g = e.slices[0].segments[0].origin) == null ? void 0 : g.city) == null ? void 0 : C.longitude) || 0
25
25
  }
26
26
  },
27
27
  destination: {
@@ -29,14 +29,14 @@ const X = "https://assets.duffel.com/img/airlines/for-light-background/full-colo
29
29
  country: ((D = (w = e.slices[0].segments.getLast()) == null ? void 0 : w.destination) == null ? void 0 : D.iataCountryCode) || ((k = (I = (P = e.slices[0].segments.getLast()) == null ? void 0 : P.destination) == null ? void 0 : I.city) == null ? void 0 : k.iataCountryCode) || "",
30
30
  airportCode: ((R = (O = e.slices[0].segments.getLast()) == null ? void 0 : O.destination) == null ? void 0 : R.iataCode) || ((E = (v = (_ = e.slices[0].segments.getLast()) == null ? void 0 : _.destination) == null ? void 0 : v.city) == null ? void 0 : E.iataCode) || "",
31
31
  coordinates: {
32
- latitude: (($ = (N = (M = e.slices[0].segments.getLast()) == null ? void 0 : M.destination) == null ? void 0 : N.city) == null ? void 0 : $.latitude) || 0,
32
+ latitude: ((N = (M = ($ = e.slices[0].segments.getLast()) == null ? void 0 : $.destination) == null ? void 0 : M.city) == null ? void 0 : N.latitude) || 0,
33
33
  longitude: ((Z = (G = (z = e.slices[0].segments.getLast()) == null ? void 0 : z.destination) == null ? void 0 : G.city) == null ? void 0 : Z.longitude) || 0
34
34
  }
35
35
  },
36
36
  // `airline` is an existing unqualified field; semantics are display-primary carrier.
37
- airline: (i == null ? void 0 : i.name) ?? "",
38
- airlineLogo: h((i == null ? void 0 : i.iataCode) ?? ""),
39
- displayAirlineIataCode: (i == null ? void 0 : i.iataCode) ?? "",
37
+ airline: (t == null ? void 0 : t.name) ?? "",
38
+ airlineLogo: h((t == null ? void 0 : t.iataCode) ?? ""),
39
+ displayAirlineIataCode: (t == null ? void 0 : t.iataCode) ?? "",
40
40
  cash: e.totalAmount ? parseFloat(e.totalAmount) : 0,
41
41
  currency: e.baseCurrency,
42
42
  flightNumber: ee(e.slices[0].segments[0]),
@@ -50,7 +50,7 @@ const X = "https://assets.duffel.com/img/airlines/for-light-background/full-colo
50
50
  duration: e.slices[0].duration,
51
51
  airlineProgram: e.airlineProgram,
52
52
  paymentOptions: [],
53
- durationMinutes: q({
53
+ durationMinutes: j({
54
54
  departureTime: y(e.slices[0].segments[0].departingAt),
55
55
  arrivalTime: y((S = e.slices[0].segments.getLast()) == null ? void 0 : S.arrivingAt),
56
56
  originTimeZone: e.slices[0].segments[0].origin.timeZone,
@@ -65,11 +65,11 @@ const X = "https://assets.duffel.com/img/airlines/for-light-background/full-colo
65
65
  lastCachedTime: e.lastCachedTime
66
66
  };
67
67
  }), ee = (s) => {
68
- const e = s.marketingCarrier ?? s.operatingCarrier, i = s.marketingCarrierFlightNumber ?? s.operatingCarrierFlightNumber;
69
- return e.iataCode + " " + H(i);
68
+ const e = s.marketingCarrier ?? s.operatingCarrier, t = s.marketingCarrierFlightNumber ?? s.operatingCarrierFlightNumber;
69
+ return e.iataCode + " " + q(t);
70
70
  }, se = (s) => {
71
- var i;
72
- const e = (i = s == null ? void 0 : s.segments) == null ? void 0 : i[0];
71
+ var t;
72
+ const e = (t = s == null ? void 0 : s.segments) == null ? void 0 : t[0];
73
73
  return (e == null ? void 0 : e.marketingCarrier) ?? (e == null ? void 0 : e.operatingCarrier);
74
74
  }, ae = (s) => {
75
75
  var e;
@@ -77,49 +77,51 @@ const X = "https://assets.duffel.com/img/airlines/for-light-background/full-colo
77
77
  }, he = (s) => !s.operatingCarrier || !s.marketingCarrier ? "" : s.operatingCarrier.iataCode !== s.marketingCarrier.iataCode ? s.operatingCarrier.name : "", be = ({
78
78
  originCode: s,
79
79
  destinationCode: e,
80
- dates: i,
81
- cabinClass: l,
82
- passengerCount: n,
83
- paymentType: c
80
+ dates: t,
81
+ cabinClass: m,
82
+ adults: r,
83
+ children: l,
84
+ infants: a,
85
+ paymentType: i
84
86
  }) => {
85
- let a = `${V.CASH_POINTS_FLIGHT_SEARCH}?`;
86
- return a += `origin=${s}`, a += `&destination=${e}`, a += `&departure_dates=[${i.map((t) => `"${t}"`).join(",")}]`, a += `&cabin_class=${l}`, a += `&adults=${n}`, a += `&cash_or_points=[${c}]`, a;
87
- }, te = (s) => s.flightDetails.slices[0].segments.map((i) => ie(i)).join("_") + "_" + y(s.departureTime).format("YYYYMMDD"), ie = (s) => {
88
- const e = s.operatingCarrier ?? s.marketingCarrier, i = s.operatingCarrierFlightNumber ?? s.marketingCarrierFlightNumber;
89
- return e.iataCode + " " + H(i);
87
+ let n = `${Q.CASH_POINTS_FLIGHT_SEARCH}?`;
88
+ return n += `origin=${s}`, n += `&destination=${e}`, n += `&departure_dates=[${t.map((d) => `"${d}"`).join(",")}]`, n += `&cabin_class=${m}`, n += `&adults=${r}`, n += `&children=${l}`, n += `&infants=${a}`, n += `&cash_or_points=[${i}]`, n;
89
+ }, te = (s) => s.flightDetails.slices[0].segments.map((t) => ie(t)).join("_") + "_" + y(s.departureTime).format("YYYYMMDD"), ie = (s) => {
90
+ const e = s.operatingCarrier ?? s.marketingCarrier, t = s.operatingCarrierFlightNumber ?? s.marketingCarrierFlightNumber;
91
+ return e.iataCode + " " + q(t);
90
92
  }, Fe = (s) => s ? s.replace(/[_-]/g, " ").split(" ").map((e) => e.charAt(0).toUpperCase() + e.slice(1).toLowerCase()).join(" ") : "", Ae = (s) => {
91
93
  const e = {};
92
94
  s.forEach((a) => {
93
- var u, d;
94
- const t = te(a);
95
- if (e[t]) {
96
- const r = K(a);
97
- e[t].flight.paymentOptions.push(r);
98
- const { lowestCash: o, currency: p, lowestPoints: m, cashFee: C, cacheData: g } = j(e[t].flight.paymentOptions);
99
- e[t].flight.points = m, e[t].flight.cashFee = C, e[t].flight.cash = o, p && (e[t].flight.currency = p), e[t].flight.isCached = g.isCached, e[t].flight.lastCachedTime = g.lastCachedTime, g.isCached && !e[t].flight.flightDetails.isCached && (e[t].flight.flightDetails = {
100
- ...e[t].flight.flightDetails,
101
- isCached: g.isCached,
102
- lastCachedTime: g.lastCachedTime
95
+ var n, d;
96
+ const i = te(a);
97
+ if (e[i]) {
98
+ const o = x(a);
99
+ e[i].flight.paymentOptions.push(o);
100
+ const { lowestCash: c, currency: p, lowestPoints: u, cashFee: g, cacheData: C } = K(e[i].flight.paymentOptions);
101
+ e[i].flight.points = u, e[i].flight.cashFee = g, e[i].flight.cash = c, p && (e[i].flight.currency = p), e[i].flight.isCached = C.isCached, e[i].flight.lastCachedTime = C.lastCachedTime, C.isCached && !e[i].flight.flightDetails.isCached && (e[i].flight.flightDetails = {
102
+ ...e[i].flight.flightDetails,
103
+ isCached: C.isCached,
104
+ lastCachedTime: C.lastCachedTime
103
105
  });
104
106
  } else {
105
- const { origin: r, destination: o } = a, p = [K(a)], m = j(p);
106
- e[t] = {
107
+ const { origin: o, destination: c } = a, p = [x(a)], u = K(p);
108
+ e[i] = {
107
109
  programs: [],
108
110
  flight: {
109
111
  id: a.awayzGroupId,
110
112
  partial: a.partial,
111
113
  origin: {
112
- city: r.city,
113
- country: r.country,
114
- airportCode: r.airportCode,
115
- coordinates: r.coordinates
116
- },
117
- destination: {
118
114
  city: o.city,
119
115
  country: o.country,
120
116
  airportCode: o.airportCode,
121
117
  coordinates: o.coordinates
122
118
  },
119
+ destination: {
120
+ city: c.city,
121
+ country: c.country,
122
+ airportCode: c.airportCode,
123
+ coordinates: c.coordinates
124
+ },
123
125
  airline: a.airline,
124
126
  airlineLogo: a.airlineLogo,
125
127
  displayAirlineIataCode: a.displayAirlineIataCode,
@@ -128,22 +130,22 @@ const X = "https://assets.duffel.com/img/airlines/for-light-background/full-colo
128
130
  numberOfStops: a.numberOfStops,
129
131
  departureTime: a.departureTime,
130
132
  arrivalTime: a.arrivalTime,
131
- awayzGroupId: t,
133
+ awayzGroupId: i,
132
134
  duration: a.duration,
133
135
  airlineProgram: a.airlineProgram,
134
- durationMinutes: q({
136
+ durationMinutes: j({
135
137
  departureTime: y(
136
138
  a.flightDetails.slices[0].segments[0].departingAt
137
139
  ),
138
140
  arrivalTime: y(
139
- (u = a.flightDetails.slices[0].segments.getLast()) == null ? void 0 : u.arrivingAt
141
+ (n = a.flightDetails.slices[0].segments.getLast()) == null ? void 0 : n.arrivingAt
140
142
  ),
141
143
  originTimeZone: a.flightDetails.slices[0].segments[0].origin.timeZone,
142
144
  destinationTimeZone: (d = a.flightDetails.slices[0].segments.getLast()) == null ? void 0 : d.destination.timeZone,
143
145
  duration: a.flightDetails.slices[0].duration
144
146
  }),
145
- cash: m.lowestCash,
146
- points: m.lowestPoints,
147
+ cash: u.lowestCash,
148
+ points: u.lowestPoints,
147
149
  flightDetails: a.flightDetails,
148
150
  currency: a.flightDetails.baseCurrency,
149
151
  cashFee: a.cashFee,
@@ -155,50 +157,50 @@ const X = "https://assets.duffel.com/img/airlines/for-light-background/full-colo
155
157
  }
156
158
  };
157
159
  }
158
- a.airlineProgram && !e[t].programs.includes(a.airlineProgram) && e[t].programs.push(a.airlineProgram);
160
+ a.airlineProgram && !e[i].programs.includes(a.airlineProgram) && e[i].programs.push(a.airlineProgram);
159
161
  });
160
- const i = [];
162
+ const t = [];
161
163
  Object.values(e).forEach((a) => {
162
- const t = a.flight.paymentOptions.filter((r) => r.cash > 0).reduce(
163
- (r, o) => o.cash < r.cash ? o : r,
164
+ const i = a.flight.paymentOptions.filter((o) => o.cash > 0).reduce(
165
+ (o, c) => c.cash < o.cash ? c : o,
164
166
  { cash: 1 / 0, carrier: { name: "", iataCode: "" } }
165
- ), u = {
167
+ ), n = {
166
168
  iataCode: a.flight.displayAirlineIataCode,
167
169
  name: a.flight.airline
168
- }, d = t.cash !== 1 / 0 ? t.carrier : u;
169
- a.programs.length > 0 ? a.programs.forEach((r) => {
170
- const o = a.flight.paymentOptions.filter(
171
- (m) => m.program === r && m.points > 0
172
- ), p = o.length > 0 ? Math.min(...o.map((m) => m.points)) : -1;
173
- i.push({
170
+ }, d = i.cash !== 1 / 0 ? i.carrier : n;
171
+ a.programs.length > 0 ? a.programs.forEach((o) => {
172
+ const c = a.flight.paymentOptions.filter(
173
+ (u) => u.program === o && u.points > 0
174
+ ), p = c.length > 0 ? Math.min(...c.map((u) => u.points)) : -1;
175
+ t.push({
174
176
  ...a.flight,
175
177
  airline: d.name,
176
178
  airlineLogo: h(d.iataCode),
177
179
  displayAirlineIataCode: d.iataCode,
178
- airlineProgram: r,
179
- cash: t.cash !== 1 / 0 ? t.cash : -1,
180
+ airlineProgram: o,
181
+ cash: i.cash !== 1 / 0 ? i.cash : -1,
180
182
  points: p
181
183
  });
182
- }) : i.push({
184
+ }) : t.push({
183
185
  ...a.flight,
184
186
  airline: d.name,
185
187
  airlineLogo: h(d.iataCode),
186
188
  displayAirlineIataCode: d.iataCode,
187
- cash: t.cash !== 1 / 0 ? t.cash : -1
189
+ cash: i.cash !== 1 / 0 ? i.cash : -1
188
190
  });
189
191
  });
190
- const { cashlessResults: l, otherResults: n } = i.reduce(
191
- (a, t) => (t.cash <= 0 && t.points > 0 ? a.cashlessResults.push(t) : t.cash > 0 && a.otherResults.push(t), a),
192
+ const { cashlessResults: m, otherResults: r } = t.reduce(
193
+ (a, i) => (i.cash <= 0 && i.points > 0 ? a.cashlessResults.push(i) : i.cash > 0 && a.otherResults.push(i), a),
192
194
  { cashlessResults: [], otherResults: [] }
193
- ), c = [...n];
194
- return l.forEach((a) => {
195
- (!c.find(
196
- (u) => u.awayzGroupId === a.awayzGroupId
197
- ) || n.length === 0) && c.push(a);
198
- }), c;
199
- }, H = (s) => s ? s.replace(/^0+/, "") : "", Le = (s) => `https://assets.duffel.com/img/airlines/for-light-background/full-color-logo/${s}.svg`, h = (s) => `${X}${s}.svg`, B = Y.logoFallbackImageUrl, x = {
200
- categoryLogo: B,
201
- programLogo: B,
195
+ ), l = [...r];
196
+ return m.forEach((a) => {
197
+ (!l.find(
198
+ (n) => n.awayzGroupId === a.awayzGroupId
199
+ ) || r.length === 0) && l.push(a);
200
+ }), l;
201
+ }, q = (s) => s ? s.replace(/^0+/, "") : "", Le = (s) => `https://assets.duffel.com/img/airlines/for-light-background/full-color-logo/${s}.svg`, h = (s) => `${X}${s}.svg`, f = H.logoFallbackImageUrl, B = {
202
+ categoryLogo: f,
203
+ programLogo: f,
202
204
  awayzActive: [],
203
205
  mainProgram: "Unknown",
204
206
  displayProgram: "Unknown",
@@ -209,30 +211,30 @@ const X = "https://assets.duffel.com/img/airlines/for-light-background/full-colo
209
211
  // Using App Foreground Colour
210
212
  url: "https://www.odynn.com"
211
213
  }, Te = async (s) => {
212
- const { airlines: e } = await Q.ensureQueryData({
214
+ const { airlines: e } = await Y.ensureQueryData({
213
215
  queryKey: ["walletAwards"],
214
- queryFn: f.getAwards,
216
+ queryFn: W.getAwards,
215
217
  staleTime: 864e5
216
218
  // 24 hours
217
219
  });
218
- let i = e.find(
219
- (l) => {
220
- var n, c, a, t;
221
- return ((c = (n = l.mainProgram) == null ? void 0 : n.toLowerCase()) == null ? void 0 : c.includes(s == null ? void 0 : s.toLowerCase())) || ((t = (a = l.displayProgram) == null ? void 0 : a.toLowerCase()) == null ? void 0 : t.includes(s == null ? void 0 : s.toLowerCase()));
220
+ let t = e.find(
221
+ (m) => {
222
+ var r, l, a, i;
223
+ return ((l = (r = m.mainProgram) == null ? void 0 : r.toLowerCase()) == null ? void 0 : l.includes(s == null ? void 0 : s.toLowerCase())) || ((i = (a = m.displayProgram) == null ? void 0 : a.toLowerCase()) == null ? void 0 : i.includes(s == null ? void 0 : s.toLowerCase()));
222
224
  }
223
- ) ?? x;
224
- return i || (i = {
225
- ...x,
225
+ ) ?? B;
226
+ return t || (t = {
227
+ ...B,
226
228
  mainProgram: s,
227
229
  displayProgram: s,
228
230
  id: s
229
- }), i;
230
- }, K = (s) => {
231
- var n, c, a, t, u, d, r, o, p, m;
232
- const e = ((a = (c = (n = s.flightDetails.slices.getFirst()) == null ? void 0 : n.segments.getFirst()) == null ? void 0 : c.passengers.getFirst()) == null ? void 0 : a.baggages) ?? [], i = ((d = (u = (t = s.flightDetails.slices.getFirst()) == null ? void 0 : t.segments.getFirst()) == null ? void 0 : u.passengers.getFirst()) == null ? void 0 : d.cabinClassMarketingName) ?? ((p = (o = (r = s.flightDetails.slices.getFirst()) == null ? void 0 : r.segments.getFirst()) == null ? void 0 : o.passengers.getFirst()) == null ? void 0 : p.cabinClass), l = e.map(
233
- (C) => ({
234
- type: W(C.type),
235
- quantity: C.quantity
231
+ }), t;
232
+ }, x = (s) => {
233
+ var r, l, a, i, n, d, o, c, p, u;
234
+ const e = ((a = (l = (r = s.flightDetails.slices.getFirst()) == null ? void 0 : r.segments.getFirst()) == null ? void 0 : l.passengers.getFirst()) == null ? void 0 : a.baggages) ?? [], t = ((d = (n = (i = s.flightDetails.slices.getFirst()) == null ? void 0 : i.segments.getFirst()) == null ? void 0 : n.passengers.getFirst()) == null ? void 0 : d.cabinClassMarketingName) ?? ((p = (c = (o = s.flightDetails.slices.getFirst()) == null ? void 0 : o.segments.getFirst()) == null ? void 0 : c.passengers.getFirst()) == null ? void 0 : p.cabinClass), m = e.map(
235
+ (g) => ({
236
+ type: V(g.type),
237
+ quantity: g.quantity
236
238
  })
237
239
  );
238
240
  return {
@@ -241,11 +243,11 @@ const X = "https://assets.duffel.com/img/airlines/for-light-background/full-colo
241
243
  points: s.points,
242
244
  program: s.airlineProgram,
243
245
  baseCurrency: s.flightDetails.baseCurrency,
244
- fareBrandName: ((m = s.flightDetails.slices.getFirst()) == null ? void 0 : m.fareBrandName) ?? "",
245
- cabinClass: i,
246
+ fareBrandName: ((u = s.flightDetails.slices.getFirst()) == null ? void 0 : u.fareBrandName) ?? "",
247
+ cabinClass: t,
246
248
  cashFee: s.cashFee,
247
249
  conditions: s.flightDetails.conditions,
248
- baggages: l,
250
+ baggages: m,
249
251
  // `carrier` is an existing unqualified field; semantics are marketing carrier.
250
252
  carrier: {
251
253
  iataCode: s.displayAirlineIataCode,
@@ -254,31 +256,31 @@ const X = "https://assets.duffel.com/img/airlines/for-light-background/full-colo
254
256
  isCached: s.isCached,
255
257
  lastCachedTime: s.lastCachedTime
256
258
  };
257
- }, j = (s) => {
259
+ }, K = (s) => {
258
260
  const e = s.filter((a) => a.cash > 0);
259
- let i = { cash: 1 / 0, baseCurrency: "" };
261
+ let t = { cash: 1 / 0, baseCurrency: "" };
260
262
  for (const a of e)
261
- a.cash < i.cash && (i = a);
262
- const l = [...s].filter(
263
+ a.cash < t.cash && (t = a);
264
+ const m = [...s].filter(
263
265
  (a) => a.points > 0
264
266
  );
265
- let n = {
267
+ let r = {
266
268
  points: 1 / 0,
267
269
  cashFee: { amount: 0, currency: "" },
268
270
  isCached: !1,
269
271
  lastCachedTime: ""
270
272
  };
271
- for (const a of l)
272
- a.points < n.points && (n = a);
273
- const c = i.cash;
273
+ for (const a of m)
274
+ a.points < r.points && (r = a);
275
+ const l = t.cash;
274
276
  return {
275
- lowestCash: c === 1 / 0 ? -1 : c,
276
- lowestPoints: n.points === 1 / 0 ? -1 : n.points,
277
- cashFee: n.cashFee,
278
- currency: i.baseCurrency === "" ? null : i.baseCurrency,
277
+ lowestCash: l === 1 / 0 ? -1 : l,
278
+ lowestPoints: r.points === 1 / 0 ? -1 : r.points,
279
+ cashFee: r.cashFee,
280
+ currency: t.baseCurrency === "" ? null : t.baseCurrency,
279
281
  cacheData: {
280
- isCached: n.isCached ?? !1,
281
- lastCachedTime: n.lastCachedTime ?? ""
282
+ isCached: r.isCached ?? !1,
283
+ lastCachedTime: r.lastCachedTime ?? ""
282
284
  }
283
285
  };
284
286
  }, ne = (s) => [
@@ -289,19 +291,24 @@ const X = "https://assets.duffel.com/img/airlines/for-light-background/full-colo
289
291
  ...Array.from({ length: s.children }, () => ({
290
292
  type: "child"
291
293
  /* CHILD */
294
+ })),
295
+ ...Array.from({ length: s.infants }, () => ({
296
+ type: "infant"
297
+ /* INFANT */
292
298
  }))
293
299
  ], we = (s) => {
294
- const i = {
300
+ const t = {
295
301
  adults: (s == null ? void 0 : s.adults) ?? 1,
296
- children: (s == null ? void 0 : s.children) ?? 0
297
- }, l = ne(i);
302
+ children: (s == null ? void 0 : s.children) ?? 0,
303
+ infants: (s == null ? void 0 : s.infants) ?? 0
304
+ }, m = ne(t);
298
305
  return {
299
- passengerCount: i.adults + i.children,
300
- passengerList: l
306
+ passengerCount: t.adults + t.children + t.infants,
307
+ passengerList: m
301
308
  };
302
309
  };
303
310
  export {
304
- x as DEFAULT_AIRLINE_PROGRAM,
311
+ B as DEFAULT_AIRLINE_PROGRAM,
305
312
  be as buildFlightSearchQuery,
306
313
  ne as buildPassengerArray,
307
314
  Fe as formatCabinClass,
@@ -315,5 +322,5 @@ export {
315
322
  Ae as groupFlightResults,
316
323
  ye as mapDataToFlightDetails,
317
324
  we as passengerValues,
318
- H as removeLeadingZeros
325
+ q as removeLeadingZeros
319
326
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@odynn/awayz-flights",
3
- "version": "0.10.17",
3
+ "version": "0.10.20",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist"
@@ -1,5 +0,0 @@
1
- var T = /* @__PURE__ */ ((_) => (_.TOKEN = "token", _.REFRESH_TOKEN = "refreshToken", _.CLIENT_ID = "clientId", _.AUTH_FLOW = "authFlow", _.OVERRIDE_TOKEN_EXCHANGE_ENDPOINT = "overrideExchangeTokenEndpoint", _))(T || {}), d = /* @__PURE__ */ ((_) => (_.ISO = "dates:iso", _.DISPLAY_SHORT = "dates:displayShort", _.DISPLAY_MEDIUM = "dates:displayMedium", _.DISPLAY_LONG = "dates:displayLong", _.DISPLAY_FULL = "dates:displayFull", _.DISPLAY_SHORT_WITH_YEAR = "dates:displayShortWithYear", _.DISPLAY_MEDIUM_WITH_YEAR = "dates:displayMediumWithYear", _.DISPLAY_LONG_WITH_YEAR = "dates:displayLongWithYear", _.DISPLAY_FULL_WITH_YEAR = "dates:displayFullWithYear", _.DATE_TIME_SHORT = "dates:dateTimeShort", _.DATE_TIME_MEDIUM = "dates:dateTimeMedium", _.DATE_TIME_LONG = "dates:dateTimeLong", _.DATE_TIME_FULL = "dates:dateTimeFull", _.DATE_TIME_SHORT_WITH_YEAR = "dates:dateTimeShortWithYear", _.DATE_TIME_MEDIUM_WITH_YEAR = "dates:dateTimeMediumWithYear", _.DATE_TIME_LONG_WITH_YEAR = "dates:dateTimeLongWithYear", _.DATE_TIME_FULL_WITH_YEAR = "dates:dateTimeFullWithYear", _.TIME_ONLY = "dates:timeOnly", _.TIME_WITH_SECONDS = "dates:timeWithSeconds", _))(d || {});
2
- export {
3
- d as E,
4
- T as a
5
- };