@movk/nuxt 1.5.0 → 1.5.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.
- package/dist/module.json +2 -2
- package/dist/module.mjs +1 -1
- package/dist/runtime/domains/api/auth.js +9 -3
- package/dist/runtime/domains/api/endpoint-config.d.ts +1 -1
- package/dist/runtime/domains/api/endpoint-config.js +5 -1
- package/dist/runtime/domains/auto-form/controls.d.ts +6 -6
- package/dist/runtime/types/api/config.d.ts +12 -1
- package/dist/runtime/types/api/module.d.ts +1 -1
- package/package.json +18 -18
package/dist/module.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@movk/nuxt",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.1",
|
|
4
4
|
"configKey": "movk",
|
|
5
5
|
"compatibility": {
|
|
6
6
|
"nuxt": ">=4.4.2"
|
|
7
7
|
},
|
|
8
8
|
"builder": {
|
|
9
|
-
"@nuxt/module-builder": "1.0.
|
|
9
|
+
"@nuxt/module-builder": "1.0.3",
|
|
10
10
|
"unbuild": "3.6.1"
|
|
11
11
|
}
|
|
12
12
|
}
|
package/dist/module.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { getPath } from "@movk/core";
|
|
2
|
-
import { useNuxtApp, useUserSession } from "#imports";
|
|
2
|
+
import { useNuxtApp, useRuntimeConfig, useUserSession } from "#imports";
|
|
3
3
|
function getUserSession() {
|
|
4
4
|
try {
|
|
5
5
|
const nuxtApp = useNuxtApp();
|
|
@@ -14,6 +14,13 @@ function getTokenFromSession(tokenPath) {
|
|
|
14
14
|
const sessionData = userSession.session.value;
|
|
15
15
|
return getPath(sessionData, tokenPath) || null;
|
|
16
16
|
}
|
|
17
|
+
function getTokenFromPublicRuntimeConfig(tokenPath) {
|
|
18
|
+
try {
|
|
19
|
+
return getPath(useRuntimeConfig().public, tokenPath) || null;
|
|
20
|
+
} catch {
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
17
24
|
function buildAuthHeaderValue(token, config) {
|
|
18
25
|
const tokenType = config.tokenType === "Custom" ? config.customTokenType || "" : config.tokenType || "Bearer";
|
|
19
26
|
return tokenType ? `${tokenType} ${token}` : token;
|
|
@@ -21,8 +28,7 @@ function buildAuthHeaderValue(token, config) {
|
|
|
21
28
|
export function getAuthHeaders(auth) {
|
|
22
29
|
const headers = {};
|
|
23
30
|
if (!auth.enabled) return headers;
|
|
24
|
-
const
|
|
25
|
-
const token = getTokenFromSession(tokenPath);
|
|
31
|
+
const token = auth.tokenSource === "public-runtime-config" ? getTokenFromPublicRuntimeConfig(auth.tokenPath || "apiToken") : getTokenFromSession(auth.sessionTokenPath || "token");
|
|
26
32
|
if (token) {
|
|
27
33
|
const headerName = auth.headerName || "Authorization";
|
|
28
34
|
headers[headerName] = buildAuthHeaderValue(token, auth);
|
|
@@ -5,7 +5,7 @@ import type { EndpointPrivateConfig, ResolvedEndpointConfig } from '../../types/
|
|
|
5
5
|
*
|
|
6
6
|
* @param publicConfig 模块公共配置
|
|
7
7
|
* @param endpoint 端点名称;未指定时使用 defaultEndpoint
|
|
8
|
-
* @param privateEndpoints
|
|
8
|
+
* @param privateEndpoints 服务端私有端点配置(含机密 headers),仅在服务端可用;与端点 publicHeaders 合并后生效
|
|
9
9
|
* @description 端点不存在时降级到 defaultEndpoint,并打印警告
|
|
10
10
|
*/
|
|
11
11
|
export declare function resolveEndpointConfig(publicConfig: MovkApiPublicConfig, endpoint?: string, privateEndpoints?: Record<string, EndpointPrivateConfig>): ResolvedEndpointConfig;
|
|
@@ -6,10 +6,14 @@ export function resolveEndpointConfig(publicConfig, endpoint, privateEndpoints)
|
|
|
6
6
|
console.warn(`[@movk/nuxt] Endpoint "${endpointName}" not found, using default`);
|
|
7
7
|
return resolveEndpointConfig(publicConfig, publicConfig.defaultEndpoint || "default", privateEndpoints);
|
|
8
8
|
}
|
|
9
|
+
const mergedHeaders = defu(
|
|
10
|
+
privateEndpoints?.[endpointName]?.headers,
|
|
11
|
+
endpointConfig.publicHeaders
|
|
12
|
+
);
|
|
9
13
|
return {
|
|
10
14
|
...endpointConfig,
|
|
11
15
|
baseURL: endpointConfig.baseURL || "",
|
|
12
|
-
headers:
|
|
16
|
+
headers: Object.keys(mergedHeaders).length > 0 ? mergedHeaders : void 0,
|
|
13
17
|
auth: defu(endpointConfig.auth, publicConfig.auth),
|
|
14
18
|
toast: defu(endpointConfig.toast, publicConfig.toast),
|
|
15
19
|
response: defu(endpointConfig.response, publicConfig.response)
|
|
@@ -474,8 +474,8 @@ declare const DEFAULT_CONTROL_COMPONENTS: {
|
|
|
474
474
|
};
|
|
475
475
|
readonly slideVerify: {
|
|
476
476
|
new (...args: any[]): import("vue").CreateComponentPublicInstanceWithMixins<Readonly<import("../../types").SlideVerifyProps & {
|
|
477
|
-
size?: import("@nuxt/ui").ComponentConfig<typeof UInput, import("
|
|
478
|
-
ui?: import("@nuxt/ui").ComponentConfig<typeof UInput, import("
|
|
477
|
+
size?: import("@nuxt/ui").ComponentConfig<typeof UInput, import("nuxt/schema").AppConfig, "slideVerify">["variants"]["size"];
|
|
478
|
+
ui?: import("@nuxt/ui").ComponentConfig<typeof UInput, import("nuxt/schema").AppConfig, "slideVerify">["slots"];
|
|
479
479
|
} & {
|
|
480
480
|
modelValue?: boolean;
|
|
481
481
|
}> & Readonly<{
|
|
@@ -504,8 +504,8 @@ declare const DEFAULT_CONTROL_COMPONENTS: {
|
|
|
504
504
|
M: {};
|
|
505
505
|
Defaults: {};
|
|
506
506
|
}, Readonly<import("../../types").SlideVerifyProps & {
|
|
507
|
-
size?: import("@nuxt/ui").ComponentConfig<typeof UInput, import("
|
|
508
|
-
ui?: import("@nuxt/ui").ComponentConfig<typeof UInput, import("
|
|
507
|
+
size?: import("@nuxt/ui").ComponentConfig<typeof UInput, import("nuxt/schema").AppConfig, "slideVerify">["variants"]["size"];
|
|
508
|
+
ui?: import("@nuxt/ui").ComponentConfig<typeof UInput, import("nuxt/schema").AppConfig, "slideVerify">["slots"];
|
|
509
509
|
} & {
|
|
510
510
|
modelValue?: boolean;
|
|
511
511
|
}> & Readonly<{
|
|
@@ -526,8 +526,8 @@ declare const DEFAULT_CONTROL_COMPONENTS: {
|
|
|
526
526
|
__isTeleport?: never;
|
|
527
527
|
__isSuspense?: never;
|
|
528
528
|
} & import("vue").ComponentOptionsBase<Readonly<import("../../types").SlideVerifyProps & {
|
|
529
|
-
size?: import("@nuxt/ui").ComponentConfig<typeof UInput, import("
|
|
530
|
-
ui?: import("@nuxt/ui").ComponentConfig<typeof UInput, import("
|
|
529
|
+
size?: import("@nuxt/ui").ComponentConfig<typeof UInput, import("nuxt/schema").AppConfig, "slideVerify">["variants"]["size"];
|
|
530
|
+
ui?: import("@nuxt/ui").ComponentConfig<typeof UInput, import("nuxt/schema").AppConfig, "slideVerify">["slots"];
|
|
531
531
|
} & {
|
|
532
532
|
modelValue?: boolean;
|
|
533
533
|
}> & Readonly<{
|
|
@@ -40,13 +40,19 @@ export interface ApiAuthConfig {
|
|
|
40
40
|
* 令牌来源类型
|
|
41
41
|
* @defaultValue 'session'
|
|
42
42
|
*/
|
|
43
|
-
tokenSource?: Suggest<'session'>;
|
|
43
|
+
tokenSource?: Suggest<'session' | 'public-runtime-config'>;
|
|
44
44
|
/**
|
|
45
45
|
* 令牌在会话对象中的路径(支持点号分隔的嵌套路径)
|
|
46
46
|
* @defaultValue 'token'
|
|
47
47
|
* @example 'token' | 'user.accessToken' | 'auth.credentials.token'
|
|
48
48
|
*/
|
|
49
49
|
sessionTokenPath?: string;
|
|
50
|
+
/**
|
|
51
|
+
* 令牌在 runtimeConfig.public 中的路径(支持点号分隔的嵌套路径),仅当 tokenSource 为 'public-runtime-config' 时生效
|
|
52
|
+
* @defaultValue 'apiToken'
|
|
53
|
+
* @example 'llmApiKey' | 'api.token'
|
|
54
|
+
*/
|
|
55
|
+
tokenPath?: string;
|
|
50
56
|
/**
|
|
51
57
|
* 令牌类型前缀
|
|
52
58
|
* @defaultValue 'Bearer'
|
|
@@ -112,6 +118,11 @@ export interface ApiEndpointPublicConfig {
|
|
|
112
118
|
* 端点别名(用于标识)
|
|
113
119
|
*/
|
|
114
120
|
alias?: string;
|
|
121
|
+
/**
|
|
122
|
+
* 该端点的公开请求头,会进入 public runtimeConfig,服务端与客户端均注入
|
|
123
|
+
* @description 仅用于非机密固定头(如 API 版本、租户标识),机密请用 headers
|
|
124
|
+
*/
|
|
125
|
+
publicHeaders?: Record<string, string>;
|
|
115
126
|
/**
|
|
116
127
|
* 端点级别的认证配置(覆盖全局配置)
|
|
117
128
|
*/
|
|
@@ -89,6 +89,6 @@ export interface ResolvedEndpointConfig extends Omit<ApiEndpointPublicConfig, 'a
|
|
|
89
89
|
toast: ApiToastConfig;
|
|
90
90
|
/** 响应配置(已合并全局默认值,必然存在) */
|
|
91
91
|
response: ApiResponseConfig;
|
|
92
|
-
/**
|
|
92
|
+
/** 请求头(服务端私有 headers 与端点 publicHeaders 的合并结果,同名键私有优先) */
|
|
93
93
|
headers?: Record<string, string>;
|
|
94
94
|
}
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@movk/nuxt",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.5.
|
|
5
|
-
"packageManager": "pnpm@11.
|
|
4
|
+
"version": "1.5.1",
|
|
5
|
+
"packageManager": "pnpm@11.17.0",
|
|
6
6
|
"description": "An engineering suite built on Nuxt UI: schema-driven AutoForm (Zod v4), a full-featured DataTable, standalone UI components and composables. Get the full capabilities — including API integration with auth & progress — in Nuxt 4, and use its UI, forms, tables and theming in plain Vue + Vite via the Vite plugin.",
|
|
7
7
|
"author": "YiXuan <mhaibaraai@gmail.com>",
|
|
8
8
|
"license": "MIT",
|
|
@@ -124,11 +124,11 @@
|
|
|
124
124
|
"test:vue": "vitest --project vue"
|
|
125
125
|
},
|
|
126
126
|
"dependencies": {
|
|
127
|
-
"@iconify-json/lucide": "^1.2.
|
|
127
|
+
"@iconify-json/lucide": "^1.2.120",
|
|
128
128
|
"@iconify-json/ph": "^1.2.2",
|
|
129
|
-
"@iconify-json/tabler": "^1.2.
|
|
129
|
+
"@iconify-json/tabler": "^1.2.37",
|
|
130
130
|
"@internationalized/date": "^3.12.2",
|
|
131
|
-
"@movk/core": "^1.
|
|
131
|
+
"@movk/core": "^1.4.1",
|
|
132
132
|
"@nuxt/image": "^2.0.0",
|
|
133
133
|
"@nuxt/ui": "^4.10.0",
|
|
134
134
|
"@tanstack/vue-table": "^8.21.3",
|
|
@@ -136,16 +136,16 @@
|
|
|
136
136
|
"@vueuse/nuxt": "^14.3.0",
|
|
137
137
|
"colortranslator": "^6.1.1",
|
|
138
138
|
"defu": "^6.1.7",
|
|
139
|
-
"magic-string": "^
|
|
139
|
+
"magic-string": "^1.1.0",
|
|
140
140
|
"maska": "^3.2.0",
|
|
141
141
|
"mlly": "^1.8.2",
|
|
142
142
|
"nuxt-auth-utils": "^0.5.29",
|
|
143
|
-
"nuxt-site-config": "^4.1.
|
|
143
|
+
"nuxt-site-config": "^4.1.2",
|
|
144
144
|
"pathe": "^2.0.3",
|
|
145
145
|
"reka-ui": "2.10.1",
|
|
146
146
|
"scule": "^1.3.0",
|
|
147
147
|
"tailwind-variants": "^3.2.2",
|
|
148
|
-
"tailwindcss": "^4.3.
|
|
148
|
+
"tailwindcss": "^4.3.3",
|
|
149
149
|
"tinyglobby": "^0.2.17",
|
|
150
150
|
"unifont": "^0.7.4",
|
|
151
151
|
"unplugin": "^3.3.0",
|
|
@@ -153,20 +153,20 @@
|
|
|
153
153
|
},
|
|
154
154
|
"devDependencies": {
|
|
155
155
|
"@nuxt/eslint-config": "^1.16.0",
|
|
156
|
-
"@nuxt/kit": "^4.
|
|
157
|
-
"@nuxt/module-builder": "^1.0.
|
|
158
|
-
"@nuxt/schema": "^4.
|
|
159
|
-
"@release-it/conventional-changelog": "^
|
|
160
|
-
"eslint": "^10.
|
|
161
|
-
"happy-dom": "^20.
|
|
162
|
-
"nuxt": "^4.
|
|
163
|
-
"release-it": "^
|
|
156
|
+
"@nuxt/kit": "^4.5.1",
|
|
157
|
+
"@nuxt/module-builder": "^1.0.3",
|
|
158
|
+
"@nuxt/schema": "^4.5.1",
|
|
159
|
+
"@release-it/conventional-changelog": "^12.0.0",
|
|
160
|
+
"eslint": "^10.8.0",
|
|
161
|
+
"happy-dom": "^20.11.1",
|
|
162
|
+
"nuxt": "^4.5.1",
|
|
163
|
+
"release-it": "^21.0.0",
|
|
164
164
|
"typescript": "^6.0.3",
|
|
165
165
|
"unbuild": "^3.6.1",
|
|
166
166
|
"unplugin-auto-import": "^21.0.0",
|
|
167
167
|
"unplugin-vue-components": "^32.1.0",
|
|
168
168
|
"vitest": "^4.1.10",
|
|
169
|
-
"vue": "^3.5.
|
|
170
|
-
"vue-tsc": "^3.3.
|
|
169
|
+
"vue": "^3.5.40",
|
|
170
|
+
"vue-tsc": "^3.3.8"
|
|
171
171
|
}
|
|
172
172
|
}
|