@dative-gpi/foundation-core-services 0.0.2

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 (76) hide show
  1. package/composables/hubs/index.ts +4 -0
  2. package/composables/hubs/useAlertsHub.ts +51 -0
  3. package/composables/hubs/useConnectivityAlertsHub.ts +51 -0
  4. package/composables/hubs/useDeviceConnectivitiesHub.ts +49 -0
  5. package/composables/hubs/useDeviceStatusesHub.ts +49 -0
  6. package/composables/index.ts +5 -0
  7. package/composables/services/index.ts +27 -0
  8. package/composables/services/useAlerts.ts +95 -0
  9. package/composables/services/useApplications.ts +47 -0
  10. package/composables/services/useArticles.ts +13 -0
  11. package/composables/services/useAuthTokens.ts +15 -0
  12. package/composables/services/useConnectivityAlerts.ts +60 -0
  13. package/composables/services/useCustomProperties.ts +11 -0
  14. package/composables/services/useCustomPropertyValues.ts +42 -0
  15. package/composables/services/useDataCategories.ts +13 -0
  16. package/composables/services/useDataDefinitions.ts +13 -0
  17. package/composables/services/useDeviceConnectivities.ts +46 -0
  18. package/composables/services/useDeviceOrganisations.ts +92 -0
  19. package/composables/services/useDeviceStatuses.ts +46 -0
  20. package/composables/services/useFamilies.ts +13 -0
  21. package/composables/services/useGroups.ts +57 -0
  22. package/composables/services/useLanguages.ts +13 -0
  23. package/composables/services/useLocations.ts +13 -0
  24. package/composables/services/useManufacturers.ts +13 -0
  25. package/composables/services/useModels.ts +13 -0
  26. package/composables/services/useOrganisationTypes.ts +13 -0
  27. package/composables/services/useOrganisations.ts +53 -0
  28. package/composables/services/usePermissionCategories.ts +11 -0
  29. package/composables/services/usePermissions.ts +42 -0
  30. package/composables/services/useRoleOrganisationTypes.ts +13 -0
  31. package/composables/services/useRoleOrganisations.ts +13 -0
  32. package/composables/services/useTimeZones.ts +11 -0
  33. package/composables/services/useTranslations.ts +42 -0
  34. package/composables/services/useUserOrganisations.ts +92 -0
  35. package/composables/services/useUsers.ts +90 -0
  36. package/composables/useLanguageCode.ts +48 -0
  37. package/composables/useOrganisationId.ts +50 -0
  38. package/composables/useTimeZone.ts +75 -0
  39. package/config/index.ts +2 -0
  40. package/config/literals/hubs.ts +14 -0
  41. package/config/literals/index.ts +5 -0
  42. package/config/urls/alerts.ts +6 -0
  43. package/config/urls/applications.ts +4 -0
  44. package/config/urls/articles.ts +4 -0
  45. package/config/urls/authTokens.ts +4 -0
  46. package/config/urls/base.ts +5 -0
  47. package/config/urls/connectivityAlerts.ts +6 -0
  48. package/config/urls/customProperties.ts +3 -0
  49. package/config/urls/customPropertyValues.ts +5 -0
  50. package/config/urls/dataCategories.ts +4 -0
  51. package/config/urls/dataDefinitions.ts +4 -0
  52. package/config/urls/deviceConnectivities.ts +6 -0
  53. package/config/urls/deviceOrganisations.ts +6 -0
  54. package/config/urls/deviceStatuses.ts +6 -0
  55. package/config/urls/families.ts +4 -0
  56. package/config/urls/files.ts +4 -0
  57. package/config/urls/groups.ts +4 -0
  58. package/config/urls/images.ts +5 -0
  59. package/config/urls/index.ts +29 -0
  60. package/config/urls/languages.ts +4 -0
  61. package/config/urls/locations.ts +4 -0
  62. package/config/urls/manufacturers.ts +4 -0
  63. package/config/urls/models.ts +4 -0
  64. package/config/urls/organisationTypes.ts +4 -0
  65. package/config/urls/organisations.ts +7 -0
  66. package/config/urls/permissionCategories.ts +3 -0
  67. package/config/urls/permissions.ts +3 -0
  68. package/config/urls/roleOrganisationTypes.ts +4 -0
  69. package/config/urls/roleOrganisations.ts +4 -0
  70. package/config/urls/timeZones.ts +3 -0
  71. package/config/urls/translations.ts +4 -0
  72. package/config/urls/urlFactory.ts +17 -0
  73. package/config/urls/userOrganisations.ts +5 -0
  74. package/config/urls/users.ts +5 -0
  75. package/index.ts +2 -0
  76. package/package.json +19 -0
