@fern-api/fdr-sdk 1.2.42-715621ac5a → 1.2.42-a13b64c1d6

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.
@@ -1726,6 +1726,13 @@ function nearestExistingAncestor(sectionPath, existing) {
1726
1726
  }
1727
1727
  function buildSectionTree(ctx, scopeSegs, parentPath, scopePrefix, changelogScopePrefix) {
1728
1728
  const sectionPaths = new Set(scopeSegs.map((s) => s.seg.section));
1729
+ const parentCandidates = scopeSegs.filter((s) => s.seg.section === parentPath);
1730
+ const parentSeg = parentCandidates.length > 1 ? parentCandidates.reduce((best, cur) => {
1731
+ const bd = metaNum(best.seg.metadata, "sidebarDepth") ?? Number.MAX_SAFE_INTEGER;
1732
+ const cd = metaNum(cur.seg.metadata, "sidebarDepth") ?? Number.MAX_SAFE_INTEGER;
1733
+ return cd < bd ? cur : best;
1734
+ }) : parentCandidates[0];
1735
+ const parentDepth = parentSeg != null ? metaNum(parentSeg.seg.metadata, "sidebarDepth") : void 0;
1729
1736
  const direct = scopeSegs.filter((s) => {
1730
1737
  const sec = s.seg.section;
1731
1738
  const type = metaStr(s.seg.metadata, "type");
@@ -1739,6 +1746,12 @@ function buildSectionTree(ctx, scopeSegs, parentPath, scopePrefix, changelogScop
1739
1746
  if (depth === 0) {
1740
1747
  return false;
1741
1748
  }
1749
+ if (sec === parentPath && s !== parentSeg && depth != null && parentDepth != null && depth > parentDepth) {
1750
+ return true;
1751
+ }
1752
+ if (parentDepth != null && depth != null && depth <= parentDepth) {
1753
+ return false;
1754
+ }
1742
1755
  const parent = parentSectionPath(sec);
1743
1756
  if (parent === parentPath) {
1744
1757
  return true;
@@ -1758,16 +1771,21 @@ function buildSectionTree(ctx, scopeSegs, parentPath, scopePrefix, changelogScop
1758
1771
  } else if (type === "changelog") {
1759
1772
  node = changelogNode(ctx, s, changelogScopePrefix ?? scopePrefix);
1760
1773
  } else {
1761
- const boundary = siblingBoundaries.get(s);
1762
- const childScopeSegs = boundary != null ? scopeSegs.filter(
1763
- (candidate) => candidate.seg.sortOrder >= boundary.lo && candidate.seg.sortOrder < boundary.hi
1764
- ) : scopeSegs;
1765
- node = sectionNode(
1766
- ctx,
1767
- s,
1768
- buildSectionTree(ctx, childScopeSegs, s.seg.section, scopePrefix, changelogScopePrefix),
1769
- scopePrefix
1770
- );
1774
+ const isSkipSlugChild = s.seg.section === parentPath;
1775
+ if (isSkipSlugChild) {
1776
+ node = sectionNode(ctx, s, [], scopePrefix);
1777
+ } else {
1778
+ const boundary = siblingBoundaries.get(s);
1779
+ const childScopeSegs = boundary != null ? scopeSegs.filter(
1780
+ (candidate) => candidate.seg.sortOrder >= boundary.lo && candidate.seg.sortOrder < boundary.hi
1781
+ ) : scopeSegs;
1782
+ node = sectionNode(
1783
+ ctx,
1784
+ s,
1785
+ buildSectionTree(ctx, childScopeSegs, s.seg.section, scopePrefix, changelogScopePrefix),
1786
+ scopePrefix
1787
+ );
1788
+ }
1771
1789
  }
1772
1790
  return { node, childIndex };
1773
1791
  });
@@ -1793,8 +1811,18 @@ function computeSiblingSortBoundaries(ordered) {
1793
1811
  rootSections.push(s);
1794
1812
  }
1795
1813
  }
1796
- const byPath = /* @__PURE__ */ new Map();
1814
+ const depth0Paths = /* @__PURE__ */ new Set();
1797
1815
  for (const s of rootSections) {
1816
+ if (metaNum(s.seg.metadata, "sidebarDepth") === 0) {
1817
+ depth0Paths.add(s.seg.section);
1818
+ }
1819
+ }
1820
+ const effectiveRootSections = rootSections.filter((s) => {
1821
+ const d = metaNum(s.seg.metadata, "sidebarDepth");
1822
+ return d === 0 || d == null || !depth0Paths.has(s.seg.section);
1823
+ });
1824
+ const byPath = /* @__PURE__ */ new Map();
1825
+ for (const s of effectiveRootSections) {
1798
1826
  const group = byPath.get(s.seg.section) ?? [];
1799
1827
  group.push(s);
1800
1828
  byPath.set(s.seg.section, group);
@@ -1819,6 +1847,12 @@ function buildSidebarRootChildren(ctx, scopeSegs, scopePrefix, changelogScopePre
1819
1847
  const hasRootSection = ordered.some(
1820
1848
  (s) => metaStr(s.seg.metadata, "type") === "section" && s.seg.section === "" && (metaNum(s.seg.metadata, "childIndex") == null || siblingBoundaries.has(s))
1821
1849
  );
1850
+ const depth0SectionPaths = /* @__PURE__ */ new Set();
1851
+ for (const s of ordered) {
1852
+ if (metaStr(s.seg.metadata, "type") === "section" && metaNum(s.seg.metadata, "sidebarDepth") === 0) {
1853
+ depth0SectionPaths.add(s.seg.section);
1854
+ }
1855
+ }
1822
1856
  for (const s of ordered) {
1823
1857
  const type = metaStr(s.seg.metadata, "type");
1824
1858
  const sec = s.seg.section;
@@ -1859,6 +1893,9 @@ function buildSidebarRootChildren(ctx, scopeSegs, scopePrefix, changelogScopePre
1859
1893
  if (isRootLevel && hasRootSection && sec !== "" && depth !== 0) {
1860
1894
  continue;
1861
1895
  }
1896
+ if (isRootLevel && depth != null && depth > 0 && depth0SectionPaths.has(sec)) {
1897
+ continue;
1898
+ }
1862
1899
  if (isRootLevel) {
1863
1900
  let node;
1864
1901
  if (API_NODE_SEGMENT_TYPES.has(type ?? "")) {