@odynn/awayz-flights 0.2.4 → 0.2.5

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.
@@ -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 G = (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, f, z, v, _, $, Z, B, E;
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) || ((z = (f = (O = e.slices[0].segments.getLast()) == null ? void 0 : O.destination) == null ? void 0 : f.city) == null ? void 0 : z.iataCode),
26
26
  coordinates: {
27
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
28
+ longitude: (E = (B = (Z = e.slices[0].segments.getLast()) == null ? void 0 : Z.destination) == null ? void 0 : B.city) == null ? void 0 : E.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 G(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
+ ...G(t) ?? []
110
109
  ];
111
110
  }, j = (s) => {
112
111
  const e = s.operatingCarrierFlightNumber ? s.operatingCarrier : s.marketingCarrier, r = s.operatingCarrierFlightNumber ?? s.marketingCarrierFlightNumber;
@@ -228,24 +227,26 @@ const B = (s) => s == null ? void 0 : s.map((e) => {
228
227
  displayProgram: s,
229
228
  id: s
230
229
  }), r;
231
- }, U = (s) => ({
232
- id: s.id,
233
- cash: s.cash,
234
- points: s.points,
235
- program: s.airlineProgram,
236
- baseCurrency: s.flightDetails.baseCurrency,
237
- fareBrandName: s.flightDetails.slices[0].fareBrandName,
238
- cashFee: s.cashFee,
239
- conditions: {
240
- //TODO: Add Refund and Change Conditions
241
- refundBeforeDeparture: !0,
242
- changeBeforeDeparture: !0
243
- },
244
- carrier: {
245
- iataCode: s.flightDetails.slices[0].segments[0].marketingCarrier.iataCode,
246
- name: s.flightDetails.slices[0].segments[0].marketingCarrier.name
247
- }
248
- }), I = (s) => {
230
+ }, U = (s) => {
231
+ var e, r, t, a;
232
+ return {
233
+ id: s.id,
234
+ cash: s.cash,
235
+ points: s.points,
236
+ program: s.airlineProgram,
237
+ baseCurrency: s.flightDetails.baseCurrency,
238
+ fareBrandName: s.flightDetails.slices[0].fareBrandName,
239
+ cashFee: s.cashFee,
240
+ conditions: {
241
+ refundBeforeDeparture: (r = (e = s.flightDetails.conditions) == null ? void 0 : e.refundBeforeDeparture) == null ? void 0 : r.allowed,
242
+ changeBeforeDeparture: (a = (t = s.flightDetails.conditions) == null ? void 0 : t.changeBeforeDeparture) == null ? void 0 : a.allowed
243
+ },
244
+ carrier: {
245
+ iataCode: s.flightDetails.slices[0].segments[0].marketingCarrier.iataCode,
246
+ name: s.flightDetails.slices[0].segments[0].marketingCarrier.name
247
+ }
248
+ };
249
+ }, I = (s) => {
249
250
  const e = Math.min(
250
251
  ...s.filter((t) => t.cash > 0).map((t) => t.cash)
251
252
  ), r = Math.min(
@@ -263,7 +264,7 @@ export {
263
264
  j as getFlightNumber,
264
265
  ie as getLogoPath,
265
266
  se as groupFlightResults,
266
- B as mapFlightDetailsToResults,
267
+ G as mapFlightDetailsToResults,
267
268
  ee as parseFlightDetails,
268
269
  T as removeLeadingZeros
269
270
  };
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.5",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist"