@arela/uploader 1.0.3 → 1.0.5

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 (44) hide show
  1. package/.env.local +316 -0
  2. package/coverage/IdentifyCommand.js.html +1462 -0
  3. package/coverage/PropagateCommand.js.html +1507 -0
  4. package/coverage/PushCommand.js.html +1504 -0
  5. package/coverage/ScanCommand.js.html +1654 -0
  6. package/coverage/UploadCommand.js.html +1846 -0
  7. package/coverage/WatchCommand.js.html +4111 -0
  8. package/coverage/base.css +224 -0
  9. package/coverage/block-navigation.js +87 -0
  10. package/coverage/favicon.png +0 -0
  11. package/coverage/index.html +191 -0
  12. package/coverage/lcov-report/IdentifyCommand.js.html +1462 -0
  13. package/coverage/lcov-report/PropagateCommand.js.html +1507 -0
  14. package/coverage/lcov-report/PushCommand.js.html +1504 -0
  15. package/coverage/lcov-report/ScanCommand.js.html +1654 -0
  16. package/coverage/lcov-report/UploadCommand.js.html +1846 -0
  17. package/coverage/lcov-report/WatchCommand.js.html +4111 -0
  18. package/coverage/lcov-report/base.css +224 -0
  19. package/coverage/lcov-report/block-navigation.js +87 -0
  20. package/coverage/lcov-report/favicon.png +0 -0
  21. package/coverage/lcov-report/index.html +191 -0
  22. package/coverage/lcov-report/prettify.css +1 -0
  23. package/coverage/lcov-report/prettify.js +2 -0
  24. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  25. package/coverage/lcov-report/sorter.js +210 -0
  26. package/coverage/lcov.info +1937 -0
  27. package/coverage/prettify.css +1 -0
  28. package/coverage/prettify.js +2 -0
  29. package/coverage/sort-arrow-sprite.png +0 -0
  30. package/coverage/sorter.js +210 -0
  31. package/docs/CROSS_PLATFORM_PATH_HANDLING.md +597 -0
  32. package/package.json +28 -2
  33. package/src/commands/IdentifyCommand.js +1 -28
  34. package/src/commands/PropagateCommand.js +1 -1
  35. package/src/commands/PushCommand.js +1 -1
  36. package/src/commands/ScanCommand.js +27 -20
  37. package/src/config/config.js +27 -48
  38. package/src/services/ScanApiService.js +4 -5
  39. package/src/utils/PathNormalizer.js +272 -0
  40. package/tests/commands/IdentifyCommand.test.js +570 -0
  41. package/tests/commands/PropagateCommand.test.js +568 -0
  42. package/tests/commands/PushCommand.test.js +754 -0
  43. package/tests/commands/ScanCommand.test.js +382 -0
  44. package/tests/unit/PathAndTableNameGeneration.test.js +1211 -0
