@7365admin1/layer-common 4.5.1-staging.300 → 4.5.1-staging.302

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,73 @@
1
1
  # @iservice365/layer-common
2
2
 
3
+ ## 4.7.2
4
+
5
+ ### Patch Changes
6
+
7
+ - ce15a17: Require a photo before a checklist task can be completed.
8
+
9
+ The Submit button in the completion dialog stays disabled until at least one
10
+ photo is attached, and the uploader is marked required. It gates on the uploaded
11
+ ids rather than previews, so a half-finished upload cannot slip through to a
12
+ server that then refuses it.
13
+
14
+ The reject dialog is deliberately not gated — a reject is somebody reporting a
15
+ problem, and demanding a photograph first would stop them reporting it. The
16
+ server scopes the rule the same way.
17
+
18
+ ## 4.7.1
19
+
20
+ ### Patch Changes
21
+
22
+ - fcb2938: Fix the context switcher showing a tick against two sites at once.
23
+
24
+ Not a comparison bug: `selected === item.value` was true for both rows because
25
+ both rows were the same site. The seven service apps build this list from
26
+ `customer-sites` with `value: i.site`, and a customer-sites row is an ENGAGEMENT,
27
+ not a site — one site can carry more than one. Production has two active rows for
28
+ the same site, identical except for a stale `name` snapshot.
29
+
30
+ The switcher now offers each destination once. First occurrence wins, so the
31
+ surviving label is the current one rather than the stale snapshot. Items with no
32
+ `value` are kept — they cannot collide, and dropping them would hide a malformed
33
+ row.
34
+
35
+ ## 4.7.0
36
+
37
+ ### Minor Changes
38
+
39
+ - a6f6af7: Add a derived module-to-application map (`utils/module-applications.ts`).
40
+
41
+ The Seven365 console listed the whole 47-entry catalogue as one flat list, so a
42
+ security client was offered Cleaning schedule management. R1 is written in terms
43
+ of applications, so the console needs to know which application each module
44
+ belongs to.
45
+
46
+ The map is DERIVED from each application's own `use*Permission` composable — the
47
+ same object that app passes to its role editor — so the console cannot disagree
48
+ with the apps. It is many-to-many on purpose: M&E reuses the cleaning schedule
49
+ module, and members/roles/attendance are shared by nearly all of them.
50
+
51
+ The seven app composables now import `useCommonPermissions` explicitly instead of
52
+ relying on Nuxt auto-import. Identical inside the app, and it is what makes the
53
+ catalogue readable outside Nuxt so the map can be derived at all.
54
+
55
+ ## 4.6.0
56
+
57
+ ### Minor Changes
58
+
59
+ - 40b7a6c: Add a search to both role dialogs, and stop Unselect All clearing what is hidden (R5).
60
+
61
+ A client builds a role out of up to 47 modules and about 127 actions inside a
62
+ modal. The search matches the names a person reads as well as the raw keys, so
63
+ "statements" and "soa" both find `SOA-mgmt`.
64
+
65
+ It filters the DISPLAY only — a permission ticked and then filtered out of view
66
+ is still ticked and still saved. Select All and Unselect All now act on the
67
+ visible set: with no search that is the whole catalogue, unchanged; with a search
68
+ active, Unselect All no longer discards every permission outside the filter,
69
+ which on the edit dialog would have been a role somebody is already using.
70
+
3
71
  ## 4.5.0
4
72
 
5
73
  ### Minor Changes
@@ -895,11 +963,11 @@
895
963
  `utils/console-tier.ts` + `composables/useConsoleTier.ts` mirror the server's
896
964
  own rule from two endpoints the console already calls, unprojected:
897
965
 
898
- GET /api/members/user/:user/app/admin the Seven365 staff membership
899
- GET /api/roles/id/:role that membership's role document
966
+ GET /api/members/user/:user/app/admin the Seven365 staff membership
967
+ GET /api/roles/id/:role that membership's role document
900
968
 
901
- owner = member.type === "admin" && role.type === "admin" && role.default === true
902
- staff = member.type === "admin" && role.type === "admin"
969
+ owner = member.type === "admin" && role.type === "admin" && role.default === true
970
+ staff = member.type === "admin" && role.type === "admin"
903
971
 
904
972
  `role.default` is the marker because it is the only property of a platform
905
973
  staff role no API caller can set - `role.controller.ts` validates create and
@@ -732,6 +732,7 @@ const {
732
732
  makeIntercomCall,
733
733
  finalizeIntercomCall,
734
734
  ensureSipAccount,
735
+ notifyIntercomCall,
735
736
  } = useHidAmico();
736
737
 
