@odynn/awayz-flights 0.10.15 → 0.10.17

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.
@@ -129,6 +129,8 @@ export interface IFlightPaymentOption {
129
129
  };
130
130
  cabinClass?: string;
131
131
  slices?: ISlice[];
132
+ isCached?: boolean;
133
+ lastCachedTime?: string;
132
134
  }
133
135
  export interface IFlightResult {
134
136
  id: string;
@@ -158,6 +160,8 @@ export interface IFlightResult {
158
160
  cabinClass: string;
159
161
  expiresAt: string;
160
162
  transferPartners: string[];
163
+ isCached: boolean;
164
+ lastCachedTime: string;
161
165
  }
162
166
  export interface IAirportLocation {
163
167
  city: string;
@@ -203,6 +207,8 @@ export interface IFlightOffer {
203
207
  };
204
208
  googleUrl: string;
205
209
  partners: string[];
210
+ isCached: boolean;
211
+ lastCachedTime: string;
206
212
  }
207
213
  export interface IPaymentRequirements {
208
214
  requiresInstantPayment: boolean;
@@ -6,27 +6,27 @@ import "react";
6
6
  import { h as y } from "../moment-BGjjqtLQ.js";
7
7
  import { EFlightEndpoint as V } from "../constants/endpoints.js";
8
8
  import { mapBaggageType as W } from "../hooks/useFlightSearch/useFlightSearch.types.js";
9
- import { WalletService as J } from "../services/wallet/WalletService.js";
10
- import { ERewardProgramCategories as X } from "../services/wallet/WalletService.types.js";
11
- const f = "https://assets.duffel.com/img/airlines/for-light-background/full-color-lockup/", Ce = (s) => s == null ? void 0 : s.map((e) => {
12
- var m, o, c, t, i, p, l, n, r, u, d, g, b, F, A, L, w, h, D, P, I, k, T, O, R, _, v, E, M, N, $, z, G, Z, S, U;
13
- const a = te(e);
9
+ import { WalletService as f } from "../services/wallet/WalletService.js";
10
+ import { ERewardProgramCategories as J } from "../services/wallet/WalletService.types.js";
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);
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: ((m = e.slices[0].segments[0].origin) == null ? void 0 : m.cityName) || ((c = (o = e.slices[0].segments[0].origin) == null ? void 0 : o.city) == null ? void 0 : c.name) || "",
20
- country: ((t = e.slices[0].segments[0].origin) == null ? void 0 : t.iataCountryCode) || ((p = (i = e.slices[0].segments[0].origin) == null ? void 0 : i.city) == null ? void 0 : p.iataCountryCode) || "",
21
- airportCode: ((l = e.slices[0].segments[0].origin) == null ? void 0 : l.iataCode) || ((r = (n = e.slices[0].segments[0].origin) == null ? void 0 : n.city) == null ? void 0 : r.iataCode) || "",
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) || "",
22
22
  coordinates: {
23
- latitude: ((d = (u = e.slices[0].segments[0].origin) == null ? void 0 : u.city) == null ? void 0 : d.latitude) || 0,
24
- longitude: ((b = (g = e.slices[0].segments[0].origin) == null ? void 0 : g.city) == null ? void 0 : b.longitude) || 0
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
25
25
  }
26
26
  },
27
27
  destination: {
28
- city: ((A = (F = e.slices[0].segments.getLast()) == null ? void 0 : F.destination) == null ? void 0 : A.cityName) || ((h = (w = (L = e.slices[0].segments.getLast()) == null ? void 0 : L.destination) == null ? void 0 : w.city) == null ? void 0 : h.name) || "",
29
- country: ((P = (D = e.slices[0].segments.getLast()) == null ? void 0 : D.destination) == null ? void 0 : P.iataCountryCode) || ((T = (k = (I = e.slices[0].segments.getLast()) == null ? void 0 : I.destination) == null ? void 0 : k.city) == null ? void 0 : T.iataCountryCode) || "",
28
+ city: ((F = (b = e.slices[0].segments.getLast()) == null ? void 0 : b.destination) == null ? void 0 : F.cityName) || ((T = (L = (A = e.slices[0].segments.getLast()) == null ? void 0 : A.destination) == null ? void 0 : L.city) == null ? void 0 : T.name) || "",
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
32
  latitude: (($ = (N = (M = e.slices[0].segments.getLast()) == null ? void 0 : M.destination) == null ? void 0 : N.city) == null ? void 0 : $.latitude) || 0,
@@ -34,9 +34,9 @@ const f = "https://assets.duffel.com/img/airlines/for-light-background/full-colo
34
34
  }
35
35
  },
