update es client to 8.12.2 (#175954)

## Summary

Fix https://github.com/elastic/kibana/issues/175919
Fix https://github.com/elastic/kibana/issues/176007

Bump `@elastic/elasticsearch` from `8.9.1-canary.1` to `8.12.2`.

## Notable changes

### `IngestPipeline._meta`

I was forced to introduce a lot of new `@ts-expect-error` because the
`_meta` property was introduced to `IngestPipeline` as mandatory instead
of optional (which feels like a type error to me)

**8.9**

```ts
export interface IngestPipeline {
  description?: string
  on_failure?: IngestProcessorContainer[]
  processors?: IngestProcessorContainer[]
  version?: VersionNumber
}
```

**8.12**

```ts
export interface IngestPipeline {
    description?: string;
    on_failure?: IngestProcessorContainer[];
    processors?: IngestProcessorContainer[];
    version?: VersionNumber;
    _meta: Metadata; // <= not defined as optional...
}
```

I opened
https://github.com/elastic/elasticsearch-specification/issues/2434 in
the specification repo to address the problem, but it likely won't be
done for any `8.12.x` versions of the client.
This commit is contained in:
Pierre Gayvallet 2024-03-07 09:14:28 +01:00 committed by GitHub
parent 90ffefd513
commit 398b62373e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
49 changed files with 108 additions and 65 deletions

View file

@ -104,7 +104,7 @@
"@elastic/charts": "64.0.0",
"@elastic/datemath": "5.0.3",
"@elastic/ecs": "^8.11.1",
"@elastic/elasticsearch": "npm:@elastic/elasticsearch-canary@8.9.1-canary.1",
"@elastic/elasticsearch": "^8.12.2",
"@elastic/ems-client": "8.5.1",
"@elastic/eui": "93.2.0",
"@elastic/filesaver": "1.1.2",

View file

@ -22,7 +22,7 @@ export interface WaitForTaskResponse {
completed: boolean;
failures: Option.Option<any[]>;
description?: string;
response?: estypes.TasksTaskStatus;
response?: estypes.TasksGetResponse['response'];
}
/**

View file

@ -194,6 +194,7 @@ describe('extract search response warnings', () => {
};
expect(
// @ts-expect-error missing new properties on clusters and clusters.details
extractWarnings(response, mockInspectorService, mockRequestAdapter, 'My request')
).toEqual([
{
@ -250,6 +251,7 @@ describe('extract search response warnings', () => {
hits: { hits: [] },
};
expect(
// @ts-expect-error missing new properties on clusters and clusters.details
extractWarnings(response, mockInspectorService, mockRequestAdapter, 'My request')
).toEqual([
{
@ -263,6 +265,7 @@ describe('extract search response warnings', () => {
it('should not include warnings when there are none', () => {
const warnings = extractWarnings(
// @ts-expect-error missing new properties on clusters and clusters.details
{
took: 10,
timed_out: false,

View file

@ -78,7 +78,7 @@ describe('transformError', () => {
});
it('transforms a ResponseError returned by the elasticsearch client', () => {
const error: errors.ResponseError = {
const error = {
name: 'ResponseError',
message: 'illegal_argument_exception',
headers: {},
@ -90,7 +90,7 @@ describe('transformError', () => {
},
meta: {} as unknown as errors.ResponseError['meta'],
statusCode: 400,
};
} as errors.ResponseError;
const transformed = transformError(error);
expect(transformed).toEqual({

View file

@ -12,7 +12,7 @@ import { pluginInitializerContextConfigMock } from '@kbn/core/server/mocks';
import { esSearchStrategyProvider } from './es_search_strategy';
import { SearchStrategyDependencies } from '../../types';
import * as indexNotFoundException from '../../../../common/search/test_data/index_not_found_exception.json';
import indexNotFoundException from '../../../../common/search/test_data/index_not_found_exception.json';
import { errors } from '@elastic/elasticsearch';
import { KbnSearchError } from '../../report_search_error';
import { firstValueFrom } from 'rxjs';
@ -156,7 +156,7 @@ describe('ES search strategy', () => {
expect(e).toBeInstanceOf(KbnSearchError);
expect(e.statusCode).toBe(404);
expect(e.message).toBe(errResponse.message);
expect(e.errBody).toBe(indexNotFoundException);
expect(e.errBody).toEqual(indexNotFoundException);
}
});

View file

@ -10,8 +10,8 @@ import { BehaviorSubject, firstValueFrom } from 'rxjs';
import { KbnServerError } from '@kbn/kibana-utils-plugin/server';
import { KbnSearchError } from '../../report_search_error';
import { errors } from '@elastic/elasticsearch';
import * as indexNotFoundException from '../../../../common/search/test_data/index_not_found_exception.json';
import * as xContentParseException from '../../../../common/search/test_data/x_content_parse_exception.json';
import indexNotFoundException from '../../../../common/search/test_data/index_not_found_exception.json';
import xContentParseException from '../../../../common/search/test_data/x_content_parse_exception.json';
import { SearchStrategyDependencies } from '../../types';
import { enhancedEsSearchStrategyProvider } from './ese_search_strategy';
import { createSearchSessionsClientMock } from '../../mocks';
@ -492,7 +492,7 @@ describe('ES search strategy', () => {
expect(err).toBeInstanceOf(KbnSearchError);
expect(err?.statusCode).toBe(404);
expect(err?.message).toBe(errResponse.message);
expect(err?.errBody).toBe(indexNotFoundException);
expect(err?.errBody).toEqual(indexNotFoundException);
});
it('throws normalized error if Error is thrown', async () => {
@ -567,7 +567,7 @@ describe('ES search strategy', () => {
expect(err).toBeInstanceOf(KbnServerError);
expect(err?.statusCode).toBe(400);
expect(err?.message).toBe(errResponse.message);
expect(err?.errBody).toBe(xContentParseException);
expect(err?.errBody).toEqual(xContentParseException);
});
});

View file

@ -10,8 +10,8 @@ import { firstValueFrom } from 'rxjs';
import { KbnServerError } from '@kbn/kibana-utils-plugin/server';
import { KbnSearchError } from '../../report_search_error';
import { errors } from '@elastic/elasticsearch';
import * as indexNotFoundException from '../../../../common/search/test_data/index_not_found_exception.json';
import * as xContentParseException from '../../../../common/search/test_data/x_content_parse_exception.json';
import indexNotFoundException from '../../../../common/search/test_data/index_not_found_exception.json';
import xContentParseException from '../../../../common/search/test_data/x_content_parse_exception.json';
import { SearchStrategyDependencies } from '../../types';
import { esqlAsyncSearchStrategyProvider } from './esql_async_search_strategy';
import { getMockSearchConfig } from '../../../../config.mock';
@ -243,7 +243,7 @@ describe('ES|QL async search strategy', () => {
expect(err).toBeInstanceOf(KbnSearchError);
expect(err?.statusCode).toBe(404);
expect(err?.message).toBe(errResponse.message);
expect(err?.errBody).toBe(indexNotFoundException);
expect(err?.errBody).toEqual(indexNotFoundException);
});
it('throws normalized error if Error is thrown', async () => {
@ -308,7 +308,7 @@ describe('ES|QL async search strategy', () => {
expect(err).toBeInstanceOf(KbnServerError);
expect(err?.statusCode).toBe(400);
expect(err?.message).toBe(errResponse.message);
expect(err?.errBody).toBe(xContentParseException);
expect(err?.errBody).toEqual(xContentParseException);
});
});

View file

@ -9,7 +9,7 @@
import { merge } from 'lodash';
import { KbnSearchError } from '../../report_search_error';
import { errors } from '@elastic/elasticsearch';
import * as indexNotFoundException from '../../../../common/search/test_data/index_not_found_exception.json';
import indexNotFoundException from '../../../../common/search/test_data/index_not_found_exception.json';
import { SearchStrategyDependencies } from '../../types';
import { sqlSearchStrategyProvider } from './sql_search_strategy';
import { createSearchSessionsClientMock } from '../../mocks';
@ -258,7 +258,7 @@ describe('SQL search strategy', () => {
expect(err).toBeInstanceOf(KbnSearchError);
expect(err?.statusCode).toBe(404);
expect(err?.message).toBe(errResponse.message);
expect(err?.errBody).toBe(indexNotFoundException);
expect(err?.errBody).toEqual(indexNotFoundException);
});
it('throws normalized error if Error is thrown', async () => {

View file

@ -8,7 +8,6 @@
import type {
AggregationsAggregationContainer,
AggregationsCompositeAggregation,
AggregationsAggregateOrder,
} from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
import type { AggregateOptions } from '../server/application/rule/methods/aggregate/types';
@ -51,7 +50,7 @@ export const getRuleTagsAggregation = (
tags: {
terms: {
field: 'alert.attributes.tags',
order: 'asc' as unknown as AggregationsAggregateOrder,
order: 'asc' as const,
},
},
},

View file

@ -7,7 +7,10 @@
import { elasticsearchServiceMock, loggingSystemMock } from '@kbn/core/server/mocks';
import { elasticsearchClientMock } from '@kbn/core-elasticsearch-client-server-mocks';
import { IndicesGetDataStreamResponse } from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
import {
IndicesGetDataStreamResponse,
IndicesDataStreamIndex,
} from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
import { errors as EsErrors } from '@elastic/elasticsearch';
import { ReplaySubject, Subject } from 'rxjs';
import { AlertsService } from './alerts_service';
@ -72,9 +75,11 @@ const GetDataStreamResponse: IndicesGetDataStreamResponse = {
generation: 1,
timestamp_field: { name: 'ignored' },
hidden: true,
indices: [{ index_name: 'ignored', index_uuid: 'ignored' }],
indices: [{ index_name: 'ignored', index_uuid: 'ignored' } as IndicesDataStreamIndex],
status: 'green',
template: 'ignored',
next_generation_managed_by: 'Index Lifecycle Management',
prefer_ilm: false,
},
],
};

View file

@ -5,7 +5,6 @@
* 2.0.
*/
import type { AggregationsAggregateOrder } from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
import { getRuleTagsAggregation } from '../../../../../../common';
import { defaultRuleAggregationFactory } from '..';
@ -65,7 +64,7 @@ describe('validateAggregationTerms', () => {
tags: {
terms: {
field: 'alert.attributes.tags',
order: 'asc' as unknown as AggregationsAggregateOrder,
order: 'asc' as const,
},
},
},

View file

@ -5,8 +5,6 @@
* 2.0.
*/
import type { QueryDslTextExpansionQuery } from '@elastic/elasticsearch/lib/api/types';
import type { MsearchQueryBody } from '../lib/langchain/elasticsearch_store/helpers/get_msearch_query_body';
/**
@ -42,7 +40,7 @@ export const mSearchQueryBody: MsearchQueryBody = {
model_text:
'Generate an ESQL query that will count the number of connections made to external IP addresses, broken down by user. If the count is greater than 100 for a specific user, add a new field called "follow_up" that contains a value of "true", otherwise, it should contain "false". The user names should also be enriched with their respective group names.',
},
} as unknown as QueryDslTextExpansionQuery,
},
},
],
},

View file

@ -10,7 +10,6 @@ import type {
FieldValue,
QueryDslQueryContainer,
QueryDslTermQuery,
QueryDslTextExpansionQuery,
} from '@elastic/elasticsearch/lib/api/types';
/**
@ -43,7 +42,7 @@ export const getVectorSearchQuery = ({
model_id: modelId,
model_text: query,
},
} as unknown as QueryDslTextExpansionQuery,
},
},
],
filter,

View file

@ -79,6 +79,7 @@ describe('getMlModelTypesForModelConfig lib function', () => {
});
describe('generateMlInferencePipelineBody lib function', () => {
// @ts-expect-error pipeline._meta defined as mandatory
const expected: MlInferencePipeline = {
description: 'my-description',
processors: [
@ -201,6 +202,7 @@ describe('generateMlInferencePipelineBody lib function', () => {
describe('parseMlInferenceParametersFromPipeline', () => {
it('returns pipeline parameters from ingest pipeline', () => {
expect(
// @ts-expect-error pipeline._meta defined as mandatory
parseMlInferenceParametersFromPipeline('unit-test', {
processors: [
{
@ -228,6 +230,7 @@ describe('parseMlInferenceParametersFromPipeline', () => {
});
it('returns pipeline parameters from ingest pipeline with multiple inference processors', () => {
expect(
// @ts-expect-error pipeline._meta defined as mandatory
parseMlInferenceParametersFromPipeline('unit-test', {
processors: [
{
@ -267,10 +270,12 @@ describe('parseMlInferenceParametersFromPipeline', () => {
});
});
it('return null if pipeline is missing inference processor', () => {
// @ts-expect-error pipeline._meta defined as mandatory
expect(parseMlInferenceParametersFromPipeline('unit-test', { processors: [] })).toBeNull();
});
it('return null if pipeline is missing field_map', () => {
expect(
// @ts-expect-error pipeline._meta defined as mandatory
parseMlInferenceParametersFromPipeline('unit-test', {
processors: [
{

View file

@ -56,6 +56,7 @@ export const generateMlInferencePipelineBody = ({
model,
pipelineName,
}: MlInferencePipelineParams): MlInferencePipeline => {
// @ts-expect-error pipeline._meta defined as mandatory
const pipelineDefinition: MlInferencePipeline = {
description: description ?? '',
processors: [],
@ -185,6 +186,7 @@ export const parseMlInferenceParametersFromPipeline = (
})
.filter((f) => f.sourceField) as FieldMapping[];
// @ts-expect-error pipeline._meta defined as mandatory
return fieldMappings.length === 0
? null
: {

View file

@ -34,6 +34,7 @@ describe('CreateMlInferencePipelineApiLogic', () => {
indexName: 'my-index',
modelId: 'my-model-id',
pipelineName: 'my-pipeline',
// @ts-expect-error pipeline._meta defined as mandatory
pipelineDefinition: { processors: [], version: 1 },
};
const result = await createMlInferencePipeline(args);

View file

@ -199,6 +199,7 @@ describe('MlInferenceLogic', () => {
],
indexName: 'test',
modelId: 'test-model',
// @ts-expect-error pipeline._meta defined as mandatory
pipelineDefinition: {},
pipelineName: 'unit-test',
});
@ -259,6 +260,7 @@ describe('MlInferenceLogic', () => {
],
});
MLInferenceLogic.actions.fetchPipelineSuccess({
// @ts-expect-error pipeline._meta defined as mandatory
'mock-pipeline': {},
});
@ -330,6 +332,7 @@ describe('MlInferenceLogic', () => {
version: 1,
};
FetchMlInferencePipelinesApiLogic.actions.apiSuccess({
// @ts-expect-error pipeline._meta defined as mandatory
'unit-test': existingPipeline,
});
MLInferenceLogic.actions.setInferencePipelineConfiguration({
@ -484,6 +487,7 @@ describe('MlInferenceLogic', () => {
jest.spyOn(MLInferenceLogic.actions, 'setAddInferencePipelineStep');
MLInferenceLogic.actions.fetchPipelineSuccess({
// @ts-expect-error pipeline._meta defined as mandatory
'mock-pipeline': {},
});
expect(MLInferenceLogic.actions.setAddInferencePipelineStep).toHaveBeenCalledWith(

View file

@ -60,6 +60,7 @@ const DEFAULT_MODELS: MlModel[] = [
];
const DEFAULT_PIPELINES: FetchMlInferencePipelinesResponse = {
// @ts-expect-error pipeline._meta defined as mandatory
'my-pipeline': {
processors: [
{
@ -130,6 +131,7 @@ describe('PipelineSelectLogic', () => {
jest.spyOn(PipelineSelectLogic.actions, 'setInferencePipelineConfiguration');
FetchMlInferencePipelinesApiLogic.actions.apiSuccess({
// @ts-expect-error pipeline._meta defined as mandatory
'my-pipeline': {
processors: [
{
@ -184,6 +186,7 @@ describe('PipelineSelectLogic', () => {
});
it('returns disabled pipeline option if missing source fields', () => {
FetchMlInferencePipelinesApiLogic.actions.apiSuccess({
// @ts-expect-error pipeline._meta defined as mandatory
'my-pipeline': {
processors: [
{
@ -232,6 +235,7 @@ describe('PipelineSelectLogic', () => {
});
it('returns enabled pipeline option if model is redacted', () => {
FetchMlInferencePipelinesApiLogic.actions.apiSuccess({
// @ts-expect-error pipeline._meta defined as mandatory
'my-pipeline': {
processors: [
{

View file

@ -46,6 +46,7 @@ const DEFAULT_VALUES: TestPipelineValues = {
simulatePipelineStatus: 0,
};
// @ts-expect-error pipeline._meta defined as mandatory
const mockInferencePipeline: MlInferencePipeline = {
processors: [],
version: 1,

View file

@ -61,6 +61,7 @@ describe('IndexPipelinesConfigurationsLogic', () => {
version: 1,
},
};
// @ts-expect-error pipeline._meta defined as mandatory
FetchCustomPipelineApiLogic.actions.apiSuccess(pipelines);
await nextTick();
@ -72,6 +73,7 @@ describe('IndexPipelinesConfigurationsLogic', () => {
version: 1,
},
};
// @ts-expect-error pipeline._meta defined as mandatory
FetchCustomPipelineApiLogic.actions.apiSuccess(pipelines);
await nextTick();
@ -92,6 +94,7 @@ describe('IndexPipelinesConfigurationsLogic', () => {
version: 1,
},
};
// @ts-expect-error pipeline._meta defined as mandatory
FetchCustomPipelineApiLogic.actions.apiSuccess(pipelines);
await nextTick();
@ -112,6 +115,7 @@ describe('IndexPipelinesConfigurationsLogic', () => {
version: 3,
},
};
// @ts-expect-error pipeline._meta defined as mandatory
FetchCustomPipelineApiLogic.actions.apiSuccess(pipelines);
IndexPipelinesConfigurationsLogic.actions.selectPipeline('foo');
await nextTick();

View file

@ -153,6 +153,7 @@ describe('PipelinesLogic', () => {
PipelinesLogic.actions.savePipeline = jest.fn();
PipelinesLogic.actions.fetchCustomPipeline = jest.fn();
PipelinesLogic.actions.fetchIndexApiSuccess(connectorIndex);
// @ts-expect-error pipeline._meta defined as mandatory
PipelinesLogic.actions.createCustomPipelineSuccess({ [connectorIndex.name]: {} });
expect(flashSuccessToast).toHaveBeenCalledWith('Custom pipeline created');
expect(PipelinesLogic.actions.setPipelineState).toHaveBeenCalledWith({
@ -216,6 +217,7 @@ describe('PipelinesLogic', () => {
...apiIndex,
});
const indexName = apiIndex.name;
// @ts-expect-error pipeline._meta defined as mandatory
const indexPipelines: Record<string, IngestPipeline> = {
[indexName]: {
processors: [],

View file

@ -56,6 +56,7 @@ describe('createMlInferencePipeline lib function', () => {
const actualResult = await createMlInferencePipeline(
pipelineName,
// @ts-expect-error pipeline._meta defined as mandatory
pipelineDefinition,
mockClient as unknown as ElasticsearchClient
);
@ -67,6 +68,7 @@ describe('createMlInferencePipeline lib function', () => {
it('should convert spaces to underscores in the pipeline name', async () => {
await createMlInferencePipeline(
'my pipeline with spaces ',
// @ts-expect-error pipeline._meta defined as mandatory
pipelineDefinition,
mockClient as unknown as ElasticsearchClient
);
@ -87,6 +89,7 @@ describe('createMlInferencePipeline lib function', () => {
const actualResult = createMlInferencePipeline(
pipelineName,
// @ts-expect-error pipeline._meta defined as mandatory
pipelineDefinition,
mockClient as unknown as ElasticsearchClient
);

View file

@ -337,6 +337,7 @@ describe('getMlInferencePipelineProcessorNamesFromPipelines', () => {
const expected = ['ml-inference-pipeline-1'];
const processorNames = getMlInferencePipelineProcessorNamesFromPipelines(
'my-index',
// @ts-expect-error pipeline._meta defined as mandatory
mockGetPipeline
);
expect(processorNames).toEqual(expected);
@ -344,6 +345,7 @@ describe('getMlInferencePipelineProcessorNamesFromPipelines', () => {
it('should return an empty array for a missing @ml-inference pipeline', () => {
const processorNames = getMlInferencePipelineProcessorNamesFromPipelines(
'my-index-without-ml-inference-pipeline',
// @ts-expect-error pipeline._meta defined as mandatory
mockGetPipeline
);
@ -353,6 +355,7 @@ describe('getMlInferencePipelineProcessorNamesFromPipelines', () => {
const processorNames = getMlInferencePipelineProcessorNamesFromPipelines(
'my-index-without-ml-inference-pipeline',
{
// @ts-expect-error pipeline._meta defined as mandatory
'my-index-without-ml-inference-pipeline': {},
}
);

View file

@ -36,6 +36,7 @@ export const createIndexPipelineDefinitions = async (
version: 1,
};
await esClient.ingest.putPipeline(mlPipeline);
// @ts-expect-error pipeline._meta defined as mandatory
result = { ...result, [mlPipeline.id]: mlPipeline };
const customPipeline = {
description: `Enterprise Search customizable ingest pipeline for the '${indexName}' index`,
@ -44,6 +45,7 @@ export const createIndexPipelineDefinitions = async (
version: 1,
};
await esClient.ingest.putPipeline(customPipeline);
// @ts-expect-error pipeline._meta defined as mandatory
result = { ...result, [customPipeline.id]: customPipeline };
const ingestPipeline = {
_meta: {

View file

@ -463,6 +463,7 @@ export function registerIndexRoutes({
const createPipelineResult = await preparePipelineAndIndexForMlInference(
indexName,
pipelineName,
// @ts-expect-error pipeline._meta defined as mandatory
pipelineDefinition,
modelId,
fieldMappings,
@ -659,6 +660,7 @@ export function registerIndexRoutes({
const simulateRequest: IngestSimulateRequest = {
docs,
// @ts-expect-error pipeline._meta defined as mandatory
pipeline: { description: defaultDescription, ...pipeline },
};

View file

@ -447,7 +447,7 @@ describe('setIndexAliasToHidden', () => {
});
});
export const GetDataStreamsResponse = {
export const GetDataStreamsResponse: estypes.IndicesGetDataStreamResponse = {
data_streams: [
{
name: 'foo',
@ -457,6 +457,8 @@ export const GetDataStreamsResponse = {
indices: [],
template: '',
hidden: true,
prefer_ilm: false,
next_generation_managed_by: 'Index Lifecycle Management',
},
],
};

View file

@ -42,7 +42,6 @@ export const deleteTransforms = async (
{
force: true,
transform_id: transformId,
// @ts-expect-error ES type needs to be updated
delete_dest_index: deleteDestinationIndices,
},
{ ...(secondaryAuth ? secondaryAuth : {}), ignore: [404] }

View file

@ -37,6 +37,7 @@ export function registerGrokSimulateRoute(framework: KibanaFramework) {
const esClient = (await requestContext.core).elasticsearch.client;
const grokdebuggerRequest = GrokdebuggerRequest.fromDownstreamJSON(request.body);
const simulateResponseFromES = await esClient.asCurrentUser.ingest.simulate({
// @ts-expect-error pipeline._meta defined as mandatory
body: grokdebuggerRequest.upstreamJSON,
});
const grokdebuggerResponse = GrokdebuggerResponse.fromUpstreamJSON(simulateResponseFromES);

View file

@ -7,10 +7,11 @@
import {
ByteSize,
IndicesDataLifecycleWithRollover,
IndicesDataStream,
IndicesDataStreamsStatsDataStreamsStatsItem,
Metadata,
IndicesDataStreamIndex,
IndicesDataStreamLifecycleWithRollover,
} from '@elastic/elasticsearch/lib/api/types';
interface TimestampFieldFromEs {
@ -28,12 +29,7 @@ type Privileges = PrivilegesFromEs;
export type HealthFromEs = 'GREEN' | 'YELLOW' | 'RED';
export interface DataStreamIndexFromEs {
index_name: string;
index_uuid: string;
prefer_ilm: boolean;
managed_by: string;
}
export type DataStreamIndexFromEs = IndicesDataStreamIndex;
export type Health = 'green' | 'yellow' | 'red';
@ -42,7 +38,6 @@ export interface EnhancedDataStreamFromEs extends IndicesDataStream {
store_size_bytes?: IndicesDataStreamsStatsDataStreamsStatsItem['store_size_bytes'];
maximum_timestamp?: IndicesDataStreamsStatsDataStreamsStatsItem['maximum_timestamp'];
indices: DataStreamIndexFromEs[];
next_generation_managed_by: string;
privileges: {
delete_index: boolean;
manage_data_stream_lifecycle: boolean;
@ -64,7 +59,7 @@ export interface DataStream {
privileges: Privileges;
hidden: boolean;
nextGenerationManagedBy: string;
lifecycle?: IndicesDataLifecycleWithRollover & {
lifecycle?: IndicesDataStreamLifecycleWithRollover & {
enabled?: boolean;
};
}

View file

@ -28,7 +28,6 @@ const enhanceDataStreams = ({
dataStreamsPrivileges?: SecurityHasPrivilegesResponse;
}): EnhancedDataStreamFromEs[] => {
return dataStreams.map((dataStream) => {
// @ts-expect-error @elastic/elasticsearch next_generation_managed_by prop is still not in the ES types
const enhancedDataStream: EnhancedDataStreamFromEs = {
...dataStream,
privileges: {

View file

@ -12,6 +12,7 @@ describe('pipeline_serialization', () => {
it('should deserialize pipelines', () => {
expect(
deserializePipelines({
// @ts-expect-error pipeline._meta defined as mandatory
pipeline1: {
description: 'pipeline 1 description',
version: 1,
@ -31,6 +32,7 @@ describe('pipeline_serialization', () => {
},
],
},
// @ts-expect-error pipeline._meta defined as mandatory
pipeline2: {
description: 'pipeline2 description',
version: 1,
@ -40,7 +42,6 @@ describe('pipeline_serialization', () => {
description: 'pipeline3 description',
version: 1,
processors: [],
// @ts-expect-error es type do not contains _meta https://github.com/elastic/elasticsearch-js/issues/1724
_meta: {
managed: true,
},

View file

@ -18,7 +18,6 @@ export function deserializePipelines(pipelinesByName: {
...pipelinesByName[name],
processors: (pipelinesByName[name]?.processors as Processor[]) ?? [],
on_failure: pipelinesByName[name]?.on_failure as Processor[],
// @ts-expect-error Missing _meta on es types https://github.com/elastic/elasticsearch-js/issues/1724
isManaged: Boolean(pipelinesByName[name]?._meta?.managed === true),
name,
};

View file

@ -37,6 +37,7 @@ export const registerSimulateRoute = ({
const response = await clusterClient.asCurrentUser.ingest.simulate({
verbose,
body: {
// @ts-expect-error pipeline._meta defined as mandatory
pipeline,
docs: documents as estypes.IngestSimulateDocument[],
},

View file

@ -229,7 +229,6 @@ export function createDistanceFilterWithMeta({
function extractGeometryFromFilter(geoFieldName: string, filter: GeoFilter): Geometry | undefined {
if (filter.geo_distance && filter.geo_distance[geoFieldName]) {
// @ts-expect-error QueryDslGeoDistanceQuery incorrectly types distance as optional
const distanceSplit = filter.geo_distance.distance.split('km');
const distance = parseFloat(distanceSplit[0]);
const circleFeature = turfCircle(filter.geo_distance[geoFieldName], distance);

View file

@ -60,6 +60,7 @@ export const AddInferencePipelineFlyout: FC<AddInferencePipelineFlyoutProps> = (
const createPipeline = async () => {
setFormState({ ...formState, creatingPipeline: true });
try {
// @ts-expect-error pipeline._meta is defined as mandatory
await createInferencePipeline(formState.pipelineName, getPipelineConfig(formState));
setFormState({
...formState,
@ -167,6 +168,7 @@ export const AddInferencePipelineFlyout: FC<AddInferencePipelineFlyoutProps> = (
)}
{step === ADD_INFERENCE_PIPELINE_STEPS.CREATE && (
<ReviewAndCreatePipeline
// @ts-expect-error pipeline._meta is defined as mandatory
inferencePipeline={getPipelineConfig(formState)}
modelType={modelType}
pipelineName={formState.pipelineName}

View file

@ -91,6 +91,7 @@ export const TestPipeline: FC<Props> = memo(({ state, sourceIndex, mode }) => {
const simulatePipeline = async () => {
try {
const result = await trainedModelPipelineSimulate(
// @ts-expect-error pipeline._meta is defined as mandatory
pipelineConfig,
JSON.parse(sampleDocsString) as IngestSimulateDocument[]
);

View file

@ -15,6 +15,7 @@ export function getPipelineConfig(state: InferecePipelineCreationState): estypes
? initialPipelineConfig?.processors[0]
: {};
// @ts-expect-error pipeline._meta is defined as mandatory
return {
description: pipelineDescription,
processors: [

View file

@ -70,6 +70,7 @@ export abstract class InferenceBase<TInferResponse> {
private inferenceError$ = new BehaviorSubject<MLHttpFetchError | null>(null);
private runningState$ = new BehaviorSubject<RUNNING_STATE>(RUNNING_STATE.STOPPED);
private isValid$ = new BehaviorSubject<boolean>(false);
// @ts-expect-error pipeline._meta is defined as mandatory
private pipeline$ = new BehaviorSubject<estypes.IngestPipeline>({});
private supportedFieldTypes: ES_FIELD_TYPES[] = [ES_FIELD_TYPES.TEXT];
private selectedDataViewId: string | undefined;
@ -246,6 +247,7 @@ export abstract class InferenceBase<TInferResponse> {
protected abstract inferIndex(): Promise<TInferResponse[]>;
public generatePipeline(): estypes.IngestPipeline {
// @ts-expect-error pipeline._meta is defined as mandatory
return {
processors: this.getProcessors(),
};

View file

@ -39,7 +39,6 @@ export class FillMaskInference extends InferenceBase<TextClassificationResponse>
deploymentId: string
) {
super(trainedModelsApi, model, inputType, deploymentId);
// @ts-expect-error mask_token is missing in type
const maskToken = model.inference_config?.[this.inferenceType]?.mask_token;
if (maskToken) {
this.maskToken = maskToken;

View file

@ -448,6 +448,7 @@ export function trainedModelsRoutes(
try {
const { pipeline, pipelineName } = request.body;
const body = await modelsProvider(client, mlClient, cloud).createInferencePipeline(
// @ts-expect-error pipeline._meta is defined as mandatory
pipeline!,
pipelineName
);

View file

@ -37,7 +37,7 @@ const mapTypeMessage: { [key: string]: string } = {
}),
};
export function isESClientError(err: ErrorTypes) {
export function isESClientError(err: ErrorTypes): err is errors.ElasticsearchClientError {
if (err instanceof errors.ElasticsearchClientError === false) return false;
const knownTypes = Object.keys(mapTypeMessage);
return knownTypes.includes(err.constructor.name);

View file

@ -5,7 +5,6 @@
* 2.0.
*/
import { errors } from '@elastic/elasticsearch';
import type { QueryDslTextExpansionQuery } from '@elastic/elasticsearch/lib/api/types';
import { serverUnavailable, gatewayTimeout } from '@hapi/boom';
import type { ElasticsearchClient } from '@kbn/core/server';
import type { Logger } from '@kbn/logging';
@ -314,7 +313,7 @@ export class KnowledgeBaseService {
model_text: text,
model_id: modelId,
},
} as unknown as QueryDslTextExpansionQuery,
},
})),
filter: [
...getAccessQuery({
@ -385,7 +384,7 @@ export class KnowledgeBaseService {
model_text: query,
model_id: modelId,
},
} as unknown as QueryDslTextExpansionQuery,
},
},
],
filter: [

View file

@ -9,7 +9,11 @@ import { type Subject, ReplaySubject } from 'rxjs';
import { ResourceInstaller } from './resource_installer';
import { loggerMock } from '@kbn/logging-mocks';
import { AlertConsumers } from '@kbn/rule-data-utils';
import { IndicesGetDataStreamResponse } from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
import {
IndicesGetDataStreamResponse,
IndicesDataStreamIndex,
IndicesDataStream,
} from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
import { Dataset } from './index_options';
import { IndexInfo } from './index_info';
@ -45,10 +49,10 @@ const GetDataStreamResponse: IndicesGetDataStreamResponse = {
generation: 1,
timestamp_field: { name: 'ignored' },
hidden: true,
indices: [{ index_name: 'ignored', index_uuid: 'ignored' }],
indices: [{ index_name: 'ignored', index_uuid: 'ignored' } as IndicesDataStreamIndex],
status: 'green',
template: 'ignored',
},
} as IndicesDataStream,
],
};

