@dative-gpi/foundation-core-services 0.0.52 → 0.0.54

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.
@@ -4,7 +4,7 @@ const organisationId = ref<string | null>(null);
4
4
 
5
5
  export const useAppOrganisationId = () => {
6
6
 
7
- const setOrganisationId = (payload: string) => {
7
+ const setAppOrganisationId = (payload: string) => {
8
8
  organisationId.value = payload;
9
9
  };
10
10
 
@@ -13,6 +13,6 @@ export const useAppOrganisationId = () => {
13
13
  return {
14
14
  ready,
15
15
  organisationId,
16
- setOrganisationId
16
+ setAppOrganisationId
17
17
  };
18
18
  }
@@ -2,7 +2,6 @@ import { onMounted, ref, watch } from "vue";
2
2
 
3
3
  import * as signalR from "@microsoft/signalr";
4
4
 
5
- import { useNotifyAlert, useNotifyRemoveAlert } from "../services/useAlerts";
6
5
  import { ALERTS_HUB_URL } from "../../config/urls";
7
6
  import { HUBS } from "../../config/literals";
8
7
 
@@ -24,9 +23,9 @@ export const useAlertsHub = () => {
24
23
  await connection.value.start();
25
24
  }
26
25
  connection.value.invoke(HUBS.SUBSCRIBE);
27
- connection.value.on(HUBS.CREATE_ALERT, (alertId: string) => useNotifyAlert().fetch(alertId));
28
- connection.value.on(HUBS.UPDATE_ALERT, (alertId: string) => useNotifyAlert().fetch(alertId));
29
- connection.value.on(HUBS.REMOVE_ALERT, (alertId: string) => useNotifyRemoveAlert().remove(alertId));
26
+ // connection.value.on(HUBS.CREATE_ALERT, (alertId: string) => useNotifyAlert().fetch(alertId));
27
+ // connection.value.on(HUBS.UPDATE_ALERT, (alertId: string) => useNotifyAlert().fetch(alertId));
28
+ // connection.value.on(HUBS.REMOVE_ALERT, (alertId: string) => useNotifyRemoveAlert().remove(alertId));
30
29
  });
31
30
 
32
31
  initialized = true;
@@ -2,7 +2,6 @@ import { onMounted, ref, watch } from "vue";
2
2
 
3
3
  import * as signalR from "@microsoft/signalr";
4
4
 
5
- import { useNotifyConnectivityAlert, useNotifyRemoveConnectivityAlert } from "../services/useConnectivityAlerts";
6
5
  import { CONNECTIVITY_ALERTS_HUB_URL } from "../../config/urls";
7
6
  import { HUBS } from "../../config/literals";
8
7
 
@@ -24,9 +23,9 @@ export const useConnectivityAlertsHub = () => {
24
23
  await connection.value.start();
25
24
  }
26
25
  connection.value.invoke(HUBS.SUBSCRIBE);
27
- connection.value.on(HUBS.CREATE_CONNECTIVITY_ALERT, (connectivityAlertId: string) => useNotifyConnectivityAlert().fetch(connectivityAlertId));
28
- connection.value.on(HUBS.UPDATE_CONNECTIVITY_ALERT, (connectivityAlertId: string) => useNotifyConnectivityAlert().fetch(connectivityAlertId));
29
- connection.value.on(HUBS.REMOVE_CONNECTIVITY_ALERT, (connectivityAlertId: string) => useNotifyRemoveConnectivityAlert().remove(connectivityAlertId));
26
+ // connection.value.on(HUBS.CREATE_CONNECTIVITY_ALERT, (connectivityAlertId: string) => useNotifyConnectivityAlert().fetch(connectivityAlertId));
27
+ // connection.value.on(HUBS.UPDATE_CONNECTIVITY_ALERT, (connectivityAlertId: string) => useNotifyConnectivityAlert().fetch(connectivityAlertId));
28
+ // connection.value.on(HUBS.REMOVE_CONNECTIVITY_ALERT, (connectivityAlertId: string) => useNotifyRemoveConnectivityAlert().remove(connectivityAlertId));
30
29
  });
31
30
 
32
31
  initialized = true;
@@ -2,7 +2,6 @@ import { onMounted, ref, watch } from "vue";
2
2
 
3
3
  import * as signalR from "@microsoft/signalr";
4
4
 
5
- import { useNotifyDeviceConnectivity } from "../services/useDeviceConnectivities";
6
5
  import { DEVICE_CONNECTIVITIES_HUB_URL } from "../../config/urls";
7
6
  import { HUBS } from "../../config/literals";
8
7
 
@@ -24,7 +23,7 @@ export const useDeviceConnectivitiesHub = () => {
24
23
  await connection.value.start();
25
24
  }
26
25
  connection.value.invoke(HUBS.SUBSCRIBE);
