Skip to content

Commit

Permalink
Merge branch 'main' into revert-1632-revert-1608-ajiang/api-definitio…
Browse files Browse the repository at this point in the history
…n-migrate-2
  • Loading branch information
abvthecity committed Oct 10, 2024
2 parents 478d82c + b5ee8b9 commit b58adc0
Show file tree
Hide file tree
Showing 61 changed files with 805 additions and 180 deletions.
2 changes: 2 additions & 0 deletions fern/apis/fdr/definition/commons.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ types:

PropertyKey: string

AudienceId: string

EndpointIdentifier:
properties:
path: EndpointPathLiteral
Expand Down
16 changes: 15 additions & 1 deletion fern/apis/fdr/definition/navigation/latest/__package__.yml
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,21 @@ types:
type: optional<Slug>
docs: The slug that should be used in the canonical URL rel. If not provided, the `slug` will be used.
icon: optional<string>
hidden: optional<boolean>
hidden:
type: optional<boolean>
docs: If true, this node will not be displayed in the sidebar, and noindex will be considered true.
authed:
type: optional<boolean>
docs: |
If true, this node is only visible to authenticated users.
If false, this node is only visible to all users (including anonymous).
audience:
type: optional<list<commons.AudienceId>>
availability: in-development
docs: |
The audience(s) that this node is intended for. If not provided, the node is intended for all audiences.
If provided, the node is only intended for the specified audience(s). OR logic is used for multiple audiences on a single node.
AND logic is used when evaluating audiences up the tree.
WithPage:
properties:
Expand Down
1 change: 1 addition & 0 deletions fern/apis/fdr/generators.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ groups:
config:
useBrandedStringAliases: true
noSerdeLayer: true
noOptionalProperties: true
outputSourceFiles: true
neverThrowErrors: true
timeoutInSeconds: infinity
Expand Down
6 changes: 6 additions & 0 deletions packages/commons/fdr-utils/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ export interface VersionSwitcherInfo {
index: number;
availability: FernNavigation.Availability | undefined;
pointsTo: FernNavigation.Slug | undefined;
hidden: boolean | undefined;
authed: boolean | undefined;
}