36
36
  // `airline` is an existing unqualified field; semantics are display-primary carrier.
37
- airline: (a == null ? void 0 : a.name) ?? "",
38
- airlineLogo: C((a == null ? void 0 : a.iataCode) ?? ""),
39
- displayAirlineIataCode: (a == null ? void 0 : a.iataCode) ?? "",
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) ?? "",
40
40
  cash: e.totalAmount ? parseFloat(e.totalAmount) : 0,
41
41
  currency: e.baseCurrency,
42
42
  flightNumber: ee(e.slices[0].segments[0]),
@@ -60,135 +60,143 @@ const f = "https://assets.duffel.com/img/airlines/for-light-background/full-colo
60
60
  cashFee: e.cashFee,
61
61
  cabinClass: e.slices[0].segments[0].passengers[0].cabinClass || e.slices[0].segments[0].passengers[0].cabin.name || e.slices[0].segments[0].passengers[0].cabinClassMarketingName || e.slices[0].segments[0].passengers[0].cabin.marketingName,
62
62
  expiresAt: e.expiresAt,
63
- transferPartners: e.partners
63
+ transferPartners: e.partners,
64
+ isCached: e.isCached,
65
+ lastCachedTime: e.lastCachedTime
64
66
  };
65
67
  }), ee = (s) => {
66
- const e = s.marketingCarrier ?? s.operatingCarrier, a = s.marketingCarrierFlightNumber ?? s.operatingCarrierFlightNumber;
67
- return e.iataCode + " " + H(a);
68
+ const e = s.marketingCarrier ?? s.operatingCarrier, i = s.marketingCarrierFlightNumber ?? s.operatingCarrierFlightNumber;
69
+ return e.iataCode + " " + H(i);
68
70
  }, se = (s) => {
69
- var a;
70
- const e = (a = s == null ? void 0 : s.segments) == null ? void 0 : a[0];
71
+ var i;
72
+ const e = (i = s == null ? void 0 : s.segments) == null ? void 0 : i[0];
71
73
  return (e == null ? void 0 : e.marketingCarrier) ?? (e == null ? void 0 : e.operatingCarrier);
72
- }, te = (s) => {
74
+ }, ae = (s) => {
73
75
  var e;
74
76
  return se((e = s == null ? void 0 : s.slices) == null ? void 0 : e[0]);
75
- }, be = (s) => !s.operatingCarrier || !s.marketingCarrier ? "" : s.operatingCarrier.iataCode !== s.marketingCarrier.iataCode ? s.operatingCarrier.name : "", Fe = ({
77
+ }, he = (s) => !s.operatingCarrier || !s.marketingCarrier ? "" : s.operatingCarrier.iataCode !== s.marketingCarrier.iataCode ? s.operatingCarrier.name : "", be = ({
76
78
  originCode: s,
77
79
  destinationCode: e,
78
- dates: a,
79
- cabinClass: m,
80
- passengerCount: o,
80
+ dates: i,
81
+ cabinClass: l,
82
+ passengerCount: n,
81
83
  paymentType: c
82
84
  }) => {
83
- let t = `${V.CASH_POINTS_FLIGHT_SEARCH}?`;
84
- return t += `origin=${s}`, t += `&destination=${e}`, t += `&departure_dates=[${a.map((i) => `"${i}"`).join(",")}]`, t += `&cabin_class=${m}`, t += `&adults=${o}`, t += `&cash_or_points=[${c}]`, t;
85
- }, ae = (s) => s.flightDetails.slices[0].segments.map((a) => ie(a)).join("_") + "_" + y(s.departureTime).format("YYYYMMDD"), ie = (s) => {
86
- const e = s.operatingCarrier ?? s.marketingCarrier, a = s.operatingCarrierFlightNumber ?? s.marketingCarrierFlightNumber;
87
- return e.iataCode + " " + H(a);
88
- }, Ae = (s) => s ? s.replace(/[_-]/g, " ").split(" ").map((e) => e.charAt(0).toUpperCase() + e.slice(1).toLowerCase()).join(" ") : "", Le = (s) => {
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);
90
+ }, Fe = (s) => s ? s.replace(/[_-]/g, " ").split(" ").map((e) => e.charAt(0).toUpperCase() + e.slice(1).toLowerCase()).join(" ") : "", Ae = (s) => {
89
91
  const e = {};
90
- s.forEach((t) => {
91
- var p, l;
92
- const i = ae(t);
93
- if (e[i]) {
94
- const n = K(t);
95
- e[i].flight.paymentOptions.push(n);
96
- const { lowestCash: r, currency: u, lowestPoints: d, cashFee: g } = j(e[i].flight.paymentOptions);
97
- e[i].flight.points = d, e[i].flight.cashFee = g, e[i].flight.cash = r, u && (e[i].flight.currency = u);
92
+ 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
103
+ });
98
104
  } else {
99
- const { origin: n, destination: r } = t, u = [K(t)], d = j(u);
100
- e[i] = {
105
+ const { origin: r, destination: o } = a, p = [K(a)], m = j(p);
106
+ e[t] = {
101
107
  programs: [],
102
108
  flight: {
103
- id: t.awayzGroupId,
104
- partial: t.partial,
109
+ id: a.awayzGroupId,
110
+ partial: a.partial,
105
111
  origin: {
106
- city: n.city,
107
- country: n.country,
108
- airportCode: n.airportCode,
109
- coordinates: n.coordinates
110
- },
111
- destination: {
112
112
  city: r.city,
113
113
  country: r.country,
114
114
  airportCode: r.airportCode,
115
115
  coordinates: r.coordinates
116
116
  },
117
- airline: t.airline,
118
- airlineLogo: t.airlineLogo,
119
- displayAirlineIataCode: t.displayAirlineIataCode,
120
- flightNumber: t.flightNumber,
121
- paymentOptions: u,
122
- numberOfStops: t.numberOfStops,
123
- departureTime: t.departureTime,
124
- arrivalTime: t.arrivalTime,
125
- awayzGroupId: i,
126
- duration: t.duration,
127
- airlineProgram: t.airlineProgram,
117
+ destination: {
118
+ city: o.city,
119
+ country: o.country,
120
+ airportCode: o.airportCode,
121
+ coordinates: o.coordinates
122
+ },
123
+ airline: a.airline,
124
+ airlineLogo: a.airlineLogo,
125
+ displayAirlineIataCode: a.displayAirlineIataCode,
126
+ flightNumber: a.flightNumber,
127
+ paymentOptions: p,
128
+ numberOfStops: a.numberOfStops,
129
+ departureTime: a.departureTime,
130
+ arrivalTime: a.arrivalTime,
131
+ awayzGroupId: t,
132
+ duration: a.duration,
133
+ airlineProgram: a.airlineProgram,
128
134
  durationMinutes: q({
129
135
  departureTime: y(
130
- t.flightDetails.slices[0].segments[0].departingAt
136
+ a.flightDetails.slices[0].segments[0].departingAt
131
137
  ),
132
138
  arrivalTime: y(
133
- (p = t.flightDetails.slices[0].segments.getLast()) == null ? void 0 : p.arrivingAt
139
+ (u = a.flightDetails.slices[0].segments.getLast()) == null ? void 0 : u.arrivingAt
134
140
  ),
135
- originTimeZone: t.flightDetails.slices[0].segments[0].origin.timeZone,
136
- destinationTimeZone: (l = t.flightDetails.slices[0].segments.getLast()) == null ? void 0 : l.destination.timeZone,
137
- duration: t.flightDetails.slices[0].duration
141
+ originTimeZone: a.flightDetails.slices[0].segments[0].origin.timeZone,
142
+ destinationTimeZone: (d = a.flightDetails.slices[0].segments.getLast()) == null ? void 0 : d.destination.timeZone,
143
+ duration: a.flightDetails.slices[0].duration
138
144
  }),
139
- cash: d.lowestCash,
140
- points: d.lowestPoints,
141
- flightDetails: t.flightDetails,
142
- currency: t.flightDetails.baseCurrency,
143
- cashFee: t.cashFee,
144
- cabinClass: t.flightDetails.slices[0].segments[0].passengers[0].cabinClass || t.flightDetails.slices[0].segments[0].passengers[0].cabin.name || t.flightDetails.slices[0].segments[0].passengers[0].cabinClassMarketingName || t.flightDetails.slices[0].segments[0].passengers[0].cabin.marketingName,
145
- expiresAt: t.expiresAt,
146
- transferPartners: t.transferPartners || []
145
+ cash: m.lowestCash,
146
+ points: m.lowestPoints,
147
+ flightDetails: a.flightDetails,
148
+ currency: a.flightDetails.baseCurrency,
149
+ cashFee: a.cashFee,
150
+ cabinClass: a.flightDetails.slices[0].segments[0].passengers[0].cabinClass || a.flightDetails.slices[0].segments[0].passengers[0].cabin.name || a.flightDetails.slices[0].segments[0].passengers[0].cabinClassMarketingName || a.flightDetails.slices[0].segments[0].passengers[0].cabin.marketingName,
151
+ expiresAt: a.expiresAt,
152
+ transferPartners: a.transferPartners || [],
153
+ isCached: a.isCached,
154
+ lastCachedTime: a.lastCachedTime
147
155
  }
148
156
  };
149
157
  }
150
- t.airlineProgram && !e[i].programs.includes(t.airlineProgram) && e[i].programs.push(t.airlineProgram);
158
+ a.airlineProgram && !e[t].programs.includes(a.airlineProgram) && e[t].programs.push(a.airlineProgram);
151
159
  });
