Skip to content

Commit

Permalink
Merge branch 'main' into rohin/better-enum-parsing-openapi-parser-v2
Browse files Browse the repository at this point in the history
  • Loading branch information
RohinBhargava committed Jan 13, 2025
2 parents 2368315 + 69227e2 commit 028e77e
Show file tree
Hide file tree
Showing 96 changed files with 616 additions and 72 deletions.
1 change: 1 addition & 0 deletions fern/apis/fdr/definition/docs/v1/db/__package__.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ types:
root: optional<navigationV1.RootNode>
navbarLinks: optional<list<commons.NavbarLink>>
footerLinks: optional<list<commons.FooterLink>>
hideNavLinks: optional<boolean>

# logo
logoHeight: optional<docsReadV1.Height>
Expand Down
1 change: 1 addition & 0 deletions fern/apis/fdr/definition/docs/v1/read/__package__.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ types:
root: optional<navigationV1.RootNode>
navbarLinks: optional<list<commons.NavbarLink>>
footerLinks: optional<list<commons.FooterLink>>
hideNavLinks: optional<boolean>

# logo
logoHeight: optional<Height>
Expand Down
1 change: 1 addition & 0 deletions fern/apis/fdr/definition/docs/v1/write/__package__.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ types:
root: optional<navigationV1.RootNode>
navbarLinks: optional<list<commons.NavbarLink>>
footerLinks: optional<list<commons.FooterLink>>
hideNavLinks: optional<boolean>

