@frontegg/redux-store 7.82.0-alpha.1 → 7.82.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/ApplicationsState/actions.js +13 -1
- package/auth/ApplicationsState/helpers.d.ts +5 -0
- package/auth/ApplicationsState/helpers.js +13 -0
- package/auth/ApplicationsState/interfaces.d.ts +1 -0
- package/auth/ApplicationsState/state.js +2 -1
- package/index.js +1 -1
- package/node/auth/ApplicationsState/actions.js +12 -0
- package/node/auth/ApplicationsState/helpers.js +16 -2
- package/node/auth/ApplicationsState/state.js +2 -1
- package/node/index.js +1 -1
- package/package.json +2 -2
|
@@ -2,7 +2,7 @@ import _extends from "@babel/runtime/helpers/esm/extends";
|
|
|
2
2
|
import { ApplicationAccessType } from '@frontegg/rest-api';
|
|
3
3
|
import { deepResetState, errorHandler, retryIfNeeded } from '../../helpers';
|
|
4
4
|
import { initialState } from './state';
|
|
5
|
-
import { getFlattenAppIds } from './helpers';
|
|
5
|
+
import { getFlattenAppIds, combineUserApplicationsWithTenantFreeAccess } from './helpers';
|
|
6
6
|
export default ((store, api, sharedActions) => {
|
|
7
7
|
const actions = sharedActions;
|
|
8
8
|
const setApplicationsState = payload => {
|
|
@@ -11,6 +11,16 @@ export default ((store, api, sharedActions) => {
|
|
|
11
11
|
const resetApplicationsState = () => {
|
|
12
12
|
deepResetState(store, ['auth', 'applicationsState'], initialState);
|
|
13
13
|
};
|
|
14
|
+
const updateCombinedUserApplications = () => {
|
|
15
|
+
const {
|
|
16
|
+
userApplications,
|
|
17
|
+
accountApplications
|
|
18
|
+
} = store.auth.applicationsState;
|
|
19
|
+
const combinedUserApplications = combineUserApplicationsWithTenantFreeAccess(userApplications, accountApplications);
|
|
20
|
+
setApplicationsState({
|
|
21
|
+
combinedUserApplications
|
|
22
|
+
});
|
|
23
|
+
};
|
|
14
24
|
const loadUserApplications = async payload => {
|
|
15
25
|
setApplicationsState({
|
|
16
26
|
loading: true,
|
|
@@ -31,6 +41,7 @@ export default ((store, api, sharedActions) => {
|
|
|
31
41
|
fetching: false,
|
|
32
42
|
loading: false
|
|
33
43
|
});
|
|
44
|
+
updateCombinedUserApplications();
|
|
34
45
|
} catch (e) {
|
|
35
46
|
setApplicationsState({
|
|
36
47
|
loading: false,
|
|
@@ -77,6 +88,7 @@ export default ((store, api, sharedActions) => {
|
|
|
77
88
|
fetching: false,
|
|
78
89
|
loading: false
|
|
79
90
|
});
|
|
91
|
+
updateCombinedUserApplications();
|
|
80
92
|
} catch (e) {
|
|
81
93
|
setApplicationsState({
|
|
82
94
|
loading: false,
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
import { ApplicationAccessType, IApplicationsResponse } from '@frontegg/rest-api';
|
|
1
2
|
export declare const getFlattenAppIds: <T extends {
|
|
2
3
|
appIds?: string[];
|
|
3
4
|
}>(listWithAppIds: T[]) => string[];
|
|
5
|
+
export declare const combineUserApplicationsWithTenantFreeAccess: (userApplications?: IApplicationsResponse[], accountApplications?: (IApplicationsResponse & {
|
|
6
|
+
userIds?: string[];
|
|
7
|
+
tenantApplicationAccessType?: ApplicationAccessType;
|
|
8
|
+
})[]) => IApplicationsResponse[];
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ApplicationAccessType } from '@frontegg/rest-api';
|
|
1
2
|
export const getFlattenAppIds = listWithAppIds => {
|
|
2
3
|
var _listWithAppIds$map$r;
|
|
3
4
|
return (_listWithAppIds$map$r = listWithAppIds.map(({
|
|
@@ -10,4 +11,16 @@ export const getFlattenAppIds = listWithAppIds => {
|
|
|
10
11
|
});
|
|
11
12
|
return allAppIds;
|
|
12
13
|
}, [])) != null ? _listWithAppIds$map$r : [];
|
|
14
|
+
};
|
|
15
|
+
export const combineUserApplicationsWithTenantFreeAccess = (userApplications, accountApplications) => {
|
|
16
|
+
if (!userApplications && !accountApplications) return [];
|
|
17
|
+
const userAppIds = new Set((userApplications == null ? void 0 : userApplications.map(app => app.id)) || []);
|
|
18
|
+
const tenantFreeApps = (accountApplications == null ? void 0 : accountApplications.filter(app => app.tenantApplicationAccessType === ApplicationAccessType.FREE_ACCESS)) || [];
|
|
19
|
+
|
|
20
|
+
// Add tenant-free apps that aren't already in user apps
|
|
21
|
+
const additionalApps = tenantFreeApps.filter(app => !userAppIds.has(app.id));
|
|
22
|
+
|
|
23
|
+
// Create a combined list
|
|
24
|
+
const combinedApps = [...(userApplications || []), ...additionalApps];
|
|
25
|
+
return combinedApps;
|
|
13
26
|
};
|
|
@@ -9,5 +9,6 @@ export interface ApplicationsState {
|
|
|
9
9
|
userIds?: string[];
|
|
10
10
|
tenantApplicationAccessType?: ApplicationAccessType;
|
|
11
11
|
})[];
|
|
12
|
+
combinedUserApplications?: IApplicationsResponse[];
|
|
12
13
|
}
|
|
13
14
|
export type UserAppsAssignmentPayload = Pick<IAssignUserToApplicationsBody, 'userId' | 'appIds'>;
|
package/index.js
CHANGED
|
@@ -18,6 +18,16 @@ var _default = (store, api, sharedActions) => {
|
|
|
18
18
|
const resetApplicationsState = () => {
|
|
19
19
|
(0, _helpers.deepResetState)(store, ['auth', 'applicationsState'], _state.initialState);
|
|
20
20
|
};
|
|
21
|
+
const updateCombinedUserApplications = () => {
|
|
22
|
+
const {
|
|
23
|
+
userApplications,
|
|
24
|
+
accountApplications
|
|
25
|
+
} = store.auth.applicationsState;
|
|
26
|
+
const combinedUserApplications = (0, _helpers2.combineUserApplicationsWithTenantFreeAccess)(userApplications, accountApplications);
|
|
27
|
+
setApplicationsState({
|
|
28
|
+
combinedUserApplications
|
|
29
|
+
});
|
|
30
|
+
};
|
|
21
31
|
const loadUserApplications = async payload => {
|
|
22
32
|
setApplicationsState({
|
|
23
33
|
loading: true,
|
|
@@ -38,6 +48,7 @@ var _default = (store, api, sharedActions) => {
|
|
|
38
48
|
fetching: false,
|
|
39
49
|
loading: false
|
|
40
50
|
});
|
|
51
|
+
updateCombinedUserApplications();
|
|
41
52
|
} catch (e) {
|
|
42
53
|
setApplicationsState({
|
|
43
54
|
loading: false,
|
|
@@ -84,6 +95,7 @@ var _default = (store, api, sharedActions) => {
|
|
|
84
95
|
fetching: false,
|
|
85
96
|
loading: false
|
|
86
97
|
});
|
|
98
|
+
updateCombinedUserApplications();
|
|
87
99
|
} catch (e) {
|
|
88
100
|
setApplicationsState({
|
|
89
101
|
loading: false,
|
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.getFlattenAppIds = void 0;
|
|
6
|
+
exports.getFlattenAppIds = exports.combineUserApplicationsWithTenantFreeAccess = void 0;
|
|
7
|
+
var _restApi = require("@frontegg/rest-api");
|
|
7
8
|
const getFlattenAppIds = listWithAppIds => {
|
|
8
9
|
var _listWithAppIds$map$r;
|
|
9
10
|
return (_listWithAppIds$map$r = listWithAppIds.map(({
|
|
@@ -17,4 +18,17 @@ const getFlattenAppIds = listWithAppIds => {
|
|
|
17
18
|
return allAppIds;
|
|
18
19
|
}, [])) != null ? _listWithAppIds$map$r : [];
|
|
19
20
|
};
|
|
20
|
-
exports.getFlattenAppIds = getFlattenAppIds;
|
|
21
|
+
exports.getFlattenAppIds = getFlattenAppIds;
|
|
22
|
+
const combineUserApplicationsWithTenantFreeAccess = (userApplications, accountApplications) => {
|
|
23
|
+
if (!userApplications && !accountApplications) return [];
|
|
24
|
+
const userAppIds = new Set((userApplications == null ? void 0 : userApplications.map(app => app.id)) || []);
|
|
25
|
+
const tenantFreeApps = (accountApplications == null ? void 0 : accountApplications.filter(app => app.tenantApplicationAccessType === _restApi.ApplicationAccessType.FREE_ACCESS)) || [];
|
|
26
|
+
|
|
27
|
+
// Add tenant-free apps that aren't already in user apps
|
|
28
|
+
const additionalApps = tenantFreeApps.filter(app => !userAppIds.has(app.id));
|
|
29
|
+
|
|
30
|
+
// Create a combined list
|
|
31
|
+
const combinedApps = [...(userApplications || []), ...additionalApps];
|
|
32
|
+
return combinedApps;
|
|
33
|
+
};
|
|
34
|
+
exports.combineUserApplicationsWithTenantFreeAccess = combineUserApplicationsWithTenantFreeAccess;
|
|
@@ -10,7 +10,8 @@ const initialState = {
|
|
|
10
10
|
fetching: true,
|
|
11
11
|
error: null,
|
|
12
12
|
userApplications: [],
|
|
13
|
-
accountApplications: []
|
|
13
|
+
accountApplications: [],
|
|
14
|
+
combinedUserApplications: []
|
|
14
15
|
};
|
|
15
16
|
exports.initialState = initialState;
|
|
16
17
|
var _default = overrideState => (0, _proxy.createProxy)(initialState, overrideState);
|
package/node/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@frontegg/redux-store",
|
|
3
|
-
"version": "7.82.0
|
|
3
|
+
"version": "7.82.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
9
|
"@frontegg/entitlements-javascript-commons": "1.1.2",
|
|
10
|
-
"@frontegg/rest-api": "7.82.0
|
|
10
|
+
"@frontegg/rest-api": "7.82.0",
|
|
11
11
|
"fast-deep-equal": "3.1.3",
|
|
12
12
|
"get-value": "^3.0.1",
|
|
13
13
|
"proxy-compare": "^3.0.0",
|