Move index patterns: src/legacy/core_plugins/data 👉 src/plugins/data (#53794)

* Move index patterns: src/legacy/core_plugins/data 👉 src/plugins/data

Closes: #43444

Make sure that all index pattern related imports use NP (and delete index_pattern folder from shim)

* fix JEST tests

* fix CI

* fix PR comments

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
This commit is contained in:
Alexey Antonov 2020-01-03 15:57:46 +03:00 committed by GitHub
parent b09653ac74
commit 6942d0bbe6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
86 changed files with 145 additions and 277 deletions

View file

@ -28,8 +28,6 @@ export function plugin() {
/** @public types */ /** @public types */
export { DataStart }; export { DataStart };
export { Field, FieldType, IFieldList, IndexPattern } from './index_patterns';
export { EsQuerySortValue, FetchOptions, ISearchSource, SortDirection } from './search/types'; export { EsQuerySortValue, FetchOptions, ISearchSource, SortDirection } from './search/types';
export { SearchSourceFields } from './search/types'; export { SearchSourceFields } from './search/types';
export { export {
@ -41,5 +39,4 @@ export {
/** @public static code */ /** @public static code */
export * from '../common'; export * from '../common';
export { FilterStateManager } from './filter/filter_manager'; export { FilterStateManager } from './filter/filter_manager';
export { getFromSavedObject, getRoutes, flattenHitWrapper } from './index_patterns';
export { getRequestInspectorStats, getResponseInspectorStats } from './search'; export { getRequestInspectorStats, getResponseInspectorStats } from './search';

View file

@ -1,33 +0,0 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import { IFieldType, indexPatterns } from '../../../../../plugins/data/public';
const getFromSavedObject = indexPatterns.getFromSavedObject;
const getRoutes = indexPatterns.getRoutes;
const flattenHitWrapper = indexPatterns.flattenHitWrapper;
export { getFromSavedObject, getRoutes, flattenHitWrapper };
export { IFieldType as FieldType };
export {
Field,
IFieldList,
IndexPattern,
IndexPatternsContract,
} from '../../../../../plugins/data/public';

View file

@ -19,7 +19,7 @@
import React from 'react'; import React from 'react';
import { shallow } from 'enzyme'; import { shallow } from 'enzyme';
import { JsonCodeBlock } from './json_code_block'; import { JsonCodeBlock } from './json_code_block';
import { IndexPattern } from 'ui/index_patterns'; import { IndexPattern } from '../../../../../plugins/data/public';
it('returns the `JsonCodeEditor` component', () => { it('returns the `JsonCodeEditor` component', () => {
const props = { const props = {

View file

@ -18,12 +18,12 @@
*/ */
import React from 'react'; import React from 'react';
import { mount } from 'enzyme'; import { mount } from 'enzyme';
import { IndexPattern } from 'ui/index_patterns';
// @ts-ignore // @ts-ignore
import { findTestSubject } from '@elastic/eui/lib/test'; import { findTestSubject } from '@elastic/eui/lib/test';
import { flattenHitWrapper } from '../../../../data/public/';
import { DocViewTable } from './table'; import { DocViewTable } from './table';
import { IndexPattern, indexPatterns } from '../../../../../../plugins/data/public';
jest.mock('ui/new_platform'); jest.mock('ui/new_platform');
// @ts-ignore // @ts-ignore
@ -70,7 +70,7 @@ const indexPattern = {
formatHit: jest.fn(hit => hit._source), formatHit: jest.fn(hit => hit._source),
} as IndexPattern; } as IndexPattern;
indexPattern.flattenHit = flattenHitWrapper(indexPattern, indexPattern.metaFields); indexPattern.flattenHit = indexPatterns.flattenHitWrapper(indexPattern, indexPattern.metaFields);
describe('DocViewTable at Discover', () => { describe('DocViewTable at Discover', () => {
// At Discover's main view, all buttons are rendered // At Discover's main view, all buttons are rendered

View file

@ -39,8 +39,13 @@ import {
unhashUrl, unhashUrl,
VISUALIZE_EMBEDDABLE_TYPE, VISUALIZE_EMBEDDABLE_TYPE,
} from '../legacy_imports'; } from '../legacy_imports';
import { FilterStateManager, IndexPattern } from '../../../../data/public'; import { FilterStateManager } from '../../../../data/public';
import { Query, SavedQuery, IndexPatternsContract } from '../../../../../../plugins/data/public'; import {
IndexPattern,
Query,
SavedQuery,
IndexPatternsContract,
} from '../../../../../../plugins/data/public';
import { import {
DashboardContainer, DashboardContainer,

View file

@ -22,12 +22,6 @@ const unmountComponentAtNode = jest.fn();
jest.doMock('react-dom', () => ({ render, unmountComponentAtNode })); jest.doMock('react-dom', () => ({ render, unmountComponentAtNode }));
// If we don't mock this, Jest fails with the error `TypeError: Cannot redefine property: prototype
// at Function.defineProperties`.
jest.mock('ui/index_patterns', () => ({
INDEX_PATTERN_ILLEGAL_CHARACTERS: ['\\', '/', '?', '"', '<', '>', '|', ' '],
}));
jest.mock('ui/chrome', () => ({ jest.mock('ui/chrome', () => ({
getUiSettingsClient: () => ({ getUiSettingsClient: () => ({
get: () => '', get: () => '',

View file

@ -32,11 +32,6 @@ const mockIndexPatternCreationType = {
checkIndicesForErrors: () => false, checkIndicesForErrors: () => false,
getShowSystemIndices: () => false, getShowSystemIndices: () => false,
}; };
// If we don't mock this, Jest fails with the error `TypeError: Cannot redefine property: prototype
// at Function.defineProperties`.
jest.mock('ui/index_patterns', () => ({
INDEX_PATTERN_ILLEGAL_CHARACTERS: ['\\', '/', '?', '"', '<', '>', '|', ' '],
}));
jest.mock('ui/chrome', () => ({ jest.mock('ui/chrome', () => ({
getUiSettingsClient: () => ({ getUiSettingsClient: () => ({

View file

@ -19,7 +19,7 @@
import React, { Component } from 'react'; import React, { Component } from 'react';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import { INDEX_PATTERN_ILLEGAL_CHARACTERS as ILLEGAL_CHARACTERS } from 'ui/index_patterns'; import { indexPatterns } from '../../../../../../../../../../plugins/data/public';
import { MAX_SEARCH_SIZE } from '../../constants'; import { MAX_SEARCH_SIZE } from '../../constants';
import { import {
getIndices, getIndices,
@ -71,7 +71,7 @@ export class StepIndexPattern extends Component {
indexPatternName: indexPatternCreationType.getIndexPatternName(), indexPatternName: indexPatternCreationType.getIndexPatternName(),
}; };
this.ILLEGAL_CHARACTERS = [...ILLEGAL_CHARACTERS]; this.ILLEGAL_CHARACTERS = [...indexPatterns.ILLEGAL_CHARACTERS];
this.lastQuery = null; this.lastQuery = null;
} }
@ -243,7 +243,7 @@ export class StepIndexPattern extends Component {
if (!query || !query.length || query === '.' || query === '..') { if (!query || !query.length || query === '.' || query === '..') {
// This is an error scenario but do not report an error // This is an error scenario but do not report an error
containsErrors = true; containsErrors = true;
} else if (containsIllegalCharacters(query, ILLEGAL_CHARACTERS)) { } else if (containsIllegalCharacters(query, indexPatterns.ILLEGAL_CHARACTERS)) {
const errorMessage = i18n.translate( const errorMessage = i18n.translate(
'kbn.management.createIndexPattern.step.invalidCharactersErrorMessage', 'kbn.management.createIndexPattern.step.invalidCharactersErrorMessage',
{ {

View file

@ -31,7 +31,7 @@ import { TimeRange } from 'src/plugins/data/public';
import { Schema } from '../vis/editors/default/schemas'; import { Schema } from '../vis/editors/default/schemas';
import { AggConfig, AggConfigOptions } from './agg_config'; import { AggConfig, AggConfigOptions } from './agg_config';
import { AggGroupNames } from '../vis/editors/default/agg_groups'; import { AggGroupNames } from '../vis/editors/default/agg_groups';
import { IndexPattern } from '../../../core_plugins/data/public'; import { IndexPattern } from '../../../../plugins/data/public';
import { ISearchSource, FetchOptions } from '../courier/types'; import { ISearchSource, FetchOptions } from '../courier/types';
type Schemas = Record<string, any>; type Schemas = Record<string, any>;

View file

@ -17,7 +17,7 @@
* under the License. * under the License.
*/ */
import { IndexPattern } from 'ui/index_patterns'; import { IndexPattern } from '../../../../../plugins/data/public';
import { AggTypeFilters } from './agg_type_filters'; import { AggTypeFilters } from './agg_type_filters';
import { AggType } from '..'; import { AggType } from '..';
import { AggConfig } from '../../vis'; import { AggConfig } from '../../vis';

View file

@ -16,7 +16,7 @@
* specific language governing permissions and limitations * specific language governing permissions and limitations
* under the License. * under the License.
*/ */
import { IndexPattern } from '../../index_patterns'; import { IndexPattern } from '../../../../../plugins/data/public';
import { AggConfig } from '../../vis'; import { AggConfig } from '../../vis';
import { AggType } from '..'; import { AggType } from '..';

View file

@ -25,7 +25,7 @@ import { FieldParamEditor } from '../../vis/editors/default/controls/field';
import { BaseParamType } from './base'; import { BaseParamType } from './base';
import { toastNotifications } from '../../notify'; import { toastNotifications } from '../../notify';
import { propFilter } from '../filter'; import { propFilter } from '../filter';
import { Field, IFieldList } from '../../index_patterns'; import { Field, IFieldList } from '../../../../../plugins/data/public';
const filterByType = propFilter('type'); const filterByType = propFilter('type');

View file

@ -17,10 +17,10 @@
* under the License. * under the License.
*/ */
import { Field } from 'ui/index_patterns';
import { IndexedArray } from 'ui/indexed_array'; import { IndexedArray } from 'ui/indexed_array';
import { AggTypeFieldFilters } from './field_filters'; import { AggTypeFieldFilters } from './field_filters';
import { AggConfig } from 'ui/vis'; import { AggConfig } from 'ui/vis';
import { Field } from '../../../../../../plugins/data/public';
describe('AggTypeFieldFilters', () => { describe('AggTypeFieldFilters', () => {
let registry: AggTypeFieldFilters; let registry: AggTypeFieldFilters;

View file

@ -16,8 +16,8 @@
* specific language governing permissions and limitations * specific language governing permissions and limitations
* under the License. * under the License.
*/ */
import { Field } from 'ui/index_patterns';
import { AggConfig } from '../../../vis'; import { AggConfig } from '../../../vis';
import { Field } from '../../../../../../plugins/data/public';
type AggTypeFieldFilter = (field: Field, aggConfig: AggConfig) => boolean; type AggTypeFieldFilter = (field: Field, aggConfig: AggConfig) => boolean;

View file

@ -1,25 +0,0 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import { indexPatterns as npIndexPatterns } from '../../../../../plugins/data/public';
export const flattenHitWrapper = npIndexPatterns.flattenHitWrapper;
// static code
export { getFromSavedObject, getRoutes } from '../../../../core_plugins/data/public';

View file

@ -1,40 +0,0 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
/**
* Nothing to see here!
*
* Index Patterns have moved to the data plugin, and are being re-exported
* from ui/index_patterns for backwards compatibility.
*/
import { indexPatterns } from '../../../../plugins/data/public';
// static code
export const INDEX_PATTERN_ILLEGAL_CHARACTERS = indexPatterns.ILLEGAL_CHARACTERS;
export const INDEX_PATTERN_ILLEGAL_CHARACTERS_VISIBLE = indexPatterns.ILLEGAL_CHARACTERS_VISIBLE;
export const ILLEGAL_CHARACTERS = indexPatterns.ILLEGAL_CHARACTERS_KEY;
export const CONTAINS_SPACES = indexPatterns.CONTAINS_SPACES_KEY;
export const validateIndexPattern = indexPatterns.validate;
export const flattenHitWrapper = indexPatterns.flattenHitWrapper;
export const getFromSavedObject = indexPatterns.getFromSavedObject;
export const getRoutes = indexPatterns.getRoutes;
// types
export { Field, FieldType, IFieldList, IndexPattern } from '../../../core_plugins/data/public';

View file

@ -17,11 +17,11 @@
* under the License. * under the License.
*/ */
import { INDEX_PATTERN_ILLEGAL_CHARACTERS_VISIBLE } from '../../index_patterns'; import { indexPatterns } from '../../../../../plugins/data/public';
export const INDEX_ILLEGAL_CHARACTERS_VISIBLE = [...INDEX_PATTERN_ILLEGAL_CHARACTERS_VISIBLE, '*']; export const INDEX_ILLEGAL_CHARACTERS_VISIBLE = [...indexPatterns.ILLEGAL_CHARACTERS_VISIBLE, '*'];
// Insert the comma into the middle, so it doesn't look as if it has grammatical meaning when // Insert the comma into the middle, so it doesn't look as if it has grammatical meaning when
// these characters are rendered in the UI. // these characters are rendered in the UI.
const insertionIndex = Math.floor(INDEX_PATTERN_ILLEGAL_CHARACTERS_VISIBLE.length / 2); const insertionIndex = Math.floor(indexPatterns.ILLEGAL_CHARACTERS_VISIBLE.length / 2);
INDEX_ILLEGAL_CHARACTERS_VISIBLE.splice(insertionIndex, 0, ','); INDEX_ILLEGAL_CHARACTERS_VISIBLE.splice(insertionIndex, 0, ',');

View file

@ -16,9 +16,9 @@
* specific language governing permissions and limitations * specific language governing permissions and limitations
* under the License. * under the License.
*/ */
import { IndexPattern } from 'src/legacy/core_plugins/data/public';
import { ComponentType } from 'react'; import { ComponentType } from 'react';
import { IScope } from 'angular'; import { IScope } from 'angular';
import { IndexPattern } from '../../../../plugins/data/public';
export interface AngularDirective { export interface AngularDirective {
controller: (scope: AngularScope) => void; controller: (scope: AngularScope) => void;

View file

@ -20,7 +20,7 @@ import _ from 'lodash';
import { EsResponse, SavedObject, SavedObjectConfig } from 'ui/saved_objects/types'; import { EsResponse, SavedObject, SavedObjectConfig } from 'ui/saved_objects/types';
import { parseSearchSource } from 'ui/saved_objects/helpers/parse_search_source'; import { parseSearchSource } from 'ui/saved_objects/helpers/parse_search_source';
import { expandShorthand, SavedObjectNotFound } from '../../../../../plugins/kibana_utils/public'; import { expandShorthand, SavedObjectNotFound } from '../../../../../plugins/kibana_utils/public';
import { IndexPattern } from '../../../../core_plugins/data/public'; import { IndexPattern } from '../../../../../plugins/data/public';
/** /**
* A given response of and ElasticSearch containing a plain saved object is applied to the given * A given response of and ElasticSearch containing a plain saved object is applied to the given

View file

@ -20,7 +20,7 @@
import { TimeIntervalParam } from 'ui/vis/editors/config/types'; import { TimeIntervalParam } from 'ui/vis/editors/config/types';
import { AggConfig } from '../..'; import { AggConfig } from '../..';
import { AggType } from '../../../agg_types'; import { AggType } from '../../../agg_types';
import { IndexPattern } from '../../../index_patterns'; import { IndexPattern } from '../../../../../../plugins/data/public';
import { leastCommonMultiple } from '../../../utils/math'; import { leastCommonMultiple } from '../../../utils/math';
import { parseEsInterval } from '../../../../../core_plugins/data/public'; import { parseEsInterval } from '../../../../../core_plugins/data/public';
import { leastCommonInterval } from '../../lib/least_common_interval'; import { leastCommonInterval } from '../../lib/least_common_interval';

View file

@ -24,8 +24,8 @@ import { AggGroupNames } from '../agg_groups';
import { DefaultEditorAgg, DefaultEditorAggProps } from './agg'; import { DefaultEditorAgg, DefaultEditorAggProps } from './agg';
import { act } from 'react-dom/test-utils'; import { act } from 'react-dom/test-utils';
import { DefaultEditorAggParams } from './agg_params'; import { DefaultEditorAggParams } from './agg_params';
import { IndexPattern } from 'ui/index_patterns';
import { AggType } from 'ui/agg_types'; import { AggType } from 'ui/agg_types';
import { IndexPattern } from '../../../../../../../plugins/data/public';
jest.mock('./agg_params', () => ({ jest.mock('./agg_params', () => ({
DefaultEditorAggParams: () => null, DefaultEditorAggParams: () => null,

View file

@ -17,13 +17,13 @@
* under the License. * under the License.
*/ */
import { Field } from 'ui/index_patterns';
import { AggParam } from 'ui/agg_types'; import { AggParam } from 'ui/agg_types';
import { AggConfig } from '../../../../agg_types/agg_config'; import { AggConfig } from '../../../../agg_types/agg_config';
import { ComboBoxGroupedOptions } from '../utils'; import { ComboBoxGroupedOptions } from '../utils';
import { EditorConfig } from '../../config/types'; import { EditorConfig } from '../../config/types';
import { VisState } from '../../..'; import { VisState } from '../../..';
import { SubAggParamsProp } from './agg_params'; import { SubAggParamsProp } from './agg_params';
import { Field } from '../../../../../../../plugins/data/public';
// NOTE: we cannot export the interface with export { InterfaceName } // NOTE: we cannot export the interface with export { InterfaceName }
// as there is currently a bug on babel typescript transform plugin for it // as there is currently a bug on babel typescript transform plugin for it

View file

@ -19,9 +19,9 @@
import React from 'react'; import React from 'react';
import { mount, shallow } from 'enzyme'; import { mount, shallow } from 'enzyme';
import { IndexPattern } from 'ui/index_patterns';
import { AggConfig, VisState } from '../../..'; import { AggConfig, VisState } from '../../..';
import { DefaultEditorAggParams, DefaultEditorAggParamsProps } from './agg_params'; import { DefaultEditorAggParams, DefaultEditorAggParamsProps } from './agg_params';
import { IndexPattern } from '../../../../../../../plugins/data/public';
const mockEditorConfig = { const mockEditorConfig = {
useNormalizedEsInterval: { hidden: false, fixedValue: false }, useNormalizedEsInterval: { hidden: false, fixedValue: false },

View file

@ -23,8 +23,8 @@ import { i18n } from '@kbn/i18n';
import useUnmount from 'react-use/lib/useUnmount'; import useUnmount from 'react-use/lib/useUnmount';
import { VisState } from 'ui/vis'; import { VisState } from 'ui/vis';
import { IndexPattern } from 'ui/index_patterns';
import { aggTypes, AggType, AggParam, AggConfig } from 'ui/agg_types/'; import { aggTypes, AggType, AggParam, AggConfig } from 'ui/agg_types/';
import { IndexPattern } from '../../../../../../../plugins/data/public';
import { DefaultEditorAggSelect } from './agg_select'; import { DefaultEditorAggSelect } from './agg_select';
import { DefaultEditorAggParam } from './agg_param'; import { DefaultEditorAggParam } from './agg_param';

View file

@ -19,7 +19,6 @@
import { AggConfig, VisState } from '../../..'; import { AggConfig, VisState } from '../../..';
import { AggType } from 'ui/agg_types'; import { AggType } from 'ui/agg_types';
import { IndexPattern, Field } from 'ui/index_patterns';
import { IndexedArray } from 'ui/indexed_array'; import { IndexedArray } from 'ui/indexed_array';
import { import {
getAggParamsToRender, getAggParamsToRender,
@ -28,6 +27,7 @@ import {
isInvalidParamsTouched, isInvalidParamsTouched,
} from './agg_params_helper'; } from './agg_params_helper';
import { EditorConfig } from '../../config/types'; import { EditorConfig } from '../../config/types';
import { IndexPattern, Field } from '../../../../../../../plugins/data/public';
jest.mock('ui/agg_types', () => ({ jest.mock('ui/agg_types', () => ({
aggTypes: { aggTypes: {

View file

@ -20,7 +20,6 @@
import { get, isEmpty } from 'lodash'; import { get, isEmpty } from 'lodash';
import { i18n } from '@kbn/i18n'; import { i18n } from '@kbn/i18n';
import { aggTypeFilters } from 'ui/agg_types/filter'; import { aggTypeFilters } from 'ui/agg_types/filter';
import { IndexPattern, Field } from 'ui/index_patterns';
import { aggTypes, AggParam, FieldParamType, AggType } from 'ui/agg_types'; import { aggTypes, AggParam, FieldParamType, AggType } from 'ui/agg_types';
import { aggTypeFieldFilters } from 'ui/agg_types/param_types/filter'; import { aggTypeFieldFilters } from 'ui/agg_types/param_types/filter';
import { AggConfig, VisState } from '../../..'; import { AggConfig, VisState } from '../../..';
@ -28,6 +27,7 @@ import { groupAndSortBy, ComboBoxGroupedOptions } from '../utils';
import { EditorConfig } from '../../config/types'; import { EditorConfig } from '../../config/types';
import { AggTypeState, AggParamsState } from './agg_params_state'; import { AggTypeState, AggParamsState } from './agg_params_state';
import { AggParamEditorProps } from './agg_param_props'; import { AggParamEditorProps } from './agg_param_props';
import { IndexPattern, Field } from '../../../../../../../plugins/data/public';
interface ParamInstanceBase { interface ParamInstanceBase {
agg: AggConfig; agg: AggConfig;

View file

@ -23,9 +23,9 @@ import { EuiComboBox, EuiComboBoxOptionProps, EuiFormRow, EuiLink, EuiText } fro
import { i18n } from '@kbn/i18n'; import { i18n } from '@kbn/i18n';
import { FormattedMessage } from '@kbn/i18n/react'; import { FormattedMessage } from '@kbn/i18n/react';
import { AggType } from 'ui/agg_types'; import { AggType } from 'ui/agg_types';
import { IndexPattern } from 'ui/index_patterns';
import { documentationLinks } from '../../../../documentation_links/documentation_links'; import { documentationLinks } from '../../../../documentation_links/documentation_links';
import { ComboBoxGroupedOptions } from '../utils'; import { ComboBoxGroupedOptions } from '../utils';
import { IndexPattern } from '../../../../../../../plugins/data/public';
interface DefaultEditorAggSelectProps { interface DefaultEditorAggSelectProps {
aggError?: string; aggError?: string;

View file

@ -21,7 +21,7 @@ import React from 'react';
import { act } from 'react-dom/test-utils'; import { act } from 'react-dom/test-utils';
import { mount, shallow, ReactWrapper } from 'enzyme'; import { mount, shallow, ReactWrapper } from 'enzyme';
import { EuiComboBoxProps, EuiComboBox } from '@elastic/eui'; import { EuiComboBoxProps, EuiComboBox } from '@elastic/eui';
import { Field } from '../../../../index_patterns'; import { Field } from '../../../../../../../plugins/data/public';
import { ComboBoxGroupedOptions, SubAggParamsProp } from '..'; import { ComboBoxGroupedOptions, SubAggParamsProp } from '..';
import { FieldParamEditor, FieldParamEditorProps } from './field'; import { FieldParamEditor, FieldParamEditorProps } from './field';
import { AggConfig, VisState } from '../../..'; import { AggConfig, VisState } from '../../..';

View file

@ -23,7 +23,7 @@ import React, { useEffect } from 'react';
import { EuiComboBox, EuiComboBoxOptionProps, EuiFormRow } from '@elastic/eui'; import { EuiComboBox, EuiComboBoxOptionProps, EuiFormRow } from '@elastic/eui';
import { i18n } from '@kbn/i18n'; import { i18n } from '@kbn/i18n';
import { AggConfig } from '../../..'; import { AggConfig } from '../../..';
import { Field } from '../../../../index_patterns'; import { Field } from '../../../../../../../plugins/data/public';
import { formatListAsProse, parseCommaSeparatedList } from '../../../../../../utils'; import { formatListAsProse, parseCommaSeparatedList } from '../../../../../../utils';
import { AggParam, FieldParamType } from '../../../../agg_types'; import { AggParam, FieldParamType } from '../../../../agg_types';
import { AggParamEditorProps, ComboBoxGroupedOptions } from '..'; import { AggParamEditorProps, ComboBoxGroupedOptions } from '..';

View file

@ -19,7 +19,7 @@
import React from 'react'; import React from 'react';
import { i18n } from '@kbn/i18n'; import { i18n } from '@kbn/i18n';
import { Field } from '../../../../index_patterns'; import { Field } from '../../../../../../../plugins/data/public';
import { FieldParamEditor } from './field'; import { FieldParamEditor } from './field';
import { getCompatibleAggs } from './top_aggregate'; import { getCompatibleAggs } from './top_aggregate';
import { AggParamEditorProps } from '..'; import { AggParamEditorProps } from '..';

View file

@ -19,7 +19,7 @@
import React from 'react'; import React from 'react';
import { i18n } from '@kbn/i18n'; import { i18n } from '@kbn/i18n';
import { Field } from '../../../../index_patterns'; import { Field } from '../../../../../../../plugins/data/public';
import { FieldParamEditor } from './field'; import { FieldParamEditor } from './field';
import { AggParamEditorProps } from '..'; import { AggParamEditorProps } from '..';

View file

@ -18,7 +18,7 @@
*/ */
import { AggType } from '../../../agg_types'; import { AggType } from '../../../agg_types';
import { aggTypeFilters, propFilter } from '../../../agg_types/filter'; import { aggTypeFilters, propFilter } from '../../../agg_types/filter';
import { IndexPattern } from '../../../index_patterns'; import { IndexPattern } from '../../../../../../plugins/data/public';
import { AggConfig } from '../../../vis'; import { AggConfig } from '../../../vis';
const filterByName = propFilter('name'); const filterByName = propFilter('name');

View file

@ -20,13 +20,13 @@
import _ from 'lodash'; import _ from 'lodash';
import { Subject, BehaviorSubject } from 'rxjs'; import { Subject, BehaviorSubject } from 'rxjs';
import moment from 'moment'; import moment from 'moment';
import { IndexPattern } from 'src/legacy/core_plugins/data/public';
import { areRefreshIntervalsDifferent, areTimeRangesDifferent } from './lib/diff_time_picker_vals'; import { areRefreshIntervalsDifferent, areTimeRangesDifferent } from './lib/diff_time_picker_vals';
import { parseQueryString } from './lib/parse_querystring'; import { parseQueryString } from './lib/parse_querystring';
import { calculateBounds, getTime } from './get_time'; import { calculateBounds, getTime } from './get_time';
import { TimefilterConfig, InputTimeRange, TimeRangeBounds } from './types'; import { TimefilterConfig, InputTimeRange, TimeRangeBounds } from './types';
import { RefreshInterval, TimeRange } from '../../../common'; import { RefreshInterval, TimeRange } from '../../../common';
import { TimeHistoryContract } from './time_history'; import { TimeHistoryContract } from './time_history';
import { IndexPattern } from '../../index_patterns';
// TODO: remove! // TODO: remove!

View file

@ -16,12 +16,13 @@
* specific language governing permissions and limitations * specific language governing permissions and limitations
* under the License. * under the License.
*/ */
import { ILLEGAL_CHARACTERS, validateIndexPattern } from 'ui/index_patterns';
import { ValidationFunc } from '../../hook_form_lib'; import { ValidationFunc } from '../../hook_form_lib';
import { containsChars } from '../../../validators/string'; import { containsChars } from '../../../validators/string';
import { ERROR_CODE } from './types'; import { ERROR_CODE } from './types';
import { indexPatterns } from '../../../../../data/public';
export const indexPatternField = (i18n: any) => ( export const indexPatternField = (i18n: any) => (
...args: Parameters<ValidationFunc> ...args: Parameters<ValidationFunc>
): ReturnType<ValidationFunc<any, ERROR_CODE>> => { ): ReturnType<ValidationFunc<any, ERROR_CODE>> => {
@ -45,9 +46,9 @@ export const indexPatternField = (i18n: any) => (
} }
// Validate illegal characters // Validate illegal characters
const errors = validateIndexPattern(value); const errors = indexPatterns.validate(value);
if (errors[ILLEGAL_CHARACTERS]) { if (errors[indexPatterns.ILLEGAL_CHARACTERS_KEY]) {
return { return {
code: 'ERR_FIELD_FORMAT', code: 'ERR_FIELD_FORMAT',
formatType: 'INDEX_PATTERN', formatType: 'INDEX_PATTERN',
@ -55,8 +56,8 @@ export const indexPatternField = (i18n: any) => (
defaultMessage: defaultMessage:
'The index pattern contains the invalid {characterListLength, plural, one {character} other {characters}} { characterList }.', 'The index pattern contains the invalid {characterListLength, plural, one {character} other {characters}} { characterList }.',
values: { values: {
characterList: errors[ILLEGAL_CHARACTERS].join(' '), characterList: errors[indexPatterns.ILLEGAL_CHARACTERS_KEY].join(' '),
characterListLength: errors[ILLEGAL_CHARACTERS].length, characterListLength: errors[indexPatterns.ILLEGAL_CHARACTERS_KEY].length,
}, },
}), }),
}; };

View file

@ -5,7 +5,7 @@
*/ */
import { setupEnvironment, pageHelpers, nextTick, getRandomString } from './helpers'; import { setupEnvironment, pageHelpers, nextTick, getRandomString } from './helpers';
import { INDEX_PATTERN_ILLEGAL_CHARACTERS_VISIBLE } from '../../../../../../src/legacy/ui/public/index_patterns'; import { indexPatterns } from '../../../../../../src/plugins/data/public';
jest.mock('ui/new_platform'); jest.mock('ui/new_platform');
@ -203,7 +203,7 @@ describe('Create Auto-follow pattern', () => {
); );
}; };
return INDEX_PATTERN_ILLEGAL_CHARACTERS_VISIBLE.reduce((promise, char) => { return indexPatterns.ILLEGAL_CHARACTERS_VISIBLE.reduce((promise, char) => {
return promise.then(() => expectInvalidChar(char)); return promise.then(() => expectInvalidChar(char));
}, Promise.resolve()); }, Promise.resolve());
}); });

View file

@ -7,7 +7,7 @@
import { setupEnvironment, pageHelpers, nextTick } from './helpers'; import { setupEnvironment, pageHelpers, nextTick } from './helpers';
import { RemoteClustersFormField } from '../../public/app/components'; import { RemoteClustersFormField } from '../../public/app/components';
import { INDEX_PATTERN_ILLEGAL_CHARACTERS_VISIBLE } from '../../../../../../src/legacy/ui/public/index_patterns'; import { indexPatterns } from '../../../../../../src/plugins/data/public';
jest.mock('ui/new_platform'); jest.mock('ui/new_platform');
@ -129,7 +129,7 @@ describe('Create Follower index', () => {
); );
}; };
return INDEX_PATTERN_ILLEGAL_CHARACTERS_VISIBLE.reduce((promise, char) => { return indexPatterns.ILLEGAL_CHARACTERS_VISIBLE.reduce((promise, char) => {
return promise.then(() => expectInvalidChar(char)); return promise.then(() => expectInvalidChar(char));
}, Promise.resolve()); }, Promise.resolve());
}); });
@ -158,7 +158,7 @@ describe('Create Follower index', () => {
); );
}; };
return INDEX_PATTERN_ILLEGAL_CHARACTERS_VISIBLE.reduce((promise, char) => { return indexPatterns.ILLEGAL_CHARACTERS_VISIBLE.reduce((promise, char) => {
return promise.then(() => expectInvalidChar(char)); return promise.then(() => expectInvalidChar(char));
}, Promise.resolve()); }, Promise.resolve());
}); });

View file

@ -29,7 +29,6 @@ import {
EuiTitle, EuiTitle,
} from '@elastic/eui'; } from '@elastic/eui';
import { INDEX_PATTERN_ILLEGAL_CHARACTERS_VISIBLE } from 'ui/index_patterns';
import { INDEX_ILLEGAL_CHARACTERS_VISIBLE } from 'ui/indices'; import { INDEX_ILLEGAL_CHARACTERS_VISIBLE } from 'ui/indices';
import routing from '../services/routing'; import routing from '../services/routing';
@ -45,8 +44,9 @@ import {
} from '../services/auto_follow_pattern_validators'; } from '../services/auto_follow_pattern_validators';
import { AutoFollowPatternRequestFlyout } from './auto_follow_pattern_request_flyout'; import { AutoFollowPatternRequestFlyout } from './auto_follow_pattern_request_flyout';
import { indexPatterns } from '../../../../../../../src/plugins/data/public';
const indexPatternIllegalCharacters = INDEX_PATTERN_ILLEGAL_CHARACTERS_VISIBLE.join(' '); const indexPatternIllegalCharacters = indexPatterns.ILLEGAL_CHARACTERS_VISIBLE.join(' ');
const indexNameIllegalCharacters = INDEX_ILLEGAL_CHARACTERS_VISIBLE.join(' '); const indexNameIllegalCharacters = INDEX_ILLEGAL_CHARACTERS_VISIBLE.join(' ');
const getEmptyAutoFollowPattern = (remoteClusterName = '') => ({ const getEmptyAutoFollowPattern = (remoteClusterName = '') => ({

View file

@ -8,18 +8,14 @@ import React from 'react';
import { i18n } from '@kbn/i18n'; import { i18n } from '@kbn/i18n';
import { FormattedMessage } from '@kbn/i18n/react'; import { FormattedMessage } from '@kbn/i18n/react';
import {
ILLEGAL_CHARACTERS,
CONTAINS_SPACES,
validateIndexPattern as getIndexPatternErrors,
} from 'ui/index_patterns';
import { import {
indexNameBeginsWithPeriod, indexNameBeginsWithPeriod,
findIllegalCharactersInIndexName, findIllegalCharactersInIndexName,
indexNameContainsSpaces, indexNameContainsSpaces,
} from 'ui/indices'; } from 'ui/indices';
import { indexPatterns } from '../../../../../../../src/plugins/data/public';
export const validateName = (name = '') => { export const validateName = (name = '') => {
let errorMsg = null; let errorMsg = null;
@ -57,9 +53,9 @@ export const validateName = (name = '') => {
export const validateLeaderIndexPattern = indexPattern => { export const validateLeaderIndexPattern = indexPattern => {
if (indexPattern) { if (indexPattern) {
const errors = getIndexPatternErrors(indexPattern); const errors = indexPatterns.validate(indexPattern);
if (errors[ILLEGAL_CHARACTERS]) { if (errors[indexPatterns.ILLEGAL_CHARACTERS_KEY]) {
return { return {
message: ( message: (
<FormattedMessage <FormattedMessage
@ -67,15 +63,17 @@ export const validateLeaderIndexPattern = indexPattern => {
defaultMessage="Remove the {characterListLength, plural, one {character} other {characters}} defaultMessage="Remove the {characterListLength, plural, one {character} other {characters}}
{characterList} from the index pattern." {characterList} from the index pattern."
values={{ values={{
characterList: <strong>{errors[ILLEGAL_CHARACTERS].join(' ')}</strong>, characterList: (
characterListLength: errors[ILLEGAL_CHARACTERS].length, <strong>{errors[indexPatterns.ILLEGAL_CHARACTERS_KEY].join(' ')}</strong>
),
characterListLength: errors[indexPatterns.ILLEGAL_CHARACTERS_KEY].length,
}} }}
/> />
), ),
}; };
} }
if (errors[CONTAINS_SPACES]) { if (errors[indexPatterns.CONTAINS_SPACES_KEY]) {
return { return {
message: ( message: (
<FormattedMessage <FormattedMessage

View file

@ -9,8 +9,7 @@ import { SearchBar, OuterSearchBarProps } from './search_bar';
import React, { ReactElement } from 'react'; import React, { ReactElement } from 'react';
import { CoreStart } from 'src/core/public'; import { CoreStart } from 'src/core/public';
import { act } from 'react-dom/test-utils'; import { act } from 'react-dom/test-utils';
import { IndexPattern } from 'src/legacy/core_plugins/data/public'; import { IndexPattern, QueryStringInput } from '../../../../../../src/plugins/data/public';
import { QueryStringInput } from '../../../../../../src/plugins/data/public';
import { KibanaContextProvider } from '../../../../../../src/plugins/kibana_react/public'; import { KibanaContextProvider } from '../../../../../../src/plugins/kibana_react/public';
import { I18nProvider } from '@kbn/i18n/react'; import { I18nProvider } from '@kbn/i18n/react';

View file

@ -10,7 +10,6 @@ import React, { useState, useEffect } from 'react';
import { i18n } from '@kbn/i18n'; import { i18n } from '@kbn/i18n';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { IndexPatternSavedObject, IndexPatternProvider } from '../types'; import { IndexPatternSavedObject, IndexPatternProvider } from '../types';
import { IndexPattern } from '../../../../../../src/legacy/core_plugins/data/public';
import { openSourceModal } from '../services/source_modal'; import { openSourceModal } from '../services/source_modal';
import { import {
GraphState, GraphState,
@ -21,6 +20,7 @@ import {
import { useKibana } from '../../../../../../src/plugins/kibana_react/public'; import { useKibana } from '../../../../../../src/plugins/kibana_react/public';
import { import {
IndexPattern,
QueryStringInput, QueryStringInput,
IDataPluginServices, IDataPluginServices,
Query, Query,

View file

@ -4,8 +4,8 @@
* you may not use this file except in compliance with the Elastic License. * you may not use this file except in compliance with the Elastic License.
*/ */
import { IndexPattern } from 'src/legacy/core_plugins/data/public';
import { IndexPatternProvider } from '../types'; import { IndexPatternProvider } from '../types';
import { IndexPattern } from '../../../../../../src/plugins/data/public';
export function createCachedIndexPatternProvider( export function createCachedIndexPatternProvider(
indexPatternGetter: (id: string) => Promise<IndexPattern> indexPatternGetter: (id: string) => Promise<IndexPattern>

View file

@ -6,9 +6,9 @@
import { GraphWorkspaceSavedObject, Workspace } from '../../types'; import { GraphWorkspaceSavedObject, Workspace } from '../../types';
import { savedWorkspaceToAppState } from './deserialize'; import { savedWorkspaceToAppState } from './deserialize';
import { IndexPattern } from 'src/legacy/core_plugins/data/public';
import { createWorkspace } from '../../angular/graph_client_workspace'; import { createWorkspace } from '../../angular/graph_client_workspace';
import { outlinkEncoders } from '../../helpers/outlink_encoders'; import { outlinkEncoders } from '../../helpers/outlink_encoders';
import { IndexPattern } from '../../../../../../../src/plugins/data/public';
describe('deserialize', () => { describe('deserialize', () => {
let savedWorkspace: GraphWorkspaceSavedObject; let savedWorkspace: GraphWorkspaceSavedObject;

View file

@ -4,7 +4,6 @@
* you may not use this file except in compliance with the Elastic License. * you may not use this file except in compliance with the Elastic License.
*/ */
import { IndexPattern } from 'src/legacy/core_plugins/data/public/';
import { import {
SerializedNode, SerializedNode,
UrlTemplate, UrlTemplate,
@ -25,6 +24,7 @@ import {
colorChoices, colorChoices,
iconChoicesByClass, iconChoicesByClass,
} from '../../helpers/style_choices'; } from '../../helpers/style_choices';
import { IndexPattern } from '../../../../../../../src/plugins/data/public';
const defaultAdvancedSettings: AdvancedSettings = { const defaultAdvancedSettings: AdvancedSettings = {
useSignificance: true, useSignificance: true,

View file

@ -6,7 +6,6 @@
import { takeLatest, put, call, select } from 'redux-saga/effects'; import { takeLatest, put, call, select } from 'redux-saga/effects';
import { i18n } from '@kbn/i18n'; import { i18n } from '@kbn/i18n';
import { IndexPattern } from 'src/legacy/core_plugins/data/public';
import { Action } from 'typescript-fsa'; import { Action } from 'typescript-fsa';
import { GraphStoreDependencies } from './store'; import { GraphStoreDependencies } from './store';
import { loadFields } from './fields'; import { loadFields } from './fields';
@ -18,6 +17,7 @@ import {
setDatasource, setDatasource,
requestDatasource, requestDatasource,
} from './datasource'; } from './datasource';
import { IndexPattern } from '../../../../../../src/plugins/data/public';
/** /**
* Saga loading field information when the datasource is switched. This will overwrite current settings * Saga loading field information when the datasource is switched. This will overwrite current settings

View file

@ -10,7 +10,7 @@ import { datasourceSelector, requestDatasource } from './datasource';
import { datasourceSaga } from './datasource.sagas'; import { datasourceSaga } from './datasource.sagas';
import { fieldsSelector } from './fields'; import { fieldsSelector } from './fields';
import { updateSettings } from './advanced_settings'; import { updateSettings } from './advanced_settings';
import { IndexPattern } from 'src/legacy/core_plugins/data/public'; import { IndexPattern } from '../../../../../../src/plugins/data/public';
const waitForPromise = () => new Promise(r => setTimeout(r)); const waitForPromise = () => new Promise(r => setTimeout(r));

View file

@ -4,13 +4,13 @@
* you may not use this file except in compliance with the Elastic License. * you may not use this file except in compliance with the Elastic License.
*/ */
import { IndexPattern } from 'src/legacy/core_plugins/data/public';
import { NotificationsStart, HttpStart } from 'kibana/public'; import { NotificationsStart, HttpStart } from 'kibana/public';
import createSagaMiddleware from 'redux-saga'; import createSagaMiddleware from 'redux-saga';
import { createStore, applyMiddleware, AnyAction } from 'redux'; import { createStore, applyMiddleware, AnyAction } from 'redux';
import { ChromeStart } from 'kibana/public'; import { ChromeStart } from 'kibana/public';
import { GraphStoreDependencies, createRootReducer, GraphStore, GraphState } from './store'; import { GraphStoreDependencies, createRootReducer, GraphStore, GraphState } from './store';
import { Workspace, GraphWorkspaceSavedObject, IndexPatternSavedObject } from '../types'; import { Workspace, GraphWorkspaceSavedObject, IndexPatternSavedObject } from '../types';
import { IndexPattern } from '../../../../../../src/plugins/data/public';
jest.mock('ui/new_platform'); jest.mock('ui/new_platform');

View file

@ -5,9 +5,9 @@
*/ */
import { SimpleSavedObject } from 'src/core/public'; import { SimpleSavedObject } from 'src/core/public';
import { IndexPattern } from 'src/legacy/core_plugins/data/public';
import { FontawesomeIcon } from '../helpers/style_choices'; import { FontawesomeIcon } from '../helpers/style_choices';
import { OutlinkEncoder } from '../helpers/outlink_encoders'; import { OutlinkEncoder } from '../helpers/outlink_encoders';
import { IndexPattern } from '../../../../../../src/plugins/data/public';
export interface UrlTemplate { export interface UrlTemplate {
url: string; url: string;

View file

@ -5,7 +5,7 @@
*/ */
jest.mock('ui/new_platform'); jest.mock('ui/new_platform');
jest.mock('ui/index_patterns');
jest.mock('./kibana_services', () => { jest.mock('./kibana_services', () => {
return { return {
SPATIAL_FILTER_TYPE: 'spatial_filter', SPATIAL_FILTER_TYPE: 'spatial_filter',
@ -20,7 +20,7 @@ import {
convertMapExtentToPolygon, convertMapExtentToPolygon,
roundCoordinates, roundCoordinates,
} from './elasticsearch_geo_utils'; } from './elasticsearch_geo_utils';
import { flattenHitWrapper } from 'ui/index_patterns'; import { indexPatterns } from '../../../../../src/plugins/data/public';
const geoFieldName = 'location'; const geoFieldName = 'location';
const mapExtent = { const mapExtent = {
@ -172,7 +172,7 @@ describe('hitsToGeoJson', () => {
}, },
}, },
}; };
const indexPatternFlattenHit = flattenHitWrapper(indexPatternMock); const indexPatternFlattenHit = indexPatterns.flattenHitWrapper(indexPatternMock);
it('Should handle geoField being an object', () => { it('Should handle geoField being an object', () => {
const hits = [ const hits = [

View file

@ -5,9 +5,8 @@
*/ */
import { FC } from 'react'; import { FC } from 'react';
import { IndexPattern } from 'ui/index_patterns';
import { SavedSearchSavedObject } from '../../../../common/types/kibana'; import { SavedSearchSavedObject } from '../../../../common/types/kibana';
import { IndexPattern } from '../../../../../../../../src/plugins/data/public';
declare const DataRecognizer: FC<{ declare const DataRecognizer: FC<{
indexPattern: IndexPattern; indexPattern: IndexPattern;

View file

@ -6,9 +6,9 @@
import React from 'react'; import React from 'react';
import { shallowWithIntl } from 'test_utils/enzyme_helpers'; import { shallowWithIntl } from 'test_utils/enzyme_helpers';
import { IndexPattern } from 'ui/index_patterns';
import { FullTimeRangeSelector } from './index'; import { FullTimeRangeSelector } from './index';
import { Query } from 'src/plugins/data/public'; import { Query } from 'src/plugins/data/public';
import { IndexPattern } from '../../../../../../../../src/plugins/data/public';
// Create a mock for the setFullTimeRange function in the service. // Create a mock for the setFullTimeRange function in the service.
// The mock is hoisted to the top, so need to prefix the mock function // The mock is hoisted to the top, so need to prefix the mock function

View file

@ -8,9 +8,9 @@ import React, { FC } from 'react';
import { FormattedMessage } from '@kbn/i18n/react'; import { FormattedMessage } from '@kbn/i18n/react';
import { Query } from 'src/plugins/data/public'; import { Query } from 'src/plugins/data/public';
import { IndexPattern } from 'ui/index_patterns';
import { EuiButton } from '@elastic/eui'; import { EuiButton } from '@elastic/eui';
import { setFullTimeRange } from './full_time_range_selector_service'; import { setFullTimeRange } from './full_time_range_selector_service';
import { IndexPattern } from '../../../../../../../../src/plugins/data/public';
interface Props { interface Props {
indexPattern: IndexPattern; indexPattern: IndexPattern;

View file

@ -7,12 +7,12 @@
import moment from 'moment'; import moment from 'moment';
import { i18n } from '@kbn/i18n'; import { i18n } from '@kbn/i18n';
import { IndexPattern } from 'ui/index_patterns';
import { toastNotifications } from 'ui/notify'; import { toastNotifications } from 'ui/notify';
import { timefilter } from 'ui/timefilter'; import { timefilter } from 'ui/timefilter';
import { Query } from 'src/plugins/data/public'; import { Query } from 'src/plugins/data/public';
import dateMath from '@elastic/datemath'; import dateMath from '@elastic/datemath';
import { ml, GetTimeFieldRangeResponse } from '../../services/ml_api_service'; import { ml, GetTimeFieldRangeResponse } from '../../services/ml_api_service';
import { IndexPattern } from '../../../../../../../../src/plugins/data/public';
export interface TimeRange { export interface TimeRange {
from: number; from: number;

View file

@ -4,7 +4,7 @@
* you may not use this file except in compliance with the Elastic License. * you may not use this file except in compliance with the Elastic License.
*/ */
import { IndexPattern } from 'ui/index_patterns'; import { IndexPattern } from '../../../../../../../../../src/plugins/data/public';
export const indexPatternMock = ({ export const indexPatternMock = ({
id: 'the-index-pattern-id', id: 'the-index-pattern-id',

View file

@ -15,11 +15,6 @@ import { kibanaContextValueMock } from '../../../../../contexts/kibana/__mocks__
import { useCreateAnalyticsForm } from '../../hooks/use_create_analytics_form'; import { useCreateAnalyticsForm } from '../../hooks/use_create_analytics_form';
jest.mock('ui/index_patterns', () => ({
validateIndexPattern: () => true,
INDEX_PATTERN_ILLEGAL_CHARACTERS: [],
}));
const getMountedHook = () => const getMountedHook = () =>
mountHook( mountHook(
() => useCreateAnalyticsForm(), () => useCreateAnalyticsForm(),

View file

@ -15,11 +15,6 @@ import { kibanaContextValueMock } from '../../../../../contexts/kibana/__mocks__
import { useCreateAnalyticsForm } from '../../hooks/use_create_analytics_form'; import { useCreateAnalyticsForm } from '../../hooks/use_create_analytics_form';
jest.mock('ui/index_patterns', () => ({
validateIndexPattern: () => true,
INDEX_PATTERN_ILLEGAL_CHARACTERS: [],
}));
const getMountedHook = () => const getMountedHook = () =>
mountHook( mountHook(
() => useCreateAnalyticsForm(), () => useCreateAnalyticsForm(),

View file

@ -15,11 +15,6 @@ import { kibanaContextValueMock } from '../../../../../contexts/kibana/__mocks__
import { useCreateAnalyticsForm } from '../../hooks/use_create_analytics_form'; import { useCreateAnalyticsForm } from '../../hooks/use_create_analytics_form';
jest.mock('ui/index_patterns', () => ({
validateIndexPattern: () => true,
INDEX_PATTERN_ILLEGAL_CHARACTERS: [],
}));
const getMountedHook = () => const getMountedHook = () =>
mountHook( mountHook(
() => useCreateAnalyticsForm(), () => useCreateAnalyticsForm(),

View file

@ -21,7 +21,6 @@ import { i18n } from '@kbn/i18n';
import { FormattedMessage } from '@kbn/i18n/react'; import { FormattedMessage } from '@kbn/i18n/react';
import { metadata } from 'ui/metadata'; import { metadata } from 'ui/metadata';
import { IndexPattern, INDEX_PATTERN_ILLEGAL_CHARACTERS } from 'ui/index_patterns';
import { ml } from '../../../../../services/ml_api_service'; import { ml } from '../../../../../services/ml_api_service';
import { Field, EVENT_RATE_FIELD_ID } from '../../../../../../../common/types/fields'; import { Field, EVENT_RATE_FIELD_ID } from '../../../../../../../common/types/fields';
@ -38,11 +37,10 @@ import { Messages } from './messages';
import { JobType } from './job_type'; import { JobType } from './job_type';
import { JobDescriptionInput } from './job_description'; import { JobDescriptionInput } from './job_description';
import { mmlUnitInvalidErrorMessage } from '../../hooks/use_create_analytics_form/reducer'; import { mmlUnitInvalidErrorMessage } from '../../hooks/use_create_analytics_form/reducer';
import {
// based on code used by `ui/index_patterns` internally IndexPattern,
// remove the space character from the list of illegal characters indexPatterns,
INDEX_PATTERN_ILLEGAL_CHARACTERS.pop(); } from '../../../../../../../../../../../src/plugins/data/public';
const characterList = INDEX_PATTERN_ILLEGAL_CHARACTERS.join(', ');
const NUMERICAL_FIELD_TYPES = new Set([ const NUMERICAL_FIELD_TYPES = new Set([
'long', 'long',
@ -63,7 +61,6 @@ const OMIT_FIELDS: string[] = ['_source', '_type', '_index', '_id', '_version',
export const CreateAnalyticsForm: FC<CreateAnalyticsFormProps> = ({ actions, state }) => { export const CreateAnalyticsForm: FC<CreateAnalyticsFormProps> = ({ actions, state }) => {
const { setFormState } = actions; const { setFormState } = actions;
const kibanaContext = useKibanaContext(); const kibanaContext = useKibanaContext();
const { form, indexPatternsMap, isAdvancedEditorEnabled, isJobCreated, requestMessages } = state; const { form, indexPatternsMap, isAdvancedEditorEnabled, isJobCreated, requestMessages } = state;
const { const {
@ -93,6 +90,7 @@ export const CreateAnalyticsForm: FC<CreateAnalyticsFormProps> = ({ actions, sta
sourceIndexFieldsCheckFailed, sourceIndexFieldsCheckFailed,
trainingPercent, trainingPercent,
} = form; } = form;
const characterList = indexPatterns.ILLEGAL_CHARACTERS_VISIBLE.join(', ');
// Find out if index pattern contain numeric fields. Provides a hint in the form // Find out if index pattern contain numeric fields. Provides a hint in the form
// that an analytics jobs is not able to identify outliers if there are no numeric fields present. // that an analytics jobs is not able to identify outliers if there are no numeric fields present.

View file

@ -12,10 +12,6 @@ import { ACTION } from './actions';
import { reducer, validateAdvancedEditor } from './reducer'; import { reducer, validateAdvancedEditor } from './reducer';
import { getInitialState, JOB_TYPES } from './state'; import { getInitialState, JOB_TYPES } from './state';
jest.mock('ui/index_patterns', () => ({
validateIndexPattern: () => true,
}));
type SourceIndex = DataFrameAnalyticsConfig['source']['index']; type SourceIndex = DataFrameAnalyticsConfig['source']['index'];
const getMockState = ({ const getMockState = ({

View file

@ -5,9 +5,6 @@
*/ */
import { i18n } from '@kbn/i18n'; import { i18n } from '@kbn/i18n';
import { validateIndexPattern } from 'ui/index_patterns';
import { isValidIndexName } from '../../../../../../../common/util/es_utils'; import { isValidIndexName } from '../../../../../../../common/util/es_utils';
import { Action, ACTION } from './actions'; import { Action, ACTION } from './actions';
@ -26,6 +23,7 @@ import {
isRegressionAnalysis, isRegressionAnalysis,
isClassificationAnalysis, isClassificationAnalysis,
} from '../../../../common/analytics'; } from '../../../../common/analytics';
import { indexPatterns } from '../../../../../../../../../../../src/plugins/data/public';
const mmlAllowedUnitsStr = `${ALLOWED_DATA_UNITS.slice(0, ALLOWED_DATA_UNITS.length - 1).join( const mmlAllowedUnitsStr = `${ALLOWED_DATA_UNITS.slice(0, ALLOWED_DATA_UNITS.length - 1).join(
', ' ', '
@ -66,9 +64,9 @@ export const validateAdvancedEditor = (state: State): State => {
// general check against Kibana index pattern names, but since this is about the advanced editor // general check against Kibana index pattern names, but since this is about the advanced editor
// with support for arrays in the job config, we also need to check that each individual name // with support for arrays in the job config, we also need to check that each individual name
// doesn't include a comma if index names are supplied as an array. // doesn't include a comma if index names are supplied as an array.
// `validateIndexPattern()` returns a map of messages, we're only interested here if it's valid or not. // `indexPatterns.validate()` returns a map of messages, we're only interested here if it's valid or not.
// If there are no messages, it means the index pattern is valid. // If there are no messages, it means the index pattern is valid.
let sourceIndexNameValid = Object.keys(validateIndexPattern(sourceIndexName)).length === 0; let sourceIndexNameValid = Object.keys(indexPatterns.validate(sourceIndexName)).length === 0;
const sourceIndex = jobConfig?.source?.index; const sourceIndex = jobConfig?.source?.index;
if (sourceIndexNameValid) { if (sourceIndexNameValid) {
if (typeof sourceIndex === 'string') { if (typeof sourceIndex === 'string') {
@ -293,7 +291,7 @@ export function reducer(state: State, action: Action): State {
if (action.payload.sourceIndex !== undefined) { if (action.payload.sourceIndex !== undefined) {
newFormState.sourceIndexNameEmpty = newFormState.sourceIndex === ''; newFormState.sourceIndexNameEmpty = newFormState.sourceIndex === '';
const validationMessages = validateIndexPattern(newFormState.sourceIndex); const validationMessages = indexPatterns.validate(newFormState.sourceIndex);
newFormState.sourceIndexNameValid = Object.keys(validationMessages).length === 0; newFormState.sourceIndexNameValid = Object.keys(validationMessages).length === 0;
} }

View file

@ -12,10 +12,6 @@ import { kibanaContextValueMock } from '../../../../../contexts/kibana/__mocks__
import { getErrorMessage, useCreateAnalyticsForm } from './use_create_analytics_form'; import { getErrorMessage, useCreateAnalyticsForm } from './use_create_analytics_form';
jest.mock('ui/index_patterns', () => ({
validateIndexPattern: () => true,
}));
const getMountedHook = () => const getMountedHook = () =>
mountHook( mountHook(
() => useCreateAnalyticsForm(), () => useCreateAnalyticsForm(),

View file

@ -8,10 +8,6 @@ import { GetDataFrameAnalyticsStatsResponseOk } from '../../../../../services/ml
import { getAnalyticsJobsStats } from './get_analytics'; import { getAnalyticsJobsStats } from './get_analytics';
import { DATA_FRAME_TASK_STATE } from '../../components/analytics_list/common'; import { DATA_FRAME_TASK_STATE } from '../../components/analytics_list/common';
jest.mock('ui/index_patterns', () => ({
validateIndexPattern: () => true,
}));
describe('get_analytics', () => { describe('get_analytics', () => {
test('should get analytics jobs stats', () => { test('should get analytics jobs stats', () => {
// arrange // arrange

View file

@ -8,11 +8,9 @@ import React, { FC, useState } from 'react';
import { FormattedMessage } from '@kbn/i18n/react'; import { FormattedMessage } from '@kbn/i18n/react';
import { i18n } from '@kbn/i18n'; import { i18n } from '@kbn/i18n';
import { IndexPattern } from 'ui/index_patterns';
import { EuiPanel, EuiSpacer, EuiText, EuiTitle, EuiFlexGroup } from '@elastic/eui'; import { EuiPanel, EuiSpacer, EuiText, EuiTitle, EuiFlexGroup } from '@elastic/eui';
import { IndexPattern } from '../../../../../../../../../../src/plugins/data/public';
import { CreateJobLinkCard } from '../../../../components/create_job_link_card'; import { CreateJobLinkCard } from '../../../../components/create_job_link_card';
import { DataRecognizer } from '../../../../components/data_recognizer'; import { DataRecognizer } from '../../../../components/data_recognizer';

View file

@ -21,7 +21,7 @@ import {
import { FormattedMessage } from '@kbn/i18n/react'; import { FormattedMessage } from '@kbn/i18n/react';
import { i18n } from '@kbn/i18n'; import { i18n } from '@kbn/i18n';
import { IndexPattern } from 'ui/index_patterns'; import { IndexPattern } from '../../../../../../../../../../src/plugins/data/public';
import { SEARCH_QUERY_LANGUAGE } from '../../../../../../common/constants/search'; import { SEARCH_QUERY_LANGUAGE } from '../../../../../../common/constants/search';
import { SavedSearchQuery } from '../../../../contexts/kibana'; import { SavedSearchQuery } from '../../../../contexts/kibana';

View file

@ -7,7 +7,7 @@
import { i18n } from '@kbn/i18n'; import { i18n } from '@kbn/i18n';
import { toastNotifications } from 'ui/notify'; import { toastNotifications } from 'ui/notify';
import { IndexPattern } from 'ui/index_patterns'; import { IndexPattern } from '../../../../../../../../../src/plugins/data/public';
import { SavedSearchQuery } from '../../../contexts/kibana'; import { SavedSearchQuery } from '../../../contexts/kibana';
import { IndexPatternTitle } from '../../../../../common/types/kibana'; import { IndexPatternTitle } from '../../../../../common/types/kibana';

View file

@ -8,7 +8,6 @@ import React, { FC, Fragment, useEffect, useState } from 'react';
import { merge } from 'rxjs'; import { merge } from 'rxjs';
import { i18n } from '@kbn/i18n'; import { i18n } from '@kbn/i18n';
import { FieldType } from 'ui/index_patterns';
import { timefilter } from 'ui/timefilter'; import { timefilter } from 'ui/timefilter';
import { import {
@ -22,7 +21,12 @@ import {
EuiSpacer, EuiSpacer,
EuiTitle, EuiTitle,
} from '@elastic/eui'; } from '@elastic/eui';
import { KBN_FIELD_TYPES, esQuery, esKuery } from '../../../../../../../../src/plugins/data/public'; import {
IFieldType,
KBN_FIELD_TYPES,
esQuery,
esKuery,
} from '../../../../../../../../src/plugins/data/public';
import { NavigationMenu } from '../../components/navigation_menu'; import { NavigationMenu } from '../../components/navigation_menu';
import { ML_JOB_FIELD_TYPES } from '../../../../common/constants/field_types'; import { ML_JOB_FIELD_TYPES } from '../../../../common/constants/field_types';
import { SEARCH_QUERY_LANGUAGE } from '../../../../common/constants/search'; import { SEARCH_QUERY_LANGUAGE } from '../../../../common/constants/search';
@ -107,7 +111,7 @@ export const Page: FC = () => {
// Obtain the list of non metric field types which appear in the index pattern. // Obtain the list of non metric field types which appear in the index pattern.
let indexedFieldTypes: ML_JOB_FIELD_TYPES[] = []; let indexedFieldTypes: ML_JOB_FIELD_TYPES[] = [];
const indexPatternFields: FieldType[] = currentIndexPattern.fields; const indexPatternFields: IFieldType[] = currentIndexPattern.fields;
indexPatternFields.forEach(field => { indexPatternFields.forEach(field => {
if (field.scripted !== true) { if (field.scripted !== true) {
const dataVisualizerType: ML_JOB_FIELD_TYPES | undefined = kbnTypeToMLJobType(field); const dataVisualizerType: ML_JOB_FIELD_TYPES | undefined = kbnTypeToMLJobType(field);

View file

@ -6,13 +6,13 @@
import memoizeOne from 'memoize-one'; import memoizeOne from 'memoize-one';
import { isEqual } from 'lodash'; import { isEqual } from 'lodash';
import { IndexPattern } from 'ui/index_patterns';
import { IndexPatternTitle } from '../../../../../../common/types/kibana'; import { IndexPatternTitle } from '../../../../../../common/types/kibana';
import { Field, SplitField, AggFieldPair } from '../../../../../../common/types/fields'; import { Field, SplitField, AggFieldPair } from '../../../../../../common/types/fields';
import { ml } from '../../../../services/ml_api_service'; import { ml } from '../../../../services/ml_api_service';
import { mlResultsService } from '../../../../services/results_service'; import { mlResultsService } from '../../../../services/results_service';
import { getCategoryFields as getCategoryFieldsOrig } from './searches'; import { getCategoryFields as getCategoryFieldsOrig } from './searches';
import { aggFieldPairsCanBeCharted } from '../job_creator/util/general'; import { aggFieldPairsCanBeCharted } from '../job_creator/util/general';
import { IndexPattern } from '../../../../../../../../../../src/plugins/data/public';
type DetectorIndex = number; type DetectorIndex = number;
export interface LineChartPoint { export interface LineChartPoint {

View file

@ -4,7 +4,6 @@
* you may not use this file except in compliance with the Elastic License. * you may not use this file except in compliance with the Elastic License.
*/ */
import { IndexPattern } from 'ui/index_patterns';
import { SavedSearchSavedObject } from '../../../../../../common/types/kibana'; import { SavedSearchSavedObject } from '../../../../../../common/types/kibana';
import { JobCreator } from './job_creator'; import { JobCreator } from './job_creator';
@ -15,6 +14,7 @@ import { JOB_TYPE } from '../../../../../../common/constants/new_job';
import { getRichDetectors } from './util/general'; import { getRichDetectors } from './util/general';
import { isValidJson } from '../../../../../../common/util/validation_utils'; import { isValidJson } from '../../../../../../common/util/validation_utils';
import { ml } from '../../../../services/ml_api_service'; import { ml } from '../../../../services/ml_api_service';
import { IndexPattern } from '../../../../../../../../../../src/plugins/data/public';
export interface RichDetector { export interface RichDetector {
agg: Aggregation | null; agg: Aggregation | null;

View file

@ -4,7 +4,6 @@
* you may not use this file except in compliance with the Elastic License. * you may not use this file except in compliance with the Elastic License.
*/ */
import { IndexPattern } from 'ui/index_patterns';
import { SavedSearchSavedObject } from '../../../../../../common/types/kibana'; import { SavedSearchSavedObject } from '../../../../../../common/types/kibana';
import { UrlConfig } from '../../../../../../common/types/custom_urls'; import { UrlConfig } from '../../../../../../common/types/custom_urls';
import { IndexPatternTitle } from '../../../../../../common/types/kibana'; import { IndexPatternTitle } from '../../../../../../common/types/kibana';
@ -24,6 +23,7 @@ import { isSparseDataJob } from './util/general';
import { parseInterval } from '../../../../../../common/util/parse_interval'; import { parseInterval } from '../../../../../../common/util/parse_interval';
import { Calendar } from '../../../../../../common/types/calendars'; import { Calendar } from '../../../../../../common/types/calendars';
import { mlCalendarService } from '../../../../services/calendar_service'; import { mlCalendarService } from '../../../../services/calendar_service';
import { IndexPattern } from '../../../../../../../../../../src/plugins/data/public';
export class JobCreator { export class JobCreator {
protected _type: JOB_TYPE = JOB_TYPE.SINGLE_METRIC; protected _type: JOB_TYPE = JOB_TYPE.SINGLE_METRIC;

View file

@ -4,12 +4,12 @@
* you may not use this file except in compliance with the Elastic License. * you may not use this file except in compliance with the Elastic License.
*/ */
import { IndexPattern } from 'ui/index_patterns';
import { SavedSearchSavedObject } from '../../../../../../common/types/kibana'; import { SavedSearchSavedObject } from '../../../../../../common/types/kibana';
import { SingleMetricJobCreator } from './single_metric_job_creator'; import { SingleMetricJobCreator } from './single_metric_job_creator';
import { MultiMetricJobCreator } from './multi_metric_job_creator'; import { MultiMetricJobCreator } from './multi_metric_job_creator';
import { PopulationJobCreator } from './population_job_creator'; import { PopulationJobCreator } from './population_job_creator';
import { AdvancedJobCreator } from './advanced_job_creator'; import { AdvancedJobCreator } from './advanced_job_creator';
import { IndexPattern } from '../../../../../../../../../../src/plugins/data/public';
import { JOB_TYPE } from '../../../../../../common/constants/new_job'; import { JOB_TYPE } from '../../../../../../common/constants/new_job';

View file

@ -4,7 +4,6 @@
* you may not use this file except in compliance with the Elastic License. * you may not use this file except in compliance with the Elastic License.
*/ */
import { IndexPattern } from 'ui/index_patterns';
import { SavedSearchSavedObject } from '../../../../../../common/types/kibana'; import { SavedSearchSavedObject } from '../../../../../../common/types/kibana';
import { JobCreator } from './job_creator'; import { JobCreator } from './job_creator';
import { import {
@ -22,6 +21,7 @@ import {
} from '../../../../../../common/constants/new_job'; } from '../../../../../../common/constants/new_job';
import { ml } from '../../../../services/ml_api_service'; import { ml } from '../../../../services/ml_api_service';
import { getRichDetectors } from './util/general'; import { getRichDetectors } from './util/general';
import { IndexPattern } from '../../../../../../../../../../src/plugins/data/public';
export class MultiMetricJobCreator extends JobCreator { export class MultiMetricJobCreator extends JobCreator {
// a multi metric job has one optional overall partition field // a multi metric job has one optional overall partition field

View file

@ -4,7 +4,6 @@
* you may not use this file except in compliance with the Elastic License. * you may not use this file except in compliance with the Elastic License.
*/ */
import { IndexPattern } from 'ui/index_patterns';
import { SavedSearchSavedObject } from '../../../../../../common/types/kibana'; import { SavedSearchSavedObject } from '../../../../../../common/types/kibana';
import { JobCreator } from './job_creator'; import { JobCreator } from './job_creator';
import { import {
@ -17,6 +16,7 @@ import { Job, Datafeed, Detector } from './configs';
import { createBasicDetector } from './util/default_configs'; import { createBasicDetector } from './util/default_configs';
import { JOB_TYPE, CREATED_BY_LABEL } from '../../../../../../common/constants/new_job'; import { JOB_TYPE, CREATED_BY_LABEL } from '../../../../../../common/constants/new_job';
import { getRichDetectors } from './util/general'; import { getRichDetectors } from './util/general';
import { IndexPattern } from '../../../../../../../../../../src/plugins/data/public';
export class PopulationJobCreator extends JobCreator { export class PopulationJobCreator extends JobCreator {
// a population job has one overall over (split) field, which is the same for all detectors // a population job has one overall over (split) field, which is the same for all detectors

View file

@ -4,7 +4,6 @@
* you may not use this file except in compliance with the Elastic License. * you may not use this file except in compliance with the Elastic License.
*/ */
import { IndexPattern } from 'ui/index_patterns';
import { SavedSearchSavedObject } from '../../../../../../common/types/kibana'; import { SavedSearchSavedObject } from '../../../../../../common/types/kibana';
import { parseInterval } from '../../../../../../common/util/parse_interval'; import { parseInterval } from '../../../../../../common/util/parse_interval';
import { JobCreator } from './job_creator'; import { JobCreator } from './job_creator';
@ -17,6 +16,7 @@ import {
} from '../../../../../../common/constants/aggregation_types'; } from '../../../../../../common/constants/aggregation_types';
import { JOB_TYPE, CREATED_BY_LABEL } from '../../../../../../common/constants/new_job'; import { JOB_TYPE, CREATED_BY_LABEL } from '../../../../../../common/constants/new_job';
import { getRichDetectors } from './util/general'; import { getRichDetectors } from './util/general';
import { IndexPattern } from '../../../../../../../../../../src/plugins/data/public';
export class SingleMetricJobCreator extends JobCreator { export class SingleMetricJobCreator extends JobCreator {
protected _type: JOB_TYPE = JOB_TYPE.SINGLE_METRIC; protected _type: JOB_TYPE = JOB_TYPE.SINGLE_METRIC;

View file

@ -4,8 +4,12 @@
* you may not use this file except in compliance with the Elastic License. * you may not use this file except in compliance with the Elastic License.
*/ */
import { IndexPattern } from 'ui/index_patterns'; import {
import { esQuery, Query, esKuery } from '../../../../../../../../../src/plugins/data/public'; IndexPattern,
esQuery,
Query,
esKuery,
} from '../../../../../../../../../src/plugins/data/public';
import { KibanaConfigTypeFix } from '../../../contexts/kibana'; import { KibanaConfigTypeFix } from '../../../contexts/kibana';
import { SEARCH_QUERY_LANGUAGE } from '../../../../../common/constants/search'; import { SEARCH_QUERY_LANGUAGE } from '../../../../../common/constants/search';
import { SavedSearchSavedObject } from '../../../../../common/types/kibana'; import { SavedSearchSavedObject } from '../../../../../common/types/kibana';

View file

@ -4,10 +4,10 @@
* you may not use this file except in compliance with the Elastic License. * you may not use this file except in compliance with the Elastic License.
*/ */
import { IndexPattern } from 'ui/index_patterns';
import { mlFunctionToESAggregation } from '../../../common/util/job_utils'; import { mlFunctionToESAggregation } from '../../../common/util/job_utils';
import { getIndexPatternById, getIndexPatternIdFromName } from '../util/index_utils'; import { getIndexPatternById, getIndexPatternIdFromName } from '../util/index_utils';
import { mlJobService } from './job_service'; import { mlJobService } from './job_service';
import { IndexPattern } from '../../../../../../../src/plugins/data/public';
type FormatsByJobId = Record<string, any>; type FormatsByJobId = Record<string, any>;
type IndexPatternIdsByJob = Record<string, any>; type IndexPatternIdsByJob = Record<string, any>;

View file

@ -5,7 +5,7 @@
*/ */
import { newJobCapsService } from './new_job_capabilities_service'; import { newJobCapsService } from './new_job_capabilities_service';
import { IndexPattern } from 'ui/index_patterns'; import { IndexPattern } from '../../../../../../../src/plugins/data/public';
// there is magic happening here. starting the include name with `mock..` // there is magic happening here. starting the include name with `mock..`
// ensures it can be lazily loaded by the jest.mock function below. // ensures it can be lazily loaded by the jest.mock function below.

View file

@ -4,8 +4,7 @@
* you may not use this file except in compliance with the Elastic License. * you may not use this file except in compliance with the Elastic License.
*/ */
import { FieldType } from 'ui/index_patterns'; import { IFieldType, KBN_FIELD_TYPES } from '../../../../../../../src/plugins/data/public';
import { KBN_FIELD_TYPES } from '../../../../../../../src/plugins/data/public';
import { ML_JOB_FIELD_TYPES } from '../../../common/constants/field_types'; import { ML_JOB_FIELD_TYPES } from '../../../common/constants/field_types';
import { import {
kbnTypeToMLJobType, kbnTypeToMLJobType,
@ -16,7 +15,7 @@ import {
describe('ML - field type utils', () => { describe('ML - field type utils', () => {
describe('kbnTypeToMLJobType', () => { describe('kbnTypeToMLJobType', () => {
test('returns correct ML_JOB_FIELD_TYPES for KBN_FIELD_TYPES', () => { test('returns correct ML_JOB_FIELD_TYPES for KBN_FIELD_TYPES', () => {
const field: FieldType = { const field: IFieldType = {
type: KBN_FIELD_TYPES.NUMBER, type: KBN_FIELD_TYPES.NUMBER,
name: KBN_FIELD_TYPES.NUMBER, name: KBN_FIELD_TYPES.NUMBER,
aggregatable: true, aggregatable: true,
@ -37,7 +36,7 @@ describe('ML - field type utils', () => {
}); });
test('returns ML_JOB_FIELD_TYPES.KEYWORD for aggregatable KBN_FIELD_TYPES.STRING', () => { test('returns ML_JOB_FIELD_TYPES.KEYWORD for aggregatable KBN_FIELD_TYPES.STRING', () => {
const field: FieldType = { const field: IFieldType = {
type: KBN_FIELD_TYPES.STRING, type: KBN_FIELD_TYPES.STRING,
name: KBN_FIELD_TYPES.STRING, name: KBN_FIELD_TYPES.STRING,
aggregatable: true, aggregatable: true,
@ -46,7 +45,7 @@ describe('ML - field type utils', () => {
}); });
test('returns ML_JOB_FIELD_TYPES.TEXT for non-aggregatable KBN_FIELD_TYPES.STRING', () => { test('returns ML_JOB_FIELD_TYPES.TEXT for non-aggregatable KBN_FIELD_TYPES.STRING', () => {
const field: FieldType = { const field: IFieldType = {
type: KBN_FIELD_TYPES.STRING, type: KBN_FIELD_TYPES.STRING,
name: KBN_FIELD_TYPES.STRING, name: KBN_FIELD_TYPES.STRING,
aggregatable: false, aggregatable: false,
@ -55,7 +54,7 @@ describe('ML - field type utils', () => {
}); });
test('returns undefined for non-aggregatable "foo"', () => { test('returns undefined for non-aggregatable "foo"', () => {
const field: FieldType = { const field: IFieldType = {
type: 'foo', type: 'foo',
name: 'foo', name: 'foo',
aggregatable: false, aggregatable: false,

View file

@ -5,15 +5,14 @@
*/ */
import { i18n } from '@kbn/i18n'; import { i18n } from '@kbn/i18n';
import { FieldType } from 'ui/index_patterns';
import { ML_JOB_FIELD_TYPES } from '../../../common/constants/field_types'; import { ML_JOB_FIELD_TYPES } from '../../../common/constants/field_types';
import { KBN_FIELD_TYPES } from '../../../../../../../src/plugins/data/public'; import { IFieldType, KBN_FIELD_TYPES } from '../../../../../../../src/plugins/data/public';
// convert kibana types to ML Job types // convert kibana types to ML Job types
// this is needed because kibana types only have string and not text and keyword. // this is needed because kibana types only have string and not text and keyword.
// and we can't use ES_FIELD_TYPES because it has no NUMBER type // and we can't use ES_FIELD_TYPES because it has no NUMBER type
export function kbnTypeToMLJobType(field: FieldType) { export function kbnTypeToMLJobType(field: IFieldType) {
// Return undefined if not one of the supported data visualizer field types. // Return undefined if not one of the supported data visualizer field types.
let type; let type;
switch (field.type) { switch (field.type) {

View file

@ -12,7 +12,7 @@ import {
MONTH, MONTH,
YEAR, YEAR,
} from '../../../../../../src/plugins/es_ui_shared/public/components/cron_editor'; } from '../../../../../../src/plugins/es_ui_shared/public/components/cron_editor';
import { INDEX_PATTERN_ILLEGAL_CHARACTERS_VISIBLE } from '../../../../../../src/legacy/ui/public/index_patterns'; import { indexPatterns } from '../../../../../../src/plugins/data/public';
import { setupEnvironment, pageHelpers } from './helpers'; import { setupEnvironment, pageHelpers } from './helpers';
jest.mock('ui/new_platform'); jest.mock('ui/new_platform');
@ -154,7 +154,7 @@ describe('Create Rollup Job, step 1: Logistics', () => {
); );
}; };
[...INDEX_PATTERN_ILLEGAL_CHARACTERS_VISIBLE, ','].reduce((promise, char) => { [...indexPatterns.ILLEGAL_CHARACTERS_VISIBLE, ','].reduce((promise, char) => {
return promise.then(() => expectInvalidChar(char)); return promise.then(() => expectInvalidChar(char));
}, Promise.resolve()); }, Promise.resolve());
}); });

View file

@ -26,12 +26,13 @@ import {
// eslint-disable-next-line @kbn/eslint/no-restricted-paths // eslint-disable-next-line @kbn/eslint/no-restricted-paths
import { CronEditor } from '../../../../../../../../../src/plugins/es_ui_shared/public/components/cron_editor'; import { CronEditor } from '../../../../../../../../../src/plugins/es_ui_shared/public/components/cron_editor';
import { INDEX_PATTERN_ILLEGAL_CHARACTERS_VISIBLE } from 'ui/index_patterns';
import { INDEX_ILLEGAL_CHARACTERS_VISIBLE } from 'ui/indices'; import { INDEX_ILLEGAL_CHARACTERS_VISIBLE } from 'ui/indices';
import { logisticalDetailsUrl, cronUrl } from '../../../services'; import { logisticalDetailsUrl, cronUrl } from '../../../services';
import { StepError } from './components'; import { StepError } from './components';
const indexPatternIllegalCharacters = INDEX_PATTERN_ILLEGAL_CHARACTERS_VISIBLE.join(' '); import { indexPatterns } from '../../../../../../../../../src/plugins/data/public';
const indexPatternIllegalCharacters = indexPatterns.ILLEGAL_CHARACTERS_VISIBLE.join(' ');
const indexIllegalCharacters = INDEX_ILLEGAL_CHARACTERS_VISIBLE.join(' '); const indexIllegalCharacters = INDEX_ILLEGAL_CHARACTERS_VISIBLE.join(' ');
export class StepLogisticsUi extends Component { export class StepLogisticsUi extends Component {

View file

@ -7,8 +7,7 @@
import React from 'react'; import React from 'react';
import { FormattedMessage } from '@kbn/i18n/react'; import { FormattedMessage } from '@kbn/i18n/react';
import { INDEX_PATTERN_ILLEGAL_CHARACTERS_VISIBLE } from 'ui/index_patterns'; import { indexPatterns } from '../../../../../../../../../src/plugins/data/public';
export function validateIndexPattern(indexPattern, rollupIndex) { export function validateIndexPattern(indexPattern, rollupIndex) {
if (!indexPattern || !indexPattern.trim()) { if (!indexPattern || !indexPattern.trim()) {
return [ return [
@ -28,7 +27,7 @@ export function validateIndexPattern(indexPattern, rollupIndex) {
]; ];
} }
const illegalCharacters = INDEX_PATTERN_ILLEGAL_CHARACTERS_VISIBLE.reduce((chars, char) => { const illegalCharacters = indexPatterns.ILLEGAL_CHARACTERS_VISIBLE.reduce((chars, char) => {
if (indexPattern.includes(char)) { if (indexPattern.includes(char)) {
chars.push(char); chars.push(char);
} }

View file

@ -6,14 +6,14 @@
import { DefaultOperator } from 'elasticsearch'; import { DefaultOperator } from 'elasticsearch';
import { IndexPattern } from 'ui/index_patterns';
import { dictionaryToArray } from '../../../common/types/common'; import { dictionaryToArray } from '../../../common/types/common';
import { SavedSearchQuery } from '../lib/kibana'; import { SavedSearchQuery } from '../lib/kibana';
import { StepDefineExposedState } from '../sections/create_transform/components/step_define/step_define_form'; import { StepDefineExposedState } from '../sections/create_transform/components/step_define/step_define_form';
import { StepDetailsExposedState } from '../sections/create_transform/components/step_details/step_details_form'; import { StepDetailsExposedState } from '../sections/create_transform/components/step_details/step_details_form';
import { IndexPattern } from '../../../../../../../src/plugins/data/public';
import { import {
getEsAggFromAggConfig, getEsAggFromAggConfig,
getEsAggFromGroupByConfig, getEsAggFromGroupByConfig,

View file

@ -5,8 +5,11 @@
*/ */
import { SavedObjectsClientContract, IUiSettingsClient } from 'src/core/public'; import { SavedObjectsClientContract, IUiSettingsClient } from 'src/core/public';
import { IndexPattern as IndexPatternType } from 'ui/index_patterns'; import {
import { esQuery, IndexPatternsContract } from '../../../../../../../../src/plugins/data/public'; IndexPattern,
esQuery,
IndexPatternsContract,
} from '../../../../../../../../src/plugins/data/public';
type IndexPatternId = string; type IndexPatternId = string;
type SavedSearchId = string; type SavedSearchId = string;
@ -68,7 +71,7 @@ export function loadCurrentSavedSearch(savedSearches: any, savedSearchId: SavedS
// Helper for creating the items used for searching and job creation. // Helper for creating the items used for searching and job creation.
export function createSearchItems( export function createSearchItems(
indexPattern: IndexPatternType | undefined, indexPattern: IndexPattern | undefined,
savedSearch: any, savedSearch: any,
config: IUiSettingsClient config: IUiSettingsClient
) { ) {

View file

@ -14,7 +14,7 @@ import {
} from '../../../../common'; } from '../../../../common';
import { getPivotPreviewDevConsoleStatement, getPivotDropdownOptions } from './common'; import { getPivotPreviewDevConsoleStatement, getPivotDropdownOptions } from './common';
import { IndexPattern } from 'ui/index_patterns'; import { IndexPattern } from '../../../../../../../../../../src/plugins/data/public';
describe('Transform: Define Pivot Common', () => { describe('Transform: Define Pivot Common', () => {
test('getPivotDropdownOptions()', () => { test('getPivotDropdownOptions()', () => {

View file

@ -5,10 +5,10 @@
*/ */
import { get } from 'lodash'; import { get } from 'lodash';
import { EuiComboBoxOptionProps } from '@elastic/eui'; import { EuiComboBoxOptionProps } from '@elastic/eui';
import {
import { IndexPattern } from 'ui/index_patterns'; IndexPattern,
KBN_FIELD_TYPES,
import { KBN_FIELD_TYPES } from '../../../../../../../../../../src/plugins/data/public'; } from '../../../../../../../../../../src/plugins/data/public';
import { import {
PreviewRequestBody, PreviewRequestBody,

View file

@ -14,7 +14,7 @@ import {
UsePivotPreviewDataReturnType, UsePivotPreviewDataReturnType,
} from './use_pivot_preview_data'; } from './use_pivot_preview_data';
import { IndexPattern } from 'ui/index_patterns'; import { IndexPattern } from '../../../../../../../../../../src/plugins/data/public';
jest.mock('../../../../hooks/use_api'); jest.mock('../../../../hooks/use_api');

View file

@ -6,13 +6,15 @@
import { useEffect, useState } from 'react'; import { useEffect, useState } from 'react';
import { IndexPattern } from 'ui/index_patterns';
import { dictionaryToArray } from '../../../../../../common/types/common'; import { dictionaryToArray } from '../../../../../../common/types/common';
import { useApi } from '../../../../hooks/use_api'; import { useApi } from '../../../../hooks/use_api';
import { Dictionary } from '../../../../../../common/types/common'; import { Dictionary } from '../../../../../../common/types/common';
import { ES_FIELD_TYPES } from '../../../../../../../../../../src/plugins/data/public'; import {
IndexPattern,
ES_FIELD_TYPES,
} from '../../../../../../../../../../src/plugins/data/public';
import { import {
getPreviewRequestBody, getPreviewRequestBody,
PreviewRequestBody, PreviewRequestBody,