@7365admin1/layer-common 4.9.1-staging.309 → 4.9.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.
Files changed (36) hide show
  1. package/CHANGELOG.md +14 -4
  2. package/components/CameraForm.vue +3 -460
  3. package/components/CameraMain.vue +1 -118
  4. package/components/DashboardMain.vue +5 -17
  5. package/components/EntryPass/QrTemplatePreview.vue +25 -21
  6. package/components/Facility/BookingSetup.vue +0 -63
  7. package/components/HidIntercomManagement.vue +43 -193
  8. package/components/HidReaderUserRoster.vue +2 -32
  9. package/components/HidUserEnrollment.vue +212 -771
  10. package/components/InvitationClientForm.vue +1 -19
  11. package/components/Layout/NavigationDrawer.vue +2 -8
  12. package/components/MemberMain.vue +1 -10
  13. package/components/RolePermissionMain.vue +2 -7
  14. package/components/VehicleForm.vue +3 -11
  15. package/components/VisitorManagement.vue +5 -267
  16. package/composables/useFacility.ts +0 -11
  17. package/composables/useHidAmico.ts +0 -97
  18. package/composables/useHidNavigation.ts +1 -25
  19. package/composables/useLocalSetup.ts +0 -7
  20. package/composables/useMember.ts +0 -11
  21. package/composables/usePeople.ts +0 -19
  22. package/composables/useSiteSettings.ts +2 -114
  23. package/composables/useWebUsb.ts +11 -14
  24. package/package.json +1 -1
  25. package/plugins/secure-member.client.ts +2 -60
  26. package/types/facility.d.ts +0 -4
  27. package/types/people.d.ts +1 -4
  28. package/utils/materialSymbols.ts +0 -3
  29. package/utils/org-modules.ts +0 -26
  30. package/utils/role.ts +0 -18
  31. package/components/CameraPlateSyncDialog.vue +0 -626
  32. package/components/HidProfileQrCode.vue +0 -323
  33. package/pages/[org]/[site]/access-mgmt/hid-qr-code/index.vue +0 -23
  34. package/utils/anpr-direction.ts +0 -70
  35. package/utils/camera-plate-sync.ts +0 -141
  36. package/utils/module-routes.ts +0 -128
@@ -25,12 +25,6 @@ export function useLocalSetup() {
25
25
 
26
26
  const isAppRoleResolved = computed(() => userAppRoleStatus.value === "resolved");
27
27
 
28
- // The modules this person's apps must HIDE at the current org|site: the
29
- // client's Seven365 module list (RP-5, 2026-09-11), answered by the server as
30
- // a deny list. `[]` means hide nothing -- the answer for every client with no
31
- // list, and for any failure. Written only by `plugins/secure-member.client.ts`.
32
- const userAppModulesDenied = useState<string[]>("userAppModulesDenied", () => []);
33
-
34
28
  const id = useState<string | null>("memberShipOrgId", () => null);
35
29
 
36
30
  const orgNature = useState<string>("orgNature", () => "");
@@ -39,7 +33,6 @@ export function useLocalSetup() {
39
33
  userAppRole,
40
34
  userAppRoleStatus,
41
35
  isAppRoleResolved,
42
- userAppModulesDenied,
43
36
  id,
44
37
  orgNature,
45
38
  };
@@ -39,17 +39,6 @@ export default function useMember() {
39
39
  });
40
40
  }
41
41
 
