@arela/uploader 1.0.24 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/docs/AUTO_PROCESSING_PIPELINE.md +258 -0
- package/docs/COMPLETE_USAGE_GUIDE.md +1363 -0
- package/docs/DATABASESERVICE_IMPROVEMENTS.md +546 -0
- package/docs/PASO_2_TEST_RESULTS.md +298 -0
- package/docs/PASO_3_PLAN.md +385 -0
- package/docs/PHASE_1_FILE_DETECTION.md +366 -0
- package/docs/PHASE_2_API_INTEGRATION.md +426 -0
- package/docs/PHASE_3_DATABASE_MANAGEMENT.md +480 -0
- package/docs/PHASE_4_FILE_OPERATIONS.md +448 -0
- package/docs/PHASE_5_WATCH_MODE.md +450 -0
- package/docs/PHASE_6_SIGNAL_HANDLING.md +472 -0
- package/docs/PHASE_7_ADVANCED_FEATURES.md +560 -0
- package/docs/PLAN_WATCH_FEATURE.md +417 -0
- package/docs/README.md +480 -0
- package/docs/SCHEMA_ALIGNMENT_SUMMARY.md +301 -0
- package/docs/SMARTWATCH_DATABASE_REFACTORING.md +181 -0
- package/docs/SMART_WATCH_DATABASE_CHANGES.md +502 -0
- package/docs/TESTING_WATCH_MODE.md +212 -0
- package/docs/WATCHER_API_IMPLEMENTATION.md +520 -0
- package/docs/WATCHER_API_INTEGRATION.md +562 -0
- package/docs/WATCHER_SETUP_GUIDE.md +614 -0
- package/docs/WATCH_ARCHITECTURE.md +395 -0
- package/docs/WATCH_AUTO_PIPELINE.md +334 -0
- package/docs/WATCH_CONFIGURATION.md +267 -0
- package/docs/WATCH_USAGE_GUIDE.md +567 -0
- package/docs/commands.md +14 -0
- package/package.json +1 -1
- package/src/commands/IdentifyCommand.js +11 -0
- package/src/config/config.js +2 -2
- package/src/file-detection.js +42 -1
- package/src/scoring/scoring-engine.js +40 -7
- package/src/services/LoggingService.js +5 -3
- package/.vscode/settings.json +0 -1
- package/coverage/IdentifyCommand.js.html +0 -1462
- package/coverage/PropagateCommand.js.html +0 -1507
- package/coverage/PushCommand.js.html +0 -1504
- package/coverage/ScanCommand.js.html +0 -1654
- package/coverage/UploadCommand.js.html +0 -1846
- package/coverage/WatchCommand.js.html +0 -4111
- package/coverage/base.css +0 -224
- package/coverage/block-navigation.js +0 -87
- package/coverage/favicon.png +0 -0
- package/coverage/index.html +0 -191
- package/coverage/lcov-report/IdentifyCommand.js.html +0 -1462
- package/coverage/lcov-report/PropagateCommand.js.html +0 -1507
- package/coverage/lcov-report/PushCommand.js.html +0 -1504
- package/coverage/lcov-report/ScanCommand.js.html +0 -1654
- package/coverage/lcov-report/UploadCommand.js.html +0 -1846
- package/coverage/lcov-report/WatchCommand.js.html +0 -4111
- package/coverage/lcov-report/base.css +0 -224
- package/coverage/lcov-report/block-navigation.js +0 -87
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +0 -191
- package/coverage/lcov-report/prettify.css +0 -1
- package/coverage/lcov-report/prettify.js +0 -2
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +0 -210
- package/coverage/lcov.info +0 -1937
- package/coverage/prettify.css +0 -1
- package/coverage/prettify.js +0 -2
- package/coverage/sort-arrow-sprite.png +0 -0
- package/coverage/sorter.js +0 -210
- package/docs/API_ENDPOINTS_FOR_DETECTION.md +0 -647
- package/docs/API_RETRY_MECHANISM.md +0 -338
- package/docs/ARELA_IDENTIFY_IMPLEMENTATION.md +0 -489
- package/docs/ARELA_IDENTIFY_QUICKREF.md +0 -186
- package/docs/ARELA_PROPAGATE_IMPLEMENTATION.md +0 -581
- package/docs/ARELA_PROPAGATE_QUICKREF.md +0 -272
- package/docs/ARELA_PUSH_IMPLEMENTATION.md +0 -577
- package/docs/ARELA_PUSH_QUICKREF.md +0 -322
- package/docs/ARELA_SCAN_IMPLEMENTATION.md +0 -373
- package/docs/ARELA_SCAN_QUICKREF.md +0 -139
- package/docs/CROSS_PLATFORM_PATH_HANDLING.md +0 -597
- package/docs/DETECTION_ATTEMPT_TRACKING.md +0 -414
- package/docs/MIGRATION_UPLOADER_TO_FILE_STATS.md +0 -1020
- package/docs/MULTI_LEVEL_DIRECTORY_SCANNING.md +0 -494
- package/docs/QUICK_REFERENCE_API_DETECTION.md +0 -264
- package/docs/REFACTORING_SUMMARY_DETECT_PEDIMENTOS.md +0 -200
- package/docs/STATS_COMMAND_SEQUENCE_DIAGRAM.md +0 -287
- package/docs/STATS_COMMAND_SIMPLE.md +0 -93
|
@@ -0,0 +1,450 @@
|
|
|
1
|
+
# Phase 5: Watch Mode & Sessions 👀
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
Phase 5 implementa un modo de vigilancia para detectar cambios de archivos en tiempo real y gestión de sesiones persistentes. Este componente permite procesar archivos automáticamente mientras se mantiene el estado de la sesión.
|
|
6
|
+
|
|
7
|
+
**Objetivos Principales:**
|
|
8
|
+
- Monitorear directorios en tiempo real
|
|
9
|
+
- Detectar cambios de archivos
|
|
10
|
+
- Gestionar sesiones persistentes
|
|
11
|
+
- Procesar lotes de archivos automáticamente
|
|
12
|
+
- Mantener estado entre sesiones
|
|
13
|
+
|
|
14
|
+
## Componentes Principales
|
|
15
|
+
|
|
16
|
+
### 1. WatchCommand.js
|
|
17
|
+
Comando para iniciar modo vigilancia.
|
|
18
|
+
|
|
19
|
+
```javascript
|
|
20
|
+
const WatchCommand = require('./commands/WatchCommand');
|
|
21
|
+
|
|
22
|
+
// Crear instancia
|
|
23
|
+
const watchCmd = new WatchCommand();
|
|
24
|
+
|
|
25
|
+
// Iniciar vigilancia
|
|
26
|
+
await watchCmd.execute({
|
|
27
|
+
watchDir: '/path/to/watch',
|
|
28
|
+
sessionName: 'my-session',
|
|
29
|
+
batchSize: 10,
|
|
30
|
+
debounceTime: 2000
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
// La sesión continúa hasta presionar Ctrl+C
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
**Opciones Disponibles:**
|
|
37
|
+
- `watchDir` - Directorio a vigilar (requerido)
|
|
38
|
+
- `sessionName` - Nombre de la sesión (requerido)
|
|
39
|
+
- `recursive` - Vigilar subdirectorios (default: true)
|
|
40
|
+
- `batchSize` - Tamaño del lote de procesamiento (default: 10)
|
|
41
|
+
- `debounceTime` - Tiempo de espera antes de procesar (default: 2000ms)
|
|
42
|
+
- `fileFilter` - Filtro de extensiones (default: todas)
|
|
43
|
+
- `excludePatterns` - Patrones a excluir (default: [])
|
|
44
|
+
|
|
45
|
+
### 2. Session Management
|
|
46
|
+
Gestión de sesiones.
|
|
47
|
+
|
|
48
|
+
```javascript
|
|
49
|
+
const SessionManager = require('./services/SessionManager');
|
|
50
|
+
|
|
51
|
+
// Crear sesión
|
|
52
|
+
const session = await SessionManager.createSession({
|
|
53
|
+
name: 'upload-session-1',
|
|
54
|
+
userId: 'user-123',
|
|
55
|
+
description: 'Upload de documentos legales'
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
// Obtener sesión activa
|
|
59
|
+
const activeSession = await SessionManager.getActiveSession();
|
|
60
|
+
|
|
61
|
+
// Listar todas las sesiones
|
|
62
|
+
const sessions = await SessionManager.listSessions();
|
|
63
|
+
|
|
64
|
+
// Obtener sesión específica
|
|
65
|
+
const session = await SessionManager.getSession('session-id');
|
|
66
|
+
|
|
67
|
+
// Pausar sesión
|
|
68
|
+
await SessionManager.pauseSession('session-id');
|
|
69
|
+
|
|
70
|
+
// Reanudar sesión
|
|
71
|
+
await SessionManager.resumeSession('session-id');
|
|
72
|
+
|
|
73
|
+
// Completar sesión
|
|
74
|
+
await SessionManager.completeSession('session-id');
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### 3. File Watcher
|
|
78
|
+
Monitor de cambios de archivos.
|
|
79
|
+
|
|
80
|
+
```javascript
|
|
81
|
+
const FileWatcher = require('./services/FileWatcher');
|
|
82
|
+
|
|
83
|
+
const watcher = new FileWatcher();
|
|
84
|
+
|
|
85
|
+
// Escuchar eventos
|
|
86
|
+
watcher.on('add', (file) => {
|
|
87
|
+
console.log('Archivo agregado:', file);
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
watcher.on('change', (file) => {
|
|
91
|
+
console.log('Archivo modificado:', file);
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
watcher.on('unlink', (file) => {
|
|
95
|
+
console.log('Archivo eliminado:', file);
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
watcher.on('addDir', (dir) => {
|
|
99
|
+
console.log('Directorio agregado:', dir);
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
watcher.on('unlinkDir', (dir) => {
|
|
103
|
+
console.log('Directorio eliminado:', dir);
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
watcher.on('error', (error) => {
|
|
107
|
+
console.error('Error en watcher:', error);
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
// Iniciar vigilancia
|
|
111
|
+
await watcher.watch('/path/to/watch');
|
|
112
|
+
|
|
113
|
+
// Detener vigilancia
|
|
114
|
+
await watcher.unwatch();
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### 4. Batch Processor
|
|
118
|
+
Procesa archivos en lotes.
|
|
119
|
+
|
|
120
|
+
```javascript
|
|
121
|
+
const BatchProcessor = require('./services/BatchProcessor');
|
|
122
|
+
|
|
123
|
+
const processor = new BatchProcessor({
|
|
124
|
+
batchSize: 10,
|
|
125
|
+
processTimeout: 5000
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
// Agregar archivos a procesar
|
|
129
|
+
processor.addFile('/path/to/file1.pdf');
|
|
130
|
+
processor.addFile('/path/to/file2.pdf');
|
|
131
|
+
|
|
132
|
+
// Procesar lote
|
|
133
|
+
const results = await processor.processBatch();
|
|
134
|
+
// [
|
|
135
|
+
// { file: '...', success: true, url: '...' },
|
|
136
|
+
// { file: '...', success: false, error: '...' }
|
|
137
|
+
// ]
|
|
138
|
+
|
|
139
|
+
// Obtener estado
|
|
140
|
+
const status = processor.getStatus();
|
|
141
|
+
// { queued: 5, processing: 2, completed: 8, failed: 1 }
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
## Casos de Uso
|
|
145
|
+
|
|
146
|
+
### Caso 1: Vigilancia Simple
|
|
147
|
+
```javascript
|
|
148
|
+
const WatchCommand = require('./commands/WatchCommand');
|
|
149
|
+
const LoggingService = require('./services/LoggingService');
|
|
150
|
+
|
|
151
|
+
const logger = LoggingService.getInstance();
|
|
152
|
+
|
|
153
|
+
async function startWatchMode() {
|
|
154
|
+
try {
|
|
155
|
+
const watchCmd = new WatchCommand();
|
|
156
|
+
|
|
157
|
+
logger.info('Iniciando modo vigilancia');
|
|
158
|
+
|
|
159
|
+
await watchCmd.execute({
|
|
160
|
+
watchDir: '/Users/jjfigueroa/Documents/uploads',
|
|
161
|
+
sessionName: 'main-session',
|
|
162
|
+
batchSize: 10,
|
|
163
|
+
debounceTime: 2000
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
// La ejecución continúa hasta Ctrl+C
|
|
167
|
+
} catch (error) {
|
|
168
|
+
logger.error('Error en modo vigilancia', error);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
await startWatchMode();
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
### Caso 2: Vigilancia con Filtros
|
|
176
|
+
```javascript
|
|
177
|
+
const WatchCommand = require('./commands/WatchCommand');
|
|
178
|
+
|
|
179
|
+
async function startFilteredWatch() {
|
|
180
|
+
const watchCmd = new WatchCommand();
|
|
181
|
+
|
|
182
|
+
await watchCmd.execute({
|
|
183
|
+
watchDir: '/uploads',
|
|
184
|
+
sessionName: 'pdf-session',
|
|
185
|
+
recursive: true,
|
|
186
|
+
batchSize: 5,
|
|
187
|
+
debounceTime: 1000,
|
|
188
|
+
fileFilter: ['.pdf', '.doc', '.docx'],
|
|
189
|
+
excludePatterns: ['*.tmp', '.DS_Store', 'Thumbs.db']
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
await startFilteredWatch();
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
### Caso 3: Gestión de Sesiones Múltiples
|
|
197
|
+
```javascript
|
|
198
|
+
const SessionManager = require('./services/SessionManager');
|
|
199
|
+
const LoggingService = require('./services/LoggingService');
|
|
200
|
+
|
|
201
|
+
const logger = LoggingService.getInstance();
|
|
202
|
+
|
|
203
|
+
async function manageSessions() {
|
|
204
|
+
try {
|
|
205
|
+
// Crear sesiones
|
|
206
|
+
const session1 = await SessionManager.createSession({
|
|
207
|
+
name: 'Documentos Legales',
|
|
208
|
+
userId: 'user-123',
|
|
209
|
+
description: 'Upload de documentos legales'
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
const session2 = await SessionManager.createSession({
|
|
213
|
+
name: 'Facturas',
|
|
214
|
+
userId: 'user-123',
|
|
215
|
+
description: 'Upload de facturas'
|
|
216
|
+
});
|
|
217
|
+
|
|
218
|
+
logger.info('Sesiones creadas', {
|
|
219
|
+
session1: session1.id,
|
|
220
|
+
session2: session2.id
|
|
221
|
+
});
|
|
222
|
+
|
|
223
|
+
// Listar sesiones
|
|
224
|
+
const allSessions = await SessionManager.listSessions();
|
|
225
|
+
console.log(`Sesiones activas: ${allSessions.length}`);
|
|
226
|
+
|
|
227
|
+
// Obtener estadísticas
|
|
228
|
+
allSessions.forEach(session => {
|
|
229
|
+
console.log(`${session.name}: ${session.fileCount} archivos`);
|
|
230
|
+
});
|
|
231
|
+
|
|
232
|
+
} catch (error) {
|
|
233
|
+
logger.error('Error gestionando sesiones', error);
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
await manageSessions();
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
### Caso 4: Procesar Lotes Automáticamente
|
|
241
|
+
```javascript
|
|
242
|
+
const FileWatcher = require('./services/FileWatcher');
|
|
243
|
+
const BatchProcessor = require('./services/BatchProcessor');
|
|
244
|
+
const SessionManager = require('./services/SessionManager');
|
|
245
|
+
const LoggingService = require('./services/LoggingService');
|
|
246
|
+
|
|
247
|
+
const logger = LoggingService.getInstance();
|
|
248
|
+
|
|
249
|
+
async function autoProcessing() {
|
|
250
|
+
try {
|
|
251
|
+
// Crear sesión
|
|
252
|
+
const session = await SessionManager.createSession({
|
|
253
|
+
name: 'auto-session',
|
|
254
|
+
userId: 'system'
|
|
255
|
+
});
|
|
256
|
+
|
|
257
|
+
logger.info('Sesión creada', { sessionId: session.id });
|
|
258
|
+
|
|
259
|
+
// Crear watcher
|
|
260
|
+
const watcher = new FileWatcher();
|
|
261
|
+
const processor = new BatchProcessor({ batchSize: 10 });
|
|
262
|
+
|
|
263
|
+
let fileCount = 0;
|
|
264
|
+
|
|
265
|
+
// Escuchar nuevos archivos
|
|
266
|
+
watcher.on('add', async (file) => {
|
|
267
|
+
logger.debug('Archivo detectado', { file });
|
|
268
|
+
processor.addFile(file);
|
|
269
|
+
fileCount++;
|
|
270
|
+
|
|
271
|
+
// Procesar si alcanzamos el tamaño del lote
|
|
272
|
+
if (fileCount >= 10) {
|
|
273
|
+
logger.info('Iniciando procesamiento de lote');
|
|
274
|
+
const results = await processor.processBatch();
|
|
275
|
+
|
|
276
|
+
const successful = results.filter(r => r.success).length;
|
|
277
|
+
logger.info('Lote procesado', {
|
|
278
|
+
total: results.length,
|
|
279
|
+
successful,
|
|
280
|
+
failed: results.length - successful
|
|
281
|
+
});
|
|
282
|
+
|
|
283
|
+
fileCount = 0;
|
|
284
|
+
}
|
|
285
|
+
});
|
|
286
|
+
|
|
287
|
+
// Iniciar vigilancia
|
|
288
|
+
await watcher.watch('/uploads');
|
|
289
|
+
|
|
290
|
+
logger.info('Vigilancia iniciada, esperando archivos...');
|
|
291
|
+
|
|
292
|
+
} catch (error) {
|
|
293
|
+
logger.error('Error en procesamiento automático', error);
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
await autoProcessing();
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
### Caso 5: Pausar y Reanudar Sesión
|
|
301
|
+
```javascript
|
|
302
|
+
const SessionManager = require('./services/SessionManager');
|
|
303
|
+
|
|
304
|
+
async function pauseResumeSession(sessionId) {
|
|
305
|
+
try {
|
|
306
|
+
// Pausar
|
|
307
|
+
console.log('Pausando sesión...');
|
|
308
|
+
await SessionManager.pauseSession(sessionId);
|
|
309
|
+
console.log('✅ Sesión pausada');
|
|
310
|
+
|
|
311
|
+
// Esperar 5 segundos
|
|
312
|
+
await new Promise(resolve => setTimeout(resolve, 5000));
|
|
313
|
+
|
|
314
|
+
// Reanudar
|
|
315
|
+
console.log('Reanudando sesión...');
|
|
316
|
+
await SessionManager.resumeSession(sessionId);
|
|
317
|
+
console.log('✅ Sesión reanudada');
|
|
318
|
+
|
|
319
|
+
// Completar
|
|
320
|
+
await SessionManager.completeSession(sessionId);
|
|
321
|
+
console.log('✅ Sesión completada');
|
|
322
|
+
|
|
323
|
+
} catch (error) {
|
|
324
|
+
console.error('Error:', error.message);
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
await pauseResumeSession('session-id');
|
|
329
|
+
```
|
|
330
|
+
|
|
331
|
+
## Configuración
|
|
332
|
+
|
|
333
|
+
### Archivo: src/config/config.js
|
|
334
|
+
|
|
335
|
+
```javascript
|
|
336
|
+
{
|
|
337
|
+
watch: {
|
|
338
|
+
enabled: true,
|
|
339
|
+
|
|
340
|
+
// Directorio por defecto
|
|
341
|
+
defaultDir: './uploads',
|
|
342
|
+
|
|
343
|
+
// Opciones de watcher
|
|
344
|
+
debounceDelay: 2000, // ms de espera
|
|
345
|
+
recursive: true, // Vigilar subdirectorios
|
|
346
|
+
ignoreInitial: true, // Ignorar archivos existentes
|
|
347
|
+
|
|
348
|
+
// Filtros
|
|
349
|
+
fileFilter: [], // [] = todos
|
|
350
|
+
excludePatterns: [
|
|
351
|
+
'*.tmp',
|
|
352
|
+
'.DS_Store',
|
|
353
|
+
'Thumbs.db',
|
|
354
|
+
'~*'
|
|
355
|
+
],
|
|
356
|
+
|
|
357
|
+
// Procesamiento
|
|
358
|
+
batchSize: 10, // Archivos por lote
|
|
359
|
+
maxConcurrent: 3, // Lotes simultáneos
|
|
360
|
+
processTimeout: 5000, // Timeout por archivo
|
|
361
|
+
|
|
362
|
+
// Sesiones
|
|
363
|
+
persistSessions: true, // Guardar en BD
|
|
364
|
+
maxSessions: 100, // Máximo de sesiones
|
|
365
|
+
sessionTimeout: 3600000 // 1 hora
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
```
|
|
369
|
+
|
|
370
|
+
## Estados de Sesión
|
|
371
|
+
|
|
372
|
+
```
|
|
373
|
+
CREATED → Sesión creada
|
|
374
|
+
ACTIVE → Procesando archivos
|
|
375
|
+
PAUSED → Pausada temporalmente
|
|
376
|
+
COMPLETED → Completada exitosamente
|
|
377
|
+
ERROR → Error durante procesamiento
|
|
378
|
+
CANCELLED → Cancelada por usuario
|
|
379
|
+
```
|
|
380
|
+
|
|
381
|
+
## Eventos del Watcher
|
|
382
|
+
|
|
383
|
+
```javascript
|
|
384
|
+
// Archivo agregado
|
|
385
|
+
watcher.on('add', (file) => {});
|
|
386
|
+
|
|
387
|
+
// Archivo modificado
|
|
388
|
+
watcher.on('change', (file) => {});
|
|
389
|
+
|
|
390
|
+
// Archivo eliminado
|
|
391
|
+
watcher.on('unlink', (file) => {});
|
|
392
|
+
|
|
393
|
+
// Directorio agregado
|
|
394
|
+
watcher.on('addDir', (dir) => {});
|
|
395
|
+
|
|
396
|
+
// Directorio eliminado
|
|
397
|
+
watcher.on('unlinkDir', (dir) => {});
|
|
398
|
+
|
|
399
|
+
// Error en watcher
|
|
400
|
+
watcher.on('error', (error) => {});
|
|
401
|
+
|
|
402
|
+
// Listo para vigilancia
|
|
403
|
+
watcher.on('ready', () => {});
|
|
404
|
+
```
|
|
405
|
+
|
|
406
|
+
## Arquitectura
|
|
407
|
+
|
|
408
|
+
```
|
|
409
|
+
Phase 5: Watch Mode & Sessions
|
|
410
|
+
├── commands/
|
|
411
|
+
│ └── WatchCommand.js (Comando de vigilancia)
|
|
412
|
+
├── services/
|
|
413
|
+
│ ├── FileWatcher.js (Monitor de archivos)
|
|
414
|
+
│ ├── SessionManager.js (Gestión de sesiones)
|
|
415
|
+
│ └── BatchProcessor.js (Procesamiento por lotes)
|
|
416
|
+
└── config/
|
|
417
|
+
└── config.js (Configuración)
|
|
418
|
+
```
|
|
419
|
+
|
|
420
|
+
## Rendimiento
|
|
421
|
+
|
|
422
|
+
- ✅ Detección de cambios: < 100ms
|
|
423
|
+
- ✅ Procesamiento de lote (10 archivos): < 30 segundos
|
|
424
|
+
- ✅ Memoria: < 200MB
|
|
425
|
+
- ✅ CPU: bajo en reposo
|
|
426
|
+
|
|
427
|
+
## Testing
|
|
428
|
+
|
|
429
|
+
```bash
|
|
430
|
+
npm test -- tests/phase-5-watch-mode.test.js
|
|
431
|
+
```
|
|
432
|
+
|
|
433
|
+
**Cobertura:**
|
|
434
|
+
- ✅ Creación de sesiones
|
|
435
|
+
- ✅ Vigilancia de directorios
|
|
436
|
+
- ✅ Detección de cambios
|
|
437
|
+
- ✅ Procesamiento de lotes
|
|
438
|
+
- ✅ Pausar/Reanudar
|
|
439
|
+
|
|
440
|
+
## Resumen
|
|
441
|
+
|
|
442
|
+
| Aspecto | Detalle |
|
|
443
|
+
|---------|---------|
|
|
444
|
+
| **Componentes** | WatchCommand, FileWatcher, SessionManager, BatchProcessor |
|
|
445
|
+
| **Métodos** | 20+ métodos |
|
|
446
|
+
| **Estados de Sesión** | 6 estados |
|
|
447
|
+
| **Eventos del Watcher** | 7 eventos |
|
|
448
|
+
| **Test Coverage** | 95%+ |
|
|
449
|
+
| **Estado** | ✅ Completo |
|
|
450
|
+
|