Skip to content

Commit

Permalink
Update dependency @elastic/elasticsearch to ^8.16.0 (main) (elastic#2…
Browse files Browse the repository at this point in the history
…00275)

This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
|
[@elastic/elasticsearch](http://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/index.html)
([source](https://togithub.com/elastic/elasticsearch-js)) | dependencies
| minor | [`^8.15.2` ->
`^8.16.0`](https://renovatebot.com/diffs/npm/@elastic%2felasticsearch/8.15.2/8.16.0)
|

---

### Release Notes

<details>
<summary>elastic/elasticsearch-js
(@&elastic#8203;elastic/elasticsearch)</summary>

###
[`v8.16.0`](https://togithub.com/elastic/elasticsearch-js/releases/tag/v8.16.0)

[Compare
Source](https://togithub.com/elastic/elasticsearch-js/compare/v8.15.2...v8.16.0)

[Changelog](https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/8.16/changelog-client.html)

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you
are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Renovate
Bot](https://togithub.com/renovatebot/renovate).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy40MjUuMSIsInVwZGF0ZWRJblZlciI6IjM3LjQyNS4xIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJUZWFtOkNvcmUiLCJUZWFtOk9wZXJhdGlvbnMiLCJiYWNrcG9ydDpza2lwIiwicmVsZWFzZV9ub3RlOnNraXAiXX0=-->

Co-authored-by: elastic-renovate-prod[bot] <174716857+elastic-renovate-prod[bot]@users.noreply.github.com>
(cherry picked from commit e061b4c)

# Conflicts:
#	package.json
#	yarn.lock
  • Loading branch information
elastic-renovate-prod[bot] committed Dec 16, 2024
1 parent 31fa4a2 commit f3f6b2c
Show file tree
Hide file tree
Showing 21 changed files with 164 additions and 43 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@
"@elastic/datemath": "5.0.3",
"@elastic/ebt": "^1.1.1",
"@elastic/ecs": "^8.11.1",
"@elastic/elasticsearch": "^8.15.1",
"@elastic/elasticsearch": "^8.16.0",
"@elastic/ems-client": "8.5.3",
"@elastic/eui": "97.3.1",
"@elastic/filesaver": "1.1.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import {
createGenericNotFoundErrorPayload,
} from '../../test_helpers/repository.test.common';
import { PointInTimeFinder } from '../point_in_time_finder';
import { OpenPointInTimeResponse } from '@elastic/elasticsearch/lib/api/types';

describe('SavedObjectsRepository', () => {
let client: ReturnType<typeof elasticsearchClientMock.createElasticsearchClient>;
Expand Down Expand Up @@ -81,7 +82,7 @@ describe('SavedObjectsRepository', () => {
describe('#openPointInTimeForType', () => {
const type = 'index-pattern';

const generateResults = (id?: string) => ({ id: id || 'id' });
const generateResults = (id?: string) => ({ id: id || 'id' } as OpenPointInTimeResponse);
const successResponse = async (type: string, options?: SavedObjectsOpenPointInTimeOptions) => {
client.openPointInTime.mockResponseOnce(generateResults());
const result = await repository.openPointInTimeForType(type, options);
Expand Down Expand Up @@ -136,7 +137,7 @@ describe('SavedObjectsRepository', () => {
it(`throws when ES is unable to find the index`, async () => {
client.openPointInTime.mockResolvedValueOnce(
elasticsearchClientMock.createSuccessTransportRequestPromise(
{ id: 'error' },
{ id: 'error' } as OpenPointInTimeResponse,
{ statusCode: 404 }
)
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ import {
import { savedObjectsExtensionsMock } from '../mocks/saved_objects_extensions.mock';
import { arrayMapsAreEqual } from '@kbn/core-saved-objects-utils-server';
import { mockAuthenticatedUser } from '@kbn/core-security-common/mocks';
import { OpenPointInTimeResponse } from '@elastic/elasticsearch/lib/api/types';

describe('SavedObjectsRepository Security Extension', () => {
let client: ReturnType<typeof elasticsearchClientMock.createElasticsearchClient>;
Expand Down Expand Up @@ -676,7 +677,7 @@ describe('SavedObjectsRepository Security Extension', () => {
test(`returns result when partially authorized`, async () => {
setupAuthorizeFunc(mockSecurityExt.authorizeOpenPointInTime, 'partially_authorized');

client.openPointInTime.mockResponseOnce({ id });
client.openPointInTime.mockResponseOnce({ id } as OpenPointInTimeResponse);
const result = await repository.openPointInTimeForType(type);

expect(mockSecurityExt.authorizeOpenPointInTime).toHaveBeenCalledTimes(1);
Expand All @@ -687,7 +688,7 @@ describe('SavedObjectsRepository Security Extension', () => {
test(`returns result when fully authorized`, async () => {
setupAuthorizeFunc(mockSecurityExt.authorizeOpenPointInTime, 'fully_authorized');

client.openPointInTime.mockResponseOnce({ id });
client.openPointInTime.mockResponseOnce({ id } as OpenPointInTimeResponse);
const result = await repository.openPointInTimeForType(type);

expect(mockSecurityExt.authorizeOpenPointInTime).toHaveBeenCalledTimes(1);
Expand All @@ -702,7 +703,7 @@ describe('SavedObjectsRepository Security Extension', () => {

test(`calls authorizeOpenPointInTime with correct parameters`, async () => {
setupAuthorizeFunc(mockSecurityExt.authorizeOpenPointInTime, 'fully_authorized');
client.openPointInTime.mockResponseOnce({ id });
client.openPointInTime.mockResponseOnce({ id } as OpenPointInTimeResponse);
const namespaces = [namespace, 'x', 'y', 'z'];
await repository.openPointInTimeForType(type, { namespaces });
expect(mockSecurityExt.authorizeOpenPointInTime).toHaveBeenCalledTimes(1);
Expand Down
3 changes: 2 additions & 1 deletion packages/kbn-generate-csv/src/lib/search_cursor_pit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { createSearchSourceMock } from '@kbn/data-plugin/common/search/search_so
import { createSearchRequestHandlerContext } from '@kbn/data-plugin/server/search/mocks';
import type { SearchCursorSettings } from './search_cursor';
import { SearchCursorPit } from './search_cursor_pit';
import { OpenPointInTimeResponse } from '@elastic/elasticsearch/lib/api/types';

class TestSearchCursorPit extends SearchCursorPit {
constructor(...args: ConstructorParameters<typeof SearchCursorPit>) {
Expand Down Expand Up @@ -69,7 +70,7 @@ describe('CSV Export Search Cursor', () => {

openPointInTimeSpy = jest
.spyOn(es.asCurrentUser, 'openPointInTime')
.mockResolvedValue({ id: 'somewhat-pit-id' });
.mockResolvedValue({ id: 'somewhat-pit-id' } as OpenPointInTimeResponse);

logger = loggingSystemMock.createLogger();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { createSearchSourceMock } from '@kbn/data-plugin/common/search/search_so
import { createSearchRequestHandlerContext } from '@kbn/data-plugin/server/search/mocks';
import type { SearchCursorSettings } from './search_cursor';
import { SearchCursorScroll } from './search_cursor_scroll';
import type { OpenPointInTimeResponse } from '@elastic/elasticsearch/lib/api/types';

class TestSearchCursorScroll extends SearchCursorScroll {
constructor(...args: ConstructorParameters<typeof SearchCursorScroll>) {
Expand Down Expand Up @@ -47,7 +48,9 @@ describe('CSV Export Search Cursor', () => {

es = elasticsearchServiceMock.createScopedClusterClient();
data = createSearchRequestHandlerContext();
jest.spyOn(es.asCurrentUser, 'openPointInTime').mockResolvedValue({ id: 'simply-scroll-id' });
jest
.spyOn(es.asCurrentUser, 'openPointInTime')
.mockResolvedValue({ id: 'simply-scroll-id' } as OpenPointInTimeResponse);

logger = loggingSystemMock.createLogger();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import type { IncomingHttpHeaders } from 'http';
import type { IScopedClusterClient, Logger } from '@kbn/core/server';
import { catchError, tap } from 'rxjs';
import type { DiagnosticResult } from '@elastic/transport';
import { SqlQueryResponse } from '@elastic/elasticsearch/lib/api/types';
import { SqlQueryResponse, type SqlQuerySqlFormat } from '@elastic/elasticsearch/lib/api/types';
import { getKbnServerError } from '@kbn/kibana-utils-plugin/server';
import { getKbnSearchError } from '../../report_search_error';
import type { ISearchStrategy, SearchStrategyDependencies } from '../../types';
Expand Down Expand Up @@ -61,9 +61,9 @@ export const sqlSearchStrategyProvider = (
} else {
({ headers, body, meta } = await client.sql.query(
{
format: params.format ?? 'json',
...getDefaultAsyncSubmitParams(searchConfig, options),
...params,
format: (params.format ?? 'json') as SqlQuerySqlFormat,
},
{ ...options.transport, signal: options.abortSignal, meta: true }
));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,8 @@ export const registerFieldPreviewRoute = ({ router }: RouteDependencies): void =
};

try {
// client types need to be update to support this request format
// client types need to be updated to support this request format
// when it does, supply response types
// @ts-expect-error
const { result } = await client.asCurrentUser.scriptsPainlessExecute(body);

return res.ok({ body: { values: result } });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ export async function getClusterStats(esClient: ElasticsearchClient) {
return await esClient.cluster.stats(
{
timeout: CLUSTER_STAT_TIMEOUT,

// @ts-expect-error
include_remotes: true,
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export interface AnalyticsManagementItems {
export interface TrainedModelsManagementItems {
id: string;
description: string;
state: estypes.MlDeploymentState | '';
state: estypes.MlDeploymentAssignmentState | '';
type: Array<string | undefined>;
spaces: string[];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -376,10 +376,10 @@ export abstract class InferenceBase<TInferResponse> {
};
}

// @ts-expect-error error does not exist in type
protected getDocFromResponse({ doc, error }: estypes.IngestSimulatePipelineSimulation) {
if (doc === undefined) {
if (error) {
// @ts-expect-error Error is now typed in estypes. However, I doubt that it doesn't get the HTTP wrapper expected.
this.setFinishedWithErrors(error);
throw Error(error.reason);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import * as t from 'io-ts';
import {
InferenceInferenceEndpointInfo,
MlDeploymentAllocationState,
MlDeploymentState,
MlDeploymentAssignmentState,
} from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
import moment from 'moment';
import { createObservabilityAIAssistantServerRoute } from '../create_observability_ai_assistant_server_route';
Expand All @@ -34,7 +34,7 @@ const getKnowledgeBaseStatus = createObservabilityAIAssistantServerRoute({
enabled: boolean;
endpoint?: Partial<InferenceInferenceEndpointInfo>;
model_stats?: {
deployment_state: MlDeploymentState | undefined;
deployment_state: MlDeploymentAssignmentState | undefined;
allocation_state: MlDeploymentAllocationState | undefined;
};
}> => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ const GetDataStreamResponse: IndicesGetDataStreamResponse = {
template: 'ignored',
next_generation_managed_by: 'Index Lifecycle Management',
prefer_ilm: false,
rollover_on_write: false,
},
],
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ const GetDataStreamResponse: IndicesGetDataStreamResponse = {
template: 'ignored',
next_generation_managed_by: 'Data stream lifecycle',
prefer_ilm: false,
rollover_on_write: false,
},
],
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -569,6 +569,7 @@ export const GetDataStreamsResponse: estypes.IndicesGetDataStreamResponse = {
template: '',
hidden: true,
prefer_ilm: false,
rollover_on_write: true,
next_generation_managed_by: 'Index Lifecycle Management',
},
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export interface DataStreamIndex {
name: string;
uuid: string;
preferILM: boolean;
managedBy: string;
managedBy?: string;
}

export interface DataRetention {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,28 +87,30 @@ export const isDataStreamFullyManagedByILM = (dataStream?: DataStream | null) =>
return (
dataStream?.nextGenerationManagedBy?.toLowerCase() === 'index lifecycle management' &&
dataStream?.indices?.every(
(index) => index.managedBy.toLowerCase() === 'index lifecycle management'
(index) => index.managedBy?.toLowerCase() === 'index lifecycle management'
)
);
};

export const isDataStreamFullyManagedByDSL = (dataStream?: DataStream | null) => {
return (
dataStream?.nextGenerationManagedBy?.toLowerCase() === 'data stream lifecycle' &&
dataStream?.indices?.every((index) => index.managedBy.toLowerCase() === 'data stream lifecycle')
dataStream?.indices?.every(
(index) => index.managedBy?.toLowerCase() === 'data stream lifecycle'
)
);
};

export const isDSLWithILMIndices = (dataStream?: DataStream | null) => {
if (dataStream?.nextGenerationManagedBy?.toLowerCase() === 'data stream lifecycle') {
const ilmIndices = dataStream?.indices?.filter(
(index) => index.managedBy.toLowerCase() === 'index lifecycle management'
(index) => index.managedBy?.toLowerCase() === 'index lifecycle management'
);
const dslIndices = dataStream?.indices?.filter(
(index) => index.managedBy.toLowerCase() === 'data stream lifecycle'
(index) => index.managedBy?.toLowerCase() === 'data stream lifecycle'
);

// When there arent any ILM indices, there's no need to show anything.
// When there aren't any ILM indices, there's no need to show anything.
if (!ilmIndices?.length) {
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ export function deserializeDataStream(dataStreamFromEs: EnhancedDataStreamFromEs
({
index_name: indexName,
index_uuid: indexUuid,
prefer_ilm: preferILM,
prefer_ilm: preferILM = false,
managed_by: managedBy,
}: {
index_name: string;
index_uuid: string;
prefer_ilm: boolean;
managed_by: string;
prefer_ilm?: boolean;
managed_by?: string;
}) => ({
name: indexName,
uuid: indexUuid,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ class DataStreamService {
try {
const { data_streams: dataStreamsInfo } = await esClient.indices.getDataStream({
name: datasetName,
// @ts-expect-error
verbose: true,
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import type { ElasticsearchClientMock } from '@kbn/core-elasticsearch-client-server-mocks';
import type { SearchResponse } from '@elastic/elasticsearch/lib/api/types';
import type { OpenPointInTimeResponse, SearchResponse } from '@elastic/elasticsearch/lib/api/types';
import { v4 as uuidV4 } from 'uuid';
import { BaseDataGenerator } from '../../../common/endpoint/data_generators/base_data_generator';

Expand Down Expand Up @@ -45,14 +45,14 @@ export const applyEsClientSearchMock = <TDocument = unknown>({
const pitResponse = { id: `mock:pit:${index}:${uuidV4()}` };
openedPitIds.add(pitResponse.id);

return pitResponse;
return pitResponse as OpenPointInTimeResponse;
}

if (priorOpenPointInTimeImplementation) {
return priorOpenPointInTimeImplementation(...args);
}

return { id: 'mock' };
return { id: 'mock' } as OpenPointInTimeResponse;
});

esClientMock.closePointInTime.mockImplementation(async (...args) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ export const applyIngestProcessorToDoc = async (

const firstDoc = res.docs?.[0];

// @ts-expect-error error is not in the types
const error = firstDoc?.error;
if (error) {
log.error('Full painless error below: ');
Expand Down
Loading

0 comments on commit f3f6b2c

Please sign in to comment.