configforge 1.0.0-beta.13 → 1.0.0-beta.14
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/README.md +225 -4
- package/dist/core/BatchProcessor.d.ts +48 -0
- package/dist/core/BatchProcessor.d.ts.map +1 -0
- package/dist/core/BatchProcessor.js +273 -0
- package/dist/core/BatchProcessor.js.map +1 -0
- package/dist/core/Converter.d.ts +24 -1
- package/dist/core/Converter.d.ts.map +1 -1
- package/dist/core/Converter.js +65 -2
- package/dist/core/Converter.js.map +1 -1
- package/dist/core/IncrementalProcessor.d.ts +75 -0
- package/dist/core/IncrementalProcessor.d.ts.map +1 -0
- package/dist/core/IncrementalProcessor.js +298 -0
- package/dist/core/IncrementalProcessor.js.map +1 -0
- package/dist/core/PerformanceMonitor.d.ts +103 -0
- package/dist/core/PerformanceMonitor.d.ts.map +1 -0
- package/dist/core/PerformanceMonitor.js +253 -0
- package/dist/core/PerformanceMonitor.js.map +1 -0
- package/dist/core/index.d.ts +3 -0
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +8 -1
- package/dist/core/index.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -862,7 +862,213 @@ console.log('Validation results:', result.context?.validationResults);
|
|
|
862
862
|
console.log('Backup created:', result.context?.backupPath);
|
|
863
863
|
```
|
|
864
864
|
|
|
865
|
-
### Example 10:
|
|
865
|
+
### Example 10: Batch Processing and Performance Features
|
|
866
|
+
|
|
867
|
+
```javascript
|
|
868
|
+
const {
|
|
869
|
+
forge,
|
|
870
|
+
BatchProcessor,
|
|
871
|
+
IncrementalProcessor,
|
|
872
|
+
PerformanceMonitor,
|
|
873
|
+
} = require('configforge');
|
|
874
|
+
|
|
875
|
+
// Create converter for processing multiple config files
|
|
876
|
+
const converter = forge()
|
|
877
|
+
.from('legacy-config')
|
|
878
|
+
.to('modern-config')
|
|
879
|
+
.map('app_name', 'application.name')
|
|
880
|
+
.map('app_version', 'application.version')
|
|
881
|
+
.map('database.host', 'db.hostname')
|
|
882
|
+
.map('database.port', 'db.port')
|
|
883
|
+
.map('server.port', 'application.port')
|
|
884
|
+
.defaults({
|
|
885
|
+
environment: 'production',
|
|
886
|
+
createdAt: () => new Date().toISOString(),
|
|
887
|
+
});
|
|
888
|
+
|
|
889
|
+
// 1. Batch Processing - Convert multiple files efficiently
|
|
890
|
+
const batchResult = await converter.convertBatch(
|
|
891
|
+
['./configs/app1.yml', './configs/app2.yml', './configs/app3.yml'],
|
|
892
|
+
{
|
|
893
|
+
parallel: true,
|
|
894
|
+
workers: 3,
|
|
895
|
+
errorStrategy: 'continue',
|
|
896
|
+
progressCallback: progress => {
|
|
897
|
+
console.log(`Progress: ${progress.completed}/${progress.total} files`);
|
|
898
|
+
},
|
|
899
|
+
}
|
|
900
|
+
);
|
|
901
|
+
|
|
902
|
+
console.log(
|
|
903
|
+
`Processed ${batchResult.stats.successfulFiles} files successfully`
|
|
904
|
+
);
|
|
905
|
+
console.log(`Failed: ${batchResult.stats.failedFiles} files`);
|
|
906
|
+
console.log(`Total duration: ${batchResult.stats.totalDuration}ms`);
|
|
907
|
+
|
|
908
|
+
// 2. Incremental Processing - Only process changed files
|
|
909
|
+
const incrementalResult = await converter.convertIncremental(
|
|
910
|
+
'./config.yml',
|
|
911
|
+
'./output/config.json',
|
|
912
|
+
'./.cache' // Cache directory
|
|
913
|
+
);
|
|
914
|
+
|
|
915
|
+
if (incrementalResult) {
|
|
916
|
+
console.log('File was processed (changed since last run)');
|
|
917
|
+
} else {
|
|
918
|
+
console.log('File skipped (no changes detected)');
|
|
919
|
+
}
|
|
920
|
+
|
|
921
|
+
// 3. Incremental Batch Processing
|
|
922
|
+
const incrementalBatchResult = await converter.convertIncrementalBatch(
|
|
923
|
+
['./configs/app1.yml', './configs/app2.yml', './configs/app3.yml'],
|
|
924
|
+
'./output',
|
|
925
|
+
{
|
|
926
|
+
cacheDir: './.cache',
|
|
927
|
+
getOutputPath: inputPath => {
|
|
928
|
+
const fileName = inputPath.split('/').pop().replace('.yml', '.json');
|
|
929
|
+
return `./output/${fileName}`;
|
|
930
|
+
},
|
|
931
|
+
}
|
|
932
|
+
);
|
|
933
|
+
|
|
934
|
+
console.log(`Processed: ${incrementalBatchResult.processed.length} files`);
|
|
935
|
+
console.log(
|
|
936
|
+
`Skipped: ${incrementalBatchResult.skipped.length} files (unchanged)`
|
|
937
|
+
);
|
|
938
|
+
|
|
939
|
+
// 4. Performance Monitoring
|
|
940
|
+
const monitor = new PerformanceMonitor();
|
|
941
|
+
monitor.start();
|
|
942
|
+
|
|
943
|
+
// Track individual steps
|
|
944
|
+
monitor.startStep('parse');
|
|
945
|
+
const result = await converter.convert('./large-config.yml');
|
|
946
|
+
monitor.endStep('parse');
|
|
947
|
+
|
|
948
|
+
// Record file sizes for throughput calculation
|
|
949
|
+
monitor.recordSizes(1024 * 1024, 800 * 1024); // 1MB input, 800KB output
|
|
950
|
+
|
|
951
|
+
// Get detailed performance metrics
|
|
952
|
+
const metrics = monitor.finish(result.stats);
|
|
953
|
+
const report = monitor.createReport(metrics);
|
|
954
|
+
|
|
955
|
+
console.log(report);
|
|
956
|
+
// === Performance Report ===
|
|
957
|
+
//
|
|
958
|
+
// Timing Breakdown:
|
|
959
|
+
// Parse: 15.23ms
|
|
960
|
+
// Map: 8.45ms
|
|
961
|
+
// Transform: 3.21ms
|
|
962
|
+
// Validate: 2.10ms
|
|
963
|
+
// Serialize: 5.67ms
|
|
964
|
+
// Total: 34.66ms
|
|
965
|
+
//
|
|
966
|
+
// Throughput:
|
|
967
|
+
// Fields/sec: 2890
|
|
968
|
+
// Transforms/sec: 1445
|
|
969
|
+
// Bytes/sec: 29.64 MB/s
|
|
970
|
+
//
|
|
971
|
+
// Memory Usage:
|
|
972
|
+
// Heap Used: 45.23 MB
|
|
973
|
+
// Heap Total: 67.89 MB
|
|
974
|
+
// RSS: 89.12 MB
|
|
975
|
+
//
|
|
976
|
+
// File Sizes:
|
|
977
|
+
// Input: 1.00 MB
|
|
978
|
+
// Output: 800.00 KB
|
|
979
|
+
// Ratio: 80.0%
|
|
980
|
+
|
|
981
|
+
// 5. Performance Benchmarking
|
|
982
|
+
const { PerformanceBenchmark } = require('configforge');
|
|
983
|
+
|
|
984
|
+
const sequentialOperation = async () => {
|
|
985
|
+
return converter.convertBatch(['./config1.yml', './config2.yml'], {
|
|
986
|
+
parallel: false,
|
|
987
|
+
});
|
|
988
|
+
};
|
|
989
|
+
|
|
990
|
+
const parallelOperation = async () => {
|
|
991
|
+
return converter.convertBatch(['./config1.yml', './config2.yml'], {
|
|
992
|
+
parallel: true,
|
|
993
|
+
workers: 2,
|
|
994
|
+
});
|
|
995
|
+
};
|
|
996
|
+
|
|
997
|
+
const benchmarks = [
|
|
998
|
+
{ name: 'sequential-processing', operation: sequentialOperation },
|
|
999
|
+
{ name: 'parallel-processing', operation: parallelOperation },
|
|
1000
|
+
];
|
|
1001
|
+
|
|
1002
|
+
const benchmarkResults = await PerformanceBenchmark.compareBenchmarks(
|
|
1003
|
+
benchmarks,
|
|
1004
|
+
10
|
|
1005
|
+
);
|
|
1006
|
+
const comparisonReport =
|
|
1007
|
+
PerformanceBenchmark.createComparisonReport(benchmarkResults);
|
|
1008
|
+
|
|
1009
|
+
console.log(comparisonReport);
|
|
1010
|
+
// === Benchmark Comparison ===
|
|
1011
|
+
//
|
|
1012
|
+
// Results (sorted by average time):
|
|
1013
|
+
// parallel-processing:
|
|
1014
|
+
// Average: 45.23ms (fastest)
|
|
1015
|
+
// Range: 42.10ms - 48.90ms
|
|
1016
|
+
// Std Dev: 2.15ms
|
|
1017
|
+
// Ops/sec: 22
|
|
1018
|
+
//
|
|
1019
|
+
// sequential-processing:
|
|
1020
|
+
// Average: 78.45ms (1.73x slower)
|
|
1021
|
+
// Range: 75.20ms - 82.10ms
|
|
1022
|
+
// Std Dev: 2.89ms
|
|
1023
|
+
// Ops/sec: 13
|
|
1024
|
+
|
|
1025
|
+
// 6. Advanced Batch Processing with Custom Options
|
|
1026
|
+
const advancedBatchResult = await converter.convertBatch(
|
|
1027
|
+
[
|
|
1028
|
+
'./configs/*.yml', // Glob patterns supported
|
|
1029
|
+
],
|
|
1030
|
+
{
|
|
1031
|
+
parallel: true,
|
|
1032
|
+
workers: 4,
|
|
1033
|
+
errorStrategy: 'fail-fast', // Stop on first error
|
|
1034
|
+
progressCallback: progress => {
|
|
1035
|
+
const percentage = Math.round(
|
|
1036
|
+
(progress.completed / progress.total) * 100
|
|
1037
|
+
);
|
|
1038
|
+
console.log(`[${percentage}%] Processing: ${progress.current}`);
|
|
1039
|
+
if (progress.failed > 0) {
|
|
1040
|
+
console.log(`⚠️ ${progress.failed} files failed`);
|
|
1041
|
+
}
|
|
1042
|
+
},
|
|
1043
|
+
}
|
|
1044
|
+
);
|
|
1045
|
+
|
|
1046
|
+
// Save all results to output directory
|
|
1047
|
+
const batchProcessor = new BatchProcessor(converter);
|
|
1048
|
+
await batchProcessor.saveBatch(advancedBatchResult.results, './output', [
|
|
1049
|
+
'./configs/app1.yml',
|
|
1050
|
+
'./configs/app2.yml',
|
|
1051
|
+
]);
|
|
1052
|
+
|
|
1053
|
+
// 7. Cache Management for Incremental Processing
|
|
1054
|
+
const incrementalProcessor = new IncrementalProcessor(converter, './.cache');
|
|
1055
|
+
|
|
1056
|
+
// Get cache statistics
|
|
1057
|
+
const cacheStats = incrementalProcessor.getCacheStats();
|
|
1058
|
+
console.log(`Cache entries: ${cacheStats.totalEntries}`);
|
|
1059
|
+
console.log(`Successful: ${cacheStats.successfulEntries}`);
|
|
1060
|
+
console.log(`Failed: ${cacheStats.failedEntries}`);
|
|
1061
|
+
|
|
1062
|
+
// Clean up stale cache entries
|
|
1063
|
+
const removedEntries = await incrementalProcessor.cleanupCache();
|
|
1064
|
+
console.log(`Removed ${removedEntries} stale cache entries`);
|
|
1065
|
+
|
|
1066
|
+
// Clear entire cache
|
|
1067
|
+
await incrementalProcessor.clearCache();
|
|
1068
|
+
console.log('Cache cleared');
|
|
1069
|
+
```
|
|
1070
|
+
|
|
1071
|
+
### Example 11: CLI Generation System
|
|
866
1072
|
|
|
867
1073
|
```javascript
|
|
868
1074
|
const { forge, CLIGenerator } = require('configforge');
|
|
@@ -924,9 +1130,12 @@ cli.parse();
|
|
|
924
1130
|
- ✅ **Conditional mapping**: Use `when()` for conditional logic
|
|
925
1131
|
- ✅ **Multi-field merging**: Use `merge()` to combine multiple sources into one target
|
|
926
1132
|
- ✅ **Default values**: Set fallback values
|
|
927
|
-
- ✅ **Comprehensive Error Handling**: Advanced error reporting with context and suggestions ⭐
|
|
928
|
-
- ✅ **CLI Generation System**: Create command-line interfaces for converters ⭐
|
|
929
|
-
- ✅ **Plugin System**: Extensible architecture with built-in plugins for validation, auditing, and backups ⭐
|
|
1133
|
+
- ✅ **Comprehensive Error Handling**: Advanced error reporting with context and suggestions ⭐ ENHANCED!
|
|
1134
|
+
- ✅ **CLI Generation System**: Create command-line interfaces for converters ⭐ ENHANCED!
|
|
1135
|
+
- ✅ **Plugin System**: Extensible architecture with built-in plugins for validation, auditing, and backups ⭐ ENHANCED!
|
|
1136
|
+
- ✅ **Batch Processing**: Efficiently process multiple files with parallel support and progress tracking ⭐ ENHANCED!
|
|
1137
|
+
- ✅ **Incremental Processing**: Only process changed files using content hashing and modification times ⭐ ENHANCED!
|
|
1138
|
+
- ✅ **Performance Monitoring**: Detailed performance tracking, benchmarking, and reporting ⭐ ENHANCED!
|
|
930
1139
|
- ✅ **File support**: Convert YAML, JSON files directly
|
|
931
1140
|
- ✅ **Statistics**: Get detailed conversion reports
|
|
932
1141
|
- ✅ **TypeScript**: Full type safety
|
|
@@ -947,6 +1156,9 @@ cli.parse();
|
|
|
947
1156
|
- **Advanced error handling and reporting system** ⭐ NEW!
|
|
948
1157
|
- **CLI generation system with command-line interfaces** ⭐ ENHANCED!
|
|
949
1158
|
- **Plugin system foundation with built-in plugins** ⭐ NEW!
|
|
1159
|
+
- **Batch processing with parallel support and progress tracking** ⭐ ENHANCED!
|
|
1160
|
+
- **Incremental processing with content hashing and modification times** ⭐ ENHANCED!
|
|
1161
|
+
- **Performance monitoring with detailed benchmarking and reporting** ⭐ ENHANCED!
|
|
950
1162
|
- File parsing (YAML, JSON)
|
|
951
1163
|
- Conversion statistics and reporting
|
|
952
1164
|
- Async and sync conversion support
|
|
@@ -984,6 +1196,15 @@ cli.parse();
|
|
|
984
1196
|
25. **Use built-in plugins** - leverage ValidationPlugin, AuditPlugin, and BackupPlugin for enhanced functionality
|
|
985
1197
|
26. **Plugin hooks execute in order** - plugins can intercept and modify data at different conversion stages
|
|
986
1198
|
27. **Error hooks provide recovery** - plugins can handle errors gracefully and provide fallback behavior
|
|
1199
|
+
28. **Use batch processing for multiple files** - `convertBatch()` processes multiple files efficiently with parallel support
|
|
1200
|
+
29. **Enable parallel processing** - set `parallel: true` and configure `workers` for faster batch processing
|
|
1201
|
+
30. **Use incremental processing** - `convertIncremental()` only processes files that have changed since last run
|
|
1202
|
+
31. **Monitor performance** - use `PerformanceMonitor` to track conversion speed, memory usage, and throughput
|
|
1203
|
+
32. **Benchmark different approaches** - use `PerformanceBenchmark` to compare sequential vs parallel processing
|
|
1204
|
+
33. **Configure error strategies** - use `errorStrategy: 'continue'` to process all files even if some fail, or `'fail-fast'` to stop on first error
|
|
1205
|
+
34. **Track progress** - provide `progressCallback` to monitor batch processing progress in real-time
|
|
1206
|
+
35. **Cache management** - use `IncrementalProcessor.getCacheStats()` and `cleanupCache()` to manage incremental processing cache
|
|
1207
|
+
36. **Save batch results** - use `BatchProcessor.saveBatch()` to save all conversion results to an output directory
|
|
987
1208
|
|
|
988
1209
|
---
|
|
989
1210
|
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { BatchOptions, BatchProgress, BatchResult, ConversionResult } from '../types';
|
|
2
|
+
import { Converter } from './Converter';
|
|
3
|
+
/**
|
|
4
|
+
* BatchProcessor handles efficient processing of multiple files
|
|
5
|
+
* with parallel processing support and progress tracking
|
|
6
|
+
*/
|
|
7
|
+
export declare class BatchProcessor {
|
|
8
|
+
private converter;
|
|
9
|
+
private options;
|
|
10
|
+
constructor(converter: Converter, options?: BatchOptions);
|
|
11
|
+
/**
|
|
12
|
+
* Process multiple files efficiently
|
|
13
|
+
*/
|
|
14
|
+
process(inputs: string[]): Promise<BatchResult>;
|
|
15
|
+
/**
|
|
16
|
+
* Process files sequentially
|
|
17
|
+
*/
|
|
18
|
+
private processSequentially;
|
|
19
|
+
/**
|
|
20
|
+
* Process files in parallel using worker threads or Promise.all
|
|
21
|
+
*/
|
|
22
|
+
private processInParallel;
|
|
23
|
+
/**
|
|
24
|
+
* Process a single file
|
|
25
|
+
*/
|
|
26
|
+
private processFile;
|
|
27
|
+
/**
|
|
28
|
+
* Create an empty batch result
|
|
29
|
+
*/
|
|
30
|
+
private createEmptyResult;
|
|
31
|
+
/**
|
|
32
|
+
* Split array into chunks
|
|
33
|
+
*/
|
|
34
|
+
private chunkArray;
|
|
35
|
+
/**
|
|
36
|
+
* Save batch results to files
|
|
37
|
+
*/
|
|
38
|
+
saveBatch(results: ConversionResult[], outputDir: string, inputPaths: string[]): Promise<void>;
|
|
39
|
+
/**
|
|
40
|
+
* Generate a progress report
|
|
41
|
+
*/
|
|
42
|
+
generateProgressReport(progress: BatchProgress): string;
|
|
43
|
+
/**
|
|
44
|
+
* Create a simple progress bar
|
|
45
|
+
*/
|
|
46
|
+
private createProgressBar;
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=BatchProcessor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BatchProcessor.d.ts","sourceRoot":"","sources":["../../src/core/BatchProcessor.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,aAAa,EACb,WAAW,EAEX,gBAAgB,EAGjB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAKxC;;;GAGG;AACH,qBAAa,cAAc;IACzB,OAAO,CAAC,SAAS,CAAY;IAC7B,OAAO,CAAC,OAAO,CAAyB;gBAE5B,SAAS,EAAE,SAAS,EAAE,OAAO,GAAE,YAAiB;IAU5D;;OAEG;IACG,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,WAAW,CAAC;IAyDrD;;OAEG;YACW,mBAAmB;IA2CjC;;OAEG;YACW,iBAAiB;IA4E/B;;OAEG;YACW,WAAW;IAwCzB;;OAEG;IACH,OAAO,CAAC,iBAAiB;IAczB;;OAEG;IACH,OAAO,CAAC,UAAU;IAQlB;;OAEG;IACG,SAAS,CACb,OAAO,EAAE,gBAAgB,EAAE,EAC3B,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,MAAM,EAAE,GACnB,OAAO,CAAC,IAAI,CAAC;IAyBhB;;OAEG;IACH,sBAAsB,CAAC,QAAQ,EAAE,aAAa,GAAG,MAAM;IAcvD;;OAEG;IACH,OAAO,CAAC,iBAAiB;CAK1B"}
|
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BatchProcessor = void 0;
|
|
4
|
+
const types_1 = require("../types");
|
|
5
|
+
const fs_1 = require("fs");
|
|
6
|
+
const path_1 = require("path");
|
|
7
|
+
const os_1 = require("os");
|
|
8
|
+
/**
|
|
9
|
+
* BatchProcessor handles efficient processing of multiple files
|
|
10
|
+
* with parallel processing support and progress tracking
|
|
11
|
+
*/
|
|
12
|
+
class BatchProcessor {
|
|
13
|
+
constructor(converter, options = {}) {
|
|
14
|
+
this.converter = converter;
|
|
15
|
+
this.options = {
|
|
16
|
+
parallel: options.parallel ?? true,
|
|
17
|
+
workers: options.workers ?? Math.min((0, os_1.cpus)().length, 4),
|
|
18
|
+
progressCallback: options.progressCallback ?? (() => { }),
|
|
19
|
+
errorStrategy: options.errorStrategy ?? 'continue',
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Process multiple files efficiently
|
|
24
|
+
*/
|
|
25
|
+
async process(inputs) {
|
|
26
|
+
const startTime = performance.now();
|
|
27
|
+
const results = [];
|
|
28
|
+
const errors = [];
|
|
29
|
+
if (inputs.length === 0) {
|
|
30
|
+
return this.createEmptyResult(startTime);
|
|
31
|
+
}
|
|
32
|
+
// Initialize progress tracking
|
|
33
|
+
const progress = {
|
|
34
|
+
total: inputs.length,
|
|
35
|
+
completed: 0,
|
|
36
|
+
failed: 0,
|
|
37
|
+
};
|
|
38
|
+
try {
|
|
39
|
+
if (this.options.parallel && inputs.length > 1) {
|
|
40
|
+
// Process files in parallel
|
|
41
|
+
const processedResults = await this.processInParallel(inputs, progress);
|
|
42
|
+
results.push(...processedResults.results);
|
|
43
|
+
errors.push(...processedResults.errors);
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
// Process files sequentially
|
|
47
|
+
const processedResults = await this.processSequentially(inputs, progress);
|
|
48
|
+
results.push(...processedResults.results);
|
|
49
|
+
errors.push(...processedResults.errors);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
catch (error) {
|
|
53
|
+
errors.push(new types_1.GenericConfigForgeError(`Batch processing failed: ${error instanceof Error ? error.message : 'Unknown error'}`));
|
|
54
|
+
}
|
|
55
|
+
// Calculate final statistics
|
|
56
|
+
const totalDuration = performance.now() - startTime;
|
|
57
|
+
const stats = {
|
|
58
|
+
totalFiles: inputs.length,
|
|
59
|
+
successfulFiles: results.filter(r => r.errors.length === 0).length,
|
|
60
|
+
failedFiles: results.filter(r => r.errors.length > 0).length + errors.length,
|
|
61
|
+
totalDuration,
|
|
62
|
+
averageDuration: results.length > 0 ? totalDuration / results.length : 0,
|
|
63
|
+
};
|
|
64
|
+
return {
|
|
65
|
+
results,
|
|
66
|
+
errors,
|
|
67
|
+
stats,
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Process files sequentially
|
|
72
|
+
*/
|
|
73
|
+
async processSequentially(inputs, progress) {
|
|
74
|
+
const results = [];
|
|
75
|
+
const errors = [];
|
|
76
|
+
for (const input of inputs) {
|
|
77
|
+
progress.current = input;
|
|
78
|
+
this.options.progressCallback(progress);
|
|
79
|
+
try {
|
|
80
|
+
const result = await this.processFile(input);
|
|
81
|
+
results.push(result);
|
|
82
|
+
if (result.errors.length > 0) {
|
|
83
|
+
progress.failed++;
|
|
84
|
+
if (this.options.errorStrategy === 'fail-fast') {
|
|
85
|
+
break;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
catch (error) {
|
|
90
|
+
const configError = error instanceof types_1.ConfigForgeError
|
|
91
|
+
? error
|
|
92
|
+
: new types_1.GenericConfigForgeError(`Failed to process ${input}: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
93
|
+
errors.push(configError);
|
|
94
|
+
progress.failed++;
|
|
95
|
+
if (this.options.errorStrategy === 'fail-fast') {
|
|
96
|
+
break;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
progress.completed++;
|
|
100
|
+
this.options.progressCallback(progress);
|
|
101
|
+
}
|
|
102
|
+
return { results, errors };
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Process files in parallel using worker threads or Promise.all
|
|
106
|
+
*/
|
|
107
|
+
async processInParallel(inputs, progress) {
|
|
108
|
+
const results = [];
|
|
109
|
+
const errors = [];
|
|
110
|
+
// For now, use Promise.all with concurrency limit instead of worker threads
|
|
111
|
+
// Worker threads would require serializing the converter configuration
|
|
112
|
+
const concurrency = Math.min(this.options.workers, inputs.length);
|
|
113
|
+
const chunks = this.chunkArray(inputs, Math.ceil(inputs.length / concurrency));
|
|
114
|
+
const chunkPromises = chunks.map(async (chunk) => {
|
|
115
|
+
const chunkResults = [];
|
|
116
|
+
const chunkErrors = [];
|
|
117
|
+
for (const input of chunk) {
|
|
118
|
+
progress.current = input;
|
|
119
|
+
this.options.progressCallback(progress);
|
|
120
|
+
try {
|
|
121
|
+
const result = await this.processFile(input);
|
|
122
|
+
chunkResults.push(result);
|
|
123
|
+
if (result.errors.length > 0) {
|
|
124
|
+
progress.failed++;
|
|
125
|
+
if (this.options.errorStrategy === 'fail-fast') {
|
|
126
|
+
throw new Error('Stopping due to fail-fast strategy');
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
catch (error) {
|
|
131
|
+
const configError = error instanceof types_1.ConfigForgeError
|
|
132
|
+
? error
|
|
133
|
+
: new types_1.GenericConfigForgeError(`Failed to process ${input}: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
134
|
+
chunkErrors.push(configError);
|
|
135
|
+
progress.failed++;
|
|
136
|
+
if (this.options.errorStrategy === 'fail-fast') {
|
|
137
|
+
throw error;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
progress.completed++;
|
|
141
|
+
this.options.progressCallback(progress);
|
|
142
|
+
}
|
|
143
|
+
return { results: chunkResults, errors: chunkErrors };
|
|
144
|
+
});
|
|
145
|
+
try {
|
|
146
|
+
const chunkResults = await Promise.all(chunkPromises);
|
|
147
|
+
for (const chunk of chunkResults) {
|
|
148
|
+
results.push(...chunk.results);
|
|
149
|
+
errors.push(...chunk.errors);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
catch (error) {
|
|
153
|
+
// Handle fail-fast scenario
|
|
154
|
+
if (this.options.errorStrategy === 'fail-fast') {
|
|
155
|
+
errors.push(new types_1.GenericConfigForgeError(`Batch processing stopped due to error: ${error instanceof Error ? error.message : 'Unknown error'}`));
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
return { results, errors };
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Process a single file
|
|
162
|
+
*/
|
|
163
|
+
async processFile(filePath) {
|
|
164
|
+
try {
|
|
165
|
+
// Check if file exists and is readable
|
|
166
|
+
await fs_1.promises.access(filePath, fs_1.promises.constants.R_OK);
|
|
167
|
+
// Convert the file
|
|
168
|
+
const result = await this.converter.convert(filePath);
|
|
169
|
+
return result;
|
|
170
|
+
}
|
|
171
|
+
catch (error) {
|
|
172
|
+
// Create a failed conversion result
|
|
173
|
+
const configError = error instanceof types_1.ConfigForgeError
|
|
174
|
+
? error
|
|
175
|
+
: new types_1.GenericConfigForgeError(`Failed to process file ${filePath}: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
176
|
+
// Return a result with the error
|
|
177
|
+
return {
|
|
178
|
+
data: {},
|
|
179
|
+
warnings: [],
|
|
180
|
+
unmapped: [],
|
|
181
|
+
errors: [configError],
|
|
182
|
+
stats: {
|
|
183
|
+
fieldsProcessed: 0,
|
|
184
|
+
fieldsMapped: 0,
|
|
185
|
+
fieldsUnmapped: 0,
|
|
186
|
+
fieldsWithDefaults: 0,
|
|
187
|
+
transformsApplied: 0,
|
|
188
|
+
validationErrors: 1,
|
|
189
|
+
duration: 0,
|
|
190
|
+
},
|
|
191
|
+
save: async () => { },
|
|
192
|
+
toJSON: () => '{}',
|
|
193
|
+
toYAML: () => '{}',
|
|
194
|
+
print: () => { },
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Create an empty batch result
|
|
200
|
+
*/
|
|
201
|
+
createEmptyResult(startTime) {
|
|
202
|
+
return {
|
|
203
|
+
results: [],
|
|
204
|
+
errors: [],
|
|
205
|
+
stats: {
|
|
206
|
+
totalFiles: 0,
|
|
207
|
+
successfulFiles: 0,
|
|
208
|
+
failedFiles: 0,
|
|
209
|
+
totalDuration: performance.now() - startTime,
|
|
210
|
+
averageDuration: 0,
|
|
211
|
+
},
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Split array into chunks
|
|
216
|
+
*/
|
|
217
|
+
chunkArray(array, chunkSize) {
|
|
218
|
+
const chunks = [];
|
|
219
|
+
for (let i = 0; i < array.length; i += chunkSize) {
|
|
220
|
+
chunks.push(array.slice(i, i + chunkSize));
|
|
221
|
+
}
|
|
222
|
+
return chunks;
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* Save batch results to files
|
|
226
|
+
*/
|
|
227
|
+
async saveBatch(results, outputDir, inputPaths) {
|
|
228
|
+
// Ensure output directory exists
|
|
229
|
+
await fs_1.promises.mkdir(outputDir, { recursive: true });
|
|
230
|
+
const savePromises = results.map(async (result, index) => {
|
|
231
|
+
if (index < inputPaths.length) {
|
|
232
|
+
const inputPath = inputPaths[index];
|
|
233
|
+
const fileName = inputPath
|
|
234
|
+
.split(/[/\\]/)
|
|
235
|
+
.pop()
|
|
236
|
+
?.replace(/\.[^/.]+$/, '') || `output_${index}`;
|
|
237
|
+
const outputPath = (0, path_1.join)(outputDir, `${fileName}.json`);
|
|
238
|
+
try {
|
|
239
|
+
await result.save(outputPath);
|
|
240
|
+
}
|
|
241
|
+
catch (error) {
|
|
242
|
+
console.warn(`Failed to save result for ${inputPath}:`, error);
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
});
|
|
246
|
+
await Promise.all(savePromises);
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* Generate a progress report
|
|
250
|
+
*/
|
|
251
|
+
generateProgressReport(progress) {
|
|
252
|
+
const percentage = Math.round((progress.completed / progress.total) * 100);
|
|
253
|
+
const bar = this.createProgressBar(percentage);
|
|
254
|
+
return [
|
|
255
|
+
`Progress: ${bar} ${percentage}%`,
|
|
256
|
+
`Files: ${progress.completed}/${progress.total}`,
|
|
257
|
+
`Failed: ${progress.failed}`,
|
|
258
|
+
progress.current ? `Current: ${progress.current}` : '',
|
|
259
|
+
]
|
|
260
|
+
.filter(Boolean)
|
|
261
|
+
.join(' | ');
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* Create a simple progress bar
|
|
265
|
+
*/
|
|
266
|
+
createProgressBar(percentage, width = 20) {
|
|
267
|
+
const filled = Math.round((percentage / 100) * width);
|
|
268
|
+
const empty = width - filled;
|
|
269
|
+
return `[${'█'.repeat(filled)}${' '.repeat(empty)}]`;
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
exports.BatchProcessor = BatchProcessor;
|
|
273
|
+
//# sourceMappingURL=BatchProcessor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BatchProcessor.js","sourceRoot":"","sources":["../../src/core/BatchProcessor.ts"],"names":[],"mappings":";;;AAAA,oCAQkB;AAElB,2BAAoC;AACpC,+BAA4B;AAC5B,2BAA0B;AAE1B;;;GAGG;AACH,MAAa,cAAc;IAIzB,YAAY,SAAoB,EAAE,UAAwB,EAAE;QAC1D,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,OAAO,GAAG;YACb,QAAQ,EAAE,OAAO,CAAC,QAAQ,IAAI,IAAI;YAClC,OAAO,EAAE,OAAO,CAAC,OAAO,IAAI,IAAI,CAAC,GAAG,CAAC,IAAA,SAAI,GAAE,CAAC,MAAM,EAAE,CAAC,CAAC;YACtD,gBAAgB,EAAE,OAAO,CAAC,gBAAgB,IAAI,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC;YACxD,aAAa,EAAE,OAAO,CAAC,aAAa,IAAI,UAAU;SACnD,CAAC;IACJ,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,OAAO,CAAC,MAAgB;QAC5B,MAAM,SAAS,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC;QACpC,MAAM,OAAO,GAAuB,EAAE,CAAC;QACvC,MAAM,MAAM,GAAuB,EAAE,CAAC;QAEtC,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACxB,OAAO,IAAI,CAAC,iBAAiB,CAAC,SAAS,CAAC,CAAC;QAC3C,CAAC;QAED,+BAA+B;QAC/B,MAAM,QAAQ,GAAkB;YAC9B,KAAK,EAAE,MAAM,CAAC,MAAM;YACpB,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AC9D,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,UAAU,GAAG,GAAG,CAAC,GAAG,KAAK,CAAC,CAAC;QACtD,MAAM,KAAK,GAAG,KAAK,GAAG,MAAM,CAAC;QAC7B,OAAO,IAAI,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC;IACvD,CAAC;CACF;AAvUD,wCAuUC"}
|
package/dist/core/Converter.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Schema, ParseOptions, Mapping, TransformFn, ValidatorFn, HookFn, ConversionResult, ForgeOptions, ConditionFn, MergeFn, ForEachFn } from '../types';
|
|
1
|
+
import { Schema, ParseOptions, Mapping, TransformFn, ValidatorFn, HookFn, ConversionResult, ForgeOptions, ConditionFn, MergeFn, ForEachFn, ConfigForgeError, BatchOptions, BatchResult } from '../types';
|
|
2
2
|
import { PluginManager } from '../plugins/PluginManager';
|
|
3
3
|
import { Plugin, PluginInstallResult } from '../plugins/Plugin';
|
|
4
4
|
/**
|
|
@@ -83,6 +83,25 @@ export declare class Converter<TSource = any, TTarget = any> {
|
|
|
83
83
|
* Convert input data - supports objects, file paths, or arrays of file paths
|
|
84
84
|
*/
|
|
85
85
|
convert(input: TSource | string | string[]): Promise<ConversionResult>;
|
|
86
|
+
/**
|
|
87
|
+
* Convert multiple files using batch processing
|
|
88
|
+
*/
|
|
89
|
+
convertBatch(inputs: string[], options?: BatchOptions): Promise<BatchResult>;
|
|
90
|
+
/**
|
|
91
|
+
* Convert files incrementally (only changed files)
|
|
92
|
+
*/
|
|
93
|
+
convertIncremental(inputPath: string, outputPath: string, cacheDir?: string): Promise<ConversionResult | null>;
|
|
94
|
+
/**
|
|
95
|
+
* Convert multiple files incrementally
|
|
96
|
+
*/
|
|
97
|
+
convertIncrementalBatch(inputPaths: string[], outputDir: string, options?: {
|
|
98
|
+
cacheDir?: string;
|
|
99
|
+
getOutputPath?: (inputPath: string) => string;
|
|
100
|
+
}): Promise<{
|
|
101
|
+
processed: ConversionResult[];
|
|
102
|
+
skipped: string[];
|
|
103
|
+
errors: ConfigForgeError[];
|
|
104
|
+
}>;
|
|
86
105
|
/**
|
|
87
106
|
* Synchronous conversion for objects only
|
|
88
107
|
*/
|
|
@@ -91,6 +110,10 @@ export declare class Converter<TSource = any, TTarget = any> {
|
|
|
91
110
|
* Load data from a file
|
|
92
111
|
*/
|
|
93
112
|
private loadFromFile;
|
|
113
|
+
/**
|
|
114
|
+
* Create a combined result from batch processing for backward compatibility
|
|
115
|
+
*/
|
|
116
|
+
private createCombinedResult;
|
|
94
117
|
/**
|
|
95
118
|
* Execute the core conversion logic using the Pipeline system
|
|
96
119
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Converter.d.ts","sourceRoot":"","sources":["../../src/core/Converter.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,MAAM,EACN,YAAY,EACZ,OAAO,EACP,WAAW,EACX,WAAW,EACX,MAAM,EACN,gBAAgB,EAChB,YAAY,EACZ,WAAW,EACX,OAAO,EACP,SAAS,
|
|
1
|
+
{"version":3,"file":"Converter.d.ts","sourceRoot":"","sources":["../../src/core/Converter.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,MAAM,EACN,YAAY,EACZ,OAAO,EACP,WAAW,EACX,WAAW,EACX,MAAM,EACN,gBAAgB,EAChB,YAAY,EACZ,WAAW,EACX,OAAO,EACP,SAAS,EAGT,gBAAgB,EAGhB,YAAY,EACZ,WAAW,EACZ,MAAM,UAAU,CAAC;AAOlB,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,MAAM,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAIhE;;GAEG;AACH,qBAAa,SAAS,CAAC,OAAO,GAAG,GAAG,EAAE,OAAO,GAAG,GAAG;IACjD,OAAO,CAAC,YAAY,CAAC,CAAS;IA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