@uxland/primary-shell 7.29.5 → 7.29.7

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.
@@ -13,6 +13,16 @@ export declare const BROKER_EVENTS: {
13
13
  readonly addHistoryItemRequest: "add_history_item_request";
14
14
  readonly addHistoryItemsRequest: "add_history_items_request";
15
15
  readonly updateHistoryItemRequest: "update_history_item_request";
16
+ readonly removeHistoryItemRequest: "remove_history_item_request";
17
+ };
18
+ readonly shell: {
19
+ readonly appCrashed: "appCrashed";
20
+ readonly mainViewChanged: "mainViewChanged";
21
+ readonly refreshTokenFailed: "refreshTokenFailed";
22
+ readonly mpidHeaderInvalid: "mpidHeaderInvalid";
23
+ readonly quickActionBusyChanged: "quickActionBusyChanged";
24
+ readonly scrollToNavItemRequested: "scrollToNavItemRequested";
25
+ readonly scrollToNavItemCompleted: "scrollToNavItemCompleted";
16
26
  };
17
27
  };
18
28
  export type BrokerEvents = typeof BROKER_EVENTS;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uxland/primary-shell",
3
- "version": "7.29.5",
3
+ "version": "7.29.7",
4
4
  "description": "Primaria Shell",
5
5
  "author": "UXLand <dev@uxland.es>",
6
6
  "homepage": "https://github.com/uxland/harmonix/tree/app#readme",
@@ -1,5 +1,5 @@
1
1
  import { shellApi } from "../../../api/api";
2
- import { shellEvents } from "../../../events";
2
+ import { BROKER_EVENTS } from "../../../api/broker/broker-events";
3
3
  import { renderNavigationTooltip } from "./navigation-tooltip";
4
4
 
