Commit Graph

122 Commits

Author SHA1 Message Date
Oleg Proskurin 4785d23179 feat: implement Phase 4 image management with upload and CRUD endpoints
Implement complete image management system with file upload, listing, retrieval,
updates, alias assignment, and soft deletion.

**v1 API Routes:**
- `POST /api/v1/images/upload` - Upload single image file with database record
- `GET /api/v1/images` - List images with filters and pagination
- `GET /api/v1/images/:id` - Get single image by ID
- `PUT /api/v1/images/:id` - Update image metadata (alias, focal point, meta)
- `PUT /api/v1/images/:id/alias` - Assign project-scoped alias to image
- `DELETE /api/v1/images/:id` - Soft delete image

**Upload Endpoint Features:**
- Uses uploadSingleImage middleware for file handling
- Creates database record with image metadata
- Stores file in MinIO storage (uploads category)
- Supports optional alias and flowId parameters
- Returns ImageResponse with all metadata

**Route Features:**
- Authentication via validateApiKey middleware
- Project key requirement
- Rate limiting on upload endpoint
- Request validation with pagination
- Error handling with proper status codes
- Response transformation with toImageResponse converter
- Project ownership verification for all operations

**ImageService Integration:**
- Uses existing ImageService methods
- Supports filtering by flowId, source, alias
- Soft delete with deletedAt timestamp
- Alias validation and conflict detection

**Type Updates:**
- Updated ImageFilters with explicit | undefined for optional properties
- All response types already defined in responses.ts

**Technical Notes:**
- Upload creates both storage record and database entry atomically
- Focal point stored as JSON with x/y coordinates
- Meta field for flexible metadata storage
- File hash set to null (TODO: implement hashing)
- All Phase 4 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:41:59 +07:00
Oleg Proskurin 071736c076 feat: add test scripts 2025-11-09 22:27:23 +07:00
Oleg Proskurin 85395084b7 feat: implement Phase 3 flow management with service and endpoints
Implement complete flow management system with CRUD operations, computed counts,
and alias management capabilities for organizing generation chains.

**Core Service:**
- **FlowService**: Complete flow lifecycle management
  - Create flows with initial empty aliases
  - CRUD operations (create, read, update, delete)
  - Computed counts for generations and images per flow
  - Alias management (add, update, remove)
  - Get flow's generations and images with pagination
  - No soft delete (flows use hard delete)

**v1 API Routes:**
- `POST /api/v1/flows` - Create new flow
- `GET /api/v1/flows` - List flows with pagination and counts
- `GET /api/v1/flows/:id` - Get single flow with computed counts
- `GET /api/v1/flows/:id/generations` - List flow's generations
- `GET /api/v1/flows/:id/images` - List flow's images
- `PUT /api/v1/flows/:id/aliases` - Update flow aliases (add/modify)
- `DELETE /api/v1/flows/:id/aliases/:alias` - Remove specific alias
- `DELETE /api/v1/flows/:id` - Delete flow (hard delete)

**Route Features:**
- Authentication via validateApiKey middleware
- Project key requirement
- Request validation with pagination
- Error handling with proper status codes
- Response transformation with toFlowResponse converter
- Project ownership verification for all operations

**Type Updates:**
- Added ListFlowGenerationsResponse and ListFlowImagesResponse
- Updated GetFlowResponse to return FlowResponse (not FlowWithDetailsResponse)
- FlowService methods return FlowWithCounts where appropriate

**Technical Notes:**
- Flows don't have deletedAt column (no soft delete support)
- All count queries filter active generations/images only
- Alias updates are merged with existing aliases
- Empty flows return generationCount: 0, imageCount: 0
- All Phase 3 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:24:40 +07:00
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
Oleg Proskurin c185ea3ff4 feat: add Phase 1 foundation for API v2.0
Implement foundational components for Banatie API v2.0 with dual alias system,
flows support, and comprehensive type safety.

**Type Definitions:**
- Add models.ts with database types (Generation, Image, Flow, etc.)
- Add requests.ts with all v2 API request types
- Add responses.ts with standardized response types and converters
- Support for pagination, filters, and complex relations

**Constants:**
- Define technical aliases (@last, @first, @upload)
- Define reserved aliases and validation patterns
- Add rate limits for master/project keys (2-bucket system)
- Add pagination, image, generation, and flow limits
- Comprehensive error messages and codes

**Validators:**
- aliasValidator: Format validation, reserved alias checking
- paginationValidator: Bounds checking with normalization
- queryValidator: UUID, aspect ratio, focal point, date range validation

**Helpers:**
- paginationBuilder: Standardized pagination response construction
- hashHelper: SHA-256 utilities for caching and file deduplication
- queryHelper: Reusable WHERE clause builders with soft delete support

**Core Services:**
- AliasService: 3-tier alias resolution (technical → flow → project)
  - Technical alias computation (@last, @first, @upload)
  - Flow-scoped alias lookup from JSONB
  - Project-scoped alias lookup with uniqueness
  - Conflict detection and validation
  - Batch resolution support

**Dependencies:**
- Add drizzle-orm to api-service for direct ORM usage

