diff --git a/README.md b/README.md index 331c8518..2f813d57 100644 --- a/README.md +++ b/README.md @@ -533,7 +533,7 @@ If you are using [Strapi v3](https://github.com/strapi/strapi/tree/v3.6.9), plea **Supported Meilisearch versions**: -This package only guarantees the compatibility with the [version v0.27.0 of Meilisearch](https://github.com/meilisearch/meilisearch/releases/tag/v0.27.0). +This package only guarantees the compatibility with the [version v0.28.0 of Meilisearch](https://github.com/meilisearch/meilisearch/releases/tag/v0.28.0). **Node / NPM versions**: diff --git a/package.json b/package.json index 40bb7eeb..d60d7b3d 100644 --- a/package.json +++ b/package.json @@ -26,7 +26,7 @@ ], "dependencies": { "@strapi/utils": "^4.2.2", - "meilisearch": "^0.25.1" + "meilisearch": "^0.27.0" }, "peerDependencies": {}, "author": { diff --git a/server/__tests__/meilisearch.test.js b/server/__tests__/meilisearch.test.js index 40b93ef3..0b8547c3 100644 --- a/server/__tests__/meilisearch.test.js +++ b/server/__tests__/meilisearch.test.js @@ -13,7 +13,7 @@ const deleteDocuments = jest.fn(() => { return [{ uid: 1 }, { uid: 2 }] }) const getIndexes = jest.fn(() => { - return [{ uid: 'my_restaurant' }, { uid: 'restaurant' }] + return { results: [{ uid: 'my_restaurant' }, { uid: 'restaurant' }] } }) const getTasks = jest.fn(() => { diff --git a/server/services/meilisearch/client.js b/server/services/meilisearch/client.js index bc38bdd0..7897f4ae 100644 --- a/server/services/meilisearch/client.js +++ b/server/services/meilisearch/client.js @@ -1,5 +1,6 @@ 'use strict' const { MeiliSearch: Meilisearch } = require('meilisearch') +const packageJson = require('../../../package.json') /** * Create a Meilisearch client instance. @@ -8,4 +9,8 @@ const { MeiliSearch: Meilisearch } = require('meilisearch') * * @returns { object } - Meilisearch client instance. */ -module.exports = config => new Meilisearch(config) +module.exports = config => + new Meilisearch({ + ...config, + clientAgents: [`Meilisearch Strapi ${packageJson.version}`], + }) diff --git a/server/services/meilisearch/connector.js b/server/services/meilisearch/connector.js index d0937559..9056b52f 100644 --- a/server/services/meilisearch/connector.js +++ b/server/services/meilisearch/connector.js @@ -63,7 +63,7 @@ module.exports = ({ strapi, adapter, config }) => { try { const { apiKey, host } = await store.getCredentials() const client = Meilisearch({ apiKey, host }) - const indexes = await client.getIndexes() + const { results: indexes } = await client.getIndexes() return indexes } catch (e) { strapi.log.error(`meilisearch: ${e.message}`) @@ -280,7 +280,7 @@ module.exports = ({ strapi, adapter, config }) => { // Add documents in Meilisearch const task = await client.index(indexUid).addDocuments(documents) - return task.uid + return task.taskUid } const tasksUids = await contentTypeService.actionInBatches({ diff --git a/yarn.lock b/yarn.lock index e79d65df..3cbb2ae5 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3140,10 +3140,10 @@ makeerror@1.0.12: dependencies: tmpl "1.0.5" -meilisearch@^0.25.1: - version "0.25.1" - resolved "https://registry.yarnpkg.com/meilisearch/-/meilisearch-0.25.1.tgz#0dc25ffad64e6e50eb3da6c0691b0ff54f8578bf" - integrity sha512-20jO0pK9BhghxHSkOLbdoYn58h/Z0PNL3JQcRq7ipNIeqrxkAetCZZ6ttJC3uxcz0jVglmiFoSXu3Z/lEOLOLQ== +meilisearch@^0.27.0: + version "0.27.0" + resolved "https://registry.yarnpkg.com/meilisearch/-/meilisearch-0.27.0.tgz#8bd57ddb77b975f93e054cb977b951c488ece297" + integrity sha512-kZOZFIuSO7c6xRf+Y2/9/h6A9pl0sCl/G44X4KuaSwxGbruOZPhmxbeVEgLHBv4pUFvQ56rNVTA/2d/5GCU1YA== dependencies: cross-fetch "^3.1.5"