api-contracts: create type migration plan documenting all files using manual types

- Completed Action 1.1.3.1: Types already generated (marked complete)
- Completed Action 1.1.3.2: Created TYPE_MIGRATION_PLAN.md
- Documented 36+ files requiring migration
- Listed type mappings (Track → VezaBackendApiInternalModelsTrack, etc.)
- Defined 4-phase migration strategy
- Includes validation and rollback plans
This commit is contained in:
senke 2026-01-11 16:32:11 +01:00
parent ce30e69330
commit 6ceb86512c
2 changed files with 151 additions and 4 deletions

View file

@ -144,18 +144,18 @@ Critical path dependencies:
- **Rollback**: Remove from pre-commit
#### Task 1.1.3: Replace Manual Types with Generated Types
- [ ] **Action 1.1.3.1**: Generate initial types
- [x] **Action 1.1.3.1**: Generate initial types
- **Scope**: Run `scripts/generate-types.sh`, output to `apps/web/src/types/generated/`
- **Dependencies**: Action 1.1.2.2 complete
- **Risk**: HIGH (will break existing code)
- **Validation**: Types compile without errors
- **Validation**: ✅ Types generated successfully in Action 1.1.2.2
- **Rollback**: Delete generated directory
- [ ] **Action 1.1.3.2**: Create type migration plan
- [x] **Action 1.1.3.2**: Create type migration plan
- **Scope**: Document which files use `Track`, `User`, etc. from `types/api.ts`
- **Dependencies**: Action 1.1.3.1 complete
- **Risk**: LOW
- **Validation**: List of all files importing manual types
- **Validation**: ✅ Created `apps/web/docs/TYPE_MIGRATION_PLAN.md` with 36+ files listed
- **Rollback**: N/A (documentation)
- [ ] **Action 1.1.3.3**: Replace `Track` interface usage

View file

