@fern-api/fdr-sdk 1.2.39-4f09cc17dc → 1.2.39-7803ef9da9
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/client/FdrClient.js +1 -0
- package/dist/js/client/FdrClient.js.map +1 -1
- package/dist/js/client/FdrClient.mjs +1 -0
- package/dist/js/client/FdrClient.mjs.map +1 -1
- package/dist/js/converters/index.js +1 -6
- package/dist/js/converters/index.js.map +1 -1
- package/dist/js/converters/index.mjs +1 -6
- package/dist/js/converters/index.mjs.map +1 -1
- package/dist/js/index.js +2 -6
- package/dist/js/index.js.map +1 -1
- package/dist/js/index.mjs +2 -6
- package/dist/js/index.mjs.map +1 -1
- package/dist/js/navigation/index.js +1 -6
- package/dist/js/navigation/index.js.map +1 -1
- package/dist/js/navigation/index.mjs +1 -6
- package/dist/js/navigation/index.mjs.map +1 -1
- package/dist/js/navigation/ledger-root-builder.js +232 -59
- package/dist/js/navigation/ledger-root-builder.js.map +1 -1
- package/dist/js/navigation/ledger-root-builder.mjs +232 -59
- package/dist/js/navigation/ledger-root-builder.mjs.map +1 -1
- package/dist/js/orpc-client.js +1 -0
- package/dist/js/orpc-client.js.map +1 -1
- package/dist/js/orpc-client.mjs +1 -0
- package/dist/js/orpc-client.mjs.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/navigation/__test__/ledger-root-builder.apiReferenceChildren.test.d.ts +2 -0
- package/dist/types/navigation/__test__/ledger-root-builder.apiReferenceChildren.test.d.ts.map +1 -0
- package/dist/types/navigation/__test__/ledger-root-builder.landingPage.test.d.ts +2 -0
- package/dist/types/navigation/__test__/ledger-root-builder.landingPage.test.d.ts.map +1 -0
- package/dist/types/navigation/__test__/ledger-root-builder.metadataPreservation.test.d.ts +2 -0
- package/dist/types/navigation/__test__/ledger-root-builder.metadataPreservation.test.d.ts.map +1 -0
- package/dist/types/navigation/__test__/ledger-root-builder.rootSlug.test.d.ts +2 -0
- package/dist/types/navigation/__test__/ledger-root-builder.rootSlug.test.d.ts.map +1 -0
- package/dist/types/navigation/__test__/ledger-root-builder.skipSlugTabs.test.d.ts +2 -0
- package/dist/types/navigation/__test__/ledger-root-builder.skipSlugTabs.test.d.ts.map +1 -0
- package/dist/types/navigation/__test__/ledger-root-builder.variantSharedSegments.test.d.ts +2 -0
- package/dist/types/navigation/__test__/ledger-root-builder.variantSharedSegments.test.d.ts.map +1 -0
- package/dist/types/navigation/ledger-root-builder.d.ts +12 -0
- package/dist/types/navigation/ledger-root-builder.d.ts.map +1 -1
- package/dist/types/navigation/utils/findNode.d.ts.map +1 -1
- package/dist/types/navigation/utils/followRedirect.d.ts.map +1 -1
- package/dist/types/orpc-client/docs-ledger/contract.d.ts +50 -0
- package/dist/types/orpc-client/docs-ledger/contract.d.ts.map +1 -1
- package/dist/types/orpc-client/docs-ledger/ledger-manifest.d.ts +12 -0
- package/dist/types/orpc-client/docs-ledger/ledger-manifest.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1082,6 +1082,63 @@ function apiLeafNodeFromNavRouteInternal(ctx, route, segmentApiDefinitionId2) {
|
|
|
1082
1082
|
}
|
|
1083
1083
|
return void 0;
|
|
1084
1084
|
}
|
|
1085
|
+
function apiLeafPositionKey(node) {
|
|
1086
|
+
switch (node.type) {
|
|
1087
|
+
case "endpoint":
|
|
1088
|
+
return `endpoint:${node.endpointId}`;
|
|
1089
|
+
case "webhook":
|
|
1090
|
+
return `webhook:${node.webhookId}`;
|
|
1091
|
+
case "webSocket":
|
|
1092
|
+
return `webSocket:${node.webSocketId}`;
|
|
1093
|
+
case "grpc":
|
|
1094
|
+
return `grpc:${node.grpcId}`;
|
|
1095
|
+
case "graphql":
|
|
1096
|
+
return `graphql:${node.graphqlOperationId}`;
|
|
1097
|
+
}
|
|
1098
|
+
}
|
|
1099
|
+
function apiChildPositionKey(node) {
|
|
1100
|
+
switch (node.type) {
|
|
1101
|
+
case "endpoint":
|
|
1102
|
+
case "webhook":
|
|
1103
|
+
case "webSocket":
|
|
1104
|
+
case "grpc":
|
|
1105
|
+
case "graphql":
|
|
1106
|
+
return apiLeafPositionKey(node);
|
|
1107
|
+
default:
|
|
1108
|
+
return void 0;
|
|
1109
|
+
}
|
|
1110
|
+
}
|
|
1111
|
+
function positionedApiLeafChildren(ctx, nav, apiDefinitionId) {
|
|
1112
|
+
const rawLeafNodes = [];
|
|
1113
|
+
const leafPositions = /* @__PURE__ */ new Map();
|
|
1114
|
+
const nonApiLeafNodes = [];
|
|
1115
|
+
for (let i = 0; i < nav.length; i++) {
|
|
1116
|
+
const route = nav[i];
|
|
1117
|
+
const pos = route.displaySortOrder ?? i;
|
|
1118
|
+
const apiLeaf = apiLeafNodeFromNavRouteInternal(ctx, route, apiDefinitionId);
|
|
1119
|
+
if (apiLeaf != null) {
|
|
1120
|
+
rawLeafNodes.push(apiLeaf);
|
|
1121
|
+
const key = apiLeafPositionKey(apiLeaf);
|
|
1122
|
+
leafPositions.set(key, Math.min(leafPositions.get(key) ?? pos, pos));
|
|
1123
|
+
continue;
|
|
1124
|
+
}
|
|
1125
|
+
const node = artifactToNode(ctx, route);
|
|
1126
|
+
if (node?.type === "page" || node?.type === "link") {
|
|
1127
|
+
nonApiLeafNodes.push({ node, pos });
|
|
1128
|
+
}
|
|
1129
|
+
}
|
|
1130
|
+
const apiLeafNodes = mergeEndpointPairs(ctx, rawLeafNodes, nav);
|
|
1131
|
+
const positionedApiLeafNodes = apiLeafNodes.map((node, index) => {
|
|
1132
|
+
if (node.type === "endpointPair") {
|
|
1133
|
+
const streamPos = leafPositions.get(apiLeafPositionKey(node.stream)) ?? index;
|
|
1134
|
+
const nonStreamPos = leafPositions.get(apiLeafPositionKey(node.nonStream)) ?? index;
|
|
1135
|
+
return { node, pos: Math.min(streamPos, nonStreamPos) };
|
|
1136
|
+
}
|
|
1137
|
+
const key = apiChildPositionKey(node);
|
|
1138
|
+
return { node, pos: key != null ? leafPositions.get(key) ?? index : index };
|
|
1139
|
+
});
|
|
1140
|
+
return [...positionedApiLeafNodes, ...nonApiLeafNodes];
|
|
1141
|
+
}
|
|
1085
1142
|
function collectApiLeafNodesFromNav(routes, basePath, segmentApiDefinitionId2) {
|
|
1086
1143
|
const ctx = createBuildContext(basePath);
|
|
1087
1144
|
return routes.map((route) => apiLeafNodeFromNavRouteInternal(ctx, route, segmentApiDefinitionId2)).filter((node) => node != null);
|
|
@@ -1194,7 +1251,7 @@ function sectionNode(ctx, scoped, sectionChildren, scopePrefix) {
|
|
|
1194
1251
|
collapsed: metaCollapsed(seg.metadata) ?? defaults.collapsed,
|
|
1195
1252
|
overviewPageId: overviewPageId != null ? PageId(overviewPageId) : void 0,
|
|
1196
1253
|
noindex: metaBool(overview?.metadata, "noindex") ?? metaBool(seg.metadata, "noindex"),
|
|
1197
|
-
collapsible: metaBool(seg.metadata, "collapsible") ?? (metaCollapsed(seg.metadata)
|
|
1254
|
+
collapsible: metaBool(seg.metadata, "collapsible") ?? (metaCollapsed(seg.metadata) === true ? true : void 0),
|
|
1198
1255
|
collapsedByDefault: metaBool(seg.metadata, "collapsedByDefault") ?? (metaCollapsed(seg.metadata) === true ? true : void 0),
|
|
1199
1256
|
availability: metaStr(seg.metadata, "availability"),
|
|
1200
1257
|
pointsTo: metaPointsTo != null ? pointsToSlug(metaPointsTo) : void 0,
|
|
@@ -1219,8 +1276,7 @@ function directChildApiPackages(parentSection, scopeSegs) {
|
|
|
1219
1276
|
}
|
|
1220
1277
|
function buildApiChildren(ctx, scoped, scopeSegs, apiDefinitionId, scopePrefix) {
|
|
1221
1278
|
const { seg, nav } = scoped;
|
|
1222
|
-
const
|
|
1223
|
-
const leafNodes = mergeEndpointPairs(ctx, rawLeafNodes, nav);
|
|
1279
|
+
const leafNodes = positionedApiLeafChildren(ctx, nav, apiDefinitionId);
|
|
1224
1280
|
const childPackages = directChildApiPackages(seg.section, scopeSegs);
|
|
1225
1281
|
const packageNodes = childPackages.map((child) => ({
|
|
1226
1282
|
node: apiPackageChildNode(
|
|
@@ -1234,18 +1290,10 @@ function buildApiChildren(ctx, scoped, scopeSegs, apiDefinitionId, scopePrefix)
|
|
|
1234
1290
|
}));
|
|
1235
1291
|
const hasChildIndex = packageNodes.some((p) => p.childIndex != null);
|
|
1236
1292
|
if (!hasChildIndex) {
|
|
1237
|
-
return [...leafNodes, ...packageNodes.map((p) => p.node)];
|
|
1238
|
-
}
|
|
1239
|
-
const leafPositions = [];
|
|
1240
|
-
for (const route of nav) {
|
|
1241
|
-
if (route.displaySortOrder != null) {
|
|
1242
|
-
leafPositions.push(route.displaySortOrder);
|
|
1243
|
-
}
|
|
1293
|
+
return [...leafNodes, ...packageNodes.map((p) => ({ node: p.node, pos: Number.MAX_SAFE_INTEGER }))].sort((a, b) => a.pos - b.pos).map((p) => p.node);
|
|
1244
1294
|
}
|
|
1245
1295
|
const positioned = [];
|
|
1246
|
-
|
|
1247
|
-
positioned.push({ node: leafNodes[i], pos: leafPositions[i] ?? i });
|
|
1248
|
-
}
|
|
1296
|
+
positioned.push(...leafNodes);
|
|
1249
1297
|
for (const p of packageNodes) {
|
|
1250
1298
|
positioned.push({ node: p.node, pos: p.childIndex ?? Number.MAX_SAFE_INTEGER });
|
|
1251
1299
|
}
|
|
@@ -1430,7 +1478,7 @@ function changelogNode(ctx, scoped, scopePrefix) {
|
|
|
1430
1478
|
pageId: PageId(metaStr(r.metadata, "pageId") ?? ""),
|
|
1431
1479
|
noindex: metaBool(r.metadata, "noindex"),
|
|
1432
1480
|
date: dateStr ?? "",
|
|
1433
|
-
tags:
|
|
1481
|
+
tags: metaStrArr(r.metadata, "tags")
|
|
1434
1482
|
};
|
|
1435
1483
|
let months = byYear.get(year);
|
|
1436
1484
|
if (months == null) {
|
|
@@ -1537,17 +1585,55 @@ function buildSectionTree(ctx, scopeSegs, parentPath, scopePrefix, changelogScop
|
|
|
1537
1585
|
return { node, childIndex };
|
|
1538
1586
|
});
|
|
1539
1587
|
}
|
|
1588
|
+
function computeSiblingSortBoundaries(ordered) {
|
|
1589
|
+
const result = /* @__PURE__ */ new Map();
|
|
1590
|
+
const sectionPaths = new Set(ordered.map((s) => s.seg.section));
|
|
1591
|
+
const rootSections = [];
|
|
1592
|
+
for (const s of ordered) {
|
|
1593
|
+
const type = metaStr(s.seg.metadata, "type");
|
|
1594
|
+
const sec = s.seg.section;
|
|
1595
|
+
if (type !== "section" || sec === "") {
|
|
1596
|
+
continue;
|
|
1597
|
+
}
|
|
1598
|
+
const parent = parentSectionPath(sec);
|
|
1599
|
+
const isRootLevel = parent === "" || !sectionPaths.has(parent) && nearestExistingAncestor(sec, sectionPaths) === "";
|
|
1600
|
+
if (isRootLevel) {
|
|
1601
|
+
rootSections.push(s);
|
|
1602
|
+
}
|
|
1603
|
+
}
|
|
1604
|
+
const byPath = /* @__PURE__ */ new Map();
|
|
1605
|
+
for (const s of rootSections) {
|
|
1606
|
+
const group = byPath.get(s.seg.section) ?? [];
|
|
1607
|
+
group.push(s);
|
|
1608
|
+
byPath.set(s.seg.section, group);
|
|
1609
|
+
}
|
|
1610
|
+
for (const [, siblings] of byPath) {
|
|
1611
|
+
if (siblings.length <= 1) {
|
|
1612
|
+
continue;
|
|
1613
|
+
}
|
|
1614
|
+
for (let i = 0; i < siblings.length; i++) {
|
|
1615
|
+
const lo = siblings[i].seg.sortOrder;
|
|
1616
|
+
const hi = i + 1 < siblings.length ? siblings[i + 1].seg.sortOrder : Number.MAX_SAFE_INTEGER;
|
|
1617
|
+
result.set(siblings[i], { lo, hi });
|
|
1618
|
+
}
|
|
1619
|
+
}
|
|
1620
|
+
return result;
|
|
1621
|
+
}
|
|
1540
1622
|
function buildSidebarRootChildren(ctx, scopeSegs, scopePrefix, changelogScopePrefix) {
|
|
1541
1623
|
const ordered = [...scopeSegs].sort((a, b) => a.seg.sortOrder - b.seg.sortOrder);
|
|
1542
1624
|
const sectionPaths = new Set(ordered.map((s) => s.seg.section));
|
|
1543
1625
|
const annotated = [];
|
|
1544
1626
|
const hasRootSection = ordered.some((s) => metaStr(s.seg.metadata, "type") === "section" && s.seg.section === "");
|
|
1627
|
+
const siblingBoundaries = computeSiblingSortBoundaries(ordered);
|
|
1545
1628
|
for (const s of ordered) {
|
|
1546
1629
|
const type = metaStr(s.seg.metadata, "type");
|
|
1547
1630
|
const sec = s.seg.section;
|
|
1548
1631
|
if (hasOwningApiReference(s, scopeSegs)) {
|
|
1549
1632
|
continue;
|
|
1550
1633
|
}
|
|
1634
|
+
if (type === "tabRoot" && metaBool(s.seg.metadata, "landingPage") === true) {
|
|
1635
|
+
continue;
|
|
1636
|
+
}
|
|
1551
1637
|
if (type === "tabRoot" || sec === "" && type !== "section") {
|
|
1552
1638
|
for (const r of s.nav) {
|
|
1553
1639
|
const node = artifactToNode(ctx, r);
|
|
@@ -1575,14 +1661,21 @@ function buildSidebarRootChildren(ctx, scopeSegs, scopePrefix, changelogScopePre
|
|
|
1575
1661
|
} else if (type === "changelog") {
|
|
1576
1662
|
node = changelogNode(ctx, s, changelogScopePrefix ?? scopePrefix);
|
|
1577
1663
|
} else {
|
|
1664
|
+
const bounds = siblingBoundaries.get(s);
|
|
1665
|
+
const ownedSegs = bounds != null ? scopeSegs.filter((seg) => seg.seg.sortOrder >= bounds.lo && seg.seg.sortOrder < bounds.hi) : scopeSegs;
|
|
1578
1666
|
node = sectionNode(
|
|
1579
1667
|
ctx,
|
|
1580
1668
|
s,
|
|
1581
|
-
buildSectionTree(ctx,
|
|
1669
|
+
buildSectionTree(ctx, ownedSegs, sec, scopePrefix, changelogScopePrefix),
|
|
1582
1670
|
scopePrefix
|
|
1583
1671
|
);
|
|
1584
1672
|
}
|
|
1585
|
-
|
|
1673
|
+
const isSharedSection = siblingBoundaries.size > 0 && scopePrefix !== "" && sec !== "" && !sec.startsWith(scopePrefix);
|
|
1674
|
+
annotated.push({
|
|
1675
|
+
node,
|
|
1676
|
+
pos: isSharedSection ? void 0 : metaNum(s.seg.metadata, "childIndex"),
|
|
1677
|
+
isLeaf: false
|
|
1678
|
+
});
|
|
1586
1679
|
}
|
|
1587
1680
|
}
|
|
1588
1681
|
const hasLeafPos = annotated.some((a) => a.isLeaf && a.pos != null);
|
|
@@ -1634,13 +1727,13 @@ function buildSidebarRoot(ctx, scopeSegs, scopePrefix, changelogScopePrefix) {
|
|
|
1634
1727
|
};
|
|
1635
1728
|
}
|
|
1636
1729
|
function buildFullRootFromSegments(options) {
|
|
1637
|
-
const { basePath, title, segments, navBySegment } = options;
|
|
1730
|
+
const { basePath, rootSlug: sourceRootSlug, title, segments, navBySegment, skipSharedSectionMerge } = options;
|
|
1638
1731
|
const ctx = createBuildContext(basePath);
|
|
1639
1732
|
const scoped = segments.filter((seg) => {
|
|
1640
1733
|
const t = metaStr(seg.metadata, "type");
|
|
1641
1734
|
return t !== "files" && t !== "redirects";
|
|
1642
1735
|
}).map((seg) => ({ seg, nav: navBySegment.get(seg.segmentHash) ?? [] }));
|
|
1643
|
-
const rootSlug = asSlug(basePath);
|
|
1736
|
+
const rootSlug = asSlug(sourceRootSlug ?? basePath);
|
|
1644
1737
|
const scopesByKey = /* @__PURE__ */ new Map();
|
|
1645
1738
|
for (const s of scoped) {
|
|
1646
1739
|
const key = scopeKey(s.seg);
|
|
@@ -1653,9 +1746,9 @@ function buildFullRootFromSegments(options) {
|
|
|
1653
1746
|
const tabs = uniqueDetails(scoped, "tab");
|
|
1654
1747
|
let child;
|
|
1655
1748
|
if (products.length > 0) {
|
|
1656
|
-
child = buildProductGroup(ctx, products, scoped, rootSlug);
|
|
1749
|
+
child = buildProductGroup(ctx, products, scoped, rootSlug, skipSharedSectionMerge);
|
|
1657
1750
|
} else if (versions.length > 0) {
|
|
1658
|
-
child = buildVersioned(ctx, versions, scoped, rootSlug, void 0);
|
|
1751
|
+
child = buildVersioned(ctx, versions, scoped, rootSlug, void 0, skipSharedSectionMerge);
|
|
1659
1752
|
} else {
|
|
1660
1753
|
child = buildUnversioned(ctx, scoped, rootSlug, tabs.length > 0);
|
|
1661
1754
|
}
|
|
@@ -1696,21 +1789,22 @@ function buildFullRootFromSegments(options) {
|
|
|
1696
1789
|
return root;
|
|
1697
1790
|
}
|
|
1698
1791
|
function uniqueDetails(scoped, dim) {
|
|
1699
|
-
const
|
|
1792
|
+
const byKey = /* @__PURE__ */ new Map();
|
|
1700
1793
|
for (const s of scoped) {
|
|
1701
1794
|
const d = s.seg[dim];
|
|
1702
1795
|
if (d == null) {
|
|
1703
1796
|
continue;
|
|
1704
1797
|
}
|
|
1705
1798
|
const slug = detailSlug(d);
|
|
1706
|
-
const
|
|
1799
|
+
const key = dim === "tab" ? d.id : slug !== "" ? slug : d.id;
|
|
1800
|
+
const existing = byKey.get(key);
|
|
1707
1801
|
if (existing == null) {
|
|
1708
|
-
|
|
1802
|
+
byKey.set(key, d);
|
|
1709
1803
|
} else if (metaStr(d.metadata, "pointsTo") != null && metaStr(existing.metadata, "pointsTo") == null) {
|
|
1710
|
-
|
|
1804
|
+
byKey.set(key, d);
|
|
1711
1805
|
}
|
|
1712
1806
|
}
|
|
1713
|
-
return [...
|
|
1807
|
+
return [...byKey.values()].sort((a, b) => a.sortOrder - b.sortOrder);
|
|
1714
1808
|
}
|
|
1715
1809
|
function scopeSlugPrefix(rootSlug, ...details) {
|
|
1716
1810
|
const parts = [rootSlug];
|
|
@@ -1761,20 +1855,34 @@ function buildSidebarRootWithVariants(ctx, scopeSegs, scopePrefix, changelogScop
|
|
|
1761
1855
|
if (variants.length <= 1) {
|
|
1762
1856
|
return buildSidebarRoot(ctx, scopeSegs, scopePrefix, changelogScopePrefix);
|
|
1763
1857
|
}
|
|
1858
|
+
const sharedSegs = scopeSegs.filter((s) => s.seg.variant == null);
|
|
1764
1859
|
const variantedNode = buildVariantedNode(ctx, variants, scopeSegs, scopePrefix);
|
|
1860
|
+
const sharedChildren = sharedSegs.length > 0 ? buildSidebarRootChildren(ctx, sharedSegs, scopePrefix, changelogScopePrefix) : [];
|
|
1765
1861
|
const first = scopeSegs[0];
|
|
1766
1862
|
return {
|
|
1767
1863
|
type: "sidebarRoot",
|
|
1768
1864
|
id: ctx.nodeId(`sidebar:${first != null ? scopeKey(first.seg) : "root"}`),
|
|
1769
1865
|
collapsed: void 0,
|
|
1770
|
-
children: [variantedNode]
|
|
1866
|
+
children: [...sharedChildren, variantedNode]
|
|
1771
1867
|
};
|
|
1772
1868
|
}
|
|
1773
1869
|
function buildTabbedOrSidebar(ctx, scopeSegs, tabsPresent, scopePrefix) {
|
|
1774
1870
|
if (!tabsPresent) {
|
|
1775
1871
|
const variants = uniqueDetails(scopeSegs, "variant");
|
|
1776
1872
|
if (variants.length > 1) {
|
|
1777
|
-
|
|
1873
|
+
const sharedSegs = scopeSegs.filter((s) => s.seg.variant == null);
|
|
1874
|
+
const variantedNode = buildVariantedNode(ctx, variants, scopeSegs, scopePrefix);
|
|
1875
|
+
if (sharedSegs.length > 0) {
|
|
1876
|
+
const sharedChildren = buildSidebarRootChildren(ctx, sharedSegs, scopePrefix);
|
|
1877
|
+
const first2 = scopeSegs[0];
|
|
1878
|
+
return {
|
|
1879
|
+
type: "sidebarRoot",
|
|
1880
|
+
id: ctx.nodeId(`sidebar:${first2 != null ? scopeKey(first2.seg) : "root"}`),
|
|
1881
|
+
collapsed: void 0,
|
|
1882
|
+
children: [...sharedChildren, variantedNode]
|
|
1883
|
+
};
|
|
1884
|
+
}
|
|
1885
|
+
return variantedNode;
|
|
1778
1886
|
}
|
|
1779
1887
|
return buildSidebarRoot(ctx, scopeSegs, scopePrefix);
|
|
1780
1888
|
}
|
|
@@ -1854,16 +1962,71 @@ function buildUnversioned(ctx, scopeSegs, scopePrefix, tabsPresent) {
|
|
|
1854
1962
|
type: "unversioned",
|
|
1855
1963
|
id: ctx.nodeId(`unversioned:${first?.seg.product?.id ?? "root"}`),
|
|
1856
1964
|
collapsed: void 0,
|
|
1857
|
-
landingPage:
|
|
1965
|
+
landingPage: buildLandingPage(ctx, scopeSegs),
|
|
1858
1966
|
// The enclosing scope prefix (product slug, or rootSlug at the top
|
|
1859
1967
|
// level) roots structural sections so they share the scope's slug
|
|
1860
1968
|
// namespace.
|
|
1861
1969
|
child: buildTabbedOrSidebar(ctx, scopeSegs, tabsPresent, scopePrefix)
|
|
1862
1970
|
};
|
|
1863
1971
|
}
|
|
1864
|
-
function
|
|
1972
|
+
function mergeSharedSections(defaultSegs, allScoped, defaultVersion, versionSlugs) {
|
|
1973
|
+
const defaultTabsByName = /* @__PURE__ */ new Map();
|
|
1974
|
+
for (const s of defaultSegs) {
|
|
1975
|
+
if (s.seg.tab != null) {
|
|
1976
|
+
const tabName = s.seg.tab.displayName;
|
|
1977
|
+
if (!defaultTabsByName.has(tabName)) {
|
|
1978
|
+
defaultTabsByName.set(tabName, s.seg.tab);
|
|
1979
|
+
}
|
|
1980
|
+
}
|
|
1981
|
+
}
|
|
1982
|
+
const existingSections = new Set(
|
|
1983
|
+
defaultSegs.filter((s) => metaStr(s.seg.metadata, "type") === "section").map((s) => s.seg.section)
|
|
1984
|
+
);
|
|
1985
|
+
const maxSortOrder = defaultSegs.reduce((max, s) => Math.max(max, s.seg.sortOrder), 0);
|
|
1986
|
+
let nextSortOrder = maxSortOrder + 1;
|
|
1987
|
+
const merged = [...defaultSegs];
|
|
1988
|
+
for (const s of allScoped) {
|
|
1989
|
+
if (s.seg.version?.id === defaultVersion.id) {
|
|
1990
|
+
continue;
|
|
1991
|
+
}
|
|
1992
|
+
const type = metaStr(s.seg.metadata, "type");
|
|
1993
|
+
if (type !== "section") {
|
|
1994
|
+
continue;
|
|
1995
|
+
}
|
|
1996
|
+
const sectionPath = s.seg.section;
|
|
1997
|
+
if (versionSlugs.some((vs) => sectionPath === vs || sectionPath.startsWith(vs + "/"))) {
|
|
1998
|
+
continue;
|
|
1999
|
+
}
|
|
2000
|
+
if (existingSections.has(sectionPath)) {
|
|
2001
|
+
continue;
|
|
2002
|
+
}
|
|
2003
|
+
const sourceTabName = s.seg.tab?.displayName ?? "";
|
|
2004
|
+
const targetTab = defaultTabsByName.get(sourceTabName);
|
|
2005
|
+
if (targetTab == null) {
|
|
2006
|
+
continue;
|
|
2007
|
+
}
|
|
2008
|
+
const metadata = s.seg.metadata != null ? { ...s.seg.metadata, childIndex: void 0 } : s.seg.metadata;
|
|
2009
|
+
merged.push({
|
|
2010
|
+
seg: {
|
|
2011
|
+
...s.seg,
|
|
2012
|
+
tab: targetTab,
|
|
2013
|
+
version: defaultVersion,
|
|
2014
|
+
sortOrder: nextSortOrder++,
|
|
2015
|
+
metadata
|
|
2016
|
+
},
|
|
2017
|
+
nav: s.nav
|
|
2018
|
+
});
|
|
2019
|
+
existingSections.add(sectionPath);
|
|
2020
|
+
}
|
|
2021
|
+
return merged;
|
|
2022
|
+
}
|
|
2023
|
+
function buildVersioned(ctx, versions, scoped, rootSlug, productPrefix, skipSharedSectionMerge) {
|
|
2024
|
+
const versionSlugs = versions.map((v) => detailSlug(v)).filter((s) => s !== "");
|
|
1865
2025
|
const children = versions.map((version) => {
|
|
1866
|
-
|
|
2026
|
+
let versionSegs = scoped.filter((s) => s.seg.version?.id === version.id);
|
|
2027
|
+
if (detailIsDefault(version) && !skipSharedSectionMerge) {
|
|
2028
|
+
versionSegs = mergeSharedSections(versionSegs, scoped, version, versionSlugs);
|
|
2029
|
+
}
|
|
1867
2030
|
const tabsPresent = uniqueDetails(versionSegs, "tab").length > 0;
|
|
1868
2031
|
const prefix = productPrefix != null ? productPrefix : rootSlug;
|
|
1869
2032
|
const versionSegment = detailSlug(version);
|
|
@@ -1881,7 +2044,7 @@ function buildVersioned(ctx, versions, scoped, rootSlug, productPrefix) {
|
|
|
1881
2044
|
default: detailIsDefault(version),
|
|
1882
2045
|
versionId: VersionId(version.id),
|
|
1883
2046
|
availability: void 0,
|
|
1884
|
-
landingPage:
|
|
2047
|
+
landingPage: buildLandingPage(ctx, versionSegs),
|
|
1885
2048
|
announcement: void 0,
|
|
1886
2049
|
pointsTo: metaStr(version.metadata, "pointsTo") != null ? pointsToSlug(metaStr(version.metadata, "pointsTo")) : void 0,
|
|
1887
2050
|
// The version's full slug roots structural sections so the whole
|
|
@@ -1962,34 +2125,41 @@ function crossVersionDedupKeys(node, parents) {
|
|
|
1962
2125
|
keys.push([...parentTitles, node.title].join("###"));
|
|
1963
2126
|
return keys;
|
|
1964
2127
|
}
|
|
1965
|
-
function
|
|
1966
|
-
|
|
1967
|
-
if (tablessSegs.length === 0) {
|
|
2128
|
+
function routeToLandingPage(ctx, route) {
|
|
2129
|
+
if (route == null || route.type !== "markdown" || route.fullPath == null) {
|
|
1968
2130
|
return void 0;
|
|
1969
2131
|
}
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
const pageId = metaStr(md, "pageId") ?? "";
|
|
1975
|
-
const slug = ctx.contentSlug(r.fullPath);
|
|
1976
|
-
return {
|
|
1977
|
-
type: "landingPage",
|
|
1978
|
-
...withMetadataDefaults({
|
|
1979
|
-
id: ctx.nodeId(`landing:${slug}`),
|
|
1980
|
-
title: metaStr(md, "title") ?? "",
|
|
1981
|
-
slug,
|
|
1982
|
-
icon: metaStr(md, "icon"),
|
|
1983
|
-
hidden: r.hidden,
|
|
1984
|
-
viewers: toViewers(metaStrArr(md, "viewers"))
|
|
1985
|
-
}),
|
|
1986
|
-
pageId: PageId(pageId),
|
|
1987
|
-
noindex: metaBool(md, "noindex")
|
|
1988
|
-
};
|
|
1989
|
-
}
|
|
1990
|
-
}
|
|
2132
|
+
const md = route.metadata;
|
|
2133
|
+
const pageId = metaStr(md, "pageId");
|
|
2134
|
+
if (pageId == null) {
|
|
2135
|
+
return void 0;
|
|
1991
2136
|
}
|
|
1992
|
-
|
|
2137
|
+
const slug = ctx.contentSlug(route.fullPath);
|
|
2138
|
+
return {
|
|
2139
|
+
type: "landingPage",
|
|
2140
|
+
...withMetadataDefaults({
|
|
2141
|
+
id: ctx.nodeId(`landing:${slug}`),
|
|
2142
|
+
title: metaStr(md, "title") ?? "",
|
|
2143
|
+
slug,
|
|
2144
|
+
icon: metaStr(md, "icon"),
|
|
2145
|
+
hidden: route.hidden,
|
|
2146
|
+
authed: metaBool(md, "authed"),
|
|
2147
|
+
viewers: toViewers(metaStrArr(md, "viewers")),
|
|
2148
|
+
orphaned: metaBool(md, "orphaned"),
|
|
2149
|
+
featureFlags: metaFeatureFlags(md)
|
|
2150
|
+
}),
|
|
2151
|
+
pageId: PageId(pageId),
|
|
2152
|
+
noindex: metaBool(md, "noindex")
|
|
2153
|
+
};
|
|
2154
|
+
}
|
|
2155
|
+
function buildLandingPage(ctx, scopeSegs) {
|
|
2156
|
+
const landingSegment = scopeSegs.find(
|
|
2157
|
+
(s) => metaStr(s.seg.metadata, "type") === "tabRoot" && metaBool(s.seg.metadata, "landingPage") === true
|
|
2158
|
+
);
|
|
2159
|
+
return routeToLandingPage(
|
|
2160
|
+
ctx,
|
|
2161
|
+
landingSegment?.nav.find((route) => route.type === "markdown")
|
|
2162
|
+
);
|
|
1993
2163
|
}
|
|
1994
2164
|
function markCrossVersionCanonicalSlugs(versionNodes) {
|
|
1995
2165
|
const keyToCanonical = /* @__PURE__ */ new Map();
|
|
@@ -2024,13 +2194,13 @@ function markCrossVersionCanonicalSlugs(versionNodes) {
|
|
|
2024
2194
|
});
|
|
2025
2195
|
}
|
|
2026
2196
|
}
|
|
2027
|
-
function buildProductGroup(ctx, products, scoped, rootSlug) {
|
|
2197
|
+
function buildProductGroup(ctx, products, scoped, rootSlug, skipSharedSectionMerge) {
|
|
2028
2198
|
const children = products.map((product) => {
|
|
2029
2199
|
const productSegs = scoped.filter((s) => s.seg.product?.id === product.id);
|
|
2030
2200
|
const versions = uniqueDetails(productSegs, "version");
|
|
2031
2201
|
const tabsPresent = uniqueDetails(productSegs, "tab").length > 0;
|
|
2032
2202
|
const productPrefix = scopeSlugPrefix(rootSlug, product);
|
|
2033
|
-
const productChild = versions.length > 0 ? buildVersioned(ctx, versions, productSegs, rootSlug, productPrefix) : buildUnversioned(ctx, productSegs, asSlug(productPrefix), tabsPresent);
|
|
2203
|
+
const productChild = versions.length > 0 ? buildVersioned(ctx, versions, productSegs, rootSlug, productPrefix, skipSharedSectionMerge) : buildUnversioned(ctx, productSegs, asSlug(productPrefix), tabsPresent);
|
|
2034
2204
|
const node = {
|
|
2035
2205
|
type: "product",
|
|
2036
2206
|
...withMetadataDefaults({
|
|
@@ -2060,7 +2230,10 @@ function buildProductGroup(ctx, products, scoped, rootSlug) {
|
|
|
2060
2230
|
type: "productgroup",
|
|
2061
2231
|
id: ctx.nodeId("productgroup"),
|
|
2062
2232
|
collapsed: void 0,
|
|
2063
|
-
landingPage:
|
|
2233
|
+
landingPage: buildLandingPage(
|
|
2234
|
+
ctx,
|
|
2235
|
+
scoped.filter((s) => s.seg.product == null)
|
|
2236
|
+
),
|
|
2064
2237
|
children
|
|
2065
2238
|
};
|
|
2066
2239
|
}
|