@choosemycompany/lib 0.2.0 → 0.3.1
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/dist/http/types.d.ts +15 -3
- package/dist/http/useHttp.d.ts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +103 -103
- package/dist/store/types.d.ts +0 -5
- package/dist/store/useStore.d.ts +2 -7
- package/package.json +1 -1
package/dist/http/types.d.ts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Shared HTTP types modeling the CMC API contract.
|
|
3
3
|
*
|
|
4
|
-
* The CMC backend wraps
|
|
4
|
+
* The CMC backend wraps responses in one of two envelopes:
|
|
5
|
+
* - **list** endpoints return `{ data: T[], pagination }` (see `ListResponse`);
|
|
6
|
+
* - **single-item** (retrieve) endpoints return `{ item: T }` (see `RetrieveResponse`).
|
|
7
|
+
*
|
|
5
8
|
* These types are independent of any HTTP client — `useHttp` happens to use
|
|
6
9
|
* `mande`, but consumers can adapt them to any fetcher.
|
|
7
10
|
*/
|
|
@@ -64,13 +67,22 @@ export type ListResponse<T> = {
|
|
|
64
67
|
pagination: Pagination;
|
|
65
68
|
};
|
|
66
69
|
/**
|
|
67
|
-
* Standard CMC single-item response envelope.
|
|
70
|
+
* Standard CMC single-item (retrieve) response envelope.
|
|
71
|
+
*
|
|
72
|
+
* The resource is exposed under `item` — **not** `data`. `data` is reserved for
|
|
73
|
+
* the list envelope (`ListResponse`), which also carries `pagination`.
|
|
68
74
|
*
|
|
69
75
|
* @typeParam T - Shape of the returned resource.
|
|
70
76
|
*/
|
|
71
77
|
export type RetrieveResponse<T> = {
|
|
72
|
-
|
|
78
|
+
item: T;
|
|
73
79
|
};
|
|
80
|
+
/**
|
|
81
|
+
* A raw JSON object as returned by the HTTP layer, before mapping to a domain
|
|
82
|
+
* type. Use as the generic argument of `RetrieveResponse` / `ListResponse` when
|
|
83
|
+
* the caller maps the payload itself — e.g. `ListResponse<HttpResponse>`.
|
|
84
|
+
*/
|
|
85
|
+
export type HttpResponse = Record<string, unknown>;
|
|
74
86
|
/**
|
|
75
87
|
* Field-level validation error item, as returned in `MandeErrorBody.errors`.
|
|
76
88
|
*/
|
package/dist/http/useHttp.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ import { MandeInstance } from 'mande';
|
|
|
12
12
|
* const { http, setToken, clearToken } = useHttp()
|
|
13
13
|
*
|
|
14
14
|
* setToken(accessToken)
|
|
15
|
-
* const {
|
|
15
|
+
* const { item } = await http.get<RetrieveResponse<User>>('/me')
|
|
16
16
|
* clearToken() // on logout
|
|
17
17
|
* ```
|
|
18
18
|
*/
|
package/dist/index.d.ts
CHANGED
|
@@ -31,5 +31,5 @@ export { usePrimaryTypeTranslation } from './i18n/usePrimaryTypeTranslation';
|
|
|
31
31
|
export { useResponsiveSize } from './ui/useResponsiveSize';
|
|
32
32
|
export { useTranslate } from './i18n/useTranslate';
|
|
33
33
|
export type { StoreOptions, RetrieveOptions, ListOptions, ViewKeyParams, View, ViewOptions, } from './store/types';
|
|
34
|
-
export type { PaginatedQuery, Pagination, ListResponse, RetrieveResponse, RequestOptions, ErrorItem, MandeError, MandeErrorBody, } from './http/types';
|
|
34
|
+
export type { PaginatedQuery, Pagination, ListResponse, RetrieveResponse, HttpResponse, RequestOptions, ErrorItem, MandeError, MandeErrorBody, } from './http/types';
|
|
35
35
|
export type { Language, Translation, InternationalizedRoute, } from './i18n/types';
|
package/dist/index.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { mande as
|
|
2
|
-
import { useRuntimeConfig as G, showError as
|
|
3
|
-
import { ref as
|
|
1
|
+
import { mande as D } from "mande";
|
|
2
|
+
import { useRuntimeConfig as G, showError as K, useState as H } from "nuxt/app";
|
|
3
|
+
import { ref as v, onMounted as z, onBeforeUnmount as F, computed as N, onUnmounted as O } from "vue";
|
|
4
4
|
import { useI18n as M } from "vue-i18n";
|
|
5
|
-
import { createError as
|
|
5
|
+
import { createError as q } from "h3";
|
|
6
6
|
let w;
|
|
7
|
-
function
|
|
7
|
+
function Z() {
|
|
8
8
|
return w || (w = G().public.cmcApiUrl, w);
|
|
9
9
|
}
|
|
10
|
-
function
|
|
11
|
-
const a =
|
|
10
|
+
function aa() {
|
|
11
|
+
const a = Z(), n = D(a, {
|
|
12
12
|
headers: {}
|
|
13
13
|
});
|
|
14
14
|
function t(e) {
|
|
@@ -25,22 +25,22 @@ function na() {
|
|
|
25
25
|
function P(a) {
|
|
26
26
|
return Object.entries(a).sort(([n], [t]) => n.localeCompare(t)).map(([n, t]) => `${n}=${t}`).join("|");
|
|
27
27
|
}
|
|
28
|
-
function
|
|
29
|
-
const n =
|
|
30
|
-
const
|
|
31
|
-
if (
|
|
28
|
+
function ea(a) {
|
|
29
|
+
const n = v({}), t = v({}), i = v({}), e = v({}), o = a.getItemId ?? ((r) => {
|
|
30
|
+
const l = r.id;
|
|
31
|
+
if (l === void 0)
|
|
32
32
|
throw new Error(
|
|
33
33
|
"useStore: no `getItemId` option provided and item has no `id` property. Either pass `getItemId` in the store options, or expose an `id` field on your items."
|
|
34
34
|
);
|
|
35
|
-
return
|
|
35
|
+
return l;
|
|
36
36
|
});
|
|
37
|
-
function
|
|
37
|
+
function d(r) {
|
|
38
38
|
return !!e.value[r];
|
|
39
39
|
}
|
|
40
|
-
async function
|
|
41
|
-
e.value[r] =
|
|
40
|
+
async function u(r, l) {
|
|
41
|
+
e.value[r] = l;
|
|
42
42
|
try {
|
|
43
|
-
const s = await
|
|
43
|
+
const s = await l;
|
|
44
44
|
return delete i.value[r], s;
|
|
45
45
|
} catch (s) {
|
|
46
46
|
throw i.value[r] = s, s;
|
|
@@ -48,10 +48,10 @@ function ia(a) {
|
|
|
48
48
|
delete e.value[r];
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
|
-
async function
|
|
51
|
+
async function f(r, l = {}) {
|
|
52
52
|
if (!a.fetchOne)
|
|
53
53
|
throw new Error("useStore.retrieve called but fetchOne is not defined in store options");
|
|
54
|
-
const { force: s = !1 } =
|
|
54
|
+
const { force: s = !1 } = l;
|
|
55
55
|
if (n.value[r] && !s)
|
|
56
56
|
return n.value[r];
|
|
57
57
|
const c = e.value[r];
|
|
@@ -59,8 +59,8 @@ function ia(a) {
|
|
|
59
59
|
return c;
|
|
60
60
|
const B = a.fetchOne, k = (async () => {
|
|
61
61
|
try {
|
|
62
|
-
const C = await B(r),
|
|
63
|
-
return n.value[r] =
|
|
62
|
+
const C = await B(r), b = a.enrichItem ? a.enrichItem(C) : C;
|
|
63
|
+
return n.value[r] = b, delete i.value[r], n.value[r];
|
|
64
64
|
} catch (C) {
|
|
65
65
|
i.value[r] = C;
|
|
66
66
|
return;
|
|
@@ -70,8 +70,8 @@ function ia(a) {
|
|
|
70
70
|
})();
|
|
71
71
|
return e.value[r] = k, k;
|
|
72
72
|
}
|
|
73
|
-
function
|
|
74
|
-
const
|
|
73
|
+
function p(r) {
|
|
74
|
+
const l = P(r), s = t.value[l];
|
|
75
75
|
if (s)
|
|
76
76
|
return {
|
|
77
77
|
items: s.itemIds.map((c) => n.value[c]).filter((c) => c !== void 0),
|
|
@@ -81,82 +81,82 @@ function ia(a) {
|
|
|
81
81
|
limit: s.limit
|
|
82
82
|
};
|
|
83
83
|
}
|
|
84
|
-
async function m(r,
|
|
84
|
+
async function m(r, l = {}) {
|
|
85
85
|
if (!a.fetchPage)
|
|
86
86
|
throw new Error("useStore.list called but fetchPage is not defined in store options");
|
|
87
|
-
const s = P(r), { force: c = !1 } =
|
|
87
|
+
const s = P(r), { force: c = !1 } = l;
|
|
88
88
|
if (t.value[s] && !c)
|
|
89
|
-
return
|
|
89
|
+
return p(r);
|
|
90
90
|
const B = e.value[s];
|
|
91
91
|
if (B)
|
|
92
|
-
return await B,
|
|
92
|
+
return await B, p(r);
|
|
93
93
|
const k = a.fetchPage, C = (async () => {
|
|
94
94
|
try {
|
|
95
|
-
const
|
|
96
|
-
for (const E of
|
|
97
|
-
const y = a.enrichItem ? a.enrichItem(E) : E, T =
|
|
95
|
+
const b = await k(r), R = [];
|
|
96
|
+
for (const E of b.items) {
|
|
97
|
+
const y = a.enrichItem ? a.enrichItem(E) : E, T = o(y);
|
|
98
98
|
n.value[T] = y, R.push(T);
|
|
99
99
|
}
|
|
100
100
|
t.value[s] = {
|
|
101
101
|
itemIds: R,
|
|
102
|
-
total:
|
|
103
|
-
hasMore:
|
|
104
|
-
page:
|
|
105
|
-
limit:
|
|
102
|
+
total: b.total,
|
|
103
|
+
hasMore: b.hasMore,
|
|
104
|
+
page: b.page,
|
|
105
|
+
limit: b.limit
|
|
106
106
|
}, delete i.value[s];
|
|
107
|
-
} catch (
|
|
108
|
-
i.value[s] =
|
|
107
|
+
} catch (b) {
|
|
108
|
+
i.value[s] = b;
|
|
109
109
|
} finally {
|
|
110
110
|
delete e.value[s];
|
|
111
111
|
}
|
|
112
112
|
})();
|
|
113
|
-
return e.value[s] = C, await C,
|
|
113
|
+
return e.value[s] = C, await C, p(r);
|
|
114
114
|
}
|
|
115
|
-
async function
|
|
115
|
+
async function h(r) {
|
|
116
116
|
if (!a.createMutation)
|
|
117
117
|
throw new Error("useStore.create called but createMutation is not defined in store options");
|
|
118
|
-
const
|
|
118
|
+
const l = await a.createMutation(r), s = a.enrichItem ? a.enrichItem(l) : l, c = o(s);
|
|
119
119
|
return n.value[c] = s, t.value = {}, s;
|
|
120
120
|
}
|
|
121
|
-
async function
|
|
121
|
+
async function g(r, l) {
|
|
122
122
|
if (!a.updateMutation)
|
|
123
123
|
throw new Error("useStore.update called but updateMutation is not defined in store options");
|
|
124
|
-
const s = a.updateMutation, c = await
|
|
124
|
+
const s = a.updateMutation, c = await u(r, (async () => s(r, l))()), B = a.enrichItem ? a.enrichItem(c) : c;
|
|
125
125
|
return n.value[r] = B, B;
|
|
126
126
|
}
|
|
127
|
-
async function
|
|
127
|
+
async function A(r) {
|
|
128
128
|
if (!a.removeMutation)
|
|
129
129
|
throw new Error("useStore.remove called but removeMutation is not defined in store options");
|
|
130
|
-
const
|
|
131
|
-
await
|
|
130
|
+
const l = a.removeMutation;
|
|
131
|
+
await u(r, (async () => l(r))()), delete n.value[r];
|
|
132
132
|
for (const s of Object.values(t.value)) {
|
|
133
133
|
const c = s.itemIds.indexOf(r);
|
|
134
134
|
c !== -1 && (s.itemIds.splice(c, 1), s.total = Math.max(0, s.total - 1));
|
|
135
135
|
}
|
|
136
136
|
}
|
|
137
|
-
function
|
|
137
|
+
function I() {
|
|
138
138
|
i.value = {};
|
|
139
139
|
}
|
|
140
|
-
function
|
|
141
|
-
n.value = {}, t.value = {}, i.value = {}, e.value = {}
|
|
140
|
+
function S() {
|
|
141
|
+
n.value = {}, t.value = {}, i.value = {}, e.value = {};
|
|
142
142
|
}
|
|
143
|
-
return { items: n, views: t, errors: i,
|
|
143
|
+
return { items: n, views: t, errors: i, isPending: d, list: m, reset: S, retrieve: f, getView: p, track: u, create: h, update: g, remove: A, clearErrors: I };
|
|
144
144
|
}
|
|
145
|
-
function
|
|
145
|
+
function na(a, n) {
|
|
146
146
|
const t = (i) => {
|
|
147
147
|
const e = a.value, o = i.target;
|
|
148
148
|
!e || !o || e.contains(o) || n();
|
|
149
149
|
};
|
|
150
150
|
z(() => {
|
|
151
151
|
document.addEventListener("click", t);
|
|
152
|
-
}),
|
|
152
|
+
}), F(() => {
|
|
153
153
|
document.removeEventListener("click", t);
|
|
154
154
|
});
|
|
155
155
|
}
|
|
156
|
-
function
|
|
156
|
+
function ia() {
|
|
157
157
|
const { locale: a } = M();
|
|
158
158
|
function n(t, i = null) {
|
|
159
|
-
const e =
|
|
159
|
+
const e = x[t.trim().toUpperCase()];
|
|
160
160
|
if (!e)
|
|
161
161
|
throw new Error(`Unknown country code: ${t}`);
|
|
162
162
|
if (i && e[i])
|
|
@@ -169,7 +169,7 @@ function ra() {
|
|
|
169
169
|
}
|
|
170
170
|
return n;
|
|
171
171
|
}
|
|
172
|
-
const
|
|
172
|
+
const x = {
|
|
173
173
|
AD: { en: "Andorra", fr: "Andorre", es: "Andorra", de: "Andorra", it: "Andorra", pt: "Andorra", da: "Andorra" },
|
|
174
174
|
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" },
|
|
175
175
|
AF: { en: "Afghanistan", fr: "Afghanistan", es: "Afganistán", de: "Afghanistan", it: "Afghanistan", pt: "Afeganistão", da: "Afghanistan" },
|
|
@@ -307,32 +307,32 @@ const J = {
|
|
|
307
307
|
ZA: { en: "South Africa", fr: "Afrique Du Sud", es: "Sudáfrica", de: "Südafrika", it: "Sudafrica", pt: "África Do Sul", da: "Sydafrika" },
|
|
308
308
|
ZM: { en: "Zambia", fr: "Zambie", es: "Zambia", de: "Sambia", it: "Zambia", pt: "Zâmbia", da: "Zambia" },
|
|
309
309
|
ZW: { en: "Zimbabwe", fr: "Zimbabwe", es: "Zimbabue", de: "Simbabwe", it: "Zimbabwe", pt: "Zimbábue", da: "Zimbabwe" }
|
|
310
|
-
},
|
|
311
|
-
const i = n || "An unexpected error occurred", e =
|
|
310
|
+
}, ta = ({ code: a, message: n, data: t }) => {
|
|
311
|
+
const i = n || "An unexpected error occurred", e = q({
|
|
312
312
|
statusCode: a,
|
|
313
313
|
statusMessage: i,
|
|
314
314
|
message: i,
|
|
315
315
|
data: t
|
|
316
316
|
});
|
|
317
|
-
throw
|
|
318
|
-
},
|
|
319
|
-
function
|
|
317
|
+
throw K(e), e;
|
|
318
|
+
}, V = "ilcJCL_lmpwcEJfSkKND";
|
|
319
|
+
function ra() {
|
|
320
320
|
const { gtagId: a } = G().public;
|
|
321
321
|
return { reportConversion: () => {
|
|
322
322
|
if (typeof window > "u" || typeof window.gtag > "u" || !a)
|
|
323
323
|
return;
|
|
324
|
-
const t = `${a}/${
|
|
324
|
+
const t = `${a}/${V}`;
|
|
325
325
|
window.gtag("event", "conversion", {
|
|
326
326
|
send_to: t
|
|
327
327
|
});
|
|
328
328
|
} };
|
|
329
329
|
}
|
|
330
330
|
const U = "https://5509641.hs-sites-eu1.com";
|
|
331
|
-
function
|
|
331
|
+
function oa() {
|
|
332
332
|
const { locale: a } = M();
|
|
333
333
|
return { contactUrl: N(() => a.value === "fr" ? `${U}/contact` : `${U}/${a.value}/contact`) };
|
|
334
334
|
}
|
|
335
|
-
function
|
|
335
|
+
function sa() {
|
|
336
336
|
async function a(i) {
|
|
337
337
|
await Promise.all(
|
|
338
338
|
i.map(
|
|
@@ -349,34 +349,34 @@ function ua() {
|
|
|
349
349
|
}
|
|
350
350
|
function t(i, e, o) {
|
|
351
351
|
if (import.meta.server)
|
|
352
|
-
return async (
|
|
352
|
+
return async (u) => {
|
|
353
353
|
i.value = !0;
|
|
354
354
|
};
|
|
355
|
-
const d =
|
|
355
|
+
const d = H(
|
|
356
356
|
`${e}LoadedImageCache`,
|
|
357
357
|
() => ({})
|
|
358
358
|
);
|
|
359
|
-
return async (
|
|
360
|
-
if (!
|
|
359
|
+
return async (u) => {
|
|
360
|
+
if (!u) {
|
|
361
361
|
i.value = !1;
|
|
362
362
|
return;
|
|
363
363
|
}
|
|
364
|
-
const f = o.map((
|
|
364
|
+
const f = o.map((h) => n(u, h)), p = `${e}|${f.join("|")}`;
|
|
365
365
|
if (d.value[p]) {
|
|
366
366
|
i.value = !0;
|
|
367
367
|
return;
|
|
368
368
|
}
|
|
369
369
|
i.value = !1;
|
|
370
|
-
const
|
|
371
|
-
await a(
|
|
370
|
+
const m = f.filter(Boolean).map(String);
|
|
371
|
+
await a(m), d.value[p] = !0, i.value = !0;
|
|
372
372
|
};
|
|
373
373
|
}
|
|
374
374
|
return t;
|
|
375
375
|
}
|
|
376
|
-
const
|
|
376
|
+
const J = {
|
|
377
377
|
en: ["US", "UK"]
|
|
378
|
-
},
|
|
379
|
-
function
|
|
378
|
+
}, $ = "FR";
|
|
379
|
+
function j(a) {
|
|
380
380
|
const n = a.trim().replace("_", "-"), [t, i] = n.split("-");
|
|
381
381
|
return {
|
|
382
382
|
language: t?.toLowerCase() ?? "",
|
|
@@ -386,45 +386,45 @@ function W(a) {
|
|
|
386
386
|
function L(a) {
|
|
387
387
|
return a.toString().trim().toUpperCase();
|
|
388
388
|
}
|
|
389
|
-
function
|
|
389
|
+
function da() {
|
|
390
390
|
function a(n, t) {
|
|
391
391
|
if (!t.length) return;
|
|
392
|
-
const i = t.map(L), e = new Set(i), { language: o, region: d } =
|
|
393
|
-
d &&
|
|
394
|
-
const f =
|
|
395
|
-
f?.length &&
|
|
396
|
-
for (const p of
|
|
392
|
+
const i = t.map(L), e = new Set(i), { language: o, region: d } = j(n), u = [];
|
|
393
|
+
d && u.push(d);
|
|
394
|
+
const f = J[o];
|
|
395
|
+
f?.length && u.push(...f.map(L)), o && u.push(o.toUpperCase()), u.push($);
|
|
396
|
+
for (const p of u)
|
|
397
397
|
if (e.has(p))
|
|
398
398
|
return p;
|
|
399
399
|
return i[0];
|
|
400
400
|
}
|
|
401
401
|
return { getRegionFromLocale: a };
|
|
402
402
|
}
|
|
403
|
-
function
|
|
403
|
+
function ua() {
|
|
404
404
|
const { t: a } = M();
|
|
405
405
|
function n(t, i) {
|
|
406
|
-
const e = a(t), o = [],
|
|
407
|
-
let
|
|
408
|
-
for (;
|
|
409
|
-
const { index:
|
|
410
|
-
|
|
406
|
+
const e = a(t), o = [], u = i.map((g) => g.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("|"), f = new RegExp(`\\[(${u})\\]([\\s\\S]*?)\\[\\/\\1\\]`, "g"), p = i.reduce((g, A) => (g[A] = !1, g), {});
|
|
407
|
+
let m = 0, h = f.exec(e);
|
|
408
|
+
for (; h; ) {
|
|
409
|
+
const { index: g, 0: A, 1: I, 2: S } = h;
|
|
410
|
+
g > m && o.push({ text: e.slice(m, g), ...p }), S && I && o.push({ text: S, ...p, [I]: !0 }), m = g + A.length, h = f.exec(e);
|
|
411
411
|
}
|
|
412
|
-
return
|
|
412
|
+
return m < e.length && o.push({ text: e.slice(m), ...p }), o;
|
|
413
413
|
}
|
|
414
414
|
return { parse: n };
|
|
415
415
|
}
|
|
416
|
-
function
|
|
416
|
+
function la(a) {
|
|
417
417
|
const { t: n, te: t, tm: i } = M();
|
|
418
418
|
function e(o, d) {
|
|
419
|
-
const
|
|
420
|
-
return t(
|
|
419
|
+
const u = `${o}.${d}`, f = `${o}.${a[0]}`;
|
|
420
|
+
return t(u) ? n(u) : t(f) ? n(f) : typeof i(o) == "string" ? n(o, {
|
|
421
421
|
primaryType: n(`common.primary-type.${d}`).toLowerCase()
|
|
422
422
|
}) : "";
|
|
423
423
|
}
|
|
424
424
|
return { getPrimaryTypeTranslation: e };
|
|
425
425
|
}
|
|
426
|
-
function
|
|
427
|
-
const i =
|
|
426
|
+
function ca(a, n, t = 768) {
|
|
427
|
+
const i = v(t - 1), e = N(
|
|
428
428
|
() => i.value >= t ? n : a
|
|
429
429
|
);
|
|
430
430
|
if (import.meta.client) {
|
|
@@ -433,13 +433,13 @@ function fa(a, n, t = 768) {
|
|
|
433
433
|
};
|
|
434
434
|
z(() => {
|
|
435
435
|
o(), window.addEventListener("resize", o);
|
|
436
|
-
}),
|
|
436
|
+
}), O(() => {
|
|
437
437
|
window.removeEventListener("resize", o);
|
|
438
438
|
});
|
|
439
439
|
}
|
|
440
440
|
return { size: e, windowWidth: i };
|
|
441
441
|
}
|
|
442
|
-
function
|
|
442
|
+
function pa() {
|
|
443
443
|
const { locale: a } = M();
|
|
444
444
|
function n(t, i = "fr") {
|
|
445
445
|
if (!t) return "";
|
|
@@ -450,17 +450,17 @@ function ga() {
|
|
|
450
450
|
}
|
|
451
451
|
export {
|
|
452
452
|
P as getViewKey,
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
453
|
+
ta as showAndThrowError,
|
|
454
|
+
na as useClickOutside,
|
|
455
|
+
ia as useCountriesTranslation,
|
|
456
|
+
ra as useGtagConversion,
|
|
457
|
+
aa as useHttp,
|
|
458
|
+
oa as useHubspotContactUrl,
|
|
459
|
+
sa as useImageCacheWatcherCallback,
|
|
460
|
+
da as useLocaleHelpers,
|
|
461
|
+
ua as useParseTranslation,
|
|
462
|
+
la as usePrimaryTypeTranslation,
|
|
463
|
+
ca as useResponsiveSize,
|
|
464
|
+
ea as useStore,
|
|
465
|
+
pa as useTranslate
|
|
466
466
|
};
|
package/dist/store/types.d.ts
CHANGED
|
@@ -72,11 +72,6 @@ export type StoreOptions<Id extends IdKey, Item, Params extends ViewKeyParams, C
|
|
|
72
72
|
updateMutation?: (id: Id, patch: UpdatePatch) => Promise<Item>;
|
|
73
73
|
/** Deletes an item server-side. Required to call `remove()`. */
|
|
74
74
|
removeMutation?: (id: Id) => Promise<void>;
|
|
75
|
-
/**
|
|
76
|
-
* Cache time-to-live in milliseconds. Reserved for future use — currently
|
|
77
|
-
* **not implemented**; cached entries live until `reset()` is called.
|
|
78
|
-
*/
|
|
79
|
-
ttlMs?: number;
|
|
80
75
|
};
|
|
81
76
|
/**
|
|
82
77
|
* Options accepted by `retrieve()`.
|
package/dist/store/useStore.d.ts
CHANGED
|
@@ -35,21 +35,16 @@ export declare function getViewKey(params: ViewKeyParams): ViewKey;
|
|
|
35
35
|
* @typeParam Id - Item identifier (string or number).
|
|
36
36
|
* @typeParam Item - Item shape stored in the cache.
|
|
37
37
|
* @typeParam Params - Paginated query shape (must extend `ViewKeyParams`).
|
|
38
|
-
* @typeParam FilterItem - Element type of the `filters` ref (free-form, owned by the consumer).
|
|
39
38
|
* @typeParam CreatePayload - Payload shape passed to `create()` (defaults to `Item`).
|
|
40
39
|
* @typeParam UpdatePatch - Patch shape passed to `update()` (defaults to `Partial<Item>`).
|
|
41
40
|
*/
|
|
42
|
-
export type Store<Id extends IdKey, Item, Params extends ViewKeyParams,
|
|
41
|
+
export type Store<Id extends IdKey, Item, Params extends ViewKeyParams, CreatePayload = Item, UpdatePatch = Partial<Item>> = {
|
|
43
42
|
/** Canonical item cache keyed by id. The single source of truth for item data. */
|
|
44
43
|
items: Ref<StoreItems<Id, Item>>;
|
|
45
44
|
/** Cached pages, keyed by `getViewKey(params)`. Each stores `itemIds[]` + pagination meta. */
|
|
46
45
|
views: Ref<StoreViews<Id>>;
|
|
47
46
|
/** Latest error per key (id for retrieve, view key for list, arbitrary for `track`). */
|
|
48
47
|
errors: Ref<StoreErrors>;
|
|
49
|
-
/** Free-form search state, exposed for consumer convenience; never read internally. */
|
|
50
|
-
search: Ref<string>;
|
|
51
|
-
/** Free-form filter state, exposed for consumer convenience; never read internally. */
|
|
52
|
-
filters: Ref<FilterItem[]>;
|
|
53
48
|
/** Returns `true` if there is an in-flight promise registered under `key`. */
|
|
54
49
|
isPending: (key: ViewKey | Id) => boolean;
|
|
55
50
|
/** Fetches one item by id (cache-first unless `force: true`). Returns `undefined` on failure. */
|
|
@@ -90,5 +85,5 @@ export type Store<Id extends IdKey, Item, Params extends ViewKeyParams, FilterIt
|
|
|
90
85
|
* await store.update('org-42', { name: 'Acme Inc.' })
|
|
91
86
|
* ```
|
|
92
87
|
*/
|
|
93
|
-
export declare function useStore<Id extends IdKey, Item, Params extends ViewKeyParams,
|
|
88
|
+
export declare function useStore<Id extends IdKey, Item, Params extends ViewKeyParams, CreatePayload = Item, UpdatePatch = Partial<Item>>(options: StoreOptions<Id, Item, Params, CreatePayload, UpdatePatch>): Store<Id, Item, Params, CreatePayload, UpdatePatch>;
|
|
94
89
|
export {};
|
package/package.json
CHANGED