@odynn/awayz-flights 0.2.4 → 0.2.6

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.
@@ -86,10 +86,7 @@ export interface IFlightPaymentOption {
86
86
  type: EBaggage | null;
87
87
  quantity: number;
88
88
  }[];
89
- conditions: {
90
- refundBeforeDeparture?: boolean;
91
- changeBeforeDeparture?: boolean;
92
- };
89
+ conditions: IOfferConditions;
93
90
  carrier: {
94
91
  iataCode: string;
95
92
  name: string;
@@ -4,8 +4,8 @@ import "react";
4
4
  import { awayzClient as q } from "@odynn/awayz-core";
5
5
  import { WalletService as Q } from "../services/wallet/WalletService.js";
6
6
  import { ERewardProgramCategories as V } from "../services/wallet/WalletService.types.js";
7
- const B = (s) => s == null ? void 0 : s.map((e) => {
8
- var r, t, a, n, i, o, m, h, g, M, P, N, A, L, w, d, p, c, y, C, b, l, u, D, k, O, z, f, v, _, $, Z, E, G;
7
+ const R = (s) => s == null ? void 0 : s.map((e) => {
8
+ var r, t, a, n, i, o, m, w, g, M, P, N, A, L, h, d, p, c, y, C, b, l, u, D, k, O, z, v, _, $, Z, f, E, G;
9
9
  return {
10
10
  id: e.id,
11
11
  points: (e == null ? void 0 : e.points) >= 0 ? e.points : -1,
@@ -13,19 +13,19 @@ const B = (s) => s == null ? void 0 : s.map((e) => {
13
13
  origin: {
14
14
  city: ((r = e.slices[0].segments[0].origin) == null ? void 0 : r.cityName) || ((a = (t = e.slices[0].segments[0].origin) == null ? void 0 : t.city) == null ? void 0 : a.name),
15
15
  country: ((n = e.slices[0].segments[0].origin) == null ? void 0 : n.iataCountryCode) || ((o = (i = e.slices[0].segments[0].origin) == null ? void 0 : i.city) == null ? void 0 : o.iataCountryCode),
16
- airportCode: ((m = e.slices[0].segments[0].origin) == null ? void 0 : m.iataCityCode) || ((g = (h = e.slices[0].segments[0].origin) == null ? void 0 : h.city) == null ? void 0 : g.iataCode),
16
+ airportCode: ((m = e.slices[0].segments[0].origin) == null ? void 0 : m.iataCityCode) || ((g = (w = e.slices[0].segments[0].origin) == null ? void 0 : w.city) == null ? void 0 : g.iataCode),
17
17
  coordinates: {
18
18
  latitude: (P = (M = e.slices[0].segments[0].origin) == null ? void 0 : M.city) == null ? void 0 : P.latitude,
19
19
  longitude: (A = (N = e.slices[0].segments[0].origin) == null ? void 0 : N.city) == null ? void 0 : A.longitude
20
20
  }
21
21
  },
22
22
  destination: {
23
- city: ((w = (L = e.slices[0].segments.getLast()) == null ? void 0 : L.destination) == null ? void 0 : w.cityName) || ((c = (p = (d = e.slices[0].segments.getLast()) == null ? void 0 : d.destination) == null ? void 0 : p.city) == null ? void 0 : c.name),
23
+ city: ((h = (L = e.slices[0].segments.getLast()) == null ? void 0 : L.destination) == null ? void 0 : h.cityName) || ((c = (p = (d = e.slices[0].segments.getLast()) == null ? void 0 : d.destination) == null ? void 0 : p.city) == null ? void 0 : c.name),
24
24
  country: ((C = (y = e.slices[0].segments.getLast()) == null ? void 0 : y.destination) == null ? void 0 : C.iataCountryCode) || ((u = (l = (b = e.slices[0].segments.getLast()) == null ? void 0 : b.destination) == null ? void 0 : l.city) == null ? void 0 : u.iataCountryCode),
25
- airportCode: ((k = (D = e.slices[0].segments.getLast()) == null ? void 0 : D.destination) == null ? void 0 : k.iataCityCode) || ((f = (z = (O = e.slices[0].segments.getLast()) == null ? void 0 : O.destination) == null ? void 0 : z.city) == null ? void 0 : f.iataCode),
25
+ airportCode: ((k = (D = e.slices[0].segments.getLast()) == null ? void 0 : D.destination) == null ? void 0 : k.iataCityCode) || ((v = (z = (O = e.slices[0].segments.getLast()) == null ? void 0 : O.destination) == null ? void 0 : z.city) == null ? void 0 : v.iataCode),
26
26
  coordinates: {
27
- latitude: ($ = (_ = (v = e.slices[0].segments.getLast()) == null ? void 0 : v.destination) == null ? void 0 : _.city) == null ? void 0 : $.latitude,
28
- longitude: (G = (E = (Z = e.slices[0].segments.getLast()) == null ? void 0 : Z.destination) == null ? void 0 : E.city) == null ? void 0 : G.longitude
27
+ latitude: (Z = ($ = (_ = e.slices[0].segments.getLast()) == null ? void 0 : _.destination) == null ? void 0 : $.city) == null ? void 0 : Z.latitude,
28
+ longitude: (G = (E = (f = e.slices[0].segments.getLast()) == null ? void 0 : f.destination) == null ? void 0 : E.city) == null ? void 0 : G.longitude
29
29
  }
30
30
  },
31
31
  airline: e.owner.name,
@@ -53,10 +53,10 @@ const B = (s) => s == null ? void 0 : s.map((e) => {
53
53
  };
54
54
  }), ee = (s, e) => {
55
55
  if (!(e != null && e.length))
56
- return B(s);
56
+ return R(s);
57
57
  const r = [...e], t = [], a = {};
58
58
  for (const i of s) {
59
- const o = i.slices[0].segments, m = o[0], h = {
59
+ const o = i.slices[0].segments, m = o[0], w = {
60
60
  iataCode: m.operatingCarrier.iataCode,
61
61
  flightNumber: T(
62
62
  m.operatingCarrierFlightNumber
@@ -66,9 +66,8 @@ const B = (s) => s == null ? void 0 : s.map((e) => {
66
66
  flightNumber: T(
67
67
  m.marketingCarrierFlightNumber
68
68
  )
69
- }, M = i.awayzMatchId, P = `${h.iataCode}_${g.iataCode}-${g.flightNumber}`, N = i.awayzMarketerMatchId, A = !!h.flightNumber && h.flightNumber != "", L = !!g.flightNumber && g.flightNumber != "", w = r.filter((d, p) => {
70
- const c = d.flightDetails, y = d.flightDetails.slices[0].segments[0].operatingCarrierFlightNumber, C = c.id && // TODO: Maybe expand on this - Id check ensures it is a duffel flight
71
- !!y && y !== "";
69
+ }, M = i.awayzMatchId, P = `${w.iataCode}_${g.iataCode}-${g.flightNumber}`, N = i.awayzMarketerMatchId, A = !!w.flightNumber && w.flightNumber != "", L = !!g.flightNumber && g.flightNumber != "", h = r.filter((d, p) => {
70
+ const c = d.flightDetails, y = d.flightDetails.slices[0].segments[0].operatingCarrierFlightNumber, C = c.id && !!y && y !== "";
72
71
  if (!(c.slices[0].segments.length === (o == null ? void 0 : o.length) && !c.slices[0].segments.find(
73
72
  (u, D) => u.departingAt !== o[D].departingAt || u.arrivingAt !== o[D].arrivingAt || u.duration !== o[D].duration
74
73
  )))
@@ -76,9 +75,9 @@ const B = (s) => s == null ? void 0 : s.map((e) => {
76
75
  let l = !1;
77
76
  return (L && A && c.awayzMatchId === M || !C && c.awayzMatchId === P || A && !L && c.awayzMarketerMatchId === N) && (l = !0), l && (a[c.id] = p), l;
78
77
  });
79
- if (w.length) {
80
- i.slices[0].comparisonKey = w[0].awayzGroupId;
81
- const d = w.find((p) => {
78
+ if (h.length) {
79
+ i.slices[0].comparisonKey = h[0].awayzGroupId;
80
+ const d = h.find((p) => {
82
81
  var C, b, l, u;
83
82
  const c = (C = p.flightDetails.slices[0].fareBrandName) == null ? void 0 : C.toLowerCase(), y = (b = i.slices[0].fareBrandName) == null ? void 0 : b.toLowerCase();
84
83
  return y === c || // Special Case for AC Only match on first word
@@ -106,7 +105,7 @@ const B = (s) => s == null ? void 0 : s.map((e) => {
106
105
  }
107
106
  return [
108
107
  ...r,
109
- ...B(t) ?? []
108
+ ...R(t) ?? []
110
109
  ];
111
110
  }, j = (s) => {
112
111
  const e = s.operatingCarrierFlightNumber ? s.operatingCarrier : s.marketingCarrier, r = s.operatingCarrierFlightNumber ?? s.marketingCarrierFlightNumber;
@@ -197,9 +196,9 @@ const B = (s) => s == null ? void 0 : s.map((e) => {
197
196
  });
198
197
  }) : r.push(t.flight);
199
198
  }), r;
200
- }, T = (s) => s ? s.replace(/^0+/, "") : "", ie = (s) => `https://assets.duffel.com/img/airlines/for-light-background/full-color-logo/${s}.svg`, R = "/img/logo/odynn-eye.svg", S = {
201
- categoryLogo: R,
202
- programLogo: R,
199
+ }, T = (s) => s ? s.replace(/^0+/, "") : "", ie = (s) => `https://assets.duffel.com/img/airlines/for-light-background/full-color-logo/${s}.svg`, S = "/img/logo/odynn-eye.svg", B = {
200
+ categoryLogo: S,
201
+ programLogo: S,
203
202
  awayzActive: [],
204
203
  mainProgram: "Unknown",
205
204
  displayProgram: "Unknown",
@@ -221,9 +220,9 @@ const B = (s) => s == null ? void 0 : s.map((e) => {
221
220
  var a, n, i, o;
222
221
  return ((n = (a = t.mainProgram) == null ? void 0 : a.toLowerCase()) == null ? void 0 : n.includes(s == null ? void 0 : s.toLowerCase())) || ((o = (i = t.displayProgram) == null ? void 0 : i.toLowerCase()) == null ? void 0 : o.includes(s == null ? void 0 : s.toLowerCase()));
223
222
  }
224
- ) ?? S;
223
+ ) ?? B;
225
224
  return r || (r = {
226
- ...S,
225
+ ...B,
227
226
  mainProgram: s,
228
227
  displayProgram: s,
229
228
  id: s
@@ -236,11 +235,7 @@ const B = (s) => s == null ? void 0 : s.map((e) => {
236
235
  baseCurrency: s.flightDetails.baseCurrency,
237
236
  fareBrandName: s.flightDetails.slices[0].fareBrandName,
238
237
  cashFee: s.cashFee,
239
- conditions: {
240
- //TODO: Add Refund and Change Conditions
241
- refundBeforeDeparture: !0,
242
- changeBeforeDeparture: !0
243
- },
238
+ conditions: s.flightDetails.conditions,
244
239
  carrier: {
245
240
  iataCode: s.flightDetails.slices[0].segments[0].marketingCarrier.iataCode,
246
241
  name: s.flightDetails.slices[0].segments[0].marketingCarrier.name
@@ -257,13 +252,13 @@ const B = (s) => s == null ? void 0 : s.map((e) => {
257
252
  };
258
253
  };
259
254
  export {
260
- S as DEFAULT_AIRLINE_PROGRAM,
255
+ B as DEFAULT_AIRLINE_PROGRAM,
261
256
  te as buildFlightSearchQuery,
262
257
  ae as getAirlineProgram,
263
258
  j as getFlightNumber,
264
259
  ie as getLogoPath,
265
260
  se as groupFlightResults,
266
- B as mapFlightDetailsToResults,
261
+ R as mapFlightDetailsToResults,
267
262
  ee as parseFlightDetails,
268
263
  T as removeLeadingZeros
269
264
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@odynn/awayz-flights",
3
- "version": "0.2.4",
3
+ "version": "0.2.6",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist"