@uxland/primary-shell 7.46.12 → 7.46.14

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 (31) hide show
  1. package/dist/{component-BzmmJiBs.js → component-LekL_wPh.js} +2 -2
  2. package/dist/{component-BzmmJiBs.js.map → component-LekL_wPh.js.map} +1 -1
  3. package/dist/{index-BRK-x41J.js → index-Dm3JkDtL.js} +10199 -10730
  4. package/dist/index-Dm3JkDtL.js.map +1 -0
  5. package/dist/index.js +3 -3
  6. package/dist/index.umd.cjs +206 -232
  7. package/dist/index.umd.cjs.map +1 -1
  8. package/dist/{plugin-B4gkpTjT.js → plugin-CVSTX5Ok.js} +5441 -5430
  9. package/dist/plugin-CVSTX5Ok.js.map +1 -0
  10. package/dist/primary/shell/src/UI/shared-components/primaria-text-editor/primaria-rich-text-editor.d.ts +7 -1
  11. package/dist/primary/shell/src/api/import-data-manager/component/component.d.ts +1 -0
  12. package/dist/primary/shell/src/features/get-user-info/backend-adapter.d.ts +4 -2
  13. package/dist/primary/shell/src/features/get-user-info/pds-token.d.ts +26 -0
  14. package/package.json +3 -3
  15. package/src/UI/components/quick-actions-menu/quick-actions-menu.ts +3 -3
  16. package/src/UI/shared-components/bootstrapper.ts +3 -1
  17. package/src/UI/shared-components/primaria-nav-item/primaria-nav-item.ts +3 -1
  18. package/src/UI/shared-components/primaria-text-editor/primaria-rich-text-editor.ts +34 -21
  19. package/src/api/ecap-event-manager/ecap-event-manager.test.ts +11 -4
  20. package/src/api/import-data-manager/component/component.ts +3 -0
  21. package/src/api/import-data-manager/import-data-manager-impl.test.ts +2 -0
  22. package/src/api/interaction-service/interaction-service-impl.tsx +37 -40
  23. package/src/api/localization/localization.ts +44 -40
  24. package/src/api/region-manager/region-manager.test.ts +1 -1
  25. package/src/api/region-manager/region-manager.ts +13 -3
  26. package/src/features/get-user-info/backend-adapter.ts +30 -18
  27. package/src/features/get-user-info/handler.test.ts +8 -2
  28. package/src/features/get-user-info/pds-token.ts +28 -0
  29. package/src/types/custom.d.ts +30 -0
  30. package/dist/index-BRK-x41J.js.map +0 -1
  31. package/dist/plugin-B4gkpTjT.js.map +0 -1
@@ -1,8 +1,12 @@
1
1
  import { inject, injectable } from "inversify";
2
- import { IUserInfo } from "./model";
3
2
  import { jwtDecode } from "jwt-decode";
4
- import { TYPES } from "../../infrastructure/ioc/types";
5
3
  import { shellApi } from "../../api/api";
4
+ import { TYPES } from "../../infrastructure/ioc/types";
5
+ import { IUserInfo } from "./model";
6
+ import { PdsAccessInfo, PdsToken } from "./pds-token";
7
+
8
+ /** Ordre de preferència dels identificadors del professional dins del token. */
9
+ const USER_ID_TYPES = ["DNI", "NIE", "PASS"];
6
10
 
