@duxweb/dvha-core 1.0.44 → 1.0.46

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 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const E=require("@tanstack/vue-query"),o=require("vue"),l=require("./auth.cjs"),p=require("./manage.cjs");function L(e){const r=p.useManage(),f=l.useGetAuth(),u=e.providerName||"default",{mutate:d}=l.useError(),i=o.toRef(e.pagination?e.pagination:{page:1,pageSize:20}),n=o.toRef(e,"sorters",{}),a=o.toRef(e,"filters",{}),s=o.toRef(e,"meta",{}),t=o.computed(()=>{const{onError:$,options:v,pagination:N,filters:y,sorters:m,meta:P,...S}=e;return S});o.watch(t,()=>{e.pagination&&(i.value.page=1)},{deep:!0});const g=o.computed(()=>({...t.value,pagination:e.pagination?i.value:void 0,filters:a.value||{},sorters:n.value||{},meta:s.value||{}})),c=E.useQuery({queryKey:[`${r.config?.name}:${u}:${e.path}`,g.value],queryFn:()=>r.config?.dataProvider?.[u]?.getList(g.value,r,f),...e.options}),A=o.computed(()=>c.isFetching.value);o.watch(c.isError,$=>{$&&(d(c.error.value),e?.onError?.(c.error.value))});const h=o.ref(void 0),q=o.ref(0),w=o.ref(0);return o.watch(c.data,$=>{$&&(h.value=$,q.value=r.config?.dataProvider?.[u]?.getTotal?.($)||0,w.value=Math.ceil(q.value/(i.value.pageSize||20))||0)},{immediate:!0}),{...c,isLoading:A,data:h,refetch:c.refetch,pagination:i,total:q,pageCount:w}}function z(e){const r=p.useManage(),f=l.useGetAuth(),u=e.providerName||"default",{mutate:d}=l.useError(),i=o.toRef(e,"pagination",{page:1,pageSize:20}),n=o.toRef(e,"sorters",{}),a=o.toRef(e,"filters",{}),s=o.toRef(e,"meta",{}),t=o.computed(()=>{const{onError:v,options:N,pagination:y,filters:m,sorters:P,meta:S,...F}=e;return F});o.watch(t,()=>{i.value.page=1},{deep:!0});const g=o.ref(0),c=o.ref(0),A=o.computed(()=>({...t.value,filters:a.value||{},sorters:n.value||{},meta:s.value||{}})),h=E.useInfiniteQuery({queryKey:[`${r.config?.name}:${u}:${e.path}:infinite`,A.value],queryFn:({pageParam:v})=>(i.value.page=v,r.config?.dataProvider?.[u]?.getList({...A.value,pagination:{...i.value,page:v}},r,f)),initialPageParam:1,getNextPageParam:(v,N,y)=>{if(!v?.data||!v?.data?.length)return;const m=r.config?.dataProvider?.[u]?.getTotal?.(v)||0;if(c.value=Math.ceil(m/(i.value.pageSize||20))||0,g.value=m,!(y*(i.value.pageSize||20)>=m))return y+1},getPreviousPageParam:(v,N,y)=>{if(y<=1)return;const m=r.config?.dataProvider?.[u]?.getTotal?.(v)||0;return c.value=Math.ceil(m/(i.value.pageSize||20))||0,g.value=m,y-1},...e.options}),q=o.computed(()=>h.isFetching.value);o.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()},$=o.ref(void 0);return o.watch(h.data,v=>{if(!v||!v?.pages||!v.pages?.length)return;const N=v.pages.reduce((m,P)=>P?.data&&Array.isArray(P.data)&&P.data?.length?m.concat(P.data):m,[]),y=v.pages[0];y&&($.value={...y,data:N})},{deep:!0,immediate:!0}),{...h,isLoading:q,data:$,fetchNextPage:w,hasNextPage:h.hasNextPage,refetch:h.refetch,pagination:i,total:g,pageCount:c}}function C(e){const r=p.useManage(),f=l.useGetAuth(),u=e.providerName||"default",{mutate:d}=l.useError(),i=o.computed(()=>{const{onError:t,options:g,...c}=e;return c}),n=E.useQuery({queryKey:[`${r.config?.name}:${u}:${e.path}`,i],queryFn:()=>r.config?.dataProvider?.[u]?.getOne(i.value,r,f),...e.options}),a=o.computed(()=>n.isFetched.value?!1:n.isFetching.value);o.watch(n.isError,t=>{t&&(d(n.error.value),e?.onError?.(n.error.value))},{immediate:!0});const s=o.ref(void 0);return o.watch(n.data,t=>{t&&(s.value=t)},{immediate:!0}),{...n,isLoading:a,data:s,refetch:n.refetch}}function D(e){const r=p.useManage(),f=l.useGetAuth(),u=e.providerName||"default",{mutate:d}=l.useError(),i=o.computed(()=>{const{onError:t,options:g,...c}=e;return c}),n=E.useQuery({queryKey:[`${r.config?.name}:${u}:${e.path}`,i],queryFn:()=>r.config?.dataProvider?.[u]?.getMany(i.value,r,f),...e.options}),a=o.computed(()=>n.isFetched.value?!1:n.isFetching.value);o.watch(n.isError,t=>{t&&(d(n.error.value),e?.onError?.(n.error.value))});const s=o.ref(void 0);return o.watch(n.data,t=>{t&&(s.value=t)},{immediate:!0}),{...n,isLoading:a,data:s,refetch:n.refetch}}function G(e){const r=p.useManage(),f=l.useGetAuth(),u=e.providerName||"default",{mutate:d}=l.useError(),{invalidate:i}=M(),n=o.computed(()=>{const{onError:t,options:g,...c}=e;return c}),a=E.useMutation({mutationFn:t=>{if(!r.config?.dataProvider)throw new Error("Data provider is not initialized");return t.path&&(e.path=t.path),r.config?.dataProvider?.[u]?.create({...n.value,...t},r,f)},onSuccess:t=>{e.onSuccess?.(t),e.path&&i(e.path)},onError:t=>{d(t),e?.onError?.(t)},...e.options}),s=o.computed(()=>a.isPending.value);return{...a,isLoading:s,mutate:a.mutate}}function Q(e){const r=p.useManage(),f=l.useGetAuth(),u=e.providerName||"default",{mutate:d}=l.useError(),{invalidate:i}=M(),n=o.computed(()=>{const{onError:t,options:g,...c}=e;return c}),a=E.useMutation({mutationFn:t=>{if(!r.config?.dataProvider)throw new Error("Data provider is not initialized");return t.path&&(e.path=t.path),r.config?.dataProvider?.[u]?.createMany({...n.value,...t},r,f)},onSuccess:t=>{e.onSuccess?.(t),e.path&&i(e.path)},onError:t=>{d(t),e?.onError?.(t)},...e.options}),s=o.computed(()=>a.isPending.value);return{...a,isLoading:s,mutate:a.mutate}}function R(e){const r=p.useManage(),f=l.useGetAuth(),u=e.providerName||"default",{mutate:d}=l.useError(),{invalidate:i}=M(),n=o.computed(()=>{const{onError:t,options:g,...c}=e;return c}),a=E.useMutation({mutationFn:t=>{if(!r.config?.dataProvider)throw new Error("Data provider is not initialized");return t.path&&(e.path=t.path),r.config?.dataProvider?.[u]?.update({...n.value,...t},r,f)},onSuccess:t=>{e.onSuccess?.(t),e.path&&i(e.path)},onError:t=>{d(t),e?.onError?.(t)},...e.options}),s=o.computed(()=>a.isPending.value);return{...a,isLoading:s,mutate:a.mutate}}function T(e){const r=p.useManage(),f=l.useGetAuth(),u=e.providerName||"default",{mutate:d}=l.useError(),{invalidate:i}=M(),n=o.computed(()=>{const{onError:t,options:g,...c}=e;return c}),a=E.useMutation({mutationFn:t=>{if(!r.config?.dataProvider)throw new Error("Data provider is not initialized");return t.path&&(e.path=t.path),r.config?.dataProvider?.[u]?.updateMany({...n.value,...t},r,f)},onSuccess:t=>{e.onSuccess?.(t),e.path&&i(e.path)},onError:t=>{d(t),e?.onError?.(t)},...e.options}),s=o.computed(()=>a.isPending.value);return{...a,isLoading:s,mutate:a.mutate}}function x(e){const r=p.useManage(),f=l.useGetAuth(),u=e.providerName||"default",{mutate:d}=l.useError(),{invalidate:i}=M(),n=o.computed(()=>{const{onError:t,options:g,...c}=e;return c}),a=E.useMutation({mutationFn:t=>{if(!r.config?.dataProvider)throw new Error("Data provider is not initialized");return t.path&&(e.path=t.path),r.config?.dataProvider?.[u]?.deleteOne({...n.value,...t},r,f)},onSuccess:t=>{e.onSuccess?.(t),e.path&&i(e.path)},onError:t=>{d(t),e?.onError?.(t)},...e.options}),s=o.computed(()=>a.isPending.value);return{...a,isLoading:s,mutate:a.mutate}}function K(e){const r=p.useManage(),f=l.useGetAuth(),u=e.providerName||"default",{mutate:d}=l.useError(),{invalidate:i}=M(),n=o.computed(()=>{const{onError:t,options:g,...c}=e;return c}),a=E.useMutation({mutationFn:t=>{if(!r.config?.dataProvider)throw new Error("Data provider is not initialized");return t.path&&(e.path=t.path),r.config?.dataProvider?.[u]?.deleteMany({...n.value,...t},r,f)},onSuccess:t=>{e.onSuccess?.(t),e.path&&i(e.path)},onError:t=>{d(t),e?.onError?.(t)},...e.options}),s=o.computed(()=>a.isPending.value);return{...a,isLoading:s,mutate:a.mutate}}function I(e){const r=p.useManage(),f=l.useGetAuth(),u=e?.providerName||"default",{mutate:d}=l.useError(),i=o.computed(()=>{if(!e)return{};const{onError:t,options:g,...c}=e;return c}),n=E.useQuery({queryKey:[`${r.config?.name}:${u}:${e?.path}`,i],queryFn:()=>r.config?.dataProvider?.[u]?.custom(i.value,r,f),...e?.options}),a=o.computed(()=>n.isFetched.value?!1:n.isFetching.value);o.watch(n.isError,t=>{t&&(d(n.error.value),e?.onError?.(n.error.value))});const s=o.ref(void 0);return o.watch(n.data,t=>{t&&(s.value=t)},{immediate:!0}),{...n,isLoading:a,data:s,refetch:n.refetch}}function O(e){const r=p.useManage(),f=l.useGetAuth(),u=e?.providerName||"default",{mutate:d}=l.useError(),i=o.computed(()=>{if(!e)return{};const{onError:s,options:t,...g}=e;return g}),n=E.useMutation({mutationFn:s=>{if(!r.config?.dataProvider)throw new Error("Data provider is not initialized");return r.config?.dataProvider?.[u]?.custom({...i.value,...s},r,f)},onSuccess:s=>{n.reset(),e?.onSuccess?.(s)},onError:s=>{d(s),e?.onError?.(s)},...e?.options}),a=o.computed(()=>n.isPending.value);return{...n,isLoading:a,mutate:n.mutate}}function U(){const e=p.useManage(),r=l.useGetAuth();return{request:u=>{if(!e.config?.dataProvider)throw new Error("Data provider is not initialized");const d=u.providerName||"default";return e.config?.dataProvider?.[d]?.custom({...u},e,r)}}}function M(){const e=E.useQueryClient(),r=p.useManage();return{invalidate:(u,d)=>{let i=u;Array.isArray(u)||(i=[u]);for(const n of i){const a=`${r.config?.name}:${d||"default"}:${n}`;e.invalidateQueries({queryKey:[a]})}}}}exports.useClient=U;exports.useCreate=G;exports.useCreateMany=Q;exports.useCustom=I;exports.useCustomMutation=O;exports.useDelete=x;exports.useDeleteMany=K;exports.useInfiniteList=z;exports.useInvalidate=M;exports.useList=L;exports.useMany=D;exports.useOne=C;exports.useUpdate=R;exports.useUpdateMany=T;
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("lodash-es");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;
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;
@@ -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 U(t) {
6
- const o = h(), l = p(), r = t.providerName || "default", { mutate: c } = P(), i = F(t.pagination ? t.pagination : { page: 1, pageSize: 20 }), n = F(t, "sorters", {}), u = F(t, "filters", {}), a = F(t, "meta", {}), e = d(() => {
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 && (i.value.page = 1);
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 ? i.value : void 0,
18
- filters: u.value || {},
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}:${r}:${t.path}`, v.value],
23
- queryFn: () => o.config?.dataProvider?.[r]?.getList(v.value, o, l),
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?.[r]?.getTotal?.(N) || 0, M.value = Math.ceil(A.value / (i.value.pageSize || 20)) || 0);
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: i,
40
+ pagination: u,
40
41
  total: A,
41
42
  pageCount: M
42
43
  };
43
44
  }
44
- function _(t) {
45
- const o = h(), l = p(), r = t.providerName || "default", { mutate: c } = P(), i = F(t, "pagination", { page: 1, pageSize: 20 }), n = F(t, "sorters", {}), u = F(t, "filters", {}), a = F(t, "meta", {}), e = d(() => {
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
- i.value.page = 1;
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: u.value || {},
57
+ filters: r.value || {},
57
58
  sorters: n.value || {},
58
59
  meta: a.value || {}
59
60
  })), g = T({
60
- queryKey: [`${o.config?.name}:${r}:${t.path}:infinite`, z.value],
61
- queryFn: ({ pageParam: f }) => (i.value.page = f, o.config?.dataProvider?.[r]?.getList({
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
- ...i.value,
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?.[r]?.getTotal?.(f) || 0;
73
- if (s.value = Math.ceil(m / (i.value.pageSize || 20)) || 0, v.value = m, !(y * (i.value.pageSize || 20) >= 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?.[r]?.getTotal?.(f) || 0;
80
- return s.value = Math.ceil(m / (i.value.pageSize || 20)) || 0, v.value = m, y - 1;
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: i,
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(), r = t.providerName || "default", { mutate: c } = P(), i = d(() => {
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}:${r}:${t.path}`, i],
120
- queryFn: () => o.config?.dataProvider?.[r]?.getOne(i.value, o, l),
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
- }), u = d(() => n.isFetched.value ? !1 : n.isFetching.value);
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: u,
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(), r = t.providerName || "default", { mutate: c } = P(), i = d(() => {
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}:${r}:${t.path}`, i],
146
- queryFn: () => o.config?.dataProvider?.[r]?.getMany(i.value, o, l),
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
- }), u = d(() => n.isFetched.value ? !1 : n.isFetching.value);
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: u,
160
+ isLoading: r,
160
161
  data: a,
161
162
  refetch: n.refetch
162
163
  };
163
164
  }
164
- function b(t) {
165
- const o = h(), l = p(), r = t.providerName || "default", { mutate: c } = P(), { invalidate: i } = w(), n = d(() => {
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
- }), u = $({
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?.[r]?.create({
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 && i(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(() => u.isPending.value);
185
+ }), a = d(() => r.isPending.value);
185
186
  return {
186
- ...u,
187
+ ...r,
187
188
  isLoading: a,
188
- mutate: u.mutate
189
+ mutate: r.mutate
189
190
  };
190
191
  }
191
192
  function j(t) {
192
- const o = h(), l = p(), r = t.providerName || "default", { mutate: c } = P(), { invalidate: i } = w(), n = d(() => {
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
- }), u = $({
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?.[r]?.createMany({
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 && i(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(() => u.isPending.value);
212
+ }), a = d(() => r.isPending.value);
212
213
  return {
213
- ...u,
214
+ ...r,
214
215
  isLoading: a,
215
- mutate: u.mutate
216
+ mutate: r.mutate
216
217
  };
217
218
  }
218
- function B(t) {
219
- const o = h(), l = p(), r = t.providerName || "default", { mutate: c } = P(), { invalidate: i } = w(), n = d(() => {
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
- }), u = $({
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?.[r]?.update({
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 && i(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(() => u.isPending.value);
239
+ }), a = d(() => r.isPending.value);
239
240
  return {
240
- ...u,
241
+ ...r,
241
242
  isLoading: a,
242
- mutate: u.mutate
243
+ mutate: r.mutate
243
244
  };
244
245
  }
245
- function H(t) {
246
- const o = h(), l = p(), r = t.providerName || "default", { mutate: c } = P(), { invalidate: i } = w(), n = d(() => {
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
- }), u = $({
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?.[r]?.updateMany({
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 && i(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(() => u.isPending.value);
266
+ }), a = d(() => r.isPending.value);
266
267
  return {
267
- ...u,
268
+ ...r,
268
269
  isLoading: a,
269
- mutate: u.mutate
270
+ mutate: r.mutate
270
271
  };
271
272
  }
272
- function J(t) {
273
- const o = h(), l = p(), r = t.providerName || "default", { mutate: c } = P(), { invalidate: i } = w(), n = d(() => {
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
- }), u = $({
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?.[r]?.deleteOne({
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 && i(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(() => u.isPending.value);
293
+ }), a = d(() => r.isPending.value);
293
294
  return {
294
- ...u,
295
+ ...r,
295
296
  isLoading: a,
296
- mutate: u.mutate
297
+ mutate: r.mutate
297
298
  };
298
299
  }
299
- function V(t) {
300
- const o = h(), l = p(), r = t.providerName || "default", { mutate: c } = P(), { invalidate: i } = w(), n = d(() => {
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
- }), u = $({
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?.[r]?.deleteMany({
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 && i(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(() => u.isPending.value);
320
+ }), a = d(() => r.isPending.value);
320
321
  return {
321
- ...u,
322
+ ...r,
322
323
  isLoading: a,
323
- mutate: u.mutate
324
+ mutate: r.mutate
324
325
  };
325
326
  }
326
- function W(t) {
327
- const o = h(), l = p(), r = t?.providerName || "default", { mutate: c } = P(), i = d(() => {
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}:${r}:${t?.path}`, i],
334
- queryFn: () => o.config?.dataProvider?.[r]?.custom(i.value, o, l),
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
- }), u = d(() => n.isFetched.value ? !1 : n.isFetching.value);
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: u,
348
+ isLoading: r,
348
349
  data: a,
349
350
  refetch: n.refetch
350
351
  };
351
352
  }
352
- function X(t) {
353
- const o = h(), l = p(), r = t?.providerName || "default", { mutate: c } = P(), i = d(() => {
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?.[r]?.custom({
363
- ...i.value,
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
- }), u = d(() => n.isPending.value);
375
+ }), r = d(() => n.isPending.value);
375
376
  return {
376
377
  ...n,
377
- isLoading: u,
378
+ isLoading: r,
378
379
  mutate: n.mutate
379
380
  };
380
381
  }
381
- function Y() {
382
+ function tt() {
382
383
  const t = h(), o = p();
383
384
  return {
384
- request: (r) => {
385
+ request: (i) => {
385
386
  if (!t.config?.dataProvider)
386
387
  throw new Error("Data provider is not initialized");
387
- const c = r.providerName || "default";
388
+ const c = i.providerName || "default";
388
389
  return t.config?.dataProvider?.[c]?.custom({
389
- ...r
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: (r, c) => {
398
- let i = r;
399
- Array.isArray(r) || (i = [r]);
400
- for (const n of i) {
401
- const u = `${o.config?.name}:${c || "default"}:${n}`;
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: [u]
406
+ queryKey: [a]
404
407
  });
405
408
  }
406
409
  }
407
410
  };
408
411
  }
409
412
  export {
410
- Y as useClient,
411
- b as useCreate,
413
+ tt as useClient,
414
+ W as useCreate,
412
415
  j as useCreateMany,
413
- W as useCustom,
414
- X as useCustomMutation,
415
- J as useDelete,
416
- V as useDeleteMany,
417
- _ as useInfiniteList,
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
- U as useList,
422
+ _ as useList,
420
423
  R as useMany,
421
424
  G as useOne,
422
- B as useUpdate,
423
- H as useUpdateMany
425
+ H as useUpdate,
426
+ J as useUpdateMany
424
427
  };
@@ -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";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@duxweb/dvha-core",
3
3
  "type": "module",
4
- "version": "1.0.44",
4
+ "version": "1.0.46",
5
5
  "author": "DuxWeb",
6
6
  "license": "MIT",
7
7
  "repository": {