@dative-gpi/foundation-core-services 0.0.8 → 0.0.10

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 (58) hide show
  1. package/composables/index.ts +1 -1
  2. package/composables/services/index.ts +2 -3
  3. package/composables/services/useActions.ts +11 -0
  4. package/composables/services/useAlerts.ts +7 -4
  5. package/composables/services/useAuthTokens.ts +1 -3
  6. package/composables/services/useComments.ts +13 -0
  7. package/composables/services/useDeviceOrganisations.ts +14 -8
  8. package/composables/services/useGroups.ts +7 -4
  9. package/composables/services/useLanguages.ts +1 -1
  10. package/composables/services/useOrganisations.ts +12 -14
  11. package/composables/services/usePermissions.ts +2 -2
  12. package/composables/services/useTables.ts +14 -0
  13. package/composables/services/useUserOrganisations.ts +16 -10
  14. package/composables/services/useUsers.ts +5 -80
  15. package/composables/useCore.ts +28 -0
  16. package/composables/useOrganisationId.ts +5 -23
  17. package/config/urls/actions.ts +3 -0
  18. package/config/urls/alerts.ts +3 -3
  19. package/config/urls/articles.ts +3 -3
  20. package/config/urls/authTokens.ts +3 -3
  21. package/config/urls/base.ts +2 -3
  22. package/config/urls/comments.ts +4 -0
  23. package/config/urls/connectivityAlerts.ts +3 -3
  24. package/config/urls/customProperties.ts +1 -1
  25. package/config/urls/customPropertyValues.ts +1 -1
  26. package/config/urls/dataCategories.ts +2 -2
  27. package/config/urls/dataDefinitions.ts +2 -2
  28. package/config/urls/deviceConnectivities.ts +1 -1
  29. package/config/urls/deviceOrganisations.ts +2 -2
  30. package/config/urls/deviceStatuses.ts +1 -1
  31. package/config/urls/groups.ts +2 -2
  32. package/config/urls/images.ts +3 -3
  33. package/config/urls/index.ts +3 -4
  34. package/config/urls/languages.ts +2 -2
  35. package/config/urls/locations.ts +2 -2
  36. package/config/urls/manufacturers.ts +2 -2
  37. package/config/urls/models.ts +2 -2
  38. package/config/urls/organisationTypes.ts +2 -2
  39. package/config/urls/organisations.ts +2 -6
  40. package/config/urls/permissionCategories.ts +1 -1
  41. package/config/urls/permissions.ts +1 -1
  42. package/config/urls/roleOrganisationTypes.ts +2 -2
  43. package/config/urls/roleOrganisations.ts +2 -2
  44. package/config/urls/tables.ts +4 -0
  45. package/config/urls/urlFactory.ts +2 -7
  46. package/config/urls/userOrganisations.ts +3 -3
  47. package/config/urls/users.ts +3 -3
  48. package/package.json +4 -4
  49. package/composables/services/useApplications.ts +0 -47
  50. package/composables/services/useFamilies.ts +0 -13
  51. package/composables/services/useTimeZones.ts +0 -11
  52. package/composables/services/useTranslations.ts +0 -42
  53. package/composables/useLanguageCode.ts +0 -48
  54. package/config/urls/applications.ts +0 -4
  55. package/config/urls/families.ts +0 -4
  56. package/config/urls/files.ts +0 -4
  57. package/config/urls/timeZones.ts +0 -3
  58. package/config/urls/translations.ts +0 -4
@@ -1,4 +1,4 @@
1
1
  export * from "./hubs";
2
2
  export * from "./services";
3
- export * from "./useLanguageCode";
3
+ export * from "./useCore";
4
4
  export * from "./useOrganisationId";
@@ -1,3 +1,4 @@
1
+ export * from "./useActions";
1
2
  export * from "./useAlerts";
2
3
  export * from "./useArticles";
3
4
  export * from "./useAuthTokens";
@@ -9,7 +10,6 @@ export * from "./useDataDefinitions";
9
10
  export * from "./useDeviceConnectivities";
10
11
  export * from "./useDeviceOrganisations";
11
12
  export * from "./useDeviceStatuses";
12
- export * from "./useFamilies";
13
13
  export * from "./useGroups";
14
14
  export * from "./useLanguages";
15
15
  export * from "./useLocations";
@@ -21,7 +21,6 @@ export * from "./usePermissionCategories";
21
21
  export * from "./usePermissions";
22
22
  export * from "./useRoleOrganisations";
23
23
  export * from "./useRoleOrganisationTypes";
24
- export * from "./useTimeZones";
25
- export * from "./useTranslations";
24
+ export * from "./useTables";
26
25
  export * from "./useUserOrganisations";
27
26
  export * from "./useUsers";
@@ -0,0 +1,11 @@
1
+ import { ActionDetails, ActionDetailsDTO, ActionInfos, ActionInfosDTO } from "@dative-gpi/foundation-core-domain";
2
+ import { ComposableFactory, ServiceFactory } from "@dative-gpi/bones-ui";
3
+
4
+ import { ACTIONS_URL } from "../../config/urls";
5
+
6
+ const ActionServiceFactory = new ServiceFactory<ActionDetailsDTO, ActionDetails>("action", ActionDetails).create(factory => factory.build(
7
+ factory.addGetMany<ActionInfosDTO, ActionInfos, string>(ACTIONS_URL, ActionInfos),
8
+ factory.addNotify()
9
+ ));
10
+
11
+ export const useActions = ComposableFactory.getMany(ActionServiceFactory);
@@ -37,10 +37,16 @@ export const useAlerts = ComposableFactory.getMany(AlertServiceFactory);
37
37
  export const useRemoveAlert = ComposableFactory.remove(AlertServiceFactory);
