feature/api-development #1

Merged
usulpro merged 47 commits from feature/api-development into main 2025-11-29 23:03:01 +07:00
1 changed files with 26 additions and 2 deletions
Showing only changes of commit bbc007bccd - Show all commits

View File

@ -10,6 +10,7 @@ import type {
import { ImageService } from './ImageService';
import { AliasService } from './AliasService';
import { ImageGenService } from '../ImageGenService';
import { StorageFactory } from '../StorageFactory';
import { buildWhereClause, buildEqCondition } from '@/utils/helpers';
import { ERROR_MESSAGES, GENERATION_LIMITS } from '@/utils/constants';
import type { ReferenceImage } from '@/types/api';
@ -170,13 +171,36 @@ export class GenerationService {
const buffers: ReferenceImage[] = [];
const metadata: Array<{ imageId: string; alias: string }> = [];
// TODO: Implement proper storage key parsing and download
// For now, we'll skip reference image buffers and just store metadata
const storageService = await StorageFactory.getInstance();
for (const [alias, resolution] of resolutions) {
if (!resolution.image) {
throw new Error(`${ERROR_MESSAGES.ALIAS_NOT_FOUND}: ${alias}`);
}
const parts = resolution.image.storageKey.split('/');
if (parts.length < 4) {
throw new Error(`Invalid storage key format: ${resolution.image.storageKey}`);
}
const orgId = parts[0]!;
const projId = parts[1]!;
const category = parts[2]! as 'uploads' | 'generated' | 'references';
const filename = parts.slice(3).join('/');
const buffer = await storageService.downloadFile(
orgId,
projId,
category,
filename
);
buffers.push({
buffer,
mimetype: resolution.image.mimeType,
originalname: filename,
});
metadata.push({
imageId: resolution.imageId,
alias,