Skip to content

Commit

Permalink
Merge branch 'main' into dd/getDocsForUrl-lambda
Browse files Browse the repository at this point in the history
  • Loading branch information
dubwub authored Jan 14, 2025
2 parents 358a0e4 + ce8d1f9 commit 0e0fc65
Show file tree
Hide file tree
Showing 115 changed files with 7,737 additions and 429 deletions.
44 changes: 44 additions & 0 deletions .github/workflows/publish-parsers-package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Publish Parsers Package

on:
push:
branches:
- main
paths:
- 'packages/parsers/package.json'

jobs:
check-and-publish:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 2 # This helps turbo resolve changes faster

- name: Install
uses: ./.github/actions/install

- name: Check package.json changes
id: check-version
run: |
CHANGED=$(git diff HEAD^ HEAD -- packages/parsers/package.json | grep '"version":' || true)
if [ ! -z "$CHANGED" ]; then
echo "version_changed=true" >> $GITHUB_OUTPUT
else
echo "version_changed=false" >> $GITHUB_OUTPUT
fi
- name: Install dependencies
if: steps.check-version.outputs.version_changed == 'true'
run: pnpm install

- name: Compile package
if: steps.check-version.outputs.version_changed == 'true'
run: pnpm --filter @fern-api/docs-parsers compile

- name: Publish to npm
if: steps.check-version.outputs.version_changed == 'true'
run: |
echo "//registry.npmjs.org/:_authToken=${{ secrets.FERN_NPM_TOKEN }}" > ~/.npmrc
pnpm --filter @fern-api/docs-parsers publish --no-git-checks --access public
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
2 changes: 1 addition & 1 deletion packages/parsers/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@fern-api/docs-parsers",
"version": "0.0.25",
"version": "0.0.34",
"repository": {
"type": "git",
"url": "https://github.com/fern-api/fern-platform.git",
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.

1 change: 1 addition & 0 deletions packages/parsers/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export * from "./ErrorCollector";
export * from "./openapi";
export * from "./openrpc";
12 changes: 10 additions & 2 deletions packages/parsers/src/openapi/3.1/OpenApiDocumentConverter.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
import { coalesceServers } from "../utils/3.1/coalesceServers";
import { SecurityRequirementObjectConverterNode } from "./auth/SecurityRequirementObjectConverter.node";
import { XFernBasePathConverterNode } from "./extensions/XFernBasePathConverter.node";
import { XFernGlobalHeadersConverterNode } from "./extensions/XFernGlobalHeadersConverter.node";
import { XFernGroupsConverterNode } from "./extensions/XFernGroupsConverter.node";
import { PathsObjectConverterNode } from "./paths/PathsObjectConverter.node";
import { ServerObjectConverterNode } from "./paths/ServerObjectConverter.node";
Expand All @@ -29,6 +30,7 @@ export class OpenApiDocumentConverterNode extends BaseOpenApiV3_1ConverterNode<
basePath: XFernBasePathConverterNode | undefined;
fernGroups: XFernGroupsConverterNode | undefined;
tags: TagObjectConverterNode[] | undefined;
globalHeaders: XFernGlobalHeadersConverterNode | undefined;

constructor(
args: BaseOpenApiV3_1ConverterNodeConstructorArgs<OpenAPIV3_1.Document>
Expand Down Expand Up @@ -128,6 +130,13 @@ export class OpenApiDocumentConverterNode extends BaseOpenApiV3_1ConverterNode<
pathId: "components",
});
}

this.globalHeaders = new XFernGlobalHeadersConverterNode({
input: this.input,
context: this.context,
accessPath: this.accessPath,
pathId: "x-fern-global-headers",
});
}

convert(): FernRegistry.api.latest.ApiDefinition | undefined {
Expand Down Expand Up @@ -188,8 +197,7 @@ export class OpenApiDocumentConverterNode extends BaseOpenApiV3_1ConverterNode<
// This is not necessary and will be removed
subpackages,
auths: this.auth?.convert() ?? {},
// TODO: Implement globalHeaders
globalHeaders: undefined,
globalHeaders: this.globalHeaders?.convert(),
};
}
}
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
Loading

0 comments on commit 0e0fc65

Please sign in to comment.