|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. |
| 4 | + |
| 5 | +## Development Commands |
| 6 | + |
| 7 | +### Core Commands |
| 8 | +- `npm test` - Run the main test suite (compiles TypeScript and runs Jest on minimal-client.test.js) |
| 9 | +- `npm run test:all` - Run all tests with Jest configuration |
| 10 | +- `npm run build` - Compile TypeScript to JavaScript in the `dist/` directory |
| 11 | +- `tsc` - Direct TypeScript compilation (same as npm run build) |
| 12 | + |
| 13 | +### Publishing Commands |
| 14 | +- `npm run patch` - Build, bump patch version, and create git tag |
| 15 | +- `npm run minor` - Build, bump minor version, and create git tag |
| 16 | +- `npm run tag` - Create git tag for current npm version |
| 17 | + |
| 18 | +## Project Architecture |
| 19 | + |
| 20 | +This is a Node.js SDK for the Openapi® marketplace that provides two main client classes: |
| 21 | + |
| 22 | +### Core Components |
| 23 | + |
| 24 | +**OauthClient** (`src/index.ts:15-60`) |
| 25 | +- Handles OAuth token management for API authentication |
| 26 | +- Supports both test (`test.oauth.altravia.com`) and production (`oauth.altravia.com`) environments |
| 27 | +- Methods: `createToken()`, `getTokens()`, `deleteToken()`, `getCounters()`, `getScopes()` |
| 28 | +- Uses HTTP Basic authentication with username/API key |
| 29 | + |
| 30 | +**Client** (`src/index.ts:62-118`) |
| 31 | +- Generic HTTP client for making API calls using access tokens |
| 32 | +- Supports all standard HTTP methods (GET, POST, PUT, DELETE, PATCH) |
| 33 | +- Uses Bearer token authentication |
| 34 | +- Generic `request()` method allows custom configurations |
| 35 | + |
| 36 | +### Dependencies |
| 37 | +- **axios** (^0.21.2) - HTTP client library for all API communications |
| 38 | +- **typescript** (^4.3.4) - TypeScript compilation |
| 39 | +- **jest** (^27.0.5) - Testing framework |
| 40 | +- **dotenv** (^10.0.0) - Environment variable loading for tests |
| 41 | + |
| 42 | +### Key File Structure |
| 43 | +- `src/index.ts` - Main SDK implementation with both client classes |
| 44 | +- `test/minimal-client.test.js` - Comprehensive test suite with mocked HTTP calls |
| 45 | +- `examples/` - Usage examples for token generation and API calls |
| 46 | +- `dist/` - Compiled JavaScript output (generated by TypeScript compiler) |
| 47 | + |
| 48 | +### Testing Notes |
| 49 | +- Tests use mocked axios instances to avoid real API calls during development |
| 50 | +- Environment variables are loaded via dotenv for test configuration |
| 51 | +- Integration tests are skipped by default but can be enabled with real credentials |
| 52 | +- Test files are excluded from TypeScript compilation |
| 53 | + |
| 54 | +### TypeScript Configuration |
| 55 | +- Targets ES5 with CommonJS modules for broad Node.js compatibility |
| 56 | +- Strict mode enabled with declaration file generation |
| 57 | +- Output goes to `dist/` directory with source maps disabled |
0 commit comments