@odynn/awayz-core 0.2.19 → 0.2.21

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.
@@ -0,0 +1,5 @@
1
+ var e = /* @__PURE__ */ ((r) => (r.TOP = "top", r.BOTTOM = "bottom", r.RIGHT = "right", r.LEFT = "left", r))(e || {}), A = /* @__PURE__ */ ((r) => (r.NA = "N/A", r.HIDDEN = "hidden", r.DISPLAYASZERO = "DisplayAsZero", r))(A || {});
2
+ export {
3
+ A as EInvalidAmountDisplayOption,
4
+ e as EToolTipPosition
5
+ };
@@ -1,5 +1,6 @@
1
- import { CashValue as a, EToolTipPosition as e } from "./CashValue/CashValue.js";
1
+ import { CashValue as e } from "./CashValue/CashValue.js";
2
+ import { EToolTipPosition as p } from "./CashValue/CashValueTypes.js";
2
3
  export {
3
- a as CashValue,
4
- e as EToolTipPosition
4
+ e as CashValue,
5
+ p as EToolTipPosition
5
6
  };
@@ -1,12 +1,16 @@
1
1
  import { QueryClient as e } from "@tanstack/react-query";
2
- const i = new e({
2
+ const r = new e({
3
3
  defaultOptions: {
4
4
  queries: {
5
- staleTime: 1e3 * 60 * 5
5
+ staleTime: 1e3 * 60 * 5,
6
6
  // 5 minutes
7
+ retry: 3
8
+ },
9
+ mutations: {
10
+ retry: 3
7
11
  }
8
12
  }
9
13
  });
10
14
  export {
11
- i as awayzClient
15
+ r as awayzClient
12
16
  };
@@ -1,8 +1,8 @@
1
- import { A as U, E as r, a as l, b as H } from "../../AccountService-BodFPpxb.js";
1
+ import { A as U, E as r, a as o, b as v } from "../../AccountService-C0p4I_Ww.js";
2
2
  import { useState as E, useCallback as R, useEffect as y } from "react";
3
3
  import { EAuthFlow as S } from "../../types/EAuthFlow.js";
4
4
  import { awayzClient as A } from "../../configs/awayzClient.js";
5
- const M = (s, t) => {
5
+ const H = (s, t) => {
6
6
  var f, m;
7
7
  let c = "", d = t;
8
8
  typeof t == "string" ? c = t : t instanceof U ? (c = t.message, d = {
@@ -26,13 +26,13 @@ const M = (s, t) => {
26
26
  ), i = R(
27
27
  async (a, e) => {
28
28
  if (s.authFlow !== S.POST_MESSAGE)
29
- return M(e ?? "exchange_token", a);
29
+ return H(e ?? "exchange_token", a);
30
30
  s != null && s.onError && (s == null || s.onError(a)), s != null && s.onErrorAsync && await (s == null ? void 0 : s.onErrorAsync(a)), c(!1);
31
31
  },
32
32
  [s]
33
33
  ), h = async (a) => {
34
34
  try {
35
- const { success: e, data: n, message: u } = await l.authenticateWithToken(a);
35
+ const { success: e, data: n, message: u } = await o.authenticateWithToken(a);
36
36
  if (!e) {
37
37
  i(u);
38
38
  return;
@@ -42,12 +42,12 @@ const M = (s, t) => {
42
42
  return;
43
43
  }
44
44
  localStorage.setItem(r.TOKEN, n.token), await w(n);
45
- const { data: o, ...g } = await l.getRequestLimit();
45
+ const { data: l, ...g } = await o.getRequestLimit();
46
46
  if (!g.success) {
47
47
  console.error({ reqLimitError: g });
48
48
  return;
49
49
  }
50
- o == null || o.forEach(
50
+ l == null || l.forEach(
51
51
  (_) => window.parent.postMessage(
52
52
  {
53
53
  type: "request_limit",
@@ -64,8 +64,8 @@ const M = (s, t) => {
64
64
  }, N = async () => {
65
65
  try {
66
66
  const { success: a, data: e } = await A.ensureQueryData({
67
- queryKey: [H.CHECK_USER],
68
- queryFn: l.checkUser
67
+ queryKey: [v.CHECK_USER],
68
+ queryFn: o.checkUser
69
69
  });
70
70
  if (!a) {
71
71
  i(e);
@@ -87,7 +87,7 @@ const M = (s, t) => {
87
87
  a && e ? N() : c(!1);
88
88
  }, []);
89
89
  const F = async () => {
90
- const a = await l.getRegions();
90
+ const a = await o.getRegions();
91
91
  K(a);
92
92
  };
93
93
  return y(() => {
@@ -99,9 +99,9 @@ const M = (s, t) => {
99
99
  }, []), y(() => {
100
100
  if (s.authFlow !== S.POST_MESSAGE) return;
101
101
  const a = async (e) => {
102
- var o;
102
+ var l;
103
103
  if (e.data.type !== "auth") return;
104
- const n = (o = e.data) == null ? void 0 : o.idToken, u = e.data.refreshToken;
104
+ const n = (l = e.data) == null ? void 0 : l.idToken, u = e.data.refreshToken;
105
105
  if (!n) {
106
106
  const g = `received message ${JSON.stringify(
107
107
  e.data
@@ -141,7 +141,7 @@ const M = (s, t) => {
141
141
  supportedRegions: I,
142
142
  signIn: async (a) => {
143
143
  var n;
144
- const e = await l.login(a);
144
+ const e = await o.login(a);
145
145
  if (!e.success)
146
146
  i(e.message);
147
147
  else {
@@ -152,7 +152,7 @@ const M = (s, t) => {
152
152
  },
153
153
  signUp: async (a) => {
154
154
  var n;
155
- const e = await l.signUp(a);
155
+ const e = await o.signUp(a);
156
156
  if (!e.success)
157
157
  i(e.message);
158
158
  else {
@@ -164,13 +164,13 @@ const M = (s, t) => {
164
164
  signOut: () => {
165
165
  localStorage.removeItem(r.TOKEN), localStorage.removeItem(r.REFRESH_TOKEN), f(!1), T(void 0), k(void 0);
166
166
  },
167
- resendVerificationEmail: async (a) => (await l.resendVerificationEmail(a)).success,
167
+ resendVerificationEmail: async (a) => (await o.resendVerificationEmail(a)).success,
168
168
  setTokens: (a, e) => {
169
169
  localStorage.setItem(r.TOKEN, a), localStorage.setItem(r.REFRESH_TOKEN, e), h(a);
170
170
  }
171
171
  };
172
172
  };
173
173
  export {
174
- M as authFailurePostMessage,
174
+ H as authFailurePostMessage,
175
175
  V as useAwayzAuth
176
176
  };
@@ -1,25 +1,25 @@
1
- import { b as s, a as n, d as i } from "../AccountService-BodFPpxb.js";
2
- import { useQuery as o } from "@tanstack/react-query";
1
+ import { b as s, a as i, d as n } from "../AccountService-C0p4I_Ww.js";
2
+ import { useQuery as u } from "@tanstack/react-query";
3
3
  import "react";
4
- var a = /* @__PURE__ */ ((e) => (e.HOTEL = "Hotel", e.FLIGHT = "Flight", e))(a || {});
5
- const m = () => {
6
- const { data: e } = o({
4
+ import { useAwayzContext as c } from "./useAwayzContext.js";
5
+ var o = /* @__PURE__ */ ((e) => (e.HOTEL = "Hotel", e.FLIGHT = "Flight", e))(o || {});
6
+ const f = () => {
7
+ const { isAuthenticated: e } = c(), { data: a } = u({
7
8
  queryKey: [s.SEARCH_LIMIT],
8
9
  queryFn: async () => {
9
- const { data: t, ...r } = await n.getRequestLimit();
10
+ const { data: t, ...r } = await i.getRequestLimit();
10
11
  if (!r.success) {
11
12
  console.error({ reqLimitError: r });
12
13
  return;
13
14
  }
14
- return i(t);
15
+ return n(t);
15
16
  },
16
- staleTime: 3e5
17
- // 5 minutes
17
+ enabled: e
18
18
  });
19
- return e ? [a.FLIGHT, a.HOTEL].map(
20
- (t) => e.find((r) => r.searchType === t)
19
+ return a ? [o.FLIGHT, o.HOTEL].map(
20
+ (t) => a.find((r) => r.searchType === t)
21
21
  ) : [void 0, void 0];
22
22
  };
23
23
  export {
24
- m as useSearchLimit
24
+ f as useSearchLimit
25
25
  };
@@ -1,13 +1,9 @@
1
+ import { EToolTipPosition, EInvalidAmountDisplayOption } from './CashValueTypes';
1
2
  export interface ICashValueProps {
2
3
  amount: number | string;
3
4
  currency: string;
4
5
  position?: EToolTipPosition;
6
+ zeroDisplayOption?: EInvalidAmountDisplayOption;
5
7
  }
6
8
  export declare const CurrencyCallStaleTimeMs: number;
7
- export declare const CashValue: ({ amount, currency, position }: ICashValueProps) => import("react/jsx-runtime").JSX.Element | "Loading...";
8
- export declare enum EToolTipPosition {
9
- TOP = "top",
10
- BOTTOM = "bottom",
11
- RIGHT = "right",
12
- LEFT = "left"
13
- }
9
+ export declare const CashValue: ({ amount, currency, position, zeroDisplayOption }: ICashValueProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Enum representing the possible positions for a tooltip.
3
+ *
4
+ * @enum {string}
5
+ * @property {string} TOP - Position the tooltip above the target element.
6
+ * @property {string} BOTTOM - Position the tooltip below the target element.
7
+ * @property {string} RIGHT - Position the tooltip to the right of the target element.
8
+ * @property {string} LEFT - Position the tooltip to the left of the target element.
9
+ */
10
+ export declare enum EToolTipPosition {
11
+ TOP = "top",
12
+ BOTTOM = "bottom",
13
+ RIGHT = "right",
14
+ LEFT = "left"
15
+ }
16
+ /**
17
+ * Enum representing the display options for invalid values in the CashValue component.
18
+ *
19
+ * @enum {string}
20
+ * @property {string} NA - Represents a "Not Applicable" state, displayed as 'N/A'.
21
+ * @property {string} HIDDEN - Hides the zero value from being displayed.
22
+ * @property {string} DISPLAYASZERO - Display the invalid value as zero.
23
+ */
24
+ export declare enum EInvalidAmountDisplayOption {
25
+ NA = "N/A",
26
+ HIDDEN = "hidden",
27
+ DISPLAYASZERO = "DisplayAsZero"
28
+ }
@@ -1 +1,2 @@
1
- export { CashValue, EToolTipPosition } from './CashValue/CashValue';
1
+ export { CashValue } from './CashValue/CashValue';
2
+ export { EToolTipPosition } from './CashValue/CashValueTypes';
package/dist/main.js CHANGED
@@ -2,20 +2,21 @@ import { AwayzProvider as e } from "./providers/AwayzProvider.js";
2
2
  import { useAwayzContext as a } from "./hooks/useAwayzContext.js";
3
3
  import { useSearchLimit as m } from "./hooks/useSearchLimit.js";
4
4
  import { EAuthFlow as x } from "./types/EAuthFlow.js";
5
- import { c as n, i as s } from "./AccountService-BodFPpxb.js";
5
+ import { c as n, i as s } from "./AccountService-C0p4I_Ww.js";
6
6
  import { awayzClient as l } from "./configs/awayzClient.js";
7
- import { CashValue as w, EToolTipPosition as y } from "./components/CashValue/CashValue.js";
8
- import { CurrencyService as h } from "./services/currency/CurrencyService.js";
9
- import { getBaseUrl as A } from "./configs/baseUrl.js";
7
+ import { CashValue as w } from "./components/CashValue/CashValue.js";
8
+ import { EToolTipPosition as C } from "./components/CashValue/CashValueTypes.js";
9
+ import { CurrencyService as z } from "./services/currency/CurrencyService.js";
10
+ import { getBaseUrl as v } from "./configs/baseUrl.js";
10
11
  export {
11
12
  e as AwayzProvider,
12
13
  w as CashValue,
13
- h as CurrencyService,
14
+ z as CurrencyService,
14
15
  x as EAuthFlow,
15
- y as EToolTipPosition,
16
+ C as EToolTipPosition,
16
17
  l as awayzClient,
17
18
  n as clientInstance,
18
- A as getBaseUrl,
19
+ v as getBaseUrl,
19
20
  s as instance,
20
21
  a as useAwayzContext,
21
22
  m as useSearchLimit
@@ -1,7 +1,7 @@
1
1
  import { jsx as t } from "react/jsx-runtime";
2
2
  import { useEffect as i } from "react";
3
3
  import { AwayzContext as m } from "../context/AwayzContext.js";
4
- import { E as e } from "../AccountService-BodFPpxb.js";
4
+ import { E as e } from "../AccountService-C0p4I_Ww.js";
5
5
  import { useAwayzAuth as s } from "../hooks/useAwayzAuth/useAwayzAuth.js";
6
6
  import { setBaseUrl as l } from "../configs/baseUrl.js";
7
7
  import { QueryClientProvider as u } from "@tanstack/react-query";
@@ -1,4 +1,4 @@
1
- import { a as p } from "../../AccountService-BodFPpxb.js";
1
+ import { a as p } from "../../AccountService-C0p4I_Ww.js";
2
2
  import "react";
3
3
  import "../../configs/endpoints.js";
4
4
  import "../../configs/awayzClient.js";
@@ -1,7 +1,7 @@
1
1
  import '../../assets/_styles.css';var i = Object.defineProperty;
2
2
  var y = (t, r, e) => r in t ? i(t, r, { enumerable: !0, configurable: !0, writable: !0, value: e }) : t[r] = e;
3
3
  var o = (t, r, e) => y(t, typeof r != "symbol" ? r + "" : r, e);
4
- import { b as p, a as C, c as a } from "../../AccountService-BodFPpxb.js";
4
+ import { a as p, b as C, c as a } from "../../AccountService-C0p4I_Ww.js";
5
5
  import "react";
6
6
  import { ECurrencyEndpoints as s } from "../../configs/endpoints.js";
7
7
  import "react/jsx-runtime";
@@ -16,8 +16,8 @@ class E {
16
16
  }) => {
17
17
  try {
18
18
  const { success: e, data: n } = await m.ensureQueryData({
19
- queryKey: [p.CHECK_USER],
20
- queryFn: C.checkUser
19
+ queryKey: [C.CHECK_USER],
20
+ queryFn: p.checkUser
21
21
  });
22
22
  if (!e)
23
23
  throw new Error("Failed to fetch user data");
@@ -1,4 +1,4 @@
1
- import { c as p, i as a } from "../AccountService-BodFPpxb.js";
1
+ import { c as p, i as a } from "../AccountService-C0p4I_Ww.js";
2
2
  import "react";
3
3
  import "../configs/endpoints.js";
4
4
  import "../configs/baseUrl.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@odynn/awayz-core",
3
- "version": "0.2.19",
3
+ "version": "0.2.21",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist"