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

* 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>

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
This commit is contained in:
Alexey Antonov 2020-01-03 21:38:33 +03:00 committed by GitHub
parent 4855bcd6b8
commit 9f885ed2e6
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 */
export { DataStart };
export { Field, FieldType, IFieldList, IndexPattern } from './index_patterns';
export { EsQuerySortValue, FetchOptions, ISearchSource, SortDirection } from './search/types';
export { SearchSourceFields } from './search/types';
export {
@ -41,5 +39,4 @@ export {
/** @public static code */
export * from '../common';
export { FilterStateManager } from './filter/filter_manager';
export { getFromSavedObject, getRoutes, flattenHitWrapper } from './index_patterns';
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 { shallow } from 'enzyme';
import { JsonCodeBlock } from './json_code_block';
import { IndexPattern } from 'ui/index_patterns';
import { IndexPattern } from '../../../../../plugins/data/public';
it('returns the `JsonCodeEditor` component', () => {
const props = {

View file

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

View file

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

View file

@ -22,12 +22,6 @@ const unmountComponentAtNode = jest.fn();
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', () => ({
getUiSettingsClient: () => ({
get: () => '',

View file

@ -32,11 +32,6 @@ const mockIndexPatternCreationType = {
checkIndicesForErrors: () => 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', () => ({
getUiSettingsClient: () => ({

View file

@ -19,7 +19,7 @@
import React, { Component } from 'react';
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 {
getIndices,
@ -71,7 +71,7 @@ export class StepIndexPattern extends Component {
indexPatternName: indexPatternCreationType.getIndexPatternName(),
};
this.ILLEGAL_CHARACTERS = [...ILLEGAL_CHARACTERS];
this.ILLEGAL_CHARACTERS = [...indexPatterns.ILLEGAL_CHARACTERS];
this.lastQuery = null;
}
@ -243,7 +243,7 @@ export class StepIndexPattern extends Component {
if (!query || !query.length || query === '.' || query === '..') {
// This is an error scenario but do not report an error
containsErrors = true;
} else if (containsIllegalCharacters(query, ILLEGAL_CHARACTERS)) {
} else if (containsIllegalCharacters(query, indexPatterns.ILLEGAL_CHARACTERS)) {
const errorMessage = i18n.translate(
'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 { AggConfig, AggConfigOptions } from './agg_config';
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';
type Schemas = Record<string, any>;

View file

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

View file

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

View file

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

View file

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

View file

@ -16,8 +16,8 @@
* specific language governing permissions and limitations
* under the License.
*/
import { Field } from 'ui/index_patterns';
import { AggConfig } from '../../../vis';
import { Field } from '../../../../../../plugins/data/public';
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.
*/
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
// 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, ',');

View file

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

View file

@ -20,7 +20,7 @@ import _ from 'lodash';
import { EsResponse, SavedObject, SavedObjectConfig } from 'ui/saved_objects/types';
import { parseSearchSource } from 'ui/saved_objects/helpers/parse_search_source';
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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -5,7 +5,7 @@
*/
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');
@ -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));
}, Promise.resolve());
});

View file

@ -7,7 +7,7 @@
import { setupEnvironment, pageHelpers, nextTick } from './helpers';
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');
@ -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));
}, 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));
}, Promise.resolve());
});

View file

