@eeacms/volto-globalsearch 1.0.21 → 1.0.22

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/CHANGELOG.md CHANGED
@@ -4,6 +4,17 @@ All notable changes to this project will be documented in this file. Dates are d
4
4
 
5
5
  Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
6
6
 
7
+ ### [1.0.22](https://github.com/eea/volto-globalsearch/compare/1.0.21...1.0.22) - 12 December 2023
8
+
9
+ #### :house: Internal changes
10
+
11
+ - chore: husky, lint-staged use fixed versions [valentinab25 - [`866609d`](https://github.com/eea/volto-globalsearch/commit/866609d540bd0efe4bab088305bb2127105d8df7)]
12
+ - chore:volto 16 in tests, update docs, fix stylelint overrides [valentinab25 - [`e09f5e2`](https://github.com/eea/volto-globalsearch/commit/e09f5e2c1161b4b867c04eb1c0421274bd6c7110)]
13
+
14
+ #### :hammer_and_wrench: Others
15
+
16
+ - removed try/catch [Zoltan Szabo - [`86cec5d`](https://github.com/eea/volto-globalsearch/commit/86cec5d49d06d41541dc6d42464e9b95769da745)]
17
+ - avoid async promise executor functions [Zoltan Szabo - [`61012e3`](https://github.com/eea/volto-globalsearch/commit/61012e331776fadaa9eafe9f7667b18d08b2351a)]
7
18
  ### [1.0.21](https://github.com/eea/volto-globalsearch/compare/1.0.20...1.0.21) - 29 September 2023
8
19
 
9
20
  #### :house: Internal changes
package/RELEASE.md CHANGED
@@ -20,9 +20,9 @@ You need to first install the [release-it](https://github.com/release-it/release
20
20
  ```
21
21
  npm install -g release-it
22
22
  ```
23
-
23
+
24
24
  Release-it uses the configuration written in the [`.release-it.json`](./.release-it.json) file located in the root of the repository.
25
-
25
+
26
26
  Release-it is a tool that automates 4 important steps in the release process:
27
27
 
28
28
  1. Version increase in `package.json` ( increased from the current version in `package.json`)
@@ -30,45 +30,45 @@ Release-it is a tool that automates 4 important steps in the release process:
30
30
  3. GitHub release on the commit with the changelog and package.json modification on the develop branch
31
31
  4. NPM release ( by default it's disabled, but can be enabled in the configuration file )
32
32
 
33
- To configure the authentification, you need to export GITHUB_TOKEN for [GitHub](https://github.com/settings/tokens)
33
+ To configure the authentification, you need to export GITHUB_TOKEN for [GitHub](https://github.com/settings/tokens)
34
34
 
35
35
  ```
36
36
  export GITHUB_TOKEN=XXX-XXXXXXXXXXXXXXXXXXXXXX
37
37
  ```
38
-
38
+
39
39
  To configure npm, you can use the `npm login` command or use a configuration file with a TOKEN :
40
-
40
+
41
41
  ```
42
42
  echo "//registry.npmjs.org/:_authToken=YYYYYYYYYYYYYYYYYYYYYYYYYYYYYY" > .npmrc
43
43
  ```
44
44
 
45
45
  #### Using release-it tool
46
-
46
+
47
47
  There are 3 yarn scripts that can be run to do the release
48
48
 
49
49
  ##### yarn release-beta
50
50
 
51
- Automatically calculates and presents 3 beta versions - patch, minor and major for you to choose ( or Other for manual input).
51
+ Automatically calculates and presents 3 beta versions - patch, minor and major for you to choose ( or Other for manual input).
52
52
 
53
53
  ```
54
- ? Select increment (next version):
55
- ❯ prepatch (0.1.1-beta.0)
56
- preminor (0.2.0-beta.0)
57
- premajor (1.0.0-beta.0)
58
- Other, please specify...
54
+ ? Select increment (next version):
55
+ ❯ prepatch (0.1.1-beta.0)
56
+ preminor (0.2.0-beta.0)
57
+ premajor (1.0.0-beta.0)
58
+ Other, please specify...
59
59
  ```
60
60
 
61
61
  ##### yarn release-major-beta
62
62
 
63
63
  Same as `yarn release-beta`, but with premajor version pre-selected.
64
-
64
+
65
65
  ##### yarn release
66
66
 
67
67
  Generic command, does not automatically add the `beta` to version, but you can still manually write it if you choose Other.
68
68
 
69
69
  #### Important notes
70
70
 
71
- > Do not use release-it tool on master branch, the commit on CHANGELOG.md file and the version increase in the package.json file can't be done without a PULL REQUEST.
71
+ > Do not use release-it tool on master branch, the commit on CHANGELOG.md file and the version increase in the package.json file can't be done without a PULL REQUEST.
72
72
 
73
73
  > Do not keep Pull Requests from develop to master branches open when you are doing beta releases from the develop branch. As long as a PR to master is open, an automatic script will run on every commit and will update both the version and the changelog to a production-ready state - ( MAJOR.MINOR.PATCH mandatory format for version).
74
74
 
package/cypress.config.js CHANGED
@@ -2,12 +2,12 @@ const { defineConfig } = require('cypress');
2
2
 
3
3
  module.exports = defineConfig({
4
4
  viewportWidth: 1280,
5
- defaultCommandTimeout: 5000,
5
+ defaultCommandTimeout: 8888,
6
6
  chromeWebSecurity: false,
7
7
  reporter: 'junit',
8
- video: true,
8
+ video: false,
9
9
  retries: {
10
- runMode: 1,
10
+ runMode: 2,
11
11
  openMode: 0,
12
12
  },
13
13
  reporterOptions: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eeacms/volto-globalsearch",
3
- "version": "1.0.21",
3
+ "version": "1.0.22",
4
4
  "description": "@eeacms/volto-globalsearch: Volto add-on",
5
5
  "main": "src/index.js",
6
6
  "author": "European Environment Agency: IDM2 A-Team",
@@ -28,8 +28,8 @@
28
28
  "@cypress/code-coverage": "^3.10.0",
29
29
  "@plone/scripts": "*",
30
30
  "babel-plugin-transform-class-properties": "^6.24.1",
31
- "husky": "*",
32
- "lint-staged": "*",
31
+ "husky": "^8.0.3",
32
+ "lint-staged": "^14.0.1",
33
33
  "md5": "^2.3.0"
34
34
  },
35
35
  "lint-staged": {
@@ -24,18 +24,12 @@ export function buildQuery(query, values) {
24
24
  }
25
25
 
26
26
  async function executeQuery(q, appConfig, params = {}, callback) {
27
- return new Promise(async (resolve, reject) => {
28
- try {
29
- params['index_name'] = 'status_' + appConfig['index_name'];
30
- const query = buildQuery(q, params);
31
- //console.log(JSON.stringify(query));
32
- const resp = await runRequest(query, appConfig);
33
- // console.log(JSON.stringify(resp.body));
34
- resolve(callback(resp.body, params));
35
- } catch (e) {
36
- reject({ error: e.message });
37
- }
38
- });
27
+ params['index_name'] = 'status_' + appConfig['index_name'];
28
+ const query = buildQuery(q, params);
29
+ //console.log(JSON.stringify(query));
30
+ const resp = await runRequest(query, appConfig);
31
+ // console.log(JSON.stringify(resp.body));
32
+ return Promise.resolve(callback(resp.body, params));
39
33
  }
40
34
 
41
35
  export function getlastandnext_started_execution(body, params = {}) {
@@ -105,130 +99,129 @@ export function getlatesttasks_for_site(body, params = {}) {
105
99
  }
106
100
 
107
101
  export async function getStatus(appConfig, params) {
108
- return new Promise(async (resolve, reject) => {
109
- let resp = 'OK';
110
- let error = null;
111
- // console.log('=======================================');
112
- // console.log('STEP 1');
113
- const step1 = await executeQuery(
114
- last_scheduled_started_indexing,
115
- appConfig,
116
- {},
117
- getlastandnext_started_execution,
118
- );
102
+ let resp = 'OK';
103
+ let error = null;
104
+ // console.log('=======================================');
105
+ // console.log('STEP 1');
106
+ const step1 = await executeQuery(
107
+ last_scheduled_started_indexing,
108
+ appConfig,
109
+ {},
110
+ getlastandnext_started_execution,
111
+ );
119
112
 
120
- // console.log(step1);
113
+ // console.log(step1);
121
114
 
122
- // const last_successful_schedule = step1.last_started;
123
- let next_schedule = step1.next_execution_date;
115
+ // const last_successful_schedule = step1.last_started;
116
+ let next_schedule = step1.next_execution_date;
124
117
 
125
- const now = params.now || Date.now() - 60 * 1000;
126
- if (now >= next_schedule) {
118
+ const now = params.now || Date.now() - 60 * 1000;
119
+ if (now >= next_schedule) {
120
+ try {
121
+ // console.log('=======================================');
122
+ // console.log('STEP 2');
123
+ const step2 = await executeQuery(
124
+ failed_scheduled_atempts_since_last_started,
125
+ appConfig,
126
+ step1,
127
+ getlastfailed_execution,
128
+ );
129
+ next_schedule = step2.next_execution_date;
130
+ // console.log(step2);
131
+ } catch {
132
+ resp = 'CRITICAL';
133
+ error = 'Failed to get status info from elasticsearch';
134
+ }
135
+ }
136
+ if (error === null) {
137
+ if (now > next_schedule) {
138
+ resp = 'CRITICAL';
139
+ error = 'Airflow stopped indexing, no new schedules in the queue';
140
+ } else {
127
141
  try {
128
- // console.log('=======================================');
129
- // console.log('STEP 2');
130
- const step2 = await executeQuery(
131
- failed_scheduled_atempts_since_last_started,
142
+ const step3 = await executeQuery(
143
+ last_sync_task_since_last_start,
132
144
  appConfig,
133
145
  step1,
134
- getlastfailed_execution,
146
+ getlastsynctaskssincestarted,
135
147
  );
136
- next_schedule = step2.next_execution_date;
137
- // console.log(step2);
138
- } catch {
139
- resp = 'CRITICAL';
140
- error = 'Failed to get status info from elasticsearch';
141
- }
142
- }
143
- if (error === null) {
144
- if (now > next_schedule) {
145
- resp = 'CRITICAL';
146
- error = 'Airflow stopped indexing, no new schedules in the queue';
147
- } else {
148
- try {
149
- const step3 = await executeQuery(
150
- last_sync_task_since_last_start,
151
- appConfig,
152
- step1,
153
- getlastsynctaskssincestarted,
154
- );
155
- // console.log(step3.sites);
156
- const all_sites_status = {};
157
- for (let i = 0; i < step3.sites.length; i++) {
158
- try {
159
- // console.log('=======================================');
160
- // console.log('STEP 4');
161
- // const step4 =
162
- await executeQuery(
163
- started_or_finished_site_since_last_started,
164
- appConfig,
165
- {
166
- site_name: step3.sites[i],
167
- last_started: step1['last_started'],
168
- },
169
- getlastsuccessfultasks_for_site,
170
- );
171
- all_sites_status[step3.sites[i]] = 'OK';
172
- // console.log(step4);
173
- } catch {
174
- // console.log('=======================================');
175
- // console.log('STEP 5');
176
- const step5 = await executeQuery(
177
- latest_tasks_for_site,
178
- appConfig,
179
- {
180
- site_name: step3.sites[i],
181
- last_started: step1['last_started'],
182
- THRESHOLD_WARNING: parseInt(
183
- params.FAILED_SYNC_THRESHOLD_WARNING,
184
- ),
185
- THRESHOLD_OK: parseInt(params.FAILED_SYNC_THRESHOLD_OK),
186
- },
187
- getlatesttasks_for_site,
188
- );
189
- all_sites_status[step3.sites[i]] = step5;
190
- }
148
+ // console.log(step3.sites);
149
+ const all_sites_status = {};
150
+ for (let i = 0; i < step3.sites.length; i++) {
151
+ try {
152
+ // console.log('=======================================');
153
+ // console.log('STEP 4');
154
+ // const step4 =
155
+ await executeQuery(
156
+ started_or_finished_site_since_last_started,
157
+ appConfig,
158
+ {
159
+ site_name: step3.sites[i],
160
+ last_started: step1['last_started'],
161
+ },
162
+ getlastsuccessfultasks_for_site,
163
+ );
164
+ all_sites_status[step3.sites[i]] = 'OK';
165
+ // console.log(step4);
166
+ } catch {
167
+ // console.log('=======================================');
168
+ // console.log('STEP 5');
169
+ const step5 = await executeQuery(
170
+ latest_tasks_for_site,
171
+ appConfig,
172
+ {
173
+ site_name: step3.sites[i],
174
+ last_started: step1['last_started'],
175
+ THRESHOLD_WARNING: parseInt(
176
+ params.FAILED_SYNC_THRESHOLD_WARNING,
177
+ ),
178
+ THRESHOLD_OK: parseInt(params.FAILED_SYNC_THRESHOLD_OK),
179
+ },
180
+ getlatesttasks_for_site,
181
+ );
182
+ all_sites_status[step3.sites[i]] = step5;
191
183
  }
192
- // console.log(all_sites_status);
193
- const oks = [];
194
- const warnings = [];
195
- const criticals = [];
196
- for (let i = 0; i < step3.sites.length; i++) {
197
- if (all_sites_status[step3.sites[i]] === 'OK') {
198
- oks.push(step3.sites[i]);
199
- }
200
- if (all_sites_status[step3.sites[i]] === 'WARNING') {
201
- warnings.push(step3.sites[i]);
202
- }
203
- if (all_sites_status[step3.sites[i]] === 'CRITICAL') {
204
- criticals.push(step3.sites[i]);
205
- }
206
- if (criticals.length > 0) {
184
+ }
185
+ // console.log(all_sites_status);
186
+ const oks = [];
187
+ const warnings = [];
188
+ const criticals = [];
189
+ for (let i = 0; i < step3.sites.length; i++) {
190
+ if (all_sites_status[step3.sites[i]] === 'OK') {
191
+ oks.push(step3.sites[i]);
192
+ }
193
+ if (all_sites_status[step3.sites[i]] === 'WARNING') {
194
+ warnings.push(step3.sites[i]);
195
+ }
196
+ if (all_sites_status[step3.sites[i]] === 'CRITICAL') {
197
+ criticals.push(step3.sites[i]);
198
+ }
199
+ if (criticals.length > 0) {
200
+ error =
201
+ 'Clusters with too many fails: ' +
202
+ criticals.concat(warnings).join(', ');
203
+ resp = 'CRITICAL';
204
+ } else {
205
+ if (warnings.length > 0) {
207
206
  error =
208
207
  'Clusters with too many fails: ' +
209
208
  criticals.concat(warnings).join(', ');
210
- resp = 'CRITICAL';
211
- } else {
212
- if (warnings.length > 0) {
213
- error =
214
- 'Clusters with too many fails: ' +
215
- criticals.concat(warnings).join(', ');
216
- resp = 'WARNING';
217
- }
209
+ resp = 'WARNING';
218
210
  }
219
211
  }
220
- } catch {
221
- error = 'Failed to get status info from elasticsearch';
222
212
  }
213
+ } catch {
214
+ error = 'Failed to get status info from elasticsearch';
223
215
  }
224
216
  }
225
- const status = { status: resp };
226
- if (error !== null) {
227
- status.error = error;
228
- }
229
- resolve(status);
230
- });
217
+ }
218
+ const status = { status: resp };
219
+ if (error !== null) {
220
+ status.error = error;
221
+ }
222
+ return Promise.resolve(status);
231
223
  }
224
+
232
225
  export default async function healthcheck(appConfig, params) {
233
226
  // is index ok?
234
227
  // return index update date
@@ -236,103 +229,101 @@ export default async function healthcheck(appConfig, params) {
236
229
  // nlpservice provides answer based on extracted term
237
230
  // number of documents with error in data raw, type of error
238
231
 
239
- return new Promise(async (resolve, reject) => {
240
- try {
241
- let {
242
- documentCountThreshold,
243
- queryTimeSecondsThreshold_OK,
244
- queryTimeSecondsThreshold_WARNING,
245
- failedSyncThreshold_OK,
246
- failedSyncThreshold_WARNING,
247
- now,
248
- } = params;
249
- documentCountThreshold =
250
- documentCountThreshold || default_documentCountThreshold;
251
- queryTimeSecondsThreshold_OK =
252
- queryTimeSecondsThreshold_OK || default_queryTimeSecondsThreshold_OK;
253
- queryTimeSecondsThreshold_WARNING =
254
- queryTimeSecondsThreshold_WARNING ||
255
- default_queryTimeSecondsThreshold_WARNING;
256
- failedSyncThreshold_OK =
257
- failedSyncThreshold_OK || default_failedSyncThreshold_OK;
258
- failedSyncThreshold_WARNING =
259
- failedSyncThreshold_WARNING || default_failedSyncThreshold_WARNING;
232
+ try {
233
+ let {
234
+ documentCountThreshold,
235
+ queryTimeSecondsThreshold_OK,
236
+ queryTimeSecondsThreshold_WARNING,
237
+ failedSyncThreshold_OK,
238
+ failedSyncThreshold_WARNING,
239
+ now,
240
+ } = params;
241
+ documentCountThreshold =
242
+ documentCountThreshold || default_documentCountThreshold;
243
+ queryTimeSecondsThreshold_OK =
244
+ queryTimeSecondsThreshold_OK || default_queryTimeSecondsThreshold_OK;
245
+ queryTimeSecondsThreshold_WARNING =
246
+ queryTimeSecondsThreshold_WARNING ||
247
+ default_queryTimeSecondsThreshold_WARNING;
248
+ failedSyncThreshold_OK =
249
+ failedSyncThreshold_OK || default_failedSyncThreshold_OK;
250
+ failedSyncThreshold_WARNING =
251
+ failedSyncThreshold_WARNING || default_failedSyncThreshold_WARNING;
260
252
 
261
- const airflow_params = {
262
- FAILED_SYNC_THRESHOLD_WARNING: failedSyncThreshold_WARNING,
263
- FAILED_SYNC_THRESHOLD_OK: failedSyncThreshold_OK,
264
- now: now,
265
- };
253
+ const airflow_params = {
254
+ FAILED_SYNC_THRESHOLD_WARNING: failedSyncThreshold_WARNING,
255
+ FAILED_SYNC_THRESHOLD_OK: failedSyncThreshold_OK,
256
+ now: now,
257
+ };
266
258
 
267
- ///////////////////
268
- const body_total = buildRequest({ filters: [] }, appConfig);
269
- //console.log(body_total);
270
- const resp_total = await runRequest(body_total, appConfig);
271
- const total = resp_total.body.hits.total.value;
272
- const total_status =
273
- total > documentCountThreshold
274
- ? { status: 'OK' }
275
- : {
276
- status: 'CRITICAL',
277
- error:
278
- 'The number of documents in elasticsearch dropped drastically',
279
- };
280
- const body_nlp = buildRequest(
281
- { filters: [], searchTerm: 'what is bise?' },
282
- appConfig,
283
- );
284
- const resp_nlp = await runRequest(body_nlp, appConfig);
285
- const elapsed = resp_nlp.body.elapsed;
259
+ ///////////////////
260
+ const body_total = buildRequest({ filters: [] }, appConfig);
261
+ //console.log(body_total);
262
+ const resp_total = await runRequest(body_total, appConfig);
263
+ const total = resp_total.body.hits.total.value;
264
+ const total_status =
265
+ total > documentCountThreshold
266
+ ? { status: 'OK' }
267
+ : {
268
+ status: 'CRITICAL',
269
+ error:
270
+ 'The number of documents in elasticsearch dropped drastically',
271
+ };
272
+ const body_nlp = buildRequest(
273
+ { filters: [], searchTerm: 'what is bise?' },
274
+ appConfig,
275
+ );
276
+ const resp_nlp = await runRequest(body_nlp, appConfig);
277
+ const elapsed = resp_nlp.body.elapsed;
286
278
 
287
- let total_elapsed = 0;
288
- Object.keys(elapsed).forEach((key) => {
289
- elapsed[key].forEach((nlp_step) => {
290
- Object.keys(nlp_step).forEach((step_name) => {
291
- total_elapsed += nlp_step[step_name].delta;
292
- });
279
+ let total_elapsed = 0;
280
+ Object.keys(elapsed).forEach((key) => {
281
+ elapsed[key].forEach((nlp_step) => {
282
+ Object.keys(nlp_step).forEach((step_name) => {
283
+ total_elapsed += nlp_step[step_name].delta;
293
284
  });
294
285
  });
286
+ });
295
287
 
296
- const elapsed_status =
297
- total_elapsed < queryTimeSecondsThreshold_OK
298
- ? { status: 'OK' }
299
- : total_elapsed < queryTimeSecondsThreshold_WARNING
300
- ? { status: 'WARNING', error: 'Slow response from NLP' }
301
- : { status: 'CRITICAL', error: 'Slow response from NLP' };
288
+ const elapsed_status =
289
+ total_elapsed < queryTimeSecondsThreshold_OK
290
+ ? { status: 'OK' }
291
+ : total_elapsed < queryTimeSecondsThreshold_WARNING
292
+ ? { status: 'WARNING', error: 'Slow response from NLP' }
293
+ : { status: 'CRITICAL', error: 'Slow response from NLP' };
302
294
 
303
- const airflow_status = await getStatus(appConfig, airflow_params);
295
+ const airflow_status = await getStatus(appConfig, airflow_params);
304
296
 
305
- let status = { status: 'OK' };
306
- if (
307
- elapsed_status.status === 'WARNING' ||
308
- airflow_status.status === 'WARNING'
309
- ) {
310
- status = { status: 'WARNING' };
311
- }
312
- if (
313
- total_status.status === 'CRITICAL' ||
314
- elapsed_status.status === 'CRITICAL' ||
315
- airflow_status.status === 'CRITICAL'
316
- ) {
317
- status = { status: 'CRITICAL' };
318
- }
297
+ let status = { status: 'OK' };
298
+ if (
299
+ elapsed_status.status === 'WARNING' ||
300
+ airflow_status.status === 'WARNING'
301
+ ) {
302
+ status = { status: 'WARNING' };
303
+ }
304
+ if (
305
+ total_status.status === 'CRITICAL' ||
306
+ elapsed_status.status === 'CRITICAL' ||
307
+ airflow_status.status === 'CRITICAL'
308
+ ) {
309
+ status = { status: 'CRITICAL' };
310
+ }
319
311
 
320
- const errors_list = [];
321
- if (total_status.error) {
322
- errors_list.push(total_status.error);
323
- }
324
- if (elapsed_status.error) {
325
- errors_list.push(elapsed_status.error);
326
- }
327
- if (airflow_status.error) {
328
- errors_list.push(airflow_status.error);
329
- }
330
- if (errors_list.length > 0) {
331
- status.error = errors_list.join('\n');
332
- }
333
- resolve(status);
334
- } catch (e) {
335
- reject({ status: 'Critical', error: e.message });
312
+ const errors_list = [];
313
+ if (total_status.error) {
314
+ errors_list.push(total_status.error);
336
315
  }
337
- });
316
+ if (elapsed_status.error) {
317
+ errors_list.push(elapsed_status.error);
318
+ }
319
+ if (airflow_status.error) {
320
+ errors_list.push(airflow_status.error);
321
+ }
322
+ if (errors_list.length > 0) {
323
+ status.error = errors_list.join('\n');
324
+ }
325
+ return Promise.resolve(status);
326
+ } catch (e) {
327
+ return Promise.reject({ status: 'Critical', error: e.message });
328
+ }
338
329
  }