This document provides essential instructions for AI agents operating within the milvus-sdk-node repository.
- Root Directory:
/Users/ryjiang/workspace/milvus-sdk-node - Source Code:
milvus/(Top-level source directory, notsrc/) - Tests:
test/(Subdirectories:grpc,http,utils,build) - Build Output:
dist/ - Dependencies: Managed via
yarn.
- Full Build:
npm run build- Cleans
dist/, compiles TypeScript with declarations, and runsbuild.js.
- Cleans
- Proto Generation:
npm run proto:json- Updates
milvus/proto-json/by converting.protofiles to JSON/TS. Use this if theproto/submodule is updated.
- Updates
- Run All Tests:
npm test - Run a Single Test File:
Note: Always set
NODE_ENV=dev npx jest test/grpc/YourTestFile.spec.ts
NODE_ENV=devto ensure correct configuration. - Run Tests with Coverage:
npm run coverage - Test Configuration:
jest.config.jsusests-jest.
- Formatter: Prettier is used. Configuration in
.prettierrc.- Check formatting:
npx prettier --check . - Fix formatting:
npx prettier --write .
- Check formatting:
- Linting: No explicit
lintscript inpackage.json. Follow existing code style strictly.
- Language: TypeScript (Target
ES2015, CommonJS modules). - Strictness:
strict: trueintsconfig.json. Ensure no implicitany.
- Indentation: 2 spaces.
- Quotes: Single quotes (
'). - Semicolons: Yes (
semi: true). - Trailing Commas: ES5 (
trailingComma: "es5"). - Bracket Spacing: Yes (
bracketSpacing: true). - Arrow Parens: Avoid (
arrowParens: "avoid").
- Classes:
PascalCase(e.g.,MilvusClient,GRPCClient). - Methods & Variables:
camelCase(e.g.,createCollection,indexParams). - Constants:
UPPER_CASE(e.g.,DEFAULT_PRIMARY_KEY_FIELD,ERROR_REASONS). - Filenames: Match the primary class/module name (e.g.,
MilvusClient.ts,DataType.ts). Tests follow*.spec.ts.
- Use absolute imports or relative imports consistent with existing files.
- In tests, import from the SDK root or specific submodules as seen in examples:
import { MilvusClient } from '../../milvus';
- Use
async/awaitpattern. - Throw
Errorobjects with descriptive messages or specific error codes. - Check operation results against
ErrorCode.SUCCESS:if (res.error_code !== ErrorCode.SUCCESS) { throw new Error(res.reason); }
- Use JSDoc for public methods and classes.
- Include
@paramand@returnstags.
- Analyze: Read
package.jsonand related source files (milvus/) to understand context. - Verify: Before editing, run relevant tests to establish a baseline.
- Edit: Make changes ensuring strict type safety and adherence to style.
- Test: Run specific tests for the modified module. Create new tests in
test/if adding features. - Format: Run
npx prettier --write <file>on changed files.
- No
srcfolder: Source code lives inmilvus/. - Proto Files:
- Protocol buffers are in
proto/(a git submodule). - Run
git submodule update --init --recursiveto fetch them. - If
.protofiles change, runnpm run proto:jsonto regenerate the JSON definitions inmilvus/proto-json/.
- Protocol buffers are in
- Environment: Node.js environment.
- Use
describeblocks to group tests by class or functionality. - Use
itblocks for specific test cases. - Mock external dependencies where appropriate, but integration tests (connecting to a mock or real Milvus instance) are common in this repo.
- Clean up resources (e.g., close connections) in
afterAll.
package.json: Scripts and dependencies.tsconfig.json: TypeScript compiler options.jest.config.js: Test runner configuration..prettierrc: Code formatting rules.