Skip to content

Commit

Permalink
Replace more legacy elasticsearch types
Browse files Browse the repository at this point in the history
  • Loading branch information
rylnd committed Aug 10, 2021
1 parent 4f7e62f commit f996e0b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* 2.0.
*/
import { useEffect, useState } from 'react';
import { SearchResponse } from 'elasticsearch';
import type { estypes } from '@elastic/elasticsearch';
import { isEmpty } from 'lodash';

import {
Expand Down Expand Up @@ -37,18 +37,18 @@ export const useFetchEcsAlertsData = ({
try {
setIsLoading(true);
const alertResponse = await KibanaServices.get().http.fetch<
SearchResponse<{ '@timestamp': string; [key: string]: unknown }>
estypes.SearchResponse<{ '@timestamp': string; [key: string]: unknown }>
>(DETECTION_ENGINE_QUERY_SIGNALS_URL, {
method: 'POST',
body: JSON.stringify(buildAlertsQuery(alertIds ?? [])),
});

setAlertEcsData(
alertResponse?.hits.hits.reduce<Ecs[]>(
(acc, { _id, _index, _source }) => [
(acc, { _id, _index, _source = {} }) => [
...acc,
{
...formatAlertToEcsSignal(_source as {}),
...formatAlertToEcsSignal(_source),
_id,
_index,
timestamp: _source['@timestamp'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
* 2.0.
*/

import { UpdateDocumentByQueryResponse } from 'elasticsearch';
import type { estypes } from '@elastic/elasticsearch';

import { useKibana } from '../../../../../src/plugins/kibana_react/public';
import { AlertStatus } from '../../../timelines/common';

Expand All @@ -24,7 +25,7 @@ export const useUpdateAlertsStatus = (): {
updateAlertStatus: (params: {
query: object;
status: AlertStatus;
}) => Promise<UpdateDocumentByQueryResponse>;
}) => Promise<estypes.UpdateByQueryResponse>;
} => {
const { http } = useKibana().services;

Expand Down

0 comments on commit f996e0b

Please sign in to comment.