From 0b774d74f89d23f6df15274e1226a66d3bcd9d69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20Fern=C3=A1ndez=20Haro?= Date: Fri, 4 Apr 2025 17:28:09 +0200 Subject: [PATCH 1/2] [ES 9.0] Remove body workaround (`@elastic/security-threat-hunting`) --- .../data-stream-adapter/src/create_or_update_data_stream.ts | 3 +-- .../packages/index-adapter/src/create_or_update_index.ts | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/x-pack/solutions/security/packages/data-stream-adapter/src/create_or_update_data_stream.ts b/x-pack/solutions/security/packages/data-stream-adapter/src/create_or_update_data_stream.ts index 4698cbb75b7a2..b7e6edab7bd86 100644 --- a/x-pack/solutions/security/packages/data-stream-adapter/src/create_or_update_data_stream.ts +++ b/x-pack/solutions/security/packages/data-stream-adapter/src/create_or_update_data_stream.ts @@ -83,8 +83,7 @@ const updateMapping = async ({ logger, esClient, indexName, writeIndexOnly }: Up () => esClient.indices.putMapping({ index: indexName, - // @ts-expect-error elasticsearch@9.0.0 https://github.com/elastic/elasticsearch-js/issues/2584 - body: simulatedMapping, + ...simulatedMapping, write_index_only: writeIndexOnly, }), { logger } diff --git a/x-pack/solutions/security/packages/index-adapter/src/create_or_update_index.ts b/x-pack/solutions/security/packages/index-adapter/src/create_or_update_index.ts index a6b2eeaaa436d..3be805a5b7505 100644 --- a/x-pack/solutions/security/packages/index-adapter/src/create_or_update_index.ts +++ b/x-pack/solutions/security/packages/index-adapter/src/create_or_update_index.ts @@ -83,8 +83,7 @@ const updateMapping = async ({ logger, esClient, indexName, writeIndexOnly }: Up () => esClient.indices.putMapping({ index: indexName, - // @ts-expect-error elasticsearch@9.0.0 https://github.com/elastic/elasticsearch-js/issues/2584 - body: simulatedMapping, + ...simulatedMapping, write_index_only: writeIndexOnly, }), { logger } From fc4e4f7b80794561c2090560e911a9bf6a3801da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20Fern=C3=A1ndez=20Haro?= Date: Mon, 7 Apr 2025 15:58:48 +0200 Subject: [PATCH 2/2] Update tests --- .../src/create_or_update_data_stream.test.ts | 4 ++-- .../packages/index-adapter/src/create_or_update_index.test.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/x-pack/solutions/security/packages/data-stream-adapter/src/create_or_update_data_stream.test.ts b/x-pack/solutions/security/packages/data-stream-adapter/src/create_or_update_data_stream.test.ts index a8da9cf65ba2a..c50e73d859eec 100644 --- a/x-pack/solutions/security/packages/data-stream-adapter/src/create_or_update_data_stream.test.ts +++ b/x-pack/solutions/security/packages/data-stream-adapter/src/create_or_update_data_stream.test.ts @@ -55,7 +55,7 @@ describe('updateDataStreams', () => { }); expect(esClient.indices.putMapping).toHaveBeenCalledWith({ index: dataStreamName, - body: simulateIndexTemplateResponse.template.mappings, + ...simulateIndexTemplateResponse.template.mappings, }); }); @@ -167,7 +167,7 @@ describe('createOrUpdateDataStream', () => { }); expect(esClient.indices.putMapping).toHaveBeenCalledWith({ index: name, - body: simulateIndexTemplateResponse.template.mappings, + ...simulateIndexTemplateResponse.template.mappings, }); }); }); diff --git a/x-pack/solutions/security/packages/index-adapter/src/create_or_update_index.test.ts b/x-pack/solutions/security/packages/index-adapter/src/create_or_update_index.test.ts index 36a00dc358570..4aaf00579249c 100644 --- a/x-pack/solutions/security/packages/index-adapter/src/create_or_update_index.test.ts +++ b/x-pack/solutions/security/packages/index-adapter/src/create_or_update_index.test.ts @@ -50,7 +50,7 @@ describe('updateIndices', () => { }); expect(esClient.indices.putMapping).toHaveBeenCalledWith({ index: indexName, - body: simulateIndexTemplateResponse.template.mappings, + ...simulateIndexTemplateResponse.template.mappings, }); }); @@ -158,7 +158,7 @@ describe('createOrUpdateIndex', () => { }); expect(esClient.indices.putMapping).toHaveBeenCalledWith({ index: name, - body: simulateIndexTemplateResponse.template.mappings, + ...simulateIndexTemplateResponse.template.mappings, }); }); });