@h-ai/kit 0.1.0-alpha.67 → 0.1.0-alpha.68
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 +39 -13
- package/README.ja.md +39 -13
- package/README.md +39 -13
- package/dist/adapter/index.d.ts +17 -2
- package/dist/adapter/index.js.map +1 -1
- package/dist/browser.d.ts +12 -6
- package/dist/browser.js +6 -7
- package/dist/browser.js.map +1 -1
- package/dist/{chunk-DVW7CQ3H.js → chunk-2PWGJCWX.js} +3 -3
- package/dist/chunk-2PWGJCWX.js.map +1 -0
- package/dist/{chunk-VOTDAVCB.js → chunk-2YYRP7HH.js} +17 -33
- package/dist/chunk-2YYRP7HH.js.map +1 -0
- package/dist/{chunk-MLSP67JF.js → chunk-333FGMGQ.js} +59 -111
- package/dist/chunk-333FGMGQ.js.map +1 -0
- package/dist/chunk-OVRZIDCD.js +175 -0
- package/dist/chunk-OVRZIDCD.js.map +1 -0
- package/dist/{chunk-L7BTMAKX.js → chunk-P6XH7G4N.js} +3 -6
- package/dist/chunk-P6XH7G4N.js.map +1 -0
- package/dist/{chunk-NVYIUBU7.js → chunk-XC7I2L3G.js} +2 -2
- package/dist/chunk-XC7I2L3G.js.map +1 -0
- package/dist/client/index.d.ts +47 -1
- package/dist/client/index.js +3 -3
- package/dist/client/index.js.map +1 -1
- package/dist/index.d.ts +217 -347
- package/dist/index.js +138 -83
- package/dist/index.js.map +1 -1
- package/dist/kit-a2a-types-CwT1AFQu.d.ts +136 -0
- package/dist/{index-B7s-0mZl.d.ts → kit-client-auth-HnZIYUia.d.ts} +220 -101
- package/dist/kit-crypto-types-Dd24aJ4m.d.ts +194 -0
- package/dist/{kit-i18n-D9Qqk-1k.d.ts → kit-i18n-DEzmzE5T.d.ts} +142 -29
- package/dist/{kit-types-ByWdbCeO.d.ts → kit-types-CnzhN-AS.d.ts} +240 -162
- package/dist/modules/a2a/index.d.ts +13 -111
- package/dist/modules/a2a/index.js +2 -2
- package/dist/modules/crypto/index.d.ts +28 -195
- package/dist/modules/crypto/index.js +3 -3
- package/dist/modules/crypto/index.js.map +1 -1
- package/package.json +10 -10
- package/dist/chunk-DVW7CQ3H.js.map +0 -1
- package/dist/chunk-L7BTMAKX.js.map +0 -1
- package/dist/chunk-MLSP67JF.js.map +0 -1
- package/dist/chunk-NVYIUBU7.js.map +0 -1
- package/dist/chunk-QHYNL24G.js +0 -117
- package/dist/chunk-QHYNL24G.js.map +0 -1
- package/dist/chunk-VOTDAVCB.js.map +0 -1
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
import { TransportServerKeyRing, CryptoFunctions, TransportKeyStore } from '@h-ai/crypto';
|
|
2
|
+
import { RequestEvent } from '@sveltejs/kit';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @h-ai/kit — Crypto 类型定义
|
|
6
|
+
*
|
|
7
|
+
* Crypto 模块集成相关类型
|
|
8
|
+
* @module kit-crypto-types
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* 辅助函数所需的异步加密依赖结构;实际服务需由应用适配,不等同于 @h-ai/crypto 的公开接口。
|
|
13
|
+
* @example
|
|
14
|
+
* ```ts
|
|
15
|
+
* import type { CryptoServiceLike } from '@h-ai/kit'
|
|
16
|
+
*
|
|
17
|
+
* async function verify(crypto: CryptoServiceLike, body: string, secret: string, signature: string) {
|
|
18
|
+
* const result = await crypto.hmac.verify(body, secret, signature, 'sha256')
|
|
19
|
+
* return result.success && result.data === true
|
|
20
|
+
* }
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
interface CryptoServiceLike {
|
|
24
|
+
hmac: {
|
|
25
|
+
sign: (data: string, key: string, algorithm?: string) => Promise<{
|
|
26
|
+
success: boolean;
|
|
27
|
+
data?: string;
|
|
28
|
+
error?: {
|
|
29
|
+
code: number;
|
|
30
|
+
message: string;
|
|
31
|
+
};
|
|
32
|
+
}>;
|
|
33
|
+
verify: (data: string, key: string, signature: string, algorithm?: string) => Promise<{
|
|
34
|
+
success: boolean;
|
|
35
|
+
data?: boolean;
|
|
36
|
+
error?: {
|
|
37
|
+
code: number;
|
|
38
|
+
message: string;
|
|
39
|
+
};
|
|
40
|
+
}>;
|
|
41
|
+
};
|
|
42
|
+
hash: {
|
|
43
|
+
digest: (data: string, algorithm?: string) => Promise<{
|
|
44
|
+
success: boolean;
|
|
45
|
+
data?: string;
|
|
46
|
+
error?: {
|
|
47
|
+
code: number;
|
|
48
|
+
message: string;
|
|
49
|
+
};
|
|
50
|
+
}>;
|
|
51
|
+
timingSafeEqual: (a: string, b: string) => Promise<{
|
|
52
|
+
success: boolean;
|
|
53
|
+
data?: boolean;
|
|
54
|
+
error?: {
|
|
55
|
+
code: number;
|
|
56
|
+
message: string;
|
|
57
|
+
};
|
|
58
|
+
}>;
|
|
59
|
+
};
|
|
60
|
+
aes: {
|
|
61
|
+
encrypt: (data: string, key: string) => Promise<{
|
|
62
|
+
success: boolean;
|
|
63
|
+
data?: string;
|
|
64
|
+
error?: {
|
|
65
|
+
code: number;
|
|
66
|
+
message: string;
|
|
67
|
+
};
|
|
68
|
+
}>;
|
|
69
|
+
decrypt: (data: string, key: string) => Promise<{
|
|
70
|
+
success: boolean;
|
|
71
|
+
data?: string;
|
|
72
|
+
error?: {
|
|
73
|
+
code: number;
|
|
74
|
+
message: string;
|
|
75
|
+
};
|
|
76
|
+
}>;
|
|
77
|
+
};
|
|
78
|
+
random: {
|
|
79
|
+
bytes: (length: number) => Promise<{
|
|
80
|
+
success: boolean;
|
|
81
|
+
data?: Uint8Array;
|
|
82
|
+
error?: {
|
|
83
|
+
code: number;
|
|
84
|
+
message: string;
|
|
85
|
+
};
|
|
86
|
+
}>;
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Webhook 验证配置
|
|
91
|
+
* @example
|
|
92
|
+
* ```ts
|
|
93
|
+
* import type { WebhookVerifyConfig } from '@h-ai/kit'
|
|
94
|
+
*
|
|
95
|
+
* function signatureHeader(config: WebhookVerifyConfig) { return config.event.request.headers.get(config.signatureHeader ?? 'X-Signature') }
|
|
96
|
+
* ```
|
|
97
|
+
*/
|
|
98
|
+
interface WebhookVerifyConfig {
|
|
99
|
+
/** Crypto 服务实例 */
|
|
100
|
+
crypto: CryptoServiceLike;
|
|
101
|
+
/** 请求事件 */
|
|
102
|
+
event: RequestEvent;
|
|
103
|
+
/** 签名密钥 */
|
|
104
|
+
secretKey: string;
|
|
105
|
+
/** 签名头名称 */
|
|
106
|
+
signatureHeader?: string;
|
|
107
|
+
/** 算法 */
|
|
108
|
+
algorithm?: 'sha256' | 'sha512';
|
|
109
|
+
/** 编码 */
|
|
110
|
+
encoding?: 'hex' | 'base64';
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* CSRF 配置
|
|
114
|
+
* @example
|
|
115
|
+
* ```ts
|
|
116
|
+
* import type { CryptoCsrfConfig } from '@h-ai/kit'
|
|
117
|
+
*
|
|
118
|
+
* function tokenSize(config: CryptoCsrfConfig) { return config.tokenLength ?? 32 }
|
|
119
|
+
* ```
|
|
120
|
+
*/
|
|
121
|
+
interface CryptoCsrfConfig {
|
|
122
|
+
/** Crypto 服务实例 */
|
|
123
|
+
crypto: CryptoServiceLike;
|
|
124
|
+
/** Cookie 名称 */
|
|
125
|
+
cookieName?: string;
|
|
126
|
+
/** Header 名称 */
|
|
127
|
+
headerName?: string;
|
|
128
|
+
/** 表单字段名称 */
|
|
129
|
+
formFieldName?: string;
|
|
130
|
+
/** Token 长度 */
|
|
131
|
+
tokenLength?: number;
|
|
132
|
+
/** Cookie 选项 */
|
|
133
|
+
cookieOptions?: {
|
|
134
|
+
path?: string;
|
|
135
|
+
httpOnly?: boolean;
|
|
136
|
+
secure?: boolean;
|
|
137
|
+
sameSite?: 'strict' | 'lax' | 'none';
|
|
138
|
+
maxAge?: number;
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* 加密 Cookie 配置
|
|
143
|
+
* @example
|
|
144
|
+
* ```ts
|
|
145
|
+
* import type { EncryptedCookieConfig } from '@h-ai/kit'
|
|
146
|
+
*
|
|
147
|
+
* function assertKey(config: EncryptedCookieConfig) {
|
|
148
|
+
* if (!config.encryptionKey) throw new Error('Encryption key required')
|
|
149
|
+
* }
|
|
150
|
+
* ```
|
|
151
|
+
*/
|
|
152
|
+
interface EncryptedCookieConfig {
|
|
153
|
+
/** Crypto 服务实例 */
|
|
154
|
+
crypto: CryptoServiceLike;
|
|
155
|
+
/** 加密密钥 */
|
|
156
|
+
encryptionKey: string;
|
|
157
|
+
/** Cookie 选项 */
|
|
158
|
+
cookieOptions?: {
|
|
159
|
+
path?: string;
|
|
160
|
+
httpOnly?: boolean;
|
|
161
|
+
secure?: boolean;
|
|
162
|
+
sameSite?: 'strict' | 'lax' | 'none';
|
|
163
|
+
maxAge?: number;
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* 传输加密配置。
|
|
169
|
+
*
|
|
170
|
+
* kit 不再维护本地加解密实现;服务端管理器由 `crypto.transport.createServer()` 创建,
|
|
171
|
+
* 协议常量与载荷类型统一来自 `@h-ai/crypto`。
|
|
172
|
+
* @example
|
|
173
|
+
* ```ts
|
|
174
|
+
* import type { TransportEncryptionConfig } from '@h-ai/kit'
|
|
175
|
+
*
|
|
176
|
+
* function publicPaths(config: TransportEncryptionConfig) { return config.excludePaths ?? [] }
|
|
177
|
+
* ```
|
|
178
|
+
*/
|
|
179
|
+
interface TransportEncryptionConfig {
|
|
180
|
+
/** 受管服务端密钥环,仅从服务端 Secret 注入,不放公开 kit 配置。 */
|
|
181
|
+
serverKeyRing: TransportServerKeyRing;
|
|
182
|
+
/** 是否启用传输加密(默认 false) */
|
|
183
|
+
enabled: boolean;
|
|
184
|
+
/** @h-ai/crypto 服务实例 */
|
|
185
|
+
crypto: CryptoFunctions;
|
|
186
|
+
/** 密钥交换端点路径(默认 `/api/_hai/key-exchange`) */
|
|
187
|
+
keyExchangePath?: string;
|
|
188
|
+
/** 排除路径(不加密),支持精确匹配和前缀匹配 */
|
|
189
|
+
excludePaths?: string[];
|
|
190
|
+
/** 显式客户端公钥存储;生产使用共享 Redis/reldb,内存仅供开发/测试。 */
|
|
191
|
+
keyStore: TransportKeyStore;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
export type { CryptoCsrfConfig as C, EncryptedCookieConfig as E, TransportEncryptionConfig as T, WebhookVerifyConfig as W, CryptoServiceLike as a };
|
|
@@ -4,9 +4,27 @@
|
|
|
4
4
|
* 声明式 CRUD 资源定义所需的全部类型。
|
|
5
5
|
* @module kit-crud-types
|
|
6
6
|
*/
|
|
7
|
-
/**
|
|
7
|
+
/**
|
|
8
|
+
* 支持的字段类型
|
|
9
|
+
* @example
|
|
10
|
+
* ```ts
|
|
11
|
+
* import type { CrudFieldType } from '@h-ai/kit'
|
|
12
|
+
*
|
|
13
|
+
* const value: CrudFieldType = 'date-range'
|
|
14
|
+
* void value
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
8
17
|
type CrudFieldType = 'string' | 'number' | 'boolean' | 'date' | 'date-range' | 'datetime' | 'email' | 'url' | 'tel' | 'password' | 'textarea' | 'select' | 'multi-select' | 'radio' | 'checkbox' | 'custom';
|
|
9
|
-
/**
|
|
18
|
+
/**
|
|
19
|
+
* 字段校验规则
|
|
20
|
+
* @example
|
|
21
|
+
* ```ts
|
|
22
|
+
* import type { CrudFieldValidation } from '@h-ai/kit'
|
|
23
|
+
*
|
|
24
|
+
* const value: CrudFieldValidation = { required: true, max: 120 }
|
|
25
|
+
* void value
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
10
28
|
interface CrudFieldValidation {
|
|
11
29
|
/** 是否必填 */
|
|
12
30
|
required?: boolean;
|
|
@@ -19,16 +37,52 @@ interface CrudFieldValidation {
|
|
|
19
37
|
/** 自定义错误提示 */
|
|
20
38
|
message?: CrudText;
|
|
21
39
|
}
|
|
22
|
-
/**
|
|
40
|
+
/**
|
|
41
|
+
* 选项项(用于 select/radio 等)
|
|
42
|
+
* @example
|
|
43
|
+
* ```ts
|
|
44
|
+
* import type { CrudFieldOption } from '@h-ai/kit'
|
|
45
|
+
*
|
|
46
|
+
* const value: CrudFieldOption = { label: 'Published', value: 'published' }
|
|
47
|
+
* void value
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
23
50
|
interface CrudFieldOption {
|
|
24
51
|
label: string;
|
|
25
52
|
value: string | number | boolean;
|
|
26
53
|
}
|
|
27
|
-
/**
|
|
54
|
+
/**
|
|
55
|
+
* 选项来源:静态数组或动态工厂函数
|
|
56
|
+
* @example
|
|
57
|
+
* ```ts
|
|
58
|
+
* import type { CrudFieldOptions } from '@h-ai/kit'
|
|
59
|
+
*
|
|
60
|
+
* const value: CrudFieldOptions = [{ label: 'Published', value: 'published' }]
|
|
61
|
+
* void value
|
|
62
|
+
* ```
|
|
63
|
+
*/
|
|
28
64
|
type CrudFieldOptions = CrudFieldOption[] | (() => CrudFieldOption[]);
|
|
29
|
-
/**
|
|
65
|
+
/**
|
|
66
|
+
* 可解析为字符串的文本值(支持 i18n)
|
|
67
|
+
* @example
|
|
68
|
+
* ```ts
|
|
69
|
+
* import type { CrudText } from '@h-ai/kit'
|
|
70
|
+
*
|
|
71
|
+
* const value: CrudText = () => 'Articles'
|
|
72
|
+
* void value
|
|
73
|
+
* ```
|
|
74
|
+
*/
|
|
30
75
|
type CrudText = string | (() => string);
|
|
31
|
-
/**
|
|
76
|
+
/**
|
|
77
|
+
* 字段定义
|
|
78
|
+
* @example
|
|
79
|
+
* ```ts
|
|
80
|
+
* import type { CrudFieldDef } from '@h-ai/kit'
|
|
81
|
+
*
|
|
82
|
+
* const value: CrudFieldDef = { id: 'title', label: 'Title', type: 'string', validation: { required: true } }
|
|
83
|
+
* void value
|
|
84
|
+
* ```
|
|
85
|
+
*/
|
|
32
86
|
interface CrudFieldDef {
|
|
33
87
|
/** 字段 ID(对应数据对象的 key) */
|
|
34
88
|
id: string;
|
|
@@ -71,24 +125,60 @@ interface CrudFieldDef {
|
|
|
71
125
|
/** 排列权重(数值越小越靠前) */
|
|
72
126
|
order?: number;
|
|
73
127
|
}
|
|
74
|
-
/**
|
|
128
|
+
/**
|
|
129
|
+
* 分页参数
|
|
130
|
+
* @example
|
|
131
|
+
* ```ts
|
|
132
|
+
* import type { CrudPaginationParams } from '@h-ai/kit'
|
|
133
|
+
*
|
|
134
|
+
* const value: CrudPaginationParams = { page: 1, pageSize: 20 }
|
|
135
|
+
* void value
|
|
136
|
+
* ```
|
|
137
|
+
*/
|
|
75
138
|
interface CrudPaginationParams {
|
|
76
139
|
page: number;
|
|
77
140
|
pageSize: number;
|
|
78
141
|
}
|
|
79
|
-
/**
|
|
142
|
+
/**
|
|
143
|
+
* 过滤参数(搜索 + 自定义过滤字段)
|
|
144
|
+
* @example
|
|
145
|
+
* ```ts
|
|
146
|
+
* import type { CrudFilterParams } from '@h-ai/kit'
|
|
147
|
+
*
|
|
148
|
+
* const value: CrudFilterParams = { search: 'example', status: 'published' }
|
|
149
|
+
* void value
|
|
150
|
+
* ```
|
|
151
|
+
*/
|
|
80
152
|
interface CrudFilterParams {
|
|
81
153
|
search?: string;
|
|
82
154
|
[key: string]: unknown;
|
|
83
155
|
}
|
|
84
|
-
/**
|
|
156
|
+
/**
|
|
157
|
+
* 分页结果
|
|
158
|
+
* @example
|
|
159
|
+
* ```ts
|
|
160
|
+
* import type { CrudPaginatedResult } from '@h-ai/kit'
|
|
161
|
+
*
|
|
162
|
+
* const value: CrudPaginatedResult<{ id: string }> = { items: [], total: 0, page: 1, pageSize: 20 }
|
|
163
|
+
* void value
|
|
164
|
+
* ```
|
|
165
|
+
*/
|
|
85
166
|
interface CrudPaginatedResult<T> {
|
|
86
167
|
items: T[];
|
|
87
168
|
total: number;
|
|
88
169
|
page: number;
|
|
89
170
|
pageSize: number;
|
|
90
171
|
}
|
|
91
|
-
/**
|
|
172
|
+
/**
|
|
173
|
+
* CRUD API 接口定义
|
|
174
|
+
* @example
|
|
175
|
+
* ```ts
|
|
176
|
+
* import type { CrudApiDef } from '@h-ai/kit'
|
|
177
|
+
*
|
|
178
|
+
* // 应用适配层把持久化查询结果转为此结构,失败应拒绝 Promise。
|
|
179
|
+
* function listAdapter(list: CrudApiDef<{ id: string }>['list']): CrudApiDef<{ id: string }> { return { list } }
|
|
180
|
+
* ```
|
|
181
|
+
*/
|
|
92
182
|
interface CrudApiDef<T = Record<string, unknown>> {
|
|
93
183
|
/** 获取分页列表 */
|
|
94
184
|
list: (params: CrudPaginationParams & CrudFilterParams) => Promise<CrudPaginatedResult<T>>;
|
|
@@ -101,7 +191,17 @@ interface CrudApiDef<T = Record<string, unknown>> {
|
|
|
101
191
|
/** 删除记录 */
|
|
102
192
|
remove?: (id: string) => Promise<void>;
|
|
103
193
|
}
|
|
104
|
-
/**
|
|
194
|
+
/**
|
|
195
|
+
* CRUD 资源定义
|
|
196
|
+
* @example
|
|
197
|
+
* ```ts
|
|
198
|
+
* import type { CrudApiDef, CrudResourceDef } from '@h-ai/kit'
|
|
199
|
+
*
|
|
200
|
+
* function articles(api: CrudApiDef<{ id: string, title: string }>): CrudResourceDef<{ id: string, title: string }> {
|
|
201
|
+
* return { name: 'article', label: 'Articles', fields: [{ id: 'title', label: 'Title', type: 'string' }], api }
|
|
202
|
+
* }
|
|
203
|
+
* ```
|
|
204
|
+
*/
|
|
105
205
|
interface CrudResourceDef<T = Record<string, unknown>> {
|
|
106
206
|
/** 资源名称(如 'user', 'role'),用于 URL 路由 */
|
|
107
207
|
name: string;
|
|
@@ -120,7 +220,16 @@ interface CrudResourceDef<T = Record<string, unknown>> {
|
|
|
120
220
|
/** 搜索占位符 */
|
|
121
221
|
searchPlaceholder?: CrudText;
|
|
122
222
|
}
|
|
123
|
-
/**
|
|
223
|
+
/**
|
|
224
|
+
* DataTable 列配置(适配 @h-ai/ui DataTable)
|
|
225
|
+
* @example
|
|
226
|
+
* ```ts
|
|
227
|
+
* import type { CrudTableColumn } from '@h-ai/kit'
|
|
228
|
+
*
|
|
229
|
+
* const value: CrudTableColumn = { key: 'title', label: 'Title' }
|
|
230
|
+
* void value
|
|
231
|
+
* ```
|
|
232
|
+
*/
|
|
124
233
|
interface CrudTableColumn {
|
|
125
234
|
key: string;
|
|
126
235
|
label: string;
|
|
@@ -128,7 +237,15 @@ interface CrudTableColumn {
|
|
|
128
237
|
align?: 'left' | 'center' | 'right';
|
|
129
238
|
render?: (item: Record<string, unknown>) => string;
|
|
130
239
|
}
|
|
131
|
-
/**
|
|
240
|
+
/**
|
|
241
|
+
* CRUD 操作对象(由 defineCrud 返回)
|
|
242
|
+
* @example
|
|
243
|
+
* ```ts
|
|
244
|
+
* import type { CrudOperations } from '@h-ai/kit'
|
|
245
|
+
*
|
|
246
|
+
* function columns(resource: CrudOperations<{ id: string }>) { return resource.toTableColumns() }
|
|
247
|
+
* ```
|
|
248
|
+
*/
|
|
132
249
|
interface CrudOperations<T = Record<string, unknown>> {
|
|
133
250
|
/** 资源元信息 */
|
|
134
251
|
resource: CrudResourceDef<T>;
|
|
@@ -176,35 +293,31 @@ declare function resolveOptions(options: CrudFieldOptions | undefined): Array<{
|
|
|
176
293
|
*
|
|
177
294
|
* @param resource - 资源定义
|
|
178
295
|
* @returns CRUD 操作对象
|
|
179
|
-
*
|
|
180
296
|
* @example
|
|
181
297
|
* ```ts
|
|
182
|
-
*
|
|
183
|
-
*
|
|
184
|
-
*
|
|
185
|
-
*
|
|
186
|
-
*
|
|
187
|
-
*
|
|
188
|
-
*
|
|
189
|
-
* api: { list, get, create, update, remove },
|
|
190
|
-
* })
|
|
298
|
+
* import { kit } from '@h-ai/kit'
|
|
299
|
+
*
|
|
300
|
+
* import type { CrudApiDef } from '@h-ai/kit'
|
|
301
|
+
*
|
|
302
|
+
* function articleResource(api: CrudApiDef<{ id: string, title: string }>) {
|
|
303
|
+
* return kit.crud.define({ name: 'article', label: 'Articles', fields: [{ id: 'title', label: 'Title', type: 'string' }], api })
|
|
304
|
+
* }
|
|
191
305
|
* ```
|
|
192
306
|
*/
|
|
193
307
|
declare function defineCrud<T = Record<string, unknown>>(resource: CrudResourceDef<T>): CrudOperations<T>;
|
|
194
308
|
|
|
195
309
|
/**
|
|
196
|
-
*
|
|
310
|
+
* 设置浏览器应用语言或 Node 启动默认语言;请求中只更新当前 runWithLocale 上下文。
|
|
197
311
|
*
|
|
198
312
|
* 通过 @h-ai/core 的集中式 locale 管理器,一次调用即可同步所有模块。
|
|
199
|
-
* 各模块的 createMessageGetter
|
|
200
|
-
*
|
|
313
|
+
* 各模块的 createMessageGetter 优先读取当前 Node 请求上下文;SSR 必须包裹实际 resolve。
|
|
314
|
+
* @param locale - 支持的应用默认语言;请求中应使用上下文隔离。
|
|
201
315
|
* @example
|
|
202
316
|
* ```ts
|
|
203
317
|
* import { kit } from '@h-ai/kit'
|
|
204
318
|
*
|
|
205
|
-
* //
|
|
206
|
-
*
|
|
207
|
-
* kit.i18n.setLocale(locale)
|
|
319
|
+
* // 应用启动时设置默认语言;请求内使用 runWithLocale。
|
|
320
|
+
* kit.i18n.setLocale('en-US')
|
|
208
321
|
* ```
|
|
209
322
|
*/
|
|
210
323
|
declare function setAllModulesLocale(locale: string): void;
|