@arela/uploader 0.2.13 → 1.0.0

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.
Files changed (43) hide show
  1. package/.env.template +66 -0
  2. package/README.md +263 -62
  3. package/docs/API_ENDPOINTS_FOR_DETECTION.md +647 -0
  4. package/docs/QUICK_REFERENCE_API_DETECTION.md +264 -0
  5. package/docs/REFACTORING_SUMMARY_DETECT_PEDIMENTOS.md +200 -0
  6. package/package.json +3 -2
  7. package/scripts/cleanup-ds-store.js +109 -0
  8. package/scripts/cleanup-system-files.js +69 -0
  9. package/scripts/tests/phase-7-features.test.js +415 -0
  10. package/scripts/tests/signal-handling.test.js +275 -0
  11. package/scripts/tests/smart-watch-integration.test.js +554 -0
  12. package/scripts/tests/watch-service-integration.test.js +584 -0
  13. package/src/commands/UploadCommand.js +31 -4
  14. package/src/commands/WatchCommand.js +1342 -0
  15. package/src/config/config.js +270 -2
  16. package/src/document-type-shared.js +2 -0
  17. package/src/document-types/support-document.js +200 -0
  18. package/src/file-detection.js +9 -1
  19. package/src/index.js +163 -4
  20. package/src/services/AdvancedFilterService.js +505 -0
  21. package/src/services/AutoProcessingService.js +749 -0
  22. package/src/services/BenchmarkingService.js +381 -0
  23. package/src/services/DatabaseService.js +1019 -539
  24. package/src/services/ErrorMonitor.js +275 -0
  25. package/src/services/LoggingService.js +419 -1
  26. package/src/services/MonitoringService.js +401 -0
  27. package/src/services/PerformanceOptimizer.js +511 -0
  28. package/src/services/ReportingService.js +511 -0
  29. package/src/services/SignalHandler.js +255 -0
  30. package/src/services/SmartWatchDatabaseService.js +527 -0
  31. package/src/services/WatchService.js +783 -0
  32. package/src/services/upload/ApiUploadService.js +447 -3
  33. package/src/services/upload/MultiApiUploadService.js +233 -0
  34. package/src/services/upload/SupabaseUploadService.js +12 -5
  35. package/src/services/upload/UploadServiceFactory.js +24 -0
  36. package/src/utils/CleanupManager.js +262 -0
  37. package/src/utils/FileOperations.js +44 -0
  38. package/src/utils/WatchEventHandler.js +522 -0
  39. package/supabase/migrations/001_create_initial_schema.sql +366 -0
  40. package/supabase/migrations/002_align_with_arela_api_schema.sql +145 -0
  41. package/.envbackup +0 -37
  42. package/SUPABASE_UPLOAD_FIX.md +0 -157
  43. package/commands.md +0 -14
package/.env.template CHANGED
@@ -63,6 +63,72 @@ MAX_CONCURRENT_SOURCES=2
63
63
  # MAX_CONCURRENT_SOURCES=1
64
64
  # BATCH_DELAY=100
65
65
 
