@frontegg/redux-store 7.39.0 → 7.40.0-alpha.1

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 (47) hide show
  1. package/auth/AcceptInvitationState/interfaces.d.ts +2 -1
  2. package/auth/ApiTokensState/interfaces.d.ts +2 -2
  3. package/auth/ApplicationsState/interfaces.d.ts +2 -2
  4. package/auth/CustomLoginState/interfaces.d.ts +2 -1
  5. package/auth/GroupsState/interfaces.d.ts +2 -2
  6. package/auth/ImpersonateState/interfaces.d.ts +2 -2
  7. package/auth/LoginState/interfaces.d.ts +2 -2
  8. package/auth/MSP/interfaces/stateTypes.d.ts +3 -3
  9. package/auth/PasskeysState/interfaces.d.ts +2 -2
  10. package/auth/RolesState/interfaces.d.ts +2 -2
  11. package/auth/SSOState/interfaces.d.ts +2 -2
  12. package/auth/Security/SecurityCenterState/interfaces.d.ts +2 -2
  13. package/auth/SignUpState/interfaces.d.ts +2 -2
  14. package/auth/SmsState/interfaces.d.ts +2 -2
  15. package/auth/SocialLoginState/interfaces.d.ts +2 -2
  16. package/auth/TeamState/interfaces.d.ts +5 -5
  17. package/connectivity/interfaces.d.ts +13 -5
  18. package/helpers/handlers.d.ts +3 -1
  19. package/helpers/handlers.js +5 -3
  20. package/index.js +1 -1
  21. package/interfaces.d.ts +5 -5
  22. package/mocks/subscriptions-mocks/billingActions-mocks/paymentMethodActions.mocks.d.ts +1 -1
  23. package/mocks/subscriptions-mocks/billingActions-mocks/subscriptionActions.mocks.d.ts +2 -2
  24. package/mocks/subscriptions-mocks/checkoutActions.mocks.d.ts +1 -1
  25. package/mocks/subscriptions-mocks/vendorPublicConfigActions.mocks.d.ts +1 -1
  26. package/node/helpers/handlers.js +6 -3
  27. package/node/index.js +1 -1
  28. package/node/subscriptions/Billing/Information/actions.js +2 -1
  29. package/node/subscriptions/Billing/Subscription/actions.js +5 -5
  30. package/node/subscriptions/Checkout/actions.js +1 -1
  31. package/package.json +2 -2
  32. package/subscriptions/Billing/Information/actions.js +2 -1
  33. package/subscriptions/Billing/Information/interfaces.d.ts +2 -2
  34. package/subscriptions/Billing/Invoices/interfaces.d.ts +3 -2
  35. package/subscriptions/Billing/PaymentMethod/actions.d.ts +2 -2
  36. package/subscriptions/Billing/PaymentMethod/interfaces.d.ts +4 -4
  37. package/subscriptions/Billing/Subscription/actions.d.ts +3 -2
  38. package/subscriptions/Billing/Subscription/actions.js +6 -6
  39. package/subscriptions/Billing/Subscription/interfaces.d.ts +4 -4
  40. package/subscriptions/Checkout/actions.d.ts +2 -1
  41. package/subscriptions/Checkout/actions.js +2 -2
  42. package/subscriptions/Checkout/interfaces.d.ts +2 -1
  43. package/subscriptions/Config/interfaces.d.ts +2 -1
  44. package/subscriptions/Plans/interfaces.d.ts +2 -1
  45. package/subscriptions/Stripe/interfaces.d.ts +2 -1
  46. package/subscriptions/VendorPublicConfig/actions.d.ts +2 -1
  47. package/subscriptions/VendorPublicConfig/interfaces.d.ts +2 -2