package/.env.local ADDED
@@ -0,0 +1,316 @@
1
+ # ============================================
2
+ # ARELA UPLOADER CONFIGURATION
3
+ # ============================================
4
+
5
+ # Localhost Arela API Configuration
6
+ ARELA_API_URL=http://localhost:3010
7
+ ARELA_API_TOKEN=555f1d5c1b5020a132002a6fa201e0074e1b057895776bd33619db0cd26b259b
8
+
9
+ # Localhost Supabase Configuration
10
+ SUPABASE_URL=http://127.0.0.1:54321
11
+ SUPABASE_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6InNlcnZpY2Vfcm9sZSIsImV4cCI6MTk4MzgxMjk5Nn0.EGIM96RAZx35lJzdJsyH-qQwv8Hdp7fsn3W0YpN81IU
12
+ SUPABASE_BUCKET=arela
13
+
14
+ # ARELA_API_TARGET=default
15
+
16
+ # Localhost Upload Configuration
17
+ UPLOAD_BASE_PATH=./sample
18
+ UPLOAD_SOURCES=2023|2024
19
+ UPLOAD_RFCS=DTM090831LF0|AKS151005E46|IMS030409FZ0|RDG1107154L7|SHP031226BV2|CSM9301219B4|LIN960124HT8|LME971009SW4|AKM9707151B6|FEL000822AG2|FDM060802J54|MTM9807279B4|AUM9207011CA|MMJ0810145N1|ACC010328EQ6|PED781129JT6|CAD890407NK7|SME140411IK7|JME1903121C2|EIJ110429NF9|PTJ080414TM6|TME050503BM4
20
+ # UPLOAD_RFCS=FDM060802J54|CSM9301219B4
21
+ UPLOAD_YEARS=2023|2024|2025
22
+
23
+ # =============================================================================
24
+ # SCAN CONFIGURATION (for arela scan command)
25
+ # =============================================================================
26
+
27
+ # Company identifier for this CLI instance (required)
28
+ # Use a short, descriptive slug for your company/agency/client
29
+ # Examples: "acme_corp", "cliente_123", "agencia_xyz"
30
+ ARELA_COMPANY_SLUG=palco
31
+
32
+ # Server identifier (required)
33
+ # Use a unique ID for each server/NAS where arela-cli is installed
34
+ # Examples: "nas01", "server-mx", "storage-01"
35
+ ARELA_SERVER_ID=local
36
+
37
+ # Base path label (optional, auto-derived from UPLOAD_BASE_PATH if not set)
38
+ # Short label describing the base path being scanned
39
+ # Examples: "data", "documents", "archive"
40
+ ARELA_BASE_PATH_LABEL=
41
+
42
+ # System file patterns to exclude from scan (comma-separated)
43
+ # These files will be filtered before uploading stats to reduce payload
44
+ SCAN_EXCLUDE_PATTERNS=.DS_Store,Thumbs.db,desktop.ini,__pycache__,.pyc,.tmp,.swp,$RECYCLE.BIN,System Volume Information,~$*
45
+
46
+ # Batch size for scan operations (default: 2000 records per API call)
47
+ SCAN_BATCH_SIZE=2000
48
+
49
+ # Directory depth level for creating separate tables (default: 0)
50
+ # 0 = single table for entire base path
51
+ # 1 = one table per first-level subdirectory
52
+ # 2 = one table per second-level subdirectory, etc.
53
+ # Example: with level=1 and base=/data, creates tables for /data/folder1, /data/folder2, etc.
54
+ SCAN_DIRECTORY_LEVEL=0
55
+
56
+ # =============================================================================
57
+ # PUSH CONFIGURATION (for arela push command)
58
+ # =============================================================================
59
+
60
+ # Filter files to upload by RFC (pipe-separated, optional)
61
+ # If not set, all files with arela_path will be uploaded
62
+ # Examples: "RFC123456ABC|RFC789012DEF"
63
+ PUSH_RFCS=
64
+
65
+ # Filter files to upload by year (pipe-separated, optional)
66
+ # If not set, all files with arela_path will be uploaded
67
+ # Examples: "2023|2024|2025"
68
+ PUSH_YEARS=
69
+
70
+ # Batch size for fetching files from database (default: 100)
71
+ PUSH_BATCH_SIZE=100
72
+
73
+ # Concurrent upload batch size (default: 10)
74
+ # Number of files to upload simultaneously
75
+ PUSH_UPLOAD_BATCH_SIZE=10
76
+
77
+ # Storage bucket for uploaded files (optional, defaults to SUPABASE_BUCKET)
78
+ # Examples: "archivos", "documents", "storage"
79
+ PUSH_BUCKET=cli
80
+
81
+
82
+ # =============================================================================
83
+ # PERFORMANCE OPTIMIZATION FOR MULTIPLE API REPLICAS
84
+ # =============================================================================
85
+
86
+ # API Connection Configuration
87
+ # Set this to match your number of API replicas (e.g., if you have 10 API instances, set to 10)
88
+ MAX_API_CONNECTIONS=10
89
+
90
+ # API Connection Timeout (milliseconds)
91
+ API_CONNECTION_TIMEOUT=60000
92
+
93
+ # Batch Processing Configuration
94
+ # Files processed concurrently per batch (should be >= MAX_API_CONNECTIONS for best performance)
95
+ BATCH_SIZE=100
96
+
97
+ # Delay between batches (0 for maximum speed)
98
+ BATCH_DELAY=0
99
+
100
+ # Source Processing Concurrency
101
+ # Number of upload sources/folders to process simultaneously
102
+ MAX_CONCURRENT_SOURCES=2
103
+
104
+ # API Retry Configuration
105
+ # Maximum number of retry attempts for failed API requests
106
+ API_MAX_RETRIES=3
107
+
108
+ # Enable exponential backoff for retries (true/false)
109
+ # When true, retry delays increase: 1s, 2s, 4s, 8s, 16s
110
+ # When false, uses fixed delay (API_RETRY_DELAY)
111
+ API_RETRY_EXPONENTIAL_BACKOFF=true
112
+
113
+ # Fixed retry delay in milliseconds (only used if exponential backoff is disabled)
114
+ API_RETRY_DELAY=1000
115
+
116
+ # =============================================================================
117
+ # EXAMPLE CONFIGURATIONS FOR DIFFERENT SCENARIOS
118
+ # =============================================================================
119
+
120
+ # For 10 API Replicas (High Performance Setup):
121
+ # MAX_API_CONNECTIONS=10
122
+ # BATCH_SIZE=100
123
+ # MAX_CONCURRENT_SOURCES=3
124
+ # BATCH_DELAY=0
125
+
126
+ # For 5 API Replicas (Medium Performance Setup):
127
+ # MAX_API_CONNECTIONS=5
128
+ # BATCH_SIZE=50
129
+ # MAX_CONCURRENT_SOURCES=2
130
+ # BATCH_DELAY=0
131
+
132
+ # For 1 API Instance (Single Instance Setup):
133
+ # MAX_API_CONNECTIONS=5
134
+ # BATCH_SIZE=20
135
+ # MAX_CONCURRENT_SOURCES=1
136
+ # BATCH_DELAY=100
137
+
138
+ # =============================================================================
139
+ # LOGGING AND MONITORING
140
+ # =============================================================================
141
+
142
+ # Progress bar update frequency
143
+ PROGRESS_UPDATE_INTERVAL=10
144
+
145
+ # Enable verbose logging (true/false)
146
+ VERBOSE_LOGGING=false
147
+
148
+
149
+
150
+
151
+
152
+
153
+
154
+
155
+
156
+
157
+
158
+
159
+
160
+
161
+
162
+
163
+
164
+
165
+
166
+
167
+
168
+
169
+
170
+
171
+
172
+ # ============================================
173
+
174
+ # # Cloud Service Arela API Configuration
175
+ # # ARELA_API_URL=https://api.aws.arela.com.mx
176
+ # # ARELA_API_TOKEN=6bd75c5b3699ecf19e6726c10ae88ae0528f0b72d6c10f8b284f92563d3822a7
177
+
178
+ # # # Cloud Service Supabase Configuration
179
+ # SUPABASE_URL=https://qlospyfsbwvkskivmsgq.supabase.co
180
+ # SUPABASE_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InFsb3NweWZzYnd2a3NraXZtc2dxIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NTU5MDg2NjUsImV4cCI6MjA3MTQ4NDY2NX0.BrqcCLxTmpU6Swl7h3gam6TeW4jVf4WssMbRm0sH7l4
181
+ # SUPABASE_BUCKET=zips
182
+
183
+ # # # Cloud Service Upload Configuration
184
+ # UPLOAD_BASE_PATH=./sample
185
+ # UPLOAD_SOURCES=zips
186
+ # # UPLOAD_RFCS=AKS151005E46|IMS030409FZ0|RDG1107154L7|SHP031226BV2|CSM9301219B4|LIN960124HT8|LME971009SW4|AKM9707151B6|FEL000822AG2|FDM060802J54|MTM9807279B4|AUM9207011CA|MMJ0810145N1|ACC010328EQ6|PED781129JT6|CAD890407NK7|SME140411IK7|JME1903121C2|EIJ110429NF9|PTJ080414TM6|TME050503BM4
187
+ # UPLOAD_RFCS=KTJ931117P55|AUM9207011CA
188
+ # UPLOAD_YEARS=2023|
189
+
190
+ # # =============================================================================
191
+ # # PERFORMANCE OPTIMIZATION FOR MULTIPLE API REPLICAS
192
+ # # =============================================================================
193
+
194
+ # # API Connection Configuration
195
+ # # Set this to match your number of API replicas (e.g., if you have 10 API instances, set to 10)
196
+ # MAX_API_CONNECTIONS=10
197
+
198
+ # # API Connection Timeout (milliseconds)
199
+ # API_CONNECTION_TIMEOUT=60000
200
+
201
+ # # Batch Processing Configuration
202
+ # # Files processed concurrently per batch (should be >= MAX_API_CONNECTIONS for best performance)
203
+ # BATCH_SIZE=100
204
+
205
+ # # Delay between batches (0 for maximum speed)
206
+ # BATCH_DELAY=0
207
+
208
+ # # Source Processing Concurrency
209
+ # # Number of upload sources/folders to process simultaneously
210
+ # MAX_CONCURRENT_SOURCES=2
211
+
212
+ # # =============================================================================
213
+ # # EXAMPLE CONFIGURATIONS FOR DIFFERENT SCENARIOS
214
+ # # =============================================================================
215
+
216
+ # # For 10 API Replicas (High Performance Setup):
217
+ # # MAX_API_CONNECTIONS=10
218
+ # # BATCH_SIZE=100
219
+ # # MAX_CONCURRENT_SOURCES=3
220
+ # # BATCH_DELAY=0
221
+
222
+ # # For 5 API Replicas (Medium Performance Setup):
223
+ # # MAX_API_CONNECTIONS=5
224
+ # # BATCH_SIZE=50
225
+ # # MAX_CONCURRENT_SOURCES=2
226
+ # # BATCH_DELAY=0
227
+
228
+ # # For 1 API Instance (Single Instance Setup):
229
+ # # MAX_API_CONNECTIONS=5
230
+ # # BATCH_SIZE=20
231
+ # # MAX_CONCURRENT_SOURCES=1
232
+ # # BATCH_DELAY=100
233
+
234
+ # # =============================================================================
235
+ # # LOGGING AND MONITORING
236
+ # # =============================================================================
237
+
238
+ # # Progress bar update frequency
239
+ # PROGRESS_UPDATE_INTERVAL=10
240
+
241
+ # # Enable verbose logging (true/false)
242
+ # VERBOSE_LOGGING=false
243
+
244
+ # # ============================================
245
+
246
+
247
+
248
+ # =============================================================================
249
+ # WATCH MODE CONFIGURATION
250
+ # =============================================================================
251
+
252
+ # Habilitar watch mode (true/false)
253
+ WATCH_ENABLED=true
254
+
255
+ # Configuración de directorios a observar (formato JSON)
256
+ # Cada directorio puede tener su propia folderStructure para organizar en el bucket
257
+ # Formato: {"ruta/directorio1":"estructura-1","ruta/directorio2":"estructura-2"}
258
+ WATCH_DIRECTORY_CONFIGS={"./sample/watcher":"prueba-watcher"}
259
+
260
+ # Estrategia de upload (opciones: individual|batch|full-structure)
261
+ # - individual: Sube solo el archivo modificado más reciente
262
+ # - batch: Sube un lote de N archivos recientes
263
+ # - full-structure: Sube la estructura completa de carpetas
264
+ WATCH_STRATEGY=batch
265
+
266
+ # Debouncing en milisegundos (esperar entre eventos antes de procesar)
267
+ WATCH_DEBOUNCE_MS=1000
268
+
269
+ # Tamaño de batch para strategy batch
270
+ WATCH_BATCH_SIZE=10
271
+
272
+ # Usar polling en lugar de eventos nativos del filesystem
273
+ # Útil para sistemas de archivos remotos o NFS
274
+ WATCH_USE_POLLING=false
275
+
276
+ # Interval de polling en milisegundos (solo si WATCH_USE_POLLING=true)
277
+ WATCH_POLL_INTERVAL=100
278
+
279
+ # Umbral de estabilidad en ms (esperar a que el archivo deje de cambiar)
280
+ WATCH_STABILITY_THRESHOLD=300
281
+
282
+ # Patrones a ignorar (separados por coma, se usan como regex)
283
+ WATCH_IGNORE_PATTERNS=.tmp,.bak,*.swp
284
+
285
+ # Detección automática de tipos de documento
286
+ WATCH_AUTO_DETECT=true
287
+
288
+ # Organización automática de archivos
289
+ WATCH_AUTO_ORGANIZE=true
290
+
291
+ # =============================================================================
292
+ # WATCH MODE - AUTOMATIC PROCESSING PIPELINE
293
+ # =============================================================================
294
+ #
295
+ # El pipeline automático ejecuta la siguiente secuencia cuando se detecta un archivo nuevo:
296
+ # 1. Stats Collection → stats --stats-only (recopila información del archivo)
297
+ # 2. PDF Detection → detect --detect-pdfs (identifica pedimentos simplificados)
298
+ # 3. Path Propagation → detect --propagate-arela-path (propaga a documentos relacionados)
299
+ # 4. RFC Upload → upload --upload-by-rfc --folder-structure (sube con estructura)
300
+ #
301
+ # El pipeline se habilita automáticamente en watch mode y usa la folderStructure
302
+ # definida para cada WATCH_DIRECTORY_CONFIGS
303
+ #
304
+ # Para deshabilitar en CLI, usa: arela watch --no-auto-processing
305
+
306
+ # =============================================================================
307
+ # LOGGING AND MONITORING
308
+ # =============================================================================
309
+
310
+ # Progress bar update frequency
311
+ PROGRESS_UPDATE_INTERVAL=10
312
+
313
+ # Enable verbose logging (true/false)
314
+ VERBOSE_LOGGING=false
315
+
316
+ # ============================================