@7365admin1/layer-common 4.82.1-staging.475 → 4.83.0
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 +10 -4
- package/assets/css/primitives.css +0 -57
- package/assets/css/screens.css +4 -8
- package/components/AccessCardDetailsDialog.vue +4 -57
- package/components/AccessCardPreviewDialog.vue +50 -291
- package/components/AppSelect.vue +4 -143
- package/components/AttendanceDetailsDialog.vue +1 -48
- package/components/AttendanceMain.vue +10 -104
- package/components/AttendanceSettingsDialog.vue +1 -53
- package/components/BuildingUnitFormEdit.vue +0 -6
- package/components/BulletinBoardView.vue +1 -1
- package/components/Dialog/UpdateMoreAction.vue +1 -11
- package/components/DocumentForm.vue +112 -407
- package/components/DocumentManagement.vue +12 -213
- package/components/Facility/BookingSetup.vue +0 -63
- package/components/HidAccessLogDashboard.vue +17 -74
- package/components/HidIntercomManagement.vue +14 -183
- package/components/HidQrCodeConfiguration.vue +195 -17
- package/components/HidReaderManagement.vue +0 -398
- package/components/HidReaderUserRoster.vue +3 -44
- package/components/HidUserEnrollment.vue +250 -1573
- package/components/InventoryMain.vue +2 -11
- package/components/InvitationClientForm.vue +1 -19
- package/components/MemberMain.vue +1 -2
- package/components/MyAttendanceMain.vue +2 -60
- package/components/NotificationBell.vue +2 -14
- package/components/RolePermissionMain.vue +2 -4
- package/components/TableMain.vue +7 -22
- package/components/VisitorForm.vue +0 -12
- package/components/VisitorManagement.vue +5 -267
- package/composables/useAttendance.ts +0 -53
- package/composables/useAttendancePermission.ts +0 -25
- package/composables/useCleaningPermission.ts +0 -5
- package/composables/useDocument.ts +0 -7
- package/composables/useFacility.ts +0 -11
- package/composables/useHidAmico.ts +0 -165
- package/composables/useHidNavigation.ts +1 -25
- package/composables/useLandscapingPermission.ts +0 -5
- package/composables/useMember.ts +0 -12
- package/composables/usePeople.ts +0 -19
- package/composables/usePestControlPermission.ts +0 -5
- package/composables/usePoolMaintenancePermission.ts +0 -5
- package/composables/useSecurityPermission.ts +0 -5
- package/composables/useServiceProvider.ts +2 -40
- package/constants/permissions.ts +0 -1
- package/nuxt.config.ts +0 -18
- package/package.json +2 -4
- package/pages/[org]/[site]/access-mgmt/administrator/index.vue +1 -1
- package/pages/[org]/[site]/access-mgmt/hid-cards/index.vue +1 -1
- package/pages/[org]/[site]/access-mgmt/hid-readers/index.vue +1 -1
- package/plugins/API.ts +0 -16
- package/types/attendance.d.ts +1 -13
- package/types/document.d.ts +0 -14
- package/types/facility.d.ts +0 -4
- package/types/member.d.ts +0 -4
- package/types/people.d.ts +1 -28
- package/types/service-provider.d.ts +0 -5
- package/utils/notification-target.ts +4 -43
- package/utils/role.ts +2 -15
- package/components/AttendanceProxyDialog.vue +0 -391
- package/components/BuildingUnitManagement.vue +0 -298
- package/components/HidAccessPermissions.vue +0 -424
- package/components/HidProfileQrCode.vue +0 -332
- package/composables/useHidReaderSelection.ts +0 -50
- package/composables/useSiteCategory.ts +0 -45
- package/pages/[org]/[site]/access-mgmt/hid-qr-code/index.vue +0 -23
- package/server/plugins/no-powered-by.ts +0 -7
- package/utils/access-suspended.ts +0 -18
- package/utils/attendance-proxy.ts +0 -110
- package/utils/hid-enrolment-subject.ts +0 -144
- package/utils/hid-permission-assignments.ts +0 -190
- package/utils/hid-reader-selection.ts +0 -52
- package/utils/occupancy-role.ts +0 -109
- package/utils/sanitize-html.ts +0 -16
- package/utils/security-headers.ts +0 -52
- package/utils/service-type.ts +0 -30
|
@@ -1,144 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WHO A HID ENROLMENT IS FOR — the pure decisions behind the subject picker.
|
|
3
|
-
*
|
|
4
|
-
* `HidUserEnrollment.vue` can enrol a resident or a staff member. The write path
|
|
5
|
-
* always carried both (`subjectLink` maps them onto `person` or `member`); what
|
|
6
|
-
* was missing was a way to choose. These are the parts of that choice worth
|
|
7
|
-
* testing on their own, kept here because a `.vue` component has no test harness
|
|
8
|
-
* in this repo.
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
export type HidEnrolmentSubject = "resident" | "property_management";
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* The dropdown's options, in the order they are drawn.
|
|
15
|
-
*
|
|
16
|
-
* `title`/`value` because `AppSelect` takes that shape. A service-provider
|
|
17
|
-
* option is expected next; adding it here is most of the work, since the write
|
|
18
|
-
* path already maps `service_provider` onto `serviceProvider`.
|
|
19
|
-
*/
|
|
20
|
-
export const HID_ENROLMENT_SUBJECTS: ReadonlyArray<{
|
|
21
|
-
title: string;
|
|
22
|
-
value: HidEnrolmentSubject;
|
|
23
|
-
}> = [
|
|
24
|
-
{ title: "Resident", value: "resident" },
|
|
25
|
-
{ title: "Member", value: "property_management" },
|
|
26
|
-
];
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* What an EDIT calls the subject it is already attached to.
|
|
30
|
-
*
|
|
31
|
-
* Wider than the dropdown on purpose. An identity's category cannot change after
|
|
32
|
-
* it is created, so an edit states it rather than offering it — and the records
|
|
33
|
-
* in the wild include `service_provider`, which the dropdown does not offer yet
|
|
34
|
-
* but `openEdit` does resolve. Falling back to the first option would label a
|
|
35
|
-
* contractor "Resident", which is worse than saying nothing useful.
|
|
36
|
-
*/
|
|
37
|
-
export function subjectCategoryLabel(category: unknown): string {
|
|
38
|
-
const labels: Record<string, string> = {
|
|
39
|
-
resident: "Resident",
|
|
40
|
-
property_management: "Member",
|
|
41
|
-
service_provider: "Service provider",
|
|
42
|
-
visitor: "Visitor",
|
|
43
|
-
};
|
|
44
|
-
return labels[String(category ?? "")] ?? "Unknown";
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* One page of `GET /api/members`, read defensively.
|
|
49
|
-
*
|
|
50
|
-
* `paginate` puts `{ items, pages }` at the root, but `items` sits under `data`
|
|
51
|
-
* on some of this product's endpoints, so both are read — the same allowance
|
|
52
|
-
* `readCandidatePage` makes. A response that carries neither is an empty page
|
|
53
|
-
* rather than a thrown error: an empty staff picker with a placeholder beats a
|
|
54
|
-
* broken dialog.
|
|
55
|
-
*/
|
|
56
|
-
export function readMemberPage(response: unknown): {
|
|
57
|
-
items: Record<string, unknown>[];
|
|
58
|
-
pages: number;
|
|
59
|
-
total: number;
|
|
60
|
-
} {
|
|
61
|
-
const source = (response && typeof response === "object" ? response : {}) as Record<string, unknown>;
|
|
62
|
-
const nested = (source.data && typeof source.data === "object" ? source.data : {}) as Record<string, unknown>;
|
|
63
|
-
const raw = Array.isArray(source.items)
|
|
64
|
-
? source.items
|
|
65
|
-
: Array.isArray(nested.items)
|
|
66
|
-
? nested.items
|
|
67
|
-
: [];
|
|
68
|
-
const pages = Number(source.pages ?? nested.pages ?? 1);
|
|
69
|
-
const items = raw.filter((row): row is Record<string, unknown> => Boolean(row) && typeof row === "object");
|
|
70
|
-
/*
|
|
71
|
-
* `total` drives "showing 10 of 23" and the Load more button. It falls back to
|
|
72
|
-
* the page's own length, not to zero, so a response without it simply reads as
|
|
73
|
-
* "this is everything" — a missing count must never make the button offer a
|
|
74
|
-
* page that is not there.
|
|
75
|
-
*/
|
|
76
|
-
const total = Number(source.total ?? nested.total ?? items.length);
|
|
77
|
-
return {
|
|
78
|
-
items,
|
|
79
|
-
pages: Number.isFinite(pages) && pages > 0 ? Math.floor(pages) : 1,
|
|
80
|
-
total: Number.isFinite(total) && total >= 0 ? Math.floor(total) : items.length,
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* Can this member actually be enrolled?
|
|
86
|
-
*
|
|
87
|
-
* Reader access is bound by USER id — `resolvePermissionUserBindings` in
|
|
88
|
-
* `iservice365-core` drops every subject without one — so a member with no app
|
|
89
|
-
* account cannot be given access and is not a candidate. The id arrives as a
|
|
90
|
-
* string from JSON but may be an object if a caller passes a raw document, so
|
|
91
|
-
* both are read rather than trusting the shape.
|
|
92
|
-
*/
|
|
93
|
-
export function memberHasAccount(row: Record<string, unknown> | null | undefined): boolean {
|
|
94
|
-
const user = row?.user;
|
|
95
|
-
if (!user) return false;
|
|
96
|
-
if (typeof user === "object") {
|
|
97
|
-
const id = (user as { _id?: unknown; toString?: () => string })._id ?? user;
|
|
98
|
-
return Boolean(String(id ?? "").trim());
|
|
99
|
-
}
|
|
100
|
-
return Boolean(String(user).trim());
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
/**
|
|
104
|
-
* How a member reads in the picker: their name, and their role beneath it.
|
|
105
|
-
*
|
|
106
|
-
* THE ACCOUNT'S NAME FIRST, then the membership's. The two diverge — a
|
|
107
|
-
* membership is created with whatever name was typed at invite time, and the
|
|
108
|
-
* person may have set their own on the account since — and the account name is
|
|
109
|
-
* the one they are known by. `userName` comes from the members endpoint's own
|
|
110
|
-
* lookup into `users`; a member with no account has none, but such a row is not
|
|
111
|
-
* a candidate anyway (`memberHasAccount`).
|
|
112
|
-
*
|
|
113
|
-
* Every step falls back, because a row with no name at all still has to be
|
|
114
|
-
* selectable rather than blank, or it cannot be told apart from the next one.
|
|
115
|
-
*/
|
|
116
|
-
export function memberCandidateOf(row: Record<string, unknown>): {
|
|
117
|
-
subjectId: string;
|
|
118
|
-
name: string;
|
|
119
|
-
subtitle: string;
|
|
120
|
-
} {
|
|
121
|
-
const text = (value: unknown) => String(value ?? "").trim();
|
|
122
|
-
return {
|
|
123
|
-
subjectId: text(row._id),
|
|
124
|
-
name: text(row.userName) || text(row.name) || text(row.email) || "Member",
|
|
125
|
-
subtitle: text(row.roleName) || text(row.email) || "",
|
|
126
|
-
};
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
/**
|
|
130
|
-
* Why somebody the operator can see elsewhere is not in this list.
|
|
131
|
-
*
|
|
132
|
-
* Left unexplained, an absence reads as a broken screen — the same reason the
|
|
133
|
-
* resident cascade carries `unitResidentNote`. Returns "" when there is nothing
|
|
134
|
-
* to say, so the caller can render it unconditionally.
|
|
135
|
-
*/
|
|
136
|
-
export function hiddenSubjectNote(count: number, noun: "resident" | "member"): string {
|
|
137
|
-
if (!Number.isFinite(count) || count <= 0) return "";
|
|
138
|
-
const whole = Math.floor(count);
|
|
139
|
-
const subject = whole === 1 ? `1 ${noun}` : `${whole} ${noun}s`;
|
|
140
|
-
const verb = whole === 1 ? "is" : "are";
|
|
141
|
-
const holder = whole === 1 ? "that person has" : "they have";
|
|
142
|
-
return `${subject} at this site ${verb} not listed:`
|
|
143
|
-
+ ` HID enrollment needs an app account, and ${holder} none yet.`;
|
|
144
|
-
}
|
|
@@ -1,190 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WHO IS ASSIGNED TO A HID READER — the editing model behind the permissions
|
|
3
|
-
* dialog.
|
|
4
|
-
*
|
|
5
|
-
* This is the step that actually grants access. Enrolling a person gives the
|
|
6
|
-
* reader a face, a card or a PIN it can RECOGNISE; it puts nobody in the group
|
|
7
|
-
* the access rule is attached to, so a recognised person is still refused at
|
|
8
|
-
* the door (access log event 6). `PUT /sites/:siteId/permissions` is the only
|
|
9
|
-
* call in the system that writes that group membership.
|
|
10
|
-
*
|
|
11
|
-
* Two contracts make this file necessary rather than inlining the logic in the
|
|
12
|
-
* component:
|
|
13
|
-
*
|
|
14
|
-
* 1. **The PUT REPLACES the whole assignment set for the reader.** The server
|
|
15
|
-
* keeps other readers' rows and overwrites this reader's with exactly what
|
|
16
|
-
* is sent. The candidate list, however, is fetched ONE CATEGORY AT A TIME.
|
|
17
|
-
* Saving from the tab in front of you while sending only that tab's people
|
|
18
|
-
* would silently revoke every resident if you were looking at the service
|
|
19
|
-
* providers tab. So the edit state is held for the whole reader and the
|
|
20
|
-
* payload is always built from all of it.
|
|
21
|
-
*
|
|
22
|
-
* 2. **The body schema accepts three keys and nothing else.**
|
|
23
|
-
* `hidPermissionAssignmentSchema` is `{ subjectId, category, intercom }`,
|
|
24
|
-
* and Joi rejects unknown keys rather than stripping them. The candidate
|
|
25
|
-
* rows carry `name`, `subtitle`, `location` and friends for display, so the
|
|
26
|
-
* payload has to be narrowed deliberately — passing a candidate straight
|
|
27
|
-
* through is a 400.
|
|
28
|
-
*/
|
|
29
|
-
|
|
30
|
-
/** The three real categories. `intercom` is a candidate FILTER, never a category. */
|
|
31
|
-
export const HID_PERMISSION_CATEGORIES: THidPermissionCategory[] = [
|
|
32
|
-
"resident",
|
|
33
|
-
"property_management",
|
|
34
|
-
"service_provider",
|
|
35
|
-
];
|
|
36
|
-
|
|
37
|
-
export type HidAssignmentState = Map<string, { category: THidPermissionCategory; intercom: boolean }>;
|
|
38
|
-
|
|
39
|
-
/** Body row for `updateSitePermissions` — exactly the keys Joi allows. */
|
|
40
|
-
export type HidAssignmentPayload = {
|
|
41
|
-
subjectId: string;
|
|
42
|
-
category: THidPermissionCategory;
|
|
43
|
-
intercom: boolean;
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
function isRealCategory(value: unknown): value is THidPermissionCategory {
|
|
47
|
-
return HID_PERMISSION_CATEGORIES.includes(value as THidPermissionCategory);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* The reader's CURRENT assignments, as the edit state.
|
|
52
|
-
*
|
|
53
|
-
* Seeded from `getSitePermissions`, which returns every category at once —
|
|
54
|
-
* that is what makes a whole-reader payload possible from a one-category view.
|
|
55
|
-
* Rows with an unrecognised category are dropped rather than carried: sending
|
|
56
|
-
* one back fails the enum check and takes the entire save with it.
|
|
57
|
-
*/
|
|
58
|
-
export function seedAssignments(
|
|
59
|
-
assignments: readonly THidPermissionAssignment[] | undefined | null,
|
|
60
|
-
): HidAssignmentState {
|
|
61
|
-
const state: HidAssignmentState = new Map();
|
|
62
|
-
if (!Array.isArray(assignments)) return state;
|
|
63
|
-
for (const assignment of assignments) {
|
|
64
|
-
const subjectId = String(assignment?.subjectId ?? "");
|
|
65
|
-
if (!subjectId || !isRealCategory(assignment?.category)) continue;
|
|
66
|
-
state.set(subjectId, {
|
|
67
|
-
category: assignment.category,
|
|
68
|
-
intercom: assignment.intercom === true,
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
return state;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* Add or remove one person.
|
|
76
|
-
*
|
|
77
|
-
* `saved` is the state the dialog opened with, and it is consulted for one
|
|
78
|
-
* reason: the `intercom` flag. Nothing here edits that flag, but
|
|
79
|
-
* `userHasSiteIntercomPermission` reads it off these same rows, so it must
|
|
80
|
-
* survive a round trip through the checkbox.
|
|
81
|
-
*
|
|
82
|
-
* - **Untick then save** drops it, which is right — an unassigned person
|
|
83
|
-
* holding a dangling intercom right would keep answering the door panel
|
|
84
|
-
* after losing the door.
|
|
85
|
-
* - **Untick then re-tick, without saving** must restore it. Removing from the
|
|
86
|
-
* draft forgets the flag, so re-adding recovers it from `saved`; otherwise a
|
|
87
|
-
* misclick corrected a second later would silently revoke intercom on the
|
|
88
|
-
* next save, with nothing on screen to show it had happened.
|
|
89
|
-
*/
|
|
90
|
-
export function setAssignment(
|
|
91
|
-
state: HidAssignmentState,
|
|
92
|
-
saved: HidAssignmentState,
|
|
93
|
-
subjectId: string,
|
|
94
|
-
category: THidPermissionCategory,
|
|
95
|
-
selected: boolean,
|
|
96
|
-
): HidAssignmentState {
|
|
97
|
-
const next: HidAssignmentState = new Map(state);
|
|
98
|
-
const id = String(subjectId ?? "");
|
|
99
|
-
if (!id || !isRealCategory(category)) return next;
|
|
100
|
-
if (!selected) {
|
|
101
|
-
next.delete(id);
|
|
102
|
-
return next;
|
|
103
|
-
}
|
|
104
|
-
const intercom = next.get(id)?.intercom ?? saved.get(id)?.intercom ?? false;
|
|
105
|
-
next.set(id, { category, intercom: intercom === true });
|
|
106
|
-
return next;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
/** The whole reader's assignments, narrowed to the three keys the API accepts. */
|
|
110
|
-
export function toAssignmentPayload(state: HidAssignmentState): HidAssignmentPayload[] {
|
|
111
|
-
return [...state.entries()].map(([subjectId, value]) => ({
|
|
112
|
-
subjectId,
|
|
113
|
-
category: value.category,
|
|
114
|
-
intercom: value.intercom === true,
|
|
115
|
-
}));
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
/**
|
|
119
|
-
* The server sends `selected` with each candidate, describing what is SAVED.
|
|
120
|
-
* Once the dialog is open the local edit state is the truth, so the flag is
|
|
121
|
-
* recomputed rather than trusted — otherwise paging or searching would redraw
|
|
122
|
-
* a row with the saved value and quietly discard an unsaved tick.
|
|
123
|
-
*/
|
|
124
|
-
export function applySelection(
|
|
125
|
-
candidates: readonly THidPermissionCandidate[] | undefined | null,
|
|
126
|
-
state: HidAssignmentState,
|
|
127
|
-
): THidPermissionCandidate[] {
|
|
128
|
-
if (!Array.isArray(candidates)) return [];
|
|
129
|
-
return candidates.map((candidate) => ({
|
|
130
|
-
...candidate,
|
|
131
|
-
selected: state.has(String(candidate?.subjectId ?? "")),
|
|
132
|
-
}));
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
/** Per-category totals for the dialog header, counted over the whole reader. */
|
|
136
|
-
export function countByCategory(state: HidAssignmentState): Record<THidPermissionCategory, number> {
|
|
137
|
-
const counts = { resident: 0, property_management: 0, service_provider: 0 } as Record<
|
|
138
|
-
THidPermissionCategory,
|
|
139
|
-
number
|
|
140
|
-
>;
|
|
141
|
-
for (const value of state.values()) counts[value.category] += 1;
|
|
142
|
-
return counts;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
/** Has anything changed since the dialog opened? Drives the Save button. */
|
|
146
|
-
export function hasChanges(saved: HidAssignmentState, draft: HidAssignmentState): boolean {
|
|
147
|
-
if (saved.size !== draft.size) return true;
|
|
148
|
-
for (const [subjectId, value] of draft) {
|
|
149
|
-
const before = saved.get(subjectId);
|
|
150
|
-
if (!before) return true;
|
|
151
|
-
if (before.category !== value.category) return true;
|
|
152
|
-
if (before.intercom !== value.intercom) return true;
|
|
153
|
-
}
|
|
154
|
-
return false;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
/**
|
|
158
|
-
* What a listing response tells us: the rows, and how many pages exist.
|
|
159
|
-
*
|
|
160
|
-
* It deliberately does NOT return the current page, and the caller must keep
|
|
161
|
-
* owning that. `paginate` in `@7365admin1/node-server-utils` returns only
|
|
162
|
-
* `{ items, pages, pageRange }` — it never echoes the page it was asked for. A
|
|
163
|
-
* caller that read one back therefore got a default on every fetch and pinned
|
|
164
|
-
* itself to page one, so the pager moved and the rows never did.
|
|
165
|
-
*
|
|
166
|
-
* `items` sits at the root on some of these endpoints and under `data` on
|
|
167
|
-
* others, so both are read.
|
|
168
|
-
*/
|
|
169
|
-
export function readCandidatePage(response: unknown): {
|
|
170
|
-
items: THidPermissionCandidate[];
|
|
171
|
-
pages: number;
|
|
172
|
-
pageRange: string;
|
|
173
|
-
} {
|
|
174
|
-
const source = (response && typeof response === "object" ? response : {}) as Record<string, unknown>;
|
|
175
|
-
const nested = (source.data && typeof source.data === "object" ? source.data : {}) as Record<string, unknown>;
|
|
176
|
-
const items = Array.isArray(source.items)
|
|
177
|
-
? source.items
|
|
178
|
-
: Array.isArray(nested.items)
|
|
179
|
-
? nested.items
|
|
180
|
-
: [];
|
|
181
|
-
const pages = Number(source.pages ?? nested.pages ?? 1);
|
|
182
|
-
// `paginate` builds this ("1-10 of 37") and the table renders it verbatim.
|
|
183
|
-
// Without it the pager draws its placeholder, "-- - -- of --".
|
|
184
|
-
const pageRange = String(source.pageRange ?? nested.pageRange ?? "");
|
|
185
|
-
return {
|
|
186
|
-
items: items as THidPermissionCandidate[],
|
|
187
|
-
pages: Number.isFinite(pages) && pages > 0 ? pages : 1,
|
|
188
|
-
pageRange,
|
|
189
|
-
};
|
|
190
|
-
}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WHICH HID READER THE OPERATOR IS WORKING ON — the one rule behind it.
|
|
3
|
-
*
|
|
4
|
-
* Every HID screen used to hold its own `ref("")` and default it to
|
|
5
|
-
* `readers[0]`, so picking HID 2 on HID Reader Users and clicking through to
|
|
6
|
-
* HID Cards put you back on HID 1. They are separate PAGES, so the component
|
|
7
|
-
* unmounted and the ref was rebuilt from scratch every time — there was no way
|
|
8
|
-
* to make a choice stick. "I am working on HID 2" is a mode, not a per-screen
|
|
9
|
-
* preference.
|
|
10
|
-
*
|
|
11
|
-
* Navigation between those pages is a route change rather than a page load
|
|
12
|
-
* (`NavigationItem.vue` renders the menu's `route` through `:to`), so the
|
|
13
|
-
* module-scoped ref in `useHidReaderSelection` survives it. This file holds the
|
|
14
|
-
* part worth testing: deciding whether a remembered choice may still be used.
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
export type HidReaderChoice = { siteId: string; readerId: string };
|
|
18
|
-
|
|
19
|
-
/** Anything with an id — the four screens all carry a different reader shape. */
|
|
20
|
-
type ReaderLike = { _id?: unknown };
|
|
21
|
-
|
|
22
|
-
export const EMPTY_HID_READER_CHOICE: HidReaderChoice = { siteId: "", readerId: "" };
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* The reader a screen should show, given what this site actually has.
|
|
26
|
-
*
|
|
27
|
-
* A remembered id is honoured ONLY when it belongs to this site and is still in
|
|
28
|
-
* the list. That single condition covers every way it goes stale:
|
|
29
|
-
*
|
|
30
|
-
* - the operator switched site, so the id belongs to a site they have left
|
|
31
|
-
* - the reader was deleted or deactivated since they chose it
|
|
32
|
-
* - nothing has been chosen yet
|
|
33
|
-
*
|
|
34
|
-
* In all three the first reader is returned instead. The alternative — using
|
|
35
|
-
* the id anyway — sends requests for a reader the site does not own, which come
|
|
36
|
-
* back empty and read on screen as a reader with no users, no cards and no
|
|
37
|
-
* logs, rather than as the mistake it is.
|
|
38
|
-
*/
|
|
39
|
-
export function resolveHidReaderId(
|
|
40
|
-
siteId: string,
|
|
41
|
-
readers: readonly ReaderLike[] | null | undefined,
|
|
42
|
-
choice: HidReaderChoice = EMPTY_HID_READER_CHOICE,
|
|
43
|
-
): string {
|
|
44
|
-
const ids = (Array.isArray(readers) ? readers : [])
|
|
45
|
-
.map((reader) => String(reader?._id ?? ""))
|
|
46
|
-
.filter(Boolean);
|
|
47
|
-
|
|
48
|
-
if (choice.siteId === String(siteId ?? "") && ids.includes(choice.readerId)) {
|
|
49
|
-
return choice.readerId;
|
|
50
|
-
}
|
|
51
|
-
return ids[0] ?? "";
|
|
52
|
-
}
|
package/utils/occupancy-role.ts
DELETED
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* OWNER / OCCUPANT / PERSON IN CHARGE - the three standings a business
|
|
3
|
-
* tenancy has, and everything the product says about them.
|
|
4
|
-
*
|
|
5
|
-
* One list, because three screens read it: the form that asks the question
|
|
6
|
-
* (`PeopleFormMgmt`), the list and preview that print the answer back, and
|
|
7
|
-
* the row menu that reassigns it (`people-mgmt`). The values are the ones the
|
|
8
|
-
* server stores and validates - `OccupancyRoles` in core's `person.model.ts`
|
|
9
|
-
* - so a value added on one side has to be added on the other.
|
|
10
|
-
*/
|
|
11
|
-
export const OCCUPANCY_ROLE_OPTIONS: TOccupancyRoleOption[] = [
|
|
12
|
-
{
|
|
13
|
-
value: "owner",
|
|
14
|
-
title: "Owner",
|
|
15
|
-
action: "Assign Owner",
|
|
16
|
-
prompt: "Assign Owner",
|
|
17
|
-
description:
|
|
18
|
-
"The legal titleholder or primary deed owner of the property.",
|
|
19
|
-
},
|
|
20
|
-
{
|
|
21
|
-
value: "occupant",
|
|
22
|
-
title: "Occupant",
|
|
23
|
-
action: "Assign Occupant",
|
|
24
|
-
prompt: "Assign Occupant",
|
|
25
|
-
description:
|
|
26
|
-
"The person currently living in, renting, or utilizing the physical unit.",
|
|
27
|
-
},
|
|
28
|
-
{
|
|
29
|
-
value: "person-in-charge",
|
|
30
|
-
title: "Person in Charge",
|
|
31
|
-
action: "Assign Person in Charge",
|
|
32
|
-
prompt: "Assign Person in Charge (PIC)",
|
|
33
|
-
description:
|
|
34
|
-
"The designated manager responsible for maintenance, emergencies, and daily operations.",
|
|
35
|
-
},
|
|
36
|
-
];
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* The same three, in the order the ROW MENU draws them, which is not the
|
|
40
|
-
* order the form's radio does. Derived rather than re-typed so the wording
|
|
41
|
-
* cannot drift between the two.
|
|
42
|
-
*/
|
|
43
|
-
export const OCCUPANCY_ROLE_ACTIONS: TOccupancyRoleOption[] = (
|
|
44
|
-
["person-in-charge", "owner", "occupant"] as TOccupancyRole[]
|
|
45
|
-
).map(
|
|
46
|
-
(value) =>
|
|
47
|
-
OCCUPANCY_ROLE_OPTIONS.find(
|
|
48
|
-
(option) => option.value === value,
|
|
49
|
-
) as TOccupancyRoleOption,
|
|
50
|
-
);
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* The label for a stored role, or "" for a person who was never asked - which
|
|
54
|
-
* is everyone on a residential site and everyone saved before the question
|
|
55
|
-
* existed. Callers decide what to print instead; nobody should print a raw
|
|
56
|
-
* `person-in-charge` at a user.
|
|
57
|
-
*/
|
|
58
|
-
export function occupancyRoleLabel(role?: string | null): string {
|
|
59
|
-
return (
|
|
60
|
-
OCCUPANCY_ROLE_OPTIONS.find((option) => option.value === role)?.title ?? ""
|
|
61
|
-
);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* Does this person hold OWNER at their unit?
|
|
66
|
-
*
|
|
67
|
-
* The role when there is one, `isOwner` when there is not - the same test the
|
|
68
|
-
* server applies (`holdsUnitOwner` in core's `unit-owner.util.ts`). A person
|
|
69
|
-
* recorded before the role existed carries only the flag, and the people list
|
|
70
|
-
* already prints them as "Owner".
|
|
71
|
-
*/
|
|
72
|
-
export function holdsUnitOwner(person?: {
|
|
73
|
-
occupancyRole?: string | null;
|
|
74
|
-
isOwner?: boolean;
|
|
75
|
-
}): boolean {
|
|
76
|
-
if (!person) return false;
|
|
77
|
-
|
|
78
|
-
if (person.occupancyRole) return person.occupancyRole === "owner";
|
|
79
|
-
|
|
80
|
-
return person.isOwner === true;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* MUST THIS PERSON HAND THE UNIT OVER BEFORE THEY CAN BE DEACTIVATED?
|
|
85
|
-
*
|
|
86
|
-
* The owner of a unit does not leave while they still own it - the standing
|
|
87
|
-
* moves to another tenant at the same block, level and unit first.
|
|
88
|
-
*
|
|
89
|
-
* Keyed to the ROLE and never to `isOwner`, exactly as the server keys it
|
|
90
|
-
* (`mustHandOverBeforeDeactivating` in core): the flag is on every resident in
|
|
91
|
-
* the estate, and no residential screen can change it, so a rule keyed to it
|
|
92
|
-
* would trap records that can never satisfy it.
|
|
93
|
-
*/
|
|
94
|
-
export function mustHandOverBeforeDeactivating(person?: {
|
|
95
|
-
occupancyRole?: string | null;
|
|
96
|
-
}): boolean {
|
|
97
|
-
return person?.occupancyRole === "owner";
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
/**
|
|
101
|
-
* Why a deactivation was held back. The SERVER carries the enforcing copy of
|
|
102
|
-
* this rule and of these words (core `unit-owner.util.ts`); this one exists so
|
|
103
|
-
* the console can say it before the round trip rather than after.
|
|
104
|
-
*/
|
|
105
|
-
export function ownerHandoverRequiredMessage(name?: string): string {
|
|
106
|
-
const who = name?.trim() ? `"${name.trim()}"` : "This person";
|
|
107
|
-
|
|
108
|
-
return `${who} is the owner of this unit. Assign the owner role to another tenant at the same block, level and unit before deactivating them.`;
|
|
109
|
-
}
|
package/utils/sanitize-html.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import DOMPurify from "dompurify";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* The one way rich text typed by a user (announcements, facility descriptions,
|
|
5
|
-
* policies) reaches `v-html`. Keeps formatting, drops scripts, event handlers,
|
|
6
|
-
* `javascript:` links and embedded frames/forms. Browser-only (the apps are
|
|
7
|
-
* `ssr: false`); without a DOM it returns "" rather than unsanitised HTML.
|
|
8
|
-
*/
|
|
9
|
-
export function sanitizeHtml(html: unknown): string {
|
|
10
|
-
if (html === null || html === undefined || html === "") return "";
|
|
11
|
-
if (typeof window === "undefined" || !DOMPurify.isSupported) return "";
|
|
12
|
-
return DOMPurify.sanitize(String(html), {
|
|
13
|
-
USE_PROFILES: { html: true },
|
|
14
|
-
FORBID_TAGS: ["style", "form", "input", "button", "iframe", "object", "embed"],
|
|
15
|
-
});
|
|
16
|
-
}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Response headers every web app sends, on the HTML shell (Nitro route rules)
|
|
3
|
-
* and on the static files (nitro writes the same rules into Cloudflare's
|
|
4
|
-
* `_headers`). One list, so the eleven apps cannot drift apart.
|
|
5
|
-
*
|
|
6
|
-
* The ENFORCED Content-Security-Policy only carries the directives that cannot
|
|
7
|
-
* break a screen: who may frame us (clickjacking), no plugins, no <base> swap.
|
|
8
|
-
* The full policy ships as Report-Only first: the apps load Google Fonts,
|
|
9
|
-
* camera players and documents in iframes, sockets and the Spaces CDN, and a
|
|
10
|
-
* wrong guess there blanks a page. Violations show in the browser console;
|
|
11
|
-
* once a release runs clean, move it to the enforced header.
|
|
12
|
-
*
|
|
13
|
-
* HSTS deliberately has no `preload`: preload is decided for the whole
|
|
14
|
-
* iservice365.org domain at the apex and is hard to undo (owner/leads action).
|
|
15
|
-
*/
|
|
16
|
-
export const CSP_ENFORCED = [
|
|
17
|
-
"frame-ancestors 'self'",
|
|
18
|
-
"object-src 'none'",
|
|
19
|
-
"base-uri 'self'",
|
|
20
|
-
].join("; ");
|
|
21
|
-
|
|
22
|
-
export const CSP_REPORT_ONLY = [
|
|
23
|
-
"default-src 'self'",
|
|
24
|
-
"script-src 'self'",
|
|
25
|
-
"style-src 'self' 'unsafe-inline' https://fonts.googleapis.com",
|
|
26
|
-
"font-src 'self' data: https://fonts.gstatic.com",
|
|
27
|
-
"img-src 'self' data: blob: https:",
|
|
28
|
-
"media-src 'self' blob: https:",
|
|
29
|
-
"connect-src 'self' https: wss:",
|
|
30
|
-
"frame-src 'self' https:",
|
|
31
|
-
"worker-src 'self' blob:",
|
|
32
|
-
"object-src 'none'",
|
|
33
|
-
"base-uri 'self'",
|
|
34
|
-
"frame-ancestors 'self'",
|
|
35
|
-
"form-action 'self' https:",
|
|
36
|
-
"upgrade-insecure-requests",
|
|
37
|
-
].join("; ");
|
|
38
|
-
|
|
39
|
-
export const SECURITY_HEADERS: Record<string, string> = {
|
|
40
|
-
"strict-transport-security": "max-age=31536000; includeSubDomains",
|
|
41
|
-
"x-content-type-options": "nosniff",
|
|
42
|
-
"x-frame-options": "SAMEORIGIN",
|
|
43
|
-
"referrer-policy": "strict-origin-when-cross-origin",
|
|
44
|
-
// camera/mic: QR scan, photo capture; geolocation: attendance;
|
|
45
|
-
// usb/serial/hid: card readers (useWebUsb). Everything else is off.
|
|
46
|
-
"permissions-policy":
|
|
47
|
-
"camera=(self), microphone=(self), geolocation=(self), usb=(self), serial=(self), hid=(self), payment=(self), display-capture=(self), bluetooth=(), midi=(), magnetometer=(), gyroscope=(), accelerometer=()",
|
|
48
|
-
// allow-popups: payment and document windows we open keep working.
|
|
49
|
-
"cross-origin-opener-policy": "same-origin-allow-popups",
|
|
50
|
-
"content-security-policy": CSP_ENFORCED,
|
|
51
|
-
"content-security-policy-report-only": CSP_REPORT_ONLY,
|
|
52
|
-
};
|
package/utils/service-type.ts
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A SERVICE PROVIDER'S LINE OF BUSINESS, AS PEOPLE NAME IT.
|
|
3
|
-
*
|
|
4
|
-
* `/api/service-providers` returns the service CODE (`mechanical_electrical_services`),
|
|
5
|
-
* which is a database value, not something to show an operator. This is the same
|
|
6
|
-
* mapping `API-core src/utils/converter.ts spmServiceNewToOld` applies — copied
|
|
7
|
-
* rather than imported, because that is a server package this layer does not
|
|
8
|
-
* depend on.
|
|
9
|
-
*
|
|
10
|
-
* NOT the same labels as `utils/module-applications.ts APPLICATIONS`. Those name
|
|
11
|
-
* the seven role-permission applications ("Mechanical & electrical", "Pest
|
|
12
|
-
* control") and are keyed `mechanical-electrical`, not `*_services`. These are
|
|
13
|
-
* the shorter names the service-provider screens use ("M&E", "Pest Control").
|
|
14
|
-
*
|
|
15
|
-
* An unknown code is returned untouched: a new service type shows as its raw
|
|
16
|
-
* code, which is visibly odd, rather than vanishing from the row.
|
|
17
|
-
*/
|
|
18
|
-
const SERVICE_TYPE_LABELS: Readonly<Record<string, string>> = Object.freeze({
|
|
19
|
-
security_agency: "Security",
|
|
20
|
-
cleaning_services: "Cleaning",
|
|
21
|
-
pool_maintenance_services: "Pool Maintenance",
|
|
22
|
-
pest_control_services: "Pest Control",
|
|
23
|
-
landscaping_services: "Landscape",
|
|
24
|
-
mechanical_electrical_services: "Mechanical & Electrical",
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
export function serviceTypeLabel(service: string | null | undefined): string {
|
|
28
|
-
const code = String(service ?? "");
|
|
29
|
-
return SERVICE_TYPE_LABELS[code] ?? code;
|
|
30
|
-
}
|