banatie-service/apps/api-service
Oleg Proskurin 2c67dad9c2 feat: implement Phase 2 core generation flow with services and endpoints
Implement the complete image generation lifecycle with ImageService, GenerationService,
and v1 API endpoints. This enables end-to-end generation with alias support and flow management.

**Core Services:**
- **ImageService**: Full CRUD for images table
  - Create/read/update/delete operations
  - Soft delete support with deletedAt
  - Project and flow alias assignment
  - Storage key and file hash tracking
  - Pagination and filtering

- **GenerationService**: Complete generation lifecycle orchestration
  - Create generation records with pending status
  - Resolve reference images via AliasService
  - Call ImageGenService for AI generation
  - Create image records in database
  - Link images to generations
  - Update generation status (processing → success/failed)
  - Support for flow association and alias assignment
  - Retry failed generations
  - Soft/hard delete operations

**v1 API Routes:**
- `POST /api/v1/generations` - Create with references & aliases
- `GET /api/v1/generations` - List with filters & pagination
- `GET /api/v1/generations/:id` - Get with full relations
- `POST /api/v1/generations/:id/retry` - Retry failed generation
- `DELETE /api/v1/generations/:id` - Delete generation & output

**Route Features:**
- Authentication via validateApiKey middleware
- Project key requirement
- Rate limiting per API key
- Request validation with pagination
- Error handling with proper status codes
- Response transformation with type converters

**Type Updates:**
- Add explicit undefined to optional properties for exactOptionalPropertyTypes
- CreateGenerationParams interface for service layer
- GenerationFilters with proper optionals

**Infrastructure:**
- Mount v1Router at /api/v1 in app.ts
- Keep legacy routes for backward compatibility
- Versioned API structure for future iterations

**Technical Notes:**
- Reference image download temporarily skipped (TODO: storage key parsing)
- File hash computation temporarily disabled (TODO: helper method)
- File size set to 0 (TODO: get from storage)
- All Phase 2 code is fully type-safe with zero TypeScript errors

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-09 22:14:49 +07:00
..
_tests chore: update docs 2025-10-12 22:19:10 +07:00
src feat: implement Phase 2 core generation flow with services and endpoints 2025-11-09 22:14:49 +07:00
.env feat: update setup 2025-10-12 21:12:58 +07:00
.prettier.config.js chore: prettier 2025-10-09 23:16:42 +07:00
Dockerfile feat: update setup 2025-10-12 21:12:58 +07:00
NETWORK_ERROR_DETECTION.md feat: detect network issues 2025-10-10 00:17:29 +07:00
docker-compose.yml feat: update config 2025-10-12 21:49:42 +07:00
eslint.config.js chore: prettier 2025-10-09 23:16:42 +07:00
package.json feat: add Phase 1 foundation for API v2.0 2025-11-09 21:53:50 +07:00
secrets.env.example feat: update setup 2025-10-12 21:12:58 +07:00
test-network-error-detector.ts feat: detect network issues 2025-10-10 00:17:29 +07:00
tsconfig.json chore: prettier 2025-10-09 23:16:42 +07:00