@frontegg/react-hooks 7.77.0 → 7.78.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.
- package/audits/auditLogs.d.ts +2 -3
- package/audits/auditLogs.js +8 -9
- package/audits/auditsMetadata.d.ts +2 -3
- package/audits/auditsMetadata.js +8 -9
- package/audits/hooks.d.ts +2 -9
- package/audits/hooks.js +10 -14
- package/auth/acceptInvitation.d.ts +7 -5
- package/auth/acceptInvitation.js +8 -13
- package/auth/activateAccount.d.ts +11 -5
- package/auth/activateAccount.js +8 -13
- package/auth/allAccounts.d.ts +47 -7
- package/auth/allAccounts.js +12 -20
- package/auth/apiTokens.d.ts +14 -3
- package/auth/apiTokens.js +8 -9
- package/auth/applications.d.ts +22 -3
- package/auth/applications.js +8 -9
- package/auth/customLogin.d.ts +9 -3
- package/auth/customLogin.js +9 -12
- package/auth/entitlements.d.ts +6 -25
- package/auth/entitlements.js +41 -73
- package/auth/forgotPassword.d.ts +12 -3
- package/auth/forgotPassword.js +10 -9
- package/auth/groups.d.ts +32 -5
- package/auth/groups.js +14 -14
- package/auth/impersonate.d.ts +6 -3
- package/auth/impersonate.js +8 -8
- package/auth/login.d.ts +74 -3
- package/auth/login.js +8 -8
- package/auth/passkeys.d.ts +10 -3
- package/auth/passkeys.js +8 -8
- package/auth/passwordRotation.d.ts +4 -3
- package/auth/passwordRotation.js +8 -9
- package/auth/profile.d.ts +19 -3
- package/auth/profile.js +17 -12
- package/auth/provisioning.d.ts +20 -3
- package/auth/provisioning.js +8 -8
- package/auth/resetPhoneNumber.d.ts +8 -3
- package/auth/resetPhoneNumber.js +8 -8
- package/auth/roles.d.ts +14 -3
- package/auth/roles.js +8 -8
- package/auth/security/restrictions.d.ts +21 -3
- package/auth/security/restrictions.js +20 -19
- package/auth/security/securityCenter.d.ts +15 -3
- package/auth/security/securityCenter.js +8 -9
- package/auth/security/securityPolicy.d.ts +35 -5
- package/auth/security/securityPolicy.js +16 -18
- package/auth/security/sessionsPolicy.d.ts +7 -3
- package/auth/security/sessionsPolicy.js +8 -9
- package/auth/sessions.d.ts +12 -3
- package/auth/sessions.js +8 -8
- package/auth/signup.d.ts +10 -5
- package/auth/signup.js +8 -16
- package/auth/sms.d.ts +13 -3
- package/auth/sms.js +8 -8
- package/auth/socialLogin.d.ts +9 -5
- package/auth/socialLogin.js +8 -13
- package/auth/sso.d.ts +31 -6
- package/auth/sso.js +8 -13
- package/auth/stepUp.d.ts +15 -14
- package/auth/stepUp.js +9 -22
- package/auth/team.d.ts +84 -13
- package/auth/team.js +12 -23
- package/auth/tenants.d.ts +9 -3
- package/auth/tenants.js +8 -9
- package/auth/unlockAccount.d.ts +6 -5
- package/auth/unlockAccount.js +8 -10
- package/auth/usernames.d.ts +7 -3
- package/auth/usernames.js +8 -8
- package/auth/usersEmailsPolicyState.d.ts +5 -5
- package/auth/usersEmailsPolicyState.js +8 -10
- package/connectivity/hooks.d.ts +41 -3
- package/connectivity/hooks.js +8 -9
- package/index.js +1 -1
- package/node/audits/auditLogs.js +11 -12
- package/node/audits/auditsMetadata.js +11 -12
- package/node/audits/hooks.js +13 -17
- package/node/auth/acceptInvitation.js +11 -13
- package/node/auth/activateAccount.js +11 -13
- package/node/auth/allAccounts.js +15 -20
- package/node/auth/apiTokens.js +11 -12
- package/node/auth/applications.js +11 -12
- package/node/auth/customLogin.js +11 -15
- package/node/auth/entitlements.js +41 -73
- package/node/auth/forgotPassword.js +13 -12
- 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 +11 -12
- package/node/auth/profile.js +19 -13
- 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 +22 -21
- package/node/auth/security/securityCenter.js +11 -12
- package/node/auth/security/securityPolicy.js +18 -17
- package/node/auth/security/sessionsPolicy.js +11 -12
- package/node/auth/sessions.js +11 -11
- package/node/auth/signup.js +11 -16
- package/node/auth/sms.js +11 -11
- package/node/auth/socialLogin.js +11 -13
- package/node/auth/sso.js +11 -13
- package/node/auth/stepUp.js +11 -24
- package/node/auth/team.js +16 -28
- package/node/auth/tenants.js +11 -12
- package/node/auth/unlockAccount.js +11 -13
- package/node/auth/usernames.js +11 -11
- package/node/auth/usersEmailsPolicyState.js +11 -13
- package/node/connectivity/hooks.js +11 -12
- package/node/index.js +1 -1
- package/node/subscriptions/hooks.js +86 -115
- package/node/useSnapshot/hookFactory.js +32 -0
- package/node/vendor/hooks.js +11 -14
- package/package.json +3 -3
- package/subscriptions/hooks.d.ts +48 -22
- package/subscriptions/hooks.js +77 -103
- package/useSnapshot/hookFactory.d.ts +18 -0
- package/useSnapshot/hookFactory.js +26 -0
- package/vendor/hooks.d.ts +2 -5
- package/vendor/hooks.js +8 -14
|
@@ -6,131 +6,102 @@ 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
|
-
return (0, _useSnapshot.useSnapshot)(config);
|
|
20
|
-
};
|
|
21
|
-
exports.usePaymentProvider = usePaymentProvider;
|
|
22
|
-
const usePaymentProviderActions = () => {
|
|
23
|
-
return (0, _FronteggStoreContext.useStore)().stateActions.subscriptions.config;
|
|
24
|
-
};
|
|
9
|
+
var _hookFactory = require("../useSnapshot/hookFactory");
|
|
10
|
+
/* ───────────────────────── subscriptions root helpers ───────────────────────── */
|
|
11
|
+
|
|
12
|
+
const {
|
|
13
|
+
useSliceState: usePaymentProvider,
|
|
14
|
+
useSliceActions: usePaymentProviderActions
|
|
15
|
+
} = (0, _hookFactory.createSliceHooks)({
|
|
16
|
+
getState: s => s.subscriptions.config,
|
|
17
|
+
getActions: a => a.subscriptions.config
|
|
18
|
+
});
|
|
25
19
|
exports.usePaymentProviderActions = usePaymentProviderActions;
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
return (0, _FronteggStoreContext.useStore)().stateActions.subscriptions.plans;
|
|
35
|
-
};
|
|
20
|
+
exports.usePaymentProvider = usePaymentProvider;
|
|
21
|
+
const {
|
|
22
|
+
useSliceState: usePlans,
|
|
23
|
+
useSliceActions: usePlansActions
|
|
24
|
+
} = (0, _hookFactory.createSliceHooks)({
|
|
25
|
+
getState: s => s.subscriptions.plans,
|
|
26
|
+
getActions: a => a.subscriptions.plans
|
|
27
|
+
});
|
|
36
28
|
exports.usePlansActions = usePlansActions;
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
return (0, _FronteggStoreContext.useStore)().stateActions.subscriptions.checkout;
|
|
46
|
-
};
|
|
29
|
+
exports.usePlans = usePlans;
|
|
30
|
+
const {
|
|
31
|
+
useSliceState: useCheckout,
|
|
32
|
+
useSliceActions: useCheckoutActions
|
|
33
|
+
} = (0, _hookFactory.createSliceHooks)({
|
|
34
|
+
getState: s => s.subscriptions.checkout,
|
|
35
|
+
getActions: a => a.subscriptions.checkout
|
|
36
|
+
});
|
|
47
37
|
exports.useCheckoutActions = useCheckoutActions;
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
exports.
|
|
58
|
-
const
|
|
59
|
-
|
|
60
|
-
|
|
38
|
+
exports.useCheckout = useCheckout;
|
|
39
|
+
const {
|
|
40
|
+
useSliceState: useStripeState,
|
|
41
|
+
useSliceActions: useStripeActions
|
|
42
|
+
} = (0, _hookFactory.createSliceHooks)({
|
|
43
|
+
getState: s => s.subscriptions.stripe,
|
|
44
|
+
getActions: a => a.subscriptions.stripe
|
|
45
|
+
});
|
|
46
|
+
exports.useStripeActions = useStripeActions;
|
|
47
|
+
exports.useStripeState = useStripeState;
|
|
48
|
+
const {
|
|
49
|
+
useSliceState: useVendorPublicConfig,
|
|
50
|
+
useSliceActions: useVendorPublicConfigActions
|
|
51
|
+
} = (0, _hookFactory.createSliceHooks)({
|
|
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
|
+
});
|
|
61
66
|
exports.useBillingInformationActions = useBillingInformationActions;
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
return useBillingActions('paymentMethod');
|
|
71
|
-
};
|
|
67
|
+
exports.useBillingInformation = useBillingInformation;
|
|
68
|
+
const {
|
|
69
|
+
useSliceState: usePaymentMethod,
|
|
70
|
+
useSliceActions: usePaymentMethodActions
|
|
71
|
+
} = (0, _hookFactory.createSliceHooks)({
|
|
72
|
+
getState: s => s.subscriptions.billing.paymentMethod,
|
|
73
|
+
getActions: a => a.subscriptions.billing.paymentMethod
|
|
74
|
+
});
|
|
72
75
|
exports.usePaymentMethodActions = usePaymentMethodActions;
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
76
|
+
exports.usePaymentMethod = usePaymentMethod;
|
|
77
|
+
const {
|
|
78
|
+
useSliceState: useInvoices,
|
|
79
|
+
useSliceActions: useInvoicesActions
|
|
80
|
+
} = (0, _hookFactory.createSliceHooks)({
|
|
81
|
+
getState: s => s.subscriptions.billing.invoices,
|
|
82
|
+
getActions: a => a.subscriptions.billing.invoices
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
/* ───────────────────────── subscription sub-slice ───────────────────────── */
|
|
83
86
|
exports.useInvoicesActions = useInvoicesActions;
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
87
|
+
exports.useInvoices = useInvoices;
|
|
88
|
+
const {
|
|
89
|
+
useSliceState: useSubscriptionState,
|
|
90
|
+
useSliceActions: _useSubscriptionActions
|
|
91
|
+
} = (0, _hookFactory.createSliceHooks)({
|
|
92
|
+
getState: s => s.subscriptions.billing.subscription,
|
|
93
|
+
getActions: a => a.subscriptions.billing.subscription
|
|
94
|
+
});
|
|
95
|
+
const useSubscription = useSubscriptionState;
|
|
96
|
+
exports.useSubscription = useSubscription;
|
|
97
|
+
const useSubscriptionCancellation = () => useSubscription().cancellation;
|
|
93
98
|
exports.useSubscriptionCancellation = useSubscriptionCancellation;
|
|
94
|
-
const useSubscriptionRenewal = () =>
|
|
95
|
-
const {
|
|
96
|
-
billing
|
|
97
|
-
} = getSubscriptionsState();
|
|
98
|
-
const {
|
|
99
|
-
renewal
|
|
100
|
-
} = (0, _useSnapshot.useSnapshot)(billing.subscription);
|
|
101
|
-
return renewal;
|
|
102
|
-
};
|
|
99
|
+
const useSubscriptionRenewal = () => useSubscription().renewal;
|
|
103
100
|
exports.useSubscriptionRenewal = useSubscriptionRenewal;
|
|
104
|
-
const useSubscription = () => {
|
|
105
|
-
const {
|
|
106
|
-
billing
|
|
107
|
-
} = getSubscriptionsState();
|
|
108
|
-
return (0, _useSnapshot.useSnapshot)(billing.subscription);
|
|
109
|
-
};
|
|
110
|
-
exports.useSubscription = useSubscription;
|
|
111
101
|
const useSubscriptionActions = () => {
|
|
112
|
-
const actions = (
|
|
102
|
+
const actions = _useSubscriptionActions();
|
|
113
103
|
return (0, _extends2.default)({}, actions, {
|
|
114
104
|
load: actions.loadSubscription
|
|
115
105
|
});
|
|
116
106
|
};
|
|
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;
|
|
107
|
+
exports.useSubscriptionActions = useSubscriptionActions;
|
|
@@ -0,0 +1,32 @@
|
|
|
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
|
+
}
|
package/node/vendor/hooks.js
CHANGED
|
@@ -3,17 +3,14 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.useVendorActions = void 0;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
return (0, _FronteggStoreContext.useStore)().stateActions.vendor;
|
|
18
|
-
};
|
|
19
|
-
exports.useVendorActions = useVendorActions;
|
|
6
|
+
exports.useVendorState = exports.useVendorActions = void 0;
|
|
7
|
+
var _hookFactory = require("../useSnapshot/hookFactory");
|
|
8
|
+
const {
|
|
9
|
+
useSliceState: useVendorState,
|
|
10
|
+
useSliceActions: useVendorActions
|
|
11
|
+
} = (0, _hookFactory.createSliceHooks)({
|
|
12
|
+
getState: s => s.vendor,
|
|
13
|
+
getActions: a => a.vendor
|
|
14
|
+
});
|
|
15
|
+
exports.useVendorActions = useVendorActions;
|
|
16
|
+
exports.useVendorState = useVendorState;
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@frontegg/react-hooks",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.78.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
|
-
"@frontegg/redux-store": "7.
|
|
10
|
-
"@frontegg/types": "7.
|
|
9
|
+
"@frontegg/redux-store": "7.78.0-alpha.1",
|
|
10
|
+
"@frontegg/types": "7.78.0-alpha.1",
|
|
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,19 +1,34 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare const usePaymentProvider: () =>
|
|
3
|
-
export declare const
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
export declare const
|
|
9
|
-
|
|
1
|
+
import { CheckoutState, PaymentProviderConfigState, PaymentProviderConfigActions, PlansState, StripeState, StripeActions, BillingInformationState, PaymentMethodState, InvoicesState, SubscriptionState, VendorPublicConfigurationState } from '@frontegg/redux-store';
|
|
2
|
+
export declare const usePaymentProvider: <S = PaymentProviderConfigState>(selector?: (s: PaymentProviderConfigState) => S) => S, usePaymentProviderActions: () => PaymentProviderConfigActions;
|
|
3
|
+
export declare const usePlans: <S = PlansState>(selector?: (s: PlansState) => S) => S, usePlansActions: () => {
|
|
4
|
+
setPlansState: (state: Partial<PlansState>) => void;
|
|
5
|
+
resetPlansState: () => void;
|
|
6
|
+
loadPlans: () => Promise<void>;
|
|
7
|
+
};
|
|
8
|
+
export declare const useCheckout: <S = CheckoutState>(selector?: (s: CheckoutState) => S) => S, useCheckoutActions: () => {
|
|
9
|
+
setCheckoutState: (state: Partial<CheckoutState>) => void;
|
|
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: () => {
|
|
10
26
|
setBillingInformationState: (state: Partial<BillingInformationState>) => void;
|
|
11
27
|
resetBillingInformationState: () => void;
|
|
12
28
|
loadSummaries: (tenantId: string, forceActive?: boolean) => Promise<void>;
|
|
13
29
|
loadBillingInformation: (forceActive?: boolean) => Promise<void>;
|
|
14
30
|
};
|
|
15
|
-
export declare const usePaymentMethod: () =>
|
|
16
|
-
export declare const usePaymentMethodActions: () => {
|
|
31
|
+
export declare const usePaymentMethod: <S = PaymentMethodState>(selector?: (s: PaymentMethodState) => S) => S, usePaymentMethodActions: () => {
|
|
17
32
|
setBillingPaymentMethodState: (state: Partial<{}>) => void;
|
|
18
33
|
resetBillingPaymentMethodState: () => void;
|
|
19
34
|
loadPaymentMethod: () => Promise<void>;
|
|
@@ -22,8 +37,7 @@ export declare const usePaymentMethodActions: () => {
|
|
|
22
37
|
submitPaymentMethodSuccess: () => Promise<void>;
|
|
23
38
|
updatePaymentMethodBillingDetails: (payload: import("@frontegg/redux-store").WithCallback<import("@frontegg/redux-store").WithId<import("dist/@frontegg/rest-api").ISubscriptionUpdatePaymentMethodBillingDetails>>) => Promise<void>;
|
|
24
39
|
};
|
|
25
|
-
export declare const useInvoices: () =>
|
|
26
|
-
export declare const useInvoicesActions: () => {
|
|
40
|
+
export declare const useInvoices: <S = InvoicesState>(selector?: (s: InvoicesState) => S) => S, useInvoicesActions: () => {
|
|
27
41
|
setBillingInvoiceState: (state: Partial<InvoicesState>) => void;
|
|
28
42
|
resetBillingInvoiceState: () => void;
|
|
29
43
|
loadInvoices: () => Promise<void>;
|
|
@@ -31,13 +45,25 @@ export declare const useInvoicesActions: () => {
|
|
|
31
45
|
downloadInvoice: (payload: import("@frontegg/redux-store").DownloadInvoiceActionPayload) => Promise<void>;
|
|
32
46
|
downloadBillingInvoice: (payload: import("@frontegg/redux-store").DownloadInvoiceActionPayload) => Promise<void>;
|
|
33
47
|
};
|
|
34
|
-
export declare const
|
|
35
|
-
export declare const
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
48
|
+
export declare const useSubscription: <S = SubscriptionState>(selector?: (s: SubscriptionState) => S) => S;
|
|
49
|
+
export declare const useSubscriptionCancellation: () => {
|
|
50
|
+
loading: boolean;
|
|
51
|
+
error: import("dist/@frontegg/rest-api").FronteggApiError | null;
|
|
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>;
|
|
39
69
|
};
|
|
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,109 +1,83 @@
|
|
|
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
|
-
|
|
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
|
-
};
|
|
2
|
+
import { createSliceHooks } from '../useSnapshot/hookFactory';
|
|
3
|
+
|
|
4
|
+
/* ───────────────────────── subscriptions root helpers ───────────────────────── */
|
|
5
|
+
|
|
6
|
+
export const {
|
|
7
|
+
useSliceState: usePaymentProvider,
|
|
8
|
+
useSliceActions: usePaymentProviderActions
|
|
9
|
+
} = createSliceHooks({
|
|
10
|
+
getState: s => s.subscriptions.config,
|
|
11
|
+
getActions: a => a.subscriptions.config
|
|
12
|
+
});
|
|
13
|
+
export const {
|
|
14
|
+
useSliceState: usePlans,
|
|
15
|
+
useSliceActions: usePlansActions
|
|
16
|
+
} = createSliceHooks({
|
|
17
|
+
getState: s => s.subscriptions.plans,
|
|
18
|
+
getActions: a => a.subscriptions.plans
|
|
19
|
+
});
|
|
20
|
+
export const {
|
|
21
|
+
useSliceState: useCheckout,
|
|
22
|
+
useSliceActions: useCheckoutActions
|
|
23
|
+
} = createSliceHooks({
|
|
24
|
+
getState: s => s.subscriptions.checkout,
|
|
25
|
+
getActions: a => a.subscriptions.checkout
|
|
26
|
+
});
|
|
27
|
+
export const {
|
|
28
|
+
useSliceState: useStripeState,
|
|
29
|
+
useSliceActions: useStripeActions
|
|
30
|
+
} = createSliceHooks({
|
|
31
|
+
getState: s => s.subscriptions.stripe,
|
|
32
|
+
getActions: a => a.subscriptions.stripe
|
|
33
|
+
});
|
|
34
|
+
export const {
|
|
35
|
+
useSliceState: useVendorPublicConfig,
|
|
36
|
+
useSliceActions: useVendorPublicConfigActions
|
|
37
|
+
} = createSliceHooks({
|
|
38
|
+
getState: s => s.subscriptions.vendorPublicConfig,
|
|
39
|
+
getActions: a => a.subscriptions.vendorPublicConfig
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
/* ───────────────────────── billing sub-slices ───────────────────────── */
|
|
43
|
+
|
|
44
|
+
export const {
|
|
45
|
+
useSliceState: useBillingInformation,
|
|
46
|
+
useSliceActions: useBillingInformationActions
|
|
47
|
+
} = createSliceHooks({
|
|
48
|
+
getState: s => s.subscriptions.billing.information,
|
|
49
|
+
getActions: a => a.subscriptions.billing.information
|
|
50
|
+
});
|
|
51
|
+
export const {
|
|
52
|
+
useSliceState: usePaymentMethod,
|
|
53
|
+
useSliceActions: usePaymentMethodActions
|
|
54
|
+
} = createSliceHooks({
|
|
55
|
+
getState: s => s.subscriptions.billing.paymentMethod,
|
|
56
|
+
getActions: a => a.subscriptions.billing.paymentMethod
|
|
57
|
+
});
|
|
58
|
+
export const {
|
|
59
|
+
useSliceState: useInvoices,
|
|
60
|
+
useSliceActions: useInvoicesActions
|
|
61
|
+
} = createSliceHooks({
|
|
62
|
+
getState: s => s.subscriptions.billing.invoices,
|
|
63
|
+
getActions: a => a.subscriptions.billing.invoices
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
/* ───────────────────────── subscription sub-slice ───────────────────────── */
|
|
67
|
+
|
|
68
|
+
const {
|
|
69
|
+
useSliceState: useSubscriptionState,
|
|
70
|
+
useSliceActions: _useSubscriptionActions
|
|
71
|
+
} = createSliceHooks({
|
|
72
|
+
getState: s => s.subscriptions.billing.subscription,
|
|
73
|
+
getActions: a => a.subscriptions.billing.subscription
|
|
74
|
+
});
|
|
75
|
+
export const useSubscription = useSubscriptionState;
|
|
76
|
+
export const useSubscriptionCancellation = () => useSubscription().cancellation;
|
|
77
|
+
export const useSubscriptionRenewal = () => useSubscription().renewal;
|
|
89
78
|
export const useSubscriptionActions = () => {
|
|
90
|
-
const actions =
|
|
79
|
+
const actions = _useSubscriptionActions();
|
|
91
80
|
return _extends({}, actions, {
|
|
92
81
|
load: actions.loadSubscription
|
|
93
82
|
});
|
|
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;
|
|
109
83
|
};
|
|
@@ -0,0 +1,18 @@
|
|
|
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 {};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// hooksFactory.ts ✅ type-safe, no TS2345
|
|
2
|
+
|
|
3
|
+
import { useSnapshot } from './index';
|
|
4
|
+
import { useStore } from '../FronteggStoreContext';
|
|
5
|
+
/**
|
|
6
|
+
* Build hooks for any slice in Frontegg’s store tree.
|
|
7
|
+
*/
|
|
8
|
+
export function createSliceHooks(cfg) {
|
|
9
|
+
/* ---------- state ---------- */
|
|
10
|
+
const useSliceState = (selector = x => x) => selector(useSnapshot(cfg.getState(useStore().store)));
|
|
11
|
+
|
|
12
|
+
/* ---------- actions ---------- */
|
|
13
|
+
const useSliceActions = () => cfg.getActions(useStore().stateActions);
|
|
14
|
+
|
|
15
|
+
/* ---------- dialogs (optional) ---------- */
|
|
16
|
+
const useSliceDialogsState = () => useSnapshot(cfg.getDialogsState(useStore().store));
|
|
17
|
+
const useSliceDialogsActions = () => cfg.getDialogsActions(useStore().stateActions);
|
|
18
|
+
|
|
19
|
+
/* IntelliSense hides the dialogs hooks when you didn’t supply them */
|
|
20
|
+
return {
|
|
21
|
+
useSliceState,
|
|
22
|
+
useSliceActions,
|
|
23
|
+
useSliceDialogsState,
|
|
24
|
+
useSliceDialogsActions
|
|
25
|
+
};
|
|
26
|
+
}
|
package/vendor/hooks.d.ts
CHANGED
|
@@ -1,5 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export
|
|
3
|
-
export declare function useVendorState(): VendorState;
|
|
4
|
-
export declare function useVendorState<S>(stateMapper: VendorStateMapper<S>): S;
|
|
5
|
-
export declare const useVendorActions: () => VendorActions;
|
|
1
|
+
import type { VendorState, VendorActions } from '@frontegg/redux-store';
|
|
2
|
+
export declare const useVendorState: <S = VendorState>(selector?: (s: VendorState) => S) => S, useVendorActions: () => VendorActions;
|