@odynn/awayz-flights 0.1.17 → 0.1.18
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.
|
@@ -263,7 +263,9 @@ const U = 1, W = J.ECONOMY, z = new AbortController(), ue = 3 * 60 * 1e3, B = (o
|
|
|
263
263
|
paymentType: l
|
|
264
264
|
});
|
|
265
265
|
let i = [];
|
|
266
|
-
|
|
266
|
+
a.current = setTimeout(() => {
|
|
267
|
+
I();
|
|
268
|
+
}, ue), await ae(Z() + f, {
|
|
267
269
|
headers: {
|
|
268
270
|
"Content-Type": "application/json",
|
|
269
271
|
Authorization: o || "",
|
|
@@ -296,9 +298,7 @@ const U = 1, W = J.ECONOMY, z = new AbortController(), ue = 3 * 60 * 1e3, B = (o
|
|
|
296
298
|
console.log("EventSource closed"), u(!1);
|
|
297
299
|
},
|
|
298
300
|
keepalive: !1
|
|
299
|
-
})
|
|
300
|
-
I();
|
|
301
|
-
}, ue);
|
|
301
|
+
});
|
|
302
302
|
}, I = () => {
|
|
303
303
|
c && (z.abort(), a.current && (clearTimeout(a.current), a.current = null), u(!1));
|
|
304
304
|
};
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { h as
|
|
1
|
+
import { h as D } from "../arrayExtensions-DWKenJCh.js";
|
|
2
2
|
import { c as z } from "../dateUtils-DeNLG5hw.js";
|
|
3
3
|
import "react";
|
|
4
|
-
import { awayzClient as
|
|
4
|
+
import { awayzClient as O } from "@odynn/awayz-auth";
|
|
5
5
|
import { WalletService as G } from "../services/wallet/WalletService.js";
|
|
6
|
-
import { ERewardProgramCategories as
|
|
7
|
-
const T = (
|
|
8
|
-
var n,
|
|
6
|
+
import { ERewardProgramCategories as _ } from "../services/wallet/WalletService.types.js";
|
|
7
|
+
const T = (s) => s == null ? void 0 : s.map((e) => {
|
|
8
|
+
var n, r, i, o, t, a, l, h, u, L, A, M, N, F, w, g, p, c, y, C, b, m, d, f;
|
|
9
9
|
return {
|
|
10
10
|
id: e.id,
|
|
11
11
|
points: (e == null ? void 0 : e.points) >= 0 ? e.points : -1,
|
|
12
12
|
partial: e.partial,
|
|
13
13
|
origin: {
|
|
14
|
-
city: e.slices[0].segments[0].origin.cityName || ((
|
|
15
|
-
country: e.slices[0].segments[0].origin.iataCountryCode || ((
|
|
14
|
+
city: e.slices[0].segments[0].origin.cityName || ((r = (n = e.slices[0].segments[0].origin) == null ? void 0 : n.city) == null ? void 0 : r.name),
|
|
15
|
+
country: e.slices[0].segments[0].origin.iataCountryCode || ((i = e.slices[0].segments[0].origin) == null ? void 0 : i.city.iataCountryCode),
|
|
16
16
|
airportCode: e.slices[0].segments[0].origin.iataCityCode || e.slices[0].segments[0].origin.city.iataCode,
|
|
17
17
|
coordinates: {
|
|
18
18
|
latitude: e.slices[0].segments[0].origin.city.latitude,
|
|
@@ -20,20 +20,20 @@ const T = (r) => r == null ? void 0 : r.map((e) => {
|
|
|
20
20
|
}
|
|
21
21
|
},
|
|
22
22
|
destination: {
|
|
23
|
-
city: ((
|
|
24
|
-
country: ((L = (u = e.slices[0].segments.getLast()) == null ? void 0 : u.destination) == null ? void 0 : L.iataCountryCode) || ((
|
|
25
|
-
airportCode: ((w = (F = e.slices[0].segments.getLast()) == null ? void 0 : F.destination) == null ? void 0 : w.iataCityCode) || ((
|
|
23
|
+
city: ((t = (o = e.slices[0].segments.getLast()) == null ? void 0 : o.destination) == null ? void 0 : t.cityName) || ((h = (l = (a = e.slices[0].segments.getLast()) == null ? void 0 : a.destination) == null ? void 0 : l.city) == null ? void 0 : h.name),
|
|
24
|
+
country: ((L = (u = e.slices[0].segments.getLast()) == null ? void 0 : u.destination) == null ? void 0 : L.iataCountryCode) || ((N = (M = (A = e.slices[0].segments.getLast()) == null ? void 0 : A.destination) == null ? void 0 : M.city) == null ? void 0 : N.iataCountryCode),
|
|
25
|
+
airportCode: ((w = (F = e.slices[0].segments.getLast()) == null ? void 0 : F.destination) == null ? void 0 : w.iataCityCode) || ((c = (p = (g = e.slices[0].segments.getLast()) == null ? void 0 : g.destination) == null ? void 0 : p.city) == null ? void 0 : c.iataCode),
|
|
26
26
|
coordinates: {
|
|
27
27
|
latitude: (b = (C = (y = e.slices[0].segments.getLast()) == null ? void 0 : y.destination) == null ? void 0 : C.city) == null ? void 0 : b.latitude,
|
|
28
|
-
longitude: (f = (
|
|
28
|
+
longitude: (f = (d = (m = e.slices[0].segments.getLast()) == null ? void 0 : m.destination) == null ? void 0 : d.city) == null ? void 0 : f.longitude
|
|
29
29
|
}
|
|
30
30
|
},
|
|
31
31
|
airline: e.owner.name,
|
|
32
32
|
cash: parseFloat(e.totalAmount),
|
|
33
|
-
flightNumber:
|
|
33
|
+
flightNumber: v(e.slices[0].segments[0]),
|
|
34
34
|
awayzGroupId: e.slices[0].comparisonKey || e.awayzRouteId || e.awayzGroupId || e.id,
|
|
35
|
-
departureTime:
|
|
36
|
-
arrivalTime:
|
|
35
|
+
departureTime: D(e.slices[0].segments[0].departingAt).toDate(),
|
|
36
|
+
arrivalTime: D(
|
|
37
37
|
e.slices[0].segments[e.slices[0].segments.length - 1].arrivingAt
|
|
38
38
|
).toDate(),
|
|
39
39
|
numberOfStops: e.slices[0].segments.length - 1,
|
|
@@ -42,21 +42,21 @@ const T = (r) => r == null ? void 0 : r.map((e) => {
|
|
|
42
42
|
airlineProgram: e.airlineProgram,
|
|
43
43
|
paymentOptions: [],
|
|
44
44
|
durationMinutes: z({
|
|
45
|
-
departureTime:
|
|
46
|
-
arrivalTime:
|
|
45
|
+
departureTime: D(e.slices[0].segments[0].departingAt),
|
|
46
|
+
arrivalTime: D(e.slices[0].segments.getLast().arrivingAt),
|
|
47
47
|
originTimeZone: e.slices[0].segments[0].origin.timeZone,
|
|
48
48
|
destinationTimeZone: e.slices[0].segments.getLast().destination.timeZone,
|
|
49
49
|
duration: e.slices[0].duration
|
|
50
50
|
})
|
|
51
51
|
};
|
|
52
|
-
}), U = (
|
|
52
|
+
}), U = (s, e) => {
|
|
53
53
|
if (!(e != null && e.length))
|
|
54
|
-
return T(
|
|
54
|
+
return T(s);
|
|
55
55
|
const n = [...e];
|
|
56
|
-
let
|
|
57
|
-
const
|
|
58
|
-
for (const
|
|
59
|
-
const a =
|
|
56
|
+
let r = [];
|
|
57
|
+
const i = {};
|
|
58
|
+
for (const t of s) {
|
|
59
|
+
const a = t.slices[0].segments, l = a[0], h = {
|
|
60
60
|
iataCode: l.operatingCarrier.iataCode,
|
|
61
61
|
flightNumber: I(
|
|
62
62
|
l.operatingCarrierFlightNumber
|
|
@@ -66,95 +66,95 @@ const T = (r) => r == null ? void 0 : r.map((e) => {
|
|
|
66
66
|
flightNumber: I(
|
|
67
67
|
l.marketingCarrierFlightNumber
|
|
68
68
|
)
|
|
69
|
-
}, L =
|
|
70
|
-
const
|
|
69
|
+
}, L = t.awayzMatchId, A = `${h.iataCode}_${u.iataCode}-${u.flightNumber}`, M = t.awayzMarketerMatchId, N = !!h.flightNumber && h.flightNumber != "", F = !!u.flightNumber && u.flightNumber != "", w = n.filter((g, p) => {
|
|
70
|
+
const c = g.flightDetails, y = g.flightDetails.slices[0].segments[0].operatingCarrierFlightNumber, C = c.id && // TODO: Maybe expand on this - Id check ensures it is a duffel flight
|
|
71
71
|
!!y && y !== "";
|
|
72
|
-
if (!(
|
|
73
|
-
(
|
|
72
|
+
if (!(c.slices[0].segments.length === (a == null ? void 0 : a.length) && !c.slices[0].segments.find(
|
|
73
|
+
(d, f) => d.departingAt !== a[f].departingAt || d.arrivingAt !== a[f].arrivingAt || d.duration !== a[f].duration
|
|
74
74
|
)))
|
|
75
75
|
return !1;
|
|
76
76
|
let m = !1;
|
|
77
|
-
return (F &&
|
|
77
|
+
return (F && N && c.awayzMatchId === L || !C && c.awayzMatchId === A || N && !F && c.awayzMarketerMatchId === M) && (m = !0), m && (i[c.id] = p), m;
|
|
78
78
|
});
|
|
79
79
|
if (w.length) {
|
|
80
|
-
|
|
81
|
-
const
|
|
82
|
-
var C, b, m,
|
|
83
|
-
const
|
|
84
|
-
return y ===
|
|
80
|
+
t.slices[0].comparisonKey = w[0].awayzGroupId;
|
|
81
|
+
const g = w.find((p) => {
|
|
82
|
+
var C, b, m, d;
|
|
83
|
+
const c = (C = p.flightDetails.slices[0].fareBrandName) == null ? void 0 : C.toLowerCase(), y = (b = t.slices[0].fareBrandName) == null ? void 0 : b.toLowerCase();
|
|
84
|
+
return y === c || // Special Case for AC Only match on first word
|
|
85
85
|
// Due to differences in scraped points data and Duffel format
|
|
86
|
-
u.iataCode === "AC" && ((m = y.split(" ")) == null ? void 0 : m[0]) === ((
|
|
86
|
+
u.iataCode === "AC" && ((m = y.split(" ")) == null ? void 0 : m[0]) === ((d = c.split(" ")) == null ? void 0 : d[0]);
|
|
87
87
|
});
|
|
88
|
-
if (
|
|
89
|
-
const p =
|
|
90
|
-
...
|
|
91
|
-
...
|
|
92
|
-
points:
|
|
93
|
-
airlineProgram:
|
|
88
|
+
if (g) {
|
|
89
|
+
const p = i[g.id], c = {
|
|
90
|
+
...t,
|
|
91
|
+
...g,
|
|
92
|
+
points: t.points,
|
|
93
|
+
airlineProgram: t.airlineProgram,
|
|
94
94
|
flightDetails: {
|
|
95
|
-
...
|
|
96
|
-
...
|
|
97
|
-
points:
|
|
98
|
-
airlineProgram:
|
|
95
|
+
...t,
|
|
96
|
+
...g.flightDetails,
|
|
97
|
+
points: t.points,
|
|
98
|
+
airlineProgram: t.airlineProgram
|
|
99
99
|
}
|
|
100
100
|
};
|
|
101
|
-
n[p] =
|
|
101
|
+
n[p] = c;
|
|
102
102
|
} else
|
|
103
|
-
|
|
103
|
+
r.push(t);
|
|
104
104
|
} else
|
|
105
|
-
|
|
105
|
+
r.push(t);
|
|
106
106
|
}
|
|
107
107
|
return [
|
|
108
108
|
...n,
|
|
109
|
-
...T(
|
|
109
|
+
...T(r) ?? []
|
|
110
110
|
];
|
|
111
|
-
},
|
|
112
|
-
const e =
|
|
111
|
+
}, v = (s) => {
|
|
112
|
+
const e = s.operatingCarrierFlightNumber ? s.operatingCarrier : s.marketingCarrier, n = s.operatingCarrierFlightNumber ?? s.marketingCarrierFlightNumber;
|
|
113
113
|
return e.iataCode + " " + I(n);
|
|
114
114
|
}, K = ({
|
|
115
|
-
originCode:
|
|
115
|
+
originCode: s,
|
|
116
116
|
destinationCode: e,
|
|
117
117
|
departureDate: n,
|
|
118
|
-
cabinClass:
|
|
119
|
-
passengerCount:
|
|
120
|
-
paymentType:
|
|
118
|
+
cabinClass: r,
|
|
119
|
+
passengerCount: i,
|
|
120
|
+
paymentType: o
|
|
121
121
|
}) => {
|
|
122
|
-
let
|
|
123
|
-
return
|
|
124
|
-
},
|
|
125
|
-
const e =
|
|
126
|
-
const
|
|
127
|
-
return
|
|
122
|
+
let t = "/flights/search/one-way/points-cash?";
|
|
123
|
+
return t += `origin=${s}`, t += `&destination=${e}`, t += `&departure_date=${n}`, t += `&cabin_class=${r}`, t += `&adults=${i}`, t += `&cash_or_points=[${o}]`, t;
|
|
124
|
+
}, j = (s) => {
|
|
125
|
+
const e = s.reduce((r, i) => {
|
|
126
|
+
const o = i.flightDetails.slices[0].segments.map((t) => I(v(t))).join("_");
|
|
127
|
+
return console.log(o), r[o] || (r[o] = []), r[o].push(i), r;
|
|
128
128
|
}, {});
|
|
129
129
|
return Object.values(e).map(
|
|
130
|
-
(
|
|
131
|
-
const
|
|
130
|
+
(r) => {
|
|
131
|
+
const i = r[0], { origin: o, destination: t } = i;
|
|
132
132
|
return {
|
|
133
|
-
id:
|
|
134
|
-
partial:
|
|
133
|
+
id: i.awayzGroupId,
|
|
134
|
+
partial: i.partial,
|
|
135
135
|
origin: {
|
|
136
|
-
city:
|
|
137
|
-
country:
|
|
138
|
-
airportCode:
|
|
139
|
-
coordinates:
|
|
136
|
+
city: o.city,
|
|
137
|
+
country: o.country,
|
|
138
|
+
airportCode: o.airportCode,
|
|
139
|
+
coordinates: o.coordinates
|
|
140
140
|
},
|
|
141
141
|
destination: {
|
|
142
|
-
city:
|
|
143
|
-
country:
|
|
144
|
-
airportCode:
|
|
145
|
-
coordinates:
|
|
142
|
+
city: t.city,
|
|
143
|
+
country: t.country,
|
|
144
|
+
airportCode: t.airportCode,
|
|
145
|
+
coordinates: t.coordinates
|
|
146
146
|
},
|
|
147
|
-
airline:
|
|
148
|
-
flightNumber:
|
|
149
|
-
lowestCash:
|
|
147
|
+
airline: i.airline,
|
|
148
|
+
flightNumber: i.flightNumber,
|
|
149
|
+
lowestCash: r.reduce(
|
|
150
150
|
(a, l) => Math.min(a, l.cash),
|
|
151
151
|
1 / 0
|
|
152
152
|
),
|
|
153
|
-
lowestPoints:
|
|
153
|
+
lowestPoints: r.reduce(
|
|
154
154
|
(a, l) => Math.min(a, l.points),
|
|
155
155
|
1 / 0
|
|
156
156
|
),
|
|
157
|
-
paymentOptions:
|
|
157
|
+
paymentOptions: r.map((a) => ({
|
|
158
158
|
id: a.id,
|
|
159
159
|
cash: a.cash,
|
|
160
160
|
points: a.points,
|
|
@@ -167,30 +167,30 @@ const T = (r) => r == null ? void 0 : r.map((e) => {
|
|
|
167
167
|
changeBeforeDeparture: !0
|
|
168
168
|
}
|
|
169
169
|
})),
|
|
170
|
-
numberOfStops:
|
|
171
|
-
departureTime:
|
|
172
|
-
arrivalTime:
|
|
173
|
-
awayzGroupId:
|
|
174
|
-
duration:
|
|
175
|
-
airlineProgram:
|
|
170
|
+
numberOfStops: i.numberOfStops,
|
|
171
|
+
departureTime: i.departureTime,
|
|
172
|
+
arrivalTime: i.arrivalTime,
|
|
173
|
+
awayzGroupId: i.awayzGroupId,
|
|
174
|
+
duration: i.duration,
|
|
175
|
+
airlineProgram: i.airlineProgram,
|
|
176
176
|
durationMinutes: z({
|
|
177
|
-
departureTime:
|
|
178
|
-
|
|
177
|
+
departureTime: D(
|
|
178
|
+
i.flightDetails.slices[0].segments[0].departingAt
|
|
179
179
|
),
|
|
180
|
-
arrivalTime:
|
|
181
|
-
|
|
180
|
+
arrivalTime: D(
|
|
181
|
+
i.flightDetails.slices[0].segments.getLast().arrivingAt
|
|
182
182
|
),
|
|
183
|
-
originTimeZone:
|
|
184
|
-
destinationTimeZone:
|
|
185
|
-
duration:
|
|
183
|
+
originTimeZone: i.flightDetails.slices[0].segments[0].origin.timeZone,
|
|
184
|
+
destinationTimeZone: i.flightDetails.slices[0].segments.getLast().destination.timeZone,
|
|
185
|
+
duration: i.flightDetails.slices[0].duration
|
|
186
186
|
}),
|
|
187
|
-
cash:
|
|
188
|
-
points:
|
|
189
|
-
flightDetails:
|
|
187
|
+
cash: i.cash,
|
|
188
|
+
points: i.points,
|
|
189
|
+
flightDetails: i.flightDetails
|
|
190
190
|
};
|
|
191
191
|
}
|
|
192
192
|
);
|
|
193
|
-
}, I = (
|
|
193
|
+
}, I = (s) => s.replace(/^0+/, ""), q = (s) => `https://assets.duffel.com/img/airlines/for-light-background/full-color-logo/${s}.svg`, P = "/img/logo/odynn-eye.svg", k = {
|
|
194
194
|
categoryLogo: P,
|
|
195
195
|
programLogo: P,
|
|
196
196
|
awayzActive: [],
|
|
@@ -198,34 +198,34 @@ const T = (r) => r == null ? void 0 : r.map((e) => {
|
|
|
198
198
|
displayProgram: "Unknown",
|
|
199
199
|
id: "Unknown",
|
|
200
200
|
totalAccumulatedPoints: 0,
|
|
201
|
-
category:
|
|
201
|
+
category: _.Airline,
|
|
202
202
|
colour: "#fff",
|
|
203
203
|
// Using App Foreground Colour
|
|
204
204
|
url: "https://www.odynn.com"
|
|
205
|
-
},
|
|
206
|
-
const { airlines: e } = await
|
|
205
|
+
}, Q = async (s) => {
|
|
206
|
+
const { airlines: e } = await O.ensureQueryData({
|
|
207
207
|
queryKey: ["walletAwards"],
|
|
208
208
|
queryFn: G.getAwards,
|
|
209
209
|
staleTime: 864e5
|
|
210
210
|
// 24 hours
|
|
211
211
|
});
|
|
212
212
|
let n = e.find(
|
|
213
|
-
(
|
|
213
|
+
(r) => r.mainProgram.toLowerCase().includes(s.toLowerCase()) || r.displayProgram.toLowerCase().includes(s.toLowerCase())
|
|
214
214
|
) ?? k;
|
|
215
215
|
return n || (n = {
|
|
216
216
|
...k,
|
|
217
|
-
mainProgram:
|
|
218
|
-
displayProgram:
|
|
219
|
-
id:
|
|
217
|
+
mainProgram: s,
|
|
218
|
+
displayProgram: s,
|
|
219
|
+
id: s
|
|
220
220
|
}), n;
|
|
221
221
|
};
|
|
222
222
|
export {
|
|
223
223
|
k as DEFAULT_AIRLINE_PROGRAM,
|
|
224
224
|
K as buildFlightSearchQuery,
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
225
|
+
Q as getAirlineProgram,
|
|
226
|
+
v as getFlightNumber,
|
|
227
|
+
q as getLogoPath,
|
|
228
|
+
j as groupFlightResults,
|
|
229
229
|
T as mapFlightDetailsToResults,
|
|
230
230
|
U as parseFlightDetails,
|
|
231
231
|
I as removeLeadingZeros
|