@arela/uploader 1.0.2 → 1.0.4

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 (61) hide show
  1. package/.env.local +316 -0
  2. package/.env.template +70 -0
  3. package/coverage/IdentifyCommand.js.html +1462 -0
  4. package/coverage/PropagateCommand.js.html +1507 -0
  5. package/coverage/PushCommand.js.html +1504 -0
  6. package/coverage/ScanCommand.js.html +1654 -0
  7. package/coverage/UploadCommand.js.html +1846 -0
  8. package/coverage/WatchCommand.js.html +4111 -0
  9. package/coverage/base.css +224 -0
  10. package/coverage/block-navigation.js +87 -0
  11. package/coverage/favicon.png +0 -0
  12. package/coverage/index.html +191 -0
  13. package/coverage/lcov-report/IdentifyCommand.js.html +1462 -0
  14. package/coverage/lcov-report/PropagateCommand.js.html +1507 -0
  15. package/coverage/lcov-report/PushCommand.js.html +1504 -0
  16. package/coverage/lcov-report/ScanCommand.js.html +1654 -0
  17. package/coverage/lcov-report/UploadCommand.js.html +1846 -0
  18. package/coverage/lcov-report/WatchCommand.js.html +4111 -0
  19. package/coverage/lcov-report/base.css +224 -0
  20. package/coverage/lcov-report/block-navigation.js +87 -0
  21. package/coverage/lcov-report/favicon.png +0 -0
  22. package/coverage/lcov-report/index.html +191 -0
  23. package/coverage/lcov-report/prettify.css +1 -0
  24. package/coverage/lcov-report/prettify.js +2 -0
  25. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  26. package/coverage/lcov-report/sorter.js +210 -0
  27. package/coverage/lcov.info +1937 -0
  28. package/coverage/prettify.css +1 -0
  29. package/coverage/prettify.js +2 -0
  30. package/coverage/sort-arrow-sprite.png +0 -0
  31. package/coverage/sorter.js +210 -0
  32. package/docs/API_RETRY_MECHANISM.md +338 -0
  33. package/docs/ARELA_IDENTIFY_IMPLEMENTATION.md +489 -0
  34. package/docs/ARELA_IDENTIFY_QUICKREF.md +186 -0
  35. package/docs/ARELA_PROPAGATE_IMPLEMENTATION.md +581 -0
  36. package/docs/ARELA_PROPAGATE_QUICKREF.md +272 -0
  37. package/docs/ARELA_PUSH_IMPLEMENTATION.md +577 -0
  38. package/docs/ARELA_PUSH_QUICKREF.md +322 -0
  39. package/docs/ARELA_SCAN_IMPLEMENTATION.md +373 -0
  40. package/docs/ARELA_SCAN_QUICKREF.md +139 -0
  41. package/docs/CROSS_PLATFORM_PATH_HANDLING.md +593 -0
  42. package/docs/DETECTION_ATTEMPT_TRACKING.md +414 -0
  43. package/docs/MIGRATION_UPLOADER_TO_FILE_STATS.md +1020 -0
  44. package/docs/MULTI_LEVEL_DIRECTORY_SCANNING.md +494 -0
  45. package/docs/STATS_COMMAND_SEQUENCE_DIAGRAM.md +287 -0
  46. package/docs/STATS_COMMAND_SIMPLE.md +93 -0
  47. package/package.json +31 -3
  48. package/src/commands/IdentifyCommand.js +459 -0
  49. package/src/commands/PropagateCommand.js +474 -0
  50. package/src/commands/PushCommand.js +473 -0
  51. package/src/commands/ScanCommand.js +523 -0
  52. package/src/config/config.js +154 -7
  53. package/src/file-detection.js +9 -10
  54. package/src/index.js +150 -0
  55. package/src/services/ScanApiService.js +645 -0
  56. package/src/utils/PathNormalizer.js +220 -0
  57. package/tests/commands/IdentifyCommand.test.js +570 -0
  58. package/tests/commands/PropagateCommand.test.js +568 -0
  59. package/tests/commands/PushCommand.test.js +754 -0
  60. package/tests/commands/ScanCommand.test.js +382 -0
  61. package/tests/unit/PathAndTableNameGeneration.test.js +1211 -0
@@ -0,0 +1,139 @@
1
+ # Arela Scan Quick Reference
2
+
3
+ ## Setup
4
+
5
+ ### 1. Configure Backend
6
+
7
+ Add `cli_registry` entity to TypeORM and run migration:
8
+
9
+ ```bash
10
+ cd arela-api
11
+ npm run migration:generate -- -n CreateCliRegistry
12
+ npm run migration:run
13
+ ```
14
+
15
+ ### 2. Configure CLI
16
+
17
+ Set environment variables in `.env`:
18
+
19
+ ```bash
20
+ # Required
21
+ ARELA_COMPANY_SLUG=your_company
22
+ ARELA_SERVER_ID=server01
23
+ UPLOAD_BASE_PATH=/path/to/files
24
+ UPLOAD_SOURCES=2023|2024|2025
25
+
26
+ # Optional
27
+ ARELA_BASE_PATH_LABEL=data
28
+ SCAN_EXCLUDE_PATTERNS=.DS_Store,Thumbs.db,desktop.ini
29
+ SCAN_BATCH_SIZE=2000
30
+
31
+ # API Configuration
32
+ ARELA_API_URL=http://localhost:3010
33
+ ARELA_API_TOKEN=your-token
34
+ ```
35
+
36
+ ## Commands
37
+
38
+ ### Scan Filesystem
39
+
40
+ ```bash
41
+ # Basic scan with throughput display
42
+ arela scan
43
+
44
+ # Scan with percentage progress (counts files first)
45
+ arela scan --count-first
46
+
47
+ # Scan to specific API target
48
+ arela scan --api cliente
49
+ ```
50
+
51
+ ### View Scan Instances
52
+
53
+ ```bash
54
+ # List all registered instances
55
+ curl -H "x-api-key: $TOKEN" \
56
+ http://localhost:3010/api/uploader/scan/instances
57
+
58
+ # Get stale instances (no scan > 90 days)
59
+ curl -H "x-api-key: $TOKEN" \
60
+ "http://localhost:3010/api/uploader/scan/stale-instances?days=90"
61
+ ```
62
+
63
+ ### Deactivate Instance
64
+
65
+ ```bash
66
+ curl -X PATCH \
67
+ -H "x-api-key: $TOKEN" \
68
+ -H "Content-Type: application/json" \
69
+ -d '{"tableName":"file_stats_company_server_path"}' \
70
+ http://localhost:3010/api/uploader/scan/deactivate
71
+ ```
72
+
73
+ ## Files Modified
74
+
75
+ ### Backend
76
+
77
+ - ✅ `src/uploader/entities/cli-registry.entity.ts` - New entity
78
+ - ✅ `src/uploader/services/file-stats-table-manager.service.ts` - New service
79
+ - ✅ `src/uploader/services/uploader.service.ts` - Added scan methods
80
+ - ✅ `src/uploader/controllers/uploader.controller.ts` - Added scan endpoints
81
+ - ✅ `src/uploader/uploader.module.ts` - Updated imports
82
+
83
+ ### CLI
84
+
85
+ - ✅ `src/commands/ScanCommand.js` - New command
86
+ - ✅ `src/services/ScanApiService.js` - New API service
87
+ - ✅ `src/config/config.js` - Added scan configuration
88
+ - ✅ `src/index.js` - Registered scan command
89
+ - ✅ `.env.template` - Added scan variables
90
+ - ✅ `docs/ARELA_SCAN_IMPLEMENTATION.md` - Documentation
91
+
92
+ ## Table Schema
93
+
94
+ Each scan instance creates a table:
95
+
96
+ ```sql
97
+ file_stats_<company>_<server>_<path>
98
+ ├── id (uuid)
99
+ ├── file_name (varchar)
100
+ ├── file_extension (varchar)
101
+ ├── directory_path (text)
102
+ ├── relative_path (text)
103
+ ├── absolute_path (text) [unique]
104
+ ├── size_bytes (bigint)
105
+ ├── modified_at (timestamp)
106
+ ├── scan_timestamp (timestamp)
107
+ └── created_at (timestamp)
108
+ ```
109
+
110
+ ## Troubleshooting
111
+
112
+ ### Error: Missing configuration
113
+
114
+ **Cause**: Required env vars not set
115
+ **Fix**: Set `ARELA_COMPANY_SLUG` and `ARELA_SERVER_ID`
116
+
117
+ ### Error: Table name collision
118
+
119
+ **Cause**: Same identifiers used with different base path
120
+ **Fix**: Change server ID or base path label
121
+
122
+ ### Error: Cannot connect to API
123
+
124
+ **Cause**: Backend not running or wrong URL
125
+ **Fix**: Verify `ARELA_API_URL` and start backend
126
+
127
+ ## Next Steps
128
+
129
+ 1. ✅ Implement `arela scan` (DONE)
130
+ 2. ⏳ Implement `arela identify` (detect pedimentos from PDFs)
131
+ 3. ⏳ Implement `arela propagate` (propagate arela_path)
132
+ 4. ⏳ Implement `arela push` (upload files by RFC)
133
+
134
+ ## Performance Tips
135
+
136
+ - Increase `SCAN_BATCH_SIZE` for better throughput (default: 2000)
137
+ - Use `MAX_API_CONNECTIONS` to match backend replicas
138
+ - Run scans during off-peak hours for large datasets
139
+ - Use `--count-first` only when progress percentage is needed