@fern-api/fdr-sdk 1.2.19-2cc97d8bd7 → 1.2.19-72be327283

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.
@@ -57485,9 +57485,10 @@ function artifactToNode(ctx, route) {
57485
57485
  };
57486
57486
  return node;
57487
57487
  }
57488
- // Endpoints / websockets / webhooks / grpc / graphql are resolved via
57489
- // the paginated apiReference + on-demand API definition, not emitted as
57490
- // standalone sidebar children here.
57488
+ // API leaf types are handled by apiReferenceNode (which calls
57489
+ // apiLeafNodeFromNavRouteInternal), not by section-level artifact
57490
+ // conversion. Returning undefined here prevents them from appearing
57491
+ // as duplicate siblings alongside the apiReference node.
57491
57492
  case "rest":
57492
57493
  case "asyncapi":
57493
57494
  case "webhook":
@@ -57549,6 +57550,51 @@ function apiLeafNodeFromNavRouteInternal(ctx, route, segmentApiDefinitionId2) {
57549
57550
  availability: void 0
57550
57551
  };
57551
57552
  }
57553
+ if (route.type === "asyncapi") {
57554
+ const webSocketId = metaStr(md, "webSocketId");
57555
+ if (webSocketId == null) {
57556
+ return void 0;
57557
+ }
57558
+ return {
57559
+ type: "webSocket",
57560
+ ...meta,
57561
+ webSocketId: WebSocketId(webSocketId),
57562
+ apiDefinitionId,
57563
+ availability: void 0,
57564
+ playground: void 0
57565
+ };
57566
+ }
57567
+ if (route.type === "grpc") {
57568
+ const grpcId = metaStr(md, "grpcId");
57569
+ const method = metaStr(md, "method");
57570
+ if (grpcId == null || method == null) {
57571
+ return void 0;
57572
+ }
57573
+ return {
57574
+ type: "grpc",
57575
+ ...meta,
57576
+ method,
57577
+ grpcId: GrpcId(grpcId),
57578
+ apiDefinitionId,
57579
+ availability: void 0
57580
+ };
57581
+ }
57582
+ if (route.type === "graphql") {
57583
+ const graphqlOperationId = metaStr(md, "graphqlOperationId");
57584
+ const operationType = metaStr(md, "operationType");
57585
+ if (graphqlOperationId == null || operationType == null) {
57586
+ return void 0;
57587
+ }
57588
+ return {
57589
+ type: "graphql",
57590
+ ...meta,
57591
+ operationType,
57592
+ graphqlOperationId: GraphQlOperationId(graphqlOperationId),
57593
+ apiDefinitionId,
57594
+ availability: void 0,
57595
+ playground: void 0
57596
+ };
57597
+ }
57552
57598
  return void 0;
57553
57599
  }
57554
57600
  function collectApiLeafNodesFromNav(routes, basePath, segmentApiDefinitionId2) {
@@ -57586,12 +57632,32 @@ function sectionNode(ctx, scoped, sectionChildren) {
57586
57632
  children: [...leafChildren, ...sectionChildren]
57587
57633
  };
57588
57634
  }
57589
- function apiReferenceNode(ctx, scoped) {
57635
+ function collectDescendantApiNav(root, scopeSegs) {
57636
+ const rootSection = root.seg.section;
57637
+ const prefix = rootSection === "" ? "" : `${rootSection}/`;
57638
+ const routes = [...root.nav];
57639
+ for (const s6 of scopeSegs) {
57640
+ if (s6 === root) {
57641
+ continue;
57642
+ }
57643
+ const type = metaStr(s6.seg.metadata, "type");
57644
+ if (type !== "apiPackage") {
57645
+ continue;
57646
+ }
57647
+ if (s6.seg.section === rootSection || s6.seg.section.startsWith(prefix)) {
57648
+ routes.push(...s6.nav);
57649
+ }
57650
+ }
57651
+ return routes;
57652
+ }
57653
+ function apiReferenceNode(ctx, scoped, scopeSegs) {
57590
57654
  const { seg, nav } = scoped;
57591
57655
  const overview = overviewRoute(nav);
57592
57656
  const overviewPageId = overview != null ? metaStr(overview.metadata, "pageId") : void 0;
57593
57657
  const apiDefinitionId = metaStr(seg.metadata, "apiDefinitionId") ?? "";
57594
57658
  const slug = ctx.contentSlug(overview?.fullPath ?? nav[0]?.fullPath ?? seg.section);
57659
+ const allNav = collectDescendantApiNav(scoped, scopeSegs);
57660
+ const children = allNav.map((route) => apiLeafNodeFromNavRouteInternal(ctx, route, apiDefinitionId)).filter((node) => node != null);
57595
57661
  return {
57596
57662
  type: "apiReference",
57597
57663
  ...withMetadataDefaults({
@@ -57610,7 +57676,7 @@ function apiReferenceNode(ctx, scoped) {
57610
57676
  showErrors: metaBool(seg.metadata, "showErrors"),
57611
57677
  hideTitle: metaBool(seg.metadata, "hideTitle"),
57612
57678
  pointsTo: void 0,
57613
- children: [],
57679
+ children,
57614
57680
  changelog: void 0,
57615
57681
  playground: void 0,
57616
57682
  postmanCollectionUrl: void 0
@@ -57694,19 +57760,37 @@ function parentSectionPath(sectionPath) {
57694
57760
  const idx = sectionPath.lastIndexOf("/");
57695
57761
  return idx === -1 ? "" : sectionPath.slice(0, idx);
57696
57762
  }
57763
+ function nearestExistingAncestor(sectionPath, existing) {
57764
+ let current = parentSectionPath(sectionPath);
57765
+ while (current !== "") {
57766
+ if (existing.has(current)) {
57767
+ return current;
57768
+ }
57769
+ current = parentSectionPath(current);
57770
+ }
57771
+ return "";
57772
+ }
57697
57773
  function buildSectionTree(ctx, scopeSegs, parentPath) {
57774
+ const sectionPaths = new Set(scopeSegs.map((s6) => s6.seg.section));
57698
57775
  const direct = scopeSegs.filter((s6) => {
57699
57776
  const sec = s6.seg.section;
57700
57777
  const type = metaStr(s6.seg.metadata, "type");
57701
57778
  if (sec === "" || type === "tabRoot") {
57702
57779
  return false;
57703
57780
  }
57704
- return parentSectionPath(sec) === parentPath;
57781
+ const parent = parentSectionPath(sec);
57782
+ if (parent === parentPath) {
57783
+ return true;
57784
+ }
57785
+ if (!sectionPaths.has(parent)) {
57786
+ return nearestExistingAncestor(sec, sectionPaths) === parentPath;
57787
+ }
57788
+ return false;
57705
57789
  }).sort((a, b6) => a.seg.sortOrder - b6.seg.sortOrder);
57706
57790
  return direct.map((s6) => {
57707
57791
  const type = metaStr(s6.seg.metadata, "type");
57708
57792
  if (type === "apiReference" || type === "apiPackage") {
57709
- return apiReferenceNode(ctx, s6);
57793
+ return apiReferenceNode(ctx, s6, scopeSegs);
57710
57794
  }
57711
57795
  if (type === "changelog") {
57712
57796
  return changelogNode(ctx, s6);
@@ -57716,6 +57800,7 @@ function buildSectionTree(ctx, scopeSegs, parentPath) {
57716
57800
  }
57717
57801
  function buildSidebarRootChildren(ctx, scopeSegs) {
57718
57802
  const ordered = [...scopeSegs].sort((a, b6) => a.seg.sortOrder - b6.seg.sortOrder);
57803
+ const sectionPaths = new Set(ordered.map((s6) => s6.seg.section));
57719
57804
  const flat = [];
57720
57805
  for (const s6 of ordered) {
57721
57806
  const type = metaStr(s6.seg.metadata, "type");
@@ -57729,9 +57814,11 @@ function buildSidebarRootChildren(ctx, scopeSegs) {
57729
57814
  }
57730
57815
  continue;
57731
57816
  }
57732
- if (parentSectionPath(sec) === "") {
57817
+ const parent = parentSectionPath(sec);
57818
+ const isRootLevel = parent === "" || !sectionPaths.has(parent) && nearestExistingAncestor(sec, sectionPaths) === "";
57819
+ if (isRootLevel) {
57733
57820
  if (type === "apiReference" || type === "apiPackage") {
57734
- flat.push(apiReferenceNode(ctx, s6));
57821
+ flat.push(apiReferenceNode(ctx, s6, scopeSegs));
57735
57822
  } else if (type === "changelog") {
57736
57823
  flat.push(changelogNode(ctx, s6));
57737
57824
  } else {
@@ -57840,10 +57927,43 @@ function buildTabbedOrSidebar(ctx, scopeSegs, tabsPresent) {
57840
57927
  }
57841
57928
  const tabDetails = uniqueDetails(scopeSegs, "tab");
57842
57929
  const children = tabDetails.map((tab) => {
57843
- const tabSegs = scopeSegs.filter((s6) => s6.seg.tab?.id === tab.id);
57930
+ const tabType = metaStr(tab.metadata, "tab_type");
57844
57931
  const tabSlug = asSlug(scopeSlugPrefix(Slug(""), tab));
57932
+ if (tabType === "link") {
57933
+ return {
57934
+ type: "link",
57935
+ id: ctx.nodeId(`link:${metaStr(tab.metadata, "url") ?? tabSlug}`),
57936
+ collapsed: void 0,
57937
+ title: tab.displayName,
57938
+ icon: tab.icon ?? void 0,
57939
+ url: Url(metaStr(tab.metadata, "url") ?? ""),
57940
+ target: void 0
57941
+ };
57942
+ }
57943
+ if (tabType === "changelog") {
57944
+ const tabSegs2 = scopeSegs.filter((s6) => s6.seg.tab?.id === tab.id);
57945
+ const changelogSeg = tabSegs2.find((s6) => metaStr(s6.seg.metadata, "type") === "changelog");
57946
+ if (changelogSeg != null) {
57947
+ return changelogNode(ctx, changelogSeg);
57948
+ }
57949
+ return {
57950
+ type: "changelog",
57951
+ ...withMetadataDefaults({
57952
+ id: ctx.nodeId(`changelog:${tabSlug}`),
57953
+ title: tab.displayName,
57954
+ slug: tabSlug,
57955
+ icon: tab.icon ?? void 0,
57956
+ hidden: tab.hidden,
57957
+ viewers: toViewers(tab.viewers)
57958
+ }),
57959
+ overviewPageId: void 0,
57960
+ noindex: void 0,
57961
+ children: []
57962
+ };
57963
+ }
57964
+ const tabSegs = scopeSegs.filter((s6) => s6.seg.tab?.id === tab.id);
57845
57965
  const metaPointsTo = metaStr(tab.metadata, "pointsTo");
57846
- const node = {
57966
+ return {
57847
57967
  type: "tab",
57848
57968
  ...withMetadataDefaults({
57849
57969
  id: ctx.nodeId(`tab:${tabSlug}`),
@@ -57856,7 +57976,6 @@ function buildTabbedOrSidebar(ctx, scopeSegs, tabsPresent) {
57856
57976
  pointsTo: metaPointsTo != null ? ctx.contentSlug(metaPointsTo) : void 0,
57857
57977
  child: buildSidebarRoot(ctx, tabSegs)
57858
57978
  };
57859
- return node;
57860
57979
  });
57861
57980
  const first = scopeSegs[0];
57862
57981
  return {