@7365admin1/layer-common 4.10.1 → 4.10.2

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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @iservice365/layer-common
2
2
 
3
+ ## 4.10.2
4
+
5
+ ### Patch Changes
6
+
7
+ - d0b5995: Role editor: a service provider editing its roles on a client's site is no longer narrowed by the client's site module list. The site tier applies only when the site belongs to the organisation whose roles are being edited; otherwise the organisation's own list applies, as before.
8
+
3
9
  ## 4.10.1
4
10
 
5
11
  ### Patch Changes
@@ -1053,11 +1059,11 @@
1053
1059
  `utils/console-tier.ts` + `composables/useConsoleTier.ts` mirror the server's
1054
1060
  own rule from two endpoints the console already calls, unprojected:
1055
1061
 
1056
- GET /api/members/user/:user/app/admin the Seven365 staff membership
1057
- GET /api/roles/id/:role that membership's role document
1062
+ GET /api/members/user/:user/app/admin the Seven365 staff membership
1063
+ GET /api/roles/id/:role that membership's role document
1058
1064
 
1059
- owner = member.type === "admin" && role.type === "admin" && role.default === true
1060
- staff = member.type === "admin" && role.type === "admin"
1065
+ owner = member.type === "admin" && role.type === "admin" && role.default === true
1066
+ staff = member.type === "admin" && role.type === "admin"
1061
1067
 
1062
1068
  `role.default` is the marker because it is the only property of a platform
1063
1069
  staff role no API caller can set - `role.controller.ts` validates create and
@@ -203,7 +203,11 @@
203
203
  // Relative import: this layer's `utils/` is not auto-imported into consumers.
204
204
  import { showSiteField } from "../utils/role";
205
205
  import { holdsPermission } from "../utils/permission-spellings";
206
- import { catalogueForOrg, effectiveModules } from "../utils/org-modules";
206
+ import {
207
+ catalogueForOrg,
208
+ effectiveModules,
209
+ siteModulesForOrg,
210
+ } from "../utils/org-modules";
207
211
 
208
212
  const props = defineProps({
209
213
  orgId: {
@@ -362,7 +366,8 @@ const offeredPermissions = computed(() =>
362
366
  props.permissions ?? {},
363
367
  effectiveModules(
364
368
  (orgForModules.value as any)?.modules,
365
- (siteForModules.value as any)?.metadata?.modules
369
+ // Only the site's OWN organisation is narrowed by it (owner Q1).
370
+ siteModulesForOrg(siteForModules.value as any, props.orgId)
366
371
  )
367
372
  )
368
373
  );
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@7365admin1/layer-common",
3
3
  "license": "MIT",
4
4
  "type": "module",
5
- "version": "4.10.1",
5
+ "version": "4.10.2",
6
6
  "author": "7365admin1",
7
7
  "main": "./nuxt.config.ts",
8
8
  "//files": "What a consumer extending this layer actually loads. Without this npm ships the whole working tree - the changesets, the CI workflows, the render harness in tools/ and any scratch directory that happened to exist at publish time. Nuxt resolves a layer by directory, so every runtime directory below has to stay listed; adding a new top-level runtime directory means adding it here too.",
@@ -187,6 +187,32 @@ export function effectiveModules(
187
187
  return allowed.length ? allowed : org;
188
188
  }
189
189
 
190
+ /**
191
+ * The site tier, but only for the organisation that OWNS the site.
192
+ *
193
+ * Owner Q1, 2026-09-11: a service provider's role editor follows the
194
+ * PROVIDER's own company modules, never the client's. A provider editing
195
+ * roles while working on a client's site passes that site's id, and the site
196
+ * list there is what the CLIENT chose for its own staff - so it must not
197
+ * narrow the provider. Only when the site belongs to the organisation whose
198
+ * roles are being edited does the site tier apply.
199
+ *
200
+ * Fails open: no site, no `orgId` on it, or no org to compare with all mean
201
+ * "no site tier", which leaves the organisation's own list in charge.
202
+ */
203
+ export function siteModulesForOrg(
204
+ site: { orgId?: unknown; org?: unknown; metadata?: { modules?: unknown } } | null | undefined,
205
+ orgId: unknown,
206
+ ): readonly string[] | undefined {
207
+ // `org` is the legacy field name; core reads `orgId ?? org` the same way.
208
+ const siteOrg = String(site?.orgId ?? site?.org ?? "");
209
+ const org = String(orgId ?? "");
210
+ if (!siteOrg || !org || siteOrg !== org) return undefined;
211
+
212
+ const modules = site?.metadata?.modules;
213
+ return Array.isArray(modules) ? modules : undefined;
214
+ }
215
+
190
216
  function isKey(value: unknown): value is string {
191
217
  return typeof value === "string" && value.trim().length > 0;
192
218
  }