@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.
@@ -1,18 +1,18 @@
1
- import { debounce as A, isArray as E } from "lodash-es";
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 q, useMany as z } from "./data.js";
4
- function p(a) {
5
- const r = o(), c = o(1), f = 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
- ), g = o(!1), V = A((e) => {
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 && (c.value = 1);
13
+ a.pagination && (i.value = 1);
14
14
  }, { deep: !0 });
15
- const { data: i, isLoading: w } = q({
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 = c.value, e.pageSize = f.value), r.value && (e[a.keywordField || "keyword"] = r.value), Object.keys(e).length ? e : void 0;
25
- }
26
- }), v = o([]), y = (e) => {
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
- }, x = (e) => {
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 = i.value) == null ? void 0 : u.data) || [], n = [...v.value];
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) => x(l));
47
- }), k = d(() => {
47
+ }), n.map((l) => m(l));
48
+ }), x = d(() => {
48
49
  var e;
49
- return ((e = i.value) == null ? void 0 : e.meta) || {};
50
- }), { refetch: F } = z({
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 ? E(a.defaultValue) ? a.defaultValue : [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 (!(g.value || !e || (g.value = !0, (Array.isArray(e) ? e : [e]).every(
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 F();
68
- v.value = ((l = t == null ? void 0 : t.data) == null ? void 0 : l.data) || [];
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 O = d(() => w.value && !i.value);
75
+ const F = d(() => w.value && !c.value);
74
76
  return {
75
77
  onSearch: S,
76
78
  options: h,
77
- meta: k,
78
- loading: O,
79
- page: c,
79
+ meta: x,
80
+ loading: F,
81
+ page: i,
80
82
  pageSize: f
81
83
  };
82
84
  }
83
85
  export {
84
- p as useSelect
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 p, useGetAuth as x, useIsLogin as m, useLogin as f, useLogout as n, useRegister as i, useUpdatePassword as d } from "./hooks/auth.js";
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 k } from "./hooks/menu.js";
7
- import { useTheme as F } from "./hooks/theme.js";
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 { initRouter as J } from "./router/route.js";
12
- import { useAuthStore as N } from "./stores/auth.js";
13
- import { useRouteStore as W } from "./stores/route.js";
14
- import { useTabStore as Y } from "./stores/tab.js";
15
- import { useManageStore as _ } from "./stores/manage.js";
16
- import { useI18nStore as ee } from "./stores/i18n.js";
17
- import { DuxLogo as oe } from "./components/common/logo.js";
18
- import { default as ue } from "./components/loader/iframe.js";
19
- import { DuxOverlay as ae } from "./components/overlay/overlay.js";
20
- import { DuxCan as xe } from "./components/auth/can.js";
21
- import { arrayToTree as fe, searchTree as ne, treeToArr as ie } from "./utils/tree.js";
22
- import { DuxAppProvider as le } from "./provider/app.js";
23
- import { DuxTabRouterView as ge } from "./provider/tab.js";
24
- import { simpleAuthProvider as Me } from "./preset/authProvider.js";
25
- import { simpleDataProvider as ye } from "./preset/dataProvider.js";
26
- import { i18nProvider as Te } from "./preset/i18nProvider.js";
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
- le as DuxAppProvider,
29
- xe as DuxCan,
30
- ue as DuxLoaderIframe,
31
- oe as DuxLogo,
32
- ae as DuxOverlay,
33
- ge as DuxTabRouterView,
34
- fe as arrayToTree,
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
- Te as i18nProvider,
37
- J as initRouter,
38
- ne as searchTree,
39
- Me as simpleAuthProvider,
40
- ye as simpleDataProvider,
41
- ie as treeToArr,
42
- N as useAuthStore,
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
- p as useForgotPassword,
55
- x as useGetAuth,
55
+ m as useForgotPassword,
56
+ J as useForm,
57
+ p as useGetAuth,
56
58
  q as useI18n,
57
- ee as useI18nStore,
59
+ oe as useI18nStore,
58
60
  I as useInfiniteList,
59
61
  P as useInvalidate,
60
- m as useIsLogin,
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
- _ as useManageStore,
67
+ ee as useManageStore,
66
68
  A as useMany,
67
- k as useMenu,
69
+ F as useMenu,
68
70
  c as useOne,
69
71
  V as useOverlay,
70
72
  i as useRegister,
71
- W as useRouteStore,
73
+ Y as useRouteStore,
72
74
  B as useSelect,
73
- Y as useTabStore,
74
- F as useTheme,
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(t) {
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 = t == null ? void 0 : t.apiPath) == null ? void 0 : d.login) || "/login", t == null ? void 0 : t.dataProviderName), n).then((e) => {
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 = e == null ? void 0 : e.data) == null ? void 0 : i.message,
11
- redirectTo: ((a = t == null ? void 0 : t.routePath) == null ? void 0 : a.index) || "/",
12
- data: (s = e == null ? void 0 : e.data) == null ? void 0 : s.data
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((e) => {
14
+ }).catch((t) => {
15
15
  var i, a;
16
16
  return {
17
17
  success: !1,
18
- message: ((a = (i = e == null ? void 0 : e.response) == null ? void 0 : i.data) == null ? void 0 : a.message) || (e == null ? void 0 : e.message)
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 = t == null ? void 0 : t.apiPath) == null ? void 0 : d.check) || "/check", t == null ? void 0 : t.dataProviderName)) || "").then((e) => {
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 = e == null ? void 0 : e.data) == null ? void 0 : i.message,
29
- data: (a = e == null ? void 0 : e.data) == null ? void 0 : a.data
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((e) => {
31
+ }).catch((t) => {
32
32
  var i, a;
33
33
  return {
34
34
  success: !1,
35
- message: ((a = (i = e == null ? void 0 : e.response) == null ? void 0 : i.data) == null ? void 0 : a.message) || (e == null ? void 0 : e.message)
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 === 403 ? {
41
+ return (n == null ? void 0 : n.status) === 401 ? {
42
42
  logout: !0,
43
- redirectTo: ((c = t == null ? void 0 : t.routePath) == null ? void 0 : c.login) || "/login",
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 = t == null ? void 0 : t.routePath) == null ? void 0 : n.login) || "/login"
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 = t == null ? void 0 : t.apiPath) == null ? void 0 : d.register) || "/register", t == null ? void 0 : t.dataProviderName)) || "", n).then((e) => {
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 = e == null ? void 0 : e.data) == null ? void 0 : i.message,
64
- redirectTo: ((a = t == null ? void 0 : t.routePath) == null ? void 0 : a.index) || "/",
65
- data: (s = e == null ? void 0 : e.data) == null ? void 0 : s.data
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((e) => {
67
+ }).catch((t) => {
68
68
  var i, a;
69
69
  return {
70
70
  success: !1,
71
- message: ((a = (i = e == null ? void 0 : e.response) == null ? void 0 : i.data) == null ? void 0 : a.message) || (e == null ? void 0 : e.message)
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 = t == null ? void 0 : t.apiPath) == null ? void 0 : d.forgotPassword) || "/forgot-password", t == null ? void 0 : t.dataProviderName)) || "", n).then((e) => {
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 = e == null ? void 0 : e.data) == null ? void 0 : i.message,
82
- redirectTo: ((a = t == null ? void 0 : t.routePath) == null ? void 0 : a.login) || "/login"
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((e) => {
84
+ }).catch((t) => {
85
85
  var i, a;
86
86
  return {
87
87
  success: !1,
88
- message: ((a = (i = e == null ? void 0 : e.response) == null ? void 0 : i.data) == null ? void 0 : a.message) || (e == null ? void 0 : e.message)
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 = t == null ? void 0 : t.apiPath) == null ? void 0 : d.updatePassword) || "/update-password", t == null ? void 0 : t.dataProviderName)) || "", n).then((e) => {
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 = e == null ? void 0 : e.data) == null ? void 0 : i.message,
99
- redirectTo: ((a = t == null ? void 0 : t.routePath) == null ? void 0 : a.login) || "/login"
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((e) => {
101
+ }).catch((t) => {
102
102
  var i, a;
103
103
  return {
104
104
  success: !1,
105
- message: ((a = (i = e == null ? void 0 : e.response) == null ? void 0 : i.data) == null ? void 0 : a.message) || (e == null ? void 0 : e.message)
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, e) => {
109
+ can: (n, c, d, t) => {
110
110
  var i, a;
111
- return !(e != null && e.permission) || Array.isArray(e == null ? void 0 : e.permission) && ((i = e == null ? void 0 : e.permission) == null ? void 0 : i.length) === 0 || typeof (e == null ? void 0 : e.permission) == "object" && Object.keys(e == null ? void 0 : e.permission).length === 0 ? !0 : !(Array.isArray(e == null ? void 0 : e.permission) && !((a = e == null ? void 0 : e.permission) != null && a.includes(n)) || typeof (e == null ? void 0 : e.permission) == "object" && (e == null ? void 0 : e.permission[n]) === !1);
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 d from "axios";
2
- import { trimStart as i } from "lodash-es";
3
- function z(g) {
4
- const t = (e) => e ? `${g.apiUrl}/${i(e || "", "/")}` : g.apiUrl;
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: t,
7
- getList: (e, n, r) => {
8
- const a = {};
9
- return e.pagination && typeof e.pagination == "object" && (a.page = e.pagination.page, a.pageSize = e.pagination.pageSize), d.get(t(e.path) || "", {
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
- ...a,
12
- ...e.filters,
13
- ...e.sorters
11
+ ...e,
12
+ ...a.filters,
13
+ ...a.sorters
14
14
  },
15
15
  headers: {
16
- Authorization: r == null ? void 0 : r.token
16
+ Authorization: t == null ? void 0 : t.token
17
17
  },
18
- ...e.meta
19
- }).then((m) => m.data);
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: (e, n, r) => d.post(t(e.path) || "", e.data, {
23
+ create: (a, l, t) => n.post(r(a.path) || "", a.data, {
22
24
  headers: {
23
- Authorization: r == null ? void 0 : r.token
25
+ Authorization: t == null ? void 0 : t.token
24
26
  },
25
- ...e.meta
26
- }).then((a) => a.data),
27
- update: (e, n, r) => d.put(t(e.id ? `${e.path}/${e.id}` : e.path) || "", e.data, {
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: r == null ? void 0 : r.token
33
+ Authorization: t == null ? void 0 : t.token
30
34
  },
31
- ...e.meta
32
- }).then((a) => a.data),
33
- deleteOne: (e, n, r) => d.delete(t(e.id ? `${e.path}/${e.id}` : e.path) || "", {
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: r == null ? void 0 : r.token
41
+ Authorization: t == null ? void 0 : t.token
36
42
  },
37
- ...e.meta
38
- }).then((a) => a.data),
39
- getOne: (e, n, r) => d.get(t(e.id ? `${e.path}/${e.id}` : e.path) || "", {
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: r == null ? void 0 : r.token
49
+ Authorization: t == null ? void 0 : t.token
42
50
  },
43
- ...e.meta
44
- }).then((a) => a.data),
45
- getMany: (e, n, r) => d.get(t(e.path) || "", {
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: e.ids
57
+ ids: a.ids
48
58
  },
49
59
  headers: {
50
- Authorization: r == null ? void 0 : r.token
60
+ Authorization: t == null ? void 0 : t.token
51
61
  },
52
- ...e.meta
53
- }).then((a) => a.data),
54
- createMany: (e, n, r) => d.post(t(e.path) || "", e.data, {
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: r == null ? void 0 : r.token
68
+ Authorization: t == null ? void 0 : t.token
57
69
  },
58
- ...e.meta
59
- }).then((a) => a.data),
60
- updateMany: (e, n, r) => d.put(t(e.path) || "", {
61
- ids: e.ids,
62
- data: e.data
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: r == null ? void 0 : r.token
79
+ Authorization: t == null ? void 0 : t.token
66
80
  },
67
- ...e.meta
68
- }).then((a) => a.data),
69
- deleteMany: (e, n, r) => d.delete(t(e.path) || "", {
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: e.ids
87
+ ids: a.ids
72
88
  },
73
89
  headers: {
74
- Authorization: r == null ? void 0 : r.token
90
+ Authorization: t == null ? void 0 : t.token
75
91
  },
76
- ...e.meta
77
- }).then((a) => a.data),
78
- custom: (e, n, r) => {
79
- let a = {
80
- ...e.query
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 e.sorters && typeof e.sorters == "object" && (a = {
83
- ...a,
84
- ...e.sorters
85
- }), e.filters && typeof e.filters == "object" && (a = {
86
- ...a,
87
- ...e.filters
88
- }), d.request({
89
- url: t(e.path || ""),
90
- method: e.method || "GET",
91
- data: e.payload,
92
- params: a,
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: r == null ? void 0 : r.token,
95
- ...e.headers
112
+ Authorization: t == null ? void 0 : t.token,
113
+ ...a.headers
96
114
  },
97
- ...e.meta
98
- }).then((m) => m.data);
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
- z as simpleDataProvider
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: any) => Promise<void>;
96
+ mutate: (error: IDataProviderError) => Promise<void>;
97
97
  };
98
98
  /**
99
99
  * Get auth