152
- const a = [];
153
- Object.values(e).forEach((t) => {
154
- const i = t.flight.paymentOptions.filter((n) => n.cash > 0).reduce(
155
- (n, r) => r.cash < n.cash ? r : n,
160
+ const i = [];
161
+ 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,
156
164
  { cash: 1 / 0, carrier: { name: "", iataCode: "" } }
157
- ), p = {
158
- iataCode: t.flight.displayAirlineIataCode,
159
- name: t.flight.airline
160
- }, l = i.cash !== 1 / 0 ? i.carrier : p;
161
- t.programs.length > 0 ? t.programs.forEach((n) => {
162
- const r = t.flight.paymentOptions.filter(
163
- (d) => d.program === n && d.points > 0
164
- ), u = r.length > 0 ? Math.min(...r.map((d) => d.points)) : -1;
165
- a.push({
166
- ...t.flight,
167
- airline: l.name,
168
- airlineLogo: C(l.iataCode),
169
- displayAirlineIataCode: l.iataCode,
170
- airlineProgram: n,
171
- cash: i.cash !== 1 / 0 ? i.cash : -1,
172
- points: u
165
+ ), u = {
166
+ iataCode: a.flight.displayAirlineIataCode,
167
+ 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({
174
+ ...a.flight,
175
+ airline: d.name,
176
+ airlineLogo: h(d.iataCode),
177
+ displayAirlineIataCode: d.iataCode,
178
+ airlineProgram: r,
179
+ cash: t.cash !== 1 / 0 ? t.cash : -1,
180
+ points: p
173
181
  });
174
- }) : a.push({
175
- ...t.flight,
176
- airline: l.name,
177
- airlineLogo: C(l.iataCode),
178
- displayAirlineIataCode: l.iataCode,
179
- cash: i.cash !== 1 / 0 ? i.cash : -1
182
+ }) : i.push({
183
+ ...a.flight,
184
+ airline: d.name,
185
+ airlineLogo: h(d.iataCode),
186
+ displayAirlineIataCode: d.iataCode,
187
+ cash: t.cash !== 1 / 0 ? t.cash : -1
180
188
  });
181
189
  });
182
- const { cashlessResults: m, otherResults: o } = a.reduce(
183
- (t, i) => (i.cash <= 0 && i.points > 0 ? t.cashlessResults.push(i) : i.cash > 0 && t.otherResults.push(i), t),
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),
184
192
  { cashlessResults: [], otherResults: [] }
185
- ), c = [...o];
186
- return m.forEach((t) => {
193
+ ), c = [...n];
194
+ return l.forEach((a) => {
187
195
  (!c.find(
188
- (p) => p.awayzGroupId === t.awayzGroupId
189
- ) || o.length === 0) && c.push(t);
196
+ (u) => u.awayzGroupId === a.awayzGroupId
197
+ ) || n.length === 0) && c.push(a);
190
198
  }), c;
191
- }, H = (s) => s ? s.replace(/^0+/, "") : "", we = (s) => `https://assets.duffel.com/img/airlines/for-light-background/full-color-logo/${s}.svg`, C = (s) => `${f}${s}.svg`, B = Y.logoFallbackImageUrl, x = {
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 = {
192
200
  categoryLogo: B,
193
201
  programLogo: B,
194
202
  awayzActive: [],
@@ -196,35 +204,35 @@ const f = "https://assets.duffel.com/img/airlines/for-light-background/full-colo
196
204
  displayProgram: "Unknown",
197
205
  id: "Unknown",
198
206
  totalAccumulatedPoints: 0,
199
- category: X.Airline,
207
+ category: J.Airline,
200
208
  colour: "#fff",
201
209
  // Using App Foreground Colour
202
210
  url: "https://www.odynn.com"
203
- }, he = async (s) => {
211
+ }, Te = async (s) => {
204
212
  const { airlines: e } = await Q.ensureQueryData({
205
213
  queryKey: ["walletAwards"],
206
- queryFn: J.getAwards,
214
+ queryFn: f.getAwards,
207
215
  staleTime: 864e5
208
216
  // 24 hours
209
217
  });
210
- let a = e.find(
211
- (m) => {
212
- var o, c, t, i;
213
- return ((c = (o = m.mainProgram) == null ? void 0 : o.toLowerCase()) == null ? void 0 : c.includes(s == null ? void 0 : s.toLowerCase())) || ((i = (t = m.displayProgram) == null ? void 0 : t.toLowerCase()) == null ? void 0 : i.includes(s == null ? void 0 : s.toLowerCase()));
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()));
214
222
  }
215
223
  ) ?? x;
