@duxweb/dvha-core 1.0.48 → 1.0.50
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("vue"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("vue"),i=require("vue-router");require("pinia");require("lodash-es");const c=require("../../hooks/manage.cjs");require("@tanstack/vue-query");require("json-2-csv");require("@vee-validate/rules");require("vee-validate");require("@vueuse/core");require("../../hooks/json/index.cjs");require("../../utils/bus.cjs");require("@overlastic/vue");require("clsx");require("colorizr");require("axios");const a=e.defineComponent({name:"DuxException",setup(l,{slots:o}){const r=e.ref(null),u=i.useRoute(),{config:n}=c.useManage();return e.onErrorCaptured(t=>(console.error(t),u.name?r.value={title:"500",desc:t?.message||"Internal Server Error"}:r.value={title:"404",desc:"Page not found"},!1)),()=>r.value?n.components?.exception?e.h(n.components.exception,{data:r.value}):e.createVNode("div",null,[e.createVNode("h1",null,[r.value?.title||"Unknown"]),e.createVNode("p",null,[r.value?.desc||"Unknown Description"]),e.createVNode("p",null,[e.createTextVNode("Use config.components.exception to configure the exception layout")])]):o.default?.()}});exports.DuxException=a;
|
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"),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}
|
|
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}`,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,20 +1,38 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import { useRoute as
|
|
3
|
-
|
|
1
|
+
import { defineComponent as i, ref as m, onErrorCaptured as l, h as u, createVNode as o, createTextVNode as a } from "vue";
|
|
2
|
+
import { useRoute as c } from "vue-router";
|
|
3
|
+
import "pinia";
|
|
4
|
+
import "lodash-es";
|
|
5
|
+
import { useManage as s } from "../../hooks/manage.js";
|
|
6
|
+
import "@tanstack/vue-query";
|
|
7
|
+
import "json-2-csv";
|
|
8
|
+
import "@vee-validate/rules";
|
|
9
|
+
import "vee-validate";
|
|
10
|
+
import "@vueuse/core";
|
|
11
|
+
import "../../hooks/json/index.js";
|
|
12
|
+
import "../../utils/bus.js";
|
|
13
|
+
import "@overlastic/vue";
|
|
14
|
+
import "clsx";
|
|
15
|
+
import "colorizr";
|
|
16
|
+
import "axios";
|
|
17
|
+
const P = /* @__PURE__ */ i({
|
|
4
18
|
name: "DuxException",
|
|
5
|
-
setup(
|
|
6
|
-
slots:
|
|
19
|
+
setup(d, {
|
|
20
|
+
slots: r
|
|
7
21
|
}) {
|
|
8
|
-
const e =
|
|
9
|
-
|
|
22
|
+
const e = m(null), p = c(), {
|
|
23
|
+
config: t
|
|
24
|
+
} = s();
|
|
25
|
+
return l((n) => (console.error(n), p.name ? e.value = {
|
|
10
26
|
title: "500",
|
|
11
|
-
desc:
|
|
27
|
+
desc: n?.message || "Internal Server Error"
|
|
12
28
|
} : e.value = {
|
|
13
29
|
title: "404",
|
|
14
30
|
desc: "Page not found"
|
|
15
|
-
}, !1)), () => e.value ?
|
|
31
|
+
}, !1)), () => e.value ? t.components?.exception ? u(t.components.exception, {
|
|
32
|
+
data: e.value
|
|
33
|
+
}) : o("div", null, [o("h1", null, [e.value?.title || "Unknown"]), o("p", null, [e.value?.desc || "Unknown Description"]), o("p", null, [a("Use config.components.exception to configure the exception layout")])]) : r.default?.();
|
|
16
34
|
}
|
|
17
35
|
});
|
|
18
36
|
export {
|
|
19
|
-
|
|
37
|
+
P as DuxException
|
|
20
38
|
};
|
package/dist/esm/hooks/data.js
CHANGED
|
@@ -58,7 +58,7 @@ function b(t) {
|
|
|
58
58
|
sorters: n.value || {},
|
|
59
59
|
meta: a.value || {}
|
|
60
60
|
})), g = T({
|
|
61
|
-
queryKey: [`${o.config?.name}:${i}:${t.path}
|
|
61
|
+
queryKey: [`${o.config?.name}:${i}:${t.path}`, z.value],
|
|
62
62
|
queryFn: ({ pageParam: f }) => (u.value.page = f, o.config?.dataProvider?.[i]?.getList({
|
|
63
63
|
...z.value,
|
|
64
64
|
pagination: {
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
-
export declare const DuxException: import("vue").DefineComponent<{}, () => import("vue
|
|
1
|
+
export declare const DuxException: import("vue").DefineComponent<{}, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
2
|
+
[key: string]: any;
|
|
3
|
+
}> | import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
2
4
|
[key: string]: any;
|
|
3
5
|
}>[] | undefined, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|