@ -29,7 +29,6 @@ import {
EuiTitle,
} from '@elastic/eui';
import { INDEX_PATTERN_ILLEGAL_CHARACTERS_VISIBLE } from 'ui/index_patterns';
import { INDEX_ILLEGAL_CHARACTERS_VISIBLE } from 'ui/indices';
import routing from '../services/routing';
@ -45,8 +44,9 @@ import {
} from '../services/auto_follow_pattern_validators';
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 getEmptyAutoFollowPattern = (remoteClusterName = '') => ({

View file

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

View file

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

View file

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

View file

@ -4,8 +4,8 @@
* 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 { IndexPattern } from '../../../../../../src/plugins/data/public';
export function createCachedIndexPatternProvider(
indexPatternGetter: (id: string) => Promise<IndexPattern>

View file

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

View file

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

View file

@ -6,7 +6,6 @@
import { takeLatest, put, call, select } from 'redux-saga/effects';
import { i18n } from '@kbn/i18n';
import { IndexPattern } from 'src/legacy/core_plugins/data/public';
import { Action } from 'typescript-fsa';
import { GraphStoreDependencies } from './store';
import { loadFields } from './fields';
@ -18,6 +17,7 @@ import {
setDatasource,
requestDatasource,
} from './datasource';
import { IndexPattern } from '../../../../../../src/plugins/data/public';
/**
* 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 { fieldsSelector } from './fields';
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));

View file

@ -4,13 +4,13 @@
* 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 createSagaMiddleware from 'redux-saga';
import { createStore, applyMiddleware, AnyAction } from 'redux';
import { ChromeStart } from 'kibana/public';
import { GraphStoreDependencies, createRootReducer, GraphStore, GraphState } from './store';
import { Workspace, GraphWorkspaceSavedObject, IndexPatternSavedObject } from '../types';
import { IndexPattern } from '../../../../../../src/plugins/data/public';
jest.mock('ui/new_platform');

View file

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

View file

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

View file

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

View file

@ -6,9 +6,9 @@
import React from 'react';
import { shallowWithIntl } from 'test_utils/enzyme_helpers';
import { IndexPattern } from 'ui/index_patterns';
import { FullTimeRangeSelector } from './index';
import { Query } from 'src/plugins/data/public';
import { IndexPattern } from '../../../../../../../../src/plugins/data/public';
// Create a mock for the setFullTimeRange function in the service.
// 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 { Query } from 'src/plugins/data/public';
import { IndexPattern } from 'ui/index_patterns';
import { EuiButton } from '@elastic/eui';
import { setFullTimeRange } from './full_time_range_selector_service';
import { IndexPattern } from '../../../../../../../../src/plugins/data/public';
interface Props {
indexPattern: IndexPattern;

View file

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

View file

@ -4,7 +4,7 @@
* 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 = ({
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';
jest.mock('ui/index_patterns', () => ({
validateIndexPattern: () => true,
INDEX_PATTERN_ILLEGAL_CHARACTERS: [],
}));
const getMountedHook = () =>
mountHook(
() => useCreateAnalyticsForm(),

View file

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

View file

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

View file

@ -21,7 +21,6 @@ import { i18n } from '@kbn/i18n';
import { FormattedMessage } from '@kbn/i18n/react';
import { metadata } from 'ui/metadata';
import { IndexPattern, INDEX_PATTERN_ILLEGAL_CHARACTERS } from 'ui/index_patterns';
import { ml } from '../../../../../services/ml_api_service';
import { Field, EVENT_RATE_FIELD_ID } from '../../../../../../../common/types/fields';
@ -38,11 +37,10 @@ import { Messages } from './messages';
import { JobType } from './job_type';
import { JobDescriptionInput } from './job_description';
import { mmlUnitInvalidErrorMessage } from '../../hooks/use_create_analytics_form/reducer';
// based on code used by `ui/index_patterns` internally
// remove the space character from the list of illegal characters
INDEX_PATTERN_ILLEGAL_CHARACTERS.pop();
const characterList = INDEX_PATTERN_ILLEGAL_CHARACTERS.join(', ');
import {
IndexPattern,
indexPatterns,
} from '../../../../../../../../../../../src/plugins/data/public';
const NUMERICAL_FIELD_TYPES = new Set([
'long',
@ -63,7 +61,6 @@ const OMIT_FIELDS: string[] = ['_source', '_type', '_index', '_id', '_version',
export const CreateAnalyticsForm: FC<CreateAnalyticsFormProps> = ({ actions, state }) => {
const { setFormState } = actions;
const kibanaContext = useKibanaContext();
const { form, indexPatternsMap, isAdvancedEditorEnabled, isJobCreated, requestMessages } = state;
const {
@ -93,6 +90,7 @@ export const CreateAnalyticsForm: FC<CreateAnalyticsFormProps> = ({ actions, sta
sourceIndexFieldsCheckFailed,
trainingPercent,
} = form;
const characterList = indexPatterns.ILLEGAL_CHARACTERS_VISIBLE.join(', ');
// 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.

View file

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

View file

@ -5,9 +5,6 @@
*/
import { i18n } from '@kbn/i18n';
import { validateIndexPattern } from 'ui/index_patterns';
import { isValidIndexName } from '../../../../../../../common/util/es_utils';
import { Action, ACTION } from './actions';
@ -26,6 +23,7 @@ import {
isRegressionAnalysis,
isClassificationAnalysis,
} from '../../../../common/analytics';
import { indexPatterns } from '../../../../../../../../../../../src/plugins/data/public';
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
// 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.
// `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.
let sourceIndexNameValid = Object.keys(validateIndexPattern(sourceIndexName)).length === 0;
let sourceIndexNameValid = Object.keys(indexPatterns.validate(sourceIndexName)).length === 0;
const sourceIndex = jobConfig?.source?.index;
if (sourceIndexNameValid) {
if (typeof sourceIndex === 'string') {
@ -293,7 +291,7 @@ export function reducer(state: State, action: Action): State {
if (action.payload.sourceIndex !== undefined) {
newFormState.sourceIndexNameEmpty = newFormState.sourceIndex === '';
const validationMessages = validateIndexPattern(newFormState.sourceIndex);
const validationMessages = indexPatterns.validate(newFormState.sourceIndex);
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';
jest.mock('ui/index_patterns', () => ({
validateIndexPattern: () => true,
}));
const getMountedHook = () =>
mountHook(
() => useCreateAnalyticsForm(),

View file

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

View file

@ -8,11 +8,9 @@ import React, { FC, useState } from 'react';
import { FormattedMessage } from '@kbn/i18n/react';
import { i18n } from '@kbn/i18n';
import { IndexPattern } from 'ui/index_patterns';
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 { DataRecognizer } from '../../../../components/data_recognizer';

View file

@ -21,7 +21,7 @@ import {
import { FormattedMessage } from '@kbn/i18n/react';
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 { SavedSearchQuery } from '../../../../contexts/kibana';

View file

@ -7,7 +7,7 @@
import { i18n } from '@kbn/i18n';
import { toastNotifications } from 'ui/notify';
import { IndexPattern } from 'ui/index_patterns';
import { IndexPattern } from '../../../../../../../../../src/plugins/data/public';
import { SavedSearchQuery } from '../../../contexts/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 { i18n } from '@kbn/i18n';
import { FieldType } from 'ui/index_patterns';
import { timefilter } from 'ui/timefilter';
import {
@ -22,7 +21,12 @@ import {
EuiSpacer,
EuiTitle,
} 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 { ML_JOB_FIELD_TYPES } from '../../../../common/constants/field_types';
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.
let indexedFieldTypes: ML_JOB_FIELD_TYPES[] = [];
const indexPatternFields: FieldType[] = currentIndexPattern.fields;
const indexPatternFields: IFieldType[] = currentIndexPattern.fields;
indexPatternFields.forEach(field => {
if (field.scripted !== true) {
const dataVisualizerType: ML_JOB_FIELD_TYPES | undefined = kbnTypeToMLJobType(field);

View file

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

View file

@ -4,7 +4,6 @@
* 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 { JobCreator } from './job_creator';
@ -15,6 +14,7 @@ import { JOB_TYPE } from '../../../../../../common/constants/new_job';
import { getRichDetectors } from './util/general';
import { isValidJson } from '../../../../../../common/util/validation_utils';
import { ml } from '../../../../services/ml_api_service';
import { IndexPattern } from '../../../../../../../../../../src/plugins/data/public';
export interface RichDetector {
agg: Aggregation | null;

View file

@ -4,7 +4,6 @@
* 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 { UrlConfig } from '../../../../../../common/types/custom_urls';
import { IndexPatternTitle } from '../../../../../../common/types/kibana';
@ -24,6 +23,7 @@ import { isSparseDataJob } from './util/general';
import { parseInterval } from '../../../../../../common/util/parse_interval';
import { Calendar } from '../../../../../../common/types/calendars';
import { mlCalendarService } from '../../../../services/calendar_service';
import { IndexPattern } from '../../../../../../../../../../src/plugins/data/public';
export class JobCreator {
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.
*/
import { IndexPattern } from 'ui/index_patterns';
import { SavedSearchSavedObject } from '../../../../../../common/types/kibana';
import { SingleMetricJobCreator } from './single_metric_job_creator';
import { MultiMetricJobCreator } from './multi_metric_job_creator';
import { PopulationJobCreator } from './population_job_creator';
import { AdvancedJobCreator } from './advanced_job_creator';
import { IndexPattern } from '../../../../../../../../../../src/plugins/data/public';
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.
*/
import { IndexPattern } from 'ui/index_patterns';
import { SavedSearchSavedObject } from '../../../../../../common/types/kibana';
import { JobCreator } from './job_creator';
import {
@ -22,6 +21,7 @@ import {
} from '../../../../../../common/constants/new_job';
import { ml } from '../../../../services/ml_api_service';
import { getRichDetectors } from './util/general';
import { IndexPattern } from '../../../../../../../../../../src/plugins/data/public';
export class MultiMetricJobCreator extends JobCreator {
// 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.
*/
import { IndexPattern } from 'ui/index_patterns';
import { SavedSearchSavedObject } from '../../../../../../common/types/kibana';
import { JobCreator } from './job_creator';
import {
@ -17,6 +16,7 @@ import { Job, Datafeed, Detector } from './configs';
import { createBasicDetector } from './util/default_configs';
import { JOB_TYPE, CREATED_BY_LABEL } from '../../../../../../common/constants/new_job';
import { getRichDetectors } from './util/general';
import { IndexPattern } from '../../../../../../../../../../src/plugins/data/public';
export class PopulationJobCreator extends JobCreator {
// 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.
*/
import { IndexPattern } from 'ui/index_patterns';
import { SavedSearchSavedObject } from '../../../../../../common/types/kibana';
import { parseInterval } from '../../../../../../common/util/parse_interval';
import { JobCreator } from './job_creator';
@ -17,6 +16,7 @@ import {
} from '../../../../../../common/constants/aggregation_types';
import { JOB_TYPE, CREATED_BY_LABEL } from '../../../../../../common/constants/new_job';
import { getRichDetectors } from './util/general';
import { IndexPattern } from '../../../../../../../../../../src/plugins/data/public';
export class SingleMetricJobCreator extends JobCreator {
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.
*/
import { IndexPattern } from 'ui/index_patterns';
import { esQuery, Query, esKuery } from '../../../../../../../../../src/plugins/data/public';
import {
IndexPattern,
esQuery,
Query,
esKuery,
} from '../../../../../../../../../src/plugins/data/public';
import { KibanaConfigTypeFix } from '../../../contexts/kibana';
import { SEARCH_QUERY_LANGUAGE } from '../../../../../common/constants/search';
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.
*/
import { IndexPattern } from 'ui/index_patterns';
import { mlFunctionToESAggregation } from '../../../common/util/job_utils';
import { getIndexPatternById, getIndexPatternIdFromName } from '../util/index_utils';
import { mlJobService } from './job_service';
import { IndexPattern } from '../../../../../../../src/plugins/data/public';
type FormatsByJobId = Record<string, any>;
type IndexPatternIdsByJob = Record<string, any>;

View file

@ -5,7 +5,7 @@
*/
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..`
// 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.
*/
import { FieldType } from 'ui/index_patterns';
import { KBN_FIELD_TYPES } from '../../../../../../../src/plugins/data/public';
import { IFieldType, KBN_FIELD_TYPES } from '../../../../../../../src/plugins/data/public';
import { ML_JOB_FIELD_TYPES } from '../../../common/constants/field_types';
import {
kbnTypeToMLJobType,
@ -16,7 +15,7 @@ import {
describe('ML - field type utils', () => {
describe('kbnTypeToMLJobType', () => {
test('returns correct ML_JOB_FIELD_TYPES for KBN_FIELD_TYPES', () => {
const field: FieldType = {
const field: IFieldType = {
type: KBN_FIELD_TYPES.NUMBER,
name: KBN_FIELD_TYPES.NUMBER,
aggregatable: true,
@ -37,7 +36,7 @@ describe('ML - field type utils', () => {
});
test('returns ML_JOB_FIELD_TYPES.KEYWORD for aggregatable KBN_FIELD_TYPES.STRING', () => {
const field: FieldType = {
const field: IFieldType = {
type: KBN_FIELD_TYPES.STRING,
name: KBN_FIELD_TYPES.STRING,
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', () => {
const field: FieldType = {
const field: IFieldType = {
type: KBN_FIELD_TYPES.STRING,
name: KBN_FIELD_TYPES.STRING,
aggregatable: false,
@ -55,7 +54,7 @@ describe('ML - field type utils', () => {
});
test('returns undefined for non-aggregatable "foo"', () => {
const field: FieldType = {
const field: IFieldType = {
type: 'foo',
name: 'foo',
aggregatable: false,

View file

@ -5,15 +5,14 @@
*/
import { i18n } from '@kbn/i18n';
import { FieldType } from 'ui/index_patterns';
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
// 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
export function kbnTypeToMLJobType(field: FieldType) {
export function kbnTypeToMLJobType(field: IFieldType) {
// Return undefined if not one of the supported data visualizer field types.
let type;
switch (field.type) {

View file

@ -12,7 +12,7 @@ import {
MONTH,
YEAR,
} 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';
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));
}, Promise.resolve());
});

View file

@ -26,12 +26,13 @@ import {
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
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 { logisticalDetailsUrl, cronUrl } from '../../../services';
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(' ');
export class StepLogisticsUi extends Component {

View file

@ -7,8 +7,7 @@
import React from '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) {
if (!indexPattern || !indexPattern.trim()) {
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)) {
chars.push(char);
}

View file

@ -6,14 +6,14 @@
import { DefaultOperator } from 'elasticsearch';
import { IndexPattern } from 'ui/index_patterns';
import { dictionaryToArray } from '../../../common/types/common';
import { SavedSearchQuery } from '../lib/kibana';
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 { IndexPattern } from '../../../../../../../src/plugins/data/public';
import {
getEsAggFromAggConfig,
getEsAggFromGroupByConfig,

View file

@ -5,8 +5,11 @@
*/
import { SavedObjectsClientContract, IUiSettingsClient } from 'src/core/public';
import { IndexPattern as IndexPatternType } from 'ui/index_patterns';
import { esQuery, IndexPatternsContract } from '../../../../../../../../src/plugins/data/public';
import {
IndexPattern,
esQuery,
IndexPatternsContract,
} from '../../../../../../../../src/plugins/data/public';
type IndexPatternId = 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.
export function createSearchItems(
indexPattern: IndexPatternType | undefined,
indexPattern: IndexPattern | undefined,
savedSearch: any,
config: IUiSettingsClient
) {

View file

@ -14,7 +14,7 @@ import {
} 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', () => {
test('getPivotDropdownOptions()', () => {

View file

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

View file

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

View file

@ -6,13 +6,15 @@
import { useEffect, useState } from 'react';
import { IndexPattern } from 'ui/index_patterns';
import { dictionaryToArray } from '../../../../../../common/types/common';
import { useApi } from '../../../../hooks/use_api';
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 {
getPreviewRequestBody,
PreviewRequestBody,