@fern-api/fdr-sdk 1.2.38-b6bdd8176d → 1.2.39-38c6f9a29c

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.
@@ -657,6 +657,77 @@ function getChildren(node) {
657
657
  }
658
658
  }
659
659
 
660
+ // ../commons/core-utils/dist/assertNever.js
661
+ function assertNever(x) {
662
+ throw new Error("Unexpected value: " + JSON.stringify(x));
663
+ }
664
+
665
+ // ../commons/core-utils/dist/visitDiscriminatedUnion.js
666
+ function visitDiscriminatedUnion(item, discriminant = "type") {
667
+ return {
668
+ _visit: (visitor) => {
669
+ const visit = visitor[item[discriminant]];
670
+ if (visit != null) {
671
+ return visit(item);
672
+ } else {
673
+ if (visitor._other == null) {
674
+ assertNever(item);
675
+ }
676
+ return visitor._other(item);
677
+ }
678
+ }
679
+ };
680
+ }
681
+ var visitDiscriminatedUnion_default = visitDiscriminatedUnion;
682
+
683
+ // src/navigation/versions/latest/getPageId.ts
684
+ var RETURN_PAGEID = (node) => node.pageId;
685
+ var RETURN_OVERVIEW_PAGEID = (node) => node.overviewPageId;
686
+ var RETURN_UNDEFINED = () => void 0;
687
+ function getPageId(node) {
688
+ return visitDiscriminatedUnion_default(node)._visit({
689
+ section: RETURN_OVERVIEW_PAGEID,
690
+ apiReference: RETURN_OVERVIEW_PAGEID,
691
+ changelog: RETURN_OVERVIEW_PAGEID,
692
+ apiPackage: RETURN_OVERVIEW_PAGEID,
693
+ changelogEntry: RETURN_PAGEID,
694
+ page: RETURN_PAGEID,
695
+ landingPage: RETURN_PAGEID,
696
+ // if the following changes, make sure to update the algolia records generator
697
+ endpoint: RETURN_UNDEFINED,
698
+ webSocket: RETURN_UNDEFINED,
699
+ webhook: RETURN_UNDEFINED,
700
+ grpc: RETURN_UNDEFINED,
701
+ graphql: RETURN_UNDEFINED,
702
+ graphqlType: RETURN_UNDEFINED
703
+ // changelogYear: RETURN_UNDEFINED,
704
+ // changelogMonth: RETURN_UNDEFINED,
705
+ });
706
+ }
707
+
708
+ // src/navigation/versions/latest/NavigationNodeSection.ts
709
+ function isSection(node) {
710
+ return node.type === "section" || node.type === "apiReference" || node.type === "changelog" || node.type === "apiPackage";
711
+ }
712
+
713
+ // src/navigation/versions/latest/NavigationNodeSectionOverview.ts
714
+ function isSectionOverview(node) {
715
+ return isSection(node) && node.overviewPageId != null;
716
+ }
717
+
718
+ // src/navigation/versions/latest/NavigationNodeMarkdown.ts
719
+ function hasMarkdown(node) {
720
+ return isMarkdownLeaf(node) || isSectionOverview(node);
721
+ }
722
+
723
+ // src/navigation/versions/latest/NavigationNodePage.ts
724
+ function isPage(node) {
725
+ return isApiLeaf(node) || node.type === "changelog" || // TODO: Uncomment when changelog years and months are visitable
726
+ // node.type === "changelogYear" ||
727
+ // node.type === "changelogMonth" ||
728
+ hasMarkdown(node);
729
+ }
730
+
660
731
  // src/navigation/versions/latest/NavigationNodeWithMetadata.ts
