@koloseum/utils 0.3.4 → 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 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) => (type === "backroom" ? Config.microservices.backroom : Config.microservices.lounges)
346
- .filter(({ slug }) => slug !== "account")
347
- .filter(({ features, roles }) => {
348
- // Superusers have access to everything
349
- if ("superuser" in role && role.superuser === true)
350
- return true;
351
- // Check if the user's role is a root role for this microservice
352
- if (roles?.some((r) => "root" in r && r.root === true && r.slug === role.slug))
353
- return true;
354
- // Check if the user's role has access to any features in this microservice
355
- return features.some((feature) => Access.roleHasAccessToFeature(role, feature, type));
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,29 +405,15 @@ 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 Lounges microservices
406
- if (type === "lounges") {
407
- const microservices = Config.microservices.lounges;
408
- for (const ms of microservices) {
409
- if (!ms.roles)
410
- continue;
411
- const featureInMs = ms.features.some(featureMatches);
412
- const msRole = ms.roles.find((r) => r.slug === role.slug);
413
- if (featureInMs && msRole && roleHasFeature(msRole))
414
- return true;
415
- }
416
- }
417
- // Check through Backroom microservices
418
- if (type === "backroom") {
419
- const microservices = Config.microservices.backroom;
420
- for (const ms of microservices) {
421
- if (!ms.roles)
422
- continue;
423
- const featureInMs = ms.features.some(featureMatches);
424
- const msRole = ms.roles.find((r) => r.slug === role.slug);
425
- if (featureInMs && msRole && roleHasFeature(msRole))
426
- return true;
427
- }
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 : [];
410
+ for (const ms of microservices) {
411
+ if (!ms.roles)
412
+ continue;
413
+ const featureInMs = ms.features.some(featureMatches);
414
+ const msRole = ms.roles.find((r) => r.slug === role.slug);
415
+ if (featureInMs && msRole && roleHasFeature(msRole))
416
+ return true;
428
417
  }
429
418
  // Return false
430
419
  return false;
package/dist/platform.js CHANGED
@@ -54,12 +54,12 @@ export const Config = {
54
54
  slug: "help",
55
55
  features: [
56
56
  {
57
- name: "Knowledge base",
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: "Support tickets",
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 information",
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 transfer",
357
+ name: "Ownership",
358
358
  description: "Request a transfer of ownership for your Lounge account.",
359
- slug: "transfer"
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.4",
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.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",