@odynn/awayz-flights 0.10.17 → 0.10.19

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
+ };
@@ -35,12 +35,13 @@ export declare const getOperatedBy: (segment: ISegment) => string;
35
35
  * @param {EFlightPaymentType} params.paymentType - The type of payment (e.g., cash, points).
36
36
  * @returns {string} The constructed flight search query URL.
37
37
  */
38
- export declare const buildFlightSearchQuery: ({ originCode, destinationCode, dates, cabinClass, passengerCount, paymentType }: {
38
+ export declare const buildFlightSearchQuery: ({ originCode, destinationCode, dates, cabinClass, adults, children, paymentType }: {
39
39
  originCode: string;
40
40
  destinationCode: string;
41
41
  dates: string[];
42
42
  cabinClass: ECabinClass;
43
- passengerCount: number;
43
+ adults: number;
44
+ children: number;
44
45
  paymentType: string[];
45
46
  }) => string;
46
47
  /**
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";
@@ -9,7 +9,7 @@ import { mapBaggageType as W } from "../hooks/useFlightSearch/useFlightSearch.ty
9
9
  import { WalletService as f } 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;
12
+ var l, n, c, a, t, p, d, r, o, u, 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
13
  const i = ae(e);
14
14
  return {
15
15
  id: e.id,
@@ -17,10 +17,10 @@ const X = "https://assets.duffel.com/img/airlines/for-light-background/full-colo
17
17
  partial: e == null ? void 0 : e.partial,
18
18
  origin: {
19
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) || "",
20
+ country: ((a = e.slices[0].segments[0].origin) == null ? void 0 : a.iataCountryCode) || ((p = (t = e.slices[0].segments[0].origin) == null ? void 0 : t.city) == null ? void 0 : p.iataCountryCode) || "",
21
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: ((m = (p = e.slices[0].segments[0].origin) == null ? void 0 : p.city) == null ? void 0 : m.latitude) || 0,
23
+ latitude: ((m = (u = e.slices[0].segments[0].origin) == null ? void 0 : u.city) == null ? void 0 : m.latitude) || 0,
24
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
  },
@@ -29,7 +29,7 @@ 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
  },
@@ -79,30 +79,31 @@ const X = "https://assets.duffel.com/img/airlines/for-light-background/full-colo
79
79
  destinationCode: e,
80
80
  dates: i,
81
81
  cabinClass: l,
82
- passengerCount: n,
83
- paymentType: c
82
+ adults: n,
83
+ children: c,
84
+ paymentType: a
84
85
  }) => {
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;
86
+ let t = `${V.CASH_POINTS_FLIGHT_SEARCH}?`;
87
+ return t += `origin=${s}`, t += `&destination=${e}`, t += `&departure_dates=[${i.map((p) => `"${p}"`).join(",")}]`, t += `&cabin_class=${l}`, t += `&adults=${n}`, t += `&children=${c}`, t += `&cash_or_points=[${a}]`, t;
87
88
  }, te = (s) => s.flightDetails.slices[0].segments.map((i) => ie(i)).join("_") + "_" + y(s.departureTime).format("YYYYMMDD"), ie = (s) => {
88
89
  const e = s.operatingCarrier ?? s.marketingCarrier, i = s.operatingCarrierFlightNumber ?? s.marketingCarrierFlightNumber;
89
90
  return e.iataCode + " " + H(i);
90
91
  }, Fe = (s) => s ? s.replace(/[_-]/g, " ").split(" ").map((e) => e.charAt(0).toUpperCase() + e.slice(1).toLowerCase()).join(" ") : "", Ae = (s) => {
91
92
  const e = {};
92
93
  s.forEach((a) => {
93
- var u, d;
94
+ var p, d;
94
95
  const t = te(a);
95
96
  if (e[t]) {
96
97
  const r = K(a);
97
98
  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 = {
99
+ const { lowestCash: o, currency: u, lowestPoints: m, cashFee: C, cacheData: g } = j(e[t].flight.paymentOptions);
100
+ e[t].flight.points = m, e[t].flight.cashFee = C, e[t].flight.cash = o, u && (e[t].flight.currency = u), e[t].flight.isCached = g.isCached, e[t].flight.lastCachedTime = g.lastCachedTime, g.isCached && !e[t].flight.flightDetails.isCached && (e[t].flight.flightDetails = {
100
101
  ...e[t].flight.flightDetails,
101
102
  isCached: g.isCached,
102
103
  lastCachedTime: g.lastCachedTime
103
104
  });
104
105
  } else {
105
- const { origin: r, destination: o } = a, p = [K(a)], m = j(p);
106
+ const { origin: r, destination: o } = a, u = [K(a)], m = j(u);
106
107
  e[t] = {
107
108
  programs: [],
108
109
  flight: {
@@ -124,7 +125,7 @@ const X = "https://assets.duffel.com/img/airlines/for-light-background/full-colo
124
125
  airlineLogo: a.airlineLogo,
125
126
  displayAirlineIataCode: a.displayAirlineIataCode,
126
127
  flightNumber: a.flightNumber,
127
- paymentOptions: p,
128
+ paymentOptions: u,
128
129
  numberOfStops: a.numberOfStops,
129
130
  departureTime: a.departureTime,
130
131
  arrivalTime: a.arrivalTime,
@@ -136,7 +137,7 @@ const X = "https://assets.duffel.com/img/airlines/for-light-background/full-colo
136
137
  a.flightDetails.slices[0].segments[0].departingAt
137
138
  ),
138
139
  arrivalTime: y(
139
- (u = a.flightDetails.slices[0].segments.getLast()) == null ? void 0 : u.arrivingAt
140
+ (p = a.flightDetails.slices[0].segments.getLast()) == null ? void 0 : p.arrivingAt
140
141
  ),
141
142
  originTimeZone: a.flightDetails.slices[0].segments[0].origin.timeZone,
142
143
  destinationTimeZone: (d = a.flightDetails.slices[0].segments.getLast()) == null ? void 0 : d.destination.timeZone,
@@ -162,14 +163,14 @@ const X = "https://assets.duffel.com/img/airlines/for-light-background/full-colo
162
163
  const t = a.flight.paymentOptions.filter((r) => r.cash > 0).reduce(
163
164
  (r, o) => o.cash < r.cash ? o : r,
164
165
  { cash: 1 / 0, carrier: { name: "", iataCode: "" } }
165
- ), u = {
166
+ ), p = {
166
167
  iataCode: a.flight.displayAirlineIataCode,
167
168
  name: a.flight.airline
168
- }, d = t.cash !== 1 / 0 ? t.carrier : u;
169
+ }, d = t.cash !== 1 / 0 ? t.carrier : p;
169
170
  a.programs.length > 0 ? a.programs.forEach((r) => {
170
171
  const o = a.flight.paymentOptions.filter(
171
172
  (m) => m.program === r && m.points > 0
172
- ), p = o.length > 0 ? Math.min(...o.map((m) => m.points)) : -1;
173
+ ), u = o.length > 0 ? Math.min(...o.map((m) => m.points)) : -1;
173
174
  i.push({
174
175
  ...a.flight,
175
176
  airline: d.name,
@@ -177,7 +178,7 @@ const X = "https://assets.duffel.com/img/airlines/for-light-background/full-colo
177
178
  displayAirlineIataCode: d.iataCode,
178
179
  airlineProgram: r,
179
180
  cash: t.cash !== 1 / 0 ? t.cash : -1,
180
- points: p
181
+ points: u
181
182
  });
182
183
  }) : i.push({
183
184
  ...a.flight,
@@ -193,7 +194,7 @@ const X = "https://assets.duffel.com/img/airlines/for-light-background/full-colo
193
194
  ), c = [...n];
194
195
  return l.forEach((a) => {
195
196
  (!c.find(
196
- (u) => u.awayzGroupId === a.awayzGroupId
197
+ (p) => p.awayzGroupId === a.awayzGroupId
197
198
  ) || n.length === 0) && c.push(a);
198
199
  }), c;
199
200
  }, 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 = {
@@ -228,8 +229,8 @@ const X = "https://assets.duffel.com/img/airlines/for-light-background/full-colo
228
229
  id: s
229
230
  }), i;
230
231
  }, 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(
232
+ var n, c, a, t, p, d, r, o, u, m;
233
+ 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 = (p = (t = s.flightDetails.slices.getFirst()) == null ? void 0 : t.segments.getFirst()) == null ? void 0 : p.passengers.getFirst()) == null ? void 0 : d.cabinClassMarketingName) ?? ((u = (o = (r = s.flightDetails.slices.getFirst()) == null ? void 0 : r.segments.getFirst()) == null ? void 0 : o.passengers.getFirst()) == null ? void 0 : u.cabinClass), l = e.map(
233
234
  (C) => ({
234
235
  type: W(C.type),
235
236
  quantity: C.quantity
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.19",
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
- };