@duxweb/dvha-core 0.1.0 → 0.1.1

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 f=require("vue"),c=require("vue-router"),h=require("../stores/auth.cjs"),d=require("./manage.cjs");function m({onSuccess:e,onError:u}){const o=d.useManage(),i=h.useAuthStore(),r=c.useRouter(),n=f.ref(!1);return{mutate:async a=>{var g;n.value=!0;const t=await((g=o.config.authProvider)==null?void 0:g.login(a,o));if(n.value=!1,t!=null&&t.success){if(!(t!=null&&t.data))throw new Error("Login response data is undefined");e==null||e(t),i.login(t.data),r.push(o.getRoutePath(t.redirectTo||"/"));return}u==null||u(t)},isLoading:n}}function P({onSuccess:e,onError:u}){const{config:o,getRoutePath:i}=d.useManage(),r=h.useAuthStore(),n=c.useRouter();return{mutate:async a=>{var g;const t=await((g=o.config.authProvider)==null?void 0:g.logout(a));if(t!=null&&t.success){e==null||e(t),r.logout(),n.push(i(t.redirectTo||"/login"));return}u==null||u(t)}}}function w({onSuccess:e,onError:u}){const{config:o,getRoutePath:i}=d.useManage(),r=h.useAuthStore(),n=c.useRouter();return{mutate:async a=>{var g;const t=await((g=o.config.authProvider)==null?void 0:g.check(a));if(t!=null&&t.success){if(e==null||e(t),!(t!=null&&t.data))throw new Error("Check response data is undefined");r.update(t.data);return}u==null||u(t),t!=null&&t.logout&&n.push(i(t.redirectTo||"/login"))}}}function R({onSuccess:e,onError:u}){const{config:o,getRoutePath:i}=d.useManage(),r=h.useAuthStore(),n=c.useRouter();return{mutate:async a=>{var g;const t=await((g=o.config.authProvider)==null?void 0:g.register(a));if(t!=null&&t.success){if(e==null||e(t),!(t!=null&&t.data))throw new Error("Register response data is undefined");r.login(t.data),n.push(i(t.redirectTo||""));return}u==null||u(t)}}}function p({onSuccess:e,onError:u}){const{config:o,getRoutePath:i}=d.useManage(),r=c.useRouter();return{mutate:async s=>{var t;const a=await((t=o.config.authProvider)==null?void 0:t.forgotPassword(s));if(a!=null&&a.success){e==null||e(a),a.redirectTo&&r.push(i(a.redirectTo));return}u==null||u(a)}}}function v({onSuccess:e,onError:u}){const{config:o,getRoutePath:i}=d.useManage(),r=c.useRouter();return{mutate:async s=>{var t;const a=await((t=o.config.authProvider)==null?void 0:t.updatePassword(s));if(a!=null&&a.success){e==null||e(a),a.redirectTo&&r.push(i(a.redirectTo));return}u==null||u(a)}}}function T(e){const{config:u,getRoutePath:o}=d.useManage(),i=c.useRouter();return{mutate:async n=>{var a;const s=await((a=u.config.authProvider)==null?void 0:a.onError(n));e==null||e(s),s!=null&&s.logout&&i.push(o(s.redirectTo||"/login"))}}}function y(e){return h.useAuthStore(e).getUser()}function L(e){return h.useAuthStore(e).isLogin()}exports.useCheck=w;exports.useError=T;exports.useForgotPassword=p;exports.useGetAuth=y;exports.useIsLogin=L;exports.useLogin=m;exports.useLogout=P;exports.useRegister=R;exports.useUpdatePassword=v;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("vue"),g=require("vue-router"),h=require("../stores/auth.cjs"),d=require("./manage.cjs");function m({onSuccess:e,onError:a}){const o=d.useManage(),s=h.useAuthStore(),r=g.useRouter(),n=f.ref(!1);return{mutate:async t=>{var c;n.value=!0;const i=await((c=o.config.authProvider)==null?void 0:c.login(t,o));if(n.value=!1,i!=null&&i.success){if(!(i!=null&&i.data))throw new Error("Login response data is undefined");e==null||e(i),s.login(i.data),r.push(o.getRoutePath(i.redirectTo||"/"));return}a==null||a(i)},isLoading:n}}function P({onSuccess:e,onError:a}){const o=d.useManage(),s=h.useAuthStore(),r=g.useRouter();return{mutate:async u=>{var i;const t=await((i=o.config.authProvider)==null?void 0:i.logout(u,o));if(t!=null&&t.success){e==null||e(t),s.logout(),r.push(o.getRoutePath(t.redirectTo||"/login"));return}a==null||a(t)}}}function w({onSuccess:e,onError:a}){const o=d.useManage(),s=h.useAuthStore(),r=g.useRouter();return{mutate:async u=>{var i;const t=await((i=o.config.authProvider)==null?void 0:i.check(u,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}a==null||a(t),t!=null&&t.logout&&r.push(o.getRoutePath(t.redirectTo||"/login"))}}}function R({onSuccess:e,onError:a}){const o=d.useManage(),s=h.useAuthStore(),r=g.useRouter();return{mutate:async u=>{var i;const t=await((i=o.config.authProvider)==null?void 0:i.register(u,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}a==null||a(t)}}}function p({onSuccess:e,onError:a}){const o=d.useManage(),s=g.useRouter();return{mutate:async n=>{var t;const u=await((t=o.config.authProvider)==null?void 0:t.forgotPassword(n,o));if(u!=null&&u.success){e==null||e(u),u.redirectTo&&s.push(o.getRoutePath(u.redirectTo));return}a==null||a(u)}}}function v({onSuccess:e,onError:a}){const o=d.useManage(),s=g.useRouter();return{mutate:async n=>{var t;const u=await((t=o.config.authProvider)==null?void 0:t.updatePassword(n,o));if(u!=null&&u.success){e==null||e(u),u.redirectTo&&s.push(o.getRoutePath(u.redirectTo));return}a==null||a(u)}}}function T(e){const{config:a,getRoutePath:o}=d.useManage(),s=g.useRouter();return{mutate:async n=>{var t;const u=await((t=a.authProvider)==null?void 0:t.onError(n));e==null||e(u),u!=null&&u.logout&&s.push(o(u.redirectTo||"/login"))}}}function y(e){return h.useAuthStore(e).getUser()}function L(e){return h.useAuthStore(e).isLogin()}exports.useCheck=w;exports.useError=T;exports.useForgotPassword=p;exports.useGetAuth=y;exports.useIsLogin=L;exports.useLogin=m;exports.useLogout=P;exports.useRegister=R;exports.useUpdatePassword=v;
@@ -1,114 +1,114 @@
1
- import { ref as h } from "vue";
1
+ import { ref as c } from "vue";
2
2
  import { useRouter as r } from "vue-router";
3
- import { useAuthStore as c } from "../stores/auth.js";
3
+ import { useAuthStore as f } from "../stores/auth.js";
4
4
  import { useManage as d } from "./manage.js";
5
- function R({ onSuccess: e, onError: a }) {
6
- const o = d(), u = c(), f = r(), n = h(!1);
5
+ function R({ onSuccess: e, onError: i }) {
6
+ const u = d(), n = f(), s = r(), g = c(!1);
7
7
  return {
8
- mutate: async (i) => {
9
- var s;
10
- n.value = !0;
11
- const t = await ((s = o.config.authProvider) == null ? void 0 : s.login(i, o));
12
- if (n.value = !1, t != null && t.success) {
13
- if (!(t != null && t.data))
8
+ mutate: async (t) => {
9
+ var h;
10
+ g.value = !0;
11
+ const o = await ((h = u.config.authProvider) == null ? void 0 : h.login(t, u));
12
+ if (g.value = !1, o != null && o.success) {
13
+ if (!(o != null && o.data))
14
14
  throw new Error("Login response data is undefined");
15
- e == null || e(t), u.login(t.data), f.push(o.getRoutePath(t.redirectTo || "/"));
15
+ e == null || e(o), n.login(o.data), s.push(u.getRoutePath(o.redirectTo || "/"));
16
16
  return;
17
17
  }
18
- a == null || a(t);
18
+ i == null || i(o);
19
19
  },
20
- isLoading: n
20
+ isLoading: g
21
21
  };
22
22
  }
23
- function v({ onSuccess: e, onError: a }) {
24
- const { config: o, getRoutePath: u } = d(), f = c(), n = r();
23
+ function v({ onSuccess: e, onError: i }) {
24
+ const u = d(), n = f(), s = r();
25
25
  return {
26
- mutate: async (i) => {
27
- var s;
28
- const t = await ((s = o.config.authProvider) == null ? void 0 : s.logout(i));
26
+ mutate: async (a) => {
27
+ var o;
28
+ const t = await ((o = u.config.authProvider) == null ? void 0 : o.logout(a, u));
29
29
  if (t != null && t.success) {
30
- e == null || e(t), f.logout(), n.push(u(t.redirectTo || "/login"));
30
+ e == null || e(t), n.logout(), s.push(u.getRoutePath(t.redirectTo || "/login"));
31
31
  return;
32
32
  }
33
- a == null || a(t);
33
+ i == null || i(t);
34
34
  }
35
35
  };
36
36
  }
37
- function T({ onSuccess: e, onError: a }) {
38
- const { config: o, getRoutePath: u } = d(), f = c(), n = r();
37
+ function T({ onSuccess: e, onError: i }) {
38
+ const u = d(), n = f(), s = r();
39
39
  return {
40
- mutate: async (i) => {
41
- var s;
42
- const t = await ((s = o.config.authProvider) == null ? void 0 : s.check(i));
40
+ mutate: async (a) => {
41
+ var o;
42
+ const t = await ((o = u.config.authProvider) == null ? void 0 : o.check(a, u));
43
43
  if (t != null && t.success) {
44
44
  if (e == null || e(t), !(t != null && t.data))
45
45
  throw new Error("Check response data is undefined");
46
- f.update(t.data);
46
+ n.update(t.data);
47
47
  return;
48
48
  }
49
- a == null || a(t), t != null && t.logout && n.push(u(t.redirectTo || "/login"));
49
+ i == null || i(t), t != null && t.logout && s.push(u.getRoutePath(t.redirectTo || "/login"));
50
50
  }
51
51
  };
52
52
  }
53
- function y({ onSuccess: e, onError: a }) {
54
- const { config: o, getRoutePath: u } = d(), f = c(), n = r();
53
+ function y({ onSuccess: e, onError: i }) {
54
+ const u = d(), n = f(), s = r();
55
55
  return {
56
- mutate: async (i) => {
57
- var s;
58
- const t = await ((s = o.config.authProvider) == null ? void 0 : s.register(i));
56
+ mutate: async (a) => {
57
+ var o;
58
+ const t = await ((o = u.config.authProvider) == null ? void 0 : o.register(a, u));
59
59
  if (t != null && t.success) {
60
60
  if (e == null || e(t), !(t != null && t.data))
61
61
  throw new Error("Register response data is undefined");
62
- f.login(t.data), n.push(u(t.redirectTo || ""));
62
+ n.login(t.data), s.push(u.getRoutePath(t.redirectTo || ""));
63
63
  return;
64
64
  }
65
- a == null || a(t);
65
+ i == null || i(t);
66
66
  }
67
67
  };
68
68
  }
69
- function L({ onSuccess: e, onError: a }) {
70
- const { config: o, getRoutePath: u } = d(), f = r();
69
+ function L({ onSuccess: e, onError: i }) {
70
+ const u = d(), n = r();
71
71
  return {
72
72
  mutate: async (g) => {
73
73
  var t;
74
- const i = await ((t = o.config.authProvider) == null ? void 0 : t.forgotPassword(g));
75
- if (i != null && i.success) {
76
- e == null || e(i), i.redirectTo && f.push(u(i.redirectTo));
74
+ const a = await ((t = u.config.authProvider) == null ? void 0 : t.forgotPassword(g, u));
75
+ if (a != null && a.success) {
76
+ e == null || e(a), a.redirectTo && n.push(u.getRoutePath(a.redirectTo));
77
77
  return;
78
78
  }
79
- a == null || a(i);
79
+ i == null || i(a);
80
80
  }
81
81
  };
82
82
  }
83
- function A({ onSuccess: e, onError: a }) {
84
- const { config: o, getRoutePath: u } = d(), f = r();
83
+ function A({ onSuccess: e, onError: i }) {
84
+ const u = d(), n = r();
85
85
  return {
86
86
  mutate: async (g) => {
87
87
  var t;
88
- const i = await ((t = o.config.authProvider) == null ? void 0 : t.updatePassword(g));
89
- if (i != null && i.success) {
90
- e == null || e(i), i.redirectTo && f.push(u(i.redirectTo));
88
+ const a = await ((t = u.config.authProvider) == null ? void 0 : t.updatePassword(g, u));
89
+ if (a != null && a.success) {
90
+ e == null || e(a), a.redirectTo && n.push(u.getRoutePath(a.redirectTo));
91
91
  return;
92
92
  }
93
- a == null || a(i);
93
+ i == null || i(a);
94
94
  }
95
95
  };
96
96
  }
97
97
  function U(e) {
98
- const { config: a, getRoutePath: o } = d(), u = r();
98
+ const { config: i, getRoutePath: u } = d(), n = r();
99
99
  return {
100
- mutate: async (n) => {
101
- var i;
102
- const g = await ((i = a.config.authProvider) == null ? void 0 : i.onError(n));
103
- e == null || e(g), g != null && g.logout && u.push(o(g.redirectTo || "/login"));
100
+ mutate: async (g) => {
101
+ var t;
102
+ const a = await ((t = i.authProvider) == null ? void 0 : t.onError(g));
103
+ e == null || e(a), a != null && a.logout && n.push(u(a.redirectTo || "/login"));
104
104
  }
105
105
  };
106
106
  }
107
107
  function x(e) {
108
- return c(e).getUser();
108
+ return f(e).getUser();
109
109
  }
110
110
  function F(e) {
111
- return c(e).isLogin();
111
+ return f(e).isLogin();
112
112
  }
113
113
  export {
114
114
  T as useCheck,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@duxweb/dvha-core",
3
3
  "type": "module",
4
- "version": "0.1.0",
4
+ "version": "0.1.1",
5
5
  "author": "DuxWeb",
6
6
  "license": "LGPL-3.0",
7
7
  "repository": {