Cleanup outdated @elastic/elasticsearch client type errors (#101741)

* fix errors and update comments in Core

* fix errors or update comments in Security plugin

* update spaces test

* update task_manager files

* update comments in monitoring plugin

* fix errors in update comments in security_solutions

* fix errors and update comments in data_enhanced

* update fleet code

* update infra code

* update comment in trigger_actions_ui

* update comment in lens

* update comments in ES-UI code

* update typings for search

* update monitoring

* remove outdated export
This commit is contained in:
Mikhail Shustov 2021-06-21 16:03:00 +02:00 committed by GitHub
parent 307a5b2e93
commit f3ec948bee
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
45 changed files with 90 additions and 96 deletions

View file

@ -126,14 +126,12 @@ export class CoreUsageDataService implements CoreService<CoreUsageDataSetup, Cor
const stats = body[0];
return {
alias: kibanaOrTaskManagerIndex(index, this.kibanaConfig!.index),
// @ts-expect-error @elastic/elasticsearch declares it 'docs.count' as optional
docsCount: parseInt(stats['docs.count'], 10),
// @ts-expect-error @elastic/elasticsearch declares it 'docs.deleted' as optional
docsDeleted: parseInt(stats['docs.deleted'], 10),
// @ts-expect-error @elastic/elasticsearch declares it 'store.size' as string | number
storeSizeBytes: parseInt(stats['store.size'], 10),
// @ts-expect-error @elastic/elasticsearch declares it 'pri.store.size' as string | number
primaryStoreSizeBytes: parseInt(stats['pri.store.size'], 10),
docsCount: stats['docs.count'] ? parseInt(stats['docs.count'], 10) : 0,
docsDeleted: stats['docs.deleted'] ? parseInt(stats['docs.deleted'], 10) : 0,
storeSizeBytes: stats['store.size'] ? parseInt(stats['store.size'], 10) : 0,
primaryStoreSizeBytes: stats['pri.store.size']
? parseInt(stats['pri.store.size'], 10)
: 0,
};
});
})

View file

@ -187,12 +187,8 @@ async function migrateSourceToDest(context: Context) {
await Index.write(
client,
dest.indexName,
await migrateRawDocs(
serializer,
documentMigrator.migrateAndConvert,
// @ts-expect-error @elastic/elasticsearch `Hit._id` may be a string | number in ES, but we always expect strings in the SO index.
docs
)
// @ts-expect-error @elastic/elasticsearch _source is optional
await migrateRawDocs(serializer, documentMigrator.migrateAndConvert, docs)
);
}
}

View file

@ -897,10 +897,10 @@ export class SavedObjectsRepository {
total: body.hits.total,
saved_objects: body.hits.hits.map(
(hit: estypes.SearchHit<SavedObjectsRawDocSource>): SavedObjectsFindResult => ({
// @ts-expect-error @elastic/elasticsearch declared Id as string | number
// @ts-expect-error @elastic/elasticsearch _source is optional
...this._rawToSavedObject(hit),
score: hit._score!,
// @ts-expect-error @elastic/elasticsearch declared sort as string | number
// @ts-expect-error @elastic/elasticsearch _source is optional
sort: hit.sort,
})
),

View file

@ -417,7 +417,9 @@ export type AggregateOf<
{
key: string;
from?: number;
from_as_string?: string;
to?: number;
to_as_string?: string;
doc_count: number;
},
TAggregationContainer extends { range: { ranges: Array<infer TRangeType> } }

View file

@ -26,6 +26,6 @@ export async function getSavedObjectsCounts(
},
};
const { body } = await esClient.search(savedObjectCountSearchParams);
// @ts-expect-error @elastic/elasticsearch Aggregate does not include `buckets`
// @ts-expect-error declare type for aggregations explicitly
return body.aggregations?.types?.buckets || [];
}

View file

