@moxn/kb-migrate 0.4.8 → 0.4.10
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.
|
@@ -152,11 +152,7 @@ async function createNotionDatabase(ctx, parentPageId, resolved) {
|
|
|
152
152
|
body: {
|
|
153
153
|
parent: { type: 'page_id', page_id: parentPageId },
|
|
154
154
|
title: [{ type: 'text', text: { content: resolved.databaseName } }],
|
|
155
|
-
initial_data_source: {
|
|
156
|
-
type: 'external',
|
|
157
|
-
external: {},
|
|
158
|
-
properties,
|
|
159
|
-
},
|
|
155
|
+
initial_data_source: { properties },
|
|
160
156
|
},
|
|
161
157
|
}));
|
|
162
158
|
const notionDatabaseId = response.id;
|
|
@@ -172,11 +168,11 @@ async function updateExistingNotionDatabase(ctx, notionDatabaseId, resolved) {
|
|
|
172
168
|
let hasMore = true;
|
|
173
169
|
let startCursor;
|
|
174
170
|
while (hasMore) {
|
|
175
|
-
const queryResult = await ctx.notionClient.
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
page_size: 100,
|
|
179
|
-
});
|
|
171
|
+
const queryResult = (await ctx.notionClient.request({
|
|
172
|
+
method: 'post',
|
|
173
|
+
path: `databases/${notionDatabaseId}/query`,
|
|
174
|
+
body: { start_cursor: startCursor, page_size: 100 },
|
|
175
|
+
}));
|
|
180
176
|
for (const page of queryResult.results) {
|
|
181
177
|
await sleep(RATE_LIMIT_MS);
|
|
182
178
|
try {
|
package/dist/targets/notion.js
CHANGED
|
@@ -46,6 +46,22 @@ function extractKBPathReferences(text) {
|
|
|
46
46
|
});
|
|
47
47
|
return { cleanedText, references };
|
|
48
48
|
}
|
|
49
|
+
/**
|
|
50
|
+
* Strip invalid internal links from markdown text.
|
|
51
|
+
* Notion rejects links that aren't valid URLs (e.g., relative KB paths
|
|
52
|
+
* like "some/relative/path"). Convert them to plain text.
|
|
53
|
+
*/
|
|
54
|
+
function stripInvalidLinks(text) {
|
|
55
|
+
// Match markdown links [text](url) where url is NOT a valid URL
|
|
56
|
+
return text.replace(/\[([^\]]+)\]\(([^)]+)\)/g, (match, displayText, url) => {
|
|
57
|
+
// Keep links that look like valid URLs (http/https/mailto/tel)
|
|
58
|
+
if (/^(https?:\/\/|mailto:|tel:|#)/.test(url)) {
|
|
59
|
+
return match;
|
|
60
|
+
}
|
|
61
|
+
// Strip relative/internal paths — just keep the display text
|
|
62
|
+
return displayText;
|
|
63
|
+
});
|
|
64
|
+
}
|
|
49
65
|
/**
|
|
50
66
|
* Convert a KB document's sections into a single markdown string.
|
|
51
67
|
* Section names become H2 headings (mirrors the import convention).
|
|
@@ -68,6 +84,9 @@ function sectionsToMarkdown(sections, options) {
|
|
|
68
84
|
text = cleanedText;
|
|
69
85
|
allReferences.push(...references);
|
|
70
86
|
}
|
|
87
|
+
// Strip relative/internal links that aren't valid URLs
|
|
88
|
+
// (Notion rejects links without a protocol)
|
|
89
|
+
text = stripInvalidLinks(text);
|
|
71
90
|
parts.push(text);
|
|
72
91
|
parts.push('');
|
|
73
92
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moxn/kb-migrate",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.10",
|
|
4
4
|
"description": "Migration tool for importing documents into Moxn Knowledge Base from local files, Notion, Google Docs, and more",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -82,7 +82,7 @@
|
|
|
82
82
|
"prepublishOnly": "npm run build"
|
|
83
83
|
},
|
|
84
84
|
"dependencies": {
|
|
85
|
-
"@notionhq/client": "^
|
|
85
|
+
"@notionhq/client": "^5.9.0",
|
|
86
86
|
"@tryfabric/martian": "^1.2.4",
|
|
87
87
|
"commander": "^12.0.0",
|
|
88
88
|
"glob": "^10.0.0",
|