@dative-gpi/foundation-shared-services 1.0.55 → 1.0.57
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/composables/services/index.ts +1 -0
- package/composables/services/useNotifications.ts +41 -0
- package/config/index.ts +1 -0
- package/config/literals/hubs.ts +16 -0
- package/config/literals/index.ts +1 -0
- package/config/urls/base.ts +3 -1
- package/config/urls/images.ts +7 -1
- package/config/urls/index.ts +1 -0
- package/config/urls/notifications.ts +6 -0
- package/package.json +3 -3
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { type NotificationDetailsDTO, type NotificationFilters, type NotificationInfosDTO } from "@dative-gpi/foundation-shared-domain/models";
|
|
2
|
+
import { NotificationDetails, NotificationInfos } from "@dative-gpi/foundation-shared-domain/models";
|
|
3
|
+
import { ComposableFactory, ServiceFactory } from "@dative-gpi/bones-ui/core";
|
|
4
|
+
|
|
5
|
+
import { HUBS, NOTIFICATION_URL, NOTIFICATIONS_HUB_URL, NOTIFICATIONS_URL } from "../../config";
|
|
6
|
+
import { HubFactory } from "../../tools";
|
|
7
|
+
|
|
8
|
+
const NotificationServiceFactory = new ServiceFactory<NotificationDetailsDTO, NotificationDetails>("notification", NotificationDetails).create(factory => factory.build(
|
|
9
|
+
factory.addGet(NOTIFICATION_URL),
|
|
10
|
+
factory.addGetMany<NotificationInfosDTO, NotificationInfos, NotificationFilters>(NOTIFICATIONS_URL, NotificationInfos),
|
|
11
|
+
factory.addNotify(notifyService => ({
|
|
12
|
+
notifyCreate: (notification: NotificationDetails) => notifyService.notify("add", notification),
|
|
13
|
+
...ServiceFactory.addCustom("acknowledge", (axios, notificationId: string) => axios.patch(NOTIFICATION_URL(notificationId)), (dto: NotificationDetailsDTO) => {
|
|
14
|
+
const result = new NotificationDetails(dto);
|
|
15
|
+
notifyService.notify("update", result);
|
|
16
|
+
return result;
|
|
17
|
+
})
|
|
18
|
+
}))
|
|
19
|
+
));
|
|
20
|
+
|
|
21
|
+
const useNotificationsHub = HubFactory.create(NOTIFICATIONS_HUB_URL,
|
|
22
|
+
(connection, { hasWatchers }) => {
|
|
23
|
+
connection.on(HUBS.CREATE_NOTIFICATION, (notificationId: string) => hasWatchers()
|
|
24
|
+
? NotificationServiceFactory.get(notificationId).then(NotificationServiceFactory.notifyCreate)
|
|
25
|
+
: null);
|
|
26
|
+
},
|
|
27
|
+
async (connection) => {
|
|
28
|
+
await connection.invoke(HUBS.SUBSCRIBE);
|
|
29
|
+
}
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
const useWatchNotifications = HubFactory.createWatcher(useNotificationsHub);
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
export const useNotifications = ComposableFactory.getMany(NotificationServiceFactory, () => {
|
|
36
|
+
const { watchMany } = useWatchNotifications();
|
|
37
|
+
return () => {
|
|
38
|
+
watchMany();
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
export const useAcknowledgeNotification = ComposableFactory.custom(NotificationServiceFactory.acknowledge);
|
package/config/index.ts
CHANGED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export const SUBSCRIBE = "Subscribe";
|
|
2
|
+
export const UNSUBSCRIBE = "Unsubscribe";
|
|
3
|
+
|
|
4
|
+
export const UPDATE_DEVICE_STATUS = "UpdateDeviceStatus";
|
|
5
|
+
|
|
6
|
+
export const UPDATE_DEVICE_CONNECTIVITY = "UpdateDeviceConnectivity";
|
|
7
|
+
|
|
8
|
+
export const CREATE_ALERT = "CreateAlert";
|
|
9
|
+
export const UPDATE_ALERT = "UpdateAlert";
|
|
10
|
+
export const REMOVE_ALERT = "RemoveAlert";
|
|
11
|
+
|
|
12
|
+
export const CREATE_CONNECTIVITY_ALERT = "CreateConnectivityAlert";
|
|
13
|
+
export const UPDATE_CONNECTIVITY_ALERT = "UpdateConnectivityAlert";
|
|
14
|
+
export const REMOVE_CONNECTIVITY_ALERT = "RemoveConnectivityAlert";
|
|
15
|
+
|
|
16
|
+
export const CREATE_NOTIFICATION = "CreateNotification";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * as HUBS from "./hubs";
|
package/config/urls/base.ts
CHANGED
package/config/urls/images.ts
CHANGED
|
@@ -3,6 +3,12 @@ import { GATEWAY_URL } from "./base";
|
|
|
3
3
|
export const IMAGES_URL = () => `${GATEWAY_URL()}/images`;
|
|
4
4
|
|
|
5
5
|
export const IMAGE_URL = (imageId: string) => `${IMAGES_URL()}/${encodeURIComponent(imageId)}`;
|
|
6
|
-
export const IMAGE_RAW_URL = (imageId: string) =>
|
|
6
|
+
export const IMAGE_RAW_URL = (imageId: string, authToken?: string) => {
|
|
7
|
+
let url = IMAGE_URL(imageId);
|
|
8
|
+
if (authToken) {
|
|
9
|
+
url += `?authToken=${encodeURIComponent(authToken)}`;
|
|
10
|
+
}
|
|
11
|
+
return url;
|
|
12
|
+
};
|
|
7
13
|
|
|
8
14
|
export const IMAGE_THUMBNAIL_URL = (imageId: string) => `${IMAGE_URL(imageId)}/thumbnail`;
|
package/config/urls/index.ts
CHANGED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { GATEWAY_URL, HUBS_URL } from "./base";
|
|
2
|
+
|
|
3
|
+
export const NOTIFICATIONS_URL = () => `${GATEWAY_URL()}/notifications`;
|
|
4
|
+
export const NOTIFICATION_URL = (notificationId: string) => `${GATEWAY_URL()}/notifications/${notificationId}`;
|
|
5
|
+
|
|
6
|
+
export const NOTIFICATIONS_HUB_URL = () => `${HUBS_URL()}/notifications`;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dative-gpi/foundation-shared-services",
|
|
3
3
|
"sideEffects": false,
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.57",
|
|
5
5
|
"description": "",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public"
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"author": "",
|
|
11
11
|
"license": "ISC",
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@dative-gpi/foundation-shared-domain": "1.0.
|
|
13
|
+
"@dative-gpi/foundation-shared-domain": "1.0.57"
|
|
14
14
|
},
|
|
15
15
|
"peerDependencies": {
|
|
16
16
|
"@dative-gpi/bones-ui": "^0.0.75",
|
|
@@ -18,5 +18,5 @@
|
|
|
18
18
|
"vue": "^3.4.29",
|
|
19
19
|
"vue-router": "^4.3.0"
|
|
20
20
|
},
|
|
21
|
-
"gitHead": "
|
|
21
|
+
"gitHead": "4445a164fed7501246674432eba3e8227c8bc827"
|
|
22
22
|
}
|