@duxweb/dvha-core 1.1.30 → 1.2.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.
Files changed (159) hide show
  1. package/dist/cjs/_virtual/_rolldown/runtime.cjs +1 -0
  2. package/dist/cjs/components/auth/can.cjs +1 -1
  3. package/dist/cjs/components/auth/index.cjs +1 -0
  4. package/dist/cjs/components/common/icon.cjs +1 -1
  5. package/dist/cjs/components/common/index.cjs +1 -0
  6. package/dist/cjs/components/common/logo.cjs +1 -1
  7. package/dist/cjs/components/index.cjs +1 -0
  8. package/dist/cjs/components/loader/iframe.cjs +1 -1
  9. package/dist/cjs/components/loader/index.cjs +1 -0
  10. package/dist/cjs/components/loader/loader.cjs +1 -1
  11. package/dist/cjs/components/loader/remote/index.cjs +1 -0
  12. package/dist/cjs/components/loader/remote/loader.cjs +1 -1
  13. package/dist/cjs/components/loader/remote/render.cjs +1 -1
  14. package/dist/cjs/components/overlay/index.cjs +1 -0
  15. package/dist/cjs/components/overlay/overlay.cjs +1 -1
  16. package/dist/cjs/components/status/error.cjs +1 -1
  17. package/dist/cjs/components/status/exception.cjs +1 -1
  18. package/dist/cjs/components/status/index.cjs +1 -0
  19. package/dist/cjs/components/status/notAuthorized.cjs +1 -1
  20. package/dist/cjs/components/status/notFound.cjs +1 -1
  21. package/dist/cjs/config/color.cjs +1 -1
  22. package/dist/cjs/directive/index.cjs +1 -0
  23. package/dist/cjs/directive/permission.cjs +1 -1
  24. package/dist/cjs/hooks/auth.cjs +1 -1
  25. package/dist/cjs/hooks/config.cjs +1 -1
  26. package/dist/cjs/hooks/data.cjs +1 -1
  27. package/dist/cjs/hooks/export.cjs +1 -1
  28. package/dist/cjs/hooks/exportCsv.cjs +2 -2
  29. package/dist/cjs/hooks/form.cjs +1 -1
  30. package/dist/cjs/hooks/formExtend.cjs +1 -1
  31. package/dist/cjs/hooks/formValidate.cjs +1 -1
  32. package/dist/cjs/hooks/i18n.cjs +1 -1
  33. package/dist/cjs/hooks/import.cjs +1 -1
  34. package/dist/cjs/hooks/importCsv.cjs +2 -2
  35. package/dist/cjs/hooks/index.cjs +1 -0
  36. package/dist/cjs/hooks/json/index.cjs +1 -1
  37. package/dist/cjs/hooks/json/utils/contextManager.cjs +1 -1
  38. package/dist/cjs/hooks/json/utils/expressionParser.cjs +1 -1
  39. package/dist/cjs/hooks/json/vFor.cjs +1 -1
  40. package/dist/cjs/hooks/json/vIf.cjs +1 -1
  41. package/dist/cjs/hooks/json/vModel.cjs +1 -1
  42. package/dist/cjs/hooks/json/vOn.cjs +1 -1
  43. package/dist/cjs/hooks/json/vShow.cjs +1 -1
  44. package/dist/cjs/hooks/json/vText.cjs +1 -1
  45. package/dist/cjs/hooks/json.cjs +1 -1
  46. package/dist/cjs/hooks/list.cjs +1 -1
  47. package/dist/cjs/hooks/manage.cjs +1 -1
  48. package/dist/cjs/hooks/menu.cjs +1 -1
  49. package/dist/cjs/hooks/overlay.cjs +1 -1
  50. package/dist/cjs/hooks/select.cjs +1 -1
  51. package/dist/cjs/hooks/theme.cjs +4 -8
  52. package/dist/cjs/hooks/tree.cjs +1 -1
  53. package/dist/cjs/hooks/upload/index.cjs +1 -0
  54. package/dist/cjs/hooks/upload/local.cjs +1 -1
  55. package/dist/cjs/hooks/upload/s3.cjs +1 -1
  56. package/dist/cjs/hooks/upload.cjs +1 -1
  57. package/dist/cjs/index.cjs +1 -1
  58. package/dist/cjs/main.cjs +1 -1
  59. package/dist/cjs/preset/authProvider.cjs +1 -1
  60. package/dist/cjs/preset/dataProvider.cjs +1 -1
  61. package/dist/cjs/preset/i18nProvider.cjs +1 -1
  62. package/dist/cjs/preset/index.cjs +1 -0
  63. package/dist/cjs/provider/app.cjs +1 -1
  64. package/dist/cjs/provider/index.cjs +1 -0
  65. package/dist/cjs/provider/tab.cjs +1 -1
  66. package/dist/cjs/router/index.cjs +1 -0
  67. package/dist/cjs/router/route.cjs +1 -1
  68. package/dist/cjs/stores/auth.cjs +1 -1
  69. package/dist/cjs/stores/i18n.cjs +1 -1
  70. package/dist/cjs/stores/index.cjs +1 -0
  71. package/dist/cjs/stores/jsonSchema.cjs +1 -1
  72. package/dist/cjs/stores/manage.cjs +1 -1
  73. package/dist/cjs/stores/route.cjs +1 -1
  74. package/dist/cjs/stores/tab.cjs +1 -1
  75. package/dist/cjs/stores/theme.cjs +1 -1
  76. package/dist/cjs/utils/bus.cjs +1 -1
  77. package/dist/cjs/utils/index.cjs +1 -0
  78. package/dist/cjs/utils/theme.cjs +8 -8
  79. package/dist/cjs/utils/tree.cjs +1 -1
  80. package/dist/esm/_virtual/_rolldown/runtime.js +9 -0
  81. package/dist/esm/components/auth/can.js +17 -36
  82. package/dist/esm/components/auth/index.js +1 -0
  83. package/dist/esm/components/common/icon.js +16 -24
  84. package/dist/esm/components/common/index.js +2 -0
  85. package/dist/esm/components/common/logo.js +50 -49
  86. package/dist/esm/components/index.js +14 -0
  87. package/dist/esm/components/loader/iframe.js +16 -18
  88. package/dist/esm/components/loader/index.js +1 -0
  89. package/dist/esm/components/loader/loader.js +11 -40
  90. package/dist/esm/components/loader/remote/index.js +2 -0
  91. package/dist/esm/components/loader/remote/loader.js +118 -156
  92. package/dist/esm/components/loader/remote/render.js +12 -17
  93. package/dist/esm/components/overlay/index.js +1 -0
  94. package/dist/esm/components/overlay/overlay.js +54 -70
  95. package/dist/esm/components/status/error.js +7 -9
  96. package/dist/esm/components/status/exception.js +21 -37
  97. package/dist/esm/components/status/index.js +4 -0
  98. package/dist/esm/components/status/notAuthorized.js +7 -9
  99. package/dist/esm/components/status/notFound.js +7 -9
  100. package/dist/esm/config/color.js +288 -290
  101. package/dist/esm/directive/index.js +1 -0
  102. package/dist/esm/directive/permission.js +7 -27
  103. package/dist/esm/hooks/auth.js +154 -120
  104. package/dist/esm/hooks/config.js +11 -9
  105. package/dist/esm/hooks/data.js +416 -415
  106. package/dist/esm/hooks/export.js +32 -36
  107. package/dist/esm/hooks/exportCsv.js +42 -46
  108. package/dist/esm/hooks/form.js +86 -95
  109. package/dist/esm/hooks/formExtend.js +36 -40
  110. package/dist/esm/hooks/formValidate.js +22 -25
  111. package/dist/esm/hooks/i18n.js +14 -18
  112. package/dist/esm/hooks/import.js +45 -54
  113. package/dist/esm/hooks/importCsv.js +90 -83
  114. package/dist/esm/hooks/index.js +31 -0
  115. package/dist/esm/hooks/json/index.js +14 -22
  116. package/dist/esm/hooks/json/utils/contextManager.js +35 -26
  117. package/dist/esm/hooks/json/utils/expressionParser.js +100 -123
  118. package/dist/esm/hooks/json/vFor.js +50 -55
  119. package/dist/esm/hooks/json/vIf.js +17 -16
  120. package/dist/esm/hooks/json/vModel.js +96 -106
  121. package/dist/esm/hooks/json/vOn.js +30 -32
  122. package/dist/esm/hooks/json/vShow.js +20 -22
  123. package/dist/esm/hooks/json/vText.js +44 -51
  124. package/dist/esm/hooks/json.js +131 -132
  125. package/dist/esm/hooks/list.js +150 -184
  126. package/dist/esm/hooks/manage.js +25 -22
  127. package/dist/esm/hooks/menu.js +57 -61
  128. package/dist/esm/hooks/overlay.js +6 -23
  129. package/dist/esm/hooks/select.js +84 -94
  130. package/dist/esm/hooks/theme.js +289 -219
  131. package/dist/esm/hooks/tree.js +43 -47
  132. package/dist/esm/hooks/upload/index.js +2 -0
  133. package/dist/esm/hooks/upload/local.js +24 -30
  134. package/dist/esm/hooks/upload/s3.js +70 -80
  135. package/dist/esm/hooks/upload.js +256 -272
  136. package/dist/esm/index.js +150 -141
  137. package/dist/esm/main.js +24 -45
  138. package/dist/esm/preset/authProvider.js +62 -68
  139. package/dist/esm/preset/dataProvider.js +154 -180
  140. package/dist/esm/preset/i18nProvider.js +28 -30
  141. package/dist/esm/preset/index.js +3 -0
  142. package/dist/esm/provider/app.js +124 -151
  143. package/dist/esm/provider/index.js +2 -0
  144. package/dist/esm/provider/tab.js +49 -66
  145. package/dist/esm/router/index.js +1 -0
  146. package/dist/esm/router/route.js +39 -46
  147. package/dist/esm/stores/auth.js +51 -46
  148. package/dist/esm/stores/i18n.js +32 -29
  149. package/dist/esm/stores/index.js +7 -0
  150. package/dist/esm/stores/jsonSchema.js +47 -34
  151. package/dist/esm/stores/manage.js +63 -48
  152. package/dist/esm/stores/route.js +60 -56
  153. package/dist/esm/stores/tab.js +55 -60
  154. package/dist/esm/stores/theme.js +48 -55
  155. package/dist/esm/utils/bus.js +3 -5
  156. package/dist/esm/utils/index.js +3 -0
  157. package/dist/esm/utils/theme.js +110 -93
  158. package/dist/esm/utils/tree.js +28 -37
  159. package/package.json +1 -1
@@ -1,429 +1,430 @@
1
- import { useQuery as D, useInfiniteQuery as Q, useMutation as $, useQueryClient as k } from "@tanstack/vue-query";
2
- import { trimStart as B } from "lodash-es";
3
- import { toRef as z, computed as s, unref as T, watch as E, ref as F } from "vue";
4
- import { useGetAuth as p, useError as P } from "./auth.js";
5
- import { useManage as h } from "./manage.js";
6
- function G(t) {
7
- const o = h(), d = p(), i = t.providerName || "default", { mutate: c } = P(), u = z(t.pagination ? t.pagination : { page: 1, pageSize: 20 }), n = s(() => T(t.sorters) || {}), r = s(() => T(t.filters) || {}), a = s(() => T(t.meta) || {}), e = s(() => {
8
- const { onError: q, options: f, pagination: L, filters: N, sorters: m, meta: S, ...x } = t;
9
- return x;
10
- });
11
- E(e, () => {
12
- t.pagination && (u.value.page = 1);
13
- }, {
14
- deep: !0
15
- });
16
- const v = s(() => ({
17
- ...e.value,
18
- pagination: t.pagination ? u.value : void 0,
19
- filters: r.value,
20
- sorters: n.value,
21
- meta: a.value
22
- })), l = s(() => [`${o.config?.name}:${i}:${t.path}`, v.value]), y = D({
23
- queryKey: l,
24
- queryFn: () => o.config?.dataProvider?.[i]?.getList(v.value, o, d),
25
- ...t.options
26
- }), C = s(() => y.isFetching.value);
27
- E(y.isError, (q) => {
28
- q && (c(y.error.value), t?.onError?.(y.error.value));
29
- });
30
- const g = F(void 0), A = F(0), M = F(0);
31
- return E(y.data, (q) => {
32
- q && (g.value = q, A.value = o.config?.dataProvider?.[i]?.getTotal?.(q) || 0, M.value = Math.ceil(A.value / (u.value.pageSize || 20)) || 0);
33
- }, {
34
- immediate: !0
35
- }), {
36
- ...y,
37
- isLoading: C,
38
- data: g,
39
- refetch: y.refetch,
40
- pagination: u,
41
- total: A,
42
- pageCount: M
43
- };
1
+ import { useManage as e } from "./manage.js";
2
+ import { useError as t, useGetAuth as n } from "./auth.js";
3
+ import { computed as r, ref as i, toRef as a, unref as o, watch as s } from "vue";
4
+ import { trimStart as c } from "lodash-es";
5
+ import { useInfiniteQuery as l, useMutation as u, useQuery as d, useQueryClient as f } from "@tanstack/vue-query";
6
+ /**
7
+ * Get list data
8
+ * @param params
9
+ */
10
+ function p(c) {
11
+ let l = e(), u = n(), f = c.providerName || "default", { mutate: p } = t(), m = a(c.pagination ? c.pagination : {
12
+ page: 1,
13
+ pageSize: 20
14
+ }), h = r(() => o(c.sorters) || {}), g = r(() => o(c.filters) || {}), _ = r(() => o(c.meta) || {}), v = r(() => {
15
+ let { onError: e, options: t, pagination: n, filters: r, sorters: i, meta: a, ...o } = c;
16
+ return o;
17
+ });
18
+ s(v, () => {
19
+ c.pagination && (m.value.page = 1);
20
+ }, { deep: !0 });
21
+ let y = r(() => ({
22
+ ...v.value,
23
+ pagination: c.pagination ? m.value : void 0,
24
+ filters: g.value,
25
+ sorters: h.value,
26
+ meta: _.value
27
+ })), b = d({
28
+ queryKey: r(() => [`${l.config?.name}:${f}:${c.path}`, y.value]),
29
+ queryFn: () => l.config?.dataProvider?.[f]?.getList(y.value, l, u),
30
+ ...c.options
31
+ }), x = r(() => b.isFetching.value);
32
+ s(b.isError, (e) => {
33
+ e && (p(b.error.value), c?.onError?.(b.error.value));
34
+ });
35
+ let S = i(void 0), C = i(0), w = i(0);
36
+ return s(b.data, (e) => {
37
+ e && (S.value = e, C.value = l.config?.dataProvider?.[f]?.getTotal?.(e) || 0, w.value = Math.ceil(C.value / (m.value.pageSize || 20)) || 0);
38
+ }, { immediate: !0 }), {
39
+ ...b,
40
+ isLoading: x,
41
+ data: S,
42
+ refetch: b.refetch,
43
+ pagination: m,
44
+ total: C,
45
+ pageCount: w
46
+ };
44
47
  }
45
- function R(t) {
46
- const o = h(), d = p(), i = t.providerName || "default", { mutate: c } = P(), u = z(t, "pagination", { page: 1, pageSize: 20 }), n = z(t, "sorters", {}), r = z(t, "filters", {}), a = z(t, "meta", {}), e = s(() => {
47
- const { onError: f, options: L, pagination: N, filters: m, sorters: S, meta: x, ...K } = t;
48
- return K;
49
- });
50
- E(e, () => {
51
- u.value.page = 1;
52
- }, {
53
- deep: !0
54
- });
55
- const v = F(0), l = F(0), y = s(() => ({
56
- ...e.value,
57
- filters: r.value || {},
58
- sorters: n.value || {},
59
- meta: a.value || {}
60
- })), C = s(() => [`${o.config?.name}:${i}:infinite:${t.path}`, y.value]), g = Q({
61
- queryKey: C,
62
- queryFn: ({ pageParam: f }) => (u.value.page = f, o.config?.dataProvider?.[i]?.getList({
63
- ...y.value,
64
- pagination: {
65
- ...u.value,
66
- page: f
67
- }
68
- }, o, d)),
69
- initialPageParam: 1,
70
- getNextPageParam: (f, L, N) => {
71
- if (!f?.data || !f?.data?.length)
72
- return;
73
- const m = o.config?.dataProvider?.[i]?.getTotal?.(f) || 0;
74
- if (l.value = Math.ceil(m / (u.value.pageSize || 20)) || 0, v.value = m, !(N * (u.value.pageSize || 20) >= m))
75
- return N + 1;
76
- },
77
- getPreviousPageParam: (f, L, N) => {
78
- if (N <= 1)
79
- return;
80
- const m = o.config?.dataProvider?.[i]?.getTotal?.(f) || 0;
81
- return l.value = Math.ceil(m / (u.value.pageSize || 20)) || 0, v.value = m, N - 1;
82
- },
83
- ...t.options
84
- }), A = s(() => g.isFetching.value);
85
- E(g.isError, (f) => {
86
- f && (c(g.error.value), t?.onError?.(g.error.value));
87
- });
88
- const M = () => {
89
- if (!(!g.hasNextPage.value || g.isFetching.value))
90
- return g.fetchNextPage();
91
- }, q = F(void 0);
92
- return E(g.data, (f) => {
93
- if (!f || !f?.pages || !f.pages?.length)
94
- return;
95
- const L = f.pages.reduce((m, S) => S?.data && Array.isArray(S.data) && S.data?.length ? m.concat(S.data) : m, []), N = f.pages[0];
96
- N && (q.value = {
97
- ...N,
98
- data: L
99
- });
100
- }, {
101
- deep: !0,
102
- immediate: !0
103
- }), {
104
- ...g,
105
- isLoading: A,
106
- data: q,
107
- fetchNextPage: M,
108
- hasNextPage: g.hasNextPage,
109
- refetch: g.refetch,
110
- pagination: u,
111
- total: v,
112
- pageCount: l
113
- };
48
+ /**
49
+ * Get infinite list data
50
+ * @param params
51
+ */
52
+ function m(o) {
53
+ let c = e(), u = n(), d = o.providerName || "default", { mutate: f } = t(), p = a(o, "pagination", {
54
+ page: 1,
55
+ pageSize: 20
56
+ }), m = a(o, "sorters", {}), h = a(o, "filters", {}), g = a(o, "meta", {}), _ = r(() => {
57
+ let { onError: e, options: t, pagination: n, filters: r, sorters: i, meta: a, ...s } = o;
58
+ return s;
59
+ });
60
+ s(_, () => {
61
+ p.value.page = 1;
62
+ }, { deep: !0 });
63
+ let v = i(0), y = i(0), b = r(() => ({
64
+ ..._.value,
65
+ filters: h.value || {},
66
+ sorters: m.value || {},
67
+ meta: g.value || {}
68
+ })), x = l({
69
+ queryKey: r(() => [`${c.config?.name}:${d}:infinite:${o.path}`, b.value]),
70
+ queryFn: ({ pageParam: e }) => (p.value.page = e, c.config?.dataProvider?.[d]?.getList({
71
+ ...b.value,
72
+ pagination: {
73
+ ...p.value,
74
+ page: e
75
+ }
76
+ }, c, u)),
77
+ initialPageParam: 1,
78
+ getNextPageParam: (e, t, n) => {
79
+ if (!e?.data || !e?.data?.length) return;
80
+ let r = c.config?.dataProvider?.[d]?.getTotal?.(e) || 0;
81
+ if (y.value = Math.ceil(r / (p.value.pageSize || 20)) || 0, v.value = r, !(n * (p.value.pageSize || 20) >= r)) return n + 1;
82
+ },
83
+ getPreviousPageParam: (e, t, n) => {
84
+ if (n <= 1) return;
85
+ let r = c.config?.dataProvider?.[d]?.getTotal?.(e) || 0;
86
+ return y.value = Math.ceil(r / (p.value.pageSize || 20)) || 0, v.value = r, n - 1;
87
+ },
88
+ ...o.options
89
+ }), S = r(() => x.isFetching.value);
90
+ s(x.isError, (e) => {
91
+ e && (f(x.error.value), o?.onError?.(x.error.value));
92
+ });
93
+ let C = () => {
94
+ if (!(!x.hasNextPage.value || x.isFetching.value)) return x.fetchNextPage();
95
+ }, w = i(void 0);
96
+ return s(x.data, (e) => {
97
+ if (!e || !e?.pages || !e.pages?.length) return;
98
+ let t = e.pages.reduce((e, t) => t?.data && Array.isArray(t.data) && t.data?.length ? e.concat(t.data) : e, []), n = e.pages[0];
99
+ n && (w.value = {
100
+ ...n,
101
+ data: t
102
+ });
103
+ }, {
104
+ deep: !0,
105
+ immediate: !0
106
+ }), {
107
+ ...x,
108
+ isLoading: S,
109
+ data: w,
110
+ fetchNextPage: C,
111
+ hasNextPage: x.hasNextPage,
112
+ refetch: x.refetch,
113
+ pagination: p,
114
+ total: v,
115
+ pageCount: y
116
+ };
114
117
  }
115
- function W(t) {
116
- const o = h(), d = p(), i = t.providerName || "default", { mutate: c } = P(), u = s(() => {
117
- const { onError: e, options: v, ...l } = t;
118
- return l;
119
- }), n = D({
120
- queryKey: [`${o.config?.name}:${i}:${t.path}`, u],
121
- queryFn: () => o.config?.dataProvider?.[i]?.getOne(u.value, o, d),
122
- ...t.options,
123
- staleTime: 0
124
- }), r = s(() => n.isFetched.value ? !1 : n.isFetching.value);
125
- E(n.isError, (e) => {
126
- e && (c(n.error.value), t?.onError?.(n.error.value));
127
- }, {
128
- immediate: !0
129
- });
130
- const a = F(void 0);
131
- return E(n.data, (e) => {
132
- e && (a.value = e);
133
- }, {
134
- immediate: !0
135
- }), {
136
- ...n,
137
- isLoading: r,
138
- data: a,
139
- refetch: n.refetch
140
- };
118
+ /**
119
+ * Get one data
120
+ * @param params
121
+ */
122
+ function h(a) {
123
+ let o = e(), c = n(), l = a.providerName || "default", { mutate: u } = t(), f = r(() => {
124
+ let { onError: e, options: t, ...n } = a;
125
+ return n;
126
+ }), p = d({
127
+ queryKey: [`${o.config?.name}:${l}:${a.path}`, f],
128
+ queryFn: () => o.config?.dataProvider?.[l]?.getOne(f.value, o, c),
129
+ ...a.options,
130
+ staleTime: 0
131
+ }), m = r(() => p.isFetched.value ? !1 : p.isFetching.value);
132
+ s(p.isError, (e) => {
133
+ e && (u(p.error.value), a?.onError?.(p.error.value));
134
+ }, { immediate: !0 });
135
+ let h = i(void 0);
136
+ return s(p.data, (e) => {
137
+ e && (h.value = e);
138
+ }, { immediate: !0 }), {
139
+ ...p,
140
+ isLoading: m,
141
+ data: h,
142
+ refetch: p.refetch
143
+ };
141
144
  }
142
- function j(t) {
143
- const o = h(), d = p(), i = t.providerName || "default", { mutate: c } = P(), u = s(() => {
144
- const { onError: e, options: v, ...l } = t;
145
- return l;
146
- }), n = D({
147
- queryKey: [`${o.config?.name}:${i}:${t.path}`, u],
148
- queryFn: () => o.config?.dataProvider?.[i]?.getMany(u.value, o, d),
149
- ...t.options,
150
- staleTime: 0
151
- }), r = s(() => n.isFetched.value ? !1 : n.isFetching.value);
152
- E(n.isError, (e) => {
153
- e && (c(n.error.value), t?.onError?.(n.error.value));
154
- });
155
- const a = F(void 0);
156
- return E(n.data, (e) => {
157
- e && (a.value = e);
158
- }, {
159
- immediate: !0
160
- }), {
161
- ...n,
162
- isLoading: r,
163
- data: a,
164
- refetch: n.refetch
165
- };
145
+ /**
146
+ * Get many data
147
+ * @param params
148
+ */
149
+ function g(a) {
150
+ let o = e(), c = n(), l = a.providerName || "default", { mutate: u } = t(), f = r(() => {
151
+ let { onError: e, options: t, ...n } = a;
152
+ return n;
153
+ }), p = d({
154
+ queryKey: [`${o.config?.name}:${l}:${a.path}`, f],
155
+ queryFn: () => o.config?.dataProvider?.[l]?.getMany(f.value, o, c),
156
+ ...a.options,
157
+ staleTime: 0
158
+ }), m = r(() => p.isFetched.value ? !1 : p.isFetching.value);
159
+ s(p.isError, (e) => {
160
+ e && (u(p.error.value), a?.onError?.(p.error.value));
161
+ });
162
+ let h = i(void 0);
163
+ return s(p.data, (e) => {
164
+ e && (h.value = e);
165
+ }, { immediate: !0 }), {
166
+ ...p,
167
+ isLoading: m,
168
+ data: h,
169
+ refetch: p.refetch
170
+ };
166
171
  }
167
- function H(t) {
168
- const o = h(), d = p(), i = t.providerName || "default", { mutate: c } = P(), { invalidate: u } = w(), n = s(() => {
169
- const { onError: e, options: v, ...l } = t;
170
- return l;
171
- }), r = $({
172
- mutationFn: (e) => {
173
- if (!o.config?.dataProvider)
174
- throw new Error("Data provider is not initialized");
175
- return e.path && (t.path = e.path), o.config?.dataProvider?.[i]?.create({
176
- ...n.value,
177
- ...e
178
- }, o, d);
179
- },
180
- onSuccess: (e) => {
181
- t.onSuccess?.(e), t.path && u(t.path);
182
- },
183
- onError: (e) => {
184
- c(e), t?.onError?.(e);
185
- },
186
- ...t.options
187
- }), a = s(() => r.isPending.value);
188
- return {
189
- ...r,
190
- isLoading: a,
191
- mutate: r.mutate
192
- };
172
+ /**
173
+ * Create data
174
+ * @param params
175
+ */
176
+ function _(i) {
177
+ let a = e(), o = n(), s = i.providerName || "default", { mutate: c } = t(), { invalidate: l } = E(), d = r(() => {
178
+ let { onError: e, options: t, ...n } = i;
179
+ return n;
180
+ }), f = u({
181
+ mutationFn: (e) => {
182
+ if (!a.config?.dataProvider) throw Error("Data provider is not initialized");
183
+ return e.path && (i.path = e.path), a.config?.dataProvider?.[s]?.create({
184
+ ...d.value,
185
+ ...e
186
+ }, a, o);
187
+ },
188
+ onSuccess: (e) => {
189
+ i.onSuccess?.(e), i.path && l(i.path);
190
+ },
191
+ onError: (e) => {
192
+ c(e), i?.onError?.(e);
193
+ },
194
+ ...i.options
195
+ }), p = r(() => f.isPending.value);
196
+ return {
197
+ ...f,
198
+ isLoading: p,
199
+ mutate: f.mutate
200
+ };
193
201
  }
194
- function J(t) {
195
- const o = h(), d = p(), i = t.providerName || "default", { mutate: c } = P(), { invalidate: u } = w(), n = s(() => {
196
- const { onError: e, options: v, ...l } = t;
197
- return l;
198
- }), r = $({
199
- mutationFn: (e) => {
200
- if (!o.config?.dataProvider)
201
- throw new Error("Data provider is not initialized");
202
- return e.path && (t.path = e.path), o.config?.dataProvider?.[i]?.createMany({
203
- ...n.value,
204
- ...e
205
- }, o, d);
206
- },
207
- onSuccess: (e) => {
208
- t.onSuccess?.(e), t.path && u(t.path);
209
- },
210
- onError: (e) => {
211
- c(e), t?.onError?.(e);
212
- },
213
- ...t.options
214
- }), a = s(() => r.isPending.value);
215
- return {
216
- ...r,
217
- isLoading: a,
218
- mutate: r.mutate
219
- };
202
+ /**
203
+ * Create data
204
+ * @param params
205
+ */
206
+ function v(i) {
207
+ let a = e(), o = n(), s = i.providerName || "default", { mutate: c } = t(), { invalidate: l } = E(), d = r(() => {
208
+ let { onError: e, options: t, ...n } = i;
209
+ return n;
210
+ }), f = u({
211
+ mutationFn: (e) => {
212
+ if (!a.config?.dataProvider) throw Error("Data provider is not initialized");
213
+ return e.path && (i.path = e.path), a.config?.dataProvider?.[s]?.createMany({
214
+ ...d.value,
215
+ ...e
216
+ }, a, o);
217
+ },
218
+ onSuccess: (e) => {
219
+ i.onSuccess?.(e), i.path && l(i.path);
220
+ },
221
+ onError: (e) => {
222
+ c(e), i?.onError?.(e);
223
+ },
224
+ ...i.options
225
+ }), p = r(() => f.isPending.value);
226
+ return {
227
+ ...f,
228
+ isLoading: p,
229
+ mutate: f.mutate
230
+ };
220
231
  }
221
- function V(t) {
222
- const o = h(), d = p(), i = t.providerName || "default", { mutate: c } = P(), { invalidate: u } = w(), n = s(() => {
223
- const { onError: e, options: v, ...l } = t;
224
- return l;
225
- }), r = $({
226
- mutationFn: (e) => {
227
- if (!o.config?.dataProvider)
228
- throw new Error("Data provider is not initialized");
229
- return e.path && (t.path = e.path), o.config?.dataProvider?.[i]?.update({
230
- ...n.value,
231
- ...e
232
- }, o, d);
233
- },
234
- onSuccess: (e) => {
235
- t.onSuccess?.(e), t.path && u(t.path);
236
- },
237
- onError: (e) => {
238
- c(e), t?.onError?.(e);
239
- },
240
- ...t.options
241
- }), a = s(() => r.isPending.value);
242
- return {
243
- ...r,
244
- isLoading: a,
245
- mutate: r.mutate
246
- };
232
+ /**
233
+ * Update data
234
+ * @param params
235
+ */
236
+ function y(i) {
237
+ let a = e(), o = n(), s = i.providerName || "default", { mutate: c } = t(), { invalidate: l } = E(), d = r(() => {
238
+ let { onError: e, options: t, ...n } = i;
239
+ return n;
240
+ }), f = u({
241
+ mutationFn: (e) => {
242
+ if (!a.config?.dataProvider) throw Error("Data provider is not initialized");
243
+ return e.path && (i.path = e.path), a.config?.dataProvider?.[s]?.update({
244
+ ...d.value,
245
+ ...e
246
+ }, a, o);
247
+ },
248
+ onSuccess: (e) => {
249
+ i.onSuccess?.(e), i.path && l(i.path);
250
+ },
251
+ onError: (e) => {
252
+ c(e), i?.onError?.(e);
253
+ },
254
+ ...i.options
255
+ }), p = r(() => f.isPending.value);
256
+ return {
257
+ ...f,
258
+ isLoading: p,
259
+ mutate: f.mutate
260
+ };
247
261
  }
248
- function X(t) {
249
- const o = h(), d = p(), i = t.providerName || "default", { mutate: c } = P(), { invalidate: u } = w(), n = s(() => {
250
- const { onError: e, options: v, ...l } = t;
251
- return l;
252
- }), r = $({
253
- mutationFn: (e) => {
254
- if (!o.config?.dataProvider)
255
- throw new Error("Data provider is not initialized");
256
- return e.path && (t.path = e.path), o.config?.dataProvider?.[i]?.updateMany({
257
- ...n.value,
258
- ...e
259
- }, o, d);
260
- },
261
- onSuccess: (e) => {
262
- t.onSuccess?.(e), t.path && u(t.path);
263
- },
264
- onError: (e) => {
265
- c(e), t?.onError?.(e);
266
- },
267
- ...t.options
268
- }), a = s(() => r.isPending.value);
269
- return {
270
- ...r,
271
- isLoading: a,
272
- mutate: r.mutate
273
- };
262
+ function b(i) {
263
+ let a = e(), o = n(), s = i.providerName || "default", { mutate: c } = t(), { invalidate: l } = E(), d = r(() => {
264
+ let { onError: e, options: t, ...n } = i;
265
+ return n;
266
+ }), f = u({
267
+ mutationFn: (e) => {
268
+ if (!a.config?.dataProvider) throw Error("Data provider is not initialized");
269
+ return e.path && (i.path = e.path), a.config?.dataProvider?.[s]?.updateMany({
270
+ ...d.value,
271
+ ...e
272
+ }, a, o);
273
+ },
274
+ onSuccess: (e) => {
275
+ i.onSuccess?.(e), i.path && l(i.path);
276
+ },
277
+ onError: (e) => {
278
+ c(e), i?.onError?.(e);
279
+ },
280
+ ...i.options
281
+ }), p = r(() => f.isPending.value);
282
+ return {
283
+ ...f,
284
+ isLoading: p,
285
+ mutate: f.mutate
286
+ };
274
287
  }
275
- function Y(t) {
276
- const o = h(), d = p(), i = t.providerName || "default", { mutate: c } = P(), { invalidate: u } = w(), n = s(() => {
277
- const { onError: e, options: v, ...l } = t;
278
- return l;
279
- }), r = $({
280
- mutationFn: (e) => {
281
- if (!o.config?.dataProvider)
282
- throw new Error("Data provider is not initialized");
283
- return e.path && (t.path = e.path), o.config?.dataProvider?.[i]?.deleteOne({
284
- ...n.value,
285
- ...e
286
- }, o, d);
287
- },
288
- onSuccess: (e) => {
289
- t.onSuccess?.(e), t.path && u(t.path);
290
- },
291
- onError: (e) => {
292
- c(e), t?.onError?.(e);
293
- },
294
- ...t.options
295
- }), a = s(() => r.isPending.value);
296
- return {
297
- ...r,
298
- isLoading: a,
299
- mutate: r.mutate
300
- };
288
+ /**
289
+ * Update data
290
+ * @param params
291
+ */
292
+ function x(i) {
293
+ let a = e(), o = n(), s = i.providerName || "default", { mutate: c } = t(), { invalidate: l } = E(), d = r(() => {
294
+ let { onError: e, options: t, ...n } = i;
295
+ return n;
296
+ }), f = u({
297
+ mutationFn: (e) => {
298
+ if (!a.config?.dataProvider) throw Error("Data provider is not initialized");
299
+ return e.path && (i.path = e.path), a.config?.dataProvider?.[s]?.deleteOne({
300
+ ...d.value,
301
+ ...e
302
+ }, a, o);
303
+ },
304
+ onSuccess: (e) => {
305
+ i.onSuccess?.(e), i.path && l(i.path);
306
+ },
307
+ onError: (e) => {
308
+ c(e), i?.onError?.(e);
309
+ },
310
+ ...i.options
311
+ }), p = r(() => f.isPending.value);
312
+ return {
313
+ ...f,
314
+ isLoading: p,
315
+ mutate: f.mutate
316
+ };
301
317
  }
302
- function Z(t) {
303
- const o = h(), d = p(), i = t.providerName || "default", { mutate: c } = P(), { invalidate: u } = w(), n = s(() => {
304
- const { onError: e, options: v, ...l } = t;
305
- return l;
306
- }), r = $({
307
- mutationFn: (e) => {
308
- if (!o.config?.dataProvider)
309
- throw new Error("Data provider is not initialized");
310
- return e.path && (t.path = e.path), o.config?.dataProvider?.[i]?.deleteMany({
311
- ...n.value,
312
- ...e
313
- }, o, d);
314
- },
315
- onSuccess: (e) => {
316
- t.onSuccess?.(e), t.path && u(t.path);
317
- },
318
- onError: (e) => {
319
- c(e), t?.onError?.(e);
320
- },
321
- ...t.options
322
- }), a = s(() => r.isPending.value);
323
- return {
324
- ...r,
325
- isLoading: a,
326
- mutate: r.mutate
327
- };
318
+ /**
319
+ * Update data
320
+ * @param params
321
+ */
322
+ function S(i) {
323
+ let a = e(), o = n(), s = i.providerName || "default", { mutate: c } = t(), { invalidate: l } = E(), d = r(() => {
324
+ let { onError: e, options: t, ...n } = i;
325
+ return n;
326
+ }), f = u({
327
+ mutationFn: (e) => {
328
+ if (!a.config?.dataProvider) throw Error("Data provider is not initialized");
329
+ return e.path && (i.path = e.path), a.config?.dataProvider?.[s]?.deleteMany({
330
+ ...d.value,
331
+ ...e
332
+ }, a, o);
333
+ },
334
+ onSuccess: (e) => {
335
+ i.onSuccess?.(e), i.path && l(i.path);
336
+ },
337
+ onError: (e) => {
338
+ c(e), i?.onError?.(e);
339
+ },
340
+ ...i.options
341
+ }), p = r(() => f.isPending.value);
342
+ return {
343
+ ...f,
344
+ isLoading: p,
345
+ mutate: f.mutate
346
+ };
328
347
  }
329
- function tt(t) {
330
- const o = h(), d = p(), i = t?.providerName || "default", { mutate: c } = P(), u = s(() => {
331
- if (!t)
332
- return {};
333
- const { onError: e, options: v, ...l } = t;
334
- return l;
335
- }), n = D({
336
- queryKey: [`${o.config?.name}:${i}:${t?.path}`, u],
337
- queryFn: () => o.config?.dataProvider?.[i]?.custom(u.value, o, d),
338
- ...t?.options
339
- }), r = s(() => n.isFetched.value ? !1 : n.isFetching.value);
340
- E(n.isError, (e) => {
341
- e && (c(n.error.value), t?.onError?.(n.error.value));
342
- });
343
- const a = F(void 0);
344
- return E(n.data, (e) => {
345
- e && (a.value = e);
346
- }, {
347
- immediate: !0
348
- }), {
349
- ...n,
350
- isLoading: r,
351
- data: a,
352
- refetch: n.refetch
353
- };
348
+ /**
349
+ * Custom query request
350
+ * @param params
351
+ */
352
+ function C(a) {
353
+ let o = e(), c = n(), l = a?.providerName || "default", { mutate: u } = t(), f = r(() => {
354
+ if (!a) return {};
355
+ let { onError: e, options: t, ...n } = a;
356
+ return n;
357
+ }), p = d({
358
+ queryKey: [`${o.config?.name}:${l}:${a?.path}`, f],
359
+ queryFn: () => o.config?.dataProvider?.[l]?.custom(f.value, o, c),
360
+ ...a?.options
361
+ }), m = r(() => p.isFetched.value ? !1 : p.isFetching.value);
362
+ s(p.isError, (e) => {
363
+ e && (u(p.error.value), a?.onError?.(p.error.value));
364
+ });
365
+ let h = i(void 0);
366
+ return s(p.data, (e) => {
367
+ e && (h.value = e);
368
+ }, { immediate: !0 }), {
369
+ ...p,
370
+ isLoading: m,
371
+ data: h,
372
+ refetch: p.refetch
373
+ };
354
374
  }
355
- function et(t) {
356
- const o = h(), d = p(), i = t?.providerName || "default", { mutate: c } = P(), u = s(() => {
357
- if (!t)
358
- return {};
359
- const { onError: a, options: e, ...v } = t;
360
- return v;
361
- }), n = $({
362
- mutationFn: (a) => {
363
- if (!o.config?.dataProvider)
364
- throw new Error("Data provider is not initialized");
365
- return o.config?.dataProvider?.[i]?.custom({
366
- ...u.value,
367
- ...a
368
- }, o, d);
369
- },
370
- onSuccess: (a) => {
371
- n.reset(), t?.onSuccess?.(a);
372
- },
373
- onError: (a) => {
374
- c(a), t?.onError?.(a);
375
- },
376
- ...t?.options
377
- }), r = s(() => n.isPending.value);
378
- return {
379
- ...n,
380
- isLoading: r,
381
- mutate: n.mutate
382
- };
375
+ /**
376
+ * Custom mutation request
377
+ * @param params
378
+ */
379
+ function w(i) {
380
+ let a = e(), o = n(), s = i?.providerName || "default", { mutate: c } = t(), l = r(() => {
381
+ if (!i) return {};
382
+ let { onError: e, options: t, ...n } = i;
383
+ return n;
384
+ }), d = u({
385
+ mutationFn: (e) => {
386
+ if (!a.config?.dataProvider) throw Error("Data provider is not initialized");
387
+ return a.config?.dataProvider?.[s]?.custom({
388
+ ...l.value,
389
+ ...e
390
+ }, a, o);
391
+ },
392
+ onSuccess: (e) => {
393
+ d.reset(), i?.onSuccess?.(e);
394
+ },
395
+ onError: (e) => {
396
+ c(e), i?.onError?.(e);
397
+ },
398
+ ...i?.options
399
+ }), f = r(() => d.isPending.value);
400
+ return {
401
+ ...d,
402
+ isLoading: f,
403
+ mutate: d.mutate
404
+ };
383
405
  }
384
- function ot() {
385
- const t = h(), o = p();
386
- return {
387
- request: (i) => {
388
- if (!t.config?.dataProvider)
389
- throw new Error("Data provider is not initialized");
390
- const c = i.providerName || "default";
391
- return t.config?.dataProvider?.[c]?.custom({
392
- ...i
393
- }, t, o);
394
- }
395
- };
406
+ /**
407
+ * Custom request client
408
+ */
409
+ function T() {
410
+ let t = e(), r = n();
411
+ return { request: (e) => {
412
+ if (!t.config?.dataProvider) throw Error("Data provider is not initialized");
413
+ let n = e.providerName || "default";
414
+ return t.config?.dataProvider?.[n]?.custom({ ...e }, t, r);
415
+ } };
396
416
  }
397
- function w() {
398
- const t = k(), o = h();
399
- return {
400
- invalidate: (i, c) => {
401
- let u = i;
402
- Array.isArray(i) || (u = [i]);
403
- for (const n of u) {
404
- let r = n;
405
- o.config?.apiBasePath && r.startsWith(o.config.apiBasePath) && (r = B(r.substring(o.config.apiBasePath.length), "/"));
406
- const a = `${o.config?.name}:${c || "default"}:${r}`;
407
- t.invalidateQueries({
408
- queryKey: [a]
409
- });
410
- }
411
- }
412
- };
417
+ function E() {
418
+ let t = f(), n = e();
419
+ return { invalidate: (e, r) => {
420
+ let i = e;
421
+ Array.isArray(e) || (i = [e]);
422
+ for (let e of i) {
423
+ let i = e;
424
+ n.config?.apiBasePath && i.startsWith(n.config.apiBasePath) && (i = c(i.substring(n.config.apiBasePath.length), "/"));
425
+ let a = `${n.config?.name}:${r || "default"}:${i}`;
426
+ t.invalidateQueries({ queryKey: [a] });
427
+ }
428
+ } };
413
429
  }
414
- export {
415
- ot as useClient,
416
- H as useCreate,
417
- J as useCreateMany,
418
- tt as useCustom,
419
- et as useCustomMutation,
420
- Y as useDelete,
421
- Z as useDeleteMany,
422
- R as useInfiniteList,
423
- w as useInvalidate,
424
- G as useList,
425
- j as useMany,
426
- W as useOne,
427
- V as useUpdate,
428
- X as useUpdateMany
429
- };
430
+ export { T as useClient, _ as useCreate, v as useCreateMany, C as useCustom, w as useCustomMutation, x as useDelete, S as useDeleteMany, m as useInfiniteList, E as useInvalidate, p as useList, g as useMany, h as useOne, y as useUpdate, b as useUpdateMany };