tencentcloud-sdk-nodejs 4.1.64 → 4.1.66
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/es/common/sdk_version.js +1 -1
- package/es/services/bh/v20230418/bh_client.js +20 -2
- package/es/services/ctem/index.js +4 -0
- package/es/services/ctem/v20231128/ctem_client.js +81 -0
- package/es/services/ctem/v20231128/ctem_models.js +0 -0
- package/es/services/ctem/v20231128/index.js +6 -0
- package/es/services/index.js +1 -0
- package/es/services/kms/v20190118/kms_client.js +59 -14
- package/es/services/lke/v20231130/lke_client.js +16 -4
- package/es/services/mqtt/v20240516/mqtt_client.js +3 -0
- package/es/services/trocket/v20230308/trocket_client.js +5 -2
- package/es/services/wedata/v20210820/wedata_client.js +13 -4
- package/package.json +1 -1
- package/tencentcloud/common/abstract_client.d.ts +111 -13
- package/tencentcloud/common/abstract_client.js +82 -15
- package/tencentcloud/common/common_client.d.ts +7 -0
- package/tencentcloud/common/common_client.js +7 -0
- package/tencentcloud/common/cvm_role_credential.d.ts +6 -0
- package/tencentcloud/common/cvm_role_credential.js +10 -1
- package/tencentcloud/common/http/http_connection.js +1 -2
- package/tencentcloud/common/interface.d.ts +35 -36
- package/tencentcloud/common/interface.js +1 -1
- package/tencentcloud/common/sdk_version.d.ts +1 -1
- package/tencentcloud/common/sdk_version.js +1 -1
- package/tencentcloud/common/sign.js +1 -1
- package/tencentcloud/common/sse_response_model.d.ts +26 -2
- package/tencentcloud/common/sse_response_model.js +17 -2
- package/tencentcloud/services/ams/v20201229/ams_models.d.ts +5 -95
- package/tencentcloud/services/apm/v20210622/apm_models.d.ts +4 -0
- package/tencentcloud/services/bh/v20230418/bh_client.d.ts +27 -3
- package/tencentcloud/services/bh/v20230418/bh_client.js +39 -3
- package/tencentcloud/services/bh/v20230418/bh_models.d.ts +311 -56
- package/tencentcloud/services/ccc/v20200210/ccc_models.d.ts +1 -1
- package/tencentcloud/services/cdb/v20170320/cdb_client.d.ts +27 -21
- package/tencentcloud/services/cdb/v20170320/cdb_client.js +27 -21
- package/tencentcloud/services/cdb/v20170320/cdb_models.d.ts +153 -113
- package/tencentcloud/services/ctem/index.d.ts +6 -0
- package/tencentcloud/services/ctem/index.js +7 -0
- package/tencentcloud/services/ctem/v20231128/ctem_client.d.ts +110 -0
- package/tencentcloud/services/ctem/v20231128/ctem_client.js +181 -0
- package/tencentcloud/services/ctem/v20231128/ctem_models.d.ts +2733 -0
- package/tencentcloud/services/ctem/v20231128/ctem_models.js +18 -0
- package/tencentcloud/services/ctem/v20231128/index.d.ts +6 -0
- package/tencentcloud/services/ctem/v20231128/index.js +10 -0
- package/tencentcloud/services/cwp/v20180228/cwp_models.d.ts +44 -0
- package/tencentcloud/services/cynosdb/v20190107/cynosdb_models.d.ts +12 -0
- package/tencentcloud/services/dlc/v20210125/dlc_client.d.ts +3 -1
- package/tencentcloud/services/dlc/v20210125/dlc_client.js +3 -1
- package/tencentcloud/services/dlc/v20210125/dlc_models.d.ts +9 -4
- package/tencentcloud/services/dsgc/v20190723/dsgc_client.d.ts +1 -3
- package/tencentcloud/services/dsgc/v20190723/dsgc_client.js +1 -3
- package/tencentcloud/services/dsgc/v20190723/dsgc_models.d.ts +93 -6
- package/tencentcloud/services/emr/v20190103/emr_client.d.ts +1 -1
- package/tencentcloud/services/emr/v20190103/emr_models.d.ts +5703 -5666
- package/tencentcloud/services/ess/v20201111/ess_models.d.ts +12 -2
- package/tencentcloud/services/hunyuan/v20230901/hunyuan_models.d.ts +5 -1
- package/tencentcloud/services/ims/v20201229/ims_models.d.ts +1 -15
- package/tencentcloud/services/index.d.ts +1 -0
- package/tencentcloud/services/index.js +2 -0
- package/tencentcloud/services/iotexplorer/v20190423/iotexplorer_models.d.ts +2 -2
- package/tencentcloud/services/iotvideo/v20201215/iotvideo_models.d.ts +2 -2
- package/tencentcloud/services/iotvideo/v20211125/iotvideo_models.d.ts +1 -1
- package/tencentcloud/services/kms/v20190118/kms_client.d.ts +76 -16
- package/tencentcloud/services/kms/v20190118/kms_client.js +112 -22
- package/tencentcloud/services/kms/v20190118/kms_models.d.ts +572 -53
- package/tencentcloud/services/lke/v20231130/lke_client.d.ts +21 -5
- package/tencentcloud/services/lke/v20231130/lke_client.js +30 -6
- package/tencentcloud/services/lke/v20231130/lke_models.d.ts +5087 -4539
- package/tencentcloud/services/mongodb/v20190725/mongodb_models.d.ts +4 -0
- package/tencentcloud/services/mps/v20190612/mps_models.d.ts +84 -9
- package/tencentcloud/services/mqtt/v20240516/mqtt_client.d.ts +5 -1
- package/tencentcloud/services/mqtt/v20240516/mqtt_client.js +6 -0
- package/tencentcloud/services/mqtt/v20240516/mqtt_models.d.ts +67 -0
- package/tencentcloud/services/redis/v20180412/redis_models.d.ts +3 -3
- package/tencentcloud/services/ses/v20201002/ses_models.d.ts +0 -4
- package/tencentcloud/services/tcss/v20201101/tcss_models.d.ts +4 -0
- package/tencentcloud/services/thpc/v20230321/thpc_models.d.ts +14 -2
- package/tencentcloud/services/tione/v20211111/tione_models.d.ts +4 -0
- package/tencentcloud/services/tke/v20180525/tke_models.d.ts +6 -0
- package/tencentcloud/services/trocket/v20230308/trocket_client.d.ts +12 -8
- package/tencentcloud/services/trocket/v20230308/trocket_client.js +14 -8
- package/tencentcloud/services/trocket/v20230308/trocket_models.d.ts +272 -177
- package/tencentcloud/services/vm/v20210922/vm_models.d.ts +61 -135
- package/tencentcloud/services/vpc/v20170312/vpc_models.d.ts +4 -0
- package/tencentcloud/services/waf/v20180125/waf_models.d.ts +33 -9
- package/tencentcloud/services/wedata/v20210820/wedata_client.d.ts +19 -7
- package/tencentcloud/services/wedata/v20210820/wedata_client.js +26 -8
- package/tencentcloud/services/wedata/v20210820/wedata_models.d.ts +322 -54
|
@@ -10,21 +10,42 @@ const tencent_cloud_sdk_exception_1 = tslib_1.__importDefault(require("./excepti
|
|
|
10
10
|
const sse_response_model_1 = require("./sse_response_model");
|
|
11
11
|
const uuid_1 = require("uuid");
|
|
12
12
|
/**
|
|
13
|
-
*
|
|
13
|
+
* Abstract base client for Tencent Cloud SDK
|
|
14
|
+
*
|
|
15
|
+
* This class provides common functionality for making API requests to Tencent Cloud services,
|
|
16
|
+
* including request signing, error handling, and response parsing.
|
|
14
17
|
*/
|
|
15
18
|
class AbstractClient {
|
|
16
19
|
/**
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
* @param {string}
|
|
20
|
-
* @param {
|
|
21
|
-
* @param {
|
|
22
|
-
* @param {
|
|
20
|
+
* Constructs a new AbstractClient instance
|
|
21
|
+
*
|
|
22
|
+
* @param {string} endpoint - The service endpoint URL (e.g. "cvm.tencentcloudapi.com")
|
|
23
|
+
* @param {string} version - The API version of the service (e.g. "2017-03-12")
|
|
24
|
+
* @param {ClientConfig} config - Configuration object containing:
|
|
25
|
+
* @param {Credential|DynamicCredential} config.credential - Credentials for authentication
|
|
26
|
+
* @param {string} [config.region] - The region of the service (e.g. "ap-shanghai")
|
|
27
|
+
* @param {ClientProfile} [config.profile={}] - Optional client configuration profile
|
|
28
|
+
*
|
|
29
|
+
* @throws {TencentCloudSDKHttpException} If invalid language is specified in profile
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* const client = new AbstractClient(
|
|
33
|
+
* "cvm.tencentcloudapi.com",
|
|
34
|
+
* "2017-03-12",
|
|
35
|
+
* {
|
|
36
|
+
* credential: {
|
|
37
|
+
* secretId: process.env.secretId,
|
|
38
|
+
* secretKey: process.env.secretKey,
|
|
39
|
+
* },
|
|
40
|
+
* region: "ap-shanghai",
|
|
41
|
+
* profile: {}
|
|
42
|
+
* }
|
|
43
|
+
* );
|
|
23
44
|
*/
|
|
24
45
|
constructor(endpoint, version, { credential, region, profile = {} }) {
|
|
25
46
|
this.path = "/";
|
|
26
47
|
/**
|
|
27
|
-
*
|
|
48
|
+
* Credential instance
|
|
28
49
|
*/
|
|
29
50
|
if (credential && "getCredential" in credential) {
|
|
30
51
|
this.credential = credential;
|
|
@@ -37,14 +58,14 @@ class AbstractClient {
|
|
|
37
58
|
}, credential);
|
|
38
59
|
}
|
|
39
60
|
/**
|
|
40
|
-
*
|
|
61
|
+
* The region of the service
|
|
41
62
|
*/
|
|
42
63
|
this.region = region || null;
|
|
43
64
|
this.sdkVersion = "SDK_NODEJS_" + sdk_version_1.sdkVersion;
|
|
44
65
|
this.apiVersion = version;
|
|
45
66
|
this.endpoint = (profile && profile.httpProfile && profile.httpProfile.endpoint) || endpoint;
|
|
46
67
|
/**
|
|
47
|
-
*
|
|
68
|
+
* Optional configuration instance
|
|
48
69
|
* @type {ClientProfile}
|
|
49
70
|
*/
|
|
50
71
|
this.profile = {
|
|
@@ -61,6 +82,10 @@ class AbstractClient {
|
|
|
61
82
|
throw new tencent_cloud_sdk_exception_1.default(`Language invalid, choices: ${interface_1.SUPPORT_LANGUAGE_LIST.join("|")}`);
|
|
62
83
|
}
|
|
63
84
|
}
|
|
85
|
+
/**
|
|
86
|
+
* Get credential information
|
|
87
|
+
* @returns {Promise<Credential>} Promise that resolves with credential information
|
|
88
|
+
*/
|
|
64
89
|
async getCredential() {
|
|
65
90
|
if ("getCredential" in this.credential) {
|
|
66
91
|
return await this.credential.getCredential();
|
|
@@ -68,7 +93,30 @@ class AbstractClient {
|
|
|
68
93
|
return this.credential;
|
|
69
94
|
}
|
|
70
95
|
/**
|
|
71
|
-
*
|
|
96
|
+
* Make an API request to Tencent Cloud service
|
|
97
|
+
*
|
|
98
|
+
* @param {string} action - The API action name to call
|
|
99
|
+
* @param {any} req - The request payload/parameters
|
|
100
|
+
* @param {ResponseCallback|RequestOptions} [options] - Either request options or callback function
|
|
101
|
+
* @param {ResponseCallback} [cb] - Optional callback function for async operation
|
|
102
|
+
* @returns {Promise<ResponseData>} Promise that resolves with the API response data
|
|
103
|
+
*
|
|
104
|
+
* @example
|
|
105
|
+
* // Using promise
|
|
106
|
+
* client.request('DescribeInstances', {Limit: 10})
|
|
107
|
+
* .then(data => console.log(data))
|
|
108
|
+
* .catch(err => console.error(err));
|
|
109
|
+
*
|
|
110
|
+
* // Using callback
|
|
111
|
+
* client.request('DescribeInstances', {Limit: 10}, (err, data) => {
|
|
112
|
+
* if (err) console.error(err);
|
|
113
|
+
* else console.log(data);
|
|
114
|
+
* });
|
|
115
|
+
*
|
|
116
|
+
* // With options
|
|
117
|
+
* client.request('DescribeInstances', {Limit: 10}, {signal: abortController.signal})
|
|
118
|
+
* .then(data => console.log(data))
|
|
119
|
+
* .catch(err => console.error(err));
|
|
72
120
|
*/
|
|
73
121
|
async request(action, req, options, cb) {
|
|
74
122
|
if (typeof options === "function") {
|
|
@@ -86,7 +134,12 @@ class AbstractClient {
|
|
|
86
134
|
}
|
|
87
135
|
}
|
|
88
136
|
/**
|
|
89
|
-
*
|
|
137
|
+
* Make a request with octet-stream content type
|
|
138
|
+
* @param {string} action API action name
|
|
139
|
+
* @param {any} req Request data
|
|
140
|
+
* @param {ResponseCallback|RequestOptions} [options] Request options or callback
|
|
141
|
+
* @param {ResponseCallback} [cb] Callback function
|
|
142
|
+
* @returns {Promise<any>} Promise that resolves with response data
|
|
90
143
|
*/
|
|
91
144
|
async requestOctetStream(action, req, options, cb) {
|
|
92
145
|
if (typeof options === "function") {
|
|
@@ -191,6 +244,12 @@ class AbstractClient {
|
|
|
191
244
|
}
|
|
192
245
|
return this.parseResponse(res);
|
|
193
246
|
}
|
|
247
|
+
/**
|
|
248
|
+
* Parse HTTP response
|
|
249
|
+
* @param {Response} res HTTP response object
|
|
250
|
+
* @returns {Promise<ResponseData>} Promise that resolves with parsed response data
|
|
251
|
+
* @throws {TencentCloudSDKHttpException} If response contains error
|
|
252
|
+
*/
|
|
194
253
|
async parseResponse(res) {
|
|
195
254
|
const traceId = res.headers.get("x-tc-traceid");
|
|
196
255
|
if (res.status !== 200) {
|
|
@@ -216,7 +275,10 @@ class AbstractClient {
|
|
|
216
275
|
}
|
|
217
276
|
}
|
|
218
277
|
/**
|
|
219
|
-
*
|
|
278
|
+
* Merge nested data into flat structure
|
|
279
|
+
* @param {any} data Input data
|
|
280
|
+
* @param {string} [prefix=""] Key prefix
|
|
281
|
+
* @returns {any} Flattened data object
|
|
220
282
|
*/
|
|
221
283
|
mergeData(data, prefix = "") {
|
|
222
284
|
const ret = {};
|
|
@@ -234,7 +296,10 @@ class AbstractClient {
|
|
|
234
296
|
return ret;
|
|
235
297
|
}
|
|
236
298
|
/**
|
|
237
|
-
*
|
|
299
|
+
* Format request data with required fields and signature
|
|
300
|
+
* @param {string} action API action name
|
|
301
|
+
* @param {RequestData} params Request parameters
|
|
302
|
+
* @returns {Promise<RequestData>} Promise that resolves with formatted request data
|
|
238
303
|
*/
|
|
239
304
|
async formatRequestData(action, params) {
|
|
240
305
|
params.Action = action;
|
|
@@ -263,7 +328,9 @@ class AbstractClient {
|
|
|
263
328
|
return params;
|
|
264
329
|
}
|
|
265
330
|
/**
|
|
266
|
-
*
|
|
331
|
+
* Format string for signature calculation
|
|
332
|
+
* @param {RequestData} params Request parameters
|
|
333
|
+
* @returns {string} String to be signed
|
|
267
334
|
*/
|
|
268
335
|
formatSignString(params) {
|
|
269
336
|
let strParam = "";
|
|
@@ -1,3 +1,10 @@
|
|
|
1
1
|
import { AbstractClient } from "./abstract_client";
|
|
2
|
+
/**
|
|
3
|
+
* Common client class for Tencent Cloud SDK
|
|
4
|
+
*
|
|
5
|
+
* You only need to install the tencentcloud-sdk-nodejs-common package to Make an API request to any product
|
|
6
|
+
*
|
|
7
|
+
* @see {@link https://github.com/TencentCloud/tencentcloud-sdk-nodejs/tree/master/examples/common} view exmaple
|
|
8
|
+
*/
|
|
2
9
|
export declare class CommonClient extends AbstractClient {
|
|
3
10
|
}
|
|
@@ -2,6 +2,13 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.CommonClient = void 0;
|
|
4
4
|
const abstract_client_1 = require("./abstract_client");
|
|
5
|
+
/**
|
|
6
|
+
* Common client class for Tencent Cloud SDK
|
|
7
|
+
*
|
|
8
|
+
* You only need to install the tencentcloud-sdk-nodejs-common package to Make an API request to any product
|
|
9
|
+
*
|
|
10
|
+
* @see {@link https://github.com/TencentCloud/tencentcloud-sdk-nodejs/tree/master/examples/common} view exmaple
|
|
11
|
+
*/
|
|
5
12
|
class CommonClient extends abstract_client_1.AbstractClient {
|
|
6
13
|
}
|
|
7
14
|
exports.CommonClient = CommonClient;
|
|
@@ -7,6 +7,12 @@ interface CvmRoleCredentialResult {
|
|
|
7
7
|
Token: string;
|
|
8
8
|
Code: string;
|
|
9
9
|
}
|
|
10
|
+
/**
|
|
11
|
+
* Tencent Cloud Credential via CVM role
|
|
12
|
+
*
|
|
13
|
+
* Automatically generates temporary credentials when binding a service role to instance.
|
|
14
|
+
* @see {@link https://cloud.tencent.com/document/product/598/85616} for more information.
|
|
15
|
+
*/
|
|
10
16
|
export default class CvmRoleCredential implements DynamicCredential {
|
|
11
17
|
protected roleNameTask: Promise<string> | null;
|
|
12
18
|
protected credentialTask: Promise<CvmRoleCredentialResult> | null;
|
|
@@ -5,7 +5,14 @@ const fetch_1 = tslib_1.__importDefault(require("./http/fetch"));
|
|
|
5
5
|
const META_URL = "http://metadata.tencentyun.com/latest/meta-data/";
|
|
6
6
|
const ROLE_URL = META_URL + "cam/security-credentials/";
|
|
7
7
|
const EXPIRE_BUFFER = 30 * 1000;
|
|
8
|
+
/**
|
|
9
|
+
* Tencent Cloud Credential via CVM role
|
|
10
|
+
*
|
|
11
|
+
* Automatically generates temporary credentials when binding a service role to instance.
|
|
12
|
+
* @see {@link https://cloud.tencent.com/document/product/598/85616} for more information.
|
|
13
|
+
*/
|
|
8
14
|
class CvmRoleCredential {
|
|
15
|
+
// Method to fetch the role name from the metadata server
|
|
9
16
|
async getRoleName() {
|
|
10
17
|
const response = await fetch_1.default(ROLE_URL, {});
|
|
11
18
|
if (!response.ok) {
|
|
@@ -13,6 +20,7 @@ class CvmRoleCredential {
|
|
|
13
20
|
}
|
|
14
21
|
return await response.text();
|
|
15
22
|
}
|
|
23
|
+
// Method to fetch credentials for a given role name
|
|
16
24
|
async getRoleCredential(roleName) {
|
|
17
25
|
const response = await fetch_1.default(ROLE_URL + roleName, {});
|
|
18
26
|
if (!response.ok) {
|
|
@@ -24,6 +32,7 @@ class CvmRoleCredential {
|
|
|
24
32
|
}
|
|
25
33
|
return json;
|
|
26
34
|
}
|
|
35
|
+
// Method to get the current credential, refreshing if expired
|
|
27
36
|
async getCredential() {
|
|
28
37
|
if (!this.roleNameTask) {
|
|
29
38
|
this.roleNameTask = this.getRoleName();
|
|
@@ -33,7 +42,7 @@ class CvmRoleCredential {
|
|
|
33
42
|
this.credentialTask = this.getRoleCredential(roleName);
|
|
34
43
|
}
|
|
35
44
|
const credential = await this.credentialTask;
|
|
36
|
-
// expired
|
|
45
|
+
// Check if the credential is expired
|
|
37
46
|
if (credential.ExpiredTime * 1000 - EXPIRE_BUFFER <= Date.now()) {
|
|
38
47
|
this.credentialTask = null;
|
|
39
48
|
return this.getCredential();
|
|
@@ -34,8 +34,7 @@ class HttpConnection {
|
|
|
34
34
|
return await fetch_1.default(url, config);
|
|
35
35
|
}
|
|
36
36
|
static async doRequestWithSign3({ method, url, data, service, action, region, version, secretId, secretKey, multipart = false, timeout = 60000, token, requestClient, language, headers = {}, agent, proxy, signal, }) {
|
|
37
|
-
//
|
|
38
|
-
// 所以这里把 readStream 转为 Buffer
|
|
37
|
+
// Convert readStream to Buffer to calculate the hash of the entire body
|
|
39
38
|
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
40
39
|
await convertReadStreamToBuffer(data);
|
|
41
40
|
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
@@ -1,116 +1,115 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { Agent } from "http";
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* Configuration type for initializing client object
|
|
5
5
|
*/
|
|
6
6
|
export interface ClientConfig {
|
|
7
7
|
/**
|
|
8
|
-
* @param {Credential} credential
|
|
9
|
-
* 必选
|
|
8
|
+
* @param {Credential} credential Authentication information
|
|
10
9
|
*/
|
|
11
10
|
credential: Credential | DynamicCredential;
|
|
12
11
|
/**
|
|
13
|
-
* @param {string} region
|
|
14
|
-
*
|
|
12
|
+
* @param {string} region Product region
|
|
13
|
+
* Required for region-specific products (e.g. CVM), optional for non-region products (e.g. SMS)
|
|
15
14
|
*/
|
|
16
15
|
region?: string;
|
|
17
16
|
/**
|
|
18
|
-
* @param {ClientProfile} profile
|
|
19
|
-
*
|
|
17
|
+
* @param {ClientProfile} profile Optional configuration instance
|
|
18
|
+
* Optional, can be skipped if no special requirements
|
|
20
19
|
*/
|
|
21
20
|
profile?: ClientProfile;
|
|
22
21
|
}
|
|
23
22
|
/**
|
|
24
|
-
*
|
|
23
|
+
* Optional configuration instance
|
|
25
24
|
*/
|
|
26
25
|
export interface ClientProfile {
|
|
27
26
|
/**
|
|
28
|
-
*
|
|
27
|
+
* Signature method (TC3-HMAC-SHA256 HmacSHA1 HmacSHA256)
|
|
29
28
|
* @type {string}
|
|
30
|
-
*
|
|
29
|
+
* Optional
|
|
31
30
|
*/
|
|
32
31
|
signMethod?: "TC3-HMAC-SHA256" | "HmacSHA256" | "HmacSHA1";
|
|
33
32
|
/**
|
|
34
|
-
*
|
|
33
|
+
* HTTP related options instance
|
|
35
34
|
* @type {HttpProfile}
|
|
36
|
-
*
|
|
35
|
+
* Optional
|
|
37
36
|
*/
|
|
38
37
|
httpProfile?: HttpProfile;
|
|
39
38
|
/**
|
|
40
|
-
*
|
|
39
|
+
* Language field attached to API requests
|
|
41
40
|
* @type {"zh-CN" | "en-US"}
|
|
42
|
-
*
|
|
41
|
+
* Optional
|
|
43
42
|
*/
|
|
44
43
|
language?: "zh-CN" | "en-US";
|
|
45
44
|
}
|
|
46
45
|
export interface HttpProfile {
|
|
47
46
|
/**
|
|
48
|
-
*
|
|
47
|
+
* Request method
|
|
49
48
|
* @type {"POST" | "GET"}
|
|
50
|
-
*
|
|
49
|
+
* Optional
|
|
51
50
|
*/
|
|
52
51
|
reqMethod?: "POST" | "GET";
|
|
53
52
|
/**
|
|
54
|
-
*
|
|
53
|
+
* The service endpoint URL (e.g. "cvm.tencentcloudapi.com")
|
|
55
54
|
* @type {string}
|
|
56
|
-
*
|
|
55
|
+
* Optional
|
|
57
56
|
*/
|
|
58
57
|
endpoint?: string;
|
|
59
58
|
/**
|
|
60
|
-
*
|
|
59
|
+
* Protocol, currently supports "https://"
|
|
61
60
|
* @type {string}
|
|
62
|
-
*
|
|
61
|
+
* Optional
|
|
63
62
|
*/
|
|
64
63
|
protocol?: string;
|
|
65
64
|
/**
|
|
66
|
-
*
|
|
65
|
+
* Request timeout in seconds, default 60s
|
|
67
66
|
* @type {number}
|
|
68
|
-
*
|
|
67
|
+
* Optional
|
|
69
68
|
*/
|
|
70
69
|
reqTimeout?: number;
|
|
71
70
|
/**
|
|
72
|
-
*
|
|
71
|
+
* Custom headers, e.g. { "X-TC-TraceId": "ffe0c072-8a5d-4e17-8887-a8a60252abca" }
|
|
73
72
|
* @type {Record<string, string>}
|
|
74
|
-
*
|
|
73
|
+
* Optional
|
|
75
74
|
*/
|
|
76
75
|
headers?: Record<string, string>;
|
|
77
76
|
/**
|
|
78
|
-
*
|
|
77
|
+
* Advanced request agent, e.g. new HttpsProxyAgent("http://127.0.0.1:8899")
|
|
79
78
|
*
|
|
80
|
-
*
|
|
79
|
+
* Higher priority than proxy configuration
|
|
81
80
|
*/
|
|
82
81
|
agent?: Agent;
|
|
83
82
|
/**
|
|
84
|
-
*
|
|
83
|
+
* HTTP request proxy, e.g. "http://127.0.0.1:8899"
|
|
85
84
|
*/
|
|
86
85
|
proxy?: string;
|
|
87
86
|
}
|
|
88
87
|
/**
|
|
89
|
-
* ClientProfile.language
|
|
88
|
+
* Supported values for ClientProfile.language property
|
|
90
89
|
*/
|
|
91
90
|
export declare const SUPPORT_LANGUAGE_LIST: string[];
|
|
92
91
|
/**
|
|
93
|
-
*
|
|
92
|
+
* Credential information class
|
|
94
93
|
*/
|
|
95
94
|
export interface Credential {
|
|
96
95
|
/**
|
|
97
|
-
*
|
|
98
|
-
*
|
|
96
|
+
* Tencent Cloud account secretId and secretKey
|
|
97
|
+
* Optional, mutually exclusive with token
|
|
99
98
|
*/
|
|
100
99
|
secretId?: string;
|
|
101
100
|
/**
|
|
102
|
-
*
|
|
103
|
-
*
|
|
101
|
+
* Tencent Cloud account secretKey
|
|
102
|
+
* Optional, mutually exclusive with token
|
|
104
103
|
*/
|
|
105
104
|
secretKey?: string;
|
|
106
105
|
/**
|
|
107
|
-
*
|
|
108
|
-
*
|
|
106
|
+
* Tencent Cloud account token
|
|
107
|
+
* Optional, mutually exclusive with secretId
|
|
109
108
|
*/
|
|
110
109
|
token?: string;
|
|
111
110
|
}
|
|
112
111
|
/**
|
|
113
|
-
*
|
|
112
|
+
* Dynamic credential information
|
|
114
113
|
*/
|
|
115
114
|
export interface DynamicCredential {
|
|
116
115
|
getCredential(): Promise<Credential>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const sdkVersion = "4.1.
|
|
1
|
+
export declare const sdkVersion = "4.1.66";
|
|
@@ -24,7 +24,7 @@ class Sign {
|
|
|
24
24
|
static sign3({ method = "POST", url = "", payload, timestamp, service, secretId, secretKey, multipart, boundary, headers: configHeaders = {}, }) {
|
|
25
25
|
const urlObj = new url_1.URL(url);
|
|
26
26
|
const contentType = configHeaders["Content-Type"];
|
|
27
|
-
//
|
|
27
|
+
// general headers
|
|
28
28
|
let headers = "";
|
|
29
29
|
let signedHeaders = "";
|
|
30
30
|
if (method === "GET") {
|
|
@@ -9,25 +9,49 @@ interface EventSourceMessage {
|
|
|
9
9
|
/** The reconnection interval (in milliseconds) to wait before retrying the connection */
|
|
10
10
|
retry?: number;
|
|
11
11
|
}
|
|
12
|
+
/**
|
|
13
|
+
* Class to handle Server-Sent Events (SSE) responses.
|
|
14
|
+
* Parses SSE data from a readable stream and emits events for messages, errors, and stream closure.
|
|
15
|
+
*/
|
|
12
16
|
export declare class SSEResponseModel {
|
|
13
17
|
private stream;
|
|
14
18
|
private readline;
|
|
15
19
|
private eventSource;
|
|
20
|
+
/**
|
|
21
|
+
* Constructs an SSEResponseModel instance.
|
|
22
|
+
* @param stream - The readable stream containing SSE data.
|
|
23
|
+
*/
|
|
16
24
|
constructor(stream: NodeJS.ReadableStream);
|
|
17
25
|
/**
|
|
18
|
-
*
|
|
26
|
+
* Initializes the SSE parser by setting up event listeners for the stream and readline.
|
|
19
27
|
*/
|
|
20
28
|
private init;
|
|
21
29
|
/**
|
|
22
|
-
*
|
|
30
|
+
* Parses raw SSE lines into an EventSourceMessage object.
|
|
31
|
+
* @param lines - An array of raw SSE lines.
|
|
32
|
+
* @returns The parsed EventSourceMessage.
|
|
23
33
|
*/
|
|
24
34
|
private parseSSEMessage;
|
|
35
|
+
/**
|
|
36
|
+
* Registers an event listener for SSE messages.
|
|
37
|
+
* @param event - The event type ("message", "close", or "error").
|
|
38
|
+
* @param listener - The callback function.
|
|
39
|
+
*/
|
|
25
40
|
on(event: "message", listener: (message: EventSourceMessage) => void): this;
|
|
26
41
|
on(event: "close", listener: () => void): this;
|
|
27
42
|
on(event: "error", listener: (err: Error) => void): this;
|
|
43
|
+
/**
|
|
44
|
+
* Removes an event listener for SSE messages.
|
|
45
|
+
* @param event - The event type ("message", "close", or "error").
|
|
46
|
+
* @param listener - The callback function.
|
|
47
|
+
*/
|
|
28
48
|
removeListener(event: "message", listener: (message: EventSourceMessage) => void): this;
|
|
29
49
|
removeListener(event: "close", listener: () => void): this;
|
|
30
50
|
removeListener(event: "error", listener: (err: Error) => void): this;
|
|
51
|
+
/**
|
|
52
|
+
* Provides an async iterator for consuming SSE messages.
|
|
53
|
+
* @returns An async iterator yielding parsed EventSourceMessage objects.
|
|
54
|
+
*/
|
|
31
55
|
[Symbol.asyncIterator](): AsyncIterableIterator<EventSourceMessage>;
|
|
32
56
|
}
|
|
33
57
|
export {};
|
|
@@ -3,9 +3,18 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.SSEResponseModel = void 0;
|
|
4
4
|
const events_1 = require("events");
|
|
5
5
|
const readline_1 = require("readline");
|
|
6
|
+
// Custom EventEmitter for handling SSE events
|
|
6
7
|
class SSEEventEmitter extends events_1.EventEmitter {
|
|
7
8
|
}
|
|
9
|
+
/**
|
|
10
|
+
* Class to handle Server-Sent Events (SSE) responses.
|
|
11
|
+
* Parses SSE data from a readable stream and emits events for messages, errors, and stream closure.
|
|
12
|
+
*/
|
|
8
13
|
class SSEResponseModel {
|
|
14
|
+
/**
|
|
15
|
+
* Constructs an SSEResponseModel instance.
|
|
16
|
+
* @param stream - The readable stream containing SSE data.
|
|
17
|
+
*/
|
|
9
18
|
constructor(stream) {
|
|
10
19
|
this.stream = stream;
|
|
11
20
|
this.readline = readline_1.createInterface({
|
|
@@ -16,7 +25,7 @@ class SSEResponseModel {
|
|
|
16
25
|
this.init();
|
|
17
26
|
}
|
|
18
27
|
/**
|
|
19
|
-
*
|
|
28
|
+
* Initializes the SSE parser by setting up event listeners for the stream and readline.
|
|
20
29
|
*/
|
|
21
30
|
init() {
|
|
22
31
|
const { stream, readline, eventSource } = this;
|
|
@@ -41,7 +50,9 @@ class SSEResponseModel {
|
|
|
41
50
|
});
|
|
42
51
|
}
|
|
43
52
|
/**
|
|
44
|
-
*
|
|
53
|
+
* Parses raw SSE lines into an EventSourceMessage object.
|
|
54
|
+
* @param lines - An array of raw SSE lines.
|
|
55
|
+
* @returns The parsed EventSourceMessage.
|
|
45
56
|
*/
|
|
46
57
|
parseSSEMessage(lines) {
|
|
47
58
|
const message = {
|
|
@@ -87,6 +98,10 @@ class SSEResponseModel {
|
|
|
87
98
|
this.eventSource.removeListener(event, listener);
|
|
88
99
|
return this;
|
|
89
100
|
}
|
|
101
|
+
/**
|
|
102
|
+
* Provides an async iterator for consuming SSE messages.
|
|
103
|
+
* @returns An async iterator yielding parsed EventSourceMessage objects.
|
|
104
|
+
*/
|
|
90
105
|
async *[Symbol.asyncIterator]() {
|
|
91
106
|
let lines = [];
|
|
92
107
|
for await (const line of this.readline) {
|