[8.x] [ML] Move FieldStatsFlyout, parseInterval, validators to packages. (#193657) (#193859)

# Backport

This will backport the following commits from `main` to `8.x`:
- [[ML] Move FieldStatsFlyout, parseInterval, validators to packages.
(#193657)](https://github.com/elastic/kibana/pull/193657)

<!--- Backport version: 8.9.8 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Walter
Rafelsberger","email":"walter.rafelsberger@elastic.co"},"sourceCommit":{"committedDate":"2024-09-24T12:00:55Z","message":"[ML]
Move FieldStatsFlyout, parseInterval, validators to packages.
(#193657)\n\n## Summary\r\n\r\nPart of #159917.\r\n\r\nMoves code from
`plugins/ml/common|public` to packages that is used by\r\ntransforms
too.\r\n\r\nWhile the transforms plugin is maintained by the ML team
too, the\r\ntransform plugin itself is independently available from the
ML UI in the\r\nKibana management section. We should try to avoid that
the transform\r\nplugin is directly depending on the `ml` plugin. This
PR moves some code\r\nfrom `plugins/ml/common|public` to packages so
that we can remove `ml`\r\nfrom the list of `requiredBundles` of the
`transform` plugin.\r\n\r\nThe packages were created with these
commands:\r\n\r\n```\r\nnode scripts/generate package
@kbn/ml-field-stats-flyout --dir
./x-pack/packages/ml/field_stats_flyout\r\nnode scripts/generate package
@kbn/ml-parse-interval --dir ./x-pack/packages/ml/parse_interval\r\nnode
scripts/generate package @kbn/ml-validators --dir
./x-pack/packages/ml/validators\r\n```\r\n\r\nThe following commands
were used to check missing jsdoc comments
and\r\nexports:\r\n\r\n```\r\nnode scripts/build_api_docs --plugin
@kbn/ml-field-stats-flyout --stats comments\r\nnode
scripts/build_api_docs --plugin @kbn/ml-field-stats-flyout --stats
exports\r\nnode scripts/build_api_docs --plugin @kbn/ml-parse-interval
--stats comments\r\nnode scripts/build_api_docs --plugin
@kbn/ml-parse-interval --stats exports\r\nnode scripts/build_api_docs
--plugin @kbn/ml-validators --stats comments\r\nnode
scripts/build_api_docs --plugin @kbn/ml-validators --stats
exports\r\n```\r\n\r\n### Checklist\r\n\r\n- [x] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common scenarios\r\n- [ ] [Flaky
Test\r\nRunner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1)
was\r\nused on any tests changed\r\n- [x] This was checked for breaking
API changes and was
[labeled\r\nappropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)","sha":"b2d85d5f8f10f7c460c3a3b732844a19c8b20d7b","branchLabelMapping":{"^v9.0.0$":"main","^v8.16.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":[":ml","release_note:skip","Feature:Transforms","v9.0.0","backport:prev-minor","v8.16.0"],"number":193657,"url":"https://github.com/elastic/kibana/pull/193657","mergeCommit":{"message":"[ML]
Move FieldStatsFlyout, parseInterval, validators to packages.
(#193657)\n\n## Summary\r\n\r\nPart of #159917.\r\n\r\nMoves code from
`plugins/ml/common|public` to packages that is used by\r\ntransforms
too.\r\n\r\nWhile the transforms plugin is maintained by the ML team
too, the\r\ntransform plugin itself is independently available from the
ML UI in the\r\nKibana management section. We should try to avoid that
the transform\r\nplugin is directly depending on the `ml` plugin. This
PR moves some code\r\nfrom `plugins/ml/common|public` to packages so
that we can remove `ml`\r\nfrom the list of `requiredBundles` of the
`transform` plugin.\r\n\r\nThe packages were created with these
commands:\r\n\r\n```\r\nnode scripts/generate package
@kbn/ml-field-stats-flyout --dir
./x-pack/packages/ml/field_stats_flyout\r\nnode scripts/generate package
@kbn/ml-parse-interval --dir ./x-pack/packages/ml/parse_interval\r\nnode
scripts/generate package @kbn/ml-validators --dir
./x-pack/packages/ml/validators\r\n```\r\n\r\nThe following commands
were used to check missing jsdoc comments
and\r\nexports:\r\n\r\n```\r\nnode scripts/build_api_docs --plugin
@kbn/ml-field-stats-flyout --stats comments\r\nnode
scripts/build_api_docs --plugin @kbn/ml-field-stats-flyout --stats
exports\r\nnode scripts/build_api_docs --plugin @kbn/ml-parse-interval
--stats comments\r\nnode scripts/build_api_docs --plugin
@kbn/ml-parse-interval --stats exports\r\nnode scripts/build_api_docs
--plugin @kbn/ml-validators --stats comments\r\nnode
scripts/build_api_docs --plugin @kbn/ml-validators --stats
exports\r\n```\r\n\r\n### Checklist\r\n\r\n- [x] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common scenarios\r\n- [ ] [Flaky
Test\r\nRunner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1)
was\r\nused on any tests changed\r\n- [x] This was checked for breaking
API changes and was
[labeled\r\nappropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)","sha":"b2d85d5f8f10f7c460c3a3b732844a19c8b20d7b"}},"sourceBranch":"main","suggestedTargetBranches":["8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","labelRegex":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/193657","number":193657,"mergeCommit":{"message":"[ML]
Move FieldStatsFlyout, parseInterval, validators to packages.
(#193657)\n\n## Summary\r\n\r\nPart of #159917.\r\n\r\nMoves code from
`plugins/ml/common|public` to packages that is used by\r\ntransforms
too.\r\n\r\nWhile the transforms plugin is maintained by the ML team
too, the\r\ntransform plugin itself is independently available from the
ML UI in the\r\nKibana management section. We should try to avoid that
the transform\r\nplugin is directly depending on the `ml` plugin. This
PR moves some code\r\nfrom `plugins/ml/common|public` to packages so
that we can remove `ml`\r\nfrom the list of `requiredBundles` of the
`transform` plugin.\r\n\r\nThe packages were created with these
commands:\r\n\r\n```\r\nnode scripts/generate package
@kbn/ml-field-stats-flyout --dir
./x-pack/packages/ml/field_stats_flyout\r\nnode scripts/generate package
@kbn/ml-parse-interval --dir ./x-pack/packages/ml/parse_interval\r\nnode
scripts/generate package @kbn/ml-validators --dir
./x-pack/packages/ml/validators\r\n```\r\n\r\nThe following commands
were used to check missing jsdoc comments
and\r\nexports:\r\n\r\n```\r\nnode scripts/build_api_docs --plugin
@kbn/ml-field-stats-flyout --stats comments\r\nnode
scripts/build_api_docs --plugin @kbn/ml-field-stats-flyout --stats
exports\r\nnode scripts/build_api_docs --plugin @kbn/ml-parse-interval
--stats comments\r\nnode scripts/build_api_docs --plugin
@kbn/ml-parse-interval --stats exports\r\nnode scripts/build_api_docs
--plugin @kbn/ml-validators --stats comments\r\nnode
scripts/build_api_docs --plugin @kbn/ml-validators --stats
exports\r\n```\r\n\r\n### Checklist\r\n\r\n- [x] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common scenarios\r\n- [ ] [Flaky
Test\r\nRunner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1)
was\r\nused on any tests changed\r\n- [x] This was checked for breaking
API changes and was
[labeled\r\nappropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)","sha":"b2d85d5f8f10f7c460c3a3b732844a19c8b20d7b"}},{"branch":"8.x","label":"v8.16.0","labelRegex":"^v8.16.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->
This commit is contained in:
Walter Rafelsberger 2024-09-24 15:44:26 +02:00 committed by GitHub
parent 5770e8a344
commit bc2bb0d77a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
139 changed files with 843 additions and 380 deletions

View file

@ -645,6 +645,7 @@
"@kbn/ml-date-picker": "link:x-pack/packages/ml/date_picker",
"@kbn/ml-date-utils": "link:x-pack/packages/ml/date_utils",
"@kbn/ml-error-utils": "link:x-pack/packages/ml/error_utils",
"@kbn/ml-field-stats-flyout": "link:x-pack/packages/ml/field_stats_flyout",
"@kbn/ml-in-memory-table": "link:x-pack/packages/ml/in_memory_table",
"@kbn/ml-is-defined": "link:x-pack/packages/ml/is_defined",
"@kbn/ml-is-populated-object": "link:x-pack/packages/ml/is_populated_object",
@ -652,6 +653,7 @@
"@kbn/ml-local-storage": "link:x-pack/packages/ml/local_storage",
"@kbn/ml-nested-property": "link:x-pack/packages/ml/nested_property",
"@kbn/ml-number-utils": "link:x-pack/packages/ml/number_utils",
"@kbn/ml-parse-interval": "link:x-pack/packages/ml/parse_interval",
"@kbn/ml-plugin": "link:x-pack/plugins/ml",
"@kbn/ml-query-utils": "link:x-pack/packages/ml/query_utils",
"@kbn/ml-random-sampler-utils": "link:x-pack/packages/ml/random_sampler_utils",
@ -663,6 +665,7 @@
"@kbn/ml-trained-models-utils": "link:x-pack/packages/ml/trained_models_utils",
"@kbn/ml-ui-actions": "link:x-pack/packages/ml/ui_actions",
"@kbn/ml-url-state": "link:x-pack/packages/ml/url_state",
"@kbn/ml-validators": "link:x-pack/packages/ml/validators",
"@kbn/monaco": "link:packages/kbn-monaco",
"@kbn/monitoring-collection-plugin": "link:x-pack/plugins/monitoring_collection",
"@kbn/monitoring-plugin": "link:x-pack/plugins/monitoring",

View file

@ -1214,6 +1214,8 @@
"@kbn/ml-date-utils/*": ["x-pack/packages/ml/date_utils/*"],
"@kbn/ml-error-utils": ["x-pack/packages/ml/error_utils"],
"@kbn/ml-error-utils/*": ["x-pack/packages/ml/error_utils/*"],
"@kbn/ml-field-stats-flyout": ["x-pack/packages/ml/field_stats_flyout"],
"@kbn/ml-field-stats-flyout/*": ["x-pack/packages/ml/field_stats_flyout/*"],
"@kbn/ml-in-memory-table": ["x-pack/packages/ml/in_memory_table"],
"@kbn/ml-in-memory-table/*": ["x-pack/packages/ml/in_memory_table/*"],
"@kbn/ml-is-defined": ["x-pack/packages/ml/is_defined"],
@ -1228,6 +1230,8 @@
"@kbn/ml-nested-property/*": ["x-pack/packages/ml/nested_property/*"],
"@kbn/ml-number-utils": ["x-pack/packages/ml/number_utils"],
"@kbn/ml-number-utils/*": ["x-pack/packages/ml/number_utils/*"],
"@kbn/ml-parse-interval": ["x-pack/packages/ml/parse_interval"],
"@kbn/ml-parse-interval/*": ["x-pack/packages/ml/parse_interval/*"],
"@kbn/ml-plugin": ["x-pack/plugins/ml"],
"@kbn/ml-plugin/*": ["x-pack/plugins/ml/*"],
"@kbn/ml-query-utils": ["x-pack/packages/ml/query_utils"],
@ -1250,6 +1254,8 @@
"@kbn/ml-ui-actions/*": ["x-pack/packages/ml/ui_actions/*"],
"@kbn/ml-url-state": ["x-pack/packages/ml/url_state"],
"@kbn/ml-url-state/*": ["x-pack/packages/ml/url_state/*"],
"@kbn/ml-validators": ["x-pack/packages/ml/validators"],
"@kbn/ml-validators/*": ["x-pack/packages/ml/validators/*"],
"@kbn/mock-idp-plugin": ["packages/kbn-mock-idp-plugin"],
"@kbn/mock-idp-plugin/*": ["packages/kbn-mock-idp-plugin/*"],
"@kbn/mock-idp-utils": ["packages/kbn-mock-idp-utils"],

View file

@ -79,6 +79,7 @@
"packages/ml/data_grid",
"packages/ml/data_view_utils",
"packages/ml/date_picker",
"packages/ml/field_stats_flyout",
"packages/ml/inference_integration_flyout",
"packages/ml/trained_models_utils",
"packages/ml/category_validator",

View file

@ -0,0 +1,3 @@
# @kbn/ml-field-stats-flyout
This package provides a field statistics flyout component. It is used in the Machine Learning and Transforms plugin.

View file

@ -25,9 +25,25 @@ export const optionCss = css`
}
`;
export const EuiComboBoxWithFieldStats: FC<
EuiComboBoxProps<string | number | string[] | undefined>
> = ({ options, ...restProps }) => {
/**
* Props for the EuiComboBoxWithFieldStats component.
*/
export type EuiComboBoxWithFieldStatsProps = EuiComboBoxProps<
string | number | string[] | undefined
>;
/**
* React component that wraps the EuiComboBox component and adds field statistics functionality.
*
* @component
* @example
* ```tsx
* <EuiComboBoxWithFieldStats options={options} />
* ```
* @param {EuiComboBoxWithFieldStatsProps} props - The component props.
*/
export const EuiComboBoxWithFieldStats: FC<EuiComboBoxWithFieldStatsProps> = (props) => {
const { options, ...restProps } = props;
const { renderOption } = useFieldStatsTrigger();
const comboBoxOptions: EuiComboBoxOptionOption[] = useMemo(
() =>

View file

@ -15,20 +15,42 @@ import { FieldStats } from '@kbn/unified-field-list/src/components/field_stats';
import { isDefined } from '@kbn/ml-is-defined';
import type { DataView } from '@kbn/data-plugin/common';
import type { TimeRange as TimeRangeMs } from '@kbn/ml-date-picker';
import { getDefaultDSLQuery } from '@kbn/ml-query-utils';
import moment from 'moment';
import { euiPaletteColorBlind } from '@elastic/eui';
import { getDefaultDatafeedQuery } from '../../jobs/new_job/utils/new_job_utils';
import { useFieldStatsFlyoutContext } from './use_field_stats_flytout_context';
import { useFieldStatsFlyoutContext } from './use_field_stats_flyout_context';
const DEFAULT_DSL_QUERY = getDefaultDatafeedQuery();
const DEFAULT_COLOR = euiPaletteColorBlind()[0];
export const FieldStatsContent: FC<{
/**
* Represents the props for the FieldStatsFlyout component.
*/
export interface FieldStatsFlyoutProps {
/**
* The data view object.
*/
dataView: DataView;
/**
* Services required for field statistics.
*/
fieldStatsServices: FieldStatsServices;
/**
* Optional time range in milliseconds.
*/
timeRangeMs?: TimeRangeMs;
/**
* Optional DSL query for filtering field statistics.
*/
dslQuery?: FieldStatsProps['dslQuery'];
}> = ({ dataView: selectedDataView, fieldStatsServices, timeRangeMs, dslQuery }) => {
}
/**
* Renders the content for the field statistics flyout.
* @param props - The props for the FieldStatsContent component.
* @returns The rendered FieldStatsContent component.
*/
export const FieldStatsContent: FC<FieldStatsFlyoutProps> = (props) => {
const { dataView: selectedDataView, fieldStatsServices, timeRangeMs, dslQuery } = props;
const { fieldName } = useFieldStatsFlyoutContext();
// Format timestamp to ISO formatted date strings
@ -58,7 +80,7 @@ export const FieldStatsContent: FC<{
<FieldStats
key={fieldForStats.name}
services={fieldStatsServices}
dslQuery={dslQuery ?? DEFAULT_DSL_QUERY}
dslQuery={dslQuery ?? getDefaultDSLQuery()}
fromDate={timeRange.from}
toDate={timeRange.to}
dataViewOrDataViewId={selectedDataView}

View file

@ -26,15 +26,43 @@ import type {
FieldStatsServices,
} from '@kbn/unified-field-list/src/components/field_stats';
import type { TimeRange as TimeRangeMs } from '@kbn/ml-date-picker';
import { useFieldStatsFlyoutContext } from './use_field_stats_flytout_context';
import { useFieldStatsFlyoutContext } from './use_field_stats_flyout_context';
import { FieldStatsContent } from './field_stats_content';
export const FieldStatsFlyout: FC<{
/**
* Props for the FieldStatsFlyout component.
*
* @typedef {Object} FieldStatsFlyoutProps
* @property dataView - The data view object.
* @property fieldStatsServices - Services required for field statistics.
* @property [timeRangeMs] - Optional time range in milliseconds.
* @property [dslQuery] - Optional DSL query for filtering field statistics.
*/
export interface FieldStatsFlyoutProps {
dataView: DataView;
fieldStatsServices: FieldStatsServices;
timeRangeMs?: TimeRangeMs;
dslQuery?: FieldStatsProps['dslQuery'];
}> = ({ dataView, fieldStatsServices, timeRangeMs, dslQuery }) => {
}
/**
* Renders a flyout component for displaying field statistics.
*
* @component
* @example
* ```tsx
* <FieldStatsFlyout
* dataView={dataView}
* fieldStatsServices={fieldStatsServices}
* timeRangeMs={timeRangeMs}
* dslQuery={dslQuery}
* />
* ```
*
* @param {Object} props - The component props.
*/
export const FieldStatsFlyout: FC<FieldStatsFlyoutProps> = (props) => {
const { dataView, fieldStatsServices, timeRangeMs, dslQuery } = props;
const { setIsFlyoutVisible, isFlyoutVisible, fieldName } = useFieldStatsFlyoutContext();
const closeFlyout = useCallback(() => setIsFlyoutVisible(false), []); // eslint-disable-line react-hooks/exhaustive-deps

View file

@ -7,7 +7,9 @@
import type { PropsWithChildren, FC } from 'react';
import React, { useCallback, useState } from 'react';
import type { CoreStart } from '@kbn/core/public';
import type { DataView } from '@kbn/data-plugin/common';
import type { DataPublicPluginStart } from '@kbn/data-plugin/public';
import type { FieldStatsServices } from '@kbn/unified-field-list/src/components/field_stats';
import type { TimeRange as TimeRangeMs } from '@kbn/ml-date-picker';
import type { FieldStatsProps } from '@kbn/unified-field-list/src/components/field_stats';
@ -16,33 +18,73 @@ import { getProcessedFields } from '@kbn/ml-data-grid';
import { stringHash } from '@kbn/ml-string-hash';
import { lastValueFrom } from 'rxjs';
import { useRef } from 'react';
import { useKibana } from '@kbn/kibana-react-plugin/public';
import { getMergedSampleDocsForPopulatedFieldsQuery } from './populated_fields/get_merged_populated_fields_query';
import { useMlKibana } from '../../contexts/kibana';
import { FieldStatsFlyout } from './field_stats_flyout';
import { MLFieldStatsFlyoutContext } from './use_field_stats_flytout_context';
import { MLFieldStatsFlyoutContext } from './use_field_stats_flyout_context';
import { PopulatedFieldsCacheManager } from './populated_fields/populated_fields_cache_manager';
export const FieldStatsFlyoutProvider: FC<
PropsWithChildren<{
dataView: DataView;
fieldStatsServices: FieldStatsServices;
timeRangeMs?: TimeRangeMs;
dslQuery?: FieldStatsProps['dslQuery'];
disablePopulatedFields?: boolean;
}>
> = ({
dataView,
fieldStatsServices,
timeRangeMs,
dslQuery,
disablePopulatedFields = false,
children,
}) => {
type Services = CoreStart & {
data: DataPublicPluginStart;
};
function useDataSearch() {
const { data } = useKibana<Services>().services;
if (!data) {
throw new Error('Kibana data service not available.');
}
return data.search;
}
/**
* Props for the FieldStatsFlyoutProvider component.
*
* @typedef {Object} FieldStatsFlyoutProviderProps
* @property dataView - The data view object.
* @property fieldStatsServices - Services required for field statistics.
* @property [timeRangeMs] - Optional time range in milliseconds.
* @property [dslQuery] - Optional DSL query for filtering field statistics.
* @property [disablePopulatedFields] - Optional flag to disable populated fields.
*/
export type FieldStatsFlyoutProviderProps = PropsWithChildren<{
dataView: DataView;
fieldStatsServices: FieldStatsServices;
timeRangeMs?: TimeRangeMs;
dslQuery?: FieldStatsProps['dslQuery'];
disablePopulatedFields?: boolean;
}>;
/**
* Provides field statistics in a flyout component.
*
* @component
* @example
* ```tsx
* <FieldStatsFlyoutProvider
* dataView={dataView}
* fieldStatsServices={fieldStatsServices}
* timeRangeMs={timeRangeMs}
* dslQuery={dslQuery}
* disablePopulatedFields={disablePopulatedFields}
* >
* {children}
* </FieldStatsFlyoutProvider>
* ```
*
* @param {FieldStatsFlyoutProviderProps} props - The component props.
*/
export const FieldStatsFlyoutProvider: FC<FieldStatsFlyoutProviderProps> = (props) => {
const {
services: {
data: { search },
},
} = useMlKibana();
dataView,
fieldStatsServices,
timeRangeMs,
dslQuery,
disablePopulatedFields = false,
children,
} = props;
const search = useDataSearch();
const [isFieldStatsFlyoutVisible, setFieldStatsIsFlyoutVisible] = useState(false);
const [fieldName, setFieldName] = useState<string | undefined>();
const [fieldValue, setFieldValue] = useState<string | number | undefined>();

View file

@ -7,30 +7,81 @@
import { EuiButtonIcon, EuiFlexGroup, EuiFlexItem, EuiToolTip, EuiText } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import React from 'react';
import React, { type FC } from 'react';
import { FieldIcon } from '@kbn/react-field';
import { type Field } from '@kbn/ml-anomaly-utils';
import { useCurrentThemeVars } from '../../contexts/kibana';
import { getKbnFieldIconType } from '../../../../common/util/get_field_icon_types';
import { useKibana } from '@kbn/kibana-react-plugin/public';
import { useCurrentEuiThemeVars } from '@kbn/ml-kibana-theme';
import { getKbnFieldIconType } from './get_kbn_field_icon_types';
function useThemeVars() {
const { theme } = useKibana().services;
if (!theme) {
throw new TypeError('theme service not available in kibana-react context.');
}
return useCurrentEuiThemeVars(theme);
}
/**
* Represents a field used for statistics.
*/
export type FieldForStats = Pick<Field, 'id' | 'type'>;
export const FieldStatsInfoButton = ({
field,
label,
onButtonClick,
disabled,
isEmpty = false,
hideTrigger = false,
}: {
/**
* Represents the props for the FieldStatsInfoButton component.
*/
export interface FieldStatsInfoButtonProps {
/**
* The field for which to display statistics.
*/
field: FieldForStats;
/**
* The label for the field.
*/
label: string;
searchValue?: string;
disabled?: boolean;
isEmpty?: boolean;
/**
* Button click callback function.
* @param field - The field for which to display statistics.
* @returns void
*/
onButtonClick?: (field: FieldForStats) => void;
/**
* If true, the button is disabled.
*/
disabled?: boolean;
/**
* If true, the field is empty.
*/
isEmpty?: boolean;
/**
* If true, the trigger is hidden.
*/
hideTrigger?: boolean;
}) => {
const themeVars = useCurrentThemeVars();
}
/**
* Renders a button component for field statistics information.
*
* @component
* @example
* ```tsx
* <FieldStatsInfoButton
* field={field}
* label={label}
* onButtonClick={handleButtonClick}
* disabled={false}
* isEmpty={true}
* hideTrigger={false}
* />
* ```
* @param {FieldStatsInfoButtonProps} props - The props for the FieldStatsInfoButton component.
*/
export const FieldStatsInfoButton: FC<FieldStatsInfoButtonProps> = (props) => {
const { field, label, onButtonClick, disabled, isEmpty, hideTrigger } = props;
const themeVars = useThemeVars();
const emptyFieldMessage = isEmpty
? ' ' +
i18n.translate('xpack.ml.newJob.wizard.fieldContextPopover.emptyFieldInSampleDocsMsg', {

View file

@ -0,0 +1,44 @@
/*
* 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 { getKbnFieldIconType } from './get_kbn_field_icon_types';
import { ES_FIELD_TYPES } from '@kbn/field-types';
describe('getKbnFieldIconType', () => {
it('should return "number" for numeric field types', () => {
const numericTypes = [
ES_FIELD_TYPES.FLOAT,
ES_FIELD_TYPES.HALF_FLOAT,
ES_FIELD_TYPES.SCALED_FLOAT,
ES_FIELD_TYPES.DOUBLE,
ES_FIELD_TYPES.INTEGER,
ES_FIELD_TYPES.LONG,
ES_FIELD_TYPES.SHORT,
ES_FIELD_TYPES.UNSIGNED_LONG,
];
numericTypes.forEach((type) => {
expect(getKbnFieldIconType(type)).toBe('number');
});
});
it('should return "date" for date field types', () => {
const dateTypes = [ES_FIELD_TYPES.DATE, ES_FIELD_TYPES.DATE_NANOS];
dateTypes.forEach((type) => {
expect(getKbnFieldIconType(type)).toBe('date');
});
});
it('should return the same type for other field types', () => {
const otherTypes = ['keyword', 'text', 'boolean', 'geo_point', 'geo_shape'];
otherTypes.forEach((type) => {
expect(getKbnFieldIconType(type)).toBe(type);
});
});
});

View file

@ -8,6 +8,12 @@
import { ES_FIELD_TYPES } from '@kbn/field-types';
import type { FieldIconProps } from '@kbn/react-field';
/**
* Returns the Kibana field icon type based on the provided field type.
*
* @param fieldType - The type of the field for which the icon type is needed.
* @returns The icon type corresponding to the provided field type.
*/
export function getKbnFieldIconType(type: string): FieldIconProps['type'] {
switch (type) {
case ES_FIELD_TYPES.FLOAT:

View file

@ -0,0 +1,27 @@
/*
* 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 { FieldStatsFlyout } from './field_stats_flyout';
export { FieldStatsContent, type FieldStatsFlyoutProps } from './field_stats_content';
export {
FieldStatsFlyoutProvider,
type FieldStatsFlyoutProviderProps,
} from './field_stats_flyout_provider';
export {
MLFieldStatsFlyoutContext,
useFieldStatsFlyoutContext,
} from './use_field_stats_flyout_context';
export {
FieldStatsInfoButton,
type FieldForStats,
type FieldStatsInfoButtonProps,
} from './field_stats_info_button';
export { useFieldStatsTrigger } from './use_field_stats_trigger';
export {
EuiComboBoxWithFieldStats,
type EuiComboBoxWithFieldStatsProps,
} from './eui_combo_box_with_field_stats';

View file

@ -5,10 +5,8 @@
* 2.0.
*/
// actual mocks
export const expandLiteralStrings = jest.fn();
export const XJsonMode = jest.fn();
export const getSavedSearch = jest.fn();
// just passing through the reimports
export { getMlSharedImports } from '@kbn/ml-plugin/public';
module.exports = {
preset: '@kbn/test',
rootDir: '../../../..',
roots: ['<rootDir>/x-pack/packages/ml/field_stats_flyout'],
};

View file

@ -0,0 +1,5 @@
{
"type": "shared-browser",
"id": "@kbn/ml-field-stats-flyout",
"owner": "@elastic/ml-ui"
}

View file

@ -0,0 +1,6 @@
{
"name": "@kbn/ml-field-stats-flyout",
"private": true,
"version": "1.0.0",
"license": "Elastic License 2.0"
}

View file

@ -0,0 +1,36 @@
{
"extends": "../../../../tsconfig.base.json",
"compilerOptions": {
"outDir": "target/types",
"types": [
"jest",
"node",
"react"
]
},
"include": [
"**/*.ts",
"**/*.tsx",
],
"exclude": [
"target/**/*"
],
"kbn_references": [
"@kbn/i18n-react",
"@kbn/data-plugin",
"@kbn/unified-field-list",
"@kbn/ml-date-picker",
"@kbn/i18n",
"@kbn/react-field",
"@kbn/ml-anomaly-utils",
"@kbn/kibana-react-plugin",
"@kbn/ml-kibana-theme",
"@kbn/core",
"@kbn/ml-data-grid",
"@kbn/ml-string-hash",
"@kbn/ml-is-populated-object",
"@kbn/ml-query-utils",
"@kbn/ml-is-defined",
"@kbn/field-types",
]
}

View file

@ -7,6 +7,10 @@
import { createContext, useContext } from 'react';
import type { TimeRange as TimeRangeMs } from '@kbn/ml-date-picker';
/**
* Represents the properties for the MLJobWizardFieldStatsFlyout component.
*/
interface MLJobWizardFieldStatsFlyoutProps {
isFlyoutVisible: boolean;
setIsFlyoutVisible: (v: boolean) => void;
@ -18,6 +22,10 @@ interface MLJobWizardFieldStatsFlyoutProps {
timeRangeMs?: TimeRangeMs;
populatedFields?: Set<string>;
}
/**
* Context for the ML Field Stats Flyout.
*/
export const MLFieldStatsFlyoutContext = createContext<MLJobWizardFieldStatsFlyoutProps>({
isFlyoutVisible: false,
setIsFlyoutVisible: () => {},
@ -28,6 +36,10 @@ export const MLFieldStatsFlyoutContext = createContext<MLJobWizardFieldStatsFlyo
populatedFields: undefined,
});
/**
* Retrieves the context for the field stats flyout.
* @returns The field stats flyout context.
*/
export function useFieldStatsFlyoutContext() {
return useContext(MLFieldStatsFlyoutContext);
}

View file

@ -13,10 +13,23 @@ import { optionCss } from './eui_combo_box_with_field_stats';
import { useFieldStatsFlyoutContext } from '.';
import type { FieldForStats } from './field_stats_info_button';
import { FieldStatsInfoButton } from './field_stats_info_button';
interface Option extends EuiComboBoxOptionOption<string> {
field: Field;
}
/**
* Custom hook for managing field statistics trigger functionality.
*
* @returns An object containing the following properties and functions:
* - `renderOption`: A callback function for rendering options in a combo box.
* - `setIsFlyoutVisible`: A function for setting the visibility of the flyout.
* - `setFieldName`: A function for setting the field name.
* - `handleFieldStatsButtonClick`: A callback function for handling field stats button click.
* - `closeFlyout`: A callback function for closing the flyout.
* - `optionCss`: CSS styles for the options in the combo box.
* - `populatedFields`: A set of populated fields.
*/
export const useFieldStatsTrigger = () => {
const { setIsFlyoutVisible, setFieldName, populatedFields } = useFieldStatsFlyoutContext();

View file

@ -0,0 +1,14 @@
# @kbn/ml-parse-interval
The `parse_interval` package provides the `parseInterval` utility function for parsing time intervals in various formats.
## Usage
```javascript
import { parseInterval } = from '@kbn/ml-parse-interval';
const intervalString = '1d';
const intervalInMs = parseInterval(intervalString);
console.log(intervalInMs); // Output: 86400000
```

View file

@ -5,4 +5,4 @@
* 2.0.
*/
export { composeValidators, patternValidator } from '@kbn/ml-plugin/common';
export { parseInterval } from './parse_interval';

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/jest_node',
rootDir: '../../../..',
roots: ['<rootDir>/x-pack/packages/ml/parse_interval'],
};

View file

@ -0,0 +1,5 @@
{
"type": "shared-common",
"id": "@kbn/ml-parse-interval",
"owner": "@elastic/ml-ui"
}

View file

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

View file

@ -11,30 +11,43 @@ import dateMath from '@kbn/datemath';
type SupportedUnits = unitOfTime.Base;
// Assume interval is in the form (value)(unit), such as "1h"
/**
* Assume interval is in the form (value)(unit), such as "1h"
*/
const INTERVAL_STRING_RE = new RegExp('^([0-9]*)\\s*(' + dateMath.units.join('|') + ')$');
// moment.js is only designed to allow fractional values between 0 and 1
// for units of hour or less.
/**
* moment.js is only designed to allow fractional values between 0 and 1
* for units of hour or less.
*/
const SUPPORT_ZERO_DURATION_UNITS: SupportedUnits[] = ['ms', 's', 'm', 'h'];
// List of time units which are supported for use in Elasticsearch durations
// (such as anomaly detection job bucket spans)
// See https://www.elastic.co/guide/en/elasticsearch/reference/current/common-options.html#time-units
/**
* List of time units which are supported for use in Elasticsearch durations
* (such as anomaly detection job bucket spans)
* See https://www.elastic.co/guide/en/elasticsearch/reference/current/common-options.html#time-units
*/
const SUPPORT_ES_DURATION_UNITS: SupportedUnits[] = ['ms', 's', 'm', 'h', 'd'];
// Parses an interval String, such as 7d, 1h or 30m to a moment duration.
// Optionally carries out an additional check that the interval is supported as a
// time unit by Elasticsearch, as units greater than 'd' for example cannot be used
// for anomaly detection job bucket spans.
// Differs from the Kibana ui/utils/parse_interval in the following ways:
// 1. A value-less interval such as 'm' is not allowed - in line with the ML back-end
// not accepting such interval Strings for the bucket span of a job.
// 2. Zero length durations 0ms, 0s, 0m and 0h are accepted as-is.
// Note that when adding or subtracting fractional durations, moment is only designed
// to work with units less than 'day'.
// 3. Fractional intervals e.g. 1.5h or 4.5d are not allowed, in line with the behaviour
// of the Elasticsearch date histogram aggregation.
/**
* Parses an interval string, such as 7d, 1h, or 30m to a moment duration.
* Optionally carries out an additional check that the interval is supported as a
* time unit by Elasticsearch, as units greater than 'd' for example cannot be used
* for anomaly detection job bucket spans.
*
* Differs from the Kibana ui/utils/parse_interval in the following ways:
* 1. A value-less interval such as 'm' is not allowed - in line with the ML back-end
* not accepting such interval strings for the bucket span of a job.
* 2. Zero length durations 0ms, 0s, 0m, and 0h are accepted as-is.
* Note that when adding or subtracting fractional durations, moment is only designed
* to work with units less than 'day'.
* 3. Fractional intervals e.g. 1.5h or 4.5d are not allowed, in line with the behaviour
* of the Elasticsearch date histogram aggregation.
*
* @param interval - The interval to parse.
* @param checkValidEsUnit - Optional. Specifies whether to check if the unit is a valid Elasticsearch duration unit. Default is false.
* @returns The parsed Duration object, or null if the interval is invalid.
*/
export function parseInterval(
interval: string | number,
checkValidEsUnit = false

View file

@ -0,0 +1,19 @@
{
"extends": "../../../../tsconfig.base.json",
"compilerOptions": {
"outDir": "target/types",
"types": [
"jest",
"node"
]
},
"include": [
"**/*.ts",
],
"exclude": [
"target/**/*"
],
"kbn_references": [
"@kbn/datemath",
]
}

View file

@ -20,4 +20,4 @@ export type {
SearchQueryVariant,
SimpleQuery,
} from './src/types';
export { getDefaultDSLQuery } from './src/get_default_query';
export { getDefaultDSLQuery } from './src/get_default_dsl_query';

View file

@ -6,9 +6,10 @@
*/
import { cloneDeep } from 'lodash';
import type { QueryDslQueryContainer } from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
const DEFAULT_QUERY = {
import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
const DEFAULT_DSL_QUERY: estypes.QueryDslQueryContainer = {
bool: {
must: [
{
@ -21,6 +22,6 @@ const DEFAULT_QUERY = {
/**
* Default DSL query which matches all the results
*/
export function getDefaultDSLQuery(): QueryDslQueryContainer {
return cloneDeep(DEFAULT_QUERY);
export function getDefaultDSLQuery(): estypes.QueryDslQueryContainer {
return cloneDeep(DEFAULT_DSL_QUERY);
}

View file

@ -149,7 +149,7 @@ TimeBuckets.prototype.getDuration = function () {
*
* Input can be one of the following:
* - "auto"
* - an interval String, such as 7d, 1h or 30m which can be parsed to a moment duration using ml/common/util/parse_interval
* - an interval String, such as 7d, 1h or 30m which can be parsed to a moment duration using @kbn/ml-parse-interval
* - a moment.duration object.
*
* @param {string|moment.duration} input - see desc

View file

@ -0,0 +1,3 @@
# @kbn/ml-validators
This package provides a set of validators for machine learning and transform related functionality in Kibana.

View file

@ -5,16 +5,40 @@
* 2.0.
*/
/**
* Interface for a callout message.
*/
export interface CalloutMessage {
/**
* Unique identifier for the callout message.
*/
id: string;
/**
* Heading of the callout message.
*/
heading: string;
/**
* Status of the callout message.
*/
status: VALIDATION_STATUS;
/**
* Text of the callout message.
*/
text: string;
/**
* Optional URL for the callout message.
*/
url?: string;
}
/**
* Type for the response of the validate analytics job API.
*/
export type ValidateAnalyticsJobResponse = CalloutMessage[];
/**
* Enum for the validation status.
*/
export enum VALIDATION_STATUS {
ERROR = 'error',
INFO = 'info',
@ -22,17 +46,54 @@ export enum VALIDATION_STATUS {
WARNING = 'warning',
}
/**
* Boolean const for skipping the bucket span estimation.
*/
export const SKIP_BUCKET_SPAN_ESTIMATION = true;
/**
* Const for allowed data units.
*/
export const ALLOWED_DATA_UNITS = ['B', 'KB', 'MB', 'GB', 'TB', 'PB'];
/**
* Const for the maximum length of a job ID.
*/
export const JOB_ID_MAX_LENGTH = 64;
// Data Frame Analytics
/**
* Const for the upper limit of training documents.
*/
export const TRAINING_DOCS_UPPER = 200000;
/**
* Const for the lower limit of training documents.
*/
export const TRAINING_DOCS_LOWER = 200;
/**
* Const for the threshold of included fields.
*/
export const INCLUDED_FIELDS_THRESHOLD = 100;
/**
* Const for the minimum number of fields for check.
*/
export const MINIMUM_NUM_FIELD_FOR_CHECK = 25;
/**
* Const for the fraction empty limit.
*/
export const FRACTION_EMPTY_LIMIT = 0.3;
/**
* Const for the maximum length of categories.
*/
export const NUM_CATEGORIES_THRESHOLD = 10;
/**
* Const for all categories.
*/
export const ALL_CATEGORIES = -1;

View file

@ -0,0 +1,32 @@
/*
* 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 {
ALL_CATEGORIES,
ALLOWED_DATA_UNITS,
FRACTION_EMPTY_LIMIT,
INCLUDED_FIELDS_THRESHOLD,
JOB_ID_MAX_LENGTH,
MINIMUM_NUM_FIELD_FOR_CHECK,
NUM_CATEGORIES_THRESHOLD,
SKIP_BUCKET_SPAN_ESTIMATION,
TRAINING_DOCS_LOWER,
TRAINING_DOCS_UPPER,
VALIDATION_STATUS,
type CalloutMessage,
type ValidateAnalyticsJobResponse,
} from './constants';
export {
composeValidators,
dictionaryValidator,
maxLengthValidator,
memoryInputValidator,
patternValidator,
requiredValidator,
timeIntervalInputValidator,
type MemoryInputValidatorResult,
} from './validators';

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/jest_node',
rootDir: '../../../..',
roots: ['<rootDir>/x-pack/packages/ml/validators'],
};

View file

@ -0,0 +1,5 @@
{
"type": "shared-common",
"id": "@kbn/ml-validators",
"owner": "@elastic/ml-ui"
}

View file

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

View file

@ -0,0 +1,19 @@
{
"extends": "../../../../tsconfig.base.json",
"compilerOptions": {
"outDir": "target/types",
"types": [
"jest",
"node"
]
},
"include": [
"**/*.ts",
],
"exclude": [
"target/**/*"
],
"kbn_references": [
"@kbn/ml-parse-interval",
]
}

View file

@ -5,8 +5,9 @@
* 2.0.
*/
import { ALLOWED_DATA_UNITS } from '../constants/validation';
import { parseInterval } from './parse_interval';
import { parseInterval } from '@kbn/ml-parse-interval';
import { ALLOWED_DATA_UNITS } from './constants';
/**
* Provides a validator function for maximum allowed input length.
@ -27,8 +28,9 @@ export function maxLengthValidator(
}
/**
* Provides a validator function for checking against pattern.
* @param pattern
* Factory that provides a validator function for checking against pattern.
* @param pattern Pattern to check against.
* @returns A validator function that checks if the value matches the pattern.
*/
export function patternValidator(
pattern: RegExp
@ -44,8 +46,10 @@ export function patternValidator(
}
/**
* Composes multiple validators into a single function
* @param validators
* Factory that composes multiple validators into a single function.
*
* @param validators List of validators to compose.
* @returns A validator function that runs all the validators.
*/
export function composeValidators(
...validators: Array<(value: any) => { [key: string]: any } | null>
@ -58,16 +62,32 @@ export function composeValidators(
};
}
/**
* Factory to create a required validator function.
* @returns A validator function that checks if the value is empty.
*/
export function requiredValidator() {
return <T extends string>(value: T) => {
return value === '' || value === undefined || value === null ? { required: true } : null;
};
}
/**
* Type for the result of a validation.
*/
export type ValidationResult = Record<string, any> | null;
/**
* Type for the result of a memory input validation.
*/
export type MemoryInputValidatorResult = { invalidUnits: { allowedUnits: string } } | null;
/**
* Factory for creating a memory input validator function.
*
* @param allowedUnits Allowed units for the memory input.
* @returns A validator function that checks if the value is a valid memory input.
*/
export function memoryInputValidator(allowedUnits = ALLOWED_DATA_UNITS) {
return <T>(value: T) => {
if (typeof value !== 'string' || value === '') {
@ -80,6 +100,11 @@ export function memoryInputValidator(allowedUnits = ALLOWED_DATA_UNITS) {
};
}
/**
* Factory for creating a time interval input validator function.
*
* @returns A validator function that checks if the value is a valid time interval.
*/
export function timeIntervalInputValidator() {
return (value: string) => {
if (value === '') {
@ -97,6 +122,12 @@ export function timeIntervalInputValidator() {
};
}
/**
* Factory to create a dictionary validator function.
* @param dict Dictionary to check against.
* @param shouldInclude Whether the value should be included in the dictionary.
* @returns A validator function that checks if the value is in the dictionary.
*/
export function dictionaryValidator(dict: string[], shouldInclude: boolean = false) {
const dictSet = new Set(dict);
return (value: string) => {

View file

@ -10,7 +10,7 @@ import { i18n } from '@kbn/i18n';
import type { DocLinksStart } from '@kbn/core/public';
import { JOB_ID_MAX_LENGTH, VALIDATION_STATUS } from './validation';
import { JOB_ID_MAX_LENGTH, VALIDATION_STATUS } from '@kbn/ml-validators';
import { renderTemplate } from '../util/string_utils';

View file

@ -5,7 +5,6 @@
* 2.0.
*/
export { composeValidators, patternValidator } from './util/validators';
export { getDefaultCapabilities as getDefaultMlCapabilities } from './types/capabilities';
export { DATAFEED_STATE, JOB_STATE } from './constants/states';
export type { MlSummaryJob, SummaryJobState } from './types/anomaly_detection_jobs';

View file

@ -6,10 +6,12 @@
*/
import { pick } from 'lodash';
import { isDefined } from '@kbn/ml-is-defined';
import { parseInterval } from '@kbn/ml-parse-interval';
import type { CombinedJobWithStats, Datafeed, Job } from '../types/anomaly_detection_jobs';
import { resolveMaxTimeInterval } from './job_utils';
import { parseInterval } from './parse_interval';
import type { JobsHealthRuleTestsConfig, JobsHealthTests } from '../types/alerts';
const narrowBucketLength = 60;

View file

@ -9,14 +9,15 @@ import { cloneDeep, each, isEmpty, isEqual, pick } from 'lodash';
import semverGte from 'semver/functions/gte';
import type { Duration } from 'moment';
import moment from 'moment';
import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
import numeral from '@elastic/numeral';
import { i18n } from '@kbn/i18n';
import type { Filter } from '@kbn/es-query';
import { isPopulatedObject } from '@kbn/ml-is-populated-object';
import type { SerializableRecord } from '@kbn/utility-types';
import { FilterStateStore } from '@kbn/es-query';
import type { QueryDslQueryContainer } from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
import { isDefined } from '@kbn/ml-is-defined';
import {
type MlEntityField,
@ -24,9 +25,9 @@ import {
ML_JOB_AGGREGATION,
MLCATEGORY,
} from '@kbn/ml-anomaly-utils';
import { ALLOWED_DATA_UNITS, JOB_ID_MAX_LENGTH } from '../constants/validation';
import { parseInterval } from './parse_interval';
import { maxLengthValidator } from './validators';
import { maxLengthValidator, ALLOWED_DATA_UNITS, JOB_ID_MAX_LENGTH } from '@kbn/ml-validators';
import { parseInterval } from '@kbn/ml-parse-interval';
import { CREATED_BY_LABEL } from '../constants/new_job';
import type {
CombinedJob,
@ -875,7 +876,7 @@ export function resolveMaxTimeInterval(timeIntervals: estypes.Duration[]): numbe
}
export function getFiltersForDSLQuery(
datafeedQuery: QueryDslQueryContainer,
datafeedQuery: estypes.QueryDslQueryContainer,
dataViewId: string | undefined,
alias?: string,
store = FilterStateStore.APP_STATE
@ -903,7 +904,7 @@ export function getFiltersForDSLQuery(
}
// check to see if the query is a known "empty" shape
export function isKnownEmptyQuery(query: QueryDslQueryContainer) {
export function isKnownEmptyQuery(query: estypes.QueryDslQueryContainer) {
const queries = [
// the default query used by the job wizards
{ bool: { must: [{ match_all: {} }] } },

View file

@ -5,7 +5,7 @@
* 2.0.
*/
import { VALIDATION_STATUS } from '../constants/validation';
import { VALIDATION_STATUS } from '@kbn/ml-validators';
// get the most severe status level from a list of messages
const contains = (arr: string[], str: string) => arr.indexOf(str) >= 0;

View file

@ -10,7 +10,7 @@ import React from 'react';
import { FormattedMessage } from '@kbn/i18n-react';
import { EuiCallOut, EuiSpacer } from '@elastic/eui';
import { parseInterval } from '../../../common/util/parse_interval';
import { parseInterval } from '@kbn/ml-parse-interval';
import { type CombinedJobWithStats } from '../../../common/types/anomaly_detection_jobs';
import { DATAFEED_STATE } from '../../../common/constants/states';
import { type MlAnomalyDetectionAlertParams } from '../../../common/types/alerts';

View file

@ -14,6 +14,7 @@ import type { RuleTypeParamsExpressionProps } from '@kbn/triggers-actions-ui-plu
import { isDefined } from '@kbn/ml-is-defined';
import { ML_ANOMALY_RESULT_TYPE, ML_ANOMALY_THRESHOLD } from '@kbn/ml-anomaly-utils';
import { useKibana } from '@kbn/kibana-react-plugin/public';
import { parseInterval } from '@kbn/ml-parse-interval';
import type { MlCapabilities } from '../../../common/types/capabilities';
import { ML_PAGES } from '../../../common/constants/locator';
import type { MlCoreSetup } from '../../plugin';
@ -34,7 +35,6 @@ import { ConfigValidator } from './config_validator';
import { type CombinedJobWithStats } from '../../../common/types/anomaly_detection_jobs';
import { AdvancedSettings } from './advanced_settings';
import { getLookbackInterval, getTopNBuckets } from '../../../common/util/alerts';
import { parseInterval } from '../../../common/util/parse_interval';
export type MlAnomalyAlertTriggerProps =
RuleTypeParamsExpressionProps<MlAnomalyDetectionAlertParams> & {

View file

@ -24,10 +24,13 @@ import {
EuiSpacer,
EuiText,
} from '@elastic/eui';
import {
composeValidators,
requiredValidator,
timeIntervalInputValidator,
} from '@kbn/ml-validators';
import type { AlertingApiService } from '../../application/services/ml_api_service/alerting';
import type { MlAnomalyDetectionAlertParams, PreviewResponse } from '../../../common/types/alerts';
import { composeValidators } from '../../../common';
import { requiredValidator, timeIntervalInputValidator } from '../../../common/util/validators';
import { invalidTimeIntervalMessage } from '../../application/jobs/new_job/common/job_validator/util';
import { ALERT_PREVIEW_SAMPLE_SIZE } from '../../../common/constants/alerts';

View file

@ -5,13 +5,15 @@
* 2.0.
*/
import type { EuiFieldTextProps } from '@elastic/eui';
import { EuiFieldText, EuiFormRow } from '@elastic/eui';
import type { FC, ReactNode } from 'react';
import React, { useMemo } from 'react';
import type { EuiFieldTextProps } from '@elastic/eui';
import { EuiFieldText, EuiFormRow } from '@elastic/eui';
import { composeValidators, timeIntervalInputValidator } from '@kbn/ml-validators';
import { invalidTimeIntervalMessage } from '../application/jobs/new_job/common/job_validator/util';
import { composeValidators } from '../../common';
import { timeIntervalInputValidator } from '../../common/util/validators';
type TimeIntervalControlProps = Omit<EuiFieldTextProps, 'value' | 'onChange'> & {
label: string | ReactNode;

View file

@ -6,6 +6,7 @@
*/
import { numberValidator } from '@kbn/ml-agg-utils';
import { timeIntervalInputValidator } from '../../common/util/validators';
import { timeIntervalInputValidator } from '@kbn/ml-validators';
export const validateLookbackInterval = timeIntervalInputValidator();
export const validateTopNBucket = numberValidator({ min: 1, integerOnly: true });

View file

@ -13,9 +13,9 @@ import { EuiFlexGroup, EuiFlexItem } from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n-react';
import { ChangePointDetection } from '@kbn/aiops-plugin/public';
import { useFieldStatsTrigger, FieldStatsFlyoutProvider } from '@kbn/ml-field-stats-flyout';
import { useDataSource } from '../contexts/ml/data_source_context';
import { useFieldStatsTrigger, FieldStatsFlyoutProvider } from '../components/field_stats_flyout';
import { useMlKibana } from '../contexts/kibana';
import { HelpMenu } from '../components/help_menu';
import { TechnicalPreviewBadge } from '../components/technical_preview_badge';

View file

@ -45,10 +45,10 @@ import { escapeQuotes } from '@kbn/es-query';
import { isQuery } from '@kbn/data-plugin/public';
import type { TimeRangeBounds } from '@kbn/ml-time-buckets';
import { parseInterval } from '@kbn/ml-parse-interval';
import { PLUGIN_ID } from '../../../../common/constants/app';
import { findMessageField } from '../../util/index_utils';
import { getInitialAnomaliesLayers, getInitialSourceIndexFieldLayers } from '../../../maps/util';
import { parseInterval } from '../../../../common/util/parse_interval';
import { ML_APP_LOCATOR, ML_PAGES } from '../../../../common/constants/locator';
import { getFiltersForDSLQuery } from '../../../../common/util/job_utils';

View file

@ -9,8 +9,8 @@ import type { FC } from 'react';
import React from 'react';
import { EuiCallOut, EuiLink, EuiSpacer } from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n-react';
import type { CalloutMessage } from '../../../../common/constants/validation';
import { VALIDATION_STATUS } from '../../../../common/constants/validation';
import type { CalloutMessage } from '@kbn/ml-validators';
import { VALIDATION_STATUS } from '@kbn/ml-validators';
export const defaultIconType = 'questionInCircle';

View file

@ -28,13 +28,13 @@ import {
type DataFrameAnalyticsConfig,
} from '@kbn/ml-data-frame-analytics-utils';
import { parseUrlState } from '@kbn/ml-url-state';
import { parseInterval } from '@kbn/ml-parse-interval';
import { useMlApi, useMlKibana } from '../../../contexts/kibana';
import { useToastNotificationService } from '../../../services/toast_notification_service';
import { isValidLabel, openCustomUrlWindow } from '../../../util/custom_url_utils';
import { getTestUrl } from './utils';
import { parseInterval } from '../../../../../common/util/parse_interval';
import { TIME_RANGE_TYPE } from './constants';
import type { Job } from '../../../../../common/types/anomaly_detection_jobs';

View file

@ -25,8 +25,9 @@ import {
type DataFrameAnalyticsConfig,
DEFAULT_RESULTS_FIELD,
} from '@kbn/ml-data-frame-analytics-utils';
import { isDefined } from '@kbn/ml-is-defined';
import { parseInterval } from '@kbn/ml-parse-interval';
import type { DashboardItems } from '../../../services/dashboard_service';
import { categoryFieldTypes } from '../../../../../common/util/fields_utils';
import { TIME_RANGE_TYPE, URL_TYPE } from './constants';
@ -35,7 +36,6 @@ import {
getPartitioningFieldNames,
getFiltersForDSLQuery,
} from '../../../../../common/util/job_utils';
import { parseInterval } from '../../../../../common/util/parse_interval';
import { replaceStringTokens } from '../../../util/string_utils';
import {
replaceTokensInUrlValue,

View file

@ -1,17 +0,0 @@
/*
* 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 { FieldStatsFlyout } from './field_stats_flyout';
export { FieldStatsContent } from './field_stats_content';
export { FieldStatsFlyoutProvider } from './field_stats_flyout_provider';
export {
MLFieldStatsFlyoutContext,
useFieldStatsFlyoutContext,
} from './use_field_stats_flytout_context';
export { FieldStatsInfoButton } from './field_stats_info_button';
export { useFieldStatsTrigger } from './use_field_stats_trigger';
export { EuiComboBoxWithFieldStats } from './eui_combo_box_with_field_stats';

View file

@ -6,11 +6,13 @@
*/
import { useCallback } from 'react';
import { i18n } from '@kbn/i18n';
import { JOB_ID_MAX_LENGTH } from '@kbn/ml-validators';
import type { JobType } from '../../../../../common/types/saved_objects';
import { isValidIndexName } from '../../../../../common/util/es_utils';
import { isJobIdValid } from '../../../../../common/util/job_utils';
import { JOB_ID_MAX_LENGTH } from '../../../../../common/constants/validation';
import type { JobIdObject } from './jobs_import_service';
import { useMlApi } from '../../../contexts/kibana';

View file

@ -31,6 +31,7 @@ import {
import { i18n } from '@kbn/i18n';
import { FormattedMessage } from '@kbn/i18n-react';
import { timeFormatter } from '@kbn/ml-date-utils';
import { parseInterval } from '@kbn/ml-parse-interval';
import type {
ModelSnapshot,
@ -42,7 +43,6 @@ import { mlResultsServiceProvider } from '../../../services/results_service';
import type { LineChartPoint } from '../../../jobs/new_job/common/chart_loader';
import { EventRateChart } from '../../../jobs/new_job/pages/components/charts/event_rate_chart/event_rate_chart';
import type { Anomaly } from '../../../jobs/new_job/common/results_loader/results_loader';
import { parseInterval } from '../../../../../common/util/parse_interval';
import type { CalendarEvent } from './create_calendar';
import { CreateCalendar } from './create_calendar';

View file

@ -25,9 +25,9 @@ import {
} from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n-react';
import { VALIDATION_STATUS } from '@kbn/ml-validators';
import { parseMessages } from '../../../../common/constants/messages';
import { VALIDATION_STATUS } from '../../../../common/constants/validation';
import { Callout, statusToEuiIconType } from '../callout';
import { getMostSevereMessageStatus } from '../../../../common/util/validation_utils';
import { toastNotificationServiceProvider } from '../../services/toast_notification_service';

View file

@ -21,9 +21,12 @@ import { i18n } from '@kbn/i18n';
import { FormattedMessage } from '@kbn/i18n-react';
import type { ES_FIELD_TYPES } from '@kbn/field-types';
import type { FieldSelectionItem } from '@kbn/ml-data-frame-analytics-utils';
import { useFieldStatsTrigger } from '../../../../../components/field_stats_flyout/use_field_stats_trigger';
import type { FieldForStats } from '../../../../../components/field_stats_flyout/field_stats_info_button';
import { FieldStatsInfoButton } from '../../../../../components/field_stats_flyout/field_stats_info_button';
import {
useFieldStatsTrigger,
FieldStatsInfoButton,
type FieldForStats,
} from '@kbn/ml-field-stats-flyout';
// @ts-ignore could not find declaration file
import { CustomSelectionTable } from '../../../../../components/custom_selection_table';

View file

@ -29,12 +29,13 @@ import {
} from '@kbn/ml-data-frame-analytics-utils';
import { DataGrid } from '@kbn/ml-data-grid';
import { SEARCH_QUERY_LANGUAGE } from '@kbn/ml-query-utils';
import { useMlApi, useMlKibana } from '../../../../../contexts/kibana';
import {
EuiComboBoxWithFieldStats,
FieldStatsFlyoutProvider,
} from '../../../../../components/field_stats_flyout';
import type { FieldForStats } from '../../../../../components/field_stats_flyout/field_stats_info_button';
type FieldForStats,
} from '@kbn/ml-field-stats-flyout';
import { useMlApi, useMlKibana } from '../../../../../contexts/kibana';
import { useNewJobCapsServiceAnalytics } from '../../../../../services/new_job_capabilities/new_job_capabilities_service_analytics';
import { useDataSource } from '../../../../../contexts/ml';

View file

@ -13,10 +13,10 @@ import { i18n } from '@kbn/i18n';
import { extractErrorMessage } from '@kbn/ml-error-utils';
import { CreateDataViewForm } from '@kbn/ml-data-view-utils/components/create_data_view_form_row';
import { DestinationIndexForm } from '@kbn/ml-creation-wizard-utils/components/destination_index_form';
import { JOB_ID_MAX_LENGTH } from '@kbn/ml-validators';
import { useMlApi, useMlKibana } from '../../../../../contexts/kibana';
import type { CreateAnalyticsStepProps } from '../../../analytics_management/hooks/use_create_analytics_form';
import { JOB_ID_MAX_LENGTH } from '../../../../../../../common/constants/validation';
import { ContinueButton } from '../continue_button';
import { ANALYTICS_STEPS } from '../../page';
import { useCanCreateDataView } from '../../hooks/use_can_create_data_view';

View file

@ -9,7 +9,8 @@ import type { FC } from 'react';
import React from 'react';
import { EuiLoadingSpinner, EuiSpacer } from '@elastic/eui';
import type { CalloutMessage } from '../../../../../../../common/constants/validation';
import type { CalloutMessage } from '@kbn/ml-validators';
import { Callout } from '../../../../../components/callout';
import { ANALYTICS_STEPS } from '../../page';
import { ContinueButton } from '../continue_button';

View file

@ -13,6 +13,8 @@ import { EuiForm } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import { extractErrorMessage } from '@kbn/ml-error-utils';
import type { CalloutMessage, ValidateAnalyticsJobResponse } from '@kbn/ml-validators';
import { VALIDATION_STATUS } from '@kbn/ml-validators';
import type { CreateAnalyticsStepProps } from '../../../analytics_management/hooks/use_create_analytics_form';
import { ValidationStep } from './validation_step';
@ -20,11 +22,6 @@ import { ValidationStepDetails } from './validation_step_details';
import { ANALYTICS_STEPS } from '../../page';
import { useMlApi } from '../../../../../contexts/kibana';
import { getJobConfigFromFormState } from '../../../analytics_management/hooks/use_create_analytics_form/state';
import type {
CalloutMessage,
ValidateAnalyticsJobResponse,
} from '../../../../../../../common/constants/validation';
import { VALIDATION_STATUS } from '../../../../../../../common/constants/validation';
export interface ValidationSummary {
warning: number;

View file

@ -39,6 +39,7 @@ import {
import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
import { SEARCH_QUERY_LANGUAGE } from '@kbn/ml-query-utils';
import { parseInterval } from '@kbn/ml-parse-interval';
import type { useColorRange } from '../../../../../components/color_range_legend';
import { ColorRangeLegend } from '../../../../../components/color_range_legend';
@ -51,7 +52,6 @@ import {
openCustomUrlWindow,
} from '../../../../../util/custom_url_utils';
import { replaceStringTokens } from '../../../../../util/string_utils';
import { parseInterval } from '../../../../../../../common/util/parse_interval';
import type { ExpandableSectionProps } from '.';
import { ExpandableSection, HEADER_ITEMS_LOADING } from '.';

View file

@ -35,11 +35,11 @@ import {
type DataFrameAnalyticsConfig,
type UpdateDataFrameAnalyticsConfig,
} from '@kbn/ml-data-frame-analytics-utils';
import type { MemoryInputValidatorResult } from '@kbn/ml-validators';
import { memoryInputValidator } from '@kbn/ml-validators';
import { useMlKibana, useMlApi } from '../../../../../contexts/kibana';
import { useToastNotificationService } from '../../../../../services/toast_notification_service';
import type { MemoryInputValidatorResult } from '../../../../../../../common/util/validators';
import { memoryInputValidator } from '../../../../../../../common/util/validators';
import { useRefreshAnalyticsList } from '../../../../common/analytics';
import type { EditAction } from './use_edit_action';

View file

@ -24,6 +24,14 @@ import {
TRAINING_PERCENT_MIN,
TRAINING_PERCENT_MAX,
} from '@kbn/ml-data-frame-analytics-utils';
import {
composeValidators,
maxLengthValidator,
memoryInputValidator,
requiredValidator,
JOB_ID_MAX_LENGTH,
ALLOWED_DATA_UNITS,
} from '@kbn/ml-validators';
import { isValidIndexName } from '../../../../../../../common/util/es_utils';
@ -35,16 +43,6 @@ import {
isJobIdValid,
validateModelMemoryLimitUnits,
} from '../../../../../../../common/util/job_utils';
import {
composeValidators,
maxLengthValidator,
memoryInputValidator,
requiredValidator,
} from '../../../../../../../common/util/validators';
import {
JOB_ID_MAX_LENGTH,
ALLOWED_DATA_UNITS,
} from '../../../../../../../common/constants/validation';
import { isAdvancedConfig } from '../../components/action_clone/clone_action_name';
const { collapseLiteralStrings } = XJson;

View file

@ -27,6 +27,7 @@ import {
import type { InfluencersFilterQuery } from '@kbn/ml-anomaly-utils';
import type { TimeRangeBounds } from '@kbn/ml-time-buckets';
import type { IUiSettingsClient } from '@kbn/core/public';
import { parseInterval } from '@kbn/ml-parse-interval';
import {
ANNOTATIONS_TABLE_DEFAULT_QUERY_SIZE,
@ -39,7 +40,6 @@ import {
isModelPlotEnabled,
isTimeSeriesViewJob,
} from '../../../common/util/job_utils';
import { parseInterval } from '../../../common/util/parse_interval';
import type { MlJobService } from '../services/job_service';
import type { SwimlaneType } from './explorer_constants';

View file

@ -17,11 +17,12 @@ import {
EuiCallOut,
} from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n-react';
import { parseInterval } from '@kbn/ml-parse-interval';
import { calculateDatafeedFrequencyDefaultSeconds } from '../../../../../../../common/util/job_utils';
import { getNewJobDefaults } from '../../../../../services/ml_server_info';
import { parseInterval } from '../../../../../../../common/util/parse_interval';
import { MLJobEditor, ML_EDITOR_MODE } from '../../ml_job_editor';
import { FormattedMessage } from '@kbn/i18n-react';
function getDefaults(bucketSpan, jobDefaults) {
const bucketSpanSeconds = bucketSpan !== undefined ? parseInterval(bucketSpan).asSeconds() : '';

View file

@ -6,13 +6,14 @@
*/
import { each } from 'lodash';
import { i18n } from '@kbn/i18n';
import { parseInterval } from '@kbn/ml-parse-interval';
import { toastNotificationServiceProvider } from '../../../services/toast_notification_service';
import { stringMatch } from '../../../util/string_utils';
import { JOB_STATE, DATAFEED_STATE } from '../../../../../common/constants/states';
import { JOB_ACTION } from '../../../../../common/constants/job_actions';
import { parseInterval } from '../../../../../common/util/parse_interval';
import { mlCalendarService } from '../../../services/calendar_service';
import { jobCloningService } from '../../../services/job_cloning_service';
import { ML_PAGES } from '../../../../../common/constants/locator';

View file

@ -7,6 +7,7 @@
import { BehaviorSubject } from 'rxjs';
import { cloneDeep } from 'lodash';
import { ES_FIELD_TYPES } from '@kbn/field-types';
import type { Query } from '@kbn/es-query';
import type { DataView } from '@kbn/data-views-plugin/public';
@ -22,6 +23,8 @@ import {
import type { RuntimeMappings } from '@kbn/ml-runtime-field-utils';
import type { SavedSearch } from '@kbn/saved-search-plugin/public';
import { isPopulatedObject } from '@kbn/ml-is-populated-object';
import { parseInterval } from '@kbn/ml-parse-interval';
import { createDatafeedId } from '../../../../../../common/util/job_utils';
import type { MlApi } from '../../../../services/ml_api_service';
import type { IndexPatternTitle } from '../../../../../../common/types/kibana';
@ -42,7 +45,6 @@ import type { CREATED_BY_LABEL } from '../../../../../../common/constants/new_jo
import { JOB_TYPE, SHARED_RESULTS_INDEX_NAME } from '../../../../../../common/constants/new_job';
import { collectAggs } from './util/general';
import { filterRuntimeMappings } from './util/filter_runtime_mappings';
import { parseInterval } from '../../../../../../common/util/parse_interval';
import type { Calendar } from '../../../../../../common/types/calendars';
import { mlCalendarService } from '../../../../services/calendar_service';
import { getDatafeedAggregations } from '../../../../../../common/util/datafeed_utils';

View file

@ -15,8 +15,9 @@ import {
ES_AGGREGATION,
} from '@kbn/ml-anomaly-utils';
import type { SavedSearch } from '@kbn/saved-search-plugin/public';
import { parseInterval } from '@kbn/ml-parse-interval';
import type { MlApi } from '../../../../services/ml_api_service';
import { parseInterval } from '../../../../../../common/util/parse_interval';
import { JobCreator } from './job_creator';
import type {
Job,

View file

@ -5,14 +5,13 @@
* 2.0.
*/
import { i18n } from '@kbn/i18n';
import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
import { i18n } from '@kbn/i18n';
import { ALLOWED_DATA_UNITS, JOB_ID_MAX_LENGTH } from '@kbn/ml-validators';
import type { BasicValidations } from './job_validator';
import type { Job, Datafeed } from '../../../../../../common/types/anomaly_detection_jobs';
import {
ALLOWED_DATA_UNITS,
JOB_ID_MAX_LENGTH,
} from '../../../../../../common/constants/validation';
import { getNewJobLimits } from '../../../../services/ml_server_info';
import type { ValidationResults } from '../../../../../../common/util/job_utils';

View file

@ -10,8 +10,8 @@ import { BehaviorSubject, lastValueFrom } from 'rxjs';
import type { ML_ANOMALY_SEVERITY } from '@kbn/ml-anomaly-utils';
import { getSeverityType, ES_AGGREGATION } from '@kbn/ml-anomaly-utils';
import type { TimeBuckets } from '@kbn/ml-time-buckets';
import { parseInterval } from '@kbn/ml-parse-interval';
import { parseInterval } from '../../../../../../common/util/parse_interval';
import { JOB_TYPE } from '../../../../../../common/constants/new_job';
import type { ModelPlotOutputResults } from '../../../../services/results_service';

View file

@ -8,6 +8,7 @@
import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
import type { FC } from 'react';
import React, { Fragment, useState, useContext, useEffect } from 'react';
import type { EuiComboBoxOptionOption } from '@elastic/eui';
import {
EuiComboBox,
@ -17,13 +18,15 @@ import {
EuiHorizontalRule,
EuiTextArea,
} from '@elastic/eui';
import {
type Field,
type Aggregation,
EVENT_RATE_FIELD_ID,
mlCategory,
} from '@kbn/ml-anomaly-utils';
import { useFieldStatsTrigger } from '../../../../../../../components/field_stats_flyout/use_field_stats_trigger';
import { useFieldStatsTrigger } from '@kbn/ml-field-stats-flyout';
import { JobCreatorContext } from '../../../job_creator_context';
import type { AdvancedJobCreator } from '../../../../../common/job_creator';
import {

View file

@ -11,9 +11,8 @@ import type { EuiComboBoxOptionOption } from '@elastic/eui';
import { EuiComboBox, EuiFormRow } from '@elastic/eui';
import type { Field, Aggregation, AggFieldPair } from '@kbn/ml-anomaly-utils';
import { EVENT_RATE_FIELD_ID } from '@kbn/ml-anomaly-utils';
import { FieldStatsInfoButton } from '../../../../../../../components/field_stats_flyout/field_stats_info_button';
import { useFieldStatsTrigger, FieldStatsInfoButton } from '@kbn/ml-field-stats-flyout';
import { JobCreatorContext } from '../../../job_creator_context';
import { useFieldStatsTrigger } from '../../../../../../../components/field_stats_flyout/use_field_stats_trigger';
// The display label used for an aggregation e.g. sum(bytes).
export type Label = string;

View file

@ -11,7 +11,8 @@ import type { EuiComboBoxOptionOption } from '@elastic/eui';
import { EuiComboBox } from '@elastic/eui';
import type { Field } from '@kbn/ml-anomaly-utils';
import { useFieldStatsTrigger } from '../../../../../../../components/field_stats_flyout/use_field_stats_trigger';
import { useFieldStatsTrigger } from '@kbn/ml-field-stats-flyout';
import { JobCreatorContext } from '../../../job_creator_context';
import { createFieldOptions } from '../../../../../common/job_creator/util/general';

View file

@ -11,7 +11,7 @@ import type { EuiComboBoxOptionOption } from '@elastic/eui';
import { EuiComboBox } from '@elastic/eui';
import type { Field } from '@kbn/ml-anomaly-utils';
import { useFieldStatsTrigger } from '../../../../../../../components/field_stats_flyout/use_field_stats_trigger';
import { useFieldStatsTrigger } from '@kbn/ml-field-stats-flyout';
import { JobCreatorContext } from '../../../job_creator_context';
import { createFieldOptions } from '../../../../../common/job_creator/util/general';

View file

@ -10,7 +10,7 @@ import React, { useCallback, useMemo } from 'react';
import type { EuiComboBoxOptionOption } from '@elastic/eui';
import { EuiComboBox } from '@elastic/eui';
import type { Field } from '@kbn/ml-anomaly-utils';
import { useFieldStatsTrigger } from '../../../../../../../components/field_stats_flyout/use_field_stats_trigger';
import { useFieldStatsTrigger } from '@kbn/ml-field-stats-flyout';
interface DropDownLabel {
label: string;

View file

@ -11,7 +11,8 @@ import type { EuiComboBoxOptionOption } from '@elastic/eui';
import { EuiComboBox } from '@elastic/eui';
import type { Field } from '@kbn/ml-anomaly-utils';
import { useFieldStatsTrigger } from '../../../../../../../components/field_stats_flyout/use_field_stats_trigger';
import { useFieldStatsTrigger } from '@kbn/ml-field-stats-flyout';
import { JobCreatorContext } from '../../../job_creator_context';
import {
createFieldOptions,

View file

@ -10,7 +10,7 @@ import React from 'react';
import type { EuiComboBoxOptionOption } from '@elastic/eui';
import { EuiComboBox } from '@elastic/eui';
import type { Field, SplitField } from '@kbn/ml-anomaly-utils';
import { useFieldStatsTrigger } from '../../../../../../../components/field_stats_flyout/use_field_stats_trigger';
import { useFieldStatsTrigger } from '@kbn/ml-field-stats-flyout';
interface DropDownLabel {
label: string;

View file

@ -11,7 +11,7 @@ import type { EuiComboBoxOptionOption } from '@elastic/eui';
import { EuiComboBox } from '@elastic/eui';
import type { Field, SplitField } from '@kbn/ml-anomaly-utils';
import { useFieldStatsTrigger } from '../../../../../../../components/field_stats_flyout/use_field_stats_trigger';
import { useFieldStatsTrigger } from '@kbn/ml-field-stats-flyout';
interface DropDownLabel {
label: string;

View file

@ -11,7 +11,8 @@ import type { EuiComboBoxOptionOption } from '@elastic/eui';
import { EuiComboBox } from '@elastic/eui';
import type { Field } from '@kbn/ml-anomaly-utils';
import { useFieldStatsTrigger } from '../../../../../../../components/field_stats_flyout/use_field_stats_trigger';
import { useFieldStatsTrigger } from '@kbn/ml-field-stats-flyout';
import { JobCreatorContext } from '../../../job_creator_context';
import {
createFieldOptions,

View file

@ -8,7 +8,8 @@
import type { FC } from 'react';
import React, { Fragment, useContext, useEffect, useState } from 'react';
import { useFieldStatsFlyoutContext } from '../../../../../components/field_stats_flyout';
import { useFieldStatsFlyoutContext } from '@kbn/ml-field-stats-flyout';
import { JobCreatorContext } from '../job_creator_context';
import { WizardNav } from '../wizard_nav';
import type { StepProps } from '../step_types';

View file

@ -13,9 +13,9 @@ import { FormattedMessage } from '@kbn/i18n-react';
import { EuiSpacer, EuiTitle, EuiFlexGroup, EuiFlexItem } from '@elastic/eui';
import type { FieldStatsServices } from '@kbn/unified-field-list/src/components/field_stats';
import { FieldStatsFlyoutProvider } from '@kbn/ml-field-stats-flyout';
import { JobCreatorContext } from '../components/job_creator_context';
import { useMlKibana } from '../../../../contexts/kibana';
import { FieldStatsFlyoutProvider } from '../../../../components/field_stats_flyout';
import { WIZARD_STEPS } from '../components/step_types';
import { TimeRangeStep } from '../components/time_range_step';

View file

@ -7,6 +7,7 @@
import type { FC } from 'react';
import React, { useEffect, useState } from 'react';
import {
EuiButton,
EuiButtonEmpty,
@ -21,12 +22,14 @@ import {
EuiSpacer,
EuiTitle,
} from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n-react';
import { composeValidators, maxLengthValidator } from '@kbn/ml-validators';
import { JOB_ID_MAX_LENGTH } from '@kbn/ml-validators';
import type { ModuleJobUI } from '../page';
import { usePartialState } from '../../../../components/custom_hooks';
import { composeValidators, maxLengthValidator } from '../../../../../../common/util/validators';
import { isJobIdValid } from '../../../../../../common/util/job_utils';
import { JOB_ID_MAX_LENGTH } from '../../../../../../common/constants/validation';
import { JobGroupsInput } from '../../common/components';
import type { JobOverride } from '../../../../../../common/types/modules';

View file

@ -7,6 +7,7 @@
import type { FC } from 'react';
import React, { useEffect, useState, useCallback, useMemo } from 'react';
import { i18n } from '@kbn/i18n';
import { FormattedMessage } from '@kbn/i18n-react';
import {
@ -21,15 +22,16 @@ import {
EuiTextAlign,
} from '@elastic/eui';
import { getTimeFilterRange, useTimefilter } from '@kbn/ml-date-picker';
import { useDataSource } from '../../../../contexts/ml/data_source_context';
import type { ModuleJobUI } from '../page';
import { SAVE_STATE } from '../page';
import {
composeValidators,
maxLengthValidator,
patternValidator,
} from '../../../../../../common/util/validators';
import { JOB_ID_MAX_LENGTH } from '../../../../../../common/constants/validation';
JOB_ID_MAX_LENGTH,
} from '@kbn/ml-validators';
import { useDataSource } from '../../../../contexts/ml/data_source_context';
import type { ModuleJobUI } from '../page';
import { SAVE_STATE } from '../page';
import type { TimeRange } from '../../common/components';
import { TimeRangePicker } from '../../common/components';

View file

@ -18,28 +18,18 @@ import type { Filter, Query, DataViewBase } from '@kbn/es-query';
import type { IUiSettingsClient } from '@kbn/core/public';
import { getEsQueryConfig } from '@kbn/data-plugin/public';
import type { SavedSearch } from '@kbn/saved-search-plugin/public';
import { SEARCH_QUERY_LANGUAGE } from '@kbn/ml-query-utils';
import { getDefaultDSLQuery, SEARCH_QUERY_LANGUAGE } from '@kbn/ml-query-utils';
import { getQueryFromSavedSearchObject } from '../../../util/index_utils';
// Provider for creating the items used for searching and job creation.
const DEFAULT_DSL_QUERY: estypes.QueryDslQueryContainer = {
bool: {
must: [
{
match_all: {},
},
],
},
};
export const DEFAULT_QUERY: Query = {
query: '',
language: 'lucene',
};
export function getDefaultDatafeedQuery() {
return cloneDeep(DEFAULT_DSL_QUERY);
return getDefaultDSLQuery();
}
export function getDefaultQuery() {

View file

@ -32,12 +32,8 @@ import type { CoreStart, OverlayStart } from '@kbn/core/public';
import { css } from '@emotion/react';
import { numberValidator } from '@kbn/ml-agg-utils';
import { toMountPoint } from '@kbn/react-kibana-mount';
import { composeValidators, dictionaryValidator, requiredValidator } from '@kbn/ml-validators';
import { getNewJobLimits, isCloudTrial } from '../services/ml_server_info';
import {
composeValidators,
dictionaryValidator,
requiredValidator,
} from '../../../common/util/validators';
import type { ModelItem } from './models_list';
import { useEnabledFeatures } from '../contexts/ml';

View file

@ -7,7 +7,8 @@
import { cloneDeep, each, find, get } from 'lodash';
import { parseInterval } from '../../../common/util/parse_interval';
import { parseInterval } from '@kbn/ml-parse-interval';
import { createDatafeedId } from '../../../common/util/job_utils';
import { isWebUrl } from '../util/url_utils';

View file

@ -16,15 +16,16 @@ import type {
DeleteDataFrameAnalyticsWithIndexStatus,
UpdateDataFrameAnalyticsConfig,
} from '@kbn/ml-data-frame-analytics-utils';
import type { ValidateAnalyticsJobResponse } from '@kbn/ml-validators';
import { ML_INTERNAL_BASE_PATH } from '../../../../common/constants/app';
import type { HttpService } from '../http_service';
import { useMlKibana } from '../../contexts/kibana';
import type { ValidateAnalyticsJobResponse } from '../../../../common/constants/validation';
import type { JobMessage } from '../../../../common/types/audit_message';
import type { PutDataFrameAnalyticsResponseSchema } from '../../../../server/routes/schemas/data_frame_analytics_schema';
import { useMlKibana } from '../../contexts/kibana';
import type { HttpService } from '../http_service';
export interface GetDataFrameAnalyticsStatsResponseOk {
node_failures?: object;
count: number;

View file

@ -19,11 +19,11 @@ import { EuiToolTip } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import { context } from '@kbn/kibana-react-plugin/public';
import { extractErrorMessage } from '@kbn/ml-error-utils';
import { parseInterval } from '@kbn/ml-parse-interval';
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';
import { parseInterval } from '../../../../../common/util/parse_interval';
import { Modal } from './modal';
import { PROGRESS_STATES } from './progress_states';
import { forecastServiceFactory } from '../../../services/forecast_service';

View file

@ -18,7 +18,8 @@ import type {
MlCustomUrlAnomalyRecordDoc,
} from '@kbn/ml-anomaly-utils';
import type { DataGridItem } from '@kbn/ml-data-grid';
import { parseInterval } from '../../../common/util/parse_interval';
import { parseInterval } from '@kbn/ml-parse-interval';
import { escapeForElasticsearchQuery, replaceStringTokens } from './string_utils';
// Value of custom_url time_range property indicating drilldown time range is calculated automatically

View file

@ -6,18 +6,19 @@
*/
import { useMemo } from 'react';
import moment from 'moment';
import type { Observable } from 'rxjs';
import { forkJoin, of, catchError, map } from 'rxjs';
import { each, get } from 'lodash';
import type { IUiSettingsClient } from '@kbn/core/public';
import { aggregationTypeTransform } from '@kbn/ml-anomaly-utils';
import { isMultiBucketAnomaly, ML_JOB_AGGREGATION } from '@kbn/ml-anomaly-utils';
import { extractErrorMessage } from '@kbn/ml-error-utils';
import moment from 'moment';
import type { Observable } from 'rxjs';
import { forkJoin, of } from 'rxjs';
import { each, get } from 'lodash';
import { catchError, map } from 'rxjs';
import { type MlAnomalyRecordDoc } from '@kbn/ml-anomaly-utils';
import type { TimeRangeBounds, TimeBucketsInterval } from '@kbn/ml-time-buckets';
import { parseInterval } from '../../../common/util/parse_interval';
import { parseInterval } from '@kbn/ml-parse-interval';
import type { GetAnnotationsResponse } from '../../../common/types/annotations';
import { mlFunctionToESAggregation } from '../../../common/util/job_utils';
import { ANNOTATIONS_TABLE_DEFAULT_QUERY_SIZE } from '../../../common/constants/search';

View file

@ -8,8 +8,10 @@
import { isEqual } from 'lodash';
import type { Observable } from 'rxjs';
import { catchError, distinctUntilChanged, EMPTY, map, switchMap } from 'rxjs';
import { parseInterval } from '@kbn/ml-parse-interval';
import type { JobId } from '../../../common/types/anomaly_detection_jobs';
import { parseInterval } from '../../../common/util/parse_interval';
import type { ExplorerJob } from '../../application/explorer/explorer_utils';
import type { AnomalyDetectorService } from '../../application/services/anomaly_detector_service';

View file

@ -31,12 +31,13 @@ import { i18n } from '@kbn/i18n';
import { FormattedMessage } from '@kbn/i18n-react';
import { extractErrorMessage } from '@kbn/ml-error-utils';
import type { TimeRange } from '@kbn/es-query';
import { JOB_ID_MAX_LENGTH } from '@kbn/ml-validators';
import type { QuickLensJobCreator } from '../../../application/jobs/new_job/job_from_lens';
import type { LayerResult } from '../../../application/jobs/new_job/job_from_lens';
import type { CreateState } from '../../../application/jobs/new_job/job_from_dashboard';
import { JOB_TYPE, DEFAULT_BUCKET_SPAN } from '../../../../common/constants/new_job';
import { basicJobValidation } from '../../../../common/util/job_utils';
import { JOB_ID_MAX_LENGTH } from '../../../../common/constants/validation';
import { invalidTimeIntervalMessage } from '../../../application/jobs/new_job/common/job_validator/util';
import { ML_APP_LOCATOR, ML_PAGES } from '../../../../common/constants/locator';
import { useMlFromLensKibanaContext } from './context';

View file

@ -41,15 +41,5 @@ export { CONTROLLED_BY_SWIM_LANE_FILTER } from './ui_actions/constants';
export type { MlLocator } from './locator';
export { useMlHref, ML_PAGES, MlLocatorDefinition } from './locator';
// Bundled shared exports
// Exported this way so the code doesn't end up in ML's page load bundle
export const getMlSharedImports = async () => {
return await import('./shared');
};
// Helper to get Type returned by getMlSharedImports.
type AwaitReturnType<T> = T extends PromiseLike<infer U> ? U : T;
export type GetMlSharedImportsReturnType = AwaitReturnType<ReturnType<typeof getMlSharedImports>>;
export { MLJobsAwaitingNodeWarning } from './application/components/jobs_awaiting_node_warning/new_job_awaiting_node_shared';
export { MlNodeAvailableWarningShared } from './application/components/node_available_warning';

View file

@ -1,11 +0,0 @@
/*
* 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 { FieldStatsInfoButton } from './application/components/field_stats_flyout/field_stats_info_button';
export { useFieldStatsTrigger } from './application/components/field_stats_flyout/use_field_stats_trigger';
export { FieldStatsFlyoutProvider } from './application/components/field_stats_flyout/field_stats_flyout_provider';
export { useFieldStatsFlyoutContext } from './application/components/field_stats_flyout/use_field_stats_flytout_context';

Some files were not shown because too many files have changed in this diff Show more