@viridial/shared 1.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 (48) hide show
  1. package/README.md +114 -0
  2. package/USER-MODULE.md +268 -0
  3. package/dist/api/auth.service.d.ts +35 -0
  4. package/dist/api/auth.service.d.ts.map +1 -0
  5. package/dist/api/auth.service.js +63 -0
  6. package/dist/api/http.client.d.ts +19 -0
  7. package/dist/api/http.client.d.ts.map +1 -0
  8. package/dist/api/http.client.js +97 -0
  9. package/dist/api/property.service.d.ts +31 -0
  10. package/dist/api/property.service.d.ts.map +1 -0
  11. package/dist/api/property.service.js +47 -0
  12. package/dist/api/user.service.d.ts +86 -0
  13. package/dist/api/user.service.d.ts.map +1 -0
  14. package/dist/api/user.service.js +145 -0
  15. package/dist/composables/useAuth.d.ts +21 -0
  16. package/dist/composables/useAuth.d.ts.map +1 -0
  17. package/dist/composables/useAuth.js +43 -0
  18. package/dist/composables/useUser.d.ts +173 -0
  19. package/dist/composables/useUser.d.ts.map +1 -0
  20. package/dist/composables/useUser.js +132 -0
  21. package/dist/constants/api.constants.d.ts +32 -0
  22. package/dist/constants/api.constants.d.ts.map +1 -0
  23. package/dist/constants/api.constants.js +35 -0
  24. package/dist/index.d.ts +19 -0
  25. package/dist/index.d.ts.map +1 -0
  26. package/dist/index.js +20 -0
  27. package/dist/stores/auth.store.d.ts +75 -0
  28. package/dist/stores/auth.store.d.ts.map +1 -0
  29. package/dist/stores/auth.store.js +71 -0
  30. package/dist/stores/user.store.d.ts +748 -0
  31. package/dist/stores/user.store.d.ts.map +1 -0
  32. package/dist/stores/user.store.js +264 -0
  33. package/dist/types/api.types.d.ts +27 -0
  34. package/dist/types/api.types.d.ts.map +1 -0
  35. package/dist/types/api.types.js +4 -0
  36. package/dist/types/auth.types.d.ts +38 -0
  37. package/dist/types/auth.types.d.ts.map +1 -0
  38. package/dist/types/auth.types.js +4 -0
  39. package/dist/types/property.types.d.ts +66 -0
  40. package/dist/types/property.types.d.ts.map +1 -0
  41. package/dist/types/property.types.js +20 -0
  42. package/dist/types/user.types.d.ts +103 -0
  43. package/dist/types/user.types.d.ts.map +1 -0
  44. package/dist/types/user.types.js +21 -0
  45. package/dist/utils/token.utils.d.ts +30 -0
  46. package/dist/utils/token.utils.d.ts.map +1 -0
  47. package/dist/utils/token.utils.js +56 -0
  48. package/package.json +96 -0
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Exports centralisés pour les modules partagés
3
+ */
4
+ export { httpClient } from './api/http.client';
5
+ export { authService } from './api/auth.service';
6
+ export { propertyService } from './api/property.service';
7
+ export { userService } from './api/user.service';
8
+ export { useAuthStore } from './stores/auth.store';
9
+ export { useUserStore } from './stores/user.store';
10
+ export { useAuth } from './composables/useAuth';
11
+ export { useUser } from './composables/useUser';
12
+ export type * from './types/api.types';
13
+ export type * from './types/auth.types';
14
+ export type * from './types/property.types';
15
+ export type * from './types/user.types';
16
+ export { tokenUtils } from './utils/token.utils';
17
+ export { API_ENDPOINTS, API_BASE_URL } from './constants/api.constants';
18
+ export { UserStatus, UserRole } from './types/user.types';
19
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAGhD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAGlD,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAA;AAC/C,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAA;AAG/C,mBAAmB,mBAAmB,CAAA;AACtC,mBAAmB,oBAAoB,CAAA;AACvC,mBAAmB,wBAAwB,CAAA;AAC3C,mBAAmB,oBAAoB,CAAA;AAGvC,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAA;AAGhD,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AAGvE,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAA"}
package/dist/index.js ADDED
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Exports centralisés pour les modules partagés
3
+ */
4
+ // API Services
5
+ export { httpClient } from './api/http.client';
6
+ export { authService } from './api/auth.service';
7
+ export { propertyService } from './api/property.service';
8
+ export { userService } from './api/user.service';
9
+ // Stores
10
+ export { useAuthStore } from './stores/auth.store';
11
+ export { useUserStore } from './stores/user.store';
12
+ // Composables
13
+ export { useAuth } from './composables/useAuth';
14
+ export { useUser } from './composables/useUser';
15
+ // Utils
16
+ export { tokenUtils } from './utils/token.utils';
17
+ // Constants
18
+ export { API_ENDPOINTS, API_BASE_URL } from './constants/api.constants';
19
+ // Enums
20
+ export { UserStatus, UserRole } from './types/user.types';
@@ -0,0 +1,75 @@
1
+ import type { UserInfo, LoginRequest } from '../types/auth.types';
2
+ /**
3
+ * Store d'authentification
4
+ */
5
+ export declare const useAuthStore: import("pinia").StoreDefinition<"auth", Pick<{
6
+ user: import("vue").Ref<{
7
+ id: number;
8
+ email: string;
9
+ name: string;
10
+ roles?: string[] | undefined;
11
+ organizationId?: number | undefined;
12
+ } | null, UserInfo | {
13
+ id: number;
14
+ email: string;
15
+ name: string;
16
+ roles?: string[] | undefined;
17
+ organizationId?: number | undefined;
18
+ } | null>;
19
+ isAuthenticated: import("vue").Ref<boolean, boolean>;
20
+ loading: import("vue").Ref<boolean, boolean>;
21
+ isAdmin: import("vue").ComputedRef<boolean>;
22
+ isAgent: import("vue").ComputedRef<boolean>;
23
+ userName: import("vue").ComputedRef<string>;
24
+ login: (credentials: LoginRequest) => Promise<void>;
25
+ logout: () => Promise<void>;
26
+ checkAuth: () => void;
27
+ setUser: (userData: UserInfo) => void;
28
+ }, "user" | "isAuthenticated" | "loading">, Pick<{
29
+ user: import("vue").Ref<{
30
+ id: number;
31
+ email: string;
32
+ name: string;
33
+ roles?: string[] | undefined;
34
+ organizationId?: number | undefined;
35
+ } | null, UserInfo | {
36
+ id: number;
37
+ email: string;
38
+ name: string;
39
+ roles?: string[] | undefined;
40
+ organizationId?: number | undefined;
41
+ } | null>;
42
+ isAuthenticated: import("vue").Ref<boolean, boolean>;
43
+ loading: import("vue").Ref<boolean, boolean>;
44
+ isAdmin: import("vue").ComputedRef<boolean>;
45
+ isAgent: import("vue").ComputedRef<boolean>;
46
+ userName: import("vue").ComputedRef<string>;
47
+ login: (credentials: LoginRequest) => Promise<void>;
48
+ logout: () => Promise<void>;
49
+ checkAuth: () => void;
50
+ setUser: (userData: UserInfo) => void;
51
+ }, "isAdmin" | "isAgent" | "userName">, Pick<{
52
+ user: import("vue").Ref<{
53
+ id: number;
54
+ email: string;
55
+ name: string;
56
+ roles?: string[] | undefined;
57
+ organizationId?: number | undefined;
58
+ } | null, UserInfo | {
59
+ id: number;
60
+ email: string;
61
+ name: string;
62
+ roles?: string[] | undefined;
63
+ organizationId?: number | undefined;
64
+ } | null>;
65
+ isAuthenticated: import("vue").Ref<boolean, boolean>;
66
+ loading: import("vue").Ref<boolean, boolean>;
67
+ isAdmin: import("vue").ComputedRef<boolean>;
68
+ isAgent: import("vue").ComputedRef<boolean>;
69
+ userName: import("vue").ComputedRef<string>;
70
+ login: (credentials: LoginRequest) => Promise<void>;
71
+ logout: () => Promise<void>;
72
+ checkAuth: () => void;
73
+ setUser: (userData: UserInfo) => void;
74
+ }, "login" | "logout" | "checkAuth" | "setUser">>;
75
+ //# sourceMappingURL=auth.store.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth.store.d.ts","sourceRoot":"","sources":["../../stores/auth.store.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAIjE;;GAEG;AACH,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;yBAmBW,YAAY,KAAG,OAAO,CAAC,IAAI,CAAC;kBAarC,OAAO,CAAC,IAAI,CAAC;qBAShB,IAAI;wBAOC,QAAQ,KAAG,IAAI;;;;;;;;;;;;;;;;;;;;yBA7BR,YAAY,KAAG,OAAO,CAAC,IAAI,CAAC;kBAarC,OAAO,CAAC,IAAI,CAAC;qBAShB,IAAI;wBAOC,QAAQ,KAAG,IAAI;;;;;;;;;;;;;;;;;;;;yBA7BR,YAAY,KAAG,OAAO,CAAC,IAAI,CAAC;kBAarC,OAAO,CAAC,IAAI,CAAC;qBAShB,IAAI;wBAOC,QAAQ,KAAG,IAAI;iDAoB1C,CAAA"}
@@ -0,0 +1,71 @@
1
+ import { defineStore } from 'pinia';
2
+ import { ref, computed } from 'vue';
3
+ import { authService } from '../api/auth.service';
4
+ import { tokenUtils } from '../utils/token.utils';
5
+ /**
6
+ * Store d'authentification
7
+ */
8
+ export const useAuthStore = defineStore('auth', () => {
9
+ const user = ref(null);
10
+ const isAuthenticated = ref(false);
11
+ const loading = ref(false);
12
+ // Getters
13
+ const isAdmin = computed(() => {
14
+ return user.value?.roles?.includes('ADMIN') || false;
15
+ });
16
+ const isAgent = computed(() => {
17
+ return user.value?.roles?.includes('AGENT') || false;
18
+ });
19
+ const userName = computed(() => {
20
+ return user.value?.name || 'User';
21
+ });
22
+ // Actions
23
+ async function login(credentials) {
24
+ loading.value = true;
25
+ try {
26
+ const response = await authService.login(credentials);
27
+ user.value = response.user;
28
+ isAuthenticated.value = true;
29
+ }
30
+ catch (error) {
31
+ throw error;
32
+ }
33
+ finally {
34
+ loading.value = false;
35
+ }
36
+ }
37
+ async function logout() {
38
+ try {
39
+ await authService.logout();
40
+ }
41
+ finally {
42
+ user.value = null;
43
+ isAuthenticated.value = false;
44
+ }
45
+ }
46
+ function checkAuth() {
47
+ if (tokenUtils.hasToken()) {
48
+ isAuthenticated.value = true;
49
+ // TODO: Récupérer les infos utilisateur depuis le token ou API
50
+ }
51
+ }
52
+ function setUser(userData) {
53
+ user.value = userData;
54
+ isAuthenticated.value = true;
55
+ }
56
+ return {
57
+ // State
58
+ user,
59
+ isAuthenticated,
60
+ loading,
61
+ // Getters
62
+ isAdmin,
63
+ isAgent,
64
+ userName,
65
+ // Actions
66
+ login,
67
+ logout,
68
+ checkAuth,
69
+ setUser
70
+ };
71
+ });