@7365admin1/layer-common 4.97.1-staging.687 → 4.97.1-staging.689

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.
@@ -10,11 +10,19 @@
10
10
  * FAILS OPEN. A route that is not listed here is allowed whatever the list says.
11
11
  * Only prefixes whose page each app gates on exactly one module are listed
12
12
  * (checked against every app's own `useLocalPermission` nav gate, 2026-09-11).
13
- * Shared or ambiguous pages stay out: calendar, keys (gated on `site-settings`),
14
- * the Cards and QR Tagging pages under access-mgmt (each app's own
15
- * `access-card-mgmt` gate), equipment and inventory, service-providers and
16
- * support tickets. The HID pages under access-mgmt ARE listed, one by one,
17
- * because each is gated on `hid-mgmt` alone (`useHidAccessPermission`).
13
+ * Shared or ambiguous pages stay out: equipment (every app's Equipment URL is a
14
+ * redirect to Inventory, no page of its own), the service-provider inventory
15
+ * page, support tickets and the org-level marketplace (vendor side, not
16
+ * `marketplace-mgmt`). The Pass & Key pages (`keys`) are gated on
17
+ * `passes-and-keys-mgmt` alone in both apps that have them (DV-0396), Cards and
18
+ * QR Tagging on `access-card-mgmt`, the service-provider list on
19
+ * `service-provider-mgmt`, Property Management's site Marketplace on
20
+ * `marketplace-mgmt`, CCTV Engine on `cctv-engine` and the four Security Ops
21
+ * pages on `security-ops`, so those ARE listed (2026-11-16). `cctv-mgmt` is
22
+ * catalogue-only: no page reads it, so there is nothing to map. The HID pages
23
+ * under access-mgmt are listed one by one, because each is gated on `hid-mgmt`
24
+ * alone (`useHidAccessPermission`); Cards is the bare `access-mgmt` route, so
25
+ * every page beside it MUST be listed or it would fall under the card module.
18
26
  *
19
27
  * NEVER MAPPED: the dashboard, settings, members, invitations and roles. A client
20
28
  * must always be able to run its own people and roles; the server never denies
@@ -71,9 +79,21 @@ export const MODULE_ROUTES: Readonly<Record<string, string>> = Object.freeze({
71
79
  "org-site-pool-schedule-area": "area-mgmt",
72
80
  "org-site-pool-schedule-unit": "unit-mgmt",
73
81
  "org-site-service-provider-mgmt": "service-provider-mgmt",
82
+ // The shared service-provider list in Security, Hygiene and the other trade apps
83
+ // (and Property Management): every app's menu reads `useServiceProviderPermission`,
84
+ // which is `service-provider-mgmt` (alias `service-provider`, same spelling group).
85
+ "org-site-service-providers": "service-provider-mgmt",
86
+ "org-site-marketplace": "marketplace-mgmt",
87
+ "org-site-keys": "passes-and-keys-mgmt",
88
+ "org-site-cctv-engine": "cctv-engine",
89
+ "org-site-security-ops": "security-ops",
90
+ // Cards is the bare `access-mgmt` route; every HID page and QR Tagging below
91
+ // is longer, so it wins. A new page under access-mgmt needs its own entry.
92
+ "org-site-access-mgmt": "access-card-mgmt",
93
+ "org-site-access-mgmt-qr-tagging": "access-card-mgmt",
74
94
  // HID access management (decision of 2026-10-16): the seven HID pages under
75
- // `access-mgmt`, named one by one so the Cards and QR Tagging pages beside
76
- // them stay unmapped. `hid-mgmt` is a governed module in core, so a client
95
+ // `access-mgmt`, named one by one so they stay apart from Cards and
96
+ // QR Tagging beside them. `hid-mgmt` is a governed module in core, so a client
77
97
  // that was not given it loses the pages and the drawer group together.
78
98
  "org-site-access-mgmt-hid-readers": "hid-mgmt",
79
99
  "org-site-access-mgmt-administrator": "hid-mgmt",
@@ -148,3 +168,23 @@ export function withoutDeniedRoutes<T extends TRouted>(
148
168
  return children.length ? [{ ...item, children }] : [];
149
169
  });
150
170
  }
171
+
172
+ /**
173
+ * A permission catalogue (`{ resource: actions }`, what `RolePermissionMain`
174
+ * takes) without the modules the client's list took away, so a role editor
175
+ * never offers a box the client cannot use (owner, 2026-11-16). `denied` is the
176
+ * server's deny list (`useLocalSetup().userAppModulesDenied`), which already
177
+ * covers a list saved with nothing ticked and never holds an always-allowed
178
+ * module. No deny list: the same object back.
179
+ */
180
+ export function withoutDeniedResources<T extends Record<string, unknown>>(
181
+ catalogue: T,
182
+ denied: readonly string[] | null | undefined,
183
+ ): T {
184
+ if (!Array.isArray(denied) || !denied.length || !catalogue || typeof catalogue !== "object") {
185
+ return catalogue;
186
+ }
187
+ return Object.fromEntries(
188
+ Object.entries(catalogue).filter(([resource]) => !denied.includes(resource.trim())),
189
+ ) as T;
190
+ }