@fern-api/fdr-sdk 1.2.44-345d4ef0ea → 1.2.44-72dfb6b83c

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.
Files changed (40) hide show
  1. package/dist/js/converters/index.js +9 -2
  2. package/dist/js/converters/index.js.map +1 -1
  3. package/dist/js/converters/index.mjs +9 -2
  4. package/dist/js/converters/index.mjs.map +1 -1
  5. package/dist/js/index.js +9 -2
  6. package/dist/js/index.js.map +1 -1
  7. package/dist/js/index.mjs +9 -2
  8. package/dist/js/index.mjs.map +1 -1
  9. package/dist/js/navigation/index.js +9 -2
  10. package/dist/js/navigation/index.js.map +1 -1
  11. package/dist/js/navigation/index.mjs +9 -2
  12. package/dist/js/navigation/index.mjs.map +1 -1
  13. package/dist/js/navigation/ledger-root-builder.js +25 -3
  14. package/dist/js/navigation/ledger-root-builder.js.map +1 -1
  15. package/dist/js/navigation/ledger-root-builder.mjs +25 -3
  16. package/dist/js/navigation/ledger-root-builder.mjs.map +1 -1
  17. package/dist/navigation/__test__/ledger-root-builder.contentfulRedirectRepro.test.d.ts +2 -0
  18. package/dist/navigation/__test__/ledger-root-builder.contentfulRedirectRepro.test.d.ts.map +1 -0
  19. package/dist/navigation/__test__/ledger-root-builder.contentfulRedirectRepro.test.js +308 -0
  20. package/dist/navigation/__test__/ledger-root-builder.contentfulRedirectRepro.test.js.map +1 -0
  21. package/dist/navigation/__test__/ledger-root-builder.pointsTo.test.js +122 -10
  22. package/dist/navigation/__test__/ledger-root-builder.pointsTo.test.js.map +1 -1
  23. package/dist/navigation/__test__/ledger-root-builder.rootChildOrder.test.js +5 -5
  24. package/dist/navigation/__test__/ledger-root-builder.rootChildOrder.test.js.map +1 -1
  25. package/dist/navigation/__test__/ledger-root-builder.sidebarDepth.test.js +194 -0
  26. package/dist/navigation/__test__/ledger-root-builder.sidebarDepth.test.js.map +1 -1
  27. package/dist/navigation/__test__/ledger-root-builder.skipSlugSiblingSection.test.js +86 -0
  28. package/dist/navigation/__test__/ledger-root-builder.skipSlugSiblingSection.test.js.map +1 -1
  29. package/dist/navigation/ledger-root-builder.d.ts.map +1 -1
  30. package/dist/navigation/ledger-root-builder.js +45 -5
  31. package/dist/navigation/ledger-root-builder.js.map +1 -1
  32. package/dist/navigation/utils/updatePointsTo.d.ts.map +1 -1
  33. package/dist/navigation/utils/updatePointsTo.js +12 -4
  34. package/dist/navigation/utils/updatePointsTo.js.map +1 -1
  35. package/dist/tsconfig.tsbuildinfo +1 -1
  36. package/dist/types/navigation/__test__/ledger-root-builder.contentfulRedirectRepro.test.d.ts +2 -0
  37. package/dist/types/navigation/__test__/ledger-root-builder.contentfulRedirectRepro.test.d.ts.map +1 -0
  38. package/dist/types/navigation/ledger-root-builder.d.ts.map +1 -1
  39. package/dist/types/navigation/utils/updatePointsTo.d.ts.map +1 -1
  40. package/package.json +1 -1
@@ -1718,6 +1718,13 @@ function buildSectionTree(ctx, scopeSegs, parentPath, scopePrefix, changelogScop
1718
1718
  if (!sectionPaths.has(parent)) {
1719
1719
  return nearestExistingAncestor(sec, sectionPaths) === parentPath;
1720
1720
  }
1721
+ if (depth != null) {
1722
+ const pSeg = scopeSegs.find((c) => c.seg.section === parent);
1723
+ const pDepth = pSeg != null ? metaNum(pSeg.seg.metadata, "sidebarDepth") : void 0;
1724
+ if (pDepth != null && depth <= pDepth) {
1725
+ return nearestExistingAncestor(parent, sectionPaths) === parentPath;
1726
+ }
1727
+ }
1721
1728
  return false;
1722
1729
  }).sort((a, b) => a.seg.sortOrder - b.seg.sortOrder);
1723
1730
  const siblingBoundaries = computeDuplicateSiblingSortBoundaries(direct);
@@ -1806,6 +1813,9 @@ function buildSidebarRootChildren(ctx, scopeSegs, scopePrefix, changelogScopePre
1806
1813
  const hasRootSection = ordered.some(
1807
1814
  (s) => metaStr(s.seg.metadata, "type") === "section" && s.seg.section === "" && (metaNum(s.seg.metadata, "childIndex") == null || siblingBoundaries.has(s))
1808
1815
  );
1816
+ const hasTrueRootWrapper = ordered.some(
1817
+ (s) => metaStr(s.seg.metadata, "type") === "section" && s.seg.section === "" && metaNum(s.seg.metadata, "childIndex") == null
1818
+ );
1809
1819
  const depth0SectionPaths = /* @__PURE__ */ new Set();
1810
1820
  for (const s of ordered) {
1811
1821
  if (metaStr(s.seg.metadata, "type") === "section" && metaNum(s.seg.metadata, "sidebarDepth") === 0) {
@@ -1840,7 +1850,15 @@ function buildSidebarRootChildren(ctx, scopeSegs, scopePrefix, changelogScopePre
1840
1850
  }
1841
1851
  if (type === "section" && sec === "" && hasRootSection) {
1842
1852
  const bounds = siblingBoundaries.get(s);
1843
- const ownedSegs = bounds != null ? scopeSegs.filter((seg) => seg.seg.sortOrder >= bounds.lo && seg.seg.sortOrder < bounds.hi) : scopeSegs;
1853
+ let ownedSegs = bounds != null ? scopeSegs.filter((seg) => seg.seg.sortOrder >= bounds.lo && seg.seg.sortOrder < bounds.hi) : scopeSegs;
1854
+ if (!hasTrueRootWrapper) {
1855
+ ownedSegs = ownedSegs.filter((o) => {
1856
+ if (o.seg.section === "") {
1857
+ return true;
1858
+ }
1859
+ return metaNum(o.seg.metadata, "sidebarDepth") != null;
1860
+ });
1861
+ }
1844
1862
  const sectionChildren = buildSectionTree(ctx, ownedSegs, "", scopePrefix, changelogScopePrefix);
1845
1863
  const node = sectionNode(ctx, s, sectionChildren, scopePrefix);
1846
1864
  annotated.push({ node, pos: metaNum(s.seg.metadata, "childIndex"), isLeaf: false });
@@ -1849,7 +1867,7 @@ function buildSidebarRootChildren(ctx, scopeSegs, scopePrefix, changelogScopePre
1849
1867
  const depth = metaNum(s.seg.metadata, "sidebarDepth");
1850
1868
  const parent = parentSectionPath(sec);
1851
1869
  const isRootLevel = depth === 0 || parent === "" || !sectionPaths.has(parent) && nearestExistingAncestor(sec, sectionPaths) === "";
1852
- if (isRootLevel && hasRootSection && sec !== "" && depth !== 0) {
1870
+ if (isRootLevel && hasRootSection && sec !== "" && (depth != null ? depth !== 0 : hasTrueRootWrapper)) {
1853
1871
  continue;
1854
1872
  }
1855
1873
  if (isRootLevel && depth != null && depth > 0 && depth0SectionPaths.has(sec)) {
@@ -1883,7 +1901,11 @@ function buildSidebarRootChildren(ctx, scopeSegs, scopePrefix, changelogScopePre
1883
1901
  const hasLeafPos = annotated.some((a) => a.isLeaf && a.pos != null);
1884
1902
  const hasSegmentPos = annotated.some((a) => !a.isLeaf && a.pos != null);
1885
1903
  const flat = hasLeafPos && hasSegmentPos ? annotated.map((a, seq) => ({ ...a, seq })).sort(
1886
- (x, y) => (x.pos ?? Number.MAX_SAFE_INTEGER) - (y.pos ?? Number.MAX_SAFE_INTEGER) || x.seq - y.seq
1904
+ (x, y) => (x.pos ?? Number.MAX_SAFE_INTEGER) - (y.pos ?? Number.MAX_SAFE_INTEGER) || // When positions tie, prefer structural nodes (sections) over
1905
+ // leaves (pages). This handles stale tabRoot nav entries whose
1906
+ // displaySortOrder wasn't updated due to content-addressing
1907
+ // (the segment hash doesn't include childPosition).
1908
+ (x.isLeaf === y.isLeaf ? 0 : x.isLeaf ? 1 : -1) || x.seq - y.seq
1887
1909
  ).map((a) => a.node) : annotated.map((a) => a.node);
1888
1910
  return groupSidebarRootChildren(ctx, flat);
1889
1911
  }