@fern-api/fdr-sdk 1.2.42-304ea6b285 → 1.2.42-54880bfeac

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 (48) 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 +58 -4
  10. package/dist/js/navigation/ledger-root-builder.js.map +1 -1
  11. package/dist/js/navigation/ledger-root-builder.mjs +58 -4
  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.sidebarDepth.test.d.ts +2 -0
  22. package/dist/navigation/__test__/ledger-root-builder.sidebarDepth.test.d.ts.map +1 -0
  23. package/dist/navigation/__test__/ledger-root-builder.sidebarDepth.test.js +273 -0
  24. package/dist/navigation/__test__/ledger-root-builder.sidebarDepth.test.js.map +1 -0
  25. package/dist/navigation/__test__/ledger-root-builder.skipSlugGroupOrdering.test.d.ts +2 -0
  26. package/dist/navigation/__test__/ledger-root-builder.skipSlugGroupOrdering.test.d.ts.map +1 -0
  27. package/dist/navigation/__test__/ledger-root-builder.skipSlugGroupOrdering.test.js +234 -0
  28. package/dist/navigation/__test__/ledger-root-builder.skipSlugGroupOrdering.test.js.map +1 -0
  29. package/dist/navigation/__test__/ledger-root-builder.skipSlugSiblingSection.test.js +105 -1
  30. package/dist/navigation/__test__/ledger-root-builder.skipSlugSiblingSection.test.js.map +1 -1
  31. package/dist/navigation/ledger-root-builder.d.ts.map +1 -1
  32. package/dist/navigation/ledger-root-builder.js +108 -12
  33. package/dist/navigation/ledger-root-builder.js.map +1 -1
  34. package/dist/orpc-client/docs-ledger/contract.d.ts +9 -0
  35. package/dist/orpc-client/docs-ledger/contract.d.ts.map +1 -1
  36. package/dist/orpc-client/docs-ledger/contract.js +1 -0
  37. package/dist/orpc-client/docs-ledger/contract.js.map +1 -1
  38. package/dist/tsconfig.tsbuildinfo +1 -1
  39. package/dist/types/navigation/__test__/ledger-root-builder.crossProductDedup.test.d.ts +2 -0
  40. package/dist/types/navigation/__test__/ledger-root-builder.crossProductDedup.test.d.ts.map +1 -0
  41. package/dist/types/navigation/__test__/ledger-root-builder.sidebarDepth.test.d.ts +2 -0
  42. package/dist/types/navigation/__test__/ledger-root-builder.sidebarDepth.test.d.ts.map +1 -0
  43. package/dist/types/navigation/__test__/ledger-root-builder.skipSlugGroupOrdering.test.d.ts +2 -0
  44. package/dist/types/navigation/__test__/ledger-root-builder.skipSlugGroupOrdering.test.d.ts.map +1 -0
  45. package/dist/types/navigation/ledger-root-builder.d.ts.map +1 -1
  46. package/dist/types/orpc-client/docs-ledger/contract.d.ts +9 -0
  47. package/dist/types/orpc-client/docs-ledger/contract.d.ts.map +1 -1
  48. package/package.json +1 -1
