Move shared index management types to package (#179932)

## Summary

This moves a number of types that are used outside of the index
management plugin to a package so we can avoid cyclical dependencies in
the work we're doing to add semantic text as a mapping type. That will
depend on the ML plugin, which has dependencies that themselves depend
on a few types from index management. I split this into a separate PR
for ease of reviewing.

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Stratoula Kalafateli <efstratia.kalafateli@elastic.co>
This commit is contained in:
Sander Philipse 2024-04-10 17:48:06 +02:00 committed by GitHub
parent 3744a30b32
commit 1fa7a69fb6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
56 changed files with 328 additions and 234 deletions

1
.github/CODEOWNERS vendored
View file

@ -478,6 +478,7 @@ src/plugins/image_embeddable @elastic/appex-sharedux
packages/kbn-import-locator @elastic/kibana-operations
packages/kbn-import-resolver @elastic/kibana-operations
x-pack/plugins/index_lifecycle_management @elastic/kibana-management
x-pack/packages/index-management @elastic/kibana-management
x-pack/plugins/index_management @elastic/kibana-management
test/plugin_functional/plugins/index_patterns @elastic/kibana-data-discovery
x-pack/packages/kbn-infra-forge @elastic/obs-ux-management-team

View file

@ -509,6 +509,7 @@
"@kbn/iframe-embedded-plugin": "link:x-pack/test/functional_embedded/plugins/iframe_embedded",
"@kbn/image-embeddable-plugin": "link:src/plugins/image_embeddable",
"@kbn/index-lifecycle-management-plugin": "link:x-pack/plugins/index_lifecycle_management",
"@kbn/index-management": "link:x-pack/packages/index-management",
"@kbn/index-management-plugin": "link:x-pack/plugins/index_management",
"@kbn/index-patterns-test-plugin": "link:test/plugin_functional/plugins/index_patterns",
"@kbn/infra-forge": "link:x-pack/packages/kbn-infra-forge",

View file

@ -22,7 +22,7 @@ import { getAggregateQueryMode, getLanguageDisplayName } from '@kbn/es-query';
import type { DataViewsPublicPluginStart } from '@kbn/data-views-plugin/public';
import type { ExpressionsStart } from '@kbn/expressions-plugin/public';
import type { CoreStart } from '@kbn/core/public';
import type { IndexManagementPluginSetup } from '@kbn/index-management-plugin/public';
import type { IndexManagementPluginSetup } from '@kbn/index-management';
import { TooltipWrapper } from '@kbn/visualization-utils';
import {
type LanguageDocumentationSections,

View file

@ -23,7 +23,7 @@
"@kbn/data-plugin",
"@kbn/expressions-plugin",
"@kbn/data-views-plugin",
"@kbn/index-management-plugin",
"@kbn/index-management",
"@kbn/visualization-utils",
"@kbn/code-editor",
"@kbn/shared-ux-markdown",

View file

@ -10,7 +10,7 @@ import { BehaviorSubject } from 'rxjs';
import type { CoreStart } from '@kbn/core/public';
import type { DataViewsPublicPluginStart } from '@kbn/data-views-plugin/public';
import type { ExpressionsStart } from '@kbn/expressions-plugin/public';
import { IndexManagementPluginSetup } from '@kbn/index-management-plugin/public';
import { IndexManagementPluginSetup } from '@kbn/index-management';
export let core: CoreStart;

View file

@ -9,7 +9,7 @@
import type { Plugin, CoreStart, CoreSetup } from '@kbn/core/public';
import type { DataViewsPublicPluginStart } from '@kbn/data-views-plugin/public';
import type { ExpressionsStart } from '@kbn/expressions-plugin/public';
import type { IndexManagementPluginSetup } from '@kbn/index-management-plugin/public';
import type { IndexManagementPluginSetup } from '@kbn/index-management';
import { setKibanaServices } from './kibana_services';
interface TextBasedLanguagesPluginStart {

View file

@ -15,10 +15,9 @@
"@kbn/core",
"@kbn/expressions-plugin",
"@kbn/data-views-plugin",
"@kbn/index-management-plugin",
"@kbn/index-management"
],
"exclude": [
"target/**/*",
]
}

View file

@ -950,6 +950,8 @@
"@kbn/import-resolver/*": ["packages/kbn-import-resolver/*"],
"@kbn/index-lifecycle-management-plugin": ["x-pack/plugins/index_lifecycle_management"],
"@kbn/index-lifecycle-management-plugin/*": ["x-pack/plugins/index_lifecycle_management/*"],
"@kbn/index-management": ["x-pack/packages/index-management"],
"@kbn/index-management/*": ["x-pack/packages/index-management/*"],
"@kbn/index-management-plugin": ["x-pack/plugins/index_management"],
"@kbn/index-management-plugin/*": ["x-pack/plugins/index_management/*"],
"@kbn/index-patterns-test-plugin": ["test/plugin_functional/plugins/index_patterns"],
@ -1814,7 +1816,9 @@
"@kbn/zod-helpers/*": ["packages/kbn-zod-helpers/*"],
// END AUTOMATED PACKAGE LISTING
// Allows for importing from `kibana` package for the exported types.
"@emotion/core": ["typings/@emotion"]
"@emotion/core": [
"typings/@emotion"
]
},
// Support .tsx files and transform JSX into calls to React.createElement
"jsx": "react",

