@7365admin1/layer-common 4.12.1 → 4.12.3

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,17 @@
1
1
  # @iservice365/layer-common
2
2
 
3
+ ## 4.12.3
4
+
5
+ ### Patch Changes
6
+
7
+ - 547f1b2: Sign-in card and every page: the member, role and organisation lookups the router guard awaits before each navigation are now bounded (5 s, same as the module deny list). A lookup that never answered used to hold the first page - every app's sign-in card included - blank for ever; past the bound it now counts as a transient failure (role unresolved, retried on the next navigation) and the page renders. Successful and 404 answers are unchanged.
8
+
9
+ ## 4.12.2
10
+
11
+ ### Patch Changes
12
+
13
+ - cbe9fa6: `useMember()` now returns `getDeniedModules`. It was declared but never returned, so the module deny list never reached the web apps (the router guard failed open) and the Client details role dialog threw and never stopped loading.
14
+
3
15
  ## 4.12.1
4
16
 
5
17
  ### Patch Changes
@@ -1089,11 +1101,11 @@
1089
1101
  `utils/console-tier.ts` + `composables/useConsoleTier.ts` mirror the server's
1090
1102
  own rule from two endpoints the console already calls, unprojected:
1091
1103
 
1092
- GET /api/members/user/:user/app/admin the Seven365 staff membership
1093
- GET /api/roles/id/:role that membership's role document
1104
+ GET /api/members/user/:user/app/admin the Seven365 staff membership
1105
+ GET /api/roles/id/:role that membership's role document
1094
1106
 
1095
- owner = member.type === "admin" && role.type === "admin" && role.default === true
1096
- staff = member.type === "admin" && role.type === "admin"
1107
+ owner = member.type === "admin" && role.type === "admin" && role.default === true
1108
+ staff = member.type === "admin" && role.type === "admin"
1097
1109
 
1098
1110
  `role.default` is the marker because it is the only property of a platform
1099
1111
  staff role no API caller can set - `role.controller.ts` validates create and
@@ -179,5 +179,6 @@ export default function useMember() {
179
179
  getAllByUserId,
180
180
  getByUserTypeOrg,
181
181
  completeMemberOnboarding,
182
+ getDeniedModules,
182
183
  };
183
184
  }
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.12.1",
5
+ "version": "4.12.3",
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.",
@@ -9,6 +9,26 @@ function statusOf(error: any) {
9
9
  return error?.statusCode ?? error?.status ?? error?.response?.status;
10
10
  }
11
11
 
12
+ /*
13
+ * This guard runs before EVERY navigation and awaits these lookups, so one that
14
+ * never answers held the first page - every app's sign-in card included - blank
15
+ * for ever. Past this bound a lookup counts as a transient failure: the role
16
+ * stays unresolved (exactly as for a 502) and the next navigation retries. Same
17
+ * bound the module deny list already uses (`getDeniedModules`, 5 s).
18
+ */
19
+ export const LOOKUP_TIMEOUT_MS = 5000;
20
+
21
+ function bounded<T>(request: Promise<T>): Promise<T> {
22
+ let timer: ReturnType<typeof setTimeout> | undefined;
23
+ const timeout = new Promise<never>((_, reject) => {
24
+ timer = setTimeout(
25
+ () => reject(Object.assign(new Error("Lookup timed out."), { statusCode: 408 })),
26
+ LOOKUP_TIMEOUT_MS,
27
+ );
28
+ });
29
+ return Promise.race([request, timeout]).finally(() => clearTimeout(timer));
30
+ }
31
+
12
32
  /** A route param that is a real id, or "": a malformed one is never sent. */
13
33
  function idParam(value: unknown) {
14
34
  return hexSchema.safeParse(value).success ? String(value) : "";
@@ -59,10 +79,10 @@ export default defineNuxtPlugin(() => {
59
79
  try {
60
80
  // The org query is not sent: the endpoint keys on user + app type only, so
61
81
  // the role does not depend on which organisation is in the current route.
62
- const member = await getByUserType(userId, APP);
82
+ const member = await bounded(getByUserType(userId, APP));
63
83
  hasMemberDocument = true;
64
84
  id.value = member.org ?? "";
65
- userAppRole.value = member.role ? await getRoleById(member.role) : null;
85
+ userAppRole.value = member.role ? await bounded(getRoleById(member.role)) : null;
66
86
  } catch (error) {
67
87
  userAppRole.value = null;
68
88
  hasMemberDocument = false;
@@ -160,7 +180,7 @@ export default defineNuxtPlugin(() => {
160
180
  }
161
181
 
162
182
  try {
163
- const orgResult = await getById(org);
183
+ const orgResult = await bounded(getById(org));
164
184
  if (orgResult) orgNature.value = orgResult.nature ?? "";
165
185
  } catch (error) {
166
186
  // Cosmetic only, and it never blocked navigation before either.