@odynn/awayz-flights 0.2.9 → 0.2.10

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.
@@ -1,12 +1,12 @@
1
1
  import { useState as D, useRef as J } from "react";
2
2
  import { useMutation as M } from "@tanstack/react-query";
3
- import { ECabinClass as Q, EFlightType as $, EFlightPaymentType as N } from "../../types/enums.js";
4
- import { FlightService as A } from "../../services/flights/FlightsService.js";
3
+ import { ECabinClass as Q, EFlightType as $, EFlightPaymentType as A } from "../../types/enums.js";
4
+ import { FlightService as q } from "../../services/flights/FlightsService.js";
5
5
  import { mapFlightDetailsToResults as X, groupFlightResults as Z, buildFlightSearchQuery as ee } from "../../utils/flightUtils.js";
6
6
  import "../../arrayExtensions-DWKenJCh.js";
7
7
  import { c as K } from "../../objectUtils-CyIaVmog.js";
8
8
  import te from "../../stores/useFlightStore.js";
9
- import { useAwayzContext as ne, awayzClient as q, getBaseUrl as re } from "@odynn/awayz-core";
9
+ import { useAwayzContext as ne, awayzClient as L, getBaseUrl as re } from "@odynn/awayz-core";
10
10
  var I = /* @__PURE__ */ ((n) => (n.CHECK_USER = "CHECK_USER", n.USER_REGIONS = "USER_REGIONS", n.CONVERT_CURRENCY = "CONVERT_CURRENCY", n.CLIENT_COMPONENT_KEY = "CLIENT_COMPONENT_KEY", n.SEARCH_LIMIT = "SEARCH_LIMIT", n))(I || {});
11
11
  async function oe(n, t) {
12
12
  const o = n.getReader();
@@ -91,7 +91,7 @@ var ue = function(n, t) {
91
91
  const j = "text/event-stream", ce = 1e3, z = "last-event-id";
92
92
  function de(n, t) {
93
93
  var { signal: o, headers: r, onopen: s, onmessage: w, onclose: c, onerror: u, openWhenHidden: a, fetch: l } = t, b = ue(t, ["signal", "headers", "onopen", "onmessage", "onclose", "onerror", "openWhenHidden", "fetch"]);
94
- return new Promise((g, L) => {
94
+ return new Promise((g, _) => {
95
95
  const p = Object.assign({}, r);
96
96
  p.accept || (p.accept = j);
97
97
  let m;
@@ -99,7 +99,7 @@ function de(n, t) {
99
99
  m.abort(), document.hidden || T();
100
100
  }
101
101
  a || document.addEventListener("visibilitychange", E);
102
- let _ = ce, R = 0;
102
+ let F = ce, R = 0;
103
103
  function S() {
104
104
  document.removeEventListener("visibilitychange", E), window.clearTimeout(R), m.abort();
105
105
  }
@@ -115,15 +115,15 @@ function de(n, t) {
115
115
  await P(C), await oe(C.body, se(ae((h) => {
116
116
  h ? p[z] = h : delete p[z];
117
117
  }, (h) => {
118
- _ = h;
118
+ F = h;
119
119
  }, w))), c == null || c(), S(), g();
120
120
  } catch (C) {
121
121
  if (!m.signal.aborted)
122
122
  try {
123
- const h = (v = u == null ? void 0 : u(C)) !== null && v !== void 0 ? v : _;
123
+ const h = (v = u == null ? void 0 : u(C)) !== null && v !== void 0 ? v : F;
124
124
  window.clearTimeout(R), R = window.setTimeout(T, h);
125
125
  } catch (h) {
126
- S(), L(h);
126
+ S(), _(h);
127
127
  }
128
128
  }
129
129
  }
@@ -149,7 +149,7 @@ const fe = 3 * 60 * 1e3, G = (n) => {
149
149
  inboundResults: l,
150
150
  outboundResults: b,
151
151
  setInboundResults: g,
152
- setOutboundResults: L,
152
+ setOutboundResults: _,
153
153
  partialOfferRequestId: p,
154
154
  setPartialOfferRequestId: m
155
155
  } = te(), E = ({
@@ -157,9 +157,9 @@ const fe = 3 * 60 * 1e3, G = (n) => {
157
157
  inbound: f
158
158
  }) => {
159
159
  const d = X(e);
160
- return (f ? g : L)(Z(d)), d;
160
+ return (f ? g : _)(Z(d)), d;
161
161
  }, {
162
- mutate: _,
162
+ mutate: F,
163
163
  status: R,
164
164
  error: S
165
165
  } = M({
@@ -175,7 +175,7 @@ const fe = 3 * 60 * 1e3, G = (n) => {
175
175
  cabin_class: e.cabinClass || B
176
176
  };
177
177
  if (e.flightType === $.ONE_WAY) {
178
- const i = await A.cashOnlySearch({
178
+ const i = await q.cashOnlySearch({
179
179
  ...d,
180
180
  departure_date: e.departureDate
181
181
  });
@@ -184,7 +184,7 @@ const fe = 3 * 60 * 1e3, G = (n) => {
184
184
  data: i.data
185
185
  };
186
186
  } else {
187
- const i = await A.roundTripOutboundSearch({
187
+ const i = await q.roundTripOutboundSearch({
188
188
  ...d,
189
189
  departure_date: e.departureDate,
190
190
  return_date: e.returnDate
@@ -208,7 +208,7 @@ const fe = 3 * 60 * 1e3, G = (n) => {
208
208
  console.error("Error in outbound flight search:", e);
209
209
  },
210
210
  onSettled: () => {
211
- q.invalidateQueries({ queryKey: [I.SEARCH_LIMIT] });
211
+ L.invalidateQueries({ queryKey: [I.SEARCH_LIMIT] });
212
212
  }
213
213
  }), {
214
214
  mutate: H,
@@ -218,7 +218,7 @@ const fe = 3 * 60 * 1e3, G = (n) => {
218
218
  mutationFn: async (e) => {
219
219
  if (!p)
220
220
  throw new Error("No partialOfferRequestId found for inbound search.");
221
- return r(e), await A.roundTripInboundSearch({
221
+ return r(e), await q.roundTripInboundSearch({
222
222
  outboundOfferId: e,
223
223
  outboundOfferRequestId: p
224
224
  });
@@ -234,7 +234,7 @@ const fe = 3 * 60 * 1e3, G = (n) => {
234
234
  console.error("Error in inbound flight search:", e);
235
235
  },
236
236
  onSettled: () => {
237
- q.invalidateQueries({ queryKey: [I.SEARCH_LIMIT] });
237
+ L.invalidateQueries({ queryKey: [I.SEARCH_LIMIT] });
238
238
  }
239
239
  }), {
240
240
  mutate: v,
@@ -244,7 +244,7 @@ const fe = 3 * 60 * 1e3, G = (n) => {
244
244
  mutationFn: async (e) => {
245
245
  if (!p)
246
246
  throw new Error("No partialOfferRequestId found for round-trip fares.");
247
- return await A.getRoundTripFares({
247
+ return await q.getRoundTripFares({
248
248
  outboundOfferId: o,
249
249
  outboundOfferRequestId: p,
250
250
  inboundOfferId: e
@@ -260,12 +260,12 @@ const fe = 3 * 60 * 1e3, G = (n) => {
260
260
  console.error("Error in round-trip fare search:", e);
261
261
  },
262
262
  onSettled: () => {
263
- q.invalidateQueries({ queryKey: [I.SEARCH_LIMIT] });
263
+ L.invalidateQueries({ queryKey: [I.SEARCH_LIMIT] });
264
264
  }
265
265
  }), x = async (e) => {
266
266
  var Y;
267
267
  u(!0);
268
- const f = e.paymentType === N.CASH_AND_MILES ? ['"cash"', '"points"'] : ['"points"'], d = ee({
268
+ const f = e.paymentType === A.CASH_AND_MILES ? ['"cash"', '"points"'] : ['"points"'], d = ee({
269
269
  originCode: e.origin,
270
270
  destinationCode: e.destination,
271
271
  departureDate: e.departureDate,
@@ -284,9 +284,9 @@ const fe = 3 * 60 * 1e3, G = (n) => {
284
284
  },
285
285
  openWhenHidden: !0,
286
286
  signal: U.signal,
287
- onmessage(F) {
287
+ onmessage(N) {
288
288
  try {
289
- const y = K(JSON.parse(F.data));
289
+ const y = K(JSON.parse(N.data));
290
290
  if (y.success === !1)
291
291
  return;
292
292
  if (y.close === !0) {
@@ -300,8 +300,8 @@ const fe = 3 * 60 * 1e3, G = (n) => {
300
300
  console.error("Error parsing message:", y), O();
301
301
  }
302
302
  },
303
- onerror(F) {
304
- throw console.error("EventSource error:", F), O(), F;
303
+ onerror(N) {
304
+ throw console.error("EventSource error:", N), O(), N;
305
305
  },
306
306
  onclose() {
307
307
  O();
@@ -309,7 +309,7 @@ const fe = 3 * 60 * 1e3, G = (n) => {
309
309
  keepalive: !1
310
310
  });
311
311
  }, O = () => {
312
- U.abort(), a.current && (clearTimeout(a.current), a.current = null), u(!1), q.invalidateQueries({ queryKey: [I.SEARCH_LIMIT] });
312
+ U.abort(), a.current && (clearTimeout(a.current), a.current = null), u(!1), L.invalidateQueries({ queryKey: [I.SEARCH_LIMIT] });
313
313
  };
314
314
  return {
315
315
  /**
@@ -339,15 +339,15 @@ const fe = 3 * 60 * 1e3, G = (n) => {
339
339
  * @param {ISearchFlightArgs} args - The search arguments
340
340
  */
341
341
  searchOutboundFlights: async (e) => {
342
- switch (G(e), e.paymentType) {
342
+ switch (G(e), _([]), e.paymentType) {
343
343
  default:
344
- case N.CASH_AND_MILES:
344
+ case A.CASH_AND_MILES:
345
345
  x(e);
346
346
  break;
347
- case N.CASH:
348
- _(e);
347
+ case A.CASH:
348
+ F(e);
349
349
  break;
350
- case N.MILES:
350
+ case A.MILES:
351
351
  x(e);
352
352
  break;
353
353
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@odynn/awayz-flights",
3
- "version": "0.2.9",
3
+ "version": "0.2.10",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist"