@odynn/awayz-core 0.2.0

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.
Files changed (44) hide show
  1. package/README.md +50 -0
  2. package/dist/AccountService-BjwUydb_.js +7670 -0
  3. package/dist/assets/CashValue.css +1 -0
  4. package/dist/components/CashValue/CashValue.js +21590 -0
  5. package/dist/configs/awayzClient.js +12 -0
  6. package/dist/configs/awayzConfig.js +1 -0
  7. package/dist/configs/baseUrl.js +8 -0
  8. package/dist/configs/defaultAwayzConfig.js +11 -0
  9. package/dist/configs/endpoints.js +5 -0
  10. package/dist/context/AwayzContext.js +16 -0
  11. package/dist/hooks/useAwayzAuth/useAwayzAuth.js +168 -0
  12. package/dist/hooks/useAwayzAuth/useAwayzAuth.types.js +1 -0
  13. package/dist/hooks/useAwayzContext.js +13 -0
  14. package/dist/lib/components/CashValue/CashValue.d.ts +14 -0
  15. package/dist/lib/configs/awayzClient.d.ts +2 -0
  16. package/dist/lib/configs/awayzConfig.d.ts +36 -0
  17. package/dist/lib/configs/baseUrl.d.ts +2 -0
  18. package/dist/lib/configs/defaultAwayzConfig.d.ts +8 -0
  19. package/dist/lib/configs/endpoints.d.ts +26 -0
  20. package/dist/lib/context/AwayzContext.d.ts +17 -0
  21. package/dist/lib/hooks/useAwayzAuth/useAwayzAuth.d.ts +37 -0
  22. package/dist/lib/hooks/useAwayzAuth/useAwayzAuth.types.d.ts +17 -0
  23. package/dist/lib/hooks/useAwayzContext.d.ts +2 -0
  24. package/dist/lib/main.d.ts +6 -0
  25. package/dist/lib/providers/AwayzProvider.d.ts +12 -0
  26. package/dist/lib/services/account/AccountService.d.ts +84 -0
  27. package/dist/lib/services/account/AccountServices.types.d.ts +152 -0
  28. package/dist/lib/services/currency/CurrencyService.d.ts +6 -0
  29. package/dist/lib/services/currency/CurrencyService.types.d.ts +17 -0
  30. package/dist/lib/services/instance.d.ts +2 -0
  31. package/dist/lib/types/EAuthFlow.d.ts +8 -0
  32. package/dist/lib/types/auth.d.ts +21 -0
  33. package/dist/lib/types/index.d.ts +1 -0
  34. package/dist/main.js +15 -0
  35. package/dist/providers/AwayzProvider.js +39 -0
  36. package/dist/services/account/AccountService.js +7 -0
  37. package/dist/services/account/AccountServices.types.js +4 -0
  38. package/dist/services/currency/CurrencyService.js +39 -0
  39. package/dist/services/currency/CurrencyService.types.js +1 -0
  40. package/dist/services/instance.js +8 -0
  41. package/dist/types/EAuthFlow.js +4 -0
  42. package/dist/types/auth.js +1 -0
  43. package/dist/types/index.js +4 -0
  44. package/package.json +44 -0
