@frontegg/redux-store 7.81.0 → 7.82.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/auth/ApplicationsState/actions.js +33 -10
- package/index.js +1 -1
- package/node/auth/ApplicationsState/actions.js +33 -10
- package/node/index.js +1 -1
- package/package.json +2 -2
|
@@ -90,17 +90,40 @@ export default ((store, api, sharedActions) => {
|
|
|
90
90
|
retryConfig
|
|
91
91
|
}) => {
|
|
92
92
|
try {
|
|
93
|
-
|
|
93
|
+
// Step 1: Fetch all assignment data in parallel
|
|
94
|
+
const [usersAppIds, tenantAppAssignments] = await Promise.all([retryIfNeeded(() => api.applications.getUsersApplicationsId({
|
|
94
95
|
userIds
|
|
95
|
-
}), retryConfig);
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
96
|
+
}), retryConfig), retryIfNeeded(() => api.applications.getTenantsApplicationsV2(), retryConfig)]);
|
|
97
|
+
|
|
98
|
+
// Step 2: Identify tenant-level free apps
|
|
99
|
+
const tenantFreeAppIds = tenantAppAssignments.flatMap(tenant => tenant.assignments).filter(assignment => assignment.accessType === ApplicationAccessType.FREE_ACCESS).map(assignment => assignment.appId);
|
|
100
|
+
|
|
101
|
+
// Step 3: Get all app IDs that need to be fetched (user assignments + tenant-free apps)
|
|
102
|
+
const userAssignedAppIds = getFlattenAppIds(usersAppIds);
|
|
103
|
+
const appIdsToFetch = [...new Set([...userAssignedAppIds, ...tenantFreeAppIds])];
|
|
104
|
+
|
|
105
|
+
// Step 4: Fetch details for all apps
|
|
106
|
+
let fetchedAppsMap = new Map();
|
|
107
|
+
if (appIdsToFetch.length > 0) {
|
|
108
|
+
const fetchedApps = await retryIfNeeded(() => api.applications.getApplicationsData({
|
|
109
|
+
appIds: appIdsToFetch
|
|
110
|
+
}), retryConfig);
|
|
111
|
+
fetchedAppsMap = new Map(fetchedApps.map(app => [app.id, app]));
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// Step 5: For each user, assemble their final list of applications.
|
|
100
115
|
return userIds.reduce((acc, userId) => {
|
|
101
|
-
var _usersAppIds$find
|
|
102
|
-
const
|
|
103
|
-
|
|
116
|
+
var _usersAppIds$find$app, _usersAppIds$find;
|
|
117
|
+
const finalApps = [];
|
|
118
|
+
const userSpecificAppIds = new Set((_usersAppIds$find$app = (_usersAppIds$find = usersAppIds.find(app => app.userId === userId)) == null ? void 0 : _usersAppIds$find.appIds) != null ? _usersAppIds$find$app : []);
|
|
119
|
+
|
|
120
|
+
// Add apps that are assigned to the user OR are app-level free OR are tenant-level free
|
|
121
|
+
fetchedAppsMap.forEach((app, appId) => {
|
|
122
|
+
if (userSpecificAppIds.has(appId) || app.accessType === ApplicationAccessType.FREE_ACCESS || tenantFreeAppIds.includes(appId)) {
|
|
123
|
+
finalApps.push(app);
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
acc[userId] = finalApps;
|
|
104
127
|
return acc;
|
|
105
128
|
}, {});
|
|
106
129
|
} catch (e) {
|
|
@@ -186,7 +209,7 @@ export default ((store, api, sharedActions) => {
|
|
|
186
209
|
return;
|
|
187
210
|
}
|
|
188
211
|
const apps = (_store$auth6 = store.auth) == null ? void 0 : (_store$auth6$applicat = _store$auth6.applicationsState) == null ? void 0 : _store$auth6$applicat.accountApplications;
|
|
189
|
-
const defaultApps = (_apps$filter = apps == null ? void 0 : apps.filter(app => app.accessType === ApplicationAccessType.FREE_ACCESS)) != null ? _apps$filter : [];
|
|
212
|
+
const defaultApps = (_apps$filter = apps == null ? void 0 : apps.filter(app => app.accessType === ApplicationAccessType.FREE_ACCESS || app.tenantApplicationAccessType === ApplicationAccessType.FREE_ACCESS)) != null ? _apps$filter : [];
|
|
190
213
|
if (appIds != null && appIds.length) {
|
|
191
214
|
var _store$auth$user$tena3, _store$auth7, _store$auth7$user;
|
|
192
215
|
const tenantId = (_store$auth$user$tena3 = (_store$auth7 = store.auth) == null ? void 0 : (_store$auth7$user = _store$auth7.user) == null ? void 0 : _store$auth7$user.tenantId) != null ? _store$auth$user$tena3 : '';
|
package/index.js
CHANGED
|
@@ -97,17 +97,40 @@ var _default = (store, api, sharedActions) => {
|
|
|
97
97
|
retryConfig
|
|
98
98
|
}) => {
|
|
99
99
|
try {
|
|
100
|
-
|
|
100
|
+
// Step 1: Fetch all assignment data in parallel
|
|
101
|
+
const [usersAppIds, tenantAppAssignments] = await Promise.all([(0, _helpers.retryIfNeeded)(() => api.applications.getUsersApplicationsId({
|
|
101
102
|
userIds
|
|
102
|
-
}), retryConfig);
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
103
|
+
}), retryConfig), (0, _helpers.retryIfNeeded)(() => api.applications.getTenantsApplicationsV2(), retryConfig)]);
|
|
104
|
+
|
|
105
|
+
// Step 2: Identify tenant-level free apps
|
|
106
|
+
const tenantFreeAppIds = tenantAppAssignments.flatMap(tenant => tenant.assignments).filter(assignment => assignment.accessType === _restApi.ApplicationAccessType.FREE_ACCESS).map(assignment => assignment.appId);
|
|
107
|
+
|
|
108
|
+
// Step 3: Get all app IDs that need to be fetched (user assignments + tenant-free apps)
|
|
109
|
+
const userAssignedAppIds = (0, _helpers2.getFlattenAppIds)(usersAppIds);
|
|
110
|
+
const appIdsToFetch = [...new Set([...userAssignedAppIds, ...tenantFreeAppIds])];
|
|
111
|
+
|
|
112
|
+
// Step 4: Fetch details for all apps
|
|
113
|
+
let fetchedAppsMap = new Map();
|
|
114
|
+
if (appIdsToFetch.length > 0) {
|
|
115
|
+
const fetchedApps = await (0, _helpers.retryIfNeeded)(() => api.applications.getApplicationsData({
|
|
116
|
+
appIds: appIdsToFetch
|
|
117
|
+
}), retryConfig);
|
|
118
|
+
fetchedAppsMap = new Map(fetchedApps.map(app => [app.id, app]));
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// Step 5: For each user, assemble their final list of applications.
|
|
107
122
|
return userIds.reduce((acc, userId) => {
|
|
108
|
-
var _usersAppIds$find
|
|
109
|
-
const
|
|
110
|
-
|
|
123
|
+
var _usersAppIds$find$app, _usersAppIds$find;
|
|
124
|
+
const finalApps = [];
|
|
125
|
+
const userSpecificAppIds = new Set((_usersAppIds$find$app = (_usersAppIds$find = usersAppIds.find(app => app.userId === userId)) == null ? void 0 : _usersAppIds$find.appIds) != null ? _usersAppIds$find$app : []);
|
|
126
|
+
|
|
127
|
+
// Add apps that are assigned to the user OR are app-level free OR are tenant-level free
|
|
128
|
+
fetchedAppsMap.forEach((app, appId) => {
|
|
129
|
+
if (userSpecificAppIds.has(appId) || app.accessType === _restApi.ApplicationAccessType.FREE_ACCESS || tenantFreeAppIds.includes(appId)) {
|
|
130
|
+
finalApps.push(app);
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
acc[userId] = finalApps;
|
|
111
134
|
return acc;
|
|
112
135
|
}, {});
|
|
113
136
|
} catch (e) {
|
|
@@ -193,7 +216,7 @@ var _default = (store, api, sharedActions) => {
|
|
|
193
216
|
return;
|
|
194
217
|
}
|
|
195
218
|
const apps = (_store$auth6 = store.auth) == null ? void 0 : (_store$auth6$applicat = _store$auth6.applicationsState) == null ? void 0 : _store$auth6$applicat.accountApplications;
|
|
196
|
-
const defaultApps = (_apps$filter = apps == null ? void 0 : apps.filter(app => app.accessType === _restApi.ApplicationAccessType.FREE_ACCESS)) != null ? _apps$filter : [];
|
|
219
|
+
const defaultApps = (_apps$filter = apps == null ? void 0 : apps.filter(app => app.accessType === _restApi.ApplicationAccessType.FREE_ACCESS || app.tenantApplicationAccessType === _restApi.ApplicationAccessType.FREE_ACCESS)) != null ? _apps$filter : [];
|
|
197
220
|
if (appIds != null && appIds.length) {
|
|
198
221
|
var _store$auth$user$tena3, _store$auth7, _store$auth7$user;
|
|
199
222
|
const tenantId = (_store$auth$user$tena3 = (_store$auth7 = store.auth) == null ? void 0 : (_store$auth7$user = _store$auth7.user) == null ? void 0 : _store$auth7$user.tenantId) != null ? _store$auth$user$tena3 : '';
|
package/node/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@frontegg/redux-store",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.82.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.
|
|
10
|
+
"@frontegg/rest-api": "7.82.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",
|