# Type Files Audit Report

**Date**: 2025-01-27  
**Actions**: 1.1.3.6, 1.1.3.7, 1.1.3.8 - Audit type files for duplication  
**Status**: ✅ Complete

## Overview

This document audits `dto.ts`, `v2-v3-types.ts`, and `backend-types.ts` to identify types that can be replaced with generated types from OpenAPI.

## Generated Types Available

From `apps/web/src/types/generated/api.ts`:
- `VezaBackendApiInternalModelsTrack` - Track model
- `VezaBackendApiInternalModelsUser` - User model
- `VezaBackendApiInternalModelsPlaylist` - Playlist model
- `VezaBackendApiInternalDtoLoginRequest` - Login request
- `VezaBackendApiInternalDtoLoginResponse` - Login response
- `VezaBackendApiInternalDtoRegisterRequest` - Register request
- `VezaBackendApiInternalDtoRegisterResponse` - Register response
- `VezaBackendApiInternalDtoUserResponse` - User response
- `VezaBackendApiInternalDtoTokenResponse` - Token response
- `InternalHandlersAPIResponse` - API response wrapper
- `InternalHandlersCreateCommentRequest` - Comment request
- And many more...

## File 1: `apps/web/src/types/dto.ts`

### Types Found:
1. `RegisterRequest` - Can use `VezaBackendApiInternalDtoRegisterRequest`
2. `RegisterResponse` - Can use `VezaBackendApiInternalDtoRegisterResponse`
3. `LoginRequest` - Can use `VezaBackendApiInternalDtoLoginRequest`
4. `LoginResponse` - Can use `VezaBackendApiInternalDtoLoginResponse`
5. `UserResponse` - Can use `VezaBackendApiInternalDtoUserResponse`
6. `TokenResponse` - Can use `VezaBackendApiInternalDtoTokenResponse`
7. `RefreshRequest` - Can use `VezaBackendApiInternalDtoRefreshRequest`
8. `ResendVerificationRequest` - Can use `VezaBackendApiInternalDtoResendVerificationRequest`
9. `ValidationError` - May need to keep (utility type)
10. `ValidationErrors` - May need to keep (utility type)

### Status:
- ✅ **All DTO types can be replaced** with generated types
- ⚠️ `ValidationError` and `ValidationErrors` may need to stay if used for form validation

### Migration Plan:
1. Replace all request/response DTOs with generated types
2. Keep `ValidationError`/`ValidationErrors` if used in forms
3. Update all imports from `@/types/dto` to `@/types/generated`

## File 2: `apps/web/src/types/v2-v3-types.ts`

### Types Found:
1. `ThemeVariant` - Keep (UI-specific, not in API)
2. `ProductDTO` - May have generated equivalent
3. `Purchase` - May have generated equivalent
4. `UploadState` - Keep (frontend state, not in API)
5. `Comment` - Check against generated comment types
6. `Post` - Keep (UI-specific, not in API)
7. `NavItem` - Keep (UI-specific, not in API)
8. `Achievement` - Keep (UI-specific, not in API)
9. `LeaderboardEntry` - Keep (UI-specific, not in API)
10. `LiveStream` - Keep (UI-specific, not in API)
11. `GearItem` - Keep (UI-specific, not in API)
12. `CartItem` - Keep (UI-specific, not in API)
13. `Course`, `Module`, `Lesson`, `Quiz` - Keep (UI-specific, not in API)
14. `Album` - Keep (UI-specific, not in API)
15. `AnalyticsMetric` - Keep (UI-specific, not in API)
16. `Channel`, `VoiceParticipant`, `Server` - Keep (UI-specific, not in API)
17. `DirectMessage` - Keep (UI-specific, not in API)
18. `FileNode` - Keep (UI-specific, not in API)
19. `SocialGroup` - Keep (UI-specific, not in API)
20. `Backup` - Keep (UI-specific, not in API)
21. `Report` - Keep (UI-specific, not in API)
22. `Project` - Keep (UI-specific, not in API)

### Status:
- ✅ **Most types are UI-specific** and should be kept
- ⚠️ `ProductDTO` and `Purchase` may have generated equivalents
- ⚠️ `Comment` imports `Track` from `./api` - needs migration

### Migration Plan:
1. Keep most types (UI-specific)
2. Check `ProductDTO` against `VezaBackendApiInternalCoreMarketplaceProduct`
3. Check `Purchase` against `VezaBackendApiInternalCoreMarketplaceOrder`
4. Update `Comment` import to use generated types
5. Remove `Track` import, use generated type if needed

## File 3: `apps/web/src/types/backend-types.ts`

### Types Found:
1. `BackendPost` - May have generated equivalent
2. `BackendFeedItem` - May have generated equivalent

### Status:
- ⚠️ **Small file, needs verification** against generated types
- May be obsolete if types exist in generated files

### Migration Plan:
1. Check if `BackendPost` matches any generated post/feed types
2. Check if `BackendFeedItem` matches any generated feed types
3. Replace or remove if obsolete
4. Update imports

## Summary

### dto.ts:
- **Replace**: 8 types (all request/response DTOs)
- **Keep**: 2 types (ValidationError, ValidationErrors - if used in forms)

### v2-v3-types.ts:
- **Replace**: 1-3 types (ProductDTO, Purchase, Comment - if generated equivalents exist)
- **Keep**: 20+ types (all UI-specific types)

### backend-types.ts:
- **Replace**: 0-2 types (BackendPost, BackendFeedItem - if generated equivalents exist)
- **Keep**: 0-2 types (if no generated equivalents)

## Next Steps

1. ✅ **Actions 1.1.3.6-1.1.3.8**: Audits complete - This document
2. ⏭️ **Action 1.1.3.3-1.1.3.5**: Replace Track/User/ApiError (HIGH risk)
3. ⏭️ **After type replacements**: Replace DTOs in dto.ts
4. ⏭️ **After type replacements**: Update v2-v3-types.ts imports
5. ⏭️ **After type replacements**: Replace/remove backend-types.ts

## Validation

✅ All type files audited  
✅ Duplication identified  
✅ Migration paths documented  
⚠️ Some types need verification against generated types
