Skip to content

Commit 9475ced

Browse files
meili-bors[bot]meili-botbidoubiwa
authored
Merge #139
139: Changes related to the next Meilisearch release (v0.28.0) r=bidoubiwa a=meili-bot This PR gathers the changes related to the next Meilisearch release (v0.28.0) so that this package is ready when the official release is out. ⚠️ This PR should NOT be merged until: - the next release of Meilisearch (v0.28.0) is out. - the [`meilisearch-js`](https://github.com/meilisearch/meilisearch-js) dependency has been released to be compatible with Meilisearch v0.28.0. Once the release is out, the upgrade of the `meilisearch-js` dependency might be committed to this branch. _This PR is auto-generated for the [pre-release week](https://github.com/meilisearch/integration-guides/blob/master/guides/pre-release-week.md) purpose._ _Related to this issue: https://github.com/meilisearch/integration-guides/issues/205_ Co-authored-by: meili-bot <[email protected]> Co-authored-by: Charlotte Vermandel <[email protected]> Co-authored-by: cvermand <[email protected]>
2 parents 6b9e6fb + 20c8a32 commit 9475ced

File tree

9 files changed

+67
-36
lines changed

9 files changed

+67
-36
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,7 @@ Full usage example:
453453
454454
**Supported Meilisearch versions**:
455455
456-
This package only guarantees the compatibility with the [version v0.27.0 of Meilisearch](https://github.com/meilisearch/meilisearch/releases/tag/v0.27.0).
456+
This package only guarantees the compatibility with the [version v0.28.0 of Meilisearch](https://github.com/meilisearch/meilisearch/releases/tag/v0.28.0).
457457
458458
**Node / NPM versions**:
459459

gatsby-node.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const { MeiliSearch } = require('meilisearch')
2-
2+
const { constructClientAgents } = require('./src/agents')
33
const {
44
validatePluginOptions,
55
validateIndexOptions,
@@ -27,6 +27,7 @@ exports.onPostBuild = async function ({ graphql, reporter }, config) {
2727
skipIndexing = false,
2828
batchSize = 1000,
2929
indexes,
30+
clientAgents = [],
3031
} = config
3132

3233
if (skipIndexing) {
@@ -59,14 +60,15 @@ exports.onPostBuild = async function ({ graphql, reporter }, config) {
5960
const client = new MeiliSearch({
6061
host: host,
6162
apiKey: apiKey,
63+
clientAgents: constructClientAgents(clientAgents),
6264
})
6365

6466
const index = client.index(currentIndex.indexUid)
6567
await index.delete()
6668

6769
// Add settings to Index
6870
if (currentIndex.settings) {
69-
const { uid: settingsUid } = await index.updateSettings(
71+
const { taskUid: settingsUid } = await index.updateSettings(
7072
currentIndex.settings
7173
)
7274
index.waitForTask(settingsUid)
@@ -89,10 +91,11 @@ exports.onPostBuild = async function ({ graphql, reporter }, config) {
8991

9092
// Wait for indexation to be completed
9193
for (const enqueuedUpdate of enqueuedUpdates) {
92-
await index.waitForTask(enqueuedUpdate.uid)
93-
const res = await index.getTask(enqueuedUpdate.uid)
94-
if (res.status === 'failed') {
95-
throw getErrorMsg(`${res.error.message} (${res.error.code})`)
94+
await index.waitForTask(enqueuedUpdate.taskUid)
95+
const task = await index.getTask(enqueuedUpdate.taskUid)
96+
97+
if (task.status === 'failed') {
98+
throw getErrorMsg(`${task.error?.message} (${task.error?.code})`)
9699
}
97100
}
98101
})

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,6 @@
5656
"wait-port": "^0.2.9"
5757
},
5858
"dependencies": {
59-
"meilisearch": "^0.25.1"
59+
"meilisearch": "^0.27.0"
6060
}
6161
}

playground/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
"dependencies": {
3333
"@mdx-js/mdx": "^1.6.22",
3434
"@mdx-js/react": "^1.6.22",
35-
"@meilisearch/instant-meilisearch": "^0.6.1",
35+
"@meilisearch/instant-meilisearch": "^0.8.0",
3636
"gatsby": "^4.3.0",
3737
"gatsby-image": "^3.11.0",
3838
"gatsby-plugin-mdx": "^3.3.0",

playground/yarn.lock

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1969,12 +1969,12 @@
19691969
resolved "https://registry.yarnpkg.com/@mdx-js/util/-/util-2.0.0-next.8.tgz#66ecc27b78e07a3ea2eb1a8fc5a99dfa0ba96690"
19701970
integrity sha512-T0BcXmNzEunFkuxrO8BFw44htvTPuAoKbLvTG41otyZBDV1Rs+JMddcUuaP5vXpTWtgD3grhcrPEwyx88RUumQ==
19711971

1972-
"@meilisearch/instant-meilisearch@^0.6.1":
1973-
version "0.6.1"
1974-
resolved "https://registry.yarnpkg.com/@meilisearch/instant-meilisearch/-/instant-meilisearch-0.6.1.tgz#b657b611f8eb79a030ded16cd977dfe7df899b30"
1975-
integrity sha512-7BHvtB/IMZUvvWozfGCeS8nNPumMyYQ9OfJO09O2SqSxZfeuGqvxWJagMW5G4vo6xW2e9u7WzbwpV3YRfRc0lg==
1972+
"@meilisearch/instant-meilisearch@^0.8.0":
1973+
version "0.8.0"
1974+
resolved "https://registry.yarnpkg.com/@meilisearch/instant-meilisearch/-/instant-meilisearch-0.8.0.tgz#c15db59446ed450f8ee22c079fcdf848b70bbab1"
1975+
integrity sha512-yqSm0oi7pqEHn5ZD3kIc8RE2wQGXn3bwXrZxHz9K1R7Ld72inax3PvdVZbVKSuyv4i2tnBh9WFT3YfrewL0Kew==
19761976
dependencies:
1977-
meilisearch "0.25.0"
1977+
meilisearch "^0.27.0"
19781978

19791979
"@microsoft/[email protected]":
19801980
version "2.0.1"
@@ -8210,10 +8210,10 @@ [email protected]:
82108210
resolved "https://registry.yarnpkg.com/media-typer/-/media-typer-0.3.0.tgz#8710d7af0aa626f8fffa1ce00168545263255748"
82118211
integrity sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g=
82128212

8213-
meilisearch@0.25.0:
8214-
version "0.25.0"
8215-
resolved "https://registry.yarnpkg.com/meilisearch/-/meilisearch-0.25.0.tgz#8e980fbdd36b9fe6ed606205e262418f21e64d84"
8216-
integrity sha512-TSIJTh5lva7WHBaoG3arNYQXuIAQkcD3BY09h2nHhjHS/wzxWKJM45x5bEC67Grw8zXihVqqmWty4a4ps4S+tg==
8213+
meilisearch@^0.27.0:
8214+
version "0.27.0"
8215+
resolved "https://registry.yarnpkg.com/meilisearch/-/meilisearch-0.27.0.tgz#8bd57ddb77b975f93e054cb977b951c488ece297"
8216+
integrity sha512-kZOZFIuSO7c6xRf+Y2/9/h6A9pl0sCl/G44X4KuaSwxGbruOZPhmxbeVEgLHBv4pUFvQ56rNVTA/2d/5GCU1YA==
82178217
dependencies:
82188218
cross-fetch "^3.1.5"
82198219

src/agents.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
const { version } = require('../package.json')
2+
3+
const constructClientAgents = (clientAgents = []) => {
4+
const gatsbyAgent = `Meilisearch Gatsby (v${version})`
5+
6+
return clientAgents.concat(gatsbyAgent)
7+
}
8+
9+
module.exports = {
10+
constructClientAgents,
11+
}

tests/index-to-meilisearch.test.js

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
/* eslint-disable no-undef */
22
const { MeiliSearch } = require('meilisearch')
33
const { onPostBuild } = require('../gatsby-node.js')
4-
const { fakeConfig, fakeGraphql, fakeReporter } = require('./utils')
4+
const {
5+
fakeConfig,
6+
fakeGraphql,
7+
fakeReporter,
8+
clearAllIndexes,
9+
} = require('./utils')
510

611
const activity = fakeReporter.activityTimer()
712

@@ -12,15 +17,10 @@ const client = new MeiliSearch({
1217

1318
describe('Index to Meilisearch', () => {
1419
beforeEach(async () => {
15-
try {
16-
await Promise.all(
17-
fakeConfig.indexes.map(
18-
async index => await client.deleteIndex(index.indexUid)
19-
)
20-
)
21-
} catch (e) {
22-
return
23-
}
20+
return clearAllIndexes({
21+
host: fakeConfig.host,
22+
apiKey: fakeConfig.apiKey,
23+
})
2424
})
2525

2626
test('Should fail if the indexes field is not provided', async () => {
@@ -205,8 +205,9 @@ describe('Index to Meilisearch', () => {
205205
],
206206
}
207207
)
208-
const indexes = await client.getIndexes()
209-
expect(indexes).toHaveLength(2)
208+
const { results } = await client.getIndexes()
209+
210+
expect(results).toHaveLength(2)
210211
})
211212

212213
test('Should delete index and recreate a new one', async () => {
@@ -252,7 +253,7 @@ describe('Index to Meilisearch', () => {
252253
.index(fakeConfig.indexes[0].indexUid)
253254
.search('Axolotl')
254255

255-
expect(firstQueryResult.nbHits).toBe(1)
256+
expect(firstQueryResult.estimatedTotalHits).toBe(1)
256257

257258
await onPostBuild(
258259
{ graphql: fakeGraphql, reporter: fakeReporter },
@@ -271,7 +272,7 @@ describe('Index to Meilisearch', () => {
271272
.index(fakeConfig.indexes[0].indexUid)
272273
.search('Axolotl')
273274

274-
expect(secondQueryResult.nbHits).toBe(0)
275+
expect(secondQueryResult.estimatedTotalHits).toBe(0)
275276
})
276277

277278
test('Should succeed and index with good config format', async () => {

tests/utils.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/* eslint-disable no-undef */
2+
const { MeiliSearch } = require('meilisearch')
23

34
const fakeConfig = {
45
host: process.env.MEILI_HTTP_ADDR || 'http://localhost:7700',
@@ -54,8 +55,23 @@ const fakeReporter = {
5455
error: jest.fn(() => {}),
5556
}
5657

58+
const clearAllIndexes = async config => {
59+
const client = new MeiliSearch(config)
60+
61+
const { results } = await client.getRawIndexes()
62+
const indexes = results.map(elem => elem.uid)
63+
64+
const taskIds = []
65+
for (const indexUid of indexes) {
66+
const { taskUid } = await client.index(indexUid).delete()
67+
taskIds.push(taskUid)
68+
}
69+
await client.waitForTasks(taskIds)
70+
}
71+
5772
module.exports = {
5873
fakeConfig,
5974
fakeGraphql,
75+
clearAllIndexes,
6076
fakeReporter,
6177
}

yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9387,10 +9387,10 @@ [email protected]:
93879387
resolved "https://registry.yarnpkg.com/media-typer/-/media-typer-0.3.0.tgz#8710d7af0aa626f8fffa1ce00168545263255748"
93889388
integrity sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g=
93899389

9390-
meilisearch@^0.25.1:
9391-
version "0.25.1"
9392-
resolved "https://registry.yarnpkg.com/meilisearch/-/meilisearch-0.25.1.tgz#0dc25ffad64e6e50eb3da6c0691b0ff54f8578bf"
9393-
integrity sha512-20jO0pK9BhghxHSkOLbdoYn58h/Z0PNL3JQcRq7ipNIeqrxkAetCZZ6ttJC3uxcz0jVglmiFoSXu3Z/lEOLOLQ==
9390+
meilisearch@^0.27.0:
9391+
version "0.27.0"
9392+
resolved "https://registry.yarnpkg.com/meilisearch/-/meilisearch-0.27.0.tgz#8bd57ddb77b975f93e054cb977b951c488ece297"
9393+
integrity sha512-kZOZFIuSO7c6xRf+Y2/9/h6A9pl0sCl/G44X4KuaSwxGbruOZPhmxbeVEgLHBv4pUFvQ56rNVTA/2d/5GCU1YA==
93949394
dependencies:
93959395
cross-fetch "^3.1.5"
93969396

0 commit comments

Comments
 (0)