Skip to content

Commit 0f44764

Browse files
committed
Add changeset for autocomplete release
1 parent d24b516 commit 0f44764

File tree

11 files changed

+48
-29
lines changed

11 files changed

+48
-29
lines changed

.changeset/beige-snails-tan.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@meilisearch/instant-meilisearch": patch
3+
---
4+
5+
Export a new type `AlgoliaSearchForFacetValuesResponse`

.changeset/curly-seas-bow.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@meilisearch/autocomplete-client": minor
3+
---
4+
5+
Creation of search client compatible with autocomplete.

.github/workflows/meilisearch-prototype-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ jobs:
4747
- name: Setup node
4848
uses: actions/setup-node@v3
4949
with:
50-
node-version: 16
50+
node-version: 18
5151
cache: yarn
5252
- name: Install dependencies
5353
run: yarn

.github/workflows/pre-release-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ jobs:
4545
- name: Setup node
4646
uses: actions/setup-node@v3
4747
with:
48-
node-version: 16
48+
node-version: 18
4949
cache: yarn
5050
- name: Install dependencies
5151
run: yarn

packages/autocomplete-client/README.md

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ Since `autocomplete.js` provides the possibility to use a custom `data source`,
4343

4444
For general information on how to use Meilisearch—such as our API reference, tutorials, guides, and in-depth articles—refer to our [main documentation website](https://docs.meilisearch.com/).
4545

46+
For information on how to use the `autocomplete` library refer to its [documentation](https://www.algolia.com/doc/ui-libraries/autocomplete/introduction/what-is-autocomplete/). It provides all the necessery information to set up your autocomplete experience.
47+
4648
## 🔧 Installation
4749

4850
Use `npm` or `yarn` to install the autocomplete client for Meilisearch.
@@ -70,7 +72,7 @@ The Meilisearch Autocomplete client provides 2 methods:
7072

7173
## 🎬 Getting started
7274

73-
To make `autocomplete` work with meilisearch, create the `autocompleteSearchClient` and provide it to the `getMeilisearchResults` method as the searchClient.
75+
To make `autocomplete` work with Meilisearch, create the `autocompleteSearchClient` and provide it to the `getMeilisearchResults` method as the `searchClient`.
7476
The following code provides a basic working code example.
7577

7678
```js
@@ -106,7 +108,7 @@ autocomplete({
106108
},
107109
templates: {
108110
item({ item, components, html }) {
109-
return html` <div>
111+
return html`<div>
110112
<div>${item.name}</div>
111113
<div>${item.description}</div>
112114
</div>`
@@ -138,7 +140,6 @@ const client = meilisearchAutocompleteClient({
138140
placeholderSearch: false,
139141
},
140142
})
141-
142143
```
143144

144145
### Placeholder Search
@@ -192,9 +193,7 @@ The other strategy is `all`, where both `hello` and `world` **must** be present
192193

193194

194195
```js
195-
{
196-
matchingStrategy: 'all' // default last
197-
}
196+
{ matchingStrategy: 'all' } // default last
198197
```
199198

200199
### Request Config
@@ -233,11 +232,6 @@ You can use your own HTTP client, for example, with [`axios`](https://github.com
233232
}
234233
```
235234

236-
## More Documentation
237-
238-
- The open-source `autocomplete` library is widely used and well documented in the [Algolia documentation](https://www.algolia.com/doc/ui-libraries/autocomplete/introduction/what-is-autocomplete/). It provides all the necessery information to set up your autocomplete experience.
239-
- The [Meilisearch documentation](https://docs.meilisearch.com/).
240-
241235
## 🤖 Compatibility with Meilisearch and Autocomplete
242236

243237
**Supported autocomplete versions**:
@@ -247,12 +241,12 @@ This package only guarantees the compatibility with the [version v1.x.x of Autoc
247241
**API compatibility with `autocomplete`**
248242
Some `autocomplete` parameters are not working using the meilisearch autocomplete client.
249243

250-
- The autocomplete [insights] parameters (https://www.algolia.com/doc/ui-libraries/autocomplete/api-reference/autocomplete-js/autocomplete/#param-insights)
244+
- The autocomplete [insights parameter](https://www.algolia.com/doc/ui-libraries/autocomplete/api-reference/autocomplete-js/autocomplete/#param-insights)
251245
- The [autocomplete-plugin-algolia-insights](https://www.algolia.com/doc/ui-libraries/autocomplete/api-reference/autocomplete-plugin-algolia-insights/) plugin
252246

253247
**Supported Meilisearch versions**:
254248

255-
This package only guarantees the compatibility with the [version v1.0.0 of Meilisearch](https://github.com/meilisearch/meilisearch/releases/tag/v1.0.0).
249+
This package guarantees compatibility with [version v1.x of Meilisearch](https://github.com/meilisearch/meilisearch/releases/latest), but some features may not be present. Please check the [issues](https://github.com/meilisearch/instant-meilisearch/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22+label%3Aenhancement) for more info.
256250

257251
**Node / NPM versions**:
258252

packages/autocomplete-client/__tests__/test.utils.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { meilisearchAutocompleteClient } from '../src'
2+
import { MeiliSearch } from 'meilisearch'
23

34
const dataset = [
45
{ id: 1, label: 'Hit 1' },
@@ -10,4 +11,10 @@ const searchClient = meilisearchAutocompleteClient({
1011
url: HOST,
1112
apiKey: API_KEY,
1213
})
13-
export { HOST, API_KEY, searchClient, dataset }
14+
15+
const meilisearchClient = new MeiliSearch({
16+
host: 'http://localhost:7700',
17+
apiKey: 'masterKey',
18+
})
19+
20+
export { HOST, API_KEY, searchClient, dataset, meilisearchClient }
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
export const HIGHLIGHT_PRE_TAG = '__aa-highlight__'
22
export const HIGHLIGHT_POST_TAG = '__/aa-highlight__'
3+
export const HITS_PER_PAGE = 5

packages/autocomplete-client/src/requesters/__tests__/getmeilisearchResults.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { getMeilisearchResults } from '../'
22
import { searchClient } from '../../../__tests__/test.utils'
33

44
describe('getMeilisearchResults', () => {
5-
test('returns the description', () => {
5+
test('the the fields in the returned description object', () => {
66
const description = getMeilisearchResults({
77
searchClient,
88
queries: [
@@ -35,7 +35,7 @@ describe('getMeilisearchResults', () => {
3535
})
3636
})
3737

38-
test('defaults transformItems to retrieve hits', () => {
38+
test('the default transformItems method on the retrieved hits', () => {
3939
const description = getMeilisearchResults<{ label: string }>({
4040
searchClient,
4141
queries: [

packages/autocomplete-client/src/search/__tests__/fetchMeilisearchResults.test.ts

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
import { fetchMeilisearchResults } from '../fetchMeilisearchResults'
2-
import { searchClient, dataset } from '../../../__tests__/test.utils'
3-
import { MeiliSearch } from 'meilisearch'
2+
import {
3+
searchClient,
4+
dataset,
5+
meilisearchClient,
6+
} from '../../../__tests__/test.utils'
47

58
beforeAll(async () => {
6-
const client = new MeiliSearch({
7-
host: 'http://localhost:7700',
8-
apiKey: 'masterKey',
9-
})
10-
const task = await client.index('testUid').addDocuments(dataset)
11-
await client.waitForTask(task.taskUid)
9+
await meilisearchClient.deleteIndex('testUid')
10+
const task = await meilisearchClient.index('testUid').addDocuments(dataset)
11+
await meilisearchClient.waitForTask(task.taskUid)
12+
})
13+
14+
afterAll(async () => {
15+
await meilisearchClient.deleteIndex('testUid')
1216
})
1317

1418
describe('fetchMeilisearchResults', () => {

packages/autocomplete-client/src/search/fetchMeilisearchResults.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@ import {
22
AlgoliaMultipleQueriesQuery,
33
AlgoliaSearchResponse,
44
} from '@meilisearch/instant-meilisearch'
5-
import { HIGHLIGHT_PRE_TAG, HIGHLIGHT_POST_TAG } from '../constants'
5+
import {
6+
HIGHLIGHT_PRE_TAG,
7+
HIGHLIGHT_POST_TAG,
8+
HITS_PER_PAGE,
9+
} from '../constants'
610
import { SearchClient as MeilisearchSearchClient } from '../types/SearchClient'
711

812
interface SearchParams {
@@ -28,7 +32,7 @@ export function fetchMeilisearchResults<TRecord = Record<string, any>>({
2832
return {
2933
...headers,
3034
params: {
31-
hitsPerPage: 5,
35+
hitsPerPage: HITS_PER_PAGE,
3236
highlightPreTag: HIGHLIGHT_PRE_TAG,
3337
highlightPostTag: HIGHLIGHT_POST_TAG,
3438
...params,

0 commit comments

Comments
 (0)