@fern-api/fdr-sdk 1.2.42-1fb0ba4870 → 1.2.42-26d605b4e0

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 (66) 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 +100 -14
  10. package/dist/js/navigation/ledger-root-builder.js.map +1 -1
  11. package/dist/js/navigation/ledger-root-builder.mjs +100 -14
  12. package/dist/js/navigation/ledger-root-builder.mjs.map +1 -1
  13. package/dist/js/orpc-client.js +48 -0
  14. package/dist/js/orpc-client.js.map +1 -1
  15. package/dist/js/orpc-client.mjs +47 -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.js +105 -1
  34. package/dist/navigation/__test__/ledger-root-builder.skipSlugSiblingSection.test.js.map +1 -1
  35. package/dist/navigation/ledger-root-builder.d.ts.map +1 -1
  36. package/dist/navigation/ledger-root-builder.js +153 -23
  37. package/dist/navigation/ledger-root-builder.js.map +1 -1
  38. package/dist/orpc-client/docs-ledger/__test__/config-files.navFiles.test.d.ts +2 -0
  39. package/dist/orpc-client/docs-ledger/__test__/config-files.navFiles.test.d.ts.map +1 -0
  40. package/dist/orpc-client/docs-ledger/__test__/config-files.navFiles.test.js +153 -0
  41. package/dist/orpc-client/docs-ledger/__test__/config-files.navFiles.test.js.map +1 -0
  42. package/dist/orpc-client/docs-ledger/config-files.d.ts +8 -0
  43. package/dist/orpc-client/docs-ledger/config-files.d.ts.map +1 -1
  44. package/dist/orpc-client/docs-ledger/config-files.js +69 -0
  45. package/dist/orpc-client/docs-ledger/config-files.js.map +1 -1
  46. package/dist/orpc-client/docs-ledger/contract.d.ts +9 -0
  47. package/dist/orpc-client/docs-ledger/contract.d.ts.map +1 -1
  48. package/dist/orpc-client/docs-ledger/contract.js +1 -0
  49. package/dist/orpc-client/docs-ledger/contract.js.map +1 -1
  50. package/dist/tsconfig.tsbuildinfo +1 -1
  51. package/dist/types/navigation/__test__/ledger-root-builder.crossProductDedup.test.d.ts +2 -0
  52. package/dist/types/navigation/__test__/ledger-root-builder.crossProductDedup.test.d.ts.map +1 -0
  53. package/dist/types/navigation/__test__/ledger-root-builder.ledgerParity.test.d.ts +2 -0
  54. package/dist/types/navigation/__test__/ledger-root-builder.ledgerParity.test.d.ts.map +1 -0
  55. package/dist/types/navigation/__test__/ledger-root-builder.sidebarDepth.test.d.ts +2 -0
  56. package/dist/types/navigation/__test__/ledger-root-builder.sidebarDepth.test.d.ts.map +1 -0
  57. package/dist/types/navigation/__test__/ledger-root-builder.skipSlugGroupOrdering.test.d.ts +2 -0
  58. package/dist/types/navigation/__test__/ledger-root-builder.skipSlugGroupOrdering.test.d.ts.map +1 -0
  59. package/dist/types/navigation/ledger-root-builder.d.ts.map +1 -1
  60. package/dist/types/orpc-client/docs-ledger/__test__/config-files.navFiles.test.d.ts +2 -0
  61. package/dist/types/orpc-client/docs-ledger/__test__/config-files.navFiles.test.d.ts.map +1 -0
  62. package/dist/types/orpc-client/docs-ledger/config-files.d.ts +8 -0
  63. package/dist/types/orpc-client/docs-ledger/config-files.d.ts.map +1 -1
  64. package/dist/types/orpc-client/docs-ledger/contract.d.ts +9 -0
  65. package/dist/types/orpc-client/docs-ledger/contract.d.ts.map +1 -1
  66. package/package.json +1 -1
@@ -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
  }
@@ -1771,6 +1825,14 @@ function buildSidebarRootChildren(ctx, scopeSegs, scopePrefix, changelogScopePre
1771
1825
  if (hasOwningApiReference(s, scopeSegs) || isNestedApiPackage(s, scopeSegs)) {
1772
1826
  continue;
1773
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
+ }
1774
1836
  if (type === "tabRoot" && metaBool(s.seg.metadata, "landingPage") === true) {
1775
1837
  continue;
1776
1838
  }
@@ -1791,9 +1853,10 @@ function buildSidebarRootChildren(ctx, scopeSegs, scopePrefix, changelogScopePre
1791
1853
  annotated.push({ node, pos: metaNum(s.seg.metadata, "childIndex"), isLeaf: false });
1792
1854
  continue;
1793
1855
  }
1856
+ const depth = metaNum(s.seg.metadata, "sidebarDepth");
1794
1857
  const parent = parentSectionPath(sec);
1795
- const isRootLevel = parent === "" || !sectionPaths.has(parent) && nearestExistingAncestor(sec, sectionPaths) === "";
1796
- if (isRootLevel && hasRootSection && sec !== "") {
1858
+ const isRootLevel = depth === 0 || parent === "" || !sectionPaths.has(parent) && nearestExistingAncestor(sec, sectionPaths) === "";
1859
+ if (isRootLevel && hasRootSection && sec !== "" && depth !== 0) {
1797
1860
  continue;
1798
1861
  }
1799
1862
  if (isRootLevel) {
@@ -1845,10 +1908,6 @@ function groupSidebarRootChildren(ctx, children) {
1845
1908
  } else if (child.type === "section" && !child.collapsible) {
1846
1909
  flushRun();
1847
1910
  out.push(child);
1848
- } else if (child.type === "changelog") {
1849
- flushRun();
1850
- run.push(child);
1851
- flushRun();
1852
1911
  } else {
1853
1912
  run.push(child);
1854
1913
  }
@@ -1963,7 +2022,7 @@ function buildVariantedNode(ctx, variants, scopeSegs, scopePrefix) {
1963
2022
  const variantIndividualSlug = detailSlug(variant);
1964
2023
  const variantSlug = variantIndividualSlug !== "" ? asSlug(slugjoin(scopePrefix, variantIndividualSlug)) : scopePrefix;
1965
2024
  const metaPointsTo = metaStr(variant.metadata, "pointsTo");
1966
- const children = buildSidebarRootChildren(ctx, variantSegs, scopePrefix);
2025
+ const children = buildSidebarRootChildren(ctx, variantSegs, variantSlug);
1967
2026
  return {
1968
2027
  type: "variant",
1969
2028
  ...withMetadataDefaults({
@@ -2365,6 +2424,7 @@ function buildProductGroup(ctx, products, scoped, rootSlug, skipSharedSectionMer
2365
2424
  };
2366
2425
  return node;
2367
2426
  });
2427
+ markCrossProductCanonicalSlugs(children);
2368
2428
  return {
2369
2429
  type: "productgroup",
2370
2430
  id: ctx.nodeId("productgroup"),
@@ -2376,6 +2436,32 @@ function buildProductGroup(ctx, products, scoped, rootSlug, skipSharedSectionMer
2376
2436
  children
2377
2437
  };
2378
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
+ }
2379
2465
  // Annotate the CommonJS export names for ESM import in node:
2380
2466
  0 && (module.exports = {
2381
2467
  apiLeafNodeFromNavRoute,