@moxn/kb-migrate 0.2.0 → 0.2.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/dist/client.js +4 -1
- package/dist/export.js +10 -7
- package/package.json +1 -1
package/dist/client.js
CHANGED
|
@@ -117,7 +117,10 @@ export class MoxnClient {
|
|
|
117
117
|
let offset = 0;
|
|
118
118
|
const limit = 100;
|
|
119
119
|
while (true) {
|
|
120
|
-
const params = new URLSearchParams({
|
|
120
|
+
const params = new URLSearchParams({
|
|
121
|
+
limit: String(limit),
|
|
122
|
+
offset: String(offset),
|
|
123
|
+
});
|
|
121
124
|
if (pathPrefix) {
|
|
122
125
|
params.set('path', pathPrefix);
|
|
123
126
|
}
|
package/dist/export.js
CHANGED
|
@@ -117,7 +117,10 @@ function buildMarkdown(doc, mediaMap, mdFilePath) {
|
|
|
117
117
|
// ──────────────────────────────────────────────
|
|
118
118
|
function getMediaTarget(block, options) {
|
|
119
119
|
if (block.blockType === 'image') {
|
|
120
|
-
return {
|
|
120
|
+
return {
|
|
121
|
+
targetDir: options.imageDir,
|
|
122
|
+
fallbackExt: mimeToExt(block.mimeType || 'image/png'),
|
|
123
|
+
};
|
|
121
124
|
}
|
|
122
125
|
else if (block.blockType === 'document') {
|
|
123
126
|
return {
|
|
@@ -137,9 +140,9 @@ export async function runExport(outputDir, options) {
|
|
|
137
140
|
const startTime = Date.now();
|
|
138
141
|
const client = new MoxnClient(options);
|
|
139
142
|
// List documents
|
|
140
|
-
console.
|
|
143
|
+
console.error('Fetching document list...');
|
|
141
144
|
const documents = await client.listDocuments(options.basePath || undefined);
|
|
142
|
-
console.
|
|
145
|
+
console.error(`Found ${documents.length} documents`);
|
|
143
146
|
if (documents.length === 0) {
|
|
144
147
|
return {
|
|
145
148
|
timestamp: new Date().toISOString(),
|
|
@@ -174,7 +177,7 @@ export async function runExport(outputDir, options) {
|
|
|
174
177
|
for (const docItem of documents) {
|
|
175
178
|
const docStart = Date.now();
|
|
176
179
|
const mediaFiles = [];
|
|
177
|
-
console.
|
|
180
|
+
console.error(`Processing: ${docItem.path}`);
|
|
178
181
|
try {
|
|
179
182
|
const doc = await client.getDocument(docItem.id);
|
|
180
183
|
const mdRelativePath = docPathToFilePath(doc.path);
|
|
@@ -205,7 +208,7 @@ export async function runExport(outputDir, options) {
|
|
|
205
208
|
}
|
|
206
209
|
catch (err) {
|
|
207
210
|
const msg = err instanceof Error ? err.message : String(err);
|
|
208
|
-
console.
|
|
211
|
+
console.error(` \u2717 Download failed: ${filename}: ${msg}`);
|
|
209
212
|
}
|
|
210
213
|
}
|
|
211
214
|
}
|
|
@@ -220,7 +223,7 @@ export async function runExport(outputDir, options) {
|
|
|
220
223
|
fs.mkdirSync(path.dirname(mdFullPath), { recursive: true });
|
|
221
224
|
fs.writeFileSync(mdFullPath, markdown, 'utf-8');
|
|
222
225
|
}
|
|
223
|
-
console.
|
|
226
|
+
console.error(` \u2713 ${mdRelativePath} (${doc.sections.length} sections, ${mediaFiles.length} media)`);
|
|
224
227
|
results.push({
|
|
225
228
|
documentId: doc.id,
|
|
226
229
|
documentPath: doc.path,
|
|
@@ -233,7 +236,7 @@ export async function runExport(outputDir, options) {
|
|
|
233
236
|
}
|
|
234
237
|
catch (error) {
|
|
235
238
|
const message = error instanceof Error ? error.message : String(error);
|
|
236
|
-
console.
|
|
239
|
+
console.error(` \u2717 Failed: ${message}`);
|
|
237
240
|
results.push({
|
|
238
241
|
documentId: docItem.id,
|
|
239
242
|
documentPath: docItem.path,
|
package/package.json
CHANGED