27
- connection.value.on(HUBS.UPDATE_DEVICE_CONNECTIVITY, (deviceOrganisationId: string) => useNotifyDeviceConnectivity().fetch(deviceOrganisationId));
26
+ // connection.value.on(HUBS.UPDATE_DEVICE_CONNECTIVITY, (deviceOrganisationId: string) => useNotifyDeviceConnectivity().fetch(deviceOrganisationId));
28
27
  });
29
28
 
30
29
  initialized = true;
@@ -2,7 +2,6 @@ import { onMounted, ref, watch } from "vue";
2
2
 
3
3
  import * as signalR from "@microsoft/signalr";
4
4
 
5
- import { useNotifyDeviceStatus } from "../services/useDeviceStatuses";
6
5
  import { DEVICE_STATUSES_HUB_URL } from "../../config/urls";
7
6
  import { HUBS } from "../../config/literals";
8
7
 
@@ -24,7 +23,7 @@ export const useDeviceStatusesHub = () => {
24
23
  await connection.value.start();
25
24
  }
26
25
  connection.value.invoke(HUBS.SUBSCRIBE);
27
- connection.value.on(HUBS.UPDATE_DEVICE_STATUS, (deviceOrganisationId: string) => useNotifyDeviceStatus().fetch(deviceOrganisationId));
26
+ // connection.value.on(HUBS.UPDATE_DEVICE_STATUS, (deviceOrganisationId: string) => useNotifyDeviceStatus().fetch(deviceOrganisationId));
28
27
  });
29
28
 
30
29
  initialized = true;
@@ -1,7 +1,5 @@
1
- import { onUnmounted, ref } from "vue";
2
-
3
1
  import { AlertDetails, AlertDetailsDTO, AlertFilters, AlertInfos, AlertInfosDTO } from "@dative-gpi/foundation-core-domain/models";
4
- import { ComposableFactory, onEntityChanged , ServiceFactory } from "@dative-gpi/bones-ui";
2
+ import { ComposableFactory, ServiceFactory } from "@dative-gpi/bones-ui";
5
3
 
6
4
  import { ALERTS_URL, ALERT_URL } from "../../config/urls";
7
5
 
@@ -9,89 +7,16 @@ const AlertServiceFactory = new ServiceFactory<AlertDetailsDTO, AlertDetails>("a
9
7
  factory.addGet(ALERT_URL),
10
8
  factory.addGetMany<AlertInfosDTO, AlertInfos, AlertFilters>(ALERTS_URL, AlertInfos),
11
9
  factory.addRemove(ALERT_URL),
12
- factory.addNotify((notifyService) => ({
13
- acknowledge: async (alertId: string): Promise<AlertDetails> => {
14
- const response = await ServiceFactory.http.patch(ALERT_URL(alertId));
15
- const result = new AlertDetails(response.data);
16
-
17
- notifyService.notify("update", result);
18
-
10
+ factory.addNotify(notify => ({
11
+ ...ServiceFactory.addCustom("acknowledge", (axios, alertId: string) => axios.patch(ALERT_URL(alertId)), (dto: AlertDetailsDTO) => {
12
+ const result = new AlertDetails(dto);
13
+ notify.notify("update", result);
19
14
  return result;
20
- },
21
- getNotify: async (alertId: string): Promise<AlertDetails> => {
22
- const response = await ServiceFactory.http.get(ALERT_URL(alertId));
23
- const result = new AlertDetails(response.data);
24
-
25
- notifyService.notify("update", result);
26
-
27
- return result;
28
- },
29
- removeNotify: (alertId: string): void => {
30
- notifyService.notify("delete", alertId);
31
- }
15
+ })
32
16
  }))
33
17
  ));
34
18
 
35
19
  export const useAlert = ComposableFactory.get(AlertServiceFactory);
36
20
  export const useAlerts = ComposableFactory.getMany(AlertServiceFactory);
37
21
  export const useRemoveAlert = ComposableFactory.remove(AlertServiceFactory);
38
- export const useAcknowledgeAlert = () => {
39
- const service = AlertServiceFactory();
40
- const subscribersIds : number[] = [];
41
-
42
- const changing = ref(false);
43
- const changed = ref<AlertDetails | null>(null);
44
-
45
- onUnmounted(() => {
46
- subscribersIds.forEach(id => service.unsubscribe(id));
47
- subscribersIds.length = 0;
48
- });
49
-
50
- const change = async (alertId: string) => {
51
- changing.value = true;
52
- try {
53
- changed.value = await service.acknowledge(alertId);
54
- }
55
- finally {
56
- changing.value = false;
57
- }
58
- subscribersIds.push(service.subscribe("all", onEntityChanged(changed)));
59
- return changed;
60
- }
61
-
62
- return {
63
- changing,
64
- change,
65
- changed
66
- };
67
- }
68
- export const useNotifyAlert = () => {
69
- const service = AlertServiceFactory();
70
-
71
- const fetching = ref(false);
72
- const fetched = ref<AlertDetails | null>(null);
73
-
74
- const fetch = async (alertId: string) => {
75
- fetching.value = true;
76
- try {
77
- fetched.value = await service.getNotify(alertId);
78
- }
79
- finally {
80
- fetching.value = false;
81
- }
82
- return fetched;
83
- }
84
-
85
- return {
86
- fetching,
87
- fetch,
88
- fetched
89
- };
90
- }
91
- export const useNotifyRemoveAlert = () => {
92
- const service = AlertServiceFactory();
93
-
94
- return {
95
- remove: service.removeNotify
96
- };
97
- }
22
+ export const useAcknowledgeAlert = ComposableFactory.custom(AlertServiceFactory.acknowledge);
@@ -1,5 +1,3 @@
1
- import { ref } from "vue";
2
-
3
1
  import { ConnectivityAlertDetails, ConnectivityAlertDetailsDTO, ConnectivityAlertFilters, ConnectivityAlertInfos, ConnectivityAlertInfosDTO } from "@dative-gpi/foundation-core-domain/models";
4
2
  import { ComposableFactory, ServiceFactory } from "@dative-gpi/bones-ui";
5
3
 
@@ -9,51 +7,9 @@ const ConnectivityAlertServiceFactory = new ServiceFactory<ConnectivityAlertDeta
9
7
  factory.addGet(CONNECTIVITY_ALERT_URL),
10
8
  factory.addGetMany<ConnectivityAlertInfosDTO, ConnectivityAlertInfos, ConnectivityAlertFilters>(CONNECTIVITY_ALERTS_URL, ConnectivityAlertInfos),
11
9
  factory.addRemove(CONNECTIVITY_ALERT_URL),
12
- factory.addNotify((notifyService) => ({
13
- getNotify: async (connectivityAlertId: string): Promise<ConnectivityAlertDetails> => {
14
- const response = await ServiceFactory.http.get(CONNECTIVITY_ALERT_URL(connectivityAlertId));
15
- const result = new ConnectivityAlertDetails(response.data);
16
-
17
- notifyService.notify("update", result);
18
-
19
- return result;
20
- },
21
- removeNotify: (connectivityAlertId: string): void => {
22
- notifyService.notify("delete", connectivityAlertId);
23
- }
24
- }))
10
+ factory.addNotify()
25
11
  ));
