@socialgouv/cdtn-elasticsearch 2.44.0 → 2.44.2

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
@@ -3,6 +3,18 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [2.44.2](https://github.com/SocialGouv/cdtn-admin/compare/v2.44.1...v2.44.2) (2024-06-04)
7
+
8
+ ### Bug Fixes
9
+
10
+ - **cdtn-elasticsearch:** add `vectorizeQuery` to type ([3c18e95](https://github.com/SocialGouv/cdtn-admin/commit/3c18e95b53dc07da3c7c53ca01e500b7338103f3))
11
+
12
+ ## [2.44.1](https://github.com/SocialGouv/cdtn-admin/compare/v2.44.0...v2.44.1) (2024-06-04)
13
+
14
+ ### Bug Fixes
15
+
16
+ - **cdtn-elasticsearch:** use `console` instead of `logger` ([#1419](https://github.com/SocialGouv/cdtn-admin/issues/1419)) ([f08b17a](https://github.com/SocialGouv/cdtn-admin/commit/f08b17ae7d5c5f607e391b7774cdd272314be1d3))
17
+
6
18
  # [2.44.0](https://github.com/SocialGouv/cdtn-admin/compare/v2.43.0...v2.44.0) (2024-06-04)
7
19
 
8
20
  ### Features
package/package.json CHANGED
@@ -1,14 +1,13 @@
1
1
  {
2
2
  "name": "@socialgouv/cdtn-elasticsearch",
3
3
  "description": "SocialGouv - Code du travail numerique - Infrastructure - Elasticsearch",
4
- "version": "2.44.0",
4
+ "version": "2.44.2",
5
5
  "babel": {
6
6
  "plugins": [
7
7
  "@babel/plugin-transform-modules-commonjs"
8
8
  ]
9
9
  },
10
10
  "dependencies": {
11
- "@shared/utils": "workspace:^",
12
11
  "got": "^11.8.2"
13
12
  },
14
13
  "license": "Apache-2.0",
@@ -41,5 +40,5 @@
41
40
  },
42
41
  "sideEffects": false,
43
42
  "types": "src/index.d.ts",
44
- "gitHead": "2b7f9e5974ebc7db3b48b234319b686f4af5c430"
43
+ "gitHead": "c633e3faa864289de54310c602aaea5183a7f82a"
45
44
  }
@@ -1,5 +1,3 @@
1
- const { logger } = require("@shared/utils");
2
-
3
1
  const { analyzer, char_filter, filter, tokenizer } = require("./analysis");
4
2
 
5
3
  async function createIndex({ client, indexName, mappings }) {
@@ -7,9 +5,9 @@ async function createIndex({ client, indexName, mappings }) {
7
5
  if (body) {
8
6
  try {
9
7
  await client.indices.delete({ index: indexName });
10
- logger.info(`Index ${indexName} deleted.`);
8
+ console.info(`Index ${indexName} deleted.`);
11
9
  } catch (error) {
12
- logger.error("index delete", error);
10
+ console.error("index delete", error);
13
11
  }
14
12
  }
15
13
  try {
@@ -31,15 +29,15 @@ async function createIndex({ client, indexName, mappings }) {
31
29
  },
32
30
  index: indexName,
33
31
  });
34
- logger.info(`Index ${indexName} created.`);
32
+ console.info(`Index ${indexName} created.`);
35
33
  } catch (error) {
36
- logger.error("index create", error);
34
+ console.error("index create", error);
37
35
  }
38
36
  }
39
37
 
40
38
  async function version({ client }) {
41
39
  const body = await client.info();
42
- logger.info(body.version.number);
40
+ console.info(body.version.number);
43
41
  }
44
42
 
45
43
  async function bulkIndexDocuments({ client, indexName, documents }) {
@@ -67,9 +65,9 @@ async function bulkIndexDocuments({ client, indexName, documents }) {
67
65
  const errorDocs = resp.items.filter((item) => item.index.status !== 201);
68
66
  throw new Error(`Error during indexing ${JSON.stringify(errorDocs)}`);
69
67
  }
70
- logger.info(`Index ${documents.length} documents.`);
68
+ console.info(`Index ${documents.length} documents.`);
71
69
  } catch (error) {
72
- logger.error(`Failed to index documents (${error})`);
70
+ console.error(`Failed to index documents (${error})`);
73
71
  throw error;
74
72
  }
75
73
  }
@@ -80,7 +78,7 @@ async function indexDocumentsBatched({
80
78
  documents,
81
79
  size = 500,
82
80
  }) {
83
- logger.info(`Loaded ${documents.length} documents`);
81
+ console.info(`Loaded ${documents.length} documents`);
84
82
  for (const chunk of chunks(documents, size)) {
85
83
  await bulkIndexDocuments({ client, documents: chunk, indexName });
86
84
  }
@@ -95,7 +93,7 @@ async function deleteOldIndex({ client, patterns, timestamp }) {
95
93
  );
96
94
 
97
95
  return Promise.all(pIndicesToDelete).then(() => {
98
- logger.info(
96
+ console.info(
99
97
  `Remove ${pIndicesToDelete.length} old indices (${JSON.stringify(
100
98
  IndicesToDelete
101
99
  )})`
package/src/index.d.ts CHANGED
@@ -7,3 +7,4 @@ export const SUGGESTIONS: string;
7
7
  export const vectorizeDocument: any;
8
8
  export const version: any;
9
9
  export const suggestionMapping: any;
10
+ export const vectorizeQuery: any;