@duxweb/dvha-core 0.1.3 → 0.1.5

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.
@@ -0,0 +1 @@
1
+ "use strict";const e=require("vue"),r=e.defineComponent({name:"DuxError",setup(){return()=>e.createVNode("div",null,[e.createVNode("h1",null,[e.createTextVNode("500")]),e.createVNode("p",null,[e.createTextVNode("Internal Server Error")])])}});module.exports=r;
@@ -0,0 +1 @@
1
+ "use strict";const e=require("vue"),t=e.defineComponent({name:"DuxNotAuthorized",setup(){return()=>e.createVNode("div",null,[e.createVNode("h1",null,[e.createTextVNode("403")]),e.createVNode("p",null,[e.createTextVNode("You are not authorized to access this page")])])}});module.exports=t;
@@ -0,0 +1 @@
1
+ "use strict";const e=require("vue"),t=e.defineComponent({name:"DuxNotFound",setup(){return()=>e.createVNode("div",null,[e.createVNode("h1",null,[e.createTextVNode("404")]),e.createVNode("p",null,[e.createTextVNode("Page not found")])])}});module.exports=t;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("vue"),c=require("vue-router"),h=require("../stores/auth.cjs"),g=require("./manage.cjs");function P({onSuccess:e,onError:u}){const o=g.useManage(),s=h.useAuthStore(),r=c.useRouter(),i=f.ref(!1);return{mutate:async t=>{var d;i.value=!0;const n=await((d=o.config.authProvider)==null?void 0:d.login(t,o));if(i.value=!1,n!=null&&n.success){if(!(n!=null&&n.data))throw new Error("Login response data is undefined");e==null||e(n),s.login(n.data),r.push(o.getRoutePath(n.redirectTo||"/"));return}u==null||u(n)},isLoading:i}}function m({onSuccess:e,onError:u}){const o=g.useManage(),s=h.useAuthStore(),r=c.useRouter();return{mutate:async a=>{var n;const t=await((n=o.config.authProvider)==null?void 0:n.logout(a,o));if(t!=null&&t.success){e==null||e(t),s.logout(),r.push(o.getRoutePath(t.redirectTo||"/login"));return}u==null||u(t)}}}function w({onSuccess:e,onError:u}){const o=g.useManage(),s=h.useAuthStore(),r=c.useRouter();return{mutate:async a=>{var n;const t=await((n=o.config.authProvider)==null?void 0:n.check(a,o));if(t!=null&&t.success){if(e==null||e(t),!(t!=null&&t.data))throw new Error("Check response data is undefined");s.update(t.data);return}u==null||u(t),t!=null&&t.logout&&r.push(o.getRoutePath(t.redirectTo||"/login"))}}}function R({onSuccess:e,onError:u}){const o=g.useManage(),s=h.useAuthStore(),r=c.useRouter();return{mutate:async a=>{var n;const t=await((n=o.config.authProvider)==null?void 0:n.register(a,o));if(t!=null&&t.success){if(e==null||e(t),!(t!=null&&t.data))throw new Error("Register response data is undefined");s.login(t.data),r.push(o.getRoutePath(t.redirectTo||""));return}u==null||u(t)}}}function p({onSuccess:e,onError:u}){const o=g.useManage(),s=c.useRouter();return{mutate:async i=>{var t;const a=await((t=o.config.authProvider)==null?void 0:t.forgotPassword(i,o));if(a!=null&&a.success){e==null||e(a),a.redirectTo&&s.push(o.getRoutePath(a.redirectTo));return}u==null||u(a)}}}function v({onSuccess:e,onError:u}){const o=g.useManage(),s=c.useRouter();return{mutate:async i=>{var t;const a=await((t=o.config.authProvider)==null?void 0:t.updatePassword(i,o));if(a!=null&&a.success){e==null||e(a),a.redirectTo&&s.push(o.getRoutePath(a.redirectTo));return}u==null||u(a)}}}function T(e){const{config:u,getRoutePath:o}=g.useManage(),s=c.useRouter();return{mutate:async i=>{var t;const a=await((t=u.authProvider)==null?void 0:t.onError(i));e==null||e(a),a!=null&&a.logout&&s.push(o(a.redirectTo||"/login"))}}}function y(e){return h.useAuthStore(e).getUser()}function A(e){return h.useAuthStore(e).isLogin()}function L(e){const u=g.useManage(e),s=h.useAuthStore(e).getUser();return(i,a)=>{var t;return(t=u.config.authProvider)!=null&&t.can?u.config.authProvider.can(i,a,u,s)||!1:!0}}exports.useCan=L;exports.useCheck=w;exports.useError=T;exports.useForgotPassword=p;exports.useGetAuth=y;exports.useIsLogin=A;exports.useLogin=P;exports.useLogout=m;exports.useRegister=R;exports.useUpdatePassword=v;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("vue"),c=require("vue-router"),h=require("../stores/auth.cjs"),g=require("./manage.cjs");function P({onSuccess:e,onError:u}){const o=g.useManage(),s=h.useAuthStore(),r=c.useRouter(),i=f.ref(!1);return{mutate:async t=>{var d;i.value=!0;const n=await((d=o.config.authProvider)==null?void 0:d.login(t,o));if(i.value=!1,n!=null&&n.success){if(!(n!=null&&n.data))throw new Error("Login response data is undefined");e==null||e(n),s.login(n.data),r.push(o.getRoutePath(n.redirectTo||"/"));return}u==null||u(n)},isLoading:i}}function m({onSuccess:e,onError:u}){const o=g.useManage(),s=h.useAuthStore(),r=c.useRouter();return{mutate:async a=>{var n;const t=await((n=o.config.authProvider)==null?void 0:n.logout(a,o));if(t!=null&&t.success){e==null||e(t),s.logout(),r.push(o.getRoutePath(t.redirectTo||"/login"));return}u==null||u(t)}}}function w({onSuccess:e,onError:u}){const o=g.useManage(),s=h.useAuthStore(),r=c.useRouter();return{mutate:async a=>{var n;const t=await((n=o.config.authProvider)==null?void 0:n.check(a,o));if(t!=null&&t.success){if(e==null||e(t),!(t!=null&&t.data))throw new Error("Check response data is undefined");s.update(t.data);return}u==null||u(t),t!=null&&t.logout&&r.push(o.getRoutePath(t.redirectTo||"/login"))}}}function R({onSuccess:e,onError:u}){const o=g.useManage(),s=h.useAuthStore(),r=c.useRouter();return{mutate:async a=>{var n;const t=await((n=o.config.authProvider)==null?void 0:n.register(a,o));if(t!=null&&t.success){if(e==null||e(t),!(t!=null&&t.data))throw new Error("Register response data is undefined");s.login(t.data),r.push(o.getRoutePath(t.redirectTo||""));return}u==null||u(t)}}}function p({onSuccess:e,onError:u}){const o=g.useManage(),s=c.useRouter();return{mutate:async i=>{var t;const a=await((t=o.config.authProvider)==null?void 0:t.forgotPassword(i,o));if(a!=null&&a.success){e==null||e(a),a.redirectTo&&s.push(o.getRoutePath(a.redirectTo));return}u==null||u(a)}}}function v({onSuccess:e,onError:u}){const o=g.useManage(),s=c.useRouter();return{mutate:async i=>{var t;const a=await((t=o.config.authProvider)==null?void 0:t.updatePassword(i,o));if(a!=null&&a.success){e==null||e(a),a.redirectTo&&s.push(o.getRoutePath(a.redirectTo));return}u==null||u(a)}}}function T(e){const{config:u,getRoutePath:o}=g.useManage(),s=c.useRouter();return{mutate:async i=>{var t;const a=await((t=u.authProvider)==null?void 0:t.onError(i));e==null||e(a),a!=null&&a.logout&&s.push(o(a.redirectTo||"/login"))}}}function y(e){return h.useAuthStore(e).getUser()}function A(e){return h.useAuthStore(e).isLogin()}function L(e){const u=g.useManage(e),s=h.useAuthStore(e).getUser();return(i,a)=>{var t;return(t=u.config.authProvider)!=null&&t.can?u.config.authProvider.can(i,a,u,s):!0}}exports.useCan=L;exports.useCheck=w;exports.useError=T;exports.useForgotPassword=p;exports.useGetAuth=y;exports.useIsLogin=A;exports.useLogin=P;exports.useLogout=m;exports.useRegister=R;exports.useUpdatePassword=v;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g=require("axios");function s(a){return{login:async(d,c)=>{var n;return await g.post(c.getApiUrl(((n=a==null?void 0:a.apiPath)==null?void 0:n.login)||"/login",a==null?void 0:a.dataProviderName),d).then(t=>{var e,i,u;return{success:!0,message:(e=t==null?void 0:t.data)==null?void 0:e.message,redirectTo:((i=a==null?void 0:a.routePath)==null?void 0:i.index)||"/",data:(u=t==null?void 0:t.data)==null?void 0:u.data}}).catch(t=>{var e,i;return{success:!1,message:((i=(e=t==null?void 0:t.response)==null?void 0:e.data)==null?void 0:i.message)||(t==null?void 0:t.message)}})},check:async(d,c)=>{var n;return await g.get((c==null?void 0:c.getApiUrl(((n=a==null?void 0:a.apiPath)==null?void 0:n.check)||"/check",a==null?void 0:a.dataProviderName))||"").then(t=>{var e,i;return{success:!0,message:(e=t==null?void 0:t.data)==null?void 0:e.message,data:(i=t==null?void 0:t.data)==null?void 0:i.data}}).catch(t=>{var e,i;return{success:!1,message:((i=(e=t==null?void 0:t.response)==null?void 0:e.data)==null?void 0:i.message)||(t==null?void 0:t.message)}})},onError:async d=>{var c;return d.status===403?{logout:!0,redirectTo:((c=a==null?void 0:a.routePath)==null?void 0:c.login)||"/login",error:d}:{logout:!1,error:d}},logout:async()=>{var d;return{success:!0,redirectTo:((d=a==null?void 0:a.routePath)==null?void 0:d.login)||"/login"}},register:async(d,c)=>{var n;return await g.post((c==null?void 0:c.getApiUrl(((n=a==null?void 0:a.apiPath)==null?void 0:n.register)||"/register",a==null?void 0:a.dataProviderName))||"",d).then(t=>{var e,i,u;return{success:!0,message:(e=t==null?void 0:t.data)==null?void 0:e.message,redirectTo:((i=a==null?void 0:a.routePath)==null?void 0:i.index)||"/",data:(u=t==null?void 0:t.data)==null?void 0:u.data}}).catch(t=>{var e,i;return{success:!1,message:((i=(e=t==null?void 0:t.response)==null?void 0:e.data)==null?void 0:i.message)||(t==null?void 0:t.message)}})},forgotPassword:async(d,c)=>{var n;return await g.post((c==null?void 0:c.getApiUrl(((n=a==null?void 0:a.apiPath)==null?void 0:n.forgotPassword)||"/forgot-password",a==null?void 0:a.dataProviderName))||"",d).then(t=>{var e,i;return{success:!0,message:(e=t==null?void 0:t.data)==null?void 0:e.message,redirectTo:((i=a==null?void 0:a.routePath)==null?void 0:i.login)||"/login"}}).catch(t=>{var e,i;return{success:!1,message:((i=(e=t==null?void 0:t.response)==null?void 0:e.data)==null?void 0:i.message)||(t==null?void 0:t.message)}})},updatePassword:async(d,c)=>{var n;return await g.post((c==null?void 0:c.getApiUrl(((n=a==null?void 0:a.apiPath)==null?void 0:n.updatePassword)||"/update-password",a==null?void 0:a.dataProviderName))||"",d).then(t=>{var e,i;return{success:!0,message:(e=t==null?void 0:t.data)==null?void 0:e.message,redirectTo:((i=a==null?void 0:a.routePath)==null?void 0:i.login)||"/login"}}).catch(t=>{var e,i;return{success:!1,message:((i=(e=t==null?void 0:t.response)==null?void 0:e.data)==null?void 0:i.message)||(t==null?void 0:t.message)}})},can:(d,c,n,t)=>{var e;return!(!(t!=null&&t.permission)||Array.isArray(t==null?void 0:t.permission)&&!((e=t==null?void 0:t.permission)!=null&&e.includes(d))||typeof(t==null?void 0:t.permission)=="object"&&(t==null?void 0:t.permission[d])===!1)}}}exports.simpleAuthProvider=s;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g=require("axios");function l(t){return{login:async(n,c)=>{var d;return await g.post(c.getApiUrl(((d=t==null?void 0:t.apiPath)==null?void 0:d.login)||"/login",t==null?void 0:t.dataProviderName),n).then(e=>{var i,a,s;return{success:!0,message:(i=e==null?void 0:e.data)==null?void 0:i.message,redirectTo:((a=t==null?void 0:t.routePath)==null?void 0:a.index)||"/",data:(s=e==null?void 0:e.data)==null?void 0:s.data}}).catch(e=>{var i,a;return{success:!1,message:((a=(i=e==null?void 0:e.response)==null?void 0:i.data)==null?void 0:a.message)||(e==null?void 0:e.message)}})},check:async(n,c)=>{var d;return await g.get((c==null?void 0:c.getApiUrl(((d=t==null?void 0:t.apiPath)==null?void 0:d.check)||"/check",t==null?void 0:t.dataProviderName))||"").then(e=>{var i,a;return{success:!0,message:(i=e==null?void 0:e.data)==null?void 0:i.message,data:(a=e==null?void 0:e.data)==null?void 0:a.data}}).catch(e=>{var i,a;return{success:!1,message:((a=(i=e==null?void 0:e.response)==null?void 0:i.data)==null?void 0:a.message)||(e==null?void 0:e.message)}})},onError:async n=>{var c;return n.status===403?{logout:!0,redirectTo:((c=t==null?void 0:t.routePath)==null?void 0:c.login)||"/login",error:n}:{logout:!1,error:n}},logout:async()=>{var n;return{success:!0,redirectTo:((n=t==null?void 0:t.routePath)==null?void 0:n.login)||"/login"}},register:async(n,c)=>{var d;return await g.post((c==null?void 0:c.getApiUrl(((d=t==null?void 0:t.apiPath)==null?void 0:d.register)||"/register",t==null?void 0:t.dataProviderName))||"",n).then(e=>{var i,a,s;return{success:!0,message:(i=e==null?void 0:e.data)==null?void 0:i.message,redirectTo:((a=t==null?void 0:t.routePath)==null?void 0:a.index)||"/",data:(s=e==null?void 0:e.data)==null?void 0:s.data}}).catch(e=>{var i,a;return{success:!1,message:((a=(i=e==null?void 0:e.response)==null?void 0:i.data)==null?void 0:a.message)||(e==null?void 0:e.message)}})},forgotPassword:async(n,c)=>{var d;return await g.post((c==null?void 0:c.getApiUrl(((d=t==null?void 0:t.apiPath)==null?void 0:d.forgotPassword)||"/forgot-password",t==null?void 0:t.dataProviderName))||"",n).then(e=>{var i,a;return{success:!0,message:(i=e==null?void 0:e.data)==null?void 0:i.message,redirectTo:((a=t==null?void 0:t.routePath)==null?void 0:a.login)||"/login"}}).catch(e=>{var i,a;return{success:!1,message:((a=(i=e==null?void 0:e.response)==null?void 0:i.data)==null?void 0:a.message)||(e==null?void 0:e.message)}})},updatePassword:async(n,c)=>{var d;return await g.post((c==null?void 0:c.getApiUrl(((d=t==null?void 0:t.apiPath)==null?void 0:d.updatePassword)||"/update-password",t==null?void 0:t.dataProviderName))||"",n).then(e=>{var i,a;return{success:!0,message:(i=e==null?void 0:e.data)==null?void 0:i.message,redirectTo:((a=t==null?void 0:t.routePath)==null?void 0:a.login)||"/login"}}).catch(e=>{var i,a;return{success:!1,message:((a=(i=e==null?void 0:e.response)==null?void 0:i.data)==null?void 0:a.message)||(e==null?void 0:e.message)}})},can:(n,c,d,e)=>{var i,a;return!(e!=null&&e.permission)||Array.isArray(e==null?void 0:e.permission)&&((i=e==null?void 0:e.permission)==null?void 0:i.length)===0||typeof(e==null?void 0:e.permission)=="object"&&Object.keys(e==null?void 0:e.permission).length===0?!0:!(Array.isArray(e==null?void 0:e.permission)&&!((a=e==null?void 0:e.permission)!=null&&a.includes(n))||typeof(e==null?void 0:e.permission)=="object"&&(e==null?void 0:e.permission[n])===!1)}}}exports.simpleAuthProvider=l;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("vue"),L=require("@overlastic/vue"),T=require("vue-router"),U=require("../hooks/auth.cjs"),V=require("../hooks/config.cjs");require("@tanstack/vue-query");const B=require("../hooks/manage.cjs");require("lodash-es");require("pinia");const G=require("../stores/auth.cjs"),H=require("../stores/route.cjs"),J=require("../stores/manage.cjs"),K=require("../stores/i18n.cjs");require("@vueuse/core");require("clsx");const Q=h=>Object.freeze(Object.defineProperty({__proto__:null,default:h},Symbol.toStringTag,{value:"Module"})),W=f.defineComponent({name:"DuxAppProvider",props:{},setup(h,{slots:p}){const l=f.inject("dux.manage"),s=V.useConfig(),d=T.useRouter();return d.beforeEach(async(o,X,a)=>{var b,$,S,R,A,M,y,_,z,k,w,D,I;const t=o.meta.manageName,E=o.meta.authorization===!1;if(!t){const e=s.defaultManage||(($=(b=s.manages)==null?void 0:b[0])==null?void 0:$.name)||"";return a({path:`/${e}`,replace:!0})}l&&(l.value=t);const m=J.useManageStore(t);m.isInit()||m.setConfig((S=s.manages)==null?void 0:S.find(e=>e.name===t),s);const c=H.useRouteStore(t),n=B.useManage(t),g=G.useAuthStore(t),v=K.useI18nStore(t);if((R=n.config)!=null&&R.i18nProvider&&!v.isInit()){const e=v.getLocale();e&&((A=n.config)==null||A.i18nProvider.changeLocale(e))}if(!g.isLogin())return E?a():a({path:n.getRoutePath("login"),replace:!0});const q=e=>e==null?void 0:e.map(u=>({...u,path:n.getRoutePath(u.path||"")}));if(!c.getRouteInit()){const e=((M=n.config)==null?void 0:M.components)||{},u=[];if(e.notFound&&u.push({name:`${t}.notFound`,label:"404",path:":pathMatch(.*)*",component:e.notFound,hidden:!0,meta:{can:!1}}),e.notAuthorized&&u.push({name:`${t}.notAuthorized`,label:"403",path:"notAuthorized",component:e.notAuthorized,hidden:!0,meta:{can:!1}}),e.error&&u.push({name:`${t}.error`,label:"500",path:"error",component:e.error,hidden:!0,meta:{can:!1}}),c.setRoutes(q(((y=n.config)==null?void 0:y.menus)||[])),(_=n.config)!=null&&_.apiRoutePath)try{await((w=(k=(z=n.config)==null?void 0:z.dataProvider)==null?void 0:k.default)==null?void 0:w.custom({path:n.config.apiRoutePath,meta:{timeout:5e3}},n,g.getUser()).then(r=>{c.appendRoutes(q(r.data||[]))}))}catch(r){console.error(r)}return c.appendRoutes(u),c.getRoutes().forEach(r=>{var O,j;if(!r.path)return;const i={name:r.name,path:r.path,meta:r.meta};switch(r.loader){case"iframe":i.component=((j=(O=n.config)==null?void 0:O.components)==null?void 0:j.iframe)||(()=>Promise.resolve().then(()=>Q(require("../components/loader/iframe.cjs"))));break;case"link":i.beforeEnter=()=>{var N;const C=((N=r.meta)==null?void 0:N.url)||r.path;return C&&window.open(C,"_blank"),!1},i.component=()=>Promise.resolve({template:"<div></div>"});break;default:r.component&&(i.component=r.component);break}d.addRoute(`${t}.auth`,i)}),a({path:o.fullPath,replace:!0})}const P=["","/",`/${t}`,`/${t}/`];if(P.includes(o.path)){const e=c.getIndexRoute();return!(e!=null&&e.path)||P.includes(e==null?void 0:e.path)?(console.warn("[Dux] index route not found, skip redirect"),a()):a({path:(e==null?void 0:e.path)||"/",replace:!0})}const F=U.useCan(t);return(((D=o.meta)==null?void 0:D.can)===void 0||((I=o.meta)==null?void 0:I.can)===!0)&&!F(o.name)?a({name:`${t}.notAuthorized`}):a()}),()=>f.createVNode(L.OverlaysProvider,null,{default:()=>{var o;return[(o=p.default)==null?void 0:o.call(p)]}})}});exports.DuxAppProvider=W;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("vue"),T=require("@overlastic/vue"),U=require("vue-router"),V=require("../hooks/auth.cjs"),B=require("../hooks/config.cjs");require("@tanstack/vue-query");const G=require("../hooks/manage.cjs");require("lodash-es");require("pinia");const H=require("../stores/auth.cjs"),J=require("../stores/route.cjs"),K=require("../stores/manage.cjs"),Q=require("../stores/i18n.cjs");require("@vueuse/core");require("clsx");const p=l=>Object.freeze(Object.defineProperty({__proto__:null,default:l},Symbol.toStringTag,{value:"Module"})),W=h.defineComponent({name:"DuxAppProvider",props:{},setup(l,{slots:f}){const m=h.inject("dux.manage"),s=B.useConfig(),d=U.useRouter();return d.beforeEach(async(o,X,a)=>{var $,S,R,A,M,y,_,k,z,w,D,I,O;const t=o.meta.manageName,L=o.meta.authorization===!1;if(!t){const e=s.defaultManage||((S=($=s.manages)==null?void 0:$[0])==null?void 0:S.name)||"";return a({path:`/${e}`,replace:!0})}m&&(m.value=t);const g=K.useManageStore(t);g.isInit()||g.setConfig((R=s.manages)==null?void 0:R.find(e=>e.name===t),s);const c=J.useRouteStore(t),n=G.useManage(t),v=H.useAuthStore(t),q=Q.useI18nStore(t);if((A=n.config)!=null&&A.i18nProvider&&!q.isInit()){const e=q.getLocale();e&&((M=n.config)==null||M.i18nProvider.changeLocale(e))}if(!v.isLogin())return L?a():a({path:n.getRoutePath("login"),replace:!0});const P=e=>e==null?void 0:e.map(u=>({...u,path:n.getRoutePath(u.path||"")}));if(!c.getRouteInit()){const e=((y=n.config)==null?void 0:y.components)||{},u=[];if(u.push({name:`${t}.notFound`,label:"404",path:":pathMatch(.*)*",component:e.notFound||(()=>Promise.resolve().then(()=>p(require("../components/status/notFound.cjs")))),hidden:!0,meta:{can:!1}}),u.push({name:`${t}.notAuthorized`,label:"403",path:"notAuthorized",component:e.notAuthorized||(()=>Promise.resolve().then(()=>p(require("../components/status/notAuthorized.cjs")))),hidden:!0,meta:{can:!1}}),u.push({name:`${t}.error`,label:"500",path:"error",component:e.error||(()=>Promise.resolve().then(()=>p(require("../components/status/error.cjs")))),hidden:!0,meta:{can:!1}}),c.setRoutes(P(((_=n.config)==null?void 0:_.menus)||[])),(k=n.config)!=null&&k.apiRoutePath)try{await((D=(w=(z=n.config)==null?void 0:z.dataProvider)==null?void 0:w.default)==null?void 0:D.custom({path:n.config.apiRoutePath,meta:{timeout:5e3}},n,v.getUser()).then(r=>{c.appendRoutes(P(r.data||[]))}))}catch(r){console.error(r)}return c.appendRoutes(u),c.getRoutes().forEach(r=>{var j,C;if(!r.path)return;const i={name:r.name,path:r.path,meta:r.meta};switch(r.loader){case"iframe":i.component=((C=(j=n.config)==null?void 0:j.components)==null?void 0:C.iframe)||(()=>Promise.resolve().then(()=>p(require("../components/loader/iframe.cjs"))));break;case"link":i.beforeEnter=()=>{var E;const N=((E=r.meta)==null?void 0:E.url)||r.path;return N&&window.open(N,"_blank"),!1},i.component=()=>Promise.resolve({template:"<div></div>"});break;default:r.component&&(i.component=r.component);break}d.addRoute(`${t}.auth`,i)}),a({path:o.fullPath,replace:!0})}const b=["","/",`/${t}`,`/${t}/`];if(b.includes(o.path)){const e=c.getIndexRoute();return!(e!=null&&e.path)||b.includes(e==null?void 0:e.path)?(console.warn("[Dux] index route not found, skip redirect"),a()):a({path:(e==null?void 0:e.path)||"/",replace:!0})}const F=V.useCan(t);return(((I=o.meta)==null?void 0:I.can)===void 0||((O=o.meta)==null?void 0:O.can)===!0)&&!F(o.name)?a({name:`${t}.notAuthorized`}):a()}),()=>h.createVNode(T.OverlaysProvider,null,{default:()=>{var o;return[(o=f.default)==null?void 0:o.call(f)]}})}});exports.DuxAppProvider=W;
@@ -0,0 +1,10 @@
1
+ import { defineComponent as n, createVNode as e, createTextVNode as r } from "vue";
2
+ const t = /* @__PURE__ */ n({
3
+ name: "DuxError",
4
+ setup() {
5
+ return () => e("div", null, [e("h1", null, [r("500")]), e("p", null, [r("Internal Server Error")])]);
6
+ }
7
+ });
8
+ export {
9
+ t as default
10
+ };
@@ -0,0 +1,10 @@
1
+ import { defineComponent as o, createVNode as e, createTextVNode as t } from "vue";
2
+ const r = /* @__PURE__ */ o({
3
+ name: "DuxNotAuthorized",
4
+ setup() {
5
+ return () => e("div", null, [e("h1", null, [t("403")]), e("p", null, [t("You are not authorized to access this page")])]);
6
+ }
7
+ });
8
+ export {
9
+ r as default
10
+ };
@@ -0,0 +1,10 @@
1
+ import { defineComponent as o, createVNode as e, createTextVNode as n } from "vue";
2
+ const u = /* @__PURE__ */ o({
3
+ name: "DuxNotFound",
4
+ setup() {
5
+ return () => e("div", null, [e("h1", null, [n("404")]), e("p", null, [n("Page not found")])]);
6
+ }
7
+ });
8
+ export {
9
+ u as default
10
+ };
@@ -114,7 +114,7 @@ function G(e) {
114
114
  const a = g(e), o = c(e).getUser();
115
115
  return (r, i) => {
116
116
  var t;
117
- return (t = a.config.authProvider) != null && t.can ? a.config.authProvider.can(r, i, a, o) || !1 : !0;
117
+ return (t = a.config.authProvider) != null && t.can ? a.config.authProvider.can(r, i, a, o) : !0;
118
118
  };
119
119
  }
120
120
  export {
@@ -1,117 +1,117 @@
1
- import u from "axios";
2
- function l(a) {
1
+ import g from "axios";
2
+ function m(t) {
3
3
  return {
4
- login: async (d, c) => {
5
- var n;
6
- return await u.post(c.getApiUrl(((n = a == null ? void 0 : a.apiPath) == null ? void 0 : n.login) || "/login", a == null ? void 0 : a.dataProviderName), d).then((t) => {
7
- var e, i, g;
4
+ login: async (n, c) => {
5
+ var d;
6
+ return await g.post(c.getApiUrl(((d = t == null ? void 0 : t.apiPath) == null ? void 0 : d.login) || "/login", t == null ? void 0 : t.dataProviderName), n).then((e) => {
7
+ var i, a, s;
8
8
  return {
9
9
  success: !0,
10
- message: (e = t == null ? void 0 : t.data) == null ? void 0 : e.message,
11
- redirectTo: ((i = a == null ? void 0 : a.routePath) == null ? void 0 : i.index) || "/",
12
- data: (g = t == null ? void 0 : t.data) == null ? void 0 : g.data
10
+ message: (i = e == null ? void 0 : e.data) == null ? void 0 : i.message,
11
+ redirectTo: ((a = t == null ? void 0 : t.routePath) == null ? void 0 : a.index) || "/",
12
+ data: (s = e == null ? void 0 : e.data) == null ? void 0 : s.data
13
13
  };
14
- }).catch((t) => {
15
- var e, i;
14
+ }).catch((e) => {
15
+ var i, a;
16
16
  return {
17
17
  success: !1,
18
- message: ((i = (e = t == null ? void 0 : t.response) == null ? void 0 : e.data) == null ? void 0 : i.message) || (t == null ? void 0 : t.message)
18
+ message: ((a = (i = e == null ? void 0 : e.response) == null ? void 0 : i.data) == null ? void 0 : a.message) || (e == null ? void 0 : e.message)
19
19
  };
20
20
  });
21
21
  },
22
- check: async (d, c) => {
23
- var n;
24
- return await u.get((c == null ? void 0 : c.getApiUrl(((n = a == null ? void 0 : a.apiPath) == null ? void 0 : n.check) || "/check", a == null ? void 0 : a.dataProviderName)) || "").then((t) => {
25
- var e, i;
22
+ check: async (n, c) => {
23
+ var d;
24
+ return await g.get((c == null ? void 0 : c.getApiUrl(((d = t == null ? void 0 : t.apiPath) == null ? void 0 : d.check) || "/check", t == null ? void 0 : t.dataProviderName)) || "").then((e) => {
25
+ var i, a;
26
26
  return {
27
27
  success: !0,
28
- message: (e = t == null ? void 0 : t.data) == null ? void 0 : e.message,
29
- data: (i = t == null ? void 0 : t.data) == null ? void 0 : i.data
28
+ message: (i = e == null ? void 0 : e.data) == null ? void 0 : i.message,
29
+ data: (a = e == null ? void 0 : e.data) == null ? void 0 : a.data
30
30
  };
31
- }).catch((t) => {
32
- var e, i;
31
+ }).catch((e) => {
32
+ var i, a;
33
33
  return {
34
34
  success: !1,
35
- message: ((i = (e = t == null ? void 0 : t.response) == null ? void 0 : e.data) == null ? void 0 : i.message) || (t == null ? void 0 : t.message)
35
+ message: ((a = (i = e == null ? void 0 : e.response) == null ? void 0 : i.data) == null ? void 0 : a.message) || (e == null ? void 0 : e.message)
36
36
  };
37
37
  });
38
38
  },
39
- onError: async (d) => {
39
+ onError: async (n) => {
40
40
  var c;
41
- return d.status === 403 ? {
41
+ return n.status === 403 ? {
42
42
  logout: !0,
43
- redirectTo: ((c = a == null ? void 0 : a.routePath) == null ? void 0 : c.login) || "/login",
44
- error: d
43
+ redirectTo: ((c = t == null ? void 0 : t.routePath) == null ? void 0 : c.login) || "/login",
44
+ error: n
45
45
  } : {
46
46
  logout: !1,
47
- error: d
47
+ error: n
48
48
  };
49
49
  },
50
50
  logout: async () => {
51
- var d;
51
+ var n;
52
52
  return {
53
53
  success: !0,
54
- redirectTo: ((d = a == null ? void 0 : a.routePath) == null ? void 0 : d.login) || "/login"
54
+ redirectTo: ((n = t == null ? void 0 : t.routePath) == null ? void 0 : n.login) || "/login"
55
55
  };
56
56
  },
57
- register: async (d, c) => {
58
- var n;
59
- return await u.post((c == null ? void 0 : c.getApiUrl(((n = a == null ? void 0 : a.apiPath) == null ? void 0 : n.register) || "/register", a == null ? void 0 : a.dataProviderName)) || "", d).then((t) => {
60
- var e, i, g;
57
+ register: async (n, c) => {
58
+ var d;
59
+ return await g.post((c == null ? void 0 : c.getApiUrl(((d = t == null ? void 0 : t.apiPath) == null ? void 0 : d.register) || "/register", t == null ? void 0 : t.dataProviderName)) || "", n).then((e) => {
60
+ var i, a, s;
61
61
  return {
62
62
  success: !0,
63
- message: (e = t == null ? void 0 : t.data) == null ? void 0 : e.message,
64
- redirectTo: ((i = a == null ? void 0 : a.routePath) == null ? void 0 : i.index) || "/",
65
- data: (g = t == null ? void 0 : t.data) == null ? void 0 : g.data
63
+ message: (i = e == null ? void 0 : e.data) == null ? void 0 : i.message,
64
+ redirectTo: ((a = t == null ? void 0 : t.routePath) == null ? void 0 : a.index) || "/",
65
+ data: (s = e == null ? void 0 : e.data) == null ? void 0 : s.data
66
66
  };
67
- }).catch((t) => {
68
- var e, i;
67
+ }).catch((e) => {
68
+ var i, a;
69
69
  return {
70
70
  success: !1,
71
- message: ((i = (e = t == null ? void 0 : t.response) == null ? void 0 : e.data) == null ? void 0 : i.message) || (t == null ? void 0 : t.message)
71
+ message: ((a = (i = e == null ? void 0 : e.response) == null ? void 0 : i.data) == null ? void 0 : a.message) || (e == null ? void 0 : e.message)
72
72
  };
73
73
  });
74
74
  },
75
- forgotPassword: async (d, c) => {
76
- var n;
77
- return await u.post((c == null ? void 0 : c.getApiUrl(((n = a == null ? void 0 : a.apiPath) == null ? void 0 : n.forgotPassword) || "/forgot-password", a == null ? void 0 : a.dataProviderName)) || "", d).then((t) => {
78
- var e, i;
75
+ forgotPassword: async (n, c) => {
76
+ var d;
77
+ return await g.post((c == null ? void 0 : c.getApiUrl(((d = t == null ? void 0 : t.apiPath) == null ? void 0 : d.forgotPassword) || "/forgot-password", t == null ? void 0 : t.dataProviderName)) || "", n).then((e) => {
78
+ var i, a;
79
79
  return {
80
80
  success: !0,
81
- message: (e = t == null ? void 0 : t.data) == null ? void 0 : e.message,
82
- redirectTo: ((i = a == null ? void 0 : a.routePath) == null ? void 0 : i.login) || "/login"
81
+ message: (i = e == null ? void 0 : e.data) == null ? void 0 : i.message,
82
+ redirectTo: ((a = t == null ? void 0 : t.routePath) == null ? void 0 : a.login) || "/login"
83
83
  };
84
- }).catch((t) => {
85
- var e, i;
84
+ }).catch((e) => {
85
+ var i, a;
86
86
  return {
87
87
  success: !1,
88
- message: ((i = (e = t == null ? void 0 : t.response) == null ? void 0 : e.data) == null ? void 0 : i.message) || (t == null ? void 0 : t.message)
88
+ message: ((a = (i = e == null ? void 0 : e.response) == null ? void 0 : i.data) == null ? void 0 : a.message) || (e == null ? void 0 : e.message)
89
89
  };
90
90
  });
91
91
  },
92
- updatePassword: async (d, c) => {
93
- var n;
94
- return await u.post((c == null ? void 0 : c.getApiUrl(((n = a == null ? void 0 : a.apiPath) == null ? void 0 : n.updatePassword) || "/update-password", a == null ? void 0 : a.dataProviderName)) || "", d).then((t) => {
95
- var e, i;
92
+ updatePassword: async (n, c) => {
93
+ var d;
94
+ return await g.post((c == null ? void 0 : c.getApiUrl(((d = t == null ? void 0 : t.apiPath) == null ? void 0 : d.updatePassword) || "/update-password", t == null ? void 0 : t.dataProviderName)) || "", n).then((e) => {
95
+ var i, a;
96
96
  return {
97
97
  success: !0,
98
- message: (e = t == null ? void 0 : t.data) == null ? void 0 : e.message,
99
- redirectTo: ((i = a == null ? void 0 : a.routePath) == null ? void 0 : i.login) || "/login"
98
+ message: (i = e == null ? void 0 : e.data) == null ? void 0 : i.message,
99
+ redirectTo: ((a = t == null ? void 0 : t.routePath) == null ? void 0 : a.login) || "/login"
100
100
  };
101
- }).catch((t) => {
102
- var e, i;
101
+ }).catch((e) => {
102
+ var i, a;
103
103
  return {
104
104
  success: !1,
105
- message: ((i = (e = t == null ? void 0 : t.response) == null ? void 0 : e.data) == null ? void 0 : i.message) || (t == null ? void 0 : t.message)
105
+ message: ((a = (i = e == null ? void 0 : e.response) == null ? void 0 : i.data) == null ? void 0 : a.message) || (e == null ? void 0 : e.message)
106
106
  };
107
107
  });
108
108
  },
109
- can: (d, c, n, t) => {
110
- var e;
111
- return !(!(t != null && t.permission) || Array.isArray(t == null ? void 0 : t.permission) && !((e = t == null ? void 0 : t.permission) != null && e.includes(d)) || typeof (t == null ? void 0 : t.permission) == "object" && (t == null ? void 0 : t.permission[d]) === !1);
109
+ can: (n, c, d, e) => {
110
+ var i, a;
111
+ return !(e != null && e.permission) || Array.isArray(e == null ? void 0 : e.permission) && ((i = e == null ? void 0 : e.permission) == null ? void 0 : i.length) === 0 || typeof (e == null ? void 0 : e.permission) == "object" && Object.keys(e == null ? void 0 : e.permission).length === 0 ? !0 : !(Array.isArray(e == null ? void 0 : e.permission) && !((a = e == null ? void 0 : e.permission) != null && a.includes(n)) || typeof (e == null ? void 0 : e.permission) == "object" && (e == null ? void 0 : e.permission[n]) === !1);
112
112
  }
113
113
  };
114
114
  }
115
115
  export {
116
- l as simpleAuthProvider
116
+ m as simpleAuthProvider
117
117
  };
@@ -21,8 +21,8 @@ const se = /* @__PURE__ */ j({
21
21
  }) {
22
22
  const f = O("dux.manage"), c = G(), s = q();
23
23
  return s.beforeEach(async (a, X, n) => {
24
- var v, R, b, A, S, $, M, k, z, w, I, C, y;
25
- const t = a.meta.manageName, N = a.meta.authorization === !1;
24
+ var v, R, b, A, S, $, M, k, w, z, I, C, y;
25
+ const t = a.meta.manageName, _ = a.meta.authorization === !1;
26
26
  if (!t) {
27
27
  const e = c.defaultManage || ((R = (v = c.manages) == null ? void 0 : v[0]) == null ? void 0 : R.name) || "";
28
28
  return n({
@@ -33,13 +33,13 @@ const se = /* @__PURE__ */ j({
33
33
  f && (f.value = t);
34
34
  const h = Q(t);
35
35
  h.isInit() || h.setConfig((b = c.manages) == null ? void 0 : b.find((e) => e.name === t), c);
36
- const u = K(t), r = H(t), d = J(t), l = T(t);
36
+ const p = K(t), r = H(t), d = J(t), l = T(t);
37
37
  if ((A = r.config) != null && A.i18nProvider && !l.isInit()) {
38
38
  const e = l.getLocale();
39
39
  e && ((S = r.config) == null || S.i18nProvider.changeLocale(e));
40
40
  }
41
41
  if (!d.isLogin())
42
- return N ? n() : n({
42
+ return _ ? n() : n({
43
43
  path: r.getRoutePath("login"),
44
44
  replace: !0
45
45
  });
@@ -47,75 +47,75 @@ const se = /* @__PURE__ */ j({
47
47
  ...i,
48
48
  path: r.getRoutePath(i.path || "")
49
49
  }));
50
- if (!u.getRouteInit()) {
50
+ if (!p.getRouteInit()) {
51
51
  const e = (($ = r.config) == null ? void 0 : $.components) || {}, i = [];
52
- if (e.notFound && i.push({
52
+ if (i.push({
53
53
  name: `${t}.notFound`,
54
54
  label: "404",
55
55
  path: ":pathMatch(.*)*",
56
- component: e.notFound,
56
+ component: e.notFound || (() => import("../components/status/notFound.js")),
57
57
  hidden: !0,
58
58
  meta: {
59
59
  can: !1
60
60
  }
61
- }), e.notAuthorized && i.push({
61
+ }), i.push({
62
62
  name: `${t}.notAuthorized`,
63
63
  label: "403",
64
64
  path: "notAuthorized",
65
- component: e.notAuthorized,
65
+ component: e.notAuthorized || (() => import("../components/status/notAuthorized.js")),
66
66
  hidden: !0,
67
67
  meta: {
68
68
  can: !1
69
69
  }
70
- }), e.error && i.push({
70
+ }), i.push({
71
71
  name: `${t}.error`,
72
72
  label: "500",
73
73
  path: "error",
74
- component: e.error,
74
+ component: e.error || (() => import("../components/status/error.js")),
75
75
  hidden: !0,
76
76
  meta: {
77
77
  can: !1
78
78
  }
79
- }), u.setRoutes(g(((M = r.config) == null ? void 0 : M.menus) || [])), (k = r.config) != null && k.apiRoutePath)
79
+ }), p.setRoutes(g(((M = r.config) == null ? void 0 : M.menus) || [])), (k = r.config) != null && k.apiRoutePath)
80
80
  try {
81
- await ((I = (w = (z = r.config) == null ? void 0 : z.dataProvider) == null ? void 0 : w.default) == null ? void 0 : I.custom({
81
+ await ((I = (z = (w = r.config) == null ? void 0 : w.dataProvider) == null ? void 0 : z.default) == null ? void 0 : I.custom({
82
82
  path: r.config.apiRoutePath,
83
83
  meta: {
84
84
  timeout: 5e3
85
85
  }
86
86
  }, r, d.getUser()).then((o) => {
87
- u.appendRoutes(g(o.data || []));
87
+ p.appendRoutes(g(o.data || []));
88
88
  }));
89
89
  } catch (o) {
90
90
  console.error(o);
91
91
  }
92
- return u.appendRoutes(i), u.getRoutes().forEach((o) => {
92
+ return p.appendRoutes(i), p.getRoutes().forEach((o) => {
93
93
  var D, E;
94
94
  if (!o.path)
95
95
  return;
96
- const p = {
96
+ const u = {
97
97
  name: o.name,
98
98
  path: o.path,
99
99
  meta: o.meta
100
100
  };
101
101
  switch (o.loader) {
102
102
  case "iframe":
103
- p.component = ((E = (D = r.config) == null ? void 0 : D.components) == null ? void 0 : E.iframe) || (() => import("../components/loader/iframe.js"));
103
+ u.component = ((E = (D = r.config) == null ? void 0 : D.components) == null ? void 0 : E.iframe) || (() => import("../components/loader/iframe.js"));
104
104
  break;
105
105
  case "link":
106
- p.beforeEnter = () => {
107
- var L;
108
- const F = ((L = o.meta) == null ? void 0 : L.url) || o.path;
109
- return F && window.open(F, "_blank"), !1;
110
- }, p.component = () => Promise.resolve({
106
+ u.beforeEnter = () => {
107
+ var N;
108
+ const L = ((N = o.meta) == null ? void 0 : N.url) || o.path;
109
+ return L && window.open(L, "_blank"), !1;
110
+ }, u.component = () => Promise.resolve({
111
111
  template: "<div></div>"
112
112
  });
113
113
  break;
114
114
  default:
115
- o.component && (p.component = o.component);
115
+ o.component && (u.component = o.component);
116
116
  break;
117
117
  }
118
- s.addRoute(`${t}.auth`, p);
118
+ s.addRoute(`${t}.auth`, u);
119
119
  }), n({
120
120
  path: a.fullPath,
121
121
  replace: !0
@@ -123,14 +123,14 @@ const se = /* @__PURE__ */ j({
123
123
  }
124
124
  const P = ["", "/", `/${t}`, `/${t}/`];
125
125
  if (P.includes(a.path)) {
126
- const e = u.getIndexRoute();
126
+ const e = p.getIndexRoute();
127
127
  return !(e != null && e.path) || P.includes(e == null ? void 0 : e.path) ? (console.warn("[Dux] index route not found, skip redirect"), n()) : n({
128
128
  path: (e == null ? void 0 : e.path) || "/",
129
129
  replace: !0
130
130
  });
131
131
  }
132
- const _ = B(t);
133
- return (((C = a.meta) == null ? void 0 : C.can) === void 0 || ((y = a.meta) == null ? void 0 : y.can) === !0) && !_(a.name) ? n({
132
+ const F = B(t);
133
+ return (((C = a.meta) == null ? void 0 : C.can) === void 0 || ((y = a.meta) == null ? void 0 : y.can) === !0) && !F(a.name) ? n({
134
134
  name: `${t}.notAuthorized`
135
135
  }) : n();
136
136
  }), () => U(V, null, {
@@ -0,0 +1,2 @@
1
+ declare const _default: import("vue").DefineComponent<{}, () => import("vue/jsx-runtime").JSX.Element, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
2
+ export default _default;
@@ -0,0 +1,2 @@
1
+ declare const _default: import("vue").DefineComponent<{}, () => import("vue/jsx-runtime").JSX.Element, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
2
+ export default _default;
@@ -0,0 +1,2 @@
1
+ declare const _default: import("vue").DefineComponent<{}, () => import("vue/jsx-runtime").JSX.Element, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
2
+ export default _default;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@duxweb/dvha-core",
3
3
  "type": "module",
4
- "version": "0.1.3",
4
+ "version": "0.1.5",
5
5
  "author": "DuxWeb",
6
6
  "license": "LGPL-3.0",
7
7
  "repository": {