From de00ba39647128fdbbf1de3630cb260f35820643 Mon Sep 17 00:00:00 2001 From: Deep Singhvi Date: Mon, 28 Oct 2024 15:20:00 -0400 Subject: [PATCH] fix(cli): revert rbac in docs till supported in docs platform (#5020) --- docs-yml.schema.json | 237 +------ fern/apis/docs-yml/definition/docs.yml | 78 +-- fern/pages/changelogs/cli/2024-10-25.mdx | 20 - fern/pages/changelogs/cli/2024-10-26.mdx | 5 - .../writeDocsDefinitionForProject.ts | 2 +- packages/cli/cli/versions.yml | 7 +- packages/cli/configuration/package.json | 4 +- .../src/docs-yml/ParsedDocsConfiguration.ts | 21 +- .../src/docs-yml/parseDocsConfiguration.ts | 66 +- .../docs/types/ApiReferenceConfiguration.ts | 4 +- .../ApiReferenceEndpointConfiguration.ts | 2 +- ...eferencePackageConfigurationWithOptions.ts | 2 +- .../types/ApiReferenceSectionConfiguration.ts | 2 +- .../api/resources/docs/types/AudienceId.ts | 8 - .../resources/docs/types/AudiencesConfig.ts | 9 + .../docs/types/ChangelogConfiguration.ts | 2 +- .../resources/docs/types/DocsConfiguration.ts | 2 - .../api/resources/docs/types/DocsInstance.ts | 3 +- .../resources/docs/types/PageConfiguration.ts | 4 +- .../sdk/api/resources/docs/types/Role.ts | 11 - .../sdk/api/resources/docs/types/RoleId.ts | 8 - .../docs/types/SectionConfiguration.ts | 2 +- .../sdk/api/resources/docs/types/TabConfig.ts | 2 +- .../api/resources/docs/types/VersionConfig.ts | 2 +- .../resources/docs/types/WithPermissions.ts | 11 - .../sdk/api/resources/docs/types/index.ts | 5 +- .../docs/types/ApiReferenceConfiguration.ts | 48 +- .../ApiReferenceEndpointConfiguration.ts | 20 +- ...eferencePackageConfigurationWithOptions.ts | 28 +- .../types/ApiReferenceSectionConfiguration.ts | 36 +- .../resources/docs/types/AudienceId.ts | 14 - .../resources/docs/types/AudiencesConfig.ts | 19 + .../docs/types/ChangelogConfiguration.ts | 18 +- .../resources/docs/types/DocsConfiguration.ts | 2 - .../resources/docs/types/DocsInstance.ts | 2 + .../resources/docs/types/PageConfiguration.ts | 18 +- .../resources/docs/types/Role.ts | 17 - .../resources/docs/types/RoleId.ts | 14 - .../docs/types/SectionConfiguration.ts | 26 +- .../resources/docs/types/TabConfig.ts | 26 +- .../resources/docs/types/VersionConfig.ts | 16 +- .../resources/docs/types/WithPermissions.ts | 22 - .../resources/docs/types/index.ts | 5 +- .../core/schemas/utils/isPlainObject.ts | 6 +- .../cli/docs-importers/commons/package.json | 4 +- .../cli/docs-importers/mintlify/package.json | 4 +- .../mintlify/src/convertMarkdown.ts | 36 +- packages/cli/docs-markdown-utils/package.json | 4 +- packages/cli/docs-preview/package.json | 2 +- .../cli/docs-preview/src/runPreviewServer.ts | 8 +- .../cli/docs-resolver/.vscode/settings.json | 3 - packages/cli/docs-resolver/package.json | 6 +- .../src/ApiReferenceNodeConverter.ts | 203 +++--- .../src/ChangelogNodeConverter.ts | 58 +- .../src/DocsDefinitionResolver.ts | 642 +++++++----------- .../cli/docs-resolver/src/NodeIdGenerator.ts | 42 +- .../src/__test__/api-resolver.test.ts | 4 +- .../docs-resolver/src/__test__/stream.test.ts | 6 +- packages/cli/ete-tests/package.json | 4 +- .../writeDocsDefinition.test.ts.snap | 126 ++-- .../fixtures/petstore/docs-definition.json | 126 ++-- .../remote-workspace-runner/package.json | 4 +- .../src/publishDocs.ts | 2 + .../runRemoteGenerationForDocsWorkspace.ts | 1 + packages/cli/register/package.json | 4 +- .../__snapshots__/extra-properties.json | 5 +- .../src/ir-to-fdr-converter/convertPackage.ts | 22 +- .../ir-to-fdr-converter/convertTypeShape.ts | 12 +- .../createDocsConfigFileAstVisitorForRules.ts | 3 +- .../src/docsAst/DocsConfigFileAstVisitor.ts | 1 - .../src/docsAst/visitDocsConfigFileYamlAst.ts | 3 +- .../src/docsAst/visitNavigationAst.ts | 8 +- .../yaml/docs-validator/src/getAllRules.ts | 4 +- .../rules/all-roles-must-be-declared/index.ts | 25 - packages/core/package.json | 4 +- pnpm-lock.yaml | 87 +-- 76 files changed, 822 insertions(+), 1497 deletions(-) delete mode 100644 fern/pages/changelogs/cli/2024-10-25.mdx delete mode 100644 fern/pages/changelogs/cli/2024-10-26.mdx delete mode 100644 packages/cli/configuration/src/docs-yml/schemas/sdk/api/resources/docs/types/AudienceId.ts create mode 100644 packages/cli/configuration/src/docs-yml/schemas/sdk/api/resources/docs/types/AudiencesConfig.ts delete mode 100644 packages/cli/configuration/src/docs-yml/schemas/sdk/api/resources/docs/types/Role.ts delete mode 100644 packages/cli/configuration/src/docs-yml/schemas/sdk/api/resources/docs/types/RoleId.ts delete mode 100644 packages/cli/configuration/src/docs-yml/schemas/sdk/api/resources/docs/types/WithPermissions.ts delete mode 100644 packages/cli/configuration/src/docs-yml/schemas/sdk/serialization/resources/docs/types/AudienceId.ts create mode 100644 packages/cli/configuration/src/docs-yml/schemas/sdk/serialization/resources/docs/types/AudiencesConfig.ts delete mode 100644 packages/cli/configuration/src/docs-yml/schemas/sdk/serialization/resources/docs/types/Role.ts delete mode 100644 packages/cli/configuration/src/docs-yml/schemas/sdk/serialization/resources/docs/types/RoleId.ts delete mode 100644 packages/cli/configuration/src/docs-yml/schemas/sdk/serialization/resources/docs/types/WithPermissions.ts delete mode 100644 packages/cli/docs-resolver/.vscode/settings.json delete mode 100644 packages/cli/yaml/docs-validator/src/rules/all-roles-must-be-declared/index.ts diff --git a/docs-yml.schema.json b/docs-yml.schema.json index c3ecde33a0e..0cf8a8013a8 100644 --- a/docs-yml.schema.json +++ b/docs-yml.schema.json @@ -37,19 +37,6 @@ } ] }, - "roles": { - "oneOf": [ - { - "type": "array", - "items": { - "$ref": "#/definitions/docs.RoleId" - } - }, - { - "type": "null" - } - ] - }, "tabs": { "oneOf": [ { @@ -271,6 +258,19 @@ } ] }, + "docs.AudiencesConfig": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "array", + "items": { + "type": "string" + } + } + ] + }, "docs.GithubEditThisPageConfig": { "type": "object", "properties": { @@ -339,6 +339,16 @@ } ] }, + "audiences": { + "oneOf": [ + { + "$ref": "#/definitions/docs.AudiencesConfig" + }, + { + "type": "null" + } + ] + }, "private": { "oneOf": [ { @@ -491,48 +501,12 @@ ], "additionalProperties": false }, - "docs.RoleId": { - "type": "string" - }, - "docs.Role": { - "anyOf": [ - { - "$ref": "#/definitions/docs.RoleId" - }, - { - "type": "array", - "items": { - "$ref": "#/definitions/docs.RoleId" - } - } - ] - }, "docs.ChangelogFolderRelativePath": { "type": "string" }, "docs.TabConfig": { "type": "object", "properties": { - "viewers": { - "oneOf": [ - { - "$ref": "#/definitions/docs.Role" - }, - { - "type": "null" - } - ] - }, - "orphaned": { - "oneOf": [ - { - "type": "boolean" - }, - { - "type": "null" - } - ] - }, "display-name": { "type": "string" }, @@ -614,26 +588,6 @@ "docs.VersionConfig": { "type": "object", "properties": { - "viewers": { - "oneOf": [ - { - "$ref": "#/definitions/docs.Role" - }, - { - "type": "null" - } - ] - }, - "orphaned": { - "oneOf": [ - { - "type": "boolean" - }, - { - "type": "null" - } - ] - }, "display-name": { "type": "string" }, @@ -670,26 +624,6 @@ "docs.PageConfiguration": { "type": "object", "properties": { - "viewers": { - "oneOf": [ - { - "$ref": "#/definitions/docs.Role" - }, - { - "type": "null" - } - ] - }, - "orphaned": { - "oneOf": [ - { - "type": "boolean" - }, - { - "type": "null" - } - ] - }, "page": { "type": "string" }, @@ -736,26 +670,6 @@ "docs.SectionConfiguration": { "type": "object", "properties": { - "viewers": { - "oneOf": [ - { - "$ref": "#/definitions/docs.Role" - }, - { - "type": "null" - } - ] - }, - "orphaned": { - "oneOf": [ - { - "type": "boolean" - }, - { - "type": "null" - } - ] - }, "section": { "type": "string" }, @@ -832,9 +746,6 @@ ], "additionalProperties": false }, - "docs.AudienceId": { - "type": "string" - }, "docs.VersionedSnippetLanguageConfiguration": { "type": "object", "properties": { @@ -975,26 +886,6 @@ "docs.ApiReferencePackageConfigurationWithOptions": { "type": "object", "properties": { - "viewers": { - "oneOf": [ - { - "$ref": "#/definitions/docs.Role" - }, - { - "type": "null" - } - ] - }, - "orphaned": { - "oneOf": [ - { - "type": "boolean" - }, - { - "type": "null" - } - ] - }, "title": { "oneOf": [ { @@ -1097,26 +988,6 @@ "docs.ApiReferenceSectionConfiguration": { "type": "object", "properties": { - "viewers": { - "oneOf": [ - { - "$ref": "#/definitions/docs.Role" - }, - { - "type": "null" - } - ] - }, - "orphaned": { - "oneOf": [ - { - "type": "boolean" - }, - { - "type": "null" - } - ] - }, "section": { "type": "string" }, @@ -1215,26 +1086,6 @@ "docs.ApiReferenceEndpointConfiguration": { "type": "object", "properties": { - "viewers": { - "oneOf": [ - { - "$ref": "#/definitions/docs.Role" - }, - { - "type": "null" - } - ] - }, - "orphaned": { - "oneOf": [ - { - "type": "boolean" - }, - { - "type": "null" - } - ] - }, "endpoint": { "type": "string" }, @@ -1350,26 +1201,6 @@ "docs.ApiReferenceConfiguration": { "type": "object", "properties": { - "viewers": { - "oneOf": [ - { - "$ref": "#/definitions/docs.Role" - }, - { - "type": "null" - } - ] - }, - "orphaned": { - "oneOf": [ - { - "type": "boolean" - }, - { - "type": "null" - } - ] - }, "api": { "type": "string" }, @@ -1388,7 +1219,7 @@ { "type": "array", "items": { - "$ref": "#/definitions/docs.AudienceId" + "type": "string" } }, { @@ -1528,26 +1359,6 @@ "docs.ChangelogConfiguration": { "type": "object", "properties": { - "viewers": { - "oneOf": [ - { - "$ref": "#/definitions/docs.Role" - }, - { - "type": "null" - } - ] - }, - "orphaned": { - "oneOf": [ - { - "type": "boolean" - }, - { - "type": "null" - } - ] - }, "changelog": { "$ref": "#/definitions/docs.ChangelogFolderRelativePath" }, diff --git a/fern/apis/docs-yml/definition/docs.yml b/fern/apis/docs-yml/definition/docs.yml index 0b0336fc4bc..0ac42c40051 100644 --- a/fern/apis/docs-yml/definition/docs.yml +++ b/fern/apis/docs-yml/definition/docs.yml @@ -43,7 +43,7 @@ types: SegmentConfig: properties: write-key: string - + FullStoryAnalyticsConfig: properties: org-id: string @@ -106,14 +106,14 @@ types: # HeapConfig: # properties: # app-id: string - + DocsConfiguration: properties: instances: list title: type: optional docs: used as tab bar title, and in the navbar if no logo is defined - analytics: + analytics: type: optional docs: | The `analytics` object allows you to configure analytics for your docs site. @@ -121,10 +121,6 @@ types: announcement: optional - roles: - docs: Global list of roles that can be used to filter the navigation and content based on the user's session. - type: optional> - # navigation tabs: optional> versions: optional> @@ -161,7 +157,6 @@ types: TabId: string TabConfig: - extends: WithPermissions properties: display-name: string icon: optional @@ -194,10 +189,14 @@ types: properties: url: string "custom-domain": optional + audiences: + type: optional + availability: in-development private: type: optional - docs: This config option is no longer used. Please reach out to the Fern Team if you want to enable private docs. - availability: deprecated + docs: | + If `private` is set to true, Fern will protect the docs site with SSO. + availability: in-development "edit-this-page": type: optional docs: | @@ -228,9 +227,32 @@ types: docs: | @default: `main` + AudiencesConfig: + discriminated: false + docs: | + Restricts the API endpoints and webhooks that are included in the docs site. + If `audiences` is not set, only entities marked as "external" will be included. + union: + - string + - list + # - AudiencesRuleConfig + + # AudiencesRuleConfig: + # properties: + # include: + # type: optional> + # docs: | + # If `include` is set, only entities that match the given audiences will be included in the site. + # exclude: + # type: optional> + # docs: | + # If `exclude` is set, entities that match the given audiences will be excluded from the site. + # exclude-no-audience: + # type: optional + # docs: | + # If `exclude-no-audience` is set to true, entities that do not have an audience will be excluded from the site. VersionConfig: - extends: WithPermissions properties: display-name: string path: @@ -427,30 +449,6 @@ types: - fixed - static - AudienceId: - type: string - docs: ID of audience which is used to filter the API spec. - - RoleId: - type: string - docs: ID of role which is used to filter the content shown in Fern Docs. - - Role: - docs: | - Audience can either be a string or list of strings - i.e. `audience: internal` or `audience: [internal, beta]` - discriminated: false - union: - - RoleId - - list - - WithPermissions: - properties: - viewers: optional - orphaned: - type: optional - docs: When `orphaned` is set to `true`, the roles will not inherit from parents. - FontConfig: properties: name: @@ -527,7 +525,6 @@ types: @default: `normal`. PageConfiguration: - extends: WithPermissions properties: page: string path: string @@ -536,7 +533,6 @@ types: hidden: optional ChangelogConfiguration: - extends: WithPermissions properties: changelog: ChangelogFolderRelativePath title: optional # defaults to "Changelog" @@ -546,7 +542,6 @@ types: # skip-slug: optional # skip-slug is not needed for changelog SectionConfiguration: - extends: WithPermissions properties: section: string path: @@ -561,13 +556,12 @@ types: skip-slug: optional ApiReferenceConfiguration: - extends: WithPermissions properties: api: string "api-name": type: optional docs: Name of API that we are referencing - audiences: optional> + audiences: optional> display-errors: type: optional docs: Defaults to false @@ -617,7 +611,6 @@ types: - LinkConfiguration ApiReferenceSectionConfiguration: - extends: WithPermissions properties: section: type: string @@ -645,7 +638,6 @@ types: - ApiReferencePackageConfigurationWithOptions ApiReferencePackageConfigurationWithOptions: - extends: WithPermissions properties: title: optional summary: @@ -662,7 +654,6 @@ types: docs: Settings for the api playground that is applied only to descendants of this api package. ApiReferenceEndpointConfiguration: - extends: WithPermissions properties: endpoint: string title: optional @@ -993,3 +984,4 @@ types: message: type: string docs: The message to display in the announcement bar. Markdown is supported. + diff --git a/fern/pages/changelogs/cli/2024-10-25.mdx b/fern/pages/changelogs/cli/2024-10-25.mdx deleted file mode 100644 index c85f003909a..00000000000 --- a/fern/pages/changelogs/cli/2024-10-25.mdx +++ /dev/null @@ -1,20 +0,0 @@ -## 0.45.0-rc21 -**`(feat):`** The Fern CLI now supports orphaned pages in your docs configuration. - - -**`(fix):`** The RBAC config model is now renamed to `roles` and `viewers`: - -```yml docs.yml -roles: - - internal - -navigation: - - section: Internal Section - viewers: - - internal - contents: - - page: Internal Page - path: ./internal/page.mdx -``` - - diff --git a/fern/pages/changelogs/cli/2024-10-26.mdx b/fern/pages/changelogs/cli/2024-10-26.mdx deleted file mode 100644 index 82310354e3b..00000000000 --- a/fern/pages/changelogs/cli/2024-10-26.mdx +++ /dev/null @@ -1,5 +0,0 @@ -## 0.45.0-rc25 -**`(fix):`** - fixes how `write-docs-definition` handles urls containing `https://` prefix -- fixes how the docs definition resolver handles changelogs under api reference nodes - - diff --git a/packages/cli/cli/src/commands/write-docs-definition/writeDocsDefinitionForProject.ts b/packages/cli/cli/src/commands/write-docs-definition/writeDocsDefinitionForProject.ts index 3381c3d9722..953bcbe4b2f 100644 --- a/packages/cli/cli/src/commands/write-docs-definition/writeDocsDefinitionForProject.ts +++ b/packages/cli/cli/src/commands/write-docs-definition/writeDocsDefinitionForProject.ts @@ -30,7 +30,7 @@ export async function writeDocsDefinitionForProject({ ); const docsResolver = new DocsDefinitionResolver( - docsWorkspace.config.instances[0]?.url ?? "http://localhost:8080", + `https://${docsWorkspace.config.instances[0]?.url ?? "https://localhost:8080"}`, docsWorkspace, fernWorkspaces, context diff --git a/packages/cli/cli/versions.yml b/packages/cli/cli/versions.yml index fe1f924762b..2a12e9adbfb 100644 --- a/packages/cli/cli/versions.yml +++ b/packages/cli/cli/versions.yml @@ -1,8 +1,7 @@ - changelogEntry: - - summary: | - - fixes how `write-docs-definition` handles urls containing `https://` prefix - - fixes how the docs definition resolver handles changelogs under api reference nodes - type: fix + - summary: | + The Fern CLI temporarily does not support RBAC/Audiences (they will be added in again shortly). + type: internal irVersion: 53 version: 0.45.0-rc25 diff --git a/packages/cli/configuration/package.json b/packages/cli/configuration/package.json index 0ed2d66b1bc..e684e26c945 100644 --- a/packages/cli/configuration/package.json +++ b/packages/cli/configuration/package.json @@ -32,7 +32,7 @@ "@fern-api/fs-utils": "workspace:*", "@fern-api/task-context": "workspace:*", "@fern-api/fern-definition-schema": "workspace:*", - "@fern-fern/fdr-cjs-sdk": "0.119.0-d531a5553", + "@fern-fern/fdr-cjs-sdk": "0.0.5833", "@fern-fern/fiddle-sdk": "0.0.584", "@fern-fern/generators-sdk": "0.114.0-5745f9e74", "find-up": "^6.3.0", @@ -56,4 +56,4 @@ "typescript": "4.6.4", "vitest": "^2.0.5" } -} +} \ No newline at end of file diff --git a/packages/cli/configuration/src/docs-yml/ParsedDocsConfiguration.ts b/packages/cli/configuration/src/docs-yml/ParsedDocsConfiguration.ts index 8c8018b96e8..7ee77a30a04 100644 --- a/packages/cli/configuration/src/docs-yml/ParsedDocsConfiguration.ts +++ b/packages/cli/configuration/src/docs-yml/ParsedDocsConfiguration.ts @@ -11,9 +11,6 @@ export interface ParsedDocsConfiguration { /* filepath of page to contents */ pages: Record; - /* RBAC declaration */ - roles: string[] | undefined; - /* navigation */ landingPage: DocsNavigationItem.Page | undefined; navigation: DocsNavigationConfiguration; @@ -138,7 +135,7 @@ export interface VersionedDocsNavigation { versions: VersionInfo[]; } -export interface VersionInfo extends CjsFdrSdk.navigation.v1.WithPermissions { +export interface VersionInfo { landingPage: DocsNavigationItem.Page | undefined; navigation: UntabbedDocsNavigation | TabbedDocsNavigation; version: string; @@ -150,7 +147,7 @@ export type DocsNavigationConfiguration = UntabbedDocsNavigation | TabbedDocsNav export type UnversionedNavigationConfiguration = UntabbedDocsNavigation | TabbedDocsNavigation; -export interface TabbedNavigation extends CjsFdrSdk.navigation.v1.WithPermissions { +export interface TabbedNavigation { // tab: string; title: string; icon: string | undefined; @@ -190,7 +187,7 @@ export type DocsNavigationItem = | DocsNavigationItem.Changelog; export declare namespace DocsNavigationItem { - export interface Page extends CjsFdrSdk.navigation.v1.WithPermissions { + export interface Page { type: "page"; title: string; icon: string | undefined; @@ -200,7 +197,7 @@ export declare namespace DocsNavigationItem { noindex: boolean | undefined; } - export interface Section extends CjsFdrSdk.navigation.v1.WithPermissions { + export interface Section { type: "section"; title: string; icon: string | undefined; @@ -212,7 +209,7 @@ export declare namespace DocsNavigationItem { overviewAbsolutePath: AbsoluteFilePath | undefined; } - export interface ApiSection extends CjsFdrSdk.navigation.v1.WithPermissions { + export interface ApiSection { type: "apiSection"; title: string; icon: string | undefined; @@ -238,7 +235,7 @@ export declare namespace DocsNavigationItem { icon: string | undefined; } - export interface Changelog extends CjsFdrSdk.navigation.v1.WithPermissions { + export interface Changelog { type: "changelog"; changelog: AbsoluteFilePath[]; title: string; @@ -262,7 +259,7 @@ export declare namespace DocsNavigationItem { } export declare namespace ParsedApiReferenceLayoutItem { - export interface Section extends CjsFdrSdk.navigation.v1.WithPermissions { + export interface Section { type: "section"; title: string; // title referencedSubpackages: string[]; // subpackage IDs @@ -274,7 +271,7 @@ export declare namespace ParsedApiReferenceLayoutItem { skipUrlSlug: boolean | undefined; playground: PlaygroundSettings | undefined; } - export interface Package extends CjsFdrSdk.navigation.v1.WithPermissions { + export interface Package { type: "package"; title: string | undefined; // defaults to subpackage title package: string; // subpackage ID @@ -287,7 +284,7 @@ export declare namespace ParsedApiReferenceLayoutItem { playground: PlaygroundSettings | undefined; } - export interface Endpoint extends CjsFdrSdk.navigation.v1.WithPermissions { + export interface Endpoint { type: "endpoint"; endpoint: string; // endpoint locator title: string | undefined; diff --git a/packages/cli/configuration/src/docs-yml/parseDocsConfiguration.ts b/packages/cli/configuration/src/docs-yml/parseDocsConfiguration.ts index a227349b912..71f86c77378 100644 --- a/packages/cli/configuration/src/docs-yml/parseDocsConfiguration.ts +++ b/packages/cli/configuration/src/docs-yml/parseDocsConfiguration.ts @@ -4,7 +4,6 @@ import { TaskContext } from "@fern-api/task-context"; import { FernRegistry as CjsFdrSdk } from "@fern-fern/fdr-cjs-sdk"; import { readFile } from "fs/promises"; import yaml from "js-yaml"; -import { Audiences } from "../commons/Audiences"; import { WithoutQuestionMarks } from "../commons/WithoutQuestionMarks"; import { convertColorsConfiguration } from "./convertColorsConfiguration"; import { getAllPages, loadAllPages } from "./getAllPages"; @@ -121,7 +120,6 @@ export async function parseDocsConfiguration({ title, // absoluteFilepath: absoluteFilepathToDocsConfig, instances, - roles: rawDocsConfiguration.roles, /* filepath of page to contents */ pages, @@ -390,9 +388,7 @@ async function getNavigationConfiguration({ version: version.displayName, navigation, availability: version.availability, - slug: version.slug, - viewers: parseRoles(version.viewers), - orphaned: version.orphaned + slug: version.slug }); } return { @@ -541,9 +537,7 @@ async function convertNavigationTabConfiguration({ child: { type: "layout", layout - }, - viewers: parseRoles(tab.viewers), - orphaned: tab.orphaned + } }; } @@ -557,9 +551,7 @@ async function convertNavigationTabConfiguration({ child: { type: "link", href: tab.href - }, - viewers: parseRoles(tab.viewers), - orphaned: tab.orphaned + } }; } @@ -573,9 +565,7 @@ async function convertNavigationTabConfiguration({ child: { type: "changelog", changelog: await listFiles(resolveFilepath(tab.changelog, absolutePathToConfig), "{md,mdx}") - }, - viewers: parseRoles(tab.viewers), - orphaned: tab.orphaned + } }; } @@ -653,9 +643,7 @@ async function convertNavigationItem({ collapsed: rawConfig.collapsed ?? undefined, hidden: rawConfig.hidden ?? undefined, skipUrlSlug: rawConfig.skipSlug ?? false, - overviewAbsolutePath: resolveFilepath(rawConfig.path, absolutePathToConfig), - viewers: parseRoles(rawConfig.viewers), - orphaned: rawConfig.orphaned + overviewAbsolutePath: resolveFilepath(rawConfig.path, absolutePathToConfig) }; } if (isRawApiSectionConfig(rawConfig)) { @@ -680,9 +668,7 @@ async function convertNavigationItem({ flattened: rawConfig.flattened ?? false, alphabetized: rawConfig.alphabetized ?? false, paginated: rawConfig.paginated ?? false, - playground: rawConfig.playground, - viewers: parseRoles(rawConfig.viewers), - orphaned: rawConfig.orphaned + playground: rawConfig.playground }; } if (isRawLinkConfig(rawConfig)) { @@ -700,9 +686,7 @@ async function convertNavigationItem({ hidden: rawConfig.hidden ?? false, icon: rawConfig.icon, title: rawConfig.title ?? DEFAULT_CHANGELOG_TITLE, - slug: rawConfig.slug, - viewers: parseRoles(rawConfig.viewers), - orphaned: rawConfig.orphaned + slug: rawConfig.slug }; } assertNever(rawConfig); @@ -731,9 +715,7 @@ function parsePageConfig( icon: item.icon, hidden: item.hidden, // TODO: implement noindex - noindex: undefined, - viewers: parseRoles(item.viewers), - orphaned: item.orphaned + noindex: undefined }; } @@ -770,9 +752,7 @@ function parseApiReferenceLayoutItem( hidden: item.hidden, skipUrlSlug: item.skipSlug, icon: item.icon, - playground: item.playground, - viewers: parseRoles(item.viewers), - orphaned: item.orphaned + playground: item.playground } ]; } else if (isRawApiRefEndpointConfiguration(item)) { @@ -784,9 +764,7 @@ function parseApiReferenceLayoutItem( icon: item.icon, slug: item.slug, hidden: item.hidden, - playground: item.playground, - viewers: parseRoles(item.viewers), - orphaned: item.orphaned + playground: item.playground } ]; } @@ -803,9 +781,7 @@ function parseApiReferenceLayoutItem( hidden: value.hidden, skipUrlSlug: value.skipSlug, icon: value.icon, - playground: value.playground, - viewers: parseRoles(value.viewers), - orphaned: value.orphaned + playground: value.playground }; } return { @@ -818,9 +794,7 @@ function parseApiReferenceLayoutItem( slug: undefined, skipUrlSlug: false, icon: undefined, - playground: undefined, - viewers: undefined, - orphaned: undefined + playground: undefined }; }); } @@ -997,19 +971,3 @@ async function convertFilepathOrUrl( // If the file does not exist, fallback to a URL return { type: "url", value }; } - -function parseRoles(raw: string | string[] | undefined): CjsFdrSdk.RoleId[] | undefined { - if (raw == null) { - return undefined; - } - - if (typeof raw === "string") { - return [CjsFdrSdk.RoleId(raw)]; - } - - if (raw.length === 0) { - return undefined; - } - - return raw.map(CjsFdrSdk.RoleId); -} diff --git a/packages/cli/configuration/src/docs-yml/schemas/sdk/api/resources/docs/types/ApiReferenceConfiguration.ts b/packages/cli/configuration/src/docs-yml/schemas/sdk/api/resources/docs/types/ApiReferenceConfiguration.ts index 23fb92597a5..5b7dc0aeb76 100644 --- a/packages/cli/configuration/src/docs-yml/schemas/sdk/api/resources/docs/types/ApiReferenceConfiguration.ts +++ b/packages/cli/configuration/src/docs-yml/schemas/sdk/api/resources/docs/types/ApiReferenceConfiguration.ts @@ -4,11 +4,11 @@ import * as FernDocsConfig from "../../.."; -export interface ApiReferenceConfiguration extends FernDocsConfig.WithPermissions { +export interface ApiReferenceConfiguration { api: string; /** Name of API that we are referencing */ apiName?: string; - audiences?: FernDocsConfig.AudienceId[]; + audiences?: string[]; /** Defaults to false */ displayErrors?: boolean; snippets?: FernDocsConfig.SnippetsConfiguration; diff --git a/packages/cli/configuration/src/docs-yml/schemas/sdk/api/resources/docs/types/ApiReferenceEndpointConfiguration.ts b/packages/cli/configuration/src/docs-yml/schemas/sdk/api/resources/docs/types/ApiReferenceEndpointConfiguration.ts index daadbb7c247..96c25ec6cbd 100644 --- a/packages/cli/configuration/src/docs-yml/schemas/sdk/api/resources/docs/types/ApiReferenceEndpointConfiguration.ts +++ b/packages/cli/configuration/src/docs-yml/schemas/sdk/api/resources/docs/types/ApiReferenceEndpointConfiguration.ts @@ -4,7 +4,7 @@ import * as FernDocsConfig from "../../.."; -export interface ApiReferenceEndpointConfiguration extends FernDocsConfig.WithPermissions { +export interface ApiReferenceEndpointConfiguration { endpoint: string; title?: string; slug?: string; diff --git a/packages/cli/configuration/src/docs-yml/schemas/sdk/api/resources/docs/types/ApiReferencePackageConfigurationWithOptions.ts b/packages/cli/configuration/src/docs-yml/schemas/sdk/api/resources/docs/types/ApiReferencePackageConfigurationWithOptions.ts index ff55abbd685..48cb0749b33 100644 --- a/packages/cli/configuration/src/docs-yml/schemas/sdk/api/resources/docs/types/ApiReferencePackageConfigurationWithOptions.ts +++ b/packages/cli/configuration/src/docs-yml/schemas/sdk/api/resources/docs/types/ApiReferencePackageConfigurationWithOptions.ts @@ -4,7 +4,7 @@ import * as FernDocsConfig from "../../.."; -export interface ApiReferencePackageConfigurationWithOptions extends FernDocsConfig.WithPermissions { +export interface ApiReferencePackageConfigurationWithOptions { title?: string; /** Relative path to the markdown file. This summary is displayed at the top of the API section. */ summary?: string; diff --git a/packages/cli/configuration/src/docs-yml/schemas/sdk/api/resources/docs/types/ApiReferenceSectionConfiguration.ts b/packages/cli/configuration/src/docs-yml/schemas/sdk/api/resources/docs/types/ApiReferenceSectionConfiguration.ts index bcc3a53b969..b5a0ffcfba3 100644 --- a/packages/cli/configuration/src/docs-yml/schemas/sdk/api/resources/docs/types/ApiReferenceSectionConfiguration.ts +++ b/packages/cli/configuration/src/docs-yml/schemas/sdk/api/resources/docs/types/ApiReferenceSectionConfiguration.ts @@ -4,7 +4,7 @@ import * as FernDocsConfig from "../../.."; -export interface ApiReferenceSectionConfiguration extends FernDocsConfig.WithPermissions { +export interface ApiReferenceSectionConfiguration { /** The title of the api package that will be displayed in the sidebar. */ section: string; /** This section will inherit the endpoints from the specified subpackage(s). If multiple packages are specified, they will be merged. */ diff --git a/packages/cli/configuration/src/docs-yml/schemas/sdk/api/resources/docs/types/AudienceId.ts b/packages/cli/configuration/src/docs-yml/schemas/sdk/api/resources/docs/types/AudienceId.ts deleted file mode 100644 index 45ccdae9fff..00000000000 --- a/packages/cli/configuration/src/docs-yml/schemas/sdk/api/resources/docs/types/AudienceId.ts +++ /dev/null @@ -1,8 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ - -/** - * ID of audience which is used to filter the API spec. - */ -export type AudienceId = string; diff --git a/packages/cli/configuration/src/docs-yml/schemas/sdk/api/resources/docs/types/AudiencesConfig.ts b/packages/cli/configuration/src/docs-yml/schemas/sdk/api/resources/docs/types/AudiencesConfig.ts new file mode 100644 index 00000000000..9cffd18bf97 --- /dev/null +++ b/packages/cli/configuration/src/docs-yml/schemas/sdk/api/resources/docs/types/AudiencesConfig.ts @@ -0,0 +1,9 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * Restricts the API endpoints and webhooks that are included in the docs site. + * If `audiences` is not set, only entities marked as "external" will be included. + */ +export type AudiencesConfig = string | string[]; diff --git a/packages/cli/configuration/src/docs-yml/schemas/sdk/api/resources/docs/types/ChangelogConfiguration.ts b/packages/cli/configuration/src/docs-yml/schemas/sdk/api/resources/docs/types/ChangelogConfiguration.ts index 3189956d2df..281cc7c13c8 100644 --- a/packages/cli/configuration/src/docs-yml/schemas/sdk/api/resources/docs/types/ChangelogConfiguration.ts +++ b/packages/cli/configuration/src/docs-yml/schemas/sdk/api/resources/docs/types/ChangelogConfiguration.ts @@ -4,7 +4,7 @@ import * as FernDocsConfig from "../../.."; -export interface ChangelogConfiguration extends FernDocsConfig.WithPermissions { +export interface ChangelogConfiguration { changelog: FernDocsConfig.ChangelogFolderRelativePath; title?: string; slug?: string; diff --git a/packages/cli/configuration/src/docs-yml/schemas/sdk/api/resources/docs/types/DocsConfiguration.ts b/packages/cli/configuration/src/docs-yml/schemas/sdk/api/resources/docs/types/DocsConfiguration.ts index e5a98789231..038bc717114 100644 --- a/packages/cli/configuration/src/docs-yml/schemas/sdk/api/resources/docs/types/DocsConfiguration.ts +++ b/packages/cli/configuration/src/docs-yml/schemas/sdk/api/resources/docs/types/DocsConfiguration.ts @@ -14,8 +14,6 @@ export interface DocsConfiguration { */ analytics?: FernDocsConfig.AnalyticsConfig; announcement?: FernDocsConfig.AnnouncementConfig; - /** Global list of roles that can be used to filter the navigation and content based on the user's session. */ - roles?: FernDocsConfig.RoleId[]; tabs?: Record; versions?: FernDocsConfig.VersionConfig[]; landingPage?: FernDocsConfig.PageConfiguration; diff --git a/packages/cli/configuration/src/docs-yml/schemas/sdk/api/resources/docs/types/DocsInstance.ts b/packages/cli/configuration/src/docs-yml/schemas/sdk/api/resources/docs/types/DocsInstance.ts index a2dba839c29..1d6a8548c7a 100644 --- a/packages/cli/configuration/src/docs-yml/schemas/sdk/api/resources/docs/types/DocsInstance.ts +++ b/packages/cli/configuration/src/docs-yml/schemas/sdk/api/resources/docs/types/DocsInstance.ts @@ -7,7 +7,8 @@ import * as FernDocsConfig from "../../.."; export interface DocsInstance { url: string; customDomain?: FernDocsConfig.CustomDomain; - /** This config option is no longer used. Please reach out to the Fern Team if you want to enable private docs. */ + audiences?: FernDocsConfig.AudiencesConfig; + /** If `private` is set to true, Fern will protect the docs site with SSO. */ private?: boolean; /** If `edit-this-page` is set, Fern will add an "Edit this page" link to the bottom of each page that links to the given GitHub repository. */ editThisPage?: FernDocsConfig.EditThisPageConfig; diff --git a/packages/cli/configuration/src/docs-yml/schemas/sdk/api/resources/docs/types/PageConfiguration.ts b/packages/cli/configuration/src/docs-yml/schemas/sdk/api/resources/docs/types/PageConfiguration.ts index c0658765cc7..4aa656757c3 100644 --- a/packages/cli/configuration/src/docs-yml/schemas/sdk/api/resources/docs/types/PageConfiguration.ts +++ b/packages/cli/configuration/src/docs-yml/schemas/sdk/api/resources/docs/types/PageConfiguration.ts @@ -2,9 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as FernDocsConfig from "../../.."; - -export interface PageConfiguration extends FernDocsConfig.WithPermissions { +export interface PageConfiguration { page: string; path: string; slug?: string; diff --git a/packages/cli/configuration/src/docs-yml/schemas/sdk/api/resources/docs/types/Role.ts b/packages/cli/configuration/src/docs-yml/schemas/sdk/api/resources/docs/types/Role.ts deleted file mode 100644 index 8654781a831..00000000000 --- a/packages/cli/configuration/src/docs-yml/schemas/sdk/api/resources/docs/types/Role.ts +++ /dev/null @@ -1,11 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ - -import * as FernDocsConfig from "../../.."; - -/** - * Audience can either be a string or list of strings - * i.e. `audience: internal` or `audience: [internal, beta]` - */ -export type Role = FernDocsConfig.RoleId | FernDocsConfig.RoleId[]; diff --git a/packages/cli/configuration/src/docs-yml/schemas/sdk/api/resources/docs/types/RoleId.ts b/packages/cli/configuration/src/docs-yml/schemas/sdk/api/resources/docs/types/RoleId.ts deleted file mode 100644 index 122a1a4728e..00000000000 --- a/packages/cli/configuration/src/docs-yml/schemas/sdk/api/resources/docs/types/RoleId.ts +++ /dev/null @@ -1,8 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ - -/** - * ID of role which is used to filter the content shown in Fern Docs. - */ -export type RoleId = string; diff --git a/packages/cli/configuration/src/docs-yml/schemas/sdk/api/resources/docs/types/SectionConfiguration.ts b/packages/cli/configuration/src/docs-yml/schemas/sdk/api/resources/docs/types/SectionConfiguration.ts index fb44c7710c0..cd390124362 100644 --- a/packages/cli/configuration/src/docs-yml/schemas/sdk/api/resources/docs/types/SectionConfiguration.ts +++ b/packages/cli/configuration/src/docs-yml/schemas/sdk/api/resources/docs/types/SectionConfiguration.ts @@ -4,7 +4,7 @@ import * as FernDocsConfig from "../../.."; -export interface SectionConfiguration extends FernDocsConfig.WithPermissions { +export interface SectionConfiguration { section: string; /** The relative path to the markdown file that will be displayed when the section is clicked. */ path?: string; diff --git a/packages/cli/configuration/src/docs-yml/schemas/sdk/api/resources/docs/types/TabConfig.ts b/packages/cli/configuration/src/docs-yml/schemas/sdk/api/resources/docs/types/TabConfig.ts index 15698b4c747..a99abc179c8 100644 --- a/packages/cli/configuration/src/docs-yml/schemas/sdk/api/resources/docs/types/TabConfig.ts +++ b/packages/cli/configuration/src/docs-yml/schemas/sdk/api/resources/docs/types/TabConfig.ts @@ -4,7 +4,7 @@ import * as FernDocsConfig from "../../.."; -export interface TabConfig extends FernDocsConfig.WithPermissions { +export interface TabConfig { displayName: string; icon?: string; slug?: string; diff --git a/packages/cli/configuration/src/docs-yml/schemas/sdk/api/resources/docs/types/VersionConfig.ts b/packages/cli/configuration/src/docs-yml/schemas/sdk/api/resources/docs/types/VersionConfig.ts index 04e0ba33f87..04d6845bcef 100644 --- a/packages/cli/configuration/src/docs-yml/schemas/sdk/api/resources/docs/types/VersionConfig.ts +++ b/packages/cli/configuration/src/docs-yml/schemas/sdk/api/resources/docs/types/VersionConfig.ts @@ -4,7 +4,7 @@ import * as FernDocsConfig from "../../.."; -export interface VersionConfig extends FernDocsConfig.WithPermissions { +export interface VersionConfig { displayName: string; /** The relative path to the version's docs.yml file. */ path: string; diff --git a/packages/cli/configuration/src/docs-yml/schemas/sdk/api/resources/docs/types/WithPermissions.ts b/packages/cli/configuration/src/docs-yml/schemas/sdk/api/resources/docs/types/WithPermissions.ts deleted file mode 100644 index 381a39b473d..00000000000 --- a/packages/cli/configuration/src/docs-yml/schemas/sdk/api/resources/docs/types/WithPermissions.ts +++ /dev/null @@ -1,11 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ - -import * as FernDocsConfig from "../../.."; - -export interface WithPermissions { - viewers?: FernDocsConfig.Role; - /** When `orphaned` is set to `true`, the roles will not inherit from parents. */ - orphaned?: boolean; -} diff --git a/packages/cli/configuration/src/docs-yml/schemas/sdk/api/resources/docs/types/index.ts b/packages/cli/configuration/src/docs-yml/schemas/sdk/api/resources/docs/types/index.ts index a3b35a5ecd3..0db7bd06ec1 100644 --- a/packages/cli/configuration/src/docs-yml/schemas/sdk/api/resources/docs/types/index.ts +++ b/packages/cli/configuration/src/docs-yml/schemas/sdk/api/resources/docs/types/index.ts @@ -12,6 +12,7 @@ export * from "./DocsInstance"; export * from "./CustomDomain"; export * from "./EditThisPageConfig"; export * from "./GithubEditThisPageConfig"; +export * from "./AudiencesConfig"; export * from "./VersionConfig"; export * from "./VersionAvailability"; export * from "./VersionFileConfig"; @@ -29,10 +30,6 @@ export * from "./SearchbarPlacement"; export * from "./TabsPlacement"; export * from "./ContentAlignment"; export * from "./HeaderPosition"; -export * from "./AudienceId"; -export * from "./RoleId"; -export * from "./Role"; -export * from "./WithPermissions"; export * from "./FontConfig"; export * from "./FontWeight"; export * from "./FontStyle"; diff --git a/packages/cli/configuration/src/docs-yml/schemas/sdk/serialization/resources/docs/types/ApiReferenceConfiguration.ts b/packages/cli/configuration/src/docs-yml/schemas/sdk/serialization/resources/docs/types/ApiReferenceConfiguration.ts index c253b8c29e8..9646d1e5155 100644 --- a/packages/cli/configuration/src/docs-yml/schemas/sdk/serialization/resources/docs/types/ApiReferenceConfiguration.ts +++ b/packages/cli/configuration/src/docs-yml/schemas/sdk/serialization/resources/docs/types/ApiReferenceConfiguration.ts @@ -9,37 +9,31 @@ import * as core from "../../../../core"; export const ApiReferenceConfiguration: core.serialization.ObjectSchema< serializers.ApiReferenceConfiguration.Raw, FernDocsConfig.ApiReferenceConfiguration -> = core.serialization - .object({ - api: core.serialization.string(), - apiName: core.serialization.property("api-name", core.serialization.string().optional()), - audiences: core.serialization - .list(core.serialization.lazy(async () => (await import("../../..")).AudienceId)) - .optional(), - displayErrors: core.serialization.property("display-errors", core.serialization.boolean().optional()), - snippets: core.serialization - .lazyObject(async () => (await import("../../..")).SnippetsConfiguration) - .optional(), - summary: core.serialization.string().optional(), - layout: core.serialization - .list(core.serialization.lazy(async () => (await import("../../..")).ApiReferenceLayoutItem)) - .optional(), - icon: core.serialization.string().optional(), - slug: core.serialization.string().optional(), - hidden: core.serialization.boolean().optional(), - skipSlug: core.serialization.property("skip-slug", core.serialization.boolean().optional()), - alphabetized: core.serialization.boolean().optional(), - flattened: core.serialization.boolean().optional(), - paginated: core.serialization.boolean().optional(), - playground: core.serialization.lazyObject(async () => (await import("../../..")).PlaygroundSettings).optional(), - }) - .extend(core.serialization.lazyObject(async () => (await import("../../..")).WithPermissions)); +> = core.serialization.object({ + api: core.serialization.string(), + apiName: core.serialization.property("api-name", core.serialization.string().optional()), + audiences: core.serialization.list(core.serialization.string()).optional(), + displayErrors: core.serialization.property("display-errors", core.serialization.boolean().optional()), + snippets: core.serialization.lazyObject(async () => (await import("../../..")).SnippetsConfiguration).optional(), + summary: core.serialization.string().optional(), + layout: core.serialization + .list(core.serialization.lazy(async () => (await import("../../..")).ApiReferenceLayoutItem)) + .optional(), + icon: core.serialization.string().optional(), + slug: core.serialization.string().optional(), + hidden: core.serialization.boolean().optional(), + skipSlug: core.serialization.property("skip-slug", core.serialization.boolean().optional()), + alphabetized: core.serialization.boolean().optional(), + flattened: core.serialization.boolean().optional(), + paginated: core.serialization.boolean().optional(), + playground: core.serialization.lazyObject(async () => (await import("../../..")).PlaygroundSettings).optional(), +}); export declare namespace ApiReferenceConfiguration { - interface Raw extends serializers.WithPermissions.Raw { + interface Raw { api: string; "api-name"?: string | null; - audiences?: serializers.AudienceId.Raw[] | null; + audiences?: string[] | null; "display-errors"?: boolean | null; snippets?: serializers.SnippetsConfiguration.Raw | null; summary?: string | null; diff --git a/packages/cli/configuration/src/docs-yml/schemas/sdk/serialization/resources/docs/types/ApiReferenceEndpointConfiguration.ts b/packages/cli/configuration/src/docs-yml/schemas/sdk/serialization/resources/docs/types/ApiReferenceEndpointConfiguration.ts index 9bf36f39e84..21113078200 100644 --- a/packages/cli/configuration/src/docs-yml/schemas/sdk/serialization/resources/docs/types/ApiReferenceEndpointConfiguration.ts +++ b/packages/cli/configuration/src/docs-yml/schemas/sdk/serialization/resources/docs/types/ApiReferenceEndpointConfiguration.ts @@ -9,19 +9,17 @@ import * as core from "../../../../core"; export const ApiReferenceEndpointConfiguration: core.serialization.ObjectSchema< serializers.ApiReferenceEndpointConfiguration.Raw, FernDocsConfig.ApiReferenceEndpointConfiguration -> = core.serialization - .object({ - endpoint: core.serialization.string(), - title: core.serialization.string().optional(), - slug: core.serialization.string().optional(), - icon: core.serialization.string().optional(), - hidden: core.serialization.boolean().optional(), - playground: core.serialization.lazyObject(async () => (await import("../../..")).PlaygroundSettings).optional(), - }) - .extend(core.serialization.lazyObject(async () => (await import("../../..")).WithPermissions)); +> = core.serialization.object({ + endpoint: core.serialization.string(), + title: core.serialization.string().optional(), + slug: core.serialization.string().optional(), + icon: core.serialization.string().optional(), + hidden: core.serialization.boolean().optional(), + playground: core.serialization.lazyObject(async () => (await import("../../..")).PlaygroundSettings).optional(), +}); export declare namespace ApiReferenceEndpointConfiguration { - interface Raw extends serializers.WithPermissions.Raw { + interface Raw { endpoint: string; title?: string | null; slug?: string | null; diff --git a/packages/cli/configuration/src/docs-yml/schemas/sdk/serialization/resources/docs/types/ApiReferencePackageConfigurationWithOptions.ts b/packages/cli/configuration/src/docs-yml/schemas/sdk/serialization/resources/docs/types/ApiReferencePackageConfigurationWithOptions.ts index 29ef330ef3c..1cc802ca933 100644 --- a/packages/cli/configuration/src/docs-yml/schemas/sdk/serialization/resources/docs/types/ApiReferencePackageConfigurationWithOptions.ts +++ b/packages/cli/configuration/src/docs-yml/schemas/sdk/serialization/resources/docs/types/ApiReferencePackageConfigurationWithOptions.ts @@ -9,23 +9,21 @@ import * as core from "../../../../core"; export const ApiReferencePackageConfigurationWithOptions: core.serialization.ObjectSchema< serializers.ApiReferencePackageConfigurationWithOptions.Raw, FernDocsConfig.ApiReferencePackageConfigurationWithOptions -> = core.serialization - .object({ - title: core.serialization.string().optional(), - summary: core.serialization.string().optional(), - contents: core.serialization - .list(core.serialization.lazy(async () => (await import("../../..")).ApiReferenceLayoutItem)) - .optional(), - slug: core.serialization.string().optional(), - icon: core.serialization.string().optional(), - hidden: core.serialization.boolean().optional(), - skipSlug: core.serialization.property("skip-slug", core.serialization.boolean().optional()), - playground: core.serialization.lazyObject(async () => (await import("../../..")).PlaygroundSettings).optional(), - }) - .extend(core.serialization.lazyObject(async () => (await import("../../..")).WithPermissions)); +> = core.serialization.object({ + title: core.serialization.string().optional(), + summary: core.serialization.string().optional(), + contents: core.serialization + .list(core.serialization.lazy(async () => (await import("../../..")).ApiReferenceLayoutItem)) + .optional(), + slug: core.serialization.string().optional(), + icon: core.serialization.string().optional(), + hidden: core.serialization.boolean().optional(), + skipSlug: core.serialization.property("skip-slug", core.serialization.boolean().optional()), + playground: core.serialization.lazyObject(async () => (await import("../../..")).PlaygroundSettings).optional(), +}); export declare namespace ApiReferencePackageConfigurationWithOptions { - interface Raw extends serializers.WithPermissions.Raw { + interface Raw { title?: string | null; summary?: string | null; contents?: serializers.ApiReferenceLayoutItem.Raw[] | null; diff --git a/packages/cli/configuration/src/docs-yml/schemas/sdk/serialization/resources/docs/types/ApiReferenceSectionConfiguration.ts b/packages/cli/configuration/src/docs-yml/schemas/sdk/serialization/resources/docs/types/ApiReferenceSectionConfiguration.ts index 4f29ce41693..6e8e970049c 100644 --- a/packages/cli/configuration/src/docs-yml/schemas/sdk/serialization/resources/docs/types/ApiReferenceSectionConfiguration.ts +++ b/packages/cli/configuration/src/docs-yml/schemas/sdk/serialization/resources/docs/types/ApiReferenceSectionConfiguration.ts @@ -9,27 +9,25 @@ import * as core from "../../../../core"; export const ApiReferenceSectionConfiguration: core.serialization.ObjectSchema< serializers.ApiReferenceSectionConfiguration.Raw, FernDocsConfig.ApiReferenceSectionConfiguration -> = core.serialization - .object({ - section: core.serialization.string(), - referencedPackages: core.serialization.property( - "referenced-packages", - core.serialization.list(core.serialization.string()).optional() - ), - summary: core.serialization.string().optional(), - contents: core.serialization - .list(core.serialization.lazy(async () => (await import("../../..")).ApiReferenceLayoutItem)) - .optional(), - slug: core.serialization.string().optional(), - icon: core.serialization.string().optional(), - hidden: core.serialization.boolean().optional(), - skipSlug: core.serialization.property("skip-slug", core.serialization.boolean().optional()), - playground: core.serialization.lazyObject(async () => (await import("../../..")).PlaygroundSettings).optional(), - }) - .extend(core.serialization.lazyObject(async () => (await import("../../..")).WithPermissions)); +> = core.serialization.object({ + section: core.serialization.string(), + referencedPackages: core.serialization.property( + "referenced-packages", + core.serialization.list(core.serialization.string()).optional() + ), + summary: core.serialization.string().optional(), + contents: core.serialization + .list(core.serialization.lazy(async () => (await import("../../..")).ApiReferenceLayoutItem)) + .optional(), + slug: core.serialization.string().optional(), + icon: core.serialization.string().optional(), + hidden: core.serialization.boolean().optional(), + skipSlug: core.serialization.property("skip-slug", core.serialization.boolean().optional()), + playground: core.serialization.lazyObject(async () => (await import("../../..")).PlaygroundSettings).optional(), +}); export declare namespace ApiReferenceSectionConfiguration { - interface Raw extends serializers.WithPermissions.Raw { + interface Raw { section: string; "referenced-packages"?: string[] | null; summary?: string | null; diff --git a/packages/cli/configuration/src/docs-yml/schemas/sdk/serialization/resources/docs/types/AudienceId.ts b/packages/cli/configuration/src/docs-yml/schemas/sdk/serialization/resources/docs/types/AudienceId.ts deleted file mode 100644 index 4e491752dd8..00000000000 --- a/packages/cli/configuration/src/docs-yml/schemas/sdk/serialization/resources/docs/types/AudienceId.ts +++ /dev/null @@ -1,14 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ - -import * as serializers from "../../.."; -import * as FernDocsConfig from "../../../../api"; -import * as core from "../../../../core"; - -export const AudienceId: core.serialization.Schema = - core.serialization.string(); - -export declare namespace AudienceId { - type Raw = string; -} diff --git a/packages/cli/configuration/src/docs-yml/schemas/sdk/serialization/resources/docs/types/AudiencesConfig.ts b/packages/cli/configuration/src/docs-yml/schemas/sdk/serialization/resources/docs/types/AudiencesConfig.ts new file mode 100644 index 00000000000..bff3ef57186 --- /dev/null +++ b/packages/cli/configuration/src/docs-yml/schemas/sdk/serialization/resources/docs/types/AudiencesConfig.ts @@ -0,0 +1,19 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../.."; +import * as FernDocsConfig from "../../../../api"; +import * as core from "../../../../core"; + +export const AudiencesConfig: core.serialization.Schema< + serializers.AudiencesConfig.Raw, + FernDocsConfig.AudiencesConfig +> = core.serialization.undiscriminatedUnion([ + core.serialization.string(), + core.serialization.list(core.serialization.string()), +]); + +export declare namespace AudiencesConfig { + type Raw = string | string[]; +} diff --git a/packages/cli/configuration/src/docs-yml/schemas/sdk/serialization/resources/docs/types/ChangelogConfiguration.ts b/packages/cli/configuration/src/docs-yml/schemas/sdk/serialization/resources/docs/types/ChangelogConfiguration.ts index 50282b0d4cc..363cd893de0 100644 --- a/packages/cli/configuration/src/docs-yml/schemas/sdk/serialization/resources/docs/types/ChangelogConfiguration.ts +++ b/packages/cli/configuration/src/docs-yml/schemas/sdk/serialization/resources/docs/types/ChangelogConfiguration.ts @@ -9,18 +9,16 @@ import * as core from "../../../../core"; export const ChangelogConfiguration: core.serialization.ObjectSchema< serializers.ChangelogConfiguration.Raw, FernDocsConfig.ChangelogConfiguration -> = core.serialization - .object({ - changelog: core.serialization.lazy(async () => (await import("../../..")).ChangelogFolderRelativePath), - title: core.serialization.string().optional(), - slug: core.serialization.string().optional(), - icon: core.serialization.string().optional(), - hidden: core.serialization.boolean().optional(), - }) - .extend(core.serialization.lazyObject(async () => (await import("../../..")).WithPermissions)); +> = core.serialization.object({ + changelog: core.serialization.lazy(async () => (await import("../../..")).ChangelogFolderRelativePath), + title: core.serialization.string().optional(), + slug: core.serialization.string().optional(), + icon: core.serialization.string().optional(), + hidden: core.serialization.boolean().optional(), +}); export declare namespace ChangelogConfiguration { - interface Raw extends serializers.WithPermissions.Raw { + interface Raw { changelog: serializers.ChangelogFolderRelativePath.Raw; title?: string | null; slug?: string | null; diff --git a/packages/cli/configuration/src/docs-yml/schemas/sdk/serialization/resources/docs/types/DocsConfiguration.ts b/packages/cli/configuration/src/docs-yml/schemas/sdk/serialization/resources/docs/types/DocsConfiguration.ts index 3f41fc40938..2627e797fd9 100644 --- a/packages/cli/configuration/src/docs-yml/schemas/sdk/serialization/resources/docs/types/DocsConfiguration.ts +++ b/packages/cli/configuration/src/docs-yml/schemas/sdk/serialization/resources/docs/types/DocsConfiguration.ts @@ -16,7 +16,6 @@ export const DocsConfiguration: core.serialization.ObjectSchema< title: core.serialization.string().optional(), analytics: core.serialization.lazyObject(async () => (await import("../../..")).AnalyticsConfig).optional(), announcement: core.serialization.lazyObject(async () => (await import("../../..")).AnnouncementConfig).optional(), - roles: core.serialization.list(core.serialization.lazy(async () => (await import("../../..")).RoleId)).optional(), tabs: core.serialization .record( core.serialization.lazy(async () => (await import("../../..")).TabId), @@ -68,7 +67,6 @@ export declare namespace DocsConfiguration { title?: string | null; analytics?: serializers.AnalyticsConfig.Raw | null; announcement?: serializers.AnnouncementConfig.Raw | null; - roles?: serializers.RoleId.Raw[] | null; tabs?: Record | null; versions?: serializers.VersionConfig.Raw[] | null; "landing-page"?: serializers.PageConfiguration.Raw | null; diff --git a/packages/cli/configuration/src/docs-yml/schemas/sdk/serialization/resources/docs/types/DocsInstance.ts b/packages/cli/configuration/src/docs-yml/schemas/sdk/serialization/resources/docs/types/DocsInstance.ts index 260c6eeaf4b..fd1064f4ae0 100644 --- a/packages/cli/configuration/src/docs-yml/schemas/sdk/serialization/resources/docs/types/DocsInstance.ts +++ b/packages/cli/configuration/src/docs-yml/schemas/sdk/serialization/resources/docs/types/DocsInstance.ts @@ -13,6 +13,7 @@ export const DocsInstance: core.serialization.ObjectSchema (await import("../../..")).CustomDomain).optional() ), + audiences: core.serialization.lazy(async () => (await import("../../..")).AudiencesConfig).optional(), private: core.serialization.boolean().optional(), editThisPage: core.serialization.property( "edit-this-page", @@ -24,6 +25,7 @@ export declare namespace DocsInstance { interface Raw { url: string; "custom-domain"?: serializers.CustomDomain.Raw | null; + audiences?: serializers.AudiencesConfig.Raw | null; private?: boolean | null; "edit-this-page"?: serializers.EditThisPageConfig.Raw | null; } diff --git a/packages/cli/configuration/src/docs-yml/schemas/sdk/serialization/resources/docs/types/PageConfiguration.ts b/packages/cli/configuration/src/docs-yml/schemas/sdk/serialization/resources/docs/types/PageConfiguration.ts index 7a4cedfa292..ef9314b1b1e 100644 --- a/packages/cli/configuration/src/docs-yml/schemas/sdk/serialization/resources/docs/types/PageConfiguration.ts +++ b/packages/cli/configuration/src/docs-yml/schemas/sdk/serialization/resources/docs/types/PageConfiguration.ts @@ -9,18 +9,16 @@ import * as core from "../../../../core"; export const PageConfiguration: core.serialization.ObjectSchema< serializers.PageConfiguration.Raw, FernDocsConfig.PageConfiguration -> = core.serialization - .object({ - page: core.serialization.string(), - path: core.serialization.string(), - slug: core.serialization.string().optional(), - icon: core.serialization.string().optional(), - hidden: core.serialization.boolean().optional(), - }) - .extend(core.serialization.lazyObject(async () => (await import("../../..")).WithPermissions)); +> = core.serialization.object({ + page: core.serialization.string(), + path: core.serialization.string(), + slug: core.serialization.string().optional(), + icon: core.serialization.string().optional(), + hidden: core.serialization.boolean().optional(), +}); export declare namespace PageConfiguration { - interface Raw extends serializers.WithPermissions.Raw { + interface Raw { page: string; path: string; slug?: string | null; diff --git a/packages/cli/configuration/src/docs-yml/schemas/sdk/serialization/resources/docs/types/Role.ts b/packages/cli/configuration/src/docs-yml/schemas/sdk/serialization/resources/docs/types/Role.ts deleted file mode 100644 index 41516cefe43..00000000000 --- a/packages/cli/configuration/src/docs-yml/schemas/sdk/serialization/resources/docs/types/Role.ts +++ /dev/null @@ -1,17 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ - -import * as serializers from "../../.."; -import * as FernDocsConfig from "../../../../api"; -import * as core from "../../../../core"; - -export const Role: core.serialization.Schema = - core.serialization.undiscriminatedUnion([ - core.serialization.lazy(async () => (await import("../../..")).RoleId), - core.serialization.list(core.serialization.lazy(async () => (await import("../../..")).RoleId)), - ]); - -export declare namespace Role { - type Raw = serializers.RoleId.Raw | serializers.RoleId.Raw[]; -} diff --git a/packages/cli/configuration/src/docs-yml/schemas/sdk/serialization/resources/docs/types/RoleId.ts b/packages/cli/configuration/src/docs-yml/schemas/sdk/serialization/resources/docs/types/RoleId.ts deleted file mode 100644 index 12eeced44cf..00000000000 --- a/packages/cli/configuration/src/docs-yml/schemas/sdk/serialization/resources/docs/types/RoleId.ts +++ /dev/null @@ -1,14 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ - -import * as serializers from "../../.."; -import * as FernDocsConfig from "../../../../api"; -import * as core from "../../../../core"; - -export const RoleId: core.serialization.Schema = - core.serialization.string(); - -export declare namespace RoleId { - type Raw = string; -} diff --git a/packages/cli/configuration/src/docs-yml/schemas/sdk/serialization/resources/docs/types/SectionConfiguration.ts b/packages/cli/configuration/src/docs-yml/schemas/sdk/serialization/resources/docs/types/SectionConfiguration.ts index 61b0ec7169f..0952825b74c 100644 --- a/packages/cli/configuration/src/docs-yml/schemas/sdk/serialization/resources/docs/types/SectionConfiguration.ts +++ b/packages/cli/configuration/src/docs-yml/schemas/sdk/serialization/resources/docs/types/SectionConfiguration.ts @@ -9,23 +9,19 @@ import * as core from "../../../../core"; export const SectionConfiguration: core.serialization.ObjectSchema< serializers.SectionConfiguration.Raw, FernDocsConfig.SectionConfiguration -> = core.serialization - .object({ - section: core.serialization.string(), - path: core.serialization.string().optional(), - contents: core.serialization.list( - core.serialization.lazy(async () => (await import("../../..")).NavigationItem) - ), - collapsed: core.serialization.boolean().optional(), - slug: core.serialization.string().optional(), - icon: core.serialization.string().optional(), - hidden: core.serialization.boolean().optional(), - skipSlug: core.serialization.property("skip-slug", core.serialization.boolean().optional()), - }) - .extend(core.serialization.lazyObject(async () => (await import("../../..")).WithPermissions)); +> = core.serialization.object({ + section: core.serialization.string(), + path: core.serialization.string().optional(), + contents: core.serialization.list(core.serialization.lazy(async () => (await import("../../..")).NavigationItem)), + collapsed: core.serialization.boolean().optional(), + slug: core.serialization.string().optional(), + icon: core.serialization.string().optional(), + hidden: core.serialization.boolean().optional(), + skipSlug: core.serialization.property("skip-slug", core.serialization.boolean().optional()), +}); export declare namespace SectionConfiguration { - interface Raw extends serializers.WithPermissions.Raw { + interface Raw { section: string; path?: string | null; contents: serializers.NavigationItem.Raw[]; diff --git a/packages/cli/configuration/src/docs-yml/schemas/sdk/serialization/resources/docs/types/TabConfig.ts b/packages/cli/configuration/src/docs-yml/schemas/sdk/serialization/resources/docs/types/TabConfig.ts index 0cc1318c2d2..0cb1351f0d8 100644 --- a/packages/cli/configuration/src/docs-yml/schemas/sdk/serialization/resources/docs/types/TabConfig.ts +++ b/packages/cli/configuration/src/docs-yml/schemas/sdk/serialization/resources/docs/types/TabConfig.ts @@ -7,22 +7,20 @@ import * as FernDocsConfig from "../../../../api"; import * as core from "../../../../core"; export const TabConfig: core.serialization.ObjectSchema = - core.serialization - .object({ - displayName: core.serialization.property("display-name", core.serialization.string()), - icon: core.serialization.string().optional(), - slug: core.serialization.string().optional(), - skipSlug: core.serialization.property("skip-slug", core.serialization.boolean().optional()), - hidden: core.serialization.boolean().optional(), - href: core.serialization.string().optional(), - changelog: core.serialization - .lazy(async () => (await import("../../..")).ChangelogFolderRelativePath) - .optional(), - }) - .extend(core.serialization.lazyObject(async () => (await import("../../..")).WithPermissions)); + core.serialization.object({ + displayName: core.serialization.property("display-name", core.serialization.string()), + icon: core.serialization.string().optional(), + slug: core.serialization.string().optional(), + skipSlug: core.serialization.property("skip-slug", core.serialization.boolean().optional()), + hidden: core.serialization.boolean().optional(), + href: core.serialization.string().optional(), + changelog: core.serialization + .lazy(async () => (await import("../../..")).ChangelogFolderRelativePath) + .optional(), + }); export declare namespace TabConfig { - interface Raw extends serializers.WithPermissions.Raw { + interface Raw { "display-name": string; icon?: string | null; slug?: string | null; diff --git a/packages/cli/configuration/src/docs-yml/schemas/sdk/serialization/resources/docs/types/VersionConfig.ts b/packages/cli/configuration/src/docs-yml/schemas/sdk/serialization/resources/docs/types/VersionConfig.ts index ac2a7f76bb1..1a37768d4c0 100644 --- a/packages/cli/configuration/src/docs-yml/schemas/sdk/serialization/resources/docs/types/VersionConfig.ts +++ b/packages/cli/configuration/src/docs-yml/schemas/sdk/serialization/resources/docs/types/VersionConfig.ts @@ -9,17 +9,15 @@ import * as core from "../../../../core"; export const VersionConfig: core.serialization.ObjectSchema< serializers.VersionConfig.Raw, FernDocsConfig.VersionConfig -> = core.serialization - .object({ - displayName: core.serialization.property("display-name", core.serialization.string()), - path: core.serialization.string(), - slug: core.serialization.string().optional(), - availability: core.serialization.lazy(async () => (await import("../../..")).VersionAvailability).optional(), - }) - .extend(core.serialization.lazyObject(async () => (await import("../../..")).WithPermissions)); +> = core.serialization.object({ + displayName: core.serialization.property("display-name", core.serialization.string()), + path: core.serialization.string(), + slug: core.serialization.string().optional(), + availability: core.serialization.lazy(async () => (await import("../../..")).VersionAvailability).optional(), +}); export declare namespace VersionConfig { - interface Raw extends serializers.WithPermissions.Raw { + interface Raw { "display-name": string; path: string; slug?: string | null; diff --git a/packages/cli/configuration/src/docs-yml/schemas/sdk/serialization/resources/docs/types/WithPermissions.ts b/packages/cli/configuration/src/docs-yml/schemas/sdk/serialization/resources/docs/types/WithPermissions.ts deleted file mode 100644 index 23d1d775558..00000000000 --- a/packages/cli/configuration/src/docs-yml/schemas/sdk/serialization/resources/docs/types/WithPermissions.ts +++ /dev/null @@ -1,22 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ - -import * as serializers from "../../.."; -import * as FernDocsConfig from "../../../../api"; -import * as core from "../../../../core"; - -export const WithPermissions: core.serialization.ObjectSchema< - serializers.WithPermissions.Raw, - FernDocsConfig.WithPermissions -> = core.serialization.object({ - viewers: core.serialization.lazy(async () => (await import("../../..")).Role).optional(), - orphaned: core.serialization.boolean().optional(), -}); - -export declare namespace WithPermissions { - interface Raw { - viewers?: serializers.Role.Raw | null; - orphaned?: boolean | null; - } -} diff --git a/packages/cli/configuration/src/docs-yml/schemas/sdk/serialization/resources/docs/types/index.ts b/packages/cli/configuration/src/docs-yml/schemas/sdk/serialization/resources/docs/types/index.ts index a3b35a5ecd3..0db7bd06ec1 100644 --- a/packages/cli/configuration/src/docs-yml/schemas/sdk/serialization/resources/docs/types/index.ts +++ b/packages/cli/configuration/src/docs-yml/schemas/sdk/serialization/resources/docs/types/index.ts @@ -12,6 +12,7 @@ export * from "./DocsInstance"; export * from "./CustomDomain"; export * from "./EditThisPageConfig"; export * from "./GithubEditThisPageConfig"; +export * from "./AudiencesConfig"; export * from "./VersionConfig"; export * from "./VersionAvailability"; export * from "./VersionFileConfig"; @@ -29,10 +30,6 @@ export * from "./SearchbarPlacement"; export * from "./TabsPlacement"; export * from "./ContentAlignment"; export * from "./HeaderPosition"; -export * from "./AudienceId"; -export * from "./RoleId"; -export * from "./Role"; -export * from "./WithPermissions"; export * from "./FontConfig"; export * from "./FontWeight"; export * from "./FontStyle"; diff --git a/packages/cli/configuration/src/generators-yml/schemas/core/schemas/utils/isPlainObject.ts b/packages/cli/configuration/src/generators-yml/schemas/core/schemas/utils/isPlainObject.ts index abd6422ae86..db82a722c35 100644 --- a/packages/cli/configuration/src/generators-yml/schemas/core/schemas/utils/isPlainObject.ts +++ b/packages/cli/configuration/src/generators-yml/schemas/core/schemas/utils/isPlainObject.ts @@ -1,15 +1,15 @@ // borrowed from https://github.com/lodash/lodash/blob/master/isPlainObject.js export function isPlainObject(value: unknown): value is Record { - if (typeof value !== "object" || value == null) { + if (typeof value !== "object" || value === null) { return false; } - if (Object.getPrototypeOf(value) == null) { + if (Object.getPrototypeOf(value) === null) { return true; } let proto = value; - while (Object.getPrototypeOf(proto) != null) { + while (Object.getPrototypeOf(proto) !== null) { proto = Object.getPrototypeOf(proto); } diff --git a/packages/cli/docs-importers/commons/package.json b/packages/cli/docs-importers/commons/package.json index ac424ff9440..45a3b785bb4 100644 --- a/packages/cli/docs-importers/commons/package.json +++ b/packages/cli/docs-importers/commons/package.json @@ -31,7 +31,7 @@ "@fern-api/configuration": "workspace:*", "@fern-api/fs-utils": "workspace:*", "@fern-api/task-context": "workspace:*", - "@fern-fern/fdr-cjs-sdk": "0.119.0-d531a5553", + "@fern-fern/fdr-cjs-sdk": "0.111.0-51d403bce", "js-yaml": "^4.1.0" }, "devDependencies": { @@ -45,4 +45,4 @@ "typescript": "4.6.4", "vitest": "^2.0.5" } -} +} \ No newline at end of file diff --git a/packages/cli/docs-importers/mintlify/package.json b/packages/cli/docs-importers/mintlify/package.json index 8d4fdf02447..cfdb47b4b45 100644 --- a/packages/cli/docs-importers/mintlify/package.json +++ b/packages/cli/docs-importers/mintlify/package.json @@ -34,7 +34,7 @@ "@fern-api/task-context": "workspace:*", "@fern-api/fs-utils": "workspace:*", "@fern-api/logger": "workspace:*", - "@fern-fern/fdr-cjs-sdk": "0.119.0-d531a5553", + "@fern-fern/fdr-cjs-sdk": "0.111.0-51d403bce", "gray-matter": "^4.0.3" }, "devDependencies": { @@ -47,4 +47,4 @@ "typescript": "4.6.4", "vitest": "^2.0.5" } -} +} \ No newline at end of file diff --git a/packages/cli/docs-importers/mintlify/src/convertMarkdown.ts b/packages/cli/docs-importers/mintlify/src/convertMarkdown.ts index 8c2afe29529..2f3c00a03d5 100644 --- a/packages/cli/docs-importers/mintlify/src/convertMarkdown.ts +++ b/packages/cli/docs-importers/mintlify/src/convertMarkdown.ts @@ -1,7 +1,7 @@ import grayMatter from "gray-matter"; import { MintlifyFrontmatter } from "./mintlify"; import { readFile } from "fs/promises"; -import { FernRegistry as CjsFdrSdk, FernRegistry } from "@fern-fern/fdr-cjs-sdk"; +import { FernRegistry as CjsFdrSdk } from "@fern-fern/fdr-cjs-sdk"; import { AbsoluteFilePath, dirname, join, RelativeFilePath, relativize } from "@fern-api/fs-utils"; import { FernDocsBuilder } from "@fern-api/docs-importer-commons"; @@ -49,39 +49,7 @@ export async function convertMarkdown({ layout: data.mode != null ? "reference" : undefined, // eslint-disable-next-line @typescript-eslint/no-explicit-any image: data["og:image"] as any, - slug: FernRegistry.navigation.latest.Slug(slug), - - // TODO: check if any of these can be set: - headline: undefined, - description: undefined, - "edit-this-page-url": undefined, - "hide-toc": undefined, - "hide-feedback": undefined, - "no-image-zoom": undefined, - "force-toc": undefined, - "hide-nav-links": undefined, - breadcrumb: undefined, - excerpt: undefined, - "canonical-url": undefined, - "og:site_name": undefined, - "og:title": undefined, - "og:description": undefined, - "og:url": undefined, - "og:image": undefined, - "og:image:width": undefined, - "og:image:height": undefined, - "og:locale": undefined, - "og:logo": undefined, - "twitter:title": undefined, - "twitter:description": undefined, - "twitter:handle": undefined, - "twitter:image": undefined, - "twitter:site": undefined, - "twitter:url": undefined, - "twitter:card": undefined, - noindex: undefined, - nofollow: undefined, - "jsonld:breadcrumb": undefined + slug }, content: transformedContent }; diff --git a/packages/cli/docs-markdown-utils/package.json b/packages/cli/docs-markdown-utils/package.json index daec12ec50e..dad386697f9 100644 --- a/packages/cli/docs-markdown-utils/package.json +++ b/packages/cli/docs-markdown-utils/package.json @@ -30,7 +30,7 @@ "dependencies": { "@fern-api/fs-utils": "workspace:*", "@fern-api/task-context": "workspace:*", - "@fern-fern/fdr-cjs-sdk": "0.119.0-d531a5553", + "@fern-fern/fdr-cjs-sdk": "0.0.5833", "gray-matter": "^4.0.3", "mdast-util-from-markdown": "^2.0.1", "mdast-util-mdx": "^3.0.0", @@ -49,4 +49,4 @@ "typescript": "4.6.4", "vitest": "^2.0.5" } -} +} \ No newline at end of file diff --git a/packages/cli/docs-preview/package.json b/packages/cli/docs-preview/package.json index f5bb2089e33..49df2911409 100644 --- a/packages/cli/docs-preview/package.json +++ b/packages/cli/docs-preview/package.json @@ -29,7 +29,7 @@ }, "dependencies": { "@fern-api/docs-resolver": "workspace:*", - "@fern-api/fdr-sdk": "0.119.0-d531a5553", + "@fern-api/fdr-sdk": "0.115.0-3cf21db72", "@fern-api/fs-utils": "workspace:*", "@fern-api/ir-sdk": "workspace:*", "@fern-api/logger": "workspace:*", diff --git a/packages/cli/docs-preview/src/runPreviewServer.ts b/packages/cli/docs-preview/src/runPreviewServer.ts index dd2ae69729d..855b40ae344 100644 --- a/packages/cli/docs-preview/src/runPreviewServer.ts +++ b/packages/cli/docs-preview/src/runPreviewServer.ts @@ -19,8 +19,10 @@ const EMPTY_DOCS_DEFINITION: DocsV1Read.DocsDefinition = { files: {}, filesV2: {}, config: { - navigation: undefined, - root: undefined, + navigation: { + landingPage: undefined, + items: [] + }, title: undefined, defaultLanguage: undefined, announcement: undefined, @@ -113,7 +115,7 @@ export async function runPreviewServer({ app.use(cors()); const instance = new URL( - wrapWithHttps(initialProject.docsWorkspaces?.config.instances[0]?.url ?? `http://localhost:${port}`) + wrapWithHttps(initialProject.docsWorkspaces?.config.instances[0]?.url ?? `localhost:${port}`) ); let project = initialProject; diff --git a/packages/cli/docs-resolver/.vscode/settings.json b/packages/cli/docs-resolver/.vscode/settings.json deleted file mode 100644 index 25fa6215fdd..00000000000 --- a/packages/cli/docs-resolver/.vscode/settings.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "typescript.tsdk": "node_modules/typescript/lib" -} diff --git a/packages/cli/docs-resolver/package.json b/packages/cli/docs-resolver/package.json index 45b4a950e2b..7ca162546df 100644 --- a/packages/cli/docs-resolver/package.json +++ b/packages/cli/docs-resolver/package.json @@ -30,8 +30,8 @@ "@fern-api/configuration": "workspace:*", "@fern-api/core-utils": "workspace:*", "@fern-api/docs-markdown-utils": "workspace:*", - "@fern-api/fdr-sdk": "0.119.0-d531a5553", - "@fern-api/ui-core-utils": "0.119.0-d531a5553", + "@fern-api/fdr-sdk": "0.115.0-3cf21db72", + "@fern-api/ui-core-utils": "0.115.0-3cf21db72", "@fern-api/fs-utils": "workspace:*", "@fern-api/ir-generator": "workspace:*", "@fern-api/ir-sdk": "workspace:*", @@ -54,4 +54,4 @@ "typescript": "4.6.4", "vitest": "^2.0.5" } -} +} \ No newline at end of file diff --git a/packages/cli/docs-resolver/src/ApiReferenceNodeConverter.ts b/packages/cli/docs-resolver/src/ApiReferenceNodeConverter.ts index 0a0e9e9d07a..b0a97fa124b 100644 --- a/packages/cli/docs-resolver/src/ApiReferenceNodeConverter.ts +++ b/packages/cli/docs-resolver/src/ApiReferenceNodeConverter.ts @@ -24,7 +24,6 @@ export class ApiReferenceNodeConverter { #children: FernNavigation.V1.ApiPackageChild[] = []; #overviewPageId: FernNavigation.V1.PageId | undefined; #slug: FernNavigation.V1.SlugGenerator; - #idgen: NodeIdGenerator; private disableEndpointPairs; constructor( private apiSection: docsYml.DocsNavigationItem.ApiSection, @@ -33,15 +32,14 @@ export class ApiReferenceNodeConverter { private workspace: FernWorkspace, private docsWorkspace: DocsWorkspace, private taskContext: TaskContext, - private markdownFilesToFullSlugs: Map, - idgen: NodeIdGenerator + private markdownFilesToFullSlugs: Map ) { this.disableEndpointPairs = docsWorkspace.config.experimental?.disableStreamToggle ?? false; this.apiDefinitionId = FernNavigation.V1.ApiDefinitionId(api.id); this.#holder = ApiDefinitionHolder.create(api, taskContext); // we are assuming that the apiDefinitionId is unique. - this.#idgen = idgen; + const idgen = NodeIdGenerator.init(this.apiDefinitionId); this.#overviewPageId = this.apiSection.overviewAbsolutePath != null @@ -65,7 +63,8 @@ export class ApiReferenceNodeConverter { this.#children = this.#convertApiReferenceLayoutItems( this.apiSection.navigation, this.#holder.api.rootPackage, - this.#slug + this.#slug, + idgen ); } @@ -78,14 +77,9 @@ export class ApiReferenceNodeConverter { public get(): FernNavigation.V1.ApiReferenceNode { const pointsTo = FernNavigation.V1.followRedirects(this.#children); - const changelogNodeConverter = new ChangelogNodeConverter( - this.markdownFilesToFullSlugs, - this.workspace.changelog?.files.map((file) => file.absoluteFilepath), - this.docsWorkspace, - this.#idgen - ).orUndefined(); + const idgen = NodeIdGenerator.init(this.apiDefinitionId); return { - id: this.#idgen.get(this.apiDefinitionId), + id: idgen.get(), type: "apiReference", title: this.apiSection.title, apiDefinitionId: this.apiDefinitionId, @@ -96,18 +90,19 @@ export class ApiReferenceNodeConverter { hidden: this.apiSection.hidden, hideTitle: this.apiSection.flattened, showErrors: this.apiSection.showErrors, - changelog: changelogNodeConverter?.toChangelogNode({ - parentSlug: this.#slug, - viewers: undefined + changelog: new ChangelogNodeConverter( + this.markdownFilesToFullSlugs, + this.workspace.changelog?.files.map((file) => file.absoluteFilepath), + this.docsWorkspace, + idgen + ).convert({ + parentSlug: this.#slug }), children: this.#children, availability: undefined, pointsTo, noindex: undefined, - playground: this.#convertPlaygroundSettings(this.apiSection.playground), - authed: undefined, - viewers: this.apiSection.viewers, - orphaned: this.apiSection.orphaned + playground: this.#convertPlaygroundSettings(this.apiSection.playground) }; } @@ -116,7 +111,8 @@ export class ApiReferenceNodeConverter { #convertApiReferenceLayoutItems( navigation: docsYml.ParsedApiReferenceLayoutItem[], apiDefinitionPackage: APIV1Read.ApiDefinitionPackage | undefined, - parentSlug: FernNavigation.V1.SlugGenerator + parentSlug: FernNavigation.V1.SlugGenerator, + idgen: NodeIdGenerator ): FernNavigation.V1.ApiPackageChild[] { apiDefinitionPackage = this.#holder.resolveSubpackage(apiDefinitionPackage); const apiDefinitionPackageId = @@ -125,50 +121,43 @@ export class ApiReferenceNodeConverter { .map((item) => visitDiscriminatedUnion(item)._visit({ link: (link) => ({ - id: this.#idgen.get(link.url), + id: idgen.append(`link:${link.url}`).get(), type: "link", title: link.text, icon: link.icon, url: FernNavigation.Url(link.url) }), - page: (page) => this.#toPageNode(page, parentSlug), - package: (pkg) => this.#convertPackage(pkg, parentSlug), - section: (section) => this.#convertSection(section, parentSlug), + page: (page) => { + const pageId = FernNavigation.V1.PageId(this.toRelativeFilepath(page.absolutePath)); + const pageSlug = parentSlug.apply({ + fullSlug: this.markdownFilesToFullSlugs.get(page.absolutePath)?.split("/"), + urlSlug: page.slug ?? kebabCase(page.title) + }); + return { + id: idgen.append(`page:${pageId}`).get(), + type: "page", + pageId, + title: page.title, + slug: pageSlug.get(), + icon: page.icon, + hidden: page.hidden, + noindex: page.noindex + }; + }, + package: (pkg) => this.#convertPackage(pkg, parentSlug, idgen), + section: (section) => this.#convertSection(section, parentSlug, idgen), item: ({ value: unknownIdentifier }): FernNavigation.V1.ApiPackageChild | undefined => - this.#convertUnknownIdentifier(unknownIdentifier, apiDefinitionPackageId, parentSlug), - endpoint: (endpoint) => this.#convertEndpoint(endpoint, apiDefinitionPackageId, parentSlug) + this.#convertUnknownIdentifier(unknownIdentifier, apiDefinitionPackageId, parentSlug, idgen), + endpoint: (endpoint) => this.#convertEndpoint(endpoint, apiDefinitionPackageId, parentSlug, idgen) }) ) .filter(isNonNullish); } - #toPageNode( - page: docsYml.DocsNavigationItem.Page, - parentSlug: FernNavigation.V1.SlugGenerator - ): FernNavigation.V1.PageNode { - const pageId = FernNavigation.V1.PageId(this.toRelativeFilepath(page.absolutePath)); - const pageSlug = parentSlug.apply({ - fullSlug: this.markdownFilesToFullSlugs.get(page.absolutePath)?.split("/"), - urlSlug: page.slug ?? kebabCase(page.title) - }); - return { - id: this.#idgen.get(pageId), - type: "page", - pageId, - title: page.title, - slug: pageSlug.get(), - icon: page.icon, - hidden: page.hidden, - noindex: page.noindex, - authed: undefined, - viewers: page.viewers, - orphaned: page.orphaned - }; - } - #convertPackage( pkg: docsYml.ParsedApiReferenceLayoutItem.Package, - parentSlug: FernNavigation.V1.SlugGenerator + parentSlug: FernNavigation.V1.SlugGenerator, + idgen: NodeIdGenerator ): FernNavigation.V1.ApiPackageNode { const overviewPageId = pkg.overviewAbsolutePath != null @@ -182,7 +171,7 @@ export class ApiReferenceNodeConverter { if (subpackage != null) { const subpackageId = ApiDefinitionHolder.getSubpackageId(subpackage); - const subpackageNodeId = this.#idgen.get(overviewPageId ?? `${this.apiDefinitionId}:${subpackageId}`); + const subpackageNodeId = idgen.append(subpackageId); if (this.#visitedSubpackages.has(subpackageId)) { this.taskContext.logger.error( @@ -191,7 +180,7 @@ export class ApiReferenceNodeConverter { } this.#visitedSubpackages.add(subpackageId); - this.#nodeIdToSubpackageId.set(subpackageNodeId, [subpackageId]); + this.#nodeIdToSubpackageId.set(subpackageNodeId.get(), [subpackageId]); const urlSlug = pkg.slug ?? (isSubpackage(subpackage) @@ -202,9 +191,14 @@ export class ApiReferenceNodeConverter { skipUrlSlug: pkg.skipUrlSlug, urlSlug }); - const convertedItems = this.#convertApiReferenceLayoutItems(pkg.contents, subpackage, slug); + const convertedItems = this.#convertApiReferenceLayoutItems( + pkg.contents, + subpackage, + slug, + subpackageNodeId + ); return { - id: subpackageNodeId, + id: subpackageNodeId.get(), type: "apiPackage", children: convertedItems, title: @@ -220,10 +214,7 @@ export class ApiReferenceNodeConverter { apiDefinitionId: this.apiDefinitionId, pointsTo: undefined, noindex: undefined, - playground: this.#convertPlaygroundSettings(pkg.playground), - authed: undefined, - viewers: pkg.viewers, - orphaned: pkg.orphaned + playground: this.#convertPlaygroundSettings(pkg.playground) }; } else { this.taskContext.logger.warn( @@ -235,9 +226,9 @@ export class ApiReferenceNodeConverter { skipUrlSlug: pkg.skipUrlSlug, urlSlug }); - const convertedItems = this.#convertApiReferenceLayoutItems(pkg.contents, undefined, slug); + const convertedItems = this.#convertApiReferenceLayoutItems(pkg.contents, undefined, slug, idgen); return { - id: this.#idgen.get(overviewPageId ?? `${this.apiDefinitionId}:${kebabCase(pkg.package)}`), + id: idgen.append(kebabCase(pkg.package)).get(), type: "apiPackage", children: convertedItems, title: pkg.title ?? pkg.package, @@ -249,17 +240,15 @@ export class ApiReferenceNodeConverter { apiDefinitionId: this.apiDefinitionId, pointsTo: undefined, noindex: undefined, - playground: this.#convertPlaygroundSettings(pkg.playground), - authed: undefined, - viewers: pkg.viewers, - orphaned: pkg.orphaned + playground: this.#convertPlaygroundSettings(pkg.playground) }; } } #convertSection( section: docsYml.ParsedApiReferenceLayoutItem.Section, - parentSlug: FernNavigation.V1.SlugGenerator + parentSlug: FernNavigation.V1.SlugGenerator, + idgen: NodeIdGenerator ): FernNavigation.V1.ApiPackageNode { const overviewPageId = section.overviewAbsolutePath != null @@ -271,7 +260,7 @@ export class ApiReferenceNodeConverter { ? this.markdownFilesToFullSlugs.get(section.overviewAbsolutePath) : undefined; - const nodeId = this.#idgen.get(overviewPageId ?? maybeFullSlug ?? parentSlug.get()); + const nodeId = idgen.append(`section:${kebabCase(section.title)}`); const subpackageIds = section.referencedSubpackages .map((locator) => { @@ -286,7 +275,7 @@ export class ApiReferenceNodeConverter { }) .filter(isNonNullish); - this.#nodeIdToSubpackageId.set(nodeId, subpackageIds); + this.#nodeIdToSubpackageId.set(nodeId.get(), subpackageIds); subpackageIds.forEach((subpackageId) => { if (this.#visitedSubpackages.has(subpackageId)) { this.taskContext.logger.error( @@ -302,9 +291,9 @@ export class ApiReferenceNodeConverter { skipUrlSlug: section.skipUrlSlug, urlSlug }); - const convertedItems = this.#convertApiReferenceLayoutItems(section.contents, undefined, slug); + const convertedItems = this.#convertApiReferenceLayoutItems(section.contents, undefined, slug, idgen); return { - id: nodeId, + id: nodeId.get(), type: "apiPackage", children: convertedItems, title: section.title, @@ -316,17 +305,15 @@ export class ApiReferenceNodeConverter { apiDefinitionId: this.apiDefinitionId, pointsTo: undefined, noindex: undefined, - playground: this.#convertPlaygroundSettings(section.playground), - authed: undefined, - viewers: section.viewers, - orphaned: section.orphaned + playground: this.#convertPlaygroundSettings(section.playground) }; } #convertUnknownIdentifier( unknownIdentifier: string, apiDefinitionPackageId: string | undefined, - parentSlug: FernNavigation.V1.SlugGenerator + parentSlug: FernNavigation.V1.SlugGenerator, + idgen: NodeIdGenerator ): FernNavigation.V1.ApiPackageChild | undefined { unknownIdentifier = unknownIdentifier.trim(); // unknownIdentifier could either be a package, endpoint, websocket, or webhook. @@ -334,7 +321,7 @@ export class ApiReferenceNodeConverter { const subpackage = this.#holder.getSubpackageByIdOrLocator(unknownIdentifier); if (subpackage != null) { const subpackageId = ApiDefinitionHolder.getSubpackageId(subpackage); - const subpackageNodeId = this.#idgen.get(`${this.apiDefinitionId}:${subpackageId}`); + const subpackageNodeId = idgen.append(subpackageId); if (this.#visitedSubpackages.has(subpackageId)) { this.taskContext.logger.error( @@ -343,11 +330,11 @@ export class ApiReferenceNodeConverter { } this.#visitedSubpackages.add(subpackageId); - this.#nodeIdToSubpackageId.set(subpackageNodeId, [subpackageId]); + this.#nodeIdToSubpackageId.set(subpackageNodeId.get(), [subpackageId]); const urlSlug = isSubpackage(subpackage) ? subpackage.urlSlug : ""; const slug = parentSlug.apply({ urlSlug }); return { - id: subpackageNodeId, + id: subpackageNodeId.get(), type: "apiPackage", children: [], title: isSubpackage(subpackage) @@ -361,10 +348,7 @@ export class ApiReferenceNodeConverter { apiDefinitionId: this.apiDefinitionId, pointsTo: undefined, noindex: undefined, - playground: undefined, - authed: undefined, - viewers: undefined, - orphaned: undefined + playground: undefined }; } @@ -377,19 +361,19 @@ export class ApiReferenceNodeConverter { icon: undefined, slug: undefined, hidden: undefined, - playground: undefined, - viewers: undefined, - orphaned: undefined + playground: undefined }, apiDefinitionPackageId, - parentSlug + parentSlug, + idgen ); } #convertEndpoint( endpointItem: docsYml.ParsedApiReferenceLayoutItem.Endpoint, apiDefinitionPackageIdRaw: string | undefined, - parentSlug: FernNavigation.V1.SlugGenerator + parentSlug: FernNavigation.V1.SlugGenerator, + idgen: NodeIdGenerator ): FernNavigation.V1.ApiPackageChild | undefined { const endpoint = (apiDefinitionPackageIdRaw != null @@ -409,7 +393,7 @@ export class ApiReferenceNodeConverter { const endpointSlug = endpointItem.slug != null ? parentSlug.append(endpointItem.slug) : parentSlug.apply(endpoint); return { - id: this.#idgen.get(`${this.apiDefinitionId}:${endpointId}`), + id: idgen.append(endpoint.id).get(), type: "endpoint", method: endpoint.method, endpointId, @@ -420,10 +404,7 @@ export class ApiReferenceNodeConverter { slug: endpointSlug.get(), icon: endpointItem.icon, hidden: endpointItem.hidden, - playground: this.#convertPlaygroundSettings(endpointItem.playground), - authed: undefined, - viewers: endpointItem.viewers, - orphaned: endpointItem.orphaned + playground: this.#convertPlaygroundSettings(endpointItem.playground) }; } @@ -444,7 +425,7 @@ export class ApiReferenceNodeConverter { } this.#visitedWebSockets.add(webSocketId); return { - id: this.#idgen.get(`${this.apiDefinitionId}:${webSocketId}`), + id: idgen.append(webSocket.id).get(), type: "webSocket", webSocketId, title: endpointItem.title ?? webSocket.name ?? stringifyEndpointPathParts(webSocket.path.parts), @@ -456,10 +437,7 @@ export class ApiReferenceNodeConverter { hidden: endpointItem.hidden, apiDefinitionId: this.apiDefinitionId, availability: FernNavigation.V1.convertAvailability(webSocket.availability), - playground: this.#convertPlaygroundSettings(endpointItem.playground), - authed: undefined, - viewers: endpointItem.viewers, - orphaned: endpointItem.orphaned + playground: this.#convertPlaygroundSettings(endpointItem.playground) }; } @@ -480,7 +458,7 @@ export class ApiReferenceNodeConverter { } this.#visitedWebhooks.add(webhookId); return { - id: this.#idgen.get(`${this.apiDefinitionId}:${webhookId}`), + id: idgen.append(webhook.id).get(), type: "webhook", webhookId, method: webhook.method, @@ -492,10 +470,7 @@ export class ApiReferenceNodeConverter { icon: endpointItem.icon, hidden: endpointItem.hidden, apiDefinitionId: this.apiDefinitionId, - availability: undefined, - authed: undefined, - viewers: endpointItem.viewers, - orphaned: endpointItem.orphaned + availability: undefined }; } @@ -533,7 +508,7 @@ export class ApiReferenceNodeConverter { return { ...child, children, - pointsTo: undefined + pointsTo: FernNavigation.V1.followRedirects(children) }; } return child; @@ -568,10 +543,7 @@ export class ApiReferenceNodeConverter { slug: endpointSlug.get(), icon: undefined, hidden: undefined, - playground: undefined, - authed: undefined, - viewers: undefined, - orphaned: undefined + playground: undefined }); }); @@ -593,10 +565,7 @@ export class ApiReferenceNodeConverter { hidden: undefined, apiDefinitionId: this.apiDefinitionId, availability: FernNavigation.V1.convertAvailability(webSocket.availability), - playground: undefined, - authed: undefined, - viewers: undefined, - orphaned: undefined + playground: undefined }); }); @@ -618,10 +587,7 @@ export class ApiReferenceNodeConverter { icon: undefined, hidden: undefined, apiDefinitionId: this.apiDefinitionId, - availability: undefined, - authed: undefined, - viewers: undefined, - orphaned: undefined + availability: undefined }); }); @@ -652,12 +618,9 @@ export class ApiReferenceNodeConverter { overviewPageId: undefined, availability: undefined, apiDefinitionId: this.apiDefinitionId, - pointsTo: undefined, + pointsTo: FernNavigation.V1.followRedirects(subpackageChildren), noindex: undefined, - playground: undefined, - authed: undefined, - viewers: undefined, - orphaned: undefined + playground: undefined }); } }); diff --git a/packages/cli/docs-resolver/src/ChangelogNodeConverter.ts b/packages/cli/docs-resolver/src/ChangelogNodeConverter.ts index 3813bf727db..416ade8ceb4 100644 --- a/packages/cli/docs-resolver/src/ChangelogNodeConverter.ts +++ b/packages/cli/docs-resolver/src/ChangelogNodeConverter.ts @@ -1,4 +1,4 @@ -import { APIV1Write, FernNavigation } from "@fern-api/fdr-sdk"; +import { FernNavigation } from "@fern-api/fdr-sdk"; import { AbsoluteFilePath, relative, RelativeFilePath } from "@fern-api/fs-utils"; import { DocsWorkspace } from "@fern-api/workspace-loader"; import dayjs from "dayjs"; @@ -17,8 +17,6 @@ interface ConvertOptions { icon?: string; hidden?: boolean; slug?: string; - viewers?: APIV1Write.RoleId[]; - orphaned?: boolean; // skipUrlSlug?: boolean; } @@ -33,17 +31,21 @@ export class ChangelogNodeConverter { private idgen: NodeIdGenerator ) {} - public toChangelogNode(opts: ConvertOptions): FernNavigation.V1.ChangelogNode { + public convert(opts: ConvertOptions): FernNavigation.V1.ChangelogNode | undefined { + if (this.changelogFiles == null || this.changelogFiles.length === 0) { + return undefined; + } + const title = opts.title ?? DEFAULT_CHANGELOG_TITLE; + this.idgen = this.idgen.append("changelog"); const unsortedChangelogItems: { date: Date; pageId: FernNavigation.PageId; absoluteFilepath: AbsoluteFilePath; }[] = []; - let overviewPagePath: AbsoluteFilePath | undefined = undefined; - for (const absoluteFilepath of this.changelogFiles ?? []) { + for (const absoluteFilepath of this.changelogFiles) { const filename = last(absoluteFilepath.split("/")); if (filename == null) { continue; @@ -75,13 +77,12 @@ export class ChangelogNodeConverter { const changelogItems = unsortedChangelogItems.map((item): FernNavigation.V1.ChangelogEntryNode => { const date = dayjs.utc(item.date); return { - id: this.idgen.get(item.pageId), + id: this.idgen.append(date.format("YYYY-M-D")).get(), type: "changelogEntry", title: date.format("MMMM D, YYYY"), slug: slug .apply({ fullSlug: this.markdownToFullSlug.get(item.absoluteFilepath)?.split("/"), - // TODO: the url slug should be the markdown filename name, minus the extension urlSlug: date.format("YYYY/M/D") }) .get(), @@ -89,41 +90,28 @@ export class ChangelogNodeConverter { hidden: undefined, date: item.date.toISOString(), pageId: item.pageId, - noindex: undefined, - authed: undefined, - viewers: undefined, - orphaned: undefined + noindex: undefined }; }); const entries = orderBy(changelogItems, (entry) => entry.date, "desc"); - const overviewPageId = - overviewPagePath != null ? FernNavigation.PageId(this.toRelativeFilepath(overviewPagePath)) : undefined; - const id = this.idgen.get(overviewPageId ?? "changelog"); - const changelogYears = this.groupByYear(id, entries, slug); + const changelogYears = this.groupByYear(entries, slug); return { - id, + id: this.idgen.get(), type: "changelog", title, slug: slug.get(), icon: opts.icon, hidden: opts.hidden, children: changelogYears, - overviewPageId, - noindex: undefined, - authed: undefined, - viewers: opts.viewers, - orphaned: opts.orphaned + overviewPageId: + overviewPagePath != null ? FernNavigation.PageId(this.toRelativeFilepath(overviewPagePath)) : undefined, + noindex: undefined }; } - public orUndefined(): ChangelogNodeConverter | undefined { - return this.changelogFiles != null && this.changelogFiles.length > 0 ? this : undefined; - } - private groupByYear( - prefix: string, entries: FernNavigation.V1.ChangelogEntryNode[], parentSlug: FernNavigation.V1.SlugGenerator ): FernNavigation.V1.ChangelogYearNode[] { @@ -137,19 +125,15 @@ export class ChangelogNodeConverter { return orderBy( Array.from(years.entries()).map(([year, entries]) => { const slug = parentSlug.append(year.toString()).get(); - const id = this.idgen.get(`${prefix}/year/${year}`); return { - id, + id: this.idgen.append(year.toString()).get(), type: "changelogYear" as const, title: year.toString(), year, slug, icon: undefined, hidden: undefined, - children: this.groupByMonth(id, entries, parentSlug), - authed: undefined, - viewers: undefined, - orphaned: undefined + children: this.groupByMonth(entries, parentSlug) }; }), "year", @@ -158,7 +142,6 @@ export class ChangelogNodeConverter { } private groupByMonth( - prefix: string, entries: FernNavigation.V1.ChangelogEntryNode[], parentSlug: FernNavigation.V1.SlugGenerator ): FernNavigation.V1.ChangelogMonthNode[] { @@ -173,17 +156,14 @@ export class ChangelogNodeConverter { Array.from(months.entries()).map(([month, entries]) => { const date = dayjs(new Date(0, month - 1)); return { - id: this.idgen.get(`${prefix}/month/${month}`), + id: this.idgen.append(date.format("YYYY-M")).get(), type: "changelogMonth" as const, title: date.format("MMMM YYYY"), month, slug: parentSlug.append(month.toString()).get(), icon: undefined, hidden: undefined, - children: entries, - authed: undefined, - viewers: undefined, - orphaned: undefined + children: entries }; }), "month", diff --git a/packages/cli/docs-resolver/src/DocsDefinitionResolver.ts b/packages/cli/docs-resolver/src/DocsDefinitionResolver.ts index c1fb8447172..72947081781 100644 --- a/packages/cli/docs-resolver/src/DocsDefinitionResolver.ts +++ b/packages/cli/docs-resolver/src/DocsDefinitionResolver.ts @@ -70,8 +70,6 @@ export class DocsDefinitionResolver { private registerApi: RegisterApiFn = defaultRegisterApi ) {} - #idgen = NodeIdGenerator.init(); - private _parsedDocsConfig: WithoutQuestionMarks | undefined; private get parsedDocsConfig(): WithoutQuestionMarks { if (this._parsedDocsConfig == null) { @@ -260,14 +258,13 @@ export class DocsDefinitionResolver { } private async convertDocsConfiguration(): Promise { - const root = await this.toRootNode(); - const config: DocsV1Write.DocsConfig = { + const convertedNavigation = await this.convertNavigationConfig(); + const config: WithoutQuestionMarks = { title: this.parsedDocsConfig.title, logoHeight: this.parsedDocsConfig.logo?.height, logoHref: this.parsedDocsConfig.logo?.href ? DocsV1Write.Url(this.parsedDocsConfig.logo?.href) : undefined, favicon: this.getFileId(this.parsedDocsConfig.favicon), - navigation: undefined, // <-- this is now deprecated - root, + navigation: convertedNavigation, colorsV3: this.convertColorConfigImageReferences(), navbarLinks: this.parsedDocsConfig.navbarLinks?.map((navbarLink) => ({ ...navbarLink, @@ -344,72 +341,166 @@ export class DocsDefinitionResolver { throw new Error("Failed to load API Definition referenced in docs"); } - private async toRootNode(): Promise { + private async convertNavigationConfig(): Promise { const slug = FernNavigation.V1.SlugGenerator.init(FernNavigation.slugjoin(this.getDocsBasePath())); - const id = this.#idgen.get("root"); - - const child: FernNavigation.V1.RootChild = await this.toRootChild(slug); - - return { - type: "root", - version: "v1", - id, - child, - slug: slug.get(), - // TODO: should this be "Documentation" by default? Or can we use the org name here? - title: this.parsedDocsConfig.title ?? "Documentation", - hidden: false, - icon: undefined, - pointsTo: undefined, - authed: undefined, - viewers: undefined, - orphaned: undefined - }; - } - - private async toRootChild(slug: FernNavigation.V1.SlugGenerator): Promise { - return visitDiscriminatedUnion(this.parsedDocsConfig.navigation)._visit>({ - untabbed: (untabbed) => - this.toUnversionedNode({ - landingPage: this.parsedDocsConfig.landingPage, - navigationConfig: untabbed, - parentSlug: slug - }), - tabbed: (tabbed) => - this.toUnversionedNode({ + switch (this.parsedDocsConfig.navigation.type) { + case "versioned": { + const versions = await Promise.all( + this.parsedDocsConfig.navigation.versions.map( + async (version): Promise => { + const versionSlug = slug.setVersionSlug(version.slug ?? kebabCase(version.version)); + const convertedNavigation = await this.convertUnversionedNavigationConfig({ + landingPage: version.landingPage, + navigationConfig: version.navigation, + parentSlug: versionSlug + }); + return { + version: FernNavigation.VersionId(version.version), + config: convertedNavigation, + availability: + version.availability != null + ? convertAvailability(version.availability) + : undefined, + urlSlugOverride: version.slug + }; + } + ) + ); + return { versions }; + } + case "untabbed": + case "tabbed": + return this.convertUnversionedNavigationConfig({ landingPage: this.parsedDocsConfig.landingPage, - navigationConfig: tabbed, + navigationConfig: this.parsedDocsConfig.navigation, parentSlug: slug - }), - versioned: (versioned) => this.toVersionedNode(versioned, slug) - }); + }); + default: + assertNever(this.parsedDocsConfig.navigation); + } } - private toLandingPageNode( - landingPageConfig: docsYml.DocsNavigationItem.Page, + private async convertNavigationItem( + item: docsYml.DocsNavigationItem, parentSlug: FernNavigation.V1.SlugGenerator - ): FernNavigation.V1.LandingPageNode { - const pageId = FernNavigation.PageId(this.toRelativeFilepath(landingPageConfig.absolutePath)); - const slug = parentSlug.apply({ - urlSlug: landingPageConfig.slug ?? kebabCase(landingPageConfig.title), - fullSlug: this.markdownFilesToFullSlugs.get(landingPageConfig.absolutePath)?.split("/") - }); - return { - type: "landingPage", - id: this.#idgen.get(pageId), - title: landingPageConfig.title, - slug: slug.get(), - icon: landingPageConfig.icon, - hidden: landingPageConfig.hidden, - viewers: landingPageConfig.viewers, - orphaned: landingPageConfig.orphaned, - pageId, - authed: undefined, - noindex: undefined - }; + ): Promise { + switch (item.type) { + case "page": { + return { + type: "page", + title: item.title, + icon: item.icon, + id: FernNavigation.PageId(this.toRelativeFilepath(item.absolutePath)), + urlSlugOverride: item.slug, + fullSlug: this.markdownFilesToFullSlugs.get(item.absolutePath)?.split("/"), + hidden: item.hidden + }; + } + case "section": { + const slug = parentSlug.apply({ + fullSlug: undefined, // TODO: implement fullSlug for sections when summary pages are supported + skipUrlSlug: item.skipUrlSlug, + urlSlug: item.slug ?? kebabCase(item.title) + }); + const sectionItems = await Promise.all( + item.contents.map((nestedItem) => this.convertNavigationItem(nestedItem, slug)) + ); + const relativeFilePath = this.toRelativeFilepath(item.overviewAbsolutePath); + return { + type: "section", + title: item.title, + + items: sectionItems, + urlSlugOverride: item.slug, + collapsed: item.collapsed, + icon: item.icon, + hidden: item.hidden, + skipUrlSlug: item.skipUrlSlug, + overviewPageId: relativeFilePath ? FernNavigation.PageId(relativeFilePath) : undefined, + fullSlug: undefined + }; + } + case "apiSection": { + const workspace = this.getFernWorkspaceForApiSection(item); + const snippetsConfig = convertDocsSnippetsConfigToFdr(item.snippetsConfiguration); + const ir = await generateIntermediateRepresentation({ + workspace, + audiences: item.audiences, + generationLanguage: undefined, + keywords: undefined, + smartCasing: false, + disableExamples: false, + readme: undefined, + version: undefined, + packageName: undefined, + context: this.taskContext + }); + // console.log(JSON.stringify(ir, undefined, 2)); + const apiDefinitionId = await this.registerApi({ + ir, + snippetsConfig, + playgroundConfig: { oauth: item.playground?.oauth }, + apiName: item.apiName + }); + const api = convertIrToApiDefinition(ir, apiDefinitionId, { oauth: item.playground?.oauth }); + const node = new ApiReferenceNodeConverter( + item, + api, + parentSlug, + workspace, + this.docsWorkspace, + this.taskContext, + this.markdownFilesToFullSlugs + ); + + return { type: "apiV2", node: node.get() }; + } + case "link": { + return { + type: "link", + icon: item.icon, + title: item.text, + url: APIV1Write.Url(item.url) + }; + } + case "changelog": { + const slug = item.slug ?? kebabCase(item.title); + const idgen = NodeIdGenerator.init(parentSlug.get()).append(slug); + const node = new ChangelogNodeConverter( + this.markdownFilesToFullSlugs, + item.changelog, + this.docsWorkspace, + idgen + ).convert({ + parentSlug, + title: item.title, + hidden: item.hidden, + slug: item.slug, + icon: item.icon + }); + + const relativeFilePath = this.toRelativeFilepath(item.changelog[0]); + return { + type: "changelogV3", + node: node ?? { + id: idgen.append("changelog").get(), + type: "changelog", + title: item.title, + slug: parentSlug.append(slug).get(), + children: [], + icon: item.icon, + hidden: item.hidden, + overviewPageId: relativeFilePath ? FernNavigation.PageId(relativeFilePath) : undefined, + noindex: false + } + }; + } + default: + assertNever(item); + } } - private async toUnversionedNode({ + private async convertUnversionedNavigationConfig({ landingPage: landingPageConfig, navigationConfig, parentSlug @@ -417,330 +508,111 @@ export class DocsDefinitionResolver { landingPage: docsYml.DocsNavigationItem.Page | undefined; navigationConfig: docsYml.UnversionedNavigationConfiguration; parentSlug: FernNavigation.V1.SlugGenerator; - }): Promise { - const id = this.#idgen.get("unversioned"); - const landingPage: FernNavigation.V1.LandingPageNode | undefined = - landingPageConfig != null ? this.toLandingPageNode(landingPageConfig, parentSlug) : undefined; - - const child = - navigationConfig.type === "tabbed" - ? await this.convertTabbedNavigation(id, navigationConfig.items, parentSlug) - : await this.toSidebarRootNode(id, navigationConfig.items, parentSlug); - - return { type: "unversioned", id, landingPage, child }; - } - - private async toVersionedNode( - versioned: docsYml.VersionedDocsNavigation, - parentSlug: FernNavigation.V1.SlugGenerator - ): Promise { - const id = this.#idgen.get("versioned"); - - return { - id, - type: "versioned", - // TODO: should the first version always be default? We should make this configurable. - children: await Promise.all( - versioned.versions.map((item, idx) => this.toVersionNode(item, parentSlug, idx === 0)) - ) - }; - } - - private async toVersionNode( - version: docsYml.VersionInfo, - parentSlug: FernNavigation.V1.SlugGenerator, - isDefault: boolean - ): Promise { - const id = this.#idgen.get(version.version); - const slug = parentSlug.setVersionSlug(version.version); - const child = - version.navigation.type === "tabbed" - ? await this.convertTabbedNavigation(id, version.navigation.items, slug) - : await this.toSidebarRootNode(id, version.navigation.items, slug); - return { - type: "version", - id, - versionId: FernNavigation.VersionId(version.version), - title: version.version, - slug: slug.get(), - child, - // TODO: the `default` property should be deprecated, and moved to the parent `versioned` node - default: isDefault, - availability: version.availability != null ? convertAvailability(version.availability) : undefined, - landingPage: version.landingPage ? this.toLandingPageNode(version.landingPage, parentSlug) : undefined, - hidden: undefined, - authed: undefined, - viewers: version.viewers, - orphaned: version.orphaned, - icon: undefined, - pointsTo: undefined - }; - } - - private async toSidebarRootNode( - prefix: string, - items: docsYml.DocsNavigationItem[], - parentSlug: FernNavigation.V1.SlugGenerator - ): Promise { - const id = this.#idgen.get(`${prefix}/root`); - - const children = await Promise.all(items.map((item) => this.toNavigationChild(id, item, parentSlug))); - - const sidebarRootChildren: FernNavigation.V1.SidebarRootChild[] = []; - children.forEach((child) => { - switch (child.type) { - case "apiReference": - case "section": - sidebarRootChildren.push(child); - return; - case "changelog": - case "link": - case "page": { - let last = sidebarRootChildren[sidebarRootChildren.length - 1]; - if (last?.type !== "sidebarGroup") { - last = { - id: this.#idgen.get(`${id}/group`), - type: "sidebarGroup", - children: [] - }; - sidebarRootChildren.push(last); - } - last.children.push(child); - return; - } - default: - assertNever(child); + }): Promise { + const landingPage = + landingPageConfig != null + ? { + id: FernNavigation.PageId(this.toRelativeFilepath(landingPageConfig.absolutePath)), + urlSlugOverride: landingPageConfig.slug, + fullSlug: this.markdownFilesToFullSlugs.get(landingPageConfig.absolutePath)?.split("/"), + hidden: landingPageConfig.hidden, + title: landingPageConfig.title, + icon: landingPageConfig.icon + } + : undefined; + switch (navigationConfig.type) { + case "untabbed": { + const untabs = await Promise.all( + navigationConfig.items.map((item) => this.convertNavigationItem(item, parentSlug)) + ); + return { + landingPage, + items: untabs + }; } - }); - - return { - type: "sidebarRoot", - id, - children: sidebarRootChildren - }; - } - - private async toNavigationChild( - prefix: string, - item: docsYml.DocsNavigationItem, - parentSlug: FernNavigation.V1.SlugGenerator - ): Promise { - return visitDiscriminatedUnion(item)._visit>({ - page: async (value) => this.toPageNode(value, parentSlug), - apiSection: async (value) => this.toApiSectionNode(value, parentSlug), - section: async (value) => this.toSectionNode(prefix, value, parentSlug), - link: async (value) => this.toLinkNode(value), - changelog: async (value) => this.toChangelogNode(value, parentSlug) - }); - } - - private async toApiSectionNode( - item: docsYml.DocsNavigationItem.ApiSection, - parentSlug: FernNavigation.V1.SlugGenerator - ): Promise { - const workspace = this.getFernWorkspaceForApiSection(item); - const snippetsConfig = convertDocsSnippetsConfigToFdr(item.snippetsConfiguration); - const ir = await generateIntermediateRepresentation({ - workspace, - audiences: item.audiences, - generationLanguage: undefined, - keywords: undefined, - smartCasing: false, - disableExamples: false, - readme: undefined, - version: undefined, - packageName: undefined, - context: this.taskContext - }); - const apiDefinitionId = await this.registerApi({ - ir, - snippetsConfig, - playgroundConfig: { oauth: item.playground?.oauth }, - apiName: item.apiName - }); - const api = convertIrToApiDefinition(ir, apiDefinitionId, { oauth: item.playground?.oauth }); - const node = new ApiReferenceNodeConverter( - item, - api, - parentSlug, - workspace, - this.docsWorkspace, - this.taskContext, - this.markdownFilesToFullSlugs, - this.#idgen - ); - return node.get(); - } - - private async toChangelogNode( - item: docsYml.DocsNavigationItem.Changelog, - parentSlug: FernNavigation.V1.SlugGenerator - ): Promise { - const changelogResolver = new ChangelogNodeConverter( - this.markdownFilesToFullSlugs, - item.changelog, - this.docsWorkspace, - this.#idgen - ); - - return changelogResolver.toChangelogNode({ - parentSlug, - title: item.title, - icon: item.icon, - viewers: item.viewers, - hidden: item.hidden, - slug: item.slug - }); - } - - private async toLinkNode(item: docsYml.DocsNavigationItem.Link): Promise { - return { - type: "link", - id: this.#idgen.get(item.url), - title: item.text, - url: FernNavigation.V1.Url(item.url), - icon: item.icon - }; - } - - private async toPageNode( - item: docsYml.DocsNavigationItem.Page, - parentSlug: FernNavigation.V1.SlugGenerator - ): Promise { - const pageId = FernNavigation.PageId(this.toRelativeFilepath(item.absolutePath)); - const slug = parentSlug.apply({ - urlSlug: item.slug ?? kebabCase(item.title), - fullSlug: this.markdownFilesToFullSlugs.get(item.absolutePath)?.split("/") - }); - const id = this.#idgen.get(pageId); - return { - id, - type: "page", - slug: slug.get(), - title: item.title, - icon: item.icon, - hidden: item.hidden, - viewers: item.viewers, - orphaned: item.orphaned, - pageId, - authed: undefined, - noindex: undefined - }; - } - - private async toSectionNode( - prefix: string, - item: docsYml.DocsNavigationItem.Section, - parentSlug: FernNavigation.V1.SlugGenerator - ): Promise { - const relativeFilePath = this.toRelativeFilepath(item.overviewAbsolutePath); - const pageId = relativeFilePath ? FernNavigation.PageId(relativeFilePath) : undefined; - const id = this.#idgen.get(pageId ?? `${prefix}/section`); - const slug = parentSlug.apply({ - urlSlug: item.slug ?? kebabCase(item.title), - fullSlug: item.overviewAbsolutePath - ? this.markdownFilesToFullSlugs.get(item.overviewAbsolutePath)?.split("/") - : undefined, - skipUrlSlug: item.skipUrlSlug - }); - return { - id, - type: "section", - overviewPageId: pageId, - slug: slug.get(), - title: item.title, - icon: item.icon, - collapsed: item.collapsed, - hidden: item.hidden, - viewers: item.viewers, - orphaned: item.orphaned, - children: await Promise.all(item.contents.map((child) => this.toNavigationChild(id, child, slug))), - authed: undefined, - pointsTo: undefined, - noindex: undefined - }; + case "tabbed": { + return { + landingPage, + tabs: undefined, + tabsV2: await this.convertTabbedNavigation(navigationConfig.items, parentSlug) + }; + } + default: + assertNever(navigationConfig); + } } private async convertTabbedNavigation( - prefix: string, items: docsYml.TabbedNavigation[], parentSlug: FernNavigation.V1.SlugGenerator - ): Promise { - const id = this.#idgen.get(`${prefix}/tabbed`); - return { - type: "tabbed", - id, - children: await Promise.all(items.map((item) => this.toTabChild(id, item, parentSlug))) - }; - } - - private async toTabChild( - prefix: string, - item: docsYml.TabbedNavigation, - parentSlug: FernNavigation.V1.SlugGenerator - ): Promise { - return visitDiscriminatedUnion(item.child)._visit>({ - link: ({ href }) => this.toTabLinkNode(item, href), - layout: ({ layout }) => this.toTabNode(prefix, item, layout, parentSlug), - changelog: ({ changelog }) => this.toTabChangelogNode(item, changelog, parentSlug) - }); - } + ): Promise { + return Promise.all( + items.map(async (tab): Promise> => { + if (tab.child.type === "link") { + return { + type: "link", + title: tab.title, + icon: tab.icon, + url: APIV1Write.Url(tab.child.href) + }; + } - private async toTabChangelogNode( - item: docsYml.TabbedNavigation, - changelog: AbsoluteFilePath[], - parentSlug: FernNavigation.V1.SlugGenerator - ): Promise { - const changelogResolver = new ChangelogNodeConverter( - this.markdownFilesToFullSlugs, - changelog, - this.docsWorkspace, - this.#idgen - ); - return changelogResolver.toChangelogNode({ - parentSlug, - title: item.title, - icon: item.icon, - viewers: item.viewers, - hidden: item.hidden, - slug: item.slug - }); - } + if (tab.child.type === "changelog") { + const idgen = NodeIdGenerator.init(parentSlug.get()); + const node = new ChangelogNodeConverter( + this.markdownFilesToFullSlugs, + tab.child.changelog, + this.docsWorkspace, + idgen + ).convert({ + parentSlug, + title: tab.title, + icon: tab.icon, + hidden: tab.hidden, + slug: tab.slug + }); + const relativeFilePath = this.toRelativeFilepath(tab.child.changelog[0]); + return { + type: "changelogV3", + node: node ?? { + id: idgen.append("changelog").get(), + type: "changelog", + title: tab.title, + slug: parentSlug.append(tab.slug ?? kebabCase(tab.title)).get(), + children: [], + icon: tab.icon, + hidden: tab.hidden, + overviewPageId: relativeFilePath ? FernNavigation.PageId(relativeFilePath) : undefined, + noindex: false + } + }; + } - private async toTabLinkNode(item: docsYml.TabbedNavigation, href: string): Promise { - return { - type: "link", - id: this.#idgen.get(href), - title: item.title, - url: FernNavigation.V1.Url(href), - icon: item.icon - }; - } + if (tab.child.type === "layout") { + const slug = parentSlug.apply({ + skipUrlSlug: tab.skipUrlSlug, + urlSlug: tab.slug ?? kebabCase(tab.title) + }); + + const tabs = await Promise.all( + tab.child.layout.map((item) => this.convertNavigationItem(item, slug)) + ); + + return { + type: "group", + title: tab.title, + icon: tab.icon, + items: tabs, + urlSlugOverride: tab.slug, + skipUrlSlug: tab.skipUrlSlug, + hidden: tab.hidden, + fullSlug: undefined + }; + } - private async toTabNode( - prefix: string, - item: docsYml.TabbedNavigation, - layout: docsYml.DocsNavigationItem[], - parentSlug: FernNavigation.V1.SlugGenerator - ): Promise { - const id = this.#idgen.get(`${prefix}/tab`); - const slug = parentSlug.apply({ - urlSlug: item.slug ?? kebabCase(item.title), - skipUrlSlug: item.skipUrlSlug - }); - return { - type: "tab", - id, - title: item.title, - slug: slug.get(), - icon: item.icon, - hidden: item.hidden, - authed: undefined, - viewers: item.viewers, - orphaned: item.orphaned, - pointsTo: undefined, - child: await this.toSidebarRootNode(id, layout, slug) - }; + assertNever(tab.child); + }) + ); } private getFileId(filepath: AbsoluteFilePath): DocsV1Write.FileId; @@ -911,18 +783,16 @@ function createEditThisPageUrl( return `${wrapWithHttps(host)}/${owner}/${repo}/blob/${branch}/fern/${pageFilepath}`; } -function convertAvailability( - availability: docsYml.RawSchemas.VersionAvailability -): FernNavigation.V1.NavigationV1Availability { +function convertAvailability(availability: docsYml.RawSchemas.VersionAvailability): DocsV1Write.Availability { switch (availability) { case "beta": - return FernNavigation.V1.NavigationV1Availability.Beta; + return DocsV1Write.Availability.Beta; case "deprecated": - return FernNavigation.V1.NavigationV1Availability.Deprecated; + return DocsV1Write.Availability.Deprecated; case "ga": - return FernNavigation.V1.NavigationV1Availability.GenerallyAvailable; + return DocsV1Write.Availability.GenerallyAvailable; case "stable": - return FernNavigation.V1.NavigationV1Availability.Stable; + return DocsV1Write.Availability.Stable; default: assertNever(availability); } diff --git a/packages/cli/docs-resolver/src/NodeIdGenerator.ts b/packages/cli/docs-resolver/src/NodeIdGenerator.ts index 27c5867a907..41eff857dab 100644 --- a/packages/cli/docs-resolver/src/NodeIdGenerator.ts +++ b/packages/cli/docs-resolver/src/NodeIdGenerator.ts @@ -1,40 +1,26 @@ import { FernNavigation } from "@fern-api/fdr-sdk"; -import crypto from "crypto"; - -function hash(id: string): string { - return crypto.createHash("sha256").update(id).digest("hex"); -} export class NodeIdGenerator { - public static init(): NodeIdGenerator { - return new NodeIdGenerator(); + public static init(id: string): NodeIdGenerator { + return new NodeIdGenerator(id, new Set([id])); } - private constructor() {} + private constructor(private id: string, private ids: Set) {} - #ids = new Map(); - #visited = new Set(); - - #getHashedId(id: string): string { - const count = this.#ids.get(id) ?? 0; - this.#ids.set(id, count + 1); - const hashedId = hash(count === 0 ? id : `${id}-${count}`); - return hashedId; + public get(): FernNavigation.V1.NodeId { + return FernNavigation.V1.NodeId(this.id); } - #getUniqueId(id: string): string { - let hashedId = this.#getHashedId(id); - let loop = 0; - while (this.#visited.has(hashedId)) { - hashedId = this.#getHashedId(id); - loop++; - if (loop > 100) { - throw new Error(`Infinite loop detected for id: ${id}`); + public append(part: string): NodeIdGenerator { + let id = `${this.id}.${part}`; + if (this.ids.has(id)) { + let i = 1; + while (this.ids.has(`${id}-${i}`)) { + i++; } + id = `${id}-${i}`; } - return hashedId; - } - public get(id: string): FernNavigation.V1.NodeId { - return FernNavigation.V1.NodeId(this.#getUniqueId(id)); + this.ids.add(id); + return new NodeIdGenerator(id, this.ids); } } diff --git a/packages/cli/docs-resolver/src/__test__/api-resolver.test.ts b/packages/cli/docs-resolver/src/__test__/api-resolver.test.ts index 2859e1413ed..b25b0f71abc 100644 --- a/packages/cli/docs-resolver/src/__test__/api-resolver.test.ts +++ b/packages/cli/docs-resolver/src/__test__/api-resolver.test.ts @@ -6,7 +6,6 @@ import { createMockTaskContext } from "@fern-api/task-context"; import { loadAPIWorkspace, loadDocsWorkspace } from "@fern-api/workspace-loader"; import { ApiDefinitionHolder } from "../ApiDefinitionHolder"; import { ApiReferenceNodeConverter } from "../ApiReferenceNodeConverter"; -import { NodeIdGenerator } from "../NodeIdGenerator"; import { convertIrToApiDefinition } from "../utils/convertIrToApiDefinition"; const context = createMockTaskContext(); @@ -78,8 +77,7 @@ it.skip("converts to api reference node", async () => { apiWorkspace, docsWorkspace, context, - new Map(), - NodeIdGenerator.init() + new Map() ).get(); expect(node).toMatchSnapshot(); diff --git a/packages/cli/docs-resolver/src/__test__/stream.test.ts b/packages/cli/docs-resolver/src/__test__/stream.test.ts index 7521dd6040e..58e988d07a8 100644 --- a/packages/cli/docs-resolver/src/__test__/stream.test.ts +++ b/packages/cli/docs-resolver/src/__test__/stream.test.ts @@ -1,12 +1,11 @@ import { docsYml } from "@fern-api/configuration"; import { FernNavigation } from "@fern-api/fdr-sdk"; import { AbsoluteFilePath, resolve } from "@fern-api/fs-utils"; -import { generateIntermediateRepresentation, IdGenerator } from "@fern-api/ir-generator"; +import { generateIntermediateRepresentation } from "@fern-api/ir-generator"; import { createMockTaskContext } from "@fern-api/task-context"; import { loadAPIWorkspace, loadDocsWorkspace } from "@fern-api/workspace-loader"; import { ApiDefinitionHolder } from "../ApiDefinitionHolder"; import { ApiReferenceNodeConverter } from "../ApiReferenceNodeConverter"; -import { NodeIdGenerator } from "../NodeIdGenerator"; import { convertIrToApiDefinition } from "../utils/convertIrToApiDefinition"; const context = createMockTaskContext(); @@ -82,8 +81,7 @@ it.skip("converts to api reference node", async () => { apiWorkspace, docsWorkspace, context, - new Map(), - NodeIdGenerator.init() + new Map() ).get(); expect(node).toMatchSnapshot(); diff --git a/packages/cli/ete-tests/package.json b/packages/cli/ete-tests/package.json index f6828ac1720..f991f44f6eb 100644 --- a/packages/cli/ete-tests/package.json +++ b/packages/cli/ete-tests/package.json @@ -29,7 +29,7 @@ }, "dependencies": { "@fern-api/configuration": "workspace:*", - "@fern-fern/fdr-cjs-sdk": "0.119.0-d531a5553", + "@fern-fern/fdr-cjs-sdk": "0.0.5833", "@fern-api/fs-utils": "workspace:*", "@fern-api/logging-execa": "workspace:*", "@fern-typescript/fetcher": "workspace:*", @@ -54,4 +54,4 @@ "prettier": "^2.7.1", "typescript": "4.6.4" } -} +} \ No newline at end of file diff --git a/packages/cli/ete-tests/src/tests/write-docs-definition/__snapshots__/writeDocsDefinition.test.ts.snap b/packages/cli/ete-tests/src/tests/write-docs-definition/__snapshots__/writeDocsDefinition.test.ts.snap index 43fd13c2257..a607791474d 100644 --- a/packages/cli/ete-tests/src/tests/write-docs-definition/__snapshots__/writeDocsDefinition.test.ts.snap +++ b/packages/cli/ete-tests/src/tests/write-docs-definition/__snapshots__/writeDocsDefinition.test.ts.snap @@ -4,75 +4,65 @@ exports[`write-docs-definition > petstore 1`] = ` "{ "config": { "title": "fern | Documentation", - "root": { - "type": "root", - "version": "v1", - "id": "4813494d137e1631bba301d5acab6e7bb7aa74ce1185d456565ef51d737677b2", - "child": { - "type": "unversioned", - "id": "d01383c373ddae4ae891cc6b64fbc0e544fd79b499637874332fc539852c6628", - "child": { - "type": "sidebarRoot", - "id": "0a1e895b8a8b5113aaf6a69838e1e98632da7db03fed25a21b8afbb301b82b06", - "children": [ - { - "id": "f9811b73ac5d1a8db842634fc0f871e03207ae44105fc9c2b7f1985e70f90d5a", - "type": "apiReference", - "title": "API Reference", - "apiDefinitionId": "api-1", - "paginated": false, - "slug": "api-reference", - "hideTitle": false, - "showErrors": false, - "children": [ - { - "id": "api-1:subpackage_pets", - "type": "apiPackage", - "children": [ - { - "id": "api-1:endpoint_pets.listPets", - "type": "endpoint", - "method": "GET", - "endpointId": "endpoint_pets.listPets", - "apiDefinitionId": "api-1", - "isResponseStream": false, - "title": "List all pets", - "slug": "api-reference/pets/list-pets" - }, - { - "id": "api-1:endpoint_pets.createPets", - "type": "endpoint", - "method": "POST", - "endpointId": "endpoint_pets.createPets", - "apiDefinitionId": "api-1", - "isResponseStream": false, - "title": "Create a pet", - "slug": "api-reference/pets/create-pets" - }, - { - "id": "api-1:endpoint_pets.showPetById", - "type": "endpoint", - "method": "GET", - "endpointId": "endpoint_pets.showPetById", - "apiDefinitionId": "api-1", - "isResponseStream": false, - "title": "Info for a specific pet", - "slug": "api-reference/pets/show-pet-by-id" - } - ], - "title": "Pets", - "slug": "api-reference/pets", - "apiDefinitionId": "api-1" - } - ], - "pointsTo": "api-reference/pets/list-pets" - } - ] + "navigation": { + "items": [ + { + "type": "apiV2", + "node": { + "id": "api-1", + "type": "apiReference", + "title": "API Reference", + "apiDefinitionId": "api-1", + "paginated": false, + "slug": "fern.docs.buildwithfern.com/api-reference", + "hideTitle": false, + "showErrors": false, + "children": [ + { + "id": "api-1:subpackage_pets", + "type": "apiPackage", + "children": [ + { + "id": "api-1:endpoint_pets.listPets", + "type": "endpoint", + "method": "GET", + "endpointId": "endpoint_pets.listPets", + "apiDefinitionId": "api-1", + "isResponseStream": false, + "title": "List all pets", + "slug": "fern.docs.buildwithfern.com/api-reference/pets/list-pets" + }, + { + "id": "api-1:endpoint_pets.createPets", + "type": "endpoint", + "method": "POST", + "endpointId": "endpoint_pets.createPets", + "apiDefinitionId": "api-1", + "isResponseStream": false, + "title": "Create a pet", + "slug": "fern.docs.buildwithfern.com/api-reference/pets/create-pets" + }, + { + "id": "api-1:endpoint_pets.showPetById", + "type": "endpoint", + "method": "GET", + "endpointId": "endpoint_pets.showPetById", + "apiDefinitionId": "api-1", + "isResponseStream": false, + "title": "Info for a specific pet", + "slug": "fern.docs.buildwithfern.com/api-reference/pets/show-pet-by-id" + } + ], + "title": "Pets", + "slug": "fern.docs.buildwithfern.com/api-reference/pets", + "apiDefinitionId": "api-1", + "pointsTo": "fern.docs.buildwithfern.com/api-reference/pets/list-pets" + } + ], + "pointsTo": "fern.docs.buildwithfern.com/api-reference/pets/list-pets" + } } - }, - "slug": "", - "title": "fern | Documentation", - "hidden": false + ] }, "colorsV3": { "type": "dark", diff --git a/packages/cli/ete-tests/src/tests/write-docs-definition/fixtures/petstore/docs-definition.json b/packages/cli/ete-tests/src/tests/write-docs-definition/fixtures/petstore/docs-definition.json index fdb21af21ac..8be7a632b19 100644 --- a/packages/cli/ete-tests/src/tests/write-docs-definition/fixtures/petstore/docs-definition.json +++ b/packages/cli/ete-tests/src/tests/write-docs-definition/fixtures/petstore/docs-definition.json @@ -1,75 +1,65 @@ { "config": { "title": "fern | Documentation", - "root": { - "type": "root", - "version": "v1", - "id": "4813494d137e1631bba301d5acab6e7bb7aa74ce1185d456565ef51d737677b2", - "child": { - "type": "unversioned", - "id": "d01383c373ddae4ae891cc6b64fbc0e544fd79b499637874332fc539852c6628", - "child": { - "type": "sidebarRoot", - "id": "0a1e895b8a8b5113aaf6a69838e1e98632da7db03fed25a21b8afbb301b82b06", - "children": [ - { - "id": "f9811b73ac5d1a8db842634fc0f871e03207ae44105fc9c2b7f1985e70f90d5a", - "type": "apiReference", - "title": "API Reference", - "apiDefinitionId": "api-1", - "paginated": false, - "slug": "api-reference", - "hideTitle": false, - "showErrors": false, - "children": [ - { - "id": "api-1:subpackage_pets", - "type": "apiPackage", - "children": [ - { - "id": "api-1:endpoint_pets.listPets", - "type": "endpoint", - "method": "GET", - "endpointId": "endpoint_pets.listPets", - "apiDefinitionId": "api-1", - "isResponseStream": false, - "title": "List all pets", - "slug": "api-reference/pets/list-pets" - }, - { - "id": "api-1:endpoint_pets.createPets", - "type": "endpoint", - "method": "POST", - "endpointId": "endpoint_pets.createPets", - "apiDefinitionId": "api-1", - "isResponseStream": false, - "title": "Create a pet", - "slug": "api-reference/pets/create-pets" - }, - { - "id": "api-1:endpoint_pets.showPetById", - "type": "endpoint", - "method": "GET", - "endpointId": "endpoint_pets.showPetById", - "apiDefinitionId": "api-1", - "isResponseStream": false, - "title": "Info for a specific pet", - "slug": "api-reference/pets/show-pet-by-id" - } - ], - "title": "Pets", - "slug": "api-reference/pets", - "apiDefinitionId": "api-1" - } - ], - "pointsTo": "api-reference/pets/list-pets" - } - ] + "navigation": { + "items": [ + { + "type": "apiV2", + "node": { + "id": "api-1", + "type": "apiReference", + "title": "API Reference", + "apiDefinitionId": "api-1", + "paginated": false, + "slug": "fern.docs.buildwithfern.com/api-reference", + "hideTitle": false, + "showErrors": false, + "children": [ + { + "id": "api-1:subpackage_pets", + "type": "apiPackage", + "children": [ + { + "id": "api-1:endpoint_pets.listPets", + "type": "endpoint", + "method": "GET", + "endpointId": "endpoint_pets.listPets", + "apiDefinitionId": "api-1", + "isResponseStream": false, + "title": "List all pets", + "slug": "fern.docs.buildwithfern.com/api-reference/pets/list-pets" + }, + { + "id": "api-1:endpoint_pets.createPets", + "type": "endpoint", + "method": "POST", + "endpointId": "endpoint_pets.createPets", + "apiDefinitionId": "api-1", + "isResponseStream": false, + "title": "Create a pet", + "slug": "fern.docs.buildwithfern.com/api-reference/pets/create-pets" + }, + { + "id": "api-1:endpoint_pets.showPetById", + "type": "endpoint", + "method": "GET", + "endpointId": "endpoint_pets.showPetById", + "apiDefinitionId": "api-1", + "isResponseStream": false, + "title": "Info for a specific pet", + "slug": "fern.docs.buildwithfern.com/api-reference/pets/show-pet-by-id" + } + ], + "title": "Pets", + "slug": "fern.docs.buildwithfern.com/api-reference/pets", + "apiDefinitionId": "api-1", + "pointsTo": "fern.docs.buildwithfern.com/api-reference/pets/list-pets" + } + ], + "pointsTo": "fern.docs.buildwithfern.com/api-reference/pets/list-pets" + } } - }, - "slug": "", - "title": "fern | Documentation", - "hidden": false + ] }, "colorsV3": { "type": "dark", diff --git a/packages/cli/generation/remote-generation/remote-workspace-runner/package.json b/packages/cli/generation/remote-generation/remote-workspace-runner/package.json index 113287980e7..6d3dc1cf0af 100644 --- a/packages/cli/generation/remote-generation/remote-workspace-runner/package.json +++ b/packages/cli/generation/remote-generation/remote-workspace-runner/package.json @@ -34,7 +34,7 @@ "@fern-api/core-utils": "workspace:*", "@fern-api/docs-resolver": "workspace:*", "@fern-api/logging-execa": "workspace:*", - "@fern-fern/fdr-cjs-sdk": "0.119.0-d531a5553", + "@fern-fern/fdr-cjs-sdk": "0.0.5833", "@fern-api/fs-utils": "workspace:*", "@fern-api/ir-generator": "workspace:*", "@fern-api/ir-migrations": "workspace:*", @@ -74,4 +74,4 @@ "typescript": "4.6.4", "vitest": "^2.0.5" } -} +} \ No newline at end of file diff --git a/packages/cli/generation/remote-generation/remote-workspace-runner/src/publishDocs.ts b/packages/cli/generation/remote-generation/remote-workspace-runner/src/publishDocs.ts index 5f1684edaa3..e0a516a6dea 100644 --- a/packages/cli/generation/remote-generation/remote-workspace-runner/src/publishDocs.ts +++ b/packages/cli/generation/remote-generation/remote-workspace-runner/src/publishDocs.ts @@ -46,6 +46,8 @@ export async function publishDocs({ fernWorkspaces: FernWorkspace[]; context: TaskContext; preview: boolean; + // TODO: implement audience support in generateIR + audiences: docsYml.RawSchemas.FernDocsConfig.AudiencesConfig | undefined; editThisPage: docsYml.RawSchemas.FernDocsConfig.EditThisPageConfig | undefined; isPrivate: boolean | undefined; }): Promise { diff --git a/packages/cli/generation/remote-generation/remote-workspace-runner/src/runRemoteGenerationForDocsWorkspace.ts b/packages/cli/generation/remote-generation/remote-workspace-runner/src/runRemoteGenerationForDocsWorkspace.ts index d21227958df..902a01bfa66 100644 --- a/packages/cli/generation/remote-generation/remote-workspace-runner/src/runRemoteGenerationForDocsWorkspace.ts +++ b/packages/cli/generation/remote-generation/remote-workspace-runner/src/runRemoteGenerationForDocsWorkspace.ts @@ -77,6 +77,7 @@ export async function runRemoteGenerationForDocsWorkspace({ context, fernWorkspaces, preview, + audiences: maybeInstance.audiences, editThisPage: maybeInstance.editThisPage, isPrivate: maybeInstance.private }); diff --git a/packages/cli/register/package.json b/packages/cli/register/package.json index 2d9d188668a..0ce6e4cd23d 100644 --- a/packages/cli/register/package.json +++ b/packages/cli/register/package.json @@ -32,7 +32,7 @@ "@fern-api/configuration": "workspace:*", "@fern-api/core": "workspace:*", "@fern-api/core-utils": "workspace:*", - "@fern-fern/fdr-cjs-sdk": "0.119.0-d531a5553", + "@fern-fern/fdr-cjs-sdk": "0.0.5833", "@fern-api/fs-utils": "workspace:*", "@fern-api/ir-generator": "workspace:*", "@fern-api/ir-sdk": "workspace:*", @@ -52,4 +52,4 @@ "typescript": "4.6.4", "vitest": "^2.0.5" } -} +} \ No newline at end of file diff --git a/packages/cli/register/src/ir-to-fdr-converter/__test__/__snapshots__/extra-properties.json b/packages/cli/register/src/ir-to-fdr-converter/__test__/__snapshots__/extra-properties.json index eeca36289ab..e15ffcc7ea5 100644 --- a/packages/cli/register/src/ir-to-fdr-converter/__test__/__snapshots__/extra-properties.json +++ b/packages/cli/register/src/ir-to-fdr-converter/__test__/__snapshots__/extra-properties.json @@ -107,10 +107,7 @@ } } } - ], - "extraProperties": { - "type": "unknown" - } + ] } } }, diff --git a/packages/cli/register/src/ir-to-fdr-converter/convertPackage.ts b/packages/cli/register/src/ir-to-fdr-converter/convertPackage.ts index a6f1b96a28f..d693492ab16 100644 --- a/packages/cli/register/src/ir-to-fdr-converter/convertPackage.ts +++ b/packages/cli/register/src/ir-to-fdr-converter/convertPackage.ts @@ -396,7 +396,7 @@ function convertRequestBody(irRequest: Ir.http.HttpRequestBody): FdrCjsSdk.api.v const requestBodyShape = Ir.http.HttpRequestBody._visit( irRequest, { - inlinedRequestBody: (inlinedRequestBody): FdrCjsSdk.api.v1.register.HttpRequestBodyShape.Json => { + inlinedRequestBody: (inlinedRequestBody) => { return { type: "json", contentType: inlinedRequestBody.contentType ?? MediaType.APPLICATION_JSON, @@ -410,12 +410,9 @@ function convertRequestBody(irRequest: Ir.http.HttpRequestBody): FdrCjsSdk.api.v valueType: convertTypeReference(property.valueType), availability: convertIrAvailability(property.availability) }) - ), - extraProperties: inlinedRequestBody.extraProperties ? { type: "unknown" } : undefined - } - - // TODO: add support for description in FDR SDK - // description: inlinedRequestBody.docs ?? undefined, + ) + }, + description: inlinedRequestBody.docs ?? undefined }; }, reference: (reference) => { @@ -624,8 +621,7 @@ function convertResponseErrorsV2( : { type: "object", extends: [], - properties, - extraProperties: undefined + properties }, statusCode: errorDeclaration.statusCode, description: errorDeclaration.docs ?? undefined, @@ -850,9 +846,7 @@ function convertWebhookPayload(irWebhookPayload: Ir.webhooks.WebhookPayload): Fd valueType: convertTypeReference(property.valueType), availability: convertIrAvailability(property.availability) }) - ), - // TODO: add support for extraProperties in IR - extraProperties: undefined + ) }, description: undefined }; @@ -884,9 +878,7 @@ function convertMessageBody( valueType: convertTypeReference(property.valueType), availability: convertIrAvailability(property.availability) }) - ), - // TODO: add support for extraProperties in IR - extraProperties: undefined + ) }; case "reference": return { diff --git a/packages/cli/register/src/ir-to-fdr-converter/convertTypeShape.ts b/packages/cli/register/src/ir-to-fdr-converter/convertTypeShape.ts index cddb17f216c..8cddf66db57 100644 --- a/packages/cli/register/src/ir-to-fdr-converter/convertTypeShape.ts +++ b/packages/cli/register/src/ir-to-fdr-converter/convertTypeShape.ts @@ -65,9 +65,7 @@ export function convertTypeShape(irType: Ir.types.Type): FdrCjsSdk.api.v1.regist { samePropertiesAsObject: (extension) => ({ extends: [FdrCjsSdk.TypeId(extension.typeId)], - properties: baseProperties, - // TODO: add support for extra properties in discriminated union - extraProperties: undefined + properties: baseProperties }), singleProperty: (singleProperty) => ({ extends: [], @@ -79,15 +77,11 @@ export function convertTypeShape(irType: Ir.types.Type): FdrCjsSdk.api.v1.regist availability: undefined }, ...baseProperties - ], - // TODO: add support for extra properties in discriminated union - extraProperties: undefined + ] }), noProperties: () => ({ extends: [], - properties: baseProperties, - // TODO: add support for extra properties in discriminated union - extraProperties: undefined + properties: baseProperties }), _other: () => { throw new Error( diff --git a/packages/cli/yaml/docs-validator/src/createDocsConfigFileAstVisitorForRules.ts b/packages/cli/yaml/docs-validator/src/createDocsConfigFileAstVisitorForRules.ts index 7d5a349a4a6..227a3e536ba 100644 --- a/packages/cli/yaml/docs-validator/src/createDocsConfigFileAstVisitorForRules.ts +++ b/packages/cli/yaml/docs-validator/src/createDocsConfigFileAstVisitorForRules.ts @@ -48,7 +48,6 @@ export function createDocsConfigFileAstVisitorForRules({ ...createAstNodeVisitor("filepath"), ...createAstNodeVisitor("markdownPage"), ...createAstNodeVisitor("versionFile"), - ...createAstNodeVisitor("apiSection"), - ...createAstNodeVisitor("permissions") + ...createAstNodeVisitor("apiSection") }; } diff --git a/packages/cli/yaml/docs-validator/src/docsAst/DocsConfigFileAstVisitor.ts b/packages/cli/yaml/docs-validator/src/docsAst/DocsConfigFileAstVisitor.ts index 90fd3bdd592..7308d259075 100644 --- a/packages/cli/yaml/docs-validator/src/docsAst/DocsConfigFileAstVisitor.ts +++ b/packages/cli/yaml/docs-validator/src/docsAst/DocsConfigFileAstVisitor.ts @@ -22,7 +22,6 @@ export interface DocsConfigFileAstNodeTypes { workspace: AbstractAPIWorkspace; context: TaskContext; }; - permissions: docsYml.RawSchemas.WithPermissions; } export type DocsConfigFileAstNodeVisitor> = ( diff --git a/packages/cli/yaml/docs-validator/src/docsAst/visitDocsConfigFileYamlAst.ts b/packages/cli/yaml/docs-validator/src/docsAst/visitDocsConfigFileYamlAst.ts index 9a1c281abc3..25f803002e4 100644 --- a/packages/cli/yaml/docs-validator/src/docsAst/visitDocsConfigFileYamlAst.ts +++ b/packages/cli/yaml/docs-validator/src/docsAst/visitDocsConfigFileYamlAst.ts @@ -256,8 +256,7 @@ export async function visitDocsConfigFileYamlAst({ } }) ); - }, - roles: noop + } }); } diff --git a/packages/cli/yaml/docs-validator/src/docsAst/visitNavigationAst.ts b/packages/cli/yaml/docs-validator/src/docsAst/visitNavigationAst.ts index c8ec82d8552..5681048f593 100644 --- a/packages/cli/yaml/docs-validator/src/docsAst/visitNavigationAst.ts +++ b/packages/cli/yaml/docs-validator/src/docsAst/visitNavigationAst.ts @@ -129,13 +129,7 @@ async function visitNavigationItem({ context }); }); - }, - viewers: async (viewers: docsYml.RawSchemas.WithPermissions["viewers"]): Promise => { - if (viewers != null && viewers.length > 0) { - await visitor.permissions?.({ viewers }, [...nodePath, "viewers"]); - } - }, - orphaned: noop + } }); if (navigationItemIsPage(navigationItem)) { diff --git a/packages/cli/yaml/docs-validator/src/getAllRules.ts b/packages/cli/yaml/docs-validator/src/getAllRules.ts index aa475c846ad..0b4ddd558fd 100644 --- a/packages/cli/yaml/docs-validator/src/getAllRules.ts +++ b/packages/cli/yaml/docs-validator/src/getAllRules.ts @@ -1,6 +1,5 @@ import { Rule } from "./Rule"; import { AccentColorContrastRule } from "./rules/accent-color-contrast"; -import { AllRolesMustBeDeclaredRule } from "./rules/all-roles-must-be-declared"; import { FilepathsExistRule } from "./rules/filepaths-exist"; import { OnlyVersionedNavigation } from "./rules/only-versioned-navigation"; import { PlaygroundEnvironmentsExistRule } from "./rules/playground-environments-exist"; @@ -20,7 +19,6 @@ export function getAllRules(): Rule[] { ValidMarkdownLinks, ValidFileTypes, PlaygroundEnvironmentsExistRule, - ValidDocsEndpoints, - AllRolesMustBeDeclaredRule + ValidDocsEndpoints ]; } diff --git a/packages/cli/yaml/docs-validator/src/rules/all-roles-must-be-declared/index.ts b/packages/cli/yaml/docs-validator/src/rules/all-roles-must-be-declared/index.ts deleted file mode 100644 index b34b05452f5..00000000000 --- a/packages/cli/yaml/docs-validator/src/rules/all-roles-must-be-declared/index.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { Rule, RuleViolation } from "../../Rule"; - -export const AllRolesMustBeDeclaredRule: Rule = { - name: "all-roles-must-be-declared", - create: (context) => { - const declaredRoles = context.workspace.config.roles; - return { - permissions: (permissions) => { - const usedRoles = [...(permissions.viewers ?? [])]; - - const violations: RuleViolation[] = []; - for (const usedRole of usedRoles) { - if (declaredRoles == null || !declaredRoles.includes(usedRole)) { - violations.push({ - severity: "error", - // TODO: add a link to the docs - message: `Role "${usedRole}" is used but not declared at the top level of the docs.yml file.` - }); - } - } - return violations; - } - }; - } -}; diff --git a/packages/core/package.json b/packages/core/package.json index 4c3de382981..cc6d78778be 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -28,7 +28,7 @@ "depcheck": "depcheck" }, "dependencies": { - "@fern-fern/fdr-cjs-sdk": "0.119.0-d531a5553", + "@fern-fern/fdr-cjs-sdk": "0.0.5833", "@fern-fern/generators-sdk": "0.114.0-5745f9e74", "@fern-api/venus-api-sdk": "0.0.38", "@fern-fern/fdr-test-sdk": "^0.0.5297", @@ -44,4 +44,4 @@ "prettier": "^2.7.1", "typescript": "4.6.4" } -} +} \ No newline at end of file diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 5219dc69eb1..e08c777596f 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -3844,8 +3844,8 @@ importers: specifier: workspace:* version: link:../task-context '@fern-fern/fdr-cjs-sdk': - specifier: 0.119.0-d531a5553 - version: 0.119.0-d531a5553 + specifier: 0.0.5833 + version: 0.0.5833 '@fern-fern/fiddle-sdk': specifier: 0.0.584 version: 0.0.584 @@ -3920,8 +3920,8 @@ importers: specifier: workspace:* version: link:../../task-context '@fern-fern/fdr-cjs-sdk': - specifier: 0.119.0-d531a5553 - version: 0.119.0-d531a5553 + specifier: 0.111.0-51d403bce + version: 0.111.0-51d403bce js-yaml: specifier: ^4.1.0 version: 4.1.0 @@ -3975,8 +3975,8 @@ importers: specifier: workspace:* version: link:../../task-context '@fern-fern/fdr-cjs-sdk': - specifier: 0.119.0-d531a5553 - version: 0.119.0-d531a5553 + specifier: 0.111.0-51d403bce + version: 0.111.0-51d403bce gray-matter: specifier: ^4.0.3 version: 4.0.3 @@ -4015,8 +4015,8 @@ importers: specifier: workspace:* version: link:../task-context '@fern-fern/fdr-cjs-sdk': - specifier: 0.119.0-d531a5553 - version: 0.119.0-d531a5553 + specifier: 0.0.5833 + version: 0.0.5833 gray-matter: specifier: ^4.0.3 version: 4.0.3 @@ -4070,8 +4070,8 @@ importers: specifier: workspace:* version: link:../docs-resolver '@fern-api/fdr-sdk': - specifier: 0.119.0-d531a5553 - version: 0.119.0-d531a5553(typescript@4.6.4) + specifier: 0.115.0-3cf21db72 + version: 0.115.0-3cf21db72(lodash-es@4.17.21)(typescript@4.6.4) '@fern-api/fs-utils': specifier: workspace:* version: link:../../commons/fs-utils @@ -4182,8 +4182,8 @@ importers: specifier: workspace:* version: link:../docs-markdown-utils '@fern-api/fdr-sdk': - specifier: 0.119.0-d531a5553 - version: 0.119.0-d531a5553(typescript@4.6.4) + specifier: 0.115.0-3cf21db72 + version: 0.115.0-3cf21db72(lodash-es@4.17.21)(typescript@4.6.4) '@fern-api/fs-utils': specifier: workspace:* version: link:../../commons/fs-utils @@ -4200,8 +4200,8 @@ importers: specifier: workspace:* version: link:../task-context '@fern-api/ui-core-utils': - specifier: 0.119.0-d531a5553 - version: 0.119.0-d531a5553 + specifier: 0.115.0-3cf21db72 + version: 0.115.0-3cf21db72 dayjs: specifier: ^1.11.11 version: 1.11.11 @@ -4310,8 +4310,8 @@ importers: specifier: workspace:* version: link:../../commons/logging-execa '@fern-fern/fdr-cjs-sdk': - specifier: 0.119.0-d531a5553 - version: 0.119.0-d531a5553 + specifier: 0.0.5833 + version: 0.0.5833 '@fern-typescript/fetcher': specifier: workspace:* version: link:../../../generators/typescript/utils/core-utilities/fetcher @@ -5069,8 +5069,8 @@ importers: specifier: workspace:* version: link:../../../workspace-loader '@fern-fern/fdr-cjs-sdk': - specifier: 0.119.0-d531a5553 - version: 0.119.0-d531a5553 + specifier: 0.0.5833 + version: 0.0.5833 '@fern-fern/fiddle-sdk': specifier: 0.0.584 version: 0.0.584 @@ -5635,8 +5635,8 @@ importers: specifier: workspace:* version: link:../task-context '@fern-fern/fdr-cjs-sdk': - specifier: 0.119.0-d531a5553 - version: 0.119.0-d531a5553 + specifier: 0.0.5833 + version: 0.0.5833 lodash-es: specifier: ^4.17.21 version: 4.17.21 @@ -6140,8 +6140,8 @@ importers: specifier: 0.0.38 version: 0.0.38 '@fern-fern/fdr-cjs-sdk': - specifier: 0.119.0-d531a5553 - version: 0.119.0-d531a5553 + specifier: 0.0.5833 + version: 0.0.5833 '@fern-fern/fdr-test-sdk': specifier: ^0.0.5297 version: 0.0.5297 @@ -7548,8 +7548,10 @@ packages: '@exodus/schemasafe@1.0.0': resolution: {integrity: sha512-2cyupPIZI69HQxEAPllLXBjQp4njDKkOjYRCYxvMZe3/LY9pp9fBM3Tb1wiFAdP6Emo4v3OEbCLGj6u73Q5KLw==} - '@fern-api/fdr-sdk@0.119.0-d531a5553': - resolution: {integrity: sha512-555o5/FE30qJ4xKk4KDPxQWBP2UE5YXKMfVQDD+YFl3e+grlxt1f0R/l6i+hlzPPu2aMPhl9tgzG+rdGFDUacw==} + '@fern-api/fdr-sdk@0.115.0-3cf21db72': + resolution: {integrity: sha512-1E/gm2gVA+jS6XbqVvkz26WXP/T7FUDF+i2jLmGtURUOgSQhFaZF5M3OVUrpO9igzXF5LlZjPw4MOTixYvIUFA==} + peerDependencies: + lodash-es: '>=4' '@fern-api/sdk@0.12.3': resolution: {integrity: sha512-sexxpQEHBmsAXW3UHo5x7NW8Z9TrHWYLGo/J7eFqHYSH8Sq9LA3vRlR0ni9h4FNlKnPDu9Y55L0BhsQVXYqPKA==} @@ -7557,8 +7559,8 @@ packages: '@fern-api/template-resolver@0.7.5': resolution: {integrity: sha512-hmvSxuhyWMjn1DxJJS/R+CIaZcF5c+UBEyFqFOw+laoBtdDvNgEyCu7XP5cILVMABPHmt7kkIO5KbrsCS5S2kw==} - '@fern-api/ui-core-utils@0.119.0-d531a5553': - resolution: {integrity: sha512-HH5C99nsEzjmSIPvc0VcmIviG8ULTQE5AlOc2snLQIrLF/h2Blunfi2kWbj/ID/QhWjBJBIfwEw2tY2wOxVfFA==} + '@fern-api/ui-core-utils@0.115.0-3cf21db72': + resolution: {integrity: sha512-H5NkeB/ZxTY6UD5xBpk68SYG1fPT48lhg6+lpO3n6txo5JlerSA2HZCbFGt8PdoDk5aT3GmtrBgIELIAXM9XbA==} '@fern-api/venus-api-sdk@0.0.38': resolution: {integrity: sha512-1JjuctZwyPu4jN51bBqjIy+uCBPGa/ROcDfqN0UnGeVEW7NyztkGh/qOFwnN6K07VMMql1AIF4Zov+MVqTPwmw==} @@ -7566,8 +7568,11 @@ packages: '@fern-fern/docs-config@0.0.80': resolution: {integrity: sha512-wAZCNxwM4qIPn3idoIihPP65KWPjNuoTSfdP4+5f8K2jJLgs5cdkY0pm4cQlGWvi5K6b+lfbUWDaslnXscJ2gQ==} - '@fern-fern/fdr-cjs-sdk@0.119.0-d531a5553': - resolution: {integrity: sha512-F0eZLfGcznnos6wv7m3MszA7Lj9SgeC9VpJyRyH0MwouGXPDa8/sdkZq+uK4QzHv1jmHo4IErcpnGEzokWUPCA==} + '@fern-fern/fdr-cjs-sdk@0.0.5833': + resolution: {integrity: sha512-D6L0CUJKAtJY4pO9qHpXMw4/k8AZSp1TBYNidkbj5s2N3VBK/fXMmyeOQG8HzPE8dpBL8ZI28kwUsfyRzamr0w==} + + '@fern-fern/fdr-cjs-sdk@0.111.0-51d403bce': + resolution: {integrity: sha512-ia/kqEDaUPiyYtLjCpYNPSO4/tDJDESpdUwEJqbYJP2awdK699L0ptGzNjvzhH0gJxe7/xj7SzPjmh3zs/hI5g==} '@fern-fern/fdr-test-sdk@0.0.5297': resolution: {integrity: sha512-jrZUZ6oIA64LHtrv77xEq0X7qJhT9xRMGWhKcLjIUArMsD7h6KMWUHVdoB/1MP0Mz/uL/E2xmM31SOgJicpIcA==} @@ -9665,9 +9670,6 @@ packages: resolution: {integrity: sha512-QCOllgZJtaUo9miYBcLChTUaHNjJF3PYs1VidD7AwiEj1kYxKeQTctLAezAOH5ZKRH0g2IgPn6KwB4IT8iRpvA==} engines: {node: '>= 0.4'} - es-toolkit@1.26.0: - resolution: {integrity: sha512-gg6ZaI4eTwzkQGkdEG+t4b4VH2mTxodBQ2KvyTKAQFIag3Vvxoq3XZ1ie4ijIQmVxiipL2+dZLDMkh1VIvAFyg==} - es6-promise@3.3.1: resolution: {integrity: sha512-SOp9Phqvqn7jtEUxPWdWfWoLmyt2VaJ6MpvP9Comy1MceMXqE6bxvaTu4iaxpYYPzhny28Lc+M87/c2cPK6lDg==} @@ -14682,16 +14684,16 @@ snapshots: '@exodus/schemasafe@1.0.0': {} - '@fern-api/fdr-sdk@0.119.0-d531a5553(typescript@4.6.4)': + '@fern-api/fdr-sdk@0.115.0-3cf21db72(lodash-es@4.17.21)(typescript@4.6.4)': dependencies: - '@fern-api/ui-core-utils': 0.119.0-d531a5553 + '@fern-api/ui-core-utils': 0.115.0-3cf21db72 '@ungap/structured-clone': 1.2.0 dayjs: 1.11.11 - es-toolkit: 1.26.0 fast-deep-equal: 3.1.3 form-data: 4.0.0 formdata-node: 6.0.3 js-base64: 3.7.7 + lodash-es: 4.17.21 node-fetch: 2.7.0 qs: 6.12.0 tinycolor2: 1.6.0 @@ -14718,7 +14720,7 @@ snapshots: dependencies: prettier: 3.3.3 - '@fern-api/ui-core-utils@0.119.0-d531a5553': + '@fern-api/ui-core-utils@0.115.0-3cf21db72': dependencies: strip-ansi: 7.1.0 title: 3.5.3 @@ -14735,7 +14737,18 @@ snapshots: '@fern-fern/docs-config@0.0.80': {} - '@fern-fern/fdr-cjs-sdk@0.119.0-d531a5553': + '@fern-fern/fdr-cjs-sdk@0.0.5833': + dependencies: + form-data: 4.0.0 + formdata-node: 6.0.3 + js-base64: 3.7.2 + node-fetch: 2.7.0 + qs: 6.11.2 + url-join: 4.0.1 + transitivePeerDependencies: + - encoding + + '@fern-fern/fdr-cjs-sdk@0.111.0-51d403bce': dependencies: form-data: 4.0.0 formdata-node: 6.0.3 @@ -17185,8 +17198,6 @@ snapshots: is-date-object: 1.0.5 is-symbol: 1.0.4 - es-toolkit@1.26.0: {} - es6-promise@3.3.1: {} esbuild@0.19.12: