@maiyunnet/kebab 9.13.8 → 9.14.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/doc/kebab-rag.md CHANGED
@@ -1360,7 +1360,7 @@ index/variables/VER.md
1360
1360
 
1361
1361
  # Variable: VER
1362
1362
 
1363
- > `const` **VER**: `"9.13.8"` = `'9.13.8'`
1363
+ > `const` **VER**: `"9.14.0"` = `'9.14.0'`
1364
1364
 
1365
1365
  Defined in: [index.ts:10](https://github.com/maiyunnet/kebab/blob/master/index.ts#L10)
1366
1366
 
@@ -5420,7 +5420,7 @@ AES 解密
5420
5420
 
5421
5421
  #### key
5422
5422
 
5423
- `CipherKey`
5423
+ `KeyLike`
5424
5424
 
5425
5425
  密钥 32 个英文字母和数字
5426
5426
 
@@ -5462,7 +5462,7 @@ AES 解密
5462
5462
 
5463
5463
  #### key
5464
5464
 
5465
- `CipherKey`
5465
+ `KeyLike`
5466
5466
 
5467
5467
  密钥 32 个英文字母和数字
5468
5468
 
@@ -5515,7 +5515,7 @@ AES 加密
5515
5515
 
5516
5516
  #### key
5517
5517
 
5518
- `CipherKey`
5518
+ `KeyLike`
5519
5519
 
5520
5520
  密钥尽量 32 个英文字母和数字,不是 32 个系统会自动处理
5521
5521
 
@@ -5559,7 +5559,7 @@ AES 加密
5559
5559
 
5560
5560
  #### key
5561
5561
 
5562
- `CipherKey`
5562
+ `KeyLike`
5563
5563
 
5564
5564
  密钥尽量 32 个英文字母和数字,不是 32 个系统会自动处理
5565
5565
 
@@ -5704,7 +5704,7 @@ cipher 解密
5704
5704
 
5705
5705
  ### key
5706
5706
 
5707
- `CipherKey`
5707
+ `KeyLike`
5708
5708
 
5709
5709
  密钥 32 个英文字母和数字
5710
5710
 
@@ -5757,7 +5757,7 @@ cipher 加密,强烈不建议使用 AES_256_ECB
5757
5757
 
5758
5758
  ### key
5759
5759
 
5760
- `CipherKey`
5760
+ `KeyLike`
5761
5761
 
5762
5762
  密钥 32 个英文字母和数字
5763
5763
 
@@ -5812,7 +5812,7 @@ AES 解密
5812
5812
 
5813
5813
  #### key
5814
5814
 
5815
- `CipherKey`
5815
+ `KeyLike`
5816
5816
 
5817
5817
  密钥 32 个英文字母和数字
5818
5818
 
@@ -5844,7 +5844,7 @@ AES 解密
5844
5844
 
5845
5845
  #### key
5846
5846
 
5847
- `CipherKey`
5847
+ `KeyLike`
5848
5848
 
5849
5849
  密钥 32 个英文字母和数字
5850
5850
 
@@ -5887,7 +5887,7 @@ AES GCM 托管加密
5887
5887
 
5888
5888
  #### key
5889
5889
 
5890
- `CipherKey`
5890
+ `KeyLike`
5891
5891
 
5892
5892
  密钥尽量 32 个英文字母和数字,不是 32 个系统会自动处理
5893
5893
 
@@ -5919,7 +5919,7 @@ AES GCM 托管加密
5919
5919
 
5920
5920
  #### key
5921
5921
 
5922
- `CipherKey`
5922
+ `KeyLike`
5923
5923
 
5924
5924
  密钥尽量 32 个英文字母和数字,不是 32 个系统会自动处理
5925
5925
 
@@ -6033,7 +6033,7 @@ hash 或 hmac 加密文件
6033
6033
 
6034
6034
  #### key?
6035
6035
 
6036
- `CipherKey`
6036
+ `KeyLike`
6037
6037
 
6038
6038
  设置则采用 hmac 加密
6039
6039
 
@@ -6069,7 +6069,7 @@ hash 或 hmac 加密文件
6069
6069
 
6070
6070
  #### key
6071
6071
 
6072
- `CipherKey`
6072
+ `KeyLike`
6073
6073
 
6074
6074
  设置则采用 hmac 加密
6075
6075
 
@@ -6116,7 +6116,7 @@ hash 或 hmac 加密
6116
6116
 
6117
6117
  #### key?
6118
6118
 
6119
- `CipherKey`
6119
+ `KeyLike`
6120
6120
 
6121
6121
  设置则采用 hmac 加密
6122
6122
 
@@ -6152,7 +6152,7 @@ hash 或 hmac 加密
6152
6152
 
6153
6153
  #### key
6154
6154
 
6155
- `CipherKey` \| `undefined`
6155
+ `KeyLike` \| `undefined`
6156
6156
 
6157
6157
  设置则采用 hmac 加密
6158
6158
 
@@ -6185,7 +6185,7 @@ Defined in: [lib/crypto.ts:136](https://github.com/maiyunnet/kebab/blob/master/l
6185
6185
 
6186
6186
  ### key
6187
6187
 
6188
- `KeyLike` \| `RsaPrivateKey`
6188
+ `KeyLike` \| `PrivateKeyInput`
6189
6189
 
6190
6190
  私钥
6191
6191
 
@@ -6220,7 +6220,7 @@ Defined in: [lib/crypto.ts:114](https://github.com/maiyunnet/kebab/blob/master/l
6220
6220
 
6221
6221
  ### key
6222
6222
 
6223
- `KeyLike` \| `RsaPrivateKey`
6223
+ `KeyLike` \| `PrivateKeyInput`
6224
6224
 
6225
6225
  私钥
6226
6226
 
@@ -6255,7 +6255,7 @@ Defined in: [lib/crypto.ts:125](https://github.com/maiyunnet/kebab/blob/master/l
6255
6255
 
6256
6256
  ### key
6257
6257
 
6258
- `KeyLike` \| `RsaPublicKey` \| `RsaPrivateKey`
6258
+ `KeyLike` \| `PrivateKeyInput` \| `PublicKeyInput`
6259
6259
 
6260
6260
  公钥
6261
6261
 
@@ -6290,7 +6290,7 @@ Defined in: [lib/crypto.ts:103](https://github.com/maiyunnet/kebab/blob/master/l
6290
6290
 
6291
6291
  ### key
6292
6292
 
6293
- `KeyLike` \| `RsaPublicKey` \| `RsaPrivateKey`
6293
+ `KeyLike` \| `PrivateKeyInput` \| `PublicKeyInput`
6294
6294
 
6295
6295
  公钥
6296
6296
 
@@ -6327,7 +6327,7 @@ Defined in: [lib/crypto.ts:69](https://github.com/maiyunnet/kebab/blob/master/li
6327
6327
 
6328
6328
  #### data
6329
6329
 
6330
- `BinaryLike`
6330
+ `string` \| `ArrayBufferView`\<`ArrayBufferLike`\>
6331
6331
 
6332
6332
  数据
6333
6333
 
@@ -6365,7 +6365,7 @@ Defined in: [lib/crypto.ts:72](https://github.com/maiyunnet/kebab/blob/master/li
6365
6365
 
6366
6366
  #### data
6367
6367
 
6368
- `BinaryLike`
6368
+ `string` \| `ArrayBufferView`\<`ArrayBufferLike`\>
6369
6369
 
6370
6370
  数据
6371
6371
 
@@ -6420,7 +6420,7 @@ SM4 解密
6420
6420
 
6421
6421
  #### key
6422
6422
 
6423
- `CipherKey`
6423
+ `KeyLike`
6424
6424
 
6425
6425
  密钥 32 个英文字母和数字
6426
6426
 
@@ -6462,7 +6462,7 @@ SM4 解密
6462
6462
 
6463
6463
  #### key
6464
6464
 
6465
- `CipherKey`
6465
+ `KeyLike`
6466
6466
 
6467
6467
  密钥 32 个英文字母和数字
6468
6468
 
@@ -6515,7 +6515,7 @@ SM4 加密
6515
6515
 
6516
6516
  #### key
6517
6517
 
6518
- `CipherKey`
6518
+ `KeyLike`
6519
6519
 
6520
6520
  密钥 32 个英文字母和数字
6521
6521
 
@@ -6557,7 +6557,7 @@ SM4 加密
6557
6557
 
6558
6558
  #### key
6559
6559
 
6560
- `CipherKey`
6560
+ `KeyLike`
6561
6561
 
6562
6562
  密钥 32 个英文字母和数字
6563
6563
 
@@ -6631,7 +6631,7 @@ Defined in: [lib/crypto.ts:90](https://github.com/maiyunnet/kebab/blob/master/li
6631
6631
 
6632
6632
  ### data
6633
6633
 
6634
- `BinaryLike`
6634
+ `string` \| `ArrayBufferView`\<`ArrayBufferLike`\>
6635
6635
 
6636
6636
  数据
6637
6637
 
@@ -8623,10 +8623,14 @@ lib/fs/functions/getContent.md
8623
8623
 
8624
8624
  ## Param
8625
8625
 
8626
+ **path**
8627
+
8626
8628
  文件路径
8627
8629
 
8628
8630
  ## Param
8629
8631
 
8632
+ **options**
8633
+
8630
8634
  编码或选项
8631
8635
 
8632
8636
  ## Call Signature
@@ -10720,7 +10724,7 @@ Defined in: [lib/net/formdata.ts:37](https://github.com/maiyunnet/kebab/blob/mas
10720
10724
 
10721
10725
  > **new FormData**(`options?`): `FormData`
10722
10726
 
10723
- Defined in: node\_modules/@types/node/stream.d.ts:80
10727
+ Defined in: node\_modules/@types/node/stream.d.ts:81
10724
10728
 
10725
10729
  #### Parameters
10726
10730
 
@@ -15063,23 +15067,29 @@ lib/sql/functions/json.md
15063
15067
 
15064
15068
  # Function: json()
15065
15069
 
15066
- > **json**(`obj`): `any`
15070
+ > **json**\<`T`\>(`obj`): `T`
15067
15071
 
15068
15072
  Defined in: [lib/sql.ts:1461](https://github.com/maiyunnet/kebab/blob/master/lib/sql.ts#L1461)
15069
15073
 
15070
15074
  将对象转换为 JSON 字符串并避开类型检查,用于适配 PostgreSQL 的 jsonb 字段
15071
15075
 
15076
+ ## Type Parameters
15077
+
15078
+ ### T
15079
+
15080
+ `T`
15081
+
15072
15082
  ## Parameters
15073
15083
 
15074
15084
  ### obj
15075
15085
 
15076
- `any`
15086
+ `T`
15077
15087
 
15078
15088
  要转换的 JSON 对象
15079
15089
 
15080
15090
  ## Returns
15081
15091
 
15082
- `any`
15092
+ `T`
15083
15093
 
15084
15094
  lib/sql/functions/value.md
15085
15095
  ---
@@ -15562,10 +15572,14 @@ Defined in: [lib/ssh/sftp.ts:442](https://github.com/maiyunnet/kebab/blob/master
15562
15572
 
15563
15573
  #### Param
15564
15574
 
15575
+ **path**
15576
+
15565
15577
  文件路径
15566
15578
 
15567
15579
  #### Param
15568
15580
 
15581
+ **options**
15582
+
15569
15583
  编码或选项
15570
15584
 
15571
15585
  #### Call Signature
@@ -18027,7 +18041,7 @@ Defined in: [lib/undici/formdata.ts:37](https://github.com/maiyunnet/kebab/blob/
18027
18041
 
18028
18042
  > **new FormData**(`options?`): `FormData`
18029
18043
 
18030
- Defined in: node\_modules/@types/node/stream.d.ts:80
18044
+ Defined in: node\_modules/@types/node/stream.d.ts:81
18031
18045
 
18032
18046
  #### Parameters
18033
18047
 
@@ -21155,10 +21169,14 @@ Defined in: [lib/zip.ts:350](https://github.com/maiyunnet/kebab/blob/master/lib/
21155
21169
 
21156
21170
  #### Param
21157
21171
 
21172
+ **path**
21173
+
21158
21174
  文件路径
21159
21175
 
21160
21176
  #### Param
21161
21177
 
21178
+ **type**
21179
+
21162
21180
  返回类型
21163
21181
 
21164
21182
  #### Call Signature
@@ -21335,10 +21353,14 @@ string
21335
21353
 
21336
21354
  #### Param
21337
21355
 
21356
+ **path**
21357
+
21338
21358
  文件夹路径
21339
21359
 
21340
21360
  #### Param
21341
21361
 
21362
+ **opt**
21363
+
21342
21364
  选项
21343
21365
 
21344
21366
  #### Call Signature
@@ -24152,6 +24174,8 @@ Defined in: [sys/mod.ts:1797](https://github.com/maiyunnet/kebab/blob/master/sys
24152
24174
 
24153
24175
  #### Param
24154
24176
 
24177
+ **key**
24178
+
24155
24179
  是否以某个字段为主键
24156
24180
 
24157
24181
  #### Call Signature
@@ -24188,6 +24212,8 @@ Defined in: [sys/mod.ts:1140](https://github.com/maiyunnet/kebab/blob/master/sys
24188
24212
 
24189
24213
  #### Param
24190
24214
 
24215
+ **key**
24216
+
24191
24217
  是否以某个字段为主键
24192
24218
 
24193
24219
  #### Call Signature
@@ -24384,6 +24410,8 @@ ON 信息
24384
24410
 
24385
24411
  #### Param
24386
24412
 
24413
+ **all**
24414
+
24387
24415
  是否获取完全的情况,默认不获取,只返回扫描情况
24388
24416
 
24389
24417
  #### Call Signature
@@ -24448,10 +24476,14 @@ Defined in: [sys/mod.ts:1640](https://github.com/maiyunnet/kebab/blob/master/sys
24448
24476
 
24449
24477
  #### Param
24450
24478
 
24479
+ **lock**
24480
+
24451
24481
  是否加锁
24452
24482
 
24453
24483
  #### Param
24454
24484
 
24485
+ **array**
24486
+
24455
24487
  是否返回原生对象
24456
24488
 
24457
24489
  #### Call Signature
@@ -24992,10 +25024,14 @@ Defined in: [sys/mod.ts:973](https://github.com/maiyunnet/kebab/blob/master/sys/
24992
25024
 
24993
25025
  #### Param
24994
25026
 
25027
+ **n**
25028
+
24995
25029
  字符串或键/值
24996
25030
 
24997
25031
  #### Param
24998
25032
 
25033
+ **v**
25034
+
24999
25035
  可能是数字
25000
25036
 
25001
25037
  #### Call Signature
@@ -25464,21 +25500,27 @@ Defined in: [sys/mod.ts:264](https://github.com/maiyunnet/kebab/blob/master/sys/
25464
25500
 
25465
25501
  ### json()
25466
25502
 
25467
- > `static` **json**(`obj`): `any`
25503
+ > `static` **json**\<`T`\>(`obj`): `T`
25468
25504
 
25469
25505
  Defined in: [sys/mod.ts:193](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L193)
25470
25506
 
25471
25507
  创建 JSON 字符串对象,用于 PGSQL 的 jsonb 字段
25472
25508
 
25509
+ #### Type Parameters
25510
+
25511
+ ##### T
25512
+
25513
+ `T`
25514
+
25473
25515
  #### Parameters
25474
25516
 
25475
25517
  ##### obj
25476
25518
 
25477
- `any`
25519
+ `T`
25478
25520
 
25479
25521
  #### Returns
25480
25522
 
25481
- `any`
25523
+ `T`
25482
25524
 
25483
25525
  ***
25484
25526
 
@@ -25488,14 +25530,20 @@ Defined in: [sys/mod.ts:193](https://github.com/maiyunnet/kebab/blob/master/sys/
25488
25530
 
25489
25531
  #### Param
25490
25532
 
25533
+ **db**
25534
+
25491
25535
  数据库对象
25492
25536
 
25493
25537
  #### Param
25494
25538
 
25539
+ **s**
25540
+
25495
25541
  筛选条件数组或字符串
25496
25542
 
25497
25543
  #### Param
25498
25544
 
25545
+ **opt**
25546
+
25499
25547
  选项(opt.pre: MySQL 表前缀/PostgreSQL Schema 名;lock 需确保 where 条件命中索引,否则可能退化为表锁)
25500
25548
 
25501
25549
  #### Call Signature
package/index.d.ts CHANGED
@@ -5,7 +5,7 @@
5
5
  * --- 本文件用来定义每个目录实体地址的常量 ---
6
6
  */
7
7
  /** --- 当前系统版本号 --- */
8
- export declare const VER = "9.13.8";
8
+ export declare const VER = "9.14.0";
9
9
  /** --- 框架根目录,以 / 结尾 --- */
10
10
  export declare const ROOT_PATH: string;
11
11
  /** --- 框架的 LIB,以 / 结尾 --- */
package/index.js CHANGED
@@ -6,7 +6,7 @@
6
6
  * --- 本文件用来定义每个目录实体地址的常量 ---
7
7
  */
8
8
  /** --- 当前系统版本号 --- */
9
- export const VER = '9.13.8';
9
+ export const VER = '9.14.0';
10
10
  // --- 服务端用的路径 ---
11
11
  const imu = decodeURIComponent(import.meta.url).replace('file://', '').replace(/^\/(\w:)/, '$1');
12
12
  /** --- /xxx/xxx --- */
package/lib/crypto.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Project: Kebab, User: JianSuoQiYue
3
3
  * Date: 2019-4-2 14:01:06
4
- * Last: 2020-3-12 14:05:24, 2022-09-12 11:52:35, 2024-9-8 17:09:39, 2024-11-11 00:21:58, 2025-6-18 20:27:47
4
+ * Last: 2020-3-12 14:05:24, 2022-09-12 11:52:35, 2024-9-8 17:09:39, 2024-11-11 00:21:58, 2025-6-18 20:27:47, 2026-07-29 11:51
5
5
  */
6
6
  import * as crypto from 'crypto';
7
7
  /**
@@ -31,8 +31,8 @@ export declare function generateKeyPair(type: string, options?: {
31
31
  * @param format 输出格式
32
32
  * @param algorithm 哈希方式
33
33
  */
34
- export declare function sign(data: crypto.BinaryLike, privateKey: crypto.KeyLike | crypto.SignKeyObjectInput | crypto.SignPrivateKeyInput | crypto.SignJsonWebKeyInput, format: 'hex' | 'base64' | 'binary', algorithm?: string): string;
35
- export declare function sign(data: crypto.BinaryLike, privateKey: crypto.KeyLike | crypto.SignKeyObjectInput | crypto.SignPrivateKeyInput | crypto.SignJsonWebKeyInput, format?: 'buffer', algorithm?: string): Buffer;
34
+ export declare function sign(data: string | NodeJS.ArrayBufferView, privateKey: crypto.KeyLike | crypto.SignKeyObjectInput | crypto.SignPrivateKeyInput | crypto.SignJsonWebKeyInput, format: 'hex' | 'base64' | 'binary', algorithm?: string): string;
35
+ export declare function sign(data: string | NodeJS.ArrayBufferView, privateKey: crypto.KeyLike | crypto.SignKeyObjectInput | crypto.SignPrivateKeyInput | crypto.SignJsonWebKeyInput, format?: 'buffer', algorithm?: string): Buffer;
36
36
  /**
37
37
  * --- 非对称验签 ---
38
38
  * @param data 数据
@@ -40,31 +40,31 @@ export declare function sign(data: crypto.BinaryLike, privateKey: crypto.KeyLike
40
40
  * @param signature 签名
41
41
  * @param algorithm 哈希方式
42
42
  */
43
- export declare function verify(data: crypto.BinaryLike, object: crypto.KeyLike | crypto.VerifyKeyObjectInput | crypto.VerifyPublicKeyInput | crypto.VerifyJsonWebKeyInput, signature: NodeJS.ArrayBufferView, algorithm?: string): boolean;
43
+ export declare function verify(data: string | NodeJS.ArrayBufferView, object: crypto.KeyLike | crypto.VerifyKeyObjectInput | crypto.VerifyPublicKeyInput | crypto.VerifyJsonWebKeyInput, signature: NodeJS.ArrayBufferView, algorithm?: string): boolean;
44
44
  /**
45
45
  * --- 非对称公钥加密 ---
46
46
  * @param key 公钥
47
47
  * @param buffer 数据
48
48
  */
49
- export declare function publicEncrypt(key: crypto.RsaPublicKey | crypto.RsaPrivateKey | crypto.KeyLike, buffer: NodeJS.ArrayBufferView | string): Buffer;
49
+ export declare function publicEncrypt(key: crypto.KeyLike | crypto.PublicKeyInput | crypto.PrivateKeyInput, buffer: NodeJS.ArrayBufferView | string): Buffer;
50
50
  /**
51
51
  * --- 非对称私钥加密 ---
52
52
  * @param key 私钥
53
53
  * @param buffer 数据
54
54
  */
55
- export declare function privateEncrypt(key: crypto.RsaPrivateKey | crypto.KeyLike, buffer: NodeJS.ArrayBufferView | string): Buffer;
55
+ export declare function privateEncrypt(key: crypto.KeyLike | crypto.PrivateKeyInput, buffer: NodeJS.ArrayBufferView | string): Buffer;
56
56
  /**
57
57
  * --- 非对称公钥解密 ---
58
58
  * @param key 公钥
59
59
  * @param buffer 数据
60
60
  */
61
- export declare function publicDecrypt(key: crypto.RsaPublicKey | crypto.RsaPrivateKey | crypto.KeyLike, buffer: NodeJS.ArrayBufferView | string): Buffer;
61
+ export declare function publicDecrypt(key: crypto.KeyLike | crypto.PublicKeyInput | crypto.PrivateKeyInput, buffer: NodeJS.ArrayBufferView | string): Buffer;
62
62
  /**
63
63
  * --- 非对称私钥解密 ---
64
64
  * @param key 私钥
65
65
  * @param buffer 数据
66
66
  */
67
- export declare function privateDecrypt(key: crypto.RsaPrivateKey | crypto.KeyLike, buffer: NodeJS.ArrayBufferView | string): Buffer;
67
+ export declare function privateDecrypt(key: crypto.KeyLike | crypto.PrivateKeyInput, buffer: NodeJS.ArrayBufferView | string): Buffer;
68
68
  /** --- 勿使用,无 iv 默认,但勿使用 --- */
69
69
  export declare const AES_256_ECB = "aes-256-ecb";
70
70
  /** --- 一般不用,兼容性场景下用 --- */
@@ -86,7 +86,7 @@ export declare const SM4_CFB = "sm4-cfb";
86
86
  * @param method 加密方法
87
87
  * @param output 输出类型
88
88
  */
89
- export declare function cipherEncrypt(original: string | Buffer, key: crypto.CipherKey, iv?: string, method?: string, output?: 'base64' | 'buffer'): string | Buffer | false;
89
+ export declare function cipherEncrypt(original: string | Buffer, key: crypto.KeyLike, iv?: string, method?: string, output?: 'base64' | 'buffer'): string | Buffer | false;
90
90
  /**
91
91
  * --- AES 加密 ---
92
92
  * @param original 原始字符串
@@ -95,16 +95,16 @@ export declare function cipherEncrypt(original: string | Buffer, key: crypto.Cip
95
95
  * @param method 加密方法
96
96
  * @param output 输出类型
97
97
  */
98
- export declare function aesEncrypt(original: string | Buffer, key: crypto.CipherKey, iv: string, method: string, output: 'buffer'): Buffer | false;
99
- export declare function aesEncrypt(original: string | Buffer, key: crypto.CipherKey, iv?: string, method?: string, output?: 'base64'): string | false;
98
+ export declare function aesEncrypt(original: string | Buffer, key: crypto.KeyLike, iv: string, method: string, output: 'buffer'): Buffer | false;
99
+ export declare function aesEncrypt(original: string | Buffer, key: crypto.KeyLike, iv?: string, method?: string, output?: 'base64'): string | false;
100
100
  /**
101
101
  * --- AES GCM 托管加密 ---
102
102
  * @param original 原始字符串
103
103
  * @param key 密钥尽量 32 个英文字母和数字,不是 32 个系统会自动处理
104
104
  * @param output 输出类型
105
105
  */
106
- export declare function gcmEncrypt(original: string | Buffer, key: crypto.CipherKey, output: 'buffer'): Buffer | false;
107
- export declare function gcmEncrypt(original: string | Buffer, key: crypto.CipherKey, output?: 'base64'): string | false;
106
+ export declare function gcmEncrypt(original: string | Buffer, key: crypto.KeyLike, output: 'buffer'): Buffer | false;
107
+ export declare function gcmEncrypt(original: string | Buffer, key: crypto.KeyLike, output?: 'base64'): string | false;
108
108
  /**
109
109
  * --- SM4 加密 ---
110
110
  * @param original 原始字符串
@@ -112,8 +112,8 @@ export declare function gcmEncrypt(original: string | Buffer, key: crypto.Cipher
112
112
  * @param iv 向量 16 个英文字母和数字
113
113
  * @param method 加密方法
114
114
  */
115
- export declare function sm4Encrypt(original: string | Buffer, key: crypto.CipherKey, iv: string, method: string, output: 'buffer'): Buffer | false;
116
- export declare function sm4Encrypt(original: string | Buffer, key: crypto.CipherKey, iv?: string, method?: string, output?: 'base64'): string | false;
115
+ export declare function sm4Encrypt(original: string | Buffer, key: crypto.KeyLike, iv: string, method: string, output: 'buffer'): Buffer | false;
116
+ export declare function sm4Encrypt(original: string | Buffer, key: crypto.KeyLike, iv?: string, method?: string, output?: 'base64'): string | false;
117
117
  /**
118
118
  * --- cipher 解密 ---
119
119
  * @param encrypt 需解密的字符串
@@ -122,7 +122,7 @@ export declare function sm4Encrypt(original: string | Buffer, key: crypto.Cipher
122
122
  * @param method 加密方法
123
123
  * @param output 输出类型
124
124
  */
125
- export declare function cipherDecrypt(encrypt: string | Buffer, key: crypto.CipherKey, iv?: string, method?: string, output?: 'binary' | 'buffer'): string | Buffer | false;
125
+ export declare function cipherDecrypt(encrypt: string | Buffer, key: crypto.KeyLike, iv?: string, method?: string, output?: 'binary' | 'buffer'): string | Buffer | false;
126
126
  /**
127
127
  * --- AES 解密 ---
128
128
  * @param encrypt 需解密的字符串
@@ -130,16 +130,16 @@ export declare function cipherDecrypt(encrypt: string | Buffer, key: crypto.Ciph
130
130
  * @param iv 向量 16(CTR) 或 12(GCM) 个英文字母和数字
131
131
  * @param method 加密方法
132
132
  */
133
- export declare function aesDecrypt(encrypt: string | Buffer, key: crypto.CipherKey, iv: string, method: string, output: 'buffer'): Buffer | false;
134
- export declare function aesDecrypt(encrypt: string | Buffer, key: crypto.CipherKey, iv?: string, method?: string, output?: 'binary'): string | false;
133
+ export declare function aesDecrypt(encrypt: string | Buffer, key: crypto.KeyLike, iv: string, method: string, output: 'buffer'): Buffer | false;
134
+ export declare function aesDecrypt(encrypt: string | Buffer, key: crypto.KeyLike, iv?: string, method?: string, output?: 'binary'): string | false;
135
135
  /**
136
136
  * --- AES 解密 ---
137
137
  * @param encrypt 需解密的字符串
138
138
  * @param key 密钥 32 个英文字母和数字
139
139
  * @param output 输出类型
140
140
  */
141
- export declare function gcmDecrypt(encrypt: string | Buffer, key: crypto.CipherKey, output: 'buffer'): Buffer | false;
142
- export declare function gcmDecrypt(encrypt: string | Buffer, key: crypto.CipherKey, output?: 'binary'): string | false;
141
+ export declare function gcmDecrypt(encrypt: string | Buffer, key: crypto.KeyLike, output: 'buffer'): Buffer | false;
142
+ export declare function gcmDecrypt(encrypt: string | Buffer, key: crypto.KeyLike, output?: 'binary'): string | false;
143
143
  /**
144
144
  * --- SM4 解密 ---
145
145
  * @param encrypt 需解密的字符串
@@ -147,24 +147,24 @@ export declare function gcmDecrypt(encrypt: string | Buffer, key: crypto.CipherK
147
147
  * @param iv 向量 16 个英文字母和数字
148
148
  * @param method 加密方法
149
149
  */
150
- export declare function sm4Decrypt(encrypt: string | Buffer, key: crypto.CipherKey, iv: string, method: string, output: 'buffer'): Buffer | false;
151
- export declare function sm4Decrypt(encrypt: string | Buffer, key: crypto.CipherKey, iv?: string, method?: string, output?: 'binary'): string | false;
150
+ export declare function sm4Decrypt(encrypt: string | Buffer, key: crypto.KeyLike, iv: string, method: string, output: 'buffer'): Buffer | false;
151
+ export declare function sm4Decrypt(encrypt: string | Buffer, key: crypto.KeyLike, iv?: string, method?: string, output?: 'binary'): string | false;
152
152
  /**
153
153
  * --- hash 或 hmac 加密 ---
154
154
  * @param algorithm 哈希方式
155
155
  * @param data 源数据
156
156
  * @param key 设置则采用 hmac 加密
157
157
  */
158
- export declare function hashHmac(algorithm: string, data: Buffer | string, key?: crypto.CipherKey, format?: 'hex' | 'base64'): string;
159
- export declare function hashHmac(algorithm: string, data: Buffer | string, key: crypto.CipherKey | undefined, format: 'buffer'): Buffer;
158
+ export declare function hashHmac(algorithm: string, data: Buffer | string, key?: crypto.KeyLike, format?: 'hex' | 'base64'): string;
159
+ export declare function hashHmac(algorithm: string, data: Buffer | string, key: crypto.KeyLike | undefined, format: 'buffer'): Buffer;
160
160
  /**
161
161
  * --- hash 或 hmac 加密文件 ---
162
162
  * @param algorithm 加密方式,如 md5、sha256、sm3 等
163
163
  * @param path 文件路径
164
164
  * @param key 设置则采用 hmac 加密
165
165
  */
166
- export declare function hashHmacFile(algorithm: string, path: string, key?: crypto.CipherKey, encoding?: 'hex' | 'base64' | 'base64url'): Promise<string | false>;
167
- export declare function hashHmacFile(algorithm: string, path: string, key: crypto.CipherKey, encoding: 'buffer'): Promise<Buffer | false>;
166
+ export declare function hashHmacFile(algorithm: string, path: string, key?: crypto.KeyLike, encoding?: 'hex' | 'base64' | 'base64url'): Promise<string | false>;
167
+ export declare function hashHmacFile(algorithm: string, path: string, key: crypto.KeyLike, encoding: 'buffer'): Promise<Buffer | false>;
168
168
  /**
169
169
  * --- base64 编码 ---
170
170
  * @param data 字符串或 Buffer
package/lib/crypto.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Project: Kebab, User: JianSuoQiYue
3
3
  * Date: 2019-4-2 14:01:06
4
- * Last: 2020-3-12 14:05:24, 2022-09-12 11:52:35, 2024-9-8 17:09:39, 2024-11-11 00:21:58, 2025-6-18 20:27:47
4
+ * Last: 2020-3-12 14:05:24, 2022-09-12 11:52:35, 2024-9-8 17:09:39, 2024-11-11 00:21:58, 2025-6-18 20:27:47, 2026-07-29 11:51
5
5
  */
6
6
  import * as crypto from 'crypto';
7
7
  // --- 库和定义 ---
package/lib/sql.d.ts CHANGED
@@ -303,4 +303,4 @@ export declare function value(val: kebab.DbValue): {
303
303
  * --- 将对象转换为 JSON 字符串并避开类型检查,用于适配 PostgreSQL 的 jsonb 字段 ---
304
304
  * @param obj 要转换的 JSON 对象
305
305
  */
306
- export declare function json(obj: kebab.Json): any;
306
+ export declare function json<T>(obj: T): T;
@@ -31,7 +31,7 @@ export declare class Response {
31
31
  /**
32
32
  * --- 获取响应读取流对象 ---
33
33
  */
34
- getStream(): zlib.BrotliDecompress | zlib.Gunzip | zlib.Inflate | (import("undici/types/readable").default & undici.Dispatcher.BodyMixin) | null;
34
+ getStream(): (import("undici/types/readable").default & undici.Dispatcher.BodyMixin) | zlib.Gunzip | zlib.Inflate | zlib.BrotliDecompress | null;
35
35
  /**
36
36
  * --- 获取原生响应读取流对象 ---
37
37
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@maiyunnet/kebab",
3
- "version": "9.13.8",
3
+ "version": "9.14.0",
4
4
  "description": "Simple, easy-to-use, and fully-featured Node.js framework that is ready-to-use out of the box.",
5
5
  "type": "module",
6
6
  "keywords": [
@@ -22,47 +22,47 @@
22
22
  "#kebab/*": "./*"
23
23
  },
24
24
  "dependencies": {
25
- "@aws-sdk/client-s3": "^3.1047.0",
26
- "@aws-sdk/lib-storage": "^3.1047.0",
25
+ "@aws-sdk/client-s3": "^3.1096.0",
26
+ "@aws-sdk/lib-storage": "^3.1096.0",
27
27
  "@litert/http-client": "^1.1.2",
28
28
  "@litert/mime": "^0.1.3",
29
29
  "@litert/redis": "^3.2.1",
30
30
  "@litert/websocket": "^0.2.8",
31
- "@radix-ui/react-checkbox": "^1.3.3",
32
- "@radix-ui/react-label": "^2.1.8",
33
- "@radix-ui/react-slot": "^1.2.4",
34
- "@radix-ui/react-switch": "^1.2.6",
35
- "@tailwindcss/cli": "^4.3.0",
31
+ "@radix-ui/react-checkbox": "^1.3.11",
32
+ "@radix-ui/react-label": "^2.1.15",
33
+ "@radix-ui/react-slot": "^1.3.3",
34
+ "@radix-ui/react-switch": "^1.3.7",
35
+ "@tailwindcss/cli": "^4.3.3",
36
36
  "@types/ssh2": "^1.15.5",
37
37
  "ajv": "^8.20.0",
38
38
  "ajv-formats": "^3.0.1",
39
39
  "class-variance-authority": "^0.7.1",
40
40
  "clsx": "^2.1.1",
41
- "ejs": "^5.0.2",
42
- "esbuild": "^0.28.0",
41
+ "ejs": "^6.0.1",
42
+ "esbuild": "^0.28.1",
43
43
  "jszip": "^3.10.1",
44
- "mysql2": "^3.22.3",
45
- "node-cron": "^4.2.1",
46
- "openai": "^6.37.0",
47
- "pg": "^8.20.0",
48
- "react": "^19.2.6",
49
- "react-dom": "^19.2.6",
50
- "react-router-dom": "^7.15.1",
44
+ "mysql2": "^3.23.2",
45
+ "node-cron": "^4.6.0",
46
+ "openai": "^7.0.0",
47
+ "pg": "^8.22.0",
48
+ "react": "^19.2.8",
49
+ "react-dom": "^19.2.8",
50
+ "react-router-dom": "^7.18.1",
51
51
  "ssh2": "^1.17.0",
52
52
  "svg-captcha": "^1.4.0",
53
53
  "tailwind-merge": "^3.6.0",
54
- "tencentcloud-sdk-nodejs": "^4.1.232",
55
- "undici": "^8.3.0"
54
+ "tencentcloud-sdk-nodejs": "^4.1.277",
55
+ "undici": "^8.9.0"
56
56
  },
57
57
  "devDependencies": {
58
58
  "@litert/eslint-plugin-rules": "^0.3.1",
59
59
  "@types/ejs": "^3.1.5",
60
- "@types/node": "^25.8.0",
60
+ "@types/node": "^26.1.2",
61
61
  "@types/pg": "^8.20.0",
62
- "@types/react": "^19.2.14",
62
+ "@types/react": "^19.2.17",
63
63
  "@types/react-dom": "^19.2.3",
64
- "typedoc": "^0.28.19",
65
- "typedoc-plugin-markdown": "^4.11.0",
64
+ "typedoc": "^0.28.20",
65
+ "typedoc-plugin-markdown": "^4.12.0",
66
66
  "typescript": "^6.0.3"
67
67
  }
68
68
  }
package/sys/child.js CHANGED
@@ -47,6 +47,8 @@ let http2Server;
47
47
  const linkCount = {};
48
48
  /** --- 是否正在停止,停止时对 HTTP/1.1 响应追加 Connection: close,避免请求完成后连接回到保活池 --- */
49
49
  let stopping = false;
50
+ /** --- 当前活跃的 HTTP/2 会话集合,用于 graceful shutdown 时发送 GOAWAY 帧 --- */
51
+ const http2Sessions = new Set();
50
52
  /**
51
53
  * --- 包装请求处理函数,统一管理 linkCount 计数和错误处理 ---
52
54
  * @param key 连接标识
@@ -144,6 +146,12 @@ async function run() {
144
146
  }
145
147
  wrapWithLinkCount(host + (req.url ?? ''), () => upgradeHandler(req, socket, true, head), '[CHILD][http2][upgrade]', 'UPGRADE');
146
148
  }).listen(lCore.globalConfig.httpsPort);
149
+ // --- 追踪 HTTP/2 会话,用于 graceful shutdown 时发送 GOAWAY 帧通知 CDN 切换连接 ---
150
+ http2Server.on('session', (session) => {
151
+ http2Sessions.add(session);
152
+ session.on('close', () => { http2Sessions.delete(session); });
153
+ session.on('error', () => { http2Sessions.delete(session); });
154
+ });
147
155
  // --- 增大 HTTP/2 超时,防止 CDN 预建连接被 Node.js 过早关闭 ---
148
156
  http2Server.setTimeout(120_000);
149
157
  httpServer = http.createServer(function (req, res) {
@@ -562,6 +570,13 @@ process.on('message', function (msg) {
562
570
  case 'stop': {
563
571
  // --- 需要停止监听,等待已有连接全部断开,然后关闭线程 ---
564
572
  stopping = true;
573
+ // --- 向所有 HTTP/2 会话发送 GOAWAY 帧,通知 CDN 客户端停止在该连接上发送新请求并切换到新连接 ---
574
+ for (const session of http2Sessions) {
575
+ try {
576
+ session.goaway(http2.constants.NGHTTP2_NO_ERROR);
577
+ }
578
+ catch { }
579
+ }
565
580
  httpServer?.close();
566
581
  http2Server?.close();
567
582
  // --- 立即关闭空闲保活连接(无活跃请求的 keep-alive socket),避免进程长时间等待 ---
package/sys/master.js CHANGED
@@ -18,6 +18,29 @@ import * as lTime from '#kebab/lib/time.js';
18
18
  import * as lZip from '#kebab/lib/zip.js';
19
19
  /** --- 当前运行中的子进程列表 --- */
20
20
  const workerList = {};
21
+ /**
22
+ * --- 等待指定 worker 开始监听端口就绪 ---
23
+ * @param worker 要等待的 worker 对象
24
+ * @param timeout 超时时间(毫秒),默认 30 秒
25
+ */
26
+ function waitForWorkerListening(worker, timeout = 30_000) {
27
+ return new Promise((resolve) => {
28
+ let timer;
29
+ const onListening = (w) => {
30
+ if (w.id === worker.id) {
31
+ clearTimeout(timer);
32
+ cluster.removeListener('listening', onListening);
33
+ resolve();
34
+ }
35
+ };
36
+ timer = setTimeout(() => {
37
+ lCore.display(`[master] Worker ${worker.process.pid ?? 'undefined'} timed out waiting for listening, proceeding anyway.`);
38
+ cluster.removeListener('listening', onListening);
39
+ resolve();
40
+ }, timeout);
41
+ cluster.on('listening', onListening);
42
+ });
43
+ }
21
44
  /**
22
45
  * --- 最终调用执行的函数块 ---
23
46
  */
@@ -124,16 +147,7 @@ function createRpcListener() {
124
147
  break;
125
148
  }
126
149
  case 'restart': {
127
- // --- 为所有子线程发送 stop 信息 ---
128
- for (const pid in workerList) {
129
- workerList[pid].worker.send({
130
- 'action': 'stop'
131
- });
132
- // --- 开启新线程 ---
133
- await createChildProcess(workerList[pid].cpu);
134
- // --- 删除记录 ---
135
- delete workerList[pid];
136
- }
150
+ await restartWorkers();
137
151
  break;
138
152
  }
139
153
  case 'global': {
@@ -768,6 +782,34 @@ function createRpcListener() {
768
782
  });
769
783
  }).listen(lCore.globalConfig.rpcPort);
770
784
  }
785
+ /**
786
+ * --- 零宕机重启所有 worker 进程:先创建新进程并等待监听就绪,再停止旧进程 ---
787
+ */
788
+ async function restartWorkers() {
789
+ // --- 收集旧进程信息(先快照,避免迭代过程中修改 workerList) ---
790
+ const oldEntries = [];
791
+ for (const pid in workerList) {
792
+ oldEntries.push({
793
+ 'pid': pid,
794
+ 'cpu': workerList[pid].cpu,
795
+ 'worker': workerList[pid].worker
796
+ });
797
+ }
798
+ // --- 阶段 1:创建新进程并等待其监听端口就绪 ---
799
+ for (const entry of oldEntries) {
800
+ const newWorker = await createChildProcess(entry.cpu);
801
+ if (newWorker) {
802
+ await waitForWorkerListening(newWorker);
803
+ }
804
+ }
805
+ // --- 阶段 2:停止旧进程 ---
806
+ for (const entry of oldEntries) {
807
+ entry.worker.send({
808
+ 'action': 'stop'
809
+ });
810
+ delete workerList[entry.pid];
811
+ }
812
+ }
771
813
  /**
772
814
  * --- 检测是否有死掉丢失的子进程,复活之 ---
773
815
  */
@@ -795,7 +837,7 @@ async function checkWorkerLost() {
795
837
  async function createChildProcess(cpu) {
796
838
  const worker = cluster.fork();
797
839
  if (!worker.process.pid) {
798
- return;
840
+ return null;
799
841
  }
800
842
  workerList[worker.process.pid] = {
801
843
  'worker': worker,
@@ -823,16 +865,7 @@ async function createChildProcess(cpu) {
823
865
  break;
824
866
  }
825
867
  case 'restart': {
826
- // --- 为所有子进程发送 restart 信息 ---
827
- for (const pid in workerList) {
828
- workerList[pid].worker.send({
829
- 'action': 'stop'
830
- });
831
- // --- 开启新线程 ---
832
- await createChildProcess(workerList[pid].cpu);
833
- // --- 删除记录 ---
834
- delete workerList[pid];
835
- }
868
+ await restartWorkers();
836
869
  break;
837
870
  }
838
871
  case 'global': {
@@ -889,6 +922,7 @@ async function createChildProcess(cpu) {
889
922
  'data': lCore.global
890
923
  });
891
924
  }
925
+ return worker;
892
926
  }
893
927
  /**
894
928
  * --- 开发模式下的文件监听自动重载(HMR),仅在 debug: true 时启用 ---
@@ -919,18 +953,10 @@ function startFileWatcher() {
919
953
  }
920
954
  restarting = true;
921
955
  lCore.display(`[HMR] File changed: ${formatName}, reloading workers...`);
922
- (async () => {
923
- // --- 为所有子进程发送 stop 信息并重启 ---
924
- for (const pid in workerList) {
925
- workerList[pid].worker.send({
926
- 'action': 'stop'
927
- });
928
- await createChildProcess(workerList[pid].cpu);
929
- delete workerList[pid];
930
- }
956
+ restartWorkers().then(() => {
931
957
  restarting = false;
932
958
  lCore.display('[HMR] All workers reloaded.');
933
- })().catch((e) => {
959
+ }).catch((e) => {
934
960
  restarting = false;
935
961
  lCore.display('[HMR] Reload error:', e);
936
962
  });
package/sys/mod.d.ts CHANGED
@@ -96,7 +96,7 @@ export default class Mod {
96
96
  'value': kebab.DbValue;
97
97
  };
98
98
  /** --- 创建 JSON 字符串对象,用于 PGSQL 的 jsonb 字段 --- */
99
- static json(obj: kebab.Json): any;
99
+ static json<T>(obj: T): T;
100
100
  /**
101
101
  * --- 添加一个序列(允许超过 65536 的占位符会被拆分多次执行) ---
102
102
  * @param db 数据库对象
@@ -5,5 +5,5 @@
5
5
  */
6
6
  import * as CheckboxPrimitive from '@radix-ui/react-checkbox';
7
7
  type CheckboxProps = React.ComponentPropsWithoutRef<typeof CheckboxPrimitive.Root>;
8
- export declare function Checkbox({ className, ...props }: CheckboxProps): import("react/jsx-runtime").JSX.Element;
8
+ export declare function Checkbox({ className, ...props }: CheckboxProps): import("react").JSX.Element;
9
9
  export {};
@@ -1,3 +1,3 @@
1
1
  type InputProps = React.InputHTMLAttributes<HTMLInputElement>;
2
- export declare function Input({ className, ...props }: InputProps): import("react/jsx-runtime").JSX.Element;
2
+ export declare function Input({ className, ...props }: InputProps): import("react").JSX.Element;
3
3
  export {};
@@ -7,5 +7,5 @@ import * as LabelPrimitive from '@radix-ui/react-label';
7
7
  import { type VariantProps } from 'class-variance-authority';
8
8
  declare const labelVariants: (props?: import("class-variance-authority/types").ClassProp | undefined) => string;
9
9
  type LabelProps = React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root> & VariantProps<typeof labelVariants>;
10
- export declare function Label({ className, ...props }: LabelProps): import("react/jsx-runtime").JSX.Element;
10
+ export declare function Label({ className, ...props }: LabelProps): import("react").JSX.Element;
11
11
  export {};
@@ -5,5 +5,5 @@
5
5
  */
6
6
  import * as SwitchPrimitive from '@radix-ui/react-switch';
7
7
  type SwitchProps = React.ComponentPropsWithoutRef<typeof SwitchPrimitive.Root>;
8
- export declare function Switch({ className, ...props }: SwitchProps): import("react/jsx-runtime").JSX.Element;
8
+ export declare function Switch({ className, ...props }: SwitchProps): import("react").JSX.Element;
9
9
  export {};
@@ -48,5 +48,5 @@ interface IProps {
48
48
  * 框架负责用 StaticRouter(服务端)/ BrowserRouter(客户端)包裹本组件,
49
49
  * 组件内部只需使用 Routes/Route/Link 等,无需自行包裹 Router。
50
50
  */
51
- export default function ReactRouterPage({ title, serverTime, node, users, user, _urlBase, _urlStc, _staticVer, }: IProps): import("react/jsx-runtime").JSX.Element;
51
+ export default function ReactRouterPage({ title, serverTime, node, users, user, _urlBase, _urlStc, _staticVer, }: IProps): import("react").JSX.Element;
52
52
  export {};
@@ -44,5 +44,5 @@ interface IProps {
44
44
  '_staticVer': string;
45
45
  }
46
46
  /** --- Kebab React 全页面演示 --- */
47
- export default function ReactPage({ title, serverTime, node, _urlBase, _urlStc, _staticVer }: IProps): import("react/jsx-runtime").JSX.Element;
47
+ export default function ReactPage({ title, serverTime, node, _urlBase, _urlStc, _staticVer }: IProps): import("react").JSX.Element;
48
48
  export {};