@fern-api/fdr-sdk 1.2.39-adc66218ce → 1.2.39-afedd1fee5

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 (42) hide show
  1. package/dist/js/client/FdrClient.js +1 -0
  2. package/dist/js/client/FdrClient.js.map +1 -1
  3. package/dist/js/client/FdrClient.mjs +1 -0
  4. package/dist/js/client/FdrClient.mjs.map +1 -1
  5. package/dist/js/converters/index.js +1 -6
  6. package/dist/js/converters/index.js.map +1 -1
  7. package/dist/js/converters/index.mjs +1 -6
  8. package/dist/js/converters/index.mjs.map +1 -1
  9. package/dist/js/index.js +2 -6
  10. package/dist/js/index.js.map +1 -1
  11. package/dist/js/index.mjs +2 -6
  12. package/dist/js/index.mjs.map +1 -1
  13. package/dist/js/navigation/index.js +1 -6
  14. package/dist/js/navigation/index.js.map +1 -1
  15. package/dist/js/navigation/index.mjs +1 -6
  16. package/dist/js/navigation/index.mjs.map +1 -1
  17. package/dist/js/navigation/ledger-root-builder.js +126 -17
  18. package/dist/js/navigation/ledger-root-builder.js.map +1 -1
  19. package/dist/js/navigation/ledger-root-builder.mjs +126 -17
  20. package/dist/js/navigation/ledger-root-builder.mjs.map +1 -1
  21. package/dist/js/orpc-client.js +1 -0
  22. package/dist/js/orpc-client.js.map +1 -1
  23. package/dist/js/orpc-client.mjs +1 -0
  24. package/dist/js/orpc-client.mjs.map +1 -1
  25. package/dist/tsconfig.tsbuildinfo +1 -1
  26. package/dist/types/navigation/__test__/ledger-root-builder.collapsedDeterminism.test.d.ts +2 -0
  27. package/dist/types/navigation/__test__/ledger-root-builder.collapsedDeterminism.test.d.ts.map +1 -0
  28. package/dist/types/navigation/__test__/ledger-root-builder.metadataPreservation.test.d.ts +2 -0
  29. package/dist/types/navigation/__test__/ledger-root-builder.metadataPreservation.test.d.ts.map +1 -0
  30. package/dist/types/navigation/__test__/ledger-root-builder.rootSlug.test.d.ts +2 -0
  31. package/dist/types/navigation/__test__/ledger-root-builder.rootSlug.test.d.ts.map +1 -0
  32. package/dist/types/navigation/__test__/ledger-root-builder.variantSharedSegments.test.d.ts +2 -0
  33. package/dist/types/navigation/__test__/ledger-root-builder.variantSharedSegments.test.d.ts.map +1 -0
  34. package/dist/types/navigation/ledger-root-builder.d.ts +12 -0
  35. package/dist/types/navigation/ledger-root-builder.d.ts.map +1 -1
  36. package/dist/types/navigation/utils/findNode.d.ts.map +1 -1
  37. package/dist/types/navigation/utils/followRedirect.d.ts.map +1 -1
  38. package/dist/types/orpc-client/docs-ledger/contract.d.ts +50 -0
  39. package/dist/types/orpc-client/docs-ledger/contract.d.ts.map +1 -1
  40. package/dist/types/orpc-client/docs-ledger/ledger-manifest.d.ts +12 -0
  41. package/dist/types/orpc-client/docs-ledger/ledger-manifest.d.ts.map +1 -1
  42. package/package.json +1 -1
