Skip to content
This repository has been archived by the owner on Dec 30, 2022. It is now read-only.

feat(algoliasearch): add support for algoliasearch v4 #2890

Merged
merged 17 commits into from
Jan 30, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
7 changes: 6 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,12 @@ jobs:
- save_cache: *save_yarn_cache
- run:
name: Install algoliasearch v3
command: yarn add -D -W "algoliasearch@3.35.1"
command: |
yarn remove -W @algolia/client-search
yarn add -W @types/algoliasearch@3.34.8 algoliasearch@3.35.1
- run:
name: Type checking
command: yarn type-check
- run:
name: Unit Tests
command: yarn test --maxWorkers=4
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"website:build": "yarn build && yarn webpack --config website/webpack.config.js"
},
"devDependencies": {
"@algolia/client-search": "4.0.0-beta.14",
"@babel/cli": "7.4.4",
"@babel/core": "7.4.5",
"@babel/plugin-proposal-class-properties": "7.4.4",
Expand Down
21 changes: 20 additions & 1 deletion packages/react-instantsearch-core/src/widgets/InstantSearch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,26 @@ import createInstantSearchManager from '../core/createInstantSearchManager';
import { InstantSearchProvider, InstantSearchContext } from '../core/context';
import { Store } from '../core/createStore';
import { PlainSearchParameters, SearchParameters } from 'algoliasearch-helper';
import { SearchResponse } from '@algolia/client-search';

import algoliasearch, {
yannickcr marked this conversation as resolved.
Show resolved Hide resolved
// @ts-ignore
Response as SearchResponseV3,
} from 'algoliasearch';
import {
SearchResponse as SearchResponseV4,
// @ts-ignore
// eslint-disable-next-line import/no-unresolved
} from '@algolia/client-search';

type DummySearchClientV4 = {
readonly addAlgoliaAgent: (segment: string, version?: string) => void;
};

type SearchResponse<THit> = ReturnType<
typeof algoliasearch
> extends DummySearchClientV4
? SearchResponseV4<THit>
: SearchResponseV3<THit>;

interface MultiResponse<THit = any> {
results: Array<SearchResponse<THit>>;
Expand Down