737
738
  const activeTab = ref<IntercomTab>("intercom");
@@ -1442,8 +1443,10 @@ async function disconnectWebPhone() {
1442
1443
 
1443
1444
  async function startWebCall() {
1444
1445
  webPhoneActionLoading.value = true;
1446
+ const destination = webPhoneForm.destination;
1445
1447
  try {
1446
- await webPhone.call(webPhoneForm.destination);
1448
+ await webPhone.call(destination);
1449
+ void ringResidentPhone(destination);
1447
1450
  } catch (error: unknown) {
1448
1451
  showMessage(getErrorMessage(error), "error");
1449
1452
  } finally {
@@ -1451,6 +1454,50 @@ async function startWebCall() {
1451
1454
  }
1452
1455
  }
1453
1456
 
1457
+ /**
1458
+ * Wake the called resident's mobile so they are there to answer.
1459
+ *
1460
+ * Deliberately fired AFTER the INVITE and never awaited. The SIP leg is the
1461
+ * call: it is already ringing by the time this runs, and a resident whose
1462
+ * phone is asleep is the only thing this fixes. So a failure here is logged
1463
+ * and dropped rather than shown — telling the operator "call failed" for a
1464
+ * call that is ringing would be worse than a silent miss.
1465
+ *
1466
+ * A destination with no resident behind it (a staff extension, an external SIP
1467
+ * address) comes back `notified: false` with a reason and is not an error.
1468
+ */
1469
+ async function ringResidentPhone(destination: string) {
1470
+ if (!props.org || !props.site) return;
1471
+
1472
+ try {
1473
+ // No `readerId`: this call came from the web phone, not a door station.
1474
+ // The reader selected in the table above is whatever the operator happens
1475
+ // to be looking at, and sending it would tell the resident's app the call
1476
+ // arrived at a door it never touched.
1477
+ await notifyIntercomCall(props.site, {
1478
+ orgId: props.org,
1479
+ destination,
1480
+ callId: createCallId(),
1481
+ });
1482
+ } catch (error: unknown) {
1483
+ console.warn("[intercom] could not send the incoming-call push", error);
1484
+ }
1485
+ }
1486
+
1487
+ /**
1488
+ * A per-call id, so a second push for the same call replaces the first on the
1489
+ * resident's lock screen rather than stacking a second ringing card.
1490
+ * `randomUUID` needs a secure context, which the web phone already requires —
1491
+ * getUserMedia does not run without one — but the fallback keeps a call from
1492
+ * failing on that account alone.
1493
+ */
1494
+ function createCallId() {
1495
+ if (typeof crypto !== "undefined" && typeof crypto.randomUUID === "function") {
1496
+ return crypto.randomUUID();
1497
+ }
1498
+ return `call-${Date.now()}-${Math.random().toString(16).slice(2)}`;
1499
+ }
1500
+
1454
1501
  async function answerWebCall() {
1455
1502
  webPhoneActionLoading.value = true;
1456
1503
  try {
@@ -541,6 +541,29 @@ export default function useHidAmico() {
541
541
  );
542
542
  }
543
543
 
544
+ /**
545
+ * Wake the resident's phone for a call the web phone has just placed.
546
+ *
547
+ * The SIP INVITE is the call and travels over the WebSocket, not through the
548
+ * API; this only rings the resident's mobile so somebody is there to answer
549
+ * it. It is therefore fired after the INVITE and never awaited in a way that
550
+ * could fail the call — see `startWebCall` in `HidIntercomManagement.vue`.
551
+ *
552
+ * `notified: false` with a reason is a normal response, not an error: staff
553
+ * extensions and external SIP addresses have no resident behind them.
554
+ */
555
+ function notifyIntercomCall(
556
+ siteId: string,
557
+ payload: { orgId: string; destination: string; callId: string; readerId?: string },
558
+ ) {
559
+ return useNuxtApp().$api<{
560
+ data: { notified: boolean; delivered?: number; reason?: string };
561
+ }>(
562
+ `${basePath}/sites/${siteId}/intercom/notify-call`,
563
+ { method: "POST", body: payload },
564
+ );
565
+ }
566
+
544
567
  function getPermissionCandidates(
545
568
  siteId: string,
546
569
  query: {
@@ -613,6 +636,7 @@ export default function useHidAmico() {
613
636
  makeIntercomCall,
614
637
  finalizeIntercomCall,
615
638
  ensureSipAccount,
639
+ notifyIntercomCall,
616
640
  getSitePermissions,
617
641
  getPermissionCandidates,
618
642
  updateSitePermissions,
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.1-staging.300",
5
+ "version": "4.5.1-staging.302",
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.",