@odynn/awayz-flights 0.1.17 → 0.1.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.
|
@@ -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
|
|
6
|
+
import { ERewardProgramCategories as _ } from "../services/wallet/WalletService.types.js";
|
|
7
7
|
const T = (r) => r == null ? void 0 : r.map((e) => {
|
|
8
|
-
var n,
|
|
8
|
+
var n, a, i, l, t, s, o, h, u, L, M, A, N, F, w, d, p, c, y, C, b, m, g, 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 || ((a = (n = e.slices[0].segments[0].origin) == null ? void 0 : n.city) == null ? void 0 : a.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,9 +20,9 @@ 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 = (l = e.slices[0].segments.getLast()) == null ? void 0 : l.destination) == null ? void 0 : t.cityName) || ((h = (o = (s = e.slices[0].segments.getLast()) == null ? void 0 : s.destination) == null ? void 0 : o.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 = (A = (M = e.slices[0].segments.getLast()) == null ? void 0 : M.destination) == null ? void 0 : A.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 = (d = e.slices[0].segments.getLast()) == null ? void 0 : d.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
28
|
longitude: (f = (g = (m = e.slices[0].segments.getLast()) == null ? void 0 : m.destination) == null ? void 0 : g.city) == null ? void 0 : f.longitude
|
|
@@ -30,10 +30,10 @@ const T = (r) => r == null ? void 0 : r.map((e) => {
|
|
|
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,8 +42,8 @@ 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
|
|
@@ -53,179 +53,191 @@ const T = (r) => r == null ? void 0 : r.map((e) => {
|
|
|
53
53
|
if (!(e != null && e.length))
|
|
54
54
|
return T(r);
|
|
55
55
|
const n = [...e];
|
|
56
|
-
let
|
|
57
|
-
const
|
|
58
|
-
for (const
|
|
59
|
-
const
|
|
60
|
-
iataCode:
|
|
56
|
+
let a = [];
|
|
57
|
+
const i = {};
|
|
58
|
+
for (const t of r) {
|
|
59
|
+
const s = t.slices[0].segments, o = s[0], h = {
|
|
60
|
+
iataCode: o.operatingCarrier.iataCode,
|
|
61
61
|
flightNumber: I(
|
|
62
|
-
|
|
62
|
+
o.operatingCarrierFlightNumber
|
|
63
63
|
)
|
|
64
64
|
}, u = {
|
|
65
|
-
iataCode:
|
|
65
|
+
iataCode: o.marketingCarrier.iataCode,
|
|
66
66
|
flightNumber: I(
|
|
67
|
-
|
|
67
|
+
o.marketingCarrierFlightNumber
|
|
68
68
|
)
|
|
69
|
-
}, L =
|
|
70
|
-
const
|
|
69
|
+
}, L = t.awayzMatchId, M = `${h.iataCode}_${u.iataCode}-${u.flightNumber}`, A = t.awayzMarketerMatchId, N = !!h.flightNumber && h.flightNumber != "", F = !!u.flightNumber && u.flightNumber != "", w = n.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
71
|
!!y && y !== "";
|
|
72
|
-
if (!(
|
|
73
|
-
(g, f) => g.departingAt !==
|
|
72
|
+
if (!(c.slices[0].segments.length === (s == null ? void 0 : s.length) && !c.slices[0].segments.find(
|
|
73
|
+
(g, f) => g.departingAt !== s[f].departingAt || g.arrivingAt !== s[f].arrivingAt || g.duration !== s[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 === M || N && !F && c.awayzMarketerMatchId === A) && (m = !0), m && (i[c.id] = p), m;
|
|
78
78
|
});
|
|
79
79
|
if (w.length) {
|
|
80
|
-
|
|
80
|
+
t.slices[0].comparisonKey = w[0].awayzGroupId;
|
|
81
81
|
const d = w.find((p) => {
|
|
82
82
|
var C, b, m, g;
|
|
83
|
-
const
|
|
84
|
-
return y ===
|
|
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]) === ((g =
|
|
86
|
+
u.iataCode === "AC" && ((m = y.split(" ")) == null ? void 0 : m[0]) === ((g = c.split(" ")) == null ? void 0 : g[0]);
|
|
87
87
|
});
|
|
88
88
|
if (d) {
|
|
89
|
-
const p =
|
|
90
|
-
...
|
|
89
|
+
const p = i[d.id], c = {
|
|
90
|
+
...t,
|
|
91
91
|
...d,
|
|
92
|
-
points:
|
|
93
|
-
airlineProgram:
|
|
92
|
+
points: t.points,
|
|
93
|
+
airlineProgram: t.airlineProgram,
|
|
94
94
|
flightDetails: {
|
|
95
|
-
...
|
|
95
|
+
...t,
|
|
96
96
|
...d.flightDetails,
|
|
97
|
-
points:
|
|
98
|
-
airlineProgram:
|
|
97
|
+
points: t.points,
|
|
98
|
+
airlineProgram: t.airlineProgram
|
|
99
99
|
}
|
|
100
100
|
};
|
|
101
|
-
n[p] =
|
|
101
|
+
n[p] = c;
|
|
102
102
|
} else
|
|
103
|
-
|
|
103
|
+
a.push(t);
|
|
104
104
|
} else
|
|
105
|
-
|
|
105
|
+
a.push(t);
|
|
106
106
|
}
|
|
107
107
|
return [
|
|
108
108
|
...n,
|
|
109
|
-
...T(
|
|
109
|
+
...T(a) ?? []
|
|
110
110
|
];
|
|
111
|
-
},
|
|
111
|
+
}, v = (r) => {
|
|
112
112
|
const e = r.operatingCarrierFlightNumber ? r.operatingCarrier : r.marketingCarrier, n = r.operatingCarrierFlightNumber ?? r.marketingCarrierFlightNumber;
|
|
113
113
|
return e.iataCode + " " + I(n);
|
|
114
114
|
}, K = ({
|
|
115
115
|
originCode: r,
|
|
116
116
|
destinationCode: e,
|
|
117
117
|
departureDate: n,
|
|
118
|
-
cabinClass:
|
|
119
|
-
passengerCount:
|
|
120
|
-
paymentType:
|
|
118
|
+
cabinClass: a,
|
|
119
|
+
passengerCount: i,
|
|
120
|
+
paymentType: l
|
|
121
121
|
}) => {
|
|
122
|
-
let
|
|
123
|
-
return
|
|
124
|
-
},
|
|
125
|
-
const e = r.reduce((
|
|
126
|
-
const
|
|
127
|
-
return
|
|
122
|
+
let t = "/flights/search/one-way/points-cash?";
|
|
123
|
+
return t += `origin=${r}`, t += `&destination=${e}`, t += `&departure_date=${n}`, t += `&cabin_class=${a}`, t += `&adults=${i}`, t += `&cash_or_points=[${l}]`, t;
|
|
124
|
+
}, j = (r) => {
|
|
125
|
+
const e = r.reduce((a, i) => {
|
|
126
|
+
const l = i.flightDetails.slices[0].segments.map((t) => I(v(t))).join("_");
|
|
127
|
+
return a[l] || (a[l] = []), a[l].push(i), a;
|
|
128
128
|
}, {});
|
|
129
129
|
return Object.values(e).map(
|
|
130
|
-
(
|
|
131
|
-
const
|
|
130
|
+
(a) => {
|
|
131
|
+
const i = a[0], { origin: l, 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: l.city,
|
|
137
|
+
country: l.country,
|
|
138
|
+
airportCode: l.airportCode,
|
|
139
|
+
coordinates: l.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:
|
|
150
|
-
(
|
|
147
|
+
airline: i.airline,
|
|
148
|
+
flightNumber: i.flightNumber,
|
|
149
|
+
lowestCash: a.reduce(
|
|
150
|
+
(s, o) => Math.min(s, o.cash),
|
|
151
151
|
1 / 0
|
|
152
152
|
),
|
|
153
|
-
lowestPoints:
|
|
154
|
-
(
|
|
153
|
+
lowestPoints: a.reduce(
|
|
154
|
+
(s, o) => Math.min(s, o.points),
|
|
155
155
|
1 / 0
|
|
156
156
|
),
|
|
157
|
-
paymentOptions:
|
|
158
|
-
id:
|
|
159
|
-
cash:
|
|
160
|
-
points:
|
|
161
|
-
cashFeeCurrency:
|
|
157
|
+
paymentOptions: a.map((s) => ({
|
|
158
|
+
id: s.id,
|
|
159
|
+
cash: s.cash,
|
|
160
|
+
points: s.points,
|
|
161
|
+
cashFeeCurrency: s.flightDetails.baseCurrency,
|
|
162
|
+
//TODO: Add Cash Fee Amount
|
|
162
163
|
cashFeeAmount: 0,
|
|
163
|
-
baseCurrency:
|
|
164
|
-
fareBrandName:
|
|
164
|
+
baseCurrency: s.flightDetails.baseCurrency,
|
|
165
|
+
fareBrandName: s.flightDetails.slices[0].fareBrandName,
|
|
165
166
|
conditions: {
|
|
167
|
+
//TODO: Add Refund and Change Conditions
|
|
166
168
|
refundBeforeDeparture: !0,
|
|
167
169
|
changeBeforeDeparture: !0
|
|
170
|
+
},
|
|
171
|
+
carrier: {
|
|
172
|
+
iataCode: s.flightDetails.slices[0].segments[0].marketingCarrier.iataCode,
|
|
173
|
+
name: s.flightDetails.slices[0].segments[0].marketingCarrier.name
|
|
168
174
|
}
|
|
169
175
|
})),
|
|
170
|
-
numberOfStops:
|
|
171
|
-
departureTime:
|
|
172
|
-
arrivalTime:
|
|
173
|
-
awayzGroupId:
|
|
174
|
-
duration:
|
|
175
|
-
airlineProgram:
|
|
176
|
+
numberOfStops: i.numberOfStops,
|
|
177
|
+
departureTime: i.departureTime,
|
|
178
|
+
arrivalTime: i.arrivalTime,
|
|
179
|
+
awayzGroupId: i.awayzGroupId,
|
|
180
|
+
duration: i.duration,
|
|
181
|
+
airlineProgram: i.airlineProgram,
|
|
176
182
|
durationMinutes: z({
|
|
177
|
-
departureTime:
|
|
178
|
-
|
|
183
|
+
departureTime: D(
|
|
184
|
+
i.flightDetails.slices[0].segments[0].departingAt
|
|
179
185
|
),
|
|
180
|
-
arrivalTime:
|
|
181
|
-
|
|
186
|
+
arrivalTime: D(
|
|
187
|
+
i.flightDetails.slices[0].segments.getLast().arrivingAt
|
|
182
188
|
),
|
|
183
|
-
originTimeZone:
|
|
184
|
-
destinationTimeZone:
|
|
185
|
-
duration:
|
|
189
|
+
originTimeZone: i.flightDetails.slices[0].segments[0].origin.timeZone,
|
|
190
|
+
destinationTimeZone: i.flightDetails.slices[0].segments.getLast().destination.timeZone,
|
|
191
|
+
duration: i.flightDetails.slices[0].duration
|
|
186
192
|
}),
|
|
187
|
-
cash:
|
|
188
|
-
|
|
189
|
-
|
|
193
|
+
cash: a.reduce(
|
|
194
|
+
(s, o) => Math.min(s, o.cash),
|
|
195
|
+
1 / 0
|
|
196
|
+
),
|
|
197
|
+
points: a.reduce(
|
|
198
|
+
(s, o) => Math.min(s, o.points),
|
|
199
|
+
1 / 0
|
|
200
|
+
),
|
|
201
|
+
flightDetails: i.flightDetails
|
|
190
202
|
};
|
|
191
203
|
}
|
|
192
204
|
);
|
|
193
|
-
}, I = (r) => r.replace(/^0+/, ""),
|
|
194
|
-
categoryLogo:
|
|
195
|
-
programLogo:
|
|
205
|
+
}, I = (r) => r.replace(/^0+/, ""), q = (r) => `https://assets.duffel.com/img/airlines/for-light-background/full-color-logo/${r}.svg`, k = "/img/logo/odynn-eye.svg", P = {
|
|
206
|
+
categoryLogo: k,
|
|
207
|
+
programLogo: k,
|
|
196
208
|
awayzActive: [],
|
|
197
209
|
mainProgram: "Unknown",
|
|
198
210
|
displayProgram: "Unknown",
|
|
199
211
|
id: "Unknown",
|
|
200
212
|
totalAccumulatedPoints: 0,
|
|
201
|
-
category:
|
|
213
|
+
category: _.Airline,
|
|
202
214
|
colour: "#fff",
|
|
203
215
|
// Using App Foreground Colour
|
|
204
216
|
url: "https://www.odynn.com"
|
|
205
|
-
},
|
|
206
|
-
const { airlines: e } = await
|
|
217
|
+
}, Q = async (r) => {
|
|
218
|
+
const { airlines: e } = await O.ensureQueryData({
|
|
207
219
|
queryKey: ["walletAwards"],
|
|
208
220
|
queryFn: G.getAwards,
|
|
209
221
|
staleTime: 864e5
|
|
210
222
|
// 24 hours
|
|
211
223
|
});
|
|
212
224
|
let n = e.find(
|
|
213
|
-
(
|
|
214
|
-
) ??
|
|
225
|
+
(a) => a.mainProgram.toLowerCase().includes(r.toLowerCase()) || a.displayProgram.toLowerCase().includes(r.toLowerCase())
|
|
226
|
+
) ?? P;
|
|
215
227
|
return n || (n = {
|
|
216
|
-
...
|
|
228
|
+
...P,
|
|
217
229
|
mainProgram: r,
|
|
218
230
|
displayProgram: r,
|
|
219
231
|
id: r
|
|
220
232
|
}), n;
|
|
221
233
|
};
|
|
222
234
|
export {
|
|
223
|
-
|
|
235
|
+
P as DEFAULT_AIRLINE_PROGRAM,
|
|
224
236
|
K as buildFlightSearchQuery,
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
237
|
+
Q as getAirlineProgram,
|
|
238
|
+
v as getFlightNumber,
|
|
239
|
+
q as getLogoPath,
|
|
240
|
+
j as groupFlightResults,
|
|
229
241
|
T as mapFlightDetailsToResults,
|
|
230
242
|
U as parseFlightDetails,
|
|
231
243
|
I as removeLeadingZeros
|