diff --git a/.pnp.cjs b/.pnp.cjs
index 5da4babfd9..296371da1c 100755
--- a/.pnp.cjs
+++ b/.pnp.cjs
@@ -3323,10 +3323,10 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) {
}]\
]],\
["@fern-fern/registry-browser", [\
- ["npm:0.17.0-8-g5dfc5af", {\
- "packageLocation": "./.yarn/cache/@fern-fern-registry-browser-npm-0.17.0-8-g5dfc5af-f827bf56ef-ad2f8a60dd.zip/node_modules/@fern-fern/registry-browser/",\
+ ["npm:0.19.1-10-gf615da5", {\
+ "packageLocation": "./.yarn/cache/@fern-fern-registry-browser-npm-0.19.1-10-gf615da5-50892051e6-26d1077db2.zip/node_modules/@fern-fern/registry-browser/",\
"packageDependencies": [\
- ["@fern-fern/registry-browser", "npm:0.17.0-8-g5dfc5af"],\
+ ["@fern-fern/registry-browser", "npm:0.19.1-10-gf615da5"],\
["@types/url-join", "npm:4.0.1"],\
["@ungap/url-search-params", "npm:0.2.2"],\
["axios", "npm:1.4.0"],\
@@ -3341,7 +3341,7 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) {
"packageLocation": "./packages/commons/app-utils/",\
"packageDependencies": [\
["@fern-ui/app-utils", "workspace:packages/commons/app-utils"],\
- ["@fern-fern/registry-browser", "npm:0.17.0-8-g5dfc5af"],\
+ ["@fern-fern/registry-browser", "npm:0.19.1-10-gf615da5"],\
["@fern-ui/core-utils", "workspace:packages/commons/core-utils"],\
["@types/jest", "npm:29.0.3"],\
["@types/lodash-es", "npm:4.17.9"],\
@@ -3442,7 +3442,7 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) {
"packageLocation": "./packages/ui/fe-bundle/",\
"packageDependencies": [\
["@fern-ui/fe-bundle", "workspace:packages/ui/fe-bundle"],\
- ["@fern-fern/registry-browser", "npm:0.17.0-8-g5dfc5af"],\
+ ["@fern-fern/registry-browser", "npm:0.19.1-10-gf615da5"],\
["@fern-ui/app-utils", "workspace:packages/commons/app-utils"],\
["@fern-ui/core-utils", "workspace:packages/commons/core-utils"],\
["@fern-ui/theme", "workspace:packages/commons/react/theme"],\
@@ -3699,7 +3699,7 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) {
["@blueprintjs/icons", "npm:4.9.0"],\
["@blueprintjs/popover2", "virtual:78e90867e46510db2994cf6ed805ab4ba701c55b6d7a2c33f6cc04865dc082c172bef019989477dda8bc6824512d13cb3bcb74ef12bd113a2f6bdcd291ad70f1#npm:1.8.0"],\
["@blueprintjs/select", "virtual:78e90867e46510db2994cf6ed805ab4ba701c55b6d7a2c33f6cc04865dc082c172bef019989477dda8bc6824512d13cb3bcb74ef12bd113a2f6bdcd291ad70f1#npm:4.5.1"],\
- ["@fern-fern/registry-browser", "npm:0.17.0-8-g5dfc5af"],\
+ ["@fern-fern/registry-browser", "npm:0.19.1-10-gf615da5"],\
["@fern-ui/app-utils", "workspace:packages/commons/app-utils"],\
["@fern-ui/core-utils", "workspace:packages/commons/core-utils"],\
["@fern-ui/react-commons", "workspace:packages/commons/react/react-commons"],\
diff --git a/.yarn/cache/@fern-fern-registry-browser-npm-0.17.0-8-g5dfc5af-f827bf56ef-ad2f8a60dd.zip b/.yarn/cache/@fern-fern-registry-browser-npm-0.19.1-10-gf615da5-50892051e6-26d1077db2.zip
similarity index 71%
rename from .yarn/cache/@fern-fern-registry-browser-npm-0.17.0-8-g5dfc5af-f827bf56ef-ad2f8a60dd.zip
rename to .yarn/cache/@fern-fern-registry-browser-npm-0.19.1-10-gf615da5-50892051e6-26d1077db2.zip
index cbdd17bf67..fa167673d5 100644
Binary files a/.yarn/cache/@fern-fern-registry-browser-npm-0.17.0-8-g5dfc5af-f827bf56ef-ad2f8a60dd.zip and b/.yarn/cache/@fern-fern-registry-browser-npm-0.19.1-10-gf615da5-50892051e6-26d1077db2.zip differ
diff --git a/packages/commons/app-utils/package.json b/packages/commons/app-utils/package.json
index 0769fb42cc..e337a0161d 100644
--- a/packages/commons/app-utils/package.json
+++ b/packages/commons/app-utils/package.json
@@ -27,7 +27,7 @@
"depcheck": "depcheck"
},
"dependencies": {
- "@fern-fern/registry-browser": "0.17.0-8-g5dfc5af",
+ "@fern-fern/registry-browser": "0.19.1-10-gf615da5",
"@fern-ui/core-utils": "workspace:*",
"lodash-es": "^4.17.21",
"next-mdx-remote": "^4.4.1",
diff --git a/packages/commons/app-utils/src/url-path-resolver/__test__/mocks.ts b/packages/commons/app-utils/src/url-path-resolver/__test__/mocks.ts
index 7ad1bc26c8..a861f6d169 100644
--- a/packages/commons/app-utils/src/url-path-resolver/__test__/mocks.ts
+++ b/packages/commons/app-utils/src/url-path-resolver/__test__/mocks.ts
@@ -55,4 +55,14 @@ export const MOCKS_DOCS_DEFINITION: FernRegistryDocsRead.DocsDefinition = {
],
},
},
+ search: {
+ type: "singleAlgoliaIndex",
+ value: {
+ type: "unversioned",
+ indexSegment: {
+ id: FernRegistryDocsRead.IndexSegmentId("seg_1"),
+ searchApiKey: "",
+ },
+ },
+ },
};
diff --git a/packages/ui/app/package.json b/packages/ui/app/package.json
index a996b32cad..481b29d377 100644
--- a/packages/ui/app/package.json
+++ b/packages/ui/app/package.json
@@ -33,7 +33,7 @@
"@blueprintjs/icons": "^4.4.0",
"@blueprintjs/popover2": "^1.8.0",
"@blueprintjs/select": "^4.4.2",
- "@fern-fern/registry-browser": "0.17.0-8-g5dfc5af",
+ "@fern-fern/registry-browser": "0.19.1-10-gf615da5",
"@fern-ui/app-utils": "workspace:*",
"@fern-ui/core-utils": "workspace:*",
"@fern-ui/react-commons": "workspace:*",
diff --git a/packages/ui/app/src/docs/Docs.tsx b/packages/ui/app/src/docs/Docs.tsx
index 5e2816922b..4efa41cab6 100644
--- a/packages/ui/app/src/docs/Docs.tsx
+++ b/packages/ui/app/src/docs/Docs.tsx
@@ -13,7 +13,7 @@ import { Header } from "./Header";
export const Docs: React.FC = memo(function UnmemoizedDocs() {
const docsContext = useDocsContext();
- const { docsDefinition, theme } = docsContext;
+ const { docsDefinition, docsInfo, theme } = docsContext;
const searchContext = useSearchContext();
const { isSearchDialogOpen, openSearchDialog, closeSearchDialog } = searchContext;
const searchService = useSearchService();
@@ -43,7 +43,13 @@ export const Docs: React.FC = memo(function UnmemoizedDocs() {
hasSpecifiedBackgroundImage={hasSpecifiedBackgroundImage}
/>
- {searchService.isAvailable &&
}
+ {searchService.isAvailable && (
+
+ )}
void;
+ activeVersion?: string;
}
}
export const SearchDialog: React.FC = (providedProps) => {
- const { isOpen, onClose } = providedProps;
+ const { isOpen, onClose, activeVersion } = providedProps;
const searchService = useSearchService();
if (!searchService.isAvailable) {
@@ -32,7 +33,11 @@ export const SearchDialog: React.FC = (providedProps) => {
= ({ hit }) => {
const { navigateToPath } = useDocsContext();
const { closeSearchDialog } = useSearchContext();
+ const handleClick = useCallback(() => {
+ closeSearchDialog();
+ navigateToPath(hit.path);
+ }, [closeSearchDialog, navigateToPath, hit.path]);
+
+ const { versionSlug, path } = hit;
+ const href = `/${versionSlug != null ? `${versionSlug}/` : ""}${path}`;
+
return (
{
- closeSearchDialog();
- navigateToPath(hit.path);
- }}
- href={`/${hit.path}`}
+ onClick={handleClick}
+ href={href}
>
{
- if (algoliaSearchIndex) {
+ const { docsDefinition, docsInfo } = useDocsContext();
+ const { search: searchInfo } = docsDefinition;
+
+ return useMemo(() => {
+ const envConfig = getEnvConfig();
+ if (typeof searchInfo !== "object") {
+ return docsDefinition.algoliaSearchIndex != null
+ ? {
+ isAvailable: true,
+ client: algolia(envConfig.algoliaAppId, envConfig.algoliaApiKey),
+ index: docsDefinition.algoliaSearchIndex,
+ }
+ : { isAvailable: false };
+ } else if (searchInfo.type === "legacyMultiAlgoliaIndex") {
+ const algoliaIndex = searchInfo.algoliaIndex ?? docsDefinition.algoliaSearchIndex;
+ return algoliaIndex != null
+ ? {
+ isAvailable: true,
+ client: algolia(envConfig.algoliaAppId, envConfig.algoliaApiKey),
+ index: algoliaIndex,
+ }
+ : { isAvailable: false };
+ } else if (searchInfo.value.type === "unversioned") {
+ if (docsInfo.type !== "unversioned") {
+ throw new Error("Inconsistent State: Received search info is unversioned but docs are versioned");
+ }
+ if (envConfig.algoliaSearchIndex == null) {
+ throw new Error('Missing environment variable "NEXT_PUBLIC_ALGOLIA_SEARCH_INDEX"');
+ }
+ const { indexSegment } = searchInfo.value;
+ return {
+ isAvailable: true,
+ client: algolia(envConfig.algoliaAppId, indexSegment.searchApiKey),
+ index: envConfig.algoliaSearchIndex,
+ };
+ } else {
+ if (docsInfo.type !== "versioned") {
+ throw new Error("Inconsistent State: Received search info is versioned but docs are unversioned");
+ }
+ const versionId = FernRegistry.docs.v1.read.VersionId(docsInfo.activeVersionName);
+ const { indexSegmentsByVersionId } = searchInfo.value;
+ const indexSegment = indexSegmentsByVersionId[versionId];
+ if (indexSegment == null) {
+ throw new Error(
+ `Inconsistent State: Did not receive index segment for version "${versionId}". This may indicate a backend bug.`
+ );
+ }
+ if (envConfig.algoliaSearchIndex == null) {
+ throw new Error('Missing environment variable "NEXT_PUBLIC_ALGOLIA_SEARCH_INDEX"');
+ }
return {
isAvailable: true,
- index: algoliaSearchIndex,
- client,
+ client: algolia(envConfig.algoliaAppId, indexSegment.searchApiKey),
+ index: envConfig.algoliaSearchIndex,
};
}
- return { isAvailable: false };
- }, [algoliaSearchIndex]);
+ }, [docsDefinition.algoliaSearchIndex, docsInfo, searchInfo]);
}
diff --git a/packages/ui/fe-bundle/.env-cmdrc.cjs b/packages/ui/fe-bundle/.env-cmdrc.cjs
index 77ebcbedec..1559c23158 100644
--- a/packages/ui/fe-bundle/.env-cmdrc.cjs
+++ b/packages/ui/fe-bundle/.env-cmdrc.cjs
@@ -4,11 +4,13 @@ module.exports = {
NEXT_PUBLIC_POSTHOG_API_KEY: "",
NEXT_PUBLIC_ALGOLIA_APP_ID: "CQINPZSKS3",
NEXT_PUBLIC_ALGOLIA_API_KEY: "9515d5b15764da73b5cfad85772779fa",
+ NEXT_PUBLIC_ALGOLIA_SEARCH_INDEX: "search_index_dev",
},
"fern-prod": {
NEXT_PUBLIC_FDR_ORIGIN: "https://registry.buildwithfern.com",
NEXT_PUBLIC_POSTHOG_API_KEY: "phc_yQgAEdJJkVpI24NdSRID2mor1x1leRpDoC9yZ9mfXal",
NEXT_PUBLIC_ALGOLIA_APP_ID: process.env.ALGOLIA_APP_ID,
NEXT_PUBLIC_ALGOLIA_API_KEY: process.env.ALGOLIA_API_KEY,
+ NEXT_PUBLIC_ALGOLIA_SEARCH_INDEX: process.env.ALGOLIA_SEARCH_INDEX,
},
};
diff --git a/packages/ui/fe-bundle/.mrlint.json b/packages/ui/fe-bundle/.mrlint.json
index 969da3ceca..8720297b7d 100644
--- a/packages/ui/fe-bundle/.mrlint.json
+++ b/packages/ui/fe-bundle/.mrlint.json
@@ -7,7 +7,8 @@
"NEXT_PUBLIC_FDR_ORIGIN",
"NEXT_PUBLIC_POSTHOG_API_KEY",
"NEXT_PUBLIC_ALGOLIA_APP_ID",
- "NEXT_PUBLIC_ALGOLIA_API_KEY"
+ "NEXT_PUBLIC_ALGOLIA_API_KEY",
+ "NEXT_PUBLIC_ALGOLIA_SEARCH_INDEX"
]
},
"rules": {
diff --git a/packages/ui/fe-bundle/package.json b/packages/ui/fe-bundle/package.json
index 22060e62e2..b437a5da2e 100644
--- a/packages/ui/fe-bundle/package.json
+++ b/packages/ui/fe-bundle/package.json
@@ -38,7 +38,7 @@
"lint:fern-prod": "yarn compile && yarn env:fern-prod next lint"
},
"dependencies": {
- "@fern-fern/registry-browser": "0.17.0-8-g5dfc5af",
+ "@fern-fern/registry-browser": "0.19.1-10-gf615da5",
"@fern-ui/app-utils": "workspace:*",
"@fern-ui/core-utils": "workspace:*",
"@fern-ui/theme": "workspace:*",
diff --git a/yarn.lock b/yarn.lock
index c29085d29e..d7e7a03d87 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -1851,16 +1851,16 @@ __metadata:
languageName: node
linkType: hard
-"@fern-fern/registry-browser@npm:0.17.0-8-g5dfc5af":
- version: 0.17.0-8-g5dfc5af
- resolution: "@fern-fern/registry-browser@npm:0.17.0-8-g5dfc5af"
+"@fern-fern/registry-browser@npm:0.19.1-10-gf615da5":
+ version: 0.19.1-10-gf615da5
+ resolution: "@fern-fern/registry-browser@npm:0.19.1-10-gf615da5"
dependencies:
"@types/url-join": 4.0.1
"@ungap/url-search-params": 0.2.2
axios: 1.4.0
js-base64: 3.7.2
url-join: 4.0.1
- checksum: ad2f8a60dda2dd8936f59f0b8388ac65b8e0d9b12fb3d9fe9d4aca5285899432617a2bfd6e522bb73066051850e99fccba3c80cbdf9aecddf861588fc1182d78
+ checksum: 26d1077db21daa51e5e1a9c56a4dd140f302a90e009aa44d08d547ad0da8fc3f0ff95907f05e972af324695f2f1227246b5340480bd86d57574b1356308620c0
languageName: node
linkType: hard
@@ -1868,7 +1868,7 @@ __metadata:
version: 0.0.0-use.local
resolution: "@fern-ui/app-utils@workspace:packages/commons/app-utils"
dependencies:
- "@fern-fern/registry-browser": 0.17.0-8-g5dfc5af
+ "@fern-fern/registry-browser": 0.19.1-10-gf615da5
"@fern-ui/core-utils": "workspace:*"
"@types/jest": ^29.0.3
"@types/lodash-es": 4.17.9
@@ -1961,7 +1961,7 @@ __metadata:
version: 0.0.0-use.local
resolution: "@fern-ui/fe-bundle@workspace:packages/ui/fe-bundle"
dependencies:
- "@fern-fern/registry-browser": 0.17.0-8-g5dfc5af
+ "@fern-fern/registry-browser": 0.19.1-10-gf615da5
"@fern-ui/app-utils": "workspace:*"
"@fern-ui/core-utils": "workspace:*"
"@fern-ui/theme": "workspace:*"
@@ -2200,7 +2200,7 @@ __metadata:
"@blueprintjs/icons": ^4.4.0
"@blueprintjs/popover2": ^1.8.0
"@blueprintjs/select": ^4.4.2
- "@fern-fern/registry-browser": 0.17.0-8-g5dfc5af
+ "@fern-fern/registry-browser": 0.19.1-10-gf615da5
"@fern-ui/app-utils": "workspace:*"
"@fern-ui/core-utils": "workspace:*"
"@fern-ui/react-commons": "workspace:*"