Thank you for your interest in contributing! This document provides guidelines for development.
-
Clone the repository
git clone https://github.com/eternalai-org/typescript-sdk.git cd sdk -
Install dependencies
# Using Bun (recommended - fastest) bun install # Using yarn yarn install # Or using npm npm install
-
Run tests
# Using Bun (recommended) bun test # Using npm npm test
-
Build the SDK
# Using Bun (recommended) bun run build # Using npm npm run build
Using Bun (recommended):
bun run dev- Build in watch modebun test- Run testsbun run test:watch- Run tests in watch modebun run test:coverage- Generate test coverage reportbun run type-check- Run TypeScript type checkingbun run lint- Lint code with ESLintbun run lint:fix- Auto-fix linting issuesbun run format- Format code with Prettierbun run format:check- Check code formattingbun run build- Build production bundle
Using npm (alternative):
npm run dev- Build in watch modenpm test- Run testsnpm run test:watch- Run tests in watch modenpm run test:coverage- Generate test coverage reportnpm run type-check- Run TypeScript type checkingnpm run lint- Lint code with ESLintnpm run lint:fix- Auto-fix linting issuesnpm run format- Format code with Prettiernpm run format:check- Check code formattingnpm run build- Build production bundle
src/
├── index.ts # Main entry point
├── client.ts # EternalAI class
├── types/ # TypeScript type definitions
│ └── index.ts
└── services/ # Service layer
└── chat.ts # Chat service
tests/ # Test files
├── README.md # Test documentation
├── client.test.ts # Client initialization tests
├── chat.test.ts # Chat service tests
├── types.test.ts # Type definition tests
└── integration.test.ts # Integration tests
- Language: TypeScript (strict mode enabled)
- Linting: ESLint with TypeScript plugin
- Formatting: Prettier
- Comments: All code comments must be in English
Run linting and formatting before committing:
# Using Bun (recommended)
bun run lint:fix
bun run format
# Using npm
npm run lint:fix
npm run format- Use Vitest for testing
- Place test files in the
tests/directory - Name test files with
.test.tssuffix - Maintain 100% code coverage (current standard)
- Mock external dependencies (like
fetch) to avoid real API calls - Use descriptive test names that explain what is being tested
- Suppress console.error when testing error handling with
vi.spyOn()
Example test:
import { describe, it, expect, vi, beforeEach } from 'vitest';
import { EternalAI } from '../src/client';
describe('EternalAI', () => {
beforeEach(() => {
vi.clearAllMocks();
});
it('should initialize correctly with valid API key', () => {
const client = new EternalAI({ apiKey: 'test' });
expect(client).toBeDefined();
expect(client.chat).toBeDefined();
});
it('should throw error when API key is missing', () => {
expect(() => new EternalAI({ apiKey: '' })).toThrow('API key is required');
});
});Current and target coverage metrics:
- Statements: 100% ✅
- Branches: 100% ✅
- Functions: 100% ✅
- Lines: 100% ✅
Please maintain 100% coverage for all new code. View the test suite documentation at tests/README.md.
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Make your changes
- Run tests and linting:
# Using Bun (recommended) bun test && bun run lint # Using npm npm test && npm run lint
- Commit your changes with a descriptive message
- Push to your fork (
git push origin feature/amazing-feature) - Open a Pull Request
Use clear and descriptive commit messages:
feat: add new featurefix: resolve bug in chat servicedocs: update READMEtest: add tests for streamingrefactor: improve error handlingchore: update dependencies
This SDK provides TypeScript bindings for EternalAI's chat completion API:
- Purpose: Enable developers to easily integrate AI chat capabilities
- Main Features: Chat completions with streaming support
- API Endpoint:
https://open.eternalai.org/api/v1 - Compatible With: OpenAI API format
For more information about EternalAI platform, visit eternalai.org/api/build.
- 🐛 Bug Reports: Open an issue on GitHub
- 💬 Questions: Open a discussion or issue
- 📖 Documentation: See README.md and tests/README.md