@choosemycompany/lib 0.1.0
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/README.md +55 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.js +432 -0
- package/dist/types/errors.d.ts +15 -0
- package/dist/types/index.d.ts +8 -0
- package/dist/types/language.d.ts +2 -0
- package/dist/types/pagination.d.ts +12 -0
- package/dist/types/request.d.ts +7 -0
- package/dist/types/response.d.ts +8 -0
- package/dist/types/routes.d.ts +6 -0
- package/dist/types/store.d.ts +15 -0
- package/dist/types/view.d.ts +12 -0
- package/dist/useClickOutside.d.ts +2 -0
- package/dist/useCountriesTranslation.d.ts +6 -0
- package/dist/useErrorHandling.d.ts +5 -0
- package/dist/useGtagConversion.d.ts +8 -0
- package/dist/useHttp.d.ts +6 -0
- package/dist/useHubspotContactUrl.d.ts +3 -0
- package/dist/useImageCacheWatcherCallback.d.ts +2 -0
- package/dist/useLocaleHelpers.d.ts +6 -0
- package/dist/useParseTranslation.d.ts +6 -0
- package/dist/usePrimaryTypeTranslation.d.ts +3 -0
- package/dist/useResponsiveSize.d.ts +4 -0
- package/dist/useStore.d.ts +20 -0
- package/dist/useTranslate.d.ts +4 -0
- package/dist/useUrlHelpers.d.ts +8 -0
- package/package.json +62 -0
package/README.md
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# @choosemycompany/lib
|
|
2
|
+
|
|
3
|
+
Composables, stores et types partagés entre les apps front ChooseMyCompany (`commercial`, `workspace`).
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pnpm add @choosemycompany/lib
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Utilisation
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
import { useHttp, useStore, useUrlHelpers, type Store, type View } from '@choosemycompany/lib'
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Un seul entry point, tout est ré-exporté depuis `@choosemycompany/lib`.
|
|
18
|
+
|
|
19
|
+
## Dépendances
|
|
20
|
+
|
|
21
|
+
Le package s'attend à être consommé **dans un projet Nuxt 4** avec les peer deps suivantes installées :
|
|
22
|
+
|
|
23
|
+
- `vue`, `vue-i18n`, `vue-router`, `pinia`
|
|
24
|
+
- `mande` (client HTTP)
|
|
25
|
+
- `h3` (pour `useErrorHandling`)
|
|
26
|
+
- `ufo` (pour `useUrlHelpers`)
|
|
27
|
+
- `@nuxtjs/i18n` (`useLocalePath`)
|
|
28
|
+
- `nuxt` (pour les auto-imports `useRuntimeConfig`, `useState`, `showError`)
|
|
29
|
+
|
|
30
|
+
Les composables utilisant `useRuntimeConfig()`, `useRoute()`, `useI18n()` doivent être appelés dans un scope Nuxt (setup, plugin, middleware).
|
|
31
|
+
|
|
32
|
+
## Développement local (HMR via sandbox)
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
pnpm install
|
|
36
|
+
pnpm --filter sandbox dev # n'existe pas : sandbox est indépendant
|
|
37
|
+
# ou
|
|
38
|
+
cd sandbox && pnpm install && pnpm dev
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
La sandbox utilise un alias Vite `@choosemycompany/lib` → `../src/index.ts`, donc chaque modif des sources de la lib déclenche du HMR immédiat.
|
|
42
|
+
|
|
43
|
+
## Build & publish
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
pnpm build # vite build → dist/
|
|
47
|
+
pnpm typecheck
|
|
48
|
+
pnpm test
|
|
49
|
+
pnpm publish # via CI CircleCI sur push main
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Changements d'API notables
|
|
53
|
+
|
|
54
|
+
- `useStore` : signature unifiée qui absorbe la variante `workspace` (search, filters, 4ᵉ générique `FilterItem`). Méthode publique : `isPending(key)`. `getViewKey` trie les clés pour garantir un cache déterministe.
|
|
55
|
+
- `usePrimaryTypeTranslation(primaryTypes)` : reçoit désormais la liste des primaryTypes en argument au lieu de l'importer depuis `@/entities/form` de commercial.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export { useHttp } from './useHttp';
|
|
2
|
+
export { useStore, getViewKey, type Store } from './useStore';
|
|
3
|
+
export { useClickOutside } from './useClickOutside';
|
|
4
|
+
export { useCountriesTranslation, type CountryCodes } from './useCountriesTranslation';
|
|
5
|
+
export { showAndThrowError } from './useErrorHandling';
|
|
6
|
+
export { useGtagConversion } from './useGtagConversion';
|
|
7
|
+
export { useHubspotContactUrl } from './useHubspotContactUrl';
|
|
8
|
+
export { useImageCacheWatcherCallback } from './useImageCacheWatcherCallback';
|
|
9
|
+
export { useLocaleHelpers } from './useLocaleHelpers';
|
|
10
|
+
export { useParseTranslation } from './useParseTranslation';
|
|
11
|
+
export { usePrimaryTypeTranslation } from './usePrimaryTypeTranslation';
|
|
12
|
+
export { useResponsiveSize } from './useResponsiveSize';
|
|
13
|
+
export { useTranslate } from './useTranslate';
|
|
14
|
+
export { useUrlHelpers } from './useUrlHelpers';
|
|
15
|
+
export type { StoreOptions, RetrieveOptions, ListOptions, ViewKeyParams, View, ViewOptions, PaginatedQuery, Pagination, ListResponse, RetrieveResponse, RequestOptions, ErrorItem, MandeError, MandeErrorBody, Language, Translation, InternationalizedRoute, } from './types';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,432 @@
|
|
|
1
|
+
import { mande as P } from "mande";
|
|
2
|
+
import { useRuntimeConfig as S, showError as w, useState as T, useLocalePath as E } from "#imports";
|
|
3
|
+
import { ref as h, onMounted as I, onBeforeUnmount as y, computed as R, onUnmounted as L } from "vue";
|
|
4
|
+
import { useI18n as C } from "vue-i18n";
|
|
5
|
+
import { createError as z } from "h3";
|
|
6
|
+
import { useRoute as G } from "vue-router";
|
|
7
|
+
import { withBase as D } from "ufo";
|
|
8
|
+
let A;
|
|
9
|
+
function N() {
|
|
10
|
+
return A || (A = S().public.cmcApiUrl, A);
|
|
11
|
+
}
|
|
12
|
+
function Q() {
|
|
13
|
+
const a = N(), e = P(a, {
|
|
14
|
+
headers: {}
|
|
15
|
+
});
|
|
16
|
+
function t(n) {
|
|
17
|
+
e.options.headers = {
|
|
18
|
+
...e.options.headers ?? {},
|
|
19
|
+
Authorization: `Bearer ${n}`
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
function i() {
|
|
23
|
+
e.options.headers && delete e.options.headers.Authorization;
|
|
24
|
+
}
|
|
25
|
+
return { http: e, setToken: t, clearToken: i };
|
|
26
|
+
}
|
|
27
|
+
function K(a) {
|
|
28
|
+
return Object.entries(a).sort(([e], [t]) => e.localeCompare(t)).map(([e, t]) => `${e}=${t}`).join("|");
|
|
29
|
+
}
|
|
30
|
+
function Y(a) {
|
|
31
|
+
const e = h({}), t = h({}), i = h([]), n = h({}), r = h(""), d = h([]);
|
|
32
|
+
function s(c) {
|
|
33
|
+
return !!n.value[c];
|
|
34
|
+
}
|
|
35
|
+
async function l(c, f = {}) {
|
|
36
|
+
const u = c, { force: b = !1 } = f;
|
|
37
|
+
if (e.value[u] && !b)
|
|
38
|
+
return e.value[u];
|
|
39
|
+
if (!a.fetchOne || s(u))
|
|
40
|
+
return e.value[u] ?? void 0;
|
|
41
|
+
n.value[u] = !0;
|
|
42
|
+
try {
|
|
43
|
+
const o = await a.fetchOne(c), B = a.enrichItem ? a.enrichItem(o) : o;
|
|
44
|
+
return e.value[u] = B, e.value[u];
|
|
45
|
+
} catch (o) {
|
|
46
|
+
i.value.push(o);
|
|
47
|
+
return;
|
|
48
|
+
} finally {
|
|
49
|
+
n.value[u] = !1;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
async function p(c, f = {}) {
|
|
53
|
+
const u = K(c), { force: b = !1 } = f;
|
|
54
|
+
if (!(t.value[u] && !b) && !(!a.fetchPage || s(u))) {
|
|
55
|
+
n.value[u] = !0;
|
|
56
|
+
try {
|
|
57
|
+
const o = await a.fetchPage(c), B = o.items.map(
|
|
58
|
+
(m) => a.enrichItem ? a.enrichItem(m) : m
|
|
59
|
+
);
|
|
60
|
+
for (const m of B) {
|
|
61
|
+
const M = a.getItemId(m);
|
|
62
|
+
e.value[M] = m;
|
|
63
|
+
}
|
|
64
|
+
t.value[u] = {
|
|
65
|
+
items: B,
|
|
66
|
+
total: o.total,
|
|
67
|
+
hasMore: o.hasMore,
|
|
68
|
+
page: o.page,
|
|
69
|
+
limit: o.limit
|
|
70
|
+
};
|
|
71
|
+
} catch (o) {
|
|
72
|
+
i.value.push(o);
|
|
73
|
+
} finally {
|
|
74
|
+
n.value[u] = !1;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
function g() {
|
|
79
|
+
e.value = {}, t.value = {}, i.value = [], n.value = {}, r.value = "", d.value = [];
|
|
80
|
+
}
|
|
81
|
+
return { items: e, views: t, errors: i, search: r, filters: d, isPending: s, list: p, reset: g, retrieve: l };
|
|
82
|
+
}
|
|
83
|
+
function X(a, e) {
|
|
84
|
+
const t = (i) => {
|
|
85
|
+
const n = a.value, r = i.target;
|
|
86
|
+
!n || !r || n.contains(r) || e();
|
|
87
|
+
};
|
|
88
|
+
I(() => {
|
|
89
|
+
document.addEventListener("click", t);
|
|
90
|
+
}), y(() => {
|
|
91
|
+
document.removeEventListener("click", t);
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
function aa() {
|
|
95
|
+
const { locale: a } = C();
|
|
96
|
+
function e(t, i = null) {
|
|
97
|
+
const n = H[t.trim().toUpperCase()];
|
|
98
|
+
if (!n)
|
|
99
|
+
throw new Error(`Unknown country code: ${t}`);
|
|
100
|
+
if (i && n[i])
|
|
101
|
+
return n[i];
|
|
102
|
+
if (n[a.value])
|
|
103
|
+
return n[a.value];
|
|
104
|
+
if (a.value !== "en" && n.en)
|
|
105
|
+
return n.en;
|
|
106
|
+
throw new Error(`Unknown country code: ${t}`);
|
|
107
|
+
}
|
|
108
|
+
return e;
|
|
109
|
+
}
|
|
110
|
+
const H = {
|
|
111
|
+
AD: { en: "Andorra", fr: "Andorre", es: "Andorra", de: "Andorra", it: "Andorra", pt: "Andorra", da: "Andorra" },
|
|
112
|
+
AE: { en: "United Arab Emirates", fr: "Émirats arabes unis", es: "Emiratos Árabes Unidos", de: "Vereinigte Arabische Emirate", it: "Emirati Arabi Uniti", pt: "Emirados Árabes Unidos", da: "De Forenede Arabiske Emirater" },
|
|
113
|
+
AF: { en: "Afghanistan", fr: "Afghanistan", es: "Afganistán", de: "Afghanistan", it: "Afghanistan", pt: "Afeganistão", da: "Afghanistan" },
|
|
114
|
+
AG: { en: "Antigua And Barbuda", fr: "Antigua-et-Barbuda", es: "Antigua y Barbuda", de: "Antigua und Barbuda", it: "Antigua e Barbuda", pt: "Antígua e Barbuda", da: "Antigua og Barbuda" },
|
|
115
|
+
AL: { en: "Albania", fr: "Albanie", es: "Albania", de: "Albanien", it: "Albania", pt: "Albânia", da: "Albanien" },
|
|
116
|
+
AM: { en: "Armenia", fr: "Arménie", es: "Armenia", de: "Armenien", it: "Armenia", pt: "Armênia", da: "Armenien" },
|
|
117
|
+
AO: { en: "Angola", fr: "Angola", es: "Angola", de: "Angola", it: "Angola", pt: "Angola", da: "Angola" },
|
|
118
|
+
AR: { en: "Argentina", fr: "Argentine", es: "Argentina", de: "Argentinien", it: "Argentina", pt: "Argentina", da: "Argentina" },
|
|
119
|
+
AT: { en: "Austria", fr: "Autriche", es: "Austria", de: "Österreich", it: "Austria", pt: "Áustria", da: "Østrig" },
|
|
120
|
+
AU: { en: "Australia", fr: "Australie", es: "Australia", de: "Australien", it: "Australia", pt: "Austrália", da: "Australien" },
|
|
121
|
+
AZ: { en: "Azerbaijan", fr: "Azerbaïdjan", es: "Azerbaiyán", de: "Aserbaidschan", it: "Azerbaigian", pt: "Azerbaijão", da: "Aserbajdsjan" },
|
|
122
|
+
BA: { en: "Bosnia And Herzegovina", fr: "Bosnie-Herzégovine", es: "Bosnia y Herzegovina", de: "Bosnien und Herzegowina", it: "Bosnia ed Erzegovina", pt: "Bósnia e Herzegovina", da: "Bosnien-Hercegovina" },
|
|
123
|
+
BB: { en: "Barbados", fr: "Barbade", es: "Barbados", de: "Barbados", it: "Barbados", pt: "Barbados", da: "Barbados" },
|
|
124
|
+
BD: { en: "Bangladesh", fr: "Bangladesh", es: "Bangladesh", de: "Bangladesch", it: "Bangladesh", pt: "Bangladesh", da: "Bangladesh" },
|
|
125
|
+
BE: { en: "Belgium", fr: "Belgique", es: "Bélgica", de: "Belgien", it: "Belgio", pt: "Bélgica", da: "Belgien" },
|
|
126
|
+
BF: { en: "Burkina Faso", fr: "Burkina Faso", es: "Burkina Faso", de: "Burkina Faso", it: "Burkina Faso", pt: "Burkina Faso", da: "Burkina Faso" },
|
|
127
|
+
BG: { en: "Bulgaria", fr: "Bulgarie", es: "Bulgaria", de: "Bulgarien", it: "Bulgaria", pt: "Bulgária", da: "Bulgarien" },
|
|
128
|
+
BH: { en: "Bahrain", fr: "Bahreïn", es: "Baréin", de: "Bahrain", it: "Bahrein", pt: "Bahrein", da: "Bahrain" },
|
|
129
|
+
BI: { en: "Burundi", fr: "Burundi", es: "Burundi", de: "Burundi", it: "Burundi", pt: "Burundi", da: "Burundi" },
|
|
130
|
+
BJ: { en: "Benin", fr: "Bénin", es: "Benín", de: "Benin", it: "Benin", pt: "Benim", da: "Benin" },
|
|
131
|
+
BM: { en: "Bermuda", fr: "Bermudes", es: "Bermudas", de: "Bermuda", it: "Bermuda", pt: "Bermudas", da: "Bermuda" },
|
|
132
|
+
BN: { en: "Brunei Darussalam", fr: "Brunei Darussalam", es: "Brunéi Darussalam", de: "Brunei Darussalam", it: "Brunei Darussalam", pt: "Brunei Darussalam", da: "Brunei Darussalam" },
|
|
133
|
+
BO: { en: "Bolivia", fr: "Bolivie", es: "Bolivia", de: "Bolivien", it: "Bolivia", pt: "Bolívia", da: "Bolivia" },
|
|
134
|
+
BR: { en: "Brazil", fr: "Brésil", es: "Brasil", de: "Brasilien", it: "Brasile", pt: "Brasil", da: "Brasilien" },
|
|
135
|
+
BS: { en: "Bahamas", fr: "Bahamas", es: "Bahamas", de: "Bahamas", it: "Bahamas", pt: "Bahamas", da: "Bahamas" },
|
|
136
|
+
BT: { en: "Bhutan", fr: "Bhoutan", es: "Bután", de: "Bhutan", it: "Bhutan", pt: "Butão", da: "Bhutan" },
|
|
137
|
+
BW: { en: "Botswana", fr: "Botswana", es: "Botsuana", de: "Botswana", it: "Botswana", pt: "Botsuana", da: "Botswana" },
|
|
138
|
+
BY: { en: "Belarus", fr: "Biélorussie", es: "Bielorrusia", de: "Weißrussland", it: "Bielorussia", pt: "Bielorrússia", da: "Hviderusland" },
|
|
139
|
+
BZ: { en: "Belize", fr: "Belize", es: "Belice", de: "Belize", it: "Belize", pt: "Belize", da: "Belize" },
|
|
140
|
+
CA: { en: "Canada", fr: "Canada", es: "Canadá", de: "Kanada", it: "Canada", pt: "Canadá", da: "Canada" },
|
|
141
|
+
CD: { en: "Congo Democratic Republic", fr: "Congo République Démocratique", es: "Congo República Democrática", de: "Kongo Demokratische Republik", it: "Congo Repubblica Democratica", pt: "Congo República Democrática", da: "Congo Demokratiske Republik" },
|
|
142
|
+
CF: { en: "Central African Republic", fr: "République Centrafricaine", es: "República Centroafricana", de: "Zentralafrikanische Republik", it: "Repubblica Centrafricana", pt: "República Centro-Africana", da: "Centralafrikanske Republik" },
|
|
143
|
+
CG: { en: "Congo", fr: "Congo", es: "Congo", de: "Kongo", it: "Congo", pt: "Congo", da: "Congo" },
|
|
144
|
+
CH: { en: "Switzerland", fr: "Suisse", es: "Suiza", de: "Schweiz", it: "Svizzera", pt: "Suíça", da: "Schweiz" },
|
|
145
|
+
CI: { en: "Ivory Coast", fr: "Côte D'Ivoire", es: "Costa de Marfil", de: "Elfenbeinküste", it: "Costa d'Avorio", pt: "Costa do Marfim", da: "Elfenbenskysten" },
|
|
146
|
+
CL: { en: "Chile", fr: "Chili", es: "Chile", de: "Chile", it: "Cile", pt: "Chile", da: "Chile" },
|
|
147
|
+
CM: { en: "Cameroon", fr: "Cameroun", es: "Camerún", de: "Kamerun", it: "Camerun", pt: "Camarões", da: "Cameroon" },
|
|
148
|
+
CN: { en: "China", fr: "Chine", es: "China", de: "China", it: "Cina", pt: "China", da: "Kina" },
|
|
149
|
+
CO: { en: "Colombia", fr: "Colombie", es: "Colombia", de: "Kolumbien", it: "Colombia", pt: "Colômbia", da: "Colombia" },
|
|
150
|
+
CR: { en: "Costa Rica", fr: "Costa Rica", es: "Costa Rica", de: "Costa Rica", it: "Costa Rica", pt: "Costa Rica", da: "Costa Rica" },
|
|
151
|
+
CU: { en: "Cuba", fr: "Cuba", es: "Cuba", de: "Kuba", it: "Cuba", pt: "Cuba", da: "Cuba" },
|
|
152
|
+
CY: { en: "Cyprus", fr: "Chypre", es: "Chipre", de: "Zypern", it: "Cipro", pt: "Chipre", da: "Cypern" },
|
|
153
|
+
CZ: { en: "Czech Republic", fr: "République Tchèque", es: "República Checa", de: "Tschechische Republik", it: "Repubblica Ceca", pt: "República Checa", da: "Tjekkiet" },
|
|
154
|
+
DE: { en: "Germany", fr: "Allemagne", es: "Alemania", de: "Deutschland", it: "Germania", pt: "Alemanha", da: "Tyskland" },
|
|
155
|
+
DJ: { en: "Djibouti", fr: "Djibouti", es: "Yibuti", de: "Dschibuti", it: "Gibuti", pt: "Djibuti", da: "Djibouti" },
|
|
156
|
+
DK: { en: "Denmark", fr: "Danemark", es: "Dinamarca", de: "Dänemark", it: "Danimarca", pt: "Dinamarca", da: "Danmark" },
|
|
157
|
+
DO: { en: "Dominican Republic", fr: "République Dominicaine", es: "República Dominicana", de: "Dominikanische Republik", it: "Repubblica Dominicana", pt: "República Dominicana", da: "Den Dominikanske Republik" },
|
|
158
|
+
DZ: { en: "Algeria", fr: "Algérie", es: "Argelia", de: "Algerien", it: "Algeria", pt: "Argélia", da: "Algeriet" },
|
|
159
|
+
EC: { en: "Ecuador", fr: "Équateur", es: "Ecuador", de: "Ecuador", it: "Ecuador", pt: "Equador", da: "Ecuador" },
|
|
160
|
+
EE: { en: "Estonia", fr: "Estonie", es: "Estonia", de: "Estland", it: "Estonia", pt: "Estônia", da: "Estland" },
|
|
161
|
+
EG: { en: "Egypt", fr: "Égypte", es: "Egipto", de: "Ägypten", it: "Egitto", pt: "Egito", da: "Egypten" },
|
|
162
|
+
ES: { en: "Spain", fr: "Espagne", es: "España", de: "Spanien", it: "Spagna", pt: "Espanha", da: "Spanien" },
|
|
163
|
+
ET: { en: "Ethiopia", fr: "Éthiopie", es: "Etiopía", de: "Äthiopien", it: "Etiopia", pt: "Etiópia", da: "Etiopien" },
|
|
164
|
+
FI: { en: "Finland", fr: "Finlande", es: "Finlandia", de: "Finnland", it: "Finlandia", pt: "Finlândia", da: "Finland" },
|
|
165
|
+
FR: { en: "France", fr: "France", es: "Francia", de: "Frankreich", it: "Francia", pt: "França", da: "Frankrig" },
|
|
166
|
+
GA: { en: "Gabon", fr: "Gabon", es: "Gabón", de: "Gabun", it: "Gabon", pt: "Gabão", da: "Gabon" },
|
|
167
|
+
GB: { en: "United Kingdom", fr: "Royaume-Uni", es: "Reino Unido", de: "Vereinigtes Königreich", it: "Regno Unito", pt: "Reino Unido", da: "Storbritannien" },
|
|
168
|
+
GE: { en: "Georgia", fr: "Géorgie", es: "Georgia", de: "Georgien", it: "Georgia", pt: "Geórgia", da: "Georgien" },
|
|
169
|
+
GH: { en: "Ghana", fr: "Ghana", es: "Ghana", de: "Ghana", it: "Ghana", pt: "Gana", da: "Ghana" },
|
|
170
|
+
GR: { en: "Greece", fr: "Grèce", es: "Grecia", de: "Griechenland", it: "Grecia", pt: "Grécia", da: "Grækenland" },
|
|
171
|
+
GT: { en: "Guatemala", fr: "Guatemala", es: "Guatemala", de: "Guatemala", it: "Guatemala", pt: "Guatemala", da: "Guatemala" },
|
|
172
|
+
HK: { en: "Hong Kong", fr: "Hong Kong", es: "Hong Kong", de: "Hongkong", it: "Hong Kong", pt: "Hong Kong", da: "Hongkong" },
|
|
173
|
+
HN: { en: "Honduras", fr: "Honduras", es: "Honduras", de: "Honduras", it: "Honduras", pt: "Honduras", da: "Honduras" },
|
|
174
|
+
HR: { en: "Croatia", fr: "Croatie", es: "Croacia", de: "Kroatien", it: "Croazia", pt: "Croácia", da: "Kroatien" },
|
|
175
|
+
HT: { en: "Haiti", fr: "Haïti", es: "Haití", de: "Haiti", it: "Haiti", pt: "Haiti", da: "Haiti" },
|
|
176
|
+
HU: { en: "Hungary", fr: "Hongrie", es: "Hungría", de: "Ungarn", it: "Ungheria", pt: "Hungria", da: "Ungarn" },
|
|
177
|
+
ID: { en: "Indonesia", fr: "Indonésie", es: "Indonesia", de: "Indonesien", it: "Indonesia", pt: "Indonésia", da: "Indonesien" },
|
|
178
|
+
IE: { en: "Ireland", fr: "Irlande", es: "Irlanda", de: "Irland", it: "Irlanda", pt: "Irlanda", da: "Irland" },
|
|
179
|
+
IL: { en: "Israel", fr: "Israël", es: "Israel", de: "Israel", it: "Israele", pt: "Israel", da: "Israel" },
|
|
180
|
+
IN: { en: "India", fr: "Inde", es: "India", de: "Indien", it: "India", pt: "Índia", da: "Indien" },
|
|
181
|
+
INT: { en: "International", fr: "International", es: "Internacional", de: "International", it: "Internazionale", pt: "Internacional", da: "International" },
|
|
182
|
+
IQ: { en: "Iraq", fr: "Irak", es: "Irak", de: "Irak", it: "Iraq", pt: "Iraque", da: "Irak" },
|
|
183
|
+
IR: { en: "Iran Islamic Republic Of", fr: "Iran République Islamique D'", es: "Irán República Islámica De", de: "Iran Islamische Republik Von", it: "Iran Repubblica Islamica Di", pt: "Irã República Islâmica De", da: "Iran Islamiske Republik Af" },
|
|
184
|
+
IS: { en: "Iceland", fr: "Islande", es: "Islandia", de: "Island", it: "Islanda", pt: "Islândia", da: "Island" },
|
|
185
|
+
IT: { en: "Italy", fr: "Italie", es: "Italia", de: "Italien", it: "Italia", pt: "Itália", da: "Italien" },
|
|
186
|
+
JM: { en: "Jamaica", fr: "Jamaïque", es: "Jamaica", de: "Jamaika", it: "Giamaica", pt: "Jamaica", da: "Jamaica" },
|
|
187
|
+
JO: { en: "Jordan", fr: "Jordanie", es: "Jordania", de: "Jordanien", it: "Giordania", pt: "Jordânia", da: "Jordan" },
|
|
188
|
+
JP: { en: "Japan", fr: "Japon", es: "Japón", de: "Japan", it: "Giappone", pt: "Japão", da: "Japan" },
|
|
189
|
+
KE: { en: "Kenya", fr: "Kenya", es: "Kenia", de: "Kenia", it: "Kenya", pt: "Quênia", da: "Kenya" },
|
|
190
|
+
KR: { en: "Korea Republic of", fr: "Corée République de", es: "Corea República de", de: "Korea Republik von", it: "Corea Repubblica di", pt: "Coreia República da", da: "Korea Republik af" },
|
|
191
|
+
KW: { en: "Kuwait", fr: "Koweït", es: "Kuwait", de: "Kuwait", it: "Kuwait", pt: "Kuwait", da: "Kuwait" },
|
|
192
|
+
KZ: { en: "Kazakhstan", fr: "Kazakhstan", es: "Kazajistán", de: "Kasachstan", it: "Kazakistan", pt: "Cazaquistão", da: "Kasakhstan" },
|
|
193
|
+
LB: { en: "Lebanon", fr: "Liban", es: "Líbano", de: "Libanon", it: "Libano", pt: "Líbano", da: "Libanon" },
|
|
194
|
+
LK: { en: "Sri Lanka", fr: "Sri Lanka", es: "Sri Lanka", de: "Sri Lanka", it: "Sri Lanka", pt: "Sri Lanka", da: "Sri Lanka" },
|
|
195
|
+
LT: { en: "Lithuania", fr: "Lituanie", es: "Lituania", de: "Litauen", it: "Lituania", pt: "Lituânia", da: "Litauen" },
|
|
196
|
+
LU: { en: "Luxembourg", fr: "Luxembourg", es: "Luxemburgo", de: "Luxemburg", it: "Lussemburgo", pt: "Luxemburgo", da: "Luxembourg" },
|
|
197
|
+
LV: { en: "Latvia", fr: "Lettonie", es: "Letonia", de: "Lettland", it: "Lettonia", pt: "Letônia", da: "Letland" },
|
|
198
|
+
MA: { en: "Morocco", fr: "Maroc", es: "Marruecos", de: "Marokko", it: "Marocco", pt: "Marrocos", da: "Marokko" },
|
|
199
|
+
MD: { en: "Moldova", fr: "Moldavie", es: "Moldavia", de: "Moldawien", it: "Moldavia", pt: "Moldávia", da: "Moldova" },
|
|
200
|
+
MG: { en: "Madagascar", fr: "Madagascar", es: "Madagascar", de: "Madagaskar", it: "Madagascar", pt: "Madagáscar", da: "Madagaskar" },
|
|
201
|
+
MK: { en: "Macedonia", fr: "Macédoine", es: "Macedonia", de: "Mazedonien", it: "Macedonia", pt: "Macedônia", da: "Makedonien" },
|
|
202
|
+
ML: { en: "Mali", fr: "Mali", es: "Malí", de: "Mali", it: "Mali", pt: "Mali", da: "Mali" },
|
|
203
|
+
MM: { en: "Myanmar", fr: "Myanmar", es: "Myanmar", de: "Myanmar", it: "Myanmar", pt: "Mianmar", da: "Myanmar" },
|
|
204
|
+
MN: { en: "Mongolia", fr: "Mongolie", es: "Mongolia", de: "Mongolei", it: "Mongolia", pt: "Mongólia", da: "Mongoliet" },
|
|
205
|
+
MT: { en: "Malta", fr: "Malte", es: "Malta", de: "Malta", it: "Malta", pt: "Malta", da: "Malta" },
|
|
206
|
+
MU: { en: "Mauritius", fr: "Maurice", es: "Mauricio", de: "Mauritius", it: "Mauritius", pt: "Maurícia", da: "Mauritius" },
|
|
207
|
+
MX: { en: "Mexico", fr: "Mexique", es: "México", de: "Mexiko", it: "Messico", pt: "México", da: "Mexico" },
|
|
208
|
+
MY: { en: "Malaysia", fr: "Malaisie", es: "Malasia", de: "Malaysia", it: "Malesia", pt: "Malásia", da: "Malaysia" },
|
|
209
|
+
MZ: { en: "Mozambique", fr: "Mozambique", es: "Mozambique", de: "Mosambik", it: "Mozambico", pt: "Moçambique", da: "Mozambique" },
|
|
210
|
+
NA: { en: "Namibia", fr: "Namibie", es: "Namibia", de: "Namibia", it: "Namibia", pt: "Namíbia", da: "Namibia" },
|
|
211
|
+
NG: { en: "Nigeria", fr: "Nigéria", es: "Nigeria", de: "Nigeria", it: "Nigeria", pt: "Nigéria", da: "Nigeria" },
|
|
212
|
+
NL: { en: "Netherlands", fr: "Pays-Bas", es: "Países Bajos", de: "Niederlande", it: "Paesi Bassi", pt: "Países Baixos", da: "Nederlandene" },
|
|
213
|
+
NO: { en: "Norway", fr: "Norvège", es: "Noruega", de: "Norwegen", it: "Norvegia", pt: "Noruega", da: "Norge" },
|
|
214
|
+
NZ: { en: "New Zealand", fr: "Nouvelle-Zélande", es: "Nueva Zelanda", de: "Neuseeland", it: "Nuova Zelanda", pt: "Nova Zelândia", da: "New Zealand" },
|
|
215
|
+
OM: { en: "Oman", fr: "Oman", es: "Omán", de: "Oman", it: "Oman", pt: "Omã", da: "Oman" },
|
|
216
|
+
PA: { en: "Panama", fr: "Panama", es: "Panamá", de: "Panama", it: "Panama", pt: "Panamá", da: "Panama" },
|
|
217
|
+
PE: { en: "Peru", fr: "Pérou", es: "Perú", de: "Peru", it: "Perù", pt: "Peru", da: "Peru" },
|
|
218
|
+
PH: { en: "Philippines", fr: "Philippines", es: "Filipinas", de: "Philippinen", it: "Filippine", pt: "Filipinas", da: "Filippinerne" },
|
|
219
|
+
PK: { en: "Pakistan", fr: "Pakistan", es: "Pakistán", de: "Pakistan", it: "Pakistan", pt: "Paquistão", da: "Pakistan" },
|
|
220
|
+
PL: { en: "Poland", fr: "Pologne", es: "Polonia", de: "Polen", it: "Polonia", pt: "Polônia", da: "Polen" },
|
|
221
|
+
PS: { en: "Palestine", fr: "Palestine", es: "Palestina", de: "Palästina", it: "Palestina", pt: "Palestina", da: "Palæstina" },
|
|
222
|
+
PT: { en: "Portugal", fr: "Portugal", es: "Portugal", de: "Portugal", it: "Portogallo", pt: "Portugal", da: "Portugal" },
|
|
223
|
+
PY: { en: "Paraguay", fr: "Paraguay", es: "Paraguay", de: "Paraguay", it: "Paraguay", pt: "Paraguai", da: "Paraguay" },
|
|
224
|
+
QA: { en: "Qatar", fr: "Qatar", es: "Catar", de: "Katar", it: "Qatar", pt: "Catar", da: "Qatar" },
|
|
225
|
+
RO: { en: "Romania", fr: "Roumanie", es: "Rumania", de: "Rumänien", it: "Romania", pt: "Romênia", da: "Rumænien" },
|
|
226
|
+
RS: { en: "Serbia", fr: "Serbie", es: "Serbia", de: "Serbien", it: "Serbia", pt: "Sérvia", da: "Serbien" },
|
|
227
|
+
RU: { en: "Russia", fr: "Russie", es: "Rusia", de: "Russland", it: "Russia", pt: "Rússia", da: "Rusland" },
|
|
228
|
+
SA: { en: "Saudi Arabia", fr: "Arabie Saoudite", es: "Arabia Saudita", de: "Saudi-Arabien", it: "Arabia Saudita", pt: "Arábia Saudita", da: "Saudi-Arabien" },
|
|
229
|
+
SE: { en: "Sweden", fr: "Suède", es: "Suecia", de: "Schweden", it: "Svezia", pt: "Suécia", da: "Sverige" },
|
|
230
|
+
SG: { en: "Singapore", fr: "Singapour", es: "Singapur", de: "Singapur", it: "Singapore", pt: "Singapura", da: "Singapore" },
|
|
231
|
+
SI: { en: "Slovenia", fr: "Slovénie", es: "Eslovenia", de: "Slowenien", it: "Slovenia", pt: "Eslovênia", da: "Slovenien" },
|
|
232
|
+
SK: { en: "Slovakia", fr: "Slovaquie", es: "Eslovaquia", de: "Slowakei", it: "Slovacchia", pt: "Eslováquia", da: "Slovakiet" },
|
|
233
|
+
SN: { en: "Senegal", fr: "Sénégal", es: "Senegal", de: "Senegal", it: "Senegal", pt: "Senegal", da: "Senegal" },
|
|
234
|
+
TH: { en: "Thailand", fr: "Thaïlande", es: "Tailandia", de: "Thailand", it: "Thailandia", pt: "Tailândia", da: "Thailand" },
|
|
235
|
+
TN: { en: "Tunisia", fr: "Tunisie", es: "Túnez", de: "Tunesien", it: "Tunisia", pt: "Tunísia", da: "Tunesien" },
|
|
236
|
+
TR: { en: "Turkey", fr: "Turquie", es: "Turquía", de: "Türkei", it: "Turchia", pt: "Turquia", da: "Tyrkiet" },
|
|
237
|
+
TW: { en: "Taiwan", fr: "Taïwan", es: "Taiwán", de: "Taiwan", it: "Taiwan", pt: "Taiwan", da: "Taiwan" },
|
|
238
|
+
TZ: { en: "Tanzania", fr: "Tanzanie", es: "Tanzania", de: "Tansania", it: "Tanzania", pt: "Tanzânia", da: "Tanzania" },
|
|
239
|
+
UA: { en: "Ukraine", fr: "Ukraine", es: "Ucrania", de: "Ukraine", it: "Ucraina", pt: "Ucrânia", da: "Ukraine" },
|
|
240
|
+
UG: { en: "Uganda", fr: "Ouganda", es: "Uganda", de: "Uganda", it: "Uganda", pt: "Uganda", da: "Uganda" },
|
|
241
|
+
US: { en: "United States", fr: "États-Unis", es: "Estados Unidos", de: "Vereinigte Staaten", it: "Stati Uniti", pt: "Estados Unidos", da: "USA" },
|
|
242
|
+
UY: { en: "Uruguay", fr: "Uruguay", es: "Uruguay", de: "Uruguay", it: "Uruguay", pt: "Uruguai", da: "Uruguay" },
|
|
243
|
+
VE: { en: "Venezuela", fr: "Venezuela", es: "Venezuela", de: "Venezuela", it: "Venezuela", pt: "Venezuela", da: "Venezuela" },
|
|
244
|
+
VN: { en: "Vietnam", fr: "Viêt Nam", es: "Vietnam", de: "Vietnam", it: "Vietnam", pt: "Vietnã", da: "Vietnam" },
|
|
245
|
+
ZA: { en: "South Africa", fr: "Afrique Du Sud", es: "Sudáfrica", de: "Südafrika", it: "Sudafrica", pt: "África Do Sul", da: "Sydafrika" },
|
|
246
|
+
ZM: { en: "Zambia", fr: "Zambie", es: "Zambia", de: "Sambia", it: "Zambia", pt: "Zâmbia", da: "Zambia" },
|
|
247
|
+
ZW: { en: "Zimbabwe", fr: "Zimbabwe", es: "Zimbabue", de: "Simbabwe", it: "Zimbabwe", pt: "Zimbábue", da: "Zimbabwe" }
|
|
248
|
+
}, ea = ({ code: a, message: e, data: t }) => {
|
|
249
|
+
const i = e || "An unexpected error occurred", n = z({
|
|
250
|
+
statusCode: a,
|
|
251
|
+
statusMessage: i,
|
|
252
|
+
message: i,
|
|
253
|
+
data: t
|
|
254
|
+
});
|
|
255
|
+
throw w(n), n;
|
|
256
|
+
}, F = "ilcJCL_lmpwcEJfSkKND";
|
|
257
|
+
function na() {
|
|
258
|
+
const { gtagId: a } = S().public;
|
|
259
|
+
return { reportConversion: () => {
|
|
260
|
+
if (typeof window > "u" || typeof window.gtag > "u" || !a)
|
|
261
|
+
return;
|
|
262
|
+
const t = `${a}/${F}`;
|
|
263
|
+
window.gtag("event", "conversion", {
|
|
264
|
+
send_to: t
|
|
265
|
+
});
|
|
266
|
+
} };
|
|
267
|
+
}
|
|
268
|
+
const v = "https://5509641.hs-sites-eu1.com";
|
|
269
|
+
function ia() {
|
|
270
|
+
const { locale: a } = C();
|
|
271
|
+
return { contactUrl: R(() => a.value === "fr" ? `${v}/contact` : `${v}/${a.value}/contact`) };
|
|
272
|
+
}
|
|
273
|
+
function ta() {
|
|
274
|
+
async function a(i) {
|
|
275
|
+
await Promise.all(
|
|
276
|
+
i.map(
|
|
277
|
+
(n) => new Promise((r) => {
|
|
278
|
+
if (!n) return r(null);
|
|
279
|
+
const d = new Image();
|
|
280
|
+
d.onload = () => r(null), d.onerror = () => r(null), d.src = n;
|
|
281
|
+
})
|
|
282
|
+
)
|
|
283
|
+
);
|
|
284
|
+
}
|
|
285
|
+
function e(i, n) {
|
|
286
|
+
return n.split(".").reduce((r, d) => r && typeof r == "object" && d in r ? r[d] : "", i) ?? "";
|
|
287
|
+
}
|
|
288
|
+
function t(i, n, r) {
|
|
289
|
+
if (import.meta.server)
|
|
290
|
+
return async (s) => {
|
|
291
|
+
i.value = !0;
|
|
292
|
+
};
|
|
293
|
+
const d = T(
|
|
294
|
+
`${n}LoadedImageCache`,
|
|
295
|
+
() => ({})
|
|
296
|
+
);
|
|
297
|
+
return async (s) => {
|
|
298
|
+
if (!s) {
|
|
299
|
+
i.value = !1;
|
|
300
|
+
return;
|
|
301
|
+
}
|
|
302
|
+
const l = r.map((c) => e(s, c)), p = `${n}|${l.join("|")}`;
|
|
303
|
+
if (d.value[p]) {
|
|
304
|
+
i.value = !0;
|
|
305
|
+
return;
|
|
306
|
+
}
|
|
307
|
+
i.value = !1;
|
|
308
|
+
const g = l.filter(Boolean).map(String);
|
|
309
|
+
await a(g), d.value[p] = !0, i.value = !0;
|
|
310
|
+
};
|
|
311
|
+
}
|
|
312
|
+
return t;
|
|
313
|
+
}
|
|
314
|
+
const q = {
|
|
315
|
+
en: ["US", "UK"]
|
|
316
|
+
}, Z = "FR";
|
|
317
|
+
function $(a) {
|
|
318
|
+
const e = a.trim().replace("_", "-"), [t, i] = e.split("-");
|
|
319
|
+
return {
|
|
320
|
+
language: t?.toLowerCase() ?? "",
|
|
321
|
+
region: i?.toUpperCase() ?? ""
|
|
322
|
+
};
|
|
323
|
+
}
|
|
324
|
+
function k(a) {
|
|
325
|
+
return a.toString().trim().toUpperCase();
|
|
326
|
+
}
|
|
327
|
+
function ra() {
|
|
328
|
+
function a(e, t) {
|
|
329
|
+
if (!t.length) return;
|
|
330
|
+
const i = t.map(k), n = new Set(i), { language: r, region: d } = $(e), s = [];
|
|
331
|
+
d && s.push(d);
|
|
332
|
+
const l = q[r];
|
|
333
|
+
l?.length && s.push(...l.map(k)), r && s.push(r.toUpperCase()), s.push(Z);
|
|
334
|
+
for (const p of s)
|
|
335
|
+
if (n.has(p))
|
|
336
|
+
return p;
|
|
337
|
+
return i[0];
|
|
338
|
+
}
|
|
339
|
+
return { getRegionFromLocale: a };
|
|
340
|
+
}
|
|
341
|
+
function oa() {
|
|
342
|
+
const { t: a } = C();
|
|
343
|
+
function e(t, i) {
|
|
344
|
+
const n = a(t), r = [], s = i.map((f) => f.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("|"), l = new RegExp(`\\[(${s})\\]([\\s\\S]*?)\\[\\/\\1\\]`, "g"), p = i.reduce((f, u) => (f[u] = !1, f), {});
|
|
345
|
+
let g = 0, c = l.exec(n);
|
|
346
|
+
for (; c; ) {
|
|
347
|
+
const { index: f, 0: u, 1: b, 2: o } = c;
|
|
348
|
+
f > g && r.push({ text: n.slice(g, f), ...p }), o && b && r.push({ text: o, ...p, [b]: !0 }), g = f + u.length, c = l.exec(n);
|
|
349
|
+
}
|
|
350
|
+
return g < n.length && r.push({ text: n.slice(g), ...p }), r;
|
|
351
|
+
}
|
|
352
|
+
return { parse: e };
|
|
353
|
+
}
|
|
354
|
+
function sa(a) {
|
|
355
|
+
const { t: e, te: t, tm: i } = C();
|
|
356
|
+
function n(r, d) {
|
|
357
|
+
const s = `${r}.${d}`, l = `${r}.${a[0]}`;
|
|
358
|
+
return t(s) ? e(s) : t(l) ? e(l) : typeof i(r) == "string" ? e(r, {
|
|
359
|
+
primaryType: e(`common.primary-type.${d}`).toLowerCase()
|
|
360
|
+
}) : "";
|
|
361
|
+
}
|
|
362
|
+
return { getPrimaryTypeTranslation: n };
|
|
363
|
+
}
|
|
364
|
+
function da(a, e, t = 768) {
|
|
365
|
+
const i = h(t - 1), n = R(
|
|
366
|
+
() => i.value >= t ? e : a
|
|
367
|
+
);
|
|
368
|
+
if (import.meta.client) {
|
|
369
|
+
const r = () => {
|
|
370
|
+
i.value = window.innerWidth;
|
|
371
|
+
};
|
|
372
|
+
I(() => {
|
|
373
|
+
r(), window.addEventListener("resize", r);
|
|
374
|
+
}), L(() => {
|
|
375
|
+
window.removeEventListener("resize", r);
|
|
376
|
+
});
|
|
377
|
+
}
|
|
378
|
+
return { size: n, windowWidth: i };
|
|
379
|
+
}
|
|
380
|
+
function ua() {
|
|
381
|
+
const { locale: a } = C();
|
|
382
|
+
function e(t, i = "fr") {
|
|
383
|
+
if (!t) return "";
|
|
384
|
+
const n = a.value;
|
|
385
|
+
return t[n] ?? t[i] ?? "";
|
|
386
|
+
}
|
|
387
|
+
return e;
|
|
388
|
+
}
|
|
389
|
+
function la() {
|
|
390
|
+
const a = S(), { locale: e } = C(), t = G(), i = E(), n = a.public.cmcAssetsUrl, r = a.public.cmcCorporateWebsiteUrl, d = a.public.siteUrl;
|
|
391
|
+
function s(o) {
|
|
392
|
+
return `${n}${o}`;
|
|
393
|
+
}
|
|
394
|
+
const l = s("/img/public-site/default-banner.png"), p = s("/img/public-site/default-logo.png");
|
|
395
|
+
function g(o) {
|
|
396
|
+
return o || l;
|
|
397
|
+
}
|
|
398
|
+
function c(o) {
|
|
399
|
+
return o || p;
|
|
400
|
+
}
|
|
401
|
+
function f(o) {
|
|
402
|
+
return `${r}${o}`;
|
|
403
|
+
}
|
|
404
|
+
function u(o) {
|
|
405
|
+
return `${d}/${e.value}/${o}`;
|
|
406
|
+
}
|
|
407
|
+
function b(o = "home") {
|
|
408
|
+
const B = String(t.name || "");
|
|
409
|
+
if (B === o || B.startsWith(`${o}__`) || B.startsWith(`${o}___`))
|
|
410
|
+
return;
|
|
411
|
+
const m = i(o), M = `/${e.value}`, U = !m || m === "/" || m.startsWith("/_") ? M : m;
|
|
412
|
+
return D(U, a.app.baseURL);
|
|
413
|
+
}
|
|
414
|
+
return { getCoverUrl: g, getLogoUrl: c, getCorporateUrl: f, getAssetsUrl: s, getSiteUrl: u, getHomeUrl: b };
|
|
415
|
+
}
|
|
416
|
+
export {
|
|
417
|
+
K as getViewKey,
|
|
418
|
+
ea as showAndThrowError,
|
|
419
|
+
X as useClickOutside,
|
|
420
|
+
aa as useCountriesTranslation,
|
|
421
|
+
na as useGtagConversion,
|
|
422
|
+
Q as useHttp,
|
|
423
|
+
ia as useHubspotContactUrl,
|
|
424
|
+
ta as useImageCacheWatcherCallback,
|
|
425
|
+
ra as useLocaleHelpers,
|
|
426
|
+
oa as useParseTranslation,
|
|
427
|
+
sa as usePrimaryTypeTranslation,
|
|
428
|
+
da as useResponsiveSize,
|
|
429
|
+
Y as useStore,
|
|
430
|
+
ua as useTranslate,
|
|
431
|
+
la as useUrlHelpers
|
|
432
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export type ErrorItem = {
|
|
2
|
+
field: string;
|
|
3
|
+
message: string;
|
|
4
|
+
detail?: string;
|
|
5
|
+
};
|
|
6
|
+
export type MandeErrorBody = {
|
|
7
|
+
errors?: Array<{
|
|
8
|
+
message?: string;
|
|
9
|
+
error?: string;
|
|
10
|
+
field?: string;
|
|
11
|
+
}>;
|
|
12
|
+
};
|
|
13
|
+
export type MandeError = Error & {
|
|
14
|
+
body?: MandeErrorBody;
|
|
15
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export type { StoreOptions, RetrieveOptions, ListOptions } from './store';
|
|
2
|
+
export type { ViewKeyParams, View, ViewOptions } from './view';
|
|
3
|
+
export type { PaginatedQuery, Pagination } from './pagination';
|
|
4
|
+
export type { ListResponse, RetrieveResponse } from './response';
|
|
5
|
+
export type { RequestOptions } from './request';
|
|
6
|
+
export type { ErrorItem, MandeError, MandeErrorBody } from './errors';
|
|
7
|
+
export type { Language, Translation } from './language';
|
|
8
|
+
export type { InternationalizedRoute } from './routes';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { View, ViewKeyParams } from './view';
|
|
2
|
+
export type StoreOptions<Id, Item, Params extends ViewKeyParams> = {
|
|
3
|
+
params?: Params;
|
|
4
|
+
getItemId: (item: Item) => Id;
|
|
5
|
+
fetchOne?: (id: Id) => Promise<Item>;
|
|
6
|
+
fetchPage?: (params: Params) => Promise<View<Item>>;
|
|
7
|
+
enrichItem?: (item: Item) => Item;
|
|
8
|
+
ttlMs?: number;
|
|
9
|
+
};
|
|
10
|
+
export type RetrieveOptions = {
|
|
11
|
+
force?: boolean;
|
|
12
|
+
};
|
|
13
|
+
export type ListOptions = {
|
|
14
|
+
force?: boolean;
|
|
15
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Ref } from 'vue';
|
|
2
|
+
import { ListOptions, RetrieveOptions, StoreOptions, View, ViewKeyParams } from './types';
|
|
3
|
+
type ViewKey = string;
|
|
4
|
+
type StoreItems<Id, Item> = Record<Id & (string | number), Item>;
|
|
5
|
+
type StoreViews<Item> = Record<ViewKey, View<Item>>;
|
|
6
|
+
type StoreErrors = unknown[];
|
|
7
|
+
export declare function getViewKey(params: ViewKeyParams): ViewKey;
|
|
8
|
+
export type Store<Id, Item, Params extends ViewKeyParams, FilterItem = unknown> = {
|
|
9
|
+
items: Ref<StoreItems<Id, Item>>;
|
|
10
|
+
views: Ref<StoreViews<Item>>;
|
|
11
|
+
errors: Ref<StoreErrors>;
|
|
12
|
+
search: Ref<string>;
|
|
13
|
+
filters: Ref<FilterItem[]>;
|
|
14
|
+
isPending: (key: ViewKey | Id & (string | number)) => boolean;
|
|
15
|
+
retrieve: (id: Id, retrieveOptions?: RetrieveOptions) => Promise<Item | undefined>;
|
|
16
|
+
list: (params: Params, listOptions?: ListOptions) => Promise<void>;
|
|
17
|
+
reset: () => void;
|
|
18
|
+
};
|
|
19
|
+
export declare function useStore<Id, Item, Params extends ViewKeyParams, FilterItem = unknown>(options: StoreOptions<Id, Item, Params>): Store<Id, Item, Params, FilterItem>;
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare function useUrlHelpers(): {
|
|
2
|
+
getCoverUrl: (url: string) => string;
|
|
3
|
+
getLogoUrl: (url: string) => string;
|
|
4
|
+
getCorporateUrl: (url: string) => string;
|
|
5
|
+
getAssetsUrl: (url: string) => string;
|
|
6
|
+
getSiteUrl: (url: string) => string;
|
|
7
|
+
getHomeUrl: (homeName?: string) => string | undefined;
|
|
8
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@choosemycompany/lib",
|
|
3
|
+
"description": "Shared composables, stores and types for ChooseMyCompany front apps",
|
|
4
|
+
"version": "0.1.0",
|
|
5
|
+
"private": false,
|
|
6
|
+
"type": "module",
|
|
7
|
+
"sideEffects": false,
|
|
8
|
+
"files": [
|
|
9
|
+
"dist"
|
|
10
|
+
],
|
|
11
|
+
"main": "./dist/index.js",
|
|
12
|
+
"module": "./dist/index.js",
|
|
13
|
+
"types": "./dist/index.d.ts",
|
|
14
|
+
"exports": {
|
|
15
|
+
".": {
|
|
16
|
+
"import": "./dist/index.js",
|
|
17
|
+
"types": "./dist/index.d.ts"
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
"peerDependencies": {
|
|
21
|
+
"@nuxtjs/i18n": "^10.0.0",
|
|
22
|
+
"h3": "^1.0.0",
|
|
23
|
+
"mande": "^2.0.0",
|
|
24
|
+
"nuxt": "^4.0.0",
|
|
25
|
+
"pinia": "^3.0.0",
|
|
26
|
+
"ufo": "^1.0.0",
|
|
27
|
+
"vue": "^3.5.0",
|
|
28
|
+
"vue-i18n": "^10.0.0",
|
|
29
|
+
"vue-router": "^4.0.0"
|
|
30
|
+
},
|
|
31
|
+
"devDependencies": {
|
|
32
|
+
"@eslint/js": "^9.36.0",
|
|
33
|
+
"@types/node": "^24.5.2",
|
|
34
|
+
"@vitejs/plugin-vue": "^5.1.4",
|
|
35
|
+
"@vue/test-utils": "^2.4.6",
|
|
36
|
+
"eslint": "^9.36.0",
|
|
37
|
+
"globals": "^16.4.0",
|
|
38
|
+
"h3": "^1.13.0",
|
|
39
|
+
"happy-dom": "^18.0.1",
|
|
40
|
+
"jiti": "^2.6.0",
|
|
41
|
+
"mande": "^2.0.9",
|
|
42
|
+
"pinia": "^3.0.3",
|
|
43
|
+
"typescript": "^5.9.2",
|
|
44
|
+
"typescript-eslint": "^8.44.1",
|
|
45
|
+
"ufo": "^1.5.4",
|
|
46
|
+
"vite": "^7.1.7",
|
|
47
|
+
"vite-plugin-dts": "^4.5.4",
|
|
48
|
+
"vitest": "^3.2.4",
|
|
49
|
+
"vue": "^3.5.22",
|
|
50
|
+
"vue-i18n": "^10.0.0",
|
|
51
|
+
"vue-router": "^4.5.1"
|
|
52
|
+
},
|
|
53
|
+
"scripts": {
|
|
54
|
+
"build": "vite build",
|
|
55
|
+
"watch": "vite build --watch",
|
|
56
|
+
"clean": "rm -rf dist",
|
|
57
|
+
"lint": "eslint .",
|
|
58
|
+
"lint:fix": "eslint . --fix",
|
|
59
|
+
"typecheck": "tsc --noEmit",
|
|
60
|
+
"test": "vitest run"
|
|
61
|
+
}
|
|
62
|
+
}
|