66
+ # =============================================================================
67
+ # WATCH MODE CONFIGURATION
68
+ # =============================================================================
69
+
70
+ # Habilitar watch mode (true/false)
71
+ WATCH_ENABLED=false
72
+
73
+ # Configuración de directorios a observar (formato JSON)
74
+ # Cada directorio puede tener su propia folderStructure para organizar en el bucket
75
+ # Formato: {"ruta/directorio1":"estructura-1","ruta/directorio2":"estructura-2"}
76
+ #
77
+ # IMPORTANTE: El folderStructure se usa en el comando:
78
+ # upload --upload-by-rfc --folder-structure <estructura>
79
+ #
80
+ # Ejemplo:
81
+ WATCH_DIRECTORY_CONFIGS={"../../Documents/2022":"estructura-2022","../../Documents/2023":"estructura-2023"}
82
+
83
+ # DEPRECATED: Configuración antigua (se mantiene para compatibilidad hacia atrás)
84
+ # WATCH_DIRECTORIES=/ruta/carpeta1,/ruta/carpeta2
85
+
86
+ # Estrategia de upload (opciones: individual|batch|full-structure)
87
+ # - individual: Sube solo el archivo modificado más reciente
88
+ # - batch: Sube un lote de N archivos recientes
89
+ # - full-structure: Sube la estructura completa de carpetas
90
+ WATCH_STRATEGY=batch
91
+
92
+ # Debouncing en milisegundos (esperar entre eventos antes de procesar)
93
+ WATCH_DEBOUNCE_MS=1000
94
+
95
+ # Tamaño de batch para strategy batch
96
+ WATCH_BATCH_SIZE=10
97
+
98
+ # Usar polling en lugar de eventos nativos del filesystem
99
+ # Útil para sistemas de archivos remotos o NFS
100
+ WATCH_USE_POLLING=false
101
+
102
+ # Interval de polling en milisegundos (solo si WATCH_USE_POLLING=true)
103
+ WATCH_POLL_INTERVAL=100
104
+
105
+ # Umbral de estabilidad en ms (esperar a que el archivo deje de cambiar)
106
+ WATCH_STABILITY_THRESHOLD=300
107
+
108
+ # Patrones a ignorar (separados por coma, se usan como regex)
109
+ WATCH_IGNORE_PATTERNS=*.tmp,*.bak,*.swp
110
+
111
+ # Detección automática de tipos de documento
112
+ WATCH_AUTO_DETECT=false
113
+
114
+ # Organización automática de archivos
115
+ WATCH_AUTO_ORGANIZE=false
116
+
117
+ # =============================================================================
118
+ # WATCH MODE - AUTOMATIC PROCESSING PIPELINE
119
+ # =============================================================================
120
+ #
121
+ # El pipeline automático ejecuta la siguiente secuencia cuando se detecta un archivo nuevo:
122
+ # 1. Stats Collection → stats --stats-only (recopila información del archivo)
123
+ # 2. PDF Detection → detect --detect-pdfs (identifica pedimentos simplificados)
124
+ # 3. Path Propagation → detect --propagate-arela-path (propaga a documentos relacionados)
125
+ # 4. RFC Upload → upload --upload-by-rfc --folder-structure (sube con estructura)
126
+ #
127
+ # El pipeline se habilita automáticamente en watch mode y usa la folderStructure
128
+ # definida para cada WATCH_DIRECTORY_CONFIGS
129
+ #
130
+ # Para deshabilitar en CLI, usa: arela watch --no-auto-processing
131
+
66
132
  # =============================================================================
67
133
  # LOGGING AND MONITORING
68
134
  # =============================================================================
package/README.md CHANGED
@@ -2,6 +2,14 @@
2
2
 
3
3
  CLI tool to upload files and directories to Arela API or Supabase Storage with automatic file processing, detection, and organization.
4
4
 
5
+ ## ✨ What's New in v0.4.0
6
+
7
+ - 🏢 **Simplified Multi-Tenant API**: Only 3 targets: `default`, `agencia`, `cliente`
8
+ - 🔀 **Cross-Tenant Mode**: Read from one API, write to another with `--source-api` and `--target-api`
9
+ - ⚙️ **Dynamic Client Config**: Switch clients by updating `.env` - no code changes needed!
10
+ - 👁️ **Enhanced Watch Mode**: Full cross-tenant support in automatic processing pipeline
11
+ - ⚡ **Optimized Connections**: HTTP Agent with connection pooling for high performance
12
+
5
13
  ## 🚀 OPTIMIZED 4-PHASE WORKFLOW
6
14
 
7
15
  **New in v0.2.0**: The tool now supports an optimized 4-phase workflow designed for maximum performance when processing large file collections:
@@ -84,6 +92,75 @@ arela --upload-by-rfc # Phase 4: Upload by RFC
84
92
  - 📋 **Upload files by specific RFC values**
85
93
  - 🔍 **Propagate arela_path from pedimento documents to related files**
86
94
  - ⚡ **4-Phase optimized workflow for maximum performance**
95
+ - 👁️ **Watch Mode** - Monitor directories for changes and upload automatically
96
+ - Multiple watch strategies (batch, individual, full-structure)
97
+ - **Multi-tenant and cross-tenant support** ⭐ NEW
98
+ - Debounce and polling support
99
+ - Auto-processing pipeline
100
+ - Dry-run mode for testing
101
+ - Pattern-based file ignoring
102
+
103
+ ## 🏢 Multi-Tenant API Support
104
+
105
+ Connect to different API instances: **default**, **agencia**, or **cliente**.
106
+
107
+ ```bash
108
+ # Upload to client API
109
+ arela upload --api cliente --upload-by-rfc
110
+
111
+ # Collect stats on agencia API
112
+ arela stats --api agencia
113
+
114
+ # Watch mode with specific API target
115
+ arela watch --api cliente
116
+ ```
117
+
118
+ ### Cross-Tenant Mode
119
+
120
+ Process files from one tenant and upload to another:
121
+
122
+ ```bash
123
+ # Read data from agencia, upload files to client
124
+ arela watch --source-api agencia --target-api cliente
125
+
126
+ # Same for upload command
127
+ arela upload --source-api agencia --target-api cliente --upload-by-rfc
128
+ ```
129
+
130
+ **How Cross-Tenant Works:**
131
+ | Phase | Description | API Used |
132
+ |-------|-------------|----------|
133
+ | Phase 1 | Stats Collection | `--source-api` |
134
+ | Phase 2 | PDF Detection | `--source-api` |
135
+ | Phase 3 | Path Propagation | `--source-api` |
136
+ | Phase 4 | File Upload | `--target-api` |
137
+
138
+ ### Available API Targets
139
+
140
+ Only 3 API targets are available: `default`, `agencia`, `cliente`
141
+
142
+ Configure in your `.env` file:
143
+
144
+ ```env
145
+ # Default API (--api default or no flag)
146
+ ARELA_API_URL=http://localhost:3010
147
+ ARELA_API_TOKEN=your_token
148
+
149
+ # Agencia API (--api agencia)
150
+ ARELA_API_AGENCIA_URL=http://localhost:4012
151
+ ARELA_API_AGENCIA_TOKEN=your_agencia_token
152
+
153
+ # Cliente API (--api cliente)
154
+ # Configure the URL/Token for the specific client you need
155
+ ARELA_API_CLIENTE_URL=http://localhost:4014
156
+ ARELA_API_CLIENTE_TOKEN=your_cliente_token
157
+
158
+ # Examples for different clients:
159
+ # Cliente AUM9207011CA: ARELA_API_CLIENTE_URL=http://localhost:4014
160
+ # Cliente KTJ931117P55: ARELA_API_CLIENTE_URL=http://localhost:4013
161
+ ```
162
+
163
+ > 💡 **Tip**: To switch between clients, just update `ARELA_API_CLIENTE_URL` and `ARELA_API_CLIENTE_TOKEN` in your `.env` file. No code changes needed!
87
164
 
88
165
  ## Installation
89
166
 
@@ -97,78 +174,136 @@ npm install -g @arela/uploader
97
174
 
98
175
  ```bash
99
176
  # Run all phases automatically (most efficient)
100
- arela --run-all-phases --batch-size 20
177
+ arela upload --run-all-phases --batch-size 20
101
178
 
102
179
  # Or run phases individually for fine-grained control
103
- arela --stats-only # Phase 1: Filesystem stats only
104
- arela --detect-pdfs --batch-size 10 # Phase 2: PDF detection
105
- arela --propagate-arela-path # Phase 3: Path propagation
106
- arela --upload-by-rfc --batch-size 5 # Phase 4: RFC-based upload
180
+ arela stats # Phase 1: Filesystem stats only
181
+ arela detect # Phase 2: PDF detection
182
+ arela detect --propagate-arela-path # Phase 3: Path propagation
183
+ arela upload --upload-by-rfc # Phase 4: RFC-based upload
107
184
  ```
108
185
 
109
- ### Traditional Single-Phase Upload (Legacy)
186
+ ### Available Commands
110
187
 
