@learnosity/lib-qti-converter 0.12.1 → 0.12.2
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 +9 -3
- package/docs/GETTING_STARTED.md +10 -4
- package/docs/TAGS_TO_QTI_METADATA.md +291 -0
- package/docs/_sidebar.md +10 -9
- package/package.json +1 -1
- package/packages/cli/dist/batchProcessors-BfmvnTQ5.js +215 -0
- package/packages/cli/dist/batchProcessors-BfmvnTQ5.js.map +1 -0
- package/packages/cli/dist/batchWorker.js +1 -1
- package/packages/cli/dist/configOutput-FwkFyQmk.js +399 -0
- package/packages/cli/dist/configOutput-FwkFyQmk.js.map +1 -0
- package/packages/cli/dist/create-prompt-COXnAzFl.js +1387 -0
- package/packages/cli/dist/create-prompt-COXnAzFl.js.map +1 -0
- package/packages/cli/dist/dist-CVD-X-DZ.js +278 -0
- package/packages/cli/dist/dist-CVD-X-DZ.js.map +1 -0
- package/packages/cli/dist/learnosityToQti-sKxcj5Hi.js +102 -0
- package/packages/cli/dist/learnosityToQti-sKxcj5Hi.js.map +1 -0
- package/packages/cli/dist/learnosityToQtiPackage-Ij4cM39M.js +632 -0
- package/packages/cli/dist/learnosityToQtiPackage-Ij4cM39M.js.map +1 -0
- package/packages/cli/dist/main.js +32 -37131
- package/packages/cli/dist/main.js.map +1 -1
- package/packages/cli/dist/pathUtils-Cz2GpPEb.js +2386 -0
- package/packages/cli/dist/pathUtils-Cz2GpPEb.js.map +1 -0
- package/packages/cli/dist/qtiPackageToLearnosity-CvXdmwsb.js +354 -0
- package/packages/cli/dist/qtiPackageToLearnosity-CvXdmwsb.js.map +1 -0
- package/packages/cli/dist/qtiToLearnosity-CkD0r1q0.js +97 -0
- package/packages/cli/dist/qtiToLearnosity-CkD0r1q0.js.map +1 -0
- package/packages/cli/dist/resolveOptions-CfXUqGkd.js +31562 -0
- package/packages/cli/dist/resolveOptions-CfXUqGkd.js.map +1 -0
- package/packages/cli/dist/rolldown-runtime-B4iAMlE-.js +35 -0
- package/packages/cli/dist/{batchProcessors-B8EQvMbH.js → table-DYcNeyJ_.js} +906 -1150
- package/packages/cli/dist/table-DYcNeyJ_.js.map +1 -0
- package/packages/core/dist/index.js +3 -1
- package/packages/core/dist/node.js +3 -1
- package/packages/cli/dist/batchProcessors-B8EQvMbH.js.map +0 -1
|
@@ -0,0 +1,399 @@
|
|
|
1
|
+
import { basename, join, resolve, sep } from "path";
|
|
2
|
+
import { existsSync, readdirSync, statSync } from "fs";
|
|
3
|
+
import { Worker } from "node:worker_threads";
|
|
4
|
+
//#region src/utils/packageScanner.ts
|
|
5
|
+
/**
|
|
6
|
+
* Package scanning utilities for detecting QTI and Learnosity packages
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Detect if a directory is a QTI package
|
|
10
|
+
* A QTI package must contain an imsmanifest.xml file
|
|
11
|
+
*/
|
|
12
|
+
function isQtiPackage(dirPath) {
|
|
13
|
+
if (!existsSync(dirPath) || !statSync(dirPath).isDirectory()) return false;
|
|
14
|
+
const manifestPath = join(dirPath, "imsmanifest.xml");
|
|
15
|
+
return existsSync(manifestPath);
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Detect if a directory is a Learnosity bundle
|
|
19
|
+
* A Learnosity bundle must contain a manifest.json file
|
|
20
|
+
*/
|
|
21
|
+
function isLearnosityBundle(dirPath) {
|
|
22
|
+
if (!existsSync(dirPath) || !statSync(dirPath).isDirectory()) return false;
|
|
23
|
+
const manifestPath = join(dirPath, "manifest.json");
|
|
24
|
+
return existsSync(manifestPath);
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Detect package type for a directory
|
|
28
|
+
*/
|
|
29
|
+
function detectPackageType(dirPath) {
|
|
30
|
+
if (isQtiPackage(dirPath)) return "qti";
|
|
31
|
+
if (isLearnosityBundle(dirPath)) return "learnosity";
|
|
32
|
+
return "unknown";
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Scan a directory recursively for packages and detect their package types
|
|
36
|
+
*
|
|
37
|
+
* @param parentDir - Parent directory containing subdirectories to scan
|
|
38
|
+
* @param expectedType - Optional filter to only return packages of a specific type
|
|
39
|
+
* @returns Array of detected packages
|
|
40
|
+
*/
|
|
41
|
+
function scanForPackages(parentDir, expectedType) {
|
|
42
|
+
const packages = [];
|
|
43
|
+
if (!existsSync(parentDir)) return packages;
|
|
44
|
+
if (!statSync(parentDir).isDirectory()) return packages;
|
|
45
|
+
/**
|
|
46
|
+
* Recursively scan directories for packages
|
|
47
|
+
*
|
|
48
|
+
* @param currentDir - Directory being scanned
|
|
49
|
+
* @param relativeDir - Path of `currentDir` relative to `parentDir` ('' at the root)
|
|
50
|
+
*/
|
|
51
|
+
function scanRecursive(currentDir, relativeDir) {
|
|
52
|
+
const items = readdirSync(currentDir);
|
|
53
|
+
for (const item of items) {
|
|
54
|
+
const itemPath = join(currentDir, item);
|
|
55
|
+
const itemRelativePath = relativeDir ? join(relativeDir, item) : item;
|
|
56
|
+
try {
|
|
57
|
+
if (!statSync(itemPath).isDirectory()) continue;
|
|
58
|
+
} catch {
|
|
59
|
+
continue;
|
|
60
|
+
}
|
|
61
|
+
const type = detectPackageType(itemPath);
|
|
62
|
+
if (type !== "unknown") {
|
|
63
|
+
if (expectedType && type !== expectedType) continue;
|
|
64
|
+
packages.push({
|
|
65
|
+
path: itemPath,
|
|
66
|
+
name: basename(itemPath),
|
|
67
|
+
relativePath: itemRelativePath,
|
|
68
|
+
type
|
|
69
|
+
});
|
|
70
|
+
continue;
|
|
71
|
+
}
|
|
72
|
+
scanRecursive(itemPath, itemRelativePath);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
scanRecursive(parentDir, "");
|
|
76
|
+
return packages;
|
|
77
|
+
}
|
|
78
|
+
//#endregion
|
|
79
|
+
//#region src/utils/workerPool.ts
|
|
80
|
+
/**
|
|
81
|
+
* Minimal reusable worker_threads pool.
|
|
82
|
+
*
|
|
83
|
+
* Spawns up to `concurrency` long-lived workers, dispatches one task at a time
|
|
84
|
+
* to each idle worker, and resolves with results in the SAME order as the input
|
|
85
|
+
* tasks (deterministic) regardless of completion order. A worker error/crash
|
|
86
|
+
* fails only its in-flight task (via `onError`) and the worker is respawned if
|
|
87
|
+
* work remains, so one bad package can't sink the whole batch.
|
|
88
|
+
*/
|
|
89
|
+
/**
|
|
90
|
+
* Run `tasks` across a pool of workers. Each worker receives one task at a time
|
|
91
|
+
* as a message and posts back a single result message.
|
|
92
|
+
*/
|
|
93
|
+
function runPool(options) {
|
|
94
|
+
const { tasks, workerUrl, onError, onResult } = options;
|
|
95
|
+
const results = new Array(tasks.length);
|
|
96
|
+
if (tasks.length === 0) return Promise.resolve(results);
|
|
97
|
+
const poolSize = Math.max(1, Math.min(options.concurrency, tasks.length));
|
|
98
|
+
return new Promise((resolve) => {
|
|
99
|
+
let nextTaskIndex = 0;
|
|
100
|
+
let completed = 0;
|
|
101
|
+
const inFlight = /* @__PURE__ */ new Map();
|
|
102
|
+
const workers = /* @__PURE__ */ new Set();
|
|
103
|
+
const settleIfDone = () => {
|
|
104
|
+
if (completed === tasks.length) {
|
|
105
|
+
for (const worker of workers) worker.terminate();
|
|
106
|
+
resolve(results);
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
const recordResult = (index, result) => {
|
|
110
|
+
if (results[index] !== void 0) return;
|
|
111
|
+
results[index] = result;
|
|
112
|
+
if (onResult) onResult(index, tasks[index], result);
|
|
113
|
+
completed++;
|
|
114
|
+
settleIfDone();
|
|
115
|
+
};
|
|
116
|
+
const dispatchNext = (worker) => {
|
|
117
|
+
if (nextTaskIndex >= tasks.length) {
|
|
118
|
+
inFlight.delete(worker);
|
|
119
|
+
workers.delete(worker);
|
|
120
|
+
worker.terminate();
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
const index = nextTaskIndex++;
|
|
124
|
+
inFlight.set(worker, index);
|
|
125
|
+
worker.once("message", (result) => {
|
|
126
|
+
inFlight.delete(worker);
|
|
127
|
+
recordResult(index, result);
|
|
128
|
+
dispatchNext(worker);
|
|
129
|
+
});
|
|
130
|
+
worker.postMessage(tasks[index]);
|
|
131
|
+
};
|
|
132
|
+
const spawn = () => {
|
|
133
|
+
const worker = new Worker(workerUrl);
|
|
134
|
+
workers.add(worker);
|
|
135
|
+
worker.on("error", (err) => {
|
|
136
|
+
const index = inFlight.get(worker);
|
|
137
|
+
inFlight.delete(worker);
|
|
138
|
+
workers.delete(worker);
|
|
139
|
+
worker.terminate();
|
|
140
|
+
if (index !== void 0) recordResult(index, onError(tasks[index], err instanceof Error ? err : new Error(String(err))));
|
|
141
|
+
if (nextTaskIndex < tasks.length) spawn();
|
|
142
|
+
else settleIfDone();
|
|
143
|
+
});
|
|
144
|
+
dispatchNext(worker);
|
|
145
|
+
};
|
|
146
|
+
for (let i = 0; i < poolSize; i++) spawn();
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
//#endregion
|
|
150
|
+
//#region src/utils/batchProcessing.ts
|
|
151
|
+
/**
|
|
152
|
+
* Batch processing utilities for recursive directory conversion
|
|
153
|
+
*/
|
|
154
|
+
/**
|
|
155
|
+
* Resolve the output directory for a package, mirroring the input folder
|
|
156
|
+
* structure below the scanned root.
|
|
157
|
+
*
|
|
158
|
+
* A package found at `<input>/grade-3/maths/pkg-a` is written to
|
|
159
|
+
* `<output>/grade-3/maths/pkg-a`, so siblings with the same directory name in
|
|
160
|
+
* different subtrees no longer collide.
|
|
161
|
+
*
|
|
162
|
+
* Falls back to `pkg.name` when a scanner does not provide `relativePath`.
|
|
163
|
+
*/
|
|
164
|
+
function resolvePackageOutputPath(outputPath, pkg) {
|
|
165
|
+
const relativePath = pkg.relativePath ?? pkg.name;
|
|
166
|
+
const packageOutputPath = resolve(outputPath, relativePath);
|
|
167
|
+
const outputRoot = resolve(outputPath);
|
|
168
|
+
if (packageOutputPath !== outputRoot && !packageOutputPath.startsWith(outputRoot + sep)) throw new Error(`Package output path escapes the output directory: ${relativePath}`);
|
|
169
|
+
return join(outputPath, relativePath);
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Label used when reporting a package, preferring the path relative to the
|
|
173
|
+
* scanned root so nested packages are distinguishable.
|
|
174
|
+
*/
|
|
175
|
+
function packageLabel(pkg) {
|
|
176
|
+
return pkg.relativePath ?? pkg.name;
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Display batch processing summary
|
|
180
|
+
*/
|
|
181
|
+
function displayBatchSummary(summary, quiet = false) {
|
|
182
|
+
if (quiet) return;
|
|
183
|
+
console.log("\n" + "=".repeat(60));
|
|
184
|
+
console.log("Batch Conversion Summary");
|
|
185
|
+
console.log("=".repeat(60));
|
|
186
|
+
console.log(`Total packages: ${summary.total}`);
|
|
187
|
+
console.log(`✓ Succeeded: ${summary.succeeded}`);
|
|
188
|
+
console.log(`✗ Failed: ${summary.failed}`);
|
|
189
|
+
console.log(`⊘ Skipped: ${summary.skipped}`);
|
|
190
|
+
console.log("-".repeat(60));
|
|
191
|
+
console.log(`Total items: ${summary.totalConvertedItems + summary.totalFailedItems}`);
|
|
192
|
+
console.log(`✓ Converted: ${summary.totalConvertedItems}`);
|
|
193
|
+
console.log(`✗ Errored: ${summary.totalFailedItems}`);
|
|
194
|
+
console.log("=".repeat(60) + "\n");
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Generic batch processor that works for both conversion directions
|
|
198
|
+
*/
|
|
199
|
+
async function processBatch(config) {
|
|
200
|
+
const { inputPath, outputPath, packageType, processPackage, options, quiet = false, scanner = scanForPackages } = config;
|
|
201
|
+
const startTime = Date.now();
|
|
202
|
+
const packages = scanner(inputPath, packageType);
|
|
203
|
+
if (packages.length === 0) {
|
|
204
|
+
const typeLabel = packageType === "qti" ? "QTI packages" : "Learnosity bundles";
|
|
205
|
+
const manifestFile = packageType === "qti" ? "imsmanifest.xml" : "manifest.json";
|
|
206
|
+
console.error(`Error: No ${typeLabel} found in subdirectories.`);
|
|
207
|
+
console.error(`A ${packageType} package must contain a ${manifestFile} file.`);
|
|
208
|
+
process.exit(1);
|
|
209
|
+
}
|
|
210
|
+
if (!quiet) {
|
|
211
|
+
const typeLabel = packageType === "qti" ? "QTI package(s)" : "Learnosity bundle(s)";
|
|
212
|
+
console.log(`Found ${packages.length} ${typeLabel}:\n`);
|
|
213
|
+
packages.forEach((pkg, idx) => {
|
|
214
|
+
console.log(` ${idx + 1}. ${packageLabel(pkg)}`);
|
|
215
|
+
});
|
|
216
|
+
console.log("");
|
|
217
|
+
}
|
|
218
|
+
const summary = {
|
|
219
|
+
total: packages.length,
|
|
220
|
+
succeeded: 0,
|
|
221
|
+
failed: 0,
|
|
222
|
+
skipped: 0,
|
|
223
|
+
totalConvertedItems: 0,
|
|
224
|
+
totalFailedItems: 0,
|
|
225
|
+
packages: []
|
|
226
|
+
};
|
|
227
|
+
for (let i = 0; i < packages.length; i++) {
|
|
228
|
+
const pkg = packages[i];
|
|
229
|
+
const packageOutputPath = resolvePackageOutputPath(outputPath, pkg);
|
|
230
|
+
if (!quiet) {
|
|
231
|
+
console.log(`\n[${i + 1}/${packages.length}] Converting: ${packageLabel(pkg)}`);
|
|
232
|
+
console.log(` Input: ${pkg.path}`);
|
|
233
|
+
console.log(` Output: ${packageOutputPath}`);
|
|
234
|
+
console.log("");
|
|
235
|
+
}
|
|
236
|
+
try {
|
|
237
|
+
const result = await processPackage(pkg, packageOutputPath, options);
|
|
238
|
+
summary.totalConvertedItems += result.convertedItemCount ?? 0;
|
|
239
|
+
summary.totalFailedItems += result.failedItemCount ?? 0;
|
|
240
|
+
if (result.success) {
|
|
241
|
+
summary.succeeded++;
|
|
242
|
+
summary.packages.push({
|
|
243
|
+
name: packageLabel(pkg),
|
|
244
|
+
type: pkg.type,
|
|
245
|
+
status: "success",
|
|
246
|
+
errorCount: result.errorCount,
|
|
247
|
+
warningCount: result.warningCount
|
|
248
|
+
});
|
|
249
|
+
if (!quiet) console.log(` ✓ SUCCESS (${result.errorCount} error(s), ${result.warningCount} warning(s))`);
|
|
250
|
+
} else {
|
|
251
|
+
summary.failed++;
|
|
252
|
+
summary.packages.push({
|
|
253
|
+
name: packageLabel(pkg),
|
|
254
|
+
type: pkg.type,
|
|
255
|
+
status: "failed",
|
|
256
|
+
errorCount: result.errorCount,
|
|
257
|
+
warningCount: result.warningCount
|
|
258
|
+
});
|
|
259
|
+
if (!quiet) {
|
|
260
|
+
console.error(` ✗ FAILED (${result.errorCount} error(s))`);
|
|
261
|
+
if (result.message) console.error(` ${result.message}`);
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
} catch (error) {
|
|
265
|
+
summary.failed++;
|
|
266
|
+
summary.packages.push({
|
|
267
|
+
name: packageLabel(pkg),
|
|
268
|
+
type: pkg.type,
|
|
269
|
+
status: "failed",
|
|
270
|
+
errorCount: 1
|
|
271
|
+
});
|
|
272
|
+
if (!quiet) console.error(` ✗ FAILED: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
displayBatchSummary(summary, quiet);
|
|
276
|
+
const duration = ((Date.now() - startTime) / 1e3).toFixed(2);
|
|
277
|
+
if (!quiet) console.log(`Completed in ${duration}s\n`);
|
|
278
|
+
if (summary.failed > 0 && summary.succeeded === 0) process.exit(1);
|
|
279
|
+
return summary;
|
|
280
|
+
}
|
|
281
|
+
/**
|
|
282
|
+
* Parallel batch processor: converts packages across a pool of worker threads.
|
|
283
|
+
*
|
|
284
|
+
* Behaviour mirrors {@link processBatch} — same scan, summary shape, console
|
|
285
|
+
* summary and exit code — but per-package conversion runs on worker threads so
|
|
286
|
+
* multiple cores are used. Results are aggregated in package order for a
|
|
287
|
+
* deterministic summary.
|
|
288
|
+
*/
|
|
289
|
+
async function processBatchParallel(config) {
|
|
290
|
+
const { inputPath, outputPath, packageType, direction, options, concurrency, quiet = false, scanner = scanForPackages, workerUrl = new URL("./batchWorker.js", import.meta.url) } = config;
|
|
291
|
+
const startTime = Date.now();
|
|
292
|
+
const packages = scanner(inputPath, packageType);
|
|
293
|
+
if (packages.length === 0) {
|
|
294
|
+
const typeLabel = packageType === "qti" ? "QTI packages" : "Learnosity bundles";
|
|
295
|
+
const manifestFile = packageType === "qti" ? "imsmanifest.xml" : "manifest.json";
|
|
296
|
+
console.error(`Error: No ${typeLabel} found in subdirectories.`);
|
|
297
|
+
console.error(`A ${packageType} package must contain a ${manifestFile} file.`);
|
|
298
|
+
process.exit(1);
|
|
299
|
+
}
|
|
300
|
+
if (!quiet) {
|
|
301
|
+
const typeLabel = packageType === "qti" ? "QTI package(s)" : "Learnosity bundle(s)";
|
|
302
|
+
console.log(`Found ${packages.length} ${typeLabel} (converting with ${Math.min(concurrency, packages.length)} workers):\n`);
|
|
303
|
+
packages.forEach((pkg, idx) => {
|
|
304
|
+
console.log(` ${idx + 1}. ${packageLabel(pkg)}`);
|
|
305
|
+
});
|
|
306
|
+
console.log("");
|
|
307
|
+
}
|
|
308
|
+
const tasks = packages.map((pkg) => ({
|
|
309
|
+
direction,
|
|
310
|
+
pkg,
|
|
311
|
+
packageOutputPath: resolvePackageOutputPath(outputPath, pkg),
|
|
312
|
+
options
|
|
313
|
+
}));
|
|
314
|
+
const results = await runPool({
|
|
315
|
+
tasks,
|
|
316
|
+
workerUrl,
|
|
317
|
+
concurrency,
|
|
318
|
+
onError: (_task, error) => ({
|
|
319
|
+
success: false,
|
|
320
|
+
errorCount: 1,
|
|
321
|
+
warningCount: 0,
|
|
322
|
+
message: error.message
|
|
323
|
+
}),
|
|
324
|
+
onResult: (index, task, result) => {
|
|
325
|
+
if (quiet) return;
|
|
326
|
+
if (result.success) console.log(` ✓ [${index + 1}/${tasks.length}] ${packageLabel(task.pkg)} (${result.errorCount} error(s), ${result.warningCount} warning(s))`);
|
|
327
|
+
else console.error(` ✗ [${index + 1}/${tasks.length}] ${packageLabel(task.pkg)} FAILED (${result.errorCount} error(s))${result.message ? `: ${result.message}` : ""}`);
|
|
328
|
+
}
|
|
329
|
+
});
|
|
330
|
+
const summary = {
|
|
331
|
+
total: packages.length,
|
|
332
|
+
succeeded: 0,
|
|
333
|
+
failed: 0,
|
|
334
|
+
skipped: 0,
|
|
335
|
+
totalConvertedItems: 0,
|
|
336
|
+
totalFailedItems: 0,
|
|
337
|
+
packages: []
|
|
338
|
+
};
|
|
339
|
+
for (let i = 0; i < packages.length; i++) {
|
|
340
|
+
const pkg = packages[i];
|
|
341
|
+
const result = results[i];
|
|
342
|
+
summary.totalConvertedItems += result.convertedItemCount ?? 0;
|
|
343
|
+
summary.totalFailedItems += result.failedItemCount ?? 0;
|
|
344
|
+
if (result.success) {
|
|
345
|
+
summary.succeeded++;
|
|
346
|
+
summary.packages.push({
|
|
347
|
+
name: packageLabel(pkg),
|
|
348
|
+
type: pkg.type,
|
|
349
|
+
status: "success",
|
|
350
|
+
errorCount: result.errorCount,
|
|
351
|
+
warningCount: result.warningCount
|
|
352
|
+
});
|
|
353
|
+
} else {
|
|
354
|
+
summary.failed++;
|
|
355
|
+
summary.packages.push({
|
|
356
|
+
name: packageLabel(pkg),
|
|
357
|
+
type: pkg.type,
|
|
358
|
+
status: "failed",
|
|
359
|
+
errorCount: result.errorCount,
|
|
360
|
+
warningCount: result.warningCount
|
|
361
|
+
});
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
displayBatchSummary(summary, quiet);
|
|
365
|
+
const duration = ((Date.now() - startTime) / 1e3).toFixed(2);
|
|
366
|
+
if (!quiet) console.log(`Completed in ${duration}s\n`);
|
|
367
|
+
if (summary.failed > 0 && summary.succeeded === 0) process.exit(1);
|
|
368
|
+
return summary;
|
|
369
|
+
}
|
|
370
|
+
//#endregion
|
|
371
|
+
//#region src/utils/configOutput.ts
|
|
372
|
+
/**
|
|
373
|
+
* Display a configuration block with consistent formatting
|
|
374
|
+
*/
|
|
375
|
+
function displayConfiguration(fields, options = {}) {
|
|
376
|
+
if (options.quiet) return;
|
|
377
|
+
console.log("\nConfiguration:");
|
|
378
|
+
for (const field of fields) {
|
|
379
|
+
const indent = field.indent ?? 0;
|
|
380
|
+
const padding = " " + " ".repeat(indent * 2);
|
|
381
|
+
const label = field.label.padEnd(14 - indent * 2, " ");
|
|
382
|
+
console.log(`${padding}${label}${field.value}`);
|
|
383
|
+
}
|
|
384
|
+
console.log("");
|
|
385
|
+
}
|
|
386
|
+
/**
|
|
387
|
+
* Helper to create a config field
|
|
388
|
+
*/
|
|
389
|
+
function configField(label, value, indent = 0) {
|
|
390
|
+
return {
|
|
391
|
+
label,
|
|
392
|
+
value,
|
|
393
|
+
indent
|
|
394
|
+
};
|
|
395
|
+
}
|
|
396
|
+
//#endregion
|
|
397
|
+
export { processBatchParallel as i, displayConfiguration as n, processBatch as r, configField as t };
|
|
398
|
+
|
|
399
|
+
//# sourceMappingURL=configOutput-FwkFyQmk.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"configOutput-FwkFyQmk.js","names":[],"sources":["../src/utils/packageScanner.ts","../src/utils/workerPool.ts","../src/utils/batchProcessing.ts","../src/utils/configOutput.ts"],"sourcesContent":["/**\n * Package scanning utilities for detecting QTI and Learnosity packages\n */\n\nimport { existsSync, statSync, readdirSync } from 'fs';\nimport { join, basename } from 'path';\n\n/**\n * Package type detection result\n */\nexport type PackageType = 'qti' | 'learnosity' | 'unknown';\n\n/**\n * Detected package information\n */\nexport interface DetectedPackage {\n /** Absolute path to the package directory */\n path: string;\n /** Package directory name */\n name: string;\n /**\n * Path to the package relative to the scanned root directory, e.g.\n * `grade-3/maths/package-a`. Used to mirror the input folder structure in\n * the output directory. Equals `name` for packages directly under the root.\n *\n * Optional so custom scanners can omit it; consumers fall back to `name`.\n */\n relativePath?: string;\n /** Detected package type */\n type: PackageType;\n}\n\n/**\n * Detect if a directory is a QTI package\n * A QTI package must contain an imsmanifest.xml file\n */\nexport function isQtiPackage(dirPath: string): boolean {\n if (!existsSync(dirPath) || !statSync(dirPath).isDirectory()) {\n return false;\n }\n\n // dirPath is a directory the operator pointed the CLI at; the filename is a\n // literal, so this join cannot traverse anywhere the caller did not ask for.\n // nosemgrep: javascript.lang.security.audit.path-traversal.path-join-resolve-traversal, javascript.lang.security.audit.path-traversal.path-join-resolve-traversal.path-join-resolve-traversal\n const manifestPath = join(dirPath, 'imsmanifest.xml');\n\n return existsSync(manifestPath);\n}\n\n/**\n * Detect if a directory is a Learnosity bundle\n * A Learnosity bundle must contain a manifest.json file\n */\nexport function isLearnosityBundle(dirPath: string): boolean {\n if (!existsSync(dirPath) || !statSync(dirPath).isDirectory()) {\n return false;\n }\n\n // Same as isQtiPackage: operator-supplied directory plus a literal filename.\n // nosemgrep: javascript.lang.security.audit.path-traversal.path-join-resolve-traversal, javascript.lang.security.audit.path-traversal.path-join-resolve-traversal.path-join-resolve-traversal\n const manifestPath = join(dirPath, 'manifest.json');\n\n return existsSync(manifestPath);\n}\n\n/**\n * Detect package type for a directory\n */\nexport function detectPackageType(dirPath: string): PackageType {\n if (isQtiPackage(dirPath)) {\n return 'qti';\n }\n if (isLearnosityBundle(dirPath)) {\n return 'learnosity';\n }\n\n return 'unknown';\n}\n\n/**\n * Scan a directory recursively for packages and detect their package types\n *\n * @param parentDir - Parent directory containing subdirectories to scan\n * @param expectedType - Optional filter to only return packages of a specific type\n * @returns Array of detected packages\n */\nexport function scanForPackages(parentDir: string, expectedType?: PackageType): DetectedPackage[] {\n const packages: DetectedPackage[] = [];\n\n if (!existsSync(parentDir)) {\n return packages;\n }\n\n const stat = statSync(parentDir);\n\n if (!stat.isDirectory()) {\n return packages;\n }\n\n /**\n * Recursively scan directories for packages\n *\n * @param currentDir - Directory being scanned\n * @param relativeDir - Path of `currentDir` relative to `parentDir` ('' at the root)\n */\n function scanRecursive(currentDir: string, relativeDir: string): void {\n // Read all items in the current directory\n const items = readdirSync(currentDir);\n\n for (const item of items) {\n // item comes from readdirSync, so it is a single existing directory\n // entry name and cannot contain separators or traversal segments.\n // nosemgrep: javascript.lang.security.audit.path-traversal.path-join-resolve-traversal, javascript.lang.security.audit.path-traversal.path-join-resolve-traversal.path-join-resolve-traversal\n const itemPath = join(currentDir, item);\n\n // relativeDir is built from earlier readdirSync entry names and item is\n // a single entry name, so this label cannot escape the scanned root.\n // nosemgrep: javascript.lang.security.audit.path-traversal.path-join-resolve-traversal, javascript.lang.security.audit.path-traversal.path-join-resolve-traversal.path-join-resolve-traversal\n const itemRelativePath = relativeDir ? join(relativeDir, item) : item;\n\n // Skip non-directories\n try {\n if (!statSync(itemPath).isDirectory()) {\n continue;\n }\n } catch {\n // Skip items that can't be accessed (permissions, broken symlinks, etc.)\n continue;\n }\n\n // Detect package type\n const type = detectPackageType(itemPath);\n\n // If this directory is a package, add it and don't recurse into it\n if (type !== 'unknown') {\n // Skip if type doesn't match expected type (if specified)\n if (expectedType && type !== expectedType) {\n continue;\n }\n\n packages.push({\n path: itemPath,\n name: basename(itemPath),\n relativePath: itemRelativePath,\n type,\n });\n\n // Don't recurse into package directories\n continue;\n }\n\n // If not a package, recurse into subdirectories\n scanRecursive(itemPath, itemRelativePath);\n }\n }\n\n scanRecursive(parentDir, '');\n\n return packages;\n}\n","/**\n * Minimal reusable worker_threads pool.\n *\n * Spawns up to `concurrency` long-lived workers, dispatches one task at a time\n * to each idle worker, and resolves with results in the SAME order as the input\n * tasks (deterministic) regardless of completion order. A worker error/crash\n * fails only its in-flight task (via `onError`) and the worker is respawned if\n * work remains, so one bad package can't sink the whole batch.\n */\n\nimport { Worker } from 'node:worker_threads';\n\nexport interface RunPoolOptions<TTask, TResult> {\n /** Tasks to process (results are returned in this order). */\n tasks: TTask[];\n /** URL/path of the worker module. */\n workerUrl: URL | string;\n /** Max concurrent workers (clamped to [1, tasks.length]). */\n concurrency: number;\n /** Map a worker error/crash to a result for the failing task. */\n onError: (task: TTask, error: Error) => TResult;\n /** Optional callback fired as each task completes (for progress). */\n onResult?: (index: number, task: TTask, result: TResult) => void;\n}\n\n/**\n * Run `tasks` across a pool of workers. Each worker receives one task at a time\n * as a message and posts back a single result message.\n */\nexport function runPool<TTask, TResult>(options: RunPoolOptions<TTask, TResult>): Promise<TResult[]> {\n const { tasks, workerUrl, onError, onResult } = options;\n const results = new Array<TResult>(tasks.length);\n\n if (tasks.length === 0) {\n return Promise.resolve(results);\n }\n\n const poolSize = Math.max(1, Math.min(options.concurrency, tasks.length));\n\n return new Promise<TResult[]>((resolve) => {\n let nextTaskIndex = 0;\n let completed = 0;\n const inFlight = new Map<Worker, number>();\n const workers = new Set<Worker>();\n\n const settleIfDone = (): void => {\n if (completed === tasks.length) {\n for (const worker of workers) {\n void worker.terminate();\n }\n resolve(results);\n }\n };\n\n const recordResult = (index: number, result: TResult): void => {\n if (results[index] !== undefined) {\n return; // already recorded (e.g. error then late message)\n }\n results[index] = result;\n\n if (onResult) {\n onResult(index, tasks[index], result);\n }\n completed++;\n settleIfDone();\n };\n\n const dispatchNext = (worker: Worker): void => {\n if (nextTaskIndex >= tasks.length) {\n inFlight.delete(worker);\n workers.delete(worker);\n void worker.terminate();\n\n return;\n }\n\n const index = nextTaskIndex++;\n\n inFlight.set(worker, index);\n\n worker.once('message', (result: TResult) => {\n inFlight.delete(worker);\n recordResult(index, result);\n dispatchNext(worker);\n });\n\n worker.postMessage(tasks[index]);\n };\n\n const spawn = (): void => {\n const worker = new Worker(workerUrl);\n\n workers.add(worker);\n\n worker.on('error', (err) => {\n const index = inFlight.get(worker);\n\n inFlight.delete(worker);\n workers.delete(worker);\n void worker.terminate();\n\n if (index !== undefined) {\n recordResult(index, onError(tasks[index], err instanceof Error ? err : new Error(String(err))));\n }\n\n // Respawn to keep draining the queue if work remains.\n if (nextTaskIndex < tasks.length) {\n spawn();\n } else {\n settleIfDone();\n }\n });\n\n dispatchNext(worker);\n };\n\n for (let i = 0; i < poolSize; i++) {\n spawn();\n }\n });\n}\n","/**\n * Batch processing utilities for recursive directory conversion\n */\n\nimport { join, resolve, sep } from 'path';\nimport { scanForPackages, type PackageType, type DetectedPackage } from './packageScanner.js';\nimport { runPool } from './workerPool.js';\nimport type { BatchTask, BatchPackageOptions, PackageResult } from './batchProcessors.js';\n\n// Re-export types for backward compatibility\nexport type { PackageType, DetectedPackage };\n\n/**\n * Batch conversion summary\n */\nexport interface BatchConversionSummary {\n /** Total packages found */\n total: number;\n /** Successfully converted packages */\n succeeded: number;\n /** Failed conversions */\n failed: number;\n /** Skipped packages (wrong type or errors) */\n skipped: number;\n /** Total items successfully converted across all packages */\n totalConvertedItems: number;\n /** Total items that failed conversion across all packages */\n totalFailedItems: number;\n /** Details for each package */\n packages: Array<{\n name: string;\n type: PackageType;\n status: 'success' | 'failed' | 'skipped';\n errorCount?: number;\n warningCount?: number;\n }>;\n}\n\n/**\n * Package processor function type\n */\nexport type PackageProcessor<TOptions> = (\n pkg: DetectedPackage,\n outputPath: string,\n options: TOptions\n) => Promise<{\n success: boolean;\n errorCount: number;\n warningCount: number;\n convertedItemCount?: number;\n failedItemCount?: number;\n message?: string;\n}>;\n\n/**\n * Package scanner function type\n */\nexport type PackageScanner = (parentDir: string, expectedType?: PackageType) => DetectedPackage[];\n\n/**\n * Batch processor configuration\n */\nexport interface BatchProcessorConfig<TOptions> {\n inputPath: string;\n outputPath: string;\n packageType: PackageType;\n processPackage: PackageProcessor<TOptions>;\n options: TOptions;\n quiet?: boolean;\n /** Optional package scanner function (defaults to scanForPackages from packageScanner.ts) */\n scanner?: PackageScanner;\n}\n\n/**\n * Resolve the output directory for a package, mirroring the input folder\n * structure below the scanned root.\n *\n * A package found at `<input>/grade-3/maths/pkg-a` is written to\n * `<output>/grade-3/maths/pkg-a`, so siblings with the same directory name in\n * different subtrees no longer collide.\n *\n * Falls back to `pkg.name` when a scanner does not provide `relativePath`.\n */\nexport function resolvePackageOutputPath(outputPath: string, pkg: DetectedPackage): string {\n const relativePath = pkg.relativePath ?? pkg.name;\n\n // relativePath is built from readdirSync entry names below the scanned root,\n // so it cannot contain traversal segments. Resolve and verify anyway so a\n // custom scanner cannot escape the output directory.\n // nosemgrep: javascript.lang.security.audit.path-traversal.path-join-resolve-traversal, javascript.lang.security.audit.path-traversal.path-join-resolve-traversal.path-join-resolve-traversal\n const packageOutputPath = resolve(outputPath, relativePath);\n\n // outputPath is the operator-supplied --out directory and is the containment\n // boundary being checked below, not untrusted input being appended to it.\n // nosemgrep: javascript.lang.security.audit.path-traversal.path-join-resolve-traversal, javascript.lang.security.audit.path-traversal.path-join-resolve-traversal.path-join-resolve-traversal\n const outputRoot = resolve(outputPath);\n\n if (packageOutputPath !== outputRoot && !packageOutputPath.startsWith(outputRoot + sep)) {\n throw new Error(`Package output path escapes the output directory: ${relativePath}`);\n }\n\n // nosemgrep: javascript.lang.security.audit.path-traversal.path-join-resolve-traversal, javascript.lang.security.audit.path-traversal.path-join-resolve-traversal.path-join-resolve-traversal\n return join(outputPath, relativePath);\n}\n\n/**\n * Label used when reporting a package, preferring the path relative to the\n * scanned root so nested packages are distinguishable.\n */\nfunction packageLabel(pkg: DetectedPackage): string {\n return pkg.relativePath ?? pkg.name;\n}\n\n/**\n * Display batch processing summary\n */\nexport function displayBatchSummary(summary: BatchConversionSummary, quiet = false): void {\n if (quiet) {\n return;\n }\n\n console.log('\\n' + '='.repeat(60));\n console.log('Batch Conversion Summary');\n console.log('='.repeat(60));\n console.log(`Total packages: ${summary.total}`);\n console.log(`✓ Succeeded: ${summary.succeeded}`);\n console.log(`✗ Failed: ${summary.failed}`);\n console.log(`⊘ Skipped: ${summary.skipped}`);\n console.log('-'.repeat(60));\n console.log(`Total items: ${summary.totalConvertedItems + summary.totalFailedItems}`);\n console.log(`✓ Converted: ${summary.totalConvertedItems}`);\n console.log(`✗ Errored: ${summary.totalFailedItems}`);\n console.log('='.repeat(60) + '\\n');\n}\n\n/**\n * Generic batch processor that works for both conversion directions\n */\nexport async function processBatch<TOptions>(\n config: BatchProcessorConfig<TOptions>\n): Promise<BatchConversionSummary> {\n const {\n inputPath,\n outputPath,\n packageType,\n processPackage,\n options,\n quiet = false,\n scanner = scanForPackages,\n } = config;\n const startTime = Date.now();\n\n // Scan for packages using the provided scanner or default\n const packages = scanner(inputPath, packageType);\n\n if (packages.length === 0) {\n const typeLabel = packageType === 'qti' ? 'QTI packages' : 'Learnosity bundles';\n const manifestFile = packageType === 'qti' ? 'imsmanifest.xml' : 'manifest.json';\n\n console.error(`Error: No ${typeLabel} found in subdirectories.`);\n console.error(`A ${packageType} package must contain a ${manifestFile} file.`);\n process.exit(1);\n }\n\n if (!quiet) {\n const typeLabel = packageType === 'qti' ? 'QTI package(s)' : 'Learnosity bundle(s)';\n\n console.log(`Found ${packages.length} ${typeLabel}:\\n`);\n packages.forEach((pkg, idx) => {\n console.log(` ${idx + 1}. ${packageLabel(pkg)}`);\n });\n console.log('');\n }\n\n // Initialize summary\n const summary: BatchConversionSummary = {\n total: packages.length,\n succeeded: 0,\n failed: 0,\n skipped: 0,\n totalConvertedItems: 0,\n totalFailedItems: 0,\n packages: [],\n };\n\n // Process each package\n for (let i = 0; i < packages.length; i++) {\n const pkg = packages[i];\n\n // Mirror the input folder structure below the scanned root.\n const packageOutputPath = resolvePackageOutputPath(outputPath, pkg);\n\n if (!quiet) {\n console.log(`\\n[${i + 1}/${packages.length}] Converting: ${packageLabel(pkg)}`);\n console.log(` Input: ${pkg.path}`);\n console.log(` Output: ${packageOutputPath}`);\n console.log('');\n }\n\n try {\n const result = await processPackage(pkg, packageOutputPath, options);\n\n summary.totalConvertedItems += result.convertedItemCount ?? 0;\n summary.totalFailedItems += result.failedItemCount ?? 0;\n\n if (result.success) {\n summary.succeeded++;\n summary.packages.push({\n name: packageLabel(pkg),\n type: pkg.type,\n status: 'success',\n errorCount: result.errorCount,\n warningCount: result.warningCount,\n });\n\n if (!quiet) {\n console.log(\n ` ✓ SUCCESS (${result.errorCount} error(s), ${result.warningCount} warning(s))`\n );\n }\n } else {\n summary.failed++;\n summary.packages.push({\n name: packageLabel(pkg),\n type: pkg.type,\n status: 'failed',\n errorCount: result.errorCount,\n warningCount: result.warningCount,\n });\n\n if (!quiet) {\n console.error(` ✗ FAILED (${result.errorCount} error(s))`);\n if (result.message) {\n console.error(` ${result.message}`);\n }\n }\n }\n } catch (error) {\n summary.failed++;\n summary.packages.push({\n name: packageLabel(pkg),\n type: pkg.type,\n status: 'failed',\n errorCount: 1,\n });\n\n if (!quiet) {\n console.error(\n ` ✗ FAILED: ${error instanceof Error ? error.message : 'Unknown error'}`\n );\n }\n }\n }\n\n // Display summary\n displayBatchSummary(summary, quiet);\n\n const duration = ((Date.now() - startTime) / 1000).toFixed(2);\n\n if (!quiet) {\n console.log(`Completed in ${duration}s\\n`);\n }\n\n // Exit with appropriate code\n if (summary.failed > 0 && summary.succeeded === 0) {\n process.exit(1);\n }\n\n return summary;\n}\n\n/**\n * Configuration for the parallel (worker-pool) batch processor.\n */\nexport interface ParallelBatchConfig {\n inputPath: string;\n outputPath: string;\n packageType: PackageType;\n direction: BatchTask['direction'];\n options: BatchPackageOptions;\n /** Max concurrent worker threads. */\n concurrency: number;\n quiet?: boolean;\n scanner?: PackageScanner;\n /** Worker module URL (defaults to the built batchWorker.js next to main.js). */\n workerUrl?: URL | string;\n}\n\n/**\n * Parallel batch processor: converts packages across a pool of worker threads.\n *\n * Behaviour mirrors {@link processBatch} — same scan, summary shape, console\n * summary and exit code — but per-package conversion runs on worker threads so\n * multiple cores are used. Results are aggregated in package order for a\n * deterministic summary.\n */\nexport async function processBatchParallel(\n config: ParallelBatchConfig\n): Promise<BatchConversionSummary> {\n const {\n inputPath,\n outputPath,\n packageType,\n direction,\n options,\n concurrency,\n quiet = false,\n scanner = scanForPackages,\n workerUrl = new URL('./batchWorker.js', import.meta.url),\n } = config;\n const startTime = Date.now();\n\n const packages = scanner(inputPath, packageType);\n\n if (packages.length === 0) {\n const typeLabel = packageType === 'qti' ? 'QTI packages' : 'Learnosity bundles';\n const manifestFile = packageType === 'qti' ? 'imsmanifest.xml' : 'manifest.json';\n\n console.error(`Error: No ${typeLabel} found in subdirectories.`);\n console.error(`A ${packageType} package must contain a ${manifestFile} file.`);\n process.exit(1);\n }\n\n if (!quiet) {\n const typeLabel = packageType === 'qti' ? 'QTI package(s)' : 'Learnosity bundle(s)';\n\n console.log(\n `Found ${packages.length} ${typeLabel} (converting with ${Math.min(concurrency, packages.length)} workers):\\n`\n );\n packages.forEach((pkg, idx) => {\n console.log(` ${idx + 1}. ${packageLabel(pkg)}`);\n });\n console.log('');\n }\n\n const tasks: BatchTask[] = packages.map((pkg) => ({\n direction,\n pkg,\n // Mirror the input folder structure below the scanned root.\n packageOutputPath: resolvePackageOutputPath(outputPath, pkg),\n options,\n }));\n\n const results = await runPool<BatchTask, PackageResult>({\n tasks,\n workerUrl,\n concurrency,\n onError: (_task, error) => ({\n success: false,\n errorCount: 1,\n warningCount: 0,\n message: error.message,\n }),\n onResult: (index, task, result) => {\n if (quiet) {\n return;\n }\n\n if (result.success) {\n console.log(\n ` ✓ [${index + 1}/${tasks.length}] ${packageLabel(task.pkg)} (${result.errorCount} error(s), ${result.warningCount} warning(s))`\n );\n } else {\n console.error(\n ` ✗ [${index + 1}/${tasks.length}] ${packageLabel(task.pkg)} FAILED (${result.errorCount} error(s))${result.message ? `: ${result.message}` : ''}`\n );\n }\n },\n });\n\n // Aggregate summary in package order (deterministic).\n const summary: BatchConversionSummary = {\n total: packages.length,\n succeeded: 0,\n failed: 0,\n skipped: 0,\n totalConvertedItems: 0,\n totalFailedItems: 0,\n packages: [],\n };\n\n for (let i = 0; i < packages.length; i++) {\n const pkg = packages[i];\n const result = results[i];\n\n summary.totalConvertedItems += result.convertedItemCount ?? 0;\n summary.totalFailedItems += result.failedItemCount ?? 0;\n\n if (result.success) {\n summary.succeeded++;\n summary.packages.push({\n name: packageLabel(pkg),\n type: pkg.type,\n status: 'success',\n errorCount: result.errorCount,\n warningCount: result.warningCount,\n });\n } else {\n summary.failed++;\n summary.packages.push({\n name: packageLabel(pkg),\n type: pkg.type,\n status: 'failed',\n errorCount: result.errorCount,\n warningCount: result.warningCount,\n });\n }\n }\n\n displayBatchSummary(summary, quiet);\n\n const duration = ((Date.now() - startTime) / 1000).toFixed(2);\n\n if (!quiet) {\n console.log(`Completed in ${duration}s\\n`);\n }\n\n if (summary.failed > 0 && summary.succeeded === 0) {\n process.exit(1);\n }\n\n return summary;\n}\n","/**\n * Shared utilities for displaying configuration output in CLI commands\n */\n\nexport interface ConfigField {\n label: string;\n value: string | number | boolean;\n indent?: number;\n}\n\nexport interface ConfigOutputOptions {\n quiet?: boolean;\n}\n\n/**\n * Display a configuration block with consistent formatting\n */\nexport function displayConfiguration(fields: ConfigField[], options: ConfigOutputOptions = {}): void {\n if (options.quiet) {\n return;\n }\n\n console.log('\\nConfiguration:');\n\n for (const field of fields) {\n const indent = field.indent ?? 0;\n const padding = ' ' + ' '.repeat(indent * 2);\n const label = field.label.padEnd(14 - indent * 2, ' ');\n\n console.log(`${padding}${label}${field.value}`);\n }\n\n console.log('');\n}\n\n/**\n * Helper to create a config field\n */\nexport function configField(label: string, value: string | number | boolean, indent = 0): ConfigField {\n return { label, value, indent };\n}\n\n/**\n * Format a list of items for configuration output\n */\nexport function formatList(items: string[], _singular: string, plural: string, showAll = false): string {\n if (items.length === 0) {\n return `0 ${plural}`;\n }\n if (items.length === 1) {\n return items[0];\n }\n\n return `${items.length} ${plural}${showAll ? ' (all)' : ''}`;\n}\n\n"],"mappings":";;;;;;;;;;;AAoCA,SAAgB,aAAa,SAA0B;CACnD,IAAI,CAAC,WAAW,OAAO,KAAK,CAAC,SAAS,OAAO,CAAC,CAAC,YAAY,GACvD,OAAO;CAMX,MAAM,eAAe,KAAK,SAAS,iBAAiB;CAEpD,OAAO,WAAW,YAAY;AAClC;;;;;AAMA,SAAgB,mBAAmB,SAA0B;CACzD,IAAI,CAAC,WAAW,OAAO,KAAK,CAAC,SAAS,OAAO,CAAC,CAAC,YAAY,GACvD,OAAO;CAKX,MAAM,eAAe,KAAK,SAAS,eAAe;CAElD,OAAO,WAAW,YAAY;AAClC;;;;AAKA,SAAgB,kBAAkB,SAA8B;CAC5D,IAAI,aA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