661
732
  function hasMetadata(node) {
662
733
  return typeof node.title === "string" && typeof node.slug === "string";
@@ -1084,8 +1155,9 @@ function sectionNode(ctx, scoped, sectionChildren, scopePrefix) {
1084
1155
  const { seg, nav } = scoped;
1085
1156
  const overview = overviewRoute(nav) ?? overviewRouteFromSegmentMeta(seg, nav);
1086
1157
  const overviewPageId = overview != null ? metaStr(overview.metadata, "pageId") : void 0;
1087
- let slug = structuralNodeSlug(ctx, overview?.fullPath, seg.section, scopePrefix);
1088
- if (seg.section === "" && overview?.fullPath == null) {
1158
+ const relSection = stripLeadingScopePrefix(seg.section, scopePrefix);
1159
+ let slug = structuralNodeSlug(ctx, overview?.fullPath, relSection, scopePrefix);
1160
+ if (relSection === "" && overview?.fullPath == null) {
1089
1161
  slug = inferSectionSlugFromNav(ctx, nav, scopePrefix) ?? slug;
1090
1162
  }
1091
1163
  const metaPointsTo = metaStr(seg.metadata, "pointsTo");
@@ -1166,7 +1238,12 @@ function apiPackageChildNode(ctx, scoped, scopeSegs, parentApiDefinitionId, scop
1166
1238
  const overview = overviewRoute(nav);
1167
1239
  const overviewPageId = overview != null ? metaStr(overview.metadata, "pageId") : void 0;
1168
1240
  const apiDefinitionId = metaStr(seg.metadata, "apiDefinitionId") ?? parentApiDefinitionId;
1169
- const slug = structuralNodeSlug(ctx, overview?.fullPath, seg.section, scopePrefix);
1241
+ const slug = structuralNodeSlug(
1242
+ ctx,
1243
+ overview?.fullPath,
1244
+ stripLeadingScopePrefix(seg.section, scopePrefix),
1245
+ scopePrefix
1246
+ );
1170
1247
  const metaPointsTo = metaStr(seg.metadata, "pointsTo");
1171
1248
  const children = buildApiChildren(ctx, scoped, scopeSegs, apiDefinitionId, scopePrefix);
1172
1249
  return {
@@ -1245,7 +1322,12 @@ function apiReferenceNode(ctx, scoped, scopeSegs, scopePrefix) {
1245
1322
  const overview = overviewRoute(nav);
1246
1323
  const overviewPageId = overview != null ? metaStr(overview.metadata, "pageId") : void 0;
1247
1324
  const apiDefinitionId = metaStr(seg.metadata, "apiDefinitionId") ?? "";
1248
- const slug = structuralNodeSlug(ctx, overview?.fullPath, seg.section, scopePrefix);
1325
+ const slug = structuralNodeSlug(
1326
+ ctx,
1327
+ overview?.fullPath,
1328
+ stripLeadingScopePrefix(seg.section, scopePrefix),
1329
+ scopePrefix
1330
+ );
1249
1331
  const metaPointsTo = metaStr(seg.metadata, "pointsTo");
1250
1332
  const children = buildApiChildren(ctx, scoped, scopeSegs, apiDefinitionId, scopePrefix);
1251
1333
  const changelog = attachedApiChangelogNode(ctx, scoped, scopeSegs, apiDefinitionId, scopePrefix);
@@ -1650,7 +1732,10 @@ function buildTabbedOrSidebar(ctx, scopeSegs, tabsPresent, scopePrefix) {
1650
1732
  const tabDetails = uniqueDetails(scopeSegs, "tab");
1651
1733
  const children = tabDetails.map((tab) => {
1652
1734
  const tabType = metaStr(tab.metadata, "tab_type");
1653
- const tabSlug = asSlug(scopeSlugPrefix(scopePrefix, tab));
1735
+ const rawTabSlug = detailSlug(tab);
1736
+ const versionDetail = scopeSegs[0]?.seg.version;
1737
+ const versionSlugStr = versionDetail != null ? detailSlug(versionDetail) : void 0;
1738
+ const tabSlug = versionSlugStr != null && rawTabSlug !== "" && (rawTabSlug === versionSlugStr || rawTabSlug.startsWith(versionSlugStr + "/")) ? asSlug(rawTabSlug) : asSlug(scopeSlugPrefix(scopePrefix, tab));
1654
1739
  if (tabType === "link") {
1655
1740
  return {
1656
1741
  type: "link",
@@ -1747,7 +1832,7 @@ function buildVersioned(ctx, versions, scoped, rootSlug, productPrefix) {
1747
1832
  default: detailIsDefault(version),
1748
1833
  versionId: VersionId(version.id),
1749
1834
  availability: void 0,
1750
- landingPage: void 0,
1835
+ landingPage: buildVersionLandingPage(ctx, versionSegs, asSlug(slug)),
1751
1836
  announcement: void 0,
1752
1837
  pointsTo: metaStr(version.metadata, "pointsTo") != null ? pointsToSlug(metaStr(version.metadata, "pointsTo")) : void 0,
1753
1838
  // The version's full slug roots structural sections so the whole
@@ -1759,6 +1844,7 @@ function buildVersioned(ctx, versions, scoped, rootSlug, productPrefix) {
1759
1844
  }
1760
1845
  return node;
1761
1846
  });
1847
+ markCrossVersionCanonicalSlugs(children);
1762
1848
  return {
1763
1849
  type: "versioned",
1764
1850
  id: ctx.nodeId(`versioned:${productPrefix ?? "root"}`),
@@ -1784,6 +1870,111 @@ function markDefaultVersionCanonicalSlugs(node, pruneSlug, versionSlug) {
1784
1870
  return;
1785
1871
  });
1786
1872
  }
1873
+ function unversionedParents(parents) {
1874
+ let versionIdx = -1;
1875
+ for (let i = parents.length - 1; i >= 0; i--) {
1876
+ if (parents[i].type === "version") {
1877
+ versionIdx = i;
1878
+ break;
1879
+ }
1880
+ }
1881
+ return versionIdx >= 0 ? parents.slice(versionIdx + 1) : parents;
1882
+ }
1883
+ function crossVersionDedupKeys(node, parents) {
1884
+ const keys = [];
1885
+ const uParents = unversionedParents(parents);
1886
+ const pid = getPageId(node);
1887
+ if (pid != null) {
1888
+ keys.push(`pid:${pid}`);
1889
+ }
1890
+ if (node.type === "endpoint" || node.type === "webSocket" || node.type === "webhook" || node.type === "grpc" || node.type === "graphql") {
1891
+ const apiParentTitles = uParents.filter(
1892
+ (p) => p.type === "apiReference"
1893
+ ).map((p) => p.title.replaceAll(" ", ""));
1894
+ const apiPrefix = apiParentTitles.join(":");
1895
+ if (node.type === "endpoint") {
1896
+ keys.push(`${apiPrefix}:api:endpoint:${node.method}:${node.endpointId}`);
1897
+ } else if (node.type === "webSocket") {
1898
+ keys.push(`${apiPrefix}:api:websocket:${node.webSocketId}`);
1899
+ } else if (node.type === "webhook") {
1900
+ keys.push(`${apiPrefix}:api:webhook:${node.method}:${node.webhookId}`);
1901
+ } else if (node.type === "grpc") {
1902
+ keys.push(`${apiPrefix}:api:grpc:${node.method}:${node.grpcId}`);
1903
+ } else if (node.type === "graphql") {
1904
+ keys.push(`${apiPrefix}:api:graphql:${node.id}`);
1905
+ }
1906
+ }
1907
+ const parentTitles = [];
1908
+ for (const p of uParents) {
1909
+ if (hasMetadata(p)) {
1910
+ parentTitles.push(p.title);
1911
+ }
1912
+ }
1913
+ keys.push([...parentTitles, node.title].join("###"));
1914
+ return keys;
1915
+ }
1916
+ function buildVersionLandingPage(ctx, versionSegs, versionSlug) {
1917
+ const tablessSegs = versionSegs.filter((s) => s.seg.tab == null);
1918
+ if (tablessSegs.length === 0) {
1919
+ return void 0;
1920
+ }
1921
+ for (const s of tablessSegs) {
1922
+ for (const r of s.nav) {
1923
+ if (r.type === "markdown" && r.fullPath != null) {
1924
+ const md = r.metadata;
1925
+ const pageId = metaStr(md, "pageId") ?? "";
1926
+ const slug = ctx.contentSlug(r.fullPath);
1927
+ return {
1928
+ type: "landingPage",
1929
+ ...withMetadataDefaults({
1930
+ id: ctx.nodeId(`landing:${slug}`),
1931
+ title: metaStr(md, "title") ?? "",
1932
+ slug,
1933
+ icon: metaStr(md, "icon"),
1934
+ hidden: r.hidden,
1935
+ viewers: toViewers(metaStrArr(md, "viewers"))
1936
+ }),
1937
+ pageId: PageId(pageId),
1938
+ noindex: metaBool(md, "noindex")
1939
+ };
1940
+ }
1941
+ }
1942
+ }
1943
+ return void 0;
1944
+ }
1945
+ function markCrossVersionCanonicalSlugs(versionNodes) {
1946
+ const keyToCanonical = /* @__PURE__ */ new Map();
1947
+ const sorted = [...versionNodes].sort((a, b) => {
1948
+ if (a.default !== b.default) {
1949
+ return a.default ? -1 : 1;
1950
+ }
1951
+ return 0;
1952
+ });
1953
+ for (const version of sorted) {
1954
+ traverseDF(version, (child, parents) => {
1955
+ if (hasMetadata(child) && isPage(child)) {
1956
+ const keys = crossVersionDedupKeys(child, parents);
1957
+ let matched = false;
1958
+ for (const key of keys) {
1959
+ const canonical = keyToCanonical.get(key);
1960
+ if (canonical != null && !version.default) {
1961
+ child.canonicalSlug = canonical;
1962
+ matched = true;
1963
+ break;
1964
+ }
1965
+ }
1966
+ if (!matched) {
1967
+ const canonical = child.canonicalSlug ?? child.slug;
1968
+ for (const key of keys) {
1969
+ if (!keyToCanonical.has(key)) {
1970
+ keyToCanonical.set(key, canonical);
1971
+ }
1972
+ }
1973
+ }
1974
+ }
1975
+ });
1976
+ }
1977
+ }
1787
1978
  function buildProductGroup(ctx, products, scoped, rootSlug) {
1788
1979
  const children = products.map((product) => {
1789
1980
  const productSegs = scoped.filter((s) => s.seg.product?.id === product.id);