@@ -1289,12 +1289,10 @@ function sectionNode(ctx, scoped, sectionChildren, scopePrefix) {
1289
1289
  return {
1290
1290
  type: "section",
1291
1291
  ...defaults,
1292
- // V2 convention: collapsed:false in docs.yml maps to "open-by-default"
1293
- // so getInitiallyOpenByDefaultNodes picks it up and the UI starts open.
1294
- collapsed: metaCollapsed(seg.metadata) === false ? "open-by-default" : metaCollapsed(seg.metadata) ?? defaults.collapsed,
1292
+ collapsed: metaCollapsed(seg.metadata) ?? defaults.collapsed,
1295
1293
  overviewPageId: overviewPageId != null ? PageId(overviewPageId) : void 0,
1296
1294
  noindex: metaBool(overview?.metadata, "noindex") ?? metaBool(seg.metadata, "noindex"),
1297
- collapsible: metaBool(seg.metadata, "collapsible") ?? (metaCollapsed(seg.metadata) != null ? true : void 0),
1295
+ collapsible: metaBool(seg.metadata, "collapsible") ?? (metaCollapsed(seg.metadata) === true ? true : void 0),
1298
1296
  collapsedByDefault: metaBool(seg.metadata, "collapsedByDefault") ?? (metaCollapsed(seg.metadata) === true ? true : void 0),
1299
1297
  availability: metaStr(seg.metadata, "availability"),
1300
1298
  pointsTo: metaPointsTo != null ? pointsToSlug(metaPointsTo) : void 0,
@@ -1521,7 +1519,7 @@ function changelogNode(ctx, scoped, scopePrefix) {
1521
1519
  pageId: PageId(metaStr(r.metadata, "pageId") ?? ""),
1522
1520
  noindex: metaBool(r.metadata, "noindex"),
1523
1521
  date: dateStr ?? "",
1524
- tags: void 0
1522
+ tags: metaStrArr(r.metadata, "tags")
1525
1523
  };
1526
1524
  let months = byYear.get(year);
1527
1525
  if (months == null) {
@@ -1628,11 +1626,46 @@ function buildSectionTree(ctx, scopeSegs, parentPath, scopePrefix, changelogScop
1628
1626
  return { node, childIndex };
1629
1627
  });
1630
1628
  }
1629
+ function computeSiblingSortBoundaries(ordered) {
1630
+ const result = /* @__PURE__ */ new Map();
1631
+ const sectionPaths = new Set(ordered.map((s) => s.seg.section));
1632
+ const rootSections = [];
1633
+ for (const s of ordered) {
1634
+ const type = metaStr(s.seg.metadata, "type");
1635
+ const sec = s.seg.section;
1636
+ if (type !== "section" || sec === "") {
1637
+ continue;
1638
+ }
1639
+ const parent = parentSectionPath(sec);
1640
+ const isRootLevel = parent === "" || !sectionPaths.has(parent) && nearestExistingAncestor(sec, sectionPaths) === "";
1641
+ if (isRootLevel) {
1642
+ rootSections.push(s);
1643
+ }
1644
+ }
1645
+ const byPath = /* @__PURE__ */ new Map();
1646
+ for (const s of rootSections) {
1647
+ const group = byPath.get(s.seg.section) ?? [];
1648
+ group.push(s);
1649
+ byPath.set(s.seg.section, group);
1650
+ }
1651
+ for (const [, siblings] of byPath) {
1652
+ if (siblings.length <= 1) {
1653
+ continue;
1654
+ }
1655
+ for (let i = 0; i < siblings.length; i++) {
1656
+ const lo = siblings[i].seg.sortOrder;
1657
+ const hi = i + 1 < siblings.length ? siblings[i + 1].seg.sortOrder : Number.MAX_SAFE_INTEGER;
1658
+ result.set(siblings[i], { lo, hi });
1659
+ }
1660
+ }
1661
+ return result;
1662
+ }
1631
1663
  function buildSidebarRootChildren(ctx, scopeSegs, scopePrefix, changelogScopePrefix) {
1632
1664
  const ordered = [...scopeSegs].sort((a, b) => a.seg.sortOrder - b.seg.sortOrder);
1633
1665
  const sectionPaths = new Set(ordered.map((s) => s.seg.section));
1634
1666
  const annotated = [];
1635
1667
  const hasRootSection = ordered.some((s) => metaStr(s.seg.metadata, "type") === "section" && s.seg.section === "");
1668
+ const siblingBoundaries = computeSiblingSortBoundaries(ordered);
1636
1669
  for (const s of ordered) {
1637
1670
  const type = metaStr(s.seg.metadata, "type");
1638
1671
  const sec = s.seg.section;
@@ -1669,14 +1702,21 @@ function buildSidebarRootChildren(ctx, scopeSegs, scopePrefix, changelogScopePre
1669
1702
  } else if (type === "changelog") {
1670
1703
  node = changelogNode(ctx, s, changelogScopePrefix ?? scopePrefix);
1671
1704
  } else {
1705
+ const bounds = siblingBoundaries.get(s);
1706
+ const ownedSegs = bounds != null ? scopeSegs.filter((seg) => seg.seg.sortOrder >= bounds.lo && seg.seg.sortOrder < bounds.hi) : scopeSegs;
1672
1707
  node = sectionNode(
1673
1708
  ctx,
1674
1709
  s,
1675
- buildSectionTree(ctx, scopeSegs, sec, scopePrefix, changelogScopePrefix),
1710
+ buildSectionTree(ctx, ownedSegs, sec, scopePrefix, changelogScopePrefix),
1676
1711
  scopePrefix
1677
1712
  );
1678
1713
  }
1679
- annotated.push({ node, pos: metaNum(s.seg.metadata, "childIndex"), isLeaf: false });
1714
+ const isSharedSection = siblingBoundaries.size > 0 && scopePrefix !== "" && sec !== "" && !sec.startsWith(scopePrefix);
1715
+ annotated.push({
1716
+ node,
1717
+ pos: isSharedSection ? void 0 : metaNum(s.seg.metadata, "childIndex"),
1718
+ isLeaf: false
1719
+ });
1680
1720
  }
1681
1721
  }
1682
1722
  const hasLeafPos = annotated.some((a) => a.isLeaf && a.pos != null);
@@ -1728,13 +1768,13 @@ function buildSidebarRoot(ctx, scopeSegs, scopePrefix, changelogScopePrefix) {
1728
1768
  };
1729
1769
  }