7
11
  export abstract class UserInfoBackendAdapter {
8
12
  abstract getUserInfo(): Promise<IUserInfo>;
@@ -11,26 +15,34 @@ export abstract class UserInfoBackendAdapter {
11
15
  export class GetUserInfoBackendAdapter implements UserInfoBackendAdapter {
12
16
  constructor(@inject(TYPES.primaryApi) private api: typeof shellApi) {}
13
17
  getUserInfo(): Promise<IUserInfo> {
14
- const decodedToken = jwtDecode(this.api.tokenManager.getToken());
18
+ const decodedToken = jwtDecode<PdsToken>(this.api.tokenManager.getToken());
19
+ const accessInfo = decodedToken.access_info;
20
+
21
+ // `IUserInfo` declara `string` a tots els camps, però el token no en garanteix cap. Abans
22
+ // el token era `any` i els absents arribaven com a `undefined` amb tipus `string`; ara es
23
+ // normalitzen a cadena buida perquè el tipus digui la veritat.
15
24
  const userInfo: IUserInfo = {
16
- userId: this.getUserId(decodedToken.access_info),
17
- firstName: decodedToken.access_info.trace_user_given_name,
18
- familyName: decodedToken.access_info.trace_user_family_name,
19
- lastName: decodedToken.access_info.trace_user_last_name,
20
- registrationNumber: decodedToken.access_info.identifier.find((id: { type: string; value: string }) => id.type === "NUMCOL")
21
- ?.value,
22
- workCenter: decodedToken.access_info.center_code,
23
- role: decodedToken.access_info.role_type,
24
- speciality: decodedToken.access_info.professional_category,
25
+ userId: this.getUserId(accessInfo) ?? "",
26
+ firstName: accessInfo?.trace_user_given_name ?? "",
27
+ familyName: accessInfo?.trace_user_family_name ?? "",
28
+ lastName: accessInfo?.trace_user_last_name ?? "",
29
+ registrationNumber: this.findIdentifier(accessInfo, "NUMCOL") ?? "",
30
+ workCenter: accessInfo?.center_code ?? "",
31
+ role: accessInfo?.role_type ?? "",
32
+ speciality: accessInfo?.professional_category ?? "",
25
33
  };
26
34
  return Promise.resolve(userInfo);
27
35
  }
28
36
 
29
- getUserId(access_info) {
30
- return (
31
- access_info.identifier?.find((identifierItem: { type: string; value: string }) => identifierItem.type === "DNI")?.value ||
32
- access_info.identifier?.find((identifierItem: { type: string; value: string }) => identifierItem.type === "NIE")?.value ||
33
- access_info.identifier?.find((identifierItem: { type: string; value: string }) => identifierItem.type === "PASS")?.value
34
- );
37
+ private findIdentifier(accessInfo: PdsAccessInfo | undefined, type: string) {
38
+ return accessInfo?.identifier?.find((identifier) => identifier.type === type)?.value;
39
+ }
40
+
41
+ getUserId(accessInfo: PdsAccessInfo | undefined) {
42
+ for (const type of USER_ID_TYPES) {
43
+ const value = this.findIdentifier(accessInfo, type);
44
+ if (value) return value;
45
+ }
46
+ return undefined;
35
47
  }
36
48
  }
@@ -27,8 +27,14 @@ describe("GetUserInfoHandler", () => {
27
27
 
28
28
  const message = {} as GetUserInfo;
29
29
  const mockUserInfo: IUserInfo = {
30
- name: "John Doe",
31
- email: "john@example.com",
30
+ userId: "12345678Z",
31
+ firstName: "John",
32
+ familyName: "Doe",
33
+ lastName: "Smith",
34
+ registrationNumber: "081234",
35
+ workCenter: "CAP",
36
+ role: "assist",
37
+ speciality: "MF",
32
38
  };
33
39
 
34
40
  beforeEach(() => {
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Els camps del token del PDS que aquest adaptador llegeix.
3
+ *
4
+ * Es declara aquí, i no s'importa `PDSToken` de `@pds/core`, per dues raons: el shell no depèn
5
+ * d'aquell package, i el seu `AccessInfo` no inclou `trace_user_last_name`, que sí que es fa
6
+ * servir. Si algun dia s'unifiquen els dos contractes, aquest fitxer hauria de desaparèixer.
7
+ *
8
+ * Tot és opcional perquè el token no en garanteix cap: fins ara el tipus era `any` i
9
+ * `IUserInfo` prometia `string` a tot arreu, cosa que no era certa en runtime.
10
+ */
11
+ export interface PdsAccessInfo {
12
+ trace_user_given_name?: string;
13
+ trace_user_family_name?: string;
14
+ trace_user_last_name?: string;
15
+ center_code?: string;
16
+ role_type?: string;
17
+ professional_category?: string;
18
+ identifier?: PdsIdentifier[];
19
+ }
20
+
21
+ export interface PdsIdentifier {
22
+ type: string;
23
+ value: string;
24
+ }
25
+
26
+ export interface PdsToken {
27
+ access_info?: PdsAccessInfo;
28
+ }
@@ -0,0 +1,30 @@
1
+ import "react";
2
+
3
+ /**
4
+ * Els components web del Design System de Salut (`dss-*`) no porten tipus, així que s'obre
5
+ * `JSX.IntrinsicElements` per acceptar qualsevol element personalitzat.
6
+ *
7
+ * S'amplien els dos especificadors: amb `jsx: "react-jsx"`, la cerca del namespace JSX passa per
8
+ * `react/jsx-runtime`, que hereta de `React.JSX`.
9
+ *
10
+ * Aquest fitxer és idèntic a tots els plugins i no es pot compartir des de l'arrel: sota pnpm,
11
+ * l'arrel no té `react` a `node_modules`, així que l'especificador no resoldria i el
12
+ * `declare module` no ampliaria res.
13
+ */
14
+ declare module "react" {
15
+ namespace JSX {
16
+ interface IntrinsicElements {
17
+ // biome-ignore lint/suspicious/noExplicitAny: els components del DSS no estan tipats
18
+ [key: string]: any;
19
+ }
20
+ }
21
+ }
22
+
23
+ declare module "react/jsx-runtime" {
24
+ namespace JSX {
25
+ interface IntrinsicElements {
26
+ // biome-ignore lint/suspicious/noExplicitAny: els components del DSS no estan tipats
27
+ [key: string]: any;
28
+ }
29
+ }
30
+ }