@learnosity/lib-qti-converter 0.12.6 → 0.12.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (28) hide show
  1. package/package.json +3 -2
  2. package/packages/cli/dist/batchProcessors-DU1HwpHY.js +3753 -0
  3. package/packages/cli/dist/batchProcessors-DU1HwpHY.js.map +1 -0
  4. package/packages/cli/dist/batchWorker.js +1 -1
  5. package/packages/cli/dist/{learnosityToQti-CXDJoJpl.js → learnosityToQti-BSbH3jyx.js} +4 -4
  6. package/packages/cli/dist/{learnosityToQti-CXDJoJpl.js.map → learnosityToQti-BSbH3jyx.js.map} +1 -1
  7. package/packages/cli/dist/{learnosityToQtiPackage-7v-s4ybk.js → learnosityToQtiPackage-B0xRzYmy.js} +4 -5
  8. package/packages/cli/dist/{learnosityToQtiPackage-7v-s4ybk.js.map → learnosityToQtiPackage-B0xRzYmy.js.map} +1 -1
  9. package/packages/cli/dist/main.js +6 -6
  10. package/packages/cli/dist/main.js.map +1 -1
  11. package/packages/cli/dist/nodeFileAccess-BkzSHCOh.js +291 -0
  12. package/packages/cli/dist/nodeFileAccess-BkzSHCOh.js.map +1 -0
  13. package/packages/cli/dist/{pathUtils-CgoDQyJk.js → pathUtils-B9yPTlVF.js} +3 -149
  14. package/packages/cli/dist/pathUtils-B9yPTlVF.js.map +1 -0
  15. package/packages/cli/dist/{qtiPackageToLearnosity-hT4QZ7YX.js → qtiPackageToLearnosity-C7JaaUDU.js} +5 -5
  16. package/packages/cli/dist/{qtiPackageToLearnosity-hT4QZ7YX.js.map → qtiPackageToLearnosity-C7JaaUDU.js.map} +1 -1
  17. package/packages/cli/dist/{qtiToLearnosity-BU7mHhIu.js → qtiToLearnosity-CYoG2aIX.js} +5 -5
  18. package/packages/cli/dist/{qtiToLearnosity-BU7mHhIu.js.map → qtiToLearnosity-CYoG2aIX.js.map} +1 -1
  19. package/packages/cli/dist/resolveOptions-CW80R2EQ.js +2879 -0
  20. package/packages/cli/dist/resolveOptions-CW80R2EQ.js.map +1 -0
  21. package/packages/cli/dist/{resolveOptions-ehwJSkQy.js → table-DjOn2Tsk.js} +2427 -2816
  22. package/packages/cli/dist/table-DjOn2Tsk.js.map +1 -0
  23. package/packages/cli/dist/batchProcessors-C8k2v0o_.js +0 -217
  24. package/packages/cli/dist/batchProcessors-C8k2v0o_.js.map +0 -1
  25. package/packages/cli/dist/pathUtils-CgoDQyJk.js.map +0 -1
  26. package/packages/cli/dist/resolveOptions-ehwJSkQy.js.map +0 -1
  27. package/packages/cli/dist/table-DYcNeyJ_.js +0 -2306
  28. package/packages/cli/dist/table-DYcNeyJ_.js.map +0 -1
@@ -1,217 +0,0 @@
1
- import { n as formatDiagnosticsSummaryTable, s as writeDiagnostics } from "./table-DYcNeyJ_.js";
2
- import { buildPackageFromActivity, convertActivity, convertQtiPackageToLearnosityBundle, ensureUniqueFolderName, loadLearnosityBundle, loadPackageDirectory, mergeActivityPackage, nodeFileAccess, sanitizeFolderName, saveQtiContentPackage, writeLearnosityBundle } from "@learnosity/converter-core/node";
3
- //#region src/utils/batchProcessors.ts
4
- /**
5
- * Per-package conversion tasks, shared by the serial batch path
6
- * (`processBatch`) and the parallel worker path (`processBatchParallel` via
7
- * `batchWorker`). Extracting them here keeps a single implementation per
8
- * direction — the same code runs inline or inside a worker thread.
9
- */
10
- /** Run one batch task in-process (used by the worker and directly in tests). */
11
- async function runBatchTask(task, quiet = true) {
12
- if (task.direction === "qti-to-learnosity") return processQtiPackageToLearnosity(task.pkg, task.packageOutputPath, task.options, quiet);
13
- return processLearnosityToQtiPackage(task.pkg, task.packageOutputPath, task.options, quiet);
14
- }
15
- function displayDiagnosticsSummary(diagnostics, quiet) {
16
- if (quiet) return;
17
- const summaryTable = formatDiagnosticsSummaryTable(diagnostics);
18
- if (summaryTable) {
19
- console.log(" Diagnostics:");
20
- console.log(summaryTable.split("\n").map((line) => " " + line).join("\n"));
21
- console.log("");
22
- }
23
- }
24
- /** Convert one QTI Content Package directory to a Learnosity bundle on disk. */
25
- async function processQtiPackageToLearnosity(pkg, packageOutputPath, options, quiet) {
26
- const loaded = loadPackageDirectory(pkg.path);
27
- const convertResult = loaded.entries ? convertQtiPackageToLearnosityBundle({ entries: loaded.entries }, {
28
- organisationId: options.organisationId,
29
- mediaVault: options.mediaVault,
30
- customAssetUrl: options.customAssetUrl,
31
- itemReferenceSource: options.itemReferenceSource,
32
- itemFilenameSource: options.itemFilenameSource,
33
- truncateTags: options.truncateTags,
34
- packageVersion: options.version,
35
- sourceDir: pkg.path,
36
- fileAccess: nodeFileAccess
37
- }) : { diagnostics: loaded.diagnostics };
38
- const errors = convertResult.diagnostics.filter((d) => d.level === "error");
39
- const warnings = convertResult.diagnostics.filter((d) => d.level === "warning");
40
- const hasValidBundle = convertResult.bundle && convertResult.bundle.items.size > 0;
41
- const convertedFiles = convertResult.convertedSourceFiles || [];
42
- const failedFiles = convertResult.failedSourceFiles || [];
43
- const filesWithErrors = /* @__PURE__ */ new Set();
44
- for (const d of convertResult.diagnostics) if (d.level === "error" && d.file) filesWithErrors.add(d.file);
45
- const convertedWithErrors = convertedFiles.filter((f) => filesWithErrors.has(f)).length;
46
- const erroredItemCount = failedFiles.length + convertedWithErrors;
47
- const cleanItemCount = convertedFiles.length - convertedWithErrors;
48
- if (errors.length > 0 && !hasValidBundle) return {
49
- success: false,
50
- errorCount: errors.length,
51
- warningCount: warnings.length,
52
- convertedItemCount: cleanItemCount,
53
- failedItemCount: erroredItemCount,
54
- message: "Conversion failed"
55
- };
56
- const writeResult = await writeLearnosityBundle(convertResult.bundle, {
57
- outDir: packageOutputPath,
58
- isZipOutput: false
59
- });
60
- const writeErrors = writeResult.diagnostics.filter((d) => d.level === "error");
61
- if (writeErrors.length > 0) return {
62
- success: false,
63
- errorCount: errors.length + writeErrors.length,
64
- warningCount: warnings.length,
65
- convertedItemCount: cleanItemCount,
66
- failedItemCount: erroredItemCount,
67
- message: "Write failed"
68
- };
69
- const diagnosticsPath = `${packageOutputPath}/diagnostics.json`;
70
- const allDiagnostics = [...convertResult.diagnostics, ...writeResult.diagnostics];
71
- const convertedActivityFiles = convertResult.convertedActivityFiles || [];
72
- await writeDiagnostics(allDiagnostics, "file", diagnosticsPath, packageOutputPath, false, {
73
- inputPath: pkg.path,
74
- outputPath: packageOutputPath,
75
- totalItemsFound: convertedFiles.length + failedFiles.length,
76
- totalActivitiesFound: convertedActivityFiles.length,
77
- convertedFiles,
78
- failedFiles,
79
- convertedActivities: convertedActivityFiles
80
- });
81
- if (!quiet) {
82
- const summaryTable = formatDiagnosticsSummaryTable(allDiagnostics);
83
- if (summaryTable) {
84
- console.log(" Diagnostics:");
85
- console.log(summaryTable.split("\n").map((line) => " " + line).join("\n"));
86
- console.log("");
87
- }
88
- }
89
- return {
90
- success: true,
91
- errorCount: errors.length,
92
- warningCount: warnings.length,
93
- convertedItemCount: cleanItemCount,
94
- failedItemCount: erroredItemCount
95
- };
96
- }
97
- /** Convert one Learnosity bundle directory to a QTI Content Package on disk. */
98
- async function processLearnosityToQtiPackage(pkg, packageOutputPath, options, quiet) {
99
- const loadResult = loadLearnosityBundle(pkg.path);
100
- if (!loadResult.bundle) {
101
- const errorCount = loadResult.diagnostics.filter((d) => d.level === "error").length;
102
- displayDiagnosticsSummary(loadResult.diagnostics, quiet);
103
- return {
104
- success: false,
105
- errorCount,
106
- warningCount: 0,
107
- message: "Bundle load error"
108
- };
109
- }
110
- const bundle = loadResult.bundle;
111
- const allDiagnostics = [...loadResult.diagnostics];
112
- const allConvertedActivities = [];
113
- const usedFolderNames = /* @__PURE__ */ new Set();
114
- const convertedItemRefs = /* @__PURE__ */ new Set();
115
- const failedItemRefs = /* @__PURE__ */ new Set();
116
- for (const activityRef of bundle.activityRefs) {
117
- const convertResult = convertActivity(bundle, activityRef, {
118
- pretty: options.pretty,
119
- version: options.qtiVersion,
120
- customAssetUrl: options.customAssetUrl
121
- });
122
- allDiagnostics.push(...convertResult.diagnostics);
123
- const itemRefs = bundle.activityItemRefs.get(activityRef) ?? [];
124
- const successfulItemRefs = new Set(convertResult.items.map((item) => item.reference));
125
- for (const itemRef of itemRefs) if (successfulItemRefs.has(itemRef)) convertedItemRefs.add(itemRef);
126
- else failedItemRefs.add(itemRef);
127
- if (convertResult.items.length > 0) {
128
- const sanitizedName = sanitizeFolderName(activityRef, `activity_${allConvertedActivities.length + 1}`);
129
- const folderName = ensureUniqueFolderName(sanitizedName, usedFolderNames);
130
- allConvertedActivities.push({
131
- activityRef,
132
- folderName,
133
- conversion: convertResult
134
- });
135
- }
136
- }
137
- for (const itemRef of convertedItemRefs) failedItemRefs.delete(itemRef);
138
- const convertedFiles = itemRefsToFilenames(bundle, convertedItemRefs);
139
- const failedFiles = itemRefsToFilenames(bundle, failedItemRefs);
140
- const convertedActivityFiles = allConvertedActivities.map(({ activityRef }) => `activities/${activityRef}.json`);
141
- const failedActivityFiles = bundle.activityRefs.filter((ref) => !allConvertedActivities.some((a) => a.activityRef === ref)).map((ref) => `activities/${ref}.json`);
142
- const totalItemsConverted = convertedItemRefs.size;
143
- const totalItemsFailed = failedItemRefs.size;
144
- const writePackageDiagnostics = () => writeDiagnostics(allDiagnostics, "file", `${packageOutputPath}/diagnostics.json`, packageOutputPath, false, {
145
- inputPath: pkg.path,
146
- outputPath: packageOutputPath,
147
- totalItemsFound: totalItemsConverted + totalItemsFailed,
148
- totalActivitiesFound: bundle.activityRefs.length,
149
- convertedFiles,
150
- failedFiles,
151
- convertedActivities: convertedActivityFiles,
152
- failedActivities: failedActivityFiles
153
- });
154
- if (allConvertedActivities.length === 0) {
155
- const errorCount = allDiagnostics.filter((d) => d.level === "error").length;
156
- await writePackageDiagnostics();
157
- return {
158
- success: false,
159
- errorCount,
160
- warningCount: allDiagnostics.filter((d) => d.level === "warning").length,
161
- convertedItemCount: 0,
162
- failedItemCount: totalItemsFailed,
163
- message: "No activities converted"
164
- };
165
- }
166
- const pkgData = {
167
- zipPath: "",
168
- version: options.qtiVersion,
169
- resources: [],
170
- entries: /* @__PURE__ */ new Map(),
171
- items: [],
172
- assets: []
173
- };
174
- const addedResourceIds = /* @__PURE__ */ new Set();
175
- for (const { activityRef, folderName, conversion } of allConvertedActivities) {
176
- const packageResult = buildPackageFromActivity(conversion, {
177
- bundleDir: pkg.path,
178
- activityRef,
179
- version: options.qtiVersion
180
- });
181
- allDiagnostics.push(...packageResult.diagnostics);
182
- mergeActivityPackage(pkgData, folderName, packageResult, addedResourceIds);
183
- }
184
- const saveResult = saveQtiContentPackage(pkgData, packageOutputPath);
185
- allDiagnostics.push(...saveResult.diagnostics);
186
- const errors = allDiagnostics.filter((d) => d.level === "error");
187
- const warnings = allDiagnostics.filter((d) => d.level === "warning");
188
- await writePackageDiagnostics();
189
- displayDiagnosticsSummary(allDiagnostics, quiet);
190
- if (errors.length > 0) return {
191
- success: false,
192
- errorCount: errors.length,
193
- warningCount: warnings.length,
194
- convertedItemCount: totalItemsConverted,
195
- failedItemCount: totalItemsFailed,
196
- message: "Conversion failed"
197
- };
198
- return {
199
- success: true,
200
- errorCount: 0,
201
- warningCount: warnings.length,
202
- convertedItemCount: totalItemsConverted,
203
- failedItemCount: totalItemsFailed
204
- };
205
- }
206
- /**
207
- * Map item references to the filenames they were loaded from, for the
208
- * diagnostics report. Falls back to the reference when the bundle has no
209
- * filename recorded, so counts always match the listed items.
210
- */
211
- function itemRefsToFilenames(bundle, itemRefs) {
212
- return [...itemRefs].map((itemRef) => bundle.itemRefToFilename.get(itemRef) ?? itemRef);
213
- }
214
- //#endregion
215
- export { processQtiPackageToLearnosity as n, runBatchTask as r, processLearnosityToQtiPackage as t };
216
-
217
- //# sourceMappingURL=batchProcessors-C8k2v0o_.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"batchProcessors-C8k2v0o_.js","names":[],"sources":["../src/utils/batchProcessors.ts"],"sourcesContent":["/**\n * Per-package conversion tasks, shared by the serial batch path\n * (`processBatch`) and the parallel worker path (`processBatchParallel` via\n * `batchWorker`). Extracting them here keeps a single implementation per\n * direction — the same code runs inline or inside a worker thread.\n */\n\nimport {\n loadPackageDirectory,\n convertQtiPackageToLearnosityBundle,\n writeLearnosityBundle,\n loadLearnosityBundle,\n convertActivity,\n buildPackageFromActivity,\n mergeActivityPackage,\n sanitizeFolderName,\n ensureUniqueFolderName,\n saveQtiContentPackage,\n nodeFileAccess,\n type Diagnostic,\n type ItemFilenameSource,\n type ItemReferenceSource,\n type LearnosityBundleModel,\n type QtiContentPackage,\n} from '@learnosity/converter-core/node';\nimport type { DetectedPackage } from './packageScanner.js';\nimport { writeDiagnostics } from '../io/writeDiagnostics.js';\nimport { formatDiagnosticsSummaryTable } from '../ux/table.js';\n\n/** Options accepted by the per-package processors (subset of resolved CLI options). */\nexport interface BatchPackageOptions {\n organisationId?: number;\n mediaVault?: boolean;\n customAssetUrl?: string;\n itemReferenceSource?: ItemReferenceSource;\n itemFilenameSource?: ItemFilenameSource;\n truncateTags?: boolean;\n version?: string;\n pretty?: boolean;\n qtiVersion?: '2.1' | '2.2';\n}\n\n/** Result of processing one package (matches PackageProcessor's return shape). */\nexport interface PackageResult {\n success: boolean;\n errorCount: number;\n warningCount: number;\n convertedItemCount?: number;\n failedItemCount?: number;\n message?: string;\n}\n\n/** A single package conversion task dispatched to a worker. */\nexport interface BatchTask {\n direction: 'qti-to-learnosity' | 'learnosity-to-qti';\n pkg: DetectedPackage;\n packageOutputPath: string;\n options: BatchPackageOptions;\n}\n\n/** Run one batch task in-process (used by the worker and directly in tests). */\nexport async function runBatchTask(task: BatchTask, quiet = true): Promise<PackageResult> {\n if (task.direction === 'qti-to-learnosity') {\n return processQtiPackageToLearnosity(task.pkg, task.packageOutputPath, task.options, quiet);\n }\n\n return processLearnosityToQtiPackage(task.pkg, task.packageOutputPath, task.options, quiet);\n}\n\nfunction displayDiagnosticsSummary(diagnostics: Diagnostic[], quiet: boolean): void {\n if (quiet) {\n return;\n }\n\n const summaryTable = formatDiagnosticsSummaryTable(diagnostics);\n\n if (summaryTable) {\n console.log(' Diagnostics:');\n console.log(\n summaryTable\n .split('\\n')\n .map((line) => ' ' + line)\n .join('\\n')\n );\n console.log('');\n }\n}\n\n/** Convert one QTI Content Package directory to a Learnosity bundle on disk. */\nexport async function processQtiPackageToLearnosity(\n pkg: DetectedPackage,\n packageOutputPath: string,\n options: BatchPackageOptions,\n quiet: boolean\n): Promise<PackageResult> {\n // Convert the package\n const loaded = loadPackageDirectory(pkg.path);\n const convertResult = loaded.entries\n ? convertQtiPackageToLearnosityBundle(\n { entries: loaded.entries },\n {\n organisationId: options.organisationId,\n mediaVault: options.mediaVault,\n customAssetUrl: options.customAssetUrl,\n itemReferenceSource: options.itemReferenceSource,\n itemFilenameSource: options.itemFilenameSource,\n truncateTags: options.truncateTags,\n packageVersion: options.version,\n sourceDir: pkg.path,\n fileAccess: nodeFileAccess,\n }\n )\n : { diagnostics: loaded.diagnostics };\n\n const errors = convertResult.diagnostics.filter((d) => d.level === 'error');\n const warnings = convertResult.diagnostics.filter((d) => d.level === 'warning');\n const hasValidBundle = convertResult.bundle && convertResult.bundle.items.size > 0;\n\n const convertedFiles = convertResult.convertedSourceFiles || [];\n const failedFiles = convertResult.failedSourceFiles || [];\n\n // Count items that have error-level diagnostics (includes both\n // completely failed items and items that converted with errors)\n const filesWithErrors = new Set<string>();\n\n for (const d of convertResult.diagnostics) {\n if (d.level === 'error' && d.file) {\n filesWithErrors.add(d.file);\n }\n }\n\n const convertedWithErrors = convertedFiles.filter((f) => filesWithErrors.has(f)).length;\n const erroredItemCount = failedFiles.length + convertedWithErrors;\n const cleanItemCount = convertedFiles.length - convertedWithErrors;\n\n if (errors.length > 0 && !hasValidBundle) {\n return {\n success: false,\n errorCount: errors.length,\n warningCount: warnings.length,\n convertedItemCount: cleanItemCount,\n failedItemCount: erroredItemCount,\n message: 'Conversion failed',\n };\n }\n\n // Write the bundle\n const writeResult = await writeLearnosityBundle(convertResult.bundle!, {\n outDir: packageOutputPath,\n isZipOutput: false,\n });\n\n const writeErrors = writeResult.diagnostics.filter((d) => d.level === 'error');\n\n if (writeErrors.length > 0) {\n return {\n success: false,\n errorCount: errors.length + writeErrors.length,\n warningCount: warnings.length,\n convertedItemCount: cleanItemCount,\n failedItemCount: erroredItemCount,\n message: 'Write failed',\n };\n }\n\n // In batch mode, always write diagnostics.json to each package directory\n const diagnosticsPath = `${packageOutputPath}/diagnostics.json`;\n const allDiagnostics = [...convertResult.diagnostics, ...writeResult.diagnostics];\n const convertedActivityFiles = convertResult.convertedActivityFiles || [];\n\n await writeDiagnostics(allDiagnostics, 'file', diagnosticsPath, packageOutputPath, false, {\n inputPath: pkg.path,\n outputPath: packageOutputPath,\n totalItemsFound: convertedFiles.length + failedFiles.length,\n totalActivitiesFound: convertedActivityFiles.length,\n convertedFiles,\n failedFiles,\n convertedActivities: convertedActivityFiles,\n });\n\n // Show condensed diagnostics summary\n if (!quiet) {\n const summaryTable = formatDiagnosticsSummaryTable(allDiagnostics);\n\n if (summaryTable) {\n console.log(' Diagnostics:');\n console.log(\n summaryTable\n .split('\\n')\n .map((line) => ' ' + line)\n .join('\\n')\n );\n console.log('');\n }\n }\n\n return {\n success: true,\n errorCount: errors.length,\n warningCount: warnings.length,\n convertedItemCount: cleanItemCount,\n failedItemCount: erroredItemCount,\n };\n}\n\n/** Convert one Learnosity bundle directory to a QTI Content Package on disk. */\nexport async function processLearnosityToQtiPackage(\n pkg: DetectedPackage,\n packageOutputPath: string,\n options: BatchPackageOptions,\n quiet: boolean\n): Promise<PackageResult> {\n // Load the bundle\n const loadResult = loadLearnosityBundle(pkg.path);\n\n if (!loadResult.bundle) {\n const errorCount = loadResult.diagnostics.filter((d) => d.level === 'error').length;\n\n displayDiagnosticsSummary(loadResult.diagnostics, quiet);\n\n return {\n success: false,\n errorCount,\n warningCount: 0,\n message: 'Bundle load error',\n };\n }\n\n const bundle = loadResult.bundle;\n const allDiagnostics: Diagnostic[] = [...loadResult.diagnostics];\n\n // Convert all activities in the bundle\n const allConvertedActivities: {\n activityRef: string;\n folderName: string;\n conversion: ReturnType<typeof convertActivity>;\n }[] = [];\n\n // Folder names for tests/<folderName>/assessmentTest.xml must be unique per package\n const usedFolderNames = new Set<string>();\n\n // Track item outcomes for the diagnostics report. Items shared by several\n // activities are counted once, hence the sets.\n const convertedItemRefs = new Set<string>();\n const failedItemRefs = new Set<string>();\n\n for (const activityRef of bundle.activityRefs) {\n const convertResult = convertActivity(bundle, activityRef, {\n pretty: options.pretty,\n version: options.qtiVersion,\n customAssetUrl: options.customAssetUrl,\n });\n\n allDiagnostics.push(...convertResult.diagnostics);\n\n const itemRefs = bundle.activityItemRefs.get(activityRef) ?? [];\n const successfulItemRefs = new Set(convertResult.items.map((item) => item.reference));\n\n for (const itemRef of itemRefs) {\n if (successfulItemRefs.has(itemRef)) {\n convertedItemRefs.add(itemRef);\n } else {\n failedItemRefs.add(itemRef);\n }\n }\n\n if (convertResult.items.length > 0) {\n const sanitizedName = sanitizeFolderName(\n activityRef,\n `activity_${allConvertedActivities.length + 1}`\n );\n const folderName = ensureUniqueFolderName(sanitizedName, usedFolderNames);\n\n allConvertedActivities.push({ activityRef, folderName, conversion: convertResult });\n }\n }\n\n // An item that converted in one activity is not a failure elsewhere.\n for (const itemRef of convertedItemRefs) {\n failedItemRefs.delete(itemRef);\n }\n\n const convertedFiles = itemRefsToFilenames(bundle, convertedItemRefs);\n const failedFiles = itemRefsToFilenames(bundle, failedItemRefs);\n const convertedActivityFiles = allConvertedActivities.map(\n ({ activityRef }) => `activities/${activityRef}.json`\n );\n const failedActivityFiles = bundle.activityRefs\n .filter((ref) => !allConvertedActivities.some((a) => a.activityRef === ref))\n .map((ref) => `activities/${ref}.json`);\n const totalItemsConverted = convertedItemRefs.size;\n const totalItemsFailed = failedItemRefs.size;\n\n // In batch mode, always write diagnostics.json to each package directory,\n // including when the package fails, so the report explains what happened.\n // Reads allDiagnostics when called, so later diagnostics are included.\n const writePackageDiagnostics = () =>\n writeDiagnostics(\n allDiagnostics,\n 'file',\n `${packageOutputPath}/diagnostics.json`,\n packageOutputPath,\n false,\n {\n inputPath: pkg.path,\n outputPath: packageOutputPath,\n totalItemsFound: totalItemsConverted + totalItemsFailed,\n totalActivitiesFound: bundle.activityRefs.length,\n convertedFiles,\n failedFiles,\n convertedActivities: convertedActivityFiles,\n failedActivities: failedActivityFiles,\n }\n );\n\n if (allConvertedActivities.length === 0) {\n const errorCount = allDiagnostics.filter((d) => d.level === 'error').length;\n\n await writePackageDiagnostics();\n\n return {\n success: false,\n errorCount,\n warningCount: allDiagnostics.filter((d) => d.level === 'warning').length,\n convertedItemCount: 0,\n failedItemCount: totalItemsFailed,\n message: 'No activities converted',\n };\n }\n\n // Build package with all activities\n const pkgData: QtiContentPackage = {\n zipPath: '',\n version: options.qtiVersion,\n resources: [],\n entries: new Map(),\n items: [],\n assets: [],\n };\n\n const addedResourceIds = new Set<string>();\n\n for (const { activityRef, folderName, conversion } of allConvertedActivities) {\n const packageResult = buildPackageFromActivity(conversion, {\n bundleDir: pkg.path,\n activityRef,\n version: options.qtiVersion,\n });\n\n allDiagnostics.push(...packageResult.diagnostics);\n\n // Relocates the assessmentTest to tests/<folderName>/assessmentTest.xml and\n // wires manifest dependencies, matching the single-package output layout.\n mergeActivityPackage(pkgData, folderName, packageResult, addedResourceIds);\n }\n\n // Save the package\n const saveResult = saveQtiContentPackage(pkgData, packageOutputPath);\n\n allDiagnostics.push(...saveResult.diagnostics);\n\n const errors = allDiagnostics.filter((d) => d.level === 'error');\n const warnings = allDiagnostics.filter((d) => d.level === 'warning');\n\n await writePackageDiagnostics();\n\n displayDiagnosticsSummary(allDiagnostics, quiet);\n\n if (errors.length > 0) {\n return {\n success: false,\n errorCount: errors.length,\n warningCount: warnings.length,\n convertedItemCount: totalItemsConverted,\n failedItemCount: totalItemsFailed,\n message: 'Conversion failed',\n };\n }\n\n return {\n success: true,\n errorCount: 0,\n warningCount: warnings.length,\n convertedItemCount: totalItemsConverted,\n failedItemCount: totalItemsFailed,\n };\n}\n\n/**\n * Map item references to the filenames they were loaded from, for the\n * diagnostics report. Falls back to the reference when the bundle has no\n * filename recorded, so counts always match the listed items.\n */\nfunction itemRefsToFilenames(bundle: LearnosityBundleModel, itemRefs: Set<string>): string[] {\n return [...itemRefs].map((itemRef) => bundle.itemRefToFilename.get(itemRef) ?? itemRef);\n}\n"],"mappings":";;;;;;;;;;AA6DA,eAAsB,aAAa,MAAiB,QAAQ,MAA8B;CACtF,IAAI,KAAK,cAAc,qBACnB,OAAO,8BAA8B,KAAK,KAAK,KAAK,mBAAmB,KAAK,SAAS,KAAK;CAG9F,OAAO,8BAA8B,KAAK,KAAK,KAAK,mBAAmB,KAAK,SAAS,KAAK;AAC9F;AAEA,SAAS,0BAA0B,aAA2B,OAAsB;CAChF,IAAI,OACA;CAGJ,MAAM,eAAe,8BAA8B,WAAW;CAE9D,IAAI,cAAc;EACd,QAAQ,IAAI,gBAAgB;EAC5B,QAAQ,IACJ,aACK,MAAM,IAAI,CAAC,CACX,KAAK,SAAS,OAAO,IAAI,CAAC,CAC1B,KAAK,IAAI,CAClB;EACA,QAAQ,IAAI,EAAE;CAClB;AACJ;;AAGA,eAAsB,8BAClB,KACA,mBACA,SACA,OACsB;CAEtB,MAAM,SAAS,qBAAqB,IAAI,IAAI;CAC5C,MAAM,gBAAgB,OAAO,UACvB,oCACI,EAAE,SAAS,OAAO,QAAQ,GAC1B;EACI,gBAAgB,QAAQ;EACxB,YAAY,QAAQ;EACpB,gBAAgB,QAAQ;EACxB,qBAAqB,QAAQ;EAC7B,oBAAoB,QAAQ;EAC5B,cAAc,QAAQ;EACtB,gBAAgB,QAAQ;EACxB,WAAW,IAAI;EACf,YAAY;CAChB,CACJ,IACA,EAAE,aAAa,OAAO,YAAY;CAExC,MAAM,SAAS,cAAc,YAAY,QAAQ,MAAM,EAAE,UAAU,OAAO;CAC1E,MAAM,WAAW,cAAc,YAAY,QAAQ,MAAM,EAAE,UAAU,SAAS;CAC9E,MAAM,iBAAiB,cAAc,UAAU,cAAc,OAAO,M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