mirror of
https://github.com/elastic/kibana.git
synced 2025-06-28 03:01:21 -04:00
## Summary We're breaking https://github.com/elastic/kibana/pull/166813 up into smaller PRs in the interest of getting PRs through sooner for type fixes. These are the changes for ML UI. --------- Co-authored-by: Dima Arnautov <dmitrii.arnautov@elastic.co>
This commit is contained in:
parent
d7e88167fa
commit
7d92c16ec0
2 changed files with 30 additions and 19 deletions
|
@ -9,30 +9,33 @@ import { sharePluginMock } from '@kbn/share-plugin/public/mocks';
|
||||||
import { type ElasticModels } from './application/services/elastic_models_service';
|
import { type ElasticModels } from './application/services/elastic_models_service';
|
||||||
import type { MlPluginSetup, MlPluginStart } from './plugin';
|
import type { MlPluginSetup, MlPluginStart } from './plugin';
|
||||||
|
|
||||||
|
const createElasticModelsMock = (): jest.Mocked<ElasticModels> => {
|
||||||
|
return {
|
||||||
|
getELSER: jest.fn().mockResolvedValue({
|
||||||
|
version: 2,
|
||||||
|
default: true,
|
||||||
|
config: {
|
||||||
|
input: {
|
||||||
|
field_names: ['text_field'],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
description: 'Elastic Learned Sparse EncodeR v2 (Tech Preview)',
|
||||||
|
name: '.elser_model_2',
|
||||||
|
}),
|
||||||
|
} as unknown as jest.Mocked<ElasticModels>;
|
||||||
|
};
|
||||||
|
|
||||||
const createSetupContract = (): jest.Mocked<MlPluginSetup> => {
|
const createSetupContract = (): jest.Mocked<MlPluginSetup> => {
|
||||||
return {
|
return {
|
||||||
locator: sharePluginMock.createLocator(),
|
locator: sharePluginMock.createLocator(),
|
||||||
|
elasticModels: createElasticModelsMock(),
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
const createStartContract = (): jest.Mocked<MlPluginStart> => {
|
const createStartContract = (): jest.Mocked<MlPluginStart> => {
|
||||||
return {
|
return {
|
||||||
locator: sharePluginMock.createLocator(),
|
locator: sharePluginMock.createLocator(),
|
||||||
elasticModels: {
|
elasticModels: createElasticModelsMock(),
|
||||||
getELSER: jest.fn(() =>
|
|
||||||
Promise.resolve({
|
|
||||||
version: 2,
|
|
||||||
default: true,
|
|
||||||
config: {
|
|
||||||
input: {
|
|
||||||
field_names: ['text_field'],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
description: 'Elastic Learned Sparse EncodeR v2 (Tech Preview)',
|
|
||||||
name: '.elser_model_2',
|
|
||||||
})
|
|
||||||
),
|
|
||||||
} as unknown as jest.Mocked<ElasticModels>,
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@ import { take } from 'rxjs/operators';
|
||||||
|
|
||||||
import type { UnifiedSearchPublicPluginStart } from '@kbn/unified-search-plugin/public';
|
import type { UnifiedSearchPublicPluginStart } from '@kbn/unified-search-plugin/public';
|
||||||
import type { ManagementSetup } from '@kbn/management-plugin/public';
|
import type { ManagementSetup } from '@kbn/management-plugin/public';
|
||||||
import type { SharePluginSetup, SharePluginStart } from '@kbn/share-plugin/public';
|
import type { LocatorPublic, SharePluginSetup, SharePluginStart } from '@kbn/share-plugin/public';
|
||||||
import type { DataPublicPluginStart } from '@kbn/data-plugin/public';
|
import type { DataPublicPluginStart } from '@kbn/data-plugin/public';
|
||||||
import type { HomePublicPluginSetup } from '@kbn/home-plugin/public';
|
import type { HomePublicPluginSetup } from '@kbn/home-plugin/public';
|
||||||
import type { EmbeddableSetup, EmbeddableStart } from '@kbn/embeddable-plugin/public';
|
import type { EmbeddableSetup, EmbeddableStart } from '@kbn/embeddable-plugin/public';
|
||||||
|
@ -54,7 +54,7 @@ import {
|
||||||
MlSharedServices,
|
MlSharedServices,
|
||||||
} from './application/services/get_shared_ml_services';
|
} from './application/services/get_shared_ml_services';
|
||||||
import { registerManagementSection } from './application/management';
|
import { registerManagementSection } from './application/management';
|
||||||
import { MlLocatorDefinition, type MlLocator } from './locator';
|
import { MlLocatorDefinition, MlLocatorParams, type MlLocator } from './locator';
|
||||||
import { setDependencyCache } from './application/util/dependency_cache';
|
import { setDependencyCache } from './application/util/dependency_cache';
|
||||||
import { registerHomeFeature } from './register_home_feature';
|
import { registerHomeFeature } from './register_home_feature';
|
||||||
import { isFullLicense, isMlEnabled } from '../common/license';
|
import { isFullLicense, isMlEnabled } from '../common/license';
|
||||||
|
@ -67,6 +67,7 @@ import {
|
||||||
type ConfigSchema,
|
type ConfigSchema,
|
||||||
} from '../common/constants/app';
|
} from '../common/constants/app';
|
||||||
import type { MlCapabilities } from './shared';
|
import type { MlCapabilities } from './shared';
|
||||||
|
import { ElasticModels } from './application/services/elastic_models_service';
|
||||||
|
|
||||||
export interface MlStartDependencies {
|
export interface MlStartDependencies {
|
||||||
dataViewEditor: DataViewEditorStart;
|
dataViewEditor: DataViewEditorStart;
|
||||||
|
@ -131,7 +132,10 @@ export class MlPlugin implements Plugin<MlPluginSetup, MlPluginStart> {
|
||||||
initEnabledFeatures(this.enabledFeatures, initializerContext.config.get());
|
initEnabledFeatures(this.enabledFeatures, initializerContext.config.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
setup(core: MlCoreSetup, pluginsSetup: MlSetupDependencies) {
|
setup(
|
||||||
|
core: MlCoreSetup,
|
||||||
|
pluginsSetup: MlSetupDependencies
|
||||||
|
): { locator?: LocatorPublic<MlLocatorParams>; elasticModels?: ElasticModels } {
|
||||||
this.sharedMlServices = getMlSharedServices(core.http);
|
this.sharedMlServices = getMlSharedServices(core.http);
|
||||||
|
|
||||||
core.application.register({
|
core.application.register({
|
||||||
|
@ -262,10 +266,14 @@ export class MlPlugin implements Plugin<MlPluginSetup, MlPluginStart> {
|
||||||
|
|
||||||
return {
|
return {
|
||||||
locator: this.locator,
|
locator: this.locator,
|
||||||
|
elasticModels: this.sharedMlServices.elasticModels,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
start(core: CoreStart, deps: MlStartDependencies) {
|
start(
|
||||||
|
core: CoreStart,
|
||||||
|
deps: MlStartDependencies
|
||||||
|
): { locator?: LocatorPublic<MlLocatorParams>; elasticModels?: ElasticModels } {
|
||||||
setDependencyCache({
|
setDependencyCache({
|
||||||
docLinks: core.docLinks!,
|
docLinks: core.docLinks!,
|
||||||
basePath: core.http.basePath,
|
basePath: core.http.basePath,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue