Skip to content

Commit 71f928e

Browse files
authored
Merge pull request #206 from yandex-cloud/beta
Stable 3.0
2 parents 42a0ce9 + a689001 commit 71f928e

953 files changed

Lines changed: 789045 additions & 621548 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.

.commitlintrc.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
11
{
2-
"extends": [
3-
"@commitlint/config-conventional"
4-
]
2+
"extends": ["@commitlint/config-conventional"]
53
}

.eslintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
src/generated/**
2+
src/clients/**

.eslintrc.json

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,7 @@
1111
"plugin:@typescript-eslint/recommended"
1212
],
1313
"parser": "@typescript-eslint/parser",
14-
"plugins": [
15-
"@typescript-eslint",
16-
"unicorn",
17-
"import",
18-
"prefer-arrow-functions"
19-
],
14+
"plugins": ["@typescript-eslint", "unicorn", "import", "prefer-arrow-functions"],
2015
"parserOptions": {
2116
"project": "tsconfig.eslint.json"
2217
},
@@ -31,8 +26,8 @@
3126
"import/prefer-default-export": "off",
3227
"comma-dangle": ["error", "always-multiline"],
3328
"indent": "off",
34-
"@typescript-eslint/indent": ["error", 4],
3529
"max-len": ["error", 140],
30+
"@typescript-eslint/indent": ["error", 4],
3631
"@typescript-eslint/ban-ts-comment": "off",
3732
"@typescript-eslint/prefer-optional-chain": "error",
3833
"prefer-arrow-functions/prefer-arrow-functions": ["error"],
@@ -42,14 +37,21 @@
4237
"no-plusplus": "off",
4338
"unicorn/import-style": "off",
4439
"@typescript-eslint/no-var-requires": "off",
45-
"no-underscore-dangle": ["error", {
46-
"allowAfterThis": true,
47-
"allowAfterSuper": false
48-
}],
40+
"no-underscore-dangle": [
41+
"error",
42+
{
43+
"allowAfterThis": true,
44+
"allowAfterSuper": false
45+
}
46+
],
4947
"unicorn/no-null": "off",
50-
"import/no-extraneous-dependencies": ["error", {
51-
"devDependencies": true
52-
}],
53-
"import/no-cycle": "off"
48+
"import/no-extraneous-dependencies": [
49+
"error",
50+
{
51+
"devDependencies": true
52+
}
53+
],
54+
"import/no-cycle": "off",
55+
"@typescript-eslint/no-explicit-any": 1
5456
}
5557
}

.github/actions/checkout-and-install-node/action.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ inputs:
55
description: 'Whether to configure the token or SSH key with the local git config'
66
required: false
77
default: 'true'
8+
submodules:
9+
description: 'Whether to checkout submodules along with specified repo'
10+
required: false
11+
default: 'false'
812
runs:
913
using: 'composite'
1014
steps:

.github/workflows/pr-checks.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,27 @@ jobs:
99
tests:
1010
runs-on: ubuntu-24.04
1111
steps:
12-
- uses: yandex-cloud/nodejs-sdk/.github/actions/checkout-and-install-node@d6b5322d8dbc130126ec1fa00bc0f2d6cc2f53db
12+
- uses: yandex-cloud/nodejs-sdk/.github/actions/checkout-and-install-node@7992e39cce119c931dab92f6879013efff123009
13+
with:
14+
submodules: recursive
1315
- run: npm run test
1416
check-endpoints:
1517
runs-on: ubuntu-24.04
1618
# Currently, the check-endpoints script fails on the master branch.
1719
# So we need to continue on error.
1820
continue-on-error: true
1921
steps:
20-
- uses: yandex-cloud/nodejs-sdk/.github/actions/checkout-and-install-node@d6b5322d8dbc130126ec1fa00bc0f2d6cc2f53db
22+
- uses: yandex-cloud/nodejs-sdk/.github/actions/checkout-and-install-node@7992e39cce119c931dab92f6879013efff123009
2123
with:
2224
submodules: recursive
2325
- run: npm run check-endpoints
2426
lint:
2527
runs-on: ubuntu-24.04
2628
steps:
27-
- uses: yandex-cloud/nodejs-sdk/.github/actions/checkout-and-install-node@d6b5322d8dbc130126ec1fa00bc0f2d6cc2f53db
29+
- uses: yandex-cloud/nodejs-sdk/.github/actions/checkout-and-install-node@7992e39cce119c931dab92f6879013efff123009
2830
- run: npm run lint
2931
build:
3032
runs-on: ubuntu-24.04
3133
steps:
32-
- uses: yandex-cloud/nodejs-sdk/.github/actions/checkout-and-install-node@d6b5322d8dbc130126ec1fa00bc0f2d6cc2f53db
34+
- uses: yandex-cloud/nodejs-sdk/.github/actions/checkout-and-install-node@7992e39cce119c931dab92f6879013efff123009
3335
- run: npm run build

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
name: Release
1212
runs-on: ubuntu-24.04
1313
steps:
14-
- uses: yandex-cloud/nodejs-sdk/.github/actions/checkout-and-install-node@d6b5322d8dbc130126ec1fa00bc0f2d6cc2f53db
14+
- uses: yandex-cloud/nodejs-sdk/.github/actions/checkout-and-install-node@7992e39cce119c931dab92f6879013efff123009
1515
with:
1616
persist-credentials: false
1717
- env:

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
.idea
22
node_modules
33
dist
4+
.env
5+
.vscode

.prettierignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
**/generated/**

.prettierrc.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
module.exports = {
2+
tabWidth: 4,
3+
printWidth: 100,
4+
singleQuote: true,
5+
trailingComma: 'all',
6+
bracketSpacing: true,
7+
overrides: [
8+
{
9+
files: ['*.js', '*.jsx', '*.ts', '*.tsx'],
10+
options: {
11+
parser: 'typescript',
12+
},
13+
},
14+
{
15+
files: ['*.md', '*.json', '*.yaml', '*.yml'],
16+
options: {
17+
tabWidth: 2,
18+
},
19+
},
20+
],
21+
};

CLAUDE.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# CLAUDE.md
2+
3+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4+
5+
## Overview
6+
7+
Yandex Cloud Node.js SDK (`@yandex-cloud/nodejs-sdk`). Provides typed gRPC clients for all Yandex Cloud services, generated from protobuf definitions in the `cloudapi` git submodule.
8+
9+
## Commands
10+
11+
- **Build:** `npm run build` (compiles TypeScript to `dist/`)
12+
- **Lint:** `npm run lint` (ESLint on `src` and `config`)
13+
- **Test:** `npm test` (runs Jest; auto-generates services first)
14+
- **Single test:** `cross-env NODE_OPTIONS="--max-old-space-size=8192" node --experimental-vm-modules node_modules/jest/bin/jest.js -c config/jest.ts --passWithNoTests 'path/to/test'`
15+
- **Typecheck:** `npm run typecheck` (checks both src and examples)
16+
- **Generate services from protos:** `npm run cloudapi:generate-services`
17+
- **Update cloudapi submodule:** `npm run cloudapi:update`
18+
19+
Commit messages must follow [Conventional Commits](https://www.conventionalcommits.org/) (enforced by commitlint via husky hook). Semantic-release publishes from `master`, `beta`, and `alpha` branches.
20+
21+
## Architecture
22+
23+
### Code generation pipeline
24+
25+
The `cloudapi` submodule contains `.proto` files from `github.com/yandex-cloud/cloudapi`. The `scripts/generate_services` script:
26+
1. Runs `ts-proto` via `grpc_tools_node_protoc` to generate TypeScript types/clients into `src/generated/`
27+
2. Detects service directories and creates re-export `index.ts` files in `src/clients/<service-name>/`
28+
3. Updates `package.json` exports map so each service is importable as `@yandex-cloud/nodejs-sdk/<service-name>`
29+
30+
**Do not edit files in `src/generated/` or `src/clients/*/index.ts` manually** — they are overwritten by code generation. Client directories may contain an `export-alias.json` for custom export names.
31+
32+
### Session and client creation
33+
34+
`Session` (`src/session.ts`) is the main entry point. It handles authentication (OAuth, IAM token, service account JSON, or metadata service) and creates gRPC channels with credentials. Clients are obtained via `session.client(ServiceClient)`, which resolves endpoints from `src/service-endpoints-map.json`.
35+
36+
### Middleware stack
37+
38+
The client factory (`src/utils/client-factory.ts`) chains three `nice-grpc` middlewares:
39+
1. **errorMetadataMiddleware** — wraps errors into `ApiError` with request/trace IDs from gRPC metadata
40+
2. **retryMiddleware** — exponential backoff retry for idempotent/configured calls
41+
3. **deadlineMiddleware** — from `nice-grpc-client-middleware-deadline`
42+
43+
### Service endpoint resolution
44+
45+
`src/service-endpoints.ts` maps a gRPC service's `serviceName` to its API endpoint using `src/service-endpoints-map.json`. The map is updated by the generation script via `scripts/check-endpoints.ts` which queries `https://api.cloud.yandex.net/endpoints`.
46+
47+
### Key types
48+
49+
- `SessionConfig` — union of credential configs (OAuth, IAM token, service account, generic/metadata)
50+
- `WrappedServiceClientType<S>` — nice-grpc `RawClient` with retry + deadline call options
51+
- `ClientCallArgs``RetryOptions & DeadlineOptions`, passed per-call
52+
- `ApiError` — extends `Error` with gRPC metadata (`requestId`, `serverTraceId`)

0 commit comments

Comments
 (0)