@vegan-friendly/strapi-plugin-elasticsearch 0.1.0-alpha.3 → 0.1.0

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.
Files changed (97) hide show
  1. package/dist/admin/index.js +4 -4
  2. package/dist/admin/pluginId.js +1 -1
  3. package/dist/admin/src/components/Initializer/index.js +2 -1
  4. package/dist/admin/src/components/SubNavigation/index.js +10 -8
  5. package/dist/admin/src/pages/ConfigureCollectionList/index.js +40 -28
  6. package/dist/admin/src/pages/Homepage/index.js +20 -21
  7. package/dist/admin/src/pluginId.d.ts +1 -1
  8. package/dist/admin/src/utils/apiUrls.js +1 -0
  9. package/dist/admin/src/utils/axiosInstance.js +1 -2
  10. package/dist/package.json +63 -0
  11. package/dist/server/bootstrap.d.ts +4 -0
  12. package/dist/server/bootstrap.js +3 -3
  13. package/dist/server/config/index.d.ts +5 -0
  14. package/dist/server/config/index.js +2 -1
  15. package/dist/server/content-types/index.d.ts +83 -2
  16. package/dist/server/content-types/index.js +9 -5
  17. package/dist/server/content-types/indexing-logs.d.ts +32 -0
  18. package/dist/server/content-types/indexing-logs.js +22 -24
  19. package/dist/server/content-types/tasks.d.ts +46 -0
  20. package/dist/server/content-types/tasks.js +33 -38
  21. package/dist/server/controllers/configure-indexing.d.ts +11 -0
  22. package/dist/server/controllers/configure-indexing.js +3 -2
  23. package/dist/server/controllers/index.d.ts +33 -5
  24. package/dist/server/controllers/index.js +15 -11
  25. package/dist/server/controllers/log-indexing.d.ts +6 -0
  26. package/dist/server/controllers/log-indexing.js +3 -2
  27. package/dist/server/controllers/perform-indexing.d.ts +8 -0
  28. package/dist/server/controllers/perform-indexing.js +3 -2
  29. package/dist/server/controllers/perform-search.d.ts +4 -1
  30. package/dist/server/controllers/perform-search.js +11 -8
  31. package/dist/server/controllers/setup-info.d.ts +6 -0
  32. package/dist/server/controllers/setup-info.js +2 -1
  33. package/dist/server/destroy.d.ts +4 -0
  34. package/dist/server/destroy.js +2 -1
  35. package/dist/server/index.d.ts +312 -10
  36. package/dist/server/index.js +25 -21
  37. package/dist/server/middlewares/index.d.ts +2 -0
  38. package/dist/server/middlewares/index.js +2 -1
  39. package/dist/server/policies/index.d.ts +2 -0
  40. package/dist/server/policies/index.js +2 -1
  41. package/dist/server/register.d.ts +4 -0
  42. package/dist/server/register.js +2 -1
  43. package/dist/server/routes/configure-indexing.d.ts +12 -0
  44. package/dist/server/routes/configure-indexing.js +2 -1
  45. package/dist/server/routes/index.d.ts +58 -5
  46. package/dist/server/routes/index.js +15 -11
  47. package/dist/server/routes/perform-indexing.d.ts +12 -0
  48. package/dist/server/routes/perform-indexing.js +2 -1
  49. package/dist/server/routes/perform-search.d.ts +12 -0
  50. package/dist/server/routes/perform-search.js +4 -3
  51. package/dist/server/routes/run-log.d.ts +12 -0
  52. package/dist/server/routes/run-log.js +3 -2
  53. package/dist/server/routes/setup-info.d.ts +12 -0
  54. package/dist/server/routes/setup-info.js +3 -2
  55. package/dist/server/services/configure-indexing.d.ts +23 -23
  56. package/dist/server/services/configure-indexing.js +30 -18
  57. package/dist/server/services/es-interface.d.ts +27 -4
  58. package/dist/server/services/es-interface.js +13 -14
  59. package/dist/server/services/helper.d.ts +34 -33
  60. package/dist/server/services/helper.js +31 -23
  61. package/dist/server/services/index.d.ts +124 -7
  62. package/dist/server/services/index.js +19 -15
  63. package/dist/server/services/log-indexing.d.ts +8 -0
  64. package/dist/server/services/log-indexing.js +8 -7
  65. package/dist/server/services/perform-indexing.d.ts +8 -0
  66. package/dist/server/services/perform-indexing.js +29 -16
  67. package/dist/server/services/schedule-indexing.d.ts +19 -0
  68. package/dist/server/services/schedule-indexing.js +13 -12
  69. package/dist/server/services/transform-content.d.ts +7 -2
  70. package/dist/server/services/transform-content.js +4 -3
  71. package/package.json +4 -2
  72. package/dist/admin/components/Initializer/index.d.ts +0 -15
  73. package/dist/admin/components/Initializer/index.js +0 -25
  74. package/dist/admin/components/PluginIcon/index.d.ts +0 -8
  75. package/dist/admin/components/PluginIcon/index.js +0 -14
  76. package/dist/admin/components/SubNavigation/index.d.ts +0 -4
  77. package/dist/admin/components/SubNavigation/index.js +0 -40
  78. package/dist/admin/pages/App/index.d.ts +0 -9
  79. package/dist/admin/pages/App/index.js +0 -29
  80. package/dist/admin/pages/ConfigureCollection/index.d.ts +0 -3
  81. package/dist/admin/pages/ConfigureCollection/index.js +0 -193
  82. package/dist/admin/pages/ConfigureCollectionList/index.d.ts +0 -3
  83. package/dist/admin/pages/ConfigureCollectionList/index.js +0 -228
  84. package/dist/admin/pages/Homepage/index.d.ts +0 -3
  85. package/dist/admin/pages/Homepage/index.js +0 -155
  86. package/dist/admin/pages/ViewIndexingRunLog/index.d.ts +0 -3
  87. package/dist/admin/pages/ViewIndexingRunLog/index.js +0 -125
  88. package/dist/admin/utils/apiUrls.d.ts +0 -10
  89. package/dist/admin/utils/apiUrls.js +0 -20
  90. package/dist/admin/utils/axiosInstance.d.ts +0 -5
  91. package/dist/admin/utils/axiosInstance.js +0 -33
  92. package/dist/admin/utils/getTrad.d.ts +0 -2
  93. package/dist/admin/utils/getTrad.js +0 -8
  94. package/dist/strapi-admin.d.ts +0 -0
  95. package/dist/strapi-admin.js +0 -2
  96. package/dist/strapi-server.d.ts +0 -0
  97. package/dist/strapi-server.js +0 -2
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  ///START : via https://raw.githubusercontent.com/Barelydead/strapi-plugin-populate-deep/main/server/helpers/index.js
3
- const { isEmpty, merge } = require("lodash/fp");
4
- const transformServiceProvider = require('./transform-content');
3
+ var __importDefault = (this && this.__importDefault) || function (mod) {
4
+ return (mod && mod.__esModule) ? mod : { "default": mod };
5
+ };
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ const fp_1 = require("lodash/fp");
8
+ const transform_content_1 = __importDefault(require("./transform-content"));
5
9
  const getPluginStore = () => {
6
10
  return strapi.store({
7
11
  environment: '',
@@ -29,7 +33,7 @@ const getFullPopulateObject = (modelUid, maxDepth = 20, ignore) => {
29
33
  if (ignore && !ignore.includes(model.collectionName))
30
34
  ignore.push(model.collectionName);
31
35
  for (const [key, value] of Object.entries(getModelPopulationAttributes(model))) {
32
- if (ignore === null || ignore === void 0 ? void 0 : ignore.includes(key))
36
+ if (ignore?.includes(key))
33
37
  continue;
34
38
  if (value) {
35
39
  if (value.type === "component") {
@@ -38,9 +42,9 @@ const getFullPopulateObject = (modelUid, maxDepth = 20, ignore) => {
38
42
  else if (value.type === "dynamiczone") {
39
43
  const dynamicPopulate = value.components.reduce((prev, cur) => {
40
44
  const curPopulate = getFullPopulateObject(cur, maxDepth - 1);
41
- return curPopulate === true ? prev : merge(prev, curPopulate);
45
+ return curPopulate === true ? prev : (0, fp_1.merge)(prev, curPopulate);
42
46
  }, {});
43
- populate[key] = isEmpty(dynamicPopulate) ? true : dynamicPopulate;
47
+ populate[key] = (0, fp_1.isEmpty)(dynamicPopulate) ? true : dynamicPopulate;
44
48
  }
45
49
  else if (value.type === "relation") {
46
50
  const relationPopulate = getFullPopulateObject(value.target, (key === 'localizations') && maxDepth > 2 ? 1 : maxDepth - 1, ignore);
@@ -53,7 +57,7 @@ const getFullPopulateObject = (modelUid, maxDepth = 20, ignore) => {
53
57
  }
54
58
  }
55
59
  }
56
- return isEmpty(populate) ? true : { populate };
60
+ return (0, fp_1.isEmpty)(populate) ? true : { populate };
57
61
  };
58
62
  ///END : via https://raw.githubusercontent.com/Barelydead/strapi-plugin-populate-deep/main/server/helpers/index.js
59
63
  /*
@@ -109,7 +113,7 @@ function extractSubfieldData({ config, data }) {
109
113
  let val = extractItem[conf['field']];
110
114
  if (Object.keys(conf).includes('transform')
111
115
  && conf['transform'] === 'markdown')
112
- val = transformServiceProvider.transform({ content: val, from: 'markdown' });
116
+ val = transform_content_1.default.transform({ content: val, from: 'markdown' });
113
117
  returnData = returnData + '\n' + val;
114
118
  }
115
119
  else if (conf.component === extractItem.__component &&
@@ -126,7 +130,7 @@ function extractSubfieldData({ config, data }) {
126
130
  let val = extractItem[conf['field']];
127
131
  if (Object.keys(conf).includes('transform')
128
132
  && conf['transform'] === 'markdown')
129
- val = transformServiceProvider.transform({ content: val, from: 'markdown' });
133
+ val = transform_content_1.default.transform({ content: val, from: 'markdown' });
130
134
  returnData = returnData + '\n' + val;
131
135
  }
132
136
  else if (Object.keys(conf).includes('subfields')) {
@@ -155,24 +159,28 @@ function extractSubfieldData({ config, data }) {
155
159
  }
156
160
  return returnData;
157
161
  }
158
- module.exports = ({ strapi }) => ({
162
+ exports.default = ({ strapi }) => ({
159
163
  async getElasticsearchInfo() {
160
164
  const configureService = strapi.plugins['elasticsearch'].services.configureIndexing;
161
165
  const esInterface = strapi.plugins['elasticsearch'].services.esInterface;
162
166
  const pluginConfig = await strapi.config.get('plugin.elasticsearch');
163
167
  const connected = pluginConfig.searchConnector && pluginConfig.searchConnector.host
164
- ? await esInterface.checkESConnection() : false;
168
+ ? await esInterface.checkESConnection()
169
+ : false;
165
170
  return {
166
- indexingCronSchedule: pluginConfig.indexingCronSchedule || "Not configured",
167
- elasticHost: pluginConfig.searchConnector ?
168
- pluginConfig.searchConnector.host || "Not configured" : "Not configured",
169
- elasticUserName: pluginConfig.searchConnector ?
170
- pluginConfig.searchConnector.username || "Not configured" : "Not configured",
171
- elasticCertificate: pluginConfig.searchConnector ?
172
- pluginConfig.searchConnector.certificate || "Not configured" : "Not configured",
173
- elasticIndexAlias: pluginConfig.indexAliasName || "Not configured",
171
+ indexingCronSchedule: pluginConfig.indexingCronSchedule || 'Not configured',
172
+ elasticHost: pluginConfig.searchConnector
173
+ ? pluginConfig.searchConnector.host || 'Not configured'
174
+ : 'Not configured',
175
+ elasticUserName: pluginConfig.searchConnector
176
+ ? pluginConfig.searchConnector.username || 'Not configured'
177
+ : 'Not configured',
178
+ elasticCertificate: pluginConfig.searchConnector
179
+ ? pluginConfig.searchConnector.certificate || 'Not configured'
180
+ : 'Not configured',
181
+ elasticIndexAlias: pluginConfig.indexAliasName || 'Not configured',
174
182
  connected: connected,
175
- initialized: configureService.isInitialized()
183
+ initialized: configureService.isInitialized(),
176
184
  };
177
185
  },
178
186
  isCollectionDraftPublish({ collectionName }) {
@@ -210,11 +218,11 @@ module.exports = ({ strapi }) => ({
210
218
  const settings = await pluginStore.get({ key: 'configsettings' });
211
219
  if (settings) {
212
220
  const objSettings = JSON.parse(settings);
213
- objSettings['indexConfig'] = { 'name': indexName };
221
+ objSettings['indexConfig'] = { name: indexName };
214
222
  await pluginStore.set({ key: 'configsettings', value: JSON.stringify(objSettings) });
215
223
  }
216
224
  else {
217
- const newSettings = JSON.stringify({ 'indexConfig': { 'name': indexName } });
225
+ const newSettings = JSON.stringify({ indexConfig: { name: indexName } });
218
226
  await pluginStore.set({ key: 'configsettings', value: newSettings });
219
227
  }
220
228
  },
@@ -256,7 +264,7 @@ module.exports = ({ strapi }) => ({
256
264
  val = data[fti[k]];
257
265
  if (Object.keys(fieldConfig).includes('transform') &&
258
266
  fieldConfig['transform'] === 'markdown')
259
- val = transformServiceProvider.transform({ content: val, from: 'markdown' });
267
+ val = transform_content_1.default.transform({ content: val, from: 'markdown' });
260
268
  }
261
269
  if (Object.keys(fieldConfig).includes('searchFieldName'))
262
270
  document[fieldConfig['searchFieldName']] = val;
@@ -265,5 +273,5 @@ module.exports = ({ strapi }) => ({
265
273
  }
266
274
  }
267
275
  return document;
268
- }
276
+ },
269
277
  });
@@ -1,7 +1,124 @@
1
- declare const configureIndexing: any;
2
- declare const scheduleIndexing: any;
3
- declare const esInterface: any;
4
- declare const indexer: any;
5
- declare const logIndexing: any;
6
- declare const helper: any;
7
- declare const transformContent: any;
1
+ declare const _default: {
2
+ configureIndexing: ({ strapi }: {
3
+ strapi: any;
4
+ }) => {
5
+ initializeStrapiElasticsearch(): Promise<void>;
6
+ markInitialized(): Promise<void>;
7
+ isInitialized(): any;
8
+ cacheConfig(): Promise<void>;
9
+ getCollectionConfig({ collectionName }: {
10
+ collectionName: any;
11
+ }): Promise<{} | null>;
12
+ getCollectionsConfiguredForIndexing(): Promise<string[]>;
13
+ isCollectionConfiguredToBeIndexed({ collectionName }: {
14
+ collectionName: any;
15
+ }): Promise<boolean>;
16
+ getContentConfig(): Promise<any>;
17
+ importContentConfig({ config }: {
18
+ config: any;
19
+ }): Promise<any>;
20
+ setContentConfig({ collection, config }: {
21
+ collection: any;
22
+ config: any;
23
+ }): Promise<any>;
24
+ };
25
+ scheduleIndexing: ({ strapi }: {
26
+ strapi: any;
27
+ }) => {
28
+ addFullSiteIndexingTask(): Promise<any>;
29
+ addCollectionToIndex({ collectionUid }: {
30
+ collectionUid: any;
31
+ }): Promise<any>;
32
+ addItemToIndex({ collectionUid, recordId }: {
33
+ collectionUid: any;
34
+ recordId: any;
35
+ }): Promise<any>;
36
+ removeItemFromIndex({ collectionUid, recordId }: {
37
+ collectionUid: any;
38
+ recordId: any;
39
+ }): Promise<void>;
40
+ getItemsPendingToBeIndexed(): Promise<any>;
41
+ markIndexingTaskComplete(recId: any): Promise<void>;
42
+ };
43
+ esInterface: ({ strapi }: {
44
+ strapi: any;
45
+ }) => {
46
+ initializeSearchEngine({ host, uname, password, cert }: {
47
+ host: any;
48
+ uname: any;
49
+ password: any;
50
+ cert: any;
51
+ }): Promise<void>;
52
+ createIndex(indexName: any): Promise<void>;
53
+ deleteIndex(indexName: any): Promise<void>;
54
+ attachAliasToIndex(indexName: any): Promise<void>;
55
+ checkESConnection(): Promise<boolean>;
56
+ indexDataToSpecificIndex({ itemId, itemData }: {
57
+ itemId: any;
58
+ itemData: any;
59
+ }, iName: any): Promise<void>;
60
+ indexData({ itemId, itemData }: {
61
+ itemId: any;
62
+ itemData: any;
63
+ }): Promise<void>;
64
+ removeItemFromIndex({ itemId }: {
65
+ itemId: any;
66
+ }): Promise<void>;
67
+ searchData(searchQuery: any): Promise<any>;
68
+ };
69
+ indexer: ({ strapi }: {
70
+ strapi: any;
71
+ }) => {
72
+ rebuildIndex(): Promise<boolean | undefined>;
73
+ indexCollection(collectionName: any, indexName?: null): Promise<boolean>;
74
+ indexPendingData(): Promise<boolean>;
75
+ };
76
+ logIndexing: ({ strapi }: {
77
+ strapi: any;
78
+ }) => {
79
+ recordIndexingPass(message: any): Promise<void>;
80
+ recordIndexingFail(message: any): Promise<void>;
81
+ fetchIndexingLogs(count?: number): Promise<any>;
82
+ };
83
+ helper: ({ strapi }: {
84
+ strapi: any;
85
+ }) => {
86
+ getElasticsearchInfo(): Promise<{
87
+ indexingCronSchedule: any;
88
+ elasticHost: any;
89
+ elasticUserName: any;
90
+ elasticCertificate: any;
91
+ elasticIndexAlias: any;
92
+ connected: any;
93
+ initialized: any;
94
+ }>;
95
+ isCollectionDraftPublish({ collectionName }: {
96
+ collectionName: any;
97
+ }): boolean;
98
+ getPopulateAttribute({ collectionName }: {
99
+ collectionName: any;
100
+ }): true | {
101
+ populate: never;
102
+ } | undefined;
103
+ getIndexItemId({ collectionName, itemId }: {
104
+ collectionName: any;
105
+ itemId: any;
106
+ }): string;
107
+ getCurrentIndexName(): Promise<string>;
108
+ getIncrementedIndexName(): Promise<string>;
109
+ storeCurrentIndexName(indexName: any): Promise<void>;
110
+ modifySubfieldsConfigForExtractor(collectionConfig: any): any;
111
+ extractDataToIndex({ collectionName, data, collectionConfig }: {
112
+ collectionName: any;
113
+ data: any;
114
+ collectionConfig: any;
115
+ }): {};
116
+ };
117
+ transformContent: {
118
+ transform({ content, from }: {
119
+ content: any;
120
+ from: any;
121
+ }): any;
122
+ };
123
+ };
124
+ export default _default;
@@ -1,17 +1,21 @@
1
1
  'use strict';
2
- const configureIndexing = require('./configure-indexing');
3
- const scheduleIndexing = require('./schedule-indexing');
4
- const esInterface = require('./es-interface');
5
- const indexer = require('./perform-indexing');
6
- const logIndexing = require('./log-indexing');
7
- const helper = require('./helper');
8
- const transformContent = require('./transform-content');
9
- module.exports = {
10
- configureIndexing,
11
- scheduleIndexing,
12
- esInterface,
13
- indexer,
14
- logIndexing,
15
- helper,
16
- transformContent
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const configure_indexing_1 = __importDefault(require("./configure-indexing"));
7
+ const schedule_indexing_1 = __importDefault(require("./schedule-indexing"));
8
+ const es_interface_1 = __importDefault(require("./es-interface"));
9
+ const perform_indexing_1 = __importDefault(require("./perform-indexing"));
10
+ const log_indexing_1 = __importDefault(require("./log-indexing"));
11
+ const helper_1 = __importDefault(require("./helper"));
12
+ const transform_content_1 = __importDefault(require("./transform-content"));
13
+ exports.default = {
14
+ configureIndexing: configure_indexing_1.default,
15
+ scheduleIndexing: schedule_indexing_1.default,
16
+ esInterface: es_interface_1.default,
17
+ indexer: perform_indexing_1.default,
18
+ logIndexing: log_indexing_1.default,
19
+ helper: helper_1.default,
20
+ transformContent: transform_content_1.default,
17
21
  };
@@ -0,0 +1,8 @@
1
+ declare const _default: ({ strapi }: {
2
+ strapi: any;
3
+ }) => {
4
+ recordIndexingPass(message: any): Promise<void>;
5
+ recordIndexingFail(message: any): Promise<void>;
6
+ fetchIndexingLogs(count?: number): Promise<any>;
7
+ };
8
+ export default _default;
@@ -1,27 +1,28 @@
1
1
  "use strict";
2
- module.exports = ({ strapi }) => ({
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = ({ strapi }) => ({
3
4
  async recordIndexingPass(message) {
4
5
  const entry = await strapi.entityService.create('plugin::elasticsearch.indexing-log', {
5
6
  data: {
6
7
  status: 'pass',
7
- details: message
8
- }
8
+ details: message,
9
+ },
9
10
  });
10
11
  },
11
12
  async recordIndexingFail(message) {
12
13
  const entry = await strapi.entityService.create('plugin::elasticsearch.indexing-log', {
13
14
  data: {
14
15
  status: 'fail',
15
- details: String(message)
16
- }
16
+ details: String(message),
17
+ },
17
18
  });
18
19
  },
19
20
  async fetchIndexingLogs(count = 50) {
20
21
  const records = await strapi.entityService.findMany('plugin::elasticsearch.indexing-log', {
21
22
  sort: { createdAt: 'DESC' },
22
23
  start: 0,
23
- limit: count
24
+ limit: count,
24
25
  });
25
26
  return records;
26
- }
27
+ },
27
28
  });
@@ -0,0 +1,8 @@
1
+ declare const _default: ({ strapi }: {
2
+ strapi: any;
3
+ }) => {
4
+ rebuildIndex(): Promise<boolean | undefined>;
5
+ indexCollection(collectionName: any, indexName?: null): Promise<boolean>;
6
+ indexPendingData(): Promise<boolean>;
7
+ };
8
+ export default _default;
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
- module.exports = ({ strapi }) => ({
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = ({ strapi }) => ({
3
4
  async rebuildIndex() {
4
5
  const helper = strapi.plugins['elasticsearch'].services.helper;
5
6
  const esInterface = strapi.plugins['elasticsearch'].services.esInterface;
@@ -25,7 +26,6 @@ module.exports = ({ strapi }) => ({
25
26
  console.log('strapi-plugin-elasticsearch : Indexing of data into the new index complete.');
26
27
  //Step 4 : Move the alias to this new index
27
28
  await esInterface.attachAliasToIndex(newIndexName);
28
- ;
29
29
  console.log('strapi-plugin-elasticsearch : Attaching the newly created index to the alias.');
30
30
  //Step 3 : Update the search-indexing-name
31
31
  await helper.storeCurrentIndexName(newIndexName);
@@ -61,9 +61,9 @@ module.exports = ({ strapi }) => ({
61
61
  populate: populateAttrib['populate'],
62
62
  filters: {
63
63
  publishedAt: {
64
- $notNull: true
65
- }
66
- }
64
+ $notNull: true,
65
+ },
66
+ },
67
67
  });
68
68
  }
69
69
  else {
@@ -75,10 +75,17 @@ module.exports = ({ strapi }) => ({
75
75
  if (entries) {
76
76
  for (let s = 0; s < entries.length; s++) {
77
77
  const item = entries[s];
78
- const indexItemId = helper.getIndexItemId({ collectionName: collectionName, itemId: item.id });
79
- const collectionConfig = await configureIndexingService.getCollectionConfig({ collectionName });
78
+ const indexItemId = helper.getIndexItemId({
79
+ collectionName: collectionName,
80
+ itemId: item.id,
81
+ });
82
+ const collectionConfig = await configureIndexingService.getCollectionConfig({
83
+ collectionName,
84
+ });
80
85
  const dataToIndex = await helper.extractDataToIndex({
81
- collectionName, data: item, collectionConfig
86
+ collectionName,
87
+ data: item,
88
+ collectionConfig,
82
89
  });
83
90
  await esInterface.indexDataToSpecificIndex({ itemId: indexItemId, itemData: dataToIndex }, indexName);
84
91
  }
@@ -92,7 +99,7 @@ module.exports = ({ strapi }) => ({
92
99
  const esInterface = strapi.plugins['elasticsearch'].services.esInterface;
93
100
  const helper = strapi.plugins['elasticsearch'].services.helper;
94
101
  const recs = await scheduleIndexingService.getItemsPendingToBeIndexed();
95
- const fullSiteIndexing = recs.filter(r => r.full_site_indexing === true).length > 0;
102
+ const fullSiteIndexing = recs.filter((r) => r.full_site_indexing === true).length > 0;
96
103
  if (fullSiteIndexing) {
97
104
  await this.rebuildIndex();
98
105
  for (let r = 0; r < recs.length; r++)
@@ -108,24 +115,30 @@ module.exports = ({ strapi }) => ({
108
115
  if (recs[r].indexing_type !== 'remove-from-index') {
109
116
  const populateAttrib = helper.getPopulateAttribute({ collectionName: col });
110
117
  const item = await strapi.entityService.findOne(col, recs[r].item_id, {
111
- populate: populateAttrib['populate']
118
+ populate: populateAttrib['populate'],
112
119
  });
113
120
  const indexItemId = helper.getIndexItemId({ collectionName: col, itemId: item.id });
114
- const collectionConfig = await configureIndexingService.getCollectionConfig({ collectionName: col });
121
+ const collectionConfig = await configureIndexingService.getCollectionConfig({
122
+ collectionName: col,
123
+ });
115
124
  const dataToIndex = await helper.extractDataToIndex({
116
- collectionName: col, data: item, collectionConfig
125
+ collectionName: col,
126
+ data: item,
127
+ collectionConfig,
117
128
  });
118
129
  await esInterface.indexData({ itemId: indexItemId, itemData: dataToIndex });
119
130
  await scheduleIndexingService.markIndexingTaskComplete(recs[r].id);
120
131
  }
121
132
  else {
122
- const indexItemId = helper.getIndexItemId({ collectionName: col, itemId: recs[r].item_id });
133
+ const indexItemId = helper.getIndexItemId({
134
+ collectionName: col,
135
+ itemId: recs[r].item_id,
136
+ });
123
137
  await esInterface.removeItemFromIndex({ itemId: indexItemId });
124
138
  await scheduleIndexingService.markIndexingTaskComplete(recs[r].id);
125
139
  }
126
- }
127
- else //index the entire collection
128
- {
140
+ } //index the entire collection
141
+ else {
129
142
  //PENDING : Index an entire collection
130
143
  await this.indexCollection(col);
131
144
  await scheduleIndexingService.markIndexingTaskComplete(recs[r].id);
@@ -0,0 +1,19 @@
1
+ declare const _default: ({ strapi }: {
2
+ strapi: any;
3
+ }) => {
4
+ addFullSiteIndexingTask(): Promise<any>;
5
+ addCollectionToIndex({ collectionUid }: {
6
+ collectionUid: any;
7
+ }): Promise<any>;
8
+ addItemToIndex({ collectionUid, recordId }: {
9
+ collectionUid: any;
10
+ recordId: any;
11
+ }): Promise<any>;
12
+ removeItemFromIndex({ collectionUid, recordId }: {
13
+ collectionUid: any;
14
+ recordId: any;
15
+ }): Promise<void>;
16
+ getItemsPendingToBeIndexed(): Promise<any>;
17
+ markIndexingTaskComplete(recId: any): Promise<void>;
18
+ };
19
+ export default _default;
@@ -1,13 +1,14 @@
1
1
  "use strict";
2
- module.exports = ({ strapi }) => ({
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = ({ strapi }) => ({
3
4
  async addFullSiteIndexingTask() {
4
5
  const data = await strapi.entityService.create('plugin::elasticsearch.task', {
5
6
  data: {
6
7
  collection_name: '',
7
8
  indexing_status: 'to-be-done',
8
9
  full_site_indexing: true,
9
- indexing_type: "add-to-index"
10
- }
10
+ indexing_type: 'add-to-index',
11
+ },
11
12
  });
12
13
  return data;
13
14
  },
@@ -17,8 +18,8 @@ module.exports = ({ strapi }) => ({
17
18
  collection_name: collectionUid,
18
19
  indexing_status: 'to-be-done',
19
20
  full_site_indexing: false,
20
- indexing_type: "add-to-index"
21
- }
21
+ indexing_type: 'add-to-index',
22
+ },
22
23
  });
23
24
  return data;
24
25
  },
@@ -29,8 +30,8 @@ module.exports = ({ strapi }) => ({
29
30
  collection_name: collectionUid,
30
31
  indexing_status: 'to-be-done',
31
32
  full_site_indexing: false,
32
- indexing_type: "add-to-index"
33
- }
33
+ indexing_type: 'add-to-index',
34
+ },
34
35
  });
35
36
  return data;
36
37
  },
@@ -41,8 +42,8 @@ module.exports = ({ strapi }) => ({
41
42
  collection_name: collectionUid,
42
43
  indexing_status: 'to-be-done',
43
44
  full_site_indexing: false,
44
- indexing_type: "remove-from-index"
45
- }
45
+ indexing_type: 'remove-from-index',
46
+ },
46
47
  });
47
48
  },
48
49
  async getItemsPendingToBeIndexed() {
@@ -54,8 +55,8 @@ module.exports = ({ strapi }) => ({
54
55
  async markIndexingTaskComplete(recId) {
55
56
  const entries = await strapi.entityService.update('plugin::elasticsearch.task', recId, {
56
57
  data: {
57
- 'indexing_status': 'done'
58
- }
58
+ indexing_status: 'done',
59
+ },
59
60
  });
60
- }
61
+ },
61
62
  });
@@ -1,2 +1,7 @@
1
- declare const markdownToTxt: any;
2
- declare function transformMarkdownToText(md: any): any;
1
+ declare const _default: {
2
+ transform({ content, from }: {
3
+ content: any;
4
+ from: any;
5
+ }): any;
6
+ };
7
+ export default _default;
@@ -1,9 +1,10 @@
1
1
  "use strict";
2
- const { markdownToTxt } = require('markdown-to-txt');
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const markdown_to_txt_1 = require("markdown-to-txt");
3
4
  function transformMarkdownToText(md) {
4
5
  let text = md;
5
6
  try {
6
- text = markdownToTxt(md);
7
+ text = (0, markdown_to_txt_1.markdownToTxt)(md);
7
8
  }
8
9
  catch (err) {
9
10
  console.error('strapi-plugin-elasticsearch : Error while transforming markdown to text.');
@@ -11,7 +12,7 @@ function transformMarkdownToText(md) {
11
12
  }
12
13
  return text;
13
14
  }
14
- module.exports = {
15
+ exports.default = {
15
16
  transform({ content, from }) {
16
17
  if (from === 'markdown')
17
18
  return transformMarkdownToText(content);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vegan-friendly/strapi-plugin-elasticsearch",
3
- "version": "0.1.0-alpha.3",
3
+ "version": "0.1.0",
4
4
  "description": "A Strapi plugin to enable using Elasticsearch with Strapi CMS.",
5
5
  "homepage": "https://github.com/vegan-friendly/strapi-plugin-elasticsearch",
6
6
  "strapi": {
@@ -36,6 +36,7 @@
36
36
  },
37
37
  "dependencies": {
38
38
  "@elastic/elasticsearch": "^8.9.0",
39
+ "@strapi/design-system": "^1.19.0",
39
40
  "markdown-to-txt": "^2.0.1"
40
41
  },
41
42
  "peerDependencies": {
@@ -54,8 +55,9 @@
54
55
  },
55
56
  "license": "MIT",
56
57
  "devDependencies": {
58
+ "@strapi/typescript-utils": "^5.12.5",
57
59
  "@types/node": "^22.14.1",
58
60
  "ts-node": "^10.9.2",
59
61
  "typescript": "^5.8.3"
60
62
  }
61
- }
63
+ }
@@ -1,15 +0,0 @@
1
- /**
2
- *
3
- * Initializer
4
- *
5
- */
6
- import PropTypes from 'prop-types';
7
- declare const Initializer: {
8
- ({ setPlugin }: {
9
- setPlugin: any;
10
- }): null;
11
- propTypes: {
12
- setPlugin: PropTypes.Validator<(...args: any[]) => any>;
13
- };
14
- };
15
- export default Initializer;
@@ -1,25 +0,0 @@
1
- "use strict";
2
- /**
3
- *
4
- * Initializer
5
- *
6
- */
7
- var __importDefault = (this && this.__importDefault) || function (mod) {
8
- return (mod && mod.__esModule) ? mod : { "default": mod };
9
- };
10
- Object.defineProperty(exports, "__esModule", { value: true });
11
- const react_1 = require("react");
12
- const prop_types_1 = __importDefault(require("prop-types"));
13
- const pluginId_1 = __importDefault(require("../../pluginId"));
14
- const Initializer = ({ setPlugin }) => {
15
- const ref = (0, react_1.useRef)();
16
- ref.current = setPlugin;
17
- (0, react_1.useEffect)(() => {
18
- ref.current(pluginId_1.default);
19
- }, []);
20
- return null;
21
- };
22
- Initializer.propTypes = {
23
- setPlugin: prop_types_1.default.func.isRequired,
24
- };
25
- exports.default = Initializer;
@@ -1,8 +0,0 @@
1
- /**
2
- *
3
- * PluginIcon
4
- *
5
- */
6
- import React from 'react';
7
- declare const PluginIcon: () => React.JSX.Element;
8
- export default PluginIcon;