View file

@ -48,6 +48,7 @@
],
"xpack.grokDebugger": "plugins/grokdebugger",
"xpack.idxMgmt": "plugins/index_management",
"xpack.idxMgmtPackage": "packages/index-management",
"xpack.indexLifecycleMgmt": "plugins/index_lifecycle_management",
"xpack.infra": "plugins/observability_solution/infra",
"xpack.logsExplorer": "plugins/observability_solution/logs_explorer",

View file

@ -0,0 +1,3 @@
# @kbn/index-management
Contains types and functions used and exported by the index management plugin. Primarily used to avoid cyclical dependencies.

View file

@ -0,0 +1,10 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
export * from './src/types';
export * from './src/home_sections';
export * from './src/services';

View file

@ -0,0 +1,12 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
module.exports = {
preset: '@kbn/test',
rootDir: '../../..',
roots: ['<rootDir>/x-pack/packages/index-management'],
};

View file

@ -0,0 +1,5 @@
{
"type": "shared-common",
"id": "@kbn/index-management",
"owner": "@elastic/kibana-management"
}

View file

@ -0,0 +1,6 @@
{
"name": "@kbn/index-management",
"private": true,
"version": "1.0.0",
"license": "Elastic License 2.0"
}

View file

@ -8,7 +8,7 @@
import { FunctionComponent, ReactNode } from 'react';
import { ApplicationStart } from '@kbn/core-application-browser';
import { EuiBreadcrumb } from '@elastic/eui';
import { Index } from '../types';
import { Index } from './types';
export enum Section {
Indices = 'indices',

View file

@ -0,0 +1,71 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
import { FunctionComponent, ReactNode } from 'react';
import { ApplicationStart } from '@kbn/core-application-browser';
import { EuiBadgeProps } from '@elastic/eui';
import { IndexDetailsTab } from '../home_sections';
import { Index } from '../types';
export interface IndexContent {
renderContent: (args: {
index: Index;
getUrlForApp: ApplicationStart['getUrlForApp'];
}) => ReturnType<FunctionComponent>;
}
export interface IndexToggle {
matchIndex: (index: Index) => boolean;
label: string;
name: string;
}
export interface IndexBadge {
matchIndex: (index: Index) => boolean;
label: string;
// a parseable search bar filter expression, for example "isFollowerIndex:true"
filterExpression?: string;
color: EuiBadgeProps['color'];
}
export interface EmptyListContent {
renderContent: (args: {
// the button to open the "create index" modal
createIndexButton: ReturnType<FunctionComponent>;
}) => ReturnType<FunctionComponent>;
}
export interface IndicesListColumn {
fieldName: string;
label: string;
order: number;
render?: (index: Index) => ReactNode;
// return a value used for sorting (only if the value is different from the original value at index[fieldName])
sort?: (index: Index) => any;
}
export interface ExtensionsSetup {
// adds an option to the "manage index" menu
addAction(action: any): void;
// adds a banner to the indices list
addBanner(banner: any): void;
// adds a filter to the indices list
addFilter(filter: any): void;
// adds a badge to the index name
addBadge(badge: IndexBadge): void;
// adds a toggle to the indices list
addToggle(toggle: IndexToggle): void;
// adds a column to display additional information added via a data enricher
addColumn(column: IndicesListColumn): void;
// set the content to render when the indices list is empty
setEmptyListContent(content: EmptyListContent): void;
// adds a tab to the index details page
addIndexDetailsTab(tab: IndexDetailsTab): void;
// sets content to render instead of the code block on the overview tab of the index page
setIndexOverviewContent(content: IndexContent): void;
// sets content to render below the docs link on the mappings tab of the index page
setIndexMappingsContent(content: IndexContent): void;
}

View file

@ -0,0 +1,8 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
export * from './extensions_service';
export * from './public_api_service';

View file

@ -0,0 +1,22 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
import type { EnrichPolicyType } from '@elastic/elasticsearch/lib/api/types';
import { SendRequestResponse } from '../types';
export interface SerializedEnrichPolicy {
type: EnrichPolicyType;
name: string;
sourceIndices: string[];
matchField: string;
enrichFields: string[];
query?: Record<string, any>;
}
export interface PublicApiServiceSetup {
getAllEnrichPolicies(): Promise<SendRequestResponse<SerializedEnrichPolicy[]>>;
}

View file

@ -0,0 +1,85 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
import {
IlmExplainLifecycleLifecycleExplain,
HealthStatus,
IndicesStatsIndexMetadataState,
Uuid,
} from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
import type { UsageCollectionSetup } from '@kbn/usage-collection-plugin/public';
import type { ManagementSetup } from '@kbn/management-plugin/public';
import type { SharePluginSetup, SharePluginStart } from '@kbn/share-plugin/public';
import type { CloudSetup } from '@kbn/cloud-plugin/public';
import type { ConsolePluginStart } from '@kbn/console-plugin/public';
import type { ScopedHistory } from '@kbn/core-application-browser';
import { ExtensionsSetup } from './services/extensions_service';
import { PublicApiServiceSetup } from './services/public_api_service';
export interface IndexManagementPluginSetup {
apiService: PublicApiServiceSetup;
extensionsService: ExtensionsSetup;
}
export interface IndexManagementPluginStart {
extensionsService: ExtensionsSetup;
getIndexMappingComponent: (deps: {
history: ScopedHistory<unknown>;
}) => React.FC<IndexMappingProps>;
}
export interface SetupDependencies {
fleet?: unknown;
usageCollection: UsageCollectionSetup;
management: ManagementSetup;
share: SharePluginSetup;
cloud?: CloudSetup;
}
export interface StartDependencies {
cloud?: CloudSetup;
console?: ConsolePluginStart;
share: SharePluginStart;
fleet?: unknown;
usageCollection: UsageCollectionSetup;
management: ManagementSetup;
}
export interface Index {
name: string;
primary?: number | string;
replica?: number | string;
isFrozen: boolean;
hidden: boolean;
aliases: string | string[];
data_stream?: string;
// The types below are added by extension services if corresponding plugins are enabled (ILM, Rollup, CCR)
isRollupIndex?: boolean;
ilm?: IlmExplainLifecycleLifecycleExplain;
isFollowerIndex?: boolean;
// The types from here below represent information returned from the index stats API;
// treated optional as the stats API is not available on serverless
health?: HealthStatus;
status?: IndicesStatsIndexMetadataState;
uuid?: Uuid;
documents?: number;
size?: string;
primary_size?: string;
documents_deleted?: number;
}
export interface IndexMappingProps {
index?: Index;
showAboutMappings?: boolean;
}
export interface SendRequestResponse<D = any, E = any> {
data: D | null;
error: E | null;
}

View file

@ -0,0 +1,26 @@
{
"extends": "../../../tsconfig.base.json",
"compilerOptions": {
"outDir": "target/types",
"types": [
"jest",
"node",
"react"
]
},
"include": [
"**/*.ts",
"**/*.tsx",
],
"exclude": [
"target/**/*"
],
"kbn_references": [
"@kbn/core-application-browser",
"@kbn/usage-collection-plugin",
"@kbn/management-plugin",
"@kbn/share-plugin",
"@kbn/cloud-plugin",
"@kbn/console-plugin",
]
}

View file

@ -15,7 +15,7 @@ import type { AppMockRenderer } from '../../common/mock';
import { createAppMockRenderer } from '../../common/mock';
import { MAX_DESCRIPTION_LENGTH } from '../../../common/constants';
import { FormTestComponent } from '../../common/test_utils';
import type { FormSchema } from '@kbn/index-management-plugin/public/shared_imports';
import type { FormSchema } from '@kbn/es-ui-shared-plugin/static/forms/hook_form_lib';
describe('Description', () => {
let appMockRender: AppMockRenderer;

View file

@ -11,12 +11,10 @@
],
"kbn_references": [
"@kbn/core",
// optionalPlugins from ./kibana.json
"@kbn/lens-plugin",
"@kbn/security-plugin",
"@kbn/spaces-plugin",
// Required from './kibana.json'
"@kbn/actions-plugin",
"@kbn/rule-registry-plugin",
@ -68,7 +66,6 @@
"@kbn/core-http-server",
"@kbn/alerting-plugin",
"@kbn/content-management-plugin",
"@kbn/index-management-plugin",
"@kbn/rison",
"@kbn/core-application-browser",
"@kbn/react-kibana-context-render",

View file

@ -22,7 +22,7 @@ import {
import { DataPublicPluginStart } from '@kbn/data-plugin/public';
import { GuidedOnboardingPluginStart } from '@kbn/guided-onboarding-plugin/public';
import { IndexMappingProps } from '@kbn/index-management-plugin/public';
import { IndexMappingProps } from '@kbn/index-management';
import { LensPublicStart } from '@kbn/lens-plugin/public';
import { MlPluginStart } from '@kbn/ml-plugin/public';
import { ELASTICSEARCH_URL_PLACEHOLDER } from '@kbn/search-api-panels/constants';

View file

@ -25,7 +25,7 @@ import { DataPublicPluginStart } from '@kbn/data-plugin/public';
import { GuidedOnboardingPluginStart } from '@kbn/guided-onboarding-plugin/public';
import type { HomePublicPluginSetup } from '@kbn/home-plugin/public';
import { i18n } from '@kbn/i18n';
import { IndexManagementPluginStart } from '@kbn/index-management-plugin/public';
import type { IndexManagementPluginStart } from '@kbn/index-management';
import { LensPublicStart } from '@kbn/lens-plugin/public';
import { LicensingPluginStart } from '@kbn/licensing-plugin/public';
import { MlPluginStart } from '@kbn/ml-plugin/public';

View file

@ -72,7 +72,7 @@
"@kbn/search-connectors-plugin",
"@kbn/search-playground",
"@kbn/utility-types",
"@kbn/index-management-plugin",
"@kbn/index-management",
"@kbn/deeplinks-search"
]
}

View file

@ -26,8 +26,7 @@ import {
import { euiThemeVars } from '@kbn/ui-theme';
import { ApplicationStart } from '@kbn/core/public';
import { Index } from '@kbn/index-management-plugin/common';
import { IndexDetailsTab } from '@kbn/index-management-plugin/common/constants';
import { Index, IndexDetailsTab } from '@kbn/index-management';
import { IlmExplainLifecycleLifecycleExplainManaged } from '@elastic/elasticsearch/lib/api/types';
import { Phase } from '../../../common/types';
import { getPolicyEditPath } from '../../application/services/navigation';

View file

@ -36,7 +36,8 @@
"@kbn/config-schema",
"@kbn/shared-ux-router",
"@kbn/ui-theme",
"@kbn/shared-ux-link-redirect-app"
"@kbn/shared-ux-link-redirect-app",
"@kbn/index-management"
],
"exclude": [
"target/**/*",

View file

@ -52,6 +52,6 @@ export {
export { MAJOR_VERSION } from './plugin';
export { Section, IndexDetailsSection } from './home_sections';
export type { IndexDetailsTab, IndexDetailsTabId } from './home_sections';
export { Section, IndexDetailsSection } from '@kbn/index-management';
export type { IndexDetailsTab, IndexDetailsTabId } from '@kbn/index-management';
export * from './allow_auto_create';

View file

@ -6,7 +6,7 @@
*/
import type { EnrichSummary, EnrichPolicyType } from '@elastic/elasticsearch/lib/api/types';
import type { SerializedEnrichPolicy } from '../types';
import type { SerializedEnrichPolicy } from '@kbn/index-management';
export const getPolicyType = (policy: EnrichSummary): EnrichPolicyType => {
if (policy.config.match) {

View file

@ -5,17 +5,6 @@
* 2.0.
*/
import type { EnrichPolicyType } from '@elastic/elasticsearch/lib/api/types';
export interface SerializedEnrichPolicy {
type: EnrichPolicyType;
name: string;
sourceIndices: string[];
matchField: string;
enrichFields: string[];
query?: Record<string, any>;
}
export interface FieldItem {
name: string;
type: string;

View file

@ -5,12 +5,7 @@
* 2.0.
*/
import {
HealthStatus,
IlmExplainLifecycleLifecycleExplain,
IndicesStatsIndexMetadataState,
Uuid,
} from '@elastic/elasticsearch/lib/api/types';
export type { Index } from '@kbn/index-management';
interface IndexModule {
number_of_shards: number | string;
@ -58,31 +53,6 @@ export interface IndexSettings {
[key: string]: any;
}
export interface Index {
name: string;
primary?: number | string;
replica?: number | string;
isFrozen: boolean;
hidden: boolean;
aliases: string | string[];
data_stream?: string;
// The types below are added by extension services if corresponding plugins are enabled (ILM, Rollup, CCR)
isRollupIndex?: boolean;
ilm?: IlmExplainLifecycleLifecycleExplain;
isFollowerIndex?: boolean;
// The types from here below represent information returned from the index stats API;
// treated optional as the stats API is not available on serverless
health?: HealthStatus;
status?: IndicesStatsIndexMetadataState;
uuid?: Uuid;
documents?: number;
size?: string;
primary_size?: string;
documents_deleted?: number;
}
export interface IndexSettingsResponse {
settings: IndexSettings;
defaults: IndexSettings;

View file

@ -8,8 +8,8 @@
import React from 'react';
import { EuiButton, EuiEmptyPrompt } from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n-react';
import { ExtensionsService } from '../../../services';
import { CreateIndexButton } from '../../sections/home/index_list/create_index/create_index_button';
import { ExtensionsService } from '../../../services/extensions_service';
export const NoMatch = ({
loadIndices,

View file

@ -13,10 +13,9 @@ import { UsageCollectionSetup } from '@kbn/usage-collection-plugin/public';
import { CloudSetup } from '@kbn/cloud-plugin/public';
import { Observable } from 'rxjs';
import { StartDependencies } from '@kbn/index-management';
import { UIM_APP_NAME } from '../../common/constants';
import { PLUGIN } from '../../common/constants/plugin';
import { ExtensionsService } from '../services';
import { StartDependencies } from '../types';
import { AppDependencies } from './app_context';
import { breadcrumbService } from './services/breadcrumbs';
import { documentationService } from './services/documentation';
@ -26,6 +25,7 @@ import { renderApp } from '.';
import { setUiMetricService } from './services/api';
import { notificationService } from './services/notification';
import { httpService } from './services/http';
import { ExtensionsService } from '../services/extensions_service';
function initSetup({
usageCollection,

View file

@ -6,7 +6,7 @@
*/
import React, { createContext, useContext, useState } from 'react';
import type { SerializedEnrichPolicy } from '../../../../common';
import type { SerializedEnrichPolicy } from '@kbn/index-management';
export type DraftPolicy = Partial<SerializedEnrichPolicy>;

View file

@ -9,12 +9,12 @@ import React, { useState, useMemo, useCallback } from 'react';
import { i18n } from '@kbn/i18n';
import { EuiSteps, EuiStepStatus, EuiCallOut, EuiSpacer } from '@elastic/eui';
import type { SerializedEnrichPolicy } from '@kbn/index-management';
import { useAppContext } from '../../app_context';
import { ConfigurationStep, FieldSelectionStep, CreateStep } from './steps';
import { useCreatePolicyContext } from './create_policy_context';
import { createEnrichPolicy } from '../../services/api';
import type { Error } from '../../../shared_imports';
import type { SerializedEnrichPolicy } from '../../../../common';
const CONFIGURATION = 1;
const FIELD_SELECTION = 2;

View file

@ -21,7 +21,7 @@ import {
EuiCodeBlock,
} from '@elastic/eui';
import type { SerializedEnrichPolicy } from '../../../../../common';
import type { SerializedEnrichPolicy } from '@kbn/index-management';
import { useCreatePolicyContext } from '../create_policy_context';
import { serializeAsESPolicy, getESPolicyCreationApiCall } from '../../../../../common/lib';

View file

@ -21,7 +21,7 @@ import {
EuiButtonEmpty,
} from '@elastic/eui';
import { CodeEditor } from '@kbn/code-editor';
import type { SerializedEnrichPolicy } from '../../../../../../common';
import type { SerializedEnrichPolicy } from '@kbn/index-management';
export interface Props {
policy: SerializedEnrichPolicy;

View file

@ -12,8 +12,8 @@ import { RouteComponentProps } from 'react-router-dom';
import { Location } from 'history';
import { parse } from 'query-string';
import type { SerializedEnrichPolicy } from '@kbn/index-management';
import { APP_WRAPPER_CLASS, useExecutionContext } from '../../../../shared_imports';
import type { SerializedEnrichPolicy } from '../../../../../common';
import { useAppContext } from '../../../app_context';
import { useRedirectPath } from '../../../hooks/redirect_path';

View file

@ -16,8 +16,8 @@ import {
import { i18n } from '@kbn/i18n';
import { FormattedMessage } from '@kbn/i18n-react';
import { reactRouterNavigate } from '@kbn/kibana-react-plugin/public';
import type { SerializedEnrichPolicy } from '@kbn/index-management';
import { useAppContext } from '../../../../app_context';
import type { SerializedEnrichPolicy } from '../../../../../../common/types';
export interface Props {
policies: SerializedEnrichPolicy[];

View file

@ -6,35 +6,9 @@
*/
import { CoreStart } from '@kbn/core/public';
import { ExtensionsService } from '../../../../../services';
import { IndexMappingProps } from '@kbn/index-management';
import { AppDependencies } from '../../../../app_context';
// duplicating this Index interface here so we don't blow up the bundle by importing all the types
interface Index {
name: string;
primary?: number | string;
replica?: number | string;
isFrozen: boolean;
hidden: boolean;
aliases: string | string[];
data_stream?: string;
// The types below are added by extension services if corresponding plugins are enabled (ILM, Rollup, CCR)
isRollupIndex?: boolean;
isFollowerIndex?: boolean;
// The types from here below represent information returned from the index stats API;
// treated optional as the stats API is not available on serverless
documents?: number;
size?: string;
primary_size?: string;
documents_deleted?: number;
}
export interface IndexMappingProps {
index?: Index;
showAboutMappings?: boolean;
}
import { ExtensionsService } from '../../../../../services/extensions_service';
export type IndexMappingWithContextProps = {
core: CoreStart;

View file

@ -7,6 +7,7 @@
import { METRIC_TYPE } from '@kbn/analytics';
import { IndicesStatsResponse } from '@elastic/elasticsearch/lib/api/types';
import type { SerializedEnrichPolicy } from '@kbn/index-management';
import {
API_BASE_PATH,
INTERNAL_API_BASE_PATH,
@ -44,7 +45,7 @@ import {
import { useRequest, sendRequest } from './use_request';
import { httpService } from './http';
import { UiMetricService } from './ui_metric';
import type { SerializedEnrichPolicy, FieldFromIndicesRequest } from '../../../common';
import type { FieldFromIndicesRequest } from '../../../common';
import { Fields } from '../components/mappings_editor/types';
interface ReloadIndicesOptions {

View file

@ -14,10 +14,11 @@ export const plugin = (ctx: PluginInitializerContext) => {
return new IndexMgmtUIPlugin(ctx);
};
export type { IndexManagementPluginSetup, IndexManagementPluginStart } from './types';
export type {
Index,
IndexMappingProps,
IndexManagementPluginSetup,
IndexManagementPluginStart,
} from '@kbn/index-management';
export { getIndexListUri, getTemplateDetailsLink } from './application/services/routing';
export type { Index } from '../common';
export type { IndexMappingProps } from './application/sections/home/index_list/details_page/index_mapping_with_context_types';

View file

@ -15,21 +15,21 @@ import {
PluginInitializerContext,
ScopedHistory,
} from '@kbn/core/public';
import { setExtensionsService } from './application/store/selectors/extension_service';
import { ExtensionsService, PublicApiService } from './services';
import {
IndexManagementPluginSetup,
SetupDependencies,
StartDependencies,
ClientConfigType,
IndexManagementPluginStart,
} from './types';
} from '@kbn/index-management';
import { setExtensionsService } from './application/store/selectors/extension_service';
import { ExtensionsService } from './services/extensions_service';
import { ClientConfigType } from './types';
// avoid import from index files in plugin.ts, use specific import paths
import { PLUGIN } from '../common/constants/plugin';
import { IndexMapping } from './application/sections/home/index_list/details_page/index_mappings_embeddable';
import { PublicApiService } from './services/public_api_service';
export class IndexMgmtUIPlugin
implements

View file

@ -6,7 +6,8 @@
*/
import type { PublicMethodsOf } from '@kbn/utility-types';
import { ExtensionsService, ExtensionsSetup } from './extensions_service';
import { ExtensionsSetup } from '@kbn/index-management/src/services/extensions_service';
import { ExtensionsService } from './extensions_service';
export type ExtensionsSetupMock = jest.Mocked<ExtensionsSetup>;

View file

@ -6,70 +6,15 @@
*/
import { i18n } from '@kbn/i18n';
import { FunctionComponent, ReactNode } from 'react';
import { ApplicationStart } from '@kbn/core-application-browser';
import { EuiBadgeProps } from '@elastic/eui';
import type { IndexDetailsTab } from '../../common/constants';
import { Index } from '..';
export interface IndexContent {
renderContent: (args: {
index: Index;
getUrlForApp: ApplicationStart['getUrlForApp'];
}) => ReturnType<FunctionComponent>;
}
export interface IndexToggle {
matchIndex: (index: Index) => boolean;
label: string;
name: string;
}
export interface IndexBadge {
matchIndex: (index: Index) => boolean;
label: string;
// a parseable search bar filter expression, for example "isFollowerIndex:true"
filterExpression?: string;
color: EuiBadgeProps['color'];
}
export interface EmptyListContent {
renderContent: (args: {
// the button to open the "create index" modal
createIndexButton: ReturnType<FunctionComponent>;
}) => ReturnType<FunctionComponent>;
}
export interface IndicesListColumn {
fieldName: string;
label: string;
order: number;
render?: (index: Index) => ReactNode;
// return a value used for sorting (only if the value is different from the original value at index[fieldName])
sort?: (index: Index) => any;
}
export interface ExtensionsSetup {
// adds an option to the "manage index" menu
addAction(action: any): void;
// adds a banner to the indices list
addBanner(banner: any): void;
// adds a filter to the indices list
addFilter(filter: any): void;
// adds a badge to the index name
addBadge(badge: IndexBadge): void;
// adds a toggle to the indices list
addToggle(toggle: IndexToggle): void;
// adds a column to display additional information added via a data enricher
addColumn(column: IndicesListColumn): void;
// set the content to render when the indices list is empty
setEmptyListContent(content: EmptyListContent): void;
// adds a tab to the index details page
addIndexDetailsTab(tab: IndexDetailsTab): void;
// sets content to render instead of the code block on the overview tab of the index page
setIndexOverviewContent(content: IndexContent): void;
// sets content to render below the docs link on the mappings tab of the index page
setIndexMappingsContent(content: IndexContent): void;
}
import {
IndexBadge,
IndexToggle,
IndicesListColumn,
EmptyListContent,
IndexContent,
ExtensionsSetup,
} from '@kbn/index-management';
import { IndexDetailsTab } from '../../common/constants';
export class ExtensionsService {
private _actions: any[] = [];

View file

@ -5,8 +5,6 @@
* 2.0.
*/
export type { ExtensionsSetup, IndexContent } from './extensions_service';
export { ExtensionsService } from './extensions_service';
export type { PublicApiServiceSetup } from './public_api_service';
export { PublicApiService } from './public_api_service';

View file

@ -5,7 +5,7 @@
* 2.0.
*/
import { PublicApiServiceSetup } from './public_api_service';
import { PublicApiServiceSetup } from '@kbn/index-management/src/services/public_api_service';
export type PublicApiServiceSetupMock = jest.Mocked<PublicApiServiceSetup>;

View file

@ -5,14 +5,9 @@
* 2.0.
*/
import { HttpSetup } from '@kbn/core/public';
import { sendRequest, SendRequestResponse } from '../shared_imports';
import { INTERNAL_API_BASE_PATH } from '../../common/constants';
import { SerializedEnrichPolicy } from '../../common/types';
export interface PublicApiServiceSetup {
getAllEnrichPolicies(): Promise<SendRequestResponse<SerializedEnrichPolicy[]>>;
}
import { HttpSetup } from '@kbn/core-http-browser';
import { INTERNAL_API_BASE_PATH } from '../../common';
import { sendRequest } from '../shared_imports';
/**
* Index Management public API service

View file

@ -5,44 +5,6 @@
* 2.0.
*/
import { UsageCollectionSetup } from '@kbn/usage-collection-plugin/public';
import { ManagementSetup } from '@kbn/management-plugin/public';
import { SharePluginSetup, SharePluginStart } from '@kbn/share-plugin/public';
import { CloudSetup } from '@kbn/cloud-plugin/public';
import { ConsolePluginStart } from '@kbn/console-plugin/public';
import { ScopedHistory } from '@kbn/core-application-browser';
import { IndexMappingProps } from './application/sections/home/index_list/details_page/index_mapping_with_context_types';
import { ExtensionsSetup, PublicApiServiceSetup } from './services';
export interface IndexManagementPluginSetup {
apiService: PublicApiServiceSetup;
extensionsService: ExtensionsSetup;
}
export interface IndexManagementPluginStart {
extensionsService: ExtensionsSetup;
getIndexMappingComponent: (deps: {
history: ScopedHistory<unknown>;
}) => React.FC<IndexMappingProps>;
}
export interface SetupDependencies {
fleet?: unknown;
usageCollection: UsageCollectionSetup;
management: ManagementSetup;
share: SharePluginSetup;
cloud?: CloudSetup;
}
export interface StartDependencies {
cloud?: CloudSetup;
console?: ConsolePluginStart;
share: SharePluginStart;
fleet?: unknown;
usageCollection: UsageCollectionSetup;
management: ManagementSetup;
}
export interface ClientConfigType {
ui: {
enabled: boolean;

View file

@ -7,7 +7,7 @@
import { IScopedClusterClient } from '@kbn/core/server';
import type { EnrichSummary } from '@elastic/elasticsearch/lib/api/types';
import type { SerializedEnrichPolicy } from '../../common/types';
import type { SerializedEnrichPolicy } from '@kbn/index-management';
import { getPolicyType } from '../../common/lib';
export const serializeEnrichmentPolicies = (

View file

@ -8,12 +8,12 @@
import { IScopedClusterClient } from '@kbn/core/server';
import { schema, TypeOf } from '@kbn/config-schema';
import type { SerializedEnrichPolicy } from '@kbn/index-management';
import { RouteDependencies } from '../../../types';
import { addInternalBasePath } from '..';
import { enrichPoliciesActions } from '../../../lib/enrich_policies';
import { serializeAsESPolicy } from '../../../../common/lib';
import { normalizeFieldsList, getIndices, FieldCapsList, getCommonFields } from './helpers';
import type { SerializedEnrichPolicy } from '../../../../common';
const validationSchema = schema.object({
policy: schema.object({

View file

@ -26,7 +26,6 @@
"@kbn/i18n",
"@kbn/ml-trained-models-utils",
"@kbn/analytics",
"@kbn/utility-types",
"@kbn/i18n-react",
"@kbn/core-doc-links-browser-mocks",
"@kbn/core-execution-context-browser-mocks",
@ -42,11 +41,14 @@
"@kbn/search-api-panels",
"@kbn/cloud-plugin",
"@kbn/ui-theme",
"@kbn/core-application-browser",
"@kbn/code-editor",
"@kbn/monaco",
"@kbn/console-plugin",
"@kbn/shared-ux-utility"
"@kbn/shared-ux-utility",
"@kbn/index-management",
"@kbn/utility-types"
],
"exclude": ["target/**/*"]
"exclude": [
"target/**/*"
]
}

View file

@ -18,7 +18,7 @@ import {
} from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n-react';
import { CoreStart } from '@kbn/core/public';
import { IndexContent } from '@kbn/index-management-plugin/public/services';
import { IndexContent } from '@kbn/index-management';
const IndexMappingsDocsLink: FunctionComponent<{ docLinks: CoreStart['docLinks'] }> = ({
docLinks,

View file

@ -12,7 +12,7 @@ import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
import { ReactQueryDevtools } from '@tanstack/react-query-devtools';
import { EuiLoadingSpinner } from '@elastic/eui';
import { IndexContent } from '@kbn/index-management-plugin/public/services';
import { IndexContent } from '@kbn/index-management';
import { ServerlessSearchPluginStartDependencies } from '../../../types';

View file

@ -46,5 +46,6 @@
"@kbn/core-logging-server-mocks",
"@kbn/discover-plugin",
"@kbn/search-connectors-plugin",
"@kbn/index-management",
]
}

View file

@ -4956,6 +4956,10 @@
version "0.0.0"
uid ""
"@kbn/index-management@link:x-pack/packages/index-management":
version "0.0.0"
uid ""
"@kbn/index-patterns-test-plugin@link:test/plugin_functional/plugins/index_patterns":
version "0.0.0"
uid ""