1730
1770
  function buildFullRootFromSegments(options) {
1731
- const { basePath, title, segments, navBySegment } = options;
1771
+ const { basePath, rootSlug: sourceRootSlug, title, segments, navBySegment, skipSharedSectionMerge } = options;
1732
1772
  const ctx = createBuildContext(basePath);
1733
1773
  const scoped = segments.filter((seg) => {
1734
1774
  const t = metaStr(seg.metadata, "type");
1735
1775
  return t !== "files" && t !== "redirects";
1736
1776
  }).map((seg) => ({ seg, nav: navBySegment.get(seg.segmentHash) ?? [] }));
1737
- const rootSlug = asSlug(basePath);
1777
+ const rootSlug = asSlug(sourceRootSlug ?? basePath);
1738
1778
  const scopesByKey = /* @__PURE__ */ new Map();
1739
1779
  for (const s of scoped) {
1740
1780
  const key = scopeKey(s.seg);
@@ -1747,9 +1787,9 @@ function buildFullRootFromSegments(options) {
1747
1787
  const tabs = uniqueDetails(scoped, "tab");
1748
1788
  let child;
1749
1789
  if (products.length > 0) {
1750
- child = buildProductGroup(ctx, products, scoped, rootSlug);
1790
+ child = buildProductGroup(ctx, products, scoped, rootSlug, skipSharedSectionMerge);
1751
1791
  } else if (versions.length > 0) {
1752
- child = buildVersioned(ctx, versions, scoped, rootSlug, void 0);
1792
+ child = buildVersioned(ctx, versions, scoped, rootSlug, void 0, skipSharedSectionMerge);
1753
1793
  } else {
1754
1794
  child = buildUnversioned(ctx, scoped, rootSlug, tabs.length > 0);
1755
1795
  }
@@ -1856,20 +1896,34 @@ function buildSidebarRootWithVariants(ctx, scopeSegs, scopePrefix, changelogScop
1856
1896
  if (variants.length <= 1) {
1857
1897
  return buildSidebarRoot(ctx, scopeSegs, scopePrefix, changelogScopePrefix);
1858
1898
  }
1899
+ const sharedSegs = scopeSegs.filter((s) => s.seg.variant == null);
1859
1900
  const variantedNode = buildVariantedNode(ctx, variants, scopeSegs, scopePrefix);
1901
+ const sharedChildren = sharedSegs.length > 0 ? buildSidebarRootChildren(ctx, sharedSegs, scopePrefix, changelogScopePrefix) : [];
1860
1902
  const first = scopeSegs[0];
1861
1903
  return {
1862
1904
  type: "sidebarRoot",
1863
1905
  id: ctx.nodeId(`sidebar:${first != null ? scopeKey(first.seg) : "root"}`),
1864
1906
  collapsed: void 0,
1865
- children: [variantedNode]
1907
+ children: [...sharedChildren, variantedNode]
1866
1908
  };
1867
1909
  }
1868
1910
  function buildTabbedOrSidebar(ctx, scopeSegs, tabsPresent, scopePrefix) {
1869
1911
  if (!tabsPresent) {
1870
1912
  const variants = uniqueDetails(scopeSegs, "variant");
1871
1913
  if (variants.length > 1) {
1872
- return buildVariantedNode(ctx, variants, scopeSegs, scopePrefix);
1914
+ const sharedSegs = scopeSegs.filter((s) => s.seg.variant == null);
1915
+ const variantedNode = buildVariantedNode(ctx, variants, scopeSegs, scopePrefix);
1916
+ if (sharedSegs.length > 0) {
1917
+ const sharedChildren = buildSidebarRootChildren(ctx, sharedSegs, scopePrefix);
1918
+ const first2 = scopeSegs[0];
1919
+ return {
1920
+ type: "sidebarRoot",
1921
+ id: ctx.nodeId(`sidebar:${first2 != null ? scopeKey(first2.seg) : "root"}`),
1922
+ collapsed: void 0,
1923
+ children: [...sharedChildren, variantedNode]
1924
+ };
1925
+ }
1926
+ return variantedNode;
1873
1927
  }
1874
1928
  return buildSidebarRoot(ctx, scopeSegs, scopePrefix);
1875
1929
  }
@@ -1956,9 +2010,64 @@ function buildUnversioned(ctx, scopeSegs, scopePrefix, tabsPresent) {
1956
2010
  child: buildTabbedOrSidebar(ctx, scopeSegs, tabsPresent, scopePrefix)
1957
2011
  };
1958
2012
  }
1959
- function buildVersioned(ctx, versions, scoped, rootSlug, productPrefix) {
2013
+ function mergeSharedSections(defaultSegs, allScoped, defaultVersion, versionSlugs) {
2014
+ const defaultTabsByName = /* @__PURE__ */ new Map();
2015
+ for (const s of defaultSegs) {
2016
+ if (s.seg.tab != null) {
2017
+ const tabName = s.seg.tab.displayName;
2018
+ if (!defaultTabsByName.has(tabName)) {
2019
+ defaultTabsByName.set(tabName, s.seg.tab);
2020
+ }
2021
+ }
2022
+ }
2023
+ const existingSections = new Set(
2024
+ defaultSegs.filter((s) => metaStr(s.seg.metadata, "type") === "section").map((s) => s.seg.section)
2025
+ );
2026
+ const maxSortOrder = defaultSegs.reduce((max, s) => Math.max(max, s.seg.sortOrder), 0);
2027
+ let nextSortOrder = maxSortOrder + 1;
2028
+ const merged = [...defaultSegs];
2029
+ for (const s of allScoped) {
2030
+ if (s.seg.version?.id === defaultVersion.id) {
2031
+ continue;
2032
+ }
2033
+ const type = metaStr(s.seg.metadata, "type");
2034
+ if (type !== "section") {
2035
+ continue;
2036
+ }
2037
+ const sectionPath = s.seg.section;
2038
+ if (versionSlugs.some((vs) => sectionPath === vs || sectionPath.startsWith(vs + "/"))) {
2039
+ continue;
2040
+ }
2041
+ if (existingSections.has(sectionPath)) {
2042
+ continue;
2043
+ }
2044
+ const sourceTabName = s.seg.tab?.displayName ?? "";
2045
+ const targetTab = defaultTabsByName.get(sourceTabName);
2046
+ if (targetTab == null) {
2047
+ continue;
2048
+ }
2049
+ const metadata = s.seg.metadata != null ? { ...s.seg.metadata, childIndex: void 0 } : s.seg.metadata;
2050
+ merged.push({
2051
+ seg: {
2052
+ ...s.seg,
2053
+ tab: targetTab,
2054
+ version: defaultVersion,
2055
+ sortOrder: nextSortOrder++,
2056
+ metadata
2057
+ },
2058
+ nav: s.nav
2059
+ });
2060
+ existingSections.add(sectionPath);
2061
+ }
2062
+ return merged;
2063
+ }
2064
+ function buildVersioned(ctx, versions, scoped, rootSlug, productPrefix, skipSharedSectionMerge) {
2065
+ const versionSlugs = versions.map((v) => detailSlug(v)).filter((s) => s !== "");
1960
2066
  const children = versions.map((version) => {
1961
- const versionSegs = scoped.filter((s) => s.seg.version?.id === version.id);
2067
+ let versionSegs = scoped.filter((s) => s.seg.version?.id === version.id);
2068
+ if (detailIsDefault(version) && !skipSharedSectionMerge) {
2069
+ versionSegs = mergeSharedSections(versionSegs, scoped, version, versionSlugs);
2070
+ }
1962
2071
  const tabsPresent = uniqueDetails(versionSegs, "tab").length > 0;
1963
2072
  const prefix = productPrefix != null ? productPrefix : rootSlug;
1964
2073
  const versionSegment = detailSlug(version);
@@ -2126,13 +2235,13 @@ function markCrossVersionCanonicalSlugs(versionNodes) {
2126
2235
  });
2127
2236
  }
2128
2237
  }
2129
- function buildProductGroup(ctx, products, scoped, rootSlug) {
2238
+ function buildProductGroup(ctx, products, scoped, rootSlug, skipSharedSectionMerge) {
2130
2239
  const children = products.map((product) => {
2131
2240
  const productSegs = scoped.filter((s) => s.seg.product?.id === product.id);
2132
2241
  const versions = uniqueDetails(productSegs, "version");
2133
2242
  const tabsPresent = uniqueDetails(productSegs, "tab").length > 0;
2134
2243
  const productPrefix = scopeSlugPrefix(rootSlug, product);
2135
- const productChild = versions.length > 0 ? buildVersioned(ctx, versions, productSegs, rootSlug, productPrefix) : buildUnversioned(ctx, productSegs, asSlug(productPrefix), tabsPresent);
2244
+ const productChild = versions.length > 0 ? buildVersioned(ctx, versions, productSegs, rootSlug, productPrefix, skipSharedSectionMerge) : buildUnversioned(ctx, productSegs, asSlug(productPrefix), tabsPresent);
2136
2245
  const node = {
2137
2246
  type: "product",
2138
2247
  ...withMetadataDefaults({