26
12
 
27
13
  export const useConnectivityAlert = ComposableFactory.get(ConnectivityAlertServiceFactory);
28
14
  export const useConnectivityAlerts = ComposableFactory.getMany(ConnectivityAlertServiceFactory);
29
- export const useRemoveConnectivityAlert = ComposableFactory.remove(ConnectivityAlertServiceFactory);
30
- export const useNotifyConnectivityAlert = () => {
31
- const service = ConnectivityAlertServiceFactory();
32
-
33
- const fetching = ref(false);
34
- const fetched = ref<ConnectivityAlertDetails | null>(null);
35
-
36
- const fetch = async (connectivityAlertId: string) => {
37
- fetching.value = true;
38
- try {
39
- fetched.value = await service.getNotify(connectivityAlertId);
40
- }
41
- finally {
42
- fetching.value = false;
43
- }
44
- return fetched;
45
- }
46
-
47
- return {
48
- fetching,
49
- fetch,
50
- fetched
51
- };
52
- }
53
- export const useNotifyRemoveConnectivityAlert = () => {
54
- const service = ConnectivityAlertServiceFactory();
55
-
56
- return {
57
- remove: service.removeNotify
58
- };
59
- }
15
+ export const useRemoveConnectivityAlert = ComposableFactory.remove(ConnectivityAlertServiceFactory);
@@ -1,41 +1,10 @@
1
- import { ref } from "vue";
2
-
3
- import { CustomPropertyValueDetails, CustomPropertyValueDetailsDTO, CustomPropertyValueInfos, CustomPropertyValueInfosDTO, PropertyEntity } from "@dative-gpi/foundation-core-domain/models";
4
- import { ServiceFactory } from "@dative-gpi/bones-ui";
1
+ import { CustomPropertyValueInfos, CustomPropertyValueInfosDTO, PropertyEntity } from "@dative-gpi/foundation-core-domain/models";
2
+ import { ComposableFactory, ServiceFactory } from "@dative-gpi/bones-ui";
5
3
 
6
4
  import { CUSTOM_PROPERTY_VALUES_URL } from "../../config/urls";
7
5
 
8
- const CustomPropertyValueServiceFactory = new ServiceFactory<CustomPropertyValueDetailsDTO, CustomPropertyValueDetails>("customPropertyValue", CustomPropertyValueDetails).create(factory => factory.build(
9
- factory.addNotify(() => ({
10
- getMany: async (entity: PropertyEntity, entityId: string, code: string): Promise<CustomPropertyValueInfos[]> => {
11
- const response = await ServiceFactory.http.get(CUSTOM_PROPERTY_VALUES_URL(entity, entityId, code));
12
- const result = response.data.map((dto: CustomPropertyValueInfosDTO) => new CustomPropertyValueInfos(dto));
13
-
14
- return result;
15
- }
16
- }))
17
- ));
18
-
19
- export const useCustomPropertyValues = () => {
20
- const service = CustomPropertyValueServiceFactory();
21
-
22
- const fetching = ref(false);
23
- const fetched = ref<CustomPropertyValueInfos[] | null>(null);
24
-
25
- const fetch = async (entity: PropertyEntity, entityId: string, code: string) => {
26
- fetching.value = true;
27
- try {
28
- fetched.value = await service.getMany(entity, entityId, code);
29
- }
30
- finally {
31
- fetching.value = false;
32
- }
33
- return fetched;
34
- }
6
+ const CustomPropertyValueServiceFactory = {
7
+ ...ServiceFactory.addCustom("getMany", (axios, entity: PropertyEntity, entityId: string, code: string) => axios.get(CUSTOM_PROPERTY_VALUES_URL(entity, entityId, code)), (dtos: CustomPropertyValueInfosDTO[]) => dtos.map((dto: CustomPropertyValueInfosDTO) => new CustomPropertyValueInfos(dto))),
8
+ };
35
9
 
36
- return {
37
- fetching,
38
- fetch,
39
- fetched
40
- }
41
- }
10
+ export const useCustomPropertyValues = ComposableFactory.custom(CustomPropertyValueServiceFactory.getMany);
@@ -1,5 +1,3 @@
1
- import { ref } from "vue";
2
-
3
1
  import { DeviceConnectivityDetails, DeviceConnectivityDetailsDTO } from "@dative-gpi/foundation-core-domain/models";
4
2
  import { ComposableFactory, ServiceFactory } from "@dative-gpi/bones-ui";
5
3
 
@@ -7,40 +5,7 @@ import { DEVICE_CONNECTIVITY_URL } from "../../config/urls";
7
5
 
8
6
  const DeviceConnectivityServiceFactory = new ServiceFactory<DeviceConnectivityDetailsDTO, DeviceConnectivityDetails>("deviceConnectivity", DeviceConnectivityDetails).create(factory => factory.build(
9
7
  factory.addGet(DEVICE_CONNECTIVITY_URL),
10
- factory.addNotify((notifyService) => ({
11
- getNotify: async (deviceConnectivityId: string): Promise<DeviceConnectivityDetails> => {
12
- const response = await ServiceFactory.http.get(DEVICE_CONNECTIVITY_URL(deviceConnectivityId));
13
- const result = new DeviceConnectivityDetails(response.data);
14
-
15
- notifyService.notify("update", result);
16
-
17
- return result;
18
- }
19
- }))
8
+ factory.addNotify()
20
9
  ));
21
10
 
22
- export const useDeviceConnectivity = ComposableFactory.get(DeviceConnectivityServiceFactory);
23
- export const useNotifyDeviceConnectivity = () => {
24
- const service = DeviceConnectivityServiceFactory();
25
-
26
- const fetching = ref(false);
27
- const fetched = ref<DeviceConnectivityDetails | null>(null);
28
-
29
- const fetch = async (deviceConnectivityId: string) => {
30
- fetching.value = true;
31
- try {
32
- fetched.value = await service.getNotify(deviceConnectivityId);
33
- }
34
- finally {
35
- fetching.value = false;
36
- }
37
-
38
- return fetched;
39
- }
40
-
41
- return {
42
- fetching,
43
- fetch,
44
- fetched
45
- };
46
- }
11
+ export const useDeviceConnectivity = ComposableFactory.get(DeviceConnectivityServiceFactory);
@@ -1,7 +1,5 @@
1
- import { onUnmounted, ref } from "vue";
2
-
3
1
  import { ChangeDeviceOrganisationGroupDTO, ChangeDeviceOrganisationLocationDTO, CreateDeviceOrganisationDTO, DeviceOrganisationDetails, DeviceOrganisationDetailsDTO, DeviceOrganisationFilters, DeviceOrganisationInfos, DeviceOrganisationInfosDTO, UpdateDeviceOrganisationDTO } from "@dative-gpi/foundation-core-domain/models";
4
- import { ComposableFactory, onEntityChanged , ServiceFactory } from "@dative-gpi/bones-ui";
2
+ import { ComposableFactory, ServiceFactory } from "@dative-gpi/bones-ui";
5
3
 
6
4
  import { DEVICE_ORGANISATIONS_URL, DEVICE_ORGANISATION_URL, DEVICE_ORGANISATION_GROUP_URL, DEVICE_ORGANISATION_LOCATION_URL } from "../../config/urls";
7
5
 
@@ -11,23 +9,17 @@ const DeviceOrganisationServiceFactory = new ServiceFactory<DeviceOrganisationDe
11
9
  factory.addCreate<CreateDeviceOrganisationDTO>(DEVICE_ORGANISATIONS_URL),