@@ -0,0 +1,12 @@
1
+ import { QueryClient as e } from "@tanstack/react-query";
2
+ const i = new e({
3
+ defaultOptions: {
4
+ queries: {
5
+ staleTime: 1e3 * 60 * 5
6
+ // 5 minutes
7
+ }
8
+ }
9
+ });
10
+ export {
11
+ i as awayzClient
12
+ };
@@ -0,0 +1 @@
1
+
@@ -0,0 +1,8 @@
1
+ let t = "";
2
+ const n = () => t, s = (e) => {
3
+ t = e ? "https://appdev.odynn.info:3003" : "https://app.odynn.info:3003";
4
+ };
5
+ export {
6
+ n as getBaseUrl,
7
+ s as setBaseUrl
8
+ };
@@ -0,0 +1,11 @@
1
+ const e = {
2
+ testMode: !1,
3
+ externalInventory: !1,
4
+ flightsConfig: {
5
+ streamTimeoutPingCount: 3,
6
+ streamTimeoutTotalSeconds: 180
7
+ }
8
+ };
9
+ export {
10
+ e as defaultAwayzConfig
11
+ };
@@ -0,0 +1,5 @@
1
+ var r = /* @__PURE__ */ ((e) => (e.SIGN_IN = "auth/user-login", e.SIGN_UP = "auth/sign-up", e.ME = "user", e.RESEND_VERIFICATION_EMAIL = "auth/resend-verification-email", e.UPDATE_USER_DETAILS = "account/update/user", e.CONFIRM_EMAIL = "account/verifyAccount", e.FORGOT_PASSWORD = "email/sendVeri", e.RESEND_OTP = "email/sendForgotPasswordVerification", e.RESET_PASSWORD = "account/updateUserPassword", e.REQUEST_LIMIT = "user/request-limit", e.APPLE_SOCIAL_SIGN_UP = "tp/apple/get/user", e.GOOGLE_SOCIAL_SIGN_UP = "tp/google/get/user", e.UPDATE_USER = "account/details/addUserDetails", e.ACKNOWLEDGEMENT = "account/update/userAcknowledgement", e.REGIONS = "user/region", e.UPDATE_USER_REGION = "/account/update/userRegion", e.UPDATE_PASSENGER_DETAILS = "/account/awayz", e.EXCHANGE_TOKEN = "user/exchange-token", e.REFRESH_TOKEN = "user/refresh-token", e.OAUTH_INITIATE = "user/oauth2/initiate", e.OAUTH_CALLBACK = "user/oauth2/callback", e))(r || {}), a = /* @__PURE__ */ ((e) => (e.CURRENCY_CONVERSION = "currency/convert", e))(a || {});
2
+ export {
3
+ r as EAuthEndpoints,
4
+ a as ECurrencyEndpoints
5
+ };
@@ -0,0 +1,16 @@
1
+ import { createContext as s } from "react";
2
+ const t = s({
3
+ isAuthenticated: !1,
4
+ isAuthenticating: !1,
5
+ supportedRegions: [],
6
+ signIn: async () => ({ success: !1, message: "No Awayz Context" }),
7
+ signUp: async () => ({ success: !1, message: "Not Awayz Context" }),
8
+ signOut: () => {
9
+ },
10
+ resendVerificationEmail: async () => !1,
11
+ setTokens: () => {
12
+ }
13
+ });
14
+ export {
15
+ t as AwayzContext
16
+ };
@@ -0,0 +1,168 @@
1
+ import { A as N, E as r, a as u, b as F } from "../../AccountService-BjwUydb_.js";
2
+ import { useState as m, useCallback as x, useEffect as w } from "react";
3
+ import { EAuthFlow as k } from "../../types/EAuthFlow.js";
4
+ import { awayzClient as U } from "../../configs/awayzClient.js";
5
+ const i = (t, a) => {
6
+ var f, E;
7
+ let c = "", d = a;
8
+ typeof a == "string" ? c = a : a instanceof N ? (c = a.message, d = {
9
+ message: a.message,
10
+ cause: a.cause,
11
+ status: a.status,
12
+ data: (f = a == null ? void 0 : a.response) == null ? void 0 : f.data
13
+ }) : c = a.message, (E = window.parent) == null || E.postMessage(
14
+ {
15
+ type: "auth_error",
16
+ details: { message: c, action: t, info: d }
17
+ },
18
+ "*"
19
+ );
20
+ }, L = (t) => {
21
+ const [a, c] = m(!0), [d, f] = m(!1), [E, S] = m(), [R, T] = m(), [O, _] = m([]), h = x(
22
+ async (s) => {
23
+ t != null && t.onSuccess && (t == null || t.onSuccess(s)), t != null && t.onSuccessAsync && await (t == null ? void 0 : t.onSuccessAsync(s)), c(!1), f(!0), S(s.token), T(s.user);
24
+ },
25
+ [t]
26
+ ), y = async (s) => {
27
+ try {
28
+ const { success: e, data: n, message: o } = await u.authenticateWithToken(s);
29
+ if (!e) {
30
+ i("exchange_token", o);
31
+ return;
32
+ }
33
+ if (!(n != null && n.token)) {
34
+ i(
35
+ "exchange_token",
36
+ "no awayz token returned after exchanging id token"
37
+ );
38
+ return;
39
+ }
40
+ localStorage.setItem(r.TOKEN, n.token), await h(n);
41
+ const { data: g, ...l } = await u.getRequestLimit();
42
+ if (!l.success) {
43
+ console.error({ reqLimitError: l });
44
+ return;
45
+ }
46
+ g == null || g.forEach(
47
+ (A) => window.parent.postMessage(
48
+ {
49
+ type: "request_limit",
50
+ limit: A
51
+ },
52
+ "*"
53
+ )
54
+ );
55
+ } catch (e) {
56
+ console.error("error handling message", e);
57
+ } finally {
58
+ c(!1);
59
+ }
60
+ }, I = async () => {
61
+ try {
62
+ const { success: s, data: e } = await U.ensureQueryData({
63
+ queryKey: [F.CHECK_USER],
64
+ queryFn: u.checkUser
65
+ });
66
+ if (!s) {
67
+ i("exchange_token", e);
68
+ return;
69
+ }
70
+ await h({
71
+ user: e,
72
+ token: localStorage.getItem(r.TOKEN)
73
+ });
74
+ } catch (s) {
75
+ i("exchange_token", s);
76
+ } finally {
77
+ c(!1);
78
+ }
79
+ };
80
+ w(() => {
81
+ if (t.authFlow !== k.OAUTH) return;
82
+ const s = localStorage.getItem(r.TOKEN), e = localStorage.getItem(r.REFRESH_TOKEN);
83
+ s && e ? I() : c(!1);
84
+ }, []);
85
+ const K = async () => {
86
+ const s = await u.getRegions();
87
+ _(s);
88
+ };
89
+ return w(() => {
90
+ K();
91
+ }, []), w(() => {
92
+ if (t.authFlow !== k.QUERY) return;
93
+ const e = new URLSearchParams(window.location.search).get(r.TOKEN);
94
+ e && y(e);
95
+ }, []), w(() => {
96
+ if (t.authFlow !== k.POST_MESSAGE) return;
97
+ const s = async (e) => {
98
+ var g;
99
+ if (e.data.type !== "auth") return;
100
+ const n = (g = e.data) == null ? void 0 : g.idToken, o = e.data.refreshToken;
101
+ if (!n) {
102
+ const l = `received message ${JSON.stringify(
103
+ e.data
104
+ )}
105
+ no idToken in body`;
106
+ i("exchange_token", l);
107
+ return;
108
+ }
109
+ if (!o) {
110
+ const l = `received message: ${JSON.stringify(
111
+ e.data
112
+ )}
113
+ no refreshToken in body`;
114
+ i("refresh_token", l);
115
+ return;
116
+ }
117
+ localStorage.setItem(r.REFRESH_TOKEN, o), await y(n);
118
+ };
119
+ return window.addEventListener("message", s), window.parent && window.parent.postMessage(
120
+ {
121
+ type: "ready"
122
+ /* READY */
123
+ },
124
+ "*"
125
+ ), () => {
126
+ window.removeEventListener("message", s);
127
+ };
128
+ }, []), {
129
+ isAuthenticating: a,
130
+ isAuthenticated: d,
131
+ token: E,
132
+ user: R,
133
+ supportedRegions: O,
134
+ signIn: async (s) => {
135
+ var n;
136
+ const e = await u.login(s);
137
+ if (!e.success)
138
+ i("exchange_token", e.message);
139
+ else {
140
+ const o = (n = e.data) == null ? void 0 : n.refreshToken;
141
+ localStorage.setItem(r.REFRESH_TOKEN, o), await h(e.data);
142
+ }
143
+ return e;
144
+ },
145
+ signUp: async (s) => {
146
+ var n;
147
+ const e = await u.signUp(s);
148
+ if (!e.success)
149
+ i("exchange_token", e.message);
150
+ else {
151
+ const o = (n = e.data) == null ? void 0 : n.refreshToken;
152
+ localStorage.setItem(r.REFRESH_TOKEN, o), await h(e.data);
153
+ }
154
+ return e;
155
+ },
156
+ signOut: () => {
157
+ localStorage.removeItem(r.TOKEN), localStorage.removeItem(r.REFRESH_TOKEN), f(!1), S(void 0), T(void 0);
158
+ },
159
+ resendVerificationEmail: async (s) => (await u.resendVerificationEmail(s)).success,
160
+ setTokens: (s, e) => {
161
+ localStorage.setItem(r.TOKEN, s), localStorage.setItem(r.REFRESH_TOKEN, e), y(s);
162
+ }
163
+ };
164
+ };
165
+ export {
166
+ i as authFailurePostMessage,
167
+ L as useAwayzAuth
168
+ };
@@ -0,0 +1,13 @@
1
+ import { useContext as r } from "react";
2
+ import { AwayzContext as t } from "../context/AwayzContext.js";
3
+ const a = () => {
4
+ const o = r(t);
5
+ if (!o)
6
+ throw new Error(
7
+ "Awayz Components must be wrapped in an AwayzProvider. Visit https://docs.awayz.com/providers/awayzprovider for more information."
8
+ );
9
+ return o;
10
+ };
11
+ export {
12
+ a as useAwayzContext
13
+ };
@@ -0,0 +1,14 @@
1
+ export interface ICashValueProps {
2
+ amount: number | string;
3
+ currency: string;
4
+ position?: EToolTipPosition;
5
+ }
6
+ export declare const CurrencyCallStaleTimeMs: number;
7
+ declare const CashValue: ({ amount, currency, position }: ICashValueProps) => import("react/jsx-runtime").JSX.Element | "Loading...";
8
+ export default CashValue;
9
+ export declare enum EToolTipPosition {
10
+ TOP = "top",
11
+ BOTTOM = "bottom",
12
+ RIGHT = "right",
13
+ LEFT = "left"
14
+ }
@@ -0,0 +1,2 @@
1
+ import { QueryClient } from '@tanstack/react-query';
2
+ export declare const awayzClient: QueryClient;
@@ -0,0 +1,36 @@
1
+ import { EAuthFlow } from '../types';
2
+ export interface IAwayzConfig {
3
+ /**
4
+ * Your custom client ID from Awayz
5
+ */
6
+ clientId: string;
7
+ /**
8
+ * The authentication flow you want to use
9
+ */
10
+ authFlow: EAuthFlow;
11
+ /**
12
+ * The list of trusted origins for the postMessage flow
13
+ */
14
+ trustedOrigins: string[];
15
+ /**
16
+ * Enable test mode to use the Awayz components in a test environment
17
+ */
18
+ testMode?: boolean;
19
+ /**
20
+ * Enable non-chain hotels for hotel searches
21
+ * @default false
22
+ */
23
+ externalInventory?: boolean;
24
+ flightsConfig?: {
25
+ /**
26
+ * The maximum number of ping events before the flight search times out
27
+ * @default 3
28
+ */
29
+ streamTimeoutPingCount?: number;
30
+ /**
31
+ * The maximum time in seconds before the flight search times out
32
+ * @default 180
33
+ */
34
+ streamTimeoutTotalSeconds?: number;
35
+ };
36
+ }
@@ -0,0 +1,2 @@
1
+ export declare const getBaseUrl: () => string;
2
+ export declare const setBaseUrl: (testMode: boolean) => void;
@@ -0,0 +1,8 @@
1
+ export declare const defaultAwayzConfig: {
2
+ testMode: boolean;
3
+ externalInventory: boolean;
4
+ flightsConfig: {
5
+ streamTimeoutPingCount: number;
6
+ streamTimeoutTotalSeconds: number;
7
+ };
8
+ };
@@ -0,0 +1,26 @@
1
+ export declare enum EAuthEndpoints {
2
+ SIGN_IN = "auth/user-login",
3
+ SIGN_UP = "auth/sign-up",
4
+ ME = "user",
5
+ RESEND_VERIFICATION_EMAIL = "auth/resend-verification-email",
6
+ UPDATE_USER_DETAILS = "account/update/user",
7
+ CONFIRM_EMAIL = "account/verifyAccount",
8
+ FORGOT_PASSWORD = "email/sendVeri",
9
+ RESEND_OTP = "email/sendForgotPasswordVerification",
10
+ RESET_PASSWORD = "account/updateUserPassword",
11
+ REQUEST_LIMIT = "user/request-limit",
12
+ APPLE_SOCIAL_SIGN_UP = "tp/apple/get/user",
13
+ GOOGLE_SOCIAL_SIGN_UP = "tp/google/get/user",
14
+ UPDATE_USER = "account/details/addUserDetails",
15
+ ACKNOWLEDGEMENT = "account/update/userAcknowledgement",
16
+ REGIONS = "user/region",
17
+ UPDATE_USER_REGION = "/account/update/userRegion",
18
+ UPDATE_PASSENGER_DETAILS = "/account/awayz",
19
+ EXCHANGE_TOKEN = "user/exchange-token",
20
+ REFRESH_TOKEN = "user/refresh-token",
21
+ OAUTH_INITIATE = "user/oauth2/initiate",
22
+ OAUTH_CALLBACK = "user/oauth2/callback"
23
+ }
24
+ export declare enum ECurrencyEndpoints {
25
+ CURRENCY_CONVERSION = "currency/convert"
26
+ }
@@ -0,0 +1,17 @@
1
+ import { IRegion, IResendVerificationEmailParams, IUser } from '../services/account/AccountServices.types';
2
+ import { ISignInParams, ISignUpParams, TAuthResponse } from '../types/auth';
3
+ import { IAwayzConfig } from '../configs/awayzConfig';
4
+ export interface IAwayzContext {
5
+ config?: IAwayzConfig;
6
+ token?: string;
7
+ user?: IUser;
8
+ isAuthenticated: boolean;
9
+ isAuthenticating: boolean;
10
+ supportedRegions: IRegion[];
11
+ signIn: (params: ISignInParams) => Promise<TAuthResponse>;
12
+ signUp: (params: ISignUpParams) => Promise<TAuthResponse>;
13
+ signOut: () => void;
14
+ resendVerificationEmail: (params: IResendVerificationEmailParams) => Promise<boolean>;
15
+ setTokens: (accessToken: string, refreshToken: string) => void;
16
+ }
17
+ export declare const AwayzContext: import('react').Context<IAwayzContext>;
@@ -0,0 +1,37 @@
1
+ import { TEmbeddedAuthOptions } from './useAwayzAuth.types';
2
+ import { IAuthData, IRegion, IResendVerificationEmailParams, IUser } from '../../services/account/AccountServices.types';
3
+ import { ISignInParams, ISignUpParams } from '../../types/auth';
4
+ declare enum ETokenType {
5
+ EXCHANGE = "exchange_token",
6
+ REFRESH = "refresh_token"
7
+ }
8
+ export declare const authFailurePostMessage: (action: ETokenType, error: any) => void;
9
+ export declare const useAwayzAuth: (options: TEmbeddedAuthOptions) => {
10
+ isAuthenticating: boolean;
11
+ isAuthenticated: boolean;
12
+ token: string | undefined;
13
+ user: IUser | undefined;
14
+ supportedRegions: IRegion[];
15
+ signIn: (params: ISignInParams) => Promise<{
16
+ success: boolean;
17
+ data: IAuthData;
18
+ message?: undefined;
19
+ } | {
20
+ success: boolean;
21
+ message: any;
22
+ data?: undefined;
23
+ }>;
24
+ signUp: (params: ISignUpParams) => Promise<{
25
+ success: boolean;
26
+ data: IAuthData;
27
+ message?: undefined;
28
+ } | {
29
+ success: boolean;
30
+ message: any;
31
+ data?: undefined;
32
+ }>;
33
+ signOut: () => void;
34
+ resendVerificationEmail: (params: IResendVerificationEmailParams) => Promise<any>;
35
+ setTokens: (accessToken: string, refreshToken: string) => void;
36
+ };
37
+ export {};
@@ -0,0 +1,17 @@
1
+ import { IAuthData } from '../../services/account/AccountServices.types';
2
+ import { EAuthFlow } from '../../types/EAuthFlow';
3
+ interface IEmbeddedAuthOptionsBase {
4
+ authFlow: EAuthFlow;
5
+ trustedOrigins: string[];
6
+ includeDebugLogs?: boolean;
7
+ }
8
+ interface IEmbeddedAuthWithSyncSuccess extends IEmbeddedAuthOptionsBase {
9
+ onSuccess: (authData: IAuthData) => void;
10
+ onSuccessAsync?: never;
11
+ }
12
+ interface IEmbeddedAuthWithAsyncSuccess extends IEmbeddedAuthOptionsBase {
13
+ onSuccess?: never;
14
+ onSuccessAsync: (authData: IAuthData) => Promise<void>;
15
+ }
16
+ export type TEmbeddedAuthOptions = IEmbeddedAuthWithSyncSuccess | IEmbeddedAuthWithAsyncSuccess;
17
+ export {};
@@ -0,0 +1,2 @@
1
+ import { IAwayzContext } from '../context/AwayzContext';
2
+ export declare const useAwayzContext: () => IAwayzContext;
@@ -0,0 +1,6 @@
1
+ export * from './providers/AwayzProvider';
2
+ export * from './hooks/useAwayzContext';
3
+ export * from './types';
4
+ export * from './services/instance';
5
+ export * from './configs/awayzClient';
6
+ export { getBaseUrl } from './configs/baseUrl';
@@ -0,0 +1,12 @@
1
+ import { default as React } from 'react';
2
+ import { IAwayzConfig } from '../configs/awayzConfig';
3
+ interface IAwayzProviderProps {
4
+ children: React.ReactNode;
5
+ config: IAwayzConfig;
6
+ }
7
+ /**
8
+ * In order for the Awayz components to work, you need to wrap your app with this provider.
9
+ * The Provider is responsible for initializing the authentication flow and providing the necessary context to the rest of the components.
10
+ */
11
+ export declare const AwayzProvider: ({ children, config }: IAwayzProviderProps) => import("react/jsx-runtime").JSX.Element;
12
+ export {};
@@ -0,0 +1,84 @@
1
+ import { IAuthData, IRegion, IResendVerificationEmailParams, ISearchLimitResponse, IUser } from './AccountServices.types';
2
+ import { TServiceResponse } from '@type-op/shared';
3
+ import { ISignInParams, ISignUpParams } from '../../types/auth';
4
+ export interface IClientUser {
5
+ _id: string;
6
+ email_address: string;
7
+ user_region: string;
8
+ client_id: string;
9
+ client_user_id: string;
10
+ __v: number;
11
+ }
12
+ /**
13
+ * AccountService provides methods for user authentication and account management.
14
+ */
15
+ declare class _AccountService {
16
+ /**
17
+ * Logs in a user with the provided email and password.
18
+ *
19
+ * @param params - The sign-in parameters containing email and password.
20
+ * @returns A promise that resolves to a service response containing authentication data.
21
+ */
22
+ login: (params: ISignInParams) => Promise<{
23
+ success: boolean;
24
+ data: IAuthData;
25
+ message?: undefined;
26
+ } | {
27
+ success: boolean;
28
+ message: any;
29
+ data?: undefined;
30
+ }>;
31
+ /**
32
+ * Registers a new user with the provided email, password, and region.
33
+ *
34
+ * @param params - The sign-up parameters containing email, password, and region.
35
+ * @returns A promise that resolves to a service response containing authentication data.
36
+ */
37
+ signUp: (params: ISignUpParams) => Promise<{
38
+ success: boolean;
39
+ data: IAuthData;
40
+ message?: undefined;
41
+ } | {
42
+ success: boolean;
43
+ message: any;
44
+ data?: undefined;
45
+ }>;
46
+ resendVerificationEmail: (params: IResendVerificationEmailParams) => Promise<any>;
47
+ /**
48
+ * Authenticates a user using an ID token.
49
+ *
50
+ * @param idToken - The ID token to authenticate with.
51
+ * @returns A promise that resolves to a service response containing authentication data.
52
+ */
53
+ authenticateWithToken: (idToken: string) => Promise<TServiceResponse<IAuthData>>;
54
+ /**
55
+ * If token is available in local storage, check if it is valid and return user details
56
+ *
57
+ * @returns A promise that resolves to a service response containing the user details.
58
+ */
59
+ checkUser: () => Promise<TServiceResponse<IUser>>;
60
+ /**
61
+ * @description In the case of a 401 error, the refresh token is used to get a new access token and user details
62
+ *
63
+ * @param refreshToken - The refresh token
64
+ */
65
+ refreshToken: (refreshToken: string) => Promise<TServiceResponse<{
66
+ user: IUser;
67
+ token: string;
68
+ id_token: string;
69
+ }>>;
70
+ /**
71
+ * Retrieves the request limit for the authenticated user.
72
+ *
73
+ * @returns A promise that resolves to a service response containing the request limit data.
74
+ */
75
+ getRequestLimit: () => Promise<TServiceResponse<ISearchLimitResponse[]>>;
76
+ /**
77
+ * Retrieves the regions available for user registration.
78
+ *
79
+ * @returns A promise that resolves to a service response containing the available regions.
80
+ */
81
+ getRegions: () => Promise<IRegion[]>;
82
+ }
83
+ export declare const AccountService: _AccountService;
84
+ export {};
@@ -0,0 +1,152 @@
1
+ import { ESearchLimitType } from '@type-op/shared';
2
+ export interface ISignUpResponse {
3
+ success: boolean;
4
+ message: string;
5
+ user?: IUser;
6
+ token?: string;
7
+ }
8
+ /**
9
+ * @description - the awayz user after being mapped from backend response to desired shape
10
+ */
11
+ export interface IUser {
12
+ id: string;
13
+ emailAddress: string;
14
+ emailVerified: boolean;
15
+ clientId: string;
16
+ clientUserId: string;
17
+ userRegion: IRegion;
18
+ account: IAccount;
19
+ }
20
+ export interface IAccount {
21
+ emailAddress: string;
22
+ password: string;
23
+ accountType: string;
24
+ priceId: string;
25
+ successUrl: string;
26
+ cancelUrl: string;
27
+ coupon?: string;
28
+ userRegion: string;
29
+ userSourceId?: string;
30
+ }
31
+ export interface IResetPasswordParams {
32
+ email: string;
33
+ password: string;
34
+ confirm_password: string;
35
+ code: string;
36
+ }
37
+ export interface IForgotPasswordResponse {
38
+ success: boolean;
39
+ message: string;
40
+ token: string;
41
+ }
42
+ export interface ISignInResponse {
43
+ success: boolean;
44
+ message: string;
45
+ data: IAuthDataResponse | null;
46
+ }
47
+ export interface IAuthDataResponse {
48
+ user: IUserResponse;
49
+ accessToken?: string;
50
+ refreshToken?: string;
51
+ }
52
+ export interface IAuthData {
53
+ user: IUser;
54
+ token?: string;
55
+ refreshToken?: string;
56
+ }
57
+ export interface IResendVerificationEmailParams {
58
+ email: string;
59
+ successUrl: string;
60
+ cancelUrl: string;
61
+ }
62
+ export interface IUserResponse {
63
+ email_address: string;
64
+ user_region: string;
65
+ client_id: string;
66
+ email_verified: boolean;
67
+ _id: string;
68
+ }
69
+ export interface ISubscription {
70
+ tier: string;
71
+ flight_search_limit: number;
72
+ hotel_search_limit: number;
73
+ is_paid: boolean;
74
+ _id: string;
75
+ }
76
+ export interface ISpendingBreakdown {
77
+ Internet: number;
78
+ Restaurants: number;
79
+ Airfare: number;
80
+ nonAirTravel: number;
81
+ Gas: number;
82
+ Other: number;
83
+ Groceries: number;
84
+ Rent: number;
85
+ }
86
+ export interface IAwayzAccess {
87
+ id: string;
88
+ details: IDetails;
89
+ customer_id: string;
90
+ cancel_at_period_end: boolean;
91
+ active: boolean;
92
+ awayz_gold: boolean;
93
+ awayz_premium: boolean;
94
+ awayz_enum: string;
95
+ }
96
+ export interface IDetails {
97
+ si_id: string;
98
+ current_period_end: number;
99
+ current_period_start: number;
100
+ interval: string;
101
+ interval_count: number;
102
+ amount: number;
103
+ price_id: string;
104
+ product_id: string;
105
+ discount_amount: number;
106
+ original_amount: any;
107
+ }
108
+ export interface ICheckUserResponse {
109
+ success: boolean;
110
+ userVeri: IUser | null;
111
+ userData: any;
112
+ message?: string;
113
+ }
114
+ export interface IRegion {
115
+ id: string;
116
+ name: string;
117
+ code: string;
118
+ currency: string;
119
+ flagIcon: string;
120
+ isActive: boolean;
121
+ }
122
+ export interface IRegionResponse {
123
+ _id: string;
124
+ name: string;
125
+ code: string;
126
+ currency: string;
127
+ flag_icon: string;
128
+ is_active: boolean;
129
+ }
130
+ export declare enum ESource {
131
+ CODE = "code",
132
+ OFFER = "offer"
133
+ }
134
+ export interface IAccountResponse {
135
+ email_address: string;
136
+ password: string;
137
+ account_type: string;
138
+ price_id: string;
139
+ success_url: string;
140
+ cancel_url: string;
141
+ coupon?: string;
142
+ user_region: string;
143
+ user_source_id?: string;
144
+ }
145
+ export interface ISearchLimitResponse {
146
+ search_type: ESearchLimitType;
147
+ subscription: string;
148
+ is_admin: boolean;
149
+ search_limit: number;
150
+ number_of_calls: number;
151
+ remaining_calls: number;
152
+ }