@fern-api/fdr-sdk 1.2.42-1fb0ba4870 → 1.2.42-23647d2912
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/js/navigation/ledger-root-builder.js +70 -11
- package/dist/js/navigation/ledger-root-builder.js.map +1 -1
- package/dist/js/navigation/ledger-root-builder.mjs +70 -11
- package/dist/js/navigation/ledger-root-builder.mjs.map +1 -1
- package/dist/navigation/__test__/ledger-root-builder.crossProductDedup.test.d.ts +2 -0
- package/dist/navigation/__test__/ledger-root-builder.crossProductDedup.test.d.ts.map +1 -0
- package/dist/navigation/__test__/ledger-root-builder.crossProductDedup.test.js +267 -0
- package/dist/navigation/__test__/ledger-root-builder.crossProductDedup.test.js.map +1 -0
- package/dist/navigation/__test__/ledger-root-builder.ledgerParity.test.d.ts +2 -0
- package/dist/navigation/__test__/ledger-root-builder.ledgerParity.test.d.ts.map +1 -0
- package/dist/navigation/__test__/ledger-root-builder.ledgerParity.test.js +306 -0
- package/dist/navigation/__test__/ledger-root-builder.ledgerParity.test.js.map +1 -0
- package/dist/navigation/ledger-root-builder.d.ts.map +1 -1
- package/dist/navigation/ledger-root-builder.js +92 -12
- package/dist/navigation/ledger-root-builder.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/navigation/__test__/ledger-root-builder.crossProductDedup.test.d.ts +2 -0
- package/dist/types/navigation/__test__/ledger-root-builder.crossProductDedup.test.d.ts.map +1 -0
- package/dist/types/navigation/__test__/ledger-root-builder.ledgerParity.test.d.ts +2 -0
- package/dist/types/navigation/__test__/ledger-root-builder.ledgerParity.test.d.ts.map +1 -0
- package/dist/types/navigation/ledger-root-builder.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1300,6 +1300,30 @@ function stripLeadingScopePrefix(section, scopePrefix) {
|
|
|
1300
1300
|
}
|
|
1301
1301
|
return section;
|
|
1302
1302
|
}
|
|
1303
|
+
function computeDuplicateSiblingSortBoundaries(siblings) {
|
|
1304
|
+
const result = /* @__PURE__ */ new Map();
|
|
1305
|
+
const byPath = /* @__PURE__ */ new Map();
|
|
1306
|
+
for (const sibling of siblings) {
|
|
1307
|
+
if (metaStr(sibling.seg.metadata, "type") !== "section") {
|
|
1308
|
+
continue;
|
|
1309
|
+
}
|
|
1310
|
+
const group = byPath.get(sibling.seg.section) ?? [];
|
|
1311
|
+
group.push(sibling);
|
|
1312
|
+
byPath.set(sibling.seg.section, group);
|
|
1313
|
+
}
|
|
1314
|
+
for (const [, group] of byPath) {
|
|
1315
|
+
if (group.length <= 1) {
|
|
1316
|
+
continue;
|
|
1317
|
+
}
|
|
1318
|
+
for (let i = 0; i < group.length; i++) {
|
|
1319
|
+
result.set(group[i], {
|
|
1320
|
+
lo: group[i].seg.sortOrder,
|
|
1321
|
+
hi: i + 1 < group.length ? group[i + 1].seg.sortOrder : Number.MAX_SAFE_INTEGER
|
|
1322
|
+
});
|
|
1323
|
+
}
|
|
1324
|
+
}
|
|
1325
|
+
return result;
|
|
1326
|
+
}
|
|
1303
1327
|
function mergeChildrenByPosition(ctx, nav, sectionChildren) {
|
|
1304
1328
|
const leafNodes = [];
|
|
1305
1329
|
for (let i = 0; i < nav.length; i++) {
|
|
@@ -1354,12 +1378,15 @@ function sectionNode(ctx, scoped, sectionChildren, scopePrefix) {
|
|
|
1354
1378
|
children: mergeChildrenByPosition(ctx, nav, sectionChildren)
|
|
1355
1379
|
};
|
|
1356
1380
|
}
|
|
1357
|
-
function directChildApiPackages(parentSection, scopeSegs) {
|
|
1381
|
+
function directChildApiPackages(parentSection, scopeSegs, apiDefinitionId) {
|
|
1358
1382
|
const sectionPaths = new Set(scopeSegs.map((s) => s.seg.section));
|
|
1359
1383
|
return scopeSegs.filter((s) => {
|
|
1360
1384
|
if (metaStr(s.seg.metadata, "type") !== "apiPackage") {
|
|
1361
1385
|
return false;
|
|
1362
1386
|
}
|
|
1387
|
+
if (metaStr(s.seg.metadata, "apiDefinitionId") !== apiDefinitionId) {
|
|
1388
|
+
return false;
|
|
1389
|
+
}
|
|
1363
1390
|
const parent = parentSectionPath(s.seg.section);
|
|
1364
1391
|
if (parent === parentSection) {
|
|
1365
1392
|
return true;
|
|
@@ -1373,7 +1400,7 @@ function directChildApiPackages(parentSection, scopeSegs) {
|
|
|
1373
1400
|
function buildApiChildren(ctx, scoped, scopeSegs, apiDefinitionId, scopePrefix) {
|
|
1374
1401
|
const { seg, nav } = scoped;
|
|
1375
1402
|
const leafNodes = positionedApiLeafChildren(ctx, nav, apiDefinitionId);
|
|
1376
|
-
const childPackages = directChildApiPackages(seg.section, scopeSegs);
|
|
1403
|
+
const childPackages = directChildApiPackages(seg.section, scopeSegs, apiDefinitionId);
|
|
1377
1404
|
const packageNodes = childPackages.map((child) => ({
|
|
1378
1405
|
node: apiPackageChildNode(
|
|
1379
1406
|
ctx,
|
|
@@ -1514,7 +1541,7 @@ function apiReferenceNode(ctx, scoped, scopeSegs, scopePrefix) {
|
|
|
1514
1541
|
availability: metaAvailability(seg.metadata),
|
|
1515
1542
|
overviewPageId: overviewPageId != null ? PageId(overviewPageId) : void 0,
|
|
1516
1543
|
noindex: metaBool(overview?.metadata, "noindex") ?? metaBool(seg.metadata, "noindex"),
|
|
1517
|
-
paginated:
|
|
1544
|
+
paginated: metaBool(seg.metadata, "paginated"),
|
|
1518
1545
|
showErrors: metaBool(seg.metadata, "showErrors"),
|
|
1519
1546
|
hideTitle: metaBool(seg.metadata, "hideTitle"),
|
|
1520
1547
|
pointsTo: metaPointsTo != null ? pointsToSlug(metaPointsTo) : void 0,
|
|
@@ -1532,7 +1559,10 @@ function attachedApiChangelogNode(ctx, scoped, scopeSegs, apiDefinitionId, scope
|
|
|
1532
1559
|
}
|
|
1533
1560
|
return metaStr(candidate.seg.metadata, "apiDefinitionId") === apiDefinitionId;
|
|
1534
1561
|
});
|
|
1535
|
-
const
|
|
1562
|
+
const apiReferenceCount = scopeSegs.filter((candidate) => {
|
|
1563
|
+
return metaStr(candidate.seg.metadata, "type") === "apiReference" && metaStr(candidate.seg.metadata, "apiDefinitionId") === apiDefinitionId;
|
|
1564
|
+
}).length;
|
|
1565
|
+
const changelogSeg = candidates.find((candidate) => parentSectionPath(candidate.seg.section) === seg.section) ?? (apiReferenceCount === 1 ? candidates[0] : void 0);
|
|
1536
1566
|
return changelogSeg != null ? changelogNode(ctx, changelogSeg, scopePrefix) : void 0;
|
|
1537
1567
|
}
|
|
1538
1568
|
function hasOwningApiReference(scoped, scopeSegs) {
|
|
@@ -1540,12 +1570,13 @@ function hasOwningApiReference(scoped, scopeSegs) {
|
|
|
1540
1570
|
if (apiDefinitionId == null || metaStr(scoped.seg.metadata, "type") !== "changelog") {
|
|
1541
1571
|
return false;
|
|
1542
1572
|
}
|
|
1543
|
-
|
|
1573
|
+
const candidates = scopeSegs.filter((candidate) => {
|
|
1544
1574
|
if (metaStr(candidate.seg.metadata, "type") !== "apiReference") {
|
|
1545
1575
|
return false;
|
|
1546
1576
|
}
|
|
1547
1577
|
return metaStr(candidate.seg.metadata, "apiDefinitionId") === apiDefinitionId;
|
|
1548
1578
|
});
|
|
1579
|
+
return candidates.some((candidate) => parentSectionPath(scoped.seg.section) === candidate.seg.section) || candidates.length === 1;
|
|
1549
1580
|
}
|
|
1550
1581
|
function isNestedApiPackage(scoped, scopeSegs) {
|
|
1551
1582
|
if (metaStr(scoped.seg.metadata, "type") !== "apiPackage") {
|
|
@@ -1700,6 +1731,7 @@ function buildSectionTree(ctx, scopeSegs, parentPath, scopePrefix, changelogScop
|
|
|
1700
1731
|
}
|
|
1701
1732
|
return false;
|
|
1702
1733
|
}).sort((a, b) => a.seg.sortOrder - b.seg.sortOrder);
|
|
1734
|
+
const siblingBoundaries = computeDuplicateSiblingSortBoundaries(direct);
|
|
1703
1735
|
return direct.map((s) => {
|
|
1704
1736
|
const type = metaStr(s.seg.metadata, "type");
|
|
1705
1737
|
const childIndex = metaNum(s.seg.metadata, "childIndex");
|
|
@@ -1709,10 +1741,14 @@ function buildSectionTree(ctx, scopeSegs, parentPath, scopePrefix, changelogScop
|
|
|
1709
1741
|
} else if (type === "changelog") {
|
|
1710
1742
|
node = changelogNode(ctx, s, changelogScopePrefix ?? scopePrefix);
|
|
1711
1743
|
} else {
|
|
1744
|
+
const boundary = siblingBoundaries.get(s);
|
|
1745
|
+
const childScopeSegs = boundary != null ? scopeSegs.filter(
|
|
1746
|
+
(candidate) => candidate.seg.sortOrder >= boundary.lo && candidate.seg.sortOrder < boundary.hi
|
|
1747
|
+
) : scopeSegs;
|
|
1712
1748
|
node = sectionNode(
|
|
1713
1749
|
ctx,
|
|
1714
1750
|
s,
|
|
1715
|
-
buildSectionTree(ctx,
|
|
1751
|
+
buildSectionTree(ctx, childScopeSegs, s.seg.section, scopePrefix, changelogScopePrefix),
|
|
1716
1752
|
scopePrefix
|
|
1717
1753
|
);
|
|
1718
1754
|
}
|
|
@@ -1845,10 +1881,6 @@ function groupSidebarRootChildren(ctx, children) {
|
|
|
1845
1881
|
} else if (child.type === "section" && !child.collapsible) {
|
|
1846
1882
|
flushRun();
|
|
1847
1883
|
out.push(child);
|
|
1848
|
-
} else if (child.type === "changelog") {
|
|
1849
|
-
flushRun();
|
|
1850
|
-
run.push(child);
|
|
1851
|
-
flushRun();
|
|
1852
1884
|
} else {
|
|
1853
1885
|
run.push(child);
|
|
1854
1886
|
}
|
|
@@ -1963,7 +1995,7 @@ function buildVariantedNode(ctx, variants, scopeSegs, scopePrefix) {
|
|
|
1963
1995
|
const variantIndividualSlug = detailSlug(variant);
|
|
1964
1996
|
const variantSlug = variantIndividualSlug !== "" ? asSlug(slugjoin(scopePrefix, variantIndividualSlug)) : scopePrefix;
|
|
1965
1997
|
const metaPointsTo = metaStr(variant.metadata, "pointsTo");
|
|
1966
|
-
const children = buildSidebarRootChildren(ctx, variantSegs,
|
|
1998
|
+
const children = buildSidebarRootChildren(ctx, variantSegs, variantSlug);
|
|
1967
1999
|
return {
|
|
1968
2000
|
type: "variant",
|
|
1969
2001
|
...withMetadataDefaults({
|
|
@@ -2365,6 +2397,7 @@ function buildProductGroup(ctx, products, scoped, rootSlug, skipSharedSectionMer
|
|
|
2365
2397
|
};
|
|
2366
2398
|
return node;
|
|
2367
2399
|
});
|
|
2400
|
+
markCrossProductCanonicalSlugs(children);
|
|
2368
2401
|
return {
|
|
2369
2402
|
type: "productgroup",
|
|
2370
2403
|
id: ctx.nodeId("productgroup"),
|
|
@@ -2376,6 +2409,32 @@ function buildProductGroup(ctx, products, scoped, rootSlug, skipSharedSectionMer
|
|
|
2376
2409
|
children
|
|
2377
2410
|
};
|
|
2378
2411
|
}
|
|
2412
|
+
function markCrossProductCanonicalSlugs(productNodes) {
|
|
2413
|
+
const pageIdToCanonical = /* @__PURE__ */ new Map();
|
|
2414
|
+
const sorted = [...productNodes].sort((a, b) => {
|
|
2415
|
+
if (a.default !== b.default) {
|
|
2416
|
+
return a.default ? -1 : 1;
|
|
2417
|
+
}
|
|
2418
|
+
return 0;
|
|
2419
|
+
});
|
|
2420
|
+
for (const product of sorted) {
|
|
2421
|
+
traverseDF(product, (child) => {
|
|
2422
|
+
if (hasMetadata(child) && isPage(child)) {
|
|
2423
|
+
const pid = getPageId(child);
|
|
2424
|
+
if (pid == null) {
|
|
2425
|
+
return;
|
|
2426
|
+
}
|
|
2427
|
+
const key = `pid:${pid}`;
|
|
2428
|
+
const canonical = pageIdToCanonical.get(key);
|
|
2429
|
+
if (canonical != null && !product.default) {
|
|
2430
|
+
child.canonicalSlug = canonical;
|
|
2431
|
+
} else if (canonical == null) {
|
|
2432
|
+
pageIdToCanonical.set(key, child.canonicalSlug ?? child.slug);
|
|
2433
|
+
}
|
|
2434
|
+
}
|
|
2435
|
+
});
|
|
2436
|
+
}
|
|
2437
|
+
}
|
|
2379
2438
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2380
2439
|
0 && (module.exports = {
|
|
2381
2440
|
apiLeafNodeFromNavRoute,
|