12
10
  factory.addUpdate<UpdateDeviceOrganisationDTO>(DEVICE_ORGANISATION_URL),
13
11
  factory.addRemove(DEVICE_ORGANISATION_URL),
14
- factory.addNotify((notifyService) => ({
15
- changeGroup: async (deviceOrganisationId: string, payload: ChangeDeviceOrganisationGroupDTO): Promise<DeviceOrganisationDetails> => {
16
- const response = await ServiceFactory.http.put(DEVICE_ORGANISATION_GROUP_URL(deviceOrganisationId), payload);
17
- const result = new DeviceOrganisationDetails(response.data);
18
-
19
- notifyService.notify("update", result);
20
-
12
+ factory.addNotify(notify => ({
13
+ ...ServiceFactory.addCustom("changeGroup", (axios, deviceOrganisationId: string, payload: ChangeDeviceOrganisationGroupDTO) => axios.put(DEVICE_ORGANISATION_GROUP_URL(deviceOrganisationId), payload), (dto: DeviceOrganisationDetailsDTO) => {
14
+ const result = new DeviceOrganisationDetails(dto);
15
+ notify.notify("update", result);
21
16
  return result;
22
- },
23
- changeLocation: async (deviceOrganisationId: string, payload: ChangeDeviceOrganisationLocationDTO): Promise<DeviceOrganisationDetails> => {
24
- const response = await ServiceFactory.http.put(DEVICE_ORGANISATION_LOCATION_URL(deviceOrganisationId), payload);
25
- const result = new DeviceOrganisationDetails(response.data);
26
-
27
- notifyService.notify("update", result);
28
-
17
+ }),
18
+ ...ServiceFactory.addCustom("changeLocation", (axios, deviceOrganisationId: string, payload: ChangeDeviceOrganisationLocationDTO) => axios.put(DEVICE_ORGANISATION_LOCATION_URL(deviceOrganisationId), payload), (dto: DeviceOrganisationDetailsDTO) => {
19
+ const result = new DeviceOrganisationDetails(dto);
20
+ notify.notify("update", result);
29
21
  return result;
30
- }
22
+ })
31
23
  }))
32
24
  ));
33
25
 
@@ -36,63 +28,5 @@ export const useDeviceOrganisations = ComposableFactory.getMany(DeviceOrganisati
36
28
  export const useCreateDeviceOrganisation = ComposableFactory.create(DeviceOrganisationServiceFactory);
37
29
  export const useUpdateDeviceOrganisation = ComposableFactory.update(DeviceOrganisationServiceFactory);
38
30
  export const useRemoveDeviceOrganisation = ComposableFactory.remove(DeviceOrganisationServiceFactory);
39
- export const useChangeDeviceOrganisationGroup = () => {
40
- const service = DeviceOrganisationServiceFactory();
41
- const subscriberIds: number[] = [];
42
-
43
- const changing = ref(false);
44
- const changed = ref<DeviceOrganisationDetails | null>(null);
45
-
46
- onUnmounted(() => {
47
- subscriberIds.forEach(id => service.unsubscribe(id));
48
- subscriberIds.length = 0;
49
- });
50
-
51
- const change = async (deviceOrganisationId: string, payload: ChangeDeviceOrganisationGroupDTO) => {
52
- changing.value = true;
53
- try {
54
- changed.value = await service.changeGroup(deviceOrganisationId, payload);
55
- }
56
- finally {
57
- changing.value = false;
58
- }
59
- subscriberIds.push(service.subscribe("all", onEntityChanged(changed)));
60
- return changed;
61
- }
62
-
63
- return {
64
- changing,
65
- change,
66
- changed
67
- }
68
- }
69
- export const useChangeDeviceOrganisationLocation = () => {
70
- const service = DeviceOrganisationServiceFactory();
71
- const subscriberIds: number[] = [];
72
-
73
- const changing = ref(false);
74
- const changed = ref<DeviceOrganisationDetails | null>(null);
75
-
76
- onUnmounted(() => {
77
- subscriberIds.forEach(id => service.unsubscribe(id));
78
- subscriberIds.length = 0;
79
- });
80
-
81
- const change = async (deviceOrganisationId: string, payload: ChangeDeviceOrganisationLocationDTO) => {
82
- changing.value = true;
83
- try {
84
- changed.value = await service.changeLocation(deviceOrganisationId, payload);
85
- }
86
- finally {
87
- changing.value = false;
88
- }
89
- subscriberIds.push(service.subscribe("all", onEntityChanged(changed)));
90
- return changed;
91
- }
92
-
93
- return {
94
- changing,
95
- change,
96
- changed
97
- }
98
- }
31
+ export const useChangeDeviceOrganisationGroup = ComposableFactory.custom(DeviceOrganisationServiceFactory.changeGroup);
32
+ export const useChangeDeviceOrganisationLocation = ComposableFactory.custom(DeviceOrganisationServiceFactory.changeLocation);
@@ -1,5 +1,3 @@
1
- import { ref } from "vue";
2
-
3
1
  import { DeviceStatusDetails, DeviceStatusDetailsDTO } from "@dative-gpi/foundation-core-domain/models";
4
2
  import { ComposableFactory, ServiceFactory } from "@dative-gpi/bones-ui";
5
3
 
@@ -7,39 +5,7 @@ import { DEVICE_STATUS_URL } from "../../config/urls";
7
5
 
8
6
  const DeviceStatusServiceFactory = new ServiceFactory<DeviceStatusDetailsDTO, DeviceStatusDetails>("deviceStatus", DeviceStatusDetails).create(factory => factory.build(
9
7
  factory.addGet(DEVICE_STATUS_URL),
10
- factory.addNotify((notifyService) => ({
11
- getNotify: async (deviceStatusId: string): Promise<DeviceStatusDetails> => {
12
- const response = await ServiceFactory.http.get(DEVICE_STATUS_URL(deviceStatusId));
13
- const result = new DeviceStatusDetails(response.data);
14
-
15
- notifyService.notify("update", result);
16
-
17
- return result;
18
- }
19
- }))
8
+ factory.addNotify()
20
9
  ));
21
10
 
22
- export const useDeviceStatus = ComposableFactory.get(DeviceStatusServiceFactory);
23
- export const useNotifyDeviceStatus = () => {
24
- const service = DeviceStatusServiceFactory();
25
-
26
- const fetching = ref(false);
27
- const fetched = ref<DeviceStatusDetails | null>(null);
28
-
29
- const fetch = async (deviceStatusId: string) => {
30
- fetching.value = true;
31
- try {
32
- fetched.value = await service.getNotify(deviceStatusId);
33
- }
34
- finally {
35
- fetching.value = false;
36
- }
37
- return fetched;
38
- }
39
-
40
- return {
41
- fetching,
42
- fetch,
43
- fetched
44
- };
45
- }
11
+ export const useDeviceStatus = ComposableFactory.get(DeviceStatusServiceFactory);
@@ -1,7 +1,5 @@
1
- import { onUnmounted, ref } from "vue";
2
-
3
1
  import { ChangeGroupParentDTO, CreateGroupDTO, GroupDetails, GroupDetailsDTO, GroupFilters, GroupInfos, GroupInfosDTO, UpdateGroupDTO } from "@dative-gpi/foundation-core-domain/models";
4
- import { ComposableFactory, onEntityChanged , ServiceFactory } from "@dative-gpi/bones-ui";
2
+ import { ComposableFactory, ServiceFactory } from "@dative-gpi/bones-ui";
5
3
 
6
4
  import { GROUPS_URL, GROUP_URL } from "../../config/urls";
7
5
 
@@ -11,15 +9,12 @@ const GroupServiceFactory = new ServiceFactory<GroupDetailsDTO, GroupDetails>("g
11
9
  factory.addCreate<CreateGroupDTO>(GROUPS_URL),
12
10
  factory.addUpdate<UpdateGroupDTO>(GROUP_URL),
13
11
  factory.addRemove(GROUP_URL),
14
- factory.addNotify((notifyService) => ({
15
- changeParent: async (groupId: string, payload: ChangeGroupParentDTO): Promise<GroupDetails> => {
16
- const response = await ServiceFactory.http.put(GROUP_URL(groupId), payload);
17
- const result = new GroupDetails(response.data);
18
-
19
- notifyService.notify("update", result);
20
-
12
+ factory.addNotify(notify => ({
13
+ ...ServiceFactory.addCustom("changeParent", (axios, groupdId: string, payload: ChangeGroupParentDTO) => axios.put(GROUP_URL(groupdId), payload), (dto: GroupDetailsDTO) => {
14
+ const result = new GroupDetails(dto);
15
+ notify.notify("update", result);
21
16
  return result;
22
- }
17
+ })
23
18
  }))
24
19
  ));
25
20
 
@@ -28,33 +23,4 @@ export const useGroups = ComposableFactory.getMany(GroupServiceFactory);
28
23
  export const useCreateGroup = ComposableFactory.create(GroupServiceFactory);
29
24
  export const useUpdateGroup = ComposableFactory.update(GroupServiceFactory);
30
25
  export const useRemoveGroup = ComposableFactory.remove(GroupServiceFactory);
31
- export const useChangeGroupParent = () => {
32
- const service = GroupServiceFactory();
33
- const subscriberIds: number[] = [];
34
-
35
- const changing = ref(false);
36
- const changed = ref<GroupDetails | null>(null);
37
-
38
- onUnmounted(() => {
39
- subscriberIds.forEach(id => service.unsubscribe(id));
40
- subscriberIds.length = 0;
41
- });
42
-
43
- const change = async (groupId: string, payload: ChangeGroupParentDTO) => {
44
- changing.value = true;
45
- try {
46
- changed.value = await service.changeParent(groupId, payload);
47
- }
48
- finally {
49
- changing.value = false;
50
- }
51
- subscriberIds.push(service.subscribe("all", onEntityChanged(changed)));
52
- return changed;
53
- }
54
-
55
- return {
56
- changing,
57
- change,
58
- changed
59
- }
60
- }
26
+ export const useChangeGroupParent = ComposableFactory.custom(GroupServiceFactory.changeParent);
@@ -1,51 +1,17 @@
1
- import { onUnmounted, ref } from "vue";
2
-
3
1
  import { OrganisationDetails, OrganisationDetailsDTO } from "@dative-gpi/foundation-shared-domain/models";
4
2
  import { ChangeOrganisationDashboardDTO } from "@dative-gpi/foundation-core-domain/models";
5
- import { onEntityChanged , ServiceFactory } from "@dative-gpi/bones-ui";
3
+ import { ComposableFactory, ServiceFactory } from "@dative-gpi/bones-ui";
6
4
 
7
5
  import { ORGANISATION_DASHBOARD_URL } from "../../config/urls";
8
6
 
9
7
  const OrganisationServiceFactory = new ServiceFactory<OrganisationDetailsDTO, OrganisationDetails>("organisation", OrganisationDetails).create(factory => factory.build(
10
- factory.addNotify((notifyService) => ({
11
- changeDashboard: async (payload: ChangeOrganisationDashboardDTO): Promise<OrganisationDetails> => {
12
- const response = await ServiceFactory.http.put(ORGANISATION_DASHBOARD_URL(), payload);
13
- const result = new OrganisationDetails(response.data);
14
-
15
- notifyService.notify("update", result);
16
-
8
+ factory.addNotify(notify => ({
9
+ ...ServiceFactory.addCustom("changeDashboard", (axios, payload: ChangeOrganisationDashboardDTO) => axios.put(ORGANISATION_DASHBOARD_URL(), payload), (dto: OrganisationDetailsDTO) => {
10
+ const result = new OrganisationDetails(dto);
11
+ notify.notify("update", result);
17
12
  return result;
18
- }
13
+ })
19
14
  }))
20
15
  ));
21
16
 
22
- export const useChangeDashboardOrganisation = () => {
23
- const service = OrganisationServiceFactory();
24
- const subscribersIds: number[] = [];
25
-
26
- const changing = ref(false);
27
- const changed = ref<OrganisationDetails | null>(null);
28
-
29
- onUnmounted(() => {
30
- subscribersIds.forEach(id => service.unsubscribe(id));
31
- subscribersIds.length = 0;
32
- });
33
-
34
- const change = async (payload: ChangeOrganisationDashboardDTO) => {
35
- changing.value = true;
36
- try {
37
- changed.value = await service.changeDashboard(payload);
38
- }
39
- finally {
40
- changing.value = false;
41
- }
42
- subscribersIds.push(service.subscribe("all", onEntityChanged(changed)));
43
- return changed;
44
- }
45
-
46
- return {
47
- changing,
48
- change,
49
- changed
50
- }
51
- }
17
+ export const useChangeDashboardOrganisation = ComposableFactory.custom(OrganisationServiceFactory.changeDashboard);
@@ -1,7 +1,5 @@
1
- import { onUnmounted, ref } from "vue";
2
-
3
1
  import { CreateUserOrganisationDTO, UpdateUserOrganisationDTO, UserOrganisationDetails, UserOrganisationDetailsDTO, UserOrganisationFilters, UserOrganisationInfos, UserOrganisationInfosDTO } from "@dative-gpi/foundation-core-domain/models";
4
- import { ComposableFactory, onEntityChanged, ServiceFactory } from "@dative-gpi/bones-ui";
2
+ import { ComposableFactory, ServiceFactory } from "@dative-gpi/bones-ui";
5
3
 
6
4
  import { USER_ORGANISATIONS_URL, USER_ORGANISATION_CURRENT_URL, USER_ORGANISATION_URL } from "../../config/urls";
7
5
 
@@ -11,88 +9,28 @@ const UserOrganisationServiceFactory = new ServiceFactory<UserOrganisationDetail
11
9
  factory.addCreate<CreateUserOrganisationDTO>(USER_ORGANISATIONS_URL),
12
10
  factory.addUpdate<UpdateUserOrganisationDTO>(USER_ORGANISATION_URL),
13
11
  factory.addRemove(USER_ORGANISATION_URL),
14
- factory.addNotify((notifyService) => ({
15
- getCurrent: async (): Promise<UserOrganisationDetails> => {
16
- const response = await ServiceFactory.http.get(USER_ORGANISATION_CURRENT_URL());
17
- const result = new UserOrganisationDetails(response.data);
18
-
19
- notifyService.notify("update", result);
20
-
12
+ ServiceFactory.addCustom("getCurrent", (axios) => axios.get(USER_ORGANISATION_CURRENT_URL()), (dto: UserOrganisationDetailsDTO) => new UserOrganisationDetails(dto)),
13
+ factory.addNotify(notify => ({
14
+ ...ServiceFactory.addCustom("updateCurrent", (axios, payload: UpdateUserOrganisationDTO) => axios.post(USER_ORGANISATION_CURRENT_URL(), payload), (dto: UserOrganisationDetailsDTO) => {
15
+ const result = new UserOrganisationDetails(dto)
16
+ notify.notify("update", result);
21
17
  return result;
22
- },
23
- updateCurrent: async(payload: UpdateUserOrganisationDTO): Promise<UserOrganisationDetails> => {
24
- const response = await ServiceFactory.http.post(USER_ORGANISATION_CURRENT_URL(), payload);
25
- const result = new UserOrganisationDetails(response.data);
26
-
27
- notifyService.notify("update", result);
28
-
29
- return result;
30
- }
18
+ }),
31
19
  }))
32
20
  ));
33
21
 
22
+ export const useTrackUserOrganisation = ComposableFactory.track(UserOrganisationServiceFactory);
23
+
34
24
  export const useUserOrganisation = ComposableFactory.get(UserOrganisationServiceFactory);
35
25
  export const useUserOrganisations = ComposableFactory.getMany(UserOrganisationServiceFactory);
36
26
  export const useCreateUserOrganisation = ComposableFactory.create(UserOrganisationServiceFactory);
37
27
  export const useUpdateUserOrganisation = ComposableFactory.update(UserOrganisationServiceFactory);
38
28
  export const useRemoveUserOrganisation = ComposableFactory.remove(UserOrganisationServiceFactory);
39
- export const useCurrentUserOrganisation = () => {
40
- const service = UserOrganisationServiceFactory();
41
- const subscribersIds: number[] = [];
42
-
43
- const fetching = ref(false);
44
- const fetched = ref<UserOrganisationDetails | null>(null);
45
-
46
- onUnmounted(() => {
47
- subscribersIds.forEach(id => service.unsubscribe(id));
48
- subscribersIds.length = 0;
49
- });
50
-
51
- const fetch = async () => {
52
- fetching.value = true;
53
- try {
54
- fetched.value = await service.getCurrent();
55
- }
56
- finally {
57
- fetching.value = false;
58
- }
59
- subscribersIds.push(service.subscribe("all", onEntityChanged(fetched)));
60
- return fetched;
61
- }
62
-
63
- return {
64
- fetching,
65
- fetch,
66
- fetched
67
- }
68
- }
69
- export const useUpdateCurrentUserOrganisation = () => {
70
- const service = UserOrganisationServiceFactory();
71
- const subscribersIds: number[] = [];
72
-
73
- const updating = ref(false);
74
- const updated = ref<UserOrganisationDetails | null>(null);
75
-
76
- onUnmounted(() => {
77
- subscribersIds.forEach(id => service.unsubscribe(id));
78
- subscribersIds.length = 0;
79
- });
80
-
81
- const update = async (payload: UpdateUserOrganisationDTO) => {
82
- updating.value = true;
83
- try {
84
- updated.value = await service.updateCurrent(payload);
85
- }
86
- finally {
87
- updating.value = false;
88
- }
89
- subscribersIds.push(service.subscribe("all", onEntityChanged(updated)));
90
- return updated;
91
- }
92
-
93
- return {
94
- updating,
95
- update,
96
- updated
29
+ export const useCurrentUserOrganisation = ComposableFactory.custom(UserOrganisationServiceFactory.getCurrent, () => {
30
+ const { track } = useTrackUserOrganisation();
31
+
32
+ return (userOrganisation) => {
33
+ track(userOrganisation);
97
34
  }
98
- }
35
+ });
36
+ export const useUpdateCurrentUserOrganisation = ComposableFactory.custom(UserOrganisationServiceFactory.updateCurrent);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@dative-gpi/foundation-core-services",
3
3
  "sideEffects": false,
4
- "version": "0.0.52",
4
+ "version": "0.0.54",
5
5
  "description": "",
6
6
  "publishConfig": {
7
7
  "access": "public"
@@ -10,11 +10,11 @@
10
10
  "author": "",
11
11
  "license": "ISC",
12
12
  "dependencies": {
13
- "@dative-gpi/bones-ui": "^0.0.61",
14
- "@dative-gpi/foundation-core-domain": "0.0.52",
13
+ "@dative-gpi/bones-ui": "^0.0.70",
14
+ "@dative-gpi/foundation-core-domain": "0.0.54",
15
15
  "@microsoft/signalr": "^8.0.0",
16
16
  "vue": "^3.2.0",
17
17
  "vue-router": "^4.2.5"
18
18
  },
19
- "gitHead": "1cea46f60262aceae3135923684ed4a5af60d0bb"
19
+ "gitHead": "391503e595cd9d731fca14b5bb2d3a10b6efee95"
20
20
  }