Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: set basic jwt authentication allowlist #1596

Merged
merged 28 commits into from
Oct 7, 2024
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/commons/search-utils/src/getSlugForSearchRecord.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ function createSearchPlaceholder(sidebar: FernNavigation.SidebarRootNode | undef

function checkHasGuides(sidebar: FernNavigation.SidebarRootNode): boolean {
let hasGuides = false;
FernNavigation.traverseNavigation(sidebar, (node) => {
FernNavigation.traverseBF(sidebar, (node) => {
if (node.type === "page") {
hasGuides = true;
return false;
Expand All @@ -113,7 +113,7 @@ function checkHasGuides(sidebar: FernNavigation.SidebarRootNode): boolean {

function checkHasEndpoints(sidebar: FernNavigation.SidebarRootNode): boolean {
let hasEndpoints = false;
FernNavigation.traverseNavigation(sidebar, (node) => {
FernNavigation.traverseBF(sidebar, (node) => {
if (node.type === "apiReference") {
hasEndpoints = true;
return false;
Expand Down
2 changes: 2 additions & 0 deletions packages/fdr-sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
},
"dependencies": {
"@fern-ui/core-utils": "workspace:*",
"@ungap/structured-clone": "^1.2.0",
"dayjs": "^1.11.11",
"fast-deep-equal": "^3.1.3",
"form-data": "4.0.0",
Expand All @@ -57,6 +58,7 @@
"@types/qs": "6.9.14",
"@types/tinycolor2": "^1.4.6",
"@types/title": "^3.4.3",
"@types/ungap__structured-clone": "^1.2.0",
"eslint": "^8.56.0",
"prettier": "^3.3.2",
"typescript": "5.4.3",
Expand Down
17 changes: 9 additions & 8 deletions packages/fdr-sdk/src/navigation/NodeCollector.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { EMPTY_ARRAY } from "@fern-ui/core-utils";
import { once } from "../utils";
import { FernNavigation } from "./..";
import { pruneVersionNode } from "./utils/pruneVersionNode";

interface NavigationNodeWithMetadataAndParents {
node: FernNavigation.NavigationNodeWithMetadata;
parents: FernNavigation.NavigationNode[];
parents: readonly FernNavigation.NavigationNodeParent[];
next: FernNavigation.NavigationNodeNeighbor | undefined;
prev: FernNavigation.NavigationNodeNeighbor | undefined;
}
Expand All @@ -14,7 +15,7 @@ const NodeCollectorInstances = new WeakMap<FernNavigation.NavigationNode, NodeCo
export class NodeCollector {
private static readonly EMPTY = new NodeCollector(undefined);
private idToNode = new Map<FernNavigation.NodeId, FernNavigation.NavigationNode>();
private idToNodeParents = new Map<FernNavigation.NodeId, FernNavigation.NavigationNode[]>();
private idToNodeParents = new Map<FernNavigation.NodeId, readonly FernNavigation.NavigationNodeParent[]>();
private slugToNode = new Map<FernNavigation.Slug, NavigationNodeWithMetadataAndParents>();
private orphanedNodes: FernNavigation.NavigationNodeWithMetadata[] = [];

Expand All @@ -36,7 +37,7 @@ export class NodeCollector {
#setNode(
slug: FernNavigation.Slug,
node: FernNavigation.NavigationNodeWithMetadata,
parents: FernNavigation.NavigationNode[],
parents: readonly FernNavigation.NavigationNodeParent[],
) {
const toSet = { node, parents, prev: this.#lastNeighboringNode, next: undefined };
this.slugToNode.set(slug, toSet);
Expand All @@ -56,7 +57,7 @@ export class NodeCollector {
if (rootNode == null) {
return;
}
FernNavigation.traverseNavigation(rootNode, (node, _index, parents) => {
FernNavigation.traverseDF(rootNode, (node, parents) => {
// if the node is the default version, make a copy of it and "prune" the version slug from all children nodes
if (node.type === "version") {
this.versionNodes.push(node);
Expand All @@ -65,7 +66,7 @@ export class NodeCollector {
if (node.type === "version" && node.default && rootNode.type === "root") {
const copy = JSON.parse(JSON.stringify(node)) as FernNavigation.VersionNode;
this.defaultVersion = pruneVersionNode(copy, rootNode.slug, node.slug);
FernNavigation.traverseNavigation(this.defaultVersion, (node, _index, innerParents) => {
FernNavigation.traverseDF(this.defaultVersion, (node, innerParents) => {
this.visitNode(node, [...parents, ...innerParents], true);
});
}
Expand All @@ -76,7 +77,7 @@ export class NodeCollector {

private visitNode(
node: FernNavigation.NavigationNode,
parents: FernNavigation.NavigationNode[],
parents: readonly FernNavigation.NavigationNodeParent[],
isDefaultVersion = false,
): void {
if (!this.idToNode.has(node.id) || isDefaultVersion) {
Expand Down Expand Up @@ -137,8 +138,8 @@ export class NodeCollector {
return this.idToNode.get(id);
}

public getParents(id: FernNavigation.NodeId): FernNavigation.NavigationNode[] {
return this.idToNodeParents.get(id) ?? [];
public getParents(id: FernNavigation.NodeId): readonly FernNavigation.NavigationNodeParent[] {
return this.idToNodeParents.get(id) ?? EMPTY_ARRAY;
}

public getSlugMapWithParents = (): ReadonlyMap<FernNavigation.Slug, NavigationNodeWithMetadataAndParents> => {
Expand Down
Loading
Loading