@duxweb/dvha-core 0.1.7 → 0.1.9
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/cjs/hooks/auth.cjs +1 -1
- package/dist/cjs/hooks/data.cjs +1 -1
- package/dist/cjs/hooks/form.cjs +1 -0
- package/dist/cjs/hooks/select.cjs +1 -1
- package/dist/cjs/index.cjs +1 -1
- package/dist/cjs/preset/authProvider.cjs +1 -1
- package/dist/cjs/preset/dataProvider.cjs +1 -1
- package/dist/esm/hooks/auth.js +6 -6
- package/dist/esm/hooks/data.js +151 -151
- package/dist/esm/hooks/form.js +67 -0
- package/dist/esm/hooks/select.js +28 -26
- package/dist/esm/index.js +44 -42
- package/dist/esm/preset/authProvider.js +33 -33
- package/dist/esm/preset/dataProvider.js +108 -69
- package/dist/types/hooks/auth.d.ts +2 -2
- package/dist/types/hooks/data.d.ts +72 -72
- package/dist/types/hooks/form.d.ts +16 -0
- package/dist/types/hooks/index.d.ts +1 -0
- package/dist/types/hooks/select.d.ts +1 -0
- package/dist/types/preset/dataProvider.d.ts +3 -1
- package/dist/types/types/auth.d.ts +6 -5
- package/dist/types/types/data.d.ts +10 -1
- package/package.json +2 -2
package/dist/esm/hooks/select.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { debounce as
|
|
1
|
+
import { debounce as N, isArray as O } from "lodash-es";
|
|
2
2
|
import { ref as o, watch as b, computed as d } from "vue";
|
|
3
|
-
import { useCustom as
|
|
4
|
-
function
|
|
5
|
-
const r = o(),
|
|
3
|
+
import { useCustom as A, useMany as E } from "./data.js";
|
|
4
|
+
function j(a) {
|
|
5
|
+
const r = o(), i = o(1), f = o(
|
|
6
6
|
typeof a.pagination == "number" ? a.pagination : a.pagination ? 20 : 0
|
|
7
|
-
),
|
|
7
|
+
), v = o(!1), V = N((e) => {
|
|
8
8
|
r.value = e;
|
|
9
9
|
}, a.debounce || 300), S = (e) => {
|
|
10
10
|
V(e);
|
|
11
11
|
};
|
|
12
12
|
b([() => a.path, () => a.params, r], () => {
|
|
13
|
-
a.pagination && (
|
|
13
|
+
a.pagination && (i.value = 1);
|
|
14
14
|
}, { deep: !0 });
|
|
15
|
-
const { data:
|
|
15
|
+
const { data: c, isLoading: w } = A({
|
|
16
16
|
get path() {
|
|
17
17
|
return a.path || "";
|
|
18
18
|
},
|
|
@@ -21,12 +21,13 @@ function p(a) {
|
|
|
21
21
|
},
|
|
22
22
|
get query() {
|
|
23
23
|
const e = {};
|
|
24
|
-
return a.pagination && (e.page =
|
|
25
|
-
}
|
|
26
|
-
|
|
24
|
+
return a.pagination && (e.page = i.value, e.pageSize = f.value), r.value && (e[a.keywordField || "keyword"] = r.value), Object.keys(e).length ? e : void 0;
|
|
25
|
+
},
|
|
26
|
+
providerName: a.providerName
|
|
27
|
+
}), g = o([]), y = (e) => {
|
|
27
28
|
const { optionField: n } = a;
|
|
28
29
|
return typeof n == "string" ? e[n] || e.value || e.id : e.value || e.id;
|
|
29
|
-
},
|
|
30
|
+
}, m = (e) => {
|
|
30
31
|
const { optionLabel: n = "label", optionValue: u = "value" } = a;
|
|
31
32
|
let l;
|
|
32
33
|
typeof n == "function" ? l = n(e) : typeof n == "string" ? l = e[n] || e.label || e.name || e.title || String(e.value || e.id || "") : l = e.label || e.name || e.title || String(e.value || e.id || "");
|
|
@@ -38,48 +39,49 @@ function p(a) {
|
|
|
38
39
|
};
|
|
39
40
|
}, h = d(() => {
|
|
40
41
|
var u;
|
|
41
|
-
const e = ((u =
|
|
42
|
+
const e = ((u = c.value) == null ? void 0 : u.data) || [], n = [...g.value];
|
|
42
43
|
return e.forEach((l) => {
|
|
43
44
|
n.some(
|
|
44
45
|
(s) => y(s) === y(l)
|
|
45
46
|
) || n.push(l);
|
|
46
|
-
}), n.map((l) =>
|
|
47
|
-
}),
|
|
47
|
+
}), n.map((l) => m(l));
|
|
48
|
+
}), x = d(() => {
|
|
48
49
|
var e;
|
|
49
|
-
return ((e =
|
|
50
|
-
}), { refetch:
|
|
50
|
+
return ((e = c.value) == null ? void 0 : e.meta) || {};
|
|
51
|
+
}), { refetch: k } = E({
|
|
51
52
|
get path() {
|
|
52
53
|
return a.path || "";
|
|
53
54
|
},
|
|
54
55
|
get ids() {
|
|
55
|
-
return a.defaultValue ?
|
|
56
|
+
return a.defaultValue ? O(a.defaultValue) ? a.defaultValue : [a.defaultValue] : [];
|
|
56
57
|
},
|
|
57
58
|
options: {
|
|
58
59
|
enabled: !1
|
|
59
|
-
}
|
|
60
|
+
},
|
|
61
|
+
providerName: a.providerName
|
|
60
62
|
});
|
|
61
63
|
b(() => a.defaultValue, async (e) => {
|
|
62
64
|
var l;
|
|
63
|
-
if (!(
|
|
65
|
+
if (!(v.value || !e || (v.value = !0, (Array.isArray(e) ? e : [e]).every(
|
|
64
66
|
(t) => h.value.some((s) => s.value === t)
|
|
65
67
|
))))
|
|
66
68
|
try {
|
|
67
|
-
const t = await
|
|
68
|
-
|
|
69
|
+
const t = await k();
|
|
70
|
+
g.value = ((l = t == null ? void 0 : t.data) == null ? void 0 : l.data) || [];
|
|
69
71
|
} catch (t) {
|
|
70
72
|
console.warn("Failed to fetch selected items:", t);
|
|
71
73
|
}
|
|
72
74
|
}, { immediate: !0 });
|
|
73
|
-
const
|
|
75
|
+
const F = d(() => w.value && !c.value);
|
|
74
76
|
return {
|
|
75
77
|
onSearch: S,
|
|
76
78
|
options: h,
|
|
77
|
-
meta:
|
|
78
|
-
loading:
|
|
79
|
-
page:
|
|
79
|
+
meta: x,
|
|
80
|
+
loading: F,
|
|
81
|
+
page: i,
|
|
80
82
|
pageSize: f
|
|
81
83
|
};
|
|
82
84
|
}
|
|
83
85
|
export {
|
|
84
|
-
|
|
86
|
+
j as useSelect
|
|
85
87
|
};
|
package/dist/esm/index.js
CHANGED
|
@@ -1,45 +1,46 @@
|
|
|
1
1
|
import { createDux as o } from "./main.js";
|
|
2
|
-
import { useCan as u, useCheck as s, useError as a, useForgotPassword as
|
|
2
|
+
import { useCan as u, useCheck as s, useError as a, useForgotPassword as m, useGetAuth as p, useIsLogin as x, useLogin as f, useLogout as n, useRegister as i, useUpdatePassword as d } from "./hooks/auth.js";
|
|
3
3
|
import { useConfig as D } from "./hooks/config.js";
|
|
4
4
|
import { useClient as C, useCreate as M, useCreateMany as v, useCustom as y, useCustomMutation as L, useDelete as T, useDeleteMany as h, useInfiniteList as I, useInvalidate as P, useList as S, useMany as A, useOne as c, useUpdate as R, useUpdateMany as w } from "./hooks/data.js";
|
|
5
5
|
import { useManage as U } from "./hooks/manage.js";
|
|
6
|
-
import { useMenu as
|
|
7
|
-
import { useTheme as
|
|
6
|
+
import { useMenu as F } from "./hooks/menu.js";
|
|
7
|
+
import { useTheme as E } from "./hooks/theme.js";
|
|
8
8
|
import { useOverlay as V } from "./hooks/overlay.js";
|
|
9
9
|
import { useI18n as q } from "./hooks/i18n.js";
|
|
10
10
|
import { useSelect as B } from "./hooks/select.js";
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
26
|
-
import {
|
|
11
|
+
import { useForm as J } from "./hooks/form.js";
|
|
12
|
+
import { initRouter as N } from "./router/route.js";
|
|
13
|
+
import { useAuthStore as W } from "./stores/auth.js";
|
|
14
|
+
import { useRouteStore as Y } from "./stores/route.js";
|
|
15
|
+
import { useTabStore as _ } from "./stores/tab.js";
|
|
16
|
+
import { useManageStore as ee } from "./stores/manage.js";
|
|
17
|
+
import { useI18nStore as oe } from "./stores/i18n.js";
|
|
18
|
+
import { DuxLogo as ue } from "./components/common/logo.js";
|
|
19
|
+
import { default as ae } from "./components/loader/iframe.js";
|
|
20
|
+
import { DuxOverlay as pe } from "./components/overlay/overlay.js";
|
|
21
|
+
import { DuxCan as fe } from "./components/auth/can.js";
|
|
22
|
+
import { arrayToTree as ie, searchTree as de, treeToArr as le } from "./utils/tree.js";
|
|
23
|
+
import { DuxAppProvider as ge } from "./provider/app.js";
|
|
24
|
+
import { DuxTabRouterView as Me } from "./provider/tab.js";
|
|
25
|
+
import { simpleAuthProvider as ye } from "./preset/authProvider.js";
|
|
26
|
+
import { simpleDataProvider as Te } from "./preset/dataProvider.js";
|
|
27
|
+
import { i18nProvider as Ie } from "./preset/i18nProvider.js";
|
|
27
28
|
export {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
29
|
+
ge as DuxAppProvider,
|
|
30
|
+
fe as DuxCan,
|
|
31
|
+
ae as DuxLoaderIframe,
|
|
32
|
+
ue as DuxLogo,
|
|
33
|
+
pe as DuxOverlay,
|
|
34
|
+
Me as DuxTabRouterView,
|
|
35
|
+
ie as arrayToTree,
|
|
35
36
|
o as createDux,
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
37
|
+
Ie as i18nProvider,
|
|
38
|
+
N as initRouter,
|
|
39
|
+
de as searchTree,
|
|
40
|
+
ye as simpleAuthProvider,
|
|
41
|
+
Te as simpleDataProvider,
|
|
42
|
+
le as treeToArr,
|
|
43
|
+
W as useAuthStore,
|
|
43
44
|
u as useCan,
|
|
44
45
|
s as useCheck,
|
|
45
46
|
C as useClient,
|
|
@@ -51,27 +52,28 @@ export {
|
|
|
51
52
|
T as useDelete,
|
|
52
53
|
h as useDeleteMany,
|
|
53
54
|
a as useError,
|
|
54
|
-
|
|
55
|
-
|
|
55
|
+
m as useForgotPassword,
|
|
56
|
+
J as useForm,
|
|
57
|
+
p as useGetAuth,
|
|
56
58
|
q as useI18n,
|
|
57
|
-
|
|
59
|
+
oe as useI18nStore,
|
|
58
60
|
I as useInfiniteList,
|
|
59
61
|
P as useInvalidate,
|
|
60
|
-
|
|
62
|
+
x as useIsLogin,
|
|
61
63
|
S as useList,
|
|
62
64
|
f as useLogin,
|
|
63
65
|
n as useLogout,
|
|
64
66
|
U as useManage,
|
|
65
|
-
|
|
67
|
+
ee as useManageStore,
|
|
66
68
|
A as useMany,
|
|
67
|
-
|
|
69
|
+
F as useMenu,
|
|
68
70
|
c as useOne,
|
|
69
71
|
V as useOverlay,
|
|
70
72
|
i as useRegister,
|
|
71
|
-
|
|
73
|
+
Y as useRouteStore,
|
|
72
74
|
B as useSelect,
|
|
73
|
-
|
|
74
|
-
|
|
75
|
+
_ as useTabStore,
|
|
76
|
+
E as useTheme,
|
|
75
77
|
R as useUpdate,
|
|
76
78
|
w as useUpdateMany,
|
|
77
79
|
d as useUpdatePassword
|
|
@@ -1,46 +1,46 @@
|
|
|
1
1
|
import g from "axios";
|
|
2
|
-
function m(
|
|
2
|
+
function m(e) {
|
|
3
3
|
return {
|
|
4
4
|
login: async (n, c) => {
|
|
5
5
|
var d;
|
|
6
|
-
return await g.post(c.getApiUrl(((d =
|
|
6
|
+
return await g.post(c.getApiUrl(((d = e == null ? void 0 : e.apiPath) == null ? void 0 : d.login) || "/login", e == null ? void 0 : e.dataProviderName), n).then((t) => {
|
|
7
7
|
var i, a, s;
|
|
8
8
|
return {
|
|
9
9
|
success: !0,
|
|
10
|
-
message: (i =
|
|
11
|
-
redirectTo: ((a =
|
|
12
|
-
data: (s =
|
|
10
|
+
message: (i = t == null ? void 0 : t.data) == null ? void 0 : i.message,
|
|
11
|
+
redirectTo: ((a = e == null ? void 0 : e.routePath) == null ? void 0 : a.index) || "/",
|
|
12
|
+
data: (s = t == null ? void 0 : t.data) == null ? void 0 : s.data
|
|
13
13
|
};
|
|
14
|
-
}).catch((
|
|
14
|
+
}).catch((t) => {
|
|
15
15
|
var i, a;
|
|
16
16
|
return {
|
|
17
17
|
success: !1,
|
|
18
|
-
message: ((a = (i =
|
|
18
|
+
message: ((a = (i = t == null ? void 0 : t.response) == null ? void 0 : i.data) == null ? void 0 : a.message) || (t == null ? void 0 : t.message)
|
|
19
19
|
};
|
|
20
20
|
});
|
|
21
21
|
},
|
|
22
22
|
check: async (n, c) => {
|
|
23
23
|
var d;
|
|
24
|
-
return await g.get((c == null ? void 0 : c.getApiUrl(((d =
|
|
24
|
+
return await g.get((c == null ? void 0 : c.getApiUrl(((d = e == null ? void 0 : e.apiPath) == null ? void 0 : d.check) || "/check", e == null ? void 0 : e.dataProviderName)) || "").then((t) => {
|
|
25
25
|
var i, a;
|
|
26
26
|
return {
|
|
27
27
|
success: !0,
|
|
28
|
-
message: (i =
|
|
29
|
-
data: (a =
|
|
28
|
+
message: (i = t == null ? void 0 : t.data) == null ? void 0 : i.message,
|
|
29
|
+
data: (a = t == null ? void 0 : t.data) == null ? void 0 : a.data
|
|
30
30
|
};
|
|
31
|
-
}).catch((
|
|
31
|
+
}).catch((t) => {
|
|
32
32
|
var i, a;
|
|
33
33
|
return {
|
|
34
34
|
success: !1,
|
|
35
|
-
message: ((a = (i =
|
|
35
|
+
message: ((a = (i = t == null ? void 0 : t.response) == null ? void 0 : i.data) == null ? void 0 : a.message) || (t == null ? void 0 : t.message)
|
|
36
36
|
};
|
|
37
37
|
});
|
|
38
38
|
},
|
|
39
39
|
onError: async (n) => {
|
|
40
40
|
var c;
|
|
41
|
-
return n.status ===
|
|
41
|
+
return (n == null ? void 0 : n.status) === 401 ? {
|
|
42
42
|
logout: !0,
|
|
43
|
-
redirectTo: ((c =
|
|
43
|
+
redirectTo: ((c = e == null ? void 0 : e.routePath) == null ? void 0 : c.login) || "/login",
|
|
44
44
|
error: n
|
|
45
45
|
} : {
|
|
46
46
|
logout: !1,
|
|
@@ -51,64 +51,64 @@ function m(t) {
|
|
|
51
51
|
var n;
|
|
52
52
|
return {
|
|
53
53
|
success: !0,
|
|
54
|
-
redirectTo: ((n =
|
|
54
|
+
redirectTo: ((n = e == null ? void 0 : e.routePath) == null ? void 0 : n.login) || "/login"
|
|
55
55
|
};
|
|
56
56
|
},
|
|
57
57
|
register: async (n, c) => {
|
|
58
58
|
var d;
|
|
59
|
-
return await g.post((c == null ? void 0 : c.getApiUrl(((d =
|
|
59
|
+
return await g.post((c == null ? void 0 : c.getApiUrl(((d = e == null ? void 0 : e.apiPath) == null ? void 0 : d.register) || "/register", e == null ? void 0 : e.dataProviderName)) || "", n).then((t) => {
|
|
60
60
|
var i, a, s;
|
|
61
61
|
return {
|
|
62
62
|
success: !0,
|
|
63
|
-
message: (i =
|
|
64
|
-
redirectTo: ((a =
|
|
65
|
-
data: (s =
|
|
63
|
+
message: (i = t == null ? void 0 : t.data) == null ? void 0 : i.message,
|
|
64
|
+
redirectTo: ((a = e == null ? void 0 : e.routePath) == null ? void 0 : a.index) || "/",
|
|
65
|
+
data: (s = t == null ? void 0 : t.data) == null ? void 0 : s.data
|
|
66
66
|
};
|
|
67
|
-
}).catch((
|
|
67
|
+
}).catch((t) => {
|
|
68
68
|
var i, a;
|
|
69
69
|
return {
|
|
70
70
|
success: !1,
|
|
71
|
-
message: ((a = (i =
|
|
71
|
+
message: ((a = (i = t == null ? void 0 : t.response) == null ? void 0 : i.data) == null ? void 0 : a.message) || (t == null ? void 0 : t.message)
|
|
72
72
|
};
|
|
73
73
|
});
|
|
74
74
|
},
|
|
75
75
|
forgotPassword: async (n, c) => {
|
|
76
76
|
var d;
|
|
77
|
-
return await g.post((c == null ? void 0 : c.getApiUrl(((d =
|
|
77
|
+
return await g.post((c == null ? void 0 : c.getApiUrl(((d = e == null ? void 0 : e.apiPath) == null ? void 0 : d.forgotPassword) || "/forgot-password", e == null ? void 0 : e.dataProviderName)) || "", n).then((t) => {
|
|
78
78
|
var i, a;
|
|
79
79
|
return {
|
|
80
80
|
success: !0,
|
|
81
|
-
message: (i =
|
|
82
|
-
redirectTo: ((a =
|
|
81
|
+
message: (i = t == null ? void 0 : t.data) == null ? void 0 : i.message,
|
|
82
|
+
redirectTo: ((a = e == null ? void 0 : e.routePath) == null ? void 0 : a.login) || "/login"
|
|
83
83
|
};
|
|
84
|
-
}).catch((
|
|
84
|
+
}).catch((t) => {
|
|
85
85
|
var i, a;
|
|
86
86
|
return {
|
|
87
87
|
success: !1,
|
|
88
|
-
message: ((a = (i =
|
|
88
|
+
message: ((a = (i = t == null ? void 0 : t.response) == null ? void 0 : i.data) == null ? void 0 : a.message) || (t == null ? void 0 : t.message)
|
|
89
89
|
};
|
|
90
90
|
});
|
|
91
91
|
},
|
|
92
92
|
updatePassword: async (n, c) => {
|
|
93
93
|
var d;
|
|
94
|
-
return await g.post((c == null ? void 0 : c.getApiUrl(((d =
|
|
94
|
+
return await g.post((c == null ? void 0 : c.getApiUrl(((d = e == null ? void 0 : e.apiPath) == null ? void 0 : d.updatePassword) || "/update-password", e == null ? void 0 : e.dataProviderName)) || "", n).then((t) => {
|
|
95
95
|
var i, a;
|
|
96
96
|
return {
|
|
97
97
|
success: !0,
|
|
98
|
-
message: (i =
|
|
99
|
-
redirectTo: ((a =
|
|
98
|
+
message: (i = t == null ? void 0 : t.data) == null ? void 0 : i.message,
|
|
99
|
+
redirectTo: ((a = e == null ? void 0 : e.routePath) == null ? void 0 : a.login) || "/login"
|
|
100
100
|
};
|
|
101
|
-
}).catch((
|
|
101
|
+
}).catch((t) => {
|
|
102
102
|
var i, a;
|
|
103
103
|
return {
|
|
104
104
|
success: !1,
|
|
105
|
-
message: ((a = (i =
|
|
105
|
+
message: ((a = (i = t == null ? void 0 : t.response) == null ? void 0 : i.data) == null ? void 0 : a.message) || (t == null ? void 0 : t.message)
|
|
106
106
|
};
|
|
107
107
|
});
|
|
108
108
|
},
|
|
109
|
-
can: (n, c, d,
|
|
109
|
+
can: (n, c, d, t) => {
|
|
110
110
|
var i, a;
|
|
111
|
-
return !(
|
|
111
|
+
return !(t != null && t.permission) || Array.isArray(t == null ? void 0 : t.permission) && ((i = t == null ? void 0 : t.permission) == null ? void 0 : i.length) === 0 || typeof (t == null ? void 0 : t.permission) == "object" && Object.keys(t == null ? void 0 : t.permission).length === 0 ? !0 : !(Array.isArray(t == null ? void 0 : t.permission) && !((a = t == null ? void 0 : t.permission) != null && a.includes(n)) || typeof (t == null ? void 0 : t.permission) == "object" && (t == null ? void 0 : t.permission[n]) === !1);
|
|
112
112
|
}
|
|
113
113
|
};
|
|
114
114
|
}
|
|
@@ -1,104 +1,143 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { trimStart as
|
|
3
|
-
function
|
|
4
|
-
const
|
|
1
|
+
import n from "axios";
|
|
2
|
+
import { trimStart as m } from "lodash-es";
|
|
3
|
+
function g(c) {
|
|
4
|
+
const r = (a) => a ? `${c.apiUrl}/${m(a || "", "/")}` : c.apiUrl;
|
|
5
5
|
return {
|
|
6
|
-
apiUrl:
|
|
7
|
-
getList: (
|
|
8
|
-
const
|
|
9
|
-
return
|
|
6
|
+
apiUrl: r,
|
|
7
|
+
getList: (a, l, t) => {
|
|
8
|
+
const e = {};
|
|
9
|
+
return a.pagination && typeof a.pagination == "object" && (e.page = a.pagination.page, e.pageSize = a.pagination.pageSize), n.get(r(a.path) || "", {
|
|
10
10
|
params: {
|
|
11
|
-
...
|
|
12
|
-
...
|
|
13
|
-
...
|
|
11
|
+
...e,
|
|
12
|
+
...a.filters,
|
|
13
|
+
...a.sorters
|
|
14
14
|
},
|
|
15
15
|
headers: {
|
|
16
|
-
Authorization:
|
|
16
|
+
Authorization: t == null ? void 0 : t.token
|
|
17
17
|
},
|
|
18
|
-
...
|
|
19
|
-
}).then((
|
|
18
|
+
...a.meta
|
|
19
|
+
}).then((d) => c.successCallback ? c.successCallback(d) : k(d)).catch((d) => {
|
|
20
|
+
throw c.errorCallback ? c.errorCallback(d) : b(d);
|
|
21
|
+
});
|
|
20
22
|
},
|
|
21
|
-
create: (
|
|
23
|
+
create: (a, l, t) => n.post(r(a.path) || "", a.data, {
|
|
22
24
|
headers: {
|
|
23
|
-
Authorization:
|
|
25
|
+
Authorization: t == null ? void 0 : t.token
|
|
24
26
|
},
|
|
25
|
-
...
|
|
26
|
-
}).then((
|
|
27
|
-
|
|
27
|
+
...a.meta
|
|
28
|
+
}).then((e) => c.successCallback ? c.successCallback(e) : k(e)).catch((e) => {
|
|
29
|
+
throw c.errorCallback ? c.errorCallback(e) : b(e);
|
|
30
|
+
}),
|
|
31
|
+
update: (a, l, t) => n.put(r(a.id ? `${a.path}/${a.id}` : a.path) || "", a.data, {
|
|
28
32
|
headers: {
|
|
29
|
-
Authorization:
|
|
33
|
+
Authorization: t == null ? void 0 : t.token
|
|
30
34
|
},
|
|
31
|
-
...
|
|
32
|
-
}).then((
|
|
33
|
-
|
|
35
|
+
...a.meta
|
|
36
|
+
}).then((e) => c.successCallback ? c.successCallback(e) : k(e)).catch((e) => {
|
|
37
|
+
throw c.errorCallback ? c.errorCallback(e) : b(e);
|
|
38
|
+
}),
|
|
39
|
+
deleteOne: (a, l, t) => n.delete(r(a.id ? `${a.path}/${a.id}` : a.path) || "", {
|
|
34
40
|
headers: {
|
|
35
|
-
Authorization:
|
|
41
|
+
Authorization: t == null ? void 0 : t.token
|
|
36
42
|
},
|
|
37
|
-
...
|
|
38
|
-
}).then((
|
|
39
|
-
|
|
43
|
+
...a.meta
|
|
44
|
+
}).then((e) => c.successCallback ? c.successCallback(e) : k(e)).catch((e) => {
|
|
45
|
+
throw c.errorCallback ? c.errorCallback(e) : b(e);
|
|
46
|
+
}),
|
|
47
|
+
getOne: (a, l, t) => n.get(r(a.id ? `${a.path}/${a.id}` : a.path) || "", {
|
|
40
48
|
headers: {
|
|
41
|
-
Authorization:
|
|
49
|
+
Authorization: t == null ? void 0 : t.token
|
|
42
50
|
},
|
|
43
|
-
...
|
|
44
|
-
}).then((
|
|
45
|
-
|
|
51
|
+
...a.meta
|
|
52
|
+
}).then((e) => c.successCallback ? c.successCallback(e) : k(e)).catch((e) => {
|
|
53
|
+
throw c.errorCallback ? c.errorCallback(e) : b(e);
|
|
54
|
+
}),
|
|
55
|
+
getMany: (a, l, t) => n.get(r(a.path) || "", {
|
|
46
56
|
params: {
|
|
47
|
-
ids:
|
|
57
|
+
ids: a.ids
|
|
48
58
|
},
|
|
49
59
|
headers: {
|
|
50
|
-
Authorization:
|
|
60
|
+
Authorization: t == null ? void 0 : t.token
|
|
51
61
|
},
|
|
52
|
-
...
|
|
53
|
-
}).then((
|
|
54
|
-
|
|
62
|
+
...a.meta
|
|
63
|
+
}).then((e) => c.successCallback ? c.successCallback(e) : k(e)).catch((e) => {
|
|
64
|
+
throw c.errorCallback ? c.errorCallback(e) : b(e);
|
|
65
|
+
}),
|
|
66
|
+
createMany: (a, l, t) => n.post(r(a.path) || "", a.data, {
|
|
55
67
|
headers: {
|
|
56
|
-
Authorization:
|
|
68
|
+
Authorization: t == null ? void 0 : t.token
|
|
57
69
|
},
|
|
58
|
-
...
|
|
59
|
-
}).then((
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
70
|
+
...a.meta
|
|
71
|
+
}).then((e) => c.successCallback ? c.successCallback(e) : k(e)).catch((e) => {
|
|
72
|
+
throw c.errorCallback ? c.errorCallback(e) : b(e);
|
|
73
|
+
}),
|
|
74
|
+
updateMany: (a, l, t) => n.put(r(a.path) || "", {
|
|
75
|
+
ids: a.ids,
|
|
76
|
+
data: a.data
|
|
63
77
|
}, {
|
|
64
78
|
headers: {
|
|
65
|
-
Authorization:
|
|
79
|
+
Authorization: t == null ? void 0 : t.token
|
|
66
80
|
},
|
|
67
|
-
...
|
|
68
|
-
}).then((
|
|
69
|
-
|
|
81
|
+
...a.meta
|
|
82
|
+
}).then((e) => c.successCallback ? c.successCallback(e) : k(e)).catch((e) => {
|
|
83
|
+
throw c.errorCallback ? c.errorCallback(e) : b(e);
|
|
84
|
+
}),
|
|
85
|
+
deleteMany: (a, l, t) => n.delete(r(a.path) || "", {
|
|
70
86
|
params: {
|
|
71
|
-
ids:
|
|
87
|
+
ids: a.ids
|
|
72
88
|
},
|
|
73
89
|
headers: {
|
|
74
|
-
Authorization:
|
|
90
|
+
Authorization: t == null ? void 0 : t.token
|
|
75
91
|
},
|
|
76
|
-
...
|
|
77
|
-
}).then((
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
92
|
+
...a.meta
|
|
93
|
+
}).then((e) => c.successCallback ? c.successCallback(e) : k(e)).catch((e) => {
|
|
94
|
+
throw c.errorCallback ? c.errorCallback(e) : b(e);
|
|
95
|
+
}),
|
|
96
|
+
custom: (a, l, t) => {
|
|
97
|
+
let e = {
|
|
98
|
+
...a.query
|
|
81
99
|
};
|
|
82
|
-
return
|
|
83
|
-
...
|
|
84
|
-
...
|
|
85
|
-
}),
|
|
86
|
-
...
|
|
87
|
-
...
|
|
88
|
-
}),
|
|
89
|
-
url:
|
|
90
|
-
method:
|
|
91
|
-
data:
|
|
92
|
-
params:
|
|
100
|
+
return a.sorters && typeof a.sorters == "object" && (e = {
|
|
101
|
+
...e,
|
|
102
|
+
...a.sorters
|
|
103
|
+
}), a.filters && typeof a.filters == "object" && (e = {
|
|
104
|
+
...e,
|
|
105
|
+
...a.filters
|
|
106
|
+
}), n.request({
|
|
107
|
+
url: r(a.path || ""),
|
|
108
|
+
method: a.method || "GET",
|
|
109
|
+
data: a.payload,
|
|
110
|
+
params: e,
|
|
93
111
|
headers: {
|
|
94
|
-
Authorization:
|
|
95
|
-
...
|
|
112
|
+
Authorization: t == null ? void 0 : t.token,
|
|
113
|
+
...a.headers
|
|
96
114
|
},
|
|
97
|
-
...
|
|
98
|
-
}).then((
|
|
115
|
+
...a.meta
|
|
116
|
+
}).then((d) => c.successCallback ? c.successCallback(d) : k(d)).catch((d) => {
|
|
117
|
+
throw c.errorCallback ? c.errorCallback(d) : b(d);
|
|
118
|
+
});
|
|
99
119
|
}
|
|
100
120
|
};
|
|
101
121
|
}
|
|
122
|
+
function k(c) {
|
|
123
|
+
var r, a, l;
|
|
124
|
+
return {
|
|
125
|
+
message: (r = c.data) == null ? void 0 : r.message,
|
|
126
|
+
data: (a = c.data) == null ? void 0 : a.data,
|
|
127
|
+
meta: (l = c.data) == null ? void 0 : l.meta,
|
|
128
|
+
raw: c.data
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
function b(c) {
|
|
132
|
+
var r, a, l, t;
|
|
133
|
+
return {
|
|
134
|
+
message: ((r = c.response.data) == null ? void 0 : r.message) || c.message,
|
|
135
|
+
data: (a = c.response.data) == null ? void 0 : a.data,
|
|
136
|
+
meta: (l = c.response.data) == null ? void 0 : l.meta,
|
|
137
|
+
status: ((t = c.response.data) == null ? void 0 : t.code) || c.response.status || 500,
|
|
138
|
+
raw: c.response.data
|
|
139
|
+
};
|
|
140
|
+
}
|
|
102
141
|
export {
|
|
103
|
-
|
|
142
|
+
g as simpleDataProvider
|
|
104
143
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { IAuthActionResponse, IAuthCheckResponse, IAuthErrorResponse, IAuthLoginResponse, IAuthLogoutResponse } from '../types';
|
|
1
|
+
import type { IAuthActionResponse, IAuthCheckResponse, IAuthErrorResponse, IAuthLoginResponse, IAuthLogoutResponse, IDataProviderError } from '../types';
|
|
2
2
|
/**
|
|
3
3
|
* Auth login params
|
|
4
4
|
*/
|
|
@@ -93,7 +93,7 @@ export declare function useUpdatePassword({ onSuccess, onError }: IAuthActionPar
|
|
|
93
93
|
* @returns Error method
|
|
94
94
|
*/
|
|
95
95
|
export declare function useError(onCallback?: (data?: IAuthErrorResponse) => void): {
|
|
96
|
-
mutate: (error:
|
|
96
|
+
mutate: (error: IDataProviderError) => Promise<void>;
|
|
97
97
|
};
|
|
98
98
|
/**
|
|
99
99
|
* Get auth
|