From adcb8d5927975c610923c0babe0864734afe277d Mon Sep 17 00:00:00 2001 From: Ignacio Rivas Date: Thu, 10 Aug 2023 12:57:59 +0300 Subject: [PATCH] Refactor types --- .../plugins/index_management/server/lib/enrich_policies.ts | 6 +++++- x-pack/plugins/index_management/server/plugin.ts | 6 +++--- .../routes/api/enrich_policies/register_list_route.ts | 4 ++-- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/x-pack/plugins/index_management/server/lib/enrich_policies.ts b/x-pack/plugins/index_management/server/lib/enrich_policies.ts index 4834d2932b5df..ca1748a380c70 100644 --- a/x-pack/plugins/index_management/server/lib/enrich_policies.ts +++ b/x-pack/plugins/index_management/server/lib/enrich_policies.ts @@ -41,8 +41,12 @@ export const serializeEnrichmentPolicies = ( }); }; -export const fetchAll = async (client: IScopedClusterClient) => { +const fetchAll = async (client: IScopedClusterClient) => { const res = await client.asCurrentUser.enrich.getPolicy(); return serializeEnrichmentPolicies(res.policies); }; + +export const enrichPoliciesActions = { + fetchAll, +}; diff --git a/x-pack/plugins/index_management/server/plugin.ts b/x-pack/plugins/index_management/server/plugin.ts index 14951ebc9e66d..bf542d61142a6 100644 --- a/x-pack/plugins/index_management/server/plugin.ts +++ b/x-pack/plugins/index_management/server/plugin.ts @@ -12,10 +12,10 @@ import { Dependencies } from './types'; import { ApiRoutes } from './routes'; import { IndexDataEnricher } from './services'; import { handleEsError } from './shared_imports'; -import * as enrichPoliciesApis from './lib/enrich_policies'; +import { enrichPoliciesActions } from './lib/enrich_policies'; export interface IndexManagementPluginSetup { - enrichPolicies: typeof enrichPoliciesApis; + enrichPoliciesActions: typeof enrichPoliciesActions; indexDataEnricher: { add: IndexDataEnricher['add']; }; @@ -61,7 +61,7 @@ export class IndexMgmtServerPlugin implements Plugin { const client = (await context.core).elasticsearch.client as IScopedClusterClient; try { - const policies = await enrichPolicies.fetchAll(client); + const policies = await enrichPoliciesActions.fetchAll(client); return response.ok({ body: policies }); } catch (error) { return handleEsError({ error, response });