@@ -0,0 +1,92 @@
1
+ import { Ref, onUnmounted, readonly, ref } from "vue";
2
+
3
+ import { ChangeDeviceOrganisationGroupDTO, ChangeDeviceOrganisationLocationDTO, CreateDeviceOrganisationDTO, DeviceOrganisationDetails, DeviceOrganisationDetailsDTO, DeviceOrganisationFilters, DeviceOrganisationInfos, DeviceOrganisationInfosDTO, UpdateDeviceOrganisationDTO } from "@dative-gpi/foundation-core-domain";
4
+ import { ComposableFactory, onEntityChanged , ServiceFactory } from "@dative-gpi/bones-ui";
5
+
6
+ import { DEVICE_ORGANISATIONS_URL, DEVICE_ORGANISATION_URL, DEVICE_ORGANISATION_GROUP_URL, DEVICE_ORGANISATION_LOCATION_URL } from "../../config/urls";
7
+
8
+ const DeviceOrganisationServiceFactory = new ServiceFactory<DeviceOrganisationDetailsDTO, DeviceOrganisationDetails>("deviceOrganisation", DeviceOrganisationDetails).create(factory => factory.build(
9
+ factory.addGet(DEVICE_ORGANISATION_URL),
10
+ factory.addGetMany<DeviceOrganisationInfosDTO, DeviceOrganisationInfos, DeviceOrganisationFilters>(DEVICE_ORGANISATIONS_URL, DeviceOrganisationInfos),
11
+ factory.addCreate<CreateDeviceOrganisationDTO>(DEVICE_ORGANISATIONS_URL),
12
+ factory.addUpdate<UpdateDeviceOrganisationDTO>(DEVICE_ORGANISATION_URL),
13
+ 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
+
21
+ 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
+
29
+ return result;
30
+ }
31
+ }))
32
+ ));
33
+
34
+ export const useDeviceOrganisation = ComposableFactory.get(DeviceOrganisationServiceFactory);
35
+ export const useDeviceOrganisations = ComposableFactory.getMany(DeviceOrganisationServiceFactory);
36
+ export const useCreateDeviceOrganisation = ComposableFactory.create(DeviceOrganisationServiceFactory);
37
+ export const useUpdateDeviceOrganisation = ComposableFactory.update(DeviceOrganisationServiceFactory);
38
+ export const useRemoveDeviceOrganisation = ComposableFactory.remove(DeviceOrganisationServiceFactory);
39
+ export const useChangeDeviceOrganisationGroup = () => {
40
+ const service = DeviceOrganisationServiceFactory();
41
+
42
+ const changing = ref(false);
43
+ const changed = ref<DeviceOrganisationDetails | null>(null) as Ref<DeviceOrganisationDetails | null>;
44
+
45
+ const change = async (deviceOrganisationId: string, payload: ChangeDeviceOrganisationGroupDTO) => {
46
+ changing.value = true;
47
+ try {
48
+ changed.value = await service.changeGroup(deviceOrganisationId, payload);
49
+ }
50
+ finally {
51
+ changing.value = false;
52
+ }
53
+
54
+ const subscriberId = service.subscribe("all", onEntityChanged(changed))
55
+ onUnmounted(() => service.unsubscribe(subscriberId));
56
+
57
+ return readonly(changed as Ref<DeviceOrganisationDetails>);
58
+ }
59
+
60
+ return {
61
+ changing: readonly(changing),
62
+ change,
63
+ changed: readonly(changed)
64
+ }
65
+ }
66
+ export const useChangeDeviceOrganisationLocation = () => {
67
+ const service = DeviceOrganisationServiceFactory();
68
+
69
+ const changing = ref(false);
70
+ const changed = ref<DeviceOrganisationDetails | null>(null) as Ref<DeviceOrganisationDetails | null>;
71
+
72
+ const change = async (deviceOrganisationId: string, payload: ChangeDeviceOrganisationLocationDTO) => {
73
+ changing.value = true;
74
+ try {
75
+ changed.value = await service.changeLocation(deviceOrganisationId, payload);
76
+ }
77
+ finally {
78
+ changing.value = false;
79
+ }
80
+
81
+ const subscriberId = service.subscribe("all", onEntityChanged(changed))
82
+ onUnmounted(() => service.unsubscribe(subscriberId));
83
+
84
+ return readonly(changed as Ref<DeviceOrganisationDetails>);
85
+ }
86
+
87
+ return {
88
+ changing: readonly(changing),
89
+ change,
90
+ changed: readonly(changed)
91
+ }
92
+ }
@@ -0,0 +1,46 @@
1
+ import { Ref, readonly, ref } from "vue";
2
+
3
+ import { DeviceStatusDetails, DeviceStatusDetailsDTO } from "@dative-gpi/foundation-core-domain";
4
+ import { ComposableFactory, ServiceFactory } from "@dative-gpi/bones-ui";
5
+
6
+ import { DEVICE_STATUS_URL } from "../../config/urls";
7
+
8
+ const DeviceStatusServiceFactory = new ServiceFactory<DeviceStatusDetailsDTO, DeviceStatusDetails>("deviceStatus", DeviceStatusDetails).create(factory => factory.build(
9
+ 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
+ }))
20
+ ));
21
+
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) as Ref<DeviceStatusDetails | 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
+
38
+ return readonly(fetched as Ref<DeviceStatusDetails>);
39
+ }
40
+
41
+ return {
42
+ fetching: readonly(fetching),
43
+ fetch,
44
+ fetched: readonly(fetched)
45
+ };
46
+ }
@@ -0,0 +1,13 @@
1
+ import { FamilyDetails, FamilyDetailsDTO, FamilyFilters, FamilyInfos, FamilyInfosDTO } from "@dative-gpi/foundation-core-domain";
2
+ import { ComposableFactory, ServiceFactory } from "@dative-gpi/bones-ui";
3
+
4
+ import { FAMILIES_URL, FAMILY_URL } from "../../config/urls";
5
+
6
+ const FamilieserviceFactory = new ServiceFactory<FamilyDetailsDTO, FamilyDetails>("family", FamilyDetails).create(factory => factory.build(
7
+ factory.addGet(FAMILY_URL),
8
+ factory.addGetMany<FamilyInfosDTO, FamilyInfos, FamilyFilters>(FAMILIES_URL, FamilyInfos),
9
+ factory.addNotify()
10
+ ));
11
+
12
+ export const useFamily = ComposableFactory.get(FamilieserviceFactory);
13
+ export const useFamilies = ComposableFactory.getMany(FamilieserviceFactory);
@@ -0,0 +1,57 @@
1
+ import { Ref, onUnmounted, readonly, ref } from "vue";
2
+
3
+ import { ChangeGroupParentDTO, CreateGroupDTO, GroupDetails, GroupDetailsDTO, GroupFilters, GroupInfos, GroupInfosDTO, UpdateGroupDTO } from "@dative-gpi/foundation-core-domain";
4
+ import { ComposableFactory, onEntityChanged , ServiceFactory } from "@dative-gpi/bones-ui";
5
+
6
+ import { GROUPS_URL, GROUP_URL } from "../../config/urls";
7
+
8
+ const GroupServiceFactory = new ServiceFactory<GroupDetailsDTO, GroupDetails>("group", GroupDetails).create(factory => factory.build(
9
+ factory.addGet(GROUP_URL),
10
+ factory.addGetMany<GroupInfosDTO, GroupInfos, GroupFilters>(GROUPS_URL, GroupInfos),
11
+ factory.addCreate<CreateGroupDTO>(GROUPS_URL),
12
+ factory.addUpdate<UpdateGroupDTO>(GROUP_URL),
13
+ 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
+
21
+ return result;
22
+ }
23
+ }))
24
+ ));
25
+
26
+ export const useGroup = ComposableFactory.get(GroupServiceFactory);
27
+ export const useGroups = ComposableFactory.getMany(GroupServiceFactory);
28
+ export const useCreateGroup = ComposableFactory.create(GroupServiceFactory);
29
+ export const useUpdateGroup = ComposableFactory.update(GroupServiceFactory);
30
+ export const useRemoveGroup = ComposableFactory.remove(GroupServiceFactory);
31
+ export const useChangeGroupParent = () => {
32
+ const service = GroupServiceFactory();
33
+
34
+ const changing = ref(false);
35
+ const changed = ref<GroupDetails | null>(null) as Ref<GroupDetails | null>;
36
+
37
+ const change = async (groupId: string, payload: ChangeGroupParentDTO) => {
38
+ changing.value = true;
39
+ try {
40
+ changed.value = await service.changeParent(groupId, payload);
41
+ }
42
+ finally {
43
+ changing.value = false;
44
+ }
45
+
46
+ const subscriberId = service.subscribe("all", onEntityChanged(changed))
47
+ onUnmounted(() => service.unsubscribe(subscriberId));
48
+
49
+ return readonly(changed as Ref<GroupDetails>);
50
+ }
51
+
52
+ return {
53
+ changing: readonly(changing),
54
+ change,
55
+ changed: readonly(changed)
56
+ }
57
+ }
@@ -0,0 +1,13 @@
1
+ import { LanguageDetails, LanguageDetailsDTO, LanguageFilters, LanguageInfos, LanguageInfosDTO } from "@dative-gpi/foundation-core-domain";
2
+ import { ComposableFactory, ServiceFactory } from "@dative-gpi/bones-ui";
3
+
4
+ import { LANGUAGES_URL, LANGUAGE_URL } from "../../config/urls";
5
+
6
+ const LanguageServiceFactory = new ServiceFactory<LanguageDetailsDTO, LanguageDetails>("language", LanguageDetails).create(factory => factory.build(
7
+ factory.addGet(LANGUAGE_URL),
8
+ factory.addGetMany<LanguageInfosDTO, LanguageInfos, LanguageFilters>(LANGUAGES_URL, LanguageInfos),
9
+ factory.addNotify()
10
+ ));
11
+
12
+ export const useLanguage = ComposableFactory.get(LanguageServiceFactory);
13
+ export const useLanguages = ComposableFactory.getMany(LanguageServiceFactory);
@@ -0,0 +1,13 @@
1
+ import { CreateLocationDTO, LocationDetails, LocationDetailsDTO, LocationFilters, LocationInfos, LocationInfosDTO, UpdateLocationDTO } from "@dative-gpi/foundation-core-domain";
2
+ import { ComposableFactory, ServiceFactory } from "@dative-gpi/bones-ui";
3
+
4
+ import { LOCATIONS_URL, LOCATION_URL } from "../../config/urls";
5
+
6
+ const LocationServiceFactory = new ServiceFactory<LocationDetailsDTO, LocationDetails>("location", LocationDetails)
7
+ .createComplete<LocationInfos, LocationInfosDTO, CreateLocationDTO, UpdateLocationDTO, LocationFilters>(LOCATIONS_URL, LOCATION_URL, LocationInfos);
8
+
9
+ export const useLocation = ComposableFactory.get(LocationServiceFactory);
10
+ export const useLocations = ComposableFactory.getMany(LocationServiceFactory);
11
+ export const useCreateLocation = ComposableFactory.create(LocationServiceFactory);
12
+ export const useUpdateLocation = ComposableFactory.update(LocationServiceFactory);
13
+ export const useRemoveLocation = ComposableFactory.remove(LocationServiceFactory);
@@ -0,0 +1,13 @@
1
+ import { ManufacturerDetails, ManufacturerDetailsDTO, ManufacturerFilters, ManufacturerInfos, ManufacturerInfosDTO } from "@dative-gpi/foundation-core-domain";
2
+ import { ComposableFactory, ServiceFactory } from "@dative-gpi/bones-ui";
3
+
4
+ import { MANUFACTURERS_URL, MANUFACTURER_URL } from "../../config/urls";
5
+
6
+ const ManufacturerServiceFactory = new ServiceFactory<ManufacturerDetailsDTO, ManufacturerDetails>("manufacturer", ManufacturerDetails).create(factory => factory.build(
7
+ factory.addGet(MANUFACTURER_URL),
8
+ factory.addGetMany<ManufacturerInfosDTO, ManufacturerInfos, ManufacturerFilters>(MANUFACTURERS_URL, ManufacturerInfos),
9
+ factory.addNotify()
10
+ ));
11
+
12
+ export const useManufacturer = ComposableFactory.get(ManufacturerServiceFactory);
13
+ export const useManufacturers = ComposableFactory.getMany(ManufacturerServiceFactory);
@@ -0,0 +1,13 @@
1
+ import { ModelDetails, ModelDetailsDTO, ModelFilters, ModelInfos, ModelInfosDTO } from "@dative-gpi/foundation-core-domain";
2
+ import { ComposableFactory, ServiceFactory } from "@dative-gpi/bones-ui";
3
+
4
+ import { MODELS_URL, MODEL_URL } from "../../config/urls";
5
+
6
+ const ModelServiceFactory = new ServiceFactory<ModelDetailsDTO, ModelDetails>("model", ModelDetails).create(factory => factory.build(
7
+ factory.addGet(MODEL_URL),
8
+ factory.addGetMany<ModelInfosDTO, ModelInfos, ModelFilters>(MODELS_URL, ModelInfos),
9
+ factory.addNotify()
10
+ ));
11
+
12
+ export const useModel = ComposableFactory.get(ModelServiceFactory);
13
+ export const useModels = ComposableFactory.getMany(ModelServiceFactory);
@@ -0,0 +1,13 @@
1
+ import { OrganisationTypeDetails, OrganisationTypeDetailsDTO, OrganisationTypeFilters, OrganisationTypeInfos, OrganisationTypeInfosDTO } from "@dative-gpi/foundation-core-domain";
2
+ import { ComposableFactory, ServiceFactory } from "@dative-gpi/bones-ui";
3
+
4
+ import { ORGANISATION_TYPES_URL, ORGANISATION_TYPE_URL } from "../../config/urls";
5
+
6
+ const OrganisationTypeServiceFactory = new ServiceFactory<OrganisationTypeDetailsDTO, OrganisationTypeDetails>("organisationType", OrganisationTypeDetails).create(factory => factory.build(
7
+ factory.addGet(ORGANISATION_TYPE_URL),
8
+ factory.addGetMany<OrganisationTypeInfosDTO, OrganisationTypeInfos, OrganisationTypeFilters>(ORGANISATION_TYPES_URL, OrganisationTypeInfos),
9
+ factory.addNotify()
10
+ ));
11
+
12
+ export const useOrganisationType = ComposableFactory.get(OrganisationTypeServiceFactory);
13
+ export const useOrganisationTypes = ComposableFactory.getMany(OrganisationTypeServiceFactory);
@@ -0,0 +1,53 @@
1
+ import { Ref, onUnmounted, readonly, ref } from "vue";
2
+
3
+ import { ChangeOrganisationDashboardDTO, OrganisationDetails, OrganisationDetailsDTO, OrganisationFilters, OrganisationInfos, OrganisationInfosDTO, UpdateOrganisationDTO } from "@dative-gpi/foundation-core-domain";
4
+ import { ComposableFactory, onEntityChanged , ServiceFactory } from "@dative-gpi/bones-ui";
5
+
6
+ import { ORGANISATION_DASHBOARD_URL, ORGANISATIONS_URL, ORGANISATION_URL } from "../../config/urls";
7
+
8
+ const OrganisationServiceFactory = new ServiceFactory<OrganisationDetailsDTO, OrganisationDetails>("organisation", OrganisationDetails).create(factory => factory.build(
9
+ factory.addGet(ORGANISATION_URL),
10
+ factory.addGetMany<OrganisationInfosDTO, OrganisationInfos, OrganisationFilters>(ORGANISATIONS_URL, OrganisationInfos),
11
+ factory.addUpdate<UpdateOrganisationDTO>(ORGANISATION_URL),
12
+ factory.addNotify((notifyService) => ({
13
+ changeDashboard: async (payload: ChangeOrganisationDashboardDTO): Promise<OrganisationDetails> => {
14
+ const response = await ServiceFactory.http.put(ORGANISATION_DASHBOARD_URL, payload);
15
+ const result = new OrganisationDetails(response.data);
16
+
17
+ notifyService.notify("update", result);
18
+
19
+ return result;
20
+ }
21
+ }))
22
+ ));
23
+
24
+ export const useOrganisation = ComposableFactory.get(OrganisationServiceFactory);
25
+ export const useOrganisations = ComposableFactory.getMany(OrganisationServiceFactory);
26
+ export const useUpdateOrganisation = ComposableFactory.update(OrganisationServiceFactory);
27
+ export const useChangeDashboardOrganisation = () => {
28
+ const service = OrganisationServiceFactory();
29
+
30
+ const changing = ref(false);
31
+ const changed = ref<OrganisationDetails | null>(null) as Ref<OrganisationDetails | null>;
32
+
33
+ const change = async (payload: ChangeOrganisationDashboardDTO) => {
34
+ changing.value = true;
35
+ try {
36
+ changed.value = await service.changeDashboard(payload);
37
+ }
38
+ finally {
39
+ changing.value = false;
40
+ }
41
+
42
+ const subscriberId = service.subscribe("all", onEntityChanged(changed))
43
+ onUnmounted(() => service.unsubscribe(subscriberId));
44
+
45
+ return readonly(changed as Ref<OrganisationDetails>);
46
+ }
47
+
48
+ return {
49
+ changing: readonly(changing),
50
+ change,
51
+ changed: readonly(changed)
52
+ }
53
+ }
@@ -0,0 +1,11 @@
1
+ import { PermissionCategoryDetails, PermissionCategoryDetailsDTO, PermissionCategoryFilters, PermissionCategoryInfos, PermissionCategoryInfosDTO } from "@dative-gpi/foundation-core-domain";
2
+ import { ComposableFactory, ServiceFactory } from "@dative-gpi/bones-ui";
3
+
4
+ import { PERMISSION_CATEGORIES_URL } from "../../config/urls";
5
+
6
+ const PermissionCategoryServiceFactory = new ServiceFactory<PermissionCategoryDetailsDTO, PermissionCategoryDetails>("permissionCategory", PermissionCategoryDetails).create(factory => factory.build(
7
+ factory.addGetMany<PermissionCategoryInfosDTO, PermissionCategoryInfos, PermissionCategoryFilters>(PERMISSION_CATEGORIES_URL, PermissionCategoryInfos),
8
+ factory.addNotify()
9
+ ));
10
+
11
+ export const usePermissionCategories = ComposableFactory.getMany(PermissionCategoryServiceFactory);
@@ -0,0 +1,42 @@
1
+ import { Ref, readonly, ref } from "vue";
2
+
3
+ import { PermissionDetails, PermissionDetailsDTO, PermissionInfos, PermissionInfosDTO } from "@dative-gpi/foundation-core-domain";
4
+ import { ServiceFactory } from "@dative-gpi/bones-ui";
5
+
6
+ import { PERMISSIONS_CURRENT_URL } from "../../config/urls";
7
+
8
+ const PermissionServiceFactory = new ServiceFactory<PermissionDetailsDTO, PermissionDetails>("permission", PermissionDetails).create(factory => factory.build(
9
+ factory.addNotify(() => ({
10
+ getCurrent: async (): Promise<PermissionInfos[]> => {
11
+ const response = await ServiceFactory.http.get(PERMISSIONS_CURRENT_URL);
12
+ const result = response.data.map((dto: PermissionInfos) => new PermissionInfos(dto));
13
+
14
+ return result;
15
+ }
16
+ }))
17
+ ));
18
+
19
+ export const useCurrentPermissions = () => {
20
+ const service = PermissionServiceFactory();
21
+
22
+ const fetching = ref(false);
23
+ const fetched = ref<PermissionInfos[] | null>(null) as Ref<PermissionInfos[] | null>;
24
+
25
+ const fetch = async () => {
26
+ fetching.value = true;
27
+ try {
28
+ fetched.value = await service.getCurrent();
29
+ }
30
+ finally {
31
+ fetching.value = false;
32
+ }
33
+
34
+ return readonly(fetched as Ref<PermissionInfos[]>);
35
+ }
36
+
37
+ return {
38
+ fetching: readonly(fetching),
39
+ fetch,
40
+ fetched: readonly(fetched)
41
+ }
42
+ }
@@ -0,0 +1,13 @@
1
+ import { RoleOrganisationTypeDetails, RoleOrganisationTypeDetailsDTO, RoleOrganisationTypeFilters, RoleOrganisationTypeInfos, RoleOrganisationTypeInfosDTO } from "@dative-gpi/foundation-core-domain";
2
+ import { ComposableFactory, ServiceFactory } from "@dative-gpi/bones-ui";
3
+
4
+ import { ROLE_ORGANISATION_TYPES_URL, ROLE_ORGANISATION_TYPE_URL } from "../../config/urls";
5
+
6
+ const RoleOrganisationTypeServiceFactory = new ServiceFactory<RoleOrganisationTypeDetailsDTO, RoleOrganisationTypeDetails>("roleOrganisationType", RoleOrganisationTypeDetails).create(factory => factory.build(
7
+ factory.addGet(ROLE_ORGANISATION_TYPE_URL),
8
+ factory.addGetMany<RoleOrganisationTypeInfosDTO, RoleOrganisationTypeInfos, RoleOrganisationTypeFilters>(ROLE_ORGANISATION_TYPES_URL, RoleOrganisationTypeInfos),
9
+ factory.addNotify()
10
+ ));
11
+
12
+ export const useRoleOrganisationType = ComposableFactory.get(RoleOrganisationTypeServiceFactory);
13
+ export const useRoleOrganisationTypes = ComposableFactory.getMany(RoleOrganisationTypeServiceFactory);
@@ -0,0 +1,13 @@
1
+ import { CreateRoleOrganisationDTO, RoleOrganisationDetails, RoleOrganisationDetailsDTO, RoleOrganisationFilters, RoleOrganisationInfos, RoleOrganisationInfosDTO, UpdateRoleOrganisationDTO } from "@dative-gpi/foundation-core-domain";
2
+ import { ComposableFactory, ServiceFactory } from "@dative-gpi/bones-ui";
3
+
4
+ import { ROLE_ORGANISATIONS_URL, ROLE_ORGANISATION_URL } from "../../config/urls";
5
+
6
+ const RoleOrganisationServiceFactory = new ServiceFactory<RoleOrganisationDetailsDTO, RoleOrganisationDetails>("roleOrganisation", RoleOrganisationDetails)
7
+ .createComplete<RoleOrganisationInfos, RoleOrganisationInfosDTO, CreateRoleOrganisationDTO, UpdateRoleOrganisationDTO, RoleOrganisationFilters>(ROLE_ORGANISATIONS_URL, ROLE_ORGANISATION_URL, RoleOrganisationInfos);
8
+
9
+ export const useRoleOrganisation = ComposableFactory.get(RoleOrganisationServiceFactory);
10
+ export const useRoleOrganisations = ComposableFactory.getMany(RoleOrganisationServiceFactory);
11
+ export const useCreateRoleOrganisation = ComposableFactory.create(RoleOrganisationServiceFactory);
12
+ export const useUpdateRoleOrganisation = ComposableFactory.update(RoleOrganisationServiceFactory);
13
+ export const useRemoveRoleOrganisation = ComposableFactory.remove(RoleOrganisationServiceFactory);
@@ -0,0 +1,11 @@
1
+ import { TimeZoneFilters, TimeZoneInfos, TimeZoneInfosDTO } from "@dative-gpi/foundation-core-domain";
2
+ import { ComposableFactory, ServiceFactory } from "@dative-gpi/bones-ui";
3
+
4
+ import { TIME_ZONES_URL } from "../../config/urls";
5
+
6
+ const TimeZoneServiceFactory = new ServiceFactory<TimeZoneInfosDTO, TimeZoneInfos>("timeZone", TimeZoneInfos).create(factory => factory.build(
7
+ factory.addGetMany<TimeZoneInfosDTO, TimeZoneInfos, TimeZoneFilters>(TIME_ZONES_URL, TimeZoneInfos),
8
+ factory.addNotify()
9
+ ));
10
+
11
+ export const useTimeZones = ComposableFactory.getMany(TimeZoneServiceFactory);
@@ -0,0 +1,42 @@
1
+ import { Ref, readonly, ref } from "vue";
2
+
3
+ import { TranslationInfos, TranslationInfosDTO, TranslationDetails, TranslationDetailsDTO } from "@dative-gpi/foundation-core-domain";
4
+ import { ServiceFactory } from "@dative-gpi/bones-ui";
5
+
6
+ import { TRANSLATIONS_LANGUAGE_URL } from "../../config/urls";
7
+
8
+ const TranslationServiceFactory = new ServiceFactory<TranslationDetailsDTO, TranslationDetails>("translation", TranslationDetails).create(factory => factory.build(
9
+ factory.addNotify(() => ({
10
+ getMany: async (languageCode: string): Promise<TranslationInfos[]> => {
11
+ const response = await ServiceFactory.http.get(TRANSLATIONS_LANGUAGE_URL(languageCode));
12
+ const result = response.data.map((dto: TranslationInfosDTO) => new TranslationInfos(dto));
13
+
14
+ return result;
15
+ }
16
+ }))
17
+ ));
18
+
19
+ export const useTranslations = () => {
20
+ const service = TranslationServiceFactory();
21
+
22
+ const fetching = ref(false);
23
+ const fetched = ref<TranslationInfos[] | null>(null) as Ref<TranslationInfos[] | null>;
24
+
25
+ const fetch = async (languageCode: string) => {
26
+ fetching.value = true;
27
+ try {
28
+ fetched.value = await service.getMany(languageCode);
29
+ }
30
+ finally {
31
+ fetching.value = false;
32
+ }
33
+
34
+ return readonly(fetched as Ref<TranslationInfos[]>);
35
+ }
36
+
37
+ return {
38
+ fetching: readonly(fetching),
39
+ fetch,
40
+ fetched: readonly(fetched)
41
+ }
42
+ }
@@ -0,0 +1,92 @@
1
+ import { Ref, onUnmounted, readonly, ref } from "vue";
2
+
3
+ import { CreateUserOrganisationDTO, UpdateUserOrganisationDTO, UserOrganisationDetails, UserOrganisationDetailsDTO, UserOrganisationFilters, UserOrganisationInfos, UserOrganisationInfosDTO } from "@dative-gpi/foundation-core-domain";
4
+ import { ComposableFactory, onEntityChanged, ServiceFactory } from "@dative-gpi/bones-ui";
5
+
6
+ import { USER_ORGANISATIONS_URL, USER_ORGANISATION_CURRENT_URL, USER_ORGANISATION_URL } from "../../config/urls";
7
+
8
+ const UserOrganisationServiceFactory = new ServiceFactory<UserOrganisationDetailsDTO, UserOrganisationDetails>("userOrganisation", UserOrganisationDetails).create(factory => factory.build(
9
+ factory.addGet(USER_ORGANISATION_URL),
10
+ factory.addGetMany<UserOrganisationInfosDTO, UserOrganisationInfos, UserOrganisationFilters>(USER_ORGANISATIONS_URL, UserOrganisationInfos),
11
+ factory.addCreate<CreateUserOrganisationDTO>(USER_ORGANISATIONS_URL),
12
+ factory.addUpdate<UpdateUserOrganisationDTO>(USER_ORGANISATION_URL),
13
+ 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
+
21
+ 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
+ }
31
+ }))
32
+ ));
33
+
34
+ export const useUserOrganisation = ComposableFactory.get(UserOrganisationServiceFactory);
35
+ export const useUserOrganisations = ComposableFactory.getMany(UserOrganisationServiceFactory);
36
+ export const useCreateUserOrganisation = ComposableFactory.create(UserOrganisationServiceFactory);
37
+ export const useUpdateUserOrganisation = ComposableFactory.update(UserOrganisationServiceFactory);
38
+ export const useRemoveUserOrganisation = ComposableFactory.remove(UserOrganisationServiceFactory);
39
+ export const useCurrentUserOrganisation = () => {
40
+ const service = UserOrganisationServiceFactory();
41
+
42
+ const fetching = ref(false);
43
+ const fetched = ref<UserOrganisationDetails | null>(null) as Ref<UserOrganisationDetails | null>;
44
+
45
+ const fetch = async () => {
46
+ fetching.value = true;
47
+ try {
48
+ fetched.value = await service.getCurrent();
49
+ }
50
+ finally {
51
+ fetching.value = false;
52
+ }
53
+
54
+ const subscriberId = service.subscribe("all", onEntityChanged(fetched))
55
+ onUnmounted(() => service.unsubscribe(subscriberId));
56
+
57
+ return readonly(fetched as Ref<UserOrganisationDetails>);
58
+ }
59
+
60
+ return {
61
+ fetching: readonly(fetching),
62
+ fetch,
63
+ fetched: readonly(fetched)
64
+ }
65
+ }
66
+ export const useUpdateCurrentUserOrganisation = () => {
67
+ const service = UserOrganisationServiceFactory();
68
+
69
+ const updating = ref(false);
70
+ const updated = ref<UserOrganisationDetails | null>(null) as Ref<UserOrganisationDetails | null>;
71
+
72
+ const update = async (payload: UpdateUserOrganisationDTO) => {
73
+ updating.value = true;
74
+ try {
75
+ updated.value = await service.updateCurrent(payload);
76
+ }
77
+ finally {
78
+ updating.value = false;
79
+ }
80
+
81
+ const subscriberId = service.subscribe("all", onEntityChanged(updated))
82
+ onUnmounted(() => service.unsubscribe(subscriberId));
83
+
84
+ return readonly(updated as Ref<UserOrganisationDetails>);
85
+ }
86
+
87
+ return {
88
+ updating: readonly(updating),
89
+ update,
90
+ updated: readonly(updated)
91
+ }
92
+ }
@@ -0,0 +1,90 @@
1
+ import { Ref, onUnmounted, readonly, ref } from "vue";
2
+
3
+ import { UpdateUserDTO, UserDetails, UserDetailsDTO, UserFilters, UserInfos, UserInfosDTO } from "@dative-gpi/foundation-core-domain";
4
+ import { ComposableFactory, onEntityChanged, ServiceFactory } from "@dative-gpi/bones-ui";
5
+
6
+ import { USERS_URL, USER_CURRENT_URL, USER_URL } from "../../config/urls";
7
+
8
+ const UserServiceFactory = new ServiceFactory<UserDetailsDTO, UserDetails>("user", UserDetails).create(factory => factory.build(
9
+ factory.addGet(USER_URL),
10
+ factory.addGetMany<UserInfosDTO, UserInfos, UserFilters>(USERS_URL, UserInfos),
11
+ factory.addUpdate<UpdateUserDTO>(USER_URL),
12
+ factory.addRemove(USER_URL),
13
+ factory.addNotify((notifyService) => ({
14
+ getCurrent: async (): Promise<UserDetails> => {
15
+ const response = await ServiceFactory.http.get(USER_CURRENT_URL);
16
+ const result = new UserDetails(response.data);
17
+
18
+ notifyService.notify("update", result);
19
+
20
+ return result;
21
+ },
22
+ updateCurrent: async(payload: UpdateUserDTO): Promise<UserDetails> => {
23
+ const response = await ServiceFactory.http.post(USER_CURRENT_URL, payload);
24
+ const result = new UserDetails(response.data);
25
+
26
+ notifyService.notify("update", result);
27
+
28
+ return result;
29
+ }
30
+ }))
31
+ ));
32
+
33
+ export const useUser = ComposableFactory.get(UserServiceFactory);
34
+ export const useUsers = ComposableFactory.getMany(UserServiceFactory);
35
+ export const useUpdateUser = ComposableFactory.update(UserServiceFactory);
36
+ export const useRemoveUser = ComposableFactory.remove(UserServiceFactory);
37
+ export const useCurrentUser = () => {
38
+ const service = UserServiceFactory();
39
+
40
+ const fetching = ref(false);
41
+ const fetched = ref<UserDetails | null>(null) as Ref<UserDetails | null>;
42
+
43
+ const fetch = async () => {
44
+ fetching.value = true;
45
+ try {
46
+ fetched.value = await service.getCurrent();
47
+ }
48
+ finally {
49
+ fetching.value = false;
50
+ }
51
+
52
+ const subscriberId = service.subscribe("all", onEntityChanged(fetched))
53
+ onUnmounted(() => service.unsubscribe(subscriberId));
54
+
55
+ return readonly(fetched as Ref<UserDetails>);
56
+ }
57
+
58
+ return {
59
+ fetching: readonly(fetching),
60
+ fetch,
61
+ fetched: readonly(fetched)
62
+ }
63
+ }
64
+ export const useUpdateCurrentUser = () => {
65
+ const service = UserServiceFactory();
66
+
67
+ const updating = ref(false);
68
+ const updated = ref<UserDetails | null>(null) as Ref<UserDetails | null>;
69
+
70
+ const update = async (payload: UpdateUserDTO) => {
71
+ updating.value = true;
72
+ try {
73
+ updated.value = await service.updateCurrent(payload);
74
+ }
75
+ finally {
76
+ updating.value = false;
77
+ }
78
+
79
+ const subscriberId = service.subscribe("all", onEntityChanged(updated))
80
+ onUnmounted(() => service.unsubscribe(subscriberId));
81
+
82
+ return readonly(updated as Ref<UserDetails>);
83
+ }
84
+
85
+ return {
86
+ updating: readonly(updating),
87
+ update,
88
+ updated: readonly(updated)
89
+ }
90
+ }