42
- // The modules this person's apps must hide (RP-5): `{ denied: string[] }`,
43
- // resolved for the membership exactly as `getByUserType` resolves it. Awaited
44
- // by the router guard on every org|site change, so a hung request must not
45
- // stall navigation: it times out, and the caller treats that as "deny nothing".
46
- function getDeniedModules(user: string, type: string, org?: string, site?: string) {
47
- return useNuxtApp().$api<{ denied?: unknown }>(
48
- `/api/members/user/${user}/app/${type}/modules`,
49
- { method: "GET", query: { org, site }, timeout: 5000 },
50
- );
51
- }
52
-
53
42
  async function getAll({
54
43
  page = 1,
55
44
  search = "",
@@ -115,24 +115,6 @@ 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
-
136
118
  async function getPeopleByUnit(
137
119
  _id: string,
138
120
  { status = "active", type = "" } = {}
@@ -166,7 +148,6 @@ export default function () {
166
148
  findPersonByPlateNumberMultipleResult,
167
149
  findPersonByContact,
168
150
  getPeopleByUnit,
169
- getOccupiedStructure,
170
151
  searchCompanyList,
171
152
  findUsersByPlateNumber,
172
153
  reviewResidentPerson,
@@ -48,22 +48,7 @@ export default function () {
48
48
  }
49
49
  );
50
50
  }
51
- async function addCamera(
52
- camera: TSiteCamera &
53
- TCameraByRecorder & {
54
- /**
55
- * Clear the new ANPR camera's allowed list and blocklist on the device
56
- * before the site's vehicles are added. Absent means keep them.
57
- */
58
- clearCameraLists?: boolean;
59
- /**
60
- * The add-camera screen has already cleared and filled the camera
61
- * itself (`clearNewCamera` / `addNewCameraPlate`), so saving must not
62
- * touch the device again.
63
- */
64
- skipPlateSync?: boolean;
65
- }
66
- ) {
51
+ async function addCamera(camera: TSiteCamera & TCameraByRecorder) {
67
52
  return await useNuxtApp().$api<Record<string, any>>(`/api/site-cameras`, {
68
53
  method: "POST",
69
54
  body: camera,
@@ -100,83 +85,6 @@ export default function () {
100
85
  * Try an address before saving it. Read-only, and it runs on the server —
101
86
  * the browser never touches a recorder and never sees a credential.
102
87
  */
103
- /* ---- filling a NEW ANPR camera, before it is saved ---- */
104
-
105
- type TNewCameraDevice = {
106
- host: string;
107
- username: string;
108
- password: string;
109
- name?: string;
110
- direction: string;
111
- };
112
-
113
- /** The plates a new camera of this type receives, blocked ones first. */
114
- async function getNewCameraPlates(
115
- siteId: string,
116
- query: { host: string; direction: string }
117
- ) {
118
- return await useNuxtApp().$api<{ items: Array<Record<string, any>> }>(
119
- `/api/site-cameras/site/${siteId}/new-camera/plates`,
120
- { method: "GET", query }
121
- );
122
- }
123
-
124
- /** Empty the new camera's allowed list and blocklist on the device. */
125
- async function clearNewCamera(siteId: string, device: TNewCameraDevice) {
126
- return await useNuxtApp().$api<Record<string, any>>(
127
- `/api/site-cameras/site/${siteId}/new-camera/clear`,
128
- { method: "POST", body: device }
129
- );
130
- }
131
-
132
- /**
133
- * Write ONE vehicle's plate to the new camera. Answers `{ ok: false, reason,
134
- * kind }` when the camera refuses it.
135
- */
136
- async function addNewCameraPlate(
137
- siteId: string,
138
- device: TNewCameraDevice,
139
- plate: { vehicle: string; list: "allowed" | "blocked"; onlyIfMissing?: boolean }
140
- ) {
141
- return await useNuxtApp().$api<{ ok: boolean; reason?: string; kind?: string }>(
142
- `/api/site-cameras/site/${siteId}/new-camera/plate`,
143
- { method: "POST", body: { ...device, ...plate } }
144
- );
145
- }
146
-
147
- /* ---- "Sync vehicles": filling a camera that is already saved ---- */
148
-
149
- /** The plates this saved camera receives, blocked ones first. */
150
- async function getCameraPlates(cameraId: string) {
151
- return await useNuxtApp().$api<{ items: Array<Record<string, any>> }>(
152
- `/api/site-cameras/id/${cameraId}/plates`,
153
- { method: "GET" }
154
- );
155
- }
156
-
157
- /** Empty the saved camera's allowed list and blocklist on the device. */
158
- async function clearCamera(cameraId: string) {
159
- return await useNuxtApp().$api<Record<string, any>>(
160
- `/api/site-cameras/id/${cameraId}/clear`,
161
- { method: "POST" }
162
- );
163
- }
164
-
165
- /**
166
- * Write ONE vehicle's plate to the saved camera. The server uses the
167
- * camera's stored login. Answers `{ ok: false, reason, kind }` when the
168
- * camera refuses it.
169
- */
170
- async function addCameraPlate(
171
- cameraId: string,
172
- plate: { vehicle: string; list: "allowed" | "blocked"; onlyIfMissing?: boolean }
173
- ) {
174
- return await useNuxtApp().$api<{ ok: boolean; reason?: string; kind?: string }>(
175
- `/api/site-cameras/id/${cameraId}/plate`,
176
- { method: "POST", body: plate }
177
- );
178
- }
179
-
180
88
  async function testSiteCamera(
181
89
  siteId: string,
182
90
  payload: { host?: string } & TCameraByRecorder
@@ -204,21 +112,7 @@ export default function () {
204
112
  | "status"
205
113
  >
206
114
  > &
207
- TCameraByRecorder & {
208
- /**
209
- * The person confirmed that this type change clears the camera's
210
- * plate lists on the camera itself (to Exit: allowed list and
211
- * blocklist; Entry / Both / Residents to Visitors: allowed list).
212
- * Without it the API refuses that change.
213
- */
214
- confirmClearCameraLists?: boolean;
215
- /**
216
- * Save a type change that would fill the camera (to Entry / Both /
217
- * Residents, or Exit to Visitors) without filling it: the vehicles
218
- * are added afterwards with "Sync vehicles", or not now.
219
- */
220
- skipPlateSync?: boolean;
221
- }
115
+ TCameraByRecorder
222
116
  ) {
223
117
  return await useNuxtApp().$api<Record<string, any>>(
224
118
  `/api/site-cameras/id/${id}`,
@@ -409,12 +303,6 @@ export default function () {
409
303
  updateSite,
410
304
  addCamera,
411
305
  testSiteCamera,
412
- getNewCameraPlates,
413
- clearNewCamera,
414
- addNewCameraPlate,
415
- getCameraPlates,
416
- clearCamera,
417
- addCameraPlate,
418
306
  getAllSiteCameras,
419
307
  bulkImportSiteCameras,
420
308
  getSiteWall,
@@ -345,19 +345,16 @@ export default function useWebUsb() {
345
345
  70,
346
346
  );
347
347
 
348
- // The pass used to print five copies of the same QR - four 140px ones at
349
- // the corners around a 250px centre - so a strip could be cut apart. It now
350
- // prints a single large QR filling that same band (y 90 to 440, above the
351
- // company name at y 470), which scans far more reliably on a thermal print.
352
- // Generated at the size it is drawn at: the old corner copies were
353
- // downscaled from the 250px canvas, which softened their modules.
354
- const qrSize = 350;
355
- const qrCanvas = await QRCode.toCanvas(qrUrlImage, {
356
- width: qrSize,
357
- margin: 1,
358
- });
348
+ const qrSmall = 140;
349
+ const qrCenter = 250;
350
+ const margin = 20;
351
+ const qrCanvas = await QRCode.toCanvas(qrUrlImage, { width: qrCenter });
359
352
 
360
- ctx.drawImage(qrCanvas, (canvas.width - qrSize) / 2, 90, qrSize, qrSize);
353
+ ctx.drawImage(qrCanvas, margin, 90, qrSmall, qrSmall);
354
+ ctx.drawImage(qrCanvas, canvas.width - qrSmall - margin, 90, qrSmall, qrSmall);
355
+ ctx.drawImage(qrCanvas, (canvas.width - qrCenter) / 2, 110, qrCenter, qrCenter);
356
+ ctx.drawImage(qrCanvas, margin, 300, qrSmall, qrSmall);
357
+ ctx.drawImage(qrCanvas, canvas.width - qrSmall - margin, 300, qrSmall, qrSmall);
361
358
 
362
359
  ctx.font = "25px Arial";
363
360
  ctx.fillText(companyName || "", canvas.width / 2, 470);
@@ -404,8 +401,8 @@ export default function useWebUsb() {
404
401
  /**
405
402
  * The self-service onboarding QR: one large QR code, a "SCAN QR CODE"-style
406
403
  * subtext, and a dark site-name banner along the bottom - a single-purpose
407
- * gate sign, not the visitor-pass receipt `createReceiptLayout` produces
408
- * (that one pairs its QR with company, date, access and instruction lines).
404
+ * gate sign, not the multi-copy visitor-pass receipt `createReceiptLayout`
405
+ * produces (that one prints several QRs to be cut apart and handed out).
409
406
  */
410
407
  async function createOnboardingQrLayout(
411
408
  qrUrlImage: string,
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.9.1-staging.309",
5
+ "version": "4.9.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,4 @@
1
1
  import { z } from "zod";
2
- import { routeDenied } from "../utils/module-routes.ts";
3
2
 
4
3
  const hexSchema = z
5
4
  .string()
@@ -9,19 +8,13 @@ function statusOf(error: any) {
9
8
  return error?.statusCode ?? error?.status ?? error?.response?.status;
10
9
  }
11
10
 
12
- /** A route param that is a real id, or "": a malformed one is never sent. */
13
- function idParam(value: unknown) {
14
- return hexSchema.safeParse(value).success ? String(value) : "";
15
- }
16
-
17
11
  export default defineNuxtPlugin(() => {
18
12
  const router = useRouter();
19
- const { getByUserType, getDeniedModules } = useMember();
13
+ const { getByUserType } = useMember();
20
14
  const { getRoleById } = useRole();
21
15
  const { getById } = useOrg();
22
16
 
23
- const { userAppRole, userAppRoleStatus, userAppModulesDenied, id, orgNature } =
24
- useLocalSetup();
17
+ const { userAppRole, userAppRoleStatus, id, orgNature } = useLocalSetup();
25
18
 
26
19
  // Resolved once per signed-in session, not once per navigation. Keyed by the
27
20
  // user cookie so signing in as somebody else re-resolves.
@@ -29,12 +22,6 @@ export default defineNuxtPlugin(() => {
29
22
  let inFlight: Promise<void> | null = null;
30
23
  let hasMemberDocument = false;
31
24
 
32
- // The client's module list is decided per org|site, so it has its own key.
33
- // `deniedWanted` is the latest key asked for: an older answer that lands after
34
- // a newer navigation is dropped instead of overwriting it.
35
- let deniedFor: string | null = null;
36
- let deniedWanted: string | null = null;
37
-
38
25
  // Deliberately never redirects and never throws.
39
26
  //
40
27
  // `GET /api/members/user/:id/app/:type` returns 404 for any account holding no
@@ -78,38 +65,6 @@ export default defineNuxtPlugin(() => {
78
65
  userAppRoleStatus.value = "resolved";
79
66
  }
80
67
 
81
- // THE CLIENT'S MODULE LIST (RP-5, 2026-09-11). The server answers with the
82
- // modules this person's apps must HIDE, for the membership the role came from
83
- // (its org) at the route's site. It FAILS OPEN: no member document, the
84
- // endpoint missing (it 404s until API-core ships it), any error, or an answer
85
- // that is not a list all mean nothing is denied -- never "hide everything".
86
- // It never touches the role or its status.
87
- async function resolveDenied(userId: string, site: string) {
88
- if (!hasMemberDocument) {
89
- deniedFor = deniedWanted = null;
90
- userAppModulesDenied.value = [];
91
- return;
92
- }
93
- const org = id.value ?? "";
94
- const key = `${userId}|${org}|${site}`;
95
- if (deniedFor === key) return;
96
- deniedWanted = key;
97
-
98
- let denied: string[] = [];
99
- try {
100
- const APP = useRuntimeConfig().public.APP;
101
- const res = await getDeniedModules(userId, APP, org || undefined, site || undefined);
102
- const list = (res as any)?.denied;
103
- if (Array.isArray(list)) denied = list.filter((k): k is string => typeof k === "string");
104
- } catch {
105
- // Fail open: `denied` stays [].
106
- }
107
-
108
- if (deniedWanted !== key) return;
109
- deniedFor = key;
110
- userAppModulesDenied.value = denied;
111
- }
112
-
113
68
  router.beforeEach(async (to) => {
114
69
  const userId = useCookie("user").value ?? "";
115
70
 
@@ -120,19 +75,6 @@ export default defineNuxtPlugin(() => {
120
75
  // default open granted everything, gates that fail closed denied everything.
121
76
  // Awaited, so no gate is ever evaluated against an unresolved role.
122
77
  if (userId) await resolveAppRole(userId);
123
- if (userId) await resolveDenied(userId, idParam(to.params.site));
124
- else if (userAppModulesDenied.value.length) {
125
- // Signed out: never carry the previous person's list.
126
- deniedFor = deniedWanted = null;
127
- userAppModulesDenied.value = [];
128
- }
129
-
130
- // A page of a module Seven365 did not give this client goes to the site's
131
- // dashboard, which is never governed. Every governed route is an
132
- // `org-site-*` page, so both params are there. Unmapped routes pass.
133
- if (routeDenied(to.name, userAppModulesDenied.value)) {
134
- return { name: "org-site-dashboard", params: { org: to.params.org, site: to.params.site } };
135
- }
136
78
 
137
79
  const isMember = to.meta?.memberOnly;
138
80
 
@@ -73,10 +73,6 @@ 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;
80
76
  bookingAmount: number | null;
81
77
  peakBookingFeeAmount?: number | null;
82
78
  bookingFeeGuestAmount?: number | null;
package/types/people.d.ts CHANGED
@@ -22,14 +22,11 @@ declare type TPeople = {
22
22
  email?: string;
23
23
  files?: { name: string, id: string }[];
24
24
  isOwner?: boolean;
25
- // Link to this person's `users` row. Empty for the person types that carry
26
- // no login, and empty for a resident whose account was never written.
27
- user?: string;
28
25
  };
29
26
 
30
27
  declare type TPlateNumber = { plateNumber: string, recNo: string, _id?: string, status: "active" | "deleted" | "pending", type: TVehicleType };
31
28
 
32
29
 
33
- declare type TPeoplePayload = Pick<TGuest, "name" | "block" | "level" | "unit" | "unitName" | "contact" | "plateNumber" | "nric" | "contact" | "remarks" | "org" | "site" | "start" | "end" | "type" | "isOwner"> & { status?: string; user?: string }
30
+ declare type TPeoplePayload = Pick<TGuest, "name" | "block" | "level" | "unit" | "unitName" | "contact" | "plateNumber" | "nric" | "contact" | "remarks" | "org" | "site" | "start" | "end" | "type" | "isOwner"> & { status?: string }
34
31
 
35
32
  declare type TPeopleType = "guest" | "resident" | "tenant"
@@ -242,9 +242,6 @@ 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",
248
245
  "mdi-bluetooth": "bluetooth",
249
246
  "mdi-nfc": "nfc",
250
247
 
@@ -187,32 +187,6 @@ 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
-
216
190
  function isKey(value: unknown): value is string {
217
191
  return typeof value === "string" && value.trim().length > 0;
218
192
  }
package/utils/role.ts CHANGED
@@ -8,21 +8,3 @@
8
8
  */
9
9
  export const showSiteField = (siteState: boolean, type: string): boolean =>
10
10
  siteState && type !== "admin";
11
-
12
- /**
13
- * The Assign Role picker's list, with the member's CURRENT role always in it.
14
- *
15
- * The list is scoped to the site and capped at 100, so a member can hold a role
16
- * it does not return (pinned to another site, or past the cap). The picker then
17
- * showed a bare id and "Role already assigned" against nothing. Widen-only: the
18
- * current role is appended when missing, nothing is removed or reordered.
19
- */
20
- export function withCurrentRole<T extends { _id?: unknown; name?: unknown }>(
21
- roles: readonly T[] | null | undefined,
22
- currentId: string | null | undefined,
23
- currentName: string | null | undefined,
24
- ): Array<T | { _id: string; name: string }> {
25
- const list = Array.isArray(roles) ? [...roles] : [];
26
- if (!currentId || list.some((r) => String(r?._id) === currentId)) return list;
27
- return [...list, { _id: currentId, name: currentName || currentId }];
28
- }