@fern-api/fdr-sdk 1.2.39-b5d93657fe → 1.2.39-b6eaa342cf
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 +87 -18
- package/dist/js/navigation/ledger-root-builder.js.map +1 -1
- package/dist/js/navigation/ledger-root-builder.mjs +87 -18
- package/dist/js/navigation/ledger-root-builder.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.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.unversionedPointsTo.test.d.ts +2 -0
- package/dist/types/navigation/__test__/ledger-root-builder.unversionedPointsTo.test.d.ts.map +1 -0
- package/dist/types/navigation/ledger-root-builder.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);
|
|
@@ -1191,7 +1248,9 @@ function sectionNode(ctx, scoped, sectionChildren, scopePrefix) {
|
|
|
1191
1248
|
return {
|
|
1192
1249
|
type: "section",
|
|
1193
1250
|
...defaults,
|
|
1194
|
-
collapsed:
|
|
1251
|
+
// V2 convention: collapsed:false in docs.yml maps to "open-by-default"
|
|
1252
|
+
// so getInitiallyOpenByDefaultNodes picks it up and the UI starts open.
|
|
1253
|
+
collapsed: metaCollapsed(seg.metadata) === false ? "open-by-default" : metaCollapsed(seg.metadata) ?? defaults.collapsed,
|
|
1195
1254
|
overviewPageId: overviewPageId != null ? PageId(overviewPageId) : void 0,
|
|
1196
1255
|
noindex: metaBool(overview?.metadata, "noindex") ?? metaBool(seg.metadata, "noindex"),
|
|
1197
1256
|
collapsible: metaBool(seg.metadata, "collapsible") ?? (metaCollapsed(seg.metadata) != null ? true : void 0),
|
|
@@ -1219,8 +1278,7 @@ function directChildApiPackages(parentSection, scopeSegs) {
|
|
|
1219
1278
|
}
|
|
1220
1279
|
function buildApiChildren(ctx, scoped, scopeSegs, apiDefinitionId, scopePrefix) {
|
|
1221
1280
|
const { seg, nav } = scoped;
|
|
1222
|
-
const
|
|
1223
|
-
const leafNodes = mergeEndpointPairs(ctx, rawLeafNodes, nav);
|
|
1281
|
+
const leafNodes = positionedApiLeafChildren(ctx, nav, apiDefinitionId);
|
|
1224
1282
|
const childPackages = directChildApiPackages(seg.section, scopeSegs);
|
|
1225
1283
|
const packageNodes = childPackages.map((child) => ({
|
|
1226
1284
|
node: apiPackageChildNode(
|
|
@@ -1234,18 +1292,10 @@ function buildApiChildren(ctx, scoped, scopeSegs, apiDefinitionId, scopePrefix)
|
|
|
1234
1292
|
}));
|
|
1235
1293
|
const hasChildIndex = packageNodes.some((p) => p.childIndex != null);
|
|
1236
1294
|
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
|
-
}
|
|
1295
|
+
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
1296
|
}
|
|
1245
1297
|
const positioned = [];
|
|
1246
|
-
|
|
1247
|
-
positioned.push({ node: leafNodes[i], pos: leafPositions[i] ?? i });
|
|
1248
|
-
}
|
|
1298
|
+
positioned.push(...leafNodes);
|
|
1249
1299
|
for (const p of packageNodes) {
|
|
1250
1300
|
positioned.push({ node: p.node, pos: p.childIndex ?? Number.MAX_SAFE_INTEGER });
|
|
1251
1301
|
}
|
|
@@ -1666,6 +1716,24 @@ function buildFullRootFromSegments(options) {
|
|
|
1666
1716
|
} else if (child.type === "versioned") {
|
|
1667
1717
|
const defaultVersion = child.children.find((v) => v.default) ?? child.children[0];
|
|
1668
1718
|
rootPointsTo = defaultVersion?.pointsTo;
|
|
1719
|
+
} else if (child.type === "unversioned") {
|
|
1720
|
+
if (tabs.length > 0) {
|
|
1721
|
+
const firstTab = tabs[0];
|
|
1722
|
+
const pt = firstTab != null ? metaStr(firstTab.metadata, "pointsTo") : void 0;
|
|
1723
|
+
rootPointsTo = pt != null ? pointsToSlug(pt) : void 0;
|
|
1724
|
+
} else {
|
|
1725
|
+
const sorted = [...scoped].sort((a, b) => a.seg.sortOrder - b.seg.sortOrder);
|
|
1726
|
+
for (const s of sorted) {
|
|
1727
|
+
if (s.seg.hidden) {
|
|
1728
|
+
continue;
|
|
1729
|
+
}
|
|
1730
|
+
const pt = metaStr(s.seg.metadata, "pointsTo");
|
|
1731
|
+
if (pt != null) {
|
|
1732
|
+
rootPointsTo = pointsToSlug(pt);
|
|
1733
|
+
break;
|
|
1734
|
+
}
|
|
1735
|
+
}
|
|
1736
|
+
}
|
|
1669
1737
|
}
|
|
1670
1738
|
const root = {
|
|
1671
1739
|
type: "root",
|
|
@@ -1678,21 +1746,22 @@ function buildFullRootFromSegments(options) {
|
|
|
1678
1746
|
return root;
|
|
1679
1747
|
}
|
|
1680
1748
|
function uniqueDetails(scoped, dim) {
|
|
1681
|
-
const
|
|
1749
|
+
const byKey = /* @__PURE__ */ new Map();
|
|
1682
1750
|
for (const s of scoped) {
|
|
1683
1751
|
const d = s.seg[dim];
|
|
1684
1752
|
if (d == null) {
|
|
1685
1753
|
continue;
|
|
1686
1754
|
}
|
|
1687
1755
|
const slug = detailSlug(d);
|
|
1688
|
-
const
|
|
1756
|
+
const key = dim === "tab" ? d.id : slug !== "" ? slug : d.id;
|
|
1757
|
+
const existing = byKey.get(key);
|
|
1689
1758
|
if (existing == null) {
|
|
1690
|
-
|
|
1759
|
+
byKey.set(key, d);
|
|
1691
1760
|
} else if (metaStr(d.metadata, "pointsTo") != null && metaStr(existing.metadata, "pointsTo") == null) {
|
|
1692
|
-
|
|
1761
|
+
byKey.set(key, d);
|
|
1693
1762
|
}
|
|
1694
1763
|
}
|
|
1695
|
-
return [...
|
|
1764
|
+
return [...byKey.values()].sort((a, b) => a.sortOrder - b.sortOrder);
|
|
1696
1765
|
}
|
|
1697
1766
|
function scopeSlugPrefix(rootSlug, ...details) {
|
|
1698
1767
|
const parts = [rootSlug];
|