5
5
  const scrollToNavItem = (
@@ -7,14 +7,14 @@ const scrollToNavItem = (
7
7
  ): Promise<{ scrollTop: number; containerTop: number; itemIndex: number; itemAbsoluteY: number }> => {
8
8
  return new Promise((resolve) => {
9
9
  const subscription = shellApi.broker.subscribe(
10
- shellEvents.scrollToNavItemCompleted,
10
+ BROKER_EVENTS.shell.scrollToNavItemCompleted,
11
11
  (data: { scrollTop: number; containerTop: number; itemIndex: number; itemAbsoluteY: number }) => {
12
12
  subscription.dispose();
13
13
  resolve(data);
14
14
  },
15
15
  );
16
16
 
17
- shellApi.broker.publish(shellEvents.scrollToNavItemRequested, navItemMenuKey);
17
+ shellApi.broker.publish(BROKER_EVENTS.shell.scrollToNavItemRequested, navItemMenuKey);
18
18
 
19
19
  // Fallback timeout in case the event doesn't arrive
20
20
  setTimeout(() => {
@@ -3,7 +3,7 @@ import { LitElement, css, html, unsafeCSS } from "lit";
3
3
  import { state } from "lit/decorators.js";
4
4
  import { PrimariaRegionHost, shellApi } from "../../../api/api";
5
5
  import { disposeShell } from "../../../disposer";
6
- import { shellEvents } from "../../../events";
6
+ import { BROKER_EVENTS } from "../../../api/broker/broker-events";
7
7
  import { translate } from "../../../locales";
8
8
  import { shellViews } from "./constants";
9
9
  import styles from "./styles.css?inline";
@@ -67,31 +67,31 @@ export class PrimariaShell extends PrimariaRegionHost(LitElement) {
67
67
 
68
68
  _subscribeEvents() {
69
69
  this.subscriptions.push(
70
- shellApi.broker.subscribe(shellEvents.appCrashed, (error: { message: string }) => {
70
+ shellApi.broker.subscribe(BROKER_EVENTS.shell.appCrashed, (error: { message: string }) => {
71
71
  this._handleError(error);
72
72
  }),
73
73
  );
74
74
 
75
75
  this.subscriptions.push(
76
- shellApi.broker.subscribe(shellEvents.refreshTokenFailed, (detail: any) => {
76
+ shellApi.broker.subscribe(BROKER_EVENTS.shell.refreshTokenFailed, (detail: any) => {
77
77
  this._handleError({ message: translate("errors.session") });
78
78
  }),
79
79
  );
80
80
 
81
81
  this.subscriptions.push(
82
- shellApi.broker.subscribe(shellEvents.mpidHeaderInvalid, (detail: any) => {
82
+ shellApi.broker.subscribe(BROKER_EVENTS.shell.mpidHeaderInvalid, (detail: any) => {
83
83
  this._handleError({ message: translate("errors.invalidPatient") });
84
84
  }),
85
85
  );
86
86
 
87
87
  this.subscriptions.push(
88
- shellApi.broker.subscribe(shellEvents.quickActionBusyChanged, (detail: { busy: boolean }) => {
88
+ shellApi.broker.subscribe(BROKER_EVENTS.shell.quickActionBusyChanged, (detail: { busy: boolean }) => {
89
89
  this.quickActionBusy = detail.busy;
90
90
  }),
91
91
  );
92
92
 
93
93
  this.subscriptions.push(
94
- shellApi.broker.subscribe(shellEvents.scrollToNavItemRequested, (navItemMenuKey: string) => {
94
+ shellApi.broker.subscribe(BROKER_EVENTS.shell.scrollToNavItemRequested, (navItemMenuKey: string) => {
95
95
  this._scrollToNavItem(navItemMenuKey);
96
96
  }),
97
97
  );
@@ -119,7 +119,7 @@ export class PrimariaShell extends PrimariaRegionHost(LitElement) {
119
119
  const targetView = allViews.find((view: any) => view.id === viewId);
120
120
 
121
121
  if (!targetView) {
122
- shellApi.broker.publish(shellEvents.scrollToNavItemCompleted, {
122
+ shellApi.broker.publish(BROKER_EVENTS.shell.scrollToNavItemCompleted, {
123
123
  scrollTop: 0,
124
124
  containerTop: 0,
125
125
  itemIndex: -1,
@@ -137,7 +137,7 @@ export class PrimariaShell extends PrimariaRegionHost(LitElement) {
137
137
  const targetIndex = sortedViews.findIndex((view: any) => view.id === viewId);
138
138
 
139
139
  if (targetIndex === -1) {
140
- shellApi.broker.publish(shellEvents.scrollToNavItemCompleted, {
140
+ shellApi.broker.publish(BROKER_EVENTS.shell.scrollToNavItemCompleted, {
141
141
  scrollTop: 0,
142
142
  containerTop: 0,
143
143
  itemIndex: -1,
@@ -147,7 +147,7 @@ export class PrimariaShell extends PrimariaRegionHost(LitElement) {
147
147
 
148
148
  const menuContainer = this.shadowRoot?.querySelector("#menu-region-container") as HTMLElement;
149
149
  if (!menuContainer) {
150
- shellApi.broker.publish(shellEvents.scrollToNavItemCompleted, {
150
+ shellApi.broker.publish(BROKER_EVENTS.shell.scrollToNavItemCompleted, {
151
151
  scrollTop: 0,
152
152
  containerTop: 0,
153
153
  itemIndex: targetIndex,
@@ -187,7 +187,7 @@ export class PrimariaShell extends PrimariaRegionHost(LitElement) {
187
187
  itemIndex: targetIndex,
188
188
  itemAbsoluteY: itemAbsoluteY,
189
189
  };
190
- shellApi.broker.publish(shellEvents.scrollToNavItemCompleted, data);
190
+ shellApi.broker.publish(BROKER_EVENTS.shell.scrollToNavItemCompleted, data);
191
191
  }, 300);
192
192
  }
193
193
  }
@@ -2,7 +2,7 @@ import { regionView } from "@uxland/regions";
2
2
  import { LitElement, PropertyValues, css, html, unsafeCSS } from "lit";
3
3
  import { property, state } from "lit/decorators.js";
4
4
  import { shellApi } from "../../../api/api";
5
- import { shellEvents } from "../../../events";
5
+ import { BROKER_EVENTS } from "../../../api/broker/broker-events";
6
6
  import { PrimariaNavItemConfig } from "../typings";
7
7
  import styles from "./styles.css?inline";
8
8
  import { template } from "./template";
@@ -47,7 +47,7 @@ export class PrimariaNavItem extends regionView(LitElement) {
47
47
  }
48
48
 
49
49
  _subscribeEvents() {
50
- const subscription = shellApi.broker.subscribe(shellEvents.mainViewChanged, (payload: { viewId: string }) => {
50
+ const subscription = shellApi.broker.subscribe(BROKER_EVENTS.shell.mainViewChanged, (payload: { viewId: string }) => {
51
51
  this.isActive = payload.viewId === this.view?.id;
52
52
  });
53
53
  this.subscriptions.push(subscription);
@@ -13,6 +13,16 @@ export const BROKER_EVENTS = {
13
13
  addHistoryItemRequest: "add_history_item_request",
14
14
  addHistoryItemsRequest: "add_history_items_request",
15
15
  updateHistoryItemRequest: "update_history_item_request",
16
+ removeHistoryItemRequest: "remove_history_item_request",
17
+ },
18
+ shell: {
19
+ appCrashed: "appCrashed",
20
+ mainViewChanged: "mainViewChanged",
21
+ refreshTokenFailed: "refreshTokenFailed",
22
+ mpidHeaderInvalid: "mpidHeaderInvalid",
23
+ quickActionBusyChanged: "quickActionBusyChanged",
24
+ scrollToNavItemRequested: "scrollToNavItemRequested",
25
+ scrollToNavItemCompleted: "scrollToNavItemCompleted",
16
26
  },
17
27
  } as const;
18
28
 
@@ -3,7 +3,7 @@ import AxiosMockAdapter from "axios-mock-adapter";
3
3
  import { beforeEach, describe, expect, it, vi } from "vitest";
4
4
  import { TokenManager, createTokenManager } from "../token-manager/token-manager";
5
5
  import { createAxiosInstance } from "./http-client";
6
- import { shellEvents } from "../../events";
6
+ import { BROKER_EVENTS } from "../broker/broker-events";
7
7
  import { createBroker } from "../broker/factory";
8
8
 
9
9
  const access_token =
@@ -91,8 +91,8 @@ describe("HTTP Client", () => {
91
91
  );
92
92
 
93
93
  expect(axiosMockInstance.history.get?.length).toBe(1); // No retry happened
94
- expect(brokerSpy).toHaveBeenCalledWith(shellEvents.refreshTokenFailed, expect.any(Object));
95
- expect(brokerSpy).toHaveBeenCalledWith(shellEvents.refreshTokenFailed, {
94
+ expect(brokerSpy).toHaveBeenCalledWith(BROKER_EVENTS.shell.refreshTokenFailed, expect.any(Object));
95
+ expect(brokerSpy).toHaveBeenCalledWith(BROKER_EVENTS.shell.refreshTokenFailed, {
96
96
  request: expect.objectContaining({ url: "/api/clinical-course" }),
97
97
  });
98
98
  });
@@ -139,7 +139,7 @@ describe("HTTP Client", () => {
139
139
  await expect(axiosInstance.get("/api/clinical-course")).rejects.toThrow(
140
140
  "Mpid header value is invalid",
141
141
  );
142
- expect(brokerSpy).toHaveBeenCalledWith(shellEvents.mpidHeaderInvalid, expect.any(Object));
142
+ expect(brokerSpy).toHaveBeenCalledWith(BROKER_EVENTS.shell.mpidHeaderInvalid, expect.any(Object));
143
143
  });
144
144
 
145
145
  it("should make a request with header and respond succesful if x-catsalut-mpid has valid value ", async () => {
@@ -200,8 +200,8 @@ describe("HTTP Client", () => {
200
200
  );
201
201
 
202
202
  expect(axiosMockInstance.history.get?.length).toBe(1); // No retry happened
203
- expect(brokerSpy).toHaveBeenCalledWith(shellEvents.refreshTokenFailed, expect.any(Object));
204
- expect(brokerSpy).toHaveBeenCalledWith(shellEvents.refreshTokenFailed, {
203
+ expect(brokerSpy).toHaveBeenCalledWith(BROKER_EVENTS.shell.refreshTokenFailed, expect.any(Object));
204
+ expect(brokerSpy).toHaveBeenCalledWith(BROKER_EVENTS.shell.refreshTokenFailed, {
205
205
  request: expect.objectContaining({ url: "/api/clinical-course" }),
206
206
  });
207
207
  });
@@ -1,6 +1,6 @@
1
1
  import axios, { AxiosRequestConfig, AxiosResponse } from "axios";
2
2
  import { TokenManager } from "../token-manager/token-manager";
3
- import { shellEvents } from "../../events";
3
+ import { BROKER_EVENTS } from "../broker/broker-events";
4
4
  import { PrimariaBroker } from "../broker/primaria-broker";
5
5
  import { jwtDecode } from "jwt-decode";
6
6
 
@@ -52,7 +52,7 @@ export const createAxiosInstance = (
52
52
  return response;
53
53
  } catch (error) {
54
54
  if (error instanceof InvalidMpidHeaderError) {
55
- broker.publish(shellEvents.mpidHeaderInvalid, {
55
+ broker.publish(BROKER_EVENTS.shell.mpidHeaderInvalid, {
56
56
  request: response.config,
57
57
  });
58
58
  }
@@ -69,7 +69,7 @@ export const createAxiosInstance = (
69
69
  return instance(originalRequest);
70
70
  } catch (refreshError) {
71
71
  console.error("Error refreshing token:", refreshError);
72
- broker.publish(shellEvents.refreshTokenFailed, {
72
+ broker.publish(BROKER_EVENTS.shell.refreshTokenFailed, {
73
73
  request: originalRequest,
74
74
  });
75
75
  return Promise.reject(error);
@@ -1,6 +1,6 @@
1
1
  import { describe, it, expect, vi, beforeEach } from "vitest";
2
2
  import { QuickActionBusyManagerImpl } from "./quick-action-busy-manager";
3
- import { shellEvents } from "../../events";
3
+ import { BROKER_EVENTS } from "../broker/broker-events";
4
4
 
5
5
  describe("QuickActionBusyManagerImpl", () => {
6
6
  let brokerMock: any;
@@ -17,7 +17,7 @@ describe("QuickActionBusyManagerImpl", () => {
17
17
  it("should add a task and emit event", () => {
18
18
  const task = { taskId: "qa1" };
19
19
  manager.addTask(task);
20
- expect(brokerMock.publish).toHaveBeenCalledWith(shellEvents.quickActionBusyChanged, {
20
+ expect(brokerMock.publish).toHaveBeenCalledWith(BROKER_EVENTS.shell.quickActionBusyChanged, {
21
21
  busy: true,
22
22
  });
23
23
  });
@@ -37,7 +37,7 @@ describe("QuickActionBusyManagerImpl", () => {
37
37
  const task = { taskId: "qa1" };
38
38
  manager.addTask(task);
39
39
  manager.removeTask("qa1");
40
- expect(brokerMock.publish).toHaveBeenCalledWith(shellEvents.quickActionBusyChanged, {
40
+ expect(brokerMock.publish).toHaveBeenCalledWith(BROKER_EVENTS.shell.quickActionBusyChanged, {
41
41
  busy: false,
42
42
  });
43
43
  });
@@ -1,4 +1,4 @@
1
- import { shellEvents } from "../../events";
1
+ import { BROKER_EVENTS } from "../broker/broker-events";
2
2
  import { PrimariaBroker } from "../broker/primaria-broker";
3
3
 
4
4
  export interface QuickActionTask {
@@ -45,6 +45,6 @@ export class QuickActionBusyManagerImpl implements QuickActionBusyManager {
45
45
 
46
46
  private emitBusyChanged(): void {
47
47
  const busy = this.isBusy();
48
- this.broker.publish(shellEvents.quickActionBusyChanged, { busy });
48
+ this.broker.publish(BROKER_EVENTS.shell.quickActionBusyChanged, { busy });
49
49
  }
50
50
  }
@@ -1,6 +1,6 @@
1
1
  import { describe, it, expect, vi, beforeEach } from "vitest";
2
2
  import { createRegionManagerProxy } from "./region-manager";
3
- import { shellEvents } from "../../events";
3
+ import { BROKER_EVENTS } from "../broker/broker-events";
4
4
 
5
5
  const pluginId = "test-plugin";
6
6
  const mockView = { id: "view1" };
@@ -48,7 +48,7 @@ describe("RegionManagerProxy", () => {
48
48
  it("activateView should activate the view and notify if region is main", async () => {
49
49
  await proxy.activateView(proxy.regions.shell.main, "view1");
50
50
  expect(regionMock.activate).toHaveBeenCalledWith(`${pluginId}::view1`);
51
- expect(broker.publish).toHaveBeenCalledWith(shellEvents.mainViewChanged, { viewId: "view1" });
51
+ expect(broker.publish).toHaveBeenCalledWith(BROKER_EVENTS.shell.mainViewChanged, { viewId: "view1" });
52
52
  });
53
53
 
54
54
  it("deactivateView should deactivate the view", async () => {
@@ -102,7 +102,7 @@ describe("RegionManagerProxy", () => {
102
102
  it("activateMainView should activate main view and notify broker", async () => {
103
103
  await proxy.activateMainView("view1");
104
104
  expect(regionMock.activate).toHaveBeenCalledWith(`${pluginId}::view1`);
105
- expect(broker.publish).toHaveBeenCalledWith(shellEvents.mainViewChanged, { viewId: "view1" });
105
+ expect(broker.publish).toHaveBeenCalledWith(BROKER_EVENTS.shell.mainViewChanged, { viewId: "view1" });
106
106
  });
107
107
 
108
108
  it("getCurrentMainViewActive should return id of the active main view", () => {
@@ -3,7 +3,7 @@ import { PluginInfo } from "../../handle-plugins";
3
3
  import { IRegion } from "@uxland/regions";
4
4
  import { shellRegions, clinicalMonitoringRegions, activityHistoryRegions } from "./regions";
5
5
  import { PrimariaBroker } from "../broker/primaria-broker";
6
- import { shellEvents } from "../../events";
6
+ import { BROKER_EVENTS } from "../broker/broker-events";
7
7
 
8
8
  export interface PrimariaRegionManager extends HarmonixRegionManager {
9
9
  regions: {
@@ -133,7 +133,7 @@ class RegionManagerProxy implements PrimariaRegionManager {
133
133
  }
134
134
 
135
135
  _notifyMainViewChanged(viewId: string) {
136
- this.broker.publish(shellEvents.mainViewChanged, { viewId });
136
+ this.broker.publish(BROKER_EVENTS.shell.mainViewChanged, { viewId });
137
137
  }
138
138
 
139
139
  _destroy() {