@7365admin1/layer-common 4.186.1 → 4.187.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/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # @iservice365/layer-common
2
2
 
3
+ ## 4.187.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 3cd4404: Staff view applies the client's module list to menus (modules Super Admin left unticked are hidden).
8
+
9
+ ## 4.187.0
10
+
11
+ ### Minor Changes
12
+
13
+ - 2d5d671: Managing agents: the owner role reads with the view-only monitoring rights (Daily Occurrence Book, patrol logs, attendance, checklists) and MA staff roles may be given them, even when the owner's permissions were chosen before these existed.
14
+
15
+ ### Patch Changes
16
+
17
+ - 3dd8a7e: Notification bell and toast: site access request notifications open the organisation Sites page on Requests to approve / Our requests.
18
+
3
19
  ## 4.186.1
4
20
 
5
21
  ### Patch Changes
@@ -4062,11 +4078,11 @@ Monthly report: a month that had patrols opens the list of that month's patrol r
4062
4078
  `utils/console-tier.ts` + `composables/useConsoleTier.ts` mirror the server's
4063
4079
  own rule from two endpoints the console already calls, unprojected:
4064
4080
 
4065
- GET /api/members/user/:user/app/admin the Seven365 staff membership
4066
- GET /api/roles/id/:role that membership's role document
4081
+ GET /api/members/user/:user/app/admin the Seven365 staff membership
4082
+ GET /api/roles/id/:role that membership's role document
4067
4083
 
4068
- owner = member.type === "admin" && role.type === "admin" && role.default === true
4069
- staff = member.type === "admin" && role.type === "admin"
4084
+ owner = member.type === "admin" && role.type === "admin" && role.default === true
4085
+ staff = member.type === "admin" && role.type === "admin"
4070
4086
 
4071
4087
  `role.default` is the marker because it is the only property of a platform
4072
4088
  staff role no API caller can set - `role.controller.ts` validates create and
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.186.1",
5
+ "version": "4.187.1",
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.",
@@ -1,5 +1,6 @@
1
1
  import { z } from "zod";
2
2
  import { routeDenied } from "../utils/module-routes.ts";
3
+ import { withMaOwnerMonitorViews } from "../utils/org-modules.ts";
3
4
  import useStaffView, { STAFF_VIEW_ROLE, staffViewCovers } from "../composables/useStaffView.ts";
4
5
 
5
6
  const hexSchema = z
