@odynn/awayz-core 0.2.16 → 0.2.17

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,32 +1,32 @@
1
- import { A as _, E as r, a as o, b as U } from "../../AccountService--d4c37gO.js";
1
+ import { A as U, E as r, a as o, b as v } from "../../AccountService--d4c37gO.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
- import { awayzClient as H } from "../../configs/awayzClient.js";
5
- const M = (s, t) => {
6
- var f, d;
7
- let c = "", m = t;
8
- typeof t == "string" ? c = t : t instanceof _ ? (c = t.message, m = {
4
+ import { awayzClient as A } from "../../configs/awayzClient.js";
5
+ const H = (s, t) => {
6
+ var f, m;
7
+ let c = "", d = t;
8
+ typeof t == "string" ? c = t : t instanceof U ? (c = t.message, d = {
9
9
  message: t.message,
10
10
  cause: t.cause,
11
11
  status: t.status,
12
12
  data: (f = t == null ? void 0 : t.response) == null ? void 0 : f.data
13
- }) : c = t.message, (d = window.parent) == null || d.postMessage(
13
+ }) : c = t.message, (m = window.parent) == null || m.postMessage(
14
14
  {
15
15
  type: "auth_error",
16
- details: { message: c, action: s, info: m }
16
+ details: { message: c, action: s, info: d }
17
17
  },
18
18
  "*"
19
19
  );
20
20
  }, V = (s) => {
21
- const [t, c] = E(!0), [m, f] = E(!1), [d, T] = E(), [A, k] = E(), [O, I] = E([]), w = R(
21
+ const [t, c] = E(!0), [d, f] = E(!1), [m, T] = E(), [O, k] = E(), [I, K] = E([]), w = R(
22
22
  async (a) => {
23
- s != null && s.onSuccess && (s == null || s.onSuccess(a)), s != null && s.onSuccessAsync && await (s == null ? void 0 : s.onSuccessAsync(a)), c(!1), f(!0), T(a.token), k(a.user);
23
+ s != null && s.onSuccess && (s == null || s.onSuccess(a)), s != null && s.onSuccessAsync && await (s == null ? void 0 : s.onSuccessAsync(a)), c(!1), f(!0), T(a.token), k(a.user), A.invalidateQueries();
24
24
  },
25
25
  [s]
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]
@@ -48,10 +48,10 @@ const M = (s, t) => {
48
48
  return;
49
49
  }
50
50
  l == null || l.forEach(
51
- (F) => window.parent.postMessage(
51
+ (_) => window.parent.postMessage(
52
52
  {
53
53
  type: "request_limit",
54
- limit: F
54
+ limit: _
55
55
  },
56
56
  "*"
57
57
  )
@@ -61,10 +61,10 @@ const M = (s, t) => {
61
61
  } finally {
62
62
  c(!1);
63
63
  }
64
- }, K = async () => {
64
+ }, N = async () => {
65
65
  try {
66
- const { success: a, data: e } = await H.ensureQueryData({
67
- queryKey: [U.CHECK_USER],
66
+ const { success: a, data: e } = await A.ensureQueryData({
67
+ queryKey: [v.CHECK_USER],
68
68
  queryFn: o.checkUser
69
69
  });
70
70
  if (!a) {
@@ -84,14 +84,14 @@ const M = (s, t) => {
84
84
  y(() => {
85
85
  if (s.authFlow !== S.STANDARD) return;
86
86
  const a = localStorage.getItem(r.TOKEN), e = localStorage.getItem(r.REFRESH_TOKEN);
87
- a && e ? K() : c(!1);
87
+ a && e ? N() : c(!1);
88
88
  }, []);
89
- const N = async () => {
89
+ const F = async () => {
90
90
  const a = await o.getRegions();
91
- I(a);
91
+ K(a);
92
92
  };
93
93
  return y(() => {
94
- N();
94
+ F();
95
95
  }, []), y(() => {
96
96
  if (s.authFlow !== S.QUERY) return;
97
97
  const e = new URLSearchParams(window.location.search).get(r.TOKEN);
@@ -135,10 +135,10 @@ const M = (s, t) => {
135
135
  };
136
136
  }, []), {
137
137
  isAuthenticating: t,
138
- isAuthenticated: m,
139
- token: d,
140
- user: A,
141
- supportedRegions: O,
138
+ isAuthenticated: d,
139
+ token: m,
140
+ user: O,
141
+ supportedRegions: I,
142
142
  signIn: async (a) => {
143
143
  var n;
144
144
  const e = await o.login(a);
@@ -171,6 +171,6 @@ const M = (s, t) => {
171
171
  };
172
172
  };
173
173
  export {
174
- M as authFailurePostMessage,
174
+ H as authFailurePostMessage,
175
175
  V as useAwayzAuth
176
176
  };
@@ -1,22 +1,10 @@
1
1
  import { ISearchLimit } from '../services/account/AccountServices.types';
2
- export declare const useSearchLimit: () => [ISearchLimit, ISearchLimit] | [undefined, undefined];
3
2
  /**
4
- * "data": [
5
- {
6
- "search_type": "Flight",
7
- "subscription": "free",
8
- "is_admin": false,
9
- "search_limit": 5,
10
- "number_of_calls": 1,
11
- "remaining_calls": 4
12
- },
13
- {
14
- "search_type": "Hotel",
15
- "subscription": "free",
16
- "is_admin": false,
17
- "search_limit": 5,
18
- "number_of_calls": 1,
19
- "remaining_calls": 4
20
- }
21
- ],
3
+ * @description
4
+ * useSearchLimit is a custom hook that fetches the search limits for Flight and Hotel searches.
5
+ * The hook returns an array of two ISearchLimit objects, one for Flights and one for Hotels.
6
+ *
7
+ * @returns [FlightSearchLimit, HotelSearchLimit]
8
+ * @returns [undefined, undefined] if the data is not available
22
9
  */
10
+ export declare const useSearchLimit: () => [ISearchLimit, ISearchLimit] | [undefined, undefined];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@odynn/awayz-core",
3
- "version": "0.2.16",
3
+ "version": "0.2.17",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist"