Skip to content

Commit

Permalink
[ML] Update imports to use @kbn/field-types package (#147769)
Browse files Browse the repository at this point in the history
Where applicable, update imports to use `@kbn/field-types` package
instead of `@kbn/data-plugin/common` plugin. Should we move some of our
own code to packages, the import via the plugin wouldn't be allowed.
  • Loading branch information
walterra authored Dec 20, 2022
1 parent 687987a commit 612b16b
Show file tree
Hide file tree
Showing 47 changed files with 50 additions and 50 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

import { cloneDeep } from 'lodash';
import { IUiSettingsClient } from '@kbn/core/public';
import { SearchSource } from '@kbn/data-plugin/common';
import { getEsQueryConfig, SearchSource } from '@kbn/data-plugin/common';
import { SavedSearch } from '@kbn/discover-plugin/public';
import { FilterManager } from '@kbn/data-plugin/public';
import {
Expand All @@ -23,7 +23,6 @@ import {
} from '@kbn/es-query';
import { QueryDslQueryContainer } from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
import type { DataView } from '@kbn/data-views-plugin/public';
import { getEsQueryConfig } from '@kbn/data-plugin/common';
import type { SimpleSavedObject } from '@kbn/core/public';
import { isPopulatedObject } from '@kbn/ml-is-populated-object';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import React, { FC, useCallback, useMemo, useState } from 'react';
import { FormattedMessage } from '@kbn/i18n-react';
import { QueryDslQueryContainer } from '@elastic/elasticsearch/lib/api/types';
import { TimefilterContract } from '@kbn/data-plugin/public';
import { DataView } from '@kbn/data-plugin/common';
import type { DataView } from '@kbn/data-plugin/common';
import {
EuiButton,
EuiButtonIcon,
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/data_visualizer/common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import { i18n } from '@kbn/i18n';
import { KBN_FIELD_TYPES } from '@kbn/data-plugin/common';
import { KBN_FIELD_TYPES } from '@kbn/field-types';
import type { DocLinksStart } from '@kbn/core/public';

export const APP_ID = 'data_visualizer';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import { difference } from 'lodash';
import { ES_FIELD_TYPES } from '@kbn/data-plugin/common';
import { ES_FIELD_TYPES } from '@kbn/field-types';
import type { FindFileStructureResponse } from '@kbn/file-upload-plugin/common';
import type { SupportedFieldType } from '../../../../../common/types';
import { SUPPORTED_FIELD_TYPES } from '../../../../../common/constants';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { FormattedMessage } from '@kbn/i18n-react';
import classNames from 'classnames';
import { i18n } from '@kbn/i18n';
import { DataViewField } from '@kbn/data-views-plugin/public';
import { ES_FIELD_TYPES, KBN_FIELD_TYPES } from '@kbn/data-plugin/common';
import { ES_FIELD_TYPES, KBN_FIELD_TYPES } from '@kbn/field-types';
import { css } from '@emotion/react';
import { useDataVisualizerKibana } from '../../../kibana_context';
import { roundToDecimalPlace, kibanaFieldFormat } from '../utils';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import React, { FC, useCallback, useMemo, useState } from 'react';
import { FormattedMessage } from '@kbn/i18n-react';
import { TimefilterContract } from '@kbn/data-plugin/public';
import { DataView } from '@kbn/data-plugin/common';
import type { DataView } from '@kbn/data-plugin/common';

import {
EuiButton,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
import { merge } from 'rxjs';
import type { EuiTableActionsColumnType } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import { DataViewField, KBN_FIELD_TYPES, UI_SETTINGS } from '@kbn/data-plugin/common';
import { type DataViewField, UI_SETTINGS } from '@kbn/data-plugin/common';
import { KBN_FIELD_TYPES } from '@kbn/field-types';
import seedrandom from 'seedrandom';
import type { SamplingOption } from '@kbn/discover-plugin/public/application/main/components/field_stats_table/field_stats_table';
import type { RandomSamplerOption } from '../constants/random_sampler';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { encode } from '@kbn/rison';
import { stringify } from 'query-string';
import { SerializableRecord } from '@kbn/utility-types';
import { Filter, TimeRange } from '@kbn/es-query';
import { RefreshInterval } from '@kbn/data-plugin/common';
import type { RefreshInterval } from '@kbn/data-plugin/common';
import { LocatorDefinition, LocatorPublic } from '@kbn/share-plugin/common';
import { GlobalQueryStateFromUrl } from '@kbn/data-plugin/public';
import { Dictionary, isRisonSerializationRequired } from '../../common/util/url_state';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { find, get } from 'lodash';
import { catchError, map } from 'rxjs/operators';
import { Observable, of } from 'rxjs';
import { AggregationsTermsAggregation } from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
import {
import type {
IKibanaSearchRequest,
IKibanaSearchResponse,
ISearchOptions,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
import { get } from 'lodash';
import { Query } from '@kbn/es-query';
import { IKibanaSearchResponse } from '@kbn/data-plugin/common';
import type { IKibanaSearchResponse } from '@kbn/data-plugin/common';
import type { AggCardinality } from '@kbn/ml-agg-utils';
import { isPopulatedObject } from '@kbn/ml-is-populated-object';
import { buildAggregationWithSamplingOption } from './build_random_sampler_agg';
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/ml/common/types/fields.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
import { ES_FIELD_TYPES } from '@kbn/data-plugin/common';
import { ES_FIELD_TYPES } from '@kbn/field-types';
import {
ML_JOB_AGGREGATION,
KIBANA_AGGREGATION,
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/ml/common/util/fields_utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* 2.0.
*/

import { ES_FIELD_TYPES } from '@kbn/data-plugin/common';
import { ES_FIELD_TYPES } from '@kbn/field-types';
import {
Field,
Aggregation,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { i18n } from '@kbn/i18n';

import { CoreSetup } from '@kbn/core/public';

import { ES_FIELD_TYPES, KBN_FIELD_TYPES } from '@kbn/data-plugin/public';
import { ES_FIELD_TYPES, KBN_FIELD_TYPES } from '@kbn/field-types';

import type { DataView, DataViewField } from '@kbn/data-views-plugin/common';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { render } from '@testing-library/react';
import { renderHook } from '@testing-library/react-hooks';
import '@testing-library/jest-dom/extend-expect';

import { KBN_FIELD_TYPES } from '@kbn/data-plugin/public';
import { KBN_FIELD_TYPES } from '@kbn/field-types';

import {
isNumericChartData,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { euiPaletteColorBlind, EuiDataGridColumn } from '@elastic/eui';

import { i18n } from '@kbn/i18n';

import { KBN_FIELD_TYPES } from '@kbn/data-plugin/public';
import { KBN_FIELD_TYPES } from '@kbn/field-types';

import {
isNumericChartData,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* 2.0.
*/

import { ES_FIELD_TYPES, KBN_FIELD_TYPES } from '@kbn/data-plugin/public';
import { ES_FIELD_TYPES, KBN_FIELD_TYPES } from '@kbn/field-types';
import { getNumTopClasses, getNumTopFeatureImportanceValues } from './analytics';
import { Field } from '../../../../common/types/fields';
import {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* 2.0.
*/

import { ES_FIELD_TYPES } from '@kbn/data-plugin/public';
import { ES_FIELD_TYPES } from '@kbn/field-types';

import { newJobCapsServiceAnalytics } from '../../services/new_job_capabilities/new_job_capabilities_service_analytics';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import { i18n } from '@kbn/i18n';
import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
import { ES_FIELD_TYPES } from '@kbn/data-plugin/public';
import { ES_FIELD_TYPES } from '@kbn/field-types';
import { EVENT_RATE_FIELD_ID } from '../../../../../../../common/types/fields';
import { ANALYSIS_CONFIG_TYPE } from '../../../../common/analytics';
import { AnalyticsJobType } from '../../../analytics_management/hooks/use_create_analytics_form/state';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import React, { FC, Fragment, useState, useEffect } from 'react';
import { EuiSpacer, EuiText } from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n-react';

import { ES_FIELD_TYPES } from '@kbn/data-plugin/public';
import { ES_FIELD_TYPES } from '@kbn/field-types';
import { AnalyticsJobType } from '../../../analytics_management/hooks/use_create_analytics_form/state';
import { ANALYSIS_CONFIG_TYPE } from '../../../../common/analytics';
import { Field, EVENT_RATE_FIELD_ID } from '../../../../../../../common/types/fields';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* 2.0.
*/

import { KBN_FIELD_TYPES } from '@kbn/data-plugin/public';
import { KBN_FIELD_TYPES } from '@kbn/field-types';
import { MlJobFieldType } from '../../../../../common/types/field_types';

export interface FieldRequestConfig {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

import { get, union, uniq } from 'lodash';
import moment from 'moment-timezone';
import { ES_FIELD_TYPES } from '@kbn/data-plugin/public';
import { ES_FIELD_TYPES } from '@kbn/field-types';
import { asyncForEach } from '@kbn/std';
import { isPopulatedObject } from '@kbn/ml-is-populated-object';
import type { DataViewsContract } from '@kbn/data-views-plugin/public';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import { BehaviorSubject } from 'rxjs';
import { cloneDeep } from 'lodash';
import { ES_FIELD_TYPES } from '@kbn/data-plugin/public';
import { ES_FIELD_TYPES } from '@kbn/field-types';
import type { DataView } from '@kbn/data-views-plugin/public';
import { SavedSearchSavedObject } from '../../../../../../common/types/kibana';
import { UrlConfig } from '../../../../../../common/types/custom_urls';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import { i18n } from '@kbn/i18n';

import { ES_FIELD_TYPES } from '@kbn/data-plugin/public';
import { ES_FIELD_TYPES } from '@kbn/field-types';
import { Job, Datafeed, Detector } from '../../../../../../../common/types/anomaly_detection_jobs';
import { newJobCapsService } from '../../../../../services/new_job_capabilities/new_job_capabilities_service';
import { NavigateToPath } from '../../../../../contexts/kibana';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import type {
import type { SerializableRecord } from '@kbn/utility-types';
import type { SharePluginStart } from '@kbn/share-plugin/public';
import { layerTypes } from '@kbn/lens-plugin/public';
import { KBN_FIELD_TYPES } from '@kbn/data-plugin/public';
import { KBN_FIELD_TYPES } from '@kbn/field-types';

import { ML_PAGES, ML_APP_LOCATOR } from '../../../../../common/constants/locator';
import { ML_JOB_AGGREGATION } from '../../../../../common/constants/aggregation_types';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
EuiLink,
} from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n-react';
import { ES_FIELD_TYPES } from '@kbn/data-plugin/public';
import { ES_FIELD_TYPES } from '@kbn/field-types';
import { useMlKibana, useNavigateToPath } from '../../../../contexts/kibana';

import { useMlContext } from '../../../../contexts/ml';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* 2.0.
*/

import { ES_FIELD_TYPES } from '@kbn/data-plugin/public';
import { ES_FIELD_TYPES } from '@kbn/field-types';
import { Aggregation, Field, NewJobCaps } from '../../../../common/types/fields';

// create two lists, one removing text fields if there are keyword equivalents and vice versa
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
import { ES_FIELD_TYPES } from '@kbn/data-plugin/public';
import { ES_FIELD_TYPES } from '@kbn/field-types';
import type { DataView } from '@kbn/data-views-plugin/public';
import type { Field, Aggregation, AggId, FieldId } from '../../../../common/types/fields';
import { EVENT_RATE_FIELD_ID } from '../../../../common/types/fields';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* 2.0.
*/

import { ES_FIELD_TYPES } from '@kbn/data-plugin/public';
import { ES_FIELD_TYPES } from '@kbn/field-types';
import { DataView } from '@kbn/data-views-plugin/public';
import { Field, NewJobCapsResponse } from '../../../../common/types/fields';
import { processTextAndKeywordFields, NewJobCapabilitiesServiceBase } from './new_job_capabilities';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
* 2.0.
*/

import { KBN_FIELD_TYPES } from '@kbn/data-plugin/public';
import { DataViewField } from '@kbn/data-views-plugin/common';
import { KBN_FIELD_TYPES } from '@kbn/field-types';
import type { DataViewField } from '@kbn/data-views-plugin/common';
import { ML_JOB_FIELD_TYPES } from '../../../common/constants/field_types';
import {
kbnTypeToMLJobType,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

import { i18n } from '@kbn/i18n';

import { KBN_FIELD_TYPES } from '@kbn/data-plugin/public';
import { DataViewField } from '@kbn/data-views-plugin/common';
import { KBN_FIELD_TYPES } from '@kbn/field-types';
import type { DataViewField } from '@kbn/data-views-plugin/common';
import { ML_JOB_FIELD_TYPES } from '../../../common/constants/field_types';

// convert kibana types to ML Job types
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import { cloneDeep } from 'lodash';
import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
import type { IScopedClusterClient } from '@kbn/core/server';
import { ES_FIELD_TYPES } from '@kbn/data-plugin/common';
import { ES_FIELD_TYPES } from '@kbn/field-types';
import type { DataViewsService } from '@kbn/data-views-plugin/common';
import type { Field, FieldId, NewJobCaps, RollupFields } from '../../../../common/types/fields';
import { combineFieldsAndAggs } from '../../../../common/util/fields_utils';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import { IScopedClusterClient } from '@kbn/core/server';
import { ES_FIELD_TYPES } from '@kbn/data-plugin/server';
import { ES_FIELD_TYPES } from '@kbn/field-types';
import { parseInterval } from '../../../common/util/parse_interval';
import { CombinedJob } from '../../../common/types/anomaly_detection_jobs';
import { validateJobObject } from './validate_job_object';
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/transform/common/api_schemas/transforms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import { schema, TypeOf } from '@kbn/config-schema';

import type { ES_FIELD_TYPES } from '@kbn/data-plugin/common';
import type { ES_FIELD_TYPES } from '@kbn/field-types';

import type { Dictionary } from '../types/common';
import type { PivotAggDict } from '../types/pivot_aggs';
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/transform/public/app/common/pivot_aggs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import { FC } from 'react';

import { ES_FIELD_TYPES, KBN_FIELD_TYPES } from '@kbn/data-plugin/common';
import { ES_FIELD_TYPES, KBN_FIELD_TYPES } from '@kbn/field-types';
import { isPopulatedObject } from '@kbn/ml-is-populated-object';

import type { AggName } from '../../../common/types/aggregations';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* 2.0.
*/

import { KBN_FIELD_TYPES } from '@kbn/data-plugin/common';
import { KBN_FIELD_TYPES } from '@kbn/field-types';
import { isPopulatedObject } from '@kbn/ml-is-populated-object';
import { AggName } from '../../../common/types/aggregations';
import { Dictionary } from '../../../common/types/common';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';

import type { IHttpFetchError } from '@kbn/core-http-browser';

import { KBN_FIELD_TYPES } from '@kbn/data-plugin/public';
import { KBN_FIELD_TYPES } from '@kbn/field-types';

import type { TransformId } from '../../../../common/types/transform';
import type { FieldHistogramsResponseSchema } from '../../../../common/api_schemas/field_histograms';
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/transform/public/app/hooks/use_api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';

import type { IHttpFetchError } from '@kbn/core-http-browser';

import { KBN_FIELD_TYPES } from '@kbn/data-plugin/public';
import { KBN_FIELD_TYPES } from '@kbn/field-types';

import type { GetTransformsAuditMessagesResponseSchema } from '../../../common/api_schemas/audit_messages';
import type {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import { getCombinedProperties } from './use_pivot_data';
import { ES_FIELD_TYPES } from '@kbn/data-plugin/common';
import { ES_FIELD_TYPES } from '@kbn/field-types';

describe('getCombinedProperties', () => {
test('extracts missing mappings from docs', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { i18n } from '@kbn/i18n';
import { getFlattenedObject } from '@kbn/std';

import { difference } from 'lodash';
import { ES_FIELD_TYPES } from '@kbn/data-plugin/common';
import { ES_FIELD_TYPES } from '@kbn/field-types';

import type { PreviewMappingsProperties } from '../../../common/api_schemas/transforms';
import { isPostTransformsPreviewResponseSchema } from '../../../common/api_schemas/type_guards';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import React from 'react';
import { I18nProvider } from '@kbn/i18n-react';
import { FilterAggForm } from './filter_agg_form';
import { CreateTransformWizardContext } from '../../../../wizard/wizard';
import { KBN_FIELD_TYPES } from '@kbn/data-plugin/common';
import { KBN_FIELD_TYPES } from '@kbn/field-types';
import type { RuntimeField } from '@kbn/data-views-plugin/common';
import { DataView } from '@kbn/data-views-plugin/public';
import { FilterTermForm } from './filter_term_form';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* 2.0.
*/

import { KBN_FIELD_TYPES } from '@kbn/data-plugin/common';
import { KBN_FIELD_TYPES } from '@kbn/field-types';
import { FilterAggType } from './types';

export const FILTERS = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import { EuiComboBoxOptionOption } from '@elastic/eui';
import { ES_FIELD_TYPES, KBN_FIELD_TYPES } from '@kbn/data-plugin/public';
import { ES_FIELD_TYPES, KBN_FIELD_TYPES } from '@kbn/field-types';
import { DataView } from '@kbn/data-views-plugin/public';

import { getNestedProperty } from '../../../../../../../common/utils/object_utils';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* 2.0.
*/

import { KBN_FIELD_TYPES } from '@kbn/data-plugin/public';
import { KBN_FIELD_TYPES } from '@kbn/field-types';
import { isPopulatedObject } from '@kbn/ml-is-populated-object';

import { EsFieldName } from '../../../../../../../common/types/fields';
Expand Down
Loading

0 comments on commit 612b16b

Please sign in to comment.