@ -27,20 +27,19 @@ describe('checkClusterForUserData', () => {
it('returns false if data only exists in system indices', async () => {
const esClient = elasticsearchServiceMock.createElasticsearchClient();
esClient.cat.indices.mockResolvedValue(
// @ts-expect-error @elastic/elasticsearch ES types don't support array response format
elasticsearchServiceMock.createApiResponse({
body: [
{
index: '.kibana',
'docs.count': 500,
'docs.count': '500',
},
{
index: 'kibana_sample_ecommerce_data',
'docs.count': 20,
'docs.count': '20',
},
{
index: '.somethingElse',
'docs.count': 20,
'docs.count': '20',
},
],
})
@ -56,16 +55,15 @@ describe('checkClusterForUserData', () => {
it('returns true if data exists in non-system indices', async () => {
const esClient = elasticsearchServiceMock.createElasticsearchClient();
esClient.cat.indices.mockResolvedValue(
// @ts-expect-error @elastic/elasticsearch ES types don't support array response format
elasticsearchServiceMock.createApiResponse({
body: [
{
index: '.kibana',
'docs.count': 500,
'docs.count': '500',
},
{
index: 'some_real_index',
'docs.count': 20,
'docs.count': '20',
},
],
})
@ -87,23 +85,21 @@ describe('checkClusterForUserData', () => {
)
.mockRejectedValueOnce(new Error('something terrible happened'))
.mockResolvedValueOnce(
// @ts-expect-error @elastic/elasticsearch ES types don't support array response format
elasticsearchServiceMock.createApiResponse({
body: [
{
index: '.kibana',
'docs.count': 500,
'docs.count': '500',
},
],
})
)
.mockResolvedValueOnce(
// @ts-expect-error @elastic/elasticsearch ES types don't support array response format
elasticsearchServiceMock.createApiResponse({
body: [
{
index: 'some_real_index',
'docs.count': 20,
'docs.count': '20',
},
],
})

View file

@ -4,7 +4,7 @@
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
import type { estypes } from '@elastic/elasticsearch';
import { Observable } from 'rxjs';
import { first } from 'rxjs/operators';
import { SearchResponse } from 'elasticsearch';
@ -36,8 +36,12 @@ export function fetchProvider(config$: Observable<SharedGlobalConfig>, logger: L
},
});
// @ts-expect-error @elastic/elasticsearch no way to declare a type for aggregations
const buckets: SessionPersistedTermsBucket[] = esResponse.aggregations!.persisted.buckets;
const aggs = esResponse.aggregations as Record<
string,
estypes.AggregationsMultiBucketAggregate<SessionPersistedTermsBucket>
>;
const buckets = aggs.persisted.buckets;
if (!buckets.length) {
return { transientCount: 0, persistedCount: 0, totalCount: 0 };
}

View file

@ -18,7 +18,7 @@ export async function getSearchStatus(
): Promise<Pick<SearchSessionRequestInfo, 'status' | 'error'>> {
// TODO: Handle strategies other than the default one
try {
// @ts-expect-error @elastic/elasticsearch status method is not defined
// @ts-expect-error start_time_in_millis: EpochMillis is string | number
const apiResponse: ApiResponse<AsyncSearchStatusResponse> = await client.asyncSearch.status({
id: asyncId,
});

View file

@ -4,7 +4,7 @@
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
import type { estypes } from '@elastic/elasticsearch';
import { keyBy, keys, merge } from 'lodash';
import type { RequestHandler, SavedObjectsBulkGetObject } from 'src/core/server';
@ -140,10 +140,7 @@ export const getListHandler: RequestHandler = async (context, request, response)
// Query backing indices to extract data stream dataset, namespace, and type values
const {
body: {
// @ts-expect-error @elastic/elasticsearch aggregations are not typed
aggregations: { dataset, namespace, type },
},
body: { aggregations: dataStreamAggs },
} = await esClient.search({
index: dataStream.indices.map((index) => index.index_name),
body: {
@ -187,6 +184,11 @@ export const getListHandler: RequestHandler = async (context, request, response)
},
});
const { dataset, namespace, type } = dataStreamAggs as Record<
string,
estypes.AggregationsMultiBucketAggregate<{ key?: string }>
>;
// Set values from backing indices query
dataStreamResponse.dataset = dataset.buckets[0]?.key || '';
dataStreamResponse.namespace = namespace.buckets[0]?.key || '';

View file

@ -47,7 +47,7 @@ export async function listEnrollmentApiKeys(
body: query ? { query } : undefined,
});
// @ts-expect-error @elastic/elasticsearch
// @ts-expect-error @elastic/elasticsearch _source is optional
const items = res.body.hits.hits.map(esDocToEnrollmentApiKey);
return {

View file

@ -123,7 +123,7 @@ const getData = async (
const client = async <Hit = {}, Aggregation = undefined>(
options: CallWithRequestParams
): Promise<InfraDatabaseSearchResponse<Hit, Aggregation>> =>
// @ts-expect-error @elastic/elasticsearch SearchResponse.body.timeout is not required
// @ts-expect-error SearchResponse.body.timeout is optional
(await esClient.search(options)).body as InfraDatabaseSearchResponse<Hit, Aggregation>;
const metrics = [

View file

@ -84,7 +84,7 @@ export const logEntrySearchStrategyProvider = ({
tiebreakerField,
runtimeMappings,
}): IEsSearchRequest => ({
// @ts-expect-error @elastic/elasticsearch declares indices_boost as Record<string, number>
// @ts-expect-error `Field` is not assignable to `SearchRequest.docvalue_fields`
params: createGetLogEntryQuery(
indices,
params.logEntryId,

View file

@ -75,7 +75,7 @@ export async function getVisualizationCounts(
},
});
// @ts-expect-error @elastic/elasticsearch no way to declare aggregations for search response
// @ts-expect-error specify aggregations type explicitly
const buckets = results.aggregations.groups.buckets;
// eslint-disable-next-line @typescript-eslint/no-explicit-any

View file

@ -95,7 +95,7 @@ export async function fetchCCRReadExceptions(
const { body: response } = await esClient.search(params);
const stats: CCRReadExceptionsStats[] = [];
// @ts-expect-error @elastic/elasticsearch Aggregate does not specify buckets
// @ts-expect-error declare aggegations type explicitly
const { buckets: remoteClusterBuckets = [] } = response.aggregations?.remote_clusters;
if (!remoteClusterBuckets?.length) {

View file

@ -25,7 +25,7 @@ describe('fetchCpuUsageNodeStats', () => {
it('fetch normal stats', async () => {
esClient.search.mockReturnValue(
// @ts-expect-error @elastic/elasticsearch Aggregate only allows unknown values
// @ts-expect-error not full response interface
elasticsearchClientMock.createSuccessTransportRequestPromise({
aggregations: {
clusters: {
@ -79,7 +79,7 @@ describe('fetchCpuUsageNodeStats', () => {
it('fetch container stats', async () => {
esClient.search.mockReturnValue(
// @ts-expect-error @elastic/elasticsearch Aggregate only allows unknown values
// @ts-expect-error not full response interface
elasticsearchClientMock.createSuccessTransportRequestPromise({
aggregations: {
clusters: {
@ -146,7 +146,7 @@ describe('fetchCpuUsageNodeStats', () => {
it('fetch properly return ccs', async () => {
esClient.search.mockReturnValue(
// @ts-expect-error @elastic/elasticsearch Aggregate only allows unknown values
// @ts-expect-error not full response interface
elasticsearchClientMock.createSuccessTransportRequestPromise({
aggregations: {
clusters: {

View file

@ -25,7 +25,7 @@ describe('fetchDiskUsageNodeStats', () => {
it('fetch normal stats', async () => {
esClient.search.mockReturnValue(
// @ts-expect-error @elastic/elasticsearch Aggregate only allows unknown values
// @ts-expect-error not full response interface
elasticsearchClientMock.createSuccessTransportRequestPromise({
aggregations: {
clusters: {

View file

@ -101,7 +101,7 @@ export async function fetchDiskUsageNodeStats(
const { body: response } = await esClient.search(params);
const stats: AlertDiskUsageNodeStats[] = [];
// @ts-expect-error @elastic/elasticsearch Aggregate does not define buckets
// @ts-expect-error declare type for aggregations explicitly
const { buckets: clusterBuckets } = response.aggregations?.clusters;
if (!clusterBuckets?.length) {

View file

@ -105,7 +105,7 @@ export async function fetchIndexShardSize(
};
const { body: response } = await esClient.search(params);
// @ts-expect-error @elastic/elasticsearch Aggregate does not specify buckets
// @ts-expect-error declare aggegations type explicitly
const { buckets: clusterBuckets } = response.aggregations?.clusters;
const stats: IndexShardSizeStats[] = [];
if (!clusterBuckets?.length) {

View file

@ -23,7 +23,7 @@ describe('fetchKibanaVersions', () => {
it('fetch as expected', async () => {
esClient.search.mockReturnValue(
// @ts-expect-error @elastic/elasticsearch Aggregate only allows unknown values
// @ts-expect-error not full response interface
elasticsearchClientMock.createSuccessTransportRequestPromise({
aggregations: {
index: {

View file

@ -23,7 +23,7 @@ describe('fetchLogstashVersions', () => {
it('fetch as expected', async () => {
esClient.search.mockReturnValue(
// @ts-expect-error @elastic/elasticsearch Aggregate only allows unknown values
// @ts-expect-error not full response interface
elasticsearchClientMock.createSuccessTransportRequestPromise({
aggregations: {
index: {

View file

@ -94,7 +94,7 @@ export async function fetchMemoryUsageNodeStats(
const { body: response } = await esClient.search(params);
const stats: AlertMemoryUsageNodeStats[] = [];
// @ts-expect-error @elastic/elasticsearch Aggregate does not define buckets
// @ts-expect-error declare type for aggregations explicitly
const { buckets: clusterBuckets } = response.aggregations?.clusters;
if (!clusterBuckets?.length) {

View file

@ -56,7 +56,7 @@ describe('fetchMissingMonitoringData', () => {
];
esClient.search.mockReturnValue(
// @ts-expect-error @elastic/elasticsearch Aggregate only allows unknown values
// @ts-expect-error not full response interface
elasticsearchClientMock.createSuccessTransportRequestPromise({
aggregations: {
clusters: {
@ -115,7 +115,7 @@ describe('fetchMissingMonitoringData', () => {
},
];
esClient.search.mockReturnValue(
// @ts-expect-error @elastic/elasticsearch Aggregate only allows unknown values
// @ts-expect-error not full response interface
elasticsearchClientMock.createSuccessTransportRequestPromise({
aggregations: {
clusters: {

View file

@ -90,7 +90,7 @@ export async function fetchNodesFromClusterStats(
const { body: response } = await esClient.search(params);
const nodes: AlertClusterStatsNodes[] = [];
// @ts-expect-error @elastic/elasticsearch Aggregate does not define buckets
// @ts-expect-error declare type for aggregations explicitly
const clusterBuckets = response.aggregations?.clusters?.buckets;
if (!clusterBuckets?.length) {
return nodes;

View file

@ -96,7 +96,7 @@ export async function fetchThreadPoolRejectionStats(
const { body: response } = await esClient.search(params);
const stats: AlertThreadPoolRejectionsStats[] = [];
// @ts-expect-error @elastic/elasticsearch Aggregate does not specify buckets
// @ts-expect-error declare type for aggregations explicitly
const { buckets: clusterBuckets } = response.aggregations?.clusters;
if (!clusterBuckets?.length) {

View file

@ -7,8 +7,8 @@
export interface User {
username: string;
email: string;
full_name: string;
email?: string;
full_name?: string;
roles: readonly string[];
enabled: boolean;
metadata?: {

View file

@ -41,8 +41,8 @@ export const THROTTLE_USERS_WAIT = 10000;
export interface UserFormValues {
username?: string;
full_name: string;
email: string;
full_name?: string;
email?: string;
password?: string;
confirm_password?: string;
roles: readonly string[];

View file

@ -224,7 +224,7 @@ export class APIKeys {
try {
result = (
await this.clusterClient.asInternalUser.security.grantApiKey({
// @ts-expect-error @elastic/elasticsearch api_key.role_descriptors
// @ts-expect-error @elastic/elasticsearch api_key.role_descriptors doesn't support `Record<string, any>`
body: params,
})
).body;

View file

@ -117,7 +117,7 @@ export abstract class BaseAuthenticationProvider {
*/
protected async getUser(request: KibanaRequest, authHeaders: Headers = {}) {
return this.authenticationInfoToAuthenticatedUser(
// @ts-expect-error @elastic/elasticsearch `AuthenticateResponse` type doesn't define `authentication_type` and `enabled`.
// @ts-expect-error Metadata is defined as Record<string, any>
(
await this.options.client
.asScoped({ headers: { ...request.headers, ...authHeaders } })

View file

@ -84,7 +84,7 @@ export class TokenAuthenticationProvider extends BaseAuthenticationProvider {
this.logger.debug('Get token API request to Elasticsearch successful');
return AuthenticationResult.succeeded(
this.authenticationInfoToAuthenticatedUser(
// @ts-expect-error @elastic/elasticsearch GetUserAccessTokenResponse declares authentication: string, but expected AuthenticatedUser
// @ts-expect-error @elastic/elasticsearch metadata defined as Record<string, any>;
authenticationInfo as AuthenticationInfo
),
{

View file

@ -73,7 +73,7 @@ export class Tokens {
return {
accessToken,
refreshToken,
// @ts-expect-error @elastic/elasticsearch declared GetUserAccessTokenResponse.authentication: string
// @ts-expect-error @elastic/elasticsearch user metadata defined as Record<string, any>
authenticationInfo: authenticationInfo as AuthenticationInfo,
};
} catch (err) {

View file

@ -32,7 +32,7 @@ export function defineGetRolesRoutes({ router, authz }: RouteDefinitionParams) {
if (elasticsearchRole) {
return response.ok({
body: transformElasticsearchRoleToRole(
// @ts-expect-error @elastic/elasticsearch `XPackRole` type doesn't define `applications` and `transient_metadata`.
// @ts-expect-error `SecurityIndicesPrivileges.names` expected to be `string[]`
elasticsearchRole,
request.params.name,
authz.applicationName

View file

@ -27,7 +27,7 @@ export function defineGetAllRolesRoutes({ router, authz }: RouteDefinitionParams
body: Object.entries(elasticsearchRoles)
.map(([roleName, elasticsearchRole]) =>
transformElasticsearchRoleToRole(
// @ts-expect-error @elastic/elasticsearch `XPackRole` type doesn't define `applications` and `transient_metadata`.
// @ts-expect-error @elastic/elasticsearch SecurityIndicesPrivileges.names expected to be string[]
elasticsearchRole,
roleName,
authz.applicationName

View file

@ -36,7 +36,7 @@ export function defineRoleMappingGetRoutes(params: RouteDefinitionParams) {
return {
name,
...mapping,
// @ts-expect-error @elastic/elasticsearch `XPackRoleMapping` type doesn't define `role_templates` property.
// @ts-expect-error @elastic/elasticsearch `SecurityRoleMapping` doeesn't contain `role_templates`
role_templates: (mapping.role_templates || []).map((entry: RoleTemplate) => {
return {
...entry,

View file

@ -128,7 +128,7 @@ export class StatsQuery {
index: this.indexPatterns,
});
// @ts-expect-error @elastic/elasticsearch no way to declare a type for aggregation in the search response
// @ts-expect-error declare aggegations type explicitly
return response.body.aggregations?.ids?.buckets.reduce(
(cummulative: Record<string, number>, bucket: CategoriesAgg) => ({
...cummulative,

View file

@ -72,9 +72,8 @@ export const getSignalVersionsByIndex = async ({
},
});
// @ts-expect-error @elastic/elasticsearch no way to declare a type for aggregation in the search response
const body = response.body as SignalVersionsAggResponse;
const indexBuckets = body.aggregations.signals_indices.buckets;
const aggs = response.body.aggregations as SignalVersionsAggResponse['aggregations'];
const indexBuckets = aggs.signals_indices.buckets;
return index.reduce<SignalVersionsByIndex>((agg, _index) => {
const bucket = indexBuckets.find((ib) => ib.key === _index);

View file

@ -72,7 +72,6 @@ export const getSignalsIndicesInRange = async ({
},
});
// @ts-expect-error @elastic/elasticsearch no way to declare a type for aggregation in the search response
const body = response.body as IndexesResponse;
return body.aggregations.indexes.buckets.map((bucket) => bucket.key);
const aggs = response.body.aggregations as IndexesResponse['aggregations'];
return aggs.indexes.buckets.map((bucket) => bucket.key);
};

View file

@ -4,7 +4,6 @@
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
import { get } from 'lodash/fp';
import set from 'set-value';
import {

View file

@ -24,7 +24,7 @@ export const hostOverview: SecuritySolutionFactory<HostsQueries.overview> = {
options: HostOverviewRequestOptions,
response: IEsSearchResponse<OverviewHostHit>
): Promise<HostsOverviewStrategyResponse> => {
// @ts-expect-error @elastic/elasticsearch no way to declare type for aggregations
// @ts-expect-error specify aggregations type explicitly
const aggregations: OverviewHostHit = get('aggregations', response.rawResponse) || {};
const inspect = {
dsl: [inspectStringifyObject(buildOverviewHostQuery(options))],

View file

@ -24,7 +24,7 @@ export const networkOverview: SecuritySolutionFactory<NetworkQueries.overview> =
options: NetworkOverviewRequestOptions,
response: IEsSearchResponse<OverviewNetworkHit>
): Promise<NetworkOverviewStrategyResponse> => {
// @ts-expect-error @elastic/elasticsearch no way to declare type for aggregations
// @ts-expect-error specify aggregations type explicitly
const aggregations: OverviewNetworkHit = get('aggregations', response.rawResponse) || {};
const inspect = {
dsl: [inspectStringifyObject(buildOverviewNetworkQuery(options))],

View file

@ -73,12 +73,10 @@ export function registerSnapshotsRoutes({
ignore_unavailable: true, // Allow request to succeed even if some snapshots are unavailable.
});
const { responses: fetchedResponses } = response.body;
const { responses: fetchedResponses = [] } = response.body;
// Decorate each snapshot with the repository with which it's associated.
// @ts-expect-error @elastic/elasticsearch related to above incorrect type from client
fetchedResponses.forEach(({ snapshots: fetchedSnapshots }) => {
// @ts-expect-error @elastic/elasticsearch related to above incorrect type from client
fetchedResponses.forEach(({ snapshots: fetchedSnapshots = [] }) => {
fetchedSnapshots.forEach((snapshot) => {
snapshots.push(
deserializeSnapshotDetails(

View file

@ -788,11 +788,11 @@ describe('padBuckets', () => {
padBuckets(10, 3000, {
key: '2020-10-02T19:47:28.128Z-2020-10-02T19:48:28.128Z',
from: 1601668048128,
// @ts-expect-error @elastic/elasticsearch doesn't decalre from_as_string property
from_as_string: '2020-10-02T19:47:28.128Z',
to: 1601668108128,
to_as_string: '2020-10-02T19:48:28.128Z',
doc_count: 0,
// @ts-expect-error result type doesn't define histogram
histogram: {
buckets: [],
},
@ -805,11 +805,11 @@ describe('padBuckets', () => {
padBuckets(10, 3000, {
key: '2020-10-02T19:47:28.128Z-2020-10-02T19:48:28.128Z',
from: 1601668046000,
// @ts-expect-error @elastic/elasticsearch doesn't decalre from_as_string property
from_as_string: '2020-10-02T19:47:26.000Z',
to: 1601668076000,
to_as_string: '2020-10-02T19:47:56.000Z',
doc_count: 3,
// @ts-expect-error result type doesn't define histogram
histogram: {
buckets: [
{
@ -883,11 +883,11 @@ describe('padBuckets', () => {
padBuckets(10, 3000, {
key: '2020-10-02T20:39:45.793Z-2020-10-02T20:40:14.793Z',
from: 1601671183000,
// @ts-expect-error @elastic/elasticsearch doesn't decalre from_as_string property
from_as_string: '2020-10-02T20:39:43.000Z',
to: 1601671213000,
to_as_string: '2020-10-02T20:40:13.000Z',
doc_count: 2,
// @ts-expect-error result type doesn't define histogram
histogram: {
buckets: [
{
@ -913,11 +913,11 @@ describe('padBuckets', () => {
padBuckets(20, 3000, {
key: '2020-10-02T20:39:45.793Z-2020-10-02T20:40:14.793Z',
from: 1601671185793,
// @ts-expect-error @elastic/elasticsearch doesn't decalre from_as_string property
from_as_string: '2020-10-02T20:39:45.793Z',
to: 1601671245793,
to_as_string: '2020-10-02T20:40:45.793Z',
doc_count: 2,
// @ts-expect-error result type doesn't define histogram
histogram: {
buckets: [
{
@ -943,11 +943,11 @@ describe('padBuckets', () => {
padBuckets(20, 3000, {
key: '2021-02-02T10:08:32.161Z-2021-02-02T10:09:32.161Z',
from: 1612260512161,
// @ts-expect-error @elastic/elasticsearch doesn't decalre from_as_string property
from_as_string: '2021-02-02T10:08:32.161Z',
to: 1612260572161,
to_as_string: '2021-02-02T10:09:32.161Z',
doc_count: 2,
// @ts-expect-error result type doesn't define histogram
histogram: {
buckets: [
{

View file

@ -319,9 +319,9 @@ export class TaskStore {
return {
docs: tasks
// @ts-expect-error @elastic/elasticsearch `Hid._id` expected to be `string`
// @ts-expect-error @elastic/elasticsearch _source is optional
.filter((doc) => this.serializer.isRawSavedObject(doc))
// @ts-expect-error @elastic/elasticsearch `Hid._id` expected to be `string`
// @ts-expect-error @elastic/elasticsearch _source is optional
.map((doc) => this.serializer.rawToSavedObject(doc))
.map((doc) => omit(doc, 'namespace') as SavedObject<SerializedConcreteTaskInstance>)
.map(savedObjectToConcreteTaskInstance),
@ -379,10 +379,8 @@ export class TaskStore {
);
return {
// @ts-expect-error @elastic/elasticsearch declares UpdateByQueryResponse.total as optional
total,
// @ts-expect-error @elastic/elasticsearch declares UpdateByQueryResponse.total as optional
updated,
total: total || 0,
updated: updated || 0,
version_conflicts: conflictsCorrectedForContinuation,
};
} catch (e) {

View file

@ -208,7 +208,7 @@ export function registerTransformsRoutes(routeDependencies: RouteDependencies) {
await ctx.core.elasticsearch.client.asCurrentUser.transform
.putTransform({
// @ts-expect-error @elastic/elasticsearch max_page_search_size is required in TransformPivot
// @ts-expect-error @elastic/elasticsearch group_by is expected to be optional in TransformPivot
body: req.body,
transform_id: transformId,
})

View file

@ -165,7 +165,7 @@ export function getResultFromEs(
delete aggregations.dateAgg;
}
// @ts-expect-error @elastic/elasticsearch Aggregate does not specify buckets
// @ts-expect-error specify aggregations type explicitly
const groupBuckets = aggregations.groupAgg?.buckets || [];
const result: TimeSeriesResult = {
results: [],

View file

@ -4,7 +4,7 @@
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
import type { estypes } from '@elastic/elasticsearch';
import expect from '@kbn/expect';
import { SuperTest } from 'supertest';
import { EsArchiver } from '@kbn/es-archiver';
@ -93,9 +93,12 @@ export function copyToSpaceTestSuiteFactory(
},
});
const aggs = response.aggregations as Record<
string,
estypes.AggregationsMultiBucketAggregate<SpaceBucket>
>;
return {
// @ts-expect-error @elastic/elasticsearch doesn't defined `count.buckets`.
buckets: response.aggregations?.count.buckets as SpaceBucket[],
buckets: aggs.count.buckets,
};
};