View file

@ -44,7 +44,6 @@ export function defineHasApiKeysRoutes({
const { api_keys: apiKeys } = await esClient.asCurrentUser.security.getApiKey({
owner: true,
// @ts-expect-error @elastic/elasticsearch SecurityGetApiKeyRequest.active_only: boolean | undefined
active_only: true,
});

View file

@ -47,6 +47,7 @@ export function defineRoleMappingPostRoutes({ router }: RouteDefinitionParams) {
const esClient = (await context.core).elasticsearch.client;
const saveResponse = await esClient.asCurrentUser.security.putRoleMapping({
name: request.params.name,
// @ts-expect-error type mismatch on role_templates
body: request.body,
});
return response.ok({ body: saveResponse });

View file

@ -87,7 +87,6 @@ export async function deleteTransforms(
await esClient.asCurrentUser.transform.deleteTransform({
transform_id: transformId,
force: shouldForceDelete && needToForceDelete,
// @ts-expect-error ES type needs to be updated
delete_dest_index: deleteDestIndex,
});
transformDeleted.success = true;

View file

@ -5,6 +5,7 @@
* 2.0.
*/
import * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
import { loggingSystemMock } from '@kbn/core/server/mocks';
import { Logger } from '@kbn/core/server';
import { TimeSeriesQuery, timeSeriesQuery, getResultFromEs } from './time_series_query';
@ -827,7 +828,7 @@ describe('getResultFromEs', () => {
took: 0,
timed_out: false,
_shards: { total: 0, successful: 0, skipped: 0, failed: 0 },
_clusters: { total: 1, successful: 1, skipped: 0 },
_clusters: { total: 1, successful: 1, skipped: 0 } as estypes.ClusterStatistics,
hits: { total: { value: 0, relation: 'eq' }, hits: [] },
},
})
@ -845,7 +846,7 @@ describe('getResultFromEs', () => {
took: 0,
timed_out: false,
_shards: { total: 0, successful: 0, skipped: 0, failed: 0 },
_clusters: { total: 1, successful: 1, skipped: 0 },
_clusters: { total: 1, successful: 1, skipped: 0 } as estypes.ClusterStatistics,
hits: { total: { value: 0, relation: 'eq' }, hits: [] },
},
})
@ -1283,7 +1284,7 @@ describe('getResultFromEs', () => {
took: 0,
timed_out: false,
_shards: { total: 0, successful: 0, skipped: 0, failed: 0 },
_clusters: { total: 1, successful: 1, skipped: 0 },
_clusters: { total: 1, successful: 1, skipped: 0 } as estypes.ClusterStatistics,
hits: { total: { value: 0, relation: 'eq' }, hits: [] },
},
})
@ -1301,7 +1302,7 @@ describe('getResultFromEs', () => {
took: 0,
timed_out: false,
_shards: { total: 0, successful: 0, skipped: 0, failed: 0 },
_clusters: { total: 1, successful: 1, skipped: 0 },
_clusters: { total: 1, successful: 1, skipped: 0 } as estypes.ClusterStatistics,
hits: { total: { value: 0, relation: 'eq' }, hits: [] },
},
})

