@fern-api/fdr-sdk 1.2.39-008eed59b3 → 1.2.39-4a89db5dd2

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 (32) 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 +104 -43
  10. package/dist/js/navigation/ledger-root-builder.js.map +1 -1
  11. package/dist/js/navigation/ledger-root-builder.mjs +104 -43
  12. package/dist/js/navigation/ledger-root-builder.mjs.map +1 -1
  13. package/dist/js/orpc-client.js +1 -0
  14. package/dist/js/orpc-client.js.map +1 -1
  15. package/dist/js/orpc-client.mjs +1 -0
  16. package/dist/js/orpc-client.mjs.map +1 -1
  17. package/dist/tsconfig.tsbuildinfo +1 -1
  18. package/dist/types/navigation/__test__/ledger-root-builder.apiReferenceChildren.test.d.ts +2 -0
  19. package/dist/types/navigation/__test__/ledger-root-builder.apiReferenceChildren.test.d.ts.map +1 -0
  20. package/dist/types/navigation/__test__/ledger-root-builder.landingPage.test.d.ts +2 -0
  21. package/dist/types/navigation/__test__/ledger-root-builder.landingPage.test.d.ts.map +1 -0
  22. package/dist/types/navigation/__test__/ledger-root-builder.rootSlug.test.d.ts +2 -0
  23. package/dist/types/navigation/__test__/ledger-root-builder.rootSlug.test.d.ts.map +1 -0
  24. package/dist/types/navigation/__test__/ledger-root-builder.skipSlugTabs.test.d.ts +2 -0
  25. package/dist/types/navigation/__test__/ledger-root-builder.skipSlugTabs.test.d.ts.map +1 -0
  26. package/dist/types/navigation/ledger-root-builder.d.ts +2 -0
  27. package/dist/types/navigation/ledger-root-builder.d.ts.map +1 -1
  28. package/dist/types/orpc-client/docs-ledger/contract.d.ts +50 -0
  29. package/dist/types/orpc-client/docs-ledger/contract.d.ts.map +1 -1
  30. package/dist/types/orpc-client/docs-ledger/ledger-manifest.d.ts +12 -0
  31. package/dist/types/orpc-client/docs-ledger/ledger-manifest.d.ts.map +1 -1
  32. package/package.json +1 -1
@@ -1123,6 +1123,63 @@ function apiLeafNodeFromNavRouteInternal(ctx, route, segmentApiDefinitionId2) {
1123
1123
  }
1124
1124
  return void 0;
1125
1125
  }
