@7365admin1/layer-common 4.185.0 → 4.185.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,18 @@
|
|
|
1
1
|
# @iservice365/layer-common
|
|
2
2
|
|
|
3
|
+
## 4.185.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- a1d99d6: HID Reader Users: link an Unmapped user to the person it is from Edit (record only, nothing sent to the reader), so their access shows in their Service365 app.
|
|
8
|
+
- 62dbba1: HID Reader Users: warn on edit and on save that a user linked to nobody in iService365 will not show in their Service365 app.
|
|
9
|
+
|
|
10
|
+
## 4.185.1
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- b5d02c0: Visitor form: look saved people up by phone only once the number is complete for its country (visitor and contractor member).
|
|
15
|
+
|
|
3
16
|
## 4.185.0
|
|
4
17
|
|
|
5
18
|
### Minor Changes
|
|
@@ -4028,11 +4041,11 @@ Monthly report: a month that had patrols opens the list of that month's patrol r
|
|
|
4028
4041
|
`utils/console-tier.ts` + `composables/useConsoleTier.ts` mirror the server's
|
|
4029
4042
|
own rule from two endpoints the console already calls, unprojected:
|
|
4030
4043
|
|
|
4031
|
-
|
|
4032
|
-
|
|
4044
|
+
GET /api/members/user/:user/app/admin the Seven365 staff membership
|
|
4045
|
+
GET /api/roles/id/:role that membership's role document
|
|
4033
4046
|
|
|
4034
|
-
|
|
4035
|
-
|
|
4047
|
+
owner = member.type === "admin" && role.type === "admin" && role.default === true
|
|
4048
|
+
staff = member.type === "admin" && role.type === "admin"
|
|
4036
4049
|
|
|
4037
4050
|
`role.default` is the marker because it is the only property of a platform
|
|
4038
4051
|
staff role no API caller can set - `role.controller.ts` validates create and
|
|
@@ -291,13 +291,25 @@
|
|
|
291
291
|
it. -->
|
|
292
292
|
<div class="field-label">Enrolling <span>*</span></div>
|
|
293
293
|
<AppSelect
|
|
294
|
-
v-if="
|
|
294
|
+
v-if="pickingSubject && subjectCategoryOptions.length"
|
|
295
295
|
v-model="form.subjectCategory"
|
|
296
296
|
:items="subjectCategoryOptions"
|
|
297
297
|
klass="mb-3"
|
|
298
298
|
@update:model-value="onSubjectCategoryChanged"
|
|
299
299
|
/>
|
|
300
300
|
<p v-else-if="selectedUser" class="field-hint mb-3">{{ subjectCategoryLabel }}</p>
|
|
301
|
+
<!-- An UNMAPPED user (created on the reader itself, or enrolled before
|
|
302
|
+
enrolment linked a person) belongs to nobody in iService365, so no
|
|
303
|
+
Service365 / member app can show it. An edit cannot add the link -
|
|
304
|
+
the subject is chosen at enrolment - so say so before the save,
|
|
305
|
+
not after the person asks why their access is missing. -->
|
|
306
|
+
<p
|
|
307
|
+
v-if="selectedUser && !hasMappedRecord(selectedUser)"
|
|
308
|
+
class="field-hint field-hint--error mb-3"
|
|
309
|
+
data-test="hid-unlinked-warning"
|
|
310
|
+
>
|
|
311
|
+
{{ UNLINKED_HID_USER_WARNING }} {{ LINK_HID_USER_PROMPT }}
|
|
312
|
+
</p>
|
|
301
313
|
<!-- WHY THERE IS NOTHING TO PICK. Drawn in place of the dropdown when
|
|
302
314
|
the reader serves nobody, and beneath it when only some types were
|
|
303
315
|
removed. Without it, a missing option reads as a screen that failed
|
|
@@ -305,7 +317,7 @@
|
|
|
305
317
|
Nothing extra is needed to stop the save: with no type there is no
|
|
306
318
|
subject, and the save already refuses that. -->
|
|
307
319
|
<p
|
|
308
|
-
v-if="
|
|
320
|
+
v-if="pickingSubject && subjectCategoryNote"
|
|
309
321
|
class="field-hint mb-3"
|
|
310
322
|
:class="{ 'field-hint--error': enrolmentSubjects.emptied }"
|
|
311
323
|
>
|
|
@@ -327,7 +339,7 @@
|
|
|
327
339
|
asked for. A row that never had one keeps not having one; that
|
|
328
340
|
is not a reason to make somebody fill in a location before they
|
|
329
341
|
can change a PIN. -->
|
|
330
|
-
<template v-if="
|
|
342
|
+
<template v-if="pickingSubject && isResidentSubject">
|
|
331
343
|
<div class="field-label">Block <span>*</span></div>
|
|
332
344
|
<!-- The listener sits on a wrapper, NOT on AppSelect: AppSelect
|
|
333
345
|
spreads `$attrs` over its v-menu activator AFTER the activator's
|
|
@@ -372,7 +384,7 @@
|
|
|
372
384
|
with no unit has no candidates to show, and the dialog is then
|
|
373
385
|
purely the reader's own credentials - photo, PIN, password -
|
|
374
386
|
which is exactly the edit that must not be blocked. -->
|
|
375
|
-
<template v-if="isResidentSubject && (
|
|
387
|
+
<template v-if="isResidentSubject && (pickingSubject || form.unit)">
|
|
376
388
|
<div class="field-label">Resident <span>*</span></div>
|
|
377
389
|
<AppSelect
|
|
378
390
|
v-model="form.subjectId"
|
|
@@ -393,7 +405,7 @@
|
|
|
393
405
|
access is bound by user id, so there is nothing to bind. The note
|
|
394
406
|
below says how many were left out rather than letting a missing
|
|
395
407
|
colleague read as a bug. -->
|
|
396
|
-
<template v-if="
|
|
408
|
+
<template v-if="pickingSubject && isMemberSubject">
|
|
397
409
|
<div class="field-label">Member <span>*</span></div>
|
|
398
410
|
<AppSelect
|
|
399
411
|
v-model="form.subjectId"
|
|
@@ -428,7 +440,7 @@
|
|
|
428
440
|
so the two screens cannot disagree about who works here.
|
|
429
441
|
Unpaged - the endpoint returns the site's people in one response -
|
|
430
442
|
so searching and filtering cost no request. -->
|
|
431
|
-
<template v-if="
|
|
443
|
+
<template v-if="pickingSubject && isProviderSubject">
|
|
432
444
|
<div class="field-label">Service</div>
|
|
433
445
|
<AppSelect
|
|
434
446
|
v-model="providerService"
|
|
@@ -452,7 +464,7 @@
|
|
|
452
464
|
else: it is the one subject type that arrives a shift at a time,
|
|
453
465
|
and the people it adds fill in their own credentials from their
|
|
454
466
|
app afterwards. -->
|
|
455
|
-
<div class="hid-bulk-cta mb-3">
|
|
467
|
+
<div v-if="!selectedUser" class="hid-bulk-cta mb-3">
|
|
456
468
|
<AppButton
|
|
457
469
|
variant="ghost"
|
|
458
470
|
icon="mdi-account-multiple-plus-outline"
|
|
@@ -495,7 +507,7 @@
|
|
|
495
507
|
whatever the reader already holds. -->
|
|
496
508
|
<!-- A mirror of the chosen member's role, on the same rule as Name:
|
|
497
509
|
restated from the record, never collected. -->
|
|
498
|
-
<template v-if="
|
|
510
|
+
<template v-if="pickingSubject && isPersonSubject">
|
|
499
511
|
<div class="field-label">{{ subjectMirrorLabel }}</div>
|
|
500
512
|
<AppField
|
|
501
513
|
v-model="form.subjectRole"
|
|
@@ -1303,6 +1315,7 @@ const {
|
|
|
1303
1315
|
runObjectOperation,
|
|
1304
1316
|
createIdentity,
|
|
1305
1317
|
updateIdentity,
|
|
1318
|
+
linkReaderUser,
|
|
1306
1319
|
deleteIdentity,
|
|
1307
1320
|
pushStoredFace,
|
|
1308
1321
|
getSitePermissions,
|
|
@@ -1423,6 +1436,16 @@ const deleteSummary = computed(() =>
|
|
|
1423
1436
|
);
|
|
1424
1437
|
const cardDialog = ref(false);
|
|
1425
1438
|
const selectedUser = ref<HidUser | null>(null);
|
|
1439
|
+
/**
|
|
1440
|
+
* LINK FROM EDIT. An Unmapped user (created on the reader, or enrolled before
|
|
1441
|
+
* enrolment linked a person) can be linked to the person it is: the same
|
|
1442
|
+
* pickers as enrolment are drawn in the edit dialog, and the save writes OUR
|
|
1443
|
+
* record only (`linkReaderUser`) - nothing is sent to the reader, nobody is
|
|
1444
|
+
* removed from it - so their existing access shows in their Service365 app.
|
|
1445
|
+
*/
|
|
1446
|
+
const linkingUnmapped = computed(() => Boolean(selectedUser.value) && !hasMappedRecord(selectedUser.value as HidUser));
|
|
1447
|
+
/** The subject pickers are drawn while enrolling, and while linking an Unmapped user. */
|
|
1448
|
+
const pickingSubject = computed(() => !selectedUser.value || linkingUnmapped.value);
|
|
1426
1449
|
const cardUser = ref<HidUser | null>(null);
|
|
1427
1450
|
const physicalCards = ref<HidCard[]>([]);
|
|
1428
1451
|
const physicalCardsByUserId = ref<Record<string, HidCard[]>>({});
|
|
@@ -3273,6 +3296,26 @@ async function saveUser() {
|
|
|
3273
3296
|
},
|
|
3274
3297
|
};
|
|
3275
3298
|
|
|
3299
|
+
if (selectedUser.value && linkingUnmapped.value && form.subjectId) {
|
|
3300
|
+
/*
|
|
3301
|
+
* LINK ONLY. Our record gets the person (and the account behind them);
|
|
3302
|
+
* the reader is not written - the user, face, card, PIN and door access
|
|
3303
|
+
* it already holds stay as they are. Anything else edited in the same
|
|
3304
|
+
* save is left for a second save, so the link never rides on a reader
|
|
3305
|
+
* write that could fail half way.
|
|
3306
|
+
*/
|
|
3307
|
+
const linkReaderId = String(selectedUser.value.reader || readerId);
|
|
3308
|
+
await linkReaderUser(linkReaderId, String(selectedUser.value.hidUserId || form.hidUserId), {
|
|
3309
|
+
...subjectLinkOf(form.subjectCategory, form.subjectId),
|
|
3310
|
+
name: form.name,
|
|
3311
|
+
registration: form.registration,
|
|
3312
|
+
});
|
|
3313
|
+
formDialog.value = false;
|
|
3314
|
+
await loadUsers();
|
|
3315
|
+
showToast("Linked. This person's HID access now shows in their Service365 app.", "success");
|
|
3316
|
+
return;
|
|
3317
|
+
}
|
|
3318
|
+
|
|
3276
3319
|
if (selectedUser.value) {
|
|
3277
3320
|
/*
|
|
3278
3321
|
* AN EDIT REACHES EVERY READER THIS PERSON IS ON.
|
|
@@ -3339,9 +3382,15 @@ async function saveUser() {
|
|
|
3339
3382
|
fanOutRunning.value = false;
|
|
3340
3383
|
|
|
3341
3384
|
const summary = editFanOutSummary(readerOutcomes.value, Boolean(form.accessPin));
|
|
3385
|
+
const savedUnlinked = !hasMappedRecord(selectedUser.value as HidUser);
|
|
3342
3386
|
await loadUsers();
|
|
3343
3387
|
if (summary.tone === "success") formDialog.value = false;
|
|
3344
|
-
showToast(
|
|
3388
|
+
showToast(
|
|
3389
|
+
summary.tone === "success" && savedUnlinked
|
|
3390
|
+
? `${summary.message} ${UNLINKED_HID_USER_WARNING}`
|
|
3391
|
+
: summary.message,
|
|
3392
|
+
summary.tone !== "success" ? "error" : savedUnlinked ? "warning" : "success",
|
|
3393
|
+
);
|
|
3345
3394
|
return;
|
|
3346
3395
|
} else {
|
|
3347
3396
|
/*
|
|
@@ -4542,6 +4591,15 @@ function getMappingStatus(user: HidUser) {
|
|
|
4542
4591
|
return hasMappedRecord(user) ? "Mapped" : "Unmapped";
|
|
4543
4592
|
}
|
|
4544
4593
|
|
|
4594
|
+
/** Shown on an edit of, and after saving, a HID user linked to nobody. */
|
|
4595
|
+
const LINK_HID_USER_PROMPT =
|
|
4596
|
+
"Pick who this is below and save to link them; nothing is changed on the reader.";
|
|
4597
|
+
|
|
4598
|
+
const UNLINKED_HID_USER_WARNING =
|
|
4599
|
+
"Not linked to anyone in iService365, so this access will not show in their"
|
|
4600
|
+
+ " Service365 app. To give the person app access, delete this HID user and"
|
|
4601
|
+
+ " enroll them again with their name selected.";
|
|
4602
|
+
|
|
4545
4603
|
function hasMappedRecord(user: HidUser) {
|
|
4546
4604
|
// Reader-user rows carry the link flag on `identity` (API `linked`).
|
|
4547
4605
|
if (toRecord(user?.identity).linked === true) return true;
|
|
@@ -202,6 +202,7 @@ import usePassKey from "../composables/usePassKey";
|
|
|
202
202
|
import useUtils from "../composables/useUtils";
|
|
203
203
|
import usePeople from "../composables/usePeople";
|
|
204
204
|
import { errorConverter } from "../utils/data";
|
|
205
|
+
import { isCompletePhoneNumber } from "../utils/phone-complete";
|
|
205
206
|
import {
|
|
206
207
|
DELETE_PERSON_TITLE,
|
|
207
208
|
PERSON_DELETED_MESSAGE,
|
|
@@ -502,13 +503,16 @@ const memberSelectedContactOptions = computed(() => {
|
|
|
502
503
|
: [];
|
|
503
504
|
});
|
|
504
505
|
|
|
505
|
-
// Member NRIC / phone lookups (isecure365 `scheduleMemberLookup`): 4
|
|
506
|
-
// characters or more, 500 ms after the last
|
|
506
|
+
// Member NRIC / phone lookups (isecure365 `scheduleMemberLookup`): NRIC 4
|
|
507
|
+
// characters or more, the phone only once complete, 500 ms after the last
|
|
508
|
+
// keystroke, across every visitor
|
|
507
509
|
// type. One person is filled in straight away (or the chooser opens).
|
|
508
510
|
const lookupTimers: Record<string, ReturnType<typeof setTimeout> | undefined> = {};
|
|
509
511
|
|
|
510
512
|
function memberTerm(by: "nric" | "contact") {
|
|
511
|
-
|
|
513
|
+
if (by === "nric") return memberForm.nric?.trim() || "";
|
|
514
|
+
// The phone only once the whole number is typed (see isCompletePhoneNumber).
|
|
515
|
+
return isCompletePhoneNumber(memberForm.contact) ? memberForm.contact.trim() : "";
|
|
512
516
|
}
|
|
513
517
|
|
|
514
518
|
function scheduleMemberLookup(by: "nric" | "contact") {
|
|
@@ -846,6 +846,7 @@ import useHidAmico from "../composables/useHidAmico";
|
|
|
846
846
|
import useFile from "../composables/useFile";
|
|
847
847
|
import usePassKey from "../composables/usePassKey";
|
|
848
848
|
import { defaultGateForSite } from "../utils/visitor-camera";
|
|
849
|
+
import { isCompletePhoneNumber } from "../utils/phone-complete";
|
|
849
850
|
import { barrierCameraOf, barrierOf, type TBarrierOutcome } from "../utils/visitor-barrier";
|
|
850
851
|
import VisitorPassKeyQRScanner from "./VisitorPassKeyQRScanner.vue";
|
|
851
852
|
import {
|
|
@@ -1392,8 +1393,9 @@ const companyCombo = ref(null);
|
|
|
1392
1393
|
/*
|
|
1393
1394
|
* People lookup and autofill, as the security mobile app (isecure365 `add.tsx`
|
|
1394
1395
|
* lookup / choosePerson / applyPerson):
|
|
1395
|
-
* - typing 4 characters or more of the NRIC
|
|
1396
|
-
*
|
|
1396
|
+
* - typing 4 characters or more of the NRIC or plate, or a COMPLETE phone
|
|
1397
|
+
* number (isCompletePhoneNumber), looks the person up, 500 ms after the
|
|
1398
|
+
* last keystroke, across EVERY
|
|
1397
1399
|
* visitor type (the type being registered first); not for pick-up /
|
|
1398
1400
|
* drop-off, which carry no person;
|
|
1399
1401
|
* - exactly one person is filled in straight away (or, with several phone
|
|
@@ -1416,7 +1418,8 @@ const lookupTimers: Partial<Record<LookupField, ReturnType<typeof setTimeout>>>
|
|
|
1416
1418
|
|
|
1417
1419
|
function lookupTerm(by: LookupField) {
|
|
1418
1420
|
if (by === "nric") return visitor.nric?.trim() || "";
|
|
1419
|
-
|
|
1421
|
+
// The phone only once the whole number is typed (see isCompletePhoneNumber).
|
|
1422
|
+
if (by === "contact") return isCompletePhoneNumber(visitor.contact) ? visitor.contact.trim() : "";
|
|
1420
1423
|
return visitor.plateNumber?.trim()?.toUpperCase() || "";
|
|
1421
1424
|
}
|
|
1422
1425
|
|
|
@@ -1526,7 +1529,7 @@ watch(
|
|
|
1526
1529
|
watch(
|
|
1527
1530
|
() => visitor.contact,
|
|
1528
1531
|
(value) => {
|
|
1529
|
-
if (!value
|
|
1532
|
+
if (!isCompletePhoneNumber(value)) {
|
|
1530
1533
|
phoneSearchMenu.value = false;
|
|
1531
1534
|
phoneSearchResults.value = [];
|
|
1532
1535
|
}
|
|
@@ -589,6 +589,23 @@ export default function useHidAmico() {
|
|
|
589
589
|
});
|
|
590
590
|
}
|
|
591
591
|
|
|
592
|
+
/**
|
|
593
|
+
* Link a user that exists only on the reader to the person it is. OUR record
|
|
594
|
+
* only - the server sends nothing to the reader - so the person's existing
|
|
595
|
+
* access shows in their Service365 app. Body from `subjectLinkOf`.
|
|
596
|
+
*/
|
|
597
|
+
function linkReaderUser(
|
|
598
|
+
readerId: string,
|
|
599
|
+
hidUserId: string | number,
|
|
600
|
+
payload: { person?: string; member?: string; serviceProvider?: string; type?: string; name?: string; registration?: string },
|
|
601
|
+
) {
|
|
602
|
+
const body = Object.fromEntries(Object.entries(payload).filter(([, value]) => value !== "" && value !== undefined));
|
|
603
|
+
return useNuxtApp().$api<HidApiRecord>(`${basePath}/readers/${readerId}/users/${hidUserId}/link`, {
|
|
604
|
+
method: "POST",
|
|
605
|
+
body,
|
|
606
|
+
});
|
|
607
|
+
}
|
|
608
|
+
|
|
592
609
|
function deleteIdentity(identityId: string) {
|
|
593
610
|
return useNuxtApp().$api<HidApiRecord>(`${basePath}/identities/${identityId}`, {
|
|
594
611
|
method: "DELETE",
|
|
@@ -735,6 +752,7 @@ export default function useHidAmico() {
|
|
|
735
752
|
getReaderAccessLogs,
|
|
736
753
|
createIdentity,
|
|
737
754
|
updateIdentity,
|
|
755
|
+
linkReaderUser,
|
|
738
756
|
deleteIdentity,
|
|
739
757
|
getIntercomStatus,
|
|
740
758
|
makeIntercomCall,
|
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.185.
|
|
5
|
+
"version": "4.185.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.",
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import phoneMasks from "./phoneMasks";
|
|
2
|
+
|
|
3
|
+
type TPhoneMask = { dial_code: string; regex: string };
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* True only for a WHOLE phone number in the stored E.164 shape (`+6591234567`):
|
|
7
|
+
* it matches the pattern of a country whose dial code it starts with (the same
|
|
8
|
+
* patterns InputPhoneNumberV2 validates with). A part-typed number is not
|
|
9
|
+
* complete. The visitor form looks saved people up by phone only once this is
|
|
10
|
+
* true: the people search matches numbers that CONTAIN the term, so a partial
|
|
11
|
+
* number found unrelated people and a single match was filled in straight away.
|
|
12
|
+
*/
|
|
13
|
+
export function isCompletePhoneNumber(value: string | null | undefined): boolean {
|
|
14
|
+
const phone = String(value ?? "").trim();
|
|
15
|
+
if (!phone.startsWith("+")) return false;
|
|
16
|
+
return (phoneMasks as TPhoneMask[]).some(
|
|
17
|
+
(country) => phone.startsWith(country.dial_code) && new RegExp(country.regex).test(phone)
|
|
18
|
+
);
|
|
19
|
+
}
|