Skip to content

Commit

Permalink
Add ChangelogV3 to fdr-sdk (#1059)
Browse files Browse the repository at this point in the history
  • Loading branch information
abvthecity authored Jun 21, 2024
1 parent 2f707e9 commit bf08716
Show file tree
Hide file tree
Showing 48 changed files with 400 additions and 236 deletions.
3 changes: 3 additions & 0 deletions fern/apis/fdr/definition/docs/v1/db/__package__.yml
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ types:
group: NavigationTabGroup
link: docsReadV1.NavigationTabLink
changelog: docsReadV1.ChangelogSection
changelogV3: docsReadV1.ChangelogSectionV3

NavigationTabGroup:
properties:
Expand Down Expand Up @@ -166,8 +167,10 @@ types:
section: DocsSection
link: docsReadV1.LinkMetadata
changelog: docsReadV1.ChangelogSection
changelogV3: docsReadV1.ChangelogSectionV3

ApiSection:
availability: deprecated
properties:
title: string
icon: optional<string>
Expand Down
29 changes: 10 additions & 19 deletions fern/apis/fdr/definition/docs/v1/read/__package__.yml
Original file line number Diff line number Diff line change
Expand Up @@ -171,26 +171,11 @@ types:
tabs: list<NavigationTab>

NavigationTab:
discriminated: false
union:
- NavigationTabGroupV1
- NavigationTabLinkV1
- ChangelogSectionV1

NavigationTabGroupV1:
extends: NavigationTabGroup
properties:
type: optional<literal<"group">>

NavigationTabLinkV1:
extends: NavigationTabLink
properties:
type: literal<"link">

ChangelogSectionV1:
extends: ChangelogSection
properties:
type: literal<"changelog">
group: NavigationTabGroup
link: NavigationTabLink
changelog: ChangelogSection
changelogV3: ChangelogSectionV3

NavigationTabGroup:
extends: NavigationNodeMetadata
Expand Down Expand Up @@ -273,6 +258,7 @@ types:
section: DocsSection
link: LinkMetadata
changelog: ChangelogSection
changelogV3: ChangelogSectionV3

PageMetadata:
extends: NavigationNodeMetadata
Expand All @@ -294,6 +280,7 @@ types:
url: string

ApiSection:
availability: deprecated
extends: NavigationNodeMetadata
properties:
title: string
Expand Down Expand Up @@ -342,6 +329,10 @@ types:
pageId: optional<commons.PageId>
items: list<ChangelogItem>

ChangelogSectionV3:
properties:
node: navigation.ChangelogNode

ChangelogItem:
properties:
date: date
Expand Down
7 changes: 7 additions & 0 deletions fern/apis/fdr/definition/docs/v1/write/__package__.yml
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ types:
group: NavigationTabGroup
link: NavigationTabLink
changelog: ChangelogSectionV2
changelogV3: ChangelogSectionV3

NavigationTabGroup:
extends: NavigationNodeMetadata
Expand Down Expand Up @@ -257,6 +258,7 @@ types:
section: DocsSection
link: LinkMetadata
changelog: ChangelogSectionV2
changelogV3: ChangelogSectionV3

PageMetadata:
extends: NavigationNodeMetadata
Expand Down Expand Up @@ -286,6 +288,7 @@ types:
url: string

ApiSection:
availability: deprecated
extends: NavigationNodeMetadata
properties:
title: string
Expand Down Expand Up @@ -357,6 +360,10 @@ types:
pageId: optional<string>
items: list<ChangelogItem>

ChangelogSectionV3:
properties:
node: navigation.ChangelogNode

ChangelogItem:
properties:
date: date
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ export type NavigationItem =
| FernRegistry.docs.v1.db.NavigationItem.ApiV2
| FernRegistry.docs.v1.db.NavigationItem.Section
| FernRegistry.docs.v1.db.NavigationItem.Link
| FernRegistry.docs.v1.db.NavigationItem.Changelog;
| FernRegistry.docs.v1.db.NavigationItem.Changelog
| FernRegistry.docs.v1.db.NavigationItem.ChangelogV3;

export declare namespace NavigationItem {
interface Page extends FernRegistry.docs.v1.read.PageMetadata {
Expand All @@ -36,4 +37,8 @@ export declare namespace NavigationItem {
interface Changelog extends FernRegistry.docs.v1.read.ChangelogSection {
type: "changelog";
}

interface ChangelogV3 extends FernRegistry.docs.v1.read.ChangelogSectionV3 {
type: "changelogV3";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import * as FernRegistry from "../../../../../../../index";
export type NavigationTabV2 =
| FernRegistry.docs.v1.db.NavigationTabV2.Group
| FernRegistry.docs.v1.db.NavigationTabV2.Link
| FernRegistry.docs.v1.db.NavigationTabV2.Changelog;
| FernRegistry.docs.v1.db.NavigationTabV2.Changelog
| FernRegistry.docs.v1.db.NavigationTabV2.ChangelogV3;

export declare namespace NavigationTabV2 {
interface Group extends FernRegistry.docs.v1.db.NavigationTabGroup {
Expand All @@ -21,4 +22,8 @@ export declare namespace NavigationTabV2 {
interface Changelog extends FernRegistry.docs.v1.read.ChangelogSection {
type: "changelog";
}

interface ChangelogV3 extends FernRegistry.docs.v1.read.ChangelogSectionV3 {
type: "changelogV3";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@

import * as FernRegistry from "../../../../../../../index";

export interface NavigationTabLinkV1 extends FernRegistry.docs.v1.read.NavigationTabLink {
type: "link";
export interface ChangelogSectionV3 {
node: FernRegistry.navigation.ChangelogNode;
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ export type NavigationItem =
| FernRegistry.docs.v1.read.NavigationItem.ApiV2
| FernRegistry.docs.v1.read.NavigationItem.Section
| FernRegistry.docs.v1.read.NavigationItem.Link
| FernRegistry.docs.v1.read.NavigationItem.Changelog;
| FernRegistry.docs.v1.read.NavigationItem.Changelog
| FernRegistry.docs.v1.read.NavigationItem.ChangelogV3;

export declare namespace NavigationItem {
interface Page extends FernRegistry.docs.v1.read.PageMetadata {
Expand All @@ -36,4 +37,8 @@ export declare namespace NavigationItem {
interface Changelog extends FernRegistry.docs.v1.read.ChangelogSection {
type: "changelog";
}

interface ChangelogV3 extends FernRegistry.docs.v1.read.ChangelogSectionV3 {
type: "changelogV3";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,25 @@
import * as FernRegistry from "../../../../../../../index";

export type NavigationTab =
| FernRegistry.docs.v1.read.NavigationTabGroupV1
| FernRegistry.docs.v1.read.NavigationTabLinkV1
| FernRegistry.docs.v1.read.ChangelogSectionV1;
| FernRegistry.docs.v1.read.NavigationTab.Group
| FernRegistry.docs.v1.read.NavigationTab.Link
| FernRegistry.docs.v1.read.NavigationTab.Changelog
| FernRegistry.docs.v1.read.NavigationTab.ChangelogV3;

export declare namespace NavigationTab {
interface Group extends FernRegistry.docs.v1.read.NavigationTabGroup {
type: "group";
}

interface Link extends FernRegistry.docs.v1.read.NavigationTabLink {
type: "link";
}

interface Changelog extends FernRegistry.docs.v1.read.ChangelogSection {
type: "changelog";
}

interface ChangelogV3 extends FernRegistry.docs.v1.read.ChangelogSectionV3 {
type: "changelogV3";
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ export * from "./NavigationConfig";
export * from "./UnversionedNavigationConfig";
export * from "./UnversionedTabbedNavigationConfig";
export * from "./NavigationTab";
export * from "./NavigationTabGroupV1";
export * from "./NavigationTabLinkV1";
export * from "./ChangelogSectionV1";
export * from "./NavigationTabGroup";
export * from "./NavigationTabLink";
export * from "./UnversionedUntabbedNavigationConfig";
Expand All @@ -39,6 +36,7 @@ export * from "./ApiNavigationConfigRoot";
export * from "./ApiNavigationConfigItem";
export * from "./ApiNavigationConfigSubpackage";
export * from "./ChangelogSection";
export * from "./ChangelogSectionV3";
export * from "./ChangelogItem";
export * from "./DocsSection";
export * from "./ApiArtifacts";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@

import * as FernRegistry from "../../../../../../../index";

export interface ChangelogSectionV1 extends FernRegistry.docs.v1.read.ChangelogSection {
type: "changelog";
export interface ChangelogSectionV3 {
node: FernRegistry.navigation.ChangelogNode;
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ export type NavigationItem =
| FernRegistry.docs.v1.write.NavigationItem.ApiV2
| FernRegistry.docs.v1.write.NavigationItem.Section
| FernRegistry.docs.v1.write.NavigationItem.Link
| FernRegistry.docs.v1.write.NavigationItem.Changelog;
| FernRegistry.docs.v1.write.NavigationItem.Changelog
| FernRegistry.docs.v1.write.NavigationItem.ChangelogV3;

export declare namespace NavigationItem {
interface Page extends FernRegistry.docs.v1.write.PageMetadata {
Expand All @@ -36,4 +37,8 @@ export declare namespace NavigationItem {
interface Changelog extends FernRegistry.docs.v1.write.ChangelogSectionV2 {
type: "changelog";
}

interface ChangelogV3 extends FernRegistry.docs.v1.write.ChangelogSectionV3 {
type: "changelogV3";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import * as FernRegistry from "../../../../../../../index";
export type NavigationTabV2 =
| FernRegistry.docs.v1.write.NavigationTabV2.Group
| FernRegistry.docs.v1.write.NavigationTabV2.Link
| FernRegistry.docs.v1.write.NavigationTabV2.Changelog;
| FernRegistry.docs.v1.write.NavigationTabV2.Changelog
| FernRegistry.docs.v1.write.NavigationTabV2.ChangelogV3;

export declare namespace NavigationTabV2 {
interface Group extends FernRegistry.docs.v1.write.NavigationTabGroup {
Expand All @@ -21,4 +22,8 @@ export declare namespace NavigationTabV2 {
interface Changelog extends FernRegistry.docs.v1.write.ChangelogSectionV2 {
type: "changelog";
}

interface ChangelogV3 extends FernRegistry.docs.v1.write.ChangelogSectionV3 {
type: "changelogV3";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export * from "./ApiNavigationConfigItem";
export * from "./ApiNavigationConfigSubpackage";
export * from "./ChangelogSection";
export * from "./ChangelogSectionV2";
export * from "./ChangelogSectionV3";
export * from "./ChangelogItem";
export * from "./DocsSection";
export * from "./ApiArtifacts";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,9 @@ function transformNavigationTabV2ForDb(writeShape: DocsV1Write.NavigationTabV2):
case "changelog": {
return { type: "changelog", ...toChangelogDb(writeShape) };
}
case "changelogV3": {
return writeShape;
}
}
}

Expand Down Expand Up @@ -259,6 +262,8 @@ export function transformNavigationItemForDb(
return { type: "changelog", ...toChangelogDb(writeShape) };
case "apiV2":
return writeShape;
case "changelogV3":
return writeShape;
default:
assertNever(writeShape);
}
Expand Down Expand Up @@ -315,6 +320,8 @@ function getReferencedApiDefinitionIdFromItem(item: DocsV1Db.NavigationItem): Fd
return [];
case "apiV2":
return [item.node.apiDefinitionId];
case "changelogV3":
return [];
default:
assertNever(item);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ export function transformNavigationTabV2ForDb(dbShape: DocsV1Db.NavigationTabV2)
fullSlug: undefined,
};
case "changelog":
case "changelogV3":
return dbShape;
default:
assertNever(dbShape);
Expand All @@ -180,17 +181,16 @@ export function transformNavigationItemForDb(dbShape: DocsV1Db.NavigationItem):
...dbShape,
showErrors: dbShape.showErrors ?? false,
};
case "page":
case "link":
return dbShape;
case "section":
return {
...dbShape,
items: dbShape.items.map((item) => transformNavigationItemForDb(item)),
};
case "page":
case "link":
case "changelog":
return dbShape;
case "apiV2":
case "changelogV3":
return dbShape;
default:
assertNever(dbShape);
Expand Down
4 changes: 3 additions & 1 deletion packages/fdr-sdk/src/navigation/NodeCollector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,11 @@ export class NodeCollector {
this.#lastNeighboringNode = undefined;
}

if (!hasMetadata(node)) {
// there's currently no visitable page for changelog months and years
if (!hasMetadata(node) || node.type === "changelogMonth" || node.type === "changelogYear") {
return;
}

const existing = this.slugToNode[node.slug];
if (existing == null) {
this.#setNode(node.slug, node, parents);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,7 @@
"docs/api/platform-api-reference/workspace/update-workspace",
"docs/api/platform-api-reference/workspace/delete-workspace",
"docs/api/platform-api-reference/changelog",
"docs/api/platform-api-reference/changelog/2024",
"docs/api/platform-api-reference/changelog/2024/5",
"docs/api/platform-api-reference/changelog/2024/5/15",
"docs/api/platform-api-reference/changelog/2024/4",
"docs/api/platform-api-reference/changelog/2024/4/23",
"docs/api/platform-api-reference/changelog/2024/4/12",
"docs/api/iam-api-reference",
Expand Down Expand Up @@ -82,7 +79,5 @@
"docs/api/iam-api-reference/user/get-user",
"docs/api/iam-api-reference/user/update-user-roles",
"docs/api/iam-api-reference/changelog",
"docs/api/iam-api-reference/changelog/2024",
"docs/api/iam-api-reference/changelog/2024/4",
"docs/api/iam-api-reference/changelog/2024/4/12"
]
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,7 @@
"docs/api/platform-api-reference/workspace/update-workspace",
"docs/api/platform-api-reference/workspace/delete-workspace",
"docs/api/platform-api-reference/changelog",
"docs/api/platform-api-reference/changelog/2024",
"docs/api/platform-api-reference/changelog/2024/5",
"docs/api/platform-api-reference/changelog/2024/5/15",
"docs/api/platform-api-reference/changelog/2024/4",
"docs/api/platform-api-reference/changelog/2024/4/23",
"docs/api/platform-api-reference/changelog/2024/4/12",
"docs/api/iam-api-reference/authorization/list-permission-groups",
Expand Down Expand Up @@ -66,7 +63,5 @@
"docs/api/iam-api-reference/user/get-user",
"docs/api/iam-api-reference/user/update-user-roles",
"docs/api/iam-api-reference/changelog",
"docs/api/iam-api-reference/changelog/2024",
"docs/api/iam-api-reference/changelog/2024/4",
"docs/api/iam-api-reference/changelog/2024/4/12"
]
Loading

0 comments on commit bf08716

Please sign in to comment.