@duxweb/dvha-core 1.0.43 → 1.0.45
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/data.cjs +1 -1
- package/dist/cjs/provider/app.cjs +1 -1
- package/dist/esm/hooks/data.js +113 -110
- package/dist/esm/provider/app.js +1 -1
- package/package.json +1 -1
package/dist/cjs/hooks/data.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const E=require("@tanstack/vue-query"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const E=require("@tanstack/vue-query"),L=require("lodash-es"),r=require("vue"),l=require("./auth.cjs"),p=require("./manage.cjs");function z(e){const o=p.useManage(),f=l.useGetAuth(),i=e.providerName||"default",{mutate:d}=l.useError(),a=r.toRef(e.pagination?e.pagination:{page:1,pageSize:20}),n=r.toRef(e,"sorters",{}),u=r.toRef(e,"filters",{}),s=r.toRef(e,"meta",{}),t=r.computed(()=>{const{onError:P,options:v,pagination:N,filters:y,sorters:m,meta:$,...S}=e;return S});r.watch(t,()=>{e.pagination&&(a.value.page=1)},{deep:!0});const g=r.computed(()=>({...t.value,pagination:e.pagination?a.value:void 0,filters:u.value||{},sorters:n.value||{},meta:s.value||{}})),c=E.useQuery({queryKey:[`${o.config?.name}:${i}:${e.path}`,g.value],queryFn:()=>o.config?.dataProvider?.[i]?.getList(g.value,o,f),...e.options}),A=r.computed(()=>c.isFetching.value);r.watch(c.isError,P=>{P&&(d(c.error.value),e?.onError?.(c.error.value))});const h=r.ref(void 0),q=r.ref(0),w=r.ref(0);return r.watch(c.data,P=>{P&&(h.value=P,q.value=o.config?.dataProvider?.[i]?.getTotal?.(P)||0,w.value=Math.ceil(q.value/(a.value.pageSize||20))||0)},{immediate:!0}),{...c,isLoading:A,data:h,refetch:c.refetch,pagination:a,total:q,pageCount:w}}function C(e){const o=p.useManage(),f=l.useGetAuth(),i=e.providerName||"default",{mutate:d}=l.useError(),a=r.toRef(e,"pagination",{page:1,pageSize:20}),n=r.toRef(e,"sorters",{}),u=r.toRef(e,"filters",{}),s=r.toRef(e,"meta",{}),t=r.computed(()=>{const{onError:v,options:N,pagination:y,filters:m,sorters:$,meta:S,...F}=e;return F});r.watch(t,()=>{a.value.page=1},{deep:!0});const g=r.ref(0),c=r.ref(0),A=r.computed(()=>({...t.value,filters:u.value||{},sorters:n.value||{},meta:s.value||{}})),h=E.useInfiniteQuery({queryKey:[`${o.config?.name}:${i}:${e.path}:infinite`,A.value],queryFn:({pageParam:v})=>(a.value.page=v,o.config?.dataProvider?.[i]?.getList({...A.value,pagination:{...a.value,page:v}},o,f)),initialPageParam:1,getNextPageParam:(v,N,y)=>{if(!v?.data||!v?.data?.length)return;const m=o.config?.dataProvider?.[i]?.getTotal?.(v)||0;if(c.value=Math.ceil(m/(a.value.pageSize||20))||0,g.value=m,!(y*(a.value.pageSize||20)>=m))return y+1},getPreviousPageParam:(v,N,y)=>{if(y<=1)return;const m=o.config?.dataProvider?.[i]?.getTotal?.(v)||0;return c.value=Math.ceil(m/(a.value.pageSize||20))||0,g.value=m,y-1},...e.options}),q=r.computed(()=>h.isFetching.value);r.watch(h.isError,v=>{v&&(d(h.error.value),e?.onError?.(h.error.value))});const w=()=>{if(!(!h.hasNextPage.value||h.isFetching.value))return h.fetchNextPage()},P=r.ref(void 0);return r.watch(h.data,v=>{if(!v||!v?.pages||!v.pages?.length)return;const N=v.pages.reduce((m,$)=>$?.data&&Array.isArray($.data)&&$.data?.length?m.concat($.data):m,[]),y=v.pages[0];y&&(P.value={...y,data:N})},{deep:!0,immediate:!0}),{...h,isLoading:q,data:P,fetchNextPage:w,hasNextPage:h.hasNextPage,refetch:h.refetch,pagination:a,total:g,pageCount:c}}function D(e){const o=p.useManage(),f=l.useGetAuth(),i=e.providerName||"default",{mutate:d}=l.useError(),a=r.computed(()=>{const{onError:t,options:g,...c}=e;return c}),n=E.useQuery({queryKey:[`${o.config?.name}:${i}:${e.path}`,a],queryFn:()=>o.config?.dataProvider?.[i]?.getOne(a.value,o,f),...e.options}),u=r.computed(()=>n.isFetched.value?!1:n.isFetching.value);r.watch(n.isError,t=>{t&&(d(n.error.value),e?.onError?.(n.error.value))},{immediate:!0});const s=r.ref(void 0);return r.watch(n.data,t=>{t&&(s.value=t)},{immediate:!0}),{...n,isLoading:u,data:s,refetch:n.refetch}}function G(e){const o=p.useManage(),f=l.useGetAuth(),i=e.providerName||"default",{mutate:d}=l.useError(),a=r.computed(()=>{const{onError:t,options:g,...c}=e;return c}),n=E.useQuery({queryKey:[`${o.config?.name}:${i}:${e.path}`,a],queryFn:()=>o.config?.dataProvider?.[i]?.getMany(a.value,o,f),...e.options}),u=r.computed(()=>n.isFetched.value?!1:n.isFetching.value);r.watch(n.isError,t=>{t&&(d(n.error.value),e?.onError?.(n.error.value))});const s=r.ref(void 0);return r.watch(n.data,t=>{t&&(s.value=t)},{immediate:!0}),{...n,isLoading:u,data:s,refetch:n.refetch}}function Q(e){const o=p.useManage(),f=l.useGetAuth(),i=e.providerName||"default",{mutate:d}=l.useError(),{invalidate:a}=M(),n=r.computed(()=>{const{onError:t,options:g,...c}=e;return c}),u=E.useMutation({mutationFn:t=>{if(!o.config?.dataProvider)throw new Error("Data provider is not initialized");return t.path&&(e.path=t.path),o.config?.dataProvider?.[i]?.create({...n.value,...t},o,f)},onSuccess:t=>{e.onSuccess?.(t),e.path&&a(e.path)},onError:t=>{d(t),e?.onError?.(t)},...e.options}),s=r.computed(()=>u.isPending.value);return{...u,isLoading:s,mutate:u.mutate}}function R(e){const o=p.useManage(),f=l.useGetAuth(),i=e.providerName||"default",{mutate:d}=l.useError(),{invalidate:a}=M(),n=r.computed(()=>{const{onError:t,options:g,...c}=e;return c}),u=E.useMutation({mutationFn:t=>{if(!o.config?.dataProvider)throw new Error("Data provider is not initialized");return t.path&&(e.path=t.path),o.config?.dataProvider?.[i]?.createMany({...n.value,...t},o,f)},onSuccess:t=>{e.onSuccess?.(t),e.path&&a(e.path)},onError:t=>{d(t),e?.onError?.(t)},...e.options}),s=r.computed(()=>u.isPending.value);return{...u,isLoading:s,mutate:u.mutate}}function T(e){const o=p.useManage(),f=l.useGetAuth(),i=e.providerName||"default",{mutate:d}=l.useError(),{invalidate:a}=M(),n=r.computed(()=>{const{onError:t,options:g,...c}=e;return c}),u=E.useMutation({mutationFn:t=>{if(!o.config?.dataProvider)throw new Error("Data provider is not initialized");return t.path&&(e.path=t.path),o.config?.dataProvider?.[i]?.update({...n.value,...t},o,f)},onSuccess:t=>{e.onSuccess?.(t),e.path&&a(e.path)},onError:t=>{d(t),e?.onError?.(t)},...e.options}),s=r.computed(()=>u.isPending.value);return{...u,isLoading:s,mutate:u.mutate}}function x(e){const o=p.useManage(),f=l.useGetAuth(),i=e.providerName||"default",{mutate:d}=l.useError(),{invalidate:a}=M(),n=r.computed(()=>{const{onError:t,options:g,...c}=e;return c}),u=E.useMutation({mutationFn:t=>{if(!o.config?.dataProvider)throw new Error("Data provider is not initialized");return t.path&&(e.path=t.path),o.config?.dataProvider?.[i]?.updateMany({...n.value,...t},o,f)},onSuccess:t=>{e.onSuccess?.(t),e.path&&a(e.path)},onError:t=>{d(t),e?.onError?.(t)},...e.options}),s=r.computed(()=>u.isPending.value);return{...u,isLoading:s,mutate:u.mutate}}function K(e){const o=p.useManage(),f=l.useGetAuth(),i=e.providerName||"default",{mutate:d}=l.useError(),{invalidate:a}=M(),n=r.computed(()=>{const{onError:t,options:g,...c}=e;return c}),u=E.useMutation({mutationFn:t=>{if(!o.config?.dataProvider)throw new Error("Data provider is not initialized");return t.path&&(e.path=t.path),o.config?.dataProvider?.[i]?.deleteOne({...n.value,...t},o,f)},onSuccess:t=>{e.onSuccess?.(t),e.path&&a(e.path)},onError:t=>{d(t),e?.onError?.(t)},...e.options}),s=r.computed(()=>u.isPending.value);return{...u,isLoading:s,mutate:u.mutate}}function I(e){const o=p.useManage(),f=l.useGetAuth(),i=e.providerName||"default",{mutate:d}=l.useError(),{invalidate:a}=M(),n=r.computed(()=>{const{onError:t,options:g,...c}=e;return c}),u=E.useMutation({mutationFn:t=>{if(!o.config?.dataProvider)throw new Error("Data provider is not initialized");return t.path&&(e.path=t.path),o.config?.dataProvider?.[i]?.deleteMany({...n.value,...t},o,f)},onSuccess:t=>{e.onSuccess?.(t),e.path&&a(e.path)},onError:t=>{d(t),e?.onError?.(t)},...e.options}),s=r.computed(()=>u.isPending.value);return{...u,isLoading:s,mutate:u.mutate}}function O(e){const o=p.useManage(),f=l.useGetAuth(),i=e?.providerName||"default",{mutate:d}=l.useError(),a=r.computed(()=>{if(!e)return{};const{onError:t,options:g,...c}=e;return c}),n=E.useQuery({queryKey:[`${o.config?.name}:${i}:${e?.path}`,a],queryFn:()=>o.config?.dataProvider?.[i]?.custom(a.value,o,f),...e?.options}),u=r.computed(()=>n.isFetched.value?!1:n.isFetching.value);r.watch(n.isError,t=>{t&&(d(n.error.value),e?.onError?.(n.error.value))});const s=r.ref(void 0);return r.watch(n.data,t=>{t&&(s.value=t)},{immediate:!0}),{...n,isLoading:u,data:s,refetch:n.refetch}}function U(e){const o=p.useManage(),f=l.useGetAuth(),i=e?.providerName||"default",{mutate:d}=l.useError(),a=r.computed(()=>{if(!e)return{};const{onError:s,options:t,...g}=e;return g}),n=E.useMutation({mutationFn:s=>{if(!o.config?.dataProvider)throw new Error("Data provider is not initialized");return o.config?.dataProvider?.[i]?.custom({...a.value,...s},o,f)},onSuccess:s=>{n.reset(),e?.onSuccess?.(s)},onError:s=>{d(s),e?.onError?.(s)},...e?.options}),u=r.computed(()=>n.isPending.value);return{...n,isLoading:u,mutate:n.mutate}}function b(){const e=p.useManage(),o=l.useGetAuth();return{request:i=>{if(!e.config?.dataProvider)throw new Error("Data provider is not initialized");const d=i.providerName||"default";return e.config?.dataProvider?.[d]?.custom({...i},e,o)}}}function M(){const e=E.useQueryClient(),o=p.useManage();return{invalidate:(i,d)=>{let a=i;Array.isArray(i)||(a=[i]);for(const n of a){let u=n;o.config?.apiBasePath&&u.startsWith(o.config.apiBasePath)&&(u=L.trimStart(u.substring(o.config.apiBasePath.length),"/"));const s=`${o.config?.name}:${d||"default"}:${u}`;e.invalidateQueries({queryKey:[s]})}}}}exports.useClient=b;exports.useCreate=Q;exports.useCreateMany=R;exports.useCustom=O;exports.useCustomMutation=U;exports.useDelete=K;exports.useDeleteMany=I;exports.useInfiniteList=C;exports.useInvalidate=M;exports.useList=z;exports.useMany=G;exports.useOne=D;exports.useUpdate=T;exports.useUpdateMany=x;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("vue"),$=require("@overlastic/vue"),A=require("vue-router"),S=require("../hooks/auth.cjs"),M=require("../hooks/config.cjs");require("@tanstack/vue-query");const k=require("../hooks/manage.cjs");require("json-2-csv");require("
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("vue"),$=require("@overlastic/vue"),A=require("vue-router"),S=require("../hooks/auth.cjs"),M=require("../hooks/config.cjs");require("@tanstack/vue-query");require("lodash-es");const k=require("../hooks/manage.cjs");require("json-2-csv");require("@vee-validate/rules");require("vee-validate");const z=require("../stores/auth.cjs"),D=require("../stores/i18n.cjs");require("pinia");const w=require("../stores/manage.cjs"),C=require("../stores/route.cjs");require("@vueuse/core");const E=require("../hooks/json.cjs");require("../hooks/json/index.cjs");require("../utils/bus.cjs");require("colorizr");require("axios");require("clsx");const F=require("../components/status/error.cjs"),I=require("../components/status/notAuthorized.cjs"),N=require("../components/status/notFound.cjs"),x=d.defineComponent({name:"DuxAppProvider",props:{},setup(y,{slots:R}){const m=d.inject("dux.manage"),s=M.useConfig(),p=A.useRouter();return p.beforeEach(async(a,j,u)=>{const e=a.meta.manageName,P=a.meta.authorization===!1;if(!e){const t=s.defaultManage||s.manages?.[0]?.name||"";return u({path:`/${t}`,replace:!0})}m&&(m.value=e);const f=w.useManageStore(e);f.isInit()||f.setConfig(s.manages?.find(t=>t.name===e),s);const c=C.useRouteStore(e),r=k.useManage(e),h=z.useAuthStore(e),l=D.useI18nStore(e);if(r.config?.i18nProvider&&!l.isInit()){const t=l.getLocale();t&&r.config?.i18nProvider.changeLocale(t)}if(E.initJsonSchemaComponents(s,e),!h.isLogin())return P?u():u({path:r.getRoutePath("login"),replace:!0});const g=t=>t?.map(i=>({...i,path:i.path?r.getRoutePath(i.path):void 0}));if(!c.getRouteInit()){const t=r.config?.components||{},i=[];return i.push({name:`${e}.notFound`,label:"404",path:":pathMatch(.*)*",component:t.notFound||N.DuxNotFound,hidden:!0,meta:{can:!1}}),i.push({name:`${e}.notAuthorized`,label:"403",path:"notAuthorized",component:t.notAuthorized||I.DuxNotAuthorized,hidden:!0,meta:{can:!1}}),i.push({name:`${e}.error`,label:"500",path:"error",component:t.error||F.DuxError,hidden:!0,meta:{can:!1}}),c.setRoutes(g(r.config?.menus||[])),r.config?.apiRoutePath&&await r.config?.dataProvider?.default?.custom({path:r.config.apiRoutePath,meta:{timeout:5e3}},r,h.getUser()).then(o=>{c.appendRoutes(g(o.data||[]))}).catch(o=>{throw r.config?.authProvider?.onError?.(o).then(n=>{n?.logout&&(h.logout(),p.push(r.getRoutePath(n.redirectTo||"/login")))}),o}),c.appendRoutes(i),c.getRoutes().forEach(o=>{if(!o.path)return;const n={name:o.name,path:o.path,meta:o.meta};switch(o.loader){case"iframe":n.component=r.config?.components?.iframe||(()=>Promise.resolve().then(()=>require("../components/loader/iframe.cjs")));break;case"remote":n.component=r.config?.components?.remote||(()=>Promise.resolve().then(()=>require("../components/loader/loader.cjs")));break;case"link":n.beforeEnter=()=>{const v=o.meta?.url||o.path;return v&&window.open(v,"_blank"),!1},n.component=()=>Promise.resolve({template:"<div></div>"});break;default:o.component&&(n.component=o.component);break}p.addRoute(`${e}.auth`,n)}),u({path:a.redirectedFrom?.path||a.path,replace:!0})}const q=["","/",`/${e}`,`/${e}/`];if(q.includes(a.path)){const t=c.getIndexRoute();return!t?.path||q.includes(t?.path)?(console.warn("[Dux] index route not found, skip redirect"),u()):u({path:t?.path||"/",replace:!0})}const b=S.useCan(e);return(a.meta?.can===void 0||a.meta?.can===!0)&&!b(a.name)?u({name:`${e}.notAuthorized`}):u()}),()=>d.createVNode($.OverlaysProvider,null,{default:()=>[R.default?.()]})}});exports.DuxAppProvider=x;
|
package/dist/esm/hooks/data.js
CHANGED
|
@@ -1,26 +1,27 @@
|
|
|
1
1
|
import { useQuery as D, useInfiniteQuery as T, useMutation as $, useQueryClient as K } from "@tanstack/vue-query";
|
|
2
|
+
import { trimStart as Q } from "lodash-es";
|
|
2
3
|
import { toRef as F, computed as d, watch as E, ref as q } from "vue";
|
|
3
4
|
import { useGetAuth as p, useError as P } from "./auth.js";
|
|
4
5
|
import { useManage as h } from "./manage.js";
|
|
5
|
-
function
|
|
6
|
-
const o = h(), l = p(),
|
|
6
|
+
function _(t) {
|
|
7
|
+
const o = h(), l = p(), i = t.providerName || "default", { mutate: c } = P(), u = F(t.pagination ? t.pagination : { page: 1, pageSize: 20 }), n = F(t, "sorters", {}), r = F(t, "filters", {}), a = F(t, "meta", {}), e = d(() => {
|
|
7
8
|
const { onError: N, options: f, pagination: L, filters: y, sorters: m, meta: S, ...C } = t;
|
|
8
9
|
return C;
|
|
9
10
|
});
|
|
10
11
|
E(e, () => {
|
|
11
|
-
t.pagination && (
|
|
12
|
+
t.pagination && (u.value.page = 1);
|
|
12
13
|
}, {
|
|
13
14
|
deep: !0
|
|
14
15
|
});
|
|
15
16
|
const v = d(() => ({
|
|
16
17
|
...e.value,
|
|
17
|
-
pagination: t.pagination ?
|
|
18
|
-
filters:
|
|
18
|
+
pagination: t.pagination ? u.value : void 0,
|
|
19
|
+
filters: r.value || {},
|
|
19
20
|
sorters: n.value || {},
|
|
20
21
|
meta: a.value || {}
|
|
21
22
|
})), s = D({
|
|
22
|
-
queryKey: [`${o.config?.name}:${
|
|
23
|
-
queryFn: () => o.config?.dataProvider?.[
|
|
23
|
+
queryKey: [`${o.config?.name}:${i}:${t.path}`, v.value],
|
|
24
|
+
queryFn: () => o.config?.dataProvider?.[i]?.getList(v.value, o, l),
|
|
24
25
|
...t.options
|
|
25
26
|
}), z = d(() => s.isFetching.value);
|
|
26
27
|
E(s.isError, (N) => {
|
|
@@ -28,7 +29,7 @@ function U(t) {
|
|
|
28
29
|
});
|
|
29
30
|
const g = q(void 0), A = q(0), M = q(0);
|
|
30
31
|
return E(s.data, (N) => {
|
|
31
|
-
N && (g.value = N, A.value = o.config?.dataProvider?.[
|
|
32
|
+
N && (g.value = N, A.value = o.config?.dataProvider?.[i]?.getTotal?.(N) || 0, M.value = Math.ceil(A.value / (u.value.pageSize || 20)) || 0);
|
|
32
33
|
}, {
|
|
33
34
|
immediate: !0
|
|
34
35
|
}), {
|
|
@@ -36,32 +37,32 @@ function U(t) {
|
|
|
36
37
|
isLoading: z,
|
|
37
38
|
data: g,
|
|
38
39
|
refetch: s.refetch,
|
|
39
|
-
pagination:
|
|
40
|
+
pagination: u,
|
|
40
41
|
total: A,
|
|
41
42
|
pageCount: M
|
|
42
43
|
};
|
|
43
44
|
}
|
|
44
|
-
function
|
|
45
|
-
const o = h(), l = p(),
|
|
45
|
+
function b(t) {
|
|
46
|
+
const o = h(), l = p(), i = t.providerName || "default", { mutate: c } = P(), u = F(t, "pagination", { page: 1, pageSize: 20 }), n = F(t, "sorters", {}), r = F(t, "filters", {}), a = F(t, "meta", {}), e = d(() => {
|
|
46
47
|
const { onError: f, options: L, pagination: y, filters: m, sorters: S, meta: C, ...x } = t;
|
|
47
48
|
return x;
|
|
48
49
|
});
|
|
49
50
|
E(e, () => {
|
|
50
|
-
|
|
51
|
+
u.value.page = 1;
|
|
51
52
|
}, {
|
|
52
53
|
deep: !0
|
|
53
54
|
});
|
|
54
55
|
const v = q(0), s = q(0), z = d(() => ({
|
|
55
56
|
...e.value,
|
|
56
|
-
filters:
|
|
57
|
+
filters: r.value || {},
|
|
57
58
|
sorters: n.value || {},
|
|
58
59
|
meta: a.value || {}
|
|
59
60
|
})), g = T({
|
|
60
|
-
queryKey: [`${o.config?.name}:${
|
|
61
|
-
queryFn: ({ pageParam: f }) => (
|
|
61
|
+
queryKey: [`${o.config?.name}:${i}:${t.path}:infinite`, z.value],
|
|
62
|
+
queryFn: ({ pageParam: f }) => (u.value.page = f, o.config?.dataProvider?.[i]?.getList({
|
|
62
63
|
...z.value,
|
|
63
64
|
pagination: {
|
|
64
|
-
...
|
|
65
|
+
...u.value,
|
|
65
66
|
page: f
|
|
66
67
|
}
|
|
67
68
|
}, o, l)),
|
|
@@ -69,15 +70,15 @@ function _(t) {
|
|
|
69
70
|
getNextPageParam: (f, L, y) => {
|
|
70
71
|
if (!f?.data || !f?.data?.length)
|
|
71
72
|
return;
|
|
72
|
-
const m = o.config?.dataProvider?.[
|
|
73
|
-
if (s.value = Math.ceil(m / (
|
|
73
|
+
const m = o.config?.dataProvider?.[i]?.getTotal?.(f) || 0;
|
|
74
|
+
if (s.value = Math.ceil(m / (u.value.pageSize || 20)) || 0, v.value = m, !(y * (u.value.pageSize || 20) >= m))
|
|
74
75
|
return y + 1;
|
|
75
76
|
},
|
|
76
77
|
getPreviousPageParam: (f, L, y) => {
|
|
77
78
|
if (y <= 1)
|
|
78
79
|
return;
|
|
79
|
-
const m = o.config?.dataProvider?.[
|
|
80
|
-
return s.value = Math.ceil(m / (
|
|
80
|
+
const m = o.config?.dataProvider?.[i]?.getTotal?.(f) || 0;
|
|
81
|
+
return s.value = Math.ceil(m / (u.value.pageSize || 20)) || 0, v.value = m, y - 1;
|
|
81
82
|
},
|
|
82
83
|
...t.options
|
|
83
84
|
}), A = d(() => g.isFetching.value);
|
|
@@ -106,20 +107,20 @@ function _(t) {
|
|
|
106
107
|
fetchNextPage: M,
|
|
107
108
|
hasNextPage: g.hasNextPage,
|
|
108
109
|
refetch: g.refetch,
|
|
109
|
-
pagination:
|
|
110
|
+
pagination: u,
|
|
110
111
|
total: v,
|
|
111
112
|
pageCount: s
|
|
112
113
|
};
|
|
113
114
|
}
|
|
114
115
|
function G(t) {
|
|
115
|
-
const o = h(), l = p(),
|
|
116
|
+
const o = h(), l = p(), i = t.providerName || "default", { mutate: c } = P(), u = d(() => {
|
|
116
117
|
const { onError: e, options: v, ...s } = t;
|
|
117
118
|
return s;
|
|
118
119
|
}), n = D({
|
|
119
|
-
queryKey: [`${o.config?.name}:${
|
|
120
|
-
queryFn: () => o.config?.dataProvider?.[
|
|
120
|
+
queryKey: [`${o.config?.name}:${i}:${t.path}`, u],
|
|
121
|
+
queryFn: () => o.config?.dataProvider?.[i]?.getOne(u.value, o, l),
|
|
121
122
|
...t.options
|
|
122
|
-
}),
|
|
123
|
+
}), r = d(() => n.isFetched.value ? !1 : n.isFetching.value);
|
|
123
124
|
E(n.isError, (e) => {
|
|
124
125
|
e && (c(n.error.value), t?.onError?.(n.error.value));
|
|
125
126
|
}, {
|
|
@@ -132,20 +133,20 @@ function G(t) {
|
|
|
132
133
|
immediate: !0
|
|
133
134
|
}), {
|
|
134
135
|
...n,
|
|
135
|
-
isLoading:
|
|
136
|
+
isLoading: r,
|
|
136
137
|
data: a,
|
|
137
138
|
refetch: n.refetch
|
|
138
139
|
};
|
|
139
140
|
}
|
|
140
141
|
function R(t) {
|
|
141
|
-
const o = h(), l = p(),
|
|
142
|
+
const o = h(), l = p(), i = t.providerName || "default", { mutate: c } = P(), u = d(() => {
|
|
142
143
|
const { onError: e, options: v, ...s } = t;
|
|
143
144
|
return s;
|
|
144
145
|
}), n = D({
|
|
145
|
-
queryKey: [`${o.config?.name}:${
|
|
146
|
-
queryFn: () => o.config?.dataProvider?.[
|
|
146
|
+
queryKey: [`${o.config?.name}:${i}:${t.path}`, u],
|
|
147
|
+
queryFn: () => o.config?.dataProvider?.[i]?.getMany(u.value, o, l),
|
|
147
148
|
...t.options
|
|
148
|
-
}),
|
|
149
|
+
}), r = d(() => n.isFetched.value ? !1 : n.isFetching.value);
|
|
149
150
|
E(n.isError, (e) => {
|
|
150
151
|
e && (c(n.error.value), t?.onError?.(n.error.value));
|
|
151
152
|
});
|
|
@@ -156,184 +157,184 @@ function R(t) {
|
|
|
156
157
|
immediate: !0
|
|
157
158
|
}), {
|
|
158
159
|
...n,
|
|
159
|
-
isLoading:
|
|
160
|
+
isLoading: r,
|
|
160
161
|
data: a,
|
|
161
162
|
refetch: n.refetch
|
|
162
163
|
};
|
|
163
164
|
}
|
|
164
|
-
function
|
|
165
|
-
const o = h(), l = p(),
|
|
165
|
+
function W(t) {
|
|
166
|
+
const o = h(), l = p(), i = t.providerName || "default", { mutate: c } = P(), { invalidate: u } = w(), n = d(() => {
|
|
166
167
|
const { onError: e, options: v, ...s } = t;
|
|
167
168
|
return s;
|
|
168
|
-
}),
|
|
169
|
+
}), r = $({
|
|
169
170
|
mutationFn: (e) => {
|
|
170
171
|
if (!o.config?.dataProvider)
|
|
171
172
|
throw new Error("Data provider is not initialized");
|
|
172
|
-
return e.path && (t.path = e.path), o.config?.dataProvider?.[
|
|
173
|
+
return e.path && (t.path = e.path), o.config?.dataProvider?.[i]?.create({
|
|
173
174
|
...n.value,
|
|
174
175
|
...e
|
|
175
176
|
}, o, l);
|
|
176
177
|
},
|
|
177
178
|
onSuccess: (e) => {
|
|
178
|
-
t.onSuccess?.(e), t.path &&
|
|
179
|
+
t.onSuccess?.(e), t.path && u(t.path);
|
|
179
180
|
},
|
|
180
181
|
onError: (e) => {
|
|
181
182
|
c(e), t?.onError?.(e);
|
|
182
183
|
},
|
|
183
184
|
...t.options
|
|
184
|
-
}), a = d(() =>
|
|
185
|
+
}), a = d(() => r.isPending.value);
|
|
185
186
|
return {
|
|
186
|
-
...
|
|
187
|
+
...r,
|
|
187
188
|
isLoading: a,
|
|
188
|
-
mutate:
|
|
189
|
+
mutate: r.mutate
|
|
189
190
|
};
|
|
190
191
|
}
|
|
191
192
|
function j(t) {
|
|
192
|
-
const o = h(), l = p(),
|
|
193
|
+
const o = h(), l = p(), i = t.providerName || "default", { mutate: c } = P(), { invalidate: u } = w(), n = d(() => {
|
|
193
194
|
const { onError: e, options: v, ...s } = t;
|
|
194
195
|
return s;
|
|
195
|
-
}),
|
|
196
|
+
}), r = $({
|
|
196
197
|
mutationFn: (e) => {
|
|
197
198
|
if (!o.config?.dataProvider)
|
|
198
199
|
throw new Error("Data provider is not initialized");
|
|
199
|
-
return e.path && (t.path = e.path), o.config?.dataProvider?.[
|
|
200
|
+
return e.path && (t.path = e.path), o.config?.dataProvider?.[i]?.createMany({
|
|
200
201
|
...n.value,
|
|
201
202
|
...e
|
|
202
203
|
}, o, l);
|
|
203
204
|
},
|
|
204
205
|
onSuccess: (e) => {
|
|
205
|
-
t.onSuccess?.(e), t.path &&
|
|
206
|
+
t.onSuccess?.(e), t.path && u(t.path);
|
|
206
207
|
},
|
|
207
208
|
onError: (e) => {
|
|
208
209
|
c(e), t?.onError?.(e);
|
|
209
210
|
},
|
|
210
211
|
...t.options
|
|
211
|
-
}), a = d(() =>
|
|
212
|
+
}), a = d(() => r.isPending.value);
|
|
212
213
|
return {
|
|
213
|
-
...
|
|
214
|
+
...r,
|
|
214
215
|
isLoading: a,
|
|
215
|
-
mutate:
|
|
216
|
+
mutate: r.mutate
|
|
216
217
|
};
|
|
217
218
|
}
|
|
218
|
-
function
|
|
219
|
-
const o = h(), l = p(),
|
|
219
|
+
function H(t) {
|
|
220
|
+
const o = h(), l = p(), i = t.providerName || "default", { mutate: c } = P(), { invalidate: u } = w(), n = d(() => {
|
|
220
221
|
const { onError: e, options: v, ...s } = t;
|
|
221
222
|
return s;
|
|
222
|
-
}),
|
|
223
|
+
}), r = $({
|
|
223
224
|
mutationFn: (e) => {
|
|
224
225
|
if (!o.config?.dataProvider)
|
|
225
226
|
throw new Error("Data provider is not initialized");
|
|
226
|
-
return e.path && (t.path = e.path), o.config?.dataProvider?.[
|
|
227
|
+
return e.path && (t.path = e.path), o.config?.dataProvider?.[i]?.update({
|
|
227
228
|
...n.value,
|
|
228
229
|
...e
|
|
229
230
|
}, o, l);
|
|
230
231
|
},
|
|
231
232
|
onSuccess: (e) => {
|
|
232
|
-
t.onSuccess?.(e), t.path &&
|
|
233
|
+
t.onSuccess?.(e), t.path && u(t.path);
|
|
233
234
|
},
|
|
234
235
|
onError: (e) => {
|
|
235
236
|
c(e), t?.onError?.(e);
|
|
236
237
|
},
|
|
237
238
|
...t.options
|
|
238
|
-
}), a = d(() =>
|
|
239
|
+
}), a = d(() => r.isPending.value);
|
|
239
240
|
return {
|
|
240
|
-
...
|
|
241
|
+
...r,
|
|
241
242
|
isLoading: a,
|
|
242
|
-
mutate:
|
|
243
|
+
mutate: r.mutate
|
|
243
244
|
};
|
|
244
245
|
}
|
|
245
|
-
function
|
|
246
|
-
const o = h(), l = p(),
|
|
246
|
+
function J(t) {
|
|
247
|
+
const o = h(), l = p(), i = t.providerName || "default", { mutate: c } = P(), { invalidate: u } = w(), n = d(() => {
|
|
247
248
|
const { onError: e, options: v, ...s } = t;
|
|
248
249
|
return s;
|
|
249
|
-
}),
|
|
250
|
+
}), r = $({
|
|
250
251
|
mutationFn: (e) => {
|
|
251
252
|
if (!o.config?.dataProvider)
|
|
252
253
|
throw new Error("Data provider is not initialized");
|
|
253
|
-
return e.path && (t.path = e.path), o.config?.dataProvider?.[
|
|
254
|
+
return e.path && (t.path = e.path), o.config?.dataProvider?.[i]?.updateMany({
|
|
254
255
|
...n.value,
|
|
255
256
|
...e
|
|
256
257
|
}, o, l);
|
|
257
258
|
},
|
|
258
259
|
onSuccess: (e) => {
|
|
259
|
-
t.onSuccess?.(e), t.path &&
|
|
260
|
+
t.onSuccess?.(e), t.path && u(t.path);
|
|
260
261
|
},
|
|
261
262
|
onError: (e) => {
|
|
262
263
|
c(e), t?.onError?.(e);
|
|
263
264
|
},
|
|
264
265
|
...t.options
|
|
265
|
-
}), a = d(() =>
|
|
266
|
+
}), a = d(() => r.isPending.value);
|
|
266
267
|
return {
|
|
267
|
-
...
|
|
268
|
+
...r,
|
|
268
269
|
isLoading: a,
|
|
269
|
-
mutate:
|
|
270
|
+
mutate: r.mutate
|
|
270
271
|
};
|
|
271
272
|
}
|
|
272
|
-
function
|
|
273
|
-
const o = h(), l = p(),
|
|
273
|
+
function V(t) {
|
|
274
|
+
const o = h(), l = p(), i = t.providerName || "default", { mutate: c } = P(), { invalidate: u } = w(), n = d(() => {
|
|
274
275
|
const { onError: e, options: v, ...s } = t;
|
|
275
276
|
return s;
|
|
276
|
-
}),
|
|
277
|
+
}), r = $({
|
|
277
278
|
mutationFn: (e) => {
|
|
278
279
|
if (!o.config?.dataProvider)
|
|
279
280
|
throw new Error("Data provider is not initialized");
|
|
280
|
-
return e.path && (t.path = e.path), o.config?.dataProvider?.[
|
|
281
|
+
return e.path && (t.path = e.path), o.config?.dataProvider?.[i]?.deleteOne({
|
|
281
282
|
...n.value,
|
|
282
283
|
...e
|
|
283
284
|
}, o, l);
|
|
284
285
|
},
|
|
285
286
|
onSuccess: (e) => {
|
|
286
|
-
t.onSuccess?.(e), t.path &&
|
|
287
|
+
t.onSuccess?.(e), t.path && u(t.path);
|
|
287
288
|
},
|
|
288
289
|
onError: (e) => {
|
|
289
290
|
c(e), t?.onError?.(e);
|
|
290
291
|
},
|
|
291
292
|
...t.options
|
|
292
|
-
}), a = d(() =>
|
|
293
|
+
}), a = d(() => r.isPending.value);
|
|
293
294
|
return {
|
|
294
|
-
...
|
|
295
|
+
...r,
|
|
295
296
|
isLoading: a,
|
|
296
|
-
mutate:
|
|
297
|
+
mutate: r.mutate
|
|
297
298
|
};
|
|
298
299
|
}
|
|
299
|
-
function
|
|
300
|
-
const o = h(), l = p(),
|
|
300
|
+
function X(t) {
|
|
301
|
+
const o = h(), l = p(), i = t.providerName || "default", { mutate: c } = P(), { invalidate: u } = w(), n = d(() => {
|
|
301
302
|
const { onError: e, options: v, ...s } = t;
|
|
302
303
|
return s;
|
|
303
|
-
}),
|
|
304
|
+
}), r = $({
|
|
304
305
|
mutationFn: (e) => {
|
|
305
306
|
if (!o.config?.dataProvider)
|
|
306
307
|
throw new Error("Data provider is not initialized");
|
|
307
|
-
return e.path && (t.path = e.path), o.config?.dataProvider?.[
|
|
308
|
+
return e.path && (t.path = e.path), o.config?.dataProvider?.[i]?.deleteMany({
|
|
308
309
|
...n.value,
|
|
309
310
|
...e
|
|
310
311
|
}, o, l);
|
|
311
312
|
},
|
|
312
313
|
onSuccess: (e) => {
|
|
313
|
-
t.onSuccess?.(e), t.path &&
|
|
314
|
+
t.onSuccess?.(e), t.path && u(t.path);
|
|
314
315
|
},
|
|
315
316
|
onError: (e) => {
|
|
316
317
|
c(e), t?.onError?.(e);
|
|
317
318
|
},
|
|
318
319
|
...t.options
|
|
319
|
-
}), a = d(() =>
|
|
320
|
+
}), a = d(() => r.isPending.value);
|
|
320
321
|
return {
|
|
321
|
-
...
|
|
322
|
+
...r,
|
|
322
323
|
isLoading: a,
|
|
323
|
-
mutate:
|
|
324
|
+
mutate: r.mutate
|
|
324
325
|
};
|
|
325
326
|
}
|
|
326
|
-
function
|
|
327
|
-
const o = h(), l = p(),
|
|
327
|
+
function Y(t) {
|
|
328
|
+
const o = h(), l = p(), i = t?.providerName || "default", { mutate: c } = P(), u = d(() => {
|
|
328
329
|
if (!t)
|
|
329
330
|
return {};
|
|
330
331
|
const { onError: e, options: v, ...s } = t;
|
|
331
332
|
return s;
|
|
332
333
|
}), n = D({
|
|
333
|
-
queryKey: [`${o.config?.name}:${
|
|
334
|
-
queryFn: () => o.config?.dataProvider?.[
|
|
334
|
+
queryKey: [`${o.config?.name}:${i}:${t?.path}`, u],
|
|
335
|
+
queryFn: () => o.config?.dataProvider?.[i]?.custom(u.value, o, l),
|
|
335
336
|
...t?.options
|
|
336
|
-
}),
|
|
337
|
+
}), r = d(() => n.isFetched.value ? !1 : n.isFetching.value);
|
|
337
338
|
E(n.isError, (e) => {
|
|
338
339
|
e && (c(n.error.value), t?.onError?.(n.error.value));
|
|
339
340
|
});
|
|
@@ -344,13 +345,13 @@ function W(t) {
|
|
|
344
345
|
immediate: !0
|
|
345
346
|
}), {
|
|
346
347
|
...n,
|
|
347
|
-
isLoading:
|
|
348
|
+
isLoading: r,
|
|
348
349
|
data: a,
|
|
349
350
|
refetch: n.refetch
|
|
350
351
|
};
|
|
351
352
|
}
|
|
352
|
-
function
|
|
353
|
-
const o = h(), l = p(),
|
|
353
|
+
function Z(t) {
|
|
354
|
+
const o = h(), l = p(), i = t?.providerName || "default", { mutate: c } = P(), u = d(() => {
|
|
354
355
|
if (!t)
|
|
355
356
|
return {};
|
|
356
357
|
const { onError: a, options: e, ...v } = t;
|
|
@@ -359,8 +360,8 @@ function X(t) {
|
|
|
359
360
|
mutationFn: (a) => {
|
|
360
361
|
if (!o.config?.dataProvider)
|
|
361
362
|
throw new Error("Data provider is not initialized");
|
|
362
|
-
return o.config?.dataProvider?.[
|
|
363
|
-
...
|
|
363
|
+
return o.config?.dataProvider?.[i]?.custom({
|
|
364
|
+
...u.value,
|
|
364
365
|
...a
|
|
365
366
|
}, o, l);
|
|
366
367
|
},
|
|
@@ -371,22 +372,22 @@ function X(t) {
|
|
|
371
372
|
c(a), t?.onError?.(a);
|
|
372
373
|
},
|
|
373
374
|
...t?.options
|
|
374
|
-
}),
|
|
375
|
+
}), r = d(() => n.isPending.value);
|
|
375
376
|
return {
|
|
376
377
|
...n,
|
|
377
|
-
isLoading:
|
|
378
|
+
isLoading: r,
|
|
378
379
|
mutate: n.mutate
|
|
379
380
|
};
|
|
380
381
|
}
|
|
381
|
-
function
|
|
382
|
+
function tt() {
|
|
382
383
|
const t = h(), o = p();
|
|
383
384
|
return {
|
|
384
|
-
request: (
|
|
385
|
+
request: (i) => {
|
|
385
386
|
if (!t.config?.dataProvider)
|
|
386
387
|
throw new Error("Data provider is not initialized");
|
|
387
|
-
const c =
|
|
388
|
+
const c = i.providerName || "default";
|
|
388
389
|
return t.config?.dataProvider?.[c]?.custom({
|
|
389
|
-
...
|
|
390
|
+
...i
|
|
390
391
|
}, t, o);
|
|
391
392
|
}
|
|
392
393
|
};
|
|
@@ -394,31 +395,33 @@ function Y() {
|
|
|
394
395
|
function w() {
|
|
395
396
|
const t = K(), o = h();
|
|
396
397
|
return {
|
|
397
|
-
invalidate: (
|
|
398
|
-
let
|
|
399
|
-
Array.isArray(
|
|
400
|
-
for (const n of
|
|
401
|
-
|
|
398
|
+
invalidate: (i, c) => {
|
|
399
|
+
let u = i;
|
|
400
|
+
Array.isArray(i) || (u = [i]);
|
|
401
|
+
for (const n of u) {
|
|
402
|
+
let r = n;
|
|
403
|
+
o.config?.apiBasePath && r.startsWith(o.config.apiBasePath) && (r = Q(r.substring(o.config.apiBasePath.length), "/"));
|
|
404
|
+
const a = `${o.config?.name}:${c || "default"}:${r}`;
|
|
402
405
|
t.invalidateQueries({
|
|
403
|
-
queryKey: [
|
|
406
|
+
queryKey: [a]
|
|
404
407
|
});
|
|
405
408
|
}
|
|
406
409
|
}
|
|
407
410
|
};
|
|
408
411
|
}
|
|
409
412
|
export {
|
|
410
|
-
|
|
411
|
-
|
|
413
|
+
tt as useClient,
|
|
414
|
+
W as useCreate,
|
|
412
415
|
j as useCreateMany,
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
416
|
+
Y as useCustom,
|
|
417
|
+
Z as useCustomMutation,
|
|
418
|
+
V as useDelete,
|
|
419
|
+
X as useDeleteMany,
|
|
420
|
+
b as useInfiniteList,
|
|
418
421
|
w as useInvalidate,
|
|
419
|
-
|
|
422
|
+
_ as useList,
|
|
420
423
|
R as useMany,
|
|
421
424
|
G as useOne,
|
|
422
|
-
|
|
423
|
-
|
|
425
|
+
H as useUpdate,
|
|
426
|
+
J as useUpdateMany
|
|
424
427
|
};
|
package/dist/esm/provider/app.js
CHANGED
|
@@ -4,9 +4,9 @@ import { useRouter as M } from "vue-router";
|
|
|
4
4
|
import { useCan as w } from "../hooks/auth.js";
|
|
5
5
|
import { useConfig as z } from "../hooks/config.js";
|
|
6
6
|
import "@tanstack/vue-query";
|
|
7
|
+
import "lodash-es";
|
|
7
8
|
import { useManage as D } from "../hooks/manage.js";
|
|
8
9
|
import "json-2-csv";
|
|
9
|
-
import "lodash-es";
|
|
10
10
|
import "@vee-validate/rules";
|
|
11
11
|
import "vee-validate";
|
|
12
12
|
import { useAuthStore as C } from "../stores/auth.js";
|