View file

@ -225,6 +225,7 @@ export default function ({ getService }: FtrProviderContext) {
await ml.testExecution.logTestStep(
'should complete the deploy model pipeline Create pipeline step'
);
// @ts-expect-error pipeline._meta is defined as mandatory
await ml.deployDFAModelFlyout.completeTrainedModelsInferenceFlyoutCreateStep({
description: modelWithoutPipelineDataExpectedValues.description,
processors: [
@ -286,6 +287,7 @@ export default function ({ getService }: FtrProviderContext) {
await ml.testExecution.logTestStep(
'should complete the deploy model pipeline Create pipeline step'
);
// @ts-expect-error pipeline._meta is defined as mandatory
await ml.deployDFAModelFlyout.completeTrainedModelsInferenceFlyoutCreateStep({
description: modelWithoutPipelineDataExpectedValues.duplicateDescription,
processors: [

View file

@ -1715,12 +1715,12 @@
"@elastic/transport" "^8.3.1"
tslib "^2.4.0"
"@elastic/elasticsearch@npm:@elastic/elasticsearch-canary@8.9.1-canary.1":
version "8.9.1-canary.1"
resolved "https://registry.yarnpkg.com/@elastic/elasticsearch-canary/-/elasticsearch-canary-8.9.1-canary.1.tgz#7c1cdc6cc4129910544b2a3abd6a73b9fcc82ff3"
integrity sha512-pxFP57AEmbsgC6LsGv7xyAR4qCXiX6JXAGVdzBXDl2qEdz1p5y3htgyT6tGvyTV11Ma0AflsWx0jJ1vrp6bGew==
"@elastic/elasticsearch@^8.12.2":
version "8.12.2"
resolved "https://registry.yarnpkg.com/@elastic/elasticsearch/-/elasticsearch-8.12.2.tgz#7a241f739a509cc59faee85f79a4c9e9e5ba9128"
integrity sha512-04NvH3LIgcv1Uwguorfw2WwzC9Lhfsqs9f0L6uq6MrCw0lqe/HOQ6E8vJ6EkHAA15iEfbhtxOtenbZVVcE+mAQ==
dependencies:
"@elastic/transport" "^8.3.3"
"@elastic/transport" "^8.4.1"
tslib "^2.4.0"
"@elastic/ems-client@8.5.1":
@ -1896,10 +1896,10 @@
undici "^5.21.2"
yaml "^2.2.2"
"@elastic/transport@^8.3.1", "@elastic/transport@^8.3.3":
version "8.3.3"
resolved "https://registry.yarnpkg.com/@elastic/transport/-/transport-8.3.3.tgz#06c5b1b9566796775ac96d17959dafc269da5ec1"
integrity sha512-g5nc//dq/RQUTMkJUB8Ui8KJa/WflWmUa7yLl4SRZd67PPxIp3cn+OvGMNIhpiLRcfz1upanzgZHb/7Po2eEdQ==
"@elastic/transport@^8.3.1", "@elastic/transport@^8.4.1":
version "8.4.1"
resolved "https://registry.yarnpkg.com/@elastic/transport/-/transport-8.4.1.tgz#f98c5a5e2156bcb3f01170b4aca7e7de4d8b61b8"
integrity sha512-/SXVuVnuU5b4dq8OFY4izG+dmGla185PcoqgK6+AJMpmOeY1QYVNbWtCwvSvoAANN5D/wV+EBU8+x7Vf9EphbA==
dependencies:
debug "^4.3.4"
hpagent "^1.0.0"