@dative-gpi/foundation-shared-services 0.0.9 → 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.
- package/composables/services/useApplications.ts +7 -4
- package/composables/services/useAuthTokens.ts +1 -1
- package/composables/services/useLandingPages.ts +7 -4
- package/composables/services/useLayoutPages.ts +7 -4
- package/composables/services/useLegalInformations.ts +7 -4
- package/composables/services/useSecuritySettings.ts +7 -4
- package/composables/services/useUserLegalInformations.ts +7 -4
- package/composables/services/useUsers.ts +14 -8
- package/composables/useLanguageCode.ts +1 -11
- package/composables/useTimeZone.ts +4 -28
- package/composables/useTranslationsProvider.ts +3 -6
- package/config/index.ts +0 -1
- package/package.json +4 -4
- package/config/literals/index.ts +0 -2
|
@@ -20,10 +20,16 @@ const ApplicationServiceFactory = new ServiceFactory<ApplicationDetailsDTO, Appl
|
|
|
20
20
|
|
|
21
21
|
export const useCurrentApplication = () => {
|
|
22
22
|
const service = ApplicationServiceFactory();
|
|
23
|
+
const subscribersIds: number[] = [];
|
|
23
24
|
|
|
24
25
|
const fetching = ref(false);
|
|
25
26
|
const fetched = ref<ApplicationDetails | null>(null) as Ref<ApplicationDetails | null>;
|
|
26
27
|
|
|
28
|
+
onUnmounted(() => {
|
|
29
|
+
subscribersIds.forEach(id => service.unsubscribe(id));
|
|
30
|
+
subscribersIds.length = 0;
|
|
31
|
+
});
|
|
32
|
+
|
|
27
33
|
const fetch = async () => {
|
|
28
34
|
fetching.value = true;
|
|
29
35
|
try {
|
|
@@ -32,10 +38,7 @@ export const useCurrentApplication = () => {
|
|
|
32
38
|
finally {
|
|
33
39
|
fetching.value = false;
|
|
34
40
|
}
|
|
35
|
-
|
|
36
|
-
const subscriberId = service.subscribe("all", onEntityChanged(fetched));
|
|
37
|
-
onUnmounted(() => service.unsubscribe(subscriberId));
|
|
38
|
-
|
|
41
|
+
subscribersIds.push(service.subscribe("all", onEntityChanged(fetched)));
|
|
39
42
|
return readonly(fetched as Ref<ApplicationDetails>);
|
|
40
43
|
}
|
|
41
44
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AuthTokenDetails, AuthTokenDetailsDTO, CreateAuthTokenDTO } from "@dative-gpi/foundation-
|
|
1
|
+
import { AuthTokenDetails, AuthTokenDetailsDTO, CreateAuthTokenDTO } from "@dative-gpi/foundation-shared-domain";
|
|
2
2
|
import { ComposableFactory, ServiceFactory } from "@dative-gpi/bones-ui";
|
|
3
3
|
|
|
4
4
|
import { AUTH_TOKENS_URL } from "../../config/urls";
|
|
@@ -20,10 +20,16 @@ const LandingPageServiceFactory = new ServiceFactory<LandingPageDetailsDTO, Land
|
|
|
20
20
|
|
|
21
21
|
export const useCurrentLandingPage = () => {
|
|
22
22
|
const service = LandingPageServiceFactory();
|
|
23
|
+
const subscribersIds: number[] = [];
|
|
23
24
|
|
|
24
25
|
const fetching = ref(false);
|
|
25
26
|
const fetched = ref<LandingPageDetails | null>(null) as Ref<LandingPageDetails | null>;
|
|
26
27
|
|
|
28
|
+
onUnmounted(() => {
|
|
29
|
+
subscribersIds.forEach(id => service.unsubscribe(id));
|
|
30
|
+
subscribersIds.length = 0;
|
|
31
|
+
});
|
|
32
|
+
|
|
27
33
|
const fetch = async () => {
|
|
28
34
|
fetching.value = true;
|
|
29
35
|
try {
|
|
@@ -32,10 +38,7 @@ export const useCurrentLandingPage = () => {
|
|
|
32
38
|
finally {
|
|
33
39
|
fetching.value = false;
|
|
34
40
|
}
|
|
35
|
-
|
|
36
|
-
const subscriberId = service.subscribe("all", onEntityChanged(fetched))
|
|
37
|
-
onUnmounted(() => service.unsubscribe(subscriberId));
|
|
38
|
-
|
|
41
|
+
subscribersIds.push(service.subscribe("all", onEntityChanged(fetched)));
|
|
39
42
|
return readonly(fetched as Ref<LandingPageDetails>);
|
|
40
43
|
}
|
|
41
44
|
|
|
@@ -20,10 +20,16 @@ const LayoutPageServiceFactory = new ServiceFactory<LayoutPageDetailsDTO, Layout
|
|
|
20
20
|
|
|
21
21
|
export const useCurrentLayoutPage = () => {
|
|
22
22
|
const service = LayoutPageServiceFactory();
|
|
23
|
+
const subscribersIds: number[] = [];
|
|
23
24
|
|
|
24
25
|
const fetching = ref(false);
|
|
25
26
|
const fetched = ref<LayoutPageDetails | null>(null) as Ref<LayoutPageDetails | null>;
|
|
26
27
|
|
|
28
|
+
onUnmounted(() => {
|
|
29
|
+
subscribersIds.forEach(id => service.unsubscribe(id));
|
|
30
|
+
subscribersIds.length = 0;
|
|
31
|
+
});
|
|
32
|
+
|
|
27
33
|
const fetch = async () => {
|
|
28
34
|
fetching.value = true;
|
|
29
35
|
try {
|
|
@@ -32,10 +38,7 @@ export const useCurrentLayoutPage = () => {
|
|
|
32
38
|
finally {
|
|
33
39
|
fetching.value = false;
|
|
34
40
|
}
|
|
35
|
-
|
|
36
|
-
const subscriberId = service.subscribe("all", onEntityChanged(fetched))
|
|
37
|
-
onUnmounted(() => service.unsubscribe(subscriberId));
|
|
38
|
-
|
|
41
|
+
subscribersIds.push(service.subscribe("all", onEntityChanged(fetched)));
|
|
39
42
|
return readonly(fetched as Ref<LayoutPageDetails>);
|
|
40
43
|
}
|
|
41
44
|
|
|
@@ -20,10 +20,16 @@ const LegalInformationServiceFactory = new ServiceFactory<LegalInformationDetail
|
|
|
20
20
|
|
|
21
21
|
export const useCurrentLegalInformation = () => {
|
|
22
22
|
const service = LegalInformationServiceFactory();
|
|
23
|
+
const subscribersIds: number[] = [];
|
|
23
24
|
|
|
24
25
|
const fetching = ref(false);
|
|
25
26
|
const fetched = ref<LegalInformationDetails | null>(null) as Ref<LegalInformationDetails | null>;
|
|
26
27
|
|
|
28
|
+
onUnmounted(() => {
|
|
29
|
+
subscribersIds.forEach(id => service.unsubscribe(id));
|
|
30
|
+
subscribersIds.length = 0;
|
|
31
|
+
});
|
|
32
|
+
|
|
27
33
|
const fetch = async () => {
|
|
28
34
|
fetching.value = true;
|
|
29
35
|
try {
|
|
@@ -32,10 +38,7 @@ export const useCurrentLegalInformation = () => {
|
|
|
32
38
|
finally {
|
|
33
39
|
fetching.value = false;
|
|
34
40
|
}
|
|
35
|
-
|
|
36
|
-
const subscriberId = service.subscribe("all", onEntityChanged(fetched))
|
|
37
|
-
onUnmounted(() => service.unsubscribe(subscriberId));
|
|
38
|
-
|
|
41
|
+
subscribersIds.push(service.subscribe("all", onEntityChanged(fetched)));
|
|
39
42
|
return readonly(fetched as Ref<LegalInformationDetails>);
|
|
40
43
|
}
|
|
41
44
|
|
|
@@ -20,10 +20,16 @@ const SecuritySettingServiceFactory = new ServiceFactory<SecuritySettingDetailsD
|
|
|
20
20
|
|
|
21
21
|
export const useCurrentSecuritySettings = () => {
|
|
22
22
|
const service = SecuritySettingServiceFactory();
|
|
23
|
+
const subscribersIds: number[] = [];
|
|
23
24
|
|
|
24
25
|
const fetching = ref(false);
|
|
25
26
|
const fetched = ref<SecuritySettingDetails | null>(null) as Ref<SecuritySettingDetails | null>;
|
|
26
27
|
|
|
28
|
+
onUnmounted(() => {
|
|
29
|
+
subscribersIds.forEach(id => service.unsubscribe(id));
|
|
30
|
+
subscribersIds.length = 0;
|
|
31
|
+
});
|
|
32
|
+
|
|
27
33
|
const fetch = async () => {
|
|
28
34
|
fetching.value = true;
|
|
29
35
|
try {
|
|
@@ -32,10 +38,7 @@ export const useCurrentSecuritySettings = () => {
|
|
|
32
38
|
finally {
|
|
33
39
|
fetching.value = false;
|
|
34
40
|
}
|
|
35
|
-
|
|
36
|
-
const subscriberId = service.subscribe("all", onEntityChanged(fetched))
|
|
37
|
-
onUnmounted(() => service.unsubscribe(subscriberId));
|
|
38
|
-
|
|
41
|
+
subscribersIds.push(service.subscribe("all", onEntityChanged(fetched)));
|
|
39
42
|
return readonly(fetched as Ref<SecuritySettingDetails>);
|
|
40
43
|
}
|
|
41
44
|
|
|
@@ -22,10 +22,16 @@ const UserLegalInformationServiceFactory = new ServiceFactory<UserLegalInformati
|
|
|
22
22
|
export const useCreateUserLegalInformation = ComposableFactory.create(UserLegalInformationServiceFactory);
|
|
23
23
|
export const useCurrentUserLegalInformation = () => {
|
|
24
24
|
const service = UserLegalInformationServiceFactory();
|
|
25
|
+
const subscribersIds: number[] = [];
|
|
25
26
|
|
|
26
27
|
const fetching = ref(false);
|
|
27
28
|
const fetched = ref<UserLegalInformationDetails | null>(null) as Ref<UserLegalInformationDetails | null>;
|
|
28
29
|
|
|
30
|
+
onUnmounted(() => {
|
|
31
|
+
subscribersIds.forEach(id => service.unsubscribe(id));
|
|
32
|
+
subscribersIds.length = 0;
|
|
33
|
+
});
|
|
34
|
+
|
|
29
35
|
const fetch = async () => {
|
|
30
36
|
fetching.value = true;
|
|
31
37
|
try {
|
|
@@ -34,10 +40,7 @@ export const useCurrentUserLegalInformation = () => {
|
|
|
34
40
|
finally {
|
|
35
41
|
fetching.value = false;
|
|
36
42
|
}
|
|
37
|
-
|
|
38
|
-
const subscriberId = service.subscribe("all", onEntityChanged(fetched))
|
|
39
|
-
onUnmounted(() => service.unsubscribe(subscriberId));
|
|
40
|
-
|
|
43
|
+
subscribersIds.push(service.subscribe("all", onEntityChanged(fetched)));
|
|
41
44
|
return readonly(fetched as Ref<UserLegalInformationDetails>);
|
|
42
45
|
}
|
|
43
46
|
|
|
@@ -28,10 +28,16 @@ const UserServiceFactory = new ServiceFactory<UserDetailsDTO, UserDetails>("user
|
|
|
28
28
|
|
|
29
29
|
export const useCurrentUser = () => {
|
|
30
30
|
const service = UserServiceFactory();
|
|
31
|
+
const subscribersIds: number[] = [];
|
|
31
32
|
|
|
32
33
|
const fetching = ref(false);
|
|
33
34
|
const fetched = ref<UserDetails | null>(null) as Ref<UserDetails | null>;
|
|
34
35
|
|
|
36
|
+
onUnmounted(() => {
|
|
37
|
+
subscribersIds.forEach(id => service.unsubscribe(id));
|
|
38
|
+
subscribersIds.length = 0;
|
|
39
|
+
});
|
|
40
|
+
|
|
35
41
|
const fetch = async () => {
|
|
36
42
|
fetching.value = true;
|
|
37
43
|
try {
|
|
@@ -40,10 +46,7 @@ export const useCurrentUser = () => {
|
|
|
40
46
|
finally {
|
|
41
47
|
fetching.value = false;
|
|
42
48
|
}
|
|
43
|
-
|
|
44
|
-
const subscriberId = service.subscribe("all", onEntityChanged(fetched))
|
|
45
|
-
onUnmounted(() => service.unsubscribe(subscriberId));
|
|
46
|
-
|
|
49
|
+
subscribersIds.push(service.subscribe("all", onEntityChanged(fetched)));
|
|
47
50
|
return readonly(fetched as Ref<UserDetails>);
|
|
48
51
|
}
|
|
49
52
|
|
|
@@ -55,10 +58,16 @@ export const useCurrentUser = () => {
|
|
|
55
58
|
}
|
|
56
59
|
export const useUpdateCurrentUser = () => {
|
|
57
60
|
const service = UserServiceFactory();
|
|
61
|
+
const subscribersIds: number[] = [];
|
|
58
62
|
|
|
59
63
|
const updating = ref(false);
|
|
60
64
|
const updated = ref<UserDetails | null>(null) as Ref<UserDetails | null>;
|
|
61
65
|
|
|
66
|
+
onUnmounted(() => {
|
|
67
|
+
subscribersIds.forEach(id => service.unsubscribe(id));
|
|
68
|
+
subscribersIds.length = 0;
|
|
69
|
+
});
|
|
70
|
+
|
|
62
71
|
const update = async (payload: UpdateUserDTO) => {
|
|
63
72
|
updating.value = true;
|
|
64
73
|
try {
|
|
@@ -67,10 +76,7 @@ export const useUpdateCurrentUser = () => {
|
|
|
67
76
|
finally {
|
|
68
77
|
updating.value = false;
|
|
69
78
|
}
|
|
70
|
-
|
|
71
|
-
const subscriberId = service.subscribe("all", onEntityChanged(updated))
|
|
72
|
-
onUnmounted(() => service.unsubscribe(subscriberId));
|
|
73
|
-
|
|
79
|
+
subscribersIds.push(service.subscribe("all", onEntityChanged(updated)));
|
|
74
80
|
return readonly(updated as Ref<UserDetails>);
|
|
75
81
|
}
|
|
76
82
|
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import { LANGUAGE_CODE } from "../config/literals";
|
|
4
|
-
|
|
5
|
-
let initialized = false;
|
|
1
|
+
import { ref, watch } from "vue";
|
|
6
2
|
|
|
7
3
|
const languageCode = ref<string | null>("fr-FR");
|
|
8
4
|
|
|
@@ -11,12 +7,6 @@ export const useLanguageCode = () => {
|
|
|
11
7
|
languageCode.value = payload;
|
|
12
8
|
};
|
|
13
9
|
|
|
14
|
-
if (!initialized) {
|
|
15
|
-
provide(LANGUAGE_CODE, languageCode);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
initialized = true;
|
|
19
|
-
|
|
20
10
|
const ready = new Promise((resolve) => {
|
|
21
11
|
if (languageCode.value) {
|
|
22
12
|
resolve(languageCode.value);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ref, watch } 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";
|
|
@@ -7,9 +7,6 @@ import { TimeZoneInfos } from "@dative-gpi/foundation-shared-domain/models";
|
|
|
7
7
|
|
|
8
8
|
import { useTranslationsProvider } from "./useTranslationsProvider";
|
|
9
9
|
import { useLanguageCode } from "./useLanguageCode";
|
|
10
|
-
import { TIME_ZONE } from "../config/literals";
|
|
11
|
-
|
|
12
|
-
let initialized = false;
|
|
13
10
|
|
|
14
11
|
const timeZone = ref<TimeZoneInfos | null>({
|
|
15
12
|
id: "Europe/Paris",
|
|
@@ -17,9 +14,6 @@ const timeZone = ref<TimeZoneInfos | null>({
|
|
|
17
14
|
});
|
|
18
15
|
|
|
19
16
|
export const useTimeZone = () => {
|
|
20
|
-
const { languageCode } = useLanguageCode();
|
|
21
|
-
const { $tr } = useTranslationsProvider();
|
|
22
|
-
|
|
23
17
|
const setTimeZone = (payload: TimeZoneInfos) => {
|
|
24
18
|
timeZone.value = payload;
|
|
25
19
|
};
|
|
@@ -151,11 +145,11 @@ export const useTimeZone = () => {
|
|
|
151
145
|
};
|
|
152
146
|
|
|
153
147
|
const todayTimeFormat = (): string => {
|
|
154
|
-
return `'${
|
|
148
|
+
return `'${useTranslationsProvider().$tr("ui.time-zone.today-at", "Today at").replaceAll("'", "''")}' HH:mm:ss`;
|
|
155
149
|
}
|
|
156
150
|
|
|
157
151
|
const yesterdayTimeFormat = (): string => {
|
|
158
|
-
return `'${
|
|
152
|
+
return `'${useTranslationsProvider().$tr("ui.time-zone.yesterday-at", "Yesterday at").replaceAll("'", "''")}' HH:mm:ss`;
|
|
159
153
|
}
|
|
160
154
|
|
|
161
155
|
const overrideFormat = (date: Date, askedFormat: string): string => {
|
|
@@ -170,7 +164,7 @@ export const useTimeZone = () => {
|
|
|
170
164
|
}
|
|
171
165
|
|
|
172
166
|
const getLocale = (): Locale => {
|
|
173
|
-
switch (languageCode.value) {
|
|
167
|
+
switch (useLanguageCode().languageCode.value) {
|
|
174
168
|
case "fr-FR": return fr;
|
|
175
169
|
case "es-ES": return es;
|
|
176
170
|
case "it-IT": return it;
|
|
@@ -180,24 +174,6 @@ export const useTimeZone = () => {
|
|
|
180
174
|
}
|
|
181
175
|
}
|
|
182
176
|
|
|
183
|
-
if (!initialized) {
|
|
184
|
-
provide(TIME_ZONE, timeZone);
|
|
185
|
-
|
|
186
|
-
onMounted(() => {
|
|
187
|
-
if (timeZone.value) {
|
|
188
|
-
return;
|
|
189
|
-
}
|
|
190
|
-
else {
|
|
191
|
-
setTimeZone(new TimeZoneInfos({
|
|
192
|
-
id: Intl.DateTimeFormat().resolvedOptions().timeZone,
|
|
193
|
-
offset: getMachineOffset()
|
|
194
|
-
}));
|
|
195
|
-
}
|
|
196
|
-
});
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
initialized = true;
|
|
200
|
-
|
|
201
177
|
const ready = new Promise((resolve) => {
|
|
202
178
|
if (timeZone.value) {
|
|
203
179
|
resolve(timeZone.value);
|
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
import { useLanguageCode, useTranslations } from "@dative-gpi/foundation-shared-services";
|
|
2
2
|
|
|
3
|
-
const { fetch, fetched } = useTranslations()
|
|
4
|
-
const { ready, languageCode } = useLanguageCode();
|
|
5
|
-
|
|
6
3
|
let initialized = false;
|
|
7
4
|
|
|
8
5
|
export const useTranslationsProvider = () => {
|
|
9
6
|
const $tr = (code: string, defaultValue: string, ...parameters: string[]): string => {
|
|
10
|
-
let translation = fetched.value.find(t => t.code === code)?.value ?? defaultValue;
|
|
7
|
+
let translation = useTranslations().fetched.value.find(t => t.code === code)?.value ?? defaultValue;
|
|
11
8
|
if (translation && parameters.length) {
|
|
12
9
|
for (let p of parameters) {
|
|
13
10
|
translation = translation.replace(`{${parameters.indexOf(p)}}`, p.toString());
|
|
@@ -19,8 +16,8 @@ export const useTranslationsProvider = () => {
|
|
|
19
16
|
const init = async () => {
|
|
20
17
|
if (!initialized) {
|
|
21
18
|
initialized = true;
|
|
22
|
-
await ready;
|
|
23
|
-
await fetch(languageCode.value!);
|
|
19
|
+
await useLanguageCode().ready;
|
|
20
|
+
await useTranslations().fetch(useLanguageCode().languageCode.value!);
|
|
24
21
|
}
|
|
25
22
|
}
|
|
26
23
|
|
package/config/index.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dative-gpi/foundation-shared-services",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.10",
|
|
4
4
|
"description": "",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -9,12 +9,12 @@
|
|
|
9
9
|
"author": "",
|
|
10
10
|
"license": "ISC",
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@dative-gpi/bones-ui": "^0.0.
|
|
13
|
-
"@dative-gpi/foundation-shared-domain": "0.0.
|
|
12
|
+
"@dative-gpi/bones-ui": "^0.0.60",
|
|
13
|
+
"@dative-gpi/foundation-shared-domain": "0.0.10",
|
|
14
14
|
"@microsoft/signalr": "^8.0.0",
|
|
15
15
|
"date-fns": "^3.2.0",
|
|
16
16
|
"vue": "^3.2.0",
|
|
17
17
|
"vue-router": "^4.2.5"
|
|
18
18
|
},
|
|
19
|
-
"gitHead": "
|
|
19
|
+
"gitHead": "765222a4eb6a5cdd690f64bc0ae3c5415081e0f0"
|
|
20
20
|
}
|
package/config/literals/index.ts
DELETED