@thallylabs/migrate 0.2.29 → 0.2.30
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/index.js +29 -14
- package/dist/index.js.map +1 -1
- package/dist/url-migration.js +29 -14
- package/dist/url-migration.js.map +1 -1
- package/package.json +1 -1
package/dist/url-migration.js
CHANGED
|
@@ -3300,6 +3300,33 @@ async function runUrlMigration(options) {
|
|
|
3300
3300
|
enqueue(sourceUrl, sourceUrl, "submitted");
|
|
3301
3301
|
for (const path of ["llms.txt", "sitemap.xml", "robots.txt"]) enqueue(`${scopePath === "/" ? "" : scopePath}/${path}`, sourceUrl, "discovery-index");
|
|
3302
3302
|
if (scopePath !== "/") for (const path of ["llms.txt", "sitemap.xml", "robots.txt"]) enqueue(`/${path}`, sourceUrl, "discovery-index");
|
|
3303
|
+
const enqueueArticleLinks = (links, base, discoveredBy) => {
|
|
3304
|
+
for (const link of links) {
|
|
3305
|
+
try {
|
|
3306
|
+
const url = new URL(link, base);
|
|
3307
|
+
if (!/\.(?:png|jpe?g|gif|svg|webp|avif|pdf|zip|mp4|webm|css|js)$/i.test(url.pathname)) enqueue(link, base, discoveredBy);
|
|
3308
|
+
} catch {
|
|
3309
|
+
}
|
|
3310
|
+
}
|
|
3311
|
+
};
|
|
3312
|
+
const enqueueNavigation = (nodes, base) => {
|
|
3313
|
+
for (const node of nodes) {
|
|
3314
|
+
if (node.url) enqueue(node.url, base, "source-navigation");
|
|
3315
|
+
enqueueNavigation(node.children ?? [], base);
|
|
3316
|
+
}
|
|
3317
|
+
};
|
|
3318
|
+
for (const record of [...records.values()]) {
|
|
3319
|
+
if (!record.evidence) continue;
|
|
3320
|
+
const final = canonical(record.evidence.finalUrl, sourceUrl);
|
|
3321
|
+
if (!final) continue;
|
|
3322
|
+
if (record.outcome === "imported") enqueueArticleLinks(record.evidence.links, final, record.url);
|
|
3323
|
+
else if (record.outcome === "excluded") {
|
|
3324
|
+
if (classifyMigrationResponse({ finalUrl: new URL(final), contentType: record.evidence.contentType, body: "" }) === "index") {
|
|
3325
|
+
for (const link of record.evidence.links) enqueue(link, final, record.url);
|
|
3326
|
+
}
|
|
3327
|
+
}
|
|
3328
|
+
}
|
|
3329
|
+
enqueueNavigation(checkpoint.navigation, sourceUrl);
|
|
3303
3330
|
const fetcher = options.fetcher ?? defaultMigrationFetcher;
|
|
3304
3331
|
const capture = options.captureProvider?.capture.bind(options.captureProvider) ?? (async ({ url }) => fetcher(url, { accept: ACCEPT }));
|
|
3305
3332
|
const assetFetcher = options.assetFetcher ?? (!options.fetcher && !options.captureProvider ? defaultAssetFetcher : void 0);
|
|
@@ -3486,20 +3513,8 @@ ${difference}`;
|
|
|
3486
3513
|
checkpoint.navigation = navigation;
|
|
3487
3514
|
navigationChanged = true;
|
|
3488
3515
|
}
|
|
3489
|
-
|
|
3490
|
-
|
|
3491
|
-
const url = new URL(link, final);
|
|
3492
|
-
if (!/\.(?:png|jpe?g|gif|svg|webp|avif|pdf|zip|mp4|webm|css|js)$/i.test(url.pathname)) enqueue(link, final, record.url);
|
|
3493
|
-
} catch {
|
|
3494
|
-
}
|
|
3495
|
-
}
|
|
3496
|
-
const visit = (nodes) => {
|
|
3497
|
-
for (const node of nodes) {
|
|
3498
|
-
if (node.url) enqueue(node.url, final, "source-navigation");
|
|
3499
|
-
visit(node.children ?? []);
|
|
3500
|
-
}
|
|
3501
|
-
};
|
|
3502
|
-
visit(navigation);
|
|
3516
|
+
enqueueArticleLinks(evidence.links, final, record.url);
|
|
3517
|
+
enqueueNavigation(navigation, final);
|
|
3503
3518
|
} catch (error) {
|
|
3504
3519
|
if (options.signal?.aborted) return;
|
|
3505
3520
|
const wasImported = record.outcome === "imported";
|