111
- #### Basic Upload with Auto-Processing (API Mode)
188
+ #### 1. **upload** - Upload files to Arela
112
189
  ```bash
113
- arela --batch-size 10 -c 5
114
- ```
190
+ # Basic upload with auto-processing (API Mode)
191
+ arela upload --batch-size 10
115
192
 
116
- ### Upload with Auto-Detection of Year/Pedimento
117
- ```bash
118
- arela --auto-detect-structure --batch-size 10 -c 5
119
- ```
193
+ # Upload with auto-detection of year/pedimento from file paths
194
+ arela upload --auto-detect-structure --batch-size 10
120
195
 
121
- ### Upload with Custom Folder Structure
122
- ```bash
123
- arela --folder-structure "2024/4023260" --batch-size 10 -c 5
196
+ # Upload with custom folder structure
197
+ arela upload --folder-structure "2024/4023260" --batch-size 10
198
+
199
+ # Upload to Supabase directly (skip API)
200
+ arela upload --force-supabase --prefix "my-folder"
201
+
202
+ # Upload files by specific RFC values
203
+ arela upload --upload-by-rfc --batch-size 5
204
+
205
+ # Upload RFC files with custom folder prefix
206
+ arela upload --upload-by-rfc --folder-structure "palco" --batch-size 5
207
+
208
+ # Upload RFC files with nested folder structure
209
+ arela upload --upload-by-rfc --folder-structure "2024/Q1/processed" --batch-size 15
210
+
211
+ # Upload with performance statistics
212
+ arela upload --batch-size 10 --show-stats
213
+
214
+ # Upload with client path tracking
215
+ arela upload --client-path "/client/documents" --batch-size 10
124
216
  ```
125
217
 
126
- ### Upload with Directory Structure Preservation
218
+ #### 2. **stats** - Collect file statistics without uploading
127
219
  ```bash
128
- arela --batch-size 10 -c 5 --preserve-structure
220
+ # Collect filesystem statistics only (Phase 1)
221
+ arela stats --batch-size 10
222
+
223
+ # Stats with custom folder organization
224
+ arela stats --folder-structure "2023/3019796" --batch-size 10
225
+
226
+ # Stats with client path tracking
227
+ arela stats --client-path "/client/documents" --batch-size 10
129
228
  ```
130
229
 
131
- ### Upload to Supabase Directly (Skip API)
230
+ #### 3. **detect** - Run document detection and path propagation
132
231
  ```bash
133
- arela --force-supabase -p "my-folder"
232
+ # Run PDF detection on existing database records (Phase 2)
233
+ arela detect --batch-size 10
234
+
235
+ # Propagate arela_path from pedimento records to related files (Phase 3)
236
+ arela detect --propagate-arela-path
134
237
  ```
135
238
 
136
- ### Upload Files by Specific RFC Values
239
+ #### 4. **watch** - Monitor directories and upload automatically ⭐ NEW
137
240
  ```bash
138
- # Upload all files associated with specific RFCs
139
- arela --upload-by-rfc --batch-size 5
241
+ # Watch directories for changes with automatic upload
242
+ arela watch --directories "/path/to/watch1,/path/to/watch2"
140
243
 
141
- # Upload RFC files with custom folder prefix
142
- arela --upload-by-rfc --folder-structure "palco" --batch-size 5
244
+ # Watch with specific API target (single tenant)
245
+ arela watch --api cliente
143
246
 
144
- # Upload RFC files with nested folder structure
145
- arela --upload-by-rfc --folder-structure "2024/client1/pedimentos" --batch-size 5
146
- ```
247
+ # Watch with cross-tenant mode (read from agencia, upload to client)
248
+ arela watch --source-api agencia --target-api cliente
147
249
 
