@fern-api/fdr-sdk 1.2.42-d3871329d3 → 1.2.42-e01a8637c3

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 (58) 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/index.js +1 -0
  6. package/dist/js/index.js.map +1 -1
  7. package/dist/js/index.mjs +1 -0
  8. package/dist/js/index.mjs.map +1 -1
  9. package/dist/js/navigation/ledger-root-builder.js +107 -22
  10. package/dist/js/navigation/ledger-root-builder.js.map +1 -1
  11. package/dist/js/navigation/ledger-root-builder.mjs +107 -22
  12. package/dist/js/navigation/ledger-root-builder.mjs.map +1 -1
  13. package/dist/js/orpc-client.js +1 -0
  14. package/dist/js/orpc-client.js.map +1 -1
  15. package/dist/js/orpc-client.mjs +1 -0
  16. package/dist/js/orpc-client.mjs.map +1 -1
  17. package/dist/navigation/__test__/ledger-root-builder.crossProductDedup.test.d.ts +2 -0
  18. package/dist/navigation/__test__/ledger-root-builder.crossProductDedup.test.d.ts.map +1 -0
  19. package/dist/navigation/__test__/ledger-root-builder.crossProductDedup.test.js +267 -0
  20. package/dist/navigation/__test__/ledger-root-builder.crossProductDedup.test.js.map +1 -0
  21. package/dist/navigation/__test__/ledger-root-builder.ledgerParity.test.d.ts +2 -0
  22. package/dist/navigation/__test__/ledger-root-builder.ledgerParity.test.d.ts.map +1 -0
  23. package/dist/navigation/__test__/ledger-root-builder.ledgerParity.test.js +306 -0
  24. package/dist/navigation/__test__/ledger-root-builder.ledgerParity.test.js.map +1 -0
  25. package/dist/navigation/__test__/ledger-root-builder.sidebarDepth.test.d.ts +2 -0
  26. package/dist/navigation/__test__/ledger-root-builder.sidebarDepth.test.d.ts.map +1 -0
  27. package/dist/navigation/__test__/ledger-root-builder.sidebarDepth.test.js +273 -0
  28. package/dist/navigation/__test__/ledger-root-builder.sidebarDepth.test.js.map +1 -0
  29. package/dist/navigation/__test__/ledger-root-builder.skipSlugGroupOrdering.test.d.ts +2 -0
  30. package/dist/navigation/__test__/ledger-root-builder.skipSlugGroupOrdering.test.d.ts.map +1 -0
  31. package/dist/navigation/__test__/ledger-root-builder.skipSlugGroupOrdering.test.js +234 -0
  32. package/dist/navigation/__test__/ledger-root-builder.skipSlugGroupOrdering.test.js.map +1 -0
  33. package/dist/navigation/__test__/ledger-root-builder.skipSlugSiblingSection.test.d.ts +2 -0
  34. package/dist/navigation/__test__/ledger-root-builder.skipSlugSiblingSection.test.d.ts.map +1 -0
  35. package/dist/navigation/__test__/ledger-root-builder.skipSlugSiblingSection.test.js +256 -0
  36. package/dist/navigation/__test__/ledger-root-builder.skipSlugSiblingSection.test.js.map +1 -0
  37. package/dist/navigation/ledger-root-builder.d.ts.map +1 -1
  38. package/dist/navigation/ledger-root-builder.js +192 -33
  39. package/dist/navigation/ledger-root-builder.js.map +1 -1
  40. package/dist/orpc-client/docs-ledger/contract.d.ts +9 -0
  41. package/dist/orpc-client/docs-ledger/contract.d.ts.map +1 -1
  42. package/dist/orpc-client/docs-ledger/contract.js +1 -0
  43. package/dist/orpc-client/docs-ledger/contract.js.map +1 -1
  44. package/dist/tsconfig.tsbuildinfo +1 -1
  45. package/dist/types/navigation/__test__/ledger-root-builder.crossProductDedup.test.d.ts +2 -0
  46. package/dist/types/navigation/__test__/ledger-root-builder.crossProductDedup.test.d.ts.map +1 -0
  47. package/dist/types/navigation/__test__/ledger-root-builder.ledgerParity.test.d.ts +2 -0
  48. package/dist/types/navigation/__test__/ledger-root-builder.ledgerParity.test.d.ts.map +1 -0
  49. package/dist/types/navigation/__test__/ledger-root-builder.sidebarDepth.test.d.ts +2 -0
  50. package/dist/types/navigation/__test__/ledger-root-builder.sidebarDepth.test.d.ts.map +1 -0
  51. package/dist/types/navigation/__test__/ledger-root-builder.skipSlugGroupOrdering.test.d.ts +2 -0
  52. package/dist/types/navigation/__test__/ledger-root-builder.skipSlugGroupOrdering.test.d.ts.map +1 -0
  53. package/dist/types/navigation/__test__/ledger-root-builder.skipSlugSiblingSection.test.d.ts +2 -0
  54. package/dist/types/navigation/__test__/ledger-root-builder.skipSlugSiblingSection.test.d.ts.map +1 -0
  55. package/dist/types/navigation/ledger-root-builder.d.ts.map +1 -1
  56. package/dist/types/orpc-client/docs-ledger/contract.d.ts +9 -0
  57. package/dist/types/orpc-client/docs-ledger/contract.d.ts.map +1 -1
  58. package/package.json +3 -3