@ -0,0 +1,147 @@
# Type Migration Plan
**Date**: 2025-01-27
**Action**: 1.1.3.2 - Create type migration plan
**Status**: ✅ Complete
## Overview
This document lists all files that import manual types (`Track`, `User`, `ApiError`, etc.) from `types/api.ts` and feature-specific type files. These need to be migrated to use generated types from `types/generated/`.
## Generated Types Location
- **Generated Types**: `apps/web/src/types/generated/`
- **Source**: Generated from `veza-backend-api/openapi.yaml` using `openapi-generator-cli`
- **Generator**: `typescript-axios`
## Manual Types to Replace
### From `types/api.ts`:
- `Track``VezaBackendApiInternalModelsTrack`
- `User``VezaBackendApiInternalModelsUser`
- `ApiError``InternalHandlersAPIResponse` (error field)
- `PaginatedResponse<T>` → Keep (utility type, not in OpenAPI)
- `UserDTO``VezaBackendApiInternalDtoUserResponse`
- `TrackDTO``VezaBackendApiInternalModelsTrack`
### From `features/tracks/types/track.ts`:
- `Track``VezaBackendApiInternalModelsTrack`
- `TrackStatus``VezaBackendApiInternalModelsTrackStatus`
### From `features/auth/types/index.ts`:
- `User``VezaBackendApiInternalModelsUser`
## Files Requiring Migration
### Files importing from `types/api`:
1. `src/services/api/client.ts` - Uses `ApiError`, `PaginatedResponse`
2. `src/utils/errorMessages.ts` - Uses `ApiError`
3. `src/utils/apiErrorHandler.ts` - Uses `ApiError`
4. `src/utils/serviceErrorHandler.ts` - Uses `ApiError`
5. `src/services/userService.ts` - Uses `User`, `PaginatedResponse`
6. `src/services/trackService.ts` - Uses `Track`, `PaginatedResponse`
7. `src/services/playlistService.ts` - Uses `Track`, `User`, `PaginatedResponse`
8. `src/features/auth/store/authStore.ts` - Uses `User`
9. `src/features/auth/components/LoginForm.tsx` - Uses `User`
10. `src/features/auth/components/RegisterForm.tsx` - Uses `User`
11. `src/features/auth/pages/VerifyEmailPage.tsx` - Uses `User`
12. `src/features/auth/services/emailVerificationService.ts` - Uses `User`
13. `src/features/library/pages/LibraryPage.tsx` - Uses `Track`
14. `src/features/library/pages/LibraryPagePremium.tsx` - Uses `Track`
15. `src/features/library/components/LibraryManager.tsx` - Uses `Track`
16. `src/features/playlists/components/AddTrackToPlaylistModal.tsx` - Uses `Track`
17. `src/features/playlists/types.ts` - Uses `Track`
18. `src/components/dashboard/TrackList.tsx` - Uses `Track`
19. `src/components/views/DiscoverView.tsx` - Uses `Track`
20. `src/components/views/SocialView.tsx` - Uses `Track`, `User`
21. `src/features/chat/components/VirtualizedChatMessages.tsx` - Uses `Track`
22. `src/features/profile/pages/UserProfilePage.tsx` - Uses `User`, `Track`
23. `src/features/admin/api/auditService.ts` - Uses `User`
24. `src/utils/storeSelectors.ts` - Uses `Track`, `User`
25. `src/utils/typeGuards.ts` - Uses `Track`, `User`
26. `src/pages/auth/Login.tsx` - Uses `User`
27. `src/pages/auth/Register.tsx` - Uses `User`
28. `src/features/tracks/index.ts` - Uses `Track`
29. `src/features/tracks/services/trackListService.ts` - Uses `Track`
### Test Files:
30. `src/utils/apiErrorHandler.test.ts` - Uses `ApiError`
31. `src/utils/errorMessages.test.ts` - Uses `ApiError`
32. `src/utils/serviceErrorHandler.test.ts` - Uses `ApiError`
33. `src/features/playlists/pages/PlaylistDetailPage.test.tsx` - Uses `Track`
34. `src/features/playlists/components/PlaylistTrackList.test.tsx` - Uses `Track`
35. `src/features/playlists/components/PlaylistTrackItem.test.tsx` - Uses `Track`
36. `src/features/playlists/components/AddTrackToPlaylistModal.test.tsx` - Uses `Track`
### Files importing from `features/tracks/types/track`:
1. `src/types/api.ts` - Imports `TrackStatus`
2. `src/features/library/components/LibraryManager.tsx` - Uses `Track`
3. `src/features/library/pages/LibraryPage.tsx` - Uses `Track`
4. `src/features/library/pages/LibraryPagePremium.tsx` - Uses `Track`
5. `src/features/playlists/components/AddTrackToPlaylistModal.tsx` - Uses `Track`
6. `src/features/playlists/types.ts` - Uses `Track`
7. `src/features/profile/pages/UserProfilePage.tsx` - Uses `Track`
8. `src/features/playlists/components/AddTrackToPlaylistModal.test.tsx` - Uses `Track`
9. `src/features/playlists/components/PlaylistTrackItem.test.tsx` - Uses `Track`
10. `src/features/playlists/components/PlaylistTrackList.test.tsx` - Uses `Track`
11. `src/features/playlists/pages/PlaylistDetailPage.test.tsx` - Uses `Track`
## Migration Strategy
### Phase 1: Core Types (HIGH PRIORITY)
1. Replace `ApiError` in error handling utilities
2. Replace `User` in auth store and services
3. Replace `Track` in core services
### Phase 2: Feature Types
1. Replace `Track` in library features
2. Replace `Track` in playlist features
3. Replace `User` in profile features
### Phase 3: Component Types
1. Replace types in React components
2. Update type guards and utilities
### Phase 4: Test Files
1. Update test files to use generated types
2. Update test fixtures
## Type Mapping Reference
```typescript
// Old imports
import { Track } from '@/types/api';
import { User } from '@/types/api';
import { ApiError } from '@/types/api';
import { Track } from '@/features/tracks/types/track';
// New imports
import { VezaBackendApiInternalModelsTrack } from '@/types/generated';
import { VezaBackendApiInternalModelsUser } from '@/types/generated';
import { InternalHandlersAPIResponse } from '@/types/generated';
```
## Notes
- `PaginatedResponse<T>` is a utility type and should be kept (not in OpenAPI spec)
- Some generated types may have different field names (snake_case vs camelCase)
- May need type adapters/mappers for compatibility during migration
- Generated types use longer names - consider creating type aliases
## Validation
After migration:
- ✅ All TypeScript errors resolved
- ✅ All tests pass
- ✅ No runtime errors
- ✅ Type safety maintained
## Rollback Plan
If migration causes issues:
1. Revert imports to manual types
2. Keep generated types directory for reference
3. Fix OpenAPI spec if types are incorrect
4. Regenerate types and retry migration