@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
@@ -1259,6 +1259,30 @@ function stripLeadingScopePrefix(section, scopePrefix) {
1259
1259
  }
1260
1260
  return section;
1261
1261
  }
1262
+ function computeDuplicateSiblingSortBoundaries(siblings) {
1263
+ const result = /* @__PURE__ */ new Map();
1264
+ const byPath = /* @__PURE__ */ new Map();
1265
+ for (const sibling of siblings) {
1266
+ if (metaStr(sibling.seg.metadata, "type") !== "section") {
1267
+ continue;
1268
+ }
1269
+ const group = byPath.get(sibling.seg.section) ?? [];
1270
+ group.push(sibling);
1271
+ byPath.set(sibling.seg.section, group);
1272
+ }
1273
+ for (const [, group] of byPath) {
1274
+ if (group.length <= 1) {
1275
+ continue;
1276
+ }
1277
+ for (let i = 0; i < group.length; i++) {
1278
+ result.set(group[i], {
1279
+ lo: group[i].seg.sortOrder,
1280
+ hi: i + 1 < group.length ? group[i + 1].seg.sortOrder : Number.MAX_SAFE_INTEGER
1281
+ });
1282
+ }
1283
+ }
1284
+ return result;
1285
+ }
1262
1286
  function mergeChildrenByPosition(ctx, nav, sectionChildren) {
1263
1287
  const leafNodes = [];
1264
1288
  for (let i = 0; i < nav.length; i++) {
@@ -1313,12 +1337,15 @@ function sectionNode(ctx, scoped, sectionChildren, scopePrefix) {
1313
1337
  children: mergeChildrenByPosition(ctx, nav, sectionChildren)
1314
1338
  };
1315
1339
  }
1316
- function directChildApiPackages(parentSection, scopeSegs) {
1340
+ function directChildApiPackages(parentSection, scopeSegs, apiDefinitionId) {
1317
1341
  const sectionPaths = new Set(scopeSegs.map((s) => s.seg.section));
1318
1342
  return scopeSegs.filter((s) => {
1319
1343
  if (metaStr(s.seg.metadata, "type") !== "apiPackage") {
1320
1344
  return false;
1321
1345
  }
1346
+ if (metaStr(s.seg.metadata, "apiDefinitionId") !== apiDefinitionId) {
1347
+ return false;
1348
+ }
1322
1349
  const parent = parentSectionPath(s.seg.section);
1323
1350
  if (parent === parentSection) {
1324
1351
  return true;
@@ -1332,7 +1359,17 @@ function directChildApiPackages(parentSection, scopeSegs) {
1332
1359
  function buildApiChildren(ctx, scoped, scopeSegs, apiDefinitionId, scopePrefix) {
1333
1360
  const { seg, nav } = scoped;
1334
1361
  const leafNodes = positionedApiLeafChildren(ctx, nav, apiDefinitionId);
1335
- const childPackages = directChildApiPackages(seg.section, scopeSegs);
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
+ }
1336
1373
  const packageNodes = childPackages.map((child) => ({
1337
1374
  node: apiPackageChildNode(
1338
1375
  ctx,
@@ -1343,6 +1380,9 @@ function buildApiChildren(ctx, scoped, scopeSegs, apiDefinitionId, scopePrefix)
1343
1380
  ),
1344
1381
  childIndex: metaNum(child.seg.metadata, "childIndex")
1345
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
+ }
1346
1386
  const hasChildIndex = packageNodes.some((p) => p.childIndex != null);
1347
1387
  if (!hasChildIndex) {
1348
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);
@@ -1473,7 +1513,7 @@ function apiReferenceNode(ctx, scoped, scopeSegs, scopePrefix) {
1473
1513
  availability: metaAvailability(seg.metadata),
1474
1514
  overviewPageId: overviewPageId != null ? PageId(overviewPageId) : void 0,
1475
1515
  noindex: metaBool(overview?.metadata, "noindex") ?? metaBool(seg.metadata, "noindex"),
1476
- paginated: true,
1516
+ paginated: metaBool(seg.metadata, "paginated"),
1477
1517
  showErrors: metaBool(seg.metadata, "showErrors"),
1478
1518
  hideTitle: metaBool(seg.metadata, "hideTitle"),
1479
1519
  pointsTo: metaPointsTo != null ? pointsToSlug(metaPointsTo) : void 0,
@@ -1491,7 +1531,10 @@ function attachedApiChangelogNode(ctx, scoped, scopeSegs, apiDefinitionId, scope
1491
1531
  }
1492
1532
  return metaStr(candidate.seg.metadata, "apiDefinitionId") === apiDefinitionId;
1493
1533
  });
1494
- const changelogSeg = candidates.find((candidate) => parentSectionPath(candidate.seg.section) === seg.section) ?? candidates[0];
1534
+ const apiReferenceCount = scopeSegs.filter((candidate) => {
1535
+ return metaStr(candidate.seg.metadata, "type") === "apiReference" && metaStr(candidate.seg.metadata, "apiDefinitionId") === apiDefinitionId;
1536
+ }).length;
1537
+ const changelogSeg = candidates.find((candidate) => parentSectionPath(candidate.seg.section) === seg.section) ?? (apiReferenceCount === 1 ? candidates[0] : void 0);
1495
1538
  return changelogSeg != null ? changelogNode(ctx, changelogSeg, scopePrefix) : void 0;
1496
1539
  }
1497
1540
  function hasOwningApiReference(scoped, scopeSegs) {
@@ -1499,12 +1542,13 @@ function hasOwningApiReference(scoped, scopeSegs) {
1499
1542
  if (apiDefinitionId == null || metaStr(scoped.seg.metadata, "type") !== "changelog") {
1500
1543
  return false;
1501
1544
  }
1502
- return scopeSegs.some((candidate) => {
1545
+ const candidates = scopeSegs.filter((candidate) => {
1503
1546
  if (metaStr(candidate.seg.metadata, "type") !== "apiReference") {
1504
1547
  return false;
1505
1548
  }
1506
1549
  return metaStr(candidate.seg.metadata, "apiDefinitionId") === apiDefinitionId;
1507
1550
  });
1551
+ return candidates.some((candidate) => parentSectionPath(scoped.seg.section) === candidate.seg.section) || candidates.length === 1;
1508
1552
  }
1509
1553
  function isNestedApiPackage(scoped, scopeSegs) {
1510
1554
  if (metaStr(scoped.seg.metadata, "type") !== "apiPackage") {
@@ -1650,6 +1694,10 @@ function buildSectionTree(ctx, scopeSegs, parentPath, scopePrefix, changelogScop
1650
1694
  if (hasOwningApiReference(s, scopeSegs) || isNestedApiPackage(s, scopeSegs)) {
1651
1695
  return false;
1652
1696
  }
1697
+ const depth = metaNum(s.seg.metadata, "sidebarDepth");
1698
+ if (depth === 0) {
1699
+ return false;
1700
+ }
1653
1701
  const parent = parentSectionPath(sec);
1654
1702
  if (parent === parentPath) {
1655
1703
  return true;
@@ -1659,6 +1707,7 @@ function buildSectionTree(ctx, scopeSegs, parentPath, scopePrefix, changelogScop
1659
1707
  }
1660
1708
  return false;
1661
1709
  }).sort((a, b) => a.seg.sortOrder - b.seg.sortOrder);
1710
+ const siblingBoundaries = computeDuplicateSiblingSortBoundaries(direct);
1662
1711
  return direct.map((s) => {
1663
1712
  const type = metaStr(s.seg.metadata, "type");
1664
1713
  const childIndex = metaNum(s.seg.metadata, "childIndex");
@@ -1668,10 +1717,14 @@ function buildSectionTree(ctx, scopeSegs, parentPath, scopePrefix, changelogScop
1668
1717
  } else if (type === "changelog") {
1669
1718
  node = changelogNode(ctx, s, changelogScopePrefix ?? scopePrefix);
1670
1719
  } else {
1720
+ const boundary = siblingBoundaries.get(s);
1721
+ const childScopeSegs = boundary != null ? scopeSegs.filter(
1722
+ (candidate) => candidate.seg.sortOrder >= boundary.lo && candidate.seg.sortOrder < boundary.hi
1723
+ ) : scopeSegs;
1671
1724
  node = sectionNode(
1672
1725
  ctx,
1673
1726
  s,
1674
- buildSectionTree(ctx, scopeSegs, s.seg.section, scopePrefix, changelogScopePrefix),
1727
+ buildSectionTree(ctx, childScopeSegs, s.seg.section, scopePrefix, changelogScopePrefix),
1675
1728
  scopePrefix
1676
1729
  );
1677
1730
  }
@@ -1692,8 +1745,9 @@ function computeSiblingSortBoundaries(ordered) {
1692
1745
  rootSections.push(s);
1693
1746
  continue;
1694
1747
  }
1748
+ const depth = metaNum(s.seg.metadata, "sidebarDepth");
1695
1749
  const parent = parentSectionPath(sec);
1696
- const isRootLevel = parent === "" || !sectionPaths.has(parent) && nearestExistingAncestor(sec, sectionPaths) === "";
1750
+ const isRootLevel = depth === 0 || parent === "" || !sectionPaths.has(parent) && nearestExistingAncestor(sec, sectionPaths) === "";
1697
1751
  if (isRootLevel) {
1698
1752
  rootSections.push(s);
1699
1753
  }
@@ -1730,6 +1784,14 @@ function buildSidebarRootChildren(ctx, scopeSegs, scopePrefix, changelogScopePre
1730
1784
  if (hasOwningApiReference(s, scopeSegs) || isNestedApiPackage(s, scopeSegs)) {
1731
1785
  continue;
1732
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
+ }
1733
1795
  if (type === "tabRoot" && metaBool(s.seg.metadata, "landingPage") === true) {
1734
1796
  continue;
1735
1797
  }
@@ -1750,9 +1812,10 @@ function buildSidebarRootChildren(ctx, scopeSegs, scopePrefix, changelogScopePre
1750
1812
  annotated.push({ node, pos: metaNum(s.seg.metadata, "childIndex"), isLeaf: false });
1751
1813
  continue;
1752
1814
  }
1815
+ const depth = metaNum(s.seg.metadata, "sidebarDepth");
1753
1816
  const parent = parentSectionPath(sec);
1754
- const isRootLevel = parent === "" || !sectionPaths.has(parent) && nearestExistingAncestor(sec, sectionPaths) === "";
1755
- if (isRootLevel && hasRootSection && sec !== "") {
1817
+ const isRootLevel = depth === 0 || parent === "" || !sectionPaths.has(parent) && nearestExistingAncestor(sec, sectionPaths) === "";
1818
+ if (isRootLevel && hasRootSection && sec !== "" && depth !== 0) {
1756
1819
  continue;
1757
1820
  }
1758
1821
  if (isRootLevel) {
@@ -1804,10 +1867,6 @@ function groupSidebarRootChildren(ctx, children) {
1804
1867
  } else if (child.type === "section" && !child.collapsible) {
1805
1868
  flushRun();
1806
1869
  out.push(child);
1807
- } else if (child.type === "changelog") {
1808
- flushRun();
1809
- run.push(child);
1810
- flushRun();
1811
1870
  } else {
1812
1871
  run.push(child);
1813
1872
  }
@@ -1922,7 +1981,7 @@ function buildVariantedNode(ctx, variants, scopeSegs, scopePrefix) {
1922
1981
  const variantIndividualSlug = detailSlug(variant);
1923
1982
  const variantSlug = variantIndividualSlug !== "" ? asSlug(slugjoin(scopePrefix, variantIndividualSlug)) : scopePrefix;
1924
1983
  const metaPointsTo = metaStr(variant.metadata, "pointsTo");
1925
- const children = buildSidebarRootChildren(ctx, variantSegs, scopePrefix);
1984
+ const children = buildSidebarRootChildren(ctx, variantSegs, variantSlug);
1926
1985
  return {
1927
1986
  type: "variant",
1928
1987
  ...withMetadataDefaults({
@@ -2324,6 +2383,7 @@ function buildProductGroup(ctx, products, scoped, rootSlug, skipSharedSectionMer
2324
2383
  };
2325
2384
  return node;
2326
2385
  });
2386
+ markCrossProductCanonicalSlugs(children);
2327
2387
  return {
2328
2388
  type: "productgroup",
2329
2389
  id: ctx.nodeId("productgroup"),
@@ -2335,6 +2395,32 @@ function buildProductGroup(ctx, products, scoped, rootSlug, skipSharedSectionMer
2335
2395
  children
2336
2396
  };
2337
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
+ }
2338
2424
  export {
2339
2425
  apiLeafNodeFromNavRoute,
2340
2426
  buildFullRootFromSegments,