@maiyunnet/kebab 3.2.11 → 3.2.13

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/index.d.ts CHANGED
@@ -5,7 +5,7 @@
5
5
  * --- 本文件用来定义每个目录实体地址的常量 ---
6
6
  */
7
7
  /** --- 当前系统版本号 --- */
8
- export declare const VER = "3.2.11";
8
+ export declare const VER = "3.2.13";
9
9
  /** --- 框架根目录,以 / 结尾 --- */
10
10
  export declare const ROOT_PATH: string;
11
11
  export declare const LIB_PATH: string;
package/index.js CHANGED
@@ -6,7 +6,7 @@
6
6
  * --- 本文件用来定义每个目录实体地址的常量 ---
7
7
  */
8
8
  /** --- 当前系统版本号 --- */
9
- export const VER = '3.2.11';
9
+ export const VER = '3.2.13';
10
10
  // --- 服务端用的路径 ---
11
11
  const imu = decodeURIComponent(import.meta.url).replace('file://', '').replace(/^\/(\w:)/, '$1');
12
12
  /** --- /xxx/xxx --- */
package/lib/core.js CHANGED
@@ -360,6 +360,9 @@ export async function passThroughAppend(passThrough, data, end = true) {
360
360
  for (const item of data) {
361
361
  if (item instanceof stream.Readable || item instanceof lResponse.Response) {
362
362
  const stm = item instanceof stream.Readable ? item : item.getStream();
363
+ if (!stm) {
364
+ continue;
365
+ }
363
366
  // --- 读取流、Net 库 Response 对象 ---
364
367
  stm.pipe(passThrough, {
365
368
  'end': false
@@ -27,9 +27,9 @@ export declare class Response {
27
27
  /**
28
28
  * --- 获取响应读取流对象 ---
29
29
  */
30
- getStream(): stream.Readable;
30
+ getStream(): stream.Readable | null;
31
31
  /**
32
32
  * --- 获取原生响应读取流对象 ---
33
33
  */
34
- getRawStream(): stream.Readable;
34
+ getRawStream(): stream.Readable | null;
35
35
  }
@@ -29,12 +29,12 @@ export class Response {
29
29
  * --- 获取响应读取流对象 ---
30
30
  */
31
31
  getStream() {
32
- return this._req.getStream();
32
+ return this._req ? this._req.getStream() : null;
33
33
  }
34
34
  /**
35
35
  * --- 获取原生响应读取流对象 ---
36
36
  */
37
37
  getRawStream() {
38
- return this._req.getRawStream();
38
+ return this._req ? this._req.getRawStream() : null;
39
39
  }
40
40
  }
package/lib/net.js CHANGED
@@ -494,6 +494,10 @@ export async function mproxy(ctr, auth, opt = {}) {
494
494
  ...opt,
495
495
  headers
496
496
  });
497
+ const stream = rres.getRawStream();
498
+ if (!stream) {
499
+ return -3;
500
+ }
497
501
  if (rres.error) {
498
502
  return -2;
499
503
  }
@@ -502,7 +506,7 @@ export async function mproxy(ctr, auth, opt = {}) {
502
506
  }
503
507
  res.writeHead(rres.headers?.['http-code'] ?? 200);
504
508
  await new Promise((resolve) => {
505
- rres.getRawStream().pipe(res).on('finish', () => {
509
+ stream.pipe(res).on('finish', () => {
506
510
  resolve();
507
511
  });
508
512
  });
@@ -554,6 +558,10 @@ export async function rproxy(ctr, route, opt = {}) {
554
558
  ...opt,
555
559
  headers
556
560
  });
561
+ const stream = rres.getRawStream();
562
+ if (!stream) {
563
+ return false;
564
+ }
557
565
  if (rres.error) {
558
566
  return false;
559
567
  }
@@ -562,7 +570,7 @@ export async function rproxy(ctr, route, opt = {}) {
562
570
  }
563
571
  res.writeHead(rres.headers?.['http-code'] ?? 200);
564
572
  await new Promise((resolve) => {
565
- rres.getRawStream().pipe(res).on('finish', () => {
573
+ stream.pipe(res).on('finish', () => {
566
574
  resolve();
567
575
  });
568
576
  });
package/lib/s3.d.ts CHANGED
@@ -60,7 +60,7 @@ export declare class S3 {
60
60
  * @param key 对象路径
61
61
  * @param bucket bucket 名
62
62
  */
63
- getObject(key: string, bucket?: string): Promise<any>;
63
+ getObject(key: string, bucket?: string): Promise<false | (stream.Readable & import("@smithy/types").SdkStreamMixin) | (Blob & import("@smithy/types").SdkStreamMixin) | (ReadableStream<any> & import("@smithy/types").SdkStreamMixin) | undefined>;
64
64
  /**
65
65
  * --- 删除对象 ---
66
66
  * @param key 对象路径
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@maiyunnet/kebab",
3
- "version": "3.2.11",
3
+ "version": "3.2.13",
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/mod.d.ts CHANGED
@@ -19,7 +19,7 @@ declare class Rows<T extends Mod> implements CRows<T> {
19
19
  get length(): number;
20
20
  /** --- 通过索引获取一个对象 --- */
21
21
  item(index: number): T;
22
- /** --- 转换为数组对象 --- */
22
+ /** --- 转换为数组对象,获取的是新创建的数组 --- */
23
23
  toArray(): Array<Record<string, any>>;
24
24
  /** --- 根据规则筛掉项,predicate 返回 true 代表保留 --- */
25
25
  filter(predicate: (value: T, index: number) => boolean): Rows<T>;
@@ -272,7 +272,7 @@ export default class Mod {
272
272
  'index'?: string;
273
273
  }): Promise<any[] | false>;
274
274
  /**
275
- * --- 将 key val 组成的数据列表转换为原生对象模式 ---
275
+ * --- 将 key val 组成的数据列表转换为原生对象模式,获取的是新创建的数组 ---
276
276
  * @param obj 要转换的 kv 数据列表
277
277
  */
278
278
  static toArrayByRecord<T extends Mod>(obj: Record<string, T>): Record<string, Record<string, any>>;
@@ -453,7 +453,7 @@ export default class Mod {
453
453
  */
454
454
  format(sql?: string, data?: any[]): string;
455
455
  /**
456
- * --- 获取值对象 ---
456
+ * --- 获取值对象,获取的是新创建的数组 ---
457
457
  */
458
458
  toArray<TC extends abstract new (...args: any) => any>(): TOnlyProperties<InstanceType<TC>> & Record<string, any>;
459
459
  /**
@@ -481,7 +481,7 @@ export declare class CRows<T> implements Iterable<T> {
481
481
  get length(): number;
482
482
  /** --- 通过索引获取一个对象 --- */
483
483
  item(index: number): T;
484
- /** --- 转换为数组对象 --- */
484
+ /** --- 转换为数组对象,获取的是新创建的数组 --- */
485
485
  toArray(): Array<Record<string, kebab.DbValue>>;
486
486
  [Symbol.iterator](): Iterator<T>;
487
487
  }
package/sys/mod.js CHANGED
@@ -22,7 +22,7 @@ class Rows {
22
22
  item(index) {
23
23
  return this._items[index];
24
24
  }
25
- /** --- 转换为数组对象 --- */
25
+ /** --- 转换为数组对象,获取的是新创建的数组 --- */
26
26
  toArray() {
27
27
  const arr = [];
28
28
  for (const item of this._items) {
@@ -544,7 +544,7 @@ class Mod {
544
544
  return primarys;
545
545
  }
546
546
  /**
547
- * --- 将 key val 组成的数据列表转换为原生对象模式 ---
547
+ * --- 将 key val 组成的数据列表转换为原生对象模式,获取的是新创建的数组 ---
548
548
  * @param obj 要转换的 kv 数据列表
549
549
  */
550
550
  static toArrayByRecord(obj) {
@@ -1393,10 +1393,10 @@ class Mod {
1393
1393
  return this._sql.format(sql, data);
1394
1394
  }
1395
1395
  /**
1396
- * --- 获取值对象 ---
1396
+ * --- 获取值对象,获取的是新创建的数组 ---
1397
1397
  */
1398
1398
  toArray() {
1399
- return this._data;
1399
+ return { ...this._data };
1400
1400
  }
1401
1401
  /**
1402
1402
  * --- 获取当前设置要提交的数据 ---
package/sys/route.js CHANGED
@@ -579,12 +579,7 @@ export async function run(data) {
579
579
  // --- 已经自行输出过 writeHead,可能自行处理了内容,如 pipe,则不再 writeHead ---
580
580
  }
581
581
  else {
582
- if (data.res.getHeader('location')) {
583
- data.res.writeHead(302);
584
- }
585
- else {
586
- data.res.writeHead(httpCode);
587
- }
582
+ data.res.writeHead(data.res.getHeader('location') ? 302 : httpCode);
588
583
  }
589
584
  if (!data.res.writableEnded) {
590
585
  // --- 如果当前还没结束,则强制关闭连接,一切 pipe 请自行在方法中 await,否则会被中断 ---
@@ -623,6 +618,11 @@ export async function run(data) {
623
618
  else if (rtn instanceof stream.Readable || rtn instanceof lResponse.Response) {
624
619
  // --- 返回的是流,那就以管道的形式输出 ---
625
620
  const stm = rtn instanceof stream.Readable ? rtn : rtn.getStream();
621
+ if (!stm) {
622
+ data.res.end('');
623
+ await waitCtr(cctr ?? middle);
624
+ return true;
625
+ }
626
626
  /** --- 当前的压缩对象 --- */
627
627
  let compress = null;
628
628
  if (!data.res.headersSent) {