@fern-api/fdr-sdk 1.2.50-22414d3dea → 1.2.51-403b2eae4f

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.
@@ -1084,9 +1084,12 @@ function apiLeafNodeFromNavRoute(route, basePath, segmentApiDefinitionId2) {
1084
1084
  return apiLeafNodeFromNavRouteInternal(ctx, route, segmentApiDefinitionId2);
1085
1085
  }
1086
1086
  function apiLeafNodeFromNavRouteInternal(ctx, route, segmentApiDefinitionId2) {
1087
+ if (route.fullPath == null) {
1088
+ return void 0;
1089
+ }
1087
1090
  const md = route.metadata;
1088
1091
  const apiDefinitionId = ApiDefinitionId(metaStr(md, "apiDefinitionId") ?? segmentApiDefinitionId2);
1089
- const slug = ctx.contentSlug(route.fullPath ?? "");
1092
+ const slug = ctx.contentSlug(route.fullPath);
1090
1093
  const title = metaStr(md, "title") ?? "";
1091
1094
  const icon = metaStr(md, "icon");
1092
1095
  const viewers = toViewers(metaStrArr(md, "viewers"));
@@ -2446,8 +2449,27 @@ function buildLandingPage(ctx, scopeSegs) {
2446
2449
  landingSegment?.nav.find((route) => route.type === "markdown")
2447
2450
  );
2448
2451
  }
2452
+ function buildSlugOwnerContentKeys(roots) {
2453
+ const slugOwnerKeys = /* @__PURE__ */ new Map();
2454
+ for (const root of roots) {
2455
+ traverseDF(root, (child, parents) => {
2456
+ if (hasMetadata(child) && isPage(child) && !slugOwnerKeys.has(child.slug)) {
2457
+ slugOwnerKeys.set(child.slug, new Set(crossVersionDedupKeys(child, parents)));
2458
+ }
2459
+ });
2460
+ }
2461
+ return slugOwnerKeys;
2462
+ }
2463
+ function canonicalOwnerSharesContent(slugOwnerKeys, canonical, keys) {
2464
+ const ownerKeys = slugOwnerKeys.get(canonical);
2465
+ if (ownerKeys == null) {
2466
+ return false;
2467
+ }
2468
+ return keys.some((key) => key.startsWith("pid:") && ownerKeys.has(key));
2469
+ }
2449
2470
  function markWithinScopeCanonicalSlugs(scopeNode) {
2450
2471
  const keyToCanonical = /* @__PURE__ */ new Map();
2472
+ const slugOwnerKeys = buildSlugOwnerContentKeys([scopeNode]);
2451
2473
  traverseDF(scopeNode, (child, parents) => {
2452
2474
  if (hasMetadata(child) && isPage(child)) {
2453
2475
  const keys = crossVersionDedupKeys(child, parents);
@@ -2455,7 +2477,7 @@ function markWithinScopeCanonicalSlugs(scopeNode) {
2455
2477
  for (const key of keys) {
2456
2478
  const canonical = keyToCanonical.get(key);
2457
2479
  if (canonical != null && canonical !== child.slug) {
2458
- if (child.slug.startsWith(canonical + "/") && getChildren(child).length > 0) {
2480
+ if (child.slug.startsWith(canonical + "/") && getChildren(child).length > 0 && !canonicalOwnerSharesContent(slugOwnerKeys, canonical, keys)) {
2459
2481
  continue;
2460
2482
  }
2461
2483
  child.canonicalSlug = canonical;
@@ -2482,6 +2504,7 @@ function markCrossVersionCanonicalSlugs(versionNodes) {
2482
2504
  }
2483
2505
  return 0;
2484
2506
  });
2507
+ const slugOwnerKeys = buildSlugOwnerContentKeys(sorted);
2485
2508
  for (const version of sorted) {
2486
2509
  traverseDF(version, (child, parents) => {
2487
2510
  if (hasMetadata(child) && isPage(child)) {
@@ -2490,7 +2513,7 @@ function markCrossVersionCanonicalSlugs(versionNodes) {
2490
2513
  for (const key of keys) {
2491
2514
  const canonical = keyToCanonical.get(key);
2492
2515
  if (canonical != null && !version.default) {
2493
- if (child.slug.startsWith(canonical + "/") && getChildren(child).length > 0) {
2516
+ if (child.slug.startsWith(canonical + "/") && getChildren(child).length > 0 && !canonicalOwnerSharesContent(slugOwnerKeys, canonical, keys)) {
2494
2517
  continue;
2495
2518
  }
2496
2519
  child.canonicalSlug = canonical;