@@ -244,7 +245,12 @@ export default defineNuxtPlugin(() => {
244
245
  // The client's module list is asked for this org and site and does not
245
246
  // need the role, so it goes out while the role is being read.
246
247
  startDenied(userId, id.value ?? "", site);
247
- userAppRole.value = member.role ? await bounded(getRoleById(member.role)) : null;
248
+ const role = member.role ? await bounded(getRoleById(member.role)) : null;
249
+ // An MA owner's role also reads with the providers' monitoring views
250
+ // (owner 2026-11-17). Only a role that could be the owner grant needs the org.
251
+ const maybeOwner = role?.default === true && role?.type === "property_management_agency";
252
+ const org = maybeOwner && id.value ? await bounded(getById(id.value)).catch(() => null) : null;
253
+ userAppRole.value = withMaOwnerMonitorViews(role, org) ?? null;
248
254
  } catch (error) {
249
255
  // Anything that is not a 404 is transient. Stay unresolved so the next
250
256
  // navigation tries again rather than denying for the rest of the session.
@@ -277,13 +283,15 @@ export default defineNuxtPlugin(() => {
277
283
  // that is not a list all mean nothing is denied -- never "hide everything".
278
284
  // It never touches the role or its status.
279
285
  async function resolveDenied(userId: string, site: string) {
280
- // Seven365 staff are not capped by the client's module list.
281
- if (!hasMemberDocument || staffViewActive) {
286
+ // Seven365 staff inside a client see that client's menus (owner 2026-11-17:
287
+ // modules Super Admin left unticked still showed in staff view). The server
288
+ // answers staff with the client's list; its own checks keep staff exempt.
289
+ if (!staffViewActive && !hasMemberDocument) {
282
290
  deniedFor = deniedWanted = null;
283
291
  userAppModulesDenied.value = [];
284
292
  return;
285
293
  }
286
- const org = id.value ?? "";
294
+ const org = (staffViewActive ? lastStaffOrg : id.value) ?? "";
287
295
  const key = `${userId}|${org}|${site}`;
288
296
  if (deniedFor === key) return;
289
297
  deniedWanted = key;
@@ -107,6 +107,8 @@ export const VENDOR_ORDER_MODULE = "marketplace-vendor-order";
107
107
  */
108
108
  export const SP_INVITATION_SCREEN = "/service-provider-invitation";
109
109
  export const INVITATIONS_ROUTE = "org-organization-client-invitations";
110
+ /** The organisation app's Sites page (its Access requests panel reads ?requests=incoming|outgoing). */
111
+ export const SITES_ROUTE = "org-organization-sites";
110
112
 
111
113
  /**
112
114
  * What a row is about. `params.kind` when the sender set it; for older rows the
@@ -233,6 +235,8 @@ SITE_PAGES.myVisitors = SITE_PAGES.visitors;
233
235
  export const WEB_TARGET_KINDS = [
234
236
  ...Object.keys(SITE_PAGES),
235
237
  "serviceProviderInvite",
238
+ "siteJoinRequest",
239
+ "siteJoinAnswer",
236
240
  VENDOR_ORDER_MODULE,
237
241
  "robot",
238
242
  "client",
@@ -313,6 +317,21 @@ export function notificationTarget(
313
317
  };
314
318
  }
315
319
 
320
+ // A company asked for access to one of our sites (approve it) or we hear the
321
+ // answer to ours (owner 2026-11-17: the click went nowhere). Both live on the
322
+ // organisation app's Sites page, Access requests panel, on the right tab.
323
+ if (kind === "siteJoinRequest" || kind === "siteJoinAnswer") {
324
+ const org = String(item?.params?.org ?? "").trim() || organization;
325
+ if (!org) return null;
326
+ return {
327
+ name: SITES_ROUTE,
328
+ params: { organization: org },
329
+ query: { requests: kind === "siteJoinRequest" ? "incoming" : "outgoing" },
330
+ app: "org",
331
+ path: `/org/${encodeURIComponent(org)}/sites`,
332
+ };
333
+ }
334
+
316
335
  if (!item) return null;
317
336
  const staff = staffTarget(kind, item);
318
337
  if (staff) return staff;
@@ -256,6 +256,35 @@ function isKey(value: unknown): value is string {
256
256
  * its own nature holding an enumerated list, and only roles of that nature are
257
257
  * capped. Anything else - every client invited before this - returns `null`.
258
258
  */
259
+ /**
260
+ * The VIEW rights a managing agent's OWNER holds on the providers' records it
261
+ * monitors (owner decision 2026-11-17), even when Super Admin chose the owner's
262
+ * permissions on Invite Client before these existed. Same strings as core
263
+ * `MA_OWNER_MONITOR_VIEWS` and API-core `site-authz.util`. View only.
264
+ */
265
+ export const MA_OWNER_MONITOR_VIEWS: readonly string[] = Object.freeze([
266
+ "daily-occurrence-books:see-all-daily-occurrence",
267
+ "daily-occurrence-books:see-daily-occurrence-details",
268
+ "daily-occurrence-entries:see-daily-occurrence-entries-details",
269
+ "virtual-patrol:see-all-virtual-patrol-logs",
270
+ "attendance-mgmt:see-all-attendance",
271
+ "cleaning-schedule-mgmt:see-all-schedules",
272
+ ]);
273
+
274
+ /**
275
+ * The signed-in person's role as the gates read it: an MA owner grant role
276
+ * (`ownerGrant`) also holds `MA_OWNER_MONITOR_VIEWS`. Any other role is returned
277
+ * unchanged. Read-only - the stored role is never written.
278
+ */
279
+ export function withMaOwnerMonitorViews<R extends { permissions?: unknown }>(
280
+ role: R | null | undefined,
281
+ org: Parameters<typeof ownerGrant>[0],
282
+ ): R | null | undefined {
283
+ const grant = ownerGrant(org, role as any, "property_management_agency");
284
+ if (!grant || !role) return role;
285
+ return { ...role, permissions: [...new Set([...(role.permissions as string[]), ...MA_OWNER_MONITOR_VIEWS])] };
286
+ }
287
+
259
288
  export function ownerGrant(
260
289
  org: { _id?: unknown; nature?: unknown; invitedRole?: unknown } | null | undefined,
261
290
  grantRole: { _id?: unknown; org?: unknown; type?: unknown; default?: unknown; permissions?: unknown } | null | undefined,
@@ -271,7 +300,10 @@ export function ownerGrant(
271
300
  Array.isArray(permissions) &&
272
301
  permissions.length > 0 &&
273
302
  !permissions.includes("*");
274
- return chosen ? (permissions as unknown[]).map(String) : null;
303
+ if (!chosen) return null;
304
+ const list = (permissions as unknown[]).map(String);
305
+ // An MA owner also holds the providers' monitoring views, so its staff may be given them.
306
+ return type === "property_management_agency" ? [...new Set([...list, ...MA_OWNER_MONITOR_VIEWS])] : list;
275
307
  }
276
308
 
277
309
  /**