|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. |
| 4 | + |
| 5 | +## Overview |
| 6 | + |
| 7 | +This is the Smartling Translation API SDK for Node.js, providing TypeScript interfaces for interacting with Smartling's translation services. The SDK covers all major API endpoints including files, jobs, locales, projects, and translation management. |
| 8 | + |
| 9 | +## Commands |
| 10 | + |
| 11 | +### Build Commands |
| 12 | +- `npm run build` - Production build (TypeScript compilation to `built/` directory) |
| 13 | +- `npm run build:dev` - Development build (includes test files) |
| 14 | + |
| 15 | +### Testing |
| 16 | +- `npm test` - Run full test suite with lint, build, and coverage |
| 17 | +- `npm run test:dev` - Run tests without JUnit reporting (for development) |
| 18 | + |
| 19 | +### Linting |
| 20 | +- `npm run pretest` - Run ESLint on all TypeScript files |
| 21 | +- ESLint configuration in `.eslintrc` with TypeScript, Airbnb, and custom rules |
| 22 | + |
| 23 | +### Single Test Execution |
| 24 | +Run individual test files using Mocha directly: |
| 25 | +```bash |
| 26 | +npm run build:dev && npx mocha built/test/[specific-test].spec.js |
| 27 | +``` |
| 28 | + |
| 29 | +## Architecture |
| 30 | + |
| 31 | +### Core Structure |
| 32 | +- **API Layer**: Organized by feature domains (`/api/`) |
| 33 | + - `auth/` - Authentication and token management |
| 34 | + - `files/` - File upload/download operations |
| 35 | + - `jobs/` - Translation job management |
| 36 | + - `locales/` - Language and locale handling |
| 37 | + - `projects/` - Project management |
| 38 | + - `strings/` - String resource management |
| 39 | + - `context/` - Context matching for translations |
| 40 | + - `job-batches/` - Batch job processing |
| 41 | + - `published-files/` - Published file management |
| 42 | + - `file-translations/` - File translation services |
| 43 | + - `mt/` - Machine translation services |
| 44 | + |
| 45 | +### Pattern Structure |
| 46 | +Each API domain follows a consistent pattern: |
| 47 | +- `index.ts` - Main API client class |
| 48 | +- `dto/` - Data transfer objects (response/request types) |
| 49 | +- `params/` - Parameter classes for API calls |
| 50 | + |
| 51 | +### Key Components |
| 52 | +- **SmartlingApiClientBuilder**: Main entry point for creating API clients |
| 53 | +- **AccessTokenProvider**: Interface for authentication (with StaticAccessTokenProvider implementation) |
| 54 | +- **SmartlingListResponse**: Generic wrapper for paginated API responses |
| 55 | +- **Logger**: Centralized logging utility |
| 56 | + |
| 57 | +### TypeScript Configuration |
| 58 | +- Uses `tsconfig.json` for production builds |
| 59 | +- Uses `tsconfig.dev.json` for development (includes test files) |
| 60 | +- Targets ES6 with CommonJS modules |
| 61 | +- Generates declaration files and source maps |
| 62 | + |
| 63 | +### Testing Framework |
| 64 | +- Mocha test runner with TypeScript support |
| 65 | +- Sinon for mocking and stubbing |
| 66 | +- NYC for code coverage reporting |
| 67 | +- Tests located in `/test/` directory matching API structure |
0 commit comments