@moxn/kb-migrate 0.4.27 → 0.4.28
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.
|
@@ -112,7 +112,7 @@ async function convertBlock(block, client, pagePathMap, visitedSyncedBlocks, dat
|
|
|
112
112
|
// Just note it in the content.
|
|
113
113
|
break;
|
|
114
114
|
case 'child_database':
|
|
115
|
-
results.push(...convertChildDatabase(block, databaseIdMap, unresolvedChildDatabases));
|
|
115
|
+
results.push(...(await convertChildDatabase(block, client, databaseIdMap, unresolvedChildDatabases)));
|
|
116
116
|
break;
|
|
117
117
|
case 'synced_block':
|
|
118
118
|
results.push(...(await convertSyncedBlock(block, client, pagePathMap, visitedSyncedBlocks, databaseIdMap, unsupportedBlocks, unresolvedChildDatabases)));
|
|
@@ -278,7 +278,7 @@ async function convertToggle(block, client, pagePathMap, visitedSyncedBlocks, da
|
|
|
278
278
|
}
|
|
279
279
|
return results;
|
|
280
280
|
}
|
|
281
|
-
function convertChildDatabase(block, databaseIdMap, unresolvedChildDatabases) {
|
|
281
|
+
async function convertChildDatabase(block, client, databaseIdMap, unresolvedChildDatabases) {
|
|
282
282
|
const cd = block;
|
|
283
283
|
const title = cd.child_database?.title || 'Untitled Database';
|
|
284
284
|
const notionDbId = normalizeId(block.id);
|
|
@@ -287,6 +287,19 @@ function convertChildDatabase(block, databaseIdMap, unresolvedChildDatabases) {
|
|
|
287
287
|
if (kbDatabaseId) {
|
|
288
288
|
return [{ blockType: 'database_embed', databaseId: kbDatabaseId }];
|
|
289
289
|
}
|
|
290
|
+
// Try to resolve as a linked database: query one entry to find the source DB
|
|
291
|
+
if (databaseIdMap) {
|
|
292
|
+
const sourceDbId = await client.resolveLinkedDatabaseSource(notionDbId);
|
|
293
|
+
if (sourceDbId) {
|
|
294
|
+
const sourceKbDbId = databaseIdMap.get(sourceDbId);
|
|
295
|
+
if (sourceKbDbId) {
|
|
296
|
+
// Cache for future blocks in this extraction
|
|
297
|
+
databaseIdMap.set(notionDbId, sourceKbDbId);
|
|
298
|
+
console.log(` Resolved linked database "${title}" → source KB ${sourceKbDbId}`);
|
|
299
|
+
return [{ blockType: 'database_embed', databaseId: sourceKbDbId }];
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
}
|
|
290
303
|
// No mapping available — collect for later creation and emit text placeholder
|
|
291
304
|
if (unresolvedChildDatabases) {
|
|
292
305
|
unresolvedChildDatabases.set(notionDbId, title);
|
package/package.json
CHANGED