1126
+ function apiLeafPositionKey(node) {
1127
+ switch (node.type) {
1128
+ case "endpoint":
1129
+ return `endpoint:${node.endpointId}`;
1130
+ case "webhook":
1131
+ return `webhook:${node.webhookId}`;
1132
+ case "webSocket":
1133
+ return `webSocket:${node.webSocketId}`;
1134
+ case "grpc":
1135
+ return `grpc:${node.grpcId}`;
1136
+ case "graphql":
1137
+ return `graphql:${node.graphqlOperationId}`;
1138
+ }
1139
+ }
1140
+ function apiChildPositionKey(node) {
1141
+ switch (node.type) {
1142
+ case "endpoint":
1143
+ case "webhook":
1144
+ case "webSocket":
1145
+ case "grpc":
1146
+ case "graphql":
1147
+ return apiLeafPositionKey(node);
1148
+ default:
1149
+ return void 0;
1150
+ }
1151
+ }
1152
+ function positionedApiLeafChildren(ctx, nav, apiDefinitionId) {
1153
+ const rawLeafNodes = [];
1154
+ const leafPositions = /* @__PURE__ */ new Map();
1155
+ const nonApiLeafNodes = [];
1156
+ for (let i = 0; i < nav.length; i++) {
1157
+ const route = nav[i];
1158
+ const pos = route.displaySortOrder ?? i;
1159
+ const apiLeaf = apiLeafNodeFromNavRouteInternal(ctx, route, apiDefinitionId);
1160
+ if (apiLeaf != null) {
1161
+ rawLeafNodes.push(apiLeaf);
1162
+ const key = apiLeafPositionKey(apiLeaf);
1163
+ leafPositions.set(key, Math.min(leafPositions.get(key) ?? pos, pos));
1164
+ continue;
1165
+ }
1166
+ const node = artifactToNode(ctx, route);
1167
+ if (node?.type === "page" || node?.type === "link") {
1168
+ nonApiLeafNodes.push({ node, pos });
1169
+ }
1170
+ }
1171
+ const apiLeafNodes = mergeEndpointPairs(ctx, rawLeafNodes, nav);
1172
+ const positionedApiLeafNodes = apiLeafNodes.map((node, index) => {
1173
+ if (node.type === "endpointPair") {
1174
+ const streamPos = leafPositions.get(apiLeafPositionKey(node.stream)) ?? index;
1175
+ const nonStreamPos = leafPositions.get(apiLeafPositionKey(node.nonStream)) ?? index;
1176
+ return { node, pos: Math.min(streamPos, nonStreamPos) };
1177
+ }
1178
+ const key = apiChildPositionKey(node);
1179
+ return { node, pos: key != null ? leafPositions.get(key) ?? index : index };
1180
+ });
1181
+ return [...positionedApiLeafNodes, ...nonApiLeafNodes];
1182
+ }
1126
1183
  function collectApiLeafNodesFromNav(routes, basePath, segmentApiDefinitionId2) {
1127
1184
  const ctx = createBuildContext(basePath);
1128
1185
  return routes.map((route) => apiLeafNodeFromNavRouteInternal(ctx, route, segmentApiDefinitionId2)).filter((node) => node != null);
@@ -1262,8 +1319,7 @@ function directChildApiPackages(parentSection, scopeSegs) {
1262
1319
  }
1263
1320
  function buildApiChildren(ctx, scoped, scopeSegs, apiDefinitionId, scopePrefix) {
1264
1321
  const { seg, nav } = scoped;
1265
- const rawLeafNodes = nav.map((route) => apiLeafNodeFromNavRouteInternal(ctx, route, apiDefinitionId)).filter((node) => node != null);
1266
- const leafNodes = mergeEndpointPairs(ctx, rawLeafNodes, nav);
1322
+ const leafNodes = positionedApiLeafChildren(ctx, nav, apiDefinitionId);
1267
1323
  const childPackages = directChildApiPackages(seg.section, scopeSegs);
1268
1324
  const packageNodes = childPackages.map((child) => ({
1269
1325
  node: apiPackageChildNode(
@@ -1277,18 +1333,10 @@ function buildApiChildren(ctx, scoped, scopeSegs, apiDefinitionId, scopePrefix)
1277
1333
  }));
1278
1334
  const hasChildIndex = packageNodes.some((p) => p.childIndex != null);
1279
1335
  if (!hasChildIndex) {
1280
- return [...leafNodes, ...packageNodes.map((p) => p.node)];
1281
- }
1282
- const leafPositions = [];
1283
- for (const route of nav) {
1284
- if (route.displaySortOrder != null) {
1285
- leafPositions.push(route.displaySortOrder);
1286
- }
1336
+ return [...leafNodes, ...packageNodes.map((p) => ({ node: p.node, pos: Number.MAX_SAFE_INTEGER }))].sort((a, b) => a.pos - b.pos).map((p) => p.node);
1287
1337
  }
1288
1338
  const positioned = [];
1289
- for (let i = 0; i < leafNodes.length; i++) {
1290
- positioned.push({ node: leafNodes[i], pos: leafPositions[i] ?? i });
1291
- }
1339
+ positioned.push(...leafNodes);
1292
1340
  for (const p of packageNodes) {
1293
1341
  positioned.push({ node: p.node, pos: p.childIndex ?? Number.MAX_SAFE_INTEGER });
1294
1342
  }
@@ -1591,6 +1639,9 @@ function buildSidebarRootChildren(ctx, scopeSegs, scopePrefix, changelogScopePre
1591
1639
  if (hasOwningApiReference(s, scopeSegs)) {
1592
1640
  continue;
1593
1641
  }
1642
+ if (type === "tabRoot" && metaBool(s.seg.metadata, "landingPage") === true) {
1643
+ continue;
1644
+ }
1594
1645
  if (type === "tabRoot" || sec === "" && type !== "section") {
1595
1646
  for (const r of s.nav) {
1596
1647
  const node = artifactToNode(ctx, r);
@@ -1677,13 +1728,13 @@ function buildSidebarRoot(ctx, scopeSegs, scopePrefix, changelogScopePrefix) {
1677
1728
  };
1678
1729
  }
1679
1730
  function buildFullRootFromSegments(options) {
1680
- const { basePath, title, segments, navBySegment } = options;
1731
+ const { basePath, rootSlug: sourceRootSlug, title, segments, navBySegment } = options;
1681
1732
  const ctx = createBuildContext(basePath);
1682
1733
  const scoped = segments.filter((seg) => {
1683
1734
  const t = metaStr(seg.metadata, "type");
1684
1735
  return t !== "files" && t !== "redirects";
1685
1736
  }).map((seg) => ({ seg, nav: navBySegment.get(seg.segmentHash) ?? [] }));
1686
- const rootSlug = asSlug(basePath);
1737
+ const rootSlug = asSlug(sourceRootSlug ?? basePath);
1687
1738
  const scopesByKey = /* @__PURE__ */ new Map();
1688
1739
  for (const s of scoped) {
1689
1740
  const key = scopeKey(s.seg);
@@ -1746,7 +1797,7 @@ function uniqueDetails(scoped, dim) {
1746
1797
  continue;
1747
1798
  }
1748
1799
  const slug = detailSlug(d);
1749
- const key = slug !== "" ? slug : d.id;
1800
+ const key = dim === "tab" ? d.id : slug !== "" ? slug : d.id;
1750
1801
  const existing = byKey.get(key);
1751
1802
  if (existing == null) {
1752
1803
  byKey.set(key, d);
@@ -1898,7 +1949,7 @@ function buildUnversioned(ctx, scopeSegs, scopePrefix, tabsPresent) {
1898
1949
  type: "unversioned",
1899
1950
  id: ctx.nodeId(`unversioned:${first?.seg.product?.id ?? "root"}`),
1900
1951
  collapsed: void 0,
1901
- landingPage: void 0,
1952
+ landingPage: buildLandingPage(ctx, scopeSegs),
1902
1953
  // The enclosing scope prefix (product slug, or rootSlug at the top
1903
1954
  // level) roots structural sections so they share the scope's slug
1904
1955
  // namespace.
@@ -1925,7 +1976,7 @@ function buildVersioned(ctx, versions, scoped, rootSlug, productPrefix) {
1925
1976
  default: detailIsDefault(version),
1926
1977
  versionId: VersionId(version.id),
1927
1978
  availability: void 0,
1928
- landingPage: buildVersionLandingPage(ctx, versionSegs, asSlug(slug)),
1979
+ landingPage: buildLandingPage(ctx, versionSegs),
1929
1980
  announcement: void 0,
1930
1981
  pointsTo: metaStr(version.metadata, "pointsTo") != null ? pointsToSlug(metaStr(version.metadata, "pointsTo")) : void 0,
1931
1982
  // The version's full slug roots structural sections so the whole
@@ -2006,34 +2057,41 @@ function crossVersionDedupKeys(node, parents) {
2006
2057
  keys.push([...parentTitles, node.title].join("###"));
2007
2058
  return keys;
2008
2059
  }
2009
- function buildVersionLandingPage(ctx, versionSegs, versionSlug) {
2010
- const tablessSegs = versionSegs.filter((s) => s.seg.tab == null);
2011
- if (tablessSegs.length === 0) {
2060
+ function routeToLandingPage(ctx, route) {
2061
+ if (route == null || route.type !== "markdown" || route.fullPath == null) {
2012
2062
  return void 0;
2013
2063
  }
2014
- for (const s of tablessSegs) {
2015
- for (const r of s.nav) {
2016
- if (r.type === "markdown" && r.fullPath != null) {
2017
- const md = r.metadata;
2018
- const pageId = metaStr(md, "pageId") ?? "";
2019
- const slug = ctx.contentSlug(r.fullPath);
2020
- return {
2021
- type: "landingPage",
2022
- ...withMetadataDefaults({
2023
- id: ctx.nodeId(`landing:${slug}`),
2024
- title: metaStr(md, "title") ?? "",
2025
- slug,
2026
- icon: metaStr(md, "icon"),
2027
- hidden: r.hidden,
2028
- viewers: toViewers(metaStrArr(md, "viewers"))
2029
- }),
2030
- pageId: PageId(pageId),
2031
- noindex: metaBool(md, "noindex")
2032
- };
2033
- }
2034
- }
2064
+ const md = route.metadata;
2065
+ const pageId = metaStr(md, "pageId");
2066
+ if (pageId == null) {
2067
+ return void 0;
2035
2068
  }
2036
- return void 0;
2069
+ const slug = ctx.contentSlug(route.fullPath);
2070
+ return {
2071
+ type: "landingPage",
2072
+ ...withMetadataDefaults({
2073
+ id: ctx.nodeId(`landing:${slug}`),
2074
+ title: metaStr(md, "title") ?? "",
2075
+ slug,
2076
+ icon: metaStr(md, "icon"),
2077
+ hidden: route.hidden,
2078
+ authed: metaBool(md, "authed"),
2079
+ viewers: toViewers(metaStrArr(md, "viewers")),
2080
+ orphaned: metaBool(md, "orphaned"),
2081
+ featureFlags: metaFeatureFlags(md)
2082
+ }),
2083
+ pageId: PageId(pageId),
2084
+ noindex: metaBool(md, "noindex")
2085
+ };
2086
+ }
2087
+ function buildLandingPage(ctx, scopeSegs) {
2088
+ const landingSegment = scopeSegs.find(
2089
+ (s) => metaStr(s.seg.metadata, "type") === "tabRoot" && metaBool(s.seg.metadata, "landingPage") === true
2090
+ );
2091
+ return routeToLandingPage(
2092
+ ctx,
2093
+ landingSegment?.nav.find((route) => route.type === "markdown")
2094
+ );
2037
2095
  }
2038
2096
  function markCrossVersionCanonicalSlugs(versionNodes) {
2039
2097
  const keyToCanonical = /* @__PURE__ */ new Map();
@@ -2104,7 +2162,10 @@ function buildProductGroup(ctx, products, scoped, rootSlug) {
2104
2162
  type: "productgroup",
2105
2163
  id: ctx.nodeId("productgroup"),
2106
2164
  collapsed: void 0,
2107
- landingPage: void 0,
2165
+ landingPage: buildLandingPage(
2166
+ ctx,
2167
+ scoped.filter((s) => s.seg.product == null)
2168
+ ),
2108
2169
  children
2109
2170
  };
2110
2171
  }