@7365admin1/layer-common 4.5.0 → 4.5.1-staging.294

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.
@@ -414,6 +414,27 @@ export default function useHidAmico() {
414
414
  );
415
415
  }
416
416
 
417
+ function getUserPasswordStatus(readerId: string, hidUserId: string | number) {
418
+ return useNuxtApp().$api<HidApiRecord>(
419
+ `${basePath}/readers/${readerId}/users/${hidUserId}/password`,
420
+ { method: "GET" },
421
+ );
422
+ }
423
+
424
+ function setUserPassword(readerId: string, hidUserId: string | number, password: string) {
425
+ return useNuxtApp().$api<HidApiRecord>(
426
+ `${basePath}/readers/${readerId}/users/${hidUserId}/password`,
427
+ { method: "PUT", body: { password } },
428
+ );
429
+ }
430
+
431
+ function deleteUserPassword(readerId: string, hidUserId: string | number) {
432
+ return useNuxtApp().$api<HidApiRecord>(
433
+ `${basePath}/readers/${readerId}/users/${hidUserId}/password`,
434
+ { method: "DELETE" },
435
+ );
436
+ }
437
+
417
438
  function deleteUserPin(readerId: string, hidUserId: string | number) {
418
439
  return useNuxtApp().$api<{ data: { pinEnrolled: boolean } }>(
419
440
  `${basePath}/readers/${readerId}/users/${hidUserId}/pin`,
@@ -530,6 +551,9 @@ export default function useHidAmico() {
530
551
  getUserPinStatus,
531
552
  setUserPin,
532
553
  deleteUserPin,
554
+ getUserPasswordStatus,
555
+ setUserPassword,
556
+ deleteUserPassword,
533
557
  getIdentities,
534
558
  getReaderUsers,
535
559
  getReaderAccessLogs,
@@ -52,6 +52,22 @@ export default function useHidNavigation() {
52
52
  params: { org, site },
53
53
  },
54
54
  },
55
+ {
56
+ // The enrollment screen, and the handoff's own nav label for it.
57
+ //
58
+ // `access-mgmt/administrator` renders HidUserEnrollment WITHOUT
59
+ // `card-management`, and that prop is what gates the Enroll action:
60
+ // <template v-if="!props.cardManagement" #actions>
61
+ // HID Cards mounts the same component WITH `card-management`, so it
62
+ // deliberately hides Enroll. Until now nothing linked to
63
+ // `administrator`, so the only screen that draws Enroll was
64
+ // reachable by typing the URL and Enroll looked missing entirely.
65
+ title: "Administrator",
66
+ route: {
67
+ name: "org-site-access-mgmt-administrator",
68
+ params: { org, site },
69
+ },
70
+ },
55
71
  {
56
72
  title: "HID Cards",
57
73
  route: {
@@ -1,3 +1,8 @@
1
+ // Explicit import rather than Nuxt auto-import. Identical inside the app, and it
2
+ // makes this catalogue readable OUTSIDE a Nuxt context -- which is what lets
3
+ // `utils/module-applications.ts` derive the module-to-application map from the
4
+ // apps themselves instead of a hand-written list that silently goes stale.
5
+ import { useCommonPermissions } from "./useCommonPermission";
1
6
  /**
2
7
  * THE LANDSCAPE ROLE CATALOGUE — the shared copy.
3
8
  *
@@ -1,3 +1,9 @@
1
+ // Explicit import rather than Nuxt auto-import. Identical inside the app, and it
2
+ // makes this catalogue readable OUTSIDE a Nuxt context -- which is what lets
3
+ // `utils/module-applications.ts` derive the module-to-application map from the
4
+ // apps themselves instead of a hand-written list that silently goes stale.
5
+ import { useCommonPermissions } from "./useCommonPermission";
6
+ import useCleaningPermission from "./useCleaningPermission";
1
7
  /**
2
8
  * THE MECHANICAL & ELECTRICAL ROLE CATALOGUE — the shared copy.
3
9
  *
@@ -115,6 +115,24 @@ export default function () {
115
115
  });
116
116
  }
117
117
 
118
+ /**
119
+ * The blocks, levels and units at a site that actually have an occupant.
120
+ * The other half of the unit picker: this narrows the cascade, then
121
+ * `getPeopleByUnit` answers "which person in this unit?".
122
+ */
123
+ async function getOccupiedStructure(
124
+ site: string,
125
+ { type = "", status = "active", block = "", level = "" } = {}
126
+ ) {
127
+ return await useNuxtApp().$api<Record<string, any>>(
128
+ `/api/people/site/${site}/occupied-structure`,
129
+ {
130
+ method: "GET",
131
+ query: { type, status, block, level },
132
+ }
133
+ );
134
+ }
135
+
118
136
  async function getPeopleByUnit(
119
137
  _id: string,
120
138
  { status = "active", type = "" } = {}
@@ -148,6 +166,7 @@ export default function () {
148
166
  findPersonByPlateNumberMultipleResult,
149
167
  findPersonByContact,
150
168
  getPeopleByUnit,
169
+ getOccupiedStructure,
151
170
  searchCompanyList,
152
171
  findUsersByPlateNumber,
153
172
  reviewResidentPerson,
@@ -1,3 +1,8 @@
1
+ // Explicit import rather than Nuxt auto-import. Identical inside the app, and it
2
+ // makes this catalogue readable OUTSIDE a Nuxt context -- which is what lets
3
+ // `utils/module-applications.ts` derive the module-to-application map from the
4
+ // apps themselves instead of a hand-written list that silently goes stale.
5
+ import { useCommonPermissions } from "./useCommonPermission";
1
6
  /**
2
7
  * THE PEST CONTROL ROLE CATALOGUE — the shared copy.
3
8
  *
@@ -1,3 +1,8 @@
1
+ // Explicit import rather than Nuxt auto-import. Identical inside the app, and it
2
+ // makes this catalogue readable OUTSIDE a Nuxt context -- which is what lets
3
+ // `utils/module-applications.ts` derive the module-to-application map from the
4
+ // apps themselves instead of a hand-written list that silently goes stale.
5
+ import { useCommonPermissions } from "./useCommonPermission";
1
6
  /**
2
7
  * THE POOL MAINTENANCE ROLE CATALOGUE — the shared copy.
3
8
  *
@@ -1,3 +1,8 @@
1
+ // Explicit import rather than Nuxt auto-import. Identical inside the app, and it
2
+ // makes this catalogue readable OUTSIDE a Nuxt context -- which is what lets
3
+ // `utils/module-applications.ts` derive the module-to-application map from the
4
+ // apps themselves instead of a hand-written list that silently goes stale.
5
+ import { useCommonPermissions } from "./useCommonPermission";
1
6
  /**
2
7
  * THE PROPERTY-MANAGEMENT ROLE CATALOGUE — the shared copy.
3
8
  *
@@ -1,3 +1,8 @@
1
+ // Explicit import rather than Nuxt auto-import. Identical inside the app, and it
2
+ // makes this catalogue readable OUTSIDE a Nuxt context -- which is what lets
3
+ // `utils/module-applications.ts` derive the module-to-application map from the
4
+ // apps themselves instead of a hand-written list that silently goes stale.
5
+ import { useCommonPermissions } from "./useCommonPermission";
1
6
  /**
2
7
  * THE SECURITY ROLE CATALOGUE — the shared copy.
3
8
  *
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.5.0",
5
+ "version": "4.5.1-staging.294",
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.",
@@ -73,6 +73,10 @@ declare type TFacility = {
73
73
  hourInterval?: number;
74
74
  isBookingFeeEnabled: boolean;
75
75
  isGuestEnabled: boolean;
76
+ /** Residents may complete this facility's checklist themselves. */
77
+ isResidentChecklistEnabled?: boolean;
78
+ /** Security may complete it. Mutually exclusive with the above. */
79
+ isSecurityChecklistEnabled?: boolean;
76
80
  bookingAmount: number | null;
77
81
  peakBookingFeeAmount?: number | null;
78
82
  bookingFeeGuestAmount?: number | null;
@@ -242,6 +242,9 @@ export const MDI_TO_SYMBOL: Record<string, string> = {
242
242
  "mdi-link-variant": "link",
243
243
  "mdi-lan-connect": "lan",
244
244
  "mdi-lan-disconnect": "link_off", // NEAREST: no disconnected-LAN glyph
245
+ "mdi-lan-check": "network_check",
246
+ "mdi-dialpad": "dialpad",
247
+ "mdi-headset": "headset_mic",
245
248
  "mdi-bluetooth": "bluetooth",
246
249
  "mdi-nfc": "nfc",
247
250
 
@@ -0,0 +1,146 @@
1
+ import useSecurityPermission from "../composables/useSecurityPermission";
2
+ import useCleaningPermission from "../composables/useCleaningPermission";
3
+ import useLandscapingPermission from "../composables/useLandscapingPermission";
4
+ import useMechanicalElectricalPermission from "../composables/useMechanicalElectricalPermission";
5
+ import usePestControlPermission from "../composables/usePestControlPermission";
6
+ import usePoolMaintenancePermission from "../composables/usePoolMaintenancePermission";
7
+ import usePropertyPermission from "../composables/usePropertyPermission";
8
+
9
+ /**
10
+ * WHICH APPLICATION EACH MODULE BELONGS TO.
11
+ *
12
+ * Owner report, 2026-09-10: *"I check security company and nature of business is
13
+ * security but have cleaning schedule management."* The Seven365 console's
14
+ * "Modules offered to this client" card listed the whole 47-entry catalogue as
15
+ * one flat alphabetical list, with nothing to say which service each module is
16
+ * part of — so a security client was offered Cleaning schedule management, and a
17
+ * cleaning client was offered Virtual patrol.
18
+ *
19
+ * R1 is written in terms of APPLICATIONS: *"assigns roles & permissions to an
20
+ * ORGANISATION for the applications it needs (Security, Cleaning, Pest, M&E, MA,
21
+ * Landscape, Pool)."* This is the map that makes that possible.
22
+ *
23
+ * ## DERIVED, never hand-written
24
+ *
25
+ * Each application's role editor already declares exactly what it offers — its
26
+ * `use*Permission` composable IS that declaration, and it is the same object the
27
+ * app passes to `RolePermissionMain` as `:permissions`. So the grouping is read
28
+ * from those composables at load time rather than copied out of them.
29
+ *
30
+ * A hand-written list would be correct on the day it was written and wrong the
31
+ * first time somebody adds a module to an app — silently, because nothing would
32
+ * fail. Deriving it means the console cannot disagree with the apps.
33
+ *
34
+ * The composables are pure (no Nuxt APIs, no lifecycle hooks), so calling them
35
+ * here is safe and costs one object construction each.
36
+ *
37
+ * ## A module can belong to SEVERAL applications, and that is not a mistake
38
+ *
39
+ * `cleaning-schedule-mgmt` is offered by BOTH Cleaning and M&E — M&E reuses the
40
+ * cleaning schedule module deliberately (`useMechanicalElectricalPermission`
41
+ * takes it from `useCleaningPermission`). `attendance-mgmt`, `site-settings`,
42
+ * `members`, `roles` and `invitations` are shared by nearly all of them.
43
+ *
44
+ * So this is a MANY-TO-MANY map, and the console has to show a shared module
45
+ * under each application that offers it. Presenting it as one-to-one would be
46
+ * the same class of wrongness as the flat list it replaces.
47
+ *
48
+ * ## It still stores a flat list of module keys
49
+ *
50
+ * `organizations.modules` is unchanged — a flat array of resource keys. Ticking
51
+ * an application ticks its keys. Nothing about the cascade, the server contract
52
+ * or the fail-open rule changes; this is how the choice is PRESENTED.
53
+ */
54
+
55
+ /** The seven service applications, in the order the owner names them in R1. */
56
+ export const APPLICATIONS = [
57
+ { key: "security", label: "Security", composable: useSecurityPermission },
58
+ { key: "cleaning", label: "Cleaning", composable: useCleaningPermission },
59
+ { key: "pest", label: "Pest control", composable: usePestControlPermission },
60
+ {
61
+ key: "mechanical-electrical",
62
+ label: "Mechanical & electrical",
63
+ composable: useMechanicalElectricalPermission,
64
+ },
65
+ { key: "landscape", label: "Landscape", composable: useLandscapingPermission },
66
+ { key: "pool", label: "Pool maintenance", composable: usePoolMaintenancePermission },
67
+ {
68
+ key: "property-management",
69
+ label: "Property management",
70
+ composable: usePropertyPermission,
71
+ },
72
+ ] as const;
73
+
74
+ export type ApplicationKey = (typeof APPLICATIONS)[number]["key"];
75
+
76
+ export type ApplicationModules = {
77
+ key: string;
78
+ label: string;
79
+ /** The resource keys this application's role editor offers. */
80
+ modules: string[];
81
+ };
82
+
83
+ /** Read one application's resource keys straight out of its own catalogue. */
84
+ function modulesOf(composable: () => { permissions?: Record<string, unknown> }): string[] {
85
+ try {
86
+ const { permissions } = composable() ?? {};
87
+ if (!permissions || typeof permissions !== "object") return [];
88
+ return Object.keys(permissions).filter(Boolean);
89
+ } catch {
90
+ /*
91
+ * FAILS OPEN as an empty list, never a throw. This runs at module load in
92
+ * the console; a composable that changes shape must not take the whole
93
+ * client-configuration screen down with it — the screen falls back to the
94
+ * ungrouped catalogue, which is exactly what it showed before this existed.
95
+ */
96
+ return [];
97
+ }
98
+ }
99
+
100
+ /** Every application with the modules it offers, derived from the apps themselves. */
101
+ export function applicationModules(): ApplicationModules[] {
102
+ return APPLICATIONS.map((app) => ({
103
+ key: app.key,
104
+ label: app.label,
105
+ modules: modulesOf(app.composable as never),
106
+ }));
107
+ }
108
+
109
+ /** Which applications offer this module. Empty means none of the seven do. */
110
+ export function applicationsForModule(resource: string): string[] {
111
+ if (!resource) return [];
112
+ return applicationModules()
113
+ .filter((app) => app.modules.includes(resource))
114
+ .map((app) => app.label);
115
+ }
116
+
117
+ /**
118
+ * Group a catalogue's keys by application, plus everything left over.
119
+ *
120
+ * The leftovers matter: `constants/permissions.ts` and the seven composables are
121
+ * two different lists and they do NOT agree — `customers`, `sites`,
122
+ * `subscriptions` and `robot-mgmt` appear in the flat catalogue but in no
123
+ * application, and `access-control`, `passes-and-keys-mgmt`, `online-forms`,
124
+ * `blocklist` and `resident-transactions` are the reverse. Dropping either set
125
+ * silently would be worse than showing it: an unticked module a client needs is
126
+ * a module they cannot be given.
127
+ */
128
+ export function groupModulesByApplication(catalogueKeys: readonly string[]): {
129
+ groups: ApplicationModules[];
130
+ ungrouped: string[];
131
+ } {
132
+ const keys = Array.isArray(catalogueKeys) ? catalogueKeys.filter(Boolean) : [];
133
+ const apps = applicationModules();
134
+
135
+ const groups = apps
136
+ .map((app) => ({
137
+ ...app,
138
+ modules: app.modules.filter((module) => keys.includes(module)),
139
+ }))
140
+ .filter((app) => app.modules.length > 0);
141
+
142
+ const claimed = new Set(groups.flatMap((app) => app.modules));
143
+ const ungrouped = keys.filter((key) => !claimed.has(key));
144
+
145
+ return { groups, ungrouped };
146
+ }