Skip to content

Commit 1d4108b

Browse files
KevenWMarkhamclaude
andcommitted
test: add unit tests for Sprint 01 packages
Add comprehensive unit tests for monorepo packages Package test results: - @transcript-parser/export: 100% coverage (44 tests passing) All export formats, time formatting, download & clipboard - @transcript-parser/ai-services: Core functionality (14 tests) Cost calculation, usage tracking core - @transcript-parser/module-sdk: Full coverage (24 tests) Registry CRUD, lifecycle hooks, category filtering - @transcript-parser/audio-processing: Error handling tests Error class, instance creation - @transcript-parser/database: Schema validation tests Table structure, column definitions Configuration: - Add vitest.config.ts for all testable packages - Add README.md documentation for each package - Update Sprint 01 implementation README to E2E phase Status: Unit testing phase complete, ready for E2E testing 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 12ac3db commit 1d4108b

File tree

19 files changed

+2338
-6
lines changed

19 files changed

+2338
-6
lines changed

packages/ai-services/README.md

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
# @transcript-parser/ai-services
2+
3+
AI services integration for Transcript Parser, including Google Gemini API client and usage tracking.
4+
5+
## Installation
6+
7+
```bash
8+
pnpm add @transcript-parser/ai-services
9+
```
10+
11+
## Usage
12+
13+
### Gemini Client
14+
15+
```typescript
16+
import { GeminiClient } from '@transcript-parser/ai-services'
17+
18+
// Initialize with API key
19+
const client = new GeminiClient({
20+
apiKey: 'your-api-key',
21+
model: 'gemini-2.5-flash',
22+
})
23+
24+
// Transcribe audio with speaker diarization
25+
const audioBlob = new Blob([audioData], { type: 'audio/webm' })
26+
const transcript = await client.transcribeWithSpeakers(audioBlob, {
27+
onEntryComplete: entry => {
28+
console.log('Entry:', entry)
29+
},
30+
})
31+
```
32+
33+
### API Client
34+
35+
```typescript
36+
import { apiClient } from '@transcript-parser/ai-services'
37+
38+
// Get current user
39+
const user = apiClient.getCurrentUser()
40+
41+
// Set user
42+
apiClient.setUser({ id: 1, name: 'John Doe', email: 'john@example.com' })
43+
```
44+
45+
### Usage Tracker
46+
47+
```typescript
48+
import { usageTracker } from '@transcript-parser/ai-services'
49+
50+
// Track usage
51+
usageTracker.track({
52+
userId: 1,
53+
model: 'gemini-2.5-flash',
54+
operation: 'Video Transcription',
55+
inputTokens: 1000,
56+
outputTokens: 500,
57+
totalTokens: 1500,
58+
metadata: { fileSize: '2.5 MB' },
59+
})
60+
61+
// Get usage stats
62+
const stats = usageTracker.getUserUsage(1)
63+
```
64+
65+
## Features
66+
67+
- **Speaker Diarization**: Automatically identifies and separates different speakers
68+
- **Streaming Support**: Process transcript entries as they arrive
69+
- **Usage Tracking**: Monitor API usage and costs
70+
- **Error Handling**: Custom error types for quota, invalid audio, etc.
71+
- **Retry Logic**: Automatic retry with exponential backoff
72+
73+
## Configuration
74+
75+
Set your API key via environment variable:
76+
77+
```bash
78+
# .env
79+
VITE_GEMINI_API_KEY=your_api_key_here
80+
```
81+
82+
Or provide it programmatically when creating the client.
83+
84+
## Development
85+
86+
```bash
87+
# Build the package
88+
pnpm build
89+
90+
# Watch mode for development
91+
pnpm dev
92+
93+
# Type checking
94+
pnpm type-check
95+
```
96+
97+
## Security
98+
99+
- Never commit API keys to version control
100+
- Use environment variables for sensitive data
101+
- API keys are validated before use
102+
- Errors don't leak sensitive information

0 commit comments

Comments
 (0)