38
38
  export const useAcknowledgeAlert = () => {
39
39
  const service = AlertServiceFactory();
40
+ const subscribersIds : number[] = [];
40
41
 
41
42
  const changing = ref(false);
42
43
  const changed = ref<AlertDetails | null>(null) as Ref<AlertDetails | null>;
43
44
 
45
+ onUnmounted(() => {
46
+ subscribersIds.forEach(id => service.unsubscribe(id));
47
+ subscribersIds.length = 0;
48
+ });
49
+
44
50
  const change = async (alertId: string) => {
45
51
  changing.value = true;
46
52
  try {
@@ -49,10 +55,7 @@ export const useAcknowledgeAlert = () => {
49
55
  finally {
50
56
  changing.value = false;
51
57
  }
52
-
53
- const subscriberId = service.subscribe("all", onEntityChanged(changed))
54
- onUnmounted(() => service.unsubscribe(subscriberId));
55
-
58
+ subscribersIds.push(service.subscribe("all", onEntityChanged(changed)));
56
59
  return readonly(changed as Ref<AlertDetails>);
57
60
  }
58
61
 
@@ -1,15 +1,13 @@
1
- import { AuthTokenDetails, AuthTokenDetailsDTO, AuthTokenFilters, AuthTokenInfos, AuthTokenInfosDTO, CreateAuthTokenDTO } from "@dative-gpi/foundation-core-domain";
1
+ import { AuthTokenDetails, AuthTokenDetailsDTO, AuthTokenFilters, AuthTokenInfos, AuthTokenInfosDTO } from "@dative-gpi/foundation-core-domain";
2
2
  import { ComposableFactory, ServiceFactory } from "@dative-gpi/bones-ui";
3
3
 
4
4
  import { AUTH_TOKENS_URL, AUTH_TOKEN_URL } from "../../config/urls";
5
5
 
6
6
  const AuthTokenServiceFactory = new ServiceFactory<AuthTokenDetailsDTO, AuthTokenDetails>("authToken", AuthTokenDetails).create(factory => factory.build(
7
7
  factory.addGetMany<AuthTokenInfosDTO, AuthTokenInfos, AuthTokenFilters>(AUTH_TOKENS_URL, AuthTokenInfos),
8
- factory.addCreate<CreateAuthTokenDTO>(AUTH_TOKENS_URL),
9
8
  factory.addRemove(AUTH_TOKEN_URL),
10
9
  factory.addNotify()
11
10
  ));
12
11
 
13
12
  export const useAuthTokens = ComposableFactory.getMany(AuthTokenServiceFactory);
14
- export const useCreateAuthToken = ComposableFactory.create(AuthTokenServiceFactory);
15
13
  export const useRemoveAuthToken = ComposableFactory.remove(AuthTokenServiceFactory);
@@ -0,0 +1,13 @@
1
+ import { CreateCommentDTO, CommentDetails, CommentDetailsDTO, CommentFilters, CommentInfos, CommentInfosDTO, UpdateCommentDTO } from "@dative-gpi/foundation-core-domain";
2
+ import { ComposableFactory, ServiceFactory } from "@dative-gpi/bones-ui";
3
+
4
+ import { COMMENTS_URL, COMMENT_URL } from "../../config/urls";
5
+
6
+ const CommentServiceFactory = new ServiceFactory<CommentDetailsDTO, CommentDetails>("comment", CommentDetails)
7
+ .createComplete<CommentInfos, CommentInfosDTO, CreateCommentDTO, UpdateCommentDTO, CommentFilters>(COMMENTS_URL, COMMENT_URL, CommentInfos);
8
+
9
+ export const useComment = ComposableFactory.get(CommentServiceFactory);
10
+ export const useComments = ComposableFactory.getMany(CommentServiceFactory);
11
+ export const useCreateComment = ComposableFactory.create(CommentServiceFactory);
12
+ export const useUpdateComment = ComposableFactory.update(CommentServiceFactory);
13
+ export const useRemoveComment = ComposableFactory.remove(CommentServiceFactory);
@@ -38,10 +38,16 @@ export const useUpdateDeviceOrganisation = ComposableFactory.update(DeviceOrgani
38
38
  export const useRemoveDeviceOrganisation = ComposableFactory.remove(DeviceOrganisationServiceFactory);
39
39
  export const useChangeDeviceOrganisationGroup = () => {
40
40
  const service = DeviceOrganisationServiceFactory();
41
+ const subscriberIds: number[] = [];
41
42
 
42
43
  const changing = ref(false);
43
44
  const changed = ref<DeviceOrganisationDetails | null>(null) as Ref<DeviceOrganisationDetails | null>;
44
45
 
46
+ onUnmounted(() => {
47
+ subscriberIds.forEach(id => service.unsubscribe(id));
48
+ subscriberIds.length = 0;
49
+ });
50
+
45
51
  const change = async (deviceOrganisationId: string, payload: ChangeDeviceOrganisationGroupDTO) => {
46
52
  changing.value = true;
47
53
  try {
@@ -50,10 +56,7 @@ export const useChangeDeviceOrganisationGroup = () => {
50
56
  finally {
51
57
  changing.value = false;
52
58
  }
53
-
54
- const subscriberId = service.subscribe("all", onEntityChanged(changed))
55
- onUnmounted(() => service.unsubscribe(subscriberId));
56
-
59
+ subscriberIds.push(service.subscribe("all", onEntityChanged(changed)));
57
60
  return readonly(changed as Ref<DeviceOrganisationDetails>);
58
61
  }
59
62
 
@@ -65,10 +68,16 @@ export const useChangeDeviceOrganisationGroup = () => {
65
68
  }
66
69
  export const useChangeDeviceOrganisationLocation = () => {
67
70
  const service = DeviceOrganisationServiceFactory();
71
+ const subscriberIds: number[] = [];
68
72
 
69
73
  const changing = ref(false);
70
74
  const changed = ref<DeviceOrganisationDetails | null>(null) as Ref<DeviceOrganisationDetails | null>;
71
75
 
76
+ onUnmounted(() => {
77
+ subscriberIds.forEach(id => service.unsubscribe(id));
78
+ subscriberIds.length = 0;
79
+ });
80
+
72
81
  const change = async (deviceOrganisationId: string, payload: ChangeDeviceOrganisationLocationDTO) => {
73
82
  changing.value = true;
74
83
  try {
@@ -77,10 +86,7 @@ export const useChangeDeviceOrganisationLocation = () => {
77
86
  finally {
78
87
  changing.value = false;
79
88
  }
80
-
81
- const subscriberId = service.subscribe("all", onEntityChanged(changed))
82
- onUnmounted(() => service.unsubscribe(subscriberId));
83
-
89
+ subscriberIds.push(service.subscribe("all", onEntityChanged(changed)));
84
90
  return readonly(changed as Ref<DeviceOrganisationDetails>);
85
91
  }
86
92
 
@@ -30,10 +30,16 @@ export const useUpdateGroup = ComposableFactory.update(GroupServiceFactory);
30
30
  export const useRemoveGroup = ComposableFactory.remove(GroupServiceFactory);
31
31
  export const useChangeGroupParent = () => {
32
32
  const service = GroupServiceFactory();
33
+ const subscriberIds: number[] = [];
33
34
 
34
35
  const changing = ref(false);
35
36
  const changed = ref<GroupDetails | null>(null) as Ref<GroupDetails | null>;
36
37
 
38
+ onUnmounted(() => {
39
+ subscriberIds.forEach(id => service.unsubscribe(id));
40
+ subscriberIds.length = 0;
41
+ });
42
+
37
43
  const change = async (groupId: string, payload: ChangeGroupParentDTO) => {
38
44
  changing.value = true;
39
45
  try {
@@ -42,10 +48,7 @@ export const useChangeGroupParent = () => {
42
48
  finally {
43
49
  changing.value = false;
44
50
  }
45
-
46
- const subscriberId = service.subscribe("all", onEntityChanged(changed))
47
- onUnmounted(() => service.unsubscribe(subscriberId));
48
-
51
+ subscriberIds.push(service.subscribe("all", onEntityChanged(changed)));
49
52
  return readonly(changed as Ref<GroupDetails>);
50
53
  }
51
54
 
@@ -1,4 +1,4 @@
1
- import { LanguageDetails, LanguageDetailsDTO, LanguageFilters, LanguageInfos, LanguageInfosDTO } from "@dative-gpi/foundation-core-domain";
1
+ import { LanguageDetails, LanguageDetailsDTO, LanguageFilters, LanguageInfos, LanguageInfosDTO } from "@dative-gpi/foundation-shared-domain";
2
2
  import { ComposableFactory, ServiceFactory } from "@dative-gpi/bones-ui";
3
3
 
4
4
  import { LANGUAGES_URL, LANGUAGE_URL } from "../../config/urls";
@@ -1,17 +1,15 @@
1
1
  import { Ref, onUnmounted, readonly, ref } from "vue";
2
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";
3
+ import { OrganisationDetails, OrganisationDetailsDTO } from "@dative-gpi/foundation-shared-domain";
4
+ import { ChangeOrganisationDashboardDTO } from "@dative-gpi/foundation-core-domain";
5
+ import { onEntityChanged , ServiceFactory } from "@dative-gpi/bones-ui";
5
6
 
6
- import { ORGANISATION_DASHBOARD_URL, ORGANISATIONS_URL, ORGANISATION_URL } from "../../config/urls";
7
+ import { ORGANISATION_DASHBOARD_URL } from "../../config/urls";
7
8
 
8
9
  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
10
  factory.addNotify((notifyService) => ({
13
11
  changeDashboard: async (payload: ChangeOrganisationDashboardDTO): Promise<OrganisationDetails> => {
14
- const response = await ServiceFactory.http.put(ORGANISATION_DASHBOARD_URL, payload);
12
+ const response = await ServiceFactory.http.put(ORGANISATION_DASHBOARD_URL(), payload);
15
13
  const result = new OrganisationDetails(response.data);
16
14
 
17
15
  notifyService.notify("update", result);
@@ -21,15 +19,18 @@ const OrganisationServiceFactory = new ServiceFactory<OrganisationDetailsDTO, Or
21
19
  }))
22
20
  ));
23
21
 
24
- export const useOrganisation = ComposableFactory.get(OrganisationServiceFactory);
25
- export const useOrganisations = ComposableFactory.getMany(OrganisationServiceFactory);
26
- export const useUpdateOrganisation = ComposableFactory.update(OrganisationServiceFactory);
27
22
  export const useChangeDashboardOrganisation = () => {
28
23
  const service = OrganisationServiceFactory();
24
+ const subscribersIds: number[] = [];
29
25
 
30
26
  const changing = ref(false);
31
27
  const changed = ref<OrganisationDetails | null>(null) as Ref<OrganisationDetails | null>;
32
28
 
29
+ onUnmounted(() => {
30
+ subscribersIds.forEach(id => service.unsubscribe(id));
31
+ subscribersIds.length = 0;
32
+ });
33
+
33
34
  const change = async (payload: ChangeOrganisationDashboardDTO) => {
34
35
  changing.value = true;
35
36
  try {
@@ -38,10 +39,7 @@ export const useChangeDashboardOrganisation = () => {
38
39
  finally {
39
40
  changing.value = false;
40
41
  }
41
-
42
- const subscriberId = service.subscribe("all", onEntityChanged(changed))
43
- onUnmounted(() => service.unsubscribe(subscriberId));
44
-
42
+ subscribersIds.push(service.subscribe("all", onEntityChanged(changed)));
45
43
  return readonly(changed as Ref<OrganisationDetails>);
46
44
  }
47
45
 
@@ -1,6 +1,6 @@
1
1
  import { Ref, readonly, ref } from "vue";
2
2
 
3
- import { PermissionDetails, PermissionDetailsDTO, PermissionInfos, PermissionInfosDTO } from "@dative-gpi/foundation-core-domain";
3
+ import { PermissionDetails, PermissionDetailsDTO, PermissionInfos } from "@dative-gpi/foundation-shared-domain";
4
4
  import { ServiceFactory } from "@dative-gpi/bones-ui";
5
5
 
6
6
  import { PERMISSIONS_CURRENT_URL } from "../../config/urls";
@@ -8,7 +8,7 @@ import { PERMISSIONS_CURRENT_URL } from "../../config/urls";
8
8
  const PermissionServiceFactory = new ServiceFactory<PermissionDetailsDTO, PermissionDetails>("permission", PermissionDetails).create(factory => factory.build(
9
9
  factory.addNotify(() => ({
10
10
  getCurrent: async (): Promise<PermissionInfos[]> => {
11
- const response = await ServiceFactory.http.get(PERMISSIONS_CURRENT_URL);
11
+ const response = await ServiceFactory.http.get(PERMISSIONS_CURRENT_URL());
12
12
  const result = response.data.map((dto: PermissionInfos) => new PermissionInfos(dto));
13
13
 
14
14
  return result;
@@ -0,0 +1,14 @@
1
+ import { TableDetails, TableDetailsDTO, UpdateTableDTO } from "@dative-gpi/foundation-core-domain";
2
+ import { ComposableFactory, ServiceFactory } from "@dative-gpi/bones-ui";
3
+
4
+ import { TABLE_URL } from "../../config/urls";
5
+
6
+ const TableServiceFactory = new ServiceFactory<TableDetailsDTO, TableDetails>("table", TableDetails).create(factory => factory.build(
7
+ factory.addGet(TABLE_URL),
8
+ factory.addUpdate<UpdateTableDTO>(TABLE_URL),
9
+ factory.addNotify()
10
+ ));
11
+
12
+
13
+ export const useTable = ComposableFactory.get(TableServiceFactory);
14
+ export const useUpdateTable = ComposableFactory.update(TableServiceFactory);
@@ -13,7 +13,7 @@ const UserOrganisationServiceFactory = new ServiceFactory<UserOrganisationDetail
13
13
  factory.addRemove(USER_ORGANISATION_URL),
14
14
  factory.addNotify((notifyService) => ({
15
15
  getCurrent: async (): Promise<UserOrganisationDetails> => {
16
- const response = await ServiceFactory.http.get(USER_ORGANISATION_CURRENT_URL);
16
+ const response = await ServiceFactory.http.get(USER_ORGANISATION_CURRENT_URL());
17
17
  const result = new UserOrganisationDetails(response.data);
18
18
 
19
19
  notifyService.notify("update", result);
@@ -21,7 +21,7 @@ const UserOrganisationServiceFactory = new ServiceFactory<UserOrganisationDetail
21
21
  return result;
22
22
  },
23
23
  updateCurrent: async(payload: UpdateUserOrganisationDTO): Promise<UserOrganisationDetails> => {
24
- const response = await ServiceFactory.http.post(USER_ORGANISATION_CURRENT_URL, payload);
24
+ const response = await ServiceFactory.http.post(USER_ORGANISATION_CURRENT_URL(), payload);
25
25
  const result = new UserOrganisationDetails(response.data);
26
26
 
27
27
  notifyService.notify("update", result);
@@ -38,10 +38,16 @@ export const useUpdateUserOrganisation = ComposableFactory.update(UserOrganisati
38
38
  export const useRemoveUserOrganisation = ComposableFactory.remove(UserOrganisationServiceFactory);
39
39
  export const useCurrentUserOrganisation = () => {
40
40
  const service = UserOrganisationServiceFactory();
41
+ const subscribersIds: number[] = [];
41
42
 
42
43
  const fetching = ref(false);
43
44
  const fetched = ref<UserOrganisationDetails | null>(null) as Ref<UserOrganisationDetails | null>;
44
45
 
46
+ onUnmounted(() => {
47
+ subscribersIds.forEach(id => service.unsubscribe(id));
48
+ subscribersIds.length = 0;
49
+ });
50
+
45
51
  const fetch = async () => {
46
52
  fetching.value = true;
47
53
  try {
@@ -50,10 +56,7 @@ export const useCurrentUserOrganisation = () => {
50
56
  finally {
51
57
  fetching.value = false;
52
58
  }
53
-
54
- const subscriberId = service.subscribe("all", onEntityChanged(fetched))
55
- onUnmounted(() => service.unsubscribe(subscriberId));
56
-
59
+ subscribersIds.push(service.subscribe("all", onEntityChanged(fetched)));
57
60
  return readonly(fetched as Ref<UserOrganisationDetails>);
58
61
  }
59
62
 
@@ -65,10 +68,16 @@ export const useCurrentUserOrganisation = () => {
65
68
  }
66
69
  export const useUpdateCurrentUserOrganisation = () => {
67
70
  const service = UserOrganisationServiceFactory();
71
+ const subscribersIds: number[] = [];
68
72
 
69
73
  const updating = ref(false);
70
74
  const updated = ref<UserOrganisationDetails | null>(null) as Ref<UserOrganisationDetails | null>;
71
75
 
76
+ onUnmounted(() => {
77
+ subscribersIds.forEach(id => service.unsubscribe(id));
78
+ subscribersIds.length = 0;
79
+ });
80
+
72
81
  const update = async (payload: UpdateUserOrganisationDTO) => {
73
82
  updating.value = true;
74
83
  try {
@@ -77,10 +86,7 @@ export const useUpdateCurrentUserOrganisation = () => {
77
86
  finally {
78
87
  updating.value = false;
79
88
  }
80
-
81
- const subscriberId = service.subscribe("all", onEntityChanged(updated))
82
- onUnmounted(() => service.unsubscribe(subscriberId));
83
-
89
+ subscribersIds.push(service.subscribe("all", onEntityChanged(updated)));
84
90
  return readonly(updated as Ref<UserOrganisationDetails>);
85
91
  }
86
92
 
@@ -1,90 +1,15 @@
1
- import { Ref, onUnmounted, readonly, ref } from "vue";
1
+ import { UpdateUserDTO, UserDetails, UserDetailsDTO } from "@dative-gpi/foundation-shared-domain";
2
+ import { ComposableFactory, ServiceFactory } from "@dative-gpi/bones-ui";
2
3
 
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";
4
+ import { USER_URL } from "../../config/urls";
7
5
 
8
6
  const UserServiceFactory = new ServiceFactory<UserDetailsDTO, UserDetails>("user", UserDetails).create(factory => factory.build(
9
7
  factory.addGet(USER_URL),
10
- factory.addGetMany<UserInfosDTO, UserInfos, UserFilters>(USERS_URL, UserInfos),
11
8
  factory.addUpdate<UpdateUserDTO>(USER_URL),
12
9
  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
- }))
10
+ factory.addNotify()
31
11
  ));
32
12
 
33
13
  export const useUser = ComposableFactory.get(UserServiceFactory);
34
- export const useUsers = ComposableFactory.getMany(UserServiceFactory);
35
14
  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
- }
15
+ export const useRemoveUser = ComposableFactory.remove(UserServiceFactory);
@@ -0,0 +1,28 @@
1
+ import { onMounted, ref } from "vue";
2
+
3
+ import { useOrganisationId } from "@dative-gpi/foundation-core-services/composables";
4
+
5
+ let called = false;
6
+
7
+ const ready = ref(false);
8
+
9
+ export function useCore() {
10
+ if (called) {
11
+ return {
12
+ ready
13
+ };
14
+ }
15
+
16
+ called = true;
17
+
18
+ const { ready: organisationIdReady } = useOrganisationId();
19
+
20
+ onMounted(async () => {
21
+ await organisationIdReady
22
+ ready.value = true;
23
+ });
24
+
25
+ return {
26
+ ready
27
+ };
28
+ }
@@ -1,32 +1,13 @@
1
- import { onMounted, provide, ref, watch } from "vue";
2
- import { useRouter } from "vue-router";
3
-
4
- import { setOrganisationId } from "../config/urls/urlFactory";
5
- import { ORGANISATION_ID } from "../config/literals";
1
+ import { ref, watch } from "vue";
6
2
 
7
3
  let initialized = false;
8
4
 
9
5
  const organisationId = ref<string | null>(null);
10
6
 
11
7
  export const useOrganisationId = () => {
12
- if (!initialized) {
13
- provide(ORGANISATION_ID, organisationId);
14
-
15
- const router = useRouter();
16
-
17
- watch(router.currentRoute, () => {
18
- organisationId.value = router.currentRoute.value.params[ORGANISATION_ID] as string | null;
19
- setOrganisationId(organisationId);
20
- });
21
-
22
- onMounted(() => {
23
- if (organisationId.value) {
24
- return;
25
- }
26
- organisationId.value = router.currentRoute.value.params[ORGANISATION_ID] as string | null;
27
- setOrganisationId(organisationId);
28
- });
29
- }
8
+ const setOrganisationId = (payload: string) => {
9
+ organisationId.value = payload;
10
+ };
30
11
 
31
12
  initialized = true;
32
13
 
@@ -46,5 +27,6 @@ export const useOrganisationId = () => {
46
27
  return {
47
28
  ready,
48
29
  organisationId,
30
+ setOrganisationId
49
31
  };
50
32
  }
@@ -0,0 +1,3 @@
1
+ import { CORE_URL } from "./base";
2
+
3
+ export const ACTIONS_URL = () => `${CORE_URL()}/actions`;
@@ -1,6 +1,6 @@
1
1
  import { CORE_URL, HUBS_URL } from "./base";
2
2
 
3
- export const ALERTS_URL = `${CORE_URL}/alerts`;
4
- export const ALERT_URL = (alertId: string) => `${ALERTS_URL}/${encodeURIComponent(alertId)}`;
3
+ export const ALERTS_URL = () => `${CORE_URL()}/alerts`;
4
+ export const ALERT_URL = (alertId: string) => `${ALERTS_URL()}/${encodeURIComponent(alertId)}`;
5
5
 
6
- export const ALERTS_HUB_URL = `${HUBS_URL}/alerts`;
6
+ export const ALERTS_HUB_URL = () => `${HUBS_URL()}/alerts`;
@@ -1,4 +1,4 @@
1
- import { ORGANISATION_URL } from "./organisations";
1
+ import { CORE_URL } from "./base";
2
2
 
3
- export const ARTICLES_URL = `${ORGANISATION_URL}/articles`;
4
- export const ARTICLE_URL = (articleId: string) => `${ARTICLES_URL}/${encodeURIComponent(articleId)}`;
3
+ export const ARTICLES_URL = () => `${CORE_URL()}/articles`;
4
+ export const ARTICLE_URL = (articleId: string) => `${ARTICLES_URL()}/${encodeURIComponent(articleId)}`;
@@ -1,4 +1,4 @@
1
- import { ORGANISATION_URL } from "./organisations";
1
+ import { CORE_URL } from "./base";
2
2
 
3
- export const AUTH_TOKENS_URL = `${ORGANISATION_URL}/pats`;
4
- export const AUTH_TOKEN_URL = (authTokenId: string) => `${AUTH_TOKENS_URL}/${encodeURIComponent(authTokenId)}`;
3
+ export const AUTH_TOKENS_URL = () => `${CORE_URL()}/pats`;
4
+ export const AUTH_TOKEN_URL = (authTokenId: string) => `${AUTH_TOKENS_URL()}/${encodeURIComponent(authTokenId)}`;
@@ -1,5 +1,4 @@
1
1
  import { urlFactory } from "./urlFactory";
2
2
 
3
- export const GATEWAY_URL = "/api/foundation/shared/v1";
4
- export const CORE_URL = urlFactory(organisationId => `/api/foundation/core/v1/organisations/${encodeURIComponent(organisationId)}`);
5
- export const HUBS_URL = urlFactory(organisationId => `/api/foundation/hubs/v1/organisations/${encodeURIComponent(organisationId)}`);
3
+ export const CORE_URL = urlFactory(organisationId => `/api/core/v1/organisations/${encodeURIComponent(organisationId)}`);
4
+ export const HUBS_URL = urlFactory(organisationId => `/api/hubs/v1/organisations/${encodeURIComponent(organisationId)}`);
@@ -0,0 +1,4 @@
1
+ import { CORE_URL } from "./base";
2
+
3
+ export const COMMENTS_URL = () => `${CORE_URL()}/comments`;
4
+ export const COMMENT_URL = (commentId: string) => `${COMMENTS_URL()}/${encodeURIComponent(commentId)}`;
@@ -1,6 +1,6 @@
1
1
  import { CORE_URL, HUBS_URL } from "./base";
2
2
 
3
- export const CONNECTIVITY_ALERTS_URL = `${CORE_URL}/connectivity-alerts`;
4
- export const CONNECTIVITY_ALERT_URL = (connectivityAlertId: string) => `${CONNECTIVITY_ALERTS_URL}/${encodeURIComponent(connectivityAlertId)}`;
3
+ export const CONNECTIVITY_ALERTS_URL = () => `${CORE_URL()}/connectivity-alerts`;
4
+ export const CONNECTIVITY_ALERT_URL = (connectivityAlertId: string) => `${CONNECTIVITY_ALERTS_URL()}/${encodeURIComponent(connectivityAlertId)}`;
5
5
 
6
- export const CONNECTIVITY_ALERTS_HUB_URL = `${HUBS_URL}/connectivity-alerts`;
6
+ export const CONNECTIVITY_ALERTS_HUB_URL = () => `${HUBS_URL()}/connectivity-alerts`;
@@ -1,3 +1,3 @@
1
1
  import { CORE_URL } from "./base";
2
2
 
3
- export const CUSTOM_PROPERTIES_URL = `${CORE_URL}/custom-properties`;
3
+ export const CUSTOM_PROPERTIES_URL = () => `${CORE_URL()}/custom-properties`;
@@ -2,4 +2,4 @@ import { PropertyEntity } from "@dative-gpi/foundation-core-domain";
2
2
 
3
3
  import { CORE_URL } from "./base";
4
4
 
5
- export const CUSTOM_PROPERTY_VALUES_URL = (entity: PropertyEntity, entityId: string, code: string) => `${CORE_URL}/custom-property-values/${encodeURIComponent(entity)}/${encodeURIComponent(entityId)}/${encodeURIComponent(code)}`;
5
+ export const CUSTOM_PROPERTY_VALUES_URL = (entity: PropertyEntity, entityId: string, code: string) => `${CORE_URL()}/custom-property-values/${encodeURIComponent(entity)}/${encodeURIComponent(entityId)}/${encodeURIComponent(code)}`;
@@ -1,4 +1,4 @@
1
1
  import { CORE_URL } from "./base";
2
2
 
3
- export const DATA_CATEGORIES_URL = `${CORE_URL}/data-categories`;
4
- export const DATA_CATEGORY_URL = (dataCategoryId: string) => `${DATA_CATEGORIES_URL}/${encodeURIComponent(dataCategoryId)}`;
3
+ export const DATA_CATEGORIES_URL = () => `${CORE_URL()}/data-categories`;
4
+ export const DATA_CATEGORY_URL = (dataCategoryId: string) => `${DATA_CATEGORIES_URL()}/${encodeURIComponent(dataCategoryId)}`;
@@ -1,4 +1,4 @@
1
1
  import { CORE_URL } from "./base";
2
2
 
3
- export const DATA_DEFINITIONS_URL = `${CORE_URL}/data-definitions`;
4
- export const DATA_DEFINITION_URL = (dataDefinitionId: string) => `${DATA_DEFINITIONS_URL}/${encodeURIComponent(dataDefinitionId)}`;
3
+ export const DATA_DEFINITIONS_URL = () => `${CORE_URL()}/data-definitions`;
4
+ export const DATA_DEFINITION_URL = (dataDefinitionId: string) => `${DATA_DEFINITIONS_URL()}/${encodeURIComponent(dataDefinitionId)}`;
@@ -3,4 +3,4 @@ import { HUBS_URL } from "./base";
3
3
 
4
4
  export const DEVICE_CONNECTIVITY_URL = (deviceOrganisationId: string) => `${DEVICE_ORGANISATION_URL(deviceOrganisationId)}/connectivity`;
5
5
 
6
- export const DEVICE_CONNECTIVITIES_HUB_URL = `${HUBS_URL}/connectivities`;
6
+ export const DEVICE_CONNECTIVITIES_HUB_URL = () => `${HUBS_URL()}/connectivities`;
@@ -1,6 +1,6 @@
1
1
  import { CORE_URL } from "./base";
2
2
 
3
- export const DEVICE_ORGANISATIONS_URL = `${CORE_URL}/device-organisations`;
4
- export const DEVICE_ORGANISATION_URL = (deviceOrganisationId: string) => `${DEVICE_ORGANISATIONS_URL}/${encodeURIComponent(deviceOrganisationId)}`;
3
+ export const DEVICE_ORGANISATIONS_URL = () => `${CORE_URL()}/device-organisations`;
4
+ export const DEVICE_ORGANISATION_URL = (deviceOrganisationId: string) => `${DEVICE_ORGANISATIONS_URL()}/${encodeURIComponent(deviceOrganisationId)}`;
5
5
  export const DEVICE_ORGANISATION_GROUP_URL = (deviceOrganisationId: string) => `${DEVICE_ORGANISATION_URL(deviceOrganisationId)}/group`;
6
6
  export const DEVICE_ORGANISATION_LOCATION_URL = (deviceOrganisationId: string) => `${DEVICE_ORGANISATION_URL(deviceOrganisationId)}/location`;
@@ -3,4 +3,4 @@ import { HUBS_URL } from "./base";
3
3
 
4
4
  export const DEVICE_STATUS_URL = (deviceOrganisationId: string) => `${DEVICE_ORGANISATION_URL(deviceOrganisationId)}/status`;
5
5
 
6
- export const DEVICE_STATUSES_HUB_URL = `${HUBS_URL}/statuses`;
6
+ export const DEVICE_STATUSES_HUB_URL = () => `${HUBS_URL()}/statuses`;
@@ -1,4 +1,4 @@
1
1
  import { CORE_URL } from "./base";
2
2
 
3
- export const GROUPS_URL = `${CORE_URL}/groups`;
4
- export const GROUP_URL = (groupId: string) => `${GROUPS_URL}/${encodeURIComponent(groupId)}`;
3
+ export const GROUPS_URL = () => `${CORE_URL()}/groups`;
4
+ export const GROUP_URL = (groupId: string) => `${GROUPS_URL()}/${encodeURIComponent(groupId)}`;
@@ -1,5 +1,5 @@
1
1
  import { CORE_URL } from "./base";
2
2
 
3
- export const IMAGES_URL = `${CORE_URL}/images`;
4
- export const IMAGE_RAW_URL = (imageId: string) => `${IMAGES_URL}/raw/${encodeURIComponent(imageId)}`;
5
- export const IMAGE_THUMBNAIL_URL = (imageId: string) => `${IMAGES_URL}/thumbnail/${encodeURIComponent(imageId)}`
3
+ export const IMAGES_URL = () => `${CORE_URL()}/images`;
4
+ export const IMAGE_RAW_URL = (imageId: string) => `${IMAGES_URL()}/raw/${encodeURIComponent(imageId)}`;
5
+ export const IMAGE_THUMBNAIL_URL = (imageId: string) => `${IMAGES_URL()}/thumbnail/${encodeURIComponent(imageId)}`
@@ -1,7 +1,8 @@
1
+ export * from "./actions";
1
2
  export * from "./alerts";
2
- export * from "./applications";
3
3
  export * from "./articles";
4
4
  export * from "./authTokens";
5
+ export * from "./comments";
5
6
  export * from "./connectivityAlerts";
6
7
  export * from "./customProperties";
7
8
  export * from "./customPropertyValues";
@@ -10,7 +11,6 @@ export * from "./dataDefinitions";
10
11
  export * from "./deviceConnectivities";
11
12
  export * from "./deviceOrganisations";
12
13
  export * from "./deviceStatuses";
13
- export * from "./families";
14
14
  export * from "./groups";
15
15
  export * from "./images";
16
16
  export * from "./languages";
@@ -23,7 +23,6 @@ export * from "./permissionCategories";
23
23
  export * from "./permissions";
24
24
  export * from "./roleOrganisations";
25
25
  export * from "./roleOrganisationTypes";
26
- export * from "./timeZones";
27
- export * from "./translations";
26
+ export * from "./tables";
28
27
  export * from "./userOrganisations";
29
28
  export * from "./users";
@@ -1,4 +1,4 @@
1
1
  import { CORE_URL } from "./base";
2
2
 
3
- export const LANGUAGES_URL = `${CORE_URL}/languages`;
4
- export const LANGUAGE_URL = (languageId: string) => `${LANGUAGES_URL}/${encodeURIComponent(languageId)}`;
3
+ export const LANGUAGES_URL = () => `${CORE_URL()}/languages`;
4
+ export const LANGUAGE_URL = (languageId: string) => `${LANGUAGES_URL()}/${encodeURIComponent(languageId)}`;
@@ -1,4 +1,4 @@
1
1
  import { CORE_URL } from "./base";
2
2
 
3
- export const LOCATIONS_URL = `${CORE_URL}/locations`;
4
- export const LOCATION_URL = (locationId: string) => `${LOCATIONS_URL}/${encodeURIComponent(locationId)}`;
3
+ export const LOCATIONS_URL = () => `${CORE_URL()}/locations`;
4
+ export const LOCATION_URL = (locationId: string) => `${LOCATIONS_URL()}/${encodeURIComponent(locationId)}`;
@@ -1,4 +1,4 @@
1
1
  import { CORE_URL } from "./base";
2
2
 
3
- export const MANUFACTURERS_URL = `${CORE_URL}/manufacturers`;
4
- export const MANUFACTURER_URL = (manufacturerId: string) => `${MANUFACTURERS_URL}/${encodeURIComponent(manufacturerId)}`;
3
+ export const MANUFACTURERS_URL = () => `${CORE_URL()}/manufacturers`;
4
+ export const MANUFACTURER_URL = (manufacturerId: string) => `${MANUFACTURERS_URL()}/${encodeURIComponent(manufacturerId)}`;
@@ -1,4 +1,4 @@
1
1
  import { CORE_URL } from "./base";
2
2
 
3
- export const MODELS_URL = `${CORE_URL}/models`;
4
- export const MODEL_URL = (modelId: string) => `${MODELS_URL}/${encodeURIComponent(modelId)}`;
3
+ export const MODELS_URL = () => `${CORE_URL()}/models`;
4
+ export const MODEL_URL = (modelId: string) => `${MODELS_URL()}/${encodeURIComponent(modelId)}`;
@@ -1,4 +1,4 @@
1
1
  import { CORE_URL } from "./base";
2
2
 
3
- export const ORGANISATION_TYPES_URL = `${CORE_URL}/organisation-types`;
4
- export const ORGANISATION_TYPE_URL = (organisationTypeId: string) => `${ORGANISATION_TYPES_URL}/${encodeURIComponent(organisationTypeId)}`;
3
+ export const ORGANISATION_TYPES_URL = () => `${CORE_URL()}/organisation-types`;
4
+ export const ORGANISATION_TYPE_URL = (organisationTypeId: string) => `${ORGANISATION_TYPES_URL()}/${encodeURIComponent(organisationTypeId)}`;
@@ -1,7 +1,3 @@
1
- import { urlFactory } from "./urlFactory";
2
- import { GATEWAY_URL } from "./base";
1
+ import { CORE_URL } from "./base";
3
2
 
4
- export const ORGANISATIONS_URL = `${GATEWAY_URL}/organisations`;
5
- export const ORGANISATION_URL = urlFactory(organisationId => `${ORGANISATIONS_URL}/${encodeURIComponent(organisationId)}`);
6
-
7
- export const ORGANISATION_DASHBOARD_URL = `${ORGANISATION_URL()}/dashboard`;
3
+ export const ORGANISATION_DASHBOARD_URL = () => `${CORE_URL()}/dashboard`;
@@ -1,3 +1,3 @@
1
1
  import { CORE_URL } from "./base";
2
2
 
3
- export const PERMISSION_CATEGORIES_URL = `${CORE_URL}/permission-categories`;
3
+ export const PERMISSION_CATEGORIES_URL = () => `${CORE_URL()}/permission-categories`;
@@ -1,3 +1,3 @@
1
1
  import { CORE_URL } from "./base";
2
2
 
3
- export const PERMISSIONS_CURRENT_URL = `${CORE_URL}/permissions/current`;
3
+ export const PERMISSIONS_CURRENT_URL = () => `${CORE_URL()}/permissions/current`;
@@ -1,4 +1,4 @@
1
1
  import { CORE_URL } from "./base";
2
2
 
3
- export const ROLE_ORGANISATION_TYPES_URL = `${CORE_URL}/role-organisation-types`;
4
- export const ROLE_ORGANISATION_TYPE_URL = (roleOrganisationTypeId: string) => `${ROLE_ORGANISATION_TYPES_URL}/${encodeURIComponent(roleOrganisationTypeId)}`;
3
+ export const ROLE_ORGANISATION_TYPES_URL = () => `${CORE_URL()}/role-organisation-types`;
4
+ export const ROLE_ORGANISATION_TYPE_URL = (roleOrganisationTypeId: string) => `${ROLE_ORGANISATION_TYPES_URL()}/${encodeURIComponent(roleOrganisationTypeId)}`;
@@ -1,4 +1,4 @@
1
1
  import { CORE_URL } from "./base";
2
2
 
3
- export const ROLE_ORGANISATIONS_URL = `${CORE_URL}/role-organisations`;
4
- export const ROLE_ORGANISATION_URL = (roleOrganisationId: string) => `${ROLE_ORGANISATIONS_URL}/${encodeURIComponent(roleOrganisationId)}`;
3
+ export const ROLE_ORGANISATIONS_URL = () => `${CORE_URL()}/role-organisations`;
4
+ export const ROLE_ORGANISATION_URL = (roleOrganisationId: string) => `${ROLE_ORGANISATIONS_URL()}/${encodeURIComponent(roleOrganisationId)}`;
@@ -0,0 +1,4 @@
1
+ import { CORE_URL } from "./base";
2
+
3
+ export const TABLES_URL = () => `${CORE_URL()}/tables`;
4
+ export const TABLE_URL = (tableCode: string) => `${TABLES_URL()}/${encodeURIComponent(tableCode)}`;
@@ -1,17 +1,12 @@
1
- import { Ref, ref } from "vue";
1
+ import { useOrganisationId } from "../../composables/useOrganisationId";
2
2
 
3
- const organisationId = ref<string | null>(null);
4
-
5
- export function setOrganisationId(orgId: Ref<string | null>) {
6
- organisationId.value = orgId.value;
7
- }
3
+ const { organisationId } = useOrganisationId();
8
4
 
9
5
  export function urlFactory(url: (orgId: string) => string) {
10
6
  return () => {
11
7
  if (!organisationId.value) {
12
8
  throw new Error("OrganisationId is not set");
13
9
  }
14
-
15
10
  return url(organisationId.value);
16
11
  }
17
12
  }
@@ -1,5 +1,5 @@
1
1
  import { CORE_URL } from "./base";
2
2
 
3
- export const USER_ORGANISATIONS_URL = `${CORE_URL}/user-organisations`;
4
- export const USER_ORGANISATION_URL = (userOrganisationId: string) => `${USER_ORGANISATIONS_URL}/${encodeURIComponent(userOrganisationId)}`;
5
- export const USER_ORGANISATION_CURRENT_URL = `${USER_ORGANISATIONS_URL}/current`;
3
+ export const USER_ORGANISATIONS_URL = () => `${CORE_URL()}/user-organisations`;
4
+ export const USER_ORGANISATION_URL = (userOrganisationId: string) => `${USER_ORGANISATIONS_URL()}/${encodeURIComponent(userOrganisationId)}`;
5
+ export const USER_ORGANISATION_CURRENT_URL = () => `${USER_ORGANISATIONS_URL()}/current`;
@@ -1,5 +1,5 @@
1
1
  import { CORE_URL } from "./base";
2
2
 
3
- export const USERS_URL = `${CORE_URL}/users`;
4
- export const USER_URL = (userId: string) => `${USERS_URL}/${encodeURIComponent(userId)}`;
5
- export const USER_CURRENT_URL = `${USERS_URL}/current`;
3
+ export const USERS_URL = () => `${CORE_URL()}/users`;
4
+ export const USER_URL = (userId: string) => `${USERS_URL()}/${encodeURIComponent(userId)}`;
5
+ export const USER_CURRENT_URL = () => `${USERS_URL()}/current`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dative-gpi/foundation-core-services",
3
- "version": "0.0.8",
3
+ "version": "0.0.10",
4
4
  "description": "",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -9,11 +9,11 @@
9
9
  "author": "",
10
10
  "license": "ISC",
11
11
  "dependencies": {
12
- "@dative-gpi/bones-ui": "^0.0.50",
13
- "@dative-gpi/foundation-core-domain": "0.0.8",
12
+ "@dative-gpi/bones-ui": "^0.0.60",
13
+ "@dative-gpi/foundation-core-domain": "0.0.10",
14
14
  "@microsoft/signalr": "^8.0.0",
15
15
  "vue": "^3.2.0",
16
16
  "vue-router": "^4.2.5"
17
17
  },
18
- "gitHead": "b3393ad0a66fda249e1b2d3582af86e961553453"
18
+ "gitHead": "765222a4eb6a5cdd690f64bc0ae3c5415081e0f0"
19
19
  }
@@ -1,47 +0,0 @@
1
- import { Ref, onUnmounted, readonly, ref } from "vue";
2
-
3
- import { ApplicationDetails, ApplicationDetailsDTO } from "@dative-gpi/foundation-core-domain";
4
- import { onEntityChanged, ServiceFactory } from "@dative-gpi/bones-ui";
5
-
6
- import { APPLICATION_CURRENT_URL } from "../../config/urls";
7
-
8
- const ApplicationServiceFactory = new ServiceFactory<ApplicationDetailsDTO, ApplicationDetails>("application", ApplicationDetails).create(factory => factory.build(
9
- factory.addNotify((notifyService) => ({
10
- getCurrent: async (): Promise<ApplicationDetails> => {
11
- const response = await ServiceFactory.http.get(APPLICATION_CURRENT_URL);
12
- const result = new ApplicationDetails(response.data);
13
-
14
- notifyService.notify("update", result);
15
-
16
- return result;
17
- }
18
- }))
19
- ));
20
-
21
- export const useCurrentApplication = () => {
22
- const service = ApplicationServiceFactory();
23
-
24
- const fetching = ref(false);
25
- const fetched = ref<ApplicationDetails | null>(null) as Ref<ApplicationDetails | null>;
26
-
27
- const fetch = async () => {
28
- fetching.value = true;
29
- try {
30
- fetched.value = await service.getCurrent();
31
- }
32
- finally {
33
- fetching.value = false;
34
- }
35
-
36
- const subscriberId = service.subscribe("all", onEntityChanged(fetched))
37
- onUnmounted(() => service.unsubscribe(subscriberId));
38
-
39
- return readonly(fetched as Ref<ApplicationDetails>);
40
- }
41
-
42
- return {
43
- fetching: readonly(fetching),
44
- fetch,
45
- fetched: readonly(fetched)
46
- }
47
- }
@@ -1,13 +0,0 @@
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);
@@ -1,11 +0,0 @@
1
- import { TimeZoneFilters, TimeZoneInfos, TimeZoneInfosDTO } from "@dative-gpi/foundation-shared-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);
@@ -1,42 +0,0 @@
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
- }
@@ -1,48 +0,0 @@
1
- import { onMounted, provide, ref, watch } from "vue";
2
-
3
- import { LANGUAGE_CODE } from "../config/literals";
4
-
5
- let initialized = false;
6
-
7
- const languageCode = ref<string | null>(null);
8
-
9
- export const useLanguageCode = () => {
10
- const setLanguageCode = (payload: string) => {
11
- localStorage.setItem(LANGUAGE_CODE, payload);
12
- languageCode.value = payload;
13
- };
14
-
15
- if (!initialized) {
16
- provide(LANGUAGE_CODE, languageCode);
17
-
18
- onMounted(() => {
19
- if (languageCode.value) {
20
- return;
21
- }
22
- if (localStorage.getItem(LANGUAGE_CODE) != null) {
23
- languageCode.value = localStorage.getItem(LANGUAGE_CODE);
24
- }
25
- });
26
- }
27
-
28
- initialized = true;
29
-
30
- const ready = new Promise((resolve) => {
31
- if (languageCode.value) {
32
- resolve(languageCode.value);
33
- }
34
- else {
35
- watch(languageCode, () => {
36
- if (languageCode.value) {
37
- resolve(languageCode.value);
38
- }
39
- });
40
- }
41
- });
42
-
43
- return {
44
- ready,
45
- languageCode,
46
- setLanguageCode
47
- };
48
- }
@@ -1,4 +0,0 @@
1
- import { GATEWAY_URL } from "./base";
2
-
3
- export const APPLICATIONS_URL = `${GATEWAY_URL}/applications`;
4
- export const APPLICATION_CURRENT_URL = `${APPLICATIONS_URL}/curent`;
@@ -1,4 +0,0 @@
1
- import { CORE_URL } from "./base";
2
-
3
- export const FAMILIES_URL = `${CORE_URL}/families`;
4
- export const FAMILY_URL = (familyId: string) => `${FAMILIES_URL}/${encodeURIComponent(familyId)}`;
@@ -1,4 +0,0 @@
1
- import { GATEWAY_URL } from "./base";
2
-
3
- export const FILES_URL = `${GATEWAY_URL}/files`;
4
- export const FILE_URL = (fileId: string) => `${FILES_URL}/${fileId}`;
@@ -1,3 +0,0 @@
1
- import { GATEWAY_URL } from "./base";
2
-
3
- export const TIME_ZONES_URL = `${GATEWAY_URL}/time-zones`;
@@ -1,4 +0,0 @@
1
- import { GATEWAY_URL } from "./base";
2
-
3
- export const TRANSLATIONS_URL = `${GATEWAY_URL}/translations`;
4
- export const TRANSLATIONS_LANGUAGE_URL = (languageCode: string) => `${TRANSLATIONS_URL}/${encodeURIComponent(languageCode)}`;