@dative-gpi/foundation-shared-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.
- package/composables/app/useAppLanguageCode.ts +2 -2
- package/composables/app/useAppTimeZone.ts +3 -3
- package/composables/services/useApplications.ts +5 -45
- package/composables/services/useImages.ts +6 -37
- package/composables/services/useTranslations.ts +6 -37
- package/composables/services/useUsers.ts +15 -77
- package/package.json +4 -4
|
@@ -3,7 +3,7 @@ import { computed, ref } from "vue";
|
|
|
3
3
|
const languageCode = ref<string | undefined>(undefined);
|
|
4
4
|
|
|
5
5
|
export const useAppLanguageCode = () => {
|
|
6
|
-
const
|
|
6
|
+
const setAppLanguageCode = (payload: string) => {
|
|
7
7
|
languageCode.value = payload;
|
|
8
8
|
};
|
|
9
9
|
|
|
@@ -12,6 +12,6 @@ export const useAppLanguageCode = () => {
|
|
|
12
12
|
return {
|
|
13
13
|
ready,
|
|
14
14
|
languageCode,
|
|
15
|
-
|
|
15
|
+
setAppLanguageCode
|
|
16
16
|
};
|
|
17
17
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { computed, ref
|
|
1
|
+
import { computed, ref } from "vue";
|
|
2
2
|
|
|
3
3
|
import { enUS, enGB, fr, it, es, de, Locale } from "date-fns/locale";
|
|
4
4
|
import { format, subDays } from "date-fns";
|
|
@@ -11,7 +11,7 @@ import { useAppLanguageCode } from "./useAppLanguageCode";
|
|
|
11
11
|
const timeZone = ref<TimeZoneInfos | null>(null);
|
|
12
12
|
|
|
13
13
|
export const useAppTimeZone = () => {
|
|
14
|
-
const
|
|
14
|
+
const setAppTimeZone = (payload: TimeZoneInfos) => {
|
|
15
15
|
timeZone.value = payload;
|
|
16
16
|
};
|
|
17
17
|
|
|
@@ -183,7 +183,7 @@ export const useAppTimeZone = () => {
|
|
|
183
183
|
return {
|
|
184
184
|
ready,
|
|
185
185
|
timeZone,
|
|
186
|
-
|
|
186
|
+
setAppTimeZone,
|
|
187
187
|
getUserOffset,
|
|
188
188
|
getMachineOffset,
|
|
189
189
|
getUserOffsetMillis,
|
|
@@ -1,50 +1,10 @@
|
|
|
1
|
-
import { onUnmounted, ref } from "vue";
|
|
2
|
-
|
|
3
1
|
import { ApplicationDetails, ApplicationDetailsDTO } from "@dative-gpi/foundation-shared-domain/models";
|
|
4
|
-
import {
|
|
2
|
+
import { ComposableFactory, ServiceFactory } from "@dative-gpi/bones-ui";
|
|
5
3
|
|
|
6
4
|
import { APPLICATION_CURRENT_URL } from "../../config/urls";
|
|
7
5
|
|
|
8
|
-
const ApplicationServiceFactory =
|
|
9
|
-
|
|
10
|
-
|
|
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
|
-
const subscribersIds: number[] = [];
|
|
24
|
-
|
|
25
|
-
const getting = ref(false);
|
|
26
|
-
const entity = ref<ApplicationDetails | null>(null);
|
|
27
|
-
|
|
28
|
-
onUnmounted(() => {
|
|
29
|
-
subscribersIds.forEach(id => service.unsubscribe(id));
|
|
30
|
-
subscribersIds.length = 0;
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
const get = async () => {
|
|
34
|
-
getting.value = true;
|
|
35
|
-
try {
|
|
36
|
-
entity.value = await service.getCurrent();
|
|
37
|
-
}
|
|
38
|
-
finally {
|
|
39
|
-
getting.value = false;
|
|
40
|
-
}
|
|
41
|
-
subscribersIds.push(service.subscribe("all", onEntityChanged(entity)));
|
|
42
|
-
return entity;
|
|
43
|
-
}
|
|
6
|
+
const ApplicationServiceFactory = {
|
|
7
|
+
...ServiceFactory.addCustom("getCurrent", (axios) => axios.get(APPLICATION_CURRENT_URL()), (dto: ApplicationDetailsDTO) => new ApplicationDetails(dto))
|
|
8
|
+
};
|
|
44
9
|
|
|
45
|
-
|
|
46
|
-
getting,
|
|
47
|
-
get,
|
|
48
|
-
entity
|
|
49
|
-
}
|
|
50
|
-
}
|
|
10
|
+
export const useCurrentApplication = ComposableFactory.custom(ApplicationServiceFactory.getCurrent);
|
|
@@ -1,41 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import { BlurHash } from "@dative-gpi/foundation-shared-domain/models";
|
|
4
|
-
import { ServiceFactory } from "@dative-gpi/bones-ui";
|
|
1
|
+
import { ComposableFactory, ServiceFactory } from "@dative-gpi/bones-ui";
|
|
2
|
+
import { BlurHash, BlurHashDTO } from "@dative-gpi/foundation-shared-domain/models";
|
|
5
3
|
|
|
6
4
|
import { IMAGE_BLURHASH_URL } from "../../config/urls";
|
|
7
5
|
|
|
8
|
-
const ImageServiceFactory =
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const response = await ServiceFactory.http.get(IMAGE_BLURHASH_URL(imageId));
|
|
12
|
-
const result = new BlurHash(response.data);
|
|
13
|
-
|
|
14
|
-
return result;
|
|
15
|
-
}
|
|
16
|
-
}))
|
|
17
|
-
));
|
|
18
|
-
|
|
19
|
-
export const useImageBlurHash = () => {
|
|
20
|
-
const service = ImageServiceFactory();
|
|
21
|
-
|
|
22
|
-
const getting = ref(false);
|
|
23
|
-
const entity = ref<BlurHash | null>(null);
|
|
24
|
-
|
|
25
|
-
const get = async (imageId: string) => {
|
|
26
|
-
getting.value = true;
|
|
27
|
-
try {
|
|
28
|
-
entity.value = await service.getBlurHash(imageId);
|
|
29
|
-
}
|
|
30
|
-
finally {
|
|
31
|
-
getting.value = false;
|
|
32
|
-
}
|
|
33
|
-
return entity;
|
|
34
|
-
}
|
|
6
|
+
const ImageServiceFactory = {
|
|
7
|
+
...ServiceFactory.addCustom("getBlurHash", (axios, imageId: string) => axios.get(IMAGE_BLURHASH_URL(imageId)), (dto: BlurHashDTO) => new BlurHash(dto))
|
|
8
|
+
};
|
|
35
9
|
|
|
36
|
-
|
|
37
|
-
getting,
|
|
38
|
-
get,
|
|
39
|
-
entity
|
|
40
|
-
}
|
|
41
|
-
}
|
|
10
|
+
export const useImageBlurHash = ComposableFactory.custom(ImageServiceFactory.getBlurHash);
|
|
@@ -1,41 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import { TranslationInfos, TranslationInfosDTO, TranslationDetails, TranslationDetailsDTO } from "@dative-gpi/foundation-shared-domain/models";
|
|
4
|
-
import { ServiceFactory } from "@dative-gpi/bones-ui";
|
|
1
|
+
import { TranslationInfos, TranslationInfosDTO } from "@dative-gpi/foundation-shared-domain/models";
|
|
2
|
+
import { ComposableFactory, ServiceFactory } from "@dative-gpi/bones-ui";
|
|
5
3
|
|
|
6
4
|
import { TRANSLATIONS_LANGUAGE_URL } from "../../config/urls";
|
|
7
5
|
|
|
8
|
-
const TranslationServiceFactory =
|
|
9
|
-
|
|
10
|
-
|
|
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 entities = ref<TranslationInfos[]>([]);
|
|
24
|
-
|
|
25
|
-
const getMany = async (languageCode: string) => {
|
|
26
|
-
fetching.value = true;
|
|
27
|
-
try {
|
|
28
|
-
entities.value = await service.getMany(languageCode);
|
|
29
|
-
}
|
|
30
|
-
finally {
|
|
31
|
-
fetching.value = false;
|
|
32
|
-
}
|
|
33
|
-
return entities;
|
|
34
|
-
}
|
|
6
|
+
const TranslationServiceFactory = {
|
|
7
|
+
...ServiceFactory.addCustom("getMany", (axios, languageCode: string) => axios.get(TRANSLATIONS_LANGUAGE_URL(languageCode)), (dtos: TranslationInfosDTO[]) => dtos.map(dto => new TranslationInfos(dto)))
|
|
8
|
+
};
|
|
35
9
|
|
|
36
|
-
|
|
37
|
-
fetching,
|
|
38
|
-
getMany,
|
|
39
|
-
entities
|
|
40
|
-
}
|
|
41
|
-
}
|
|
10
|
+
export const useTranslations = ComposableFactory.custom(TranslationServiceFactory.getMany);
|
|
@@ -1,88 +1,26 @@
|
|
|
1
|
-
import { onUnmounted, ref } from "vue";
|
|
2
|
-
|
|
3
1
|
import { UpdateUserDTO, UserDetails, UserDetailsDTO } from "@dative-gpi/foundation-shared-domain/models";
|
|
4
|
-
import {
|
|
2
|
+
import { ComposableFactory, ServiceFactory } from "@dative-gpi/bones-ui";
|
|
5
3
|
|
|
6
4
|
import { USER_CURRENT_URL } from "../../config/urls";
|
|
7
5
|
|
|
8
6
|
const UserServiceFactory = new ServiceFactory<UserDetailsDTO, UserDetails>("user", UserDetails).create(factory => factory.build(
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const result = new UserDetails(
|
|
13
|
-
|
|
14
|
-
notifyService.notify("update", result);
|
|
15
|
-
|
|
16
|
-
return result;
|
|
17
|
-
},
|
|
18
|
-
updateCurrent: async (payload: UpdateUserDTO): Promise<UserDetails> => {
|
|
19
|
-
const response = await ServiceFactory.http.post(USER_CURRENT_URL(), payload);
|
|
20
|
-
const result = new UserDetails(response.data);
|
|
21
|
-
|
|
22
|
-
notifyService.notify("update", result);
|
|
23
|
-
|
|
7
|
+
ServiceFactory.addCustom("getCurrent", (axios) => axios.get(USER_CURRENT_URL()), (dto: UserDetailsDTO) => new UserDetails(dto)),
|
|
8
|
+
factory.addNotify(notify => ({
|
|
9
|
+
...ServiceFactory.addCustom("updateCurrent", (axios, payload: UpdateUserDTO) => axios.post(USER_CURRENT_URL(), payload), (dto: UserDetailsDTO) => {
|
|
10
|
+
const result = new UserDetails(dto);
|
|
11
|
+
notify.notify("update", result);
|
|
24
12
|
return result;
|
|
25
|
-
}
|
|
13
|
+
})
|
|
26
14
|
}))
|
|
27
15
|
));
|
|
28
16
|
|
|
29
|
-
export const
|
|
30
|
-
const service = UserServiceFactory();
|
|
31
|
-
const subscribersIds: number[] = [];
|
|
32
|
-
|
|
33
|
-
const getting = ref(false);
|
|
34
|
-
const entity = ref<UserDetails | null>(null);
|
|
35
|
-
|
|
36
|
-
onUnmounted(() => {
|
|
37
|
-
subscribersIds.forEach(id => service.unsubscribe(id));
|
|
38
|
-
subscribersIds.length = 0;
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
const get = async () => {
|
|
42
|
-
getting.value = true;
|
|
43
|
-
try {
|
|
44
|
-
entity.value = await service.getCurrent();
|
|
45
|
-
}
|
|
46
|
-
finally {
|
|
47
|
-
getting.value = false;
|
|
48
|
-
}
|
|
49
|
-
subscribersIds.push(service.subscribe("all", onEntityChanged(entity)));
|
|
50
|
-
return entity;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
return {
|
|
54
|
-
getting,
|
|
55
|
-
get,
|
|
56
|
-
entity
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
export const useUpdateCurrentUser = () => {
|
|
60
|
-
const service = UserServiceFactory();
|
|
61
|
-
const subscribersIds: number[] = [];
|
|
62
|
-
|
|
63
|
-
const updating = ref(false);
|
|
64
|
-
const updated = ref<UserDetails | null>(null);
|
|
65
|
-
|
|
66
|
-
onUnmounted(() => {
|
|
67
|
-
subscribersIds.forEach(id => service.unsubscribe(id));
|
|
68
|
-
subscribersIds.length = 0;
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
const update = async (payload: UpdateUserDTO) => {
|
|
72
|
-
updating.value = true;
|
|
73
|
-
try {
|
|
74
|
-
updated.value = await service.updateCurrent(payload);
|
|
75
|
-
}
|
|
76
|
-
finally {
|
|
77
|
-
updating.value = false;
|
|
78
|
-
}
|
|
79
|
-
subscribersIds.push(service.subscribe("all", onEntityChanged(updated)));
|
|
80
|
-
return updated;
|
|
81
|
-
}
|
|
17
|
+
export const useTrackUser = ComposableFactory.track(UserServiceFactory);
|
|
82
18
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
19
|
+
export const useCurrentUser = ComposableFactory.custom(UserServiceFactory.getCurrent, () => {
|
|
20
|
+
const { track } = useTrackUser();
|
|
21
|
+
|
|
22
|
+
return (user) => {
|
|
23
|
+
track(user);
|
|
87
24
|
}
|
|
88
|
-
}
|
|
25
|
+
});
|
|
26
|
+
export const useUpdateCurrentUser = ComposableFactory.custom(UserServiceFactory.updateCurrent);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dative-gpi/foundation-shared-services",
|
|
3
3
|
"sideEffects": false,
|
|
4
|
-
"version": "0.0.
|
|
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.
|
|
14
|
-
"@dative-gpi/foundation-shared-domain": "0.0.
|
|
13
|
+
"@dative-gpi/bones-ui": "^0.0.70",
|
|
14
|
+
"@dative-gpi/foundation-shared-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": "
|
|
19
|
+
"gitHead": "391503e595cd9d731fca14b5bb2d3a10b6efee95"
|
|
20
20
|
}
|