@frontegg/redux-store 6.123.0 → 6.124.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/auth/Entitlements/interfaces.d.ts +14 -0
- package/auth/Entitlements/saga.d.ts +15 -4
- package/auth/Entitlements/saga.js +19 -8
- package/auth/index.d.ts +1 -1
- package/auth/reducer.d.ts +3 -2
- package/auth/reducer.js +3 -1
- package/index.js +1 -1
- package/node/auth/Entitlements/saga.js +20 -7
- package/node/auth/reducer.js +3 -1
- package/node/index.js +1 -1
- package/package.json +1 -1
|
@@ -1,7 +1,21 @@
|
|
|
1
1
|
import { NotEntitledReason } from '@frontegg/rest-api';
|
|
2
|
+
/**
|
|
3
|
+
* Frontegg app entitlements configuration
|
|
4
|
+
*/
|
|
2
5
|
export interface EntitlementsOptions {
|
|
3
6
|
enabled: boolean;
|
|
4
7
|
}
|
|
8
|
+
/**
|
|
9
|
+
* Load entitlements callback
|
|
10
|
+
* @param isSucceeded true will be passed when completed successfully, false when failed
|
|
11
|
+
*/
|
|
12
|
+
export declare type LoadEntitlementsCallback = (isSucceeded: boolean) => void;
|
|
13
|
+
/**
|
|
14
|
+
* Load entitlements saga action payload
|
|
15
|
+
*/
|
|
16
|
+
export interface LoadEntitlementsActionPayload {
|
|
17
|
+
callback: LoadEntitlementsCallback;
|
|
18
|
+
}
|
|
5
19
|
export interface Entitlement {
|
|
6
20
|
isEntitled: boolean;
|
|
7
21
|
justification?: NotEntitledReason;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { UserEntitlementsResponse } from '@frontegg/rest-api';
|
|
2
|
+
import { PayloadAction } from '@reduxjs/toolkit';
|
|
3
|
+
import { LoadEntitlementsActionPayload } from './interfaces';
|
|
2
4
|
/**
|
|
3
5
|
* @param oldEntitlements
|
|
4
6
|
* @param newEntitlements
|
|
@@ -16,13 +18,22 @@ export declare function handleFetchedEntitlements(newEntitlementsResponse: UserE
|
|
|
16
18
|
type: string;
|
|
17
19
|
}>, void, UserEntitlementsResponse>;
|
|
18
20
|
/**
|
|
19
|
-
* Load entitlements
|
|
21
|
+
* Load entitlements data (exposed by frontegg app)
|
|
20
22
|
* Don't update entitlements data in the store when data is equal (deep check) to the existing store data
|
|
21
|
-
* @param
|
|
22
|
-
* @param callback called to notify the caller that the call is completed (for loading state)
|
|
23
|
+
* @param callback called on request completed with true if succeeded, false if failed
|
|
23
24
|
*/
|
|
24
|
-
export declare function
|
|
25
|
+
export declare function loadEntitlementsOnDemand(callback?: LoadEntitlementsActionPayload['callback']): Generator<Generator<import("redux-saga/effects").SelectEffect | import("redux-saga/effects").PutEffect<{
|
|
25
26
|
payload: Partial<UserEntitlementsResponse>;
|
|
26
27
|
type: string;
|
|
27
28
|
}>, void, UserEntitlementsResponse> | import("redux-saga/effects").CallEffect<UserEntitlementsResponse>, void, UserEntitlementsResponse>;
|
|
29
|
+
/**
|
|
30
|
+
* Load entitlements data for saga action
|
|
31
|
+
* Don't update entitlements data in the store when data is equal (deep check) to the existing store data
|
|
32
|
+
* @param payloadAction saga payload action including a payload with/out a callback
|
|
33
|
+
* The callback will be called on request completed with true if succeeded, false if failed
|
|
34
|
+
*/
|
|
35
|
+
export declare function loadEntitlements({ payload }: PayloadAction<LoadEntitlementsActionPayload>): Generator<Generator<Generator<import("redux-saga/effects").SelectEffect | import("redux-saga/effects").PutEffect<{
|
|
36
|
+
payload: Partial<UserEntitlementsResponse>;
|
|
37
|
+
type: string;
|
|
38
|
+
}>, void, UserEntitlementsResponse> | import("redux-saga/effects").CallEffect<UserEntitlementsResponse>, void, UserEntitlementsResponse>, void, unknown>;
|
|
28
39
|
export declare function entitlementsSagas(): Generator<import("redux-saga/effects").ForkEffect<never>, void, unknown>;
|
|
@@ -2,7 +2,6 @@ import isEqual from 'fast-deep-equal';
|
|
|
2
2
|
import { call, put, takeLeading, select } from 'redux-saga/effects';
|
|
3
3
|
import { api } from '@frontegg/rest-api';
|
|
4
4
|
import { actions } from '../reducer';
|
|
5
|
-
|
|
6
5
|
/**
|
|
7
6
|
* @param oldEntitlements
|
|
8
7
|
* @param newEntitlements
|
|
@@ -30,18 +29,30 @@ export function* handleFetchedEntitlements(newEntitlementsResponse) {
|
|
|
30
29
|
}
|
|
31
30
|
|
|
32
31
|
/**
|
|
33
|
-
* Load entitlements
|
|
32
|
+
* Load entitlements data (exposed by frontegg app)
|
|
34
33
|
* Don't update entitlements data in the store when data is equal (deep check) to the existing store data
|
|
35
|
-
* @param
|
|
36
|
-
* @param callback called to notify the caller that the call is completed (for loading state)
|
|
34
|
+
* @param callback called on request completed with true if succeeded, false if failed
|
|
37
35
|
*/
|
|
38
|
-
export function*
|
|
36
|
+
export function* loadEntitlementsOnDemand(callback) {
|
|
39
37
|
try {
|
|
40
38
|
const entitlements = yield call(api.entitlements.loadEntitlements);
|
|
41
39
|
yield handleFetchedEntitlements(entitlements);
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
40
|
+
callback == null ? void 0 : callback(true);
|
|
41
|
+
} catch (e) {
|
|
42
|
+
callback == null ? void 0 : callback(false);
|
|
43
|
+
} finally {}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Load entitlements data for saga action
|
|
48
|
+
* Don't update entitlements data in the store when data is equal (deep check) to the existing store data
|
|
49
|
+
* @param payloadAction saga payload action including a payload with/out a callback
|
|
50
|
+
* The callback will be called on request completed with true if succeeded, false if failed
|
|
51
|
+
*/
|
|
52
|
+
export function* loadEntitlements({
|
|
53
|
+
payload
|
|
54
|
+
}) {
|
|
55
|
+
yield loadEntitlementsOnDemand(payload == null ? void 0 : payload.callback);
|
|
45
56
|
}
|
|
46
57
|
export function* entitlementsSagas() {
|
|
47
58
|
yield takeLeading(actions.loadEntitlements, loadEntitlements);
|
package/auth/index.d.ts
CHANGED
|
@@ -727,7 +727,7 @@ declare const _default: {
|
|
|
727
727
|
setState: import("@reduxjs/toolkit").ActionCreatorWithPayload<Partial<import("./interfaces").AuthState>, string>;
|
|
728
728
|
setUser: import("@reduxjs/toolkit").ActionCreatorWithPayload<import("./interfaces").User, string>;
|
|
729
729
|
setEntitlements: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[Partial<import("@frontegg/rest-api").UserEntitlementsResponse>], Partial<import("@frontegg/rest-api").UserEntitlementsResponse>, string, never, never>;
|
|
730
|
-
loadEntitlements: import("@reduxjs/toolkit").
|
|
730
|
+
loadEntitlements: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[(import("./Entitlements/interfaces").LoadEntitlementsActionPayload | undefined)?], import("./Entitlements/interfaces").LoadEntitlementsActionPayload | undefined, string, never, never>;
|
|
731
731
|
};
|
|
732
732
|
};
|
|
733
733
|
export default _default;
|
package/auth/reducer.d.ts
CHANGED
|
@@ -27,6 +27,7 @@ import { AllAccountsActions } from './MSP/AllAccountsState';
|
|
|
27
27
|
import { AllAccountsDialogsActions } from './MSP/AllAccountsState/allAccountsDialogsState';
|
|
28
28
|
import { SecurityCenterActions } from './SecurityCenterState';
|
|
29
29
|
import { UserEntitlementsResponse } from '@frontegg/rest-api';
|
|
30
|
+
import { LoadEntitlementsActionPayload } from './Entitlements/interfaces';
|
|
30
31
|
declare const reducer: import("redux").Reducer<AuthState, import("redux").AnyAction>;
|
|
31
32
|
declare const actions: {
|
|
32
33
|
loadRecommendations: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>;
|
|
@@ -687,14 +688,14 @@ declare const actions: {
|
|
|
687
688
|
setState: import("@reduxjs/toolkit").ActionCreatorWithPayload<Partial<AuthState>, string>;
|
|
688
689
|
setUser: import("@reduxjs/toolkit").ActionCreatorWithPayload<User, string>;
|
|
689
690
|
setEntitlements: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[Partial<UserEntitlementsResponse>], Partial<UserEntitlementsResponse>, string, never, never>;
|
|
690
|
-
loadEntitlements: import("@reduxjs/toolkit").
|
|
691
|
+
loadEntitlements: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[(LoadEntitlementsActionPayload | undefined)?], LoadEntitlementsActionPayload | undefined, string, never, never>;
|
|
691
692
|
};
|
|
692
693
|
export declare type RootActions = {
|
|
693
694
|
setState: (state: Partial<AuthState>) => void;
|
|
694
695
|
resetState: () => void;
|
|
695
696
|
setUser: (user: User) => void;
|
|
696
697
|
setEntitlements: (entitlements: Partial<UserEntitlementsResponse>) => void;
|
|
697
|
-
loadEntitlements: () => void;
|
|
698
|
+
loadEntitlements: (payload?: LoadEntitlementsActionPayload) => void;
|
|
698
699
|
};
|
|
699
700
|
export declare type AuthActions = RootActions & LoginActions & SocialLoginActions & ActivateAccountActions & ImpersonateActions & AcceptInvitationActions & ForgotPasswordActions & ResetPhoneNumberActions & SignUpActions & ProfileActions & CustomLoginActions & SSOActions & MfaActions & TeamActions & GroupsActions & GroupsDialogsActions & ApiTokensActions & SecurityPolicyActions & AccountSettingsActions & TenantsActions & RolesActions & SessionsActions & RestrictionsActions & ProvisioningActions & PasskeysActions & AllAccountsActions & AllAccountsDialogsActions & SecurityCenterActions;
|
|
700
701
|
export { reducer, actions };
|
package/auth/reducer.js
CHANGED
|
@@ -47,6 +47,8 @@ const {
|
|
|
47
47
|
}, loginReducers, socialLoginsReducer, activateAccountReducers, impersonateReducers, acceptInvitationReducers, forgotPasswordReducers, resetPhoneNumberReducers, signUpReducers, profileReducers, customLoginReducers, ssoReducers, mfaReducers, teamReducers, groupsReducers, groupsDialogsReducers, apiTokensReducers, securityPolicyReducers, accountSettingsReducers, tenantsReducers, rolesReducers, sessionsReducers, sessionsPolicyReducers, restrictionsReducers, provisioningReducers, passkeysReducers, allAccountsReducers, allAccountsDialogsReducers, securityCenterReducers)
|
|
48
48
|
});
|
|
49
49
|
const actions = _extends({
|
|
50
|
-
loadEntitlements: createAction(`${authStoreName}/loadEntitlements
|
|
50
|
+
loadEntitlements: createAction(`${authStoreName}/loadEntitlements`, payload => ({
|
|
51
|
+
payload
|
|
52
|
+
}))
|
|
51
53
|
}, sliceActions, loginActions, socialLoginsActions, activateAccountActions, acceptInvitationActions, forgotPasswordActions, resetPhoneNumberActions, signUpActions, profileActions, customLoginActions, ssoActions, mfaActions, teamActions, groupsActions, groupsDialogsActions, apiTokensActions, securityPolicyActions, accountSettingsActions, tenantsActions, rolesActions, sessionsActions, sessionsPolicyActions, restrictionsActions, provisioningActions, impersonateActions, passkeysActions, allAccountsActions, securityCenterActions);
|
|
52
54
|
export { reducer, actions };
|
package/index.js
CHANGED
|
@@ -8,6 +8,7 @@ exports.entitlementsSagas = entitlementsSagas;
|
|
|
8
8
|
exports.handleFetchedEntitlements = handleFetchedEntitlements;
|
|
9
9
|
exports.isEntitlementsChanged = isEntitlementsChanged;
|
|
10
10
|
exports.loadEntitlements = loadEntitlements;
|
|
11
|
+
exports.loadEntitlementsOnDemand = loadEntitlementsOnDemand;
|
|
11
12
|
var _fastDeepEqual = _interopRequireDefault(require("fast-deep-equal"));
|
|
12
13
|
var _effects = require("redux-saga/effects");
|
|
13
14
|
var _restApi = require("@frontegg/rest-api");
|
|
@@ -39,18 +40,30 @@ function* handleFetchedEntitlements(newEntitlementsResponse) {
|
|
|
39
40
|
}
|
|
40
41
|
|
|
41
42
|
/**
|
|
42
|
-
* Load entitlements
|
|
43
|
+
* Load entitlements data (exposed by frontegg app)
|
|
43
44
|
* Don't update entitlements data in the store when data is equal (deep check) to the existing store data
|
|
44
|
-
* @param
|
|
45
|
-
* @param callback called to notify the caller that the call is completed (for loading state)
|
|
45
|
+
* @param callback called on request completed with true if succeeded, false if failed
|
|
46
46
|
*/
|
|
47
|
-
function*
|
|
47
|
+
function* loadEntitlementsOnDemand(callback) {
|
|
48
48
|
try {
|
|
49
49
|
const entitlements = yield (0, _effects.call)(_restApi.api.entitlements.loadEntitlements);
|
|
50
50
|
yield handleFetchedEntitlements(entitlements);
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
51
|
+
callback == null ? void 0 : callback(true);
|
|
52
|
+
} catch (e) {
|
|
53
|
+
callback == null ? void 0 : callback(false);
|
|
54
|
+
} finally {}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Load entitlements data for saga action
|
|
59
|
+
* Don't update entitlements data in the store when data is equal (deep check) to the existing store data
|
|
60
|
+
* @param payloadAction saga payload action including a payload with/out a callback
|
|
61
|
+
* The callback will be called on request completed with true if succeeded, false if failed
|
|
62
|
+
*/
|
|
63
|
+
function* loadEntitlements({
|
|
64
|
+
payload
|
|
65
|
+
}) {
|
|
66
|
+
yield loadEntitlementsOnDemand(payload == null ? void 0 : payload.callback);
|
|
54
67
|
}
|
|
55
68
|
function* entitlementsSagas() {
|
|
56
69
|
yield (0, _effects.takeLeading)(_reducer.actions.loadEntitlements, loadEntitlements);
|
package/node/auth/reducer.js
CHANGED
|
@@ -55,6 +55,8 @@ const {
|
|
|
55
55
|
});
|
|
56
56
|
exports.reducer = reducer;
|
|
57
57
|
const actions = (0, _extends2.default)({
|
|
58
|
-
loadEntitlements: (0, _toolkit.createAction)(`${_constants.authStoreName}/loadEntitlements
|
|
58
|
+
loadEntitlements: (0, _toolkit.createAction)(`${_constants.authStoreName}/loadEntitlements`, payload => ({
|
|
59
|
+
payload
|
|
60
|
+
}))
|
|
59
61
|
}, sliceActions, _LoginState.loginActions, _SocialLogins.socialLoginsActions, _ActivateState.activateAccountActions, _AcceptInvitationState.acceptInvitationActions, _ForgotPasswordState.forgotPasswordActions, _ResetPhoneNumberState.resetPhoneNumberActions, _SignUp.signUpActions, _ProfileState.profileActions, _CustomLoginState.customLoginActions, _SSOState.ssoActions, _MfaState.mfaActions, _TeamState.teamActions, _GroupsState.groupsActions, _groupsDialogsState.groupsDialogsActions, _ApiTokensState.apiTokensActions, _SecurityPolicyState.securityPolicyActions, _AccountSettingsState.accountSettingsActions, _TenantsState.tenantsActions, _RolesState.rolesActions, _SessionsState.sessionsActions, _SessionsPolicyState.sessionsPolicyActions, _RestrictionsState.restrictionsActions, _Provisioning.provisioningActions, _ImpersonationState.impersonateActions, _PasskeysState.passkeysActions, _AllAccountsState.allAccountsActions, _SecurityCenterState.securityCenterActions);
|
|
60
62
|
exports.actions = actions;
|
package/node/index.js
CHANGED