216
- return a || (a = {
224
+ return i || (i = {
217
225
  ...x,
218
226
  mainProgram: s,
219
227
  displayProgram: s,
220
228
  id: s
221
- }), a;
229
+ }), i;
222
230
  }, K = (s) => {
223
- var o, c, t, i, p, l, n, r, u, d;
224
- const e = ((t = (c = (o = s.flightDetails.slices.getFirst()) == null ? void 0 : o.segments.getFirst()) == null ? void 0 : c.passengers.getFirst()) == null ? void 0 : t.baggages) ?? [], a = ((l = (p = (i = s.flightDetails.slices.getFirst()) == null ? void 0 : i.segments.getFirst()) == null ? void 0 : p.passengers.getFirst()) == null ? void 0 : l.cabinClassMarketingName) ?? ((u = (r = (n = s.flightDetails.slices.getFirst()) == null ? void 0 : n.segments.getFirst()) == null ? void 0 : r.passengers.getFirst()) == null ? void 0 : u.cabinClass), m = e.map(
225
- (g) => ({
226
- type: W(g.type),
227
- quantity: g.quantity
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
228
236
  })
229
237
  );
230
238
  return {
@@ -233,39 +241,45 @@ const f = "https://assets.duffel.com/img/airlines/for-light-background/full-colo
233
241
  points: s.points,
234
242
  program: s.airlineProgram,
235
243
  baseCurrency: s.flightDetails.baseCurrency,
236
- fareBrandName: ((d = s.flightDetails.slices.getFirst()) == null ? void 0 : d.fareBrandName) ?? "",
237
- cabinClass: a,
244
+ fareBrandName: ((m = s.flightDetails.slices.getFirst()) == null ? void 0 : m.fareBrandName) ?? "",
245
+ cabinClass: i,
238
246
  cashFee: s.cashFee,
239
247
  conditions: s.flightDetails.conditions,
240
- baggages: m,
248
+ baggages: l,
241
249
  // `carrier` is an existing unqualified field; semantics are marketing carrier.
242
250
  carrier: {
243
251
  iataCode: s.displayAirlineIataCode,
244
252
  name: s.airline
245
- }
253
+ },
254
+ isCached: s.isCached,
255
+ lastCachedTime: s.lastCachedTime
246
256
  };
