@sinoia/hubdoc-tools 1.3.3 → 1.3.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.
- package/dist/index.d.ts +1 -1
- package/dist/plugins/alfresco/index.d.ts +26 -0
- package/dist/plugins/alfresco/index.d.ts.map +1 -0
- package/dist/plugins/alfresco/index.js +405 -0
- package/dist/plugins/alfresco/index.js.map +1 -0
- package/dist/plugins/alfresco/plugin.json +12 -0
- package/dist/plugins/aws-s3/index.d.ts +23 -0
- package/dist/plugins/aws-s3/index.d.ts.map +1 -0
- package/dist/plugins/aws-s3/index.js +383 -0
- package/dist/plugins/aws-s3/index.js.map +1 -0
- package/dist/plugins/aws-s3/plugin.json +12 -0
- package/dist/plugins/azure-blob/index.d.ts +23 -0
- package/dist/plugins/azure-blob/index.d.ts.map +1 -0
- package/dist/plugins/azure-blob/index.js +340 -0
- package/dist/plugins/azure-blob/index.js.map +1 -0
- package/dist/plugins/azure-blob/plugin.json +12 -0
- package/dist/plugins/box/index.d.ts +26 -0
- package/dist/plugins/box/index.d.ts.map +1 -0
- package/dist/plugins/box/index.js +387 -0
- package/dist/plugins/box/index.js.map +1 -0
- package/dist/plugins/box/plugin.json +12 -0
- package/dist/plugins/core/index.d.ts +25 -0
- package/dist/plugins/core/index.d.ts.map +1 -0
- package/dist/plugins/core/index.js +400 -0
- package/dist/plugins/core/index.js.map +1 -0
- package/dist/plugins/core/plugin.json +26 -0
- package/dist/plugins/dropbox/index.d.ts +27 -0
- package/dist/plugins/dropbox/index.d.ts.map +1 -0
- package/dist/plugins/dropbox/index.js +375 -0
- package/dist/plugins/dropbox/index.js.map +1 -0
- package/dist/plugins/dropbox/plugin.json +12 -0
- package/dist/plugins/filesystem/index.d.ts +22 -0
- package/dist/plugins/filesystem/index.d.ts.map +1 -0
- package/dist/plugins/filesystem/index.js +306 -0
- package/dist/plugins/filesystem/index.js.map +1 -0
- package/dist/plugins/filesystem/plugin.json +12 -0
- package/dist/plugins/googledrive/index.d.ts +27 -0
- package/dist/plugins/googledrive/index.d.ts.map +1 -0
- package/dist/plugins/googledrive/index.js +383 -0
- package/dist/plugins/googledrive/index.js.map +1 -0
- package/dist/plugins/googledrive/plugin.json +12 -0
- package/dist/plugins/nuxeo/index.d.ts +24 -0
- package/dist/plugins/nuxeo/index.d.ts.map +1 -0
- package/dist/plugins/nuxeo/index.js +405 -0
- package/dist/plugins/nuxeo/index.js.map +1 -0
- package/dist/plugins/nuxeo/plugin.json +12 -0
- package/dist/plugins/onedrive/index.d.ts +25 -0
- package/dist/plugins/onedrive/index.d.ts.map +1 -0
- package/dist/plugins/onedrive/index.js +362 -0
- package/dist/plugins/onedrive/index.js.map +1 -0
- package/dist/plugins/onedrive/plugin.json +12 -0
- package/dist/plugins/opentext/index.d.ts +26 -0
- package/dist/plugins/opentext/index.d.ts.map +1 -0
- package/dist/plugins/opentext/index.js +440 -0
- package/dist/plugins/opentext/index.js.map +1 -0
- package/dist/plugins/opentext/plugin.json +12 -0
- package/dist/plugins/sharepoint/index.d.ts +27 -0
- package/dist/plugins/sharepoint/index.d.ts.map +1 -0
- package/dist/plugins/sharepoint/index.js +397 -0
- package/dist/plugins/sharepoint/index.js.map +1 -0
- package/dist/plugins/sharepoint/plugin.json +12 -0
- package/dist/services/hubdoc-api.d.ts +1 -1
- package/dist/services/hubdoc-api.js +1 -1
- package/dist/services/oauth-token-service.d.ts +1 -1
- package/dist/services/oauth-token-service.js +2 -2
- package/dist/services/permission-manager.d.ts +1 -1
- package/dist/services/permission-manager.js +1 -1
- package/dist/src/types/plugins.d.ts +111 -0
- package/dist/src/types/plugins.d.ts.map +1 -0
- package/dist/src/types/plugins.js +3 -0
- package/dist/src/types/plugins.js.map +1 -0
- package/dist/src/utils/concurrent-processor.d.ts +63 -0
- package/dist/src/utils/concurrent-processor.d.ts.map +1 -0
- package/dist/src/utils/concurrent-processor.js +240 -0
- package/dist/src/utils/concurrent-processor.js.map +1 -0
- package/dist/src/utils/xml-metadata.d.ts +47 -0
- package/dist/src/utils/xml-metadata.d.ts.map +1 -0
- package/dist/src/utils/xml-metadata.js +200 -0
- package/dist/src/utils/xml-metadata.js.map +1 -0
- package/dist/types/index.d.ts +1 -1
- package/package.json +10 -2
- package/plugins/aws-s3/index.ts +2 -2
- package/plugins/sharepoint/index.ts +1 -1
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
export interface ConcurrentProcessorOptions {
|
|
2
|
+
concurrency: number;
|
|
3
|
+
onProgress?: (completed: number, total: number, current?: string) => void;
|
|
4
|
+
onError?: (error: Error, item: any, index: number) => void;
|
|
5
|
+
}
|
|
6
|
+
export interface ProcessingResult<T, R> {
|
|
7
|
+
results: R[];
|
|
8
|
+
errors: Array<{
|
|
9
|
+
item: T;
|
|
10
|
+
index: number;
|
|
11
|
+
error: Error;
|
|
12
|
+
}>;
|
|
13
|
+
totalProcessed: number;
|
|
14
|
+
successCount: number;
|
|
15
|
+
errorCount: number;
|
|
16
|
+
processingTime: number;
|
|
17
|
+
}
|
|
18
|
+
export declare class ConcurrentProcessor {
|
|
19
|
+
/**
|
|
20
|
+
* Process an array of items concurrently with limited parallelism
|
|
21
|
+
*/
|
|
22
|
+
static processInBatches<T, R>(items: T[], processor: (item: T, index: number) => Promise<R>, options: ConcurrentProcessorOptions): Promise<ProcessingResult<T, R>>;
|
|
23
|
+
/**
|
|
24
|
+
* Process items with automatic progress display
|
|
25
|
+
*/
|
|
26
|
+
static processWithProgress<T, R>(items: T[], processor: (item: T, index: number) => Promise<R>, options: {
|
|
27
|
+
concurrency: number;
|
|
28
|
+
operation: string;
|
|
29
|
+
itemName?: string;
|
|
30
|
+
}): Promise<ProcessingResult<T, R>>;
|
|
31
|
+
/**
|
|
32
|
+
* Create batches from an array
|
|
33
|
+
*/
|
|
34
|
+
static createBatches<T>(items: T[], batchSize: number): T[][];
|
|
35
|
+
/**
|
|
36
|
+
* Process items in sequential batches with concurrency within each batch
|
|
37
|
+
*/
|
|
38
|
+
static processInSequentialBatches<T, R>(items: T[], processor: (item: T, index: number) => Promise<R>, options: {
|
|
39
|
+
batchSize: number;
|
|
40
|
+
concurrencyPerBatch: number;
|
|
41
|
+
onBatchComplete?: (batchIndex: number, totalBatches: number) => void;
|
|
42
|
+
onProgress?: (completed: number, total: number) => void;
|
|
43
|
+
onError?: (error: Error, item: T, index: number) => void;
|
|
44
|
+
}): Promise<ProcessingResult<T, R>>;
|
|
45
|
+
/**
|
|
46
|
+
* Get a string description of an item for logging
|
|
47
|
+
*/
|
|
48
|
+
private static getItemDescription;
|
|
49
|
+
/**
|
|
50
|
+
* Utility to delay execution (for rate limiting)
|
|
51
|
+
*/
|
|
52
|
+
static delay(ms: number): Promise<void>;
|
|
53
|
+
/**
|
|
54
|
+
* Process with automatic retry on failure
|
|
55
|
+
*/
|
|
56
|
+
static processWithRetry<T, R>(items: T[], processor: (item: T, index: number, attempt: number) => Promise<R>, options: {
|
|
57
|
+
concurrency: number;
|
|
58
|
+
maxRetries?: number;
|
|
59
|
+
retryDelay?: number;
|
|
60
|
+
onProgress?: (completed: number, total: number) => void;
|
|
61
|
+
}): Promise<ProcessingResult<T, R>>;
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=concurrent-processor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"concurrent-processor.d.ts","sourceRoot":"","sources":["../../../src/utils/concurrent-processor.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,0BAA0B;IACzC,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IAC1E,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CAC5D;AAED,MAAM,WAAW,gBAAgB,CAAC,CAAC,EAAE,CA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AAO,CAAC,CAAC,CAAC,EACjD,OAAO,EAAE;QACP,SAAS,EAAE,MAAM,CAAC;QAClB,mBAAmB,EAAE,MAAM,CAAC;QAC5B,eAAe,CAAC,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,KAAK,IAAI,CAAC;QACrE,UAAU,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;QACxD,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;KAC1D,GACA,OAAO,CAAC,gBAAgB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAiElC;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,kBAAkB;IAejC;;OAEG;IACH,MAAM,CAAC,KAAK,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIvC;;OAEG;WACU,gBAAgB,CAAC,CAAC,EAAE,CAAC,EAChC,KAAK,EAAE,CAAC,EAAE,EACV,SAAS,EAAE,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC,CAAC,CAAC,EAClE,OAAO,EAAE;QACP,WAAW,EAAE,MAAM,CAAC;QACpB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,UAAU,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;KACzD,GACA,OAAO,CAAC,gBAAgB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;CA0BnC"}
|
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.ConcurrentProcessor = void 0;
|
|
7
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
8
|
+
class ConcurrentProcessor {
|
|
9
|
+
/**
|
|
10
|
+
* Process an array of items concurrently with limited parallelism
|
|
11
|
+
*/
|
|
12
|
+
static async processInBatches(items, processor, options) {
|
|
13
|
+
const { concurrency, onProgress, onError } = options;
|
|
14
|
+
const startTime = Date.now();
|
|
15
|
+
const results = new Array(items.length);
|
|
16
|
+
const errors = [];
|
|
17
|
+
let completed = 0;
|
|
18
|
+
let processing = 0;
|
|
19
|
+
let nextIndex = 0;
|
|
20
|
+
// Progress tracking
|
|
21
|
+
onProgress?.(0, items.length);
|
|
22
|
+
return new Promise((resolve) => {
|
|
23
|
+
const processNext = async () => {
|
|
24
|
+
if (nextIndex >= items.length) {
|
|
25
|
+
return; // No more items to process
|
|
26
|
+
}
|
|
27
|
+
const currentIndex = nextIndex++;
|
|
28
|
+
const item = items[currentIndex];
|
|
29
|
+
processing++;
|
|
30
|
+
try {
|
|
31
|
+
const result = await processor(item, currentIndex);
|
|
32
|
+
results[currentIndex] = result;
|
|
33
|
+
}
|
|
34
|
+
catch (error) {
|
|
35
|
+
const errorInfo = {
|
|
36
|
+
item,
|
|
37
|
+
index: currentIndex,
|
|
38
|
+
error: error
|
|
39
|
+
};
|
|
40
|
+
errors.push(errorInfo);
|
|
41
|
+
onError?.(error, item, currentIndex);
|
|
42
|
+
}
|
|
43
|
+
finally {
|
|
44
|
+
processing--;
|
|
45
|
+
completed++;
|
|
46
|
+
// Update progress
|
|
47
|
+
onProgress?.(completed, items.length, this.getItemDescription(item));
|
|
48
|
+
// Check if we can process more items
|
|
49
|
+
if (nextIndex < items.length && processing < concurrency) {
|
|
50
|
+
processNext();
|
|
51
|
+
}
|
|
52
|
+
// Check if we're done
|
|
53
|
+
if (completed === items.length) {
|
|
54
|
+
const processingTime = Date.now() - startTime;
|
|
55
|
+
resolve({
|
|
56
|
+
results,
|
|
57
|
+
errors,
|
|
58
|
+
totalProcessed: completed,
|
|
59
|
+
successCount: completed - errors.length,
|
|
60
|
+
errorCount: errors.length,
|
|
61
|
+
processingTime
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
// Start initial batch of workers
|
|
67
|
+
const initialWorkers = Math.min(concurrency, items.length);
|
|
68
|
+
for (let i = 0; i < initialWorkers; i++) {
|
|
69
|
+
processNext();
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Process items with automatic progress display
|
|
75
|
+
*/
|
|
76
|
+
static async processWithProgress(items, processor, options) {
|
|
77
|
+
const { concurrency, operation, itemName = 'items' } = options;
|
|
78
|
+
console.log(chalk_1.default.blue(`🚀 Starting ${operation.toLowerCase()} with ${concurrency} concurrent job${concurrency > 1 ? 's' : ''}...`));
|
|
79
|
+
let lastProgressTime = 0;
|
|
80
|
+
const startTime = Date.now();
|
|
81
|
+
const result = await this.processInBatches(items, processor, {
|
|
82
|
+
concurrency,
|
|
83
|
+
onProgress: (completed, total, current) => {
|
|
84
|
+
const now = Date.now();
|
|
85
|
+
// Throttle progress updates to avoid spam
|
|
86
|
+
if (now - lastProgressTime > 500 || completed === total) {
|
|
87
|
+
const percentage = Math.round((completed / total) * 100);
|
|
88
|
+
const elapsed = Math.round((now - startTime) / 1000);
|
|
89
|
+
const rate = elapsed > 0 ? Math.round(completed / elapsed) : 0;
|
|
90
|
+
let progressMsg = `📊 Progress: ${completed}/${total} ${itemName} (${percentage}%)`;
|
|
91
|
+
if (rate > 0) {
|
|
92
|
+
progressMsg += ` - ${rate}/s`;
|
|
93
|
+
}
|
|
94
|
+
if (current) {
|
|
95
|
+
progressMsg += ` - Current: ${current}`;
|
|
96
|
+
}
|
|
97
|
+
console.log(chalk_1.default.cyan(progressMsg));
|
|
98
|
+
lastProgressTime = now;
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
onError: (error, item, index) => {
|
|
102
|
+
const itemDesc = this.getItemDescription(item);
|
|
103
|
+
console.log(chalk_1.default.yellow(`⚠️ Error processing ${itemDesc}: ${error.message}`));
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
// Final summary
|
|
107
|
+
const duration = Math.round(result.processingTime / 1000);
|
|
108
|
+
const rate = duration > 0 ? Math.round(result.successCount / duration) : result.successCount;
|
|
109
|
+
console.log(chalk_1.default.green(`✅ ${operation} completed in ${duration}s`));
|
|
110
|
+
console.log(chalk_1.default.green(` • Success: ${result.successCount} ${itemName}`));
|
|
111
|
+
if (result.errorCount > 0) {
|
|
112
|
+
console.log(chalk_1.default.yellow(` • Errors: ${result.errorCount} ${itemName}`));
|
|
113
|
+
}
|
|
114
|
+
if (rate > 0) {
|
|
115
|
+
console.log(chalk_1.default.blue(` • Average rate: ${rate} ${itemName}/s`));
|
|
116
|
+
}
|
|
117
|
+
return result;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Create batches from an array
|
|
121
|
+
*/
|
|
122
|
+
static createBatches(items, batchSize) {
|
|
123
|
+
const batches = [];
|
|
124
|
+
for (let i = 0; i < items.length; i += batchSize) {
|
|
125
|
+
batches.push(items.slice(i, i + batchSize));
|
|
126
|
+
}
|
|
127
|
+
return batches;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Process items in sequential batches with concurrency within each batch
|
|
131
|
+
*/
|
|
132
|
+
static async processInSequentialBatches(items, processor, options) {
|
|
133
|
+
const { batchSize, concurrencyPerBatch, onBatchComplete, onProgress, onError } = options;
|
|
134
|
+
const batches = this.createBatches(items, batchSize);
|
|
135
|
+
const allResults = new Array(items.length);
|
|
136
|
+
const allErrors = [];
|
|
137
|
+
let totalCompleted = 0;
|
|
138
|
+
const startTime = Date.now();
|
|
139
|
+
for (let batchIndex = 0; batchIndex < batches.length; batchIndex++) {
|
|
140
|
+
const batch = batches[batchIndex];
|
|
141
|
+
const batchStartIndex = batchIndex * batchSize;
|
|
142
|
+
// Process batch with concurrency
|
|
143
|
+
const batchResult = await this.processInBatches(batch, async (item, batchRelativeIndex) => {
|
|
144
|
+
const globalIndex = batchStartIndex + batchRelativeIndex;
|
|
145
|
+
return processor(item, globalIndex);
|
|
146
|
+
}, {
|
|
147
|
+
concurrency: concurrencyPerBatch,
|
|
148
|
+
onProgress: (completed, total) => {
|
|
149
|
+
const globalCompleted = totalCompleted + completed;
|
|
150
|
+
onProgress?.(globalCompleted, items.length);
|
|
151
|
+
},
|
|
152
|
+
onError: (error, item, batchRelativeIndex) => {
|
|
153
|
+
const globalIndex = batchStartIndex + batchRelativeIndex;
|
|
154
|
+
onError?.(error, item, globalIndex);
|
|
155
|
+
}
|
|
156
|
+
});
|
|
157
|
+
// Merge results
|
|
158
|
+
for (let i = 0; i < batch.length; i++) {
|
|
159
|
+
const globalIndex = batchStartIndex + i;
|
|
160
|
+
if (batchResult.results[i] !== undefined) {
|
|
161
|
+
allResults[globalIndex] = batchResult.results[i];
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
// Merge errors with corrected indices
|
|
165
|
+
batchResult.errors.forEach(error => {
|
|
166
|
+
allErrors.push({
|
|
167
|
+
...error,
|
|
168
|
+
index: batchStartIndex + error.index
|
|
169
|
+
});
|
|
170
|
+
});
|
|
171
|
+
totalCompleted += batch.length;
|
|
172
|
+
onBatchComplete?.(batchIndex + 1, batches.length);
|
|
173
|
+
}
|
|
174
|
+
const processingTime = Date.now() - startTime;
|
|
175
|
+
return {
|
|
176
|
+
results: allResults,
|
|
177
|
+
errors: allErrors,
|
|
178
|
+
totalProcessed: items.length,
|
|
179
|
+
successCount: totalCompleted - allErrors.length,
|
|
180
|
+
errorCount: allErrors.length,
|
|
181
|
+
processingTime
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Get a string description of an item for logging
|
|
186
|
+
*/
|
|
187
|
+
static getItemDescription(item) {
|
|
188
|
+
if (!item)
|
|
189
|
+
return 'unknown';
|
|
190
|
+
// Try common properties for description
|
|
191
|
+
if (typeof item === 'string')
|
|
192
|
+
return item;
|
|
193
|
+
if (item.name)
|
|
194
|
+
return item.name;
|
|
195
|
+
if (item.fileName)
|
|
196
|
+
return item.fileName;
|
|
197
|
+
if (item.filePath)
|
|
198
|
+
return item.filePath.split('/').pop() || item.filePath;
|
|
199
|
+
if (item.documentName)
|
|
200
|
+
return item.documentName;
|
|
201
|
+
if (item.path)
|
|
202
|
+
return item.path;
|
|
203
|
+
if (item.id)
|
|
204
|
+
return item.id;
|
|
205
|
+
return 'item';
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Utility to delay execution (for rate limiting)
|
|
209
|
+
*/
|
|
210
|
+
static delay(ms) {
|
|
211
|
+
return new Promise(resolve => setTimeout(resolve, ms));
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Process with automatic retry on failure
|
|
215
|
+
*/
|
|
216
|
+
static async processWithRetry(items, processor, options) {
|
|
217
|
+
const { concurrency, maxRetries = 2, retryDelay = 1000, onProgress } = options;
|
|
218
|
+
const processorWithRetry = async (item, index) => {
|
|
219
|
+
let lastError;
|
|
220
|
+
for (let attempt = 0; attempt <= maxRetries; attempt++) {
|
|
221
|
+
try {
|
|
222
|
+
return await processor(item, index, attempt);
|
|
223
|
+
}
|
|
224
|
+
catch (error) {
|
|
225
|
+
lastError = error;
|
|
226
|
+
if (attempt < maxRetries) {
|
|
227
|
+
await this.delay(retryDelay * (attempt + 1)); // Exponential backoff
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
throw lastError;
|
|
232
|
+
};
|
|
233
|
+
return this.processInBatches(items, processorWithRetry, {
|
|
234
|
+
concurrency,
|
|
235
|
+
onProgress
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
exports.ConcurrentProcessor = ConcurrentProcessor;
|
|
240
|
+
//# sourceMappingURL=concurrent-processor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"concurrent-processor.js","sourceRoot":"","sources":["../../../src/utils/concurrent-processor.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAiB1B,MAAa,mBAAmB;IAC9B;;OAEG;IACH,MAAM,CAAC,KAAK,CAAC,gBAAgB,CAC3B,KAAU,EACV,SAAiD,EACjD,OAAmC;QAEnC,MAAM,EAAE,WAAW,EAAE,UAAU,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC;QACrD,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QAE7B,MAAM,OAAO,GAAQ,IAAI,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QAC7C,MAAM,MAAM,GAAoD,EAAE,CAAC;QAEnE,IAAI,SAAS,GAAG,CAAC,CAAC;QAClB,IAAI,UAAU,GAAG,CAAC,CAAC;QACnB,IAAI,SAAS,GAAG,CAAC,CAAC;QAElB,oBAAoB;QACpB,UAAU,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;QAE9B,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;YAC7B,MAAM,WAAW,GAAG,KAAK,IAAmB,EAAE;gBAC5C,IAAI,SAAS,IAAI,KAAK,CAAC,MAAM,EAAE,CAAC;oBAC9B,OAAO,CAAC,2BAA2B;gBACrC,CAAC;gBAED,MAAM,YAAY,GAAG,SAAS,EAAE,CAAC;gBACjC,MAAM,IAAI,GAAG,KAAK,CAAC,YAAY,CAAC,CAAC;gBACjC,UAAU,EAAE,CAAC;gBAEb,IAAI,CAAC;oBACH,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC;oBACnD,OAAO,CAAC,YAAY,CAAC,GAAG,MAAM,CAAC;gBAEjC,CAAC;gBAAC,OAAO,KAAK,EAAE,CAAC;oBACf,MAAM,SAA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D,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,KAAK,CAAC,gBAAgB,CAC3B,KAAU,EACV,SAAkE,EAClE,OAKC;QAED,MAAM,EAAE,WAAW,EAAE,UAAU,GAAG,CAAC,EAAE,UAAU,GAAG,IAAI,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC;QAE/E,MAAM,kBAAkB,GAAG,KAAK,EAAE,IAAO,EAAE,KAAa,EAAc,EAAE;YACtE,IAAI,SAAgB,CAAC;YAErB,KAAK,IAAI,OAAO,GAAG,CAAC,EAAE,OAAO,IAAI,UAAU,EAAE,OAAO,EAAE,EAAE,CAAC;gBACvD,IAAI,CAAC;oBACH,OAAO,MAAM,SAAS,CAAC,IAAI,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;gBAC/C,CAAC;gBAAC,OAAO,KAAK,EAAE,CAAC;oBACf,SAAS,GAAG,KAAc,CAAC;oBAE3B,IAAI,OAAO,GAAG,UAAU,EAAE,CAAC;wBACzB,MAAM,IAAI,CAAC,KAAK,CAAC,UAAU,GAAG,CAAC,OAAO,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,sBAAsB;oBACtE,CAAC;gBACH,CAAC;YACH,CAAC;YAED,MAAM,SAAU,CAAC;QACnB,CAAC,CAAC;QAEF,OAAO,IAAI,CAAC,gBAAgB,CAAC,KAAK,EAAE,kBAAkB,EAAE;YACtD,WAAW;YACX,UAAU;SACX,CAAC,CAAC;IACL,CAAC;CACF;AA1SD,kDA0SC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
export interface MetadataEntry {
|
|
2
|
+
label: string;
|
|
3
|
+
code: string;
|
|
4
|
+
value: string;
|
|
5
|
+
description?: string;
|
|
6
|
+
}
|
|
7
|
+
export interface ParsedMetadata {
|
|
8
|
+
[key: string]: string | Date | undefined;
|
|
9
|
+
}
|
|
10
|
+
export declare class XmlMetadataParser {
|
|
11
|
+
/**
|
|
12
|
+
* Find metadata XML file for a given document file
|
|
13
|
+
* Looks for files with pattern: {filename}_metadata.xml
|
|
14
|
+
*/
|
|
15
|
+
static findMetadataFile(documentPath: string): string | null;
|
|
16
|
+
/**
|
|
17
|
+
* Parse XML metadata file and extract structured metadata
|
|
18
|
+
*/
|
|
19
|
+
static parseMetadataFile(xmlPath: string): Promise<ParsedMetadata>;
|
|
20
|
+
/**
|
|
21
|
+
* Extract metadata from parsed XML structure
|
|
22
|
+
* Handles Excel XML format with metadata table
|
|
23
|
+
*/
|
|
24
|
+
private static extractMetadataFromXml;
|
|
25
|
+
/**
|
|
26
|
+
* Extract cell value from Excel XML cell structure
|
|
27
|
+
*/
|
|
28
|
+
private static getCellValue;
|
|
29
|
+
/**
|
|
30
|
+
* Convert string value to appropriate type (Date, number, etc.)
|
|
31
|
+
*/
|
|
32
|
+
private static convertValue;
|
|
33
|
+
/**
|
|
34
|
+
* Extract metadata from simple XML structure
|
|
35
|
+
*/
|
|
36
|
+
private static extractSimpleMetadata;
|
|
37
|
+
/**
|
|
38
|
+
* Flatten nested objects with dot notation
|
|
39
|
+
*/
|
|
40
|
+
private static flattenObject;
|
|
41
|
+
/**
|
|
42
|
+
* Get HubDoc-compatible metadata from parsed metadata
|
|
43
|
+
* Maps common fields to HubDoc expected names
|
|
44
|
+
*/
|
|
45
|
+
static getHubDocMetadata(metadata: ParsedMetadata): Record<string, any>;
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=xml-metadata.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"xml-metadata.d.ts","sourceRoot":"","sources":["../../../src/utils/xml-metadata.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,cAAc;IAC7B,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;CAC1C;AAED,qBAAa,iBAAiB;IAC5B;;;OAGG;IACH,MAAM,CAAC,gBAAgB,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI;IAsB5D;;OAEG;WACU,iBAAiB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC;IA2BxE;;;OAGG;IACH,OAAO,CAAC,MAAM,CAAC,sBAAsB;IA8CrC;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,YAAY;IAU3B;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,YAAY;IAe3B;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,qBAAqB;IAapC;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,aAAa;IAY5B;;;OAGG;IACH,MAAM,CAAC,iBAAiB,CAAC,QAAQ,EAAE,cAAc,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;CAqCxE"}
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.XmlMetadataParser = void 0;
|
|
7
|
+
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
9
|
+
const xml2js_1 = require("xml2js");
|
|
10
|
+
class XmlMetadataParser {
|
|
11
|
+
/**
|
|
12
|
+
* Find metadata XML file for a given document file
|
|
13
|
+
* Looks for files with pattern: {filename}_metadata.xml
|
|
14
|
+
*/
|
|
15
|
+
static findMetadataFile(documentPath) {
|
|
16
|
+
const dir = path_1.default.dirname(documentPath);
|
|
17
|
+
const filename = path_1.default.basename(documentPath, path_1.default.extname(documentPath));
|
|
18
|
+
// Common metadata file patterns
|
|
19
|
+
const patterns = [
|
|
20
|
+
`${filename}_metadata.xml`,
|
|
21
|
+
`${filename}.metadata.xml`,
|
|
22
|
+
`${filename}_meta.xml`,
|
|
23
|
+
`metadata_${filename}.xml`
|
|
24
|
+
];
|
|
25
|
+
for (const pattern of patterns) {
|
|
26
|
+
const metadataPath = path_1.default.join(dir, pattern);
|
|
27
|
+
if (fs_extra_1.default.existsSync(metadataPath)) {
|
|
28
|
+
return metadataPath;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Parse XML metadata file and extract structured metadata
|
|
35
|
+
*/
|
|
36
|
+
static async parseMetadataFile(xmlPath) {
|
|
37
|
+
try {
|
|
38
|
+
const xmlContent = await fs_extra_1.default.readFile(xmlPath, 'utf-8');
|
|
39
|
+
// Handle BOM if present
|
|
40
|
+
const cleanXml = xmlContent.replace(/^\uFEFF/, '');
|
|
41
|
+
return new Promise((resolve, reject) => {
|
|
42
|
+
(0, xml2js_1.parseString)(cleanXml, (err, result) => {
|
|
43
|
+
if (err) {
|
|
44
|
+
reject(err);
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
try {
|
|
48
|
+
const metadata = this.extractMetadataFromXml(result);
|
|
49
|
+
resolve(metadata);
|
|
50
|
+
}
|
|
51
|
+
catch (parseError) {
|
|
52
|
+
reject(parseError);
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
catch (error) {
|
|
58
|
+
throw new Error(`Failed to parse metadata file ${xmlPath}: ${error}`);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Extract metadata from parsed XML structure
|
|
63
|
+
* Handles Excel XML format with metadata table
|
|
64
|
+
*/
|
|
65
|
+
static extractMetadataFromXml(xmlObj) {
|
|
66
|
+
const metadata = {};
|
|
67
|
+
try {
|
|
68
|
+
// Handle Excel XML format
|
|
69
|
+
if (xmlObj.Workbook && xmlObj.Workbook.Worksheet) {
|
|
70
|
+
const worksheet = xmlObj.Workbook.Worksheet[0];
|
|
71
|
+
if (worksheet.Table && worksheet.Table[0].Row) {
|
|
72
|
+
const rows = worksheet.Table[0].Row;
|
|
73
|
+
// Skip header rows and extract data
|
|
74
|
+
for (let i = 2; i < rows.length; i++) { // Start from row 2 (skip headers)
|
|
75
|
+
const row = rows[i];
|
|
76
|
+
if (row.Cell && row.Cell.length >= 3) {
|
|
77
|
+
const cells = row.Cell;
|
|
78
|
+
const label = this.getCellValue(cells[0]);
|
|
79
|
+
const code = this.getCellValue(cells[1]);
|
|
80
|
+
const value = this.getCellValue(cells[2]);
|
|
81
|
+
if (code && value) {
|
|
82
|
+
// Convert to appropriate type
|
|
83
|
+
metadata[code] = this.convertValue(value);
|
|
84
|
+
// Also store with label as key if different from code
|
|
85
|
+
if (label && label !== code) {
|
|
86
|
+
metadata[label] = this.convertValue(value);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
// Handle simple XML metadata format
|
|
94
|
+
else if (xmlObj.metadata) {
|
|
95
|
+
this.extractSimpleMetadata(xmlObj.metadata, metadata);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
catch (error) {
|
|
99
|
+
console.warn('Failed to extract metadata from XML structure:', error);
|
|
100
|
+
}
|
|
101
|
+
return metadata;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Extract cell value from Excel XML cell structure
|
|
105
|
+
*/
|
|
106
|
+
static getCellValue(cell) {
|
|
107
|
+
if (!cell || !cell.Data || !cell.Data[0])
|
|
108
|
+
return undefined;
|
|
109
|
+
const data = cell.Data[0];
|
|
110
|
+
if (data.$?.Type === 'DateTime' && data._) {
|
|
111
|
+
return data._;
|
|
112
|
+
}
|
|
113
|
+
return data._ || data;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Convert string value to appropriate type (Date, number, etc.)
|
|
117
|
+
*/
|
|
118
|
+
static convertValue(value) {
|
|
119
|
+
// Ensure value is a string
|
|
120
|
+
if (typeof value !== 'string') {
|
|
121
|
+
return String(value);
|
|
122
|
+
}
|
|
123
|
+
// Try to parse as date
|
|
124
|
+
if (value.match(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}/)) {
|
|
125
|
+
return new Date(value);
|
|
126
|
+
}
|
|
127
|
+
// For numbers, keep as string to avoid type issues
|
|
128
|
+
return value;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Extract metadata from simple XML structure
|
|
132
|
+
*/
|
|
133
|
+
static extractSimpleMetadata(metadataObj, result) {
|
|
134
|
+
for (const [key, value] of Object.entries(metadataObj)) {
|
|
135
|
+
if (typeof value === 'string') {
|
|
136
|
+
result[key] = this.convertValue(value);
|
|
137
|
+
}
|
|
138
|
+
else if (Array.isArray(value) && value.length > 0) {
|
|
139
|
+
result[key] = this.convertValue(value[0]);
|
|
140
|
+
}
|
|
141
|
+
else if (typeof value === 'object' && value !== null) {
|
|
142
|
+
// Nested object - flatten with dot notation
|
|
143
|
+
this.flattenObject(value, result, key);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Flatten nested objects with dot notation
|
|
149
|
+
*/
|
|
150
|
+
static flattenObject(obj, result, prefix) {
|
|
151
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
152
|
+
const newKey = `${prefix}.${key}`;
|
|
153
|
+
if (typeof value === 'string') {
|
|
154
|
+
result[newKey] = this.convertValue(value);
|
|
155
|
+
}
|
|
156
|
+
else if (Array.isArray(value) && value.length > 0) {
|
|
157
|
+
result[newKey] = this.convertValue(value[0]);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Get HubDoc-compatible metadata from parsed metadata
|
|
163
|
+
* Maps common fields to HubDoc expected names
|
|
164
|
+
*/
|
|
165
|
+
static getHubDocMetadata(metadata) {
|
|
166
|
+
const hubdocMeta = {};
|
|
167
|
+
// Common field mappings
|
|
168
|
+
const fieldMappings = {
|
|
169
|
+
'title': ['TITLE', 'Titre', 'title', 'name'],
|
|
170
|
+
'author': ['AUTHOR', 'CREATOR', 'Auteur', 'Crée par', 'author', 'creator'],
|
|
171
|
+
'description': ['COMMENTAIRE', 'Commentaire', 'description', 'comment'],
|
|
172
|
+
'created': ['CREATIONDATE', 'Crée le', 'created', 'creationDate'],
|
|
173
|
+
'modified': ['MODIFICATIONDATE', 'Modifié le', 'modified', 'modificationDate'],
|
|
174
|
+
'status': ['STATUS', 'Etat', 'status', 'state'],
|
|
175
|
+
'type': ['TYPE', 'OBJECTTYPE', 'Type', 'Famille de documents', 'type'],
|
|
176
|
+
'reference': ['REFERENCE', 'CODE', 'Référence', 'Identifiant', 'reference', 'code'],
|
|
177
|
+
'project': ['PROJET', 'Projet-Opération', 'project'],
|
|
178
|
+
'phase': ['PHASE', 'Phase', 'phase'],
|
|
179
|
+
'version': ['VERSION', 'Indice', 'version'],
|
|
180
|
+
'zone': ['ZONE', 'Site-Zone', 'zone'],
|
|
181
|
+
'specialty': ['SPECIALITE', 'Spécialité-Lot', 'specialty']
|
|
182
|
+
};
|
|
183
|
+
// Map metadata to HubDoc fields
|
|
184
|
+
for (const [hubdocField, possibleKeys] of Object.entries(fieldMappings)) {
|
|
185
|
+
for (const key of possibleKeys) {
|
|
186
|
+
if (metadata[key] !== undefined) {
|
|
187
|
+
hubdocMeta[hubdocField] = metadata[key];
|
|
188
|
+
break;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
// Add all original metadata with prefix
|
|
193
|
+
for (const [key, value] of Object.entries(metadata)) {
|
|
194
|
+
hubdocMeta[`xml_${key}`] = value;
|
|
195
|
+
}
|
|
196
|
+
return hubdocMeta;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
exports.XmlMetadataParser = XmlMetadataParser;
|
|
200
|
+
//# sourceMapping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workspace } from '
|
|
1
|
+
import type { Folder, Document, BulkUpload, Workspace } from '@api/models';
|
|
2
2
|
export type { Folder, Document, BulkUpload, Workspace };
|
|
3
3
|
export type HubDocFolder = Folder;
|
|
4
4
|
export type HubDocDocument = Document;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sinoia/hubdoc-tools",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.5",
|
|
4
4
|
"description": "Professional command-line tool for HubDoc document management and bulk import/export",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -19,10 +19,18 @@
|
|
|
19
19
|
"require": "./dist/index.js",
|
|
20
20
|
"import": "./dist/index.js"
|
|
21
21
|
},
|
|
22
|
+
"./plugins/*": {
|
|
23
|
+
"types": "./dist/plugins/*/index.d.ts",
|
|
24
|
+
"require": "./dist/plugins/*/index.js",
|
|
25
|
+
"import": "./dist/plugins/*/index.js"
|
|
26
|
+
},
|
|
22
27
|
"./package.json": "./package.json"
|
|
23
28
|
},
|
|
24
29
|
"scripts": {
|
|
25
|
-
"build": "
|
|
30
|
+
"build": "npm run build:main && npm run build:plugins",
|
|
31
|
+
"build:main": "tsc --project tsconfig.main.json && tsc-alias",
|
|
32
|
+
"build:plugins": "tsc --project tsconfig.plugins.json && npm run copy:plugin-manifests",
|
|
33
|
+
"copy:plugin-manifests": "for dir in plugins/*/; do name=$(basename \"$dir\"); [ -f \"$dir/plugin.json\" ] && mkdir -p \"dist/plugins/$name\" && cp \"$dir/plugin.json\" \"dist/plugins/$name/\" || true; done",
|
|
26
34
|
"dev": "ts-node -r tsconfig-paths/register src/cli.ts",
|
|
27
35
|
"start": "node dist/cli.js",
|
|
28
36
|
"test": "jest",
|
package/plugins/aws-s3/index.ts
CHANGED
|
@@ -191,12 +191,12 @@ export default class S3Plugin implements DocumentSourcePlugin {
|
|
|
191
191
|
return pump();
|
|
192
192
|
};
|
|
193
193
|
await pump();
|
|
194
|
-
} else if (typeof response.Body.pipe === 'function') {
|
|
194
|
+
} else if (typeof (response.Body as any).pipe === 'function') {
|
|
195
195
|
// Node.js stream
|
|
196
196
|
(response.Body as any).pipe(writer);
|
|
197
197
|
} else {
|
|
198
198
|
// Buffer or Uint8Array
|
|
199
|
-
writer.write(response.Body as
|
|
199
|
+
writer.write(response.Body as any);
|
|
200
200
|
writer.end();
|
|
201
201
|
}
|
|
202
202
|
|
|
@@ -161,7 +161,7 @@ export default class SharePointPlugin implements DocumentSourcePlugin {
|
|
|
161
161
|
try {
|
|
162
162
|
do {
|
|
163
163
|
const url = nextLink || `/drives/${driveId}/items/${folderId}/children`;
|
|
164
|
-
const response = await this.apiClient.get(url, {
|
|
164
|
+
const response: any = await this.apiClient.get(url, {
|
|
165
165
|
params: nextLink ? {} : {
|
|
166
166
|
$expand: 'thumbnails',
|
|
167
167
|
$select: 'id,name,size,lastModifiedDateTime,createdDateTime,file,folder,createdBy,lastModifiedBy,parentReference,webUrl'
|