codevdesign 1.0.72 → 1.0.74

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/index.ts CHANGED
@@ -1,80 +1,80 @@
1
- import csqcAlerteErreur from './composants/csqcAlerteErreur.vue'
2
- import csqcDialogue from './composants/csqcDialogue.vue'
3
-
4
- // à enlever éventuellement. Remplacé par csqcSwitch
5
- import csqcOptionSwitch from './composants/csqcSwitch.vue'
6
- import csqcRecherche from './composants/csqcRecherche.vue'
7
- import csqcSnackbar from './composants/csqcSnackbar.vue'
8
- import csqcTiroir from './composants/csqcTiroir.vue'
9
- import pivEntete from './composants/gabarit/pivEntete.vue'
10
- import pivFooter from './composants/gabarit/pivPiedPage.vue'
11
- import csqcMenu from './composants/gabarit/csqcMenu.vue'
12
- import csqcConfirmation from './composants/csqcConfirmation.vue'
13
- import csqcSaisie from './composants/csqcModaleSaisie.vue'
14
- import csqcDate from './composants/csqcDate.vue'
15
- import csqcTable from './composants/csqcTable/csqcTable.vue'
16
- import csqcCodeBudgetaire from './composants/csqcCodeBudgetaireGenerique.vue'
17
- import csqcChaise from './composants/csqcChaise/chaiseConteneur.vue'
18
- import csqcAide from './composants/csqcAide.vue'
19
- import csqcEntete from './composants/csqcEntete.vue'
20
- import csqcTexteBilingue from './composants/csqcTexteBilingue.vue'
21
- import csqcSwitch from './composants/csqcSwitch.vue'
22
-
23
- //import csqcEditeurTexteRiche from './composants/csqcEditeurTexteRiche.vue'
24
- import csqcImportCSV from './composants/csqcImportCSV.vue'
25
- import csqcRechercheUtilisateur from './composants/csqcRechercheUtilisateur.vue'
26
- import validateurs from './composants/validateurs'
27
-
28
- // modèles
29
- import NotificationGabaritDefaut from './modeles/notificationGabaritDefaut'
30
- import modeleSnackbar from './modeles/composants/snackbar'
31
- import modeleDatatableColonne from './modeles/composants/datatableColonne'
32
- import apiReponse from './modeles/apiReponse'
33
- import data from './modeles/data'
34
- import response from './modeles/response'
35
-
36
- // outils
37
- import csqcRafraichisseurToken from './outils/rafraichisseurToken'
38
- import csqcRafraichisseurTokenParent from './outils/csqcRafraichisseurTokenParent'
39
- import csqcOutils from './outils/csqcOutils'
40
-
41
- // i18n
42
- import csqcEn from './locales/en.json'
43
- import csqcFr from './locales/fr.json'
44
-
45
- export {
46
- csqcFr,
47
- csqcEn,
48
- csqcAlerteErreur,
49
- csqcDialogue,
50
- csqcConfirmation,
51
- csqcSaisie,
52
- csqcDate,
53
- csqcOptionSwitch, // a enlever eventuellement
54
- csqcSwitch,
55
- csqcRecherche,
56
- csqcSnackbar,
57
- csqcTable,
58
- csqcTiroir,
59
- csqcMenu,
60
- csqcCodeBudgetaire,
61
- csqcChaise,
62
- pivFooter,
63
- pivEntete,
64
- csqcAide,
65
- csqcEntete,
66
- csqcTexteBilingue,
67
- // csqcEditeurTexteRiche,
68
- validateurs,
69
- csqcImportCSV,
70
- csqcRechercheUtilisateur,
71
- csqcRafraichisseurToken,
72
- csqcRafraichisseurTokenParent,
73
- csqcOutils,
74
- modeleSnackbar,
75
- modeleDatatableColonne as colonne,
76
- apiReponse,
77
- data,
78
- response,
79
- NotificationGabaritDefaut,
80
- }
1
+ import csqcAlerteErreur from './composants/csqcAlerteErreur.vue'
2
+ import csqcDialogue from './composants/csqcDialogue.vue'
3
+
4
+ // à enlever éventuellement. Remplacé par csqcSwitch
5
+ import csqcOptionSwitch from './composants/csqcSwitch.vue'
6
+ import csqcRecherche from './composants/csqcRecherche.vue'
7
+ import csqcSnackbar from './composants/csqcSnackbar.vue'
8
+ import csqcTiroir from './composants/csqcTiroir.vue'
9
+ import pivEntete from './composants/gabarit/pivEntete.vue'
10
+ import pivFooter from './composants/gabarit/pivPiedPage.vue'
11
+ import csqcMenu from './composants/gabarit/csqcMenu.vue'
12
+ import csqcConfirmation from './composants/csqcConfirmation.vue'
13
+ import csqcSaisie from './composants/csqcModaleSaisie.vue'
14
+ import csqcDate from './composants/csqcDate.vue'
15
+ import csqcTable from './composants/csqcTable/csqcTable.vue'
16
+ import csqcCodeBudgetaire from './composants/csqcCodeBudgetaireGenerique.vue'
17
+ import csqcChaise from './composants/csqcChaise/chaiseConteneur.vue'
18
+ import csqcAide from './composants/csqcAide.vue'
19
+ import csqcEntete from './composants/csqcEntete.vue'
20
+ import csqcTexteBilingue from './composants/csqcTexteBilingue.vue'
21
+ import csqcSwitch from './composants/csqcSwitch.vue'
22
+
23
+ //import csqcEditeurTexteRiche from './composants/csqcEditeurTexteRiche.vue'
24
+ import csqcImportCSV from './composants/csqcImportCSV.vue'
25
+ import csqcRechercheUtilisateur from './composants/csqcRechercheUtilisateur.vue'
26
+ import validateurs from './composants/validateurs'
27
+
28
+ // modèles
29
+ import NotificationGabaritDefaut from './modeles/notificationGabaritDefaut'
30
+ import modeleSnackbar from './modeles/composants/snackbar'
31
+ import modeleDatatableColonne from './modeles/composants/datatableColonne'
32
+ import apiReponse from './modeles/apiReponse'
33
+ import data from './modeles/data'
34
+ import response from './modeles/response'
35
+
36
+ // outils
37
+ import csqcRafraichisseurToken from './outils/rafraichisseurToken'
38
+ import csqcRafraichisseurTokenParent from './outils/csqcRafraichisseurTokenParent'
39
+ import csqcOutils from './outils/csqcOutils'
40
+
41
+ // i18n
42
+ import csqcEn from './locales/en.json'
43
+ import csqcFr from './locales/fr.json'
44
+
45
+ export {
46
+ csqcFr,
47
+ csqcEn,
48
+ csqcAlerteErreur,
49
+ csqcDialogue,
50
+ csqcConfirmation,
51
+ csqcSaisie,
52
+ csqcDate,
53
+ csqcOptionSwitch, // a enlever eventuellement
54
+ csqcSwitch,
55
+ csqcRecherche,
56
+ csqcSnackbar,
57
+ csqcTable,
58
+ csqcTiroir,
59
+ csqcMenu,
60
+ csqcCodeBudgetaire,
61
+ csqcChaise,
62
+ pivFooter,
63
+ pivEntete,
64
+ csqcAide,
65
+ csqcEntete,
66
+ csqcTexteBilingue,
67
+ // csqcEditeurTexteRiche,
68
+ validateurs,
69
+ csqcImportCSV,
70
+ csqcRechercheUtilisateur,
71
+ csqcRafraichisseurToken,
72
+ csqcRafraichisseurTokenParent,
73
+ csqcOutils,
74
+ modeleSnackbar,
75
+ modeleDatatableColonne as colonne,
76
+ apiReponse,
77
+ data,
78
+ response,
79
+ NotificationGabaritDefaut,
80
+ }
@@ -1,18 +1,18 @@
1
- export interface MenuItem {
2
- nom: string
3
- path: string
4
- droit: string
5
- }
6
-
7
- export interface SousListe {
8
- droit: string
9
- id: number
10
- nom: string
11
- }
12
-
13
- export interface SousListeItems {
14
- parentId: number
15
- nom: string
16
- path: string
17
- droit: string
18
- }
1
+ export interface MenuItem {
2
+ nom: string
3
+ path: string
4
+ droit: string
5
+ }
6
+
7
+ export interface SousListe {
8
+ droit: string
9
+ id: number
10
+ nom: string
11
+ }
12
+
13
+ export interface SousListeItems {
14
+ parentId: number
15
+ nom: string
16
+ path: string
17
+ droit: string
18
+ }
@@ -1,31 +1,31 @@
1
- import type { DataTableCompareFunction, DataTableHeader, FilterFunction } from 'vuetify'
2
- import { HeaderCellProps } from 'vuetify/lib/components/VDataTable/types.mjs';
3
- import { SelectItemKey } from 'vuetify/lib/util/helpers.mjs';
4
-
5
- class datatableColonne<T = any> implements DataTableHeader<T> {
6
- key?: 'data-table-group' | 'data-table-select' | 'data-table-expand' | (string & {});
7
- value?: SelectItemKey<T>;
8
- title?: string;
9
- fixed?: boolean | 'start' | 'end';
10
- align?: 'start' | 'end' | 'center';
11
- width?: number | string;
12
- minWidth?: number | string;
13
- maxWidth?: number | string;
14
- nowrap?: boolean;
15
- intent?: number;
16
- headerProps?: Record<string, any>;
17
- cellProps?: HeaderCellProps;
18
- sortable?: boolean;
19
- sort?: DataTableCompareFunction;
20
- sortRaw?: DataTableCompareFunction;
21
- filter?: FilterFunction;
22
- children?: DataTableHeader<T>[];
23
-
24
- constructor(title: string, key: string) {
25
- this.title = title
26
- this.key = key
27
- this.align = key === 'action' ? 'end' : key === 'estActif' ? 'center' : 'start'
28
- this.sortable = key !== 'action'
29
- }
30
- }
31
- export default datatableColonne
1
+ import type { DataTableCompareFunction, DataTableHeader, FilterFunction } from 'vuetify'
2
+ import { HeaderCellProps } from 'vuetify/lib/components/VDataTable/types.mjs';
3
+ import { SelectItemKey } from 'vuetify/lib/util/helpers.mjs';
4
+
5
+ class datatableColonne<T = any> implements DataTableHeader<T> {
6
+ key?: 'data-table-group' | 'data-table-select' | 'data-table-expand' | (string & {});
7
+ value?: SelectItemKey<T>;
8
+ title?: string;
9
+ fixed?: boolean | 'start' | 'end';
10
+ align?: 'start' | 'end' | 'center';
11
+ width?: number | string;
12
+ minWidth?: number | string;
13
+ maxWidth?: number | string;
14
+ nowrap?: boolean;
15
+ intent?: number;
16
+ headerProps?: Record<string, any>;
17
+ cellProps?: HeaderCellProps;
18
+ sortable?: boolean;
19
+ sort?: DataTableCompareFunction;
20
+ sortRaw?: DataTableCompareFunction;
21
+ filter?: FilterFunction;
22
+ children?: DataTableHeader<T>[];
23
+
24
+ constructor(title: string, key: string) {
25
+ this.title = title
26
+ this.key = key
27
+ this.align = key === 'action' ? 'end' : key === 'estActif' ? 'center' : 'start'
28
+ this.sortable = key !== 'action'
29
+ }
30
+ }
31
+ export default datatableColonne
@@ -1,113 +1,113 @@
1
- import axios, { type AxiosInstance, type AxiosError, type AxiosResponse } from 'axios'
2
- import { useAppStore } from '@/store/appStore'
3
- import router from '@/router'
4
-
5
- type ApiReponse<T = unknown> =
6
- // Succès
7
- | {
8
- succes: true
9
- resultat: T
10
- status?: number
11
- message?: string
12
- location?: string
13
- parametres?: unknown
14
- [k: string]: unknown
15
- }
16
- // Échec (le backend peut quand même renvoyer resultat null/absent)
17
- | {
18
- succes: false
19
- resultat?: unknown
20
- status?: number
21
- message?: string
22
- location?: string
23
- parametres?: unknown
24
- [k: string]: unknown
25
- }
26
-
27
- let client: AxiosInstance | null = null
28
- let cachedBaseUrl = '' // pour éviter de régénérer une instance axios si rien n’a changé
29
-
30
- export default {
31
- clearCache: false,
32
-
33
- getAxios(): AxiosInstance {
34
- const appStore = useAppStore()
35
-
36
- const rawUrl = appStore.modeleCharger
37
- ? appStore.appModele!.urlBase
38
- : window.location.origin + import.meta.env.BASE_URL
39
-
40
- const urlBase = rawUrl.endsWith('/') ? rawUrl.slice(0, -1) : rawUrl
41
-
42
- // Si la base URL n'a pas changé et qu'on a déjà un client, on le renvoie
43
- if (client && cachedBaseUrl === urlBase && !this.clearCache) return client
44
- cachedBaseUrl = urlBase
45
-
46
- client = axios.create({
47
- baseURL: `${urlBase}/api`,
48
- withCredentials: true,
49
- timeout: 90_000,
50
- headers: {
51
- Accept: 'application/json',
52
- 'Content-Type': 'application/json',
53
- 'X-Requested-With': 'XMLHttpRequest',
54
- },
55
- // validateStatus: (s) => s >= 200 && s < 300, // défaut axios
56
- })
57
-
58
- client.interceptors.response.use(
59
- (response: AxiosResponse<any>) => {
60
- const data = response.data
61
-
62
- // Détection de la réponse { succes, resultat }
63
- if (data && typeof data === 'object' && 'succes' in data) {
64
- const env = data as ApiReponse
65
- return env.succes === true ? env.resultat : Promise.reject(env)
66
- }
67
-
68
- // Sinon, renvoyer data si présent, sinon la réponse complète
69
- return data ?? response
70
- },
71
-
72
- (error: AxiosError<any>) => {
73
- const status = error.response?.status
74
- const payload = error.response?.data?.resultat ?? { message: error.message }
75
- console.log("Status d'erreur : ", status)
76
- console.log("Contenu d'erreur", payload)
77
- // 403 / 404
78
- if (status === 403 || status === 404) {
79
- try {
80
- appStore.lancerErreur(payload)
81
- if (router.currentRoute.value.name !== '403') {
82
- router.push({ name: '403' })
83
- }
84
- } catch {
85
- // no-op
86
- }
87
- return Promise.reject(payload)
88
- }
89
-
90
- // gérer les autres 4XX ici
91
-
92
- // Log minimal
93
- console.error('HTTP error', {
94
- status,
95
- url: error.config?.url,
96
- payload,
97
- })
98
-
99
- // Remonter l’erreur normalisée dans appstore
100
- try {
101
- if (payload) appStore.lancerErreur(payload)
102
- } catch {
103
- // no-op
104
- }
105
- return Promise.reject(payload)
106
- },
107
- )
108
-
109
- // reset le flag si on l’avait utilisé pour forcer la recréation de l'instance
110
- this.clearCache = false
111
- return client
112
- },
113
- }
1
+ import axios, { type AxiosInstance, type AxiosError, type AxiosResponse } from 'axios'
2
+ import { useAppStore } from '@/store/appStore'
3
+ import router from '@/router'
4
+
5
+ type ApiReponse<T = unknown> =
6
+ // Succès
7
+ | {
8
+ succes: true
9
+ resultat: T
10
+ status?: number
11
+ message?: string
12
+ location?: string
13
+ parametres?: unknown
14
+ [k: string]: unknown
15
+ }
16
+ // Échec (le backend peut quand même renvoyer resultat null/absent)
17
+ | {
18
+ succes: false
19
+ resultat?: unknown
20
+ status?: number
21
+ message?: string
22
+ location?: string
23
+ parametres?: unknown
24
+ [k: string]: unknown
25
+ }
26
+
27
+ let client: AxiosInstance | null = null
28
+ let cachedBaseUrl = '' // pour éviter de régénérer une instance axios si rien n’a changé
29
+
30
+ export default {
31
+ clearCache: false,
32
+
33
+ getAxios(): AxiosInstance {
34
+ const appStore = useAppStore()
35
+
36
+ const rawUrl = appStore.modeleCharger
37
+ ? appStore.appModele!.urlBase
38
+ : window.location.origin + import.meta.env.BASE_URL
39
+
40
+ const urlBase = rawUrl.endsWith('/') ? rawUrl.slice(0, -1) : rawUrl
41
+
42
+ // Si la base URL n'a pas changé et qu'on a déjà un client, on le renvoie
43
+ if (client && cachedBaseUrl === urlBase && !this.clearCache) return client
44
+ cachedBaseUrl = urlBase
45
+
46
+ client = axios.create({
47
+ baseURL: `${urlBase}/api`,
48
+ withCredentials: true,
49
+ timeout: 90_000,
50
+ headers: {
51
+ Accept: 'application/json',
52
+ 'Content-Type': 'application/json',
53
+ 'X-Requested-With': 'XMLHttpRequest',
54
+ },
55
+ // validateStatus: (s) => s >= 200 && s < 300, // défaut axios
56
+ })
57
+
58
+ client.interceptors.response.use(
59
+ (response: AxiosResponse<any>) => {
60
+ const data = response.data
61
+
62
+ // Détection de la réponse { succes, resultat }
63
+ if (data && typeof data === 'object' && 'succes' in data) {
64
+ const env = data as ApiReponse
65
+ return env.succes === true ? env.resultat : Promise.reject(env)
66
+ }
67
+
68
+ // Sinon, renvoyer data si présent, sinon la réponse complète
69
+ return data ?? response
70
+ },
71
+
72
+ (error: AxiosError<any>) => {
73
+ const status = error.response?.status
74
+ const payload = error.response?.data?.resultat ?? { message: error.message }
75
+ console.log("Status d'erreur : ", status)
76
+ console.log("Contenu d'erreur", payload)
77
+ // 403 / 404
78
+ if (status === 403 || status === 404) {
79
+ try {
80
+ appStore.lancerErreur(payload)
81
+ if (router.currentRoute.value.name !== '403') {
82
+ router.push({ name: '403' })
83
+ }
84
+ } catch {
85
+ // no-op
86
+ }
87
+ return Promise.reject(payload)
88
+ }
89
+
90
+ // gérer les autres 4XX ici
91
+
92
+ // Log minimal
93
+ console.error('HTTP error', {
94
+ status,
95
+ url: error.config?.url,
96
+ payload,
97
+ })
98
+
99
+ // Remonter l’erreur normalisée dans appstore
100
+ try {
101
+ if (payload) appStore.lancerErreur(payload)
102
+ } catch {
103
+ // no-op
104
+ }
105
+ return Promise.reject(payload)
106
+ },
107
+ )
108
+
109
+ // reset le flag si on l’avait utilisé pour forcer la recréation de l'instance
110
+ this.clearCache = false
111
+ return client
112
+ },
113
+ }