Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump algoliasearch from 5.2.5 to 5.10.1 #232

Merged
merged 4 commits into from
Oct 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/models/SearchHits.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Hit, SearchHits } from "algoliasearch";
import { Hit, SearchHits } from "@algolia/client-search";
// eslint-disable-next-line import/no-extraneous-dependencies
import algoliasearchHelper from "algoliasearch-helper";
import { Service } from "./Service";
Expand Down
6 changes: 3 additions & 3 deletions app/pages/ServiceListingPage/ServiceListingPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ import {
Service,
} from "../../models";
import styles from "./ServiceListingPage.module.scss";
import { algoliasearch } from "algoliasearch";
import { searchClient } from "@algolia/client-search";
Copy link
Collaborator

@rosschapman rosschapman Oct 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: This is lighter package for working just with search and index objects without bringing in other APIs for Recommend, Analytics, A/B testing, etc.... See: https://www.algolia.com/doc/libraries/javascript/v5/methods/search/.

However, we are still importing the larger complete algoliasearch package. It's a bit of a longer story, but ideally I would just use the algoliasearch/lite module everywhere. But there are some type issues emanating when using that for single record lookup with client.getObject. These particular types errors were supposed to be fixed in v5.2.x. So strange we're seeing them:

ERROR in ./node_modules/algoliasearch/dist/browser.js 22:19-28
export 'EventType' (imported as 'EventType') was not found in '@algolia/client-personalization' (possible exports: apiClientVersion, personalizationClient)
 @ ./app/pages/ServiceListingPage/ServiceListingPage.tsx 14:0-45 16:15-27
 @ ./app/Router.tsx 9:0-81 54:62-80
 @ ./app/components/ui/Navigation/Navigation.tsx 10:0-41 85:38-44
 @ ./app/components/ui/index.ts 5:0-40 5:0-40
 @ ./app/App.tsx 9:0-61 42:44-50 79:40-50 79:92-98
 @ ./app/init.tsx 6:0-28 11:211-214

On top of that we actually only need avail ourselves of single record lookup with getObject as a hack for service data that might be missing. So the algolia story is a little bit of a mess right now but I think over time we'll be able to figure out a solution using a single, leaner algolia search JS module. I'm just not going to worry about it too much at this moment.

import config from "./../../config";

const searchClient = algoliasearch(
const client = searchClient(
config.ALGOLIA_APPLICATION_ID,
config.ALGOLIA_READ_ONLY_API_KEY
);
Expand Down Expand Up @@ -75,7 +75,7 @@ export const ServiceListingPage = () => {
try {
// CAVEAT: Hopefully this does not change!
const serviceObjectID = `service_${pathname.split("/")[2]}`;
const service = (await searchClient.getObject({
const service = (await client.getObject({
indexName: INDEX_NAME,
objectID: serviceObjectID,
})) as unknown as Service;
Expand Down
2 changes: 1 addition & 1 deletion app/utils/useAppContext.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { AroundRadius } from "algoliasearch";
import { AroundRadius } from "@algolia/client-search";
import React, {
useMemo,
createContext,
Expand Down
186 changes: 132 additions & 54 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@
},
"browser": "app/init.jsx",
"dependencies": {
"@algolia/client-search": "^5.10.1",
"@babel/polyfill": "^7.4.4",
"algoliasearch": "^5.2.5",
"algoliasearch": "^5.10.1",
"classnames": "^2.2.6",
"copy-webpack-plugin": "^12.0.2",
"google-map-react": "^2.2.1",
Expand Down
Loading