Thank you for your interest in contributing to the Apache IoTDB Node.js client!
- Node.js >= 14.0.0
- npm or yarn
- Apache Thrift compiler (for regenerating Thrift files)
- Git
- Clone the repository:
git clone https://github.com/CritasWang/@iotdb/client.git
cd @iotdb/client- Install dependencies:
npm install- Build the project:
npm run build- Run tests:
npm testnpm run buildThis compiles TypeScript files to JavaScript in the dist/ directory.
Run all tests:
npm testRun only unit tests:
npm run test:unitRun only E2E tests (requires running IoTDB instance):
export IOTDB_HOST=localhost
export IOTDB_PORT=6667
npm run test:e2enpm run lintnpm run format- Use TypeScript strict mode
- Follow existing code formatting (use Prettier)
- Add JSDoc comments for public APIs
- Keep functions focused and concise
- Use async/await instead of callbacks
- Handle errors appropriately
- Place in
tests/unit/ - Test individual functions and classes
- Mock external dependencies
- Aim for high coverage
- Place in
tests/e2e/ - Test against real IoTDB instance
- Use environment variables for configuration
- Gracefully handle missing IoTDB instance
- Clean up test data
Example E2E test pattern:
describe('Feature E2E Tests',()=>{letclient;beforeAll(async()=>{try{client=newSession({host: process.env.IOTDB_HOST||'localhost',port: parseInt(process.env.IOTDB_PORT||'6667'),});awaitclient.open();}catch(error){console.warn('IoTDB not available, tests will be skipped');}});afterAll(async()=>{if(client?.isOpen()){awaitclient.close();}});test('Should do something',async()=>{if(!client?.isOpen()){console.log('Skipping - no IoTDB connection');return;}// Test implementation});});- Create a feature branch from
main - Make your changes
- Add/update tests as needed
- Ensure all tests pass
- Update documentation if needed
- Submit a pull request
- Code builds without errors
- All tests pass
- New code has tests
- Documentation updated (if applicable)
- CHANGELOG.md updated
- Code follows project style
- Commit messages are clear
If you need to update to a newer version of IoTDB's Thrift definitions:
- Download the latest Thrift files from Apache IoTDB:
git clone --depth 1 https://github.com/apache/iotdb.git /tmp/iotdb- Copy the Thrift files:
cp /tmp/iotdb/iotdb-protocol/thrift-datanode/src/main/thrift/client.thrift thrift/
cp /tmp/iotdb/iotdb-protocol/thrift-commons/src/main/thrift/common.thrift thrift/- Regenerate the Node.js client:
thrift --gen js:node -out src/thrift/generated thrift/client.thrift- Test thoroughly to ensure compatibility
When adding new features:
- Check if the feature is supported in Apache IoTDB
- Add the implementation in the appropriate file
- Add TypeScript type definitions
- Write unit tests
- Write E2E tests
- Add example usage
- Update README.md
- Update IMPLEMENTATION.md
- Update CHANGELOG.md
- Add method to
src/client/Session.ts - Add the same method to
src/client/SessionPool.ts(delegating to pool) - Add tests in
tests/e2e/Session.test.tsandtests/e2e/SessionPool.test.ts - Update TypeScript exports in
src/index.tsif needed - Add example usage in README.md
- Update interfaces in
src/utils/Config.ts - Update DEFAULT_CONFIG or DEFAULT_POOL_CONFIG
- Update tests in
tests/unit/Config.test.ts - Document in README.md
When reporting issues, please include:
- Node.js version
- IoTDB version
- Operating system
- Steps to reproduce
- Expected behavior
- Actual behavior
- Error messages/stack traces
For questions or discussions:
- Open an issue on GitHub
- Check existing issues and documentation
By contributing, you agree that your contributions will be licensed under the Apache License 2.0.