@h-ai/kit 1.0.0-beta.18 → 1.0.0-beta.19
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.en.md +53 -33
- package/README.ja.md +53 -33
- package/README.md +54 -33
- package/dist/adapter/index.d.ts +8 -7
- package/dist/adapter/index.js.map +1 -1
- package/dist/browser.d.ts +9 -26
- package/dist/browser.js +4 -4
- package/dist/browser.js.map +1 -1
- package/dist/{chunk-JRQPMPQC.js → chunk-BCEBXG4X.js} +2 -2
- package/dist/chunk-BCEBXG4X.js.map +1 -0
- package/dist/{chunk-7EH47MTW.js → chunk-BVGXHIXR.js} +30 -9
- package/dist/chunk-BVGXHIXR.js.map +1 -0
- package/dist/{chunk-WCMEGLBL.js → chunk-GQZCU6PC.js} +11 -5
- package/dist/chunk-GQZCU6PC.js.map +1 -0
- package/dist/{chunk-5JW3VW4Q.js → chunk-JL2C5ZGQ.js} +38 -11
- package/dist/chunk-JL2C5ZGQ.js.map +1 -0
- package/dist/{chunk-6KS67QUS.js → chunk-WYGIKXHE.js} +20 -7
- package/dist/chunk-WYGIKXHE.js.map +1 -0
- package/dist/client/index.d.ts +6 -5
- package/dist/client/index.js +5 -5
- package/dist/client/index.js.map +1 -1
- package/dist/index.d.ts +18 -711
- package/dist/index.js +264 -149
- package/dist/index.js.map +1 -1
- package/dist/{kit-a2a-types-ikgvWS3T.d.ts → kit-a2a-types-CeDikRAX.d.ts} +3 -2
- package/dist/kit-config-CCksTmi5.d.ts +182 -0
- package/dist/kit-crypto-types-CqFENBqm.d.ts +47 -0
- package/dist/kit-types-BUDaKGB0.d.ts +2057 -0
- package/dist/modules/a2a/index.d.ts +9 -5
- package/dist/modules/a2a/index.js +1 -1
- package/dist/modules/crypto/index.d.ts +8 -105
- package/dist/modules/crypto/index.js +3 -149
- package/dist/modules/crypto/index.js.map +1 -1
- package/package.json +22 -22
- package/dist/chunk-5JW3VW4Q.js.map +0 -1
- package/dist/chunk-6KS67QUS.js.map +0 -1
- package/dist/chunk-7EH47MTW.js.map +0 -1
- package/dist/chunk-JRQPMPQC.js.map +0 -1
- package/dist/chunk-WCMEGLBL.js.map +0 -1
- package/dist/kit-client-auth-DeWmc-1u.d.ts +0 -406
- package/dist/kit-crypto-types-Brd0l8Hv.d.ts +0 -204
- package/dist/kit-i18n-CjwdGeKY.d.ts +0 -506
- package/dist/kit-types-CnfBC89D.d.ts +0 -832
package/dist/index.d.ts
CHANGED
|
@@ -1,23 +1,17 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { C as ClientTransportConfig, K as KitClient,
|
|
3
|
-
import { d as defineCrud, s as setAllModulesLocale } from './kit-i18n-CjwdGeKY.js';
|
|
4
|
-
export { C as CrudApiDef, b as CrudFieldDef, c as CrudFieldOption, e as CrudFieldOptions, f as CrudFieldType, g as CrudFieldValidation, h as CrudFilterParams, i as CrudOperations, j as CrudPaginatedResult, k as CrudPaginationParams, l as CrudResourceDef, m as CrudTableColumn, n as CrudText, K as KitConfigSchema, r as resolveKitConfig, a as resolveKitTransportConfig, o as resolveOptions, p as resolveText } from './kit-i18n-CjwdGeKY.js';
|
|
5
|
-
import { S as SessionData, r as SessionLike, h as HandleConfig, s as rateLimitMiddleware, t as createCacheRateLimitStore, u as createMemoryRateLimitStore } from './kit-types-CnfBC89D.js';
|
|
6
|
-
export { A as ApiResponse, a as AuthOperations, b as AuthOperationsProvider, C as CorsConfig, F as FormError, c as FormValidationResult, G as GuardConfig, d as GuardResult, H as HaiRequestEvent, e as HandleA2AConfig, f as HandleA2AOperations, g as HandleAuthConfig, i as HookCryptoConfig, K as KitConfig, j as KitConfigInput, k as KitPublicConfig, l as KitServerConfig, m as KitServerConfigInput, n as KitTransportConfig, o as KitTransportConfigInput, v as MemoryRateLimitStore, M as Middleware, p as MiddlewareContext, w as RateLimitCache, R as RateLimitConfig, x as RateLimitEntry, y as RateLimitStore, q as RouteGuard, T as TransportEncryptionOptions } from './kit-types-CnfBC89D.js';
|
|
1
|
+
import { S as SessionData, z as KitFunctions } from './kit-types-BUDaKGB0.js';
|
|
2
|
+
export { A as ApiResponse, D as AuthCookieWriter, a as AuthOperations, b as AuthOperationsProvider, B as BrowserKitFunctions, C as ClientTransportConfig, c as CorsConfig, E as CrudApiDef, I as CrudFieldDef, J as CrudFieldOption, L as CrudFieldOptions, N as CrudFieldType, O as CrudFieldValidation, P as CrudFilterParams, Q as CrudOperations, U as CrudPaginatedResult, V as CrudPaginationParams, W as CrudResourceDef, X as CrudTableColumn, Y as CrudText, Z as FeedbackHandlerOptions, F as FormError, d as FormValidationResult, G as GuardConfig, e as GuardResult, H as HaiRequestEvent, f as HandleA2AConfig, g as HandleA2AOperations, h as HandleAuthConfig, i as HandleConfig, j as HookCryptoConfig, _ as IdParamSchema, K as KitClient, k as KitClientConfig, l as KitConfig, m as KitConfigInput, n as KitPublicConfig, o as KitServerConfig, p as KitServerConfigInput, q as KitTransportConfig, r as KitTransportConfigInput, $ as MemoryRateLimitStore, M as Middleware, s as MiddlewareContext, a0 as PaginationQuerySchema, a1 as PermissionGuardConfig, a2 as RateLimitCache, R as RateLimitConfig, a3 as RateLimitEntry, a4 as RateLimitStore, t as RouteGuard, u as SessionLike, T as TransportEncryptionOptions, a5 as defineCrud, a6 as matchPermission, a7 as resolveOptions, a8 as resolveText } from './kit-types-BUDaKGB0.js';
|
|
7
3
|
import { CryptoFunctions } from '@h-ai/crypto';
|
|
8
4
|
export { EncryptedPayload, TransportEncryptionManager, TransportKeyPair } from '@h-ai/crypto';
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
import
|
|
15
|
-
import * as zod from 'zod';
|
|
16
|
-
import { z } from 'zod';
|
|
17
|
-
import { IamFunctions } from '@h-ai/iam';
|
|
18
|
-
export { A as A2AApiKeyAuthConfig, K as KitA2AHandlerConfig, R as ResolvedA2AConfig } from './kit-a2a-types-ikgvWS3T.js';
|
|
19
|
-
export { C as CryptoCsrfConfig, a as CryptoServiceLike, E as EncryptedCookieConfig, T as TransportEncryptionConfig, W as WebhookVerifyConfig } from './kit-crypto-types-Brd0l8Hv.js';
|
|
5
|
+
export { A as A2AApiKeyAuthConfig, K as KitA2AHandlerConfig, R as ResolvedA2AConfig } from './kit-a2a-types-CeDikRAX.js';
|
|
6
|
+
export { T as TransportEncryptionConfig } from './kit-crypto-types-CqFENBqm.js';
|
|
7
|
+
export { K as KitConfigSchema, r as resolveKitConfig, a as resolveKitTransportConfig } from './kit-config-CCksTmi5.js';
|
|
8
|
+
import '@h-ai/core';
|
|
9
|
+
import '@h-ai/iam';
|
|
10
|
+
import '@sveltejs/kit';
|
|
20
11
|
import '@h-ai/api-contract';
|
|
12
|
+
import '@sveltejs/kit/hooks';
|
|
13
|
+
import '@h-ai/feedback';
|
|
14
|
+
import 'zod';
|
|
21
15
|
|
|
22
16
|
/**
|
|
23
17
|
* @h-ai/kit — 认证守卫
|
|
@@ -61,87 +55,6 @@ interface SessionGuardConfig {
|
|
|
61
55
|
apiMode?: boolean;
|
|
62
56
|
}
|
|
63
57
|
|
|
64
|
-
/**
|
|
65
|
-
* @h-ai/kit — 权限守卫
|
|
66
|
-
*
|
|
67
|
-
* 验证用户是否具有指定权限。
|
|
68
|
-
* @module kit-permission
|
|
69
|
-
*/
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* 权限守卫配置
|
|
73
|
-
* @example
|
|
74
|
-
* ```ts
|
|
75
|
-
* import type { PermissionGuardConfig } from '@h-ai/kit'
|
|
76
|
-
*
|
|
77
|
-
* const value: PermissionGuardConfig = { permissions: ['article:read'] }
|
|
78
|
-
* void value
|
|
79
|
-
* ```
|
|
80
|
-
*/
|
|
81
|
-
interface PermissionGuardConfig {
|
|
82
|
-
/** 需要的权限列表(默认 OR 逻辑,满足任一即通过) */
|
|
83
|
-
permissions: string[];
|
|
84
|
-
/** 为 `true` 时要求用户拥有 **全部** 权限(AND 逻辑) */
|
|
85
|
-
requireAll?: boolean;
|
|
86
|
-
/** 无权限时重定向 URL(默认 `'/403'`) */
|
|
87
|
-
forbiddenUrl?: string;
|
|
88
|
-
/** 为 `true` 时返回 JSON 403 而非重定向 */
|
|
89
|
-
apiMode?: boolean;
|
|
90
|
-
}
|
|
91
|
-
/**
|
|
92
|
-
* 匹配权限
|
|
93
|
-
*
|
|
94
|
-
* 支持通配符:
|
|
95
|
-
* - `admin:*` 匹配 `admin:read`、`admin:write` 等
|
|
96
|
-
* - `*` 匹配所有权限
|
|
97
|
-
*
|
|
98
|
-
* @param required - 需要的权限码
|
|
99
|
-
* @param userPermissions - 用户已有的权限列表
|
|
100
|
-
* @returns 是否匹配
|
|
101
|
-
* @example
|
|
102
|
-
* ```ts
|
|
103
|
-
* import { matchPermission } from '@h-ai/kit'
|
|
104
|
-
*
|
|
105
|
-
* const allowed = matchPermission('article:read', ['article:*'])
|
|
106
|
-
* void allowed
|
|
107
|
-
* ```
|
|
108
|
-
*/
|
|
109
|
-
declare function matchPermission(required: string, userPermissions: string[]): boolean;
|
|
110
|
-
/**
|
|
111
|
-
* 检查会话是否具有指定权限(布尔判断)
|
|
112
|
-
*
|
|
113
|
-
* 适用于条件分支场景(如菜单过滤、按钮显示等)。
|
|
114
|
-
*
|
|
115
|
-
* @param session - 当前会话数据,null/undefined 视为无权限
|
|
116
|
-
* @param permission - 需要的权限码,如 `user:read`
|
|
117
|
-
* @returns 是否拥有权限
|
|
118
|
-
* @example
|
|
119
|
-
* ```ts
|
|
120
|
-
* import { kit } from '@h-ai/kit'
|
|
121
|
-
*
|
|
122
|
-
* const allowed = kit.guard.check({ userId: 'user_1', roles: ['editor'], permissions: ['article:read'] }, 'article:read')
|
|
123
|
-
* void allowed
|
|
124
|
-
* ```
|
|
125
|
-
*/
|
|
126
|
-
declare function hasPermission(session: SessionLike | null | undefined, permission: string): boolean;
|
|
127
|
-
/**
|
|
128
|
-
* 要求会话具有指定权限,不满足时 throw Response
|
|
129
|
-
*
|
|
130
|
-
* throw 的 Response 对象由 kit.handler 捕获并直接作为 API 响应返回。
|
|
131
|
-
* 搭配 `kit.handler()` 使用时,无需手动检查返回值。
|
|
132
|
-
*
|
|
133
|
-
* @param session - 当前会话数据,null/undefined 视为未认证
|
|
134
|
-
* @param permission - 需要的权限码,如 `user:create`
|
|
135
|
-
* @throws Response - 未认证 401 / 无权限 403
|
|
136
|
-
* @example
|
|
137
|
-
* ```ts
|
|
138
|
-
* import { kit } from '@h-ai/kit'
|
|
139
|
-
*
|
|
140
|
-
* kit.guard.require({ userId: 'user_1', roles: ['editor'], permissions: ['article:read'] }, 'article:read') // 拒绝时抛出 Response,由 kit.handler 传递。
|
|
141
|
-
* ```
|
|
142
|
-
*/
|
|
143
|
-
declare function requirePermission(session: SessionLike | null | undefined, permission: string): void;
|
|
144
|
-
|
|
145
58
|
/**
|
|
146
59
|
* @h-ai/kit — 角色守卫
|
|
147
60
|
*
|
|
@@ -170,35 +83,10 @@ interface RoleGuardConfig {
|
|
|
170
83
|
apiMode?: boolean;
|
|
171
84
|
}
|
|
172
85
|
|
|
173
|
-
/** 可选敏感操作再鉴别;由操作入口在现有权限/资源检查之后调用。 */
|
|
174
|
-
|
|
175
|
-
/**
|
|
176
|
-
* 要求选定操作携带短期单次再鉴别票据;失败抛出 Response,由 kit.handler 返回。
|
|
177
|
-
* 不替代已有认证、权限与资源范围守卫;操作 ID 必须由服务端指定。
|
|
178
|
-
* @param iam - 已初始化的 IAM 服务。
|
|
179
|
-
* @param event - 当前请求与 Cookie,不能跨请求保存。
|
|
180
|
-
* @param operation - 当前服务端操作 ID。
|
|
181
|
-
* @returns 策略关闭、未选操作或证明校验成功时无返回值。
|
|
182
|
-
* @example
|
|
183
|
-
* ```ts
|
|
184
|
-
* import { iam } from '@h-ai/iam'
|
|
185
|
-
* import type { SessionLike } from '@h-ai/kit'
|
|
186
|
-
* import type { RequestEvent } from '@sveltejs/kit'
|
|
187
|
-
* import { kit } from '@h-ai/kit'
|
|
188
|
-
* // session 由应用在当前请求完成鉴别后传入,不在跨请求闭包中保存。
|
|
189
|
-
* async function remove(event: Pick<RequestEvent, 'request' | 'cookies'>, session: SessionLike) {
|
|
190
|
-
* kit.guard.require(session, 'user:delete')
|
|
191
|
-
* await kit.guard.requireSensitive(iam, event, 'iam.users.delete')
|
|
192
|
-
* return kit.response.ok({ allowed: true })
|
|
193
|
-
* }
|
|
194
|
-
* ```
|
|
195
|
-
*/
|
|
196
|
-
declare function requireSensitiveOperation(iam: IamFunctions, event: Pick<RequestEvent, 'request' | 'cookies'>, operation: string): Promise<void>;
|
|
197
|
-
|
|
198
86
|
/**
|
|
199
87
|
* @h-ai/kit — Cookie 加密代理
|
|
200
88
|
*
|
|
201
|
-
* 通过 Proxy
|
|
89
|
+
* 通过 Proxy 对指定 Cookie 进行 SM4-CBC 加密和 HMAC-SHA256 认证,先验真再解密。
|
|
202
90
|
* @module kit-cookie-proxy
|
|
203
91
|
*/
|
|
204
92
|
|
|
@@ -224,477 +112,11 @@ interface CookieProxyConfig {
|
|
|
224
112
|
}
|
|
225
113
|
|
|
226
114
|
/**
|
|
227
|
-
* @h-ai/kit —
|
|
228
|
-
*
|
|
229
|
-
* 创建 SvelteKit Handle Hook,集成请求 ID 生成、会话验证、Cookie 加密代理、
|
|
230
|
-
* 路由守卫、中间件链与可选传输加密;同时提供 `sequence()` 组合多个 Handle。
|
|
231
|
-
* @module kit-handle
|
|
232
|
-
*/
|
|
233
|
-
|
|
234
|
-
/**
|
|
235
|
-
* 创建 hai handle hook
|
|
236
|
-
*
|
|
237
|
-
* 整合会话解析、路由守卫、中间件链与统一错误处理的 SvelteKit Handle 工厂。
|
|
238
|
-
*
|
|
239
|
-
* 执行顺序:
|
|
240
|
-
* 1. 生成 `requestId` 并写入 `event.locals`
|
|
241
|
-
* 2. 根据 `auth` 配置从 Bearer / Cookie 解析会话
|
|
242
|
-
* 3. 根据 `auth.protectedPaths` 自动执行路由守卫 + 额外自定义守卫
|
|
243
|
-
* 4. 构建中间件链(内置 logging / rateLimit + 自定义)并执行
|
|
244
|
-
* 5. 调用 `resolve(event)` 获取业务响应
|
|
245
|
-
* 6. 附加 `X-Request-Id` 响应头
|
|
246
|
-
*
|
|
247
|
-
* @param config - Handle 配置(均有合理默认值,可零配置使用)
|
|
248
|
-
* @returns SvelteKit Handle 函数
|
|
249
|
-
* @example
|
|
250
|
-
* ```ts
|
|
251
|
-
* import { kit } from '@h-ai/kit'
|
|
252
|
-
*
|
|
253
|
-
* const handle = kit.createHandle({ auth: { verifyToken: async () => null, protectedPaths: ['/admin/**'] } })
|
|
254
|
-
* void handle
|
|
255
|
-
* ```
|
|
256
|
-
*/
|
|
257
|
-
declare function createHandle(config?: HandleConfig): Handle;
|
|
258
|
-
/**
|
|
259
|
-
* 组合多个 SvelteKit handle 为单一 handle
|
|
260
|
-
*
|
|
261
|
-
* 洋葱模型:`sequence(a, b, c)` 执行顺序为 a → b → c → resolve → c → b → a。
|
|
262
|
-
*
|
|
263
|
-
* @param handles - 待组合的 handle 函数列表
|
|
264
|
-
* @returns 组合后的单一 Handle 函数
|
|
265
|
-
* @example
|
|
266
|
-
* ```ts
|
|
267
|
-
* import { kit } from '@h-ai/kit'
|
|
268
|
-
*
|
|
269
|
-
* const handle = kit.sequence(kit.createHandle({ logging: true }), kit.createHandle())
|
|
270
|
-
* void handle
|
|
271
|
-
* ```
|
|
272
|
-
*/
|
|
273
|
-
declare function sequence(...handles: Handle[]): Handle;
|
|
274
|
-
|
|
275
|
-
/** 可直接挂到 SvelteKit catch-all 路由的反馈适配,无 serv 或 Svelte UI 依赖。 */
|
|
276
|
-
|
|
277
|
-
/**
|
|
278
|
-
* 反馈服务及可信范围解析。resolveContext 必须使用已验证 session/宿主策略。
|
|
279
|
-
* @example
|
|
280
|
-
* ```ts
|
|
281
|
-
* import type { FeedbackHandlerOptions } from '@h-ai/kit'
|
|
282
|
-
* import { feedback } from '@h-ai/feedback'
|
|
283
|
-
* const options: FeedbackHandlerOptions = { feedback, resolveContext: () => null }
|
|
284
|
-
* // 应用实现真实 session 映射;null 拒绝访问,不能从 JSON 取得身份。
|
|
285
|
-
* ```
|
|
286
|
-
*/
|
|
287
|
-
interface FeedbackHandlerOptions {
|
|
288
|
-
readonly feedback: FeedbackFunctions;
|
|
289
|
-
readonly resolveContext: (event: RequestEvent) => FeedbackContext | null | Promise<FeedbackContext | null>;
|
|
290
|
-
readonly basePath?: string;
|
|
291
|
-
}
|
|
292
|
-
/**
|
|
293
|
-
* 装配反馈 REST 路由;默认路径 /api/feedback,由宿主 handle 保持 CSRF、认证和传输加密。
|
|
294
|
-
* @param options - 已初始化服务与可信范围映射。
|
|
295
|
-
* @returns 可赋值给 catch-all 路由 GET/POST/PATCH 的同一 handler。
|
|
296
|
-
* @example
|
|
297
|
-
* ```ts
|
|
298
|
-
* import { kit } from '@h-ai/kit'
|
|
299
|
-
* import { feedback } from '@h-ai/feedback'
|
|
300
|
-
* const handler = kit.createFeedbackHandler({ feedback, resolveContext: () => null })
|
|
301
|
-
* // 路由 export const GET = handler;真实应用从受信 session 返回范围,null 默认拒绝。
|
|
302
|
-
* ```
|
|
303
|
-
*/
|
|
304
|
-
declare function createFeedbackHandler(options: FeedbackHandlerOptions): RequestHandler;
|
|
305
|
-
|
|
306
|
-
/**
|
|
307
|
-
* 应用路由直接导出对应 handler;认证 ops 仍由 createHandle 注入。
|
|
308
|
-
* @param iam - 已由应用初始化的 IAM 服务对象。
|
|
309
|
-
* @returns 标准认证端点的 RequestHandler 集合。
|
|
310
|
-
* @example 模块内部上下文
|
|
311
|
-
* ```ts
|
|
312
|
-
* function build(iam: IamFunctions) {
|
|
313
|
-
* return createAuthApi(iam) // 调用方负责初始化 IAM;工厂只装配 handler。
|
|
314
|
-
* }
|
|
315
|
-
* ```
|
|
316
|
-
*/
|
|
317
|
-
declare function createAuthApi(iam: IamFunctions): {
|
|
318
|
-
closeSession: _sveltejs_kit.RequestHandler;
|
|
319
|
-
createCaptcha: _sveltejs_kit.RequestHandler;
|
|
320
|
-
reauthenticate: _sveltejs_kit.RequestHandler;
|
|
321
|
-
publicConfig: _sveltejs_kit.RequestHandler;
|
|
322
|
-
renewPassword: _sveltejs_kit.RequestHandler;
|
|
323
|
-
login: _sveltejs_kit.RequestHandler;
|
|
324
|
-
loginWithLdap: _sveltejs_kit.RequestHandler;
|
|
325
|
-
loginWithOtp: _sveltejs_kit.RequestHandler;
|
|
326
|
-
register: _sveltejs_kit.RequestHandler;
|
|
327
|
-
sendOtp: _sveltejs_kit.RequestHandler;
|
|
328
|
-
requestPasswordReset: _sveltejs_kit.RequestHandler;
|
|
329
|
-
confirmPasswordReset: _sveltejs_kit.RequestHandler;
|
|
330
|
-
};
|
|
331
|
-
|
|
332
|
-
/**
|
|
333
|
-
* @h-ai/kit — API Handler 包装器
|
|
334
|
-
*
|
|
335
|
-
* 统一封装 SvelteKit API Handler 的错误处理逻辑。
|
|
336
|
-
* @module kit-handler
|
|
337
|
-
*/
|
|
338
|
-
|
|
339
|
-
/**
|
|
340
|
-
* 创建 API Handler 包装器
|
|
341
|
-
*
|
|
342
|
-
* 将业务逻辑包裹在统一的异常边界中:
|
|
343
|
-
* 1. 正常执行 `fn(event)` 返回 Response
|
|
344
|
-
* 2. 若 `fn` throw 了 `Response`(如 `kit.guard.require` / `kit.validate.body`),直接返回该 Response
|
|
345
|
-
* 3. 若 `fn` throw 了 SvelteKit 控制流(`redirect()` / `error()`),继续抛出
|
|
346
|
-
* 4. 其他异常:记录日志 → 返回 `kit.response.internalError()`
|
|
347
|
-
*
|
|
348
|
-
* @param fn - 业务处理函数
|
|
349
|
-
* @returns SvelteKit RequestHandler
|
|
350
|
-
* @example
|
|
351
|
-
* ```ts
|
|
352
|
-
* import { kit } from '@h-ai/kit'
|
|
353
|
-
*
|
|
354
|
-
* const GET = kit.handler(() => kit.response.ok({ healthy: true }))
|
|
355
|
-
* void GET
|
|
356
|
-
* ```
|
|
357
|
-
*/
|
|
358
|
-
declare function handler(fn: (event: RequestEvent) => Promise<Response> | Response): RequestHandler;
|
|
359
|
-
|
|
360
|
-
/**
|
|
361
|
-
* @h-ai/kit — API 响应工具
|
|
362
|
-
*
|
|
363
|
-
* 标准化 API 响应工具集,统一 `{ success, data?, error?, requestId? }` 结构。
|
|
364
|
-
* 提供成功响应(ok / created / noContent)、错误响应
|
|
365
|
-
* (badRequest / unauthorized / forbidden / notFound / conflict / validationError / internalError)
|
|
366
|
-
* 以及重定向响应。
|
|
367
|
-
* @module kit-response
|
|
368
|
-
*/
|
|
369
|
-
|
|
370
|
-
/**
|
|
371
|
-
* 创建 200 成功响应
|
|
372
|
-
*
|
|
373
|
-
* @param data - 响应数据,序列化为 JSON
|
|
374
|
-
* @param requestId - 可选请求 ID,用于链路追踪
|
|
375
|
-
* @returns `{ success: true, data, requestId }` 格式的 JSON Response
|
|
376
|
-
* @example
|
|
377
|
-
* ```ts
|
|
378
|
-
* import { kit } from '@h-ai/kit'
|
|
379
|
-
*
|
|
380
|
-
* const response = kit.response.ok({ id: 'article_1' })
|
|
381
|
-
* void response.status
|
|
382
|
-
* ```
|
|
383
|
-
*/
|
|
384
|
-
declare function ok<T>(data: T, requestId?: string): Response;
|
|
385
|
-
/**
|
|
386
|
-
* 创建 201 资源创建成功响应
|
|
387
|
-
*
|
|
388
|
-
* @param data - 新创建的资源数据
|
|
389
|
-
* @param requestId - 可选请求 ID
|
|
390
|
-
* @returns `{ success: true, data }` 格式的 JSON Response(status 201)
|
|
391
|
-
* @example
|
|
392
|
-
* ```ts
|
|
393
|
-
* import { kit } from '@h-ai/kit'
|
|
394
|
-
*
|
|
395
|
-
* const response = kit.response.created({ id: 'article_1' })
|
|
396
|
-
* void response.status
|
|
397
|
-
* ```
|
|
398
|
-
*/
|
|
399
|
-
declare function created<T>(data: T, requestId?: string): Response;
|
|
400
|
-
/**
|
|
401
|
-
* 创建 204 无内容响应
|
|
402
|
-
*
|
|
403
|
-
* 通常用于 DELETE 成功或无返回值的更新操作。
|
|
404
|
-
*
|
|
405
|
-
* @returns 空 body、status 204 的 Response
|
|
406
|
-
* @example
|
|
407
|
-
* ```ts
|
|
408
|
-
* import { kit } from '@h-ai/kit'
|
|
409
|
-
*
|
|
410
|
-
* const response = kit.response.noContent()
|
|
411
|
-
* void response.status
|
|
412
|
-
* ```
|
|
413
|
-
*/
|
|
414
|
-
declare function noContent(): Response;
|
|
415
|
-
/**
|
|
416
|
-
* 创建自定义错误响应
|
|
417
|
-
*
|
|
418
|
-
* @param code - 错误码(如 `'CUSTOM_ERROR'`)
|
|
419
|
-
* @param message - 人可读错误消息
|
|
420
|
-
* @param status - HTTP 状态码,默认 400
|
|
421
|
-
* @param requestId - 可选请求 ID
|
|
422
|
-
* @param details - 可选额外详情
|
|
423
|
-
* @returns `{ success: false, error: { code, message, details } }` 格式的 JSON Response
|
|
424
|
-
* @example
|
|
425
|
-
* ```ts
|
|
426
|
-
* import { kit } from '@h-ai/kit'
|
|
427
|
-
*
|
|
428
|
-
* const response = kit.response.error('ARTICLE_MISSING', 'Article missing', 404)
|
|
429
|
-
* void response.status
|
|
430
|
-
* ```
|
|
431
|
-
*/
|
|
432
|
-
declare function error(code: string, message: string, status?: number, requestId?: string, details?: unknown): Response;
|
|
433
|
-
/**
|
|
434
|
-
* 创建 400 Bad Request 响应
|
|
435
|
-
*
|
|
436
|
-
* @param message - 错误消息
|
|
437
|
-
* @param requestId - 可选请求 ID
|
|
438
|
-
* @param details - 可选额外详情
|
|
439
|
-
* @returns error code 为 `'BAD_REQUEST'` 的 JSON Response
|
|
440
|
-
* @example
|
|
441
|
-
* ```ts
|
|
442
|
-
* import { kit } from '@h-ai/kit'
|
|
443
|
-
*
|
|
444
|
-
* const response = kit.response.badRequest('Invalid article')
|
|
445
|
-
* void response.status
|
|
446
|
-
* ```
|
|
447
|
-
*/
|
|
448
|
-
declare function badRequest(message: string, requestId?: string, details?: unknown): Response;
|
|
449
|
-
/**
|
|
450
|
-
* 创建 401 Unauthorized 响应
|
|
451
|
-
*
|
|
452
|
-
* @param message - 错误消息,默认 `'Authentication required'`
|
|
453
|
-
* @param requestId - 可选请求 ID
|
|
454
|
-
* @returns error code 为 `'UNAUTHORIZED'` 的 JSON Response
|
|
455
|
-
* @example
|
|
456
|
-
* ```ts
|
|
457
|
-
* import { kit } from '@h-ai/kit'
|
|
458
|
-
*
|
|
459
|
-
* const response = kit.response.unauthorized()
|
|
460
|
-
* void response.status
|
|
461
|
-
* ```
|
|
462
|
-
*/
|
|
463
|
-
declare function unauthorized(message?: string, requestId?: string): Response;
|
|
464
|
-
/**
|
|
465
|
-
* 创建 403 Forbidden 响应
|
|
466
|
-
*
|
|
467
|
-
* @param message - 错误消息,默认 `'Access denied'`
|
|
468
|
-
* @param requestId - 可选请求 ID
|
|
469
|
-
* @returns error code 为 `'FORBIDDEN'` 的 JSON Response
|
|
470
|
-
* @example
|
|
471
|
-
* ```ts
|
|
472
|
-
* import { kit } from '@h-ai/kit'
|
|
473
|
-
*
|
|
474
|
-
* const response = kit.response.forbidden()
|
|
475
|
-
* void response.status
|
|
476
|
-
* ```
|
|
477
|
-
*/
|
|
478
|
-
declare function forbidden(message?: string, requestId?: string): Response;
|
|
479
|
-
/**
|
|
480
|
-
* 创建 404 Not Found 响应
|
|
481
|
-
*
|
|
482
|
-
* @param message - 错误消息,默认 `'Resource not found'`
|
|
483
|
-
* @param requestId - 可选请求 ID
|
|
484
|
-
* @returns error code 为 `'NOT_FOUND'` 的 JSON Response
|
|
485
|
-
* @example
|
|
486
|
-
* ```ts
|
|
487
|
-
* import { kit } from '@h-ai/kit'
|
|
488
|
-
*
|
|
489
|
-
* const response = kit.response.notFound()
|
|
490
|
-
* void response.status
|
|
491
|
-
* ```
|
|
492
|
-
*/
|
|
493
|
-
declare function notFound(message?: string, requestId?: string): Response;
|
|
494
|
-
/**
|
|
495
|
-
* 创建 409 Conflict 响应
|
|
496
|
-
*
|
|
497
|
-
* @param message - 冲突描述(如重复创建等)
|
|
498
|
-
* @param requestId - 可选请求 ID
|
|
499
|
-
* @returns error code 为 `'CONFLICT'` 的 JSON Response
|
|
500
|
-
* @example
|
|
501
|
-
* ```ts
|
|
502
|
-
* import { kit } from '@h-ai/kit'
|
|
503
|
-
*
|
|
504
|
-
* const response = kit.response.conflict('Already updated')
|
|
505
|
-
* void response.status
|
|
506
|
-
* ```
|
|
507
|
-
*/
|
|
508
|
-
declare function conflict(message: string, requestId?: string): Response;
|
|
509
|
-
/**
|
|
510
|
-
* 创建 422 Unprocessable Entity 响应(验证错误)
|
|
511
|
-
*
|
|
512
|
-
* @param errors - 字段级别的验证错误列表
|
|
513
|
-
* @param requestId - 可选请求 ID
|
|
514
|
-
* @returns error code 为 `'VALIDATION_ERROR'`,details 包含 `errors` 数组
|
|
515
|
-
* @example
|
|
516
|
-
* ```ts
|
|
517
|
-
* import { kit } from '@h-ai/kit'
|
|
518
|
-
*
|
|
519
|
-
* const response = kit.response.validationError([{ field: 'title', message: 'Title is required' }])
|
|
520
|
-
* void response.status
|
|
521
|
-
* ```
|
|
522
|
-
*/
|
|
523
|
-
declare function validationError(errors: Array<{
|
|
524
|
-
field: string;
|
|
525
|
-
message: string;
|
|
526
|
-
}>, requestId?: string): Response;
|
|
527
|
-
/**
|
|
528
|
-
* 创建 500 Internal Server Error 响应
|
|
529
|
-
*
|
|
530
|
-
* @param message - 错误消息,默认 `'Internal server error'`
|
|
531
|
-
* @param requestId - 可选请求 ID
|
|
532
|
-
* @returns error code 为 `'INTERNAL_ERROR'` 的 JSON Response
|
|
533
|
-
* @example
|
|
534
|
-
* ```ts
|
|
535
|
-
* import { kit } from '@h-ai/kit'
|
|
536
|
-
*
|
|
537
|
-
* const response = kit.response.internalError()
|
|
538
|
-
* void response.status
|
|
539
|
-
* ```
|
|
540
|
-
*/
|
|
541
|
-
declare function internalError(message?: string, requestId?: string): Response;
|
|
542
|
-
/**
|
|
543
|
-
* 创建重定向响应
|
|
544
|
-
*
|
|
545
|
-
* @param url - 目标 URL
|
|
546
|
-
* @param status - HTTP 状态码,默认 302;常用 303(POST 后重定向)
|
|
547
|
-
* @returns 带 `Location` 头的空 body Response
|
|
548
|
-
* @example
|
|
549
|
-
* ```ts
|
|
550
|
-
* import { kit } from '@h-ai/kit'
|
|
551
|
-
*
|
|
552
|
-
* const response = kit.response.redirect('/articles', 303)
|
|
553
|
-
* void response.status
|
|
554
|
-
* ```
|
|
555
|
-
*/
|
|
556
|
-
declare function redirect(url: string, status?: 301 | 302 | 303 | 307 | 308): Response;
|
|
557
|
-
/**
|
|
558
|
-
* 将 HaiResult<T> 转换为标准 API Response
|
|
559
|
-
*
|
|
560
|
-
* 成功时返回 200 ok(data),失败时从 error 对象中提取 code、message,
|
|
561
|
-
* 并根据 httpStatusMap 映射 HTTP 状态码(未命中时默认 400)。
|
|
562
|
-
*
|
|
563
|
-
* @param result - core HaiResult 对象({ success, data } 或 { success: false, error })
|
|
564
|
-
* @param httpStatusMap - 模块导出的错误码 → HTTP 状态码映射表(如 IamErrorHttpStatus)
|
|
565
|
-
* @param requestId - 可选请求 ID,用于链路追踪
|
|
566
|
-
* @returns 标准化 JSON Response
|
|
567
|
-
* @example
|
|
568
|
-
* ```ts
|
|
569
|
-
* import { kit } from '@h-ai/kit'
|
|
570
|
-
*
|
|
571
|
-
* const response = kit.response.fromResult({ success: true, data: { id: 'article_1' } })
|
|
572
|
-
* void response.status
|
|
573
|
-
* ```
|
|
574
|
-
*/
|
|
575
|
-
declare function fromResult<T>(result: {
|
|
576
|
-
success: true;
|
|
577
|
-
data: T;
|
|
578
|
-
} | {
|
|
579
|
-
success: false;
|
|
580
|
-
error: {
|
|
581
|
-
code: number | string;
|
|
582
|
-
message: string;
|
|
583
|
-
[key: string]: unknown;
|
|
584
|
-
};
|
|
585
|
-
}, httpStatusMap?: Record<number | string, number>, requestId?: string): Response;
|
|
586
|
-
/**
|
|
587
|
-
* 按模块错误的 HTTP 状态构建安全的统一 API 错误响应。
|
|
588
|
-
* @param haiError - 包含 code、message 和可选 httpStatus 的模块错误。
|
|
589
|
-
* @param requestId - 可选的请求追踪标识。
|
|
590
|
-
* @returns 包含统一错误结构和对应 HTTP 状态的 Response。
|
|
591
|
-
* @example
|
|
592
|
-
* ```ts
|
|
593
|
-
* import { kit } from '@h-ai/kit'
|
|
594
|
-
*
|
|
595
|
-
* const response = kit.response.fromError({ code: 'app:articles:001', message: 'Article missing', httpStatus: 404 })
|
|
596
|
-
* void response.status
|
|
597
|
-
* ```
|
|
598
|
-
*/
|
|
599
|
-
declare function fromError(haiError: HaiError, requestId?: string): Response;
|
|
600
|
-
|
|
601
|
-
/**
|
|
602
|
-
* @h-ai/kit — 请求数据验证
|
|
115
|
+
* @h-ai/kit — 服务对象主入口
|
|
603
116
|
*
|
|
604
|
-
*
|
|
605
|
-
*
|
|
606
|
-
* 等模块重复维护同一套 issue 解析与消息映射逻辑;模块前缀映射也统一交给
|
|
607
|
-
* `core.zodValidation.createPrefixedZodMessageGetter()` 处理。
|
|
608
|
-
* 每种数据源都提供两类 API:
|
|
609
|
-
* - 安全返回:`FormValidationResult`
|
|
610
|
-
* - 失败抛出:`OrFail`(抛出 `Response`,由 kit.handler 作为 API 控制流处理)
|
|
611
|
-
* @module kit-validation
|
|
612
|
-
*/
|
|
613
|
-
|
|
614
|
-
/**
|
|
615
|
-
* 从 Request 解析并验证表单数据,失败时 throw Response
|
|
616
|
-
*
|
|
617
|
-
* 与 `validateForm` 功能相同,但校验失败时 throw 400 Response(SvelteKit 控制流),
|
|
618
|
-
* 搭配 `kit.handler()` 使用可精简 handler 代码。
|
|
619
|
-
*
|
|
620
|
-
* @param request - SvelteKit 请求对象
|
|
621
|
-
* @param schema - Zod Schema
|
|
622
|
-
* @returns 校验通过的数据(类型安全)
|
|
623
|
-
* @throws Response - 400 BadRequest(含首条错误消息)
|
|
624
|
-
* @example 模块内部上下文
|
|
625
|
-
* ```ts
|
|
626
|
-
* const schema = zod.object({ title: zod.string().min(1) })
|
|
627
|
-
* const result = await validateFormOrFail(new Request('https://app.example.com/api', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ title: 'Example' }) }), schema)
|
|
628
|
-
* // 校验失败抛出 Response,由框架错误边界透传。
|
|
629
|
-
* void result.title
|
|
630
|
-
* ```
|
|
631
|
-
*/
|
|
632
|
-
declare function validateFormOrFail<T extends z.ZodType>(request: Request, schema: T): Promise<z.infer<T>>;
|
|
633
|
-
/**
|
|
634
|
-
* 从 URL 查询参数验证,失败时 throw Response
|
|
635
|
-
*
|
|
636
|
-
* @param url - 请求 URL 对象
|
|
637
|
-
* @param schema - Zod Schema
|
|
638
|
-
* @returns 校验通过的数据
|
|
639
|
-
* @throws Response - 400 BadRequest
|
|
640
|
-
* @example 模块内部上下文
|
|
641
|
-
* ```ts
|
|
642
|
-
* const schema = zod.object({ title: zod.string().min(1) })
|
|
643
|
-
* const result = validateQueryOrFail(new URL('https://app.example.com/articles?title=Example'), schema)
|
|
644
|
-
* // 校验失败抛出 Response,由框架错误边界透传。
|
|
645
|
-
* void result.title
|
|
646
|
-
* ```
|
|
647
|
-
*/
|
|
648
|
-
declare function validateQueryOrFail<T extends z.ZodType>(url: URL, schema: T): z.infer<T>;
|
|
649
|
-
/**
|
|
650
|
-
* 验证路径参数,失败时 throw Response
|
|
651
|
-
*
|
|
652
|
-
* @param params - SvelteKit 路由参数
|
|
653
|
-
* @param schema - Zod Schema
|
|
654
|
-
* @returns 校验通过的数据
|
|
655
|
-
* @throws Response - 400 BadRequest
|
|
656
|
-
* @example 模块内部上下文
|
|
657
|
-
* ```ts
|
|
658
|
-
* const schema = zod.object({ title: zod.string().min(1) })
|
|
659
|
-
* const result = validateParamsOrFail({ title: 'Example' }, schema)
|
|
660
|
-
* // 校验失败抛出 Response,由框架错误边界透传。
|
|
661
|
-
* void result.title
|
|
662
|
-
* ```
|
|
663
|
-
*/
|
|
664
|
-
declare function validateParamsOrFail<T extends z.ZodType>(params: Record<string, string>, schema: T): z.infer<T>;
|
|
665
|
-
/**
|
|
666
|
-
* 路径参数 id 校验 Schema
|
|
667
|
-
*
|
|
668
|
-
* 验证 `event.params.id` 为非空字符串。
|
|
669
|
-
* @example
|
|
670
|
-
* ```ts
|
|
671
|
-
* import { IdParamSchema } from '@h-ai/kit'
|
|
672
|
-
*
|
|
673
|
-
* const value = IdParamSchema.parse({ id: 'article_1' })
|
|
674
|
-
* void value
|
|
675
|
-
* ```
|
|
676
|
-
*/
|
|
677
|
-
declare const IdParamSchema: z.ZodObject<{
|
|
678
|
-
id: z.ZodString;
|
|
679
|
-
}, z.core.$strip>;
|
|
680
|
-
/**
|
|
681
|
-
* 通用分页查询参数 Schema
|
|
682
|
-
*
|
|
683
|
-
* 包含 page(默认 1)、pageSize(默认 20,上限 100)、search(可选)。
|
|
684
|
-
* 可通过 `.extend()` 扩展业务字段。
|
|
685
|
-
* @example
|
|
686
|
-
* ```ts
|
|
687
|
-
* import { PaginationQuerySchema } from '@h-ai/kit'
|
|
688
|
-
*
|
|
689
|
-
* const value = PaginationQuerySchema.parse({ page: '1', pageSize: '20' })
|
|
690
|
-
* void value
|
|
691
|
-
* ```
|
|
117
|
+
* SvelteKit 集成模块的统一命名空间出口。 所有功能通过 kit 对象访问:
|
|
118
|
+
* @module kit-main
|
|
692
119
|
*/
|
|
693
|
-
declare const PaginationQuerySchema: z.ZodObject<{
|
|
694
|
-
page: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
|
|
695
|
-
pageSize: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
|
|
696
|
-
search: z.ZodOptional<z.ZodString>;
|
|
697
|
-
}, z.core.$strip>;
|
|
698
120
|
|
|
699
121
|
/**
|
|
700
122
|
* Kit 模块统一出口。
|
|
@@ -709,123 +131,7 @@ declare const PaginationQuerySchema: z.ZodObject<{
|
|
|
709
131
|
* void handle
|
|
710
132
|
* ```
|
|
711
133
|
*/
|
|
712
|
-
declare const kit:
|
|
713
|
-
/** 创建反馈的受控 catch-all HTTP handler,身份范围由宿主解析。 */
|
|
714
|
-
createFeedbackHandler: typeof createFeedbackHandler;
|
|
715
|
-
/** 原子限流工厂;共享store生命周期由应用管理。 */
|
|
716
|
-
middleware: {
|
|
717
|
-
rateLimit: typeof rateLimitMiddleware;
|
|
718
|
-
createCacheRateLimitStore: typeof createCacheRateLimitStore;
|
|
719
|
-
createMemoryRateLimitStore: typeof createMemoryRateLimitStore;
|
|
720
|
-
};
|
|
721
|
-
/** 创建 SvelteKit Handle Hook(含 auth / logging / rateLimit 内置配置) */
|
|
722
|
-
createHandle: typeof createHandle;
|
|
723
|
-
/** 组合多个 Handle */
|
|
724
|
-
sequence: typeof sequence;
|
|
725
|
-
/** API Handler 包装器(自动错误边界) */
|
|
726
|
-
handler: typeof handler;
|
|
727
|
-
guard: {
|
|
728
|
-
/** 选定敏感操作要求单次再鉴别;先调用现有权限与资源守卫。 */
|
|
729
|
-
requireSensitive: typeof requireSensitiveOperation;
|
|
730
|
-
/** 要求权限,不满足时 throw Response(SvelteKit 控制流) */
|
|
731
|
-
require: typeof requirePermission;
|
|
732
|
-
/** 检查会话是否具有指定权限(布尔) */
|
|
733
|
-
check: typeof hasPermission;
|
|
734
|
-
};
|
|
735
|
-
response: {
|
|
736
|
-
/** 200 成功 */
|
|
737
|
-
ok: typeof ok;
|
|
738
|
-
/** 201 创建成功 */
|
|
739
|
-
created: typeof created;
|
|
740
|
-
/** 204 无内容 */
|
|
741
|
-
noContent: typeof noContent;
|
|
742
|
-
/** 自定义错误响应 */
|
|
743
|
-
error: typeof error;
|
|
744
|
-
/** 400 BadRequest */
|
|
745
|
-
badRequest: typeof badRequest;
|
|
746
|
-
/** 401 Unauthorized */
|
|
747
|
-
unauthorized: typeof unauthorized;
|
|
748
|
-
/** 403 Forbidden */
|
|
749
|
-
forbidden: typeof forbidden;
|
|
750
|
-
/** 404 NotFound */
|
|
751
|
-
notFound: typeof notFound;
|
|
752
|
-
/** 409 Conflict */
|
|
753
|
-
conflict: typeof conflict;
|
|
754
|
-
/** 422 验证错误 */
|
|
755
|
-
validationError: typeof validationError;
|
|
756
|
-
/** 500 InternalError */
|
|
757
|
-
internalError: typeof internalError;
|
|
758
|
-
/** 重定向 */
|
|
759
|
-
redirect: typeof redirect;
|
|
760
|
-
/** 将 HaiResult<T> 转为标准 API Response(支持 httpStatusMap) */
|
|
761
|
-
fromResult: typeof fromResult;
|
|
762
|
-
/** 将模块错误码映射为标准 HTTP Response */
|
|
763
|
-
fromError: typeof fromError;
|
|
764
|
-
};
|
|
765
|
-
validate: {
|
|
766
|
-
/** 验证请求体(JSON/表单),失败 throw Response */
|
|
767
|
-
body: typeof validateFormOrFail;
|
|
768
|
-
/** 验证查询参数,失败 throw Response */
|
|
769
|
-
query: typeof validateQueryOrFail;
|
|
770
|
-
/** 验证路径参数,失败 throw Response */
|
|
771
|
-
params: typeof validateParamsOrFail;
|
|
772
|
-
/** 路径参数 id Schema({id: string}) */
|
|
773
|
-
IdParamSchema: zod.ZodObject<{
|
|
774
|
-
id: zod.ZodString;
|
|
775
|
-
}, zod_v4_core.$strip>;
|
|
776
|
-
/** 通用分页查询 Schema(page / pageSize / search) */
|
|
777
|
-
PaginationQuerySchema: zod.ZodObject<{
|
|
778
|
-
page: zod.ZodDefault<zod.ZodCoercedNumber<unknown>>;
|
|
779
|
-
pageSize: zod.ZodDefault<zod.ZodCoercedNumber<unknown>>;
|
|
780
|
-
search: zod.ZodOptional<zod.ZodString>;
|
|
781
|
-
}, zod_v4_core.$strip>;
|
|
782
|
-
};
|
|
783
|
-
client: {
|
|
784
|
-
/** 创建统一客户端(CSRF + 传输加密透明合并) */
|
|
785
|
-
create: typeof createKitClient;
|
|
786
|
-
/** 标准认证表单动作(Cookie 模式)。 */
|
|
787
|
-
createAuthActions: typeof createKitAuthActions;
|
|
788
|
-
/**
|
|
789
|
-
* 用解析后的 {@link KitConfig} 一键安装浏览器端传输加密
|
|
790
|
-
* (应用层推荐入口;内部预热 crypto 并调用 installBrowserTransportFetch)
|
|
791
|
-
*/
|
|
792
|
-
installBrowserTransport: typeof installBrowserTransport;
|
|
793
|
-
/** 底层入口:直接传 transport 配置安装浏览器全局 fetch 包装 */
|
|
794
|
-
installBrowserTransportFetch: typeof installBrowserTransportFetch;
|
|
795
|
-
};
|
|
796
|
-
auth: {
|
|
797
|
-
/** 标准匿名认证端点白名单。 */
|
|
798
|
-
publicPaths: string[];
|
|
799
|
-
/** 标准配置/登录/注册/验证码/重置 handler 集合。 */
|
|
800
|
-
createApi: typeof createAuthApi;
|
|
801
|
-
/** 服务端登录(密码):内部调用 iam.auth.login + 自动写入 Token Cookie */
|
|
802
|
-
login: typeof login;
|
|
803
|
-
/** 服务端登录(OTP 验证码):内部调用 iam.auth.loginWithOtp + 自动写入 Token Cookie */
|
|
804
|
-
loginWithOtp: typeof loginWithOtp;
|
|
805
|
-
/** 服务端登录(LDAP):内部调用 iam.auth.loginWithLdap + 自动写入 Token Cookie */
|
|
806
|
-
loginWithLdap: typeof loginWithLdap;
|
|
807
|
-
/** 服务端登录(API Key):内部调用 iam.auth.loginWithApiKey + 自动写入 Token Cookie */
|
|
808
|
-
loginWithApiKey: typeof loginWithApiKey;
|
|
809
|
-
/** 服务端注册并登录:内部调用 iam.auth.registerAndLogin + 自动写入 Token Cookie */
|
|
810
|
-
registerAndLogin: typeof registerAndLogin;
|
|
811
|
-
/** 服务端登出:内部调用 iam.auth.logout + 清除 Token Cookie */
|
|
812
|
-
logout: typeof logout;
|
|
813
|
-
/** 写入浏览器端 Access Token(客户端 login/register 用) */
|
|
814
|
-
setBrowserToken: typeof setBrowserToken;
|
|
815
|
-
/** 清除浏览器端 Access Token(客户端 logout 用) */
|
|
816
|
-
clearBrowserToken: typeof clearBrowserToken;
|
|
817
|
-
};
|
|
818
|
-
crud: {
|
|
819
|
-
/** 定义 CRUD 资源(声明式配置 → 操作对象) */
|
|
820
|
-
define: typeof defineCrud;
|
|
821
|
-
};
|
|
822
|
-
i18n: {
|
|
823
|
-
/** 统一设置所有 hai 模块的默认语言 */
|
|
824
|
-
setLocale: typeof setAllModulesLocale;
|
|
825
|
-
/** 请求/SSR 语言隔离;异步处理使用同一请求上下文。 */
|
|
826
|
-
runWithLocale: <T>(locale: _h_ai_core.Locale, operation: () => T) => T;
|
|
827
|
-
};
|
|
828
|
-
};
|
|
134
|
+
declare const kit: KitFunctions;
|
|
829
135
|
|
|
830
136
|
/**
|
|
831
137
|
* @h-ai/kit — 日志中间件
|
|
@@ -854,4 +160,5 @@ interface LoggingMiddlewareConfig {
|
|
|
854
160
|
redactFields?: string[];
|
|
855
161
|
}
|
|
856
162
|
|
|
857
|
-
export {
|
|
163
|
+
export { KitFunctions, SessionData, kit };
|
|
164
|
+
export type { AuthGuardConfig, CookieProxyConfig, LoggingMiddlewareConfig, RoleGuardConfig, SessionGuardConfig };
|