Contributing
Development setup, code quality, and contribution guidelines for CosmosQL
Thank you for your interest in contributing to CosmosQL! This guide will help you get started with development.
Development Setup
Prerequisites
- Node.js 18+ or Bun 1.0+
- TypeScript 5.0+
- Git for version control
Getting Started
- Clone the repository:
git clone https://github.com/Stoffberg/cosmosql.git
cd cosmosql- Install dependencies:
# Using Bun (recommended)
bun install
# Or using npm
npm install- Build the project:
bun run build
# Or
npm run build- Run tests:
# All tests
bun test
# Unit tests only
bun test tests/unit
# Integration tests only
bun test tests/integrationNote: Integration tests require a real Azure CosmosDB account. Set up environment variables:
COSMOS_ENDPOINT=https://your-account.documents.azure.com:443/
COSMOS_KEY=your-key
COSMOS_DATABASE=test-dbCode Quality
CosmosQL maintains high code quality standards:
Linting and Formatting
Biome is used for linting and formatting:
# Check for issues
bun run lint
# Auto-fix issues
bun run formatTypeScript
- Strict mode is enabled
- All code must be fully typed
- Avoid
anytypes unless absolutely necessary
Testing
- Comprehensive test suite required for all changes
- Maintain high test coverage
- Add tests for new features and bug fixes
Architecture
Understanding CosmosQL's architecture helps when contributing:
Core Principles
- Zero Dependencies - Only TypeScript, no external runtime dependencies
- Type-Level Programming - Leverage TypeScript's type system for schema inference
- REST API Direct - Direct HTTP calls to CosmosDB REST API, no SDK wrapper
- Bun Runtime Optimized - Built and tested with Bun, works with Node.js
Project Structure
cosmosql/
├── src/
│ ├── client/ # Client creation and configuration
│ ├── container/ # Container schema definitions
│ ├── query/ # Query builder and execution
│ ├── types/ # Type definitions and inference
│ └── utils/ # Utilities and helpers
├── tests/
│ ├── unit/ # Unit tests
│ └── integration/ # Integration tests with real CosmosDB
└── package.jsonKey Concepts
- Schema Definition: TypeScript-only schemas that don't exist at runtime
- Type Inference: Automatic type inference from schemas
- Partition Key Enforcement: Compile-time enforcement via TypeScript
- Query Builder: Type-safe SQL query generation
Making Changes
Workflow
- Create a branch:
git checkout -b feature/your-feature-name
# or
git checkout -b fix/your-bug-fix-
Make your changes - Write code, add tests
-
Run tests and linting:
bun test
bun run lint- Commit your changes:
git commit -m "feat: add new feature description"Follow Conventional Commits format:
feat:- New featurefix:- Bug fixdocs:- Documentation changestest:- Test additions/changesrefactor:- Code refactoringperf:- Performance improvements
- Push and create a PR:
git push origin feature/your-feature-namePull Request Guidelines
- Clear description of what changed and why
- Reference issues if fixing a bug or feature request
- Add tests for new features or bug fixes
- Update documentation if API changes or new features added
- Ensure all tests pass and linting is clean
Testing Requirements
- New features must include unit tests
- Integration tests for database operations
- Edge cases should be covered
- Maintain or improve test coverage
Areas for Contribution
High Priority
- Bug fixes - Report and fix bugs
- Documentation - Improve clarity and completeness
- Performance - Optimize queries and operations
- Type safety - Enhance type inference and error messages
Feature Ideas
- Aggregation functions (
count,sum,avg, etc.) - Cursor-based pagination
- Batch operations across partitions
- Additional query operators
Documentation
- Code examples
- Best practices guides
- Migration guides
- API reference improvements
Getting Help
If you need help:
- Check existing issues on GitHub
- Ask questions in discussions
- Join Discord community (if available)
- Read existing code to understand patterns
License
CosmosQL is licensed under the MIT License. By contributing, you agree that your contributions will be licensed under the same license.
Thank you for contributing to CosmosQL! Your efforts help make CosmosDB development safer and more enjoyable for everyone.