247
257
  }, j = (s) => {
248
- const e = s.filter((t) => t.cash > 0);
249
- let a = { cash: 1 / 0, baseCurrency: "" };
250
- for (const t of e)
251
- t.cash < a.cash && (a = t);
252
- const o = [...s].filter(
253
- (t) => t.points > 0
254
- ).reduce(
255
- (t, i) => i.points < t.points ? i : t,
256
- {
257
- points: 1 / 0,
258
- cashFee: {
259
- amount: 0,
260
- currency: ""
261
- }
262
- }
263
- ), c = a.cash;
258
+ const e = s.filter((a) => a.cash > 0);
259
+ let i = { cash: 1 / 0, baseCurrency: "" };
260
+ for (const a of e)
261
+ a.cash < i.cash && (i = a);
262
+ const l = [...s].filter(
263
+ (a) => a.points > 0
264
+ );
265
+ let n = {
266
+ points: 1 / 0,
267
+ cashFee: { amount: 0, currency: "" },
268
+ isCached: !1,
269
+ lastCachedTime: ""
270
+ };
271
+ for (const a of l)
272
+ a.points < n.points && (n = a);
273
+ const c = i.cash;
264
274
  return {
265
275
  lowestCash: c === 1 / 0 ? -1 : c,
266
- lowestPoints: o.points === 1 / 0 ? -1 : o.points,
267
- cashFee: o.cashFee,
268
- currency: a.baseCurrency === "" ? null : a.baseCurrency
276
+ lowestPoints: n.points === 1 / 0 ? -1 : n.points,
277
+ cashFee: n.cashFee,
278
+ currency: i.baseCurrency === "" ? null : i.baseCurrency,
279
+ cacheData: {
280
+ isCached: n.isCached ?? !1,
281
+ lastCachedTime: n.lastCachedTime ?? ""
282
+ }
269
283
  };
270
284
  }, ne = (s) => [
271
285
  ...Array.from({ length: s.adults }, () => ({
@@ -276,30 +290,30 @@ const f = "https://assets.duffel.com/img/airlines/for-light-background/full-colo
276
290
  type: "child"
277
291
  /* CHILD */
278
292
  }))
279
- ], De = (s) => {
280
- const a = {
293
+ ], we = (s) => {
294
+ const i = {
281
295
  adults: (s == null ? void 0 : s.adults) ?? 1,
282
296
  children: (s == null ? void 0 : s.children) ?? 0
283
- }, m = ne(a);
297
+ }, l = ne(i);
284
298
  return {
285
- passengerCount: a.adults + a.children,
286
- passengerList: m
299
+ passengerCount: i.adults + i.children,
300
+ passengerList: l
287
301
  };
288
302
  };
289
303
  export {
290
304
  x as DEFAULT_AIRLINE_PROGRAM,
291
- Fe as buildFlightSearchQuery,
305
+ be as buildFlightSearchQuery,
292
306
  ne as buildPassengerArray,
293
- Ae as formatCabinClass,
294
- he as getAirlineProgram,
307
+ Fe as formatCabinClass,
308
+ Te as getAirlineProgram,
295
309
  ee as getFlightNumber,
296
- C as getFullLogoPath,
297
- we as getLogoPath,
298
- be as getOperatedBy,
299
- te as getPrimaryDisplayCarrierForFlightOffer,
310
+ h as getFullLogoPath,
311
+ Le as getLogoPath,
312
+ he as getOperatedBy,
313
+ ae as getPrimaryDisplayCarrierForFlightOffer,
300
314
  se as getPrimaryDisplayCarrierForSlice,
301
- Le as groupFlightResults,
302
- Ce as mapDataToFlightDetails,
303
- De as passengerValues,
315
+ Ae as groupFlightResults,
316
+ ye as mapDataToFlightDetails,
317
+ we as passengerValues,
304
318
  H as removeLeadingZeros
305
319
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@odynn/awayz-flights",
3
- "version": "0.10.15",
3
+ "version": "0.10.17",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist"