@koloseum/utils 0.3.5 → 0.3.6
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/dist/client.js +17 -14
- package/dist/platform.js +5 -5
- package/package.json +2 -2
package/dist/client.js
CHANGED
|
@@ -342,18 +342,21 @@ export const Access = {
|
|
|
342
342
|
* @param type - The type of microservice to get the features for, i.e. "backroom" or "lounges"
|
|
343
343
|
* @returns The microservices that the role has access to.
|
|
344
344
|
*/
|
|
345
|
-
getMicroservicesForRole: (role, type) =>
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
345
|
+
getMicroservicesForRole: (role, type) => {
|
|
346
|
+
const microservices = type === "backroom" ? Config.microservices.backroom : type === "lounges" ? Config.microservices.lounges : [];
|
|
347
|
+
return microservices
|
|
348
|
+
.filter(({ slug }) => slug !== "account")
|
|
349
|
+
.filter(({ features, roles }) => {
|
|
350
|
+
// Superusers have access to everything
|
|
351
|
+
if ("superuser" in role && role.superuser === true)
|
|
352
|
+
return true;
|
|
353
|
+
// Check if the user's role is a root role for this microservice
|
|
354
|
+
if (roles?.some((r) => "root" in r && r.root === true && r.slug === role.slug))
|
|
355
|
+
return true;
|
|
356
|
+
// Check if the user's role has access to any features in this microservice
|
|
357
|
+
return features.some((feature) => Access.roleHasAccessToFeature(role, feature, type));
|
|
358
|
+
});
|
|
359
|
+
},
|
|
357
360
|
/**
|
|
358
361
|
* Renders the microservice features for the current user.
|
|
359
362
|
* @param user - The user to render the features for.
|
|
@@ -402,8 +405,8 @@ export const Access = {
|
|
|
402
405
|
const roleHasFeature = (r) => isRootFeature ||
|
|
403
406
|
("root" in r && r.root === true) ||
|
|
404
407
|
("featureSlugs" in r && feature.slug !== undefined && (r.featureSlugs?.includes(feature.slug) ?? false));
|
|
405
|
-
// Check through microservices for the given type
|
|
406
|
-
const microservices = type === "lounges" ? Config.microservices.lounges : Config.microservices.backroom;
|
|
408
|
+
// Check through microservices for the given type; invalid type grants no access
|
|
409
|
+
const microservices = type === "lounges" ? Config.microservices.lounges : type === "backroom" ? Config.microservices.backroom : [];
|
|
407
410
|
for (const ms of microservices) {
|
|
408
411
|
if (!ms.roles)
|
|
409
412
|
continue;
|
package/dist/platform.js
CHANGED
|
@@ -54,12 +54,12 @@ export const Config = {
|
|
|
54
54
|
slug: "help",
|
|
55
55
|
features: [
|
|
56
56
|
{
|
|
57
|
-
name: "Knowledge
|
|
57
|
+
name: "Knowledge Base",
|
|
58
58
|
description: "Browse and read help articles and basic guides.",
|
|
59
59
|
slug: "knowledge-base"
|
|
60
60
|
},
|
|
61
61
|
{
|
|
62
|
-
name: "
|
|
62
|
+
name: "Tickets",
|
|
63
63
|
description: "View support ticket list and status. Create a new ticket for assistance.",
|
|
64
64
|
slug: "tickets"
|
|
65
65
|
}
|
|
@@ -344,7 +344,7 @@ export const Config = {
|
|
|
344
344
|
slug: "account",
|
|
345
345
|
features: [
|
|
346
346
|
{
|
|
347
|
-
name: "Company
|
|
347
|
+
name: "Company",
|
|
348
348
|
description: "Review and update your Lounge's company information.",
|
|
349
349
|
slug: "company"
|
|
350
350
|
},
|
|
@@ -354,9 +354,9 @@ export const Config = {
|
|
|
354
354
|
slug: "finances"
|
|
355
355
|
},
|
|
356
356
|
{
|
|
357
|
-
name: "Ownership
|
|
357
|
+
name: "Ownership",
|
|
358
358
|
description: "Request a transfer of ownership for your Lounge account.",
|
|
359
|
-
slug: "
|
|
359
|
+
slug: "ownership"
|
|
360
360
|
}
|
|
361
361
|
],
|
|
362
362
|
roles: [
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@koloseum/utils",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.6",
|
|
4
4
|
"author": "Koloseum Technologies Limited",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "Utility logic for use across Koloseum web apps (TypeScript)",
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
"validator": "^13.15.15"
|
|
63
63
|
},
|
|
64
64
|
"devDependencies": {
|
|
65
|
-
"@koloseum/types": "^0.3.
|
|
65
|
+
"@koloseum/types": "^0.3.5",
|
|
66
66
|
"@playwright/test": "^1.55.0",
|
|
67
67
|
"@suprsend/web-components": "^0.4.0",
|
|
68
68
|
"@types/sanitize-html": "^2.16.0",
|