mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
[ML] Consolidating shared types and util functions (#65247)
* [ML] Consolidating shared types and util functions * including formatter * adding missing includes * removing unused export * ignoring numeral type error Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
This commit is contained in:
parent
3604f5d21a
commit
55e4c7f9a7
24 changed files with 57 additions and 40 deletions
|
@ -9,8 +9,6 @@ import React from 'react';
|
|||
|
||||
import { EuiToolTip } from '@elastic/eui';
|
||||
|
||||
// don't use something like plugins/ml/../common
|
||||
// because it won't work with the jest tests
|
||||
import { getMLJobTypeAriaLabel } from '../../util/field_types_utils';
|
||||
import { ML_JOB_FIELD_TYPES } from '../../../../common/constants/field_types';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
|
|
|
@ -14,8 +14,6 @@ import PropTypes from 'prop-types';
|
|||
|
||||
import { EuiCallOut } from '@elastic/eui';
|
||||
|
||||
// don't use something like plugins/ml/../common
|
||||
// because it won't work with the jest tests
|
||||
import { MESSAGE_LEVEL } from '../../../../common/constants/message_levels';
|
||||
|
||||
function getCallOutAttributes(message, status) {
|
||||
|
|
|
@ -30,8 +30,6 @@ import { FormattedMessage } from '@kbn/i18n/react';
|
|||
|
||||
import { getDocLinks } from '../../util/dependency_cache';
|
||||
|
||||
// don't use something like plugins/ml/../common
|
||||
// because it won't work with the jest tests
|
||||
import { VALIDATION_STATUS } from '../../../../common/constants/validation';
|
||||
import { getMostSevereMessageStatus } from '../../../../common/util/validation_utils';
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
*/
|
||||
|
||||
import { isEqual } from 'lodash';
|
||||
// @ts-ignore
|
||||
import numeral from '@elastic/numeral';
|
||||
import { ml } from '../../../../services/ml_api_service';
|
||||
import { AnalysisResult, InputOverrides } from '../../../../../../common/types/file_datavisualizer';
|
||||
|
|
|
@ -17,8 +17,6 @@ import d3 from 'd3';
|
|||
import $ from 'jquery';
|
||||
import moment from 'moment';
|
||||
|
||||
// don't use something like plugins/ml/../common
|
||||
// because it won't work with the jest tests
|
||||
import { formatHumanReadableDateTime } from '../../util/date_utils';
|
||||
import { formatValue } from '../../formatters/format_value';
|
||||
import { getSeverityColor, getSeverityWithLow } from '../../../../common/util/anomaly_utils';
|
||||
|
|
|
@ -17,8 +17,6 @@ import d3 from 'd3';
|
|||
import $ from 'jquery';
|
||||
import moment from 'moment';
|
||||
|
||||
// don't use something like plugins/ml/../common
|
||||
// because it won't work with the jest tests
|
||||
import { formatHumanReadableDateTime } from '../../util/date_utils';
|
||||
import { formatValue } from '../../formatters/format_value';
|
||||
import {
|
||||
|
|
|
@ -14,8 +14,6 @@ import _ from 'lodash';
|
|||
import d3 from 'd3';
|
||||
import moment from 'moment';
|
||||
|
||||
// don't use something like plugins/ml/../common
|
||||
// because it won't work with the jest tests
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import { Subscription } from 'rxjs';
|
||||
import { TooltipValue } from '@elastic/charts';
|
||||
|
|
|
@ -15,8 +15,6 @@ import React, { Component } from 'react';
|
|||
|
||||
import { EuiButton, EuiToolTip } from '@elastic/eui';
|
||||
|
||||
// don't use something like plugins/ml/../common
|
||||
// because it won't work with the jest tests
|
||||
import { FORECAST_REQUEST_STATE, JOB_STATE } from '../../../../../common/constants/states';
|
||||
import { MESSAGE_LEVEL } from '../../../../../common/constants/message_levels';
|
||||
import { isJobVersionGte } from '../../../../../common/util/job_utils';
|
||||
|
|
|
@ -23,8 +23,6 @@ import {
|
|||
EuiToolTip,
|
||||
} from '@elastic/eui';
|
||||
|
||||
// don't use something like plugins/ml/../common
|
||||
// because it won't work with the jest tests
|
||||
import { JOB_STATE } from '../../../../../common/constants/states';
|
||||
import { FORECAST_DURATION_MAX_DAYS } from './forecasting_modal';
|
||||
import { ForecastProgress } from './forecast_progress';
|
||||
|
|
|
@ -13,7 +13,6 @@ import {
|
|||
MlSetupDependencies,
|
||||
MlStartDependencies,
|
||||
} from './plugin';
|
||||
import { getMetricChangeDescription } from './application/formatters/metric_change_description';
|
||||
|
||||
export const plugin: PluginInitializer<
|
||||
MlPluginSetup,
|
||||
|
@ -22,4 +21,5 @@ export const plugin: PluginInitializer<
|
|||
MlStartDependencies
|
||||
> = () => new MlPlugin();
|
||||
|
||||
export { MlPluginSetup, MlPluginStart, getMetricChangeDescription };
|
||||
export { MlPluginSetup, MlPluginStart };
|
||||
export * from './shared';
|
||||
|
|
22
x-pack/plugins/ml/public/shared.ts
Normal file
22
x-pack/plugins/ml/public/shared.ts
Normal 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;
|
||||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
|
||||
export * from '../common/constants/anomalies';
|
||||
|
||||
export * from '../common/types/data_recognizer';
|
||||
export * from '../common/types/capabilities';
|
||||
export * from '../common/types/anomalies';
|
||||
export * from '../common/types/modules';
|
||||
export * from '../common/types/audit_message';
|
||||
|
||||
export * from '../common/util/anomaly_utils';
|
||||
export * from '../common/util/errors';
|
||||
export * from '../common/util/validators';
|
||||
|
||||
export * from './application/formatters/metric_change_description';
|
||||
|
||||
export * from './application/components/data_grid';
|
||||
export * from './application/data_frame_analytics/common';
|
|
@ -7,5 +7,6 @@
|
|||
import { PluginInitializerContext } from 'kibana/server';
|
||||
import { MlServerPlugin } from './plugin';
|
||||
export { MlPluginSetup, MlPluginStart } from './plugin';
|
||||
export * from './shared';
|
||||
|
||||
export const plugin = (ctx: PluginInitializerContext) => new MlServerPlugin(ctx);
|
||||
|
|
7
x-pack/plugins/ml/server/shared.ts
Normal file
7
x-pack/plugins/ml/server/shared.ts
Normal file
|
@ -0,0 +1,7 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License;
|
||||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
|
||||
export * from '../common/types/anomalies';
|
|
@ -4,7 +4,7 @@
|
|||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
|
||||
import { AuditMessageBase } from '../../../../ml/common/types/audit_message';
|
||||
import { AuditMessageBase } from '../../../../ml/public';
|
||||
import { MlError } from '../ml/types';
|
||||
|
||||
export interface Group {
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
import { SearchResponse, SearchParams } from 'elasticsearch';
|
||||
|
||||
import { AnomalyRecordDoc as Anomaly } from '../../../../ml/common/types/anomalies';
|
||||
import { AnomalyRecordDoc as Anomaly } from '../../../../ml/server';
|
||||
|
||||
export { Anomaly };
|
||||
export type AnomalyResults = SearchResponse<Anomaly>;
|
||||
|
|
|
@ -14,8 +14,8 @@ export const useRequest = jest.fn(() => ({
|
|||
}));
|
||||
|
||||
// just passing through the reimports
|
||||
export { getErrorMessage } from '../../../ml/common/util/errors';
|
||||
export {
|
||||
getErrorMessage,
|
||||
getDataGridSchemaFromKibanaFieldType,
|
||||
getFieldsFromKibanaIndexPattern,
|
||||
multiColumnSortFactory,
|
||||
|
@ -27,5 +27,5 @@ export {
|
|||
SearchResponse7,
|
||||
UseDataGridReturnType,
|
||||
UseIndexDataReturnType,
|
||||
} from '../../../ml/public/application/components/data_grid';
|
||||
export { INDEX_STATUS } from '../../../ml/public/application/data_frame_analytics/common';
|
||||
INDEX_STATUS,
|
||||
} from '../../../ml/public';
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
|
||||
import { composeValidators, patternValidator } from '../../../../ml/common/util/validators';
|
||||
import { composeValidators, patternValidator } from '../../../../ml/public';
|
||||
|
||||
export type AggName = string;
|
||||
|
||||
|
|
|
@ -16,9 +16,8 @@ export {
|
|||
useRequest,
|
||||
} from '../../../../src/plugins/es_ui_shared/public/request/np_ready_request';
|
||||
|
||||
export { getErrorMessage } from '../../ml/common/util/errors';
|
||||
|
||||
export {
|
||||
getErrorMessage,
|
||||
getDataGridSchemaFromKibanaFieldType,
|
||||
getFieldsFromKibanaIndexPattern,
|
||||
multiColumnSortFactory,
|
||||
|
@ -30,5 +29,5 @@ export {
|
|||
SearchResponse7,
|
||||
UseDataGridReturnType,
|
||||
UseIndexDataReturnType,
|
||||
} from '../../ml/public/application/components/data_grid';
|
||||
export { INDEX_STATUS } from '../../ml/public/application/data_frame_analytics/common';
|
||||
INDEX_STATUS,
|
||||
} from '../../ml/public';
|
||||
|
|
|
@ -9,11 +9,11 @@ import moment from 'moment';
|
|||
import { AnnotationTooltipFormatter, RectAnnotation } from '@elastic/charts';
|
||||
import { RectAnnotationDatum } from '@elastic/charts/dist/chart_types/xy_chart/utils/specs';
|
||||
import { AnnotationTooltip } from './annotation_tooltip';
|
||||
import { ANOMALY_SEVERITY } from '../../../../../../plugins/ml/common/constants/anomalies';
|
||||
import {
|
||||
ANOMALY_SEVERITY,
|
||||
getSeverityColor,
|
||||
getSeverityType,
|
||||
} from '../../../../../../plugins/ml/common/util/anomaly_utils';
|
||||
} from '../../../../../../plugins/ml/public';
|
||||
|
||||
interface Props {
|
||||
anomalies: any;
|
||||
|
|
|
@ -20,7 +20,7 @@ import { getMLJobId } from '../../../state/api/ml_anomaly';
|
|||
import * as labels from './translations';
|
||||
import { useKibana } from '../../../../../../../src/plugins/kibana_react/public';
|
||||
import { ManageMLJobComponent } from './manage_ml_job';
|
||||
import { JobStat } from '../../../../../../plugins/ml/common/types/data_recognizer';
|
||||
import { JobStat } from '../../../../../../plugins/ml/public';
|
||||
import { useMonitorId } from '../../../hooks';
|
||||
|
||||
export const MLIntegrationComponent = () => {
|
||||
|
|
|
@ -20,7 +20,7 @@ import {
|
|||
} from '../../../state/selectors';
|
||||
import { UptimeRefreshContext } from '../../../contexts';
|
||||
import { getMLJobId } from '../../../state/api/ml_anomaly';
|
||||
import { JobStat } from '../../../../../ml/common/types/data_recognizer';
|
||||
import { JobStat } from '../../../../../ml/public';
|
||||
import { MonitorDurationComponent } from './monitor_duration';
|
||||
import { MonitorIdParam } from '../../../../common/types';
|
||||
|
||||
|
|
|
@ -6,15 +6,17 @@
|
|||
|
||||
import { createAction } from 'redux-actions';
|
||||
import { createAsyncAction } from './utils';
|
||||
import { MlCapabilitiesResponse } from '../../../../../plugins/ml/common/types/capabilities';
|
||||
import { AnomaliesTableRecord } from '../../../../../plugins/ml/common/types/anomalies';
|
||||
import {
|
||||
MlCapabilitiesResponse,
|
||||
AnomaliesTableRecord,
|
||||
JobExistResult,
|
||||
} from '../../../../../plugins/ml/public';
|
||||
import {
|
||||
CreateMLJobSuccess,
|
||||
DeleteJobResults,
|
||||
MonitorIdParam,
|
||||
HeartbeatIndicesParam,
|
||||
} from './types';
|
||||
import { JobExistResult } from '../../../../../plugins/ml/common/types/data_recognizer';
|
||||
|
||||
export const resetMLState = createAction('RESET_ML_STATE');
|
||||
|
||||
|
|
|
@ -8,15 +8,17 @@ import moment from 'moment';
|
|||
import { apiService } from './utils';
|
||||
import { AnomalyRecords, AnomalyRecordsParams } from '../actions';
|
||||
import { API_URLS, ML_JOB_ID, ML_MODULE_ID } from '../../../common/constants';
|
||||
import { MlCapabilitiesResponse } from '../../../../../plugins/ml/common/types/capabilities';
|
||||
import {
|
||||
MlCapabilitiesResponse,
|
||||
DataRecognizerConfigResponse,
|
||||
JobExistResult,
|
||||
} from '../../../../../plugins/ml/public';
|
||||
import {
|
||||
CreateMLJobSuccess,
|
||||
DeleteJobResults,
|
||||
MonitorIdParam,
|
||||
HeartbeatIndicesParam,
|
||||
} from '../actions/types';
|
||||
import { DataRecognizerConfigResponse } from '../../../../../plugins/ml/common/types/modules';
|
||||
import { JobExistResult } from '../../../../../plugins/ml/common/types/data_recognizer';
|
||||
|
||||
const getJobPrefix = (monitorId: string) => {
|
||||
// ML App doesn't support upper case characters in job name
|
||||
|
|
|
@ -16,9 +16,8 @@ import {
|
|||
} from '../actions';
|
||||
import { getAsyncInitialState, handleAsyncAction } from './utils';
|
||||
import { AsyncInitialState } from './types';
|
||||
import { MlCapabilitiesResponse } from '../../../../../plugins/ml/common/types/capabilities';
|
||||
import { MlCapabilitiesResponse, JobExistResult } from '../../../../../plugins/ml/public';
|
||||
import { CreateMLJobSuccess, DeleteJobResults } from '../actions/types';
|
||||
import { JobExistResult } from '../../../../../plugins/ml/common/types/data_recognizer';
|
||||
|
||||
export interface MLJobState {
|
||||
mlJob: AsyncInitialState<JobExistResult>;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue