sa2kit 1.6.8 → 1.6.9
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/calendar/index.js +10 -8
- package/dist/calendar/index.js.map +1 -1
- package/dist/calendar/index.mjs +3 -1
- package/dist/calendar/index.mjs.map +1 -1
- package/dist/calendar/routes/index.js +21 -21
- package/dist/calendar/routes/index.mjs +1 -1
- package/dist/calendar/server.js +13 -13
- package/dist/calendar/server.mjs +2 -2
- package/dist/{chunk-VHU2YGRQ.mjs → chunk-4FOBBWXW.mjs} +25 -11
- package/dist/chunk-4FOBBWXW.mjs.map +1 -0
- package/dist/{chunk-ZDRBMSTS.js → chunk-G6WRJ2H2.js} +25 -11
- package/dist/chunk-G6WRJ2H2.js.map +1 -0
- package/dist/{chunk-6WXOA4BE.mjs → chunk-GVVS4IMM.mjs} +2 -2
- package/dist/chunk-GVVS4IMM.mjs.map +1 -0
- package/dist/{chunk-AXP7KROR.js → chunk-WC5QFO3T.js} +2 -2
- package/dist/chunk-WC5QFO3T.js.map +1 -0
- package/dist/index.js +5 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +41 -7
- package/dist/ConfigService-BxK06xP6.d.mts +0 -262
- package/dist/ConfigService-BxK06xP6.d.ts +0 -262
- package/dist/UniversalFileService-BuHN-jrR.d.ts +0 -515
- package/dist/UniversalFileService-CGGzYeeF.d.mts +0 -515
- package/dist/analytics/index.d.mts +0 -1084
- package/dist/analytics/index.d.ts +0 -1084
- package/dist/analytics/server/index.d.mts +0 -499
- package/dist/analytics/server/index.d.ts +0 -499
- package/dist/api/index.d.mts +0 -248
- package/dist/api/index.d.ts +0 -248
- package/dist/audioDetection/index.d.mts +0 -449
- package/dist/audioDetection/index.d.ts +0 -449
- package/dist/auth/client/index.d.mts +0 -153
- package/dist/auth/client/index.d.ts +0 -153
- package/dist/auth/components/index.d.mts +0 -227
- package/dist/auth/components/index.d.ts +0 -227
- package/dist/auth/hooks/index.d.mts +0 -31
- package/dist/auth/hooks/index.d.ts +0 -31
- package/dist/auth/index.d.mts +0 -40
- package/dist/auth/index.d.ts +0 -40
- package/dist/auth/middleware/index.d.mts +0 -75
- package/dist/auth/middleware/index.d.ts +0 -75
- package/dist/auth/routes/index.d.mts +0 -261
- package/dist/auth/routes/index.d.ts +0 -261
- package/dist/auth/schema/index.d.mts +0 -789
- package/dist/auth/schema/index.d.ts +0 -789
- package/dist/auth/services/index.d.mts +0 -48
- package/dist/auth/services/index.d.ts +0 -48
- package/dist/calendar/index.d.mts +0 -1197
- package/dist/calendar/index.d.ts +0 -1197
- package/dist/calendar/routes/index.d.mts +0 -118
- package/dist/calendar/routes/index.d.ts +0 -118
- package/dist/calendar/server.d.mts +0 -1184
- package/dist/calendar/server.d.ts +0 -1184
- package/dist/chunk-6WXOA4BE.mjs.map +0 -1
- package/dist/chunk-AXP7KROR.js.map +0 -1
- package/dist/chunk-VHU2YGRQ.mjs.map +0 -1
- package/dist/chunk-ZDRBMSTS.js.map +0 -1
- package/dist/config/index.d.mts +0 -64
- package/dist/config/index.d.ts +0 -64
- package/dist/config/server/index.d.mts +0 -1533
- package/dist/config/server/index.d.ts +0 -1533
- package/dist/drizzle-auth-service-Bxlovhv8.d.ts +0 -145
- package/dist/drizzle-auth-service-DZY2F1sv.d.mts +0 -145
- package/dist/drizzle-schema-BNhqj2AZ.d.mts +0 -1114
- package/dist/drizzle-schema-BNhqj2AZ.d.ts +0 -1114
- package/dist/enums-Dume-V5Y.d.mts +0 -16
- package/dist/enums-Dume-V5Y.d.ts +0 -16
- package/dist/i18n/index.d.mts +0 -417
- package/dist/i18n/index.d.ts +0 -417
- package/dist/imageCrop/index.d.mts +0 -165
- package/dist/imageCrop/index.d.ts +0 -165
- package/dist/index-DSel44Ke.d.mts +0 -93
- package/dist/index-DSel44Ke.d.ts +0 -93
- package/dist/index.d.mts +0 -693
- package/dist/index.d.ts +0 -693
- package/dist/logger/index.d.mts +0 -125
- package/dist/logger/index.d.ts +0 -125
- package/dist/mmd/admin/index.d.mts +0 -487
- package/dist/mmd/admin/index.d.ts +0 -487
- package/dist/mmd/index.d.mts +0 -599
- package/dist/mmd/index.d.ts +0 -599
- package/dist/mmd/server/index.d.mts +0 -138
- package/dist/mmd/server/index.d.ts +0 -138
- package/dist/music/index.d.mts +0 -74
- package/dist/music/index.d.ts +0 -74
- package/dist/music/server/index.d.mts +0 -1
- package/dist/music/server/index.d.ts +0 -1
- package/dist/request/index.d.mts +0 -51
- package/dist/request/index.d.ts +0 -51
- package/dist/storage/index.d.mts +0 -75
- package/dist/storage/index.d.ts +0 -75
- package/dist/testYourself/admin/index.d.mts +0 -58
- package/dist/testYourself/admin/index.d.ts +0 -58
- package/dist/testYourself/index.d.mts +0 -53
- package/dist/testYourself/index.d.ts +0 -53
- package/dist/testYourself/server/index.d.mts +0 -1029
- package/dist/testYourself/server/index.d.ts +0 -1029
- package/dist/types-B60F7EZZ.d.mts +0 -248
- package/dist/types-B60F7EZZ.d.ts +0 -248
- package/dist/types-BINlP9MK.d.mts +0 -286
- package/dist/types-BINlP9MK.d.ts +0 -286
- package/dist/types-BaZccpvk.d.mts +0 -48
- package/dist/types-BaZccpvk.d.ts +0 -48
- package/dist/types-CK4We_aI.d.mts +0 -270
- package/dist/types-CK4We_aI.d.ts +0 -270
- package/dist/types-CbTsi9CZ.d.mts +0 -31
- package/dist/types-CbTsi9CZ.d.ts +0 -31
- package/dist/types-CroexXnI.d.ts +0 -99
- package/dist/types-DmsXCWvm.d.mts +0 -99
- package/dist/types-Dt0oqeFM.d.mts +0 -70
- package/dist/types-zK6kDzDQ.d.ts +0 -70
- package/dist/universalExport/index.d.mts +0 -235
- package/dist/universalExport/index.d.ts +0 -235
- package/dist/universalExport/server/index.d.mts +0 -1270
- package/dist/universalExport/server/index.d.ts +0 -1270
- package/dist/universalFile/index.d.mts +0 -480
- package/dist/universalFile/index.d.ts +0 -480
- package/dist/universalFile/server/index.d.mts +0 -4516
- package/dist/universalFile/server/index.d.ts +0 -4516
- package/dist/useElectronStorage-Dj0rcorG.d.mts +0 -65
- package/dist/useElectronStorage-DwnNfIhl.d.ts +0 -65
- package/dist/utils/index.d.mts +0 -192
- package/dist/utils/index.d.ts +0 -192
|
@@ -1,153 +0,0 @@
|
|
|
1
|
-
import { S as StorageAdapter } from '../../types-BaZccpvk.js';
|
|
2
|
-
import { R as RequestAdapter } from '../../types-CbTsi9CZ.js';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Auth Client - Types
|
|
6
|
-
* API 客户端类型定义
|
|
7
|
-
*/
|
|
8
|
-
/**
|
|
9
|
-
* API 响应类型
|
|
10
|
-
*/
|
|
11
|
-
interface ApiResponse<T = any> {
|
|
12
|
-
success: boolean;
|
|
13
|
-
data?: T;
|
|
14
|
-
error?: string;
|
|
15
|
-
message?: string;
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* 用户类型
|
|
19
|
-
*/
|
|
20
|
-
interface User {
|
|
21
|
-
id: string;
|
|
22
|
-
email: string;
|
|
23
|
-
username: string;
|
|
24
|
-
role: string;
|
|
25
|
-
nickname?: string;
|
|
26
|
-
avatar?: string;
|
|
27
|
-
image?: string;
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* 认证响应类型
|
|
31
|
-
*/
|
|
32
|
-
interface AuthResponse {
|
|
33
|
-
user: User;
|
|
34
|
-
token: string;
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* 存储键名
|
|
38
|
-
*/
|
|
39
|
-
declare const STORAGE_KEYS: {
|
|
40
|
-
readonly AUTH_TOKEN: "auth_token";
|
|
41
|
-
readonly USER_DATA: "user_data";
|
|
42
|
-
};
|
|
43
|
-
/**
|
|
44
|
-
* API 路由
|
|
45
|
-
*/
|
|
46
|
-
declare const API_ROUTES: {
|
|
47
|
-
readonly AUTH: {
|
|
48
|
-
readonly LOGIN: "/auth/login";
|
|
49
|
-
readonly REGISTER: "/auth/register";
|
|
50
|
-
readonly LOGOUT: "/auth/logout";
|
|
51
|
-
readonly ME: "/auth/me";
|
|
52
|
-
};
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* Auth Client - Base API Client
|
|
57
|
-
* 基础 API 客户端
|
|
58
|
-
*/
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* 基础 API 客户端
|
|
62
|
-
* 提供统一的 API 调用逻辑,通过适配器模式支持多平台
|
|
63
|
-
*
|
|
64
|
-
* @example
|
|
65
|
-
* ```typescript
|
|
66
|
-
* import { BaseApiClient } from '@qhr123/sa2kit/auth/client';
|
|
67
|
-
* import { WebStorageAdapter } from '@qhr123/sa2kit/storage';
|
|
68
|
-
* import { WebRequestAdapter } from '@qhr123/sa2kit/request';
|
|
69
|
-
*
|
|
70
|
-
* const apiClient = new BaseApiClient(
|
|
71
|
-
* new WebStorageAdapter(),
|
|
72
|
-
* new WebRequestAdapter(),
|
|
73
|
-
* '/api'
|
|
74
|
-
* );
|
|
75
|
-
*
|
|
76
|
-
* await apiClient.init();
|
|
77
|
-
* const result = await apiClient.login('user@example.com', 'password');
|
|
78
|
-
* ```
|
|
79
|
-
*/
|
|
80
|
-
declare class BaseApiClient {
|
|
81
|
-
private storage;
|
|
82
|
-
private request;
|
|
83
|
-
private baseUrl;
|
|
84
|
-
private token;
|
|
85
|
-
private user;
|
|
86
|
-
constructor(storage: StorageAdapter, request: RequestAdapter, baseUrl: string);
|
|
87
|
-
/**
|
|
88
|
-
* 初始化 - 从存储中加载 token 和用户信息
|
|
89
|
-
*/
|
|
90
|
-
init(): Promise<void>;
|
|
91
|
-
/**
|
|
92
|
-
* 设置认证 token
|
|
93
|
-
*/
|
|
94
|
-
setToken(token: string | null): Promise<void>;
|
|
95
|
-
/**
|
|
96
|
-
* 设置用户信息
|
|
97
|
-
*/
|
|
98
|
-
setUser(user: User | null): Promise<void>;
|
|
99
|
-
/**
|
|
100
|
-
* 获取当前 token
|
|
101
|
-
*/
|
|
102
|
-
getToken(): string | null;
|
|
103
|
-
/**
|
|
104
|
-
* 获取当前用户
|
|
105
|
-
*/
|
|
106
|
-
getUser(): User | null;
|
|
107
|
-
/**
|
|
108
|
-
* 检查是否已登录
|
|
109
|
-
*/
|
|
110
|
-
isAuthenticated(): Promise<boolean>;
|
|
111
|
-
/**
|
|
112
|
-
* 清除用户数据
|
|
113
|
-
*/
|
|
114
|
-
clearUserData(): Promise<void>;
|
|
115
|
-
/**
|
|
116
|
-
* 发送请求的通用方法
|
|
117
|
-
*/
|
|
118
|
-
private sendRequest;
|
|
119
|
-
/**
|
|
120
|
-
* 用户注册
|
|
121
|
-
*/
|
|
122
|
-
register(email: string, password: string, username: string): Promise<ApiResponse<AuthResponse>>;
|
|
123
|
-
/**
|
|
124
|
-
* 用户登录
|
|
125
|
-
*/
|
|
126
|
-
login(email: string, password: string): Promise<ApiResponse<AuthResponse>>;
|
|
127
|
-
/**
|
|
128
|
-
* 用户退出登录
|
|
129
|
-
*/
|
|
130
|
-
logout(): Promise<void>;
|
|
131
|
-
/**
|
|
132
|
-
* 获取当前用户信息
|
|
133
|
-
*/
|
|
134
|
-
getCurrentUser(): Promise<ApiResponse<User>>;
|
|
135
|
-
/**
|
|
136
|
-
* 发送 GET 请求
|
|
137
|
-
*/
|
|
138
|
-
get<T = any>(url: string, params?: Record<string, any>): Promise<ApiResponse<T>>;
|
|
139
|
-
/**
|
|
140
|
-
* 发送 POST 请求
|
|
141
|
-
*/
|
|
142
|
-
post<T = any>(url: string, body?: any): Promise<ApiResponse<T>>;
|
|
143
|
-
/**
|
|
144
|
-
* 发送 PUT 请求
|
|
145
|
-
*/
|
|
146
|
-
put<T = any>(url: string, body?: any): Promise<ApiResponse<T>>;
|
|
147
|
-
/**
|
|
148
|
-
* 发送 DELETE 请求
|
|
149
|
-
*/
|
|
150
|
-
delete<T = any>(url: string): Promise<ApiResponse<T>>;
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
export { API_ROUTES, type ApiResponse, type AuthResponse, BaseApiClient, STORAGE_KEYS, type User };
|
|
@@ -1,227 +0,0 @@
|
|
|
1
|
-
import React__default from 'react';
|
|
2
|
-
import { H as HeadlessLoginFormProps, a as HeadlessRegisterFormProps } from '../../types-Dt0oqeFM.mjs';
|
|
3
|
-
export { B as BaseFormProps, L as LoginFormState, R as RegisterFormState } from '../../types-Dt0oqeFM.mjs';
|
|
4
|
-
import { BaseApiClient } from '../client/index.mjs';
|
|
5
|
-
import { a as User } from '../../types-DmsXCWvm.mjs';
|
|
6
|
-
import '../../types-BaZccpvk.mjs';
|
|
7
|
-
import '../../types-CbTsi9CZ.mjs';
|
|
8
|
-
import '../../enums-Dume-V5Y.mjs';
|
|
9
|
-
import 'drizzle-orm/pg-core';
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Auth Components - LoginForm (Headless)
|
|
13
|
-
* 无样式的登录表单组件
|
|
14
|
-
*/
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Headless 登录表单组件
|
|
18
|
-
*
|
|
19
|
-
* 提供登录逻辑但不包含任何 UI 样式,
|
|
20
|
-
* 使用 render props 模式让用户完全控制 UI
|
|
21
|
-
*
|
|
22
|
-
* @example
|
|
23
|
-
* ```tsx
|
|
24
|
-
* <LoginForm apiClient={apiClient}>
|
|
25
|
-
* {({ email, password, loading, error, handleEmailChange, handlePasswordChange, handleSubmit }) => (
|
|
26
|
-
* <form onSubmit={handleSubmit}>
|
|
27
|
-
* <input
|
|
28
|
-
* value={email}
|
|
29
|
-
* onChange={(e) => handleEmailChange(e.target.value)}
|
|
30
|
-
* />
|
|
31
|
-
* <input
|
|
32
|
-
* type="password"
|
|
33
|
-
* value={password}
|
|
34
|
-
* onChange={(e) => handlePasswordChange(e.target.value)}
|
|
35
|
-
* />
|
|
36
|
-
* {error && <div>{error}</div>}
|
|
37
|
-
* <button disabled={loading}>
|
|
38
|
-
* {loading ? '登录中...' : '登录'}
|
|
39
|
-
* </button>
|
|
40
|
-
* </form>
|
|
41
|
-
* )}
|
|
42
|
-
* </LoginForm>
|
|
43
|
-
* ```
|
|
44
|
-
*/
|
|
45
|
-
declare function LoginForm({ apiClient, onSuccess, onError, children }: HeadlessLoginFormProps): React__default.JSX.Element;
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Auth Components - RegisterForm (Headless)
|
|
49
|
-
* 无样式的注册表单组件
|
|
50
|
-
*/
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* Headless 注册表单组件
|
|
54
|
-
*
|
|
55
|
-
* 提供注册逻辑但不包含任何 UI 样式,
|
|
56
|
-
* 使用 render props 模式让用户完全控制 UI
|
|
57
|
-
*
|
|
58
|
-
* @example
|
|
59
|
-
* ```tsx
|
|
60
|
-
* <RegisterForm apiClient={apiClient}>
|
|
61
|
-
* {({ email, password, username, loading, error, handleEmailChange, handlePasswordChange, handleUsernameChange, handleSubmit }) => (
|
|
62
|
-
* <form onSubmit={handleSubmit}>
|
|
63
|
-
* <input
|
|
64
|
-
* value={email}
|
|
65
|
-
* onChange={(e) => handleEmailChange(e.target.value)}
|
|
66
|
-
* />
|
|
67
|
-
* <input
|
|
68
|
-
* value={username}
|
|
69
|
-
* onChange={(e) => handleUsernameChange(e.target.value)}
|
|
70
|
-
* />
|
|
71
|
-
* <input
|
|
72
|
-
* type="password"
|
|
73
|
-
* value={password}
|
|
74
|
-
* onChange={(e) => handlePasswordChange(e.target.value)}
|
|
75
|
-
* />
|
|
76
|
-
* {error && <div>{error}</div>}
|
|
77
|
-
* <button disabled={loading}>
|
|
78
|
-
* {loading ? '注册中...' : '注册'}
|
|
79
|
-
* </button>
|
|
80
|
-
* </form>
|
|
81
|
-
* )}
|
|
82
|
-
* </RegisterForm>
|
|
83
|
-
* ```
|
|
84
|
-
*/
|
|
85
|
-
declare function RegisterForm({ apiClient, onSuccess, onError, children, }: HeadlessRegisterFormProps): React__default.JSX.Element;
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
* Admin Login Page Component
|
|
89
|
-
* 完整的管理后台登录页面组件
|
|
90
|
-
*
|
|
91
|
-
* 功能:
|
|
92
|
-
* - 邮箱密码登录
|
|
93
|
-
* - 开发环境测试账户自动填充
|
|
94
|
-
* - Analytics 埋点集成
|
|
95
|
-
* - 角色权限检查
|
|
96
|
-
* - 响应式设计
|
|
97
|
-
*/
|
|
98
|
-
|
|
99
|
-
interface AdminLoginPageProps {
|
|
100
|
-
/**
|
|
101
|
-
* API 客户端实例
|
|
102
|
-
*/
|
|
103
|
-
apiClient: BaseApiClient;
|
|
104
|
-
/**
|
|
105
|
-
* 登录成功后的回调
|
|
106
|
-
*/
|
|
107
|
-
onLoginSuccess?: (user: User) => void;
|
|
108
|
-
/**
|
|
109
|
-
* 登录失败的回调
|
|
110
|
-
*/
|
|
111
|
-
onLoginError?: (error: string) => void;
|
|
112
|
-
/**
|
|
113
|
-
* 权限检查函数(可选)
|
|
114
|
-
* 返回 true 表示有权限,false 表示无权限
|
|
115
|
-
*/
|
|
116
|
-
checkPermission?: (user: User) => boolean;
|
|
117
|
-
/**
|
|
118
|
-
* 权限不足时的错误消息
|
|
119
|
-
*/
|
|
120
|
-
permissionDeniedMessage?: string;
|
|
121
|
-
/**
|
|
122
|
-
* 开发环境配置
|
|
123
|
-
*/
|
|
124
|
-
devConfig?: {
|
|
125
|
-
/**
|
|
126
|
-
* 是否启用开发模式功能(自动填充等)
|
|
127
|
-
*/
|
|
128
|
-
enabled?: boolean;
|
|
129
|
-
/**
|
|
130
|
-
* 测试账户邮箱
|
|
131
|
-
*/
|
|
132
|
-
testEmail?: string;
|
|
133
|
-
/**
|
|
134
|
-
* 测试账户密码
|
|
135
|
-
*/
|
|
136
|
-
testPassword?: string;
|
|
137
|
-
/**
|
|
138
|
-
* 自动填充延迟(毫秒)
|
|
139
|
-
*/
|
|
140
|
-
autoFillDelay?: number;
|
|
141
|
-
};
|
|
142
|
-
/**
|
|
143
|
-
* 页面文本配置
|
|
144
|
-
*/
|
|
145
|
-
texts?: {
|
|
146
|
-
appName?: string;
|
|
147
|
-
appDescription?: string;
|
|
148
|
-
pageTitle?: string;
|
|
149
|
-
pageSubtitle?: string;
|
|
150
|
-
emailLabel?: string;
|
|
151
|
-
emailPlaceholder?: string;
|
|
152
|
-
passwordLabel?: string;
|
|
153
|
-
passwordPlaceholder?: string;
|
|
154
|
-
loginButton?: string;
|
|
155
|
-
loggingInButton?: string;
|
|
156
|
-
fillTestAccount?: string;
|
|
157
|
-
copyCredentials?: string;
|
|
158
|
-
devModeLabel?: string;
|
|
159
|
-
testAccountInfo?: string;
|
|
160
|
-
testAccountFilled?: string;
|
|
161
|
-
footer?: string;
|
|
162
|
-
};
|
|
163
|
-
/**
|
|
164
|
-
* Analytics 集成(可选)
|
|
165
|
-
*/
|
|
166
|
-
analytics?: {
|
|
167
|
-
/**
|
|
168
|
-
* 页面访问埋点
|
|
169
|
-
*/
|
|
170
|
-
trackPageView?: (data: Record<string, any>) => void;
|
|
171
|
-
/**
|
|
172
|
-
* 登录成功埋点
|
|
173
|
-
*/
|
|
174
|
-
trackLoginSuccess?: (user: User) => void;
|
|
175
|
-
/**
|
|
176
|
-
* 登录失败埋点
|
|
177
|
-
*/
|
|
178
|
-
trackLoginFailed?: (error: string, email: string) => void;
|
|
179
|
-
/**
|
|
180
|
-
* 权限拒绝埋点
|
|
181
|
-
*/
|
|
182
|
-
trackPermissionDenied?: (user: User) => void;
|
|
183
|
-
/**
|
|
184
|
-
* 设置用户信息
|
|
185
|
-
*/
|
|
186
|
-
setUser?: (user: {
|
|
187
|
-
userId: string;
|
|
188
|
-
email: string;
|
|
189
|
-
role: string;
|
|
190
|
-
}) => void;
|
|
191
|
-
};
|
|
192
|
-
/**
|
|
193
|
-
* UI 组件(可选,用于自定义样式)
|
|
194
|
-
*/
|
|
195
|
-
components?: {
|
|
196
|
-
Container?: React__default.ComponentType<{
|
|
197
|
-
children: React__default.ReactNode;
|
|
198
|
-
}>;
|
|
199
|
-
Card?: React__default.ComponentType<{
|
|
200
|
-
children: React__default.ReactNode;
|
|
201
|
-
}>;
|
|
202
|
-
Input?: React__default.ComponentType<any>;
|
|
203
|
-
Button?: React__default.ComponentType<any>;
|
|
204
|
-
Alert?: React__default.ComponentType<{
|
|
205
|
-
children: React__default.ReactNode;
|
|
206
|
-
}>;
|
|
207
|
-
Badge?: React__default.ComponentType<{
|
|
208
|
-
children: React__default.ReactNode;
|
|
209
|
-
variant?: string;
|
|
210
|
-
}>;
|
|
211
|
-
};
|
|
212
|
-
/**
|
|
213
|
-
* className 配置(用于 Tailwind CSS)
|
|
214
|
-
*/
|
|
215
|
-
classNames?: {
|
|
216
|
-
container?: string;
|
|
217
|
-
card?: string;
|
|
218
|
-
header?: string;
|
|
219
|
-
form?: string;
|
|
220
|
-
input?: string;
|
|
221
|
-
button?: string;
|
|
222
|
-
alert?: string;
|
|
223
|
-
};
|
|
224
|
-
}
|
|
225
|
-
declare function AdminLoginPage(props: AdminLoginPageProps): React__default.JSX.Element;
|
|
226
|
-
|
|
227
|
-
export { AdminLoginPage, type AdminLoginPageProps, HeadlessLoginFormProps, HeadlessRegisterFormProps, LoginForm, RegisterForm };
|
|
@@ -1,227 +0,0 @@
|
|
|
1
|
-
import React__default from 'react';
|
|
2
|
-
import { H as HeadlessLoginFormProps, a as HeadlessRegisterFormProps } from '../../types-zK6kDzDQ.js';
|
|
3
|
-
export { B as BaseFormProps, L as LoginFormState, R as RegisterFormState } from '../../types-zK6kDzDQ.js';
|
|
4
|
-
import { BaseApiClient } from '../client/index.js';
|
|
5
|
-
import { a as User } from '../../types-CroexXnI.js';
|
|
6
|
-
import '../../types-BaZccpvk.js';
|
|
7
|
-
import '../../types-CbTsi9CZ.js';
|
|
8
|
-
import '../../enums-Dume-V5Y.js';
|
|
9
|
-
import 'drizzle-orm/pg-core';
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Auth Components - LoginForm (Headless)
|
|
13
|
-
* 无样式的登录表单组件
|
|
14
|
-
*/
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Headless 登录表单组件
|
|
18
|
-
*
|
|
19
|
-
* 提供登录逻辑但不包含任何 UI 样式,
|
|
20
|
-
* 使用 render props 模式让用户完全控制 UI
|
|
21
|
-
*
|
|
22
|
-
* @example
|
|
23
|
-
* ```tsx
|
|
24
|
-
* <LoginForm apiClient={apiClient}>
|
|
25
|
-
* {({ email, password, loading, error, handleEmailChange, handlePasswordChange, handleSubmit }) => (
|
|
26
|
-
* <form onSubmit={handleSubmit}>
|
|
27
|
-
* <input
|
|
28
|
-
* value={email}
|
|
29
|
-
* onChange={(e) => handleEmailChange(e.target.value)}
|
|
30
|
-
* />
|
|
31
|
-
* <input
|
|
32
|
-
* type="password"
|
|
33
|
-
* value={password}
|
|
34
|
-
* onChange={(e) => handlePasswordChange(e.target.value)}
|
|
35
|
-
* />
|
|
36
|
-
* {error && <div>{error}</div>}
|
|
37
|
-
* <button disabled={loading}>
|
|
38
|
-
* {loading ? '登录中...' : '登录'}
|
|
39
|
-
* </button>
|
|
40
|
-
* </form>
|
|
41
|
-
* )}
|
|
42
|
-
* </LoginForm>
|
|
43
|
-
* ```
|
|
44
|
-
*/
|
|
45
|
-
declare function LoginForm({ apiClient, onSuccess, onError, children }: HeadlessLoginFormProps): React__default.JSX.Element;
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Auth Components - RegisterForm (Headless)
|
|
49
|
-
* 无样式的注册表单组件
|
|
50
|
-
*/
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* Headless 注册表单组件
|
|
54
|
-
*
|
|
55
|
-
* 提供注册逻辑但不包含任何 UI 样式,
|
|
56
|
-
* 使用 render props 模式让用户完全控制 UI
|
|
57
|
-
*
|
|
58
|
-
* @example
|
|
59
|
-
* ```tsx
|
|
60
|
-
* <RegisterForm apiClient={apiClient}>
|
|
61
|
-
* {({ email, password, username, loading, error, handleEmailChange, handlePasswordChange, handleUsernameChange, handleSubmit }) => (
|
|
62
|
-
* <form onSubmit={handleSubmit}>
|
|
63
|
-
* <input
|
|
64
|
-
* value={email}
|
|
65
|
-
* onChange={(e) => handleEmailChange(e.target.value)}
|
|
66
|
-
* />
|
|
67
|
-
* <input
|
|
68
|
-
* value={username}
|
|
69
|
-
* onChange={(e) => handleUsernameChange(e.target.value)}
|
|
70
|
-
* />
|
|
71
|
-
* <input
|
|
72
|
-
* type="password"
|
|
73
|
-
* value={password}
|
|
74
|
-
* onChange={(e) => handlePasswordChange(e.target.value)}
|
|
75
|
-
* />
|
|
76
|
-
* {error && <div>{error}</div>}
|
|
77
|
-
* <button disabled={loading}>
|
|
78
|
-
* {loading ? '注册中...' : '注册'}
|
|
79
|
-
* </button>
|
|
80
|
-
* </form>
|
|
81
|
-
* )}
|
|
82
|
-
* </RegisterForm>
|
|
83
|
-
* ```
|
|
84
|
-
*/
|
|
85
|
-
declare function RegisterForm({ apiClient, onSuccess, onError, children, }: HeadlessRegisterFormProps): React__default.JSX.Element;
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
* Admin Login Page Component
|
|
89
|
-
* 完整的管理后台登录页面组件
|
|
90
|
-
*
|
|
91
|
-
* 功能:
|
|
92
|
-
* - 邮箱密码登录
|
|
93
|
-
* - 开发环境测试账户自动填充
|
|
94
|
-
* - Analytics 埋点集成
|
|
95
|
-
* - 角色权限检查
|
|
96
|
-
* - 响应式设计
|
|
97
|
-
*/
|
|
98
|
-
|
|
99
|
-
interface AdminLoginPageProps {
|
|
100
|
-
/**
|
|
101
|
-
* API 客户端实例
|
|
102
|
-
*/
|
|
103
|
-
apiClient: BaseApiClient;
|
|
104
|
-
/**
|
|
105
|
-
* 登录成功后的回调
|
|
106
|
-
*/
|
|
107
|
-
onLoginSuccess?: (user: User) => void;
|
|
108
|
-
/**
|
|
109
|
-
* 登录失败的回调
|
|
110
|
-
*/
|
|
111
|
-
onLoginError?: (error: string) => void;
|
|
112
|
-
/**
|
|
113
|
-
* 权限检查函数(可选)
|
|
114
|
-
* 返回 true 表示有权限,false 表示无权限
|
|
115
|
-
*/
|
|
116
|
-
checkPermission?: (user: User) => boolean;
|
|
117
|
-
/**
|
|
118
|
-
* 权限不足时的错误消息
|
|
119
|
-
*/
|
|
120
|
-
permissionDeniedMessage?: string;
|
|
121
|
-
/**
|
|
122
|
-
* 开发环境配置
|
|
123
|
-
*/
|
|
124
|
-
devConfig?: {
|
|
125
|
-
/**
|
|
126
|
-
* 是否启用开发模式功能(自动填充等)
|
|
127
|
-
*/
|
|
128
|
-
enabled?: boolean;
|
|
129
|
-
/**
|
|
130
|
-
* 测试账户邮箱
|
|
131
|
-
*/
|
|
132
|
-
testEmail?: string;
|
|
133
|
-
/**
|
|
134
|
-
* 测试账户密码
|
|
135
|
-
*/
|
|
136
|
-
testPassword?: string;
|
|
137
|
-
/**
|
|
138
|
-
* 自动填充延迟(毫秒)
|
|
139
|
-
*/
|
|
140
|
-
autoFillDelay?: number;
|
|
141
|
-
};
|
|
142
|
-
/**
|
|
143
|
-
* 页面文本配置
|
|
144
|
-
*/
|
|
145
|
-
texts?: {
|
|
146
|
-
appName?: string;
|
|
147
|
-
appDescription?: string;
|
|
148
|
-
pageTitle?: string;
|
|
149
|
-
pageSubtitle?: string;
|
|
150
|
-
emailLabel?: string;
|
|
151
|
-
emailPlaceholder?: string;
|
|
152
|
-
passwordLabel?: string;
|
|
153
|
-
passwordPlaceholder?: string;
|
|
154
|
-
loginButton?: string;
|
|
155
|
-
loggingInButton?: string;
|
|
156
|
-
fillTestAccount?: string;
|
|
157
|
-
copyCredentials?: string;
|
|
158
|
-
devModeLabel?: string;
|
|
159
|
-
testAccountInfo?: string;
|
|
160
|
-
testAccountFilled?: string;
|
|
161
|
-
footer?: string;
|
|
162
|
-
};
|
|
163
|
-
/**
|
|
164
|
-
* Analytics 集成(可选)
|
|
165
|
-
*/
|
|
166
|
-
analytics?: {
|
|
167
|
-
/**
|
|
168
|
-
* 页面访问埋点
|
|
169
|
-
*/
|
|
170
|
-
trackPageView?: (data: Record<string, any>) => void;
|
|
171
|
-
/**
|
|
172
|
-
* 登录成功埋点
|
|
173
|
-
*/
|
|
174
|
-
trackLoginSuccess?: (user: User) => void;
|
|
175
|
-
/**
|
|
176
|
-
* 登录失败埋点
|
|
177
|
-
*/
|
|
178
|
-
trackLoginFailed?: (error: string, email: string) => void;
|
|
179
|
-
/**
|
|
180
|
-
* 权限拒绝埋点
|
|
181
|
-
*/
|
|
182
|
-
trackPermissionDenied?: (user: User) => void;
|
|
183
|
-
/**
|
|
184
|
-
* 设置用户信息
|
|
185
|
-
*/
|
|
186
|
-
setUser?: (user: {
|
|
187
|
-
userId: string;
|
|
188
|
-
email: string;
|
|
189
|
-
role: string;
|
|
190
|
-
}) => void;
|
|
191
|
-
};
|
|
192
|
-
/**
|
|
193
|
-
* UI 组件(可选,用于自定义样式)
|
|
194
|
-
*/
|
|
195
|
-
components?: {
|
|
196
|
-
Container?: React__default.ComponentType<{
|
|
197
|
-
children: React__default.ReactNode;
|
|
198
|
-
}>;
|
|
199
|
-
Card?: React__default.ComponentType<{
|
|
200
|
-
children: React__default.ReactNode;
|
|
201
|
-
}>;
|
|
202
|
-
Input?: React__default.ComponentType<any>;
|
|
203
|
-
Button?: React__default.ComponentType<any>;
|
|
204
|
-
Alert?: React__default.ComponentType<{
|
|
205
|
-
children: React__default.ReactNode;
|
|
206
|
-
}>;
|
|
207
|
-
Badge?: React__default.ComponentType<{
|
|
208
|
-
children: React__default.ReactNode;
|
|
209
|
-
variant?: string;
|
|
210
|
-
}>;
|
|
211
|
-
};
|
|
212
|
-
/**
|
|
213
|
-
* className 配置(用于 Tailwind CSS)
|
|
214
|
-
*/
|
|
215
|
-
classNames?: {
|
|
216
|
-
container?: string;
|
|
217
|
-
card?: string;
|
|
218
|
-
header?: string;
|
|
219
|
-
form?: string;
|
|
220
|
-
input?: string;
|
|
221
|
-
button?: string;
|
|
222
|
-
alert?: string;
|
|
223
|
-
};
|
|
224
|
-
}
|
|
225
|
-
declare function AdminLoginPage(props: AdminLoginPageProps): React__default.JSX.Element;
|
|
226
|
-
|
|
227
|
-
export { AdminLoginPage, type AdminLoginPageProps, HeadlessLoginFormProps, HeadlessRegisterFormProps, LoginForm, RegisterForm };
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { b as BaseApiClient, U as UseAuthReturn } from '../../types-DmsXCWvm.mjs';
|
|
3
|
-
export { A as AuthResult, a as User } from '../../types-DmsXCWvm.mjs';
|
|
4
|
-
import '../../enums-Dume-V5Y.mjs';
|
|
5
|
-
import 'drizzle-orm/pg-core';
|
|
6
|
-
|
|
7
|
-
declare function useAuth(apiClient: BaseApiClient): UseAuthReturn;
|
|
8
|
-
/**
|
|
9
|
-
* 表单验证 Hook
|
|
10
|
-
*
|
|
11
|
-
* @example
|
|
12
|
-
* ```typescript
|
|
13
|
-
* const { values, errors, handleChange, handleBlur, validate } = useAuthForm({
|
|
14
|
-
* email: '',
|
|
15
|
-
* password: ''
|
|
16
|
-
* })
|
|
17
|
-
* ```
|
|
18
|
-
*/
|
|
19
|
-
declare function useAuthForm<T extends Record<string, any>>(initialValues: T): {
|
|
20
|
-
values: T;
|
|
21
|
-
errors: Partial<Record<keyof T, string>>;
|
|
22
|
-
touched: Partial<Record<keyof T, boolean>>;
|
|
23
|
-
handleChange: (field: keyof T, value: any) => void;
|
|
24
|
-
handleBlur: (field: keyof T) => void;
|
|
25
|
-
validate: (validationRules: Partial<Record<keyof T, (value: any) => string | undefined>>) => boolean;
|
|
26
|
-
reset: () => void;
|
|
27
|
-
setValues: React.Dispatch<React.SetStateAction<T>>;
|
|
28
|
-
setErrors: React.Dispatch<React.SetStateAction<Partial<Record<keyof T, string>>>>;
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
export { BaseApiClient, UseAuthReturn, useAuth, useAuthForm };
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { b as BaseApiClient, U as UseAuthReturn } from '../../types-CroexXnI.js';
|
|
3
|
-
export { A as AuthResult, a as User } from '../../types-CroexXnI.js';
|
|
4
|
-
import '../../enums-Dume-V5Y.js';
|
|
5
|
-
import 'drizzle-orm/pg-core';
|
|
6
|
-
|
|
7
|
-
declare function useAuth(apiClient: BaseApiClient): UseAuthReturn;
|
|
8
|
-
/**
|
|
9
|
-
* 表单验证 Hook
|
|
10
|
-
*
|
|
11
|
-
* @example
|
|
12
|
-
* ```typescript
|
|
13
|
-
* const { values, errors, handleChange, handleBlur, validate } = useAuthForm({
|
|
14
|
-
* email: '',
|
|
15
|
-
* password: ''
|
|
16
|
-
* })
|
|
17
|
-
* ```
|
|
18
|
-
*/
|
|
19
|
-
declare function useAuthForm<T extends Record<string, any>>(initialValues: T): {
|
|
20
|
-
values: T;
|
|
21
|
-
errors: Partial<Record<keyof T, string>>;
|
|
22
|
-
touched: Partial<Record<keyof T, boolean>>;
|
|
23
|
-
handleChange: (field: keyof T, value: any) => void;
|
|
24
|
-
handleBlur: (field: keyof T) => void;
|
|
25
|
-
validate: (validationRules: Partial<Record<keyof T, (value: any) => string | undefined>>) => boolean;
|
|
26
|
-
reset: () => void;
|
|
27
|
-
setValues: React.Dispatch<React.SetStateAction<T>>;
|
|
28
|
-
setErrors: React.Dispatch<React.SetStateAction<Partial<Record<keyof T, string>>>>;
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
export { BaseApiClient, UseAuthReturn, useAuth, useAuthForm };
|
package/dist/auth/index.d.mts
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { U as UserRole } from '../enums-Dume-V5Y.mjs';
|
|
2
|
-
export { u as userRole } from '../enums-Dume-V5Y.mjs';
|
|
3
|
-
export { Account, NewAccount, NewSession, NewUser, NewVerification, Session, User, Verification, account, accountRelations, session, sessionRelations, user, userRelations, verifications } from './schema/index.mjs';
|
|
4
|
-
export { A as AuthResult, a as AuthServiceConfig, D as DrizzleAuthService, S as SessionInfo, U as UserInfo, V as VerifyResult } from '../drizzle-auth-service-DZY2F1sv.mjs';
|
|
5
|
-
export { JwtPayload, generateToken, getTokenFromRequest, hashPassword, verifyJwtToken, verifyPassword } from './services/index.mjs';
|
|
6
|
-
import { NextRequest } from 'next/server';
|
|
7
|
-
export { AnalyticsEvent, AnalyticsService, ApiResponse, BaseRouteConfig, LoginRouteConfig, RegisterRouteConfig, createAnalyticsAdapter, createDefaultBaseConfig, createDefaultLoginConfig, createDefaultRegisterConfig, createLoginHandler, createLoginOptionsHandler, createLogoutHandler, createLogoutOptionsHandler, createMeHandler, createMeOptionsHandler, createRegisterHandler, createRegisterOptionsHandler } from './routes/index.mjs';
|
|
8
|
-
export { AuthLevel, AuthMiddlewareConfig, RouteContext, RouteHandler, createAuthMiddleware } from './middleware/index.mjs';
|
|
9
|
-
export { useAuth, useAuthForm } from './hooks/index.mjs';
|
|
10
|
-
export { API_ROUTES, BaseApiClient, STORAGE_KEYS } from './client/index.mjs';
|
|
11
|
-
export { L as LoginFormState, R as RegisterFormState } from '../types-Dt0oqeFM.mjs';
|
|
12
|
-
export { B as BaseUser, L as LoginForm, R as RegisterForm, U as UseAuthReturn } from '../types-DmsXCWvm.mjs';
|
|
13
|
-
import 'drizzle-orm/pg-core';
|
|
14
|
-
import 'drizzle-orm';
|
|
15
|
-
import 'react';
|
|
16
|
-
import '../types-BaZccpvk.mjs';
|
|
17
|
-
import '../types-CbTsi9CZ.mjs';
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* 验证 API 请求的身份
|
|
21
|
-
* 从请求头中获取 Token 并验证,返回用户信息
|
|
22
|
-
*/
|
|
23
|
-
declare function validateApiAuth(request: NextRequest): Promise<{
|
|
24
|
-
id: string;
|
|
25
|
-
email: string;
|
|
26
|
-
username: string | undefined;
|
|
27
|
-
role: UserRole;
|
|
28
|
-
} | null>;
|
|
29
|
-
/**
|
|
30
|
-
* 验证 API 请求的身份(针对使用数字 ID 的项目)
|
|
31
|
-
* 将 string 类型的 userId 转换为 number 类型
|
|
32
|
-
*/
|
|
33
|
-
declare function validateApiAuthNumeric(request: NextRequest): Promise<{
|
|
34
|
-
id: number;
|
|
35
|
-
email: string;
|
|
36
|
-
username: string | undefined;
|
|
37
|
-
role: UserRole;
|
|
38
|
-
} | null>;
|
|
39
|
-
|
|
40
|
-
export { UserRole, validateApiAuth, validateApiAuthNumeric };
|