strapi-plugin-meilisearch 0.8.2 → 0.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
<h4 align="center">
|
|
8
8
|
<a href="https://github.com/meilisearch/meilisearch">Meilisearch</a> |
|
|
9
9
|
<a href="https://docs.meilisearch.com">Documentation</a> |
|
|
10
|
-
<a href="https://
|
|
10
|
+
<a href="https://discord.meilisearch.com">Discord</a> |
|
|
11
11
|
<a href="https://roadmap.meilisearch.com/tabs/1-under-consideration">Roadmap</a> |
|
|
12
12
|
<a href="https://www.meilisearch.com">Website</a> |
|
|
13
13
|
<a href="https://docs.meilisearch.com/faq">FAQ</a>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "strapi-plugin-meilisearch",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.1",
|
|
4
4
|
"description": "Synchronise and search in your Strapi content-types with Meilisearch",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"playground:dev": "yarn --cwd ./playground && yarn --cwd ./playground dev",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"README.md"
|
|
26
26
|
],
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@strapi/utils": "^4.5.
|
|
28
|
+
"@strapi/utils": "^4.5.4",
|
|
29
29
|
"meilisearch": "^0.30.0"
|
|
30
30
|
},
|
|
31
31
|
"peerDependencies": {},
|
|
@@ -37,7 +37,7 @@ module.exports = ({ strapi }) => {
|
|
|
37
37
|
addCollectionNamePrefix: function ({ contentType, entries }) {
|
|
38
38
|
return entries.map(entry => ({
|
|
39
39
|
...entry,
|
|
40
|
-
|
|
40
|
+
_meilisearch_id: this.addCollectionNamePrefixToId({
|
|
41
41
|
entryId: entry.id,
|
|
42
42
|
contentType,
|
|
43
43
|
}),
|
|
@@ -130,7 +130,9 @@ module.exports = ({ strapi, adapter, config }) => {
|
|
|
130
130
|
})
|
|
131
131
|
)
|
|
132
132
|
} else {
|
|
133
|
-
return client
|
|
133
|
+
return client
|
|
134
|
+
.index(indexUid)
|
|
135
|
+
.updateDocuments(sanitized, { primaryKey: '_meilisearch_id' })
|
|
134
136
|
}
|
|
135
137
|
})
|
|
136
138
|
},
|
|
@@ -251,7 +253,9 @@ module.exports = ({ strapi, adapter, config }) => {
|
|
|
251
253
|
adapter,
|
|
252
254
|
})
|
|
253
255
|
|
|
254
|
-
const task = await client
|
|
256
|
+
const task = await client
|
|
257
|
+
.index(indexUid)
|
|
258
|
+
.addDocuments(documents, { primaryKey: '_meilisearch_id' })
|
|
255
259
|
await store.addIndexedContentType({ contentType })
|
|
256
260
|
|
|
257
261
|
return task
|
|
@@ -285,7 +289,9 @@ module.exports = ({ strapi, adapter, config }) => {
|
|
|
285
289
|
})
|
|
286
290
|
|
|
287
291
|
// Add documents in Meilisearch
|
|
288
|
-
const task = await client
|
|
292
|
+
const task = await client
|
|
293
|
+
.index(indexUid)
|
|
294
|
+
.addDocuments(documents, { primaryKey: '_meilisearch_id' })
|
|
289
295
|
|
|
290
296
|
return task.taskUid
|
|
291
297
|
}
|
|
@@ -314,9 +320,9 @@ module.exports = ({ strapi, adapter, config }) => {
|
|
|
314
320
|
const indexUid = config.getIndexNameOfContentType({ contentType })
|
|
315
321
|
|
|
316
322
|
// Fetch contentTypes that has the same indexName as the provided contentType
|
|
317
|
-
const contentTypesWithSameIndex = await config
|
|
318
|
-
{ indexUid }
|
|
319
|
-
|
|
323
|
+
const contentTypesWithSameIndex = await config
|
|
324
|
+
.listContentTypesWithCustomIndexName({ indexName: indexUid })
|
|
325
|
+
.map(contentTypeName => `api::${contentTypeName}.${contentTypeName}`)
|
|
320
326
|
|
|
321
327
|
// get all contentTypes (not indexes) indexed in Meilisearch.
|
|
322
328
|
const indexedContentTypes = await store.getIndexedContentTypes()
|
|
@@ -343,7 +349,7 @@ module.exports = ({ strapi, adapter, config }) => {
|
|
|
343
349
|
}
|
|
344
350
|
)
|
|
345
351
|
if (indexedContentTypesWithSameIndex.length > 1) {
|
|
346
|
-
const deleteEntries = async (entries, contentType) => {
|
|
352
|
+
const deleteEntries = async ({ entries, contentType }) => {
|
|
347
353
|
await this.deleteEntriesFromMeiliSearch({
|
|
348
354
|
contentType,
|
|
349
355
|
entriesId: entries.map(entry => entry.id),
|