interface SidebarTabGroup {
Expand All @@ -22,6 +24,8 @@ interface SidebarTabGroup {
index: number;
slug: FernNavigation.Slug;
pointsTo: FernNavigation.Slug | undefined;
hidden: boolean | undefined;
authed: boolean | undefined;
}

interface SidebarTabLink {
Expand All @@ -38,6 +42,8 @@ interface SidebarTabChangelog {
icon: string | undefined;
index: number;
slug: FernNavigation.Slug;
hidden: boolean | undefined;
authed: boolean | undefined;
}

export type SidebarTab = SidebarTabGroup | SidebarTabLink | SidebarTabChangelog;
2 changes: 2 additions & 0 deletions packages/fdr-sdk/src/__test__/__snapshots__/hume.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ exports[`hume > gets navigation root for /reference/expression-measurement-api/s

exports[`hume > gets navigation root for /support 1`] = `
{
"audience": undefined,
"authed": undefined,
"canonicalSlug": undefined,
"hidden": false,
"icon": undefined,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ exports[`no-version-no-tabs > gets navigation root for /docs 1`] = `

exports[`no-version-no-tabs > gets navigation root for /docs/api/page-6 1`] = `
{
"audience": undefined,
"authed": undefined,
"canonicalSlug": undefined,
"hidden": undefined,
"icon": undefined,
Expand All @@ -45,6 +47,8 @@ exports[`no-version-no-tabs > gets navigation root for /docs/api/section-1 1`] =

exports[`no-version-no-tabs > gets navigation root for /docs/api/section-2 1`] = `
{
"audience": undefined,
"authed": undefined,
"canonicalSlug": undefined,
"hidden": undefined,
"icon": undefined,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ exports[`no-version-yes-tabs > gets navigation root for /docs/api 1`] = `

exports[`no-version-yes-tabs > gets navigation root for /docs/api/page-2 1`] = `
{
"audience": undefined,
"authed": undefined,
"canonicalSlug": undefined,
"hidden": undefined,
"icon": undefined,
Expand All @@ -48,6 +50,8 @@ exports[`no-version-yes-tabs > gets navigation root for /docs/api/section-1 1`]

exports[`no-version-yes-tabs > gets navigation root for /docs/api/tab-1 1`] = `
{
"audience": undefined,
"authed": undefined,
"canonicalSlug": undefined,
"hidden": undefined,
"icon": undefined,
Expand All @@ -66,6 +70,8 @@ exports[`no-version-yes-tabs > gets navigation root for /docs/api/tab-1 3`] = `"

exports[`no-version-yes-tabs > gets navigation root for /docs/api/tab-2 1`] = `
{
"audience": undefined,
"authed": undefined,
"canonicalSlug": undefined,
"hidden": undefined,
"icon": undefined,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -861,6 +861,8 @@ exports[`polytomic > gets navigation root for /2023-04-25/not-found 1`] = `

exports[`polytomic > gets navigation root for /2024-02-08/guides/introduction 1`] = `
{
"audience": undefined,
"authed": undefined,
"canonicalSlug": undefined,
"hidden": false,
"icon": undefined,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,8 @@ exports[`primer > gets navigation root for /docs/api/introduction/getting-starte
exports[`primer > gets navigation root for /docs/api/v2.1/api-reference/client-session-api/retrieve-client-side-token 1`] = `
{
"apiDefinitionId": "7ed504c0-fc2e-4a52-b3fd-b277869eda14",
"audience": undefined,
"authed": undefined,
"availability": undefined,
"canonicalSlug": "docs/api/v2.3/api-reference/client-session-api/retrieve-client-side-token",
"endpointId": "subpackage_clientSessionApi.retrieveClientSideToken",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ exports[`uploadcare > gets navigation root for /docs/file-management 1`] = `

exports[`uploadcare > gets navigation root for /docs/file-management/overview 1`] = `
{
"audience": undefined,
"authed": undefined,
"canonicalSlug": undefined,
"hidden": undefined,
"icon": undefined,
Expand Down Expand Up @@ -118,6 +120,8 @@ exports[`uploadcare > gets navigation root for /docs/introduction 1`] = `

exports[`uploadcare > gets navigation root for /docs/introduction/intro 1`] = `
{
"audience": undefined,
"authed": undefined,
"canonicalSlug": undefined,
"hidden": undefined,
"icon": undefined,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ exports[`yes-version-no-tabs > gets navigation root for /docs/api/version-1 3`]

exports[`yes-version-no-tabs > gets navigation root for /docs/api/version-1/page-5 1`] = `
{
"audience": undefined,
"authed": undefined,
"canonicalSlug": undefined,
"hidden": undefined,
"icon": undefined,
Expand All @@ -92,6 +94,8 @@ exports[`yes-version-no-tabs > gets navigation root for /docs/api/version-1/sect

exports[`yes-version-no-tabs > gets navigation root for /docs/api/version-1/version-1 1`] = `
{
"audience": undefined,
"authed": undefined,
"canonicalSlug": undefined,
"hidden": undefined,
"icon": undefined,
Expand All @@ -117,6 +121,8 @@ exports[`yes-version-no-tabs > gets navigation root for /docs/api/version-2 1`]

exports[`yes-version-no-tabs > gets navigation root for /docs/api/version-2/version-1 1`] = `
{
"audience": undefined,
"authed": undefined,
"canonicalSlug": undefined,
"hidden": undefined,
"icon": undefined,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ exports[`yes-version-yes-tabs > gets navigation root for /docs/api/version-1 1`]

exports[`yes-version-yes-tabs > gets navigation root for /docs/api/version-1/section-2 1`] = `
{
"audience": undefined,
"authed": undefined,
"canonicalSlug": undefined,
"hidden": undefined,
"icon": undefined,
Expand Down
7 changes: 5 additions & 2 deletions packages/fdr-sdk/src/api-definition/unwrap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export type UnwrappedReference = {

export type UnwrappedObjectType = {
properties: Latest.ObjectProperty[];
extraProperties: Latest.TypeReference | undefined;
descriptions: FernDocs.MarkdownText[];
};

Expand Down Expand Up @@ -201,6 +202,7 @@ export function unwrapObjectType(
}

const directProperties = object.properties;
const extraProperties = object.extraProperties;
const descriptions: FernDocs.MarkdownText[] = [];
const extendedProperties = object.extends.flatMap((typeId): Latest.ObjectProperty[] => {
const typeDef = types[typeId];
Expand Down Expand Up @@ -262,7 +264,7 @@ export function unwrapObjectType(
(property) => unwrapReference(property.valueShape, types)?.isOptional,
(property) => AvailabilityOrder.indexOf(property.availability ?? Latest.Availability.Stable),
);
const toRet = { properties, descriptions };
const toRet = { properties, descriptions, extraProperties };
UnwrapObjectTypeCache.set(object, toRet);
return toRet;
}
Expand All @@ -279,7 +281,7 @@ export function unwrapObjectType(
(property) => AvailabilityOrder.indexOf(property.availability ?? Latest.Availability.Stable),
(property) => property.key,
);
const toRet = { properties, descriptions };
const toRet = { properties, descriptions, extraProperties };
UnwrapObjectTypeCache.set(object, toRet);
return toRet;
}
Expand Down Expand Up @@ -309,6 +311,7 @@ export function unwrapDiscriminatedUnionVariant(
},
...properties,
],
extraProperties: undefined,
descriptions,
};
}
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/fdr-sdk/src/navigation/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ export * from "../client/generated/api/resources/commons";
export * from "./ApiDefinitionHolder";
export * as migrate from "./migrators";
export * as utils from "./utils";
export * from "./utils/pruneNavigationTree";
export * from "./versions";
export { ApiDefinitionHolder, ApiDefinitionPruner, ApiTypeIdVisitor, NodeCollector };
Loading

0 comments on commit b58adc0

Please sign in to comment.