@hostlink/nuxt-light 1.76.0 → 1.77.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +21 -0
- package/dist/module.json +1 -1
- package/dist/runtime/components/L/AppMain.vue +2 -2
- package/dist/runtime/components/L/Login.vue +3 -3
- package/dist/runtime/formkit/Form.vue +4 -2
- package/dist/runtime/formkit/index.js +2 -1
- package/dist/runtime/plugin.js +6 -1
- package/dist/runtime/utils/formClient.d.ts +4 -0
- package/dist/runtime/utils/formClient.js +3 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -74,6 +74,11 @@ export default defineNuxtConfig({
|
|
|
74
74
|
},
|
|
75
75
|
business: {
|
|
76
76
|
baseURL: 'https://business.example.com/graphql',
|
|
77
|
+
audience: 'business-api',
|
|
78
|
+
},
|
|
79
|
+
infra: {
|
|
80
|
+
baseURL: 'https://infra.example.com/graphql',
|
|
81
|
+
audience: 'infra-api',
|
|
77
82
|
},
|
|
78
83
|
},
|
|
79
84
|
},
|
|
@@ -94,6 +99,22 @@ clients: {
|
|
|
94
99
|
}
|
|
95
100
|
```
|
|
96
101
|
|
|
102
|
+
Clients with an `audience` obtain a short-lived audience token lazily from the
|
|
103
|
+
default `auth` client. The token is cached by that client, refreshed shortly
|
|
104
|
+
before expiry, and sent as a Bearer token automatically:
|
|
105
|
+
|
|
106
|
+
```http
|
|
107
|
+
Authorization: Bearer <audience-access-token>
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
Components and composables do not need to fetch or attach tokens themselves.
|
|
111
|
+
For example, the first request made by this table automatically requests a
|
|
112
|
+
`business-api` token from Auth:
|
|
113
|
+
|
|
114
|
+
```vue
|
|
115
|
+
<L-Table client="business" model-name="Order" />
|
|
116
|
+
```
|
|
117
|
+
|
|
97
118
|
### Backwards-compatible single endpoint
|
|
98
119
|
|
|
99
120
|
The existing `public.apiBase` setting is still supported. When no named
|
package/dist/module.json
CHANGED
|
@@ -5,7 +5,7 @@ import { useQuasar, setCssVar, getCssVar } from "quasar";
|
|
|
5
5
|
import { useI18n } from "vue-i18n";
|
|
6
6
|
import { ref, computed, reactive, provide, watch, toRaw, onMounted } from "vue";
|
|
7
7
|
import { useRuntimeConfig } from "nuxt/app";
|
|
8
|
-
import
|
|
8
|
+
import useLightClient from "../../composables/useLightClient";
|
|
9
9
|
import { filterMenuItems } from "../../utils/filterMenuItems";
|
|
10
10
|
const emits = defineEmits(["logout"]);
|
|
11
11
|
defineProps({
|
|
@@ -249,7 +249,7 @@ if (route.fullPath == "/" && my.default_page) {
|
|
|
249
249
|
router.push(my.default_page);
|
|
250
250
|
}
|
|
251
251
|
const onLogout = async () => {
|
|
252
|
-
await logout();
|
|
252
|
+
await useLightClient().auth.logout();
|
|
253
253
|
emits("logout");
|
|
254
254
|
};
|
|
255
255
|
</script>
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { ref, reactive, onMounted, resolveComponent } from "vue";
|
|
3
3
|
import { useQuasar } from "quasar";
|
|
4
4
|
import { useHead } from "#imports";
|
|
5
|
-
import { getApiClient
|
|
5
|
+
import { getApiClient } from "@hostlink/light";
|
|
6
6
|
const api = getApiClient();
|
|
7
7
|
import { useI18n } from "vue-i18n";
|
|
8
8
|
const { t } = useI18n();
|
|
@@ -42,7 +42,7 @@ const passwordExpiredProcess = (username, password) => {
|
|
|
42
42
|
persistent: true
|
|
43
43
|
}).onOk(async (newPassword) => {
|
|
44
44
|
try {
|
|
45
|
-
await changeExpiredPassword(username, password, newPassword);
|
|
45
|
+
await api.auth.changeExpiredPassword(username, password, newPassword);
|
|
46
46
|
$q.notify({
|
|
47
47
|
message: t("Your password has been changed successfully, please login again"),
|
|
48
48
|
color: "positive",
|
|
@@ -81,7 +81,7 @@ const submit = async () => {
|
|
|
81
81
|
if (await form1.value.validate()) {
|
|
82
82
|
try {
|
|
83
83
|
loading.value = true;
|
|
84
|
-
await login(data.username, data.password, data.code);
|
|
84
|
+
await api.auth.login(data.username, data.password, data.code);
|
|
85
85
|
emits("login");
|
|
86
86
|
} catch (e) {
|
|
87
87
|
data.code = "";
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { useRouter, useRoute } from "vue-router";
|
|
3
3
|
import { useQuasar } from "quasar";
|
|
4
4
|
import { computed, model } from "#imports";
|
|
5
|
+
import { getFormClient } from "../utils/formClient";
|
|
5
6
|
const route = useRoute();
|
|
6
7
|
const router = useRouter();
|
|
7
8
|
const $q = useQuasar();
|
|
@@ -24,6 +25,7 @@ if (props.context.attrs.onSubmitted) {
|
|
|
24
25
|
}
|
|
25
26
|
const modelName = props.context.modelName || (typeof route.name === "string" ? route.name.split("-")[0] : void 0);
|
|
26
27
|
const id = props.context.modelId || route.params[typeof route.name === "string" ? route.name.split("-")[1] : "id"];
|
|
28
|
+
const client = getFormClient(props.context);
|
|
27
29
|
if (!props.context.onSubmit) {
|
|
28
30
|
props.context.node.props.onSubmit = async function() {
|
|
29
31
|
const removeUndefined = (obj) => {
|
|
@@ -51,7 +53,7 @@ if (!props.context.onSubmit) {
|
|
|
51
53
|
const v = removeUndefined(props.context.value);
|
|
52
54
|
try {
|
|
53
55
|
if (id) {
|
|
54
|
-
if (await model(modelName).update(Number(id), v)) {
|
|
56
|
+
if (await model(modelName, client).update(Number(id), v)) {
|
|
55
57
|
$q.notify({
|
|
56
58
|
message: "Updated successfully",
|
|
57
59
|
color: "positive",
|
|
@@ -62,7 +64,7 @@ if (!props.context.onSubmit) {
|
|
|
62
64
|
}
|
|
63
65
|
}
|
|
64
66
|
} else {
|
|
65
|
-
if (await model(modelName).add(v)) {
|
|
67
|
+
if (await model(modelName, client).add(v)) {
|
|
66
68
|
$q.notify({
|
|
67
69
|
message: "Added successfully",
|
|
68
70
|
color: "positive",
|
package/dist/runtime/plugin.js
CHANGED
|
@@ -27,7 +27,12 @@ export default defineNuxtPlugin((nuxtApp) => {
|
|
|
27
27
|
if (!configuredClients.auth) {
|
|
28
28
|
registerLightClient("auth", createClient(getApiBase()));
|
|
29
29
|
}
|
|
30
|
-
|
|
30
|
+
const authClient = useLightClient();
|
|
31
|
+
setApiClient(authClient);
|
|
32
|
+
for (const [name, config] of Object.entries(configuredClients)) {
|
|
33
|
+
if (name === "auth" || typeof config === "string" || !config.audience) continue;
|
|
34
|
+
useLightClient(name).useAudience(authClient, config.audience);
|
|
35
|
+
}
|
|
31
36
|
defineModel("Permission", {}).setDataPath("app.listPermission");
|
|
32
37
|
defineModel("SystemValue", {}).setDataPath("app.listSystemValue");
|
|
33
38
|
defineModel("Config", {}).setDataPath("app.listConfig");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hostlink/nuxt-light",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.77.2",
|
|
4
4
|
"description": "HostLink Nuxt Light Framework",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"@formkit/inputs": "^2.1.2",
|
|
39
39
|
"@formkit/validation": "^2.1.2",
|
|
40
40
|
"@formkit/vue": "^2.1.2",
|
|
41
|
-
"@hostlink/light": "^3.
|
|
41
|
+
"@hostlink/light": "^3.4.0",
|
|
42
42
|
"@nuxt/module-builder": "^1.0.1",
|
|
43
43
|
"@quasar/extras": "^2.0.2",
|
|
44
44
|
"@quasar/quasar-ui-qmarkdown": "^3.0.1",
|