@movk/nuxt 0.1.1 → 1.0.0
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 +84 -9
- package/dist/module.d.mts +11 -0
- package/dist/module.json +1 -1
- package/dist/module.mjs +29 -3
- package/dist/runtime/components/AutoForm.d.vue.ts +12 -6
- package/dist/runtime/components/AutoForm.vue +3 -1
- package/dist/runtime/components/AutoForm.vue.d.ts +12 -6
- package/dist/runtime/components/ColorChooser.d.vue.ts +11 -5
- package/dist/runtime/components/ColorChooser.vue.d.ts +11 -5
- package/dist/runtime/components/DatePicker.d.vue.ts +14 -5
- package/dist/runtime/components/DatePicker.vue.d.ts +14 -5
- package/dist/runtime/components/StarRating.d.vue.ts +7 -7
- package/dist/runtime/components/StarRating.vue.d.ts +7 -7
- package/dist/runtime/components/auto-form-renderer/AutoFormRendererArray.d.vue.ts +6 -4
- package/dist/runtime/components/auto-form-renderer/AutoFormRendererArray.vue.d.ts +6 -4
- package/dist/runtime/components/auto-form-renderer/AutoFormRendererField.d.vue.ts +6 -4
- package/dist/runtime/components/auto-form-renderer/AutoFormRendererField.vue.d.ts +6 -4
- package/dist/runtime/components/auto-form-renderer/AutoFormRendererLayout.d.vue.ts +6 -4
- package/dist/runtime/components/auto-form-renderer/AutoFormRendererLayout.vue.d.ts +6 -4
- package/dist/runtime/components/auto-form-renderer/AutoFormRendererNested.d.vue.ts +6 -4
- package/dist/runtime/components/auto-form-renderer/AutoFormRendererNested.vue.d.ts +6 -4
- package/dist/runtime/components/input/WithCharacterLimit.d.vue.ts +11 -5
- package/dist/runtime/components/input/WithCharacterLimit.vue.d.ts +11 -5
- package/dist/runtime/components/input/WithClear.d.vue.ts +12 -5
- package/dist/runtime/components/input/WithClear.vue.d.ts +12 -5
- package/dist/runtime/components/input/WithCopy.d.vue.ts +12 -5
- package/dist/runtime/components/input/WithCopy.vue.d.ts +12 -5
- package/dist/runtime/components/input/WithPasswordToggle.d.vue.ts +11 -5
- package/dist/runtime/components/input/WithPasswordToggle.vue.d.ts +11 -5
- package/dist/runtime/composables/useApiAuth.d.ts +47 -0
- package/dist/runtime/composables/useApiAuth.js +66 -0
- package/dist/runtime/composables/useApiFetch.d.ts +42 -0
- package/dist/runtime/composables/useApiFetch.js +43 -0
- package/dist/runtime/composables/useAutoForm.d.ts +874 -54
- package/dist/runtime/composables/useClientApiFetch.d.ts +24 -0
- package/dist/runtime/composables/useClientApiFetch.js +8 -0
- package/dist/runtime/composables/useDateFormatter.d.ts +21 -7
- package/dist/runtime/composables/useDateFormatter.js +92 -57
- package/dist/runtime/composables/useDownloadWithProgress.d.ts +48 -0
- package/dist/runtime/composables/useDownloadWithProgress.js +85 -0
- package/dist/runtime/composables/useUploadWithProgress.d.ts +52 -0
- package/dist/runtime/composables/useUploadWithProgress.js +117 -0
- package/dist/runtime/plugins/api.factory.d.ts +2 -0
- package/dist/runtime/plugins/api.factory.js +188 -0
- package/dist/runtime/schemas/api.d.ts +354 -0
- package/dist/runtime/schemas/api.js +212 -0
- package/dist/runtime/server/api/_movk/session.post.d.ts +10 -0
- package/dist/runtime/server/api/_movk/session.post.js +18 -0
- package/dist/runtime/types/api.d.ts +218 -0
- package/dist/runtime/types/api.js +8 -0
- package/dist/runtime/types/auth.d.ts +34 -0
- package/dist/runtime/types/auto-form-renderer.d.ts +14 -22
- package/dist/runtime/types/auto-form-renderer.js +0 -0
- package/dist/runtime/types/components.d.ts +29 -41
- package/dist/runtime/types/components.js +0 -0
- package/dist/runtime/types/index.d.ts +1 -0
- package/dist/runtime/types/index.js +3 -2
- package/dist/runtime/utils/api-utils.d.ts +64 -0
- package/dist/runtime/utils/api-utils.js +127 -0
- package/package.json +32 -25
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
import { getPath, triggerDownload, extractFilename } from "@movk/core";
|
|
2
|
+
import {
|
|
3
|
+
showToast,
|
|
4
|
+
isBusinessSuccess,
|
|
5
|
+
extractMessage,
|
|
6
|
+
extractToastMessage
|
|
7
|
+
} from "../utils/api-utils.js";
|
|
8
|
+
import { defineNuxtPlugin, useRuntimeConfig, navigateTo, useNuxtApp, useUserSession } from "#imports";
|
|
9
|
+
import defu from "defu";
|
|
10
|
+
function getUserSession() {
|
|
11
|
+
try {
|
|
12
|
+
const nuxtApp = useNuxtApp();
|
|
13
|
+
return nuxtApp.runWithContext(() => useUserSession());
|
|
14
|
+
} catch {
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
function getTokenFromSession(tokenPath) {
|
|
19
|
+
const userSession = getUserSession();
|
|
20
|
+
if (!userSession?.session?.value) return null;
|
|
21
|
+
const sessionData = userSession.session.value;
|
|
22
|
+
return getPath(sessionData, tokenPath) || null;
|
|
23
|
+
}
|
|
24
|
+
function buildAuthHeader(token, config) {
|
|
25
|
+
const tokenType = config.tokenType === "Custom" ? config.customTokenType || "" : config.tokenType || "Bearer";
|
|
26
|
+
return tokenType ? `${tokenType} ${token}` : token;
|
|
27
|
+
}
|
|
28
|
+
async function handleUnauthorized(config) {
|
|
29
|
+
const userSession = getUserSession();
|
|
30
|
+
if (config.clearSessionOnUnauthorized && userSession?.clear) {
|
|
31
|
+
await userSession.clear();
|
|
32
|
+
}
|
|
33
|
+
if (config.redirectOnUnauthorized) {
|
|
34
|
+
const loginPath = config.loginPath || "/login";
|
|
35
|
+
const nuxtApp = useNuxtApp();
|
|
36
|
+
await nuxtApp.runWithContext(() => navigateTo(loginPath));
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
function getApiFetchContext(context) {
|
|
40
|
+
return context.options.context || {};
|
|
41
|
+
}
|
|
42
|
+
function createBuiltinHooks(resolvedConfig, moduleConfig) {
|
|
43
|
+
const { auth: authConfig, toast: toastConfig, success: successConfig } = resolvedConfig;
|
|
44
|
+
return {
|
|
45
|
+
onRequest(context) {
|
|
46
|
+
if (authConfig.enabled) {
|
|
47
|
+
const tokenPath = authConfig.sessionTokenPath || "token";
|
|
48
|
+
const token = getTokenFromSession(tokenPath);
|
|
49
|
+
if (token) {
|
|
50
|
+
const headerName = authConfig.headerName || "Authorization";
|
|
51
|
+
const headerValue = buildAuthHeader(token, authConfig);
|
|
52
|
+
context.options.headers = context.options.headers || new Headers();
|
|
53
|
+
if (context.options.headers instanceof Headers) {
|
|
54
|
+
context.options.headers.set(headerName, headerValue);
|
|
55
|
+
} else {
|
|
56
|
+
context.options.headers[headerName] = headerValue;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
if (moduleConfig.debug) {
|
|
61
|
+
console.log(`[Movk API] Request: ${context.options.method || "GET"} ${resolvedConfig.baseURL}${context.request}`);
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
async onRequestError({ error }) {
|
|
65
|
+
if (moduleConfig.debug) {
|
|
66
|
+
console.error("[Movk API] Request Error:", error);
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
async onResponse(context) {
|
|
70
|
+
const response = context.response;
|
|
71
|
+
const data = response._data;
|
|
72
|
+
if (moduleConfig.debug) {
|
|
73
|
+
console.log("[Movk API] Response:", data);
|
|
74
|
+
}
|
|
75
|
+
if (!import.meta.client) return;
|
|
76
|
+
const { toast, skipBusinessCheck } = getApiFetchContext(context);
|
|
77
|
+
const isSuccess = skipBusinessCheck || isBusinessSuccess(data, successConfig);
|
|
78
|
+
const message = extractMessage(data, successConfig);
|
|
79
|
+
if (isSuccess) {
|
|
80
|
+
const successMessage = toast !== false ? toast?.successMessage || message : void 0;
|
|
81
|
+
showToast("success", successMessage, toast, toastConfig);
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
async onResponseError(context) {
|
|
85
|
+
const { response } = context;
|
|
86
|
+
if (response.status === 401) {
|
|
87
|
+
await handleUnauthorized(authConfig);
|
|
88
|
+
}
|
|
89
|
+
if (moduleConfig.debug) {
|
|
90
|
+
console.error("[Movk API] Error:", response.status, response._data);
|
|
91
|
+
}
|
|
92
|
+
if (!import.meta.client) return;
|
|
93
|
+
const { toast } = getApiFetchContext(context);
|
|
94
|
+
const data = response._data;
|
|
95
|
+
const message = data ? extractMessage(data, successConfig) : void 0;
|
|
96
|
+
const errorMessage = toast !== false ? toast?.errorMessage || message || `\u8BF7\u6C42\u5931\u8D25 (${response.status})` : void 0;
|
|
97
|
+
showToast("error", errorMessage, toast, toastConfig);
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
function createApiClient(resolvedConfig, moduleConfig, getOrCreateEndpoint) {
|
|
102
|
+
const builtinHooks = createBuiltinHooks(resolvedConfig, moduleConfig);
|
|
103
|
+
resolvedConfig.builtinHooks = builtinHooks;
|
|
104
|
+
const $fetchInstance = $fetch.create({
|
|
105
|
+
baseURL: resolvedConfig.baseURL,
|
|
106
|
+
headers: resolvedConfig.headers,
|
|
107
|
+
onRequest: builtinHooks.onRequest,
|
|
108
|
+
onRequestError: builtinHooks.onRequestError,
|
|
109
|
+
onResponse: builtinHooks.onResponse,
|
|
110
|
+
onResponseError: builtinHooks.onResponseError
|
|
111
|
+
});
|
|
112
|
+
const download = async (url, filename, options = {}) => {
|
|
113
|
+
const { toast, ...fetchOptions } = options;
|
|
114
|
+
const response = await $fetchInstance.raw(url, {
|
|
115
|
+
...fetchOptions,
|
|
116
|
+
method: "GET",
|
|
117
|
+
responseType: "blob",
|
|
118
|
+
context: { toast }
|
|
119
|
+
});
|
|
120
|
+
if (!response._data) {
|
|
121
|
+
throw new Error("\u4E0B\u8F7D\u5931\u8D25: \u672A\u63A5\u6536\u5230\u6570\u636E");
|
|
122
|
+
}
|
|
123
|
+
const finalFilename = filename || extractFilename(response.headers, url.split("/").pop() || "download");
|
|
124
|
+
triggerDownload(response._data, finalFilename);
|
|
125
|
+
if (import.meta.client && toast !== false) {
|
|
126
|
+
const message = extractToastMessage(toast, "success", `\u4E0B\u8F7D\u6210\u529F: ${finalFilename}`);
|
|
127
|
+
showToast("success", message, toast, resolvedConfig.toast);
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
const upload = async (url, file, options = {}) => {
|
|
131
|
+
const { toast, fieldName = "file", ...fetchOptions } = options;
|
|
132
|
+
const formData = file instanceof FormData ? file : (() => {
|
|
133
|
+
const fd = new FormData();
|
|
134
|
+
const files = Array.isArray(file) ? file : [file];
|
|
135
|
+
files.forEach((f) => fd.append(fieldName, f));
|
|
136
|
+
return fd;
|
|
137
|
+
})();
|
|
138
|
+
return $fetchInstance(url, {
|
|
139
|
+
...fetchOptions,
|
|
140
|
+
method: "POST",
|
|
141
|
+
body: formData,
|
|
142
|
+
context: { toast }
|
|
143
|
+
});
|
|
144
|
+
};
|
|
145
|
+
return {
|
|
146
|
+
$fetch: $fetchInstance,
|
|
147
|
+
use: (endpoint) => getOrCreateEndpoint(endpoint),
|
|
148
|
+
download,
|
|
149
|
+
upload,
|
|
150
|
+
getConfig: () => resolvedConfig
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
export default defineNuxtPlugin(() => {
|
|
154
|
+
const moduleConfig = useRuntimeConfig().public.movkApi;
|
|
155
|
+
if (!moduleConfig.enabled) {
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
const endpointCache = /* @__PURE__ */ new Map();
|
|
159
|
+
const getOrCreateEndpoint = (endpointName) => {
|
|
160
|
+
if (endpointCache.has(endpointName)) {
|
|
161
|
+
return endpointCache.get(endpointName);
|
|
162
|
+
}
|
|
163
|
+
const endpoints = moduleConfig.endpoints || {};
|
|
164
|
+
const endpointConfig = endpoints[endpointName];
|
|
165
|
+
if (!endpointConfig) {
|
|
166
|
+
console.warn(`[Movk API] Endpoint "${endpointName}" not found, using default`);
|
|
167
|
+
return getOrCreateEndpoint(moduleConfig.defaultEndpoint || "default");
|
|
168
|
+
}
|
|
169
|
+
const resolvedConfig = {
|
|
170
|
+
...endpointConfig,
|
|
171
|
+
auth: defu(endpointConfig.auth, moduleConfig.auth),
|
|
172
|
+
toast: defu(endpointConfig.toast, moduleConfig.toast),
|
|
173
|
+
success: defu(endpointConfig.success, moduleConfig.success)
|
|
174
|
+
};
|
|
175
|
+
const client = createApiClient(
|
|
176
|
+
resolvedConfig,
|
|
177
|
+
moduleConfig,
|
|
178
|
+
getOrCreateEndpoint
|
|
179
|
+
);
|
|
180
|
+
endpointCache.set(endpointName, client);
|
|
181
|
+
return client;
|
|
182
|
+
};
|
|
183
|
+
const defaultEndpoint = moduleConfig.defaultEndpoint || "default";
|
|
184
|
+
const api = getOrCreateEndpoint(defaultEndpoint);
|
|
185
|
+
return {
|
|
186
|
+
provide: { api }
|
|
187
|
+
};
|
|
188
|
+
});
|
|
@@ -0,0 +1,354 @@
|
|
|
1
|
+
import { z } from 'zod/v4';
|
|
2
|
+
/**
|
|
3
|
+
* 成功响应判断配置 Schema
|
|
4
|
+
*/
|
|
5
|
+
export declare const apiSuccessConfigSchema: z.ZodObject<{
|
|
6
|
+
successCodes: z.ZodDefault<z.ZodArray<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>>>;
|
|
7
|
+
codeKey: z.ZodDefault<z.ZodString>;
|
|
8
|
+
messageKey: z.ZodDefault<z.ZodString>;
|
|
9
|
+
dataKey: z.ZodDefault<z.ZodString>;
|
|
10
|
+
}, z.core.$strip>;
|
|
11
|
+
/**
|
|
12
|
+
* Session 管理配置 Schema
|
|
13
|
+
* 用于登录流程中自动设置 nuxt-auth-utils session
|
|
14
|
+
*/
|
|
15
|
+
export declare const apiSessionConfigSchema: z.ZodObject<{
|
|
16
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
17
|
+
userInfoPath: z.ZodOptional<z.ZodString>;
|
|
18
|
+
tokenPath: z.ZodDefault<z.ZodString>;
|
|
19
|
+
userDataPath: z.ZodDefault<z.ZodString>;
|
|
20
|
+
sessionTokenPath: z.ZodDefault<z.ZodString>;
|
|
21
|
+
}, z.core.$strip>;
|
|
22
|
+
/**
|
|
23
|
+
* Auth 认证配置 Schema
|
|
24
|
+
* 使用 nuxt-auth-utils 进行认证管理
|
|
25
|
+
*/
|
|
26
|
+
export declare const apiAuthConfigSchema: z.ZodObject<{
|
|
27
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
28
|
+
tokenSource: z.ZodDefault<z.ZodEnum<{
|
|
29
|
+
custom: "custom";
|
|
30
|
+
session: "session";
|
|
31
|
+
}>>;
|
|
32
|
+
sessionTokenPath: z.ZodDefault<z.ZodString>;
|
|
33
|
+
tokenType: z.ZodDefault<z.ZodEnum<{
|
|
34
|
+
Bearer: "Bearer";
|
|
35
|
+
Basic: "Basic";
|
|
36
|
+
Custom: "Custom";
|
|
37
|
+
}>>;
|
|
38
|
+
customTokenType: z.ZodOptional<z.ZodString>;
|
|
39
|
+
headerName: z.ZodDefault<z.ZodString>;
|
|
40
|
+
redirectOnUnauthorized: z.ZodDefault<z.ZodBoolean>;
|
|
41
|
+
loginPath: z.ZodDefault<z.ZodString>;
|
|
42
|
+
clearSessionOnUnauthorized: z.ZodDefault<z.ZodBoolean>;
|
|
43
|
+
}, z.core.$strip>;
|
|
44
|
+
/**
|
|
45
|
+
* Toast 提示配置 Schema
|
|
46
|
+
* @see https://ui.nuxt.com/docs/composables/use-toast
|
|
47
|
+
*/
|
|
48
|
+
export declare const apiToastConfigSchema: z.ZodObject<{
|
|
49
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
50
|
+
success: z.ZodOptional<z.ZodObject<{
|
|
51
|
+
show: z.ZodDefault<z.ZodBoolean>;
|
|
52
|
+
color: z.ZodDefault<z.ZodString>;
|
|
53
|
+
icon: z.ZodOptional<z.ZodString>;
|
|
54
|
+
duration: z.ZodDefault<z.ZodNumber>;
|
|
55
|
+
}, z.core.$loose>>;
|
|
56
|
+
error: z.ZodOptional<z.ZodObject<{
|
|
57
|
+
show: z.ZodDefault<z.ZodBoolean>;
|
|
58
|
+
color: z.ZodDefault<z.ZodString>;
|
|
59
|
+
icon: z.ZodOptional<z.ZodString>;
|
|
60
|
+
duration: z.ZodDefault<z.ZodNumber>;
|
|
61
|
+
}, z.core.$loose>>;
|
|
62
|
+
}, z.core.$strip>;
|
|
63
|
+
/**
|
|
64
|
+
* 单个 API 端点配置 Schema
|
|
65
|
+
*/
|
|
66
|
+
export declare const apiEndpointConfigSchema: z.ZodObject<{
|
|
67
|
+
baseURL: z.ZodString;
|
|
68
|
+
alias: z.ZodOptional<z.ZodString>;
|
|
69
|
+
auth: z.ZodOptional<z.ZodObject<{
|
|
70
|
+
enabled: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
|
|
71
|
+
tokenSource: z.ZodOptional<z.ZodDefault<z.ZodEnum<{
|
|
72
|
+
custom: "custom";
|
|
73
|
+
session: "session";
|
|
74
|
+
}>>>;
|
|
75
|
+
sessionTokenPath: z.ZodOptional<z.ZodDefault<z.ZodString>>;
|
|
76
|
+
tokenType: z.ZodOptional<z.ZodDefault<z.ZodEnum<{
|
|
77
|
+
Bearer: "Bearer";
|
|
78
|
+
Basic: "Basic";
|
|
79
|
+
Custom: "Custom";
|
|
80
|
+
}>>>;
|
|
81
|
+
customTokenType: z.ZodOptional<z.ZodOptional<z.ZodString>>;
|
|
82
|
+
headerName: z.ZodOptional<z.ZodDefault<z.ZodString>>;
|
|
83
|
+
redirectOnUnauthorized: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
|
|
84
|
+
loginPath: z.ZodOptional<z.ZodDefault<z.ZodString>>;
|
|
85
|
+
clearSessionOnUnauthorized: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
|
|
86
|
+
}, z.core.$strip>>;
|
|
87
|
+
toast: z.ZodOptional<z.ZodObject<{
|
|
88
|
+
enabled: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
|
|
89
|
+
success: z.ZodOptional<z.ZodOptional<z.ZodObject<{
|
|
90
|
+
show: z.ZodDefault<z.ZodBoolean>;
|
|
91
|
+
color: z.ZodDefault<z.ZodString>;
|
|
92
|
+
icon: z.ZodOptional<z.ZodString>;
|
|
93
|
+
duration: z.ZodDefault<z.ZodNumber>;
|
|
94
|
+
}, z.core.$loose>>>;
|
|
95
|
+
error: z.ZodOptional<z.ZodOptional<z.ZodObject<{
|
|
96
|
+
show: z.ZodDefault<z.ZodBoolean>;
|
|
97
|
+
color: z.ZodDefault<z.ZodString>;
|
|
98
|
+
icon: z.ZodOptional<z.ZodString>;
|
|
99
|
+
duration: z.ZodDefault<z.ZodNumber>;
|
|
100
|
+
}, z.core.$loose>>>;
|
|
101
|
+
}, z.core.$strip>>;
|
|
102
|
+
success: z.ZodOptional<z.ZodObject<{
|
|
103
|
+
successCodes: z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>>>>;
|
|
104
|
+
codeKey: z.ZodOptional<z.ZodDefault<z.ZodString>>;
|
|
105
|
+
messageKey: z.ZodOptional<z.ZodDefault<z.ZodString>>;
|
|
106
|
+
dataKey: z.ZodOptional<z.ZodDefault<z.ZodString>>;
|
|
107
|
+
}, z.core.$strip>>;
|
|
108
|
+
headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
109
|
+
}, z.core.$strip>;
|
|
110
|
+
/**
|
|
111
|
+
* Movk API 模块配置 Schema
|
|
112
|
+
*/
|
|
113
|
+
export declare const movkApiModuleOptionsSchema: z.ZodPipe<z.ZodObject<{
|
|
114
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
115
|
+
defaultEndpoint: z.ZodDefault<z.ZodString>;
|
|
116
|
+
endpoints: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
117
|
+
baseURL: z.ZodString;
|
|
118
|
+
alias: z.ZodOptional<z.ZodString>;
|
|
119
|
+
auth: z.ZodOptional<z.ZodObject<{
|
|
120
|
+
enabled: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
|
|
121
|
+
tokenSource: z.ZodOptional<z.ZodDefault<z.ZodEnum<{
|
|
122
|
+
custom: "custom";
|
|
123
|
+
session: "session";
|
|
124
|
+
}>>>;
|
|
125
|
+
sessionTokenPath: z.ZodOptional<z.ZodDefault<z.ZodString>>;
|
|
126
|
+
tokenType: z.ZodOptional<z.ZodDefault<z.ZodEnum<{
|
|
127
|
+
Bearer: "Bearer";
|
|
128
|
+
Basic: "Basic";
|
|
129
|
+
Custom: "Custom";
|
|
130
|
+
}>>>;
|
|
131
|
+
customTokenType: z.ZodOptional<z.ZodOptional<z.ZodString>>;
|
|
132
|
+
headerName: z.ZodOptional<z.ZodDefault<z.ZodString>>;
|
|
133
|
+
redirectOnUnauthorized: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
|
|
134
|
+
loginPath: z.ZodOptional<z.ZodDefault<z.ZodString>>;
|
|
135
|
+
clearSessionOnUnauthorized: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
|
|
136
|
+
}, z.core.$strip>>;
|
|
137
|
+
toast: z.ZodOptional<z.ZodObject<{
|
|
138
|
+
enabled: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
|
|
139
|
+
success: z.ZodOptional<z.ZodOptional<z.ZodObject<{
|
|
140
|
+
show: z.ZodDefault<z.ZodBoolean>;
|
|
141
|
+
color: z.ZodDefault<z.ZodString>;
|
|
142
|
+
icon: z.ZodOptional<z.ZodString>;
|
|
143
|
+
duration: z.ZodDefault<z.ZodNumber>;
|
|
144
|
+
}, z.core.$loose>>>;
|
|
145
|
+
error: z.ZodOptional<z.ZodOptional<z.ZodObject<{
|
|
146
|
+
show: z.ZodDefault<z.ZodBoolean>;
|
|
147
|
+
color: z.ZodDefault<z.ZodString>;
|
|
148
|
+
icon: z.ZodOptional<z.ZodString>;
|
|
149
|
+
duration: z.ZodDefault<z.ZodNumber>;
|
|
150
|
+
}, z.core.$loose>>>;
|
|
151
|
+
}, z.core.$strip>>;
|
|
152
|
+
success: z.ZodOptional<z.ZodObject<{
|
|
153
|
+
successCodes: z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>>>>;
|
|
154
|
+
codeKey: z.ZodOptional<z.ZodDefault<z.ZodString>>;
|
|
155
|
+
messageKey: z.ZodOptional<z.ZodDefault<z.ZodString>>;
|
|
156
|
+
dataKey: z.ZodOptional<z.ZodDefault<z.ZodString>>;
|
|
157
|
+
}, z.core.$strip>>;
|
|
158
|
+
headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
159
|
+
}, z.core.$strip>>>;
|
|
160
|
+
auth: z.ZodOptional<z.ZodObject<{
|
|
161
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
162
|
+
tokenSource: z.ZodDefault<z.ZodEnum<{
|
|
163
|
+
custom: "custom";
|
|
164
|
+
session: "session";
|
|
165
|
+
}>>;
|
|
166
|
+
sessionTokenPath: z.ZodDefault<z.ZodString>;
|
|
167
|
+
tokenType: z.ZodDefault<z.ZodEnum<{
|
|
168
|
+
Bearer: "Bearer";
|
|
169
|
+
Basic: "Basic";
|
|
170
|
+
Custom: "Custom";
|
|
171
|
+
}>>;
|
|
172
|
+
customTokenType: z.ZodOptional<z.ZodString>;
|
|
173
|
+
headerName: z.ZodDefault<z.ZodString>;
|
|
174
|
+
redirectOnUnauthorized: z.ZodDefault<z.ZodBoolean>;
|
|
175
|
+
loginPath: z.ZodDefault<z.ZodString>;
|
|
176
|
+
clearSessionOnUnauthorized: z.ZodDefault<z.ZodBoolean>;
|
|
177
|
+
}, z.core.$strip>>;
|
|
178
|
+
toast: z.ZodOptional<z.ZodObject<{
|
|
179
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
180
|
+
success: z.ZodOptional<z.ZodObject<{
|
|
181
|
+
show: z.ZodDefault<z.ZodBoolean>;
|
|
182
|
+
color: z.ZodDefault<z.ZodString>;
|
|
183
|
+
icon: z.ZodOptional<z.ZodString>;
|
|
184
|
+
duration: z.ZodDefault<z.ZodNumber>;
|
|
185
|
+
}, z.core.$loose>>;
|
|
186
|
+
error: z.ZodOptional<z.ZodObject<{
|
|
187
|
+
show: z.ZodDefault<z.ZodBoolean>;
|
|
188
|
+
color: z.ZodDefault<z.ZodString>;
|
|
189
|
+
icon: z.ZodOptional<z.ZodString>;
|
|
190
|
+
duration: z.ZodDefault<z.ZodNumber>;
|
|
191
|
+
}, z.core.$loose>>;
|
|
192
|
+
}, z.core.$strip>>;
|
|
193
|
+
success: z.ZodOptional<z.ZodObject<{
|
|
194
|
+
successCodes: z.ZodDefault<z.ZodArray<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>>>;
|
|
195
|
+
codeKey: z.ZodDefault<z.ZodString>;
|
|
196
|
+
messageKey: z.ZodDefault<z.ZodString>;
|
|
197
|
+
dataKey: z.ZodDefault<z.ZodString>;
|
|
198
|
+
}, z.core.$strip>>;
|
|
199
|
+
debug: z.ZodDefault<z.ZodBoolean>;
|
|
200
|
+
}, z.core.$strip>, z.ZodTransform<{
|
|
201
|
+
auth: {
|
|
202
|
+
enabled: boolean;
|
|
203
|
+
tokenSource: "custom" | "session";
|
|
204
|
+
sessionTokenPath: string;
|
|
205
|
+
tokenType: "Bearer" | "Basic" | "Custom";
|
|
206
|
+
headerName: string;
|
|
207
|
+
redirectOnUnauthorized: boolean;
|
|
208
|
+
loginPath: string;
|
|
209
|
+
clearSessionOnUnauthorized: boolean;
|
|
210
|
+
customTokenType?: string | undefined;
|
|
211
|
+
};
|
|
212
|
+
toast: {
|
|
213
|
+
enabled: boolean;
|
|
214
|
+
success?: {
|
|
215
|
+
[x: string]: unknown;
|
|
216
|
+
show: boolean;
|
|
217
|
+
color: string;
|
|
218
|
+
duration: number;
|
|
219
|
+
icon?: string | undefined;
|
|
220
|
+
} | undefined;
|
|
221
|
+
error?: {
|
|
222
|
+
[x: string]: unknown;
|
|
223
|
+
show: boolean;
|
|
224
|
+
color: string;
|
|
225
|
+
duration: number;
|
|
226
|
+
icon?: string | undefined;
|
|
227
|
+
} | undefined;
|
|
228
|
+
};
|
|
229
|
+
success: {
|
|
230
|
+
successCodes: (string | number)[];
|
|
231
|
+
codeKey: string;
|
|
232
|
+
messageKey: string;
|
|
233
|
+
dataKey: string;
|
|
234
|
+
};
|
|
235
|
+
enabled: boolean;
|
|
236
|
+
defaultEndpoint: string;
|
|
237
|
+
endpoints: Record<string, {
|
|
238
|
+
baseURL: string;
|
|
239
|
+
alias?: string | undefined;
|
|
240
|
+
auth?: {
|
|
241
|
+
enabled?: boolean | undefined;
|
|
242
|
+
tokenSource?: "custom" | "session" | undefined;
|
|
243
|
+
sessionTokenPath?: string | undefined;
|
|
244
|
+
tokenType?: "Bearer" | "Basic" | "Custom" | undefined;
|
|
245
|
+
customTokenType?: string | undefined;
|
|
246
|
+
headerName?: string | undefined;
|
|
247
|
+
redirectOnUnauthorized?: boolean | undefined;
|
|
248
|
+
loginPath?: string | undefined;
|
|
249
|
+
clearSessionOnUnauthorized?: boolean | undefined;
|
|
250
|
+
} | undefined;
|
|
251
|
+
toast?: {
|
|
252
|
+
enabled?: boolean | undefined;
|
|
253
|
+
success?: {
|
|
254
|
+
[x: string]: unknown;
|
|
255
|
+
show: boolean;
|
|
256
|
+
color: string;
|
|
257
|
+
duration: number;
|
|
258
|
+
icon?: string | undefined;
|
|
259
|
+
} | undefined;
|
|
260
|
+
error?: {
|
|
261
|
+
[x: string]: unknown;
|
|
262
|
+
show: boolean;
|
|
263
|
+
color: string;
|
|
264
|
+
duration: number;
|
|
265
|
+
icon?: string | undefined;
|
|
266
|
+
} | undefined;
|
|
267
|
+
} | undefined;
|
|
268
|
+
success?: {
|
|
269
|
+
successCodes?: (string | number)[] | undefined;
|
|
270
|
+
codeKey?: string | undefined;
|
|
271
|
+
messageKey?: string | undefined;
|
|
272
|
+
dataKey?: string | undefined;
|
|
273
|
+
} | undefined;
|
|
274
|
+
headers?: Record<string, string> | undefined;
|
|
275
|
+
}>;
|
|
276
|
+
debug: boolean;
|
|
277
|
+
}, {
|
|
278
|
+
enabled: boolean;
|
|
279
|
+
defaultEndpoint: string;
|
|
280
|
+
endpoints: Record<string, {
|
|
281
|
+
baseURL: string;
|
|
282
|
+
alias?: string | undefined;
|
|
283
|
+
auth?: {
|
|
284
|
+
enabled?: boolean | undefined;
|
|
285
|
+
tokenSource?: "custom" | "session" | undefined;
|
|
286
|
+
sessionTokenPath?: string | undefined;
|
|
287
|
+
tokenType?: "Bearer" | "Basic" | "Custom" | undefined;
|
|
288
|
+
customTokenType?: string | undefined;
|
|
289
|
+
headerName?: string | undefined;
|
|
290
|
+
redirectOnUnauthorized?: boolean | undefined;
|
|
291
|
+
loginPath?: string | undefined;
|
|
292
|
+
clearSessionOnUnauthorized?: boolean | undefined;
|
|
293
|
+
} | undefined;
|
|
294
|
+
toast?: {
|
|
295
|
+
enabled?: boolean | undefined;
|
|
296
|
+
success?: {
|
|
297
|
+
[x: string]: unknown;
|
|
298
|
+
show: boolean;
|
|
299
|
+
color: string;
|
|
300
|
+
duration: number;
|
|
301
|
+
icon?: string | undefined;
|
|
302
|
+
} | undefined;
|
|
303
|
+
error?: {
|
|
304
|
+
[x: string]: unknown;
|
|
305
|
+
show: boolean;
|
|
306
|
+
color: string;
|
|
307
|
+
duration: number;
|
|
308
|
+
icon?: string | undefined;
|
|
309
|
+
} | undefined;
|
|
310
|
+
} | undefined;
|
|
311
|
+
success?: {
|
|
312
|
+
successCodes?: (string | number)[] | undefined;
|
|
313
|
+
codeKey?: string | undefined;
|
|
314
|
+
messageKey?: string | undefined;
|
|
315
|
+
dataKey?: string | undefined;
|
|
316
|
+
} | undefined;
|
|
317
|
+
headers?: Record<string, string> | undefined;
|
|
318
|
+
}>;
|
|
319
|
+
debug: boolean;
|
|
320
|
+
auth?: {
|
|
321
|
+
enabled: boolean;
|
|
322
|
+
tokenSource: "custom" | "session";
|
|
323
|
+
sessionTokenPath: string;
|
|
324
|
+
tokenType: "Bearer" | "Basic" | "Custom";
|
|
325
|
+
headerName: string;
|
|
326
|
+
redirectOnUnauthorized: boolean;
|
|
327
|
+
loginPath: string;
|
|
328
|
+
clearSessionOnUnauthorized: boolean;
|
|
329
|
+
customTokenType?: string | undefined;
|
|
330
|
+
} | undefined;
|
|
331
|
+
toast?: {
|
|
332
|
+
enabled: boolean;
|
|
333
|
+
success?: {
|
|
334
|
+
[x: string]: unknown;
|
|
335
|
+
show: boolean;
|
|
336
|
+
color: string;
|
|
337
|
+
duration: number;
|
|
338
|
+
icon?: string | undefined;
|
|
339
|
+
} | undefined;
|
|
340
|
+
error?: {
|
|
341
|
+
[x: string]: unknown;
|
|
342
|
+
show: boolean;
|
|
343
|
+
color: string;
|
|
344
|
+
duration: number;
|
|
345
|
+
icon?: string | undefined;
|
|
346
|
+
} | undefined;
|
|
347
|
+
} | undefined;
|
|
348
|
+
success?: {
|
|
349
|
+
successCodes: (string | number)[];
|
|
350
|
+
codeKey: string;
|
|
351
|
+
messageKey: string;
|
|
352
|
+
dataKey: string;
|
|
353
|
+
} | undefined;
|
|
354
|
+
}>>;
|