@frontegg/react-hooks 7.78.0-alpha.1 → 7.78.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.
- package/audits/auditLogs.d.ts +3 -2
- package/audits/auditLogs.js +9 -8
- package/audits/auditsMetadata.d.ts +3 -2
- package/audits/auditsMetadata.js +9 -8
- package/audits/hooks.d.ts +9 -2
- package/audits/hooks.js +14 -10
- package/auth/acceptInvitation.d.ts +5 -7
- package/auth/acceptInvitation.js +13 -8
- package/auth/activateAccount.d.ts +5 -11
- package/auth/activateAccount.js +13 -8
- package/auth/allAccounts.d.ts +7 -47
- package/auth/allAccounts.js +20 -12
- package/auth/apiTokens.d.ts +3 -14
- package/auth/apiTokens.js +9 -8
- package/auth/applications.d.ts +3 -22
- package/auth/applications.js +9 -8
- package/auth/customLogin.d.ts +3 -9
- package/auth/customLogin.js +12 -9
- package/auth/entitlements.d.ts +25 -6
- package/auth/entitlements.js +73 -41
- package/auth/forgotPassword.d.ts +3 -12
- package/auth/forgotPassword.js +9 -10
- package/auth/groups.d.ts +5 -32
- package/auth/groups.js +14 -14
- package/auth/impersonate.d.ts +3 -6
- package/auth/impersonate.js +8 -8
- package/auth/login.d.ts +3 -74
- package/auth/login.js +8 -8
- package/auth/passkeys.d.ts +3 -10
- package/auth/passkeys.js +8 -8
- package/auth/passwordRotation.d.ts +3 -4
- package/auth/passwordRotation.js +9 -8
- package/auth/profile.d.ts +3 -19
- package/auth/profile.js +12 -17
- package/auth/provisioning.d.ts +3 -20
- package/auth/provisioning.js +8 -8
- package/auth/resetPhoneNumber.d.ts +3 -8
- package/auth/resetPhoneNumber.js +8 -8
- package/auth/roles.d.ts +3 -14
- package/auth/roles.js +8 -8
- package/auth/security/restrictions.d.ts +3 -21
- package/auth/security/restrictions.js +19 -20
- package/auth/security/securityCenter.d.ts +3 -15
- package/auth/security/securityCenter.js +9 -8
- package/auth/security/securityPolicy.d.ts +5 -35
- package/auth/security/securityPolicy.js +18 -16
- package/auth/security/sessionsPolicy.d.ts +3 -7
- package/auth/security/sessionsPolicy.js +9 -8
- package/auth/sessions.d.ts +3 -12
- package/auth/sessions.js +8 -8
- package/auth/signup.d.ts +5 -10
- package/auth/signup.js +16 -8
- package/auth/sms.d.ts +3 -13
- package/auth/sms.js +8 -8
- package/auth/socialLogin.d.ts +5 -9
- package/auth/socialLogin.js +13 -8
- package/auth/sso.d.ts +6 -31
- package/auth/sso.js +13 -8
- package/auth/stepUp.d.ts +14 -15
- package/auth/stepUp.js +22 -9
- package/auth/team.d.ts +13 -84
- package/auth/team.js +23 -12
- package/auth/tenants.d.ts +3 -9
- package/auth/tenants.js +9 -8
- package/auth/unlockAccount.d.ts +5 -6
- package/auth/unlockAccount.js +10 -8
- package/auth/usernames.d.ts +3 -7
- package/auth/usernames.js +8 -8
- package/auth/usersEmailsPolicyState.d.ts +5 -5
- package/auth/usersEmailsPolicyState.js +10 -8
- package/connectivity/hooks.d.ts +3 -41
- package/connectivity/hooks.js +9 -8
- package/index.js +1 -1
- package/node/audits/auditLogs.js +12 -11
- package/node/audits/auditsMetadata.js +12 -11
- package/node/audits/hooks.js +17 -13
- package/node/auth/acceptInvitation.js +13 -11
- package/node/auth/activateAccount.js +13 -11
- package/node/auth/allAccounts.js +20 -15
- package/node/auth/apiTokens.js +12 -11
- package/node/auth/applications.js +12 -11
- package/node/auth/customLogin.js +15 -11
- package/node/auth/entitlements.js +73 -41
- package/node/auth/forgotPassword.js +12 -13
- package/node/auth/groups.js +17 -17
- package/node/auth/impersonate.js +11 -11
- package/node/auth/login.js +11 -11
- package/node/auth/passkeys.js +11 -11
- package/node/auth/passwordRotation.js +12 -11
- package/node/auth/profile.js +13 -19
- package/node/auth/provisioning.js +11 -11
- package/node/auth/resetPhoneNumber.js +11 -11
- package/node/auth/roles.js +11 -11
- package/node/auth/security/restrictions.js +21 -22
- package/node/auth/security/securityCenter.js +12 -11
- package/node/auth/security/securityPolicy.js +17 -18
- package/node/auth/security/sessionsPolicy.js +12 -11
- package/node/auth/sessions.js +11 -11
- package/node/auth/signup.js +16 -11
- package/node/auth/sms.js +11 -11
- package/node/auth/socialLogin.js +13 -11
- package/node/auth/sso.js +13 -11
- package/node/auth/stepUp.js +24 -11
- package/node/auth/team.js +28 -16
- package/node/auth/tenants.js +12 -11
- package/node/auth/unlockAccount.js +13 -11
- package/node/auth/usernames.js +11 -11
- package/node/auth/usersEmailsPolicyState.js +13 -11
- package/node/connectivity/hooks.js +12 -11
- package/node/index.js +1 -1
- package/node/subscriptions/hooks.js +115 -86
- package/node/vendor/hooks.js +14 -11
- package/package.json +3 -3
- package/subscriptions/hooks.d.ts +22 -48
- package/subscriptions/hooks.js +103 -77
- package/vendor/hooks.d.ts +5 -2
- package/vendor/hooks.js +14 -8
- package/node/useSnapshot/hookFactory.js +0 -32
- package/useSnapshot/hookFactory.d.ts +0 -18
- package/useSnapshot/hookFactory.js +0 -26
|
@@ -6,102 +6,131 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.useVendorPublicConfigActions = exports.useVendorPublicConfig = exports.useSubscriptionRenewal = exports.useSubscriptionCancellation = exports.useSubscriptionActions = exports.useSubscription = exports.useStripeState = exports.useStripeActions = exports.usePlansActions = exports.usePlans = exports.usePaymentProviderActions = exports.usePaymentProvider = exports.usePaymentMethodActions = exports.usePaymentMethod = exports.useInvoicesActions = exports.useInvoices = exports.useCheckoutActions = exports.useCheckout = exports.useBillingInformationActions = exports.useBillingInformation = void 0;
|
|
8
8
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
|
-
var
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
});
|
|
19
|
-
|
|
9
|
+
var _FronteggStoreContext = require("../FronteggStoreContext");
|
|
10
|
+
var _useSnapshot = require("../useSnapshot");
|
|
11
|
+
function getSubscriptionsState() {
|
|
12
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
13
|
+
return (0, _FronteggStoreContext.useStore)().store.subscriptions;
|
|
14
|
+
}
|
|
15
|
+
const usePaymentProvider = () => {
|
|
16
|
+
const {
|
|
17
|
+
config
|
|
18
|
+
} = getSubscriptionsState();
|
|
19
|
+
return (0, _useSnapshot.useSnapshot)(config);
|
|
20
|
+
};
|
|
20
21
|
exports.usePaymentProvider = usePaymentProvider;
|
|
21
|
-
const {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
22
|
+
const usePaymentProviderActions = () => {
|
|
23
|
+
return (0, _FronteggStoreContext.useStore)().stateActions.subscriptions.config;
|
|
24
|
+
};
|
|
25
|
+
exports.usePaymentProviderActions = usePaymentProviderActions;
|
|
26
|
+
const usePlans = () => {
|
|
27
|
+
const {
|
|
28
|
+
plans
|
|
29
|
+
} = getSubscriptionsState();
|
|
30
|
+
return (0, _useSnapshot.useSnapshot)(plans);
|
|
31
|
+
};
|
|
29
32
|
exports.usePlans = usePlans;
|
|
30
|
-
const {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
33
|
+
const usePlansActions = () => {
|
|
34
|
+
return (0, _FronteggStoreContext.useStore)().stateActions.subscriptions.plans;
|
|
35
|
+
};
|
|
36
|
+
exports.usePlansActions = usePlansActions;
|
|
37
|
+
const useCheckout = () => {
|
|
38
|
+
const {
|
|
39
|
+
checkout
|
|
40
|
+
} = getSubscriptionsState();
|
|
41
|
+
return (0, _useSnapshot.useSnapshot)(checkout);
|
|
42
|
+
};
|
|
38
43
|
exports.useCheckout = useCheckout;
|
|
39
|
-
const {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
}
|
|
52
|
-
getState: s => s.subscriptions.vendorPublicConfig,
|
|
53
|
-
getActions: a => a.subscriptions.vendorPublicConfig
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
/* ───────────────────────── billing sub-slices ───────────────────────── */
|
|
57
|
-
exports.useVendorPublicConfigActions = useVendorPublicConfigActions;
|
|
58
|
-
exports.useVendorPublicConfig = useVendorPublicConfig;
|
|
59
|
-
const {
|
|
60
|
-
useSliceState: useBillingInformation,
|
|
61
|
-
useSliceActions: useBillingInformationActions
|
|
62
|
-
} = (0, _hookFactory.createSliceHooks)({
|
|
63
|
-
getState: s => s.subscriptions.billing.information,
|
|
64
|
-
getActions: a => a.subscriptions.billing.information
|
|
65
|
-
});
|
|
66
|
-
exports.useBillingInformationActions = useBillingInformationActions;
|
|
44
|
+
const useCheckoutActions = () => {
|
|
45
|
+
return (0, _FronteggStoreContext.useStore)().stateActions.subscriptions.checkout;
|
|
46
|
+
};
|
|
47
|
+
exports.useCheckoutActions = useCheckoutActions;
|
|
48
|
+
const useBillingActions = billingKey => {
|
|
49
|
+
return (0, _FronteggStoreContext.useStore)().stateActions.subscriptions.billing[billingKey];
|
|
50
|
+
};
|
|
51
|
+
const useBillingInformation = () => {
|
|
52
|
+
const {
|
|
53
|
+
billing
|
|
54
|
+
} = getSubscriptionsState();
|
|
55
|
+
return (0, _useSnapshot.useSnapshot)(billing.information);
|
|
56
|
+
};
|
|
67
57
|
exports.useBillingInformation = useBillingInformation;
|
|
68
|
-
const {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
58
|
+
const useBillingInformationActions = () => {
|
|
59
|
+
return useBillingActions('information');
|
|
60
|
+
};
|
|
61
|
+
exports.useBillingInformationActions = useBillingInformationActions;
|
|
62
|
+
const usePaymentMethod = () => {
|
|
63
|
+
const {
|
|
64
|
+
billing
|
|
65
|
+
} = getSubscriptionsState();
|
|
66
|
+
return (0, _useSnapshot.useSnapshot)(billing.paymentMethod);
|
|
67
|
+
};
|
|
76
68
|
exports.usePaymentMethod = usePaymentMethod;
|
|
77
|
-
const {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
69
|
+
const usePaymentMethodActions = () => {
|
|
70
|
+
return useBillingActions('paymentMethod');
|
|
71
|
+
};
|
|
72
|
+
exports.usePaymentMethodActions = usePaymentMethodActions;
|
|
73
|
+
const useInvoices = () => {
|
|
74
|
+
const {
|
|
75
|
+
billing
|
|
76
|
+
} = getSubscriptionsState();
|
|
77
|
+
return (0, _useSnapshot.useSnapshot)(billing.invoices);
|
|
78
|
+
};
|
|
87
79
|
exports.useInvoices = useInvoices;
|
|
88
|
-
const {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
80
|
+
const useInvoicesActions = () => {
|
|
81
|
+
return useBillingActions('invoices');
|
|
82
|
+
};
|
|
83
|
+
exports.useInvoicesActions = useInvoicesActions;
|
|
84
|
+
const useSubscriptionCancellation = () => {
|
|
85
|
+
const {
|
|
86
|
+
billing
|
|
87
|
+
} = getSubscriptionsState();
|
|
88
|
+
const {
|
|
89
|
+
cancellation
|
|
90
|
+
} = (0, _useSnapshot.useSnapshot)(billing.subscription);
|
|
91
|
+
return cancellation;
|
|
92
|
+
};
|
|
98
93
|
exports.useSubscriptionCancellation = useSubscriptionCancellation;
|
|
99
|
-
const useSubscriptionRenewal = () =>
|
|
94
|
+
const useSubscriptionRenewal = () => {
|
|
95
|
+
const {
|
|
96
|
+
billing
|
|
97
|
+
} = getSubscriptionsState();
|
|
98
|
+
const {
|
|
99
|
+
renewal
|
|
100
|
+
} = (0, _useSnapshot.useSnapshot)(billing.subscription);
|
|
101
|
+
return renewal;
|
|
102
|
+
};
|
|
100
103
|
exports.useSubscriptionRenewal = useSubscriptionRenewal;
|
|
104
|
+
const useSubscription = () => {
|
|
105
|
+
const {
|
|
106
|
+
billing
|
|
107
|
+
} = getSubscriptionsState();
|
|
108
|
+
return (0, _useSnapshot.useSnapshot)(billing.subscription);
|
|
109
|
+
};
|
|
110
|
+
exports.useSubscription = useSubscription;
|
|
101
111
|
const useSubscriptionActions = () => {
|
|
102
|
-
const actions =
|
|
112
|
+
const actions = (0, _FronteggStoreContext.useStore)().stateActions.subscriptions.billing.subscription;
|
|
103
113
|
return (0, _extends2.default)({}, actions, {
|
|
104
114
|
load: actions.loadSubscription
|
|
105
115
|
});
|
|
106
116
|
};
|
|
107
|
-
exports.useSubscriptionActions = useSubscriptionActions;
|
|
117
|
+
exports.useSubscriptionActions = useSubscriptionActions;
|
|
118
|
+
const useStripeState = () => {
|
|
119
|
+
const {
|
|
120
|
+
stripe
|
|
121
|
+
} = getSubscriptionsState();
|
|
122
|
+
return (0, _useSnapshot.useSnapshot)(stripe);
|
|
123
|
+
};
|
|
124
|
+
exports.useStripeState = useStripeState;
|
|
125
|
+
const useStripeActions = () => {
|
|
126
|
+
return (0, _FronteggStoreContext.useStore)().stateActions.subscriptions.stripe;
|
|
127
|
+
};
|
|
128
|
+
exports.useStripeActions = useStripeActions;
|
|
129
|
+
const useVendorPublicConfig = () => {
|
|
130
|
+
return (0, _useSnapshot.useSnapshot)((0, _FronteggStoreContext.useStore)().store.subscriptions.vendorPublicConfig);
|
|
131
|
+
};
|
|
132
|
+
exports.useVendorPublicConfig = useVendorPublicConfig;
|
|
133
|
+
const useVendorPublicConfigActions = () => {
|
|
134
|
+
return (0, _FronteggStoreContext.useStore)().stateActions.subscriptions.vendorPublicConfig;
|
|
135
|
+
};
|
|
136
|
+
exports.useVendorPublicConfigActions = useVendorPublicConfigActions;
|
package/node/vendor/hooks.js
CHANGED
|
@@ -3,14 +3,17 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
6
|
+
exports.useVendorActions = void 0;
|
|
7
|
+
exports.useVendorState = useVendorState;
|
|
8
|
+
var _FronteggStoreContext = require("../FronteggStoreContext");
|
|
9
|
+
var _useSnapshot = require("../useSnapshot");
|
|
10
|
+
const defaultMapper = state => state;
|
|
11
|
+
// @deprecated use useVendorState() instead
|
|
12
|
+
function useVendorState(stateMapper = defaultMapper) {
|
|
13
|
+
const state = (0, _FronteggStoreContext.useStore)().store.vendor;
|
|
14
|
+
return stateMapper((0, _useSnapshot.useSnapshot)(state));
|
|
15
|
+
}
|
|
16
|
+
const useVendorActions = () => {
|
|
17
|
+
return (0, _FronteggStoreContext.useStore)().stateActions.vendor;
|
|
18
|
+
};
|
|
19
|
+
exports.useVendorActions = useVendorActions;
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@frontegg/react-hooks",
|
|
3
|
-
"version": "7.78.0
|
|
3
|
+
"version": "7.78.0",
|
|
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
|
-
"@frontegg/redux-store": "7.78.0
|
|
10
|
-
"@frontegg/types": "7.78.0
|
|
9
|
+
"@frontegg/redux-store": "7.78.0",
|
|
10
|
+
"@frontegg/types": "7.78.0",
|
|
11
11
|
"@types/react": "*",
|
|
12
12
|
"@types/react-is": "^17.0.7",
|
|
13
13
|
"get-value": "^3.0.1",
|
package/subscriptions/hooks.d.ts
CHANGED
|
@@ -1,34 +1,19 @@
|
|
|
1
|
-
import { CheckoutState, PaymentProviderConfigState,
|
|
2
|
-
export declare const usePaymentProvider:
|
|
3
|
-
export declare const
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
export declare const
|
|
9
|
-
|
|
10
|
-
resetCheckoutState: () => void;
|
|
11
|
-
loadCheckout: () => void;
|
|
12
|
-
resetCheckout: () => void;
|
|
13
|
-
submitCheckout: () => void;
|
|
14
|
-
confirmCheckout: (payload: import("@frontegg/redux-store").ConfirmCheckoutActionPayload) => Promise<void>;
|
|
15
|
-
errorCheckout: (payload: import("dist/@frontegg/rest-api").FronteggApiError) => void;
|
|
16
|
-
};
|
|
17
|
-
export declare const useStripeState: <S = StripeState>(selector?: (s: StripeState) => S) => S, useStripeActions: () => StripeActions;
|
|
18
|
-
export declare const useVendorPublicConfig: <S = VendorPublicConfigurationState>(selector?: (s: VendorPublicConfigurationState) => S) => S, useVendorPublicConfigActions: () => {
|
|
19
|
-
setVendorPublicConfigState: (state: Partial<VendorPublicConfigurationState>) => void;
|
|
20
|
-
resetVendorPublicConfigState: () => void;
|
|
21
|
-
setVendorPublicConfigError: (error: import("dist/@frontegg/rest-api").FronteggApiError) => void;
|
|
22
|
-
setVendorPublicConfigLoading: (loading: boolean) => void;
|
|
23
|
-
loadVendorPublicConfiguration: () => Promise<void>;
|
|
24
|
-
};
|
|
25
|
-
export declare const useBillingInformation: <S = BillingInformationState>(selector?: (s: BillingInformationState) => S) => S, useBillingInformationActions: () => {
|
|
1
|
+
import { CheckoutActions, CheckoutState, PaymentProviderConfigActions, PaymentProviderConfigState, PlansActions, PlansState, StripeActions, StripeState, SubscriptionState, BillingInformationState, InvoicesState, PaymentMethodState, BillingStateActions, VendorPublicConfigurationState, VendorPublicConfigurationActions } from '@frontegg/redux-store';
|
|
2
|
+
export declare const usePaymentProvider: () => PaymentProviderConfigState;
|
|
3
|
+
export declare const usePaymentProviderActions: () => PaymentProviderConfigActions;
|
|
4
|
+
export declare const usePlans: () => PlansState;
|
|
5
|
+
export declare const usePlansActions: () => PlansActions;
|
|
6
|
+
export declare const useCheckout: () => CheckoutState;
|
|
7
|
+
export declare const useCheckoutActions: () => CheckoutActions;
|
|
8
|
+
export declare const useBillingInformation: () => BillingInformationState;
|
|
9
|
+
export declare const useBillingInformationActions: () => {
|
|
26
10
|
setBillingInformationState: (state: Partial<BillingInformationState>) => void;
|
|
27
11
|
resetBillingInformationState: () => void;
|
|
28
12
|
loadSummaries: (tenantId: string, forceActive?: boolean) => Promise<void>;
|
|
29
13
|
loadBillingInformation: (forceActive?: boolean) => Promise<void>;
|
|
30
14
|
};
|
|
31
|
-
export declare const usePaymentMethod:
|
|
15
|
+
export declare const usePaymentMethod: () => PaymentMethodState;
|
|
16
|
+
export declare const usePaymentMethodActions: () => {
|
|
32
17
|
setBillingPaymentMethodState: (state: Partial<{}>) => void;
|
|
33
18
|
resetBillingPaymentMethodState: () => void;
|
|
34
19
|
loadPaymentMethod: () => Promise<void>;
|
|
@@ -37,7 +22,8 @@ export declare const usePaymentMethod: <S = PaymentMethodState>(selector?: (s: P
|
|
|
37
22
|
submitPaymentMethodSuccess: () => Promise<void>;
|
|
38
23
|
updatePaymentMethodBillingDetails: (payload: import("@frontegg/redux-store").WithCallback<import("@frontegg/redux-store").WithId<import("dist/@frontegg/rest-api").ISubscriptionUpdatePaymentMethodBillingDetails>>) => Promise<void>;
|
|
39
24
|
};
|
|
40
|
-
export declare const useInvoices:
|
|
25
|
+
export declare const useInvoices: () => InvoicesState;
|
|
26
|
+
export declare const useInvoicesActions: () => {
|
|
41
27
|
setBillingInvoiceState: (state: Partial<InvoicesState>) => void;
|
|
42
28
|
resetBillingInvoiceState: () => void;
|
|
43
29
|
loadInvoices: () => Promise<void>;
|
|
@@ -45,25 +31,13 @@ export declare const useInvoices: <S = InvoicesState>(selector?: (s: InvoicesSta
|
|
|
45
31
|
downloadInvoice: (payload: import("@frontegg/redux-store").DownloadInvoiceActionPayload) => Promise<void>;
|
|
46
32
|
downloadBillingInvoice: (payload: import("@frontegg/redux-store").DownloadInvoiceActionPayload) => Promise<void>;
|
|
47
33
|
};
|
|
48
|
-
export declare const
|
|
49
|
-
export declare const
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
export declare const useSubscriptionRenewal: () => {
|
|
54
|
-
loading: boolean;
|
|
55
|
-
error: import("dist/@frontegg/rest-api").FronteggApiError | null;
|
|
56
|
-
};
|
|
57
|
-
export declare const useSubscriptionActions: () => {
|
|
58
|
-
load: () => Promise<void>;
|
|
59
|
-
setBillingSubscriptionState: (state: Partial<{}>) => void;
|
|
60
|
-
resetBillingSubscriptionState: () => void;
|
|
61
|
-
setCancellationLoading: (loading: boolean) => void;
|
|
62
|
-
setCancellationError: (error: import("dist/@frontegg/rest-api").FronteggApiError | null) => void;
|
|
63
|
-
setRenewalLoading: (loading: boolean) => void;
|
|
64
|
-
setRenewalError: (error: import("dist/@frontegg/rest-api").FronteggApiError | null) => void;
|
|
65
|
-
loadSubscription: () => Promise<void>;
|
|
66
|
-
loadSubscriptionTenant: () => Promise<void>;
|
|
67
|
-
cancelSubscription: () => Promise<void>;
|
|
68
|
-
renewSubscription: () => Promise<void>;
|
|
34
|
+
export declare const useSubscriptionCancellation: () => SubscriptionState["cancellation"];
|
|
35
|
+
export declare const useSubscriptionRenewal: () => SubscriptionState["renewal"];
|
|
36
|
+
export declare const useSubscription: () => SubscriptionState;
|
|
37
|
+
export declare const useSubscriptionActions: () => BillingStateActions["subscription"] & {
|
|
38
|
+
load: () => void;
|
|
69
39
|
};
|
|
40
|
+
export declare const useStripeState: () => StripeState;
|
|
41
|
+
export declare const useStripeActions: () => StripeActions;
|
|
42
|
+
export declare const useVendorPublicConfig: () => VendorPublicConfigurationState;
|
|
43
|
+
export declare const useVendorPublicConfigActions: () => VendorPublicConfigurationActions;
|
package/subscriptions/hooks.js
CHANGED
|
@@ -1,83 +1,109 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
export const {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
} =
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
2
|
+
import { useStore } from '../FronteggStoreContext';
|
|
3
|
+
import { useSnapshot } from '../useSnapshot';
|
|
4
|
+
function getSubscriptionsState() {
|
|
5
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
6
|
+
return useStore().store.subscriptions;
|
|
7
|
+
}
|
|
8
|
+
export const usePaymentProvider = () => {
|
|
9
|
+
const {
|
|
10
|
+
config
|
|
11
|
+
} = getSubscriptionsState();
|
|
12
|
+
return useSnapshot(config);
|
|
13
|
+
};
|
|
14
|
+
export const usePaymentProviderActions = () => {
|
|
15
|
+
return useStore().stateActions.subscriptions.config;
|
|
16
|
+
};
|
|
17
|
+
export const usePlans = () => {
|
|
18
|
+
const {
|
|
19
|
+
plans
|
|
20
|
+
} = getSubscriptionsState();
|
|
21
|
+
return useSnapshot(plans);
|
|
22
|
+
};
|
|
23
|
+
export const usePlansActions = () => {
|
|
24
|
+
return useStore().stateActions.subscriptions.plans;
|
|
25
|
+
};
|
|
26
|
+
export const useCheckout = () => {
|
|
27
|
+
const {
|
|
28
|
+
checkout
|
|
29
|
+
} = getSubscriptionsState();
|
|
30
|
+
return useSnapshot(checkout);
|
|
31
|
+
};
|
|
32
|
+
export const useCheckoutActions = () => {
|
|
33
|
+
return useStore().stateActions.subscriptions.checkout;
|
|
34
|
+
};
|
|
35
|
+
const useBillingActions = billingKey => {
|
|
36
|
+
return useStore().stateActions.subscriptions.billing[billingKey];
|
|
37
|
+
};
|
|
38
|
+
export const useBillingInformation = () => {
|
|
39
|
+
const {
|
|
40
|
+
billing
|
|
41
|
+
} = getSubscriptionsState();
|
|
42
|
+
return useSnapshot(billing.information);
|
|
43
|
+
};
|
|
44
|
+
export const useBillingInformationActions = () => {
|
|
45
|
+
return useBillingActions('information');
|
|
46
|
+
};
|
|
47
|
+
export const usePaymentMethod = () => {
|
|
48
|
+
const {
|
|
49
|
+
billing
|
|
50
|
+
} = getSubscriptionsState();
|
|
51
|
+
return useSnapshot(billing.paymentMethod);
|
|
52
|
+
};
|
|
53
|
+
export const usePaymentMethodActions = () => {
|
|
54
|
+
return useBillingActions('paymentMethod');
|
|
55
|
+
};
|
|
56
|
+
export const useInvoices = () => {
|
|
57
|
+
const {
|
|
58
|
+
billing
|
|
59
|
+
} = getSubscriptionsState();
|
|
60
|
+
return useSnapshot(billing.invoices);
|
|
61
|
+
};
|
|
62
|
+
export const useInvoicesActions = () => {
|
|
63
|
+
return useBillingActions('invoices');
|
|
64
|
+
};
|
|
65
|
+
export const useSubscriptionCancellation = () => {
|
|
66
|
+
const {
|
|
67
|
+
billing
|
|
68
|
+
} = getSubscriptionsState();
|
|
69
|
+
const {
|
|
70
|
+
cancellation
|
|
71
|
+
} = useSnapshot(billing.subscription);
|
|
72
|
+
return cancellation;
|
|
73
|
+
};
|
|
74
|
+
export const useSubscriptionRenewal = () => {
|
|
75
|
+
const {
|
|
76
|
+
billing
|
|
77
|
+
} = getSubscriptionsState();
|
|
78
|
+
const {
|
|
79
|
+
renewal
|
|
80
|
+
} = useSnapshot(billing.subscription);
|
|
81
|
+
return renewal;
|
|
82
|
+
};
|
|
83
|
+
export const useSubscription = () => {
|
|
84
|
+
const {
|
|
85
|
+
billing
|
|
86
|
+
} = getSubscriptionsState();
|
|
87
|
+
return useSnapshot(billing.subscription);
|
|
88
|
+
};
|
|
78
89
|
export const useSubscriptionActions = () => {
|
|
79
|
-
const actions =
|
|
90
|
+
const actions = useStore().stateActions.subscriptions.billing.subscription;
|
|
80
91
|
return _extends({}, actions, {
|
|
81
92
|
load: actions.loadSubscription
|
|
82
93
|
});
|
|
94
|
+
};
|
|
95
|
+
export const useStripeState = () => {
|
|
96
|
+
const {
|
|
97
|
+
stripe
|
|
98
|
+
} = getSubscriptionsState();
|
|
99
|
+
return useSnapshot(stripe);
|
|
100
|
+
};
|
|
101
|
+
export const useStripeActions = () => {
|
|
102
|
+
return useStore().stateActions.subscriptions.stripe;
|
|
103
|
+
};
|
|
104
|
+
export const useVendorPublicConfig = () => {
|
|
105
|
+
return useSnapshot(useStore().store.subscriptions.vendorPublicConfig);
|
|
106
|
+
};
|
|
107
|
+
export const useVendorPublicConfigActions = () => {
|
|
108
|
+
return useStore().stateActions.subscriptions.vendorPublicConfig;
|
|
83
109
|
};
|
package/vendor/hooks.d.ts
CHANGED
|
@@ -1,2 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
export
|
|
1
|
+
import { VendorActions, VendorState } from '@frontegg/redux-store';
|
|
2
|
+
export type VendorStateMapper<S> = (state: VendorState) => S;
|
|
3
|
+
export declare function useVendorState(): VendorState;
|
|
4
|
+
export declare function useVendorState<S>(stateMapper: VendorStateMapper<S>): S;
|
|
5
|
+
export declare const useVendorActions: () => VendorActions;
|
package/vendor/hooks.js
CHANGED
|
@@ -1,8 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import { useStore } from '../FronteggStoreContext';
|
|
2
|
+
import { useSnapshot } from '../useSnapshot';
|
|
3
|
+
|
|
4
|
+
// TODO: remove useless stateMapper, valtio already does this
|
|
5
|
+
|
|
6
|
+
const defaultMapper = state => state;
|
|
7
|
+
// @deprecated use useVendorState() instead
|
|
8
|
+
export function useVendorState(stateMapper = defaultMapper) {
|
|
9
|
+
const state = useStore().store.vendor;
|
|
10
|
+
return stateMapper(useSnapshot(state));
|
|
11
|
+
}
|
|
12
|
+
export const useVendorActions = () => {
|
|
13
|
+
return useStore().stateActions.vendor;
|
|
14
|
+
};
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.createSliceHooks = createSliceHooks;
|
|
7
|
-
var _index = require("./index");
|
|
8
|
-
var _FronteggStoreContext = require("../FronteggStoreContext");
|
|
9
|
-
// hooksFactory.ts ✅ type-safe, no TS2345
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Build hooks for any slice in Frontegg’s store tree.
|
|
13
|
-
*/
|
|
14
|
-
function createSliceHooks(cfg) {
|
|
15
|
-
/* ---------- state ---------- */
|
|
16
|
-
const useSliceState = (selector = x => x) => selector((0, _index.useSnapshot)(cfg.getState((0, _FronteggStoreContext.useStore)().store)));
|
|
17
|
-
|
|
18
|
-
/* ---------- actions ---------- */
|
|
19
|
-
const useSliceActions = () => cfg.getActions((0, _FronteggStoreContext.useStore)().stateActions);
|
|
20
|
-
|
|
21
|
-
/* ---------- dialogs (optional) ---------- */
|
|
22
|
-
const useSliceDialogsState = () => (0, _index.useSnapshot)(cfg.getDialogsState((0, _FronteggStoreContext.useStore)().store));
|
|
23
|
-
const useSliceDialogsActions = () => cfg.getDialogsActions((0, _FronteggStoreContext.useStore)().stateActions);
|
|
24
|
-
|
|
25
|
-
/* IntelliSense hides the dialogs hooks when you didn’t supply them */
|
|
26
|
-
return {
|
|
27
|
-
useSliceState,
|
|
28
|
-
useSliceActions,
|
|
29
|
-
useSliceDialogsState,
|
|
30
|
-
useSliceDialogsActions
|
|
31
|
-
};
|
|
32
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { useStore } from '../FronteggStoreContext';
|
|
2
|
-
type Store = ReturnType<typeof useStore>['store'];
|
|
3
|
-
type Actions = ReturnType<typeof useStore>['stateActions'];
|
|
4
|
-
/**
|
|
5
|
-
* Build hooks for any slice in Frontegg’s store tree.
|
|
6
|
-
*/
|
|
7
|
-
export declare function createSliceHooks<SliceState extends object, SliceActions, SliceDialogsState extends object = never, SliceDialogsActions = never>(cfg: {
|
|
8
|
-
getState: (s: Store) => SliceState;
|
|
9
|
-
getActions: (a: Actions) => SliceActions;
|
|
10
|
-
getDialogsState?: (s: Store) => SliceDialogsState;
|
|
11
|
-
getDialogsActions?: (a: Actions) => SliceDialogsActions;
|
|
12
|
-
}): {
|
|
13
|
-
readonly useSliceState: <S = SliceState>(selector?: (s: SliceState) => S) => S;
|
|
14
|
-
readonly useSliceActions: () => SliceActions;
|
|
15
|
-
readonly useSliceDialogsState: () => SliceDialogsState;
|
|
16
|
-
readonly useSliceDialogsActions: () => SliceDialogsActions;
|
|
17
|
-
};
|
|
18
|
-
export {};
|