From 365c1e6c022cdb05931011cbe4c422455adedca4 Mon Sep 17 00:00:00 2001 From: Andrew Jiang Date: Tue, 8 Oct 2024 11:22:04 -0400 Subject: [PATCH] feat: launchdarkly context + chore: refactor edge functions (#1604) --- packages/commons/fdr-utils/tsconfig.json | 2 +- .../src/jsonld/components/Breadcrumb.tsx | 1 + packages/commons/search-utils/package.json | 3 +- .../commons/search-utils/src/SearchConfig.ts | 29 +-- packages/commons/search-utils/tsconfig.json | 2 +- packages/fdr-sdk/tsconfig.build.json | 2 +- packages/healthchecks/tsconfig.json | 2 +- packages/template-resolver/tsconfig.json | 2 +- packages/ui/app/package.json | 3 +- packages/ui/app/src/atoms/auth.ts | 2 +- packages/ui/app/src/atoms/docs.ts | 36 +--- packages/ui/app/src/atoms/flags.ts | 2 +- packages/ui/app/src/atoms/launchdarkly.ts | 94 +++++++++ packages/ui/app/src/atoms/types.ts | 36 +--- .../ui/app/src/components/LinkPreload.tsx | 22 ++ packages/ui/app/src/docs/DocsPage.tsx | 3 + packages/ui/app/src/index.ts | 3 +- .../components/launchdarkly/LaunchDarkly.tsx | 77 +------ .../app/src/resolver/ApiDefinitionResolver.ts | 2 +- .../app/src/resolver/ApiEndpointResolver.ts | 2 +- .../__test__/ApiDefinitionResolver.test.ts | 2 +- .../src/resolver/resolveApiEndpointPage.ts | 2 +- .../src/resolver/resolveApiReferencePage.ts | 2 +- .../ui/app/src/resolver/resolveDocsContent.ts | 2 +- .../app/src/resolver/resolveMarkdownPage.ts | 2 +- packages/ui/app/src/search/SearchHits.tsx | 1 - .../src/services/useApiKeyInjectionConfig.ts | 2 +- packages/ui/app/tsconfig.json | 8 +- packages/ui/docs-bundle/next.config.mjs | 3 + packages/ui/docs-bundle/package.json | 3 +- packages/ui/docs-bundle/src/middleware.ts | 6 +- .../[api]/endpoint/[endpoint].ts | 2 +- .../api-definition/[api]/webhook/[webhook].ts | 2 +- .../[api]/websocket/[websocket].ts | 2 +- .../api/fern-docs/auth/api-key-injection.ts | 6 +- .../src/pages/api/fern-docs/auth/callback.ts | 6 +- .../pages/api/fern-docs/auth/jwt/callback.ts | 4 +- .../src/pages/api/fern-docs/auth/logout.ts | 2 +- .../src/pages/api/fern-docs/changelog.ts | 2 +- .../src/pages/api/fern-docs/feature-flags.ts | 166 +-------------- .../fern-docs/integrations/launchdarkly.ts | 110 ++++++++-- .../integrations/launchdarkly/identify.ts | 16 ++ .../pages/api/fern-docs/oauth/ory/callback.ts | 6 +- .../api/fern-docs/oauth/webflow/callback.ts | 2 +- .../src/pages/api/fern-docs/preview.ts | 2 +- .../src/pages/api/fern-docs/resolve-api.ts | 2 +- .../src/pages/api/fern-docs/robots.txt.ts | 2 +- .../src/pages/api/fern-docs/search.ts | 5 +- .../src/pages/api/fern-docs/sitemap.xml.ts | 2 +- .../src/server/ApiDefinitionLoader.ts | 4 +- .../ui/docs-bundle/src/server/DocsLoader.ts | 4 +- .../src/server/LoadDocsPerformanceTracker.ts | 2 +- .../ui/docs-bundle/src/server/auth/FernJWT.ts | 2 +- .../src/server/auth/OAuth2Client.ts | 6 +- .../src/server/auth/checkViewerAllowed.ts | 4 +- .../server/auth/getApiKeyInjectionConfig.ts | 4 +- .../ui/docs-bundle/src/server/authProps.ts | 4 +- .../src/server/getDocsPageProps.ts | 8 +- .../src/server/getDynamicDocsPageProps.ts | 4 +- .../ui/docs-bundle/src/server/loadWithUrl.ts | 2 +- .../src/server/withBasicTokenPublic.ts | 2 +- .../src/server/withInitialProps.ts | 25 +-- .../ui/docs-bundle/src/server/withSSGProps.ts | 2 +- .../docs-bundle/src/server/xfernhost/edge.ts | 2 +- .../docs-bundle/src/server/xfernhost/node.ts | 2 +- packages/ui/docs-bundle/tsconfig.json | 11 +- packages/ui/fern-docs-auth/.depcheckrc.json | 1 + packages/ui/fern-docs-auth/.prettierrc.cjs | 1 + packages/ui/fern-docs-auth/.stylelintrc.json | 1 + packages/ui/fern-docs-auth/package.json | 50 +++++ .../src/auth => fern-docs-auth/src}/index.ts | 0 .../auth => fern-docs-auth/src}/injection.ts | 0 .../src/auth => fern-docs-auth/src}/types.ts | 0 packages/ui/fern-docs-auth/tsconfig.json | 8 + packages/ui/fern-docs-auth/vitest.config.ts | 7 + .../ui/fern-docs-edge-config/.depcheckrc.json | 1 + .../ui/fern-docs-edge-config/.prettierrc.cjs | 1 + .../fern-docs-edge-config/.stylelintrc.json | 1 + .../ui/fern-docs-edge-config/package.json | 55 +++++ .../src}/getAuthEdgeConfig.ts | 4 +- .../src}/getCustomerAnalytics.ts | 11 +- .../src/getFeatureFlags.ts | 165 +++++++++++++++ .../src/getInkeepSettings.ts | 8 + .../src/getLaunchDarklySettings.ts | 15 ++ .../src/getSeoDisabled.ts} | 2 +- .../ui/fern-docs-edge-config/src/index.ts | 6 + .../ui/fern-docs-edge-config/tsconfig.json | 19 ++ .../ui/fern-docs-edge-config/vitest.config.ts | 7 + .../src}/constants.ts | 1 + packages/ui/fern-docs-utils/src/flags.ts | 65 ++++++ packages/ui/fern-docs-utils/src/index.ts | 5 + .../src}/isCustomDomain.ts | 0 .../src}/isDevelopment.ts | 0 .../src}/withoutStaging.ts | 0 packages/ui/fern-docs-utils/tsconfig.json | 2 +- .../src/utils/getDocsPageProps.ts | 4 +- .../ui/local-preview-bundle/tsconfig.json | 2 +- pnpm-lock.yaml | 195 +++++++++--------- 98 files changed, 887 insertions(+), 535 deletions(-) create mode 100644 packages/ui/app/src/atoms/launchdarkly.ts create mode 100644 packages/ui/app/src/components/LinkPreload.tsx create mode 100644 packages/ui/docs-bundle/src/pages/api/fern-docs/integrations/launchdarkly/identify.ts create mode 100644 packages/ui/fern-docs-auth/.depcheckrc.json create mode 100644 packages/ui/fern-docs-auth/.prettierrc.cjs create mode 100644 packages/ui/fern-docs-auth/.stylelintrc.json create mode 100644 packages/ui/fern-docs-auth/package.json rename packages/ui/{app/src/auth => fern-docs-auth/src}/index.ts (100%) rename packages/ui/{app/src/auth => fern-docs-auth/src}/injection.ts (100%) rename packages/ui/{app/src/auth => fern-docs-auth/src}/types.ts (100%) create mode 100644 packages/ui/fern-docs-auth/tsconfig.json create mode 100644 packages/ui/fern-docs-auth/vitest.config.ts create mode 100644 packages/ui/fern-docs-edge-config/.depcheckrc.json create mode 100644 packages/ui/fern-docs-edge-config/.prettierrc.cjs create mode 100644 packages/ui/fern-docs-edge-config/.stylelintrc.json create mode 100644 packages/ui/fern-docs-edge-config/package.json rename packages/ui/{docs-bundle/src/server/auth => fern-docs-edge-config/src}/getAuthEdgeConfig.ts (86%) rename packages/ui/{docs-bundle/src/server => fern-docs-edge-config/src}/getCustomerAnalytics.ts (71%) create mode 100644 packages/ui/fern-docs-edge-config/src/getFeatureFlags.ts create mode 100644 packages/ui/fern-docs-edge-config/src/getInkeepSettings.ts create mode 100644 packages/ui/fern-docs-edge-config/src/getLaunchDarklySettings.ts rename packages/ui/{docs-bundle/src/server/disabledSeo.ts => fern-docs-edge-config/src/getSeoDisabled.ts} (82%) create mode 100644 packages/ui/fern-docs-edge-config/src/index.ts create mode 100644 packages/ui/fern-docs-edge-config/tsconfig.json create mode 100644 packages/ui/fern-docs-edge-config/vitest.config.ts rename packages/ui/{docs-bundle/src/server => fern-docs-utils/src}/constants.ts (94%) create mode 100644 packages/ui/fern-docs-utils/src/flags.ts rename packages/ui/{docs-bundle/src/server => fern-docs-utils/src}/isCustomDomain.ts (100%) rename packages/ui/{docs-bundle/src/server => fern-docs-utils/src}/isDevelopment.ts (100%) rename packages/ui/{docs-bundle/src/server => fern-docs-utils/src}/withoutStaging.ts (100%) diff --git a/packages/commons/fdr-utils/tsconfig.json b/packages/commons/fdr-utils/tsconfig.json index 54cc57ae2a..dc07764da5 100644 --- a/packages/commons/fdr-utils/tsconfig.json +++ b/packages/commons/fdr-utils/tsconfig.json @@ -7,7 +7,7 @@ "include": ["./src/**/*"], "references": [ { - "path": "../../fdr-sdk" + "path": "../../fdr-sdk/tsconfig.build.json" } ] } diff --git a/packages/commons/next-seo/src/jsonld/components/Breadcrumb.tsx b/packages/commons/next-seo/src/jsonld/components/Breadcrumb.tsx index 5eab60bfc1..3eb680a5ff 100644 --- a/packages/commons/next-seo/src/jsonld/components/Breadcrumb.tsx +++ b/packages/commons/next-seo/src/jsonld/components/Breadcrumb.tsx @@ -7,6 +7,7 @@ export const Breadcrumb = memo( return (