Skip to content

Commit 96d11c4

Browse files
committed
Merge branch 'dev/1.4.18' into 'master' (merge request !14)
dev/1.4.18 fix: 修复单测
2 parents 5aa0c9f + 5d7142b commit 96d11c4

File tree

8 files changed

+205
-31
lines changed

8 files changed

+205
-31
lines changed

demo/demo.js

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -923,7 +923,6 @@ function deleteBucketLogging() {
923923
}
924924

925925
function putBucketInventory() {
926-
var AppId = config.Bucket.substr(config.Bucket.lastIndexOf('-') + 1);
927926
cos.putBucketInventory(
928927
{
929928
Bucket: config.Bucket, // Bucket 格式:test-1250000000
@@ -966,6 +965,54 @@ function putBucketInventory() {
966965
);
967966
}
968967

968+
function postBucketInventory() {
969+
cos.postBucketInventory(
970+
{
971+
Bucket: config.Bucket, // Bucket 格式:test-1250000000
972+
Region: config.Region,
973+
Id: 'inventory_test6',
974+
InventoryConfiguration: {
975+
Id: 'inventory_test6',
976+
Destination: {
977+
COSBucketDestination: {
978+
Format: 'CSV',
979+
AccountId: config.Uin,
980+
Bucket: 'qcs::cos:' + config.Region + '::' + config.Bucket,
981+
Prefix: 'inventory6',
982+
Encryption: {
983+
SSECOS: '',
984+
},
985+
},
986+
},
987+
Filter: {
988+
Prefix: 'myPrefix',
989+
// Period: {
990+
// StartTime: new Date('2023-05-01').getTime()/1000,
991+
// EndTime: new Date('2023-05-31').getTime()/1000,
992+
// },
993+
// And: {
994+
// Prefix: 'myPrefix',
995+
// Tag: [{ Key: 'test1', Value: '1'}, { Key: 'test2', Value: '2' }]
996+
// }
997+
},
998+
IncludedObjectVersions: 'All',
999+
OptionalFields: [
1000+
'Size',
1001+
'LastModifiedDate',
1002+
'ETag',
1003+
'StorageClass',
1004+
'IsMultipartUploaded',
1005+
'ReplicationStatus',
1006+
'Tag',
1007+
],
1008+
},
1009+
},
1010+
function (err, data) {
1011+
logger.log('postBucketInventory:', err || data);
1012+
},
1013+
);
1014+
}
1015+
9691016
function getBucketInventory() {
9701017
cos.getBucketInventory(
9711018
{
@@ -4673,6 +4720,7 @@ function postSnapshot() {
46734720
'getBucketLogging',
46744721
'deleteBucketLogging',
46754722
'putBucketInventory',
4723+
'postBucketInventory',
46764724
'getBucketInventory',
46774725
'deleteBucketInventory',
46784726
'listBucketInventory',

dist/cos-js-sdk-v5.js

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6948,7 +6948,7 @@ module.exports = function(module) {
69486948
/*! exports provided: name, version, description, main, types, scripts, repository, keywords, author, license, bugs, homepage, dependencies, devDependencies, default */
69496949
/***/ (function(module) {
69506950

6951-
module.exports = JSON.parse("{\"name\":\"cos-js-sdk-v5\",\"version\":\"1.4.17\",\"description\":\"JavaScript SDK for [腾讯云对象存储](https://cloud.tencent.com/product/cos)\",\"main\":\"dist/cos-js-sdk-v5.js\",\"types\":\"index.d.ts\",\"scripts\":{\"prettier\":\"prettier --write src demo/demo.js test/test.js server/sts.js\",\"server\":\"node server/sts.js\",\"dev\":\"cross-env NODE_ENV=development webpack -w --mode=development\",\"build\":\"cross-env NODE_ENV=production webpack --mode=production\",\"cos-auth.min.js\":\"uglifyjs ./demo/common/cos-auth.js -o ./demo/common/cos-auth.min.js -c -m\",\"test\":\"jest --coverage\"},\"repository\":{\"type\":\"git\",\"url\":\"git+https://github.com/tencentyun/cos-js-sdk-v5.git\"},\"keywords\":[],\"author\":\"carsonxu\",\"license\":\"ISC\",\"bugs\":{\"url\":\"https://github.com/tencentyun/cos-js-sdk-v5/issues\"},\"homepage\":\"https://github.com/tencentyun/cos-js-sdk-v5#readme\",\"dependencies\":{\"@xmldom/xmldom\":\"^0.8.6\"},\"devDependencies\":{\"@babel/core\":\"7.17.9\",\"@babel/plugin-transform-runtime\":\"7.18.10\",\"@babel/preset-env\":\"7.16.11\",\"babel-loader\":\"8.2.5\",\"body-parser\":\"^1.18.3\",\"cross-env\":\"^5.2.0\",\"express\":\"^4.16.4\",\"jest\":\"^29.3.1\",\"jest-environment-jsdom\":\"^29.3.1\",\"jest-localstorage-mock\":\"^2.4.26\",\"prettier\":\"2.8.8\",\"qcloud-cos-sts\":\"^3.0.2\",\"request\":\"^2.87.0\",\"terser-webpack-plugin\":\"4.2.3\",\"uglifyjs\":\"^2.4.11\",\"webpack\":\"4.46.0\",\"webpack-cli\":\"4.10.0\"}}");
6951+
module.exports = JSON.parse("{\"name\":\"cos-js-sdk-v5\",\"version\":\"1.4.18\",\"description\":\"JavaScript SDK for [腾讯云对象存储](https://cloud.tencent.com/product/cos)\",\"main\":\"dist/cos-js-sdk-v5.js\",\"types\":\"index.d.ts\",\"scripts\":{\"prettier\":\"prettier --write src demo/demo.js test/test.js server/sts.js index.d.ts\",\"server\":\"node server/sts.js\",\"dev\":\"cross-env NODE_ENV=development webpack -w --mode=development\",\"build\":\"cross-env NODE_ENV=production webpack --mode=production\",\"cos-auth.min.js\":\"uglifyjs ./demo/common/cos-auth.js -o ./demo/common/cos-auth.min.js -c -m\",\"test\":\"jest --runInBand --coverage\"},\"repository\":{\"type\":\"git\",\"url\":\"git+https://github.com/tencentyun/cos-js-sdk-v5.git\"},\"keywords\":[],\"author\":\"carsonxu\",\"license\":\"ISC\",\"bugs\":{\"url\":\"https://github.com/tencentyun/cos-js-sdk-v5/issues\"},\"homepage\":\"https://github.com/tencentyun/cos-js-sdk-v5#readme\",\"dependencies\":{\"@xmldom/xmldom\":\"^0.8.6\"},\"devDependencies\":{\"@babel/core\":\"7.17.9\",\"@babel/plugin-transform-runtime\":\"7.18.10\",\"@babel/preset-env\":\"7.16.11\",\"babel-loader\":\"8.2.5\",\"body-parser\":\"^1.18.3\",\"cross-env\":\"^5.2.0\",\"express\":\"^4.16.4\",\"jest\":\"^29.3.1\",\"jest-environment-jsdom\":\"^29.3.1\",\"prettier\":\"2.8.8\",\"qcloud-cos-sts\":\"^3.0.2\",\"request\":\"^2.87.0\",\"terser-webpack-plugin\":\"4.2.3\",\"uglifyjs\":\"^2.4.11\",\"webpack\":\"4.46.0\",\"webpack-cli\":\"4.10.0\"}}");
69526952

69536953
/***/ }),
69546954

@@ -10007,7 +10007,7 @@ function getBucketLogging(params, callback) {
1000710007
*/
1000810008

1000910009

10010-
function putBucketInventory(params, callback) {
10010+
function submitBucketInventory(method, params, callback) {
1001110011
var InventoryConfiguration = util.clone(params['InventoryConfiguration']);
1001210012

1001310013
if (InventoryConfiguration.OptionalFields) {
@@ -10032,9 +10032,10 @@ function putBucketInventory(params, callback) {
1003210032
var headers = params.Headers;
1003310033
headers['Content-Type'] = 'application/xml';
1003410034
headers['Content-MD5'] = util.b64(util.md5(xml));
10035+
var action = method === 'PUT' ? 'name/cos:PutBucketInventory' : 'name/cos:PostBucketInventory';
1003510036
submitRequest.call(this, {
10036-
Action: 'name/cos:PutBucketInventory',
10037-
method: 'PUT',
10037+
Action: action,
10038+
method: method,
1003810039
Bucket: params.Bucket,
1003910040
Region: params.Region,
1004010041
body: xml,
@@ -10058,6 +10059,22 @@ function putBucketInventory(params, callback) {
1005810059
});
1005910060
});
1006010061
}
10062+
/**
10063+
* 创建一个清单任务
10064+
*/
10065+
10066+
10067+
function putBucketInventory(params, callback) {
10068+
return submitBucketInventory.call(this, 'PUT', params, callback);
10069+
}
10070+
/**
10071+
* 创建一个一次性清单任务 会立即执行
10072+
*/
10073+
10074+
10075+
function postBucketInventory(params, callback) {
10076+
return submitBucketInventory.call(this, 'POST', params, callback);
10077+
}
1006110078
/**
1006210079
* 获取 Bucket 的清单任务信息
1006310080
* @param {Object} params 参数对象,必须
@@ -12527,6 +12544,7 @@ var API_MAP = {
1252712544
getBucketLogging: getBucketLogging,
1252812545
putBucketInventory: putBucketInventory,
1252912546
// BucketInventory
12547+
postBucketInventory: postBucketInventory,
1253012548
getBucketInventory: getBucketInventory,
1253112549
listBucketInventory: listBucketInventory,
1253212550
deleteBucketInventory: deleteBucketInventory,

dist/cos-js-sdk-v5.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

index.d.ts

Lines changed: 44 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1010,27 +1010,30 @@ declare namespace COS {
10101010
BucketLoggingStatus: BucketLoggingStatus;
10111011
}
10121012

1013-
// putBucketInventory
1014-
/** putBucketInventory 接口参数 */
1015-
interface InventoryConfiguration {
1013+
interface BaseInventoryConfiguration {
10161014
/** 清单的名称,与请求参数中的 id 对应,可选 */
10171015
Id: string;
1018-
/** 清单是否启用的标识:如果设置为 true,清单功能将生效,如果设置为 false,将不生成任何清单,必选 */
1019-
IsEnabled: BooleanString;
10201016
/** 是否在清单中包含对象版本:如果设置为 All,清单中将会包含所有对象版本,并在清单中增加 VersionId,IsLatest,DeleteMarker 这几个字段,如果设置为 Current,则清单中不包含对象版本信息,必选 */
10211017
IncludedObjectVersions: 'All' | 'Current';
10221018
/** 筛选待分析对象。清单功能将分析符合 Filter 中设置的前缀的对象,可选 */
10231019
Filter?: {
10241020
/** 筛选待分析对象。清单功能将分析符合 Filter 中设置的前缀的对象,可选 */
10251021
Prefix?: Prefix;
1022+
/** 需要分析的对象的创建时间范围 */
1023+
Period?: {
1024+
StartTime?: number;
1025+
EndTime?: number;
1026+
};
1027+
/** 筛选待分析对象时,可以用对象标签(支持多个)作为过滤条件 */
1028+
Tag?: Tag[];
1029+
/** 筛选待分析对象时,如果同时需要前缀与对象标签条件,需要用 And 包装 */
1030+
And?: {
1031+
Prefix: Prefix;
1032+
Tag: Tag[];
1033+
};
10261034
};
10271035
/** 设置清单结果中应包含的分析项目,可选 */
10281036
OptionalFields?: string[];
1029-
/** 配置清单任务周期,必选 */
1030-
Schedule: {
1031-
/** 清单任务周期,可选项为按日或者按周,枚举值:Daily、Weekly,必选 */
1032-
Frequency: 'Daily' | 'Weekly';
1033-
};
10341037
/** 描述存放清单结果的信息,必选 */
10351038
Destination: {
10361039
/** 清单结果导出后存放的存储桶信息,必选 */
@@ -1051,6 +1054,19 @@ declare namespace COS {
10511054
};
10521055
};
10531056
}
1057+
1058+
// putBucketInventory
1059+
/** putBucketInventory 接口参数 */
1060+
interface InventoryConfiguration extends BaseInventoryConfiguration {
1061+
/** 清单是否启用的标识:如果设置为 true,清单功能将生效,如果设置为 false,将不生成任何清单,必选 */
1062+
IsEnabled: BooleanString;
1063+
/** 配置清单任务周期,必选 */
1064+
Schedule: {
1065+
/** 清单任务周期,可选项为按日或者按周,枚举值:Daily、Weekly,必选 */
1066+
Frequency: 'Daily' | 'Weekly';
1067+
};
1068+
}
1069+
10541070
interface PutBucketInventoryParams extends BucketParams {
10551071
/** 清单的名称,与请求参数中的 id 对应 */
10561072
Id: string;
@@ -1060,6 +1076,17 @@ declare namespace COS {
10601076
/** putBucketInventory 接口返回值 */
10611077
interface PutBucketInventoryResult extends GeneralResult {}
10621078

1079+
// postBucketInventory
1080+
/** postBucketInventory 接口参数 */
1081+
interface PostBucketInventoryParams extends BucketParams {
1082+
/** 清单的名称,与请求参数中的 id 对应 */
1083+
Id: string;
1084+
/** 包含清单任务的详细信息 */
1085+
InventoryConfiguration: BaseInventoryConfiguration;
1086+
}
1087+
/** postBucketInventory 接口返回值 */
1088+
interface PostBucketInventoryResult extends GeneralResult {}
1089+
10631090
// getBucketInventory
10641091
/** getBucketInventory 接口参数 */
10651092
interface GetBucketInventoryParams extends BucketParams {
@@ -2256,6 +2283,13 @@ declare class COS {
22562283
): void;
22572284
putBucketInventory(params: COS.PutBucketInventoryParams): Promise<COS.PutBucketInventoryResult>;
22582285

2286+
/** 创建/编辑 Bucket 一次性清单任务 @see https://cloud.tencent.com/document/product/436/83382 */
2287+
postBucketInventory(
2288+
params: COS.PostBucketInventoryParams,
2289+
callback: (err: COS.CosError, data: COS.PostBucketInventoryResult) => void,
2290+
): void;
2291+
postBucketInventory(params: COS.PostBucketInventoryParams): Promise<COS.PostBucketInventoryResult>;
2292+
22592293
/** 获取 Bucket 的清单任务信息 @see https://cloud.tencent.com/document/product/436/33705 */
22602294
getBucketInventory(
22612295
params: COS.GetBucketInventoryParams,

jest.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module.exports = {
22
collectCoverage: true, // 是否显示覆盖率报告
33
// 告诉 jest 哪些文件需要经过单元测试测试
4-
collectCoverageFrom: ['**/src/*.js', '!**/src/tracker.js', '!**/src/session.js', '!**/src/async.js', '!**/src/util.js'],
4+
collectCoverageFrom: ['**/src/*.js'],
55
coverageThreshold: {
66
global: {
77
statements: 90, // 保证每个语句都执行了

package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "cos-js-sdk-v5",
3-
"version": "1.4.17",
3+
"version": "1.4.18",
44
"description": "JavaScript SDK for [腾讯云对象存储](https://cloud.tencent.com/product/cos)",
55
"main": "dist/cos-js-sdk-v5.js",
66
"types": "index.d.ts",
@@ -10,7 +10,7 @@
1010
"dev": "cross-env NODE_ENV=development webpack -w --mode=development",
1111
"build": "cross-env NODE_ENV=production webpack --mode=production",
1212
"cos-auth.min.js": "uglifyjs ./demo/common/cos-auth.js -o ./demo/common/cos-auth.min.js -c -m",
13-
"test": "jest --coverage"
13+
"test": "jest --runInBand --coverage"
1414
},
1515
"repository": {
1616
"type": "git",
@@ -36,7 +36,6 @@
3636
"express": "^4.16.4",
3737
"jest": "^29.3.1",
3838
"jest-environment-jsdom": "^29.3.1",
39-
"jest-localstorage-mock": "^2.4.26",
4039
"prettier": "2.8.8",
4140
"qcloud-cos-sts": "^3.0.2",
4241
"request": "^2.87.0",

src/base.js

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1577,7 +1577,7 @@ function getBucketLogging(params, callback) {
15771577
* @return {Object} err 请求失败的错误,如果请求成功,则为空。https://cloud.tencent.com/document/product/436/7730
15781578
* @return {Object} data 返回数据
15791579
*/
1580-
function putBucketInventory(params, callback) {
1580+
function submitBucketInventory(method, params, callback) {
15811581
var InventoryConfiguration = util.clone(params['InventoryConfiguration']);
15821582

15831583
if (InventoryConfiguration.OptionalFields) {
@@ -1607,11 +1607,13 @@ function putBucketInventory(params, callback) {
16071607
headers['Content-Type'] = 'application/xml';
16081608
headers['Content-MD5'] = util.b64(util.md5(xml));
16091609

1610+
var action = method === 'PUT' ? 'name/cos:PutBucketInventory' : 'name/cos:PostBucketInventory';
1611+
16101612
submitRequest.call(
16111613
this,
16121614
{
1613-
Action: 'name/cos:PutBucketInventory',
1614-
method: 'PUT',
1615+
Action: action,
1616+
method,
16151617
Bucket: params.Bucket,
16161618
Region: params.Region,
16171619
body: xml,
@@ -1635,6 +1637,20 @@ function putBucketInventory(params, callback) {
16351637
);
16361638
}
16371639

1640+
/**
1641+
* 创建一个清单任务
1642+
*/
1643+
function putBucketInventory(params, callback) {
1644+
return submitBucketInventory.call(this, 'PUT', params, callback);
1645+
}
1646+
1647+
/**
1648+
* 创建一个一次性清单任务 会立即执行
1649+
*/
1650+
function postBucketInventory(params, callback) {
1651+
return submitBucketInventory.call(this, 'POST', params, callback);
1652+
}
1653+
16381654
/**
16391655
* 获取 Bucket 的清单任务信息
16401656
* @param {Object} params 参数对象,必须
@@ -4134,6 +4150,7 @@ var API_MAP = {
41344150
putBucketLogging: putBucketLogging, // BucketLogging
41354151
getBucketLogging: getBucketLogging,
41364152
putBucketInventory: putBucketInventory, // BucketInventory
4153+
postBucketInventory: postBucketInventory,
41374154
getBucketInventory: getBucketInventory,
41384155
listBucketInventory: listBucketInventory,
41394156
deleteBucketInventory: deleteBucketInventory,

0 commit comments

Comments
 (0)