All Phase 1 code is 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 21:53:50 +07:00
Oleg Proskurin df84e400f5 chore: update documentation 2025-11-09 21:24:14 +07:00
Oleg Proskurin 1236dd78e2 Merge branch 'feature/db-for-generation' 2025-11-09 17:50:19 +07:00
Oleg Proskurin 047c924193 fix: update schemes 2025-10-26 23:14:05 +07:00
Oleg Proskurin dbf82d2801 feat: update DB schemas 2025-10-26 23:00:10 +07:00
Oleg Proskurin e88617b430 feat: add documentation 2025-10-26 22:26:02 +07:00
Oleg Proskurin a7dc96d1a5 fix: update config 2025-10-26 19:28:31 +07:00
Oleg Proskurin a397de80e9 fix: upload page 2025-10-26 19:13:48 +07:00
Oleg Proskurin 349abc2071 fix: scroll position 2025-10-26 18:38:44 +07:00
Oleg Proskurin b4e5a05ae6 feat: improve 2025-10-26 18:03:17 +07:00
Oleg Proskurin d6a9cd6990 feat: add page-context 2025-10-26 17:37:23 +07:00
Oleg Proskurin 2f8d239da0 feat: switch to sections 2025-10-26 16:33:18 +07:00
Oleg Proskurin ab85b5e1fa feat: add sections components 2025-10-25 22:01:26 +07:00
Oleg Proskurin f46a8d66d3 Merge branch 'feature/apikey-api' 2025-10-25 20:04:54 +07:00
Oleg Proskurin d7c230fae8 feat: add sub nav to admin section 2025-10-25 20:04:43 +07:00
Oleg Proskurin b9a8ca8368 refactor: switch landing from DB to api requests 2025-10-25 18:58:01 +07:00
Oleg Proskurin d1806bfd7e feat: enhance api key api 2025-10-25 18:57:19 +07:00
Oleg Proskurin f1335fb4d3 Merge branch 'feature/global-apikey-widget' 2025-10-25 18:20:12 +07:00
Oleg Proskurin a4842e2cd4 fix: focus 2025-10-24 23:24:38 +07:00
Oleg Proskurin d5fe272460 fix: styles 2025-10-24 23:08:53 +07:00
Oleg Proskurin 78bff3f2ed fix: mobile position 2025-10-24 22:48:10 +07:00
Oleg Proskurin 7b8c8ec5e8 feat: add mobile widget view 2025-10-23 23:13:50 +07:00
Oleg Proskurin 15eb364ebd fix: widget position 2025-10-23 22:27:51 +07:00
Oleg Proskurin daa8117ce5 add apikey widget 2025-10-23 22:14:06 +07:00
Oleg Proskurin 4caa475f30 feat: start apikey component 2025-10-22 23:01:37 +07:00
Oleg Proskurin 9facc1621c feat: init apikey widget 2025-10-22 22:39:56 +07:00
Oleg Proskurin 36bab4ddaa Merge branch 'feature/documentation-section' 2025-10-22 22:35:22 +07:00
Oleg Proskurin da6887d41c feat: update navbar 2025-10-21 23:31:08 +07:00
Oleg Proskurin f90fd8f65a feat: add DocPage 2025-10-21 22:47:45 +07:00
Oleg Proskurin da33f96c35 feat: improve docs layout 2025-10-21 20:57:51 +07:00
Oleg Proskurin 813e0b186c feat: extract components 2025-10-18 01:14:41 +07:00
Oleg Proskurin 94c8aafe5b chore: sort components folders 2025-10-17 23:45:10 +07:00
Oleg Proskurin a272c8d74f feat: leave final variant 2025-10-17 23:32:20 +07:00
Oleg Proskurin bd46f63ac8 fix: widget 2025-10-16 15:59:02 +07:00
Oleg Proskurin 7368d287e9 feat: update interactive snippet 2025-10-15 00:31:49 +07:00
Oleg Proskurin 658f1420db feat: polish 2025-10-14 01:07:50 +07:00
Oleg Proskurin 1d1a88d073 feat: final variant ready 2025-10-14 00:54:34 +07:00
Oleg Proskurin da47634805 chore: preview variants 2025-10-13 00:19:57 +07:00
Oleg Proskurin b0943606e1 fix: ts issue 2025-10-12 23:01:52 +07:00
Oleg Proskurin 7416c6d441 chore: code cleanup 2025-10-12 22:59:24 +07:00
Oleg Proskurin e0924f9c4b fix: get images endpoint 2025-10-12 22:55:37 +07:00
Oleg Proskurin 3cbb366a9d chore: update docs 2025-10-12 22:19:10 +07:00
Oleg Proskurin 9a9c7260e2 fix: return correct codes 2025-10-12 22:13:34 +07:00
Oleg Proskurin 691e472a2e chore: add todo 2025-10-12 22:05:23 +07:00
Oleg Proskurin 55c8d23c1b feat: update config 2025-10-12 21:49:42 +07:00
Oleg Proskurin dd48d4e1a1 feat: update setup 2025-10-12 21:12:58 +07:00