Skip to content

Commit 0fad459

Browse files
committed
Merge "master" into "cloud_detect-Node.js-2023-08-31-online-2189-2026_01_15_17_22_09"
Conflicts: meta.json
2 parents 731bd91 + ba1fa95 commit 0fad459

13,313 files changed

Lines changed: 699884 additions & 169 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ jobs:
1616
- name: Setup Node.js
1717
uses: actions/setup-node@v4
1818
with:
19-
node-version: 20
19+
node-version: 18
2020

2121
- name: Setup pnpm
2222
uses: pnpm/action-setup@v2
2323
with:
24-
version: 8
24+
version: 9
2525

2626
- name: Install Dependencies
2727
run: pnpm install

.github/workflows/release.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ jobs:
2020
- name: Setup Node.js
2121
uses: actions/setup-node@v4
2222
with:
23-
node-version: 20
23+
node-version: 18
2424

2525
- name: Setup pnpm
2626
uses: pnpm/action-setup@v2
2727
with:
28-
version: 8
28+
version: 9
2929

3030
- name: Install Dependencies
3131
run: pnpm install

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Dependencies
22
node_modules/
33
.pnpm-store
4-
4+
.npmrc
55

66
# Build outputs
77
dist/

README.EN.md

Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,16 @@ English | [中文](README.md)
22

33
# Volcengine SDK for Node.js
44

5-
## Installation
6-
7-
### Requirements
5+
## Requirements
86

97
- Node.js >= 18
108

9+
## Installation
10+
1111
Recommended to use `pnpm` for installation. `npm` and `yarn` are also supported.
1212

13+
1. Installation Core Packages
14+
1315
```bash
1416
# pnpm
1517
pnpm add @volcengine/sdk-core
@@ -21,6 +23,21 @@ npm install @volcengine/sdk-core
2123
yarn add @volcengine/sdk-core
2224
```
2325

26+
2. Installation Service Packages
27+
28+
Take installing ECS service SDK package as an example:
29+
30+
```bash
31+
# pnpm
32+
pnpm add @volcengine/ecs
33+
34+
# npm
35+
npm install @volcengine/ecs
36+
37+
# yarn
38+
yarn add @volcengine/ecs
39+
```
40+
2441
## Environment Variables
2542

2643
The SDK automatically reads the following environment variables as access credentials:
@@ -35,34 +52,26 @@ export VOLCSTACK_ACCESS_KEY_ID="YOUR_AK"
3552
export VOLCSTACK_SECRET_ACCESS_KEY="YOUR_SK"
3653
```
3754

38-
## Endpoint Configuration
39-
40-
The SDK supports multiple ways to configure the Endpoint, with the following priority (highest to lowest):
41-
42-
1. **Custom Endpoint**: Specify `EndpointWithEndpoint` in the client configuration (e.g. `iam.example.com`).
43-
2. **Automatic Addressing**: Specify `region`, and the SDK will automatically construct the Endpoint based on the service name and region (e.g. `ecs.cn-beijing.volcengineapi.com`).
44-
3. **Default**: If not specified and cannot be deduced, `open.volcengineapi.com` is used by default.
45-
4655
## Quick Start
4756

4857
The following example shows how to initialize the client and send a request.
49-
Install the corresponding service SDK package (e.g., `@volcengine/iam`).
58+
Install the corresponding service SDK package (e.g., `@volcengine/ecs`).
5059

5160
```bash
5261
# pnpm
53-
pnpm add @volcengine/iam
62+
pnpm add @volcengine/ecs
5463
```
5564

5665
```typescript
57-
import { IAMClient, ListUsersCommand } from "@volcengine/iam"; // Need to install the corresponding service package
66+
import { ECSClient, DescribeZonesCommand } from "@volcengine/ecs"; // Need to install the corresponding service package
5867

5968
// 1. Use AK/SK from environment variables and specify Region
60-
const client = new IAMClient({
69+
const client = new ECSClient({
6170
region: "cn-beijing",
6271
});
6372

6473
// 2. Or explicitly pass AK/SK in the code
65-
// const client = new IAMClient({
74+
// const client = new ECSClient({
6675
// accessKeyId: "YOUR_AK",
6776
// secretAccessKey: "YOUR_SK",
6877
// region: "cn-beijing",
@@ -71,7 +80,7 @@ const client = new IAMClient({
7180
async function main() {
7281
try {
7382
// Send request (refer to service SDK documentation for specific Commands)
74-
const command = new ListUsersCommand({});
83+
const command = new DescribeZonesCommand({});
7584
const response = await client.send(command);
7685
console.log(response);
7786
} catch (error) {

README.md

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
1-
中文 | [English](README.EN.MD)
1+
中文 | [English](README.EN.md)
22

33
# Volcengine SDK for Node.js
44

5-
## 安装
6-
7-
### 环境要求
5+
## 环境要求
86

97
- Node.js >= 18
108

11-
推荐使用 `pnpm` 进行安装,同时支持 `npm``yarn`
9+
## 安装
10+
11+
推荐使用 `pnpm` 进行安装,同时支持 `npm``yarn`
12+
13+
1. 安装 Core 包
1214

1315
```bash
1416
# pnpm
@@ -21,6 +23,21 @@ npm install @volcengine/sdk-core
2123
yarn add @volcengine/sdk-core
2224
```
2325

26+
2. 安装云产品 SDK 包
27+
28+
以安装 ECS 业务 SDK 包为例:
29+
30+
```bash
31+
# pnpm
32+
pnpm add @volcengine/ecs
33+
34+
# npm
35+
npm install @volcengine/ecs
36+
37+
# yarn
38+
yarn add @volcengine/ecs
39+
```
40+
2441
## 环境变量设置
2542

2643
SDK 会自动读取以下环境变量作为访问凭据:
@@ -35,35 +52,20 @@ export VOLCSTACK_ACCESS_KEY_ID="YOUR_AK"
3552
export VOLCSTACK_SECRET_ACCESS_KEY="YOUR_SK"
3653
```
3754

38-
## Endpoint 设置
39-
40-
SDK 支持多种方式配置 Endpoint,优先级从高到低:
41-
42-
1. **自定义 Endpoint**: 在客户端配置中指定 `host` (e.g. `open.volcengineapi.com`).
43-
2. **自动寻址**: 指定 `region`,SDK 会根据服务名和区域自动构造 Endpoint (e.g. `ecs.cn-beijing.volcengineapi.com`).
44-
3. **默认**: 如果未指定且无法推导,默认使用 `open.volcengineapi.com`.
45-
4655
## 快速开始
4756

4857
以下示例展示了如何初始化客户端并发送请求。
49-
安装对应的业务 SDK 包(如 `@volcengine/iam`)。
50-
51-
```bash
52-
# pnpm
53-
pnpm add @volcengine/iam
54-
55-
```
5658

5759
```typescript
58-
import { IAMClient } from "@volcengine/iam"; // 需安装对应的业务包
60+
import { ECSClient, DescribeZonesCommand } from "@volcengine/ecs"; // 需安装对应的业务包
5961

6062
// 1. 使用环境变量中的 AK/SK,并指定 Region
61-
const client = new IAMClient({
63+
const client = new ECSClient({
6264
region: "cn-beijing",
6365
});
6466

6567
// 2. 或者在代码中显式传入 AK/SK
66-
// const client = new IAMClient({
68+
// const client = new ECSClient({
6769
// accessKeyId: "YOUR_AK",
6870
// secretAccessKey: "YOUR_SK",
6971
// region: "cn-beijing",
@@ -72,7 +74,7 @@ const client = new IAMClient({
7274
async function main() {
7375
try {
7476
// 发送请求 (具体 Command 需参考业务 SDK 文档)
75-
const command = new ListUsersCommand({});
77+
const command = new DescribeZonesCommand({});
7678
const response = await client.send(command);
7779
console.log(response);
7880
} catch (error) {

SDK_Integration.md

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ English | [中文](SDK_Integration_zh.md)
55
- [Environment and Installation](#environment-and-installation)
66
- [Environment Requirements](#environment-requirements)
77
- [Installation](#installation)
8-
- [Quick Start](#quick-start)
98
- [Credentials](#credentials)
109
- [AK/SK (Access Key)](#aksk-access-key)
1110
- [STS Token (Security Token Service)](#sts-token-security-token-service)
@@ -29,7 +28,6 @@ English | [中文](SDK_Integration_zh.md)
2928
- [Backoff Strategy](#backoff-strategy)
3029
- [Custom Retry Strategy](#custom-retry-strategy)
3130
- [Exception Handling](#exception-handling)
32-
- [Output Raw Response](#output-raw-response)
3331
- [Resource Cleanup](#resource-cleanup)
3432
- [Debug Mechanism](#debug-mechanism)
3533
- [Environment Variables Description](#environment-variables-description)
@@ -44,6 +42,8 @@ English | [中文](SDK_Integration_zh.md)
4442

4543
It is recommended to use `pnpm` for installation, but `npm` and `yarn` are also supported.
4644

45+
1. Installation Core Packages
46+
4747
```bash
4848
# pnpm
4949
pnpm add @volcengine/sdk-core
@@ -55,6 +55,21 @@ npm install @volcengine/sdk-core
5555
yarn add @volcengine/sdk-core
5656
```
5757

58+
2. Installation Service Packages
59+
60+
Take installing ECS service SDK package as an example:
61+
62+
```bash
63+
# pnpm
64+
pnpm add @volcengine/ecs
65+
66+
# npm
67+
npm install @volcengine/ecs
68+
69+
# yarn
70+
yarn add @volcengine/ecs
71+
```
72+
5873
## Credentials
5974

6075
The SDK supports multiple ways to configure credentials, with the following priority from high to low:
@@ -441,9 +456,10 @@ The backoff strategy determines the wait time between each retry. You can choose
441456
- `ExponentialWithRandomJitterBackoffStrategy` (Default): Exponential backoff with jitter. Adds a random delay on top of exponential backoff to help avoid "thundering herd" effects.
442457

443458
```typescript
459+
import { StrategyName } from "@volcengine/sdk-core";
444460
const client = new EcsClient({
445461
// ... other configurations
446-
retryMode: "ExponentialBackoffStrategy",
462+
strategyName: StrategyName.ExponentialWithRandomJitterBackoffStrategy,
447463
});
448464
```
449465

@@ -502,7 +518,7 @@ try {
502518
if (error.status !== undefined) {
503519
// 1.1 SSL Error (status === 0)
504520
if (error.status === 0) {
505-
console.error(`❌ SSL Error: ${error.message}`);
521+
console.error(`❌ SSL Error`);
506522
}
507523
// 1.2 Server returned error (status > 0)
508524
else {
@@ -514,7 +530,6 @@ try {
514530
console.error(` RequestId: ${RequestId}`);
515531
} else {
516532
// Other HTTP errors (such as 404, 500, 502, etc.)
517-
console.error(`❌ HTTP Error ${error.status}: ${error.message}`);
518533
}
519534
}
520535
}
@@ -530,17 +545,12 @@ try {
530545
}
531546
// 3. Handle other SDK exceptions (Exception)
532547
else {
533-
console.error("❌ SDK Exception Occurred:");
534-
console.error(` Message: ${error.message}`);
535-
console.error(` Name: ${error.name}`);
536-
if (error.originalError) {
537-
console.error(" Cause:", error.originalError);
538-
}
548+
console.error("❌ SDK Exception Occurred");
539549
}
540550
}
541551
// 4. Unknown error (Error not thrown by SDK)
542552
else {
543-
console.error("❌ Unknown Error:", error);
553+
console.error("❌ Unknown Error");
544554
}
545555
}
546556
```

0 commit comments

Comments
 (0)