148
- ### Propagate Arela Path from Pedimentos to Related Files
149
- ```bash
150
- # Copy arela_path from pedimento_simplificado records to related files
151
- arela --propagate-arela-path
250
+ # Watch with custom upload strategy (default: batch)
251
+ arela watch --directories "/path/to/watch" --strategy individual
252
+ arela watch --directories "/path/to/watch" --strategy full-structure
253
+
254
+ # Watch with custom debounce delay (default: 1000ms)
255
+ arela watch --directories "/path/to/watch" --debounce 2000
256
+
257
+ # Watch with automatic 4-step pipeline
258
+ arela watch --directories "/path/to/watch" --auto-processing --batch-size 10
259
+
260
+ # Watch with polling instead of native file system events
261
+ arela watch --directories "/path/to/watch" --poll 5000
262
+
263
+ # Watch with pattern ignoring
264
+ arela watch --directories "/path/to/watch" --ignore "node_modules,*.log,*.tmp"
265
+
266
+ # Watch in dry-run mode (simulate without uploading)
267
+ arela watch --directories "/path/to/watch" --dry-run
268
+
269
+ # Watch with verbose logging
270
+ arela watch --directories "/path/to/watch" --verbose
152
271
  ```
153
272
 
154
- ### Stats-Only Mode (No Upload)
273
+ **Watch Strategies:**
274
+ - `batch` **(default)**: Groups files and uploads periodically
275
+ - `individual`: Uploads each file immediately as it changes
276
+ - `full-structure`: Preserves directory structure during upload
277
+
278
+ **Multi-Tenant Options:**
279
+ - `--api <target>`: Use a single API for all operations
280
+ - `--source-api <target>`: API for reading/processing (phases 1-3)
281
+ - `--target-api <target>`: API for uploading (phase 4)
282
+
283
+ #### 5. **query** - Query database for file status
155
284
  ```bash
156
- # Only process file stats and insert to database, don't upload
157
- arela --stats-only --folder-structure "2023/3019796"
285
+ # Show files ready for upload
286
+ arela query --ready-files
158
287
  ```
159
288
 
160
- ### Upload with Performance Statistics
289
+ #### 6. **config** - Show current configuration
161
290
  ```bash
162
- arela --batch-size 10 -c 5 --show-stats
291
+ # Display all configuration settings
292
+ arela config
163
293
  ```
164
294
 
165
- ### Upload with Client Path Tracking
295
+ ### Legacy Syntax (Still Supported)
296
+
297
+ The old flag-based syntax is still supported for backward compatibility:
298
+
166
299
  ```bash
167
- arela --client-path "/client/documents" --batch-size 10 -c 5
300
+ # These are equivalent to the commands above
301
+ arela --stats-only # Same as: arela stats
302
+ arela --detect-pdfs # Same as: arela detect
303
+ arela --propagate-arela-path # Same as: arela detect --propagate-arela-path
304
+ arela --upload-by-rfc # Same as: arela upload --upload-by-rfc
168
305
  ```
169
306
 
170
- ### Options
171
-
172
307
  #### Phase Control
173
308
  - `--stats-only`: **Phase 1** - Only collect filesystem stats (no file reading)
174
309
  - `--detect-pdfs`: **Phase 2** - Process PDF files for pedimento-simplificado detection
@@ -176,36 +311,71 @@ arela --client-path "/client/documents" --batch-size 10 -c 5
176
311
  - `--upload-by-rfc`: **Phase 4** - Upload files based on RFC values from UPLOAD_RFCS
177
312
  - `--run-all-phases`: **All Phases** - Run complete optimized workflow
178
313
 
179
- #### Performance & Configuration
180
- - `-c, --concurrency <number>`: Files per batch for processing (default: 10)
181
- - `--batch-size <number>`: API batch size (default: 10)
182
- - `--show-stats`: Show detailed processing statistics
314
+ #### Global Options (all commands)
315
+ - `-v, --verbose`: Enable verbose logging
316
+ - `--clear-log`: Clear the log file before starting
317
+ - `-h, --help`: Display help information
318
+ - `--version`: Display version number
183
319
 
