feat: add UI components for alert dialog, badge, checkbox, dialog, label, select, sheet, table, textarea
- Implemented AlertDialog component with overlay, content, header, footer, title, description, action, and cancel functionalities. - Created Badge component with variant support for different styles. - Developed Checkbox component with custom styling and indicator. - Added Dialog component with trigger, close, overlay, content, header, footer, title, and description. - Introduced Label component for form elements. - Built Select component with trigger, content, group, item, label, separator, and scroll buttons. - Created Sheet component with trigger, close, overlay, content, header, footer, title, and description. - Implemented Table component with header, body, footer, row, head, cell, and caption. - Added Textarea component with custom styling. - Established API service for game management with CRUD operations and metadata search functionalities. - Updated dependencies in package lock files.
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
/**
|
||||
* Servicio: importService
|
||||
*
|
||||
* Orquesta el proceso de importación de ROMs desde un directorio:
|
||||
* Orquesta el proceso de importación de juegos desde un directorio:
|
||||
* 1. Lista archivos usando `scanDirectory`.
|
||||
* 2. Calcula hashes y tamaño con `computeHashes` (streaming).
|
||||
* 3. Normaliza el nombre a un `slug` y, si `persist` es true, crea/obtiene
|
||||
* el `Game` correspondiente y hace `upsert` del `RomFile` en Prisma.
|
||||
* el `Game` correspondiente con source="rom".
|
||||
*
|
||||
* `importDirectory` devuelve un resumen con contadores `{ processed, createdCount, upserted }`.
|
||||
*/
|
||||
@@ -89,31 +89,44 @@ export async function importDirectory(
|
||||
const baseName = path.parse(file.filename).name;
|
||||
const slug = createSlug(baseName);
|
||||
|
||||
let game = null;
|
||||
|
||||
if (persist) {
|
||||
game = await prisma.game.findUnique({ where: { slug } });
|
||||
|
||||
if (!game) {
|
||||
game = await prisma.game.create({ data: { title: baseName, slug } });
|
||||
createdCount++;
|
||||
}
|
||||
|
||||
await prisma.romFile.upsert({
|
||||
where: { checksum },
|
||||
update: { lastSeenAt: new Date(), size, hashes: JSON.stringify(hashes) },
|
||||
create: {
|
||||
path: file.path,
|
||||
filename: file.filename,
|
||||
checksum,
|
||||
size,
|
||||
format: file.format,
|
||||
hashes: JSON.stringify(hashes),
|
||||
gameId: game?.id,
|
||||
// Buscar si ya existe un juego con este checksum (source=rom)
|
||||
let game = await prisma.game.findFirst({
|
||||
where: {
|
||||
source: 'rom',
|
||||
romChecksum: checksum,
|
||||
},
|
||||
});
|
||||
|
||||
upserted++;
|
||||
if (!game) {
|
||||
// Crear nuevo juego con source="rom"
|
||||
game = await prisma.game.create({
|
||||
data: {
|
||||
title: baseName,
|
||||
slug: `${slug}-${Date.now()}`,
|
||||
source: 'rom',
|
||||
romPath: file.path,
|
||||
romFilename: file.filename,
|
||||
romSize: size,
|
||||
romChecksum: checksum,
|
||||
romFormat: file.format,
|
||||
romHashes: JSON.stringify(hashes),
|
||||
addedAt: new Date(),
|
||||
lastSeenAt: new Date(),
|
||||
},
|
||||
});
|
||||
createdCount++;
|
||||
} else {
|
||||
// Actualizar lastSeenAt si ya existe
|
||||
game = await prisma.game.update({
|
||||
where: { id: game.id },
|
||||
data: {
|
||||
lastSeenAt: new Date(),
|
||||
romHashes: JSON.stringify(hashes),
|
||||
},
|
||||
});
|
||||
upserted++;
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
logger.warn?.(
|
||||
|
||||
Reference in New Issue
Block a user