This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
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.
- Build:
npm run build(compiles TypeScript todist/) - Lint:
npm run lint(ESLint onsrcandconfig) - Test:
npm test(runs Jest; auto-generates services first) - 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' - Typecheck:
npm run typecheck(checks both src and examples) - Generate services from protos:
npm run cloudapi:generate-services - Update cloudapi submodule:
npm run cloudapi:update
Commit messages must follow Conventional Commits (enforced by commitlint via husky hook). Semantic-release publishes from master, beta, and alpha branches.
The cloudapi submodule contains .proto files from github.com/yandex-cloud/cloudapi. The scripts/generate_services script:
- Runs
ts-protoviagrpc_tools_node_protocto generate TypeScript types/clients intosrc/generated/ - Detects service directories and creates re-export
index.tsfiles insrc/clients/<service-name>/ - Updates
package.jsonexports map so each service is importable as@yandex-cloud/nodejs-sdk/<service-name>
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.
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.
The client factory (src/utils/client-factory.ts) chains three nice-grpc middlewares:
- errorMetadataMiddleware — wraps errors into
ApiErrorwith request/trace IDs from gRPC metadata - retryMiddleware — exponential backoff retry for idempotent/configured calls
- deadlineMiddleware — from
nice-grpc-client-middleware-deadline
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.
SessionConfig— union of credential configs (OAuth, IAM token, service account, generic/metadata)WrappedServiceClientType<S>— nice-grpcRawClientwith retry + deadline call optionsClientCallArgs—RetryOptions & DeadlineOptions, passed per-callApiError— extendsErrorwith gRPC metadata (requestId,serverTraceId)