184
- #### Upload Configuration
185
- - `-p, --prefix <prefix>`: Prefix path in bucket (default: "")
186
- - `-b, --bucket <bucket>`: Bucket name override
187
- - `--force-supabase`: Force direct Supabase upload (skip API)
188
- - `--no-auto-detect`: Disable automatic file detection (API mode only)
189
- - `--no-auto-organize`: Disable automatic file organization (API mode only)
190
- - `--preserve-structure`: **Preserve original directory structure when using auto-organize**
191
- - `--folder-structure <structure>`: **Custom folder structure** (e.g., "2024/4023260" or "cliente1/pedimentos")
192
- - `--auto-detect-structure`: **Automatically detect year/pedimento from file paths**
320
+ #### Upload Command Options
321
+ - `-b, --batch-size <size>`: API batch size (default: 10)
322
+ - `--folder-structure <structure>`: Custom folder structure (e.g., "2024/4023260")
193
323
  - `--client-path <path>`: Client path for metadata tracking
324
+ - `--auto-detect-structure`: Automatically detect year/pedimento from file paths
325
+ - `--auto-detect`: Enable automatic document type detection
326
+ - `--auto-organize`: Enable automatic file organization
327
+ - `--force-supabase`: Force direct Supabase upload (skip API)
328
+ - `--skip-processed`: Skip files already processed
329
+ - `--show-stats`: Show performance statistics
330
+ - `--upload-by-rfc`: Upload files based on RFC values from UPLOAD_RFCS
331
+ - `--run-all-phases`: Run all processing phases sequentially
194
332
 
195
- #### Legacy Options
196
- - `--no-detect`: Disable document type detection in stats-only mode
197
- - `-v, --version`: Display version number
198
- - `-h, --help`: Display help information
333
+ #### Stats Command Options
334
+ - `-b, --batch-size <size>`: Batch size for processing (default: 10)
335
+ - `--client-path <path>`: Client path for metadata tracking
336
+ - `--show-stats`: Show performance statistics
337
+
338
+ #### Detect Command Options
339
+ - `-b, --batch-size <size>`: Batch size for PDF detection (default: 10)
340
+ - `--propagate-arela-path`: Propagate arela_path from pedimento records to related files
341
+
342
+ #### Watch Command Options
343
+ - `-d, --directories <paths>`: **Comma-separated directories to watch** (required)
344
+ - `-s, --strategy <strategy>`: Upload strategy (default: batch)
345
+ - `batch`: Groups files and uploads periodically
346
+ - `individual`: Uploads each file immediately
347
+ - `full-structure`: Preserves directory structure
348
+ - `--api <target>`: Use a single API target for all operations
349
+ - `--source-api <target>`: API for reading/processing (phases 1-3)
350
+ - `--target-api <target>`: API for uploading (phase 4)
351
+ - `--debounce <ms>`: Debounce delay in milliseconds (default: 1000)
352
+ - `-b, --batch-size <size>`: Batch size for uploads (default: 10)
353
+ - `--poll <ms>`: Use polling instead of native file system events (interval in ms)
354
+ - `--ignore <patterns>`: Comma-separated patterns to ignore
355
+ - `--auto-detect`: Enable automatic document type detection
356
+ - `--auto-organize`: Enable automatic file organization
357
+ - `--auto-processing`: Enable automatic 4-step pipeline (stats, detect, propagate, upload)
358
+ - `--dry-run`: Simulate changes without uploading
359
+ - `--verbose`: Enable verbose logging
199
360
 
200
361
  ## Environment Variables
201
362
 
202
363
  Create a `.env` file in your project root:
203
364
 
204
365
  ```env
205
- # For API Mode (recommended)
366
+ # Default API (--api default or no flag)
206
367
  ARELA_API_URL=http://localhost:3010
207
368
  ARELA_API_TOKEN=your_api_token
208
369
 
370
+ # Agencia API (--api agencia)
371
+ ARELA_API_AGENCIA_URL=http://localhost:4012
372
+ ARELA_API_AGENCIA_TOKEN=your_agencia_token
373
+
374
+ # Cliente API (--api cliente)
375
+ # Configure for the specific client you need
376
+ ARELA_API_CLIENTE_URL=http://localhost:4014
377
+ ARELA_API_CLIENTE_TOKEN=your_cliente_token
378
+
209
379
  # For Direct Supabase Mode (fallback)
210
380
  SUPABASE_URL=your_supabase_url
211
381
  SUPABASE_KEY=your_supabase_anon_key
@@ -218,18 +388,26 @@ UPLOAD_SOURCES=folder1|folder2|file.pdf
218
388
  # RFC-based Upload Configuration
219
389
  # Pipe-separated list of RFCs to upload files for
220
390
  UPLOAD_RFCS=MMJ0810145N1|ABC1234567XY|DEF9876543ZZ
391
+
392
+ # Watch Mode Configuration (JSON format)
393
+ WATCH_DIRECTORY_CONFIGS={"../../Documents/2022":"palco","../../Documents/2023":"palco"}
221
394
  ```