@@ -1300,6 +1300,30 @@ function stripLeadingScopePrefix(section, scopePrefix) {
1300
1300
  }
1301
1301
  return section;
1302
1302
  }
1303
+ function computeDuplicateSiblingSortBoundaries(siblings) {
1304
+ const result = /* @__PURE__ */ new Map();
1305
+ const byPath = /* @__PURE__ */ new Map();
1306
+ for (const sibling of siblings) {
1307
+ if (metaStr(sibling.seg.metadata, "type") !== "section") {
1308
+ continue;
1309
+ }
1310
+ const group = byPath.get(sibling.seg.section) ?? [];
1311
+ group.push(sibling);
1312
+ byPath.set(sibling.seg.section, group);
1313
+ }
1314
+ for (const [, group] of byPath) {
1315
+ if (group.length <= 1) {
1316
+ continue;
1317
+ }
1318
+ for (let i = 0; i < group.length; i++) {
1319
+ result.set(group[i], {
1320
+ lo: group[i].seg.sortOrder,
1321
+ hi: i + 1 < group.length ? group[i + 1].seg.sortOrder : Number.MAX_SAFE_INTEGER
1322
+ });
1323
+ }
1324
+ }
1325
+ return result;
1326
+ }
1303
1327
  function mergeChildrenByPosition(ctx, nav, sectionChildren) {
1304
1328
  const leafNodes = [];
1305
1329
  for (let i = 0; i < nav.length; i++) {
@@ -1354,12 +1378,15 @@ function sectionNode(ctx, scoped, sectionChildren, scopePrefix) {
1354
1378
  children: mergeChildrenByPosition(ctx, nav, sectionChildren)
1355
1379
  };
1356
1380
  }
1357
- function directChildApiPackages(parentSection, scopeSegs) {
1381
+ function directChildApiPackages(parentSection, scopeSegs, apiDefinitionId) {
1358
1382
  const sectionPaths = new Set(scopeSegs.map((s) => s.seg.section));
1359
1383
  return scopeSegs.filter((s) => {
1360
1384
  if (metaStr(s.seg.metadata, "type") !== "apiPackage") {
1361
1385
  return false;
1362
1386
  }
1387
+ if (metaStr(s.seg.metadata, "apiDefinitionId") !== apiDefinitionId) {
1388
+ return false;
1389
+ }
1363
1390
  const parent = parentSectionPath(s.seg.section);
1364
1391
  if (parent === parentSection) {
1365
1392
  return true;
@@ -1373,7 +1400,17 @@ function directChildApiPackages(parentSection, scopeSegs) {
1373
1400
  function buildApiChildren(ctx, scoped, scopeSegs, apiDefinitionId, scopePrefix) {
1374
1401
  const { seg, nav } = scoped;
1375
1402
  const leafNodes = positionedApiLeafChildren(ctx, nav, apiDefinitionId);
1376
- const childPackages = directChildApiPackages(seg.section, scopeSegs);
1403
+ let childPackages = directChildApiPackages(seg.section, scopeSegs, apiDefinitionId);
1404
+ const samePathApiSiblings = scopeSegs.filter(
1405
+ (s) => s.seg.section === seg.section && s.seg.sortOrder !== seg.sortOrder && API_NODE_SEGMENT_TYPES.has(metaStr(s.seg.metadata, "type") ?? "")
1406
+ );
1407
+ const hasCollapsedGroups = samePathApiSiblings.length > 0;
1408
+ if (hasCollapsedGroups && metaStr(seg.metadata, "type") !== "apiReference") {
1409
+ const nextSibling = samePathApiSiblings.filter((s) => s.seg.sortOrder > seg.sortOrder).sort((a, b) => a.seg.sortOrder - b.seg.sortOrder)[0];
1410
+ const lo = seg.sortOrder;
1411
+ const hi = nextSibling?.seg.sortOrder ?? Number.MAX_SAFE_INTEGER;
1412
+ childPackages = childPackages.filter((c) => c.seg.sortOrder > lo && c.seg.sortOrder < hi);
1413
+ }
1377
1414
  const packageNodes = childPackages.map((child) => ({
1378
1415
  node: apiPackageChildNode(
1379
1416
  ctx,
@@ -1384,6 +1421,9 @@ function buildApiChildren(ctx, scoped, scopeSegs, apiDefinitionId, scopePrefix)
1384
1421
  ),
1385
1422
  childIndex: metaNum(child.seg.metadata, "childIndex")
1386
1423
  }));
1424
+ if (hasCollapsedGroups && metaStr(seg.metadata, "type") === "apiReference") {
1425
+ return [...leafNodes, ...packageNodes.map((p, i) => ({ node: p.node, pos: leafNodes.length + i }))].sort((a, b) => a.pos - b.pos).map((p) => p.node);
1426
+ }
1387
1427
  const hasChildIndex = packageNodes.some((p) => p.childIndex != null);
1388
1428
  if (!hasChildIndex) {
1389
1429
  return [...leafNodes, ...packageNodes.map((p) => ({ node: p.node, pos: Number.MAX_SAFE_INTEGER }))].sort((a, b) => a.pos - b.pos).map((p) => p.node);
@@ -1514,7 +1554,7 @@ function apiReferenceNode(ctx, scoped, scopeSegs, scopePrefix) {
1514
1554
  availability: metaAvailability(seg.metadata),
1515
1555
  overviewPageId: overviewPageId != null ? PageId(overviewPageId) : void 0,
1516
1556
  noindex: metaBool(overview?.metadata, "noindex") ?? metaBool(seg.metadata, "noindex"),
1517
- paginated: true,
1557
+ paginated: metaBool(seg.metadata, "paginated"),
1518
1558
  showErrors: metaBool(seg.metadata, "showErrors"),
1519
1559
  hideTitle: metaBool(seg.metadata, "hideTitle"),
1520
1560
  pointsTo: metaPointsTo != null ? pointsToSlug(metaPointsTo) : void 0,
@@ -1532,7 +1572,10 @@ function attachedApiChangelogNode(ctx, scoped, scopeSegs, apiDefinitionId, scope
1532
1572
  }
1533
1573
  return metaStr(candidate.seg.metadata, "apiDefinitionId") === apiDefinitionId;
1534
1574
  });
1535
- const changelogSeg = candidates.find((candidate) => parentSectionPath(candidate.seg.section) === seg.section) ?? candidates[0];
1575
+ const apiReferenceCount = scopeSegs.filter((candidate) => {
1576
+ return metaStr(candidate.seg.metadata, "type") === "apiReference" && metaStr(candidate.seg.metadata, "apiDefinitionId") === apiDefinitionId;
1577
+ }).length;
1578
+ const changelogSeg = candidates.find((candidate) => parentSectionPath(candidate.seg.section) === seg.section) ?? (apiReferenceCount === 1 ? candidates[0] : void 0);
1536
1579
  return changelogSeg != null ? changelogNode(ctx, changelogSeg, scopePrefix) : void 0;
1537
1580
  }
1538
1581
  function hasOwningApiReference(scoped, scopeSegs) {
@@ -1540,12 +1583,13 @@ function hasOwningApiReference(scoped, scopeSegs) {
1540
1583
  if (apiDefinitionId == null || metaStr(scoped.seg.metadata, "type") !== "changelog") {
1541
1584
  return false;
1542
1585
  }
1543
- return scopeSegs.some((candidate) => {
1586
+ const candidates = scopeSegs.filter((candidate) => {
1544
1587
  if (metaStr(candidate.seg.metadata, "type") !== "apiReference") {
1545
1588
  return false;
1546
1589
  }
1547
1590
  return metaStr(candidate.seg.metadata, "apiDefinitionId") === apiDefinitionId;
1548
1591
  });
1592
+ return candidates.some((candidate) => parentSectionPath(scoped.seg.section) === candidate.seg.section) || candidates.length === 1;
1549
1593
  }
1550
1594
  function isNestedApiPackage(scoped, scopeSegs) {
1551
1595
  if (metaStr(scoped.seg.metadata, "type") !== "apiPackage") {
@@ -1691,6 +1735,10 @@ function buildSectionTree(ctx, scopeSegs, parentPath, scopePrefix, changelogScop
1691
1735
  if (hasOwningApiReference(s, scopeSegs) || isNestedApiPackage(s, scopeSegs)) {
1692
1736
  return false;
1693
1737
  }
1738
+ const depth = metaNum(s.seg.metadata, "sidebarDepth");
1739
+ if (depth === 0) {
1740
+ return false;
1741
+ }
1694
1742
  const parent = parentSectionPath(sec);
1695
1743
  if (parent === parentPath) {
1696
1744
  return true;
@@ -1700,6 +1748,7 @@ function buildSectionTree(ctx, scopeSegs, parentPath, scopePrefix, changelogScop
1700
1748
  }
1701
1749
  return false;
1702
1750
  }).sort((a, b) => a.seg.sortOrder - b.seg.sortOrder);
1751
+ const siblingBoundaries = computeDuplicateSiblingSortBoundaries(direct);
1703
1752
  return direct.map((s) => {
1704
1753
  const type = metaStr(s.seg.metadata, "type");
1705
1754
  const childIndex = metaNum(s.seg.metadata, "childIndex");
@@ -1709,10 +1758,14 @@ function buildSectionTree(ctx, scopeSegs, parentPath, scopePrefix, changelogScop
1709
1758
  } else if (type === "changelog") {
1710
1759
  node = changelogNode(ctx, s, changelogScopePrefix ?? scopePrefix);
1711
1760
  } 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;
1712
1765
  node = sectionNode(
1713
1766
  ctx,
1714
1767
  s,
1715
- buildSectionTree(ctx, scopeSegs, s.seg.section, scopePrefix, changelogScopePrefix),
1768
+ buildSectionTree(ctx, childScopeSegs, s.seg.section, scopePrefix, changelogScopePrefix),
1716
1769
  scopePrefix
1717
1770
  );
1718
1771
  }
@@ -1733,8 +1786,9 @@ function computeSiblingSortBoundaries(ordered) {
1733
1786
  rootSections.push(s);
1734
1787
  continue;
1735
1788
  }
1789
+ const depth = metaNum(s.seg.metadata, "sidebarDepth");
1736
1790
  const parent = parentSectionPath(sec);
1737
- const isRootLevel = parent === "" || !sectionPaths.has(parent) && nearestExistingAncestor(sec, sectionPaths) === "";
1791
+ const isRootLevel = depth === 0 || parent === "" || !sectionPaths.has(parent) && nearestExistingAncestor(sec, sectionPaths) === "";
1738
1792
  if (isRootLevel) {
1739
1793
  rootSections.push(s);
1740
1794
  }
@@ -1761,14 +1815,24 @@ function buildSidebarRootChildren(ctx, scopeSegs, scopePrefix, changelogScopePre
1761
1815
  const ordered = [...scopeSegs].sort((a, b) => a.seg.sortOrder - b.seg.sortOrder);
1762
1816
  const sectionPaths = new Set(ordered.map((s) => s.seg.section));
1763
1817
  const annotated = [];
1764
- const hasRootSection = ordered.some((s) => metaStr(s.seg.metadata, "type") === "section" && s.seg.section === "");
1765
1818
  const siblingBoundaries = computeSiblingSortBoundaries(ordered);
1819
+ const hasRootSection = ordered.some(
1820
+ (s) => metaStr(s.seg.metadata, "type") === "section" && s.seg.section === "" && (metaNum(s.seg.metadata, "childIndex") == null || siblingBoundaries.has(s))
1821
+ );
1766
1822
  for (const s of ordered) {
1767
1823
  const type = metaStr(s.seg.metadata, "type");
1768
1824
  const sec = s.seg.section;
1769
1825
  if (hasOwningApiReference(s, scopeSegs) || isNestedApiPackage(s, scopeSegs)) {
1770
1826
  continue;
1771
1827
  }
1828
+ if (type === "apiPackage") {
1829
+ const hasApiRefSibling = ordered.some(
1830
+ (sib) => sib.seg.section === sec && metaStr(sib.seg.metadata, "type") === "apiReference"
1831
+ );
1832
+ if (hasApiRefSibling) {
1833
+ continue;
1834
+ }
1835
+ }
1772
1836
  if (type === "tabRoot" && metaBool(s.seg.metadata, "landingPage") === true) {
1773
1837
  continue;
1774
1838
  }
@@ -1781,7 +1845,7 @@ function buildSidebarRootChildren(ctx, scopeSegs, scopePrefix, changelogScopePre
1781
1845
  }
1782
1846
  continue;
1783
1847
  }
1784
- if (type === "section" && sec === "") {
1848
+ if (type === "section" && sec === "" && hasRootSection) {
1785
1849
  const bounds = siblingBoundaries.get(s);
1786
1850
  const ownedSegs = bounds != null ? scopeSegs.filter((seg) => seg.seg.sortOrder >= bounds.lo && seg.seg.sortOrder < bounds.hi) : scopeSegs;
1787
1851
  const sectionChildren = buildSectionTree(ctx, ownedSegs, "", scopePrefix, changelogScopePrefix);
@@ -1789,9 +1853,10 @@ function buildSidebarRootChildren(ctx, scopeSegs, scopePrefix, changelogScopePre
1789
1853
  annotated.push({ node, pos: metaNum(s.seg.metadata, "childIndex"), isLeaf: false });
1790
1854
  continue;
1791
1855
  }
1856
+ const depth = metaNum(s.seg.metadata, "sidebarDepth");
1792
1857
  const parent = parentSectionPath(sec);
1793
- const isRootLevel = parent === "" || !sectionPaths.has(parent) && nearestExistingAncestor(sec, sectionPaths) === "";
1794
- if (isRootLevel && hasRootSection && sec !== "") {
1858
+ const isRootLevel = depth === 0 || parent === "" || !sectionPaths.has(parent) && nearestExistingAncestor(sec, sectionPaths) === "";
1859
+ if (isRootLevel && hasRootSection && sec !== "" && depth == null) {
1795
1860
  continue;
1796
1861
  }
1797
1862
  if (isRootLevel) {
@@ -1803,12 +1868,9 @@ function buildSidebarRootChildren(ctx, scopeSegs, scopePrefix, changelogScopePre
1803
1868
  } else {
1804
1869
  const bounds = siblingBoundaries.get(s);
1805
1870
  const ownedSegs = bounds != null ? scopeSegs.filter((seg) => seg.seg.sortOrder >= bounds.lo && seg.seg.sortOrder < bounds.hi) : scopeSegs;
1806
- node = sectionNode(
1807
- ctx,
1808
- s,
1809
- buildSectionTree(ctx, ownedSegs, sec, scopePrefix, changelogScopePrefix),
1810
- scopePrefix
1811
- );
1871
+ const isUnboundedSkipSlugSibling = sec === "" && metaNum(s.seg.metadata, "childIndex") != null && bounds == null;
1872
+ const sectionChildren = isUnboundedSkipSlugSibling ? [] : buildSectionTree(ctx, ownedSegs, sec, scopePrefix, changelogScopePrefix);
1873
+ node = sectionNode(ctx, s, sectionChildren, scopePrefix);
1812
1874
  }
1813
1875
  const isSharedSection = siblingBoundaries.size > 0 && scopePrefix !== "" && sec !== "" && !sec.startsWith(scopePrefix);
1814
1876
  annotated.push({
@@ -1846,10 +1908,6 @@ function groupSidebarRootChildren(ctx, children) {
1846
1908
  } else if (child.type === "section" && !child.collapsible) {
1847
1909
  flushRun();
1848
1910
  out.push(child);
1849
- } else if (child.type === "changelog") {
1850
- flushRun();
1851
- run.push(child);
1852
- flushRun();
1853
1911
  } else {
1854
1912
  run.push(child);
1855
1913
  }
@@ -1964,7 +2022,7 @@ function buildVariantedNode(ctx, variants, scopeSegs, scopePrefix) {
1964
2022
  const variantIndividualSlug = detailSlug(variant);
1965
2023
  const variantSlug = variantIndividualSlug !== "" ? asSlug(slugjoin(scopePrefix, variantIndividualSlug)) : scopePrefix;
1966
2024
  const metaPointsTo = metaStr(variant.metadata, "pointsTo");
1967
- const children = buildSidebarRootChildren(ctx, variantSegs, scopePrefix);
2025
+ const children = buildSidebarRootChildren(ctx, variantSegs, variantSlug);
1968
2026
  return {
1969
2027
  type: "variant",
1970
2028
  ...withMetadataDefaults({
@@ -2366,6 +2424,7 @@ function buildProductGroup(ctx, products, scoped, rootSlug, skipSharedSectionMer
2366
2424
  };
2367
2425
  return node;
2368
2426
  });
2427
+ markCrossProductCanonicalSlugs(children);
2369
2428
  return {
2370
2429
  type: "productgroup",
2371
2430
  id: ctx.nodeId("productgroup"),
@@ -2377,6 +2436,32 @@ function buildProductGroup(ctx, products, scoped, rootSlug, skipSharedSectionMer
2377
2436
  children
2378
2437
  };
2379
2438
  }
2439
+ function markCrossProductCanonicalSlugs(productNodes) {
2440
+ const pageIdToCanonical = /* @__PURE__ */ new Map();
2441
+ const sorted = [...productNodes].sort((a, b) => {
2442
+ if (a.default !== b.default) {
2443
+ return a.default ? -1 : 1;
2444
+ }
2445
+ return 0;
2446
+ });
2447
+ for (const product of sorted) {
2448
+ traverseDF(product, (child) => {
2449
+ if (hasMetadata(child) && isPage(child)) {
2450
+ const pid = getPageId(child);
2451
+ if (pid == null) {
2452
+ return;
2453
+ }
2454
+ const key = `pid:${pid}`;
2455
+ const canonical = pageIdToCanonical.get(key);
2456
+ if (canonical != null && !product.default) {
2457
+ child.canonicalSlug = canonical;
2458
+ } else if (canonical == null) {
2459
+ pageIdToCanonical.set(key, child.canonicalSlug ?? child.slug);
2460
+ }
2461
+ }
2462
+ });
2463
+ }
2464
+ }
2380
2465
  // Annotate the CommonJS export names for ESM import in node:
2381
2466
  0 && (module.exports = {
2382
2467
  apiLeafNodeFromNavRoute,