@maiyunnet/kebab 9.12.2 → 9.13.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 +207 -11
- package/index.d.ts +1 -1
- package/index.js +1 -1
- package/lib/s3.d.ts +39 -0
- package/lib/s3.js +40 -1
- package/package.json +1 -1
- package/sys/child.js +1 -1
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.
|
|
1363
|
+
> `const` **VER**: `"9.13.0"` = `'9.13.0'`
|
|
1364
1364
|
|
|
1365
1365
|
Defined in: [index.ts:10](https://github.com/maiyunnet/kebab/blob/master/index.ts#L10)
|
|
1366
1366
|
|
|
@@ -12555,7 +12555,7 @@ lib/s3/classes/S3.md
|
|
|
12555
12555
|
|
|
12556
12556
|
# Class: S3
|
|
12557
12557
|
|
|
12558
|
-
Defined in: [lib/s3.ts:
|
|
12558
|
+
Defined in: [lib/s3.ts:79](https://github.com/maiyunnet/kebab/blob/master/lib/s3.ts#L79)
|
|
12559
12559
|
|
|
12560
12560
|
## Constructors
|
|
12561
12561
|
|
|
@@ -12563,7 +12563,7 @@ Defined in: [lib/s3.ts:43](https://github.com/maiyunnet/kebab/blob/master/lib/s3
|
|
|
12563
12563
|
|
|
12564
12564
|
> **new S3**(`ctr`, `opt`): `S3`
|
|
12565
12565
|
|
|
12566
|
-
Defined in: [lib/s3.ts:
|
|
12566
|
+
Defined in: [lib/s3.ts:88](https://github.com/maiyunnet/kebab/blob/master/lib/s3.ts#L88)
|
|
12567
12567
|
|
|
12568
12568
|
#### Parameters
|
|
12569
12569
|
|
|
@@ -12585,7 +12585,7 @@ Defined in: [lib/s3.ts:52](https://github.com/maiyunnet/kebab/blob/master/lib/s3
|
|
|
12585
12585
|
|
|
12586
12586
|
> **deleteObject**(`key`, `bucket?`): `Promise`\<`boolean`\>
|
|
12587
12587
|
|
|
12588
|
-
Defined in: [lib/s3.ts:
|
|
12588
|
+
Defined in: [lib/s3.ts:255](https://github.com/maiyunnet/kebab/blob/master/lib/s3.ts#L255)
|
|
12589
12589
|
|
|
12590
12590
|
删除对象
|
|
12591
12591
|
|
|
@@ -12613,7 +12613,7 @@ bucket 名
|
|
|
12613
12613
|
|
|
12614
12614
|
> **deleteObjects**(`keys`, `bucket?`): `Promise`\<`boolean`\>
|
|
12615
12615
|
|
|
12616
|
-
Defined in: [lib/s3.ts:
|
|
12616
|
+
Defined in: [lib/s3.ts:275](https://github.com/maiyunnet/kebab/blob/master/lib/s3.ts#L275)
|
|
12617
12617
|
|
|
12618
12618
|
批量删除对象
|
|
12619
12619
|
|
|
@@ -12641,7 +12641,7 @@ bucket 名
|
|
|
12641
12641
|
|
|
12642
12642
|
> **destroy**(): `void`
|
|
12643
12643
|
|
|
12644
|
-
Defined in: [lib/s3.ts:
|
|
12644
|
+
Defined in: [lib/s3.ts:317](https://github.com/maiyunnet/kebab/blob/master/lib/s3.ts#L317)
|
|
12645
12645
|
|
|
12646
12646
|
销毁连接,释放资源
|
|
12647
12647
|
一般会自动垃圾回收,但高频接口也可主动调用
|
|
@@ -12656,7 +12656,7 @@ Defined in: [lib/s3.ts:231](https://github.com/maiyunnet/kebab/blob/master/lib/s
|
|
|
12656
12656
|
|
|
12657
12657
|
> **getObject**(`key`, `bucket?`): `Promise`\<`false` \| `Readable` & `SdkStreamMixin` \| `Blob` & `SdkStreamMixin` \| `ReadableStream`\<`any`\> & `SdkStreamMixin` \| `undefined`\>
|
|
12658
12658
|
|
|
12659
|
-
Defined in: [lib/s3.ts:
|
|
12659
|
+
Defined in: [lib/s3.ts:235](https://github.com/maiyunnet/kebab/blob/master/lib/s3.ts#L235)
|
|
12660
12660
|
|
|
12661
12661
|
获取对象流,可通过流获取 buffer 或 text
|
|
12662
12662
|
|
|
@@ -12684,7 +12684,7 @@ bucket 名
|
|
|
12684
12684
|
|
|
12685
12685
|
> **headObject**(`key`, `bucket?`): `Promise`\<`false` \| `HeadObjectCommandOutput`\>
|
|
12686
12686
|
|
|
12687
|
-
Defined in: [lib/s3.ts:
|
|
12687
|
+
Defined in: [lib/s3.ts:297](https://github.com/maiyunnet/kebab/blob/master/lib/s3.ts#L297)
|
|
12688
12688
|
|
|
12689
12689
|
检测对象是否存在
|
|
12690
12690
|
|
|
@@ -12712,7 +12712,7 @@ bucket 名
|
|
|
12712
12712
|
|
|
12713
12713
|
> **putObject**(`key`, `content`, `length?`, `bucket?`): `Promise`\<`false` \| `CompleteMultipartUploadCommandOutput`\>
|
|
12714
12714
|
|
|
12715
|
-
Defined in: [lib/s3.ts:
|
|
12715
|
+
Defined in: [lib/s3.ts:139](https://github.com/maiyunnet/kebab/blob/master/lib/s3.ts#L139)
|
|
12716
12716
|
|
|
12717
12717
|
上传对象(可传流且也可无需设置 length) --
|
|
12718
12718
|
|
|
@@ -12776,11 +12776,39 @@ bucket 名
|
|
|
12776
12776
|
|
|
12777
12777
|
***
|
|
12778
12778
|
|
|
12779
|
+
### putObjects()
|
|
12780
|
+
|
|
12781
|
+
> **putObjects**(`items`, `options?`): `Promise`\<[`IPutObjectsItemResult`](../interfaces/IPutObjectsItemResult.md)[]\>
|
|
12782
|
+
|
|
12783
|
+
Defined in: [lib/s3.ts:184](https://github.com/maiyunnet/kebab/blob/master/lib/s3.ts#L184)
|
|
12784
|
+
|
|
12785
|
+
批量上传对象,并发控制,单次失败不影响其他项
|
|
12786
|
+
|
|
12787
|
+
#### Parameters
|
|
12788
|
+
|
|
12789
|
+
##### items
|
|
12790
|
+
|
|
12791
|
+
[`IPutObjectItem`](../interfaces/IPutObjectItem.md)[]
|
|
12792
|
+
|
|
12793
|
+
上传项列表
|
|
12794
|
+
|
|
12795
|
+
##### options?
|
|
12796
|
+
|
|
12797
|
+
[`IPutObjectsOptions`](../interfaces/IPutObjectsOptions.md)
|
|
12798
|
+
|
|
12799
|
+
批量上传选项
|
|
12800
|
+
|
|
12801
|
+
#### Returns
|
|
12802
|
+
|
|
12803
|
+
`Promise`\<[`IPutObjectsItemResult`](../interfaces/IPutObjectsItemResult.md)[]\>
|
|
12804
|
+
|
|
12805
|
+
***
|
|
12806
|
+
|
|
12779
12807
|
### setBucket()
|
|
12780
12808
|
|
|
12781
12809
|
> **setBucket**(`bucket`): `void`
|
|
12782
12810
|
|
|
12783
|
-
Defined in: [lib/s3.ts:
|
|
12811
|
+
Defined in: [lib/s3.ts:128](https://github.com/maiyunnet/kebab/blob/master/lib/s3.ts#L128)
|
|
12784
12812
|
|
|
12785
12813
|
修改预定义 bucket
|
|
12786
12814
|
|
|
@@ -12856,7 +12884,7 @@ lib/s3/functions/get.md
|
|
|
12856
12884
|
|
|
12857
12885
|
> **get**(`ctr`, `opt`): [`S3`](../classes/S3.md)
|
|
12858
12886
|
|
|
12859
|
-
Defined in: [lib/s3.ts:
|
|
12887
|
+
Defined in: [lib/s3.ts:327](https://github.com/maiyunnet/kebab/blob/master/lib/s3.ts#L327)
|
|
12860
12888
|
|
|
12861
12889
|
创建一个对象存储对象
|
|
12862
12890
|
|
|
@@ -12898,6 +12926,9 @@ lib/s3/index.md
|
|
|
12898
12926
|
## Interfaces
|
|
12899
12927
|
|
|
12900
12928
|
- [IOptions](interfaces/IOptions.md)
|
|
12929
|
+
- [IPutObjectItem](interfaces/IPutObjectItem.md)
|
|
12930
|
+
- [IPutObjectsItemResult](interfaces/IPutObjectsItemResult.md)
|
|
12931
|
+
- [IPutObjectsOptions](interfaces/IPutObjectsOptions.md)
|
|
12901
12932
|
|
|
12902
12933
|
## Functions
|
|
12903
12934
|
|
|
@@ -12978,6 +13009,171 @@ Defined in: [lib/s3.ts:30](https://github.com/maiyunnet/kebab/blob/master/lib/s3
|
|
|
12978
13009
|
|
|
12979
13010
|
服务商 -
|
|
12980
13011
|
|
|
13012
|
+
lib/s3/interfaces/IPutObjectItem.md
|
|
13013
|
+
---
|
|
13014
|
+
|
|
13015
|
+
[**Documents for @maiyunnet/kebab**](../../../index.md)
|
|
13016
|
+
|
|
13017
|
+
***
|
|
13018
|
+
|
|
13019
|
+
[Documents for @maiyunnet/kebab](../../../index.md) / [lib/s3](../index.md) / IPutObjectItem
|
|
13020
|
+
|
|
13021
|
+
# Interface: IPutObjectItem
|
|
13022
|
+
|
|
13023
|
+
Defined in: [lib/s3.ts:44](https://github.com/maiyunnet/kebab/blob/master/lib/s3.ts#L44)
|
|
13024
|
+
|
|
13025
|
+
批量上传单项
|
|
13026
|
+
|
|
13027
|
+
## Properties
|
|
13028
|
+
|
|
13029
|
+
### bucket?
|
|
13030
|
+
|
|
13031
|
+
> `optional` **bucket?**: `string`
|
|
13032
|
+
|
|
13033
|
+
Defined in: [lib/s3.ts:56](https://github.com/maiyunnet/kebab/blob/master/lib/s3.ts#L56)
|
|
13034
|
+
|
|
13035
|
+
bucket 名,优先级高于 options.bucket
|
|
13036
|
+
|
|
13037
|
+
***
|
|
13038
|
+
|
|
13039
|
+
### content
|
|
13040
|
+
|
|
13041
|
+
> **content**: `string` \| `Buffer`\<`ArrayBufferLike`\> \| `Readable`
|
|
13042
|
+
|
|
13043
|
+
Defined in: [lib/s3.ts:48](https://github.com/maiyunnet/kebab/blob/master/lib/s3.ts#L48)
|
|
13044
|
+
|
|
13045
|
+
内容
|
|
13046
|
+
|
|
13047
|
+
***
|
|
13048
|
+
|
|
13049
|
+
### disposition?
|
|
13050
|
+
|
|
13051
|
+
> `optional` **disposition?**: `string`
|
|
13052
|
+
|
|
13053
|
+
Defined in: [lib/s3.ts:54](https://github.com/maiyunnet/kebab/blob/master/lib/s3.ts#L54)
|
|
13054
|
+
|
|
13055
|
+
content-disposition
|
|
13056
|
+
|
|
13057
|
+
***
|
|
13058
|
+
|
|
13059
|
+
### key
|
|
13060
|
+
|
|
13061
|
+
> **key**: `string`
|
|
13062
|
+
|
|
13063
|
+
Defined in: [lib/s3.ts:46](https://github.com/maiyunnet/kebab/blob/master/lib/s3.ts#L46)
|
|
13064
|
+
|
|
13065
|
+
对象路径
|
|
13066
|
+
|
|
13067
|
+
***
|
|
13068
|
+
|
|
13069
|
+
### length?
|
|
13070
|
+
|
|
13071
|
+
> `optional` **length?**: `number`
|
|
13072
|
+
|
|
13073
|
+
Defined in: [lib/s3.ts:50](https://github.com/maiyunnet/kebab/blob/master/lib/s3.ts#L50)
|
|
13074
|
+
|
|
13075
|
+
contentLength,流模式需要设置
|
|
13076
|
+
|
|
13077
|
+
***
|
|
13078
|
+
|
|
13079
|
+
### type?
|
|
13080
|
+
|
|
13081
|
+
> `optional` **type?**: `string`
|
|
13082
|
+
|
|
13083
|
+
Defined in: [lib/s3.ts:52](https://github.com/maiyunnet/kebab/blob/master/lib/s3.ts#L52)
|
|
13084
|
+
|
|
13085
|
+
content-type,如 application/javascript
|
|
13086
|
+
|
|
13087
|
+
lib/s3/interfaces/IPutObjectsItemResult.md
|
|
13088
|
+
---
|
|
13089
|
+
|
|
13090
|
+
[**Documents for @maiyunnet/kebab**](../../../index.md)
|
|
13091
|
+
|
|
13092
|
+
***
|
|
13093
|
+
|
|
13094
|
+
[Documents for @maiyunnet/kebab](../../../index.md) / [lib/s3](../index.md) / IPutObjectsItemResult
|
|
13095
|
+
|
|
13096
|
+
# Interface: IPutObjectsItemResult
|
|
13097
|
+
|
|
13098
|
+
Defined in: [lib/s3.ts:68](https://github.com/maiyunnet/kebab/blob/master/lib/s3.ts#L68)
|
|
13099
|
+
|
|
13100
|
+
批量上传单项结果
|
|
13101
|
+
|
|
13102
|
+
## Properties
|
|
13103
|
+
|
|
13104
|
+
### error?
|
|
13105
|
+
|
|
13106
|
+
> `optional` **error?**: `string`
|
|
13107
|
+
|
|
13108
|
+
Defined in: [lib/s3.ts:76](https://github.com/maiyunnet/kebab/blob/master/lib/s3.ts#L76)
|
|
13109
|
+
|
|
13110
|
+
错误信息,失败时返回
|
|
13111
|
+
|
|
13112
|
+
***
|
|
13113
|
+
|
|
13114
|
+
### key
|
|
13115
|
+
|
|
13116
|
+
> **key**: `string`
|
|
13117
|
+
|
|
13118
|
+
Defined in: [lib/s3.ts:70](https://github.com/maiyunnet/kebab/blob/master/lib/s3.ts#L70)
|
|
13119
|
+
|
|
13120
|
+
对象路径
|
|
13121
|
+
|
|
13122
|
+
***
|
|
13123
|
+
|
|
13124
|
+
### location?
|
|
13125
|
+
|
|
13126
|
+
> `optional` **location?**: `string`
|
|
13127
|
+
|
|
13128
|
+
Defined in: [lib/s3.ts:74](https://github.com/maiyunnet/kebab/blob/master/lib/s3.ts#L74)
|
|
13129
|
+
|
|
13130
|
+
对象访问地址,成功时返回
|
|
13131
|
+
|
|
13132
|
+
***
|
|
13133
|
+
|
|
13134
|
+
### success
|
|
13135
|
+
|
|
13136
|
+
> **success**: `boolean`
|
|
13137
|
+
|
|
13138
|
+
Defined in: [lib/s3.ts:72](https://github.com/maiyunnet/kebab/blob/master/lib/s3.ts#L72)
|
|
13139
|
+
|
|
13140
|
+
是否成功
|
|
13141
|
+
|
|
13142
|
+
lib/s3/interfaces/IPutObjectsOptions.md
|
|
13143
|
+
---
|
|
13144
|
+
|
|
13145
|
+
[**Documents for @maiyunnet/kebab**](../../../index.md)
|
|
13146
|
+
|
|
13147
|
+
***
|
|
13148
|
+
|
|
13149
|
+
[Documents for @maiyunnet/kebab](../../../index.md) / [lib/s3](../index.md) / IPutObjectsOptions
|
|
13150
|
+
|
|
13151
|
+
# Interface: IPutObjectsOptions
|
|
13152
|
+
|
|
13153
|
+
Defined in: [lib/s3.ts:60](https://github.com/maiyunnet/kebab/blob/master/lib/s3.ts#L60)
|
|
13154
|
+
|
|
13155
|
+
批量上传选项
|
|
13156
|
+
|
|
13157
|
+
## Properties
|
|
13158
|
+
|
|
13159
|
+
### bucket?
|
|
13160
|
+
|
|
13161
|
+
> `optional` **bucket?**: `string`
|
|
13162
|
+
|
|
13163
|
+
Defined in: [lib/s3.ts:64](https://github.com/maiyunnet/kebab/blob/master/lib/s3.ts#L64)
|
|
13164
|
+
|
|
13165
|
+
bucket 名
|
|
13166
|
+
|
|
13167
|
+
***
|
|
13168
|
+
|
|
13169
|
+
### concurrency?
|
|
13170
|
+
|
|
13171
|
+
> `optional` **concurrency?**: `number`
|
|
13172
|
+
|
|
13173
|
+
Defined in: [lib/s3.ts:62](https://github.com/maiyunnet/kebab/blob/master/lib/s3.ts#L62)
|
|
13174
|
+
|
|
13175
|
+
并发数,默认 5
|
|
13176
|
+
|
|
12981
13177
|
lib/scan/classes/Scan.md
|
|
12982
13178
|
---
|
|
12983
13179
|
|
package/index.d.ts
CHANGED
package/index.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* --- 本文件用来定义每个目录实体地址的常量 ---
|
|
7
7
|
*/
|
|
8
8
|
/** --- 当前系统版本号 --- */
|
|
9
|
-
export const VER = '9.
|
|
9
|
+
export const VER = '9.13.0';
|
|
10
10
|
// --- 服务端用的路径 ---
|
|
11
11
|
const imu = decodeURIComponent(import.meta.url).replace('file://', '').replace(/^\/(\w:)/, '$1');
|
|
12
12
|
/** --- /xxx/xxx --- */
|
package/lib/s3.d.ts
CHANGED
|
@@ -31,6 +31,39 @@ export interface IOptions {
|
|
|
31
31
|
/** --- 预定义 bucket --- */
|
|
32
32
|
'bucket'?: string;
|
|
33
33
|
}
|
|
34
|
+
/** --- 批量上传单项 --- */
|
|
35
|
+
export interface IPutObjectItem {
|
|
36
|
+
/** --- 对象路径 --- */
|
|
37
|
+
'key': string;
|
|
38
|
+
/** --- 内容 --- */
|
|
39
|
+
'content': string | Buffer | stream.Readable;
|
|
40
|
+
/** --- contentLength,流模式需要设置 --- */
|
|
41
|
+
'length'?: number;
|
|
42
|
+
/** --- content-type,如 application/javascript --- */
|
|
43
|
+
'type'?: string;
|
|
44
|
+
/** --- content-disposition --- */
|
|
45
|
+
'disposition'?: string;
|
|
46
|
+
/** --- bucket 名,优先级高于 options.bucket --- */
|
|
47
|
+
'bucket'?: string;
|
|
48
|
+
}
|
|
49
|
+
/** --- 批量上传选项 --- */
|
|
50
|
+
export interface IPutObjectsOptions {
|
|
51
|
+
/** --- 并发数,默认 5 --- */
|
|
52
|
+
'concurrency'?: number;
|
|
53
|
+
/** --- bucket 名 --- */
|
|
54
|
+
'bucket'?: string;
|
|
55
|
+
}
|
|
56
|
+
/** --- 批量上传单项结果 --- */
|
|
57
|
+
export interface IPutObjectsItemResult {
|
|
58
|
+
/** --- 对象路径 --- */
|
|
59
|
+
'key': string;
|
|
60
|
+
/** --- 是否成功 --- */
|
|
61
|
+
'success': boolean;
|
|
62
|
+
/** --- 对象访问地址,成功时返回 --- */
|
|
63
|
+
'location'?: string;
|
|
64
|
+
/** --- 错误信息,失败时返回 --- */
|
|
65
|
+
'error'?: string;
|
|
66
|
+
}
|
|
34
67
|
export declare class S3 {
|
|
35
68
|
private readonly _link;
|
|
36
69
|
/** --- bucket 名 --- */
|
|
@@ -56,6 +89,12 @@ export declare class S3 {
|
|
|
56
89
|
'disposition'?: string;
|
|
57
90
|
'bucket'?: string;
|
|
58
91
|
}, bucket?: string): Promise<s3.CompleteMultipartUploadCommandOutput | false>;
|
|
92
|
+
/**
|
|
93
|
+
* --- 批量上传对象,并发控制,单次失败不影响其他项 ---
|
|
94
|
+
* @param items 上传项列表
|
|
95
|
+
* @param options 批量上传选项
|
|
96
|
+
*/
|
|
97
|
+
putObjects(items: IPutObjectItem[], options?: IPutObjectsOptions): Promise<IPutObjectsItemResult[]>;
|
|
59
98
|
/**
|
|
60
99
|
* --- 获取对象流,可通过流获取 buffer 或 text ---
|
|
61
100
|
* @param key 对象路径
|
package/lib/s3.js
CHANGED
|
@@ -104,12 +104,51 @@ export class S3 {
|
|
|
104
104
|
return false;
|
|
105
105
|
}
|
|
106
106
|
}
|
|
107
|
+
/**
|
|
108
|
+
* --- 批量上传对象,并发控制,单次失败不影响其他项 ---
|
|
109
|
+
* @param items 上传项列表
|
|
110
|
+
* @param options 批量上传选项
|
|
111
|
+
*/
|
|
112
|
+
async putObjects(items, options) {
|
|
113
|
+
const concurrency = options?.concurrency ?? 5;
|
|
114
|
+
const sharedBucket = options?.bucket;
|
|
115
|
+
const results = new Array(items.length);
|
|
116
|
+
let cursor = 0;
|
|
117
|
+
const worker = async () => {
|
|
118
|
+
while (cursor < items.length) {
|
|
119
|
+
const i = cursor++;
|
|
120
|
+
const item = items[i];
|
|
121
|
+
const bucket = item.bucket ?? sharedBucket;
|
|
122
|
+
const res = await this.putObject(item.key, item.content, {
|
|
123
|
+
'length': item.length,
|
|
124
|
+
'type': item.type,
|
|
125
|
+
'disposition': item.disposition,
|
|
126
|
+
}, bucket);
|
|
127
|
+
if (res) {
|
|
128
|
+
results[i] = {
|
|
129
|
+
'key': item.key,
|
|
130
|
+
'success': true,
|
|
131
|
+
'location': res.Location,
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
else {
|
|
135
|
+
results[i] = {
|
|
136
|
+
'key': item.key,
|
|
137
|
+
'success': false,
|
|
138
|
+
'error': 'upload failed',
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
const workers = Array.from({ 'length': Math.min(concurrency, items.length) }, () => worker());
|
|
144
|
+
await Promise.all(workers);
|
|
145
|
+
return results;
|
|
146
|
+
}
|
|
107
147
|
/**
|
|
108
148
|
* --- 获取对象流,可通过流获取 buffer 或 text ---
|
|
109
149
|
* @param key 对象路径
|
|
110
150
|
* @param bucket bucket 名
|
|
111
151
|
*/
|
|
112
|
-
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
|
|
113
152
|
async getObject(key, bucket) {
|
|
114
153
|
try {
|
|
115
154
|
const go = new s3.GetObjectCommand({
|
package/package.json
CHANGED