Skip to content

Commit

Permalink
Fixing types
Browse files Browse the repository at this point in the history
  • Loading branch information
ymao1 committed Jul 20, 2022
1 parent 83e971e commit 003afab
Showing 1 changed file with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,16 @@ import { ElasticsearchClient } from '@kbn/core/server';
import { Logger } from '@kbn/core/server';
import { IndexPatternsFetcher } from '@kbn/data-plugin/server';

import { ESSearchRequest, ESSearchResponse } from '@kbn/core/types/elasticsearch';
import {
RuleDataWriteDisabledError,
RuleDataWriterInitializationError,
} from '../rule_data_plugin_service/errors';
import { IndexInfo } from '../rule_data_plugin_service/index_info';
import { IResourceInstaller } from '../rule_data_plugin_service/resource_installer';
import { IRuleDataClient, IRuleDataReader, IRuleDataWriter } from './types';
import { ParsedTechnicalFields } from '../../common/parse_technical_fields';
import { ParsedExperimentalFields } from '../../common/parse_experimental_fields';

export interface RuleDataClientConstructorOptions {
indexInfo: IndexInfo;
Expand Down Expand Up @@ -103,13 +106,20 @@ export class RuleDataClient implements IRuleDataClient {
};

return {
search: async (request) => {
search: async <TSearchRequest extends ESSearchRequest>(
request: TSearchRequest
): Promise<
ESSearchResponse<Partial<ParsedTechnicalFields & ParsedExperimentalFields>, TSearchRequest>
> => {
try {
const clusterClient = await waitUntilReady();
return await clusterClient.search({
return (await clusterClient.search({
...request,
index: indexPattern,
});
})) as unknown as ESSearchResponse<
Partial<ParsedTechnicalFields & ParsedExperimentalFields>,
TSearchRequest
>;
} catch (err) {
this.options.logger.error(`Error performing search in RuleDataClient - ${err.message}`);
throw err;
Expand Down

0 comments on commit 003afab

Please sign in to comment.