# logo
logoHeight: optional<Height>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export class DefinitionObjectFactory {
},
navbarLinks: [],
navigation: { items: [], landingPage: undefined },
hideNavLinks: undefined,
root: undefined,
title: undefined,
defaultLanguage: undefined,
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ export function convertDocsDefinitionToDb({
: undefined,
navbarLinks: writeShape.config.navbarLinks,
footerLinks: writeShape.config.footerLinks,
hideNavLinks: writeShape.config.hideNavLinks,
title: writeShape.config.title,
favicon: writeShape.config.favicon,
backgroundImage: writeShape.config.backgroundImage,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export function convertDbDocsConfigToRead({
colorsV3: dbShape.colorsV3 ?? getColorsV3(dbShape),
navbarLinks: dbShape.navbarLinks,
footerLinks: dbShape.footerLinks,
hideNavLinks: dbShape.hideNavLinks,
title: dbShape.title,
favicon: dbShape.favicon,
typographyV2:
Expand Down
25 changes: 24 additions & 1 deletion packages/fdr-sdk/src/navigation/NodeCollector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { EMPTY_ARRAY } from "@fern-api/ui-core-utils";
import { once } from "es-toolkit/function";
import { FernNavigation } from "./..";
import { pruneVersionNode } from "./utils/pruneVersionNode";
import { NavigationNodeWithMetadata } from "./versions";

interface NavigationNodeWithMetadataAndParents {
node: FernNavigation.NavigationNodeWithMetadata;
Expand Down Expand Up @@ -134,7 +135,6 @@ export class NodeCollector {
this.#setNode(node.slug, node, parents);
} else {
if (FernNavigation.isPage(existing.node)) {
// eslint-disable-next-line no-console
console.warn(`Duplicate slug found: ${node.slug}`, node.title);
}
this.orphanedNodes.push(node);
Expand Down Expand Up @@ -236,6 +236,29 @@ export class NodeCollector {
return this.#getIndexablePageSlugs();
}

#getIndexablePageNodesWithAuth = once((): NavigationNodeWithMetadata[] => {
const slugRecord: Record<string, NavigationNodeWithMetadata> = {};

[...this.slugToNode.values()]
.filter(({ node }) => FernNavigation.isPage(node))
.filter(({ node }) => !node.hidden)
.filter(({ node }) =>
FernNavigation.hasMarkdown(node) ? !node.noindex : true
)
.forEach((node) => {
const canonicalSlug = node.node.canonicalSlug ?? node.node.slug;
// Only keep the first node we see for each canonical slug
if (!(canonicalSlug in slugRecord)) {
slugRecord[canonicalSlug] = node.node;
}
});

return Object.values(slugRecord);
});
get indexablePageNodesWithAuth(): NavigationNodeWithMetadata[] {
return this.#getIndexablePageNodesWithAuth();
}

public getVersionNodes = (): FernNavigation.VersionNode[] => {
return this.versionNodes;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export const CopyToClipboardButton: React.FC<CopyToClipboardButton.Props> = ({
copyToClipboard?.();
}) ?? (
<FernButton
className={cn("fern-copy-button group", className)}
className={cn("fern-copy-button group backdrop-blur", className)}
disabled={copyToClipboard == null}
onClickCapture={(e) => {
onClick?.(e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
exports[`CopyToClipboardButton > renders correctly 1`] = `
<button
aria-disabled={false}
className="fern-copy-button group fern-button minimal normal rounded square"
className="fern-copy-button group backdrop-blur fern-button minimal normal rounded square"
data-state="closed"
data-testid="copy-btn"
onBlur={[Function]}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {
RootNode,
getPageId,
hasMarkdown,
isPage,
} from "@fern-api/fdr-sdk/navigation";
import { flatten } from "es-toolkit/array";
import { FernTurbopufferRecordWithoutVector } from "../types";
Expand Down Expand Up @@ -35,12 +34,7 @@ export async function createTurbopufferRecords({
> {
const collector = NodeCollector.collect(root);

const pageNodes = Array.from(collector.slugMap.values())
.filter(isPage)
// exclude hidden pages
.filter((node) => node.hidden !== true)
// exclude pages that are noindexed
.filter((node) => (hasMarkdown(node) ? node.noindex !== true : true));
const pageNodes = collector.indexablePageNodesWithAuth;

const markdownNodes = pageNodes.filter(hasMarkdown);
// const apiLeafNodes = pageNodes.filter(isApiLeaf);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ export const CodeBlockWithClipboardButton: React.FC<
<CopyToClipboardButton
className={cn(
"absolute z-20",
"z-10 opacity-0 transition group-hover/cb-container:opacity-100",
"right-1 top-1"
"z-10 opacity-0 backdrop-blur transition group-hover/cb-container:opacity-100",
"right-3 top-2"
)}
content={code}
/>
Expand Down
2 changes: 1 addition & 1 deletion packages/fern-docs/ui/src/search/SearchV2.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export function SearchV2(): ReactElement | false {

// Rerouting to ferndocs.com for production environments to ensure streaming works
// Also see: next.config.mjs, where we set CORS headers
if (process.env.NODE_ENV === "production") {
if (process.env.NEXT_PUBLIC_VERCEL_ENV === "production") {
chatEndpoint = `https://app.ferndocs.com/api/fern-docs/search/v2/chat`;
suggestEndpoint = `https://app.ferndocs.com/api/fern-docs/search/v2/suggest`;
}
Expand Down
1 change: 1 addition & 0 deletions packages/parsers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"dependencies": {
"@fern-api/logger": "0.4.24-rc1",
"@fern-api/ui-core-utils": "workspace:*",
"@open-rpc/meta-schema": "^1.14.9",
"es-toolkit": "^1.24.0",
"openapi-types": "^12.1.3",
"ts-essentials": "^10.0.1",
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createMockContext } from "../../../../__test__/createMockContext.util";
import { createMockContext } from "../../../__test__/createMockContext.util";
import { HeaderSecuritySchemeConverterNode } from "../HeaderSecuritySchemeConverter.node";

describe("HeaderSecuritySchemeConverterNode", () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { OpenAPIV3_1 } from "openapi-types";
import { createMockContext } from "../../../../__test__/createMockContext.util";
import { createMockContext } from "../../../__test__/createMockContext.util";
import { OAuth2SecuritySchemeConverterNode } from "../OAuth2SecuritySchemeConverter.node";

describe("OAuth2SecuritySchemeConverterNode", () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { OpenAPIV3_1 } from "openapi-types";
import { createMockContext } from "../../../../__test__/createMockContext.util";
import { createMockContext } from "../../../__test__/createMockContext.util";
import { SecurityRequirementObjectConverterNode } from "../SecurityRequirementObjectConverter.node";

describe("SecurityRequirementObjectConverterNode", () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { OpenAPIV3_1 } from "openapi-types";
import { createMockContext } from "../../../../__test__/createMockContext.util";
import { createMockContext } from "../../../__test__/createMockContext.util";
import { SecuritySchemeConverterNode } from "../SecuritySchemeConverter.node";

describe("SecuritySchemeConverterNode", () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { OpenAPIV3_1 } from "openapi-types";
import { createMockContext } from "../../../../__test__/createMockContext.util";
import { FernRegistry } from "../../../../client/generated";
import { createMockContext } from "../../../__test__/createMockContext.util";
import {
Availability,
AvailabilityConverterNode,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { OpenAPIV3_1 } from "openapi-types";
import { createMockContext } from "../../../../__test__/createMockContext.util";
import { createMockContext } from "../../../__test__/createMockContext.util";
import { XFernBasePathConverterNode } from "../XFernBasePathConverter.node";
import { X_FERN_BASE_PATH } from "../fernExtension.consts";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { createMockContext } from "../../../../__test__/createMockContext.util";
import { FernRegistry } from "../../../../client/generated";
import { createMockContext } from "../../../__test__/createMockContext.util";
import { BaseOpenApiV3_1ConverterNodeConstructorArgs } from "../../../BaseOpenApiV3_1Converter.node";
import {
RequestMediaTypeObjectConverterNode,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createMockContext } from "../../../../__test__/createMockContext.util";
import { createMockContext } from "../../../__test__/createMockContext.util";
import { XFernGroupNameConverterNode } from "../XFernGroupNameConverter.node";

describe("XFernGroupNameConverterNode", () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { createMockContext } from "../../../../__test__/createMockContext.util";
import { createMockContext } from "../../../__test__/createMockContext.util";
import { BaseOpenApiV3_1ConverterNodeConstructorArgs } from "../../../BaseOpenApiV3_1Converter.node";
import { XFernSdkMethodNameConverterNode } from "../XFernSdkMethodNameConverter.node";
import { X_FERN_SDK_METHOD_NAME } from "../fernExtension.consts";
import { XFernSdkMethodNameConverterNode } from "../XFernSdkMethodNameConverter.node";

describe("XFernSdkMethodNameConverterNode", () => {
const mockContext = createMockContext();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { createMockContext } from "../../../../__test__/createMockContext.util";
import { createMockContext } from "../../../__test__/createMockContext.util";
import { BaseOpenApiV3_1ConverterNodeConstructorArgs } from "../../../BaseOpenApiV3_1Converter.node";
import { XFernServerNameConverterNode } from "../XFernServerNameConverter.node";
import { X_FERN_SERVER_NAME } from "../fernExtension.consts";
import { XFernServerNameConverterNode } from "../XFernServerNameConverter.node";

describe("XFernServerNameConverterNode", () => {
const mockContext = createMockContext();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createMockContext } from "../../../../../__test__/createMockContext.util";
import { createMockContext } from "../../../../__test__/createMockContext.util";
import { XFernAccessTokenLocatorConverterNode } from "../../auth/XFernAccessTokenLocatorConverter.node";

describe("XFernAccessTokenLocatorConverterNode", () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createMockContext } from "../../../../../__test__/createMockContext.util";
import { createMockContext } from "../../../../__test__/createMockContext.util";
import { XFernBasicAuthNode } from "../../auth/XFernBasicAuth.node";
import { TokenSecurityScheme } from "../../auth/types/TokenSecurityScheme";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createMockContext } from "../../../../../__test__/createMockContext.util";
import { createMockContext } from "../../../../__test__/createMockContext.util";
import { XFernBasicPasswordVariableNameConverterNode } from "../../auth/XFernBasicPasswordVariableNameConverter.node";

describe("XFernBasicPasswordVariableNameConverterNode", () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createMockContext } from "../../../../../__test__/createMockContext.util";
import { createMockContext } from "../../../../__test__/createMockContext.util";
import { XFernBasicUsernameVariableNameConverterNode } from "../../auth/XFernBasicUsernameVariableNameConverter.node";

describe("XFernBasicUsernameVariableNameConverterNode", () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createMockContext } from "../../../../../__test__/createMockContext.util";
import { createMockContext } from "../../../../__test__/createMockContext.util";
import { XBearerFormatConverterNode } from "../../auth/XBearerFormatConverter.node";

describe("XBearerFormatConverterNode", () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createMockContext } from "../../../../../__test__/createMockContext.util";
import { createMockContext } from "../../../../__test__/createMockContext.util";
import { XFernBearerTokenConverterNode } from "../../auth/XFernBearerTokenConverter.node";
import { TokenSecurityScheme } from "../../auth/types/TokenSecurityScheme";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createMockContext } from "../../../../../__test__/createMockContext.util";
import { createMockContext } from "../../../../__test__/createMockContext.util";
import { XFernBearerTokenVariableNameConverterNode } from "../../auth/XFernBearerTokenVariableNameConverter.node";

describe("XFernBearerTokenVariableNameConverterNode", () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createMockContext } from "../../../../../__test__/createMockContext.util";
import { createMockContext } from "../../../../__test__/createMockContext.util";
import { XFernHeaderAuthConverterNode } from "../../auth/XFernHeaderAuthConverter.node";
import { HeaderTokenSecurityScheme } from "../../auth/types/TokenSecurityScheme";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createMockContext } from "../../../../../__test__/createMockContext.util";
import { createMockContext } from "../../../../__test__/createMockContext.util";
import { XFernHeaderVariableNameConverterNode } from "../../auth/XFernHeaderVariableNameConverter.node";

describe("XFernHeaderVariableNameConverterNode", () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createMockContext } from "../../../../../__test__/createMockContext.util";
import { createMockContext } from "../../../../__test__/createMockContext.util";
import { BaseOpenApiV3_1ConverterNodeConstructorArgs } from "../../../../BaseOpenApiV3_1Converter.node";
import { RedocExampleConverterNode } from "../../examples/RedocExampleConverter.node";
import {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createMockContext } from "../../../../__test__/createMockContext.util";
import { createMockContext } from "../../../__test__/createMockContext.util";
import { ExampleObjectConverterNode } from "../ExampleObjectConverter.node";
import { RequestMediaTypeObjectConverterNode } from "../request/RequestMediaTypeObjectConverter.node";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { OpenAPIV3_1 } from "openapi-types";
import { createMockContext } from "../../../../__test__/createMockContext.util";
import { FernRegistry } from "../../../../client/generated";
import { createMockContext } from "../../../__test__/createMockContext.util";
import { OperationObjectConverterNode } from "../OperationObjectConverter.node";

describe("OperationObjectConverterNode", () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { OpenAPIV3_1 } from "openapi-types";
import { createMockContext } from "../../../../__test__/createMockContext.util";
import { createMockContext } from "../../../__test__/createMockContext.util";
import { PathItemObjectConverterNode } from "../PathItemObjectConverter.node";

describe("PathItemObjectConverterNode", () => {
Expand Down
Loading

0 comments on commit 028e77e

Please sign in to comment.