@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.
@@ -1043,9 +1043,12 @@ function apiLeafNodeFromNavRoute(route, basePath, segmentApiDefinitionId2) {
1043
1043
  return apiLeafNodeFromNavRouteInternal(ctx, route, segmentApiDefinitionId2);
1044
1044
  }
1045
1045
  function apiLeafNodeFromNavRouteInternal(ctx, route, segmentApiDefinitionId2) {
1046
+ if (route.fullPath == null) {
1047
+ return void 0;
1048
+ }
1046
1049
  const md = route.metadata;
1047
1050
  const apiDefinitionId = ApiDefinitionId(metaStr(md, "apiDefinitionId") ?? segmentApiDefinitionId2);
1048
- const slug = ctx.contentSlug(route.fullPath ?? "");
1051
+ const slug = ctx.contentSlug(route.fullPath);
1049
1052
  const title = metaStr(md, "title") ?? "";
1050
1053
  const icon = metaStr(md, "icon");
1051
1054
  const viewers = toViewers(metaStrArr(md, "viewers"));
@@ -2405,8 +2408,27 @@ function buildLandingPage(ctx, scopeSegs) {
2405
2408
  landingSegment?.nav.find((route) => route.type === "markdown")
2406
2409
  );
2407
2410
  }
2411
+ function buildSlugOwnerContentKeys(roots) {
2412
+ const slugOwnerKeys = /* @__PURE__ */ new Map();
2413
+ for (const root of roots) {
2414
+ traverseDF(root, (child, parents) => {
2415
+ if (hasMetadata(child) && isPage(child) && !slugOwnerKeys.has(child.slug)) {
2416
+ slugOwnerKeys.set(child.slug, new Set(crossVersionDedupKeys(child, parents)));
2417
+ }
2418
+ });
2419
+ }
2420
+ return slugOwnerKeys;
2421
+ }
2422
+ function canonicalOwnerSharesContent(slugOwnerKeys, canonical, keys) {
2423
+ const ownerKeys = slugOwnerKeys.get(canonical);
2424
+ if (ownerKeys == null) {
2425
+ return false;
2426
+ }
2427
+ return keys.some((key) => key.startsWith("pid:") && ownerKeys.has(key));
2428
+ }
2408
2429
  function markWithinScopeCanonicalSlugs(scopeNode) {
2409
2430
  const keyToCanonical = /* @__PURE__ */ new Map();
2431
+ const slugOwnerKeys = buildSlugOwnerContentKeys([scopeNode]);
2410
2432
  traverseDF(scopeNode, (child, parents) => {
2411
2433
  if (hasMetadata(child) && isPage(child)) {
2412
2434
  const keys = crossVersionDedupKeys(child, parents);
@@ -2414,7 +2436,7 @@ function markWithinScopeCanonicalSlugs(scopeNode) {
2414
2436
  for (const key of keys) {
2415
2437
  const canonical = keyToCanonical.get(key);
2416
2438
  if (canonical != null && canonical !== child.slug) {
2417
- if (child.slug.startsWith(canonical + "/") && getChildren(child).length > 0) {
2439
+ if (child.slug.startsWith(canonical + "/") && getChildren(child).length > 0 && !canonicalOwnerSharesContent(slugOwnerKeys, canonical, keys)) {
2418
2440
  continue;
2419
2441
  }
2420
2442
  child.canonicalSlug = canonical;
@@ -2441,6 +2463,7 @@ function markCrossVersionCanonicalSlugs(versionNodes) {
2441
2463
  }
2442
2464
  return 0;
2443
2465
  });
2466
+ const slugOwnerKeys = buildSlugOwnerContentKeys(sorted);
2444
2467
  for (const version of sorted) {
2445
2468
  traverseDF(version, (child, parents) => {
2446
2469
  if (hasMetadata(child) && isPage(child)) {
@@ -2449,7 +2472,7 @@ function markCrossVersionCanonicalSlugs(versionNodes) {
2449
2472
  for (const key of keys) {
2450
2473
  const canonical = keyToCanonical.get(key);
2451
2474
  if (canonical != null && !version.default) {
2452
- if (child.slug.startsWith(canonical + "/") && getChildren(child).length > 0) {
2475
+ if (child.slug.startsWith(canonical + "/") && getChildren(child).length > 0 && !canonicalOwnerSharesContent(slugOwnerKeys, canonical, keys)) {
2453
2476
  continue;
2454
2477
  }
2455
2478
  child.canonicalSlug = canonical;