@@ -1,3 +1,4 @@
1
+ import { FronteggApiError } from '@frontegg/rest-api';
1
2
  export declare enum AcceptInvitationStep {
2
3
  'validate' = "validate",
3
4
  'invalid' = "invalid",
@@ -6,6 +7,6 @@ export declare enum AcceptInvitationStep {
6
7
  'failed' = "failed"
7
8
  }
8
9
  export interface AcceptInvitationState {
9
- error?: string;
10
+ error?: FronteggApiError;
10
11
  step: AcceptInvitationStep;
11
12
  }
@@ -1,4 +1,4 @@
1
- import { ITeamUserPermission, ITeamUserRole, MachineToMachineAuthStrategy } from '@frontegg/rest-api';
1
+ import { FronteggApiError, ITeamUserPermission, ITeamUserRole, MachineToMachineAuthStrategy } from '@frontegg/rest-api';
2
2
  import { LoaderIndicatorState, WithCallback } from '../../interfaces';
3
3
  export interface ApiTokensState {
4
4
  loaders: LoaderIndicatorState<ApiStateKeys>;
@@ -52,7 +52,7 @@ export interface ITenantApiAccessTokensData {
52
52
  }
53
53
  export type ApiStateIndicator = {
54
54
  key: ApiStateKeys;
55
- value: string | boolean;
55
+ value: string | boolean | FronteggApiError;
56
56
  };
57
57
  export declare enum ApiStateKeys {
58
58
  LOAD_API_TOKENS = "LOAD_API_TOKENS",
@@ -1,6 +1,6 @@
1
- import { IApplicationsResponse, IAssignUserToApplicationsBody } from '@frontegg/rest-api';
1
+ import { FronteggApiError, IApplicationsResponse, IAssignUserToApplicationsBody } from '@frontegg/rest-api';
2
2
  export interface ApplicationsState {
3
- error?: string | null;
3
+ error?: FronteggApiError | null | string;
4
4
  fetching?: boolean;
5
5
  loading?: boolean;
6
6
  saving?: boolean;
@@ -1,5 +1,6 @@
1
+ import { FronteggApiError } from '@frontegg/rest-api';
1
2
  export interface CustomLoginState {
2
- error?: string | null;
3
+ error?: FronteggApiError | string | null;
3
4
  loading?: boolean;
4
5
  saving?: boolean;
5
6
  customLoginSearchParams?: string;
@@ -1,5 +1,5 @@
1
1
  import { LoaderIndicatorState, WithCallback } from '../../interfaces';
2
- import type { IGroupConfigResponse, IGroupResponse, IGetGroup, ICreateGroup, IUpdateGroup, IUpdateGroupRoles, IUpdateGroupUsers, IUpdateGroupConfig, IGroupUser, ITeamUser } from '@frontegg/rest-api';
2
+ import type { IGroupConfigResponse, IGroupResponse, IGetGroup, ICreateGroup, IUpdateGroup, IUpdateGroupRoles, IUpdateGroupUsers, IUpdateGroupConfig, IGroupUser, ITeamUser, FronteggApiError } from '@frontegg/rest-api';
3
3
  import { IGetUsersV2Payload } from '../TeamState/interfaces';
4
4
  export declare enum GroupsStateKeys {
5
5
  CREATE_GROUP = "CREATE_GROUP",
@@ -17,7 +17,7 @@ export declare enum GroupsStateKeys {
17
17
  }
18
18
  export type GroupsStateIndicator = {
19
19
  key: GroupsStateKeys;
20
- value: string | boolean;
20
+ value: string | boolean | FronteggApiError;
21
21
  };
22
22
  export type IGroup = IGroupResponse;
23
23
  export type IGroupConfig = IGroupConfigResponse;
@@ -1,4 +1,4 @@
1
- import type { IImpersonate } from '@frontegg/rest-api';
1
+ import type { FronteggApiError, IImpersonate } from '@frontegg/rest-api';
2
2
  import type { CustomEventsOptions } from '../interfaces';
3
3
  export declare enum ImpersonateStep {
4
4
  'impersonating' = "impersonating",
@@ -6,7 +6,7 @@ export declare enum ImpersonateStep {
6
6
  }
7
7
  export interface ImpersonateState {
8
8
  loading: boolean;
9
- error?: string | null;
9
+ error?: FronteggApiError | null;
10
10
  step: ImpersonateStep;
11
11
  }
12
12
  export interface IImpersonatePayload extends IImpersonate {
@@ -1,4 +1,4 @@
1
- import { AuthStrategyEnum, IEnrollMFAWebAuthn, ILoginResponse, IPasswordlessPostLogin, IRecoverMFAToken, ITenantsResponse, IVerifyMFAWebAuthn, IVerifyNewWebAuthnDevice, IWebAuthnPostLogin } from '@frontegg/rest-api';
1
+ import { AuthStrategyEnum, FronteggApiError, IEnrollMFAWebAuthn, ILoginResponse, IPasswordlessPostLogin, IRecoverMFAToken, ITenantsResponse, IVerifyMFAWebAuthn, IVerifyNewWebAuthnDevice, IWebAuthnPostLogin } from '@frontegg/rest-api';
2
2
  import { WithCallback } from '../../interfaces';
3
3
  import { CustomEventsOptions } from '../interfaces';
4
4
  export declare enum LoginStep {
@@ -42,7 +42,7 @@ export interface LoginState {
42
42
  allowRememberMfaDevice?: boolean;
43
43
  mfaDeviceExpiration?: number;
44
44
  inviteTokenTenantName?: string;
45
- inviteTokenError?: string;
45
+ inviteTokenError?: FronteggApiError | string;
46
46
  isNewUser?: boolean;
47
47
  phoneNumber?: string;
48
48
  quickLoginToRegister?: QuickLoginStrategy;
@@ -1,4 +1,4 @@
1
- import { IRole, ITeamUser, IUsersV3Data, ISettingsResponse, GetUserJwtResponseDto, SearchSubTenantsParams, FronteggPaginationLinks, ISearchUserQueryParamsV3, IGetTenantsUserCountResponse, UpdateSubAccountAccessRequestDto, UpdateUserRolesForSubTenantsRequestDto, UpdateSubTenantManagementRequest, SubAccountAccessTypeEnum, UpdateSubTenantHierarchySettingsRequest } from '@frontegg/rest-api';
1
+ import { IRole, ITeamUser, IUsersV3Data, ISettingsResponse, GetUserJwtResponseDto, SearchSubTenantsParams, FronteggPaginationLinks, ISearchUserQueryParamsV3, IGetTenantsUserCountResponse, UpdateSubAccountAccessRequestDto, UpdateUserRolesForSubTenantsRequestDto, UpdateSubTenantManagementRequest, SubAccountAccessTypeEnum, UpdateSubTenantHierarchySettingsRequest, FronteggApiError } from '@frontegg/rest-api';
2
2
  import { LoaderIndicatorState, WithCallback } from '../../../interfaces';
3
3
  import { IParentTenant, GetUserJwtRequestDto, CreateSubTenantRequest, UpdateSubTenantRequest, AddUsersToSubTenantRequest, UpdateSubTenantRequestParams, RemoveUserFromSubTenantsRequest, RemoveUserFromSubTenantsRequestTenantDto } from '@frontegg/rest-api';
4
4
  export declare enum AllAccountsStateKeys {
@@ -73,7 +73,7 @@ export type TSetUserRolesForSubAccountRequest = UpdateUserRolesForSubTenantsRequ
73
73
  export type TRootLevelAccount = Omit<TAccountsTree, 'children'>;
74
74
  export type AllAccountsStateIndicator = {
75
75
  key: AllAccountsStateKeys;
76
- value: boolean | string;
76
+ value: boolean | string | FronteggApiError;
77
77
  };
78
78
  export type TUpdateSubAccountAccessForUser = UpdateSubAccountAccessRequestDto & UpdateSubAccountAccessRequestDto & {
79
79
  userId: string;
@@ -83,7 +83,7 @@ export type TLoadNumberOfUsersForSelectedSubAccount = {
83
83
  };
84
84
  export interface IAllAccountsState {
85
85
  loaders: LoaderIndicatorState<AllAccountsStateKeys>;
86
- errors: LoaderIndicatorState<AllAccountsStateKeys>;
86
+ errors: LoaderIndicatorState<AllAccountsStateKeys, FronteggApiError>;
87
87
  accounts: TAccountsTree;
88
88
  accountsQueryParams: TAccountsQueryParams;
89
89
  searchAccountsData: Omit<TAccountsTree, 'children'>[];
@@ -1,6 +1,6 @@
1
- import { IWebAuthnDevice } from '@frontegg/rest-api';
1
+ import { FronteggApiError, IWebAuthnDevice } from '@frontegg/rest-api';
2
2
  export interface PasskeysState {
3
3
  devices: IWebAuthnDevice[];
4
4
  loading: boolean;
5
- error: string | null;
5
+ error: FronteggApiError | null;
6
6
  }
@@ -1,4 +1,4 @@
1
- import { IRole, IRolePermission, IRolePermissionCategory } from '@frontegg/rest-api';
1
+ import { FronteggApiError, IRole, IRolePermission, IRolePermissionCategory } from '@frontegg/rest-api';
2
2
  import { ErrorsIndicatorState, LoaderIndicatorState } from '../../interfaces';
3
3
  export declare enum RolesStateKeys {
4
4
  EDIT_ROLE_DIALOG = "editRoleDialog",
@@ -9,7 +9,7 @@ export declare enum RolesStateKeys {
9
9
  }
10
10
  export type RolesStateIndicator = {
11
11
  key: RolesStateKeys;
12
- value: boolean | string;
12
+ value: boolean | string | FronteggApiError;
13
13
  };
14
14
  export type RolesState = {
15
15
  roles: IRole[];
@@ -1,4 +1,4 @@
1
- import { ICreateSamlGroup, ISamlConfiguration, ISamlRolesGroup, IOidcConfiguration, ITeamUserRole, ICreateSSODomain, ISSODomain, IUpdateSamlConfiguration, ISamlMetadata, IUpdateSSOConfiguration, ISSOConfiguration, IUpdateSamlGroup } from '@frontegg/rest-api';
1
+ import { ICreateSamlGroup, ISamlConfiguration, ISamlRolesGroup, IOidcConfiguration, ITeamUserRole, ICreateSSODomain, ISSODomain, IUpdateSamlConfiguration, ISamlMetadata, IUpdateSSOConfiguration, ISSOConfiguration, IUpdateSamlGroup, FronteggApiError } from '@frontegg/rest-api';
2
2
  import { WithCallback } from '../../interfaces';
3
3
  export type { ISSOConfiguration, ISSODomain };
4
4
  export interface SSOState {
@@ -18,7 +18,7 @@ export interface SSOState {
18
18
  }
19
19
  export type SSOStateIndicator = {
20
20
  key: SSOStateKeys;
21
- value: string | boolean;
21
+ value: string | boolean | FronteggApiError;
22
22
  };
23
23
  export declare enum SSOStateKeys {
24
24
  LOAD_SSO_CONFIGURATIONS = "LOAD_SSO_CONFIGURATIONS",
@@ -1,4 +1,4 @@
1
- import { Insight, Recommendation } from '@frontegg/rest-api';
1
+ import { FronteggApiError, Insight, Recommendation } from '@frontegg/rest-api';
2
2
  import { ErrorsIndicatorState, LoaderIndicatorState } from '../../../interfaces';
3
3
  import { ISearchUserQueryParamsV3 } from '@frontegg/rest-api';
4
4
  import { IUserV3 } from '../../TeamState/interfaces';
@@ -23,7 +23,7 @@ export declare enum SecurityCenterStateKeys {
23
23
  }
24
24
  export type SecurityCenterStateIndicator = {
25
25
  key: SecurityCenterStateKeys;
26
- value: boolean | string;
26
+ value: boolean | FronteggApiError;
27
27
  };
28
28
  export interface ISecurityCenterTable {
29
29
  users?: IUserV3[];
@@ -1,10 +1,10 @@
1
- import { ISignUpUser } from '@frontegg/rest-api';
1
+ import { FronteggApiError, ISignUpUser } from '@frontegg/rest-api';
2
2
  import { CustomEventsOptions } from '../interfaces';
3
3
  export interface SignUpState {
4
4
  loading: boolean;
5
5
  allowSignUps: boolean;
6
6
  allowNotVerifiedUsersLogin: boolean;
7
- error?: string;
7
+ error?: FronteggApiError;
8
8
  errorTraceId?: string | null;
9
9
  firstLoad: boolean;
10
10
  shouldActivate?: boolean;
@@ -1,10 +1,10 @@
1
- import { IPhoneNumber } from '@frontegg/rest-api';
1
+ import { FronteggApiError, IPhoneNumber } from '@frontegg/rest-api';
2
2
  export interface IPhoneId {
3
3
  phoneId: string;
4
4
  }
5
5
  export interface SmsState {
6
6
  loading: boolean;
7
- error: string | null;
7
+ error: FronteggApiError | null;
8
8
  phoneNumbers?: IPhoneNumber[];
9
9
  otcToken?: string;
10
10
  }
@@ -1,4 +1,4 @@
1
- import { ICustomSocialLoginProviderConfigurationV1, ILoginViaSocialLogin, ISocialLoginProviderConfiguration, ISocialLoginProviderConfigurationV2 } from '@frontegg/rest-api';
1
+ import { FronteggApiError, ICustomSocialLoginProviderConfigurationV1, ILoginViaSocialLogin, ISocialLoginProviderConfiguration, ISocialLoginProviderConfigurationV2 } from '@frontegg/rest-api';
2
2
  import { CustomEventsOptions } from '../interfaces';
3
3
  export interface SocialLoginState {
4
4
  firstLoad: boolean;
@@ -6,7 +6,7 @@ export interface SocialLoginState {
6
6
  socialLoginsConfig?: ISocialLoginProviderConfiguration[];
7
7
  socialLoginsConfigV2?: ISocialLoginProviderConfigurationV2[];
8
8
  customSocialLoginsConfig?: ICustomSocialLoginProviderConfigurationV1['providers'];
9
- error?: string;
9
+ error?: FronteggApiError | string;
10
10
  }
11
11
  export interface ILoginViaSocialLoginPayload extends ILoginViaSocialLogin {
12
12
  events?: CustomEventsOptions;
@@ -1,4 +1,4 @@
1
- import { ITeamUserRole, ITeamUser, ITeamUserPermission, ISubTenantUser, SortByEnum, ISearchUserQueryParamsV2, QueryFilter, QuerySort, IRole, IUsersV3Data, ITemporaryUserConfiguration, IAddUser } from '@frontegg/rest-api';
1
+ import { ITeamUserRole, ITeamUser, ITeamUserPermission, ISubTenantUser, SortByEnum, ISearchUserQueryParamsV2, QueryFilter, QuerySort, IRole, IUsersV3Data, ITemporaryUserConfiguration, IAddUser, FronteggApiError } from '@frontegg/rest-api';
2
2
  import { GroupsState } from '../GroupsState/interfaces';
3
3
  import { LoaderIndicatorState, WithCallback } from '../../interfaces';
4
4
  import { ApplicationsState } from '../ApplicationsState/interfaces';
@@ -20,7 +20,7 @@ export declare enum TeamStateKeys {
20
20
  }
21
21
  export type TeamStateIndicator = {
22
22
  key: TeamStateKeys;
23
- value: string | boolean;
23
+ value: string | boolean | FronteggApiError;
24
24
  };
25
25
  type BaseDialogState = {
26
26
  open?: boolean;
@@ -28,16 +28,16 @@ type BaseDialogState = {
28
28
  };
29
29
  export type AddUserDialogState = BaseDialogState & {
30
30
  loading?: boolean;
31
- error?: boolean | string;
31
+ error?: boolean | string | FronteggApiError;
32
32
  };
33
33
  export type EnableDisableUserDialogState = BaseDialogState & {
34
34
  loading?: boolean;
35
- error?: string;
35
+ error?: FronteggApiError;
36
36
  };
37
37
  export type ISetAddUserDialog = Omit<AddUserDialogState, 'loading' | 'error' | 'open'>;
38
38
  export type DeleteUserDialogState = BaseDialogState & {
39
39
  loading?: boolean;
40
- error?: boolean | string;
40
+ error?: boolean | FronteggApiError;
41
41
  userId?: string;
42
42
  email?: string;
43
43
  };
@@ -1,4 +1,4 @@
1
- import { ICategory, IChannelsMap, ISlackChannel, ISlackConfigurations, IWebhookLogsResponse, IWebhooksConfigurations, IEmailSMSConfigResponse, ISlackEvent, IEmailSMSSubscriptionResponse, IWebhooksSaveData } from '@frontegg/rest-api';
1
+ import { ICategory, IChannelsMap, ISlackChannel, ISlackConfigurations, IWebhookLogsResponse, IWebhooksConfigurations, IEmailSMSConfigResponse, ISlackEvent, IEmailSMSSubscriptionResponse, IWebhooksSaveData, FronteggApiError } from '@frontegg/rest-api';
2
2
  export type TPlatform = 'slack' | 'email' | 'sms' | 'webhook';
3
3
  export type TWebhookStatus = 'success' | 'failed' | undefined;
4
4
  export type TWebhookImage = 'sms' | 'email' | 'slack' | 'webhook';
@@ -16,10 +16,10 @@ export interface ConnectivityState {
16
16
  webhook?: IWebhooksConfigurations[];
17
17
  categories?: ICategory[];
18
18
  channelMap?: Record<TPlatform, IChannelsMap[]>;
19
- error?: string;
19
+ error?: FronteggApiError;
20
20
  processIds: string[];
21
21
  slackChannels: {
22
- error?: string;
22
+ error?: FronteggApiError;
23
23
  isLoading: boolean;
24
24
  isLoadingScope?: boolean;
25
25
  data?: ISlackChannel[];
@@ -45,10 +45,18 @@ export type IConnectivityData = ConnectivityData;
45
45
  export interface IRootPath {
46
46
  rootPath?: string;
47
47
  }
48
- export interface IWebhookTestResult {
48
+ export type TBaseWebhookResult = {
49
49
  status: TWebhookStatus;
50
+ };
51
+ export type IWebhookTestResult = {
52
+ status: 'failed';
53
+ message?: FronteggApiError;
54
+ } | {
55
+ status: 'success';
50
56
  message?: string;
51
- }
57
+ } | {
58
+ status: undefined;
59
+ };
52
60
  export interface IWebhookRetryResult {
53
61
  [k: string]: {
54
62
  isProcess: boolean;
@@ -1,2 +1,4 @@
1
+ import { FronteggApiError } from '@frontegg/rest-api';
2
+ export declare const isFronteggApiError: (error: unknown | Error | FronteggApiError) => error is FronteggApiError;
1
3
  export declare const isError: (error: any) => error is Error;
2
- export declare const errorHandler: <T>(error: unknown, fallback?: T) => string | T;
4
+ export declare const errorHandler: <T>(error: unknown, fallback?: T) => FronteggApiError | T;
@@ -1,4 +1,5 @@
1
- const isFronteggApiError = error => Boolean(error == null ? void 0 : error.statusCode);
1
+ import { FronteggApiError } from '@frontegg/rest-api';
2
+ export const isFronteggApiError = error => Boolean(error == null ? void 0 : error.statusCode);
2
3
  export const isError = error => {
3
4
  if (error instanceof Error) {
4
5
  return true;
@@ -13,12 +14,13 @@ export const errorHandler = (error, fallback) => {
13
14
  return fallback;
14
15
  }
15
16
  if (isFronteggApiError(error)) {
16
- return error.message;
17
+ console.error(error.message);
18
+ return error;
17
19
  }
18
20
  if (isError(error)) {
19
21
  console.error(error.message);
20
22
  } else if (typeof error === 'string') {
21
23
  console.error(error);
22
24
  }
23
- return fallback != null ? fallback : GENERIC_ERROR_MESSAGE;
25
+ return fallback != null ? fallback : new FronteggApiError(GENERIC_ERROR_MESSAGE, 500, null);
24
26
  };
package/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /** @license Frontegg v7.39.0
1
+ /** @license Frontegg v7.40.0-alpha.1
2
2
  *
3
3
  * This source code is licensed under the MIT license found in the
4
4
  * LICENSE file in the root directory of this source tree.
package/interfaces.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { api, ContextOptions, fetch } from '@frontegg/rest-api';
1
+ import { api, ContextOptions, fetch, FronteggApiError } from '@frontegg/rest-api';
2
2
  import { AuthActions, AuthStateActions } from './auth';
3
3
  import type { AuthState } from './auth/interfaces';
4
4
  import type { ConnectivityActions } from './connectivity';
@@ -81,7 +81,7 @@ export type SharedActions = any;
81
81
  export type RestApi = typeof api & {
82
82
  fetch: typeof fetch;
83
83
  };
84
- export type CallbackMethod<R = boolean> = (data: R | null, error?: string | any | unknown) => void;
84
+ export type CallbackMethod<R = boolean> = (data: R | null, error?: FronteggApiError | any | unknown) => void;
85
85
  export type WithCallback<T = object, R = boolean> = T & {
86
86
  callback?: CallbackMethod<R>;
87
87
  };
@@ -104,11 +104,11 @@ export type WithId<T = object> = T & {
104
104
  export type WithSilentLoad<T = {}> = T & {
105
105
  silentLoading?: boolean;
106
106
  };
107
- export type LoaderIndicatorState<T extends string> = Partial<{
108
- [key in T]: string | boolean;
107
+ export type LoaderIndicatorState<T extends string, V = string | boolean> = Partial<{
108
+ [key in T]: V;
109
109
  }>;
110
110
  export type ErrorsIndicatorState<T extends string> = Partial<{
111
- [key in T]: string | boolean;
111
+ [key in T]: FronteggApiError | boolean;
112
112
  }>;
113
113
  export type DeepPartial<T> = {
114
114
  [P in keyof T]?: T[P] extends any[] | undefined ? T[P] : T[P] extends Function ? T[P] : T[P] extends object | undefined ? Partial<T[P]> : T[P];
@@ -4,7 +4,7 @@ declare const _default: (store: FronteggState, api: RestApi, actions: SharedActi
4
4
  resetBillingPaymentMethodState: () => void;
5
5
  loadPaymentMethod: () => Promise<void>;
6
6
  submitPaymentMethod: () => Promise<void>;
7
- submitPaymentMethodError: (error: string) => Promise<void>;
7
+ submitPaymentMethodError: (error: import("dist/@frontegg/rest-api").FronteggApiError) => Promise<void>;
8
8
  submitPaymentMethodSuccess: () => Promise<void>;
9
9
  updatePaymentMethodBillingDetails: (payload: import("../../../interfaces").WithCallback<import("../../../interfaces").WithId<import("dist/@frontegg/rest-api").ISubscriptionUpdatePaymentMethodBillingDetails>>) => Promise<void>;
10
10
  };
@@ -3,9 +3,9 @@ declare const _default: (store: FronteggState, api: RestApi, actions: SharedActi
3
3
  setBillingSubscriptionState: (state: Partial<{}>) => void;
4
4
  resetBillingSubscriptionState: () => void;
5
5
  setCancellationLoading: (loading: boolean) => void;
6
- setCancellationError: (error: string | null) => void;
6
+ setCancellationError: (error: import("dist/@frontegg/rest-api").FronteggApiError | null) => void;
7
7
  setRenewalLoading: (loading: boolean) => void;
8
- setRenewalError: (error: string | null) => void;
8
+ setRenewalError: (error: import("dist/@frontegg/rest-api").FronteggApiError | null) => void;
9
9
  loadSubscription: () => Promise<void>;
10
10
  loadSubscriptionTenant: () => Promise<void>;
11
11
  cancelSubscription: () => Promise<void>;
@@ -6,6 +6,6 @@ declare const _default: (store: FronteggState, api: RestApi, actions: SharedActi
6
6
  resetCheckout: () => void;
7
7
  submitCheckout: () => void;
8
8
  confirmCheckout: (payload: import("../..").ConfirmCheckoutActionPayload) => Promise<void>;
9
- errorCheckout: (payload: string) => void;
9
+ errorCheckout: (payload: import("dist/@frontegg/rest-api").FronteggApiError) => void;
10
10
  };
11
11
  export default _default;
@@ -2,7 +2,7 @@ import { FronteggState, RestApi, SharedActions } from '../../interfaces';
2
2
  declare const _default: (store: FronteggState, api: RestApi, actions: SharedActions) => {
3
3
  setVendorPublicConfigState: (state: Partial<import("../..").VendorPublicConfigurationState>) => void;
4
4
  resetVendorPublicConfigState: () => void;
5
- setVendorPublicConfigError: (error: string) => void;
5
+ setVendorPublicConfigError: (error: import("dist/@frontegg/rest-api").FronteggApiError) => void;
6
6
  setVendorPublicConfigLoading: (loading: boolean) => void;
7
7
  loadVendorPublicConfiguration: () => Promise<void>;
8
8
  };
@@ -3,8 +3,10 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.isError = exports.errorHandler = void 0;
6
+ exports.isFronteggApiError = exports.isError = exports.errorHandler = void 0;
7
+ var _restApi = require("@frontegg/rest-api");
7
8
  const isFronteggApiError = error => Boolean(error == null ? void 0 : error.statusCode);
9
+ exports.isFronteggApiError = isFronteggApiError;
8
10
  const isError = error => {
9
11
  if (error instanceof Error) {
10
12
  return true;
@@ -20,13 +22,14 @@ const errorHandler = (error, fallback) => {
20
22
  return fallback;
21
23
  }
22
24
  if (isFronteggApiError(error)) {
23
- return error.message;
25
+ console.error(error.message);
26
+ return error;
24
27
  }
25
28
  if (isError(error)) {
26
29
  console.error(error.message);
27
30
  } else if (typeof error === 'string') {
28
31
  console.error(error);
29
32
  }
30
- return fallback != null ? fallback : GENERIC_ERROR_MESSAGE;
33
+ return fallback != null ? fallback : new _restApi.FronteggApiError(GENERIC_ERROR_MESSAGE, 500, null);
31
34
  };
32
35
  exports.errorHandler = errorHandler;
package/node/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /** @license Frontegg v7.39.0
1
+ /** @license Frontegg v7.40.0-alpha.1
2
2
  *
3
3
  * This source code is licensed under the MIT license found in the
4
4
  * LICENSE file in the root directory of this source tree.
@@ -8,6 +8,7 @@ exports.default = void 0;
8
8
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
9
9
  var _state = require("./state");
10
10
  var _helpers = require("../../../helpers");
11
+ var _restApi = require("@frontegg/rest-api");
11
12
  var _interfaces = require("../../interfaces");
12
13
  var _helpers2 = require("../../helpers");
13
14
  var _default = (store, api, sharedActions) => {
@@ -81,7 +82,7 @@ var _default = (store, api, sharedActions) => {
81
82
  const paymentProvider = (_store$subscriptions$ = store.subscriptions.config.config) == null ? void 0 : _store$subscriptions$.paymentProvider;
82
83
  const tenantId = (_store$auth$user = store.auth.user) == null ? void 0 : _store$auth$user.tenantId;
83
84
  if (!paymentProvider || !tenantId) {
84
- setInformationError(!paymentProvider ? 'Internal feature failure' : 'Not authorized');
85
+ setInformationError(new _restApi.FronteggApiError(!paymentProvider ? 'Internal feature failure' : 'Not authorized', 500, null));
85
86
  return;
86
87
  }
87
88
  await loadSummaries(tenantId, forceActive);
@@ -65,7 +65,7 @@ var _default = (store, api, sharedActions) => {
65
65
  var _store$auth$user;
66
66
  const tenantId = (_store$auth$user = store.auth.user) == null ? void 0 : _store$auth$user.tenantId;
67
67
  if (!tenantId) {
68
- __setError('TenantId is not defined');
68
+ __setError(new _restApi.FronteggApiError('TenantId is not defined', 500, null));
69
69
  return;
70
70
  }
71
71
  await actions.loadSummaries(tenantId);
@@ -75,11 +75,11 @@ var _default = (store, api, sharedActions) => {
75
75
  subscription
76
76
  } = store.subscriptions.billing.subscription;
77
77
  if (!subscription) {
78
- setCancellationError('Subscription not found.');
78
+ setCancellationError(new _restApi.FronteggApiError('Subscription not found', 500, null));
79
79
  return;
80
80
  }
81
81
  if (subscription != null && subscription.externallyManaged) {
82
- setCancellationError('Billing is externally managed.');
82
+ setCancellationError(new _restApi.FronteggApiError('Billing is externally managed', 500, null));
83
83
  return;
84
84
  }
85
85
  const {
@@ -104,11 +104,11 @@ var _default = (store, api, sharedActions) => {
104
104
  subscription
105
105
  } = store.subscriptions.billing.subscription;
106
106
  if (!subscription) {
107
- setRenewalError('Subscription not found.');
107
+ setRenewalError(new _restApi.FronteggApiError('Subscription not found', 500, null));
108
108
  return;
109
109
  }
110
110
  if (subscription != null && subscription.externallyManaged) {
111
- setRenewalError('Billing is externally managed');
111
+ setRenewalError(new _restApi.FronteggApiError('Billing is externally managed', 500, null));
112
112
  return;
113
113
  }
114
114
  const {
@@ -50,7 +50,7 @@ var _default = (store, api, sharedActions) => {
50
50
  if (!subscription) {
51
51
  setCheckoutState({
52
52
  loading: false,
53
- error: 'Subscription not found'
53
+ error: new _restApi.FronteggApiError('Subscription not found', 500, null)
54
54
  });
55
55
  return;
56
56
  }
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@frontegg/redux-store",
3
- "version": "7.39.0",
3
+ "version": "7.40.0-alpha.1",
4
4
  "main": "./node/index.js",
5
5
  "license": "MIT",
6
6
  "author": "Frontegg LTD",
7
7
  "dependencies": {
8
8
  "@babel/runtime": "^7.18.6",
9
9
  "@frontegg/entitlements-javascript-commons": "1.1.2",
10
- "@frontegg/rest-api": "7.39.0",
10
+ "@frontegg/rest-api": "7.40.0-alpha.1",
11
11
  "fast-deep-equal": "3.1.3",
12
12
  "get-value": "^3.0.1",
13
13
  "proxy-compare": "^3.0.0",
@@ -1,6 +1,7 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import { initialState } from './state';
3
3
  import { deepResetState, errorHandler } from '../../../helpers';
4
+ import { FronteggApiError } from '@frontegg/rest-api';
4
5
  import { SubscriptionStatus } from '../../interfaces';
5
6
  import { toSubscriptionCancellation, toSubscriptionStatus } from '../../helpers';
6
7
  export default ((store, api, sharedActions) => {
@@ -74,7 +75,7 @@ export default ((store, api, sharedActions) => {
74
75
  const paymentProvider = (_store$subscriptions$ = store.subscriptions.config.config) == null ? void 0 : _store$subscriptions$.paymentProvider;
75
76
  const tenantId = (_store$auth$user = store.auth.user) == null ? void 0 : _store$auth$user.tenantId;
76
77
  if (!paymentProvider || !tenantId) {
77
- setInformationError(!paymentProvider ? 'Internal feature failure' : 'Not authorized');
78
+ setInformationError(new FronteggApiError(!paymentProvider ? 'Internal feature failure' : 'Not authorized', 500, null));
78
79
  return;
79
80
  }
80
81
  await loadSummaries(tenantId, forceActive);
@@ -1,8 +1,8 @@
1
1
  import { Plan } from '../../interfaces';
2
- import { ISubscriptionSummariesResponse } from '@frontegg/rest-api';
2
+ import { FronteggApiError, ISubscriptionSummariesResponse } from '@frontegg/rest-api';
3
3
  export interface BillingInformationState {
4
4
  loading: boolean;
5
- error: string | null;
5
+ error: FronteggApiError | null;
6
6
  fetching: boolean;
7
7
  summary?: ISubscriptionSummariesResponse;
8
8
  plan?: Plan;
@@ -1,12 +1,13 @@
1
+ import { FronteggApiError } from '@frontegg/rest-api';
1
2
  import { Invoice } from '../../interfaces';
2
3
  export interface InvoicesState {
3
4
  loading: boolean;
4
- error: string | null;
5
+ error: FronteggApiError | null;
5
6
  fetching: boolean;
6
7
  invoices: Invoice[];
7
8
  invoiceDownload: {
8
9
  loading: boolean;
9
- error: string | null;
10
+ error: FronteggApiError | null;
10
11
  };
11
12
  }
12
13
  export interface InvoicesActions {
@@ -1,11 +1,11 @@
1
1
  import { FronteggState, RestApi, SharedActions, WithCallback, WithId } from '../../../interfaces';
2
- import { ISubscriptionUpdatePaymentMethodBillingDetails } from '@frontegg/rest-api';
2
+ import { FronteggApiError, ISubscriptionUpdatePaymentMethodBillingDetails } from '@frontegg/rest-api';
3
3
  declare const _default: (store: FronteggState, api: RestApi, sharedActions: SharedActions) => {
4
4
  setBillingPaymentMethodState: (state: Partial<{}>) => void;
5
5
  resetBillingPaymentMethodState: () => void;
6
6
  loadPaymentMethod: () => Promise<void>;
7
7
  submitPaymentMethod: () => Promise<void>;
8
- submitPaymentMethodError: (error: string) => Promise<void>;
8
+ submitPaymentMethodError: (error: FronteggApiError) => Promise<void>;
9
9
  submitPaymentMethodSuccess: () => Promise<void>;
10
10
  updatePaymentMethodBillingDetails: (payload: WithCallback<WithId<ISubscriptionUpdatePaymentMethodBillingDetails>>) => Promise<void>;
11
11
  };
@@ -1,4 +1,4 @@
1
- import { ISubscriptionUpdatePaymentMethodBillingDetails } from '@frontegg/rest-api';
1
+ import { FronteggApiError, ISubscriptionUpdatePaymentMethodBillingDetails } from '@frontegg/rest-api';
2
2
  import { WithCallback } from '../../../interfaces';
3
3
  export type PaymentMethod = {
4
4
  id: string;
@@ -13,7 +13,7 @@ export type PaymentMethod = {
13
13
  };
14
14
  export interface PaymentMethodState {
15
15
  loading: boolean;
16
- error: string | null;
16
+ error: FronteggApiError | null;
17
17
  fetching: boolean;
18
18
  paymentMethod?: PaymentMethod;
19
19
  }
@@ -22,9 +22,9 @@ export interface PaymentMethodActions {
22
22
  updatePaymentMethodBillingDetails: (payload: WithCallback<ISubscriptionUpdatePaymentMethodBillingDetails & {
23
23
  id: string;
24
24
  }>) => void;
25
- setError: (error: string | null) => void;
25
+ setError: (error: FronteggApiError | null) => void;
26
26
  submitPaymentMethod: () => void;
27
- submitPaymentMethodError: (error: string) => void;
27
+ submitPaymentMethodError: (error: FronteggApiError) => void;
28
28
  submitPaymentMethodSuccess: () => void;
29
29
  }
30
30
  export interface BillingDetailsResponse {
@@ -1,11 +1,12 @@
1
1
  import { FronteggState, RestApi, SharedActions } from '../../../interfaces';
2
+ import { FronteggApiError } from '@frontegg/rest-api';
2
3
  declare const _default: (store: FronteggState, api: RestApi, sharedActions: SharedActions) => {
3
4
  setBillingSubscriptionState: (state: Partial<{}>) => void;
4
5
  resetBillingSubscriptionState: () => void;
5
6
  setCancellationLoading: (loading: boolean) => void;
6
- setCancellationError: (error: string | null) => void;
7
+ setCancellationError: (error: FronteggApiError | null) => void;
7
8
  setRenewalLoading: (loading: boolean) => void;
8
- setRenewalError: (error: string | null) => void;
9
+ setRenewalError: (error: FronteggApiError | null) => void;
9
10
  loadSubscription: () => Promise<void>;
10
11
  loadSubscriptionTenant: () => Promise<void>;
11
12
  cancelSubscription: () => Promise<void>;
@@ -1,6 +1,6 @@
1
1
  import { initialState } from './state';
2
2
  import { deepResetState, errorHandler } from '../../../helpers';
3
- import { ISubscriptionCancellationPolicy, ISubscriptionStatus } from '@frontegg/rest-api';
3
+ import { FronteggApiError, ISubscriptionCancellationPolicy, ISubscriptionStatus } from '@frontegg/rest-api';
4
4
  export default ((store, api, sharedActions) => {
5
5
  const actions = sharedActions;
6
6
  const setBillingSubscriptionState = state => {
@@ -59,7 +59,7 @@ export default ((store, api, sharedActions) => {
59
59
  var _store$auth$user;
60
60
  const tenantId = (_store$auth$user = store.auth.user) == null ? void 0 : _store$auth$user.tenantId;
61
61
  if (!tenantId) {
62
- __setError('TenantId is not defined');
62
+ __setError(new FronteggApiError('TenantId is not defined', 500, null));
63
63
  return;
64
64
  }
65
65
  await actions.loadSummaries(tenantId);
@@ -69,11 +69,11 @@ export default ((store, api, sharedActions) => {
69
69
  subscription
70
70
  } = store.subscriptions.billing.subscription;
71
71
  if (!subscription) {
72
- setCancellationError('Subscription not found.');
72
+ setCancellationError(new FronteggApiError('Subscription not found', 500, null));
73
73
  return;
74
74
  }
75
75
  if (subscription != null && subscription.externallyManaged) {
76
- setCancellationError('Billing is externally managed.');
76
+ setCancellationError(new FronteggApiError('Billing is externally managed', 500, null));
77
77
  return;
78
78
  }
79
79
  const {
@@ -98,11 +98,11 @@ export default ((store, api, sharedActions) => {
98
98
  subscription
99
99
  } = store.subscriptions.billing.subscription;
100
100
  if (!subscription) {
101
- setRenewalError('Subscription not found.');
101
+ setRenewalError(new FronteggApiError('Subscription not found', 500, null));
102
102
  return;
103
103
  }
104
104
  if (subscription != null && subscription.externallyManaged) {
105
- setRenewalError('Billing is externally managed');
105
+ setRenewalError(new FronteggApiError('Billing is externally managed', 500, null));
106
106
  return;
107
107
  }
108
108
  const {
@@ -1,15 +1,15 @@
1
- import { ISubscriptionResponse } from '@frontegg/rest-api';
1
+ import { FronteggApiError, ISubscriptionResponse } from '@frontegg/rest-api';
2
2
  export interface SubscriptionState {
3
3
  loading: boolean;
4
- error: string | null;
4
+ error: FronteggApiError | null;
5
5
  fetching: boolean;
6
6
  subscription?: ISubscriptionResponse;
7
7
  cancellation: {
8
8
  loading: boolean;
9
- error: string | null;
9
+ error: FronteggApiError | null;
10
10
  };
11
11
  renewal: {
12
12
  loading: boolean;
13
- error: string | null;
13
+ error: FronteggApiError | null;
14
14
  };
15
15
  }
@@ -1,5 +1,6 @@
1
1
  import { FronteggState, RestApi, SharedActions } from '../../interfaces';
2
2
  import { CheckoutState, ConfirmCheckoutActionPayload } from './interfaces';
3
+ import { FronteggApiError } from '@frontegg/rest-api';
3
4
  declare const _default: (store: FronteggState, api: RestApi, sharedActions: SharedActions) => {
4
5
  setCheckoutState: (state: Partial<CheckoutState>) => void;
5
6
  resetCheckoutState: () => void;
@@ -7,6 +8,6 @@ declare const _default: (store: FronteggState, api: RestApi, sharedActions: Shar
7
8
  resetCheckout: () => void;
8
9
  submitCheckout: () => void;
9
10
  confirmCheckout: (payload: ConfirmCheckoutActionPayload) => Promise<void>;
10
- errorCheckout: (payload: string) => void;
11
+ errorCheckout: (payload: FronteggApiError) => void;
11
12
  };
12
13
  export default _default;
@@ -1,7 +1,7 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import { deepResetState, errorHandler } from '../../helpers';
3
3
  import { initialState } from './state';
4
- import { ISubscriptionStatus } from '@frontegg/rest-api';
4
+ import { FronteggApiError, ISubscriptionStatus } from '@frontegg/rest-api';
5
5
  export default ((store, api, sharedActions) => {
6
6
  const actions = sharedActions;
7
7
  const setCheckoutState = state => {
@@ -43,7 +43,7 @@ export default ((store, api, sharedActions) => {
43
43
  if (!subscription) {
44
44
  setCheckoutState({
45
45
  loading: false,
46
- error: 'Subscription not found'
46
+ error: new FronteggApiError('Subscription not found', 500, null)
47
47
  });
48
48
  return;
49
49
  }
@@ -1,7 +1,8 @@
1
+ import { FronteggApiError } from '@frontegg/rest-api';
1
2
  export interface CheckoutState {
2
3
  fetching: boolean;
3
4
  loading: boolean;
4
- error: string | null;
5
+ error: FronteggApiError | null;
5
6
  confirmed: boolean;
6
7
  }
7
8
  export interface ConfirmCheckoutActionPayload {
@@ -1,3 +1,4 @@
1
+ import { FronteggApiError } from '@frontegg/rest-api';
1
2
  import { PaymentProvider } from '../interfaces';
2
3
  interface StripePaymentProviderConfig {
3
4
  paymentProvider: PaymentProvider.STRIPE;
@@ -6,7 +7,7 @@ interface StripePaymentProviderConfig {
6
7
  type PaymentProviderCustomConfig = StripePaymentProviderConfig;
7
8
  export type PaymentProviderConfigState = {
8
9
  loading: boolean;
9
- error: string | null;
10
+ error: FronteggApiError | null;
10
11
  fetching: boolean;
11
12
  config: PaymentProviderCustomConfig | null;
12
13
  };
@@ -1,7 +1,8 @@
1
+ import { FronteggApiError } from '@frontegg/rest-api';
1
2
  import { Plan } from '../interfaces';
2
3
  export interface PlansState {
3
4
  loading: boolean;
4
- error: string | null;
5
+ error: FronteggApiError | null;
5
6
  fetching: boolean;
6
7
  plans: Plan[];
7
8
  }
@@ -1,6 +1,7 @@
1
+ import { FronteggApiError } from '@frontegg/rest-api';
1
2
  export interface StripeState {
2
3
  loading: boolean;
3
- error: string | null;
4
+ error: FronteggApiError | null;
4
5
  customerId?: string;
5
6
  cardSetupIntentSecret: string | null;
6
7
  }
@@ -1,9 +1,10 @@
1
1
  import { FronteggState, RestApi, SharedActions } from '../../interfaces';
2
2
  import { VendorPublicConfigurationState } from './interfaces';
3
+ import { FronteggApiError } from '@frontegg/rest-api';
3
4
  declare const _default: (store: FronteggState, api: RestApi, sharedActions: SharedActions) => {
4
5
  setVendorPublicConfigState: (state: Partial<VendorPublicConfigurationState>) => void;
5
6
  resetVendorPublicConfigState: () => void;
6
- setVendorPublicConfigError: (error: string) => void;
7
+ setVendorPublicConfigError: (error: FronteggApiError) => void;
7
8
  setVendorPublicConfigLoading: (loading: boolean) => void;
8
9
  loadVendorPublicConfiguration: () => Promise<void>;
9
10
  };
@@ -1,7 +1,7 @@
1
- import { IVendorPublicConfigurationResponse } from '@frontegg/rest-api';
1
+ import { FronteggApiError, IVendorPublicConfigurationResponse } from '@frontegg/rest-api';
2
2
  export interface VendorPublicConfigurationState {
3
3
  loading: boolean;
4
- error?: string;
4
+ error?: FronteggApiError;
5
5
  fetching: boolean;
6
6
  vendorPublicConfig: IVendorPublicConfigurationResponse | null;
7
7
  }