@@ -1359,7 +1359,17 @@ function directChildApiPackages(parentSection, scopeSegs, apiDefinitionId) {
1359
1359
  function buildApiChildren(ctx, scoped, scopeSegs, apiDefinitionId, scopePrefix) {
1360
1360
  const { seg, nav } = scoped;
1361
1361
  const leafNodes = positionedApiLeafChildren(ctx, nav, apiDefinitionId);
1362
- const childPackages = directChildApiPackages(seg.section, scopeSegs, apiDefinitionId);
1362
+ let childPackages = directChildApiPackages(seg.section, scopeSegs, apiDefinitionId);
1363
+ const samePathApiSiblings = scopeSegs.filter(
1364
+ (s) => s.seg.section === seg.section && s.seg.sortOrder !== seg.sortOrder && API_NODE_SEGMENT_TYPES.has(metaStr(s.seg.metadata, "type") ?? "")
1365
+ );
1366
+ const hasCollapsedGroups = samePathApiSiblings.length > 0;
1367
+ if (hasCollapsedGroups && metaStr(seg.metadata, "type") !== "apiReference") {
1368
+ const nextSibling = samePathApiSiblings.filter((s) => s.seg.sortOrder > seg.sortOrder).sort((a, b) => a.seg.sortOrder - b.seg.sortOrder)[0];
1369
+ const lo = seg.sortOrder;
1370
+ const hi = nextSibling?.seg.sortOrder ?? Number.MAX_SAFE_INTEGER;
1371
+ childPackages = childPackages.filter((c) => c.seg.sortOrder > lo && c.seg.sortOrder < hi);
1372
+ }
1363
1373
  const packageNodes = childPackages.map((child) => ({
1364
1374
  node: apiPackageChildNode(
1365
1375
  ctx,
@@ -1370,6 +1380,9 @@ function buildApiChildren(ctx, scoped, scopeSegs, apiDefinitionId, scopePrefix)
1370
1380
  ),
1371
1381
  childIndex: metaNum(child.seg.metadata, "childIndex")
1372
1382
  }));
1383
+ if (hasCollapsedGroups && metaStr(seg.metadata, "type") === "apiReference") {
1384
+ return [...leafNodes, ...packageNodes.map((p, i) => ({ node: p.node, pos: leafNodes.length + i }))].sort((a, b) => a.pos - b.pos).map((p) => p.node);
1385
+ }
1373
1386
  const hasChildIndex = packageNodes.some((p) => p.childIndex != null);
1374
1387
  if (!hasChildIndex) {
1375
1388
  return [...leafNodes, ...packageNodes.map((p) => ({ node: p.node, pos: Number.MAX_SAFE_INTEGER }))].sort((a, b) => a.pos - b.pos).map((p) => p.node);
@@ -1681,6 +1694,10 @@ function buildSectionTree(ctx, scopeSegs, parentPath, scopePrefix, changelogScop
1681
1694
  if (hasOwningApiReference(s, scopeSegs) || isNestedApiPackage(s, scopeSegs)) {
1682
1695
  return false;
1683
1696
  }
1697
+ const depth = metaNum(s.seg.metadata, "sidebarDepth");
1698
+ if (depth === 0) {
1699
+ return false;
1700
+ }
1684
1701
  const parent = parentSectionPath(sec);
1685
1702
  if (parent === parentPath) {
1686
1703
  return true;
@@ -1728,8 +1745,9 @@ function computeSiblingSortBoundaries(ordered) {
1728
1745
  rootSections.push(s);
1729
1746
  continue;
1730
1747
  }
1748
+ const depth = metaNum(s.seg.metadata, "sidebarDepth");
1731
1749
  const parent = parentSectionPath(sec);
1732
- const isRootLevel = parent === "" || !sectionPaths.has(parent) && nearestExistingAncestor(sec, sectionPaths) === "";
1750
+ const isRootLevel = depth === 0 || parent === "" || !sectionPaths.has(parent) && nearestExistingAncestor(sec, sectionPaths) === "";
1733
1751
  if (isRootLevel) {
1734
1752
  rootSections.push(s);
1735
1753
  }
@@ -1766,6 +1784,14 @@ function buildSidebarRootChildren(ctx, scopeSegs, scopePrefix, changelogScopePre
1766
1784
  if (hasOwningApiReference(s, scopeSegs) || isNestedApiPackage(s, scopeSegs)) {
1767
1785
  continue;
1768
1786
  }
1787
+ if (type === "apiPackage") {
1788
+ const hasApiRefSibling = ordered.some(
1789
+ (sib) => sib.seg.section === sec && metaStr(sib.seg.metadata, "type") === "apiReference"
1790
+ );
1791
+ if (hasApiRefSibling) {
1792
+ continue;
1793
+ }
1794
+ }
1769
1795
  if (type === "tabRoot" && metaBool(s.seg.metadata, "landingPage") === true) {
1770
1796
  continue;
1771
1797
  }
@@ -1786,9 +1812,10 @@ function buildSidebarRootChildren(ctx, scopeSegs, scopePrefix, changelogScopePre
1786
1812
  annotated.push({ node, pos: metaNum(s.seg.metadata, "childIndex"), isLeaf: false });
1787
1813
  continue;
1788
1814
  }
1815
+ const depth = metaNum(s.seg.metadata, "sidebarDepth");
1789
1816
  const parent = parentSectionPath(sec);
1790
- const isRootLevel = parent === "" || !sectionPaths.has(parent) && nearestExistingAncestor(sec, sectionPaths) === "";
1791
- if (isRootLevel && hasRootSection && sec !== "") {
1817
+ const isRootLevel = depth === 0 || parent === "" || !sectionPaths.has(parent) && nearestExistingAncestor(sec, sectionPaths) === "";
1818
+ if (isRootLevel && hasRootSection && sec !== "" && depth !== 0) {
1792
1819
  continue;
1793
1820
  }
1794
1821
  if (isRootLevel) {
@@ -2356,6 +2383,7 @@ function buildProductGroup(ctx, products, scoped, rootSlug, skipSharedSectionMer
2356
2383
  };
2357
2384
  return node;
2358
2385
  });
2386
+ markCrossProductCanonicalSlugs(children);
2359
2387
  return {
2360
2388
  type: "productgroup",
2361
2389
  id: ctx.nodeId("productgroup"),
@@ -2367,6 +2395,32 @@ function buildProductGroup(ctx, products, scoped, rootSlug, skipSharedSectionMer
2367
2395
  children
2368
2396
  };
2369
2397
  }
2398
+ function markCrossProductCanonicalSlugs(productNodes) {
2399
+ const pageIdToCanonical = /* @__PURE__ */ new Map();
2400
+ const sorted = [...productNodes].sort((a, b) => {
2401
+ if (a.default !== b.default) {
2402
+ return a.default ? -1 : 1;
2403
+ }
2404
+ return 0;
2405
+ });
2406
+ for (const product of sorted) {
2407
+ traverseDF(product, (child) => {
2408
+ if (hasMetadata(child) && isPage(child)) {
2409
+ const pid = getPageId(child);
2410
+ if (pid == null) {
2411
+ return;
2412
+ }
2413
+ const key = `pid:${pid}`;
2414
+ const canonical = pageIdToCanonical.get(key);
2415
+ if (canonical != null && !product.default) {
2416
+ child.canonicalSlug = canonical;
2417
+ } else if (canonical == null) {
2418
+ pageIdToCanonical.set(key, child.canonicalSlug ?? child.slug);
2419
+ }
2420
+ }
2421
+ });
2422
+ }
2423
+ }
2370
2424
  export {
2371
2425
  apiLeafNodeFromNavRoute,
2372
2426
  buildFullRootFromSegments,