@maiyunnet/kebab 9.13.7 → 9.13.8

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.7"` = `'9.13.7'`
1363
+ > `const` **VER**: `"9.13.8"` = `'9.13.8'`
1364
1364
 
1365
1365
  Defined in: [index.ts:10](https://github.com/maiyunnet/kebab/blob/master/index.ts#L10)
1366
1366
 
@@ -6829,7 +6829,7 @@ lib/db/conn/classes/Connection.md
6829
6829
 
6830
6830
  # Class: Connection
6831
6831
 
6832
- Defined in: [lib/db/conn.ts:34](https://github.com/maiyunnet/kebab/blob/master/lib/db/conn.ts#L34)
6832
+ Defined in: [lib/db/conn.ts:37](https://github.com/maiyunnet/kebab/blob/master/lib/db/conn.ts#L37)
6833
6833
 
6834
6834
  数据库连接对象
6835
6835
 
@@ -6839,7 +6839,7 @@ Defined in: [lib/db/conn.ts:34](https://github.com/maiyunnet/kebab/blob/master/l
6839
6839
 
6840
6840
  > **new Connection**(`etc`, `link`): `Connection`
6841
6841
 
6842
- Defined in: [lib/db/conn.ts:59](https://github.com/maiyunnet/kebab/blob/master/lib/db/conn.ts#L59)
6842
+ Defined in: [lib/db/conn.ts:62](https://github.com/maiyunnet/kebab/blob/master/lib/db/conn.ts#L62)
6843
6843
 
6844
6844
  #### Parameters
6845
6845
 
@@ -6861,7 +6861,7 @@ Defined in: [lib/db/conn.ts:59](https://github.com/maiyunnet/kebab/blob/master/l
6861
6861
 
6862
6862
  > **beginTransaction**(): `Promise`\<`boolean`\>
6863
6863
 
6864
- Defined in: [lib/db/conn.ts:319](https://github.com/maiyunnet/kebab/blob/master/lib/db/conn.ts#L319)
6864
+ Defined in: [lib/db/conn.ts:322](https://github.com/maiyunnet/kebab/blob/master/lib/db/conn.ts#L322)
6865
6865
 
6866
6866
  #### Returns
6867
6867
 
@@ -6873,7 +6873,7 @@ Defined in: [lib/db/conn.ts:319](https://github.com/maiyunnet/kebab/blob/master/
6873
6873
 
6874
6874
  > **commit**(): `Promise`\<`boolean`\>
6875
6875
 
6876
- Defined in: [lib/db/conn.ts:340](https://github.com/maiyunnet/kebab/blob/master/lib/db/conn.ts#L340)
6876
+ Defined in: [lib/db/conn.ts:343](https://github.com/maiyunnet/kebab/blob/master/lib/db/conn.ts#L343)
6877
6877
 
6878
6878
  #### Returns
6879
6879
 
@@ -6885,7 +6885,7 @@ Defined in: [lib/db/conn.ts:340](https://github.com/maiyunnet/kebab/blob/master/
6885
6885
 
6886
6886
  > **end**(): `Promise`\<`boolean`\>
6887
6887
 
6888
- Defined in: [lib/db/conn.ts:308](https://github.com/maiyunnet/kebab/blob/master/lib/db/conn.ts#L308)
6888
+ Defined in: [lib/db/conn.ts:311](https://github.com/maiyunnet/kebab/blob/master/lib/db/conn.ts#L311)
6889
6889
 
6890
6890
  关闭连接,一般情况下不使用
6891
6891
 
@@ -6899,7 +6899,7 @@ Defined in: [lib/db/conn.ts:308](https://github.com/maiyunnet/kebab/blob/master/
6899
6899
 
6900
6900
  > **execute**(`sql`, `values?`): `Promise`\<[`IPacket`](../../interfaces/IPacket.md)\>
6901
6901
 
6902
- Defined in: [lib/db/conn.ts:235](https://github.com/maiyunnet/kebab/blob/master/lib/db/conn.ts#L235)
6902
+ Defined in: [lib/db/conn.ts:238](https://github.com/maiyunnet/kebab/blob/master/lib/db/conn.ts#L238)
6903
6903
 
6904
6904
  执行一条 SQL 并获得影响行数对象 packet
6905
6905
 
@@ -6927,7 +6927,7 @@ Defined in: [lib/db/conn.ts:235](https://github.com/maiyunnet/kebab/blob/master/
6927
6927
 
6928
6928
  > **getEtc**(): [`IConfigDb`](../../../../index/interfaces/IConfigDb.md)
6929
6929
 
6930
- Defined in: [lib/db/conn.ts:68](https://github.com/maiyunnet/kebab/blob/master/lib/db/conn.ts#L68)
6930
+ Defined in: [lib/db/conn.ts:71](https://github.com/maiyunnet/kebab/blob/master/lib/db/conn.ts#L71)
6931
6931
 
6932
6932
  获取连接 etc 信息
6933
6933
 
@@ -6941,7 +6941,7 @@ Defined in: [lib/db/conn.ts:68](https://github.com/maiyunnet/kebab/blob/master/l
6941
6941
 
6942
6942
  > **getLast**(): `number`
6943
6943
 
6944
- Defined in: [lib/db/conn.ts:80](https://github.com/maiyunnet/kebab/blob/master/lib/db/conn.ts#L80)
6944
+ Defined in: [lib/db/conn.ts:83](https://github.com/maiyunnet/kebab/blob/master/lib/db/conn.ts#L83)
6945
6945
 
6946
6946
  获取最后一次获取连接的时间
6947
6947
 
@@ -6955,7 +6955,7 @@ Defined in: [lib/db/conn.ts:80](https://github.com/maiyunnet/kebab/blob/master/l
6955
6955
 
6956
6956
  > **getLastSql**(): `object`[]
6957
6957
 
6958
- Defined in: [lib/db/conn.ts:87](https://github.com/maiyunnet/kebab/blob/master/lib/db/conn.ts#L87)
6958
+ Defined in: [lib/db/conn.ts:90](https://github.com/maiyunnet/kebab/blob/master/lib/db/conn.ts#L90)
6959
6959
 
6960
6960
  获取最后两次执行的 sql 字符串
6961
6961
 
@@ -6969,7 +6969,7 @@ Defined in: [lib/db/conn.ts:87](https://github.com/maiyunnet/kebab/blob/master/l
6969
6969
 
6970
6970
  > **getService**(): [`ESERVICE`](../../enumerations/ESERVICE.md)
6971
6971
 
6972
- Defined in: [lib/db/conn.ts:73](https://github.com/maiyunnet/kebab/blob/master/lib/db/conn.ts#L73)
6972
+ Defined in: [lib/db/conn.ts:76](https://github.com/maiyunnet/kebab/blob/master/lib/db/conn.ts#L76)
6973
6973
 
6974
6974
  获取数据库服务类型
6975
6975
 
@@ -6983,7 +6983,7 @@ Defined in: [lib/db/conn.ts:73](https://github.com/maiyunnet/kebab/blob/master/l
6983
6983
 
6984
6984
  > **isAvailable**(`last?`): `Promise`\<`boolean`\>
6985
6985
 
6986
- Defined in: [lib/db/conn.ts:154](https://github.com/maiyunnet/kebab/blob/master/lib/db/conn.ts#L154)
6986
+ Defined in: [lib/db/conn.ts:157](https://github.com/maiyunnet/kebab/blob/master/lib/db/conn.ts#L157)
6987
6987
 
6988
6988
  通过执行一条语句判断当前连接是否可用
6989
6989
 
@@ -7005,7 +7005,7 @@ Defined in: [lib/db/conn.ts:154](https://github.com/maiyunnet/kebab/blob/master/
7005
7005
 
7006
7006
  > **isLost**(): `boolean`
7007
7007
 
7008
- Defined in: [lib/db/conn.ts:104](https://github.com/maiyunnet/kebab/blob/master/lib/db/conn.ts#L104)
7008
+ Defined in: [lib/db/conn.ts:107](https://github.com/maiyunnet/kebab/blob/master/lib/db/conn.ts#L107)
7009
7009
 
7010
7010
  是否已经丢失
7011
7011
 
@@ -7019,7 +7019,7 @@ Defined in: [lib/db/conn.ts:104](https://github.com/maiyunnet/kebab/blob/master/
7019
7019
 
7020
7020
  > **isTransaction**(): `boolean`
7021
7021
 
7022
- Defined in: [lib/db/conn.ts:111](https://github.com/maiyunnet/kebab/blob/master/lib/db/conn.ts#L111)
7022
+ Defined in: [lib/db/conn.ts:114](https://github.com/maiyunnet/kebab/blob/master/lib/db/conn.ts#L114)
7023
7023
 
7024
7024
  是否是开启事务状态
7025
7025
 
@@ -7033,7 +7033,7 @@ Defined in: [lib/db/conn.ts:111](https://github.com/maiyunnet/kebab/blob/master/
7033
7033
 
7034
7034
  > **isUsing**(): `boolean`
7035
7035
 
7036
- Defined in: [lib/db/conn.ts:118](https://github.com/maiyunnet/kebab/blob/master/lib/db/conn.ts#L118)
7036
+ Defined in: [lib/db/conn.ts:121](https://github.com/maiyunnet/kebab/blob/master/lib/db/conn.ts#L121)
7037
7037
 
7038
7038
  获取当前状态是否正在被使用中
7039
7039
 
@@ -7047,7 +7047,7 @@ Defined in: [lib/db/conn.ts:118](https://github.com/maiyunnet/kebab/blob/master/
7047
7047
 
7048
7048
  > **query**(`sql`, `values?`): `Promise`\<[`IData`](../../interfaces/IData.md)\>
7049
7049
 
7050
- Defined in: [lib/db/conn.ts:177](https://github.com/maiyunnet/kebab/blob/master/lib/db/conn.ts#L177)
7050
+ Defined in: [lib/db/conn.ts:180](https://github.com/maiyunnet/kebab/blob/master/lib/db/conn.ts#L180)
7051
7051
 
7052
7052
  执行一条 SQL 并获得返回数据
7053
7053
 
@@ -7075,7 +7075,7 @@ Defined in: [lib/db/conn.ts:177](https://github.com/maiyunnet/kebab/blob/master/
7075
7075
 
7076
7076
  > **refreshLast**(): `void`
7077
7077
 
7078
- Defined in: [lib/db/conn.ts:146](https://github.com/maiyunnet/kebab/blob/master/lib/db/conn.ts#L146)
7078
+ Defined in: [lib/db/conn.ts:149](https://github.com/maiyunnet/kebab/blob/master/lib/db/conn.ts#L149)
7079
7079
 
7080
7080
  设定最后使用时间
7081
7081
 
@@ -7089,7 +7089,7 @@ Defined in: [lib/db/conn.ts:146](https://github.com/maiyunnet/kebab/blob/master/
7089
7089
 
7090
7090
  > **rollback**(): `Promise`\<`boolean`\>
7091
7091
 
7092
- Defined in: [lib/db/conn.ts:358](https://github.com/maiyunnet/kebab/blob/master/lib/db/conn.ts#L358)
7092
+ Defined in: [lib/db/conn.ts:361](https://github.com/maiyunnet/kebab/blob/master/lib/db/conn.ts#L361)
7093
7093
 
7094
7094
  #### Returns
7095
7095
 
@@ -7101,7 +7101,7 @@ Defined in: [lib/db/conn.ts:358](https://github.com/maiyunnet/kebab/blob/master/
7101
7101
 
7102
7102
  > **setLost**(): `void`
7103
7103
 
7104
- Defined in: [lib/db/conn.ts:97](https://github.com/maiyunnet/kebab/blob/master/lib/db/conn.ts#L97)
7104
+ Defined in: [lib/db/conn.ts:100](https://github.com/maiyunnet/kebab/blob/master/lib/db/conn.ts#L100)
7105
7105
 
7106
7106
  将本条连接设置为不可用
7107
7107
 
@@ -7115,7 +7115,7 @@ Defined in: [lib/db/conn.ts:97](https://github.com/maiyunnet/kebab/blob/master/l
7115
7115
 
7116
7116
  > **used**(): `void`
7117
7117
 
7118
- Defined in: [lib/db/conn.ts:139](https://github.com/maiyunnet/kebab/blob/master/lib/db/conn.ts#L139)
7118
+ Defined in: [lib/db/conn.ts:142](https://github.com/maiyunnet/kebab/blob/master/lib/db/conn.ts#L142)
7119
7119
 
7120
7120
  取消占用
7121
7121
 
@@ -7129,7 +7129,7 @@ Defined in: [lib/db/conn.ts:139](https://github.com/maiyunnet/kebab/blob/master/
7129
7129
 
7130
7130
  > **using**(): `boolean`
7131
7131
 
7132
- Defined in: [lib/db/conn.ts:125](https://github.com/maiyunnet/kebab/blob/master/lib/db/conn.ts#L125)
7132
+ Defined in: [lib/db/conn.ts:128](https://github.com/maiyunnet/kebab/blob/master/lib/db/conn.ts#L128)
7133
7133
 
7134
7134
  判断是否可用(丢失的也算不可用),返回 true 代表获取成功并自动刷新最后时间
7135
7135
 
@@ -26510,7 +26510,7 @@ sys/route/functions/getFormData.md
26510
26510
 
26511
26511
  > **getFormData**(`req`, `events?`, `limits?`): `Promise`\<`false` \| \{ `files`: `Record`\<`string`, [`IPostFile`](../../../index/interfaces/IPostFile.md) \| [`IPostFile`](../../../index/interfaces/IPostFile.md)[]\>; `post`: `Record`\<`string`, [`Json`](../../../index/type-aliases/Json.md)\>; \}\>
26512
26512
 
26513
- Defined in: [sys/route.ts:970](https://github.com/maiyunnet/kebab/blob/master/sys/route.ts#L970)
26513
+ Defined in: [sys/route.ts:980](https://github.com/maiyunnet/kebab/blob/master/sys/route.ts#L980)
26514
26514
 
26515
26515
  获取 formdata 的 post
26516
26516
 
@@ -26577,7 +26577,7 @@ sys/route/functions/getPost.md
26577
26577
 
26578
26578
  > **getPost**(`req`): `Promise`\<\{ `input`: `string`; `post`: `Record`\<`string`, `any`\>; `raw`: `Record`\<`string`, `any`\>; \}\>
26579
26579
 
26580
- Defined in: [sys/route.ts:884](https://github.com/maiyunnet/kebab/blob/master/sys/route.ts#L884)
26580
+ Defined in: [sys/route.ts:894](https://github.com/maiyunnet/kebab/blob/master/sys/route.ts#L894)
26581
26581
 
26582
26582
  获取 post 对象(通常已自动获取),如果是文件上传(formdata)的情况则不获取
26583
26583
 
@@ -26606,7 +26606,7 @@ sys/route/functions/run.md
26606
26606
 
26607
26607
  > **run**(`data`): `Promise`\<`boolean`\>
26608
26608
 
26609
- Defined in: [sys/route.ts:77](https://github.com/maiyunnet/kebab/blob/master/sys/route.ts#L77)
26609
+ Defined in: [sys/route.ts:87](https://github.com/maiyunnet/kebab/blob/master/sys/route.ts#L87)
26610
26610
 
26611
26611
  若为动态路径则执行此函数,此函数不进行判断 kebab.json 是否存在
26612
26612
 
@@ -26693,7 +26693,7 @@ sys/route/functions/unlinkUploadFiles.md
26693
26693
 
26694
26694
  > **unlinkUploadFiles**(`cctr`): `Promise`\<`void`\>
26695
26695
 
26696
- Defined in: [sys/route.ts:843](https://github.com/maiyunnet/kebab/blob/master/sys/route.ts#L843)
26696
+ Defined in: [sys/route.ts:853](https://github.com/maiyunnet/kebab/blob/master/sys/route.ts#L853)
26697
26697
 
26698
26698
  删除本次请求所有已上传的临时文件
26699
26699
 
@@ -26722,7 +26722,7 @@ sys/route/functions/waitCtr.md
26722
26722
 
26723
26723
  > **waitCtr**(`cctr`): `Promise`\<`void`\>
26724
26724
 
26725
- Defined in: [sys/route.ts:863](https://github.com/maiyunnet/kebab/blob/master/sys/route.ts#L863)
26725
+ Defined in: [sys/route.ts:873](https://github.com/maiyunnet/kebab/blob/master/sys/route.ts#L873)
26726
26726
 
26727
26727
  等待异步任务结束,并删除临时文件,如果结束后还有事务没关闭,则会在本函数中打印控制台并且写入 log 文件
26728
26728
  此时其实已经给客户端返回了,此处等待不消耗客户端的等待时间
package/index.d.ts CHANGED
@@ -1,11 +1,11 @@
1
1
  /**
2
2
  * Project: Kebab, User: JianSuoQiYue
3
3
  * Date: 2019-3-30 12:46:41
4
- * Last: 2020-3-8 21:04:24, 2022-07-22 14:20:34, 2023-5-24 01:34:57, 2025-6-13 14:49:27, 2025-10-1 10:11:54
4
+ * Last: 2020-3-8 21:04:24, 2022-07-22 14:20:34, 2023-5-24 01:34:57, 2025-6-13 14:49:27, 2025-10-1 10:11:54, 2026-07-14 17:40:00
5
5
  * --- 本文件用来定义每个目录实体地址的常量 ---
6
6
  */
7
7
  /** --- 当前系统版本号 --- */
8
- export declare const VER = "9.13.7";
8
+ export declare const VER = "9.13.8";
9
9
  /** --- 框架根目录,以 / 结尾 --- */
10
10
  export declare const ROOT_PATH: string;
11
11
  /** --- 框架的 LIB,以 / 结尾 --- */
package/index.js CHANGED
@@ -2,11 +2,11 @@
2
2
  /**
3
3
  * Project: Kebab, User: JianSuoQiYue
4
4
  * Date: 2019-3-30 12:46:41
5
- * Last: 2020-3-8 21:04:24, 2022-07-22 14:20:34, 2023-5-24 01:34:57, 2025-6-13 14:49:27, 2025-10-1 10:11:54
5
+ * Last: 2020-3-8 21:04:24, 2022-07-22 14:20:34, 2023-5-24 01:34:57, 2025-6-13 14:49:27, 2025-10-1 10:11:54, 2026-07-14 17:40:00
6
6
  * --- 本文件用来定义每个目录实体地址的常量 ---
7
7
  */
8
8
  /** --- 当前系统版本号 --- */
9
- export const VER = '9.13.7';
9
+ export const VER = '9.13.8';
10
10
  // --- 服务端用的路径 ---
11
11
  const imu = decodeURIComponent(import.meta.url).replace('file://', '').replace(/^\/(\w:)/, '$1');
12
12
  /** --- /xxx/xxx --- */
package/lib/db/conn.js CHANGED
@@ -3,6 +3,8 @@ import * as lCore from '#kebab/lib/core.js';
3
3
  import * as lTime from '#kebab/lib/time.js';
4
4
  import * as lDb from '#kebab/lib/db.js';
5
5
  // --- 注册解析器 ---
6
+ // --- pg 库对以下类型默认返回 string,为与 MySQL 行为保持一致,在此注册解析器转为 JS 原生类型 ---
7
+ // --- POLYGON: 返回如 ((1,1),(2,2)) 的字符串,解析为 {x, y}[] ---
6
8
  pg.types.setTypeParser(pg.types.builtins.POLYGON, val => {
7
9
  if (val === null) {
8
10
  return null;
@@ -20,6 +22,7 @@ pg.types.setTypeParser(pg.types.builtins.POLYGON, val => {
20
22
  // --- 返回 [{x: 1, y: 1}, {x :2, y: 2}, ... ] ---
21
23
  return points;
22
24
  });
25
+ // --- INT8 (bigint): JS Number 无法安全表示 64 位整数,pg 默认返回 string,parseInt 转为 number ---
23
26
  pg.types.setTypeParser(pg.types.builtins.INT8, val => {
24
27
  if (val === null) {
25
28
  return null;
@@ -170,7 +173,7 @@ export class Connection {
170
173
  }));
171
174
  }
172
175
  else {
173
- const res = await this._link.execute(sql, values);
176
+ const res = await this._link.query(sql, values);
174
177
  rtn.rows = res[0];
175
178
  if (res[1]) {
176
179
  rtn.fields = res[1].map(item => ({
@@ -236,7 +239,7 @@ export class Connection {
236
239
  }));
237
240
  }
238
241
  else {
239
- const res = await this._link.execute(sql, values);
242
+ const res = await this._link.query(sql, values);
240
243
  rtn.packet = {
241
244
  'affected': res[0].affectedRows,
242
245
  'insert': res[0].insertId,
@@ -31,7 +31,7 @@ export declare class Response {
31
31
  /**
32
32
  * --- 获取响应读取流对象 ---
33
33
  */
34
- getStream(): (import("undici/types/readable").default & undici.Dispatcher.BodyMixin) | zlib.Gunzip | zlib.Inflate | zlib.BrotliDecompress | null;
34
+ getStream(): zlib.BrotliDecompress | zlib.Gunzip | zlib.Inflate | (import("undici/types/readable").default & undici.Dispatcher.BodyMixin) | 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.7",
3
+ "version": "9.13.8",
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": [
package/sys/child.js CHANGED
@@ -303,7 +303,9 @@ async function requestHandler(req, res, https) {
303
303
  res.setHeader('content-length', Buffer.byteLength(content));
304
304
  lCore.writeHead(res, 500);
305
305
  }
306
- res.end(content);
306
+ if (!res.writableEnded) {
307
+ res.end(content);
308
+ }
307
309
  return;
308
310
  }
309
311
  }
@@ -344,7 +346,9 @@ async function requestHandler(req, res, https) {
344
346
  res.setHeader('content-length', Buffer.byteLength(content));
345
347
  lCore.writeHead(res, 500);
346
348
  }
347
- res.end(content);
349
+ if (!res.writableEnded) {
350
+ res.end(content);
351
+ }
348
352
  return;
349
353
  }
350
354
  }
package/sys/route.js CHANGED
@@ -37,7 +37,9 @@ function respond500(res) {
37
37
  res.setHeader('content-length', Buffer.byteLength(content));
38
38
  lCore.writeHead(res, 500);
39
39
  }
40
- res.end(content);
40
+ if (!res.writableEnded) {
41
+ res.end(content);
42
+ }
41
43
  }
42
44
  /**
43
45
  * --- 输出 404 错误响应 ---
@@ -47,16 +49,24 @@ function respond500(res) {
47
49
  */
48
50
  function respond404(res, config, path) {
49
51
  if (config?.route?.['#404']) {
50
- res.setHeader('location', lText.urlResolve(config.const.urlBase, config.route['#404']));
51
- lCore.writeHead(res, 302);
52
- res.end('');
52
+ if (!res.headersSent) {
53
+ res.setHeader('location', lText.urlResolve(config.const.urlBase, config.route['#404']));
54
+ lCore.writeHead(res, 302);
55
+ }
56
+ if (!res.writableEnded) {
57
+ res.end('');
58
+ }
53
59
  return;
54
60
  }
55
61
  const content = '[Error] Controller not found, path: ' + path + '.';
56
- res.setHeader('content-type', 'text/html; charset=utf-8');
57
- res.setHeader('content-length', Buffer.byteLength(content));
58
- lCore.writeHead(res, 404);
59
- res.end(content);
62
+ if (!res.headersSent) {
63
+ res.setHeader('content-type', 'text/html; charset=utf-8');
64
+ res.setHeader('content-length', Buffer.byteLength(content));
65
+ lCore.writeHead(res, 404);
66
+ }
67
+ if (!res.writableEnded) {
68
+ res.end(content);
69
+ }
60
70
  }
61
71
  /**
62
72
  * --- 若为动态路径则执行此函数,此函数不进行判断 kebab.json 是否存在 ---