Skip to content

Commit

Permalink
ts-ify module to avoid type error
Browse files Browse the repository at this point in the history
  • Loading branch information
spalger committed Jun 7, 2021
1 parent f8aa37d commit 1b7ed41
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,23 @@
* Side Public License, v 1.
*/

const ES_ARCHIVER_LOAD_METHODS = ['load', 'loadIfNeeded', 'unload', 'emptyKibanaIndex'];
import type { ProvidedType } from '@kbn/test';

import type { EsArchiverProvider } from '../es_archiver';
import type { RetryService } from '../retry';
import type { KibanaServerProvider } from './kibana_server';

const ES_ARCHIVER_LOAD_METHODS = ['load', 'loadIfNeeded', 'unload', 'emptyKibanaIndex'] as const;
const KIBANA_INDEX = '.kibana';

export function extendEsArchiver({ esArchiver, kibanaServer, retry, defaults }) {
interface Options {
esArchiver: ProvidedType<typeof EsArchiverProvider>;
kibanaServer: ProvidedType<typeof KibanaServerProvider>;
retry: RetryService;
defaults: Record<string, any>;
}

export function extendEsArchiver({ esArchiver, kibanaServer, retry, defaults }: Options) {
// only extend the esArchiver if there are default uiSettings to restore
if (!defaults) {
return;
Expand All @@ -18,9 +31,9 @@ export function extendEsArchiver({ esArchiver, kibanaServer, retry, defaults })
ES_ARCHIVER_LOAD_METHODS.forEach((method) => {
const originalMethod = esArchiver[method];

esArchiver[method] = async (...args) => {
esArchiver[method] = async (...args: unknown[]) => {
// esArchiver methods return a stats object, with information about the indexes created
const stats = await originalMethod.apply(esArchiver, args);
const stats = await originalMethod.apply(esArchiver, args as any);

const statsKeys = Object.keys(stats);
const kibanaKeys = statsKeys.filter(
Expand Down
1 change: 0 additions & 1 deletion test/common/services/kibana_server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,4 @@
*/

export { KibanaServerProvider } from './kibana_server';
// @ts-ignore
export { extendEsArchiver } from './extend_es_archiver';

0 comments on commit 1b7ed41

Please sign in to comment.