222
395
 
223
396
  **Environment Variable Details:**
224
397
 
225
- - `ARELA_API_URL`: Base URL for the Arela API service
226
- - `ARELA_API_TOKEN`: Authentication token for API access
398
+ - `ARELA_API_URL`: Base URL for default API service
399
+ - `ARELA_API_AGENCIA_URL`: URL for agencia API
400
+ - `ARELA_API_CLIENTE_URL`: URL for client API (configure per client)
401
+ - `ARELA_API_TOKEN`: Authentication token for default API
402
+ - `ARELA_API_AGENCIA_TOKEN`: Token for agencia API
403
+ - `ARELA_API_CLIENTE_TOKEN`: Token for client API
227
404
  - `SUPABASE_URL`: Your Supabase project URL
228
405
  - `SUPABASE_KEY`: Supabase anonymous key for direct uploads
229
406
  - `SUPABASE_BUCKET`: Target bucket name in Supabase Storage
230
407
  - `UPLOAD_BASE_PATH`: Root directory containing files to upload
231
408
  - `UPLOAD_SOURCES`: Pipe-separated list of folders/files to process
232
409
  - `UPLOAD_RFCS`: Pipe-separated list of RFC values for targeted uploads
410
+ - `WATCH_DIRECTORY_CONFIGS`: JSON mapping directories to folder structures
233
411
 
234
412
  ## RFC-Based File Upload
235
413
 
@@ -434,7 +612,25 @@ The tool maintains comprehensive logs both locally and remotely:
434
612
 
435
613
  ## Version History
436
614
 
437
- **v2.0.0** - Latest Release
615
+ **v0.4.0** - Current Release 🆕
616
+ - ✨ **Simplified Multi-Tenant API**: Only 3 targets: `default`, `agencia`, `cliente`
617
+ - ✨ **Cross-Tenant Mode**: Read from one API, upload to another
618
+ - ✨ **Dynamic Client Config**: Change client by updating `.env` (no code changes)
619
+ - ✨ New `--api` flag for single API target
620
+ - ✨ New `--source-api` flag for source API (phases 1-3)
621
+ - ✨ New `--target-api` flag for target API (phase 4)
622
+ - ✨ `WATCH_DIRECTORY_CONFIGS` environment variable for watch mode
623
+ - 🔧 Enhanced pipeline routing for cross-tenant operations
624
+ - 📝 Simplified documentation for multi-tenant configuration
625
+
626
+ **v0.3.0** - Watch Mode Release
627
+ - ✨ Added watch command with chokidar integration
628
+ - ✨ Automatic 4-step pipeline (stats → detect → propagate → upload)
629
+ - ✨ Multiple upload strategies (batch, individual, full-structure)
630
+ - ✨ Configurable debounce and polling options
631
+ - 🔧 Signal handling for graceful shutdown
632
+
633
+ **v0.2.0** - Pipeline Automation
438
634
  - ✨ Added smart year/pedimento auto-detection from file paths
439
635
  - ✨ Custom folder structure support with `--folder-structure` option
440
636
  - ✨ Client path tracking with `--client-path` option
@@ -446,6 +642,11 @@ The tool maintains comprehensive logs both locally and remotely:
446
642
  - 📝 Comprehensive logging with SANITIZED status
447
643
  - 🔧 Memory optimization for large file processing
448
644
 
645
+ **v0.1.0** - Initial Release
646
+ - 📦 Basic upload functionality
647
+ - 🔌 API and Supabase direct mode support
648
+ - 📂 RFC-based file upload
649
+
449
650
  ## Troubleshooting
450
651
 
451
652
  **Connection Issues:**